@cloudparker/moldex.js 0.0.28 → 0.0.30
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/dist/services/dialog/dialog-service.d.ts +16 -0
- package/dist/services/dialog/dialog-service.js +23 -1
- package/dist/services/utils/utils-service.d.ts +3 -0
- package/dist/services/utils/utils-service.js +26 -0
- package/dist/tailwind.css +1 -1
- package/dist/views/core/button/components/button/button.svelte +57 -34
- package/dist/views/core/button/components/button/button.svelte.d.ts +19 -18
- package/dist/views/core/button/components/button-back/button-back.svelte +44 -0
- package/dist/views/core/button/components/button-back/button-back.svelte.d.ts +24 -0
- package/dist/views/core/button/components/button-close/button-close.svelte +7 -0
- package/dist/views/core/button/components/button-close/button-close.svelte.d.ts +19 -0
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte +47 -0
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte.d.ts +25 -0
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte +94 -42
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte.d.ts +11 -11
- package/dist/views/core/button/components/button-menu/button-menu.svelte +155 -103
- package/dist/views/core/button/components/button-menu/button-menu.svelte.d.ts +7 -7
- package/dist/views/core/button/components/button-ok/button-ok.svelte +7 -0
- package/dist/views/core/button/components/button-ok/button-ok.svelte.d.ts +19 -0
- package/dist/views/core/button/index.d.ts +5 -1
- package/dist/views/core/button/index.js +10 -1
- package/dist/views/core/dialog/components/dialog/dialog.svelte +328 -231
- package/dist/views/core/dialog/components/dialog/dialog.svelte.d.ts +6 -10
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte +189 -0
- package/dist/views/core/dialog/components/list-dialog/list-picker-dialog.svelte.d.ts +41 -0
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte +22 -13
- package/dist/views/core/dialog/index.d.ts +4 -2
- package/dist/views/core/dialog/index.js +2 -2
- package/dist/views/core/drawer/components/drawer/drawer.svelte +52 -34
- package/dist/views/core/icon/components/icon/icon.svelte +25 -12
- package/dist/views/core/icon/components/icon/icon.svelte.d.ts +1 -0
- package/dist/views/core/icon/services/icon-path-service.d.ts +6 -0
- package/dist/views/core/icon/services/icon-path-service.js +6 -0
- package/dist/views/core/index.d.ts +2 -0
- package/dist/views/core/index.js +2 -0
- package/dist/views/core/input/components/color-field/color-field.svelte +114 -0
- package/dist/views/core/input/components/color-field/color-field.svelte.d.ts +23 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte +467 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte.d.ts +63 -0
- package/dist/views/core/input/components/date-field/date-field.svelte +13 -0
- package/dist/views/core/input/components/date-field/date-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte +13 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/email-field/email-field.svelte +12 -0
- package/dist/views/core/input/components/email-field/email-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/file-field/file-field.svelte +92 -0
- package/dist/views/core/input/components/file-field/file-field.svelte.d.ts +25 -0
- package/dist/views/core/input/components/input-field/input-field.svelte +382 -0
- package/dist/views/core/{form → input}/components/input-field/input-field.svelte.d.ts +51 -35
- package/dist/views/core/input/components/label/label.svelte +46 -0
- package/dist/views/core/input/components/number-field/number-field.svelte +13 -0
- package/dist/views/core/input/components/number-field/number-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/password-field/password-field.svelte +83 -0
- package/dist/views/core/input/components/password-field/password-field.svelte.d.ts +24 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte +90 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte.d.ts +24 -0
- package/dist/views/core/input/components/range-field/range-field.svelte +72 -0
- package/dist/views/core/input/components/range-field/range-field.svelte.d.ts +31 -0
- package/dist/views/core/input/components/search-field/search-field.svelte +67 -0
- package/dist/views/core/input/components/search-field/search-field.svelte.d.ts +24 -0
- package/dist/views/core/input/components/text-field/text-field.svelte +12 -0
- package/dist/views/core/input/components/text-field/text-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +12 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte.d.ts +21 -0
- package/dist/views/core/input/components/time-field/time-field.svelte +12 -0
- package/dist/views/core/input/components/time-field/time-field.svelte.d.ts +21 -0
- package/dist/views/core/input/index.d.ts +19 -0
- package/dist/views/core/input/index.js +19 -0
- package/dist/views/core/navbar/components/navbar/navbar.svelte +71 -39
- package/dist/views/core/navbar/components/navbar/navbar.svelte.d.ts +3 -3
- package/dist/views/core/no-data/components/no-data/no-data.svelte +51 -0
- package/dist/views/core/no-data/components/no-data/no-data.svelte.d.ts +27 -0
- package/dist/views/core/no-data/index.d.ts +2 -0
- package/dist/views/core/no-data/index.js +2 -0
- package/dist/views/core/pagination/components/pagination/pagination.svelte +100 -71
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte +37 -23
- package/dist/views/core/referrer/components/referrer.svelte +15 -13
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte +6 -2
- package/dist/views/core/screen-detector/components/screen-detector.svelte +13 -9
- package/dist/views/core/spinner/components/spinner/spinner.svelte +7 -2
- package/dist/views/core/text/components/text-await/text-await.svelte +8 -2
- package/dist/views/core/text/components/text-copy/text-copy.svelte +28 -17
- package/dist/views/core/text/components/text-country/text-country.svelte +42 -29
- package/dist/views/core/text/components/text-country-state/text-country-state.svelte +38 -30
- package/dist/views/core/text/components/text-currency/text-currency.svelte +21 -10
- package/dist/views/core/text/components/text-date/text-date.svelte +33 -21
- package/dist/views/core/text/components/text-email/text-email.svelte +13 -4
- package/dist/views/core/text/components/text-html/text-html.svelte +3 -2
- package/dist/views/core/text/components/text-phone/text-phone.svelte +13 -4
- package/dist/views/core/toast/components/toast/toast.svelte +44 -21
- package/package.json +2 -2
- package/dist/views/core/form/components/input-field/input-field.svelte +0 -233
- package/dist/views/core/form/components/label/label.svelte +0 -32
- package/dist/views/core/form/index.d.ts +0 -3
- package/dist/views/core/form/index.js +0 -3
- /package/dist/views/core/{form → input}/components/label/label.svelte.d.ts +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ripple } from '../../../../../actions';
|
|
3
|
+
import { openFilePicker } from '../../../../../services';
|
|
4
|
+
import { mdiAttachment } from '../../../icon';
|
|
5
|
+
import Icon from '../../../icon/components/icon/icon.svelte';
|
|
6
|
+
import InputField, { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
appearance,
|
|
10
|
+
size,
|
|
11
|
+
className,
|
|
12
|
+
accept = '',
|
|
13
|
+
multiple = false,
|
|
14
|
+
value,
|
|
15
|
+
...props
|
|
16
|
+
}: InputFieldPropsType & {
|
|
17
|
+
accept?: string;
|
|
18
|
+
multiple?: boolean;
|
|
19
|
+
value?: File | File[];
|
|
20
|
+
} = $props();
|
|
21
|
+
|
|
22
|
+
let btnRoundedClassName = $state('');
|
|
23
|
+
let btnIconSizeClassName = $state('');
|
|
24
|
+
let fileNameDisplay = $state('');
|
|
25
|
+
|
|
26
|
+
let inputFieldRef: InputField | null = $state(null);
|
|
27
|
+
|
|
28
|
+
export function focus() {
|
|
29
|
+
inputFieldRef?.focus();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function handleFileAttachment() {
|
|
33
|
+
let res: File | File[] = await openFilePicker({ accept, multiple });
|
|
34
|
+
if (res) {
|
|
35
|
+
value = res;
|
|
36
|
+
if (multiple) {
|
|
37
|
+
let files: File[] = value as File[];
|
|
38
|
+
fileNameDisplay = files.map((file) => file.name).join(', ');
|
|
39
|
+
} else {
|
|
40
|
+
let file: File = value as File;
|
|
41
|
+
fileNameDisplay = file.name;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
$effect(() => {
|
|
47
|
+
if (size) {
|
|
48
|
+
switch (size) {
|
|
49
|
+
case 'lg':
|
|
50
|
+
btnIconSizeClassName = '!h-7 !w-7';
|
|
51
|
+
break;
|
|
52
|
+
case 'md':
|
|
53
|
+
btnIconSizeClassName = '!h-6 !w-6';
|
|
54
|
+
break;
|
|
55
|
+
case 'sm':
|
|
56
|
+
btnIconSizeClassName = '!h-5 !w-5';
|
|
57
|
+
break;
|
|
58
|
+
case 'xs':
|
|
59
|
+
btnIconSizeClassName = '!h-4 !w-4';
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
$effect(() => {
|
|
66
|
+
if (!appearance || appearance == 'normal') {
|
|
67
|
+
btnRoundedClassName = 'rounded-tr-lg rounded-br-lg';
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
{#snippet fileButton()}
|
|
73
|
+
<button
|
|
74
|
+
class="px-3 h-full hover:bg-gray-100 {btnRoundedClassName} "
|
|
75
|
+
use:ripple
|
|
76
|
+
onclick={handleFileAttachment}
|
|
77
|
+
>
|
|
78
|
+
<Icon path={mdiAttachment} className=" {btnIconSizeClassName}"></Icon>
|
|
79
|
+
</button>
|
|
80
|
+
{/snippet}
|
|
81
|
+
|
|
82
|
+
<InputField
|
|
83
|
+
bind:this={inputFieldRef}
|
|
84
|
+
{...props}
|
|
85
|
+
{appearance}
|
|
86
|
+
{size}
|
|
87
|
+
value={fileNameDisplay}
|
|
88
|
+
className="pr-14 {className}"
|
|
89
|
+
type="text"
|
|
90
|
+
readonly
|
|
91
|
+
rightSnippet={fileButton}
|
|
92
|
+
/>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const FileField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType & {
|
|
16
|
+
accept?: string;
|
|
17
|
+
multiple?: boolean;
|
|
18
|
+
value?: File | File[];
|
|
19
|
+
}, {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
}, {}, {
|
|
22
|
+
focus: () => void;
|
|
23
|
+
}, "">;
|
|
24
|
+
type FileField = InstanceType<typeof FileField>;
|
|
25
|
+
export default FileField;
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type InputFieldSizeType = 'lg' | 'md' | 'sm' | 'xs';
|
|
3
|
+
export type InputFieldAppearanceType =
|
|
4
|
+
| 'normal'
|
|
5
|
+
| 'box'
|
|
6
|
+
| 'fill'
|
|
7
|
+
| 'underline'
|
|
8
|
+
| 'fill-underline'
|
|
9
|
+
| 'none';
|
|
10
|
+
|
|
11
|
+
export type InputValueType =
|
|
12
|
+
| string
|
|
13
|
+
| string[]
|
|
14
|
+
| number
|
|
15
|
+
| number[]
|
|
16
|
+
| Date
|
|
17
|
+
| Date[]
|
|
18
|
+
| File
|
|
19
|
+
| File[]
|
|
20
|
+
| null
|
|
21
|
+
| undefined;
|
|
22
|
+
|
|
23
|
+
export type InputFieldPropsType = {
|
|
24
|
+
appearance?: InputFieldAppearanceType;
|
|
25
|
+
ariaControls?: string;
|
|
26
|
+
ariaExpanded?: boolean;
|
|
27
|
+
autofocus?: boolean;
|
|
28
|
+
className?: string;
|
|
29
|
+
cols?: number;
|
|
30
|
+
containerClassName?: string;
|
|
31
|
+
contentSnippet?: Snippet;
|
|
32
|
+
contentSnippetClassName?: string;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
floatingLabel?: boolean;
|
|
35
|
+
hasRequiredSymbol?: boolean;
|
|
36
|
+
iconClassName?: string;
|
|
37
|
+
iconPath?: string;
|
|
38
|
+
id?: string;
|
|
39
|
+
label?: string;
|
|
40
|
+
labelClassName?: string;
|
|
41
|
+
leftSnippet?: Snippet;
|
|
42
|
+
leftSnippetContainerClassName?: string;
|
|
43
|
+
max?: number;
|
|
44
|
+
maxlength?: number;
|
|
45
|
+
min?: number;
|
|
46
|
+
minlength?: number;
|
|
47
|
+
multiple?: boolean;
|
|
48
|
+
name?: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
onblur?: (ev: any) => void;
|
|
51
|
+
onchange?: (ev: any) => void;
|
|
52
|
+
onclick?: (ev: MouseEvent) => void;
|
|
53
|
+
ondblclick?: (ev: MouseEvent) => void;
|
|
54
|
+
ondrag?: (ev: DragEvent) => void;
|
|
55
|
+
ondragover?: (ev: DragEvent) => void;
|
|
56
|
+
ondrop?: (ev: DragEvent) => void;
|
|
57
|
+
onfocus?: (ev: any) => void;
|
|
58
|
+
oninput?: (ev: any) => void;
|
|
59
|
+
onkeydown?: (ev: KeyboardEvent) => void;
|
|
60
|
+
onkeypress?: (ev: KeyboardEvent) => void;
|
|
61
|
+
onkeyup?: (ev: KeyboardEvent) => void;
|
|
62
|
+
onmousedown?: (ev: MouseEvent) => void;
|
|
63
|
+
onmouseup?: (ev: MouseEvent) => void;
|
|
64
|
+
pattern?: string;
|
|
65
|
+
placeholder?: string;
|
|
66
|
+
readonly?: boolean;
|
|
67
|
+
required?: boolean;
|
|
68
|
+
requiredSymbol?: string;
|
|
69
|
+
requiredSymbolColor?: string;
|
|
70
|
+
rightSnippet?: Snippet;
|
|
71
|
+
rightSnippetContainerClassName?: string;
|
|
72
|
+
role?: AriaRole;
|
|
73
|
+
rows?: number;
|
|
74
|
+
size?: InputFieldSizeType;
|
|
75
|
+
step?: number;
|
|
76
|
+
type?: HTMLInputTypeAttribute | 'textarea';
|
|
77
|
+
value?: InputValueType;
|
|
78
|
+
};
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<script lang="ts">
|
|
82
|
+
import type { Snippet } from 'svelte';
|
|
83
|
+
import type { HTMLInputTypeAttribute, AriaRole } from 'svelte/elements';
|
|
84
|
+
import Label from '../label/label.svelte';
|
|
85
|
+
|
|
86
|
+
let {
|
|
87
|
+
appearance = 'normal',
|
|
88
|
+
ariaControls,
|
|
89
|
+
ariaExpanded,
|
|
90
|
+
autofocus = false,
|
|
91
|
+
className = '',
|
|
92
|
+
cols,
|
|
93
|
+
containerClassName = '',
|
|
94
|
+
contentSnippet,
|
|
95
|
+
contentSnippetClassName,
|
|
96
|
+
disabled = false,
|
|
97
|
+
floatingLabel = false,
|
|
98
|
+
hasRequiredSymbol = true,
|
|
99
|
+
id = '',
|
|
100
|
+
label = '',
|
|
101
|
+
labelClassName = '',
|
|
102
|
+
leftSnippet,
|
|
103
|
+
leftSnippetContainerClassName = '',
|
|
104
|
+
max,
|
|
105
|
+
maxlength,
|
|
106
|
+
min,
|
|
107
|
+
minlength,
|
|
108
|
+
multiple = false,
|
|
109
|
+
name = '',
|
|
110
|
+
title,
|
|
111
|
+
onblur,
|
|
112
|
+
onchange,
|
|
113
|
+
onclick,
|
|
114
|
+
ondblclick,
|
|
115
|
+
ondrag,
|
|
116
|
+
ondragover,
|
|
117
|
+
ondrop,
|
|
118
|
+
onfocus,
|
|
119
|
+
oninput,
|
|
120
|
+
onkeydown,
|
|
121
|
+
onkeypress,
|
|
122
|
+
onkeyup,
|
|
123
|
+
onmousedown,
|
|
124
|
+
onmouseup,
|
|
125
|
+
pattern = '',
|
|
126
|
+
placeholder = '',
|
|
127
|
+
readonly = false,
|
|
128
|
+
required = false,
|
|
129
|
+
requiredSymbol = '*',
|
|
130
|
+
requiredSymbolColor = 'red',
|
|
131
|
+
rightSnippet,
|
|
132
|
+
rightSnippetContainerClassName = '',
|
|
133
|
+
role,
|
|
134
|
+
rows = 5,
|
|
135
|
+
size = 'md',
|
|
136
|
+
step,
|
|
137
|
+
type = 'text',
|
|
138
|
+
value = $bindable('')
|
|
139
|
+
}: InputFieldPropsType = $props();
|
|
140
|
+
|
|
141
|
+
let inputRef: HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement | null = $state(null);
|
|
142
|
+
|
|
143
|
+
let sizeClassName = $state('');
|
|
144
|
+
let appearanceClassName = $state('');
|
|
145
|
+
let floatingLabelClassName = $state('');
|
|
146
|
+
let floatingLabelPaddingClassName = $state('');
|
|
147
|
+
let floatingLabelTextClassName = $state('');
|
|
148
|
+
|
|
149
|
+
export function focus() {
|
|
150
|
+
inputRef && inputRef.focus();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
$effect(() => {
|
|
154
|
+
if (floatingLabel || leftSnippet != null || rightSnippet != null) {
|
|
155
|
+
containerClassName = (containerClassName || '') + ' relative';
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
$effect(() => {
|
|
160
|
+
if (floatingLabel) {
|
|
161
|
+
if (size) {
|
|
162
|
+
let flpcn = '';
|
|
163
|
+
switch (size) {
|
|
164
|
+
case 'lg':
|
|
165
|
+
flpcn = ` px-1 peer-focus:px-1 peer-placeholder-shown:px-4 `;
|
|
166
|
+
floatingLabelTextClassName = 'text-base';
|
|
167
|
+
break;
|
|
168
|
+
case 'md':
|
|
169
|
+
flpcn = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2.5 ';
|
|
170
|
+
floatingLabelTextClassName = 'text-sm';
|
|
171
|
+
|
|
172
|
+
break;
|
|
173
|
+
case 'sm':
|
|
174
|
+
flpcn = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2';
|
|
175
|
+
floatingLabelTextClassName = 'text-xs';
|
|
176
|
+
break;
|
|
177
|
+
case 'xs':
|
|
178
|
+
flpcn = ' px-0 peer-focus:px-0 peer-placeholder-shown:px-1 ';
|
|
179
|
+
floatingLabelTextClassName = 'text-xs';
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
floatingLabelPaddingClassName = flpcn;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
floatingLabelClassName = `absolute duration-300 transform top-0 rounded -translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-0 peer-placeholder-shown:start-0 peer-focus:start-1 bg-white peer-placeholder-shown:bg-transparent peer-focus:bg-white start-1 ${floatingLabelPaddingClassName} ${floatingLabelTextClassName}`;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
$effect(() => {
|
|
190
|
+
if (appearance) {
|
|
191
|
+
switch (appearance) {
|
|
192
|
+
case 'normal':
|
|
193
|
+
appearanceClassName =
|
|
194
|
+
'bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-indigo-500 focus:border-indigo-500 dark:bg-gray-700 ';
|
|
195
|
+
break;
|
|
196
|
+
case 'box':
|
|
197
|
+
appearanceClassName =
|
|
198
|
+
'bg-gray-50 border border-gray-300 text-gray-900 focus:ring-indigo-500 focus:border-indigo-500 ';
|
|
199
|
+
break;
|
|
200
|
+
case 'fill':
|
|
201
|
+
appearanceClassName =
|
|
202
|
+
'bg-gray-100 border-0 appearance-none focus:bg-gray-200 focus:outline-none focus:ring-0';
|
|
203
|
+
break;
|
|
204
|
+
|
|
205
|
+
case 'underline':
|
|
206
|
+
appearanceClassName =
|
|
207
|
+
'bg-transparent border-0 border-b-2 border-gray-300 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600';
|
|
208
|
+
break;
|
|
209
|
+
case 'fill-underline':
|
|
210
|
+
appearanceClassName =
|
|
211
|
+
'bg-gray-100 border-0 border-b-2 border-gray-300 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600';
|
|
212
|
+
break;
|
|
213
|
+
case 'none':
|
|
214
|
+
appearanceClassName =
|
|
215
|
+
'hover:bg-gray-100 focus:bg-gray-100 border-0 focus:outline-none focus:ring-0 appearance-none';
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
$effect(() => {
|
|
222
|
+
if (size) {
|
|
223
|
+
switch (size) {
|
|
224
|
+
case 'lg':
|
|
225
|
+
sizeClassName = 'p-4 text-base';
|
|
226
|
+
break;
|
|
227
|
+
case 'md':
|
|
228
|
+
sizeClassName = 'p-2.5 text-sm';
|
|
229
|
+
break;
|
|
230
|
+
case 'sm':
|
|
231
|
+
sizeClassName = 'p-2 text-xs';
|
|
232
|
+
break;
|
|
233
|
+
case 'xs':
|
|
234
|
+
sizeClassName = 'p-1 text-xs';
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
$effect(() => {
|
|
241
|
+
if (name && !id) {
|
|
242
|
+
id = name;
|
|
243
|
+
} else if (id && !name) {
|
|
244
|
+
name = id;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
$effect(() => {
|
|
249
|
+
if (inputRef && autofocus) {
|
|
250
|
+
inputRef.focus();
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
</script>
|
|
254
|
+
|
|
255
|
+
{#snippet labelSnippet()}
|
|
256
|
+
<Label
|
|
257
|
+
forName={id}
|
|
258
|
+
{label}
|
|
259
|
+
className="{floatingLabelClassName} {labelClassName}"
|
|
260
|
+
{required}
|
|
261
|
+
{requiredSymbolColor}
|
|
262
|
+
{requiredSymbol}
|
|
263
|
+
{hasRequiredSymbol}
|
|
264
|
+
/>
|
|
265
|
+
{/snippet}
|
|
266
|
+
|
|
267
|
+
{#if !floatingLabel && label}
|
|
268
|
+
{@render labelSnippet()}
|
|
269
|
+
{/if}
|
|
270
|
+
|
|
271
|
+
<div class="w-full {containerClassName}">
|
|
272
|
+
{#if leftSnippet}
|
|
273
|
+
<div
|
|
274
|
+
class="absolute flex items-center justify-center left-children {leftSnippetContainerClassName}"
|
|
275
|
+
>
|
|
276
|
+
{@render leftSnippet()}
|
|
277
|
+
</div>
|
|
278
|
+
{/if}
|
|
279
|
+
|
|
280
|
+
{#if type == 'textarea'}
|
|
281
|
+
<textarea
|
|
282
|
+
bind:this={inputRef}
|
|
283
|
+
bind:value
|
|
284
|
+
class="block w-full peer {appearanceClassName} {sizeClassName} {className}"
|
|
285
|
+
{title}
|
|
286
|
+
{id}
|
|
287
|
+
{name}
|
|
288
|
+
{placeholder}
|
|
289
|
+
{required}
|
|
290
|
+
{disabled}
|
|
291
|
+
{readonly}
|
|
292
|
+
{maxlength}
|
|
293
|
+
{minlength}
|
|
294
|
+
{rows}
|
|
295
|
+
{cols}
|
|
296
|
+
{onchange}
|
|
297
|
+
{oninput}
|
|
298
|
+
{onfocus}
|
|
299
|
+
{onblur}
|
|
300
|
+
{ondblclick}
|
|
301
|
+
{onclick}
|
|
302
|
+
{onmousedown}
|
|
303
|
+
{onmouseup}
|
|
304
|
+
{onkeydown}
|
|
305
|
+
{onkeyup}
|
|
306
|
+
{onkeypress}
|
|
307
|
+
{ondrop}
|
|
308
|
+
{ondrag}
|
|
309
|
+
{ondragover}
|
|
310
|
+
></textarea>
|
|
311
|
+
{:else}
|
|
312
|
+
<input
|
|
313
|
+
bind:this={inputRef}
|
|
314
|
+
bind:value
|
|
315
|
+
class="block w-full peer {appearanceClassName} {sizeClassName} {className}"
|
|
316
|
+
{title}
|
|
317
|
+
{type}
|
|
318
|
+
{id}
|
|
319
|
+
{name}
|
|
320
|
+
{placeholder}
|
|
321
|
+
{required}
|
|
322
|
+
{disabled}
|
|
323
|
+
{readonly}
|
|
324
|
+
{maxlength}
|
|
325
|
+
{minlength}
|
|
326
|
+
{min}
|
|
327
|
+
{max}
|
|
328
|
+
{step}
|
|
329
|
+
{pattern}
|
|
330
|
+
{multiple}
|
|
331
|
+
{role}
|
|
332
|
+
{onchange}
|
|
333
|
+
{oninput}
|
|
334
|
+
{onfocus}
|
|
335
|
+
{onblur}
|
|
336
|
+
{ondblclick}
|
|
337
|
+
{onclick}
|
|
338
|
+
{onmousedown}
|
|
339
|
+
{onmouseup}
|
|
340
|
+
{onkeydown}
|
|
341
|
+
{onkeyup}
|
|
342
|
+
{onkeypress}
|
|
343
|
+
{ondrop}
|
|
344
|
+
{ondrag}
|
|
345
|
+
{ondragover}
|
|
346
|
+
aria-controls={ariaControls}
|
|
347
|
+
aria-expanded={ariaExpanded}
|
|
348
|
+
/>
|
|
349
|
+
{/if}
|
|
350
|
+
{#if contentSnippet}
|
|
351
|
+
<div
|
|
352
|
+
class="absolute inset-0 pointer-events-none block w-full overflow-hidden {appearanceClassName} {sizeClassName} {contentSnippetClassName}"
|
|
353
|
+
>
|
|
354
|
+
{@render contentSnippet()}
|
|
355
|
+
</div>
|
|
356
|
+
{/if}
|
|
357
|
+
{#if rightSnippet}
|
|
358
|
+
<div
|
|
359
|
+
class="absolute flex items-center justify-center right-children {rightSnippetContainerClassName}"
|
|
360
|
+
>
|
|
361
|
+
{@render rightSnippet()}
|
|
362
|
+
</div>
|
|
363
|
+
{/if}
|
|
364
|
+
|
|
365
|
+
{#if label && floatingLabel}
|
|
366
|
+
{@render labelSnippet()}
|
|
367
|
+
{/if}
|
|
368
|
+
</div>
|
|
369
|
+
|
|
370
|
+
<style>
|
|
371
|
+
.left-children {
|
|
372
|
+
left: 2px;
|
|
373
|
+
top: 2px;
|
|
374
|
+
bottom: 2px;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.right-children {
|
|
378
|
+
right: 2px;
|
|
379
|
+
top: 2px;
|
|
380
|
+
bottom: 2px;
|
|
381
|
+
}
|
|
382
|
+
</style>
|
|
@@ -1,50 +1,64 @@
|
|
|
1
|
-
export type InputFieldTypesType = 'text' | 'number' | 'date';
|
|
2
1
|
export type InputFieldSizeType = 'lg' | 'md' | 'sm' | 'xs';
|
|
3
|
-
export type InputFieldAppearanceType = 'normal' | 'box' | 'fill' | 'underline' | 'fill-underline';
|
|
2
|
+
export type InputFieldAppearanceType = 'normal' | 'box' | 'fill' | 'underline' | 'fill-underline' | 'none';
|
|
3
|
+
export type InputValueType = string | string[] | number | number[] | Date | Date[] | File | File[] | null | undefined;
|
|
4
4
|
export type InputFieldPropsType = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
appearance?: InputFieldAppearanceType;
|
|
6
|
+
ariaControls?: string;
|
|
7
|
+
ariaExpanded?: boolean;
|
|
8
|
+
autofocus?: boolean;
|
|
8
9
|
className?: string;
|
|
9
|
-
|
|
10
|
-
type?: InputFieldTypesType;
|
|
11
|
-
labelClassName?: string;
|
|
10
|
+
cols?: number;
|
|
12
11
|
containerClassName?: string;
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
contentSnippet?: Snippet;
|
|
13
|
+
contentSnippetClassName?: string;
|
|
15
14
|
disabled?: boolean;
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
floatingLabel?: boolean;
|
|
16
|
+
hasRequiredSymbol?: boolean;
|
|
17
|
+
iconClassName?: string;
|
|
18
|
+
iconPath?: string;
|
|
19
|
+
id?: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
labelClassName?: string;
|
|
22
|
+
leftSnippet?: Snippet;
|
|
23
|
+
leftSnippetContainerClassName?: string;
|
|
24
|
+
max?: number;
|
|
18
25
|
maxlength?: number;
|
|
19
|
-
minlength?: number;
|
|
20
26
|
min?: number;
|
|
21
|
-
|
|
22
|
-
step?: number;
|
|
23
|
-
requiredSymbolColor?: string;
|
|
24
|
-
requiredSymbol?: string;
|
|
25
|
-
hasRequiredSymbol?: boolean;
|
|
26
|
-
size?: InputFieldSizeType;
|
|
27
|
-
appearance?: InputFieldAppearanceType;
|
|
28
|
-
floatingLabel?: boolean;
|
|
29
|
-
pattern?: string;
|
|
27
|
+
minlength?: number;
|
|
30
28
|
multiple?: boolean;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
onchange?: (ev: any) => void;
|
|
34
|
-
oninput?: (ev: any) => void;
|
|
35
|
-
onfocus?: (ev: any) => void;
|
|
29
|
+
name?: string;
|
|
30
|
+
title?: string;
|
|
36
31
|
onblur?: (ev: any) => void;
|
|
37
|
-
|
|
32
|
+
onchange?: (ev: any) => void;
|
|
38
33
|
onclick?: (ev: MouseEvent) => void;
|
|
39
|
-
|
|
40
|
-
onmouseup?: (ev: MouseEvent) => void;
|
|
41
|
-
onkeydown?: (ev: KeyboardEvent) => void;
|
|
42
|
-
onkeyup?: (ev: KeyboardEvent) => void;
|
|
43
|
-
onkeypress?: (ev: KeyboardEvent) => void;
|
|
44
|
-
ondrop?: (ev: DragEvent) => void;
|
|
34
|
+
ondblclick?: (ev: MouseEvent) => void;
|
|
45
35
|
ondrag?: (ev: DragEvent) => void;
|
|
46
36
|
ondragover?: (ev: DragEvent) => void;
|
|
37
|
+
ondrop?: (ev: DragEvent) => void;
|
|
38
|
+
onfocus?: (ev: any) => void;
|
|
39
|
+
oninput?: (ev: any) => void;
|
|
40
|
+
onkeydown?: (ev: KeyboardEvent) => void;
|
|
41
|
+
onkeypress?: (ev: KeyboardEvent) => void;
|
|
42
|
+
onkeyup?: (ev: KeyboardEvent) => void;
|
|
43
|
+
onmousedown?: (ev: MouseEvent) => void;
|
|
44
|
+
onmouseup?: (ev: MouseEvent) => void;
|
|
45
|
+
pattern?: string;
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
readonly?: boolean;
|
|
48
|
+
required?: boolean;
|
|
49
|
+
requiredSymbol?: string;
|
|
50
|
+
requiredSymbolColor?: string;
|
|
51
|
+
rightSnippet?: Snippet;
|
|
52
|
+
rightSnippetContainerClassName?: string;
|
|
53
|
+
role?: AriaRole;
|
|
54
|
+
rows?: number;
|
|
55
|
+
size?: InputFieldSizeType;
|
|
56
|
+
step?: number;
|
|
57
|
+
type?: HTMLInputTypeAttribute | 'textarea';
|
|
58
|
+
value?: InputValueType;
|
|
47
59
|
};
|
|
60
|
+
import type { Snippet } from 'svelte';
|
|
61
|
+
import type { HTMLInputTypeAttribute, AriaRole } from 'svelte/elements';
|
|
48
62
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
49
63
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
50
64
|
$$bindings?: Bindings;
|
|
@@ -60,6 +74,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
60
74
|
}
|
|
61
75
|
declare const InputField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType, {
|
|
62
76
|
[evt: string]: CustomEvent<any>;
|
|
63
|
-
}, {}, {
|
|
77
|
+
}, {}, {
|
|
78
|
+
focus: () => void;
|
|
79
|
+
}, "value">;
|
|
64
80
|
type InputField = InstanceType<typeof InputField>;
|
|
65
81
|
export default InputField;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
type PropsType = {
|
|
5
|
+
forName?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
requiredSymbolColor?: string;
|
|
11
|
+
requiredSymbol?: string;
|
|
12
|
+
hasRequiredSymbol?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
forName,
|
|
17
|
+
label = '',
|
|
18
|
+
className = '',
|
|
19
|
+
required = false,
|
|
20
|
+
requiredSymbolColor = 'red',
|
|
21
|
+
requiredSymbol = '*',
|
|
22
|
+
hasRequiredSymbol = true,
|
|
23
|
+
children
|
|
24
|
+
}: PropsType = $props();
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<label
|
|
28
|
+
for={forName || ''}
|
|
29
|
+
class="block text-sm text-gray-500 {hasRequiredSymbol && required ? 'required' : ''} {className}"
|
|
30
|
+
style="--requiredSymbolColor:{requiredSymbolColor}; --requiredSymbol: '{requiredSymbol}'; "
|
|
31
|
+
>
|
|
32
|
+
{#if children}
|
|
33
|
+
{@render children()}
|
|
34
|
+
{:else}
|
|
35
|
+
{label || ''}
|
|
36
|
+
{/if}
|
|
37
|
+
</label>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
.required::after {
|
|
41
|
+
content: var(--requiredSymbol);
|
|
42
|
+
color: var(--requiredSymbolColor);
|
|
43
|
+
font-weight: bold;
|
|
44
|
+
margin-left: 4px;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import InputField, { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
3
|
+
|
|
4
|
+
let props: InputFieldPropsType = $props();
|
|
5
|
+
|
|
6
|
+
let inputFieldRef: InputField | null = $state(null);
|
|
7
|
+
|
|
8
|
+
export function focus() {
|
|
9
|
+
inputFieldRef?.focus();
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<InputField bind:this={inputFieldRef} {...props} type="number" />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type InputFieldPropsType } from '../input-field/input-field.svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const NumberField: $$__sveltets_2_IsomorphicComponent<InputFieldPropsType, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {
|
|
18
|
+
focus: () => void;
|
|
19
|
+
}, "">;
|
|
20
|
+
type NumberField = InstanceType<typeof NumberField>;
|
|
21
|
+
export default NumberField;
|