@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
|
@@ -1,76 +1,121 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { cva as t } from "../../lib/cva.js";
|
|
4
|
+
import { forwardRef as n } from "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/ui/Badge.tsx
|
|
7
|
+
var a = t(["inline-flex items-center gap-1 rounded-full px-2 py-0.5", "text-xs font-medium whitespace-nowrap"], {
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
subtle: "",
|
|
11
|
+
outline: "border bg-transparent"
|
|
12
|
+
},
|
|
13
|
+
tone: {
|
|
14
|
+
neutral: "",
|
|
15
|
+
accent: "",
|
|
16
|
+
success: "",
|
|
17
|
+
warning: "",
|
|
18
|
+
danger: "",
|
|
19
|
+
info: ""
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
compoundVariants: [
|
|
23
|
+
{
|
|
24
|
+
variant: "subtle",
|
|
25
|
+
tone: "neutral",
|
|
26
|
+
class: "bg-background-muted text-foreground-muted"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
variant: "subtle",
|
|
30
|
+
tone: "accent",
|
|
31
|
+
class: "bg-accent-soft text-on-accent-soft"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
variant: "subtle",
|
|
35
|
+
tone: "success",
|
|
36
|
+
class: "bg-success-soft text-success-text"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
variant: "subtle",
|
|
40
|
+
tone: "warning",
|
|
41
|
+
class: "bg-warning-soft text-warning-text"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
variant: "subtle",
|
|
45
|
+
tone: "danger",
|
|
46
|
+
class: "bg-danger-soft text-danger-text"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
variant: "subtle",
|
|
50
|
+
tone: "info",
|
|
51
|
+
class: "bg-info-soft text-info-text"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
variant: "outline",
|
|
55
|
+
tone: "neutral",
|
|
56
|
+
class: "border-border text-foreground-muted"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
variant: "outline",
|
|
60
|
+
tone: "accent",
|
|
61
|
+
class: "border-accent text-accent"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
variant: "outline",
|
|
65
|
+
tone: "success",
|
|
66
|
+
class: "border-success-border-soft text-success-text"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
variant: "outline",
|
|
70
|
+
tone: "warning",
|
|
71
|
+
class: "border-warning-border-soft text-warning-text"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
variant: "outline",
|
|
75
|
+
tone: "danger",
|
|
76
|
+
class: "border-danger-border-soft text-danger-text"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
variant: "outline",
|
|
80
|
+
tone: "info",
|
|
81
|
+
class: "border-info-border-soft text-info-text"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
defaultVariants: {
|
|
85
|
+
variant: "subtle",
|
|
86
|
+
tone: "neutral"
|
|
87
|
+
}
|
|
88
|
+
}), o = {
|
|
89
|
+
neutral: "bg-foreground-subtle",
|
|
90
|
+
accent: "bg-accent",
|
|
91
|
+
success: "bg-success",
|
|
92
|
+
warning: "bg-warning",
|
|
93
|
+
danger: "bg-danger",
|
|
94
|
+
info: "bg-info"
|
|
95
|
+
}, s = n(function({ className: t, variant: n, tone: s = "neutral", dot: c, icon: l, children: u, ...d }, f) {
|
|
96
|
+
return /* @__PURE__ */ i("span", {
|
|
97
|
+
ref: f,
|
|
98
|
+
className: e(a({
|
|
99
|
+
variant: n,
|
|
100
|
+
tone: s
|
|
101
|
+
}), t),
|
|
102
|
+
...d,
|
|
103
|
+
children: [
|
|
104
|
+
l && /* @__PURE__ */ r("span", {
|
|
105
|
+
"aria-hidden": !0,
|
|
106
|
+
className: "inline-flex shrink-0 [&_svg]:size-3",
|
|
107
|
+
children: l
|
|
108
|
+
}),
|
|
109
|
+
c && !l && /* @__PURE__ */ r("span", {
|
|
110
|
+
"aria-hidden": !0,
|
|
111
|
+
className: e("inline-block size-1.5 rounded-full", o[s ?? "neutral"])
|
|
112
|
+
}),
|
|
113
|
+
u
|
|
114
|
+
]
|
|
115
|
+
});
|
|
71
116
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
//# sourceMappingURL=Badge.js.map
|
|
117
|
+
s.displayName = "Badge";
|
|
118
|
+
//#endregion
|
|
119
|
+
export { s as Badge };
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sources":["../../../src/components/ui/Badge.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\nimport { cva, type VariantProps } from '@/lib/cva';\n\nconst badge = cva(\n [\n 'inline-flex items-center gap-1 rounded-full px-2 py-0.5',\n 'text-xs font-medium whitespace-nowrap',\n ],\n {\n variants: {\n variant: {\n subtle: '',\n outline: 'border bg-transparent',\n },\n tone: {\n neutral: '',\n accent: '',\n success: '',\n warning: '',\n danger: '',\n info: '',\n },\n },\n compoundVariants: [\n // Subtle — coloured fill + matching text.\n { variant: 'subtle', tone: 'neutral', class: 'bg-background-muted text-foreground-muted' },\n { variant: 'subtle', tone: 'accent', class: 'bg-accent-soft text-on-accent-soft' },\n { variant: 'subtle', tone: 'success', class: 'bg-success-soft text-success-text' },\n { variant: 'subtle', tone: 'warning', class: 'bg-warning-soft text-warning-text' },\n { variant: 'subtle', tone: 'danger', class: 'bg-danger-soft text-danger-text' },\n { variant: 'subtle', tone: 'info', class: 'bg-info-soft text-info-text' },\n // Outline — coloured border + text, transparent fill.\n { variant: 'outline', tone: 'neutral', class: 'border-border text-foreground-muted' },\n { variant: 'outline', tone: 'accent', class: 'border-accent text-accent' },\n {\n variant: 'outline',\n tone: 'success',\n class: 'border-success-border-soft text-success-text',\n },\n {\n variant: 'outline',\n tone: 'warning',\n class: 'border-warning-border-soft text-warning-text',\n },\n { variant: 'outline', tone: 'danger', class: 'border-danger-border-soft text-danger-text' },\n { variant: 'outline', tone: 'info', class: 'border-info-border-soft text-info-text' },\n ],\n defaultVariants: { variant: 'subtle', tone: 'neutral' },\n },\n);\n\nexport interface BadgeProps extends HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badge> {\n /** Show a leading status dot in the same tone. */\n dot?: boolean;\n /** Leading icon (decorative — sized 12px, `aria-hidden`). Overrides `dot`. */\n icon?: ReactNode;\n}\n\nconst dotColour = {\n neutral: 'bg-foreground-subtle',\n accent: 'bg-accent',\n success: 'bg-success',\n warning: 'bg-warning',\n danger: 'bg-danger',\n info: 'bg-info',\n} as const;\n\n/**\n * Status pill. Use `subtle` for high-volume contexts (table cells, lists);\n * `outline` when the badge sits on a busy or coloured background.\n *\n * @example\n * <Badge tone=\"success\" dot>Active</Badge>\n * <Badge tone=\"danger\" variant=\"outline\">Failed</Badge>\n *\n * @do Use badges to summarise state, not to label categories — for taxonomies\n * pick a tone palette and stick with it.\n * @dont Use a badge as a button. Wrap it in a Button or use a Toggle.\n */\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n { className, variant, tone = 'neutral', dot, icon, children, ...props },\n ref,\n) {\n return (\n <span ref={ref} className={cn(badge({ variant, tone }), className)} {...props}>\n {icon && (\n <span aria-hidden className=\"inline-flex shrink-0 [&_svg]:size-3\">\n {icon}\n </span>\n )}\n {dot && !icon && (\n <span\n aria-hidden\n className={cn('inline-block size-1.5 rounded-full', dotColour[tone ?? 'neutral'])}\n />\n )}\n {children}\n </span>\n );\n});\nBadge.displayName = 'Badge';\n"],"
|
|
1
|
+
{"version":3,"file":"Badge.js","names":[],"sources":["../../../src/components/ui/Badge.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\nimport { cva, type VariantProps } from '@/lib/cva';\n\nconst badge = cva(\n [\n 'inline-flex items-center gap-1 rounded-full px-2 py-0.5',\n 'text-xs font-medium whitespace-nowrap',\n ],\n {\n variants: {\n variant: {\n subtle: '',\n outline: 'border bg-transparent',\n },\n tone: {\n neutral: '',\n accent: '',\n success: '',\n warning: '',\n danger: '',\n info: '',\n },\n },\n compoundVariants: [\n // Subtle — coloured fill + matching text.\n { variant: 'subtle', tone: 'neutral', class: 'bg-background-muted text-foreground-muted' },\n { variant: 'subtle', tone: 'accent', class: 'bg-accent-soft text-on-accent-soft' },\n { variant: 'subtle', tone: 'success', class: 'bg-success-soft text-success-text' },\n { variant: 'subtle', tone: 'warning', class: 'bg-warning-soft text-warning-text' },\n { variant: 'subtle', tone: 'danger', class: 'bg-danger-soft text-danger-text' },\n { variant: 'subtle', tone: 'info', class: 'bg-info-soft text-info-text' },\n // Outline — coloured border + text, transparent fill.\n { variant: 'outline', tone: 'neutral', class: 'border-border text-foreground-muted' },\n { variant: 'outline', tone: 'accent', class: 'border-accent text-accent' },\n {\n variant: 'outline',\n tone: 'success',\n class: 'border-success-border-soft text-success-text',\n },\n {\n variant: 'outline',\n tone: 'warning',\n class: 'border-warning-border-soft text-warning-text',\n },\n { variant: 'outline', tone: 'danger', class: 'border-danger-border-soft text-danger-text' },\n { variant: 'outline', tone: 'info', class: 'border-info-border-soft text-info-text' },\n ],\n defaultVariants: { variant: 'subtle', tone: 'neutral' },\n },\n);\n\nexport interface BadgeProps extends HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badge> {\n /** Show a leading status dot in the same tone. */\n dot?: boolean;\n /** Leading icon (decorative — sized 12px, `aria-hidden`). Overrides `dot`. */\n icon?: ReactNode;\n}\n\nconst dotColour = {\n neutral: 'bg-foreground-subtle',\n accent: 'bg-accent',\n success: 'bg-success',\n warning: 'bg-warning',\n danger: 'bg-danger',\n info: 'bg-info',\n} as const;\n\n/**\n * Status pill. Use `subtle` for high-volume contexts (table cells, lists);\n * `outline` when the badge sits on a busy or coloured background.\n *\n * @example\n * <Badge tone=\"success\" dot>Active</Badge>\n * <Badge tone=\"danger\" variant=\"outline\">Failed</Badge>\n *\n * @do Use badges to summarise state, not to label categories — for taxonomies\n * pick a tone palette and stick with it.\n * @dont Use a badge as a button. Wrap it in a Button or use a Toggle.\n */\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n { className, variant, tone = 'neutral', dot, icon, children, ...props },\n ref,\n) {\n return (\n <span ref={ref} className={cn(badge({ variant, tone }), className)} {...props}>\n {icon && (\n <span aria-hidden className=\"inline-flex shrink-0 [&_svg]:size-3\">\n {icon}\n </span>\n )}\n {dot && !icon && (\n <span\n aria-hidden\n className={cn('inline-block size-1.5 rounded-full', dotColour[tone ?? 'neutral'])}\n />\n )}\n {children}\n </span>\n );\n});\nBadge.displayName = 'Badge';\n"],"mappings":";;;;;;AAMA,IAAM,IAAQ,EACZ,CACE,2DACA,uCACF,GACA;CACE,UAAU;EACR,SAAS;GACP,QAAQ;GACR,SAAS;EACX;EACA,MAAM;GACJ,SAAS;GACT,QAAQ;GACR,SAAS;GACT,SAAS;GACT,QAAQ;GACR,MAAM;EACR;CACF;CACA,kBAAkB;EAEhB;GAAE,SAAS;GAAU,MAAM;GAAW,OAAO;EAA4C;EACzF;GAAE,SAAS;GAAU,MAAM;GAAU,OAAO;EAAqC;EACjF;GAAE,SAAS;GAAU,MAAM;GAAW,OAAO;EAAoC;EACjF;GAAE,SAAS;GAAU,MAAM;GAAW,OAAO;EAAoC;EACjF;GAAE,SAAS;GAAU,MAAM;GAAU,OAAO;EAAkC;EAC9E;GAAE,SAAS;GAAU,MAAM;GAAQ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|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { useStrings as t } from "../../hooks/use-strings.js";
|
|
4
|
+
import { ChevronRight as n, MoreHorizontal as r } from "../../icons/index.js";
|
|
5
|
+
import { forwardRef as i } from "react";
|
|
6
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/ui/Breadcrumbs.tsx
|
|
8
|
+
var s = i(function({ items: i, maxItems: s = 4, renderLink: c, collapsedLabel: l, className: u, "aria-label": d, ...f }, p) {
|
|
9
|
+
let m = t(), h = l ?? m.breadcrumbs.collapsed, g = i.length > s ? [
|
|
10
|
+
i[0],
|
|
11
|
+
{ collapsed: !0 },
|
|
12
|
+
...i.slice(-2)
|
|
13
|
+
] : i;
|
|
14
|
+
return /* @__PURE__ */ a("nav", {
|
|
15
|
+
ref: p,
|
|
16
|
+
"aria-label": d ?? m.breadcrumbs.label,
|
|
17
|
+
className: e("text-sm", u),
|
|
18
|
+
...f,
|
|
19
|
+
children: /* @__PURE__ */ a("ol", {
|
|
20
|
+
className: "text-foreground-subtle flex flex-wrap items-center gap-1.5",
|
|
21
|
+
children: g.map((e, t) => {
|
|
22
|
+
let i = t === g.length - 1;
|
|
23
|
+
if ("collapsed" in e) return /* @__PURE__ */ o("li", {
|
|
24
|
+
className: "flex items-center gap-1.5",
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ a(r, {
|
|
27
|
+
className: "size-4",
|
|
28
|
+
"aria-hidden": !0
|
|
29
|
+
}),
|
|
30
|
+
/* @__PURE__ */ a("span", {
|
|
31
|
+
className: "sr-only",
|
|
32
|
+
children: h
|
|
33
|
+
}),
|
|
34
|
+
/* @__PURE__ */ a(n, {
|
|
35
|
+
className: "size-3.5",
|
|
36
|
+
"aria-hidden": !0
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
}, `ellipsis-${t}`);
|
|
40
|
+
let s = e, l = i ? /* @__PURE__ */ a("span", {
|
|
41
|
+
"aria-current": "page",
|
|
42
|
+
className: "text-foreground font-medium",
|
|
43
|
+
children: s.label
|
|
44
|
+
}) : s.href ? c ? c(s.href, s.label) : /* @__PURE__ */ a("a", {
|
|
45
|
+
href: s.href,
|
|
46
|
+
className: "hover:text-foreground focus-visible:ring-ring rounded-sm transition-colors duration-[var(--duration-fast)] outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
47
|
+
children: s.label
|
|
48
|
+
}) : /* @__PURE__ */ a("span", { children: s.label });
|
|
49
|
+
return /* @__PURE__ */ o("li", {
|
|
50
|
+
className: "flex items-center gap-1.5",
|
|
51
|
+
children: [l, !i && /* @__PURE__ */ a(n, {
|
|
52
|
+
className: "size-3.5",
|
|
53
|
+
"aria-hidden": !0
|
|
54
|
+
})]
|
|
55
|
+
}, t);
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
});
|
|
47
59
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=Breadcrumbs.js.map
|
|
60
|
+
s.displayName = "Breadcrumbs";
|
|
61
|
+
//#endregion
|
|
62
|
+
export { s as Breadcrumbs };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=Breadcrumbs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumbs.js","sources":["../../../src/components/ui/Breadcrumbs.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type HTMLAttributes, type ReactNode } from 'react';\nimport { ChevronRight, MoreHorizontal } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\nexport interface BreadcrumbItem {\n /** Visible label. */\n label: ReactNode;\n /** Optional URL. Last item is treated as current page even if href is set. */\n href?: string;\n}\n\nexport interface BreadcrumbsProps extends HTMLAttributes<HTMLElement> {\n items: BreadcrumbItem[];\n /** Collapse to first + ellipsis + last `n` when items.length exceeds this. */\n maxItems?: number;\n /** Custom link renderer (for next/link, react-router, etc.). */\n renderLink?: (href: string, children: ReactNode) => ReactNode;\n /** sr-only text for the collapsed ellipsis. Default \"Hidden items\". */\n collapsedLabel?: string;\n}\n\n/**\n * Breadcrumb trail. Collapses with an ellipsis when there are too many crumbs.\n *\n * @example\n * <Breadcrumbs items={[\n * { label: 'Projects', href: '/projects' },\n * { label: 'Nova', href: '/projects/nova' },\n * { label: 'Settings' },\n * ]} />\n *\n * @example With react-router\n * <Breadcrumbs items={trail} renderLink={(href, c) => <Link to={href}>{c}</Link>} />\n *\n * @do Always omit `href` on the last item — it represents the current page.\n * @dont Use Breadcrumbs for flat navigation. Use TopNav links instead.\n */\nexport const Breadcrumbs = forwardRef<HTMLElement, BreadcrumbsProps>(function Breadcrumbs(\n {\n items,\n maxItems = 4,\n renderLink,\n collapsedLabel: collapsedLabelProp,\n className,\n 'aria-label': ariaLabel,\n ...props\n },\n ref,\n) {\n const strings = useStrings();\n const collapsedLabel = collapsedLabelProp ?? strings.breadcrumbs.collapsed;\n const shouldCollapse = items.length > maxItems;\n const displayItems = !shouldCollapse\n ? items\n : [items[0], { collapsed: true } as const, ...items.slice(-2)];\n\n return (\n <nav\n ref={ref}\n aria-label={ariaLabel ?? strings.breadcrumbs.label}\n className={cn('text-sm', className)}\n {...props}\n >\n <ol className=\"text-foreground-subtle flex flex-wrap items-center gap-1.5\">\n {displayItems.map((it, i) => {\n const isLast = i === displayItems.length - 1;\n if ('collapsed' in it) {\n return (\n <li key={`ellipsis-${i}`} className=\"flex items-center gap-1.5\">\n <MoreHorizontal className=\"size-4\" aria-hidden />\n <span className=\"sr-only\">{collapsedLabel}</span>\n <ChevronRight className=\"size-3.5\" aria-hidden />\n </li>\n );\n }\n const item = it as BreadcrumbItem;\n const labelNode = isLast ? (\n <span aria-current=\"page\" className=\"text-foreground font-medium\">\n {item.label}\n </span>\n ) : item.href ? (\n renderLink ? (\n renderLink(item.href, item.label)\n ) : (\n <a\n href={item.href}\n className=\"hover:text-foreground focus-visible:ring-ring rounded-sm transition-colors duration-[var(--duration-fast)] outline-none focus-visible:ring-2 focus-visible:ring-offset-2\"\n >\n {item.label}\n </a>\n )\n ) : (\n <span>{item.label}</span>\n );\n return (\n <li key={i} className=\"flex items-center gap-1.5\">\n {labelNode}\n {!isLast && <ChevronRight className=\"size-3.5\" aria-hidden />}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n});\nBreadcrumbs.displayName = 'Breadcrumbs';\n"],"
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.js","names":[],"sources":["../../../src/components/ui/Breadcrumbs.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type HTMLAttributes, type ReactNode } from 'react';\nimport { ChevronRight, MoreHorizontal } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\nexport interface BreadcrumbItem {\n /** Visible label. */\n label: ReactNode;\n /** Optional URL. Last item is treated as current page even if href is set. */\n href?: string;\n}\n\nexport interface BreadcrumbsProps extends HTMLAttributes<HTMLElement> {\n items: BreadcrumbItem[];\n /** Collapse to first + ellipsis + last `n` when items.length exceeds this. */\n maxItems?: number;\n /** Custom link renderer (for next/link, react-router, etc.). */\n renderLink?: (href: string, children: ReactNode) => ReactNode;\n /** sr-only text for the collapsed ellipsis. Default \"Hidden items\". */\n collapsedLabel?: string;\n}\n\n/**\n * Breadcrumb trail. Collapses with an ellipsis when there are too many crumbs.\n *\n * @example\n * <Breadcrumbs items={[\n * { label: 'Projects', href: '/projects' },\n * { label: 'Nova', href: '/projects/nova' },\n * { label: 'Settings' },\n * ]} />\n *\n * @example With react-router\n * <Breadcrumbs items={trail} renderLink={(href, c) => <Link to={href}>{c}</Link>} />\n *\n * @do Always omit `href` on the last item — it represents the current page.\n * @dont Use Breadcrumbs for flat navigation. Use TopNav links instead.\n */\nexport const Breadcrumbs = forwardRef<HTMLElement, BreadcrumbsProps>(function Breadcrumbs(\n {\n items,\n maxItems = 4,\n renderLink,\n collapsedLabel: collapsedLabelProp,\n className,\n 'aria-label': ariaLabel,\n ...props\n },\n ref,\n) {\n const strings = useStrings();\n const collapsedLabel = collapsedLabelProp ?? strings.breadcrumbs.collapsed;\n const shouldCollapse = items.length > maxItems;\n const displayItems = !shouldCollapse\n ? items\n : [items[0], { collapsed: true } as const, ...items.slice(-2)];\n\n return (\n <nav\n ref={ref}\n aria-label={ariaLabel ?? strings.breadcrumbs.label}\n className={cn('text-sm', className)}\n {...props}\n >\n <ol className=\"text-foreground-subtle flex flex-wrap items-center gap-1.5\">\n {displayItems.map((it, i) => {\n const isLast = i === displayItems.length - 1;\n if ('collapsed' in it) {\n return (\n <li key={`ellipsis-${i}`} className=\"flex items-center gap-1.5\">\n <MoreHorizontal className=\"size-4\" aria-hidden />\n <span className=\"sr-only\">{collapsedLabel}</span>\n <ChevronRight className=\"size-3.5\" aria-hidden />\n </li>\n );\n }\n const item = it as BreadcrumbItem;\n const labelNode = isLast ? (\n <span aria-current=\"page\" className=\"text-foreground font-medium\">\n {item.label}\n </span>\n ) : item.href ? (\n renderLink ? (\n renderLink(item.href, item.label)\n ) : (\n <a\n href={item.href}\n className=\"hover:text-foreground focus-visible:ring-ring rounded-sm transition-colors duration-[var(--duration-fast)] outline-none focus-visible:ring-2 focus-visible:ring-offset-2\"\n >\n {item.label}\n </a>\n )\n ) : (\n <span>{item.label}</span>\n );\n return (\n <li key={i} className=\"flex items-center gap-1.5\">\n {labelNode}\n {!isLast && <ChevronRight className=\"size-3.5\" aria-hidden />}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n});\nBreadcrumbs.displayName = 'Breadcrumbs';\n"],"mappings":";;;;;;;AA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