@fluentui/react-utilities 0.0.0-nightly-20220302-0405.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 +1844 -0
- package/CHANGELOG.md +736 -0
- package/LICENSE +15 -0
- package/README.md +5 -0
- package/dist/react-utilities.d.ts +782 -0
- package/lib/compose/getSlots.d.ts +30 -0
- package/lib/compose/getSlots.js +63 -0
- package/lib/compose/getSlots.js.map +1 -0
- package/lib/compose/index.d.ts +3 -0
- package/lib/compose/index.js +4 -0
- package/lib/compose/index.js.map +1 -0
- package/lib/compose/resolveShorthand.d.ts +16 -0
- package/lib/compose/resolveShorthand.js +31 -0
- package/lib/compose/resolveShorthand.js.map +1 -0
- package/lib/compose/types.d.ts +155 -0
- package/lib/compose/types.js +6 -0
- package/lib/compose/types.js.map +1 -0
- package/lib/hooks/index.d.ts +16 -0
- package/lib/hooks/index.js +17 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/useBoolean.d.ts +17 -0
- package/lib/hooks/useBoolean.js +28 -0
- package/lib/hooks/useBoolean.js.map +1 -0
- package/lib/hooks/useConst.d.ts +12 -0
- package/lib/hooks/useConst.js +30 -0
- package/lib/hooks/useConst.js.map +1 -0
- package/lib/hooks/useControllableState.d.ts +31 -0
- package/lib/hooks/useControllableState.js +73 -0
- package/lib/hooks/useControllableState.js.map +1 -0
- package/lib/hooks/useEventCallback.d.ts +13 -0
- package/lib/hooks/useEventCallback.js +28 -0
- package/lib/hooks/useEventCallback.js.map +1 -0
- package/lib/hooks/useFirstMount.d.ts +11 -0
- package/lib/hooks/useFirstMount.js +23 -0
- package/lib/hooks/useFirstMount.js.map +1 -0
- package/lib/hooks/useForceUpdate.d.ts +4 -0
- package/lib/hooks/useForceUpdate.js +9 -0
- package/lib/hooks/useForceUpdate.js.map +1 -0
- package/lib/hooks/useId.d.ts +15 -0
- package/lib/hooks/useId.js +31 -0
- package/lib/hooks/useId.js.map +1 -0
- package/lib/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
- package/lib/hooks/useIsomorphicLayoutEffect.js +15 -0
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -0
- 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.d.ts +13 -0
- package/lib/hooks/useMergedRefs.js +26 -0
- package/lib/hooks/useMergedRefs.js.map +1 -0
- package/lib/hooks/useMount.d.ts +6 -0
- package/lib/hooks/useMount.js +17 -0
- package/lib/hooks/useMount.js.map +1 -0
- package/lib/hooks/useOnClickOutside.d.ts +29 -0
- package/lib/hooks/useOnClickOutside.js +136 -0
- package/lib/hooks/useOnClickOutside.js.map +1 -0
- package/lib/hooks/useOnScrollOutside.d.ts +5 -0
- package/lib/hooks/useOnScrollOutside.js +36 -0
- package/lib/hooks/useOnScrollOutside.js.map +1 -0
- package/lib/hooks/usePrevious.d.ts +1 -0
- package/lib/hooks/usePrevious.js +9 -0
- package/lib/hooks/usePrevious.js.map +1 -0
- package/lib/hooks/useTimeout.d.ts +8 -0
- package/lib/hooks/useTimeout.js +29 -0
- package/lib/hooks/useTimeout.js.map +1 -0
- package/lib/hooks/useUnmount.d.ts +6 -0
- package/lib/hooks/useUnmount.js +17 -0
- package/lib/hooks/useUnmount.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/lib/ssr/SSRContext.d.ts +33 -0
- package/lib/ssr/SSRContext.js +65 -0
- package/lib/ssr/SSRContext.js.map +1 -0
- package/lib/ssr/canUseDOM.d.ts +4 -0
- package/lib/ssr/canUseDOM.js +8 -0
- package/lib/ssr/canUseDOM.js.map +1 -0
- package/lib/ssr/index.d.ts +2 -0
- package/lib/ssr/index.js +3 -0
- package/lib/ssr/index.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/utils/applyTriggerPropsToChildren.d.ts +5 -0
- package/lib/utils/applyTriggerPropsToChildren.js +36 -0
- package/lib/utils/applyTriggerPropsToChildren.js.map +1 -0
- package/lib/utils/clamp.d.ts +8 -0
- package/lib/utils/clamp.js +9 -0
- package/lib/utils/clamp.js.map +1 -0
- package/lib/utils/getNativeElementProps.d.ts +31 -0
- package/lib/utils/getNativeElementProps.js +61 -0
- package/lib/utils/getNativeElementProps.js.map +1 -0
- package/lib/utils/getRTLSafeKey.d.ts +4 -0
- package/lib/utils/getRTLSafeKey.js +21 -0
- package/lib/utils/getRTLSafeKey.js.map +1 -0
- 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 +9 -0
- package/lib/utils/index.js +10 -0
- package/lib/utils/index.js.map +1 -0
- 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.d.ts +14 -0
- package/lib/utils/omit.js +27 -0
- package/lib/utils/omit.js.map +1 -0
- package/lib/utils/properties.d.ts +154 -0
- package/lib/utils/properties.js +237 -0
- package/lib/utils/properties.js.map +1 -0
- package/lib/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
- package/lib/utils/shouldPreventDefaultOnKeyDown.js +24 -0
- package/lib/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
- package/lib-commonjs/compose/getSlots.d.ts +30 -0
- package/lib-commonjs/compose/getSlots.js +74 -0
- package/lib-commonjs/compose/getSlots.js.map +1 -0
- package/lib-commonjs/compose/index.d.ts +3 -0
- package/lib-commonjs/compose/index.js +14 -0
- package/lib-commonjs/compose/index.js.map +1 -0
- package/lib-commonjs/compose/resolveShorthand.d.ts +16 -0
- package/lib-commonjs/compose/resolveShorthand.js +41 -0
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -0
- package/lib-commonjs/compose/types.d.ts +155 -0
- package/lib-commonjs/compose/types.js +10 -0
- package/lib-commonjs/compose/types.js.map +1 -0
- package/lib-commonjs/hooks/index.d.ts +16 -0
- package/lib-commonjs/hooks/index.js +40 -0
- package/lib-commonjs/hooks/index.js.map +1 -0
- package/lib-commonjs/hooks/useBoolean.d.ts +17 -0
- package/lib-commonjs/hooks/useBoolean.js +39 -0
- package/lib-commonjs/hooks/useBoolean.js.map +1 -0
- package/lib-commonjs/hooks/useConst.d.ts +12 -0
- package/lib-commonjs/hooks/useConst.js +40 -0
- package/lib-commonjs/hooks/useConst.js.map +1 -0
- package/lib-commonjs/hooks/useControllableState.d.ts +31 -0
- package/lib-commonjs/hooks/useControllableState.js +83 -0
- package/lib-commonjs/hooks/useControllableState.js.map +1 -0
- package/lib-commonjs/hooks/useEventCallback.d.ts +13 -0
- package/lib-commonjs/hooks/useEventCallback.js +39 -0
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -0
- package/lib-commonjs/hooks/useFirstMount.d.ts +11 -0
- package/lib-commonjs/hooks/useFirstMount.js +33 -0
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -0
- package/lib-commonjs/hooks/useForceUpdate.d.ts +4 -0
- package/lib-commonjs/hooks/useForceUpdate.js +19 -0
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -0
- package/lib-commonjs/hooks/useId.d.ts +15 -0
- package/lib-commonjs/hooks/useId.js +44 -0
- package/lib-commonjs/hooks/useId.js.map +1 -0
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +24 -0
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -0
- 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.d.ts +13 -0
- package/lib-commonjs/hooks/useMergedRefs.js +36 -0
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -0
- package/lib-commonjs/hooks/useMount.d.ts +6 -0
- package/lib-commonjs/hooks/useMount.js +27 -0
- package/lib-commonjs/hooks/useMount.js.map +1 -0
- package/lib-commonjs/hooks/useOnClickOutside.d.ts +29 -0
- package/lib-commonjs/hooks/useOnClickOutside.js +147 -0
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -0
- package/lib-commonjs/hooks/useOnScrollOutside.d.ts +5 -0
- package/lib-commonjs/hooks/useOnScrollOutside.js +47 -0
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -0
- package/lib-commonjs/hooks/usePrevious.d.ts +1 -0
- package/lib-commonjs/hooks/usePrevious.js +19 -0
- package/lib-commonjs/hooks/usePrevious.js.map +1 -0
- package/lib-commonjs/hooks/useTimeout.d.ts +8 -0
- package/lib-commonjs/hooks/useTimeout.js +40 -0
- package/lib-commonjs/hooks/useTimeout.js.map +1 -0
- package/lib-commonjs/hooks/useUnmount.d.ts +6 -0
- package/lib-commonjs/hooks/useUnmount.js +27 -0
- package/lib-commonjs/hooks/useUnmount.js.map +1 -0
- package/lib-commonjs/index.d.ts +4 -0
- package/lib-commonjs/index.js +16 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/ssr/SSRContext.d.ts +33 -0
- package/lib-commonjs/ssr/SSRContext.js +80 -0
- package/lib-commonjs/ssr/SSRContext.js.map +1 -0
- package/lib-commonjs/ssr/canUseDOM.d.ts +4 -0
- package/lib-commonjs/ssr/canUseDOM.js +17 -0
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -0
- package/lib-commonjs/ssr/index.d.ts +2 -0
- package/lib-commonjs/ssr/index.js +12 -0
- package/lib-commonjs/ssr/index.js.map +1 -0
- package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +5 -0
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js +47 -0
- package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -0
- package/lib-commonjs/utils/clamp.d.ts +8 -0
- package/lib-commonjs/utils/clamp.js +18 -0
- package/lib-commonjs/utils/clamp.js.map +1 -0
- package/lib-commonjs/utils/getNativeElementProps.d.ts +31 -0
- package/lib-commonjs/utils/getNativeElementProps.js +73 -0
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -0
- package/lib-commonjs/utils/getRTLSafeKey.d.ts +4 -0
- package/lib-commonjs/utils/getRTLSafeKey.js +30 -0
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -0
- 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 +9 -0
- package/lib-commonjs/utils/index.js +26 -0
- package/lib-commonjs/utils/index.js.map +1 -0
- 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.d.ts +14 -0
- package/lib-commonjs/utils/omit.js +36 -0
- package/lib-commonjs/utils/omit.js.map +1 -0
- package/lib-commonjs/utils/properties.d.ts +154 -0
- package/lib-commonjs/utils/properties.js +246 -0
- package/lib-commonjs/utils/properties.js.map +1 -0
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.d.ts +7 -0
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js +34 -0
- package/lib-commonjs/utils/shouldPreventDefaultOnKeyDown.js.map +1 -0
- package/package.json +50 -0
@@ -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/"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export * from './applyTriggerPropsToChildren';
|
2
|
+
export * from './clamp';
|
3
|
+
export * from './getNativeElementProps';
|
4
|
+
export * from './getRTLSafeKey';
|
5
|
+
export * from './getTriggerChild';
|
6
|
+
export * from './isFluentTrigger';
|
7
|
+
export * from './omit';
|
8
|
+
export * from './properties';
|
9
|
+
export * from './shouldPreventDefaultOnKeyDown';
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
+
|
9
|
+
tslib_1.__exportStar(require("./applyTriggerPropsToChildren"), exports);
|
10
|
+
|
11
|
+
tslib_1.__exportStar(require("./clamp"), exports);
|
12
|
+
|
13
|
+
tslib_1.__exportStar(require("./getNativeElementProps"), exports);
|
14
|
+
|
15
|
+
tslib_1.__exportStar(require("./getRTLSafeKey"), exports);
|
16
|
+
|
17
|
+
tslib_1.__exportStar(require("./getTriggerChild"), exports);
|
18
|
+
|
19
|
+
tslib_1.__exportStar(require("./isFluentTrigger"), exports);
|
20
|
+
|
21
|
+
tslib_1.__exportStar(require("./omit"), exports);
|
22
|
+
|
23
|
+
tslib_1.__exportStar(require("./properties"), exports);
|
24
|
+
|
25
|
+
tslib_1.__exportStar(require("./shouldPreventDefaultOnKeyDown"), exports);
|
26
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
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/"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* Tiny helper to do the minimal amount of work in duplicating an object but omitting some
|
3
|
+
* props. This ends up faster than using object ...rest or reduce to filter.
|
4
|
+
*
|
5
|
+
* This behaves very much like filteredAssign, but does not merge many objects together,
|
6
|
+
* uses an exclusion object map, and avoids spreads all for optimal performance.
|
7
|
+
*
|
8
|
+
* See perf test for background:
|
9
|
+
* https://jsperf.com/omit-vs-rest-vs-reduce/1
|
10
|
+
*
|
11
|
+
* @param obj - The object to clone
|
12
|
+
* @param exclusions - The array of keys to exclude
|
13
|
+
*/
|
14
|
+
export declare function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.omit = void 0;
|
7
|
+
/**
|
8
|
+
* Tiny helper to do the minimal amount of work in duplicating an object but omitting some
|
9
|
+
* props. This ends up faster than using object ...rest or reduce to filter.
|
10
|
+
*
|
11
|
+
* This behaves very much like filteredAssign, but does not merge many objects together,
|
12
|
+
* uses an exclusion object map, and avoids spreads all for optimal performance.
|
13
|
+
*
|
14
|
+
* See perf test for background:
|
15
|
+
* https://jsperf.com/omit-vs-rest-vs-reduce/1
|
16
|
+
*
|
17
|
+
* @param obj - The object to clone
|
18
|
+
* @param exclusions - The array of keys to exclude
|
19
|
+
*/
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
21
|
+
|
22
|
+
function omit(obj, exclusions) {
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
24
|
+
const result = {};
|
25
|
+
|
26
|
+
for (const key in obj) {
|
27
|
+
if (exclusions.indexOf(key) === -1 && obj.hasOwnProperty(key)) {
|
28
|
+
result[key] = obj[key];
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
return result;
|
33
|
+
}
|
34
|
+
|
35
|
+
exports.omit = omit;
|
36
|
+
//# sourceMappingURL=omit.js.map
|
@@ -0,0 +1 @@
|
|
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/"}
|
@@ -0,0 +1,154 @@
|
|
1
|
+
/**
|
2
|
+
* An array of events that are allowed on every html element type.
|
3
|
+
*
|
4
|
+
* @public
|
5
|
+
*/
|
6
|
+
export declare const baseElementEvents: Record<string, number>;
|
7
|
+
/**
|
8
|
+
* An array of element attributes which are allowed on every html element type.
|
9
|
+
*
|
10
|
+
* @public
|
11
|
+
*/
|
12
|
+
export declare const baseElementProperties: Record<string, number>;
|
13
|
+
/**
|
14
|
+
* An array of HTML element properties and events.
|
15
|
+
*
|
16
|
+
* @public
|
17
|
+
*/
|
18
|
+
export declare const htmlElementProperties: Record<string, number>;
|
19
|
+
/**
|
20
|
+
* An array of LABEL tag properties and events.
|
21
|
+
*
|
22
|
+
* @public
|
23
|
+
*/
|
24
|
+
export declare const labelProperties: Record<string, number>;
|
25
|
+
/**
|
26
|
+
* An array of AUDIO tag properties and events.
|
27
|
+
|
28
|
+
* @public
|
29
|
+
*/
|
30
|
+
export declare const audioProperties: Record<string, number>;
|
31
|
+
/**
|
32
|
+
* An array of VIDEO tag properties and events.
|
33
|
+
*
|
34
|
+
* @public
|
35
|
+
*/
|
36
|
+
export declare const videoProperties: Record<string, number>;
|
37
|
+
/**
|
38
|
+
* An array of OL tag properties and events.
|
39
|
+
*
|
40
|
+
* @public
|
41
|
+
*/
|
42
|
+
export declare const olProperties: Record<string, number>;
|
43
|
+
/**
|
44
|
+
* An array of LI tag properties and events.
|
45
|
+
*
|
46
|
+
* @public
|
47
|
+
*/
|
48
|
+
export declare const liProperties: Record<string, number>;
|
49
|
+
/**
|
50
|
+
* An array of A tag properties and events.
|
51
|
+
*
|
52
|
+
* @public
|
53
|
+
*/
|
54
|
+
export declare const anchorProperties: Record<string, number>;
|
55
|
+
/**
|
56
|
+
* An array of BUTTON tag properties and events.
|
57
|
+
*
|
58
|
+
* @public
|
59
|
+
*/
|
60
|
+
export declare const buttonProperties: Record<string, number>;
|
61
|
+
/**
|
62
|
+
* An array of INPUT tag properties and events.
|
63
|
+
*
|
64
|
+
* @public
|
65
|
+
*/
|
66
|
+
export declare const inputProperties: Record<string, number>;
|
67
|
+
/**
|
68
|
+
* An array of TEXTAREA tag properties and events.
|
69
|
+
*
|
70
|
+
* @public
|
71
|
+
*/
|
72
|
+
export declare const textAreaProperties: Record<string, number>;
|
73
|
+
/**
|
74
|
+
* An array of SELECT tag properties and events.
|
75
|
+
*
|
76
|
+
* @public
|
77
|
+
*/
|
78
|
+
export declare const selectProperties: Record<string, number>;
|
79
|
+
export declare const optionProperties: Record<string, number>;
|
80
|
+
/**
|
81
|
+
* An array of TABLE tag properties and events.
|
82
|
+
*
|
83
|
+
* @public
|
84
|
+
*/
|
85
|
+
export declare const tableProperties: Record<string, number>;
|
86
|
+
/**
|
87
|
+
* An array of TR tag properties and events.
|
88
|
+
*
|
89
|
+
* @public
|
90
|
+
*/
|
91
|
+
export declare const trProperties: Record<string, number>;
|
92
|
+
/**
|
93
|
+
* An array of TH tag properties and events.
|
94
|
+
*
|
95
|
+
* @public
|
96
|
+
*/
|
97
|
+
export declare const thProperties: Record<string, number>;
|
98
|
+
/**
|
99
|
+
* An array of TD tag properties and events.
|
100
|
+
*
|
101
|
+
* @public
|
102
|
+
*/
|
103
|
+
export declare const tdProperties: Record<string, number>;
|
104
|
+
export declare const colGroupProperties: Record<string, number>;
|
105
|
+
export declare const colProperties: Record<string, number>;
|
106
|
+
/**
|
107
|
+
* An array of FIELDSET tag properties and events.
|
108
|
+
*
|
109
|
+
* @public
|
110
|
+
*/
|
111
|
+
export declare const fieldsetProperties: Record<string, number>;
|
112
|
+
/**
|
113
|
+
* An array of FORM tag properties and events.
|
114
|
+
*
|
115
|
+
* @public
|
116
|
+
*/
|
117
|
+
export declare const formProperties: Record<string, number>;
|
118
|
+
/**
|
119
|
+
* An array of IFRAME tag properties and events.
|
120
|
+
*
|
121
|
+
* @public
|
122
|
+
*/
|
123
|
+
export declare const iframeProperties: Record<string, number>;
|
124
|
+
/**
|
125
|
+
* An array of IMAGE tag properties and events.
|
126
|
+
*
|
127
|
+
* @public
|
128
|
+
*/
|
129
|
+
export declare const imgProperties: Record<string, number>;
|
130
|
+
/**
|
131
|
+
* @deprecated Use imgProperties for img elements.
|
132
|
+
*/
|
133
|
+
export declare const imageProperties: Record<string, number>;
|
134
|
+
/**
|
135
|
+
* An array of DIV tag properties and events.
|
136
|
+
*
|
137
|
+
* @public
|
138
|
+
*/
|
139
|
+
export declare const divProperties: Record<string, number>;
|
140
|
+
/**
|
141
|
+
* Gets native supported props for an html element provided the allowance set. Use one of the property
|
142
|
+
* sets defined (divProperties, buttonPropertes, etc) to filter out supported properties from a given
|
143
|
+
* props set. Note that all data- and aria- prefixed attributes will be allowed.
|
144
|
+
* NOTE: getNativeProps should always be applied first when adding props to a react component. The
|
145
|
+
* non-native props should be applied second. This will prevent getNativeProps from overriding your custom props.
|
146
|
+
* For example, if props passed to getNativeProps has an onClick function and getNativeProps is added to
|
147
|
+
* the component after an onClick function is added, then the getNativeProps onClick will override it.
|
148
|
+
*
|
149
|
+
* @public
|
150
|
+
* @param props - The unfiltered input props
|
151
|
+
* @param allowedPropsNames - The array or record of allowed prop names.
|
152
|
+
* @returns The filtered props
|
153
|
+
*/
|
154
|
+
export declare function getNativeProps<T extends Record<string, any>>(props: Record<string, any>, allowedPropNames: string[] | Record<string, number>, excludedPropNames?: string[]): T;
|