@marianmeres/stuic 1.126.0 → 2.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/README.md +2 -8
  2. package/dist/_shared.css +2 -0
  3. package/dist/actions/autogrow.svelte.d.ts +6 -0
  4. package/dist/actions/autogrow.svelte.js +19 -0
  5. package/dist/actions/highlight-dragover.svelte.d.ts +7 -0
  6. package/dist/actions/highlight-dragover.svelte.js +38 -0
  7. package/dist/actions/index.d.ts +7 -0
  8. package/dist/actions/index.js +7 -0
  9. package/dist/actions/on-submit-validity-check.svelte.d.ts +15 -0
  10. package/dist/actions/on-submit-validity-check.svelte.js +58 -0
  11. package/dist/actions/tooltip/index.css +34 -0
  12. package/dist/actions/tooltip/tooltip.svelte.d.ts +13 -0
  13. package/dist/actions/tooltip/tooltip.svelte.js +203 -0
  14. package/dist/actions/trim.svelte.d.ts +4 -0
  15. package/dist/actions/trim.svelte.js +17 -0
  16. package/dist/actions/{validate.d.ts → validate.svelte.d.ts} +8 -8
  17. package/dist/actions/validate.svelte.js +90 -0
  18. package/dist/components/AlertConfirmPrompt/AlertConfirmPrompt.svelte +59 -385
  19. package/dist/components/AlertConfirmPrompt/AlertConfirmPrompt.svelte.d.ts +9 -101
  20. package/dist/components/AlertConfirmPrompt/Current.svelte +202 -0
  21. package/dist/components/AlertConfirmPrompt/Current.svelte.d.ts +22 -0
  22. package/dist/components/AlertConfirmPrompt/acp-icons.d.ts +7 -2
  23. package/dist/components/AlertConfirmPrompt/acp-icons.js +8 -8
  24. package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.d.ts +63 -0
  25. package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.js +144 -0
  26. package/dist/components/AlertConfirmPrompt/index.d.ts +2 -0
  27. package/dist/components/AlertConfirmPrompt/index.js +2 -0
  28. package/dist/components/AnimatedElipsis/AnimatedEllipsis.svelte +47 -0
  29. package/dist/components/AnimatedElipsis/AnimatedEllipsis.svelte.d.ts +7 -0
  30. package/dist/components/AnimatedElipsis/index.d.ts +1 -0
  31. package/dist/components/AnimatedElipsis/index.js +1 -0
  32. package/dist/components/AppShell/AppShell.svelte +188 -127
  33. package/dist/components/AppShell/AppShell.svelte.d.ts +62 -43
  34. package/dist/components/AppShell/index.d.ts +1 -0
  35. package/dist/components/AppShell/index.js +1 -0
  36. package/dist/components/Backdrop/Backdrop.svelte +149 -49
  37. package/dist/components/Backdrop/Backdrop.svelte.d.ts +22 -37
  38. package/dist/components/Backdrop/index.d.ts +1 -0
  39. package/dist/components/Backdrop/index.js +1 -0
  40. package/dist/components/Button/Button.svelte +122 -146
  41. package/dist/components/Button/Button.svelte.d.ts +22 -80
  42. package/dist/components/Button/index.css +16 -0
  43. package/dist/components/Button/index.d.ts +1 -0
  44. package/dist/components/Button/index.js +1 -0
  45. package/dist/components/ColResize/ColResize.svelte +0 -0
  46. package/dist/components/ColResize/ColResize.svelte.d.ts +26 -0
  47. package/dist/components/ColorScheme/{LocalColorScheme.svelte → ColorSchemeLocal.svelte} +2 -2
  48. package/dist/components/ColorScheme/ColorSchemeLocal.svelte.d.ts +26 -0
  49. package/dist/components/ColorScheme/{SystemAwareColorScheme.svelte → ColorSchemeSystemAware.svelte} +4 -4
  50. package/dist/components/ColorScheme/ColorSchemeSystemAware.svelte.d.ts +26 -0
  51. package/dist/components/ColorScheme/color-scheme.d.ts +26 -8
  52. package/dist/components/ColorScheme/color-scheme.js +40 -16
  53. package/dist/components/ColorScheme/index.d.ts +3 -0
  54. package/dist/components/ColorScheme/index.js +3 -0
  55. package/dist/components/DismissibleMessage/DismissibleMessage.svelte +76 -83
  56. package/dist/components/DismissibleMessage/DismissibleMessage.svelte.d.ts +16 -37
  57. package/dist/components/DismissibleMessage/index.css +13 -0
  58. package/dist/components/DismissibleMessage/index.d.ts +1 -0
  59. package/dist/components/DismissibleMessage/index.js +1 -0
  60. package/dist/components/Drawer/Drawer.svelte +155 -84
  61. package/dist/components/Drawer/Drawer.svelte.d.ts +24 -35
  62. package/dist/components/Drawer/index.d.ts +1 -0
  63. package/dist/components/Drawer/index.js +1 -0
  64. package/dist/components/HoverExpandableWidth/HoverExpandableWidth.svelte +150 -111
  65. package/dist/components/HoverExpandableWidth/HoverExpandableWidth.svelte.d.ts +16 -29
  66. package/dist/components/HoverExpandableWidth/index.d.ts +1 -0
  67. package/dist/components/HoverExpandableWidth/index.js +1 -0
  68. package/dist/components/Input/FieldCheckbox.svelte +174 -132
  69. package/dist/components/Input/FieldCheckbox.svelte.d.ts +28 -64
  70. package/dist/components/Input/FieldFile.svelte +166 -0
  71. package/dist/components/Input/FieldFile.svelte.d.ts +41 -0
  72. package/dist/components/Input/FieldInput.svelte +143 -0
  73. package/dist/components/Input/FieldInput.svelte.d.ts +41 -0
  74. package/dist/components/Input/FieldLikeButton.svelte +206 -0
  75. package/dist/components/Input/FieldLikeButton.svelte.d.ts +41 -0
  76. package/dist/components/Input/FieldOptions.svelte +646 -0
  77. package/dist/components/Input/FieldOptions.svelte.d.ts +58 -0
  78. package/dist/components/Input/FieldRadios.svelte +126 -77
  79. package/dist/components/Input/FieldRadios.svelte.d.ts +23 -61
  80. package/dist/components/Input/FieldSelect.svelte +160 -239
  81. package/dist/components/Input/FieldSelect.svelte.d.ts +40 -88
  82. package/dist/components/Input/FieldSwitch.svelte +132 -0
  83. package/dist/components/Input/FieldSwitch.svelte.d.ts +41 -0
  84. package/dist/components/Input/FieldTextarea.svelte +146 -0
  85. package/dist/components/Input/FieldTextarea.svelte.d.ts +44 -0
  86. package/dist/components/Input/Fieldset.svelte +21 -17
  87. package/dist/components/Input/Fieldset.svelte.d.ts +10 -27
  88. package/dist/components/Input/_internal/FieldRadioInternal.svelte +186 -0
  89. package/dist/components/Input/_internal/FieldRadioInternal.svelte.d.ts +30 -0
  90. package/dist/components/Input/_internal/InputWrap.svelte +216 -0
  91. package/dist/components/Input/_internal/InputWrap.svelte.d.ts +36 -0
  92. package/dist/components/Input/index.css +134 -0
  93. package/dist/components/Input/index.d.ts +11 -0
  94. package/dist/components/Input/index.js +11 -0
  95. package/dist/components/Input/types.d.ts +11 -0
  96. package/dist/components/KbdShortcut/KbdShortcut.svelte +89 -0
  97. package/dist/components/KbdShortcut/KbdShortcut.svelte.d.ts +17 -0
  98. package/dist/components/KbdShortcut/index.d.ts +1 -0
  99. package/dist/components/KbdShortcut/index.js +1 -0
  100. package/dist/components/Modal/Modal.svelte +127 -0
  101. package/dist/components/Modal/Modal.svelte.d.ts +32 -0
  102. package/dist/components/Modal/index.d.ts +1 -0
  103. package/dist/components/Modal/index.js +1 -0
  104. package/dist/components/ModalDialog/ModalDialog.svelte +137 -81
  105. package/dist/components/ModalDialog/ModalDialog.svelte.d.ts +17 -38
  106. package/dist/components/ModalDialog/index.d.ts +1 -0
  107. package/dist/components/ModalDialog/index.js +1 -0
  108. package/dist/components/Notifications/Notifications.svelte +259 -173
  109. package/dist/components/Notifications/Notifications.svelte.d.ts +32 -60
  110. package/dist/components/Notifications/index.css +12 -0
  111. package/dist/components/Notifications/index.d.ts +2 -0
  112. package/dist/components/Notifications/index.js +2 -0
  113. package/dist/components/Notifications/notifications-icons.d.ts +1 -1
  114. package/dist/components/Notifications/notifications-icons.js +4 -4
  115. package/dist/components/Notifications/notifications-stack.svelte.d.ts +89 -0
  116. package/dist/components/Notifications/notifications-stack.svelte.js +161 -0
  117. package/dist/components/Progress/Progress.svelte +26 -0
  118. package/dist/components/Progress/Progress.svelte.d.ts +10 -0
  119. package/dist/components/Progress/_internal/Bar.svelte +31 -0
  120. package/dist/components/Progress/_internal/Bar.svelte.d.ts +10 -0
  121. package/dist/components/Progress/_internal/Circle.svelte +10 -0
  122. package/dist/components/Progress/_internal/Circle.svelte.d.ts +7 -0
  123. package/dist/components/Progress/index.css +7 -0
  124. package/dist/components/Progress/index.d.ts +1 -0
  125. package/dist/components/Progress/index.js +1 -0
  126. package/dist/components/Spinner/Spinner.svelte +56 -41
  127. package/dist/components/Spinner/Spinner.svelte.d.ts +10 -22
  128. package/dist/components/Spinner/index.d.ts +1 -0
  129. package/dist/components/Spinner/index.js +1 -0
  130. package/dist/components/Switch/Switch.svelte +158 -118
  131. package/dist/components/Switch/Switch.svelte.d.ts +25 -66
  132. package/dist/components/Switch/SwitchButton.svelte +131 -0
  133. package/dist/components/Switch/SwitchButton.svelte.d.ts +21 -0
  134. package/dist/components/Switch/index.css +7 -0
  135. package/dist/components/Switch/index.d.ts +2 -0
  136. package/dist/components/Switch/index.js +2 -0
  137. package/dist/components/Thc/Thc.svelte +67 -10
  138. package/dist/components/Thc/Thc.svelte.d.ts +18 -22
  139. package/dist/components/Thc/index.d.ts +1 -0
  140. package/dist/components/Thc/index.js +1 -0
  141. package/dist/components/TwCheck/TwCheck.svelte +34 -0
  142. package/dist/components/TwCheck/TwCheck.svelte.d.ts +10 -0
  143. package/dist/components/TwCheck/index.css +5 -0
  144. package/dist/components/TwCheck/index.d.ts +1 -0
  145. package/dist/components/TwCheck/index.js +1 -0
  146. package/dist/components/X/X.svelte +12 -5
  147. package/dist/components/X/X.svelte.d.ts +6 -18
  148. package/dist/components/X/index.d.ts +1 -0
  149. package/dist/components/X/index.js +1 -0
  150. package/dist/index.css +26 -0
  151. package/dist/index.d.ts +21 -39
  152. package/dist/index.js +23 -54
  153. package/dist/types.d.ts +251 -2
  154. package/dist/types.js +248 -0
  155. package/dist/utils/breakpoint.svelte.d.ts +19 -0
  156. package/dist/utils/breakpoint.svelte.js +42 -0
  157. package/dist/utils/debounce.d.ts +13 -0
  158. package/dist/utils/debounce.js +22 -0
  159. package/dist/utils/device-pointer.svelte.d.ts +11 -0
  160. package/dist/utils/device-pointer.svelte.js +26 -0
  161. package/dist/utils/event-modifiers.d.ts +4 -0
  162. package/dist/utils/event-modifiers.js +29 -0
  163. package/dist/utils/get-id.d.ts +1 -1
  164. package/dist/utils/get-id.js +3 -1
  165. package/dist/utils/index.d.ts +21 -0
  166. package/dist/utils/index.js +21 -0
  167. package/dist/utils/is-browser.d.ts +1 -0
  168. package/dist/utils/is-browser.js +5 -0
  169. package/dist/utils/is-mac.d.ts +1 -0
  170. package/dist/utils/is-mac.js +11 -0
  171. package/dist/utils/maybe-json-parse.d.ts +1 -0
  172. package/dist/utils/maybe-json-parse.js +12 -0
  173. package/dist/utils/maybe-json-stringify.d.ts +1 -0
  174. package/dist/utils/maybe-json-stringify.js +11 -0
  175. package/dist/utils/move-array-item.d.ts +4 -0
  176. package/dist/utils/move-array-item.js +20 -0
  177. package/dist/utils/omit-pick.d.ts +2 -2
  178. package/dist/utils/omit-pick.js +10 -8
  179. package/dist/utils/paint.d.ts +18 -0
  180. package/dist/utils/paint.js +32 -0
  181. package/dist/utils/persistent-state.svelte.d.ts +23 -0
  182. package/dist/utils/persistent-state.svelte.js +48 -0
  183. package/dist/utils/prefers-reduced-motion.svelte.d.ts +2 -0
  184. package/dist/utils/prefers-reduced-motion.svelte.js +4 -0
  185. package/dist/utils/qsa.d.ts +1 -0
  186. package/dist/utils/qsa.js +3 -0
  187. package/dist/utils/sleep.d.ts +28 -0
  188. package/dist/utils/sleep.js +33 -0
  189. package/dist/utils/storage-abstraction.d.ts +35 -0
  190. package/dist/utils/storage-abstraction.js +136 -0
  191. package/dist/utils/str-hash.d.ts +7 -0
  192. package/dist/utils/str-hash.js +35 -0
  193. package/dist/utils/throttle.d.ts +1 -0
  194. package/dist/utils/throttle.js +47 -0
  195. package/dist/utils/to-integer.d.ts +1 -0
  196. package/dist/utils/to-integer.js +11 -0
  197. package/dist/utils/tr.d.ts +5 -0
  198. package/dist/utils/tr.js +13 -0
  199. package/dist/utils/tw-merge.d.ts +10 -0
  200. package/dist/utils/tw-merge.js +16 -0
  201. package/dist/utils/ucfirst.d.ts +1 -0
  202. package/dist/utils/ucfirst.js +6 -0
  203. package/package.json +66 -73
  204. package/dist/actions/autogrow.d.ts +0 -8
  205. package/dist/actions/autogrow.js +0 -22
  206. package/dist/actions/autoscroll.d.ts +0 -21
  207. package/dist/actions/autoscroll.js +0 -60
  208. package/dist/actions/drag-drop.d.ts +0 -28
  209. package/dist/actions/drag-drop.js +0 -152
  210. package/dist/actions/on-outside.d.ts +0 -9
  211. package/dist/actions/on-outside.js +0 -27
  212. package/dist/actions/pre-submit-validity-check.d.ts +0 -3
  213. package/dist/actions/pre-submit-validity-check.js +0 -21
  214. package/dist/actions/tooltip/_make-visible.d.ts +0 -3
  215. package/dist/actions/tooltip/_make-visible.js +0 -25
  216. package/dist/actions/tooltip/_maybe-pick-safe-placement.d.ts +0 -3
  217. package/dist/actions/tooltip/_maybe-pick-safe-placement.js +0 -86
  218. package/dist/actions/tooltip/_set-position.d.ts +0 -2
  219. package/dist/actions/tooltip/_set-position.js +0 -125
  220. package/dist/actions/tooltip/tooltip.d.ts +0 -42
  221. package/dist/actions/tooltip/tooltip.js +0 -299
  222. package/dist/actions/trim.d.ts +0 -4
  223. package/dist/actions/trim.js +0 -18
  224. package/dist/actions/validate.js +0 -80
  225. package/dist/components/AlertConfirmPrompt/alert-confirm-prompt.d.ts +0 -58
  226. package/dist/components/AlertConfirmPrompt/alert-confirm-prompt.js +0 -141
  227. package/dist/components/ColorScheme/LocalColorScheme.svelte.d.ts +0 -25
  228. package/dist/components/ColorScheme/SystemAwareColorScheme.svelte.d.ts +0 -25
  229. package/dist/components/Input/Field.svelte +0 -315
  230. package/dist/components/Input/Field.svelte.d.ts +0 -102
  231. package/dist/components/Input/PinInput.svelte +0 -151
  232. package/dist/components/Input/PinInput.svelte.d.ts +0 -51
  233. package/dist/components/Input/XFieldRadioInternal.svelte +0 -143
  234. package/dist/components/Input/XFieldRadioInternal.svelte.d.ts +0 -45
  235. package/dist/components/Notifications/notifications.d.ts +0 -78
  236. package/dist/components/Notifications/notifications.js +0 -215
  237. package/dist/components/Popover/Popover.svelte +0 -24
  238. package/dist/components/Popover/Popover.svelte.d.ts +0 -22
  239. package/dist/components/Spinner/Spinner.v5.svelte +0 -114
  240. package/dist/components/Spinner/Spinner.v5.svelte.d.ts +0 -16
  241. package/dist/utils/calculate-alignment.d.ts +0 -68
  242. package/dist/utils/calculate-alignment.js +0 -183
  243. package/dist/utils/device-pointer.d.ts +0 -5
  244. package/dist/utils/device-pointer.js +0 -10
  245. package/dist/utils/prefers-reduced-motion.d.ts +0 -6
  246. package/dist/utils/prefers-reduced-motion.js +0 -26
  247. package/dist/utils/tw-merge2.d.ts +0 -3
  248. package/dist/utils/tw-merge2.js +0 -9
  249. package/dist/utils/tw-types.d.ts +0 -1
  250. package/dist/utils/window-size.d.ts +0 -22
  251. package/dist/utils/window-size.js +0 -35
  252. /package/dist/{utils/tw-types.js → components/Input/types.js} +0 -0
@@ -1,182 +1,257 @@
1
- <script context="module">import { createClog } from "@marianmeres/clog";
2
- import { fade } from "svelte/transition";
3
- import { twMerge2 } from "../../utils/tw-merge2.js";
4
- import Thc from "../Thc/Thc.svelte";
5
- import X from "../X/X.svelte";
6
- import { notificationsDefaultIcons } from "./notifications-icons.js";
7
- const X_POSITIONS = ["left", "center", "right"];
8
- const Y_POSITIONS = ["top", "center", "bottom"];
9
- const DEFAULT = {
10
- posX: "right",
11
- posXMobile: "center",
12
- posY: "top",
13
- posYMobile: "bottom"
14
- };
15
- const XMAP = { left: "sm:items-start", center: "sm:items-center", right: "sm:items-end" };
16
- const XMAP_M = { left: "items-start", center: "items-center", right: "items-end" };
17
- const YMAP = { top: "sm:items-start", center: "sm:items-center", bottom: "sm:items-end" };
18
- const YMAP_M = { top: "items-start", center: "items-center", bottom: "items-end" };
19
- export class NotificationsConfig {
20
- static preset = {
21
- wrap: `
22
- fixed z-50
23
- `,
24
- wrapInner: `
25
- p-4 space-y-4
26
- `,
27
- notification: {
28
- box: `
29
- relative flex
30
- pointer-events-auto
31
- w-full max-w-sm
32
- rounded-md
33
- shadow-lg
34
- bg-neutral-700 text-neutral-50
35
- `,
36
- count: `
37
- absolute -top-2 -right-2
38
- w-auto h-auto
39
- flex items-center justify-center
40
- px-2 py-1 rounded-full
41
- leading-none text-xs
42
- bg-neutral-950 text-neutral-50
43
- `,
44
- icon: `
45
- flex items-start justify-center
46
- pt-4 pr-0 pb-4 pl-4
47
- text-neutral-200
48
- `,
49
- content: `
50
- flex-1
51
- flex flex-col justify-center
52
- text-sm
53
- pl-4 pr-1 py-3
54
- `,
55
- button: `
56
- flex flex-col items-center justify-center
57
- leading-none
58
- px-3
59
- hover:bg-neutral-950/20
60
- focus-visible:bg-neutral-950/20 focus-visible:outline-none focus-visible:ring-0
61
- group
62
- rounded-tr-md rounded-br-md
63
- `,
64
- x: `
65
- opacity-75 group-hover:opacity-100
66
- `
67
- }
68
- };
69
- // prettier-ignore
70
- static presetByType = {
71
- info: { box: ``, count: ``, icon: ``, content: ``, button: ``, x: `` },
72
- success: { box: ``, count: ``, icon: ``, content: ``, button: ``, x: `` },
73
- warn: { box: ``, count: ``, icon: ``, content: ``, button: ``, x: `` },
74
- error: { box: `bg-red-700`, count: ``, icon: ``, content: ``, button: ``, x: `` }
75
- };
76
- }
77
- </script>
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
- <script>const clog = createClog("Notifications");
80
- export let notifications;
81
- export let forceAsHtml = void 0;
82
- export let defaultIcons = notificationsDefaultIcons;
83
- export let classes = {};
84
- export let classesByType = {};
85
- export let ariaCloseLabel = "Discard";
86
- export let posX = DEFAULT.posX;
87
- export let posXMobile = DEFAULT.posXMobile;
88
- export let posY = DEFAULT.posY;
89
- export let posYMobile = DEFAULT.posYMobile;
90
- let x, y, xMobile, yMobile;
91
- export function getPositionConfig() {
92
- return {
93
- posX: x,
94
- posY: y,
95
- posXMobile: xMobile,
96
- posYMobile: yMobile
97
- };
98
- }
99
- $:
100
- x = X_POSITIONS.includes(posX) ? posX : DEFAULT.posX;
101
- $:
102
- xMobile = X_POSITIONS.includes(posXMobile) ? posXMobile : DEFAULT.posXMobile;
103
- $:
104
- y = Y_POSITIONS.includes(posY) ? posY : DEFAULT.posY;
105
- $:
106
- yMobile = Y_POSITIONS.includes(posYMobile) ? posYMobile : DEFAULT.posYMobile;
107
- $:
108
- _wrapClass = twMerge2(
109
- NotificationsConfig.preset.wrap,
110
- `flex flex-row inset-0
111
- pointer-events-none bg-transparent`,
112
- YMAP_M[yMobile],
113
- YMAP[y]
114
- );
115
- $:
116
- _wrapInnerClass = twMerge2(
117
- NotificationsConfig.preset.wrapInner,
118
- `flex flex-col w-full
119
- pointer-events-none bg-transparent`,
120
- XMAP_M[xMobile],
121
- XMAP[x]
122
- );
123
- const _collectClasses = (n, k) => [
124
- NotificationsConfig?.preset?.notification?.[k] || "",
125
- classes?.[k] || "",
126
- NotificationsConfig?.presetByType?.[n.type]?.[k] || "",
127
- classesByType?.[n.type]?.[k] || "",
128
- n.class?.[k] || ""
129
- ];
130
- const _boxClass = (n) => twMerge2(..._collectClasses(n, "box"));
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 $notifications.length}
141
- <div class={_wrapClass} aria-live="assertive">
142
- <div class={_wrapInnerClass}>
143
- {#each $notifications as n}
144
- {@const iconFn = _iconFn(n)}
145
- <!-- use your own component -->
146
- {#if n?.component}
147
- <svelte:component
148
- this={n.component.component || n.component}
149
- {...n.component.props || {}}
150
- notification={n}
151
- {notifications}
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
- transition:fade|global={{ duration: 200 }}
160
- class={_boxClass(n)}
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
- on:mouseover={() => notifications.event(n.id, notifications.EVENT.MOUSEOVER)}
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={_countClass(n)}>
237
+ <div class={twMerge("count", _classNotifCount, classNotifCount)}>
171
238
  {n.count}
172
239
  </div>
173
240
  {/if}
174
-
175
- {#if _isFn(iconFn)}
176
- <div class={_iconClass(n)}>{@html iconFn()}</div>
241
+ {#if typeof iconFn === "function"}
242
+ <div class={twMerge("icon", _classNotifIcon, classNotifIcon)}>
243
+ {@html iconFn()}
244
+ </div>
177
245
  {/if}
178
246
 
179
- <div class={_contentClass(n)}>
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
- <button
189
- class={_buttonClass(n)}
190
- aria-label={ariaCloseLabel}
191
- on:click|preventDefault|stopPropagation={() => notifications.remove(n.id)}
192
- >
193
- <X class={_xClass(n)} />
194
- </button>
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 { SvelteComponent } from "svelte";
2
- import type { NotificationKnownClasses, NotificationType, createNotificationsStore } from './notifications.js';
3
- declare const X_POSITIONS: readonly ["left", "center", "right"];
4
- declare const Y_POSITIONS: readonly ["top", "center", "bottom"];
5
- type ArrayElement<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer ArrayElement> ? ArrayElement : never;
6
- export type NOTIFICATIONS_POSX = ArrayElement<typeof X_POSITIONS>;
7
- export type NOTIFICATIONS_POSY = ArrayElement<typeof Y_POSITIONS>;
8
- export declare class NotificationsConfig {
9
- static preset: {
10
- wrap: string;
11
- wrapInner: string;
12
- notification: {
13
- box: string;
14
- count: string;
15
- icon: string;
16
- content: string;
17
- button: string;
18
- x: string;
19
- };
20
- };
21
- static presetByType: Record<NotificationType, NotificationKnownClasses>;
22
- }
23
- declare const __propDef: {
24
- props: {
25
- notifications: ReturnType<typeof createNotificationsStore>;
26
- forceAsHtml?: boolean | undefined;
27
- defaultIcons?: Partial<Record<NotificationType, () => string>>;
28
- classes?: Partial<NotificationKnownClasses>;
29
- classesByType?: Partial<Record<NotificationType, Partial<NotificationKnownClasses>>>;
30
- ariaCloseLabel?: string;
31
- posX?: NOTIFICATIONS_POSX;
32
- posXMobile?: NOTIFICATIONS_POSX;
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
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./notifications-stack.svelte.js";
2
+ export { default as Notifications } from "./Notifications.svelte";
@@ -0,0 +1,2 @@
1
+ export * from "./notifications-stack.svelte.js";
2
+ export { default as Notifications } from "./Notifications.svelte";
@@ -1,2 +1,2 @@
1
- import type { NotificationType } from './notifications.js';
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 '@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';
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({}),