@stll/ui 0.74.0 → 0.76.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 (99) hide show
  1. package/dist/components/button-classes.d.ts +45 -0
  2. package/dist/components/button-classes.js +49 -0
  3. package/dist/components/button.d.ts +1 -3
  4. package/dist/components/button.js +8 -43
  5. package/dist/components/checkbox.js +1 -1
  6. package/dist/components/composer-tokens.d.ts +9 -1
  7. package/dist/components/composer-tokens.js +9 -1
  8. package/dist/components/composer.d.ts +2 -2
  9. package/dist/components/composer.js +4 -4
  10. package/dist/components/control-face.d.ts +132 -0
  11. package/dist/components/control-face.js +168 -0
  12. package/dist/components/court-badge.d.ts +4 -2
  13. package/dist/components/court-badge.js +5 -3
  14. package/dist/components/document-mark.shared.d.ts +149 -0
  15. package/dist/components/document-mark.shared.js +62 -0
  16. package/dist/components/frame.d.ts +5 -1
  17. package/dist/components/frame.js +2 -2
  18. package/dist/components/input-otp-face.d.ts +4 -0
  19. package/dist/components/input-otp-face.js +15 -0
  20. package/dist/components/input-otp.d.ts +1 -1
  21. package/dist/components/input-otp.js +3 -8
  22. package/dist/components/input.native.js +2 -7
  23. package/dist/components/label-classes.d.ts +20 -0
  24. package/dist/components/label-classes.js +21 -0
  25. package/dist/components/label.d.ts +2 -20
  26. package/dist/components/label.js +2 -19
  27. package/dist/components/landing-shell.d.ts +64 -0
  28. package/dist/components/landing-shell.js +189 -0
  29. package/dist/components/landing.d.ts +2 -39
  30. package/dist/components/landing.js +2 -66
  31. package/dist/components/list-shell.d.ts +39 -0
  32. package/dist/components/list-shell.js +99 -0
  33. package/dist/components/list.d.ts +3 -17
  34. package/dist/components/list.js +2 -42
  35. package/dist/components/segmented-icon-toggle.d.ts +4 -1
  36. package/dist/components/segmented-icon-toggle.js +5 -4
  37. package/dist/components/select-classes.d.ts +10 -0
  38. package/dist/components/select-classes.js +13 -0
  39. package/dist/components/select.js +3 -7
  40. package/dist/components/separator.native.js +2 -1
  41. package/dist/components/sheet.native.js +4 -3
  42. package/dist/components/skeleton.d.ts +3 -1
  43. package/dist/components/skeleton.js +9 -2
  44. package/dist/components/split-button.d.ts +2 -1
  45. package/dist/components/split-button.js +6 -14
  46. package/dist/components/switch.d.ts +1 -5
  47. package/dist/components/switch.js +2 -5
  48. package/dist/components/table-cell.d.ts +35 -0
  49. package/dist/components/table-cell.js +26 -0
  50. package/dist/components/table-chart.js +28 -18
  51. package/dist/components/table-shell.d.ts +126 -0
  52. package/dist/components/table-shell.js +136 -0
  53. package/dist/components/table.d.ts +4 -88
  54. package/dist/components/table.js +21 -70
  55. package/dist/components/tabs-classes.d.ts +8 -0
  56. package/dist/components/tabs-classes.js +10 -0
  57. package/dist/components/tabs.js +4 -3
  58. package/dist/components/toggle-classes.d.ts +13 -0
  59. package/dist/components/toggle-classes.js +10 -0
  60. package/dist/components/toggle-group-classes.d.ts +12 -0
  61. package/dist/components/toggle-group-classes.js +13 -0
  62. package/dist/components/toggle-group.js +3 -2
  63. package/dist/components/tooltip.d.ts +6 -1
  64. package/dist/components/tooltip.js +2 -1
  65. package/dist/components/truncated-text-face.d.ts +33 -0
  66. package/dist/components/truncated-text-face.js +30 -0
  67. package/dist/components/truncated-text.d.ts +1 -6
  68. package/dist/components/truncated-text.js +1 -15
  69. package/dist/components/view-toolbar-classes.d.ts +13 -0
  70. package/dist/components/view-toolbar-classes.js +15 -0
  71. package/dist/components/view-toolbar-shell.d.ts +24 -0
  72. package/dist/components/view-toolbar-shell.js +43 -0
  73. package/dist/components/view-toolbar.d.ts +2 -15
  74. package/dist/components/view-toolbar.js +8 -26
  75. package/dist/components/workspace-shell.d.ts +7 -1
  76. package/dist/components/workspace-shell.js +21 -3
  77. package/dist/data-table/table.js +2 -1
  78. package/dist/icons.d.ts +2 -2
  79. package/dist/icons.js +2 -2
  80. package/dist/index.d.ts +15 -9
  81. package/dist/index.js +11 -8
  82. package/dist/inspector/pane-width.d.ts +1 -1
  83. package/dist/inspector/pane-width.js +2 -2
  84. package/dist/inspector/use-pane-width.d.ts +7 -9
  85. package/dist/inspector/use-pane-width.js +42 -27
  86. package/dist/kanban/card-shell.js +1 -1
  87. package/dist/kanban/column-bands.d.ts +0 -8
  88. package/dist/kanban/column-bands.js +1 -18
  89. package/dist/kanban/column-header-shell.d.ts +39 -0
  90. package/dist/kanban/column-header-shell.js +48 -0
  91. package/dist/kanban/column-header.js +9 -12
  92. package/dist/kanban/index.d.ts +2 -2
  93. package/dist/kanban/index.js +3 -3
  94. package/dist/kanban/layout-tokens.d.ts +18 -1
  95. package/dist/kanban/layout-tokens.js +18 -1
  96. package/dist/kanban/sticky-lane.d.ts +2 -7
  97. package/dist/kanban/sticky-lane.js +1 -6
  98. package/dist/kanban/subgroup-board.js +2 -2
  99. package/package.json +52 -4
@@ -5,6 +5,7 @@ import { CONTROL_SIZE } from "../lib/control-size.js";
5
5
  import { FIELD_TRIGGER_CLASS_NAME } from "../lib/field-trigger.js";
6
6
  import { OVERLAY_LAYER_CLASS_NAMES } from "../lib/overlay-layer.js";
7
7
  import { cn } from "../lib/utils.js";
8
+ import { SELECT_TRIGGER_ICON_CLASS_NAME, SELECT_TRIGGER_SIZE_CLASS_NAMES, SELECT_VALUE_CLASS_NAME } from "./select-classes.js";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
10
  import * as React from "react";
10
11
  import { Select as Select$1 } from "@base-ui/react/select";
@@ -37,18 +38,13 @@ const SelectTrigger = ({ className, align = "center", size = CONTROL_SIZE.defaul
37
38
  ...props,
38
39
  children: [children, /* @__PURE__ */ jsx(Select$1.Icon, {
39
40
  "data-slot": "select-icon",
40
- children: /* @__PURE__ */ jsx(ChevronsUpDownIcon, { className: "-me-1 size-4.5 opacity-80 sm:size-4" })
41
+ children: /* @__PURE__ */ jsx(ChevronsUpDownIcon, { className: SELECT_TRIGGER_ICON_CLASS_NAME })
41
42
  })]
42
43
  });
43
- const SELECT_TRIGGER_SIZE_CLASS_NAMES = {
44
- [CONTROL_SIZE.sm]: "min-h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] text-sm sm:min-h-7 sm:text-xs",
45
- [CONTROL_SIZE.default]: void 0,
46
- [CONTROL_SIZE.lg]: "min-h-10 sm:min-h-9"
47
- };
48
44
  const SelectValue = ({ className, children, placeholder, ...props }) => {
49
45
  const displays = React.use(SelectItemDisplaysContext);
50
46
  if (children !== void 0 || displays.size === 0) return /* @__PURE__ */ jsx(Select$1.Value, {
51
- className: cn("data-placeholder:text-muted-foreground flex-1 truncate", className),
47
+ className: cn(SELECT_VALUE_CLASS_NAME, className),
52
48
  "data-slot": "select-value",
53
49
  placeholder,
54
50
  ...props,
@@ -1,3 +1,4 @@
1
+ import { cn } from "../lib/utils.js";
1
2
  import { jsx } from "react/jsx-runtime";
2
3
  import { View } from "react-native";
3
4
  // src/components/separator.native.tsx
@@ -9,7 +10,7 @@ import { View } from "react-native";
9
10
  const Separator = ({ className, orientation = "horizontal", ...props }) => /* @__PURE__ */ jsx(View, {
10
11
  ...props,
11
12
  accessibilityElementsHidden: true,
12
- className: `bg-border ${orientation === "vertical" ? "w-px self-stretch" : "h-px w-full"} ${className ?? ""}`,
13
+ className: cn("bg-border", orientation === "vertical" ? "w-px self-stretch" : "h-px w-full", className),
13
14
  importantForAccessibility: "no-hide-descendants"
14
15
  });
15
16
  export { Separator };
@@ -1,3 +1,4 @@
1
+ import { cn } from "../lib/utils.js";
1
2
  import { Button } from "./button.native.js";
2
3
  import { Text as Text$1 } from "./text.native.js";
3
4
  import { jsx } from "react/jsx-runtime";
@@ -29,12 +30,12 @@ const Sheet = ({ children, onOpenChange, open = false }) => {
29
30
  /** The sheet's surface: the background, inset, and room for the keyboard. */
30
31
  const SheetPopup = ({ className, ...props }) => /* @__PURE__ */ jsx(KeyboardAvoidingView, {
31
32
  behavior: Platform.OS === "ios" ? "padding" : void 0,
32
- className: `bg-background flex-1 gap-4 px-5 pt-5 ${className ?? ""}`,
33
+ className: cn("bg-background flex-1 gap-4 px-5 pt-5", className),
33
34
  ...props
34
35
  });
35
36
  /** The title row: the title leading, a close or done action trailing. */
36
37
  const SheetHeader = ({ className, ...props }) => /* @__PURE__ */ jsx(View, {
37
- className: `flex-row items-center justify-between gap-4 ${className ?? ""}`,
38
+ className: cn("flex-row items-center justify-between gap-4", className),
38
39
  ...props
39
40
  });
40
41
  const SheetTitle = (props) => /* @__PURE__ */ jsx(Text$1, {
@@ -48,7 +49,7 @@ const SheetDescription = (props) => /* @__PURE__ */ jsx(Text$1, {
48
49
  });
49
50
  /** The sheet's body, scrolling when it outgrows the sheet. */
50
51
  const SheetPanel = ({ contentContainerClassName, ...props }) => /* @__PURE__ */ jsx(ScrollView, {
51
- contentContainerClassName: `gap-4 ${contentContainerClassName ?? ""}`,
52
+ contentContainerClassName: cn("gap-4", contentContainerClassName),
52
53
  keyboardShouldPersistTaps: "handled",
53
54
  ...props
54
55
  });
@@ -1,2 +1,4 @@
1
1
  declare const Skeleton: ({ className, ...props }: React.ComponentProps<"div">) => import("react").JSX.Element;
2
- export { Skeleton };
2
+ /** Phrasing content for a skeleton inside a paragraph or an inline control. */
3
+ declare const InlineSkeleton: ({ className, ...props }: React.ComponentProps<"span">) => import("react").JSX.Element;
4
+ export { InlineSkeleton, Skeleton };
@@ -1,9 +1,16 @@
1
1
  import { cn } from "../lib/utils.js";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  // src/components/skeleton.tsx
4
+ const SKELETON_CLASS_NAME = "animate-skeleton rounded-sm [--skeleton-highlight:--alpha(var(--color-white)/64%)] [background:linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)_var(--color-muted)_0_0/200%_100%_fixed] dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]";
4
5
  const Skeleton = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
5
- className: cn("animate-skeleton rounded-sm [--skeleton-highlight:--alpha(var(--color-white)/64%)] [background:linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)_var(--color-muted)_0_0/200%_100%_fixed] dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]", className),
6
+ className: cn(SKELETON_CLASS_NAME, className),
6
7
  "data-slot": "skeleton",
7
8
  ...props
8
9
  });
9
- export { Skeleton };
10
+ /** Phrasing content for a skeleton inside a paragraph or an inline control. */
11
+ const InlineSkeleton = ({ className, ...props }) => /* @__PURE__ */ jsx("span", {
12
+ className: cn(SKELETON_CLASS_NAME, className),
13
+ "data-slot": "skeleton",
14
+ ...props
15
+ });
16
+ export { InlineSkeleton, Skeleton };
@@ -2,6 +2,7 @@ import { BUTTON_CONTENT, Button } from "./button.js";
2
2
  import { ComponentProps, ReactNode } from "react";
3
3
  import { DropdownMenu as Menu } from "./menu.js";
4
4
  import { Popover } from "./popover.js";
5
+ import { SplitButtonSize } from "./control-face.js";
5
6
  type SplitButtonSharedProps = {
6
7
  menuLabel: string;
7
8
  primaryDescriptionId?: string;
@@ -10,7 +11,7 @@ type SplitButtonSharedProps = {
10
11
  menu: ReactNode;
11
12
  primaryDisabled?: boolean;
12
13
  menuDisabled?: boolean;
13
- size?: "sm" | "md";
14
+ size?: SplitButtonSize;
14
15
  className?: string;
15
16
  };
16
17
  type SplitButtonPrimary = {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import { ChevronDownIcon } from "../icons.js";
3
2
  import { cn } from "../lib/utils.js";
4
3
  import { BUTTON_CONTENT, Button } from "./button.js";
4
+ import { SPLIT_BUTTON_PRIMARY_CLASS, SPLIT_BUTTON_ROOT_CLASS, SPLIT_BUTTON_TRIGGER_CLASS, SplitButtonChevron } from "./control-face.js";
5
5
  import { DropdownMenu as Menu, DropdownMenuTrigger as MenuTrigger } from "./menu.js";
6
6
  import { Popover, PopoverTrigger } from "./popover.js";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -15,19 +15,19 @@ import { jsx, jsxs } from "react/jsx-runtime";
15
15
  const SplitButton = (props) => {
16
16
  const { primaryLabel, menuLabel, primaryDescriptionId, menuDescriptionId, onPrimaryClick, children, menu, primaryDisabled, menuDisabled, size = "md", className } = props;
17
17
  const triggerButton = /* @__PURE__ */ jsx(Button, {
18
- className: cn("group-hover/split:bg-muted group-focus-within/split:bg-muted hover:bg-accent active:bg-accent/80 data-popup-open:bg-accent rounded-md [&_svg]:mx-0", size === "sm" ? "h-7 w-3.5 px-0 sm:h-7" : "h-8 w-4 px-0 sm:h-8", "pointer-coarse:min-h-11 pointer-coarse:min-w-11"),
18
+ className: SPLIT_BUTTON_TRIGGER_CLASS[size],
19
19
  size: "sm",
20
20
  tooltip: menuLabel,
21
21
  variant: "ghost"
22
22
  });
23
23
  const controls = /* @__PURE__ */ jsxs("div", {
24
- className: cn("group/split hover:border-border focus-within:border-border has-[[data-popup-open]]:border-border inline-flex shrink-0 items-center rounded-lg border border-transparent p-0.5", className),
24
+ className: cn(SPLIT_BUTTON_ROOT_CLASS, className),
25
25
  "data-size": size,
26
26
  "data-slot": "split-button",
27
27
  children: [/* @__PURE__ */ jsx(Button, {
28
28
  "aria-describedby": primaryDescriptionId,
29
29
  "aria-label": primaryLabel,
30
- className: cn("active:bg-accent/80 rounded-md [&_svg]:mx-0 [&_svg]:size-3.5 [&_svg:not([class*='size-'])]:size-3.5 sm:[&_svg:not([class*='size-'])]:size-3.5", size === "sm" ? "h-7 ps-1.5 pe-0.5 sm:h-7" : "h-8 ps-2 pe-0.5 sm:h-8", "pointer-coarse:min-h-11 pointer-coarse:min-w-11"),
30
+ className: SPLIT_BUTTON_PRIMARY_CLASS[size],
31
31
  disabled: primaryDisabled,
32
32
  onClick: onPrimaryClick,
33
33
  size: "sm",
@@ -39,21 +39,13 @@ const SplitButton = (props) => {
39
39
  "aria-label": menuLabel,
40
40
  disabled: menuDisabled,
41
41
  render: triggerButton,
42
- children: /* @__PURE__ */ jsx(ChevronDownIcon, {
43
- "aria-hidden": "true",
44
- className: "size-[0.65625rem]",
45
- strokeWidth: 1.5
46
- })
42
+ children: /* @__PURE__ */ jsx(SplitButtonChevron, {})
47
43
  }) : /* @__PURE__ */ jsx(MenuTrigger, {
48
44
  "aria-describedby": menuDescriptionId,
49
45
  "aria-label": menuLabel,
50
46
  disabled: menuDisabled,
51
47
  render: triggerButton,
52
- children: /* @__PURE__ */ jsx(ChevronDownIcon, {
53
- "aria-hidden": "true",
54
- className: "size-[0.65625rem]",
55
- strokeWidth: 1.5
56
- })
48
+ children: /* @__PURE__ */ jsx(SplitButtonChevron, {})
57
49
  })]
58
50
  });
59
51
  if (props.surface === "popover") return /* @__PURE__ */ jsxs(Popover, {
@@ -1,10 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Switch as Switch$1 } from "@base-ui/react/switch";
3
- /**
4
- * `default` is a setting's own control; `sm` sits in a dense row or a menu
5
- * beside small type.
6
- */
7
- type SwitchSize = "sm" | "default";
3
+ import { SwitchSize } from "./toggle-classes.js";
8
4
  type SwitchProps = Switch$1.Root.Props & {
9
5
  size?: SwitchSize | undefined;
10
6
  };
@@ -1,19 +1,16 @@
1
1
  "use client";
2
2
  import { cn } from "../lib/utils.js";
3
+ import { SWITCH_ROOT_CLASS_NAME, SWITCH_ROOT_SIZE_CLASS_NAME } from "./toggle-classes.js";
3
4
  import { jsx, jsxs } from "react/jsx-runtime";
4
5
  import { useId } from "react";
5
6
  import { Switch as Switch$1 } from "@base-ui/react/switch";
6
7
  // src/components/switch.tsx
7
- const SWITCH_ROOT_SIZE_CLASS_NAME = {
8
- default: "h-5 w-9",
9
- sm: "h-4 w-7"
10
- };
11
8
  const SWITCH_THUMB_SIZE_CLASS_NAME = {
12
9
  default: "size-4 ltr:data-checked:translate-x-4.5 ltr:data-unchecked:translate-x-0.5 rtl:data-checked:-translate-x-4.5 rtl:data-unchecked:-translate-x-0.5",
13
10
  sm: "size-3 ltr:data-checked:translate-x-3.5 ltr:data-unchecked:translate-x-0.5 rtl:data-checked:-translate-x-3.5 rtl:data-unchecked:-translate-x-0.5"
14
11
  };
15
12
  const Switch = ({ className, size = "default", ...props }) => /* @__PURE__ */ jsx(Switch$1.Root, {
16
- className: cn("focus-visible:ring-ring focus-visible:ring-offset-background data-checked:bg-primary data-unchecked:bg-input relative inline-flex shrink-0 items-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-offset-1 data-disabled:opacity-64", SWITCH_ROOT_SIZE_CLASS_NAME[size], className),
13
+ className: cn(SWITCH_ROOT_CLASS_NAME, SWITCH_ROOT_SIZE_CLASS_NAME[size], className),
17
14
  "data-size": size,
18
15
  "data-slot": "switch",
19
16
  ...props,
@@ -0,0 +1,35 @@
1
+ import * as React from "react";
2
+ /**
3
+ * Where a column sets its content. `end` lines up figures and amounts;
4
+ * `start` is the default reading edge. A `numeric` head or cell sets to the
5
+ * end unless it names an alignment, so a figures column needs one prop.
6
+ */
7
+ type TableAlign = "start" | "center" | "end";
8
+ /** A muted row or cell supports its neighbours. */
9
+ type TableTone = "default" | "muted";
10
+ declare const TABLE_ALIGN_CLASS: {
11
+ readonly center: "text-center";
12
+ readonly end: "text-end";
13
+ readonly start: "text-start";
14
+ };
15
+ declare const PROSE_CELL_CLASS = "in-data-[density=prose]:h-auto in-data-[density=prose]:border-e in-data-[density=prose]:border-b in-data-[density=prose]:px-3 in-data-[density=prose]:py-2 in-data-[density=prose]:align-top in-data-[density=prose]:leading-normal in-data-[density=prose]:last:border-e-0 in-data-[density=prose]:min-w-24 in-data-[density=prose]:first:min-w-36 in-data-[cell-text=wrap]:in-data-[density=prose]:wrap-anywhere in-data-[cell-text=wrap]:in-data-[density=prose]:whitespace-normal";
16
+ declare const resolveTableAlign: (align: TableAlign | undefined, numeric: boolean) => TableAlign | undefined;
17
+ type TableCellFaceProps = Omit<React.ComponentProps<"td">, "align"> & {
18
+ align?: TableAlign | undefined;
19
+ tone?: TableTone | undefined;
20
+ /**
21
+ * Figures set in tabular numerals and to the end of the cell (unless
22
+ * `align` says otherwise), so digits line up down the column.
23
+ */
24
+ numeric?: boolean | undefined;
25
+ /**
26
+ * The cell holds one control that fills it edge to edge and pads itself (a
27
+ * button that opens the row's record), so the cell adds no padding and the
28
+ * control's hover band reaches the cell's borders.
29
+ */
30
+ flush?: boolean;
31
+ };
32
+ type TableCellStyleProps = Pick<TableCellFaceProps, "align" | "className" | "flush" | "numeric" | "tone">;
33
+ declare const tableCellClassName: ({ align, className, flush, numeric, tone }: TableCellStyleProps) => string;
34
+ declare const TableCellFace: ({ align, className, flush, numeric, tone, ...props }: TableCellFaceProps) => React.JSX.Element;
35
+ export { PROSE_CELL_CLASS, TABLE_ALIGN_CLASS, type TableAlign, TableCellFace, type TableCellFaceProps, type TableTone, resolveTableAlign, tableCellClassName };
@@ -0,0 +1,26 @@
1
+ import { cn } from "../lib/utils.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ // src/components/table-cell.tsx
4
+ const TABLE_ALIGN_CLASS = {
5
+ center: "text-center",
6
+ end: "text-end",
7
+ start: "text-start"
8
+ };
9
+ const PROSE_CELL_CLASS = "in-data-[density=prose]:h-auto in-data-[density=prose]:border-e in-data-[density=prose]:border-b in-data-[density=prose]:px-3 in-data-[density=prose]:py-2 in-data-[density=prose]:align-top in-data-[density=prose]:leading-normal in-data-[density=prose]:last:border-e-0 in-data-[density=prose]:min-w-24 in-data-[density=prose]:first:min-w-36 in-data-[cell-text=wrap]:in-data-[density=prose]:wrap-anywhere in-data-[cell-text=wrap]:in-data-[density=prose]:whitespace-normal";
10
+ const resolveTableAlign = (align, numeric) => align ?? (numeric ? "end" : void 0);
11
+ const tableCellClassName = ({ align, className, flush = false, numeric = false, tone = "default" }) => {
12
+ const resolvedAlign = resolveTableAlign(align, numeric);
13
+ return cn("align-middle leading-none whitespace-nowrap has-[[role=checkbox]]:pe-0", flush ? "p-0" : "p-2.5 in-data-[density=compact]:px-0 in-data-[density=compact]:py-1.5 in-data-[inset=card]:px-4 in-data-[slot=frame]:first:p-[calc(--spacing(2.5)-1px)] in-data-[slot=frame]:last:p-[calc(--spacing(2.5)-1px)]", "in-data-[density=compact]:leading-6 in-data-[density=compact]:whitespace-normal", PROSE_CELL_CLASS, "in-data-[density=prose]:[tr:last-child>&]:border-b-0", resolvedAlign !== void 0 && TABLE_ALIGN_CLASS[resolvedAlign], tone === "muted" && "text-muted-foreground", numeric && "tabular-nums", className);
14
+ };
15
+ const TableCellFace = ({ align, className, flush = false, numeric, tone, ...props }) => /* @__PURE__ */ jsx("td", {
16
+ className: tableCellClassName({
17
+ align,
18
+ className,
19
+ flush,
20
+ numeric,
21
+ tone
22
+ }),
23
+ "data-slot": "table-cell",
24
+ ...props
25
+ });
26
+ export { PROSE_CELL_CLASS, TABLE_ALIGN_CLASS, TableCellFace, resolveTableAlign, tableCellClassName };
@@ -58,8 +58,11 @@ const CartesianPlot = ({ kind, points, formatNumber, xMode = "numeric" }) => {
58
58
  const keyedPoints = identifyPoints(points);
59
59
  const groups = Map.groupBy(keyedPoints, ({ point }) => point.series ?? "");
60
60
  const seriesNames = [...groups.keys()];
61
- const barStep = PLOT.width / points.length;
62
- const labelStep = Math.max(1, Math.ceil(points.length / 8));
61
+ const barGroups = [...Map.groupBy(keyedPoints, ({ point }) => point.x)];
62
+ const barSlot = PLOT.width / barGroups.length;
63
+ const barsPerGroup = Math.max(...barGroups.map(([, group]) => group.length));
64
+ const barWidth = barSlot * .7 / barsPerGroup;
65
+ const barLabelStep = Math.max(1, Math.ceil(barGroups.length / 8));
63
66
  const categories = [...new Map(points.map((point) => [point.x, point])).values()];
64
67
  const categoryStep = Math.max(1, Math.ceil(categories.length / 8));
65
68
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -96,22 +99,29 @@ const CartesianPlot = ({ kind, points, formatNumber, xMode = "numeric" }) => {
96
99
  y1: y(0),
97
100
  y2: y(0),
98
101
  stroke: "var(--muted-foreground)"
99
- }), keyedPoints.map(({ point, key }, index) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
100
- "data-slot": "chart-bar",
101
- x: PLOT.x + index * barStep + barStep * .15,
102
- y: Math.min(y(point.y), y(0)),
103
- width: barStep * .7,
104
- height: Math.abs(y(point.y) - y(0)),
105
- fill: color(seriesNames.indexOf(point.series ?? "")),
106
- children: /* @__PURE__ */ jsx("title", { children: `${point.label}: ${formatNumber(point.y)}${point.series ? ` (${point.series})` : ""}` })
107
- }), index % labelStep === 0 && /* @__PURE__ */ jsx("text", {
108
- x: PLOT.x + (index + .5) * barStep,
109
- y: PLOT.y + PLOT.height + 20,
110
- textAnchor: "middle",
111
- fill: "var(--muted-foreground)",
112
- style: { unicodeBidi: "plaintext" },
113
- children: point.label.length > 16 ? `${point.label.slice(0, 15)}…` : point.label
114
- })] }, key))] }) : /* @__PURE__ */ jsxs(Fragment, { children: [xMode === "category" ? categories.filter((_, index) => index % categoryStep === 0).map((point) => /* @__PURE__ */ jsx("text", {
102
+ }), barGroups.map(([position, group], groupIndex) => {
103
+ const first = group[0]?.point;
104
+ return /* @__PURE__ */ jsxs("g", {
105
+ "data-slot": "chart-bar-group",
106
+ children: [group.map(({ point, key }, barIndex) => /* @__PURE__ */ jsx("rect", {
107
+ "data-slot": "chart-bar",
108
+ x: PLOT.x + groupIndex * barSlot + barSlot * .15 + barIndex * barWidth,
109
+ y: Math.min(y(point.y), y(0)),
110
+ width: barWidth,
111
+ height: Math.abs(y(point.y) - y(0)),
112
+ fill: color(seriesNames.indexOf(point.series ?? "")),
113
+ children: /* @__PURE__ */ jsx("title", { children: `${point.label}: ${formatNumber(point.y)}${point.series ? ` (${point.series})` : ""}` })
114
+ }, key)), first !== void 0 && groupIndex % barLabelStep === 0 && /* @__PURE__ */ jsx("text", {
115
+ "data-slot": "chart-x-tick",
116
+ x: PLOT.x + (groupIndex + .5) * barSlot,
117
+ y: PLOT.y + PLOT.height + 20,
118
+ textAnchor: "middle",
119
+ fill: "var(--muted-foreground)",
120
+ style: { unicodeBidi: "plaintext" },
121
+ children: first.label.length > 16 ? `${first.label.slice(0, 15)}…` : first.label
122
+ })]
123
+ }, position);
124
+ })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [xMode === "category" ? categories.filter((_, index) => index % categoryStep === 0).map((point) => /* @__PURE__ */ jsx("text", {
115
125
  "data-slot": "chart-x-tick",
116
126
  x: x(point.x),
117
127
  y: PLOT.y + PLOT.height + 20,
@@ -0,0 +1,126 @@
1
+ import * as React from "react";
2
+ import { TableAlign, TableCellFace, TableTone } from "./table-cell.js";
3
+ /**
4
+ * How far cells pad their content from the column edges.
5
+ *
6
+ * `card` pads 16px, the inset of a card's header and body, so a table set
7
+ * directly inside a bordered card lines its columns up with the card's title.
8
+ */
9
+ type TableInset = "default" | "card";
10
+ /**
11
+ * Who scrolls a table wider or taller than its box. `self` wraps it in its own
12
+ * horizontal scroller. `parent` renders the bare table for a page that already
13
+ * scrolls it (a `ScrollArea`, a scrolling pane): a scroller of its own would
14
+ * become the reference box of a sticky header and stop it from sticking.
15
+ */
16
+ type TableScroll = "self" | "parent";
17
+ /**
18
+ * How tightly a table sets its cells.
19
+ *
20
+ * `default` is a data table: padded cells on one line, rows that light up
21
+ * under the pointer. `compact` is a small reading table inside a card or a
22
+ * review (a term set against a standard, a presence matrix): cells sit at
23
+ * text leading with no side padding, headings keep a trailing gap so a
24
+ * right-aligned heading never touches the next column, values wrap, and rows
25
+ * do not highlight because nothing in them is a row-wide target. A row
26
+ * header (`<TableHead scope="row">`) in a compact body reads as the row's
27
+ * first cell rather than as a column heading.
28
+ *
29
+ * `prose` is a table of sentences read across columns (an AI answer's
30
+ * comparison, a clause review): ruled columns and rows, cells padded and set
31
+ * at reading leading from their top, a quiet header in normal weight, and a
32
+ * first column wide enough to hold a few words per line. Its cells wrap or
33
+ * stay on one line as `cellText` says.
34
+ */
35
+ type TableDensity = "default" | "compact" | "prose";
36
+ /**
37
+ * How a `prose` table sets long cell text: `wrap` breaks it over lines,
38
+ * `single-line` keeps every cell on one line and leaves the table wider than
39
+ * its box for the scroller around it.
40
+ */
41
+ type TableCellText = "wrap" | "single-line";
42
+ type TableProps = React.ComponentProps<"table"> & {
43
+ cellText?: TableCellText;
44
+ density?: TableDensity;
45
+ inset?: TableInset;
46
+ scroll?: TableScroll;
47
+ };
48
+ declare const Table: ({ cellText, className, density, inset, scroll, ...props }: TableProps) => React.JSX.Element;
49
+ type TableHeaderProps = React.ComponentProps<"thead"> & {
50
+ /**
51
+ * `muted` lays the header row on a muted band, separating it from the rows
52
+ * of a long list.
53
+ */
54
+ surface?: "plain" | "muted";
55
+ /**
56
+ * Keeps the header in view while the rows scroll under it, on a translucent
57
+ * muted band. The table must scroll with its parent (`scroll="parent"`).
58
+ */
59
+ sticky?: boolean;
60
+ };
61
+ declare const TableHeader: ({ className, surface, sticky, ...props }: TableHeaderProps) => React.JSX.Element;
62
+ declare const TableBody: ({ className, ...props }: React.ComponentProps<"tbody">) => React.JSX.Element;
63
+ declare const TableFooter: ({ className, ...props }: React.ComponentProps<"tfoot">) => React.JSX.Element;
64
+ declare const TableRow: ({ className, tone, ...props }: React.ComponentProps<"tr"> & {
65
+ tone?: TableTone | undefined;
66
+ }) => React.JSX.Element;
67
+ type TableHeadProps = Omit<React.ComponentProps<"th">, "align"> & {
68
+ align?: TableAlign | undefined;
69
+ /**
70
+ * Heads a column of figures: tabular numerals, like its cells, set to the
71
+ * end unless `align` says otherwise.
72
+ */
73
+ numeric?: boolean | undefined;
74
+ };
75
+ declare const TableHead: ({ className, align, numeric, ...props }: TableHeadProps) => React.JSX.Element;
76
+ declare const TableCaption: ({ className, ...props }: React.ComponentProps<"caption">) => React.JSX.Element;
77
+ type SortDirection = "asc" | "desc" | null;
78
+ /** A sortable head's `aria-sort` for its direction. */
79
+ declare const ariaSortOf: (direction: SortDirection) => "ascending" | "descending" | "none";
80
+ /** The arrow after a sorted head's label; nothing for an unsorted one. */
81
+ declare const SortDirectionIcon: ({ direction }: {
82
+ direction: SortDirection;
83
+ }) => React.JSX.Element | null;
84
+ /** A head's label and the control after it, on one line. */
85
+ declare const HEAD_CONTENT_CLASS = "inline-flex items-center gap-1";
86
+ /** The arrow's slot, held open so a label never moves as the sort flips. */
87
+ declare const SORT_ICON_SLOT_CLASS = "inline-flex w-3 shrink-0 justify-center";
88
+ /**
89
+ * A sortable head's button: a quiet button whose inline padding equals the
90
+ * head's, pulled back by a negative margin so the label lines up with the
91
+ * cells and the button never reaches past the table's edge. In an
92
+ * end-aligned (numeric) column the arrow sits before the label.
93
+ */
94
+ declare const sortableHeadButtonClassName: (endAligned: boolean) => string;
95
+ /** A head's label before its page has loaded: the cut line it sits on. */
96
+ declare const TableHeadLabel: ({ children }: {
97
+ children: React.ReactNode;
98
+ }) => React.JSX.Element;
99
+ type SortableHeadFaceProps = Omit<TableHeadProps, "children" | "onClick"> & {
100
+ children: React.ReactNode;
101
+ sortDirection?: SortDirection;
102
+ /** Drawn next to the label, where the head's trailing control goes. */
103
+ trailing?: React.ReactNode;
104
+ };
105
+ /**
106
+ * A sortable head before its page has loaded: the label in the sort button's
107
+ * face and the arrow in its slot, with no behaviour.
108
+ */
109
+ declare const SortableHeadFace: ({ align, children, numeric, sortDirection, trailing, ...props }: SortableHeadFaceProps) => React.JSX.Element;
110
+ type TableSkeletonColumn = {
111
+ id: string;
112
+ className?: string | undefined;
113
+ align?: TableAlign | undefined;
114
+ } & ({
115
+ bar: string;
116
+ } | {
117
+ placeholder: React.ReactNode;
118
+ });
119
+ /** Rows that share the table's cell geometry and its caller's column order. */
120
+ declare const TableSkeletonRows: ({ columns, count, rowClassName }: {
121
+ columns: readonly TableSkeletonColumn[];
122
+ /** Rows to draw, clamped to the reserved placeholder keys. */
123
+ count?: number | undefined;
124
+ rowClassName?: string | undefined;
125
+ }) => React.JSX.Element[];
126
+ export { HEAD_CONTENT_CLASS, SORT_ICON_SLOT_CLASS, type SortDirection, SortDirectionIcon, SortableHeadFace, Table, type TableAlign, TableBody, TableCaption, TableCellFace, type TableCellText, type TableDensity, TableFooter, TableHead, TableHeadLabel, type TableHeadProps, TableHeader, type TableHeaderProps, type TableInset, type TableProps, TableRow, type TableScroll, TableSkeletonRows, type TableTone, ariaSortOf, sortableHeadButtonClassName };
@@ -0,0 +1,136 @@
1
+ import { ArrowDownIcon, ArrowUpIcon } from "../icons.js";
2
+ import { cn } from "../lib/utils.js";
3
+ import { buttonFaceClassName } from "./control-face.js";
4
+ import { InlineSkeleton } from "./skeleton.js";
5
+ import { PROSE_CELL_CLASS, TABLE_ALIGN_CLASS, TableCellFace, resolveTableAlign } from "./table-cell.js";
6
+ import { TRUNCATED_TEXT_LINES_CLASS } from "./truncated-text-face.js";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ // src/components/table-shell.tsx
9
+ const Table = ({ cellText = "wrap", className, density = "default", inset = "default", scroll = "self", ...props }) => {
10
+ const table = /* @__PURE__ */ jsx("table", {
11
+ className: cn("w-full caption-bottom text-sm in-data-[slot=frame]:border-separate in-data-[slot=frame]:border-spacing-0", density === "prose" && "border-separate border-spacing-0", className),
12
+ "data-cell-text": cellText,
13
+ "data-density": density,
14
+ "data-inset": inset,
15
+ "data-slot": "table",
16
+ ...props
17
+ });
18
+ if (scroll === "parent") return table;
19
+ return /* @__PURE__ */ jsx("div", {
20
+ className: "relative w-full overflow-x-auto",
21
+ "data-slot": "table-container",
22
+ children: table
23
+ });
24
+ };
25
+ const TableHeader = ({ className, surface = "plain", sticky = false, ...props }) => /* @__PURE__ */ jsx("thead", {
26
+ className: cn("[&_tr]:border-b in-data-[slot=frame]:**:[th]:h-9 in-data-[density=prose]:*:[tr]:hover:bg-transparent in-data-[slot=frame]:*:[tr]:border-none in-data-[slot=frame]:*:[tr]:hover:bg-transparent", surface === "muted" && "bg-muted/50", sticky && "bg-muted/80 sticky top-0 z-10 backdrop-blur", sticky && "in-data-[density=prose]:bg-card in-data-[density=prose]:backdrop-blur-none", className),
27
+ "data-slot": "table-header",
28
+ ...props
29
+ });
30
+ const TableBody = ({ className, ...props }) => /* @__PURE__ */ jsx("tbody", {
31
+ className: cn("in-data-[slot=frame]:*:[tr]:*:[td]:bg-background in-data-[slot=frame]:*:[tr]:data-[state=selected]:*:[td]:bg-muted/72 relative before:pointer-events-none before:absolute before:inset-px before:rounded-[calc(var(--radius-xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] not-in-data-[slot=frame]:before:hidden in-data-[slot=frame]:rounded-xl in-data-[slot=frame]:shadow-xs/5 dark:before:shadow-[0_-1px_--theme(--color-white/8%)] [&_tr:last-child]:border-0 in-data-[slot=frame]:*:[tr]:border-0 in-data-[slot=frame]:*:[tr]:*:[td]:border-b in-data-[slot=frame]:*:[tr]:*:[td]:bg-clip-padding in-data-[slot=frame]:*:[tr]:first:*:[td]:first:rounded-ss-xl in-data-[slot=frame]:*:[tr]:*:[td]:first:border-s in-data-[slot=frame]:*:[tr]:first:*:[td]:border-t in-data-[slot=frame]:*:[tr]:last:*:[td]:last:rounded-ee-xl in-data-[slot=frame]:*:[tr]:*:[td]:last:border-e in-data-[slot=frame]:*:[tr]:first:*:[td]:last:rounded-se-xl in-data-[slot=frame]:*:[tr]:last:*:[td]:first:rounded-es-xl in-data-[slot=frame]:*:[tr]:hover:*:[td]:bg-transparent", className),
32
+ "data-slot": "table-body",
33
+ ...props
34
+ });
35
+ const TableFooter = ({ className, ...props }) => /* @__PURE__ */ jsx("tfoot", {
36
+ className: cn("bg-muted/72 border-t font-medium in-data-[slot=frame]:border-none in-data-[slot=frame]:bg-transparent in-data-[slot=frame]:*:[tr]:hover:bg-transparent [&>tr]:last:border-b-0", className),
37
+ "data-slot": "table-footer",
38
+ ...props
39
+ });
40
+ const TableRow = ({ className, tone = "default", ...props }) => /* @__PURE__ */ jsx("tr", {
41
+ className: cn("hover:bg-muted/72 data-[state=selected]:bg-muted/72 border-b in-data-[density=compact]:hover:bg-transparent in-data-[slot=frame]:hover:bg-transparent in-data-[slot=frame]:data-[state=selected]:bg-transparent", tone === "muted" && "text-muted-foreground", className),
42
+ "data-slot": "table-row",
43
+ ...props
44
+ });
45
+ const TableHead = ({ className, align, numeric = false, ...props }) => /* @__PURE__ */ jsx("th", {
46
+ className: cn("text-muted-foreground h-10 px-2.5 align-middle leading-none font-medium whitespace-nowrap in-data-[inset=card]:px-4 has-[[role=checkbox]]:w-px has-[[role=checkbox]]:pe-0", "in-data-[density=compact]:h-auto in-data-[density=compact]:px-0 in-data-[density=compact]:py-1 in-data-[density=compact]:pe-3 in-data-[density=compact]:text-xs", "in-data-[density=compact]:[tbody_&]:py-1.5 in-data-[density=compact]:[tbody_&]:text-sm in-data-[density=compact]:[tbody_&]:leading-6 in-data-[density=compact]:[tbody_&]:font-normal in-data-[density=compact]:[tbody_&]:whitespace-normal in-data-[density=compact]:[tbody_&]:text-inherit", PROSE_CELL_CLASS, "in-data-[density=prose]:[thead_&]:bg-muted in-data-[density=prose]:font-normal", TABLE_ALIGN_CLASS[resolveTableAlign(align, numeric) ?? "start"], numeric && "tabular-nums", className),
47
+ "data-slot": "table-head",
48
+ ...props
49
+ });
50
+ const TableCaption = ({ className, ...props }) => /* @__PURE__ */ jsx("caption", {
51
+ className: cn("text-muted-foreground mt-4 text-sm in-data-[slot=frame]:my-4", className),
52
+ "data-slot": "table-caption",
53
+ ...props
54
+ });
55
+ /** A sortable head's `aria-sort` for its direction. */
56
+ const ariaSortOf = (direction) => {
57
+ if (direction === "asc") return "ascending";
58
+ if (direction === "desc") return "descending";
59
+ return "none";
60
+ };
61
+ /** The arrow after a sorted head's label; nothing for an unsorted one. */
62
+ const SortDirectionIcon = ({ direction }) => {
63
+ if (direction === "asc") return /* @__PURE__ */ jsx(ArrowUpIcon, { className: "size-3" });
64
+ if (direction === "desc") return /* @__PURE__ */ jsx(ArrowDownIcon, { className: "size-3" });
65
+ return null;
66
+ };
67
+ /** A head's label and the control after it, on one line. */
68
+ const HEAD_CONTENT_CLASS = "inline-flex items-center gap-1";
69
+ /** The arrow's slot, held open so a label never moves as the sort flips. */
70
+ const SORT_ICON_SLOT_CLASS = "inline-flex w-3 shrink-0 justify-center";
71
+ /**
72
+ * A sortable head's button: a quiet button whose inline padding equals the
73
+ * head's, pulled back by a negative margin so the label lines up with the
74
+ * cells and the button never reaches past the table's edge. In an
75
+ * end-aligned (numeric) column the arrow sits before the label.
76
+ */
77
+ const sortableHeadButtonClassName = (endAligned) => cn("min-w-0 gap-1 px-2.5", endAligned ? "-me-2.5 flex-row-reverse" : "-ms-2.5");
78
+ /** A head's label before its page has loaded: the cut line it sits on. */
79
+ const TableHeadLabel = ({ children }) => /* @__PURE__ */ jsx("span", {
80
+ className: TRUNCATED_TEXT_LINES_CLASS[1],
81
+ "data-slot": "truncated-text",
82
+ children
83
+ });
84
+ /**
85
+ * A sortable head before its page has loaded: the label in the sort button's
86
+ * face and the arrow in its slot, with no behaviour.
87
+ */
88
+ const SortableHeadFace = ({ align, children, numeric = false, sortDirection = null, trailing, ...props }) => /* @__PURE__ */ jsx(TableHead, {
89
+ align,
90
+ "aria-sort": ariaSortOf(sortDirection),
91
+ numeric,
92
+ ...props,
93
+ onClick: void 0,
94
+ children: /* @__PURE__ */ jsxs("span", {
95
+ className: HEAD_CONTENT_CLASS,
96
+ children: [/* @__PURE__ */ jsxs("span", {
97
+ "aria-hidden": "true",
98
+ className: cn(buttonFaceClassName({
99
+ size: "default",
100
+ variant: "muted"
101
+ }), sortableHeadButtonClassName(resolveTableAlign(align, numeric) === "end")),
102
+ children: [/* @__PURE__ */ jsx(TableHeadLabel, { children }), /* @__PURE__ */ jsx("span", {
103
+ className: SORT_ICON_SLOT_CLASS,
104
+ children: /* @__PURE__ */ jsx(SortDirectionIcon, { direction: sortDirection })
105
+ })]
106
+ }), trailing]
107
+ })
108
+ });
109
+ const SKELETON_ROW_KEYS = [
110
+ "a",
111
+ "b",
112
+ "c",
113
+ "d",
114
+ "e",
115
+ "f",
116
+ "g",
117
+ "h",
118
+ "i",
119
+ "j",
120
+ "k",
121
+ "l"
122
+ ];
123
+ /** Rows that share the table's cell geometry and its caller's column order. */
124
+ const TableSkeletonRows = ({ columns, count = 5, rowClassName }) => SKELETON_ROW_KEYS.slice(0, Math.max(0, count)).map((rowKey) => /* @__PURE__ */ jsx(TableRow, {
125
+ "aria-hidden": "true",
126
+ className: rowClassName,
127
+ children: columns.map((column) => /* @__PURE__ */ jsx(TableCellFace, {
128
+ align: column.align,
129
+ className: column.className,
130
+ children: "bar" in column ? /* @__PURE__ */ jsx("span", {
131
+ className: "inline-flex h-8 items-center sm:h-7",
132
+ children: /* @__PURE__ */ jsx(InlineSkeleton, { className: cn("h-3.5 max-w-full", column.bar) })
133
+ }) : column.placeholder
134
+ }, column.id))
135
+ }, rowKey));
136
+ export { HEAD_CONTENT_CLASS, SORT_ICON_SLOT_CLASS, SortDirectionIcon, SortableHeadFace, Table, TableBody, TableCaption, TableCellFace, TableFooter, TableHead, TableHeadLabel, TableHeader, TableRow, TableSkeletonRows, ariaSortOf, sortableHeadButtonClassName };