@krak-stack/registry 0.4.0 → 0.5.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/CHANGELOG.md +18 -0
- package/dist/components/ui/app-switcher.d.ts +25 -0
- package/dist/components/ui/app-switcher.js +233 -0
- package/dist/components/ui/bulk-list-input.d.ts +24 -0
- package/dist/components/ui/bulk-list-input.js +152 -0
- package/dist/components/ui/choice-cards.d.ts +32 -0
- package/dist/components/ui/choice-cards.js +88 -0
- package/dist/components/ui/color-picker.js +3 -2
- package/dist/components/ui/effect-form.js +2 -2
- package/dist/components/ui/form.js +2 -2
- package/dist/components/ui/icon-input.js +2 -2
- package/dist/components/ui/secret-value.d.ts +19 -0
- package/dist/components/ui/secret-value.js +216 -0
- package/dist/components/ui/upload-attachment.d.ts +39 -0
- package/dist/components/ui/upload-attachment.js +286 -0
- package/dist/components/ui/virtualized-combobox.js +2 -2
- package/package.json +21 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @krak-stack/registry
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b3cb799: Add App Switcher, Secret Value, Bulk List Input, Choice Cards, and Upload Attachment as standalone components with package exports and English/French documentation.
|
|
8
|
+
|
|
3
9
|
## 0.4.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -22,6 +28,18 @@
|
|
|
22
28
|
|
|
23
29
|
- 86fc54f: Add a domain-neutral Stepper and optional StepperContent with controlled navigation, underline/labelled/segmented presentations, explicit completion/error states, bilingual defaults, and reduced-motion-aware directional slide transitions inside a stationary frame.
|
|
24
30
|
|
|
31
|
+
## 0.2.2
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Prevent virtualized combobox group headings from collapsing into options after asynchronous search results refresh.
|
|
36
|
+
|
|
37
|
+
## 0.2.1
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Keep the color picker panel full-width inside its popup, with even padding and a HEX value centered beneath it. Prevent react-colorful's injected styles from overriding panel, hue slider, and pointer dimensions.
|
|
42
|
+
|
|
25
43
|
## 0.2.0
|
|
26
44
|
|
|
27
45
|
### Minor Changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type AppSwitcherItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
href: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
badge?: ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type AppSwitcherMessages = {
|
|
12
|
+
label: string;
|
|
13
|
+
current: string;
|
|
14
|
+
empty: string;
|
|
15
|
+
};
|
|
16
|
+
export type AppSwitcherProps = {
|
|
17
|
+
items: readonly AppSwitcherItem[];
|
|
18
|
+
currentApp?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
locale?: string;
|
|
22
|
+
messages?: Partial<Record<string, Partial<AppSwitcherMessages>>>;
|
|
23
|
+
};
|
|
24
|
+
/** Navigation only: the host supplies trusted destinations and available apps. */
|
|
25
|
+
export declare const AppSwitcher: ({ items, currentApp, disabled, className, locale: override, messages, }: AppSwitcherProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// ../../src/components/ui/app-switcher.tsx
|
|
2
|
+
import { Check, Grid2X2 } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
// ../../src/components/ui/button.tsx
|
|
5
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
|
|
8
|
+
// ../../src/lib/utils.ts
|
|
9
|
+
import { cn } from "cn";
|
|
10
|
+
|
|
11
|
+
// ../../src/components/ui/button.tsx
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
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", {
|
|
14
|
+
variants: {
|
|
15
|
+
variant: {
|
|
16
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
17
|
+
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",
|
|
18
|
+
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",
|
|
19
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
20
|
+
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",
|
|
21
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
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",
|
|
25
|
+
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",
|
|
26
|
+
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",
|
|
27
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
28
|
+
icon: "size-9",
|
|
29
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
30
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
31
|
+
"icon-lg": "size-10"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
variant: "default",
|
|
36
|
+
size: "default"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
function Button({
|
|
40
|
+
className,
|
|
41
|
+
variant = "default",
|
|
42
|
+
size = "default",
|
|
43
|
+
...props
|
|
44
|
+
}) {
|
|
45
|
+
return /* @__PURE__ */ jsx(ButtonPrimitive, {
|
|
46
|
+
"data-slot": "button",
|
|
47
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ../../src/components/ui/dropdown-menu.tsx
|
|
53
|
+
import { Menu as MenuPrimitive } from "@base-ui/react/menu";
|
|
54
|
+
import { ChevronRightIcon, CheckIcon } from "lucide-react";
|
|
55
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
56
|
+
function DropdownMenu({ ...props }) {
|
|
57
|
+
return /* @__PURE__ */ jsx2(MenuPrimitive.Root, {
|
|
58
|
+
"data-slot": "dropdown-menu",
|
|
59
|
+
...props
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function DropdownMenuTrigger({ ...props }) {
|
|
63
|
+
return /* @__PURE__ */ jsx2(MenuPrimitive.Trigger, {
|
|
64
|
+
"data-slot": "dropdown-menu-trigger",
|
|
65
|
+
...props
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function DropdownMenuContent({
|
|
69
|
+
align = "start",
|
|
70
|
+
alignOffset = 0,
|
|
71
|
+
side = "bottom",
|
|
72
|
+
sideOffset = 4,
|
|
73
|
+
className,
|
|
74
|
+
...props
|
|
75
|
+
}) {
|
|
76
|
+
return /* @__PURE__ */ jsx2(MenuPrimitive.Portal, {
|
|
77
|
+
children: /* @__PURE__ */ jsx2(MenuPrimitive.Positioner, {
|
|
78
|
+
className: "isolate z-50 outline-none",
|
|
79
|
+
align,
|
|
80
|
+
alignOffset,
|
|
81
|
+
side,
|
|
82
|
+
sideOffset,
|
|
83
|
+
children: /* @__PURE__ */ jsx2(MenuPrimitive.Popup, {
|
|
84
|
+
"data-slot": "dropdown-menu-content",
|
|
85
|
+
className: cn("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95", className),
|
|
86
|
+
...props
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function DropdownMenuGroup({ ...props }) {
|
|
92
|
+
return /* @__PURE__ */ jsx2(MenuPrimitive.Group, {
|
|
93
|
+
"data-slot": "dropdown-menu-group",
|
|
94
|
+
...props
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function DropdownMenuLabel({
|
|
98
|
+
className,
|
|
99
|
+
inset,
|
|
100
|
+
...props
|
|
101
|
+
}) {
|
|
102
|
+
return /* @__PURE__ */ jsx2(MenuPrimitive.GroupLabel, {
|
|
103
|
+
"data-slot": "dropdown-menu-label",
|
|
104
|
+
"data-inset": inset,
|
|
105
|
+
className: cn("px-2 py-1.5 text-xs font-medium text-muted-foreground data-inset:pl-8", className),
|
|
106
|
+
...props
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function DropdownMenuItem({
|
|
110
|
+
className,
|
|
111
|
+
inset,
|
|
112
|
+
variant = "default",
|
|
113
|
+
...props
|
|
114
|
+
}) {
|
|
115
|
+
return /* @__PURE__ */ jsx2(MenuPrimitive.Item, {
|
|
116
|
+
"data-slot": "dropdown-menu-item",
|
|
117
|
+
"data-inset": inset,
|
|
118
|
+
"data-variant": variant,
|
|
119
|
+
className: cn("group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive", className),
|
|
120
|
+
...props
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ../../src/components/ui/app-switcher.tsx
|
|
125
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
126
|
+
import { jsx as jsx3, jsxs as jsxs2, Fragment } from "react/jsx-runtime";
|
|
127
|
+
var labels = {
|
|
128
|
+
en: {
|
|
129
|
+
label: "Switch application",
|
|
130
|
+
current: "Current application",
|
|
131
|
+
empty: "No applications available"
|
|
132
|
+
},
|
|
133
|
+
fr: {
|
|
134
|
+
label: "Changer d’application",
|
|
135
|
+
current: "Application actuelle",
|
|
136
|
+
empty: "Aucune application disponible"
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var AppSwitcher = ({
|
|
140
|
+
items,
|
|
141
|
+
currentApp,
|
|
142
|
+
disabled,
|
|
143
|
+
className,
|
|
144
|
+
locale: override,
|
|
145
|
+
messages
|
|
146
|
+
}) => {
|
|
147
|
+
const locale = useKrakstackLocale(override);
|
|
148
|
+
const copy = {
|
|
149
|
+
...locale.startsWith("fr") ? labels.fr : labels.en,
|
|
150
|
+
...messages?.[locale.split("-")[0] ?? locale],
|
|
151
|
+
...messages?.[locale]
|
|
152
|
+
};
|
|
153
|
+
return /* @__PURE__ */ jsxs2(DropdownMenu, {
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ jsx3(DropdownMenuTrigger, {
|
|
156
|
+
render: /* @__PURE__ */ jsx3(Button, {
|
|
157
|
+
type: "button",
|
|
158
|
+
variant: "outline",
|
|
159
|
+
size: "icon",
|
|
160
|
+
className,
|
|
161
|
+
disabled,
|
|
162
|
+
"aria-label": copy.label
|
|
163
|
+
}),
|
|
164
|
+
children: /* @__PURE__ */ jsx3(Grid2X2, {
|
|
165
|
+
"aria-hidden": "true"
|
|
166
|
+
})
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ jsx3(DropdownMenuContent, {
|
|
169
|
+
align: "end",
|
|
170
|
+
className: "w-80 max-w-[calc(100vw-2rem)]",
|
|
171
|
+
children: /* @__PURE__ */ jsxs2(DropdownMenuGroup, {
|
|
172
|
+
children: [
|
|
173
|
+
/* @__PURE__ */ jsx3(DropdownMenuLabel, {
|
|
174
|
+
children: copy.label
|
|
175
|
+
}),
|
|
176
|
+
items.length === 0 ? /* @__PURE__ */ jsx3("p", {
|
|
177
|
+
className: "text-muted-foreground px-2 py-3 text-sm",
|
|
178
|
+
children: copy.empty
|
|
179
|
+
}) : null,
|
|
180
|
+
items.map((item) => /* @__PURE__ */ jsxs2(DropdownMenuItem, {
|
|
181
|
+
disabled: item.disabled,
|
|
182
|
+
render: /* @__PURE__ */ jsx3("a", {
|
|
183
|
+
href: item.disabled ? undefined : item.href,
|
|
184
|
+
"aria-current": item.id === currentApp ? "page" : undefined
|
|
185
|
+
}),
|
|
186
|
+
className: "gap-3 py-3",
|
|
187
|
+
children: [
|
|
188
|
+
item.icon ? /* @__PURE__ */ jsx3("span", {
|
|
189
|
+
"aria-hidden": "true",
|
|
190
|
+
className: "flex size-9 shrink-0 items-center justify-center rounded-md border",
|
|
191
|
+
children: item.icon
|
|
192
|
+
}) : null,
|
|
193
|
+
/* @__PURE__ */ jsxs2("span", {
|
|
194
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
195
|
+
children: [
|
|
196
|
+
/* @__PURE__ */ jsxs2("span", {
|
|
197
|
+
className: "flex items-center gap-2",
|
|
198
|
+
children: [
|
|
199
|
+
/* @__PURE__ */ jsx3("span", {
|
|
200
|
+
className: "truncate font-medium",
|
|
201
|
+
children: item.label
|
|
202
|
+
}),
|
|
203
|
+
item.badge
|
|
204
|
+
]
|
|
205
|
+
}),
|
|
206
|
+
item.description ? /* @__PURE__ */ jsx3("span", {
|
|
207
|
+
className: "text-muted-foreground text-xs",
|
|
208
|
+
children: item.description
|
|
209
|
+
}) : null
|
|
210
|
+
]
|
|
211
|
+
}),
|
|
212
|
+
item.id === currentApp ? /* @__PURE__ */ jsxs2(Fragment, {
|
|
213
|
+
children: [
|
|
214
|
+
/* @__PURE__ */ jsx3(Check, {
|
|
215
|
+
"aria-hidden": "true"
|
|
216
|
+
}),
|
|
217
|
+
/* @__PURE__ */ jsx3("span", {
|
|
218
|
+
className: "sr-only",
|
|
219
|
+
children: copy.current
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
}) : null
|
|
223
|
+
]
|
|
224
|
+
}, item.id))
|
|
225
|
+
]
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
export {
|
|
232
|
+
AppSwitcher
|
|
233
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
import { Textarea } from "./textarea.js";
|
|
3
|
+
export type BulkListResult = {
|
|
4
|
+
items: string[];
|
|
5
|
+
duplicates: number;
|
|
6
|
+
};
|
|
7
|
+
/** Text tokenization, not CSV parsing or domain validation. */
|
|
8
|
+
export declare const parseBulkList: (text: string, options?: {
|
|
9
|
+
separator?: RegExp;
|
|
10
|
+
normalize?: (value: string) => string;
|
|
11
|
+
}) => BulkListResult;
|
|
12
|
+
export type BulkListInputProps = Omit<ComponentProps<typeof Textarea>, "value" | "defaultValue" | "onChange" | "children"> & {
|
|
13
|
+
value: string;
|
|
14
|
+
onValueChange: (value: string) => void;
|
|
15
|
+
label?: ReactNode;
|
|
16
|
+
files?: {
|
|
17
|
+
accept: string;
|
|
18
|
+
label: string;
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
onSelect: (files: readonly File[]) => void;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare const BulkListInput: ({ value, onValueChange, label, files, disabled, readOnly, ...props }: BulkListInputProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// ../../src/components/ui/bulk-list-input.tsx
|
|
2
|
+
import { Upload } from "lucide-react";
|
|
3
|
+
import { useRef } 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/textarea.tsx
|
|
54
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
55
|
+
function Textarea({ className, ...props }) {
|
|
56
|
+
return /* @__PURE__ */ jsx2("textarea", {
|
|
57
|
+
"data-slot": "textarea",
|
|
58
|
+
className: cn("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 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),
|
|
59
|
+
...props
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ../../src/components/ui/bulk-list-input.tsx
|
|
64
|
+
import { jsx as jsx3, jsxs, Fragment } from "react/jsx-runtime";
|
|
65
|
+
var parseBulkList = (text, options = {}) => {
|
|
66
|
+
const values = text.split(options.separator ?? /[,\r\n]+/).map((value) => value.trim()).filter(Boolean);
|
|
67
|
+
const seen = new Set;
|
|
68
|
+
const items = values.filter((value) => {
|
|
69
|
+
const key = options.normalize?.(value) ?? value;
|
|
70
|
+
if (seen.has(key))
|
|
71
|
+
return false;
|
|
72
|
+
seen.add(key);
|
|
73
|
+
return true;
|
|
74
|
+
});
|
|
75
|
+
return { items, duplicates: values.length - items.length };
|
|
76
|
+
};
|
|
77
|
+
var BulkListInput = ({
|
|
78
|
+
value,
|
|
79
|
+
onValueChange,
|
|
80
|
+
label,
|
|
81
|
+
files,
|
|
82
|
+
disabled,
|
|
83
|
+
readOnly,
|
|
84
|
+
...props
|
|
85
|
+
}) => {
|
|
86
|
+
const input = useRef(null);
|
|
87
|
+
const filesDisabled = disabled || readOnly || files?.disabled;
|
|
88
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
89
|
+
className: "flex min-w-0 flex-col gap-3",
|
|
90
|
+
onDragOver: (event) => {
|
|
91
|
+
if (files && event.dataTransfer.types.includes("Files"))
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
},
|
|
94
|
+
onDrop: (event) => {
|
|
95
|
+
if (!files || !event.dataTransfer.files.length)
|
|
96
|
+
return;
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
if (!filesDisabled)
|
|
99
|
+
files.onSelect(Array.from(event.dataTransfer.files));
|
|
100
|
+
},
|
|
101
|
+
children: [
|
|
102
|
+
label || files ? /* @__PURE__ */ jsxs("div", {
|
|
103
|
+
className: "flex flex-wrap items-center justify-between gap-2",
|
|
104
|
+
children: [
|
|
105
|
+
label,
|
|
106
|
+
files ? /* @__PURE__ */ jsxs(Fragment, {
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ jsx3("input", {
|
|
109
|
+
ref: input,
|
|
110
|
+
type: "file",
|
|
111
|
+
className: "hidden",
|
|
112
|
+
accept: files.accept,
|
|
113
|
+
multiple: files.multiple,
|
|
114
|
+
disabled: filesDisabled,
|
|
115
|
+
onChange: (event) => {
|
|
116
|
+
const selected = Array.from(event.target.files ?? []);
|
|
117
|
+
event.target.value = "";
|
|
118
|
+
if (selected.length && !filesDisabled)
|
|
119
|
+
files.onSelect(selected);
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
123
|
+
type: "button",
|
|
124
|
+
variant: "outline",
|
|
125
|
+
size: "sm",
|
|
126
|
+
disabled: filesDisabled,
|
|
127
|
+
onClick: () => input.current?.click(),
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ jsx3(Upload, {
|
|
130
|
+
"aria-hidden": "true"
|
|
131
|
+
}),
|
|
132
|
+
files.label
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
}) : null
|
|
137
|
+
]
|
|
138
|
+
}) : null,
|
|
139
|
+
/* @__PURE__ */ jsx3(Textarea, {
|
|
140
|
+
...props,
|
|
141
|
+
value,
|
|
142
|
+
disabled,
|
|
143
|
+
readOnly,
|
|
144
|
+
onChange: (event) => onValueChange(event.target.value)
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
BulkListInput,
|
|
151
|
+
parseBulkList
|
|
152
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type ChoiceCardOption = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type ChoiceCardsBaseProps = {
|
|
10
|
+
name: string;
|
|
11
|
+
label: ReactNode;
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
error?: ReactNode;
|
|
14
|
+
options: readonly ChoiceCardOption[];
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
onBlur?: () => void;
|
|
18
|
+
};
|
|
19
|
+
export type ChoiceCardsProps = ChoiceCardsBaseProps & ({
|
|
20
|
+
mode: "single";
|
|
21
|
+
value: string | null;
|
|
22
|
+
onValueChange: (value: string) => void;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
mode: "multiple";
|
|
26
|
+
value: readonly string[];
|
|
27
|
+
onValueChange: (value: string[]) => void;
|
|
28
|
+
required?: never;
|
|
29
|
+
});
|
|
30
|
+
/** Native inputs retain browser keyboard navigation and form submission. */
|
|
31
|
+
export declare const ChoiceCards: (props: ChoiceCardsProps) => import("react").JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// ../../src/components/ui/choice-cards.tsx
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
|
|
4
|
+
// ../../src/lib/utils.ts
|
|
5
|
+
import { cn } from "cn";
|
|
6
|
+
|
|
7
|
+
// ../../src/components/ui/choice-cards.tsx
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var ChoiceCards = (props) => {
|
|
10
|
+
const id = useId();
|
|
11
|
+
const describedBy = [
|
|
12
|
+
props.description ? `${id}-description` : undefined,
|
|
13
|
+
props.error ? `${id}-error` : undefined
|
|
14
|
+
].filter(Boolean).join(" ") || undefined;
|
|
15
|
+
return /* @__PURE__ */ jsxs("fieldset", {
|
|
16
|
+
disabled: props.disabled,
|
|
17
|
+
"aria-describedby": describedBy,
|
|
18
|
+
"aria-invalid": props.error ? true : undefined,
|
|
19
|
+
className: "min-w-0 space-y-3",
|
|
20
|
+
onBlur: (event) => {
|
|
21
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
22
|
+
props.onBlur?.();
|
|
23
|
+
},
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ jsx("legend", {
|
|
26
|
+
className: "text-sm font-medium",
|
|
27
|
+
children: props.label
|
|
28
|
+
}),
|
|
29
|
+
props.description ? /* @__PURE__ */ jsx("p", {
|
|
30
|
+
id: `${id}-description`,
|
|
31
|
+
className: "text-muted-foreground text-sm",
|
|
32
|
+
children: props.description
|
|
33
|
+
}) : null,
|
|
34
|
+
/* @__PURE__ */ jsx("div", {
|
|
35
|
+
className: cn("grid gap-3 sm:grid-cols-2", props.className),
|
|
36
|
+
children: props.options.map((option) => /* @__PURE__ */ jsxs("label", {
|
|
37
|
+
className: "bg-card has-checked:border-primary has-checked:bg-primary/5 has-focus-visible:ring-ring flex cursor-pointer items-start gap-3 rounded-lg border p-4 text-sm transition-colors has-focus-visible:ring-2 has-disabled:cursor-not-allowed has-disabled:opacity-50",
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx("input", {
|
|
40
|
+
type: props.mode === "single" ? "radio" : "checkbox",
|
|
41
|
+
name: props.name,
|
|
42
|
+
value: option.value,
|
|
43
|
+
disabled: option.disabled,
|
|
44
|
+
required: props.mode === "single" ? props.required : undefined,
|
|
45
|
+
checked: props.mode === "single" ? props.value === option.value : props.value.includes(option.value),
|
|
46
|
+
"aria-invalid": props.error ? true : undefined,
|
|
47
|
+
"aria-describedby": describedBy,
|
|
48
|
+
className: "accent-primary mt-0.5 size-4 shrink-0",
|
|
49
|
+
onChange: (event) => {
|
|
50
|
+
if (props.mode === "single")
|
|
51
|
+
props.onValueChange(option.value);
|
|
52
|
+
else
|
|
53
|
+
props.onValueChange(event.target.checked ? [...props.value, option.value] : props.value.filter((value) => value !== option.value));
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
option.icon ? /* @__PURE__ */ jsx("span", {
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
className: "shrink-0 [&_svg]:size-5",
|
|
59
|
+
children: option.icon
|
|
60
|
+
}) : null,
|
|
61
|
+
/* @__PURE__ */ jsxs("span", {
|
|
62
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ jsx("span", {
|
|
65
|
+
className: "font-medium",
|
|
66
|
+
children: option.label
|
|
67
|
+
}),
|
|
68
|
+
option.description ? /* @__PURE__ */ jsx("span", {
|
|
69
|
+
className: "text-muted-foreground",
|
|
70
|
+
children: option.description
|
|
71
|
+
}) : null
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
}, option.value))
|
|
76
|
+
}),
|
|
77
|
+
props.error ? /* @__PURE__ */ jsx("p", {
|
|
78
|
+
id: `${id}-error`,
|
|
79
|
+
role: "alert",
|
|
80
|
+
className: "text-destructive text-sm",
|
|
81
|
+
children: props.error
|
|
82
|
+
}) : null
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
export {
|
|
87
|
+
ChoiceCards
|
|
88
|
+
};
|
|
@@ -256,10 +256,11 @@ var ColorPanel = ({
|
|
|
256
256
|
}, [copy.saturation, copy.hue, copy.saturationValue, copy.brightnessValue]);
|
|
257
257
|
return /* @__PURE__ */ jsx5("div", {
|
|
258
258
|
ref,
|
|
259
|
-
className: "[&_.react-
|
|
259
|
+
className: "[&_.react-colorful__hue]:h-4! [&_.react-colorful__pointer]:size-5!",
|
|
260
260
|
children: /* @__PURE__ */ jsx5(HexColorPicker, {
|
|
261
261
|
color,
|
|
262
|
-
onChange
|
|
262
|
+
onChange,
|
|
263
|
+
style: { width: "100%", height: "12rem" }
|
|
263
264
|
})
|
|
264
265
|
});
|
|
265
266
|
};
|
|
@@ -995,7 +995,7 @@ var VirtualizedComboboxList = ({
|
|
|
995
995
|
}));
|
|
996
996
|
const selectedEntries = itemEntries.filter(({ item }) => selectedValues.has(item.value));
|
|
997
997
|
const availableEntries = itemEntries.filter(({ item }) => !selectedValues.has(item.value));
|
|
998
|
-
const entries = groupSelections ? [
|
|
998
|
+
const entries = filteredItems.length === 0 ? [] : groupSelections ? [
|
|
999
999
|
...selectedEntries.length > 0 ? [
|
|
1000
1000
|
{
|
|
1001
1001
|
kind: "group",
|
|
@@ -1114,7 +1114,7 @@ var VirtualizedComboboxContent = ({
|
|
|
1114
1114
|
side: "bottom",
|
|
1115
1115
|
sideOffset: 6,
|
|
1116
1116
|
children: /* @__PURE__ */ jsxs5(ComboboxPrimitive.Popup, {
|
|
1117
|
-
className: cn("
|
|
1117
|
+
className: cn("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-in-95 relative flex max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) flex-col overflow-hidden rounded-md shadow-md ring-1 duration-100", contentClassName),
|
|
1118
1118
|
children: [
|
|
1119
1119
|
/* @__PURE__ */ jsx12("div", {
|
|
1120
1120
|
className: "min-w-0 shrink-0 p-1 pb-0",
|
|
@@ -999,7 +999,7 @@ var VirtualizedComboboxList = ({
|
|
|
999
999
|
}));
|
|
1000
1000
|
const selectedEntries = itemEntries.filter(({ item }) => selectedValues.has(item.value));
|
|
1001
1001
|
const availableEntries = itemEntries.filter(({ item }) => !selectedValues.has(item.value));
|
|
1002
|
-
const entries = groupSelections ? [
|
|
1002
|
+
const entries = filteredItems.length === 0 ? [] : groupSelections ? [
|
|
1003
1003
|
...selectedEntries.length > 0 ? [
|
|
1004
1004
|
{
|
|
1005
1005
|
kind: "group",
|
|
@@ -1118,7 +1118,7 @@ var VirtualizedComboboxContent = ({
|
|
|
1118
1118
|
side: "bottom",
|
|
1119
1119
|
sideOffset: 6,
|
|
1120
1120
|
children: /* @__PURE__ */ jsxs5(ComboboxPrimitive.Popup, {
|
|
1121
|
-
className: cn("
|
|
1121
|
+
className: cn("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-in-95 relative flex max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) flex-col overflow-hidden rounded-md shadow-md ring-1 duration-100", contentClassName),
|
|
1122
1122
|
children: [
|
|
1123
1123
|
/* @__PURE__ */ jsx12("div", {
|
|
1124
1124
|
className: "min-w-0 shrink-0 p-1 pb-0",
|
|
@@ -172,7 +172,7 @@ var VirtualizedComboboxList = ({
|
|
|
172
172
|
}));
|
|
173
173
|
const selectedEntries = itemEntries.filter(({ item }) => selectedValues.has(item.value));
|
|
174
174
|
const availableEntries = itemEntries.filter(({ item }) => !selectedValues.has(item.value));
|
|
175
|
-
const entries = groupSelections ? [
|
|
175
|
+
const entries = filteredItems.length === 0 ? [] : groupSelections ? [
|
|
176
176
|
...selectedEntries.length > 0 ? [
|
|
177
177
|
{
|
|
178
178
|
kind: "group",
|
|
@@ -291,7 +291,7 @@ var VirtualizedComboboxContent = ({
|
|
|
291
291
|
side: "bottom",
|
|
292
292
|
sideOffset: 6,
|
|
293
293
|
children: /* @__PURE__ */ jsxs(ComboboxPrimitive.Popup, {
|
|
294
|
-
className: cn("
|
|
294
|
+
className: cn("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-in-95 relative flex max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) flex-col overflow-hidden rounded-md shadow-md ring-1 duration-100", contentClassName),
|
|
295
295
|
children: [
|
|
296
296
|
/* @__PURE__ */ jsx4("div", {
|
|
297
297
|
className: "min-w-0 shrink-0 p-1 pb-0",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type CopyButtonMessageTranslations } from "./copy-button.js";
|
|
2
|
+
export type SecretValueMessages = {
|
|
3
|
+
show: string;
|
|
4
|
+
hide: string;
|
|
5
|
+
hidden: string;
|
|
6
|
+
};
|
|
7
|
+
export type SecretValueProps = {
|
|
8
|
+
value: string;
|
|
9
|
+
label: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
copyable?: boolean;
|
|
12
|
+
autoHideDelay?: number;
|
|
13
|
+
className?: string;
|
|
14
|
+
locale?: string;
|
|
15
|
+
messages?: Partial<Record<string, Partial<SecretValueMessages>>>;
|
|
16
|
+
copyMessages?: CopyButtonMessageTranslations;
|
|
17
|
+
};
|
|
18
|
+
/** 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;
|
|
@@ -0,0 +1,216 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type UploadAttachmentState = {
|
|
2
|
+
status: "idle";
|
|
3
|
+
} | {
|
|
4
|
+
status: "uploading";
|
|
5
|
+
progress?: number;
|
|
6
|
+
} | {
|
|
7
|
+
status: "processing";
|
|
8
|
+
} | {
|
|
9
|
+
status: "done";
|
|
10
|
+
} | {
|
|
11
|
+
status: "cancelled";
|
|
12
|
+
} | {
|
|
13
|
+
status: "error";
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
export type UploadAttachmentMessages = {
|
|
17
|
+
idle: string;
|
|
18
|
+
uploading: string;
|
|
19
|
+
processing: string;
|
|
20
|
+
done: string;
|
|
21
|
+
cancelled: string;
|
|
22
|
+
cancel: string;
|
|
23
|
+
retry: string;
|
|
24
|
+
remove: string;
|
|
25
|
+
};
|
|
26
|
+
export type UploadAttachmentProps = {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
state: UploadAttachmentState;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
onCancel?: () => void;
|
|
32
|
+
onRetry?: () => void;
|
|
33
|
+
onRemove?: () => void;
|
|
34
|
+
className?: string;
|
|
35
|
+
locale?: string;
|
|
36
|
+
messages?: Partial<Record<string, Partial<UploadAttachmentMessages>>>;
|
|
37
|
+
};
|
|
38
|
+
/** Controlled presentation. The host owns transport, cancellation and retry policy. */
|
|
39
|
+
export declare const UploadAttachment: ({ name, description, state, disabled, onCancel, onRetry, onRemove, className, locale: override, messages, }: UploadAttachmentProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
// ../../src/components/ui/upload-attachment.tsx
|
|
2
|
+
import {
|
|
3
|
+
Check,
|
|
4
|
+
File,
|
|
5
|
+
LoaderCircle,
|
|
6
|
+
RotateCcw,
|
|
7
|
+
TriangleAlert,
|
|
8
|
+
X
|
|
9
|
+
} from "lucide-react";
|
|
10
|
+
import { useId } from "react";
|
|
11
|
+
|
|
12
|
+
// ../../src/components/ui/attachment.tsx
|
|
13
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
14
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
15
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
16
|
+
|
|
17
|
+
// ../../src/lib/utils.ts
|
|
18
|
+
import { cn } from "cn";
|
|
19
|
+
|
|
20
|
+
// ../../src/components/ui/button.tsx
|
|
21
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
22
|
+
import { cva } from "class-variance-authority";
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
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", {
|
|
25
|
+
variants: {
|
|
26
|
+
variant: {
|
|
27
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
28
|
+
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",
|
|
29
|
+
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",
|
|
30
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
31
|
+
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",
|
|
32
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
33
|
+
},
|
|
34
|
+
size: {
|
|
35
|
+
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",
|
|
36
|
+
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",
|
|
37
|
+
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",
|
|
38
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
39
|
+
icon: "size-9",
|
|
40
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
41
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
42
|
+
"icon-lg": "size-10"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
defaultVariants: {
|
|
46
|
+
variant: "default",
|
|
47
|
+
size: "default"
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
function Button({
|
|
51
|
+
className,
|
|
52
|
+
variant = "default",
|
|
53
|
+
size = "default",
|
|
54
|
+
...props
|
|
55
|
+
}) {
|
|
56
|
+
return /* @__PURE__ */ jsx(ButtonPrimitive, {
|
|
57
|
+
"data-slot": "button",
|
|
58
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
59
|
+
...props
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ../../src/components/ui/attachment.tsx
|
|
64
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
65
|
+
var attachmentVariants = cva2("group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed", {
|
|
66
|
+
variants: {
|
|
67
|
+
size: {
|
|
68
|
+
default: "gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2",
|
|
69
|
+
sm: "gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5",
|
|
70
|
+
xs: "gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1"
|
|
71
|
+
},
|
|
72
|
+
orientation: {
|
|
73
|
+
horizontal: "min-w-40 items-center",
|
|
74
|
+
vertical: "w-24 flex-col has-data-[slot=attachment-content]:w-30"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
function Attachment({
|
|
79
|
+
className,
|
|
80
|
+
state = "done",
|
|
81
|
+
size = "default",
|
|
82
|
+
orientation = "horizontal",
|
|
83
|
+
...props
|
|
84
|
+
}) {
|
|
85
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
86
|
+
"data-slot": "attachment",
|
|
87
|
+
"data-state": state,
|
|
88
|
+
"data-size": size,
|
|
89
|
+
"data-orientation": orientation,
|
|
90
|
+
className: cn(attachmentVariants({ size, orientation }), className),
|
|
91
|
+
...props
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
var attachmentMediaVariants = cva2("relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5", {
|
|
95
|
+
variants: {
|
|
96
|
+
variant: {
|
|
97
|
+
icon: "",
|
|
98
|
+
image: "opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
defaultVariants: {
|
|
102
|
+
variant: "icon"
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
function AttachmentMedia({
|
|
106
|
+
className,
|
|
107
|
+
variant = "icon",
|
|
108
|
+
...props
|
|
109
|
+
}) {
|
|
110
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
111
|
+
"data-slot": "attachment-media",
|
|
112
|
+
"data-variant": variant,
|
|
113
|
+
className: cn(attachmentMediaVariants({ variant }), className),
|
|
114
|
+
...props
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function AttachmentContent({
|
|
118
|
+
className,
|
|
119
|
+
...props
|
|
120
|
+
}) {
|
|
121
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
122
|
+
"data-slot": "attachment-content",
|
|
123
|
+
className: cn("max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1", className),
|
|
124
|
+
...props
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function AttachmentTitle({
|
|
128
|
+
className,
|
|
129
|
+
...props
|
|
130
|
+
}) {
|
|
131
|
+
return /* @__PURE__ */ jsx2("span", {
|
|
132
|
+
"data-slot": "attachment-title",
|
|
133
|
+
className: cn("block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer", className),
|
|
134
|
+
...props
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function AttachmentDescription({
|
|
138
|
+
className,
|
|
139
|
+
...props
|
|
140
|
+
}) {
|
|
141
|
+
return /* @__PURE__ */ jsx2("span", {
|
|
142
|
+
"data-slot": "attachment-description",
|
|
143
|
+
className: cn("mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80", "max-w-full", className),
|
|
144
|
+
...props
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function AttachmentActions({
|
|
148
|
+
className,
|
|
149
|
+
...props
|
|
150
|
+
}) {
|
|
151
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
152
|
+
"data-slot": "attachment-actions",
|
|
153
|
+
className: cn("relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1", className),
|
|
154
|
+
...props
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ../../src/components/ui/upload-attachment.tsx
|
|
159
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
160
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
161
|
+
var labels = {
|
|
162
|
+
en: {
|
|
163
|
+
idle: "Ready to upload",
|
|
164
|
+
uploading: "Uploading",
|
|
165
|
+
processing: "Processing",
|
|
166
|
+
done: "Upload complete",
|
|
167
|
+
cancelled: "Upload cancelled",
|
|
168
|
+
cancel: "Cancel upload",
|
|
169
|
+
retry: "Retry upload",
|
|
170
|
+
remove: "Remove attachment"
|
|
171
|
+
},
|
|
172
|
+
fr: {
|
|
173
|
+
idle: "Prêt à téléverser",
|
|
174
|
+
uploading: "Téléversement",
|
|
175
|
+
processing: "Traitement",
|
|
176
|
+
done: "Téléversement terminé",
|
|
177
|
+
cancelled: "Téléversement annulé",
|
|
178
|
+
cancel: "Annuler le téléversement",
|
|
179
|
+
retry: "Réessayer le téléversement",
|
|
180
|
+
remove: "Retirer la pièce jointe"
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
var UploadAttachment = ({
|
|
184
|
+
name,
|
|
185
|
+
description,
|
|
186
|
+
state,
|
|
187
|
+
disabled,
|
|
188
|
+
onCancel,
|
|
189
|
+
onRetry,
|
|
190
|
+
onRemove,
|
|
191
|
+
className,
|
|
192
|
+
locale: override,
|
|
193
|
+
messages
|
|
194
|
+
}) => {
|
|
195
|
+
const locale = useKrakstackLocale(override);
|
|
196
|
+
const id = useId();
|
|
197
|
+
const copy = {
|
|
198
|
+
...locale.startsWith("fr") ? labels.fr : labels.en,
|
|
199
|
+
...messages?.[locale.split("-")[0] ?? locale],
|
|
200
|
+
...messages?.[locale]
|
|
201
|
+
};
|
|
202
|
+
const busy = state.status === "uploading" || state.status === "processing";
|
|
203
|
+
const progress = state.status === "uploading" && state.progress !== undefined && Number.isFinite(state.progress) ? Math.min(100, Math.max(0, state.progress)) : undefined;
|
|
204
|
+
const status = state.status === "error" ? state.message : copy[state.status];
|
|
205
|
+
return /* @__PURE__ */ jsxs(Attachment, {
|
|
206
|
+
state: state.status === "cancelled" ? "idle" : state.status,
|
|
207
|
+
className,
|
|
208
|
+
"aria-labelledby": `${id}-name`,
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ jsx3(AttachmentMedia, {
|
|
211
|
+
children: state.status === "done" ? /* @__PURE__ */ jsx3(Check, {
|
|
212
|
+
"aria-hidden": "true"
|
|
213
|
+
}) : state.status === "error" ? /* @__PURE__ */ jsx3(TriangleAlert, {
|
|
214
|
+
"aria-hidden": "true"
|
|
215
|
+
}) : busy ? /* @__PURE__ */ jsx3(LoaderCircle, {
|
|
216
|
+
"aria-hidden": "true",
|
|
217
|
+
className: "motion-safe:animate-spin"
|
|
218
|
+
}) : /* @__PURE__ */ jsx3(File, {
|
|
219
|
+
"aria-hidden": "true"
|
|
220
|
+
})
|
|
221
|
+
}),
|
|
222
|
+
/* @__PURE__ */ jsxs(AttachmentContent, {
|
|
223
|
+
children: [
|
|
224
|
+
/* @__PURE__ */ jsx3(AttachmentTitle, {
|
|
225
|
+
id: `${id}-name`,
|
|
226
|
+
children: name
|
|
227
|
+
}),
|
|
228
|
+
description ? /* @__PURE__ */ jsx3(AttachmentDescription, {
|
|
229
|
+
children: description
|
|
230
|
+
}) : null,
|
|
231
|
+
/* @__PURE__ */ jsx3("p", {
|
|
232
|
+
role: state.status === "error" ? "alert" : "status",
|
|
233
|
+
className: "text-muted-foreground mt-1 text-xs",
|
|
234
|
+
children: status
|
|
235
|
+
}),
|
|
236
|
+
state.status === "uploading" ? /* @__PURE__ */ jsx3("progress", {
|
|
237
|
+
className: "accent-primary mt-2 h-1.5 w-full",
|
|
238
|
+
"aria-label": `${copy.uploading}: ${name}`,
|
|
239
|
+
max: 100,
|
|
240
|
+
value: progress
|
|
241
|
+
}) : null
|
|
242
|
+
]
|
|
243
|
+
}),
|
|
244
|
+
/* @__PURE__ */ jsxs(AttachmentActions, {
|
|
245
|
+
children: [
|
|
246
|
+
busy && onCancel ? /* @__PURE__ */ jsx3(Button, {
|
|
247
|
+
type: "button",
|
|
248
|
+
variant: "ghost",
|
|
249
|
+
size: "icon-sm",
|
|
250
|
+
disabled,
|
|
251
|
+
"aria-label": `${copy.cancel}: ${name}`,
|
|
252
|
+
onClick: onCancel,
|
|
253
|
+
children: /* @__PURE__ */ jsx3(X, {
|
|
254
|
+
"aria-hidden": "true"
|
|
255
|
+
})
|
|
256
|
+
}) : null,
|
|
257
|
+
(state.status === "error" || state.status === "cancelled") && onRetry ? /* @__PURE__ */ jsx3(Button, {
|
|
258
|
+
type: "button",
|
|
259
|
+
variant: "ghost",
|
|
260
|
+
size: "icon-sm",
|
|
261
|
+
disabled,
|
|
262
|
+
"aria-label": `${copy.retry}: ${name}`,
|
|
263
|
+
onClick: onRetry,
|
|
264
|
+
children: /* @__PURE__ */ jsx3(RotateCcw, {
|
|
265
|
+
"aria-hidden": "true"
|
|
266
|
+
})
|
|
267
|
+
}) : null,
|
|
268
|
+
!busy && onRemove ? /* @__PURE__ */ jsx3(Button, {
|
|
269
|
+
type: "button",
|
|
270
|
+
variant: "ghost",
|
|
271
|
+
size: "icon-sm",
|
|
272
|
+
disabled,
|
|
273
|
+
"aria-label": `${copy.remove}: ${name}`,
|
|
274
|
+
onClick: onRemove,
|
|
275
|
+
children: /* @__PURE__ */ jsx3(X, {
|
|
276
|
+
"aria-hidden": "true"
|
|
277
|
+
})
|
|
278
|
+
}) : null
|
|
279
|
+
]
|
|
280
|
+
})
|
|
281
|
+
]
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
export {
|
|
285
|
+
UploadAttachment
|
|
286
|
+
};
|
|
@@ -158,7 +158,7 @@ var VirtualizedComboboxList = ({
|
|
|
158
158
|
}));
|
|
159
159
|
const selectedEntries = itemEntries.filter(({ item }) => selectedValues.has(item.value));
|
|
160
160
|
const availableEntries = itemEntries.filter(({ item }) => !selectedValues.has(item.value));
|
|
161
|
-
const entries = groupSelections ? [
|
|
161
|
+
const entries = filteredItems.length === 0 ? [] : groupSelections ? [
|
|
162
162
|
...selectedEntries.length > 0 ? [
|
|
163
163
|
{
|
|
164
164
|
kind: "group",
|
|
@@ -277,7 +277,7 @@ var VirtualizedComboboxContent = ({
|
|
|
277
277
|
side: "bottom",
|
|
278
278
|
sideOffset: 6,
|
|
279
279
|
children: /* @__PURE__ */ jsxs(ComboboxPrimitive.Popup, {
|
|
280
|
-
className: cn("
|
|
280
|
+
className: cn("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-in-95 relative flex max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) flex-col overflow-hidden rounded-md shadow-md ring-1 duration-100", contentClassName),
|
|
281
281
|
children: [
|
|
282
282
|
/* @__PURE__ */ jsx4("div", {
|
|
283
283
|
className: "min-w-0 shrink-0 p-1 pb-0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,26 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
|
+
"./app-switcher": {
|
|
21
|
+
"types": "./dist/components/ui/app-switcher.d.ts",
|
|
22
|
+
"import": "./dist/components/ui/app-switcher.js"
|
|
23
|
+
},
|
|
24
|
+
"./secret-value": {
|
|
25
|
+
"types": "./dist/components/ui/secret-value.d.ts",
|
|
26
|
+
"import": "./dist/components/ui/secret-value.js"
|
|
27
|
+
},
|
|
28
|
+
"./bulk-list-input": {
|
|
29
|
+
"types": "./dist/components/ui/bulk-list-input.d.ts",
|
|
30
|
+
"import": "./dist/components/ui/bulk-list-input.js"
|
|
31
|
+
},
|
|
32
|
+
"./choice-cards": {
|
|
33
|
+
"types": "./dist/components/ui/choice-cards.d.ts",
|
|
34
|
+
"import": "./dist/components/ui/choice-cards.js"
|
|
35
|
+
},
|
|
36
|
+
"./upload-attachment": {
|
|
37
|
+
"types": "./dist/components/ui/upload-attachment.d.ts",
|
|
38
|
+
"import": "./dist/components/ui/upload-attachment.js"
|
|
39
|
+
},
|
|
20
40
|
"./webhooks/client": {
|
|
21
41
|
"types": "./dist/services/webhooks/client/delivery-table.d.ts",
|
|
22
42
|
"import": "./dist/services/webhooks/client/delivery-table.js"
|