@krak-stack/registry 0.8.2 → 0.8.3

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,5 +1,13 @@
1
1
  # @krak-stack/registry
2
2
 
3
+ ## 0.8.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Replace SecretValue with CopyValue, modeled on Kokobi's read-only copyable input. Values are visible by default; enable `secret` for reveal/hide and optional auto-hide. Add a borderless `variant="ghost"` with monospaced text and an icon-only copy button, and tighten spacing between actions.
8
+
9
+ Migrate imports from `@krak-stack/registry/secret-value` to `@krak-stack/registry/copy-value`, rename `SecretValue` to `CopyValue`, and add `secret` to preserve masking. The shadcn registry item is now `@krak-stack/copy-value`. Include updated English/French documentation and previews.
10
+
3
11
  ## 0.8.2
4
12
 
5
13
  ### Patch Changes
@@ -1,19 +1,21 @@
1
1
  import { type CopyButtonMessageTranslations } from "./copy-button.js";
2
- export type SecretValueMessages = {
2
+ export type CopyValueMessages = {
3
3
  show: string;
4
4
  hide: string;
5
5
  hidden: string;
6
6
  };
7
- export type SecretValueProps = {
7
+ export type CopyValueProps = {
8
8
  value: string;
9
9
  label: string;
10
+ secret?: boolean;
11
+ variant?: "outline" | "ghost";
10
12
  disabled?: boolean;
11
13
  copyable?: boolean;
12
14
  autoHideDelay?: number;
13
15
  className?: string;
14
16
  locale?: string;
15
- messages?: Partial<Record<string, Partial<SecretValueMessages>>>;
17
+ messages?: Partial<Record<string, Partial<CopyValueMessages>>>;
16
18
  copyMessages?: CopyButtonMessageTranslations;
17
19
  };
18
20
  /** Masking is presentation, not a security boundary. Never logs the value. */
19
- export declare const SecretValue: ({ value, label, disabled, copyable, autoHideDelay, className, locale: override, messages, copyMessages, }: SecretValueProps) => import("react").JSX.Element;
21
+ export declare const CopyValue: ({ value, label, secret, variant, disabled, copyable, autoHideDelay, className, locale: override, messages, copyMessages, }: CopyValueProps) => import("react").JSX.Element;
@@ -0,0 +1,319 @@
1
+ // ../../src/components/ui/copy-value.tsx
2
+ import { Eye, EyeOff } from "lucide-react";
3
+ import { useEffect as useEffect2, useState as useState2 } from "react";
4
+
5
+ // ../../src/components/ui/input-group.tsx
6
+ import { cva as cva2 } from "class-variance-authority";
7
+
8
+ // ../../src/components/ui/button.tsx
9
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
10
+ import { cva } from "class-variance-authority";
11
+
12
+ // ../../src/lib/utils.ts
13
+ import { cn } from "cn";
14
+
15
+ // ../../src/components/ui/button.tsx
16
+ import { jsx } from "react/jsx-runtime";
17
+ var buttonVariants = cva("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
18
+ variants: {
19
+ variant: {
20
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
21
+ outline: "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
22
+ secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
23
+ ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
24
+ destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
25
+ link: "text-primary underline-offset-4 hover:underline"
26
+ },
27
+ size: {
28
+ default: "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
29
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
30
+ sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
31
+ lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
32
+ icon: "size-9",
33
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
34
+ "icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
35
+ "icon-lg": "size-10"
36
+ }
37
+ },
38
+ defaultVariants: {
39
+ variant: "default",
40
+ size: "default"
41
+ }
42
+ });
43
+ function Button({
44
+ className,
45
+ variant = "default",
46
+ size = "default",
47
+ ...props
48
+ }) {
49
+ return /* @__PURE__ */ jsx(ButtonPrimitive, {
50
+ "data-slot": "button",
51
+ className: cn(buttonVariants({ variant, size, className })),
52
+ ...props
53
+ });
54
+ }
55
+
56
+ // ../../src/components/ui/input.tsx
57
+ import { Input as InputPrimitive } from "@base-ui/react/input";
58
+ import { jsx as jsx2 } from "react/jsx-runtime";
59
+ function Input({ className, type, ...props }) {
60
+ return /* @__PURE__ */ jsx2(InputPrimitive, {
61
+ type,
62
+ "data-slot": "input",
63
+ className: cn("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
64
+ ...props
65
+ });
66
+ }
67
+
68
+ // ../../src/components/ui/input-group.tsx
69
+ import { jsx as jsx3 } from "react/jsx-runtime";
70
+ function InputGroup({ className, ...props }) {
71
+ return /* @__PURE__ */ jsx3("div", {
72
+ "data-slot": "input-group",
73
+ role: "group",
74
+ className: cn("group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5", className),
75
+ ...props
76
+ });
77
+ }
78
+ var inputGroupAddonVariants = cva2("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
79
+ variants: {
80
+ align: {
81
+ "inline-start": "order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]",
82
+ "inline-end": "order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]",
83
+ "block-start": "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
84
+ "block-end": "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"
85
+ }
86
+ },
87
+ defaultVariants: { align: "inline-start" }
88
+ });
89
+ function InputGroupAddon({
90
+ className,
91
+ align = "inline-start",
92
+ ...props
93
+ }) {
94
+ return /* @__PURE__ */ jsx3("div", {
95
+ role: "group",
96
+ "data-slot": "input-group-addon",
97
+ "data-align": align,
98
+ className: cn(inputGroupAddonVariants({ align }), className),
99
+ onClick: (event) => {
100
+ if (event.target instanceof HTMLElement && event.target.closest("button")) {
101
+ return;
102
+ }
103
+ event.currentTarget.parentElement?.querySelector("input")?.focus();
104
+ },
105
+ ...props
106
+ });
107
+ }
108
+ var inputGroupButtonVariants = cva2("flex items-center gap-2 text-sm shadow-none", {
109
+ variants: {
110
+ size: {
111
+ xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
112
+ sm: "",
113
+ "icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
114
+ "icon-sm": "size-8 p-0 has-[>svg]:p-0"
115
+ }
116
+ },
117
+ defaultVariants: { size: "xs" }
118
+ });
119
+ function InputGroupButton({
120
+ className,
121
+ type = "button",
122
+ variant = "ghost",
123
+ size = "xs",
124
+ ...props
125
+ }) {
126
+ return /* @__PURE__ */ jsx3(Button, {
127
+ type,
128
+ "data-size": size,
129
+ variant,
130
+ className: cn(inputGroupButtonVariants({ size }), className),
131
+ ...props
132
+ });
133
+ }
134
+ function InputGroupInput({
135
+ className,
136
+ ...props
137
+ }) {
138
+ return /* @__PURE__ */ jsx3(Input, {
139
+ "data-slot": "input-group-control",
140
+ className: cn("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent", className),
141
+ ...props
142
+ });
143
+ }
144
+
145
+ // ../../src/components/ui/copy-button.tsx
146
+ import { Check, Copy, TriangleAlert } from "lucide-react";
147
+ import { useEffect, useRef, useState } from "react";
148
+ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
149
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
150
+ var messages = {
151
+ en: { copy: "Copy", copied: "Copied", copyFailed: "Copy failed" },
152
+ fr: { copy: "Copier", copied: "Copié", copyFailed: "Échec de la copie" }
153
+ };
154
+ var copyButtonMessages = (locale = "en", translations) => ({
155
+ ...locale.startsWith("fr") ? messages.fr : messages.en,
156
+ ...translations?.[locale.split("-")[0] ?? locale],
157
+ ...translations?.[locale]
158
+ });
159
+ function CopyButton({
160
+ value,
161
+ valueDescription,
162
+ copyVariant = "default",
163
+ locale: localeOverride,
164
+ messages,
165
+ onCopied,
166
+ onCopyError,
167
+ resetDelay = 1500,
168
+ disabled,
169
+ size,
170
+ "aria-label": ariaLabel,
171
+ ...props
172
+ }) {
173
+ const locale = useKrakstackLocale(localeOverride);
174
+ const [copyState, setCopyState] = useState("idle");
175
+ const copyTimeout = useRef(undefined);
176
+ const labels = copyButtonMessages(locale, messages);
177
+ const accessibleLabel = ariaLabel ?? (valueDescription ? `${labels.copy} ${valueDescription}` : labels.copy);
178
+ const isLarge = copyVariant === "large";
179
+ const defaultSize = copyVariant === "sm" ? "icon-xs" : isLarge ? "sm" : "icon-sm";
180
+ useEffect(() => {
181
+ return () => {
182
+ if (copyTimeout.current)
183
+ clearTimeout(copyTimeout.current);
184
+ };
185
+ }, []);
186
+ const resetCopyState = () => {
187
+ if (copyTimeout.current)
188
+ clearTimeout(copyTimeout.current);
189
+ copyTimeout.current = setTimeout(() => setCopyState("idle"), resetDelay);
190
+ };
191
+ const copy = async () => {
192
+ try {
193
+ await navigator.clipboard.writeText(value);
194
+ setCopyState("copied");
195
+ onCopied?.();
196
+ } catch (error) {
197
+ setCopyState("failed");
198
+ onCopyError?.(error instanceof Error ? error : new Error(labels.copyFailed, { cause: error }));
199
+ }
200
+ resetCopyState();
201
+ };
202
+ const status = copyState === "copied" ? valueDescription ? `${labels.copied}: ${valueDescription}` : labels.copied : copyState === "failed" ? valueDescription ? `${labels.copyFailed}: ${valueDescription}` : labels.copyFailed : "";
203
+ return /* @__PURE__ */ jsxs(Button, {
204
+ "aria-label": accessibleLabel,
205
+ disabled,
206
+ onClick: copy,
207
+ size: size ?? defaultSize,
208
+ ...props,
209
+ children: [
210
+ /* @__PURE__ */ jsx4("span", {
211
+ "aria-live": "polite",
212
+ className: "sr-only",
213
+ role: "status",
214
+ children: status
215
+ }),
216
+ copyState === "copied" ? /* @__PURE__ */ jsx4(Check, {
217
+ "aria-hidden": "true"
218
+ }) : null,
219
+ copyState === "failed" ? /* @__PURE__ */ jsx4(TriangleAlert, {
220
+ "aria-hidden": "true"
221
+ }) : null,
222
+ copyState === "idle" ? /* @__PURE__ */ jsx4(Copy, {
223
+ "aria-hidden": "true"
224
+ }) : null,
225
+ isLarge ? /* @__PURE__ */ jsx4("span", {
226
+ children: labels.copy
227
+ }) : null
228
+ ]
229
+ });
230
+ }
231
+
232
+ // ../../src/components/ui/copy-value.tsx
233
+ import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
234
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
235
+ var labels = {
236
+ en: { show: "Show", hide: "Hide", hidden: "Hidden value" },
237
+ fr: { show: "Afficher", hide: "Masquer", hidden: "Valeur masquée" }
238
+ };
239
+ var CopyValue = ({
240
+ value,
241
+ label,
242
+ secret = false,
243
+ variant = "outline",
244
+ disabled,
245
+ copyable = true,
246
+ autoHideDelay = 0,
247
+ className,
248
+ locale: override,
249
+ messages,
250
+ copyMessages
251
+ }) => {
252
+ const locale = useKrakstackLocale2(override);
253
+ const copy = {
254
+ ...locale.startsWith("fr") ? labels.fr : labels.en,
255
+ ...messages?.[locale.split("-")[0] ?? locale],
256
+ ...messages?.[locale]
257
+ };
258
+ const [revealedValue, setRevealedValue] = useState2(null);
259
+ const [previous, setPrevious] = useState2({ value, disabled, secret });
260
+ if (previous.value !== value || previous.disabled !== disabled || previous.secret !== secret) {
261
+ setPrevious({ value, disabled, secret });
262
+ setRevealedValue(null);
263
+ }
264
+ const revealed = secret && !disabled && revealedValue === value;
265
+ useEffect2(() => {
266
+ if (!revealed || autoHideDelay <= 0)
267
+ return;
268
+ const timer = setTimeout(() => setRevealedValue(null), autoHideDelay);
269
+ return () => clearTimeout(timer);
270
+ }, [revealed, autoHideDelay, value]);
271
+ return /* @__PURE__ */ jsxs2(InputGroup, {
272
+ className: cn("min-w-0", variant === "ghost" && "border-0 bg-transparent shadow-none dark:bg-transparent", className),
273
+ children: [
274
+ /* @__PURE__ */ jsx5(InputGroupInput, {
275
+ className: variant === "ghost" ? "pl-0 font-mono" : undefined,
276
+ "aria-label": secret && !revealed ? `${label}: ${copy.hidden}` : label,
277
+ value,
278
+ type: secret && !revealed ? "password" : "text",
279
+ autoComplete: secret ? "off" : undefined,
280
+ readOnly: true,
281
+ disabled,
282
+ onFocus: (event) => event.currentTarget.select()
283
+ }),
284
+ /* @__PURE__ */ jsxs2(InputGroupAddon, {
285
+ align: "inline-end",
286
+ className: "gap-0",
287
+ children: [
288
+ secret ? /* @__PURE__ */ jsx5(InputGroupButton, {
289
+ type: "button",
290
+ size: "icon-sm",
291
+ variant: "ghost",
292
+ disabled,
293
+ "aria-label": `${revealed ? copy.hide : copy.show} ${label}`,
294
+ "aria-pressed": revealed,
295
+ onClick: () => setRevealedValue(revealed ? null : value),
296
+ children: revealed ? /* @__PURE__ */ jsx5(EyeOff, {
297
+ "aria-hidden": "true"
298
+ }) : /* @__PURE__ */ jsx5(Eye, {
299
+ "aria-hidden": "true"
300
+ })
301
+ }) : null,
302
+ copyable ? /* @__PURE__ */ jsx5(CopyButton, {
303
+ type: "button",
304
+ value,
305
+ valueDescription: label,
306
+ disabled,
307
+ variant: "ghost",
308
+ copyVariant: variant === "ghost" ? "default" : "large",
309
+ locale,
310
+ messages: copyMessages
311
+ }) : null
312
+ ]
313
+ })
314
+ ]
315
+ });
316
+ };
317
+ export {
318
+ CopyValue
319
+ };
@@ -605,21 +605,18 @@ function NotificationListItem({
605
605
  ]
606
606
  });
607
607
  return /* @__PURE__ */ jsxs2("div", {
608
- className: cn("group grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start py-2", unread && "bg-muted/70"),
608
+ className: cn("group relative min-w-0", unread && "bg-muted/70"),
609
609
  "data-unread": unread || undefined,
610
610
  children: [
611
- notification.href || onNavigate ? /* @__PURE__ */ jsx8(Button, {
612
- className: "h-auto w-full min-w-0 justify-start px-3 py-2.5 text-left [overflow-wrap:anywhere] whitespace-normal",
611
+ /* @__PURE__ */ jsx8(Button, {
612
+ className: cn("h-auto w-full min-w-0 cursor-pointer justify-start rounded-none border-0 px-3 py-4 text-left [overflow-wrap:anywhere] whitespace-normal", !notification.archivedAt && onArchive && "pr-14"),
613
613
  onClick: selectNotification,
614
614
  type: "button",
615
615
  variant: "ghost",
616
616
  children: content
617
- }) : /* @__PURE__ */ jsx8("div", {
618
- className: "flex min-w-0 px-3 py-2.5 [overflow-wrap:anywhere]",
619
- children: content
620
617
  }),
621
618
  !notification.archivedAt && onArchive ? /* @__PURE__ */ jsx8("div", {
622
- className: "pt-2 pr-2",
619
+ className: "absolute top-3 right-2",
623
620
  children: /* @__PURE__ */ jsx8(ArchiveButton, {
624
621
  label: labels.archiveItem(notificationTitle(notification)),
625
622
  notificationIds: [notification.id],
@@ -698,21 +698,18 @@ function NotificationListItem({
698
698
  ]
699
699
  });
700
700
  return /* @__PURE__ */ jsxs2("div", {
701
- className: cn("group grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start py-2", unread && "bg-muted/70"),
701
+ className: cn("group relative min-w-0", unread && "bg-muted/70"),
702
702
  "data-unread": unread || undefined,
703
703
  children: [
704
- notification.href || onNavigate ? /* @__PURE__ */ jsx8(Button, {
705
- className: "h-auto w-full min-w-0 justify-start px-3 py-2.5 text-left [overflow-wrap:anywhere] whitespace-normal",
704
+ /* @__PURE__ */ jsx8(Button, {
705
+ className: cn("h-auto w-full min-w-0 cursor-pointer justify-start rounded-none border-0 px-3 py-4 text-left [overflow-wrap:anywhere] whitespace-normal", !notification.archivedAt && onArchive && "pr-14"),
706
706
  onClick: selectNotification,
707
707
  type: "button",
708
708
  variant: "ghost",
709
709
  children: content
710
- }) : /* @__PURE__ */ jsx8("div", {
711
- className: "flex min-w-0 px-3 py-2.5 [overflow-wrap:anywhere]",
712
- children: content
713
710
  }),
714
711
  !notification.archivedAt && onArchive ? /* @__PURE__ */ jsx8("div", {
715
- className: "pt-2 pr-2",
712
+ className: "absolute top-3 right-2",
716
713
  children: /* @__PURE__ */ jsx8(ArchiveButton, {
717
714
  label: labels.archiveItem(notificationTitle(notification)),
718
715
  notificationIds: [notification.id],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/registry",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Tree-shakable KrakStack components and Effect services.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -69,9 +69,9 @@
69
69
  "types": "./dist/components/ui/app-switcher.d.ts",
70
70
  "import": "./dist/components/ui/app-switcher.js"
71
71
  },
72
- "./secret-value": {
73
- "types": "./dist/components/ui/secret-value.d.ts",
74
- "import": "./dist/components/ui/secret-value.js"
72
+ "./copy-value": {
73
+ "types": "./dist/components/ui/copy-value.d.ts",
74
+ "import": "./dist/components/ui/copy-value.js"
75
75
  },
76
76
  "./bulk-list-input": {
77
77
  "types": "./dist/components/ui/bulk-list-input.d.ts",
@@ -402,8 +402,8 @@
402
402
  "cn": "^0.3.0",
403
403
  "drizzle-orm": "^1.0.0-rc.4-5d5b77c",
404
404
  "effect": "^4.1.0",
405
- "lucide-react": "^1.18.0",
406
405
  "libphonenumber-js": "^1.13.16",
406
+ "lucide-react": "^1.18.0",
407
407
  "motion": "^14.12.0",
408
408
  "react": "^19.2.0",
409
409
  "react-dom": "^19.2.0"
@@ -1,216 +0,0 @@
1
- // ../../src/components/ui/secret-value.tsx
2
- import { Eye, EyeOff } from "lucide-react";
3
- import { useEffect as useEffect2, useState as useState2 } from "react";
4
-
5
- // ../../src/components/ui/button.tsx
6
- import { Button as ButtonPrimitive } from "@base-ui/react/button";
7
- import { cva } from "class-variance-authority";
8
-
9
- // ../../src/lib/utils.ts
10
- import { cn } from "cn";
11
-
12
- // ../../src/components/ui/button.tsx
13
- import { jsx } from "react/jsx-runtime";
14
- var buttonVariants = cva("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
15
- variants: {
16
- variant: {
17
- default: "bg-primary text-primary-foreground hover:bg-primary/80",
18
- outline: "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
19
- secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
20
- ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
21
- destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
22
- link: "text-primary underline-offset-4 hover:underline"
23
- },
24
- size: {
25
- default: "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
26
- xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
27
- sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
28
- lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
29
- icon: "size-9",
30
- "icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
31
- "icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
32
- "icon-lg": "size-10"
33
- }
34
- },
35
- defaultVariants: {
36
- variant: "default",
37
- size: "default"
38
- }
39
- });
40
- function Button({
41
- className,
42
- variant = "default",
43
- size = "default",
44
- ...props
45
- }) {
46
- return /* @__PURE__ */ jsx(ButtonPrimitive, {
47
- "data-slot": "button",
48
- className: cn(buttonVariants({ variant, size, className })),
49
- ...props
50
- });
51
- }
52
-
53
- // ../../src/components/ui/copy-button.tsx
54
- import { Check, Copy, TriangleAlert } from "lucide-react";
55
- import { useEffect, useRef, useState } from "react";
56
- import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
57
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
58
- var messages = {
59
- en: { copy: "Copy", copied: "Copied", copyFailed: "Copy failed" },
60
- fr: { copy: "Copier", copied: "Copié", copyFailed: "Échec de la copie" }
61
- };
62
- var copyButtonMessages = (locale = "en", translations) => ({
63
- ...locale.startsWith("fr") ? messages.fr : messages.en,
64
- ...translations?.[locale.split("-")[0] ?? locale],
65
- ...translations?.[locale]
66
- });
67
- function CopyButton({
68
- value,
69
- valueDescription,
70
- copyVariant = "default",
71
- locale: localeOverride,
72
- messages,
73
- onCopied,
74
- onCopyError,
75
- resetDelay = 1500,
76
- disabled,
77
- size,
78
- "aria-label": ariaLabel,
79
- ...props
80
- }) {
81
- const locale = useKrakstackLocale(localeOverride);
82
- const [copyState, setCopyState] = useState("idle");
83
- const copyTimeout = useRef(undefined);
84
- const labels = copyButtonMessages(locale, messages);
85
- const accessibleLabel = ariaLabel ?? (valueDescription ? `${labels.copy} ${valueDescription}` : labels.copy);
86
- const isLarge = copyVariant === "large";
87
- const defaultSize = copyVariant === "sm" ? "icon-xs" : isLarge ? "sm" : "icon-sm";
88
- useEffect(() => {
89
- return () => {
90
- if (copyTimeout.current)
91
- clearTimeout(copyTimeout.current);
92
- };
93
- }, []);
94
- const resetCopyState = () => {
95
- if (copyTimeout.current)
96
- clearTimeout(copyTimeout.current);
97
- copyTimeout.current = setTimeout(() => setCopyState("idle"), resetDelay);
98
- };
99
- const copy = async () => {
100
- try {
101
- await navigator.clipboard.writeText(value);
102
- setCopyState("copied");
103
- onCopied?.();
104
- } catch (error) {
105
- setCopyState("failed");
106
- onCopyError?.(error instanceof Error ? error : new Error(labels.copyFailed, { cause: error }));
107
- }
108
- resetCopyState();
109
- };
110
- const status = copyState === "copied" ? valueDescription ? `${labels.copied}: ${valueDescription}` : labels.copied : copyState === "failed" ? valueDescription ? `${labels.copyFailed}: ${valueDescription}` : labels.copyFailed : "";
111
- return /* @__PURE__ */ jsxs(Button, {
112
- "aria-label": accessibleLabel,
113
- disabled,
114
- onClick: copy,
115
- size: size ?? defaultSize,
116
- ...props,
117
- children: [
118
- /* @__PURE__ */ jsx2("span", {
119
- "aria-live": "polite",
120
- className: "sr-only",
121
- role: "status",
122
- children: status
123
- }),
124
- copyState === "copied" ? /* @__PURE__ */ jsx2(Check, {
125
- "aria-hidden": "true"
126
- }) : null,
127
- copyState === "failed" ? /* @__PURE__ */ jsx2(TriangleAlert, {
128
- "aria-hidden": "true"
129
- }) : null,
130
- copyState === "idle" ? /* @__PURE__ */ jsx2(Copy, {
131
- "aria-hidden": "true"
132
- }) : null,
133
- isLarge ? /* @__PURE__ */ jsx2("span", {
134
- children: labels.copy
135
- }) : null
136
- ]
137
- });
138
- }
139
-
140
- // ../../src/components/ui/secret-value.tsx
141
- import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
142
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
143
- var labels = {
144
- en: { show: "Show", hide: "Hide", hidden: "Hidden value" },
145
- fr: { show: "Afficher", hide: "Masquer", hidden: "Valeur masquée" }
146
- };
147
- var SecretValue = ({
148
- value,
149
- label,
150
- disabled,
151
- copyable = true,
152
- autoHideDelay = 0,
153
- className,
154
- locale: override,
155
- messages,
156
- copyMessages
157
- }) => {
158
- const locale = useKrakstackLocale2(override);
159
- const copy = {
160
- ...locale.startsWith("fr") ? labels.fr : labels.en,
161
- ...messages?.[locale.split("-")[0] ?? locale],
162
- ...messages?.[locale]
163
- };
164
- const [revealedValue, setRevealedValue] = useState2(null);
165
- const [previous, setPrevious] = useState2({ value, disabled });
166
- if (previous.value !== value || previous.disabled !== disabled) {
167
- setPrevious({ value, disabled });
168
- setRevealedValue(null);
169
- }
170
- const revealed = !disabled && revealedValue === value;
171
- useEffect2(() => {
172
- if (!revealed || autoHideDelay <= 0)
173
- return;
174
- const timer = setTimeout(() => setRevealedValue(null), autoHideDelay);
175
- return () => clearTimeout(timer);
176
- }, [revealed, autoHideDelay, value]);
177
- return /* @__PURE__ */ jsxs2("div", {
178
- className: cn("flex min-w-0 items-center gap-2", className),
179
- children: [
180
- /* @__PURE__ */ jsx3("code", {
181
- className: "min-w-0 flex-1 text-sm break-all",
182
- "aria-label": revealed ? undefined : `${label}: ${copy.hidden}`,
183
- children: revealed ? value : /* @__PURE__ */ jsx3("span", {
184
- "aria-hidden": "true",
185
- children: "••••••••"
186
- })
187
- }),
188
- /* @__PURE__ */ jsx3(Button, {
189
- type: "button",
190
- size: "icon-sm",
191
- variant: "ghost",
192
- disabled,
193
- "aria-label": `${revealed ? copy.hide : copy.show} ${label}`,
194
- "aria-pressed": revealed,
195
- onClick: () => setRevealedValue(revealed ? null : value),
196
- children: revealed ? /* @__PURE__ */ jsx3(EyeOff, {
197
- "aria-hidden": "true"
198
- }) : /* @__PURE__ */ jsx3(Eye, {
199
- "aria-hidden": "true"
200
- })
201
- }),
202
- copyable ? /* @__PURE__ */ jsx3(CopyButton, {
203
- type: "button",
204
- value,
205
- valueDescription: label,
206
- disabled,
207
- variant: "ghost",
208
- locale,
209
- messages: copyMessages
210
- }) : null
211
- ]
212
- });
213
- };
214
- export {
215
- SecretValue
216
- };