@starasia/input 1.0.4 → 2.0.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.
package/dist/input.es.js CHANGED
@@ -1,367 +1,593 @@
1
- import { jsx as c, jsxs as N } from "react/jsx-runtime";
2
- import B, { forwardRef as W, useState as w, useRef as A, useEffect as x } from "react";
3
- const G = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
4
-
5
- * {
6
- margin: 0;
7
- padding: 0;
8
- }
1
+ import { jsx as a, jsxs as o, Fragment as Bn } from "react/jsx-runtime";
2
+ import Ln, { forwardRef as hn, useState as I, useRef as B, useEffect as T, useImperativeHandle as Rn, useLayoutEffect as un } from "react";
3
+ const Sn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
9
4
 
10
5
  :root {
11
- /* spacing */
12
- --starasia-ui-input-spacing-xs: var(--starasia-ui-spacing-xs, 4px);
13
- --starasia-ui-input-spacing-sm: var(--starasia-ui-spacing-sm, 8px);
14
- --starasia-ui-input-spacing-ms: var(--starasia-ui-spacing-12, 12px);
15
- --starasia-ui-input-spacing-md: var(--starasia-ui-spacing-lg, 16px);
16
- --starasia-ui-input-spacing-lg: var(--starasia-ui-spacing-xl, 24px);
17
-
18
- /* color */
19
- /* brand */
20
- --starasia-ui-input-color-primary-blue: var(--starasia-ui-brand-primary-default, rgba(74, 106, 148, 1));
21
- --starasia-ui-input-color-secondary-blue: var(--starasia-ui-brand-primary-default, rgba(74, 106, 148, 1));
22
- --starasia-ui-input-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary, rgba(144, 176, 218, 1));
23
- --starasia-ui-input-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary, rgba(227, 237, 248, 1));
24
- --starasia-ui-input-color-quinary-blue: var(--starasia-ui-brand-primary-tertiary, rgba(227, 237, 248, 1));
25
- /* gray */
26
- --starasia-ui-input-color-primary-gray: var(
27
- --starasia-ui-color-gray-700,
28
- rgba(72, 80, 76, 1)
29
- );
30
- --starasia-ui-input-color-secondary-gray: var(
31
- --starasia-ui-color-gray-500,
32
- rgba(120, 134, 127, 1)
33
- );
34
- --starasia-ui-input-color-tertiary-gray: var(
35
- --starasia-ui-color-gray-300,
36
- rgba(174, 182, 178, 1)
37
- );
38
- --starasia-ui-input-color-quaternary-gray: var(
39
- --starasia-ui-color-gray-100,
40
- rgba(239, 243, 248, 1)
41
- );
42
- --starasia-ui-input-color-quinary-gray: var(
43
- --starasia-ui-color-gray-50,
44
- rgba(255, 254, 255, 1)
45
- );
46
- /* red */
47
- --starasia-ui-input-color-primary-red: var(
48
- --starasia-ui-color-red-700,
49
- rgba(164, 19, 60, 1)
50
- );
51
- --starasia-ui-input-color-secondary-red: var(
52
- --starasia-ui-color-red-500,
53
- rgba(255, 77, 109, 1)
54
- );
55
- --starasia-ui-input-color-tertiary-red: var(
56
- --starasia-ui-color-red-300,
57
- rgba(255, 143, 163, 1)
58
- );
59
- --starasia-ui-input-color-quaternary-red: var(
60
- --starasia-ui-color-red-100,
61
- rgba(255, 204, 213, 1)
62
- );
63
- --starasia-ui-input-color-quinary-red: var(
64
- --starasia-ui-color-red-50,
65
- rgba(255, 240, 243, 1)
66
- );
67
- /* orange */
68
- --starasia-ui-input-color-primary-orange: var(
69
- --starasia-ui-color-orange-700,
70
- rgba(152, 104, 0, 1)
71
- );
72
- --starasia-ui-input-color-secondary-orange: var(
73
- --starasia-ui-color-orange-500,
74
- rgba(210, 160, 58, 1)
75
- );
76
- --starasia-ui-input-color-tertiary-orange: var(
77
- --starasia-ui-color-orange-300,
78
- rgba(255, 203, 105, 1)
79
- );
80
- --starasia-ui-input-color-quaternary-orange: var(
81
- --starasia-ui-color-orange-100,
82
- rgba(255, 245, 193, 1)
83
- );
84
- --starasia-ui-input-color-quinary-orange: var(
85
- --starasia-ui-color-orange-50,
86
- rgba(250, 246, 224, 1)
87
- );
88
-
89
- /* text color */
90
- --starasia-ui-text-default: var(--starasia-ui-color-gray-900);
91
- --starasia-ui-color-text: var(--starasia-ui-text-default);
92
-
93
- /* border width */
94
- --starasia-ui-input-border-width: var(--starasia-ui-border, 1px);
95
-
96
- /* border color */
97
- --starasia-ui-color-border: rgba(120, 134, 127, 0.2);
98
-
99
- /* disabled */
100
- --starasia-ui-input-color-disabled-bg: rgba(242, 243, 242, 1);
101
- --starasia-ui-input-color-disabled-text: rgba(147, 158, 153, 1);
102
- --starasia-ui-input-color-addons-bg: rgba(120, 134, 127, 0.1);
103
- --starasia-ui-input-color-addons-bg-disabled: rgba(120, 134, 127, 0.3);
104
-
105
- /* white */
106
- --starasia-ui-input-color-white: var(--starasia-ui-color-gray-50, rgba(255, 254, 255, 1));
6
+ /* Figma design tokens */
7
+ --sa-input-text-primary: #292a2e;
8
+ --sa-input-text-subtle: #505258;
9
+ --sa-input-text-subtlest: #6b6e76;
10
+ --sa-input-text-error: #a4133c;
11
+ --sa-input-text-disable: rgba(24, 26, 25, 0.56);
12
+
13
+ --sa-input-icon-subtle: #505258;
14
+ --sa-input-icon-subtlest: #6b6e76;
15
+ --sa-input-icon-success: #208958;
16
+ --sa-input-icon-disable: rgba(24, 26, 25, 0.56);
17
+
18
+ --sa-input-border-subtle: rgba(11, 18, 14, 0.14);
19
+ --sa-input-border-brand: #1976d2;
20
+ --sa-input-border-brand-subtle: #90caf9;
21
+ --sa-input-border-danger: #c9184a;
22
+ --sa-input-border-danger-subtle: #ffb3c1;
23
+ --sa-input-border-success: #28ac6e;
24
+ --sa-input-border-disabled: rgba(24, 26, 25, 0.56);
25
+
26
+ --sa-input-bg-neutral: #f0f1f2;
27
+ --sa-input-bg-error-subtlest: #fff0f3;
28
+ --sa-input-bg-success-subtlest: #ecfff6;
29
+ --sa-input-accent-subtle: #f0f1f2;
30
+
31
+ --sa-input-text-placeholder: rgb(201, 206, 204);
32
+
33
+ --sa-input-radius: 6px;
34
+ --sa-input-padding-x: 12px;
35
+ --sa-input-padding-y: 8px;
36
+ --sa-input-gap: 8px;
37
+ }
38
+
39
+ /* ROOT */
40
+ .sa-tf {
41
+ box-sizing: border-box;
42
+ display: flex;
43
+ flex-direction: column;
44
+ align-items: stretch;
45
+ gap: 8px;
46
+ font-family: "Poppins", sans-serif;
47
+ width: max-content;
48
+ }
49
+ .sa-tf *,
50
+ .sa-tf *::before,
51
+ .sa-tf *::after {
52
+ box-sizing: border-box;
53
+ }
54
+ .sa-tf-fullwidth {
55
+ width: 100%;
56
+ }
107
57
 
108
- /* height */
109
- --starasia-ui-input-height-sm: var(--starasia-ui-h-8, 32px);
110
- /* --starasia-ui-input-height-md: var(--starasia-ui-h-10, 40px); */
111
- --starasia-ui-input-height-md: 38px;
112
- --starasia-ui-input-height-lg: var(--starasia-ui-h-12, 48px);
58
+ /* outside-left layout */
59
+ .sa-tf-label-outside-left {
60
+ flex-direction: row;
61
+ align-items: flex-start;
62
+ gap: 8px;
63
+ }
64
+ .sa-tf-label-outside-left > .sa-tf-label-col {
65
+ width: 40%;
66
+ min-width: 120px;
67
+ display: flex;
68
+ flex-direction: column;
69
+ gap: 8px;
70
+ padding-top: 9.5px;
71
+ }
72
+ .sa-tf-label-outside-left > .sa-tf-input-col {
73
+ flex: 1 1 0;
74
+ min-width: 0;
75
+ display: flex;
76
+ flex-direction: column;
77
+ gap: 8px;
78
+ }
113
79
 
114
- /* border radius */
115
- --starasia-ui-input-border-radius-sm: var(--starasia-ui-radii-md, 8px);
116
- --starasia-ui-input-border-radius-md: var(--starasia-ui-radii-md, 8px);
117
- --starasia-ui-input-border-radius-lg: var(--starasia-ui-radii-lg, 12px);
80
+ /* LABEL ROW */
81
+ .sa-tf-label {
82
+ display: flex;
83
+ align-items: center;
84
+ gap: 4px;
85
+ width: 100%;
86
+ color: var(--sa-input-text-primary);
87
+ font-weight: 500;
88
+ font-size: 14px;
89
+ line-height: normal;
90
+ margin: 0;
91
+ }
92
+ .sa-tf-size-sm .sa-tf-label,
93
+ .sa-tf-size-sm .sa-tf-label-inside-text {
94
+ font-size: 12px;
95
+ }
96
+ .sa-tf-required {
97
+ color: var(--sa-input-text-error);
98
+ font-weight: 500;
99
+ }
100
+ .sa-tf-optional {
101
+ background: var(--sa-input-accent-subtle);
102
+ border: 1px solid var(--sa-input-border-subtle);
103
+ border-radius: 4px;
104
+ padding: 0 8px;
105
+ font-size: 10px;
106
+ font-weight: 500;
107
+ line-height: 18px;
108
+ color: var(--sa-input-text-primary);
109
+ display: inline-flex;
110
+ align-items: center;
111
+ }
118
112
 
119
- --starasia-ui-input-placeholder-color: var(
120
- --starasia-ui-color-gray-200,
121
- rgba(201, 206, 204, 1)
122
- );
113
+ /* DESCRIPTIONS */
114
+ .sa-tf-desc-top,
115
+ .sa-tf-helper,
116
+ .sa-tf-error {
117
+ font-size: 12px;
118
+ line-height: 18px;
119
+ margin: 0;
120
+ font-weight: 400;
121
+ }
122
+ .sa-tf-desc-top,
123
+ .sa-tf-helper {
124
+ color: var(--sa-input-text-subtlest);
125
+ }
126
+ .sa-tf-error {
127
+ color: var(--sa-input-text-error);
128
+ }
129
+ .sa-tf-size-sm .sa-tf-desc-top,
130
+ .sa-tf-size-sm .sa-tf-helper,
131
+ .sa-tf-size-sm .sa-tf-error {
132
+ font-size: 10px;
133
+ line-height: 15px;
123
134
  }
124
135
 
125
- .starasia-input-container {
126
- box-sizing: border-box;
136
+ /* INPUT BOX */
137
+ .sa-tf-box {
138
+ display: flex;
139
+ align-items: stretch;
140
+ gap: var(--sa-input-gap);
141
+ border-radius: var(--sa-input-radius);
142
+ position: relative;
143
+ width: 100%;
144
+ background: transparent;
145
+ border: 0.8px solid var(--sa-input-border-subtle);
127
146
  overflow: hidden;
147
+ transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
148
+ }
149
+ .sa-tf-box-content {
128
150
  display: flex;
129
151
  align-items: center;
130
- /* gap: var(--starasia-ui-input-spacing-sm); */
152
+ gap: var(--sa-input-gap);
153
+ flex: 1 1 0;
154
+ min-width: 0;
155
+ padding: var(--sa-input-padding-y) var(--sa-input-padding-x);
131
156
  }
132
157
 
133
- .starasia-input-container:has(input:focus) {
134
- border-color: var(--starasia-ui-input-color-primary-blue);
135
- box-shadow: 0px 0px 0px 2px var(--starasia-ui-input-color-quaternary-blue);
158
+ /* sizes */
159
+ .sa-tf-size-sm .sa-tf-box {
160
+ min-height: 32px;
136
161
  }
137
-
138
- .starasia-input-container:has(input:disabled)
139
- .starasia-input-container-icon-left {
140
- background-color: var(--starasia-ui-input-color-disabled-bg);
162
+ .sa-tf-size-md .sa-tf-box {
163
+ min-height: 40px;
141
164
  }
142
-
143
- .starasia-input-container:has(input:disabled)
144
- .starasia-input-container-icon-right {
145
- background-color: var(--starasia-ui-input-color-disabled-bg);
165
+ .sa-tf-size-lg .sa-tf-box {
166
+ min-height: 48px;
146
167
  }
147
-
148
- .starasia-input-container:has(input:disabled) {
149
- /* border-color: var(--starasia-ui-input-color-tertiary-gray); */
150
- /* background-color: var(--starasia-ui-input-color-tertiary-gray); */
151
- border-color: var(--starasia-ui-color-border);
152
- background-color: var(--starasia-ui-input-color-disabled-bg);
168
+ .sa-tf-size-xl .sa-tf-box {
169
+ min-height: 56px;
153
170
  }
154
171
 
155
- .starasia-input-container:has(input:disabled) input {
156
- color: var(--starasia-ui-input-color-disabled-text) !important;
157
- border-color: var(--starasia-ui-color-border);
158
- background-color: var(--starasia-ui-input-color-disabled-bg);
172
+ /* variants */
173
+ .sa-tf-variant-outline .sa-tf-box {
174
+ background: transparent;
175
+ border: 0.8px solid var(--sa-input-border-subtle);
159
176
  }
160
-
161
- .starasia-input-outline.starasia-input-container-error {
162
- border-color: var(--starasia-ui-input-color-secondary-red) !important;
177
+ .sa-tf-variant-standard .sa-tf-box {
178
+ background: var(--sa-input-bg-neutral);
179
+ border: 0.8px solid transparent;
163
180
  }
164
-
165
- .starasia-input-filled.starasia-input-container-error {
166
- border-color: var(--starasia-ui-input-color-secondary-red) !important;
167
- background-color: var(--starasia-ui-input-color-quinary-red);
181
+ .sa-tf-variant-flushed .sa-tf-box {
182
+ background: transparent;
183
+ border: 0;
184
+ border-bottom: 0.8px solid var(--sa-input-border-subtle);
185
+ border-radius: 0;
168
186
  }
169
187
 
170
- .starasia-input-flushed.starasia-input-container-error {
171
- border-color: var(--starasia-ui-input-color-secondary-red) !important;
188
+ /* state: focused */
189
+ .sa-tf-focused.sa-tf-status-default .sa-tf-box,
190
+ .sa-tf-variant-outline.sa-tf-focused.sa-tf-status-default .sa-tf-box {
191
+ border-color: var(--sa-input-border-brand);
192
+ border-width: 1.2px;
172
193
  }
173
-
174
- .starasia-input-outline.starasia-input-container-warning {
175
- border-color: var(--starasia-ui-input-color-secondary-orange) !important;
194
+ .sa-tf-variant-flushed.sa-tf-focused.sa-tf-status-default .sa-tf-box {
195
+ border-bottom-color: var(--sa-input-border-brand);
196
+ border-bottom-width: 1.2px;
176
197
  }
177
-
178
- .starasia-input-filled.starasia-input-container-warning {
179
- border-color: var(--starasia-ui-input-color-secondary-orange) !important;
180
- background-color: var(--starasia-ui-input-color-quinary-orange);
198
+ .sa-tf-variant-standard.sa-tf-focused.sa-tf-status-default .sa-tf-box {
199
+ border-color: var(--sa-input-border-brand);
200
+ border-width: 1.2px;
181
201
  }
182
202
 
183
- .starasia-input-flushed.starasia-input-container-warning {
184
- border-color: var(--starasia-ui-input-color-secondary-orange) !important;
203
+ /* inside-label focused: outer ring */
204
+ .sa-tf-label-inside.sa-tf-focused.sa-tf-status-default .sa-tf-box {
205
+ box-shadow: 0 0 0 1.2px var(--sa-input-border-brand-subtle);
185
206
  }
186
207
 
187
- .starasia-input-outline {
188
- border-color: var(--starasia-ui-color-border);
189
- background-color: transparent;
190
- border-width: var(--starasia-ui-input-border-width);
191
- border-style: solid;
208
+ /* state: error */
209
+ .sa-tf-status-error .sa-tf-box {
210
+ border-color: var(--sa-input-border-danger);
211
+ border-width: 1.2px;
192
212
  }
193
-
194
- .starasia-input-filled {
195
- border-width: var(--starasia-ui-input-border-width);
196
- border-style: solid;
197
- border-color: var(--starasia-ui-input-color-quinary-gray);
198
- background-color: var(--starasia-ui-input-color-quinary-gray);
213
+ .sa-tf-variant-flushed.sa-tf-status-error .sa-tf-box {
214
+ border: 0;
215
+ border-bottom: 1.2px solid var(--sa-input-border-danger);
199
216
  }
200
217
 
201
- .starasia-input-flushed.starasia-input-container:has(input:focus) {
202
- box-shadow: none;
218
+ /* Flushed must never render a box-shadow ring — only the bottom border. */
219
+ .sa-tf-variant-flushed .sa-tf-box {
220
+ box-shadow: none !important;
203
221
  }
204
-
205
- .starasia-input-flushed {
206
- border-bottom: var(--starasia-ui-input-border-width) solid
207
- var(--starasia-ui-input-color-tertiary-gray);
208
- border-bottom-left-radius: 0 !important;
209
- border-bottom-right-radius: 0 !important;
222
+ .sa-tf-variant-standard.sa-tf-status-error .sa-tf-box {
223
+ background: var(--sa-input-bg-error-subtlest);
210
224
  }
211
-
212
- .starasia-input-container.sm {
213
- height: var(--starasia-ui-input-height-sm);
214
- border-radius: var(--starasia-ui-input-border-radius-sm);
215
- font-size: var(--starasia-ui-fontSizes-sm, 12px);
216
- /* padding-inline: var(--starasia-ui-input-spacing-sm); */
225
+ .sa-tf-status-error.sa-tf-focused .sa-tf-box {
226
+ box-shadow: 0 0 0 1.2px var(--sa-input-border-danger-subtle);
217
227
  }
218
228
 
219
- .starasia-input-container.md {
220
- height: var(--starasia-ui-input-height-md);
221
- border-radius: var(--starasia-ui-input-border-radius-md);
222
- font-size: var(--starasia-ui-fontSizes-md, 14px);
223
- /* padding-inline: var(--starasia-ui-input-spacing-ms); */
229
+ /* state: success */
230
+ .sa-tf-status-success .sa-tf-box {
231
+ border-color: var(--sa-input-border-success);
232
+ border-width: 1.2px;
233
+ }
234
+ .sa-tf-variant-flushed.sa-tf-status-success .sa-tf-box {
235
+ border: 0;
236
+ border-bottom: 1.2px solid var(--sa-input-border-success);
237
+ }
238
+ .sa-tf-variant-standard.sa-tf-status-success .sa-tf-box {
239
+ background: var(--sa-input-bg-success-subtlest);
224
240
  }
225
241
 
226
- .starasia-input-container.lg {
227
- height: var(--starasia-ui-input-height-lg);
228
- border-radius: var(--starasia-ui-input-border-radius-lg);
229
- font-size: var(--starasia-ui-fontSizes-lg, 16px);
230
- /* padding-inline: var(--starasia-ui-input-spacing-ms); */
242
+ /* state: disable */
243
+ .sa-tf-status-disable .sa-tf-box,
244
+ .sa-tf-disabled .sa-tf-box {
245
+ border-color: var(--sa-input-border-disabled);
246
+ cursor: not-allowed;
247
+ }
248
+ .sa-tf-variant-standard.sa-tf-status-disable .sa-tf-box,
249
+ .sa-tf-variant-standard.sa-tf-disabled .sa-tf-box {
250
+ background: var(--sa-input-bg-neutral);
251
+ border-color: transparent;
252
+ }
253
+ .sa-tf-status-disable .sa-tf-input,
254
+ .sa-tf-disabled .sa-tf-input {
255
+ color: var(--sa-input-text-disable);
256
+ cursor: not-allowed;
257
+ }
258
+ .sa-tf-status-disable .sa-tf-placeholder,
259
+ .sa-tf-disabled .sa-tf-placeholder {
260
+ color: var(--sa-input-text-disable);
231
261
  }
232
262
 
233
- .starasia-input-preview-container {
234
- width: 100%;
235
- position: relative;
236
- z-index: 1;
237
- height: 100%;
263
+ /* Icons inside box */
264
+ .sa-tf-icon {
265
+ display: inline-flex;
266
+ align-items: center;
267
+ justify-content: center;
268
+ flex-shrink: 0;
269
+ color: var(--sa-input-icon-subtle);
270
+ }
271
+ .sa-tf-icon-clickable {
272
+ cursor: pointer;
273
+ }
274
+ .sa-tf-status-disable .sa-tf-icon,
275
+ .sa-tf-disabled .sa-tf-icon {
276
+ color: var(--sa-input-icon-disable);
277
+ }
278
+ .sa-tf-status-success .sa-tf-success-mark {
279
+ color: var(--sa-input-icon-success);
238
280
  }
239
281
 
240
- .starasia-input-placeholder {
241
- position: absolute;
242
- top: 50%;
243
- left: 8px;
244
- transform: translateY(-50%);
245
- font-family: "Poppins", serif;
246
- color: var(--starasia-ui-input-placeholder-color);
247
- font-weight: var(--starasia-ui-fontWeights-normal, 300);
282
+ /* Clear (×) button — slot is always reserved to keep input width stable */
283
+ .sa-tf-clear {
284
+ appearance: none;
285
+ border: 0;
286
+ background: transparent;
287
+ padding: 0;
288
+ margin: 0;
289
+ cursor: pointer;
290
+ color: var(--sa-input-icon-subtlest);
291
+ border-radius: 50%;
292
+ opacity: 1;
293
+ transition: opacity 120ms ease, color 120ms ease, transform 80ms ease;
294
+ }
295
+ .sa-tf-clear:hover {
296
+ color: var(--sa-input-icon-subtle);
297
+ }
298
+ .sa-tf-clear:active {
299
+ transform: scale(0.92);
300
+ }
301
+ .sa-tf-clear:focus-visible {
302
+ outline: 2px solid var(--sa-input-border-brand-subtle);
303
+ outline-offset: 2px;
304
+ }
305
+ .sa-tf-clear-hidden {
306
+ opacity: 0;
248
307
  pointer-events: none;
308
+ cursor: default;
249
309
  }
250
310
 
251
- .starasia-input-placeholder-highlighted {
252
- color: var(--starasia-ui-input-color-primary-gray);
311
+ /* Addons (left/right blocks) */
312
+ .sa-tf-addon {
313
+ display: flex;
314
+ align-items: center;
315
+ justify-content: center;
316
+ padding: 0 12px;
317
+ background: var(--sa-input-bg-neutral);
318
+ color: var(--sa-input-text-subtle);
319
+ font-size: 14px;
320
+ line-height: 21px;
321
+ flex-shrink: 0;
322
+ align-self: stretch;
253
323
  }
254
-
255
- .starasia-input-preview-container
256
- .starasia-input:focus
257
- + .starasia-input-placeholder {
258
- display: none;
324
+ .sa-tf-addon-left {
325
+ border-right: 0.8px solid var(--sa-input-border-subtle);
326
+ }
327
+ .sa-tf-addon-right {
328
+ border-left: 0.8px solid var(--sa-input-border-subtle);
329
+ }
330
+ .sa-tf-size-sm .sa-tf-addon {
331
+ font-size: 12px;
332
+ line-height: 18px;
259
333
  }
260
334
 
261
- .starasia-input {
335
+ /* Input field + placeholder */
336
+ .sa-tf-field-wrap {
337
+ display: flex;
338
+ align-items: center;
339
+ flex: 1 1 0;
340
+ min-width: 0;
341
+ position: relative;
342
+ }
343
+ .sa-tf-input {
262
344
  width: 100%;
263
- box-sizing: border-box;
264
- height: 100%;
265
- border: none;
345
+ border: 0;
266
346
  outline: none;
267
- font-family: "Poppins", serif;
268
- font-size: inherit;
269
- font-weight: var(--starasia-ui-fontWeights-medium, 400);
270
347
  background: transparent;
271
- color: var(--starasia-ui-color-text);
272
- padding-inline: var(--starasia-ui-input-spacing-sm) !important;
348
+ padding: 0;
349
+ margin: 0;
350
+ font-family: inherit;
351
+ font-size: 14px;
352
+ font-weight: 400;
353
+ line-height: 21px;
354
+ color: var(--sa-input-text-primary);
355
+ }
356
+ .sa-tf-size-sm .sa-tf-input {
357
+ font-size: 12px;
358
+ line-height: 18px;
359
+ }
360
+ .sa-tf-input::placeholder {
361
+ color: var(--sa-input-text-placeholder);
362
+ font-weight: 300;
363
+ opacity: 1;
364
+ }
365
+ .sa-tf-variant-standard .sa-tf-input::placeholder,
366
+ .sa-tf-variant-standard .sa-tf-placeholder {
367
+ color: var(--sa-input-text-placeholder);
368
+ }
369
+ .sa-tf-input:disabled {
370
+ color: var(--sa-input-text-disable);
371
+ cursor: not-allowed;
372
+ -webkit-text-fill-color: var(--sa-input-text-disable);
273
373
  }
274
374
 
275
- /* .starasia-input-container:not(:has(.starasia-input-container-icon-left)) .starasia-input {
276
- padding-inline: 12px !important;
277
- } */
278
- /* just icon */
279
-
280
- /* INPUT ICON */
281
- .starasia-input-container-icon-left {
375
+ .sa-tf-placeholder {
376
+ position: absolute;
377
+ inset: 0;
282
378
  display: flex;
283
- height: 100%;
284
379
  align-items: center;
285
- padding-left: 12px;
286
- background: transparent;
380
+ pointer-events: none;
381
+ color: var(--sa-input-text-placeholder);
382
+ font-size: 14px;
383
+ font-weight: 300;
384
+ line-height: 21px;
385
+ margin: 0;
386
+ white-space: nowrap;
387
+ overflow: hidden;
388
+ text-overflow: ellipsis;
389
+ }
390
+ .sa-tf-size-sm .sa-tf-placeholder {
391
+ font-size: 12px;
392
+ line-height: 18px;
393
+ }
394
+ .sa-tf-placeholder-highlight {
395
+ color: var(--sa-input-text-primary);
396
+ font-weight: 500;
287
397
  }
288
398
 
289
- .starasia-input-container-icon-right {
290
- display: flex;
291
- height: 100%;
399
+ /* ─────────────────────────────────────────────────────────────────
400
+ Inside-label (floating) layout & animation
401
+ ─────────────────────────────────────────────────────────────────
402
+ Both rows always render so the transition is smooth — visibility
403
+ is controlled with max-height + opacity, not conditional render.
404
+ */
405
+ .sa-tf-label-inside .sa-tf-box {
292
406
  align-items: center;
293
- padding-right: 12px;
294
- background: transparent;
407
+ cursor: text;
295
408
  }
296
-
297
- /* INPUT ADDONS */
298
- .starasia-input-container-addons-left {
299
- background-color: var(--starasia-ui-input-color-addons-bg);
300
- height: 100%;
301
- display: flex;
302
- padding-inline: var(--starasia-ui-input-spacing-ms);
409
+ .sa-tf-label-inside.sa-tf-disabled .sa-tf-box,
410
+ .sa-tf-label-inside.sa-tf-status-disable .sa-tf-box {
411
+ cursor: not-allowed;
412
+ }
413
+ /* Box-content stays as a flex row so icons share container padding. */
414
+ .sa-tf-label-inside .sa-tf-box-content {
415
+ flex-direction: row;
303
416
  align-items: center;
304
- justify-content: center;
305
- font-family: "Poppins", serif;
306
- color: var(--starasia-ui-input-color-secondary-gray);
307
- border-right: 1px solid var(--starasia-ui-color-border);
417
+ gap: var(--sa-input-gap);
308
418
  }
309
419
 
310
- .starasia-input-container-addons-right {
311
- background-color: var(--starasia-ui-input-color-addons-bg);
312
- height: 100%;
420
+ /* The label + input rows live inside this column. Stack handles the
421
+ floating animation; icons (siblings) translate to align with the
422
+ input row when floating. */
423
+ .sa-tf-label-inside .sa-tf-inside-stack {
313
424
  display: flex;
314
- padding-inline: var(--starasia-ui-input-spacing-ms);
315
- align-items: center;
425
+ flex-direction: column;
426
+ flex: 1 1 0;
427
+ min-width: 0;
428
+ gap: 0;
316
429
  justify-content: center;
317
- font-family: "Poppins", serif;
318
- color: var(--starasia-ui-input-color-secondary-gray);
319
- border-left: 1px solid var(--starasia-ui-color-border);
430
+ transition: gap 180ms cubic-bezier(0.4, 0, 0.2, 1);
431
+ }
432
+ .sa-tf-label-inside.sa-tf-floating .sa-tf-inside-stack {
433
+ gap: 4px;
320
434
  }
321
435
 
322
- .starasia-input-container:has(input:disabled)
323
- .starasia-input-container-addons-right {
324
- background-color: var(--starasia-ui-input-color-addons-bg-disabled) !important;
436
+ /* Icons & success-mark: align with active row.
437
+ Resting → vertical-center of label.
438
+ Floating → translated down so they sit next to the input text. */
439
+ .sa-tf-label-inside .sa-tf-box-content > .sa-tf-icon {
440
+ align-self: center;
441
+ transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
442
+ transform: translateY(0);
443
+ }
444
+ .sa-tf-label-inside.sa-tf-floating .sa-tf-box-content > .sa-tf-icon {
445
+ transform: translateY(11px);
446
+ }
447
+ .sa-tf-label-inside.sa-tf-size-sm.sa-tf-floating .sa-tf-box-content > .sa-tf-icon {
448
+ transform: translateY(9px);
449
+ }
450
+ .sa-tf-label-inside.sa-tf-size-lg.sa-tf-floating .sa-tf-box-content > .sa-tf-icon {
451
+ transform: translateY(12px);
452
+ }
453
+ .sa-tf-label-inside.sa-tf-size-xl.sa-tf-floating .sa-tf-box-content > .sa-tf-icon {
454
+ transform: translateY(13px);
325
455
  }
326
456
 
327
- .starasia-input-container:has(input:disabled)
328
- .starasia-input-container-addons-left {
329
- background-color: var(--starasia-ui-input-color-addons-bg-disabled) !important;
457
+ /* Label row — animates font-size when floating */
458
+ .sa-tf-label-inside .sa-tf-inside-label-row {
459
+ display: flex;
460
+ align-items: center;
461
+ gap: 4px;
462
+ width: 100%;
463
+ font-size: 14px;
464
+ font-weight: 500;
465
+ color: var(--sa-input-text-primary);
466
+ line-height: 21px;
467
+ transition: font-size 180ms cubic-bezier(0.4, 0, 0.2, 1),
468
+ line-height 180ms cubic-bezier(0.4, 0, 0.2, 1),
469
+ color 180ms cubic-bezier(0.4, 0, 0.2, 1);
470
+ pointer-events: none;
471
+ }
472
+ .sa-tf-label-inside .sa-tf-inside-label-row label {
473
+ pointer-events: auto;
474
+ }
475
+ .sa-tf-label-inside.sa-tf-size-sm .sa-tf-inside-label-row {
476
+ font-size: 12px;
477
+ line-height: 18px;
478
+ }
479
+ .sa-tf-label-inside.sa-tf-floating .sa-tf-inside-label-row {
480
+ font-size: 12px;
481
+ line-height: 18px;
482
+ color: var(--sa-input-text-subtle);
483
+ }
484
+ .sa-tf-label-inside.sa-tf-size-sm.sa-tf-floating .sa-tf-inside-label-row {
485
+ font-size: 10px;
486
+ line-height: 15px;
487
+ }
488
+ .sa-tf-label-inside.sa-tf-focused.sa-tf-status-default .sa-tf-inside-label-row {
489
+ color: var(--sa-input-border-brand);
490
+ }
491
+ .sa-tf-label-inside.sa-tf-status-error .sa-tf-inside-label-row {
492
+ color: var(--sa-input-text-error);
493
+ }
494
+ .sa-tf-label-inside.sa-tf-no-label .sa-tf-inside-label-row {
495
+ display: none;
330
496
  }
331
497
 
332
- .starasia-input::placeholder {
333
- color: var(--starasia-ui-input-placeholder-color);
334
- font-weight: var(--starasia-ui-fontWeights-normal, 300);
335
- }
336
- `, P = (a) => {
337
- if (a === "sm")
338
- return 16;
339
- if (a === "md")
340
- return 16;
341
- if (a === "lg")
342
- return 20;
343
- }, T = (a) => a === "default" ? "#939E99" : a === "error" ? "#EF4444" : a === "warning" ? "#EAB308" : "#939E99", j = (a) => a === "default" ? "#939E99" : a === "error" ? "#EF4444" : a === "warning" ? "#EAB308" : "#939E99", J = W(
344
- ({ options: a, value: n, setValue: s, isComponentVisible: o, onOptionChange: e }, i) => {
345
- const [k, V] = w([]), u = A(null), g = () => {
346
- if (i != null && i.current && u.current) {
347
- const h = window.innerHeight, b = i == null ? void 0 : i.current.getBoundingClientRect(), C = u.current.getBoundingClientRect(), m = b.bottom + C.height;
348
- u.current.style.left = `${b.left}px`, u.current.style.width = `${b.width}px`, m >= h - 10 ? u.current.style.top = `${b.top - C.height - 5}px` : u.current.style.top = `${b.top + b.height}px`;
498
+ /* Input row — collapsed when not floating */
499
+ .sa-tf-label-inside .sa-tf-inside-row {
500
+ display: flex;
501
+ align-items: center;
502
+ gap: var(--sa-input-gap);
503
+ width: 100%;
504
+ max-height: 0;
505
+ opacity: 0;
506
+ overflow: hidden;
507
+ transform-origin: top left;
508
+ transform: translateY(-4px);
509
+ transition: max-height 180ms cubic-bezier(0.4, 0, 0.2, 1),
510
+ opacity 140ms cubic-bezier(0.4, 0, 0.2, 1),
511
+ transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
512
+ }
513
+ .sa-tf-label-inside.sa-tf-floating .sa-tf-inside-row,
514
+ .sa-tf-label-inside.sa-tf-no-label .sa-tf-inside-row {
515
+ max-height: 28px;
516
+ opacity: 1;
517
+ transform: translateY(0);
518
+ }
519
+ .sa-tf-label-inside.sa-tf-size-sm.sa-tf-floating .sa-tf-inside-row,
520
+ .sa-tf-label-inside.sa-tf-size-sm.sa-tf-no-label .sa-tf-inside-row {
521
+ max-height: 22px;
522
+ }
523
+ .sa-tf-label-inside.sa-tf-size-lg.sa-tf-floating .sa-tf-inside-row,
524
+ .sa-tf-label-inside.sa-tf-size-xl.sa-tf-floating .sa-tf-inside-row,
525
+ .sa-tf-label-inside.sa-tf-size-lg.sa-tf-no-label .sa-tf-inside-row,
526
+ .sa-tf-label-inside.sa-tf-size-xl.sa-tf-no-label .sa-tf-inside-row {
527
+ max-height: 32px;
528
+ }
529
+
530
+ /* Box height grows smoothly when floating */
531
+ .sa-tf-label-inside .sa-tf-box {
532
+ transition: border-color 120ms ease, box-shadow 120ms ease,
533
+ background-color 120ms ease, min-height 180ms cubic-bezier(0.4, 0, 0.2, 1);
534
+ }
535
+ .sa-tf-label-inside.sa-tf-floating.sa-tf-size-sm .sa-tf-box {
536
+ min-height: 56px;
537
+ }
538
+ .sa-tf-label-inside.sa-tf-floating.sa-tf-size-md .sa-tf-box {
539
+ min-height: 64px;
540
+ }
541
+ .sa-tf-label-inside.sa-tf-floating.sa-tf-size-lg .sa-tf-box {
542
+ min-height: 72px;
543
+ }
544
+ .sa-tf-label-inside.sa-tf-floating.sa-tf-size-xl .sa-tf-box {
545
+ min-height: 80px;
546
+ }
547
+ `, k = (n) => n === "lg" || n === "xl" ? 18 : 16, G = {
548
+ default: "#505258",
549
+ error: "#a4133c",
550
+ success: "#208958",
551
+ disable: "rgba(24, 26, 25, 0.56)"
552
+ }, pn = (n, s) => s ? G.disable : G[n] ?? G.default;
553
+ function En(n) {
554
+ return Number(n.replace(/\./g, ""));
555
+ }
556
+ function J(n) {
557
+ let s = n.replace(/[^\d]/g, "");
558
+ return s = s.replace(/^0+(?=\d)/, ""), s.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
559
+ }
560
+ function Dn(n, s) {
561
+ if (s <= 0)
562
+ return 0;
563
+ let r = 0;
564
+ for (let l = 0; l < n.length; l++)
565
+ if (/\d/.test(n[l]) && (r += 1, r === s))
566
+ return l + 1;
567
+ return n.length;
568
+ }
569
+ const Fn = hn(
570
+ ({ options: n, value: s, setValue: r, isComponentVisible: l, onOptionChange: d }, f) => {
571
+ const [x, V] = I([]), c = B(null), u = () => {
572
+ if (f != null && f.current && c.current) {
573
+ const h = window.innerHeight, p = f == null ? void 0 : f.current.getBoundingClientRect(), m = c.current.getBoundingClientRect(), w = p.bottom + m.height;
574
+ c.current.style.left = `${p.left}px`, c.current.style.width = `${p.width}px`, w >= h - 10 ? c.current.style.top = `${p.top - m.height - 5}px` : c.current.style.top = `${p.top + p.height}px`;
349
575
  }
350
576
  };
351
- return x(() => (window.addEventListener("scroll", g), window.addEventListener("resize", g), () => {
352
- window.removeEventListener("scroll", g), window.removeEventListener("resize", g);
353
- }), [i, u]), x(() => {
354
- g();
355
- }, [o]), x(() => {
577
+ return T(() => (window.addEventListener("scroll", u), window.addEventListener("resize", u), () => {
578
+ window.removeEventListener("scroll", u), window.removeEventListener("resize", u);
579
+ }), [f, c]), T(() => {
580
+ u();
581
+ }, [l]), T(() => {
356
582
  V(
357
- (a == null ? void 0 : a.filter(
358
- (h) => h.toLowerCase().startsWith(n.toLowerCase())
583
+ (n == null ? void 0 : n.filter(
584
+ (h) => h.toLowerCase().startsWith(s.toLowerCase())
359
585
  )) || []
360
586
  );
361
- }, [n, a]), /* @__PURE__ */ c(
587
+ }, [s, n]), /* @__PURE__ */ a(
362
588
  "div",
363
589
  {
364
- ref: u,
590
+ ref: c,
365
591
  style: {
366
592
  position: "fixed",
367
593
  padding: "8px",
@@ -372,15 +598,15 @@ const G = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@30
372
598
  overflow: "auto",
373
599
  zIndex: 5e4
374
600
  },
375
- children: k == null ? void 0 : k.map(
376
- (h) => M(h, n, s, e)
601
+ children: x == null ? void 0 : x.map(
602
+ (h) => On(h, s, r, d)
377
603
  )
378
604
  }
379
605
  );
380
606
  }
381
- ), M = (a, n, s, o) => {
382
- const e = a.toLowerCase().indexOf(n.toLowerCase());
383
- return /* @__PURE__ */ N(
607
+ ), On = (n, s, r, l) => {
608
+ const d = n.toLowerCase().indexOf(s.toLowerCase());
609
+ return /* @__PURE__ */ o(
384
610
  "p",
385
611
  {
386
612
  style: {
@@ -391,194 +617,328 @@ const G = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@30
391
617
  cursor: "pointer"
392
618
  },
393
619
  onClick: () => {
394
- s(a), o && o(a);
620
+ r(n), l && l(n);
395
621
  },
396
622
  children: [
397
- a.slice(0, e),
398
- /* @__PURE__ */ c("span", { style: { color: "#374151" }, children: a.slice(e, e + n.length) }),
399
- a.slice(e + n.length)
623
+ n.slice(0, d),
624
+ /* @__PURE__ */ a("span", { style: { color: "#374151" }, children: n.slice(d, d + s.length) }),
625
+ n.slice(d + s.length)
400
626
  ]
401
627
  }
402
628
  );
403
629
  };
404
- function Q(a) {
405
- const [n, s] = w(a), o = A(null), e = (i) => {
406
- o.current && !o.current.contains(i.target) && s(!1);
630
+ function Tn(n) {
631
+ const [s, r] = I(n), l = B(null), d = (f) => {
632
+ l.current && !l.current.contains(f.target) && r(!1);
407
633
  };
408
- return x(() => (document.addEventListener("click", e, !0), () => {
409
- document.removeEventListener("click", e, !0);
410
- }), []), { ref: o, isComponentVisible: n, setIsComponentVisible: s };
411
- }
412
- const D = "starasia-input-styles", X = (a) => {
413
- if (!document.getElementById(D)) {
414
- const n = document.createElement("style");
415
- n.id = D, n.textContent = a, document.head.appendChild(n);
634
+ return T(() => (document.addEventListener("click", d, !0), () => {
635
+ document.removeEventListener("click", d, !0);
636
+ }), []), { ref: l, isComponentVisible: s, setIsComponentVisible: r };
637
+ }
638
+ const bn = "starasia-input-styles", Vn = (n) => {
639
+ if (!(typeof document > "u") && !document.getElementById(bn)) {
640
+ const s = document.createElement("style");
641
+ s.id = bn, s.textContent = n, document.head.appendChild(s);
416
642
  }
417
643
  };
418
- X(G);
419
- function Z(a) {
420
- return Number(a.replace(/\./g, ""));
421
- }
422
- const z = (a) => {
423
- let n = a.replace(/[^\d]/g, "");
424
- return n = n.replace(/^0+(?=\d)/, ""), n.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
425
- }, ra = W(
426
- (a, n) => {
644
+ Vn(Sn);
645
+ const $n = (n) => /* @__PURE__ */ o(
646
+ "svg",
647
+ {
648
+ viewBox: "0 0 16 16",
649
+ fill: "none",
650
+ xmlns: "http://www.w3.org/2000/svg",
651
+ ...n,
652
+ children: [
653
+ /* @__PURE__ */ a("circle", { cx: "8", cy: "8", r: "6.5", stroke: "currentColor", strokeWidth: "1.2" }),
654
+ /* @__PURE__ */ a(
655
+ "path",
656
+ {
657
+ d: "M5.2 8.2l1.8 1.8 3.8-4.2",
658
+ stroke: "currentColor",
659
+ strokeWidth: "1.4",
660
+ strokeLinecap: "round",
661
+ strokeLinejoin: "round"
662
+ }
663
+ )
664
+ ]
665
+ }
666
+ ), jn = (n) => /* @__PURE__ */ o(
667
+ "svg",
668
+ {
669
+ viewBox: "0 0 16 16",
670
+ fill: "none",
671
+ xmlns: "http://www.w3.org/2000/svg",
672
+ ...n,
673
+ children: [
674
+ /* @__PURE__ */ a("circle", { cx: "8", cy: "8", r: "7", fill: "currentColor", opacity: "0.2" }),
675
+ /* @__PURE__ */ a(
676
+ "path",
677
+ {
678
+ d: "M5.5 5.5l5 5M10.5 5.5l-5 5",
679
+ stroke: "currentColor",
680
+ strokeWidth: "1.4",
681
+ strokeLinecap: "round"
682
+ }
683
+ )
684
+ ]
685
+ }
686
+ ), Yn = hn(
687
+ (n, s) => {
427
688
  const {
428
- leftIcon: s,
429
- rightIcon: o,
430
- size: e = "md",
431
- status: i = "default",
432
- inputUse: k = "icon",
433
- variant: V = "outline",
434
- leftAddons: u,
435
- rightAddons: g,
436
- onClickLeftIcon: h,
437
- onClickRightIcon: b,
438
- highlightPlaceholder: C,
439
- currency: m,
440
- fullWidth: O = !1,
689
+ size: r = "md",
690
+ variant: l = "outline",
691
+ status: d = "default",
692
+ label: f,
693
+ labelPosition: x = "outside-top",
694
+ required: V,
695
+ optional: c,
696
+ description: u,
697
+ helperText: h,
698
+ errorText: p,
699
+ leftIcon: m,
700
+ rightIcon: w,
701
+ leftAddons: L,
702
+ rightAddons: R,
703
+ onClickLeftIcon: Q,
704
+ onClickRightIcon: Z,
705
+ fullWidth: gn = !1,
706
+ highlightPlaceholder: $,
707
+ currency: S,
441
708
  options: E,
442
- onOptionChange: K,
443
- ...r
444
- } = a;
445
- {
446
- const [F, L] = w(!0), [v, S] = w(""), [H, R] = w(""), {
447
- isComponentVisible: q,
448
- ref: $,
449
- setIsComponentVisible: U
450
- } = Q(!1), Y = () => {
451
- U((t) => !t);
452
- };
453
- return x(() => {
454
- typeof r.value == "string" && r.value.length || r.defaultValue || typeof r.value == "number" ? L(!1) : L(!0);
455
- }, [r.value, r.defaultValue]), x(() => {
456
- S(m ? z(String(r.value)) : r.value || "");
457
- }, [r]), /* @__PURE__ */ N(
458
- "div",
709
+ onOptionChange: j,
710
+ clearable: xn = !0,
711
+ onClear: Y,
712
+ ...e
713
+ } = n, W = e.value !== void 0, [A, y] = I(() => {
714
+ const t = e.value !== void 0 ? String(e.value ?? "") : String(e.defaultValue ?? "");
715
+ return S ? J(t) : t;
716
+ }), [nn, tn] = I(!1), [mn, en] = I(""), z = B(null), C = B(null);
717
+ Rn(s, () => C.current);
718
+ const sn = B(
719
+ e.id ?? `sa-input-${Math.random().toString(36).slice(2, 9)}`
720
+ ), {
721
+ isComponentVisible: an,
722
+ ref: M,
723
+ setIsComponentVisible: vn
724
+ } = Tn(!1);
725
+ un(() => {
726
+ if (!W)
727
+ return;
728
+ const t = e.value === void 0 || e.value === null ? "" : String(e.value), i = S ? J(t) : t;
729
+ y((b) => b === i ? b : i);
730
+ }, [e.value, S, W]), un(() => {
731
+ if (z.current === null)
732
+ return;
733
+ const t = C.current, i = z.current;
734
+ if (z.current = null, !!t)
735
+ try {
736
+ t.setSelectionRange(i, i);
737
+ } catch {
738
+ }
739
+ }, [A]);
740
+ const N = A, D = N !== "" && N !== void 0, v = d === "disable" || e.disabled, P = v ? "disable" : d, H = x === "inside", wn = H && (D || nn), q = [
741
+ "sa-tf",
742
+ `sa-tf-variant-${l}`,
743
+ `sa-tf-size-${r}`,
744
+ `sa-tf-status-${P}`,
745
+ `sa-tf-label-${x}`,
746
+ nn ? "sa-tf-focused" : "",
747
+ v ? "sa-tf-disabled" : "",
748
+ wn ? "sa-tf-floating" : "",
749
+ f ? "" : "sa-tf-no-label",
750
+ gn ? "sa-tf-fullwidth" : ""
751
+ ].filter(Boolean).join(" "), yn = () => {
752
+ var t;
753
+ return (t = C.current) == null ? void 0 : t.focus();
754
+ }, zn = (t) => {
755
+ var fn, cn;
756
+ if (!S) {
757
+ const O = t.target.selectionStart;
758
+ O !== null && (z.current = O), y(t.target.value), (fn = e.onChange) == null || fn.call(e, t);
759
+ return;
760
+ }
761
+ const i = t.target.value;
762
+ let b = i, g = t.target.selectionStart ?? i.length;
763
+ if (mn === "Backspace") {
764
+ const O = A.replace(/\D/g, ""), In = i.replace(/\D/g, "");
765
+ O.length === In.length && g > 0 && (b = i.slice(0, g - 1) + i.slice(g), g -= 1);
766
+ }
767
+ const X = J(b), Cn = b.slice(0, g).replace(/\D/g, "").length, Nn = Dn(X, Cn);
768
+ z.current = Nn, y(X), (cn = e.onChange) == null || cn.call(e, {
769
+ ...t,
770
+ target: {
771
+ ...t.target,
772
+ value: String(En(X)),
773
+ name: t.target.name
774
+ }
775
+ }), en("");
776
+ }, K = (t) => f ? /* @__PURE__ */ o("div", { className: t, children: [
777
+ /* @__PURE__ */ a(
778
+ "label",
459
779
  {
460
- className: `starasia-input-container starasia-input-${V} starasia-input-container-${i} ${e} `,
461
- style: {
462
- width: O ? "auto" : "max-content",
463
- position: "relative"
780
+ htmlFor: sn.current,
781
+ style: { cursor: v ? "not-allowed" : "pointer" },
782
+ children: f
783
+ }
784
+ ),
785
+ c ? /* @__PURE__ */ a("span", { className: "sa-tf-optional", children: "Optional" }) : null,
786
+ V ? /* @__PURE__ */ a("span", { className: "sa-tf-required", "aria-hidden": "true", children: "*" }) : null
787
+ ] }) : null, _ = /* @__PURE__ */ o(Bn, { children: [
788
+ h ? /* @__PURE__ */ a("p", { className: "sa-tf-helper", children: h }) : null,
789
+ p && d === "error" ? /* @__PURE__ */ a("p", { className: "sa-tf-error", children: p }) : null
790
+ ] }), F = (t, i) => /* @__PURE__ */ a(
791
+ "span",
792
+ {
793
+ className: `sa-tf-icon${i ? " sa-tf-icon-clickable" : ""}`,
794
+ onClick: i,
795
+ children: Ln.cloneElement(t, {
796
+ width: k(r),
797
+ height: k(r),
798
+ color: pn(P, v),
799
+ style: { color: pn(P, v) }
800
+ })
801
+ }
802
+ ), rn = d === "success" ? /* @__PURE__ */ a("span", { className: "sa-tf-icon sa-tf-success-mark", "aria-hidden": "true", children: /* @__PURE__ */ a(
803
+ $n,
804
+ {
805
+ width: k(r),
806
+ height: k(r)
807
+ }
808
+ ) }) : null, on = xn && !v ? /* @__PURE__ */ a(
809
+ "button",
810
+ {
811
+ type: "button",
812
+ className: `sa-tf-icon sa-tf-clear${D ? "" : " sa-tf-clear-hidden"}`,
813
+ "aria-label": "Clear input",
814
+ "aria-hidden": !D,
815
+ tabIndex: -1,
816
+ onClick: (t) => {
817
+ var b;
818
+ t.stopPropagation(), W || y("");
819
+ const i = {
820
+ target: { value: "", name: e.name },
821
+ currentTarget: { value: "", name: e.name }
822
+ };
823
+ (b = e.onChange) == null || b.call(e, i), Y == null || Y(), z.current = 0, requestAnimationFrame(() => {
824
+ var g;
825
+ return (g = C.current) == null ? void 0 : g.focus();
826
+ });
827
+ },
828
+ onMouseDown: (t) => t.preventDefault(),
829
+ children: /* @__PURE__ */ a(
830
+ jn,
831
+ {
832
+ width: k(r),
833
+ height: k(r)
834
+ }
835
+ )
836
+ }
837
+ ) : null, kn = !D && !!e.placeholder && !!$, ln = /* @__PURE__ */ o("div", { className: "sa-tf-field-wrap", children: [
838
+ /* @__PURE__ */ a(
839
+ "input",
840
+ {
841
+ ...e,
842
+ id: sn.current,
843
+ ref: C,
844
+ className: "sa-tf-input",
845
+ disabled: v,
846
+ placeholder: $ ? "" : e.placeholder,
847
+ value: N,
848
+ onFocus: (t) => {
849
+ var i;
850
+ tn(!0), vn(!0), (i = e.onFocus) == null || i.call(e, t);
464
851
  },
465
- ref: $,
466
- onClick: Y,
467
- children: [
468
- u ? /* @__PURE__ */ c("div", { className: "starasia-input-container-addons-left", children: u }) : null,
469
- s ? /* @__PURE__ */ c("div", { className: "starasia-input-container-icon-left", children: B.cloneElement(s, {
470
- width: P(e),
471
- color: T(r.disabled ? "disable" : i),
472
- onClick: h,
473
- style: {
474
- color: `${T(
475
- r.disabled ? "disable" : i
476
- )}`
477
- }
478
- }) }) : null,
479
- /* @__PURE__ */ N("div", { className: "starasia-input-preview-container", children: [
480
- /* @__PURE__ */ c(
481
- "input",
482
- {
483
- className: "starasia-input",
484
- ...r,
485
- placeholder: "",
486
- disabled: i === "disable" ? !0 : r.disabled,
487
- ref: n,
488
- onChange: (t) => {
489
- let d = m ? z(t.target.value) : t.target.value;
490
- const l = t.target.selectionStart;
491
- if (m)
492
- if (H === "Backspace")
493
- if (typeof l == "number" && v[l] === ".") {
494
- let f = d.slice(0, l - 1), y = d.slice(
495
- l,
496
- d.length
497
- );
498
- d = z(f + y);
499
- const p = v.length - 1, I = d.length - 1;
500
- setTimeout(
501
- () => t.target.setSelectionRange(
502
- l - (p - I) < 0 ? 0 : l - (p - I),
503
- l - (p - I) < 0 ? 0 : l - (p - I)
504
- ),
505
- 0
506
- );
507
- } else {
508
- const f = v.length - 1, y = d.length - 1;
509
- let p = l + 1 - (f - y);
510
- setTimeout(
511
- () => t.target.setSelectionRange(
512
- p < 0 ? 0 : p,
513
- p < 0 ? 0 : p
514
- ),
515
- 0
516
- );
517
- }
518
- else {
519
- const f = v.length - 1, y = d.length - 1;
520
- setTimeout(
521
- () => t.target.setSelectionRange(
522
- l + (y - f) - 1,
523
- l + (y - f) - 1
524
- ),
525
- 0
526
- );
527
- }
528
- S(d), t.target.value ? L(!1) : L(!0), r.onChange && r.onChange({
529
- ...t,
530
- target: {
531
- ...t.target,
532
- value: m ? String(Z(d)) : d,
533
- name: t.target.name
534
- }
535
- }), R("");
536
- },
537
- value: v,
538
- onKeyDown: (t) => {
539
- t.key === "Backspace" && R(t.key), r.onKeyDown && r.onKeyDown(t);
540
- }
541
- }
542
- ),
543
- F ? _(r.placeholder, C) : null
544
- ] }),
545
- o ? /* @__PURE__ */ c("div", { className: "starasia-input-container-icon-right", children: B.cloneElement(o, {
546
- width: P(e),
547
- color: j(r.disabled ? "disable" : i),
548
- onClick: b,
549
- style: {
550
- color: `${j(
551
- r.disabled ? "disable" : i
552
- )}`
553
- }
554
- }) }) : null,
555
- g ? /* @__PURE__ */ c("div", { className: "starasia-input-container-addons-right", children: g }) : null,
556
- v && q && (E != null && E.length) ? /* @__PURE__ */ c(
557
- J,
558
- {
559
- options: E,
560
- value: v,
561
- setValue: S,
562
- ref: $,
563
- isComponentVisible: q,
564
- onOptionChange: K
565
- }
566
- ) : null
567
- ]
852
+ onBlur: (t) => {
853
+ var i;
854
+ tn(!1), (i = e.onBlur) == null || i.call(e, t);
855
+ },
856
+ onKeyDown: (t) => {
857
+ var i;
858
+ t.key === "Backspace" && en(t.key), (i = e.onKeyDown) == null || i.call(e, t);
859
+ },
860
+ onChange: zn
568
861
  }
569
- );
570
- }
862
+ ),
863
+ kn ? Wn(e.placeholder, $) : null
864
+ ] }), dn = N && an && (E != null && E.length) ? /* @__PURE__ */ a(
865
+ Fn,
866
+ {
867
+ options: E,
868
+ value: N,
869
+ setValue: y,
870
+ ref: M,
871
+ isComponentVisible: an,
872
+ onOptionChange: (t) => {
873
+ j == null || j(t), y(t);
874
+ }
875
+ }
876
+ ) : null, U = H ? /* @__PURE__ */ o(
877
+ "div",
878
+ {
879
+ className: "sa-tf-box",
880
+ ref: M,
881
+ onClick: yn,
882
+ children: [
883
+ L ? /* @__PURE__ */ a("div", { className: "sa-tf-addon sa-tf-addon-left", children: L }) : null,
884
+ /* @__PURE__ */ o("div", { className: "sa-tf-box-content", children: [
885
+ m ? F(m, Q) : null,
886
+ /* @__PURE__ */ o("div", { className: "sa-tf-inside-stack", children: [
887
+ K("sa-tf-inside-label-row"),
888
+ /* @__PURE__ */ a("div", { className: "sa-tf-inside-row", children: ln })
889
+ ] }),
890
+ on,
891
+ rn,
892
+ w ? F(w, Z) : null
893
+ ] }),
894
+ R ? /* @__PURE__ */ a("div", { className: "sa-tf-addon sa-tf-addon-right", children: R }) : null,
895
+ dn
896
+ ]
897
+ }
898
+ ) : /* @__PURE__ */ o("div", { className: "sa-tf-box", ref: M, children: [
899
+ L ? /* @__PURE__ */ a("div", { className: "sa-tf-addon sa-tf-addon-left", children: L }) : null,
900
+ /* @__PURE__ */ o("div", { className: "sa-tf-box-content", children: [
901
+ m ? F(m, Q) : null,
902
+ ln,
903
+ on,
904
+ rn,
905
+ w ? F(w, Z) : null
906
+ ] }),
907
+ R ? /* @__PURE__ */ a("div", { className: "sa-tf-addon sa-tf-addon-right", children: R }) : null,
908
+ dn
909
+ ] });
910
+ return x === "outside-left" ? /* @__PURE__ */ o("div", { className: q, children: [
911
+ /* @__PURE__ */ o("div", { className: "sa-tf-label-col", children: [
912
+ K("sa-tf-label"),
913
+ u ? /* @__PURE__ */ a("p", { className: "sa-tf-desc-top", children: u }) : null
914
+ ] }),
915
+ /* @__PURE__ */ o("div", { className: "sa-tf-input-col", children: [
916
+ U,
917
+ _
918
+ ] })
919
+ ] }) : H ? /* @__PURE__ */ o("div", { className: q, children: [
920
+ U,
921
+ _
922
+ ] }) : /* @__PURE__ */ o("div", { className: q, children: [
923
+ K("sa-tf-label"),
924
+ u ? /* @__PURE__ */ a("p", { className: "sa-tf-desc-top", children: u }) : null,
925
+ U,
926
+ _
927
+ ] });
571
928
  }
572
- ), _ = (a, n) => {
573
- if (!a || !n)
574
- return /* @__PURE__ */ c("p", { className: "starasia-input-placeholder", children: a || "" });
575
- const s = a.toLowerCase().indexOf(n.toLowerCase());
576
- return s === -1 ? /* @__PURE__ */ c("p", { className: "starasia-input-placeholder", children: a }) : /* @__PURE__ */ N("p", { className: "starasia-input-placeholder", children: [
577
- a.slice(0, s),
578
- /* @__PURE__ */ c("span", { className: "starasia-input-placeholder-highlighted", children: a.slice(s, s + n.length) }),
579
- a.slice(s + n.length)
929
+ ), Wn = (n, s) => {
930
+ if (!n)
931
+ return null;
932
+ if (!s)
933
+ return /* @__PURE__ */ a("p", { className: "sa-tf-placeholder", children: n });
934
+ const r = n.toLowerCase().indexOf(s.toLowerCase());
935
+ return r === -1 ? /* @__PURE__ */ a("p", { className: "sa-tf-placeholder", children: n }) : /* @__PURE__ */ o("p", { className: "sa-tf-placeholder", children: [
936
+ n.slice(0, r),
937
+ /* @__PURE__ */ a("span", { className: "sa-tf-placeholder-highlight", children: n.slice(r, r + s.length) }),
938
+ n.slice(r + s.length)
580
939
  ] });
581
940
  };
941
+ Yn.displayName = "Input";
582
942
  export {
583
- ra as Input
943
+ Yn as Input
584
944
  };