@heigin/ui 0.0.0-stage → 0.1.1
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/CHANGELOG.md +33 -0
- package/LICENSE +15 -0
- package/README.md +28 -2
- package/dist/base.css +44 -0
- package/dist/components/crm/activity-timeline.d.ts +23 -0
- package/dist/components/crm/activity-timeline.js +41 -0
- package/dist/components/crm/approval-card.d.ts +33 -0
- package/dist/components/crm/approval-card.js +101 -0
- package/dist/components/crm/channel-mark.d.ts +10 -0
- package/dist/components/crm/channel-mark.js +57 -0
- package/dist/components/crm/conversation-list-item.d.ts +23 -0
- package/dist/components/crm/conversation-list-item.js +62 -0
- package/dist/components/crm/crm.module.js +161 -0
- package/dist/components/crm/deal-stage.d.ts +13 -0
- package/dist/components/crm/deal-stage.js +27 -0
- package/dist/components/crm/detail-list.d.ts +17 -0
- package/dist/components/crm/detail-list.js +35 -0
- package/dist/components/crm/filter-chip.d.ts +16 -0
- package/dist/components/crm/filter-chip.js +45 -0
- package/dist/components/crm/filter-toolbar.d.ts +16 -0
- package/dist/components/crm/filter-toolbar.js +42 -0
- package/dist/components/crm/metric-card.d.ts +30 -0
- package/dist/components/crm/metric-card.js +61 -0
- package/dist/components/crm/money-value.d.ts +9 -0
- package/dist/components/crm/money-value.js +27 -0
- package/dist/components/crm/page-header.d.ts +11 -0
- package/dist/components/crm/page-header.js +28 -0
- package/dist/components/crm/record-header.d.ts +22 -0
- package/dist/components/crm/record-header.js +53 -0
- package/dist/components/crm/sidebar-nav.d.ts +33 -0
- package/dist/components/crm/sidebar-nav.js +53 -0
- package/dist/components/crm/sla-clock.d.ts +11 -0
- package/dist/components/crm/sla-clock.js +41 -0
- package/dist/components/crm/status-badge.d.ts +94 -0
- package/dist/components/crm/status-badge.js +106 -0
- package/dist/components/crm/task-row.d.ts +18 -0
- package/dist/components/crm/task-row.js +52 -0
- package/dist/components/crm/trust-rung-badge.d.ts +14 -0
- package/dist/components/crm/trust-rung-badge.js +35 -0
- package/dist/components/ui/alert-dialog.d.ts +22 -0
- package/dist/components/ui/alert-dialog.js +87 -0
- package/dist/components/ui/avatar.d.ts +13 -0
- package/dist/components/ui/avatar.js +38 -0
- package/dist/components/ui/avatar.module.js +17 -0
- package/dist/components/ui/badge.d.ts +12 -0
- package/dist/components/ui/badge.js +28 -0
- package/dist/components/ui/badge.module.js +25 -0
- package/dist/components/ui/button.d.ts +19 -0
- package/dist/components/ui/button.js +39 -0
- package/dist/components/ui/button.module.js +27 -0
- package/dist/components/ui/card.d.ts +19 -0
- package/dist/components/ui/card.js +35 -0
- package/dist/components/ui/card.module.js +23 -0
- package/dist/components/ui/checkbox.d.ts +11 -0
- package/dist/components/ui/checkbox.js +47 -0
- package/dist/components/ui/choice.module.js +28 -0
- package/dist/components/ui/dialog.d.ts +32 -0
- package/dist/components/ui/dialog.js +67 -0
- package/dist/components/ui/dialog.module.js +39 -0
- package/dist/components/ui/drawer.d.ts +20 -0
- package/dist/components/ui/drawer.js +44 -0
- package/dist/components/ui/dropdown-menu.d.ts +38 -0
- package/dist/components/ui/dropdown-menu.js +66 -0
- package/dist/components/ui/empty-state.d.ts +12 -0
- package/dist/components/ui/empty-state.js +33 -0
- package/dist/components/ui/empty-state.module.js +19 -0
- package/dist/components/ui/field.d.ts +38 -0
- package/dist/components/ui/field.js +77 -0
- package/dist/components/ui/field.module.js +17 -0
- package/dist/components/ui/icon-button.d.ts +9 -0
- package/dist/components/ui/icon-button.js +21 -0
- package/dist/components/ui/input.d.ts +8 -0
- package/dist/components/ui/input.js +23 -0
- package/dist/components/ui/input.module.js +25 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +34 -0
- package/dist/components/ui/native-select.d.ts +10 -0
- package/dist/components/ui/native-select.js +26 -0
- package/dist/components/ui/pagination.d.ts +12 -0
- package/dist/components/ui/pagination.js +54 -0
- package/dist/components/ui/popover.d.ts +17 -0
- package/dist/components/ui/popover.js +41 -0
- package/dist/components/ui/popup.module.js +39 -0
- package/dist/components/ui/radio-group.d.ts +18 -0
- package/dist/components/ui/radio-group.js +50 -0
- package/dist/components/ui/search-input.d.ts +15 -0
- package/dist/components/ui/search-input.js +64 -0
- package/dist/components/ui/select.d.ts +27 -0
- package/dist/components/ui/select.js +71 -0
- package/dist/components/ui/skeleton.d.ts +12 -0
- package/dist/components/ui/skeleton.js +23 -0
- package/dist/components/ui/skeleton.module.js +15 -0
- package/dist/components/ui/spinner.d.ts +8 -0
- package/dist/components/ui/spinner.js +19 -0
- package/dist/components/ui/spinner.module.js +13 -0
- package/dist/components/ui/switch.d.ts +10 -0
- package/dist/components/ui/switch.js +35 -0
- package/dist/components/ui/table.d.ts +52 -0
- package/dist/components/ui/table.js +143 -0
- package/dist/components/ui/table.module.js +42 -0
- package/dist/components/ui/tabs.d.ts +25 -0
- package/dist/components/ui/tabs.js +47 -0
- package/dist/components/ui/tabs.module.js +21 -0
- package/dist/components/ui/textarea.d.ts +6 -0
- package/dist/components/ui/textarea.js +23 -0
- package/dist/components/ui/toast.d.ts +30 -0
- package/dist/components/ui/toast.js +81 -0
- package/dist/components/ui/toast.module.js +21 -0
- package/dist/components/ui/tooltip.d.ts +18 -0
- package/dist/components/ui/tooltip.js +30 -0
- package/dist/components/ui/visually-hidden.d.ts +3 -0
- package/dist/components/ui/visually-hidden.js +26 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +50 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +7 -0
- package/dist/lib/format.d.ts +6 -0
- package/dist/lib/format.js +33 -0
- package/dist/styles.css +2317 -0
- package/dist/tailwind.css +82 -0
- package/dist/tokens.css +131 -0
- package/dist/tokens.d.ts +339 -0
- package/dist/tokens.js +791 -0
- package/package.json +54 -4
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { useField } from "./field.js";
|
|
5
|
+
import input_module_default from "./input.module.js";
|
|
6
|
+
import popup_module_default from "./popup.module.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Check, ChevronDown } from "lucide-react";
|
|
10
|
+
import { Select } from "@base-ui/react/select";
|
|
11
|
+
//#region src/components/ui/select.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Single-value select with a custom listbox. Works inside a `Field` (label, description, error).
|
|
14
|
+
* For long, searchable lists use a combobox instead.
|
|
15
|
+
*/
|
|
16
|
+
var Select$1 = React.forwardRef(function Select$2({ options, value, defaultValue, onValueChange, placeholder = "Select…", disabled, required, invalid, name, size = "md", id, className, ...aria }, ref) {
|
|
17
|
+
const field = useField();
|
|
18
|
+
const items = React.useMemo(() => Object.fromEntries(options.map((o) => [o.value, o.label])), [options]);
|
|
19
|
+
const isInvalid = invalid ?? field?.invalid ?? false;
|
|
20
|
+
return /* @__PURE__ */ jsxs(Select.Root, {
|
|
21
|
+
items,
|
|
22
|
+
value,
|
|
23
|
+
defaultValue,
|
|
24
|
+
onValueChange: (next) => onValueChange?.(next ?? null),
|
|
25
|
+
disabled: disabled ?? field?.disabled,
|
|
26
|
+
required: required ?? field?.required,
|
|
27
|
+
name,
|
|
28
|
+
children: [/* @__PURE__ */ jsxs(Select.Trigger, {
|
|
29
|
+
ref,
|
|
30
|
+
id: id ?? field?.controlId,
|
|
31
|
+
"aria-describedby": field?.describedBy,
|
|
32
|
+
"aria-invalid": isInvalid || void 0,
|
|
33
|
+
"aria-label": aria["aria-label"],
|
|
34
|
+
className: cn(input_module_default.control, size !== "md" && input_module_default[size], popup_module_default.trigger, className),
|
|
35
|
+
children: [/* @__PURE__ */ jsx(Select.Value, {
|
|
36
|
+
className: popup_module_default.value,
|
|
37
|
+
placeholder
|
|
38
|
+
}), /* @__PURE__ */ jsx(Select.Icon, {
|
|
39
|
+
className: popup_module_default.chevron,
|
|
40
|
+
children: /* @__PURE__ */ jsx(ChevronDown, {
|
|
41
|
+
strokeWidth: 1.6,
|
|
42
|
+
"aria-hidden": "true"
|
|
43
|
+
})
|
|
44
|
+
})]
|
|
45
|
+
}), /* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Positioner, {
|
|
46
|
+
className: popup_module_default.positioner,
|
|
47
|
+
sideOffset: 4,
|
|
48
|
+
alignItemWithTrigger: false,
|
|
49
|
+
children: /* @__PURE__ */ jsx(Select.Popup, {
|
|
50
|
+
className: popup_module_default.popup,
|
|
51
|
+
children: /* @__PURE__ */ jsx(Select.List, { children: options.map((option) => /* @__PURE__ */ jsxs(Select.Item, {
|
|
52
|
+
value: option.value,
|
|
53
|
+
disabled: option.disabled,
|
|
54
|
+
className: popup_module_default.item,
|
|
55
|
+
children: [/* @__PURE__ */ jsx(Select.ItemText, {
|
|
56
|
+
className: popup_module_default.itemText,
|
|
57
|
+
children: option.label
|
|
58
|
+
}), /* @__PURE__ */ jsx(Select.ItemIndicator, {
|
|
59
|
+
className: popup_module_default.itemIndicator,
|
|
60
|
+
children: /* @__PURE__ */ jsx(Check, {
|
|
61
|
+
strokeWidth: 2,
|
|
62
|
+
"aria-hidden": "true"
|
|
63
|
+
})
|
|
64
|
+
})]
|
|
65
|
+
}, option.value)) })
|
|
66
|
+
})
|
|
67
|
+
}) })]
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
//#endregion
|
|
71
|
+
export { Select$1 as Select };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SkeletonProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
width?: number | string;
|
|
4
|
+
height?: number | string;
|
|
5
|
+
/** `circle` for avatars, `text` for a line of copy. */
|
|
6
|
+
shape?: "rect" | "text" | "circle";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Loading placeholder (production: surface-hover fill, pulse 1.4s). Decorative: announce loading
|
|
10
|
+
* once on the container (e.g. `aria-busy` on the table) rather than on every skeleton.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Skeleton({ width, height, shape, className, style, ...props }: SkeletonProps): React.JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import skeleton_module_default from "./skeleton.module.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ui/skeleton.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Loading placeholder (production: surface-hover fill, pulse 1.4s). Decorative: announce loading
|
|
8
|
+
* once on the container (e.g. `aria-busy` on the table) rather than on every skeleton.
|
|
9
|
+
*/
|
|
10
|
+
function Skeleton({ width, height, shape = "rect", className, style, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx("span", {
|
|
12
|
+
"aria-hidden": "true",
|
|
13
|
+
className: cn(skeleton_module_default.skeleton, skeleton_module_default[shape], className),
|
|
14
|
+
style: {
|
|
15
|
+
width,
|
|
16
|
+
height,
|
|
17
|
+
...style
|
|
18
|
+
},
|
|
19
|
+
...props
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { Skeleton };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/components/ui/skeleton.module.css
|
|
2
|
+
var skeleton = "hg-skeleton-module_skeleton_1Lhb8";
|
|
3
|
+
var pulse = "hg-skeleton-module_pulse_JamTf";
|
|
4
|
+
var rect = "hg-skeleton-module_rect_Z6Ias";
|
|
5
|
+
var text = "hg-skeleton-module_text_Tes7v";
|
|
6
|
+
var circle = "hg-skeleton-module_circle_eRyZb";
|
|
7
|
+
var skeleton_module_default = {
|
|
8
|
+
skeleton,
|
|
9
|
+
pulse,
|
|
10
|
+
rect,
|
|
11
|
+
text,
|
|
12
|
+
circle
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { circle, skeleton_module_default as default, pulse, rect, skeleton, text };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SpinnerProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
size?: "sm" | "md" | "lg";
|
|
4
|
+
/** Accessible label. Pass `null` when the spinner is decorative (e.g. inside a labelled button). */
|
|
5
|
+
label?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** Indeterminate loading indicator. Uses `currentColor`, so it inherits the text colour. */
|
|
8
|
+
export declare const Spinner: React.ForwardRefExoticComponent<SpinnerProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import spinner_module_default from "./spinner.module.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ui/spinner.tsx
|
|
6
|
+
/** Indeterminate loading indicator. Uses `currentColor`, so it inherits the text colour. */
|
|
7
|
+
var Spinner = React.forwardRef(function Spinner({ size = "md", label = "Loading", className, ...props }, ref) {
|
|
8
|
+
return /* @__PURE__ */ jsx("span", {
|
|
9
|
+
ref,
|
|
10
|
+
role: label ? "status" : void 0,
|
|
11
|
+
"aria-label": label ?? void 0,
|
|
12
|
+
"aria-hidden": label ? void 0 : true,
|
|
13
|
+
"data-size": size,
|
|
14
|
+
className: cn(spinner_module_default.spinner, size !== "md" && spinner_module_default[size], className),
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Spinner };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/components/ui/spinner.module.css
|
|
2
|
+
var spinner = "hg-spinner-module_spinner_BFhah";
|
|
3
|
+
var spin = "hg-spinner-module_spin_Sm-na";
|
|
4
|
+
var sm = "hg-spinner-module_sm_PPN9F";
|
|
5
|
+
var lg = "hg-spinner-module_lg_V06Hv";
|
|
6
|
+
var spinner_module_default = {
|
|
7
|
+
spinner,
|
|
8
|
+
spin,
|
|
9
|
+
sm,
|
|
10
|
+
lg
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { spinner_module_default as default, lg, sm, spin, spinner };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Switch as BaseSwitch } from "@base-ui/react/switch";
|
|
3
|
+
export interface SwitchProps extends Omit<React.ComponentPropsWithoutRef<typeof BaseSwitch.Root>, "className" | "render" | "children"> {
|
|
4
|
+
/** Visible label. Without one, pass `aria-label`. */
|
|
5
|
+
label?: React.ReactNode;
|
|
6
|
+
description?: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
/** On/off toggle for settings that apply immediately. Built on Base UI (`role="switch"`). */
|
|
10
|
+
export declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import choice_module_default from "./choice.module.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Switch } from "@base-ui/react/switch";
|
|
8
|
+
//#region src/components/ui/switch.tsx
|
|
9
|
+
/** On/off toggle for settings that apply immediately. Built on Base UI (`role="switch"`). */
|
|
10
|
+
var Switch$1 = React.forwardRef(function Switch$2({ label, description, className, disabled, ...props }, ref) {
|
|
11
|
+
const control = /* @__PURE__ */ jsx(Switch.Root, {
|
|
12
|
+
ref,
|
|
13
|
+
disabled,
|
|
14
|
+
className: cn(choice_module_default.switch, !label && className),
|
|
15
|
+
...props,
|
|
16
|
+
children: /* @__PURE__ */ jsx(Switch.Thumb, { className: choice_module_default.thumb })
|
|
17
|
+
});
|
|
18
|
+
if (!label) return control;
|
|
19
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
20
|
+
className: cn(choice_module_default.choice, className),
|
|
21
|
+
"data-disabled": disabled ? "" : void 0,
|
|
22
|
+
children: [control, /* @__PURE__ */ jsxs("span", {
|
|
23
|
+
className: choice_module_default.text,
|
|
24
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
25
|
+
className: choice_module_default.label,
|
|
26
|
+
children: label
|
|
27
|
+
}), description && /* @__PURE__ */ jsx("span", {
|
|
28
|
+
className: choice_module_default.description,
|
|
29
|
+
children: description
|
|
30
|
+
})]
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//#endregion
|
|
35
|
+
export { Switch$1 as Switch };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type SortDirection = "asc" | "desc";
|
|
3
|
+
export interface SortState {
|
|
4
|
+
columnId: string;
|
|
5
|
+
direction: SortDirection;
|
|
6
|
+
}
|
|
7
|
+
export interface TableColumn<T> {
|
|
8
|
+
id: string;
|
|
9
|
+
header: React.ReactNode;
|
|
10
|
+
/** Cell renderer. Defaults to `String(row[id])` when the row has that key. */
|
|
11
|
+
cell?: (row: T) => React.ReactNode;
|
|
12
|
+
align?: "start" | "end" | "center";
|
|
13
|
+
/** CSS width, e.g. "160px" or "20%". */
|
|
14
|
+
width?: string;
|
|
15
|
+
sortable?: boolean;
|
|
16
|
+
/** Hide below 768px. Keep the identifying column visible. */
|
|
17
|
+
hideOnMobile?: boolean;
|
|
18
|
+
/** Use tabular numerals (amounts, counts, dates). */
|
|
19
|
+
numeric?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface TableProps<T> {
|
|
22
|
+
/** Accessible table name. Rendered as a visually hidden caption unless `showCaption`. */
|
|
23
|
+
caption: string;
|
|
24
|
+
showCaption?: boolean;
|
|
25
|
+
columns: TableColumn<T>[];
|
|
26
|
+
rows: T[];
|
|
27
|
+
getRowId: (row: T) => string;
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
/** Number of skeleton rows while loading. */
|
|
30
|
+
loadingRows?: number;
|
|
31
|
+
/** Rendered in place of rows when `rows` is empty and not loading. */
|
|
32
|
+
empty?: React.ReactNode;
|
|
33
|
+
/** Enables a checkbox column. Controlled. */
|
|
34
|
+
selectedIds?: ReadonlySet<string>;
|
|
35
|
+
onSelectionChange?: (ids: Set<string>) => void;
|
|
36
|
+
/** Label for a row's checkbox, e.g. (row) => `Select ${row.name}`. */
|
|
37
|
+
getRowLabel?: (row: T) => string;
|
|
38
|
+
sort?: SortState | null;
|
|
39
|
+
onSortChange?: (sort: SortState | null) => void;
|
|
40
|
+
/** Makes rows clickable (mouse) — always also provide a link or button in the row for keyboard users. */
|
|
41
|
+
onRowClick?: (row: T) => void;
|
|
42
|
+
density?: "default" | "compact";
|
|
43
|
+
stickyHeader?: boolean;
|
|
44
|
+
/** Wrap the table in its own bordered surface, as production list pages do. Default `true`; pass `false` inside a Card. */
|
|
45
|
+
bordered?: boolean;
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Generic data table: configurable columns, loading skeletons, empty state, row selection and
|
|
50
|
+
* sortable headers. Sorting and pagination are controlled — the table never reorders data itself.
|
|
51
|
+
*/
|
|
52
|
+
export declare function Table<T>({ caption, showCaption, columns, rows, getRowId, loading, loadingRows, empty, selectedIds, onSelectionChange, getRowLabel, sort, onSortChange, onRowClick, density, stickyHeader, bordered, className, }: TableProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { Checkbox } from "./checkbox.js";
|
|
5
|
+
import { Skeleton } from "./skeleton.js";
|
|
6
|
+
import table_module_default from "./table.module.js";
|
|
7
|
+
import "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { ArrowDown, ArrowUp, ChevronsUpDown } from "lucide-react";
|
|
10
|
+
//#region src/components/ui/table.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Generic data table: configurable columns, loading skeletons, empty state, row selection and
|
|
13
|
+
* sortable headers. Sorting and pagination are controlled — the table never reorders data itself.
|
|
14
|
+
*/
|
|
15
|
+
function Table({ caption, showCaption = false, columns, rows, getRowId, loading = false, loadingRows = 5, empty, selectedIds, onSelectionChange, getRowLabel, sort, onSortChange, onRowClick, density = "default", stickyHeader = false, bordered = true, className }) {
|
|
16
|
+
const selectable = Boolean(selectedIds && onSelectionChange);
|
|
17
|
+
const rowIds = rows.map(getRowId);
|
|
18
|
+
const selectedCount = selectable ? rowIds.filter((id) => selectedIds.has(id)).length : 0;
|
|
19
|
+
const allSelected = rows.length > 0 && selectedCount === rows.length;
|
|
20
|
+
const someSelected = selectedCount > 0 && !allSelected;
|
|
21
|
+
const colCount = columns.length + (selectable ? 1 : 0);
|
|
22
|
+
const toggleAll = () => {
|
|
23
|
+
if (!onSelectionChange || !selectedIds) return;
|
|
24
|
+
const next = new Set(selectedIds);
|
|
25
|
+
if (allSelected) rowIds.forEach((id) => next.delete(id));
|
|
26
|
+
else rowIds.forEach((id) => next.add(id));
|
|
27
|
+
onSelectionChange(next);
|
|
28
|
+
};
|
|
29
|
+
const toggleRow = (id) => {
|
|
30
|
+
if (!onSelectionChange || !selectedIds) return;
|
|
31
|
+
const next = new Set(selectedIds);
|
|
32
|
+
if (next.has(id)) next.delete(id);
|
|
33
|
+
else next.add(id);
|
|
34
|
+
onSelectionChange(next);
|
|
35
|
+
};
|
|
36
|
+
const cycleSort = (columnId) => {
|
|
37
|
+
if (!onSortChange) return;
|
|
38
|
+
if (!sort || sort.columnId !== columnId) onSortChange({
|
|
39
|
+
columnId,
|
|
40
|
+
direction: "asc"
|
|
41
|
+
});
|
|
42
|
+
else if (sort.direction === "asc") onSortChange({
|
|
43
|
+
columnId,
|
|
44
|
+
direction: "desc"
|
|
45
|
+
});
|
|
46
|
+
else onSortChange(null);
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ jsx("div", {
|
|
49
|
+
className: cn(table_module_default.scroller, bordered && table_module_default.bordered, className),
|
|
50
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
51
|
+
className: cn(table_module_default.table, density === "compact" && table_module_default.compact, stickyHeader && table_module_default.sticky),
|
|
52
|
+
"aria-busy": loading || void 0,
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx("caption", {
|
|
55
|
+
className: showCaption ? table_module_default.caption : table_module_default.srOnly,
|
|
56
|
+
children: caption
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [selectable && /* @__PURE__ */ jsx("th", {
|
|
59
|
+
scope: "col",
|
|
60
|
+
className: table_module_default.selectCell,
|
|
61
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
62
|
+
"aria-label": "Select all rows",
|
|
63
|
+
checked: allSelected,
|
|
64
|
+
indeterminate: someSelected,
|
|
65
|
+
disabled: loading || rows.length === 0,
|
|
66
|
+
onCheckedChange: toggleAll
|
|
67
|
+
})
|
|
68
|
+
}), columns.map((column) => {
|
|
69
|
+
const active = sort?.columnId === column.id;
|
|
70
|
+
const ariaSort = active ? sort.direction === "asc" ? "ascending" : "descending" : column.sortable ? "none" : void 0;
|
|
71
|
+
return /* @__PURE__ */ jsx("th", {
|
|
72
|
+
scope: "col",
|
|
73
|
+
"aria-sort": ariaSort,
|
|
74
|
+
style: { width: column.width },
|
|
75
|
+
className: cn(table_module_default[`align-${column.align ?? "start"}`], column.hideOnMobile && table_module_default.hideOnMobile),
|
|
76
|
+
children: column.sortable && onSortChange ? /* @__PURE__ */ jsxs("button", {
|
|
77
|
+
type: "button",
|
|
78
|
+
className: table_module_default.sortButton,
|
|
79
|
+
onClick: () => cycleSort(column.id),
|
|
80
|
+
children: [column.header, /* @__PURE__ */ jsx("span", {
|
|
81
|
+
className: cn(table_module_default.sortIcon, active && table_module_default.sortIconActive),
|
|
82
|
+
"aria-hidden": "true",
|
|
83
|
+
children: active ? sort.direction === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { strokeWidth: 1.6 }) : /* @__PURE__ */ jsx(ArrowDown, { strokeWidth: 1.6 }) : /* @__PURE__ */ jsx(ChevronsUpDown, { strokeWidth: 1.6 })
|
|
84
|
+
})]
|
|
85
|
+
}) : column.header
|
|
86
|
+
}, column.id);
|
|
87
|
+
})] }) }),
|
|
88
|
+
/* @__PURE__ */ jsxs("tbody", { children: [
|
|
89
|
+
loading && Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ jsxs("tr", {
|
|
90
|
+
className: table_module_default.skeletonRow,
|
|
91
|
+
children: [selectable && /* @__PURE__ */ jsx("td", {
|
|
92
|
+
className: table_module_default.selectCell,
|
|
93
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
94
|
+
width: 16,
|
|
95
|
+
height: 16
|
|
96
|
+
})
|
|
97
|
+
}), columns.map((column) => /* @__PURE__ */ jsx("td", {
|
|
98
|
+
className: column.hideOnMobile ? table_module_default.hideOnMobile : void 0,
|
|
99
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
100
|
+
shape: "text",
|
|
101
|
+
width: `${50 + (i * 17 + column.id.length * 7) % 40}%`
|
|
102
|
+
})
|
|
103
|
+
}, column.id))]
|
|
104
|
+
}, `skeleton-${i}`)),
|
|
105
|
+
!loading && rows.length === 0 && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
|
|
106
|
+
colSpan: colCount,
|
|
107
|
+
className: table_module_default.emptyCell,
|
|
108
|
+
children: empty ?? /* @__PURE__ */ jsx("span", {
|
|
109
|
+
className: table_module_default.emptyText,
|
|
110
|
+
children: "No results"
|
|
111
|
+
})
|
|
112
|
+
}) }),
|
|
113
|
+
!loading && rows.map((row) => {
|
|
114
|
+
const id = getRowId(row);
|
|
115
|
+
const selected = selectable && selectedIds.has(id);
|
|
116
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
117
|
+
"data-selected": selected ? "" : void 0,
|
|
118
|
+
"aria-selected": selectable ? selected : void 0,
|
|
119
|
+
className: cn(onRowClick && table_module_default.clickable),
|
|
120
|
+
onClick: onRowClick ? (event) => {
|
|
121
|
+
if (event.target.closest("a,button,input,[role=checkbox],[role=menuitem]")) return;
|
|
122
|
+
onRowClick(row);
|
|
123
|
+
} : void 0,
|
|
124
|
+
children: [selectable && /* @__PURE__ */ jsx("td", {
|
|
125
|
+
className: table_module_default.selectCell,
|
|
126
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
127
|
+
"aria-label": getRowLabel ? getRowLabel(row) : `Select row ${id}`,
|
|
128
|
+
checked: selected,
|
|
129
|
+
onCheckedChange: () => toggleRow(id)
|
|
130
|
+
})
|
|
131
|
+
}), columns.map((column) => /* @__PURE__ */ jsx("td", {
|
|
132
|
+
className: cn(table_module_default[`align-${column.align ?? "start"}`], column.numeric && table_module_default.numeric, column.hideOnMobile && table_module_default.hideOnMobile),
|
|
133
|
+
children: column.cell ? column.cell(row) : String(row[column.id] ?? "")
|
|
134
|
+
}, column.id))]
|
|
135
|
+
}, id);
|
|
136
|
+
})
|
|
137
|
+
] })
|
|
138
|
+
]
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { Table };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/components/ui/table.module.css
|
|
2
|
+
var scroller = "hg-table-module_scroller_XzvYr";
|
|
3
|
+
var bordered = "hg-table-module_bordered_pH0dc";
|
|
4
|
+
var table = "hg-table-module_table_jSpSA";
|
|
5
|
+
var compact = "hg-table-module_compact_c867I";
|
|
6
|
+
var sticky = "hg-table-module_sticky_gIqmw";
|
|
7
|
+
var skeletonRow = "hg-table-module_skeletonRow_z0LTg";
|
|
8
|
+
var clickable = "hg-table-module_clickable_46-S2";
|
|
9
|
+
var numeric = "hg-table-module_numeric_EEaT1";
|
|
10
|
+
var selectCell = "hg-table-module_selectCell_rmWwT";
|
|
11
|
+
var sortButton = "hg-table-module_sortButton_fzfWB";
|
|
12
|
+
var sortIcon = "hg-table-module_sortIcon_D2T-j";
|
|
13
|
+
var sortIconActive = "hg-table-module_sortIconActive_7--vT";
|
|
14
|
+
var emptyCell = "hg-table-module_emptyCell_DVD9X";
|
|
15
|
+
var emptyText = "hg-table-module_emptyText_2x9nh";
|
|
16
|
+
var caption = "hg-table-module_caption_KTNye";
|
|
17
|
+
var srOnly = "hg-table-module_srOnly_tRNri";
|
|
18
|
+
var hideOnMobile = "hg-table-module_hideOnMobile_ykrgY";
|
|
19
|
+
var table_module_default = {
|
|
20
|
+
scroller,
|
|
21
|
+
bordered,
|
|
22
|
+
table,
|
|
23
|
+
compact,
|
|
24
|
+
sticky,
|
|
25
|
+
skeletonRow,
|
|
26
|
+
clickable,
|
|
27
|
+
"align-start": "hg-table-module_align-start_o-rBV",
|
|
28
|
+
"align-end": "hg-table-module_align-end_RcTKy",
|
|
29
|
+
"align-center": "hg-table-module_align-center_Z5nZD",
|
|
30
|
+
numeric,
|
|
31
|
+
selectCell,
|
|
32
|
+
sortButton,
|
|
33
|
+
sortIcon,
|
|
34
|
+
sortIconActive,
|
|
35
|
+
emptyCell,
|
|
36
|
+
emptyText,
|
|
37
|
+
caption,
|
|
38
|
+
srOnly,
|
|
39
|
+
hideOnMobile
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { bordered, caption, clickable, compact, table_module_default as default, emptyCell, emptyText, hideOnMobile, numeric, scroller, selectCell, skeletonRow, sortButton, sortIcon, sortIconActive, srOnly, sticky, table };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Tabs as BaseTabs } from "@base-ui/react/tabs";
|
|
3
|
+
export interface TabsProps extends Omit<React.ComponentPropsWithoutRef<typeof BaseTabs.Root>, "className" | "onValueChange"> {
|
|
4
|
+
onValueChange?: (value: string) => void;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Root of a tab set. Accepts `value` / `defaultValue` / `onValueChange`. */
|
|
8
|
+
export declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export interface TabsListProps extends Omit<React.ComponentPropsWithoutRef<typeof BaseTabs.List>, "className"> {
|
|
10
|
+
/** `pill` (default) matches production record tabs and inbox filters. `underline` is a proposed extension for page-level sections. */
|
|
11
|
+
variant?: "pill" | "underline";
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The row of tabs. Arrow keys move between tabs; Home/End jump to the ends. */
|
|
15
|
+
export declare const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
|
|
16
|
+
export interface TabProps extends Omit<React.ComponentPropsWithoutRef<typeof BaseTabs.Tab>, "className"> {
|
|
17
|
+
/** Optional count shown after the label (e.g. unread items). */
|
|
18
|
+
count?: number;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const Tab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLButtonElement>>;
|
|
22
|
+
export interface TabsPanelProps extends Omit<React.ComponentPropsWithoutRef<typeof BaseTabs.Panel>, "className"> {
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const TabsPanel: React.ForwardRefExoticComponent<TabsPanelProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import tabs_module_default from "./tabs.module.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Tabs } from "@base-ui/react/tabs";
|
|
8
|
+
//#region src/components/ui/tabs.tsx
|
|
9
|
+
/** Root of a tab set. Accepts `value` / `defaultValue` / `onValueChange`. */
|
|
10
|
+
var Tabs$1 = React.forwardRef(function Tabs$2({ className, onValueChange, ...props }, ref) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Tabs.Root, {
|
|
12
|
+
ref,
|
|
13
|
+
className: cn(tabs_module_default.root, className),
|
|
14
|
+
onValueChange: (value) => onValueChange?.(String(value)),
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
/** The row of tabs. Arrow keys move between tabs; Home/End jump to the ends. */
|
|
19
|
+
var TabsList = React.forwardRef(function TabsList({ variant = "pill", className, children, ...props }, ref) {
|
|
20
|
+
return /* @__PURE__ */ jsxs(Tabs.List, {
|
|
21
|
+
ref,
|
|
22
|
+
"data-variant": variant,
|
|
23
|
+
className: cn(tabs_module_default.list, tabs_module_default[variant], className),
|
|
24
|
+
...props,
|
|
25
|
+
children: [children, variant === "underline" && /* @__PURE__ */ jsx(Tabs.Indicator, { className: tabs_module_default.indicator })]
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var Tab = React.forwardRef(function Tab({ count, className, children, ...props }, ref) {
|
|
29
|
+
return /* @__PURE__ */ jsxs(Tabs.Tab, {
|
|
30
|
+
ref,
|
|
31
|
+
className: cn(tabs_module_default.tab, className),
|
|
32
|
+
...props,
|
|
33
|
+
children: [children, count !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
34
|
+
className: tabs_module_default.count,
|
|
35
|
+
children: count
|
|
36
|
+
})]
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var TabsPanel = React.forwardRef(function TabsPanel({ className, ...props }, ref) {
|
|
40
|
+
return /* @__PURE__ */ jsx(Tabs.Panel, {
|
|
41
|
+
ref,
|
|
42
|
+
className: cn(tabs_module_default.panel, className),
|
|
43
|
+
...props
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { Tab, Tabs$1 as Tabs, TabsList, TabsPanel };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/components/ui/tabs.module.css
|
|
2
|
+
var root = "hg-tabs-module_root_teHYJ";
|
|
3
|
+
var list = "hg-tabs-module_list_B7nug";
|
|
4
|
+
var underline = "hg-tabs-module_underline_sJKKp";
|
|
5
|
+
var pill = "hg-tabs-module_pill_iBRDF";
|
|
6
|
+
var tab = "hg-tabs-module_tab_VjOwv";
|
|
7
|
+
var count = "hg-tabs-module_count_sAzpc";
|
|
8
|
+
var indicator = "hg-tabs-module_indicator_xYb-j";
|
|
9
|
+
var panel = "hg-tabs-module_panel_StQX1";
|
|
10
|
+
var tabs_module_default = {
|
|
11
|
+
root,
|
|
12
|
+
list,
|
|
13
|
+
underline,
|
|
14
|
+
pill,
|
|
15
|
+
tab,
|
|
16
|
+
count,
|
|
17
|
+
indicator,
|
|
18
|
+
panel
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { count, tabs_module_default as default, indicator, list, panel, pill, root, tab, underline };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
3
|
+
invalid?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/** Multi-line text input. Resizes vertically. Inherits wiring from a surrounding `Field`. */
|
|
6
|
+
export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { useFieldControlProps } from "./field.js";
|
|
5
|
+
import input_module_default from "./input.module.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/ui/textarea.tsx
|
|
9
|
+
/** Multi-line text input. Resizes vertically. Inherits wiring from a surrounding `Field`. */
|
|
10
|
+
var Textarea = React.forwardRef(function Textarea({ invalid, className, rows = 4, ...props }, ref) {
|
|
11
|
+
const fieldProps = useFieldControlProps({
|
|
12
|
+
...props,
|
|
13
|
+
"aria-invalid": invalid || props["aria-invalid"] || void 0
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
16
|
+
ref,
|
|
17
|
+
rows,
|
|
18
|
+
className: cn(input_module_default.control, input_module_default.textarea, className),
|
|
19
|
+
...fieldProps
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
//#endregion
|
|
23
|
+
export { Textarea };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type ToastTone = "neutral" | "success" | "warning" | "danger" | "info";
|
|
3
|
+
export interface ToastOptions {
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
description?: React.ReactNode;
|
|
6
|
+
tone?: ToastTone;
|
|
7
|
+
/** Auto-dismiss delay in ms. Default 5000. Use 0 to keep it until dismissed. */
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/** Optional single action, e.g. Undo. */
|
|
10
|
+
action?: {
|
|
11
|
+
label: string;
|
|
12
|
+
onClick: () => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns `toast(options)` and `dismiss(id?)`. Must be used inside `ToastProvider`.
|
|
17
|
+
* Danger toasts are announced assertively; others politely.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useToast(): {
|
|
20
|
+
toast: ({ title, description, tone, timeout, action }: ToastOptions) => string;
|
|
21
|
+
dismiss: (toastId?: string) => void;
|
|
22
|
+
};
|
|
23
|
+
export interface ToastProviderProps {
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
/** Maximum visible toasts. Default 3. */
|
|
26
|
+
limit?: number;
|
|
27
|
+
closeLabel?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Mount once near the app root. Renders the toast viewport (bottom-right; bottom-centre on mobile). */
|
|
30
|
+
export declare function ToastProvider({ children, limit, closeLabel }: ToastProviderProps): React.JSX.Element;
|