@krak-stack/registry 0.8.3 → 0.9.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +10 -5
  2. package/dist/components/ui/animated-list.js +5 -0
  3. package/dist/components/ui/app-switcher.d.ts +2 -1
  4. package/dist/components/ui/app-switcher.js +5 -1
  5. package/dist/components/ui/async-action-button.d.ts +2 -1
  6. package/dist/components/ui/async-action-button.js +3 -1
  7. package/dist/components/ui/bulk-list-input.d.ts +2 -1
  8. package/dist/components/ui/bulk-list-input.js +6 -1
  9. package/dist/components/ui/calendar.d.ts +10 -0
  10. package/dist/components/ui/choice-cards.d.ts +1 -0
  11. package/dist/components/ui/choice-cards.js +7 -1
  12. package/dist/components/ui/color-picker.d.ts +2 -1
  13. package/dist/components/ui/color-picker.js +4 -1
  14. package/dist/components/ui/cron-expression-editor.d.ts +3 -1
  15. package/dist/components/ui/cron-expression-editor.js +13 -3
  16. package/dist/components/ui/danger-confirmation.d.ts +1 -0
  17. package/dist/components/ui/danger-confirmation.js +5 -1
  18. package/dist/components/ui/date-picker.d.ts +33 -0
  19. package/dist/components/ui/date-picker.js +470 -0
  20. package/dist/components/ui/date-picker.schema.d.ts +9 -0
  21. package/dist/components/ui/editable-text.js +8 -1
  22. package/dist/components/ui/form.d.ts +5 -5
  23. package/dist/components/ui/image-crop-editor.js +10 -1
  24. package/dist/components/ui/phone-number-input.d.ts +3 -1
  25. package/dist/components/ui/phone-number-input.js +53 -13
  26. package/dist/components/ui/phone-number-input.schema.d.ts +7 -0
  27. package/dist/components/ui/{copy-value.d.ts → secret-value.d.ts} +4 -6
  28. package/dist/components/ui/secret-value.js +222 -0
  29. package/dist/components/ui/select-with-custom-input.d.ts +36 -0
  30. package/dist/components/ui/select-with-custom-input.js +275 -0
  31. package/dist/components/ui/sidebar-layout.js +1 -0
  32. package/dist/components/ui/stepper.js +8 -0
  33. package/dist/components/ui/timezone-select.d.ts +2 -1
  34. package/dist/components/ui/timezone-select.js +5 -1
  35. package/dist/components/ui/toast.d.ts +18 -0
  36. package/dist/components/ui/toast.js +121 -0
  37. package/dist/components/ui/unsaved-changes-guard.d.ts +2 -1
  38. package/dist/components/ui/unsaved-changes-guard.js +4 -1
  39. package/dist/components/ui/upload-attachment.js +3 -0
  40. package/dist/lib/docs.js +1 -0
  41. package/package.json +19 -5
  42. package/dist/components/ui/copy-value.js +0 -319
@@ -1,319 +0,0 @@
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
- };