@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.
- 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/autoscroll.d.ts +0 -21
- package/dist/actions/autoscroll.js +0 -60
- 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,245 +1,166 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLSelectAttributes } from "svelte/elements";
|
|
4
|
+
import {
|
|
5
|
+
validate as validateAction,
|
|
6
|
+
type ValidateOptions,
|
|
7
|
+
type ValidationResult,
|
|
8
|
+
} from "../../actions/validate.svelte.js";
|
|
9
|
+
import { getId } from "../../utils/get-id.js";
|
|
10
|
+
import { twMerge } from "../../utils/tw-merge.js";
|
|
11
|
+
import type { THC } from "../Thc/Thc.svelte";
|
|
12
|
+
import InputWrap from "./_internal/InputWrap.svelte";
|
|
13
|
+
import type { FieldSelectOption } from "./types.js";
|
|
14
|
+
|
|
15
|
+
type SnippetWithId = Snippet<[{ id: string }]>;
|
|
16
|
+
|
|
17
|
+
interface Props extends HTMLSelectAttributes {
|
|
18
|
+
input?: HTMLSelectElement;
|
|
19
|
+
value?: string | number; // badInput
|
|
20
|
+
label?: SnippetWithId | THC;
|
|
21
|
+
description?: SnippetWithId | THC;
|
|
22
|
+
class?: string;
|
|
23
|
+
id?: string;
|
|
24
|
+
tabindex?: number; // tooShort
|
|
25
|
+
renderSize?: "sm" | "md" | "lg" | string;
|
|
26
|
+
//
|
|
27
|
+
options: (string | FieldSelectOption)[];
|
|
28
|
+
//
|
|
29
|
+
required?: boolean;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
//
|
|
32
|
+
validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
|
|
33
|
+
// wrap snippets
|
|
34
|
+
labelAfter?: SnippetWithId | THC;
|
|
35
|
+
inputBefore?: SnippetWithId | THC;
|
|
36
|
+
inputAfter?: SnippetWithId | THC;
|
|
37
|
+
inputBelow?: SnippetWithId | THC;
|
|
38
|
+
below?: SnippetWithId | THC;
|
|
39
|
+
//
|
|
40
|
+
labelLeft?: boolean;
|
|
41
|
+
labelLeftWidth?: "normal" | "wide";
|
|
42
|
+
labelLeftBreakpoint?: number;
|
|
43
|
+
//
|
|
44
|
+
classInput?: string;
|
|
45
|
+
classLabel?: string;
|
|
46
|
+
classLabelBox?: string;
|
|
47
|
+
classInputBox?: string;
|
|
48
|
+
classInputBoxWrap?: string;
|
|
49
|
+
classDescBox?: string;
|
|
50
|
+
classBelowBox?: string;
|
|
51
|
+
style?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let {
|
|
55
|
+
input = $bindable(),
|
|
56
|
+
value = $bindable(),
|
|
57
|
+
label = "",
|
|
58
|
+
id = getId(),
|
|
59
|
+
tabindex = 0,
|
|
60
|
+
description,
|
|
61
|
+
class: classProp,
|
|
62
|
+
renderSize = "md",
|
|
63
|
+
//
|
|
64
|
+
options = [],
|
|
65
|
+
//
|
|
66
|
+
required = false,
|
|
67
|
+
disabled = false,
|
|
68
|
+
//
|
|
69
|
+
validate,
|
|
70
|
+
//
|
|
71
|
+
labelAfter,
|
|
72
|
+
inputBefore,
|
|
73
|
+
inputAfter,
|
|
74
|
+
inputBelow,
|
|
75
|
+
below,
|
|
76
|
+
//
|
|
77
|
+
labelLeft = false,
|
|
78
|
+
labelLeftWidth = "normal",
|
|
79
|
+
labelLeftBreakpoint = 480,
|
|
80
|
+
//
|
|
81
|
+
classInput,
|
|
82
|
+
classLabel,
|
|
83
|
+
classLabelBox,
|
|
84
|
+
classInputBox,
|
|
85
|
+
classInputBoxWrap,
|
|
86
|
+
classDescBox,
|
|
87
|
+
classBelowBox,
|
|
88
|
+
style,
|
|
89
|
+
//
|
|
90
|
+
...rest
|
|
91
|
+
}: Props = $props();
|
|
74
92
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
export let labelLeft = FieldSelectConfig.labelLeft;
|
|
94
|
-
export let labelLeftWidth = FieldSelectConfig.labelLeftWidth;
|
|
95
|
-
let validation;
|
|
96
|
-
const setValidationResult = (res) => validation = res;
|
|
97
|
-
const _normalizeAndGroupOptions = (opts) => {
|
|
98
|
-
const groupped = /* @__PURE__ */ new Map();
|
|
99
|
-
opts.forEach((v) => {
|
|
100
|
-
if (typeof v === "string")
|
|
101
|
-
v = { label: v };
|
|
102
|
-
if (v.value === void 0)
|
|
103
|
-
v.value = v.label;
|
|
104
|
-
const optgLabel = v.optgroup || "";
|
|
105
|
-
if (!groupped.has(optgLabel))
|
|
106
|
-
groupped.set(optgLabel, []);
|
|
107
|
-
const optgroup = groupped.get(optgLabel);
|
|
108
|
-
optgroup.push(v);
|
|
109
|
-
});
|
|
110
|
-
return groupped;
|
|
111
|
-
};
|
|
112
|
-
let _options;
|
|
113
|
-
$:
|
|
114
|
-
_options = _normalizeAndGroupOptions(options);
|
|
115
|
-
let _inputEl;
|
|
116
|
-
$:
|
|
117
|
-
if (_inputEl)
|
|
118
|
-
dispatch("input_mounted", _inputEl);
|
|
119
|
-
const _collectClasses = (k, extra = "") => [
|
|
120
|
-
_PRESET?.[k] || "",
|
|
121
|
-
_PRESET_BY_SIZE?.[size]?.[k] || "",
|
|
122
|
-
FieldSelectConfig?.class?.[k] || "",
|
|
123
|
-
FieldSelectConfig?.classBySize?.[size]?.[k] || "",
|
|
124
|
-
extra || "",
|
|
125
|
-
_class?.[k] || "",
|
|
126
|
-
classBySize?.[size]?.[k] || ""
|
|
127
|
-
].join(" ");
|
|
128
|
-
$:
|
|
129
|
-
_boxClass = twMerge2(_collectClasses("box"));
|
|
130
|
-
$:
|
|
131
|
-
_labelClass = twMerge2(
|
|
132
|
-
_collectClasses(
|
|
133
|
-
"label",
|
|
134
|
-
showAsterixOnRequired && required ? _collectClasses("asterix") : ""
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
$:
|
|
138
|
-
_wrapClass = twMerge2(
|
|
139
|
-
_collectClasses(
|
|
140
|
-
"wrap",
|
|
141
|
-
validation && !validation.valid ? _collectClasses("invalid") : ""
|
|
142
|
-
)
|
|
143
|
-
);
|
|
144
|
-
$:
|
|
145
|
-
_inputClass = twMerge2("form-input", _collectClasses("input"));
|
|
146
|
-
$:
|
|
147
|
-
_validationMessageClass = twMerge2(_collectClasses("validationMessage"));
|
|
148
|
-
$:
|
|
149
|
-
_descriptionClass = twMerge2(_collectClasses("description"));
|
|
150
|
-
$:
|
|
151
|
-
_belowClass = twMerge2(_collectClasses("below"));
|
|
93
|
+
//
|
|
94
|
+
let validation: ValidationResult | undefined = $state();
|
|
95
|
+
const setValidationResult = (res: ValidationResult) => (validation = res);
|
|
96
|
+
|
|
97
|
+
const _normalizeAndGroupOptions = (opts: (string | FieldSelectOption)[]) => {
|
|
98
|
+
const groupped = new Map<string, FieldSelectOption[]>();
|
|
99
|
+
opts.forEach((v) => {
|
|
100
|
+
if (typeof v === "string") v = { label: v };
|
|
101
|
+
if (v.value === undefined) v.value = v.label;
|
|
102
|
+
const optgLabel = v.optgroup || "";
|
|
103
|
+
if (!groupped.has(optgLabel)) groupped.set(optgLabel, []);
|
|
104
|
+
const optgroup = groupped.get(optgLabel);
|
|
105
|
+
optgroup!.push(v);
|
|
106
|
+
});
|
|
107
|
+
return groupped;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
let _options = $derived(_normalizeAndGroupOptions(options));
|
|
152
111
|
</script>
|
|
153
112
|
|
|
154
|
-
<
|
|
155
|
-
|
|
156
|
-
class
|
|
157
|
-
|
|
113
|
+
<InputWrap
|
|
114
|
+
{description}
|
|
115
|
+
class={classProp}
|
|
116
|
+
size={renderSize}
|
|
117
|
+
{id}
|
|
118
|
+
{label}
|
|
119
|
+
{labelAfter}
|
|
120
|
+
{inputBefore}
|
|
121
|
+
{inputAfter}
|
|
122
|
+
{below}
|
|
123
|
+
{required}
|
|
124
|
+
{disabled}
|
|
125
|
+
{labelLeft}
|
|
126
|
+
{labelLeftWidth}
|
|
127
|
+
{labelLeftBreakpoint}
|
|
128
|
+
{classLabel}
|
|
129
|
+
{classLabelBox}
|
|
130
|
+
{classInputBox}
|
|
131
|
+
{classInputBoxWrap}
|
|
132
|
+
{classDescBox}
|
|
133
|
+
{classBelowBox}
|
|
134
|
+
{validation}
|
|
135
|
+
{style}
|
|
158
136
|
>
|
|
159
|
-
<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
class
|
|
137
|
+
<select
|
|
138
|
+
bind:value
|
|
139
|
+
bind:this={input}
|
|
140
|
+
{id}
|
|
141
|
+
class={twMerge("form-input", renderSize, classInput)}
|
|
142
|
+
use:validateAction={() => ({
|
|
143
|
+
enabled: !!validate,
|
|
144
|
+
...(typeof validate === "boolean" ? {} : validate),
|
|
145
|
+
setValidationResult,
|
|
146
|
+
})}
|
|
147
|
+
{tabindex}
|
|
148
|
+
{required}
|
|
149
|
+
{disabled}
|
|
150
|
+
{...rest}
|
|
164
151
|
>
|
|
165
|
-
{#
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
<Thc thc={label} forceAsHtml />
|
|
171
|
-
{/if}
|
|
172
|
-
</label>
|
|
173
|
-
{/if}
|
|
174
|
-
<slot name="right_of_label" />
|
|
175
|
-
</div>
|
|
176
|
-
<div
|
|
177
|
-
class:col-span-3={labelLeft && labelLeftWidth === 'normal'}
|
|
178
|
-
class:col-span-2={labelLeft && labelLeftWidth === 'wide'}
|
|
179
|
-
>
|
|
180
|
-
<div
|
|
181
|
-
class={_wrapClass}
|
|
182
|
-
class:cursor-not-allowed={disabled}
|
|
183
|
-
class:opacity-50={disabled}
|
|
184
|
-
>
|
|
185
|
-
<div class="flex">
|
|
186
|
-
<slot name="input_before" {id} />
|
|
187
|
-
<select
|
|
188
|
-
class={_inputClass}
|
|
189
|
-
bind:value
|
|
190
|
-
bind:this={_inputEl}
|
|
191
|
-
{id}
|
|
192
|
-
{disabled}
|
|
193
|
-
{required}
|
|
194
|
-
{tabindex}
|
|
195
|
-
{autofocus}
|
|
196
|
-
{name}
|
|
197
|
-
use:validateAction={validate
|
|
198
|
-
? { ...(validate === true ? {} : validate), setValidationResult }
|
|
199
|
-
: undefined}
|
|
200
|
-
on:blur
|
|
201
|
-
on:change
|
|
202
|
-
on:click
|
|
203
|
-
on:focus
|
|
204
|
-
on:input
|
|
205
|
-
on:keydown
|
|
206
|
-
on:keyup
|
|
207
|
-
on:touchstart|passive
|
|
208
|
-
on:touchend|passive
|
|
209
|
-
on:touchcancel
|
|
210
|
-
on:mouseenter
|
|
211
|
-
on:mouseleave
|
|
212
|
-
>
|
|
213
|
-
{#each _options as [_optgroup, _opts]}
|
|
214
|
-
{#if _optgroup}
|
|
215
|
-
<optgroup label={_optgroup}>
|
|
216
|
-
{#each _opts as o}
|
|
217
|
-
<option value={o.value}>{o.label}</option>
|
|
218
|
-
{/each}
|
|
219
|
-
</optgroup>
|
|
220
|
-
{:else}
|
|
221
|
-
{#each _opts as o}
|
|
222
|
-
<option value={o.value}>{o.label}</option>
|
|
223
|
-
{/each}
|
|
224
|
-
{/if}
|
|
152
|
+
{#each _options as [_optgroup, _opts]}
|
|
153
|
+
{#if _optgroup}
|
|
154
|
+
<optgroup label={_optgroup}>
|
|
155
|
+
{#each _opts as o}
|
|
156
|
+
<option value={o.value}>{o.label}</option>
|
|
225
157
|
{/each}
|
|
226
|
-
</
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
{/if}
|
|
236
|
-
{#if description}
|
|
237
|
-
<div class={_descriptionClass}>
|
|
238
|
-
<Thc thc={description} forceAsHtml />
|
|
239
|
-
</div>
|
|
240
|
-
{/if}
|
|
241
|
-
{#if $$slots.below}
|
|
242
|
-
<div class={_belowClass}><slot name="below" {id} /></div>
|
|
243
|
-
{/if}
|
|
244
|
-
</div>
|
|
245
|
-
</div>
|
|
158
|
+
</optgroup>
|
|
159
|
+
{:else}
|
|
160
|
+
{#each _opts as o}
|
|
161
|
+
<option value={o.value}>{o.label}</option>
|
|
162
|
+
{/each}
|
|
163
|
+
{/if}
|
|
164
|
+
{/each}
|
|
165
|
+
</select>
|
|
166
|
+
</InputWrap>
|
|
@@ -1,89 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLSelectAttributes } from "svelte/elements";
|
|
3
|
+
import { type ValidateOptions } from "../../actions/validate.svelte.js";
|
|
4
|
+
import type { THC } from "../Thc/Thc.svelte";
|
|
5
|
+
import type { FieldSelectOption } from "./types.js";
|
|
6
|
+
type SnippetWithId = Snippet<[{
|
|
7
|
+
id: string;
|
|
8
|
+
}]>;
|
|
9
|
+
interface Props extends HTMLSelectAttributes {
|
|
10
|
+
input?: HTMLSelectElement;
|
|
11
|
+
value?: string | number;
|
|
12
|
+
label?: SnippetWithId | THC;
|
|
13
|
+
description?: SnippetWithId | THC;
|
|
14
|
+
class?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
tabindex?: number;
|
|
17
|
+
renderSize?: "sm" | "md" | "lg" | string;
|
|
18
|
+
options: (string | FieldSelectOption)[];
|
|
19
|
+
required?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
|
|
22
|
+
labelAfter?: SnippetWithId | THC;
|
|
23
|
+
inputBefore?: SnippetWithId | THC;
|
|
24
|
+
inputAfter?: SnippetWithId | THC;
|
|
25
|
+
inputBelow?: SnippetWithId | THC;
|
|
26
|
+
below?: SnippetWithId | THC;
|
|
27
|
+
labelLeft?: boolean;
|
|
28
|
+
labelLeftWidth?: "normal" | "wide";
|
|
29
|
+
labelLeftBreakpoint?: number;
|
|
30
|
+
classInput?: string;
|
|
31
|
+
classLabel?: string;
|
|
32
|
+
classLabelBox?: string;
|
|
33
|
+
classInputBox?: string;
|
|
34
|
+
classInputBoxWrap?: string;
|
|
35
|
+
classDescBox?: string;
|
|
36
|
+
classBelowBox?: string;
|
|
37
|
+
style?: string;
|
|
14
38
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
lg?: FieldSelectConfigClasses;
|
|
19
|
-
}
|
|
20
|
-
export declare class FieldSelectConfig {
|
|
21
|
-
static class: FieldSelectConfigClasses;
|
|
22
|
-
static classBySize: FieldSelectConfigClassesBySize;
|
|
23
|
-
static labelLeft: boolean;
|
|
24
|
-
static labelLeftWidth: 'normal' | 'wide';
|
|
25
|
-
static readonly _preset: FieldSelectConfigClasses;
|
|
26
|
-
static readonly _presetBySize: FieldSelectConfigClassesBySize;
|
|
27
|
-
}
|
|
28
|
-
declare const __propDef: {
|
|
29
|
-
props: {
|
|
30
|
-
options?: (string | {
|
|
31
|
-
label: string;
|
|
32
|
-
value?: string;
|
|
33
|
-
optgroup?: string;
|
|
34
|
-
})[];
|
|
35
|
-
class?: FieldSelectConfigClasses;
|
|
36
|
-
classBySize?: FieldSelectConfigClassesBySize;
|
|
37
|
-
size?: "sm" | "md" | "lg";
|
|
38
|
-
id?: string;
|
|
39
|
-
value: any;
|
|
40
|
-
label?: THC;
|
|
41
|
-
name?: string;
|
|
42
|
-
tabindex?: number;
|
|
43
|
-
description?: THC;
|
|
44
|
-
disabled?: boolean;
|
|
45
|
-
required?: boolean;
|
|
46
|
-
autofocus?: true | undefined;
|
|
47
|
-
validate?: ValidateOptions | true | undefined;
|
|
48
|
-
showAsterixOnRequired?: boolean;
|
|
49
|
-
labelLeft?: boolean;
|
|
50
|
-
labelLeftWidth?: "normal" | "wide";
|
|
51
|
-
};
|
|
52
|
-
events: {
|
|
53
|
-
blur: FocusEvent;
|
|
54
|
-
change: Event;
|
|
55
|
-
click: MouseEvent;
|
|
56
|
-
focus: FocusEvent;
|
|
57
|
-
input: Event;
|
|
58
|
-
keydown: KeyboardEvent;
|
|
59
|
-
keyup: KeyboardEvent;
|
|
60
|
-
touchstart: TouchEvent;
|
|
61
|
-
touchend: TouchEvent;
|
|
62
|
-
touchcancel: TouchEvent;
|
|
63
|
-
mouseenter: MouseEvent;
|
|
64
|
-
mouseleave: MouseEvent;
|
|
65
|
-
} & {
|
|
66
|
-
[evt: string]: CustomEvent<any>;
|
|
67
|
-
};
|
|
68
|
-
slots: {
|
|
69
|
-
label: {};
|
|
70
|
-
right_of_label: {};
|
|
71
|
-
input_before: {
|
|
72
|
-
id: string;
|
|
73
|
-
};
|
|
74
|
-
input_after: {
|
|
75
|
-
id: string;
|
|
76
|
-
};
|
|
77
|
-
below: {
|
|
78
|
-
id: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
exports?: {} | undefined;
|
|
82
|
-
bindings?: string | undefined;
|
|
83
|
-
};
|
|
84
|
-
export type FieldSelectProps = typeof __propDef.props;
|
|
85
|
-
export type FieldSelectEvents = typeof __propDef.events;
|
|
86
|
-
export type FieldSelectSlots = typeof __propDef.slots;
|
|
87
|
-
export default class FieldSelect extends SvelteComponent<FieldSelectProps, FieldSelectEvents, FieldSelectSlots> {
|
|
88
|
-
}
|
|
89
|
-
export {};
|
|
39
|
+
declare const FieldSelect: import("svelte").Component<Props, {}, "value" | "input">;
|
|
40
|
+
type FieldSelect = ReturnType<typeof FieldSelect>;
|
|
41
|
+
export default FieldSelect;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import {
|
|
4
|
+
type ValidateOptions,
|
|
5
|
+
type ValidationResult,
|
|
6
|
+
} from "../../actions/validate.svelte.js";
|
|
7
|
+
import { getId } from "../../utils/get-id.js";
|
|
8
|
+
import { twMerge } from "../../utils/tw-merge.js";
|
|
9
|
+
import Switch from "../Switch/Switch.svelte";
|
|
10
|
+
import type { THC } from "../Thc/Thc.svelte";
|
|
11
|
+
import InputWrap from "./_internal/InputWrap.svelte";
|
|
12
|
+
|
|
13
|
+
type SnippetWithId = Snippet<[{ id: string }]>;
|
|
14
|
+
|
|
15
|
+
interface Props extends Record<string, any> {
|
|
16
|
+
input?: HTMLInputElement;
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
label?: SnippetWithId | THC;
|
|
19
|
+
// type?: "submit" | "reset" | "button";
|
|
20
|
+
description?: SnippetWithId | THC;
|
|
21
|
+
class?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
tabindex?: number; // tooShort
|
|
24
|
+
renderSize?: "sm" | "md" | "lg" | string;
|
|
25
|
+
useTrim?: boolean;
|
|
26
|
+
name?: string;
|
|
27
|
+
//
|
|
28
|
+
required?: boolean;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
//
|
|
31
|
+
validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
|
|
32
|
+
// wrap snippets
|
|
33
|
+
labelAfter?: SnippetWithId | THC;
|
|
34
|
+
inputBefore?: SnippetWithId | THC;
|
|
35
|
+
inputAfter?: SnippetWithId | THC;
|
|
36
|
+
inputBelow?: SnippetWithId | THC;
|
|
37
|
+
below?: SnippetWithId | THC;
|
|
38
|
+
//
|
|
39
|
+
labelLeft?: boolean;
|
|
40
|
+
labelLeftWidth?: "normal" | "wide";
|
|
41
|
+
labelLeftBreakpoint?: number;
|
|
42
|
+
//
|
|
43
|
+
classInput?: string;
|
|
44
|
+
classLabel?: string;
|
|
45
|
+
classLabelBox?: string;
|
|
46
|
+
classInputBox?: string;
|
|
47
|
+
classInputBoxWrap?: string;
|
|
48
|
+
classDescBox?: string;
|
|
49
|
+
classBelowBox?: string;
|
|
50
|
+
//
|
|
51
|
+
style?: string;
|
|
52
|
+
//
|
|
53
|
+
renderValue?: (rawValue: any) => string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let {
|
|
57
|
+
input = $bindable(),
|
|
58
|
+
checked = $bindable(),
|
|
59
|
+
label = "",
|
|
60
|
+
id = getId(),
|
|
61
|
+
// type = "button",
|
|
62
|
+
tabindex = 0,
|
|
63
|
+
description,
|
|
64
|
+
class: classProp,
|
|
65
|
+
renderSize = "md",
|
|
66
|
+
useTrim = true,
|
|
67
|
+
name,
|
|
68
|
+
//
|
|
69
|
+
required = false,
|
|
70
|
+
disabled = false,
|
|
71
|
+
//
|
|
72
|
+
validate,
|
|
73
|
+
//
|
|
74
|
+
labelAfter,
|
|
75
|
+
inputBefore,
|
|
76
|
+
inputAfter,
|
|
77
|
+
inputBelow,
|
|
78
|
+
below,
|
|
79
|
+
//
|
|
80
|
+
labelLeft = false,
|
|
81
|
+
labelLeftWidth = "normal",
|
|
82
|
+
labelLeftBreakpoint = 480,
|
|
83
|
+
//
|
|
84
|
+
classInput,
|
|
85
|
+
classLabel,
|
|
86
|
+
classLabelBox,
|
|
87
|
+
classInputBox,
|
|
88
|
+
classInputBoxWrap,
|
|
89
|
+
classDescBox,
|
|
90
|
+
classBelowBox,
|
|
91
|
+
style = "",
|
|
92
|
+
//
|
|
93
|
+
renderValue,
|
|
94
|
+
//
|
|
95
|
+
...rest
|
|
96
|
+
}: Props = $props();
|
|
97
|
+
|
|
98
|
+
//
|
|
99
|
+
let validation: ValidationResult | undefined = $state();
|
|
100
|
+
const setValidationResult = (res: ValidationResult) => (validation = res);
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<InputWrap
|
|
104
|
+
{description}
|
|
105
|
+
class={classProp}
|
|
106
|
+
size={renderSize}
|
|
107
|
+
{id}
|
|
108
|
+
{label}
|
|
109
|
+
{labelAfter}
|
|
110
|
+
{inputBefore}
|
|
111
|
+
{inputAfter}
|
|
112
|
+
{below}
|
|
113
|
+
{required}
|
|
114
|
+
{disabled}
|
|
115
|
+
{labelLeft}
|
|
116
|
+
{labelLeftWidth}
|
|
117
|
+
{labelLeftBreakpoint}
|
|
118
|
+
{classLabel}
|
|
119
|
+
{classLabelBox}
|
|
120
|
+
{classInputBox}
|
|
121
|
+
classInputBoxWrap={twMerge(
|
|
122
|
+
"border-0 focus-within:border-0 focus-within:dark:border-0 focus-within:ring-0",
|
|
123
|
+
"bg-transparent dark:bg-transparent",
|
|
124
|
+
classInputBoxWrap
|
|
125
|
+
)}
|
|
126
|
+
{classDescBox}
|
|
127
|
+
{classBelowBox}
|
|
128
|
+
{validation}
|
|
129
|
+
{style}
|
|
130
|
+
>
|
|
131
|
+
<Switch bind:checked {name} {required} {disabled} {validate} {setValidationResult} />
|
|
132
|
+
</InputWrap>
|