@sincpro/web-ui 2.2.0 → 2.3.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.
- package/README.md +69 -3
- package/dist/components/board/Board.js +1 -1
- package/dist/components/listing/GroupingLevels.js +11 -9
- package/dist/components/listing/RecordCard.js +1 -1
- package/dist/components/navigation/NavigationTree.js +36 -9
- package/dist/components/search/CriteriaBuilder.js +3 -2
- package/dist/components/search/CriteriaChips.js +6 -5
- package/dist/components/search/JoinWord.js +1 -1
- package/dist/components/search/SearchBar.js +41 -25
- package/dist/components/shell/AppFrame.d.ts +10 -1
- package/dist/components/shell/AppFrame.js +53 -10
- package/dist/components/shell/Sidebar.d.ts +8 -3
- package/dist/components/shell/Sidebar.js +36 -11
- package/dist/components/shell/TopBar.d.ts +8 -1
- package/dist/components/shell/TopBar.js +6 -5
- package/dist/components/shell/brandMark.d.ts +17 -0
- package/dist/components/shell/brandMark.js +9 -0
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +2 -0
- package/dist/foundations/copy.es.js +3 -3
- package/dist/foundations/copy.js +3 -3
- package/dist/foundations/variants.js +19 -2
- package/dist/primitives/block/Block.js +1 -1
- package/dist/primitives/button/Button.d.ts +3 -1
- package/dist/primitives/button/Button.js +6 -6
- package/dist/primitives/choice/SegmentedControl.d.ts +4 -1
- package/dist/primitives/choice/SegmentedControl.js +35 -7
- package/dist/primitives/dialog/Dialog.d.ts +1 -1
- package/dist/primitives/dialog/Dialog.js +2 -2
- package/dist/primitives/field/CardNumberInput.js +1 -1
- package/dist/primitives/field/Checks.d.ts +14 -0
- package/dist/primitives/field/Checks.js +12 -4
- package/dist/primitives/field/DurationInput.js +1 -1
- package/dist/primitives/field/Field.js +7 -7
- package/dist/primitives/field/PatternInput.js +1 -1
- package/dist/primitives/field/RichTextEditor.js +2 -2
- package/dist/primitives/field/SignatureInput.js +1 -1
- package/dist/primitives/field/aria.d.ts +2 -2
- package/dist/primitives/field/aria.js +5 -5
- package/dist/primitives/field/index.d.ts +1 -1
- package/dist/primitives/field/index.js +1 -1
- package/dist/primitives/menu/Menu.d.ts +23 -7
- package/dist/primitives/menu/Menu.js +76 -22
- package/dist/primitives/overlay/Popover.js +2 -2
- package/dist/primitives/picker/Picker.js +3 -3
- package/dist/primitives/picker/TagsField.js +1 -1
- package/dist/primitives/table/EditableTable.js +2 -2
- package/dist/primitives/table/ReportTable.js +1 -1
- package/dist/primitives/table/Table.js +2 -2
- package/dist/primitives/tag/Tag.d.ts +9 -0
- package/dist/primitives/tag/Tag.js +14 -1
- package/dist/primitives/tag/Tags.js +6 -7
- package/dist/primitives/value/Metric.js +4 -4
- package/dist/tokens.css +163 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -145,19 +145,85 @@ on `:root`, and every palette — light, dark, and a light subtree inside a dark
|
|
|
145
145
|
--brand-chrome: #10203f; /* the application bar */
|
|
146
146
|
--brand-chrome-raised: #1a2c52;
|
|
147
147
|
--brand-chrome-edge: #10203f;
|
|
148
|
+
--brand-ground: #f7f8fa; /* the page's paper */
|
|
149
|
+
--brand-surface: #ffffff; /* raised boxes, menus */
|
|
148
150
|
|
|
149
151
|
--brand-dark-accent: #e0b850; /* the same, for the dark palette */
|
|
150
152
|
--brand-dark-chrome: #0a1428;
|
|
153
|
+
--brand-dark-ground: #121417;
|
|
154
|
+
|
|
155
|
+
--brand-radius: 0.5; /* the corners: 0 square everywhere · 1 the system's · 1.5 rounder */
|
|
151
156
|
}
|
|
152
157
|
```
|
|
153
158
|
|
|
154
|
-
The full list is `
|
|
155
|
-
`
|
|
156
|
-
|
|
159
|
+
The full list is `ground`, `surface`, `line`, `line-strong`, `ink`, `muted`, `accent`,
|
|
160
|
+
`accent-hover`, `on-accent`, `primary`, `primary-hover`, `chrome`, `chrome-raised`, `chrome-edge`,
|
|
161
|
+
`chrome-accent` and `chrome-link`; `--brand-<token>` is the light palette's and
|
|
162
|
+
`--brand-dark-<token>` the dark's. One left unset keeps the system's value. Do not
|
|
157
163
|
override `--color-*` directly: those are redefined per theme, so an override on `:root` loses to
|
|
158
164
|
`[data-theme="light"]` and leaks into the dark palette. The system measures its own contrasts;
|
|
159
165
|
your brand's are checked by Storybook's a11y pass if you render your stories with it.
|
|
160
166
|
|
|
167
|
+
The corners are one knob: `--brand-radius` multiplies the whole radius scale (`mark`, `control`,
|
|
168
|
+
`box`, `panel`, `pill`), so the steps keep their proportion and a dropdown stays concentric with
|
|
169
|
+
its rows. `0` squares everything, the capsules too. A single step can still be set on its own —
|
|
170
|
+
`--brand-radius-control: 6px`. Both go on `:root`.
|
|
171
|
+
|
|
172
|
+
#### Customizing a component
|
|
173
|
+
|
|
174
|
+
The brand changes the whole product. To change **one component** — square buttons for a
|
|
175
|
+
till, a cooler menu, cards without a border — set its `--ui-*` tokens, on `:root` for the
|
|
176
|
+
whole application or on any element for a zone. Each one falls back to the system's token, so
|
|
177
|
+
setting nothing changes nothing, and each resolves on the element, so the dark theme still
|
|
178
|
+
follows:
|
|
179
|
+
|
|
180
|
+
```css
|
|
181
|
+
:root {
|
|
182
|
+
--ui-button-radius: 0;
|
|
183
|
+
--ui-popover-bg: var(--color-ground);
|
|
184
|
+
}
|
|
185
|
+
.till {
|
|
186
|
+
--ui-control-radius: 0; /* only inside this zone */
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
| Component | Tokens |
|
|
191
|
+
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
192
|
+
| `Button`, `ButtonLink` | `--ui-button-radius` |
|
|
193
|
+
| `IconButton`, `IconLink` | `--ui-icon-button-radius` |
|
|
194
|
+
| Inputs, selects, date and pickers' boxes | `--ui-control-radius`, `--ui-control-bg`, `--ui-control-border` |
|
|
195
|
+
| Menus, lists, popovers, the cuts panel | `--ui-popover-radius`, `--ui-popover-bg`, `--ui-popover-border`, `--ui-popover-shadow` |
|
|
196
|
+
| A row inside them (menu item, option) | `--ui-option-radius`, `--ui-option-active-bg` |
|
|
197
|
+
| `Dialog` | `--ui-dialog-radius`, `--ui-dialog-bg` |
|
|
198
|
+
| `Block`, `RecordCard`, `BoardTile`, `Metric` | `--ui-card-radius`, `--ui-card-bg`, `--ui-card-border` |
|
|
199
|
+
| `Tag`, `Tags`, the search bar's chips | `--ui-tag-radius` |
|
|
200
|
+
| `SearchBar`'s field | `--ui-search-radius` (and the control's bg and border) |
|
|
201
|
+
| The sidebar on the canvas | `--ui-sidebar-bg`, `--ui-sidebar-border` |
|
|
202
|
+
| `NavigationTree` | `--ui-nav-radius`, `--ui-nav-current-bg` |
|
|
203
|
+
| Table headers (`DataTable`, `EditableTable`, `ReportTable`) | `--ui-table-head-bg` |
|
|
204
|
+
|
|
205
|
+
What a token does not cover, a **part** does. Every customizable piece names its root
|
|
206
|
+
`data-ui="<component>"` and its parts `data-ui="<component>.<part>"`, with its variant beside
|
|
207
|
+
(`data-emphasis`, `data-size`, `data-surface`, `data-tone`) — stable names for your CSS, instead
|
|
208
|
+
of classes that change with the next refactor:
|
|
209
|
+
|
|
210
|
+
```css
|
|
211
|
+
[data-ui="button"][data-emphasis="primary"] {
|
|
212
|
+
letter-spacing: 0.02em;
|
|
213
|
+
}
|
|
214
|
+
[data-ui="popover"] {
|
|
215
|
+
backdrop-filter: blur(8px);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`,
|
|
220
|
+
`menu.section`, `menu.item`, `menu.fold`, `dialog`, `block`, `record-card`, `board.tile`,
|
|
221
|
+
`metric`, `tag`, `tags.item`, `search`, `search.field`, `search.chip`, `search.panel`,
|
|
222
|
+
`search.suggestions`, `table`, `table.head`, `topbar`, `topbar.brand`, `topbar.menus`,
|
|
223
|
+
`topbar.actions`, `topbar.user`, `frame`, `frame.bar`, `frame.sidebar`, `frame.main`, `sidebar`,
|
|
224
|
+
`sidebar.brand`, `sidebar.user`, `sidebar.nav`, `sidebar.account`, `navigation`,
|
|
225
|
+
`navigation.item`. Put your rules in a cascade layer above web-ui's, or outside any layer.
|
|
226
|
+
|
|
161
227
|
#### Living beside a site's own CSS
|
|
162
228
|
|
|
163
229
|
The package's styles are in cascade layers (`@layer base`, `utilities`), and **CSS outside any
|
|
@@ -31,7 +31,7 @@ const SPAN = {
|
|
|
31
31
|
/** One tile of a `Board`: a titled surface around a chart, a list or a number. */
|
|
32
32
|
export function BoardTile({ title, description, actions, span = 1, state = READY, children, }) {
|
|
33
33
|
const copy = useUiCopy();
|
|
34
|
-
return (_jsxs("section", { "aria-label": title, ...(state.status === "loading" ? { "aria-busy": true } : {}), className: `flex min-w-0 flex-col gap-4 rounded-
|
|
34
|
+
return (_jsxs("section", { "aria-label": title, ...(state.status === "loading" ? { "aria-busy": true } : {}), "data-ui": "board.tile", className: `flex min-w-0 flex-col gap-4 rounded-ui-card border border-line-strong bg-ui-card p-4 ${SPAN[span]}`, children: [_jsxs("header", { className: "flex min-w-0 items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h2", { className: "text-lead font-semibold text-ink", children: title }), description === undefined ? null : (_jsx("p", { className: "mt-0.5 text-meta text-muted", children: description }))] }), actions === undefined ? null : (_jsx("div", { className: "flex shrink-0 items-center gap-1", children: actions }))] }), state.status === "loading" ? (
|
|
35
35
|
/* A quiet block where the chart goes. It appears late, like every skeleton: a fast
|
|
36
36
|
read never shows it. */
|
|
37
37
|
_jsx("div", { className: "min-h-(--size-tile-body) animate-reveal-late rounded-control bg-ink/4", children: _jsx("span", { className: "sr-only", children: copy.failed.loading }) })) : state.status === "failed" ? (_jsx("div", { className: "flex min-h-(--size-tile-body) flex-col justify-center", children: _jsx(Failure, { heading: fillCopy(copy.board.tileFailed, { title }), state: state }) })) : (children)] }));
|
|
@@ -4,6 +4,9 @@ import { FieldPath } from "../search/FieldPath.js";
|
|
|
4
4
|
import { grainName } from "../../foundations/calendar.js";
|
|
5
5
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
6
6
|
import { GRAIN_ORDER, levelKey, } from "../../foundations/grouping.js";
|
|
7
|
+
import { CheckMark } from "../../primitives/field/Checks.js";
|
|
8
|
+
import { Count } from "../../primitives/tag/Count.js";
|
|
9
|
+
import { chosenTone } from "../../primitives/tag/Tag.js";
|
|
7
10
|
import { ChevronDown, ChevronRight, ChevronUp, Plus, X } from "lucide-react";
|
|
8
11
|
import { useState } from "react";
|
|
9
12
|
function fieldLabel(fields, field) {
|
|
@@ -21,28 +24,27 @@ export function GroupingLevels({ fields, control, grainLabel, addPath, }) {
|
|
|
21
24
|
const grain = (one) => grainLabel?.(one) ?? grainName(one);
|
|
22
25
|
const isOpen = (field) => opened.includes(field);
|
|
23
26
|
const toggleOpen = (field) => setOpened((current) => current.includes(field) ? current.filter((one) => one !== field) : [...current, field]);
|
|
24
|
-
return (_jsxs("div", { className: "flex flex-col gap-0.5", children: [placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("ol", { className: "flex flex-wrap gap-1 px-1 pb-1.5", children: placed.map((level, index) => (_jsx("li", { children: _jsxs("span", { className:
|
|
27
|
+
return (_jsxs("div", { className: "flex flex-col gap-0.5", children: [placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("ol", { className: "flex flex-wrap gap-1 px-1 pb-1.5", children: placed.map((level, index) => (_jsx("li", { children: _jsxs("span", { "data-ui": "search.chip", className: `inline-flex items-center gap-1 rounded-ui-tag py-0.5 pr-0.5 pl-1.5 text-micro ${chosenTone("canvas")}`, children: [_jsx("span", { className: "tabular-nums opacity-70", children: index + 1 }), _jsxs("span", { className: "max-w-32 truncate", children: [fieldLabel(fields, level.field), level.grain === undefined ? "" : ` · ${grain(level.grain)}`] }), _jsx("button", { type: "button", onClick: () => control.move(level.field, -1), disabled: index === 0, "aria-label": copy.grouping.up, title: copy.grouping.up, className: "rounded-pill p-0.5 hover:bg-primary/15 disabled:opacity-30 disabled:hover:bg-transparent", children: _jsx(ChevronUp, { className: "size-3", strokeWidth: 2.5 }) }), _jsx("button", { type: "button", onClick: () => control.move(level.field, 1), disabled: index === placed.length - 1, "aria-label": copy.grouping.down, title: copy.grouping.down, className: "rounded-pill p-0.5 hover:bg-primary/15 disabled:opacity-30 disabled:hover:bg-transparent", children: _jsx(ChevronDown, { className: "size-3", strokeWidth: 2.5 }) }), _jsx("button", { type: "button", onClick: () => control.remove(level.field, level.grain), "aria-label": copy.grouping.remove, title: copy.grouping.remove, className: "rounded-pill p-0.5 hover:bg-primary/15", children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) })] }) }, levelKey(level)))) }), _jsx("div", { className: "mb-1 h-px bg-line", role: "separator" })] })), fields.map((one) => {
|
|
25
28
|
const grains = one.grains;
|
|
26
29
|
/* An ordinary field: a checkbox and nothing more. */
|
|
27
30
|
if (grains === undefined || grains.length === 0) {
|
|
28
31
|
const on = control.has(one.field);
|
|
29
|
-
return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field), "aria-pressed": on, className:
|
|
32
|
+
return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field), "aria-pressed": on, className: "flex items-center gap-2 rounded-ui-option px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-ui-option-active", children: [_jsx(Mark, { on: on }), _jsx("span", { className: `min-w-0 truncate text-meta ${on ? "font-medium text-ink" : "text-ink"}`, children: one.label })] }, one.field));
|
|
30
33
|
}
|
|
31
34
|
/* A DATE: it unfolds and offers its cuts as checkboxes. */
|
|
32
35
|
const open = isOpen(one.field);
|
|
33
36
|
const puestos = placed.filter((level) => level.field === one.field);
|
|
34
|
-
return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("button", { type: "button", onClick: () => toggleOpen(one.field), "aria-expanded": open, className: "flex items-center gap-1.5 rounded-
|
|
37
|
+
return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("button", { type: "button", onClick: () => toggleOpen(one.field), "aria-expanded": open, className: "flex items-center gap-1.5 rounded-ui-option px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-ui-option-active", children: [_jsx(ChevronRight, { className: `size-(--size-icon-sm) shrink-0 text-muted transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-meta ${puestos.length > 0 ? "font-medium text-ink" : "text-ink"}`, children: one.label }), puestos.length === 0 ? null : _jsx(Count, { value: puestos.length })] }), !open ? null : (_jsx("div", { className: "flex flex-col pl-(--spacing-indent)", children: GRAIN_ORDER.filter((g) => grains.includes(g)).map((g) => {
|
|
35
38
|
const on = control.has(one.field, g);
|
|
36
|
-
return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field, g), "aria-pressed": on, className:
|
|
39
|
+
return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field, g), "aria-pressed": on, className: "flex items-center gap-2 rounded-ui-option px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-ui-option-active", children: [_jsx(Mark, { on: on }), _jsx("span", { className: `min-w-0 truncate text-meta ${on ? "font-medium text-ink" : "text-muted"}`, children: grain(g) })] }, g));
|
|
37
40
|
}) }))] }, one.field));
|
|
38
41
|
}), addPath === undefined ? null : (_jsx("div", { className: "px-1 pt-1", children: _jsx(FieldPath, { look: "button", icon: Plus, model: addPath.model, ...(addPath.loadModel === undefined ? {} : { loadModel: addPath.loadModel }), ...(addPath.filter === undefined ? {} : { filter: addPath.filter }), ...(addPath.followRelations === undefined
|
|
39
42
|
? {}
|
|
40
43
|
: { followRelations: addPath.followRelations }), value: [], label: copy.fieldPath.addLevel, placeholder: copy.fieldPath.addLevel, onChange: addPath.onPick }) })), placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-1 h-px bg-line", role: "separator" }), _jsx("button", { type: "button", onClick: () => control.clear(), className: "rounded-control px-2 py-1 text-left text-meta text-muted transition-colors duration-(--duration-instant) hover:bg-ink/4 hover:text-ink", children: copy.grouping.clear })] }))] }));
|
|
41
44
|
}
|
|
42
|
-
/** The tick mark. The column ALWAYS exists, ticked or not: without it,
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* checkboxes and not as loose text with a gap on the left. */
|
|
45
|
+
/** The tick mark. The column ALWAYS exists, ticked or not: without it, ticking shifts the
|
|
46
|
+
* text and the list jumps. It is `Checkbox`'s box, the same as the filters column, so both
|
|
47
|
+
* columns read as the multiple choice they are. */
|
|
46
48
|
function Mark({ on }) {
|
|
47
|
-
return (_jsx("span", { className: "flex size-(--size-icon-sm) shrink-0 items-center justify-center", children:
|
|
49
|
+
return (_jsx("span", { className: "flex size-(--size-icon-sm) shrink-0 items-center justify-center", children: _jsx(CheckMark, { on: on }) }));
|
|
48
50
|
}
|
|
@@ -20,7 +20,7 @@ export function RecordCard({ title, subtitle, tags, meta, figure, media, footer,
|
|
|
20
20
|
kanban state inside it would be a control inside a control, which is invalid and which a
|
|
21
21
|
screen reader announces as one thing. The footer's controls sit above the stretch. */
|
|
22
22
|
const titleText = _jsx("span", { className: "min-w-0 truncate", children: title });
|
|
23
|
-
return (_jsxs("div", { className: `relative flex w-full min-w-0 flex-col gap-2 rounded-
|
|
23
|
+
return (_jsxs("div", { "data-ui": "record-card", className: `relative flex w-full min-w-0 flex-col gap-2 rounded-ui-card border border-ui-card-border bg-ui-card p-4 text-left ${onOpen === undefined
|
|
24
24
|
? ""
|
|
25
25
|
: "transition-colors duration-(--duration-instant) focus-within:border-line-strong hover:border-line-strong"}`, children: [media === undefined ? null : media.person === true ? (
|
|
26
26
|
/* The name is written right below it: the photo's `alt` would say it twice. */
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { AriaLocale } from "../../foundations/aria.js";
|
|
4
4
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
5
|
+
import { useSurface } from "../../foundations/surface.js";
|
|
5
6
|
import { focusRing, tv } from "../../foundations/variants.js";
|
|
6
7
|
import { Count } from "../../primitives/tag/Count.js";
|
|
7
8
|
import { ChevronRight } from "lucide-react";
|
|
@@ -9,13 +10,23 @@ import { useMemo } from "react";
|
|
|
9
10
|
import { Button as AriaButton, Link, NavigationTree as AriaNavigationTree, NavigationTreeItem as AriaNavigationTreeItem, NavigationTreeItemContent, RouterProvider, } from "react-aria-components";
|
|
10
11
|
const row = tv({
|
|
11
12
|
extend: focusRing,
|
|
12
|
-
base: "group relative flex min-w-0 items-center rounded-
|
|
13
|
+
base: "group relative flex min-w-0 items-center rounded-ui-nav text-meta outline-offset-0 select-none",
|
|
13
14
|
variants: {
|
|
15
|
+
surface: {
|
|
16
|
+
canvas: "text-ink",
|
|
17
|
+
chrome: "text-chrome-ink outline-chrome-link",
|
|
18
|
+
},
|
|
14
19
|
isCurrent: {
|
|
15
|
-
true: "
|
|
16
|
-
false: "
|
|
20
|
+
true: "font-medium forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
|
|
21
|
+
false: "",
|
|
17
22
|
},
|
|
18
23
|
},
|
|
24
|
+
compoundVariants: [
|
|
25
|
+
{ surface: "canvas", isCurrent: true, class: "bg-ui-nav-current text-primary" },
|
|
26
|
+
{ surface: "canvas", isCurrent: false, class: "hover:bg-ink/6" },
|
|
27
|
+
{ surface: "chrome", isCurrent: true, class: "bg-chrome-link/15 text-chrome-link" },
|
|
28
|
+
{ surface: "chrome", isCurrent: false, class: "hover:bg-chrome-ink/10" },
|
|
29
|
+
],
|
|
19
30
|
});
|
|
20
31
|
const link = tv({
|
|
21
32
|
base: "flex h-(--size-control-sm) min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 text-current no-underline outline-0",
|
|
@@ -25,11 +36,26 @@ const link = tv({
|
|
|
25
36
|
});
|
|
26
37
|
const chevronButton = tv({
|
|
27
38
|
extend: focusRing,
|
|
28
|
-
base: "mr-1 inline-flex shrink-0 items-center justify-center rounded-mark p-1
|
|
39
|
+
base: "mr-1 inline-flex shrink-0 items-center justify-center rounded-mark p-1 transition-colors duration-(--duration-instant)",
|
|
40
|
+
variants: {
|
|
41
|
+
surface: {
|
|
42
|
+
canvas: "text-muted hover:bg-ink/6 hover:text-ink pressed:bg-ink/10",
|
|
43
|
+
chrome: "text-chrome-muted outline-chrome-link hover:bg-chrome-ink/10 hover:text-chrome-ink pressed:bg-chrome-ink/15",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
29
46
|
});
|
|
30
47
|
/** The marker of the current row: a bar on the leading edge, so the spot reads in the
|
|
31
48
|
* margin before the label is read. */
|
|
32
|
-
const
|
|
49
|
+
const MARKER = {
|
|
50
|
+
canvas: "absolute inset-y-1 start-0 w-0.5 rounded-pill bg-primary forced-colors:bg-[HighlightText]",
|
|
51
|
+
chrome: "absolute inset-y-1 start-0 w-0.5 rounded-pill bg-chrome-link forced-colors:bg-[HighlightText]",
|
|
52
|
+
};
|
|
53
|
+
/** The colour of what is «here» — the current row's icon, a folded module that holds it —
|
|
54
|
+
* and of what is not. */
|
|
55
|
+
const HERE = {
|
|
56
|
+
canvas: { here: "text-primary", rest: "text-muted" },
|
|
57
|
+
chrome: { here: "text-chrome-link", rest: "text-chrome-muted" },
|
|
58
|
+
};
|
|
33
59
|
/** The ids of every module on the way to `id`, so the row you are on is never folded away. */
|
|
34
60
|
function pathTo(items, id) {
|
|
35
61
|
if (id === undefined)
|
|
@@ -55,6 +81,7 @@ function pathTo(items, id) {
|
|
|
55
81
|
*/
|
|
56
82
|
export function NavigationTree({ items, current, onNavigate, defaultExpanded = [], label, }) {
|
|
57
83
|
const copy = useUiCopy();
|
|
84
|
+
const surface = useSurface();
|
|
58
85
|
const expanded = useMemo(() => [...new Set([...defaultExpanded, ...pathTo(items, current)])],
|
|
59
86
|
// The initial state only: React Aria owns the expansion after the first render.
|
|
60
87
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -71,9 +98,9 @@ export function NavigationTree({ items, current, onNavigate, defaultExpanded = [
|
|
|
71
98
|
paddingInlineStart: `calc(var(--spacing) * 4 + var(--size-icon-md) + var(--spacing-indent) * ${level - 2})`,
|
|
72
99
|
}
|
|
73
100
|
: undefined;
|
|
74
|
-
return (_jsxs(AriaNavigationTreeItem, { id: item.id, textValue: item.label, ...(module ? {} : { href: item.id }), className: ({ isCurrent, isFocusVisible }) => row({ isCurrent, isFocusVisible }), children: [_jsx(NavigationTreeItemContent, { children: ({ isCurrent, isCurrentAncestor, isExpanded }) => (_jsxs(_Fragment, { children: [isCurrent ? _jsx("span", { "aria-hidden": true, className:
|
|
75
|
-
?
|
|
76
|
-
:
|
|
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)
|
|
102
|
+
? HERE[surface].here
|
|
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));
|
|
77
104
|
};
|
|
78
|
-
return (_jsx(AriaLocale, { children: _jsx(RouterProvider, { navigate: (id) => onNavigate?.(id), useHref: (id) => `#${id}`, children: _jsx(AriaNavigationTree, { "aria-label": label ?? copy.shell.menus, selectedRoute: current ?? null, defaultExpandedKeys: expanded, className: "flex w-full min-w-0 flex-col gap-px p-2 outline-0", children: items.map((item) => render(item, 1)) }) }) }));
|
|
105
|
+
return (_jsx(AriaLocale, { children: _jsx(RouterProvider, { navigate: (id) => onNavigate?.(id), useHref: (id) => `#${id}`, children: _jsx(AriaNavigationTree, { "data-ui": "navigation", "aria-label": label ?? copy.shell.menus, selectedRoute: current ?? null, defaultExpandedKeys: expanded, className: "flex w-full min-w-0 flex-col gap-px p-2 outline-0", children: items.map((item) => render(item, 1)) }) }) }));
|
|
79
106
|
}
|
|
@@ -8,6 +8,7 @@ import { GRAIN_ORDER } from "../../foundations/grouping.js";
|
|
|
8
8
|
import { useSurface } from "../../foundations/surface.js";
|
|
9
9
|
import { Rule } from "../../primitives/block/Block.js";
|
|
10
10
|
import { Button } from "../../primitives/button/index.js";
|
|
11
|
+
import { chosenTone } from "../../primitives/tag/Tag.js";
|
|
11
12
|
import { Tags } from "../../primitives/tag/Tags.js";
|
|
12
13
|
import { Plus, Trash2 } from "lucide-react";
|
|
13
14
|
import { Fragment, useMemo, useState } from "react";
|
|
@@ -56,7 +57,7 @@ function AddTag({ label, options, onPick, }) {
|
|
|
56
57
|
const [open, setOpen] = useState(false);
|
|
57
58
|
if (options.length === 0)
|
|
58
59
|
return null;
|
|
59
|
-
return (_jsxs("span", { className: "relative inline-flex shrink-0", children: [_jsxs("button", { type: "button", onClick: () => setOpen((current) => !current), "aria-expanded": open, className: "inline-flex shrink-0 items-center gap-1 rounded-pill border border-dashed border-line-strong px-2 py-0.5 text-micro text-muted transition-colors duration-(--duration-instant) hover:border-line-strong hover:bg-ink/5 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: [_jsx(Plus, { className: "size-3", strokeWidth: 2, "aria-hidden": true }), label] }), open ? (_jsx("span", { className: "absolute top-full left-0 z-40 mt-1 max-h-64 overflow-y-auto rounded-
|
|
60
|
+
return (_jsxs("span", { className: "relative inline-flex shrink-0", children: [_jsxs("button", { type: "button", onClick: () => setOpen((current) => !current), "aria-expanded": open, className: "inline-flex shrink-0 items-center gap-1 rounded-pill border border-dashed border-line-strong px-2 py-0.5 text-micro text-muted transition-colors duration-(--duration-instant) hover:border-line-strong hover:bg-ink/5 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: [_jsx(Plus, { className: "size-3", strokeWidth: 2, "aria-hidden": true }), label] }), open ? (_jsx("span", { "data-ui": "popover", className: "absolute top-full left-0 z-40 mt-1 max-h-64 overflow-y-auto rounded-ui-popover border border-ui-popover-border bg-ui-popover p-1 shadow-ui-popover", children: _jsx(Tags, { stack: true, label: label, items: options.map((name) => ({
|
|
60
61
|
id: name,
|
|
61
62
|
label: name,
|
|
62
63
|
onSelect: () => {
|
|
@@ -283,6 +284,6 @@ export function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }) {
|
|
|
283
284
|
const chosen = fields.includes(name);
|
|
284
285
|
return (_jsx("button", { type: "button", onClick: () => push({
|
|
285
286
|
fields: chosen ? fields.filter((one) => one !== name) : [...fields, name],
|
|
286
|
-
}), className: `rounded-pill border px-2 py-0.5 text-micro ${chosen ? "
|
|
287
|
+
}), className: `rounded-pill border px-2 py-0.5 text-micro ${chosen ? chosenTone("canvas") : `text-muted ${box}`}`, children: name }, name));
|
|
287
288
|
}) })] }), _jsx(LazyJsonEditor, { value: rawText, onChange: updateRaw, error: rawError, height: "14rem", label: copy.builder.json }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { role: "primary", disabled: rawError !== null, onClick: () => onApply(rawText.trim() === "" ? undefined : JSON.parse(rawText)), children: copy.builder.apply }), onCancel === undefined ? null : (_jsx(Button, { role: "ghost", onClick: onCancel, children: copy.builder.cancel }))] })] }));
|
|
288
289
|
}
|
|
@@ -4,6 +4,7 @@ import { filtersOf, groupsOf, } from "./criteria.js";
|
|
|
4
4
|
import { JoinWord } from "./JoinWord.js";
|
|
5
5
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
6
6
|
import { bySurface, useSurface } from "../../foundations/surface.js";
|
|
7
|
+
import { chosenTone } from "../../primitives/tag/Tag.js";
|
|
7
8
|
import { ChevronRight, Layers, X } from "lucide-react";
|
|
8
9
|
import { Fragment, useState } from "react";
|
|
9
10
|
export function CriteriaChips({ criteria, onOpen, onJoin, onRemove, onRemoveMany, open, collapseAfter = 4, surface, }) {
|
|
@@ -39,7 +40,7 @@ export function CriteriaChips({ criteria, onOpen, onJoin, onRemove, onRemoveMany
|
|
|
39
40
|
const unfolded = expanded || open !== undefined || !Number.isFinite(collapseAfter);
|
|
40
41
|
const beyondWide = Math.max(0, facets.length - collapseAfter);
|
|
41
42
|
const beyondNarrow = Math.max(0, facets.length - 1);
|
|
42
|
-
const more = (count, hidden, className) => (_jsx("button", { type: "button", onClick: () => setExpanded(true), title: hidden, "aria-label": `${fillCopy(copy.search.moreFacets, { count })}: ${hidden}`, className: `${className} shrink-0 items-center rounded-
|
|
43
|
+
const more = (count, hidden, className) => (_jsx("button", { type: "button", onClick: () => setExpanded(true), title: hidden, "aria-label": `${fillCopy(copy.search.moreFacets, { count })}: ${hidden}`, className: `${className} shrink-0 items-center rounded-ui-tag border px-2 py-0.5 text-micro font-medium tabular-nums transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "border-line-strong text-muted hover:bg-ink/5 hover:text-ink", "border-chrome-ink/30 text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: fillCopy(copy.search.moreFacets, { count }) }));
|
|
43
44
|
const hiddenFrom = (from) => facets
|
|
44
45
|
.slice(from)
|
|
45
46
|
.map((one) => one.label)
|
|
@@ -76,7 +77,7 @@ function labelOf(node, joins) {
|
|
|
76
77
|
function GroupChain({ groups, onOpen, onRemoveMany, surface, }) {
|
|
77
78
|
const copy = useUiCopy();
|
|
78
79
|
const chain = groups.map((one) => one.label).join(" › ");
|
|
79
|
-
return (_jsxs("span", { role: "group", "aria-label": `${copy.search.groupedBy} ${chain}`, title: `${copy.search.groupedBy} ${chain}`, className: `inline-flex min-w-0 max-w-(--container-chain) items-center gap-1 rounded-
|
|
80
|
+
return (_jsxs("span", { role: "group", "aria-label": `${copy.search.groupedBy} ${chain}`, title: `${copy.search.groupedBy} ${chain}`, className: `inline-flex min-w-0 max-w-(--container-chain) items-center gap-1 rounded-ui-tag border py-0.5 pl-1.5 text-micro ${bySurface(surface, "border-line-strong bg-surface text-ink", "border-chrome-ink/30 bg-chrome-ink/8 text-chrome-ink")} ${onRemoveMany === undefined ? "pr-2" : "pr-0.5"}`, children: [_jsx(Layers, { className: `size-3 shrink-0 ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: groups.map((one, at) => (_jsxs(Fragment, { children: [at === 0 ? null : (_jsx(ChevronRight, { className: `mx-0.5 inline size-3 align-middle ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true })), onOpen === undefined ? (_jsx("span", { children: one.label })) : (_jsx("button", { type: "button", onClick: () => onOpen(one.path), title: copy.search.openBuilderHere, className: "inline rounded-control hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: one.label }))] }, one.path.join(".")))) }), onRemoveMany === undefined ? null : (_jsx("button", { type: "button", onClick: () => onRemoveMany(groups.map((one) => one.path)), "aria-label": copy.search.removeGrouping, title: copy.search.removeGrouping, className: `inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(surface, "hover:bg-ink/10", "hover:bg-chrome-ink/20")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }))] }));
|
|
80
81
|
}
|
|
81
82
|
function Node({ node, path, onOpen, onJoin, onRemove, open, surface, }) {
|
|
82
83
|
const copy = useUiCopy();
|
|
@@ -97,7 +98,7 @@ function Node({ node, path, onOpen, onJoin, onRemove, open, surface, }) {
|
|
|
97
98
|
}
|
|
98
99
|
function Chip({ label, path, onOpen, onRemove, surface, }) {
|
|
99
100
|
const copy = useUiCopy();
|
|
100
|
-
const shell = `inline-flex min-w-0 max-w-(--container-facet) items-center gap-1 rounded-
|
|
101
|
+
const shell = `inline-flex min-w-0 max-w-(--container-facet) items-center gap-1 rounded-ui-tag py-0.5 text-micro ${chosenTone(surface)} ${onRemove === undefined ? "px-2" : "pr-0.5 pl-2"}`;
|
|
101
102
|
const remove = onRemove === undefined ? null : (_jsx("button", { type: "button", onClick: (event) => {
|
|
102
103
|
/* Without this, removing it also opens it: the click arrives here and then
|
|
103
104
|
bubbles up. */
|
|
@@ -105,11 +106,11 @@ function Chip({ label, path, onOpen, onRemove, surface, }) {
|
|
|
105
106
|
onRemove(path);
|
|
106
107
|
}, "aria-label": copy.search.removeFilter.replace("{label}", label), className: `inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(surface, "hover:bg-primary/20", "hover:bg-chrome-link/25")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }));
|
|
107
108
|
if (onOpen === undefined) {
|
|
108
|
-
return (_jsxs("span", { className: shell, children: [_jsx("span", { className: "min-w-0 truncate", children: label }), remove] }));
|
|
109
|
+
return (_jsxs("span", { "data-ui": "search.chip", className: shell, children: [_jsx("span", { className: "min-w-0 truncate", children: label }), remove] }));
|
|
109
110
|
}
|
|
110
111
|
/* Two SIBLING buttons in the chip — open and remove — and never one inside the other. It
|
|
111
112
|
used to be a `span role="button"` holding the × button: an interactive control inside
|
|
112
113
|
another one, which a screen reader announces as one thing and axe flags
|
|
113
114
|
(`nested-interactive`). Siblings, each with its own name, are both reachable. */
|
|
114
|
-
return (_jsxs("span", { className: shell, children: [_jsx("button", { type: "button", onClick: () => onOpen(path), title: copy.search.openBuilderHere, className: "min-w-0 truncate rounded-control text-left hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: label }), remove] }));
|
|
115
|
+
return (_jsxs("span", { "data-ui": "search.chip", className: shell, children: [_jsx("button", { type: "button", onClick: () => onOpen(path), title: copy.search.openBuilderHere, className: "min-w-0 truncate rounded-control text-left hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: label }), remove] }));
|
|
115
116
|
}
|
|
@@ -35,7 +35,7 @@ export function JoinWord({ join, onChange, surface, }) {
|
|
|
35
35
|
if (onChange === undefined) {
|
|
36
36
|
return _jsx("span", { className: "shrink-0 text-micro text-muted", children: word });
|
|
37
37
|
}
|
|
38
|
-
return (_jsxs("span", { className: "relative inline-flex shrink-0", children: [_jsx("button", { type: "button", onClick: () => setOpen((current) => !current), "aria-expanded": open, title: copy.search.switchJoin, className: `shrink-0 rounded-control px-1 text-micro font-medium underline decoration-dotted underline-offset-4 decoration-current/40 transition-colors hover:decoration-current focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:text-ink", "text-chrome-muted hover:text-chrome-ink")}`, children: word }), open ? (_jsx("span", { className: "absolute top-full left-0 z-40 mt-1 rounded-
|
|
38
|
+
return (_jsxs("span", { className: "relative inline-flex shrink-0", children: [_jsx("button", { type: "button", onClick: () => setOpen((current) => !current), "aria-expanded": open, title: copy.search.switchJoin, className: `shrink-0 rounded-control px-1 text-micro font-medium underline decoration-dotted underline-offset-4 decoration-current/40 transition-colors hover:decoration-current focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:text-ink", "text-chrome-muted hover:text-chrome-ink")}`, children: word }), open ? (_jsx("span", { "data-ui": "popover", className: "absolute top-full left-0 z-40 mt-1 rounded-ui-popover border border-ui-popover-border bg-ui-popover p-1 shadow-ui-popover", children: _jsx(Tags, { stack: true, surface: "canvas", label: copy.search.switchJoin, items: OPTIONS.map((one) => ({
|
|
39
39
|
id: one,
|
|
40
40
|
label: copy.search.joins[one === "not" ? "none" : one],
|
|
41
41
|
selected: one === join,
|
|
@@ -5,27 +5,31 @@ import { CriteriaChips } from "./CriteriaChips.js";
|
|
|
5
5
|
import { describeCondition, opLabel, queryFields, readTyped, suggest, withoutValue, } from "./query.js";
|
|
6
6
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
7
7
|
import { bySurface, useSurface } from "../../foundations/surface.js";
|
|
8
|
+
import { CheckMark } from "../../primitives/field/Checks.js";
|
|
9
|
+
import { Count } from "../../primitives/tag/Count.js";
|
|
10
|
+
import { chosenTone } from "../../primitives/tag/Tag.js";
|
|
8
11
|
import { Tags } from "../../primitives/tag/Tags.js";
|
|
9
|
-
import { ChevronRight, CornerDownRight, ListFilter, Search, SlidersHorizontal, X, } from "lucide-react";
|
|
12
|
+
import { ChevronRight, CornerDownRight, Layers, ListFilter, Search, SlidersHorizontal, Star, X, } from "lucide-react";
|
|
10
13
|
import { Fragment, useEffect, useId, useRef, useState } from "react";
|
|
11
14
|
import { mergeProps, Overlay, useOverlay, useOverlayPosition } from "react-aria";
|
|
12
|
-
function Option({ o, onSelect }) {
|
|
15
|
+
function Option({ o, checks, onSelect, }) {
|
|
13
16
|
const Icon = o.icon;
|
|
14
|
-
|
|
17
|
+
const toggles = checks || o.checked !== undefined;
|
|
18
|
+
return (_jsxs("button", { type: "button", disabled: o.disabled, onClick: () => onSelect?.(o.id), ...(toggles ? { "aria-pressed": o.checked === true } : {}), className: "flex w-full items-start gap-2 rounded-ui-option px-1.5 py-1 text-left transition-colors duration-(--duration-instant) disabled:pointer-events-none disabled:opacity-45 hover:bg-ui-option-active", children: [_jsx("span", { className: "mt-0.5 flex size-(--size-icon-sm) shrink-0 items-center justify-center", children: toggles ? (_jsx(CheckMark, { on: o.checked === true })) : Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-sm) text-muted", strokeWidth: 2, "aria-hidden": true })) }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: `truncate text-meta ${o.checked === true ? "font-medium text-ink" : "text-ink"}`, children: o.label }), o.badge === undefined ? null : (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-warn/30 bg-warn/10 px-2 py-0.5 text-micro text-warn", children: o.badge }))] }), o.hint === undefined ? null : (_jsx("span", { className: "mt-0.5 block truncate text-micro text-muted", children: o.hint }))] })] }));
|
|
15
19
|
}
|
|
16
20
|
/** A panel group. Collapsible when it asks —a date, which brings eleven
|
|
17
21
|
* options— and open from the start if it already has something ticked: otherwise what is set
|
|
18
22
|
* stays hidden behind a chevron and you have to guess where it is. */
|
|
19
|
-
function Group({ group, first, onSelect, }) {
|
|
23
|
+
function Group({ group, first, checks, onSelect, }) {
|
|
20
24
|
const active = group.options.some((o) => o.checked === true);
|
|
21
25
|
const [open, setOpen] = useState(active);
|
|
22
|
-
const options = (_jsx(_Fragment, { children: group.options.map((o) => (_jsxs(Fragment, { children: [o.divider === true ? _jsx("div", { className: "my-1 h-px bg-line", role: "separator" }) : null, _jsx(Option, { o: o, onSelect: onSelect })] }, o.id))) }));
|
|
26
|
+
const options = (_jsx(_Fragment, { children: group.options.map((o) => (_jsxs(Fragment, { children: [o.divider === true ? _jsx("div", { className: "my-1 h-px bg-line", role: "separator" }) : null, _jsx(Option, { o: o, checks: checks, onSelect: onSelect })] }, o.id))) }));
|
|
23
27
|
return (_jsxs("div", { className: "flex flex-col gap-0.5", children: [first ? null : _jsx("div", { className: "my-1 h-px bg-line", role: "separator" }), group.label === undefined ? null : group.collapsible !== true ? (
|
|
24
|
-
/* The group's label goes in the TEXT column, not the edge one.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
_jsxs("div", { className: "flex items-center gap-2 px-1.5 pt-1 pb-0.5 text-micro text-muted", children: [_jsx("span", { className: "size-(--size-icon-sm) shrink-0", "aria-hidden": true }), group.label] })) : (_jsxs("button", { type: "button", onClick: () => setOpen(!open), "aria-expanded": open, className: "flex items-center gap-2 rounded-
|
|
28
|
+
/* The group's label goes in the TEXT column, not the edge one. The column's title
|
|
29
|
+
is the step above (the section, with its icon); this one is a step down: the
|
|
30
|
+
quiet size, and the same gap as the mark so that «mostrar sólo» starts where
|
|
31
|
+
«traídos» starts. */
|
|
32
|
+
_jsxs("div", { className: "flex items-center gap-2 px-1.5 pt-1 pb-0.5 text-micro text-muted", children: [_jsx("span", { className: "size-(--size-icon-sm) shrink-0", "aria-hidden": true }), group.label] })) : (_jsxs("button", { type: "button", onClick: () => setOpen(!open), "aria-expanded": open, className: "flex items-center gap-2 rounded-ui-option px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-ui-option-active", children: [_jsx(ChevronRight, { className: `size-(--size-icon-sm) shrink-0 text-muted transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-meta ${active ? "font-medium text-ink" : "text-ink"}`, children: group.label }), !active ? null : (_jsx(Count, { value: group.options.filter((o) => o.checked === true).length }))] })), group.collapsible === true && !open ? null : (_jsx("div", { className: group.collapsible === true
|
|
29
33
|
? "flex flex-col gap-0.5 pl-(--spacing-indent)"
|
|
30
34
|
: "flex flex-col gap-0.5", children: options }))] }));
|
|
31
35
|
}
|
|
@@ -135,11 +139,28 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
135
139
|
const columns = [
|
|
136
140
|
...(filters === undefined || !withOptions(filters)
|
|
137
141
|
? []
|
|
138
|
-
: [
|
|
139
|
-
|
|
142
|
+
: [
|
|
143
|
+
{
|
|
144
|
+
title: copy.search.filters,
|
|
145
|
+
icon: ListFilter,
|
|
146
|
+
groups: filters,
|
|
147
|
+
checks: true,
|
|
148
|
+
onSelect: onFilterSelect,
|
|
149
|
+
},
|
|
150
|
+
]),
|
|
151
|
+
...(grouping === undefined
|
|
152
|
+
? []
|
|
153
|
+
: [{ title: copy.search.groupBy, icon: Layers, content: grouping }]),
|
|
140
154
|
...(favorites === undefined || !withOptions(favorites)
|
|
141
155
|
? []
|
|
142
|
-
: [
|
|
156
|
+
: [
|
|
157
|
+
{
|
|
158
|
+
title: copy.search.favorites,
|
|
159
|
+
icon: Star,
|
|
160
|
+
groups: favorites,
|
|
161
|
+
onSelect: onFavoriteSelect,
|
|
162
|
+
},
|
|
163
|
+
]),
|
|
143
164
|
];
|
|
144
165
|
/* THE PANEL IS A LAYER, and Escape closes the layer on top — only that one.
|
|
145
166
|
|
|
@@ -259,12 +280,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
259
280
|
? one
|
|
260
281
|
: { ...node, of: [...node.of, one] };
|
|
261
282
|
}
|
|
262
|
-
return (_jsxs("div", { ref: box, onKeyDown: closePanelOnEscape,
|
|
263
|
-
/* `min-w-48`: placed in a flex row without a width, the bar used to collapse to its
|
|
264
|
-
narrowest and the input slid UNDER the filters button («bu⊞car»). 12rem is the
|
|
265
|
-
magnifier, a word of input and the buttons; a narrower container scrolls, it does
|
|
266
|
-
not stack controls on top of each other. */
|
|
267
|
-
className: "relative flex min-w-48 items-center gap-2", children: [_jsxs("div", { className: `@container/bar flex min-h-(--size-control-md) w-full min-w-0 items-start rounded-box border transition-colors duration-(--duration-instant) ${bySurface(sup, "border-line-strong bg-surface focus-within:border-primary/60",
|
|
283
|
+
return (_jsxs("div", { ref: box, onKeyDown: closePanelOnEscape, "data-ui": "search", className: "relative flex min-w-48 items-center gap-2", children: [_jsxs("div", { "data-ui": "search.field", className: `@container/bar flex min-h-(--size-control-md) w-full min-w-0 items-start rounded-ui-search border transition-colors duration-(--duration-instant) ${bySurface(sup, "border-ui-control-border bg-ui-control focus-within:border-primary/60",
|
|
268
284
|
/* On the chrome what defines the field is the BORDER, not the fill. The
|
|
269
285
|
blue is already almost black, so sinking it gives no contrast (1.05:1) and
|
|
270
286
|
raising it gives 1.21:1 — in both cases the field does not read as a
|
|
@@ -430,7 +446,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
430
446
|
is not available, the input stretches as always. */
|
|
431
447
|
style: step.field === undefined ? undefined : { fieldSizing: "content" }, className: step.field === undefined
|
|
432
448
|
? `h-7 ${criteria.length === 0 ? "min-w-24" : "min-w-16"} flex-1 bg-transparent text-meta outline-none ${bySurface(sup, "text-ink placeholder:text-muted", "text-chrome-ink placeholder:text-chrome-muted")}`
|
|
433
|
-
: `min-w-16 rounded-pill px-2 py-0.5 text-micro outline-none ${bySurface(sup, "bg-
|
|
449
|
+
: `min-w-16 rounded-pill px-2 py-0.5 text-micro outline-none ${bySurface(sup, "bg-primary/8 text-ink placeholder:text-muted", "bg-chrome-link/20 text-chrome-ink placeholder:text-chrome-muted")}` })] }), puestos === 0 ? null : (_jsx("button", { type: "button", onClick: () => {
|
|
434
450
|
onCriteriaChange([]);
|
|
435
451
|
setOpenGroup(null);
|
|
436
452
|
input.current?.focus();
|
|
@@ -445,8 +461,8 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
445
461
|
label: copy.search.tools,
|
|
446
462
|
count: puestos.toLocaleString(copy.locale),
|
|
447
463
|
}), title: copy.search.tools, className: `my-0.5 mr-0.5 inline-flex h-(--size-control-sm) shrink-0 items-center gap-1 rounded-control border px-2 text-micro transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${puestos > 0 || panel
|
|
448
|
-
? bySurface(sup, "border-
|
|
449
|
-
: bySurface(sup, "border-transparent text-muted hover:bg-ink/5 hover:text-ink", "border-transparent text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: [_jsx(ListFilter, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }), puestos > 0 ? _jsx("span", { className: "text-micro tabular-nums", children: puestos }) : null] }))] }), trailing, open ? (_jsxs("div", { className: `absolute top-full z-30 mt-1 overflow-hidden rounded-
|
|
464
|
+
? bySurface(sup, "border-primary/30 bg-primary/8 text-primary", "border-chrome-link/35 bg-chrome-link/15 text-chrome-link")
|
|
465
|
+
: bySurface(sup, "border-transparent text-muted hover:bg-ink/5 hover:text-ink", "border-transparent text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: [_jsx(ListFilter, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }), puestos > 0 ? _jsx("span", { className: "text-micro tabular-nums", children: puestos }) : null] }))] }), trailing, open ? (_jsxs("div", { "data-ui": "search.suggestions", className: `absolute top-full z-30 mt-1 overflow-hidden rounded-ui-popover border border-ui-popover-border bg-ui-popover shadow-ui-popover ${asTags ? "left-0 w-max max-w-full" : "right-0 left-0"}`, children: [openJoin === undefined ? null : (_jsxs("div", { className: "flex items-center gap-1.5 border-line border-b px-3 py-1.5 text-micro text-muted", children: [_jsx(CornerDownRight, { className: "size-3 shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: copy.search.landsHere }), _jsx("span", { className: `shrink-0 rounded-pill px-1.5 ${chosenTone("canvas")}`, children: copy.search.joins[openJoin === "not" ? "none" : openJoin] })] })), asTags ? (
|
|
450
466
|
/* A LIST, not a strip. You are CHOOSING: the eye goes down a
|
|
451
467
|
column and so does the keyboard. Twelve attributes folded into three
|
|
452
468
|
rows are twelve things to sweep in zigzag to find one. */
|
|
@@ -462,9 +478,9 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
462
478
|
onSelect: () => pick(one),
|
|
463
479
|
})) }) })) : (_jsx("div", { id: listId, role: "listbox", "aria-label": copy.search.suggestions, className: "p-1", children: suggestions.map((one, at) => (_jsxs("div", { id: optionId(at), role: "option", "aria-selected": at === active,
|
|
464
480
|
/* The input keeps the focus: pressing an option must not take it. */
|
|
465
|
-
onMouseDown: (event) => event.preventDefault(), onClick: () => pick(one), onMouseEnter: () => setActive(at), className: `flex w-full cursor-pointer items-baseline gap-1.5 rounded-
|
|
466
|
-
c.groups?.map((g, gi) => (_jsx(Group, { group: g, first: gi === 0, onSelect: c.onSelect }, g.label ?? gi))) })] }, c.title))), onOpenBuilder === undefined ? null : (_jsx("div", { className: "w-full border-t border-line p-1", children: _jsxs("button", { type: "button", onClick: () => {
|
|
481
|
+
onMouseDown: (event) => event.preventDefault(), onClick: () => pick(one), onMouseEnter: () => setActive(at), className: `flex w-full cursor-pointer items-baseline gap-1.5 rounded-ui-option px-2 py-1.5 text-left text-meta transition-colors duration-(--duration-instant) ${at === active ? "bg-ui-option-active" : "hover:bg-ink/4"}`, children: [_jsx("span", { className: "shrink-0 font-medium text-ink", children: one.label }), one.kind === "condition" || one.kind === "literal" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "shrink-0 text-muted", children: ":" }), _jsx("span", { className: "min-w-0 truncate font-mono text-micro text-ink", children: one.hint })] })) : one.kind === "field" && one.hint !== undefined ? (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-line-strong bg-ink/5 px-2 py-0.5 text-micro text-muted", children: one.hint })) : null] }, one.id))) }))] })) : null, panel && (columns.length > 0 || onOpenBuilder !== undefined) ? (_jsx(Overlay, { children: _jsxs("div", { ...mergeProps(overlayProps, positionProps), ref: panelBox, id: id, "data-react-aria-top-layer": "", "data-ui": "search.panel", className: "z-30 flex w-max max-w-(--container-cuts) flex-wrap overflow-hidden rounded-ui-popover border border-ui-popover-border bg-ui-popover shadow-ui-popover", children: [columns.map((c, i) => (_jsxs("div", { className: `flex min-w-48 flex-1 flex-col ${i === 0 ? "" : "border-t border-line sm:border-t-0 sm:border-l"}`, children: [_jsxs("div", { className: "flex items-center gap-2 px-2.5 pt-2.5 pb-1 text-meta font-semibold text-ink", children: [_jsx(c.icon, { className: "size-(--size-icon-sm) shrink-0 text-muted", strokeWidth: 2, "aria-hidden": true }), c.title] }), _jsx("div", { className: "flex max-h-96 flex-col gap-0.5 overflow-y-auto p-1", children: c.content ??
|
|
482
|
+
c.groups?.map((g, gi) => (_jsx(Group, { group: g, first: gi === 0, checks: c.checks === true, onSelect: c.onSelect }, g.label ?? gi))) })] }, c.title))), onOpenBuilder === undefined ? null : (_jsx("div", { className: "w-full border-t border-line p-1", children: _jsxs("button", { type: "button", onClick: () => {
|
|
467
483
|
onOpenBuilder();
|
|
468
484
|
setPanel(false);
|
|
469
|
-
}, className: "flex w-full items-center gap-2 rounded-
|
|
485
|
+
}, className: "flex w-full items-center gap-2 rounded-ui-option px-1.5 py-1 text-left text-meta text-ink transition-colors duration-(--duration-instant) hover:bg-ui-option-active focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: [_jsx(SlidersHorizontal, { className: "size-(--size-icon-sm)", strokeWidth: 2 }), copy.search.openBuilder] }) }))] }) })) : null] }));
|
|
470
486
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Surface } from "../../foundations/types.js";
|
|
1
2
|
import { type ReactNode } from "react";
|
|
2
3
|
export declare function AppFrame({
|
|
3
4
|
/** The bar at the top. It stays in view while scrolling. */
|
|
@@ -12,10 +13,18 @@ sidebar,
|
|
|
12
13
|
/** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
|
|
13
14
|
* drawer and something has to open it — a `TopBar` with the product's name, which draws
|
|
14
15
|
* the button first. A bare `TopBar` by default. */
|
|
15
|
-
narrowMenu,
|
|
16
|
+
narrowMenu,
|
|
17
|
+
/** The surface of the sidebar and its drawer. `chrome` wears the brand's colour — for the
|
|
18
|
+
* sidebar as the application's chrome (no `menu`). `canvas` by default. */
|
|
19
|
+
sidebarSurface,
|
|
20
|
+
/** Who scrolls. `page` (the default): the whole page, with the bars stuck on top. `view`:
|
|
21
|
+
* the frame is the window's height and the view scrolls inside itself — a workspace. */
|
|
22
|
+
scroll, children, }: {
|
|
16
23
|
menu?: ReactNode;
|
|
17
24
|
status?: ReactNode;
|
|
18
25
|
sidebar?: ReactNode;
|
|
19
26
|
narrowMenu?: ReactNode;
|
|
27
|
+
sidebarSurface?: Surface;
|
|
28
|
+
scroll?: "page" | "view";
|
|
20
29
|
children: ReactNode;
|
|
21
30
|
}): import("react").JSX.Element;
|