@cloudparker/moldex.js 4.1.7 → 4.1.9
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/actions/badge.d.ts +12 -0
- package/dist/actions/badge.js +22 -0
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.js +3 -0
- package/dist/actions/no-context-menu.d.ts +3 -0
- package/dist/actions/no-context-menu.js +11 -0
- package/dist/actions/ripple.css +29 -0
- package/dist/actions/ripple.d.ts +7 -0
- package/dist/actions/ripple.js +74 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/services/date/date-service.d.ts +52 -0
- package/dist/services/date/date-service.js +206 -0
- package/dist/services/dialog/dialog-service.d.ts +96 -0
- package/dist/services/dialog/dialog-service.js +350 -0
- package/dist/services/index.d.ts +12 -0
- package/dist/services/index.js +12 -0
- package/dist/services/navigation/navigation-service.d.ts +39 -0
- package/dist/services/navigation/navigation-service.js +100 -0
- package/dist/services/screen/screen-service.d.ts +17 -0
- package/dist/services/screen/screen-service.js +40 -0
- package/dist/services/toast/toast-service.d.ts +5 -0
- package/dist/services/toast/toast-service.js +26 -0
- package/dist/services/utils/color-service.d.ts +46 -0
- package/dist/services/utils/color-service.js +73 -0
- package/dist/services/utils/currency-service.d.ts +91 -0
- package/dist/services/utils/currency-service.js +140 -0
- package/dist/services/utils/download-service.d.ts +91 -0
- package/dist/services/utils/download-service.js +159 -0
- package/dist/services/utils/file-service.d.ts +140 -0
- package/dist/services/utils/file-service.js +301 -0
- package/dist/services/utils/http-service.d.ts +77 -0
- package/dist/services/utils/http-service.js +158 -0
- package/dist/services/utils/image-service.d.ts +107 -0
- package/dist/services/utils/image-service.js +260 -0
- package/dist/services/utils/melody-service.d.ts +5 -0
- package/dist/services/utils/melody-service.js +41 -0
- package/dist/services/utils/utils-service.d.ts +260 -0
- package/dist/services/utils/utils-service.js +413 -0
- package/dist/stores/referrer-store/referrer-store.svelte.d.ts +3 -0
- package/dist/stores/referrer-store/referrer-store.svelte.js +11 -0
- package/dist/stores/screen-size/screen-size-store.svelte.d.ts +11 -0
- package/dist/stores/screen-size/screen-size-store.svelte.js +33 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.js +16 -0
- package/dist/views/core/button/components/button/button.svelte +161 -0
- package/dist/views/core/button/components/button/button.svelte.d.ts +4 -0
- package/dist/views/core/button/components/button-back/button-back.svelte +46 -0
- package/dist/views/core/button/components/button-back/button-back.svelte.d.ts +11 -0
- package/dist/views/core/button/components/button-close/button-close.svelte +8 -0
- package/dist/views/core/button/components/button-close/button-close.svelte.d.ts +4 -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 +11 -0
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte +149 -0
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte.d.ts +24 -0
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte +136 -0
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte.d.ts +4 -0
- package/dist/views/core/button/components/button-menu/button-menu.svelte +105 -0
- package/dist/views/core/button/components/button-menu/button-menu.svelte.d.ts +21 -0
- package/dist/views/core/button/components/button-ok/button-ok.svelte +9 -0
- package/dist/views/core/button/components/button-ok/button-ok.svelte.d.ts +4 -0
- package/dist/views/core/button/components/button-search/button-search.svelte +72 -0
- package/dist/views/core/button/components/button-search/button-search.svelte.d.ts +21 -0
- package/dist/views/core/button/components/switch/switch.svelte +62 -0
- package/dist/views/core/button/components/switch/switch.svelte.d.ts +4 -0
- package/dist/views/core/button/index.d.ts +12 -0
- package/dist/views/core/button/index.js +12 -0
- package/dist/views/core/button/types.d.ts +100 -0
- package/dist/views/core/button/types.js +1 -0
- package/dist/views/core/common/components/content-area/content-area.svelte +47 -0
- package/dist/views/core/common/components/content-area/content-area.svelte.d.ts +12 -0
- package/dist/views/core/common/components/loading/loading.svelte +14 -0
- package/dist/views/core/common/components/loading/loading.svelte.d.ts +7 -0
- package/dist/views/core/common/components/virtual-scrolling/virtual-scrolling-list.svelte +60 -0
- package/dist/views/core/common/components/virtual-scrolling/virtual-scrolling-list.svelte.d.ts +11 -0
- package/dist/views/core/common/index.d.ts +4 -0
- package/dist/views/core/common/index.js +4 -0
- package/dist/views/core/dialog/components/cropper-dialog/cropper-dialog.svelte +51 -0
- package/dist/views/core/dialog/components/cropper-dialog/cropper-dialog.svelte.d.ts +5 -0
- package/dist/views/core/dialog/components/dialog/dialog.svelte +370 -0
- package/dist/views/core/dialog/components/dialog/dialog.svelte.d.ts +19 -0
- package/dist/views/core/dialog/components/loading-dialog/loading-dialog.svelte +42 -0
- package/dist/views/core/dialog/components/loading-dialog/loading-dialog.svelte.d.ts +12 -0
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte +22 -0
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte.d.ts +9 -0
- package/dist/views/core/dialog/components/number-field-dialog/number-field-dialog.svelte +57 -0
- package/dist/views/core/dialog/components/number-field-dialog/number-field-dialog.svelte.d.ts +14 -0
- package/dist/views/core/dialog/components/picker-dialog/picker-dialog.svelte +181 -0
- package/dist/views/core/dialog/components/picker-dialog/picker-dialog.svelte.d.ts +5 -0
- package/dist/views/core/dialog/components/text-field-dialog/text-field-dialog.svelte +56 -0
- package/dist/views/core/dialog/components/text-field-dialog/text-field-dialog.svelte.d.ts +15 -0
- package/dist/views/core/dialog/components/textarea-field-dialog/textarea-field-dialog.svelte +56 -0
- package/dist/views/core/dialog/components/textarea-field-dialog/textarea-field-dialog.svelte.d.ts +15 -0
- package/dist/views/core/dialog/index.d.ts +9 -0
- package/dist/views/core/dialog/index.js +9 -0
- package/dist/views/core/dialog/types.d.ts +105 -0
- package/dist/views/core/dialog/types.js +1 -0
- package/dist/views/core/drawer/components/drawer/drawer.svelte +110 -0
- package/dist/views/core/drawer/components/drawer/drawer.svelte.d.ts +19 -0
- package/dist/views/core/drawer/index.d.ts +2 -0
- package/dist/views/core/drawer/index.js +2 -0
- package/dist/views/core/icon/components/icon/icon.svelte +27 -0
- package/dist/views/core/icon/components/icon/icon.svelte.d.ts +12 -0
- package/dist/views/core/icon/components/icon-circle/icon-circle.svelte +17 -0
- package/dist/views/core/icon/components/icon-circle/icon-circle.svelte.d.ts +8 -0
- package/dist/views/core/icon/index.d.ts +4 -0
- package/dist/views/core/icon/index.js +4 -0
- package/dist/views/core/icon/services/icon-path-service.d.ts +23 -0
- package/dist/views/core/icon/services/icon-path-service.js +24 -0
- package/dist/views/core/index.d.ts +16 -0
- package/dist/views/core/index.js +16 -0
- package/dist/views/core/input/components/checkbox-field/checkbox-field.svelte +83 -0
- package/dist/views/core/input/components/checkbox-field/checkbox-field.svelte.d.ts +19 -0
- package/dist/views/core/input/components/color-field/color-field.svelte +135 -0
- package/dist/views/core/input/components/color-field/color-field.svelte.d.ts +11 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte +492 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte.d.ts +7 -0
- package/dist/views/core/input/components/date-field/date-field.svelte +40 -0
- package/dist/views/core/input/components/date-field/date-field.svelte.d.ts +11 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte +22 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte.d.ts +8 -0
- package/dist/views/core/input/components/email-field/email-field.svelte +27 -0
- package/dist/views/core/input/components/email-field/email-field.svelte.d.ts +8 -0
- package/dist/views/core/input/components/file-field/file-field.svelte +106 -0
- package/dist/views/core/input/components/file-field/file-field.svelte.d.ts +13 -0
- package/dist/views/core/input/components/input-field/input-field.svelte +336 -0
- package/dist/views/core/input/components/input-field/input-field.svelte.d.ts +9 -0
- package/dist/views/core/input/components/label/label.svelte +48 -0
- package/dist/views/core/input/components/label/label.svelte.d.ts +14 -0
- package/dist/views/core/input/components/number-field/number-field.svelte +22 -0
- package/dist/views/core/input/components/number-field/number-field.svelte.d.ts +8 -0
- package/dist/views/core/input/components/password-field/password-field.svelte +100 -0
- package/dist/views/core/input/components/password-field/password-field.svelte.d.ts +12 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte +187 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte.d.ts +12 -0
- package/dist/views/core/input/components/radio-field/radio-field.svelte +127 -0
- package/dist/views/core/input/components/radio-field/radio-field.svelte.d.ts +4 -0
- package/dist/views/core/input/components/range-field/range-field.svelte +120 -0
- package/dist/views/core/input/components/range-field/range-field.svelte.d.ts +23 -0
- package/dist/views/core/input/components/search-field/search-field.svelte +80 -0
- package/dist/views/core/input/components/search-field/search-field.svelte.d.ts +12 -0
- package/dist/views/core/input/components/text-field/text-field.svelte +31 -0
- package/dist/views/core/input/components/text-field/text-field.svelte.d.ts +11 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +27 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte.d.ts +8 -0
- package/dist/views/core/input/components/time-field/time-field.svelte +21 -0
- package/dist/views/core/input/components/time-field/time-field.svelte.d.ts +8 -0
- package/dist/views/core/input/index.d.ts +20 -0
- package/dist/views/core/input/index.js +20 -0
- package/dist/views/core/input/types.d.ts +159 -0
- package/dist/views/core/input/types.js +1 -0
- package/dist/views/core/navbar/components/navbar/navbar.svelte +133 -0
- package/dist/views/core/navbar/components/navbar/navbar.svelte.d.ts +4 -0
- package/dist/views/core/navbar/index.d.ts +3 -0
- package/dist/views/core/navbar/index.js +3 -0
- package/dist/views/core/navbar/types.d.ts +35 -0
- package/dist/views/core/navbar/types.js +1 -0
- package/dist/views/core/no-data/components/no-data/no-data.svelte +47 -0
- package/dist/views/core/no-data/components/no-data/no-data.svelte.d.ts +13 -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 +151 -0
- package/dist/views/core/pagination/components/pagination/pagination.svelte.d.ts +16 -0
- package/dist/views/core/pagination/index.d.ts +2 -0
- package/dist/views/core/pagination/index.js +2 -0
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte +55 -0
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte.d.ts +11 -0
- package/dist/views/core/progressbar/index.d.ts +2 -0
- package/dist/views/core/progressbar/index.js +2 -0
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte +8 -0
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte.d.ts +6 -0
- package/dist/views/core/ruler/index.d.ts +2 -0
- package/dist/views/core/ruler/index.js +2 -0
- package/dist/views/core/screen-detector/components/screen-detector.svelte +17 -0
- package/dist/views/core/screen-detector/components/screen-detector.svelte.d.ts +3 -0
- package/dist/views/core/screen-detector/index.d.ts +2 -0
- package/dist/views/core/screen-detector/index.js +2 -0
- package/dist/views/core/sidebar/components/sidebar.svelte +49 -0
- package/dist/views/core/sidebar/components/sidebar.svelte.d.ts +12 -0
- package/dist/views/core/sidebar/index.d.ts +2 -0
- package/dist/views/core/sidebar/index.js +2 -0
- package/dist/views/core/spinner/components/spinner/spinner.svelte +21 -0
- package/dist/views/core/spinner/components/spinner/spinner.svelte.d.ts +6 -0
- package/dist/views/core/spinner/index.d.ts +2 -0
- package/dist/views/core/spinner/index.js +2 -0
- package/dist/views/core/text/components/text-await/text-await.svelte +23 -0
- package/dist/views/core/text/components/text-await/text-await.svelte.d.ts +10 -0
- package/dist/views/core/text/components/text-copy/text-copy.svelte +40 -0
- package/dist/views/core/text/components/text-copy/text-copy.svelte.d.ts +10 -0
- package/dist/views/core/text/components/text-currency/text-currency.svelte +24 -0
- package/dist/views/core/text/components/text-currency/text-currency.svelte.d.ts +11 -0
- package/dist/views/core/text/components/text-date/text-date.svelte +40 -0
- package/dist/views/core/text/components/text-date/text-date.svelte.d.ts +10 -0
- package/dist/views/core/text/components/text-email/text-email.svelte +22 -0
- package/dist/views/core/text/components/text-email/text-email.svelte.d.ts +9 -0
- package/dist/views/core/text/components/text-html/text-html.svelte +7 -0
- package/dist/views/core/text/components/text-html/text-html.svelte.d.ts +6 -0
- package/dist/views/core/text/components/text-phone/text-phone.svelte +25 -0
- package/dist/views/core/text/components/text-phone/text-phone.svelte.d.ts +9 -0
- package/dist/views/core/text/index.d.ts +8 -0
- package/dist/views/core/text/index.js +8 -0
- package/dist/views/core/toast/components/toast/toast.svelte +46 -0
- package/dist/views/core/toast/components/toast/toast.svelte.d.ts +7 -0
- package/dist/views/core/toast/index.d.ts +3 -0
- package/dist/views/core/toast/index.js +3 -0
- package/dist/views/core/toast/types.d.ts +8 -0
- package/dist/views/core/toast/types.js +1 -0
- package/dist/views/extra/fields/country-combobox-field.svelte +42 -0
- package/dist/views/extra/fields/country-combobox-field.svelte.d.ts +8 -0
- package/dist/views/extra/index.d.ts +6 -0
- package/dist/views/extra/index.js +6 -0
- package/dist/views/extra/loaders/country-loader.svelte +38 -0
- package/dist/views/extra/loaders/country-loader.svelte.d.ts +12 -0
- package/dist/views/extra/texts/text-country-state.svelte +48 -0
- package/dist/views/extra/texts/text-country-state.svelte.d.ts +6 -0
- package/dist/views/extra/texts/text-country.svelte +22 -0
- package/dist/views/extra/texts/text-country.svelte.d.ts +6 -0
- package/dist/views/extra/types.d.ts +5 -0
- package/dist/views/extra/types.js +1 -0
- package/dist/views/index.d.ts +2 -0
- package/dist/views/index.js +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ripple } from '../../../../../actions/ripple.js';
|
|
3
|
+
import { openFilePickerDialog } from '../../../../../services/index.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import Icon from '../../../icon/components/icon/icon.svelte';
|
|
7
|
+
import { mdiAttachment } from '../../../icon/index.js';
|
|
8
|
+
import type { InputFieldProps } from '../../types';
|
|
9
|
+
import InputField from '../input-field/input-field.svelte';
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
appearance,
|
|
13
|
+
size,
|
|
14
|
+
className,
|
|
15
|
+
accepts = '',
|
|
16
|
+
multiple = false,
|
|
17
|
+
value = $bindable(null),
|
|
18
|
+
...props
|
|
19
|
+
}: InputFieldProps & {
|
|
20
|
+
accepts?: string;
|
|
21
|
+
multiple?: boolean;
|
|
22
|
+
value?: File | File[] | null;
|
|
23
|
+
} = $props();
|
|
24
|
+
|
|
25
|
+
let btnRoundedClassName = $derived.by(() => {
|
|
26
|
+
if (!appearance || appearance == 'normal') {
|
|
27
|
+
return 'rounded-tr-lg rounded-br-lg';
|
|
28
|
+
}
|
|
29
|
+
return '';
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
let btnIconSizeClassName = $derived.by(() => {
|
|
33
|
+
let className = '';
|
|
34
|
+
if (size) {
|
|
35
|
+
switch (size) {
|
|
36
|
+
case 'lg':
|
|
37
|
+
className = '!h-7 !w-7';
|
|
38
|
+
break;
|
|
39
|
+
case 'md':
|
|
40
|
+
className = '!h-6 !w-6';
|
|
41
|
+
break;
|
|
42
|
+
case 'sm':
|
|
43
|
+
className = '!h-5 !w-5';
|
|
44
|
+
break;
|
|
45
|
+
case 'xs':
|
|
46
|
+
className = '!h-4 !w-4';
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return className;
|
|
51
|
+
});
|
|
52
|
+
let fileNameDisplay = $state('');
|
|
53
|
+
|
|
54
|
+
let inputFieldRef: any | null = $state(null);
|
|
55
|
+
|
|
56
|
+
export function focus() {
|
|
57
|
+
inputFieldRef?.focus();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getElement() {
|
|
61
|
+
return inputFieldRef;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function select() {
|
|
65
|
+
inputFieldRef && inputFieldRef.select();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function handleFileAttachment<T extends File | File[]>() {
|
|
69
|
+
let res: File | File[] | null = null;
|
|
70
|
+
res = await openFilePickerDialog<T>(accepts, { multiple: multiple || false });
|
|
71
|
+
if (res) {
|
|
72
|
+
value = res;
|
|
73
|
+
if (multiple) {
|
|
74
|
+
let files: File[] = value as File[];
|
|
75
|
+
fileNameDisplay = files.map((file) => file.name).join(', ');
|
|
76
|
+
} else {
|
|
77
|
+
let file: File = value as File;
|
|
78
|
+
fileNameDisplay = file.name;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
{#snippet fileButton()}
|
|
85
|
+
<button
|
|
86
|
+
id="btn-file-picker"
|
|
87
|
+
type="button"
|
|
88
|
+
class="h-full px-3 hover:bg-gray-100 focus:outline-primary {btnRoundedClassName} "
|
|
89
|
+
use:ripple
|
|
90
|
+
onclick={handleFileAttachment}
|
|
91
|
+
>
|
|
92
|
+
<Icon path={mdiAttachment} className=" {btnIconSizeClassName}"></Icon>
|
|
93
|
+
</button>
|
|
94
|
+
{/snippet}
|
|
95
|
+
|
|
96
|
+
<InputField
|
|
97
|
+
bind:this={inputFieldRef}
|
|
98
|
+
{...props}
|
|
99
|
+
{appearance}
|
|
100
|
+
{size}
|
|
101
|
+
value={fileNameDisplay}
|
|
102
|
+
className="pr-14 {className}"
|
|
103
|
+
type="text"
|
|
104
|
+
readonly
|
|
105
|
+
rightSnippet={fileButton}
|
|
106
|
+
/>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { InputFieldProps } from '../../types';
|
|
2
|
+
type $$ComponentProps = InputFieldProps & {
|
|
3
|
+
accepts?: string;
|
|
4
|
+
multiple?: boolean;
|
|
5
|
+
value?: File | File[] | null;
|
|
6
|
+
};
|
|
7
|
+
declare const FileField: import("svelte").Component<$$ComponentProps, {
|
|
8
|
+
focus: () => void;
|
|
9
|
+
getElement: () => any;
|
|
10
|
+
select: () => void;
|
|
11
|
+
}, "value">;
|
|
12
|
+
type FileField = ReturnType<typeof FileField>;
|
|
13
|
+
export default FileField;
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { InputFieldProps } from '../../types';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import Label from '../label/label.svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
appearance = 'normal',
|
|
9
|
+
ariaControls,
|
|
10
|
+
ariaExpanded,
|
|
11
|
+
autofocus = false,
|
|
12
|
+
className = '',
|
|
13
|
+
cols,
|
|
14
|
+
containerClassName = '',
|
|
15
|
+
contentSnippet,
|
|
16
|
+
contentSnippetClassName,
|
|
17
|
+
disabled = false,
|
|
18
|
+
floatingLabel = false,
|
|
19
|
+
hasRequiredSymbol = true,
|
|
20
|
+
id = '',
|
|
21
|
+
label = '',
|
|
22
|
+
labelClassName = '',
|
|
23
|
+
leftSnippet,
|
|
24
|
+
leftSnippetContainerClassName = '',
|
|
25
|
+
max,
|
|
26
|
+
maxlength,
|
|
27
|
+
min,
|
|
28
|
+
minlength,
|
|
29
|
+
multiple = false,
|
|
30
|
+
name = '',
|
|
31
|
+
title,
|
|
32
|
+
onBlur,
|
|
33
|
+
onChange,
|
|
34
|
+
onClick,
|
|
35
|
+
onDblClick,
|
|
36
|
+
onDrag,
|
|
37
|
+
onDragOver,
|
|
38
|
+
onDrop,
|
|
39
|
+
onFocus,
|
|
40
|
+
onInput,
|
|
41
|
+
onKeyDown,
|
|
42
|
+
onKeyPress,
|
|
43
|
+
onKeyUp,
|
|
44
|
+
onMouseDown,
|
|
45
|
+
onMouseUp,
|
|
46
|
+
pattern,
|
|
47
|
+
placeholder = '',
|
|
48
|
+
readonly = false,
|
|
49
|
+
required = false,
|
|
50
|
+
requiredSymbol = '*',
|
|
51
|
+
requiredSymbolColor = 'red',
|
|
52
|
+
rightSnippet,
|
|
53
|
+
rightSnippetContainerClassName = '',
|
|
54
|
+
role,
|
|
55
|
+
rows = 5,
|
|
56
|
+
size = 'md',
|
|
57
|
+
step,
|
|
58
|
+
type = 'text',
|
|
59
|
+
value = $bindable()
|
|
60
|
+
}: InputFieldProps = $props();
|
|
61
|
+
|
|
62
|
+
let inputRef: HTMLInputElement | HTMLTextAreaElement | null = $state(null);
|
|
63
|
+
|
|
64
|
+
let nameDerived = $derived(name || id);
|
|
65
|
+
let idDerived = $derived(id || name);
|
|
66
|
+
|
|
67
|
+
let containerClassNameDerived = $derived.by(() => {
|
|
68
|
+
if (floatingLabel || leftSnippet != null || rightSnippet != null) {
|
|
69
|
+
return (containerClassName || '') + ' relative';
|
|
70
|
+
}
|
|
71
|
+
return containerClassName;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
let sizeClassName = $derived.by(() => {
|
|
75
|
+
let sizeClassName = '';
|
|
76
|
+
if (size) {
|
|
77
|
+
switch (size) {
|
|
78
|
+
case 'lg':
|
|
79
|
+
sizeClassName = 'p-4 text-neutral';
|
|
80
|
+
break;
|
|
81
|
+
case 'md':
|
|
82
|
+
sizeClassName = 'p-2.5 text-sm';
|
|
83
|
+
break;
|
|
84
|
+
case 'sm':
|
|
85
|
+
sizeClassName = 'p-2 text-xs';
|
|
86
|
+
break;
|
|
87
|
+
case 'xs':
|
|
88
|
+
sizeClassName = 'p-1 text-xs';
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return sizeClassName;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
let floatingLabelPaddingClassName = $derived.by(() => {
|
|
96
|
+
if (floatingLabel) {
|
|
97
|
+
if (size) {
|
|
98
|
+
let floatingClassName = '';
|
|
99
|
+
switch (size) {
|
|
100
|
+
case 'lg':
|
|
101
|
+
floatingClassName = ` px-1 peer-focus:px-1 peer-placeholder-shown:px-4 `;
|
|
102
|
+
break;
|
|
103
|
+
case 'md':
|
|
104
|
+
floatingClassName = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2.5 ';
|
|
105
|
+
break;
|
|
106
|
+
case 'sm':
|
|
107
|
+
floatingClassName = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2';
|
|
108
|
+
break;
|
|
109
|
+
case 'xs':
|
|
110
|
+
floatingClassName = ' px-0 peer-focus:px-0 peer-placeholder-shown:px-1 ';
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
return floatingClassName;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return '';
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
let floatingLabelTextClassName = $derived.by(() => {
|
|
120
|
+
let className = '';
|
|
121
|
+
if (floatingLabel) {
|
|
122
|
+
if (size) {
|
|
123
|
+
switch (size) {
|
|
124
|
+
case 'lg':
|
|
125
|
+
className = 'text-neutral';
|
|
126
|
+
break;
|
|
127
|
+
case 'md':
|
|
128
|
+
className = 'text-sm';
|
|
129
|
+
break;
|
|
130
|
+
case 'sm':
|
|
131
|
+
className = 'text-xs';
|
|
132
|
+
break;
|
|
133
|
+
case 'xs':
|
|
134
|
+
className = 'text-xs';
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return className;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
let floatingLabelClassName = $derived.by(() => {
|
|
143
|
+
if (floatingLabel) {
|
|
144
|
+
return `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-focus:bg-white dark:bg-neutral-700 peer-focus:bg-neutral-800 peer-placeholder-shown:bg-transparent start-1 ${floatingLabelPaddingClassName} ${floatingLabelTextClassName}`;
|
|
145
|
+
}
|
|
146
|
+
return '';
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
let appearanceClassName = $derived.by(() => {
|
|
150
|
+
let className = '';
|
|
151
|
+
if (appearance) {
|
|
152
|
+
switch (appearance) {
|
|
153
|
+
case 'normal':
|
|
154
|
+
className =
|
|
155
|
+
'border rounded-lg bg-neutral-100 dark:bg-neutral-700 border-neutral-300 dark:border-neutral-500 text-neutral-950 dark:text-neutral-50 focus:ring-primary-500 focus:border-primary-500 dark:focus:ring-primary-500 dark:focus:border-primary-500 focus:bg-neutral-50 dark:focus:bg-neutral-800 ';
|
|
156
|
+
break;
|
|
157
|
+
case 'box':
|
|
158
|
+
className =
|
|
159
|
+
'border bg-neutral-100 dark:bg-neutral-700 border-neutral-300 dark:border-neutral-500 text-neutral-950 dark:text-neutral-50 focus:ring-primary-500 focus:border-primary-500 dark:focus:ring-primary-500 dark:focus:border-primary-500 focus:bg-neutral-50 dark:focus:bg-neutral-800 ';
|
|
160
|
+
break;
|
|
161
|
+
case 'fill':
|
|
162
|
+
className =
|
|
163
|
+
' border-0 appearance-none focus:ring-0 bg-neutral-100 dark:bg-neutral-700 text-neutral-950 dark:text-neutral-50 focus:bg-neutral-50 dark:focus:bg-neutral-800 ';
|
|
164
|
+
break;
|
|
165
|
+
case 'underline':
|
|
166
|
+
className =
|
|
167
|
+
'bg-transparent border-0 border-b-2 appearance-none focus:ring-0 text-neutral-950 dark:text-neutral-50 border-neutral-300 dark:border-neutral-700 focus:border-primary-500 dark:focus:border-primary-500';
|
|
168
|
+
break;
|
|
169
|
+
case 'fill-underline':
|
|
170
|
+
className =
|
|
171
|
+
'border-0 border-b-2 appearance-none ring-0 text-neutral-950 dark:text-neutral-50 bg-neutral-100 dark:bg-neutral-700 border-neutral-300 dark:border-neutral-500 focus:border-primary-500 dark:focus:border-primary-500 ';
|
|
172
|
+
break;
|
|
173
|
+
case 'none':
|
|
174
|
+
className =
|
|
175
|
+
'border-0 focus:ring-0 appearance-none text-neutral-950 dark:text-neutral-50 bg-transparent dark:bg-transparent focus:bg-neutral-100 dark:focus:bg-neutral-800 hover:bg-neutral-100 dark:hover:bg-neutral-800';
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return className;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
export function focus() {
|
|
183
|
+
inputRef && inputRef.focus();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function getElement() {
|
|
187
|
+
return inputRef;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function select() {
|
|
191
|
+
return inputRef && (inputRef as HTMLInputElement).select();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function getBoundingClientRect() {
|
|
195
|
+
if (inputRef) {
|
|
196
|
+
return inputRef.getBoundingClientRect();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
$effect(() => {
|
|
201
|
+
setTimeout(() => {
|
|
202
|
+
if (inputRef && autofocus) {
|
|
203
|
+
inputRef.focus();
|
|
204
|
+
}
|
|
205
|
+
}, 10);
|
|
206
|
+
});
|
|
207
|
+
</script>
|
|
208
|
+
|
|
209
|
+
{#snippet labelSnippet()}
|
|
210
|
+
<Label
|
|
211
|
+
forName={idDerived}
|
|
212
|
+
{label}
|
|
213
|
+
className=" {floatingLabel ? '' : 'mb-1 '} {floatingLabelClassName} {labelClassName}"
|
|
214
|
+
{required}
|
|
215
|
+
{requiredSymbolColor}
|
|
216
|
+
{requiredSymbol}
|
|
217
|
+
{hasRequiredSymbol}
|
|
218
|
+
/>
|
|
219
|
+
{/snippet}
|
|
220
|
+
|
|
221
|
+
{#if !floatingLabel && label}
|
|
222
|
+
{@render labelSnippet()}
|
|
223
|
+
{/if}
|
|
224
|
+
|
|
225
|
+
<div class="w-full {containerClassNameDerived}">
|
|
226
|
+
{#if leftSnippet}
|
|
227
|
+
<div
|
|
228
|
+
class="left-children absolute flex items-center justify-center {leftSnippetContainerClassName}"
|
|
229
|
+
>
|
|
230
|
+
{@render leftSnippet()}
|
|
231
|
+
</div>
|
|
232
|
+
{/if}
|
|
233
|
+
|
|
234
|
+
{#if type == 'textarea'}
|
|
235
|
+
<textarea
|
|
236
|
+
bind:this={inputRef}
|
|
237
|
+
bind:value
|
|
238
|
+
class="peer block w-full outline-none {appearanceClassName} {sizeClassName} {className}"
|
|
239
|
+
{title}
|
|
240
|
+
id={idDerived}
|
|
241
|
+
name={nameDerived}
|
|
242
|
+
{placeholder}
|
|
243
|
+
{required}
|
|
244
|
+
{disabled}
|
|
245
|
+
{readonly}
|
|
246
|
+
{maxlength}
|
|
247
|
+
{minlength}
|
|
248
|
+
{rows}
|
|
249
|
+
{cols}
|
|
250
|
+
onchange={onChange}
|
|
251
|
+
oninput={onInput}
|
|
252
|
+
onfocus={onFocus}
|
|
253
|
+
onblur={onBlur}
|
|
254
|
+
ondblclick={onDblClick}
|
|
255
|
+
onclick={onClick}
|
|
256
|
+
onmousedown={onMouseDown}
|
|
257
|
+
onmouseup={onMouseUp}
|
|
258
|
+
onkeydown={onKeyDown}
|
|
259
|
+
onkeyup={onKeyUp}
|
|
260
|
+
onkeypress={onKeyPress}
|
|
261
|
+
ondrop={onDrop}
|
|
262
|
+
ondrag={onDrag}
|
|
263
|
+
ondragover={onDragOver}
|
|
264
|
+
></textarea>
|
|
265
|
+
{:else}
|
|
266
|
+
<input
|
|
267
|
+
bind:this={inputRef}
|
|
268
|
+
bind:value
|
|
269
|
+
class="peer block w-full outline-none {appearanceClassName} {sizeClassName} {className}"
|
|
270
|
+
{title}
|
|
271
|
+
{type}
|
|
272
|
+
id={idDerived}
|
|
273
|
+
name={nameDerived}
|
|
274
|
+
{placeholder}
|
|
275
|
+
{required}
|
|
276
|
+
{disabled}
|
|
277
|
+
{readonly}
|
|
278
|
+
{maxlength}
|
|
279
|
+
{minlength}
|
|
280
|
+
{min}
|
|
281
|
+
{max}
|
|
282
|
+
{step}
|
|
283
|
+
{pattern}
|
|
284
|
+
{multiple}
|
|
285
|
+
{role}
|
|
286
|
+
onchange={onChange}
|
|
287
|
+
oninput={onInput}
|
|
288
|
+
onfocus={onFocus}
|
|
289
|
+
onblur={onBlur}
|
|
290
|
+
ondblclick={onDblClick}
|
|
291
|
+
onclick={onClick}
|
|
292
|
+
onmousedown={onMouseDown}
|
|
293
|
+
onmouseup={onMouseUp}
|
|
294
|
+
onkeydown={onKeyDown}
|
|
295
|
+
onkeyup={onKeyUp}
|
|
296
|
+
onkeypress={onKeyPress}
|
|
297
|
+
ondrop={onDrop}
|
|
298
|
+
ondrag={onDrag}
|
|
299
|
+
ondragover={onDragOver}
|
|
300
|
+
aria-controls={ariaControls}
|
|
301
|
+
aria-expanded={ariaExpanded}
|
|
302
|
+
/>
|
|
303
|
+
{/if}
|
|
304
|
+
{#if contentSnippet}
|
|
305
|
+
<div
|
|
306
|
+
class="pointer-events-none absolute inset-0 block w-full overflow-hidden {appearanceClassName} {sizeClassName} {contentSnippetClassName}"
|
|
307
|
+
>
|
|
308
|
+
{@render contentSnippet()}
|
|
309
|
+
</div>
|
|
310
|
+
{/if}
|
|
311
|
+
{#if rightSnippet}
|
|
312
|
+
<div
|
|
313
|
+
class="right-children absolute flex items-center justify-center {rightSnippetContainerClassName}"
|
|
314
|
+
>
|
|
315
|
+
{@render rightSnippet()}
|
|
316
|
+
</div>
|
|
317
|
+
{/if}
|
|
318
|
+
|
|
319
|
+
{#if label && floatingLabel}
|
|
320
|
+
{@render labelSnippet()}
|
|
321
|
+
{/if}
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<style>
|
|
325
|
+
.left-children {
|
|
326
|
+
left: 2px;
|
|
327
|
+
top: 2px;
|
|
328
|
+
bottom: 2px;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.right-children {
|
|
332
|
+
right: 2px;
|
|
333
|
+
top: 2px;
|
|
334
|
+
bottom: 2px;
|
|
335
|
+
}
|
|
336
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InputFieldProps } from '../../types';
|
|
2
|
+
declare const InputField: import("svelte").Component<InputFieldProps, {
|
|
3
|
+
focus: () => void;
|
|
4
|
+
getElement: () => HTMLInputElement | HTMLTextAreaElement;
|
|
5
|
+
select: () => void;
|
|
6
|
+
getBoundingClientRect: () => DOMRect;
|
|
7
|
+
}, "value">;
|
|
8
|
+
type InputField = ReturnType<typeof InputField>;
|
|
9
|
+
export default InputField;
|
|
@@ -0,0 +1,48 @@
|
|
|
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-neutral-500 dark:text-neutral-400 {hasRequiredSymbol && required
|
|
30
|
+
? 'required'
|
|
31
|
+
: ''} {className}"
|
|
32
|
+
style="--requiredSymbolColor:{requiredSymbolColor}; --requiredSymbol: '{requiredSymbol}'; "
|
|
33
|
+
>
|
|
34
|
+
{#if children}
|
|
35
|
+
{@render children()}
|
|
36
|
+
{:else}
|
|
37
|
+
{label || ''}
|
|
38
|
+
{/if}
|
|
39
|
+
</label>
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
.required::after {
|
|
43
|
+
content: var(--requiredSymbol);
|
|
44
|
+
color: var(--requiredSymbolColor);
|
|
45
|
+
font-weight: bold;
|
|
46
|
+
margin-left: 4px;
|
|
47
|
+
}
|
|
48
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type PropsType = {
|
|
3
|
+
forName?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
requiredSymbolColor?: string;
|
|
9
|
+
requiredSymbol?: string;
|
|
10
|
+
hasRequiredSymbol?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare const Label: import("svelte").Component<PropsType, {}, "">;
|
|
13
|
+
type Label = ReturnType<typeof Label>;
|
|
14
|
+
export default Label;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { InputFieldProps } from '../../types';
|
|
3
|
+
import InputField from '../input-field/input-field.svelte';
|
|
4
|
+
|
|
5
|
+
let { value = $bindable(), ...props }: InputFieldProps = $props();
|
|
6
|
+
|
|
7
|
+
let inputFieldRef: any | null = $state(null);
|
|
8
|
+
|
|
9
|
+
export function focus() {
|
|
10
|
+
inputFieldRef?.focus();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getElement() {
|
|
14
|
+
return inputFieldRef;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function select() {
|
|
18
|
+
inputFieldRef && inputFieldRef.select();
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<InputField bind:this={inputFieldRef} {...props} type="number" bind:value />
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InputFieldProps } from '../../types';
|
|
2
|
+
declare const NumberField: import("svelte").Component<InputFieldProps, {
|
|
3
|
+
focus: () => void;
|
|
4
|
+
getElement: () => any;
|
|
5
|
+
select: () => void;
|
|
6
|
+
}, "value">;
|
|
7
|
+
type NumberField = ReturnType<typeof NumberField>;
|
|
8
|
+
export default NumberField;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ripple } from '../../../../../actions/ripple.js';
|
|
3
|
+
import Icon from '../../../icon/components/icon/icon.svelte';
|
|
4
|
+
import { mdiEyeOffOutline, mdiEyeOutline } from '../../../icon/index.js';
|
|
5
|
+
import type { InputFieldProps } from '../../types';
|
|
6
|
+
import InputField from '../input-field/input-field.svelte';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
type = 'password',
|
|
10
|
+
size,
|
|
11
|
+
appearance,
|
|
12
|
+
buttonClassName,
|
|
13
|
+
iconClassName,
|
|
14
|
+
name,
|
|
15
|
+
id,
|
|
16
|
+
value = $bindable(),
|
|
17
|
+
...props
|
|
18
|
+
}: InputFieldProps & {
|
|
19
|
+
buttonClassName?: string;
|
|
20
|
+
iconClassName?: string;
|
|
21
|
+
} = $props();
|
|
22
|
+
|
|
23
|
+
let btnRoundedClassName = $derived.by(() => {
|
|
24
|
+
if (!appearance || appearance == 'normal') {
|
|
25
|
+
return 'rounded-tr-lg rounded-br-lg';
|
|
26
|
+
}
|
|
27
|
+
return '';
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
let btnIconSizeClassName = $derived.by(() => {
|
|
31
|
+
let className = '';
|
|
32
|
+
if (size) {
|
|
33
|
+
switch (size) {
|
|
34
|
+
case 'lg':
|
|
35
|
+
className = '!h-7 !w-7';
|
|
36
|
+
break;
|
|
37
|
+
case 'md':
|
|
38
|
+
className = '!h-6 !w-6';
|
|
39
|
+
break;
|
|
40
|
+
case 'sm':
|
|
41
|
+
className = '!h-5 !w-5';
|
|
42
|
+
break;
|
|
43
|
+
case 'xs':
|
|
44
|
+
className = '!h-4 !w-4';
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return className;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
let inputFieldRef: any | null = $state(null);
|
|
52
|
+
|
|
53
|
+
export function focus() {
|
|
54
|
+
inputFieldRef?.focus();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getElement() {
|
|
58
|
+
return inputFieldRef;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function select() {
|
|
62
|
+
inputFieldRef && inputFieldRef.select();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function handleTogglePassword() {
|
|
66
|
+
if (type == 'password') {
|
|
67
|
+
type = 'text';
|
|
68
|
+
} else {
|
|
69
|
+
type = 'password';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
{#snippet showPasswordButton()}
|
|
75
|
+
<button
|
|
76
|
+
id="btn-eye-{name || id}"
|
|
77
|
+
type="button"
|
|
78
|
+
class="h-full px-3 hover:bg-neutral-100 focus:outline-primary {btnRoundedClassName} {buttonClassName}"
|
|
79
|
+
use:ripple
|
|
80
|
+
onclick={handleTogglePassword}
|
|
81
|
+
>
|
|
82
|
+
<Icon
|
|
83
|
+
path={type == 'password' ? mdiEyeOffOutline : mdiEyeOutline}
|
|
84
|
+
className=" {btnIconSizeClassName} {iconClassName}"
|
|
85
|
+
/>
|
|
86
|
+
</button>
|
|
87
|
+
{/snippet}
|
|
88
|
+
|
|
89
|
+
<InputField
|
|
90
|
+
bind:this={inputFieldRef}
|
|
91
|
+
{...props}
|
|
92
|
+
{type}
|
|
93
|
+
{id}
|
|
94
|
+
{name}
|
|
95
|
+
maxlength={props?.maxlength || 200}
|
|
96
|
+
rightSnippet={showPasswordButton}
|
|
97
|
+
{size}
|
|
98
|
+
{appearance}
|
|
99
|
+
bind:value
|
|
100
|
+
/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InputFieldProps } from '../../types';
|
|
2
|
+
type $$ComponentProps = InputFieldProps & {
|
|
3
|
+
buttonClassName?: string;
|
|
4
|
+
iconClassName?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const PasswordField: import("svelte").Component<$$ComponentProps, {
|
|
7
|
+
focus: () => void;
|
|
8
|
+
getElement: () => any;
|
|
9
|
+
select: () => void;
|
|
10
|
+
}, "value">;
|
|
11
|
+
type PasswordField = ReturnType<typeof PasswordField>;
|
|
12
|
+
export default PasswordField;
|