@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,156 +1,198 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
4
|
+
import { slide } from "svelte/transition";
|
|
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 { Thc } from "../Thc/index.js";
|
|
13
|
+
import { isTHCNotEmpty, type THC } from "../Thc/Thc.svelte";
|
|
14
|
+
|
|
15
|
+
type SnippetWithId = Snippet<[{ id: string }]>;
|
|
16
|
+
|
|
17
|
+
interface Props extends HTMLInputAttributes {
|
|
18
|
+
input?: HTMLInputElement;
|
|
19
|
+
id?: string;
|
|
20
|
+
checked?: boolean;
|
|
21
|
+
label?: SnippetWithId | THC;
|
|
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
|
+
class?: string;
|
|
30
|
+
classInputBox?: string;
|
|
31
|
+
classInput?: string;
|
|
32
|
+
classLabelBox?: string;
|
|
33
|
+
classLabel?: string;
|
|
34
|
+
classDescBox?: string;
|
|
35
|
+
classValidationBox?: string;
|
|
36
|
+
style?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let {
|
|
40
|
+
input = $bindable(),
|
|
41
|
+
id = getId(),
|
|
42
|
+
checked = $bindable(),
|
|
43
|
+
label,
|
|
44
|
+
required,
|
|
45
|
+
disabled,
|
|
46
|
+
renderSize = "md",
|
|
47
|
+
description,
|
|
48
|
+
validate,
|
|
49
|
+
class: classProp,
|
|
50
|
+
classInputBox,
|
|
51
|
+
classInput,
|
|
52
|
+
classLabelBox,
|
|
53
|
+
classLabel,
|
|
54
|
+
classDescBox,
|
|
55
|
+
classValidationBox,
|
|
56
|
+
style,
|
|
57
|
+
...rest
|
|
58
|
+
}: Props = $props();
|
|
59
|
+
|
|
60
|
+
//
|
|
61
|
+
let validation: ValidationResult | undefined = $state();
|
|
62
|
+
const setValidationResult = (res: ValidationResult) => (validation = res);
|
|
63
|
+
|
|
64
|
+
//
|
|
65
|
+
let invalid = $derived(validation && !validation?.valid);
|
|
66
|
+
let idDesc = getId();
|
|
48
67
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
_PRESET_BY_SIZE?.[size]?.[k] || "",
|
|
69
|
-
FieldCheckboxConfig?.class?.[k] || "",
|
|
70
|
-
FieldCheckboxConfig?.classBySize?.[size]?.[k] || "",
|
|
71
|
-
extra || "",
|
|
72
|
-
_class?.[k] || "",
|
|
73
|
-
classBySize?.[size]?.[k] || ""
|
|
74
|
-
].join(" ");
|
|
75
|
-
$:
|
|
76
|
-
_boxClass = twMerge2(_collectClasses("box"));
|
|
77
|
-
$:
|
|
78
|
-
_inputClass = twMerge2(
|
|
79
|
-
_collectClasses(
|
|
80
|
-
"input",
|
|
81
|
-
validation && !validation.valid ? _collectClasses("invalid") : ""
|
|
82
|
-
)
|
|
83
|
-
);
|
|
84
|
-
$:
|
|
85
|
-
_labelClass = twMerge2(_collectClasses("label"));
|
|
86
|
-
$:
|
|
87
|
-
_validationMessageClass = twMerge2(_collectClasses("validationMessage"));
|
|
88
|
-
$:
|
|
89
|
-
_descriptionClass = twMerge2(_collectClasses("description"));
|
|
68
|
+
// $inspect(33333, invalid, validation);
|
|
69
|
+
|
|
70
|
+
//
|
|
71
|
+
let _classCommon = $derived(
|
|
72
|
+
[invalid && "invalid", disabled && "disabled", required && "required", renderSize]
|
|
73
|
+
.filter(Boolean)
|
|
74
|
+
.join(" ")
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const _preset = {
|
|
78
|
+
labelBox: {
|
|
79
|
+
label: {
|
|
80
|
+
size: {
|
|
81
|
+
sm: "text-sm mt-0.5",
|
|
82
|
+
lg: "font-bold",
|
|
83
|
+
} as any,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
90
87
|
</script>
|
|
91
88
|
|
|
92
|
-
|
|
93
|
-
|
|
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
|
+
`stuic-checkbox`,
|
|
100
|
+
_classCommon,
|
|
101
|
+
"flex items-start mb-4 text-base",
|
|
102
|
+
classProp
|
|
103
|
+
)}
|
|
104
|
+
{style}
|
|
105
|
+
>
|
|
106
|
+
<div
|
|
107
|
+
class={twMerge(
|
|
108
|
+
"input-box",
|
|
109
|
+
_classCommon,
|
|
110
|
+
"flex h-6 items-center ml-1",
|
|
111
|
+
classInputBox
|
|
112
|
+
)}
|
|
113
|
+
>
|
|
94
114
|
<input
|
|
95
115
|
{id}
|
|
96
116
|
type="checkbox"
|
|
117
|
+
bind:this={input}
|
|
97
118
|
bind:checked
|
|
98
119
|
aria-checked={checked}
|
|
99
120
|
aria-describedby={description ? idDesc : undefined}
|
|
100
|
-
{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
121
|
+
use:validateAction={() => ({
|
|
122
|
+
enabled: !!validate,
|
|
123
|
+
...(typeof validate === "boolean" ? {} : validate),
|
|
124
|
+
setValidationResult,
|
|
125
|
+
})}
|
|
126
|
+
class={twMerge(
|
|
127
|
+
_classCommon,
|
|
128
|
+
`size-5 rounded
|
|
129
|
+
bg-neutral-100
|
|
130
|
+
border-neutral-300
|
|
131
|
+
text-input-accent dark:text-input-accent-dark
|
|
132
|
+
cursor-pointer
|
|
133
|
+
|
|
134
|
+
checked:border-input-accent checked:bg-input-accent
|
|
135
|
+
checked:dark:border-input-accent-dark checked:dark:bg-input-accent-dark
|
|
136
|
+
|
|
137
|
+
focus:border-input-accent
|
|
138
|
+
focus:ring-4
|
|
139
|
+
focus:ring-offset-0
|
|
140
|
+
focus:ring-input-accent/20 focus:dark:ring-input-accent-dark/20
|
|
141
|
+
|
|
142
|
+
disabled:cursor-not-allowed`,
|
|
143
|
+
classInput
|
|
144
|
+
)}
|
|
104
145
|
{required}
|
|
105
|
-
{
|
|
106
|
-
|
|
107
|
-
? { ...(validate === true ? {} : validate), setValidationResult }
|
|
108
|
-
: undefined}
|
|
109
|
-
on:blur
|
|
110
|
-
on:change
|
|
111
|
-
on:click
|
|
112
|
-
on:focus
|
|
113
|
-
on:input
|
|
114
|
-
on:keydown
|
|
115
|
-
on:keyup
|
|
116
|
-
on:touchstart|passive
|
|
117
|
-
on:touchend|passive
|
|
118
|
-
on:touchmove|passive
|
|
119
|
-
on:touchcancel
|
|
120
|
-
on:mouseenter
|
|
121
|
-
on:mouseleave
|
|
146
|
+
{disabled}
|
|
147
|
+
{...rest}
|
|
122
148
|
/>
|
|
123
149
|
</div>
|
|
124
|
-
<div class="ml-3 w-full">
|
|
150
|
+
<div class={twMerge("label-box", _classCommon, "ml-3 w-full", classLabelBox)}>
|
|
125
151
|
{#if label}
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
152
|
+
<div
|
|
153
|
+
class={twMerge(
|
|
154
|
+
"label",
|
|
155
|
+
_classCommon,
|
|
156
|
+
"block w-full cursor-pointer",
|
|
157
|
+
disabled && "cursor-not-allowed",
|
|
158
|
+
required && "after:content-['*'] after:opacity-40 after:pl-1",
|
|
159
|
+
_preset.labelBox.label.size[renderSize],
|
|
160
|
+
classLabel
|
|
161
|
+
)}
|
|
131
162
|
>
|
|
132
|
-
|
|
133
|
-
|
|
163
|
+
{#if isTHCNotEmpty(label)}
|
|
164
|
+
<Thc thc={label as THC} forceAsHtml />
|
|
165
|
+
{:else}
|
|
166
|
+
{@render (label as SnippetWithId)({ id })}
|
|
167
|
+
{/if}
|
|
168
|
+
</div>
|
|
134
169
|
{/if}
|
|
135
170
|
{#if validation && !validation?.valid}
|
|
136
|
-
<div
|
|
171
|
+
<div
|
|
172
|
+
transition:slide={{ duration: 150 }}
|
|
173
|
+
class={twMerge(
|
|
174
|
+
"validation-box",
|
|
175
|
+
_classCommon,
|
|
176
|
+
"text-xs text-input-accent dark:text-input-accent-dark tracking-tight",
|
|
177
|
+
classValidationBox
|
|
178
|
+
)}
|
|
179
|
+
>
|
|
137
180
|
{@html validation.message}
|
|
138
181
|
</div>
|
|
139
182
|
{/if}
|
|
140
|
-
{#if description
|
|
141
|
-
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-static-element-interactions -->
|
|
183
|
+
{#if description}
|
|
142
184
|
<div
|
|
143
|
-
|
|
144
|
-
class
|
|
145
|
-
|
|
146
|
-
|
|
185
|
+
id={idDesc}
|
|
186
|
+
class={twMerge(
|
|
187
|
+
"desc-box",
|
|
188
|
+
_classCommon,
|
|
189
|
+
"text-sm opacity-50 cursor-pointer font-normal",
|
|
190
|
+
disabled && "cursor-not-allowed",
|
|
191
|
+
classDescBox
|
|
192
|
+
)}
|
|
147
193
|
>
|
|
148
|
-
{
|
|
149
|
-
<slot name="description" />
|
|
150
|
-
{:else}
|
|
151
|
-
<Thc thc={description} forceAsHtml />
|
|
152
|
-
{/if}
|
|
194
|
+
{@render snippetOrThc({ id, value: description })}
|
|
153
195
|
</div>
|
|
154
196
|
{/if}
|
|
155
197
|
</div>
|
|
156
|
-
</
|
|
198
|
+
</label>
|
|
@@ -1,65 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLInputAttributes } 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 HTMLInputAttributes {
|
|
9
|
+
input?: HTMLInputElement;
|
|
10
|
+
id?: string;
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
label?: SnippetWithId | THC;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
renderSize?: "sm" | "md" | "lg" | string;
|
|
16
|
+
description?: SnippetWithId | THC;
|
|
17
|
+
validate?: boolean | Omit<ValidateOptions, "setValidationResult">;
|
|
18
|
+
class?: string;
|
|
19
|
+
classInputBox?: string;
|
|
20
|
+
classInput?: string;
|
|
21
|
+
classLabelBox?: string;
|
|
22
|
+
classLabel?: string;
|
|
23
|
+
classDescBox?: string;
|
|
24
|
+
classValidationBox?: string;
|
|
25
|
+
style?: string;
|
|
11
26
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
lg?: FieldCheckboxConfigClasses;
|
|
16
|
-
}
|
|
17
|
-
export declare class FieldCheckboxConfig {
|
|
18
|
-
static class: FieldCheckboxConfigClasses;
|
|
19
|
-
static classBySize: FieldCheckboxConfigClassesBySize;
|
|
20
|
-
}
|
|
21
|
-
declare const __propDef: {
|
|
22
|
-
props: {
|
|
23
|
-
class?: FieldCheckboxConfigClasses;
|
|
24
|
-
classBySize?: FieldCheckboxConfigClassesBySize;
|
|
25
|
-
size?: "sm" | "md" | "lg";
|
|
26
|
-
id?: string;
|
|
27
|
-
checked?: boolean;
|
|
28
|
-
label?: THC;
|
|
29
|
-
name?: string;
|
|
30
|
-
description?: THC;
|
|
31
|
-
tabindex?: number;
|
|
32
|
-
disabled?: boolean | undefined;
|
|
33
|
-
readonly?: boolean | undefined;
|
|
34
|
-
required?: boolean | undefined;
|
|
35
|
-
validate?: ValidateOptions | true | undefined;
|
|
36
|
-
};
|
|
37
|
-
events: {
|
|
38
|
-
blur: FocusEvent;
|
|
39
|
-
change: Event;
|
|
40
|
-
click: MouseEvent;
|
|
41
|
-
focus: FocusEvent;
|
|
42
|
-
input: Event;
|
|
43
|
-
keydown: KeyboardEvent;
|
|
44
|
-
keyup: KeyboardEvent;
|
|
45
|
-
touchstart: TouchEvent;
|
|
46
|
-
touchend: TouchEvent;
|
|
47
|
-
touchmove: TouchEvent;
|
|
48
|
-
touchcancel: TouchEvent;
|
|
49
|
-
mouseenter: MouseEvent;
|
|
50
|
-
mouseleave: MouseEvent;
|
|
51
|
-
} & {
|
|
52
|
-
[evt: string]: CustomEvent<any>;
|
|
53
|
-
};
|
|
54
|
-
slots: {
|
|
55
|
-
description: {};
|
|
56
|
-
};
|
|
57
|
-
exports?: {} | undefined;
|
|
58
|
-
bindings?: string | undefined;
|
|
59
|
-
};
|
|
60
|
-
export type FieldCheckboxProps = typeof __propDef.props;
|
|
61
|
-
export type FieldCheckboxEvents = typeof __propDef.events;
|
|
62
|
-
export type FieldCheckboxSlots = typeof __propDef.slots;
|
|
63
|
-
export default class FieldCheckbox extends SvelteComponent<FieldCheckboxProps, FieldCheckboxEvents, FieldCheckboxSlots> {
|
|
64
|
-
}
|
|
65
|
-
export {};
|
|
27
|
+
declare const FieldCheckbox: import("svelte").Component<Props, {}, "input" | "checked">;
|
|
28
|
+
type FieldCheckbox = ReturnType<typeof FieldCheckbox>;
|
|
29
|
+
export default FieldCheckbox;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
4
|
+
import { highlightDragover } from "../../actions/highlight-dragover.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
|
+
|
|
15
|
+
type SnippetWithId = Snippet<[{ id: string }]>;
|
|
16
|
+
|
|
17
|
+
interface Props extends HTMLInputAttributes, Record<string, any> {
|
|
18
|
+
input?: HTMLInputElement;
|
|
19
|
+
files?: FileList;
|
|
20
|
+
multiple?: boolean;
|
|
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
|
+
//
|
|
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
|
+
classFileList?: string;
|
|
51
|
+
//
|
|
52
|
+
style?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let {
|
|
56
|
+
input = $bindable(),
|
|
57
|
+
files = $bindable(),
|
|
58
|
+
multiple,
|
|
59
|
+
label = "",
|
|
60
|
+
id = getId(),
|
|
61
|
+
type = "text",
|
|
62
|
+
tabindex = 0,
|
|
63
|
+
description,
|
|
64
|
+
class: classProp,
|
|
65
|
+
renderSize,
|
|
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
|
+
classFileList,
|
|
90
|
+
style,
|
|
91
|
+
//
|
|
92
|
+
...rest
|
|
93
|
+
}: Props = $props();
|
|
94
|
+
|
|
95
|
+
let validation: ValidationResult | undefined = $state();
|
|
96
|
+
const setValidationResult = (res: ValidationResult) => (validation = res);
|
|
97
|
+
|
|
98
|
+
// $inspect(files);
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<InputWrap
|
|
102
|
+
{description}
|
|
103
|
+
class={classProp}
|
|
104
|
+
size={renderSize}
|
|
105
|
+
{id}
|
|
106
|
+
{label}
|
|
107
|
+
{labelAfter}
|
|
108
|
+
{inputBefore}
|
|
109
|
+
{inputAfter}
|
|
110
|
+
{below}
|
|
111
|
+
{required}
|
|
112
|
+
{disabled}
|
|
113
|
+
{labelLeft}
|
|
114
|
+
{labelLeftWidth}
|
|
115
|
+
{labelLeftBreakpoint}
|
|
116
|
+
{classLabel}
|
|
117
|
+
{classLabelBox}
|
|
118
|
+
{classInputBox}
|
|
119
|
+
{classInputBoxWrap}
|
|
120
|
+
{classDescBox}
|
|
121
|
+
{classBelowBox}
|
|
122
|
+
{validation}
|
|
123
|
+
{style}
|
|
124
|
+
>
|
|
125
|
+
<div class="block w-full">
|
|
126
|
+
<input
|
|
127
|
+
type="file"
|
|
128
|
+
bind:files
|
|
129
|
+
bind:this={input}
|
|
130
|
+
{id}
|
|
131
|
+
class={twMerge(
|
|
132
|
+
"form-input",
|
|
133
|
+
"block border-0 w-full !text-sm",
|
|
134
|
+
"file:rounded file:border-0 file:mr-4 file:bg-neutral-200",
|
|
135
|
+
"file:px-2 file:py-0.5 file:cursor-pointer file:text-sm",
|
|
136
|
+
"focus-visible:ring-0 focus:ring-0 focus:leading-0",
|
|
137
|
+
renderSize,
|
|
138
|
+
classInput
|
|
139
|
+
)}
|
|
140
|
+
use:highlightDragover={() => ({ classes: ["outline-dashed"] })}
|
|
141
|
+
use:validateAction={() => ({
|
|
142
|
+
enabled: !!validate,
|
|
143
|
+
...(typeof validate === "boolean" ? {} : validate),
|
|
144
|
+
setValidationResult,
|
|
145
|
+
})}
|
|
146
|
+
{multiple}
|
|
147
|
+
{tabindex}
|
|
148
|
+
{required}
|
|
149
|
+
{disabled}
|
|
150
|
+
{...rest}
|
|
151
|
+
/>
|
|
152
|
+
{#if (files?.length || 0) > 1}
|
|
153
|
+
<ul
|
|
154
|
+
class={twMerge(
|
|
155
|
+
"px-2.5 pb-2.5 pt-1 text-sm opacity-80",
|
|
156
|
+
"space-y-1 list-decimal list-inside",
|
|
157
|
+
classFileList
|
|
158
|
+
)}
|
|
159
|
+
>
|
|
160
|
+
{#each files || [] as f}
|
|
161
|
+
<li>{f.name}</li>
|
|
162
|
+
{/each}
|
|
163
|
+
</ul>
|
|
164
|
+
{/if}
|
|
165
|
+
</div>
|
|
166
|
+
</InputWrap>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLInputAttributes } 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 HTMLInputAttributes, Record<string, any> {
|
|
9
|
+
input?: HTMLInputElement;
|
|
10
|
+
files?: FileList;
|
|
11
|
+
multiple?: boolean;
|
|
12
|
+
label?: SnippetWithId | THC;
|
|
13
|
+
description?: SnippetWithId | THC;
|
|
14
|
+
class?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
tabindex?: number;
|
|
17
|
+
renderSize?: "sm" | "md" | "lg" | 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
|
+
classFileList?: string;
|
|
37
|
+
style?: string;
|
|
38
|
+
}
|
|
39
|
+
declare const FieldFile: import("svelte").Component<Props, {}, "input" | "files">;
|
|
40
|
+
type FieldFile = ReturnType<typeof FieldFile>;
|
|
41
|
+
export default FieldFile;
|