@cloudparker/moldex.js 0.0.124 → 4.1.0
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/types.d.ts +6 -0
- package/dist/types.js +7 -0
- package/dist/views/core/button/components/button/button.svelte +135 -83
- package/dist/views/core/button/components/button-back/button-back.svelte +28 -15
- package/dist/views/core/button/components/button-close/button-close.svelte +4 -2
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte +29 -15
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte +96 -72
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte.d.ts +1 -1
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte +98 -52
- package/dist/views/core/button/components/button-menu/button-menu.svelte +79 -43
- package/dist/views/core/button/components/button-ok/button-ok.svelte +4 -2
- package/dist/views/core/button/components/button-search/button-search.svelte +45 -21
- package/dist/views/core/button/components/switch/switch.svelte +50 -37
- package/dist/views/core/common/components/content-area/content-area.svelte +40 -27
- package/dist/views/core/common/components/loading/loading.svelte +9 -2
- package/dist/views/core/common/components/virtual-scrolling/virtual-scrolling-list.svelte +37 -20
- package/dist/views/core/dialog/components/cropper-dialog/cropper-dialog.svelte +52 -36
- package/dist/views/core/dialog/components/dialog/dialog.svelte +298 -177
- package/dist/views/core/dialog/components/loading-dialog/loading-dialog.svelte +30 -18
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte +17 -7
- package/dist/views/core/dialog/components/number-field-dialog/number-field-dialog.svelte +41 -26
- package/dist/views/core/dialog/components/picker-dialog/picker-dialog.svelte +150 -105
- package/dist/views/core/dialog/components/text-field-dialog/text-field-dialog.svelte +40 -25
- package/dist/views/core/dialog/components/textarea-field-dialog/textarea-field-dialog.svelte +40 -25
- package/dist/views/core/drawer/components/drawer/drawer.svelte +58 -36
- package/dist/views/core/icon/components/icon/icon.svelte +24 -12
- package/dist/views/core/icon/components/icon-circle/icon-circle.svelte +10 -2
- package/dist/views/core/input/components/checkbox-field/checkbox-field.svelte +44 -25
- package/dist/views/core/input/components/color-field/color-field.svelte +81 -69
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte +359 -269
- package/dist/views/core/input/components/date-field/date-field.svelte +39 -30
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte +18 -12
- package/dist/views/core/input/components/email-field/email-field.svelte +17 -12
- package/dist/views/core/input/components/file-field/file-field.svelte +78 -64
- package/dist/views/core/input/components/input-field/input-field.svelte +267 -164
- package/dist/views/core/input/components/label/label.svelte +24 -10
- package/dist/views/core/input/components/number-field/number-field.svelte +18 -12
- package/dist/views/core/input/components/password-field/password-field.svelte +70 -57
- package/dist/views/core/input/components/phone-field/phone-field.svelte +155 -104
- package/dist/views/core/input/components/radio-field/radio-field.svelte +83 -52
- package/dist/views/core/input/components/range-field/range-field.svelte +67 -44
- package/dist/views/core/input/components/search-field/search-field.svelte +62 -45
- package/dist/views/core/input/components/text-field/text-field.svelte +21 -16
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +17 -12
- package/dist/views/core/input/components/time-field/time-field.svelte +17 -12
- package/dist/views/core/navbar/components/navbar/navbar.svelte +76 -38
- package/dist/views/core/no-data/components/no-data/no-data.svelte +36 -19
- package/dist/views/core/pagination/components/pagination/pagination.svelte +90 -66
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte +36 -22
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte +5 -1
- package/dist/views/core/screen-detector/components/screen-detector.svelte +13 -9
- package/dist/views/core/sidebar/components/sidebar.svelte +36 -23
- package/dist/views/core/spinner/components/spinner/spinner.svelte +6 -1
- package/dist/views/core/text/components/text-await/text-await.svelte +9 -1
- package/dist/views/core/text/components/text-copy/text-copy.svelte +27 -16
- package/dist/views/core/text/components/text-currency/text-currency.svelte +13 -2
- package/dist/views/core/text/components/text-date/text-date.svelte +32 -20
- package/dist/views/core/text/components/text-email/text-email.svelte +12 -3
- package/dist/views/core/text/components/text-html/text-html.svelte +2 -1
- package/dist/views/core/text/components/text-phone/text-phone.svelte +12 -3
- package/dist/views/core/toast/components/toast/toast.svelte +43 -20
- package/dist/views/extra/fields/country-combobox-field.svelte +23 -15
- package/dist/views/extra/loaders/country-loader.svelte +33 -15
- package/dist/views/extra/texts/text-country-state.svelte +36 -28
- package/dist/views/extra/texts/text-country.svelte +16 -8
- package/package.json +3 -12
- package/readme.md +57 -2
- package/dist/tailwind.css +0 -1
- package/dist/theme.css +0 -27
|
@@ -1,107 +1,158 @@
|
|
|
1
|
-
<script module lang="ts"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type LibPhoneNumberParseType = {
|
|
3
|
+
isValid: () => boolean;
|
|
4
|
+
nationalNumber: string;
|
|
5
|
+
countryCallingCode: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type LibPhoneNumberType = {
|
|
9
|
+
parsePhoneNumber: (phoneNumber: string, dialCode?: string) => LibPhoneNumberParseType;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type CountryType = {
|
|
13
|
+
name: string;
|
|
14
|
+
dialCode: string;
|
|
15
|
+
isoCode: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type EasyCountryDataType = {
|
|
19
|
+
getCountries: () => CountryType[];
|
|
20
|
+
getCountry: (params: { name?: string; dialCode?: string; isoCode?: string }) => CountryType;
|
|
21
|
+
};
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import { ripple } from '../../../../../actions';
|
|
26
|
+
import { openPickerDialog } from '../../../../../services';
|
|
27
|
+
import EasyScriptLoader from '@cloudparker/easy-script-loader-svelte';
|
|
28
|
+
import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
id,
|
|
32
|
+
name,
|
|
33
|
+
value = $bindable(''),
|
|
34
|
+
size,
|
|
35
|
+
appearance,
|
|
36
|
+
buttonClassName,
|
|
37
|
+
className,
|
|
38
|
+
dialCode = $bindable('+1'),
|
|
39
|
+
floatingLabel,
|
|
40
|
+
labelClassName,
|
|
41
|
+
...props
|
|
42
|
+
}: InputFieldProps & {
|
|
43
|
+
buttonClassName?: string;
|
|
44
|
+
dialCode?: string;
|
|
45
|
+
} = $props();
|
|
46
|
+
|
|
47
|
+
let EasyCountryData: EasyCountryDataType;
|
|
48
|
+
let LibPhonenumber: LibPhoneNumberType | null = $state(null);
|
|
49
|
+
let inputFieldRef: any | null = $state(null);
|
|
50
|
+
|
|
51
|
+
let dailCodeValue = $derived.by(() => {
|
|
52
|
+
if (value && LibPhonenumber) {
|
|
53
|
+
let { dialCode } = validatePhoneNumber(value);
|
|
54
|
+
return dialCode;
|
|
55
|
+
}
|
|
56
|
+
return formatDialCode(dialCode);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
let phoneNumberValue = $derived.by(() => {
|
|
60
|
+
if (value && LibPhonenumber) {
|
|
61
|
+
let { phoneNumber } = validatePhoneNumber(value);
|
|
62
|
+
return phoneNumber;
|
|
63
|
+
}
|
|
64
|
+
return '';
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
let btnRoundedClassName = $derived.by(() => {
|
|
68
|
+
if (!appearance || appearance == 'normal') {
|
|
69
|
+
return 'rounded-tl-lg rounded-bl-lg';
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
function validatePhoneNumber(number: string) {
|
|
74
|
+
try {
|
|
75
|
+
let parsed = LibPhonenumber?.parsePhoneNumber(number as string);
|
|
76
|
+
if (parsed && parsed.isValid()) {
|
|
77
|
+
return {
|
|
78
|
+
phoneNumber: parsed.nationalNumber || '',
|
|
79
|
+
dialCode: formatDialCode(parsed.countryCallingCode)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
} catch (error) {}
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function focus() {
|
|
87
|
+
inputFieldRef?.focus();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function getElement() {
|
|
91
|
+
return inputFieldRef;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function select() {
|
|
95
|
+
inputFieldRef && inputFieldRef.select();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function formatDialCode(dialcode: string) {
|
|
99
|
+
dialcode = `${dialCode}`.trim();
|
|
100
|
+
return dialCode.startsWith('+') ? dialcode : `+${dialCode}`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function handleDialCodePicker() {
|
|
104
|
+
if (EasyCountryData) {
|
|
105
|
+
let items = EasyCountryData.getCountries();
|
|
106
|
+
let res: string = await openPickerDialog<string>({
|
|
107
|
+
value: dialCode,
|
|
108
|
+
items,
|
|
109
|
+
identityFieldName: 'dialCode',
|
|
110
|
+
itemTileSnippet: dialCodePickerItemTile
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (res) {
|
|
114
|
+
dialCode = res;
|
|
115
|
+
if (dialCode && phoneNumberValue) {
|
|
116
|
+
value = `${dialCode}${phoneNumberValue}`;
|
|
117
|
+
}
|
|
118
|
+
inputFieldRef && inputFieldRef.focus();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function handleEasyCountryDataScriptLoad(lib: EasyCountryDataType) {
|
|
124
|
+
EasyCountryData = lib;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function handleLibphonenumberScriptLoad(lib: LibPhoneNumberType) {
|
|
128
|
+
LibPhonenumber = lib;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function handleNumberInput(ev: InputEvent) {
|
|
132
|
+
let target: HTMLInputElement = ev.target as HTMLInputElement;
|
|
133
|
+
let text: string = target?.value || '';
|
|
134
|
+
let { phoneNumber } = validatePhoneNumber(`${dialCode}${text}`);
|
|
135
|
+
if (phoneNumber) {
|
|
136
|
+
value = `${dialCode}${phoneNumber}`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function handleNumberKeyDown(ev: KeyboardEvent) {
|
|
141
|
+
if (
|
|
142
|
+
!(
|
|
143
|
+
(ev.key >= '0' && ev.key <= '9') ||
|
|
144
|
+
ev.key === 'Backspace' ||
|
|
145
|
+
ev.key === 'Delete' ||
|
|
146
|
+
ev.key === 'ArrowLeft' ||
|
|
147
|
+
ev.key === 'ArrowRight' ||
|
|
148
|
+
ev.key === 'ArrowUp' ||
|
|
149
|
+
ev.key === 'ArrowDown' ||
|
|
150
|
+
ev.key === 'Tab'
|
|
151
|
+
)
|
|
152
|
+
) {
|
|
153
|
+
ev.preventDefault();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
105
156
|
</script>
|
|
106
157
|
|
|
107
158
|
{#snippet dialCodePickerItemTile(item: any, index: number)}
|
|
@@ -1,56 +1,87 @@
|
|
|
1
|
-
<script lang="ts" module
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type RadioValuetype = string | boolean | number | Date;
|
|
3
|
+
export type RadioItem = { value: any; label: string; desc?: string };
|
|
4
|
+
export type RadioItems = (RadioValuetype | RadioItem)[];
|
|
5
|
+
export type RadioPosition = 'left' | 'right';
|
|
6
|
+
export type RadioDiration = 'vertical' | 'horizontal';
|
|
7
|
+
export type RadioPropsType = {
|
|
8
|
+
className?: string;
|
|
9
|
+
groupContainerClassName?: string;
|
|
10
|
+
hasPrimitiveItemsData?: boolean;
|
|
11
|
+
id?: string;
|
|
12
|
+
items?: RadioItems;
|
|
13
|
+
labelClassName?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
position?: RadioPosition;
|
|
16
|
+
direction?: RadioDiration;
|
|
17
|
+
radioContainerClassName?: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
subtitleClassName?: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
titleClassName?: string;
|
|
23
|
+
value?: RadioValuetype;
|
|
24
|
+
descClassName?: string;
|
|
25
|
+
onChange?: (value: RadioValuetype) => void;
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
let {
|
|
31
|
+
direction = 'vertical',
|
|
32
|
+
className,
|
|
33
|
+
groupContainerClassName,
|
|
34
|
+
id,
|
|
35
|
+
items = [],
|
|
36
|
+
labelClassName,
|
|
37
|
+
name,
|
|
38
|
+
position = 'left',
|
|
39
|
+
radioContainerClassName,
|
|
40
|
+
required,
|
|
41
|
+
subtitle,
|
|
42
|
+
subtitleClassName,
|
|
43
|
+
title,
|
|
44
|
+
titleClassName,
|
|
45
|
+
value = $bindable(),
|
|
46
|
+
descClassName,
|
|
47
|
+
onChange
|
|
48
|
+
}: RadioPropsType = $props();
|
|
49
|
+
|
|
50
|
+
let hasPrimitiveItemsData = $derived.by(() => {
|
|
51
|
+
if (items?.length) {
|
|
52
|
+
let item = items[0];
|
|
53
|
+
if (typeof item === 'object' && item !== null) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
});
|
|
2
59
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
});
|
|
31
|
-
let fieldsetId = $derived.by(() => {
|
|
32
|
-
if (id) {
|
|
33
|
-
return id;
|
|
34
|
-
} else {
|
|
35
|
-
return name;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
let preparedItems = $derived.by(() => {
|
|
39
|
-
if (items?.length) {
|
|
40
|
-
if (hasPrimitiveItemsData) {
|
|
41
|
-
return items.map((item) => ({ label: item, value: item }));
|
|
42
|
-
} else {
|
|
43
|
-
return items;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return [];
|
|
47
|
-
});
|
|
48
|
-
function handleChange(ev, item) {
|
|
49
|
-
value = item.value;
|
|
50
|
-
if (onChange && value) {
|
|
51
|
-
onChange(value);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
60
|
+
let fieldsetId = $derived.by(() => {
|
|
61
|
+
if (id) {
|
|
62
|
+
return id;
|
|
63
|
+
} else {
|
|
64
|
+
return name;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
let preparedItems: RadioItem[] = $derived.by(() => {
|
|
69
|
+
if (items?.length) {
|
|
70
|
+
if (hasPrimitiveItemsData) {
|
|
71
|
+
return items.map((item) => ({ label: item, value: item }) as RadioItem);
|
|
72
|
+
} else {
|
|
73
|
+
return items as RadioItem[];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return [];
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
function handleChange(ev: Event, item: RadioItem) {
|
|
80
|
+
value = item.value;
|
|
81
|
+
if (onChange && value) {
|
|
82
|
+
onChange(value);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
54
85
|
</script>
|
|
55
86
|
|
|
56
87
|
{#snippet labelSnippet(item: RadioItem, index: number)}
|
|
@@ -1,45 +1,69 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import InputField, { type InputFieldSize } from '../input-field/input-field.svelte';
|
|
3
|
+
|
|
4
|
+
type RangeFieldPropsType = {
|
|
5
|
+
id?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
size?: InputFieldSize;
|
|
9
|
+
value?: number;
|
|
10
|
+
min?: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
step?: number;
|
|
13
|
+
thumbSize?: string;
|
|
14
|
+
thumbColor?: string;
|
|
15
|
+
oninput?: (ev: any) => void;
|
|
16
|
+
onfocus?: (ev: any) => void;
|
|
17
|
+
onblur?: (ev: any) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
id,
|
|
22
|
+
value = $bindable(0),
|
|
23
|
+
size = 'md',
|
|
24
|
+
min = 0,
|
|
25
|
+
max = 100,
|
|
26
|
+
name,
|
|
27
|
+
step,
|
|
28
|
+
className,
|
|
29
|
+
thumbSize = '16px',
|
|
30
|
+
oninput,
|
|
31
|
+
onblur,
|
|
32
|
+
onfocus
|
|
33
|
+
}: RangeFieldPropsType = $props();
|
|
34
|
+
|
|
35
|
+
let rangeSizeClassName = $state('');
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
switch (size) {
|
|
39
|
+
case 'lg':
|
|
40
|
+
rangeSizeClassName = 'h-3 ';
|
|
41
|
+
break;
|
|
42
|
+
case 'md':
|
|
43
|
+
rangeSizeClassName = 'h-2 ';
|
|
44
|
+
break;
|
|
45
|
+
case 'sm':
|
|
46
|
+
rangeSizeClassName = 'h-1 ';
|
|
47
|
+
break;
|
|
48
|
+
case 'xs':
|
|
49
|
+
rangeSizeClassName = 'h-2-px ';
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
let inputRef: HTMLInputElement | null = $state(null);
|
|
55
|
+
|
|
56
|
+
export function getElement() {
|
|
57
|
+
return inputRef;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function focus() {
|
|
61
|
+
return inputRef && inputRef.focus();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function select() {
|
|
65
|
+
return inputRef && inputRef.select();
|
|
66
|
+
}
|
|
43
67
|
</script>
|
|
44
68
|
|
|
45
69
|
<input
|
|
@@ -64,8 +88,7 @@ export function select() {
|
|
|
64
88
|
}
|
|
65
89
|
|
|
66
90
|
.range-slider {
|
|
67
|
-
|
|
68
|
-
appearance: none;
|
|
91
|
+
appearance: none;
|
|
69
92
|
-webkit-appearance: none;
|
|
70
93
|
}
|
|
71
94
|
.range-slider::-webkit-slider-thumb {
|
|
@@ -1,48 +1,65 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { mdiMagnify } from '../../../icon';
|
|
3
|
+
import Icon from '../../../icon/components/icon/icon.svelte';
|
|
4
|
+
import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
className,
|
|
8
|
+
placeholder,
|
|
9
|
+
iconClassName,
|
|
10
|
+
value = $bindable(''),
|
|
11
|
+
onSearch,
|
|
12
|
+
...props
|
|
13
|
+
}: InputFieldProps & {
|
|
14
|
+
iconClassName?: string;
|
|
15
|
+
onSearch?: (value: string) => void;
|
|
16
|
+
} = $props();
|
|
17
|
+
|
|
18
|
+
const debouncedSearch = debounce(search, 300);
|
|
19
|
+
let lastQuery: string;
|
|
20
|
+
|
|
21
|
+
let inputFieldRef: any | null = $state(null);
|
|
22
|
+
|
|
23
|
+
export function focus() {
|
|
24
|
+
inputFieldRef?.focus();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getElement() {
|
|
28
|
+
return inputFieldRef;
|
|
29
|
+
}
|
|
30
|
+
export function select() {
|
|
31
|
+
inputFieldRef && inputFieldRef.select();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function handleInput(ev: any) {
|
|
35
|
+
// console.log(ev);
|
|
36
|
+
let input: HTMLInputElement = ev?.target;
|
|
37
|
+
if (input) {
|
|
38
|
+
let searchText = (input.value || '').toLowerCase().trim();
|
|
39
|
+
debouncedSearch(searchText);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function search(query: string) {
|
|
44
|
+
if (lastQuery != query) {
|
|
45
|
+
onSearch && onSearch(query);
|
|
46
|
+
lastQuery = query;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function debounce<T extends (...args: any[]) => void>(
|
|
51
|
+
func: T,
|
|
52
|
+
wait: number
|
|
53
|
+
): (...args: Parameters<T>) => void {
|
|
54
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
55
|
+
|
|
56
|
+
return function (...args: Parameters<T>) {
|
|
57
|
+
clearTimeout(timeout);
|
|
58
|
+
timeout = setTimeout(() => {
|
|
59
|
+
func(...args);
|
|
60
|
+
}, wait);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
46
63
|
</script>
|
|
47
64
|
|
|
48
65
|
{#snippet searchIcon()}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export function
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
maxlength,
|
|
6
|
+
value = $bindable(''),
|
|
7
|
+
...props
|
|
8
|
+
}: InputFieldProps & { value?: string | null | undefined } = $props();
|
|
9
|
+
let inputFieldRef: any | null = $state(null);
|
|
10
|
+
|
|
11
|
+
export function focus() {
|
|
12
|
+
inputFieldRef?.focus();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getElement() {
|
|
16
|
+
return inputFieldRef;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function select() {
|
|
20
|
+
return inputFieldRef && inputFieldRef.select();
|
|
21
|
+
}
|
|
17
22
|
</script>
|
|
18
23
|
|
|
19
24
|
<InputField
|