@cbrl/design 0.0.0-stage → 0.2.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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -2
  3. package/dist/components/alert-dialog.d.ts +14 -0
  4. package/dist/components/alert-dialog.js +82 -0
  5. package/dist/components/app-shell.d.ts +38 -0
  6. package/dist/components/app-shell.js +72 -0
  7. package/dist/components/auth-split-screen.d.ts +30 -0
  8. package/dist/components/auth-split-screen.js +45 -0
  9. package/dist/components/avatar.d.ts +11 -0
  10. package/dist/components/avatar.js +50 -0
  11. package/dist/components/badge.d.ts +9 -0
  12. package/dist/components/badge.js +27 -0
  13. package/dist/components/breadcrumb.d.ts +11 -0
  14. package/dist/components/breadcrumb.js +69 -0
  15. package/dist/components/button.d.ts +10 -0
  16. package/dist/components/button.js +47 -0
  17. package/dist/components/calendar.d.ts +7 -0
  18. package/dist/components/calendar.js +142 -0
  19. package/dist/components/card.d.ts +13 -0
  20. package/dist/components/card.js +57 -0
  21. package/dist/components/checkbox.d.ts +4 -0
  22. package/dist/components/checkbox.js +20 -0
  23. package/dist/components/collapsible.d.ts +5 -0
  24. package/dist/components/collapsible.js +23 -0
  25. package/dist/components/date-field.d.ts +31 -0
  26. package/dist/components/date-field.js +129 -0
  27. package/dist/components/dialog.d.ts +17 -0
  28. package/dist/components/dialog.js +95 -0
  29. package/dist/components/dropdown-menu.d.ts +29 -0
  30. package/dist/components/dropdown-menu.js +127 -0
  31. package/dist/components/empty-state.d.ts +32 -0
  32. package/dist/components/empty-state.js +61 -0
  33. package/dist/components/field.d.ts +25 -0
  34. package/dist/components/field.js +121 -0
  35. package/dist/components/highlighted-textarea.d.ts +6 -0
  36. package/dist/components/highlighted-textarea.js +68 -0
  37. package/dist/components/icons/brand-icon.d.ts +6 -0
  38. package/dist/components/icons/brand-icon.js +13 -0
  39. package/dist/components/icons/google-icon.d.ts +7 -0
  40. package/dist/components/icons/google-icon.js +33 -0
  41. package/dist/components/icons/whatsapp-icon.d.ts +7 -0
  42. package/dist/components/icons/whatsapp-icon.js +18 -0
  43. package/dist/components/input-group.d.ts +8 -0
  44. package/dist/components/input-group.js +28 -0
  45. package/dist/components/input.d.ts +3 -0
  46. package/dist/components/input.js +13 -0
  47. package/dist/components/label.d.ts +4 -0
  48. package/dist/components/label.js +14 -0
  49. package/dist/components/list.d.ts +174 -0
  50. package/dist/components/list.js +281 -0
  51. package/dist/components/main.d.ts +10 -0
  52. package/dist/components/main.js +36 -0
  53. package/dist/components/pagination.d.ts +25 -0
  54. package/dist/components/pagination.js +104 -0
  55. package/dist/components/popover.d.ts +6 -0
  56. package/dist/components/popover.js +28 -0
  57. package/dist/components/radio-group.d.ts +5 -0
  58. package/dist/components/radio-group.js +27 -0
  59. package/dist/components/scroll-area.d.ts +5 -0
  60. package/dist/components/scroll-area.js +35 -0
  61. package/dist/components/select.d.ts +15 -0
  62. package/dist/components/select.js +95 -0
  63. package/dist/components/separator.d.ts +4 -0
  64. package/dist/components/separator.js +16 -0
  65. package/dist/components/setting-row.d.ts +8 -0
  66. package/dist/components/setting-row.js +36 -0
  67. package/dist/components/settings-section.d.ts +7 -0
  68. package/dist/components/settings-section.js +36 -0
  69. package/dist/components/sheet.d.ts +14 -0
  70. package/dist/components/sheet.js +89 -0
  71. package/dist/components/sidebar-core.d.ts +33 -0
  72. package/dist/components/sidebar-core.js +220 -0
  73. package/dist/components/sidebar-menu.d.ts +38 -0
  74. package/dist/components/sidebar-menu.js +168 -0
  75. package/dist/components/sidebar.d.ts +3 -0
  76. package/dist/components/skeleton.d.ts +2 -0
  77. package/dist/components/skeleton.js +11 -0
  78. package/dist/components/sonner.d.ts +3 -0
  79. package/dist/components/sonner.js +31 -0
  80. package/dist/components/stepper.d.ts +8 -0
  81. package/dist/components/stepper.js +58 -0
  82. package/dist/components/switch.d.ts +6 -0
  83. package/dist/components/switch.js +19 -0
  84. package/dist/components/table.d.ts +10 -0
  85. package/dist/components/table.js +65 -0
  86. package/dist/components/tabs.d.ts +7 -0
  87. package/dist/components/tabs.js +35 -0
  88. package/dist/components/textarea.d.ts +3 -0
  89. package/dist/components/textarea.js +12 -0
  90. package/dist/components/theme-provider.d.ts +15 -0
  91. package/dist/components/theme-provider.js +22 -0
  92. package/dist/components/tooltip.d.ts +7 -0
  93. package/dist/components/tooltip.js +35 -0
  94. package/dist/components/typography.d.ts +9 -0
  95. package/dist/components/typography.js +45 -0
  96. package/dist/components/user-menu.d.ts +27 -0
  97. package/dist/components/user-menu.js +49 -0
  98. package/dist/globals.css +60 -0
  99. package/dist/hooks/use-mobile.d.ts +1 -0
  100. package/dist/hooks/use-mobile.js +17 -0
  101. package/dist/index.d.ts +53 -0
  102. package/dist/index.js +51 -0
  103. package/dist/lib/cn.d.ts +2 -0
  104. package/dist/lib/cn.js +7 -0
  105. package/dist/lib/css-vars.js +5 -0
  106. package/dist/lib/date.js +38 -0
  107. package/dist/lib/initials.d.ts +8 -0
  108. package/dist/lib/initials.js +15 -0
  109. package/dist/lib/nav.d.ts +15 -0
  110. package/dist/lib/nav.js +11 -0
  111. package/dist/lib/toaster-theme.js +5 -0
  112. package/dist/shadcn.css +635 -0
  113. package/dist/tokens.css +160 -0
  114. package/package.json +85 -3
@@ -0,0 +1,174 @@
1
+ import { EmptyStateProps } from "./empty-state.js";
2
+ import { PaginationProps } from "./pagination.js";
3
+ import * as React from "react";
4
+ import { VariantProps } from "class-variance-authority";
5
+ declare const listVariants: (props?: ({
6
+ bordered?: boolean | null | undefined;
7
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
+ declare const listItemVariants: (props?: ({
9
+ interactive?: boolean | null | undefined;
10
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
+ declare function ListItem({ className, interactive, asChild, ...props }: React.ComponentProps<'div'> & VariantProps<typeof listItemVariants> & {
12
+ asChild?: boolean;
13
+ }): React.JSX.Element;
14
+ declare function ListItemMedia({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
15
+ declare function ListItemLeading({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
16
+ declare function ListItemContent({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
17
+ declare function ListItemTitle({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
18
+ declare function ListItemDescription({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
19
+ declare function ListItemMeta({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
20
+ declare function ListItemTrailing({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
21
+ declare function ListItemActions({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
22
+ /**
23
+ * Per-item descriptor returned by `renderItem`. Every field except `title` is
24
+ * optional, so the same component serves people lists (avatar) and object lists
25
+ * (icon), with or without a trailing value.
26
+ */
27
+ type ListItemDescriptor = {
28
+ /** Raw leading visual — typically an `<Avatar>`. Takes precedence over `icon`. */
29
+ leading?: React.ReactNode;
30
+ /** Icon rendered inside the muted squircle (`ListItemMedia`) — for object lists. */
31
+ icon?: React.ReactNode;
32
+ /** Primary line. Required. */
33
+ title: React.ReactNode;
34
+ /** Inline status pill shown next to the title (e.g. a `<Badge>`). */
35
+ badge?: React.ReactNode;
36
+ /** Secondary muted line (contact, plan, item count…). */
37
+ description?: React.ReactNode;
38
+ /** Muted middle column — secondary metadata such as a date. */
39
+ meta?: React.ReactNode;
40
+ /** Right-aligned value (amount/price) — rendered bold + `tabular-nums`. */
41
+ trailing?: React.ReactNode;
42
+ /** Small muted sub-line under the value (e.g. a discount). */
43
+ trailingHint?: React.ReactNode;
44
+ /**
45
+ * Row actions area — the overflow (⋯) menu and/or one or more exposed
46
+ * quick-actions beside it. Pass a single node or a fragment of several; the
47
+ * `ListItemActions` slot spaces them.
48
+ */
49
+ actions?: React.ReactNode;
50
+ /** Makes the whole row a link (only when there is no `actions` menu). */
51
+ href?: string;
52
+ /** Makes the whole row a button (only when there is no `actions` menu). */
53
+ onClick?: () => void;
54
+ };
55
+ /**
56
+ * Search box config. Submit-on-Enter: the box keeps its own draft so typing is
57
+ * instant, and only fires `onSearch` when the user presses Enter or clicks the
58
+ * search icon — so a server-side consumer requeries once per search, not per
59
+ * keystroke. `value` is the APPLIED query (e.g. read from a URL param); the
60
+ * draft re-syncs to it whenever it changes from outside (navigation, clear).
61
+ * Provide this config to opt into search; omit it for no search box.
62
+ */
63
+ type ListSearchConfig = {
64
+ /** The currently applied query (source of truth; seeds + re-syncs the draft). */
65
+ value: string;
66
+ /** Fired with the trimmed draft on Enter / search-icon click. */
67
+ onSearch: (value: string) => void;
68
+ /** Placeholder shown in the empty box. */
69
+ placeholder?: string;
70
+ /** Accessible label (defaults to the placeholder, then "Search"). */
71
+ ariaLabel?: string;
72
+ };
73
+ /**
74
+ * One filter dropdown (facet-filter pattern). Declarative + controlled: the List
75
+ * renders a `<Select>` whose FIRST option is auto-generated from `label` and
76
+ * means "all / no filter" (`allValue`) — so at rest the trigger reads as the
77
+ * field name ("Horário") and selecting a value replaces it. The List does NOT
78
+ * filter the data — the consumer applies the choice (server query, URL param…)
79
+ * and passes back the already-filtered `items`.
80
+ */
81
+ type ListFilterConfig = {
82
+ /** Stable key (React key). */
83
+ key: string;
84
+ /**
85
+ * Field name. Doubles as the trigger's accessible name (`aria-label`) AND the
86
+ * label of the auto-prepended "all" option shown at rest.
87
+ */
88
+ label: string;
89
+ /** Current selection — `allValue` when no filter is applied. */
90
+ value: string;
91
+ /** Fired with the chosen option value (`allValue` for "all"). */
92
+ onChange: (value: string) => void;
93
+ /**
94
+ * The selectable values BEYOND "all" — the List prepends the "all" option
95
+ * itself. Radix Select forbids an empty-string value, so use non-empty values.
96
+ */
97
+ options: readonly {
98
+ value: string;
99
+ label: string;
100
+ }[];
101
+ /**
102
+ * The value that means "no filter applied" (the prepended "all" option's
103
+ * value, and the signal for filtered-empty vs truly empty). Defaults to `'all'`.
104
+ */
105
+ allValue?: string;
106
+ /**
107
+ * Label of the prepended "all / no filter" option (e.g. "Todos"/"Todas"). It
108
+ * is a real, distinct option — never the field name. Defaults to `'All'`
109
+ * (consumers localize).
110
+ */
111
+ allLabel?: string;
112
+ };
113
+ /** Pagination config — the controlled {@link Pagination} props, minus styling. */
114
+ type ListPaginationConfig = Omit<PaginationProps, 'className'>;
115
+ /**
116
+ * Empty-state content: the common `EmptyStateProps` (rendered as an
117
+ * `<EmptyState>`) or a ready React element for a bespoke empty surface.
118
+ */
119
+ type ListEmptyContent = EmptyStateProps | React.ReactElement;
120
+ type ListProps<T> = Omit<React.ComponentProps<'ul'>, 'children'> & VariantProps<typeof listVariants> & {
121
+ /** The data to render. */
122
+ items: readonly T[];
123
+ /** Stable React key per item. */
124
+ getKey: (item: T, index: number) => React.Key;
125
+ /** Maps an item to its visual descriptor. */
126
+ renderItem: (item: T, index: number) => ListItemDescriptor;
127
+ /**
128
+ * Element used to render rows that have an `href` (e.g. a router `<Link>`).
129
+ * Receives `href`, `className` and `children`. Defaults to a plain `<a>`.
130
+ */
131
+ linkComponent?: React.ElementType;
132
+ /** When true, renders `loadingCount` skeleton rows instead of items. */
133
+ loading?: boolean;
134
+ /** Number of skeleton rows while `loading`. Defaults to 3. */
135
+ loadingCount?: number;
136
+ /** Whether skeleton rows include a leading square. Defaults to true. */
137
+ loadingLeading?: boolean;
138
+ /**
139
+ * Shown when `items` is empty and not loading. Either `EmptyStateProps` (the
140
+ * common case → rendered as an `<EmptyState>`) or a ready React element for
141
+ * surfaces whose empty state needs custom chrome (e.g. a server-action create
142
+ * form). Omit to render nothing.
143
+ */
144
+ empty?: ListEmptyContent;
145
+ /**
146
+ * Surface header (title + primary CTA). Rendered above the toolbar for the
147
+ * populated, filtered-empty and loading states; hidden when truly empty so
148
+ * the `empty` protagonist owns the screen.
149
+ */
150
+ header?: React.ReactNode;
151
+ /** Opt-in search box rendered in the toolbar above the list. */
152
+ search?: ListSearchConfig;
153
+ /** Opt-in filter dropdowns rendered in the toolbar above the list. */
154
+ filters?: readonly ListFilterConfig[];
155
+ /** Opt-in pagination rendered below the list (self-hides for a single page). */
156
+ pagination?: ListPaginationConfig;
157
+ /** Extra controls appended to the toolbar's filter cluster (escape hatch). */
158
+ toolbarExtra?: React.ReactNode;
159
+ /**
160
+ * Shown instead of `empty` when the list is empty WHILE a query is active
161
+ * (search text or a non-default filter) — the toolbar stays so the user can
162
+ * clear it. `EmptyStateProps` or a ready element. Defaults to a neutral "No
163
+ * results" state. Ignored when no query is active (then `empty` wins).
164
+ */
165
+ filteredEmpty?: ListEmptyContent;
166
+ /**
167
+ * Force the empty-vs-filtered-empty decision. By default the List infers an
168
+ * active query from `search`/`filters` values; set this when the inference
169
+ * is wrong (e.g. a default filter that already narrows the set).
170
+ */
171
+ isFiltered?: boolean;
172
+ };
173
+ declare function List<T>({ items, getKey, renderItem, linkComponent, loading, loadingCount, loadingLeading, empty, header, search, filters, pagination, toolbarExtra, filteredEmpty, isFiltered, bordered, className, ...props }: ListProps<T>): React.ReactNode;
174
+ export { List, type ListEmptyContent, type ListFilterConfig, ListItem, ListItemActions, ListItemContent, ListItemDescription, type ListItemDescriptor, ListItemLeading, ListItemMedia, ListItemMeta, ListItemTitle, ListItemTrailing, type ListPaginationConfig, type ListProps, type ListSearchConfig, listItemVariants, listVariants };
@@ -0,0 +1,281 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.js";
3
+ import { EmptyState } from "./empty-state.js";
4
+ import { InputGroup, InputGroupAddon, InputGroupInput } from "./input-group.js";
5
+ import { Pagination } from "./pagination.js";
6
+ import { Select as Select$1, SelectContent, SelectItem, SelectTrigger } from "./select.js";
7
+ import { Skeleton } from "./skeleton.js";
8
+ import * as React from "react";
9
+ import { cva } from "class-variance-authority";
10
+ import { Slot } from "radix-ui";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ import { Search } from "lucide-react";
13
+ // src/components/list.tsx
14
+ const listVariants = cva("group/list flex flex-col", {
15
+ variants: { bordered: {
16
+ true: "overflow-hidden rounded-md border",
17
+ false: "gap-1"
18
+ } },
19
+ defaultVariants: { bordered: true }
20
+ });
21
+ const BORDERED_ROW = "relative after:bg-border after:pointer-events-none after:absolute after:inset-x-4 after:bottom-0 after:h-px last:after:hidden";
22
+ const listItemVariants = cva("flex min-h-16 items-center gap-3 px-4 py-3 text-sm", {
23
+ variants: { interactive: {
24
+ true: "hover:bg-accent/40 focus-visible:ring-ring/50 cursor-pointer transition-colors outline-none focus-visible:ring-2 focus-visible:ring-inset",
25
+ false: ""
26
+ } },
27
+ defaultVariants: { interactive: false }
28
+ });
29
+ function ListItem({ className, interactive = false, asChild = false, ...props }) {
30
+ const Comp = asChild ? Slot.Root : "div";
31
+ return /* @__PURE__ */ jsx(Comp, {
32
+ "data-slot": "list-item",
33
+ "data-interactive": interactive,
34
+ className: cn(listItemVariants({ interactive }), className),
35
+ ...props
36
+ });
37
+ }
38
+ function ListItemMedia({ className, ...props }) {
39
+ return /* @__PURE__ */ jsx("div", {
40
+ "data-slot": "list-item-media",
41
+ className: cn("bg-muted text-muted-foreground flex size-9 shrink-0 items-center justify-center rounded-lg [&_svg]:size-4", className),
42
+ ...props
43
+ });
44
+ }
45
+ function ListItemLeading({ className, ...props }) {
46
+ return /* @__PURE__ */ jsx("div", {
47
+ "data-slot": "list-item-leading",
48
+ className: cn("flex shrink-0 items-center", className),
49
+ ...props
50
+ });
51
+ }
52
+ function ListItemContent({ className, ...props }) {
53
+ return /* @__PURE__ */ jsx("div", {
54
+ "data-slot": "list-item-content",
55
+ className: cn("flex min-w-0 flex-1 flex-col gap-0.5", className),
56
+ ...props
57
+ });
58
+ }
59
+ function ListItemTitle({ className, ...props }) {
60
+ return /* @__PURE__ */ jsx("div", {
61
+ "data-slot": "list-item-title",
62
+ className: cn("truncate text-sm leading-snug font-medium", className),
63
+ ...props
64
+ });
65
+ }
66
+ function ListItemDescription({ className, ...props }) {
67
+ return /* @__PURE__ */ jsx("div", {
68
+ "data-slot": "list-item-description",
69
+ className: cn("text-muted-foreground truncate text-xs", className),
70
+ ...props
71
+ });
72
+ }
73
+ function ListItemMeta({ className, ...props }) {
74
+ return /* @__PURE__ */ jsx("div", {
75
+ "data-slot": "list-item-meta",
76
+ className: cn("text-muted-foreground hidden shrink-0 text-xs sm:block", className),
77
+ ...props
78
+ });
79
+ }
80
+ function ListItemTrailing({ className, ...props }) {
81
+ return /* @__PURE__ */ jsx("div", {
82
+ "data-slot": "list-item-trailing",
83
+ className: cn("flex shrink-0 flex-col items-end text-sm font-semibold tabular-nums", className),
84
+ ...props
85
+ });
86
+ }
87
+ function ListItemActions({ className, ...props }) {
88
+ return /* @__PURE__ */ jsx("div", {
89
+ "data-slot": "list-item-actions",
90
+ className: cn("flex shrink-0 items-center gap-0.5", className),
91
+ ...props
92
+ });
93
+ }
94
+ const DEFAULT_FILTER_ALL_VALUE = "all";
95
+ const DEFAULT_FILTER_ALL_LABEL = "All";
96
+ function renderEmptyContent(content, className) {
97
+ if (React.isValidElement(content)) return content;
98
+ return /* @__PURE__ */ jsx(EmptyState, {
99
+ ...content,
100
+ className
101
+ });
102
+ }
103
+ function ListRowInner({ leading, icon, title, badge, description, meta, trailing, trailingHint, actions }) {
104
+ let leadingNode = null;
105
+ if (leading != null) leadingNode = /* @__PURE__ */ jsx(ListItemLeading, { children: leading });
106
+ else if (icon != null) leadingNode = /* @__PURE__ */ jsx(ListItemMedia, { children: icon });
107
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
108
+ leadingNode,
109
+ /* @__PURE__ */ jsxs(ListItemContent, { children: [/* @__PURE__ */ jsx(ListItemTitle, { children: title }), description != null ? /* @__PURE__ */ jsx(ListItemDescription, { children: description }) : null] }),
110
+ badge != null ? /* @__PURE__ */ jsx("div", {
111
+ "data-slot": "list-item-badge",
112
+ className: "flex shrink-0 items-center",
113
+ children: badge
114
+ }) : null,
115
+ meta != null ? /* @__PURE__ */ jsx(ListItemMeta, { children: meta }) : null,
116
+ trailing != null ? /* @__PURE__ */ jsxs(ListItemTrailing, { children: [/* @__PURE__ */ jsx("span", { children: trailing }), trailingHint != null ? /* @__PURE__ */ jsx("span", {
117
+ className: "text-muted-foreground text-xs font-normal",
118
+ children: trailingHint
119
+ }) : null] }) : null,
120
+ actions != null ? /* @__PURE__ */ jsx(ListItemActions, { children: actions }) : null
121
+ ] });
122
+ }
123
+ function ListSkeletonRow({ leading, bordered }) {
124
+ return /* @__PURE__ */ jsxs("li", {
125
+ "aria-hidden": true,
126
+ className: cn(listItemVariants(), bordered && BORDERED_ROW),
127
+ "data-slot": "list-item",
128
+ children: [
129
+ leading ? /* @__PURE__ */ jsx(Skeleton, { className: "size-9 shrink-0 rounded-lg" }) : null,
130
+ /* @__PURE__ */ jsxs("div", {
131
+ className: "flex min-w-0 flex-1 flex-col gap-1.5",
132
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-3.5 w-1/3" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-1/2" })]
133
+ }),
134
+ /* @__PURE__ */ jsx(Skeleton, { className: "ml-auto h-3.5 w-12 shrink-0" })
135
+ ]
136
+ });
137
+ }
138
+ function ListSearchBox({ value, onSearch, placeholder, ariaLabel }) {
139
+ const [draft, setDraft] = React.useState(value);
140
+ React.useEffect(() => {
141
+ setDraft(value);
142
+ }, [value]);
143
+ const label = ariaLabel ?? placeholder ?? "Search";
144
+ return /* @__PURE__ */ jsx("form", {
145
+ role: "search",
146
+ className: "w-full sm:max-w-xs",
147
+ onSubmit: (event) => {
148
+ event.preventDefault();
149
+ onSearch(draft.trim());
150
+ },
151
+ children: /* @__PURE__ */ jsxs(InputGroup, { children: [/* @__PURE__ */ jsx(InputGroupAddon, {
152
+ align: "inline-start",
153
+ children: /* @__PURE__ */ jsx("button", {
154
+ type: "submit",
155
+ "aria-label": label,
156
+ className: "flex items-center",
157
+ children: /* @__PURE__ */ jsx(Search, {})
158
+ })
159
+ }), /* @__PURE__ */ jsx(InputGroupInput, {
160
+ type: "search",
161
+ value: draft,
162
+ onChange: (event) => setDraft(event.target.value),
163
+ placeholder,
164
+ "aria-label": label
165
+ })] })
166
+ });
167
+ }
168
+ function ListToolbar({ search, filters, toolbarExtra }) {
169
+ const hasFilterCluster = (filters?.length ?? 0) > 0 || toolbarExtra != null;
170
+ return /* @__PURE__ */ jsxs("div", {
171
+ "data-slot": "list-toolbar",
172
+ className: "flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",
173
+ children: [search != null ? /* @__PURE__ */ jsx(ListSearchBox, { ...search }) : null, hasFilterCluster ? /* @__PURE__ */ jsxs("div", {
174
+ className: "flex shrink-0 items-center gap-2",
175
+ children: [filters?.map((filter) => {
176
+ const allValue = filter.allValue ?? DEFAULT_FILTER_ALL_VALUE;
177
+ const allLabel = filter.allLabel ?? DEFAULT_FILTER_ALL_LABEL;
178
+ const selected = filter.options.find((option) => option.value === filter.value);
179
+ return /* @__PURE__ */ jsxs(Select$1, {
180
+ value: filter.value,
181
+ onValueChange: filter.onChange,
182
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
183
+ size: "sm",
184
+ "aria-label": filter.label,
185
+ className: "min-w-36",
186
+ children: /* @__PURE__ */ jsx("span", {
187
+ className: "truncate",
188
+ children: filter.value === allValue ? filter.label : selected?.label ?? filter.label
189
+ })
190
+ }), /* @__PURE__ */ jsxs(SelectContent, { children: [/* @__PURE__ */ jsx(SelectItem, {
191
+ value: allValue,
192
+ children: allLabel
193
+ }), filter.options.map((option) => /* @__PURE__ */ jsx(SelectItem, {
194
+ value: option.value,
195
+ children: option.label
196
+ }, option.value))] })]
197
+ }, filter.key);
198
+ }), toolbarExtra]
199
+ }) : null]
200
+ });
201
+ }
202
+ function List({ items, getKey, renderItem, linkComponent, loading = false, loadingCount = 3, loadingLeading = true, empty, header, search, filters, pagination, toolbarExtra, filteredEmpty, isFiltered, bordered = true, className, ...props }) {
203
+ const LinkComponent = linkComponent ?? "a";
204
+ const isBordered = bordered !== false;
205
+ const hasToolbar = search != null || (filters?.length ?? 0) > 0 || toolbarExtra != null;
206
+ const hasShell = hasToolbar || pagination != null || header != null;
207
+ const toolbar = hasToolbar ? /* @__PURE__ */ jsx(ListToolbar, {
208
+ search,
209
+ filters,
210
+ toolbarExtra
211
+ }) : null;
212
+ const shell = (children) => hasShell ? /* @__PURE__ */ jsx("div", {
213
+ "data-slot": "list-root",
214
+ className: cn("flex flex-col gap-4", className),
215
+ children
216
+ }) : children;
217
+ const renderUl = (children) => /* @__PURE__ */ jsx("ul", {
218
+ "data-slot": "list",
219
+ "data-bordered": isBordered,
220
+ className: cn(listVariants({ bordered: isBordered }), !hasShell && className),
221
+ ...props,
222
+ children
223
+ });
224
+ if (loading) {
225
+ const skeletons = Array.from({ length: loadingCount }, (_, i) => /* @__PURE__ */ jsx(ListSkeletonRow, {
226
+ leading: loadingLeading,
227
+ bordered: isBordered
228
+ }, i));
229
+ return shell(/* @__PURE__ */ jsxs(Fragment, { children: [
230
+ /* @__PURE__ */ jsx(React.Fragment, { children: header }, "list-header"),
231
+ toolbar,
232
+ renderUl(skeletons)
233
+ ] }));
234
+ }
235
+ if (items.length === 0) {
236
+ const queryActive = isFiltered ?? ((search?.value ?? "") !== "" || (filters ?? []).some((f) => f.value !== (f.allValue ?? DEFAULT_FILTER_ALL_VALUE)));
237
+ if (hasToolbar && queryActive) return shell(/* @__PURE__ */ jsxs(Fragment, { children: [
238
+ /* @__PURE__ */ jsx(React.Fragment, { children: header }, "list-header"),
239
+ toolbar,
240
+ renderEmptyContent(filteredEmpty ?? { title: "No results" })
241
+ ] }));
242
+ return empty != null ? renderEmptyContent(empty, cn(className)) : null;
243
+ }
244
+ const rows = items.map((item, index) => {
245
+ const descriptor = renderItem(item, index);
246
+ const inner = /* @__PURE__ */ jsx(ListRowInner, { ...descriptor });
247
+ const interactiveClass = cn(listItemVariants({ interactive: true }));
248
+ let row;
249
+ if (descriptor.actions == null && descriptor.href != null) row = /* @__PURE__ */ jsx(LinkComponent, {
250
+ href: descriptor.href,
251
+ "data-slot": "list-item",
252
+ "data-interactive": true,
253
+ className: interactiveClass,
254
+ children: inner
255
+ });
256
+ else if (descriptor.actions == null && descriptor.onClick != null) row = /* @__PURE__ */ jsx("button", {
257
+ type: "button",
258
+ onClick: descriptor.onClick,
259
+ "data-slot": "list-item",
260
+ "data-interactive": true,
261
+ className: interactiveClass,
262
+ children: inner
263
+ });
264
+ else row = /* @__PURE__ */ jsx("div", {
265
+ "data-slot": "list-item",
266
+ className: cn(listItemVariants()),
267
+ children: inner
268
+ });
269
+ return /* @__PURE__ */ jsx("li", {
270
+ className: cn(isBordered && BORDERED_ROW),
271
+ children: row
272
+ }, getKey(item, index));
273
+ });
274
+ return shell(/* @__PURE__ */ jsxs(Fragment, { children: [
275
+ /* @__PURE__ */ jsx(React.Fragment, { children: header }, "list-header"),
276
+ toolbar,
277
+ renderUl(rows),
278
+ pagination != null ? /* @__PURE__ */ jsx(Pagination, { ...pagination }) : null
279
+ ] }));
280
+ }
281
+ export { List, ListItem, ListItemActions, ListItemContent, ListItemDescription, ListItemLeading, ListItemMedia, ListItemMeta, ListItemTitle, ListItemTrailing, listItemVariants, listVariants };
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import { VariantProps } from "class-variance-authority";
3
+ declare const frameVariants: (props?: ({
4
+ width?: "default" | "narrow" | "full" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ declare function Main({ className, width, children, ...props }: React.ComponentProps<'main'> & VariantProps<typeof frameVariants>): React.JSX.Element;
7
+ declare const mainVariants: (props?: ({
8
+ width?: "default" | "narrow" | "full" | null | undefined;
9
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
10
+ export { Main, mainVariants };
@@ -0,0 +1,36 @@
1
+ import { cn } from "../lib/cn.js";
2
+ import "react";
3
+ import { cva } from "class-variance-authority";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/main.tsx
6
+ const frameVariants = cva("w-full flex-1 p-6", {
7
+ variants: { width: {
8
+ narrow: "mx-auto max-w-7xl",
9
+ default: "mx-auto max-w-7xl",
10
+ full: ""
11
+ } },
12
+ defaultVariants: { width: "default" }
13
+ });
14
+ const contentVariants = cva("w-full", {
15
+ variants: { width: {
16
+ narrow: "max-w-2xl",
17
+ default: "",
18
+ full: ""
19
+ } },
20
+ defaultVariants: { width: "default" }
21
+ });
22
+ function Main({ className, width = "default", children, ...props }) {
23
+ return /* @__PURE__ */ jsx("main", {
24
+ "data-slot": "main",
25
+ "data-width": width,
26
+ className: frameVariants({ width }),
27
+ ...props,
28
+ children: /* @__PURE__ */ jsx("div", {
29
+ "data-slot": "main-content",
30
+ className: cn(contentVariants({ width }), className),
31
+ children
32
+ })
33
+ });
34
+ }
35
+ const mainVariants = frameVariants;
36
+ export { Main, mainVariants };
@@ -0,0 +1,25 @@
1
+ type PaginationLabels = {
2
+ /** `aria-label` of the wrapping nav. */
3
+ root?: string;
4
+ /** `aria-label` of the previous-page control. */
5
+ previous?: string;
6
+ /** `aria-label` of the next-page control. */
7
+ next?: string;
8
+ /** `aria-label` of a numbered page control. */
9
+ page?: (page: number) => string;
10
+ };
11
+ type PaginationProps = {
12
+ /** Current page, 1-based. */
13
+ page: number;
14
+ /** Total number of pages. */
15
+ pageCount: number;
16
+ /** Fired with the target page (clamped to `[1, pageCount]`). */
17
+ onPageChange: (page: number) => void;
18
+ /** Pages shown on each side of the current page before collapsing. Default 1. */
19
+ siblingCount?: number;
20
+ /** Accessible labels — English defaults; override for localization. */
21
+ labels?: PaginationLabels;
22
+ className?: string;
23
+ };
24
+ declare function Pagination({ page, pageCount, onPageChange, siblingCount, labels, className }: PaginationProps): import("react").JSX.Element | null;
25
+ export { Pagination, type PaginationProps };
@@ -0,0 +1,104 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.js";
3
+ import { buttonVariants } from "./button.js";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react";
6
+ // src/components/pagination.tsx
7
+ /**
8
+ * Page tokens to render: always first + last, a window of `siblingCount` around
9
+ * the current page, and ellipses for the gaps. Pure + exported for unit testing
10
+ * the windowing in isolation.
11
+ */
12
+ function buildPaginationRange(page, pageCount, siblingCount = 1) {
13
+ const range = (start, end) => Array.from({ length: end - start + 1 }, (_, i) => start + i);
14
+ if (pageCount <= siblingCount * 2 + 5) return range(1, pageCount);
15
+ const leftSibling = Math.max(page - siblingCount, 1);
16
+ const rightSibling = Math.min(page + siblingCount, pageCount);
17
+ const showLeftEllipsis = leftSibling > 2;
18
+ const showRightEllipsis = rightSibling < pageCount - 1;
19
+ if (!showLeftEllipsis && showRightEllipsis) return [
20
+ ...range(1, siblingCount * 2 + 3),
21
+ "ellipsis-right",
22
+ pageCount
23
+ ];
24
+ if (showLeftEllipsis && !showRightEllipsis) return [
25
+ 1,
26
+ "ellipsis-left",
27
+ ...range(pageCount - (siblingCount * 2 + 2), pageCount)
28
+ ];
29
+ return [
30
+ 1,
31
+ "ellipsis-left",
32
+ ...range(leftSibling, rightSibling),
33
+ "ellipsis-right",
34
+ pageCount
35
+ ];
36
+ }
37
+ const DEFAULT_LABELS = {
38
+ root: "Pagination",
39
+ previous: "Go to previous page",
40
+ next: "Go to next page",
41
+ page: (page) => `Go to page ${page}`
42
+ };
43
+ function Pagination({ page, pageCount, onPageChange, siblingCount = 1, labels, className }) {
44
+ if (pageCount <= 1) return null;
45
+ const text = {
46
+ ...DEFAULT_LABELS,
47
+ ...labels
48
+ };
49
+ const items = buildPaginationRange(page, pageCount, siblingCount);
50
+ const go = (target) => {
51
+ const clamped = Math.min(Math.max(target, 1), pageCount);
52
+ if (clamped !== page) onPageChange(clamped);
53
+ };
54
+ return /* @__PURE__ */ jsxs("nav", {
55
+ "data-slot": "pagination",
56
+ role: "navigation",
57
+ "aria-label": text.root,
58
+ className: cn("flex items-center justify-center gap-1", className),
59
+ children: [
60
+ /* @__PURE__ */ jsx("button", {
61
+ type: "button",
62
+ "data-slot": "pagination-previous",
63
+ "aria-label": text.previous,
64
+ disabled: page <= 1,
65
+ onClick: () => go(page - 1),
66
+ className: cn(buttonVariants({
67
+ variant: "ghost",
68
+ size: "icon-sm"
69
+ })),
70
+ children: /* @__PURE__ */ jsx(ChevronLeft, {})
71
+ }),
72
+ items.map((item) => item === "ellipsis-left" || item === "ellipsis-right" ? /* @__PURE__ */ jsx("span", {
73
+ "data-slot": "pagination-ellipsis",
74
+ "aria-hidden": true,
75
+ className: "text-muted-foreground flex size-7 items-center justify-center",
76
+ children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "size-4" })
77
+ }, item) : /* @__PURE__ */ jsx("button", {
78
+ type: "button",
79
+ "data-slot": "pagination-page",
80
+ "aria-label": text.page(item),
81
+ "aria-current": item === page ? "page" : void 0,
82
+ onClick: () => go(item),
83
+ className: cn(buttonVariants({
84
+ variant: item === page ? "outline" : "ghost",
85
+ size: "icon-sm"
86
+ }), "tabular-nums"),
87
+ children: item
88
+ }, item)),
89
+ /* @__PURE__ */ jsx("button", {
90
+ type: "button",
91
+ "data-slot": "pagination-next",
92
+ "aria-label": text.next,
93
+ disabled: page >= pageCount,
94
+ onClick: () => go(page + 1),
95
+ className: cn(buttonVariants({
96
+ variant: "ghost",
97
+ size: "icon-sm"
98
+ })),
99
+ children: /* @__PURE__ */ jsx(ChevronRight, {})
100
+ })
101
+ ]
102
+ });
103
+ }
104
+ export { Pagination, buildPaginationRange };
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ import { Popover as Popover$1 } from "radix-ui";
3
+ declare function Popover({ ...props }: React.ComponentProps<typeof Popover$1.Root>): React.JSX.Element;
4
+ declare function PopoverTrigger({ ...props }: React.ComponentProps<typeof Popover$1.Trigger>): React.JSX.Element;
5
+ declare function PopoverContent({ className, align, sideOffset, ...props }: React.ComponentProps<typeof Popover$1.Content>): React.JSX.Element;
6
+ export { Popover, PopoverContent, PopoverTrigger };
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.js";
3
+ import "react";
4
+ import { Popover as Popover$1 } from "radix-ui";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/popover.tsx
7
+ function Popover({ ...props }) {
8
+ return /* @__PURE__ */ jsx(Popover$1.Root, {
9
+ "data-slot": "popover",
10
+ ...props
11
+ });
12
+ }
13
+ function PopoverTrigger({ ...props }) {
14
+ return /* @__PURE__ */ jsx(Popover$1.Trigger, {
15
+ "data-slot": "popover-trigger",
16
+ ...props
17
+ });
18
+ }
19
+ function PopoverContent({ className, align = "end", sideOffset = 4, ...props }) {
20
+ return /* @__PURE__ */ jsx(Popover$1.Portal, { children: /* @__PURE__ */ jsx(Popover$1.Content, {
21
+ "data-slot": "popover-content",
22
+ align,
23
+ sideOffset,
24
+ className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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 z-50 w-80 rounded-md border p-4 shadow-md outline-hidden", className),
25
+ ...props
26
+ }) });
27
+ }
28
+ export { Popover, PopoverContent, PopoverTrigger };
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import { RadioGroup as RadioGroup$1 } from "radix-ui";
3
+ declare function RadioGroup({ className, ...props }: React.ComponentProps<typeof RadioGroup$1.Root>): React.JSX.Element;
4
+ declare function RadioGroupItem({ className, ...props }: React.ComponentProps<typeof RadioGroup$1.Item>): React.JSX.Element;
5
+ export { RadioGroup, RadioGroupItem };