@craftzbay/ui 0.11.3 → 1.0.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/README.md +1 -1
- package/dist-lib/_virtual/_rolldown/runtime.js +11 -0
- package/dist-lib/components/ui/Accordion.js +42 -67
- package/dist-lib/components/ui/Accordion.js.map +1 -1
- package/dist-lib/components/ui/Alert.js +71 -77
- package/dist-lib/components/ui/Alert.js.map +1 -1
- package/dist-lib/components/ui/Avatar.js +67 -92
- package/dist-lib/components/ui/Avatar.js.map +1 -1
- package/dist-lib/components/ui/Badge.js +119 -74
- package/dist-lib/components/ui/Badge.js.map +1 -1
- package/dist-lib/components/ui/Breadcrumbs.js +62 -50
- package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
- package/dist-lib/components/ui/Button.js +129 -131
- package/dist-lib/components/ui/Button.js.map +1 -1
- package/dist-lib/components/ui/Calendar.d.ts +1 -1
- package/dist-lib/components/ui/Calendar.js +99 -136
- package/dist-lib/components/ui/Calendar.js.map +1 -1
- package/dist-lib/components/ui/Card.js +88 -94
- package/dist-lib/components/ui/Card.js.map +1 -1
- package/dist-lib/components/ui/Carousel.js +125 -170
- package/dist-lib/components/ui/Carousel.js.map +1 -1
- package/dist-lib/components/ui/Chart.d.ts +3 -3
- package/dist-lib/components/ui/Chart.js +435 -464
- package/dist-lib/components/ui/Chart.js.map +1 -1
- package/dist-lib/components/ui/Checkbox.js +60 -69
- package/dist-lib/components/ui/Checkbox.js.map +1 -1
- package/dist-lib/components/ui/Combobox.js +179 -192
- package/dist-lib/components/ui/Combobox.js.map +1 -1
- package/dist-lib/components/ui/CommandPalette.d.ts +2 -2
- package/dist-lib/components/ui/CommandPalette.js +106 -167
- package/dist-lib/components/ui/CommandPalette.js.map +1 -1
- package/dist-lib/components/ui/ContextMenu.d.ts +1 -1
- package/dist-lib/components/ui/ContextMenu.js +89 -154
- package/dist-lib/components/ui/ContextMenu.js.map +1 -1
- package/dist-lib/components/ui/DataGrid.d.ts +1 -1
- package/dist-lib/components/ui/DataGrid.js +99 -96
- package/dist-lib/components/ui/DataGrid.js.map +1 -1
- package/dist-lib/components/ui/DatePicker.js +151 -188
- package/dist-lib/components/ui/DatePicker.js.map +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.d.ts +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.js +120 -130
- package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
- package/dist-lib/components/ui/Dialog.d.ts +3 -3
- package/dist-lib/components/ui/Dialog.js +108 -156
- package/dist-lib/components/ui/Dialog.js.map +1 -1
- package/dist-lib/components/ui/Drawer.d.ts +3 -3
- package/dist-lib/components/ui/Drawer.js +90 -124
- package/dist-lib/components/ui/Drawer.js.map +1 -1
- package/dist-lib/components/ui/DropdownMenu.d.ts +1 -1
- package/dist-lib/components/ui/DropdownMenu.js +92 -158
- package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
- package/dist-lib/components/ui/EmptyState.js +31 -44
- package/dist-lib/components/ui/EmptyState.js.map +1 -1
- package/dist-lib/components/ui/ErrorState.js +57 -67
- package/dist-lib/components/ui/ErrorState.js.map +1 -1
- package/dist-lib/components/ui/FileUpload.js +113 -107
- package/dist-lib/components/ui/FileUpload.js.map +1 -1
- package/dist-lib/components/ui/Form.d.ts +6 -4
- package/dist-lib/components/ui/Form.js +117 -122
- package/dist-lib/components/ui/Form.js.map +1 -1
- package/dist-lib/components/ui/Icon.d.ts +1 -1
- package/dist-lib/components/ui/Icon.js +30 -29
- package/dist-lib/components/ui/Icon.js.map +1 -1
- package/dist-lib/components/ui/IconButton.js +61 -63
- package/dist-lib/components/ui/IconButton.js.map +1 -1
- package/dist-lib/components/ui/Input.js +133 -156
- package/dist-lib/components/ui/Input.js.map +1 -1
- package/dist-lib/components/ui/Kbd.js +14 -21
- package/dist-lib/components/ui/Kbd.js.map +1 -1
- package/dist-lib/components/ui/MultiSelect.js +176 -208
- package/dist-lib/components/ui/MultiSelect.js.map +1 -1
- package/dist-lib/components/ui/Pagination.js +152 -149
- package/dist-lib/components/ui/Pagination.js.map +1 -1
- package/dist-lib/components/ui/Popover.js +18 -33
- package/dist-lib/components/ui/Popover.js.map +1 -1
- package/dist-lib/components/ui/Progress.js +77 -99
- package/dist-lib/components/ui/Progress.js.map +1 -1
- package/dist-lib/components/ui/RadioGroup.js +51 -80
- package/dist-lib/components/ui/RadioGroup.js.map +1 -1
- package/dist-lib/components/ui/RelativeTime.js +22 -29
- package/dist-lib/components/ui/RelativeTime.js.map +1 -1
- package/dist-lib/components/ui/ScrollArea.js +39 -58
- package/dist-lib/components/ui/ScrollArea.js.map +1 -1
- package/dist-lib/components/ui/Select.js +108 -131
- package/dist-lib/components/ui/Select.js.map +1 -1
- package/dist-lib/components/ui/Separator.js +18 -24
- package/dist-lib/components/ui/Separator.js.map +1 -1
- package/dist-lib/components/ui/Sheet.d.ts +2 -2
- package/dist-lib/components/ui/Sheet.js +77 -129
- package/dist-lib/components/ui/Sheet.js.map +1 -1
- package/dist-lib/components/ui/Sidebar.d.ts +1 -1
- package/dist-lib/components/ui/Sidebar.js +168 -207
- package/dist-lib/components/ui/Sidebar.js.map +1 -1
- package/dist-lib/components/ui/Skeleton.js +17 -27
- package/dist-lib/components/ui/Skeleton.js.map +1 -1
- package/dist-lib/components/ui/Slider.js +45 -62
- package/dist-lib/components/ui/Slider.js.map +1 -1
- package/dist-lib/components/ui/Snackbar.js +75 -55
- package/dist-lib/components/ui/Snackbar.js.map +1 -1
- package/dist-lib/components/ui/Spinner.js +45 -52
- package/dist-lib/components/ui/Spinner.js.map +1 -1
- package/dist-lib/components/ui/Stepper.js +56 -108
- package/dist-lib/components/ui/Stepper.js.map +1 -1
- package/dist-lib/components/ui/Switch.js +46 -79
- package/dist-lib/components/ui/Switch.js.map +1 -1
- package/dist-lib/components/ui/Table.js +108 -169
- package/dist-lib/components/ui/Table.js.map +1 -1
- package/dist-lib/components/ui/Tabs.js +57 -88
- package/dist-lib/components/ui/Tabs.js.map +1 -1
- package/dist-lib/components/ui/TagInput.js +76 -109
- package/dist-lib/components/ui/TagInput.js.map +1 -1
- package/dist-lib/components/ui/Textarea.js +74 -86
- package/dist-lib/components/ui/Textarea.js.map +1 -1
- package/dist-lib/components/ui/Timeline.d.ts +3 -3
- package/dist-lib/components/ui/Timeline.js +61 -49
- package/dist-lib/components/ui/Timeline.js.map +1 -1
- package/dist-lib/components/ui/Toast.d.ts +1 -1
- package/dist-lib/components/ui/Toast.js +136 -150
- package/dist-lib/components/ui/Toast.js.map +1 -1
- package/dist-lib/components/ui/Tooltip.d.ts +2 -2
- package/dist-lib/components/ui/Tooltip.js +35 -56
- package/dist-lib/components/ui/Tooltip.js.map +1 -1
- package/dist-lib/components/ui/TopNav.js +46 -66
- package/dist-lib/components/ui/TopNav.js.map +1 -1
- package/dist-lib/components/ui/Tree.js +134 -168
- package/dist-lib/components/ui/Tree.js.map +1 -1
- package/dist-lib/hooks/use-debounce.js +24 -33
- package/dist-lib/hooks/use-debounce.js.map +1 -1
- package/dist-lib/hooks/use-delayed-loading.js +20 -18
- package/dist-lib/hooks/use-delayed-loading.js.map +1 -1
- package/dist-lib/hooks/use-field-ids.js +14 -16
- package/dist-lib/hooks/use-field-ids.js.map +1 -1
- package/dist-lib/hooks/use-media-query.js +15 -19
- package/dist-lib/hooks/use-media-query.js.map +1 -1
- package/dist-lib/hooks/use-modifier-key.d.ts +0 -4
- package/dist-lib/hooks/use-modifier-key.js +19 -16
- package/dist-lib/hooks/use-modifier-key.js.map +1 -1
- package/dist-lib/hooks/use-strings.js +10 -10
- package/dist-lib/hooks/use-strings.js.map +1 -1
- package/dist-lib/hooks/use-toast.js +73 -62
- package/dist-lib/hooks/use-toast.js.map +1 -1
- package/dist-lib/icon.js +2 -6
- package/dist-lib/icons/index.d.ts +1 -1
- package/dist-lib/icons/index.js +166 -163
- package/dist-lib/icons/index.js.map +1 -1
- package/dist-lib/illustrations/index.d.ts +7 -7
- package/dist-lib/illustrations/index.js +255 -106
- package/dist-lib/illustrations/index.js.map +1 -1
- package/dist-lib/index.js +69 -291
- package/dist-lib/lib/cva.js +2 -0
- package/dist-lib/lib/format.js +71 -87
- package/dist-lib/lib/format.js.map +1 -1
- package/dist-lib/lib/return-focus.js +11 -11
- package/dist-lib/lib/return-focus.js.map +1 -1
- package/dist-lib/lib/strings.js +167 -135
- package/dist-lib/lib/strings.js.map +1 -1
- package/dist-lib/lib/strings.mn.js +150 -113
- package/dist-lib/lib/strings.mn.js.map +1 -1
- package/dist-lib/lib/utils.js +9 -9
- package/dist-lib/lib/utils.js.map +1 -1
- package/dist-lib/styles.css +3 -1
- package/package.json +53 -53
- package/dist-lib/__tests__/helpers/color.d.ts +0 -9
- package/dist-lib/__tests__/helpers/theme.d.ts +0 -18
- package/dist-lib/icon.js.map +0 -1
- package/dist-lib/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ Inside `packages/ui` itself, `pnpm build` produces the distributable bundle and
|
|
|
109
109
|
## Tech stack
|
|
110
110
|
|
|
111
111
|
- **Tailwind CSS v4** — tokens defined in `@theme` in `src/styles/theme.css` (`globals.css` = tailwind + tw-animate-css + theme)
|
|
112
|
-
- **React 18 / 19** + **TypeScript 5.7
|
|
112
|
+
- **React 18 / 19** + **TypeScript 5.7+**
|
|
113
113
|
- **Radix UI** primitives for accessibility-correct overlays
|
|
114
114
|
- **class-variance-authority** + `cn()` (`clsx` + `tailwind-merge`)
|
|
115
115
|
- **Lucide** icons (16 / 20px, 1.5 stroke)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.defineProperty, t = (t, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in t) e(r, i, {
|
|
5
|
+
get: t[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as __exportAll };
|
|
@@ -1,71 +1,46 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
);
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { ChevronDown as t } from "../../icons/index.js";
|
|
4
|
+
import { forwardRef as n } from "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
import * as a from "@radix-ui/react-accordion";
|
|
7
|
+
//#region src/components/ui/Accordion.tsx
|
|
8
|
+
var o = a.Root, s = n(function({ className: t, ...n }, i) {
|
|
9
|
+
return /* @__PURE__ */ r(a.Item, {
|
|
10
|
+
ref: i,
|
|
11
|
+
className: e("border-border border-b", t),
|
|
12
|
+
...n
|
|
13
|
+
});
|
|
16
14
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
...r,
|
|
32
|
-
children: [
|
|
33
|
-
e,
|
|
34
|
-
/* @__PURE__ */ t(
|
|
35
|
-
m,
|
|
36
|
-
{
|
|
37
|
-
className: "text-foreground-subtle size-4 shrink-0 transition-transform duration-[var(--duration-base)]",
|
|
38
|
-
"aria-hidden": !0
|
|
39
|
-
}
|
|
40
|
-
)
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
) });
|
|
15
|
+
s.displayName = "AccordionItem";
|
|
16
|
+
var c = n(function({ className: n, children: o, ...s }, c) {
|
|
17
|
+
return /* @__PURE__ */ r(a.Header, {
|
|
18
|
+
className: "flex",
|
|
19
|
+
children: /* @__PURE__ */ i(a.Trigger, {
|
|
20
|
+
ref: c,
|
|
21
|
+
className: e("text-foreground flex flex-1 items-center justify-between gap-2 py-4 text-left text-sm font-medium", "transition-colors duration-[var(--duration-fast)] outline-none", "hover:text-accent", "focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2", "[&[data-state=open]>svg]:rotate-180", n),
|
|
22
|
+
...s,
|
|
23
|
+
children: [o, /* @__PURE__ */ r(t, {
|
|
24
|
+
className: "text-foreground-subtle size-4 shrink-0 transition-transform duration-[var(--duration-base)]",
|
|
25
|
+
"aria-hidden": !0
|
|
26
|
+
})]
|
|
27
|
+
})
|
|
28
|
+
});
|
|
44
29
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// except by design; `prefers-reduced-motion` disables it globally.
|
|
57
|
-
"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
|
|
58
|
-
),
|
|
59
|
-
...r,
|
|
60
|
-
children: /* @__PURE__ */ t("div", { className: i("pt-0 pb-4", o), children: e })
|
|
61
|
-
}
|
|
62
|
-
);
|
|
30
|
+
c.displayName = "AccordionTrigger";
|
|
31
|
+
var l = n(function({ className: t, children: n, ...i }, o) {
|
|
32
|
+
return /* @__PURE__ */ r(a.Content, {
|
|
33
|
+
ref: o,
|
|
34
|
+
className: e("text-foreground-muted overflow-hidden text-sm", "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"),
|
|
35
|
+
...i,
|
|
36
|
+
children: /* @__PURE__ */ r("div", {
|
|
37
|
+
className: e("pt-0 pb-4", t),
|
|
38
|
+
children: n
|
|
39
|
+
})
|
|
40
|
+
});
|
|
63
41
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
l as AccordionTrigger
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=Accordion.js.map
|
|
42
|
+
l.displayName = "AccordionContent";
|
|
43
|
+
//#endregion
|
|
44
|
+
export { o as Accordion, l as AccordionContent, s as AccordionItem, c as AccordionTrigger };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=Accordion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sources":["../../../src/components/ui/Accordion.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from 'react';\nimport * as AccordionPrimitive from '@radix-ui/react-accordion';\nimport { ChevronDown } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/**\n * Accessible disclosure list. Supports single (`type=\"single\"`) and multiple\n * (`type=\"multiple\"`) open behaviour — both come from Radix.\n *\n * @example FAQ\n * <Accordion type=\"single\" collapsible>\n * <AccordionItem value=\"q1\">\n * <AccordionTrigger>Can I cancel anytime?</AccordionTrigger>\n * <AccordionContent>Yes — usage stops at the end of the billing period.</AccordionContent>\n * </AccordionItem>\n * …\n * </Accordion>\n *\n * @do Use for FAQs, settings groups, and progressive-disclosure forms.\n * @dont Nest accordions inside accordions — the focus order becomes opaque.\n */\nexport const Accordion = AccordionPrimitive.Root;\n\nexport const AccordionItem = forwardRef<\n ElementRef<typeof AccordionPrimitive.Item>,\n ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>\n>(function AccordionItem({ className, ...props }, ref) {\n return (\n <AccordionPrimitive.Item\n ref={ref}\n className={cn('border-border border-b', className)}\n {...props}\n />\n );\n});\nAccordionItem.displayName = 'AccordionItem';\n\nexport const AccordionTrigger = forwardRef<\n ElementRef<typeof AccordionPrimitive.Trigger>,\n ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>\n>(function AccordionTrigger({ className, children, ...props }, ref) {\n return (\n <AccordionPrimitive.Header className=\"flex\">\n <AccordionPrimitive.Trigger\n ref={ref}\n className={cn(\n 'text-foreground flex flex-1 items-center justify-between gap-2 py-4 text-left text-sm font-medium',\n 'transition-colors duration-[var(--duration-fast)] outline-none',\n 'hover:text-accent',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n '[&[data-state=open]>svg]:rotate-180',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronDown\n className=\"text-foreground-subtle size-4 shrink-0 transition-transform duration-[var(--duration-base)]\"\n aria-hidden\n />\n </AccordionPrimitive.Trigger>\n </AccordionPrimitive.Header>\n );\n});\nAccordionTrigger.displayName = 'AccordionTrigger';\n\nexport const AccordionContent = forwardRef<\n ElementRef<typeof AccordionPrimitive.Content>,\n ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>\n>(function AccordionContent({ className, children, ...props }, ref) {\n return (\n <AccordionPrimitive.Content\n ref={ref}\n className={cn(\n 'text-foreground-muted overflow-hidden text-sm',\n // Deliberate motion exception: height animates (layout property). Radix only\n // keeps Content mounted through CSS *animations*, so a grid-rows transition\n // would cut the close. The panel is short and nothing below it reflows\n // except by design; `prefers-reduced-motion` disables it globally.\n 'data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down',\n )}\n {...props}\n >\n <div className={cn('pt-0 pb-4', className)}>{children}</div>\n </AccordionPrimitive.Content>\n );\n});\nAccordionContent.displayName = 'AccordionContent';\n"],"
|
|
1
|
+
{"version":3,"file":"Accordion.js","names":[],"sources":["../../../src/components/ui/Accordion.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from 'react';\nimport * as AccordionPrimitive from '@radix-ui/react-accordion';\nimport { ChevronDown } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/**\n * Accessible disclosure list. Supports single (`type=\"single\"`) and multiple\n * (`type=\"multiple\"`) open behaviour — both come from Radix.\n *\n * @example FAQ\n * <Accordion type=\"single\" collapsible>\n * <AccordionItem value=\"q1\">\n * <AccordionTrigger>Can I cancel anytime?</AccordionTrigger>\n * <AccordionContent>Yes — usage stops at the end of the billing period.</AccordionContent>\n * </AccordionItem>\n * …\n * </Accordion>\n *\n * @do Use for FAQs, settings groups, and progressive-disclosure forms.\n * @dont Nest accordions inside accordions — the focus order becomes opaque.\n */\nexport const Accordion = AccordionPrimitive.Root;\n\nexport const AccordionItem = forwardRef<\n ElementRef<typeof AccordionPrimitive.Item>,\n ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>\n>(function AccordionItem({ className, ...props }, ref) {\n return (\n <AccordionPrimitive.Item\n ref={ref}\n className={cn('border-border border-b', className)}\n {...props}\n />\n );\n});\nAccordionItem.displayName = 'AccordionItem';\n\nexport const AccordionTrigger = forwardRef<\n ElementRef<typeof AccordionPrimitive.Trigger>,\n ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>\n>(function AccordionTrigger({ className, children, ...props }, ref) {\n return (\n <AccordionPrimitive.Header className=\"flex\">\n <AccordionPrimitive.Trigger\n ref={ref}\n className={cn(\n 'text-foreground flex flex-1 items-center justify-between gap-2 py-4 text-left text-sm font-medium',\n 'transition-colors duration-[var(--duration-fast)] outline-none',\n 'hover:text-accent',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n '[&[data-state=open]>svg]:rotate-180',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronDown\n className=\"text-foreground-subtle size-4 shrink-0 transition-transform duration-[var(--duration-base)]\"\n aria-hidden\n />\n </AccordionPrimitive.Trigger>\n </AccordionPrimitive.Header>\n );\n});\nAccordionTrigger.displayName = 'AccordionTrigger';\n\nexport const AccordionContent = forwardRef<\n ElementRef<typeof AccordionPrimitive.Content>,\n ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>\n>(function AccordionContent({ className, children, ...props }, ref) {\n return (\n <AccordionPrimitive.Content\n ref={ref}\n className={cn(\n 'text-foreground-muted overflow-hidden text-sm',\n // Deliberate motion exception: height animates (layout property). Radix only\n // keeps Content mounted through CSS *animations*, so a grid-rows transition\n // would cut the close. The panel is short and nothing below it reflows\n // except by design; `prefers-reduced-motion` disables it globally.\n 'data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down',\n )}\n {...props}\n >\n <div className={cn('pt-0 pb-4', className)}>{children}</div>\n </AccordionPrimitive.Content>\n );\n});\nAccordionContent.displayName = 'AccordionContent';\n"],"mappings":";;;;;;;AAuBA,IAAa,IAAY,EAAmB,MAE/B,IAAgB,EAG3B,SAAuB,EAAE,cAAW,GAAG,KAAS,GAAK;CACrD,OACE,kBAAC,EAAmB,MAApB;EACO;EACL,WAAW,EAAG,0BAA0B,CAAS;EACjD,GAAI;CACL,CAAA;AAEL,CAAC;AACD,EAAc,cAAc;AAE5B,IAAa,IAAmB,EAG9B,SAA0B,EAAE,cAAW,aAAU,GAAG,KAAS,GAAK;CAClE,OACE,kBAAC,EAAmB,QAApB;EAA2B,WAAU;EACnC,UAAA,kBAAC,EAAmB,SAApB;GACO;GACL,WAAW,EACT,qGACA,kEACA,qBACA,iHACA,uCACA,CACF;GACA,GAAI;GAVN,UAAA,CAYG,GACD,kBAAC,GAAD;IACE,WAAU;IACV,eAAA;GACD,CAAA,CACyB;;CACH,CAAA;AAE/B,CAAC;AACD,EAAiB,cAAc;AAE/B,IAAa,IAAmB,EAG9B,SAA0B,EAAE,cAAW,aAAU,GAAG,KAAS,GAAK;CAClE,OACE,kBAAC,EAAmB,SAApB;EACO;EACL,WAAW,EACT,iDAKA,mFACF;EACA,GAAI;EAEJ,UAAA,kBAAC,OAAD;GAAK,WAAW,EAAG,aAAa,CAAS;GAAI;EAAc,CAAA;CACjC,CAAA;AAEhC,CAAC;AACD,EAAiB,cAAc"}
|
|
@@ -1,79 +1,73 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
children: /* @__PURE__ */ e(A, { className: "size-3.5", "aria-hidden": !0 })
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
);
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { cva as t } from "../../lib/cva.js";
|
|
4
|
+
import { useStrings as n } from "../../hooks/use-strings.js";
|
|
5
|
+
import { AlertTriangle as r, CheckCircle2 as i, Info as a, X as o, XCircle as s } from "../../icons/index.js";
|
|
6
|
+
import { createElement as c, forwardRef as l, useState as u } from "react";
|
|
7
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/ui/Alert.tsx
|
|
9
|
+
var p = t(["relative flex w-full gap-3 rounded-lg border p-4", "text-sm"], {
|
|
10
|
+
variants: { variant: {
|
|
11
|
+
default: "border-border bg-background-subtle text-foreground",
|
|
12
|
+
info: "border-info-border-soft bg-info-soft text-info-text",
|
|
13
|
+
success: "border-success-border-soft bg-success-soft text-success-text",
|
|
14
|
+
warning: "border-warning-border-soft bg-warning-soft text-warning-text",
|
|
15
|
+
danger: "border-danger-border-soft bg-danger-soft text-danger-text"
|
|
16
|
+
} },
|
|
17
|
+
defaultVariants: { variant: "default" }
|
|
18
|
+
}), m = {
|
|
19
|
+
default: null,
|
|
20
|
+
info: /* @__PURE__ */ d(a, {
|
|
21
|
+
className: "mt-0.5 size-4 shrink-0",
|
|
22
|
+
"aria-hidden": !0
|
|
23
|
+
}),
|
|
24
|
+
success: /* @__PURE__ */ d(i, {
|
|
25
|
+
className: "mt-0.5 size-4 shrink-0",
|
|
26
|
+
"aria-hidden": !0
|
|
27
|
+
}),
|
|
28
|
+
warning: /* @__PURE__ */ d(r, {
|
|
29
|
+
className: "mt-0.5 size-4 shrink-0",
|
|
30
|
+
"aria-hidden": !0
|
|
31
|
+
}),
|
|
32
|
+
danger: /* @__PURE__ */ d(s, {
|
|
33
|
+
className: "mt-0.5 size-4 shrink-0",
|
|
34
|
+
"aria-hidden": !0
|
|
35
|
+
})
|
|
36
|
+
}, h = l(function({ className: t, variant: r = "default", title: i, dismissible: a, onDismiss: s, open: l, onOpenChange: h, icon: g, live: _ = !1, headingLevel: v = 3, children: y, ...b }, x) {
|
|
37
|
+
let S = n(), [C, w] = u(!0);
|
|
38
|
+
if (!(l ?? C)) return null;
|
|
39
|
+
let T = () => {
|
|
40
|
+
l === void 0 && w(!1), h?.(!1), s?.();
|
|
41
|
+
}, E = g === !1 ? null : g ?? m[r ?? "default"];
|
|
42
|
+
return /* @__PURE__ */ f("div", {
|
|
43
|
+
ref: x,
|
|
44
|
+
role: _ ? r === "danger" ? "alert" : "status" : void 0,
|
|
45
|
+
className: e(p({ variant: r }), t),
|
|
46
|
+
...b,
|
|
47
|
+
children: [
|
|
48
|
+
E,
|
|
49
|
+
/* @__PURE__ */ f("div", {
|
|
50
|
+
className: "min-w-0 flex-1",
|
|
51
|
+
children: [i && c(`h${v}`, { className: "mb-1 leading-tight font-medium" }, i), /* @__PURE__ */ d("div", {
|
|
52
|
+
className: "text-sm leading-relaxed [&_p]:leading-relaxed",
|
|
53
|
+
children: y
|
|
54
|
+
})]
|
|
55
|
+
}),
|
|
56
|
+
a && /* @__PURE__ */ d("button", {
|
|
57
|
+
type: "button",
|
|
58
|
+
"aria-label": S.alert.dismiss,
|
|
59
|
+
onClick: T,
|
|
60
|
+
className: e("inline-flex size-6 shrink-0 items-center justify-center rounded-md", "outline-none hover:bg-current/10", "focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2"),
|
|
61
|
+
children: /* @__PURE__ */ d(o, {
|
|
62
|
+
className: "size-3.5",
|
|
63
|
+
"aria-hidden": !0
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
74
68
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
//# sourceMappingURL=Alert.js.map
|
|
69
|
+
h.displayName = "Alert";
|
|
70
|
+
//#endregion
|
|
71
|
+
export { h as Alert };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=Alert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sources":["../../../src/components/ui/Alert.tsx"],"sourcesContent":["'use client';\n\nimport { createElement, forwardRef, useState, type HTMLAttributes, type ReactNode } from 'react';\nimport { AlertTriangle, CheckCircle2, Info, X, XCircle } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { cva, type VariantProps } from '@/lib/cva';\n\nconst alert = cva(['relative flex w-full gap-3 rounded-lg border p-4', 'text-sm'], {\n variants: {\n variant: {\n default: 'border-border bg-background-subtle text-foreground',\n info: 'border-info-border-soft bg-info-soft text-info-text',\n success: 'border-success-border-soft bg-success-soft text-success-text',\n warning: 'border-warning-border-soft bg-warning-soft text-warning-text',\n danger: 'border-danger-border-soft bg-danger-soft text-danger-text',\n },\n },\n defaultVariants: { variant: 'default' },\n});\n\nconst iconForVariant = {\n default: null,\n info: <Info className=\"mt-0.5 size-4 shrink-0\" aria-hidden />,\n success: <CheckCircle2 className=\"mt-0.5 size-4 shrink-0\" aria-hidden />,\n warning: <AlertTriangle className=\"mt-0.5 size-4 shrink-0\" aria-hidden />,\n danger: <XCircle className=\"mt-0.5 size-4 shrink-0\" aria-hidden />,\n};\n\nexport interface AlertProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>, VariantProps<typeof alert> {\n /** Heading. Renders bold above the description. */\n title?: ReactNode;\n /** Show a dismiss (×) button. */\n dismissible?: boolean;\n /** Called when the user dismisses. */\n onDismiss?: () => void;\n /**\n * Controlled visibility. Omit for the default uncontrolled behaviour\n * (visible until dismissed).\n */\n open?: boolean;\n /** Called with the next visibility when the user dismisses. */\n onOpenChange?: (open: boolean) => void;\n /** Override the variant's default icon. Pass `false` to suppress the icon. */\n icon?: ReactNode | false;\n /**\n * Announce the alert to screen readers when it appears: `role=\"alert\"` for\n * `danger`, `role=\"status\"` otherwise. Off by default — content that is on\n * the page at load should not be announced as a live update.\n * @default false\n */\n live?: boolean;\n /** Heading level of `title`. Default 3 — fits under a page h1 / section h2. */\n headingLevel?: 2 | 3 | 4 | 5 | 6;\n}\n\n/**\n * Inline banner for static page-level or section-level state. For transient\n * notifications use `Toast` instead.\n *\n * @example Inline error\n * <Alert variant=\"danger\" title=\"Payment failed\">\n * Your card was declined. Update your billing info to retry.\n * </Alert>\n *\n * @example Dismissible info\n * <Alert variant=\"info\" dismissible onDismiss={dismiss}>\n * We're improving search — give us feedback at #search-feedback.\n * </Alert>\n *\n * @do Use the closest semantic variant — `info` for neutral facts,\n * `warning` for \"watch out\", `danger` for \"this is broken\".\n * @dont Use Alert for one-time confirmations — that's Toast.\n */\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(\n {\n className,\n variant = 'default',\n title,\n dismissible,\n onDismiss,\n open: openProp,\n onOpenChange,\n icon,\n live = false,\n headingLevel = 3,\n children,\n ...props\n },\n ref,\n) {\n const strings = useStrings();\n const [internalOpen, setInternalOpen] = useState(true);\n const open = openProp ?? internalOpen;\n if (!open) return null;\n\n const handleDismiss = () => {\n if (openProp === undefined) setInternalOpen(false);\n onOpenChange?.(false);\n onDismiss?.();\n };\n\n const renderedIcon = icon === false ? null : (icon ?? iconForVariant[variant ?? 'default']);\n\n return (\n <div\n ref={ref}\n // Only errors interrupt the screen reader; everything else is polite.\n role={live ? (variant === 'danger' ? 'alert' : 'status') : undefined}\n className={cn(alert({ variant }), className)}\n {...props}\n >\n {renderedIcon}\n <div className=\"min-w-0 flex-1\">\n {title &&\n createElement(`h${headingLevel}`, { className: 'mb-1 leading-tight font-medium' }, title)}\n <div className=\"text-sm leading-relaxed [&_p]:leading-relaxed\">{children}</div>\n </div>\n {dismissible && (\n <button\n type=\"button\"\n aria-label={strings.alert.dismiss}\n onClick={handleDismiss}\n className={cn(\n 'inline-flex size-6 shrink-0 items-center justify-center rounded-md',\n 'outline-none hover:bg-current/10',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n )}\n >\n <X className=\"size-3.5\" aria-hidden />\n </button>\n )}\n </div>\n );\n});\nAlert.displayName = 'Alert';\n"],"
|
|
1
|
+
{"version":3,"file":"Alert.js","names":[],"sources":["../../../src/components/ui/Alert.tsx"],"sourcesContent":["'use client';\n\nimport { createElement, forwardRef, useState, type HTMLAttributes, type ReactNode } from 'react';\nimport { AlertTriangle, CheckCircle2, Info, X, XCircle } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { cva, type VariantProps } from '@/lib/cva';\n\nconst alert = cva(['relative flex w-full gap-3 rounded-lg border p-4', 'text-sm'], {\n variants: {\n variant: {\n default: 'border-border bg-background-subtle text-foreground',\n info: 'border-info-border-soft bg-info-soft text-info-text',\n success: 'border-success-border-soft bg-success-soft text-success-text',\n warning: 'border-warning-border-soft bg-warning-soft text-warning-text',\n danger: 'border-danger-border-soft bg-danger-soft text-danger-text',\n },\n },\n defaultVariants: { variant: 'default' },\n});\n\nconst iconForVariant = {\n default: null,\n info: <Info className=\"mt-0.5 size-4 shrink-0\" aria-hidden />,\n success: <CheckCircle2 className=\"mt-0.5 size-4 shrink-0\" aria-hidden />,\n warning: <AlertTriangle className=\"mt-0.5 size-4 shrink-0\" aria-hidden />,\n danger: <XCircle className=\"mt-0.5 size-4 shrink-0\" aria-hidden />,\n};\n\nexport interface AlertProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>, VariantProps<typeof alert> {\n /** Heading. Renders bold above the description. */\n title?: ReactNode;\n /** Show a dismiss (×) button. */\n dismissible?: boolean;\n /** Called when the user dismisses. */\n onDismiss?: () => void;\n /**\n * Controlled visibility. Omit for the default uncontrolled behaviour\n * (visible until dismissed).\n */\n open?: boolean;\n /** Called with the next visibility when the user dismisses. */\n onOpenChange?: (open: boolean) => void;\n /** Override the variant's default icon. Pass `false` to suppress the icon. */\n icon?: ReactNode | false;\n /**\n * Announce the alert to screen readers when it appears: `role=\"alert\"` for\n * `danger`, `role=\"status\"` otherwise. Off by default — content that is on\n * the page at load should not be announced as a live update.\n * @default false\n */\n live?: boolean;\n /** Heading level of `title`. Default 3 — fits under a page h1 / section h2. */\n headingLevel?: 2 | 3 | 4 | 5 | 6;\n}\n\n/**\n * Inline banner for static page-level or section-level state. For transient\n * notifications use `Toast` instead.\n *\n * @example Inline error\n * <Alert variant=\"danger\" title=\"Payment failed\">\n * Your card was declined. Update your billing info to retry.\n * </Alert>\n *\n * @example Dismissible info\n * <Alert variant=\"info\" dismissible onDismiss={dismiss}>\n * We're improving search — give us feedback at #search-feedback.\n * </Alert>\n *\n * @do Use the closest semantic variant — `info` for neutral facts,\n * `warning` for \"watch out\", `danger` for \"this is broken\".\n * @dont Use Alert for one-time confirmations — that's Toast.\n */\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(\n {\n className,\n variant = 'default',\n title,\n dismissible,\n onDismiss,\n open: openProp,\n onOpenChange,\n icon,\n live = false,\n headingLevel = 3,\n children,\n ...props\n },\n ref,\n) {\n const strings = useStrings();\n const [internalOpen, setInternalOpen] = useState(true);\n const open = openProp ?? internalOpen;\n if (!open) return null;\n\n const handleDismiss = () => {\n if (openProp === undefined) setInternalOpen(false);\n onOpenChange?.(false);\n onDismiss?.();\n };\n\n const renderedIcon = icon === false ? null : (icon ?? iconForVariant[variant ?? 'default']);\n\n return (\n <div\n ref={ref}\n // Only errors interrupt the screen reader; everything else is polite.\n role={live ? (variant === 'danger' ? 'alert' : 'status') : undefined}\n className={cn(alert({ variant }), className)}\n {...props}\n >\n {renderedIcon}\n <div className=\"min-w-0 flex-1\">\n {title &&\n createElement(`h${headingLevel}`, { className: 'mb-1 leading-tight font-medium' }, title)}\n <div className=\"text-sm leading-relaxed [&_p]:leading-relaxed\">{children}</div>\n </div>\n {dismissible && (\n <button\n type=\"button\"\n aria-label={strings.alert.dismiss}\n onClick={handleDismiss}\n className={cn(\n 'inline-flex size-6 shrink-0 items-center justify-center rounded-md',\n 'outline-none hover:bg-current/10',\n 'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2',\n )}\n >\n <X className=\"size-3.5\" aria-hidden />\n </button>\n )}\n </div>\n );\n});\nAlert.displayName = 'Alert';\n"],"mappings":";;;;;;;;AAQA,IAAM,IAAQ,EAAI,CAAC,oDAAoD,SAAS,GAAG;CACjF,UAAU,EACR,SAAS;EACP,SAAS;EACT,MAAM;EACN,SAAS;EACT,SAAS;EACT,QAAQ;CACV,EACF;CACA,iBAAiB,EAAE,SAAS,UAAU;AACxC,CAAC,GAEK,IAAiB;CACrB,SAAS;CACT,MAAM,kBAAC,GAAD;EAAM,WAAU;EAAyB,eAAA;CAAa,CAAA;CAC5D,SAAS,kBAAC,GAAD;EAAc,WAAU;EAAyB,eAAA;CAAa,CAAA;CACvE,SAAS,kBAAC,GAAD;EAAe,WAAU;EAAyB,eAAA;CAAa,CAAA;CACxE,QAAQ,kBAAC,GAAD;EAAS,WAAU;EAAyB,eAAA;CAAa,CAAA;AACnE,GAgDa,IAAQ,EAAuC,SAC1D,EACE,cACA,aAAU,WACV,UACA,gBACA,cACA,MAAM,GACN,iBACA,SACA,UAAO,IACP,kBAAe,GACf,aACA,GAAG,KAEL,GACA;CACA,IAAM,IAAU,EAAW,GACrB,CAAC,GAAc,KAAmB,EAAS,EAAI;CAErD,IAAI,EADS,KAAY,IACd,OAAO;CAElB,IAAM,UAAsB;EAG1B,AAFI,MAAa,KAAA,KAAW,EAAgB,EAAK,GACjD,IAAe,EAAK,GACpB,IAAY;CACd,GAEM,IAAe,MAAS,KAAQ,OAAQ,KAAQ,EAAe,KAAW;CAEhF,OACE,kBAAC,OAAD;EACO;EAEL,MAAM,IAAQ,MAAY,WAAW,UAAU,WAAY,KAAA;EAC3D,WAAW,EAAG,EAAM,EAAE,WAAQ,CAAC,GAAG,CAAS;EAC3C,GAAI;EALN,UAAA;GAOG;GACD,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,KACC,EAAc,IAAI,KAAgB,EAAE,WAAW,iCAAiC,GAAG,CAAK,GAC1F,kBAAC,OAAD;KAAK,WAAU;KAAiD;IAAc,CAAA,CAC3E;;GACJ,KACC,kBAAC,UAAD;IACE,MAAK;IACL,cAAY,EAAQ,MAAM;IAC1B,SAAS;IACT,WAAW,EACT,sEACA,oCACA,+GACF;IAEA,UAAA,kBAAC,GAAD;KAAG,WAAU;KAAW,eAAA;IAAa,CAAA;GAC/B,CAAA;EAEP;;AAET,CAAC;AACD,EAAM,cAAc"}
|
|
@@ -1,94 +1,69 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
children: u ?? "?"
|
|
48
|
-
}
|
|
49
|
-
)
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
),
|
|
53
|
-
r && /* @__PURE__ */ i(
|
|
54
|
-
"span",
|
|
55
|
-
{
|
|
56
|
-
role: "img",
|
|
57
|
-
"aria-label": v(s.avatar.status, { status: r }),
|
|
58
|
-
className: l(
|
|
59
|
-
"ring-background absolute right-0 bottom-0 block size-[28%] rounded-full ring-2",
|
|
60
|
-
w[r]
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
] });
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
G.displayName = "Avatar";
|
|
68
|
-
const C = b(function({ max: m = 4, size: t = "md", className: e, children: c, ...u }, r) {
|
|
69
|
-
const d = p(), a = N.toArray(c), s = a.slice(0, m), f = a.length - s.length;
|
|
70
|
-
return /* @__PURE__ */ o("div", { ref: r, className: l("flex items-center -space-x-2", e), ...u, children: [
|
|
71
|
-
s.map((n, k) => /* @__PURE__ */ i("div", { className: "ring-background rounded-full ring-2", children: h(n) && n.props.size === void 0 ? y(n, { size: t }) : n }, k)),
|
|
72
|
-
f > 0 && /* @__PURE__ */ o(
|
|
73
|
-
"div",
|
|
74
|
-
{
|
|
75
|
-
className: l(
|
|
76
|
-
"bg-background-muted text-foreground-muted ring-background inline-flex items-center justify-center rounded-full ring-2",
|
|
77
|
-
x[t],
|
|
78
|
-
"font-medium"
|
|
79
|
-
),
|
|
80
|
-
"aria-label": v(d.avatar.more, { n: f }),
|
|
81
|
-
children: [
|
|
82
|
-
"+",
|
|
83
|
-
f
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
)
|
|
87
|
-
] });
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { cva as t } from "../../lib/cva.js";
|
|
4
|
+
import { formatString as n } from "../../lib/strings.js";
|
|
5
|
+
import { useStrings as r } from "../../hooks/use-strings.js";
|
|
6
|
+
import { Children as i, cloneElement as a, forwardRef as o, isValidElement as s } from "react";
|
|
7
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
|
+
import * as u from "@radix-ui/react-avatar";
|
|
9
|
+
//#region src/components/ui/Avatar.tsx
|
|
10
|
+
var d = {
|
|
11
|
+
xs: "size-5 text-xs",
|
|
12
|
+
sm: "size-6 text-xs",
|
|
13
|
+
md: "size-8 text-xs",
|
|
14
|
+
lg: "size-10 text-sm",
|
|
15
|
+
xl: "size-12 text-base"
|
|
16
|
+
}, f = t("relative inline-flex shrink-0", {
|
|
17
|
+
variants: { size: d },
|
|
18
|
+
defaultVariants: { size: "md" }
|
|
19
|
+
}), p = {
|
|
20
|
+
online: "bg-success",
|
|
21
|
+
busy: "bg-danger",
|
|
22
|
+
away: "bg-warning",
|
|
23
|
+
offline: "bg-foreground-subtle"
|
|
24
|
+
}, m = o(function({ className: t, size: i, src: a, alt: o, fallback: s, status: d, ...m }, h) {
|
|
25
|
+
let g = r();
|
|
26
|
+
return /* @__PURE__ */ l("span", {
|
|
27
|
+
className: e(f({ size: i }), t),
|
|
28
|
+
children: [/* @__PURE__ */ l(u.Root, {
|
|
29
|
+
ref: h,
|
|
30
|
+
className: "bg-background-muted text-foreground-muted block size-full overflow-hidden rounded-full",
|
|
31
|
+
...m,
|
|
32
|
+
children: [a && /* @__PURE__ */ c(u.Image, {
|
|
33
|
+
src: a,
|
|
34
|
+
alt: o ?? "",
|
|
35
|
+
className: "aspect-square size-full object-cover"
|
|
36
|
+
}), /* @__PURE__ */ c(u.Fallback, {
|
|
37
|
+
delayMs: a ? 200 : 0,
|
|
38
|
+
className: "bg-background-muted flex size-full items-center justify-center font-medium uppercase",
|
|
39
|
+
children: s ?? "?"
|
|
40
|
+
})]
|
|
41
|
+
}), d && /* @__PURE__ */ c("span", {
|
|
42
|
+
role: "img",
|
|
43
|
+
"aria-label": n(g.avatar.status, { status: d }),
|
|
44
|
+
className: e("ring-background absolute right-0 bottom-0 block size-[28%] rounded-full ring-2", p[d])
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
88
47
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
48
|
+
m.displayName = "Avatar";
|
|
49
|
+
var h = o(function({ max: t = 4, size: o = "md", className: u, children: f, ...p }, m) {
|
|
50
|
+
let h = r(), g = i.toArray(f), _ = g.slice(0, t), v = g.length - _.length;
|
|
51
|
+
return /* @__PURE__ */ l("div", {
|
|
52
|
+
ref: m,
|
|
53
|
+
className: e("flex items-center -space-x-2", u),
|
|
54
|
+
...p,
|
|
55
|
+
children: [_.map((e, t) => /* @__PURE__ */ c("div", {
|
|
56
|
+
className: "ring-background rounded-full ring-2",
|
|
57
|
+
children: s(e) && e.props.size === void 0 ? a(e, { size: o }) : e
|
|
58
|
+
}, t)), v > 0 && /* @__PURE__ */ l("div", {
|
|
59
|
+
className: e("bg-background-muted text-foreground-muted ring-background inline-flex items-center justify-center rounded-full ring-2", d[o], "font-medium"),
|
|
60
|
+
"aria-label": n(h.avatar.more, { n: v }),
|
|
61
|
+
children: ["+", v]
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
h.displayName = "AvatarGroup";
|
|
66
|
+
//#endregion
|
|
67
|
+
export { m as Avatar, h as AvatarGroup };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=Avatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sources":["../../../src/components/ui/Avatar.tsx"],"sourcesContent":["'use client';\n\nimport {\n Children,\n cloneElement,\n forwardRef,\n isValidElement,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport * as AvatarPrimitive from '@radix-ui/react-avatar';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString } from '@/lib/strings';\nimport { cva, type VariantProps } from '@/lib/cva';\n\nconst sizeMap = {\n xs: 'size-5 text-xs',\n sm: 'size-6 text-xs',\n md: 'size-8 text-xs',\n lg: 'size-10 text-sm',\n xl: 'size-12 text-base',\n} as const;\n\n// The wrapper sets size — Root sits inside and clips image/fallback only.\nconst avatarWrapper = cva('relative inline-flex shrink-0', {\n variants: { size: sizeMap },\n defaultVariants: { size: 'md' },\n});\n\nexport interface AvatarProps\n extends\n ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,\n VariantProps<typeof avatarWrapper> {\n /** Image URL. If absent or fails to load, fallback initials are shown. */\n src?: string;\n /** Alt text for the image; falls back to fallback when there's no `src`. */\n alt?: string;\n /** Initials shown when image is missing or loading. Pass at most 2 characters. */\n fallback?: string;\n /** Status dot rendered on the bottom-right. */\n status?: 'online' | 'busy' | 'away' | 'offline';\n}\n\nconst statusColour: Record<NonNullable<AvatarProps['status']>, string> = {\n online: 'bg-success',\n busy: 'bg-danger',\n away: 'bg-warning',\n offline: 'bg-foreground-subtle',\n};\n\n/**\n * Avatar with image, initials fallback, and optional status dot.\n *\n * @example\n * <Avatar src={user.photo} alt={user.name} fallback={getInitials(user.name)} status=\"online\" />\n *\n * @example AvatarGroup\n * <AvatarGroup max={3}>\n * {users.map(u => <Avatar key={u.id} src={u.photo} fallback={getInitials(u.name)} />)}\n * </AvatarGroup>\n *\n * @do Provide `alt` for image avatars and meaningful initials for the\n * fallback so screen readers announce something useful.\n * @dont Use the status dot without a tooltip explaining what it means.\n */\nexport const Avatar = forwardRef<ElementRef<typeof AvatarPrimitive.Root>, AvatarProps>(\n function Avatar({ className, size, src, alt, fallback, status, ...props }, ref) {\n const strings = useStrings();\n return (\n <span className={cn(avatarWrapper({ size }), className)}>\n <AvatarPrimitive.Root\n ref={ref}\n className=\"bg-background-muted text-foreground-muted block size-full overflow-hidden rounded-full\"\n {...props}\n >\n {src && (\n <AvatarPrimitive.Image\n src={src}\n alt={alt ?? ''}\n className=\"aspect-square size-full object-cover\"\n />\n )}\n <AvatarPrimitive.Fallback\n delayMs={src ? 200 : 0}\n className=\"bg-background-muted flex size-full items-center justify-center font-medium uppercase\"\n >\n {fallback ?? '?'}\n </AvatarPrimitive.Fallback>\n </AvatarPrimitive.Root>\n {status && (\n <span\n role=\"img\"\n aria-label={formatString(strings.avatar.status, { status })}\n className={cn(\n 'ring-background absolute right-0 bottom-0 block size-[28%] rounded-full ring-2',\n statusColour[status],\n )}\n />\n )}\n </span>\n );\n },\n);\nAvatar.displayName = 'Avatar';\n\nexport interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {\n /** Maximum visible avatars before showing a \"+N\" overflow chip. */\n max?: number;\n /** Avatar size applied to children (unless a child sets its own) + overflow. */\n size?: keyof typeof sizeMap;\n /** Children — Avatars. */\n children: ReactNode;\n}\n\n/**\n * Overlapping avatars with overflow indicator. Pass plain `<Avatar>` children.\n */\nexport const AvatarGroup = forwardRef<HTMLDivElement, AvatarGroupProps>(function AvatarGroup(\n { max = 4, size = 'md', className, children, ...props },\n ref,\n) {\n const strings = useStrings();\n const items = Children.toArray(children);\n const visible = items.slice(0, max);\n const overflow = items.length - visible.length;\n\n return (\n <div ref={ref} className={cn('flex items-center -space-x-2', className)} {...props}>\n {visible.map((child, i) => (\n <div key={i} className=\"ring-background rounded-full ring-2\">\n {isValidElement<AvatarProps>(child) && child.props.size === undefined\n ? cloneElement(child, { size })\n : child}\n </div>\n ))}\n {overflow > 0 && (\n <div\n className={cn(\n 'bg-background-muted text-foreground-muted ring-background inline-flex items-center justify-center rounded-full ring-2',\n sizeMap[size],\n 'font-medium',\n )}\n aria-label={formatString(strings.avatar.more, { n: overflow })}\n >\n +{overflow}\n </div>\n )}\n </div>\n );\n});\nAvatarGroup.displayName = 'AvatarGroup';\n"],"
|
|
1
|
+
{"version":3,"file":"Avatar.js","names":[],"sources":["../../../src/components/ui/Avatar.tsx"],"sourcesContent":["'use client';\n\nimport {\n Children,\n cloneElement,\n forwardRef,\n isValidElement,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport * as AvatarPrimitive from '@radix-ui/react-avatar';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString } from '@/lib/strings';\nimport { cva, type VariantProps } from '@/lib/cva';\n\nconst sizeMap = {\n xs: 'size-5 text-xs',\n sm: 'size-6 text-xs',\n md: 'size-8 text-xs',\n lg: 'size-10 text-sm',\n xl: 'size-12 text-base',\n} as const;\n\n// The wrapper sets size — Root sits inside and clips image/fallback only.\nconst avatarWrapper = cva('relative inline-flex shrink-0', {\n variants: { size: sizeMap },\n defaultVariants: { size: 'md' },\n});\n\nexport interface AvatarProps\n extends\n ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,\n VariantProps<typeof avatarWrapper> {\n /** Image URL. If absent or fails to load, fallback initials are shown. */\n src?: string;\n /** Alt text for the image; falls back to fallback when there's no `src`. */\n alt?: string;\n /** Initials shown when image is missing or loading. Pass at most 2 characters. */\n fallback?: string;\n /** Status dot rendered on the bottom-right. */\n status?: 'online' | 'busy' | 'away' | 'offline';\n}\n\nconst statusColour: Record<NonNullable<AvatarProps['status']>, string> = {\n online: 'bg-success',\n busy: 'bg-danger',\n away: 'bg-warning',\n offline: 'bg-foreground-subtle',\n};\n\n/**\n * Avatar with image, initials fallback, and optional status dot.\n *\n * @example\n * <Avatar src={user.photo} alt={user.name} fallback={getInitials(user.name)} status=\"online\" />\n *\n * @example AvatarGroup\n * <AvatarGroup max={3}>\n * {users.map(u => <Avatar key={u.id} src={u.photo} fallback={getInitials(u.name)} />)}\n * </AvatarGroup>\n *\n * @do Provide `alt` for image avatars and meaningful initials for the\n * fallback so screen readers announce something useful.\n * @dont Use the status dot without a tooltip explaining what it means.\n */\nexport const Avatar = forwardRef<ElementRef<typeof AvatarPrimitive.Root>, AvatarProps>(\n function Avatar({ className, size, src, alt, fallback, status, ...props }, ref) {\n const strings = useStrings();\n return (\n <span className={cn(avatarWrapper({ size }), className)}>\n <AvatarPrimitive.Root\n ref={ref}\n className=\"bg-background-muted text-foreground-muted block size-full overflow-hidden rounded-full\"\n {...props}\n >\n {src && (\n <AvatarPrimitive.Image\n src={src}\n alt={alt ?? ''}\n className=\"aspect-square size-full object-cover\"\n />\n )}\n <AvatarPrimitive.Fallback\n delayMs={src ? 200 : 0}\n className=\"bg-background-muted flex size-full items-center justify-center font-medium uppercase\"\n >\n {fallback ?? '?'}\n </AvatarPrimitive.Fallback>\n </AvatarPrimitive.Root>\n {status && (\n <span\n role=\"img\"\n aria-label={formatString(strings.avatar.status, { status })}\n className={cn(\n 'ring-background absolute right-0 bottom-0 block size-[28%] rounded-full ring-2',\n statusColour[status],\n )}\n />\n )}\n </span>\n );\n },\n);\nAvatar.displayName = 'Avatar';\n\nexport interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {\n /** Maximum visible avatars before showing a \"+N\" overflow chip. */\n max?: number;\n /** Avatar size applied to children (unless a child sets its own) + overflow. */\n size?: keyof typeof sizeMap;\n /** Children — Avatars. */\n children: ReactNode;\n}\n\n/**\n * Overlapping avatars with overflow indicator. Pass plain `<Avatar>` children.\n */\nexport const AvatarGroup = forwardRef<HTMLDivElement, AvatarGroupProps>(function AvatarGroup(\n { max = 4, size = 'md', className, children, ...props },\n ref,\n) {\n const strings = useStrings();\n const items = Children.toArray(children);\n const visible = items.slice(0, max);\n const overflow = items.length - visible.length;\n\n return (\n <div ref={ref} className={cn('flex items-center -space-x-2', className)} {...props}>\n {visible.map((child, i) => (\n <div key={i} className=\"ring-background rounded-full ring-2\">\n {isValidElement<AvatarProps>(child) && child.props.size === undefined\n ? cloneElement(child, { size })\n : child}\n </div>\n ))}\n {overflow > 0 && (\n <div\n className={cn(\n 'bg-background-muted text-foreground-muted ring-background inline-flex items-center justify-center rounded-full ring-2',\n sizeMap[size],\n 'font-medium',\n )}\n aria-label={formatString(strings.avatar.more, { n: overflow })}\n >\n +{overflow}\n </div>\n )}\n </div>\n );\n});\nAvatarGroup.displayName = 'AvatarGroup';\n"],"mappings":";;;;;;;;;AAkBA,IAAM,IAAU;CACd,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN,GAGM,IAAgB,EAAI,iCAAiC;CACzD,UAAU,EAAE,MAAM,EAAQ;CAC1B,iBAAiB,EAAE,MAAM,KAAK;AAChC,CAAC,GAgBK,IAAmE;CACvE,QAAQ;CACR,MAAM;CACN,MAAM;CACN,SAAS;AACX,GAiBa,IAAS,EACpB,SAAgB,EAAE,cAAW,SAAM,QAAK,QAAK,aAAU,WAAQ,GAAG,KAAS,GAAK;CAC9E,IAAM,IAAU,EAAW;CAC3B,OACE,kBAAC,QAAD;EAAM,WAAW,EAAG,EAAc,EAAE,QAAK,CAAC,GAAG,CAAS;EAAtD,UAAA,CACE,kBAAC,EAAgB,MAAjB;GACO;GACL,WAAU;GACV,GAAI;GAHN,UAAA,CAKG,KACC,kBAAC,EAAgB,OAAjB;IACO;IACL,KAAK,KAAO;IACZ,WAAU;GACX,CAAA,GAEH,kBAAC,EAAgB,UAAjB;IACE,SAAS,IAAM,MAAM;IACrB,WAAU;IAET,UAAA,KAAY;GACW,CAAA,CACN;EACrB,CAAA,GAAA,KACC,kBAAC,QAAD;GACE,MAAK;GACL,cAAY,EAAa,EAAQ,OAAO,QAAQ,EAAE,UAAO,CAAC;GAC1D,WAAW,EACT,kFACA,EAAa,EACf;EACD,CAAA,CAEC;;AAEV,CACF;AACA,EAAO,cAAc;AAcrB,IAAa,IAAc,EAA6C,SACtE,EAAE,SAAM,GAAG,UAAO,MAAM,cAAW,aAAU,GAAG,KAChD,GACA;CACA,IAAM,IAAU,EAAW,GACrB,IAAQ,EAAS,QAAQ,CAAQ,GACjC,IAAU,EAAM,MAAM,GAAG,CAAG,GAC5B,IAAW,EAAM,SAAS,EAAQ;CAExC,OACE,kBAAC,OAAD;EAAU;EAAK,WAAW,EAAG,gCAAgC,CAAS;EAAG,GAAI;EAA7E,UAAA,CACG,EAAQ,KAAK,GAAO,MACnB,kBAAC,OAAD;GAAa,WAAU;GACpB,UAAA,EAA4B,CAAK,KAAK,EAAM,MAAM,SAAS,KAAA,IACxD,EAAa,GAAO,EAAE,QAAK,CAAC,IAC5B;EACD,GAJK,CAIL,CACN,GACA,IAAW,KACV,kBAAC,OAAD;GACE,WAAW,EACT,yHACA,EAAQ,IACR,aACF;GACA,cAAY,EAAa,EAAQ,OAAO,MAAM,EAAE,GAAG,EAAS,CAAC;GAN/D,UAAA,CAOC,KACG,CACC;EAEJ,CAAA,CAAA;;AAET,CAAC;AACD,EAAY,cAAc"}
|