@stackone/malachite 2.112.0 → 2.113.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/COMPONENTS.md +4 -0
- package/dist/assets/icons/arrow_line_left.svg.js +6 -0
- package/dist/assets/icons/arrow_line_left.svg.js.map +1 -0
- package/dist/assets/icons/arrow_line_right.svg.js +6 -0
- package/dist/assets/icons/arrow_line_right.svg.js.map +1 -0
- package/dist/assets/icons/book.svg.js +6 -0
- package/dist/assets/icons/book.svg.js.map +1 -0
- package/dist/assets/icons/book_open.svg.js +6 -0
- package/dist/assets/icons/book_open.svg.js.map +1 -0
- package/dist/components/Accordion.js +66 -64
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/ActionMenu.js +97 -96
- package/dist/components/ActionMenu.js.map +1 -1
- package/dist/components/BannerButton.js +44 -0
- package/dist/components/BannerButton.js.map +1 -0
- package/dist/components/CopyButton.js +37 -0
- package/dist/components/CopyButton.js.map +1 -0
- package/dist/components/CustomIcons/ArrowLineLeftIcon.js +21 -0
- package/dist/components/CustomIcons/ArrowLineLeftIcon.js.map +1 -0
- package/dist/components/CustomIcons/ArrowLineRightIcon.js +21 -0
- package/dist/components/CustomIcons/ArrowLineRightIcon.js.map +1 -0
- package/dist/components/CustomIcons/BookIcon.js +16 -0
- package/dist/components/CustomIcons/BookIcon.js.map +1 -0
- package/dist/components/CustomIcons/BookOpenIcon.js +21 -0
- package/dist/components/CustomIcons/BookOpenIcon.js.map +1 -0
- package/dist/components/CustomIcons/index.js +363 -351
- package/dist/components/CustomIcons/index.js.map +1 -1
- package/dist/components/DividerToggle.js +68 -0
- package/dist/components/DividerToggle.js.map +1 -0
- package/dist/components/FormSteps.js +110 -0
- package/dist/components/FormSteps.js.map +1 -0
- package/dist/components/Input/Input.js +202 -178
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/KeyValueList.js +36 -35
- package/dist/components/KeyValueList.js.map +1 -1
- package/dist/components/actionMenuStyles.js +70 -51
- package/dist/components/actionMenuStyles.js.map +1 -1
- package/dist/components/chromeStyles.js +2 -3
- package/dist/components/chromeStyles.js.map +1 -1
- package/dist/index.d.ts +270 -116
- package/dist/index.js +451 -435
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/dist/theme.js +12 -9
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
4
|
-
import { Button as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { paintedFieldValue as
|
|
13
|
-
const
|
|
1
|
+
import { jsx as a, jsxs as m, Fragment as ie } from "react/jsx-runtime";
|
|
2
|
+
import { useState as V, useEffect as Ie, useRef as ye } from "react";
|
|
3
|
+
import Ne, { useFormFieldIds as Ce } from "../BaseFormComponent.js";
|
|
4
|
+
import { Button as le } from "../Button.js";
|
|
5
|
+
import { CopyButton as Ee } from "../CopyButton.js";
|
|
6
|
+
import ke from "../CustomIcons/EyeClosedIcon.js";
|
|
7
|
+
import Se from "../CustomIcons/EyeIcon.js";
|
|
8
|
+
import $e from "../CustomIcons/InfoIcon.js";
|
|
9
|
+
import { FieldMessage as je } from "../FieldMessage.js";
|
|
10
|
+
import ze from "../LoadingInput.js";
|
|
11
|
+
import Re from "../Tooltip.js";
|
|
12
|
+
import { paintedFieldValue as Te } from "../devWarning.js";
|
|
13
|
+
const ae = {
|
|
14
14
|
small: "h-[var(--malachite-control-height-small,28px)]",
|
|
15
15
|
medium: "h-[var(--malachite-control-height-medium,32px)]",
|
|
16
16
|
large: "h-[var(--malachite-control-height-large,42px)]"
|
|
17
|
-
},
|
|
17
|
+
}, te = {
|
|
18
18
|
small: "text-[length:var(--malachite-font-size-small,13px)]",
|
|
19
19
|
medium: "text-[length:var(--malachite-font-size-small,13px)]",
|
|
20
20
|
large: "text-[length:var(--malachite-font-size-15,15px)] leading-[1.4]"
|
|
21
|
-
},
|
|
21
|
+
}, re = {
|
|
22
22
|
small: "px-[10px]",
|
|
23
23
|
medium: "px-[10px]",
|
|
24
24
|
large: "px-[16px]"
|
|
25
|
-
},
|
|
25
|
+
}, Ve = {
|
|
26
26
|
small: "rounded-[var(--malachite-radius-10,10px)]",
|
|
27
27
|
medium: "rounded-xl",
|
|
28
28
|
large: "rounded-[var(--malachite-radius-xxl,14px)]"
|
|
29
|
-
}, Me = (
|
|
30
|
-
switch (
|
|
29
|
+
}, Me = (t, e) => {
|
|
30
|
+
switch (t) {
|
|
31
31
|
case "ghost":
|
|
32
32
|
return {
|
|
33
33
|
wrapper: [
|
|
@@ -49,205 +49,250 @@ const K = {
|
|
|
49
49
|
borderRadius: ""
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
},
|
|
53
|
-
label:
|
|
52
|
+
}, Le = ({
|
|
53
|
+
label: t,
|
|
54
54
|
hint: e,
|
|
55
55
|
hintIcon: i,
|
|
56
|
-
tooltip:
|
|
57
|
-
placeholder:
|
|
58
|
-
icon:
|
|
56
|
+
tooltip: N,
|
|
57
|
+
placeholder: f,
|
|
58
|
+
icon: x,
|
|
59
59
|
name: o,
|
|
60
60
|
required: h,
|
|
61
|
-
requiredIndicator:
|
|
62
|
-
error:
|
|
63
|
-
description:
|
|
64
|
-
loading:
|
|
65
|
-
readOnly:
|
|
66
|
-
type:
|
|
67
|
-
size:
|
|
68
|
-
variant:
|
|
69
|
-
defaultValue:
|
|
70
|
-
disabled:
|
|
71
|
-
prefixValue:
|
|
72
|
-
prefixSecondaryValue:
|
|
73
|
-
ellipsis:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"aria-
|
|
86
|
-
"aria-
|
|
61
|
+
requiredIndicator: C,
|
|
62
|
+
error: M,
|
|
63
|
+
description: Z,
|
|
64
|
+
loading: se = !1,
|
|
65
|
+
readOnly: b = !1,
|
|
66
|
+
type: p = "text",
|
|
67
|
+
size: l = "large",
|
|
68
|
+
variant: oe = "default",
|
|
69
|
+
defaultValue: _,
|
|
70
|
+
disabled: v,
|
|
71
|
+
prefixValue: A,
|
|
72
|
+
prefixSecondaryValue: D,
|
|
73
|
+
ellipsis: P = !1,
|
|
74
|
+
copyOnClick: de = !1,
|
|
75
|
+
formControl: G,
|
|
76
|
+
buttons: g,
|
|
77
|
+
onCopyClick: H,
|
|
78
|
+
showCopyButton: ce,
|
|
79
|
+
onChange: E,
|
|
80
|
+
value: ne,
|
|
81
|
+
onBlur: d,
|
|
82
|
+
helperText: w,
|
|
83
|
+
showPasswordToggle: k = !0,
|
|
84
|
+
id: me,
|
|
85
|
+
"aria-label": U,
|
|
86
|
+
"aria-labelledby": W,
|
|
87
|
+
"aria-describedby": he
|
|
87
88
|
}) => {
|
|
88
|
-
const { controlId:
|
|
89
|
-
id:
|
|
90
|
-
label:
|
|
91
|
-
description:
|
|
89
|
+
const { controlId: S, labelId: pe, descriptionId: X, hintId: q, helperTextId: $ } = Ce({
|
|
90
|
+
id: me,
|
|
91
|
+
label: t,
|
|
92
|
+
description: Z,
|
|
92
93
|
hint: e,
|
|
93
94
|
helperText: !0
|
|
94
|
-
}), [
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
|
|
95
|
+
}), [j, ve] = V(!1), [ue, fe] = V(_ || ""), [z, J] = V(!1);
|
|
96
|
+
Ie(() => {
|
|
97
|
+
if (z) {
|
|
98
|
+
const r = setTimeout(() => {
|
|
99
|
+
J(!1);
|
|
99
100
|
}, 1e3);
|
|
100
|
-
return () => clearTimeout(
|
|
101
|
+
return () => clearTimeout(r);
|
|
101
102
|
}
|
|
102
|
-
}, [
|
|
103
|
-
const
|
|
104
|
-
const c =
|
|
105
|
-
|
|
106
|
-
},
|
|
103
|
+
}, [z]);
|
|
104
|
+
const K = (r) => (s) => {
|
|
105
|
+
const c = s.target.value;
|
|
106
|
+
fe(c), E == null || E(c), r == null || r(c);
|
|
107
|
+
}, Q = ye(void 0), Y = (r) => Te({
|
|
107
108
|
component: "Input",
|
|
108
109
|
name: o,
|
|
109
|
-
value:
|
|
110
|
-
formValue:
|
|
111
|
-
defaultValue:
|
|
112
|
-
bound: !!
|
|
113
|
-
uncontrolledValue:
|
|
114
|
-
}),
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
} : void 0,
|
|
118
|
-
const
|
|
110
|
+
value: ne,
|
|
111
|
+
formValue: r,
|
|
112
|
+
defaultValue: _,
|
|
113
|
+
bound: !!G,
|
|
114
|
+
uncontrolledValue: ue
|
|
115
|
+
}), I = H ? () => {
|
|
116
|
+
const r = Y(Q.current);
|
|
117
|
+
r && (navigator.clipboard.writeText(r), J(!0), H());
|
|
118
|
+
} : void 0, L = p === "password" ? j ? "text" : "password" : p, xe = x || A || D, be = ae[l], ge = (r) => {
|
|
119
|
+
const s = Me(oe, r);
|
|
119
120
|
return [
|
|
120
121
|
"relative",
|
|
121
122
|
"flex items-center",
|
|
122
123
|
"w-full",
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
s.borderRadius || Ve[l],
|
|
125
|
+
v ? "bg-[var(--malachite-card-dimmed-background)]" : "bg-[var(--malachite-card-background)]",
|
|
125
126
|
"transition-colors duration-200 ease-in-out",
|
|
126
|
-
|
|
127
|
-
...
|
|
128
|
-
|
|
127
|
+
s.shadow,
|
|
128
|
+
...v ? [] : s.wrapper,
|
|
129
|
+
ae[l]
|
|
129
130
|
].filter(Boolean).join(" ");
|
|
130
131
|
};
|
|
131
132
|
return /* @__PURE__ */ a(
|
|
132
|
-
|
|
133
|
+
Ne,
|
|
133
134
|
{
|
|
134
|
-
label:
|
|
135
|
+
label: t,
|
|
135
136
|
hint: e,
|
|
136
137
|
hintIcon: i,
|
|
137
|
-
tooltip:
|
|
138
|
+
tooltip: N,
|
|
138
139
|
name: o,
|
|
139
140
|
required: h,
|
|
140
|
-
requiredIndicator:
|
|
141
|
-
loading:
|
|
142
|
-
formControl:
|
|
143
|
-
description:
|
|
144
|
-
controlId:
|
|
145
|
-
labelId:
|
|
146
|
-
descriptionId:
|
|
147
|
-
hintId:
|
|
141
|
+
requiredIndicator: C,
|
|
142
|
+
loading: se,
|
|
143
|
+
formControl: G,
|
|
144
|
+
description: Z,
|
|
145
|
+
controlId: S,
|
|
146
|
+
labelId: pe,
|
|
147
|
+
descriptionId: X,
|
|
148
|
+
hintId: q,
|
|
148
149
|
loadingComponent: /* @__PURE__ */ a(
|
|
149
|
-
|
|
150
|
+
ze,
|
|
150
151
|
{
|
|
151
|
-
heightClass:
|
|
152
|
-
helperText: !!
|
|
152
|
+
heightClass: be,
|
|
153
|
+
helperText: !!w,
|
|
153
154
|
helperTextMarginTop: !0
|
|
154
155
|
}
|
|
155
156
|
),
|
|
156
|
-
children: ({ error:
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
157
|
+
children: ({ error: r, message: s, onFieldChange: c, onFieldBlur: n, value: O }) => {
|
|
158
|
+
Q.current = O;
|
|
159
|
+
const u = Y(O), R = ce ?? !!(I && v && u), y = M ?? r, T = M === !1 ? void 0 : s, F = y && !T, we = F || R || (g == null ? void 0 : g.length) || p === "password" && k, B = `${$}-error`, ee = [
|
|
160
|
+
X,
|
|
161
|
+
q,
|
|
162
|
+
w ? $ : void 0,
|
|
163
|
+
T ? B : void 0,
|
|
164
|
+
he
|
|
164
165
|
].filter(Boolean).join(" ") || void 0;
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
return /* @__PURE__ */ m(ie, { children: [
|
|
167
|
+
/* @__PURE__ */ m("div", { className: ge(y), children: [
|
|
168
|
+
xe && /* @__PURE__ */ a("div", { className: "flex items-center pl-3 pr-1 flex-shrink-0 pointer-events-none", children: /* @__PURE__ */ a(
|
|
169
|
+
Ze,
|
|
169
170
|
{
|
|
170
|
-
prefixValue:
|
|
171
|
-
prefixSecondaryValue:
|
|
172
|
-
icon:
|
|
171
|
+
prefixValue: A,
|
|
172
|
+
prefixSecondaryValue: D,
|
|
173
|
+
icon: x
|
|
173
174
|
}
|
|
174
175
|
) }),
|
|
175
|
-
/* @__PURE__ */ a(
|
|
176
|
+
de && R && I ? /* @__PURE__ */ a(
|
|
177
|
+
Re,
|
|
178
|
+
{
|
|
179
|
+
text: u,
|
|
180
|
+
fill: !0,
|
|
181
|
+
triggerAs: "div",
|
|
182
|
+
describesTrigger: !1,
|
|
183
|
+
showOnFocus: !1,
|
|
184
|
+
children: /* @__PURE__ */ m("div", { className: "relative flex min-w-0 flex-1", children: [
|
|
185
|
+
/* @__PURE__ */ a(
|
|
186
|
+
"input",
|
|
187
|
+
{
|
|
188
|
+
id: S,
|
|
189
|
+
type: L,
|
|
190
|
+
placeholder: f,
|
|
191
|
+
value: u,
|
|
192
|
+
onChange: K(c),
|
|
193
|
+
onBlur: () => {
|
|
194
|
+
d == null || d(), n == null || n();
|
|
195
|
+
},
|
|
196
|
+
disabled: v || b,
|
|
197
|
+
readOnly: b,
|
|
198
|
+
autoComplete: "off",
|
|
199
|
+
"aria-label": U,
|
|
200
|
+
"aria-labelledby": W,
|
|
201
|
+
"aria-invalid": y || void 0,
|
|
202
|
+
"aria-required": h || void 0,
|
|
203
|
+
"aria-describedby": ee,
|
|
204
|
+
className: `flex-1 bg-transparent border-none outline-none text-[var(--malachite-text-primary)] placeholder:text-[var(--malachite-text-placeholder)] disabled:text-[var(--malachite-text-primary)] disabled:cursor-not-allowed ${te[l]} ${re[l]} ${P ? "min-w-0 truncate" : ""}`,
|
|
205
|
+
name: o
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
/* @__PURE__ */ a(
|
|
209
|
+
"button",
|
|
210
|
+
{
|
|
211
|
+
type: "button",
|
|
212
|
+
tabIndex: -1,
|
|
213
|
+
"aria-hidden": "true",
|
|
214
|
+
onClick: I,
|
|
215
|
+
className: "absolute inset-0 cursor-copy border-0 bg-transparent p-0"
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
] })
|
|
219
|
+
}
|
|
220
|
+
) : /* @__PURE__ */ a(
|
|
176
221
|
"input",
|
|
177
222
|
{
|
|
178
|
-
id:
|
|
179
|
-
type:
|
|
180
|
-
placeholder:
|
|
181
|
-
value:
|
|
182
|
-
onChange:
|
|
223
|
+
id: S,
|
|
224
|
+
type: L,
|
|
225
|
+
placeholder: f,
|
|
226
|
+
value: u,
|
|
227
|
+
onChange: K(c),
|
|
183
228
|
onBlur: () => {
|
|
184
|
-
|
|
229
|
+
d == null || d(), n == null || n();
|
|
185
230
|
},
|
|
186
|
-
disabled:
|
|
187
|
-
readOnly:
|
|
231
|
+
disabled: v || b,
|
|
232
|
+
readOnly: b,
|
|
188
233
|
autoComplete: "off",
|
|
189
|
-
"aria-label":
|
|
190
|
-
"aria-labelledby":
|
|
191
|
-
"aria-invalid":
|
|
234
|
+
"aria-label": U,
|
|
235
|
+
"aria-labelledby": W,
|
|
236
|
+
"aria-invalid": y || void 0,
|
|
192
237
|
"aria-required": h || void 0,
|
|
193
|
-
"aria-describedby":
|
|
194
|
-
className: `flex-1 bg-transparent border-none outline-none text-[var(--malachite-text-primary)] placeholder:text-[var(--malachite-text-placeholder)] disabled:text-[var(--malachite-text-primary)] disabled:cursor-not-allowed ${
|
|
238
|
+
"aria-describedby": ee,
|
|
239
|
+
className: `flex-1 bg-transparent border-none outline-none text-[var(--malachite-text-primary)] placeholder:text-[var(--malachite-text-placeholder)] disabled:text-[var(--malachite-text-primary)] disabled:cursor-not-allowed ${te[l]} ${re[l]} ${P ? "min-w-0 truncate" : ""}`,
|
|
195
240
|
name: o
|
|
196
241
|
}
|
|
197
242
|
),
|
|
198
|
-
|
|
243
|
+
we && /* @__PURE__ */ m(
|
|
199
244
|
"div",
|
|
200
245
|
{
|
|
201
|
-
className: `flex items-center pl-1 flex-shrink-0 ${
|
|
246
|
+
className: `flex items-center pl-1 flex-shrink-0 ${p === "password" && k ? "pr-0" : "pr-3"}`,
|
|
202
247
|
children: [
|
|
203
248
|
/* @__PURE__ */ a(
|
|
204
|
-
|
|
249
|
+
_e,
|
|
205
250
|
{
|
|
206
|
-
error:
|
|
207
|
-
defaultValue:
|
|
208
|
-
onCopyClick:
|
|
209
|
-
showCopyButton:
|
|
210
|
-
copied:
|
|
211
|
-
type:
|
|
212
|
-
showPassword:
|
|
213
|
-
showPasswordToggle:
|
|
214
|
-
onTogglePassword: () =>
|
|
251
|
+
error: F,
|
|
252
|
+
defaultValue: u,
|
|
253
|
+
onCopyClick: I,
|
|
254
|
+
showCopyButton: R,
|
|
255
|
+
copied: z,
|
|
256
|
+
type: p,
|
|
257
|
+
showPassword: j,
|
|
258
|
+
showPasswordToggle: k,
|
|
259
|
+
onTogglePassword: () => ve(!j)
|
|
215
260
|
}
|
|
216
261
|
),
|
|
217
|
-
/* @__PURE__ */ a(
|
|
262
|
+
/* @__PURE__ */ a(Ae, { buttons: g })
|
|
218
263
|
]
|
|
219
264
|
}
|
|
220
265
|
)
|
|
221
266
|
] }),
|
|
222
|
-
|
|
267
|
+
w && /* @__PURE__ */ a(
|
|
223
268
|
"div",
|
|
224
269
|
{
|
|
225
|
-
id:
|
|
226
|
-
className: "mt-1 text-[length:var(--malachite-font-size-small,13px)] text-left pl-2 text-[var(--malachite-text-dimmed,rgb(161,161,161))]",
|
|
227
|
-
children:
|
|
270
|
+
id: $,
|
|
271
|
+
className: "mt-1 text-[length:var(--malachite-font-size-small,13px)] text-left pl-2 text-[var(--malachite-text-dimmed,rgb(161,161,161))] [overflow-wrap:anywhere]",
|
|
272
|
+
children: w
|
|
228
273
|
}
|
|
229
274
|
),
|
|
230
|
-
/* @__PURE__ */ a(
|
|
275
|
+
/* @__PURE__ */ a(je, { id: B, message: T, spaced: !0 })
|
|
231
276
|
] });
|
|
232
277
|
}
|
|
233
278
|
}
|
|
234
279
|
);
|
|
235
|
-
},
|
|
280
|
+
}, Ze = ({ prefixValue: t, prefixSecondaryValue: e, icon: i }) => /* @__PURE__ */ m("div", { className: "flex items-center gap-1", children: [
|
|
236
281
|
i && /* @__PURE__ */ a("span", { className: "flex items-center justify-center text-[var(--malachite-text-dimmed)] w-4 h-4 flex-shrink-0", children: i }),
|
|
237
|
-
|
|
282
|
+
t && /* @__PURE__ */ a("span", { className: "text-[length:var(--malachite-font-size-medium,14px)] leading-[1.4] text-[var(--malachite-text-dimmed)] whitespace-nowrap", children: t }),
|
|
238
283
|
e && /* @__PURE__ */ a("span", { className: "text-[length:var(--malachite-font-size-medium,14px)] leading-[1.4] text-[var(--malachite-text-dimmed)] whitespace-nowrap", children: e })
|
|
239
|
-
] }),
|
|
240
|
-
error:
|
|
284
|
+
] }), _e = ({
|
|
285
|
+
error: t,
|
|
241
286
|
defaultValue: e,
|
|
242
287
|
onCopyClick: i,
|
|
243
|
-
showCopyButton:
|
|
244
|
-
copied:
|
|
245
|
-
type:
|
|
288
|
+
showCopyButton: N = !1,
|
|
289
|
+
copied: f = !1,
|
|
290
|
+
type: x,
|
|
246
291
|
showPassword: o,
|
|
247
292
|
showPasswordToggle: h = !0,
|
|
248
|
-
onTogglePassword:
|
|
249
|
-
}) => /* @__PURE__ */
|
|
250
|
-
|
|
293
|
+
onTogglePassword: C
|
|
294
|
+
}) => /* @__PURE__ */ m("div", { className: "flex items-center gap-1", children: [
|
|
295
|
+
t && // Decorative: the rejection is carried by the message beneath the field, so
|
|
251
296
|
// announcing an unnamed icon here would only repeat it as "info".
|
|
252
297
|
/* @__PURE__ */ a(
|
|
253
298
|
"div",
|
|
@@ -255,7 +300,7 @@ const K = {
|
|
|
255
300
|
"aria-hidden": "true",
|
|
256
301
|
className: "flex items-center justify-center w-5 h-5 flex-shrink-0",
|
|
257
302
|
children: /* @__PURE__ */ a(
|
|
258
|
-
|
|
303
|
+
$e,
|
|
259
304
|
{
|
|
260
305
|
size: 16,
|
|
261
306
|
className: "text-[var(--malachite-destructive-foreground,rgb(196,62,62))]"
|
|
@@ -263,37 +308,16 @@ const K = {
|
|
|
263
308
|
)
|
|
264
309
|
}
|
|
265
310
|
),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
{
|
|
269
|
-
onClick: i,
|
|
270
|
-
type: "button",
|
|
271
|
-
"aria-label": "Copy",
|
|
272
|
-
className: "flex items-center justify-center w-5 h-5 hover:bg-[var(--malachite-primary-border)] rounded transition-colors flex-shrink-0 cursor-pointer",
|
|
273
|
-
children: x ? /* @__PURE__ */ a(
|
|
274
|
-
ye,
|
|
275
|
-
{
|
|
276
|
-
size: 16,
|
|
277
|
-
style: { color: "var(--malachite-success-foreground)" }
|
|
278
|
-
}
|
|
279
|
-
) : /* @__PURE__ */ a(Ce, { size: 16 })
|
|
280
|
-
}
|
|
281
|
-
),
|
|
282
|
-
m === "password" && h && /* @__PURE__ */ a(Y, { variant: "no-style", onClick: g, type: "button", size: "small", children: o ? /* @__PURE__ */ a(
|
|
283
|
-
Ne,
|
|
284
|
-
{
|
|
285
|
-
size: 16,
|
|
286
|
-
style: { color: "var(--malachite-text-dimmed)" }
|
|
287
|
-
}
|
|
288
|
-
) : /* @__PURE__ */ a(
|
|
311
|
+
N && i && e && /* @__PURE__ */ a(Ee, { copied: f, onCopy: i }),
|
|
312
|
+
x === "password" && h && /* @__PURE__ */ a(le, { variant: "no-style", onClick: C, type: "button", size: "small", children: o ? /* @__PURE__ */ a(
|
|
289
313
|
ke,
|
|
290
314
|
{
|
|
291
315
|
size: 16,
|
|
292
316
|
style: { color: "var(--malachite-text-dimmed)" }
|
|
293
317
|
}
|
|
294
|
-
) })
|
|
295
|
-
] }),
|
|
296
|
-
|
|
318
|
+
) : /* @__PURE__ */ a(Se, { size: 16, style: { color: "var(--malachite-text-dimmed)" } }) })
|
|
319
|
+
] }), Ae = ({ buttons: t }) => t != null && t.length ? /* @__PURE__ */ a(ie, { children: t.map((e) => /* @__PURE__ */ a(
|
|
320
|
+
le,
|
|
297
321
|
{
|
|
298
322
|
variant: e.variant || (e.danger ? "destructive" : "outline"),
|
|
299
323
|
size: e.size || "small",
|
|
@@ -307,6 +331,6 @@ const K = {
|
|
|
307
331
|
e.label
|
|
308
332
|
)) }) : null;
|
|
309
333
|
export {
|
|
310
|
-
|
|
334
|
+
Le as default
|
|
311
335
|
};
|
|
312
336
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sources":["../../../src/components/Input/Input.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport type { Control, FieldPath, FieldValues } from 'react-hook-form';\nimport BaseFormComponent, { type RequiredIndicator, useFormFieldIds } from '../BaseFormComponent';\nimport { Button } from '../Button';\nimport CheckCircleFilled from '../CustomIcons/CheckCircleFilled';\nimport CopyIcon from '../CustomIcons/CopyIcon';\nimport EyeClosedIcon from '../CustomIcons/EyeClosedIcon';\nimport EyeIcon from '../CustomIcons/EyeIcon';\nimport InfoIcon from '../CustomIcons/InfoIcon';\nimport FieldMessage from '../FieldMessage';\nimport LoadingInput from '../LoadingInput';\nimport { paintedFieldValue } from '../devWarning';\nimport type { ButtonDefinition, InputSize, InputType, InputVariant } from './types';\n\ninterface InputProps {\n label?: string;\n hint?: string;\n /** Decorative icon drawn before `hint`, such as a glyph for the value's type. Shown only with a `hint`. */\n hintIcon?: React.ReactNode;\n tooltip?: string;\n placeholder?: string;\n icon?: React.ReactNode;\n readOnly?: boolean;\n name: FieldPath<FieldValues> | string;\n type?: InputType;\n description?: string;\n size?: InputSize;\n variant?: InputVariant;\n required?: boolean;\n requiredIndicator?: RequiredIndicator;\n error?: boolean;\n loading?: boolean;\n defaultValue?: string;\n disabled?: boolean;\n prefixValue?: string;\n prefixSecondaryValue?: string;\n ellipsis?: boolean;\n formControl?: Control<FieldValues, unknown>;\n buttons?: ButtonDefinition[];\n onCopyClick?: () => void;\n showCopyButton?: boolean;\n onChange?: (value: string) => void;\n /** Controlled value, for a source of truth outside the form (URL, app state). */\n value?: string;\n onBlur?: () => void;\n helperText?: React.ReactNode;\n showPasswordToggle?: boolean;\n id?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n}\n\n// Figma specs one Input, at 42px / px-16 / 15px / radius 14 — the large tier. The smaller\n// tiers have no Input master, so they follow Search, which shares the field chrome.\nconst SIZE_HEIGHT: Record<InputSize, string> = {\n small: 'h-[var(--malachite-control-height-small,28px)]',\n medium: 'h-[var(--malachite-control-height-medium,32px)]',\n large: 'h-[var(--malachite-control-height-large,42px)]',\n};\n\nconst SIZE_TEXT: Record<InputSize, string> = {\n small: 'text-[length:var(--malachite-font-size-small,13px)]',\n medium: 'text-[length:var(--malachite-font-size-small,13px)]',\n large: 'text-[length:var(--malachite-font-size-15,15px)] leading-[1.4]',\n};\n\nconst SIZE_PADDING: Record<InputSize, string> = {\n small: 'px-[10px]',\n medium: 'px-[10px]',\n large: 'px-[16px]',\n};\n\nconst SIZE_RADIUS: Record<InputSize, string> = {\n small: 'rounded-[var(--malachite-radius-10,10px)]',\n medium: 'rounded-xl',\n large: 'rounded-[var(--malachite-radius-xxl,14px)]',\n};\n\nconst getVariantClasses = (\n variant: InputVariant,\n error?: boolean,\n): {\n wrapper: string[];\n shadow: string;\n borderRadius: string;\n} => {\n switch (variant) {\n case 'ghost':\n return {\n wrapper: [\n error\n ? 'border-0 border-b border-solid border-[var(--malachite-destructive-border)]'\n : '',\n error\n ? 'focus-within:border-[var(--malachite-destructive-border-hover)] hover:border-[var(--malachite-destructive-border-hover)]'\n : '',\n ],\n shadow: 'shadow-none',\n borderRadius: 'rounded-none',\n };\n case 'default':\n default:\n return {\n wrapper: [\n 'border border-solid',\n error\n ? 'border-[var(--malachite-destructive-border)]'\n : 'border-[var(--malachite-card-border)]',\n error\n ? 'focus-within:border-[var(--malachite-destructive-border-hover)] hover:border-[var(--malachite-destructive-border-hover)]'\n : 'focus-within:border-[var(--malachite-control-border-hover)] hover:border-[var(--malachite-control-border-hover)]',\n ],\n shadow: error ? 'shadow-error' : 'shadow-default',\n borderRadius: '',\n };\n }\n};\n\nconst Input: React.FC<InputProps> = ({\n label,\n hint,\n hintIcon,\n tooltip,\n placeholder,\n icon,\n name,\n required,\n requiredIndicator,\n error,\n description,\n loading = false,\n readOnly = false,\n type = 'text',\n size = 'large',\n variant = 'default',\n defaultValue,\n disabled,\n prefixValue,\n prefixSecondaryValue,\n ellipsis = false,\n formControl,\n buttons,\n onCopyClick,\n showCopyButton,\n onChange,\n value,\n onBlur,\n helperText,\n showPasswordToggle = true,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n}) => {\n const { controlId, labelId, descriptionId, hintId, helperTextId } = useFormFieldIds({\n id,\n label,\n description,\n hint,\n helperText: true,\n });\n const [showPassword, setShowPassword] = useState(false);\n const [inputValue, setInputValue] = useState(defaultValue || '');\n const [copied, setCopied] = useState(false);\n\n useEffect(() => {\n if (copied) {\n const timer = setTimeout(() => {\n setCopied(false);\n }, 1000);\n return () => clearTimeout(timer);\n }\n }, [copied]);\n\n const handleChange =\n (reportToForm?: (value: unknown) => void) => (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n setInputValue(newValue);\n onChange?.(newValue);\n reportToForm?.(newValue);\n };\n\n const formValueRef = useRef<unknown>(undefined);\n const paintedValue = (formValue: unknown): string =>\n paintedFieldValue({\n component: 'Input',\n name,\n value,\n formValue,\n defaultValue,\n bound: !!formControl,\n uncontrolledValue: inputValue,\n });\n\n const handleCopyClick = onCopyClick\n ? () => {\n const copyValue = paintedValue(formValueRef.current);\n if (copyValue) {\n navigator.clipboard.writeText(copyValue);\n setCopied(true);\n onCopyClick();\n }\n }\n : undefined;\n\n const actualInputType = type === 'password' ? (showPassword ? 'text' : 'password') : type;\n\n const hasPrefix = icon || prefixValue || prefixSecondaryValue;\n\n // The skeleton stands in for the field, so it reads the same height the wrapper does.\n const heightClass = SIZE_HEIGHT[size];\n\n const buildWrapperClasses = (isError: boolean): string => {\n const variantStyles = getVariantClasses(variant, isError);\n\n return [\n 'relative',\n 'flex items-center',\n 'w-full',\n variantStyles.borderRadius || SIZE_RADIUS[size],\n disabled\n ? 'bg-[var(--malachite-card-dimmed-background)]'\n : 'bg-[var(--malachite-card-background)]',\n 'transition-colors duration-200 ease-in-out',\n variantStyles.shadow,\n ...(disabled ? [] : variantStyles.wrapper),\n SIZE_HEIGHT[size],\n ]\n .filter(Boolean)\n .join(' ');\n };\n\n return (\n <BaseFormComponent\n label={label}\n hint={hint}\n hintIcon={hintIcon}\n tooltip={tooltip}\n name={name}\n required={required}\n requiredIndicator={requiredIndicator}\n loading={loading}\n formControl={formControl}\n description={description}\n controlId={controlId}\n labelId={labelId}\n descriptionId={descriptionId}\n hintId={hintId}\n loadingComponent={\n <LoadingInput\n heightClass={heightClass}\n helperText={!!helperText}\n helperTextMarginTop\n />\n }\n >\n {({ error: fieldError, message, onFieldChange, onFieldBlur, value: formValue }) => {\n formValueRef.current = formValue;\n const displayValue = paintedValue(formValue);\n const shouldShowCopyButton =\n showCopyButton ?? !!(handleCopyClick && disabled && displayValue);\n const isError = error ?? fieldError;\n // `error={false}` opts out of the resolver entirely, message included: a\n // screen that has dealt with the rejection its own way would otherwise keep\n // reporting it in destructive text and through `aria-describedby`.\n // The message is its own line rather than a replacement for the helper text:\n // a field that explains where to find its value still has to say why what was\n // typed was rejected, and dropping one for the other left the field marked red\n // with nothing anywhere saying what was wrong.\n const errorMessage = error === false ? undefined : message;\n // The icon is the only signal a consumer-forced `error` has; beside a message it\n // is duplication, and it crowds the suffix next to a reveal or copy control.\n const showErrorIcon = isError && !errorMessage;\n const hasSuffix =\n showErrorIcon ||\n shouldShowCopyButton ||\n buttons?.length ||\n (type === 'password' && showPasswordToggle);\n const errorMessageId = `${helperTextId}-error`;\n const describedBy =\n [\n descriptionId,\n hintId,\n helperText ? helperTextId : undefined,\n errorMessage ? errorMessageId : undefined,\n ariaDescribedBy,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n\n return (\n <>\n <div className={buildWrapperClasses(isError)}>\n {hasPrefix && (\n <div className=\"flex items-center pl-3 pr-1 flex-shrink-0 pointer-events-none\">\n <CompositeIcon\n prefixValue={prefixValue}\n prefixSecondaryValue={prefixSecondaryValue}\n icon={icon}\n />\n </div>\n )}\n\n <input\n id={controlId}\n type={actualInputType}\n placeholder={placeholder}\n value={displayValue}\n onChange={handleChange(onFieldChange)}\n onBlur={() => {\n onBlur?.();\n onFieldBlur?.();\n }}\n disabled={disabled || readOnly}\n readOnly={readOnly}\n autoComplete=\"off\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={isError || undefined}\n aria-required={required || undefined}\n aria-describedby={describedBy}\n className={`flex-1 bg-transparent border-none outline-none text-[var(--malachite-text-primary)] placeholder:text-[var(--malachite-text-placeholder)] disabled:text-[var(--malachite-text-primary)] disabled:cursor-not-allowed ${SIZE_TEXT[size]} ${SIZE_PADDING[size]} ${ellipsis ? 'min-w-0 truncate' : ''}`}\n name={name}\n />\n\n {hasSuffix && (\n <div\n className={`flex items-center pl-1 flex-shrink-0 ${type === 'password' && showPasswordToggle ? 'pr-0' : 'pr-3'}`}\n >\n <Suffix\n error={showErrorIcon}\n defaultValue={displayValue}\n onCopyClick={handleCopyClick}\n showCopyButton={shouldShowCopyButton}\n copied={copied}\n type={type}\n showPassword={showPassword}\n showPasswordToggle={showPasswordToggle}\n onTogglePassword={() => setShowPassword(!showPassword)}\n />\n <InputButtons buttons={buttons} />\n </div>\n )}\n </div>\n {helperText && (\n <div\n id={helperTextId}\n className=\"mt-1 text-[length:var(--malachite-font-size-small,13px)] text-left pl-2 text-[var(--malachite-text-dimmed,rgb(161,161,161))]\"\n >\n {helperText}\n </div>\n )}\n <FieldMessage id={errorMessageId} message={errorMessage} spaced />\n </>\n );\n }}\n </BaseFormComponent>\n );\n};\n\nconst CompositeIcon: React.FC<{\n prefixValue?: string;\n prefixSecondaryValue?: string;\n icon?: React.ReactNode;\n}> = ({ prefixValue, prefixSecondaryValue, icon }) => {\n return (\n <div className=\"flex items-center gap-1\">\n {icon && (\n <span className=\"flex items-center justify-center text-[var(--malachite-text-dimmed)] w-4 h-4 flex-shrink-0\">\n {icon}\n </span>\n )}\n {prefixValue && (\n <span className=\"text-[length:var(--malachite-font-size-medium,14px)] leading-[1.4] text-[var(--malachite-text-dimmed)] whitespace-nowrap\">\n {prefixValue}\n </span>\n )}\n {prefixSecondaryValue && (\n <span className=\"text-[length:var(--malachite-font-size-medium,14px)] leading-[1.4] text-[var(--malachite-text-dimmed)] whitespace-nowrap\">\n {prefixSecondaryValue}\n </span>\n )}\n </div>\n );\n};\n\nconst Suffix: React.FC<{\n error?: boolean;\n defaultValue?: string;\n onCopyClick?: () => void;\n showCopyButton?: boolean;\n copied?: boolean;\n type?: InputType;\n showPassword?: boolean;\n showPasswordToggle?: boolean;\n onTogglePassword?: () => void;\n}> = ({\n error,\n defaultValue,\n onCopyClick,\n showCopyButton = false,\n copied = false,\n type,\n showPassword,\n showPasswordToggle = true,\n onTogglePassword,\n}) => {\n return (\n <div className=\"flex items-center gap-1\">\n {error && (\n // Decorative: the rejection is carried by the message beneath the field, so\n // announcing an unnamed icon here would only repeat it as \"info\".\n <div\n aria-hidden=\"true\"\n className=\"flex items-center justify-center w-5 h-5 flex-shrink-0\"\n >\n <InfoIcon\n size={16}\n className=\"text-[var(--malachite-destructive-foreground,rgb(196,62,62))]\"\n />\n </div>\n )}\n {showCopyButton && onCopyClick && defaultValue && (\n <button\n onClick={onCopyClick}\n type=\"button\"\n aria-label=\"Copy\"\n className=\"flex items-center justify-center w-5 h-5 hover:bg-[var(--malachite-primary-border)] rounded transition-colors flex-shrink-0 cursor-pointer\"\n >\n {copied ? (\n <CheckCircleFilled\n size={16}\n style={{ color: 'var(--malachite-success-foreground)' }}\n />\n ) : (\n <CopyIcon size={16} />\n )}\n </button>\n )}\n {type === 'password' && showPasswordToggle && (\n <Button variant=\"no-style\" onClick={onTogglePassword} type=\"button\" size=\"small\">\n {showPassword ? (\n <EyeClosedIcon\n size={16}\n style={{ color: 'var(--malachite-text-dimmed)' }}\n />\n ) : (\n <EyeIcon\n size={16}\n style={{ color: 'var(--malachite-text-dimmed)' }}\n />\n )}\n </Button>\n )}\n </div>\n );\n};\n\nconst InputButtons: React.FC<{\n buttons?: ButtonDefinition[];\n}> = ({ buttons }) => {\n if (!buttons?.length) {\n return null;\n }\n\n return (\n <>\n {buttons.map((button) => (\n <Button\n key={button.label}\n variant={button.variant || (button.danger ? 'destructive' : 'outline')}\n size={button.size || 'small'}\n disabled={button.disabled}\n icon={button.icon}\n tooltip={button.tooltip}\n onClick={button.onClick}\n className=\"ml-1\"\n >\n {button.label}\n </Button>\n ))}\n </>\n );\n};\n\nexport default Input;\n"],"names":["SIZE_HEIGHT","SIZE_TEXT","SIZE_PADDING","SIZE_RADIUS","getVariantClasses","variant","error","Input","label","hint","hintIcon","tooltip","placeholder","icon","name","required","requiredIndicator","description","loading","readOnly","type","size","defaultValue","disabled","prefixValue","prefixSecondaryValue","ellipsis","formControl","buttons","onCopyClick","showCopyButton","onChange","value","onBlur","helperText","showPasswordToggle","id","ariaLabel","ariaLabelledBy","ariaDescribedBy","controlId","labelId","descriptionId","hintId","helperTextId","useFormFieldIds","showPassword","setShowPassword","useState","inputValue","setInputValue","copied","setCopied","useEffect","timer","handleChange","reportToForm","e","newValue","formValueRef","useRef","paintedValue","formValue","paintedFieldValue","handleCopyClick","copyValue","actualInputType","hasPrefix","heightClass","buildWrapperClasses","isError","variantStyles","jsx","BaseFormComponent","LoadingInput","fieldError","message","onFieldChange","onFieldBlur","displayValue","shouldShowCopyButton","errorMessage","showErrorIcon","hasSuffix","errorMessageId","describedBy","jsxs","Fragment","CompositeIcon","Suffix","InputButtons","FieldMessage","onTogglePassword","InfoIcon","CheckCircleFilled","CopyIcon","Button","EyeClosedIcon","EyeIcon","button"],"mappings":";;;;;;;;;;;;AAuDA,MAAMA,IAAyC;AAAA,EAC3C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAAuC;AAAA,EACzC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAA0C;AAAA,EAC5C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAAyC;AAAA,EAC3C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAAoB,CACtBC,GACAC,MAKC;AACD,UAAQD,GAAA;AAAA,IACJ,KAAK;AACD,aAAO;AAAA,QACH,SAAS;AAAA,UACLC,IACM,iFACA;AAAA,UACNA,IACM,6HACA;AAAA,QAAA;AAAA,QAEV,QAAQ;AAAA,QACR,cAAc;AAAA,MAAA;AAAA,IAEtB,KAAK;AAAA,IACL;AACI,aAAO;AAAA,QACH,SAAS;AAAA,UACL;AAAA,UACAA,IACM,iDACA;AAAA,UACNA,IACM,6HACA;AAAA,QAAA;AAAA,QAEV,QAAQA,IAAQ,iBAAiB;AAAA,QACjC,cAAc;AAAA,MAAA;AAAA,EAClB;AAEZ,GAEMC,KAA8B,CAAC;AAAA,EACjC,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,OAAAV;AAAA,EACA,aAAAW;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA,EACP,MAAAC,IAAO;AAAA,EACP,SAAAhB,IAAU;AAAA,EACV,cAAAiB;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,E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,EACnD,CAER;AAAA,GAER,GAIFR,KAED,CAAC,EAAE,SAAA9D,QACCA,KAAA,QAAAA,EAAS,SAKV,gBAAA4C,EAAAe,GAAA,EACK,UAAA3D,EAAQ,IAAI,CAACuE,MACV,gBAAA3B;AAAA,EAACwB;AAAA,EAAA;AAAA,IAEG,SAASG,EAAO,YAAYA,EAAO,SAAS,gBAAgB;AAAA,IAC5D,MAAMA,EAAO,QAAQ;AAAA,IACrB,UAAUA,EAAO;AAAA,IACjB,MAAMA,EAAO;AAAA,IACb,SAASA,EAAO;AAAA,IAChB,SAASA,EAAO;AAAA,IAChB,WAAU;AAAA,IAET,UAAAA,EAAO;AAAA,EAAA;AAAA,EATHA,EAAO;AAAA,CAWnB,GACL,IAnBO;"}
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../../src/components/Input/Input.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport type { Control, FieldPath, FieldValues } from 'react-hook-form';\nimport BaseFormComponent, { type RequiredIndicator, useFormFieldIds } from '../BaseFormComponent';\nimport { Button } from '../Button';\nimport CopyButton from '../CopyButton';\nimport EyeClosedIcon from '../CustomIcons/EyeClosedIcon';\nimport EyeIcon from '../CustomIcons/EyeIcon';\nimport InfoIcon from '../CustomIcons/InfoIcon';\nimport FieldMessage from '../FieldMessage';\nimport LoadingInput from '../LoadingInput';\nimport Tooltip from '../Tooltip';\nimport { paintedFieldValue } from '../devWarning';\nimport type { ButtonDefinition, InputSize, InputType, InputVariant } from './types';\n\ninterface InputProps {\n label?: string;\n hint?: string;\n /** Decorative icon drawn before `hint`, such as a glyph for the value's type. Shown only with a `hint`. */\n hintIcon?: React.ReactNode;\n tooltip?: string;\n placeholder?: string;\n icon?: React.ReactNode;\n readOnly?: boolean;\n name: FieldPath<FieldValues> | string;\n type?: InputType;\n description?: string;\n size?: InputSize;\n variant?: InputVariant;\n required?: boolean;\n requiredIndicator?: RequiredIndicator;\n error?: boolean;\n loading?: boolean;\n defaultValue?: string;\n disabled?: boolean;\n prefixValue?: string;\n prefixSecondaryValue?: string;\n ellipsis?: boolean;\n /**\n * For a value shown to copy (`showCopyButton` with `onCopyClick`): a click anywhere on the\n * value copies it too, under a copy cursor, and hovering shows the whole value. The copy\n * button stays the keyboard's way to copy.\n */\n copyOnClick?: boolean;\n formControl?: Control<FieldValues, unknown>;\n buttons?: ButtonDefinition[];\n onCopyClick?: () => void;\n showCopyButton?: boolean;\n onChange?: (value: string) => void;\n /** Controlled value, for a source of truth outside the form (URL, app state). */\n value?: string;\n onBlur?: () => void;\n helperText?: React.ReactNode;\n showPasswordToggle?: boolean;\n id?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n}\n\n// Figma specs one Input, at 42px / px-16 / 15px / radius 14 — the large tier. The smaller\n// tiers have no Input master, so they follow Search, which shares the field chrome.\nconst SIZE_HEIGHT: Record<InputSize, string> = {\n small: 'h-[var(--malachite-control-height-small,28px)]',\n medium: 'h-[var(--malachite-control-height-medium,32px)]',\n large: 'h-[var(--malachite-control-height-large,42px)]',\n};\n\nconst SIZE_TEXT: Record<InputSize, string> = {\n small: 'text-[length:var(--malachite-font-size-small,13px)]',\n medium: 'text-[length:var(--malachite-font-size-small,13px)]',\n large: 'text-[length:var(--malachite-font-size-15,15px)] leading-[1.4]',\n};\n\nconst SIZE_PADDING: Record<InputSize, string> = {\n small: 'px-[10px]',\n medium: 'px-[10px]',\n large: 'px-[16px]',\n};\n\nconst SIZE_RADIUS: Record<InputSize, string> = {\n small: 'rounded-[var(--malachite-radius-10,10px)]',\n medium: 'rounded-xl',\n large: 'rounded-[var(--malachite-radius-xxl,14px)]',\n};\n\nconst getVariantClasses = (\n variant: InputVariant,\n error?: boolean,\n): {\n wrapper: string[];\n shadow: string;\n borderRadius: string;\n} => {\n switch (variant) {\n case 'ghost':\n return {\n wrapper: [\n error\n ? 'border-0 border-b border-solid border-[var(--malachite-destructive-border)]'\n : '',\n error\n ? 'focus-within:border-[var(--malachite-destructive-border-hover)] hover:border-[var(--malachite-destructive-border-hover)]'\n : '',\n ],\n shadow: 'shadow-none',\n borderRadius: 'rounded-none',\n };\n case 'default':\n default:\n return {\n wrapper: [\n 'border border-solid',\n error\n ? 'border-[var(--malachite-destructive-border)]'\n : 'border-[var(--malachite-card-border)]',\n error\n ? 'focus-within:border-[var(--malachite-destructive-border-hover)] hover:border-[var(--malachite-destructive-border-hover)]'\n : 'focus-within:border-[var(--malachite-control-border-hover)] hover:border-[var(--malachite-control-border-hover)]',\n ],\n shadow: error ? 'shadow-error' : 'shadow-default',\n borderRadius: '',\n };\n }\n};\n\nconst Input: React.FC<InputProps> = ({\n label,\n hint,\n hintIcon,\n tooltip,\n placeholder,\n icon,\n name,\n required,\n requiredIndicator,\n error,\n description,\n loading = false,\n readOnly = false,\n type = 'text',\n size = 'large',\n variant = 'default',\n defaultValue,\n disabled,\n prefixValue,\n prefixSecondaryValue,\n ellipsis = false,\n copyOnClick = false,\n formControl,\n buttons,\n onCopyClick,\n showCopyButton,\n onChange,\n value,\n onBlur,\n helperText,\n showPasswordToggle = true,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n}) => {\n const { controlId, labelId, descriptionId, hintId, helperTextId } = useFormFieldIds({\n id,\n label,\n description,\n hint,\n helperText: true,\n });\n const [showPassword, setShowPassword] = useState(false);\n const [inputValue, setInputValue] = useState(defaultValue || '');\n const [copied, setCopied] = useState(false);\n\n useEffect(() => {\n if (copied) {\n const timer = setTimeout(() => {\n setCopied(false);\n }, 1000);\n return () => clearTimeout(timer);\n }\n }, [copied]);\n\n const handleChange =\n (reportToForm?: (value: unknown) => void) => (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n setInputValue(newValue);\n onChange?.(newValue);\n reportToForm?.(newValue);\n };\n\n const formValueRef = useRef<unknown>(undefined);\n const paintedValue = (formValue: unknown): string =>\n paintedFieldValue({\n component: 'Input',\n name,\n value,\n formValue,\n defaultValue,\n bound: !!formControl,\n uncontrolledValue: inputValue,\n });\n\n const handleCopyClick = onCopyClick\n ? () => {\n const copyValue = paintedValue(formValueRef.current);\n if (copyValue) {\n navigator.clipboard.writeText(copyValue);\n setCopied(true);\n onCopyClick();\n }\n }\n : undefined;\n\n const actualInputType = type === 'password' ? (showPassword ? 'text' : 'password') : type;\n\n const hasPrefix = icon || prefixValue || prefixSecondaryValue;\n\n // The skeleton stands in for the field, so it reads the same height the wrapper does.\n const heightClass = SIZE_HEIGHT[size];\n\n const buildWrapperClasses = (isError: boolean): string => {\n const variantStyles = getVariantClasses(variant, isError);\n\n return [\n 'relative',\n 'flex items-center',\n 'w-full',\n variantStyles.borderRadius || SIZE_RADIUS[size],\n disabled\n ? 'bg-[var(--malachite-card-dimmed-background)]'\n : 'bg-[var(--malachite-card-background)]',\n 'transition-colors duration-200 ease-in-out',\n variantStyles.shadow,\n ...(disabled ? [] : variantStyles.wrapper),\n SIZE_HEIGHT[size],\n ]\n .filter(Boolean)\n .join(' ');\n };\n\n return (\n <BaseFormComponent\n label={label}\n hint={hint}\n hintIcon={hintIcon}\n tooltip={tooltip}\n name={name}\n required={required}\n requiredIndicator={requiredIndicator}\n loading={loading}\n formControl={formControl}\n description={description}\n controlId={controlId}\n labelId={labelId}\n descriptionId={descriptionId}\n hintId={hintId}\n loadingComponent={\n <LoadingInput\n heightClass={heightClass}\n helperText={!!helperText}\n helperTextMarginTop\n />\n }\n >\n {({ error: fieldError, message, onFieldChange, onFieldBlur, value: formValue }) => {\n formValueRef.current = formValue;\n const displayValue = paintedValue(formValue);\n const shouldShowCopyButton =\n showCopyButton ?? !!(handleCopyClick && disabled && displayValue);\n const isError = error ?? fieldError;\n // `error={false}` opts out of the resolver entirely, message included: a\n // screen that has dealt with the rejection its own way would otherwise keep\n // reporting it in destructive text and through `aria-describedby`.\n // The message is its own line rather than a replacement for the helper text:\n // a field that explains where to find its value still has to say why what was\n // typed was rejected, and dropping one for the other left the field marked red\n // with nothing anywhere saying what was wrong.\n const errorMessage = error === false ? undefined : message;\n // The icon is the only signal a consumer-forced `error` has; beside a message it\n // is duplication, and it crowds the suffix next to a reveal or copy control.\n const showErrorIcon = isError && !errorMessage;\n const hasSuffix =\n showErrorIcon ||\n shouldShowCopyButton ||\n buttons?.length ||\n (type === 'password' && showPasswordToggle);\n const errorMessageId = `${helperTextId}-error`;\n const describedBy =\n [\n descriptionId,\n hintId,\n helperText ? helperTextId : undefined,\n errorMessage ? errorMessageId : undefined,\n ariaDescribedBy,\n ]\n .filter(Boolean)\n .join(' ') || undefined;\n\n return (\n <>\n <div className={buildWrapperClasses(isError)}>\n {hasPrefix && (\n <div className=\"flex items-center pl-3 pr-1 flex-shrink-0 pointer-events-none\">\n <CompositeIcon\n prefixValue={prefixValue}\n prefixSecondaryValue={prefixSecondaryValue}\n icon={icon}\n />\n </div>\n )}\n\n {copyOnClick && shouldShowCopyButton && handleCopyClick ? (\n <Tooltip\n text={displayValue}\n fill\n triggerAs=\"div\"\n describesTrigger={false}\n showOnFocus={false}\n >\n <div className=\"relative flex min-w-0 flex-1\">\n <input\n id={controlId}\n type={actualInputType}\n placeholder={placeholder}\n value={displayValue}\n onChange={handleChange(onFieldChange)}\n onBlur={() => {\n onBlur?.();\n onFieldBlur?.();\n }}\n disabled={disabled || readOnly}\n readOnly={readOnly}\n autoComplete=\"off\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={isError || undefined}\n aria-required={required || undefined}\n aria-describedby={describedBy}\n className={`flex-1 bg-transparent border-none outline-none text-[var(--malachite-text-primary)] placeholder:text-[var(--malachite-text-placeholder)] disabled:text-[var(--malachite-text-primary)] disabled:cursor-not-allowed ${SIZE_TEXT[size]} ${SIZE_PADDING[size]} ${ellipsis ? 'min-w-0 truncate' : ''}`}\n name={name}\n />\n {/* Out of the tab order and the tree: the copy button is the keyboard's way to copy. */}\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n onClick={handleCopyClick}\n className=\"absolute inset-0 cursor-copy border-0 bg-transparent p-0\"\n />\n </div>\n </Tooltip>\n ) : (\n <input\n id={controlId}\n type={actualInputType}\n placeholder={placeholder}\n value={displayValue}\n onChange={handleChange(onFieldChange)}\n onBlur={() => {\n onBlur?.();\n onFieldBlur?.();\n }}\n disabled={disabled || readOnly}\n readOnly={readOnly}\n autoComplete=\"off\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-invalid={isError || undefined}\n aria-required={required || undefined}\n aria-describedby={describedBy}\n className={`flex-1 bg-transparent border-none outline-none text-[var(--malachite-text-primary)] placeholder:text-[var(--malachite-text-placeholder)] disabled:text-[var(--malachite-text-primary)] disabled:cursor-not-allowed ${SIZE_TEXT[size]} ${SIZE_PADDING[size]} ${ellipsis ? 'min-w-0 truncate' : ''}`}\n name={name}\n />\n )}\n\n {hasSuffix && (\n <div\n className={`flex items-center pl-1 flex-shrink-0 ${type === 'password' && showPasswordToggle ? 'pr-0' : 'pr-3'}`}\n >\n <Suffix\n error={showErrorIcon}\n defaultValue={displayValue}\n onCopyClick={handleCopyClick}\n showCopyButton={shouldShowCopyButton}\n copied={copied}\n type={type}\n showPassword={showPassword}\n showPasswordToggle={showPasswordToggle}\n onTogglePassword={() => setShowPassword(!showPassword)}\n />\n <InputButtons buttons={buttons} />\n </div>\n )}\n </div>\n {helperText && (\n <div\n id={helperTextId}\n className=\"mt-1 text-[length:var(--malachite-font-size-small,13px)] text-left pl-2 text-[var(--malachite-text-dimmed,rgb(161,161,161))] [overflow-wrap:anywhere]\"\n >\n {helperText}\n </div>\n )}\n <FieldMessage id={errorMessageId} message={errorMessage} spaced />\n </>\n );\n }}\n </BaseFormComponent>\n );\n};\n\nconst CompositeIcon: React.FC<{\n prefixValue?: string;\n prefixSecondaryValue?: string;\n icon?: React.ReactNode;\n}> = ({ prefixValue, prefixSecondaryValue, icon }) => {\n return (\n <div className=\"flex items-center gap-1\">\n {icon && (\n <span className=\"flex items-center justify-center text-[var(--malachite-text-dimmed)] w-4 h-4 flex-shrink-0\">\n {icon}\n </span>\n )}\n {prefixValue && (\n <span className=\"text-[length:var(--malachite-font-size-medium,14px)] leading-[1.4] text-[var(--malachite-text-dimmed)] whitespace-nowrap\">\n {prefixValue}\n </span>\n )}\n {prefixSecondaryValue && (\n <span className=\"text-[length:var(--malachite-font-size-medium,14px)] leading-[1.4] text-[var(--malachite-text-dimmed)] whitespace-nowrap\">\n {prefixSecondaryValue}\n </span>\n )}\n </div>\n );\n};\n\nconst Suffix: React.FC<{\n error?: boolean;\n defaultValue?: string;\n onCopyClick?: () => void;\n showCopyButton?: boolean;\n copied?: boolean;\n type?: InputType;\n showPassword?: boolean;\n showPasswordToggle?: boolean;\n onTogglePassword?: () => void;\n}> = ({\n error,\n defaultValue,\n onCopyClick,\n showCopyButton = false,\n copied = false,\n type,\n showPassword,\n showPasswordToggle = true,\n onTogglePassword,\n}) => {\n return (\n <div className=\"flex items-center gap-1\">\n {error && (\n // Decorative: the rejection is carried by the message beneath the field, so\n // announcing an unnamed icon here would only repeat it as \"info\".\n <div\n aria-hidden=\"true\"\n className=\"flex items-center justify-center w-5 h-5 flex-shrink-0\"\n >\n <InfoIcon\n size={16}\n className=\"text-[var(--malachite-destructive-foreground,rgb(196,62,62))]\"\n />\n </div>\n )}\n {showCopyButton && onCopyClick && defaultValue && (\n <CopyButton copied={copied} onCopy={onCopyClick} />\n )}\n {type === 'password' && showPasswordToggle && (\n <Button variant=\"no-style\" onClick={onTogglePassword} type=\"button\" size=\"small\">\n {showPassword ? (\n <EyeClosedIcon\n size={16}\n style={{ color: 'var(--malachite-text-dimmed)' }}\n />\n ) : (\n <EyeIcon size={16} style={{ color: 'var(--malachite-text-dimmed)' }} />\n )}\n </Button>\n )}\n </div>\n );\n};\n\nconst InputButtons: React.FC<{\n buttons?: ButtonDefinition[];\n}> = ({ buttons }) => {\n if (!buttons?.length) {\n return null;\n }\n\n return (\n <>\n {buttons.map((button) => (\n <Button\n key={button.label}\n variant={button.variant || (button.danger ? 'destructive' : 'outline')}\n size={button.size || 'small'}\n disabled={button.disabled}\n icon={button.icon}\n tooltip={button.tooltip}\n onClick={button.onClick}\n className=\"ml-1\"\n >\n {button.label}\n </Button>\n ))}\n </>\n );\n};\n\nexport default Input;\n"],"names":["SIZE_HEIGHT","SIZE_TEXT","SIZE_PADDING","SIZE_RADIUS","getVariantClasses","variant","error","Input","label","hint","hintIcon","tooltip","placeholder","icon","name","required","requiredIndicator","description","loading","readOnly","type","size","defaultValue","disabled","prefixValue","prefixSecondaryValue","ellipsis","copyOnClick","formControl","buttons","onCopyClick","showCopyButton","onChange","value","onBlur","helperText","showPasswordToggle","id","ariaLabel","ariaLabelledBy","ariaDescribedBy","controlId","labelId","descriptionId","hintId","helperTextId","useFormFieldIds","showPassword","setShowPassword","useState","inputValue","setInputValue","copied","setCopied","useEffect","timer","handleChange","reportToForm","e","newValue","formValueRef","useRef","paintedValue","formValue","paintedFieldValue","handleCopyClick","copyValue","actualInputType","hasPrefix","heightClass","buildWrapperClasses","isError","variantStyles","jsx","BaseFormComponent","LoadingInput","fieldError","message","onFieldChange","onFieldBlur","displayValue","shouldShowCopyButton","errorMessage","showErrorIcon","hasSuffix","errorMessageId","describedBy","jsxs","Fragment","CompositeIcon","Tooltip","Suffix","InputButtons","FieldMessage","onTogglePassword","InfoIcon","CopyButton","Button","EyeClosedIcon","EyeIcon","button"],"mappings":";;;;;;;;;;;;AA6DA,MAAMA,KAAyC;AAAA,EAC3C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAAuC;AAAA,EACzC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAA0C;AAAA,EAC5C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAAyC;AAAA,EAC3C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAAoB,CACtBC,GACAC,MAKC;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