@fluentui/react-utilities 0.0.0-nightlyc9ccb6f37d20211122.1 → 0.0.0-nightlyf1be0a972820211214.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 +49 -6
- package/CHANGELOG.md +16 -6
- package/dist/react-utilities.d.ts +47 -35
- package/lib/compose/getSlots.d.ts +4 -2
- package/lib/compose/getSlots.js +4 -2
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/types.d.ts +2 -3
- package/lib/compose/types.js.map +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/getNativeElementProps.d.ts +22 -0
- package/lib/utils/getNativeElementProps.js +22 -0
- package/lib/utils/getNativeElementProps.js.map +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 +4 -2
- package/lib-commonjs/compose/getSlots.js +4 -2
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/types.d.ts +2 -3
- package/lib-commonjs/compose/types.js.map +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/getNativeElementProps.d.ts +22 -0
- package/lib-commonjs/utils/getNativeElementProps.js +25 -1
- package/lib-commonjs/utils/getNativeElementProps.js.map +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 +5 -5
- 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,22 +2,65 @@
|
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-utilities_v0.0.0-
|
7
|
-
"version": "0.0.0-
|
5
|
+
"date": "Tue, 14 Dec 2021 04:16:20 GMT",
|
6
|
+
"tag": "@fluentui/react-utilities_v0.0.0-nightlyf1be0a972820211214.1",
|
7
|
+
"version": "0.0.0-nightlyf1be0a972820211214.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
11
11
|
"author": "email not defined",
|
12
12
|
"package": "@fluentui/react-utilities",
|
13
|
-
"commit": "
|
13
|
+
"commit": "3bda806f2deef1997fc6c070450a4a7aacb036ca",
|
14
14
|
"comment": "Release nightly v9"
|
15
15
|
},
|
16
|
+
{
|
17
|
+
"author": "elcraig@microsoft.com",
|
18
|
+
"package": "@fluentui/react-utilities",
|
19
|
+
"commit": "39ce3cbcf15ce2619649e1eddccf932736ceac07",
|
20
|
+
"comment": "[breaking] Remove useControllableValue hook (use useControllableState instead)"
|
21
|
+
},
|
16
22
|
{
|
17
23
|
"author": "beachball",
|
18
24
|
"package": "@fluentui/react-utilities",
|
19
|
-
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-
|
20
|
-
"commit": "
|
25
|
+
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightlyf1be0a972820211214.1",
|
26
|
+
"commit": "3bda806f2deef1997fc6c070450a4a7aacb036ca"
|
27
|
+
}
|
28
|
+
],
|
29
|
+
"none": [
|
30
|
+
{
|
31
|
+
"author": "elcraig@microsoft.com",
|
32
|
+
"package": "@fluentui/react-utilities",
|
33
|
+
"commit": "3360b45ec159250b1346c91afad7dce138e6bc20",
|
34
|
+
"comment": "Update API file to version generated by typescript 4.3"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"author": "seanmonahan@microsoft.com",
|
38
|
+
"package": "@fluentui/react-utilities",
|
39
|
+
"commit": "6404bef16cebf1f67b9b80a9f6d5f605f9873df1",
|
40
|
+
"comment": "Update getSlots() docs."
|
41
|
+
}
|
42
|
+
]
|
43
|
+
}
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"date": "Thu, 25 Nov 2021 08:34:09 GMT",
|
47
|
+
"tag": "@fluentui/react-utilities_v9.0.0-beta.4",
|
48
|
+
"version": "9.0.0-beta.4",
|
49
|
+
"comments": {
|
50
|
+
"none": [
|
51
|
+
{
|
52
|
+
"author": "lingfangao@hotmail.com",
|
53
|
+
"package": "@fluentui/react-utilities",
|
54
|
+
"commit": "718e63006d8d07d24efab9c32942041963d78dc7",
|
55
|
+
"comment": "Migrate package to use solution style ts-configs"
|
56
|
+
}
|
57
|
+
],
|
58
|
+
"prerelease": [
|
59
|
+
{
|
60
|
+
"author": "behowell@microsoft.com",
|
61
|
+
"package": "@fluentui/react-utilities",
|
62
|
+
"commit": "99adff5a9aab9086e8bc4737040654ab23f0febe",
|
63
|
+
"comment": "Update utility types to support specifying a primary slot other than root"
|
21
64
|
}
|
22
65
|
]
|
23
66
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,18 +1,28 @@
|
|
1
1
|
# Change Log - @fluentui/react-utilities
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Tue, 14 Dec 2021 04:16:20 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-
|
7
|
+
## [0.0.0-nightlyf1be0a972820211214.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v0.0.0-nightlyf1be0a972820211214.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-beta.
|
9
|
+
Tue, 14 Dec 2021 04:16:20 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-beta.4..@fluentui/react-utilities_v0.0.0-nightlyf1be0a972820211214.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
|
-
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/
|
15
|
-
-
|
14
|
+
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/3bda806f2deef1997fc6c070450a4a7aacb036ca) by email not defined)
|
15
|
+
- [breaking] Remove useControllableValue hook (use useControllableState instead) ([PR #20865](https://github.com/microsoft/fluentui/pull/20865) by elcraig@microsoft.com)
|
16
|
+
- Bump @fluentui/keyboard-keys to v0.0.0-nightlyf1be0a972820211214.1 ([commit](https://github.com/microsoft/fluentui/commit/3bda806f2deef1997fc6c070450a4a7aacb036ca) by beachball)
|
17
|
+
|
18
|
+
## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.0.0-beta.4)
|
19
|
+
|
20
|
+
Thu, 25 Nov 2021 08:34:09 GMT
|
21
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-beta.3..@fluentui/react-utilities_v9.0.0-beta.4)
|
22
|
+
|
23
|
+
### Changes
|
24
|
+
|
25
|
+
- Update utility types to support specifying a primary slot other than root ([PR #20617](https://github.com/microsoft/fluentui/pull/20617) by behowell@microsoft.com)
|
16
26
|
|
17
27
|
## [9.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.0.0-beta.3)
|
18
28
|
|
@@ -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
|
*
|
@@ -75,7 +73,7 @@ export declare const colProperties: Record<string, number>;
|
|
75
73
|
|
76
74
|
export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{
|
77
75
|
[Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>;
|
78
|
-
}, Primary> & PropsWithoutRef<Shorthands[Primary]>;
|
76
|
+
}, Primary & 'root'> & PropsWithoutRef<Shorthands[Primary]>;
|
79
77
|
|
80
78
|
export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord> = {
|
81
79
|
components?: {
|
@@ -89,8 +87,7 @@ export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord
|
|
89
87
|
* This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`;
|
90
88
|
* it shouldn't be used as the type of a slot.
|
91
89
|
*/
|
92
|
-
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{
|
93
|
-
children?: React_2.ReactNode;
|
90
|
+
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<Pick<React_2.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
|
94
91
|
as?: keyof JSX.IntrinsicElements;
|
95
92
|
}>;
|
96
93
|
|
@@ -101,11 +98,6 @@ export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{
|
|
101
98
|
*/
|
102
99
|
export declare const defaultSSRContextValue: SSRContextValue;
|
103
100
|
|
104
|
-
/**
|
105
|
-
* Default value can be a value or an initializer
|
106
|
-
*/
|
107
|
-
declare type DefaultValue<TValue> = TValue | (() => TValue);
|
108
|
-
|
109
101
|
/**
|
110
102
|
* An array of DIV tag properties and events.
|
111
103
|
*
|
@@ -150,6 +142,29 @@ export declare function getNativeElementProps<TAttributes extends React_2.HTMLAt
|
|
150
142
|
*/
|
151
143
|
export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
|
152
144
|
|
145
|
+
/**
|
146
|
+
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
147
|
+
*
|
148
|
+
* This function is only for use with components that have a primary slot other than `root`.
|
149
|
+
* Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
|
150
|
+
*
|
151
|
+
* @returns An object containing the native props for the `root` and primary slots.
|
152
|
+
*/
|
153
|
+
export declare const getPartitionedNativeProps: ({ primarySlotTagName, props, excludedPropNames, }: {
|
154
|
+
/** The primary slot's element type (e.g. 'div') */
|
155
|
+
primarySlotTagName: keyof JSX.IntrinsicElements;
|
156
|
+
/** The component's props object */
|
157
|
+
props: Pick<React_2.HTMLAttributes<HTMLElement>, 'style' | 'className'>;
|
158
|
+
/** List of native props to exclude from the returned value */
|
159
|
+
excludedPropNames?: string[] | undefined;
|
160
|
+
}) => {
|
161
|
+
root: {
|
162
|
+
style: React_2.CSSProperties | undefined;
|
163
|
+
className: string | undefined;
|
164
|
+
};
|
165
|
+
primary: React_2.HTMLAttributes<any>;
|
166
|
+
};
|
167
|
+
|
153
168
|
/**
|
154
169
|
* Finds and swaps a provided key for it's right to left format.
|
155
170
|
*/
|
@@ -164,8 +179,10 @@ export declare const getRTLSafeKey: (key: string, dir: 'ltr' | 'rtl') => string;
|
|
164
179
|
* Slots will render as null if they are rendered as primitives with undefined children.
|
165
180
|
*
|
166
181
|
* The slotProps will always omit the `as` prop within them, and for slots that are string
|
167
|
-
* primitives, the props will be filtered according
|
168
|
-
* 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.
|
169
186
|
*
|
170
187
|
* @param state - State including slot definitions
|
171
188
|
* @param slotNames - Name of which props are slots
|
@@ -313,7 +330,7 @@ export declare function omit<TObj extends Record<string, any>, Exclusions extend
|
|
313
330
|
/**
|
314
331
|
* Similar to React.Children.only, but drills into fragments rather than treating them as a single child
|
315
332
|
*/
|
316
|
-
export declare const onlyChild: <P>(child:
|
333
|
+
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>>;
|
317
334
|
|
318
335
|
export declare const optionProperties: Record<string, number>;
|
319
336
|
|
@@ -471,42 +488,37 @@ export declare type UseBooleanCallbacks = {
|
|
471
488
|
export declare function useConst<T>(initialValue: T | (() => T)): T;
|
472
489
|
|
473
490
|
/**
|
474
|
-
* A useState
|
475
|
-
*
|
476
|
-
*
|
491
|
+
* A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
|
492
|
+
* such as a checked state or text input string.
|
493
|
+
*
|
494
|
+
* Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
|
495
|
+
* controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
|
496
|
+
*
|
497
|
+
* @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
|
498
|
+
* of the current value and an updater (dispatch) function. The updater function is referentially
|
499
|
+
* stable (won't change during the component's lifecycle). It can take either a new value, or a
|
500
|
+
* function which is passed the previous value and returns the new value. Unlike `setState`, calls
|
501
|
+
* to the updater function will only be respected if the component is uncontrolled.
|
502
|
+
* @see https://reactjs.org/docs/uncontrolled-components.html
|
477
503
|
*/
|
478
504
|
export declare const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React_2.Dispatch<React_2.SetStateAction<State>>];
|
479
505
|
|
480
506
|
export declare type UseControllableStateOptions<State> = {
|
481
507
|
/**
|
482
|
-
* User
|
508
|
+
* User-provided default state or initializer, for uncontrolled usage.
|
483
509
|
*/
|
484
510
|
defaultState?: State | (() => State);
|
485
511
|
/**
|
486
|
-
* User
|
512
|
+
* User-provided controlled state. `undefined` means internal state will be used.
|
487
513
|
*/
|
488
514
|
state: State | undefined;
|
489
515
|
/**
|
490
|
-
* Used
|
516
|
+
* Used as the initial state if `state` and `defaultState` are both `undefined`.
|
517
|
+
* If `undefined` is the correct initial state, pass that here.
|
491
518
|
*/
|
492
519
|
initialState: State;
|
493
520
|
};
|
494
521
|
|
495
|
-
/**
|
496
|
-
* Hook to manage a value that could be either controlled or uncontrolled, such as a checked state or
|
497
|
-
* text box string.
|
498
|
-
* @param controlledValue - The controlled value passed in the props. This value will always be used if provided,
|
499
|
-
* and the internal state will be updated to reflect it.
|
500
|
-
* @param defaultUncontrolledValue - Initial value for the internal state in the uncontrolled case.
|
501
|
-
* @returns An array of the current value and an updater callback. Like `React.useState`, the updater
|
502
|
-
* callback always has the same identity, and it can take either a new value, or a function which
|
503
|
-
* is passed the previous value and returns the new value.
|
504
|
-
* @see https://reactjs.org/docs/uncontrolled-components.html
|
505
|
-
*/
|
506
|
-
export declare function useControllableValue<TValue, TElement extends HTMLElement>(controlledValue: TValue, defaultUncontrolledValue: DefaultValue<TValue>): Readonly<[TValue, (update: React_2.SetStateAction<TValue>) => void]>;
|
507
|
-
|
508
|
-
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]>;
|
509
|
-
|
510
522
|
/**
|
511
523
|
* https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
|
512
524
|
*
|
@@ -15,8 +15,10 @@ 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
24
|
* @param slotNames - Name of which props are slots
|
package/lib/compose/getSlots.js
CHANGED
@@ -10,8 +10,10 @@ 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
19
|
* @param slotNames - Name of which props are slots
|
@@ -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;;;;;;;;;;;;;;;;;AAiBG;;AACH,OAAM,SAAU,QAAV,CACJ,KADI,EAEJ,SAAA,GAAyB,CAAC,MAAD,CAFrB,EAE6B;AAKjC,QAAM,KAAK,GAAG,EAAd;AACA,QAAM,SAAS,GAAG,EAAlB;;AAEA,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;;AAED,SAAS,OAAT,CACE,KADF,EAEE,QAFF,EAEa;;;AAEX,MAAI,KAAK,CAAC,QAAD,CAAL,KAAoB,SAAxB,EAAmC;AACjC,WAAO,CAAC,UAAD,EAAa,SAAb,CAAP;AACD;;AACD,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA,EAAE,EAAE,MAAhB;AAAwB,OAAG;AAA3B,MAAoC,KAAK,CAAC,QAAD,CAA/C;AAEA,QAAM,IAAI,GAAI,CAAA,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAG,QAAH,CAAhB,MAAiC,SAAjC,IAA8C,OAAO,KAAK,CAAC,UAAN,CAAiB,QAAjB,CAAP,KAAsC,QAApF,GACV,MAAM,KAAI,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,MAAgB,IAAhB,IAAgB,EAAA,KAAA,KAAA,CAAhB,GAAgB,KAAA,CAAhB,GAAgB,EAAA,CAAG,QAAH,CAApB,CAAN,IAA0C,KADhC,GAEV,KAAK,CAAC,UAAN,CAAiB,QAAjB,CAFJ;;AAIA,MAAI,OAAO,QAAP,KAAoB,UAAxB,EAAoC;AAClC,UAAM,MAAM,GAAG,QAAf;AACA,WAAO,CACL,KAAK,CAAC,QADD,EAEJ;AACC,MAAA,QAAQ,EAAE,MAAM,CAAC,IAAD,EAAO,IAAP;AADjB,KAFI,CAAP;AAMD;;AAED,QAAM,gBAAgB,GAAG,OAAO,IAAP,KAAgB,QAAhB,KAA4B,CAAA,EAAA,GAAA,KAAK,CAAC,QAAD,CAAL,MAAe,IAAf,IAAe,EAAA,KAAA,KAAA,CAAf,GAAe,KAAA,CAAf,GAAe,EAAA,CAAE,EAA7C,CAAzB;AACA,QAAM,SAAS,GAAI,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAD,CAAN,EAAmB,CAAC,IAAD,CAAnB,CAAP,GAAoC,KAAK,CAAC,QAAD,CAA5E;AAEA,SAAO,CAAC,IAAD,EAAO,SAAP,CAAP;AACD","sourceRoot":""}
|
package/lib/compose/types.d.ts
CHANGED
@@ -8,8 +8,7 @@ export declare type ShorthandProps<Props extends DefaultObjectShorthandProps> =
|
|
8
8
|
* This should ONLY be used in type templates as in `extends DefaultObjectShorthandProps`;
|
9
9
|
* it shouldn't be used as the type of a slot.
|
10
10
|
*/
|
11
|
-
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<{
|
12
|
-
children?: React.ReactNode;
|
11
|
+
export declare type DefaultObjectShorthandProps = ObjectShorthandProps<Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
|
13
12
|
as?: keyof JSX.IntrinsicElements;
|
14
13
|
}>;
|
15
14
|
/**
|
@@ -78,7 +77,7 @@ export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U :
|
|
78
77
|
export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;
|
79
78
|
export declare type ComponentProps<Shorthands extends ObjectShorthandPropsRecord, Primary extends keyof Shorthands = 'root'> = Omit<{
|
80
79
|
[Key in keyof Shorthands]?: ShorthandProps<NonNullable<Shorthands[Key]>>;
|
81
|
-
}, Primary> & PropsWithoutRef<Shorthands[Primary]>;
|
80
|
+
}, Primary & 'root'> & PropsWithoutRef<Shorthands[Primary]>;
|
82
81
|
export declare type ComponentState<Shorthands extends ObjectShorthandPropsRecord> = {
|
83
82
|
components?: {
|
84
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);
|
package/lib/compose/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/compose/types.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../src/compose/types.ts"],"names":[],"mappings":"WAgJA;AACA;AACA;AACA;AACA","sourceRoot":""}
|
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;;;AACH,OAAO,MAAM,oBAAoB,GAC/B,OADkC,IAEsB;AACxD,QAAM,YAAY,GAAG,eAAe,CAAC,OAAO,CAAC,KAAT,CAApC;AACA,QAAM,YAAY,GAAG,OAAO,OAAO,CAAC,YAAf,KAAgC,WAAhC,GAA8C,OAAO,CAAC,YAAtD,GAAqE,OAAO,CAAC,YAAlG;AACA,QAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,KAAK,CAAC,QAAN,CAAsB,YAAtB,CAA1C;AAEA,QAAM,KAAK,GAAG,YAAY,GAAI,OAAO,CAAC,KAAZ,GAA8B,aAAxD;AAEA,QAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAAa,KAAb,CAAjB;AACA,EAAA,KAAK,CAAC,SAAN,CAAgB,MAAK;AACnB,IAAA,QAAQ,CAAC,OAAT,GAAmB,KAAnB;AACD,GAFD,EAEG,CAAC,KAAD,CAFH,EARwD,CAYxD;AACA;;AACA,QAAM,QAAQ,GAAG,KAAK,CAAC,WAAN,CAAmB,QAAD,IAA0C;AAC3E;AACA;AACA,QAAI,iBAAiB,CAAC,QAAD,CAArB,EAAiC;AAC/B,MAAA,QAAQ,CAAC,OAAT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AAc,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;
|
@@ -7,3 +7,25 @@ import * as React from 'react';
|
|
7
7
|
* @param excludedPropNames - List of props to disallow
|
8
8
|
*/
|
9
9
|
export declare function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(tagName: string, props: {}, excludedPropNames?: string[]): TAttributes;
|
10
|
+
/**
|
11
|
+
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
12
|
+
*
|
13
|
+
* This function is only for use with components that have a primary slot other than `root`.
|
14
|
+
* Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
|
15
|
+
*
|
16
|
+
* @returns An object containing the native props for the `root` and primary slots.
|
17
|
+
*/
|
18
|
+
export declare const getPartitionedNativeProps: ({ primarySlotTagName, props, excludedPropNames, }: {
|
19
|
+
/** The primary slot's element type (e.g. 'div') */
|
20
|
+
primarySlotTagName: keyof JSX.IntrinsicElements;
|
21
|
+
/** The component's props object */
|
22
|
+
props: Pick<React.HTMLAttributes<HTMLElement>, 'style' | 'className'>;
|
23
|
+
/** List of native props to exclude from the returned value */
|
24
|
+
excludedPropNames?: string[] | undefined;
|
25
|
+
}) => {
|
26
|
+
root: {
|
27
|
+
style: React.CSSProperties | undefined;
|
28
|
+
className: string | undefined;
|
29
|
+
};
|
30
|
+
primary: React.HTMLAttributes<any>;
|
31
|
+
};
|
@@ -35,4 +35,26 @@ export function getNativeElementProps(tagName, props, excludedPropNames) {
|
|
35
35
|
allowedPropNames.as = 1;
|
36
36
|
return getNativeProps(props, allowedPropNames, excludedPropNames);
|
37
37
|
}
|
38
|
+
/**
|
39
|
+
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
40
|
+
*
|
41
|
+
* This function is only for use with components that have a primary slot other than `root`.
|
42
|
+
* Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
|
43
|
+
*
|
44
|
+
* @returns An object containing the native props for the `root` and primary slots.
|
45
|
+
*/
|
46
|
+
|
47
|
+
export const getPartitionedNativeProps = ({
|
48
|
+
primarySlotTagName,
|
49
|
+
props,
|
50
|
+
excludedPropNames
|
51
|
+
}) => {
|
52
|
+
return {
|
53
|
+
root: {
|
54
|
+
style: props.style,
|
55
|
+
className: props.className
|
56
|
+
},
|
57
|
+
primary: getNativeElementProps(primarySlotTagName, props, [...(excludedPropNames || []), 'style', 'className'])
|
58
|
+
};
|
59
|
+
};
|
38
60
|
//# sourceMappingURL=getNativeElementProps.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/getNativeElementProps.ts"],"names":[],"mappings":"AACA,SACE,eADF,EAEE,eAFF,EAGE,eAHF,EAIE,YAJF,EAKE,YALF,EAME,gBANF,EAOE,gBAPF,EAQE,eARF,EASE,kBATF,EAUE,gBAVF,EAWE,gBAXF,EAYE,eAZF,EAaE,YAbF,EAcE,YAdF,EAeE,YAfF,EAgBE,kBAhBF,EAiBE,aAjBF,EAkBE,cAlBF,EAmBE,gBAnBF,EAoBE,aApBF,EAqBE,qBArBF,EAsBE,cAt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C;AAExC,EAAA,KAFwC;AAGxC,EAAA;AAHwC,CAAD,KAapC;AACH,SAAO;AACL,IAAA,IAAI,EAAE;AAAE,MAAA,KAAK,EAAE,KAAK,CAAC,KAAf;AAAsB,MAAA,SAAS,EAAE,KAAK,CAAC;AAAvC,KADD;AAEL,IAAA,OAAO,EAAE,qBAAqB,CAAC,kBAAD,EAAqB,KAArB,EAA4B,CAAC,IAAI,iBAAiB,IAAI,EAAzB,CAAD,EAA+B,OAA/B,EAAwC,WAAxC,CAA5B;AAFzB,GAAP;AAID,CAlBM","sourceRoot":""}
|
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>>;
|