@sincpro/web-ui 2.3.0 → 2.5.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 (70) hide show
  1. package/README.md +71 -6
  2. package/dist/components/activity/Activity.d.ts +20 -1
  3. package/dist/components/activity/Activity.js +44 -7
  4. package/dist/components/activity/index.d.ts +1 -1
  5. package/dist/components/board/Board.d.ts +74 -2
  6. package/dist/components/board/Board.js +65 -2
  7. package/dist/components/board/index.d.ts +1 -1
  8. package/dist/components/board/index.js +1 -1
  9. package/dist/components/canvas/canvas.css +6 -1
  10. package/dist/components/form/Form.js +11 -0
  11. package/dist/components/form/FormIndex.d.ts +11 -0
  12. package/dist/components/form/FormIndex.js +96 -0
  13. package/dist/components/form/Sheet.js +5 -0
  14. package/dist/components/guide/Guide.d.ts +33 -0
  15. package/dist/components/guide/Guide.js +288 -0
  16. package/dist/components/guide/GuideSpot.d.ts +14 -0
  17. package/dist/components/guide/GuideSpot.js +13 -0
  18. package/dist/components/guide/index.d.ts +4 -0
  19. package/dist/components/guide/index.js +6 -0
  20. package/dist/components/guide/place.d.ts +44 -0
  21. package/dist/components/guide/place.js +69 -0
  22. package/dist/components/guide/target.d.ts +41 -0
  23. package/dist/components/guide/target.js +55 -0
  24. package/dist/components/index.d.ts +1 -0
  25. package/dist/components/index.js +1 -0
  26. package/dist/components/listing/ChartExplorer.js +10 -5
  27. package/dist/components/listing/Listing.js +7 -5
  28. package/dist/components/listing/Row.js +8 -7
  29. package/dist/components/navigation/NavigationTree.js +1 -1
  30. package/dist/components/record/DirtyActions.d.ts +19 -8
  31. package/dist/components/record/DirtyActions.js +89 -13
  32. package/dist/components/record/RecordHeader.js +17 -11
  33. package/dist/components/record/ThumbBar.js +2 -1
  34. package/dist/components/shell/SearchEntry.d.ts +29 -0
  35. package/dist/components/shell/SearchEntry.js +34 -0
  36. package/dist/components/shell/Sidebar.d.ts +5 -1
  37. package/dist/components/shell/Sidebar.js +4 -3
  38. package/dist/components/shell/TopBar.d.ts +5 -1
  39. package/dist/components/shell/TopBar.js +3 -2
  40. package/dist/components/shell/index.d.ts +1 -0
  41. package/dist/components/shell/index.js +3 -0
  42. package/dist/foundations/calendar.d.ts +12 -0
  43. package/dist/foundations/calendar.js +50 -0
  44. package/dist/foundations/chart.d.ts +10 -1
  45. package/dist/foundations/chart.js +17 -1
  46. package/dist/foundations/copy.d.ts +39 -2
  47. package/dist/foundations/copy.es.js +19 -0
  48. package/dist/foundations/copy.js +19 -0
  49. package/dist/foundations/form.d.ts +6 -0
  50. package/dist/foundations/form.js +7 -0
  51. package/dist/foundations/index.d.ts +3 -2
  52. package/dist/foundations/index.js +4 -2
  53. package/dist/foundations/pivot.d.ts +6 -0
  54. package/dist/foundations/pivot.js +1 -0
  55. package/dist/foundations/shortcut.d.ts +18 -0
  56. package/dist/foundations/shortcut.js +20 -0
  57. package/dist/primitives/chart/BarList.d.ts +30 -0
  58. package/dist/primitives/chart/BarList.js +27 -0
  59. package/dist/primitives/chart/Chart.d.ts +13 -0
  60. package/dist/primitives/chart/Chart.js +71 -19
  61. package/dist/primitives/chart/Sparkline.d.ts +30 -0
  62. package/dist/primitives/chart/Sparkline.js +53 -0
  63. package/dist/primitives/chart/index.d.ts +2 -0
  64. package/dist/primitives/chart/index.js +2 -0
  65. package/dist/primitives/field/Field.d.ts +6 -2
  66. package/dist/primitives/field/Field.js +35 -6
  67. package/dist/primitives/value/Metric.d.ts +12 -1
  68. package/dist/primitives/value/Metric.js +9 -4
  69. package/dist/tokens.css +92 -22
  70. package/package.json +1 -1
@@ -9,9 +9,14 @@ import { Button, IconButton } from "../../primitives/button/Button.js";
9
9
  import { Chart } from "../../primitives/chart/Chart.js";
10
10
  import { SegmentedControl } from "../../primitives/choice/SegmentedControl.js";
11
11
  import { Menu } from "../../primitives/menu/Menu.js";
12
- import { ArrowDownWideNarrow, ArrowUpNarrowWide, ChartColumnBig, ChartLine, ChartPie, Download, GitCompareArrows, Layers, Sigma, TrendingUp, } from "lucide-react";
12
+ import { ArrowDownWideNarrow, ArrowUpNarrowWide, ChartArea, ChartColumnBig, ChartLine, ChartPie, Download, GitCompareArrows, Layers, Sigma, TrendingUp, } from "lucide-react";
13
13
  import { useMemo, useState } from "react";
14
- const KIND_ICON = { bar: ChartColumnBig, line: ChartLine, pie: ChartPie };
14
+ const KIND_ICON = {
15
+ bar: ChartColumnBig,
16
+ line: ChartLine,
17
+ area: ChartArea,
18
+ pie: ChartPie,
19
+ };
15
20
  /**
16
21
  * Odoo's GRAPH view, for any set: bars, lines or a pie; which measures; split by what along
17
22
  * the axis and by what into series; stacked, cumulative, ordered; against the previous
@@ -64,7 +69,7 @@ export function ChartExplorer({ folded, items, of, fields = [], labelOf: outerLa
64
69
  return measuresShown.map((measure) => {
65
70
  const reading = {
66
71
  measure: measure.id,
67
- cumulative: kind === "line" && cumulative,
72
+ cumulative: (kind === "line" || kind === "area") && cumulative,
68
73
  ...(kind === "pie" ? { maxCategories: 7 } : {}),
69
74
  };
70
75
  const current = chartFromPivot(pivot, reading);
@@ -92,7 +97,7 @@ export function ChartExplorer({ folded, items, of, fields = [], labelOf: outerLa
92
97
  /* The last one stays: a chart of no measure is no chart. */
93
98
  setChosen(!on.includes(id) ? [...on, id] : on.length === 1 ? on : on.filter((one) => one !== id));
94
99
  };
95
- return (_jsxs("div", { className: "flex min-w-0 flex-col gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-5 gap-y-2", children: [_jsx(SegmentedControl, { "aria-label": words.kind, size: "sm", value: kind, onChange: (next) => setKind(next), options: ["bar", "line", "pie"].map((one) => ({
100
+ return (_jsxs("div", { className: "flex min-w-0 flex-col gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-5 gap-y-2", children: [_jsx(SegmentedControl, { "aria-label": words.kind, size: "sm", value: kind, onChange: (next) => setKind(next), options: ["bar", "line", "area", "pie"].map((one) => ({
96
101
  value: one,
97
102
  label: words[one],
98
103
  icon: KIND_ICON[one],
@@ -105,7 +110,7 @@ export function ChartExplorer({ folded, items, of, fields = [], labelOf: outerLa
105
110
  checked: measuresShown.some((on) => on.id === one.id),
106
111
  })),
107
112
  },
108
- ], onSelect: toggleMeasure }), folded === undefined ? (_jsxs(_Fragment, { children: [_jsx(AxisLevels, { name: words.categoriesAxis, levels: categories, onChange: following ? null : setOwnCategories, fields: fields, used: series, labelOf: labelOf }), kind === "pie" || (following && series.length === 0) ? null : (_jsx(AxisLevels, { name: words.seriesAxis, levels: series, onChange: following ? null : setOwnSeries, fields: fields, used: categories, labelOf: labelOf }))] })) : null, _jsxs("div", { className: "ml-auto flex items-center gap-1", children: [canCompare ? (_jsx(IconButton, { icon: GitCompareArrows, label: fillCopy(words.compareWith, { name: compare.previous }), "aria-pressed": comparing, onClick: () => setComparing((now) => !now) })) : null, kind !== "pie" && manySeries ? (_jsx(IconButton, { icon: Layers, label: words.stacked, "aria-pressed": stacked, onClick: () => setStacked((now) => !now) })) : null, kind === "line" ? (_jsx(IconButton, { icon: TrendingUp, label: words.cumulative, "aria-pressed": cumulative && additive, disabled: !additive, onClick: () => setCumulative((now) => !now) })) : null, _jsx(IconButton, { icon: ArrowDownWideNarrow, label: words.descending, "aria-pressed": order === "desc", onClick: () => toggleOrder("desc") }), _jsx(IconButton, { icon: ArrowUpNarrowWide, label: words.ascending, "aria-pressed": order === "asc", onClick: () => toggleOrder("asc") }), pivot === undefined ? null : (_jsx(Button, { role: "ghost", size: "sm", icon: Download, onClick: () => downloadPivot(pivot, fileName === undefined ? {} : { name: fileName }), children: copy.pivot.download }))] })] }), charts.map((data) => (_jsxs("section", { className: "flex min-w-0 flex-col gap-2", children: [charts.length > 1 ? (_jsx("h3", { className: "text-meta font-semibold text-ink", children: data.measure.header })) : null, _jsx(Chart, { data: data, kind: kind, stacked: stacked, label: charts.length > 1
113
+ ], onSelect: toggleMeasure }), folded === undefined ? (_jsxs(_Fragment, { children: [_jsx(AxisLevels, { name: words.categoriesAxis, levels: categories, onChange: following ? null : setOwnCategories, fields: fields, used: series, labelOf: labelOf }), kind === "pie" || (following && series.length === 0) ? null : (_jsx(AxisLevels, { name: words.seriesAxis, levels: series, onChange: following ? null : setOwnSeries, fields: fields, used: categories, labelOf: labelOf }))] })) : null, _jsxs("div", { className: "ml-auto flex items-center gap-1", children: [canCompare ? (_jsx(IconButton, { icon: GitCompareArrows, label: fillCopy(words.compareWith, { name: compare.previous }), "aria-pressed": comparing, onClick: () => setComparing((now) => !now) })) : null, kind !== "pie" && manySeries ? (_jsx(IconButton, { icon: Layers, label: words.stacked, "aria-pressed": stacked, onClick: () => setStacked((now) => !now) })) : null, kind === "line" || kind === "area" ? (_jsx(IconButton, { icon: TrendingUp, label: words.cumulative, "aria-pressed": cumulative && additive, disabled: !additive, onClick: () => setCumulative((now) => !now) })) : null, _jsx(IconButton, { icon: ArrowDownWideNarrow, label: words.descending, "aria-pressed": order === "desc", onClick: () => toggleOrder("desc") }), _jsx(IconButton, { icon: ArrowUpNarrowWide, label: words.ascending, "aria-pressed": order === "asc", onClick: () => toggleOrder("asc") }), pivot === undefined ? null : (_jsx(Button, { role: "ghost", size: "sm", icon: Download, onClick: () => downloadPivot(pivot, fileName === undefined ? {} : { name: fileName }), children: copy.pivot.download }))] })] }), charts.map((data) => (_jsxs("section", { className: "flex min-w-0 flex-col gap-2", children: [charts.length > 1 ? (_jsx("h3", { className: "text-meta font-semibold text-ink", children: data.measure.header })) : null, _jsx(Chart, { data: data, kind: kind, stacked: stacked, label: charts.length > 1
109
114
  ? describe(data.measure.header, label ?? data.categoryTitle)
110
115
  : (label ?? describe(data.measure.header, data.categoryTitle)), ...(onPoint === undefined ? {} : { onPoint }), ...(height === undefined ? {} : { height }) })] }, data.measure.id)))] }));
111
116
  }
@@ -42,11 +42,13 @@ import { createPortal } from "react-dom";
42
42
  * ── The row lays itself out; nobody tells it how ────────────────────
43
43
  *
44
44
  * WHICH presentation is the consumer's call. How a row arranges itself inside
45
- * the one that was chosen is nobody's: there is no width at which a row «turns
46
- * narrow», and no breakpoint written anywhere. Every zone asks for what it
47
- * needs —the name `--container-name`, the tags `--container-tags`, the
48
- * metadata what it says— and the line does what a line does: what does not fit
49
- * wraps, and the name keeps the first one.
45
+ * the one that was chosen is the row's, and it is the same for every row: the
46
+ * name, its metadata under it, the tags after the text (`--container-row-text`
47
+ * wide at most). The one thing the width changes — the tags leaving the name's
48
+ * line for one of their own — is a container query on the row's box
49
+ * (`--container-row-split`), so it is decided by the LIST's width, never by
50
+ * how long one row's metadata happens to be. Deciding it per row by wrapping
51
+ * put one meta beside its name and the next one under it, in the same list.
50
52
  *
51
53
  * **That is why it holds up with a checkbox, an icon, actions, no tags, or a
52
54
  * metadata three times longer.** None of that is declared anywhere: they all
@@ -68,12 +68,13 @@ export function Row({ icon: Icon, avatar, name, onOpen, onPeek, click = "peek",
68
68
  just the same by clicking anywhere on the row, not only on the
69
69
  name. With the preview turned off (`PeekLayer.tsx`) this is today the
70
70
  case for everyone: a click on the row opens, plain and simple. */
71
- onClick: click === "open" ? (onOpen ?? onPeek) : (onPeek ?? onOpen), role: "presentation", children: [onSelectedChange === undefined ? null : (_jsx("input", { type: "checkbox", checked: selected ?? false, "aria-label": fillCopy(copy.selection.named, { name }), onChange: (e) => onSelectedChange(e.target.checked), onClick: (e) => e.stopPropagation(), className: "size-3.5 shrink-0 cursor-pointer accent-primary" })), avatar !== undefined ? (_jsx(Avatar, { name: avatar.name, size: "sm", ...(avatar.src === undefined ? {} : { src: avatar.src }) })) : Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 1.75, "aria-hidden": true })), _jsxs("div", { className: `flex min-w-0 shrink grow basis-(--container-name) flex-wrap items-center gap-y-0 ${byDensity(d, "gap-x-3", "gap-x-2")}`, children: [_jsx("span", { className: "min-w-0 grow basis-(--container-name)", children: _jsx(RecordLink, { ...((onOpen ?? onPeek) === undefined ? {} : { onClick: (onOpen ?? onPeek) }), title: name, children: name }) }), meta === undefined ? null : (
72
- /* Wrapped or not, the metadata is still there —it is what saves
73
- having to open a set to know whether it is a thousand rows or a
74
- million— and it truncates instead of wrapping into itself: three
75
- lines per row in a 480 px drawer means three rows fit on screen. */
76
- _jsx("span", { className: "min-w-0 truncate text-micro tabular-nums text-muted", children: meta })), tags === undefined ? null : (_jsx("span", { className: "ms-auto flex min-w-fit shrink basis-(--container-tags) items-center justify-end gap-1.5", children: tags }))] }), _jsx("span", { className: "flex shrink-0 items-center gap-1 opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100", children: _jsx(Trail, { name: name, openAs: openAs, ...(actions === undefined ? {} : { actions }), copy: copyAs, ...(onPeek === undefined || !openers ? {} : { onPeek }), ...(onOpen === undefined || !openers ? {} : { onOpen }), ...(more === undefined ? {} : { more }), ...(onMoreSelect === undefined ? {} : { onMoreSelect }) }) })] }) }));
71
+ onClick: click === "open" ? (onOpen ?? onPeek) : (onPeek ?? onOpen), role: "presentation", children: [onSelectedChange === undefined ? null : (_jsx("input", { type: "checkbox", checked: selected ?? false, "aria-label": fillCopy(copy.selection.named, { name }), onChange: (e) => onSelectedChange(e.target.checked), onClick: (e) => e.stopPropagation(), className: "size-3.5 shrink-0 cursor-pointer accent-primary" })), avatar !== undefined ? (_jsx(Avatar, { name: avatar.name, size: "sm", ...(avatar.src === undefined ? {} : { src: avatar.src }) })) : Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 1.75, "aria-hidden": true })), _jsx("div", { className: "@container/row min-w-0 grow", children: _jsxs("div", { className: `flex min-w-0 items-center gap-y-1 @max-row-split/row:flex-wrap ${byDensity(d, "gap-x-3", "gap-x-2")}`, children: [_jsxs("span", { "data-slot": "row-text", className: "flex min-w-0 shrink grow basis-(--container-name) flex-col @row-split/row:max-w-(--container-row-text)", children: [_jsx(RecordLink, { ...((onOpen ?? onPeek) === undefined
72
+ ? {}
73
+ : { onClick: (onOpen ?? onPeek) }), title: name, children: name }), meta === undefined ? null : (
74
+ /* It truncates instead of wrapping into itself: three lines per row in a
75
+ 480 px drawer means three rows fit on screen. In mono figures: under the
76
+ name, row after row, the dates and amounts line up. */
77
+ _jsx("span", { className: "min-w-0 truncate text-micro tabular-nums text-muted", children: meta }))] }), tags === undefined ? null : (_jsx("span", { "data-slot": "row-tags", className: "flex min-w-fit shrink-0 basis-(--container-tags) flex-wrap items-center gap-1.5 @max-row-split/row:basis-full", children: tags }))] }) }), _jsx("span", { className: "flex shrink-0 items-center gap-1 opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100", children: _jsx(Trail, { name: name, openAs: openAs, ...(actions === undefined ? {} : { actions }), copy: copyAs, ...(onPeek === undefined || !openers ? {} : { onPeek }), ...(onOpen === undefined || !openers ? {} : { onOpen }), ...(more === undefined ? {} : { more }), ...(onMoreSelect === undefined ? {} : { onMoreSelect }) }) })] }) }));
77
78
  if (children === undefined)
78
79
  return row;
79
80
  /* What the resource produced, hanging below. The indent reaches up to where
@@ -110,7 +111,7 @@ export function RowHeader({ name, meta, tags, withSelection = false, withIcon =
110
111
  return (_jsxs("div", { "data-slot": "row-header",
111
112
  /* It sticks below the list's bar, like the table's header
112
113
  and the sheet's. See `system/sticky.tsx`. */
113
- className: `sticky z-10 flex min-w-0 items-center border-b border-line-strong bg-ground ${byDensity(d, "gap-3 px-3 py-2", "gap-2 px-2.5 py-1.5")}`, style: stickyTop, role: "presentation", children: [!withSelection ? null : _jsx("span", { className: "size-3.5 shrink-0", "aria-hidden": true }), withAvatar ? (_jsx("span", { className: "size-5 shrink-0", "aria-hidden": true })) : !withIcon ? null : (_jsx("span", { className: "size-(--size-icon-md) shrink-0", "aria-hidden": true })), _jsxs("div", { className: `flex min-w-0 shrink grow basis-(--container-name) flex-wrap items-center gap-y-0 ${byDensity(d, "gap-x-3", "gap-x-2")}`, children: [_jsx("span", { className: `min-w-0 grow basis-(--container-name) ${rotulo}`, children: name }), meta === undefined ? null : _jsx("span", { className: `min-w-0 ${rotulo}`, children: meta }), tags === undefined ? null : (_jsx("span", { className: "ms-auto flex min-w-fit shrink basis-(--container-tags) items-center justify-end", children: _jsx("span", { className: rotulo, children: tags }) }))] }), trail !== undefined ? (_jsx("span", { inert: true, "aria-hidden": true, className: "invisible flex shrink-0 items-center gap-1", children: _jsx(Trail, { name: "", openAs: "", ...(trail.actions === undefined ? {} : { actions: trail.actions }), ...(trail.copy === false ? { copy: false } : {}), ...(trail.peek === true ? { onPeek: () => { } } : {}), ...(trail.open === true ? { onOpen: () => { } } : {}) }) })) : !withActions ? null : (_jsx("span", { className: "size-(--size-control-sm) shrink-0", "aria-hidden": true }))] }));
114
+ className: `sticky z-10 flex min-w-0 items-center border-b border-line-strong bg-ground ${byDensity(d, "gap-3 px-3 py-2", "gap-2 px-2.5 py-1.5")}`, style: stickyTop, role: "presentation", children: [!withSelection ? null : _jsx("span", { className: "size-3.5 shrink-0", "aria-hidden": true }), withAvatar ? (_jsx("span", { className: "size-5 shrink-0", "aria-hidden": true })) : !withIcon ? null : (_jsx("span", { className: "size-(--size-icon-md) shrink-0", "aria-hidden": true })), _jsx("div", { className: "@container/row min-w-0 grow", children: _jsxs("div", { className: `flex min-w-0 items-center gap-y-1 @max-row-split/row:flex-wrap ${byDensity(d, "gap-x-3", "gap-x-2")}`, children: [_jsxs("span", { className: "flex min-w-0 shrink grow basis-(--container-name) flex-col @row-split/row:max-w-(--container-row-text)", children: [_jsx("span", { className: rotulo, children: name }), meta === undefined ? null : _jsx("span", { className: rotulo, children: meta })] }), tags === undefined ? null : (_jsx("span", { className: "flex min-w-fit shrink-0 basis-(--container-tags) items-center @max-row-split/row:basis-full", children: _jsx("span", { className: rotulo, children: tags }) }))] }) }), trail !== undefined ? (_jsx("span", { inert: true, "aria-hidden": true, className: "invisible flex shrink-0 items-center gap-1", children: _jsx(Trail, { name: "", openAs: "", ...(trail.actions === undefined ? {} : { actions: trail.actions }), ...(trail.copy === false ? { copy: false } : {}), ...(trail.peek === true ? { onPeek: () => { } } : {}), ...(trail.open === true ? { onOpen: () => { } } : {}) }) })) : !withActions ? null : (_jsx("span", { className: "size-(--size-control-sm) shrink-0", "aria-hidden": true }))] }));
114
115
  }
115
116
  /**
116
117
  * The header of a group inside a list.
@@ -98,7 +98,7 @@ export function NavigationTree({ items, current, onNavigate, defaultExpanded = [
98
98
  paddingInlineStart: `calc(var(--spacing) * 4 + var(--size-icon-md) + var(--spacing-indent) * ${level - 2})`,
99
99
  }
100
100
  : undefined;
101
- return (_jsxs(AriaNavigationTreeItem, { "data-ui": "navigation.item", id: item.id, textValue: item.label, ...(module ? {} : { href: item.id }), className: ({ isCurrent, isFocusVisible }) => row({ surface, isCurrent, isFocusVisible }), children: [_jsx(NavigationTreeItemContent, { children: ({ isCurrent, isCurrentAncestor, isExpanded }) => (_jsxs(_Fragment, { children: [isCurrent ? _jsx("span", { "aria-hidden": true, className: MARKER[surface] }) : null, _jsxs(Link, { className: link({ isModule: module }), style: indent, children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-md) shrink-0 ${isCurrent || (isCurrentAncestor && !isExpanded)
101
+ return (_jsxs(AriaNavigationTreeItem, { "data-ui": "navigation.item", "data-key": item.id, id: item.id, textValue: item.label, ...(module ? {} : { href: item.id }), className: ({ isCurrent, isFocusVisible }) => row({ surface, isCurrent, isFocusVisible }), children: [_jsx(NavigationTreeItemContent, { children: ({ isCurrent, isCurrentAncestor, isExpanded }) => (_jsxs(_Fragment, { children: [isCurrent ? _jsx("span", { "aria-hidden": true, className: MARKER[surface] }) : null, _jsxs(Link, { className: link({ isModule: module }), style: indent, children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-md) shrink-0 ${isCurrent || (isCurrentAncestor && !isExpanded)
102
102
  ? HERE[surface].here
103
103
  : HERE[surface].rest}`, strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: `min-w-0 flex-1 truncate ${isCurrentAncestor && !isExpanded ? HERE[surface].here : ""}`, children: item.label }), item.count === undefined ? null : (_jsx(Count, { value: item.count, current: isCurrent }))] }), module ? (_jsx(AriaButton, { slot: "chevron", className: ({ isFocusVisible }) => chevronButton({ surface, isFocusVisible }), children: _jsx(ChevronRight, { className: `size-(--size-icon-sm) transition-transform duration-(--duration-quick) ease-(--ease-out) ${isExpanded ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true }) })) : null] })) }), children.map((child) => render(child, level + 1))] }, item.id));
104
104
  };
@@ -8,11 +8,11 @@ export interface DirtyState {
8
8
  * regla». */
9
9
  label?: string;
10
10
  /** Why it CANNOT be saved yet. Present = the button is off and the reason is written
11
- * where the «unsaved» mark was — a button that is off with no reason is a wall, and a
12
- * reason in a `title` reaches neither the keyboard nor a finger. */
11
+ * beside it — a button that is off with no reason is a wall, and a reason in a `title`
12
+ * reaches neither the keyboard nor a finger. It is the only mark the rail draws. */
13
13
  blocked?: string;
14
- /** How many fields changed: «2 cambios sin guardar» instead of a bare «sin guardar». The
15
- * fields themselves are marked by their `Field changed`. */
14
+ /** How many fields changed. Not drawn: it describes the Save button, «Guardar — 2 cambios
15
+ * sin guardar», for whoever cannot see the fields' own `Field changed` marks. */
16
16
  changes?: number;
17
17
  }
18
18
  /** Save and discard, in the rail and in place of the action buttons.
@@ -21,10 +21,17 @@ export interface DirtyState {
21
21
  * the same rule as `FormActions`, and here it matters more: the rail is where
22
22
  * the hand is after editing.
23
23
  *
24
- * The «sin guardar» warning is text and not just a color: whoever is leaving
25
- * the screen has to be able to read what is going on, not deduce it from a
26
- * dot. */
27
- export declare function DirtyActions({ onSave, onDiscard, saving, label, blocked, changes, }: DirtyState): import("react").JSX.Element;
24
+ * There is no «sin guardar» mark. The two buttons only exist while something changed, and
25
+ * each changed field already says so (`Field changed`): a third signal repeating the other
26
+ * two was noise beside the one action that matters. The only thing written here is what
27
+ * the buttons cannot say — WHY it cannot be saved yet (`blocked`). The count of changes
28
+ * still reaches a screen reader, as the Save button's description. */
29
+ export declare function DirtyActions({ onSave, onDiscard, saving, label, blocked, changes, floating, }: DirtyState & {
30
+ /** In the floating bar (`DirtyBar`): the count is WRITTEN — the changed fields may be far
31
+ * up a long form, out of sight, and their marks with them — and Discard is the quiet
32
+ * ghost, so the bar reads «what is pending · undo · save» and not two equal boxes. */
33
+ floating?: boolean;
34
+ }): import("react").JSX.Element;
28
35
  /**
29
36
  * Whether the record has JUST been saved: `dirty` went from saving straight to gone.
30
37
  *
@@ -38,3 +45,7 @@ export declare function useJustSaved(dirty: DirtyState | undefined): boolean;
38
45
  export declare function SavedMark({ saved }: {
39
46
  saved: boolean;
40
47
  }): import("react").JSX.Element;
48
+ export declare function DirtyBar({ dirty, saved, }: {
49
+ dirty: DirtyState | undefined;
50
+ saved: boolean;
51
+ }): import("react").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
4
- import { bySurface, useSurface } from "../../foundations/surface.js";
4
+ import { bySurface, SurfaceProvider, useSurface } from "../../foundations/surface.js";
5
5
  import { Button } from "../../primitives/button/Button.js";
6
6
  import { Check, Save, Undo2 } from "lucide-react";
7
7
  import { useEffect, useId, useRef, useState } from "react";
@@ -11,21 +11,32 @@ import { useEffect, useId, useRef, useState } from "react";
11
11
  * the same rule as `FormActions`, and here it matters more: the rail is where
12
12
  * the hand is after editing.
13
13
  *
14
- * The «sin guardar» warning is text and not just a color: whoever is leaving
15
- * the screen has to be able to read what is going on, not deduce it from a
16
- * dot. */
17
- export function DirtyActions({ onSave, onDiscard, saving = false, label, blocked, changes, }) {
14
+ * There is no «sin guardar» mark. The two buttons only exist while something changed, and
15
+ * each changed field already says so (`Field changed`): a third signal repeating the other
16
+ * two was noise beside the one action that matters. The only thing written here is what
17
+ * the buttons cannot say — WHY it cannot be saved yet (`blocked`). The count of changes
18
+ * still reaches a screen reader, as the Save button's description. */
19
+ export function DirtyActions({ onSave, onDiscard, saving = false, label, blocked, changes, floating = false, }) {
18
20
  const copy = useUiCopy();
19
21
  const blockedId = useId();
22
+ const changesId = useId();
20
23
  /* It follows the rail it sits on instead of assuming the dark one: on a light rail the
21
24
  chrome palette was white text on white. */
22
25
  const surface = useSurface();
23
- return (_jsxs(_Fragment, { children: [_jsx("span", { ...(blocked === undefined ? {} : { id: blockedId }), className: `inline-flex h-(--size-control-md) min-w-0 shrink items-center gap-1.5 truncate rounded-control px-2.5 text-meta font-medium ${bySurface(surface, "bg-warn/12 text-warn", "bg-chrome-warn/15 text-chrome-warn")}`, children: blocked ??
24
- (changes === undefined || changes === 0
25
- ? copy.record.unsaved
26
- : fillCopy(changes === 1 ? copy.record.unsavedOne : copy.record.unsavedMany, {
27
- count: changes.toLocaleString(copy.locale),
28
- })) }), _jsx(Button, { surface: surface, onClick: onDiscard, disabled: saving, icon: Undo2, children: copy.record.discard }), _jsx(Button, { role: "primary", surface: surface, onClick: onSave, busy: saving, disabled: blocked !== undefined, icon: Save, ...(blocked === undefined ? {} : { "aria-describedby": blockedId }), children: saving ? copy.record.saving : (label ?? copy.record.save) })] }));
26
+ const counted = changes !== undefined && changes > 0;
27
+ const describedBy = [
28
+ ...(blocked === undefined ? [] : [blockedId]),
29
+ ...(counted ? [changesId] : []),
30
+ ].join(" ");
31
+ return (_jsxs(_Fragment, { children: [blocked === undefined ? null : (_jsx("span", { id: blockedId, "data-ui": "dirty.blocked", className: `inline-flex h-(--size-control-md) min-w-0 shrink items-center gap-1.5 truncate rounded-control px-2.5 text-meta font-medium ${bySurface(surface, "bg-warn/12 text-warn", "bg-chrome-warn/15 text-chrome-warn")}`, children: blocked })), counted ? (_jsx("span", { id: changesId, ...(floating
32
+ ? {
33
+ /* One row on a phone too: the count gives way (it truncates), never the
34
+ buttons — a pill broken in two rows is a blob. */
35
+ className: `min-w-0 shrink! truncate px-2.5 text-meta ${bySurface(surface, "text-muted", "text-chrome-muted")}`,
36
+ }
37
+ : { hidden: true }), children: fillCopy(changes === 1 ? copy.record.unsavedOne : copy.record.unsavedMany, {
38
+ count: changes.toLocaleString(copy.locale),
39
+ }) })) : null, _jsx(Button, { ...(floating ? { role: "ghost" } : {}), surface: surface, onClick: onDiscard, disabled: saving, icon: Undo2, children: copy.record.discard }), _jsx(Button, { role: "primary", surface: surface, onClick: onSave, busy: saving, disabled: blocked !== undefined, icon: Save, ...(describedBy === "" ? {} : { "aria-describedby": describedBy }), children: saving ? copy.record.saving : (label ?? copy.record.save) })] }));
29
40
  }
30
41
  /** The one action a view leads with: the element written with `role="primary"` — the
31
42
  * same prop that paints it gold and that `make smoke` counts, so there is no second way to
@@ -64,10 +75,75 @@ export function useJustSaved(dirty) {
64
75
  }, [saving, present]);
65
76
  return saved;
66
77
  }
78
+ /** The «✓ Guardado» chip itself, without its live region: what is SEEN. */
79
+ function SavedChip() {
80
+ const copy = useUiCopy();
81
+ const surface = useSurface();
82
+ return (_jsxs("span", { "aria-hidden": true, className: `inline-flex h-(--size-control-md) shrink-0 items-center gap-1.5 rounded-ui-button px-2.5 text-meta font-medium transition-[opacity,translate] duration-(--duration-quick) ease-(--ease-out) starting:-translate-y-0.5 starting:opacity-0 ${bySurface(surface, "bg-good/12 text-good", "bg-chrome-good/15 text-chrome-good")}`, children: [_jsx(Check, { className: "size-(--size-icon-sm)", strokeWidth: 2.5 }), copy.record.saved] }));
83
+ }
67
84
  /** «✓ Guardado», where Save was, for a moment. The live region is always there — a region
68
85
  * inserted together with its words is not reliably announced. */
69
86
  export function SavedMark({ saved }) {
70
87
  const copy = useUiCopy();
71
- const surface = useSurface();
72
- return (_jsxs(_Fragment, { children: [_jsx("span", { role: "status", className: "sr-only", children: saved ? copy.record.saved : "" }), saved ? (_jsxs("span", { "aria-hidden": true, className: `inline-flex h-(--size-control-md) shrink-0 items-center gap-1.5 rounded-control px-2.5 text-meta font-medium transition-[opacity,translate] duration-(--duration-quick) ease-(--ease-out) starting:-translate-y-0.5 starting:opacity-0 ${bySurface(surface, "bg-good/12 text-good", "bg-chrome-good/15 text-chrome-good")}`, children: [_jsx(Check, { className: "size-(--size-icon-sm)", strokeWidth: 2.5 }), copy.record.saved] })) : null] }));
88
+ return (_jsxs(_Fragment, { children: [_jsx("span", { role: "status", className: "sr-only", children: saved ? copy.record.saved : "" }), saved ? _jsx(SavedChip, {}) : null] }));
89
+ }
90
+ /**
91
+ * Save and Discard FLOATING at the bottom of the screen, centred — the «settings» form
92
+ * style's (`FormStyleProvider`), in place of the rail and the thumb bar.
93
+ *
94
+ * Context: a settings form is long and read top to bottom; the rail is left behind with the
95
+ * first card, and the last field changed is near the bottom. The bar appears with the first
96
+ * change, in the dark band (the chrome) so it reads apart from the cards, and says «Guardado»
97
+ * for a moment where Save was. Sticky and last in the record, as the thumb bar: at the end of
98
+ * the form it settles under the last card and covers nothing.
99
+ *
100
+ * ── It never covers the field being typed into ──────────────────────
101
+ *
102
+ * The bar appears with the first keystroke, and on a phone the field being typed into is
103
+ * often the one at the bottom of the screen — right where the bar lands. So while the bar is
104
+ * up, the field that has the focus (when the bar appears, and each time the focus moves) is
105
+ * scrolled up out from under it: a form that hides what you are writing is broken, however
106
+ * nice the bar.
107
+ *
108
+ * ── Its shape ─────────────────────────────────────────────────────────
109
+ *
110
+ * A pill holds pills: the buttons inside take the pill's radius (`--ui-button-radius`), or a
111
+ * full-round bar around 8 px corners reads as two boxes in a tube. On the dark theme the
112
+ * chrome is as dark as the ground, so the bar carries the chrome's hairline (`chrome-edge`) —
113
+ * invisible on light, where the chrome already stands apart by luminance.
114
+ */
115
+ const PILL = { "--ui-button-radius": "var(--radius-pill)" };
116
+ /** Scrolls `field` up from under `bar` when they overlap, with a little air above the bar. */
117
+ function clearOf(bar, field) {
118
+ if (!(field instanceof HTMLElement) || field === document.body || bar.contains(field))
119
+ return;
120
+ const over = bar.getBoundingClientRect();
121
+ const under = field.getBoundingClientRect();
122
+ if (over.height === 0 || under.bottom <= over.top || under.top >= over.bottom)
123
+ return;
124
+ const before = field.style.scrollMarginBottom;
125
+ field.style.scrollMarginBottom = `${String(Math.ceil(over.height + 12))}px`;
126
+ field.scrollIntoView({ block: "nearest" });
127
+ field.style.scrollMarginBottom = before;
128
+ }
129
+ export function DirtyBar({ dirty, saved, }) {
130
+ const copy = useUiCopy();
131
+ const shown = dirty !== undefined || saved;
132
+ const ref = useRef(null);
133
+ useEffect(() => {
134
+ const bar = ref.current;
135
+ if (!shown || bar === null)
136
+ return;
137
+ /* After the bar has its height: the frame it was drawn in. */
138
+ const frame = requestAnimationFrame(() => clearOf(bar, document.activeElement));
139
+ const onFocus = (event) => clearOf(bar, event.target);
140
+ document.addEventListener("focusin", onFocus);
141
+ return () => {
142
+ cancelAnimationFrame(frame);
143
+ document.removeEventListener("focusin", onFocus);
144
+ };
145
+ }, [shown]);
146
+ /* Always mounted, so «Guardado» is announced (see `SavedMark`); with nothing to say it has
147
+ no height and covers nothing. */
148
+ return (_jsxs("div", { ref: ref, "data-ui": "dirty.bar", className: `pointer-events-none sticky bottom-0 z-20 mt-auto flex justify-center px-3 ${shown ? "pt-3 safe-bottom" : ""}`, children: [_jsx("span", { role: "status", className: "sr-only", children: saved ? copy.record.saved : "" }), shown ? (_jsx(SurfaceProvider, { value: "chrome", children: _jsx("div", { style: PILL, className: "pointer-events-auto flex max-w-full min-w-0 items-center gap-1 rounded-pill border border-chrome-edge bg-chrome p-1.5 shadow-float *:shrink-0", children: dirty === undefined ? _jsx(SavedChip, {}) : _jsx(DirtyActions, { ...dirty, floating: true }) }) })) : null] }));
73
149
  }
@@ -1,18 +1,24 @@
1
1
  "use client";
2
2
  import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { Breadcrumb } from "./Breadcrumb.js";
4
- import { DirtyActions, SavedMark, useJustSaved, } from "./DirtyActions.js";
4
+ import { DirtyActions, DirtyBar, SavedMark, useJustSaved, } from "./DirtyActions.js";
5
5
  import { isPrimary, ThumbBar, thumbPlan } from "./ThumbBar.js";
6
6
  import { byDensity, useDensity } from "../../foundations/density.js";
7
+ import { useFormStyle } from "../../foundations/form.js";
7
8
  import { SurfaceProvider } from "../../foundations/surface.js";
8
9
  import { Line } from "../../primitives/block/Line.js";
9
10
  import { Tag } from "../../primitives/tag/Tag.js";
10
11
  import { useEffect, useRef } from "react";
11
12
  export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Icon, title, subtitle, tag, figure, railSurface = "canvas", smart, aspects, dirty, activity, activityLayout = "auto", width = "reading", ribbon, blocking, indicator, paper: onPaper, children, }) {
12
13
  const d = useDensity();
14
+ /* The «settings» form style (`FormStyleProvider`): Save and Discard float at the bottom
15
+ (`DirtyBar`) instead of taking the rail and the thumb bar, and the record has no white
16
+ sheet of its own — its sections are the cards, on the ground. */
17
+ const floating = useFormStyle() === "settings";
13
18
  /* «Guardado» is said where Save was; a record whose rail exists only while it has changes
14
19
  keeps it for that moment, or the answer would leave with the question. */
15
20
  const saved = useJustSaved(dirty);
21
+ const railDirty = floating ? undefined : dirty;
16
22
  /* Save is gone the moment it has saved, and the focus that was on it fell to the page —
17
23
  a keyboard was left at the top of the document. It comes back to the record's name:
18
24
  where reading the record starts, and announced together with «Guardado». */
@@ -24,12 +30,12 @@ export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Ico
24
30
  if (lost)
25
31
  nameRef.current?.focus({ preventScroll: true });
26
32
  }, [saved]);
27
- const hasRail = saved ||
33
+ const hasRail = (saved && !floating) ||
28
34
  crumbs !== undefined ||
29
35
  pager !== undefined ||
30
36
  actions !== undefined ||
31
37
  status !== undefined ||
32
- dirty !== undefined;
38
+ railDirty !== undefined;
33
39
  /* In compact the rail goes away ENTIRELY, and it is not for room: in a
34
40
  preview, the breadcrumbs and the pager belong to the surface that opened it
35
41
  —the list behind is still there— and the actions are already in the
@@ -42,7 +48,7 @@ export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Ico
42
48
  /* The activity column at the RIGHT of the sheet when the page is wide (THE PAGE). */
43
49
  const beside = activity !== undefined && activityLayout === "auto";
44
50
  /* The thumb bar's content (see THE THUMB BAR in `ThumbBar`): dirty first, else the primary. */
45
- const { rail: railActions, primaries, mode: thumb, } = thumbPlan({ withRail, actions, dirty });
51
+ const { rail: railActions, primaries, mode: thumb, } = thumbPlan({ withRail, actions, dirty: railDirty });
46
52
  /* In compact the TITLE is not drawn either, for the same reason as in
47
53
  `Listing`: the surface header already says it. Drawing it here showed it
48
54
  twice in the same 480 px drawer — and the name of a customer in this product
@@ -92,15 +98,15 @@ export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Ico
92
98
  it. The line wraps on a phone, so it is never pushed out of reach. */
93
99
  smart === undefined && indicator === undefined ? undefined : (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center justify-center gap-2", children: [smart, indicator] })), end: pager }), actions === undefined &&
94
100
  status === undefined &&
95
- dirty === undefined &&
96
- !saved ? null : (
101
+ railDirty === undefined &&
102
+ (!saved || floating) ? null : (
97
103
  /* Row 2 — WHAT I CAN DO and WHERE IT IS AT: actions stuck to the
98
104
  left edge, the history and the state stuck to the right one. No
99
105
  `flex-wrap`: wrapping split the row in two and the state ended up
100
106
  below the actions, which is another hierarchy. */
101
- _jsxs("div", { className: "flex min-w-0 items-start gap-x-4", children: [dirty !== undefined ? (_jsx("div", { className: "flex shrink-0 items-center gap-1.5 @max-handheld/record:hidden", children: _jsx(DirtyActions, { ...dirty }) })) : actions === undefined ? (_jsx(SavedMark, { saved: saved })) : (_jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [primaries.length === 0
107
+ _jsxs("div", { className: "flex min-w-0 items-start gap-x-4", children: [railDirty !== undefined ? (_jsx("div", { className: "flex shrink-0 items-center gap-1.5 @max-handheld/record:hidden", children: _jsx(DirtyActions, { ...railDirty }) })) : actions === undefined ? (floating ? null : (_jsx(SavedMark, { saved: saved }))) : (_jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [primaries.length === 0
102
108
  ? actions
103
- : railActions.map((node) => isPrimary(node) ? (_jsx("span", { "data-thumb-moves": "", className: "contents @max-handheld/record:hidden", children: node }, node.key)) : (node)), _jsx(SavedMark, { saved: saved })] })), status === undefined ? null : (_jsx("div", { className: "ml-auto flex min-w-0 flex-col items-end gap-1.5", children: status }))] }))] }) }) }) })) : null, paper ? (
109
+ : railActions.map((node) => isPrimary(node) ? (_jsx("span", { "data-thumb-moves": "", className: "contents @max-handheld/record:hidden", children: node }, node.key)) : (node)), floating ? null : _jsx(SavedMark, { saved: saved })] })), status === undefined ? null : (_jsx("div", { className: "ml-auto flex min-w-0 flex-col items-end gap-1.5", children: status }))] }))] }) }) }) })) : null, paper ? (
104
110
  /* ==================================================================== *
105
111
  * THE PAGE — [sheet | Actividad], on the ground.
106
112
  *
@@ -128,14 +134,14 @@ export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Ico
128
134
  * the application bar.
129
135
  * ==================================================================== */
130
136
  _jsx("div", { className: "bg-ground px-3 pt-3 pb-3", children: _jsx("div", { className: "@container/page", children: _jsxs("div", { className: `flex min-w-0 flex-col gap-3 ${column} ${beside
131
- ? "@beside/page:flex-row @beside/page:items-stretch @beside/page:justify-center @beside/page:gap-0"
137
+ ? `@beside/page:flex-row @beside/page:items-stretch @beside/page:justify-center ${floating ? "@beside/page:gap-4" : "@beside/page:gap-0"}`
132
138
  : ""}`, children: [_jsxs("div", { className: `flex min-w-0 flex-1 flex-col gap-3 ${beside && width === "reading"
133
139
  ? "mx-auto w-full max-w-(--container-sheet) @beside/page:mx-0"
134
- : ""}`, children: [blocking, _jsxs("div", { className: `relative flex min-w-0 flex-col overflow-clip rounded-box border border-line bg-surface ${beside ? "@beside/page:rounded-r-none" : ""}`, children: [ribbon, identity, children] }), activity !== undefined && activityLayout === "below" ? activity : null] }), beside ? (
140
+ : ""}`, children: [blocking, _jsxs("div", { className: `relative flex min-w-0 flex-col overflow-clip ${floating ? "" : "rounded-box border border-line bg-surface"} ${beside && !floating ? "@beside/page:rounded-r-none" : ""}`, children: [ribbon, identity, children] }), activity !== undefined && activityLayout === "below" ? activity : null] }), beside ? (
135
141
  /* After the sheet: the record first, what is around it second — in the
136
142
  reading order and on screen. */
137
143
  _jsx("div", { className: "mx-auto w-full max-w-(--container-sheet) min-w-0 @beside/page:mx-0 @beside/page:flex @beside/page:w-auto @beside/page:max-w-none @beside/page:shrink-0", children: activity })) : null] }) }) })) : (
138
144
  /* No paper (a modal, a drawer): one surface, no ground beside
139
145
  it — the band first, the record, and the activity below. */
140
- _jsxs("div", { className: "relative flex min-w-0 flex-1 flex-col overflow-clip bg-surface", children: [ribbon, blocking === undefined ? null : (_jsx("div", { className: byDensity(d, "px-4 pt-3.5", "pb-2"), children: blocking })), identity, children, activity === undefined ? null : (_jsx("div", { className: byDensity(d, "px-4 pb-4", "pb-2"), children: activity }))] })), thumb === null ? null : _jsx(ThumbBar, { mode: thumb, dirty: dirty, primaries: primaries })] }));
146
+ _jsxs("div", { className: "relative flex min-w-0 flex-1 flex-col overflow-clip bg-surface", children: [ribbon, blocking === undefined ? null : (_jsx("div", { className: byDensity(d, "px-4 pt-3.5", "pb-2"), children: blocking })), identity, children, activity === undefined ? null : (_jsx("div", { className: byDensity(d, "px-4 pb-4", "pb-2"), children: activity }))] })), thumb === null ? null : (_jsx(ThumbBar, { mode: thumb, dirty: railDirty, primaries: primaries })), floating ? _jsx(DirtyBar, { dirty: dirty, saved: saved }) : null] }));
141
147
  }
@@ -25,7 +25,8 @@ import { cloneElement, isValidElement } from "react";
25
25
  *
26
26
  * What goes in it is decided, not composed:
27
27
  *
28
- * 1. With `dirty`, the bar holds «sin guardar», Discard and Save — the same
28
+ * 1. With `dirty`, the bar holds Discard and Save — and why it cannot be saved yet, when
29
+ * it cannot (`blocked`) — the same
29
30
  * precedence the rail already has: while there are unsaved changes the
30
31
  * only things that can be done are confirm or throw them away.
31
32
  * 2. Otherwise, the action written with `role="primary"` and NOTHING else.
@@ -0,0 +1,29 @@
1
+ import type { Surface } from "../../foundations/types.js";
2
+ /**
3
+ * THE WAY INTO THE PALETTE, drawn — «Buscar… ⌘K».
4
+ *
5
+ * Context: a command palette that only opens with a key is a feature nobody finds. quipu's
6
+ * people asked for «a global search» while ⌘K already opened one. This is the visible door: it
7
+ * reads like a search field, it says the shortcut so the next time the hand goes to the
8
+ * keyboard, and pressing it calls `onSearch` — the application opens its palette there.
9
+ *
10
+ * It does NOT listen for the shortcut. The palette does (composer's ⌘K); a second listener here
11
+ * would open it twice, or open it in an application whose palette uses another key.
12
+ *
13
+ * Inside the phone drawer it closes the drawer first: the palette opens over the page, not
14
+ * over a drawer about to cover it.
15
+ */
16
+ export type SearchEntryProps = {
17
+ onSearch: () => void;
18
+ /** What it says. «Buscar…» by default; «Buscar socios…» when the palette searches one thing. */
19
+ label?: string;
20
+ /** The key the palette listens for together with ⌘ / Ctrl: `K` by default. `false` draws no
21
+ * shortcut — the palette has none, or it is not a ⌘ one. */
22
+ shortcut?: string | false;
23
+ /** `row` fills its column (the sidebar). `bar` sizes to its words, and on a phone folds to
24
+ * the magnifier alone (a bar on top). */
25
+ layout?: "row" | "bar";
26
+ /** By default the surface it sits on. */
27
+ surface?: Surface;
28
+ };
29
+ export declare function SearchEntry({ onSearch, label, shortcut, layout, surface, }: SearchEntryProps): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useSidebarDrawer } from "./sidebarDrawer.js";
4
+ import { useUiCopy } from "../../foundations/copy.js";
5
+ import { modShortcut, useKeyboardPlatform } from "../../foundations/shortcut.js";
6
+ import { useSurface } from "../../foundations/surface.js";
7
+ import { Search } from "lucide-react";
8
+ const SKIN = {
9
+ canvas: {
10
+ box: "border-ui-control-border bg-ui-control text-muted hover:border-line-strong hover:text-ink focus-visible:outline-primary",
11
+ keys: "border-line text-muted",
12
+ },
13
+ chrome: {
14
+ box: "border-chrome-ink/15 bg-chrome-ink/6 text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink focus-visible:outline-chrome-link",
15
+ keys: "border-chrome-ink/20 text-chrome-muted",
16
+ },
17
+ };
18
+ export function SearchEntry({ onSearch, label, shortcut = "K", layout = "row", surface, }) {
19
+ const copy = useUiCopy();
20
+ const sup = useSurface(surface);
21
+ const drawer = useSidebarDrawer();
22
+ const platform = useKeyboardPlatform();
23
+ const skin = SKIN[sup];
24
+ const keys = shortcut === false || platform === null ? null : modShortcut(shortcut, platform);
25
+ const bar = layout === "bar";
26
+ return (_jsxs("button", { type: "button", onClick: () => {
27
+ if (drawer?.isOpen === true)
28
+ drawer.close();
29
+ onSearch();
30
+ }, ...(keys === null ? {} : { "aria-keyshortcuts": keys.aria }), className: `flex h-(--size-control-sm) min-w-0 cursor-pointer items-center gap-2 rounded-ui-control border px-2 text-meta transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 ${bar ? "shrink-0 max-sm:w-(--size-control-sm) max-sm:justify-center" : "w-full"} ${skin.box}`, "data-ui": "search-entry", "data-surface": sup, children: [_jsx(Search, { className: "size-(--size-icon-md) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-left ${bar ? "max-sm:sr-only" : ""}`, children: label ?? copy.shell.search }), keys === null ? null : (
31
+ /* Seen, not heard: `aria-keyshortcuts` already tells a screen reader, and «⌘K» read
32
+ aloud is noise after the name. Not drawn for a finger: a phone has no ⌘. */
33
+ _jsx("kbd", { "aria-hidden": true, className: `shrink-0 rounded-control border px-1.5 font-mono text-micro pointer-coarse:hidden ${bar ? "max-sm:hidden" : ""} ${skin.keys}`, "data-ui": "search-entry.keys", children: keys.label }))] }));
34
+ }
@@ -1,4 +1,5 @@
1
1
  import { type BrandLogo } from "./brandMark.js";
2
+ import { type SearchEntryProps } from "./SearchEntry.js";
2
3
  import type { Surface } from "../../foundations/types.js";
3
4
  import type { LucideIcon } from "lucide-react";
4
5
  import type { ReactNode } from "react";
@@ -25,6 +26,9 @@ export type SidebarProps = {
25
26
  detail?: string;
26
27
  avatar?: string;
27
28
  };
29
+ /** «Buscar… ⌘K» under the product and the user: the application's palette, made visible.
30
+ * `onSearch` opens it; the palette keeps listening for its own key. */
31
+ search?: Omit<SearchEntryProps, "layout" | "surface">;
28
32
  /** The navigation: a `NavigationTree`. It scrolls; the top and the bottom stay. */
29
33
  children: ReactNode;
30
34
  /** The account, pinned to the bottom: change the password, view the site, sign out. */
@@ -36,4 +40,4 @@ export type SidebarProps = {
36
40
  /** `chrome` wears the brand's colour. By default the frame's `sidebarSurface`. */
37
41
  surface?: Surface;
38
42
  };
39
- export declare function Sidebar({ brand, user, children, actions, onAction, footer, surface, }: SidebarProps): import("react").JSX.Element;
43
+ export declare function Sidebar({ brand, user, search, children, actions, onAction, footer, surface, }: SidebarProps): import("react").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { BrandMark } from "./brandMark.js";
4
+ import { SearchEntry, } from "./SearchEntry.js";
4
5
  import { useSidebarDrawer } from "./sidebarDrawer.js";
5
6
  import { useUiCopy } from "../../foundations/copy.js";
6
7
  import { SurfaceProvider, useSurface } from "../../foundations/surface.js";
@@ -47,11 +48,11 @@ function Action({ action, skin, onAction, }) {
47
48
  drawer?.close();
48
49
  }, children: content }));
49
50
  }
50
- export function Sidebar({ brand, user, children, actions, onAction, footer, surface, }) {
51
+ export function Sidebar({ brand, user, search, children, actions, onAction, footer, surface, }) {
51
52
  const copy = useUiCopy();
52
53
  const sup = useSurface(surface);
53
54
  const skin = SKIN[sup];
54
- const head = brand !== undefined || user !== undefined;
55
+ const head = brand !== undefined || user !== undefined || search !== undefined;
55
56
  const foot = (actions !== undefined && actions.length > 0) || footer !== undefined;
56
- return (_jsx(SurfaceProvider, { value: sup, children: _jsxs("div", { "data-ui": "sidebar", "data-surface": sup, className: `flex h-full min-h-0 min-w-0 flex-col ${skin.root}`, children: [head ? (_jsxs("div", { className: `shrink-0 border-b pb-2 ${skin.line}`, children: [brand === undefined ? null : _jsx(Brand, { brand: brand, skin: skin }), user === undefined ? null : _jsx(User, { user: user, skin: skin })] })) : null, _jsx("div", { "data-ui": "sidebar.nav", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: children }), foot ? (_jsxs("div", { "data-ui": "sidebar.account", className: `flex shrink-0 flex-col gap-2 border-t p-2 ${skin.line}`, children: [actions === undefined || actions.length === 0 ? null : (_jsx("ul", { "aria-label": copy.shell.account, className: "flex flex-col gap-px", children: actions.map((action) => (_jsx("li", { children: _jsx(Action, { action: action, skin: skin, ...(onAction === undefined ? {} : { onAction }) }) }, action.id))) })), footer] })) : null] }) }));
57
+ return (_jsx(SurfaceProvider, { value: sup, children: _jsxs("div", { "data-ui": "sidebar", "data-surface": sup, className: `flex h-full min-h-0 min-w-0 flex-col ${skin.root}`, children: [head ? (_jsxs("div", { className: `shrink-0 border-b pb-2 ${skin.line}`, children: [brand === undefined ? null : _jsx(Brand, { brand: brand, skin: skin }), user === undefined ? null : _jsx(User, { user: user, skin: skin }), search === undefined ? null : (_jsx("div", { "data-ui": "sidebar.search", className: "px-2 pt-2", children: _jsx(SearchEntry, { ...search }) }))] })) : null, _jsx("div", { "data-ui": "sidebar.nav", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: children }), foot ? (_jsxs("div", { "data-ui": "sidebar.account", className: `flex shrink-0 flex-col gap-2 border-t p-2 ${skin.line}`, children: [actions === undefined || actions.length === 0 ? null : (_jsx("ul", { "aria-label": copy.shell.account, className: "flex flex-col gap-px", children: actions.map((action) => (_jsx("li", { children: _jsx(Action, { action: action, skin: skin, ...(onAction === undefined ? {} : { onAction }) }) }, action.id))) })), footer] })) : null] }) }));
57
58
  }
@@ -1,4 +1,5 @@
1
1
  import { type BrandLogo } from "./brandMark.js";
2
+ import { type SearchEntryProps } from "./SearchEntry.js";
2
3
  import { type MenuGroup } from "../../primitives/menu/Menu.js";
3
4
  import { type LucideIcon } from "lucide-react";
4
5
  import { type ReactNode } from "react";
@@ -18,7 +19,7 @@ export interface TopMenu {
18
19
  /** `columns` lays its sections side by side: a big module menu, seen whole. */
19
20
  layout?: "list" | "columns";
20
21
  }
21
- export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, systray, user, onUserSelect, userGroups, }: {
22
+ export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, search, systray, user, onUserSelect, userGroups, }: {
22
23
  /** The product's name, when there is ONE product. It is drawn like the
23
24
  * current app of the switcher —same icon, same weight— but without the
24
25
  * switcher: nothing to switch to. */
@@ -39,6 +40,9 @@ export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, curr
39
40
  * I» is answered without opening any of them. */
40
41
  currentMenu?: string;
41
42
  onMenuSelect?: (menuId: string, optionId: string) => void;
43
+ /** «Buscar… ⌘K» before the tray: the application's palette, made visible. On a phone it
44
+ * folds to the magnifier. `onSearch` opens the palette; the palette keeps its own key. */
45
+ search?: Omit<SearchEntryProps, "layout" | "surface">;
42
46
  /** What happened while I was not looking: activity, alerts. Icons with a count. */
43
47
  systray?: ReactNode;
44
48
  user?: {
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { BrandMark } from "./brandMark.js";
4
+ import { SearchEntry, } from "./SearchEntry.js";
4
5
  import { SidebarToggle } from "./sidebarDrawer.js";
5
6
  import { useUiCopy } from "../../foundations/copy.js";
6
7
  import { SurfaceProvider } from "../../foundations/surface.js";
@@ -9,11 +10,11 @@ import { Count, countText } from "../../primitives/tag/Count.js";
9
10
  import { Avatar } from "../../primitives/value/Person.js";
10
11
  import { Grid3x3 } from "lucide-react";
11
12
  import { useMemo, useState } from "react";
12
- export function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, systray, user, onUserSelect, userGroups, }) {
13
+ export function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, search, systray, user, onUserSelect, userGroups, }) {
13
14
  const copy = useUiCopy();
14
15
  const actual = apps?.find((a) => a.id === currentApp);
15
16
  const brand = app ?? actual;
16
- return (_jsx(SurfaceProvider, { value: "chrome", children: _jsxs("header", { "data-ui": "topbar", className: "flex h-(--size-appbar) min-w-0 items-center gap-1 border-b border-chrome-edge bg-chrome px-2", children: [_jsx(SidebarToggle, {}), apps === undefined || apps.length === 0 ? null : (_jsx(AppSwitcher, { apps: apps, current: currentApp, ...(onAppSelect === undefined ? {} : { onSelect: onAppSelect }) })), brand === undefined ? null : (_jsxs("span", { "data-ui": "topbar.brand", className: "flex shrink-0 items-center gap-2 pr-2 pl-1", children: ["logo" in brand && brand.logo !== undefined ? (_jsx(BrandMark, { logo: brand.logo, className: "size-(--size-control-sm) shrink-0" })) : brand.icon === undefined ? null : (_jsx(brand.icon, { className: "size-(--size-icon-md) text-chrome-link", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "text-lead font-medium text-chrome-ink", children: brand.label })] })), menus === undefined ? null : (_jsx("nav", { "data-ui": "topbar.menus", className: "scroll-quiet flex min-w-0 items-center gap-0.5", "aria-label": copy.shell.menus, children: menus.map((m) => (_jsx(Menu, { label: m.label, groups: m.groups, surface: "chrome", variant: "text", chevron: false, current: m.id === currentMenu, ...(m.layout === undefined ? {} : { layout: m.layout }), ...(m.count === undefined ? {} : { count: m.count }), onSelect: (id) => onMenuSelect?.(m.id, id) }, m.id))) })), _jsxs("div", { "data-ui": "topbar.actions", className: "ml-auto flex shrink-0 items-center gap-1 pl-2", children: [systray, user === undefined ? null : (_jsx(UserMenu, { name: user.name, ...(user.detail === undefined ? {} : { detail: user.detail }), groups: userGroups ?? [], ...(onUserSelect === undefined ? {} : { onSelect: onUserSelect }) }))] })] }) }));
17
+ return (_jsx(SurfaceProvider, { value: "chrome", children: _jsxs("header", { "data-ui": "topbar", className: "flex h-(--size-appbar) min-w-0 items-center gap-1 border-b border-chrome-edge bg-chrome px-2", children: [_jsx(SidebarToggle, {}), apps === undefined || apps.length === 0 ? null : (_jsx(AppSwitcher, { apps: apps, current: currentApp, ...(onAppSelect === undefined ? {} : { onSelect: onAppSelect }) })), brand === undefined ? null : (_jsxs("span", { "data-ui": "topbar.brand", className: "flex shrink-0 items-center gap-2 pr-2 pl-1", children: ["logo" in brand && brand.logo !== undefined ? (_jsx(BrandMark, { logo: brand.logo, className: "size-(--size-control-sm) shrink-0" })) : brand.icon === undefined ? null : (_jsx(brand.icon, { className: "size-(--size-icon-md) text-chrome-link", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "text-lead font-medium text-chrome-ink", children: brand.label })] })), menus === undefined ? null : (_jsx("nav", { "data-ui": "topbar.menus", className: "scroll-quiet flex min-w-0 items-center gap-0.5", "aria-label": copy.shell.menus, children: menus.map((m) => (_jsx(Menu, { label: m.label, groups: m.groups, surface: "chrome", variant: "text", chevron: false, current: m.id === currentMenu, ...(m.layout === undefined ? {} : { layout: m.layout }), ...(m.count === undefined ? {} : { count: m.count }), onSelect: (id) => onMenuSelect?.(m.id, id) }, m.id))) })), _jsxs("div", { "data-ui": "topbar.actions", className: "ml-auto flex shrink-0 items-center gap-1 pl-2", children: [search === undefined ? null : _jsx(SearchEntry, { ...search, layout: "bar" }), systray, user === undefined ? null : (_jsx(UserMenu, { name: user.name, ...(user.detail === undefined ? {} : { detail: user.detail }), groups: userGroups ?? [], ...(onUserSelect === undefined ? {} : { onSelect: onUserSelect }) }))] })] }) }));
17
18
  }
18
19
  /** The app switcher: a grid, not a list.
19
20
  *