@pzerelles/headlessui-svelte 2.1.1-next.1 → 2.1.2-next.11
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/dist/button/Button.svelte +6 -10
- package/dist/button/Button.svelte.d.ts +34 -26
- package/dist/checkbox/Checkbox.svelte +43 -25
- package/dist/checkbox/Checkbox.svelte.d.ts +42 -28
- package/dist/close-button/CloseButton.svelte +5 -4
- package/dist/close-button/CloseButton.svelte.d.ts +36 -13
- package/dist/combobox/Combobox.svelte +2 -2
- package/dist/combobox/Combobox.svelte.d.ts +9 -9
- package/dist/data-interactive/DataInteractive.svelte +41 -0
- package/dist/data-interactive/DataInteractive.svelte.d.ts +39 -0
- package/dist/data-interactive/index.d.ts +1 -0
- package/dist/data-interactive/index.js +1 -0
- package/dist/description/Description.svelte +10 -53
- package/dist/description/Description.svelte.d.ts +15 -32
- package/dist/description/context.svelte.d.ts +17 -0
- package/dist/description/context.svelte.js +51 -0
- package/dist/dialog/Dialog.svelte +51 -0
- package/dist/dialog/Dialog.svelte.d.ts +60 -0
- package/dist/dialog/DialogBackdrop.svelte +39 -0
- package/dist/dialog/DialogBackdrop.svelte.d.ts +38 -0
- package/dist/dialog/DialogPanel.svelte +46 -0
- package/dist/dialog/DialogPanel.svelte.d.ts +40 -0
- package/dist/dialog/DialogTitle.svelte +29 -0
- package/dist/dialog/DialogTitle.svelte.d.ts +34 -0
- package/dist/dialog/InternalDialog.svelte +233 -0
- package/dist/dialog/InternalDialog.svelte.d.ts +42 -0
- package/dist/dialog/context.svelte.d.ts +15 -0
- package/dist/dialog/context.svelte.js +16 -0
- package/dist/dialog/index.d.ts +4 -0
- package/dist/dialog/index.js +4 -0
- package/dist/field/Field.svelte +8 -11
- package/dist/field/Field.svelte.d.ts +21 -17
- package/dist/fieldset/Fieldset.svelte +11 -9
- package/dist/fieldset/Fieldset.svelte.d.ts +21 -17
- package/dist/focus-trap/FocusTrap.svelte +325 -0
- package/dist/focus-trap/FocusTrap.svelte.d.ts +46 -0
- package/dist/focus-trap/FocusTrapFeatures.d.ts +14 -0
- package/dist/focus-trap/FocusTrapFeatures.js +15 -0
- package/dist/hooks/use-controllable.svelte.d.ts +1 -1
- package/dist/hooks/use-controllable.svelte.js +3 -3
- package/dist/hooks/use-did-element-move.svelte.js +5 -10
- package/dist/hooks/use-escape.svelte.d.ts +5 -0
- package/dist/hooks/use-escape.svelte.js +26 -0
- package/dist/hooks/use-event-listener.svelte.d.ts +6 -0
- package/dist/hooks/use-event-listener.svelte.js +12 -0
- package/dist/hooks/use-inert-others.svelte.d.ts +2 -2
- package/dist/hooks/use-inert-others.svelte.js +3 -3
- package/dist/hooks/use-is-mounted.svelte.d.ts +3 -0
- package/dist/hooks/use-is-mounted.svelte.js +14 -0
- package/dist/hooks/use-is-touch-device.svelte.d.ts +3 -0
- package/dist/hooks/use-is-touch-device.svelte.js +20 -0
- package/dist/hooks/use-root-containers.svelte.d.ts +9 -0
- package/dist/hooks/use-root-containers.svelte.js +50 -0
- package/dist/hooks/use-tab-direction.svelte.d.ts +7 -0
- package/dist/hooks/use-tab-direction.svelte.js +25 -0
- package/dist/hooks/use-transition.svelte.js +14 -13
- package/dist/hooks/use-tree-walker.svelte.d.ts +8 -0
- package/dist/hooks/use-tree-walker.svelte.js +19 -0
- package/dist/hooks/use-watch.svelte.d.ts +4 -0
- package/dist/hooks/use-watch.svelte.js +16 -0
- package/dist/hooks/use-window-event.svelte.d.ts +6 -0
- package/dist/hooks/use-window-event.svelte.js +12 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/input/Input.svelte +59 -0
- package/dist/input/Input.svelte.d.ts +50 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.js +1 -0
- package/dist/internal/FloatingProvider.svelte +12 -0
- package/dist/internal/FloatingProvider.svelte.d.ts +22 -0
- package/dist/internal/FocusSentinel.svelte.d.ts +4 -1
- package/dist/internal/ForcePortalRoot.svelte +6 -0
- package/dist/internal/ForcePortalRoot.svelte.d.ts +22 -0
- package/dist/internal/FormFields.svelte.d.ts +4 -1
- package/dist/internal/FormResolver.svelte.d.ts +4 -1
- package/dist/internal/Hidden.svelte +6 -14
- package/dist/internal/Hidden.svelte.d.ts +19 -15
- package/dist/internal/HiddenFeatures.d.ts +5 -0
- package/dist/internal/HiddenFeatures.js +9 -0
- package/dist/internal/HoistFormFields.svelte.d.ts +4 -1
- package/dist/internal/MainTreeProvider.svelte +45 -0
- package/dist/internal/MainTreeProvider.svelte.d.ts +31 -0
- package/dist/internal/Portal.svelte.d.ts +4 -1
- package/dist/internal/close-provider.d.ts +7 -0
- package/dist/internal/close-provider.js +7 -0
- package/dist/internal/floating-provider.svelte.d.ts +3 -0
- package/dist/internal/floating-provider.svelte.js +206 -0
- package/dist/internal/floating.svelte.d.ts +50 -20
- package/dist/internal/floating.svelte.js +100 -271
- package/dist/internal/inner.svelte.d.ts +91 -0
- package/dist/internal/inner.svelte.js +202 -0
- package/dist/internal/open-closed.d.ts +1 -1
- package/dist/internal/open-closed.js +1 -1
- package/dist/label/Label.svelte +17 -65
- package/dist/label/Label.svelte.d.ts +19 -32
- package/dist/label/context.svelte.d.ts +17 -0
- package/dist/label/context.svelte.js +56 -0
- package/dist/legend/Legend.svelte +4 -3
- package/dist/legend/Legend.svelte.d.ts +33 -15
- package/dist/listbox/Listbox.svelte +40 -74
- package/dist/listbox/Listbox.svelte.d.ts +30 -72
- package/dist/listbox/ListboxButton.svelte +16 -18
- package/dist/listbox/ListboxButton.svelte.d.ts +16 -7
- package/dist/listbox/ListboxOption.svelte +10 -10
- package/dist/listbox/ListboxOption.svelte.d.ts +22 -11
- package/dist/listbox/ListboxOptions.svelte +62 -60
- package/dist/listbox/ListboxOptions.svelte.d.ts +23 -7
- package/dist/listbox/ListboxSelectedOption.svelte +15 -7
- package/dist/listbox/ListboxSelectedOption.svelte.d.ts +24 -14
- package/dist/listbox/context.svelte.d.ts +75 -0
- package/dist/listbox/context.svelte.js +36 -0
- package/dist/menu/Menu.svelte +235 -0
- package/dist/menu/Menu.svelte.d.ts +42 -0
- package/dist/menu/MenuButton.svelte +129 -0
- package/dist/menu/MenuButton.svelte.d.ts +52 -0
- package/dist/menu/MenuHeading.svelte +19 -0
- package/dist/menu/MenuHeading.svelte.d.ts +39 -0
- package/dist/menu/MenuItem.svelte +114 -0
- package/dist/menu/MenuItem.svelte.d.ts +49 -0
- package/dist/menu/MenuItems.svelte +248 -0
- package/dist/menu/MenuItems.svelte.d.ts +55 -0
- package/dist/menu/MenuSection.svelte +14 -0
- package/dist/menu/MenuSection.svelte.d.ts +35 -0
- package/dist/menu/MenuSeparator.svelte +9 -0
- package/dist/menu/MenuSeparator.svelte.d.ts +35 -0
- package/dist/menu/context.svelte.d.ts +47 -0
- package/dist/menu/context.svelte.js +21 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.js +7 -0
- package/dist/portal/InternalPortal.svelte +22 -33
- package/dist/portal/InternalPortal.svelte.d.ts +16 -7
- package/dist/portal/Portal.svelte +4 -8
- package/dist/portal/Portal.svelte.d.ts +6 -6
- package/dist/portal/PortalGroup.svelte +5 -6
- package/dist/portal/PortalGroup.svelte.d.ts +16 -7
- package/dist/switch/Switch.svelte +41 -37
- package/dist/switch/Switch.svelte.d.ts +24 -7
- package/dist/switch/SwitchGroup.svelte +7 -8
- package/dist/switch/SwitchGroup.svelte.d.ts +14 -7
- package/dist/tabs/Tab.svelte +9 -14
- package/dist/tabs/Tab.svelte.d.ts +18 -6
- package/dist/tabs/TabGroup.svelte +20 -23
- package/dist/tabs/TabGroup.svelte.d.ts +19 -6
- package/dist/tabs/TabList.svelte +5 -7
- package/dist/tabs/TabList.svelte.d.ts +13 -6
- package/dist/tabs/TabPanel.svelte +30 -32
- package/dist/tabs/TabPanel.svelte.d.ts +19 -6
- package/dist/tabs/TabPanels.svelte +5 -6
- package/dist/tabs/TabPanels.svelte.d.ts +13 -6
- package/dist/textarea/Textarea.svelte +67 -0
- package/dist/textarea/Textarea.svelte.d.ts +50 -0
- package/dist/textarea/index.d.ts +1 -0
- package/dist/textarea/index.js +1 -0
- package/dist/transition/InternalTransitionChild.svelte +178 -0
- package/dist/transition/InternalTransitionChild.svelte.d.ts +55 -0
- package/dist/transition/Transition.svelte +89 -0
- package/dist/transition/Transition.svelte.d.ts +42 -0
- package/dist/transition/TransitionChild.svelte +16 -0
- package/dist/transition/TransitionChild.svelte.d.ts +44 -0
- package/dist/transition/context.svelte.d.ts +64 -0
- package/dist/transition/context.svelte.js +120 -0
- package/dist/transition/index.d.ts +2 -0
- package/dist/transition/index.js +2 -0
- package/dist/utils/ElementOrComponent.svelte +26 -0
- package/dist/utils/ElementOrComponent.svelte.d.ts +56 -0
- package/dist/utils/Generic.svelte +44 -0
- package/dist/utils/Generic.svelte.d.ts +35 -0
- package/dist/utils/StableCollection.svelte +1 -1
- package/dist/utils/StableCollection.svelte.d.ts +4 -1
- package/dist/utils/active-element-history.d.ts +1 -0
- package/dist/utils/active-element-history.js +35 -0
- package/dist/utils/alternative-types.d.ts +21 -0
- package/dist/utils/alternative-types.js +1 -0
- package/dist/utils/class-names.d.ts +1 -0
- package/dist/utils/class-names.js +10 -0
- package/dist/utils/floating-ui/svelte/components/FloatingNode.svelte +17 -0
- package/dist/utils/floating-ui/svelte/components/FloatingNode.svelte.d.ts +23 -0
- package/dist/utils/floating-ui/svelte/components/FloatingTree.svelte +50 -0
- package/dist/utils/floating-ui/svelte/components/FloatingTree.svelte.d.ts +41 -0
- package/dist/utils/floating-ui/svelte/hooks/useFloating.svelte.d.ts +6 -0
- package/dist/utils/floating-ui/svelte/hooks/useFloating.svelte.js +158 -0
- package/dist/utils/floating-ui/svelte/hooks/useFloatingRootContext.svelte.d.ts +11 -0
- package/dist/utils/floating-ui/svelte/hooks/useFloatingRootContext.svelte.js +53 -0
- package/dist/utils/floating-ui/svelte/hooks/useId.svelte.d.ts +9 -0
- package/dist/utils/floating-ui/svelte/hooks/useId.svelte.js +28 -0
- package/dist/utils/floating-ui/svelte/hooks/useInteractions.svelte.d.ts +23 -0
- package/dist/utils/floating-ui/svelte/hooks/useInteractions.svelte.js +72 -0
- package/dist/utils/floating-ui/svelte/index.d.ts +5 -0
- package/dist/utils/floating-ui/svelte/index.js +5 -0
- package/dist/utils/floating-ui/svelte/inner.svelte.d.ts +83 -0
- package/dist/utils/floating-ui/svelte/inner.svelte.js +178 -0
- package/dist/utils/floating-ui/svelte/types.d.ts +114 -0
- package/dist/utils/floating-ui/svelte/types.js +1 -0
- package/dist/utils/floating-ui/svelte/utils/createPubSub.d.ts +5 -0
- package/dist/utils/floating-ui/svelte/utils/createPubSub.js +14 -0
- package/dist/utils/floating-ui/svelte/utils/getFloatingFocusElement.d.ts +2 -0
- package/dist/utils/floating-ui/svelte/utils/getFloatingFocusElement.js +13 -0
- package/dist/utils/floating-ui/svelte/utils/log.d.ts +2 -0
- package/dist/utils/floating-ui/svelte/utils/log.js +19 -0
- package/dist/utils/floating-ui/svelte/utils.d.ts +19 -0
- package/dist/utils/floating-ui/svelte/utils.js +136 -0
- package/dist/utils/floating-ui/svelte-dom/arrow.d.ts +22 -0
- package/dist/utils/floating-ui/svelte-dom/arrow.js +29 -0
- package/dist/utils/floating-ui/svelte-dom/index.d.ts +2 -0
- package/dist/utils/floating-ui/svelte-dom/index.js +2 -0
- package/dist/utils/floating-ui/svelte-dom/types.d.ts +80 -0
- package/dist/utils/floating-ui/svelte-dom/types.js +3 -0
- package/dist/utils/floating-ui/svelte-dom/useFloating.svelte.d.ts +6 -0
- package/dist/utils/floating-ui/svelte-dom/useFloating.svelte.js +183 -0
- package/dist/utils/floating-ui/svelte-dom/utils/deepEqual.d.ts +1 -0
- package/dist/utils/floating-ui/svelte-dom/utils/deepEqual.js +50 -0
- package/dist/utils/floating-ui/svelte-dom/utils/getDPR.d.ts +1 -0
- package/dist/utils/floating-ui/svelte-dom/utils/getDPR.js +7 -0
- package/dist/utils/floating-ui/svelte-dom/utils/roundByDPR.d.ts +1 -0
- package/dist/utils/floating-ui/svelte-dom/utils/roundByDPR.js +5 -0
- package/dist/utils/floating-ui/svelte-dom/utils/useLatestRef.d.ts +4 -0
- package/dist/utils/floating-ui/svelte-dom/utils/useLatestRef.js +7 -0
- package/dist/utils/focus-management.d.ts +2 -1
- package/dist/utils/focus-management.js +13 -13
- package/dist/utils/id.d.ts +1 -1
- package/dist/utils/id.js +1 -1
- package/dist/utils/on-document-ready.d.ts +1 -0
- package/dist/utils/on-document-ready.js +12 -0
- package/dist/utils/render.d.ts +3 -0
- package/dist/utils/render.js +63 -0
- package/dist/utils/state.d.ts +7 -1
- package/dist/utils/state.js +10 -6
- package/dist/utils/style.d.ts +2 -0
- package/dist/utils/style.js +6 -0
- package/dist/utils/types.d.ts +14 -17
- package/dist/utils/types.js +0 -5
- package/package.json +33 -31
- package/dist/internal/id.d.ts +0 -8
- package/dist/internal/id.js +0 -11
- package/dist/tabs/Button.svelte +0 -65
- package/dist/tabs/Button.svelte.d.ts +0 -39
- package/dist/utils/close.d.ts +0 -2
- package/dist/utils/close.js +0 -3
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { isHTMLElement, isShadowRoot } from "@floating-ui/utils/dom";
|
|
2
|
+
export function activeElement(doc) {
|
|
3
|
+
let activeElement = doc.activeElement;
|
|
4
|
+
while (activeElement?.shadowRoot?.activeElement != null) {
|
|
5
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
6
|
+
}
|
|
7
|
+
return activeElement;
|
|
8
|
+
}
|
|
9
|
+
export function contains(parent, child) {
|
|
10
|
+
if (!parent || !child) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const rootNode = child.getRootNode?.();
|
|
14
|
+
// First, attempt with faster native method
|
|
15
|
+
if (parent.contains(child)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
// then fallback to custom implementation with Shadow DOM support
|
|
19
|
+
if (rootNode && isShadowRoot(rootNode)) {
|
|
20
|
+
let next = child;
|
|
21
|
+
while (next) {
|
|
22
|
+
if (parent === next) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
next = next.parentNode || next.host;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Give up, the result is false
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
// Avoid Chrome DevTools blue warning.
|
|
33
|
+
export function getPlatform() {
|
|
34
|
+
const uaData = navigator.userAgentData;
|
|
35
|
+
if (uaData?.platform) {
|
|
36
|
+
return uaData.platform;
|
|
37
|
+
}
|
|
38
|
+
return navigator.platform;
|
|
39
|
+
}
|
|
40
|
+
export function getUserAgent() {
|
|
41
|
+
const uaData = navigator.userAgentData;
|
|
42
|
+
if (uaData && Array.isArray(uaData.brands)) {
|
|
43
|
+
return uaData.brands.map(({ brand, version }) => `${brand}/${version}`).join(" ");
|
|
44
|
+
}
|
|
45
|
+
return navigator.userAgent;
|
|
46
|
+
}
|
|
47
|
+
// License: https://github.com/adobe/react-spectrum/blob/b35d5c02fe900badccd0cf1a8f23bb593419f238/packages/@react-aria/utils/src/isVirtualEvent.ts
|
|
48
|
+
export function isVirtualClick(event) {
|
|
49
|
+
// FIXME: Firefox is now emitting a deprecation warning for `mozInputSource`.
|
|
50
|
+
// Try to find a workaround for this. `react-aria` source still has the check.
|
|
51
|
+
if (event.mozInputSource === 0 && event.isTrusted) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
if (isAndroid() && event.pointerType) {
|
|
55
|
+
return event.type === "click" && event.buttons === 1;
|
|
56
|
+
}
|
|
57
|
+
return event.detail === 0 && !event.pointerType;
|
|
58
|
+
}
|
|
59
|
+
export function isVirtualPointerEvent(event) {
|
|
60
|
+
if (isJSDOM())
|
|
61
|
+
return false;
|
|
62
|
+
return ((!isAndroid() && event.width === 0 && event.height === 0) ||
|
|
63
|
+
(isAndroid() &&
|
|
64
|
+
event.width === 1 &&
|
|
65
|
+
event.height === 1 &&
|
|
66
|
+
event.pressure === 0 &&
|
|
67
|
+
event.detail === 0 &&
|
|
68
|
+
event.pointerType === "mouse") ||
|
|
69
|
+
// iOS VoiceOver returns 0.333• for width/height.
|
|
70
|
+
(event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "touch"));
|
|
71
|
+
}
|
|
72
|
+
export function isSafari() {
|
|
73
|
+
// Chrome DevTools does not complain about navigator.vendor
|
|
74
|
+
return /apple/i.test(navigator.vendor);
|
|
75
|
+
}
|
|
76
|
+
export function isAndroid() {
|
|
77
|
+
const re = /android/i;
|
|
78
|
+
return re.test(getPlatform()) || re.test(getUserAgent());
|
|
79
|
+
}
|
|
80
|
+
export function isMac() {
|
|
81
|
+
return getPlatform().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
|
|
82
|
+
}
|
|
83
|
+
export function isJSDOM() {
|
|
84
|
+
return getUserAgent().includes("jsdom/");
|
|
85
|
+
}
|
|
86
|
+
export function isMouseLikePointerType(pointerType, strict) {
|
|
87
|
+
// On some Linux machines with Chromium, mouse inputs return a `pointerType`
|
|
88
|
+
// of "pen": https://github.com/floating-ui/floating-ui/issues/2015
|
|
89
|
+
const values = ["mouse", "pen"];
|
|
90
|
+
if (!strict) {
|
|
91
|
+
values.push("", undefined);
|
|
92
|
+
}
|
|
93
|
+
return values.includes(pointerType);
|
|
94
|
+
}
|
|
95
|
+
/*export function isReactEvent(event: any): event is React.SyntheticEvent {
|
|
96
|
+
return "nativeEvent" in event
|
|
97
|
+
}*/
|
|
98
|
+
export function isRootElement(element) {
|
|
99
|
+
return element.matches("html,body");
|
|
100
|
+
}
|
|
101
|
+
export function getDocument(node) {
|
|
102
|
+
return node?.ownerDocument || document;
|
|
103
|
+
}
|
|
104
|
+
export function isEventTargetWithin(event, node) {
|
|
105
|
+
if (node == null) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if ("composedPath" in event) {
|
|
109
|
+
return event.composedPath().includes(node);
|
|
110
|
+
}
|
|
111
|
+
// TS thinks `event` is of type never as it assumes all browsers support composedPath, but browsers without shadow dom don't
|
|
112
|
+
const e = event;
|
|
113
|
+
return e.target != null && node.contains(e.target);
|
|
114
|
+
}
|
|
115
|
+
export function getTarget(event) {
|
|
116
|
+
if ("composedPath" in event) {
|
|
117
|
+
return event.composedPath()[0];
|
|
118
|
+
}
|
|
119
|
+
// TS thinks `event` is of type never as it assumes all browsers support
|
|
120
|
+
// `composedPath()`, but browsers without shadow DOM don't.
|
|
121
|
+
return event.target;
|
|
122
|
+
}
|
|
123
|
+
export const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled])," +
|
|
124
|
+
"[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
|
|
125
|
+
export function isTypeableElement(element) {
|
|
126
|
+
return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
|
|
127
|
+
}
|
|
128
|
+
export function stopEvent(event /*| React.SyntheticEvent*/) {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
event.stopPropagation();
|
|
131
|
+
}
|
|
132
|
+
export function isTypeableCombobox(element) {
|
|
133
|
+
if (!element)
|
|
134
|
+
return false;
|
|
135
|
+
return element.getAttribute("role") === "combobox" && isTypeableElement(element);
|
|
136
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MutableRefObject } from "../../ref.svelte.js";
|
|
2
|
+
import type { Derivable, Middleware, Padding } from "@floating-ui/dom";
|
|
3
|
+
export interface ArrowOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The arrow element to be positioned.
|
|
6
|
+
* @default undefined
|
|
7
|
+
*/
|
|
8
|
+
element: MutableRefObject<Element | null> | Element | null;
|
|
9
|
+
/**
|
|
10
|
+
* The padding between the arrow element and the floating element edges.
|
|
11
|
+
* Useful when the floating element has rounded corners.
|
|
12
|
+
* @default 0
|
|
13
|
+
*/
|
|
14
|
+
padding?: Padding;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Provides data to position an inner element of the floating element so that it
|
|
18
|
+
* appears centered to the reference element.
|
|
19
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
20
|
+
* @see https://floating-ui.com/docs/arrow
|
|
21
|
+
*/
|
|
22
|
+
export declare const arrow: (options: ArrowOptions | Derivable<ArrowOptions>) => Middleware;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { arrow as arrowCore } from "@floating-ui/dom";
|
|
2
|
+
/**
|
|
3
|
+
* Provides data to position an inner element of the floating element so that it
|
|
4
|
+
* appears centered to the reference element.
|
|
5
|
+
* This wraps the core `arrow` middleware to allow React refs as the element.
|
|
6
|
+
* @see https://floating-ui.com/docs/arrow
|
|
7
|
+
*/
|
|
8
|
+
export const arrow = (options) => {
|
|
9
|
+
function isRef(value) {
|
|
10
|
+
return {}.hasOwnProperty.call(value, "current");
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
name: "arrow",
|
|
14
|
+
options,
|
|
15
|
+
fn(state) {
|
|
16
|
+
const { element, padding } = typeof options === "function" ? options(state) : options;
|
|
17
|
+
if (element && isRef(element)) {
|
|
18
|
+
if (element.current != null) {
|
|
19
|
+
return arrowCore({ element: element.current, padding }).fn(state);
|
|
20
|
+
}
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
if (element) {
|
|
24
|
+
return arrowCore({ element, padding }).fn(state);
|
|
25
|
+
}
|
|
26
|
+
return {};
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { MutableRefObject } from "../../ref.svelte.js";
|
|
2
|
+
import type { ComputePositionConfig, ComputePositionReturn, VirtualElement } from "@floating-ui/dom";
|
|
3
|
+
export type { ArrowOptions } from "./arrow.js";
|
|
4
|
+
export { arrow } from "./arrow.js";
|
|
5
|
+
export { useFloating } from "./useFloating.svelte.js";
|
|
6
|
+
export type { AlignedPlacement, Alignment, AutoPlacementOptions, AutoUpdateOptions, Axis, Boundary, ClientRectObject, ComputePositionConfig, ComputePositionReturn, Coords, Derivable, DetectOverflowOptions, Dimensions, ElementContext, ElementRects, Elements, FlipOptions, FloatingElement, HideOptions, InlineOptions, Length, Middleware, MiddlewareArguments, MiddlewareData, MiddlewareReturn, MiddlewareState, NodeScroll, OffsetOptions, Padding, Placement, Platform, Rect, ReferenceElement, RootBoundary, ShiftOptions, Side, SideObject, SizeOptions, Strategy, VirtualElement, } from "@floating-ui/dom";
|
|
7
|
+
export { autoPlacement, autoUpdate, computePosition, detectOverflow, flip, getOverflowAncestors, hide, inline, limitShift, offset, platform, shift, size, } from "@floating-ui/dom";
|
|
8
|
+
type Prettify<T> = {
|
|
9
|
+
[K in keyof T]: T[K];
|
|
10
|
+
} & {};
|
|
11
|
+
export type UseFloatingData = Prettify<ComputePositionReturn & {
|
|
12
|
+
isPositioned: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
export type ReferenceType = Element | VirtualElement;
|
|
15
|
+
export type UseFloatingReturn<RT extends ReferenceType = ReferenceType> = Prettify<UseFloatingData & {
|
|
16
|
+
/**
|
|
17
|
+
* Update the position of the floating element, re-rendering the component
|
|
18
|
+
* if required.
|
|
19
|
+
*/
|
|
20
|
+
update: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Pre-configured positioning styles to apply to the floating element.
|
|
23
|
+
*/
|
|
24
|
+
floatingStyles: string;
|
|
25
|
+
/**
|
|
26
|
+
* Object containing the reference and floating refs and reactive setters.
|
|
27
|
+
*/
|
|
28
|
+
refs: {
|
|
29
|
+
/**
|
|
30
|
+
* A React ref to the reference element.
|
|
31
|
+
*/
|
|
32
|
+
reference: MutableRefObject<RT | null>;
|
|
33
|
+
/**
|
|
34
|
+
* A React ref to the floating element.
|
|
35
|
+
*/
|
|
36
|
+
floating: MutableRefObject<HTMLElement | null>;
|
|
37
|
+
/**
|
|
38
|
+
* A callback to set the reference element (reactive).
|
|
39
|
+
*/
|
|
40
|
+
setReference: (node: RT | null) => void;
|
|
41
|
+
/**
|
|
42
|
+
* A callback to set the floating element (reactive).
|
|
43
|
+
*/
|
|
44
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Object containing the reference and floating elements.
|
|
48
|
+
*/
|
|
49
|
+
elements: {
|
|
50
|
+
reference: RT | null;
|
|
51
|
+
floating: HTMLElement | null;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
export type UseFloatingOptions<RT extends ReferenceType = ReferenceType> = Prettify<Partial<ComputePositionConfig> & {
|
|
55
|
+
/**
|
|
56
|
+
* A callback invoked when both the reference and floating elements are
|
|
57
|
+
* mounted, and cleaned up when either is unmounted. This is useful for
|
|
58
|
+
* setting up event listeners (e.g. pass `autoUpdate`).
|
|
59
|
+
*/
|
|
60
|
+
whileElementsMounted?: (reference: RT, floating: HTMLElement, update: () => void) => () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Object containing the reference and floating elements.
|
|
63
|
+
*/
|
|
64
|
+
elements?: {
|
|
65
|
+
reference?: RT | null;
|
|
66
|
+
floating?: HTMLElement | null;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* The `open` state of the floating element to synchronize with the
|
|
70
|
+
* `isPositioned` value.
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
open?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Whether to use `transform` for positioning instead of `top` and `left`
|
|
76
|
+
* (layout) in the `floatingStyles` object.
|
|
77
|
+
* @default false
|
|
78
|
+
*/
|
|
79
|
+
transform?: boolean;
|
|
80
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReferenceType, UseFloatingOptions, UseFloatingReturn } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Provides data to position a floating element.
|
|
4
|
+
* @see https://floating-ui.com/docs/useFloating
|
|
5
|
+
*/
|
|
6
|
+
export declare function useFloating<RT extends ReferenceType = ReferenceType>(options?: UseFloatingOptions): UseFloatingReturn<RT>;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { computePosition } from "@floating-ui/dom";
|
|
2
|
+
import { deepEqual } from "./utils/deepEqual.js";
|
|
3
|
+
import { getDPR } from "./utils/getDPR.js";
|
|
4
|
+
import { roundByDPR } from "./utils/roundByDPR.js";
|
|
5
|
+
import { useLatestRef } from "./utils/useLatestRef.js";
|
|
6
|
+
import { tick, untrack } from "svelte";
|
|
7
|
+
import { stylePropsToString } from "../../style.js";
|
|
8
|
+
/**
|
|
9
|
+
* Provides data to position a floating element.
|
|
10
|
+
* @see https://floating-ui.com/docs/useFloating
|
|
11
|
+
*/
|
|
12
|
+
export function useFloating(options = {}) {
|
|
13
|
+
const { placement = "bottom", strategy = "absolute", middleware = [], platform, elements: externalElements = {}, transform = true, whileElementsMounted, open, } = $derived(options);
|
|
14
|
+
const { reference: externalReference, floating: externalFloating } = $derived(externalElements);
|
|
15
|
+
let data = $state({
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
strategy,
|
|
19
|
+
placement,
|
|
20
|
+
middlewareData: {},
|
|
21
|
+
isPositioned: false,
|
|
22
|
+
});
|
|
23
|
+
const setData = (value) => (data = value);
|
|
24
|
+
let latestMiddleware = $state(middleware);
|
|
25
|
+
$effect(() => {
|
|
26
|
+
if (!deepEqual(latestMiddleware, middleware)) {
|
|
27
|
+
latestMiddleware = middleware;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
let _reference = $state(null);
|
|
31
|
+
let _floating = $state(null);
|
|
32
|
+
const setReference = (node) => {
|
|
33
|
+
if (node !== referenceRef.current) {
|
|
34
|
+
referenceRef.current = node;
|
|
35
|
+
_reference = node;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const setFloating = (node) => {
|
|
39
|
+
if (node !== floatingRef.current) {
|
|
40
|
+
floatingRef.current = node;
|
|
41
|
+
_floating = node;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const referenceEl = $derived((externalReference || _reference));
|
|
45
|
+
const floatingEl = $derived(externalFloating || _floating);
|
|
46
|
+
const referenceRef = $state({ current: null });
|
|
47
|
+
const floatingRef = $state({ current: null });
|
|
48
|
+
const dataRef = $state({ current: data });
|
|
49
|
+
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
50
|
+
const whileElementsMountedRef = useLatestRef({
|
|
51
|
+
get value() {
|
|
52
|
+
return whileElementsMounted;
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const platformRef = useLatestRef({
|
|
56
|
+
get value() {
|
|
57
|
+
return platform;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
const openRef = useLatestRef({
|
|
61
|
+
get value() {
|
|
62
|
+
return open;
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const update = () => {
|
|
66
|
+
if (!referenceRef.current || !floatingRef.current) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const config = {
|
|
70
|
+
placement,
|
|
71
|
+
strategy,
|
|
72
|
+
middleware: latestMiddleware,
|
|
73
|
+
};
|
|
74
|
+
if (platformRef.current) {
|
|
75
|
+
config.platform = platformRef.current;
|
|
76
|
+
}
|
|
77
|
+
computePosition(referenceRef.current, floatingRef.current, config).then(async (data) => {
|
|
78
|
+
console.log("computing", config);
|
|
79
|
+
const fullData = {
|
|
80
|
+
...data,
|
|
81
|
+
// The floating element's position may be recomputed while it's closed
|
|
82
|
+
// but still mounted (such as when transitioning out). To ensure
|
|
83
|
+
// `isPositioned` will be `false` initially on the next open, avoid
|
|
84
|
+
// setting it to `true` when `open === false` (must be specified).
|
|
85
|
+
isPositioned: openRef.current !== false,
|
|
86
|
+
};
|
|
87
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
88
|
+
dataRef.current = fullData;
|
|
89
|
+
setData(fullData);
|
|
90
|
+
await tick();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
$effect(() => {
|
|
95
|
+
open;
|
|
96
|
+
untrack(() => {
|
|
97
|
+
if (open === false && dataRef.current.isPositioned) {
|
|
98
|
+
dataRef.current.isPositioned = false;
|
|
99
|
+
data.isPositioned = false;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
const isMountedRef = $state({ current: false });
|
|
104
|
+
$effect(() => {
|
|
105
|
+
isMountedRef.current = true;
|
|
106
|
+
return () => {
|
|
107
|
+
isMountedRef.current = false;
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
$effect(() => {
|
|
111
|
+
if (referenceEl)
|
|
112
|
+
referenceRef.current = referenceEl;
|
|
113
|
+
if (floatingEl)
|
|
114
|
+
floatingRef.current = floatingEl;
|
|
115
|
+
if (referenceEl && floatingEl) {
|
|
116
|
+
if (whileElementsMountedRef.current) {
|
|
117
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
118
|
+
}
|
|
119
|
+
update();
|
|
120
|
+
}
|
|
121
|
+
}); //, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted])
|
|
122
|
+
const refs = $derived({
|
|
123
|
+
reference: referenceRef,
|
|
124
|
+
floating: floatingRef,
|
|
125
|
+
setReference,
|
|
126
|
+
setFloating,
|
|
127
|
+
});
|
|
128
|
+
const elements = $derived({ reference: referenceEl, floating: floatingEl });
|
|
129
|
+
const floatingStyles = $derived.by(() => {
|
|
130
|
+
const initialStyles = {
|
|
131
|
+
position: strategy,
|
|
132
|
+
left: 0,
|
|
133
|
+
top: 0,
|
|
134
|
+
};
|
|
135
|
+
if (!elements.floating) {
|
|
136
|
+
return stylePropsToString(initialStyles);
|
|
137
|
+
}
|
|
138
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
139
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
140
|
+
if (transform) {
|
|
141
|
+
return stylePropsToString({
|
|
142
|
+
...initialStyles,
|
|
143
|
+
transform: `translate(${x}px, ${y}px)`,
|
|
144
|
+
...(getDPR(elements.floating) >= 1.5 && { "will-change": "transform" }),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return stylePropsToString({
|
|
148
|
+
position: strategy,
|
|
149
|
+
left: x,
|
|
150
|
+
top: y,
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
get placement() {
|
|
155
|
+
return data.placement;
|
|
156
|
+
},
|
|
157
|
+
get strategy() {
|
|
158
|
+
return data.strategy;
|
|
159
|
+
},
|
|
160
|
+
get middlewareData() {
|
|
161
|
+
return data.middlewareData;
|
|
162
|
+
},
|
|
163
|
+
get x() {
|
|
164
|
+
return data.x;
|
|
165
|
+
},
|
|
166
|
+
get y() {
|
|
167
|
+
return data.y;
|
|
168
|
+
},
|
|
169
|
+
get isPositioned() {
|
|
170
|
+
return data.isPositioned;
|
|
171
|
+
},
|
|
172
|
+
update,
|
|
173
|
+
get refs() {
|
|
174
|
+
return refs;
|
|
175
|
+
},
|
|
176
|
+
get elements() {
|
|
177
|
+
return elements;
|
|
178
|
+
},
|
|
179
|
+
get floatingStyles() {
|
|
180
|
+
return floatingStyles;
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepEqual(a: any, b: any): boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Fork of `fast-deep-equal` that only does the comparisons we need and compares
|
|
2
|
+
// functions
|
|
3
|
+
export function deepEqual(a, b) {
|
|
4
|
+
if (a === b) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (typeof a !== typeof b) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (typeof a === "function" && a.toString() === b.toString()) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
let length;
|
|
14
|
+
let i;
|
|
15
|
+
let keys;
|
|
16
|
+
if (a && b && typeof a === "object") {
|
|
17
|
+
if (Array.isArray(a)) {
|
|
18
|
+
length = a.length;
|
|
19
|
+
if (length !== b.length)
|
|
20
|
+
return false;
|
|
21
|
+
for (i = length; i-- !== 0;) {
|
|
22
|
+
if (!deepEqual(a[i], b[i])) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
keys = Object.keys(a);
|
|
29
|
+
length = keys.length;
|
|
30
|
+
if (length !== Object.keys(b).length) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
for (i = length; i-- !== 0;) {
|
|
34
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
for (i = length; i-- !== 0;) {
|
|
39
|
+
const key = keys[i];
|
|
40
|
+
if (key === "_owner" && a.$$typeof) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (!deepEqual(a[key], b[key])) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return a !== a && b !== b;
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDPR(element: Element): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function roundByDPR(element: Element, value: number): number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare let focusableSelector: string;
|
|
1
2
|
export declare enum Focus {
|
|
2
3
|
/** Focus the first non-disabled element */
|
|
3
4
|
First = 1,
|
|
@@ -35,7 +36,7 @@ export declare enum FocusableMode {
|
|
|
35
36
|
export declare function isFocusableElement(element: HTMLElement, mode?: FocusableMode): boolean;
|
|
36
37
|
export declare function restoreFocusIfNecessary(element: HTMLElement | null): void;
|
|
37
38
|
export declare function focusElement(element: HTMLElement | null): void;
|
|
38
|
-
export declare function sortByDomNode<T>(nodes: T[], resolveKey?: (item: T) => HTMLElement | null
|
|
39
|
+
export declare function sortByDomNode<T>(nodes: T[], resolveKey?: (item: T) => HTMLElement | null): T[];
|
|
39
40
|
export declare function focusFrom(current: HTMLElement | null, focus: Focus): FocusResult;
|
|
40
41
|
export declare function focusIn(container: HTMLElement | HTMLElement[], focus: Focus, { sorted, relativeTo, skipElements, }?: Partial<{
|
|
41
42
|
sorted: boolean;
|
|
@@ -3,7 +3,7 @@ import { match } from "./match.js";
|
|
|
3
3
|
import { getOwnerDocument } from "./owner.js";
|
|
4
4
|
// Credit:
|
|
5
5
|
// - https://stackoverflow.com/a/30753870
|
|
6
|
-
|
|
6
|
+
export let focusableSelector = [
|
|
7
7
|
"[contentEditable=true]",
|
|
8
8
|
"[tabindex]",
|
|
9
9
|
"a[href]",
|
|
@@ -21,7 +21,7 @@ const focusableSelector = [
|
|
|
21
21
|
(selector) => `${selector}:not([tabindex='-1']):not([style*='display: none'])`
|
|
22
22
|
: (selector) => `${selector}:not([tabindex='-1'])`)
|
|
23
23
|
.join(",");
|
|
24
|
-
|
|
24
|
+
let autoFocusableSelector = [
|
|
25
25
|
// In a perfect world this was just `autofocus`, but React doesn't pass `autofocus` to the DOM...
|
|
26
26
|
"[data-autofocus]",
|
|
27
27
|
]
|
|
@@ -105,7 +105,7 @@ export function isFocusableElement(element, mode = FocusableMode.Strict) {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
export function restoreFocusIfNecessary(element) {
|
|
108
|
-
|
|
108
|
+
let ownerDocument = getOwnerDocument(element);
|
|
109
109
|
disposables().nextFrame(() => {
|
|
110
110
|
if (ownerDocument && !isFocusableElement(ownerDocument.activeElement, FocusableMode.Strict)) {
|
|
111
111
|
focusElement(element);
|
|
@@ -144,17 +144,17 @@ export function focusElement(element) {
|
|
|
144
144
|
element?.focus({ preventScroll: true });
|
|
145
145
|
}
|
|
146
146
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select
|
|
147
|
-
|
|
147
|
+
let selectableSelector = ["textarea", "input"].join(",");
|
|
148
148
|
function isSelectableElement(element) {
|
|
149
149
|
return element?.matches?.(selectableSelector) ?? false;
|
|
150
150
|
}
|
|
151
151
|
export function sortByDomNode(nodes, resolveKey = (i) => i) {
|
|
152
152
|
return nodes.slice().sort((aItem, zItem) => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (
|
|
153
|
+
let a = resolveKey(aItem);
|
|
154
|
+
let z = resolveKey(zItem);
|
|
155
|
+
if (a === null || z === null)
|
|
156
156
|
return 0;
|
|
157
|
-
|
|
157
|
+
let position = a.compareDocumentPosition(z);
|
|
158
158
|
if (position & Node.DOCUMENT_POSITION_FOLLOWING)
|
|
159
159
|
return -1;
|
|
160
160
|
if (position & Node.DOCUMENT_POSITION_PRECEDING)
|
|
@@ -166,7 +166,7 @@ export function focusFrom(current, focus) {
|
|
|
166
166
|
return focusIn(getFocusableElements(), focus, { relativeTo: current });
|
|
167
167
|
}
|
|
168
168
|
export function focusIn(container, focus, { sorted = true, relativeTo = null, skipElements = [], } = {}) {
|
|
169
|
-
|
|
169
|
+
let ownerDocument = Array.isArray(container)
|
|
170
170
|
? container.length > 0
|
|
171
171
|
? container[0].ownerDocument
|
|
172
172
|
: document
|
|
@@ -185,14 +185,14 @@ export function focusIn(container, focus, { sorted = true, relativeTo = null, sk
|
|
|
185
185
|
));
|
|
186
186
|
}
|
|
187
187
|
relativeTo = relativeTo ?? ownerDocument.activeElement;
|
|
188
|
-
|
|
188
|
+
let direction = (() => {
|
|
189
189
|
if (focus & (Focus.First | Focus.Next))
|
|
190
190
|
return Direction.Next;
|
|
191
191
|
if (focus & (Focus.Previous | Focus.Last))
|
|
192
192
|
return Direction.Previous;
|
|
193
193
|
throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last");
|
|
194
194
|
})();
|
|
195
|
-
|
|
195
|
+
let startIndex = (() => {
|
|
196
196
|
if (focus & Focus.First)
|
|
197
197
|
return 0;
|
|
198
198
|
if (focus & Focus.Previous)
|
|
@@ -203,9 +203,9 @@ export function focusIn(container, focus, { sorted = true, relativeTo = null, sk
|
|
|
203
203
|
return elements.length - 1;
|
|
204
204
|
throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last");
|
|
205
205
|
})();
|
|
206
|
-
|
|
206
|
+
let focusOptions = focus & Focus.NoScroll ? { preventScroll: true } : {};
|
|
207
207
|
let offset = 0;
|
|
208
|
-
|
|
208
|
+
let total = elements.length;
|
|
209
209
|
let next = undefined;
|
|
210
210
|
do {
|
|
211
211
|
// Guard against infinite loops
|
package/dist/utils/id.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const alphaid: (size?: number) => string;
|
|
2
2
|
export declare const htmlid: (size?: number) => string;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const useProvidedId: () => string | undefined;
|
|
4
4
|
export declare const createIdContext: (id: string) => string | undefined;
|