@cloudparker/moldex.js 0.0.124 → 4.1.1

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.
Files changed (69) hide show
  1. package/dist/types.d.ts +6 -0
  2. package/dist/types.js +7 -0
  3. package/dist/views/core/button/components/button/button.svelte +135 -83
  4. package/dist/views/core/button/components/button-back/button-back.svelte +28 -15
  5. package/dist/views/core/button/components/button-close/button-close.svelte +4 -2
  6. package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte +29 -15
  7. package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte +96 -72
  8. package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte.d.ts +1 -1
  9. package/dist/views/core/button/components/button-list-item/button-list-item.svelte +98 -52
  10. package/dist/views/core/button/components/button-menu/button-menu.svelte +79 -43
  11. package/dist/views/core/button/components/button-ok/button-ok.svelte +4 -2
  12. package/dist/views/core/button/components/button-search/button-search.svelte +45 -21
  13. package/dist/views/core/button/components/switch/switch.svelte +50 -37
  14. package/dist/views/core/common/components/content-area/content-area.svelte +40 -27
  15. package/dist/views/core/common/components/loading/loading.svelte +9 -2
  16. package/dist/views/core/common/components/virtual-scrolling/virtual-scrolling-list.svelte +37 -20
  17. package/dist/views/core/dialog/components/cropper-dialog/cropper-dialog.svelte +52 -36
  18. package/dist/views/core/dialog/components/dialog/dialog.svelte +298 -177
  19. package/dist/views/core/dialog/components/loading-dialog/loading-dialog.svelte +30 -18
  20. package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte +17 -7
  21. package/dist/views/core/dialog/components/number-field-dialog/number-field-dialog.svelte +41 -26
  22. package/dist/views/core/dialog/components/picker-dialog/picker-dialog.svelte +150 -105
  23. package/dist/views/core/dialog/components/text-field-dialog/text-field-dialog.svelte +40 -25
  24. package/dist/views/core/dialog/components/textarea-field-dialog/textarea-field-dialog.svelte +40 -25
  25. package/dist/views/core/drawer/components/drawer/drawer.svelte +58 -36
  26. package/dist/views/core/icon/components/icon/icon.svelte +24 -12
  27. package/dist/views/core/icon/components/icon-circle/icon-circle.svelte +10 -2
  28. package/dist/views/core/input/components/checkbox-field/checkbox-field.svelte +44 -25
  29. package/dist/views/core/input/components/color-field/color-field.svelte +81 -69
  30. package/dist/views/core/input/components/combobox-field/combobox-field.svelte +359 -269
  31. package/dist/views/core/input/components/date-field/date-field.svelte +39 -30
  32. package/dist/views/core/input/components/datetime-field/datetime-field.svelte +18 -12
  33. package/dist/views/core/input/components/email-field/email-field.svelte +17 -12
  34. package/dist/views/core/input/components/file-field/file-field.svelte +78 -64
  35. package/dist/views/core/input/components/input-field/input-field.svelte +267 -164
  36. package/dist/views/core/input/components/label/label.svelte +24 -10
  37. package/dist/views/core/input/components/number-field/number-field.svelte +18 -12
  38. package/dist/views/core/input/components/password-field/password-field.svelte +70 -57
  39. package/dist/views/core/input/components/phone-field/phone-field.svelte +155 -104
  40. package/dist/views/core/input/components/radio-field/radio-field.svelte +83 -52
  41. package/dist/views/core/input/components/range-field/range-field.svelte +67 -44
  42. package/dist/views/core/input/components/search-field/search-field.svelte +62 -45
  43. package/dist/views/core/input/components/text-field/text-field.svelte +21 -16
  44. package/dist/views/core/input/components/textarea-field/textarea-field.svelte +17 -12
  45. package/dist/views/core/input/components/time-field/time-field.svelte +17 -12
  46. package/dist/views/core/navbar/components/navbar/navbar.svelte +76 -38
  47. package/dist/views/core/no-data/components/no-data/no-data.svelte +36 -19
  48. package/dist/views/core/pagination/components/pagination/pagination.svelte +90 -66
  49. package/dist/views/core/progressbar/components/progressbar/progressbar.svelte +36 -22
  50. package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte +5 -1
  51. package/dist/views/core/screen-detector/components/screen-detector.svelte +13 -9
  52. package/dist/views/core/sidebar/components/sidebar.svelte +36 -23
  53. package/dist/views/core/spinner/components/spinner/spinner.svelte +6 -1
  54. package/dist/views/core/text/components/text-await/text-await.svelte +9 -1
  55. package/dist/views/core/text/components/text-copy/text-copy.svelte +27 -16
  56. package/dist/views/core/text/components/text-currency/text-currency.svelte +13 -2
  57. package/dist/views/core/text/components/text-date/text-date.svelte +32 -20
  58. package/dist/views/core/text/components/text-email/text-email.svelte +12 -3
  59. package/dist/views/core/text/components/text-html/text-html.svelte +2 -1
  60. package/dist/views/core/text/components/text-phone/text-phone.svelte +12 -3
  61. package/dist/views/core/toast/components/toast/toast.svelte +43 -20
  62. package/dist/views/extra/fields/country-combobox-field.svelte +23 -15
  63. package/dist/views/extra/loaders/country-loader.svelte +33 -15
  64. package/dist/views/extra/texts/text-country-state.svelte +36 -28
  65. package/dist/views/extra/texts/text-country.svelte +16 -8
  66. package/package.json +3 -12
  67. package/readme.md +57 -2
  68. package/dist/tailwind.css +0 -1
  69. package/dist/theme.css +0 -27
@@ -1,168 +1,271 @@
1
- <script module lang="ts"></script>
1
+ <script module lang="ts">
2
+ export type InputFieldSize = 'lg' | 'md' | 'sm' | 'xs';
3
+ export type InputFieldAppearance =
4
+ | 'normal'
5
+ | 'box'
6
+ | 'fill'
7
+ | 'underline'
8
+ | 'fill-underline'
9
+ | 'none';
2
10
 
3
- <script lang="ts">import Label from "../label/label.svelte";
4
- let {
5
- appearance = "normal",
6
- ariaControls,
7
- ariaExpanded,
8
- autofocus = false,
9
- className = "",
10
- cols,
11
- containerClassName = "",
12
- contentSnippet,
13
- contentSnippetClassName,
14
- disabled = false,
15
- floatingLabel = false,
16
- hasRequiredSymbol = true,
17
- id = "",
18
- label = "",
19
- labelClassName = "",
20
- leftSnippet,
21
- leftSnippetContainerClassName = "",
22
- max,
23
- maxlength,
24
- min,
25
- minlength,
26
- multiple = false,
27
- name = "",
28
- title,
29
- onBlur,
30
- onChange,
31
- onClick,
32
- onDblClick,
33
- onDrag,
34
- onDragOver,
35
- onDrop,
36
- onFocus,
37
- onInput,
38
- onKeyDown,
39
- onKeyPress,
40
- onKeyUp,
41
- onMouseDown,
42
- onMouseUp,
43
- pattern,
44
- placeholder = "",
45
- readonly = false,
46
- required = false,
47
- requiredSymbol = "*",
48
- requiredSymbolColor = "red",
49
- rightSnippet,
50
- rightSnippetContainerClassName = "",
51
- role,
52
- rows = 5,
53
- size = "md",
54
- step,
55
- type = "text",
56
- value = $bindable()
57
- } = $props();
58
- let inputRef = $state(null);
59
- let sizeClassName = $state("");
60
- let appearanceClassName = $state("");
61
- let floatingLabelClassName = $state("");
62
- let floatingLabelPaddingClassName = $state("");
63
- let floatingLabelTextClassName = $state("");
64
- export function focus() {
65
- inputRef && inputRef.focus();
66
- }
67
- export function getElement() {
68
- return inputRef;
69
- }
70
- export function select() {
71
- return inputRef && inputRef.select();
72
- }
73
- export function getBoundingClientRect() {
74
- if (inputRef) {
75
- return inputRef.getBoundingClientRect();
76
- }
77
- }
78
- $effect(() => {
79
- if (floatingLabel || leftSnippet != null || rightSnippet != null) {
80
- containerClassName = (containerClassName || "") + " relative";
81
- }
82
- });
83
- $effect(() => {
84
- if (floatingLabel) {
85
- if (size) {
86
- let flpcn = "";
87
- switch (size) {
88
- case "lg":
89
- flpcn = ` px-1 peer-focus:px-1 peer-placeholder-shown:px-4 `;
90
- floatingLabelTextClassName = "text-base";
91
- break;
92
- case "md":
93
- flpcn = " px-1 peer-focus:px-1 peer-placeholder-shown:px-2.5 ";
94
- floatingLabelTextClassName = "text-sm";
95
- break;
96
- case "sm":
97
- flpcn = " px-1 peer-focus:px-1 peer-placeholder-shown:px-2";
98
- floatingLabelTextClassName = "text-xs";
99
- break;
100
- case "xs":
101
- flpcn = " px-0 peer-focus:px-0 peer-placeholder-shown:px-1 ";
102
- floatingLabelTextClassName = "text-xs";
103
- break;
104
- }
105
- floatingLabelPaddingClassName = flpcn;
106
- }
107
- floatingLabelClassName = `absolute duration-300 transform top-0 rounded -translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-0 peer-placeholder-shown:start-0 peer-focus:start-1 bg-white peer-focus:bg-white dark:bg-base-700 peer-focus:bg-base-800 peer-placeholder-shown:bg-transparent start-1 ${floatingLabelPaddingClassName} ${floatingLabelTextClassName}`;
108
- }
109
- });
110
- $effect(() => {
111
- if (appearance) {
112
- switch (appearance) {
113
- case "normal":
114
- appearanceClassName = "border rounded-lg bg-base-100 dark:bg-base-700 border-base-300 dark:border-base-500 text-base-950 dark:text-base-50 focus:ring-primary-500 focus:border-primary-500 dark:focus:ring-primary-500 dark:focus:border-primary-500 focus:bg-base-50 dark:focus:bg-base-800 ";
115
- break;
116
- case "box":
117
- appearanceClassName = "border bg-base-100 dark:bg-base-700 border-base-300 dark:border-base-500 text-base-950 dark:text-base-50 focus:ring-primary-500 focus:border-primary-500 dark:focus:ring-primary-500 dark:focus:border-primary-500 focus:bg-base-50 dark:focus:bg-base-800 ";
118
- break;
119
- case "fill":
120
- appearanceClassName = " border-0 appearance-none focus:ring-0 bg-base-100 dark:bg-base-700 text-base-950 dark:text-base-50 focus:bg-base-50 dark:focus:bg-base-800 ";
121
- break;
122
- case "underline":
123
- appearanceClassName = "bg-transparent border-0 border-b-2 appearance-none focus:ring-0 text-base-950 dark:text-base-50 border-base-300 dark:border-base-700 focus:border-primary-500 dark:focus:border-primary-500";
124
- break;
125
- case "fill-underline":
126
- appearanceClassName = "border-0 border-b-2 appearance-none ring-0 text-base-950 dark:text-base-50 bg-base-100 dark:bg-base-700 border-base-300 dark:border-base-500 focus:border-primary-500 dark:focus:border-primary-500 ";
127
- break;
128
- case "none":
129
- appearanceClassName = "border-0 focus:ring-0 appearance-none text-base-950 dark:text-base-50 bg-transparent dark:bg-transparent focus:bg-base-100 dark:focus:bg-base-800 hover:bg-base-100 dark:hover:bg-base-800";
130
- break;
131
- }
132
- }
133
- });
134
- $effect(() => {
135
- if (size) {
136
- switch (size) {
137
- case "lg":
138
- sizeClassName = "p-4 text-base";
139
- break;
140
- case "md":
141
- sizeClassName = "p-2.5 text-sm";
142
- break;
143
- case "sm":
144
- sizeClassName = "p-2 text-xs";
145
- break;
146
- case "xs":
147
- sizeClassName = "p-1 text-xs";
148
- break;
149
- }
150
- }
151
- });
152
- $effect(() => {
153
- if (name && !id) {
154
- id = name;
155
- } else if (id && !name) {
156
- name = id;
157
- }
158
- });
159
- $effect(() => {
160
- setTimeout(() => {
161
- if (inputRef && autofocus) {
162
- inputRef.focus();
163
- }
164
- }, 10);
165
- });
11
+ export type InputValue =
12
+ | any
13
+ | string
14
+ | string[]
15
+ | number
16
+ | number[]
17
+ | Date
18
+ | Date[]
19
+ | File
20
+ | File[]
21
+ | null
22
+ | undefined;
23
+
24
+ export type InputFieldProps = {
25
+ appearance?: InputFieldAppearance;
26
+ ariaControls?: string;
27
+ ariaExpanded?: boolean;
28
+ autofocus?: boolean;
29
+ className?: string;
30
+ cols?: number;
31
+ containerClassName?: string;
32
+ contentSnippet?: Snippet;
33
+ contentSnippetClassName?: string;
34
+ disabled?: boolean;
35
+ floatingLabel?: boolean;
36
+ hasRequiredSymbol?: boolean;
37
+ iconClassName?: string;
38
+ iconPath?: string;
39
+ id?: string;
40
+ label?: string;
41
+ labelClassName?: string;
42
+ leftSnippet?: Snippet;
43
+ leftSnippetContainerClassName?: string;
44
+ max?: number | string;
45
+ maxlength?: number;
46
+ min?: number | string;
47
+ minlength?: number;
48
+ multiple?: boolean;
49
+ name?: string;
50
+ title?: string;
51
+ onBlur?: (ev: any) => void;
52
+ onChange?: (ev: any) => void;
53
+ onClick?: (ev: MouseEvent) => void;
54
+ onDblClick?: (ev: MouseEvent) => void;
55
+ onDrag?: (ev: DragEvent) => void;
56
+ onDragOver?: (ev: DragEvent) => void;
57
+ onDrop?: (ev: DragEvent) => void;
58
+ onFocus?: (ev: any) => void;
59
+ onInput?: (ev: any) => void;
60
+ onKeyDown?: (ev: KeyboardEvent) => void;
61
+ onKeyPress?: (ev: KeyboardEvent) => void;
62
+ onKeyUp?: (ev: KeyboardEvent) => void;
63
+ onMouseDown?: (ev: MouseEvent) => void;
64
+ onMouseUp?: (ev: MouseEvent) => void;
65
+ pattern?: string;
66
+ placeholder?: string;
67
+ readonly?: boolean;
68
+ required?: boolean;
69
+ requiredSymbol?: string;
70
+ requiredSymbolColor?: string;
71
+ rightSnippet?: Snippet;
72
+ rightSnippetContainerClassName?: string;
73
+ role?: AriaRole;
74
+ rows?: number;
75
+ size?: InputFieldSize;
76
+ step?: number;
77
+ type?: HTMLInputTypeAttribute | 'textarea';
78
+ value?: InputValue;
79
+ };
80
+ </script>
81
+
82
+ <script lang="ts">
83
+ import type { Snippet } from 'svelte';
84
+ import type { HTMLInputTypeAttribute, AriaRole } from 'svelte/elements';
85
+ import Label from '../label/label.svelte';
86
+
87
+ let {
88
+ appearance = 'normal',
89
+ ariaControls,
90
+ ariaExpanded,
91
+ autofocus = false,
92
+ className = '',
93
+ cols,
94
+ containerClassName = '',
95
+ contentSnippet,
96
+ contentSnippetClassName,
97
+ disabled = false,
98
+ floatingLabel = false,
99
+ hasRequiredSymbol = true,
100
+ id = '',
101
+ label = '',
102
+ labelClassName = '',
103
+ leftSnippet,
104
+ leftSnippetContainerClassName = '',
105
+ max,
106
+ maxlength,
107
+ min,
108
+ minlength,
109
+ multiple = false,
110
+ name = '',
111
+ title,
112
+ onBlur,
113
+ onChange,
114
+ onClick,
115
+ onDblClick,
116
+ onDrag,
117
+ onDragOver,
118
+ onDrop,
119
+ onFocus,
120
+ onInput,
121
+ onKeyDown,
122
+ onKeyPress,
123
+ onKeyUp,
124
+ onMouseDown,
125
+ onMouseUp,
126
+ pattern,
127
+ placeholder = '',
128
+ readonly = false,
129
+ required = false,
130
+ requiredSymbol = '*',
131
+ requiredSymbolColor = 'red',
132
+ rightSnippet,
133
+ rightSnippetContainerClassName = '',
134
+ role,
135
+ rows = 5,
136
+ size = 'md',
137
+ step,
138
+ type = 'text',
139
+ value = $bindable()
140
+ }: InputFieldProps = $props();
141
+
142
+ let inputRef: HTMLInputElement | HTMLTextAreaElement | null = $state(null);
143
+
144
+ let sizeClassName = $state('');
145
+ let appearanceClassName = $state('');
146
+ let floatingLabelClassName = $state('');
147
+ let floatingLabelPaddingClassName = $state('');
148
+ let floatingLabelTextClassName = $state('');
149
+
150
+ export function focus() {
151
+ inputRef && inputRef.focus();
152
+ }
153
+
154
+ export function getElement() {
155
+ return inputRef;
156
+ }
157
+
158
+ export function select() {
159
+ return inputRef && (inputRef as HTMLInputElement).select();
160
+ }
161
+
162
+ export function getBoundingClientRect() {
163
+ if (inputRef) {
164
+ return inputRef.getBoundingClientRect();
165
+ }
166
+ }
167
+
168
+ $effect(() => {
169
+ if (floatingLabel || leftSnippet != null || rightSnippet != null) {
170
+ containerClassName = (containerClassName || '') + ' relative';
171
+ }
172
+ });
173
+
174
+ $effect(() => {
175
+ if (floatingLabel) {
176
+ if (size) {
177
+ let flpcn = '';
178
+ switch (size) {
179
+ case 'lg':
180
+ flpcn = ` px-1 peer-focus:px-1 peer-placeholder-shown:px-4 `;
181
+ floatingLabelTextClassName = 'text-base';
182
+ break;
183
+ case 'md':
184
+ flpcn = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2.5 ';
185
+ floatingLabelTextClassName = 'text-sm';
186
+
187
+ break;
188
+ case 'sm':
189
+ flpcn = ' px-1 peer-focus:px-1 peer-placeholder-shown:px-2';
190
+ floatingLabelTextClassName = 'text-xs';
191
+ break;
192
+ case 'xs':
193
+ flpcn = ' px-0 peer-focus:px-0 peer-placeholder-shown:px-1 ';
194
+ floatingLabelTextClassName = 'text-xs';
195
+ break;
196
+ }
197
+ floatingLabelPaddingClassName = flpcn;
198
+ }
199
+
200
+ floatingLabelClassName = `absolute duration-300 transform top-0 rounded -translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-0 peer-placeholder-shown:start-0 peer-focus:start-1 bg-white peer-focus:bg-white dark:bg-base-700 peer-focus:bg-base-800 peer-placeholder-shown:bg-transparent start-1 ${floatingLabelPaddingClassName} ${floatingLabelTextClassName}`;
201
+ }
202
+ });
203
+
204
+ $effect(() => {
205
+ if (appearance) {
206
+ switch (appearance) {
207
+ case 'normal':
208
+ appearanceClassName =
209
+ 'border rounded-lg bg-base-100 dark:bg-base-700 border-base-300 dark:border-base-500 text-base-950 dark:text-base-50 focus:ring-primary-500 focus:border-primary-500 dark:focus:ring-primary-500 dark:focus:border-primary-500 focus:bg-base-50 dark:focus:bg-base-800 ';
210
+ break;
211
+ case 'box':
212
+ appearanceClassName =
213
+ 'border bg-base-100 dark:bg-base-700 border-base-300 dark:border-base-500 text-base-950 dark:text-base-50 focus:ring-primary-500 focus:border-primary-500 dark:focus:ring-primary-500 dark:focus:border-primary-500 focus:bg-base-50 dark:focus:bg-base-800 ';
214
+ break;
215
+ case 'fill':
216
+ appearanceClassName =
217
+ ' border-0 appearance-none focus:ring-0 bg-base-100 dark:bg-base-700 text-base-950 dark:text-base-50 focus:bg-base-50 dark:focus:bg-base-800 ';
218
+ break;
219
+ case 'underline':
220
+ appearanceClassName =
221
+ 'bg-transparent border-0 border-b-2 appearance-none focus:ring-0 text-base-950 dark:text-base-50 border-base-300 dark:border-base-700 focus:border-primary-500 dark:focus:border-primary-500';
222
+ break;
223
+ case 'fill-underline':
224
+ appearanceClassName =
225
+ 'border-0 border-b-2 appearance-none ring-0 text-base-950 dark:text-base-50 bg-base-100 dark:bg-base-700 border-base-300 dark:border-base-500 focus:border-primary-500 dark:focus:border-primary-500 ';
226
+ break;
227
+ case 'none':
228
+ appearanceClassName =
229
+ 'border-0 focus:ring-0 appearance-none text-base-950 dark:text-base-50 bg-transparent dark:bg-transparent focus:bg-base-100 dark:focus:bg-base-800 hover:bg-base-100 dark:hover:bg-base-800';
230
+ break;
231
+ }
232
+ }
233
+ });
234
+
235
+ $effect(() => {
236
+ if (size) {
237
+ switch (size) {
238
+ case 'lg':
239
+ sizeClassName = 'p-4 text-base';
240
+ break;
241
+ case 'md':
242
+ sizeClassName = 'p-2.5 text-sm';
243
+ break;
244
+ case 'sm':
245
+ sizeClassName = 'p-2 text-xs';
246
+ break;
247
+ case 'xs':
248
+ sizeClassName = 'p-1 text-xs';
249
+ break;
250
+ }
251
+ }
252
+ });
253
+
254
+ $effect(() => {
255
+ if (name && !id) {
256
+ id = name;
257
+ } else if (id && !name) {
258
+ name = id;
259
+ }
260
+ });
261
+
262
+ $effect(() => {
263
+ setTimeout(() => {
264
+ if (inputRef && autofocus) {
265
+ inputRef.focus();
266
+ }
267
+ }, 10);
268
+ });
166
269
  </script>
167
270
 
168
271
  {#snippet labelSnippet()}
@@ -1,13 +1,27 @@
1
- <script lang="ts">let {
2
- forName,
3
- label = "",
4
- className = "",
5
- required = false,
6
- requiredSymbolColor = "red",
7
- requiredSymbol = "*",
8
- hasRequiredSymbol = true,
9
- children
10
- } = $props();
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();
11
25
  </script>
12
26
 
13
27
  <label
@@ -1,15 +1,21 @@
1
- <script lang="ts">import InputField, {} from "../input-field/input-field.svelte";
2
- let { value = $bindable(), ...props } = $props();
3
- let inputFieldRef = $state(null);
4
- export function focus() {
5
- inputFieldRef?.focus();
6
- }
7
- export function getElement() {
8
- return inputFieldRef;
9
- }
10
- export function select() {
11
- inputFieldRef && inputFieldRef.select();
12
- }
1
+ <script lang="ts">
2
+ import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
3
+
4
+ let { value = $bindable(), ...props }: InputFieldProps = $props();
5
+
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
+ inputFieldRef && inputFieldRef.select();
18
+ }
13
19
  </script>
14
20
 
15
21
  <InputField bind:this={inputFieldRef} {...props} type="number" bind:value />
@@ -1,60 +1,73 @@
1
- <script lang="ts">import { ripple } from "../../../../../actions";
2
- import { mdiEyeOffOutline, mdiEyeOutline } from "../../../icon";
3
- import Icon from "../../../icon/components/icon/icon.svelte";
4
- import InputField, {} from "../input-field/input-field.svelte";
5
- let {
6
- type = "password",
7
- size,
8
- appearance,
9
- buttonClassName,
10
- iconClassName,
11
- name,
12
- id,
13
- value = $bindable(),
14
- ...props
15
- } = $props();
16
- let btnRoundedClassName = $state("");
17
- let btnIconSizeClassName = $state("");
18
- let inputFieldRef = $state(null);
19
- export function focus() {
20
- inputFieldRef?.focus();
21
- }
22
- export function getElement() {
23
- return inputFieldRef;
24
- }
25
- export function select() {
26
- inputFieldRef && inputFieldRef.select();
27
- }
28
- function handleTogglePassword() {
29
- if (type == "password") {
30
- type = "text";
31
- } else {
32
- type = "password";
33
- }
34
- }
35
- $effect(() => {
36
- if (size) {
37
- switch (size) {
38
- case "lg":
39
- btnIconSizeClassName = "!h-7 !w-7";
40
- break;
41
- case "md":
42
- btnIconSizeClassName = "!h-6 !w-6";
43
- break;
44
- case "sm":
45
- btnIconSizeClassName = "!h-5 !w-5";
46
- break;
47
- case "xs":
48
- btnIconSizeClassName = "!h-4 !w-4";
49
- break;
50
- }
51
- }
52
- });
53
- $effect(() => {
54
- if (!appearance || appearance == "normal") {
55
- btnRoundedClassName = "rounded-tr-lg rounded-br-lg";
56
- }
57
- });
1
+ <script lang="ts">
2
+ import { ripple } from '../../../../../actions';
3
+ import { mdiEyeOffOutline, mdiEyeOutline } from '../../../icon';
4
+ import Icon from '../../../icon/components/icon/icon.svelte';
5
+ import InputField, { type InputFieldProps } from '../input-field/input-field.svelte';
6
+
7
+ let {
8
+ type = 'password',
9
+ size,
10
+ appearance,
11
+ buttonClassName,
12
+ iconClassName,
13
+ name,
14
+ id,
15
+ value = $bindable(),
16
+ ...props
17
+ }: InputFieldProps & {
18
+ buttonClassName?: string;
19
+ iconClassName?: string;
20
+ } = $props();
21
+
22
+ let btnRoundedClassName = $state('');
23
+ let btnIconSizeClassName = $state('');
24
+
25
+ let inputFieldRef: any | null = $state(null);
26
+
27
+ export function focus() {
28
+ inputFieldRef?.focus();
29
+ }
30
+
31
+ export function getElement() {
32
+ return inputFieldRef;
33
+ }
34
+
35
+ export function select() {
36
+ inputFieldRef && inputFieldRef.select();
37
+ }
38
+
39
+ function handleTogglePassword() {
40
+ if (type == 'password') {
41
+ type = 'text';
42
+ } else {
43
+ type = 'password';
44
+ }
45
+ }
46
+
47
+ $effect(() => {
48
+ if (size) {
49
+ switch (size) {
50
+ case 'lg':
51
+ btnIconSizeClassName = '!h-7 !w-7';
52
+ break;
53
+ case 'md':
54
+ btnIconSizeClassName = '!h-6 !w-6';
55
+ break;
56
+ case 'sm':
57
+ btnIconSizeClassName = '!h-5 !w-5';
58
+ break;
59
+ case 'xs':
60
+ btnIconSizeClassName = '!h-4 !w-4';
61
+ break;
62
+ }
63
+ }
64
+ });
65
+
66
+ $effect(() => {
67
+ if (!appearance || appearance == 'normal') {
68
+ btnRoundedClassName = 'rounded-tr-lg rounded-br-lg';
69
+ }
70
+ });
58
71
  </script>
59
72
 
60
73
  {#snippet showPasswordButton()}