@fluentui/react-utilities 0.0.0-nightly-20230427-0418.1 → 0.0.0-nightly-20230428-0419.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 +5 -5
- package/CHANGELOG.md +5 -5
- package/package.json +2 -2
- package/dist/index.d.ts +0 -710
- package/lib/compose/constants.js +0 -5
- package/lib/compose/constants.js.map +0 -1
- package/lib/compose/getSlots.js +0 -58
- package/lib/compose/getSlots.js.map +0 -1
- package/lib/compose/getSlotsNext.js +0 -34
- package/lib/compose/getSlotsNext.js.map +0 -1
- package/lib/compose/index.js +0 -7
- package/lib/compose/index.js.map +0 -1
- package/lib/compose/isResolvedShorthand.js +0 -35
- package/lib/compose/isResolvedShorthand.js.map +0 -1
- package/lib/compose/resolveShorthand.js +0 -34
- package/lib/compose/resolveShorthand.js.map +0 -1
- package/lib/compose/types.js +0 -2
- package/lib/compose/types.js.map +0 -1
- package/lib/events/index.js +0 -2
- package/lib/events/index.js.map +0 -1
- package/lib/events/mouseTouchHelpers.js +0 -39
- package/lib/events/mouseTouchHelpers.js.map +0 -1
- package/lib/hooks/index.js +0 -13
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useControllableState.js +0 -49
- package/lib/hooks/useControllableState.js.map +0 -1
- package/lib/hooks/useEventCallback.js +0 -28
- package/lib/hooks/useEventCallback.js.map +0 -1
- package/lib/hooks/useFirstMount.js +0 -21
- package/lib/hooks/useFirstMount.js.map +0 -1
- package/lib/hooks/useForceUpdate.js +0 -9
- package/lib/hooks/useForceUpdate.js.map +0 -1
- package/lib/hooks/useId.js +0 -48
- package/lib/hooks/useId.js.map +0 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js +0 -13
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +0 -1
- package/lib/hooks/useMergedRefs.js +0 -25
- package/lib/hooks/useMergedRefs.js.map +0 -1
- package/lib/hooks/useOnClickOutside.js +0 -135
- package/lib/hooks/useOnClickOutside.js.map +0 -1
- package/lib/hooks/useOnScrollOutside.js +0 -36
- package/lib/hooks/useOnScrollOutside.js.map +0 -1
- package/lib/hooks/usePrevious.js +0 -12
- package/lib/hooks/usePrevious.js.map +0 -1
- package/lib/hooks/useScrollbarWidth.js +0 -30
- package/lib/hooks/useScrollbarWidth.js.map +0 -1
- package/lib/hooks/useTimeout.js +0 -28
- package/lib/hooks/useTimeout.js.map +0 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +0 -1
- package/lib/ssr/SSRContext.js +0 -60
- package/lib/ssr/SSRContext.js.map +0 -1
- package/lib/ssr/canUseDOM.js +0 -8
- package/lib/ssr/canUseDOM.js.map +0 -1
- package/lib/ssr/index.js +0 -3
- package/lib/ssr/index.js.map +0 -1
- package/lib/trigger/applyTriggerPropsToChildren.js +0 -33
- package/lib/trigger/applyTriggerPropsToChildren.js.map +0 -1
- package/lib/trigger/getTriggerChild.js +0 -34
- package/lib/trigger/getTriggerChild.js.map +0 -1
- package/lib/trigger/index.js +0 -5
- package/lib/trigger/index.js.map +0 -1
- package/lib/trigger/isFluentTrigger.js +0 -10
- package/lib/trigger/isFluentTrigger.js.map +0 -1
- package/lib/trigger/types.js +0 -2
- package/lib/trigger/types.js.map +0 -1
- package/lib/utils/clamp.js +0 -9
- package/lib/utils/clamp.js.map +0 -1
- package/lib/utils/getNativeElementProps.js +0 -61
- package/lib/utils/getNativeElementProps.js.map +0 -1
- package/lib/utils/getRTLSafeKey.js +0 -19
- package/lib/utils/getRTLSafeKey.js.map +0 -1
- package/lib/utils/getReactCallbackName.js +0 -24
- package/lib/utils/getReactCallbackName.js.map +0 -1
- package/lib/utils/index.js +0 -9
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/isHTMLElement.js +0 -20
- package/lib/utils/isHTMLElement.js.map +0 -1
- package/lib/utils/isInteractiveHTMLElement.js +0 -22
- package/lib/utils/isInteractiveHTMLElement.js.map +0 -1
- package/lib/utils/mergeCallbacks.js +0 -29
- package/lib/utils/mergeCallbacks.js.map +0 -1
- package/lib/utils/omit.js +0 -24
- package/lib/utils/omit.js.map +0 -1
- package/lib/utils/properties.js +0 -200
- package/lib/utils/properties.js.map +0 -1
@@ -1,135 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { useEventCallback } from './useEventCallback';
|
3
|
-
/**
|
4
|
-
* @internal
|
5
|
-
* Utility to perform checks where a click/touch event was made outside a component
|
6
|
-
*/
|
7
|
-
export const useOnClickOutside = options => {
|
8
|
-
const {
|
9
|
-
refs,
|
10
|
-
callback,
|
11
|
-
element,
|
12
|
-
disabled,
|
13
|
-
contains: containsProp
|
14
|
-
} = options;
|
15
|
-
const timeoutId = React.useRef(undefined);
|
16
|
-
useIFrameFocus(options);
|
17
|
-
const listener = useEventCallback(ev => {
|
18
|
-
const contains = containsProp || ((parent, child) => {
|
19
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
20
|
-
});
|
21
|
-
const isOutside = refs.every(ref => !contains(ref.current || null, ev.target));
|
22
|
-
if (isOutside && !disabled) {
|
23
|
-
callback(ev);
|
24
|
-
}
|
25
|
-
});
|
26
|
-
React.useEffect(() => {
|
27
|
-
if (disabled) {
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
// Store the current event to avoid triggering handlers immediately
|
31
|
-
// Note this depends on a deprecated but extremely well supported quirk of the web platform
|
32
|
-
// https://github.com/facebook/react/issues/20074
|
33
|
-
let currentEvent = getWindowEvent(window);
|
34
|
-
const conditionalHandler = event => {
|
35
|
-
// Skip if this event is the same as the one running when we added the handlers
|
36
|
-
if (event === currentEvent) {
|
37
|
-
currentEvent = undefined;
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
listener(event);
|
41
|
-
};
|
42
|
-
// use capture phase because React can update DOM before the event bubbles to the document
|
43
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);
|
44
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);
|
45
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);
|
46
|
-
// Garbage collect this event after it's no longer useful to avoid memory leaks
|
47
|
-
timeoutId.current = window.setTimeout(() => {
|
48
|
-
currentEvent = undefined;
|
49
|
-
}, 1);
|
50
|
-
return () => {
|
51
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);
|
52
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
|
53
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('contextmenu', conditionalHandler, true);
|
54
|
-
clearTimeout(timeoutId.current);
|
55
|
-
currentEvent = undefined;
|
56
|
-
};
|
57
|
-
}, [listener, element, disabled]);
|
58
|
-
};
|
59
|
-
const getWindowEvent = target => {
|
60
|
-
if (target) {
|
61
|
-
var _target_ownerDocument, _target_ownerDocument_defaultView;
|
62
|
-
if (typeof target.window === 'object' && target.window === target) {
|
63
|
-
// eslint-disable-next-line deprecation/deprecation
|
64
|
-
return target.event;
|
65
|
-
}
|
66
|
-
var _target_ownerDocument_defaultView_event;
|
67
|
-
// eslint-disable-next-line deprecation/deprecation
|
68
|
-
return (_target_ownerDocument_defaultView_event = (_target_ownerDocument = target.ownerDocument) === null || _target_ownerDocument === void 0 ? void 0 : (_target_ownerDocument_defaultView = _target_ownerDocument.defaultView) === null || _target_ownerDocument_defaultView === void 0 ? void 0 : _target_ownerDocument_defaultView.event) !== null && _target_ownerDocument_defaultView_event !== void 0 ? _target_ownerDocument_defaultView_event : undefined;
|
69
|
-
}
|
70
|
-
return undefined;
|
71
|
-
};
|
72
|
-
const FUI_FRAME_EVENT = 'fuiframefocus';
|
73
|
-
/**
|
74
|
-
* Since click events do not propagate past iframes, we use focus to detect if a
|
75
|
-
* click has happened inside an iframe, since the only ways of focusing inside an
|
76
|
-
* iframe are:
|
77
|
-
* - clicking inside
|
78
|
-
* - tabbing inside
|
79
|
-
*
|
80
|
-
* Polls the value of `document.activeElement`. If it is an iframe, then dispatch
|
81
|
-
* a custom DOM event. When the custom event is received call the provided callback
|
82
|
-
*/
|
83
|
-
const useIFrameFocus = options => {
|
84
|
-
const {
|
85
|
-
disabled,
|
86
|
-
element: targetDocument,
|
87
|
-
callback,
|
88
|
-
contains: containsProp = (parent, child) => {
|
89
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
90
|
-
},
|
91
|
-
pollDuration = 1000,
|
92
|
-
refs
|
93
|
-
} = options;
|
94
|
-
const timeoutRef = React.useRef();
|
95
|
-
const listener = useEventCallback(e => {
|
96
|
-
const contains = containsProp || ((parent, child) => {
|
97
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
98
|
-
});
|
99
|
-
const isOutside = refs.every(ref => !contains(ref.current || null, e.target));
|
100
|
-
if (isOutside && !disabled) {
|
101
|
-
callback(e);
|
102
|
-
}
|
103
|
-
});
|
104
|
-
// Adds listener to the custom iframe focus event
|
105
|
-
React.useEffect(() => {
|
106
|
-
if (disabled) {
|
107
|
-
return;
|
108
|
-
}
|
109
|
-
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);
|
110
|
-
return () => {
|
111
|
-
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener(FUI_FRAME_EVENT, listener, true);
|
112
|
-
};
|
113
|
-
}, [targetDocument, disabled, listener]);
|
114
|
-
// Starts polling for the active element
|
115
|
-
React.useEffect(() => {
|
116
|
-
var _targetDocument_defaultView;
|
117
|
-
if (disabled) {
|
118
|
-
return;
|
119
|
-
}
|
120
|
-
timeoutRef.current = targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.setInterval(() => {
|
121
|
-
const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
|
122
|
-
if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'IFRAME' || (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'WEBVIEW') {
|
123
|
-
const event = new CustomEvent(FUI_FRAME_EVENT, {
|
124
|
-
bubbles: true
|
125
|
-
});
|
126
|
-
activeElement.dispatchEvent(event);
|
127
|
-
}
|
128
|
-
}, pollDuration);
|
129
|
-
return () => {
|
130
|
-
var _targetDocument_defaultView;
|
131
|
-
targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.clearTimeout(timeoutRef.current);
|
132
|
-
};
|
133
|
-
}, [targetDocument, disabled, pollDuration]);
|
134
|
-
};
|
135
|
-
//# sourceMappingURL=useOnClickOutside.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","useEventCallback","useOnClickOutside","options","refs","callback","element","disabled","contains","containsProp","timeoutId","useRef","undefined","useIFrameFocus","listener","ev","parent","child","isOutside","every","ref","current","target","useEffect","currentEvent","getWindowEvent","window","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","_target_ownerDocument","_target_ownerDocument_defaultView","_target_ownerDocument_defaultView_event","ownerDocument","defaultView","FUI_FRAME_EVENT","targetDocument","pollDuration","timeoutRef","e","_targetDocument_defaultView","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"sources":["../../src/hooks/useOnClickOutside.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n\n/**\n * @internal\n */\nexport type UseOnClickOrScrollOutsideOptions = {\n /**\n * The element to listen for the click event\n */\n element: Document | undefined;\n /**\n * Refs to elements that check if the click is outside\n */\n refs: React.MutableRefObject<HTMLElement | undefined | null>[];\n\n /**\n * By default uses element.contains, but custom contain function can be provided\n *\n * @param parent - provided parent element\n * @param child - event target element\n */\n contains?(parent: HTMLElement | null, child: HTMLElement): boolean;\n\n /**\n * Disables event listeners\n */\n disabled?: boolean;\n\n /**\n * Called if the click is outside the element refs\n */\n callback: (ev: MouseEvent | TouchEvent) => void;\n};\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnClickOutside = (options: UseOnClickOrScrollOutsideOptions) => {\n const { refs, callback, element, disabled, contains: containsProp } = options;\n const timeoutId = React.useRef<number | undefined>(undefined);\n useIFrameFocus(options);\n\n const listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n const contains: UseOnClickOrScrollOutsideOptions['contains'] =\n containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, ev.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n // Store the current event to avoid triggering handlers immediately\n // Note this depends on a deprecated but extremely well supported quirk of the web platform\n // https://github.com/facebook/react/issues/20074\n let currentEvent = getWindowEvent(window);\n\n const conditionalHandler = (event: MouseEvent | TouchEvent) => {\n // Skip if this event is the same as the one running when we added the handlers\n if (event === currentEvent) {\n currentEvent = undefined;\n return;\n }\n\n listener(event);\n };\n\n // use capture phase because React can update DOM before the event bubbles to the document\n element?.addEventListener('click', conditionalHandler, true);\n element?.addEventListener('touchstart', conditionalHandler, true);\n element?.addEventListener('contextmenu', conditionalHandler, true);\n\n // Garbage collect this event after it's no longer useful to avoid memory leaks\n timeoutId.current = window.setTimeout(() => {\n currentEvent = undefined;\n }, 1);\n\n return () => {\n element?.removeEventListener('click', conditionalHandler, true);\n element?.removeEventListener('touchstart', conditionalHandler, true);\n element?.removeEventListener('contextmenu', conditionalHandler, true);\n\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [listener, element, disabled]);\n};\n\nconst getWindowEvent = (target: Node | Window): Event | undefined => {\n if (target) {\n if (typeof (target as Window).window === 'object' && (target as Window).window === target) {\n // eslint-disable-next-line deprecation/deprecation\n return target.event;\n }\n\n // eslint-disable-next-line deprecation/deprecation\n return (target as Node).ownerDocument?.defaultView?.event ?? undefined;\n }\n\n return undefined;\n};\n\nconst FUI_FRAME_EVENT = 'fuiframefocus';\n\ninterface UseIFrameFocusOptions extends UseOnClickOrScrollOutsideOptions {\n /**\n * Millisecond duration to poll\n */\n pollDuration?: number;\n}\n\n/**\n * Since click events do not propagate past iframes, we use focus to detect if a\n * click has happened inside an iframe, since the only ways of focusing inside an\n * iframe are:\n * - clicking inside\n * - tabbing inside\n *\n * Polls the value of `document.activeElement`. If it is an iframe, then dispatch\n * a custom DOM event. When the custom event is received call the provided callback\n */\nconst useIFrameFocus = (options: UseIFrameFocusOptions) => {\n const {\n disabled,\n element: targetDocument,\n callback,\n contains: containsProp = (parent, child) => !!parent?.contains(child),\n pollDuration = 1000,\n refs,\n } = options;\n const timeoutRef = React.useRef<number>();\n\n const listener = useEventCallback((e: Event) => {\n const contains = containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, e.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(e as MouseEvent);\n }\n });\n\n // Adds listener to the custom iframe focus event\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n targetDocument?.addEventListener(FUI_FRAME_EVENT, listener, true);\n\n return () => {\n targetDocument?.removeEventListener(FUI_FRAME_EVENT, listener, true);\n };\n }, [targetDocument, disabled, listener]);\n\n // Starts polling for the active element\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n timeoutRef.current = targetDocument?.defaultView?.setInterval(() => {\n const activeElement = targetDocument?.activeElement;\n\n if (activeElement?.tagName === 'IFRAME' || activeElement?.tagName === 'WEBVIEW') {\n const event = new CustomEvent(FUI_FRAME_EVENT, { bubbles: true });\n activeElement.dispatchEvent(event);\n }\n }, pollDuration);\n\n return () => {\n targetDocument?.defaultView?.clearTimeout(timeoutRef.current);\n };\n }, [targetDocument, disabled, pollDuration]);\n};\n"],"mappings":"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"}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { useEventCallback } from './useEventCallback';
|
3
|
-
/**
|
4
|
-
* @internal
|
5
|
-
* Utility to perform checks where a click/touch event was made outside a component
|
6
|
-
*/
|
7
|
-
export const useOnScrollOutside = options => {
|
8
|
-
const {
|
9
|
-
refs,
|
10
|
-
callback,
|
11
|
-
element,
|
12
|
-
disabled,
|
13
|
-
contains: containsProp
|
14
|
-
} = options;
|
15
|
-
const listener = useEventCallback(ev => {
|
16
|
-
const contains = containsProp || ((parent, child) => {
|
17
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
18
|
-
});
|
19
|
-
const isOutside = refs.every(ref => !contains(ref.current || null, ev.target));
|
20
|
-
if (isOutside && !disabled) {
|
21
|
-
callback(ev);
|
22
|
-
}
|
23
|
-
});
|
24
|
-
React.useEffect(() => {
|
25
|
-
if (disabled) {
|
26
|
-
return;
|
27
|
-
}
|
28
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('wheel', listener);
|
29
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('touchmove', listener);
|
30
|
-
return () => {
|
31
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('wheel', listener);
|
32
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('touchmove', listener);
|
33
|
-
};
|
34
|
-
}, [listener, element, disabled]);
|
35
|
-
};
|
36
|
-
//# sourceMappingURL=useOnScrollOutside.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","useEventCallback","useOnScrollOutside","options","refs","callback","element","disabled","contains","containsProp","listener","ev","parent","child","isOutside","every","ref","current","target","useEffect","addEventListener","removeEventListener"],"sources":["../../src/hooks/useOnScrollOutside.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\nimport type { UseOnClickOrScrollOutsideOptions } from './useOnClickOutside';\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnScrollOutside = (options: UseOnClickOrScrollOutsideOptions) => {\n const { refs, callback, element, disabled, contains: containsProp } = options;\n\n const listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n const contains: UseOnClickOrScrollOutsideOptions['contains'] =\n containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, ev.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n element?.addEventListener('wheel', listener);\n element?.addEventListener('touchmove', listener);\n\n return () => {\n element?.removeEventListener('wheel', listener);\n element?.removeEventListener('touchmove', listener);\n };\n }, [listener, element, disabled]);\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAgB,QAAQ;AAGjC;;;;AAIA,OAAO,MAAMC,kBAAA,GAAsBC,OAAA,IAA8C;EAC/E,MAAM;IAAEC,IAAA;IAAMC,QAAA;IAAUC,OAAA;IAASC,QAAA;IAAUC,QAAA,EAAUC;EAAY,CAAE,GAAGN,OAAA;EAEtE,MAAMO,QAAA,GAAWT,gBAAA,CAAkBU,EAAA,IAAgC;IACjE,MAAMH,QAAA,GACJC,YAAA,KAAiB,CAACG,MAAA,EAAQC,KAAA;MAAU,QAAC,EAACD,MAAA,aAAAA,MAAA,uBAAAA,MAAA,CAAQJ,QAAQ,CAACK,KAAA;KAAK;IAE9D,MAAMC,SAAA,GAAYV,IAAA,CAAKW,KAAK,CAACC,GAAA,IAAO,CAACR,QAAA,CAASQ,GAAA,CAAIC,OAAO,IAAI,IAAI,EAAEN,EAAA,CAAGO,MAAM;IAC5E,IAAIJ,SAAA,IAAa,CAACP,QAAA,EAAU;MAC1BF,QAAA,CAASM,EAAA;IACX;EACF;EAEAX,KAAA,CAAMmB,SAAS,CAAC,MAAM;IACpB,IAAIZ,QAAA,EAAU;MACZ;IACF;IAEAD,OAAA,aAAAA,OAAA,uBAAAA,OAAA,CAASc,gBAAgB,CAAC,SAASV,QAAA;IACnCJ,OAAA,aAAAA,OAAA,uBAAAA,OAAA,CAASc,gBAAgB,CAAC,aAAaV,QAAA;IAEvC,OAAO,MAAM;MACXJ,OAAA,aAAAA,OAAA,uBAAAA,OAAA,CAASe,mBAAmB,CAAC,SAASX,QAAA;MACtCJ,OAAA,aAAAA,OAAA,uBAAAA,OAAA,CAASe,mBAAmB,CAAC,aAAaX,QAAA;IAC5C;EACF,GAAG,CAACA,QAAA,EAAUJ,OAAA,EAASC,QAAA,CAAS;AAClC"}
|
package/lib/hooks/usePrevious.js
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* @internal
|
4
|
-
*/
|
5
|
-
export const usePrevious = value => {
|
6
|
-
const ref = React.useRef(null);
|
7
|
-
React.useEffect(() => {
|
8
|
-
ref.current = value;
|
9
|
-
}, [value]);
|
10
|
-
return ref.current;
|
11
|
-
};
|
12
|
-
//# sourceMappingURL=usePrevious.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","usePrevious","value","ref","useRef","useEffect","current"],"sources":["../../src/hooks/usePrevious.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n */\nexport const usePrevious = <ValueType = unknown>(value: ValueType) => {\n const ref = React.useRef<ValueType | null>(null);\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref.current;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB;;;AAGA,OAAO,MAAMC,WAAA,GAAoCC,KAAA,IAAqB;EACpE,MAAMC,GAAA,GAAMH,KAAA,CAAMI,MAAM,CAAmB,IAAI;EAC/CJ,KAAA,CAAMK,SAAS,CAAC,MAAM;IACpBF,GAAA,CAAIG,OAAO,GAAGJ,KAAA;EAChB,GAAG,CAACA,KAAA,CAAM;EACV,OAAOC,GAAA,CAAIG,OAAO;AACpB"}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
const cache = /*#__PURE__*/new WeakMap();
|
3
|
-
/**
|
4
|
-
* @returns The width in pixels of the scrollbar in the user agent
|
5
|
-
*/
|
6
|
-
export function useScrollbarWidth(options) {
|
7
|
-
const {
|
8
|
-
targetDocument,
|
9
|
-
force
|
10
|
-
} = options;
|
11
|
-
return React.useMemo(() => {
|
12
|
-
if (!targetDocument) {
|
13
|
-
return 0;
|
14
|
-
}
|
15
|
-
if (!force && cache.has(targetDocument)) {
|
16
|
-
return cache.get(targetDocument);
|
17
|
-
}
|
18
|
-
const outer = targetDocument.createElement('div');
|
19
|
-
outer.style.visibility = 'hidden';
|
20
|
-
outer.style.overflow = 'scroll';
|
21
|
-
const inner = targetDocument.createElement('div');
|
22
|
-
outer.appendChild(inner);
|
23
|
-
targetDocument.body.appendChild(outer);
|
24
|
-
const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
|
25
|
-
outer.remove();
|
26
|
-
cache.set(targetDocument, scrollbarWidth);
|
27
|
-
return scrollbarWidth;
|
28
|
-
}, [targetDocument, force]);
|
29
|
-
}
|
30
|
-
//# sourceMappingURL=useScrollbarWidth.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","cache","WeakMap","useScrollbarWidth","options","targetDocument","force","useMemo","has","get","outer","createElement","style","visibility","overflow","inner","appendChild","body","scrollbarWidth","offsetWidth","remove","set"],"sources":["../../src/hooks/useScrollbarWidth.ts"],"sourcesContent":["import * as React from 'react';\n\nconst cache = new WeakMap<Document, number>();\n\ninterface UseScrollbarWidthOptions {\n /**\n * Reference document to measure the scrollbar width\n */\n targetDocument: Document | null | undefined;\n\n /**\n * Does not use the cache and recalculates the scrollbar width\n */\n force?: boolean;\n}\n\n/**\n * @returns The width in pixels of the scrollbar in the user agent\n */\nexport function useScrollbarWidth(options: UseScrollbarWidthOptions) {\n const { targetDocument, force } = options;\n return React.useMemo(() => {\n if (!targetDocument) {\n return 0;\n }\n\n if (!force && cache.has(targetDocument)) {\n return cache.get(targetDocument);\n }\n\n const outer = targetDocument.createElement('div');\n outer.style.visibility = 'hidden';\n outer.style.overflow = 'scroll';\n\n const inner = targetDocument.createElement('div');\n outer.appendChild(inner);\n\n targetDocument.body.appendChild(outer);\n const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;\n outer.remove();\n cache.set(targetDocument, scrollbarWidth);\n return scrollbarWidth;\n }, [targetDocument, force]);\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB,MAAMC,KAAA,gBAAQ,IAAIC,OAAA;AAclB;;;AAGA,OAAO,SAASC,kBAAkBC,OAAiC,EAAE;EACnE,MAAM;IAAEC,cAAA;IAAgBC;EAAK,CAAE,GAAGF,OAAA;EAClC,OAAOJ,KAAA,CAAMO,OAAO,CAAC,MAAM;IACzB,IAAI,CAACF,cAAA,EAAgB;MACnB,OAAO;IACT;IAEA,IAAI,CAACC,KAAA,IAASL,KAAA,CAAMO,GAAG,CAACH,cAAA,GAAiB;MACvC,OAAOJ,KAAA,CAAMQ,GAAG,CAACJ,cAAA;IACnB;IAEA,MAAMK,KAAA,GAAQL,cAAA,CAAeM,aAAa,CAAC;IAC3CD,KAAA,CAAME,KAAK,CAACC,UAAU,GAAG;IACzBH,KAAA,CAAME,KAAK,CAACE,QAAQ,GAAG;IAEvB,MAAMC,KAAA,GAAQV,cAAA,CAAeM,aAAa,CAAC;IAC3CD,KAAA,CAAMM,WAAW,CAACD,KAAA;IAElBV,cAAA,CAAeY,IAAI,CAACD,WAAW,CAACN,KAAA;IAChC,MAAMQ,cAAA,GAAiBR,KAAA,CAAMS,WAAW,GAAGJ,KAAA,CAAMI,WAAW;IAC5DT,KAAA,CAAMU,MAAM;IACZnB,KAAA,CAAMoB,GAAG,CAAChB,cAAA,EAAgBa,cAAA;IAC1B,OAAOA,cAAA;EACT,GAAG,CAACb,cAAA,EAAgBC,KAAA,CAAM;AAC5B"}
|
package/lib/hooks/useTimeout.js
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* @internal
|
4
|
-
* Helper to manage a browser timeout.
|
5
|
-
* Ensures that the timeout isn't set multiple times at once,
|
6
|
-
* and is cleaned up when the component is unloaded.
|
7
|
-
*
|
8
|
-
* @returns A pair of [setTimeout, clearTimeout] that are stable between renders.
|
9
|
-
*/
|
10
|
-
export function useTimeout() {
|
11
|
-
const [timeout] = React.useState(() => ({
|
12
|
-
id: undefined,
|
13
|
-
set: (fn, delay) => {
|
14
|
-
timeout.clear();
|
15
|
-
timeout.id = setTimeout(fn, delay);
|
16
|
-
},
|
17
|
-
clear: () => {
|
18
|
-
if (timeout.id !== undefined) {
|
19
|
-
clearTimeout(timeout.id);
|
20
|
-
timeout.id = undefined;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}));
|
24
|
-
// Clean up the timeout when the component is unloaded
|
25
|
-
React.useEffect(() => timeout.clear, [timeout]);
|
26
|
-
return [timeout.set, timeout.clear];
|
27
|
-
}
|
28
|
-
//# sourceMappingURL=useTimeout.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","useTimeout","timeout","useState","id","undefined","set","fn","delay","clear","setTimeout","clearTimeout","useEffect"],"sources":["../../src/hooks/useTimeout.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */\nexport function useTimeout() {\n const [timeout] = React.useState(() => ({\n id: undefined as ReturnType<typeof setTimeout> | undefined,\n set: (fn: () => void, delay: number) => {\n timeout.clear();\n timeout.id = setTimeout(fn, delay);\n },\n clear: () => {\n if (timeout.id !== undefined) {\n clearTimeout(timeout.id);\n timeout.id = undefined;\n }\n },\n }));\n\n // Clean up the timeout when the component is unloaded\n React.useEffect(() => timeout.clear, [timeout]);\n\n return [timeout.set, timeout.clear] as const;\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB;;;;;;;;AAQA,OAAO,SAASC,WAAA,EAAa;EAC3B,MAAM,CAACC,OAAA,CAAQ,GAAGF,KAAA,CAAMG,QAAQ,CAAC,OAAO;IACtCC,EAAA,EAAIC,SAAA;IACJC,GAAA,EAAKA,CAACC,EAAA,EAAgBC,KAAA,KAAkB;MACtCN,OAAA,CAAQO,KAAK;MACbP,OAAA,CAAQE,EAAE,GAAGM,UAAA,CAAWH,EAAA,EAAIC,KAAA;IAC9B;IACAC,KAAA,EAAOA,CAAA,KAAM;MACX,IAAIP,OAAA,CAAQE,EAAE,KAAKC,SAAA,EAAW;QAC5BM,YAAA,CAAaT,OAAA,CAAQE,EAAE;QACvBF,OAAA,CAAQE,EAAE,GAAGC,SAAA;MACf;IACF;EACF;EAEA;EACAL,KAAA,CAAMY,SAAS,CAAC,MAAMV,OAAA,CAAQO,KAAK,EAAE,CAACP,OAAA,CAAQ;EAE9C,OAAO,CAACA,OAAA,CAAQI,GAAG,EAAEJ,OAAA,CAAQO,KAAK,CAAC;AACrC"}
|
package/lib/index.js
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
export { getSlots, getSlotsNext, resolveShorthand, isResolvedShorthand, SLOT_RENDER_FUNCTION_SYMBOL } from './compose/index';
|
2
|
-
export { IdPrefixProvider, resetIdsForTests, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';
|
3
|
-
export { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';
|
4
|
-
export { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit } from './utils/index';
|
5
|
-
export { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';
|
6
|
-
export { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["getSlots","getSlotsNext","resolveShorthand","isResolvedShorthand","SLOT_RENDER_FUNCTION_SYMBOL","IdPrefixProvider","resetIdsForTests","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords"],"sources":["../src/index.ts"],"sourcesContent":["export {\n getSlots,\n getSlotsNext,\n resolveShorthand,\n isResolvedShorthand,\n SLOT_RENDER_FUNCTION_SYMBOL,\n} from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n} from './utils/index';\n\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\n\nexport type { FluentTriggerComponent, TriggerProps } from './trigger/index';\n\n/**\n * Event utils\n */\nexport type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './events/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n"],"mappings":"AAAA,SACEA,QAAQ,EACRC,YAAY,EACZC,gBAAgB,EAChBC,mBAAmB,EACnBC,2BAA2B,QACtB;AAiBP,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,WAAW,EACXC,iBAAiB,EACjBC,UAAU,QACL;AAGP,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ;AAEjD,SACEC,KAAK,EACLC,qBAAqB,EACrBC,yBAAyB,EACzBC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,wBAAwB,EACxBC,IAAI,QACC;AAEP,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,eAAe,QAAQ;AAQ9E,SAASC,YAAY,EAAEC,YAAY,EAAEC,oBAAoB,QAAQ"}
|
package/lib/ssr/SSRContext.js
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { canUseDOM } from './canUseDOM';
|
3
|
-
/**
|
4
|
-
* Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
|
5
|
-
*
|
6
|
-
* @internal
|
7
|
-
*/
|
8
|
-
export const defaultSSRContextValue = {
|
9
|
-
current: 0
|
10
|
-
};
|
11
|
-
export const SSRContext = /*#__PURE__*/React.createContext(undefined);
|
12
|
-
/**
|
13
|
-
* @internal
|
14
|
-
*/
|
15
|
-
export function useSSRContext() {
|
16
|
-
var _React_useContext;
|
17
|
-
return (_React_useContext = React.useContext(SSRContext)) !== null && _React_useContext !== void 0 ? _React_useContext : defaultSSRContextValue;
|
18
|
-
}
|
19
|
-
/**
|
20
|
-
* When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
|
21
|
-
* are consistent between the client and server.
|
22
|
-
*
|
23
|
-
* @public
|
24
|
-
*/
|
25
|
-
export const SSRProvider = props => {
|
26
|
-
const [value] = React.useState(() => ({
|
27
|
-
current: 0
|
28
|
-
}));
|
29
|
-
return /*#__PURE__*/React.createElement(SSRContext.Provider, {
|
30
|
-
value: value
|
31
|
-
}, props.children);
|
32
|
-
};
|
33
|
-
/**
|
34
|
-
* Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay
|
35
|
-
* browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.
|
36
|
-
*/
|
37
|
-
export function useIsSSR() {
|
38
|
-
const isInSSRContext = useSSRContext() !== defaultSSRContextValue;
|
39
|
-
const [isSSR, setIsSSR] = React.useState(isInSSRContext);
|
40
|
-
// If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the
|
41
|
-
// developer to add one.
|
42
|
-
if (process.env.NODE_ENV !== 'production') {
|
43
|
-
if (!isInSSRContext && !canUseDOM()) {
|
44
|
-
// eslint-disable-next-line no-console
|
45
|
-
console.error(['@fluentui/react-components: ', 'When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' + 'generated between the client and server.', '\n', '\n', 'Check documentation at https://aka.ms/fluentui-ssr'].join(''));
|
46
|
-
}
|
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;
|
59
|
-
}
|
60
|
-
//# sourceMappingURL=SSRContext.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","canUseDOM","defaultSSRContextValue","current","SSRContext","createContext","undefined","useSSRContext","_React_useContext","useContext","SSRProvider","props","value","useState","createElement","Provider","children","useIsSSR","isInSSRContext","isSSR","setIsSSR","process","env","NODE_ENV","console","error","join","useLayoutEffect"],"sources":["../../src/ssr/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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,SAAS,QAAQ;AAY1B;;;;;AAKA,OAAO,MAAMC,sBAAA,GAA0C;EACrDC,OAAA,EAAS;AACX;AAEA,OAAO,MAAMC,UAAA,gBAAaJ,KAAA,CAAMK,aAAa,CAA8BC,SAAA;AAE3E;;;AAGA,OAAO,SAASC,cAAA,EAAiC;MACxCC,iBAAA;EAAP,OAAO,CAAAA,iBAAA,GAAAR,KAAA,CAAMS,UAAU,CAACL,UAAA,eAAjBI,iBAAA,cAAAA,iBAAA,GAAgCN,sBAAsB;AAC/D;AAEA;;;;;;AAMA,OAAO,MAAMQ,WAAA,GAAuDC,KAAA,IAAS;EAC3E,MAAM,CAACC,KAAA,CAAM,GAAGZ,KAAA,CAAMa,QAAQ,CAAkB,OAAO;IAAEV,OAAA,EAAS;EAAE;EAEpE,oBAAOH,KAAA,CAAAc,aAAA,CAACV,UAAA,CAAWW,QAAQ;IAACH,KAAA,EAAOA;KAAQD,KAAA,CAAMK,QAAQ;AAC3D;AAEA;;;;AAIA,OAAO,SAASC,SAAA,EAAoB;EAClC,MAAMC,cAAA,GAAiBX,aAAA,OAAoBL,sBAAA;EAC3C,MAAM,CAACiB,KAAA,EAAOC,QAAA,CAAS,GAAGpB,KAAA,CAAMa,QAAQ,CAACK,cAAA;EAEzC;EACA;EACA,IAAIG,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACzC,IAAI,CAACL,cAAA,IAAkB,CAACjB,SAAA,IAAa;MACnC;MACAuB,OAAA,CAAQC,KAAK,CACX,CACE,gCACA,4GACE,4CACF,MACA,MACA,qDACD,CAACC,IAAI,CAAC;IAEX;EACF;EAEA;EACA;EACA,IAAIzB,SAAA,MAAeiB,cAAA,EAAgB;IACjC;IACA;IACA;IACAlB,KAAA,CAAM2B,eAAe,CAAC,MAAM;MAC1BP,QAAA,CAAS,KAAK;IAChB,GAAG,EAAE;EACP;EAEA,OAAOD,KAAA;AACT"}
|
package/lib/ssr/canUseDOM.js
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Verifies if an application can use DOM.
|
3
|
-
*/export function canUseDOM() {
|
4
|
-
return typeof window !== 'undefined' && !!(window.document &&
|
5
|
-
// eslint-disable-next-line deprecation/deprecation
|
6
|
-
window.document.createElement);
|
7
|
-
}
|
8
|
-
//# sourceMappingURL=canUseDOM.js.map
|
package/lib/ssr/canUseDOM.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["canUseDOM","window","document","createElement"],"sources":["../../src/ssr/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"],"mappings":"AAAA;;GAGA,OAAO,SAASA,UAAA,EAAqB;EACnC,OACE,OAAOC,MAAA,KAAW,eAClB,CAAC,EACCA,MAAA,CAAOC,QAAQ;EACf;EACAD,MAAA,CAAOC,QAAQ,CAACC,aAAa,CAAD;AAGlC"}
|
package/lib/ssr/index.js
DELETED
package/lib/ssr/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/ssr/index.ts"],"sourcesContent":["export * from './canUseDOM';\nexport * from './SSRContext';\n"],"mappings":"AAAA,cAAc;AACd,cAAc"}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { isFluentTrigger } from './isFluentTrigger';
|
3
|
-
/**
|
4
|
-
* @internal
|
5
|
-
* resolve the trigger props to the children, either by calling the render function, or cloning with the new props.
|
6
|
-
*/
|
7
|
-
export function applyTriggerPropsToChildren(children, triggerChildProps) {
|
8
|
-
if (typeof children === 'function') {
|
9
|
-
return children(triggerChildProps);
|
10
|
-
} else if (children) {
|
11
|
-
return cloneTriggerTree(children, triggerChildProps);
|
12
|
-
}
|
13
|
-
// Components in React should return either JSX elements or "null", otherwise React will throw:
|
14
|
-
// Nothing was returned from render.
|
15
|
-
// This usually means a return statement is missing. Or, to render nothing, return null.
|
16
|
-
return children || null;
|
17
|
-
}
|
18
|
-
/**
|
19
|
-
* Clones a React element tree, and applies the given props to the first grandchild that is not
|
20
|
-
* a FluentTriggerComponent or React Fragment (the same element returned by {@link getTriggerChild}).
|
21
|
-
*/
|
22
|
-
function cloneTriggerTree(child, triggerProps) {
|
23
|
-
if (! /*#__PURE__*/React.isValidElement(child) || child.type === React.Fragment) {
|
24
|
-
throw new Error('A trigger element must be a single element for this component. ' + "Please ensure that you're not using React Fragments.");
|
25
|
-
}
|
26
|
-
if (isFluentTrigger(child)) {
|
27
|
-
const grandchild = cloneTriggerTree(child.props.children, triggerProps);
|
28
|
-
return /*#__PURE__*/React.cloneElement(child, undefined, grandchild);
|
29
|
-
} else {
|
30
|
-
return /*#__PURE__*/React.cloneElement(child, triggerProps);
|
31
|
-
}
|
32
|
-
}
|
33
|
-
//# sourceMappingURL=applyTriggerPropsToChildren.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","isFluentTrigger","applyTriggerPropsToChildren","children","triggerChildProps","cloneTriggerTree","child","triggerProps","isValidElement","type","Fragment","Error","grandchild","props","cloneElement","undefined"],"sources":["../../src/trigger/applyTriggerPropsToChildren.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * resolve the trigger props to the children, either by calling the render function, or cloning with the new props.\n */\nexport function applyTriggerPropsToChildren<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n triggerChildProps: TriggerChildProps,\n): React.ReactElement | null {\n if (typeof children === 'function') {\n return children(triggerChildProps);\n } else if (children) {\n return cloneTriggerTree(children, triggerChildProps);\n }\n\n // Components in React should return either JSX elements or \"null\", otherwise React will throw:\n // Nothing was returned from render.\n // This usually means a return statement is missing. Or, to render nothing, return null.\n return children || null;\n}\n\n/**\n * Clones a React element tree, and applies the given props to the first grandchild that is not\n * a FluentTriggerComponent or React Fragment (the same element returned by {@link getTriggerChild}).\n */\nfunction cloneTriggerTree<TriggerChildProps>(\n child: React.ReactNode,\n triggerProps: TriggerChildProps,\n): React.ReactElement {\n if (!React.isValidElement(child) || child.type === React.Fragment) {\n throw new Error(\n 'A trigger element must be a single element for this component. ' +\n \"Please ensure that you're not using React Fragments.\",\n );\n }\n\n if (isFluentTrigger(child)) {\n const grandchild = cloneTriggerTree(child.props.children, triggerProps);\n return React.cloneElement(child, undefined, grandchild);\n } else {\n return React.cloneElement(child, triggerProps as TriggerChildProps & React.Attributes);\n }\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,eAAe,QAAQ;AAGhC;;;;AAIA,OAAO,SAASC,4BACdC,QAAqD,EACrDC,iBAAoC,EACT;EAC3B,IAAI,OAAOD,QAAA,KAAa,YAAY;IAClC,OAAOA,QAAA,CAASC,iBAAA;EAClB,OAAO,IAAID,QAAA,EAAU;IACnB,OAAOE,gBAAA,CAAiBF,QAAA,EAAUC,iBAAA;EACpC;EAEA;EACA;EACA;EACA,OAAOD,QAAA,IAAY,IAAI;AACzB;AAEA;;;;AAIA,SAASE,iBACPC,KAAsB,EACtBC,YAA+B,EACX;EACpB,IAAI,eAACP,KAAA,CAAMQ,cAAc,CAACF,KAAA,KAAUA,KAAA,CAAMG,IAAI,KAAKT,KAAA,CAAMU,QAAQ,EAAE;IACjE,MAAM,IAAIC,KAAA,CACR,oEACE;EAEN;EAEA,IAAIV,eAAA,CAAgBK,KAAA,GAAQ;IAC1B,MAAMM,UAAA,GAAaP,gBAAA,CAAiBC,KAAA,CAAMO,KAAK,CAACV,QAAQ,EAAEI,YAAA;IAC1D,oBAAOP,KAAA,CAAMc,YAAY,CAACR,KAAA,EAAOS,SAAA,EAAWH,UAAA;EAC9C,OAAO;IACL,oBAAOZ,KAAA,CAAMc,YAAY,CAACR,KAAA,EAAOC,YAAA;EACnC;AACF"}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
import { isFluentTrigger } from './isFluentTrigger';
|
3
|
-
/**
|
4
|
-
* @internal
|
5
|
-
* Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).
|
6
|
-
*
|
7
|
-
* In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,
|
8
|
-
* it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.
|
9
|
-
* This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.
|
10
|
-
*
|
11
|
-
* For example, the following returns `<div id="child" />`:
|
12
|
-
* ```jsx
|
13
|
-
* getTriggerChild(
|
14
|
-
* <Tooltip>
|
15
|
-
* <MenuTrigger>
|
16
|
-
* <div id="child" />
|
17
|
-
* </MenuTrigger>
|
18
|
-
* </Tooltip>
|
19
|
-
* );
|
20
|
-
* ```
|
21
|
-
*
|
22
|
-
* In the case where the immediate child is not a valid element,
|
23
|
-
* null is returned
|
24
|
-
*/
|
25
|
-
export function getTriggerChild(children) {
|
26
|
-
if (! /*#__PURE__*/React.isValidElement(children)) {
|
27
|
-
return null;
|
28
|
-
}
|
29
|
-
return isFluentTrigger(children) ? getTriggerChild(
|
30
|
-
// FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,
|
31
|
-
// but for some reason it's failing on build
|
32
|
-
children.props.children) : children;
|
33
|
-
}
|
34
|
-
//# sourceMappingURL=getTriggerChild.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","isFluentTrigger","getTriggerChild","children","isValidElement","props"],"sources":["../../src/trigger/getTriggerChild.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).\n *\n * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,\n * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.\n * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.\n *\n * For example, the following returns `<div id=\"child\" />`:\n * ```jsx\n * getTriggerChild(\n * <Tooltip>\n * <MenuTrigger>\n * <div id=\"child\" />\n * </MenuTrigger>\n * </Tooltip>\n * );\n * ```\n *\n * In the case where the immediate child is not a valid element,\n * null is returned\n */\nexport function getTriggerChild<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (React.ReactElement<Partial<TriggerChildProps>> & { ref?: React.Ref<any> }) | null {\n if (!React.isValidElement<TriggerChildProps>(children)) {\n return null;\n }\n return isFluentTrigger(children)\n ? getTriggerChild(\n // FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,\n // but for some reason it's failing on build\n (children.props as TriggerProps).children,\n )\n : children;\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,eAAe,QAAQ;AAGhC;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,SAASC,gBACdC,QAAqD,EAE+B;EACpF,IAAI,eAACH,KAAA,CAAMI,cAAc,CAAoBD,QAAA,GAAW;IACtD,OAAO,IAAI;EACb;EACA,OAAOF,eAAA,CAAgBE,QAAA,IACnBD,eAAA;EAGE;EADA;EACCC,QAAA,CAASE,KAAK,CAAkBF,QAAQ,IAE3CA,QAAQ;AACd"}
|
package/lib/trigger/index.js
DELETED
package/lib/trigger/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/trigger/index.ts"],"sourcesContent":["export * from './applyTriggerPropsToChildren';\nexport * from './getTriggerChild';\nexport * from './isFluentTrigger';\nexport * from './types';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
2
|
-
/**
|
3
|
-
* @internal
|
4
|
-
* Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
|
5
|
-
* See the {@link FluentTriggerComponent} type for more info.
|
6
|
-
*/
|
7
|
-
export function isFluentTrigger(element) {
|
8
|
-
return Boolean(element.type.isFluentTriggerComponent);
|
9
|
-
}
|
10
|
-
//# sourceMappingURL=isFluentTrigger.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","isFluentTrigger","element","Boolean","type","isFluentTriggerComponent"],"sources":["../../src/trigger/isFluentTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport type { FluentTriggerComponent, TriggerProps } from './types';\n\n/**\n * @internal\n * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).\n * See the {@link FluentTriggerComponent} type for more info.\n */\nexport function isFluentTrigger(element: React.ReactElement): element is React.ReactElement<TriggerProps> {\n return Boolean((element.type as FluentTriggerComponent).isFluentTriggerComponent);\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAGvB;;;;;AAKA,OAAO,SAASC,gBAAgBC,OAA2B,EAA+C;EACxG,OAAOC,OAAA,CAAQD,OAAC,CAAQE,IAAI,CAA4BC,wBAAwB;AAClF"}
|
package/lib/trigger/types.js
DELETED
package/lib/trigger/types.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React"],"sources":["../../src/trigger/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"],"mappings":"AAAA,YAAYA,KAAA,MAAW"}
|
package/lib/utils/clamp.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @internal
|
3
|
-
* Clamps `value` to a number between the min and max.
|
4
|
-
*
|
5
|
-
* @param value - the value to be clamped
|
6
|
-
* @param min - the lowest valid value
|
7
|
-
* @param max - the highest valid value
|
8
|
-
*/export const clamp = (value, min, max) => Math.max(min, Math.min(max, value || 0));
|
9
|
-
//# sourceMappingURL=clamp.js.map
|
package/lib/utils/clamp.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["clamp","value","min","max","Math"],"sources":["../../src/utils/clamp.ts"],"sourcesContent":["/**\n * @internal\n * Clamps `value` to a number between the min and max.\n *\n * @param value - the value to be clamped\n * @param min - the lowest valid value\n * @param max - the highest valid value\n */\nexport const clamp = (value: number, min: number, max: number): number => Math.max(min, Math.min(max, value || 0));\n"],"mappings":"AAAA;;;;;;;GAQA,OAAO,MAAMA,KAAA,GAAQA,CAACC,KAAA,EAAeC,GAAA,EAAaC,GAAA,KAAwBC,IAAA,CAAKD,GAAG,CAACD,GAAA,EAAKE,IAAA,CAAKF,GAAG,CAACC,GAAA,EAAKF,KAAA,IAAS"}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import * as React from 'react';
|
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
|
-
const nativeElementMap = {
|
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
|
-
};
|
28
|
-
/**
|
29
|
-
* Given an element tagname and user props, filters the props to only allowed props for the given
|
30
|
-
* element type.
|
31
|
-
* @param tagName - Tag name (e.g. "div")
|
32
|
-
* @param props - Props object
|
33
|
-
* @param excludedPropNames - List of props to disallow
|
34
|
-
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
35
|
-
export function getNativeElementProps(tagName, props, excludedPropNames) {
|
36
|
-
const allowedPropNames = tagName && nativeElementMap[tagName] || htmlElementProperties;
|
37
|
-
allowedPropNames.as = 1;
|
38
|
-
return getNativeProps(props, allowedPropNames, excludedPropNames);
|
39
|
-
}
|
40
|
-
/**
|
41
|
-
* Splits the native props into ones that go to the `root` slot, and ones that go to the primary slot.
|
42
|
-
*
|
43
|
-
* This function is only for use with components that have a primary slot other than `root`.
|
44
|
-
* Most components should use {@link getNativeElementProps} for their root slot if it is the primary slot.
|
45
|
-
*
|
46
|
-
* @returns An object containing the native props for the `root` and primary slots.
|
47
|
-
*/
|
48
|
-
export const getPartitionedNativeProps = ({
|
49
|
-
primarySlotTagName,
|
50
|
-
props,
|
51
|
-
excludedPropNames
|
52
|
-
}) => {
|
53
|
-
return {
|
54
|
-
root: {
|
55
|
-
style: props.style,
|
56
|
-
className: props.className
|
57
|
-
},
|
58
|
-
primary: getNativeElementProps(primarySlotTagName, props, [...(excludedPropNames || []), 'style', 'className'])
|
59
|
-
};
|
60
|
-
};
|
61
|
-
//# sourceMappingURL=getNativeElementProps.js.map
|