@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
@@ -0,0 +1,41 @@
1
+ import type { Snippet } from "svelte";
2
+ import { type ValidateOptions } from "../../actions/validate.svelte.js";
3
+ import type { THC } from "../Thc/Thc.svelte";
4
+ type SnippetWithId = Snippet<[{
5
+ id: string;
6
+ }]>;
7
+ interface Props extends Record<string, any> {
8
+ input?: HTMLInputElement;
9
+ checked?: boolean;
10
+ label?: SnippetWithId | THC;
11
+ description?: SnippetWithId | THC;
12
+ class?: string;
13
+ id?: string;
14
+ tabindex?: number;
15
+ renderSize?: "sm" | "md" | "lg" | string;
16
+ useTrim?: boolean;
17
+ name?: string;
18
+ required?: boolean;
19
+ disabled?: boolean;
20
+ validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
21
+ labelAfter?: SnippetWithId | THC;
22
+ inputBefore?: SnippetWithId | THC;
23
+ inputAfter?: SnippetWithId | THC;
24
+ inputBelow?: SnippetWithId | THC;
25
+ below?: SnippetWithId | THC;
26
+ labelLeft?: boolean;
27
+ labelLeftWidth?: "normal" | "wide";
28
+ labelLeftBreakpoint?: number;
29
+ classInput?: string;
30
+ classLabel?: string;
31
+ classLabelBox?: string;
32
+ classInputBox?: string;
33
+ classInputBoxWrap?: string;
34
+ classDescBox?: string;
35
+ classBelowBox?: string;
36
+ style?: string;
37
+ renderValue?: (rawValue: any) => string;
38
+ }
39
+ declare const FieldSwitch: import("svelte").Component<Props, {}, "input" | "checked">;
40
+ type FieldSwitch = ReturnType<typeof FieldSwitch>;
41
+ export default FieldSwitch;
@@ -0,0 +1,146 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ import type { HTMLInputAttributes, HTMLTextareaAttributes } from "svelte/elements";
4
+ import { trim } from "../../actions/trim.svelte.js";
5
+ import {
6
+ validate as validateAction,
7
+ type ValidateOptions,
8
+ type ValidationResult,
9
+ } from "../../actions/validate.svelte.js";
10
+ import { getId } from "../../utils/get-id.js";
11
+ import { twMerge } from "../../utils/tw-merge.js";
12
+ import type { THC } from "../Thc/Thc.svelte";
13
+ import InputWrap from "./_internal/InputWrap.svelte";
14
+ import { autogrow } from "../../actions/autogrow.svelte.js";
15
+
16
+ type SnippetWithId = Snippet<[{ id: string }]>;
17
+
18
+ interface Props extends HTMLTextareaAttributes {
19
+ input?: HTMLTextAreaElement;
20
+ value?: string; // badInput
21
+ label?: SnippetWithId | THC;
22
+ description?: SnippetWithId | THC;
23
+ class?: string;
24
+ id?: string;
25
+ tabindex?: number; // tooShort
26
+ renderSize?: "sm" | "md" | "lg" | string;
27
+ useTrim?: boolean;
28
+ useAutogrow?: boolean | { enabled?: boolean; max?: number };
29
+ //
30
+ required?: boolean;
31
+ disabled?: boolean;
32
+ //
33
+ validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
34
+ // wrap snippets
35
+ labelAfter?: SnippetWithId | THC;
36
+ inputBefore?: SnippetWithId | THC;
37
+ inputAfter?: SnippetWithId | THC;
38
+ inputBelow?: SnippetWithId | THC;
39
+ below?: SnippetWithId | THC;
40
+ //
41
+ labelLeft?: boolean;
42
+ labelLeftWidth?: "normal" | "wide";
43
+ labelLeftBreakpoint?: number;
44
+ //
45
+ classInput?: string;
46
+ classLabel?: string;
47
+ classLabelBox?: string;
48
+ classInputBox?: string;
49
+ classInputBoxWrap?: string;
50
+ classDescBox?: string;
51
+ classBelowBox?: string;
52
+ style?: string;
53
+ }
54
+
55
+ let {
56
+ input = $bindable(),
57
+ value = $bindable(),
58
+ label = "",
59
+ id = getId(),
60
+ tabindex = 0,
61
+ description,
62
+ class: classProp,
63
+ renderSize = "md",
64
+ useTrim = true,
65
+ useAutogrow = true,
66
+ //
67
+ required = false,
68
+ disabled = false,
69
+ //
70
+ validate,
71
+ //
72
+ labelAfter,
73
+ inputBefore,
74
+ inputAfter,
75
+ inputBelow,
76
+ below,
77
+ //
78
+ labelLeft = false,
79
+ labelLeftWidth = "normal",
80
+ labelLeftBreakpoint = 480,
81
+ //
82
+ classInput,
83
+ classLabel,
84
+ classLabelBox,
85
+ classInputBox,
86
+ classInputBoxWrap,
87
+ classDescBox,
88
+ classBelowBox,
89
+ style,
90
+ //
91
+ ...rest
92
+ }: Props = $props();
93
+
94
+ //
95
+ let validation: ValidationResult | undefined = $state();
96
+ const setValidationResult = (res: ValidationResult) => (validation = res);
97
+ </script>
98
+
99
+ <InputWrap
100
+ {description}
101
+ class={classProp}
102
+ size={renderSize}
103
+ {id}
104
+ {label}
105
+ {labelAfter}
106
+ {inputBefore}
107
+ {inputAfter}
108
+ {below}
109
+ {required}
110
+ {disabled}
111
+ {labelLeft}
112
+ {labelLeftWidth}
113
+ {labelLeftBreakpoint}
114
+ {classLabel}
115
+ {classLabelBox}
116
+ {classInputBox}
117
+ {classInputBoxWrap}
118
+ {classDescBox}
119
+ {classBelowBox}
120
+ {validation}
121
+ {style}
122
+ >
123
+ <textarea
124
+ bind:value
125
+ bind:this={input}
126
+ {id}
127
+ class={twMerge("form-input min-h-16", renderSize, classInput)}
128
+ use:trim={() => ({
129
+ enabled: useTrim,
130
+ setValue: (v: string) => (value = v),
131
+ })}
132
+ use:validateAction={() => ({
133
+ enabled: !!validate,
134
+ ...(typeof validate === "boolean" ? {} : validate),
135
+ setValidationResult,
136
+ })}
137
+ use:autogrow={() => ({
138
+ enabled: !!useAutogrow,
139
+ ...(typeof useAutogrow === "boolean" ? {} : useAutogrow),
140
+ })}
141
+ {tabindex}
142
+ {required}
143
+ {disabled}
144
+ {...rest}
145
+ ></textarea>
146
+ </InputWrap>
@@ -0,0 +1,44 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLTextareaAttributes } from "svelte/elements";
3
+ import { type ValidateOptions } from "../../actions/validate.svelte.js";
4
+ import type { THC } from "../Thc/Thc.svelte";
5
+ type SnippetWithId = Snippet<[{
6
+ id: string;
7
+ }]>;
8
+ interface Props extends HTMLTextareaAttributes {
9
+ input?: HTMLTextAreaElement;
10
+ value?: string;
11
+ label?: SnippetWithId | THC;
12
+ description?: SnippetWithId | THC;
13
+ class?: string;
14
+ id?: string;
15
+ tabindex?: number;
16
+ renderSize?: "sm" | "md" | "lg" | string;
17
+ useTrim?: boolean;
18
+ useAutogrow?: boolean | {
19
+ enabled?: boolean;
20
+ max?: number;
21
+ };
22
+ required?: boolean;
23
+ disabled?: boolean;
24
+ validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
25
+ labelAfter?: SnippetWithId | THC;
26
+ inputBefore?: SnippetWithId | THC;
27
+ inputAfter?: SnippetWithId | THC;
28
+ inputBelow?: SnippetWithId | THC;
29
+ below?: SnippetWithId | THC;
30
+ labelLeft?: boolean;
31
+ labelLeftWidth?: "normal" | "wide";
32
+ labelLeftBreakpoint?: number;
33
+ classInput?: string;
34
+ classLabel?: string;
35
+ classLabelBox?: string;
36
+ classInputBox?: string;
37
+ classInputBoxWrap?: string;
38
+ classDescBox?: string;
39
+ classBelowBox?: string;
40
+ style?: string;
41
+ }
42
+ declare const FieldTextarea: import("svelte").Component<Props, {}, "value" | "input">;
43
+ type FieldTextarea = ReturnType<typeof FieldTextarea>;
44
+ export default FieldTextarea;
@@ -1,25 +1,29 @@
1
- <script context="module">import { twMerge2 } from "../../utils/tw-merge2.js";
2
- import Thc from "../Thc/Thc.svelte";
3
- const _PRESET = {
4
- box: `border border-neutral-200 p-4 pt-3 rounded-md`,
5
- legend: `px-2`
6
- };
7
- export class FieldsetConfig {
8
- static class = {};
9
- }
10
- </script>
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ import type { THC } from "../Thc/Thc.svelte";
4
+ import Thc from "../Thc/Thc.svelte";
5
+ import { twMerge } from "../../utils/tw-merge.js";
11
6
 
12
- <script>let _class = {};
13
- export { _class as class };
14
- export let legend = "";
15
- const _collectClasses = (k, extra = "") => [_PRESET?.[k] || "", FieldsetConfig?.class?.[k] || "", _class?.[k] || ""].join(" ");
7
+ interface Props {
8
+ legend?: THC;
9
+ class?: string;
10
+ classLegend?: string;
11
+ children?: Snippet;
12
+ }
13
+ let { legend, class: classProp, children, classLegend }: Props = $props();
16
14
  </script>
17
15
 
18
- <fieldset class={twMerge2(_collectClasses('box'))}>
16
+ <fieldset
17
+ class={twMerge(
18
+ "stuic-fieldset",
19
+ "border border-neutral-300 p-4 pt-3 rounded-md my-8",
20
+ classProp
21
+ )}
22
+ >
19
23
  {#if legend}
20
- <legend class={twMerge2(_collectClasses('legend'))}>
24
+ <legend class={twMerge("px-2", classLegend)}>
21
25
  <Thc thc={legend} forceAsHtml />
22
26
  </legend>
23
27
  {/if}
24
- <slot />
28
+ {@render children?.()}
25
29
  </fieldset>
@@ -1,28 +1,11 @@
1
- import { SvelteComponent } from "svelte";
2
- export interface FieldsetConfigClasses {
3
- box?: string;
4
- legend?: string;
1
+ import type { Snippet } from "svelte";
2
+ import type { THC } from "../Thc/Thc.svelte";
3
+ interface Props {
4
+ legend?: THC;
5
+ class?: string;
6
+ classLegend?: string;
7
+ children?: Snippet;
5
8
  }
6
- export declare class FieldsetConfig {
7
- static class: FieldsetConfigClasses;
8
- }
9
- declare const __propDef: {
10
- props: {
11
- class?: FieldsetConfigClasses;
12
- legend?: string;
13
- };
14
- events: {
15
- [evt: string]: CustomEvent<any>;
16
- };
17
- slots: {
18
- default: {};
19
- };
20
- exports?: {} | undefined;
21
- bindings?: string | undefined;
22
- };
23
- export type FieldsetProps = typeof __propDef.props;
24
- export type FieldsetEvents = typeof __propDef.events;
25
- export type FieldsetSlots = typeof __propDef.slots;
26
- export default class Fieldset extends SvelteComponent<FieldsetProps, FieldsetEvents, FieldsetSlots> {
27
- }
28
- export {};
9
+ declare const Fieldset: import("svelte").Component<Props, {}, "">;
10
+ type Fieldset = ReturnType<typeof Fieldset>;
11
+ export default Fieldset;
@@ -0,0 +1,186 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ import type { THC } from "../../Thc/Thc.svelte";
4
+ import {
5
+ validate as validateAction,
6
+ type ValidateOptions,
7
+ type ValidationResult,
8
+ } from "../../../actions/validate.svelte.js";
9
+ import type { HTMLInputAttributes } from "svelte/elements";
10
+ import { getId } from "../../../utils/get-id.js";
11
+ import { twMerge } from "../../../utils/tw-merge.js";
12
+ import Thc, { isTHCNotEmpty } from "../../Thc/Thc.svelte";
13
+
14
+ type SnippetWithId = Snippet<[{ id: string }]>;
15
+
16
+ interface Props extends HTMLInputAttributes {
17
+ input?: HTMLInputElement;
18
+ group?: string;
19
+ label?: SnippetWithId | THC;
20
+ name?: string;
21
+ value?: string;
22
+ required?: boolean;
23
+ disabled?: boolean;
24
+ renderSize?: "sm" | "md" | "lg" | string;
25
+ description?: SnippetWithId | THC;
26
+ //
27
+ validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
28
+ //
29
+ classRadioBox?: string;
30
+ classInputBox?: string;
31
+ classInput?: string;
32
+ classLabelBox?: string;
33
+ classLabel?: string;
34
+ classDescBox?: string;
35
+ classValidationBox?: string;
36
+ //
37
+ validation: ValidationResult | undefined;
38
+ }
39
+
40
+ let {
41
+ input = $bindable(),
42
+ group = $bindable(),
43
+ value,
44
+ label,
45
+ name,
46
+ required,
47
+ disabled,
48
+ description,
49
+ renderSize,
50
+ tabindex,
51
+ validate,
52
+ classRadioBox,
53
+ classInputBox,
54
+ classInput,
55
+ classLabelBox,
56
+ classLabel,
57
+ classDescBox,
58
+ classValidationBox,
59
+ validation = $bindable(),
60
+ ...rest
61
+ }: Props = $props();
62
+
63
+ //
64
+ // let validation: ValidationResult | undefined = $state();
65
+ const setValidationResult = (res: ValidationResult) => (validation = res);
66
+
67
+ //
68
+ let invalid = $derived(validation && !validation?.valid);
69
+ let id = getId();
70
+ let idDesc = getId();
71
+
72
+ //
73
+ let _classCommon = $derived(
74
+ [invalid && "invalid", disabled && "disabled", renderSize].filter(Boolean).join(" ")
75
+ );
76
+
77
+ const _preset = {
78
+ labelBox: {
79
+ label: {
80
+ size: {
81
+ sm: "text-sm mt-0.5",
82
+ lg: "font-semibold",
83
+ } as any,
84
+ },
85
+ },
86
+ };
87
+ </script>
88
+
89
+ {#snippet snippetOrThc({ id, value }: { id: string; value?: SnippetWithId | THC })}
90
+ {#if typeof value === "function"}
91
+ {@render value({ id })}
92
+ {:else if value}
93
+ <Thc thc={value} forceAsHtml />
94
+ {/if}
95
+ {/snippet}
96
+
97
+ <label
98
+ class={twMerge(
99
+ "radio-box",
100
+ _classCommon,
101
+ "flex items-start cursor-pointer pr-1",
102
+ disabled && "cursor-not-allowed",
103
+ classRadioBox
104
+ )}
105
+ >
106
+ <div
107
+ class={twMerge(
108
+ "input-box",
109
+ _classCommon,
110
+ "flex h-6 items-center ml-1",
111
+ classInputBox
112
+ )}
113
+ >
114
+ <input
115
+ type="radio"
116
+ {id}
117
+ bind:this={input}
118
+ bind:group
119
+ {value}
120
+ {name}
121
+ class={twMerge(
122
+ _classCommon,
123
+ `size-4 rounded-full
124
+ bg-neutral-100
125
+ border-neutral-300
126
+ text-input-accent dark:text-input-accent-dark
127
+ cursor-pointer
128
+
129
+ checked:border-input-accent checked:bg-input-accent
130
+ checked:dark:border-input-accent-dark checked:dark:bg-input-accent-dark
131
+
132
+ focus:border-input-accent
133
+ focus:ring-4
134
+ focus:ring-offset-0
135
+ focus:ring-input-accent/20 focus:dark:ring-input-accent-dark/20
136
+
137
+ disabled:cursor-not-allowed`,
138
+ disabled && "cursor-not-allowed",
139
+ classInput
140
+ )}
141
+ aria-describedby={description ? idDesc : undefined}
142
+ use:validateAction={() => ({
143
+ enabled: !!validate,
144
+ ...(typeof validate === "boolean" ? {} : validate),
145
+ setValidationResult,
146
+ })}
147
+ {required}
148
+ {disabled}
149
+ {...rest}
150
+ />
151
+ </div>
152
+ <div class={twMerge("label-box", _classCommon, "ml-3 w-full", classLabelBox)}>
153
+ {#if label}
154
+ <div
155
+ class={twMerge(
156
+ "label",
157
+ _classCommon,
158
+ "block w-full cursor-pointer",
159
+ renderSize && _preset.labelBox.label.size[renderSize],
160
+ required && "after:content-['*'] after:opacity-40 after:pl-1",
161
+ classLabel
162
+ )}
163
+ >
164
+ {#if isTHCNotEmpty(label)}
165
+ <Thc thc={label as THC} forceAsHtml />
166
+ {:else}
167
+ {@render (label as SnippetWithId)({ id })}
168
+ {/if}
169
+ </div>
170
+ {/if}
171
+ {#if description}
172
+ <div
173
+ id={idDesc}
174
+ class={twMerge(
175
+ "desc-box",
176
+ _classCommon,
177
+ "text-sm opacity-50 cursor-pointer font-normal",
178
+ disabled && "cursor-not-allowed",
179
+ classDescBox
180
+ )}
181
+ >
182
+ {@render snippetOrThc({ id, value: description })}
183
+ </div>
184
+ {/if}
185
+ </div>
186
+ </label>
@@ -0,0 +1,30 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { THC } from "../../Thc/Thc.svelte";
3
+ import { type ValidateOptions, type ValidationResult } from "../../../actions/validate.svelte.js";
4
+ import type { HTMLInputAttributes } from "svelte/elements";
5
+ type SnippetWithId = Snippet<[{
6
+ id: string;
7
+ }]>;
8
+ interface Props extends HTMLInputAttributes {
9
+ input?: HTMLInputElement;
10
+ group?: string;
11
+ label?: SnippetWithId | THC;
12
+ name?: string;
13
+ value?: string;
14
+ required?: boolean;
15
+ disabled?: boolean;
16
+ renderSize?: "sm" | "md" | "lg" | string;
17
+ description?: SnippetWithId | THC;
18
+ validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
19
+ classRadioBox?: string;
20
+ classInputBox?: string;
21
+ classInput?: string;
22
+ classLabelBox?: string;
23
+ classLabel?: string;
24
+ classDescBox?: string;
25
+ classValidationBox?: string;
26
+ validation: ValidationResult | undefined;
27
+ }
28
+ declare const FieldRadioInternal: import("svelte").Component<Props, {}, "input" | "group" | "validation">;
29
+ type FieldRadioInternal = ReturnType<typeof FieldRadioInternal>;
30
+ export default FieldRadioInternal;