@ggem-farming/ui 0.0.0-stage → 0.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.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -2
  3. package/dist/accordion/accordion.d.ts +41 -0
  4. package/dist/accordion/accordion.js +89 -0
  5. package/dist/avatar/avatar.d.ts +20 -0
  6. package/dist/avatar/avatar.js +38 -0
  7. package/dist/badge/badge.d.ts +16 -0
  8. package/dist/badge/badge.js +85 -0
  9. package/dist/breadcrumbs/breadcrumbs.d.ts +19 -0
  10. package/dist/breadcrumbs/breadcrumbs.js +44 -0
  11. package/dist/button/button.d.ts +16 -0
  12. package/dist/button/button.js +49 -0
  13. package/dist/button/icon-button.d.ts +17 -0
  14. package/dist/button/icon-button.js +33 -0
  15. package/dist/card/card.d.ts +16 -0
  16. package/dist/card/card.js +56 -0
  17. package/dist/checkbox/checkbox.d.ts +15 -0
  18. package/dist/checkbox/checkbox.js +47 -0
  19. package/dist/combobox/combobox.d.ts +37 -0
  20. package/dist/combobox/combobox.js +155 -0
  21. package/dist/command/command-palette.d.ts +50 -0
  22. package/dist/command/command-palette.js +170 -0
  23. package/dist/command/kbd.d.ts +6 -0
  24. package/dist/command/kbd.js +16 -0
  25. package/dist/data/data-table.d.ts +105 -0
  26. package/dist/data/data-table.js +269 -0
  27. package/dist/data/export-button.d.ts +19 -0
  28. package/dist/data/export-button.js +34 -0
  29. package/dist/data/filter-bar.d.ts +54 -0
  30. package/dist/data/filter-bar.js +187 -0
  31. package/dist/data/pagination.d.ts +13 -0
  32. package/dist/data/pagination.js +84 -0
  33. package/dist/data/selection-bar.d.ts +21 -0
  34. package/dist/data/selection-bar.js +31 -0
  35. package/dist/date/date-input.d.ts +41 -0
  36. package/dist/date/date-input.js +71 -0
  37. package/dist/dialog/confirm-dialog.d.ts +24 -0
  38. package/dist/dialog/confirm-dialog.js +77 -0
  39. package/dist/dialog/dialog.d.ts +46 -0
  40. package/dist/dialog/dialog.js +102 -0
  41. package/dist/dialog/form-panel.d.ts +28 -0
  42. package/dist/dialog/form-panel.js +51 -0
  43. package/dist/feedback/alert.d.ts +29 -0
  44. package/dist/feedback/alert.js +70 -0
  45. package/dist/feedback/progress.d.ts +25 -0
  46. package/dist/feedback/progress.js +54 -0
  47. package/dist/feedback/toaster.d.ts +7 -0
  48. package/dist/feedback/toaster.js +35 -0
  49. package/dist/field/field.d.ts +40 -0
  50. package/dist/field/field.js +83 -0
  51. package/dist/field/text-field.d.ts +9 -0
  52. package/dist/field/text-field.js +16 -0
  53. package/dist/file-input/file-input.d.ts +26 -0
  54. package/dist/file-input/file-input.js +149 -0
  55. package/dist/fonts.css +3 -0
  56. package/dist/index.d.ts +43 -0
  57. package/dist/index.js +43 -0
  58. package/dist/input/input.d.ts +13 -0
  59. package/dist/input/input.js +25 -0
  60. package/dist/layout/app-shell.d.ts +100 -0
  61. package/dist/layout/app-shell.js +433 -0
  62. package/dist/layout/page.d.ts +20 -0
  63. package/dist/layout/page.js +53 -0
  64. package/dist/layout/record.d.ts +39 -0
  65. package/dist/layout/record.js +79 -0
  66. package/dist/lib/cn.d.ts +3 -0
  67. package/dist/lib/cn.js +18 -0
  68. package/dist/lib/control.js +14 -0
  69. package/dist/lib/popup.js +20 -0
  70. package/dist/menu/menu.d.ts +45 -0
  71. package/dist/menu/menu.js +85 -0
  72. package/dist/popover/popover.d.ts +22 -0
  73. package/dist/popover/popover.js +39 -0
  74. package/dist/radio/radio.d.ts +12 -0
  75. package/dist/radio/radio.js +25 -0
  76. package/dist/select/select.d.ts +23 -0
  77. package/dist/select/select.js +66 -0
  78. package/dist/separator/separator.d.ts +6 -0
  79. package/dist/separator/separator.js +14 -0
  80. package/dist/stat/stat.d.ts +28 -0
  81. package/dist/stat/stat.js +55 -0
  82. package/dist/state/states.d.ts +36 -0
  83. package/dist/state/states.js +108 -0
  84. package/dist/styles.css +42 -0
  85. package/dist/switch/switch.d.ts +9 -0
  86. package/dist/switch/switch.js +18 -0
  87. package/dist/table/table.d.ts +28 -0
  88. package/dist/table/table.js +72 -0
  89. package/dist/tabs/tabs.d.ts +26 -0
  90. package/dist/tabs/tabs.js +45 -0
  91. package/dist/tooltip/tooltip.d.ts +17 -0
  92. package/dist/tooltip/tooltip.js +27 -0
  93. package/package.json +57 -4
@@ -0,0 +1,37 @@
1
+ import { ReactNode } from "react";
2
+ import { Combobox as Combobox$1 } from "@base-ui/react/combobox";
3
+ export interface ComboboxOption<Value extends string | number> {
4
+ value: Value;
5
+ label: string;
6
+ disabled?: boolean;
7
+ }
8
+ export interface ComboboxProps<Value extends string | number> extends Omit<Combobox$1.Root.Props<Value, false, ComboboxOption<Value>>, 'items' | 'children' | 'multiple'> {
9
+ /** The choices. `value` is what the app stores (usually an ID); `label` is shown and searched. */
10
+ options: readonly ComboboxOption<Value>[];
11
+ placeholder?: string;
12
+ /** Shown when nothing matches the typed text. */
13
+ emptyText?: ReactNode;
14
+ /** Name for screen readers when there is no `FieldLabel`. */
15
+ 'aria-label'?: string;
16
+ /** Classes for the input group. */
17
+ className?: string;
18
+ }
19
+ /**
20
+ * Pick one value from a long list by typing to filter it. Inside a `Field`, `FieldLabel` labels it.
21
+ * For server-side search, filter `options` from your query and pass `filter={null}`.
22
+ */
23
+ export declare function Combobox<Value extends string | number>({ options, placeholder, emptyText, className, 'aria-label': ariaLabel, ...props }: ComboboxProps<Value>): import("react").JSX.Element;
24
+ export interface MultiComboboxProps<Value extends string | number> extends Omit<Combobox$1.Root.Props<Value, true, ComboboxOption<Value>>, 'items' | 'children' | 'multiple'> {
25
+ /** The choices. `value` is what the app stores (usually an ID); `label` is shown and searched. */
26
+ options: readonly ComboboxOption<Value>[];
27
+ placeholder?: string;
28
+ emptyText?: ReactNode;
29
+ /** Name for screen readers when there is no `FieldLabel`. */
30
+ 'aria-label'?: string;
31
+ className?: string;
32
+ }
33
+ /**
34
+ * Pick several values from a long list. Chosen values show as chips in the input; Backspace
35
+ * removes the last one, and Left Arrow from the start of the input moves into the chips.
36
+ */
37
+ export declare function MultiCombobox<Value extends string | number>({ options, placeholder, emptyText, className, 'aria-label': ariaLabel, ...props }: MultiComboboxProps<Value>): import("react").JSX.Element;
@@ -0,0 +1,155 @@
1
+ import { cn } from "../lib/cn.js";
2
+ import { controlFrame, controlHeight } from "../lib/control.js";
3
+ import { inlineIconButton, popupItem, popupSurface } from "../lib/popup.js";
4
+ import { useMemo } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Check, ChevronDown, X } from "lucide-react";
7
+ import { Combobox as Combobox$1 } from "@base-ui/react/combobox";
8
+ // src/combobox/combobox.tsx
9
+ /**
10
+ * Pick one value from a long list by typing to filter it. Inside a `Field`, `FieldLabel` labels it.
11
+ * For server-side search, filter `options` from your query and pass `filter={null}`.
12
+ */
13
+ function Combobox({ options, placeholder, emptyText = "No matches", className, "aria-label": ariaLabel, ...props }) {
14
+ const items = useMemo(() => Combobox$1.createItems(options, {
15
+ getValue: (option) => option.value,
16
+ getLabel: (option) => option.label
17
+ }), [options]);
18
+ return /* @__PURE__ */ jsxs(Combobox$1.Root, {
19
+ items,
20
+ ...props,
21
+ children: [/* @__PURE__ */ jsxs(Combobox$1.InputGroup, {
22
+ className: cn(controlFrame, controlHeight, "flex items-center gap-0.5 pr-1", "focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-focus", "has-data-invalid:border-danger", className),
23
+ children: [
24
+ /* @__PURE__ */ jsx(Combobox$1.Input, {
25
+ "aria-label": ariaLabel,
26
+ placeholder,
27
+ className: "h-full min-w-0 flex-1 bg-transparent pl-2.5 outline-none placeholder:text-fg-muted"
28
+ }),
29
+ /* @__PURE__ */ jsx(Combobox$1.Clear, {
30
+ "aria-label": "Clear selection",
31
+ className: inlineIconButton,
32
+ children: /* @__PURE__ */ jsx(X, {
33
+ className: "size-3.5",
34
+ "aria-hidden": true
35
+ })
36
+ }),
37
+ /* @__PURE__ */ jsx(Combobox$1.Trigger, {
38
+ "aria-label": "Show options",
39
+ className: inlineIconButton,
40
+ children: /* @__PURE__ */ jsx(ChevronDown, {
41
+ className: "size-4",
42
+ "aria-hidden": true
43
+ })
44
+ })
45
+ ]
46
+ }), /* @__PURE__ */ jsx(Combobox$1.Portal, { children: /* @__PURE__ */ jsx(Combobox$1.Positioner, {
47
+ sideOffset: 4,
48
+ className: "z-(--z-popover) outline-none",
49
+ children: /* @__PURE__ */ jsxs(Combobox$1.Popup, {
50
+ className: cn(popupSurface, "w-(--anchor-width) max-w-(--available-width)"),
51
+ children: [/* @__PURE__ */ jsx(Combobox$1.Empty, { children: /* @__PURE__ */ jsx("div", {
52
+ className: "px-3 py-2.5 text-sm text-fg-muted",
53
+ children: emptyText
54
+ }) }), /* @__PURE__ */ jsx(Combobox$1.List, {
55
+ className: "max-h-[min(22rem,var(--available-height))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",
56
+ children: (option) => /* @__PURE__ */ jsxs(Combobox$1.Item, {
57
+ value: option.value,
58
+ disabled: option.disabled ?? false,
59
+ className: cn(popupItem, "justify-between"),
60
+ children: [/* @__PURE__ */ jsx("span", {
61
+ className: "min-w-0 truncate",
62
+ children: option.label
63
+ }), /* @__PURE__ */ jsx(Combobox$1.ItemIndicator, {
64
+ className: "flex text-fg",
65
+ children: /* @__PURE__ */ jsx(Check, {
66
+ className: "size-4",
67
+ "aria-hidden": true
68
+ })
69
+ })]
70
+ }, option.value)
71
+ })]
72
+ })
73
+ }) })]
74
+ });
75
+ }
76
+ /**
77
+ * Pick several values from a long list. Chosen values show as chips in the input; Backspace
78
+ * removes the last one, and Left Arrow from the start of the input moves into the chips.
79
+ */
80
+ function MultiCombobox({ options, placeholder, emptyText = "No matches", className, "aria-label": ariaLabel, ...props }) {
81
+ const items = useMemo(() => Combobox$1.createItems(options, {
82
+ getValue: (option) => option.value,
83
+ getLabel: (option) => option.label
84
+ }), [options]);
85
+ const labelOf = useMemo(() => {
86
+ const labels = new Map(options.map((option) => [option.value, option.label]));
87
+ return (value) => labels.get(value) ?? String(value);
88
+ }, [options]);
89
+ return /* @__PURE__ */ jsxs(Combobox$1.Root, {
90
+ items,
91
+ multiple: true,
92
+ ...props,
93
+ children: [/* @__PURE__ */ jsxs(Combobox$1.InputGroup, {
94
+ className: cn(controlFrame, "flex min-h-8 cursor-text flex-wrap items-center gap-1 px-1 py-1 pointer-coarse:min-h-11", "focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-focus", "has-data-invalid:border-danger", className),
95
+ children: [/* @__PURE__ */ jsx(Combobox$1.Value, { children: (selected) => /* @__PURE__ */ jsxs(Combobox$1.Chips, {
96
+ className: "flex min-w-0 flex-1 flex-wrap items-center gap-1",
97
+ "aria-label": selected.length ? "Selected" : void 0,
98
+ children: [selected.map((value) => /* @__PURE__ */ jsxs(Combobox$1.Chip, {
99
+ "aria-label": labelOf(value),
100
+ className: "flex h-6 items-center gap-1 rounded bg-surface-hover pr-0.5 pl-2 text-sm outline-none focus-within:bg-primary focus-within:text-on-primary data-highlighted:bg-primary data-highlighted:text-on-primary pointer-coarse:h-8",
101
+ children: [/* @__PURE__ */ jsx("span", {
102
+ className: "max-w-[20ch] truncate",
103
+ children: labelOf(value)
104
+ }), /* @__PURE__ */ jsx(Combobox$1.ChipRemove, {
105
+ "aria-label": `Remove ${labelOf(value)}`,
106
+ className: "grid size-5 place-items-center rounded-sm hover:bg-surface-raised/20",
107
+ children: /* @__PURE__ */ jsx(X, {
108
+ className: "size-3",
109
+ "aria-hidden": true
110
+ })
111
+ })]
112
+ }, value)), /* @__PURE__ */ jsx(Combobox$1.Input, {
113
+ "aria-label": ariaLabel,
114
+ placeholder: selected.length ? void 0 : placeholder,
115
+ className: "h-6 min-w-16 flex-1 bg-transparent pl-1.5 outline-none placeholder:text-fg-muted"
116
+ })]
117
+ }) }), /* @__PURE__ */ jsx(Combobox$1.Trigger, {
118
+ "aria-label": "Show options",
119
+ className: inlineIconButton,
120
+ children: /* @__PURE__ */ jsx(ChevronDown, {
121
+ className: "size-4",
122
+ "aria-hidden": true
123
+ })
124
+ })]
125
+ }), /* @__PURE__ */ jsx(Combobox$1.Portal, { children: /* @__PURE__ */ jsx(Combobox$1.Positioner, {
126
+ sideOffset: 4,
127
+ className: "z-(--z-popover) outline-none",
128
+ children: /* @__PURE__ */ jsxs(Combobox$1.Popup, {
129
+ className: cn(popupSurface, "w-(--anchor-width) max-w-(--available-width)"),
130
+ children: [/* @__PURE__ */ jsx(Combobox$1.Empty, { children: /* @__PURE__ */ jsx("div", {
131
+ className: "px-3 py-2.5 text-sm text-fg-muted",
132
+ children: emptyText
133
+ }) }), /* @__PURE__ */ jsx(Combobox$1.List, {
134
+ className: "max-h-[min(22rem,var(--available-height))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",
135
+ children: (option) => /* @__PURE__ */ jsxs(Combobox$1.Item, {
136
+ value: option.value,
137
+ disabled: option.disabled ?? false,
138
+ className: cn(popupItem, "justify-between"),
139
+ children: [/* @__PURE__ */ jsx("span", {
140
+ className: "min-w-0 truncate",
141
+ children: option.label
142
+ }), /* @__PURE__ */ jsx(Combobox$1.ItemIndicator, {
143
+ className: "flex text-fg",
144
+ children: /* @__PURE__ */ jsx(Check, {
145
+ className: "size-4",
146
+ "aria-hidden": true
147
+ })
148
+ })]
149
+ }, option.value)
150
+ })]
151
+ })
152
+ }) })]
153
+ });
154
+ }
155
+ export { Combobox, MultiCombobox };
@@ -0,0 +1,50 @@
1
+ import { ReactNode } from "react";
2
+ export interface CommandItem {
3
+ /** Unique within the palette, e.g. a route or a farmer ID. */
4
+ value: string;
5
+ /** What is shown and searched. */
6
+ label: string;
7
+ /** Secondary text, e.g. a phone number or the section a page is in. */
8
+ description?: ReactNode;
9
+ icon?: ReactNode;
10
+ /** A shortcut hint shown on the right, e.g. "G F". */
11
+ shortcut?: string;
12
+ disabled?: boolean;
13
+ }
14
+ export interface CommandGroup {
15
+ label: string;
16
+ items: readonly CommandItem[];
17
+ }
18
+ export interface CommandPaletteProps {
19
+ open: boolean;
20
+ onOpenChange: (open: boolean) => void;
21
+ groups: readonly CommandGroup[];
22
+ /** Runs the chosen command; the palette then closes. */
23
+ onSelect: (item: CommandItem) => void;
24
+ /** Accessible name of the dialog. Default "Command palette". */
25
+ label?: string;
26
+ placeholder?: string;
27
+ /** Typed text (controlled), e.g. for a server search. */
28
+ query?: string;
29
+ onQueryChange?: (query: string) => void;
30
+ /**
31
+ * `true` when `groups` already hold server results for `query`: the palette shows them as they
32
+ * are instead of filtering them again.
33
+ */
34
+ serverFiltered?: boolean;
35
+ /** Results are loading for the current query. */
36
+ loading?: boolean;
37
+ /** Shown when nothing matches. */
38
+ emptyText?: ReactNode;
39
+ }
40
+ /**
41
+ * A keyboard-first launcher: type to filter, arrow keys to move, Enter to run, Escape to close.
42
+ * Open it with `useCommandShortcut` (⌘K / Ctrl+K). Works for navigation, actions and record
43
+ * search (pass `serverFiltered` with results from your API).
44
+ */
45
+ export declare function CommandPalette({ open, onOpenChange, groups, onSelect, label, placeholder, query, onQueryChange, serverFiltered, loading, emptyText }: CommandPaletteProps): import("react").JSX.Element;
46
+ /**
47
+ * Toggles a palette with ⌘K (macOS) or Ctrl+K (elsewhere), from anywhere on the page. Mount it
48
+ * once, next to the palette.
49
+ */
50
+ export declare function useCommandShortcut(onToggle: () => void, key?: string): void;
@@ -0,0 +1,170 @@
1
+ import { overlayBackdrop } from "../dialog/dialog.js";
2
+ import { cn } from "../lib/cn.js";
3
+ import { Kbd } from "./kbd.js";
4
+ import { useEffect, useId } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { CornerDownLeft, LoaderCircle, Search } from "lucide-react";
7
+ import { Dialog } from "@base-ui/react/dialog";
8
+ import { Autocomplete } from "@base-ui/react/autocomplete";
9
+ // src/command/command-palette.tsx
10
+ /**
11
+ * A keyboard-first launcher: type to filter, arrow keys to move, Enter to run, Escape to close.
12
+ * Open it with `useCommandShortcut` (⌘K / Ctrl+K). Works for navigation, actions and record
13
+ * search (pass `serverFiltered` with results from your API).
14
+ */
15
+ function CommandPalette({ open, onOpenChange, groups, onSelect, label = "Command palette", placeholder = "Search…", query, onQueryChange, serverFiltered = false, loading = false, emptyText = "No results" }) {
16
+ const hintId = useId();
17
+ const items = groups.filter((group) => group.items.length > 0).map((group) => ({
18
+ value: group.label,
19
+ items: group.items
20
+ }));
21
+ return /* @__PURE__ */ jsx(Dialog.Root, {
22
+ open,
23
+ onOpenChange,
24
+ children: /* @__PURE__ */ jsxs(Dialog.Portal, { children: [/* @__PURE__ */ jsx(Dialog.Backdrop, { className: overlayBackdrop }), /* @__PURE__ */ jsx(Dialog.Viewport, {
25
+ className: "fixed inset-0 z-(--z-modal) flex items-start justify-center px-2 pt-[12vh] pb-2",
26
+ children: /* @__PURE__ */ jsx(Dialog.Popup, {
27
+ "aria-label": label,
28
+ className: cn("flex max-h-[min(34rem,calc(100dvh-5rem))] w-full max-w-xl flex-col overflow-hidden", "rounded-xl border border-border bg-surface-raised text-fg shadow-lg outline-none", "transition-[translate,scale,opacity] duration-fast ease-standard", "data-starting-style:-translate-y-2 data-starting-style:scale-[0.98] data-starting-style:opacity-0", "data-ending-style:-translate-y-2 data-ending-style:scale-[0.98] data-ending-style:opacity-0"),
29
+ children: /* @__PURE__ */ jsxs(Autocomplete.Root, {
30
+ open: true,
31
+ inline: true,
32
+ items,
33
+ itemToStringValue: (item) => item.label,
34
+ autoHighlight: "always",
35
+ keepHighlight: true,
36
+ filter: serverFiltered ? null : void 0,
37
+ value: query,
38
+ onValueChange: onQueryChange,
39
+ children: [
40
+ /* @__PURE__ */ jsxs(Autocomplete.InputGroup, {
41
+ className: "flex items-center gap-2 border-b border-border px-3",
42
+ children: [
43
+ /* @__PURE__ */ jsx(Search, {
44
+ className: "size-4 shrink-0 text-fg-muted",
45
+ "aria-hidden": true
46
+ }),
47
+ /* @__PURE__ */ jsx(Autocomplete.Input, {
48
+ "aria-label": placeholder.replace(/…$/, ""),
49
+ "aria-describedby": hintId,
50
+ placeholder,
51
+ className: "h-12 min-w-0 flex-1 bg-transparent text-base outline-none placeholder:text-fg-muted"
52
+ }),
53
+ loading && /* @__PURE__ */ jsx(LoaderCircle, {
54
+ className: "size-4 shrink-0 animate-spin text-fg-muted motion-reduce:animate-none",
55
+ "aria-hidden": true
56
+ }),
57
+ /* @__PURE__ */ jsxs(Dialog.Close, {
58
+ className: "sr-only",
59
+ children: ["Close ", label.toLowerCase()]
60
+ })
61
+ ]
62
+ }),
63
+ /* @__PURE__ */ jsxs("div", {
64
+ className: "min-h-0 flex-1 overflow-y-auto overscroll-contain",
65
+ children: [
66
+ /* @__PURE__ */ jsx(Autocomplete.Status, {
67
+ className: "sr-only",
68
+ children: loading ? "Searching…" : void 0
69
+ }),
70
+ /* @__PURE__ */ jsx(Autocomplete.Empty, { children: /* @__PURE__ */ jsx("div", {
71
+ className: "px-4 py-10 text-center text-sm text-fg-muted",
72
+ children: loading ? "Searching…" : emptyText
73
+ }) }),
74
+ /* @__PURE__ */ jsx(Autocomplete.List, {
75
+ className: "p-1.5 data-empty:p-0",
76
+ children: (group) => /* @__PURE__ */ jsxs(Autocomplete.Group, {
77
+ items: group.items,
78
+ className: "not-last:mb-1",
79
+ children: [/* @__PURE__ */ jsx(Autocomplete.GroupLabel, {
80
+ className: "px-2 pt-2 pb-1 text-xs font-medium text-fg-muted",
81
+ children: group.value
82
+ }), /* @__PURE__ */ jsx(Autocomplete.Collection, { children: (item) => /* @__PURE__ */ jsxs(Autocomplete.Item, {
83
+ value: item,
84
+ disabled: item.disabled ?? false,
85
+ onClick: () => {
86
+ onSelect(item);
87
+ onOpenChange(false);
88
+ },
89
+ className: cn("group flex min-h-10 cursor-default items-center gap-3 rounded-md px-2 py-1.5 text-sm outline-none select-none [scroll-margin-block:0.375rem]", "data-highlighted:bg-surface-hover data-disabled:opacity-50 pointer-coarse:min-h-12", "[&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-fg-muted"),
90
+ children: [
91
+ item.icon,
92
+ /* @__PURE__ */ jsxs("span", {
93
+ className: "min-w-0 flex-1",
94
+ children: [/* @__PURE__ */ jsx("span", {
95
+ className: "block truncate",
96
+ children: item.label
97
+ }), item.description && /* @__PURE__ */ jsx("span", {
98
+ className: "block truncate text-xs text-fg-muted",
99
+ children: item.description
100
+ })]
101
+ }),
102
+ item.shortcut && /* @__PURE__ */ jsx("span", {
103
+ className: "hidden gap-1 sm:flex",
104
+ "aria-hidden": true,
105
+ children: item.shortcut.split(" ").map((key) => /* @__PURE__ */ jsx(Kbd, { children: key }, key))
106
+ }),
107
+ /* @__PURE__ */ jsx(CornerDownLeft, {
108
+ className: "hidden group-data-highlighted:block",
109
+ "aria-hidden": true
110
+ })
111
+ ]
112
+ }, item.value) })]
113
+ }, group.value)
114
+ })
115
+ ]
116
+ }),
117
+ /* @__PURE__ */ jsxs("div", {
118
+ className: "flex items-center gap-4 border-t border-border bg-surface-muted px-3 py-2 text-xs text-fg-muted",
119
+ children: [
120
+ /* @__PURE__ */ jsx("span", {
121
+ id: hintId,
122
+ className: "sr-only",
123
+ children: "Use the arrow keys to move and Enter to choose."
124
+ }),
125
+ /* @__PURE__ */ jsxs("span", {
126
+ className: "flex items-center gap-1",
127
+ "aria-hidden": true,
128
+ children: [
129
+ /* @__PURE__ */ jsx(Kbd, { children: "↑" }),
130
+ /* @__PURE__ */ jsx(Kbd, { children: "↓" }),
131
+ " move"
132
+ ]
133
+ }),
134
+ /* @__PURE__ */ jsxs("span", {
135
+ className: "flex items-center gap-1",
136
+ "aria-hidden": true,
137
+ children: [/* @__PURE__ */ jsx(Kbd, { children: "Enter" }), " choose"]
138
+ }),
139
+ /* @__PURE__ */ jsxs("span", {
140
+ className: "ml-auto flex items-center gap-1",
141
+ "aria-hidden": true,
142
+ children: [/* @__PURE__ */ jsx(Kbd, { children: "Esc" }), " close"]
143
+ })
144
+ ]
145
+ })
146
+ ]
147
+ })
148
+ })
149
+ })] })
150
+ });
151
+ }
152
+ /**
153
+ * Toggles a palette with ⌘K (macOS) or Ctrl+K (elsewhere), from anywhere on the page. Mount it
154
+ * once, next to the palette.
155
+ */
156
+ function useCommandShortcut(onToggle, key = "k") {
157
+ useEffect(() => {
158
+ const listener = (event) => {
159
+ if (event.key.toLowerCase() === key && (event.metaKey || event.ctrlKey) && !event.altKey) {
160
+ event.preventDefault();
161
+ onToggle();
162
+ }
163
+ };
164
+ window.addEventListener("keydown", listener);
165
+ return () => {
166
+ window.removeEventListener("keydown", listener);
167
+ };
168
+ }, [onToggle, key]);
169
+ }
170
+ export { CommandPalette, useCommandShortcut };
@@ -0,0 +1,6 @@
1
+ import { HTMLAttributes } from "react";
2
+ /**
3
+ * A keyboard key, e.g. `<Kbd>⌘</Kbd><Kbd>K</Kbd>` or `<Kbd>Enter</Kbd>`. Pair symbol-only keys with
4
+ * text for screen readers (`aria-label="Command"`) where the meaning isn't otherwise given.
5
+ */
6
+ export declare const Kbd: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & import("react").RefAttributes<HTMLElement>>;
@@ -0,0 +1,16 @@
1
+ import { cn } from "../lib/cn.js";
2
+ import { forwardRef } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/command/kbd.tsx
5
+ /**
6
+ * A keyboard key, e.g. `<Kbd>⌘</Kbd><Kbd>K</Kbd>` or `<Kbd>Enter</Kbd>`. Pair symbol-only keys with
7
+ * text for screen readers (`aria-label="Command"`) where the meaning isn't otherwise given.
8
+ */
9
+ const Kbd = forwardRef(function Kbd({ className, ...props }, ref) {
10
+ return /* @__PURE__ */ jsx("kbd", {
11
+ ref,
12
+ className: cn("inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-surface-muted px-1", "font-mono text-[0.6875rem] leading-none font-medium text-fg-muted", className),
13
+ ...props
14
+ });
15
+ });
16
+ export { Kbd };
@@ -0,0 +1,105 @@
1
+ import { ReactNode } from "react";
2
+ import { CellData, ColumnDef, ColumnVisibilityState, OnChangeFn, PaginationState, Row, RowData, RowSelectionState, SortingState, TableFeatures } from "@tanstack/react-table";
3
+ declare module '@tanstack/table-core' {
4
+ interface ColumnMeta<in out TFeatures extends TableFeatures, in out TData extends RowData, TValue extends CellData = CellData> {
5
+ /** Right-align numbers and money. */
6
+ align?: 'left' | 'right';
7
+ /** Role in the phone card: `title`, `subtitle` (joined with ·), `trailing`, or `false` to hide. */
8
+ card?: 'title' | 'subtitle' | 'trailing' | false;
9
+ /** `low` columns hide until the table is wide (64rem), e.g. phone, field officer. */
10
+ priority?: 'low';
11
+ }
12
+ }
13
+ /** The table features the kit registers: sorting, pagination, row selection, column visibility. */
14
+ export declare const dataTableFeatures: {
15
+ rowSortingFeature: import("@tanstack/table-core").TableFeature;
16
+ sortedRowModel: (table: import("@tanstack/table-core").Table<any, any>) => () => import("@tanstack/table-core").RowModel<any, any>;
17
+ sortFns: {
18
+ alphanumeric: import("@tanstack/table-core").CreatedSortFn<any, any>;
19
+ text: import("@tanstack/table-core").CreatedSortFn<any, any>;
20
+ datetime: import("@tanstack/table-core").CreatedSortFn<any, any>;
21
+ basic: import("@tanstack/table-core").CreatedSortFn<any, any>;
22
+ };
23
+ rowPaginationFeature: import("@tanstack/table-core").TableFeature;
24
+ paginatedRowModel: (table: import("@tanstack/table-core").Table<any, any>) => () => import("@tanstack/table-core").RowModel<any, any>;
25
+ rowSelectionFeature: import("@tanstack/table-core").TableFeature;
26
+ columnVisibilityFeature: import("@tanstack/table-core").TableFeature;
27
+ };
28
+ export type DataTableFeatures = typeof dataTableFeatures;
29
+ export type DataTableColumn<TData extends RowData> = ColumnDef<DataTableFeatures, TData, any>;
30
+ export type DataTableRow<TData extends RowData> = Row<DataTableFeatures, TData>;
31
+ /** Column ID → visible. Only an explicit `false` hides a column. */
32
+ export type VisibilityState = ColumnVisibilityState;
33
+ /**
34
+ * Typed column helper. Build the list with `col.columns([...])` so each column keeps its own value
35
+ * type; annotating the array as `DataTableColumn<T>[]` would widen cell values to `any`.
36
+ * ```ts
37
+ * const col = createDataTableColumnHelper<Farmer>();
38
+ * const columns = col.columns([col.accessor('name', { header: 'Farmer' })]);
39
+ * ```
40
+ */
41
+ export declare function createDataTableColumnHelper<TData extends RowData>(): import("@tanstack/table-core").ColumnHelper<{
42
+ rowSortingFeature: import("@tanstack/table-core").TableFeature;
43
+ sortedRowModel: (table: import("@tanstack/table-core").Table<any, any>) => () => import("@tanstack/table-core").RowModel<any, any>;
44
+ sortFns: {
45
+ alphanumeric: import("@tanstack/table-core").CreatedSortFn<any, any>;
46
+ text: import("@tanstack/table-core").CreatedSortFn<any, any>;
47
+ datetime: import("@tanstack/table-core").CreatedSortFn<any, any>;
48
+ basic: import("@tanstack/table-core").CreatedSortFn<any, any>;
49
+ };
50
+ rowPaginationFeature: import("@tanstack/table-core").TableFeature;
51
+ paginatedRowModel: (table: import("@tanstack/table-core").Table<any, any>) => () => import("@tanstack/table-core").RowModel<any, any>;
52
+ rowSelectionFeature: import("@tanstack/table-core").TableFeature;
53
+ columnVisibilityFeature: import("@tanstack/table-core").TableFeature;
54
+ }, TData>;
55
+ export interface DataTableProps<TData extends RowData> {
56
+ /** Name of the table for screen readers, e.g. "Farmers". */
57
+ 'aria-label': string;
58
+ columns: readonly DataTableColumn<TData>[];
59
+ data: readonly TData[] | undefined;
60
+ /** Stable ID per row (never the index). */
61
+ getRowId: (row: TData) => string;
62
+ /** Text naming a row, used for its selection checkbox, e.g. the farmer's name. */
63
+ getRowLabel?: (row: TData) => string;
64
+ /**
65
+ * Total rows on the server. Setting it switches to server mode: `data` is the current page,
66
+ * already sorted; the table only reports `sorting` and `pagination` changes.
67
+ */
68
+ rowCount?: number;
69
+ sorting?: SortingState;
70
+ onSortingChange?: OnChangeFn<SortingState>;
71
+ pagination?: PaginationState;
72
+ onPaginationChange?: OnChangeFn<PaginationState>;
73
+ columnVisibility?: VisibilityState;
74
+ onColumnVisibilityChange?: OnChangeFn<VisibilityState>;
75
+ /** Show checkboxes. Selection is keyed by row ID, across pages. */
76
+ enableRowSelection?: boolean;
77
+ rowSelection?: RowSelectionState;
78
+ onRowSelectionChange?: OnChangeFn<RowSelectionState>;
79
+ /** Page sizes offered; `false` hides the footer (e.g. short fixed lists). */
80
+ pageSizes?: readonly number[] | false;
81
+ /**
82
+ * Mouse shortcut: open the row when it is clicked anywhere. Keyboard users need a link in the
83
+ * first column too. Clicks on links, buttons and checkboxes in the row are ignored.
84
+ */
85
+ onRowClick?: (row: TData) => void;
86
+ /** First load with no data yet: shows skeleton rows. */
87
+ loading?: boolean;
88
+ /** Refetching with data shown: keeps rows and shows a progress line. */
89
+ fetching?: boolean;
90
+ /**
91
+ * Why the load failed, e.g. "Check your connection and try again." The table supplies the title
92
+ * ("Couldn't load farmers"). With rows still shown it appears as a banner above them.
93
+ */
94
+ error?: ReactNode;
95
+ onRetry?: () => void;
96
+ /** Shown when there are no rows; say why and offer the next step. */
97
+ empty?: ReactNode;
98
+ className?: string;
99
+ }
100
+ /**
101
+ * A data table that fills the remaining height, with sorting, paging, selection, loading, error
102
+ * and empty states. Narrow containers (under 42rem) show cards instead of a table.
103
+ */
104
+ export declare function DataTable<TData extends RowData>({ 'aria-label': label, columns, data, getRowId, getRowLabel, rowCount, sorting, onSortingChange, pagination, onPaginationChange, columnVisibility, onColumnVisibilityChange, enableRowSelection, rowSelection, onRowSelectionChange, pageSizes, onRowClick, loading, fetching, error, onRetry, empty, className }: DataTableProps<TData>): import("react").JSX.Element;
105
+ export type { PaginationState, RowSelectionState, SortingState };