@marianmeres/stuic 1.126.0 → 2.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -8
- package/dist/_shared.css +2 -0
- package/dist/actions/autogrow.svelte.d.ts +6 -0
- package/dist/actions/autogrow.svelte.js +19 -0
- package/dist/actions/highlight-dragover.svelte.d.ts +7 -0
- package/dist/actions/highlight-dragover.svelte.js +38 -0
- package/dist/actions/index.d.ts +7 -0
- package/dist/actions/index.js +7 -0
- package/dist/actions/on-submit-validity-check.svelte.d.ts +15 -0
- package/dist/actions/on-submit-validity-check.svelte.js +58 -0
- package/dist/actions/tooltip/index.css +34 -0
- package/dist/actions/tooltip/tooltip.svelte.d.ts +13 -0
- package/dist/actions/tooltip/tooltip.svelte.js +203 -0
- package/dist/actions/trim.svelte.d.ts +4 -0
- package/dist/actions/trim.svelte.js +17 -0
- package/dist/actions/{validate.d.ts → validate.svelte.d.ts} +8 -8
- package/dist/actions/validate.svelte.js +90 -0
- package/dist/components/AlertConfirmPrompt/AlertConfirmPrompt.svelte +59 -385
- package/dist/components/AlertConfirmPrompt/AlertConfirmPrompt.svelte.d.ts +9 -101
- package/dist/components/AlertConfirmPrompt/Current.svelte +202 -0
- package/dist/components/AlertConfirmPrompt/Current.svelte.d.ts +22 -0
- package/dist/components/AlertConfirmPrompt/acp-icons.d.ts +7 -2
- package/dist/components/AlertConfirmPrompt/acp-icons.js +8 -8
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.d.ts +63 -0
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.js +144 -0
- package/dist/components/AlertConfirmPrompt/index.d.ts +2 -0
- package/dist/components/AlertConfirmPrompt/index.js +2 -0
- package/dist/components/AnimatedElipsis/AnimatedEllipsis.svelte +47 -0
- package/dist/components/AnimatedElipsis/AnimatedEllipsis.svelte.d.ts +7 -0
- package/dist/components/AnimatedElipsis/index.d.ts +1 -0
- package/dist/components/AnimatedElipsis/index.js +1 -0
- package/dist/components/AppShell/AppShell.svelte +188 -127
- package/dist/components/AppShell/AppShell.svelte.d.ts +62 -43
- package/dist/components/AppShell/index.d.ts +1 -0
- package/dist/components/AppShell/index.js +1 -0
- package/dist/components/Backdrop/Backdrop.svelte +149 -49
- package/dist/components/Backdrop/Backdrop.svelte.d.ts +22 -37
- package/dist/components/Backdrop/index.d.ts +1 -0
- package/dist/components/Backdrop/index.js +1 -0
- package/dist/components/Button/Button.svelte +122 -146
- package/dist/components/Button/Button.svelte.d.ts +22 -80
- package/dist/components/Button/index.css +16 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/ColResize/ColResize.svelte +0 -0
- package/dist/components/ColResize/ColResize.svelte.d.ts +26 -0
- package/dist/components/ColorScheme/{LocalColorScheme.svelte → ColorSchemeLocal.svelte} +2 -2
- package/dist/components/ColorScheme/ColorSchemeLocal.svelte.d.ts +26 -0
- package/dist/components/ColorScheme/{SystemAwareColorScheme.svelte → ColorSchemeSystemAware.svelte} +4 -4
- package/dist/components/ColorScheme/ColorSchemeSystemAware.svelte.d.ts +26 -0
- package/dist/components/ColorScheme/color-scheme.d.ts +26 -8
- package/dist/components/ColorScheme/color-scheme.js +40 -16
- package/dist/components/ColorScheme/index.d.ts +3 -0
- package/dist/components/ColorScheme/index.js +3 -0
- package/dist/components/DismissibleMessage/DismissibleMessage.svelte +76 -83
- package/dist/components/DismissibleMessage/DismissibleMessage.svelte.d.ts +16 -37
- package/dist/components/DismissibleMessage/index.css +13 -0
- package/dist/components/DismissibleMessage/index.d.ts +1 -0
- package/dist/components/DismissibleMessage/index.js +1 -0
- package/dist/components/Drawer/Drawer.svelte +155 -84
- package/dist/components/Drawer/Drawer.svelte.d.ts +24 -35
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/Drawer/index.js +1 -0
- package/dist/components/HoverExpandableWidth/HoverExpandableWidth.svelte +150 -111
- package/dist/components/HoverExpandableWidth/HoverExpandableWidth.svelte.d.ts +16 -29
- package/dist/components/HoverExpandableWidth/index.d.ts +1 -0
- package/dist/components/HoverExpandableWidth/index.js +1 -0
- package/dist/components/Input/FieldCheckbox.svelte +174 -132
- package/dist/components/Input/FieldCheckbox.svelte.d.ts +28 -64
- package/dist/components/Input/FieldFile.svelte +166 -0
- package/dist/components/Input/FieldFile.svelte.d.ts +41 -0
- package/dist/components/Input/FieldInput.svelte +143 -0
- package/dist/components/Input/FieldInput.svelte.d.ts +41 -0
- package/dist/components/Input/FieldLikeButton.svelte +206 -0
- package/dist/components/Input/FieldLikeButton.svelte.d.ts +41 -0
- package/dist/components/Input/FieldOptions.svelte +646 -0
- package/dist/components/Input/FieldOptions.svelte.d.ts +58 -0
- package/dist/components/Input/FieldRadios.svelte +126 -77
- package/dist/components/Input/FieldRadios.svelte.d.ts +23 -61
- package/dist/components/Input/FieldSelect.svelte +160 -239
- package/dist/components/Input/FieldSelect.svelte.d.ts +40 -88
- package/dist/components/Input/FieldSwitch.svelte +132 -0
- package/dist/components/Input/FieldSwitch.svelte.d.ts +41 -0
- package/dist/components/Input/FieldTextarea.svelte +146 -0
- package/dist/components/Input/FieldTextarea.svelte.d.ts +44 -0
- package/dist/components/Input/Fieldset.svelte +21 -17
- package/dist/components/Input/Fieldset.svelte.d.ts +10 -27
- package/dist/components/Input/_internal/FieldRadioInternal.svelte +186 -0
- package/dist/components/Input/_internal/FieldRadioInternal.svelte.d.ts +30 -0
- package/dist/components/Input/_internal/InputWrap.svelte +216 -0
- package/dist/components/Input/_internal/InputWrap.svelte.d.ts +36 -0
- package/dist/components/Input/index.css +134 -0
- package/dist/components/Input/index.d.ts +11 -0
- package/dist/components/Input/index.js +11 -0
- package/dist/components/Input/types.d.ts +11 -0
- package/dist/components/KbdShortcut/KbdShortcut.svelte +89 -0
- package/dist/components/KbdShortcut/KbdShortcut.svelte.d.ts +17 -0
- package/dist/components/KbdShortcut/index.d.ts +1 -0
- package/dist/components/KbdShortcut/index.js +1 -0
- package/dist/components/Modal/Modal.svelte +127 -0
- package/dist/components/Modal/Modal.svelte.d.ts +32 -0
- package/dist/components/Modal/index.d.ts +1 -0
- package/dist/components/Modal/index.js +1 -0
- package/dist/components/ModalDialog/ModalDialog.svelte +137 -81
- package/dist/components/ModalDialog/ModalDialog.svelte.d.ts +17 -38
- package/dist/components/ModalDialog/index.d.ts +1 -0
- package/dist/components/ModalDialog/index.js +1 -0
- package/dist/components/Notifications/Notifications.svelte +259 -173
- package/dist/components/Notifications/Notifications.svelte.d.ts +32 -60
- package/dist/components/Notifications/index.css +12 -0
- package/dist/components/Notifications/index.d.ts +2 -0
- package/dist/components/Notifications/index.js +2 -0
- package/dist/components/Notifications/notifications-icons.d.ts +1 -1
- package/dist/components/Notifications/notifications-icons.js +4 -4
- package/dist/components/Notifications/notifications-stack.svelte.d.ts +89 -0
- package/dist/components/Notifications/notifications-stack.svelte.js +161 -0
- package/dist/components/Progress/Progress.svelte +26 -0
- package/dist/components/Progress/Progress.svelte.d.ts +10 -0
- package/dist/components/Progress/_internal/Bar.svelte +31 -0
- package/dist/components/Progress/_internal/Bar.svelte.d.ts +10 -0
- package/dist/components/Progress/_internal/Circle.svelte +10 -0
- package/dist/components/Progress/_internal/Circle.svelte.d.ts +7 -0
- package/dist/components/Progress/index.css +7 -0
- package/dist/components/Progress/index.d.ts +1 -0
- package/dist/components/Progress/index.js +1 -0
- package/dist/components/Spinner/Spinner.svelte +56 -41
- package/dist/components/Spinner/Spinner.svelte.d.ts +10 -22
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Spinner/index.js +1 -0
- package/dist/components/Switch/Switch.svelte +158 -118
- package/dist/components/Switch/Switch.svelte.d.ts +25 -66
- package/dist/components/Switch/SwitchButton.svelte +131 -0
- package/dist/components/Switch/SwitchButton.svelte.d.ts +21 -0
- package/dist/components/Switch/index.css +7 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/index.js +2 -0
- package/dist/components/Thc/Thc.svelte +67 -10
- package/dist/components/Thc/Thc.svelte.d.ts +18 -22
- package/dist/components/Thc/index.d.ts +1 -0
- package/dist/components/Thc/index.js +1 -0
- package/dist/components/TwCheck/TwCheck.svelte +34 -0
- package/dist/components/TwCheck/TwCheck.svelte.d.ts +10 -0
- package/dist/components/TwCheck/index.css +5 -0
- package/dist/components/TwCheck/index.d.ts +1 -0
- package/dist/components/TwCheck/index.js +1 -0
- package/dist/components/X/X.svelte +12 -5
- package/dist/components/X/X.svelte.d.ts +6 -18
- package/dist/components/X/index.d.ts +1 -0
- package/dist/components/X/index.js +1 -0
- package/dist/index.css +26 -0
- package/dist/index.d.ts +21 -39
- package/dist/index.js +23 -54
- package/dist/types.d.ts +251 -2
- package/dist/types.js +248 -0
- package/dist/utils/breakpoint.svelte.d.ts +19 -0
- package/dist/utils/breakpoint.svelte.js +42 -0
- package/dist/utils/debounce.d.ts +13 -0
- package/dist/utils/debounce.js +22 -0
- package/dist/utils/device-pointer.svelte.d.ts +11 -0
- package/dist/utils/device-pointer.svelte.js +26 -0
- package/dist/utils/event-modifiers.d.ts +4 -0
- package/dist/utils/event-modifiers.js +29 -0
- package/dist/utils/get-id.d.ts +1 -1
- package/dist/utils/get-id.js +3 -1
- package/dist/utils/index.d.ts +21 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/is-browser.d.ts +1 -0
- package/dist/utils/is-browser.js +5 -0
- package/dist/utils/is-mac.d.ts +1 -0
- package/dist/utils/is-mac.js +11 -0
- package/dist/utils/maybe-json-parse.d.ts +1 -0
- package/dist/utils/maybe-json-parse.js +12 -0
- package/dist/utils/maybe-json-stringify.d.ts +1 -0
- package/dist/utils/maybe-json-stringify.js +11 -0
- package/dist/utils/move-array-item.d.ts +4 -0
- package/dist/utils/move-array-item.js +20 -0
- package/dist/utils/omit-pick.d.ts +2 -2
- package/dist/utils/omit-pick.js +10 -8
- package/dist/utils/paint.d.ts +18 -0
- package/dist/utils/paint.js +32 -0
- package/dist/utils/persistent-state.svelte.d.ts +23 -0
- package/dist/utils/persistent-state.svelte.js +48 -0
- package/dist/utils/prefers-reduced-motion.svelte.d.ts +2 -0
- package/dist/utils/prefers-reduced-motion.svelte.js +4 -0
- package/dist/utils/qsa.d.ts +1 -0
- package/dist/utils/qsa.js +3 -0
- package/dist/utils/sleep.d.ts +28 -0
- package/dist/utils/sleep.js +33 -0
- package/dist/utils/storage-abstraction.d.ts +35 -0
- package/dist/utils/storage-abstraction.js +136 -0
- package/dist/utils/str-hash.d.ts +7 -0
- package/dist/utils/str-hash.js +35 -0
- package/dist/utils/throttle.d.ts +1 -0
- package/dist/utils/throttle.js +47 -0
- package/dist/utils/to-integer.d.ts +1 -0
- package/dist/utils/to-integer.js +11 -0
- package/dist/utils/tr.d.ts +5 -0
- package/dist/utils/tr.js +13 -0
- package/dist/utils/tw-merge.d.ts +10 -0
- package/dist/utils/tw-merge.js +16 -0
- package/dist/utils/ucfirst.d.ts +1 -0
- package/dist/utils/ucfirst.js +6 -0
- package/package.json +66 -73
- package/dist/actions/autogrow.d.ts +0 -8
- package/dist/actions/autogrow.js +0 -22
- package/dist/actions/drag-drop.d.ts +0 -28
- package/dist/actions/drag-drop.js +0 -152
- package/dist/actions/on-outside.d.ts +0 -9
- package/dist/actions/on-outside.js +0 -27
- package/dist/actions/pre-submit-validity-check.d.ts +0 -3
- package/dist/actions/pre-submit-validity-check.js +0 -21
- package/dist/actions/tooltip/_make-visible.d.ts +0 -3
- package/dist/actions/tooltip/_make-visible.js +0 -25
- package/dist/actions/tooltip/_maybe-pick-safe-placement.d.ts +0 -3
- package/dist/actions/tooltip/_maybe-pick-safe-placement.js +0 -86
- package/dist/actions/tooltip/_set-position.d.ts +0 -2
- package/dist/actions/tooltip/_set-position.js +0 -125
- package/dist/actions/tooltip/tooltip.d.ts +0 -42
- package/dist/actions/tooltip/tooltip.js +0 -299
- package/dist/actions/trim.d.ts +0 -4
- package/dist/actions/trim.js +0 -18
- package/dist/actions/validate.js +0 -80
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt.d.ts +0 -58
- package/dist/components/AlertConfirmPrompt/alert-confirm-prompt.js +0 -141
- package/dist/components/ColorScheme/LocalColorScheme.svelte.d.ts +0 -25
- package/dist/components/ColorScheme/SystemAwareColorScheme.svelte.d.ts +0 -25
- package/dist/components/Input/Field.svelte +0 -315
- package/dist/components/Input/Field.svelte.d.ts +0 -102
- package/dist/components/Input/PinInput.svelte +0 -151
- package/dist/components/Input/PinInput.svelte.d.ts +0 -51
- package/dist/components/Input/XFieldRadioInternal.svelte +0 -143
- package/dist/components/Input/XFieldRadioInternal.svelte.d.ts +0 -45
- package/dist/components/Notifications/notifications.d.ts +0 -78
- package/dist/components/Notifications/notifications.js +0 -215
- package/dist/components/Popover/Popover.svelte +0 -24
- package/dist/components/Popover/Popover.svelte.d.ts +0 -22
- package/dist/components/Spinner/Spinner.v5.svelte +0 -114
- package/dist/components/Spinner/Spinner.v5.svelte.d.ts +0 -16
- package/dist/utils/calculate-alignment.d.ts +0 -68
- package/dist/utils/calculate-alignment.js +0 -183
- package/dist/utils/device-pointer.d.ts +0 -5
- package/dist/utils/device-pointer.js +0 -10
- package/dist/utils/prefers-reduced-motion.d.ts +0 -6
- package/dist/utils/prefers-reduced-motion.js +0 -26
- package/dist/utils/tw-merge2.d.ts +0 -3
- package/dist/utils/tw-merge2.js +0 -9
- package/dist/utils/tw-types.d.ts +0 -1
- package/dist/utils/window-size.d.ts +0 -22
- package/dist/utils/window-size.js +0 -35
- /package/dist/{utils/tw-types.js → components/Input/types.js} +0 -0
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
<script context="module">import { createClog } from "@marianmeres/clog";
|
|
2
|
-
import { createEventDispatcher } from "svelte";
|
|
3
|
-
import { slide } from "svelte/transition";
|
|
4
|
-
import { autogrow } from "../../actions/autogrow.js";
|
|
5
|
-
import { trim } from "../../actions/trim.js";
|
|
6
|
-
import { validate as validateAction } from "../../actions/validate.js";
|
|
7
|
-
import { getId } from "../../utils/get-id.js";
|
|
8
|
-
import Thc from "../Thc/Thc.svelte";
|
|
9
|
-
const _emptyClasses = () => ({
|
|
10
|
-
box: "",
|
|
11
|
-
wrap: "",
|
|
12
|
-
label: "",
|
|
13
|
-
input: "",
|
|
14
|
-
invalid: "",
|
|
15
|
-
validationMessage: "",
|
|
16
|
-
description: "",
|
|
17
|
-
below: "",
|
|
18
|
-
asterix: ""
|
|
19
|
-
});
|
|
20
|
-
const _PRESET = {
|
|
21
|
-
box: "mb-4 grid",
|
|
22
|
-
// gap-4
|
|
23
|
-
wrap: `
|
|
24
|
-
rounded-md border border-neutral-300 dark:border-neutral-600
|
|
25
|
-
bg-neutral-100 dark:bg-neutral-700
|
|
26
|
-
focus-within:border-stuic-primary
|
|
27
|
-
focus-within:ring-4
|
|
28
|
-
focus-within:ring-stuic-primary
|
|
29
|
-
focus-within:ring-opacity-20
|
|
30
|
-
`,
|
|
31
|
-
label: `block flex-1 px-2 mb-1`,
|
|
32
|
-
//
|
|
33
|
-
input: `
|
|
34
|
-
rounded-md border-0 w-full flex-1
|
|
35
|
-
bg-transparent
|
|
36
|
-
tracking-tight
|
|
37
|
-
focus:outline-0 focus-visible:ring-0
|
|
38
|
-
placeholder:tracking-tight
|
|
39
|
-
placeholder:text-neutral-950/35 dark:placeholder:text-neutral-50/35
|
|
40
|
-
text-neutral-950 dark:text-neutral-50
|
|
41
|
-
`,
|
|
42
|
-
invalid: `border-stuic-primary`,
|
|
43
|
-
validationMessage: `my-1 text-xs text-stuic-primary px-2 tracking-tight`,
|
|
44
|
-
description: `mx-2 mt-1 text-sm opacity-50`,
|
|
45
|
-
below: `mx-2 my-1`,
|
|
46
|
-
asterix: `after:content-['*'] after:opacity-30 after:pl-1`
|
|
47
|
-
};
|
|
48
|
-
const _PRESET_BY_SIZE = {
|
|
49
|
-
sm: {
|
|
50
|
-
label: "text-sm",
|
|
51
|
-
input: "text-sm placeholder:text-sm"
|
|
52
|
-
},
|
|
53
|
-
md: {
|
|
54
|
-
label: "text-base",
|
|
55
|
-
input: "text-base placeholder:text-base"
|
|
56
|
-
},
|
|
57
|
-
lg: {
|
|
58
|
-
label: "text-base font-bold",
|
|
59
|
-
input: "text-lg placeholder:text-lg"
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
export class FieldConfig {
|
|
63
|
-
//
|
|
64
|
-
static class = _emptyClasses();
|
|
65
|
-
static classBySize = {
|
|
66
|
-
sm: _emptyClasses(),
|
|
67
|
-
md: _emptyClasses(),
|
|
68
|
-
lg: _emptyClasses()
|
|
69
|
-
};
|
|
70
|
-
static labelLeft = false;
|
|
71
|
-
static labelLeftWidth = "normal";
|
|
72
|
-
//
|
|
73
|
-
static _preset = _PRESET;
|
|
74
|
-
static _presetBySize = _PRESET_BY_SIZE;
|
|
75
|
-
}
|
|
76
|
-
</script>
|
|
77
|
-
|
|
78
|
-
<script>import { twMerge2 } from "../../utils/tw-merge2.js";
|
|
79
|
-
import PinInput from "./PinInput.svelte";
|
|
80
|
-
const clog = createClog("Field");
|
|
81
|
-
const dispatch = createEventDispatcher();
|
|
82
|
-
const setType = (el, t) => el.type = t;
|
|
83
|
-
let _class = {};
|
|
84
|
-
export { _class as class };
|
|
85
|
-
export let classBySize = {};
|
|
86
|
-
export let size = "md";
|
|
87
|
-
export let id = getId();
|
|
88
|
-
export let value;
|
|
89
|
-
export let label = "";
|
|
90
|
-
export let type = "text";
|
|
91
|
-
export let name = "";
|
|
92
|
-
export let tabindex = 0;
|
|
93
|
-
export let description = "";
|
|
94
|
-
export let autofocus = void 0;
|
|
95
|
-
export let disabled = false;
|
|
96
|
-
export let readonly = false;
|
|
97
|
-
export let required = false;
|
|
98
|
-
export let placeholder = void 0;
|
|
99
|
-
export let autocomplete = void 0;
|
|
100
|
-
export let minlength = void 0;
|
|
101
|
-
export let maxlength = void 0;
|
|
102
|
-
export let min = void 0;
|
|
103
|
-
export let max = void 0;
|
|
104
|
-
export let pattern = void 0;
|
|
105
|
-
export let step = void 0;
|
|
106
|
-
export let useTrim = true;
|
|
107
|
-
export let textareaAutoEnlarge = true;
|
|
108
|
-
export let labelLeft = FieldConfig.labelLeft;
|
|
109
|
-
export let labelLeftWidth = FieldConfig.labelLeftWidth;
|
|
110
|
-
export let validate = void 0;
|
|
111
|
-
export let showAsterixOnRequired = true;
|
|
112
|
-
let validation;
|
|
113
|
-
const setValidationResult = (res) => validation = res;
|
|
114
|
-
let _inputEl;
|
|
115
|
-
$:
|
|
116
|
-
if (_inputEl)
|
|
117
|
-
dispatch("input_mounted", _inputEl);
|
|
118
|
-
const _collectClasses = (k, extra = "") => [
|
|
119
|
-
_PRESET?.[k] || "",
|
|
120
|
-
_PRESET_BY_SIZE?.[size]?.[k] || "",
|
|
121
|
-
FieldConfig?.class?.[k] || "",
|
|
122
|
-
FieldConfig?.classBySize?.[size]?.[k] || "",
|
|
123
|
-
extra || "",
|
|
124
|
-
_class?.[k] || "",
|
|
125
|
-
classBySize?.[size]?.[k] || ""
|
|
126
|
-
].join(" ");
|
|
127
|
-
$:
|
|
128
|
-
_boxClass = twMerge2(_collectClasses("box"));
|
|
129
|
-
$:
|
|
130
|
-
_labelClass = twMerge2(
|
|
131
|
-
_collectClasses(
|
|
132
|
-
"label",
|
|
133
|
-
showAsterixOnRequired && required ? _collectClasses("asterix") : ""
|
|
134
|
-
)
|
|
135
|
-
);
|
|
136
|
-
$:
|
|
137
|
-
_wrapClass = twMerge2(
|
|
138
|
-
_collectClasses(
|
|
139
|
-
"wrap",
|
|
140
|
-
validation && !validation.valid ? _collectClasses("invalid") : ""
|
|
141
|
-
)
|
|
142
|
-
);
|
|
143
|
-
$:
|
|
144
|
-
_inputClass = twMerge2(
|
|
145
|
-
"form-input",
|
|
146
|
-
type === "textarea" ? "min-h-16" : "",
|
|
147
|
-
_collectClasses("input")
|
|
148
|
-
);
|
|
149
|
-
$:
|
|
150
|
-
_validationMessageClass = twMerge2(_collectClasses("validationMessage"));
|
|
151
|
-
$:
|
|
152
|
-
_descriptionClass = twMerge2(_collectClasses("description"));
|
|
153
|
-
$:
|
|
154
|
-
_belowClass = twMerge2(_collectClasses("below"));
|
|
155
|
-
</script>
|
|
156
|
-
|
|
157
|
-
<div
|
|
158
|
-
class={_boxClass}
|
|
159
|
-
class:grid-cols-4={labelLeft && labelLeftWidth === 'normal'}
|
|
160
|
-
class:grid-cols-3={labelLeft && labelLeftWidth === 'wide'}
|
|
161
|
-
>
|
|
162
|
-
<div
|
|
163
|
-
class="flex"
|
|
164
|
-
class:items-end={!labelLeft}
|
|
165
|
-
class:items-start={labelLeft}
|
|
166
|
-
class:mt-1={labelLeft}
|
|
167
|
-
>
|
|
168
|
-
{#if label || $$slots.label}
|
|
169
|
-
<label for={id} class={_labelClass} class:required>
|
|
170
|
-
{#if $$slots.label}
|
|
171
|
-
<slot name="label" />
|
|
172
|
-
{:else}
|
|
173
|
-
<Thc thc={label} forceAsHtml />
|
|
174
|
-
{/if}
|
|
175
|
-
</label>
|
|
176
|
-
{/if}
|
|
177
|
-
<slot name="right_of_label" />
|
|
178
|
-
</div>
|
|
179
|
-
<div
|
|
180
|
-
class:col-span-3={labelLeft && labelLeftWidth === 'normal'}
|
|
181
|
-
class:col-span-2={labelLeft && labelLeftWidth === 'wide'}
|
|
182
|
-
>
|
|
183
|
-
<div
|
|
184
|
-
class={_wrapClass}
|
|
185
|
-
class:cursor-not-allowed={disabled}
|
|
186
|
-
class:opacity-50={disabled}
|
|
187
|
-
>
|
|
188
|
-
<div class="flex">
|
|
189
|
-
<slot name="input_before" {id} />
|
|
190
|
-
{#if type === 'textarea'}
|
|
191
|
-
<textarea
|
|
192
|
-
bind:value
|
|
193
|
-
bind:this={_inputEl}
|
|
194
|
-
{id}
|
|
195
|
-
class={_inputClass}
|
|
196
|
-
class:cursor-not-allowed={disabled}
|
|
197
|
-
{name}
|
|
198
|
-
{placeholder}
|
|
199
|
-
{disabled}
|
|
200
|
-
{readonly}
|
|
201
|
-
{required}
|
|
202
|
-
{autofocus}
|
|
203
|
-
{tabindex}
|
|
204
|
-
use:trim={useTrim}
|
|
205
|
-
use:validateAction={validate
|
|
206
|
-
? { ...(validate === true ? {} : validate), setValidationResult }
|
|
207
|
-
: undefined}
|
|
208
|
-
use:autogrow={{ allowed: textareaAutoEnlarge }}
|
|
209
|
-
on:blur
|
|
210
|
-
on:change
|
|
211
|
-
on:click
|
|
212
|
-
on:focus
|
|
213
|
-
on:input
|
|
214
|
-
on:keydown
|
|
215
|
-
on:keyup
|
|
216
|
-
on:touchstart|passive
|
|
217
|
-
on:touchend|passive
|
|
218
|
-
on:touchmove|passive
|
|
219
|
-
on:touchcancel
|
|
220
|
-
on:mouseenter
|
|
221
|
-
on:mouseleave
|
|
222
|
-
{...$$restProps}
|
|
223
|
-
></textarea>
|
|
224
|
-
{:else if type === 'pin'}
|
|
225
|
-
<PinInput
|
|
226
|
-
bind:value
|
|
227
|
-
inputClass={_inputClass}
|
|
228
|
-
on:input_mounted
|
|
229
|
-
{id}
|
|
230
|
-
{name}
|
|
231
|
-
{disabled}
|
|
232
|
-
{readonly}
|
|
233
|
-
{required}
|
|
234
|
-
{autofocus}
|
|
235
|
-
{tabindex}
|
|
236
|
-
{placeholder}
|
|
237
|
-
{pattern}
|
|
238
|
-
{setValidationResult}
|
|
239
|
-
bind:validate
|
|
240
|
-
on:blur
|
|
241
|
-
on:change
|
|
242
|
-
on:click
|
|
243
|
-
on:focus
|
|
244
|
-
on:input
|
|
245
|
-
on:keydown
|
|
246
|
-
on:keyup
|
|
247
|
-
on:touchstart
|
|
248
|
-
on:touchend
|
|
249
|
-
on:touchmove
|
|
250
|
-
on:touchcancel
|
|
251
|
-
on:mouseenter
|
|
252
|
-
on:mouseleave
|
|
253
|
-
{...$$restProps}
|
|
254
|
-
/>
|
|
255
|
-
{:else}
|
|
256
|
-
<input
|
|
257
|
-
bind:value
|
|
258
|
-
bind:this={_inputEl}
|
|
259
|
-
use:setType={type}
|
|
260
|
-
{id}
|
|
261
|
-
class={_inputClass}
|
|
262
|
-
class:cursor-not-allowed={disabled}
|
|
263
|
-
{name}
|
|
264
|
-
{placeholder}
|
|
265
|
-
{disabled}
|
|
266
|
-
{readonly}
|
|
267
|
-
{required}
|
|
268
|
-
{autofocus}
|
|
269
|
-
{autocomplete}
|
|
270
|
-
{tabindex}
|
|
271
|
-
{minlength}
|
|
272
|
-
{maxlength}
|
|
273
|
-
{min}
|
|
274
|
-
{max}
|
|
275
|
-
{pattern}
|
|
276
|
-
{step}
|
|
277
|
-
use:trim={useTrim}
|
|
278
|
-
use:validateAction={validate
|
|
279
|
-
? { ...(validate === true ? {} : validate), setValidationResult }
|
|
280
|
-
: undefined}
|
|
281
|
-
on:blur
|
|
282
|
-
on:change
|
|
283
|
-
on:click
|
|
284
|
-
on:focus
|
|
285
|
-
on:input
|
|
286
|
-
on:keydown
|
|
287
|
-
on:keyup
|
|
288
|
-
on:touchstart|passive
|
|
289
|
-
on:touchend|passive
|
|
290
|
-
on:touchmove|passive
|
|
291
|
-
on:touchcancel
|
|
292
|
-
on:mouseenter
|
|
293
|
-
on:mouseleave
|
|
294
|
-
{...$$restProps}
|
|
295
|
-
/>
|
|
296
|
-
{/if}
|
|
297
|
-
<slot name="input_after" {id} />
|
|
298
|
-
</div>
|
|
299
|
-
<slot name="input_below" {id} />
|
|
300
|
-
</div>
|
|
301
|
-
{#if validation && !validation?.valid}
|
|
302
|
-
<div transition:slide={{ duration: 150 }} class={_validationMessageClass}>
|
|
303
|
-
{@html validation.message}
|
|
304
|
-
</div>
|
|
305
|
-
{/if}
|
|
306
|
-
{#if description}
|
|
307
|
-
<div class={_descriptionClass}>
|
|
308
|
-
<Thc thc={description} forceAsHtml />
|
|
309
|
-
</div>
|
|
310
|
-
{/if}
|
|
311
|
-
{#if $$slots.below}
|
|
312
|
-
<div class={_belowClass}><slot name="below" {id} /></div>
|
|
313
|
-
{/if}
|
|
314
|
-
</div>
|
|
315
|
-
</div>
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { ValidateOptions } from '../../actions/validate.js';
|
|
3
|
-
import type { THC } from '../Thc/Thc.svelte';
|
|
4
|
-
export interface FieldConfigClasses {
|
|
5
|
-
box?: string;
|
|
6
|
-
wrap?: string;
|
|
7
|
-
label?: string;
|
|
8
|
-
input?: string;
|
|
9
|
-
invalid?: string;
|
|
10
|
-
validationMessage?: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
below?: string;
|
|
13
|
-
asterix?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface FieldConfigClassesBySize {
|
|
16
|
-
sm?: FieldConfigClasses;
|
|
17
|
-
md?: FieldConfigClasses;
|
|
18
|
-
lg?: FieldConfigClasses;
|
|
19
|
-
}
|
|
20
|
-
export declare class FieldConfig {
|
|
21
|
-
static class: FieldConfigClasses;
|
|
22
|
-
static classBySize: FieldConfigClassesBySize;
|
|
23
|
-
static labelLeft: boolean;
|
|
24
|
-
static labelLeftWidth: 'normal' | 'wide';
|
|
25
|
-
static readonly _preset: FieldConfigClasses;
|
|
26
|
-
static readonly _presetBySize: FieldConfigClassesBySize;
|
|
27
|
-
}
|
|
28
|
-
declare const __propDef: {
|
|
29
|
-
props: {
|
|
30
|
-
[x: string]: any;
|
|
31
|
-
class?: FieldConfigClasses | undefined;
|
|
32
|
-
classBySize?: FieldConfigClassesBySize | undefined;
|
|
33
|
-
size?: "sm" | "md" | "lg" | undefined;
|
|
34
|
-
id?: string | undefined;
|
|
35
|
-
value: string;
|
|
36
|
-
label?: THC | undefined;
|
|
37
|
-
type?: string | undefined;
|
|
38
|
-
name?: string | undefined;
|
|
39
|
-
tabindex?: number | undefined;
|
|
40
|
-
description?: THC | undefined;
|
|
41
|
-
autofocus?: true | undefined | undefined;
|
|
42
|
-
disabled?: boolean | undefined;
|
|
43
|
-
readonly?: boolean | undefined;
|
|
44
|
-
required?: boolean | undefined;
|
|
45
|
-
placeholder?: string | undefined | undefined;
|
|
46
|
-
autocomplete?: string | undefined | undefined;
|
|
47
|
-
minlength?: number | undefined | undefined;
|
|
48
|
-
maxlength?: number | undefined | undefined;
|
|
49
|
-
min?: number | undefined | undefined;
|
|
50
|
-
max?: number | undefined | undefined;
|
|
51
|
-
pattern?: string | undefined | undefined;
|
|
52
|
-
step?: number | undefined | undefined;
|
|
53
|
-
useTrim?: boolean | undefined;
|
|
54
|
-
textareaAutoEnlarge?: boolean | undefined;
|
|
55
|
-
labelLeft?: boolean | undefined;
|
|
56
|
-
labelLeftWidth?: "normal" | "wide" | undefined;
|
|
57
|
-
validate?: true | ValidateOptions | undefined;
|
|
58
|
-
showAsterixOnRequired?: boolean | undefined;
|
|
59
|
-
};
|
|
60
|
-
events: {
|
|
61
|
-
blur: FocusEvent;
|
|
62
|
-
change: Event;
|
|
63
|
-
click: MouseEvent;
|
|
64
|
-
focus: FocusEvent;
|
|
65
|
-
input: Event;
|
|
66
|
-
keydown: KeyboardEvent;
|
|
67
|
-
keyup: KeyboardEvent;
|
|
68
|
-
touchstart: TouchEvent;
|
|
69
|
-
touchend: TouchEvent;
|
|
70
|
-
touchmove: TouchEvent;
|
|
71
|
-
touchcancel: TouchEvent;
|
|
72
|
-
mouseenter: MouseEvent;
|
|
73
|
-
mouseleave: MouseEvent;
|
|
74
|
-
input_mounted: CustomEvent<any>;
|
|
75
|
-
} & {
|
|
76
|
-
[evt: string]: CustomEvent<any>;
|
|
77
|
-
};
|
|
78
|
-
slots: {
|
|
79
|
-
label: {};
|
|
80
|
-
right_of_label: {};
|
|
81
|
-
input_before: {
|
|
82
|
-
id: string;
|
|
83
|
-
};
|
|
84
|
-
input_after: {
|
|
85
|
-
id: string;
|
|
86
|
-
};
|
|
87
|
-
input_below: {
|
|
88
|
-
id: string;
|
|
89
|
-
};
|
|
90
|
-
below: {
|
|
91
|
-
id: string;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
exports?: undefined;
|
|
95
|
-
bindings?: undefined;
|
|
96
|
-
};
|
|
97
|
-
export type FieldProps = typeof __propDef.props;
|
|
98
|
-
export type FieldEvents = typeof __propDef.events;
|
|
99
|
-
export type FieldSlots = typeof __propDef.slots;
|
|
100
|
-
export default class Field extends SvelteComponent<FieldProps, FieldEvents, FieldSlots> {
|
|
101
|
-
}
|
|
102
|
-
export {};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
<script>import { createClog } from "@marianmeres/clog";
|
|
2
|
-
import { iconBsEye } from "@marianmeres/icons-fns/bootstrap/iconBsEye.js";
|
|
3
|
-
import { iconBsEyeSlash } from "@marianmeres/icons-fns/bootstrap/iconBsEyeSlash.js";
|
|
4
|
-
import { iconBsX } from "@marianmeres/icons-fns/bootstrap/iconBsX.js";
|
|
5
|
-
import { createEventDispatcher } from "svelte";
|
|
6
|
-
import { trim } from "../../actions/trim.js";
|
|
7
|
-
import { validate as validateAction } from "../../actions/validate.js";
|
|
8
|
-
import { getId } from "../../utils/get-id.js";
|
|
9
|
-
import { twMerge2 } from "../../utils/tw-merge2.js";
|
|
10
|
-
const dispatch = createEventDispatcher();
|
|
11
|
-
const clog = createClog("PinInput");
|
|
12
|
-
export let tabindex = 0;
|
|
13
|
-
export let id = getId();
|
|
14
|
-
export let name;
|
|
15
|
-
export let value;
|
|
16
|
-
export let inputClass;
|
|
17
|
-
export let placeholder;
|
|
18
|
-
export let length = 4;
|
|
19
|
-
export let pattern = void 0;
|
|
20
|
-
export let autofocus = void 0;
|
|
21
|
-
export let disabled = false;
|
|
22
|
-
export let readonly = false;
|
|
23
|
-
export let required = false;
|
|
24
|
-
export let validate = void 0;
|
|
25
|
-
export let setValidationResult;
|
|
26
|
-
export let masked = false;
|
|
27
|
-
let _unmasked = false;
|
|
28
|
-
export let showX = false;
|
|
29
|
-
export let pinCellClass = "";
|
|
30
|
-
let _inputEl;
|
|
31
|
-
$:
|
|
32
|
-
if (_inputEl)
|
|
33
|
-
dispatch("input_mounted", _inputEl);
|
|
34
|
-
$:
|
|
35
|
-
if (length < 2)
|
|
36
|
-
length = 2;
|
|
37
|
-
$:
|
|
38
|
-
if (length > 12)
|
|
39
|
-
length = 12;
|
|
40
|
-
$:
|
|
41
|
-
if (value.length > length)
|
|
42
|
-
value = value.slice(0, length);
|
|
43
|
-
$:
|
|
44
|
-
_chars = value.split("").slice(0, length).map((c) => {
|
|
45
|
-
return masked && !_unmasked ? "*" : c;
|
|
46
|
-
});
|
|
47
|
-
$:
|
|
48
|
-
_cells = new Array(length);
|
|
49
|
-
let w = 0;
|
|
50
|
-
const gridCols = [
|
|
51
|
-
"grid-cols-2",
|
|
52
|
-
"grid-cols-3",
|
|
53
|
-
"grid-cols-4",
|
|
54
|
-
"grid-cols-5",
|
|
55
|
-
"grid-cols-6",
|
|
56
|
-
"grid-cols-7",
|
|
57
|
-
"grid-cols-8",
|
|
58
|
-
"grid-cols-9",
|
|
59
|
-
"grid-cols-10",
|
|
60
|
-
"grid-cols-11",
|
|
61
|
-
"grid-cols-12"
|
|
62
|
-
];
|
|
63
|
-
</script>
|
|
64
|
-
|
|
65
|
-
<div class="relative w-full">
|
|
66
|
-
<div class="absolute inset-0 grid {gridCols[length - 2]} pointer-events-none p-1 gap-1">
|
|
67
|
-
{#each _cells as c, idx (idx)}
|
|
68
|
-
<div
|
|
69
|
-
class={twMerge2(
|
|
70
|
-
'flex items-center justify-center rounded bg-neutral-950/10 font-mono',
|
|
71
|
-
pinCellClass
|
|
72
|
-
)}
|
|
73
|
-
>
|
|
74
|
-
{#if _chars[idx]}
|
|
75
|
-
<span class="">{_chars[idx] || ''}</span>
|
|
76
|
-
{:else if !_chars.length}
|
|
77
|
-
<span class="opacity-25">{placeholder?.[idx] || ''}</span>
|
|
78
|
-
{/if}
|
|
79
|
-
</div>
|
|
80
|
-
{/each}
|
|
81
|
-
</div>
|
|
82
|
-
<div class="aboslute inset-0" bind:clientWidth={w}>
|
|
83
|
-
<input
|
|
84
|
-
bind:value
|
|
85
|
-
bind:this={_inputEl}
|
|
86
|
-
{id}
|
|
87
|
-
type="text"
|
|
88
|
-
spellcheck="false"
|
|
89
|
-
class={twMerge2(
|
|
90
|
-
'caret-neutral-950',
|
|
91
|
-
inputClass,
|
|
92
|
-
`font-mono text-transparent dark:text-transparent`
|
|
93
|
-
)}
|
|
94
|
-
class:cursor-not-allowed={disabled}
|
|
95
|
-
style="
|
|
96
|
-
padding-left: {100 / length / 2}%;
|
|
97
|
-
padding-right: {100 / length / 2}%;
|
|
98
|
-
letter-spacing: calc({w / length}px - 1ch);
|
|
99
|
-
"
|
|
100
|
-
{name}
|
|
101
|
-
minlength={length}
|
|
102
|
-
maxlength={length}
|
|
103
|
-
{disabled}
|
|
104
|
-
{readonly}
|
|
105
|
-
{required}
|
|
106
|
-
{autofocus}
|
|
107
|
-
{tabindex}
|
|
108
|
-
{pattern}
|
|
109
|
-
use:trim
|
|
110
|
-
use:validateAction={validate
|
|
111
|
-
? { ...(validate === true ? {} : validate), setValidationResult }
|
|
112
|
-
: undefined}
|
|
113
|
-
on:blur
|
|
114
|
-
on:change
|
|
115
|
-
on:click
|
|
116
|
-
on:focus
|
|
117
|
-
on:input
|
|
118
|
-
on:keydown
|
|
119
|
-
on:keyup
|
|
120
|
-
on:touchstart|passive
|
|
121
|
-
on:touchend|passive
|
|
122
|
-
on:touchmove|passive
|
|
123
|
-
on:touchcancel
|
|
124
|
-
on:mouseenter
|
|
125
|
-
on:mouseleave
|
|
126
|
-
{...$$restProps}
|
|
127
|
-
/>
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
130
|
-
{#if showX || masked}
|
|
131
|
-
<div class="flex items-center justify-center mr-1">
|
|
132
|
-
{#if showX}
|
|
133
|
-
<button type="button" class="p-2" on:click={() => (value = '')}>
|
|
134
|
-
{@html iconBsX()}
|
|
135
|
-
</button>
|
|
136
|
-
{/if}
|
|
137
|
-
{#if masked}
|
|
138
|
-
<button
|
|
139
|
-
type="button"
|
|
140
|
-
class="p-2 focus:outline-0"
|
|
141
|
-
on:click={() => (_unmasked = !_unmasked)}
|
|
142
|
-
>
|
|
143
|
-
{#if _unmasked}
|
|
144
|
-
{@html iconBsEye()}
|
|
145
|
-
{:else}
|
|
146
|
-
{@html iconBsEyeSlash()}
|
|
147
|
-
{/if}
|
|
148
|
-
</button>
|
|
149
|
-
{/if}
|
|
150
|
-
</div>
|
|
151
|
-
{/if}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { ValidateOptions } from '../../actions/validate.js';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
[x: string]: any;
|
|
6
|
-
tabindex?: number | undefined;
|
|
7
|
-
id?: string | undefined;
|
|
8
|
-
name: string;
|
|
9
|
-
value: string;
|
|
10
|
-
inputClass: string;
|
|
11
|
-
placeholder: string | undefined;
|
|
12
|
-
length?: number | undefined;
|
|
13
|
-
pattern?: string | undefined | undefined;
|
|
14
|
-
autofocus?: true | undefined | undefined;
|
|
15
|
-
disabled?: boolean | undefined;
|
|
16
|
-
readonly?: boolean | undefined;
|
|
17
|
-
required?: boolean | undefined;
|
|
18
|
-
validate?: true | ValidateOptions | undefined;
|
|
19
|
-
setValidationResult: any;
|
|
20
|
-
masked?: boolean | undefined;
|
|
21
|
-
showX?: boolean | undefined;
|
|
22
|
-
pinCellClass?: string | undefined;
|
|
23
|
-
};
|
|
24
|
-
events: {
|
|
25
|
-
blur: FocusEvent;
|
|
26
|
-
change: Event;
|
|
27
|
-
click: MouseEvent;
|
|
28
|
-
focus: FocusEvent;
|
|
29
|
-
input: Event;
|
|
30
|
-
keydown: KeyboardEvent;
|
|
31
|
-
keyup: KeyboardEvent;
|
|
32
|
-
touchstart: TouchEvent;
|
|
33
|
-
touchend: TouchEvent;
|
|
34
|
-
touchmove: TouchEvent;
|
|
35
|
-
touchcancel: TouchEvent;
|
|
36
|
-
mouseenter: MouseEvent;
|
|
37
|
-
mouseleave: MouseEvent;
|
|
38
|
-
input_mounted: CustomEvent<any>;
|
|
39
|
-
} & {
|
|
40
|
-
[evt: string]: CustomEvent<any>;
|
|
41
|
-
};
|
|
42
|
-
slots: {};
|
|
43
|
-
exports?: undefined;
|
|
44
|
-
bindings?: undefined;
|
|
45
|
-
};
|
|
46
|
-
export type PinInputProps = typeof __propDef.props;
|
|
47
|
-
export type PinInputEvents = typeof __propDef.events;
|
|
48
|
-
export type PinInputSlots = typeof __propDef.slots;
|
|
49
|
-
export default class PinInput extends SvelteComponent<PinInputProps, PinInputEvents, PinInputSlots> {
|
|
50
|
-
}
|
|
51
|
-
export {};
|