Skip to content

Commit

Permalink
[utils] Allow nested imports for MUI-X
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Jun 14, 2023
1 parent 6e8b99d commit a78c098
Show file tree
Hide file tree
Showing 41 changed files with 33 additions and 26 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/mui-utils/src/HTMLElementType/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './HTMLElementType';
1 change: 0 additions & 1 deletion packages/mui-utils/src/capitalize.d.ts

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import MuiError from '../macros/MuiError.macro';
import MuiError from '../../macros/MuiError.macro';

// It should to be noted that this function isn't equivalent to `text-transform: capitalize`.
//
// A strict capitalization should uppercase the first letter of each word in the sentence.
// We only handle the first word.
export default function capitalize(string) {
export default function capitalize(string: string): string {
if (typeof string !== 'string') {
throw new MuiError('MUI: `capitalize(string)` expects a string argument.');
}
Expand Down
1 change: 1 addition & 0 deletions packages/mui-utils/src/capitalize/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './capitalize';
File renamed without changes.
1 change: 1 addition & 0 deletions packages/mui-utils/src/chainPropTypes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './chainPropTypes';
8 changes: 0 additions & 8 deletions packages/mui-utils/src/debounce.d.ts

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
export interface Cancelable {
clear(): void;
}

// Corresponds to 10 frames at 60 Hz.
// A few bytes payload overhead when lodash/debounce is ~3 kB and debounce ~300 B.
export default function debounce(func, wait = 166) {
let timeout;
function debounced(...args) {
export default function debounce<T extends (...args: any[]) => any>(func: T, wait = 166) {
let timeout: ReturnType<typeof setTimeout>;
function debounced(...args: Parameters<T>) {
const later = () => {
// @ts-ignore
func.apply(this, args);
};
clearTimeout(timeout);
Expand All @@ -14,5 +19,5 @@ export default function debounce(func, wait = 166) {
clearTimeout(timeout);
};

return debounced;
return debounced as T & Cancelable;
}
2 changes: 2 additions & 0 deletions packages/mui-utils/src/debounce/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './debounce';
export * from './debounce';
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/mui-utils/src/exactProp/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './exactProp';
1 change: 1 addition & 0 deletions packages/mui-utils/src/ownerDocument/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ownerDocument';
File renamed without changes.
1 change: 1 addition & 0 deletions packages/mui-utils/src/ownerWindow/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ownerWindow';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ownerDocument from './ownerDocument';
import ownerDocument from '../ownerDocument';

export default function ownerWindow(node: Node | undefined): Window {
const doc = ownerDocument(node);
Expand Down
1 change: 1 addition & 0 deletions packages/mui-utils/src/ponyfillGlobal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ponyfillGlobal';
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/mui-utils/src/setRef.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import { unstable_setRef as setRef } from '.';
import setRef from './setRef';

describe('setRef', () => {
it('can handle callback refs', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-utils/src/useControlled/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './useControlled';
export * from './useControlled';
1 change: 1 addition & 0 deletions packages/mui-utils/src/useControlled/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './useControlled';
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions packages/mui-utils/src/useEnhancedEffect.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/mui-utils/src/useEnhancedEffect/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './useEnhancedEffect';
File renamed without changes.
1 change: 1 addition & 0 deletions packages/mui-utils/src/useEventCallback/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './useEventCallback';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import useEnhancedEffect from './useEnhancedEffect';
import useEnhancedEffect from '../useEnhancedEffect';

/**
* https://github.com/facebook/react/issues/14099#issuecomment-440013892
Expand Down
1 change: 1 addition & 0 deletions packages/mui-utils/src/useForkRef/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './useForkRef';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, screen } from 'test/utils';
import { unstable_useForkRef as useForkRef } from '.';
import useForkRef from './useForkRef';

describe('useForkRef', () => {
const { render } = createRenderer();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import setRef from './setRef';
import setRef from '../setRef';

export default function useForkRef<Instance>(
...refs: Array<React.Ref<Instance> | undefined>
Expand Down
1 change: 1 addition & 0 deletions packages/mui-utils/src/useId/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './useId';
File renamed without changes.
File renamed without changes.

0 comments on commit a78c098

Please sign in to comment.