@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,187 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { ripple } from '../../../../../actions';
|
|
5
|
+
import { openPickerDialog } from '../../../../../services';
|
|
6
|
+
import EasyScriptLoader from '@cloudparker/easy-script-loader-svelte';
|
|
7
|
+
import InputField from '../input-field/input-field.svelte';
|
|
8
|
+
import type { EasyCountryDataType, InputFieldProps, LibPhoneNumberType } from '../../types';
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
id,
|
|
12
|
+
name,
|
|
13
|
+
value = $bindable(''),
|
|
14
|
+
size,
|
|
15
|
+
appearance,
|
|
16
|
+
buttonClassName,
|
|
17
|
+
className,
|
|
18
|
+
dialCode = $bindable('+1'),
|
|
19
|
+
floatingLabel,
|
|
20
|
+
labelClassName,
|
|
21
|
+
...props
|
|
22
|
+
}: InputFieldProps & {
|
|
23
|
+
buttonClassName?: string;
|
|
24
|
+
dialCode?: string;
|
|
25
|
+
} = $props();
|
|
26
|
+
|
|
27
|
+
let EasyCountryData: EasyCountryDataType;
|
|
28
|
+
let LibPhoneNumber: LibPhoneNumberType | null = $state(null);
|
|
29
|
+
let inputFieldRef: any | null = $state(null);
|
|
30
|
+
|
|
31
|
+
let dailCodeValue = $derived.by(() => {
|
|
32
|
+
if (value && LibPhoneNumber) {
|
|
33
|
+
let { dialCode } = validatePhoneNumber(value);
|
|
34
|
+
return dialCode;
|
|
35
|
+
}
|
|
36
|
+
return formatDialCode(dialCode);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
let phoneNumberValue = $derived.by(() => {
|
|
40
|
+
if (value && LibPhoneNumber) {
|
|
41
|
+
let { phoneNumber } = validatePhoneNumber(value);
|
|
42
|
+
return phoneNumber;
|
|
43
|
+
}
|
|
44
|
+
return '';
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
let btnRoundedClassName = $derived.by(() => {
|
|
48
|
+
if (!appearance || appearance == 'normal') {
|
|
49
|
+
return 'rounded-tl-lg rounded-bl-lg';
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
function validatePhoneNumber(number: string) {
|
|
54
|
+
try {
|
|
55
|
+
let parsed = LibPhoneNumber?.parsePhoneNumber(number as string);
|
|
56
|
+
if (parsed && parsed.isValid()) {
|
|
57
|
+
return {
|
|
58
|
+
phoneNumber: parsed.nationalNumber || '',
|
|
59
|
+
dialCode: formatDialCode(parsed.countryCallingCode)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {}
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function focus() {
|
|
67
|
+
inputFieldRef?.focus();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function getElement() {
|
|
71
|
+
return inputFieldRef;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function select() {
|
|
75
|
+
inputFieldRef && inputFieldRef.select();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function formatDialCode(dialcode: string) {
|
|
79
|
+
dialcode = `${dialCode}`.trim();
|
|
80
|
+
return dialCode.startsWith('+') ? dialcode : `+${dialCode}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function handleDialCodePicker() {
|
|
84
|
+
if (EasyCountryData) {
|
|
85
|
+
let items = EasyCountryData.getCountries();
|
|
86
|
+
let res: string = await openPickerDialog<string>({
|
|
87
|
+
value: dialCode,
|
|
88
|
+
items,
|
|
89
|
+
identityFieldName: 'dialCode',
|
|
90
|
+
itemTileSnippet: dialCodePickerItemTile
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (res) {
|
|
94
|
+
dialCode = res;
|
|
95
|
+
if (dialCode && phoneNumberValue) {
|
|
96
|
+
value = `${dialCode}${phoneNumberValue}`;
|
|
97
|
+
}
|
|
98
|
+
inputFieldRef && inputFieldRef.focus();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function handleEasyCountryDataScriptLoad(lib: EasyCountryDataType) {
|
|
104
|
+
EasyCountryData = lib;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function handleLibPhoneNumberScriptLoad(lib: LibPhoneNumberType) {
|
|
108
|
+
LibPhoneNumber = lib;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function handleNumberInput(ev: InputEvent) {
|
|
112
|
+
let target: HTMLInputElement = ev.target as HTMLInputElement;
|
|
113
|
+
let text: string = target?.value || '';
|
|
114
|
+
let { phoneNumber } = validatePhoneNumber(`${dialCode}${text}`);
|
|
115
|
+
if (phoneNumber) {
|
|
116
|
+
value = `${dialCode}${phoneNumber}`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function handleNumberKeyDown(ev: KeyboardEvent) {
|
|
121
|
+
if (
|
|
122
|
+
!(
|
|
123
|
+
(ev.key >= '0' && ev.key <= '9') ||
|
|
124
|
+
ev.key === 'Backspace' ||
|
|
125
|
+
ev.key === 'Delete' ||
|
|
126
|
+
ev.key === 'ArrowLeft' ||
|
|
127
|
+
ev.key === 'ArrowRight' ||
|
|
128
|
+
ev.key === 'ArrowUp' ||
|
|
129
|
+
ev.key === 'ArrowDown' ||
|
|
130
|
+
ev.key === 'Tab'
|
|
131
|
+
)
|
|
132
|
+
) {
|
|
133
|
+
ev.preventDefault();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
{#snippet dialCodePickerItemTile(item: any, index: number)}
|
|
139
|
+
<div class="w-14 text-sm font-bold text-neutral">
|
|
140
|
+
{item.dialCode}
|
|
141
|
+
</div>
|
|
142
|
+
<div class="flex-grow">
|
|
143
|
+
{item.name}
|
|
144
|
+
</div>
|
|
145
|
+
{/snippet}
|
|
146
|
+
|
|
147
|
+
{#snippet showDialCodeButton()}
|
|
148
|
+
<button
|
|
149
|
+
id="btn-dialcode-picker-{name || id}"
|
|
150
|
+
type="button"
|
|
151
|
+
class="w-16 h-full hover:bg-gray-100 font-bold text-gray-400 focus:outline-primary {btnRoundedClassName} {buttonClassName}"
|
|
152
|
+
use:ripple
|
|
153
|
+
onclick={handleDialCodePicker}
|
|
154
|
+
>
|
|
155
|
+
{dailCodeValue}
|
|
156
|
+
</button>
|
|
157
|
+
{/snippet}
|
|
158
|
+
|
|
159
|
+
<EasyScriptLoader
|
|
160
|
+
scriptName="EasyCountryData"
|
|
161
|
+
scriptUrl="https://cdn.jsdelivr.net/gh/paramanandapradhan/easy-countrydata@main/dist/index.js"
|
|
162
|
+
onLoad={handleEasyCountryDataScriptLoad}
|
|
163
|
+
/>
|
|
164
|
+
|
|
165
|
+
<EasyScriptLoader
|
|
166
|
+
scriptName="libphonenumber"
|
|
167
|
+
scriptUrl="https://unpkg.com/libphonenumber-js@1.11.7/bundle/libphonenumber-min.js"
|
|
168
|
+
onLoad={handleLibPhoneNumberScriptLoad}
|
|
169
|
+
/>
|
|
170
|
+
|
|
171
|
+
<InputField
|
|
172
|
+
{...props}
|
|
173
|
+
bind:this={inputFieldRef}
|
|
174
|
+
value={phoneNumberValue}
|
|
175
|
+
type="tel"
|
|
176
|
+
{id}
|
|
177
|
+
{name}
|
|
178
|
+
maxlength={props?.maxlength || 12}
|
|
179
|
+
leftSnippet={showDialCodeButton}
|
|
180
|
+
{size}
|
|
181
|
+
{appearance}
|
|
182
|
+
{floatingLabel}
|
|
183
|
+
className="pl-16 {className}"
|
|
184
|
+
labelClassName=" {floatingLabel ? 'peer-placeholder-shown:ps-16' : ''} {labelClassName}"
|
|
185
|
+
onInput={handleNumberInput}
|
|
186
|
+
onKeyDown={handleNumberKeyDown}
|
|
187
|
+
/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InputFieldProps } from '../../types';
|
|
2
|
+
type $$ComponentProps = InputFieldProps & {
|
|
3
|
+
buttonClassName?: string;
|
|
4
|
+
dialCode?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const PhoneField: import("svelte").Component<$$ComponentProps, {
|
|
7
|
+
focus: () => void;
|
|
8
|
+
getElement: () => any;
|
|
9
|
+
select: () => void;
|
|
10
|
+
}, "value" | "dialCode">;
|
|
11
|
+
type PhoneField = ReturnType<typeof PhoneField>;
|
|
12
|
+
export default PhoneField;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { RadioItem, RadioPropsType } from '../../types';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
direction = 'vertical',
|
|
8
|
+
className,
|
|
9
|
+
groupContainerClassName,
|
|
10
|
+
id,
|
|
11
|
+
items = [],
|
|
12
|
+
labelClassName,
|
|
13
|
+
name,
|
|
14
|
+
position = 'left',
|
|
15
|
+
radioContainerClassName,
|
|
16
|
+
required,
|
|
17
|
+
subtitle,
|
|
18
|
+
subtitleClassName,
|
|
19
|
+
title,
|
|
20
|
+
titleClassName,
|
|
21
|
+
value = $bindable(),
|
|
22
|
+
descClassName,
|
|
23
|
+
onChange
|
|
24
|
+
}: RadioPropsType = $props();
|
|
25
|
+
|
|
26
|
+
let hasPrimitiveItemsData = $derived.by(() => {
|
|
27
|
+
if (items?.length) {
|
|
28
|
+
let item = items[0];
|
|
29
|
+
if (typeof item === 'object' && item !== null) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
let fieldsetId = $derived.by(() => {
|
|
37
|
+
if (id) {
|
|
38
|
+
return id;
|
|
39
|
+
} else {
|
|
40
|
+
return name;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
let preparedItems: RadioItem[] = $derived.by(() => {
|
|
45
|
+
if (items?.length) {
|
|
46
|
+
if (hasPrimitiveItemsData) {
|
|
47
|
+
return items.map((item) => ({ label: item, value: item }) as RadioItem);
|
|
48
|
+
} else {
|
|
49
|
+
return items as RadioItem[];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return [];
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
function handleChange(ev: Event, item: RadioItem) {
|
|
56
|
+
value = item.value;
|
|
57
|
+
if (onChange && value) {
|
|
58
|
+
onChange(value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
{#snippet labelSnippet(item: RadioItem, index: number)}
|
|
64
|
+
<div class="leading-6">
|
|
65
|
+
<div class="ml-4 block text-sm font-medium text-gray-900 flex-grow {labelClassName}">
|
|
66
|
+
{item.label || ''}
|
|
67
|
+
</div>
|
|
68
|
+
{#if item.desc}
|
|
69
|
+
<div class="ml-4 block text-xs text-gray-500 flex-grow {descClassName}">
|
|
70
|
+
{item.desc || ''}
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
73
|
+
</div>
|
|
74
|
+
{/snippet}
|
|
75
|
+
|
|
76
|
+
<fieldset id={fieldsetId}>
|
|
77
|
+
{#if title}
|
|
78
|
+
<legend
|
|
79
|
+
class="text-sm font-semibold leading-6 text-gray-900 {required
|
|
80
|
+
? 'required'
|
|
81
|
+
: ''} {titleClassName}">{title}</legend
|
|
82
|
+
>
|
|
83
|
+
{/if}
|
|
84
|
+
{#if subtitle}
|
|
85
|
+
<p class="mt-1 text-sm leading-6 text-gray-600 {subtitleClassName}">{subtitle}</p>
|
|
86
|
+
{/if}
|
|
87
|
+
|
|
88
|
+
<div
|
|
89
|
+
class="{title || subtitle ? 'mt-6' : ''} {direction == 'vertical'
|
|
90
|
+
? 'space-y-4'
|
|
91
|
+
: 'space-x-6 flex items-center'} {groupContainerClassName} "
|
|
92
|
+
>
|
|
93
|
+
{#each preparedItems || [] as item, index}
|
|
94
|
+
<label
|
|
95
|
+
class="flex items-center cursor-pointer select-none {radioContainerClassName}"
|
|
96
|
+
for="option-{index}"
|
|
97
|
+
>
|
|
98
|
+
{#if position == 'right'}
|
|
99
|
+
{@render labelSnippet(item, index)}
|
|
100
|
+
{/if}
|
|
101
|
+
|
|
102
|
+
<input
|
|
103
|
+
id="option-{index}"
|
|
104
|
+
{name}
|
|
105
|
+
type="radio"
|
|
106
|
+
value={item.value}
|
|
107
|
+
checked={value === item.value}
|
|
108
|
+
class="h-6 w-6 appearance-none rounded-full bg-neutral-200 dark:bg-neutral-700 dark:checked:bg-primary checked:bg-primary checked:hover:bg-primary checked:focus:bg-primary focus:ring-primary focus:shadow-primary outline-primary border-neutral-300 dark:border-neutral-600 {className}"
|
|
109
|
+
onchange={(ev) => handleChange(ev, item)}
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
{#if position == 'left'}
|
|
113
|
+
{@render labelSnippet(item, index)}
|
|
114
|
+
{/if}
|
|
115
|
+
</label>
|
|
116
|
+
{/each}
|
|
117
|
+
</div>
|
|
118
|
+
</fieldset>
|
|
119
|
+
|
|
120
|
+
<style>
|
|
121
|
+
[type='radio']:checked {
|
|
122
|
+
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e");
|
|
123
|
+
background-size: 100% 100%;
|
|
124
|
+
background-position: center;
|
|
125
|
+
background-repeat: no-repeat;
|
|
126
|
+
}
|
|
127
|
+
</style>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { InputFieldSize } from "../../types";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
type RangeFieldPropsType = {
|
|
6
|
+
id?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
size?: InputFieldSize;
|
|
10
|
+
value?: number;
|
|
11
|
+
min?: number;
|
|
12
|
+
max?: number;
|
|
13
|
+
step?: number;
|
|
14
|
+
thumbSize?: string;
|
|
15
|
+
thumbColor?: string;
|
|
16
|
+
oninput?: (ev: any) => void;
|
|
17
|
+
onfocus?: (ev: any) => void;
|
|
18
|
+
onblur?: (ev: any) => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
id,
|
|
23
|
+
value = $bindable(0),
|
|
24
|
+
size = 'md',
|
|
25
|
+
min = 0,
|
|
26
|
+
max = 100,
|
|
27
|
+
name,
|
|
28
|
+
step,
|
|
29
|
+
className,
|
|
30
|
+
thumbSize = '16px',
|
|
31
|
+
oninput,
|
|
32
|
+
onblur,
|
|
33
|
+
onfocus
|
|
34
|
+
}: RangeFieldPropsType = $props();
|
|
35
|
+
|
|
36
|
+
let rangeSizeClassName = $derived.by(() => {
|
|
37
|
+
let className = '';
|
|
38
|
+
switch (size) {
|
|
39
|
+
case 'lg':
|
|
40
|
+
className = 'h-3 ';
|
|
41
|
+
break;
|
|
42
|
+
case 'md':
|
|
43
|
+
className = 'h-2 ';
|
|
44
|
+
break;
|
|
45
|
+
case 'sm':
|
|
46
|
+
className = 'h-1 ';
|
|
47
|
+
break;
|
|
48
|
+
case 'xs':
|
|
49
|
+
className = 'h-2-px ';
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
return className;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
let inputRef: HTMLInputElement | null = $state(null);
|
|
56
|
+
|
|
57
|
+
export function getElement() {
|
|
58
|
+
return inputRef;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function focus() {
|
|
62
|
+
return inputRef && inputRef.focus();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function select() {
|
|
66
|
+
return inputRef && inputRef.select();
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<input
|
|
71
|
+
bind:this={inputRef}
|
|
72
|
+
bind:value
|
|
73
|
+
{id}
|
|
74
|
+
{name}
|
|
75
|
+
type="range"
|
|
76
|
+
class="range-slider range-lg w-full cursor-pointer appearance-none rounded-lg bg-gray-200 outline-none focus:outline-none dark:bg-gray-700 {rangeSizeClassName} {className}"
|
|
77
|
+
{min}
|
|
78
|
+
{max}
|
|
79
|
+
{step}
|
|
80
|
+
style="--thumbSize: {thumbSize};"
|
|
81
|
+
{oninput}
|
|
82
|
+
{onfocus}
|
|
83
|
+
{onblur}
|
|
84
|
+
/>
|
|
85
|
+
|
|
86
|
+
<style>
|
|
87
|
+
.h-2-px {
|
|
88
|
+
height: 2px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.range-slider {
|
|
92
|
+
appearance: none;
|
|
93
|
+
-webkit-appearance: none;
|
|
94
|
+
}
|
|
95
|
+
.range-slider::-webkit-slider-thumb {
|
|
96
|
+
-webkit-appearance: none;
|
|
97
|
+
width: var(--thumbSize);
|
|
98
|
+
height: var(--thumbSize);
|
|
99
|
+
background-color: var(--color-primary-600);
|
|
100
|
+
border-radius: 50%;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Thumb styling for Firefox */
|
|
104
|
+
.range-slider::-moz-range-thumb {
|
|
105
|
+
-moz-appearance: none;
|
|
106
|
+
width: var(--thumbSize);
|
|
107
|
+
height: var(--thumbSize);
|
|
108
|
+
background-color: var(--color-primary-600);
|
|
109
|
+
border-radius: 50%;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* Thumb styling for Edge */
|
|
113
|
+
.range-slider::-ms-thumb {
|
|
114
|
+
-ms-appearance: none;
|
|
115
|
+
width: var(--thumbSize);
|
|
116
|
+
height: var(--thumbSize);
|
|
117
|
+
background-color: var(--color-primary-600);
|
|
118
|
+
border-radius: 50%;
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { InputFieldSize } from "../../types";
|
|
2
|
+
type RangeFieldPropsType = {
|
|
3
|
+
id?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
size?: InputFieldSize;
|
|
7
|
+
value?: number;
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
step?: number;
|
|
11
|
+
thumbSize?: string;
|
|
12
|
+
thumbColor?: string;
|
|
13
|
+
oninput?: (ev: any) => void;
|
|
14
|
+
onfocus?: (ev: any) => void;
|
|
15
|
+
onblur?: (ev: any) => void;
|
|
16
|
+
};
|
|
17
|
+
declare const RangeField: import("svelte").Component<RangeFieldPropsType, {
|
|
18
|
+
getElement: () => HTMLInputElement;
|
|
19
|
+
focus: () => void;
|
|
20
|
+
select: () => void;
|
|
21
|
+
}, "value">;
|
|
22
|
+
type RangeField = ReturnType<typeof RangeField>;
|
|
23
|
+
export default RangeField;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import Icon from '../../../icon/components/icon/icon.svelte';
|
|
4
|
+
import { mdiMagnify } from '../../../icon/index.js';
|
|
5
|
+
import type { InputFieldProps } from '../../types';
|
|
6
|
+
import InputField from '../input-field/input-field.svelte';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
className,
|
|
10
|
+
placeholder,
|
|
11
|
+
iconClassName,
|
|
12
|
+
value = $bindable(''),
|
|
13
|
+
onSearch,
|
|
14
|
+
...props
|
|
15
|
+
}: InputFieldProps & {
|
|
16
|
+
iconClassName?: string;
|
|
17
|
+
onSearch?: (value: string) => void;
|
|
18
|
+
} = $props();
|
|
19
|
+
|
|
20
|
+
const debouncedSearch = debounce(search, 300);
|
|
21
|
+
let lastQuery: string;
|
|
22
|
+
|
|
23
|
+
let inputFieldRef: any | null = $state(null);
|
|
24
|
+
|
|
25
|
+
export function focus() {
|
|
26
|
+
inputFieldRef?.focus();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getElement() {
|
|
30
|
+
return inputFieldRef;
|
|
31
|
+
}
|
|
32
|
+
export function select() {
|
|
33
|
+
inputFieldRef && inputFieldRef.select();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function handleInput(ev: any) {
|
|
37
|
+
// console.log(ev);
|
|
38
|
+
let input: HTMLInputElement = ev?.target;
|
|
39
|
+
if (input) {
|
|
40
|
+
let searchText = (input.value || '').toLowerCase().trim();
|
|
41
|
+
debouncedSearch(searchText);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function search(query: string) {
|
|
46
|
+
if (lastQuery != query) {
|
|
47
|
+
onSearch && onSearch(query);
|
|
48
|
+
lastQuery = query;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function debounce<T extends (...args: any[]) => void>(
|
|
53
|
+
func: T,
|
|
54
|
+
wait: number
|
|
55
|
+
): (...args: Parameters<T>) => void {
|
|
56
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
57
|
+
|
|
58
|
+
return function (...args: Parameters<T>) {
|
|
59
|
+
clearTimeout(timeout);
|
|
60
|
+
timeout = setTimeout(() => {
|
|
61
|
+
func(...args);
|
|
62
|
+
}, wait);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
{#snippet searchIcon()}
|
|
68
|
+
<Icon path={mdiMagnify} className="mx-3 text-gray-400 {iconClassName}"></Icon>
|
|
69
|
+
{/snippet}
|
|
70
|
+
<InputField
|
|
71
|
+
bind:value
|
|
72
|
+
bind:this={inputFieldRef}
|
|
73
|
+
{...props}
|
|
74
|
+
type="search"
|
|
75
|
+
maxlength={props?.maxlength || 200}
|
|
76
|
+
leftSnippet={searchIcon}
|
|
77
|
+
className="pl-12 {className}"
|
|
78
|
+
{placeholder}
|
|
79
|
+
onInput={handleInput}
|
|
80
|
+
/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InputFieldProps } from '../../types';
|
|
2
|
+
type $$ComponentProps = InputFieldProps & {
|
|
3
|
+
iconClassName?: string;
|
|
4
|
+
onSearch?: (value: string) => void;
|
|
5
|
+
};
|
|
6
|
+
declare const SearchField: import("svelte").Component<$$ComponentProps, {
|
|
7
|
+
focus: () => void;
|
|
8
|
+
getElement: () => any;
|
|
9
|
+
select: () => void;
|
|
10
|
+
}, "value">;
|
|
11
|
+
type SearchField = ReturnType<typeof SearchField>;
|
|
12
|
+
export default SearchField;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { InputFieldProps } from '../../types';
|
|
3
|
+
import InputField from '../input-field/input-field.svelte';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
maxlength,
|
|
7
|
+
value = $bindable(''),
|
|
8
|
+
...props
|
|
9
|
+
}: InputFieldProps & { value?: string | null | undefined } = $props();
|
|
10
|
+
let inputFieldRef: any | null = $state(null);
|
|
11
|
+
|
|
12
|
+
export function focus() {
|
|
13
|
+
inputFieldRef?.focus();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getElement() {
|
|
17
|
+
return inputFieldRef;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function select() {
|
|
21
|
+
return inputFieldRef && inputFieldRef.select();
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<InputField
|
|
26
|
+
{...props}
|
|
27
|
+
bind:value={value as string | null | undefined}
|
|
28
|
+
bind:this={inputFieldRef}
|
|
29
|
+
type="text"
|
|
30
|
+
maxlength={maxlength || 200}
|
|
31
|
+
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InputFieldProps } from '../../types';
|
|
2
|
+
type $$ComponentProps = InputFieldProps & {
|
|
3
|
+
value?: string | null | undefined;
|
|
4
|
+
};
|
|
5
|
+
declare const TextField: import("svelte").Component<$$ComponentProps, {
|
|
6
|
+
focus: () => void;
|
|
7
|
+
getElement: () => any;
|
|
8
|
+
select: () => any;
|
|
9
|
+
}, "value">;
|
|
10
|
+
type TextField = ReturnType<typeof TextField>;
|
|
11
|
+
export default TextField;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
let inputFieldRef: any | null = $state(null);
|
|
7
|
+
|
|
8
|
+
export function focus() {
|
|
9
|
+
inputFieldRef?.focus();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getElement() {
|
|
13
|
+
return inputFieldRef;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function select() {
|
|
17
|
+
return inputFieldRef && inputFieldRef.select();
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<InputField
|
|
22
|
+
bind:this={inputFieldRef}
|
|
23
|
+
{...props}
|
|
24
|
+
type="textarea"
|
|
25
|
+
maxlength={props?.maxlength || 300}
|
|
26
|
+
bind:value
|
|
27
|
+
/>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InputFieldProps } from '../../types';
|
|
2
|
+
declare const TextareaField: import("svelte").Component<InputFieldProps, {
|
|
3
|
+
focus: () => void;
|
|
4
|
+
getElement: () => any;
|
|
5
|
+
select: () => any;
|
|
6
|
+
}, "value">;
|
|
7
|
+
type TextareaField = ReturnType<typeof TextareaField>;
|
|
8
|
+
export default TextareaField;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
let inputFieldRef: any | null = $state(null);
|
|
7
|
+
|
|
8
|
+
export function focus() {
|
|
9
|
+
inputFieldRef?.focus();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getElement() {
|
|
13
|
+
return inputFieldRef;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function select() {
|
|
17
|
+
return inputFieldRef && inputFieldRef.select();
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<InputField bind:this={inputFieldRef} {...props} type="time" bind:value />
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InputFieldProps } from '../../types';
|
|
2
|
+
declare const TimeField: import("svelte").Component<InputFieldProps, {
|
|
3
|
+
focus: () => void;
|
|
4
|
+
getElement: () => any;
|
|
5
|
+
select: () => any;
|
|
6
|
+
}, "value">;
|
|
7
|
+
type TimeField = ReturnType<typeof TimeField>;
|
|
8
|
+
export default TimeField;
|