@fluentui/react-utilities 9.3.0 → 9.3.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 +30 -1
- package/CHANGELOG.md +11 -2
- package/dist/index.d.ts +2 -2
- package/lib/compose/getSlots.js +0 -8
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/isResolvedShorthand.js +0 -1
- package/lib/compose/isResolvedShorthand.js.map +1 -1
- package/lib/compose/resolveShorthand.js +2 -6
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/hooks/useControllableState.js +6 -12
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useEventCallback.js +0 -1
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.js +0 -3
- package/lib/hooks/useFirstMount.js.map +1 -1
- package/lib/hooks/useForceUpdate.js +0 -1
- package/lib/hooks/useForceUpdate.js.map +1 -1
- package/lib/hooks/useId.js +0 -3
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js +0 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedRefs.js +2 -3
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +8 -26
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js +0 -4
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js +0 -1
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useTimeout.js +2 -3
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/ssr/SSRContext.js +4 -11
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js +2 -1
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/trigger/applyTriggerPropsToChildren.js +2 -6
- package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/trigger/getTriggerChild.js +2 -3
- package/lib/trigger/getTriggerChild.js.map +1 -1
- package/lib/trigger/isFluentTrigger.js.map +1 -1
- package/lib/utils/getNativeElementProps.js +0 -2
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js +0 -2
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js +0 -3
- package/lib/utils/getReactCallbackName.js.map +1 -1
- package/lib/utils/isHTMLElement.js +2 -2
- package/lib/utils/isHTMLElement.js.map +1 -1
- package/lib/utils/isInteractiveHTMLElement.js +0 -4
- package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib/utils/mergeCallbacks.js.map +1 -1
- package/lib/utils/omit.js +0 -2
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/properties.js +7 -36
- package/lib/utils/properties.js.map +1 -1
- package/lib-amd/utils/isHTMLElement.js +4 -3
- package/lib-amd/utils/isHTMLElement.js.map +1 -1
- package/lib-amd/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib-commonjs/compose/getSlots.js +0 -12
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/index.js +0 -5
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/isResolvedShorthand.js +0 -4
- package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js +2 -9
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/hooks/index.js +0 -12
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.js +6 -14
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js +0 -5
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js +0 -6
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js +0 -4
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.js +0 -8
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +0 -4
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +2 -6
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +8 -30
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js +0 -8
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js +0 -4
- package/lib-commonjs/hooks/usePrevious.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js +2 -6
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/index.js +0 -10
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js +4 -17
- package/lib-commonjs/ssr/SSRContext.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js +2 -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 +2 -10
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/trigger/getTriggerChild.js +2 -7
- package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
- package/lib-commonjs/trigger/index.js +0 -5
- package/lib-commonjs/trigger/index.js.map +1 -1
- package/lib-commonjs/trigger/isFluentTrigger.js +0 -2
- package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
- package/lib-commonjs/trigger/types.js.map +1 -1
- package/lib-commonjs/utils/clamp.js +0 -2
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.js +0 -6
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js +0 -4
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.js +0 -5
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -9
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isHTMLElement.js +2 -4
- package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/isInteractiveHTMLElement.js +0 -7
- package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/mergeCallbacks.js +0 -2
- package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
- package/lib-commonjs/utils/omit.js +0 -4
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/properties.js +7 -38
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/package.json +2 -2
@@ -9,7 +9,7 @@
|
|
9
9
|
*/
|
10
10
|
export function isHTMLElement(element) {
|
11
11
|
var _a;
|
12
|
-
|
13
|
-
return Boolean(
|
12
|
+
const typedElement = element;
|
13
|
+
return Boolean(typedElement !== null && ((_a = typedElement === null || typedElement === void 0 ? void 0 : typedElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) && typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement);
|
14
14
|
}
|
15
15
|
//# sourceMappingURL=isHTMLElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA;;;;;;;;;AASA,OAAM,SAAUA,aAAa,CAACC,OAAiB;;EAC7C,MAAMC,YAAY,GAAGD,OAAkC;EACvD,OAAOE,OAAO,CACZD,YAAY,KAAK,IAAI,KACnB,kBAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEE,aAAa,0CAAEC,WAAW,KACxCH,YAAY,YAAYA,YAAY,CAACE,aAAa,CAACC,WAAW,CAACC,WAAW,CAC7E;AACH","names":["isHTMLElement","element","typedElement","Boolean","ownerDocument","defaultView","HTMLElement"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"sourcesContent":["/**\n * @internal\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is required as simply using `instanceof`\n * might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n */\nexport function isHTMLElement(element?: unknown): element is HTMLElement {\n const typedElement = element as Node | null | undefined;\n return Boolean(\n typedElement !== null &&\n typedElement?.ownerDocument?.defaultView &&\n typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement,\n );\n}\n"]}
|
@@ -3,16 +3,13 @@ import { isHTMLElement } from './isHTMLElement';
|
|
3
3
|
* @internal
|
4
4
|
* Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys
|
5
5
|
*/
|
6
|
-
|
7
6
|
export function isInteractiveHTMLElement(element) {
|
8
7
|
if (!isHTMLElement(element)) {
|
9
8
|
return false;
|
10
9
|
}
|
11
|
-
|
12
10
|
const {
|
13
11
|
tagName
|
14
12
|
} = element;
|
15
|
-
|
16
13
|
switch (tagName) {
|
17
14
|
case 'BUTTON':
|
18
15
|
case 'A':
|
@@ -20,7 +17,6 @@ export function isInteractiveHTMLElement(element) {
|
|
20
17
|
case 'TEXTAREA':
|
21
18
|
return true;
|
22
19
|
}
|
23
|
-
|
24
20
|
return element.isContentEditable;
|
25
21
|
}
|
26
22
|
//# sourceMappingURL=isInteractiveHTMLElement.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAE/C;;;;AAIA,OAAM,SAAUC,wBAAwB,CAACC,OAAgB;EACvD,IAAI,CAACF,aAAa,CAACE,OAAO,CAAC,EAAE;IAC3B,OAAO,KAAK;;EAGd,MAAM;IAAEC;EAAO,CAAE,GAAGD,OAAO;EAC3B,QAAQC,OAAO;IACb,KAAK,QAAQ;IACb,KAAK,GAAG;IACR,KAAK,OAAO;IACZ,KAAK,UAAU;MACb,OAAO,IAAI;EAAC;EAGhB,OAAOD,OAAO,CAACE,iBAAiB;AAClC","names":["isHTMLElement","isInteractiveHTMLElement","element","tagName","isContentEditable"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/isInteractiveHTMLElement.ts"],"sourcesContent":["import { isHTMLElement } from './isHTMLElement';\n\n/**\n * @internal\n * Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys\n */\nexport function isInteractiveHTMLElement(element: unknown) {\n if (!isHTMLElement(element)) {\n return false;\n }\n\n const { tagName } = element;\n switch (tagName) {\n case 'BUTTON':\n case 'A':\n case 'INPUT':\n case 'TEXTAREA':\n return true;\n }\n\n return element.isContentEditable;\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAM,SAAUA,cAAc,CAC5BC,SAAgD,EAChDC,SAAgD;EAEhD,OAAO,CAAC,GAAGC,IAAU,KAAI;IACvBF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAG,GAAGE,IAAI,CAAC;IACpBD,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAG,GAAGC,IAAI,CAAC;EACtB,CAAC;AACH","names":["mergeCallbacks","callback1","callback2","args"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/mergeCallbacks.ts"],"sourcesContent":["/**\n * @internal\n * Combine two event callbacks into a single callback function that calls each one in order.\n *\n * Usage example:\n * ```ts\n * state.slot.onChange = mergeCallbacks(state.slot.onChange, ev => {\n * // Handle onChange\n * });\n * ```\n *\n * The primary use is to avoid the need to capture an existing callback (`state.slot.onChange` in the example) to a\n * local variable before replacing with a new listener that calls the existing one. This helps avoid bugs like:\n * * Infinite recursion by calling the re-assigned state.slot.onChange if it's not captured to a local variable.\n * * Missing a call to the original onChange due to an early return or other conditional.\n *\n * If you need a callback that is stable between renders, wrap the result in {@link useEventCallback}.\n *\n * @param callback1 - The first callback to be called, or undefined\n * @param callback2 - The second callback to be called, or undefined\n *\n * @returns A function that that calls the provided functions in order\n */\nexport function mergeCallbacks<Args extends unknown[]>(\n callback1: ((...args: Args) => void) | undefined,\n callback2: ((...args: Args) => void) | undefined,\n) {\n return (...args: Args) => {\n callback1?.(...args);\n callback2?.(...args);\n };\n}\n"]}
|
package/lib/utils/omit.js
CHANGED
@@ -15,13 +15,11 @@
|
|
15
15
|
export function omit(obj, exclusions) {
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
17
17
|
const result = {};
|
18
|
-
|
19
18
|
for (const key in obj) {
|
20
19
|
if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {
|
21
20
|
result[key] = obj[key];
|
22
21
|
}
|
23
22
|
}
|
24
|
-
|
25
23
|
return result;
|
26
24
|
}
|
27
25
|
//# sourceMappingURL=omit.js.map
|
package/lib/utils/omit.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA;;;;;;;;;;;;;AAaA;AACA,OAAM,SAAUA,IAAI,CAClBC,GAAS,EACTC,UAAsB;EAEtB;EACA,MAAMC,MAAM,GAAwB,EAAE;EAEtC,KAAK,MAAMC,GAAG,IAAIH,GAAG,EAAE;IACrB,IAAIC,UAAU,CAACG,OAAO,CAACD,GAAG,CAAC,KAAK,CAAC,CAAC,IAAIH,GAAG,CAACK,cAAc,CAACF,GAAG,CAAC,EAAE;MAC7DD,MAAM,CAACC,GAAG,CAAC,GAAGH,GAAG,CAACG,GAAG,CAAC;;;EAI1B,OAAOD,MAAc;AACvB","names":["omit","obj","exclusions","result","key","indexOf","hasOwnProperty"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/omit.ts"],"sourcesContent":["/**\n * Tiny helper to do the minimal amount of work in duplicating an object but omitting some\n * props. This ends up faster than using object ...rest or reduce to filter.\n *\n * This behaves very much like filteredAssign, but does not merge many objects together,\n * uses an exclusion object map, and avoids spreads all for optimal performance.\n *\n * See perf test for background:\n * https://jsperf.com/omit-vs-rest-vs-reduce/1\n *\n * @param obj - The object to clone\n * @param exclusions - The array of keys to exclude\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(\n obj: TObj,\n exclusions: Exclusions,\n): Omit<TObj, Exclusions[number]> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n\n for (const key in obj) {\n if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {\n result[key] = obj[key];\n }\n }\n\n return result as TObj;\n}\n"]}
|
package/lib/utils/properties.js
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
const toObjectMap = (...items) => {
|
2
2
|
const result = {};
|
3
|
-
|
4
3
|
for (const item of items) {
|
5
4
|
const keys = Array.isArray(item) ? item : Object.keys(item);
|
6
|
-
|
7
5
|
for (const key of keys) {
|
8
6
|
result[key] = 1;
|
9
7
|
}
|
10
8
|
}
|
11
|
-
|
12
9
|
return result;
|
13
10
|
};
|
14
11
|
/**
|
@@ -16,15 +13,12 @@ const toObjectMap = (...items) => {
|
|
16
13
|
*
|
17
14
|
* @public
|
18
15
|
*/
|
19
|
-
|
20
|
-
|
21
16
|
export const baseElementEvents = /*#__PURE__*/toObjectMap(['onAuxClick', 'onCopy', 'onCut', 'onPaste', 'onCompositionEnd', 'onCompositionStart', 'onCompositionUpdate', 'onFocus', 'onFocusCapture', 'onBlur', 'onBlurCapture', 'onChange', 'onInput', 'onSubmit', 'onLoad', 'onError', 'onKeyDown', 'onKeyDownCapture', 'onKeyPress', 'onKeyUp', 'onAbort', 'onCanPlay', 'onCanPlayThrough', 'onDurationChange', 'onEmptied', 'onEncrypted', 'onEnded', 'onLoadedData', 'onLoadedMetadata', 'onLoadStart', 'onPause', 'onPlay', 'onPlaying', 'onProgress', 'onRateChange', 'onSeeked', 'onSeeking', 'onStalled', 'onSuspend', 'onTimeUpdate', 'onVolumeChange', 'onWaiting', 'onClick', 'onClickCapture', 'onContextMenu', 'onDoubleClick', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onMouseDown', 'onMouseDownCapture', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', 'onMouseUpCapture', 'onSelect', 'onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart', 'onScroll', 'onWheel', 'onPointerCancel', 'onPointerDown', 'onPointerEnter', 'onPointerLeave', 'onPointerMove', 'onPointerOut', 'onPointerOver', 'onPointerUp', 'onGotPointerCapture', 'onLostPointerCapture']);
|
22
17
|
/**
|
23
18
|
* An array of element attributes which are allowed on every html element type.
|
24
19
|
*
|
25
20
|
* @public
|
26
21
|
*/
|
27
|
-
|
28
22
|
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
23
|
]);
|
30
24
|
/**
|
@@ -32,7 +26,6 @@ export const baseElementProperties = /*#__PURE__*/toObjectMap(['accessKey', 'chi
|
|
32
26
|
*
|
33
27
|
* @public
|
34
28
|
*/
|
35
|
-
|
36
29
|
export const microdataProperties = /*#__PURE__*/toObjectMap(['itemID', 'itemProp', 'itemRef', 'itemScope', 'itemType' // global
|
37
30
|
]);
|
38
31
|
/**
|
@@ -40,14 +33,12 @@ export const microdataProperties = /*#__PURE__*/toObjectMap(['itemID', 'itemProp
|
|
40
33
|
*
|
41
34
|
* @public
|
42
35
|
*/
|
43
|
-
|
44
36
|
export const htmlElementProperties = /*#__PURE__*/toObjectMap(baseElementProperties, baseElementEvents, microdataProperties);
|
45
37
|
/**
|
46
38
|
* An array of LABEL tag properties and events.
|
47
39
|
*
|
48
40
|
* @public
|
49
41
|
*/
|
50
|
-
|
51
42
|
export const labelProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['form' // button, fieldset, input, label, meter, object, output, select, textarea
|
52
43
|
]);
|
53
44
|
/**
|
@@ -55,7 +46,6 @@ export const labelProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, [
|
|
55
46
|
|
56
47
|
* @public
|
57
48
|
*/
|
58
|
-
|
59
49
|
export const audioProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['height', 'loop', 'muted', 'preload', 'src', 'width' // canvas, embed, iframe, img, input, object, video
|
60
50
|
]);
|
61
51
|
/**
|
@@ -63,7 +53,6 @@ export const audioProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, [
|
|
63
53
|
*
|
64
54
|
* @public
|
65
55
|
*/
|
66
|
-
|
67
56
|
export const videoProperties = /*#__PURE__*/toObjectMap(audioProperties, ['poster' // video
|
68
57
|
]);
|
69
58
|
/**
|
@@ -71,7 +60,6 @@ export const videoProperties = /*#__PURE__*/toObjectMap(audioProperties, ['poste
|
|
71
60
|
*
|
72
61
|
* @public
|
73
62
|
*/
|
74
|
-
|
75
63
|
export const olProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['start' // ol
|
76
64
|
]);
|
77
65
|
/**
|
@@ -79,7 +67,6 @@ export const olProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['st
|
|
79
67
|
*
|
80
68
|
* @public
|
81
69
|
*/
|
82
|
-
|
83
70
|
export const liProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['value' // button, input, li, option, meter, progress, param
|
84
71
|
]);
|
85
72
|
/**
|
@@ -87,7 +74,6 @@ export const liProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['va
|
|
87
74
|
*
|
88
75
|
* @public
|
89
76
|
*/
|
90
|
-
|
91
77
|
export const anchorProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['download', 'href', 'hrefLang', 'media', 'rel', 'target', 'type' // a, button, input, link, menu, object, script, source, style
|
92
78
|
]);
|
93
79
|
/**
|
@@ -95,7 +81,6 @@ export const anchorProperties = /*#__PURE__*/toObjectMap(htmlElementProperties,
|
|
95
81
|
*
|
96
82
|
* @public
|
97
83
|
*/
|
98
|
-
|
99
84
|
export const timeProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['dateTime' // time
|
100
85
|
]);
|
101
86
|
/**
|
@@ -103,7 +88,6 @@ export const timeProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['
|
|
103
88
|
*
|
104
89
|
* @public
|
105
90
|
*/
|
106
|
-
|
107
91
|
export const buttonProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['autoFocus', 'disabled', 'form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget', 'type', 'value' // button, input, li, option, meter, progress, param,
|
108
92
|
]);
|
109
93
|
/**
|
@@ -111,7 +95,6 @@ export const buttonProperties = /*#__PURE__*/toObjectMap(htmlElementProperties,
|
|
111
95
|
*
|
112
96
|
* @public
|
113
97
|
*/
|
114
|
-
|
115
98
|
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
|
116
99
|
]);
|
117
100
|
/**
|
@@ -119,7 +102,6 @@ export const inputProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['acce
|
|
119
102
|
*
|
120
103
|
* @public
|
121
104
|
*/
|
122
|
-
|
123
105
|
export const textAreaProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['autoCapitalize', 'cols', 'dirname', 'form', 'maxLength', 'placeholder', 'readOnly', 'required', 'rows', 'wrap' // textarea
|
124
106
|
]);
|
125
107
|
/**
|
@@ -127,9 +109,9 @@ export const textAreaProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['a
|
|
127
109
|
*
|
128
110
|
* @public
|
129
111
|
*/
|
130
|
-
|
131
112
|
export const selectProperties = /*#__PURE__*/toObjectMap(buttonProperties, ['form', 'multiple', 'required' // input, select, textarea
|
132
113
|
]);
|
114
|
+
|
133
115
|
export const optionProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['selected', 'value' // button, input, li, option, meter, progress, param
|
134
116
|
]);
|
135
117
|
/**
|
@@ -137,7 +119,6 @@ export const optionProperties = /*#__PURE__*/toObjectMap(htmlElementProperties,
|
|
137
119
|
*
|
138
120
|
* @public
|
139
121
|
*/
|
140
|
-
|
141
122
|
export const tableProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['cellPadding', 'cellSpacing' // table
|
142
123
|
]);
|
143
124
|
/**
|
@@ -145,14 +126,12 @@ export const tableProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, [
|
|
145
126
|
*
|
146
127
|
* @public
|
147
128
|
*/
|
148
|
-
|
149
129
|
export const trProperties = htmlElementProperties;
|
150
130
|
/**
|
151
131
|
* An array of TH tag properties and events.
|
152
132
|
*
|
153
133
|
* @public
|
154
134
|
*/
|
155
|
-
|
156
135
|
export const thProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['colSpan', 'rowSpan', 'scope' // th
|
157
136
|
]);
|
158
137
|
/**
|
@@ -160,11 +139,12 @@ export const thProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['co
|
|
160
139
|
*
|
161
140
|
* @public
|
162
141
|
*/
|
163
|
-
|
164
142
|
export const tdProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['colSpan', 'headers', 'rowSpan', 'scope' // th
|
165
143
|
]);
|
144
|
+
|
166
145
|
export const colGroupProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['span' // col, colgroup
|
167
146
|
]);
|
147
|
+
|
168
148
|
export const colProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['span' // col, colgroup
|
169
149
|
]);
|
170
150
|
/**
|
@@ -172,7 +152,6 @@ export const colProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['s
|
|
172
152
|
*
|
173
153
|
* @public
|
174
154
|
*/
|
175
|
-
|
176
155
|
export const fieldsetProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['disabled', 'form' // button, fieldset, input, label, meter, object, output, select, textarea
|
177
156
|
]);
|
178
157
|
/**
|
@@ -180,7 +159,6 @@ export const fieldsetProperties = /*#__PURE__*/toObjectMap(htmlElementProperties
|
|
180
159
|
*
|
181
160
|
* @public
|
182
161
|
*/
|
183
|
-
|
184
162
|
export const formProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['acceptCharset', 'action', 'encType', 'encType', 'method', 'noValidate', 'target' // form
|
185
163
|
]);
|
186
164
|
/**
|
@@ -188,7 +166,6 @@ export const formProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['
|
|
188
166
|
*
|
189
167
|
* @public
|
190
168
|
*/
|
191
|
-
|
192
169
|
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,
|
193
170
|
]);
|
194
171
|
/**
|
@@ -196,7 +173,6 @@ export const iframeProperties = /*#__PURE__*/toObjectMap(htmlElementProperties,
|
|
196
173
|
*
|
197
174
|
* @public
|
198
175
|
*/
|
199
|
-
|
200
176
|
export const imgProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['alt', 'crossOrigin', 'height', 'src', 'srcSet', 'useMap', 'width' // canvas, embed, iframe, img, input, object, video
|
201
177
|
]);
|
202
178
|
/**
|
@@ -204,14 +180,12 @@ export const imgProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['a
|
|
204
180
|
*
|
205
181
|
* @public
|
206
182
|
*/
|
207
|
-
|
208
183
|
export const dialogProperties = /*#__PURE__*/toObjectMap(htmlElementProperties, ['open', 'onCancel', 'onClose']);
|
209
184
|
/**
|
210
185
|
* An array of DIV tag properties and events.
|
211
186
|
*
|
212
187
|
* @public
|
213
188
|
*/
|
214
|
-
|
215
189
|
export const divProperties = htmlElementProperties;
|
216
190
|
/**
|
217
191
|
* Gets native supported props for an html element provided the allowance set. Use one of the property
|
@@ -229,28 +203,25 @@ export const divProperties = htmlElementProperties;
|
|
229
203
|
* @returns The filtered props
|
230
204
|
*/
|
231
205
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
232
|
-
|
233
|
-
|
206
|
+
export function getNativeProps(
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
234
208
|
props, allowedPropNames, excludedPropNames) {
|
235
209
|
// It'd be great to properly type this while allowing 'aria-` and 'data-' attributes like TypeScript does for
|
236
210
|
// JSX attributes, but that ability is hardcoded into the TS compiler with no analog in TypeScript typings.
|
237
211
|
// Then we'd be able to enforce props extends native props (including aria- and data- attributes), and then
|
238
212
|
// return native props.
|
239
213
|
// We should be able to do this once this PR is merged: https://github.com/microsoft/TypeScript/pull/26797
|
240
|
-
const isArray = Array.isArray(allowedPropNames);
|
241
|
-
|
214
|
+
const isArray = Array.isArray(allowedPropNames);
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
242
216
|
const result = {};
|
243
217
|
const keys = Object.keys(props);
|
244
|
-
|
245
218
|
for (const key of keys) {
|
246
219
|
const isNativeProp = !isArray && allowedPropNames[key] || isArray && allowedPropNames.indexOf(key) >= 0 || key.indexOf('data-') === 0 || key.indexOf('aria-') === 0;
|
247
|
-
|
248
220
|
if (isNativeProp && (!excludedPropNames || (excludedPropNames === null || excludedPropNames === void 0 ? void 0 : excludedPropNames.indexOf(key)) === -1)) {
|
249
221
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
250
222
|
result[key] = props[key];
|
251
223
|
}
|
252
224
|
}
|
253
|
-
|
254
225
|
return result;
|
255
226
|
}
|
256
227
|
//# sourceMappingURL=properties.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-utilities/src/utils/properties.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,CAAC,GAAG,KAAJ,KAAoD;EACtE,MAAM,MAAM,GAA2B,EAAvC;;EAEA,KAAK,MAAM,IAAX,IAAmB,KAAnB,EAA0B;IACxB,MAAM,IAAI,GAAG,KAAK,CAAC,OAAN,CAAc,IAAd,IAAsB,IAAtB,GAA6B,MAAM,CAAC,IAAP,CAAY,IAAZ,CAA1C;;IAEA,KAAK,MAAM,GAAX,IAAkB,IAAlB,EAAwB;MACtB,MAAM,CAAC,GAAD,CAAN,GAAc,CAAd;IACD;EACF;;EAED,OAAO,MAAP;AACD,CAZD;AAcA;;;;AAIG;;;AACH,OAAO,MAAM,iBAAiB,gBAAG,WAAW,CAAC,CAC3C,YAD2C,EAE3C,QAF2C,EAG3C,OAH2C,EAI3C,SAJ2C,EAK3C,kBAL2C,EAM3C,oBAN2C,EAO3C,qBAP2C,EAQ3C,SAR2C,EAS3C,gBAT2C,EAU3C,QAV2C,EAW3C,eAX2C,EAY3C,UAZ2C,EAa3C,SAb2C,EAc3C,UAd2C,EAe3C,QAf2C,EAgB3C,SAhB2C,EAiB3C,WAjB2C,EAkB3C,kBAlB2C,EAmB3C,YAnB2C,EAoB3C,SApB2C,EAqB3C,SArB2C,EAsB3C,WAtB2C,EAuB3C,kBAvB2C,EAwB3C,kBAxB2C,EAyB3C,WAzB2C,EA0B3C,aA1B2C,EA2B3C,SA3B2C,EA4B3C,cA5B2C,EA6B3C,kBA7B2C,EA8B3C,aA9B2C,EA+B3C,SA/B2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AC,GAAD,CAAN,GAAc,KAAM,CAAC,GAAD,CAApB;IACD;EACF;;EAED,OAAO,MAAP;AACD","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"],"sourceRoot":"../src/"}
|
1
|
+
{"version":3,"mappings":"AAAA,MAAMA,WAAW,GAAG,CAAC,GAAGC,KAA4C,KAAI;EACtE,MAAMC,MAAM,GAA2B,EAAE;EAEzC,KAAK,MAAMC,IAAI,IAAIF,KAAK,EAAE;IACxB,MAAMG,IAAI,GAAGC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,GAAGA,IAAI,GAAGI,MAAM,CAACH,IAAI,CAACD,IAAI,CAAC;IAE3D,KAAK,MAAMK,GAAG,IAAIJ,IAAI,EAAE;MACtBF,MAAM,CAACM,GAAG,CAAC,GAAG,CAAC;;;EAInB,OAAON,MAAM;AACf,CAAC;AAED;;;;;AAKA,OAAO,MAAMO,iBAAiB,gBAAGT,WAAW,CAAC,CAC3C,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,UAAU,EACV,SAAS,EACT,UAA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,GAAGD,KAAK,CAACC,OAAO,CAACiC,gBAAgB,CAAC;EAC/C;EACA,MAAMrC,MAAM,GAAwB,EAAE;EACtC,MAAME,IAAI,GAAGG,MAAM,CAACH,IAAI,CAACkC,KAAK,CAAC;EAE/B,KAAK,MAAM9B,GAAG,IAAIJ,IAAI,EAAE;IACtB,MAAMqC,YAAY,GACf,CAACnC,OAAO,IAAKiC,gBAA2C,CAAC/B,GAAG,CAAC,IAC7DF,OAAO,IAAKiC,gBAA6B,CAACG,OAAO,CAAClC,GAAG,CAAC,IAAI,CAAE,IAC7DA,GAAG,CAACkC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAC1BlC,GAAG,CAACkC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;IAE5B,IAAID,YAAY,KAAK,CAACD,iBAAiB,IAAI,kBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAEE,OAAO,CAAClC,GAAG,CAAC,MAAK,CAAC,CAAC,CAAC,EAAE;MAClF;MACAN,MAAM,CAACM,GAAG,CAAC,GAAG8B,KAAM,CAAC9B,GAAG,CAAQ;;;EAIpC,OAAON,MAAW;AACpB","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"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/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"]}
|
@@ -13,9 +13,10 @@ define(["require", "exports"], function (require, exports) {
|
|
13
13
|
*/
|
14
14
|
function isHTMLElement(element) {
|
15
15
|
var _a;
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
var typedElement = element;
|
17
|
+
return Boolean(typedElement !== null &&
|
18
|
+
((_a = typedElement === null || typedElement === void 0 ? void 0 : typedElement.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) &&
|
19
|
+
typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement);
|
19
20
|
}
|
20
21
|
exports.isHTMLElement = isHTMLElement;
|
21
22
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"isHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,
|
1
|
+
{"version":3,"file":"isHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isHTMLElement.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAiB;;QAC7C,IAAM,YAAY,GAAG,OAAkC,CAAC;QACxD,OAAO,OAAO,CACZ,YAAY,KAAK,IAAI;aACnB,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,aAAa,0CAAE,WAAW,CAAA;YACxC,YAAY,YAAY,YAAY,CAAC,aAAa,CAAC,WAAW,CAAC,WAAW,CAC7E,CAAC;IACJ,CAAC;IAPD,sCAOC","sourcesContent":["/**\n * @internal\n * Verifies if a given node is an HTMLElement,\n * this method works seamlessly with frames and elements from different documents\n *\n * This is required as simply using `instanceof`\n * might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)\n *\n */\nexport function isHTMLElement(element?: unknown): element is HTMLElement {\n const typedElement = element as Node | null | undefined;\n return Boolean(\n typedElement !== null &&\n typedElement?.ownerDocument?.defaultView &&\n typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement,\n );\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"isInteractiveHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isInteractiveHTMLElement.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACH,SAAgB,wBAAwB,CAAC,
|
1
|
+
{"version":3,"file":"isInteractiveHTMLElement.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/isInteractiveHTMLElement.ts"],"names":[],"mappings":";;;;IAEA;;;OAGG;IACH,SAAgB,wBAAwB,CAAC,OAAgB;QACvD,IAAI,CAAC,6BAAa,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,KAAK,CAAC;SACd;QAEO,IAAA,OAAO,GAAK,OAAO,QAAZ,CAAa;QAC5B,QAAQ,OAAO,EAAE;YACf,KAAK,QAAQ,CAAC;YACd,KAAK,GAAG,CAAC;YACT,KAAK,OAAO,CAAC;YACb,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC;SACf;QAED,OAAO,OAAO,CAAC,iBAAiB,CAAC;IACnC,CAAC;IAfD,4DAeC","sourcesContent":["import { isHTMLElement } from './isHTMLElement';\n\n/**\n * @internal\n * Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys\n */\nexport function isInteractiveHTMLElement(element: unknown) {\n if (!isHTMLElement(element)) {\n return false;\n }\n\n const { tagName } = element;\n switch (tagName) {\n case 'BUTTON':\n case 'A':\n case 'INPUT':\n case 'TEXTAREA':\n return true;\n }\n\n return element.isContentEditable;\n}\n"]}
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getSlots = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const omit_1 = /*#__PURE__*/require("../utils/omit");
|
11
9
|
/**
|
12
10
|
* Given the state and an array of slot names, will break out `slots` and `slotProps`
|
@@ -25,48 +23,38 @@ const omit_1 = /*#__PURE__*/require("../utils/omit");
|
|
25
23
|
* @param state - State including slot definitions
|
26
24
|
* @returns An object containing the `slots` map and `slotProps` map.
|
27
25
|
*/
|
28
|
-
|
29
|
-
|
30
26
|
function getSlots(state) {
|
31
27
|
const slots = {};
|
32
28
|
const slotProps = {};
|
33
29
|
const slotNames = Object.keys(state.components);
|
34
|
-
|
35
30
|
for (const slotName of slotNames) {
|
36
31
|
const [slot, props] = getSlot(state, slotName);
|
37
32
|
slots[slotName] = slot;
|
38
33
|
slotProps[slotName] = props;
|
39
34
|
}
|
40
|
-
|
41
35
|
return {
|
42
36
|
slots,
|
43
37
|
slotProps: slotProps
|
44
38
|
};
|
45
39
|
}
|
46
|
-
|
47
40
|
exports.getSlots = getSlots;
|
48
|
-
|
49
41
|
function getSlot(state, slotName) {
|
50
42
|
var _a, _b, _c;
|
51
|
-
|
52
43
|
if (state[slotName] === undefined) {
|
53
44
|
return [null, undefined];
|
54
45
|
}
|
55
|
-
|
56
46
|
const {
|
57
47
|
children,
|
58
48
|
as: asProp,
|
59
49
|
...rest
|
60
50
|
} = state[slotName];
|
61
51
|
const slot = ((_a = state.components) === null || _a === void 0 ? void 0 : _a[slotName]) === undefined || typeof state.components[slotName] === 'string' ? asProp || ((_b = state.components) === null || _b === void 0 ? void 0 : _b[slotName]) || 'div' : state.components[slotName];
|
62
|
-
|
63
52
|
if (typeof children === 'function') {
|
64
53
|
const render = children;
|
65
54
|
return [React.Fragment, {
|
66
55
|
children: render(slot, rest)
|
67
56
|
}];
|
68
57
|
}
|
69
|
-
|
70
58
|
const shouldOmitAsProp = typeof slot === 'string' && ((_c = state[slotName]) === null || _c === void 0 ? void 0 : _c.as);
|
71
59
|
const slotProps = shouldOmitAsProp ? omit_1.omit(state[slotName], ['as']) : state[slotName];
|
72
60
|
return [slot, slotProps];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;AA6BA;;;;;;;;;;;;;;;;;AAiBA,SAAgBA,QAAQ,CACtBC,KAAwB;EAKxB,MAAMC,KAAK,GAAG,EAAc;EAC5B,MAAMC,SAAS,GAAG,EAAO;EAEzB,MAAMC,SAAS,GAAgBC,MAAM,CAACC,IAAI,CAACL,KAAK,CAACM,UAAU,CAAC;EAC5D,KAAK,MAAMC,QAAQ,IAAIJ,SAAS,EAAE;IAChC,MAAM,CAACK,IAAI,EAAEC,KAAK,CAAC,GAAGC,OAAO,CAACV,KAAK,EAAEO,QAAQ,CAAC;IAC9CN,KAAK,CAACM,QAAQ,CAAC,GAAGC,IAAiC;IACnDN,SAAS,CAACK,QAAQ,CAAC,GAAGE,KAAK;;EAE7B,OAAO;IAAER,KAAK;IAAEC,SAAS,EAAGA;EAA2C,CAAE;AAC3E;AAhBAS;AAkBA,SAASD,OAAO,CACdV,KAAwB,EACxBO,QAAW;;EAEX,IAAIP,KAAK,CAACO,QAAQ,CAAC,KAAKK,SAAS,EAAE;IACjC,OAAO,CAAC,IAAI,EAAEA,SAAiB,CAAC;;EAElC,MAAM;IAAEC,QAAQ;IAAEC,EAAE,EAAEC,MAAM;IAAE,GAAGC;EAAI,CAAE,GAAGhB,KAAK,CAACO,QAAQ,CAAE;EAE1D,MAAMC,IAAI,GAAI,YAAK,CAACF,UAAU,0CAAGC,QAAQ,CAAC,MAAKK,SAAS,IAAI,OAAOZ,KAAK,CAACM,UAAU,CAACC,QAAQ,CAAC,KAAK,QAAQ,GACtGQ,MAAM,KAAI,WAAK,CAACT,UAAU,0CAAGC,QAAQ,CAAC,KAAI,KAAK,GAC/CP,KAAK,CAACM,UAAU,CAACC,QAAQ,CAA6B;EAE1D,IAAI,OAAOM,QAAQ,KAAK,UAAU,EAAE;IAClC,MAAMI,MAAM,GAAGJ,QAAoC;IACnD,OAAO,CACLK,KAAK,CAACC,QAAQ,EACb;MACCN,QAAQ,EAAEI,MAAM,CAACT,IAAI,EAAEQ,IAAqC;KACzC,CACtB;;EAGH,MAAMI,gBAAgB,GAAG,OAAOZ,IAAI,KAAK,QAAQ,KAAI,WAAK,CAACD,QAAQ,CAAC,0CAAEO,EAAE;EACxE,MAAMZ,SAAS,GAAIkB,gBAAgB,GAAGC,WAAI,CAACrB,KAAK,CAACO,QAAQ,CAAE,EAAE,CAAC,IAAI,CAAC,CAAC,GAAGP,KAAK,CAACO,QAAQ,CAAU;EAE/F,OAAO,CAACC,IAAI,EAAEN,SAAS,CAAC;AAC1B","names":["getSlots","state","slots","slotProps","slotNames","Object","keys","components","slotName","slot","props","getSlot","exports","undefined","children","as","asProp","rest","render","React","Fragment","shouldOmitAsProp","omit_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/getSlots.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { omit } from '../utils/omit';\nimport type {\n AsIntrinsicElement,\n ComponentState,\n ExtractSlotProps,\n SlotPropsRecord,\n SlotRenderFunction,\n UnionToIntersection,\n} from './types';\n\nexport type Slots<S extends SlotPropsRecord> = {\n [K in keyof S]: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // for slots with an `as` prop, the slot will be any one of the possible values of `as`\n As\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? React.ElementType<NonNullable<P>>\n : React.ElementType<ExtractSlotProps<S[K]>>;\n};\n\ntype ObjectSlotProps<S extends SlotPropsRecord> = {\n [K in keyof S]-?: ExtractSlotProps<S[K]> extends AsIntrinsicElement<infer As>\n ? // For intrinsic element types, return the intersection of all possible\n // element's props, to be compatible with the As type returned by Slots<>\n UnionToIntersection<JSX.IntrinsicElements[As]>\n : ExtractSlotProps<S[K]> extends React.ComponentType<infer P>\n ? P\n : never;\n};\n\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 */\nexport function getSlots<R extends SlotPropsRecord>(\n state: ComponentState<R>,\n): {\n slots: Slots<R>;\n slotProps: ObjectSlotProps<R>;\n} {\n const slots = {} as Slots<R>;\n const slotProps = {} as R;\n\n const slotNames: (keyof R)[] = Object.keys(state.components);\n for (const slotName of slotNames) {\n const [slot, props] = getSlot(state, slotName);\n slots[slotName] = slot as Slots<R>[typeof slotName];\n slotProps[slotName] = props;\n }\n return { slots, slotProps: (slotProps as unknown) as ObjectSlotProps<R> };\n}\n\nfunction getSlot<R extends SlotPropsRecord, K extends keyof R>(\n state: ComponentState<R>,\n slotName: K,\n): readonly [React.ElementType<R[K]> | null, R[K]] {\n if (state[slotName] === undefined) {\n return [null, undefined as R[K]];\n }\n const { children, as: asProp, ...rest } = state[slotName]!;\n\n const slot = (state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'\n ? asProp || state.components?.[slotName] || 'div'\n : state.components[slotName]) as React.ElementType<R[K]>;\n\n if (typeof children === 'function') {\n const render = children as SlotRenderFunction<R[K]>;\n return [\n React.Fragment,\n ({\n children: render(slot, rest as Omit<R[K], 'children' | 'as'>),\n } as unknown) as R[K],\n ];\n }\n\n const shouldOmitAsProp = typeof slot === 'string' && state[slotName]?.as;\n const slotProps = (shouldOmitAsProp ? omit(state[slotName]!, ['as']) : state[slotName]) as R[K];\n\n return [slot, slotProps];\n}\n"]}
|
@@ -3,14 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
-
|
9
7
|
tslib_1.__exportStar(require("./getSlots"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./resolveShorthand"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./types"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./isResolvedShorthand"), exports);
|
16
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-utilities/src/compose/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/compose/index.ts"],"sourcesContent":["export * from './getSlots';\nexport * from './resolveShorthand';\nexport * from './types';\nexport * from './isResolvedShorthand';\n"]}
|