@stackone/malachite 2.124.0 → 2.126.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 +9 -8
- package/dist/components/Card.js +17 -17
- package/dist/components/Card.js.map +1 -1
- package/dist/components/HexagonScale.js +25 -10
- package/dist/components/HexagonScale.js.map +1 -1
- package/dist/components/Input/Input.js +176 -195
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/KeyValueStrip.js +57 -41
- package/dist/components/KeyValueStrip.js.map +1 -1
- package/dist/components/PillButton.js +68 -45
- package/dist/components/PillButton.js.map +1 -1
- package/dist/components/ScoreMeter.js +79 -0
- package/dist/components/ScoreMeter.js.map +1 -0
- package/dist/components/Table/Table.js +3 -2
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Timeline.js +88 -77
- package/dist/components/Timeline.js.map +1 -1
- package/dist/components/Typography/Text.js +27 -24
- package/dist/components/Typography/Text.js.map +1 -1
- package/dist/components/overlayBehaviour.js +8 -9
- package/dist/components/overlayBehaviour.js.map +1 -1
- package/dist/index.d.ts +41 -2
- package/dist/index.js +293 -291
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +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 { CopyButton as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { FieldMessage as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { paintedFieldValue as
|
|
13
|
-
const
|
|
1
|
+
import { jsx as a, jsxs as s, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import { useState as T, useEffect as ye, useRef as Ne } from "react";
|
|
3
|
+
import Ce, { useFormFieldIds as Ee } from "../BaseFormComponent.js";
|
|
4
|
+
import { Button as Y } from "../Button.js";
|
|
5
|
+
import { CopyButton as ke } from "../CopyButton.js";
|
|
6
|
+
import Se from "../CustomIcons/EyeClosedIcon.js";
|
|
7
|
+
import ze from "../CustomIcons/EyeIcon.js";
|
|
8
|
+
import je from "../CustomIcons/InfoIcon.js";
|
|
9
|
+
import { FieldMessage as Re } from "../FieldMessage.js";
|
|
10
|
+
import Te from "../LoadingInput.js";
|
|
11
|
+
import Ve from "../Tooltip.js";
|
|
12
|
+
import { paintedFieldValue as $e } from "../devWarning.js";
|
|
13
|
+
const O = {
|
|
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
|
+
}, Me = {
|
|
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
|
+
}, Ze = {
|
|
22
22
|
small: "px-[10px]",
|
|
23
23
|
medium: "px-[10px]",
|
|
24
24
|
large: "px-[16px]"
|
|
25
|
-
},
|
|
25
|
+
}, _e = {
|
|
26
26
|
small: "rounded-[var(--malachite-radius-10,10px)]",
|
|
27
27
|
medium: "rounded-xl",
|
|
28
28
|
large: "rounded-[var(--malachite-radius-xxl,14px)]"
|
|
29
|
-
},
|
|
30
|
-
switch (
|
|
29
|
+
}, Ae = (r, e) => {
|
|
30
|
+
switch (r) {
|
|
31
31
|
case "ghost":
|
|
32
32
|
return {
|
|
33
33
|
wrapper: [
|
|
@@ -49,250 +49,231 @@ const ae = {
|
|
|
49
49
|
borderRadius: ""
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
},
|
|
53
|
-
label:
|
|
52
|
+
}, Fe = ({
|
|
53
|
+
label: r,
|
|
54
54
|
hint: e,
|
|
55
55
|
hintIcon: i,
|
|
56
|
-
tooltip:
|
|
57
|
-
placeholder:
|
|
58
|
-
icon:
|
|
56
|
+
tooltip: g,
|
|
57
|
+
placeholder: b,
|
|
58
|
+
icon: m,
|
|
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
|
-
copyOnClick:
|
|
75
|
-
formControl:
|
|
76
|
-
buttons:
|
|
77
|
-
onCopyClick:
|
|
78
|
-
showCopyButton:
|
|
79
|
-
onChange:
|
|
80
|
-
value:
|
|
81
|
-
onBlur:
|
|
82
|
-
helperText:
|
|
83
|
-
showPasswordToggle:
|
|
84
|
-
id:
|
|
85
|
-
|
|
86
|
-
"
|
|
87
|
-
"aria-
|
|
61
|
+
requiredIndicator: w,
|
|
62
|
+
error: V,
|
|
63
|
+
description: $,
|
|
64
|
+
loading: F = !1,
|
|
65
|
+
readOnly: M = !1,
|
|
66
|
+
type: d = "text",
|
|
67
|
+
size: n = "large",
|
|
68
|
+
variant: ee = "default",
|
|
69
|
+
defaultValue: Z,
|
|
70
|
+
disabled: p,
|
|
71
|
+
prefixValue: _,
|
|
72
|
+
prefixSecondaryValue: A,
|
|
73
|
+
ellipsis: ae = !1,
|
|
74
|
+
copyOnClick: re = !1,
|
|
75
|
+
formControl: D,
|
|
76
|
+
buttons: u,
|
|
77
|
+
onCopyClick: P,
|
|
78
|
+
showCopyButton: te,
|
|
79
|
+
onChange: I,
|
|
80
|
+
value: ie,
|
|
81
|
+
onBlur: y,
|
|
82
|
+
helperText: v,
|
|
83
|
+
showPasswordToggle: N = !0,
|
|
84
|
+
id: le,
|
|
85
|
+
autoFocus: se = !1,
|
|
86
|
+
autoComplete: oe = "off",
|
|
87
|
+
"aria-label": de,
|
|
88
|
+
"aria-labelledby": ne,
|
|
89
|
+
"aria-describedby": ce
|
|
88
90
|
}) => {
|
|
89
|
-
const { controlId:
|
|
90
|
-
id:
|
|
91
|
-
label:
|
|
92
|
-
description:
|
|
91
|
+
const { controlId: B, labelId: me, descriptionId: G, hintId: H, helperTextId: C } = Ee({
|
|
92
|
+
id: le,
|
|
93
|
+
label: r,
|
|
94
|
+
description: $,
|
|
93
95
|
hint: e,
|
|
94
96
|
helperText: !0
|
|
95
|
-
}), [
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
const
|
|
99
|
-
|
|
97
|
+
}), [E, he] = T(!1), [pe, ue] = T(Z || ""), [k, L] = T(!1);
|
|
98
|
+
ye(() => {
|
|
99
|
+
if (k) {
|
|
100
|
+
const t = setTimeout(() => {
|
|
101
|
+
L(!1);
|
|
100
102
|
}, 1e3);
|
|
101
|
-
return () => clearTimeout(
|
|
103
|
+
return () => clearTimeout(t);
|
|
102
104
|
}
|
|
103
|
-
}, [
|
|
104
|
-
const
|
|
105
|
-
const c =
|
|
106
|
-
|
|
107
|
-
},
|
|
105
|
+
}, [k]);
|
|
106
|
+
const ve = (t) => (l) => {
|
|
107
|
+
const c = l.target.value;
|
|
108
|
+
ue(c), I == null || I(c), t == null || t(c);
|
|
109
|
+
}, U = Ne(void 0), W = (t) => $e({
|
|
108
110
|
component: "Input",
|
|
109
111
|
name: o,
|
|
110
|
-
value:
|
|
111
|
-
formValue:
|
|
112
|
-
defaultValue:
|
|
113
|
-
bound: !!
|
|
114
|
-
uncontrolledValue:
|
|
115
|
-
}),
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
} : void 0,
|
|
119
|
-
const
|
|
112
|
+
value: ie,
|
|
113
|
+
formValue: t,
|
|
114
|
+
defaultValue: Z,
|
|
115
|
+
bound: !!D,
|
|
116
|
+
uncontrolledValue: pe
|
|
117
|
+
}), f = P ? () => {
|
|
118
|
+
const t = W(U.current);
|
|
119
|
+
t && (navigator.clipboard.writeText(t), L(!0), P());
|
|
120
|
+
} : void 0, fe = d === "password" ? E ? "text" : "password" : d, xe = m || _ || A, ge = O[n], be = (t) => {
|
|
121
|
+
const l = Ae(ee, t);
|
|
120
122
|
return [
|
|
121
123
|
"relative",
|
|
122
124
|
"flex items-center",
|
|
123
125
|
"w-full",
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
l.borderRadius || _e[n],
|
|
127
|
+
p ? "bg-[var(--malachite-card-dimmed-background)]" : "bg-[var(--malachite-card-background)]",
|
|
126
128
|
"transition-colors duration-200 ease-in-out",
|
|
127
|
-
|
|
128
|
-
...
|
|
129
|
-
|
|
129
|
+
l.shadow,
|
|
130
|
+
...p ? [] : l.wrapper,
|
|
131
|
+
O[n]
|
|
130
132
|
].filter(Boolean).join(" ");
|
|
131
133
|
};
|
|
132
134
|
return /* @__PURE__ */ a(
|
|
133
|
-
|
|
135
|
+
Ce,
|
|
134
136
|
{
|
|
135
|
-
label:
|
|
137
|
+
label: r,
|
|
136
138
|
hint: e,
|
|
137
139
|
hintIcon: i,
|
|
138
|
-
tooltip:
|
|
140
|
+
tooltip: g,
|
|
139
141
|
name: o,
|
|
140
142
|
required: h,
|
|
141
|
-
requiredIndicator:
|
|
142
|
-
loading:
|
|
143
|
-
formControl:
|
|
144
|
-
description:
|
|
145
|
-
controlId:
|
|
146
|
-
labelId:
|
|
147
|
-
descriptionId:
|
|
148
|
-
hintId:
|
|
143
|
+
requiredIndicator: w,
|
|
144
|
+
loading: F,
|
|
145
|
+
formControl: D,
|
|
146
|
+
description: $,
|
|
147
|
+
controlId: B,
|
|
148
|
+
labelId: me,
|
|
149
|
+
descriptionId: G,
|
|
150
|
+
hintId: H,
|
|
149
151
|
loadingComponent: /* @__PURE__ */ a(
|
|
150
|
-
|
|
152
|
+
Te,
|
|
151
153
|
{
|
|
152
|
-
heightClass:
|
|
153
|
-
helperText: !!
|
|
154
|
+
heightClass: ge,
|
|
155
|
+
helperText: !!v,
|
|
154
156
|
helperTextMarginTop: !0
|
|
155
157
|
}
|
|
156
158
|
),
|
|
157
|
-
children: ({ error:
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
].filter(Boolean).join(" ") || void 0
|
|
166
|
-
|
|
167
|
-
|
|
159
|
+
children: ({ error: t, message: l, onFieldChange: c, onFieldBlur: S, value: X }) => {
|
|
160
|
+
U.current = X;
|
|
161
|
+
const x = W(X), z = te ?? !!(f && p && x), j = V ?? t, R = V === !1 ? void 0 : l, q = j && !R, we = q || z || (u == null ? void 0 : u.length) || d === "password" && N, J = `${C}-error`, Ie = [
|
|
162
|
+
G,
|
|
163
|
+
H,
|
|
164
|
+
v ? C : void 0,
|
|
165
|
+
R ? J : void 0,
|
|
166
|
+
ce
|
|
167
|
+
].filter(Boolean).join(" ") || void 0, K = /* @__PURE__ */ a(
|
|
168
|
+
"input",
|
|
169
|
+
{
|
|
170
|
+
id: B,
|
|
171
|
+
type: fe,
|
|
172
|
+
placeholder: b,
|
|
173
|
+
value: x,
|
|
174
|
+
onChange: ve(c),
|
|
175
|
+
onBlur: () => {
|
|
176
|
+
y == null || y(), S == null || S();
|
|
177
|
+
},
|
|
178
|
+
disabled: p || M,
|
|
179
|
+
readOnly: M,
|
|
180
|
+
autoComplete: oe,
|
|
181
|
+
autoFocus: se,
|
|
182
|
+
"aria-label": de,
|
|
183
|
+
"aria-labelledby": ne,
|
|
184
|
+
"aria-invalid": j || void 0,
|
|
185
|
+
"aria-required": h || void 0,
|
|
186
|
+
"aria-describedby": Ie,
|
|
187
|
+
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 ${Me[n]} ${Ze[n]} ${ae ? "min-w-0 truncate" : ""}`,
|
|
188
|
+
name: o
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
return /* @__PURE__ */ s(Q, { children: [
|
|
192
|
+
/* @__PURE__ */ s("div", { className: be(j), children: [
|
|
168
193
|
xe && /* @__PURE__ */ a("div", { className: "flex items-center pl-3 pr-1 flex-shrink-0 pointer-events-none", children: /* @__PURE__ */ a(
|
|
169
|
-
|
|
194
|
+
De,
|
|
170
195
|
{
|
|
171
|
-
prefixValue:
|
|
172
|
-
prefixSecondaryValue:
|
|
173
|
-
icon:
|
|
196
|
+
prefixValue: _,
|
|
197
|
+
prefixSecondaryValue: A,
|
|
198
|
+
icon: m
|
|
174
199
|
}
|
|
175
200
|
) }),
|
|
176
|
-
|
|
177
|
-
|
|
201
|
+
re && z && f ? /* @__PURE__ */ a(
|
|
202
|
+
Ve,
|
|
178
203
|
{
|
|
179
|
-
text:
|
|
204
|
+
text: x,
|
|
180
205
|
fill: !0,
|
|
181
206
|
triggerAs: "div",
|
|
182
207
|
describesTrigger: !1,
|
|
183
208
|
showOnFocus: !1,
|
|
184
|
-
children: /* @__PURE__ */
|
|
185
|
-
|
|
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
|
-
),
|
|
209
|
+
children: /* @__PURE__ */ s("div", { className: "relative flex min-w-0 flex-1", children: [
|
|
210
|
+
K,
|
|
208
211
|
/* @__PURE__ */ a(
|
|
209
212
|
"button",
|
|
210
213
|
{
|
|
211
214
|
type: "button",
|
|
212
215
|
tabIndex: -1,
|
|
213
216
|
"aria-hidden": "true",
|
|
214
|
-
onClick:
|
|
217
|
+
onClick: f,
|
|
215
218
|
className: "absolute inset-0 cursor-copy border-0 bg-transparent p-0"
|
|
216
219
|
}
|
|
217
220
|
)
|
|
218
221
|
] })
|
|
219
222
|
}
|
|
220
|
-
) :
|
|
221
|
-
|
|
222
|
-
{
|
|
223
|
-
id: S,
|
|
224
|
-
type: L,
|
|
225
|
-
placeholder: f,
|
|
226
|
-
value: u,
|
|
227
|
-
onChange: K(c),
|
|
228
|
-
onBlur: () => {
|
|
229
|
-
d == null || d(), n == null || n();
|
|
230
|
-
},
|
|
231
|
-
disabled: v || b,
|
|
232
|
-
readOnly: b,
|
|
233
|
-
autoComplete: "off",
|
|
234
|
-
"aria-label": U,
|
|
235
|
-
"aria-labelledby": W,
|
|
236
|
-
"aria-invalid": y || void 0,
|
|
237
|
-
"aria-required": h || void 0,
|
|
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" : ""}`,
|
|
240
|
-
name: o
|
|
241
|
-
}
|
|
242
|
-
),
|
|
243
|
-
we && /* @__PURE__ */ m(
|
|
223
|
+
) : K,
|
|
224
|
+
we && /* @__PURE__ */ s(
|
|
244
225
|
"div",
|
|
245
226
|
{
|
|
246
|
-
className: `flex items-center pl-1 flex-shrink-0 ${
|
|
227
|
+
className: `flex items-center pl-1 flex-shrink-0 ${d === "password" && N ? "pr-0" : "pr-3"}`,
|
|
247
228
|
children: [
|
|
248
229
|
/* @__PURE__ */ a(
|
|
249
|
-
|
|
230
|
+
Pe,
|
|
250
231
|
{
|
|
251
|
-
error:
|
|
252
|
-
defaultValue:
|
|
253
|
-
onCopyClick:
|
|
254
|
-
showCopyButton:
|
|
255
|
-
copied:
|
|
256
|
-
type:
|
|
257
|
-
showPassword:
|
|
258
|
-
showPasswordToggle:
|
|
259
|
-
onTogglePassword: () =>
|
|
232
|
+
error: q,
|
|
233
|
+
defaultValue: x,
|
|
234
|
+
onCopyClick: f,
|
|
235
|
+
showCopyButton: z,
|
|
236
|
+
copied: k,
|
|
237
|
+
type: d,
|
|
238
|
+
showPassword: E,
|
|
239
|
+
showPasswordToggle: N,
|
|
240
|
+
onTogglePassword: () => he(!E)
|
|
260
241
|
}
|
|
261
242
|
),
|
|
262
|
-
/* @__PURE__ */ a(
|
|
243
|
+
/* @__PURE__ */ a(Be, { buttons: u })
|
|
263
244
|
]
|
|
264
245
|
}
|
|
265
246
|
)
|
|
266
247
|
] }),
|
|
267
|
-
|
|
248
|
+
v && /* @__PURE__ */ a(
|
|
268
249
|
"div",
|
|
269
250
|
{
|
|
270
|
-
id:
|
|
251
|
+
id: C,
|
|
271
252
|
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:
|
|
253
|
+
children: v
|
|
273
254
|
}
|
|
274
255
|
),
|
|
275
|
-
/* @__PURE__ */ a(
|
|
256
|
+
/* @__PURE__ */ a(Re, { id: J, message: R, spaced: !0 })
|
|
276
257
|
] });
|
|
277
258
|
}
|
|
278
259
|
}
|
|
279
260
|
);
|
|
280
|
-
},
|
|
261
|
+
}, De = ({ prefixValue: r, prefixSecondaryValue: e, icon: i }) => /* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
|
|
281
262
|
i && /* @__PURE__ */ a("span", { className: "flex items-center justify-center text-[var(--malachite-text-dimmed)] w-4 h-4 flex-shrink-0", children: i }),
|
|
282
|
-
|
|
263
|
+
r && /* @__PURE__ */ a("span", { className: "text-[length:var(--malachite-font-size-medium,14px)] leading-[1.4] text-[var(--malachite-text-dimmed)] whitespace-nowrap", children: r }),
|
|
283
264
|
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 })
|
|
284
|
-
] }),
|
|
285
|
-
error:
|
|
265
|
+
] }), Pe = ({
|
|
266
|
+
error: r,
|
|
286
267
|
defaultValue: e,
|
|
287
268
|
onCopyClick: i,
|
|
288
|
-
showCopyButton:
|
|
289
|
-
copied:
|
|
290
|
-
type:
|
|
269
|
+
showCopyButton: g = !1,
|
|
270
|
+
copied: b = !1,
|
|
271
|
+
type: m,
|
|
291
272
|
showPassword: o,
|
|
292
273
|
showPasswordToggle: h = !0,
|
|
293
|
-
onTogglePassword:
|
|
294
|
-
}) => /* @__PURE__ */
|
|
295
|
-
|
|
274
|
+
onTogglePassword: w
|
|
275
|
+
}) => /* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
|
|
276
|
+
r && // Decorative: the rejection is carried by the message beneath the field, so
|
|
296
277
|
// announcing an unnamed icon here would only repeat it as "info".
|
|
297
278
|
/* @__PURE__ */ a(
|
|
298
279
|
"div",
|
|
@@ -300,7 +281,7 @@ const ae = {
|
|
|
300
281
|
"aria-hidden": "true",
|
|
301
282
|
className: "flex items-center justify-center w-5 h-5 flex-shrink-0",
|
|
302
283
|
children: /* @__PURE__ */ a(
|
|
303
|
-
|
|
284
|
+
je,
|
|
304
285
|
{
|
|
305
286
|
size: 16,
|
|
306
287
|
className: "text-[var(--malachite-destructive-foreground,rgb(196,62,62))]"
|
|
@@ -308,16 +289,16 @@ const ae = {
|
|
|
308
289
|
)
|
|
309
290
|
}
|
|
310
291
|
),
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
292
|
+
g && i && e && /* @__PURE__ */ a(ke, { copied: b, onCopy: i }),
|
|
293
|
+
m === "password" && h && /* @__PURE__ */ a(Y, { variant: "no-style", onClick: w, type: "button", size: "small", children: o ? /* @__PURE__ */ a(
|
|
294
|
+
Se,
|
|
314
295
|
{
|
|
315
296
|
size: 16,
|
|
316
297
|
style: { color: "var(--malachite-text-dimmed)" }
|
|
317
298
|
}
|
|
318
|
-
) : /* @__PURE__ */ a(
|
|
319
|
-
] }),
|
|
320
|
-
|
|
299
|
+
) : /* @__PURE__ */ a(ze, { size: 16, style: { color: "var(--malachite-text-dimmed)" } }) })
|
|
300
|
+
] }), Be = ({ buttons: r }) => r != null && r.length ? /* @__PURE__ */ a(Q, { children: r.map((e) => /* @__PURE__ */ a(
|
|
301
|
+
Y,
|
|
321
302
|
{
|
|
322
303
|
variant: e.variant || (e.danger ? "destructive" : "outline"),
|
|
323
304
|
size: e.size || "small",
|
|
@@ -331,6 +312,6 @@ const ae = {
|
|
|
331
312
|
e.label
|
|
332
313
|
)) }) : null;
|
|
333
314
|
export {
|
|
334
|
-
|
|
315
|
+
Fe as default
|
|
335
316
|
};
|
|
336
317
|
//# 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 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;AA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AAmE;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,eAAY;AAAA,MACZ,WAAU;AAAA,MAEV,UAAA,gBAAAA;AAAA,QAACsB;AAAA,QAAA;AAAA,UACG,MAAM;AAAA,UACN,WAAU;AAAA,QAAA;AAAA,MAAA;AAAA,IACd;AAAA,EAAA;AAAA,EAGPhE,KAAkBD,KAAeR,uBAC7B0E,IAAA,EAAW,QAAA5C,GAAgB,QAAQtB,GAAa;AAAA,EAEpDV,MAAS,cAAcgB,KACpB,gBAAAqC,EAACwB,IAAA,EAAO,SAAQ,YAAW,SAASH,GAAkB,MAAK,UAAS,MAAK,SACpE,UAAA/C,IACG,gBAAA0B;AAAA,IAACyB;AAAA,IAAA;AAAA,MACG,MAAM;AAAA,MACN,OAAO,EAAE,OAAO,+BAAA;AAAA,IAA+B;AAAA,EAAA,IAGnD,gBAAAzB,EAAC0B,IAAA,EAAQ,MAAM,IAAI,OAAO,EAAE,OAAO,+BAAA,EAA+B,CAAG,EAAA,CAE7E;AAAA,GAER,GAIFP,KAED,CAAC,EAAE,SAAA/D,QACCA,KAAA,QAAAA,EAAS,SAKV,gBAAA4C,EAAAe,IAAA,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 /** Moves focus into the field when it mounts, such as the first field of a form that just opened. */\n autoFocus?: boolean;\n /** The browser's autofill hint, such as `current-password` or `new-password`. Defaults to `off`. */\n autoComplete?: 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 autoFocus = false,\n autoComplete = 'off',\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 const field = (\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={autoComplete}\n autoFocus={autoFocus}\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 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 {field}\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 field\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","autoFocus","autoComplete","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","field","jsxs","Fragment","CompositeIcon","Tooltip","Suffix","InputButtons","FieldMessage","onTogglePassword","InfoIcon","CopyButton","Button","EyeClosedIcon","EyeIcon","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