@fluentui/react-utilities 0.0.0-nightlyd3bf09bf8120211201.1 → 0.0.0-nightlye1926bfeca20220204.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 +80 -6
- package/CHANGELOG.md +13 -6
- package/dist/react-utilities.d.ts +155 -84
- package/lib/compose/getSlots.d.ts +11 -10
- package/lib/compose/getSlots.js +6 -4
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/resolveShorthand.d.ts +5 -5
- package/lib/compose/resolveShorthand.js +3 -3
- package/lib/compose/types.d.ts +48 -26
- package/lib/compose/types.js.map +1 -1
- package/lib/hooks/index.d.ts +1 -1
- package/lib/hooks/index.js +1 -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/useMergedEventCallbacks.d.ts +18 -0
- package/lib/hooks/useMergedEventCallbacks.js +26 -0
- package/lib/hooks/useMergedEventCallbacks.js.map +1 -0
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/utils/applyTriggerPropsToChildren.d.ts +1 -1
- package/lib/utils/applyTriggerPropsToChildren.js +19 -2
- package/lib/utils/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/utils/getReactCallbackName.d.ts +25 -0
- package/lib/utils/getReactCallbackName.js +26 -0
- package/lib/utils/getReactCallbackName.js.map +1 -0
- package/lib/utils/getTriggerChild.d.ts +22 -0
- package/lib/utils/getTriggerChild.js +26 -0
- package/lib/utils/getTriggerChild.js.map +1 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +2 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isFluentTrigger.d.ts +22 -0
- package/lib/utils/isFluentTrigger.js +8 -0
- package/lib/utils/isFluentTrigger.js.map +1 -0
- package/lib/utils/properties.js +40 -20
- package/lib/utils/properties.js.map +1 -1
- package/lib-commonjs/compose/getSlots.d.ts +11 -10
- package/lib-commonjs/compose/getSlots.js +6 -4
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.d.ts +5 -5
- package/lib-commonjs/compose/resolveShorthand.js +3 -3
- package/lib-commonjs/compose/types.d.ts +48 -26
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/hooks/index.d.ts +1 -1
- package/lib-commonjs/hooks/index.js +2 -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/useMergedEventCallbacks.d.ts +18 -0
- package/lib-commonjs/hooks/useMergedEventCallbacks.js +36 -0
- package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -0
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +1 -1
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js +19 -2
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.d.ts +25 -0
- package/lib-commonjs/utils/getReactCallbackName.js +35 -0
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -0
- package/lib-commonjs/utils/getTriggerChild.d.ts +22 -0
- package/lib-commonjs/utils/getTriggerChild.js +37 -0
- package/lib-commonjs/utils/getTriggerChild.js.map +1 -0
- package/lib-commonjs/utils/index.d.ts +2 -1
- package/lib-commonjs/utils/index.js +4 -2
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isFluentTrigger.d.ts +22 -0
- package/lib-commonjs/utils/isFluentTrigger.js +17 -0
- package/lib-commonjs/utils/isFluentTrigger.js.map +1 -0
- package/lib-commonjs/utils/properties.js +40 -20
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/package.json +3 -7
- 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/utils/onlyChild.d.ts +0 -5
- package/lib/utils/onlyChild.js +0 -13
- package/lib/utils/onlyChild.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/lib-commonjs/utils/onlyChild.d.ts +0 -5
- package/lib-commonjs/utils/onlyChild.js +0 -23
- package/lib-commonjs/utils/onlyChild.js.map +0 -1
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
|
* @deprec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;;;;;;;;;;AAaG;AACH;;AACA,OAAM,SAAU,cAAV,EACJ;AACA,KAFI,EAGJ,gBAHI,EAIJ,iBAJI,EAIwB;AAE5B;AACA;AACA;AACA;AACA;AAEA,QAAM,OAAO,GAAG,KAAK,CAAC,OAAN,CAAc,gBAAd,CAAhB,CAR4B,CAS5B;;AACA,QAAM,MAAM,GAAwB,EAApC;AACA,QAAM,IAAI,GAAG,MAAM,CAAC,IAAP,CAAY,KAAZ,CAAb;;AAEA,OAAK,MAAM,GAAX,IAAkB,IAAlB,EAAwB;AACtB,UAAM,YAAY,GACf,CAAC,OAAD,IAAa,gBAA2C,CAAC,GAAD,CAAzD,IACC,OAAO,IAAK,gBAA6B,CAAC,OAA9B,CAAsC,GAAtC,KAA8C,CAD3D,IAEA,GAAG,CAAC,OAAJ,CAAY,OAAZ,MAAyB,CAFzB,IAGA,GAAG,CAAC,OAAJ,CAAY,OAAZ,MAAyB,CAJ3B;;AAMA,QAAI,YAAY,KAAK,CAAC,iBAAD,IAAsB,CAAA,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAE,OAAnB,CAA2B,GAA3B,CAAA,MAAoC,CAAC,CAAhE,CAAhB,EAAoF;AAClF;AACA,MAAA,MAAM,CAAC,GAAD,CAAN,GAAc,KAAM,CAAC,GAAD,CAApB;AACD;AACF;;AAED,SAAO,MAAP;AACD","sourceRoot":""}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { AsIntrinsicElement, ComponentState,
|
3
|
-
export declare type Slots<S extends
|
4
|
-
[K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? As : S[K] extends
|
2
|
+
import type { AsIntrinsicElement, ComponentState, SlotProps, SlotPropsRecord, UnionToIntersection } from './types';
|
3
|
+
export declare type Slots<S extends SlotPropsRecord> = {
|
4
|
+
[K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? As : S[K] extends SlotProps<infer P> ? React.ElementType<NonNullable<P>> : React.ElementType<NonNullable<S[K]>>;
|
5
5
|
};
|
6
|
-
declare type
|
7
|
-
[K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : NonNullable<S[K]> extends
|
6
|
+
declare type ObjectSlotProps<S extends SlotPropsRecord> = {
|
7
|
+
[K in keyof S]-?: NonNullable<S[K]> extends AsIntrinsicElement<infer As> ? UnionToIntersection<JSX.IntrinsicElements[As]> : NonNullable<S[K]> extends SlotProps<infer P> ? P : never;
|
8
8
|
};
|
9
9
|
/**
|
10
10
|
* Given the state and an array of slot names, will break out `slots` and `slotProps`
|
@@ -15,15 +15,16 @@ 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
|
26
|
+
export declare function getSlots<R extends SlotPropsRecord>(state: ComponentState<R>): {
|
26
27
|
slots: Slots<R>;
|
27
|
-
slotProps:
|
28
|
+
slotProps: ObjectSlotProps<R>;
|
28
29
|
};
|
29
30
|
export {};
|
@@ -19,18 +19,20 @@ const omit_1 = /*#__PURE__*/require("../utils/omit");
|
|
19
19
|
* Slots will render as null if they are rendered as primitives with undefined children.
|
20
20
|
*
|
21
21
|
* The slotProps will always omit the `as` prop within them, and for slots that are string
|
22
|
-
* primitives, the props will be filtered according
|
23
|
-
* slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
22
|
+
* primitives, the props will be filtered according to the slot type by the type system.
|
23
|
+
* For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable
|
24
|
+
* anchor props. Note that this is only enforced at build time by Typescript -- there is no
|
25
|
+
* runtime code filtering props in this function.
|
24
26
|
*
|
25
27
|
* @param state - State including slot definitions
|
26
|
-
* @param slotNames - Name of which props are slots
|
27
28
|
* @returns An object containing the `slots` map and `slotProps` map.
|
28
29
|
*/
|
29
30
|
|
30
31
|
|
31
|
-
function getSlots(state
|
32
|
+
function getSlots(state) {
|
32
33
|
const slots = {};
|
33
34
|
const slotProps = {};
|
35
|
+
const slotNames = Object.keys(state.components);
|
34
36
|
|
35
37
|
for (const slotName of slotNames) {
|
36
38
|
const [slot, props] = getSlot(state, slotName);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/compose/getSlots.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;
|
1
|
+
{"version":3,"sources":["../../src/compose/getSlots.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AACA,MAAA,MAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;AA6BA;;;;;;;;;;;;;;;;AAgBG;;;AACH,SAAgB,QAAhB,CACE,KADF,EAC0B;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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AAG,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,MAAA,CAAA,IAAA,CAAK,KAAK,CAAC,QAAD,CAAV,EAAuB,CAAC,IAAD,CAAvB,CAAH,GAAoC,KAAK,CAAC,QAAD,CAA5E;AAEA,SAAO,CAAC,IAAD,EAAO,SAAP,CAAP;AACD","sourceRoot":""}
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import type {
|
1
|
+
import type { UnknownSlotProps, ShorthandProps } from './types';
|
2
2
|
export declare type ResolveShorthandOptions<Props extends Record<string, any>, Required extends boolean = false> = {
|
3
3
|
required?: Required;
|
4
4
|
defaultProps?: Props;
|
5
5
|
};
|
6
6
|
/**
|
7
|
-
* Resolves
|
7
|
+
* Resolves shorthands into slot props, to ensure normalization of the signature
|
8
8
|
* being passed down to getSlots method
|
9
|
-
* @param value - the base
|
10
|
-
* @param options - options to resolve
|
9
|
+
* @param value - the base shorthand props
|
10
|
+
* @param options - options to resolve shorthand props
|
11
11
|
*/
|
12
|
-
export declare function resolveShorthand<Props extends
|
12
|
+
export declare function resolveShorthand<Props extends UnknownSlotProps, Required extends boolean = false>(value: ShorthandProps<Props>, options?: ResolveShorthandOptions<Props, Required>): Required extends false ? Props | undefined : Props;
|
@@ -7,10 +7,10 @@ exports.resolveShorthand = void 0;
|
|
7
7
|
|
8
8
|
const react_1 = /*#__PURE__*/require("react");
|
9
9
|
/**
|
10
|
-
* Resolves
|
10
|
+
* Resolves shorthands into slot props, to ensure normalization of the signature
|
11
11
|
* being passed down to getSlots method
|
12
|
-
* @param value - the base
|
13
|
-
* @param options - options to resolve
|
12
|
+
* @param value - the base shorthand props
|
13
|
+
* @param options - options to resolve shorthand props
|
14
14
|
*/
|
15
15
|
|
16
16
|
|
@@ -1,45 +1,60 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
export declare type
|
3
|
-
export declare type
|
4
|
-
export declare type ShorthandProps<Props extends
|
2
|
+
export declare type SlotRenderFunction<Props> = (Component: React.ElementType<Props>, props: Omit<Props, 'children' | 'as'>) => React.ReactNode;
|
3
|
+
export declare type SlotPropsRecord = Record<string, UnknownSlotProps | undefined>;
|
4
|
+
export declare type ShorthandProps<Props extends UnknownSlotProps> = React.ReactChild | React.ReactNodeArray | React.ReactPortal | number | null | undefined | Props;
|
5
5
|
/**
|
6
|
-
* Matches any
|
6
|
+
* Matches any slot props type.
|
7
7
|
*
|
8
|
-
* This should ONLY be used in type templates as in `extends
|
8
|
+
* This should ONLY be used in type templates as in `extends DefaultObjectSlotProps`;
|
9
9
|
* it shouldn't be used as the type of a slot.
|
10
10
|
*/
|
11
|
-
export declare type
|
11
|
+
export declare type UnknownSlotProps = SlotProps<Pick<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'> & {
|
12
12
|
as?: keyof JSX.IntrinsicElements;
|
13
13
|
}>;
|
14
14
|
/**
|
15
|
-
*
|
16
|
-
*
|
17
|
-
* For intrinsic elements like 'div', use {@link IntrinsicShorthandProps} instead.
|
15
|
+
* Takes the props we want to support for a slot and adds the ability for `children` to be a render function that takes
|
16
|
+
* those props.
|
18
17
|
*/
|
19
|
-
export declare type
|
18
|
+
export declare type SlotProps<Props extends {
|
20
19
|
children?: React.ReactNode;
|
21
20
|
} = {}> = Props & {
|
22
|
-
children?: Props['children'] |
|
21
|
+
children?: Props['children'] | SlotRenderFunction<Props>;
|
23
22
|
};
|
23
|
+
/**
|
24
|
+
* Defines the slot props for a slot that supports a Component type.
|
25
|
+
*
|
26
|
+
* For intrinsic/native elements like 'div', use {@link IntrinsicSlotProps} instead.
|
27
|
+
*
|
28
|
+
* The generic param is the type of a control, i.e. a React component. For example:
|
29
|
+
*
|
30
|
+
* @example
|
31
|
+
* ```
|
32
|
+
* type Props = {...}
|
33
|
+
* const Button: React.FC<Props> = () => {...}
|
34
|
+
* // $ExpectType ...
|
35
|
+
* type SlotProps = ComponentSlotProps<typeof Button>
|
36
|
+
* ```
|
37
|
+
*/
|
38
|
+
export declare type ComponentSlotProps<Component extends React.ComponentType> = Component extends React.ComponentType<infer Props> ? SlotProps<Props> : never;
|
24
39
|
/**
|
25
40
|
* Define the slot arguments for a slot that supports one or more intrinsic element types, such as 'div'.
|
26
|
-
* For slots that support custom components, use {@link
|
41
|
+
* For slots that support custom components, use {@link ComponentSlotProps} instead.
|
27
42
|
*
|
28
43
|
* The first param is the slot's default type if no `as` prop is specified.
|
29
44
|
* The second param is an optional union of alternative types that can be specified for the `as` prop.
|
30
45
|
*
|
31
46
|
* ```
|
32
|
-
*
|
33
|
-
*
|
34
|
-
*
|
47
|
+
* IntrinsicSlotProps<'div'> // Slot is always div
|
48
|
+
* IntrinsicSlotProps<'button', 'a'> // Defaults to button, but allows as="a" with anchor-specific props
|
49
|
+
* IntrinsicSlotProps<'label', 'span' | 'div'>; // Defaults to label, but allows as="span" or as="div"
|
35
50
|
* ```
|
36
51
|
*/
|
37
|
-
export declare type
|
52
|
+
export declare type IntrinsicSlotProps<DefaultAs extends keyof JSX.IntrinsicElements, AlternateAs extends keyof JSX.IntrinsicElements = never> = IsSingleton<DefaultAs> extends false ? 'Error: first parameter to IntrinsicSlotProps must be a single element type, not a union of types' : ({
|
38
53
|
as?: DefaultAs;
|
39
|
-
} &
|
54
|
+
} & SlotProps<React.PropsWithRef<JSX.IntrinsicElements[DefaultAs]>>) | {
|
40
55
|
[As in AlternateAs]: {
|
41
56
|
as: As;
|
42
|
-
} &
|
57
|
+
} & SlotProps<React.PropsWithRef<JSX.IntrinsicElements[As]>>;
|
43
58
|
}[AlternateAs];
|
44
59
|
/**
|
45
60
|
* Evaluates to true if the given type contains exactly one string, or false if it is a union of strings.
|
@@ -69,20 +84,27 @@ export declare type AsIntrinsicElement<As extends keyof JSX.IntrinsicElements> =
|
|
69
84
|
export declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
|
70
85
|
/**
|
71
86
|
* Removes the 'ref' prop from the given Props type, leaving unions intact (such as the discriminated union created by
|
72
|
-
*
|
87
|
+
* IntrinsicSlotProps). This allows IntrinsicSlotProps to be used with React.forwardRef.
|
73
88
|
*
|
74
89
|
* The conditional "extends unknown" (always true) exploits a quirk in the way TypeScript handles conditional
|
75
90
|
* types, to prevent unions from being expanded.
|
76
91
|
*/
|
77
92
|
export declare type PropsWithoutRef<P> = 'ref' extends keyof P ? (P extends unknown ? Omit<P, 'ref'> : P) : P;
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
93
|
+
/**
|
94
|
+
* Defines the Props type for a component given its slots and the definition of which one is the primary slot,
|
95
|
+
* defaulting to root if one is not provided.
|
96
|
+
*/
|
97
|
+
export declare type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> = Omit<{
|
98
|
+
[Key in keyof Slots]?: ShorthandProps<NonNullable<Slots[Key]>>;
|
99
|
+
}, Primary & 'root'> & PropsWithoutRef<Slots[Primary]>;
|
100
|
+
/**
|
101
|
+
* Defines the State object of a component given its slots.
|
102
|
+
*/
|
103
|
+
export declare type ComponentState<Slots extends SlotPropsRecord> = {
|
104
|
+
components: {
|
105
|
+
[Key in keyof Slots]-?: React.ComponentType<NonNullable<Slots[Key]> extends SlotProps<infer P> ? P : NonNullable<Slots[Key]>> | (NonNullable<Slots[Key]> extends AsIntrinsicElement<infer As> ? As : keyof JSX.IntrinsicElements);
|
84
106
|
};
|
85
|
-
} &
|
107
|
+
} & Slots;
|
86
108
|
/**
|
87
109
|
* This is part of a hack to infer the element type from a native element *props* type.
|
88
110
|
* The only place the original element is found in a native props type (at least that's workable
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/compose/types.ts"],"names":[],"mappings":";;;;
|
1
|
+
{"version":3,"sources":["../../src/compose/types.ts"],"names":[],"mappings":";;;;IAyKA;AACA;AACA;AACA;AACA","sourceRoot":""}
|
@@ -1,11 +1,11 @@
|
|
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';
|
8
7
|
export * from './useIsomorphicLayoutEffect';
|
8
|
+
export * from './useMergedEventCallbacks';
|
9
9
|
export * from './useMergedRefs';
|
10
10
|
export * from './useMount';
|
11
11
|
export * from './useOnClickOutside';
|
@@ -12,8 +12,6 @@ tslib_1.__exportStar(require("./useBoolean"), exports);
|
|
12
12
|
|
13
13
|
tslib_1.__exportStar(require("./useConst"), exports);
|
14
14
|
|
15
|
-
tslib_1.__exportStar(require("./useControllableValue"), exports);
|
16
|
-
|
17
15
|
tslib_1.__exportStar(require("./useEventCallback"), exports);
|
18
16
|
|
19
17
|
tslib_1.__exportStar(require("./useFirstMount"), exports);
|
@@ -22,6 +20,8 @@ tslib_1.__exportStar(require("./useId"), exports);
|
|
22
20
|
|
23
21
|
tslib_1.__exportStar(require("./useIsomorphicLayoutEffect"), exports);
|
24
22
|
|
23
|
+
tslib_1.__exportStar(require("./useMergedEventCallbacks"), exports);
|
24
|
+
|
25
25
|
tslib_1.__exportStar(require("./useMergedRefs"), exports);
|
26
26
|
|
27
27
|
tslib_1.__exportStar(require("./useMount"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,
|
1
|
+
{"version":3,"sources":["../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,6BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA","sourceRoot":""}
|
@@ -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>>];
|
@@ -9,23 +9,28 @@ const React = /*#__PURE__*/require("react");
|
|
9
9
|
|
10
10
|
const useConst_1 = /*#__PURE__*/require("./useConst");
|
11
11
|
|
12
|
-
function isUndefined(state) {
|
13
|
-
return typeof state === 'undefined';
|
14
|
-
}
|
15
|
-
|
16
12
|
function isFactoryDispatch(newState) {
|
17
13
|
return typeof newState === 'function';
|
18
14
|
}
|
19
15
|
/**
|
20
|
-
* A useState
|
21
|
-
*
|
22
|
-
*
|
16
|
+
* A `useState`-like hook to manage a value that could be either controlled or uncontrolled,
|
17
|
+
* such as a checked state or text input string.
|
18
|
+
*
|
19
|
+
* Unlike `setState`, it's okay to call the returned updater (dispatch) function for either a
|
20
|
+
* controlled or uncontrolled component. Calls will only be respected if the component is uncontrolled.
|
21
|
+
*
|
22
|
+
* @returns Same as [`useState`](https://reactjs.org/docs/hooks-reference.html#usestate): an array
|
23
|
+
* of the current value and an updater (dispatch) function. The updater function is referentially
|
24
|
+
* stable (won't change during the component's lifecycle). It can take either a new value, or a
|
25
|
+
* function which is passed the previous value and returns the new value. Unlike `setState`, calls
|
26
|
+
* to the updater function will only be respected if the component is uncontrolled.
|
27
|
+
* @see https://reactjs.org/docs/uncontrolled-components.html
|
23
28
|
*/
|
24
29
|
|
25
30
|
|
26
31
|
const useControllableState = options => {
|
27
32
|
const isControlled = useIsControlled(options.state);
|
28
|
-
const initialState =
|
33
|
+
const initialState = typeof options.defaultState === 'undefined' ? options.initialState : options.defaultState;
|
29
34
|
const [internalState, setInternalState] = React.useState(initialState);
|
30
35
|
const state = isControlled ? options.state : internalState;
|
31
36
|
const stateRef = React.useRef(state);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,UAAA,gBAAA,OAAA,CAAA,YAAA,CAAA;;
|
1
|
+
{"version":3,"sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,UAAA,gBAAA,OAAA,CAAA,YAAA,CAAA;;AAkBA,SAAS,iBAAT,CAAkC,QAAlC,EAAuE;AACrE,SAAO,OAAO,QAAP,KAAoB,UAA3B;AACD;AAED;;;;;;;;;;;;;AAaG;;;AACI,MAAM,oBAAoB,GAC/B,OADkC,IAEsB;A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,UAAI,YAAY,MAAM,eAAe,KAAK,SAA1B,CAAhB,EAAsD;AACpD,cAAM,KAAK,GAAG,IAAI,KAAJ,EAAd;AAEA,cAAM,cAAc,GAAG,YAAY,GAC/B,uCAD+B,GAE/B,wCAFJ;AAIA,cAAM,gBAAgB,GAAG,YAAY,GAAG,yBAAH,GAA+B,wBAApE,CAPoD,CASpD;;AACA,QAAA,OAAO,CAAC,KAAR,CACE,CACE;AACA,qCAA6B,cAA7B,GAA8C,sCAFhD,EAGE,mBAAmB,gBAAnB,GAAsC,kCAHxC,EAIE,oGAJF,EAKE,2DALF,EAME,KAAK,CAAC,KANR,EAOE,IAPF,CAOO,GAPP,CADF;AAUD;AACF,KAtBD,EAsBG,CAAC,YAAD,EAAe,eAAf,CAtBH;AAuBD;;AAED,SAAO,YAAP;AACD,CAhCD","sourceRoot":""}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* Combine two event callbacks into a single callback function that calls each one in order.
|
3
|
+
*
|
4
|
+
* This is useful to add an event listener to an existing element without overwriting the current listener, if any.
|
5
|
+
*
|
6
|
+
* For example:
|
7
|
+
* ```ts
|
8
|
+
* state.slot.onChange = useMergedCallbacks(state.slot.onChange, ev => {
|
9
|
+
* // Handle onChange
|
10
|
+
* });
|
11
|
+
* ```
|
12
|
+
*
|
13
|
+
* @param callback1 - The first callback to be called
|
14
|
+
* @param callback2 - The second callback to be called
|
15
|
+
*
|
16
|
+
* @returns An event callback that calls the callbacks in order, and is stable between renders
|
17
|
+
*/
|
18
|
+
export declare function useMergedEventCallbacks<Args extends unknown[]>(callback1: ((...args: Args) => void) | undefined, callback2: ((...args: Args) => void) | undefined): (...args: Args) => void;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useMergedEventCallbacks = void 0;
|
7
|
+
|
8
|
+
const useEventCallback_1 = /*#__PURE__*/require("./useEventCallback");
|
9
|
+
/**
|
10
|
+
* Combine two event callbacks into a single callback function that calls each one in order.
|
11
|
+
*
|
12
|
+
* This is useful to add an event listener to an existing element without overwriting the current listener, if any.
|
13
|
+
*
|
14
|
+
* For example:
|
15
|
+
* ```ts
|
16
|
+
* state.slot.onChange = useMergedCallbacks(state.slot.onChange, ev => {
|
17
|
+
* // Handle onChange
|
18
|
+
* });
|
19
|
+
* ```
|
20
|
+
*
|
21
|
+
* @param callback1 - The first callback to be called
|
22
|
+
* @param callback2 - The second callback to be called
|
23
|
+
*
|
24
|
+
* @returns An event callback that calls the callbacks in order, and is stable between renders
|
25
|
+
*/
|
26
|
+
|
27
|
+
|
28
|
+
function useMergedEventCallbacks(callback1, callback2) {
|
29
|
+
return useEventCallback_1.useEventCallback((...args) => {
|
30
|
+
callback1 === null || callback1 === void 0 ? void 0 : callback1(...args);
|
31
|
+
callback2 === null || callback2 === void 0 ? void 0 : callback2(...args);
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
exports.useMergedEventCallbacks = useMergedEventCallbacks;
|
36
|
+
//# sourceMappingURL=useMergedEventCallbacks.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useMergedEventCallbacks.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AAEA;;;;;;;;;;;;;;;;AAgBG;;;AACH,SAAgB,uBAAhB,CACE,SADF,EAEE,SAFF,EAEkD;AAEhD,SAAO,kBAAA,CAAA,gBAAA,CAAiB,CAAC,GAAG,IAAJ,KAAkB;AACxC,IAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAG,GAAG,IAAN,CAAT;AACA,IAAA,SAAS,KAAA,IAAT,IAAA,SAAS,KAAA,KAAA,CAAT,GAAS,KAAA,CAAT,GAAA,SAAS,CAAG,GAAG,IAAN,CAAT;AACD,GAHM,CAAP;AAID;;AARD,OAAA,CAAA,uBAAA,GAAA,uBAAA","sourceRoot":""}
|