@fluentui/react-utilities 0.0.0-nightlyf1be0a972820211214.1 → 0.0.0-nightlyf3017f159620220222.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 +120 -6
- package/CHANGELOG.md +35 -6
- package/dist/react-utilities.d.ts +193 -78
- package/lib/compose/getSlots.d.ts +7 -8
- package/lib/compose/getSlots.js +3 -4
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/index.d.ts +0 -1
- package/lib/compose/index.js +0 -1
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/resolveShorthand.d.ts +10 -6
- package/lib/compose/resolveShorthand.js +5 -5
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/compose/types.d.ts +86 -34
- package/lib/compose/types.js.map +1 -1
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useBoolean.js.map +1 -1
- package/lib/hooks/useConst.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/useMergedEventCallbacks.d.ts +18 -0
- package/lib/hooks/useMergedEventCallbacks.js +26 -0
- package/lib/hooks/useMergedEventCallbacks.js.map +1 -0
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useMount.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/hooks/useUnmount.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/utils/applyTriggerPropsToChildren.d.ts +1 -1
- package/lib/utils/applyTriggerPropsToChildren.js +23 -3
- package/lib/utils/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getNativeElementProps.d.ts +4 -4
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.d.ts +25 -0
- package/lib/utils/getReactCallbackName.js +26 -0
- package/lib/utils/getReactCallbackName.js.map +1 -0
- package/lib/utils/getTriggerChild.d.ts +22 -0
- package/lib/utils/getTriggerChild.js +26 -0
- package/lib/utils/getTriggerChild.js.map +1 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +2 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isFluentTrigger.d.ts +22 -0
- package/lib/utils/isFluentTrigger.js +8 -0
- package/lib/utils/isFluentTrigger.js.map +1 -0
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/properties.js.map +1 -1
- package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
- package/lib-commonjs/compose/getSlots.d.ts +7 -8
- package/lib-commonjs/compose/getSlots.js +3 -5
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/index.d.ts +0 -1
- package/lib-commonjs/compose/index.js +0 -2
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.d.ts +10 -6
- package/lib-commonjs/compose/resolveShorthand.js +5 -5
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/types.d.ts +86 -34
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/hooks/index.d.ts +1 -0
- package/lib-commonjs/hooks/index.js +2 -0
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useBoolean.js.map +1 -1
- package/lib-commonjs/hooks/useConst.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/useMergedEventCallbacks.d.ts +18 -0
- package/lib-commonjs/hooks/useMergedEventCallbacks.js +36 -0
- package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -0
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useMount.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/hooks/useUnmount.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/utils/applyTriggerPropsToChildren.d.ts +1 -1
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js +24 -4
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.d.ts +4 -4
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.d.ts +25 -0
- package/lib-commonjs/utils/getReactCallbackName.js +35 -0
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -0
- package/lib-commonjs/utils/getTriggerChild.d.ts +22 -0
- package/lib-commonjs/utils/getTriggerChild.js +37 -0
- package/lib-commonjs/utils/getTriggerChild.js.map +1 -0
- package/lib-commonjs/utils/index.d.ts +2 -1
- package/lib-commonjs/utils/index.js +4 -2
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isFluentTrigger.d.ts +22 -0
- package/lib-commonjs/utils/isFluentTrigger.js +17 -0
- package/lib-commonjs/utils/isFluentTrigger.js.map +1 -0
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -1
- package/package.json +3 -7
- package/lib/compose/nullRender.d.ts +0 -4
- package/lib/compose/nullRender.js +0 -5
- package/lib/compose/nullRender.js.map +0 -1
- package/lib/utils/onlyChild.d.ts +0 -5
- package/lib/utils/onlyChild.js +0 -13
- package/lib/utils/onlyChild.js.map +0 -1
- package/lib-commonjs/compose/nullRender.d.ts +0 -4
- package/lib-commonjs/compose/nullRender.js +0 -14
- package/lib-commonjs/compose/nullRender.js.map +0 -1
- package/lib-commonjs/utils/onlyChild.d.ts +0 -5
- package/lib-commonjs/utils/onlyChild.js +0 -23
- package/lib-commonjs/utils/onlyChild.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["utils/getNativeElementProps.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AAyBA,MAAM,gBAAgB,GAA2C;AAC/D,EAAA,KAAK,EAAE,YAAA,CAAA,eADwD;AAE/D,EAAA,KAAK,EAAE,YAAA,CAAA,eAFwD;AAG/D,EAAA,KAAK,EAAE,YAAA,CAAA,eAHwD;AAI/D,EAAA,EAAE,EAAE,YAAA,CAAA,YAJ2D;AAK/D,EAAA,EAAE,EAAE,YAAA,CAAA,YAL2D;AAM/D,EAAA,CAAC,EAAE,YAAA,CAAA,gBAN4D;AAO/D,EAAA,MAAM,EAAE,YAA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AAO,EAAE,qBAAqB,CAAgC,kBAAhC,EAAoD,KAApD,EAA2D,CACvF,IAAI,iBAAiB,IAAI,EAAzB,CADuF,EAEvF,OAFuF,EAGvF,WAHuF,CAA3D;AAFzB,GAAP;AAQD,CAzBM;;AAAM,OAAA,CAAA,yBAAA,GAAyB,yBAAzB","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 formProperties,\n iframeProperties,\n imgProperties,\n htmlElementProperties,\n getNativeProps,\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 form: formProperties,\n iframe: iframeProperties,\n img: imgProperties,\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"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["utils/getRTLSafeKey.ts"],"names":[],"mappings":";;;;;;AAAA;;AAEG;;AACI,MAAM,aAAa,GAAG,CAAC,GAAD,EAAc,GAAd,KAAoC;AAC/D,MAAI,GAAG,KAAK,KAAZ,EAAmB;AACjB,YAAQ,GAAR;AACE,WAAK,WAAL;AAAkB;AAChB,iBAAO,YAAP;AACD;;AAED,WAAK,YAAL;AAAmB;AACjB,iBAAO,WAAP;AACD;AAPH;AASD;;AAED,SAAO,GAAP;AACD,CAdM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["/**\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"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
interface ReactSyntheticEvent extends React.SyntheticEvent<unknown> {
|
3
|
+
_reactName?: string;
|
4
|
+
dispatchConfig?: {
|
5
|
+
registrationName: string;
|
6
|
+
phasedRegistrationNames: {
|
7
|
+
bubbled: string;
|
8
|
+
captured: string;
|
9
|
+
};
|
10
|
+
};
|
11
|
+
}
|
12
|
+
declare type NonUndefined<A> = A extends undefined ? never : A;
|
13
|
+
declare type FunctionKeys<T extends object> = {
|
14
|
+
[K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never;
|
15
|
+
}[keyof T];
|
16
|
+
export declare type ReactCallbackName = FunctionKeys<React.DOMAttributes<unknown>>;
|
17
|
+
/**
|
18
|
+
* React.SyntheticEvent contains name of a callback that should be fired, this function returns it.
|
19
|
+
*
|
20
|
+
* Ideally, it should also distinguish regular and "capture" callbacks, but it's possible only with React 17 as
|
21
|
+
* ".eventPhase" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events
|
22
|
+
* are handled in bubble phase.
|
23
|
+
*/
|
24
|
+
export declare function getReactCallbackName(event: ReactSyntheticEvent): ReactCallbackName | undefined;
|
25
|
+
export {};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getReactCallbackName = void 0;
|
7
|
+
/**
|
8
|
+
* React.SyntheticEvent contains name of a callback that should be fired, this function returns it.
|
9
|
+
*
|
10
|
+
* Ideally, it should also distinguish regular and "capture" callbacks, but it's possible only with React 17 as
|
11
|
+
* ".eventPhase" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events
|
12
|
+
* are handled in bubble phase.
|
13
|
+
*/
|
14
|
+
|
15
|
+
function getReactCallbackName(event) {
|
16
|
+
if (event._reactName) {
|
17
|
+
return event._reactName;
|
18
|
+
}
|
19
|
+
|
20
|
+
if (event.dispatchConfig) {
|
21
|
+
if (event.dispatchConfig.registrationName) {
|
22
|
+
return event.dispatchConfig.registrationName;
|
23
|
+
}
|
24
|
+
|
25
|
+
return event.dispatchConfig.phasedRegistrationNames.bubbled;
|
26
|
+
}
|
27
|
+
|
28
|
+
if (process.env.NODE_ENV !== 'production') {
|
29
|
+
// eslint-disable-next-line no-console
|
30
|
+
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
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
exports.getReactCallbackName = getReactCallbackName;
|
35
|
+
//# sourceMappingURL=getReactCallbackName.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["utils/getReactCallbackName.ts"],"names":[],"mappings":";;;;;;AAwBA;;;;;;AAMG;;AACH,SAAgB,oBAAhB,CAAqC,KAArC,EAA+D;AAC7D,MAAI,KAAK,CAAC,UAAV,EAAsB;AACpB,WAAO,KAAK,CAAC,UAAb;AACD;;AAED,MAAI,KAAK,CAAC,cAAV,EAA0B;AACxB,QAAI,KAAK,CAAC,cAAN,CAAqB,gBAAzB,EAA2C;AACzC,aAAO,KAAK,CAAC,cAAN,CAAqB,gBAA5B;AACD;;AAED,WAAO,KAAK,CAAC,cAAN,CAAqB,uBAArB,CAA6C,OAApD;AACD;;AAED,MAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;AACA,IAAA,OAAO,CAAC,KAAR,CAAc,CACZ,kFADY,EAEZ,mFAFY,CAAd;AAID;AACF;;AApBD,OAAA,CAAA,oBAAA,GAAA,oBAAA","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"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
/**
|
3
|
+
* Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).
|
4
|
+
*
|
5
|
+
* In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,
|
6
|
+
* it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.
|
7
|
+
* This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.
|
8
|
+
*
|
9
|
+
* For example, the following returns `<div id="child" />`:
|
10
|
+
* ```jsx
|
11
|
+
* getTriggerChild(
|
12
|
+
* <Tooltip>
|
13
|
+
* <MenuTrigger>
|
14
|
+
* <div id="child" />
|
15
|
+
* </MenuTrigger>
|
16
|
+
* </Tooltip>
|
17
|
+
* );
|
18
|
+
* ```
|
19
|
+
*/
|
20
|
+
export declare const getTriggerChild: (children: React.ReactNode) => React.ReactElement & {
|
21
|
+
ref?: React.Ref<unknown>;
|
22
|
+
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getTriggerChild = void 0;
|
7
|
+
|
8
|
+
const React = /*#__PURE__*/require("react");
|
9
|
+
|
10
|
+
const isFluentTrigger_1 = /*#__PURE__*/require("./isFluentTrigger");
|
11
|
+
/**
|
12
|
+
* Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).
|
13
|
+
*
|
14
|
+
* In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,
|
15
|
+
* it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.
|
16
|
+
* This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.
|
17
|
+
*
|
18
|
+
* For example, the following returns `<div id="child" />`:
|
19
|
+
* ```jsx
|
20
|
+
* getTriggerChild(
|
21
|
+
* <Tooltip>
|
22
|
+
* <MenuTrigger>
|
23
|
+
* <div id="child" />
|
24
|
+
* </MenuTrigger>
|
25
|
+
* </Tooltip>
|
26
|
+
* );
|
27
|
+
* ```
|
28
|
+
*/
|
29
|
+
|
30
|
+
|
31
|
+
const getTriggerChild = children => {
|
32
|
+
const child = React.Children.only(children);
|
33
|
+
return isFluentTrigger_1.isFluentTrigger(child) ? exports.getTriggerChild(child.props.children) : child;
|
34
|
+
};
|
35
|
+
|
36
|
+
exports.getTriggerChild = getTriggerChild;
|
37
|
+
//# sourceMappingURL=getTriggerChild.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["utils/getTriggerChild.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAEA;;;;;;;;;;;;;;;;;AAiBG;;;AACI,MAAM,eAAe,GAAI,QAAD,IAAiF;AAC9G,QAAM,KAAK,GAAG,KAAK,CAAC,QAAN,CAAe,IAAf,CAAoB,QAApB,CAAd;AACA,SAAO,iBAAA,CAAA,eAAA,CAAgB,KAAhB,IAAyB,OAAA,CAAA,eAAA,CAAgB,KAAK,CAAC,KAAN,CAAY,QAA5B,CAAzB,GAAiE,KAAxE;AACD,CAHM;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\n\n/**\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 */\nexport const getTriggerChild = (children: React.ReactNode): React.ReactElement & { ref?: React.Ref<unknown> } => {\n const child = React.Children.only(children) as React.ReactElement;\n return isFluentTrigger(child) ? getTriggerChild(child.props.children) : child;\n};\n"],"sourceRoot":"../src/"}
|
@@ -2,7 +2,8 @@ export * from './applyTriggerPropsToChildren';
|
|
2
2
|
export * from './clamp';
|
3
3
|
export * from './getNativeElementProps';
|
4
4
|
export * from './getRTLSafeKey';
|
5
|
+
export * from './getTriggerChild';
|
6
|
+
export * from './isFluentTrigger';
|
5
7
|
export * from './omit';
|
6
|
-
export * from './onlyChild';
|
7
8
|
export * from './properties';
|
8
9
|
export * from './shouldPreventDefaultOnKeyDown';
|
@@ -14,9 +14,11 @@ tslib_1.__exportStar(require("./getNativeElementProps"), exports);
|
|
14
14
|
|
15
15
|
tslib_1.__exportStar(require("./getRTLSafeKey"), exports);
|
16
16
|
|
17
|
-
tslib_1.__exportStar(require("./
|
17
|
+
tslib_1.__exportStar(require("./getTriggerChild"), exports);
|
18
|
+
|
19
|
+
tslib_1.__exportStar(require("./isFluentTrigger"), exports);
|
18
20
|
|
19
|
-
tslib_1.__exportStar(require("./
|
21
|
+
tslib_1.__exportStar(require("./omit"), exports);
|
20
22
|
|
21
23
|
tslib_1.__exportStar(require("./properties"), exports);
|
22
24
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iCAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './applyTriggerPropsToChildren';\nexport * from './clamp';\nexport * from './getNativeElementProps';\nexport * from './getRTLSafeKey';\nexport * from './getTriggerChild';\nexport * from './isFluentTrigger';\nexport * from './omit';\nexport * from './properties';\nexport * from './shouldPreventDefaultOnKeyDown';\n"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
/**
|
3
|
+
* Allows a component to be tagged as a FluentUI trigger component.
|
4
|
+
*
|
5
|
+
* Triggers are special-case components: they attach event listeners and other props on their child,
|
6
|
+
* and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.
|
7
|
+
*
|
8
|
+
* A component can be tagged as a trigger as follows:
|
9
|
+
* ```ts
|
10
|
+
* const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;
|
11
|
+
*
|
12
|
+
* MyComponent.isFluentTriggerComponent = true; // MUST also set this to true
|
13
|
+
* ```
|
14
|
+
*/
|
15
|
+
export declare type FluentTriggerComponent = {
|
16
|
+
isFluentTriggerComponent?: boolean;
|
17
|
+
};
|
18
|
+
/**
|
19
|
+
* Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
|
20
|
+
* See the {@link FluentTriggerComponent} type for more info.
|
21
|
+
*/
|
22
|
+
export declare const isFluentTrigger: (element: React.ReactElement) => boolean | undefined;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.isFluentTrigger = void 0;
|
7
|
+
/**
|
8
|
+
* Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
|
9
|
+
* See the {@link FluentTriggerComponent} type for more info.
|
10
|
+
*/
|
11
|
+
|
12
|
+
const isFluentTrigger = element => {
|
13
|
+
return element.type.isFluentTriggerComponent;
|
14
|
+
};
|
15
|
+
|
16
|
+
exports.isFluentTrigger = isFluentTrigger;
|
17
|
+
//# sourceMappingURL=isFluentTrigger.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["utils/isFluentTrigger.ts"],"names":[],"mappings":";;;;;;AAmBA;;;AAGG;;AACI,MAAM,eAAe,GAAI,OAAD,IAAgC;AAC7D,SAAQ,OAAO,CAAC,IAAR,CAAwC,wBAAhD;AACD,CAFM;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","sourcesContent":["import * as React from 'react';\n\n/**\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 * 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 const isFluentTrigger = (element: React.ReactElement) => {\n return (element.type as FluentTriggerComponent).isFluentTriggerComponent;\n};\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["utils/omit.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;AAYG;AACH;;AACA,SAAgB,IAAhB,CACE,GADF,EAEE,UAFF,EAEwB;AAEtB;AACA,QAAM,MAAM,GAAwB,EAApC;;AAEA,OAAK,MAAM,GAAX,IAAkB,GAAlB,EAAuB;AACrB,QAAI,UAAU,CAAC,OAAX,CAAmB,GAAnB,MAA4B,CAAC,CAA7B,IAAkC,GAAG,CAAC,cAAJ,CAAmB,GAAnB,CAAtC,EAA+D;AAC7D,MAAA,MAAM,CAAC,GAAD,CAAN,GAAc,GAAG,CAAC,GAAD,CAAjB;AACD;AACF;;AAED,SAAO,MAAP;AACD;;AAdD,OAAA,CAAA,IAAA,GAAA,IAAA","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"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/properties.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAM,WAAW,GAAG,CAAC,GAAG,KAAJ,KAAoD;AACtE,QAAM,MAAM,GAA2B,EAAvC;;AAEA,OAAK,MAAM,IAAX,IAAmB,KAAnB,EAA0B;AACxB,UAAM,IAAI,GAAG,KAAK,CAAC,OAAN,CAAc,IAAd,IAAsB,IAAtB,GAA6B,MAAM,CAAC,IAAP,CAAY,IAAZ,CAA1C;;AAEA,SAAK,MAAM,GAAX,IAAkB,IAAlB,EAAwB;AACtB,MAAA,MAAM,CAAC,GAAD,CAAN,GAAc,CAAd;AACD;AACF;;AAED,SAAO,MAAP;AACD,CAZD;AAcA;;;;AAIG;;;AACU,OAAA,CAAA,iBAAA,gBAAoB,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/B2C,EAgC3C,QAhC2C,EAiC3C,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AAG,KAAK,CAAC,OAAN,CAAc,gBAAd,CAAhB,CAR4B,CAS5B;;AACA,QAAM,MAAM,GAAwB,EAApC;AACA,QAAM,IAAI,GAAG,MAAM,CAAC,IAAP,CAAY,KAAZ,CAAb;;AAEA,OAAK,MAAM,GAAX,IAAkB,IAAlB,EAAwB;AACtB,UAAM,YAAY,GACf,CAAC,OAAD,IAAa,gBAA2C,CAAC,GAAD,CAAzD,IACC,OAAO,IAAK,gBAA6B,CAAC,OAA9B,CAAsC,GAAtC,KAA8C,CAD3D,IAEA,GAAG,CAAC,OAAJ,CAAY,OAAZ,MAAyB,CAFzB,IAGA,GAAG,CAAC,OAAJ,CAAY,OAAZ,MAAyB,CAJ3B;;AAMA,QAAI,YAAY,KAAK,CAAC,iBAAD,IAAsB,CAAA,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAE,OAAnB,CAA2B,GAA3B,CAAA,MAAoC,CAAC,CAAhE,CAAhB,EAAoF;AAClF;AACA,MAAA,MAAM,CAAC,GAAD,CAAN,GAAc,KAAM,CAAC,GAAD,CAApB;AACD;AACF;;AAED,SAAO,MAAP;AACD;;AA/BD,OAAA,CAAA,cAAA,GAAA,cAAA","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 HTML element properties and events.\n *\n * @public\n */\nexport const htmlElementProperties = toObjectMap(baseElementProperties, baseElementEvents);\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 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 '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 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 * @deprecated Use imgProperties for img elements.\n */\nexport const imageProperties = imgProperties;\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 allowedPropsNames - The array or record of allowed prop names.\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 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["utils/shouldPreventDefaultOnKeyDown.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAGA;;;;AAIG;;;AACH,SAAgB,6BAAhB,CAA8C,CAA9C,EAAoF;AAClF,QAAM,GAAG,GAAG,CAAC,CAAC,GAAd;AACA,QAAM,MAAM,GAA4B,CAAC,CAAC,MAA1C;AAEA,QAAM,YAAY,GAAG,GAAG,KAAK,eAAA,CAAA,KAAR,IAAiB,GAAG,KAAK,eAAA,CAAA,KAA9C;;AAEA,MAAI,CAAA,MAAM,KAAA,IAAN,IAAA,MAAM,KAAA,KAAA,CAAN,GAAM,KAAA,CAAN,GAAA,MAAM,CAAE,OAAR,MAAoB,GAAxB,EAA6B;AAC3B,WAAO,GAAG,KAAK,eAAA,CAAA,KAAf;AACD;;AAED,QAAM,YAAY,GAChB,CAAA,MAAM,KAAA,IAAN,IAAA,MAAM,KAAA,KAAA,CAAN,GAAM,KAAA,CAAN,GAAA,MAAM,CAAE,OAAR,MAAoB,OAApB,IAA+B,CAAA,MAAM,KAAA,IAAN,IAAA,MAAM,KAAA,KAAA,CAAN,GAAM,KAAA,CAAN,GAAA,MAAM,CAAE,OAAR,MAAoB,UAAnD,IAAiE,CAAA,MAAM,KAAA,IAAN,IAAA,MAAM,KAAA,KAAA,CAAN,GAAM,KAAA,CAAN,GAAA,MAAM,CAAE,iBAAR,MAA8B,IADjG;AAGA,SAAO,YAAY,IAAI,CAAC,YAAxB;AACD;;AAdD,OAAA,CAAA,6BAAA,GAAA,6BAAA","sourcesContent":["import { Space, Enter } from '@fluentui/keyboard-keys';\nimport * as React from 'react';\n\n/**\n * Checks if the keyboard event should preventDefault() for Enter and Spacebar keys\n *\n * Useful for situations where a keydown needs to be transformed to a click event\n */\nexport function shouldPreventDefaultOnKeyDown(e: KeyboardEvent | React.KeyboardEvent) {\n const key = e.key;\n const target: HTMLElement | undefined = e.target as HTMLElement;\n\n const matchesByKey = key === Space || key === Enter;\n\n if (target?.tagName === 'A') {\n return key === Space;\n }\n\n const ignoredByTag =\n target?.tagName === 'INPUT' || target?.tagName === 'TEXTAREA' || target?.isContentEditable === true;\n\n return matchesByKey && !ignoredByTag;\n}\n"],"sourceRoot":"../src/"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-nightlyf3017f159620220222.1",
|
4
4
|
"description": "A set of general React-specific utilities.",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"code-style": "just-scripts code-style",
|
19
19
|
"just": "just-scripts",
|
20
20
|
"lint": "just-scripts lint",
|
21
|
-
"test": "jest",
|
21
|
+
"test": "jest --passWithNoTests",
|
22
22
|
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
|
23
23
|
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-utilities/src && yarn docs",
|
24
24
|
"start": "yarn storybook",
|
@@ -27,17 +27,13 @@
|
|
27
27
|
"devDependencies": {
|
28
28
|
"@fluentui/eslint-plugin": "*",
|
29
29
|
"@fluentui/scripts": "^1.0.0",
|
30
|
-
"@types/enzyme": "3.10.3",
|
31
|
-
"@types/enzyme-adapter-react-16": "1.0.3",
|
32
30
|
"@types/react": "16.9.42",
|
33
31
|
"@types/react-test-renderer": "^16.0.0",
|
34
|
-
"enzyme": "~3.10.0",
|
35
|
-
"enzyme-adapter-react-16": "^1.15.0",
|
36
32
|
"react": "16.8.6",
|
37
33
|
"react-test-renderer": "^16.3.0"
|
38
34
|
},
|
39
35
|
"dependencies": {
|
40
|
-
"@fluentui/keyboard-keys": "0.0.0-
|
36
|
+
"@fluentui/keyboard-keys": "0.0.0-nightlyf3017f159620220222.1",
|
41
37
|
"tslib": "^2.1.0"
|
42
38
|
},
|
43
39
|
"peerDependencies": {
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"nullRender.js","sourceRoot":"","sources":["../../src/compose/nullRender.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC"}
|
package/lib/utils/onlyChild.d.ts
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Similar to React.Children.only, but drills into fragments rather than treating them as a single child
|
4
|
-
*/
|
5
|
-
export declare const onlyChild: <P>(child: boolean | React.ReactText | React.ReactFragment | React.ReactPortal | React.ReactElement<P, string | React.JSXElementConstructor<any>> | null | undefined) => React.ReactElement<P, string | React.JSXElementConstructor<any>>;
|
package/lib/utils/onlyChild.js
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Similar to React.Children.only, but drills into fragments rather than treating them as a single child
|
4
|
-
*/
|
5
|
-
|
6
|
-
export const onlyChild = child => {
|
7
|
-
if (! /*#__PURE__*/React.isValidElement(child)) {
|
8
|
-
throw new Error(`Component's child must be a single element`);
|
9
|
-
}
|
10
|
-
|
11
|
-
return child.type === React.Fragment ? onlyChild(child.props.children) : child;
|
12
|
-
};
|
13
|
-
//# sourceMappingURL=onlyChild.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/onlyChild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;AAEG;;AACH,OAAO,MAAM,SAAS,GACpB,KADuB,IAEE;AACzB,MAAI,eAAC,KAAK,CAAC,cAAN,CAAqB,KAArB,CAAL,EAAkC;AAChC,UAAM,IAAI,KAAJ,CAAU,4CAAV,CAAN;AACD;;AAED,SAAO,KAAK,CAAC,IAAN,KAAe,KAAK,CAAC,QAArB,GAAgC,SAAS,CAAC,KAAK,CAAC,KAAN,CAAY,QAAb,CAAzC,GAAkE,KAAzE;AACD,CARM","sourceRoot":""}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.nullRender = void 0;
|
7
|
-
/**
|
8
|
-
* Simple constant function for returning null, used to render empty templates in JSX.
|
9
|
-
*/
|
10
|
-
|
11
|
-
const nullRender = () => null;
|
12
|
-
|
13
|
-
exports.nullRender = nullRender;
|
14
|
-
//# sourceMappingURL=nullRender.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/compose/nullRender.tsx"],"names":[],"mappings":";;;;;;AAAA;;AAEG;;AACI,MAAM,UAAU,GAAG,MAAM,IAAzB;;AAAM,OAAA,CAAA,UAAA,GAAU,UAAV","sourceRoot":""}
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* Similar to React.Children.only, but drills into fragments rather than treating them as a single child
|
4
|
-
*/
|
5
|
-
export declare const onlyChild: <P>(child: boolean | React.ReactText | React.ReactFragment | React.ReactPortal | React.ReactElement<P, string | React.JSXElementConstructor<any>> | null | undefined) => React.ReactElement<P, string | React.JSXElementConstructor<any>>;
|
@@ -1,23 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.onlyChild = void 0;
|
7
|
-
|
8
|
-
const React = /*#__PURE__*/require("react");
|
9
|
-
/**
|
10
|
-
* Similar to React.Children.only, but drills into fragments rather than treating them as a single child
|
11
|
-
*/
|
12
|
-
|
13
|
-
|
14
|
-
const onlyChild = child => {
|
15
|
-
if (!React.isValidElement(child)) {
|
16
|
-
throw new Error(`Component's child must be a single element`);
|
17
|
-
}
|
18
|
-
|
19
|
-
return child.type === React.Fragment ? exports.onlyChild(child.props.children) : child;
|
20
|
-
};
|
21
|
-
|
22
|
-
exports.onlyChild = onlyChild;
|
23
|
-
//# sourceMappingURL=onlyChild.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/onlyChild.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;AAEG;;;AACI,MAAM,SAAS,GACpB,KADuB,IAEE;AACzB,MAAI,CAAC,KAAK,CAAC,cAAN,CAAqB,KAArB,CAAL,EAAkC;AAChC,UAAM,IAAI,KAAJ,CAAU,4CAAV,CAAN;AACD;;AAED,SAAO,KAAK,CAAC,IAAN,KAAe,KAAK,CAAC,QAArB,GAAgC,OAAA,CAAA,SAAA,CAAU,KAAK,CAAC,KAAN,CAAY,QAAtB,CAAhC,GAAkE,KAAzE;AACD,CARM;;AAAM,OAAA,CAAA,SAAA,GAAS,SAAT","sourceRoot":""}
|