@fluentui/react-utilities 0.0.0-nightly99adff5a9a20211125.1 → 0.0.0-nightlya9c3d10d9520220113.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +56 -3
- package/CHANGELOG.md +16 -4
- package/dist/react-utilities.d.ts +24 -35
- package/lib/compose/getSlots.d.ts +5 -4
- package/lib/compose/getSlots.js +6 -4
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/types.d.ts +1 -1
- package/lib/hooks/index.d.ts +0 -1
- package/lib/hooks/index.js +0 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useControllableState.d.ts +16 -6
- package/lib/hooks/useControllableState.js +13 -8
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/utils/applyTriggerPropsToChildren.d.ts +1 -1
- package/lib/utils/onlyChild.d.ts +1 -1
- package/lib/utils/properties.js +40 -20
- package/lib/utils/properties.js.map +1 -1
- package/lib-commonjs/compose/getSlots.d.ts +5 -4
- package/lib-commonjs/compose/getSlots.js +6 -4
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/types.d.ts +1 -1
- package/lib-commonjs/hooks/index.d.ts +0 -1
- package/lib-commonjs/hooks/index.js +0 -2
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.d.ts +16 -6
- package/lib-commonjs/hooks/useControllableState.js +13 -8
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +1 -1
- package/lib-commonjs/utils/onlyChild.d.ts +1 -1
- package/lib-commonjs/utils/properties.js +40 -20
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/package.json +2 -6
- package/lib/hooks/useControllableValue.d.ts +0 -20
- package/lib/hooks/useControllableValue.js +0 -57
- package/lib/hooks/useControllableValue.js.map +0 -1
- package/lib-commonjs/hooks/useControllableValue.d.ts +0 -20
- package/lib-commonjs/hooks/useControllableValue.js +0 -68
- package/lib-commonjs/hooks/useControllableValue.js.map +0 -1
package/CHANGELOG.json
CHANGED
@@ -2,9 +2,62 @@
|
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "Thu,
|
6
|
-
"tag": "@fluentui/react-utilities_v0.0.0-
|
7
|
-
"version": "0.0.0-
|
5
|
+
"date": "Thu, 13 Jan 2022 04:15:38 GMT",
|
6
|
+
"tag": "@fluentui/react-utilities_v0.0.0-nightlya9c3d10d9520220113.1",
|
7
|
+
"version": "0.0.0-nightlya9c3d10d9520220113.1",
|
8
|
+
"comments": {
|
9
|
+
"prerelease": [
|
10
|
+
{
|
11
|
+
"author": "email not defined",
|
12
|
+
"package": "@fluentui/react-utilities",
|
13
|
+
"commit": "e5182b449d13b07c2da6a36ece6f79ec664c4075",
|
14
|
+
"comment": "Release nightly v9"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "behowell@microsoft.com",
|
18
|
+
"package": "@fluentui/react-utilities",
|
19
|
+
"commit": "7cc28ed8320b00f42d91c63882f10316db2205c5",
|
20
|
+
"comment": "getSlots: remove slotNames param, and infer from state.components instead"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "elcraig@microsoft.com",
|
24
|
+
"package": "@fluentui/react-utilities",
|
25
|
+
"commit": "39ce3cbcf15ce2619649e1eddccf932736ceac07",
|
26
|
+
"comment": "[breaking] Remove useControllableValue hook (use useControllableState instead)"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"author": "beachball",
|
30
|
+
"package": "@fluentui/react-utilities",
|
31
|
+
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightlya9c3d10d9520220113.1",
|
32
|
+
"commit": "e5182b449d13b07c2da6a36ece6f79ec664c4075"
|
33
|
+
}
|
34
|
+
],
|
35
|
+
"none": [
|
36
|
+
{
|
37
|
+
"author": "elcraig@microsoft.com",
|
38
|
+
"package": "@fluentui/react-utilities",
|
39
|
+
"commit": "3360b45ec159250b1346c91afad7dce138e6bc20",
|
40
|
+
"comment": "Update API file to version generated by typescript 4.3"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"author": "seanmonahan@microsoft.com",
|
44
|
+
"package": "@fluentui/react-utilities",
|
45
|
+
"commit": "6404bef16cebf1f67b9b80a9f6d5f605f9873df1",
|
46
|
+
"comment": "Update getSlots() docs."
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"author": "lingfangao@hotmail.com",
|
50
|
+
"package": "@fluentui/react-utilities",
|
51
|
+
"commit": "a4e048a0e03ddd676670da516e3a6612b26ea500",
|
52
|
+
"comment": "chore: Remove enzyme from react-utilities tests"
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"date": "Thu, 25 Nov 2021 08:34:09 GMT",
|
59
|
+
"tag": "@fluentui/react-utilities_v9.0.0-beta.4",
|
60
|
+
"version": "9.0.0-beta.4",
|
8
61
|
"comments": {
|
9
62
|
"none": [
|
10
63
|
{
|
package/CHANGELOG.md
CHANGED
@@ -1,13 +1,25 @@
|
|
1
1
|
# Change Log - @fluentui/react-utilities
|
2
2
|
|
3
|
-
This log was last generated on Thu,
|
3
|
+
This log was last generated on Thu, 13 Jan 2022 04:15:38 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-
|
7
|
+
## [0.0.0-nightlya9c3d10d9520220113.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v0.0.0-nightlya9c3d10d9520220113.1)
|
8
8
|
|
9
|
-
Thu,
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-beta.
|
9
|
+
Thu, 13 Jan 2022 04:15:38 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-beta.4..@fluentui/react-utilities_v0.0.0-nightlya9c3d10d9520220113.1)
|
11
|
+
|
12
|
+
### Changes
|
13
|
+
|
14
|
+
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/e5182b449d13b07c2da6a36ece6f79ec664c4075) by email not defined)
|
15
|
+
- getSlots: remove slotNames param, and infer from state.components instead ([PR #21134](https://github.com/microsoft/fluentui/pull/21134) by behowell@microsoft.com)
|
16
|
+
- [breaking] Remove useControllableValue hook (use useControllableState instead) ([PR #20865](https://github.com/microsoft/fluentui/pull/20865) by elcraig@microsoft.com)
|
17
|
+
- Bump @fluentui/keyboard-keys to v0.0.0-nightlya9c3d10d9520220113.1 ([commit](https://github.com/microsoft/fluentui/commit/e5182b449d13b07c2da6a36ece6f79ec664c4075) by beachball)
|
18
|
+
|
19
|
+
## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.0.0-beta.4)
|
20
|
+
|
21
|
+
Thu, 25 Nov 2021 08:34:09 GMT
|
22
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-beta.3..@fluentui/react-utilities_v9.0.0-beta.4)
|
11
23
|
|
12
24
|
### Changes
|
13
25
|
|
@@ -11,7 +11,7 @@ export declare const anchorProperties: Record<string, number>;
|
|
11
11
|
/**
|
12
12
|
* Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
|
13
13
|
*/
|
14
|
-
export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React_2.ReactElement<any, string |
|
14
|
+
export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React_2.ReactElement<any, string | React_2.JSXElementConstructor<any>> | ((props: TTriggerProps) => React_2.ReactNode) | null | undefined, triggerProps: TTriggerProps) => React_2.ReactNode;
|
15
15
|
|
16
16
|
/**
|
17
17
|
* Helper type for inferring the type of the as prop from a Props type.
|
@@ -58,8 +58,6 @@ export declare const buttonProperties: Record<string, number>;
|
|
58
58
|
*/
|
59
59
|
export declare function canUseDOM(): boolean;
|
60
60
|
|
61
|
-
export declare type ChangeCallback<TElement extends HTMLElement, TValue, TEvent extends React_2.SyntheticEvent<TElement> | undefined> = (ev: TEvent, newValue: TValue | undefined) => void;
|
62
|
-
|
63
61
|
/**
|
64
62
|
* Clamps `value` to a number between the min and max.
|
65
63
|
*
|
@@ -78,7 +76,7 @@ export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord
|
|
78
76
|
}, Primary & 'root'> & PropsWithoutRef<Shorthands[Primary]>;
|
79
77
|
|
80
78
|
export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord> = {
|
81
|
-
components
|
79
|
+
components: {
|
82
80
|
[Key in keyof Shorthands]-?: React_2.ComponentType<NonNullable<Shorthands[Key]> extends ObjectShorthandProps<infer P> ? P : NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
|
83
81
|
};
|
84
82
|
} & Shorthands;
|
@@ -100,11 +98,6 @@ export declare type DefaultObjectShorthandProps = ObjectShorthandProps<Pick<Reac
|
|
100
98
|
*/
|
101
99
|
export declare const defaultSSRContextValue: SSRContextValue;
|
102
100
|
|
103
|
-
/**
|
104
|
-
* Default value can be a value or an initializer
|
105
|
-
*/
|
106
|
-
declare type DefaultValue<TValue> = TValue | (() => TValue);
|
107
|
-
|
108
101
|
/**
|
109
102
|
* An array of DIV tag properties and events.
|
110
103
|
*
|
@@ -186,14 +179,15 @@ export declare const getRTLSafeKey: (key: string, dir: 'ltr' | 'rtl') => string;
|
|
186
179
|
* Slots will render as null if they are rendered as primitives with undefined children.
|
187
180
|
*
|
188
181
|
* The slotProps will always omit the `as` prop within them, and for slots that are string
|
189
|
-
* primitives, the props will be filtered according
|
190
|
-
* slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
182
|
+
* primitives, the props will be filtered according to the slot type by the type system.
|
183
|
+
* For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
184
|
+
* anchor props. Note that this is only enforced at build time by Typescript -- there is no
|
185
|
+
* runtime code filtering props in this function.
|
191
186
|
*
|
192
187
|
* @param state - State including slot definitions
|
193
|
-
* @param slotNames - Name of which props are slots
|
194
188
|
* @returns An object containing the `slots` map and `slotProps` map.
|
195
189
|
*/
|
196
|
-
export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R
|
190
|
+
export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R>): {
|
197
191
|
slots: Slots<R>;
|
198
192
|
slotProps: SlotProps<R>;
|
199
193
|
};
|
@@ -335,7 +329,7 @@ export declare function omit<TObj extends Record<string, any>, Exclusions extend
|
|
335
329
|
/**
|
336
330
|
* Similar to React.Children.only, but drills into fragments rather than treating them as a single child
|
337
331
|
*/
|
338
|
-
export declare const onlyChild: <P>(child:
|
332
|
+
export declare const onlyChild: <P>(child: boolean | React_2.ReactText | React_2.ReactFragment | React_2.ReactPortal | React_2.ReactElement<P, string | React_2.JSXElementConstructor<any>> | null | undefined) => React_2.ReactElement<P, string | React_2.JSXElementConstructor<any>>;
|
339
333
|
|
340
334
|
export declare const optionProperties: Record<string, number>;
|
341
335
|
|
@@ -493,42 +487,37 @@ export declare type UseBooleanCallbacks = {
|
|
493
487
|
export declare function useConst<T>(initialValue: T | (() => T)): T;
|
494
488
|
|
495
489
|
/**
|
496
|
-
* A useState
|
497
|
-
*
|
498
|
-
*
|
490
|
+
* A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
|
491
|
+
* such as a checked state or text input string.
|
492
|
+
*
|
493
|
+
* Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
|
494
|
+
* controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
|
495
|
+
*
|
496
|
+
* @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
|
497
|
+
* of the current value and an updater (dispatch) function. The updater function is referentially
|
498
|
+
* stable (won't change during the component's lifecycle). It can take either a new value, or a
|
499
|
+
* function which is passed the previous value and returns the new value. Unlike `setState`, calls
|
500
|
+
* to the updater function will only be respected if the component is uncontrolled.
|
501
|
+
* @see https://reactjs.org/docs/uncontrolled-components.html
|
499
502
|
*/
|
500
503
|
export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React_2.Dispatch<React_2.SetStateAction<State>>];
|
501
504
|
|
502
505
|
export declare type UseControllableStateOptions<State> = {
|
503
506
|
/**
|
504
|
-
* User
|
507
|
+
* User-provided default state or initializer, for uncontrolled usage.
|
505
508
|
*/
|
506
509
|
defaultState?: State | (() => State);
|
507
510
|
/**
|
508
|
-
* User
|
511
|
+
* User-provided controlled state. `undefined` means internal state will be used.
|
509
512
|
*/
|
510
513
|
state: State | undefined;
|
511
514
|
/**
|
512
|
-
* Used
|
515
|
+
* Used as the initial state if `state` and `defaultState` are both `undefined`.
|
516
|
+
* If `undefined` is the correct initial state, pass that here.
|
513
517
|
*/
|
514
518
|
initialState: State;
|
515
519
|
};
|
516
520
|
|
517
|
-
/**
|
518
|
-
* Hook to manage a value that could be either controlled or uncontrolled, such as a checked state or
|
519
|
-
* text box string.
|
520
|
-
* @param controlledValue - The controlled value passed in the props. This value will always be used if provided,
|
521
|
-
* and the internal state will be updated to reflect it.
|
522
|
-
* @param defaultUncontrolledValue - Initial value for the internal state in the uncontrolled case.
|
523
|
-
* @returns An array of the current value and an updater callback. Like `React.useState`, the updater
|
524
|
-
* callback always has the same identity, and it can take either a new value, or a function which
|
525
|
-
* is passed the previous value and returns the new value.
|
526
|
-
* @see https://reactjs.org/docs/uncontrolled-components.html
|
527
|
-
*/
|
528
|
-
export declare function useControllableValue<TValue, TElement extends HTMLElement>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>): Readonly<[TValue, (update: React_2.SetStateAction<TValue>) => void]>;
|
529
|
-
|
530
|
-
export declare function useControllableValue<TValue, TElement extends HTMLElement, TEvent extends React_2.SyntheticEvent<TElement> | undefined>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>, onChange: ChangeCallback<TElement, TValue, TEvent>): Readonly<[TValue, (update: React_2.SetStateAction<TValue>, ev?: React_2.FormEvent<TElement>) => void]>;
|
531
|
-
|
532
521
|
/**
|
533
522
|
* https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
|
534
523
|
*
|
@@ -15,14 +15,15 @@ declare type SlotProps<S extends ObjectShorthandPropsRecord> = {
|
|
15
15
|
* Slots will render as null if they are rendered as primitives with undefined children.
|
16
16
|
*
|
17
17
|
* The slotProps will always omit the `as` prop within them, and for slots that are string
|
18
|
-
* primitives, the props will be filtered according
|
19
|
-
* slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
18
|
+
* primitives, the props will be filtered according to the slot type by the type system.
|
19
|
+
* For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
20
|
+
* anchor props. Note that this is only enforced at build time by Typescript -- there is no
|
21
|
+
* runtime code filtering props in this function.
|
20
22
|
*
|
21
23
|
* @param state - State including slot definitions
|
22
|
-
* @param slotNames - Name of which props are slots
|
23
24
|
* @returns An object containing the `slots` map and `slotProps` map.
|
24
25
|
*/
|
25
|
-
export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R
|
26
|
+
export declare function getSlots<R extends ObjectShorthandPropsRecord>(state: ComponentState<R>): {
|
26
27
|
slots: Slots<R>;
|
27
28
|
slotProps: SlotProps<R>;
|
28
29
|
};
|
package/lib/compose/getSlots.js
CHANGED
@@ -10,17 +10,19 @@ import { omit } from '../utils/omit';
|
|
10
10
|
* Slots will render as null if they are rendered as primitives with undefined children.
|
11
11
|
*
|
12
12
|
* The slotProps will always omit the `as` prop within them, and for slots that are string
|
13
|
-
* primitives, the props will be filtered according
|
14
|
-
* slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
13
|
+
* primitives, the props will be filtered according to the slot type by the type system.
|
14
|
+
* For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
15
|
+
* anchor props. Note that this is only enforced at build time by Typescript -- there is no
|
16
|
+
* runtime code filtering props in this function.
|
15
17
|
*
|
16
18
|
* @param state - State including slot definitions
|
17
|
-
* @param slotNames - Name of which props are slots
|
18
19
|
* @returns An object containing the `slots` map and `slotProps` map.
|
19
20
|
*/
|
20
21
|
|
21
|
-
export function getSlots(state
|
22
|
+
export function getSlots(state) {
|
22
23
|
const slots = {};
|
23
24
|
const slotProps = {};
|
25
|
+
const slotNames = Object.keys(state.components);
|
24
26
|
|
25
27
|
for (const slotName of slotNames) {
|
26
28
|
const [slot, props] = getSlot(state, slotName);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/compose/getSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAUA,SAAS,UAAT,QAA2B,cAA3B;AACA,SAAS,IAAT,QAAqB,eAArB;AAqBA
|
1
|
+
{"version":3,"sources":["../../src/compose/getSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAUA,SAAS,UAAT,QAA2B,cAA3B;AACA,SAAS,IAAT,QAAqB,eAArB;AAqBA;;;;;;;;;;;;;;;;AAgBG;;AACH,OAAM,SAAU,QAAV,CACJ,KADI,EACoB;AAKxB,QAAM,KAAK,GAAG,EAAd;AACA,QAAM,SAAS,GAAG,EAAlB;AAEA,QAAM,SAAS,GAAgB,MAAM,CAAC,IAAP,CAAY,KAAK,CAAC,UAAlB,CAA/B;;AACA,OAAK,MAAM,QAAX,IAAuB,SAAvB,EAAkC;AAChC,UAAM,CAAC,IAAD,EAAO,KAAP,IAAgB,OAAO,CAAC,KAAD,EAAQ,QAAR,CAA7B;AACA,IAAA,KAAK,CAAC,QAAD,CAAL,GAAkB,IAAlB;AACA,IAAA,SAAS,CAAC,QAAD,CAAT,GAAsB,KAAtB;AACD;;AACD,SAAO;AAAE,IAAA,KAAF;AAAS,IAAA,SAAS,EAAG;AAArB,GAAP;AACD;;A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AK,CAAC,QAAD,CAA5E;AAEA,SAAO,CAAC,IAAD,EAAO,SAAP,CAAP;AACD","sourceRoot":""}
|
package/lib/compose/types.d.ts
CHANGED
@@ -79,7 +79,7 @@ export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord
|
|
79
79
|
[Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>;
|
80
80
|
}, Primary & 'root'> & PropsWithoutRef<Shorthands[Primary]>;
|
81
81
|
export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord> = {
|
82
|
-
components
|
82
|
+
components: {
|
83
83
|
[Key in keyof Shorthands]-?: React.ComponentType<NonNullable<Shorthands[Key]> extends ObjectShorthandProps<infer P> ? P : NonNullable<Shorthands[Key]>> | (NonNullable<Shorthands[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
|
84
84
|
};
|
85
85
|
} & Shorthands;
|
package/lib/hooks/index.d.ts
CHANGED
package/lib/hooks/index.js
CHANGED
package/lib/hooks/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC"}
|
@@ -1,21 +1,31 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
export declare type UseControllableStateOptions<State> = {
|
3
3
|
/**
|
4
|
-
* User
|
4
|
+
* User-provided default state or initializer, for uncontrolled usage.
|
5
5
|
*/
|
6
6
|
defaultState?: State | (() => State);
|
7
7
|
/**
|
8
|
-
* User
|
8
|
+
* User-provided controlled state. `undefined` means internal state will be used.
|
9
9
|
*/
|
10
10
|
state: State | undefined;
|
11
11
|
/**
|
12
|
-
* Used
|
12
|
+
* Used as the initial state if `state` and `defaultState` are both `undefined`.
|
13
|
+
* If `undefined` is the correct initial state, pass that here.
|
13
14
|
*/
|
14
15
|
initialState: State;
|
15
16
|
};
|
16
17
|
/**
|
17
|
-
* A useState
|
18
|
-
*
|
19
|
-
*
|
18
|
+
* A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
|
19
|
+
* such as a checked state or text input string.
|
20
|
+
*
|
21
|
+
* Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
|
22
|
+
* controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
|
23
|
+
*
|
24
|
+
* @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
|
25
|
+
* of the current value and an updater (dispatch) function. The updater function is referentially
|
26
|
+
* stable (won't change during the component's lifecycle). It can take either a new value, or a
|
27
|
+
* function which is passed the previous value and returns the new value. Unlike `setState`, calls
|
28
|
+
* to the updater function will only be respected if the component is uncontrolled.
|
29
|
+
* @see https://reactjs.org/docs/uncontrolled-components.html
|
20
30
|
*/
|
21
31
|
export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React.Dispatch<React.SetStateAction<State>>];
|
@@ -1,23 +1,28 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { useConst } from './useConst';
|
3
3
|
|
4
|
-
function isUndefined(state) {
|
5
|
-
return typeof state === 'undefined';
|
6
|
-
}
|
7
|
-
|
8
4
|
function isFactoryDispatch(newState) {
|
9
5
|
return typeof newState === 'function';
|
10
6
|
}
|
11
7
|
/**
|
12
|
-
* A useState
|
13
|
-
*
|
14
|
-
*
|
8
|
+
* A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
|
9
|
+
* such as a checked state or text input string.
|
10
|
+
*
|
11
|
+
* Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
|
12
|
+
* controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
|
13
|
+
*
|
14
|
+
* @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
|
15
|
+
* of the current value and an updater (dispatch) function. The updater function is referentially
|
16
|
+
* stable (won't change during the component's lifecycle). It can take either a new value, or a
|
17
|
+
* function which is passed the previous value and returns the new value. Unlike `setState`, calls
|
18
|
+
* to the updater function will only be respected if the component is uncontrolled.
|
19
|
+
* @see https://reactjs.org/docs/uncontrolled-components.html
|
15
20
|
*/
|
16
21
|
|
17
22
|
|
18
23
|
export const useControllableState = options => {
|
19
24
|
const isControlled = useIsControlled(options.state);
|
20
|
-
const initialState =
|
25
|
+
const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;
|
21
26
|
const [internalState, setInternalState] = React.useState(initialState);
|
22
27
|
const state = isControlled ? options.state : internalState;
|
23
28
|
const stateRef = React.useRef(state);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,YAAzB;;
|
1
|
+
{"version":3,"sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,YAAzB;;AAkBA,SAAS,iBAAT,CAAkC,QAAlC,EAAuE;AACrE,SAAO,OAAO,QAAP,KAAoB,UAA3B;AACD;AAED;;;;;;;;;;;;;AAaG;;;AAC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,MAAA,UAAU,CAAC,OAAX,GAAqB,CAAA,EAAA,GAAA,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAE,WAAhB,MAA2B,IAA3B,IAA2B,EAAA,KAAA,KAAA,CAA3B,GAA2B,KAAA,CAA3B,GAA2B,EAAA,CAAE,WAAF,CAAc,MAAK;AACjE,cAAM,aAAa,GAAG,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAE,aAAtC;;AACA,YAAI,CAAA,aAAa,KAAA,IAAb,IAAA,aAAa,KAAA,KAAA,CAAb,GAAa,KAAA,CAAb,GAAA,aAAa,CAAE,OAAf,MAA2B,QAA/B,EAAyC;AACvC,gBAAM,KAAK,GAAG,IAAI,WAAJ,CAAgB,eAAhB,EAAiC;AAAE,YAAA,OAAO,EAAE;AAAX,WAAjC,CAAd;AACA,UAAA,aAAa,CAAC,aAAd,CAA4B,KAA5B;AACD;AACF,OAN+C,EAM7C,YAN6C,CAAhD;AAOD;;AACD,WAAO,MAAK;;;AACV,OAAA,EAAA,GAAA,cAAc,KAAA,IAAd,IAAA,cAAc,KAAA,KAAA,CAAd,GAAc,KAAA,CAAd,GAAA,cAAc,CAAE,WAAhB,MAA2B,IAA3B,IAA2B,EAAA,KAAA,KAAA,CAA3B,GAA2B,KAAA,CAA3B,GAA2B,EAAA,CAAE,YAAF,CAAe,UAAU,CAAC,OAA1B,CAA3B;AACD,KAFD;AAGD,GAbD,EAaG,CAAC,cAAD,EAAiB,wBAAjB,EAA2C,YAA3C,CAbH;AAcD,CAvCD","sourceRoot":""}
|
@@ -2,4 +2,4 @@ import * as React from 'react';
|
|
2
2
|
/**
|
3
3
|
* Apply the trigger props to the children, either by calling the render function, or cloning with the new props.
|
4
4
|
*/
|
5
|
-
export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React.ReactElement<any, string |
|
5
|
+
export declare const applyTriggerPropsToChildren: <TTriggerProps>(children: React.ReactElement<any, string | React.JSXElementConstructor<any>> | ((props: TTriggerProps) => React.ReactNode) | null | undefined, triggerProps: TTriggerProps) => React.ReactNode;
|
package/lib/utils/onlyChild.d.ts
CHANGED
@@ -2,4 +2,4 @@ import * as React from 'react';
|
|
2
2
|
/**
|
3
3
|
* Similar to React.Children.only, but drills into fragments rather than treating them as a single child
|
4
4
|
*/
|
5
|
-
export declare const onlyChild: <P>(child:
|
5
|
+
export declare const onlyChild: <P>(child: boolean | React.ReactText | React.ReactFragment | React.ReactPortal | React.ReactElement<P, string | React.JSXElementConstructor<any>> | null | undefined) => React.ReactElement<P, string | React.JSXElementConstructor<any>>;
|
package/lib/utils/properties.js
CHANGED
@@ -25,7 +25,8 @@ export const baseElementEvents = /*#__PURE__*/toObjectMap(['onAuxClick', 'onCopy
|
|
25
25
|
* @public
|
26
26
|
*/
|
27
27
|
|
28
|
-
export const baseElementProperties = /*#__PURE__*/toObjectMap(['accessKey', 'children', 'className', 'contentEditable', 'dir', 'draggable', 'hidden', 'htmlFor', 'id', 'lang', 'ref', 'role', 'style', 'tabIndex', 'title', 'translate', 'spellCheck', 'name'
|
28
|
+
export const baseElementProperties = /*#__PURE__*/toObjectMap(['accessKey', 'children', 'className', 'contentEditable', 'dir', 'draggable', 'hidden', 'htmlFor', 'id', 'lang', 'ref', 'role', 'style', 'tabIndex', 'title', 'translate', 'spellCheck', 'name' // global
|
29
|
+
]);
|
29
30
|
/**
|
30
31
|
* An array of HTML element properties and events.
|
31
32
|
*
|
@@ -39,78 +40,90 @@ export const htmlElementProperties = /*#__PURE__*/toObjectMap(baseElementPropert
|
|
39
40
|
* @public
|
40
41
|
*/
|
41
42
|
|
42
|
-
export const labelProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['form'
|
43
|
+
export const labelProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['form' // button, fieldset, input, label, meter, object, output, select, textarea
|
44
|
+
]);
|
43
45
|
/**
|
44
46
|
* An array of AUDIO tag properties and events.
|
45
47
|
|
46
48
|
* @public
|
47
49
|
*/
|
48
50
|
|
49
|
-
export const audioProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['height', 'loop', 'muted', 'preload', 'src', 'width'
|
51
|
+
export const audioProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['height', 'loop', 'muted', 'preload', 'src', 'width' // canvas, embed, iframe, img, input, object, video
|
52
|
+
]);
|
50
53
|
/**
|
51
54
|
* An array of VIDEO tag properties and events.
|
52
55
|
*
|
53
56
|
* @public
|
54
57
|
*/
|
55
58
|
|
56
|
-
export const videoProperties = /*#__PURE__*/toObjectMap(audioProperties, ['poster'
|
59
|
+
export const videoProperties = /*#__PURE__*/toObjectMap(audioProperties, ['poster' // video
|
60
|
+
]);
|
57
61
|
/**
|
58
62
|
* An array of OL tag properties and events.
|
59
63
|
*
|
60
64
|
* @public
|
61
65
|
*/
|
62
66
|
|
63
|
-
export const olProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['start'
|
67
|
+
export const olProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['start' // ol
|
68
|
+
]);
|
64
69
|
/**
|
65
70
|
* An array of LI tag properties and events.
|
66
71
|
*
|
67
72
|
* @public
|
68
73
|
*/
|
69
74
|
|
70
|
-
export const liProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['value'
|
75
|
+
export const liProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['value' // button, input, li, option, meter, progress, param
|
76
|
+
]);
|
71
77
|
/**
|
72
78
|
* An array of A tag properties and events.
|
73
79
|
*
|
74
80
|
* @public
|
75
81
|
*/
|
76
82
|
|
77
|
-
export const anchorProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['download', 'href', 'hrefLang', 'media', 'rel', 'target', 'type'
|
83
|
+
export const anchorProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['download', 'href', 'hrefLang', 'media', 'rel', 'target', 'type' // a, button, input, link, menu, object, script, source, style
|
84
|
+
]);
|
78
85
|
/**
|
79
86
|
* An array of BUTTON tag properties and events.
|
80
87
|
*
|
81
88
|
* @public
|
82
89
|
*/
|
83
90
|
|
84
|
-
export const buttonProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['autoFocus', 'disabled', 'form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget', 'type', 'value'
|
91
|
+
export const buttonProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['autoFocus', 'disabled', 'form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget', 'type', 'value' // button, input, li, option, meter, progress, param,
|
92
|
+
]);
|
85
93
|
/**
|
86
94
|
* An array of INPUT tag properties and events.
|
87
95
|
*
|
88
96
|
* @public
|
89
97
|
*/
|
90
98
|
|
91
|
-
export const inputProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['accept', 'alt', 'autoCapitalize', 'autoComplete', 'checked', 'dirname', 'form', 'height', 'inputMode', 'list', 'max', 'maxLength', 'min', 'multiple', 'pattern', 'placeholder', 'readOnly', 'required', 'src', 'step', 'size', 'type', 'value', 'width'
|
99
|
+
export const inputProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['accept', 'alt', 'autoCapitalize', 'autoComplete', 'checked', 'dirname', 'form', 'height', 'inputMode', 'list', 'max', 'maxLength', 'min', 'multiple', 'pattern', 'placeholder', 'readOnly', 'required', 'src', 'step', 'size', 'type', 'value', 'width' // canvas, embed, iframe, img, input, object, video
|
100
|
+
]);
|
92
101
|
/**
|
93
102
|
* An array of TEXTAREA tag properties and events.
|
94
103
|
*
|
95
104
|
* @public
|
96
105
|
*/
|
97
106
|
|
98
|
-
export const textAreaProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['autoCapitalize', 'cols', 'dirname', 'form', 'maxLength', 'placeholder', 'readOnly', 'required', 'rows', 'wrap'
|
107
|
+
export const textAreaProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['autoCapitalize', 'cols', 'dirname', 'form', 'maxLength', 'placeholder', 'readOnly', 'required', 'rows', 'wrap' // textarea
|
108
|
+
]);
|
99
109
|
/**
|
100
110
|
* An array of SELECT tag properties and events.
|
101
111
|
*
|
102
112
|
* @public
|
103
113
|
*/
|
104
114
|
|
105
|
-
export const selectProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['form', 'multiple', 'required'
|
106
|
-
|
115
|
+
export const selectProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['form', 'multiple', 'required' // input, select, textarea
|
116
|
+
]);
|
117
|
+
export const optionProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['selected', 'value' // button, input, li, option, meter, progress, param
|
118
|
+
]);
|
107
119
|
/**
|
108
120
|
* An array of TABLE tag properties and events.
|
109
121
|
*
|
110
122
|
* @public
|
111
123
|
*/
|
112
124
|
|
113
|
-
export const tableProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['cellPadding', 'cellSpacing'
|
125
|
+
export const tableProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['cellPadding', 'cellSpacing' // table
|
126
|
+
]);
|
114
127
|
/**
|
115
128
|
* An array of TR tag properties and events.
|
116
129
|
*
|
@@ -124,37 +137,44 @@ export const trProperties = htmlElementProperties;
|
|
124
137
|
* @public
|
125
138
|
*/
|
126
139
|
|
127
|
-
export const thProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['rowSpan', 'scope'
|
140
|
+
export const thProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['rowSpan', 'scope' // th
|
141
|
+
]);
|
128
142
|
/**
|
129
143
|
* An array of TD tag properties and events.
|
130
144
|
*
|
131
145
|
* @public
|
132
146
|
*/
|
133
147
|
|
134
|
-
export const tdProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['colSpan', 'headers', 'rowSpan', 'scope'
|
135
|
-
|
136
|
-
export const
|
148
|
+
export const tdProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['colSpan', 'headers', 'rowSpan', 'scope' // th
|
149
|
+
]);
|
150
|
+
export const colGroupProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['span' // col, colgroup
|
151
|
+
]);
|
152
|
+
export const colProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['span' // col, colgroup
|
153
|
+
]);
|
137
154
|
/**
|
138
155
|
* An array of FORM tag properties and events.
|
139
156
|
*
|
140
157
|
* @public
|
141
158
|
*/
|
142
159
|
|
143
|
-
export const formProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['acceptCharset', 'action', 'encType', 'encType', 'method', 'noValidate', 'target'
|
160
|
+
export const formProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['acceptCharset', 'action', 'encType', 'encType', 'method', 'noValidate', 'target' // form
|
161
|
+
]);
|
144
162
|
/**
|
145
163
|
* An array of IFRAME tag properties and events.
|
146
164
|
*
|
147
165
|
* @public
|
148
166
|
*/
|
149
167
|
|
150
|
-
export const iframeProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['allow', 'allowFullScreen', 'allowPaymentRequest', 'allowTransparency', 'csp', 'height', 'importance', 'referrerPolicy', 'sandbox', 'src', 'srcDoc', 'width'
|
168
|
+
export const iframeProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['allow', 'allowFullScreen', 'allowPaymentRequest', 'allowTransparency', 'csp', 'height', 'importance', 'referrerPolicy', 'sandbox', 'src', 'srcDoc', 'width' // canvas, embed, iframe, img, input, object, video,
|
169
|
+
]);
|
151
170
|
/**
|
152
171
|
* An array of IMAGE tag properties and events.
|
153
172
|
*
|
154
173
|
* @public
|
155
174
|
*/
|
156
175
|
|
157
|
-
export const imgProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['alt', 'crossOrigin', 'height', 'src', 'srcSet', 'useMap', 'width'
|
176
|
+
export const imgProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['alt', 'crossOrigin', 'height', 'src', 'srcSet', 'useMap', 'width' // canvas, embed, iframe, img, input, object, video
|
177
|
+
]);
|
158
178
|
/**
|
159
179
|
* @deprecated Use imgProperties for img elements.
|
160
180
|
*/
|