@vuu-ui/vuu-utils 2.0.0 → 2.1.0-alpha.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/cjs/node_modules/@dnd-kit/react/hooks.js +3 -3
- package/cjs/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +492 -0
- package/cjs/node_modules/@floating-ui/dom/dist/floating-ui.dom.js.map +1 -0
- package/cjs/node_modules/@floating-ui/react/dist/floating-ui.react.js +987 -0
- package/cjs/node_modules/@floating-ui/react/dist/floating-ui.react.js.map +1 -0
- package/cjs/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js +130 -0
- package/cjs/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js.map +1 -0
- package/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +183 -0
- package/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +1 -0
- package/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +39 -0
- package/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/aria-announcer/AriaAnnouncerContext.js +10 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/aria-announcer/AriaAnnouncerContext.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/aria-announcer/AriaAnnouncerProvider.js +76 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/aria-announcer/AriaAnnouncerProvider.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/aria-announcer/useAriaAnnouncer.js +52 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/aria-announcer/useAriaAnnouncer.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/breakpoints/BreakpointProvider.js +59 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/breakpoints/BreakpointProvider.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/breakpoints/Breakpoints.js +12 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/breakpoints/Breakpoints.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/button/Button.css.js +6 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/button/Button.css.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/button/Button.js +96 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/button/Button.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/button/useButton.js +65 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/button/useButton.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/salt-provider/ProviderContext.js +11 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/salt-provider/ProviderContext.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/salt-provider/SaltProvider.css.js +6 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/salt-provider/SaltProvider.css.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/salt-provider/SaltProvider.js +160 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/salt-provider/SaltProvider.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/salt-provider/ThemeApplicator.js +115 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/salt-provider/ThemeApplicator.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/spinner/Spinner.css.js +6 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/spinner/Spinner.css.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/spinner/Spinner.js +86 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/spinner/Spinner.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/spinner/svgSpinners/SpinnerSVG.js +93 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/spinner/svgSpinners/SpinnerSVG.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/createChainedFunction.js +20 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/createChainedFunction.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/createContext.js +14 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/createContext.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/debounce.js +22 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/debounce.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/makePrefixer.js +6 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/makePrefixer.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/useFloatingUI/useFloatingUI.js +52 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/useFloatingUI/useFloatingUI.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/useId.js +45 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/useId.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/useIsomorphicLayoutEffect.js +8 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/useIsomorphicLayoutEffect.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/usePreventScroll.js +233 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/utils/usePreventScroll.js.map +1 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/viewport/ViewportProvider.js +35 -0
- package/cjs/node_modules/@salt-ds/core/dist-es/viewport/ViewportProvider.js.map +1 -0
- package/cjs/node_modules/@salt-ds/styles/dist-es/style-injection-provider/index.js +22 -0
- package/cjs/node_modules/@salt-ds/styles/dist-es/style-injection-provider/index.js.map +1 -0
- package/cjs/node_modules/@salt-ds/styles/dist-es/use-style-injection/InsertionPointProvider.js +16 -0
- package/cjs/node_modules/@salt-ds/styles/dist-es/use-style-injection/InsertionPointProvider.js.map +1 -0
- package/cjs/node_modules/@salt-ds/styles/dist-es/use-style-injection/useStyleInjection.js +75 -0
- package/cjs/node_modules/@salt-ds/styles/dist-es/use-style-injection/useStyleInjection.js.map +1 -0
- package/cjs/node_modules/@salt-ds/window/dist-es/WindowProvider.js +17 -0
- package/cjs/node_modules/@salt-ds/window/dist-es/WindowProvider.js.map +1 -0
- package/cjs/node_modules/tabbable/dist/index.esm.js +550 -0
- package/cjs/node_modules/tabbable/dist/index.esm.js.map +1 -0
- package/cjs/packages/vuu-utils/src/ThemeProvider.js +2 -2
- package/cjs/packages/vuu-utils/src/ThemeProvider.js.map +1 -1
- package/cjs/packages/vuu-utils/src/data-editing/DataEditingProvider.js +25 -0
- package/cjs/packages/vuu-utils/src/data-editing/DataEditingProvider.js.map +1 -0
- package/cjs/packages/vuu-utils/src/data-editing/EditButtons.js +23 -0
- package/cjs/packages/vuu-utils/src/data-editing/EditButtons.js.map +1 -0
- package/cjs/packages/vuu-utils/src/data-editing/EditTracker.js +154 -0
- package/cjs/packages/vuu-utils/src/data-editing/EditTracker.js.map +1 -0
- package/cjs/packages/vuu-utils/src/data-editing/useEditableTable.js +69 -0
- package/cjs/packages/vuu-utils/src/data-editing/useEditableTable.js.map +1 -0
- package/cjs/packages/vuu-utils/src/index.js +9 -0
- package/cjs/packages/vuu-utils/src/index.js.map +1 -1
- package/esm/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +489 -0
- package/esm/node_modules/@floating-ui/dom/dist/floating-ui.dom.js.map +1 -0
- package/esm/node_modules/@floating-ui/react/dist/floating-ui.react.js +962 -0
- package/esm/node_modules/@floating-ui/react/dist/floating-ui.react.js.map +1 -0
- package/esm/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js +114 -0
- package/esm/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js.map +1 -0
- package/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +162 -0
- package/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +1 -0
- package/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +33 -0
- package/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/aria-announcer/AriaAnnouncerContext.js +8 -0
- package/esm/node_modules/@salt-ds/core/dist-es/aria-announcer/AriaAnnouncerContext.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/aria-announcer/AriaAnnouncerProvider.js +73 -0
- package/esm/node_modules/@salt-ds/core/dist-es/aria-announcer/AriaAnnouncerProvider.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/aria-announcer/useAriaAnnouncer.js +50 -0
- package/esm/node_modules/@salt-ds/core/dist-es/aria-announcer/useAriaAnnouncer.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/breakpoints/BreakpointProvider.js +56 -0
- package/esm/node_modules/@salt-ds/core/dist-es/breakpoints/BreakpointProvider.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/breakpoints/Breakpoints.js +10 -0
- package/esm/node_modules/@salt-ds/core/dist-es/breakpoints/Breakpoints.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/button/Button.css.js +4 -0
- package/esm/node_modules/@salt-ds/core/dist-es/button/Button.css.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/button/Button.js +94 -0
- package/esm/node_modules/@salt-ds/core/dist-es/button/Button.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/button/useButton.js +63 -0
- package/esm/node_modules/@salt-ds/core/dist-es/button/useButton.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/salt-provider/ProviderContext.js +9 -0
- package/esm/node_modules/@salt-ds/core/dist-es/salt-provider/ProviderContext.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/salt-provider/SaltProvider.css.js +4 -0
- package/esm/node_modules/@salt-ds/core/dist-es/salt-provider/SaltProvider.css.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/salt-provider/SaltProvider.js +151 -0
- package/esm/node_modules/@salt-ds/core/dist-es/salt-provider/SaltProvider.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/salt-provider/ThemeApplicator.js +113 -0
- package/esm/node_modules/@salt-ds/core/dist-es/salt-provider/ThemeApplicator.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/spinner/Spinner.css.js +4 -0
- package/esm/node_modules/@salt-ds/core/dist-es/spinner/Spinner.css.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/spinner/Spinner.js +84 -0
- package/esm/node_modules/@salt-ds/core/dist-es/spinner/Spinner.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/spinner/svgSpinners/SpinnerSVG.js +91 -0
- package/esm/node_modules/@salt-ds/core/dist-es/spinner/svgSpinners/SpinnerSVG.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/createChainedFunction.js +18 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/createChainedFunction.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/createContext.js +12 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/createContext.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/debounce.js +20 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/debounce.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/makePrefixer.js +4 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/makePrefixer.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/useFloatingUI/useFloatingUI.js +50 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/useFloatingUI/useFloatingUI.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/useId.js +24 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/useId.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/useIsomorphicLayoutEffect.js +6 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/useIsomorphicLayoutEffect.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/usePreventScroll.js +231 -0
- package/esm/node_modules/@salt-ds/core/dist-es/utils/usePreventScroll.js.map +1 -0
- package/esm/node_modules/@salt-ds/core/dist-es/viewport/ViewportProvider.js +32 -0
- package/esm/node_modules/@salt-ds/core/dist-es/viewport/ViewportProvider.js.map +1 -0
- package/esm/node_modules/@salt-ds/styles/dist-es/style-injection-provider/index.js +19 -0
- package/esm/node_modules/@salt-ds/styles/dist-es/style-injection-provider/index.js.map +1 -0
- package/esm/node_modules/@salt-ds/styles/dist-es/use-style-injection/InsertionPointProvider.js +14 -0
- package/esm/node_modules/@salt-ds/styles/dist-es/use-style-injection/InsertionPointProvider.js.map +1 -0
- package/esm/node_modules/@salt-ds/styles/dist-es/use-style-injection/useStyleInjection.js +54 -0
- package/esm/node_modules/@salt-ds/styles/dist-es/use-style-injection/useStyleInjection.js.map +1 -0
- package/esm/node_modules/@salt-ds/window/dist-es/WindowProvider.js +15 -0
- package/esm/node_modules/@salt-ds/window/dist-es/WindowProvider.js.map +1 -0
- package/esm/node_modules/tabbable/dist/index.esm.js +546 -0
- package/esm/node_modules/tabbable/dist/index.esm.js.map +1 -0
- package/esm/packages/vuu-utils/src/ThemeProvider.js +2 -2
- package/esm/packages/vuu-utils/src/ThemeProvider.js.map +1 -1
- package/esm/packages/vuu-utils/src/context-definitions/WorkspaceContext.js +2 -2
- package/esm/packages/vuu-utils/src/context-definitions/WorkspaceContext.js.map +1 -1
- package/esm/packages/vuu-utils/src/data-editing/DataEditingProvider.js +22 -0
- package/esm/packages/vuu-utils/src/data-editing/DataEditingProvider.js.map +1 -0
- package/esm/packages/vuu-utils/src/data-editing/EditButtons.js +21 -0
- package/esm/packages/vuu-utils/src/data-editing/EditButtons.js.map +1 -0
- package/esm/packages/vuu-utils/src/data-editing/EditTracker.js +152 -0
- package/esm/packages/vuu-utils/src/data-editing/EditTracker.js.map +1 -0
- package/esm/packages/vuu-utils/src/data-editing/useEditableTable.js +67 -0
- package/esm/packages/vuu-utils/src/data-editing/useEditableTable.js.map +1 -0
- package/esm/packages/vuu-utils/src/feature-utils.js +2 -2
- package/esm/packages/vuu-utils/src/feature-utils.js.map +1 -1
- package/esm/packages/vuu-utils/src/index.js +4 -0
- package/esm/packages/vuu-utils/src/index.js.map +1 -1
- package/package.json +6 -6
- package/types/data-editing/DataEditingProvider.d.ts +7 -0
- package/types/data-editing/EditButtons.d.ts +7 -0
- package/types/data-editing/EditTracker.d.ts +24 -0
- package/types/data-editing/useEditableTable.d.ts +15 -0
- package/types/index.d.ts +5 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { forwardRef, useEffect } from 'react';
|
|
4
|
+
import { useAriaAnnouncer } from '../aria-announcer/useAriaAnnouncer.js';
|
|
5
|
+
import '../aria-announcer/AriaAnnouncerContext.js';
|
|
6
|
+
import { useDensity } from '../salt-provider/SaltProvider.js';
|
|
7
|
+
import { makePrefixer } from '../utils/makePrefixer.js';
|
|
8
|
+
import '../utils/useFloatingUI/useFloatingUI.js';
|
|
9
|
+
import { useId } from '../utils/useId.js';
|
|
10
|
+
import '../viewport/ViewportProvider.js';
|
|
11
|
+
import css_248z from './Spinner.css.js';
|
|
12
|
+
import { SpinnerSVG } from './svgSpinners/SpinnerSVG.js';
|
|
13
|
+
import { useWindow } from '../../../window/dist-es/WindowProvider.js';
|
|
14
|
+
import { useComponentCssInjection } from '../../../styles/dist-es/use-style-injection/useStyleInjection.js';
|
|
15
|
+
|
|
16
|
+
const handleSize = (size) => size === "default" ? "medium" : size;
|
|
17
|
+
const withBaseName = makePrefixer("saltSpinner");
|
|
18
|
+
const Spinner = forwardRef(
|
|
19
|
+
function Spinner2({
|
|
20
|
+
"aria-label": ariaLabel = "loading",
|
|
21
|
+
announcerInterval = 5e3,
|
|
22
|
+
announcerTimeout = 2e4,
|
|
23
|
+
completionAnnouncement = `finished ${ariaLabel}`,
|
|
24
|
+
disableAnnouncer,
|
|
25
|
+
className,
|
|
26
|
+
size = "medium",
|
|
27
|
+
id: idProp,
|
|
28
|
+
...rest
|
|
29
|
+
}, ref) {
|
|
30
|
+
const id = useId(idProp);
|
|
31
|
+
const targetWindow = useWindow();
|
|
32
|
+
useComponentCssInjection({
|
|
33
|
+
testId: "salt-spinner",
|
|
34
|
+
css: css_248z,
|
|
35
|
+
window: targetWindow
|
|
36
|
+
});
|
|
37
|
+
const { announce } = useAriaAnnouncer();
|
|
38
|
+
const density = useDensity();
|
|
39
|
+
size = handleSize(size);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (disableAnnouncer) return;
|
|
42
|
+
announce(ariaLabel);
|
|
43
|
+
const startTime = Date.now();
|
|
44
|
+
const interval = announcerInterval > 0 && setInterval(() => {
|
|
45
|
+
if (Date.now() - startTime > announcerTimeout) {
|
|
46
|
+
announce(
|
|
47
|
+
`${ariaLabel} is still in progress, but will no longer announce.`
|
|
48
|
+
);
|
|
49
|
+
interval && clearInterval(interval);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
announce(ariaLabel);
|
|
53
|
+
}, announcerInterval);
|
|
54
|
+
return () => {
|
|
55
|
+
if (disableAnnouncer) return;
|
|
56
|
+
interval && clearInterval(interval);
|
|
57
|
+
if (completionAnnouncement) {
|
|
58
|
+
announce(completionAnnouncement);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}, [
|
|
62
|
+
announce,
|
|
63
|
+
announcerInterval,
|
|
64
|
+
announcerTimeout,
|
|
65
|
+
ariaLabel,
|
|
66
|
+
completionAnnouncement,
|
|
67
|
+
disableAnnouncer
|
|
68
|
+
]);
|
|
69
|
+
return /* @__PURE__ */ jsx(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
"aria-label": ariaLabel,
|
|
73
|
+
className: clsx(withBaseName(), withBaseName(size), className),
|
|
74
|
+
ref,
|
|
75
|
+
role: "img",
|
|
76
|
+
...rest,
|
|
77
|
+
children: /* @__PURE__ */ jsx(SpinnerSVG, { size, density, id })
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
export { Spinner };
|
|
84
|
+
//# sourceMappingURL=Spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spinner.js","sources":["../../../../../../../../node_modules/@salt-ds/core/dist-es/spinner/Spinner.js"],"sourcesContent":["import { jsx } from 'react/jsx-runtime';\nimport { useComponentCssInjection } from '@salt-ds/styles';\nimport { useWindow } from '@salt-ds/window';\nimport { clsx } from 'clsx';\nimport { forwardRef, useEffect } from 'react';\nimport { useAriaAnnouncer } from '../aria-announcer/useAriaAnnouncer.js';\nimport '../aria-announcer/AriaAnnouncerContext.js';\nimport { useDensity } from '../salt-provider/SaltProvider.js';\nimport { makePrefixer } from '../utils/makePrefixer.js';\nimport '../utils/useFloatingUI/useFloatingUI.js';\nimport { useId } from '../utils/useId.js';\nimport '../viewport/ViewportProvider.js';\nimport css_248z from './Spinner.css.js';\nimport { SpinnerSVG } from './svgSpinners/SpinnerSVG.js';\n\nconst SpinnerSizeValues = [\n \"default\",\n \"large\",\n \"small\",\n \"medium\"\n];\nconst handleSize = (size) => size === \"default\" ? \"medium\" : size;\nconst withBaseName = makePrefixer(\"saltSpinner\");\nconst Spinner = forwardRef(\n function Spinner2({\n \"aria-label\": ariaLabel = \"loading\",\n announcerInterval = 5e3,\n announcerTimeout = 2e4,\n completionAnnouncement = `finished ${ariaLabel}`,\n disableAnnouncer,\n className,\n size = \"medium\",\n id: idProp,\n ...rest\n }, ref) {\n const id = useId(idProp);\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-spinner\",\n css: css_248z,\n window: targetWindow\n });\n const { announce } = useAriaAnnouncer();\n const density = useDensity();\n size = handleSize(size);\n useEffect(() => {\n if (disableAnnouncer) return;\n announce(ariaLabel);\n const startTime = Date.now();\n const interval = announcerInterval > 0 && setInterval(() => {\n if (Date.now() - startTime > announcerTimeout) {\n announce(\n `${ariaLabel} is still in progress, but will no longer announce.`\n );\n interval && clearInterval(interval);\n return;\n }\n announce(ariaLabel);\n }, announcerInterval);\n return () => {\n if (disableAnnouncer) return;\n interval && clearInterval(interval);\n if (completionAnnouncement) {\n announce(completionAnnouncement);\n }\n };\n }, [\n announce,\n announcerInterval,\n announcerTimeout,\n ariaLabel,\n completionAnnouncement,\n disableAnnouncer\n ]);\n return /* @__PURE__ */ jsx(\n \"div\",\n {\n \"aria-label\": ariaLabel,\n className: clsx(withBaseName(), withBaseName(size), className),\n ref,\n role: \"img\",\n ...rest,\n children: /* @__PURE__ */ jsx(SpinnerSVG, { size, density, id })\n }\n );\n }\n);\n\nexport { Spinner, SpinnerSizeValues };\n//# sourceMappingURL=Spinner.js.map\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAM,UAAU,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,SAAS,GAAG,QAAQ,GAAG,IAAI;AACjE,MAAM,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC;AAC3C,MAAC,OAAO,GAAG,UAAU;AAC1B,EAAE,SAAS,QAAQ,CAAC;AACpB,IAAI,YAAY,EAAE,SAAS,GAAG,SAAS;AACvC,IAAI,iBAAiB,GAAG,GAAG;AAC3B,IAAI,gBAAgB,GAAG,GAAG;AAC1B,IAAI,sBAAsB,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACpD,IAAI,gBAAgB;AACpB,IAAI,SAAS;AACb,IAAI,IAAI,GAAG,QAAQ;AACnB,IAAI,EAAE,EAAE,MAAM;AACd,IAAI,GAAG;AACP,GAAG,EAAE,GAAG,EAAE;AACV,IAAI,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC;AAC5B,IAAI,MAAM,YAAY,GAAG,SAAS,EAAE;AACpC,IAAI,wBAAwB,CAAC;AAC7B,MAAM,MAAM,EAAE,cAAc;AAC5B,MAAM,GAAG,EAAE,QAAQ;AACnB,MAAM,MAAM,EAAE;AACd,K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AACX,QAAQ,IAAI,EAAE,KAAK;AACnB,QAAQ,GAAG,IAAI;AACf,QAAQ,QAAQ,kBAAkB,GAAG,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;AACvE;AACA,KAAK;AACL;AACA;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { makePrefixer } from '../../utils/makePrefixer.js';
|
|
4
|
+
import 'clsx';
|
|
5
|
+
import '../../utils/useFloatingUI/useFloatingUI.js';
|
|
6
|
+
import '../../utils/useId.js';
|
|
7
|
+
import '../../salt-provider/SaltProvider.js';
|
|
8
|
+
import '../../viewport/ViewportProvider.js';
|
|
9
|
+
|
|
10
|
+
const withBaseName = makePrefixer("saltSpinner");
|
|
11
|
+
const sizeAndStrokeWidthMapping = {
|
|
12
|
+
small: {
|
|
13
|
+
high: { width: 12, strokeWidth: 2 },
|
|
14
|
+
medium: { width: 12, strokeWidth: 2 },
|
|
15
|
+
low: { width: 14, strokeWidth: 2 },
|
|
16
|
+
touch: { width: 16, strokeWidth: 2 }
|
|
17
|
+
},
|
|
18
|
+
medium: {
|
|
19
|
+
high: { width: 20, strokeWidth: 2 },
|
|
20
|
+
medium: { width: 28, strokeWidth: 4 },
|
|
21
|
+
low: { width: 36, strokeWidth: 6 },
|
|
22
|
+
touch: { width: 44, strokeWidth: 8 }
|
|
23
|
+
},
|
|
24
|
+
large: {
|
|
25
|
+
high: { width: 40, strokeWidth: 2 },
|
|
26
|
+
medium: { width: 56, strokeWidth: 4 },
|
|
27
|
+
low: { width: 72, strokeWidth: 6 },
|
|
28
|
+
touch: { width: 88, strokeWidth: 8 }
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const SpinnerSVG = ({
|
|
32
|
+
id = "svg-spinner",
|
|
33
|
+
rest,
|
|
34
|
+
size,
|
|
35
|
+
density
|
|
36
|
+
}) => {
|
|
37
|
+
const { width, strokeWidth } = sizeAndStrokeWidthMapping[size][density];
|
|
38
|
+
const radius = (width - strokeWidth) / 2;
|
|
39
|
+
return /* @__PURE__ */ jsxs(
|
|
40
|
+
"svg",
|
|
41
|
+
{
|
|
42
|
+
className: withBaseName("spinner"),
|
|
43
|
+
viewBox: `0 0 ${width} ${width}`,
|
|
44
|
+
id,
|
|
45
|
+
...rest,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: `${id}-1`, x1: "0", y1: "0", x2: "100%", y2: "0", children: [
|
|
48
|
+
/* @__PURE__ */ jsx(
|
|
49
|
+
"stop",
|
|
50
|
+
{
|
|
51
|
+
className: withBaseName("gradientStop"),
|
|
52
|
+
offset: "15%",
|
|
53
|
+
stopOpacity: "1"
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
"stop",
|
|
58
|
+
{
|
|
59
|
+
className: withBaseName("gradientStop"),
|
|
60
|
+
offset: "100%",
|
|
61
|
+
stopOpacity: "0"
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] }) }),
|
|
65
|
+
/* @__PURE__ */ jsxs("g", { fill: "none", children: [
|
|
66
|
+
/* @__PURE__ */ jsx(
|
|
67
|
+
"path",
|
|
68
|
+
{
|
|
69
|
+
d: `M${width - strokeWidth / 2},${width / 2} a${radius},${radius} 0 1,0 -${width - strokeWidth},0`,
|
|
70
|
+
stroke: "var(--saltSpinner-gradient-color, var(--salt-accent-background)",
|
|
71
|
+
strokeWidth: "var(--spinner-strokeWidth)",
|
|
72
|
+
fill: "none"
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
"path",
|
|
77
|
+
{
|
|
78
|
+
d: `M${width / 2},${strokeWidth / 2} a${radius},${radius} 0 1,0 0,${width - strokeWidth}`,
|
|
79
|
+
stroke: `url(#${id}-1)`,
|
|
80
|
+
strokeWidth: "var(--spinner-strokeWidth)",
|
|
81
|
+
fill: "none"
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] })
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export { SpinnerSVG };
|
|
91
|
+
//# sourceMappingURL=SpinnerSVG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpinnerSVG.js","sources":["../../../../../../../../../node_modules/@salt-ds/core/dist-es/spinner/svgSpinners/SpinnerSVG.js"],"sourcesContent":["import { jsxs, jsx } from 'react/jsx-runtime';\nimport 'react';\nimport { makePrefixer } from '../../utils/makePrefixer.js';\nimport 'clsx';\nimport '../../utils/useFloatingUI/useFloatingUI.js';\nimport '../../utils/useId.js';\nimport '../../salt-provider/SaltProvider.js';\nimport '../../viewport/ViewportProvider.js';\n\nconst withBaseName = makePrefixer(\"saltSpinner\");\nconst sizeAndStrokeWidthMapping = {\n small: {\n high: { width: 12, strokeWidth: 2 },\n medium: { width: 12, strokeWidth: 2 },\n low: { width: 14, strokeWidth: 2 },\n touch: { width: 16, strokeWidth: 2 }\n },\n medium: {\n high: { width: 20, strokeWidth: 2 },\n medium: { width: 28, strokeWidth: 4 },\n low: { width: 36, strokeWidth: 6 },\n touch: { width: 44, strokeWidth: 8 }\n },\n large: {\n high: { width: 40, strokeWidth: 2 },\n medium: { width: 56, strokeWidth: 4 },\n low: { width: 72, strokeWidth: 6 },\n touch: { width: 88, strokeWidth: 8 }\n }\n};\nconst SpinnerSVG = ({\n id = \"svg-spinner\",\n rest,\n size,\n density\n}) => {\n const { width, strokeWidth } = sizeAndStrokeWidthMapping[size][density];\n const radius = (width - strokeWidth) / 2;\n return /* @__PURE__ */ jsxs(\n \"svg\",\n {\n className: withBaseName(\"spinner\"),\n viewBox: `0 0 ${width} ${width}`,\n id,\n ...rest,\n children: [\n /* @__PURE__ */ jsx(\"defs\", { children: /* @__PURE__ */ jsxs(\"linearGradient\", { id: `${id}-1`, x1: \"0\", y1: \"0\", x2: \"100%\", y2: \"0\", children: [\n /* @__PURE__ */ jsx(\n \"stop\",\n {\n className: withBaseName(\"gradientStop\"),\n offset: \"15%\",\n stopOpacity: \"1\"\n }\n ),\n /* @__PURE__ */ jsx(\n \"stop\",\n {\n className: withBaseName(\"gradientStop\"),\n offset: \"100%\",\n stopOpacity: \"0\"\n }\n )\n ] }) }),\n /* @__PURE__ */ jsxs(\"g\", { fill: \"none\", children: [\n /* @__PURE__ */ jsx(\n \"path\",\n {\n d: `M${width - strokeWidth / 2},${width / 2} a${radius},${radius} 0 1,0 -${width - strokeWidth},0`,\n stroke: \"var(--saltSpinner-gradient-color, var(--salt-accent-background)\",\n strokeWidth: \"var(--spinner-strokeWidth)\",\n fill: \"none\"\n }\n ),\n /* @__PURE__ */ jsx(\n \"path\",\n {\n d: `M${width / 2},${strokeWidth / 2} a${radius},${radius} 0 1,0 0,${width - strokeWidth}`,\n stroke: `url(#${id}-1)`,\n strokeWidth: \"var(--spinner-strokeWidth)\",\n fill: \"none\"\n }\n )\n ] })\n ]\n }\n );\n};\n\nexport { SpinnerSVG };\n//# sourceMappingURL=SpinnerSVG.js.map\n"],"names":[],"mappings":";;;;;;;;;AASA,MAAM,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC;AAChD,MAAM,yBAAyB,GAAG;AAClC,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;AACvC,IAAI,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;AACzC,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;AACtC,IAAI,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC;AACtC,GAAG;A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E,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC;AACvG,cAAc,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC;AACrC,cAAc,WAAW,EAAE,4BAA4B;AACvD,cAAc,IAAI,EAAE;AACpB;AACA;AACA,SAAS,EAAE;AACX;AACA;AACA,GAAG;AACH;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function createChainedFunction(...funcs) {
|
|
2
|
+
return funcs.reduce(
|
|
3
|
+
(acc, func) => {
|
|
4
|
+
if (func == null) {
|
|
5
|
+
return acc;
|
|
6
|
+
}
|
|
7
|
+
return function chainedFunction(...args) {
|
|
8
|
+
acc.apply(this, args);
|
|
9
|
+
func.apply(this, args);
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
() => {
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { createChainedFunction };
|
|
18
|
+
//# sourceMappingURL=createChainedFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createChainedFunction.js","sources":["../../../../../../../../node_modules/@salt-ds/core/dist-es/utils/createChainedFunction.js"],"sourcesContent":["function createChainedFunction(...funcs) {\n return funcs.reduce(\n (acc, func) => {\n if (func == null) {\n return acc;\n }\n return function chainedFunction(...args) {\n acc.apply(this, args);\n func.apply(this, args);\n };\n },\n () => {\n }\n );\n}\n\nexport { createChainedFunction };\n//# sourceMappingURL=createChainedFunction.js.map\n"],"names":[],"mappings":"AAAA,SAAS,qBAAqB,CAAC,GAAG,KAAK,EAAE;AACzC,EAAE,OAAO,KAAK,CAAC,MAAM;AACrB,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK;AACnB,MAAM,IAAI,IAAI,IAAI,IAAI,EAAE;AACxB,QAAQ,OAAO,GAAG;AAClB;AACA,MAAM,OAAO,SAAS,eAAe,CAAC,GAAG,IAAI,EAAE;AAC/C,QAAQ,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AAC7B,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AAC9B,OAAO;AACP,KAAK;AACL,IAAI,MAAM;AACV;AACA,GAAG;AACH;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext as createContext$1 } from 'react';
|
|
2
|
+
|
|
3
|
+
function createContext(name, defaultValue) {
|
|
4
|
+
const context = createContext$1(defaultValue);
|
|
5
|
+
if (process.env.NODE_ENV !== "production") {
|
|
6
|
+
context.displayName = name;
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { createContext };
|
|
12
|
+
//# sourceMappingURL=createContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContext.js","sources":["../../../../../../../../node_modules/@salt-ds/core/dist-es/utils/createContext.js"],"sourcesContent":["import { createContext as createContext$1 } from 'react';\n\nfunction createContext(name, defaultValue) {\n const context = createContext$1(defaultValue);\n if (process.env.NODE_ENV !== \"production\") {\n context.displayName = name;\n }\n return context;\n}\n\nexport { createContext };\n//# sourceMappingURL=createContext.js.map\n"],"names":[],"mappings":";;AAEA,SAAS,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE;AAC3C,EAAE,MAAM,OAAO,GAAG,eAAe,CAAC,YAAY,CAAC;AAC/C,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;AAC7C,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI;AAC9B;AACA,EAAE,OAAO,OAAO;AAChB;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function debounce(func, wait = 166, leading = false) {
|
|
2
|
+
let timeout;
|
|
3
|
+
const debounced = function debounced2(...args) {
|
|
4
|
+
const later = () => {
|
|
5
|
+
func.apply(this, args);
|
|
6
|
+
};
|
|
7
|
+
clearTimeout(timeout);
|
|
8
|
+
if (leading) {
|
|
9
|
+
later();
|
|
10
|
+
}
|
|
11
|
+
timeout = window.setTimeout(later, wait);
|
|
12
|
+
};
|
|
13
|
+
debounced.clear = () => {
|
|
14
|
+
clearTimeout(timeout);
|
|
15
|
+
};
|
|
16
|
+
return debounced;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { debounce };
|
|
20
|
+
//# sourceMappingURL=debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","sources":["../../../../../../../../node_modules/@salt-ds/core/dist-es/utils/debounce.js"],"sourcesContent":["function debounce(func, wait = 166, leading = false) {\n let timeout;\n const debounced = function debounced2(...args) {\n const later = () => {\n func.apply(this, args);\n };\n clearTimeout(timeout);\n if (leading) {\n later();\n }\n timeout = window.setTimeout(later, wait);\n };\n debounced.clear = () => {\n clearTimeout(timeout);\n };\n return debounced;\n}\n\nexport { debounce };\n//# sourceMappingURL=debounce.js.map\n"],"names":[],"mappings":"AAAA,SAAS,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,GAAG,EAAE,OAAO,GAAG,KAAK,EAAE;AACrD,EAAE,IAAI,OAAO;AACb,EAAE,MAAM,SAAS,GAAG,SAAS,UAAU,CAAC,GAAG,IAAI,EAAE;AACjD,IAAI,MAAM,KAAK,GAAG,MAAM;AACxB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AAC5B,KAAK;AACL,IAAI,YAAY,CAAC,OAAO,CAAC;AACzB,IAAI,IAAI,OAAO,EAAE;AACjB,MAAM,KAAK,EAAE;AACb;AACA,IAAI,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;AAC5C,GAAG;AACH,EAAE,SAAS,CAAC,KAAK,GAAG,MAAM;AAC1B,IAAI,YAAY,CAAC,OAAO,CAAC;AACzB,GAAG;AACH,EAAE,OAAO,SAAS;AAClB;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makePrefixer.js","sources":["../../../../../../../../node_modules/@salt-ds/core/dist-es/utils/makePrefixer.js"],"sourcesContent":["const makePrefixer = (prefix) => (...names) => [prefix, ...names].join(\"-\");\n\nexport { makePrefixer };\n//# sourceMappingURL=makePrefixer.js.map\n"],"names":[],"mappings":"AAAK,MAAC,YAAY,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { FloatingPortal, FloatingFocusManager } from '../../../../../@floating-ui/react/dist/floating-ui.react.js';
|
|
3
|
+
import { forwardRef, createContext } from 'react';
|
|
4
|
+
import { useTheme, SaltProviderNext, SaltProvider } from '../../salt-provider/SaltProvider.js';
|
|
5
|
+
import { usePreventScroll } from '../usePreventScroll.js';
|
|
6
|
+
import { platform } from '../../../../../@floating-ui/dom/dist/floating-ui.dom.js';
|
|
7
|
+
|
|
8
|
+
const DefaultFloatingComponent = forwardRef(function DefaultFloatingComponent2(props, ref) {
|
|
9
|
+
const {
|
|
10
|
+
open,
|
|
11
|
+
top,
|
|
12
|
+
left,
|
|
13
|
+
position,
|
|
14
|
+
width: _width,
|
|
15
|
+
height: _height,
|
|
16
|
+
focusManagerProps,
|
|
17
|
+
lockScroll,
|
|
18
|
+
style: styleProp,
|
|
19
|
+
...rest
|
|
20
|
+
} = props;
|
|
21
|
+
const style = {
|
|
22
|
+
...styleProp,
|
|
23
|
+
top,
|
|
24
|
+
left,
|
|
25
|
+
position
|
|
26
|
+
};
|
|
27
|
+
const { themeNext } = useTheme();
|
|
28
|
+
usePreventScroll({ isDisabled: !lockScroll || !open });
|
|
29
|
+
const ChosenSaltProvider = themeNext ? SaltProviderNext : SaltProvider;
|
|
30
|
+
if (focusManagerProps && open) {
|
|
31
|
+
return /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(ChosenSaltProvider, { applyClassesTo: "scope", children: /* @__PURE__ */ jsx(FloatingFocusManager, { ...focusManagerProps, children: /* @__PURE__ */ jsx("div", { style, ...rest, ref }) }) }) });
|
|
32
|
+
}
|
|
33
|
+
return open ? /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(ChosenSaltProvider, { applyClassesTo: "scope", children: /* @__PURE__ */ jsx("div", { style, ...rest, ref }) }) }) : null;
|
|
34
|
+
});
|
|
35
|
+
const FloatingComponentContext = createContext({
|
|
36
|
+
Component: DefaultFloatingComponent
|
|
37
|
+
});
|
|
38
|
+
if (process.env.NODE_ENV !== "production") {
|
|
39
|
+
FloatingComponentContext.displayName = "FloatingComponentContext";
|
|
40
|
+
}
|
|
41
|
+
const defaultGetMiddleware = (defaultMiddleware) => defaultMiddleware;
|
|
42
|
+
const defaultFloatingPlaform = {
|
|
43
|
+
platform,
|
|
44
|
+
middleware: defaultGetMiddleware,
|
|
45
|
+
animationFrame: false
|
|
46
|
+
};
|
|
47
|
+
createContext(
|
|
48
|
+
defaultFloatingPlaform
|
|
49
|
+
);
|
|
50
|
+
//# sourceMappingURL=useFloatingUI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFloatingUI.js","sources":["../../../../../../../../../node_modules/@salt-ds/core/dist-es/utils/useFloatingUI/useFloatingUI.js"],"sourcesContent":["import { jsx } from 'react/jsx-runtime';\nimport { FloatingPortal, FloatingFocusManager, platform, flip, shift, limitShift, useFloating, autoUpdate } from '@floating-ui/react';\nimport { forwardRef, createContext, useContext, useMemo } from 'react';\nimport { useTheme, SaltProviderNext, SaltProvider } from '../../salt-provider/SaltProvider.js';\nimport { usePreventScroll } from '../usePreventScroll.js';\n\nconst DefaultFloatingComponent = forwardRef(function DefaultFloatingComponent2(props, ref) {\n const {\n open,\n top,\n left,\n position,\n width: _width,\n height: _height,\n focusManagerProps,\n lockScroll,\n style: styleProp,\n ...rest\n } = props;\n const style = {\n ...styleProp,\n top,\n left,\n position\n };\n const { themeNext } = useTheme();\n usePreventScroll({ isDisabled: !lockScroll || !open });\n const ChosenSaltProvider = themeNext ? SaltProviderNext : SaltProvider;\n if (focusManagerProps && open) {\n return /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(ChosenSaltProvider, { applyClassesTo: \"scope\", children: /* @__PURE__ */ jsx(FloatingFocusManager, { ...focusManagerProps, children: /* @__PURE__ */ jsx(\"div\", { style, ...rest, ref }) }) }) });\n }\n return open ? /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(ChosenSaltProvider, { applyClassesTo: \"scope\", children: /* @__PURE__ */ jsx(\"div\", { style, ...rest, ref }) }) }) : null;\n});\nconst FloatingComponentContext = createContext({\n Component: DefaultFloatingComponent\n});\nif (process.env.NODE_ENV !== \"production\") {\n FloatingComponentContext.displayName = \"FloatingComponentContext\";\n}\nfunction FloatingComponentProvider(props) {\n const { Component, children } = props;\n const value = useMemo(() => ({ Component }), [Component]);\n return /* @__PURE__ */ jsx(FloatingComponentContext.Provider, { value, children });\n}\nfunction useFloatingComponent() {\n return useContext(FloatingComponentContext);\n}\nconst defaultGetMiddleware = (defaultMiddleware) => defaultMiddleware;\nconst defaultFloatingPlaform = {\n platform,\n middleware: defaultGetMiddleware,\n animationFrame: false\n};\nconst FloatingPlatformContext = createContext(\n defaultFloatingPlaform\n);\nfunction FloatingPlatformProvider(props) {\n const {\n platform: platformProp,\n middleware,\n animationFrame,\n children\n } = props;\n const floatingPlatformContextValue = useMemo(\n () => ({\n platform: platformProp ?? platform,\n middleware: middleware ?? defaultGetMiddleware,\n animationFrame: animationFrame || false\n }),\n [platformProp, middleware, animationFrame]\n );\n return /* @__PURE__ */ jsx(FloatingPlatformContext.Provider, { value: floatingPlatformContextValue, children });\n}\nfunction useFloatingPlatform() {\n return useContext(FloatingPlatformContext);\n}\nconst DEFAULT_FLOATING_UI_MIDDLEWARE = [\n flip(),\n shift({ limiter: limitShift() })\n];\nfunction useFloatingUI(props) {\n const {\n middleware = DEFAULT_FLOATING_UI_MIDDLEWARE,\n open = false,\n onOpenChange,\n ...other\n } = props;\n const handleOpenChange = (open2, boolean, reason) => {\n update();\n onOpenChange == null ? void 0 : onOpenChange(open2, boolean, reason);\n };\n const {\n platform: contextPlatform,\n middleware: contextMiddleware,\n animationFrame\n } = useFloatingPlatform();\n const { refs, update, ...rest } = useFloating({\n ...other,\n middleware: contextMiddleware(middleware),\n open,\n onOpenChange: handleOpenChange,\n whileElementsMounted: (...args) => {\n const cleanup = autoUpdate(...args, { animationFrame });\n return cleanup;\n },\n platform: contextPlatform\n });\n return {\n reference: refs.setReference,\n floating: refs.setFloating,\n refs,\n update,\n ...rest\n };\n}\n\nexport { DEFAULT_FLOATING_UI_MIDDLEWARE, FloatingComponentProvider, FloatingPlatformProvider, useFloatingComponent, useFloatingPlatform, useFloatingUI };\n//# sourceMappingURL=useFloatingUI.js.map\n"],"names":[],"mappings":";;;;;;;AAMA,MAAM,wBAAwB,GAAG,UAAU,CAAC,SAAS,yBAAyB,CAAC,KAAK,EAAE,GAAG,EAAE;AAC3F,EAAE,MAAM;AACR,IAAI,IAAI;AACR,IAAI,GAAG;AACP,IAAI,IAAI;AACR,IAAI,QAAQ;AACZ,IAAI,KAAK,EAAE,MAAM;AACjB,IAAI,MAAM,EAAE,OAAO;AACnB,IAAI,iBAAiB;AACrB,IAAI,UAAU;AACd,IAAI,KAAK,EAAE,SAAS;AACpB,IAAI,GAAG;AACP,GAAG,GAAG,KAAK;AACX,EAAE,MAAM,KAAK,GAAG;AAChB,IAAI,GAAG,SAAS;AAChB,IAAI,GAAG;AACP,IAAI,IAAI;AACR,IAAI;AACJ,GAAG;AACH,EAAE,MAAM,EAAE,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_google_ignoreList":[0]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
const maybeReactUseId = React["useId".toString()];
|
|
4
|
+
let globalId = BigInt(0);
|
|
5
|
+
function useIdLegacy(idOverride) {
|
|
6
|
+
const [defaultId, setDefaultId] = React.useState(idOverride);
|
|
7
|
+
const id = idOverride || defaultId;
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
if (defaultId == null) {
|
|
10
|
+
setDefaultId(`salt-${++globalId}`);
|
|
11
|
+
}
|
|
12
|
+
}, [defaultId]);
|
|
13
|
+
return id;
|
|
14
|
+
}
|
|
15
|
+
function useId(idOverride) {
|
|
16
|
+
if (maybeReactUseId !== void 0) {
|
|
17
|
+
const reactId = maybeReactUseId();
|
|
18
|
+
return idOverride ?? reactId;
|
|
19
|
+
}
|
|
20
|
+
return useIdLegacy(idOverride);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { useId };
|
|
24
|
+
//# sourceMappingURL=useId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useId.js","sources":["../../../../../../../../node_modules/@salt-ds/core/dist-es/utils/useId.js"],"sourcesContent":["import * as React from 'react';\n\nconst maybeReactUseId = React[\"useId\".toString()];\nlet globalId = BigInt(0);\nfunction useIdLegacy(idOverride) {\n const [defaultId, setDefaultId] = React.useState(idOverride);\n const id = idOverride || defaultId;\n React.useEffect(() => {\n if (defaultId == null) {\n setDefaultId(`salt-${++globalId}`);\n }\n }, [defaultId]);\n return id;\n}\nfunction useId(idOverride) {\n if (maybeReactUseId !== void 0) {\n const reactId = maybeReactUseId();\n return idOverride ?? reactId;\n }\n return useIdLegacy(idOverride);\n}\nfunction useIdMemo(idOverride) {\n return React.useMemo(() => {\n return idOverride ?? `salt-${++globalId}`;\n }, [idOverride]);\n}\n\nexport { useId, useIdMemo };\n//# sourceMappingURL=useId.js.map\n"],"names":[],"mappings":";;AAEA,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;AACjD,IAAI,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC;AACxB,SAAS,WAAW,CAAC,UAAU,EAAE;AACjC,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;AAC9D,EAAE,MAAM,EAAE,GAAG,UAAU,IAAI,SAAS;AACpC,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM;AACxB,IAAI,IAAI,SAAS,IAAI,IAAI,EAAE;AAC3B,MAAM,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxC;AACA,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AACjB,EAAE,OAAO,EAAE;AACX;AACA,SAAS,KAAK,CAAC,UAAU,EAAE;AAC3B,EAAE,IAAI,eAAe,KAAK,KAAK,CAAC,EAAE;AAClC,IAAI,MAAM,OAAO,GAAG,eAAe,EAAE;AACrC,IAAI,OAAO,UAAU,IAAI,OAAO;AAChC;AACA,EAAE,OAAO,WAAW,CAAC,UAAU,CAAC;AAChC;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useLayoutEffect, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useIsomorphicLayoutEffect = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined" ? useLayoutEffect : useEffect;
|
|
4
|
+
|
|
5
|
+
export { useIsomorphicLayoutEffect };
|
|
6
|
+
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.js","sources":["../../../../../../../../node_modules/@salt-ds/core/dist-es/utils/useIsomorphicLayoutEffect.js"],"sourcesContent":["import { useLayoutEffect, useEffect } from 'react';\n\nconst useIsomorphicLayoutEffect = typeof window !== \"undefined\" && typeof window.document !== \"undefined\" && typeof window.document.createElement !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport { useIsomorphicLayoutEffect };\n//# sourceMappingURL=useIsomorphicLayoutEffect.js.map\n"],"names":[],"mappings":";;AAEK,MAAC,yBAAyB,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,CAAC,aAAa,KAAK,WAAW,GAAG,eAAe,GAAG;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { createChainedFunction } from './createChainedFunction.js';
|
|
2
|
+
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js';
|
|
3
|
+
|
|
4
|
+
const visualViewport = typeof document !== "undefined" && window.visualViewport;
|
|
5
|
+
const nonTextInputTypes = /* @__PURE__ */ new Set([
|
|
6
|
+
"checkbox",
|
|
7
|
+
"radio",
|
|
8
|
+
"range",
|
|
9
|
+
"color",
|
|
10
|
+
"file",
|
|
11
|
+
"image",
|
|
12
|
+
"button",
|
|
13
|
+
"submit",
|
|
14
|
+
"reset"
|
|
15
|
+
]);
|
|
16
|
+
let preventScrollCount = 0;
|
|
17
|
+
let restore;
|
|
18
|
+
function usePreventScroll(options = {}) {
|
|
19
|
+
const { isDisabled } = options;
|
|
20
|
+
useIsomorphicLayoutEffect(() => {
|
|
21
|
+
if (isDisabled) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
preventScrollCount++;
|
|
25
|
+
if (preventScrollCount === 1) {
|
|
26
|
+
if (isIOS()) {
|
|
27
|
+
restore = preventScrollMobileSafari();
|
|
28
|
+
} else {
|
|
29
|
+
restore = preventScrollStandard();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return () => {
|
|
33
|
+
preventScrollCount--;
|
|
34
|
+
if (preventScrollCount === 0) {
|
|
35
|
+
restore();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}, [isDisabled]);
|
|
39
|
+
}
|
|
40
|
+
function preventScrollStandard() {
|
|
41
|
+
return createChainedFunction(
|
|
42
|
+
setStyle(
|
|
43
|
+
document.documentElement,
|
|
44
|
+
"paddingRight",
|
|
45
|
+
`${window.innerWidth - document.documentElement.clientWidth}px`
|
|
46
|
+
),
|
|
47
|
+
setStyle(document.documentElement, "overflow", "hidden")
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
function preventScrollMobileSafari() {
|
|
51
|
+
let scrollable;
|
|
52
|
+
let restoreScrollableStyles;
|
|
53
|
+
const onTouchStart = (e) => {
|
|
54
|
+
scrollable = getScrollParent(e.target, true);
|
|
55
|
+
if (scrollable === document.documentElement && scrollable === document.body) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (scrollable instanceof HTMLElement && window.getComputedStyle(scrollable).overscrollBehavior === "auto") {
|
|
59
|
+
restoreScrollableStyles = setStyle(
|
|
60
|
+
scrollable,
|
|
61
|
+
"overscrollBehavior",
|
|
62
|
+
"contain"
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const onTouchMove = (e) => {
|
|
67
|
+
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (scrollable.scrollHeight === scrollable.clientHeight && scrollable.scrollWidth === scrollable.clientWidth) {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const onTouchEnd = () => {
|
|
76
|
+
if (restoreScrollableStyles) {
|
|
77
|
+
restoreScrollableStyles();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const onFocus = (e) => {
|
|
81
|
+
const target = e.target;
|
|
82
|
+
if (willOpenKeyboard(target)) {
|
|
83
|
+
setupStyles();
|
|
84
|
+
target.style.transform = "translateY(-2000px)";
|
|
85
|
+
requestAnimationFrame(() => {
|
|
86
|
+
target.style.transform = "";
|
|
87
|
+
if (visualViewport) {
|
|
88
|
+
if (visualViewport.height < window.innerHeight) {
|
|
89
|
+
requestAnimationFrame(() => {
|
|
90
|
+
scrollIntoView(target);
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
visualViewport.addEventListener(
|
|
94
|
+
"resize",
|
|
95
|
+
() => scrollIntoView(target),
|
|
96
|
+
{ once: true }
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
let restoreStyles = null;
|
|
104
|
+
const setupStyles = () => {
|
|
105
|
+
if (restoreStyles) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const onWindowScroll = () => {
|
|
109
|
+
window.scrollTo(0, 0);
|
|
110
|
+
};
|
|
111
|
+
const scrollX = window.pageXOffset;
|
|
112
|
+
const scrollY = window.pageYOffset;
|
|
113
|
+
restoreStyles = createChainedFunction(
|
|
114
|
+
addEvent(window, "scroll", onWindowScroll),
|
|
115
|
+
setStyle(
|
|
116
|
+
document.documentElement,
|
|
117
|
+
"paddingRight",
|
|
118
|
+
`${window.innerWidth - document.documentElement.clientWidth}px`
|
|
119
|
+
),
|
|
120
|
+
setStyle(document.documentElement, "overflow", "hidden"),
|
|
121
|
+
setStyle(document.body, "marginTop", `-${scrollY}px`),
|
|
122
|
+
() => {
|
|
123
|
+
window.scrollTo(scrollX, scrollY);
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
window.scrollTo(0, 0);
|
|
127
|
+
};
|
|
128
|
+
const removeEvents = createChainedFunction(
|
|
129
|
+
addEvent(document, "touchstart", onTouchStart, {
|
|
130
|
+
passive: false,
|
|
131
|
+
capture: true
|
|
132
|
+
}),
|
|
133
|
+
addEvent(document, "touchmove", onTouchMove, {
|
|
134
|
+
passive: false,
|
|
135
|
+
capture: true
|
|
136
|
+
}),
|
|
137
|
+
addEvent(document, "touchend", onTouchEnd, {
|
|
138
|
+
passive: false,
|
|
139
|
+
capture: true
|
|
140
|
+
}),
|
|
141
|
+
addEvent(document, "focus", onFocus, true)
|
|
142
|
+
);
|
|
143
|
+
return () => {
|
|
144
|
+
restoreScrollableStyles == null ? void 0 : restoreScrollableStyles();
|
|
145
|
+
restoreStyles == null ? void 0 : restoreStyles();
|
|
146
|
+
removeEvents();
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function setStyle(element, style, value) {
|
|
150
|
+
const cur = element.style[style];
|
|
151
|
+
element.style[style] = value;
|
|
152
|
+
return () => {
|
|
153
|
+
element.style[style] = cur;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function addEvent(target, event, handler, options) {
|
|
157
|
+
target.addEventListener(event, handler, options);
|
|
158
|
+
return () => {
|
|
159
|
+
target.removeEventListener(event, handler, options);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function scrollIntoView(target) {
|
|
163
|
+
const root = document.scrollingElement || document.documentElement;
|
|
164
|
+
let nextTarget = target;
|
|
165
|
+
while (nextTarget && nextTarget !== root) {
|
|
166
|
+
const scrollable = getScrollParent(nextTarget);
|
|
167
|
+
if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== nextTarget) {
|
|
168
|
+
const scrollableTop = scrollable.getBoundingClientRect().top;
|
|
169
|
+
const targetTop = nextTarget.getBoundingClientRect().top;
|
|
170
|
+
if (targetTop > scrollableTop + nextTarget.clientHeight) {
|
|
171
|
+
scrollable.scrollTop += targetTop - scrollableTop;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
nextTarget = scrollable.parentElement;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function willOpenKeyboard(target) {
|
|
178
|
+
return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
|
|
179
|
+
}
|
|
180
|
+
function isScrollable(node, checkForOverflow) {
|
|
181
|
+
if (!node) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const style = window.getComputedStyle(node);
|
|
185
|
+
let isScrollable2 = /(auto|scroll)/.test(
|
|
186
|
+
style.overflow + style.overflowX + style.overflowY
|
|
187
|
+
);
|
|
188
|
+
if (isScrollable2 && checkForOverflow) {
|
|
189
|
+
isScrollable2 = node.scrollHeight !== node.clientHeight || node.scrollWidth !== node.clientWidth;
|
|
190
|
+
}
|
|
191
|
+
return isScrollable2;
|
|
192
|
+
}
|
|
193
|
+
function getScrollParent(node, checkForOverflow) {
|
|
194
|
+
let scrollableNode = node;
|
|
195
|
+
if (isScrollable(scrollableNode, checkForOverflow)) {
|
|
196
|
+
scrollableNode = scrollableNode.parentElement;
|
|
197
|
+
}
|
|
198
|
+
while (scrollableNode && !isScrollable(scrollableNode, checkForOverflow)) {
|
|
199
|
+
scrollableNode = scrollableNode.parentElement;
|
|
200
|
+
}
|
|
201
|
+
return scrollableNode || document.scrollingElement || document.documentElement;
|
|
202
|
+
}
|
|
203
|
+
function testPlatform(re) {
|
|
204
|
+
var _a;
|
|
205
|
+
return typeof window !== "undefined" && window.navigator != null ? re.test(
|
|
206
|
+
// @ts-expect-error userAgentData is only supported in Chrome 90+
|
|
207
|
+
((_a = window.navigator.userAgentData) == null ? void 0 : _a.platform) || window.navigator.platform
|
|
208
|
+
) : false;
|
|
209
|
+
}
|
|
210
|
+
function cached(fn) {
|
|
211
|
+
if (process.env.NODE_ENV === "test") {
|
|
212
|
+
return fn;
|
|
213
|
+
}
|
|
214
|
+
let res = null;
|
|
215
|
+
return () => {
|
|
216
|
+
if (res == null) {
|
|
217
|
+
res = fn();
|
|
218
|
+
}
|
|
219
|
+
return res;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const isMac = cached(() => testPlatform(/^Mac/i));
|
|
223
|
+
const isIPhone = cached(() => testPlatform(/^iPhone/i));
|
|
224
|
+
const isIPad = cached(
|
|
225
|
+
() => testPlatform(/^iPad/i) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
226
|
+
isMac() && navigator.maxTouchPoints > 1
|
|
227
|
+
);
|
|
228
|
+
const isIOS = cached(() => isIPhone() || isIPad());
|
|
229
|
+
|
|
230
|
+
export { usePreventScroll };
|
|
231
|
+
//# sourceMappingURL=usePreventScroll.js.map
|