@fluentui/react-utilities 9.2.2 → 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 +66 -1
- package/CHANGELOG.md +21 -2
- package/dist/index.d.ts +17 -8
- 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 +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/index.js +2 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isHTMLElement.js +15 -0
- package/lib/utils/isHTMLElement.js.map +1 -0
- package/lib/utils/isInteractiveHTMLElement.js +22 -0
- package/lib/utils/isInteractiveHTMLElement.js.map +1 -0
- 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/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/utils/index.js +3 -2
- package/lib-amd/utils/index.js.map +1 -1
- package/lib-amd/utils/isHTMLElement.js +23 -0
- package/lib-amd/utils/isHTMLElement.js.map +1 -0
- package/lib-amd/utils/isInteractiveHTMLElement.js +25 -0
- package/lib-amd/utils/isInteractiveHTMLElement.js.map +1 -0
- 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 +9 -13
- 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 +2 -9
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isHTMLElement.js +22 -0
- package/lib-commonjs/utils/isHTMLElement.js.map +1 -0
- package/lib-commonjs/utils/isInteractiveHTMLElement.js +29 -0
- package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -0
- 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
- package/lib/utils/shouldPreventDefaultOnKeyDown.js +0 -25
- package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +0 -1
- package/lib-amd/utils/shouldPreventDefaultOnKeyDown.js +0 -26
- package/lib-amd/utils/shouldPreventDefaultOnKeyDown.js.map +0 -1
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +0 -35
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;;AAIA,SAAgBA,2BAA2B,CACzCC,QAAqD,EACrDC,iBAAoC;EAEpC,IAAI,OAAOD,QAAQ,KAAK,UAAU,EAAE;IAClC,OAAOA,QAAQ,CAACC,iBAAiB,CAAC;GACnC,MAAM,IAAID,QAAQ,EAAE;IACnB,OAAOE,gBAAgB,CAACF,QAAQ,EAAEC,iBAAiB,CAAC;;EAGtD;EACA;EACA;EACA,OAAOD,QAAQ,IAAI,IAAI;AACzB;AAdAG;AAgBA;;;;AAIA,SAASD,gBAAgB,CACvBE,KAAsB,EACtBC,YAA+B;EAE/B,IAAI,CAACC,KAAK,CAACC,cAAc,CAACH,KAAK,CAAC,IAAIA,KAAK,CAACI,IAAI,KAAKF,KAAK,CAACG,QAAQ,EAAE;IACjE,MAAM,IAAIC,KAAK,CACb,iEAAiE,GAC/D,sDAAsD,CACzD;;EAGH,IAAIC,iCAAe,CAACP,KAAK,CAAC,EAAE;IAC1B,MAAMQ,UAAU,GAAGV,gBAAgB,CAACE,KAAK,CAACS,KAAK,CAACb,QAAQ,EAAEK,YAAY,CAAC;IACvE,OAAOC,KAAK,CAACQ,YAAY,CAACV,KAAK,EAAEW,SAAS,EAAEH,UAAU,CAAC;GACxD,MAAM;IACL,OAAON,KAAK,CAACQ,YAAY,CAACV,KAAK,EAAEC,YAAoD,CAAC;;AAE1F","names":["applyTriggerPropsToChildren","children","triggerChildProps","cloneTriggerTree","exports","child","triggerProps","React","isValidElement","type","Fragment","Error","isFluentTrigger_1","grandchild","props","cloneElement","undefined"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/trigger/applyTriggerPropsToChildren.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * resolve the trigger props to the children, either by calling the render function, or cloning with the new props.\n */\nexport function applyTriggerPropsToChildren<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n triggerChildProps: TriggerChildProps,\n): React.ReactElement | null {\n if (typeof children === 'function') {\n return children(triggerChildProps);\n } else if (children) {\n return cloneTriggerTree(children, triggerChildProps);\n }\n\n // Components in React should return either JSX elements or \"null\", otherwise React will throw:\n // Nothing was returned from render.\n // This usually means a return statement is missing. Or, to render nothing, return null.\n return children || null;\n}\n\n/**\n * Clones a React element tree, and applies the given props to the first grandchild that is not\n * a FluentTriggerComponent or React Fragment (the same element returned by {@link getTriggerChild}).\n */\nfunction cloneTriggerTree<TriggerChildProps>(\n child: React.ReactNode,\n triggerProps: TriggerChildProps,\n): React.ReactElement {\n if (!React.isValidElement(child) || child.type === React.Fragment) {\n throw new Error(\n 'A trigger element must be a single element for this component. ' +\n \"Please ensure that you're not using React Fragments.\",\n );\n }\n\n if (isFluentTrigger(child)) {\n const grandchild = cloneTriggerTree(child.props.children, triggerProps);\n return React.cloneElement(child, undefined, grandchild);\n } else {\n return React.cloneElement(child, triggerProps as TriggerChildProps & React.Attributes);\n }\n}\n"]}
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getTriggerChild = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const isFluentTrigger_1 = /*#__PURE__*/require("./isFluentTrigger");
|
11
9
|
/**
|
12
10
|
* @internal
|
@@ -30,17 +28,14 @@ const isFluentTrigger_1 = /*#__PURE__*/require("./isFluentTrigger");
|
|
30
28
|
* In the case where the immediate child is not a valid element,
|
31
29
|
* null is returned
|
32
30
|
*/
|
33
|
-
|
34
|
-
|
35
31
|
function getTriggerChild(children) {
|
36
32
|
if (!React.isValidElement(children)) {
|
37
33
|
return null;
|
38
34
|
}
|
39
|
-
|
40
|
-
|
35
|
+
return isFluentTrigger_1.isFluentTrigger(children) ? getTriggerChild(
|
36
|
+
// FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,
|
41
37
|
// but for some reason it's failing on build
|
42
38
|
children.props.children) : children;
|
43
39
|
}
|
44
|
-
|
45
40
|
exports.getTriggerChild = getTriggerChild;
|
46
41
|
//# sourceMappingURL=getTriggerChild.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgBA,eAAe,CAC7BC,QAAqD;EAGrD,IAAI,CAACC,KAAK,CAACC,cAAc,CAAoBF,QAAQ,CAAC,EAAE;IACtD,OAAO,IAAI;;EAEb,OAAOG,iCAAe,CAACH,QAAQ,CAAC,GAC5BD,eAAe;EACb;EACA;EACCC,QAAQ,CAACI,KAAsB,CAACJ,QAAQ,CAC1C,GACDA,QAAQ;AACd;AAdAK","names":["getTriggerChild","children","React","isValidElement","isFluentTrigger_1","props","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/trigger/getTriggerChild.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).\n *\n * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,\n * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.\n * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.\n *\n * For example, the following returns `<div id=\"child\" />`:\n * ```jsx\n * getTriggerChild(\n * <Tooltip>\n * <MenuTrigger>\n * <div id=\"child\" />\n * </MenuTrigger>\n * </Tooltip>\n * );\n * ```\n *\n * In the case where the immediate child is not a valid element,\n * null is returned\n */\nexport function getTriggerChild<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (React.ReactElement<Partial<TriggerChildProps>> & { ref?: React.Ref<any> }) | null {\n if (!React.isValidElement<TriggerChildProps>(children)) {\n return null;\n }\n return isFluentTrigger(children)\n ? getTriggerChild(\n // FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,\n // but for some reason it's failing on build\n (children.props as TriggerProps).children,\n )\n : children;\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("./applyTriggerPropsToChildren"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./getTriggerChild"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./isFluentTrigger"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./types"), exports);
|
16
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-utilities/src/trigger/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/trigger/index.ts"],"sourcesContent":["export * from './applyTriggerPropsToChildren';\nexport * from './getTriggerChild';\nexport * from './isFluentTrigger';\nexport * from './types';\n"]}
|
@@ -9,10 +9,8 @@ exports.isFluentTrigger = void 0;
|
|
9
9
|
* Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
|
10
10
|
* See the {@link FluentTriggerComponent} type for more info.
|
11
11
|
*/
|
12
|
-
|
13
12
|
function isFluentTrigger(element) {
|
14
13
|
return Boolean(element.type.isFluentTriggerComponent);
|
15
14
|
}
|
16
|
-
|
17
15
|
exports.isFluentTrigger = isFluentTrigger;
|
18
16
|
//# sourceMappingURL=isFluentTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAGA;;;;;AAKA,SAAgBA,eAAe,CAACC,OAA2B;EACzD,OAAOC,OAAO,CAAED,OAAO,CAACE,IAA+B,CAACC,wBAAwB,CAAC;AACnF;AAFAC","names":["isFluentTrigger","element","Boolean","type","isFluentTriggerComponent","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/trigger/isFluentTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport type { FluentTriggerComponent, TriggerProps } from './types';\n\n/**\n * @internal\n * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).\n * See the {@link FluentTriggerComponent} type for more info.\n */\nexport function isFluentTrigger(element: React.ReactElement): element is React.ReactElement<TriggerProps> {\n return Boolean((element.type as FluentTriggerComponent).isFluentTriggerComponent);\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
@@ -12,8 +12,6 @@ exports.clamp = void 0;
|
|
12
12
|
* @param min - the lowest valid value
|
13
13
|
* @param max - the highest valid value
|
14
14
|
*/
|
15
|
-
|
16
15
|
const clamp = (value, min, max) => Math.max(min, Math.min(max, value || 0));
|
17
|
-
|
18
16
|
exports.clamp = clamp;
|
19
17
|
//# sourceMappingURL=clamp.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;;;;;;;;AAQO,MAAMA,KAAK,GAAG,CAACC,KAAa,EAAEC,GAAW,EAAEC,GAAW,KAAaC,IAAI,CAACD,GAAG,CAACD,GAAG,EAAEE,IAAI,CAACF,GAAG,CAACC,GAAG,EAAEF,KAAK,IAAI,CAAC,CAAC,CAAC;AAArGI,aAAK","names":["clamp","value","min","max","Math","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/clamp.ts"],"sourcesContent":["/**\n * @internal\n * Clamps `value` to a number between the min and max.\n *\n * @param value - the value to be clamped\n * @param min - the lowest valid value\n * @param max - the highest valid value\n */\nexport const clamp = (value: number, min: number, max: number): number => Math.max(min, Math.min(max, value || 0));\n"]}
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getPartitionedNativeProps = exports.getNativeElementProps = void 0;
|
7
|
-
|
8
7
|
const properties_1 = /*#__PURE__*/require("./properties");
|
9
|
-
|
10
8
|
const nativeElementMap = {
|
11
9
|
label: properties_1.labelProperties,
|
12
10
|
audio: properties_1.audioProperties,
|
@@ -40,13 +38,11 @@ const nativeElementMap = {
|
|
40
38
|
* @param excludedPropNames - List of props to disallow
|
41
39
|
*/
|
42
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
43
|
-
|
44
41
|
function getNativeElementProps(tagName, props, excludedPropNames) {
|
45
42
|
const allowedPropNames = tagName && nativeElementMap[tagName] || properties_1.htmlElementProperties;
|
46
43
|
allowedPropNames.as = 1;
|
47
44
|
return properties_1.getNativeProps(props, allowedPropNames, excludedPropNames);
|
48
45
|
}
|
49
|
-
|
50
46
|
exports.getNativeElementProps = getNativeElementProps;
|
51
47
|
/**
|
52
48
|
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
@@ -56,7 +52,6 @@ exports.getNativeElementProps = getNativeElementProps;
|
|
56
52
|
*
|
57
53
|
* @returns An object containing the native props for the `root` and primary slots.
|
58
54
|
*/
|
59
|
-
|
60
55
|
const getPartitionedNativeProps = ({
|
61
56
|
primarySlotTagName,
|
62
57
|
props,
|
@@ -70,6 +65,5 @@ const getPartitionedNativeProps = ({
|
|
70
65
|
primary: getNativeElementProps(primarySlotTagName, props, [...(excludedPropNames || []), 'style', 'className'])
|
71
66
|
};
|
72
67
|
};
|
73
|
-
|
74
68
|
exports.getPartitionedNativeProps = getPartitionedNativeProps;
|
75
69
|
//# sourceMappingURL=getNativeElementProps.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AACA;AA4BA,MAAMA,gBAAgB,GAA2C;EAC/DC,KAAK,EAAEC,4BAAe;EACtBC,KAAK,EAAED,4BAAe;EACtBE,KAAK,EAAEF,4BAAe;EACtBG,EAAE,EAAEH,yBAAY;EAChBI,EAAE,EAAEJ,yBAAY;EAChBK,CAAC,EAAEL,6BAAgB;EACnBM,MAAM,EAAEN,6BAAgB;EACxBO,KAAK,EAAEP,4BAAe;EACtBQ,QAAQ,EAAER,+BAAkB;EAC5BS,MAAM,EAAET,6BAAgB;EACxBU,MAAM,EAAEV,6BAAgB;EACxBW,KAAK,EAAEX,4BAAe;EACtBY,EAAE,EAAEZ,yBAAY;EAChBa,EAAE,EAAEb,yBAAY;EAChBc,EAAE,EAAEd,yBAAY;EAChBe,QAAQ,EAAEf,+BAAkB;EAC5BgB,GAAG,EAAEhB,0BAAa;EAClBiB,QAAQ,EAAEjB,+BAAkB;EAC5BkB,IAAI,EAAElB,2BAAc;EACpBmB,MAAM,EAAEnB,6BAAgB;EACxBoB,GAAG,EAAEpB,0BAAa;EAClBqB,IAAI,EAAErB,2BAAc;EACpBsB,MAAM,EAAEtB;CACT;AAED;;;;;;;AAOA;AACA,SAAgBuB,qBAAqB,CACnCC,OAAe,EACfC,KAAS,EACTC,iBAA4B;EAE5B,MAAMC,gBAAgB,GAAIH,OAAO,IAAI1B,gBAAgB,CAAC0B,OAAO,CAAC,IAAKxB,kCAAqB;EACxF2B,gBAAgB,CAACC,EAAE,GAAG,CAAC;EAEvB,OAAO5B,2BAAc,CAACyB,KAAK,EAAEE,gBAAgB,EAAED,iBAAiB,CAAC;AACnE;AATAG;AAWA;;;;;;;;AAQO,MAAMC,yBAAyB,GAAG,CAGvC;EACAC,kBAAkB;EAClBN,KAAK;EACLC;AAAiB,CAUlB,KAAI;EACH,OAAO;IACLM,IAAI,EAAE;MAAEC,KAAK,EAAER,KAAK,CAACQ,KAAK;MAAEC,SAAS,EAAET,KAAK,CAACS;IAAS,CAAE;IACxDC,OAAO,EAAEZ,qBAAqB,CAAgCQ,kBAAkB,EAAEN,KAAK,EAAE,CACvF,IAAIC,iBAAiB,IAAI,EAAE,CAAC,EAC5B,OAAO,EACP,WAAW,CACZ;GACF;AACH,CAAC;AAzBYG,iCAAyB","names":["nativeElementMap","label","properties_1","audio","video","ol","li","a","button","input","textarea","select","option","table","tr","th","td","colGroup","col","fieldset","form","iframe","img","time","dialog","getNativeElementProps","tagName","props","excludedPropNames","allowedPropNames","as","exports","getPartitionedNativeProps","primarySlotTagName","root","style","className","primary"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/getNativeElementProps.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n labelProperties,\n audioProperties,\n videoProperties,\n olProperties,\n liProperties,\n anchorProperties,\n buttonProperties,\n inputProperties,\n textAreaProperties,\n selectProperties,\n optionProperties,\n tableProperties,\n trProperties,\n thProperties,\n tdProperties,\n colGroupProperties,\n colProperties,\n fieldsetProperties,\n formProperties,\n iframeProperties,\n imgProperties,\n htmlElementProperties,\n getNativeProps,\n timeProperties,\n dialogProperties,\n} from './properties';\n\nconst nativeElementMap: Record<string, Record<string, number>> = {\n label: labelProperties,\n audio: audioProperties,\n video: videoProperties,\n ol: olProperties,\n li: liProperties,\n a: anchorProperties,\n button: buttonProperties,\n input: inputProperties,\n textarea: textAreaProperties,\n select: selectProperties,\n option: optionProperties,\n table: tableProperties,\n tr: trProperties,\n th: thProperties,\n td: tdProperties,\n colGroup: colGroupProperties,\n col: colProperties,\n fieldset: fieldsetProperties,\n form: formProperties,\n iframe: iframeProperties,\n img: imgProperties,\n time: timeProperties,\n dialog: dialogProperties,\n};\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n * @param tagName - Tag name (e.g. \"div\")\n * @param props - Props object\n * @param excludedPropNames - List of props to disallow\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(\n tagName: string,\n props: {},\n excludedPropNames?: string[],\n): TAttributes {\n const allowedPropNames = (tagName && nativeElementMap[tagName]) || htmlElementProperties;\n allowedPropNames.as = 1;\n\n return getNativeProps(props, allowedPropNames, excludedPropNames);\n}\n\n/**\n * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.\n *\n * This function is only for use with components that have a primary slot other than `root`.\n * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.\n *\n * @returns An object containing the native props for the `root` and primary slots.\n */\nexport const getPartitionedNativeProps = <\n Props extends Pick<React.HTMLAttributes<HTMLElement>, 'style' | 'className'>,\n ExcludedPropKeys extends Extract<keyof Props, string> = never\n>({\n primarySlotTagName,\n props,\n excludedPropNames,\n}: {\n /** The primary slot's element type (e.g. 'div') */\n primarySlotTagName: keyof JSX.IntrinsicElements;\n\n /** The component's props object */\n props: Props;\n\n /** List of native props to exclude from the returned value */\n excludedPropNames?: ExcludedPropKeys[];\n}) => {\n return {\n root: { style: props.style, className: props.className },\n primary: getNativeElementProps<Omit<Props, ExcludedPropKeys>>(primarySlotTagName, props, [\n ...(excludedPropNames || []),\n 'style',\n 'className',\n ]),\n };\n};\n"]}
|
@@ -8,7 +8,6 @@ exports.getRTLSafeKey = void 0;
|
|
8
8
|
* @internal
|
9
9
|
* Finds and swaps a provided key for it's right to left format.
|
10
10
|
*/
|
11
|
-
|
12
11
|
const getRTLSafeKey = (key, dir) => {
|
13
12
|
if (dir === 'rtl') {
|
14
13
|
switch (key) {
|
@@ -16,16 +15,13 @@ const getRTLSafeKey = (key, dir) => {
|
|
16
15
|
{
|
17
16
|
return 'ArrowRight';
|
18
17
|
}
|
19
|
-
|
20
18
|
case 'ArrowRight':
|
21
19
|
{
|
22
20
|
return 'ArrowLeft';
|
23
21
|
}
|
24
22
|
}
|
25
23
|
}
|
26
|
-
|
27
24
|
return key;
|
28
25
|
};
|
29
|
-
|
30
26
|
exports.getRTLSafeKey = getRTLSafeKey;
|
31
27
|
//# sourceMappingURL=getRTLSafeKey.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;;;;AAIO,MAAMA,aAAa,GAAG,CAACC,GAAW,EAAEC,GAAkB,KAAI;EAC/D,IAAIA,GAAG,KAAK,KAAK,EAAE;IACjB,QAAQD,GAAG;MACT,KAAK,WAAW;QAAE;UAChB,OAAO,YAAY;;MAGrB,KAAK,YAAY;QAAE;UACjB,OAAO,WAAW;;IACnB;;EAIL,OAAOA,GAAG;AACZ,CAAC;AAdYE,qBAAa","names":["getRTLSafeKey","key","dir","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/getRTLSafeKey.ts"],"sourcesContent":["/**\n * @internal\n * Finds and swaps a provided key for it's right to left format.\n */\nexport const getRTLSafeKey = (key: string, dir: 'ltr' | 'rtl') => {\n if (dir === 'rtl') {\n switch (key) {\n case 'ArrowLeft': {\n return 'ArrowRight';\n }\n\n case 'ArrowRight': {\n return 'ArrowLeft';\n }\n }\n }\n\n return key;\n};\n"]}
|
@@ -11,25 +11,20 @@ exports.getReactCallbackName = void 0;
|
|
11
11
|
* ".eventPhase" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events
|
12
12
|
* are handled in bubble phase.
|
13
13
|
*/
|
14
|
-
|
15
14
|
function getReactCallbackName(event) {
|
16
15
|
if (event._reactName) {
|
17
16
|
return event._reactName;
|
18
17
|
}
|
19
|
-
|
20
18
|
if (event.dispatchConfig) {
|
21
19
|
if (event.dispatchConfig.registrationName) {
|
22
20
|
return event.dispatchConfig.registrationName;
|
23
21
|
}
|
24
|
-
|
25
22
|
return event.dispatchConfig.phasedRegistrationNames.bubbled;
|
26
23
|
}
|
27
|
-
|
28
24
|
if (process.env.NODE_ENV !== 'production') {
|
29
25
|
// eslint-disable-next-line no-console
|
30
26
|
console.error(['Passed React.SyntheticEvent does not contain ".dispatchConfig" or "._reactName".', 'This should not happen, please report it to https://github.com/microsoft/fluentui']);
|
31
27
|
}
|
32
28
|
}
|
33
|
-
|
34
29
|
exports.getReactCallbackName = getReactCallbackName;
|
35
30
|
//# sourceMappingURL=getReactCallbackName.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAwBA;;;;;;;AAOA,SAAgBA,oBAAoB,CAACC,KAA0B;EAC7D,IAAIA,KAAK,CAACC,UAAU,EAAE;IACpB,OAAOD,KAAK,CAACC,UAA+B;;EAG9C,IAAID,KAAK,CAACE,cAAc,EAAE;IACxB,IAAIF,KAAK,CAACE,cAAc,CAACC,gBAAgB,EAAE;MACzC,OAAOH,KAAK,CAACE,cAAc,CAACC,gBAAqC;;IAGnE,OAAOH,KAAK,CAACE,cAAc,CAACE,uBAAuB,CAACC,OAA4B;;EAGlF,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC;IACAC,OAAO,CAACC,KAAK,CAAC,CACZ,kFAAkF,EAClF,mFAAmF,CACpF,CAAC;;AAEN;AApBAC","names":["getReactCallbackName","event","_reactName","dispatchConfig","registrationName","phasedRegistrationNames","bubbled","process","env","NODE_ENV","console","error","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/getReactCallbackName.ts"],"sourcesContent":["import * as React from 'react';\n\ninterface ReactSyntheticEvent extends React.SyntheticEvent<unknown> {\n // React 17/18\n // See https://github.com/facebook/react/pull/19236\n _reactName?: string;\n\n // React 16\n dispatchConfig?: {\n registrationName: string;\n phasedRegistrationNames: {\n bubbled: string;\n captured: string;\n };\n };\n}\n\ntype NonUndefined<A> = A extends undefined ? never : A;\ntype FunctionKeys<T extends object> = {\n [K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never;\n}[keyof T];\n\nexport type ReactCallbackName = FunctionKeys<React.DOMAttributes<unknown>>;\n\n/**\n * React.SyntheticEvent contains name of a callback that should be fired, this function returns it.\n *\n * Ideally, it should also distinguish regular and \"capture\" callbacks, but it's possible only with React 17 as\n * \".eventPhase\" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events\n * are handled in bubble phase.\n */\nexport function getReactCallbackName(event: ReactSyntheticEvent): ReactCallbackName | undefined {\n if (event._reactName) {\n return event._reactName as ReactCallbackName;\n }\n\n if (event.dispatchConfig) {\n if (event.dispatchConfig.registrationName) {\n return event.dispatchConfig.registrationName as ReactCallbackName;\n }\n\n return event.dispatchConfig.phasedRegistrationNames.bubbled as ReactCallbackName;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error([\n 'Passed React.SyntheticEvent does not contain \".dispatchConfig\" or \"._reactName\".',\n 'This should not happen, please report it to https://github.com/microsoft/fluentui',\n ]);\n }\n}\n"]}
|
@@ -3,20 +3,13 @@
|
|
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("./clamp"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./getNativeElementProps"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./getRTLSafeKey"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./mergeCallbacks"), exports);
|
16
|
-
|
17
11
|
tslib_1.__exportStar(require("./omit"), exports);
|
18
|
-
|
19
12
|
tslib_1.__exportStar(require("./properties"), exports);
|
20
|
-
|
21
|
-
tslib_1.__exportStar(require("./
|
13
|
+
tslib_1.__exportStar(require("./isHTMLElement"), exports);
|
14
|
+
tslib_1.__exportStar(require("./isInteractiveHTMLElement"), exports);
|
22
15
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-utilities/src/utils/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-utilities/src/utils/index.ts"],"sourcesContent":["export * from './clamp';\nexport * from './getNativeElementProps';\nexport * from './getRTLSafeKey';\nexport * from './mergeCallbacks';\nexport * from './omit';\nexport * from './properties';\nexport * from './isHTMLElement';\nexport * from './isInteractiveHTMLElement';\n"]}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.isHTMLElement = void 0;
|
7
|
+
/**
|
8
|
+
* @internal
|
9
|
+
* Verifies if a given node is an HTMLElement,
|
10
|
+
* this method works seamlessly with frames and elements from different documents
|
11
|
+
*
|
12
|
+
* This is required as simply using `instanceof`
|
13
|
+
* might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
|
14
|
+
*
|
15
|
+
*/
|
16
|
+
function isHTMLElement(element) {
|
17
|
+
var _a;
|
18
|
+
const typedElement = element;
|
19
|
+
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);
|
20
|
+
}
|
21
|
+
exports.isHTMLElement = isHTMLElement;
|
22
|
+
//# sourceMappingURL=isHTMLElement.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;;;;;;;;;AASA,SAAgBA,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;AAPAC","names":["isHTMLElement","element","typedElement","Boolean","ownerDocument","defaultView","HTMLElement","exports"],"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"]}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.isInteractiveHTMLElement = void 0;
|
7
|
+
const isHTMLElement_1 = /*#__PURE__*/require("./isHTMLElement");
|
8
|
+
/**
|
9
|
+
* @internal
|
10
|
+
* Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys
|
11
|
+
*/
|
12
|
+
function isInteractiveHTMLElement(element) {
|
13
|
+
if (!isHTMLElement_1.isHTMLElement(element)) {
|
14
|
+
return false;
|
15
|
+
}
|
16
|
+
const {
|
17
|
+
tagName
|
18
|
+
} = element;
|
19
|
+
switch (tagName) {
|
20
|
+
case 'BUTTON':
|
21
|
+
case 'A':
|
22
|
+
case 'INPUT':
|
23
|
+
case 'TEXTAREA':
|
24
|
+
return true;
|
25
|
+
}
|
26
|
+
return element.isContentEditable;
|
27
|
+
}
|
28
|
+
exports.isInteractiveHTMLElement = isInteractiveHTMLElement;
|
29
|
+
//# sourceMappingURL=isInteractiveHTMLElement.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;;;;AAIA,SAAgBA,wBAAwB,CAACC,OAAgB;EACvD,IAAI,CAACC,6BAAa,CAACD,OAAO,CAAC,EAAE;IAC3B,OAAO,KAAK;;EAGd,MAAM;IAAEE;EAAO,CAAE,GAAGF,OAAO;EAC3B,QAAQE,OAAO;IACb,KAAK,QAAQ;IACb,KAAK,GAAG;IACR,KAAK,OAAO;IACZ,KAAK,UAAU;MACb,OAAO,IAAI;EAAC;EAGhB,OAAOF,OAAO,CAACG,iBAAiB;AAClC;AAfAC","names":["isInteractiveHTMLElement","element","isHTMLElement_1","tagName","isContentEditable","exports"],"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"]}
|
@@ -27,13 +27,11 @@ exports.mergeCallbacks = void 0;
|
|
27
27
|
*
|
28
28
|
* @returns A function that that calls the provided functions in order
|
29
29
|
*/
|
30
|
-
|
31
30
|
function mergeCallbacks(callback1, callback2) {
|
32
31
|
return (...args) => {
|
33
32
|
callback1 === null || callback1 === void 0 ? void 0 : callback1(...args);
|
34
33
|
callback2 === null || callback2 === void 0 ? void 0 : callback2(...args);
|
35
34
|
};
|
36
35
|
}
|
37
|
-
|
38
36
|
exports.mergeCallbacks = mergeCallbacks;
|
39
37
|
//# sourceMappingURL=mergeCallbacks.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgBA,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;AARAC","names":["mergeCallbacks","callback1","callback2","args","exports"],"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"]}
|
@@ -18,19 +18,15 @@ exports.omit = void 0;
|
|
18
18
|
* @param exclusions - The array of keys to exclude
|
19
19
|
*/
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
21
|
-
|
22
21
|
function omit(obj, exclusions) {
|
23
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
24
23
|
const result = {};
|
25
|
-
|
26
24
|
for (const key in obj) {
|
27
25
|
if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {
|
28
26
|
result[key] = obj[key];
|
29
27
|
}
|
30
28
|
}
|
31
|
-
|
32
29
|
return result;
|
33
30
|
}
|
34
|
-
|
35
31
|
exports.omit = omit;
|
36
32
|
//# sourceMappingURL=omit.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;;;;;;;;;;;;;AAaA;AACA,SAAgBA,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;AAdAI","names":["omit","obj","exclusions","result","key","indexOf","hasOwnProperty","exports"],"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"]}
|