@krak-stack/registry 0.4.0 → 0.6.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 (33) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/components/ui/animated-list.d.ts +22 -0
  3. package/dist/components/ui/animated-list.js +219 -0
  4. package/dist/components/ui/animated-number.d.ts +9 -0
  5. package/dist/components/ui/animated-number.js +52 -0
  6. package/dist/components/ui/app-switcher.d.ts +25 -0
  7. package/dist/components/ui/app-switcher.js +233 -0
  8. package/dist/components/ui/async-action-button.d.ts +16 -0
  9. package/dist/components/ui/async-action-button.js +147 -0
  10. package/dist/components/ui/auto-height.d.ts +9 -0
  11. package/dist/components/ui/auto-height.js +45 -0
  12. package/dist/components/ui/bulk-list-input.d.ts +24 -0
  13. package/dist/components/ui/bulk-list-input.js +152 -0
  14. package/dist/components/ui/choice-cards.d.ts +32 -0
  15. package/dist/components/ui/choice-cards.js +88 -0
  16. package/dist/components/ui/color-picker.js +3 -2
  17. package/dist/components/ui/danger-confirmation.d.ts +20 -0
  18. package/dist/components/ui/danger-confirmation.js +394 -0
  19. package/dist/components/ui/editable-text.d.ts +19 -0
  20. package/dist/components/ui/editable-text.js +334 -0
  21. package/dist/components/ui/effect-form.js +2 -2
  22. package/dist/components/ui/form.js +2 -2
  23. package/dist/components/ui/icon-input.js +2 -2
  24. package/dist/components/ui/presence-transition.d.ts +9 -0
  25. package/dist/components/ui/presence-transition.js +41 -0
  26. package/dist/components/ui/secret-value.d.ts +19 -0
  27. package/dist/components/ui/secret-value.js +216 -0
  28. package/dist/components/ui/unsaved-changes-guard.d.ts +15 -0
  29. package/dist/components/ui/unsaved-changes-guard.js +235 -0
  30. package/dist/components/ui/upload-attachment.d.ts +39 -0
  31. package/dist/components/ui/upload-attachment.js +286 -0
  32. package/dist/components/ui/virtualized-combobox.js +2 -2
  33. package/package.json +54 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @krak-stack/registry
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5c9f4c2: Add Async Action Button, Unsaved Changes Guard, Danger Confirmation, Editable Text, Presence Transition, Auto Height, Animated List, and Animated Number as standalone components with bilingual documentation and reduced-motion-aware previews.
8
+
9
+ Animated List includes controlled vertical drag reordering and accessible keyboard handles.
10
+
11
+ ## 0.5.0
12
+
13
+ ### Minor Changes
14
+
15
+ - b3cb799: Add App Switcher, Secret Value, Bulk List Input, Choice Cards, and Upload Attachment as standalone components with package exports and English/French documentation.
16
+
3
17
  ## 0.4.0
4
18
 
5
19
  ### Minor Changes
@@ -22,6 +36,18 @@
22
36
 
23
37
  - 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
38
 
39
+ ## 0.2.2
40
+
41
+ ### Patch Changes
42
+
43
+ - Prevent virtualized combobox group headings from collapsing into options after asynchronous search results refresh.
44
+
45
+ ## 0.2.1
46
+
47
+ ### Patch Changes
48
+
49
+ - 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.
50
+
25
51
  ## 0.2.0
26
52
 
27
53
  ### Minor Changes
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from "react";
2
+ export type AnimatedListProps<T> = {
3
+ items: readonly T[];
4
+ getKey: (item: T) => string;
5
+ children: (item: T) => ReactNode;
6
+ duration?: number;
7
+ className?: string;
8
+ itemClassName?: string;
9
+ label?: string;
10
+ onReorder?: (items: T[]) => void;
11
+ dragOverflow?: number;
12
+ getItemLabel?: (item: T) => string;
13
+ locale?: string;
14
+ messages?: Partial<Record<string, Partial<AnimatedListMessages>>>;
15
+ };
16
+ export type AnimatedListMessages = {
17
+ reorder: string;
18
+ instructions: string;
19
+ position: (label: string, position: number, total: number) => string;
20
+ };
21
+ /** Stable entity keys preserve child state across inserts and reordering. */
22
+ export declare const AnimatedList: <T>({ items, getKey, children, duration, className, itemClassName, label, onReorder, dragOverflow, getItemLabel, locale: override, messages, }: AnimatedListProps<T>) => import("react").JSX.Element;
@@ -0,0 +1,219 @@
1
+ // ../../src/components/ui/animated-list.tsx
2
+ import {
3
+ AnimatePresence,
4
+ Reorder,
5
+ motion,
6
+ useDragControls,
7
+ useIsPresent,
8
+ useReducedMotion
9
+ } from "motion/react";
10
+ import { GripVertical } from "lucide-react";
11
+ import { useId, useRef, useState } from "react";
12
+ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
13
+
14
+ // ../../src/lib/utils.ts
15
+ import { cn } from "cn";
16
+
17
+ // ../../src/components/ui/animated-list.tsx
18
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
19
+ var labels = {
20
+ en: {
21
+ reorder: "Reorder",
22
+ instructions: "Drag to reorder, or use Arrow Up, Arrow Down, Home and End on the handle.",
23
+ position: (label, position, total) => `${label}, position ${position} of ${total}.`
24
+ },
25
+ fr: {
26
+ reorder: "Réordonner",
27
+ instructions: "Faites glisser pour réordonner, ou utilisez les flèches haut et bas, Début et Fin sur la poignée.",
28
+ position: (label, position, total) => `${label}, position ${position} sur ${total}.`
29
+ }
30
+ };
31
+ var AnimatedList = ({
32
+ items,
33
+ getKey,
34
+ children,
35
+ duration = 180,
36
+ className,
37
+ itemClassName,
38
+ label,
39
+ onReorder,
40
+ dragOverflow = 12,
41
+ getItemLabel,
42
+ locale: override,
43
+ messages
44
+ }) => {
45
+ const locale = useKrakstackLocale(override);
46
+ const copy = {
47
+ ...locale.startsWith("fr") ? labels.fr : labels.en,
48
+ ...messages?.[locale.split("-")[0] ?? locale],
49
+ ...messages?.[locale]
50
+ };
51
+ const instructions = useId();
52
+ const container = useRef(null);
53
+ const [announcedKey, setAnnouncedKey] = useState(null);
54
+ const keys = items.map(getKey);
55
+ const announcement = items.map((item, index) => getKey(item) === announcedKey ? copy.position(getItemLabel?.(item) ?? getKey(item), index + 1, items.length) : "").join("");
56
+ const reorder = (nextKeys) => {
57
+ const order = new Map(nextKeys.map((key, index) => [key, index]));
58
+ onReorder?.([...items].sort((a, b) => (order.get(getKey(a)) ?? 0) - (order.get(getKey(b)) ?? 0)));
59
+ };
60
+ if (onReorder)
61
+ return /* @__PURE__ */ jsxs(Fragment, {
62
+ children: [
63
+ /* @__PURE__ */ jsx(Reorder.Group, {
64
+ ref: container,
65
+ as: "ul",
66
+ axis: "y",
67
+ values: keys,
68
+ onReorder: reorder,
69
+ className: cn("grid gap-3", className),
70
+ "aria-label": label,
71
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
72
+ initial: false,
73
+ children: items.map((item, index) => {
74
+ const key = getKey(item);
75
+ const itemLabel = getItemLabel?.(item) ?? key;
76
+ return /* @__PURE__ */ jsx(ReorderableListItem, {
77
+ value: key,
78
+ duration,
79
+ className: itemClassName,
80
+ instructions,
81
+ handleLabel: `${copy.reorder}: ${itemLabel}`,
82
+ disabled: items.length < 2,
83
+ constraints: container,
84
+ dragOverflow,
85
+ onMove: (direction) => {
86
+ const target = direction === "Home" ? 0 : direction === "End" ? items.length - 1 : Math.max(0, Math.min(items.length - 1, index + (direction === "ArrowUp" ? -1 : 1)));
87
+ if (index === target)
88
+ return;
89
+ const nextKeys = [...keys];
90
+ nextKeys.splice(index, 1);
91
+ nextKeys.splice(target, 0, key);
92
+ setAnnouncedKey(key);
93
+ reorder(nextKeys);
94
+ },
95
+ onDragEnd: () => setAnnouncedKey(key),
96
+ children: children(item)
97
+ }, key);
98
+ })
99
+ })
100
+ }),
101
+ /* @__PURE__ */ jsx("span", {
102
+ id: instructions,
103
+ className: "sr-only",
104
+ children: copy.instructions
105
+ }),
106
+ /* @__PURE__ */ jsx("span", {
107
+ role: "status",
108
+ className: "sr-only",
109
+ children: announcement
110
+ })
111
+ ]
112
+ });
113
+ return /* @__PURE__ */ jsx("ul", {
114
+ className: cn("grid gap-3", className),
115
+ "aria-label": label,
116
+ children: /* @__PURE__ */ jsx(AnimatePresence, {
117
+ initial: false,
118
+ children: items.map((item) => /* @__PURE__ */ jsx(AnimatedListItem, {
119
+ duration,
120
+ className: itemClassName,
121
+ children: children(item)
122
+ }, getKey(item)))
123
+ })
124
+ });
125
+ };
126
+ var ReorderableListItem = ({
127
+ children,
128
+ value,
129
+ duration,
130
+ className,
131
+ instructions,
132
+ handleLabel,
133
+ disabled,
134
+ constraints,
135
+ dragOverflow,
136
+ onMove,
137
+ onDragEnd
138
+ }) => {
139
+ const present = useIsPresent();
140
+ const reduced = useReducedMotion();
141
+ const controls = useDragControls();
142
+ return /* @__PURE__ */ jsxs(Reorder.Item, {
143
+ as: "li",
144
+ value,
145
+ dragListener: false,
146
+ dragControls: controls,
147
+ dragMomentum: false,
148
+ dragConstraints: constraints,
149
+ dragElastic: 0,
150
+ onMeasureDragConstraints: (bounds) => ({
151
+ ...bounds,
152
+ top: bounds.top - Math.max(0, dragOverflow),
153
+ bottom: bounds.bottom + Math.max(0, dragOverflow)
154
+ }),
155
+ tabIndex: -1,
156
+ layout: "position",
157
+ className: cn("relative", className),
158
+ inert: !present,
159
+ "aria-hidden": !present ? true : undefined,
160
+ initial: { opacity: 0 },
161
+ animate: { opacity: 1 },
162
+ exit: { opacity: 0 },
163
+ transition: {
164
+ duration: reduced !== false ? 0 : Math.max(0, duration) / 1000
165
+ },
166
+ onDragEnd,
167
+ children: [
168
+ /* @__PURE__ */ jsx("button", {
169
+ type: "button",
170
+ disabled: disabled || !present,
171
+ "aria-label": handleLabel,
172
+ "aria-describedby": instructions,
173
+ className: "text-muted-foreground focus-visible:ring-ring inline-flex size-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-md outline-none select-none focus-visible:ring-2 active:cursor-grabbing disabled:cursor-default disabled:opacity-50",
174
+ onPointerDown: (event) => {
175
+ if (!disabled && present)
176
+ controls.start(event);
177
+ },
178
+ onKeyDown: (event) => {
179
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
180
+ return;
181
+ if (event.key === "ArrowUp" || event.key === "ArrowDown" || event.key === "Home" || event.key === "End") {
182
+ event.preventDefault();
183
+ event.stopPropagation();
184
+ onMove(event.key);
185
+ }
186
+ },
187
+ children: /* @__PURE__ */ jsx(GripVertical, {
188
+ className: "size-4",
189
+ "aria-hidden": "true"
190
+ })
191
+ }),
192
+ children
193
+ ]
194
+ });
195
+ };
196
+ var AnimatedListItem = ({
197
+ children,
198
+ duration,
199
+ className
200
+ }) => {
201
+ const present = useIsPresent();
202
+ const reduced = useReducedMotion();
203
+ return /* @__PURE__ */ jsx(motion.li, {
204
+ layout: reduced === false ? "position" : false,
205
+ className,
206
+ inert: !present,
207
+ "aria-hidden": !present ? true : undefined,
208
+ initial: { opacity: 0 },
209
+ animate: { opacity: 1 },
210
+ exit: { opacity: 0 },
211
+ transition: {
212
+ duration: reduced !== false ? 0 : Math.max(0, duration) / 1000
213
+ },
214
+ children
215
+ });
216
+ };
217
+ export {
218
+ AnimatedList
219
+ };
@@ -0,0 +1,9 @@
1
+ export type AnimatedNumberProps = {
2
+ value: number;
3
+ duration?: number;
4
+ format?: Intl.NumberFormatOptions;
5
+ locale?: string;
6
+ className?: string;
7
+ };
8
+ /** Assistive technology receives the target, not a stream of intermediate values. */
9
+ export declare const AnimatedNumber: ({ value, duration, format, locale: override, className, }: AnimatedNumberProps) => import("react").JSX.Element;
@@ -0,0 +1,52 @@
1
+ // ../../src/components/ui/animated-number.tsx
2
+ import {
3
+ animate,
4
+ motion,
5
+ useMotionValue,
6
+ useReducedMotion,
7
+ useTransform
8
+ } from "motion/react";
9
+ import { useEffect, useMemo } from "react";
10
+ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ var AnimatedNumber = ({
13
+ value,
14
+ duration = 350,
15
+ format,
16
+ locale: override,
17
+ className
18
+ }) => {
19
+ const locale = useKrakstackLocale(override);
20
+ const formatter = useMemo(() => new Intl.NumberFormat(locale, format), [locale, format]);
21
+ const displayed = useMotionValue(value);
22
+ const text = useTransform(() => formatter.format(displayed.get()));
23
+ const reduced = useReducedMotion();
24
+ useEffect(() => {
25
+ if (reduced !== false || duration <= 0 || !Number.isFinite(value) || !Number.isFinite(displayed.get())) {
26
+ displayed.set(value);
27
+ return;
28
+ }
29
+ const controls = animate(displayed, value, {
30
+ duration: duration / 1000,
31
+ ease: "easeOut"
32
+ });
33
+ return () => controls.stop();
34
+ }, [displayed, duration, reduced, value]);
35
+ return /* @__PURE__ */ jsxs("span", {
36
+ "data-slot": "animated-number",
37
+ className,
38
+ children: [
39
+ /* @__PURE__ */ jsx("span", {
40
+ className: "sr-only",
41
+ children: formatter.format(value)
42
+ }),
43
+ /* @__PURE__ */ jsx(motion.span, {
44
+ "aria-hidden": "true",
45
+ children: text
46
+ })
47
+ ]
48
+ });
49
+ };
50
+ export {
51
+ AnimatedNumber
52
+ };
@@ -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,16 @@
1
+ import { type ComponentProps } from "react";
2
+ import { Button } from "./button.js";
3
+ export type AsyncActionButtonMessages = {
4
+ pending: string;
5
+ success: string;
6
+ retry: string;
7
+ error: string;
8
+ };
9
+ export type AsyncActionButtonProps = Omit<ComponentProps<typeof Button>, "onClick" | "type" | "render" | "nativeButton" | "aria-busy"> & {
10
+ onAction: () => Promise<void>;
11
+ onPendingChange?: (pending: boolean) => void;
12
+ locale?: string;
13
+ messages?: Partial<Record<string, Partial<AsyncActionButtonMessages>>>;
14
+ };
15
+ /** Runs only on activation. Failures stay local; raw error details are never rendered. */
16
+ export declare const AsyncActionButton: ({ onAction, onPendingChange, children, disabled, locale: override, messages, ...props }: AsyncActionButtonProps) => import("react").JSX.Element;