@starasia/input 1.0.4 → 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/README.md +272 -81
- package/dist/functions.d.ts +13 -3
- package/dist/input.es.js +824 -466
- package/dist/input.umd.js +473 -264
- package/dist/types.d.ts +22 -8
- package/package.json +1 -1
package/dist/input.es.js
CHANGED
|
@@ -1,367 +1,591 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
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
|
-
/*
|
|
12
|
-
--
|
|
13
|
-
--
|
|
14
|
-
--
|
|
15
|
-
--
|
|
16
|
-
--
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
--
|
|
21
|
-
--
|
|
22
|
-
|
|
23
|
-
--
|
|
24
|
-
--
|
|
25
|
-
|
|
26
|
-
--
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
--
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
--
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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-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
|
+
}
|
|
107
55
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
}
|
|
113
77
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
}
|
|
118
110
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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;
|
|
123
132
|
}
|
|
124
133
|
|
|
125
|
-
|
|
126
|
-
|
|
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);
|
|
127
144
|
overflow: hidden;
|
|
145
|
+
transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
|
|
146
|
+
}
|
|
147
|
+
.sa-tf-box-content {
|
|
128
148
|
display: flex;
|
|
129
149
|
align-items: center;
|
|
130
|
-
|
|
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);
|
|
131
154
|
}
|
|
132
155
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
156
|
+
/* sizes */
|
|
157
|
+
.sa-tf-size-sm .sa-tf-box {
|
|
158
|
+
min-height: 32px;
|
|
136
159
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
.starasia-input-container-icon-left {
|
|
140
|
-
background-color: var(--starasia-ui-input-color-disabled-bg);
|
|
160
|
+
.sa-tf-size-md .sa-tf-box {
|
|
161
|
+
min-height: 40px;
|
|
141
162
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
.starasia-input-container-icon-right {
|
|
145
|
-
background-color: var(--starasia-ui-input-color-disabled-bg);
|
|
163
|
+
.sa-tf-size-lg .sa-tf-box {
|
|
164
|
+
min-height: 48px;
|
|
146
165
|
}
|
|
147
|
-
|
|
148
|
-
|
|
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);
|
|
166
|
+
.sa-tf-size-xl .sa-tf-box {
|
|
167
|
+
min-height: 56px;
|
|
153
168
|
}
|
|
154
169
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
170
|
+
/* variants */
|
|
171
|
+
.sa-tf-variant-outline .sa-tf-box {
|
|
172
|
+
background: transparent;
|
|
173
|
+
border: 0.8px solid var(--sa-input-border-subtle);
|
|
159
174
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
border
|
|
175
|
+
.sa-tf-variant-standard .sa-tf-box {
|
|
176
|
+
background: var(--sa-input-bg-neutral);
|
|
177
|
+
border: 0.8px solid transparent;
|
|
163
178
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
border
|
|
167
|
-
|
|
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;
|
|
168
184
|
}
|
|
169
185
|
|
|
170
|
-
|
|
171
|
-
|
|
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;
|
|
172
191
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
border-
|
|
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;
|
|
176
195
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
border-
|
|
180
|
-
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;
|
|
181
199
|
}
|
|
182
200
|
|
|
183
|
-
|
|
184
|
-
|
|
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);
|
|
185
204
|
}
|
|
186
205
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
border-width:
|
|
191
|
-
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;
|
|
192
210
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
border-
|
|
196
|
-
border-style: solid;
|
|
197
|
-
border-color: var(--starasia-ui-input-color-quinary-gray);
|
|
198
|
-
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);
|
|
199
214
|
}
|
|
200
215
|
|
|
201
|
-
|
|
202
|
-
|
|
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;
|
|
203
219
|
}
|
|
204
|
-
|
|
205
|
-
|
|
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;
|
|
220
|
+
.sa-tf-variant-standard.sa-tf-status-error .sa-tf-box {
|
|
221
|
+
background: var(--sa-input-bg-error-subtlest);
|
|
210
222
|
}
|
|
211
|
-
|
|
212
|
-
.
|
|
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); */
|
|
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);
|
|
217
225
|
}
|
|
218
226
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
border-
|
|
222
|
-
|
|
223
|
-
|
|
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);
|
|
224
238
|
}
|
|
225
239
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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);
|
|
231
259
|
}
|
|
232
260
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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);
|
|
238
278
|
}
|
|
239
279
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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;
|
|
248
305
|
pointer-events: none;
|
|
306
|
+
cursor: default;
|
|
249
307
|
}
|
|
250
308
|
|
|
251
|
-
|
|
252
|
-
|
|
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;
|
|
253
321
|
}
|
|
254
|
-
|
|
255
|
-
.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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;
|
|
259
331
|
}
|
|
260
332
|
|
|
261
|
-
|
|
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 {
|
|
262
342
|
width: 100%;
|
|
263
|
-
|
|
264
|
-
height: 100%;
|
|
265
|
-
border: none;
|
|
343
|
+
border: 0;
|
|
266
344
|
outline: none;
|
|
267
|
-
font-family: "Poppins", serif;
|
|
268
|
-
font-size: inherit;
|
|
269
|
-
font-weight: var(--starasia-ui-fontWeights-medium, 400);
|
|
270
345
|
background: transparent;
|
|
271
|
-
|
|
272
|
-
|
|
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);
|
|
273
371
|
}
|
|
274
372
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
/* just icon */
|
|
279
|
-
|
|
280
|
-
/* INPUT ICON */
|
|
281
|
-
.starasia-input-container-icon-left {
|
|
373
|
+
.sa-tf-placeholder {
|
|
374
|
+
position: absolute;
|
|
375
|
+
inset: 0;
|
|
282
376
|
display: flex;
|
|
283
|
-
height: 100%;
|
|
284
377
|
align-items: center;
|
|
285
|
-
|
|
286
|
-
|
|
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;
|
|
287
395
|
}
|
|
288
396
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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 {
|
|
292
404
|
align-items: center;
|
|
293
|
-
|
|
294
|
-
background: transparent;
|
|
405
|
+
cursor: text;
|
|
295
406
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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;
|
|
303
414
|
align-items: center;
|
|
304
|
-
|
|
305
|
-
font-family: "Poppins", serif;
|
|
306
|
-
color: var(--starasia-ui-input-color-secondary-gray);
|
|
307
|
-
border-right: 1px solid var(--starasia-ui-color-border);
|
|
415
|
+
gap: var(--sa-input-gap);
|
|
308
416
|
}
|
|
309
417
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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 {
|
|
313
422
|
display: flex;
|
|
314
|
-
|
|
315
|
-
|
|
423
|
+
flex-direction: column;
|
|
424
|
+
flex: 1 1 0;
|
|
425
|
+
min-width: 0;
|
|
426
|
+
gap: 0;
|
|
316
427
|
justify-content: center;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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;
|
|
320
432
|
}
|
|
321
433
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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);
|
|
325
453
|
}
|
|
326
454
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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;
|
|
330
494
|
}
|
|
331
495
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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`;
|
|
349
573
|
}
|
|
350
574
|
};
|
|
351
|
-
return
|
|
352
|
-
window.removeEventListener("scroll",
|
|
353
|
-
}), [
|
|
354
|
-
|
|
355
|
-
}, [
|
|
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(() => {
|
|
356
580
|
V(
|
|
357
|
-
(
|
|
358
|
-
(h) => h.toLowerCase().startsWith(
|
|
581
|
+
(n == null ? void 0 : n.filter(
|
|
582
|
+
(h) => h.toLowerCase().startsWith(s.toLowerCase())
|
|
359
583
|
)) || []
|
|
360
584
|
);
|
|
361
|
-
}, [
|
|
585
|
+
}, [s, n]), /* @__PURE__ */ a(
|
|
362
586
|
"div",
|
|
363
587
|
{
|
|
364
|
-
ref:
|
|
588
|
+
ref: c,
|
|
365
589
|
style: {
|
|
366
590
|
position: "fixed",
|
|
367
591
|
padding: "8px",
|
|
@@ -372,15 +596,15 @@ const G = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@30
|
|
|
372
596
|
overflow: "auto",
|
|
373
597
|
zIndex: 5e4
|
|
374
598
|
},
|
|
375
|
-
children:
|
|
376
|
-
(h) =>
|
|
599
|
+
children: x == null ? void 0 : x.map(
|
|
600
|
+
(h) => On(h, s, r, d)
|
|
377
601
|
)
|
|
378
602
|
}
|
|
379
603
|
);
|
|
380
604
|
}
|
|
381
|
-
),
|
|
382
|
-
const
|
|
383
|
-
return /* @__PURE__ */
|
|
605
|
+
), On = (n, s, r, l) => {
|
|
606
|
+
const d = n.toLowerCase().indexOf(s.toLowerCase());
|
|
607
|
+
return /* @__PURE__ */ o(
|
|
384
608
|
"p",
|
|
385
609
|
{
|
|
386
610
|
style: {
|
|
@@ -391,194 +615,328 @@ const G = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@30
|
|
|
391
615
|
cursor: "pointer"
|
|
392
616
|
},
|
|
393
617
|
onClick: () => {
|
|
394
|
-
|
|
618
|
+
r(n), l && l(n);
|
|
395
619
|
},
|
|
396
620
|
children: [
|
|
397
|
-
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
|
|
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)
|
|
400
624
|
]
|
|
401
625
|
}
|
|
402
626
|
);
|
|
403
627
|
};
|
|
404
|
-
function
|
|
405
|
-
const [
|
|
406
|
-
|
|
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);
|
|
407
631
|
};
|
|
408
|
-
return
|
|
409
|
-
document.removeEventListener("click",
|
|
410
|
-
}), []), { ref:
|
|
411
|
-
}
|
|
412
|
-
const
|
|
413
|
-
if (!document.getElementById(
|
|
414
|
-
const
|
|
415
|
-
|
|
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);
|
|
416
640
|
}
|
|
417
641
|
};
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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) => {
|
|
427
686
|
const {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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,
|
|
441
706
|
options: E,
|
|
442
|
-
onOptionChange:
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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",
|
|
459
777
|
{
|
|
460
|
-
|
|
461
|
-
style: {
|
|
462
|
-
|
|
463
|
-
|
|
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",
|
|
838
|
+
{
|
|
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);
|
|
464
849
|
},
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
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
|
-
]
|
|
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
|
|
568
859
|
}
|
|
569
|
-
)
|
|
570
|
-
|
|
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
|
+
] });
|
|
571
926
|
}
|
|
572
|
-
),
|
|
573
|
-
if (!
|
|
574
|
-
return
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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)
|
|
580
937
|
] });
|
|
581
938
|
};
|
|
939
|
+
Yn.displayName = "Input";
|
|
582
940
|
export {
|
|
583
|
-
|
|
941
|
+
Yn as Input
|
|
584
942
|
};
|