@fluentui/react-utilities 9.9.0 → 9.9.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 +46 -1
- package/CHANGELOG.md +20 -2
- package/dist/index.d.ts +1 -1
- package/lib/compose/constants.js +1 -2
- package/lib/compose/constants.js.map +1 -1
- package/lib/compose/getSlots.js +40 -36
- package/lib/compose/getSlots.js.map +1 -1
- package/lib/compose/getSlotsNext.js +30 -28
- package/lib/compose/getSlotsNext.js.map +1 -1
- package/lib/compose/index.js +0 -1
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/isResolvedShorthand.js +2 -4
- package/lib/compose/isResolvedShorthand.js.map +1 -1
- package/lib/compose/resolveShorthand.js +21 -26
- package/lib/compose/resolveShorthand.js.map +1 -1
- package/lib/compose/types.js +0 -1
- package/lib/compose/types.js.map +1 -1
- package/lib/events/index.js +0 -1
- package/lib/events/index.js.map +1 -1
- package/lib/events/mouseTouchHelpers.js +27 -27
- package/lib/events/mouseTouchHelpers.js.map +1 -1
- package/lib/hooks/index.js +0 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useControllableState.js +57 -32
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useEventCallback.js +15 -13
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.js +7 -9
- package/lib/hooks/useFirstMount.js.map +1 -1
- package/lib/hooks/useForceUpdate.js +2 -4
- package/lib/hooks/useForceUpdate.js.map +1 -1
- package/lib/hooks/useId.js +32 -29
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js +1 -2
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedRefs.js +17 -18
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +110 -114
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js +25 -29
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js +8 -8
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useScrollbarWidth.js +24 -26
- package/lib/hooks/useScrollbarWidth.js.map +1 -1
- package/lib/hooks/useTimeout.js +22 -19
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/ssr/SSRContext.js +40 -39
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js +3 -5
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/ssr/index.js +0 -1
- package/lib/ssr/index.js.map +1 -1
- package/lib/trigger/applyTriggerPropsToChildren.js +20 -23
- package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/trigger/getTriggerChild.js +7 -10
- package/lib/trigger/getTriggerChild.js.map +1 -1
- package/lib/trigger/index.js +0 -1
- package/lib/trigger/index.js.map +1 -1
- package/lib/trigger/isFluentTrigger.js +2 -4
- package/lib/trigger/isFluentTrigger.js.map +1 -1
- package/lib/trigger/types.js +0 -1
- package/lib/trigger/types.js.map +1 -1
- package/lib/utils/clamp.js +1 -2
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getNativeElementProps.js +38 -40
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js +12 -13
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js +16 -15
- package/lib/utils/getReactCallbackName.js.map +1 -1
- package/lib/utils/index.js +0 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isHTMLElement.js +5 -6
- package/lib/utils/isHTMLElement.js.map +1 -1
- package/lib/utils/isInteractiveHTMLElement.js +13 -17
- package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib/utils/mergeCallbacks.js +5 -6
- package/lib/utils/mergeCallbacks.js.map +1 -1
- package/lib/utils/omit.js +7 -8
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/priorityQueue.js +85 -86
- package/lib/utils/priorityQueue.js.map +1 -1
- package/lib/utils/properties.js +290 -80
- package/lib/utils/properties.js.map +1 -1
- package/lib-commonjs/compose/constants.js +1 -3
- package/lib-commonjs/compose/constants.js.map +1 -1
- package/lib-commonjs/compose/getSlots.js +1 -3
- package/lib-commonjs/compose/getSlots.js.map +1 -1
- package/lib-commonjs/compose/getSlotsNext.js +2 -3
- package/lib-commonjs/compose/getSlotsNext.js.map +1 -1
- package/lib-commonjs/compose/index.js +0 -3
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/isResolvedShorthand.js +1 -3
- package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
- package/lib-commonjs/compose/resolveShorthand.js +1 -3
- package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/types.js +0 -3
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/events/index.js +0 -3
- package/lib-commonjs/events/index.js.map +1 -1
- package/lib-commonjs/events/mouseTouchHelpers.js +1 -3
- package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
- package/lib-commonjs/hooks/index.js +0 -3
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.js +18 -6
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js +1 -3
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js +1 -3
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js +1 -3
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.js +1 -3
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +1 -3
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +2 -5
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +1 -3
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js +1 -3
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js +1 -3
- package/lib-commonjs/hooks/usePrevious.js.map +1 -1
- package/lib-commonjs/hooks/useScrollbarWidth.js +2 -4
- package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js +1 -3
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/index.js +0 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js +1 -3
- package/lib-commonjs/ssr/SSRContext.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js +1 -3
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
- package/lib-commonjs/ssr/index.js +0 -3
- package/lib-commonjs/ssr/index.js.map +1 -1
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +1 -3
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/trigger/getTriggerChild.js +2 -5
- package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
- package/lib-commonjs/trigger/index.js +0 -3
- package/lib-commonjs/trigger/index.js.map +1 -1
- package/lib-commonjs/trigger/isFluentTrigger.js +1 -3
- package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
- package/lib-commonjs/trigger/types.js +0 -3
- package/lib-commonjs/trigger/types.js.map +1 -1
- package/lib-commonjs/utils/clamp.js +1 -3
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.js +1 -3
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js +1 -3
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.js +1 -3
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -3
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isHTMLElement.js +1 -3
- package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/isInteractiveHTMLElement.js +1 -3
- package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/mergeCallbacks.js +1 -3
- package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
- package/lib-commonjs/utils/omit.js +1 -3
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/priorityQueue.js +5 -7
- package/lib-commonjs/utils/priorityQueue.js.map +1 -1
- package/lib-commonjs/utils/properties.js +28 -31
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/package.json +2 -2
package/lib/ssr/SSRContext.js
CHANGED
@@ -4,57 +4,58 @@ import { canUseDOM } from './canUseDOM';
|
|
4
4
|
* Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
|
5
5
|
*
|
6
6
|
* @internal
|
7
|
-
*/
|
8
|
-
|
9
|
-
current: 0
|
7
|
+
*/ export const defaultSSRContextValue = {
|
8
|
+
current: 0
|
10
9
|
};
|
11
|
-
export const SSRContext = /*#__PURE__*/React.createContext(undefined);
|
10
|
+
export const SSRContext = /*#__PURE__*/ React.createContext(undefined);
|
12
11
|
/**
|
13
12
|
* @internal
|
14
|
-
*/
|
15
|
-
|
16
|
-
|
17
|
-
return (_React_useContext = React.useContext(SSRContext)) !== null && _React_useContext !== void 0 ? _React_useContext : defaultSSRContextValue;
|
13
|
+
*/ export function useSSRContext() {
|
14
|
+
var _React_useContext;
|
15
|
+
return (_React_useContext = React.useContext(SSRContext)) !== null && _React_useContext !== void 0 ? _React_useContext : defaultSSRContextValue;
|
18
16
|
}
|
19
17
|
/**
|
20
18
|
* When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
|
21
19
|
* are consistent between the client and server.
|
22
20
|
*
|
23
21
|
* @public
|
24
|
-
*/
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}, props.children);
|
22
|
+
*/ export const SSRProvider = (props)=>{
|
23
|
+
const [value] = React.useState(()=>({
|
24
|
+
current: 0
|
25
|
+
}));
|
26
|
+
return /*#__PURE__*/ React.createElement(SSRContext.Provider, {
|
27
|
+
value: value
|
28
|
+
}, props.children);
|
32
29
|
};
|
33
30
|
/**
|
34
31
|
* Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay
|
35
32
|
* browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.
|
36
|
-
*/
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
33
|
+
*/ export function useIsSSR() {
|
34
|
+
const isInSSRContext = useSSRContext() !== defaultSSRContextValue;
|
35
|
+
const [isSSR, setIsSSR] = React.useState(isInSSRContext);
|
36
|
+
// If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the
|
37
|
+
// developer to add one.
|
38
|
+
if (process.env.NODE_ENV !== 'production') {
|
39
|
+
if (!isInSSRContext && !canUseDOM()) {
|
40
|
+
// eslint-disable-next-line no-console
|
41
|
+
console.error([
|
42
|
+
'@fluentui/react-components: ',
|
43
|
+
'When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' + 'generated between the client and server.',
|
44
|
+
'\n',
|
45
|
+
'\n',
|
46
|
+
'Check documentation at https://aka.ms/fluentui-ssr'
|
47
|
+
].join(''));
|
48
|
+
}
|
49
|
+
}
|
50
|
+
// If on the client, and the component was initially server rendered, then schedule a layout effect to update the
|
51
|
+
// component after hydration.
|
52
|
+
if (canUseDOM() && isInSSRContext) {
|
53
|
+
// This if statement technically breaks the rules of hooks, but is safe because the condition never changes after
|
54
|
+
// mounting.
|
55
|
+
// eslint-disable-next-line
|
56
|
+
React.useLayoutEffect(()=>{
|
57
|
+
setIsSSR(false);
|
58
|
+
}, []);
|
46
59
|
}
|
47
|
-
|
48
|
-
// If on the client, and the component was initially server rendered, then schedule a layout effect to update the
|
49
|
-
// component after hydration.
|
50
|
-
if (canUseDOM() && isInSSRContext) {
|
51
|
-
// This if statement technically breaks the rules of hooks, but is safe because the condition never changes after
|
52
|
-
// mounting.
|
53
|
-
// eslint-disable-next-line
|
54
|
-
React.useLayoutEffect(() => {
|
55
|
-
setIsSSR(false);
|
56
|
-
}, []);
|
57
|
-
}
|
58
|
-
return isSSR;
|
60
|
+
return isSSR;
|
59
61
|
}
|
60
|
-
//# sourceMappingURL=SSRContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["SSRContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from './canUseDOM';\n\n/**\n * To support SSR, the auto incrementing id counter is stored in a context. This allows it to be reset on every request\n * to ensure the client and server are consistent.\n *\n * @internal\n */\nexport type SSRContextValue = {\n current: number;\n};\n\n/**\n * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.\n *\n * @internal\n */\nexport const defaultSSRContextValue: SSRContextValue = {\n current: 0,\n};\n\nexport const SSRContext = React.createContext<SSRContextValue | undefined>(undefined) as React.Context<SSRContextValue>;\n\n/**\n * @internal\n */\nexport function useSSRContext(): SSRContextValue {\n return React.useContext(SSRContext) ?? defaultSSRContextValue;\n}\n\n/**\n * When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids\n * are consistent between the client and server.\n *\n * @public\n */\nexport const SSRProvider: React.FC<{ children: React.ReactNode }> = props => {\n const [value] = React.useState<SSRContextValue>(() => ({ current: 0 }));\n\n return <SSRContext.Provider value={value}>{props.children}</SSRContext.Provider>;\n};\n\n/**\n * Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay\n * browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.\n */\nexport function useIsSSR(): boolean {\n const isInSSRContext = useSSRContext() !== defaultSSRContextValue;\n const [isSSR, setIsSSR] = React.useState(isInSSRContext);\n\n // If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the\n // developer to add one.\n if (process.env.NODE_ENV !== 'production') {\n if (!isInSSRContext && !canUseDOM()) {\n // eslint-disable-next-line no-console\n console.error(\n [\n '@fluentui/react-components: ',\n 'When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' +\n 'generated between the client and server.',\n '\\n',\n '\\n',\n 'Check documentation at https://aka.ms/fluentui-ssr',\n ].join(''),\n );\n }\n }\n\n // If on the client, and the component was initially server rendered, then schedule a layout effect to update the\n // component after hydration.\n if (canUseDOM() && isInSSRContext) {\n // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after\n // mounting.\n // eslint-disable-next-line\n React.useLayoutEffect(() => {\n setIsSSR(false);\n }, []);\n }\n\n return isSSR;\n}\n"],"names":["React","canUseDOM","defaultSSRContextValue","current","SSRContext","createContext","undefined","useSSRContext","useContext","SSRProvider","props","value","useState","Provider","children","useIsSSR","isInSSRContext","isSSR","setIsSSR","process","env","NODE_ENV","console","error","join","useLayoutEffect"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,SAAS,QAAQ,cAAc;AAYxC;;;;CAIC,GACD,OAAO,MAAMC,yBAA0C;IACrDC,SAAS;AACX,EAAE;AAEF,OAAO,MAAMC,2BAAaJ,MAAMK,aAAa,CAA8BC,WAA6C;AAExH;;CAEC,GACD,OAAO,SAASC,gBAAiC;QACxCP;IAAP,OAAOA,CAAAA,oBAAAA,MAAMQ,UAAU,CAACJ,yBAAjBJ,+BAAAA,oBAAgCE,sBAAsB;AAC/D,CAAC;AAED;;;;;CAKC,GACD,OAAO,MAAMO,cAAuDC,CAAAA,QAAS;IAC3E,MAAM,CAACC,MAAM,GAAGX,MAAMY,QAAQ,CAAkB,IAAO,CAAA;YAAET,SAAS;QAAE,CAAA;IAEpE,qBAAO,oBAACC,WAAWS,QAAQ;QAACF,OAAOA;OAAQD,MAAMI,QAAQ;AAC3D,EAAE;AAEF;;;CAGC,GACD,OAAO,SAASC,WAAoB;IAClC,MAAMC,iBAAiBT,oBAAoBL;IAC3C,MAAM,CAACe,OAAOC,SAAS,GAAGlB,MAAMY,QAAQ,CAACI;IAEzC,6GAA6G;IAC7G,wBAAwB;IACxB,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,CAACL,kBAAkB,CAACf,aAAa;YACnC,sCAAsC;YACtCqB,QAAQC,KAAK,CACX;gBACE;gBACA,4GACE;gBACF;gBACA;gBACA;aACD,CAACC,IAAI,CAAC;QAEX,CAAC;IACH,CAAC;IAED,iHAAiH;IACjH,6BAA6B;IAC7B,IAAIvB,eAAee,gBAAgB;QACjC,iHAAiH;QACjH,YAAY;QACZ,2BAA2B;QAC3BhB,MAAMyB,eAAe,CAAC,IAAM;YAC1BP,SAAS,KAAK;QAChB,GAAG,EAAE;IACP,CAAC;IAED,OAAOD;AACT,CAAC"}
|
package/lib/ssr/canUseDOM.js
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* Verifies if an application can use DOM.
|
3
|
-
*/export function canUseDOM() {
|
4
|
-
|
5
|
-
|
6
|
-
window.document.createElement);
|
3
|
+
*/ export function canUseDOM() {
|
4
|
+
return typeof window !== 'undefined' && !!(window.document && // eslint-disable-next-line deprecation/deprecation
|
5
|
+
window.document.createElement);
|
7
6
|
}
|
8
|
-
//# sourceMappingURL=canUseDOM.js.map
|
package/lib/ssr/canUseDOM.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["canUseDOM.ts"],"sourcesContent":["/**\n * Verifies if an application can use DOM.\n */\nexport function canUseDOM(): boolean {\n return (\n typeof window !== 'undefined' &&\n !!(\n window.document &&\n // eslint-disable-next-line deprecation/deprecation\n window.document.createElement\n )\n );\n}\n"],"names":["canUseDOM","window","document","createElement"],"mappings":"AAAA;;CAEC,GACD,OAAO,SAASA,YAAqB;IACnC,OACE,OAAOC,WAAW,eAClB,CAAC,CACCA,CAAAA,OAAOC,QAAQ,IACf,mDAAmD;IACnDD,OAAOC,QAAQ,CAACC,aAAa,AAAD;AAGlC,CAAC"}
|
package/lib/ssr/index.js
CHANGED
package/lib/ssr/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './canUseDOM';\nexport * from './SSRContext';\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,eAAe"}
|
@@ -3,31 +3,28 @@ import { isFluentTrigger } from './isFluentTrigger';
|
|
3
3
|
/**
|
4
4
|
* @internal
|
5
5
|
* resolve the trigger props to the children, either by calling the render function, or cloning with the new props.
|
6
|
-
*/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
return children || null;
|
6
|
+
*/ export function applyTriggerPropsToChildren(children, triggerChildProps) {
|
7
|
+
if (typeof children === 'function') {
|
8
|
+
return children(triggerChildProps);
|
9
|
+
} else if (children) {
|
10
|
+
return cloneTriggerTree(children, triggerChildProps);
|
11
|
+
}
|
12
|
+
// Components in React should return either JSX elements or "null", otherwise React will throw:
|
13
|
+
// Nothing was returned from render.
|
14
|
+
// This usually means a return statement is missing. Or, to render nothing, return null.
|
15
|
+
return children || null;
|
17
16
|
}
|
18
17
|
/**
|
19
18
|
* Clones a React element tree, and applies the given props to the first grandchild that is not
|
20
19
|
* a FluentTriggerComponent or React Fragment (the same element returned by {@link getTriggerChild}).
|
21
|
-
*/
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
20
|
+
*/ function cloneTriggerTree(child, triggerProps) {
|
21
|
+
if (!React.isValidElement(child) || child.type === React.Fragment) {
|
22
|
+
throw new Error('A trigger element must be a single element for this component. ' + "Please ensure that you're not using React Fragments.");
|
23
|
+
}
|
24
|
+
if (isFluentTrigger(child)) {
|
25
|
+
const grandchild = cloneTriggerTree(child.props.children, triggerProps);
|
26
|
+
return React.cloneElement(child, undefined, grandchild);
|
27
|
+
} else {
|
28
|
+
return React.cloneElement(child, triggerProps);
|
29
|
+
}
|
32
30
|
}
|
33
|
-
//# sourceMappingURL=applyTriggerPropsToChildren.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["applyTriggerPropsToChildren.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * resolve the trigger props to the children, either by calling the render function, or cloning with the new props.\n */\nexport function applyTriggerPropsToChildren<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n triggerChildProps: TriggerChildProps,\n): React.ReactElement | null {\n if (typeof children === 'function') {\n return children(triggerChildProps);\n } else if (children) {\n return cloneTriggerTree(children, triggerChildProps);\n }\n\n // Components in React should return either JSX elements or \"null\", otherwise React will throw:\n // Nothing was returned from render.\n // This usually means a return statement is missing. Or, to render nothing, return null.\n return children || null;\n}\n\n/**\n * Clones a React element tree, and applies the given props to the first grandchild that is not\n * a FluentTriggerComponent or React Fragment (the same element returned by {@link getTriggerChild}).\n */\nfunction cloneTriggerTree<TriggerChildProps>(\n child: React.ReactNode,\n triggerProps: TriggerChildProps,\n): React.ReactElement {\n if (!React.isValidElement(child) || child.type === React.Fragment) {\n throw new Error(\n 'A trigger element must be a single element for this component. ' +\n \"Please ensure that you're not using React Fragments.\",\n );\n }\n\n if (isFluentTrigger(child)) {\n const grandchild = cloneTriggerTree(child.props.children, triggerProps);\n return React.cloneElement(child, undefined, grandchild);\n } else {\n return React.cloneElement(child, triggerProps as TriggerChildProps & React.Attributes);\n }\n}\n"],"names":["React","isFluentTrigger","applyTriggerPropsToChildren","children","triggerChildProps","cloneTriggerTree","child","triggerProps","isValidElement","type","Fragment","Error","grandchild","props","cloneElement","undefined"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,eAAe,QAAQ,oBAAoB;AAGpD;;;CAGC,GACD,OAAO,SAASC,4BACdC,QAAqD,EACrDC,iBAAoC,EACT;IAC3B,IAAI,OAAOD,aAAa,YAAY;QAClC,OAAOA,SAASC;IAClB,OAAO,IAAID,UAAU;QACnB,OAAOE,iBAAiBF,UAAUC;IACpC,CAAC;IAED,+FAA+F;IAC/F,sCAAsC;IACtC,0FAA0F;IAC1F,OAAOD,YAAY,IAAI;AACzB,CAAC;AAED;;;CAGC,GACD,SAASE,iBACPC,KAAsB,EACtBC,YAA+B,EACX;IACpB,IAAI,CAACP,MAAMQ,cAAc,CAACF,UAAUA,MAAMG,IAAI,KAAKT,MAAMU,QAAQ,EAAE;QACjE,MAAM,IAAIC,MACR,oEACE,wDACF;IACJ,CAAC;IAED,IAAIV,gBAAgBK,QAAQ;QAC1B,MAAMM,aAAaP,iBAAiBC,MAAMO,KAAK,CAACV,QAAQ,EAAEI;QAC1D,OAAOP,MAAMc,YAAY,CAACR,OAAOS,WAAWH;IAC9C,OAAO;QACL,OAAOZ,MAAMc,YAAY,CAACR,OAAOC;IACnC,CAAC;AACH"}
|
@@ -21,14 +21,11 @@ import { isFluentTrigger } from './isFluentTrigger';
|
|
21
21
|
*
|
22
22
|
* In the case where the immediate child is not a valid element,
|
23
23
|
* null is returned
|
24
|
-
*/
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
// but for some reason it's failing on build
|
32
|
-
children.props.children) : children;
|
24
|
+
*/ export function getTriggerChild(children) {
|
25
|
+
if (!React.isValidElement(children)) {
|
26
|
+
return null;
|
27
|
+
}
|
28
|
+
return isFluentTrigger(children) ? getTriggerChild(// FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,
|
29
|
+
// but for some reason it's failing on build
|
30
|
+
children.props.children) : children;
|
33
31
|
}
|
34
|
-
//# sourceMappingURL=getTriggerChild.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["getTriggerChild.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).\n *\n * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,\n * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.\n * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.\n *\n * For example, the following returns `<div id=\"child\" />`:\n * ```jsx\n * getTriggerChild(\n * <Tooltip>\n * <MenuTrigger>\n * <div id=\"child\" />\n * </MenuTrigger>\n * </Tooltip>\n * );\n * ```\n *\n * In the case where the immediate child is not a valid element,\n * null is returned\n */\nexport function getTriggerChild<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (React.ReactElement<Partial<TriggerChildProps>> & { ref?: React.Ref<any> }) | null {\n if (!React.isValidElement<TriggerChildProps>(children)) {\n return null;\n }\n return isFluentTrigger(children)\n ? getTriggerChild(\n // FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,\n // but for some reason it's failing on build\n (children.props as TriggerProps).children,\n )\n : children;\n}\n"],"names":["React","isFluentTrigger","getTriggerChild","children","isValidElement","props"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,eAAe,QAAQ,oBAAoB;AAGpD;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,gBACdC,QAAqD,EAE+B;IACpF,IAAI,CAACH,MAAMI,cAAc,CAAoBD,WAAW;QACtD,OAAO,IAAI;IACb,CAAC;IACD,OAAOF,gBAAgBE,YACnBD,gBAGE,AAFA,uFAAuF;IACvF,4CAA4C;IAC3CC,SAASE,KAAK,CAAkBF,QAAQ,IAE3CA,QAAQ;AACd,CAAC"}
|
package/lib/trigger/index.js
CHANGED
package/lib/trigger/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './applyTriggerPropsToChildren';\nexport * from './getTriggerChild';\nexport * from './isFluentTrigger';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,cAAc,gCAAgC;AAC9C,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,UAAU"}
|
@@ -3,8 +3,6 @@ import * as React from 'react';
|
|
3
3
|
* @internal
|
4
4
|
* Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
|
5
5
|
* See the {@link FluentTriggerComponent} type for more info.
|
6
|
-
*/
|
7
|
-
|
8
|
-
return Boolean(element.type.isFluentTriggerComponent);
|
6
|
+
*/ export function isFluentTrigger(element) {
|
7
|
+
return Boolean(element.type.isFluentTriggerComponent);
|
9
8
|
}
|
10
|
-
//# sourceMappingURL=isFluentTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["isFluentTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport type { FluentTriggerComponent, TriggerProps } from './types';\n\n/**\n * @internal\n * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).\n * See the {@link FluentTriggerComponent} type for more info.\n */\nexport function isFluentTrigger(element: React.ReactElement): element is React.ReactElement<TriggerProps> {\n return Boolean((element.type as FluentTriggerComponent).isFluentTriggerComponent);\n}\n"],"names":["React","isFluentTrigger","element","Boolean","type","isFluentTriggerComponent"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B;;;;CAIC,GACD,OAAO,SAASC,gBAAgBC,OAA2B,EAA+C;IACxG,OAAOC,QAAQ,AAACD,QAAQE,IAAI,CAA4BC,wBAAwB;AAClF,CAAC"}
|
package/lib/trigger/types.js
CHANGED
package/lib/trigger/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["types.ts"],"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"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
package/lib/utils/clamp.js
CHANGED
@@ -5,5 +5,4 @@
|
|
5
5
|
* @param value - the value to be clamped
|
6
6
|
* @param min - the lowest valid value
|
7
7
|
* @param max - the highest valid value
|
8
|
-
*/export const clamp = (value, min, max)
|
9
|
-
//# sourceMappingURL=clamp.js.map
|
8
|
+
*/ export const clamp = (value, min, max)=>Math.max(min, Math.min(max, value || 0));
|
package/lib/utils/clamp.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["clamp.ts"],"sourcesContent":["/**\n * @internal\n * Clamps `value` to a number between the min and max.\n *\n * @param value - the value to be clamped\n * @param min - the lowest valid value\n * @param max - the highest valid value\n */\nexport const clamp = (value: number, min: number, max: number): number => Math.max(min, Math.min(max, value || 0));\n"],"names":["clamp","value","min","max","Math"],"mappings":"AAAA;;;;;;;CAOC,GACD,OAAO,MAAMA,QAAQ,CAACC,OAAeC,KAAaC,MAAwBC,KAAKD,GAAG,CAACD,KAAKE,KAAKF,GAAG,CAACC,KAAKF,SAAS,IAAI"}
|
@@ -1,29 +1,29 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { labelProperties, audioProperties, videoProperties, olProperties, liProperties, anchorProperties, buttonProperties, inputProperties, textAreaProperties, selectProperties, optionProperties, tableProperties, trProperties, thProperties, tdProperties, colGroupProperties, colProperties, fieldsetProperties, formProperties, iframeProperties, imgProperties, htmlElementProperties, getNativeProps, timeProperties, dialogProperties } from './properties';
|
3
3
|
const nativeElementMap = {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
4
|
+
label: labelProperties,
|
5
|
+
audio: audioProperties,
|
6
|
+
video: videoProperties,
|
7
|
+
ol: olProperties,
|
8
|
+
li: liProperties,
|
9
|
+
a: anchorProperties,
|
10
|
+
button: buttonProperties,
|
11
|
+
input: inputProperties,
|
12
|
+
textarea: textAreaProperties,
|
13
|
+
select: selectProperties,
|
14
|
+
option: optionProperties,
|
15
|
+
table: tableProperties,
|
16
|
+
tr: trProperties,
|
17
|
+
th: thProperties,
|
18
|
+
td: tdProperties,
|
19
|
+
colGroup: colGroupProperties,
|
20
|
+
col: colProperties,
|
21
|
+
fieldset: fieldsetProperties,
|
22
|
+
form: formProperties,
|
23
|
+
iframe: iframeProperties,
|
24
|
+
img: imgProperties,
|
25
|
+
time: timeProperties,
|
26
|
+
dialog: dialogProperties
|
27
27
|
};
|
28
28
|
/**
|
29
29
|
* Given an element tagname and user props, filters the props to only allowed props for the given
|
@@ -33,9 +33,9 @@ const nativeElementMap = {
|
|
33
33
|
* @param excludedPropNames - List of props to disallow
|
34
34
|
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
35
35
|
export function getNativeElementProps(tagName, props, excludedPropNames) {
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
const allowedPropNames = tagName && nativeElementMap[tagName] || htmlElementProperties;
|
37
|
+
allowedPropNames.as = 1;
|
38
|
+
return getNativeProps(props, allowedPropNames, excludedPropNames);
|
39
39
|
}
|
40
40
|
/**
|
41
41
|
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
@@ -44,18 +44,16 @@ export function getNativeElementProps(tagName, props, excludedPropNames) {
|
|
44
44
|
* Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
|
45
45
|
*
|
46
46
|
* @returns An object containing the native props for the `root` and primary slots.
|
47
|
-
*/
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
};
|
47
|
+
*/ export const getPartitionedNativeProps = ({ primarySlotTagName , props , excludedPropNames })=>{
|
48
|
+
return {
|
49
|
+
root: {
|
50
|
+
style: props.style,
|
51
|
+
className: props.className
|
52
|
+
},
|
53
|
+
primary: getNativeElementProps(primarySlotTagName, props, [
|
54
|
+
...excludedPropNames || [],
|
55
|
+
'style',
|
56
|
+
'className'
|
57
|
+
])
|
58
|
+
};
|
60
59
|
};
|
61
|
-
//# sourceMappingURL=getNativeElementProps.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["getNativeElementProps.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n labelProperties,\n audioProperties,\n videoProperties,\n olProperties,\n liProperties,\n anchorProperties,\n buttonProperties,\n inputProperties,\n textAreaProperties,\n selectProperties,\n optionProperties,\n tableProperties,\n trProperties,\n thProperties,\n tdProperties,\n colGroupProperties,\n colProperties,\n fieldsetProperties,\n formProperties,\n iframeProperties,\n imgProperties,\n htmlElementProperties,\n getNativeProps,\n timeProperties,\n dialogProperties,\n} from './properties';\n\nconst nativeElementMap: Record<string, Record<string, number>> = {\n label: labelProperties,\n audio: audioProperties,\n video: videoProperties,\n ol: olProperties,\n li: liProperties,\n a: anchorProperties,\n button: buttonProperties,\n input: inputProperties,\n textarea: textAreaProperties,\n select: selectProperties,\n option: optionProperties,\n table: tableProperties,\n tr: trProperties,\n th: thProperties,\n td: tdProperties,\n colGroup: colGroupProperties,\n col: colProperties,\n fieldset: fieldsetProperties,\n form: formProperties,\n iframe: iframeProperties,\n img: imgProperties,\n time: timeProperties,\n dialog: dialogProperties,\n};\n\n/**\n * Given an element tagname and user props, filters the props to only allowed props for the given\n * element type.\n * @param tagName - Tag name (e.g. \"div\")\n * @param props - Props object\n * @param excludedPropNames - List of props to disallow\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getNativeElementProps<TAttributes extends React.HTMLAttributes<any>>(\n tagName: string,\n props: {},\n excludedPropNames?: string[],\n): TAttributes {\n const allowedPropNames = (tagName && nativeElementMap[tagName]) || htmlElementProperties;\n allowedPropNames.as = 1;\n\n return getNativeProps(props, allowedPropNames, excludedPropNames);\n}\n\n/**\n * Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.\n *\n * This function is only for use with components that have a primary slot other than `root`.\n * Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.\n *\n * @returns An object containing the native props for the `root` and primary slots.\n */\nexport const getPartitionedNativeProps = <\n Props extends Pick<React.HTMLAttributes<HTMLElement>, 'style' | 'className'>,\n ExcludedPropKeys extends Extract<keyof Props, string> = never,\n>({\n primarySlotTagName,\n props,\n excludedPropNames,\n}: {\n /** The primary slot's element type (e.g. 'div') */\n primarySlotTagName: keyof JSX.IntrinsicElements;\n\n /** The component's props object */\n props: Props;\n\n /** List of native props to exclude from the returned value */\n excludedPropNames?: ExcludedPropKeys[];\n}) => {\n return {\n root: { style: props.style, className: props.className },\n primary: getNativeElementProps<Omit<Props, ExcludedPropKeys>>(primarySlotTagName, props, [\n ...(excludedPropNames || []),\n 'style',\n 'className',\n ]),\n };\n};\n"],"names":["React","labelProperties","audioProperties","videoProperties","olProperties","liProperties","anchorProperties","buttonProperties","inputProperties","textAreaProperties","selectProperties","optionProperties","tableProperties","trProperties","thProperties","tdProperties","colGroupProperties","colProperties","fieldsetProperties","formProperties","iframeProperties","imgProperties","htmlElementProperties","getNativeProps","timeProperties","dialogProperties","nativeElementMap","label","audio","video","ol","li","a","button","input","textarea","select","option","table","tr","th","td","colGroup","col","fieldset","form","iframe","img","time","dialog","getNativeElementProps","tagName","props","excludedPropNames","allowedPropNames","as","getPartitionedNativeProps","primarySlotTagName","root","style","className","primary"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,gBAAgB,EAChBC,gBAAgB,EAChBC,eAAe,EACfC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,EAChBC,eAAe,EACfC,YAAY,EACZC,YAAY,EACZC,YAAY,EACZC,kBAAkB,EAClBC,aAAa,EACbC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,aAAa,EACbC,qBAAqB,EACrBC,cAAc,EACdC,cAAc,EACdC,gBAAgB,QACX,eAAe;AAEtB,MAAMC,mBAA2D;IAC/DC,OAAO1B;IACP2B,OAAO1B;IACP2B,OAAO1B;IACP2B,IAAI1B;IACJ2B,IAAI1B;IACJ2B,GAAG1B;IACH2B,QAAQ1B;IACR2B,OAAO1B;IACP2B,UAAU1B;IACV2B,QAAQ1B;IACR2B,QAAQ1B;IACR2B,OAAO1B;IACP2B,IAAI1B;IACJ2B,IAAI1B;IACJ2B,IAAI1B;IACJ2B,UAAU1B;IACV2B,KAAK1B;IACL2B,UAAU1B;IACV2B,MAAM1B;IACN2B,QAAQ1B;IACR2B,KAAK1B;IACL2B,MAAMxB;IACNyB,QAAQxB;AACV;AAEA;;;;;;CAMC,GACD,8DAA8D;AAC9D,OAAO,SAASyB,sBACdC,OAAe,EACfC,KAAS,EACTC,iBAA4B,EACf;IACb,MAAMC,mBAAmB,AAACH,WAAWzB,gBAAgB,CAACyB,QAAQ,IAAK7B;IACnEgC,iBAAiBC,EAAE,GAAG;IAEtB,OAAOhC,eAAe6B,OAAOE,kBAAkBD;AACjD,CAAC;AAED;;;;;;;CAOC,GACD,OAAO,MAAMG,4BAA4B,CAGvC,EACAC,mBAAkB,EAClBL,MAAK,EACLC,kBAAiB,EAUlB,GAAK;IACJ,OAAO;QACLK,MAAM;YAAEC,OAAOP,MAAMO,KAAK;YAAEC,WAAWR,MAAMQ,SAAS;QAAC;QACvDC,SAASX,sBAAqDO,oBAAoBL,OAAO;eACnFC,qBAAqB,EAAE;YAC3B;YACA;SACD;IACH;AACF,EAAE"}
|
@@ -1,19 +1,18 @@
|
|
1
1
|
/**
|
2
2
|
* @internal
|
3
3
|
* Finds and swaps a provided key for it's right to left format.
|
4
|
-
*/export const getRTLSafeKey = (key, dir)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
*/ export const getRTLSafeKey = (key, dir)=>{
|
5
|
+
if (dir === 'rtl') {
|
6
|
+
switch(key){
|
7
|
+
case 'ArrowLeft':
|
8
|
+
{
|
9
|
+
return 'ArrowRight';
|
10
|
+
}
|
11
|
+
case 'ArrowRight':
|
12
|
+
{
|
13
|
+
return 'ArrowLeft';
|
14
|
+
}
|
14
15
|
}
|
15
16
|
}
|
16
|
-
|
17
|
-
return key;
|
17
|
+
return key;
|
18
18
|
};
|
19
|
-
//# sourceMappingURL=getRTLSafeKey.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["getRTLSafeKey.ts"],"sourcesContent":["/**\n * @internal\n * Finds and swaps a provided key for it's right to left format.\n */\nexport const getRTLSafeKey = (key: string, dir: 'ltr' | 'rtl') => {\n if (dir === 'rtl') {\n switch (key) {\n case 'ArrowLeft': {\n return 'ArrowRight';\n }\n\n case 'ArrowRight': {\n return 'ArrowLeft';\n }\n }\n }\n\n return key;\n};\n"],"names":["getRTLSafeKey","key","dir"],"mappings":"AAAA;;;CAGC,GACD,OAAO,MAAMA,gBAAgB,CAACC,KAAaC,MAAuB;IAChE,IAAIA,QAAQ,OAAO;QACjB,OAAQD;YACN,KAAK;gBAAa;oBAChB,OAAO;gBACT;YAEA,KAAK;gBAAc;oBACjB,OAAO;gBACT;QACF;IACF,CAAC;IAED,OAAOA;AACT,EAAE"}
|
@@ -5,20 +5,21 @@ import * as React from 'react';
|
|
5
5
|
* Ideally, it should also distinguish regular and "capture" callbacks, but it's possible only with React 17 as
|
6
6
|
* ".eventPhase" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events
|
7
7
|
* are handled in bubble phase.
|
8
|
-
*/
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
*/ export function getReactCallbackName(event) {
|
9
|
+
if (event._reactName) {
|
10
|
+
return event._reactName;
|
11
|
+
}
|
12
|
+
if (event.dispatchConfig) {
|
13
|
+
if (event.dispatchConfig.registrationName) {
|
14
|
+
return event.dispatchConfig.registrationName;
|
15
|
+
}
|
16
|
+
return event.dispatchConfig.phasedRegistrationNames.bubbled;
|
17
|
+
}
|
18
|
+
if (process.env.NODE_ENV !== 'production') {
|
19
|
+
// eslint-disable-next-line no-console
|
20
|
+
console.error([
|
21
|
+
'Passed React.SyntheticEvent does not contain ".dispatchConfig" or "._reactName".',
|
22
|
+
'This should not happen, please report it to https://github.com/microsoft/fluentui'
|
23
|
+
]);
|
16
24
|
}
|
17
|
-
return event.dispatchConfig.phasedRegistrationNames.bubbled;
|
18
|
-
}
|
19
|
-
if (process.env.NODE_ENV !== 'production') {
|
20
|
-
// eslint-disable-next-line no-console
|
21
|
-
console.error(['Passed React.SyntheticEvent does not contain ".dispatchConfig" or "._reactName".', 'This should not happen, please report it to https://github.com/microsoft/fluentui']);
|
22
|
-
}
|
23
25
|
}
|
24
|
-
//# sourceMappingURL=getReactCallbackName.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["getReactCallbackName.ts"],"sourcesContent":["import * as React from 'react';\n\ninterface ReactSyntheticEvent extends React.SyntheticEvent<unknown> {\n // React 17/18\n // See https://github.com/facebook/react/pull/19236\n _reactName?: string;\n\n // React 16\n dispatchConfig?: {\n registrationName: string;\n phasedRegistrationNames: {\n bubbled: string;\n captured: string;\n };\n };\n}\n\ntype NonUndefined<A> = A extends undefined ? never : A;\ntype FunctionKeys<T extends object> = {\n [K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never;\n}[keyof T];\n\nexport type ReactCallbackName = FunctionKeys<React.DOMAttributes<unknown>>;\n\n/**\n * React.SyntheticEvent contains name of a callback that should be fired, this function returns it.\n *\n * Ideally, it should also distinguish regular and \"capture\" callbacks, but it's possible only with React 17 as\n * \".eventPhase\" there has proper value, see https://github.com/facebook/react/pull/19244. In React 16 all events\n * are handled in bubble phase.\n */\nexport function getReactCallbackName(event: ReactSyntheticEvent): ReactCallbackName | undefined {\n if (event._reactName) {\n return event._reactName as ReactCallbackName;\n }\n\n if (event.dispatchConfig) {\n if (event.dispatchConfig.registrationName) {\n return event.dispatchConfig.registrationName as ReactCallbackName;\n }\n\n return event.dispatchConfig.phasedRegistrationNames.bubbled as ReactCallbackName;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error([\n 'Passed React.SyntheticEvent does not contain \".dispatchConfig\" or \"._reactName\".',\n 'This should not happen, please report it to https://github.com/microsoft/fluentui',\n ]);\n }\n}\n"],"names":["React","getReactCallbackName","event","_reactName","dispatchConfig","registrationName","phasedRegistrationNames","bubbled","process","env","NODE_ENV","console","error"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAwB/B;;;;;;CAMC,GACD,OAAO,SAASC,qBAAqBC,KAA0B,EAAiC;IAC9F,IAAIA,MAAMC,UAAU,EAAE;QACpB,OAAOD,MAAMC,UAAU;IACzB,CAAC;IAED,IAAID,MAAME,cAAc,EAAE;QACxB,IAAIF,MAAME,cAAc,CAACC,gBAAgB,EAAE;YACzC,OAAOH,MAAME,cAAc,CAACC,gBAAgB;QAC9C,CAAC;QAED,OAAOH,MAAME,cAAc,CAACE,uBAAuB,CAACC,OAAO;IAC7D,CAAC;IAED,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,sCAAsC;QACtCC,QAAQC,KAAK,CAAC;YACZ;YACA;SACD;IACH,CAAC;AACH,CAAC"}
|
package/lib/utils/index.js
CHANGED
package/lib/utils/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './clamp';\nexport * from './getNativeElementProps';\nexport * from './getRTLSafeKey';\nexport * from './mergeCallbacks';\nexport * from './omit';\nexport * from './properties';\nexport * from './isHTMLElement';\nexport * from './isInteractiveHTMLElement';\nexport * from './priorityQueue';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,0BAA0B;AACxC,cAAc,kBAAkB;AAChC,cAAc,mBAAmB;AACjC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cAAc,kBAAkB"}
|
@@ -11,10 +11,9 @@
|
|
11
11
|
* isHTMLElement(event.target, {constructorName: 'HTMLInputElement'}) && event.target.value // some value
|
12
12
|
* ```
|
13
13
|
*
|
14
|
-
*/export function isHTMLElement(element, options) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
*/ export function isHTMLElement(element, options) {
|
15
|
+
var _typedElement_ownerDocument;
|
16
|
+
const typedElement = element;
|
17
|
+
var _options_constructorName;
|
18
|
+
return Boolean((typedElement === null || typedElement === void 0 ? void 0 : (_typedElement_ownerDocument = typedElement.ownerDocument) === null || _typedElement_ownerDocument === void 0 ? void 0 : _typedElement_ownerDocument.defaultView) && typedElement instanceof typedElement.ownerDocument.defaultView[(_options_constructorName = options === null || options === void 0 ? void 0 : options.constructorName) !== null && _options_constructorName !== void 0 ? _options_constructorName : 'HTMLElement']);
|
19
19
|
}
|
20
|
-
//# sourceMappingURL=isHTMLElement.js.map
|