@marianmeres/stuic 1.125.0 → 2.0.0-next.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/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 +52 -37
- 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/autoscroll.d.ts +0 -21
- package/dist/actions/autoscroll.js +0 -60
- 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,53 +1,153 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
static fadeInDuration = 50;
|
|
4
|
-
static fadeOutDuration = 150;
|
|
5
|
-
}
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
const _instances = [];
|
|
6
3
|
</script>
|
|
7
4
|
|
|
8
|
-
<script
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import {
|
|
7
|
+
focusTrap as focusTrapAction,
|
|
8
|
+
twMerge,
|
|
9
|
+
waitForNextRepaint,
|
|
10
|
+
type FocusTrapOptions,
|
|
11
|
+
} from "../../index.js";
|
|
12
|
+
import { createClog } from "@marianmeres/clog";
|
|
13
|
+
import { PressedKeys, watch } from "runed";
|
|
14
|
+
import { type Snippet } from "svelte";
|
|
15
|
+
import { fade } from "svelte/transition";
|
|
16
|
+
|
|
17
|
+
const clog = createClog("Backdrop").debug;
|
|
18
|
+
|
|
19
|
+
interface Props extends Record<string, any> {
|
|
20
|
+
class?: string;
|
|
21
|
+
focusTrap?: boolean | FocusTrapOptions;
|
|
22
|
+
fadeInDuration?: number;
|
|
23
|
+
fadeOutDuration?: number;
|
|
24
|
+
transitionEnabled?: boolean;
|
|
25
|
+
el?: HTMLDivElement;
|
|
26
|
+
children?: Snippet;
|
|
27
|
+
onEscape?: () => void;
|
|
28
|
+
visible?: boolean;
|
|
29
|
+
noScrollLock?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let {
|
|
33
|
+
class: classProp,
|
|
34
|
+
focusTrap = true,
|
|
35
|
+
fadeInDuration = 50,
|
|
36
|
+
fadeOutDuration = 150,
|
|
37
|
+
transitionEnabled = true,
|
|
38
|
+
el = $bindable(),
|
|
39
|
+
children,
|
|
40
|
+
onEscape,
|
|
41
|
+
visible = $bindable(false),
|
|
42
|
+
noScrollLock,
|
|
43
|
+
...rest
|
|
44
|
+
}: Props = $props();
|
|
45
|
+
|
|
46
|
+
let _opener: undefined | null | HTMLElement = $state();
|
|
47
|
+
|
|
48
|
+
// let keys = new PressedKeys();
|
|
49
|
+
// let isEscapePressed = $derived(keys.has("Escape"));
|
|
50
|
+
// $effect(() => {
|
|
51
|
+
// if (isEscapePressed && typeof onEscape === "function") {
|
|
52
|
+
// // clog("Executing onEscape...");
|
|
53
|
+
// onEscape();
|
|
54
|
+
// }
|
|
55
|
+
// });
|
|
56
|
+
|
|
57
|
+
$effect(() => {
|
|
58
|
+
if (!transitionEnabled) {
|
|
59
|
+
fadeInDuration = 0;
|
|
60
|
+
fadeOutDuration = 0;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export function close() {
|
|
65
|
+
visible = false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function open(openerOrEvent?: null | HTMLElement | MouseEvent) {
|
|
69
|
+
visible = true;
|
|
70
|
+
setOpener(
|
|
71
|
+
(openerOrEvent as any)?.currentTarget ?? openerOrEvent ?? document.activeElement
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function setOpener(opener?: null | HTMLElement) {
|
|
76
|
+
_opener = opener;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function visibility() {
|
|
80
|
+
return {
|
|
81
|
+
get visible() {
|
|
82
|
+
return visible;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
watch(
|
|
88
|
+
() => visible,
|
|
89
|
+
(isVisible, wasVisible) => {
|
|
90
|
+
if (wasVisible && !isVisible && _opener) {
|
|
91
|
+
_opener?.focus();
|
|
92
|
+
_opener = null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// lock body scroll when open and restore back
|
|
98
|
+
let _original: any = {};
|
|
99
|
+
$effect(() => {
|
|
100
|
+
if (noScrollLock) return;
|
|
101
|
+
if (visible) {
|
|
102
|
+
_original = window.getComputedStyle(document.body);
|
|
103
|
+
const scrollY = window.scrollY;
|
|
104
|
+
|
|
105
|
+
document.body.style.position = "fixed";
|
|
106
|
+
document.body.style.top = `-${scrollY}px`;
|
|
107
|
+
document.body.style.width = "100%";
|
|
108
|
+
document.body.style.overflow = "hidden";
|
|
109
|
+
} else {
|
|
110
|
+
const scrollY = document.body.style.top;
|
|
111
|
+
|
|
112
|
+
document.body.style.position = _original.position;
|
|
113
|
+
document.body.style.position = "";
|
|
114
|
+
document.body.style.top = "";
|
|
115
|
+
document.body.style.width = "";
|
|
116
|
+
document.body.style.overflow = "";
|
|
117
|
+
|
|
118
|
+
// Restore scroll position
|
|
119
|
+
window.scrollTo(0, parseInt(scrollY || "0") * -1);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
$effect(() => {
|
|
124
|
+
function onkeydown(e: KeyboardEvent) {
|
|
125
|
+
if (e.key === "Escape" && typeof onEscape === "function") {
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
e.stopImmediatePropagation();
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
onEscape();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
el?.addEventListener("keydown", onkeydown);
|
|
133
|
+
return () => el?.removeEventListener("keydown", onkeydown);
|
|
134
|
+
});
|
|
30
135
|
</script>
|
|
31
136
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fixed inset-0 flex z-10
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
role="presentation"
|
|
50
|
-
tabindex="-1"
|
|
51
|
-
>
|
|
52
|
-
<slot />
|
|
53
|
-
</div>
|
|
137
|
+
{#if visible}
|
|
138
|
+
<div
|
|
139
|
+
bind:this={el}
|
|
140
|
+
role="presentation"
|
|
141
|
+
tabindex="-1"
|
|
142
|
+
class={twMerge("fixed inset-0 flex z-10", classProp)}
|
|
143
|
+
in:fade={{ duration: fadeInDuration }}
|
|
144
|
+
out:fade={{ duration: fadeOutDuration }}
|
|
145
|
+
use:focusTrapAction={{
|
|
146
|
+
...(typeof focusTrap === "object" ? focusTrap : {}),
|
|
147
|
+
enabled: typeof focusTrap === "boolean" ? focusTrap : !!focusTrap.enabled,
|
|
148
|
+
}}
|
|
149
|
+
{...rest}
|
|
150
|
+
>
|
|
151
|
+
{@render children?.()}
|
|
152
|
+
</div>
|
|
153
|
+
{/if}
|
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { type FocusTrapOptions } from "../../index.js";
|
|
2
|
+
import { type Snippet } from "svelte";
|
|
3
|
+
interface Props extends Record<string, any> {
|
|
4
|
+
class?: string;
|
|
5
|
+
focusTrap?: boolean | FocusTrapOptions;
|
|
6
|
+
fadeInDuration?: number;
|
|
7
|
+
fadeOutDuration?: number;
|
|
8
|
+
transitionEnabled?: boolean;
|
|
9
|
+
el?: HTMLDivElement;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
onEscape?: () => void;
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
noScrollLock?: boolean;
|
|
6
14
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
fadeInDuration?: number;
|
|
14
|
-
fadeOutDuration?: number;
|
|
15
|
-
transitionEnabled?: boolean;
|
|
15
|
+
declare const Backdrop: import("svelte").Component<Props, {
|
|
16
|
+
close: () => void;
|
|
17
|
+
open: (openerOrEvent?: null | HTMLElement | MouseEvent) => void;
|
|
18
|
+
setOpener: (opener?: null | HTMLElement) => void;
|
|
19
|
+
visibility: () => {
|
|
20
|
+
readonly visible: boolean;
|
|
16
21
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
mouseup: MouseEvent;
|
|
21
|
-
touchstart: TouchEvent;
|
|
22
|
-
touchend: TouchEvent;
|
|
23
|
-
escape: CustomEvent<any>;
|
|
24
|
-
element: CustomEvent<any>;
|
|
25
|
-
} & {
|
|
26
|
-
[evt: string]: CustomEvent<any>;
|
|
27
|
-
};
|
|
28
|
-
slots: {
|
|
29
|
-
default: {};
|
|
30
|
-
};
|
|
31
|
-
exports?: {} | undefined;
|
|
32
|
-
bindings?: string | undefined;
|
|
33
|
-
};
|
|
34
|
-
export type BackdropProps = typeof __propDef.props;
|
|
35
|
-
export type BackdropEvents = typeof __propDef.events;
|
|
36
|
-
export type BackdropSlots = typeof __propDef.slots;
|
|
37
|
-
export default class Backdrop extends SvelteComponent<BackdropProps, BackdropEvents, BackdropSlots> {
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
22
|
+
}, "el" | "visible">;
|
|
23
|
+
type Backdrop = ReturnType<typeof Backdrop>;
|
|
24
|
+
export default Backdrop;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Backdrop } from "./Backdrop.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Backdrop } from "./Backdrop.svelte";
|
|
@@ -1,155 +1,131 @@
|
|
|
1
|
-
<script
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
xl: ""
|
|
47
|
-
};
|
|
48
|
-
static class = "";
|
|
49
|
-
// to be defined at consumer level...
|
|
50
|
-
static variant = {
|
|
51
|
-
primary: `
|
|
52
|
-
bg-stuic-primary text-stuic-on-primary
|
|
53
|
-
dark:bg-stuic-primary-dark dark:text-stuic-on-primary-dark
|
|
54
|
-
`.trim(),
|
|
55
|
-
secondary: `
|
|
56
|
-
bg-stuic-secondary text-stuic-on-secondary
|
|
57
|
-
dark:bg-stuic-secondary-dark dark:text-stuic-on-secondary-dark
|
|
58
|
-
`.trim()
|
|
59
|
-
};
|
|
60
|
-
}
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export const BUTTON_STUIC_BASE_CLASSES = `
|
|
3
|
+
bg-button-bg text-button-text
|
|
4
|
+
dark:bg-button-bg-dark dark:text-button-text-dark
|
|
5
|
+
font-mono text-sm text-center
|
|
6
|
+
leading-4
|
|
7
|
+
border-1
|
|
8
|
+
border-button-border dark:border-button-border-dark
|
|
9
|
+
rounded-md
|
|
10
|
+
inline-flex items-center justify-center gap-x-2
|
|
11
|
+
px-3 py-1.5
|
|
12
|
+
|
|
13
|
+
hover:brightness-[1.05]
|
|
14
|
+
active:brightness-[0.95]
|
|
15
|
+
disabled:hover:brightness-100
|
|
16
|
+
|
|
17
|
+
focus:brightness-[1.05]
|
|
18
|
+
focus:border-button-border-focus focus:dark:border-button-border-focus-dark
|
|
19
|
+
|
|
20
|
+
focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20
|
|
21
|
+
focus-visible:outline-4 focus-visible:outline-black/10 focus-visible:dark:outline-white/20
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
export const BUTTON_STUIC_PRESET_CLASSES: any = {
|
|
25
|
+
size: {
|
|
26
|
+
sm: `text-xs rounded-sm px-2 py-0.5`,
|
|
27
|
+
lg: `text-base rounded-md`,
|
|
28
|
+
},
|
|
29
|
+
variant: {
|
|
30
|
+
primary: `font-medium`,
|
|
31
|
+
secondary: `
|
|
32
|
+
bg-neutral-100 dark:bg-neutral-600
|
|
33
|
+
text-black/60 dark:text-white/80
|
|
34
|
+
shadow-[1px_1px_0_0_rgba(0_0_0_/_.2)]
|
|
35
|
+
active:shadow-none active:translate-[1px]
|
|
36
|
+
focus:shadow-black/30
|
|
37
|
+
`,
|
|
38
|
+
},
|
|
39
|
+
muted: `text-black/70 dark:text-white/70`,
|
|
40
|
+
shadow: `
|
|
41
|
+
shadow-[1px_1px_0_0_rgba(0_0_0_/_.4)]
|
|
42
|
+
active:shadow-none active:translate-[1px]
|
|
43
|
+
disabled:shadow-none disabled:active:shadow-none disabled:active:translate-none
|
|
44
|
+
`,
|
|
45
|
+
};
|
|
61
46
|
</script>
|
|
62
47
|
|
|
63
|
-
<script
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
48
|
+
<script lang="ts">
|
|
49
|
+
import type { Snippet } from "svelte";
|
|
50
|
+
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
51
|
+
import { twMerge } from "../../utils/tw-merge.js";
|
|
52
|
+
//
|
|
53
|
+
import "./index.css";
|
|
54
|
+
|
|
55
|
+
// interface Props extends DataAttributes, Partial<Omit<HTMLButtonElement, 'children'>> {
|
|
56
|
+
interface Props extends HTMLButtonAttributes {
|
|
57
|
+
variant?: "primary" | "secondary" | string;
|
|
58
|
+
size?: "sm" | "md" | "lg" | string;
|
|
59
|
+
muted?: boolean;
|
|
60
|
+
noshadow?: boolean;
|
|
61
|
+
unstyled?: boolean;
|
|
62
|
+
class?: string;
|
|
63
|
+
href?: string;
|
|
64
|
+
children?: Snippet<[{ checked?: boolean }]>;
|
|
65
|
+
// support for switch
|
|
66
|
+
roleSwitch?: boolean;
|
|
67
|
+
checked?: boolean;
|
|
68
|
+
el?: Element;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let {
|
|
72
|
+
variant,
|
|
73
|
+
size,
|
|
74
|
+
class: classProp,
|
|
75
|
+
muted,
|
|
76
|
+
noshadow,
|
|
77
|
+
unstyled,
|
|
78
|
+
href,
|
|
79
|
+
children,
|
|
80
|
+
//
|
|
81
|
+
roleSwitch = false,
|
|
82
|
+
checked = $bindable(false),
|
|
83
|
+
el = $bindable(),
|
|
84
|
+
//
|
|
85
|
+
...rest
|
|
86
|
+
}: Props = $props();
|
|
87
|
+
|
|
88
|
+
// let button: HTMLButtonElement | undefined = $state();
|
|
89
|
+
|
|
90
|
+
$effect(() => {
|
|
91
|
+
const toggle = () => (checked = !checked);
|
|
92
|
+
if (!href && roleSwitch && el) {
|
|
93
|
+
el?.addEventListener("click", toggle);
|
|
94
|
+
}
|
|
95
|
+
return () => el?.removeEventListener("click", toggle);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const _base = BUTTON_STUIC_BASE_CLASSES;
|
|
99
|
+
const _preset: any = BUTTON_STUIC_PRESET_CLASSES;
|
|
100
|
+
|
|
101
|
+
// see button.css
|
|
102
|
+
let _class = $derived(
|
|
103
|
+
[
|
|
104
|
+
// "namespace" (so we can target it in css files when customizing)
|
|
105
|
+
"stuic-button",
|
|
106
|
+
// pass all styling props as classnames as well
|
|
107
|
+
variant,
|
|
108
|
+
size,
|
|
109
|
+
muted && "muted",
|
|
110
|
+
noshadow && "no-shadow",
|
|
111
|
+
// now, attach the default tw classes (unless not explicitly forbidden)
|
|
112
|
+
!unstyled && _base,
|
|
113
|
+
!unstyled && size && _preset.size[size],
|
|
114
|
+
!unstyled && variant && _preset.variant[variant],
|
|
115
|
+
!unstyled && muted && _preset.muted,
|
|
116
|
+
!unstyled && !noshadow && _preset.shadow,
|
|
117
|
+
]
|
|
118
|
+
.filter(Boolean)
|
|
119
|
+
.join(" ")
|
|
120
|
+
);
|
|
102
121
|
</script>
|
|
103
122
|
|
|
104
123
|
{#if href}
|
|
105
|
-
<a
|
|
106
|
-
{
|
|
107
|
-
class={buttonClass}
|
|
108
|
-
{...$$restProps}
|
|
109
|
-
role="button"
|
|
110
|
-
data-button-size={size}
|
|
111
|
-
data-button-shadow={shadow}
|
|
112
|
-
data-button-rounded={rounded}
|
|
113
|
-
data-button-variant={variant}
|
|
114
|
-
on:focus
|
|
115
|
-
on:blur
|
|
116
|
-
on:click
|
|
117
|
-
on:change
|
|
118
|
-
on:keydown
|
|
119
|
-
on:keyup
|
|
120
|
-
on:touchstart|passive
|
|
121
|
-
on:touchend|passive
|
|
122
|
-
on:touchmove|passive
|
|
123
|
-
on:touchcancel
|
|
124
|
-
on:mouseenter
|
|
125
|
-
on:mouseleave
|
|
126
|
-
>
|
|
127
|
-
<slot />
|
|
124
|
+
<a {href} bind:this={el} class={twMerge(_class, classProp)} {...rest as any}>
|
|
125
|
+
{@render children?.({})}
|
|
128
126
|
</a>
|
|
129
127
|
{:else}
|
|
130
|
-
<button
|
|
131
|
-
{
|
|
132
|
-
{disabled}
|
|
133
|
-
class={buttonClass}
|
|
134
|
-
{value}
|
|
135
|
-
data-button-size={size}
|
|
136
|
-
data-button-shadow={shadow}
|
|
137
|
-
data-button-rounded={rounded}
|
|
138
|
-
data-button-variant={variant}
|
|
139
|
-
{...$$restProps}
|
|
140
|
-
on:focus
|
|
141
|
-
on:blur
|
|
142
|
-
on:click
|
|
143
|
-
on:change
|
|
144
|
-
on:keydown
|
|
145
|
-
on:keyup
|
|
146
|
-
on:touchstart|passive
|
|
147
|
-
on:touchend|passive
|
|
148
|
-
on:touchmove|passive
|
|
149
|
-
on:touchcancel
|
|
150
|
-
on:mouseenter
|
|
151
|
-
on:mouseleave
|
|
152
|
-
>
|
|
153
|
-
<slot />
|
|
128
|
+
<button bind:this={el} class={twMerge(_class, classProp)} {...rest}>
|
|
129
|
+
{@render children?.({ checked })}
|
|
154
130
|
</button>
|
|
155
131
|
{/if}
|
|
@@ -1,81 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
lg: string;
|
|
21
|
-
xl: string;
|
|
22
|
-
};
|
|
23
|
-
static presetsSize: {
|
|
24
|
-
xs: string;
|
|
25
|
-
sm: string;
|
|
26
|
-
md: string;
|
|
27
|
-
lg: string;
|
|
28
|
-
xl: string;
|
|
29
|
-
};
|
|
30
|
-
static classBySize: {
|
|
31
|
-
xs: string;
|
|
32
|
-
sm: string;
|
|
33
|
-
md: string;
|
|
34
|
-
lg: string;
|
|
35
|
-
xl: string;
|
|
36
|
-
};
|
|
37
|
-
static class: string;
|
|
38
|
-
static variant: Record<string, string>;
|
|
1
|
+
export declare const BUTTON_STUIC_BASE_CLASSES = "\n\t\tbg-button-bg text-button-text \n\t\tdark:bg-button-bg-dark dark:text-button-text-dark\n\t\tfont-mono text-sm text-center \n\t\tleading-4\n\t\tborder-1\n\t\tborder-button-border dark:border-button-border-dark\n\t\trounded-md\n\t\tinline-flex items-center justify-center gap-x-2\n\t\tpx-3 py-1.5\n\n\t\thover:brightness-[1.05]\n\t\tactive:brightness-[0.95]\n\t\tdisabled:hover:brightness-100\n\n\t\tfocus:brightness-[1.05] \n\t\tfocus:border-button-border-focus focus:dark:border-button-border-focus-dark\n\n\t\t focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20\n\t\tfocus-visible:outline-4 focus-visible:outline-black/10 focus-visible:dark:outline-white/20\n\t";
|
|
2
|
+
export declare const BUTTON_STUIC_PRESET_CLASSES: any;
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
5
|
+
import "./index.css";
|
|
6
|
+
interface Props extends HTMLButtonAttributes {
|
|
7
|
+
variant?: "primary" | "secondary" | string;
|
|
8
|
+
size?: "sm" | "md" | "lg" | string;
|
|
9
|
+
muted?: boolean;
|
|
10
|
+
noshadow?: boolean;
|
|
11
|
+
unstyled?: boolean;
|
|
12
|
+
class?: string;
|
|
13
|
+
href?: string;
|
|
14
|
+
children?: Snippet<[{
|
|
15
|
+
checked?: boolean;
|
|
16
|
+
}]>;
|
|
17
|
+
roleSwitch?: boolean;
|
|
18
|
+
checked?: boolean;
|
|
19
|
+
el?: Element;
|
|
39
20
|
}
|
|
40
|
-
declare const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class?: string | undefined;
|
|
44
|
-
href?: string | undefined;
|
|
45
|
-
type?: "reset" | "submit" | "button" | null | undefined;
|
|
46
|
-
shadow?: boolean | undefined;
|
|
47
|
-
rounded?: boolean | "full" | undefined;
|
|
48
|
-
variant?: string | undefined | undefined;
|
|
49
|
-
square?: boolean | undefined;
|
|
50
|
-
disabled?: boolean | undefined;
|
|
51
|
-
value?: string | undefined | undefined;
|
|
52
|
-
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
53
|
-
};
|
|
54
|
-
events: {
|
|
55
|
-
focus: FocusEvent;
|
|
56
|
-
blur: FocusEvent;
|
|
57
|
-
click: MouseEvent;
|
|
58
|
-
change: Event;
|
|
59
|
-
keydown: KeyboardEvent;
|
|
60
|
-
keyup: KeyboardEvent;
|
|
61
|
-
touchstart: TouchEvent;
|
|
62
|
-
touchend: TouchEvent;
|
|
63
|
-
touchmove: TouchEvent;
|
|
64
|
-
touchcancel: TouchEvent;
|
|
65
|
-
mouseenter: MouseEvent;
|
|
66
|
-
mouseleave: MouseEvent;
|
|
67
|
-
} & {
|
|
68
|
-
[evt: string]: CustomEvent<any>;
|
|
69
|
-
};
|
|
70
|
-
slots: {
|
|
71
|
-
default: {};
|
|
72
|
-
};
|
|
73
|
-
exports?: undefined;
|
|
74
|
-
bindings?: undefined;
|
|
75
|
-
};
|
|
76
|
-
export type ButtonProps = typeof __propDef.props;
|
|
77
|
-
export type ButtonEvents = typeof __propDef.events;
|
|
78
|
-
export type ButtonSlots = typeof __propDef.slots;
|
|
79
|
-
export default class Button extends SvelteComponent<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
80
|
-
}
|
|
81
|
-
export {};
|
|
21
|
+
declare const Button: import("svelte").Component<Props, {}, "checked" | "el">;
|
|
22
|
+
type Button = ReturnType<typeof Button>;
|
|
23
|
+
export default Button;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@import "../../_shared.css";
|
|
2
|
+
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
@theme inline {
|
|
5
|
+
--color-button-bg: var(--color-button-bg, var(--color-neutral-200));
|
|
6
|
+
--color-button-bg-dark: var(--color-button-bg-dark, var(--color-neutral-500));
|
|
7
|
+
|
|
8
|
+
--color-button-text: var(--color-button-text, var(--color-black));
|
|
9
|
+
--color-button-text-dark: var(--color-button-text-dark, var(--color-white));
|
|
10
|
+
|
|
11
|
+
--color-button-border: var(--color-button-border, var(--color-neutral-400));
|
|
12
|
+
--color-button-border-dark: var(--color-button-border-dark, var(--color-neutral-800));
|
|
13
|
+
|
|
14
|
+
--color-button-border-focus: var(--color-button-border-focus, var(--color-neutral-500));
|
|
15
|
+
--color-button-border-focus-dark: var(--color-button-border-focus-dark, var(--color-neutral-500));
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Button } from './Button.svelte';
|