@marianmeres/stuic 1.126.0 → 2.0.0-next.3
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/README.md +2 -8
- package/dist/_shared.css +2 -0
- package/dist/actions/autogrow.svelte.d.ts +6 -0
- package/dist/actions/autogrow.svelte.js +19 -0
- package/dist/actions/highlight-dragover.svelte.d.ts +7 -0
- package/dist/actions/highlight-dragover.svelte.js +38 -0
- package/dist/actions/index.d.ts +7 -0
- package/dist/actions/index.js +7 -0
- package/dist/actions/on-submit-validity-check.svelte.d.ts +15 -0
- package/dist/actions/on-submit-validity-check.svelte.js +58 -0
- package/dist/actions/tooltip/index.css +34 -0
- package/dist/actions/tooltip/tooltip.svelte.d.ts +13 -0
- package/dist/actions/tooltip/tooltip.svelte.js +203 -0
- package/dist/actions/trim.svelte.d.ts +4 -0
- package/dist/actions/trim.svelte.js +17 -0
- package/dist/actions/{validate.d.ts → validate.svelte.d.ts} +8 -8
- package/dist/actions/validate.svelte.js +90 -0
- package/dist/components/AlertConfirmPrompt/AlertConfirmPrompt.svelte +59 -385
- package/dist/components/AlertConfirmPrompt/AlertConfirmPrompt.svelte.d.ts +9 -101
- package/dist/components/AlertConfirmPrompt/Current.svelte +202 -0
- package/dist/components/AlertConfirmPrompt/Current.svelte.d.ts +22 -0
- package/dist/components/AlertConfirmPrompt/acp-icons.d.ts +7 -2
- package/dist/components/AlertConfirmPrompt/acp-icons.js +8 -8
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.d.ts +63 -0
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.js +144 -0
- package/dist/components/AlertConfirmPrompt/index.d.ts +2 -0
- package/dist/components/AlertConfirmPrompt/index.js +2 -0
- package/dist/components/AnimatedElipsis/AnimatedEllipsis.svelte +47 -0
- package/dist/components/AnimatedElipsis/AnimatedEllipsis.svelte.d.ts +7 -0
- package/dist/components/AnimatedElipsis/index.d.ts +1 -0
- package/dist/components/AnimatedElipsis/index.js +1 -0
- package/dist/components/AppShell/AppShell.svelte +188 -127
- package/dist/components/AppShell/AppShell.svelte.d.ts +62 -43
- package/dist/components/AppShell/index.d.ts +1 -0
- package/dist/components/AppShell/index.js +1 -0
- package/dist/components/Backdrop/Backdrop.svelte +149 -49
- package/dist/components/Backdrop/Backdrop.svelte.d.ts +22 -37
- package/dist/components/Backdrop/index.d.ts +1 -0
- package/dist/components/Backdrop/index.js +1 -0
- package/dist/components/Button/Button.svelte +122 -146
- package/dist/components/Button/Button.svelte.d.ts +22 -80
- package/dist/components/Button/index.css +16 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/ColResize/ColResize.svelte +0 -0
- package/dist/components/ColResize/ColResize.svelte.d.ts +26 -0
- package/dist/components/ColorScheme/{LocalColorScheme.svelte → ColorSchemeLocal.svelte} +2 -2
- package/dist/components/ColorScheme/ColorSchemeLocal.svelte.d.ts +26 -0
- package/dist/components/ColorScheme/{SystemAwareColorScheme.svelte → ColorSchemeSystemAware.svelte} +4 -4
- package/dist/components/ColorScheme/ColorSchemeSystemAware.svelte.d.ts +26 -0
- package/dist/components/ColorScheme/color-scheme.d.ts +26 -8
- package/dist/components/ColorScheme/color-scheme.js +40 -16
- package/dist/components/ColorScheme/index.d.ts +3 -0
- package/dist/components/ColorScheme/index.js +3 -0
- package/dist/components/DismissibleMessage/DismissibleMessage.svelte +76 -83
- package/dist/components/DismissibleMessage/DismissibleMessage.svelte.d.ts +16 -37
- package/dist/components/DismissibleMessage/index.css +13 -0
- package/dist/components/DismissibleMessage/index.d.ts +1 -0
- package/dist/components/DismissibleMessage/index.js +1 -0
- package/dist/components/Drawer/Drawer.svelte +155 -84
- package/dist/components/Drawer/Drawer.svelte.d.ts +24 -35
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/Drawer/index.js +1 -0
- package/dist/components/HoverExpandableWidth/HoverExpandableWidth.svelte +150 -111
- package/dist/components/HoverExpandableWidth/HoverExpandableWidth.svelte.d.ts +16 -29
- package/dist/components/HoverExpandableWidth/index.d.ts +1 -0
- package/dist/components/HoverExpandableWidth/index.js +1 -0
- package/dist/components/Input/FieldCheckbox.svelte +174 -132
- package/dist/components/Input/FieldCheckbox.svelte.d.ts +28 -64
- package/dist/components/Input/FieldFile.svelte +166 -0
- package/dist/components/Input/FieldFile.svelte.d.ts +41 -0
- package/dist/components/Input/FieldInput.svelte +143 -0
- package/dist/components/Input/FieldInput.svelte.d.ts +41 -0
- package/dist/components/Input/FieldLikeButton.svelte +206 -0
- package/dist/components/Input/FieldLikeButton.svelte.d.ts +41 -0
- package/dist/components/Input/FieldOptions.svelte +646 -0
- package/dist/components/Input/FieldOptions.svelte.d.ts +58 -0
- package/dist/components/Input/FieldRadios.svelte +126 -77
- package/dist/components/Input/FieldRadios.svelte.d.ts +23 -61
- package/dist/components/Input/FieldSelect.svelte +160 -239
- package/dist/components/Input/FieldSelect.svelte.d.ts +40 -88
- package/dist/components/Input/FieldSwitch.svelte +132 -0
- package/dist/components/Input/FieldSwitch.svelte.d.ts +41 -0
- package/dist/components/Input/FieldTextarea.svelte +146 -0
- package/dist/components/Input/FieldTextarea.svelte.d.ts +44 -0
- package/dist/components/Input/Fieldset.svelte +21 -17
- package/dist/components/Input/Fieldset.svelte.d.ts +10 -27
- package/dist/components/Input/_internal/FieldRadioInternal.svelte +186 -0
- package/dist/components/Input/_internal/FieldRadioInternal.svelte.d.ts +30 -0
- package/dist/components/Input/_internal/InputWrap.svelte +216 -0
- package/dist/components/Input/_internal/InputWrap.svelte.d.ts +36 -0
- package/dist/components/Input/index.css +134 -0
- package/dist/components/Input/index.d.ts +11 -0
- package/dist/components/Input/index.js +11 -0
- package/dist/components/Input/types.d.ts +11 -0
- package/dist/components/KbdShortcut/KbdShortcut.svelte +89 -0
- package/dist/components/KbdShortcut/KbdShortcut.svelte.d.ts +17 -0
- package/dist/components/KbdShortcut/index.d.ts +1 -0
- package/dist/components/KbdShortcut/index.js +1 -0
- package/dist/components/Modal/Modal.svelte +127 -0
- package/dist/components/Modal/Modal.svelte.d.ts +32 -0
- package/dist/components/Modal/index.d.ts +1 -0
- package/dist/components/Modal/index.js +1 -0
- package/dist/components/ModalDialog/ModalDialog.svelte +137 -81
- package/dist/components/ModalDialog/ModalDialog.svelte.d.ts +17 -38
- package/dist/components/ModalDialog/index.d.ts +1 -0
- package/dist/components/ModalDialog/index.js +1 -0
- package/dist/components/Notifications/Notifications.svelte +259 -173
- package/dist/components/Notifications/Notifications.svelte.d.ts +32 -60
- package/dist/components/Notifications/index.css +12 -0
- package/dist/components/Notifications/index.d.ts +2 -0
- package/dist/components/Notifications/index.js +2 -0
- package/dist/components/Notifications/notifications-icons.d.ts +1 -1
- package/dist/components/Notifications/notifications-icons.js +4 -4
- package/dist/components/Notifications/notifications-stack.svelte.d.ts +89 -0
- package/dist/components/Notifications/notifications-stack.svelte.js +161 -0
- package/dist/components/Progress/Progress.svelte +26 -0
- package/dist/components/Progress/Progress.svelte.d.ts +10 -0
- package/dist/components/Progress/_internal/Bar.svelte +31 -0
- package/dist/components/Progress/_internal/Bar.svelte.d.ts +10 -0
- package/dist/components/Progress/_internal/Circle.svelte +10 -0
- package/dist/components/Progress/_internal/Circle.svelte.d.ts +7 -0
- package/dist/components/Progress/index.css +7 -0
- package/dist/components/Progress/index.d.ts +1 -0
- package/dist/components/Progress/index.js +1 -0
- package/dist/components/Spinner/Spinner.svelte +56 -41
- package/dist/components/Spinner/Spinner.svelte.d.ts +10 -22
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Spinner/index.js +1 -0
- package/dist/components/Switch/Switch.svelte +158 -118
- package/dist/components/Switch/Switch.svelte.d.ts +25 -66
- package/dist/components/Switch/SwitchButton.svelte +131 -0
- package/dist/components/Switch/SwitchButton.svelte.d.ts +21 -0
- package/dist/components/Switch/index.css +7 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/index.js +2 -0
- package/dist/components/Thc/Thc.svelte +67 -10
- package/dist/components/Thc/Thc.svelte.d.ts +18 -22
- package/dist/components/Thc/index.d.ts +1 -0
- package/dist/components/Thc/index.js +1 -0
- package/dist/components/TwCheck/TwCheck.svelte +34 -0
- package/dist/components/TwCheck/TwCheck.svelte.d.ts +10 -0
- package/dist/components/TwCheck/index.css +5 -0
- package/dist/components/TwCheck/index.d.ts +1 -0
- package/dist/components/TwCheck/index.js +1 -0
- package/dist/components/X/X.svelte +12 -5
- package/dist/components/X/X.svelte.d.ts +6 -18
- package/dist/components/X/index.d.ts +1 -0
- package/dist/components/X/index.js +1 -0
- package/dist/index.css +26 -0
- package/dist/index.d.ts +21 -39
- package/dist/index.js +23 -54
- package/dist/types.d.ts +251 -2
- package/dist/types.js +248 -0
- package/dist/utils/breakpoint.svelte.d.ts +19 -0
- package/dist/utils/breakpoint.svelte.js +42 -0
- package/dist/utils/debounce.d.ts +13 -0
- package/dist/utils/debounce.js +22 -0
- package/dist/utils/device-pointer.svelte.d.ts +11 -0
- package/dist/utils/device-pointer.svelte.js +26 -0
- package/dist/utils/event-modifiers.d.ts +4 -0
- package/dist/utils/event-modifiers.js +29 -0
- package/dist/utils/get-id.d.ts +1 -1
- package/dist/utils/get-id.js +3 -1
- package/dist/utils/index.d.ts +21 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/is-browser.d.ts +1 -0
- package/dist/utils/is-browser.js +5 -0
- package/dist/utils/is-mac.d.ts +1 -0
- package/dist/utils/is-mac.js +11 -0
- package/dist/utils/maybe-json-parse.d.ts +1 -0
- package/dist/utils/maybe-json-parse.js +12 -0
- package/dist/utils/maybe-json-stringify.d.ts +1 -0
- package/dist/utils/maybe-json-stringify.js +11 -0
- package/dist/utils/move-array-item.d.ts +4 -0
- package/dist/utils/move-array-item.js +20 -0
- package/dist/utils/omit-pick.d.ts +2 -2
- package/dist/utils/omit-pick.js +10 -8
- package/dist/utils/paint.d.ts +18 -0
- package/dist/utils/paint.js +32 -0
- package/dist/utils/persistent-state.svelte.d.ts +23 -0
- package/dist/utils/persistent-state.svelte.js +48 -0
- package/dist/utils/prefers-reduced-motion.svelte.d.ts +2 -0
- package/dist/utils/prefers-reduced-motion.svelte.js +4 -0
- package/dist/utils/qsa.d.ts +1 -0
- package/dist/utils/qsa.js +3 -0
- package/dist/utils/sleep.d.ts +28 -0
- package/dist/utils/sleep.js +33 -0
- package/dist/utils/storage-abstraction.d.ts +35 -0
- package/dist/utils/storage-abstraction.js +136 -0
- package/dist/utils/str-hash.d.ts +7 -0
- package/dist/utils/str-hash.js +35 -0
- package/dist/utils/throttle.d.ts +1 -0
- package/dist/utils/throttle.js +47 -0
- package/dist/utils/to-integer.d.ts +1 -0
- package/dist/utils/to-integer.js +11 -0
- package/dist/utils/tr.d.ts +5 -0
- package/dist/utils/tr.js +13 -0
- package/dist/utils/tw-merge.d.ts +10 -0
- package/dist/utils/tw-merge.js +16 -0
- package/dist/utils/ucfirst.d.ts +1 -0
- package/dist/utils/ucfirst.js +6 -0
- package/package.json +66 -73
- package/dist/actions/autogrow.d.ts +0 -8
- package/dist/actions/autogrow.js +0 -22
- package/dist/actions/drag-drop.d.ts +0 -28
- package/dist/actions/drag-drop.js +0 -152
- package/dist/actions/on-outside.d.ts +0 -9
- package/dist/actions/on-outside.js +0 -27
- package/dist/actions/pre-submit-validity-check.d.ts +0 -3
- package/dist/actions/pre-submit-validity-check.js +0 -21
- package/dist/actions/tooltip/_make-visible.d.ts +0 -3
- package/dist/actions/tooltip/_make-visible.js +0 -25
- package/dist/actions/tooltip/_maybe-pick-safe-placement.d.ts +0 -3
- package/dist/actions/tooltip/_maybe-pick-safe-placement.js +0 -86
- package/dist/actions/tooltip/_set-position.d.ts +0 -2
- package/dist/actions/tooltip/_set-position.js +0 -125
- package/dist/actions/tooltip/tooltip.d.ts +0 -42
- package/dist/actions/tooltip/tooltip.js +0 -299
- package/dist/actions/trim.d.ts +0 -4
- package/dist/actions/trim.js +0 -18
- package/dist/actions/validate.js +0 -80
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt.d.ts +0 -58
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt.js +0 -141
- package/dist/components/ColorScheme/LocalColorScheme.svelte.d.ts +0 -25
- package/dist/components/ColorScheme/SystemAwareColorScheme.svelte.d.ts +0 -25
- package/dist/components/Input/Field.svelte +0 -315
- package/dist/components/Input/Field.svelte.d.ts +0 -102
- package/dist/components/Input/PinInput.svelte +0 -151
- package/dist/components/Input/PinInput.svelte.d.ts +0 -51
- package/dist/components/Input/XFieldRadioInternal.svelte +0 -143
- package/dist/components/Input/XFieldRadioInternal.svelte.d.ts +0 -45
- package/dist/components/Notifications/notifications.d.ts +0 -78
- package/dist/components/Notifications/notifications.js +0 -215
- package/dist/components/Popover/Popover.svelte +0 -24
- package/dist/components/Popover/Popover.svelte.d.ts +0 -22
- package/dist/components/Spinner/Spinner.v5.svelte +0 -114
- package/dist/components/Spinner/Spinner.v5.svelte.d.ts +0 -16
- package/dist/utils/calculate-alignment.d.ts +0 -68
- package/dist/utils/calculate-alignment.js +0 -183
- package/dist/utils/device-pointer.d.ts +0 -5
- package/dist/utils/device-pointer.js +0 -10
- package/dist/utils/prefers-reduced-motion.d.ts +0 -6
- package/dist/utils/prefers-reduced-motion.js +0 -26
- package/dist/utils/tw-merge2.d.ts +0 -3
- package/dist/utils/tw-merge2.js +0 -9
- package/dist/utils/tw-types.d.ts +0 -1
- package/dist/utils/window-size.d.ts +0 -22
- package/dist/utils/window-size.js +0 -35
- /package/dist/{utils/tw-types.js → components/Input/types.js} +0 -0
|
@@ -1,88 +1,159 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fly } from "svelte/transition";
|
|
3
|
+
import { type FocusTrapOptions } from "../../actions/focus-trap.js";
|
|
4
|
+
import { prefersReducedMotion } from "../../utils/prefers-reduced-motion.svelte.js";
|
|
5
|
+
import { twMerge } from "../../utils/tw-merge.js";
|
|
6
|
+
import Backdrop from "../Backdrop/Backdrop.svelte";
|
|
7
|
+
import type { Snippet } from "svelte";
|
|
8
|
+
// import { onClickOutside } from "runed";
|
|
9
|
+
|
|
10
|
+
const prefersReduced = prefersReducedMotion();
|
|
11
|
+
const DEFAULT_POS = "left";
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
visible?: boolean;
|
|
15
|
+
position?: "left" | "top" | "right" | "bottom";
|
|
16
|
+
children: Snippet;
|
|
17
|
+
class?: string;
|
|
18
|
+
classBackdrop?: string;
|
|
19
|
+
labelledby?: string;
|
|
20
|
+
describedby?: string;
|
|
21
|
+
transitionDuration?: number;
|
|
22
|
+
// transitionEnabled?: boolean;
|
|
23
|
+
elBackdrop?: HTMLDivElement;
|
|
24
|
+
el?: HTMLDivElement;
|
|
25
|
+
focusTrap?: boolean | FocusTrapOptions;
|
|
26
|
+
// will be used in `fly` config. Ideally should match with the provided tw classes
|
|
27
|
+
// to make the animation optimal. May include ccs units (will be considered as pixels otherwise).
|
|
28
|
+
animOffset?: string | number;
|
|
29
|
+
onEscape?: () => void;
|
|
30
|
+
//
|
|
31
|
+
onOutside?: () => void;
|
|
32
|
+
// onOutsideEnabled?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let {
|
|
36
|
+
visible = $bindable(false),
|
|
37
|
+
position = DEFAULT_POS,
|
|
38
|
+
children,
|
|
39
|
+
class: classProp,
|
|
40
|
+
classBackdrop,
|
|
41
|
+
labelledby,
|
|
42
|
+
describedby,
|
|
43
|
+
transitionDuration = 200,
|
|
44
|
+
// transitionEnabled = true,
|
|
45
|
+
elBackdrop = $bindable(),
|
|
46
|
+
el = $bindable(),
|
|
47
|
+
focusTrap,
|
|
48
|
+
animOffset = "75vw",
|
|
49
|
+
onEscape,
|
|
50
|
+
onOutside,
|
|
51
|
+
// onOutsideEnabled = true,
|
|
52
|
+
}: Props = $props();
|
|
53
|
+
|
|
54
|
+
$effect(() => {
|
|
55
|
+
if (prefersReduced.current) transitionDuration = 0;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// opinionated: make backdrop fade-in a little faster (but never longer than 200)... looks better
|
|
59
|
+
let fadeInDuration = $derived(Math.min(transitionDuration * 0.7, 200));
|
|
60
|
+
|
|
61
|
+
// prettier-ignore
|
|
62
|
+
const _classPresetsBackdrop = {
|
|
63
|
+
left: `justify-start`,
|
|
64
|
+
right: `justify-end`,
|
|
65
|
+
top: `items-start`,
|
|
66
|
+
bottom: `items-end`,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// prettier-ignore
|
|
70
|
+
const _classPresets = {
|
|
71
|
+
left: `w-full sm:w-[75vw] h-full`,
|
|
72
|
+
right: `w-full sm:w-[75vw] h-full`,
|
|
73
|
+
// top/bottom are full by default
|
|
74
|
+
top: `w-full h-full`, // sm:h-[75vh]
|
|
75
|
+
bottom: `w-full h-full`, // sm:h-[75vh]
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// prettier-ignore
|
|
79
|
+
let _animPresets = $derived({
|
|
80
|
+
left: { x: `-${animOffset}`, y: 0 },
|
|
81
|
+
right: { x: animOffset, y: 0 },
|
|
82
|
+
top: { x: 0, y: `-${animOffset}`},
|
|
83
|
+
bottom: { x: 0, y: animOffset },
|
|
84
|
+
});
|
|
11
85
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
bottom: { x: 0, y: animOffset }
|
|
49
|
-
};
|
|
50
|
-
let el;
|
|
51
|
-
$:
|
|
52
|
-
if (el)
|
|
53
|
-
dispatch("element", { drawer: el });
|
|
86
|
+
// onClickOutside(
|
|
87
|
+
// () => el,
|
|
88
|
+
// () => {
|
|
89
|
+
// // noop if not enabled
|
|
90
|
+
// if (!onOutsideEnabled) return;
|
|
91
|
+
// // explicit false means ignoring outside click
|
|
92
|
+
// if (typeof onOutside === "function") onOutside();
|
|
93
|
+
// else if (onOutside !== false) visible = false;
|
|
94
|
+
// }
|
|
95
|
+
// );
|
|
96
|
+
|
|
97
|
+
let _classBackdrop = $derived(
|
|
98
|
+
_classPresetsBackdrop[position] ?? _classPresetsBackdrop[DEFAULT_POS]
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
let _class = $derived(_classPresets[position] ?? _classPresets[DEFAULT_POS]);
|
|
102
|
+
|
|
103
|
+
let flyOptions = $derived({
|
|
104
|
+
duration: transitionDuration,
|
|
105
|
+
...(_animPresets[position] ?? _animPresets[DEFAULT_POS]),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
let backdrop: Backdrop = $state()!;
|
|
109
|
+
|
|
110
|
+
export function close() {
|
|
111
|
+
backdrop.close();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function open(openerOrEvent?: null | HTMLElement | MouseEvent) {
|
|
115
|
+
// setOpener(openerOrEvent ?? (document.activeElement as any));
|
|
116
|
+
backdrop.open(openerOrEvent);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function setOpener(opener?: null | HTMLElement) {
|
|
120
|
+
backdrop.setOpener(opener);
|
|
121
|
+
}
|
|
54
122
|
</script>
|
|
55
123
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
124
|
+
<!--
|
|
125
|
+
Using `onmousedown` not `onclick` intentionally. Otherwise drag inside + release outside
|
|
126
|
+
(eg selecting text and accidentally release outside) would trigger close.
|
|
127
|
+
-->
|
|
128
|
+
|
|
129
|
+
<Backdrop
|
|
130
|
+
bind:this={backdrop}
|
|
131
|
+
bind:el={elBackdrop}
|
|
132
|
+
bind:visible
|
|
133
|
+
class={twMerge(_classBackdrop, classBackdrop)}
|
|
134
|
+
{focusTrap}
|
|
135
|
+
{fadeInDuration}
|
|
136
|
+
fadeOutDuration={transitionDuration}
|
|
137
|
+
{onEscape}
|
|
138
|
+
onmousedown={() => onOutside?.()}
|
|
139
|
+
>
|
|
140
|
+
<!-- svelte-ignore a11y_interactive_supports_focus -->
|
|
141
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
142
|
+
<div
|
|
143
|
+
bind:this={el}
|
|
144
|
+
aria-modal="true"
|
|
145
|
+
role="dialog"
|
|
146
|
+
aria-labelledby={labelledby}
|
|
147
|
+
aria-describedby={describedby}
|
|
148
|
+
class={twMerge("overflow-y-auto", _class, classProp)}
|
|
149
|
+
transition:fly={flyOptions}
|
|
150
|
+
onmousedown={(e) => {
|
|
151
|
+
if (onOutside) {
|
|
152
|
+
e.stopImmediatePropagation();
|
|
153
|
+
e.stopPropagation();
|
|
154
|
+
}
|
|
155
|
+
}}
|
|
65
156
|
>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
a11y-no-noninteractive-element-interactions
|
|
70
|
-
-->
|
|
71
|
-
<div
|
|
72
|
-
bind:this={el}
|
|
73
|
-
on:mousedown|stopPropagation
|
|
74
|
-
aria-modal="true"
|
|
75
|
-
role="dialog"
|
|
76
|
-
aria-labelledby={labelledby}
|
|
77
|
-
aria-describedby={describedby}
|
|
78
|
-
transition:fly={{
|
|
79
|
-
duration: transitionEnabled ? transitionDuration : 0,
|
|
80
|
-
...(_presetsAnim[position] || {}),
|
|
81
|
-
}}
|
|
82
|
-
class={twMerge2(`overflow-y-auto ${_presetsCls[position] || ''} ${_class}`)}
|
|
83
|
-
use:onOutside
|
|
84
|
-
>
|
|
85
|
-
<slot />
|
|
86
|
-
</div>
|
|
87
|
-
</Backdrop>
|
|
88
|
-
{/if}
|
|
157
|
+
{@render children()}
|
|
158
|
+
</div>
|
|
159
|
+
</Backdrop>
|
|
@@ -1,36 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
events: {
|
|
19
|
-
escape: CustomEvent<any>;
|
|
20
|
-
element: CustomEvent<any>;
|
|
21
|
-
mousedown: MouseEvent;
|
|
22
|
-
} & {
|
|
23
|
-
[evt: string]: CustomEvent<any>;
|
|
24
|
-
};
|
|
25
|
-
slots: {
|
|
26
|
-
default: {};
|
|
27
|
-
};
|
|
28
|
-
exports?: {} | undefined;
|
|
29
|
-
bindings?: string | undefined;
|
|
30
|
-
};
|
|
31
|
-
export type DrawerProps = typeof __propDef.props;
|
|
32
|
-
export type DrawerEvents = typeof __propDef.events;
|
|
33
|
-
export type DrawerSlots = typeof __propDef.slots;
|
|
34
|
-
export default class Drawer extends SvelteComponent<DrawerProps, DrawerEvents, DrawerSlots> {
|
|
1
|
+
import { type FocusTrapOptions } from "../../actions/focus-trap.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
interface Props {
|
|
4
|
+
visible?: boolean;
|
|
5
|
+
position?: "left" | "top" | "right" | "bottom";
|
|
6
|
+
children: Snippet;
|
|
7
|
+
class?: string;
|
|
8
|
+
classBackdrop?: string;
|
|
9
|
+
labelledby?: string;
|
|
10
|
+
describedby?: string;
|
|
11
|
+
transitionDuration?: number;
|
|
12
|
+
elBackdrop?: HTMLDivElement;
|
|
13
|
+
el?: HTMLDivElement;
|
|
14
|
+
focusTrap?: boolean | FocusTrapOptions;
|
|
15
|
+
animOffset?: string | number;
|
|
16
|
+
onEscape?: () => void;
|
|
17
|
+
onOutside?: () => void;
|
|
35
18
|
}
|
|
36
|
-
|
|
19
|
+
declare const Drawer: import("svelte").Component<Props, {
|
|
20
|
+
close: () => void;
|
|
21
|
+
open: (openerOrEvent?: null | HTMLElement | MouseEvent) => void;
|
|
22
|
+
setOpener: (opener?: null | HTMLElement) => void;
|
|
23
|
+
}, "el" | "visible" | "elBackdrop">;
|
|
24
|
+
type Drawer = ReturnType<typeof Drawer>;
|
|
25
|
+
export default Drawer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Drawer } from "./Drawer.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Drawer } from "./Drawer.svelte";
|
|
@@ -1,117 +1,156 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DevicePointer } from "../../utils/device-pointer.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { innerHeight, innerWidth } from "svelte/reactivity/window";
|
|
4
|
+
import { DevicePointer } from "../../utils/device-pointer.svelte.js";
|
|
5
|
+
import { waitForNextRepaint, waitForTransitionEnd } from "../../utils/paint.js";
|
|
6
|
+
import { prefersReducedMotion } from "../../utils/prefers-reduced-motion.svelte.js";
|
|
7
|
+
import { twMerge } from "../../utils/tw-merge.js";
|
|
8
|
+
|
|
9
|
+
const dp = new DevicePointer();
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
class?: string;
|
|
14
|
+
shadowOpacity?: number;
|
|
15
|
+
duration?: number;
|
|
16
|
+
targetWidth?: number;
|
|
17
|
+
delayIn?: number;
|
|
18
|
+
delayOut?: number;
|
|
19
|
+
children: Snippet<
|
|
20
|
+
[
|
|
21
|
+
{
|
|
22
|
+
isExpanded: boolean;
|
|
23
|
+
isExpanding: boolean;
|
|
24
|
+
isShrinking: boolean;
|
|
25
|
+
inTransition: boolean;
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
enabled = dp.isFine,
|
|
33
|
+
shadowOpacity = 0.5,
|
|
34
|
+
duration: _duration = 150,
|
|
35
|
+
targetWidth = 256,
|
|
36
|
+
delayIn = 500,
|
|
37
|
+
delayOut = 300,
|
|
38
|
+
class: classProp,
|
|
39
|
+
children,
|
|
40
|
+
...rest
|
|
41
|
+
}: Props = $props();
|
|
42
|
+
|
|
43
|
+
//
|
|
44
|
+
const prefersReduced = prefersReducedMotion();
|
|
45
|
+
let el = $state<HTMLDivElement>()!;
|
|
46
|
+
let isExpanded = $state(false);
|
|
47
|
+
let isShrinking = $state(false);
|
|
48
|
+
let isExpanding = $state(false);
|
|
49
|
+
let inTransition = $derived(isExpanding || isShrinking);
|
|
50
|
+
let _timer: any;
|
|
51
|
+
let box = $state<DOMRect>();
|
|
52
|
+
let duration = $derived(prefersReduced.current ? 0 : _duration);
|
|
53
|
+
|
|
54
|
+
function clear() {
|
|
55
|
+
clearTimeout(_timer);
|
|
56
|
+
_timer = null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function schedule(fn: CallableFunction, delay: number) {
|
|
60
|
+
clear();
|
|
61
|
+
_timer = setTimeout(() => {
|
|
62
|
+
fn?.();
|
|
63
|
+
clear();
|
|
64
|
+
}, delay);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function expand() {
|
|
68
|
+
if (!enabled) return;
|
|
69
|
+
if (isExpanding || isShrinking || isExpanded) return;
|
|
70
|
+
|
|
71
|
+
// asap
|
|
72
|
+
isExpanded = true;
|
|
73
|
+
isExpanding = true;
|
|
74
|
+
|
|
75
|
+
box = el.getBoundingClientRect();
|
|
76
|
+
const pos = {
|
|
77
|
+
top: box.top,
|
|
78
|
+
bottom: innerHeight.current! - box.bottom,
|
|
79
|
+
left: box.left,
|
|
80
|
+
right: innerWidth.current! - box.right,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// <offset-x>, <offset-y>, <blur-radius>, <spread-radius>
|
|
84
|
+
el.style.boxShadow = `16px 0 24px -16px rgb(0 0 0 / ${shadowOpacity})`;
|
|
85
|
+
|
|
86
|
+
// no transition yet
|
|
87
|
+
el.style.top = `${pos.top}px`;
|
|
88
|
+
el.style.right = `${pos.right}px`;
|
|
89
|
+
el.style.bottom = `${pos.bottom}px`;
|
|
90
|
+
el.style.left = `${pos.left}px`;
|
|
91
|
+
|
|
92
|
+
el.style.width = "auto";
|
|
93
|
+
el.style.height = "auto";
|
|
94
|
+
|
|
95
|
+
el.style.zIndex = "1";
|
|
96
|
+
|
|
97
|
+
// kind of ugly - need to set props in multiple steps...
|
|
98
|
+
(async () => {
|
|
99
|
+
await waitForNextRepaint();
|
|
100
|
+
el.style.position = `fixed`;
|
|
101
|
+
|
|
102
|
+
await waitForNextRepaint();
|
|
103
|
+
el.style.width = `${box!.width}px`;
|
|
104
|
+
|
|
105
|
+
await waitForNextRepaint();
|
|
106
|
+
el.style.transitionProperty = "all";
|
|
107
|
+
el.style.width = `${targetWidth}px`;
|
|
108
|
+
|
|
109
|
+
await waitForTransitionEnd(el);
|
|
110
|
+
isExpanding = false;
|
|
111
|
+
})();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function shrink() {
|
|
115
|
+
if (!enabled) return;
|
|
116
|
+
if (isExpanding || isShrinking || !isExpanded) return;
|
|
117
|
+
|
|
118
|
+
// asap
|
|
119
|
+
isExpanded = false;
|
|
120
|
+
isShrinking = true;
|
|
121
|
+
|
|
122
|
+
el.style.boxShadow = "none";
|
|
123
|
+
el.style.width = `${box!.width}px`;
|
|
124
|
+
|
|
125
|
+
(async () => {
|
|
126
|
+
await waitForTransitionEnd(el);
|
|
127
|
+
isShrinking = false;
|
|
128
|
+
|
|
129
|
+
// now reset all back to defaults
|
|
130
|
+
el.style.position = `static`;
|
|
131
|
+
|
|
132
|
+
el.style.top = "auto";
|
|
133
|
+
el.style.right = "auto";
|
|
134
|
+
el.style.bottom = "auto";
|
|
135
|
+
el.style.left = "auto";
|
|
136
|
+
|
|
137
|
+
el.style.width = "100%";
|
|
138
|
+
el.style.height = "100%";
|
|
139
|
+
|
|
140
|
+
el.style.zIndex = "0";
|
|
141
|
+
el.style.transitionProperty = "none";
|
|
142
|
+
})();
|
|
143
|
+
}
|
|
99
144
|
</script>
|
|
100
145
|
|
|
101
|
-
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-static-element-interactions -->
|
|
102
146
|
<div
|
|
103
147
|
bind:this={el}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
148
|
+
onmouseenter={() => schedule(expand, delayIn)}
|
|
149
|
+
onmouseleave={() => schedule(shrink, delayOut)}
|
|
150
|
+
class={twMerge("stuic-expandable", "overflow-x-hidden overflow-y-auto", classProp)}
|
|
151
|
+
style="width: 100%; height: 100%; transition-timing-function: ease-in; transition-duration: {duration}ms;"
|
|
152
|
+
aria-expanded={isExpanded}
|
|
153
|
+
{...rest}
|
|
110
154
|
>
|
|
111
|
-
|
|
112
|
-
isExpanded={_isExpanded}
|
|
113
|
-
isExpanding={_isExpanding}
|
|
114
|
-
isShrinking={_isShrinking}
|
|
115
|
-
inTransition={_isExpanding || _isShrinking}
|
|
116
|
-
/>
|
|
155
|
+
{@render children({ isExpanded, isShrinking, isExpanding, inTransition })}
|
|
117
156
|
</div>
|
|
@@ -1,34 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
events: {
|
|
13
|
-
click: MouseEvent;
|
|
14
|
-
change: CustomEvent<any>;
|
|
15
|
-
} & {
|
|
16
|
-
[evt: string]: CustomEvent<any>;
|
|
17
|
-
};
|
|
18
|
-
slots: {
|
|
19
|
-
default: {
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
interface Props {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
class?: string;
|
|
5
|
+
shadowOpacity?: number;
|
|
6
|
+
duration?: number;
|
|
7
|
+
targetWidth?: number;
|
|
8
|
+
delayIn?: number;
|
|
9
|
+
delayOut?: number;
|
|
10
|
+
children: Snippet<[
|
|
11
|
+
{
|
|
20
12
|
isExpanded: boolean;
|
|
21
13
|
isExpanding: boolean;
|
|
22
14
|
isShrinking: boolean;
|
|
23
15
|
inTransition: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
exports?: {} | undefined;
|
|
27
|
-
bindings?: string | undefined;
|
|
28
|
-
};
|
|
29
|
-
export type HoverExpandableWidthProps = typeof __propDef.props;
|
|
30
|
-
export type HoverExpandableWidthEvents = typeof __propDef.events;
|
|
31
|
-
export type HoverExpandableWidthSlots = typeof __propDef.slots;
|
|
32
|
-
export default class HoverExpandableWidth extends SvelteComponent<HoverExpandableWidthProps, HoverExpandableWidthEvents, HoverExpandableWidthSlots> {
|
|
16
|
+
}
|
|
17
|
+
]>;
|
|
33
18
|
}
|
|
34
|
-
|
|
19
|
+
declare const HoverExpandableWidth: import("svelte").Component<Props, {}, "">;
|
|
20
|
+
type HoverExpandableWidth = ReturnType<typeof HoverExpandableWidth>;
|
|
21
|
+
export default HoverExpandableWidth;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as HoverExpandableWidth } from "./HoverExpandableWidth.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as HoverExpandableWidth } from "./HoverExpandableWidth.svelte";
|