@fluentui/react-utilities 9.2.0 → 9.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +45 -1
- package/CHANGELOG.md +21 -2
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/isResolvedShorthand.js.map +1 -1
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/compose/types.js.map +1 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.js.map +1 -1
- package/lib/hooks/useForceUpdate.js.map +1 -1
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/ssr/index.js.map +1 -1
- package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/trigger/getTriggerChild.js.map +1 -1
- package/lib/trigger/index.js.map +1 -1
- package/lib/trigger/isFluentTrigger.js.map +1 -1
- package/lib/trigger/types.js.map +1 -1
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeCallbacks.js.map +1 -1
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/properties.js +1 -1
- package/lib/utils/properties.js.map +1 -1
- package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
- package/lib-amd/compose/getSlots.js +58 -0
- package/lib-amd/compose/getSlots.js.map +1 -0
- package/lib-amd/compose/index.js +9 -0
- package/lib-amd/compose/index.js.map +1 -0
- package/lib-amd/compose/isResolvedShorthand.js +40 -0
- package/lib-amd/compose/isResolvedShorthand.js.map +1 -0
- package/lib-amd/compose/resolveShorthand.js +27 -0
- package/lib-amd/compose/resolveShorthand.js.map +1 -0
- package/lib-amd/compose/types.js +5 -0
- package/lib-amd/compose/types.js.map +1 -0
- package/lib-amd/hooks/index.js +16 -0
- package/lib-amd/hooks/index.js.map +1 -0
- package/lib-amd/hooks/useControllableState.js +81 -0
- package/lib-amd/hooks/useControllableState.js.map +1 -0
- package/lib-amd/hooks/useEventCallback.js +36 -0
- package/lib-amd/hooks/useEventCallback.js.map +1 -0
- package/lib-amd/hooks/useFirstMount.js +26 -0
- package/lib-amd/hooks/useFirstMount.js.map +1 -0
- package/lib-amd/hooks/useForceUpdate.js +14 -0
- package/lib-amd/hooks/useForceUpdate.js.map +1 -0
- package/lib-amd/hooks/useId.js +32 -0
- package/lib-amd/hooks/useId.js.map +1 -0
- package/lib-amd/hooks/useIsomorphicLayoutEffect.js +17 -0
- package/lib-amd/hooks/useIsomorphicLayoutEffect.js.map +1 -0
- package/lib-amd/hooks/useMergedRefs.js +34 -0
- package/lib-amd/hooks/useMergedRefs.js.map +1 -0
- package/lib-amd/hooks/useOnClickOutside.js +116 -0
- package/lib-amd/hooks/useOnClickOutside.js.map +1 -0
- package/lib-amd/hooks/useOnScrollOutside.js +31 -0
- package/lib-amd/hooks/useOnScrollOutside.js.map +1 -0
- package/lib-amd/hooks/usePrevious.js +17 -0
- package/lib-amd/hooks/usePrevious.js.map +1 -0
- package/lib-amd/hooks/useTimeout.js +33 -0
- package/lib-amd/hooks/useTimeout.js.map +1 -0
- package/lib-amd/index.js +33 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/ssr/SSRContext.js +69 -0
- package/lib-amd/ssr/SSRContext.js.map +1 -0
- package/lib-amd/ssr/canUseDOM.js +16 -0
- package/lib-amd/ssr/canUseDOM.js.map +1 -0
- package/lib-amd/ssr/index.js +7 -0
- package/lib-amd/ssr/index.js.map +1 -0
- package/lib-amd/trigger/applyTriggerPropsToChildren.js +40 -0
- package/lib-amd/trigger/applyTriggerPropsToChildren.js.map +1 -0
- package/lib-amd/trigger/getTriggerChild.js +40 -0
- package/lib-amd/trigger/getTriggerChild.js.map +1 -0
- package/lib-amd/trigger/index.js +9 -0
- package/lib-amd/trigger/index.js.map +1 -0
- package/lib-amd/trigger/isFluentTrigger.js +15 -0
- package/lib-amd/trigger/isFluentTrigger.js.map +1 -0
- package/lib-amd/trigger/types.js +5 -0
- package/lib-amd/trigger/types.js.map +1 -0
- package/lib-amd/utils/clamp.js +16 -0
- package/lib-amd/utils/clamp.js.map +1 -0
- package/lib-amd/utils/getNativeElementProps.js +64 -0
- package/lib-amd/utils/getNativeElementProps.js.map +1 -0
- package/lib-amd/utils/getRTLSafeKey.js +24 -0
- package/lib-amd/utils/getRTLSafeKey.js.map +1 -0
- package/lib-amd/utils/index.js +12 -0
- package/lib-amd/utils/index.js.map +1 -0
- package/lib-amd/utils/mergeCallbacks.js +40 -0
- package/lib-amd/utils/mergeCallbacks.js.map +1 -0
- package/lib-amd/utils/omit.js +31 -0
- package/lib-amd/utils/omit.js.map +1 -0
- package/lib-amd/utils/properties.js +450 -0
- package/lib-amd/utils/properties.js.map +1 -0
- package/lib-amd/utils/shouldPreventDefaultOnKeyDown.js +26 -0
- package/lib-amd/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
- package/lib-commonjs/ssr/index.js.map +1 -1
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
- package/lib-commonjs/trigger/index.js.map +1 -1
- package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/properties.js +1 -1
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
- package/package.json +8 -8
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/trigger/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Allows a component to be tagged as a FluentUI trigger component.\n *\n * Triggers are special-case components: they attach event listeners and other props on their child,\n * and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.\n *\n * A component can be tagged as a trigger as follows:\n * ```ts\n * const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;\n *\n * MyComponent.isFluentTriggerComponent = true; // MUST also set this to true\n * ```\n */\nexport type FluentTriggerComponent = {\n isFluentTriggerComponent?: boolean;\n};\n\n/**\n * A trigger may have a children that could be either:\n * 1. A single element\n * 2. A render function that will receive properties and must return a valid element or null\n * 3. null or undefined\n */\nexport type TriggerProps<TriggerChildProps = unknown> = {\n children?: React.ReactElement | ((props: TriggerChildProps) => React.ReactElement | null) | null;\n};\n"]}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.clamp = void 0;
|
5
|
+
/**
|
6
|
+
* @internal
|
7
|
+
* Clamps `value` to a number between the min and max.
|
8
|
+
*
|
9
|
+
* @param value - the value to be clamped
|
10
|
+
* @param min - the lowest valid value
|
11
|
+
* @param max - the highest valid value
|
12
|
+
*/
|
13
|
+
var clamp = function (value, min, max) { return Math.max(min, Math.min(max, value || 0)); };
|
14
|
+
exports.clamp = clamp;
|
15
|
+
});
|
16
|
+
//# sourceMappingURL=clamp.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/clamp.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;OAOG;IACI,IAAM,KAAK,GAAG,UAAC,KAAa,EAAE,GAAW,EAAE,GAAW,IAAa,OAAA,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,EAAxC,CAAwC,CAAC;IAAtG,QAAA,KAAK,SAAiG","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"]}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
define(["require", "exports", "tslib", "./properties"], function (require, exports, tslib_1, properties_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.getPartitionedNativeProps = exports.getNativeElementProps = void 0;
|
5
|
+
var nativeElementMap = {
|
6
|
+
label: properties_1.labelProperties,
|
7
|
+
audio: properties_1.audioProperties,
|
8
|
+
video: properties_1.videoProperties,
|
9
|
+
ol: properties_1.olProperties,
|
10
|
+
li: properties_1.liProperties,
|
11
|
+
a: properties_1.anchorProperties,
|
12
|
+
button: properties_1.buttonProperties,
|
13
|
+
input: properties_1.inputProperties,
|
14
|
+
textarea: properties_1.textAreaProperties,
|
15
|
+
select: properties_1.selectProperties,
|
16
|
+
option: properties_1.optionProperties,
|
17
|
+
table: properties_1.tableProperties,
|
18
|
+
tr: properties_1.trProperties,
|
19
|
+
th: properties_1.thProperties,
|
20
|
+
td: properties_1.tdProperties,
|
21
|
+
colGroup: properties_1.colGroupProperties,
|
22
|
+
col: properties_1.colProperties,
|
23
|
+
fieldset: properties_1.fieldsetProperties,
|
24
|
+
form: properties_1.formProperties,
|
25
|
+
iframe: properties_1.iframeProperties,
|
26
|
+
img: properties_1.imgProperties,
|
27
|
+
time: properties_1.timeProperties,
|
28
|
+
dialog: properties_1.dialogProperties,
|
29
|
+
};
|
30
|
+
/**
|
31
|
+
* Given an element tagname and user props, filters the props to only allowed props for the given
|
32
|
+
* element type.
|
33
|
+
* @param tagName - Tag name (e.g. "div")
|
34
|
+
* @param props - Props object
|
35
|
+
* @param excludedPropNames - List of props to disallow
|
36
|
+
*/
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
38
|
+
function getNativeElementProps(tagName, props, excludedPropNames) {
|
39
|
+
var allowedPropNames = (tagName && nativeElementMap[tagName]) || properties_1.htmlElementProperties;
|
40
|
+
allowedPropNames.as = 1;
|
41
|
+
return properties_1.getNativeProps(props, allowedPropNames, excludedPropNames);
|
42
|
+
}
|
43
|
+
exports.getNativeElementProps = getNativeElementProps;
|
44
|
+
/**
|
45
|
+
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
46
|
+
*
|
47
|
+
* This function is only for use with components that have a primary slot other than `root`.
|
48
|
+
* Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
|
49
|
+
*
|
50
|
+
* @returns An object containing the native props for the `root` and primary slots.
|
51
|
+
*/
|
52
|
+
var getPartitionedNativeProps = function (_a) {
|
53
|
+
var primarySlotTagName = _a.primarySlotTagName, props = _a.props, excludedPropNames = _a.excludedPropNames;
|
54
|
+
return {
|
55
|
+
root: { style: props.style, className: props.className },
|
56
|
+
primary: getNativeElementProps(primarySlotTagName, props, tslib_1.__spreadArray(tslib_1.__spreadArray([], (excludedPropNames || [])), [
|
57
|
+
'style',
|
58
|
+
'className',
|
59
|
+
])),
|
60
|
+
};
|
61
|
+
};
|
62
|
+
exports.getPartitionedNativeProps = getPartitionedNativeProps;
|
63
|
+
});
|
64
|
+
//# sourceMappingURL=getNativeElementProps.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getNativeElementProps.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/getNativeElementProps.ts"],"names":[],"mappings":";;;;IA6BA,IAAM,gBAAgB,GAA2C;QAC/D,KAAK,EAAE,4BAAe;QACtB,KAAK,EAAE,4BAAe;QACtB,KAAK,EAAE,4BAAe;QACtB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,CAAC,EAAE,6BAAgB;QACnB,MAAM,EAAE,6BAAgB;QACxB,KAAK,EAAE,4BAAe;QACtB,QAAQ,EAAE,+BAAkB;QAC5B,MAAM,EAAE,6BAAgB;QACxB,MAAM,EAAE,6BAAgB;QACxB,KAAK,EAAE,4BAAe;QACtB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,EAAE,EAAE,yBAAY;QAChB,QAAQ,EAAE,+BAAkB;QAC5B,GAAG,EAAE,0BAAa;QAClB,QAAQ,EAAE,+BAAkB;QAC5B,IAAI,EAAE,2BAAc;QACpB,MAAM,EAAE,6BAAgB;QACxB,GAAG,EAAE,0BAAa;QAClB,IAAI,EAAE,2BAAc;QACpB,MAAM,EAAE,6BAAgB;KACzB,CAAC;IAEF;;;;;;OAMG;IACH,8DAA8D;IAC9D,SAAgB,qBAAqB,CACnC,OAAe,EACf,KAAS,EACT,iBAA4B;QAE5B,IAAM,gBAAgB,GAAG,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,kCAAqB,CAAC;QACzF,gBAAgB,CAAC,EAAE,GAAG,CAAC,CAAC;QAExB,OAAO,2BAAc,CAAC,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IACpE,CAAC;IATD,sDASC;IAED;;;;;;;OAOG;IACI,IAAM,yBAAyB,GAAG,UAGvC,EAaD;YAZC,kBAAkB,wBAAA,EAClB,KAAK,WAAA,EACL,iBAAiB,uBAAA;QAWjB,OAAO;YACL,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;YACxD,OAAO,EAAE,qBAAqB,CAAgC,kBAAkB,EAAE,KAAK,kDAClF,CAAC,iBAAiB,IAAI,EAAE,CAAC;gBAC5B,OAAO;gBACP,WAAW;eACX;SACH,CAAC;IACJ,CAAC,CAAC;IAzBW,QAAA,yBAAyB,6BAyBpC","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"]}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.getRTLSafeKey = void 0;
|
5
|
+
/**
|
6
|
+
* @internal
|
7
|
+
* Finds and swaps a provided key for it's right to left format.
|
8
|
+
*/
|
9
|
+
var getRTLSafeKey = function (key, dir) {
|
10
|
+
if (dir === 'rtl') {
|
11
|
+
switch (key) {
|
12
|
+
case 'ArrowLeft': {
|
13
|
+
return 'ArrowRight';
|
14
|
+
}
|
15
|
+
case 'ArrowRight': {
|
16
|
+
return 'ArrowLeft';
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return key;
|
21
|
+
};
|
22
|
+
exports.getRTLSafeKey = getRTLSafeKey;
|
23
|
+
});
|
24
|
+
//# sourceMappingURL=getRTLSafeKey.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getRTLSafeKey.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/getRTLSafeKey.ts"],"names":[],"mappings":";;;;IAAA;;;OAGG;IACI,IAAM,aAAa,GAAG,UAAC,GAAW,EAAE,GAAkB;QAC3D,IAAI,GAAG,KAAK,KAAK,EAAE;YACjB,QAAQ,GAAG,EAAE;gBACX,KAAK,WAAW,CAAC,CAAC;oBAChB,OAAO,YAAY,CAAC;iBACrB;gBAED,KAAK,YAAY,CAAC,CAAC;oBACjB,OAAO,WAAW,CAAC;iBACpB;aACF;SACF;QAED,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;IAdW,QAAA,aAAa,iBAcxB","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"]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
define(["require", "exports", "tslib", "./clamp", "./getNativeElementProps", "./getRTLSafeKey", "./mergeCallbacks", "./omit", "./properties", "./shouldPreventDefaultOnKeyDown"], function (require, exports, tslib_1, clamp_1, getNativeElementProps_1, getRTLSafeKey_1, mergeCallbacks_1, omit_1, properties_1, shouldPreventDefaultOnKeyDown_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
tslib_1.__exportStar(clamp_1, exports);
|
5
|
+
tslib_1.__exportStar(getNativeElementProps_1, exports);
|
6
|
+
tslib_1.__exportStar(getRTLSafeKey_1, exports);
|
7
|
+
tslib_1.__exportStar(mergeCallbacks_1, exports);
|
8
|
+
tslib_1.__exportStar(omit_1, exports);
|
9
|
+
tslib_1.__exportStar(properties_1, exports);
|
10
|
+
tslib_1.__exportStar(shouldPreventDefaultOnKeyDown_1, exports);
|
11
|
+
});
|
12
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/index.ts"],"names":[],"mappings":";;;IAAA,uCAAwB;IACxB,uDAAwC;IACxC,+CAAgC;IAChC,gDAAiC;IACjC,sCAAuB;IACvB,4CAA6B;IAC7B,+DAAgD","sourcesContent":["export * from './clamp';\nexport * from './getNativeElementProps';\nexport * from './getRTLSafeKey';\nexport * from './mergeCallbacks';\nexport * from './omit';\nexport * from './properties';\nexport * from './shouldPreventDefaultOnKeyDown';\n"]}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.mergeCallbacks = void 0;
|
5
|
+
/**
|
6
|
+
* @internal
|
7
|
+
* Combine two event callbacks into a single callback function that calls each one in order.
|
8
|
+
*
|
9
|
+
* Usage example:
|
10
|
+
* ```ts
|
11
|
+
* state.slot.onChange = mergeCallbacks(state.slot.onChange, ev => {
|
12
|
+
* // Handle onChange
|
13
|
+
* });
|
14
|
+
* ```
|
15
|
+
*
|
16
|
+
* The primary use is to avoid the need to capture an existing callback (`state.slot.onChange` in the example) to a
|
17
|
+
* local variable before replacing with a new listener that calls the existing one. This helps avoid bugs like:
|
18
|
+
* * Infinite recursion by calling the re-assigned state.slot.onChange if it's not captured to a local variable.
|
19
|
+
* * Missing a call to the original onChange due to an early return or other conditional.
|
20
|
+
*
|
21
|
+
* If you need a callback that is stable between renders, wrap the result in {@link useEventCallback}.
|
22
|
+
*
|
23
|
+
* @param callback1 - The first callback to be called, or undefined
|
24
|
+
* @param callback2 - The second callback to be called, or undefined
|
25
|
+
*
|
26
|
+
* @returns A function that that calls the provided functions in order
|
27
|
+
*/
|
28
|
+
function mergeCallbacks(callback1, callback2) {
|
29
|
+
return function () {
|
30
|
+
var args = [];
|
31
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
32
|
+
args[_i] = arguments[_i];
|
33
|
+
}
|
34
|
+
callback1 === null || callback1 === void 0 ? void 0 : callback1.apply(void 0, args);
|
35
|
+
callback2 === null || callback2 === void 0 ? void 0 : callback2.apply(void 0, args);
|
36
|
+
};
|
37
|
+
}
|
38
|
+
exports.mergeCallbacks = mergeCallbacks;
|
39
|
+
});
|
40
|
+
//# sourceMappingURL=mergeCallbacks.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mergeCallbacks.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/mergeCallbacks.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAgB,cAAc,CAC5B,SAAgD,EAChD,SAAgD;QAEhD,OAAO;YAAC,cAAa;iBAAb,UAAa,EAAb,qBAAa,EAAb,IAAa;gBAAb,yBAAa;;YACnB,SAAS,aAAT,SAAS,uBAAT,SAAS,eAAM,IAAI,CAAC,CAAC;YACrB,SAAS,aAAT,SAAS,uBAAT,SAAS,eAAM,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC;IARD,wCAQC","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"]}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.omit = void 0;
|
5
|
+
/**
|
6
|
+
* Tiny helper to do the minimal amount of work in duplicating an object but omitting some
|
7
|
+
* props. This ends up faster than using object ...rest or reduce to filter.
|
8
|
+
*
|
9
|
+
* This behaves very much like filteredAssign, but does not merge many objects together,
|
10
|
+
* uses an exclusion object map, and avoids spreads all for optimal performance.
|
11
|
+
*
|
12
|
+
* See perf test for background:
|
13
|
+
* https://jsperf.com/omit-vs-rest-vs-reduce/1
|
14
|
+
*
|
15
|
+
* @param obj - The object to clone
|
16
|
+
* @param exclusions - The array of keys to exclude
|
17
|
+
*/
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
19
|
+
function omit(obj, exclusions) {
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
21
|
+
var result = {};
|
22
|
+
for (var key in obj) {
|
23
|
+
if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {
|
24
|
+
result[key] = obj[key];
|
25
|
+
}
|
26
|
+
}
|
27
|
+
return result;
|
28
|
+
}
|
29
|
+
exports.omit = omit;
|
30
|
+
});
|
31
|
+
//# sourceMappingURL=omit.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"omit.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/utils/omit.ts"],"names":[],"mappings":";;;;IAAA;;;;;;;;;;;;OAYG;IACH,8DAA8D;IAC9D,SAAgB,IAAI,CAClB,GAAS,EACT,UAAsB;QAEtB,8DAA8D;QAC9D,IAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,KAAK,IAAM,GAAG,IAAI,GAAG,EAAE;YACrB,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBAC7D,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;aACxB;SACF;QAED,OAAO,MAAc,CAAC;IACxB,CAAC;IAdD,oBAcC","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"]}
|