@fluentui/react-utilities 9.9.0 → 9.9.2
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 +46 -1
- package/CHANGELOG.md +20 -2
- package/dist/index.d.ts +1 -1
- package/lib/compose/constants.js +1 -2
- package/lib/compose/constants.js.map +1 -1
- package/lib/compose/getSlots.js +40 -36
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/getSlotsNext.js +30 -28
- package/lib/compose/getSlotsNext.js.map +1 -1
- package/lib/compose/index.js +0 -1
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/isResolvedShorthand.js +2 -4
- package/lib/compose/isResolvedShorthand.js.map +1 -1
- package/lib/compose/resolveShorthand.js +21 -26
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/compose/types.js +0 -1
- package/lib/compose/types.js.map +1 -1
- package/lib/events/index.js +0 -1
- package/lib/events/index.js.map +1 -1
- package/lib/events/mouseTouchHelpers.js +27 -27
- package/lib/events/mouseTouchHelpers.js.map +1 -1
- package/lib/hooks/index.js +0 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useControllableState.js +57 -32
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useEventCallback.js +15 -13
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.js +7 -9
- package/lib/hooks/useFirstMount.js.map +1 -1
- package/lib/hooks/useForceUpdate.js +2 -4
- package/lib/hooks/useForceUpdate.js.map +1 -1
- package/lib/hooks/useId.js +32 -29
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js +1 -2
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedRefs.js +17 -18
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +110 -114
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js +25 -29
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js +8 -8
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useScrollbarWidth.js +24 -26
- package/lib/hooks/useScrollbarWidth.js.map +1 -1
- package/lib/hooks/useTimeout.js +22 -19
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/ssr/SSRContext.js +40 -39
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js +3 -5
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/ssr/index.js +0 -1
- package/lib/ssr/index.js.map +1 -1
- package/lib/trigger/applyTriggerPropsToChildren.js +20 -23
- package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/trigger/getTriggerChild.js +7 -10
- package/lib/trigger/getTriggerChild.js.map +1 -1
- package/lib/trigger/index.js +0 -1
- package/lib/trigger/index.js.map +1 -1
- package/lib/trigger/isFluentTrigger.js +2 -4
- package/lib/trigger/isFluentTrigger.js.map +1 -1
- package/lib/trigger/types.js +0 -1
- package/lib/trigger/types.js.map +1 -1
- package/lib/utils/clamp.js +1 -2
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getNativeElementProps.js +38 -40
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js +12 -13
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js +16 -15
- package/lib/utils/getReactCallbackName.js.map +1 -1
- package/lib/utils/index.js +0 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isHTMLElement.js +5 -6
- package/lib/utils/isHTMLElement.js.map +1 -1
- package/lib/utils/isInteractiveHTMLElement.js +13 -17
- package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib/utils/mergeCallbacks.js +5 -6
- package/lib/utils/mergeCallbacks.js.map +1 -1
- package/lib/utils/omit.js +7 -8
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/priorityQueue.js +85 -86
- package/lib/utils/priorityQueue.js.map +1 -1
- package/lib/utils/properties.js +290 -80
- package/lib/utils/properties.js.map +1 -1
- package/lib-commonjs/compose/constants.js +1 -3
- package/lib-commonjs/compose/constants.js.map +1 -1
- package/lib-commonjs/compose/getSlots.js +1 -3
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/getSlotsNext.js +2 -3
- package/lib-commonjs/compose/getSlotsNext.js.map +1 -1
- package/lib-commonjs/compose/index.js +0 -3
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/isResolvedShorthand.js +1 -3
- package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js +1 -3
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/types.js +0 -3
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/events/index.js +0 -3
- package/lib-commonjs/events/index.js.map +1 -1
- package/lib-commonjs/events/mouseTouchHelpers.js +1 -3
- package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
- package/lib-commonjs/hooks/index.js +0 -3
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.js +18 -6
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js +1 -3
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js +1 -3
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js +1 -3
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.js +1 -3
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +1 -3
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +2 -5
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +1 -3
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js +1 -3
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js +1 -3
- package/lib-commonjs/hooks/usePrevious.js.map +1 -1
- package/lib-commonjs/hooks/useScrollbarWidth.js +2 -4
- package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js +1 -3
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/index.js +0 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js +1 -3
- package/lib-commonjs/ssr/SSRContext.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js +1 -3
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
- package/lib-commonjs/ssr/index.js +0 -3
- package/lib-commonjs/ssr/index.js.map +1 -1
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +1 -3
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/trigger/getTriggerChild.js +2 -5
- package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
- package/lib-commonjs/trigger/index.js +0 -3
- package/lib-commonjs/trigger/index.js.map +1 -1
- package/lib-commonjs/trigger/isFluentTrigger.js +1 -3
- package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
- package/lib-commonjs/trigger/types.js +0 -3
- package/lib-commonjs/trigger/types.js.map +1 -1
- package/lib-commonjs/utils/clamp.js +1 -3
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.js +1 -3
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js +1 -3
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.js +1 -3
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -3
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isHTMLElement.js +1 -3
- package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/isInteractiveHTMLElement.js +1 -3
- package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/mergeCallbacks.js +1 -3
- package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
- package/lib-commonjs/utils/omit.js +1 -3
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/priorityQueue.js +5 -7
- package/lib-commonjs/utils/priorityQueue.js.map +1 -1
- package/lib-commonjs/utils/properties.js +28 -31
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/package.json +2 -2
package/lib/utils/properties.js
CHANGED
@@ -1,166 +1,378 @@
|
|
1
|
-
const toObjectMap = (...items)
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
const toObjectMap = (...items)=>{
|
2
|
+
const result = {};
|
3
|
+
for (const item of items){
|
4
|
+
const keys = Array.isArray(item) ? item : Object.keys(item);
|
5
|
+
for (const key of keys){
|
6
|
+
result[key] = 1;
|
7
|
+
}
|
7
8
|
}
|
8
|
-
|
9
|
-
return result;
|
9
|
+
return result;
|
10
10
|
};
|
11
11
|
/**
|
12
12
|
* An array of events that are allowed on every html element type.
|
13
13
|
*
|
14
14
|
* @public
|
15
|
-
*/
|
16
|
-
|
15
|
+
*/ export const baseElementEvents = toObjectMap([
|
16
|
+
'onAuxClick',
|
17
|
+
'onCopy',
|
18
|
+
'onCut',
|
19
|
+
'onPaste',
|
20
|
+
'onCompositionEnd',
|
21
|
+
'onCompositionStart',
|
22
|
+
'onCompositionUpdate',
|
23
|
+
'onFocus',
|
24
|
+
'onFocusCapture',
|
25
|
+
'onBlur',
|
26
|
+
'onBlurCapture',
|
27
|
+
'onChange',
|
28
|
+
'onInput',
|
29
|
+
'onSubmit',
|
30
|
+
'onLoad',
|
31
|
+
'onError',
|
32
|
+
'onKeyDown',
|
33
|
+
'onKeyDownCapture',
|
34
|
+
'onKeyPress',
|
35
|
+
'onKeyUp',
|
36
|
+
'onAbort',
|
37
|
+
'onCanPlay',
|
38
|
+
'onCanPlayThrough',
|
39
|
+
'onDurationChange',
|
40
|
+
'onEmptied',
|
41
|
+
'onEncrypted',
|
42
|
+
'onEnded',
|
43
|
+
'onLoadedData',
|
44
|
+
'onLoadedMetadata',
|
45
|
+
'onLoadStart',
|
46
|
+
'onPause',
|
47
|
+
'onPlay',
|
48
|
+
'onPlaying',
|
49
|
+
'onProgress',
|
50
|
+
'onRateChange',
|
51
|
+
'onSeeked',
|
52
|
+
'onSeeking',
|
53
|
+
'onStalled',
|
54
|
+
'onSuspend',
|
55
|
+
'onTimeUpdate',
|
56
|
+
'onVolumeChange',
|
57
|
+
'onWaiting',
|
58
|
+
'onClick',
|
59
|
+
'onClickCapture',
|
60
|
+
'onContextMenu',
|
61
|
+
'onDoubleClick',
|
62
|
+
'onDrag',
|
63
|
+
'onDragEnd',
|
64
|
+
'onDragEnter',
|
65
|
+
'onDragExit',
|
66
|
+
'onDragLeave',
|
67
|
+
'onDragOver',
|
68
|
+
'onDragStart',
|
69
|
+
'onDrop',
|
70
|
+
'onMouseDown',
|
71
|
+
'onMouseDownCapture',
|
72
|
+
'onMouseEnter',
|
73
|
+
'onMouseLeave',
|
74
|
+
'onMouseMove',
|
75
|
+
'onMouseOut',
|
76
|
+
'onMouseOver',
|
77
|
+
'onMouseUp',
|
78
|
+
'onMouseUpCapture',
|
79
|
+
'onSelect',
|
80
|
+
'onTouchCancel',
|
81
|
+
'onTouchEnd',
|
82
|
+
'onTouchMove',
|
83
|
+
'onTouchStart',
|
84
|
+
'onScroll',
|
85
|
+
'onWheel',
|
86
|
+
'onPointerCancel',
|
87
|
+
'onPointerDown',
|
88
|
+
'onPointerEnter',
|
89
|
+
'onPointerLeave',
|
90
|
+
'onPointerMove',
|
91
|
+
'onPointerOut',
|
92
|
+
'onPointerOver',
|
93
|
+
'onPointerUp',
|
94
|
+
'onGotPointerCapture',
|
95
|
+
'onLostPointerCapture'
|
96
|
+
]);
|
17
97
|
/**
|
18
98
|
* An array of element attributes which are allowed on every html element type.
|
19
99
|
*
|
20
100
|
* @public
|
21
|
-
*/
|
22
|
-
|
101
|
+
*/ export const baseElementProperties = toObjectMap([
|
102
|
+
'accessKey',
|
103
|
+
'children',
|
104
|
+
'className',
|
105
|
+
'contentEditable',
|
106
|
+
'dir',
|
107
|
+
'draggable',
|
108
|
+
'hidden',
|
109
|
+
'htmlFor',
|
110
|
+
'id',
|
111
|
+
'lang',
|
112
|
+
'ref',
|
113
|
+
'role',
|
114
|
+
'style',
|
115
|
+
'tabIndex',
|
116
|
+
'title',
|
117
|
+
'translate',
|
118
|
+
'spellCheck',
|
119
|
+
'name'
|
120
|
+
]);
|
23
121
|
/**
|
24
122
|
* An array of microdata attributes that are allowed on every html element type.
|
25
123
|
*
|
26
124
|
* @public
|
27
|
-
*/
|
28
|
-
|
125
|
+
*/ export const microdataProperties = toObjectMap([
|
126
|
+
'itemID',
|
127
|
+
'itemProp',
|
128
|
+
'itemRef',
|
129
|
+
'itemScope',
|
130
|
+
'itemType'
|
131
|
+
]);
|
29
132
|
/**
|
30
133
|
* An array of HTML element properties and events.
|
31
134
|
*
|
32
135
|
* @public
|
33
|
-
*/
|
34
|
-
export const htmlElementProperties = /*#__PURE__*/toObjectMap(baseElementProperties, baseElementEvents, microdataProperties);
|
136
|
+
*/ export const htmlElementProperties = toObjectMap(baseElementProperties, baseElementEvents, microdataProperties);
|
35
137
|
/**
|
36
138
|
* An array of LABEL tag properties and events.
|
37
139
|
*
|
38
140
|
* @public
|
39
|
-
*/
|
40
|
-
|
141
|
+
*/ export const labelProperties = toObjectMap(htmlElementProperties, [
|
142
|
+
'form'
|
143
|
+
]);
|
41
144
|
/**
|
42
145
|
* An array of AUDIO tag properties and events.
|
43
146
|
|
44
147
|
* @public
|
45
|
-
*/
|
46
|
-
|
148
|
+
*/ export const audioProperties = toObjectMap(htmlElementProperties, [
|
149
|
+
'height',
|
150
|
+
'loop',
|
151
|
+
'muted',
|
152
|
+
'preload',
|
153
|
+
'src',
|
154
|
+
'width'
|
155
|
+
]);
|
47
156
|
/**
|
48
157
|
* An array of VIDEO tag properties and events.
|
49
158
|
*
|
50
159
|
* @public
|
51
|
-
*/
|
52
|
-
|
160
|
+
*/ export const videoProperties = toObjectMap(audioProperties, [
|
161
|
+
'poster'
|
162
|
+
]);
|
53
163
|
/**
|
54
164
|
* An array of OL tag properties and events.
|
55
165
|
*
|
56
166
|
* @public
|
57
|
-
*/
|
58
|
-
|
167
|
+
*/ export const olProperties = toObjectMap(htmlElementProperties, [
|
168
|
+
'start'
|
169
|
+
]);
|
59
170
|
/**
|
60
171
|
* An array of LI tag properties and events.
|
61
172
|
*
|
62
173
|
* @public
|
63
|
-
*/
|
64
|
-
|
174
|
+
*/ export const liProperties = toObjectMap(htmlElementProperties, [
|
175
|
+
'value'
|
176
|
+
]);
|
65
177
|
/**
|
66
178
|
* An array of A tag properties and events.
|
67
179
|
*
|
68
180
|
* @public
|
69
|
-
*/
|
70
|
-
|
181
|
+
*/ export const anchorProperties = toObjectMap(htmlElementProperties, [
|
182
|
+
'download',
|
183
|
+
'href',
|
184
|
+
'hrefLang',
|
185
|
+
'media',
|
186
|
+
'rel',
|
187
|
+
'target',
|
188
|
+
'type'
|
189
|
+
]);
|
71
190
|
/**
|
72
191
|
* An array of TIME tag properties and events.
|
73
192
|
*
|
74
193
|
* @public
|
75
|
-
*/
|
76
|
-
|
194
|
+
*/ export const timeProperties = toObjectMap(htmlElementProperties, [
|
195
|
+
'dateTime'
|
196
|
+
]);
|
77
197
|
/**
|
78
198
|
* An array of BUTTON tag properties and events.
|
79
199
|
*
|
80
200
|
* @public
|
81
|
-
*/
|
82
|
-
|
201
|
+
*/ export const buttonProperties = toObjectMap(htmlElementProperties, [
|
202
|
+
'autoFocus',
|
203
|
+
'disabled',
|
204
|
+
'form',
|
205
|
+
'formAction',
|
206
|
+
'formEncType',
|
207
|
+
'formMethod',
|
208
|
+
'formNoValidate',
|
209
|
+
'formTarget',
|
210
|
+
'type',
|
211
|
+
'value'
|
212
|
+
]);
|
83
213
|
/**
|
84
214
|
* An array of INPUT tag properties and events.
|
85
215
|
*
|
86
216
|
* @public
|
87
|
-
*/
|
88
|
-
|
217
|
+
*/ export const inputProperties = toObjectMap(buttonProperties, [
|
218
|
+
'accept',
|
219
|
+
'alt',
|
220
|
+
'autoCapitalize',
|
221
|
+
'autoComplete',
|
222
|
+
'checked',
|
223
|
+
'dirname',
|
224
|
+
'form',
|
225
|
+
'height',
|
226
|
+
'inputMode',
|
227
|
+
'list',
|
228
|
+
'max',
|
229
|
+
'maxLength',
|
230
|
+
'min',
|
231
|
+
'multiple',
|
232
|
+
'pattern',
|
233
|
+
'placeholder',
|
234
|
+
'readOnly',
|
235
|
+
'required',
|
236
|
+
'src',
|
237
|
+
'step',
|
238
|
+
'size',
|
239
|
+
'type',
|
240
|
+
'value',
|
241
|
+
'width'
|
242
|
+
]);
|
89
243
|
/**
|
90
244
|
* An array of TEXTAREA tag properties and events.
|
91
245
|
*
|
92
246
|
* @public
|
93
|
-
*/
|
94
|
-
|
247
|
+
*/ export const textAreaProperties = toObjectMap(buttonProperties, [
|
248
|
+
'autoCapitalize',
|
249
|
+
'cols',
|
250
|
+
'dirname',
|
251
|
+
'form',
|
252
|
+
'maxLength',
|
253
|
+
'placeholder',
|
254
|
+
'readOnly',
|
255
|
+
'required',
|
256
|
+
'rows',
|
257
|
+
'wrap'
|
258
|
+
]);
|
95
259
|
/**
|
96
260
|
* An array of SELECT tag properties and events.
|
97
261
|
*
|
98
262
|
* @public
|
99
|
-
*/
|
100
|
-
|
101
|
-
|
263
|
+
*/ export const selectProperties = toObjectMap(buttonProperties, [
|
264
|
+
'form',
|
265
|
+
'multiple',
|
266
|
+
'required'
|
267
|
+
]);
|
268
|
+
export const optionProperties = toObjectMap(htmlElementProperties, [
|
269
|
+
'selected',
|
270
|
+
'value'
|
271
|
+
]);
|
102
272
|
/**
|
103
273
|
* An array of TABLE tag properties and events.
|
104
274
|
*
|
105
275
|
* @public
|
106
|
-
*/
|
107
|
-
|
276
|
+
*/ export const tableProperties = toObjectMap(htmlElementProperties, [
|
277
|
+
'cellPadding',
|
278
|
+
'cellSpacing'
|
279
|
+
]);
|
108
280
|
/**
|
109
281
|
* An array of TR tag properties and events.
|
110
282
|
*
|
111
283
|
* @public
|
112
|
-
*/
|
113
|
-
export const trProperties = htmlElementProperties;
|
284
|
+
*/ export const trProperties = htmlElementProperties;
|
114
285
|
/**
|
115
286
|
* An array of TH tag properties and events.
|
116
287
|
*
|
117
288
|
* @public
|
118
|
-
*/
|
119
|
-
|
289
|
+
*/ export const thProperties = toObjectMap(htmlElementProperties, [
|
290
|
+
'colSpan',
|
291
|
+
'rowSpan',
|
292
|
+
'scope'
|
293
|
+
]);
|
120
294
|
/**
|
121
295
|
* An array of TD tag properties and events.
|
122
296
|
*
|
123
297
|
* @public
|
124
|
-
*/
|
125
|
-
|
126
|
-
|
127
|
-
|
298
|
+
*/ export const tdProperties = toObjectMap(htmlElementProperties, [
|
299
|
+
'colSpan',
|
300
|
+
'headers',
|
301
|
+
'rowSpan',
|
302
|
+
'scope'
|
303
|
+
]);
|
304
|
+
export const colGroupProperties = toObjectMap(htmlElementProperties, [
|
305
|
+
'span'
|
306
|
+
]);
|
307
|
+
export const colProperties = toObjectMap(htmlElementProperties, [
|
308
|
+
'span'
|
309
|
+
]);
|
128
310
|
/**
|
129
311
|
* An array of FIELDSET tag properties and events.
|
130
312
|
*
|
131
313
|
* @public
|
132
|
-
*/
|
133
|
-
|
314
|
+
*/ export const fieldsetProperties = toObjectMap(htmlElementProperties, [
|
315
|
+
'disabled',
|
316
|
+
'form'
|
317
|
+
]);
|
134
318
|
/**
|
135
319
|
* An array of FORM tag properties and events.
|
136
320
|
*
|
137
321
|
* @public
|
138
|
-
*/
|
139
|
-
|
322
|
+
*/ export const formProperties = toObjectMap(htmlElementProperties, [
|
323
|
+
'acceptCharset',
|
324
|
+
'action',
|
325
|
+
'encType',
|
326
|
+
'encType',
|
327
|
+
'method',
|
328
|
+
'noValidate',
|
329
|
+
'target'
|
330
|
+
]);
|
140
331
|
/**
|
141
332
|
* An array of IFRAME tag properties and events.
|
142
333
|
*
|
143
334
|
* @public
|
144
|
-
*/
|
145
|
-
|
335
|
+
*/ export const iframeProperties = toObjectMap(htmlElementProperties, [
|
336
|
+
'allow',
|
337
|
+
'allowFullScreen',
|
338
|
+
'allowPaymentRequest',
|
339
|
+
'allowTransparency',
|
340
|
+
'csp',
|
341
|
+
'height',
|
342
|
+
'importance',
|
343
|
+
'referrerPolicy',
|
344
|
+
'sandbox',
|
345
|
+
'src',
|
346
|
+
'srcDoc',
|
347
|
+
'width'
|
348
|
+
]);
|
146
349
|
/**
|
147
350
|
* An array of IMAGE tag properties and events.
|
148
351
|
*
|
149
352
|
* @public
|
150
|
-
*/
|
151
|
-
|
353
|
+
*/ export const imgProperties = toObjectMap(htmlElementProperties, [
|
354
|
+
'alt',
|
355
|
+
'crossOrigin',
|
356
|
+
'height',
|
357
|
+
'src',
|
358
|
+
'srcSet',
|
359
|
+
'useMap',
|
360
|
+
'width'
|
361
|
+
]);
|
152
362
|
/**
|
153
363
|
* An array of DIALOG tag properties and events.
|
154
364
|
*
|
155
365
|
* @public
|
156
|
-
*/
|
157
|
-
|
366
|
+
*/ export const dialogProperties = toObjectMap(htmlElementProperties, [
|
367
|
+
'open',
|
368
|
+
'onCancel',
|
369
|
+
'onClose'
|
370
|
+
]);
|
158
371
|
/**
|
159
372
|
* An array of DIV tag properties and events.
|
160
373
|
*
|
161
374
|
* @public
|
162
|
-
*/
|
163
|
-
export const divProperties = htmlElementProperties;
|
375
|
+
*/ export const divProperties = htmlElementProperties;
|
164
376
|
/**
|
165
377
|
* Gets native supported props for an html element provided the allowance set. Use one of the property
|
166
378
|
* sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given
|
@@ -176,25 +388,23 @@ export const divProperties = htmlElementProperties;
|
|
176
388
|
* @param excludedPropNames
|
177
389
|
* @returns The filtered props
|
178
390
|
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
179
|
-
export function getNativeProps(
|
180
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
391
|
+
export function getNativeProps(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
181
392
|
props, allowedPropNames, excludedPropNames) {
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
393
|
+
// It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for
|
394
|
+
// JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.
|
395
|
+
// Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then
|
396
|
+
// return native props.
|
397
|
+
// We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797
|
398
|
+
const isArray = Array.isArray(allowedPropNames);
|
399
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
400
|
+
const result = {};
|
401
|
+
const keys = Object.keys(props);
|
402
|
+
for (const key of keys){
|
403
|
+
const isNativeProp = !isArray && allowedPropNames[key] || isArray && allowedPropNames.indexOf(key) >= 0 || key.indexOf('data-') === 0 || key.indexOf('aria-') === 0;
|
404
|
+
if (isNativeProp && (!excludedPropNames || (excludedPropNames === null || excludedPropNames === void 0 ? void 0 : excludedPropNames.indexOf(key)) === -1)) {
|
405
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
406
|
+
result[key] = props[key];
|
407
|
+
}
|
196
408
|
}
|
197
|
-
|
198
|
-
return result;
|
409
|
+
return result;
|
199
410
|
}
|
200
|
-
//# sourceMappingURL=properties.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["toObjectMap","items","result","item","keys","Array","isArray","Object","key","baseElementEvents","baseElementProperties","microdataProperties","htmlElementProperties","labelProperties","audioProperties","videoProperties","olProperties","liProperties","anchorProperties","timeProperties","buttonProperties","inputProperties","textAreaProperties","selectProperties","optionProperties","tableProperties","trProperties","thProperties","tdProperties","colGroupProperties","colProperties","fieldsetProperties","formProperties","iframeProperties","imgProperties","dialogProperties","divProperties","getNativeProps","props","allowedPropNames","excludedPropNames","isNativeProp","indexOf"],"sources":["../../src/utils/properties.ts"],"sourcesContent":["const toObjectMap = (...items: (string[] | Record<string, number>)[]) => {\n const result: Record<string, number> = {};\n\n for (const item of items) {\n const keys = Array.isArray(item) ? item : Object.keys(item);\n\n for (const key of keys) {\n result[key] = 1;\n }\n }\n\n return result;\n};\n\n/**\n * An array of events that are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementEvents = toObjectMap([\n 'onAuxClick',\n 'onCopy',\n 'onCut',\n 'onPaste',\n 'onCompositionEnd',\n 'onCompositionStart',\n 'onCompositionUpdate',\n 'onFocus',\n 'onFocusCapture',\n 'onBlur',\n 'onBlurCapture',\n 'onChange',\n 'onInput',\n 'onSubmit',\n 'onLoad',\n 'onError',\n 'onKeyDown',\n 'onKeyDownCapture',\n 'onKeyPress',\n 'onKeyUp',\n 'onAbort',\n 'onCanPlay',\n 'onCanPlayThrough',\n 'onDurationChange',\n 'onEmptied',\n 'onEncrypted',\n 'onEnded',\n 'onLoadedData',\n 'onLoadedMetadata',\n 'onLoadStart',\n 'onPause',\n 'onPlay',\n 'onPlaying',\n 'onProgress',\n 'onRateChange',\n 'onSeeked',\n 'onSeeking',\n 'onStalled',\n 'onSuspend',\n 'onTimeUpdate',\n 'onVolumeChange',\n 'onWaiting',\n 'onClick',\n 'onClickCapture',\n 'onContextMenu',\n 'onDoubleClick',\n 'onDrag',\n 'onDragEnd',\n 'onDragEnter',\n 'onDragExit',\n 'onDragLeave',\n 'onDragOver',\n 'onDragStart',\n 'onDrop',\n 'onMouseDown',\n 'onMouseDownCapture',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseMove',\n 'onMouseOut',\n 'onMouseOver',\n 'onMouseUp',\n 'onMouseUpCapture',\n 'onSelect',\n 'onTouchCancel',\n 'onTouchEnd',\n 'onTouchMove',\n 'onTouchStart',\n 'onScroll',\n 'onWheel',\n 'onPointerCancel',\n 'onPointerDown',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerMove',\n 'onPointerOut',\n 'onPointerOver',\n 'onPointerUp',\n 'onGotPointerCapture',\n 'onLostPointerCapture',\n]);\n\n/**\n * An array of element attributes which are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementProperties = toObjectMap([\n 'accessKey', // global\n 'children', // global\n 'className', // global\n 'contentEditable', // global\n 'dir', // global\n 'draggable', // global\n 'hidden', // global\n 'htmlFor', // global\n 'id', // global\n 'lang', // global\n 'ref', // global\n 'role', // global\n 'style', // global\n 'tabIndex', // global\n 'title', // global\n 'translate', // global\n 'spellCheck', // global\n 'name', // global\n]);\n\n/**\n * An array of microdata attributes that are allowed on every html element type.\n *\n * @public\n */\nexport const microdataProperties = toObjectMap([\n 'itemID', // global\n 'itemProp', // global\n 'itemRef', // global\n 'itemScope', // global\n 'itemType', // global\n]);\n\n/**\n * An array of HTML element properties and events.\n *\n * @public\n */\nexport const htmlElementProperties = toObjectMap(baseElementProperties, baseElementEvents, microdataProperties);\n\n/**\n * An array of LABEL tag properties and events.\n *\n * @public\n */\nexport const labelProperties = toObjectMap(htmlElementProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of AUDIO tag properties and events.\n\n * @public\n */\nexport const audioProperties = toObjectMap(htmlElementProperties, [\n 'height', // canvas, embed, iframe, img, input, object, video\n 'loop', // audio, video\n 'muted', // audio, video\n 'preload', // audio, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of VIDEO tag properties and events.\n *\n * @public\n */\nexport const videoProperties = toObjectMap(audioProperties, [\n 'poster', // video\n]);\n\n/**\n * An array of OL tag properties and events.\n *\n * @public\n */\nexport const olProperties = toObjectMap(htmlElementProperties, [\n 'start', // ol\n]);\n\n/**\n * An array of LI tag properties and events.\n *\n * @public\n */\nexport const liProperties = toObjectMap(htmlElementProperties, [\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of A tag properties and events.\n *\n * @public\n */\nexport const anchorProperties = toObjectMap(htmlElementProperties, [\n 'download', // a, area\n 'href', // a, area, base, link\n 'hrefLang', // a, area, link\n 'media', // a, area, link, source, style\n 'rel', // a, area, link\n 'target', // a, area, base, form\n 'type', // a, button, input, link, menu, object, script, source, style\n]);\n\n/**\n * An array of TIME tag properties and events.\n *\n * @public\n */\nexport const timeProperties = toObjectMap(htmlElementProperties, [\n 'dateTime', // time\n]);\n\n/**\n * An array of BUTTON tag properties and events.\n *\n * @public\n */\nexport const buttonProperties = toObjectMap(htmlElementProperties, [\n 'autoFocus', // button, input, select, textarea\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'formAction', // input, button\n 'formEncType', // input, button\n 'formMethod', // input, button\n 'formNoValidate', // input, button\n 'formTarget', // input, button\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param,\n]);\n\n/**\n * An array of INPUT tag properties and events.\n *\n * @public\n */\nexport const inputProperties = toObjectMap(buttonProperties, [\n 'accept', // input\n 'alt', // area, img, input\n 'autoCapitalize', // input, textarea\n 'autoComplete', // form, input\n 'checked', // input\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'height', // canvas, embed, iframe, img, input, object, video\n 'inputMode', // input\n 'list', // input\n 'max', // input, meter\n 'maxLength', // input, textarea\n 'min', // input, meter\n 'multiple', // input, select\n 'pattern', // input\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'step', // input\n 'size', // input\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of TEXTAREA tag properties and events.\n *\n * @public\n */\nexport const textAreaProperties = toObjectMap(buttonProperties, [\n 'autoCapitalize', // input, textarea\n 'cols', // textarea\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'maxLength', // input, textarea\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'rows', // textarea\n 'wrap', // textarea\n]);\n\n/**\n * An array of SELECT tag properties and events.\n *\n * @public\n */\nexport const selectProperties = toObjectMap(buttonProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'multiple', // input, select\n 'required', // input, select, textarea\n]);\n\nexport const optionProperties = toObjectMap(htmlElementProperties, [\n 'selected', // option\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of TABLE tag properties and events.\n *\n * @public\n */\nexport const tableProperties = toObjectMap(htmlElementProperties, [\n 'cellPadding', // table\n 'cellSpacing', // table\n]);\n\n/**\n * An array of TR tag properties and events.\n *\n * @public\n */\nexport const trProperties = htmlElementProperties;\n\n/**\n * An array of TH tag properties and events.\n *\n * @public\n */\nexport const thProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td, th\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\n/**\n * An array of TD tag properties and events.\n *\n * @public\n */\nexport const tdProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td\n 'headers', // td\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\nexport const colGroupProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\nexport const colProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\n/**\n * An array of FIELDSET tag properties and events.\n *\n * @public\n */\nexport const fieldsetProperties = toObjectMap(htmlElementProperties, [\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of FORM tag properties and events.\n *\n * @public\n */\nexport const formProperties = toObjectMap(htmlElementProperties, [\n 'acceptCharset', // form\n 'action', // form\n 'encType', // form\n 'encType', // form\n 'method', // form\n 'noValidate', // form\n 'target', // form\n]);\n\n/**\n * An array of IFRAME tag properties and events.\n *\n * @public\n */\nexport const iframeProperties = toObjectMap(htmlElementProperties, [\n 'allow', // iframe\n 'allowFullScreen', // iframe\n 'allowPaymentRequest', // iframe\n 'allowTransparency', // iframe\n 'csp', // iframe\n 'height', // canvas, embed, iframe, img, input, object, video\n 'importance', // iframe\n 'referrerPolicy', // iframe\n 'sandbox', // iframe\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcDoc', // iframe\n 'width', // canvas, embed, iframe, img, input, object, video,\n]);\n\n/**\n * An array of IMAGE tag properties and events.\n *\n * @public\n */\nexport const imgProperties = toObjectMap(htmlElementProperties, [\n 'alt', // area, img, input\n 'crossOrigin', // img\n 'height', // canvas, embed, iframe, img, input, object, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcSet', // img, source\n 'useMap', // img, object,\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of DIALOG tag properties and events.\n *\n * @public\n */\nexport const dialogProperties = toObjectMap(htmlElementProperties, ['open', 'onCancel', 'onClose']);\n\n/**\n * An array of DIV tag properties and events.\n *\n * @public\n */\nexport const divProperties = htmlElementProperties;\n\n/**\n * Gets native supported props for an html element provided the allowance set. Use one of the property\n * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given\n * props set. Note that all data- and aria- prefixed attributes will be allowed.\n * NOTE: getNativeProps should always be applied first when adding props to a react component. The\n * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.\n * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to\n * the component after an onClick function is added, then the getNativeProps onClick will override it.\n *\n * @public\n * @param props - The unfiltered input props\n * @param allowedPropNames - The array or record of allowed prop names.\n * @param excludedPropNames\n * @returns The filtered props\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeProps<T extends Record<string, any>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>,\n allowedPropNames: string[] | Record<string, number>,\n excludedPropNames?: string[],\n): T {\n // It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for\n // JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.\n // Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then\n // return native props.\n // We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797\n\n const isArray = Array.isArray(allowedPropNames);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n const keys = Object.keys(props);\n\n for (const key of keys) {\n const isNativeProp =\n (!isArray && (allowedPropNames as Record<string, number>)[key]) ||\n (isArray && (allowedPropNames as string[]).indexOf(key) >= 0) ||\n key.indexOf('data-') === 0 ||\n key.indexOf('aria-') === 0;\n\n if (isNativeProp && (!excludedPropNames || excludedPropNames?.indexOf(key) === -1)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result[key] = props![key] as any;\n }\n }\n\n return result as T;\n}\n"],"mappings":"AAAA,MAAMA,WAAA,GAAcA,CAAC,GAAGC,KAAA,KAAiD;EACvE,MAAMC,MAAA,GAAiC,CAAC;EAExC,KAAK,MAAMC,IAAA,IAAQF,KAAA,EAAO;IACxB,MAAMG,IAAA,GAAOC,KAAA,CAAMC,OAAO,CAACH,IAAA,IAAQA,IAAA,GAAOI,MAAA,CAAOH,IAAI,CAACD,IAAA,CAAK;IAE3D,KAAK,MAAMK,GAAA,IAAOJ,IAAA,EAAM;MACtBF,MAAM,CAACM,GAAA,CAAI,GAAG;IAChB;EACF;EAEA,OAAON,MAAA;AACT;AAEA;;;;;AAKA,OAAO,MAAMO,iBAAA,gBAAoBT,WAAA,CAAY,CAC3C,cACA,UACA,SACA,WACA,oBACA,sBACA,uBACA,WACA,kBACA,UACA,iBACA,YACA,WACA,YACA,UACA,WACA,aACA,oBACA,cACA,WACA,WACA,aACA,oBACA,oBACA,aACA,eACA,WACA,gBACA,oBACA,eACA,WACA,UACA,aACA,cACA,gBACA,YACA,aACA,aACA,aACA,gBACA,kBACA,aACA,WACA,kBACA,iBACA,iBACA,UACA,aACA,eACA,cACA,eACA,cACA,eACA,UACA,eACA,sBACA,gBACA,gBACA,eACA,cACA,eACA,aACA,oBACA,YACA,iBACA,cACA,eACA,gBACA,YACA,WACA,mBACA,iBACA,kBACA,kBACA,iBACA,gBACA,iBACA,eACA,uBACA,uBACD;AAED;;;;;AAKA,OAAO,MAAMU,qBAAA,gBAAwBV,WAAA,CAAY,CAC/C,aACA,YACA,aACA,mBACA,OACA,aACA,UACA,WACA,MACA,QACA,OACA,QACA,SACA,YACA,SACA,aACA,cACA,OACD;AAED;;;;;AAKA,OAAO,MAAMW,mBAAA,gBAAsBX,WAAA,CAAY,CAC7C,UACA,YACA,WACA,aACA,WACD;AAED;;;;;AAKA,OAAO,MAAMY,qBAAA,gBAAwBZ,WAAA,CAAYU,qBAAA,EAAuBD,iBAAA,EAAmBE,mBAAA;AAE3F;;;;;AAKA,OAAO,MAAME,eAAA,gBAAkBb,WAAA,CAAYY,qBAAA,EAAuB,CAChE,OACD;AAED;;;;;AAKA,OAAO,MAAME,eAAA,gBAAkBd,WAAA,CAAYY,qBAAA,EAAuB,CAChE,UACA,QACA,SACA,WACA,OACA,QACD;AAED;;;;;AAKA,OAAO,MAAMG,eAAA,gBAAkBf,WAAA,CAAYc,eAAA,EAAiB,CAC1D,SACD;AAED;;;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,GACJ,CAAEnC,OAAA,IAAWiC,gBAA4C,CAAC/B,GAAA,CAAI,IAC7DF,OAAA,IAAWiC,gBAAC,CAA8BG,OAAO,CAAClC,GAAA,KAAQ,KAC3DA,GAAA,CAAIkC,OAAO,CAAC,aAAa,KACzBlC,GAAA,CAAIkC,OAAO,CAAC,aAAa;IAE3B,IAAID,YAAA,KAAiB,CAACD,iBAAA,IAAqB,CAAAA,iBAAA,aAAAA,iBAAA,uBAAAA,iBAAA,CAAmBE,OAAO,CAAClC,GAAA,OAAS,CAAC,IAAI;MAClF;MACAN,MAAM,CAACM,GAAA,CAAI,GAAG8B,KAAM,CAAC9B,GAAA,CAAI;IAC3B;EACF;EAEA,OAAON,MAAA;AACT"}
|
1
|
+
{"version":3,"sources":["properties.ts"],"sourcesContent":["const toObjectMap = (...items: (string[] | Record<string, number>)[]) => {\n const result: Record<string, number> = {};\n\n for (const item of items) {\n const keys = Array.isArray(item) ? item : Object.keys(item);\n\n for (const key of keys) {\n result[key] = 1;\n }\n }\n\n return result;\n};\n\n/**\n * An array of events that are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementEvents = toObjectMap([\n 'onAuxClick',\n 'onCopy',\n 'onCut',\n 'onPaste',\n 'onCompositionEnd',\n 'onCompositionStart',\n 'onCompositionUpdate',\n 'onFocus',\n 'onFocusCapture',\n 'onBlur',\n 'onBlurCapture',\n 'onChange',\n 'onInput',\n 'onSubmit',\n 'onLoad',\n 'onError',\n 'onKeyDown',\n 'onKeyDownCapture',\n 'onKeyPress',\n 'onKeyUp',\n 'onAbort',\n 'onCanPlay',\n 'onCanPlayThrough',\n 'onDurationChange',\n 'onEmptied',\n 'onEncrypted',\n 'onEnded',\n 'onLoadedData',\n 'onLoadedMetadata',\n 'onLoadStart',\n 'onPause',\n 'onPlay',\n 'onPlaying',\n 'onProgress',\n 'onRateChange',\n 'onSeeked',\n 'onSeeking',\n 'onStalled',\n 'onSuspend',\n 'onTimeUpdate',\n 'onVolumeChange',\n 'onWaiting',\n 'onClick',\n 'onClickCapture',\n 'onContextMenu',\n 'onDoubleClick',\n 'onDrag',\n 'onDragEnd',\n 'onDragEnter',\n 'onDragExit',\n 'onDragLeave',\n 'onDragOver',\n 'onDragStart',\n 'onDrop',\n 'onMouseDown',\n 'onMouseDownCapture',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseMove',\n 'onMouseOut',\n 'onMouseOver',\n 'onMouseUp',\n 'onMouseUpCapture',\n 'onSelect',\n 'onTouchCancel',\n 'onTouchEnd',\n 'onTouchMove',\n 'onTouchStart',\n 'onScroll',\n 'onWheel',\n 'onPointerCancel',\n 'onPointerDown',\n 'onPointerEnter',\n 'onPointerLeave',\n 'onPointerMove',\n 'onPointerOut',\n 'onPointerOver',\n 'onPointerUp',\n 'onGotPointerCapture',\n 'onLostPointerCapture',\n]);\n\n/**\n * An array of element attributes which are allowed on every html element type.\n *\n * @public\n */\nexport const baseElementProperties = toObjectMap([\n 'accessKey', // global\n 'children', // global\n 'className', // global\n 'contentEditable', // global\n 'dir', // global\n 'draggable', // global\n 'hidden', // global\n 'htmlFor', // global\n 'id', // global\n 'lang', // global\n 'ref', // global\n 'role', // global\n 'style', // global\n 'tabIndex', // global\n 'title', // global\n 'translate', // global\n 'spellCheck', // global\n 'name', // global\n]);\n\n/**\n * An array of microdata attributes that are allowed on every html element type.\n *\n * @public\n */\nexport const microdataProperties = toObjectMap([\n 'itemID', // global\n 'itemProp', // global\n 'itemRef', // global\n 'itemScope', // global\n 'itemType', // global\n]);\n\n/**\n * An array of HTML element properties and events.\n *\n * @public\n */\nexport const htmlElementProperties = toObjectMap(baseElementProperties, baseElementEvents, microdataProperties);\n\n/**\n * An array of LABEL tag properties and events.\n *\n * @public\n */\nexport const labelProperties = toObjectMap(htmlElementProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of AUDIO tag properties and events.\n\n * @public\n */\nexport const audioProperties = toObjectMap(htmlElementProperties, [\n 'height', // canvas, embed, iframe, img, input, object, video\n 'loop', // audio, video\n 'muted', // audio, video\n 'preload', // audio, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of VIDEO tag properties and events.\n *\n * @public\n */\nexport const videoProperties = toObjectMap(audioProperties, [\n 'poster', // video\n]);\n\n/**\n * An array of OL tag properties and events.\n *\n * @public\n */\nexport const olProperties = toObjectMap(htmlElementProperties, [\n 'start', // ol\n]);\n\n/**\n * An array of LI tag properties and events.\n *\n * @public\n */\nexport const liProperties = toObjectMap(htmlElementProperties, [\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of A tag properties and events.\n *\n * @public\n */\nexport const anchorProperties = toObjectMap(htmlElementProperties, [\n 'download', // a, area\n 'href', // a, area, base, link\n 'hrefLang', // a, area, link\n 'media', // a, area, link, source, style\n 'rel', // a, area, link\n 'target', // a, area, base, form\n 'type', // a, button, input, link, menu, object, script, source, style\n]);\n\n/**\n * An array of TIME tag properties and events.\n *\n * @public\n */\nexport const timeProperties = toObjectMap(htmlElementProperties, [\n 'dateTime', // time\n]);\n\n/**\n * An array of BUTTON tag properties and events.\n *\n * @public\n */\nexport const buttonProperties = toObjectMap(htmlElementProperties, [\n 'autoFocus', // button, input, select, textarea\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'formAction', // input, button\n 'formEncType', // input, button\n 'formMethod', // input, button\n 'formNoValidate', // input, button\n 'formTarget', // input, button\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param,\n]);\n\n/**\n * An array of INPUT tag properties and events.\n *\n * @public\n */\nexport const inputProperties = toObjectMap(buttonProperties, [\n 'accept', // input\n 'alt', // area, img, input\n 'autoCapitalize', // input, textarea\n 'autoComplete', // form, input\n 'checked', // input\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'height', // canvas, embed, iframe, img, input, object, video\n 'inputMode', // input\n 'list', // input\n 'max', // input, meter\n 'maxLength', // input, textarea\n 'min', // input, meter\n 'multiple', // input, select\n 'pattern', // input\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'step', // input\n 'size', // input\n 'type', // a, button, input, link, menu, object, script, source, style\n 'value', // button, input, li, option, meter, progress, param\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of TEXTAREA tag properties and events.\n *\n * @public\n */\nexport const textAreaProperties = toObjectMap(buttonProperties, [\n 'autoCapitalize', // input, textarea\n 'cols', // textarea\n 'dirname', // input, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'maxLength', // input, textarea\n 'placeholder', // input, textarea\n 'readOnly', // input, textarea\n 'required', // input, select, textarea\n 'rows', // textarea\n 'wrap', // textarea\n]);\n\n/**\n * An array of SELECT tag properties and events.\n *\n * @public\n */\nexport const selectProperties = toObjectMap(buttonProperties, [\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n 'multiple', // input, select\n 'required', // input, select, textarea\n]);\n\nexport const optionProperties = toObjectMap(htmlElementProperties, [\n 'selected', // option\n 'value', // button, input, li, option, meter, progress, param\n]);\n\n/**\n * An array of TABLE tag properties and events.\n *\n * @public\n */\nexport const tableProperties = toObjectMap(htmlElementProperties, [\n 'cellPadding', // table\n 'cellSpacing', // table\n]);\n\n/**\n * An array of TR tag properties and events.\n *\n * @public\n */\nexport const trProperties = htmlElementProperties;\n\n/**\n * An array of TH tag properties and events.\n *\n * @public\n */\nexport const thProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td, th\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\n/**\n * An array of TD tag properties and events.\n *\n * @public\n */\nexport const tdProperties = toObjectMap(htmlElementProperties, [\n 'colSpan', // td\n 'headers', // td\n 'rowSpan', // td, th\n 'scope', // th\n]);\n\nexport const colGroupProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\nexport const colProperties = toObjectMap(htmlElementProperties, [\n 'span', // col, colgroup\n]);\n\n/**\n * An array of FIELDSET tag properties and events.\n *\n * @public\n */\nexport const fieldsetProperties = toObjectMap(htmlElementProperties, [\n 'disabled', // button, fieldset, input, optgroup, option, select, textarea\n 'form', // button, fieldset, input, label, meter, object, output, select, textarea\n]);\n\n/**\n * An array of FORM tag properties and events.\n *\n * @public\n */\nexport const formProperties = toObjectMap(htmlElementProperties, [\n 'acceptCharset', // form\n 'action', // form\n 'encType', // form\n 'encType', // form\n 'method', // form\n 'noValidate', // form\n 'target', // form\n]);\n\n/**\n * An array of IFRAME tag properties and events.\n *\n * @public\n */\nexport const iframeProperties = toObjectMap(htmlElementProperties, [\n 'allow', // iframe\n 'allowFullScreen', // iframe\n 'allowPaymentRequest', // iframe\n 'allowTransparency', // iframe\n 'csp', // iframe\n 'height', // canvas, embed, iframe, img, input, object, video\n 'importance', // iframe\n 'referrerPolicy', // iframe\n 'sandbox', // iframe\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcDoc', // iframe\n 'width', // canvas, embed, iframe, img, input, object, video,\n]);\n\n/**\n * An array of IMAGE tag properties and events.\n *\n * @public\n */\nexport const imgProperties = toObjectMap(htmlElementProperties, [\n 'alt', // area, img, input\n 'crossOrigin', // img\n 'height', // canvas, embed, iframe, img, input, object, video\n 'src', // audio, embed, iframe, img, input, script, source, track, video\n 'srcSet', // img, source\n 'useMap', // img, object,\n 'width', // canvas, embed, iframe, img, input, object, video\n]);\n\n/**\n * An array of DIALOG tag properties and events.\n *\n * @public\n */\nexport const dialogProperties = toObjectMap(htmlElementProperties, ['open', 'onCancel', 'onClose']);\n\n/**\n * An array of DIV tag properties and events.\n *\n * @public\n */\nexport const divProperties = htmlElementProperties;\n\n/**\n * Gets native supported props for an html element provided the allowance set. Use one of the property\n * sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given\n * props set. Note that all data- and aria- prefixed attributes will be allowed.\n * NOTE: getNativeProps should always be applied first when adding props to a react component. The\n * non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.\n * For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to\n * the component after an onClick function is added, then the getNativeProps onClick will override it.\n *\n * @public\n * @param props - The unfiltered input props\n * @param allowedPropNames - The array or record of allowed prop names.\n * @param excludedPropNames\n * @returns The filtered props\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeProps<T extends Record<string, any>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>,\n allowedPropNames: string[] | Record<string, number>,\n excludedPropNames?: string[],\n): T {\n // It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for\n // JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.\n // Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then\n // return native props.\n // We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797\n\n const isArray = Array.isArray(allowedPropNames);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n const keys = Object.keys(props);\n\n for (const key of keys) {\n const isNativeProp =\n (!isArray && (allowedPropNames as Record<string, number>)[key]) ||\n (isArray && (allowedPropNames as string[]).indexOf(key) >= 0) ||\n key.indexOf('data-') === 0 ||\n key.indexOf('aria-') === 0;\n\n if (isNativeProp && (!excludedPropNames || excludedPropNames?.indexOf(key) === -1)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result[key] = props![key] as any;\n }\n }\n\n return result as T;\n}\n"],"names":["toObjectMap","items","result","item","keys","Array","isArray","Object","key","baseElementEvents","baseElementProperties","microdataProperties","htmlElementProperties","labelProperties","audioProperties","videoProperties","olProperties","liProperties","anchorProperties","timeProperties","buttonProperties","inputProperties","textAreaProperties","selectProperties","optionProperties","tableProperties","trProperties","thProperties","tdProperties","colGroupProperties","colProperties","fieldsetProperties","formProperties","iframeProperties","imgProperties","dialogProperties","divProperties","getNativeProps","props","allowedPropNames","excludedPropNames","isNativeProp","indexOf"],"mappings":"AAAA,MAAMA,cAAc,CAAC,GAAGC,QAAiD;IACvE,MAAMC,SAAiC,CAAC;IAExC,KAAK,MAAMC,QAAQF,MAAO;QACxB,MAAMG,OAAOC,MAAMC,OAAO,CAACH,QAAQA,OAAOI,OAAOH,IAAI,CAACD,KAAK;QAE3D,KAAK,MAAMK,OAAOJ,KAAM;YACtBF,MAAM,CAACM,IAAI,GAAG;QAChB;IACF;IAEA,OAAON;AACT;AAEA;;;;CAIC,GACD,OAAO,MAAMO,oBAAoBT,YAAY;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMU,wBAAwBV,YAAY;IAC/C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMW,sBAAsBX,YAAY;IAC7C;IACA;IACA;IACA;IACA;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAMY,wBAAwBZ,YAAYU,uBAAuBD,mBAAmBE,qBAAqB;AAEhH;;;;CAIC,GACD,OAAO,MAAME,kBAAkBb,YAAYY,uBAAuB;IAChE;CACD,EAAE;AAEH;;;;CAIC,GACD,OAAO,MAAME,kBAAkBd,YAAYY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,WAAW,AAACiC,gBAA2C,CAAC/B,IAAI,IAC7DF,WAAW,AAACiC,iBAA8BG,OAAO,CAAClC,QAAQ,KAC3DA,IAAIkC,OAAO,CAAC,aAAa,KACzBlC,IAAIkC,OAAO,CAAC,aAAa;QAE3B,IAAID,gBAAiB,CAAA,CAACD,qBAAqBA,CAAAA,8BAAAA,+BAAAA,KAAAA,IAAAA,kBAAmBE,OAAO,CAAClC,UAAS,CAAC,CAAA,GAAI;YAClF,8DAA8D;YAC9DN,MAAM,CAACM,IAAI,GAAG8B,KAAM,CAAC9B,IAAI;QAC3B,CAAC;IACH;IAEA,OAAON;AACT,CAAC"}
|
@@ -9,6 +9,4 @@ Object.defineProperty(exports, "SLOT_RENDER_FUNCTION_SYMBOL", {
|
|
9
9
|
enumerable: true,
|
10
10
|
get: ()=>SLOT_RENDER_FUNCTION_SYMBOL
|
11
11
|
});
|
12
|
-
const SLOT_RENDER_FUNCTION_SYMBOL =
|
13
|
-
|
14
|
-
//# sourceMappingURL=constants.js.map
|
12
|
+
const SLOT_RENDER_FUNCTION_SYMBOL = Symbol('fui.slotRenderFunction');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["constants.js"],"sourcesContent":["/**\n * @internal\n * Internal reference for the render function\n */ export const SLOT_RENDER_FUNCTION_SYMBOL = Symbol('fui.slotRenderFunction');\n"],"names":["SLOT_RENDER_FUNCTION_SYMBOL","Symbol"],"mappings":"AAAA;;;CAGC;;;;+BAAgBA;;aAAAA;;AAAN,MAAMA,8BAA8BC,OAAO"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["getSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { omit } from '../utils/omit';\nimport { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';\n/**\n * Given the state and an array of slot names, will break out `slots` and `slotProps`\n * collections.\n *\n * The root is derived from a mix of `components` props and `as` prop.\n *\n * Slots will render as null if they are rendered as primitives with undefined children.\n *\n * The slotProps will always omit the `as` prop within them, and for slots that are string\n * primitives, the props will be filtered according to the slot type by the type system.\n * For example, if the slot is rendered `as: 'a'`, the props will be filtered for acceptable\n * anchor props. Note that this is only enforced at build time by Typescript -- there is no\n * runtime code filtering props in this function.\n *\n * @param state - State including slot definitions\n * @returns An object containing the `slots` map and `slotProps` map.\n */ export function getSlots(state) {\n const slots = {};\n const slotProps = {};\n const slotNames = Object.keys(state.components);\n for (const slotName of slotNames){\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot;\n slotProps[slotName] = props;\n }\n return {\n slots,\n slotProps: slotProps\n };\n}\nfunction getSlot(state, slotName) {\n var _state_components, _state_components1;\n const props = state[slotName];\n if (props === undefined) {\n return [\n null,\n undefined\n ];\n }\n const { children , as: asProp , [SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction , ...rest } = props;\n const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];\n if (renderFunction || typeof children === 'function') {\n const render = renderFunction || children;\n return [\n React.Fragment,\n {\n children: render(slot, rest)\n }\n ];\n }\n const shouldOmitAsProp = typeof slot === 'string' && asProp;\n const slotProps = shouldOmitAsProp ? omit(props, [\n 'as'\n ]) : props;\n return [\n slot,\n slotProps\n ];\n}\n"],"names":["getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","_state_components","_state_components1","undefined","children","as","asProp","SLOT_RENDER_FUNCTION_SYMBOL","renderFunction","rest","render","React","Fragment","shouldOmitAsProp","omit"],"mappings":";;;;+BAmBoBA;;aAAAA;;;6DAnBG;sBACF;2BACuB;AAiBjC,SAASA,SAASC,KAAK,EAAE;IAChC,MAAMC,QAAQ,CAAC;IACf,MAAMC,YAAY,CAAC;IACnB,MAAMC,YAAYC,OAAOC,IAA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31,6 +31,7 @@ function getSlotNext(state, slotName) {
|
|
31
31
|
undefined
|
32
32
|
];
|
33
33
|
}
|
34
|
+
// TS Error: Property 'as' does not exist on type 'UnknownSlotProps | undefined'.ts(2339)
|
34
35
|
const { as: asProp , ...propsWithoutAs } = props;
|
35
36
|
const slot = ((_state_components = state.components) === null || _state_components === void 0 ? void 0 : _state_components[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_state_components1 = state.components) === null || _state_components1 === void 0 ? void 0 : _state_components1[slotName]) || 'div' : state.components[slotName];
|
36
37
|
const shouldOmitAsProp = typeof slot === 'string' && asProp;
|
@@ -39,6 +40,4 @@ function getSlotNext(state, slotName) {
|
|
39
40
|
slot,
|
40
41
|
slotProps
|
41
42
|
];
|
42
|
-
}
|
43
|
-
|
44
|
-
//# sourceMappingURL=getSlotsNext.js.map
|
43
|
+
}
|