@fluentui/react-utilities 0.0.0-nightlya372ad979820211103.1 → 0.0.0-nightlycbf184efa720211222.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.
Files changed (142) hide show
  1. package/CHANGELOG.json +78 -6
  2. package/CHANGELOG.md +25 -6
  3. package/dist/react-utilities.d.ts +47 -35
  4. package/lib/compose/getSlots.d.ts +4 -2
  5. package/lib/compose/getSlots.js +19 -27
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/nullRender.js +1 -3
  8. package/lib/compose/nullRender.js.map +1 -1
  9. package/lib/compose/resolveShorthand.js +8 -7
  10. package/lib/compose/resolveShorthand.js.map +1 -1
  11. package/lib/compose/types.d.ts +2 -3
  12. package/lib/compose/types.js.map +1 -1
  13. package/lib/hooks/index.d.ts +0 -1
  14. package/lib/hooks/index.js +0 -1
  15. package/lib/hooks/index.js.map +1 -1
  16. package/lib/hooks/useBoolean.js +10 -21
  17. package/lib/hooks/useBoolean.js.map +1 -1
  18. package/lib/hooks/useConst.js +1 -1
  19. package/lib/hooks/useConst.js.map +1 -1
  20. package/lib/hooks/useControllableState.d.ts +16 -6
  21. package/lib/hooks/useControllableState.js +26 -25
  22. package/lib/hooks/useControllableState.js.map +1 -1
  23. package/lib/hooks/useEventCallback.js +6 -12
  24. package/lib/hooks/useEventCallback.js.map +1 -1
  25. package/lib/hooks/useFirstMount.js +1 -1
  26. package/lib/hooks/useFirstMount.js.map +1 -1
  27. package/lib/hooks/useForceUpdate.js +1 -3
  28. package/lib/hooks/useForceUpdate.js.map +1 -1
  29. package/lib/hooks/useId.js +2 -4
  30. package/lib/hooks/useId.js.map +1 -1
  31. package/lib/hooks/useIsomorphicLayoutEffect.js +1 -1
  32. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  33. package/lib/hooks/useMergedRefs.js +5 -13
  34. package/lib/hooks/useMergedRefs.js.map +1 -1
  35. package/lib/hooks/useMount.js +3 -3
  36. package/lib/hooks/useMount.js.map +1 -1
  37. package/lib/hooks/useOnClickOutside.js +30 -36
  38. package/lib/hooks/useOnClickOutside.js.map +1 -1
  39. package/lib/hooks/useOnScrollOutside.js +13 -15
  40. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  41. package/lib/hooks/usePrevious.js +3 -3
  42. package/lib/hooks/usePrevious.js.map +1 -1
  43. package/lib/hooks/useTimeout.js +13 -17
  44. package/lib/hooks/useTimeout.js.map +1 -1
  45. package/lib/hooks/useUnmount.js +5 -7
  46. package/lib/hooks/useUnmount.js.map +1 -1
  47. package/lib/ssr/SSRContext.js +9 -15
  48. package/lib/ssr/SSRContext.js.map +1 -1
  49. package/lib/utils/applyTriggerPropsToChildren.d.ts +1 -1
  50. package/lib/utils/applyTriggerPropsToChildren.js +1 -1
  51. package/lib/utils/applyTriggerPropsToChildren.js.map +1 -1
  52. package/lib/utils/clamp.js +1 -3
  53. package/lib/utils/clamp.js.map +1 -1
  54. package/lib/utils/getNativeElementProps.d.ts +22 -0
  55. package/lib/utils/getNativeElementProps.js +24 -2
  56. package/lib/utils/getNativeElementProps.js.map +1 -1
  57. package/lib/utils/getRTLSafeKey.js +1 -1
  58. package/lib/utils/getRTLSafeKey.js.map +1 -1
  59. package/lib/utils/omit.js +2 -2
  60. package/lib/utils/omit.js.map +1 -1
  61. package/lib/utils/onlyChild.d.ts +1 -1
  62. package/lib/utils/onlyChild.js +2 -2
  63. package/lib/utils/onlyChild.js.map +1 -1
  64. package/lib/utils/properties.js +55 -44
  65. package/lib/utils/properties.js.map +1 -1
  66. package/lib/utils/shouldPreventDefaultOnKeyDown.js +4 -4
  67. package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  68. package/lib-commonjs/compose/getSlots.d.ts +4 -2
  69. package/lib-commonjs/compose/getSlots.js +22 -31
  70. package/lib-commonjs/compose/getSlots.js.map +1 -1
  71. package/lib-commonjs/compose/index.js +1 -1
  72. package/lib-commonjs/compose/nullRender.js +1 -3
  73. package/lib-commonjs/compose/nullRender.js.map +1 -1
  74. package/lib-commonjs/compose/resolveShorthand.js +9 -9
  75. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  76. package/lib-commonjs/compose/types.d.ts +2 -3
  77. package/lib-commonjs/compose/types.js.map +1 -1
  78. package/lib-commonjs/hooks/index.d.ts +0 -1
  79. package/lib-commonjs/hooks/index.js +1 -3
  80. package/lib-commonjs/hooks/index.js.map +1 -1
  81. package/lib-commonjs/hooks/useBoolean.js +12 -23
  82. package/lib-commonjs/hooks/useBoolean.js.map +1 -1
  83. package/lib-commonjs/hooks/useConst.js +2 -2
  84. package/lib-commonjs/hooks/useConst.js.map +1 -1
  85. package/lib-commonjs/hooks/useControllableState.d.ts +16 -6
  86. package/lib-commonjs/hooks/useControllableState.js +28 -27
  87. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  88. package/lib-commonjs/hooks/useEventCallback.js +8 -14
  89. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  90. package/lib-commonjs/hooks/useFirstMount.js +2 -2
  91. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  92. package/lib-commonjs/hooks/useForceUpdate.js +2 -4
  93. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  94. package/lib-commonjs/hooks/useId.js +4 -6
  95. package/lib-commonjs/hooks/useId.js.map +1 -1
  96. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +2 -2
  97. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  98. package/lib-commonjs/hooks/useMergedRefs.js +6 -15
  99. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  100. package/lib-commonjs/hooks/useMount.js +4 -4
  101. package/lib-commonjs/hooks/useMount.js.map +1 -1
  102. package/lib-commonjs/hooks/useOnClickOutside.js +32 -38
  103. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  104. package/lib-commonjs/hooks/useOnScrollOutside.js +15 -17
  105. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  106. package/lib-commonjs/hooks/usePrevious.js +4 -4
  107. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  108. package/lib-commonjs/hooks/useTimeout.js +15 -19
  109. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  110. package/lib-commonjs/hooks/useUnmount.js +6 -8
  111. package/lib-commonjs/hooks/useUnmount.js.map +1 -1
  112. package/lib-commonjs/index.js +1 -1
  113. package/lib-commonjs/ssr/SSRContext.js +9 -15
  114. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  115. package/lib-commonjs/ssr/index.js +1 -1
  116. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +1 -1
  117. package/lib-commonjs/utils/applyTriggerPropsToChildren.js +3 -3
  118. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -1
  119. package/lib-commonjs/utils/clamp.js +1 -3
  120. package/lib-commonjs/utils/clamp.js.map +1 -1
  121. package/lib-commonjs/utils/getNativeElementProps.d.ts +22 -0
  122. package/lib-commonjs/utils/getNativeElementProps.js +28 -4
  123. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  124. package/lib-commonjs/utils/getRTLSafeKey.js +1 -1
  125. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  126. package/lib-commonjs/utils/index.js +1 -1
  127. package/lib-commonjs/utils/omit.js +2 -2
  128. package/lib-commonjs/utils/omit.js.map +1 -1
  129. package/lib-commonjs/utils/onlyChild.d.ts +1 -1
  130. package/lib-commonjs/utils/onlyChild.js +3 -3
  131. package/lib-commonjs/utils/onlyChild.js.map +1 -1
  132. package/lib-commonjs/utils/properties.js +50 -39
  133. package/lib-commonjs/utils/properties.js.map +1 -1
  134. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +5 -5
  135. package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
  136. package/package.json +5 -10
  137. package/lib/hooks/useControllableValue.d.ts +0 -20
  138. package/lib/hooks/useControllableValue.js +0 -62
  139. package/lib/hooks/useControllableValue.js.map +0 -1
  140. package/lib-commonjs/hooks/useControllableValue.d.ts +0 -20
  141. package/lib-commonjs/hooks/useControllableValue.js +0 -73
  142. package/lib-commonjs/hooks/useControllableValue.js.map +0 -1
package/CHANGELOG.json CHANGED
@@ -2,22 +2,94 @@
2
2
  "name": "@fluentui/react-utilities",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 03 Nov 2021 08:24:07 GMT",
6
- "tag": "@fluentui/react-utilities_v0.0.0-nightlya372ad979820211103.1",
7
- "version": "0.0.0-nightlya372ad979820211103.1",
5
+ "date": "Wed, 22 Dec 2021 04:13:41 GMT",
6
+ "tag": "@fluentui/react-utilities_v0.0.0-nightlycbf184efa720211222.1",
7
+ "version": "0.0.0-nightlycbf184efa720211222.1",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
11
11
  "author": "email not defined",
12
12
  "package": "@fluentui/react-utilities",
13
- "commit": "ff9c0a60767a2dbd1afdc71659a5daee5f2068dd",
13
+ "commit": "28b9baaabf69c84b88a540aa640694c468cb98e0",
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-nightlya372ad979820211103.1",
20
- "commit": "ff9c0a60767a2dbd1afdc71659a5daee5f2068dd"
25
+ "comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightlycbf184efa720211222.1",
26
+ "commit": "28b9baaabf69c84b88a540aa640694c468cb98e0"
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
+ "author": "lingfangao@hotmail.com",
44
+ "package": "@fluentui/react-utilities",
45
+ "commit": "a4e048a0e03ddd676670da516e3a6612b26ea500",
46
+ "comment": "chore: Remove enzyme from react-utilities tests"
47
+ }
48
+ ]
49
+ }
50
+ },
51
+ {
52
+ "date": "Thu, 25 Nov 2021 08:34:09 GMT",
53
+ "tag": "@fluentui/react-utilities_v9.0.0-beta.4",
54
+ "version": "9.0.0-beta.4",
55
+ "comments": {
56
+ "none": [
57
+ {
58
+ "author": "lingfangao@hotmail.com",
59
+ "package": "@fluentui/react-utilities",
60
+ "commit": "718e63006d8d07d24efab9c32942041963d78dc7",
61
+ "comment": "Migrate package to use solution style ts-configs"
62
+ }
63
+ ],
64
+ "prerelease": [
65
+ {
66
+ "author": "behowell@microsoft.com",
67
+ "package": "@fluentui/react-utilities",
68
+ "commit": "99adff5a9aab9086e8bc4737040654ab23f0febe",
69
+ "comment": "Update utility types to support specifying a primary slot other than root"
70
+ }
71
+ ]
72
+ }
73
+ },
74
+ {
75
+ "date": "Fri, 12 Nov 2021 13:25:10 GMT",
76
+ "tag": "@fluentui/react-utilities_v9.0.0-beta.3",
77
+ "version": "9.0.0-beta.3",
78
+ "comments": {
79
+ "none": [
80
+ {
81
+ "author": "lingfangao@hotmail.com",
82
+ "package": "@fluentui/react-utilities",
83
+ "commit": "00f70581480b536e723fb69edf0ae617beac4807",
84
+ "comment": "Remove beta release tag"
85
+ }
86
+ ],
87
+ "prerelease": [
88
+ {
89
+ "author": "gcox@microsoft.com",
90
+ "package": "@fluentui/react-utilities",
91
+ "commit": "c9bd5b5a02ae94a8239ce1b56cac2f0d0dbd3586",
92
+ "comment": "Updated beta and RC components to ES2019"
21
93
  }
22
94
  ]
23
95
  }
package/CHANGELOG.md CHANGED
@@ -1,18 +1,37 @@
1
1
  # Change Log - @fluentui/react-utilities
2
2
 
3
- This log was last generated on Wed, 03 Nov 2021 08:24:07 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 22 Dec 2021 04:13:41 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightlya372ad979820211103.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v0.0.0-nightlya372ad979820211103.1)
7
+ ## [0.0.0-nightlycbf184efa720211222.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v0.0.0-nightlycbf184efa720211222.1)
8
8
 
9
- Wed, 03 Nov 2021 08:24:07 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-beta.2..@fluentui/react-utilities_v0.0.0-nightlya372ad979820211103.1)
9
+ Wed, 22 Dec 2021 04:13:41 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-beta.4..@fluentui/react-utilities_v0.0.0-nightlycbf184efa720211222.1)
11
11
 
12
12
  ### Changes
13
13
 
14
- - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/ff9c0a60767a2dbd1afdc71659a5daee5f2068dd) by email not defined)
15
- - Bump @fluentui/keyboard-keys to v0.0.0-nightlya372ad979820211103.1 ([commit](https://github.com/microsoft/fluentui/commit/ff9c0a60767a2dbd1afdc71659a5daee5f2068dd) by beachball)
14
+ - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/28b9baaabf69c84b88a540aa640694c468cb98e0) 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-nightlycbf184efa720211222.1 ([commit](https://github.com/microsoft/fluentui/commit/28b9baaabf69c84b88a540aa640694c468cb98e0) 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)
26
+
27
+ ## [9.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.0.0-beta.3)
28
+
29
+ Fri, 12 Nov 2021 13:25:10 GMT
30
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.0.0-beta.2..@fluentui/react-utilities_v9.0.0-beta.3)
31
+
32
+ ### Changes
33
+
34
+ - Updated beta and RC components to ES2019 ([PR #20405](https://github.com/microsoft/fluentui/pull/20405) by gcox@microsoft.com)
16
35
 
17
36
  ## [9.0.0-beta.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.0.0-beta.2)
18
37
 
@@ -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 | ((props: any) => React_2.ReactElement<any, string | any | (new (props: any) => React_2.Component<any, any, any>)> | null) | (new (props: any) => React_2.Component<any, any, any>)> | ((props: TTriggerProps) => React_2.ReactNode) | null | undefined, triggerProps: TTriggerProps) => React_2.ReactNode;
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 the the slot type. For example, if the
168
- * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
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: string | number | boolean | {} | React_2.ReactNodeArray | React_2.ReactPortal | React_2.ReactElement<P, string | ((props: any) => React_2.ReactElement<any, string | any | (new (props: any) => React_2.Component<any, any, any>)> | null) | (new (props: any) => React_2.Component<any, any, any>)> | null | undefined) => React_2.ReactElement<P, string | ((props: any) => React_2.ReactElement<any, string | any | (new (props: any) => React_2.Component<any, any, any>)> | null) | (new (props: any) => React_2.Component<any, any, any>)>;
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 'like' hook that allows optional user control
475
- * Useful for components which allow uncontrolled and controlled behaviour for users
476
- * @returns - https://reactjs.org/docs/hooks-state.html
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 provided default state or factory initializer
508
+ * User-provided default state or initializer, for uncontrolled usage.
483
509
  */
484
510
  defaultState?: State | (() => State);
485
511
  /**
486
- * User provided controllable state, undefined state means internal state will be used
512
+ * User-provided controlled state. `undefined` means internal state will be used.
487
513
  */
488
514
  state: State | undefined;
489
515
  /**
490
- * Used to initialize state if all user provided states are undefined
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 the the slot type. For example, if the
19
- * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
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
@@ -1,4 +1,3 @@
1
- import { __rest } from "tslib";
2
1
  import * as React from 'react';
3
2
  import { nullRender } from './nullRender';
4
3
  import { omit } from '../utils/omit';
@@ -11,35 +10,28 @@ import { omit } from '../utils/omit';
11
10
  * Slots will render as null if they are rendered as primitives with undefined children.
12
11
  *
13
12
  * The slotProps will always omit the `as` prop within them, and for slots that are string
14
- * primitives, the props will be filtered according the the slot type. For example, if the
15
- * slot is rendered `as: 'a'`, the props will be filtered for acceptable anchor props.
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.
16
17
  *
17
18
  * @param state - State including slot definitions
18
19
  * @param slotNames - Name of which props are slots
19
20
  * @returns An object containing the `slots` map and `slotProps` map.
20
21
  */
21
22
 
22
- export function getSlots(state, slotNames) {
23
- if (slotNames === void 0) {
24
- slotNames = ['root'];
25
- }
26
-
27
- var slots = {};
28
- var slotProps = {};
29
-
30
- for (var _i = 0, slotNames_1 = slotNames; _i < slotNames_1.length; _i++) {
31
- var slotName = slotNames_1[_i];
32
-
33
- var _a = getSlot(state, slotName),
34
- slot = _a[0],
35
- props = _a[1];
23
+ export function getSlots(state, slotNames = ['root']) {
24
+ const slots = {};
25
+ const slotProps = {};
36
26
 
27
+ for (const slotName of slotNames) {
28
+ const [slot, props] = getSlot(state, slotName);
37
29
  slots[slotName] = slot;
38
30
  slotProps[slotName] = props;
39
31
  }
40
32
 
41
33
  return {
42
- slots: slots,
34
+ slots,
43
35
  slotProps: slotProps
44
36
  };
45
37
  }
@@ -51,22 +43,22 @@ function getSlot(state, slotName) {
51
43
  return [nullRender, undefined];
52
44
  }
53
45
 
54
- var _d = state[slotName],
55
- children = _d.children,
56
- asProp = _d.as,
57
- rest = __rest(_d, ["children", "as"]);
58
-
59
- var slot = ((_a = state.components) === null || _a === void 0 ? void 0 : _a[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_b = state.components) === null || _b === void 0 ? void 0 : _b[slotName]) || 'div' : state.components[slotName];
46
+ const {
47
+ children,
48
+ as: asProp,
49
+ ...rest
50
+ } = state[slotName];
51
+ const slot = ((_a = state.components) === null || _a === void 0 ? void 0 : _a[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_b = state.components) === null || _b === void 0 ? void 0 : _b[slotName]) || 'div' : state.components[slotName];
60
52
 
61
53
  if (typeof children === 'function') {
62
- var render = children;
54
+ const render = children;
63
55
  return [React.Fragment, {
64
56
  children: render(slot, rest)
65
57
  }];
66
58
  }
67
59
 
68
- var shouldOmitAsProp = typeof slot === 'string' && ((_c = state[slotName]) === null || _c === void 0 ? void 0 : _c.as);
69
- var slotProps = shouldOmitAsProp ? omit(state[slotName], ['as']) : state[slotName];
60
+ const shouldOmitAsProp = typeof slot === 'string' && ((_c = state[slotName]) === null || _c === void 0 ? void 0 : _c.as);
61
+ const slotProps = shouldOmitAsProp ? omit(state[slotName], ['as']) : state[slotName];
70
62
  return [slot, slotProps];
71
63
  }
72
64
  //# sourceMappingURL=getSlots.js.map
@@ -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;;;;;;;;;;;;;;;AAeG;;AACH,OAAM,SAAU,QAAV,CACJ,KADI,EAEJ,SAFI,EAE6B;AAAjC,MAAA,SAAA,KAAA,KAAA,CAAA,EAAA;AAAA,IAAA,SAAA,GAAA,CAA0B,MAA1B,CAAA;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AAe,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":""}
@@ -1,7 +1,5 @@
1
1
  /**
2
2
  * Simple constant function for returning null, used to render empty templates in JSX.
3
3
  */
4
- export var nullRender = function () {
5
- return null;
6
- };
4
+ export const nullRender = () => null;
7
5
  //# sourceMappingURL=nullRender.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/compose/nullRender.tsx"],"names":[],"mappings":"AAAA;;AAEG;AACH,OAAO,IAAM,UAAU,GAAG,YAAA;AAAM,SAAA,IAAA;AAAI,CAA7B","sourceRoot":""}
1
+ {"version":3,"file":"nullRender.js","sourceRoot":"","sources":["../../src/compose/nullRender.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC"}
@@ -1,4 +1,3 @@
1
- import { __assign } from "tslib";
2
1
  import { isValidElement } from 'react';
3
2
  /**
4
3
  * Resolves ShorthandProps into ObjectShorthandProps, to ensure normalization of the signature
@@ -8,16 +7,16 @@ import { isValidElement } from 'react';
8
7
  */
9
8
 
10
9
  export function resolveShorthand(value, options) {
11
- var _a = options || {},
12
- _b = _a.required,
13
- required = _b === void 0 ? false : _b,
14
- defaultProps = _a.defaultProps;
10
+ const {
11
+ required = false,
12
+ defaultProps
13
+ } = options || {};
15
14
 
16
15
  if (value === null || value === undefined && !required) {
17
16
  return undefined;
18
17
  }
19
18
 
20
- var resolvedShorthand = {};
19
+ let resolvedShorthand = {};
21
20
 
22
21
  if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || /*#__PURE__*/isValidElement(value)) {
23
22
  resolvedShorthand.children = value;
@@ -25,6 +24,8 @@ export function resolveShorthand(value, options) {
25
24
  resolvedShorthand = value;
26
25
  }
27
26
 
28
- return defaultProps ? __assign(__assign({}, defaultProps), resolvedShorthand) : resolvedShorthand;
27
+ return defaultProps ? { ...defaultProps,
28
+ ...resolvedShorthand
29
+ } : resolvedShorthand;
29
30
  }
30
31
  //# sourceMappingURL=resolveShorthand.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/compose/resolveShorthand.ts"],"names":[],"mappings":";AAAA,SAAS,cAAT,QAA+B,OAA/B;AASA;;;;;AAKG;;AACH,OAAM,SAAU,gBAAV,CACJ,KADI,EAEJ,OAFI,EAE8C;AAE5C,MAAA,EAAA,GAAqC,OAAO,IAAI,EAAhD;AAAA,MAAE,EAAA,GAAA,EAAA,CAAA,QAAF;AAAA,MAAE,QAAQ,GAAA,EAAA,KAAA,KAAA,CAAA,GAAG,KAAH,GAAQ,EAAlB;AAAA,MAAoB,YAAY,GAAA,EAAA,CAAA,YAAhC;;AACN,MAAI,KAAK,KAAK,IAAV,IAAmB,KAAK,KAAK,SAAV,IAAuB,CAAC,QAA/C,EAA0D;AACxD,WAAO,SAAP;AACD;;AAED,MAAI,iBAAiB,GAAG,EAAxB;;AAEA,MAAI,OAAO,KAAP,KAAiB,QAAjB,IAA6B,OAAO,KAAP,KAAiB,QAA9C,IAA0D,KAAK,CAAC,OAAN,CAAc,KAAd,CAA1D,iBAAkF,cAAc,CAAC,KAAD,CAApG,EAA6G;AAC3G,IAAA,iBAAiB,CAAC,QAAlB,GAA6B,KAA7B;AACD,GAFD,MAEO,IAAI,OAAO,KAAP,KAAiB,QAArB,EAA+B;AACpC,IAAA,iBAAiB,GAAG,KAApB;AACD;;AAED,SAAQ,YAAY,GAAE,QAAA,CAAA,QAAA,CAAA,EAAA,EAAM,YAAN,CAAA,EAAuB,iBAAvB,CAAF,GAA+C,iBAAnE;AAGD","sourceRoot":""}
1
+ {"version":3,"sources":["../../src/compose/resolveShorthand.ts"],"names":[],"mappings":"AAAA,SAAS,cAAT,QAA+B,OAA/B;AASA;;;;;AAKG;;AACH,OAAM,SAAU,gBAAV,CACJ,KADI,EAEJ,OAFI,EAE8C;AAElD,QAAM;AAAE,IAAA,QAAQ,GAAG,KAAb;AAAoB,IAAA;AAApB,MAAqC,OAAO,IAAI,EAAtD;;AACA,MAAI,KAAK,KAAK,IAAV,IAAmB,KAAK,KAAK,SAAV,IAAuB,CAAC,QAA/C,EAA0D;AACxD,WAAO,SAAP;AACD;;AAED,MAAI,iBAAiB,GAAG,EAAxB;;AAEA,MAAI,OAAO,KAAP,KAAiB,QAAjB,IAA6B,OAAO,KAAP,KAAiB,QAA9C,IAA0D,KAAK,CAAC,OAAN,CAAc,KAAd,CAA1D,iBAAkF,cAAc,CAAC,KAAD,CAApG,EAA6G;AAC3G,IAAA,iBAAiB,CAAC,QAAlB,GAA6B,KAA7B;AACD,GAFD,MAEO,IAAI,OAAO,KAAP,KAAiB,QAArB,EAA+B;AACpC,IAAA,iBAAiB,GAAG,KAApB;AACD;;AAED,SAAQ,YAAY,GAAG,EAAE,GAAG,YAAL;AAAmB,OAAG;AAAtB,GAAH,GAA+C,iBAAnE;AAGD","sourceRoot":""}
@@ -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);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/compose/types.ts"],"names":[],"mappings":"WA2IA;AACA;AACA;AACA;AACA","sourceRoot":""}
1
+ {"version":3,"sources":["../../src/compose/types.ts"],"names":[],"mappings":"WAgJA;AACA;AACA;AACA;AACA","sourceRoot":""}
@@ -1,7 +1,6 @@
1
1
  export * from './useControllableState';
2
2
  export * from './useBoolean';
3
3
  export * from './useConst';
4
- export * from './useControllableValue';
5
4
  export * from './useEventCallback';
6
5
  export * from './useFirstMount';
7
6
  export * from './useId';
@@ -1,7 +1,6 @@
1
1
  export * from './useControllableState';
2
2
  export * from './useBoolean';
3
3
  export * from './useConst';
4
- export * from './useControllableValue';
5
4
  export * from './useEventCallback';
6
5
  export * from './useFirstMount';
7
6
  export * from './useId';
@@ -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,wBAAwB,CAAC;AACvC,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
+ {"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"}
@@ -9,31 +9,20 @@ import { useConst } from './useConst';
9
9
  */
10
10
 
11
11
  export function useBoolean(initialState) {
12
- var _a = React.useState(initialState),
13
- value = _a[0],
14
- setValue = _a[1];
15
-
16
- var setTrue = useConst(function () {
17
- return function () {
18
- setValue(true);
19
- };
12
+ const [value, setValue] = React.useState(initialState);
13
+ const setTrue = useConst(() => () => {
14
+ setValue(true);
20
15
  });
21
- var setFalse = useConst(function () {
22
- return function () {
23
- setValue(false);
24
- };
16
+ const setFalse = useConst(() => () => {
17
+ setValue(false);
25
18
  });
26
- var toggle = useConst(function () {
27
- return function () {
28
- setValue(function (currentValue) {
29
- return !currentValue;
30
- });
31
- };
19
+ const toggle = useConst(() => () => {
20
+ setValue(currentValue => !currentValue);
32
21
  });
33
22
  return [value, {
34
- setTrue: setTrue,
35
- setFalse: setFalse,
36
- toggle: toggle
23
+ setTrue,
24
+ setFalse,
25
+ toggle
37
26
  }];
38
27
  }
39
28
  //# sourceMappingURL=useBoolean.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useBoolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,YAAzB;AAYA;;;;;;AAMG;;AACH,OAAM,SAAU,UAAV,CAAqB,YAArB,EAA0C;AACxC,MAAA,EAAA,GAAoB,KAAK,CAAC,QAAN,CAAe,YAAf,CAApB;AAAA,MAAC,KAAK,GAAA,EAAA,CAAA,CAAA,CAAN;AAAA,MAAQ,QAAQ,GAAA,EAAA,CAAA,CAAA,CAAhB;;AAEN,MAAM,OAAO,GAAG,QAAQ,CAAC,YAAA;AAAM,WAAA,YAAA;AAC7B,MAAA,QAAQ,CAAC,IAAD,CAAR;AAD6B,KAAA;AAE9B,GAFuB,CAAxB;AAGA,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAA;AAAM,WAAA,YAAA;AAC9B,MAAA,QAAQ,CAAC,KAAD,CAAR;AAD8B,KAAA;AAE/B,GAFwB,CAAzB;AAGA,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAA;AAAM,WAAA,YAAA;AAC5B,MAAA,QAAQ,CAAC,UAAA,YAAA,EAAY;AAAI,eAAA,CAAA,YAAA;AAAa,OAA9B,CAAR;AAD4B,KAAA;AAE7B,GAFsB,CAAvB;AAIA,SAAO,CAAC,KAAD,EAAQ;AAAE,IAAA,OAAO,EAAA,OAAT;AAAW,IAAA,QAAQ,EAAA,QAAnB;AAAqB,IAAA,MAAM,EAAA;AAA3B,GAAR,CAAP;AACD","sourceRoot":""}
1
+ {"version":3,"sources":["../../src/hooks/useBoolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,YAAzB;AAYA;;;;;;AAMG;;AACH,OAAM,SAAU,UAAV,CAAqB,YAArB,EAA0C;AAC9C,QAAM,CAAC,KAAD,EAAQ,QAAR,IAAoB,KAAK,CAAC,QAAN,CAAe,YAAf,CAA1B;AAEA,QAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,MAAK;AAClC,IAAA,QAAQ,CAAC,IAAD,CAAR;AACD,GAFuB,CAAxB;AAGA,QAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,MAAK;AACnC,IAAA,QAAQ,CAAC,KAAD,CAAR;AACD,GAFwB,CAAzB;AAGA,QAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,MAAK;AACjC,IAAA,QAAQ,CAAC,YAAY,IAAI,CAAC,YAAlB,CAAR;AACD,GAFsB,CAAvB;AAIA,SAAO,CAAC,KAAD,EAAQ;AAAE,IAAA,OAAF;AAAW,IAAA,QAAX;AAAqB,IAAA;AAArB,GAAR,CAAP;AACD","sourceRoot":""}
@@ -15,7 +15,7 @@ export function useConst(initialValue) {
15
15
  // Use useRef to store the value because it's the least expensive built-in hook that works here
16
16
  // (we could also use `const [value] = React.useState(initialValue)` but that's more expensive
17
17
  // internally due to reducer handling which we don't need)
18
- var ref = React.useRef();
18
+ const ref = React.useRef();
19
19
 
20
20
  if (ref.current === undefined) {
21
21
  // Box the value in an object so we can tell if it's initialized even if the initializer
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useConst.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;;;;;;;;;AAUG;;AACH,OAAM,SAAU,QAAV,CAAsB,YAAtB,EAAiD;AACrD;AACA;AACA;AACA,MAAM,GAAG,GAAG,KAAK,CAAC,MAAN,EAAZ;;AACA,MAAI,GAAG,CAAC,OAAJ,KAAgB,SAApB,EAA+B;AAC7B;AACA;AACA,IAAA,GAAG,CAAC,OAAJ,GAAc;AACZ,MAAA,KAAK,EAAE,OAAO,YAAP,KAAwB,UAAxB,GAAsC,YAAyB,EAA/D,GAAoE;AAD/D,KAAd;AAGD;;AACD,SAAO,GAAG,CAAC,OAAJ,CAAY,KAAnB;AACD","sourceRoot":""}
1
+ {"version":3,"sources":["../../src/hooks/useConst.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;;;;;;;;;AAUG;;AACH,OAAM,SAAU,QAAV,CAAsB,YAAtB,EAAiD;AACrD;AACA;AACA;AACA,QAAM,GAAG,GAAG,KAAK,CAAC,MAAN,EAAZ;;AACA,MAAI,GAAG,CAAC,OAAJ,KAAgB,SAApB,EAA+B;AAC7B;AACA;AACA,IAAA,GAAG,CAAC,OAAJ,GAAc;AACZ,MAAA,KAAK,EAAE,OAAO,YAAP,KAAwB,UAAxB,GAAsC,YAAyB,EAA/D,GAAoE;AAD/D,KAAd;AAGD;;AACD,SAAO,GAAG,CAAC,OAAJ,CAAY,KAAnB;AACD","sourceRoot":""}
@@ -1,21 +1,31 @@
1
1
  import * as React from 'react';
2
2
  export declare type UseControllableStateOptions<State> = {
3
3
  /**
4
- * User provided default state or factory initializer
4
+ * User-provided default state or initializer, for uncontrolled usage.
5
5
  */
6
6
  defaultState?: State | (() => State);
7
7
  /**
8
- * User provided controllable state, undefined state means internal state will be used
8
+ * User-provided controlled state. `undefined` means internal state will be used.
9
9
  */
10
10
  state: State | undefined;
11
11
  /**
12
- * Used to initialize state if all user provided states are undefined
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 'like' hook that allows optional user control
18
- * Useful for components which allow uncontrolled and controlled behaviour for users
19
- * @returns - https://reactjs.org/docs/hooks-state.html
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>>];