@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,182 +1,257 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import { fade } from "svelte/transition";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fade } from "svelte/transition";
|
|
3
|
+
import type { TW_COLORS } from "../../types.js";
|
|
4
|
+
import { twMerge } from "../../utils/tw-merge.js";
|
|
5
|
+
import Thc from "../Thc/Thc.svelte";
|
|
6
|
+
import X from "../X/X.svelte";
|
|
7
|
+
import { notificationsDefaultIcons } from "./notifications-icons.js";
|
|
8
|
+
import "./index.css";
|
|
9
|
+
import type {
|
|
10
|
+
Notification,
|
|
11
|
+
NotificationsStack,
|
|
12
|
+
NotificationType,
|
|
13
|
+
} from "./notifications-stack.svelte.js";
|
|
14
|
+
import Progress from "../Progress/Progress.svelte";
|
|
15
|
+
|
|
16
|
+
const X_POSITIONS = ["left", "center", "right"] as const;
|
|
17
|
+
const Y_POSITIONS = ["top", "center", "bottom"] as const;
|
|
18
|
+
|
|
19
|
+
type NOTIFICATIONS_POSX = (typeof X_POSITIONS)[number];
|
|
20
|
+
type NOTIFICATIONS_POSY = (typeof Y_POSITIONS)[number];
|
|
21
|
+
|
|
22
|
+
const DEFAULT: {
|
|
23
|
+
posX: NOTIFICATIONS_POSX;
|
|
24
|
+
posXMobile: NOTIFICATIONS_POSX;
|
|
25
|
+
posY: NOTIFICATIONS_POSY;
|
|
26
|
+
posYMobile: NOTIFICATIONS_POSY;
|
|
27
|
+
} = {
|
|
28
|
+
posX: "right",
|
|
29
|
+
posXMobile: "center",
|
|
30
|
+
posY: "top",
|
|
31
|
+
posYMobile: "bottom",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// prettier-ignore
|
|
35
|
+
const XMAP = { left: 'sm:justify-start', center: 'sm:justify-center', right: 'sm:justify-end' };
|
|
36
|
+
// prettier-ignore
|
|
37
|
+
const XMAP_M = { left: 'justify-start', center: 'justify-center', right: 'justify-end' };
|
|
38
|
+
|
|
39
|
+
// prettier-ignore
|
|
40
|
+
const YMAP = { top: 'sm:justify-start', center: 'sm:justify-center', bottom: 'sm:justify-end' };
|
|
41
|
+
// prettier-ignore
|
|
42
|
+
const YMAP_M = { top: 'justify-start', center: 'justify-center', bottom: 'justify-end' };
|
|
43
|
+
|
|
44
|
+
interface Props {
|
|
45
|
+
notifications: NotificationsStack;
|
|
46
|
+
// right|center|left
|
|
47
|
+
posX?: NOTIFICATIONS_POSX;
|
|
48
|
+
posXMobile?: NOTIFICATIONS_POSX;
|
|
49
|
+
// top|center|bottom
|
|
50
|
+
posY?: NOTIFICATIONS_POSY;
|
|
51
|
+
posYMobile?: NOTIFICATIONS_POSY;
|
|
52
|
+
//
|
|
53
|
+
themeInfo?: TW_COLORS;
|
|
54
|
+
themeError?: TW_COLORS;
|
|
55
|
+
themeWarn?: TW_COLORS;
|
|
56
|
+
themeSuccess?: TW_COLORS;
|
|
57
|
+
noTheme?: boolean;
|
|
58
|
+
//
|
|
59
|
+
classWrapY?: string;
|
|
60
|
+
classWrapX?: string;
|
|
61
|
+
class?: string; // classNotifBox
|
|
62
|
+
classNotifCount?: string;
|
|
63
|
+
classNotifIcon?: string;
|
|
64
|
+
classNotifContent?: string;
|
|
65
|
+
classNotifButton?: string;
|
|
66
|
+
classNotifButtonX?: string;
|
|
67
|
+
//
|
|
68
|
+
classProgress?: string;
|
|
69
|
+
classProgressBar?: string;
|
|
70
|
+
//
|
|
71
|
+
forceAsHtml?: boolean;
|
|
72
|
+
ariaCloseLabel?: string;
|
|
73
|
+
duration?: number;
|
|
74
|
+
//
|
|
75
|
+
noProgress?: boolean;
|
|
76
|
+
noXButton?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let {
|
|
80
|
+
notifications,
|
|
81
|
+
//
|
|
82
|
+
posX = DEFAULT.posX,
|
|
83
|
+
posXMobile = DEFAULT.posXMobile,
|
|
84
|
+
//
|
|
85
|
+
posY = DEFAULT.posY,
|
|
86
|
+
posYMobile = DEFAULT.posYMobile,
|
|
87
|
+
//
|
|
88
|
+
themeInfo = "neutral",
|
|
89
|
+
themeError = "red",
|
|
90
|
+
themeWarn = "yellow",
|
|
91
|
+
themeSuccess = "green",
|
|
92
|
+
// use truthy `noTheme` if manual css-only var customization is needed
|
|
93
|
+
noTheme,
|
|
94
|
+
//
|
|
95
|
+
classWrapY,
|
|
96
|
+
classWrapX,
|
|
97
|
+
class: classNotifBox,
|
|
98
|
+
classNotifCount,
|
|
99
|
+
classNotifIcon,
|
|
100
|
+
classNotifContent,
|
|
101
|
+
classNotifButton,
|
|
102
|
+
classNotifButtonX,
|
|
103
|
+
//
|
|
104
|
+
classProgress,
|
|
105
|
+
classProgressBar,
|
|
106
|
+
//
|
|
107
|
+
forceAsHtml,
|
|
108
|
+
ariaCloseLabel = "Close",
|
|
109
|
+
duration = 200,
|
|
110
|
+
noProgress,
|
|
111
|
+
noXButton,
|
|
112
|
+
}: Props = $props();
|
|
113
|
+
|
|
114
|
+
let { x, y, xMobile, yMobile } = $derived.by(() => {
|
|
115
|
+
const x = X_POSITIONS.includes(posX) ? posX : DEFAULT.posX;
|
|
116
|
+
const xMobile = X_POSITIONS.includes(posXMobile) ? posXMobile : DEFAULT.posXMobile;
|
|
117
|
+
const y = Y_POSITIONS.includes(posY) ? posY : DEFAULT.posY;
|
|
118
|
+
const yMobile = Y_POSITIONS.includes(posYMobile) ? posYMobile : DEFAULT.posYMobile;
|
|
119
|
+
return { x, y, xMobile, yMobile };
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const maybeComponent = (n: Notification): { Cmp: any; props: any } => {
|
|
123
|
+
// todo when needed
|
|
124
|
+
return { Cmp: null, props: null };
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const maybeIcon = (n: Notification) => n.iconFn ?? notificationsDefaultIcons?.[n.type];
|
|
128
|
+
|
|
129
|
+
const _classWrapX = `
|
|
130
|
+
fixed z-50 flex flex-row inset-0
|
|
131
|
+
pointer-events-none bg-transparent`;
|
|
132
|
+
|
|
133
|
+
const _classWrapY = `
|
|
134
|
+
p-4 space-y-4
|
|
135
|
+
flex flex-col inset-0
|
|
136
|
+
pointer-events-none bg-transparent`;
|
|
137
|
+
|
|
138
|
+
const _classNotifBox = `
|
|
139
|
+
relative flex
|
|
140
|
+
pointer-events-auto
|
|
141
|
+
w-xs sm:w-sm max-w-sm
|
|
142
|
+
rounded-lg
|
|
143
|
+
shadow-lg
|
|
144
|
+
border border-notif-border dark:border-notif-border-dark
|
|
145
|
+
bg-notif-bg text-notif-text
|
|
146
|
+
dark:bg-notif-bg-dark dark:text-notif-text-dark`;
|
|
78
147
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
];
|
|
130
|
-
|
|
131
|
-
const _countClass = (n) => twMerge2(..._collectClasses(n, "count"));
|
|
132
|
-
const _iconClass = (n) => twMerge2(..._collectClasses(n, "icon"));
|
|
133
|
-
const _contentClass = (n) => twMerge2(..._collectClasses(n, "content"));
|
|
134
|
-
const _buttonClass = (n) => twMerge2(..._collectClasses(n, "button"));
|
|
135
|
-
const _xClass = (n) => twMerge2(..._collectClasses(n, "x"));
|
|
136
|
-
const _iconFn = (o) => o.iconFn ?? defaultIcons?.[o.type];
|
|
137
|
-
const _isFn = (v) => typeof v === "function";
|
|
148
|
+
const _classNotifCount = `
|
|
149
|
+
absolute -top-2 -right-2
|
|
150
|
+
w-auto h-auto
|
|
151
|
+
flex items-center justify-center
|
|
152
|
+
px-2 py-1 rounded-full
|
|
153
|
+
leading-none text-xs
|
|
154
|
+
bg-neutral-950 text-neutral-50`;
|
|
155
|
+
|
|
156
|
+
const _classNotifIcon = `
|
|
157
|
+
flex items-start justify-center
|
|
158
|
+
pt-4 pr-0 pb-4 pl-4
|
|
159
|
+
text-neutral-200`;
|
|
160
|
+
|
|
161
|
+
const _classNotifContent = `
|
|
162
|
+
flex-1
|
|
163
|
+
flex flex-col justify-center
|
|
164
|
+
text-sm tracking-tight
|
|
165
|
+
pl-4 pr-1 py-3`;
|
|
166
|
+
|
|
167
|
+
const _classNotifButton = `
|
|
168
|
+
flex flex-col items-center justify-center
|
|
169
|
+
leading-none
|
|
170
|
+
px-3
|
|
171
|
+
hover:bg-neutral-950/10
|
|
172
|
+
focus-visible:bg-neutral-950/10 focus-visible:outline-none focus-visible:ring-0
|
|
173
|
+
group
|
|
174
|
+
rounded-tr-md rounded-br-md`;
|
|
175
|
+
|
|
176
|
+
const _classNotifButtonX = `opacity-75 group-hover:opacity-100`;
|
|
177
|
+
|
|
178
|
+
const _classProgress = `absolute inset-0 size-full bg-transparent rounded-tl-md rounded-bl-md`;
|
|
179
|
+
const _classProgressBar = `bg-white/10 dark:bg-white/10 size-full rounded-tl-md rounded-bl-md`;
|
|
180
|
+
|
|
181
|
+
const _buildTheme = (type: NotificationType) => {
|
|
182
|
+
if (noTheme) return "";
|
|
183
|
+
let theme =
|
|
184
|
+
{
|
|
185
|
+
info: themeInfo,
|
|
186
|
+
error: themeError,
|
|
187
|
+
success: themeSuccess,
|
|
188
|
+
warn: themeWarn,
|
|
189
|
+
}[type] || "info";
|
|
190
|
+
return [
|
|
191
|
+
`--color-notif-bg: var(--color-${theme}-700);`,
|
|
192
|
+
`--color-notif-text: var(--color-${theme}-50);`,
|
|
193
|
+
`--color-notif-border: var(--color-${theme}-800);`,
|
|
194
|
+
//
|
|
195
|
+
`--color-notif-bg-dark: var(--color-${theme}-800);`,
|
|
196
|
+
`--color-notif-text-dark: var(--color-${theme}-200);`,
|
|
197
|
+
`--color-notif-border-dark: var(--color-${theme}-700);`,
|
|
198
|
+
].join("");
|
|
199
|
+
};
|
|
138
200
|
</script>
|
|
139
201
|
|
|
140
|
-
{#if
|
|
141
|
-
<div
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
202
|
+
{#if notifications.stack.length}
|
|
203
|
+
<div
|
|
204
|
+
aria-live="assertive"
|
|
205
|
+
class={twMerge(
|
|
206
|
+
"stuic-notifs wrap-x",
|
|
207
|
+
_classWrapX,
|
|
208
|
+
XMAP[x],
|
|
209
|
+
XMAP_M[xMobile],
|
|
210
|
+
classWrapX
|
|
211
|
+
)}
|
|
212
|
+
>
|
|
213
|
+
<div class={twMerge("wrap-y", _classWrapY, YMAP_M[yMobile], YMAP[y], classWrapY)}>
|
|
214
|
+
{#each notifications.stack as n (n.id)}
|
|
215
|
+
{@const { Cmp, props } = maybeComponent(n)}
|
|
216
|
+
{@const iconFn = maybeIcon(n)}
|
|
217
|
+
{@const showXButton = !noXButton || n.ttl > 1000}
|
|
218
|
+
{#if Cmp}
|
|
219
|
+
<Cmp {...props || {}} notification={n} {notifications} />
|
|
153
220
|
{:else}
|
|
154
|
-
<!-- svelte-ignore
|
|
155
|
-
a11y-click-events-have-key-events
|
|
156
|
-
a11y-no-noninteractive-element-interactions
|
|
157
|
-
a11y-mouse-events-have-key-events -->
|
|
158
221
|
<div
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
class:cursor-pointer={typeof n.onClick === 'function'}
|
|
162
|
-
data-notification-type={n.type}
|
|
163
|
-
data-notification-multiple={n.count > 1 ? true : undefined}
|
|
222
|
+
class={twMerge("box", _classNotifBox, classNotifBox)}
|
|
223
|
+
transition:fade|global={{ duration }}
|
|
164
224
|
role="alert"
|
|
165
|
-
|
|
166
|
-
on:mouseout={() => notifications.event(n.id, notifications.EVENT.MOUSEOUT)}
|
|
167
|
-
on:click={() => notifications.event(n.id, notifications.EVENT.CLICK)}
|
|
225
|
+
style={_buildTheme(n.type)}
|
|
168
226
|
>
|
|
227
|
+
{#if n.ttl && !noProgress}
|
|
228
|
+
<Progress
|
|
229
|
+
progress={100 - n._ttlProgress * 100}
|
|
230
|
+
class={twMerge(_classProgress, classProgress)}
|
|
231
|
+
classBar={twMerge(_classProgressBar, classProgressBar)}
|
|
232
|
+
styleBar="transition-duration: {notifications.options.disposeInterval}ms;"
|
|
233
|
+
/>
|
|
234
|
+
{/if}
|
|
235
|
+
|
|
169
236
|
{#if n.count > 1}
|
|
170
|
-
<div class={
|
|
237
|
+
<div class={twMerge("count", _classNotifCount, classNotifCount)}>
|
|
171
238
|
{n.count}
|
|
172
239
|
</div>
|
|
173
240
|
{/if}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
241
|
+
{#if typeof iconFn === "function"}
|
|
242
|
+
<div class={twMerge("icon", _classNotifIcon, classNotifIcon)}>
|
|
243
|
+
{@html iconFn()}
|
|
244
|
+
</div>
|
|
177
245
|
{/if}
|
|
178
246
|
|
|
179
|
-
<div
|
|
247
|
+
<div
|
|
248
|
+
class={twMerge(
|
|
249
|
+
"content",
|
|
250
|
+
_classNotifContent,
|
|
251
|
+
classNotifContent,
|
|
252
|
+
!showXButton && "pr-4"
|
|
253
|
+
)}
|
|
254
|
+
>
|
|
180
255
|
<Thc
|
|
181
256
|
thc={n.content}
|
|
182
257
|
forceAsHtml={n.forceAsHtml ?? forceAsHtml}
|
|
@@ -185,13 +260,24 @@ const _isFn = (v) => typeof v === "function";
|
|
|
185
260
|
/>
|
|
186
261
|
</div>
|
|
187
262
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
263
|
+
{#if showXButton}
|
|
264
|
+
<button
|
|
265
|
+
type="button"
|
|
266
|
+
class={twMerge("button", _classNotifButton, classNotifButton)}
|
|
267
|
+
aria-label={ariaCloseLabel}
|
|
268
|
+
onclick={(e) => {
|
|
269
|
+
e.preventDefault();
|
|
270
|
+
e.stopPropagation();
|
|
271
|
+
e.stopImmediatePropagation();
|
|
272
|
+
notifications.removeById(n.id);
|
|
273
|
+
}}
|
|
274
|
+
>
|
|
275
|
+
<X
|
|
276
|
+
class={twMerge("x", _classNotifButtonX, classNotifButtonX)}
|
|
277
|
+
strokeWidth={1.5}
|
|
278
|
+
/>
|
|
279
|
+
</button>
|
|
280
|
+
{/if}
|
|
195
281
|
</div>
|
|
196
282
|
{/if}
|
|
197
283
|
{/each}
|
|
@@ -1,60 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
declare const
|
|
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
|
-
posY?: NOTIFICATIONS_POSY;
|
|
34
|
-
posYMobile?: NOTIFICATIONS_POSY;
|
|
35
|
-
getPositionConfig?: () => {
|
|
36
|
-
posX: "center" | "left" | "right";
|
|
37
|
-
posY: "center" | "top" | "bottom";
|
|
38
|
-
posXMobile: "center" | "left" | "right";
|
|
39
|
-
posYMobile: "center" | "top" | "bottom";
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
events: {
|
|
43
|
-
[evt: string]: CustomEvent<any>;
|
|
44
|
-
};
|
|
45
|
-
slots: {};
|
|
46
|
-
exports?: {} | undefined;
|
|
47
|
-
bindings?: string | undefined;
|
|
48
|
-
};
|
|
49
|
-
export type NotificationsProps = typeof __propDef.props;
|
|
50
|
-
export type NotificationsEvents = typeof __propDef.events;
|
|
51
|
-
export type NotificationsSlots = typeof __propDef.slots;
|
|
52
|
-
export default class Notifications extends SvelteComponent<NotificationsProps, NotificationsEvents, NotificationsSlots> {
|
|
53
|
-
get getPositionConfig(): () => {
|
|
54
|
-
posX: "center" | "left" | "right";
|
|
55
|
-
posY: "center" | "top" | "bottom";
|
|
56
|
-
posXMobile: "center" | "left" | "right";
|
|
57
|
-
posYMobile: "center" | "top" | "bottom";
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export {};
|
|
1
|
+
import type { TW_COLORS } from "../../types.js";
|
|
2
|
+
import "./index.css";
|
|
3
|
+
import type { NotificationsStack } from "./notifications-stack.svelte.js";
|
|
4
|
+
declare const Notifications: import("svelte").Component<{
|
|
5
|
+
notifications: NotificationsStack;
|
|
6
|
+
posX?: "center" | "left" | "right";
|
|
7
|
+
posXMobile?: "center" | "left" | "right";
|
|
8
|
+
posY?: "center" | "top" | "bottom";
|
|
9
|
+
posYMobile?: "center" | "top" | "bottom";
|
|
10
|
+
themeInfo?: TW_COLORS;
|
|
11
|
+
themeError?: TW_COLORS;
|
|
12
|
+
themeWarn?: TW_COLORS;
|
|
13
|
+
themeSuccess?: TW_COLORS;
|
|
14
|
+
noTheme?: boolean;
|
|
15
|
+
classWrapY?: string;
|
|
16
|
+
classWrapX?: string;
|
|
17
|
+
class?: string;
|
|
18
|
+
classNotifCount?: string;
|
|
19
|
+
classNotifIcon?: string;
|
|
20
|
+
classNotifContent?: string;
|
|
21
|
+
classNotifButton?: string;
|
|
22
|
+
classNotifButtonX?: string;
|
|
23
|
+
classProgress?: string;
|
|
24
|
+
classProgressBar?: string;
|
|
25
|
+
forceAsHtml?: boolean;
|
|
26
|
+
ariaCloseLabel?: string;
|
|
27
|
+
duration?: number;
|
|
28
|
+
noProgress?: boolean;
|
|
29
|
+
noXButton?: boolean;
|
|
30
|
+
}, {}, "">;
|
|
31
|
+
type Notifications = ReturnType<typeof Notifications>;
|
|
32
|
+
export default Notifications;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@import "../../_shared.css";
|
|
2
|
+
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
@theme inline {
|
|
5
|
+
--color-notif-bg: var(--color-notif-bg, var(--color-neutral-700));
|
|
6
|
+
--color-notif-text: var(--color-notif-text, var(--color-neutral-50));
|
|
7
|
+
--color-notif-border: var(--color-notif-border, var(--color-neutral-900));
|
|
8
|
+
|
|
9
|
+
--color-notif-bg-dark: var(--color-notif-bg-dark, var(--color-neutral-950));
|
|
10
|
+
--color-notif-text-dark: var(--color-notif-text-dark, var(--color-neutral-200));
|
|
11
|
+
--color-notif-border-dark: var(--color-notif-border-dark, var(--color-neutral-500));
|
|
12
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { NotificationType } from
|
|
1
|
+
import type { NotificationType } from "./notifications-stack.svelte.js";
|
|
2
2
|
export declare const notificationsDefaultIcons: Record<NotificationType, () => string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iconFeatherAlertTriangle } from
|
|
2
|
-
import { iconFeatherCheckCircle } from
|
|
3
|
-
import { iconFeatherInfo } from
|
|
4
|
-
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 { iconFeatherXOctagon } from "@marianmeres/icons-fns/feather/iconFeatherXOctagon.js";
|
|
5
5
|
export const notificationsDefaultIcons = {
|
|
6
6
|
info: () => iconFeatherInfo({}),
|
|
7
7
|
success: () => iconFeatherCheckCircle({}),
|