@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
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { twMerge } from "../../utils/tw-merge.js";
|
|
3
|
+
import Button from "../Button/Button.svelte";
|
|
4
|
+
import FieldInput from "../Input/FieldInput.svelte";
|
|
5
|
+
import FieldSelect from "../Input/FieldSelect.svelte";
|
|
6
|
+
import Spinner from "../Spinner/Spinner.svelte";
|
|
7
|
+
import Thc, { isTHCNotEmpty } from "../Thc/Thc.svelte";
|
|
8
|
+
import { acpDefaultIcons } from "./acp-icons.js";
|
|
9
|
+
import {
|
|
10
|
+
AlertConfirmPromptType,
|
|
11
|
+
type AlertConfirmPromptStack,
|
|
12
|
+
} from "./alert-confirm-prompt-stack.svelte.js";
|
|
13
|
+
|
|
14
|
+
const { ALERT, CONFIRM, PROMPT } = AlertConfirmPromptType;
|
|
15
|
+
const isFn = (v: any) => typeof v === "function";
|
|
16
|
+
|
|
17
|
+
interface Props {
|
|
18
|
+
acp?: AlertConfirmPromptStack;
|
|
19
|
+
value?: any;
|
|
20
|
+
isPending?: boolean;
|
|
21
|
+
forceAsHtml?: boolean;
|
|
22
|
+
class?: string;
|
|
23
|
+
classWrap?: string;
|
|
24
|
+
classIconBox?: string;
|
|
25
|
+
classContentBox?: string;
|
|
26
|
+
classTitle?: string;
|
|
27
|
+
classContent?: string;
|
|
28
|
+
classInputBox?: string;
|
|
29
|
+
classInput?: string;
|
|
30
|
+
classMenu?: string;
|
|
31
|
+
classMenuLi?: string;
|
|
32
|
+
classButton?: string;
|
|
33
|
+
classSpinnerBox?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let {
|
|
37
|
+
acp,
|
|
38
|
+
value = $bindable(),
|
|
39
|
+
isPending = $bindable(false),
|
|
40
|
+
forceAsHtml = true,
|
|
41
|
+
class: classProp,
|
|
42
|
+
classWrap,
|
|
43
|
+
classIconBox,
|
|
44
|
+
classContentBox,
|
|
45
|
+
classTitle,
|
|
46
|
+
classContent,
|
|
47
|
+
classInputBox,
|
|
48
|
+
classInput,
|
|
49
|
+
classMenu,
|
|
50
|
+
classMenuLi,
|
|
51
|
+
classButton,
|
|
52
|
+
classSpinnerBox,
|
|
53
|
+
}: Props = $props();
|
|
54
|
+
|
|
55
|
+
let current = $derived(acp?.current!);
|
|
56
|
+
|
|
57
|
+
let iconFn = $derived.by(() => {
|
|
58
|
+
let out = current.iconFn;
|
|
59
|
+
if (current.iconFn === true) {
|
|
60
|
+
out = acpDefaultIcons[current.variant];
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const createOnClick = (worker: CallableFunction) => async (e: Event) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
isPending = true;
|
|
68
|
+
await Promise.resolve(worker(current.type === PROMPT ? value : true));
|
|
69
|
+
isPending = false;
|
|
70
|
+
value = null;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const debug = (c?: string, flag = 0) =>
|
|
74
|
+
c && flag ? `outline outline-dashed ${c}` : "";
|
|
75
|
+
|
|
76
|
+
// Default classes
|
|
77
|
+
|
|
78
|
+
const _class = "p-1 sm:p-2 h-full flex flex-col overflow-hidden";
|
|
79
|
+
|
|
80
|
+
const _classWrap = `flex-1 sm:flex sm:items-start overflow-hidden`;
|
|
81
|
+
|
|
82
|
+
const _classIconBox = `size-12 sm:size-10
|
|
83
|
+
mt-1 mb-4 sm:my-0 sm:mr-5
|
|
84
|
+
mx-auto
|
|
85
|
+
flex flex-shrink-0 items-center justify-center
|
|
86
|
+
rounded-full
|
|
87
|
+
bg-neutral-950/10 text-neutral-950/80
|
|
88
|
+
dark:bg-neutral-50/20 dark:text-neutral-50/80`;
|
|
89
|
+
|
|
90
|
+
const _classContentBox = `mt-3 sm:mt-0 flex-1 overflow-hidden h-full flex flex-col`;
|
|
91
|
+
|
|
92
|
+
const _classTitle = `text-center sm:text-left text-base font-semibold leading-6`;
|
|
93
|
+
|
|
94
|
+
const _classContent = `mt-2 mx-3 sm:mx-0 text-center sm:text-left text-sm opacity-75`;
|
|
95
|
+
|
|
96
|
+
const _classMenu = `mt-6 sm:flex sm:space-x-4 justify-end space-y-3 sm:space-y-0`;
|
|
97
|
+
|
|
98
|
+
const _classMenuLi = `flex-1 sm:flex-none w-full sm:w-auto sm:inline-block`;
|
|
99
|
+
|
|
100
|
+
const _classButton = "min-w-24 text-center w-full sm:w-auto";
|
|
101
|
+
|
|
102
|
+
const _classSpinnerBox = `absolute inset-0 flex items-center justify-center bg-white/75 dark:bg-black/75`;
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<div class={twMerge("stuic-acp", _class, classProp)}>
|
|
106
|
+
<div class={twMerge("wrap", _classWrap, classWrap)}>
|
|
107
|
+
{#if typeof iconFn === "function"}
|
|
108
|
+
<div
|
|
109
|
+
class={twMerge(
|
|
110
|
+
"icon-box",
|
|
111
|
+
debug("outline-green-500"),
|
|
112
|
+
_classIconBox,
|
|
113
|
+
classIconBox
|
|
114
|
+
)}
|
|
115
|
+
>
|
|
116
|
+
{@html iconFn()}
|
|
117
|
+
</div>
|
|
118
|
+
{/if}
|
|
119
|
+
<div class={twMerge("content-box", _classContentBox, classContentBox)}>
|
|
120
|
+
<h1
|
|
121
|
+
class={twMerge(
|
|
122
|
+
"title",
|
|
123
|
+
_classTitle,
|
|
124
|
+
typeof iconFn === "function" && "pt-2",
|
|
125
|
+
classTitle
|
|
126
|
+
)}
|
|
127
|
+
>
|
|
128
|
+
<Thc thc={current.title} {forceAsHtml} />
|
|
129
|
+
</h1>
|
|
130
|
+
|
|
131
|
+
<div class="scrollable overflow-y-auto flex-1" style="scrollbar-width: thin;">
|
|
132
|
+
{#if isTHCNotEmpty(current.content)}
|
|
133
|
+
<div class={twMerge("content", _classContent, classContent)}>
|
|
134
|
+
<Thc thc={current.content} {forceAsHtml} />
|
|
135
|
+
</div>
|
|
136
|
+
{/if}
|
|
137
|
+
|
|
138
|
+
{#if current.type === PROMPT}
|
|
139
|
+
<div class={twMerge("input-box", "mt-1 p-2", classInputBox)}>
|
|
140
|
+
{#if current?.promptFieldProps?.options?.length}
|
|
141
|
+
<FieldSelect
|
|
142
|
+
bind:value
|
|
143
|
+
class={twMerge("input", "m-0", classInput)}
|
|
144
|
+
options={current.promptFieldProps.options}
|
|
145
|
+
renderSize="sm"
|
|
146
|
+
disabled={isPending}
|
|
147
|
+
{...current.promptFieldProps}
|
|
148
|
+
/>
|
|
149
|
+
{:else}
|
|
150
|
+
<FieldInput
|
|
151
|
+
bind:value
|
|
152
|
+
class={twMerge("input", classInput)}
|
|
153
|
+
renderSize="sm"
|
|
154
|
+
disabled={isPending}
|
|
155
|
+
{...current?.promptFieldProps || {}}
|
|
156
|
+
/>
|
|
157
|
+
{/if}
|
|
158
|
+
</div>
|
|
159
|
+
{/if}
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
<menu class={twMerge(_classMenu, classMenu)}>
|
|
164
|
+
{#if current.type !== ALERT}
|
|
165
|
+
<li class={twMerge(_classMenuLi, classMenuLi)}>
|
|
166
|
+
<Button
|
|
167
|
+
class={twMerge("cancel", _classButton, classButton)}
|
|
168
|
+
disabled={isPending}
|
|
169
|
+
onclick={createOnClick(current.onCancel)}
|
|
170
|
+
>
|
|
171
|
+
<Thc thc={current.labelCancel} {forceAsHtml} />
|
|
172
|
+
</Button>
|
|
173
|
+
</li>
|
|
174
|
+
{/if}
|
|
175
|
+
{#if current.labelCustom && typeof current.onCustom === "function"}
|
|
176
|
+
<li class={twMerge(_classMenuLi, classMenuLi)}>
|
|
177
|
+
<Button
|
|
178
|
+
class={twMerge("custom", _classButton, classButton)}
|
|
179
|
+
disabled={isPending}
|
|
180
|
+
onclick={createOnClick(current.onCustom)}
|
|
181
|
+
>
|
|
182
|
+
<Thc thc={current.labelCustom} {forceAsHtml} />
|
|
183
|
+
</Button>
|
|
184
|
+
</li>
|
|
185
|
+
{/if}
|
|
186
|
+
<li class={twMerge(_classMenuLi, classMenuLi)}>
|
|
187
|
+
<Button
|
|
188
|
+
class={twMerge("ok", _classButton, classButton)}
|
|
189
|
+
variant="primary"
|
|
190
|
+
disabled={isPending}
|
|
191
|
+
onclick={createOnClick(current.onOk)}
|
|
192
|
+
>
|
|
193
|
+
<Thc thc={current.labelOk} {forceAsHtml} />
|
|
194
|
+
</Button>
|
|
195
|
+
</li>
|
|
196
|
+
</menu>
|
|
197
|
+
{#if isPending}
|
|
198
|
+
<div class={twMerge("spinner-box", _classSpinnerBox, classSpinnerBox)}>
|
|
199
|
+
<Spinner class="w-8" />
|
|
200
|
+
</div>
|
|
201
|
+
{/if}
|
|
202
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type AlertConfirmPromptStack } from "./alert-confirm-prompt-stack.svelte.js";
|
|
2
|
+
interface Props {
|
|
3
|
+
acp?: AlertConfirmPromptStack;
|
|
4
|
+
value?: any;
|
|
5
|
+
isPending?: boolean;
|
|
6
|
+
forceAsHtml?: boolean;
|
|
7
|
+
class?: string;
|
|
8
|
+
classWrap?: string;
|
|
9
|
+
classIconBox?: string;
|
|
10
|
+
classContentBox?: string;
|
|
11
|
+
classTitle?: string;
|
|
12
|
+
classContent?: string;
|
|
13
|
+
classInputBox?: string;
|
|
14
|
+
classInput?: string;
|
|
15
|
+
classMenu?: string;
|
|
16
|
+
classMenuLi?: string;
|
|
17
|
+
classButton?: string;
|
|
18
|
+
classSpinnerBox?: string;
|
|
19
|
+
}
|
|
20
|
+
declare const Current: import("svelte").Component<Props, {}, "value" | "isPending">;
|
|
21
|
+
type Current = ReturnType<typeof Current>;
|
|
22
|
+
export default Current;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const acpDefaultIcons: {
|
|
2
|
+
info: () => any;
|
|
3
|
+
success: () => any;
|
|
4
|
+
warn: () => any;
|
|
5
|
+
error: () => any;
|
|
6
|
+
spinner: () => any;
|
|
7
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { iconFeatherAlertTriangle } from
|
|
2
|
-
import { iconFeatherCheckCircle } from
|
|
3
|
-
import { iconFeatherInfo } from
|
|
4
|
-
import { iconFeatherRefreshCw } from
|
|
5
|
-
import { iconFeatherXOctagon } from
|
|
1
|
+
import { iconFeatherAlertTriangle } from "@marianmeres/icons-fns/feather/iconFeatherAlertTriangle.js";
|
|
2
|
+
import { iconFeatherCheckCircle } from "@marianmeres/icons-fns/feather/iconFeatherCheckCircle.js";
|
|
3
|
+
import { iconFeatherInfo } from "@marianmeres/icons-fns/feather/iconFeatherInfo.js";
|
|
4
|
+
import { iconFeatherRefreshCw } from "@marianmeres/icons-fns/feather/iconFeatherRefreshCw.js";
|
|
5
|
+
import { iconFeatherXOctagon } from "@marianmeres/icons-fns/feather/iconFeatherXOctagon.js";
|
|
6
6
|
export const acpDefaultIcons = {
|
|
7
|
-
info: () => iconFeatherInfo({}),
|
|
7
|
+
info: () => iconFeatherInfo({ size: 24 }),
|
|
8
8
|
success: () => iconFeatherCheckCircle({}),
|
|
9
|
-
warn: () => iconFeatherAlertTriangle({ class:
|
|
9
|
+
warn: () => iconFeatherAlertTriangle({ class: "-mt-[3px]" }), // move up a little because it looks better with the triangle
|
|
10
10
|
error: () => iconFeatherXOctagon({}),
|
|
11
|
-
spinner: () => iconFeatherRefreshCw({ size: 32, class:
|
|
11
|
+
spinner: () => iconFeatherRefreshCw({ size: 32, class: "opacity-50" }),
|
|
12
12
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { THC } from "../Thc/Thc.svelte";
|
|
2
|
+
export declare enum AlertConfirmPromptType {
|
|
3
|
+
ALERT = "alert",
|
|
4
|
+
CONFIRM = "confirm",
|
|
5
|
+
PROMPT = "prompt"
|
|
6
|
+
}
|
|
7
|
+
export type AlertConfirmPromptVariant = "info" | "success" | "warn" | "error";
|
|
8
|
+
export type FnOnOK = (value: any) => any;
|
|
9
|
+
export type FnOnCancel = (value: false) => any;
|
|
10
|
+
export type FnOnEscape = () => void;
|
|
11
|
+
export type FnOnCustom = (value: any) => any;
|
|
12
|
+
export interface AlertConfirmPromptObj extends Record<string, any> {
|
|
13
|
+
type: AlertConfirmPromptType.ALERT | AlertConfirmPromptType.CONFIRM | AlertConfirmPromptType.PROMPT;
|
|
14
|
+
title: THC;
|
|
15
|
+
content: THC;
|
|
16
|
+
value: any;
|
|
17
|
+
labelOk: THC;
|
|
18
|
+
onOk: FnOnOK;
|
|
19
|
+
labelCancel: THC;
|
|
20
|
+
onCancel: FnOnCancel;
|
|
21
|
+
onEscape: FnOnEscape;
|
|
22
|
+
labelCustom?: THC;
|
|
23
|
+
onCustom?: FnOnCustom;
|
|
24
|
+
promptFieldProps?: any;
|
|
25
|
+
variant: AlertConfirmPromptVariant;
|
|
26
|
+
iconFn: (() => string) | boolean;
|
|
27
|
+
forceAsHtml?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare class AlertConfirmPromptStack {
|
|
30
|
+
#private;
|
|
31
|
+
defaults: Partial<AlertConfirmPromptObj>;
|
|
32
|
+
constructor(defaults?: Partial<AlertConfirmPromptObj>);
|
|
33
|
+
get length(): number;
|
|
34
|
+
get current(): AlertConfirmPromptObj;
|
|
35
|
+
shift: () => AlertConfirmPromptObj | undefined;
|
|
36
|
+
reset: () => void;
|
|
37
|
+
escape: () => void;
|
|
38
|
+
dump: () => AlertConfirmPromptObj[];
|
|
39
|
+
/**
|
|
40
|
+
* Main api.
|
|
41
|
+
*/
|
|
42
|
+
alert: (o?: Partial<AlertConfirmPromptObj> | string) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Main api.
|
|
45
|
+
*/
|
|
46
|
+
confirm: (onOk: FnOnOK, o?: Partial<AlertConfirmPromptObj>) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Main api.
|
|
49
|
+
*/
|
|
50
|
+
prompt: (onOk: FnOnOK, o?: Partial<AlertConfirmPromptObj>) => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sugar helper to monkey patch the native window.alert
|
|
54
|
+
*/
|
|
55
|
+
export declare function createAlert(acp: AlertConfirmPromptStack, defaults?: Partial<AlertConfirmPromptObj>): (message: string, o?: Partial<AlertConfirmPromptObj>) => Promise<undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Sugar helper to monkey patch the native window.confirm
|
|
58
|
+
*/
|
|
59
|
+
export declare function createConfirm(acp: AlertConfirmPromptStack, defaults?: Partial<AlertConfirmPromptObj>): (message: string, o?: Partial<AlertConfirmPromptObj>) => Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Sugar helper to monkey patch the native window.prompt
|
|
62
|
+
*/
|
|
63
|
+
export declare function createPrompt(acp: AlertConfirmPromptStack, defaults?: Partial<AlertConfirmPromptObj>): (message: string, defaultValue?: string, o?: Partial<AlertConfirmPromptObj>) => Promise<string | null>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { createClog } from "@marianmeres/clog";
|
|
2
|
+
const clog = createClog("alert-confirm-prompt-stack").debug;
|
|
3
|
+
export var AlertConfirmPromptType;
|
|
4
|
+
(function (AlertConfirmPromptType) {
|
|
5
|
+
AlertConfirmPromptType["ALERT"] = "alert";
|
|
6
|
+
AlertConfirmPromptType["CONFIRM"] = "confirm";
|
|
7
|
+
AlertConfirmPromptType["PROMPT"] = "prompt";
|
|
8
|
+
})(AlertConfirmPromptType || (AlertConfirmPromptType = {}));
|
|
9
|
+
const isFn = (v) => typeof v === "function";
|
|
10
|
+
const ucf = (s) => `${s}`[0].toUpperCase() + `${s}`.slice(1);
|
|
11
|
+
export class AlertConfirmPromptStack {
|
|
12
|
+
defaults;
|
|
13
|
+
// fifo
|
|
14
|
+
#stack = $state([]);
|
|
15
|
+
constructor(defaults = {}) {
|
|
16
|
+
this.defaults = defaults;
|
|
17
|
+
this.defaults ??= {};
|
|
18
|
+
this.defaults.labelOk ||= "OK";
|
|
19
|
+
this.defaults.labelCancel ||= "Cancel";
|
|
20
|
+
this.defaults.iconFn ??= true;
|
|
21
|
+
}
|
|
22
|
+
get length() {
|
|
23
|
+
return this.#stack.length;
|
|
24
|
+
}
|
|
25
|
+
get current() {
|
|
26
|
+
return this.#stack[0];
|
|
27
|
+
}
|
|
28
|
+
#push = (o) => {
|
|
29
|
+
if (!isFn(o.onOk))
|
|
30
|
+
o.onOk = this.shift;
|
|
31
|
+
if (!isFn(o.onCancel))
|
|
32
|
+
o.onCancel = this.shift;
|
|
33
|
+
if (!isFn(o.onEscape))
|
|
34
|
+
o.onEscape = this.shift;
|
|
35
|
+
if (!isFn(o.onCustom))
|
|
36
|
+
o.onCustom = () => undefined;
|
|
37
|
+
o.type ??= AlertConfirmPromptType.ALERT;
|
|
38
|
+
o.labelOk ??= this.defaults.labelOk;
|
|
39
|
+
o.labelCancel ??= this.defaults.labelCancel;
|
|
40
|
+
o.iconFn ??= this.defaults.iconFn;
|
|
41
|
+
o.title ??= ucf(`${o.type || ""}`);
|
|
42
|
+
// variant defaults to info
|
|
43
|
+
if (!["info", "success", "warn", "error"].includes(o?.variant)) {
|
|
44
|
+
o.variant = "info";
|
|
45
|
+
}
|
|
46
|
+
o._id = Math.random().toString(36).slice(2);
|
|
47
|
+
this.#stack.push(o);
|
|
48
|
+
};
|
|
49
|
+
shift = () => this.#stack.shift();
|
|
50
|
+
reset = () => {
|
|
51
|
+
this.#stack = [];
|
|
52
|
+
};
|
|
53
|
+
escape = () => {
|
|
54
|
+
this.#stack?.[0]?.onEscape?.();
|
|
55
|
+
this.shift();
|
|
56
|
+
};
|
|
57
|
+
dump = () => {
|
|
58
|
+
return [...this.#stack];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Main api.
|
|
62
|
+
*/
|
|
63
|
+
alert = (o) => {
|
|
64
|
+
if (typeof o === "string")
|
|
65
|
+
o = { title: o };
|
|
66
|
+
this.#push({ ...(o || {}), type: AlertConfirmPromptType.ALERT });
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Main api.
|
|
70
|
+
*/
|
|
71
|
+
confirm = (onOk, o) => {
|
|
72
|
+
this.#push({ onOk, value: false, ...o, type: AlertConfirmPromptType.CONFIRM });
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Main api.
|
|
76
|
+
*/
|
|
77
|
+
prompt = (onOk, o) => {
|
|
78
|
+
this.#push({ onOk, value: "", ...o, type: AlertConfirmPromptType.PROMPT });
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Sugar helper to monkey patch the native window.alert
|
|
83
|
+
*/
|
|
84
|
+
export function createAlert(acp, defaults) {
|
|
85
|
+
// allowing to add the custom param outside of the native signature
|
|
86
|
+
return (message, o) => new Promise((resolve) => acp.alert({
|
|
87
|
+
...(defaults || {}),
|
|
88
|
+
onOk: () => {
|
|
89
|
+
acp.shift();
|
|
90
|
+
resolve(undefined);
|
|
91
|
+
},
|
|
92
|
+
content: message,
|
|
93
|
+
onEscape: () => {
|
|
94
|
+
acp.shift();
|
|
95
|
+
resolve(undefined);
|
|
96
|
+
},
|
|
97
|
+
...(o || {}),
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Sugar helper to monkey patch the native window.confirm
|
|
102
|
+
*/
|
|
103
|
+
export function createConfirm(acp, defaults) {
|
|
104
|
+
// allowing to add the custom param outside of the native signature
|
|
105
|
+
return (message, o) => new Promise((resolve) => acp.confirm(() => {
|
|
106
|
+
acp.shift();
|
|
107
|
+
resolve(true);
|
|
108
|
+
}, {
|
|
109
|
+
...(defaults || {}),
|
|
110
|
+
content: message,
|
|
111
|
+
onCancel: () => {
|
|
112
|
+
acp.shift();
|
|
113
|
+
resolve(false);
|
|
114
|
+
},
|
|
115
|
+
onEscape: () => {
|
|
116
|
+
acp.shift();
|
|
117
|
+
resolve(false);
|
|
118
|
+
},
|
|
119
|
+
...(o || {}),
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sugar helper to monkey patch the native window.prompt
|
|
124
|
+
*/
|
|
125
|
+
export function createPrompt(acp, defaults) {
|
|
126
|
+
// allowing to add the custom param outside of the native signature
|
|
127
|
+
return (message, defaultValue = "", o) => new Promise((resolve) => acp.prompt((value) => {
|
|
128
|
+
acp.shift();
|
|
129
|
+
resolve(value);
|
|
130
|
+
}, {
|
|
131
|
+
...(defaults || {}),
|
|
132
|
+
content: message,
|
|
133
|
+
value: defaultValue,
|
|
134
|
+
onCancel: () => {
|
|
135
|
+
acp.shift();
|
|
136
|
+
resolve(null);
|
|
137
|
+
},
|
|
138
|
+
onEscape: () => {
|
|
139
|
+
acp.shift();
|
|
140
|
+
resolve(null);
|
|
141
|
+
},
|
|
142
|
+
...(o || {}),
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createTickerRAF } from "@marianmeres/ticker";
|
|
3
|
+
import { onMount } from "svelte";
|
|
4
|
+
|
|
5
|
+
let { class: _class, enabled = true }: { class?: string; enabled?: boolean } = $props();
|
|
6
|
+
|
|
7
|
+
const speed = 250;
|
|
8
|
+
let visible = $state([false, false, false]);
|
|
9
|
+
let i = $state(0);
|
|
10
|
+
|
|
11
|
+
onMount(() => {
|
|
12
|
+
const ticker = createTickerRAF(speed, true);
|
|
13
|
+
const unsub = ticker.subscribe((t) => {
|
|
14
|
+
if (i > visible.length - 1) {
|
|
15
|
+
i = 0;
|
|
16
|
+
visible = visible.map((v) => false);
|
|
17
|
+
} else {
|
|
18
|
+
visible[i] = true;
|
|
19
|
+
i++;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return () => {
|
|
23
|
+
ticker.stop();
|
|
24
|
+
unsub();
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<!-- prettier-ignore -->
|
|
30
|
+
<span class={_class}>
|
|
31
|
+
<span
|
|
32
|
+
class={visible[0] || !enabled ? 'opacity-100' : 'opacity-0'}
|
|
33
|
+
style="transition-duration: {speed}ms;"
|
|
34
|
+
>.</span><span
|
|
35
|
+
class={visible[1] || !enabled ? 'opacity-100' : 'opacity-0'}
|
|
36
|
+
style="transition-duration: {speed}ms;"
|
|
37
|
+
>.</span><span
|
|
38
|
+
class={visible[2] || !enabled ? 'opacity-100' : 'opacity-0'}
|
|
39
|
+
style="transition-duration: {speed}ms;"
|
|
40
|
+
>.</span>
|
|
41
|
+
</span>
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
span span {
|
|
45
|
+
transition-property: opacity;
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AnimatedEllipsis } from "./AnimatedEllipsis.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AnimatedEllipsis } from "./AnimatedEllipsis.svelte";
|