@starasia/input 1.0.3 → 2.0.0

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