@krak-stack/registry 0.10.18 → 0.10.19
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LucideIcon } from "lucide-react";
|
|
1
2
|
import { type CopyButtonMessageTranslations } from "./copy-button.js";
|
|
2
3
|
export type CopyValueMessages = {
|
|
3
4
|
show: string;
|
|
@@ -7,6 +8,8 @@ export type CopyValueMessages = {
|
|
|
7
8
|
export type CopyValueProps = {
|
|
8
9
|
value: string;
|
|
9
10
|
label: string;
|
|
11
|
+
showLabel?: boolean;
|
|
12
|
+
icon?: LucideIcon;
|
|
10
13
|
secret?: boolean;
|
|
11
14
|
variant?: "outline" | "ghost";
|
|
12
15
|
disabled?: boolean;
|
|
@@ -18,4 +21,4 @@ export type CopyValueProps = {
|
|
|
18
21
|
copyMessages?: CopyButtonMessageTranslations;
|
|
19
22
|
};
|
|
20
23
|
/** Masking is presentation, not a security boundary. Never logs the value. */
|
|
21
|
-
export declare const CopyValue: ({ value, label, secret, variant, disabled, copyable, autoHideDelay, className, locale: override, messages, copyMessages, }: CopyValueProps) => import("react").JSX.Element;
|
|
24
|
+
export declare const CopyValue: ({ value, label, showLabel, icon: Icon, secret, variant, disabled, copyable, autoHideDelay, className, locale: override, messages, copyMessages, }: CopyValueProps) => import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ../../src/components/ui/copy-value.tsx
|
|
2
2
|
import { Eye, EyeOff } from "lucide-react";
|
|
3
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
3
|
+
import { useEffect as useEffect2, useId, useState as useState2 } from "react";
|
|
4
4
|
|
|
5
5
|
// ../../src/components/ui/input-group.tsx
|
|
6
6
|
import { cva as cva2 } from "class-variance-authority";
|
|
@@ -231,7 +231,20 @@ function CopyButton({
|
|
|
231
231
|
|
|
232
232
|
// ../../src/components/ui/copy-value.tsx
|
|
233
233
|
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
234
|
-
|
|
234
|
+
|
|
235
|
+
// ../../src/components/ui/label.tsx
|
|
236
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
237
|
+
"use client";
|
|
238
|
+
function Label({ className, ...props }) {
|
|
239
|
+
return /* @__PURE__ */ jsx5("label", {
|
|
240
|
+
"data-slot": "label",
|
|
241
|
+
className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
|
|
242
|
+
...props
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ../../src/components/ui/copy-value.tsx
|
|
247
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
235
248
|
var labels = {
|
|
236
249
|
en: { show: "Show", hide: "Hide", hidden: "Hidden value" },
|
|
237
250
|
fr: { show: "Afficher", hide: "Masquer", hidden: "Valeur masquée" }
|
|
@@ -239,6 +252,8 @@ var labels = {
|
|
|
239
252
|
var CopyValue = ({
|
|
240
253
|
value,
|
|
241
254
|
label,
|
|
255
|
+
showLabel = false,
|
|
256
|
+
icon: Icon,
|
|
242
257
|
secret = false,
|
|
243
258
|
variant = "outline",
|
|
244
259
|
disabled,
|
|
@@ -249,6 +264,7 @@ var CopyValue = ({
|
|
|
249
264
|
messages,
|
|
250
265
|
copyMessages
|
|
251
266
|
}) => {
|
|
267
|
+
const inputId = useId();
|
|
252
268
|
const locale = useKrakstackLocale2(override);
|
|
253
269
|
const copy = {
|
|
254
270
|
...locale.startsWith("fr") ? labels.fr : labels.en,
|
|
@@ -268,12 +284,13 @@ var CopyValue = ({
|
|
|
268
284
|
const timer = setTimeout(() => setRevealedValue(null), autoHideDelay);
|
|
269
285
|
return () => clearTimeout(timer);
|
|
270
286
|
}, [revealed, autoHideDelay, value]);
|
|
271
|
-
|
|
287
|
+
const input = /* @__PURE__ */ jsxs2(InputGroup, {
|
|
272
288
|
className: cn("min-w-0", variant === "ghost" && "border-0 bg-transparent shadow-none dark:bg-transparent", className),
|
|
273
289
|
children: [
|
|
274
|
-
/* @__PURE__ */
|
|
290
|
+
/* @__PURE__ */ jsx6(InputGroupInput, {
|
|
291
|
+
id: showLabel ? inputId : undefined,
|
|
275
292
|
className: variant === "ghost" ? "pl-0 font-mono" : undefined,
|
|
276
|
-
"aria-label": secret && !revealed ? `${label}: ${copy.hidden}` : label,
|
|
293
|
+
"aria-label": secret && !revealed ? `${label}: ${copy.hidden}` : showLabel ? undefined : label,
|
|
277
294
|
value,
|
|
278
295
|
type: secret && !revealed ? "password" : "text",
|
|
279
296
|
autoComplete: secret ? "off" : undefined,
|
|
@@ -281,11 +298,17 @@ var CopyValue = ({
|
|
|
281
298
|
disabled,
|
|
282
299
|
onFocus: (event) => event.currentTarget.select()
|
|
283
300
|
}),
|
|
301
|
+
Icon && /* @__PURE__ */ jsx6(InputGroupAddon, {
|
|
302
|
+
align: "inline-start",
|
|
303
|
+
children: /* @__PURE__ */ jsx6(Icon, {
|
|
304
|
+
"aria-hidden": "true"
|
|
305
|
+
})
|
|
306
|
+
}),
|
|
284
307
|
/* @__PURE__ */ jsxs2(InputGroupAddon, {
|
|
285
308
|
align: "inline-end",
|
|
286
309
|
className: "gap-0",
|
|
287
310
|
children: [
|
|
288
|
-
secret ? /* @__PURE__ */
|
|
311
|
+
secret ? /* @__PURE__ */ jsx6(InputGroupButton, {
|
|
289
312
|
type: "button",
|
|
290
313
|
size: "icon-sm",
|
|
291
314
|
variant: "ghost",
|
|
@@ -293,13 +316,13 @@ var CopyValue = ({
|
|
|
293
316
|
"aria-label": `${revealed ? copy.hide : copy.show} ${label}`,
|
|
294
317
|
"aria-pressed": revealed,
|
|
295
318
|
onClick: () => setRevealedValue(revealed ? null : value),
|
|
296
|
-
children: revealed ? /* @__PURE__ */
|
|
319
|
+
children: revealed ? /* @__PURE__ */ jsx6(EyeOff, {
|
|
297
320
|
"aria-hidden": "true"
|
|
298
|
-
}) : /* @__PURE__ */
|
|
321
|
+
}) : /* @__PURE__ */ jsx6(Eye, {
|
|
299
322
|
"aria-hidden": "true"
|
|
300
323
|
})
|
|
301
324
|
}) : null,
|
|
302
|
-
copyable ? /* @__PURE__ */
|
|
325
|
+
copyable ? /* @__PURE__ */ jsx6(CopyButton, {
|
|
303
326
|
type: "button",
|
|
304
327
|
value,
|
|
305
328
|
valueDescription: label,
|
|
@@ -313,6 +336,16 @@ var CopyValue = ({
|
|
|
313
336
|
})
|
|
314
337
|
]
|
|
315
338
|
});
|
|
339
|
+
return showLabel ? /* @__PURE__ */ jsxs2("div", {
|
|
340
|
+
className: "flex min-w-0 flex-col gap-2",
|
|
341
|
+
children: [
|
|
342
|
+
/* @__PURE__ */ jsx6(Label, {
|
|
343
|
+
htmlFor: inputId,
|
|
344
|
+
children: label
|
|
345
|
+
}),
|
|
346
|
+
input
|
|
347
|
+
]
|
|
348
|
+
}) : input;
|
|
316
349
|
};
|
|
317
350
|
export {
|
|
318
351
|
CopyValue
|