@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,387 +1,61 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
border border-neutral-50
|
|
34
|
-
dark:border-neutral-50/20
|
|
35
|
-
`,
|
|
36
|
-
icon: `
|
|
37
|
-
size-12 sm:size-10
|
|
38
|
-
mt-1 mb-4 sm:my-0 sm:mr-5
|
|
39
|
-
mx-auto
|
|
40
|
-
flex flex-shrink-0 items-center justify-center
|
|
41
|
-
rounded-full
|
|
42
|
-
|
|
43
|
-
bg-neutral-950/10 text-neutral-950/80
|
|
44
|
-
dark:bg-neutral-50/20 dark:text-neutral-50/80
|
|
45
|
-
`,
|
|
46
|
-
contentBlock: `mt-3 sm:mt-0 sm:flex-1`,
|
|
47
|
-
title: `
|
|
48
|
-
text-center sm:text-left
|
|
49
|
-
text-base font-semibold leading-6
|
|
50
|
-
`,
|
|
51
|
-
content: `
|
|
52
|
-
mt-2 mx-3 sm:mx-0
|
|
53
|
-
text-center sm:text-left
|
|
54
|
-
text-sm
|
|
55
|
-
opacity-75
|
|
56
|
-
`,
|
|
57
|
-
inputBox: `mt-3`,
|
|
58
|
-
inputField: `m-0`,
|
|
59
|
-
menu: `
|
|
60
|
-
mt-6
|
|
61
|
-
sm:flex sm:space-x-4 justify-end
|
|
62
|
-
space-y-3 sm:space-y-0
|
|
63
|
-
`,
|
|
64
|
-
menuLi: `flex-1 sm:flex-none w-full sm:w-auto sm:inline-block`,
|
|
65
|
-
button: `w-full min-w-24 justify-center`,
|
|
66
|
-
spinnerBox: `
|
|
67
|
-
absolute inset-0 flex justify-center items-center
|
|
68
|
-
rounded-lg
|
|
69
|
-
|
|
70
|
-
bg-neutral-50/75
|
|
71
|
-
dark:bg-neutral-950/75
|
|
72
|
-
`
|
|
73
|
-
};
|
|
74
|
-
// prettier-ignore
|
|
75
|
-
static presetByVariant = {
|
|
76
|
-
info: { dialog: "", icon: "", contentBlock: "", title: "", content: "", inputBox: "", inputField: "", menu: "", button: "", spinnerBox: "" },
|
|
77
|
-
success: { dialog: "", icon: "", contentBlock: "", title: "", content: "", inputBox: "", inputField: "", menu: "", button: "", spinnerBox: "" },
|
|
78
|
-
warn: { dialog: "", icon: "", contentBlock: "", title: "", content: "", inputBox: "", inputField: "", menu: "", button: "", spinnerBox: "" },
|
|
79
|
-
error: { dialog: "", icon: "", contentBlock: "", title: "", content: "", inputBox: "", inputField: "", menu: "", button: "", spinnerBox: "" }
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
const _isFn = (v) => typeof v === "function";
|
|
83
|
-
</script>
|
|
84
|
-
|
|
85
|
-
<script>const { ALERT, CONFIRM, PROMPT } = AlertConfirmPromptType;
|
|
86
|
-
const clog = createClog("AlertConfirmPrompt");
|
|
87
|
-
export let notifications = void 0;
|
|
88
|
-
export let notificationsRestProps = { forceAsHtml: true };
|
|
89
|
-
export let notificationsPositionConfig = {};
|
|
90
|
-
export let acp;
|
|
91
|
-
export let forceAsHtml = void 0;
|
|
92
|
-
export let defaultIcons = acpDefaultIcons;
|
|
93
|
-
export let classes = {};
|
|
94
|
-
export let classesByVariant = {};
|
|
95
|
-
export let backdropFadeIn = true;
|
|
96
|
-
$:
|
|
97
|
-
dialog = $acp[0];
|
|
98
|
-
let _dialogEl;
|
|
99
|
-
let value = null;
|
|
100
|
-
let isPending = false;
|
|
101
|
-
$:
|
|
102
|
-
if (dialog?.type === PROMPT) {
|
|
103
|
-
if (value === null)
|
|
104
|
-
value = dialog.value;
|
|
105
|
-
} else {
|
|
106
|
-
value = null;
|
|
107
|
-
}
|
|
108
|
-
$:
|
|
109
|
-
if (dialog && _dialogEl)
|
|
110
|
-
!_dialogEl.hasAttribute("open") && _dialogEl.showModal();
|
|
111
|
-
$:
|
|
112
|
-
if (!dialog && _dialogEl)
|
|
113
|
-
_dialogEl.close("cleanup");
|
|
114
|
-
const onKeyDown = (e) => {
|
|
115
|
-
if (!dialog)
|
|
116
|
-
return;
|
|
117
|
-
if (e.key === "Escape") {
|
|
118
|
-
e.stopPropagation();
|
|
119
|
-
e.stopImmediatePropagation();
|
|
120
|
-
if (!isPending)
|
|
121
|
-
return acp.escape();
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
onMount(() => {
|
|
125
|
-
_dialogEl.addEventListener("cancel", (e) => {
|
|
126
|
-
e.preventDefault();
|
|
127
|
-
});
|
|
128
|
-
document.addEventListener("keydown", onKeyDown, true);
|
|
129
|
-
return () => document.removeEventListener("keydown", onKeyDown, true);
|
|
130
|
-
});
|
|
131
|
-
const _collectClasses = (o, k) => [
|
|
132
|
-
AlertConfirmPromptConfig?.preset?.[k] || "",
|
|
133
|
-
classes?.[k] || "",
|
|
134
|
-
AlertConfirmPromptConfig.presetByVariant?.[o?.variant]?.[k] || "",
|
|
135
|
-
classesByVariant?.[o?.variant]?.[k] || "",
|
|
136
|
-
o?.class?.[k] || ""
|
|
137
|
-
];
|
|
138
|
-
$:
|
|
139
|
-
_dialogClass = twMerge2(..._collectClasses(dialog, "dialog"));
|
|
140
|
-
$:
|
|
141
|
-
_iconClass = twMerge2(..._collectClasses(dialog, "icon"));
|
|
142
|
-
$:
|
|
143
|
-
_contentBlockClass = twMerge2(..._collectClasses(dialog, "contentBlock"));
|
|
144
|
-
$:
|
|
145
|
-
_titleClass = twMerge2(..._collectClasses(dialog, "title"));
|
|
146
|
-
$:
|
|
147
|
-
_contentClass = twMerge2(..._collectClasses(dialog, "content"));
|
|
148
|
-
$:
|
|
149
|
-
_inputBoxClass = twMerge2(..._collectClasses(dialog, "inputBox"));
|
|
150
|
-
$:
|
|
151
|
-
_inputFieldClass = twMerge2(..._collectClasses(dialog, "inputField"));
|
|
152
|
-
$:
|
|
153
|
-
_menuClass = twMerge2(..._collectClasses(dialog, "menu"));
|
|
154
|
-
$:
|
|
155
|
-
_menuLiClass = twMerge2(AlertConfirmPromptConfig.preset.menuLi);
|
|
156
|
-
$:
|
|
157
|
-
_buttonClass = twMerge2(..._collectClasses(dialog, "button"));
|
|
158
|
-
$:
|
|
159
|
-
_spinnerBoxClass = twMerge2(..._collectClasses(dialog, "spinnerBox"));
|
|
160
|
-
$:
|
|
161
|
-
iconFn = dialog?.iconFn ?? defaultIcons?.[dialog?.variant];
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { twMerge } from "../../utils/tw-merge.js";
|
|
3
|
+
import ModalDialog from "../ModalDialog/ModalDialog.svelte";
|
|
4
|
+
import { isTHCNotEmpty } from "../Thc/Thc.svelte";
|
|
5
|
+
import {
|
|
6
|
+
AlertConfirmPromptType,
|
|
7
|
+
type AlertConfirmPromptStack,
|
|
8
|
+
} from "./alert-confirm-prompt-stack.svelte.js";
|
|
9
|
+
import Current from "./Current.svelte";
|
|
10
|
+
|
|
11
|
+
const { ALERT, CONFIRM, PROMPT } = AlertConfirmPromptType;
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
acp?: AlertConfirmPromptStack;
|
|
15
|
+
forceAsHtml?: boolean;
|
|
16
|
+
class?: string;
|
|
17
|
+
classModalInnerBox?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let { acp, forceAsHtml, class: classProp, classModalInnerBox }: Props = $props();
|
|
21
|
+
|
|
22
|
+
let modal = $state<ModalDialog>();
|
|
23
|
+
|
|
24
|
+
$effect(() => {
|
|
25
|
+
if (modal) {
|
|
26
|
+
acp?.current ? modal.open() : modal.close();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
let value = $state();
|
|
31
|
+
let isPending = $state(false);
|
|
162
32
|
</script>
|
|
163
33
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
// clog('on:reset', value);
|
|
193
|
-
isPending = true;
|
|
194
|
-
await Promise.resolve(dialog.onCancel(false));
|
|
195
|
-
isPending = false;
|
|
196
|
-
value = null;
|
|
197
|
-
}}
|
|
198
|
-
>
|
|
199
|
-
<!-- this sm:flex is not configurable -->
|
|
200
|
-
<div class="sm:flex sm:items-start">
|
|
201
|
-
{#if _isFn(iconFn)}
|
|
202
|
-
<div
|
|
203
|
-
class={_iconClass}
|
|
204
|
-
data-acp-type={dialog?.type}
|
|
205
|
-
data-acp-variant={dialog?.variant}
|
|
206
|
-
data-acp-is-pending={isPending}
|
|
207
|
-
>
|
|
208
|
-
{@html iconFn()}
|
|
209
|
-
</div>
|
|
210
|
-
{/if}
|
|
211
|
-
<div class={_contentBlockClass}>
|
|
212
|
-
<h1
|
|
213
|
-
class={_titleClass}
|
|
214
|
-
data-acp-type={dialog?.type}
|
|
215
|
-
data-acp-variant={dialog?.variant}
|
|
216
|
-
data-acp-is-pending={isPending}
|
|
217
|
-
>
|
|
218
|
-
<Thc thc={dialog.title} {forceAsHtml} />
|
|
219
|
-
</h1>
|
|
220
|
-
{#if dialog.content}
|
|
221
|
-
<div
|
|
222
|
-
class={_contentClass}
|
|
223
|
-
data-acp-type={dialog?.type}
|
|
224
|
-
data-acp-variant={dialog?.variant}
|
|
225
|
-
data-acp-is-pending={isPending}
|
|
226
|
-
>
|
|
227
|
-
<Thc thc={dialog.content} {forceAsHtml} />
|
|
228
|
-
</div>
|
|
229
|
-
{/if}
|
|
230
|
-
{#if dialog.type === PROMPT}
|
|
231
|
-
<div
|
|
232
|
-
class={_inputBoxClass}
|
|
233
|
-
data-acp-type={dialog?.type}
|
|
234
|
-
data-acp-variant={dialog?.variant}
|
|
235
|
-
data-acp-is-pending={isPending}
|
|
236
|
-
>
|
|
237
|
-
{#if dialog?.promptFieldProps?.options?.length}
|
|
238
|
-
<FieldSelect
|
|
239
|
-
class={_inputFieldClass}
|
|
240
|
-
bind:value
|
|
241
|
-
data-acp-type={dialog?.type}
|
|
242
|
-
data-acp-variant={dialog?.variant}
|
|
243
|
-
data-acp-is-pending={isPending}
|
|
244
|
-
autofocus
|
|
245
|
-
size="sm"
|
|
246
|
-
validate
|
|
247
|
-
{...dialog.promptFieldProps}
|
|
248
|
-
/>
|
|
249
|
-
{:else}
|
|
250
|
-
<Field
|
|
251
|
-
class={_inputFieldClass}
|
|
252
|
-
bind:value
|
|
253
|
-
data-acp-type={dialog?.type}
|
|
254
|
-
data-acp-variant={dialog?.variant}
|
|
255
|
-
data-acp-is-pending={isPending}
|
|
256
|
-
autofocus
|
|
257
|
-
size="sm"
|
|
258
|
-
validate
|
|
259
|
-
{...dialog?.promptFieldProps || {}}
|
|
260
|
-
/>
|
|
261
|
-
{/if}
|
|
262
|
-
</div>
|
|
263
|
-
{/if}
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
<menu
|
|
267
|
-
class={_menuClass}
|
|
268
|
-
data-acp-type={dialog?.type}
|
|
269
|
-
data-acp-variant={dialog?.variant}
|
|
270
|
-
data-acp-is-pending={isPending}
|
|
271
|
-
>
|
|
272
|
-
{#if dialog.type !== ALERT}
|
|
273
|
-
<li
|
|
274
|
-
class={_menuLiClass}
|
|
275
|
-
data-acp-dialog-type={dialog?.type}
|
|
276
|
-
data-acp-variant={dialog?.variant}
|
|
277
|
-
data-acp-is-pending={isPending}
|
|
278
|
-
>
|
|
279
|
-
<Button
|
|
280
|
-
class={_buttonClass}
|
|
281
|
-
type="reset"
|
|
282
|
-
data-acp-button-type="cancel"
|
|
283
|
-
data-acp-dialog-type={dialog?.type}
|
|
284
|
-
data-acp-variant={dialog?.variant}
|
|
285
|
-
data-acp-is-pending={isPending}
|
|
286
|
-
disabled={isPending}
|
|
287
|
-
>
|
|
288
|
-
<Thc thc={dialog.labelCancel} {forceAsHtml} />
|
|
289
|
-
</Button>
|
|
290
|
-
</li>
|
|
291
|
-
{/if}
|
|
292
|
-
{#if dialog.labelCustom && _isFn(dialog.onCustom)}
|
|
293
|
-
<li
|
|
294
|
-
class={_menuLiClass}
|
|
295
|
-
data-acp-dialog-type={dialog?.type}
|
|
296
|
-
data-acp-variant={dialog?.variant}
|
|
297
|
-
data-acp-is-pending={isPending}
|
|
298
|
-
>
|
|
299
|
-
<Button
|
|
300
|
-
class={_buttonClass}
|
|
301
|
-
on:click={async (e) => {
|
|
302
|
-
e.preventDefault();
|
|
303
|
-
isPending = true;
|
|
304
|
-
await Promise.resolve(dialog.onCustom(value));
|
|
305
|
-
isPending = false;
|
|
306
|
-
value = null;
|
|
307
|
-
}}
|
|
308
|
-
type="button"
|
|
309
|
-
data-acp-button-type="custom"
|
|
310
|
-
data-acp-dialog-type={dialog?.type}
|
|
311
|
-
data-acp-variant={dialog?.variant}
|
|
312
|
-
data-acp-is-pending={isPending}
|
|
313
|
-
disabled={isPending}
|
|
314
|
-
>
|
|
315
|
-
<Thc thc={dialog.labelCustom} {forceAsHtml} />
|
|
316
|
-
</Button>
|
|
317
|
-
</li>
|
|
318
|
-
{/if}
|
|
319
|
-
<li
|
|
320
|
-
class={_menuLiClass}
|
|
321
|
-
data-acp-type={dialog?.type}
|
|
322
|
-
data-acp-variant={dialog?.variant}
|
|
323
|
-
data-acp-is-pending={isPending}
|
|
324
|
-
>
|
|
325
|
-
<Button
|
|
326
|
-
class={_buttonClass}
|
|
327
|
-
type="submit"
|
|
328
|
-
value="OK"
|
|
329
|
-
data-acp-button-type="ok"
|
|
330
|
-
data-acp-dialog-type={dialog?.type}
|
|
331
|
-
data-acp-variant={dialog?.variant}
|
|
332
|
-
data-acp-is-pending={isPending}
|
|
333
|
-
disabled={isPending}
|
|
334
|
-
variant="primary"
|
|
335
|
-
>
|
|
336
|
-
<Thc thc={dialog.labelOk} {forceAsHtml} />
|
|
337
|
-
</Button>
|
|
338
|
-
</li>
|
|
339
|
-
</menu>
|
|
340
|
-
{#if isPending}
|
|
341
|
-
<div
|
|
342
|
-
class={_spinnerBoxClass}
|
|
343
|
-
data-acp-type={dialog?.type}
|
|
344
|
-
data-acp-variant={dialog?.variant}
|
|
345
|
-
>
|
|
346
|
-
<div class="rotating-cw">
|
|
347
|
-
{@html acpDefaultIcons.spinner()}
|
|
348
|
-
</div>
|
|
349
|
-
</div>
|
|
350
|
-
{/if}
|
|
351
|
-
</form>
|
|
352
|
-
{/key}
|
|
353
|
-
{/if}
|
|
354
|
-
|
|
355
|
-
{#if notifications}
|
|
356
|
-
<Notifications
|
|
357
|
-
{notifications}
|
|
358
|
-
{...notificationsRestProps || {}}
|
|
359
|
-
{...notificationsPositionConfig || {}}
|
|
360
|
-
/>
|
|
361
|
-
{/if}
|
|
362
|
-
</dialog>
|
|
363
|
-
|
|
364
|
-
<style>@keyframes -global-rotating-cw {
|
|
365
|
-
from {
|
|
366
|
-
transform: rotate(0deg);
|
|
367
|
-
}
|
|
368
|
-
to {
|
|
369
|
-
transform: rotate(360deg);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
.rotating-cw {
|
|
373
|
-
animation: rotating-cw 0.6s linear infinite;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
dialog.backdrop-fade-in-normal[open]::backdrop {
|
|
377
|
-
animation: fade 0.15s ease-out;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
@keyframes fade {
|
|
381
|
-
from {
|
|
382
|
-
opacity: 0;
|
|
383
|
-
}
|
|
384
|
-
to {
|
|
385
|
-
opacity: 1;
|
|
386
|
-
}
|
|
387
|
-
}</style>
|
|
34
|
+
{#if acp?.current}
|
|
35
|
+
<!--
|
|
36
|
+
// always allow escape - this emulates native alert/confirm/prompt
|
|
37
|
+
preEscapeClose={acp?.current?.onEscape}
|
|
38
|
+
// do not close modal if stack is not empty (this is just `ModalDialog` render business)
|
|
39
|
+
preClose={() => !acp.length}
|
|
40
|
+
// do not allow close on outside click - this emulates native alert/confirm/prompt
|
|
41
|
+
noClickOutsideClose
|
|
42
|
+
-->
|
|
43
|
+
<ModalDialog
|
|
44
|
+
bind:this={modal}
|
|
45
|
+
preEscapeClose={() => {
|
|
46
|
+
return isPending ? false : acp?.current.onEscape?.();
|
|
47
|
+
}}
|
|
48
|
+
preClose={() => !acp.length}
|
|
49
|
+
noClickOutsideClose
|
|
50
|
+
type={acp?.current?.type}
|
|
51
|
+
class={twMerge(
|
|
52
|
+
"max-w-xl justify-end max-h-[62vh] sm:max-h-[200px] border p-4 rounded-lg",
|
|
53
|
+
// different max-h based on not/existing content
|
|
54
|
+
isTHCNotEmpty(acp?.current?.content) ? "sm:max-h-[200px]" : "sm:max-h-[150px]",
|
|
55
|
+
acp?.current?.type === PROMPT && "sm:max-h-[250px]",
|
|
56
|
+
classProp
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
<Current bind:value bind:isPending {acp} />
|
|
60
|
+
</ModalDialog>
|
|
61
|
+
{/if}
|
|
@@ -1,102 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { type AlertConfirmPromptStack } from "./alert-confirm-prompt-stack.svelte.js";
|
|
2
|
+
interface Props {
|
|
3
|
+
acp?: AlertConfirmPromptStack;
|
|
4
|
+
forceAsHtml?: boolean;
|
|
5
|
+
class?: string;
|
|
6
|
+
classModalInnerBox?: string;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
icon: string;
|
|
12
|
-
contentBlock: string;
|
|
13
|
-
title: string;
|
|
14
|
-
content: string;
|
|
15
|
-
inputBox: string;
|
|
16
|
-
inputField: string;
|
|
17
|
-
menu: string;
|
|
18
|
-
menuLi: string;
|
|
19
|
-
button: string;
|
|
20
|
-
spinnerBox: string;
|
|
21
|
-
};
|
|
22
|
-
static presetByVariant: {
|
|
23
|
-
info: {
|
|
24
|
-
dialog: string;
|
|
25
|
-
icon: string;
|
|
26
|
-
contentBlock: string;
|
|
27
|
-
title: string;
|
|
28
|
-
content: string;
|
|
29
|
-
inputBox: string;
|
|
30
|
-
inputField: string;
|
|
31
|
-
menu: string;
|
|
32
|
-
button: string;
|
|
33
|
-
spinnerBox: string;
|
|
34
|
-
};
|
|
35
|
-
success: {
|
|
36
|
-
dialog: string;
|
|
37
|
-
icon: string;
|
|
38
|
-
contentBlock: string;
|
|
39
|
-
title: string;
|
|
40
|
-
content: string;
|
|
41
|
-
inputBox: string;
|
|
42
|
-
inputField: string;
|
|
43
|
-
menu: string;
|
|
44
|
-
button: string;
|
|
45
|
-
spinnerBox: string;
|
|
46
|
-
};
|
|
47
|
-
warn: {
|
|
48
|
-
dialog: string;
|
|
49
|
-
icon: string;
|
|
50
|
-
contentBlock: string;
|
|
51
|
-
title: string;
|
|
52
|
-
content: string;
|
|
53
|
-
inputBox: string;
|
|
54
|
-
inputField: string;
|
|
55
|
-
menu: string;
|
|
56
|
-
button: string;
|
|
57
|
-
spinnerBox: string;
|
|
58
|
-
};
|
|
59
|
-
error: {
|
|
60
|
-
dialog: string;
|
|
61
|
-
icon: string;
|
|
62
|
-
contentBlock: string;
|
|
63
|
-
title: string;
|
|
64
|
-
content: string;
|
|
65
|
-
inputBox: string;
|
|
66
|
-
inputField: string;
|
|
67
|
-
menu: string;
|
|
68
|
-
button: string;
|
|
69
|
-
spinnerBox: string;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
declare const __propDef: {
|
|
74
|
-
props: {
|
|
75
|
-
notifications?: ReturnType<typeof createNotificationsStore> | undefined;
|
|
76
|
-
notificationsRestProps?: any;
|
|
77
|
-
notificationsPositionConfig?: Partial<{
|
|
78
|
-
posX: NOTIFICATIONS_POSX;
|
|
79
|
-
posXMobile: NOTIFICATIONS_POSX;
|
|
80
|
-
posY: NOTIFICATIONS_POSY;
|
|
81
|
-
posYMobile: NOTIFICATIONS_POSY;
|
|
82
|
-
}>;
|
|
83
|
-
acp: ReturnType<typeof createAlertConfirmPromptStore>;
|
|
84
|
-
forceAsHtml?: boolean | undefined;
|
|
85
|
-
defaultIcons?: Partial<AlertConfirmPromptIcons>;
|
|
86
|
-
classes?: Partial<AlertConfirmPromptKnownClasses>;
|
|
87
|
-
classesByVariant?: Partial<Record<AlertConfirmPromptVariant, Partial<AlertConfirmPromptKnownClasses>>>;
|
|
88
|
-
backdropFadeIn?: boolean;
|
|
89
|
-
};
|
|
90
|
-
events: {
|
|
91
|
-
[evt: string]: CustomEvent<any>;
|
|
92
|
-
};
|
|
93
|
-
slots: {};
|
|
94
|
-
exports?: {} | undefined;
|
|
95
|
-
bindings?: string | undefined;
|
|
96
|
-
};
|
|
97
|
-
export type AlertConfirmPromptProps = typeof __propDef.props;
|
|
98
|
-
export type AlertConfirmPromptEvents = typeof __propDef.events;
|
|
99
|
-
export type AlertConfirmPromptSlots = typeof __propDef.slots;
|
|
100
|
-
export default class AlertConfirmPrompt extends SvelteComponent<AlertConfirmPromptProps, AlertConfirmPromptEvents, AlertConfirmPromptSlots> {
|
|
101
|
-
}
|
|
102
|
-
export {};
|
|
8
|
+
declare const AlertConfirmPrompt: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type AlertConfirmPrompt = ReturnType<typeof AlertConfirmPrompt>;
|
|
10
|
+
export default AlertConfirmPrompt;
|