@sincpro/web-ui 2.2.0 → 2.4.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 +113 -3
- package/dist/components/board/Board.js +1 -1
- package/dist/components/guide/Guide.d.ts +33 -0
- package/dist/components/guide/Guide.js +288 -0
- package/dist/components/guide/GuideSpot.d.ts +14 -0
- package/dist/components/guide/GuideSpot.js +13 -0
- package/dist/components/guide/index.d.ts +4 -0
- package/dist/components/guide/index.js +6 -0
- package/dist/components/guide/place.d.ts +44 -0
- package/dist/components/guide/place.js +69 -0
- package/dist/components/guide/target.d.ts +41 -0
- package/dist/components/guide/target.js +55 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/listing/GroupingLevels.js +11 -9
- package/dist/components/listing/Listing.js +7 -5
- package/dist/components/listing/RecordCard.js +1 -1
- package/dist/components/listing/Row.js +8 -7
- package/dist/components/navigation/NavigationTree.js +36 -9
- package/dist/components/record/DirtyActions.d.ts +9 -7
- package/dist/components/record/DirtyActions.js +14 -9
- package/dist/components/record/ThumbBar.js +2 -1
- 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/SearchEntry.d.ts +29 -0
- package/dist/components/shell/SearchEntry.js +34 -0
- package/dist/components/shell/Sidebar.d.ts +12 -3
- package/dist/components/shell/Sidebar.js +38 -12
- package/dist/components/shell/TopBar.d.ts +12 -1
- package/dist/components/shell/TopBar.js +7 -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 +2 -0
- package/dist/components/shell/index.js +5 -0
- package/dist/foundations/copy.d.ts +19 -2
- package/dist/foundations/copy.es.js +13 -3
- package/dist/foundations/copy.js +13 -3
- package/dist/foundations/index.d.ts +1 -0
- package/dist/foundations/index.js +2 -0
- package/dist/foundations/shortcut.d.ts +18 -0
- package/dist/foundations/shortcut.js +20 -0
- 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.d.ts +5 -1
- package/dist/primitives/value/Metric.js +8 -6
- package/dist/tokens.css +202 -56
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Box } from "./place.js";
|
|
2
|
+
/**
|
|
3
|
+
* What a step of a tour points at.
|
|
4
|
+
*
|
|
5
|
+
* Context: the anchors are the ones the system already keeps stable, so no component needs a
|
|
6
|
+
* prop to be pointed at:
|
|
7
|
+
*
|
|
8
|
+
* - `{ part }` — a web-ui part (`data-ui`, listed in the README and guarded by a test):
|
|
9
|
+
* `{ part: "sidebar.search" }`. With `key`, one item of a collection:
|
|
10
|
+
* `{ part: "navigation.item", key: "socios.cuotas" }`.
|
|
11
|
+
* - `{ spot }` — anything the application marked: `<GuideSpot id="cifras">` or its own
|
|
12
|
+
* element with `data-guide="cifras"`.
|
|
13
|
+
* - `{ selector }` — any CSS selector, for what has no name yet.
|
|
14
|
+
* - a function — a ref, or whatever the application computes at that moment.
|
|
15
|
+
*/
|
|
16
|
+
export type GuideTarget = {
|
|
17
|
+
part: string;
|
|
18
|
+
key?: string;
|
|
19
|
+
} | {
|
|
20
|
+
spot: string;
|
|
21
|
+
} | {
|
|
22
|
+
selector: string;
|
|
23
|
+
} | (() => Element | null | undefined);
|
|
24
|
+
/** The CSS selector a target names; `null` for a function. */
|
|
25
|
+
export declare function selectorOf(target: Exclude<GuideTarget, () => unknown>): string;
|
|
26
|
+
export declare function selectorOf(target: GuideTarget): string | null;
|
|
27
|
+
/** The element's box on screen, `null` when it has none — hidden, or not laid out. A
|
|
28
|
+
* `GuideSpot` measures as the union of what it wraps. */
|
|
29
|
+
export declare function boxOf(element: Element): Box | null;
|
|
30
|
+
export type Found = {
|
|
31
|
+
/** The first match that is on screen. */
|
|
32
|
+
shown: Element | null;
|
|
33
|
+
/** A match that exists but is not on screen — the sidebar beside the view, on a phone. */
|
|
34
|
+
hidden: Element | null;
|
|
35
|
+
};
|
|
36
|
+
/** Of every match, the one on screen wins: the same sidebar is laid out twice on a phone —
|
|
37
|
+
* hidden beside the view, and shown in the drawer. */
|
|
38
|
+
export declare function findTarget(target: GuideTarget, root?: ParentNode): Found;
|
|
39
|
+
/** What to scroll so the target is in view: a `GuideSpot` has no box to scroll to, its first
|
|
40
|
+
* child does. */
|
|
41
|
+
export declare function scrollable(element: Element): Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/* A quoted attribute value: only `"` and `\` need escaping there — and unlike `CSS.escape`
|
|
3
|
+
this also runs where there is no DOM (a test, a server). */
|
|
4
|
+
const quoted = (value) => `"${value.replace(/["\\]/g, "\\$&")}"`;
|
|
5
|
+
export function selectorOf(target) {
|
|
6
|
+
if (typeof target === "function")
|
|
7
|
+
return null;
|
|
8
|
+
if ("part" in target) {
|
|
9
|
+
const part = `[data-ui=${quoted(target.part)}]`;
|
|
10
|
+
return target.key === undefined ? part : `${part}[data-key=${quoted(target.key)}]`;
|
|
11
|
+
}
|
|
12
|
+
if ("spot" in target)
|
|
13
|
+
return `[data-guide=${quoted(target.spot)}]`;
|
|
14
|
+
return target.selector;
|
|
15
|
+
}
|
|
16
|
+
/** `display: contents` has no box of its own (a `GuideSpot`): its box is its children's. */
|
|
17
|
+
function wraps(element) {
|
|
18
|
+
return getComputedStyle(element).display === "contents";
|
|
19
|
+
}
|
|
20
|
+
/** The element's box on screen, `null` when it has none — hidden, or not laid out. A
|
|
21
|
+
* `GuideSpot` measures as the union of what it wraps. */
|
|
22
|
+
export function boxOf(element) {
|
|
23
|
+
if (wraps(element)) {
|
|
24
|
+
const boxes = [...element.children].map(boxOf).filter((box) => box !== null);
|
|
25
|
+
if (boxes.length === 0)
|
|
26
|
+
return null;
|
|
27
|
+
const top = Math.min(...boxes.map((b) => b.top));
|
|
28
|
+
const left = Math.min(...boxes.map((b) => b.left));
|
|
29
|
+
const bottom = Math.max(...boxes.map((b) => b.top + b.height));
|
|
30
|
+
const right = Math.max(...boxes.map((b) => b.left + b.width));
|
|
31
|
+
return { top, left, width: right - left, height: bottom - top };
|
|
32
|
+
}
|
|
33
|
+
if (!element.checkVisibility({ visibilityProperty: true }))
|
|
34
|
+
return null;
|
|
35
|
+
const rect = element.getBoundingClientRect();
|
|
36
|
+
if (rect.width === 0 && rect.height === 0)
|
|
37
|
+
return null;
|
|
38
|
+
return { top: rect.top, left: rect.left, width: rect.width, height: rect.height };
|
|
39
|
+
}
|
|
40
|
+
/** Of every match, the one on screen wins: the same sidebar is laid out twice on a phone —
|
|
41
|
+
* hidden beside the view, and shown in the drawer. */
|
|
42
|
+
export function findTarget(target, root = document) {
|
|
43
|
+
const matches = typeof target === "function"
|
|
44
|
+
? [target()].filter((one) => one !== null && one !== undefined)
|
|
45
|
+
: [...root.querySelectorAll(selectorOf(target))];
|
|
46
|
+
return {
|
|
47
|
+
shown: matches.find((one) => boxOf(one) !== null) ?? null,
|
|
48
|
+
hidden: matches.find((one) => boxOf(one) === null) ?? null,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** What to scroll so the target is in view: a `GuideSpot` has no box to scroll to, its first
|
|
52
|
+
* child does. */
|
|
53
|
+
export function scrollable(element) {
|
|
54
|
+
return wraps(element) ? (element.firstElementChild ?? element) : element;
|
|
55
|
+
}
|
|
@@ -9,6 +9,7 @@ export * from "./flow/index.js";
|
|
|
9
9
|
export * from "./form/index.js";
|
|
10
10
|
export * from "./frame/index.js";
|
|
11
11
|
export * from "./gantt/index.js";
|
|
12
|
+
export * from "./guide/index.js";
|
|
12
13
|
export * from "./lines/index.js";
|
|
13
14
|
export * from "./listing/index.js";
|
|
14
15
|
export * from "./navigation/index.js";
|
package/dist/components/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./flow/index.js";
|
|
|
10
10
|
export * from "./form/index.js";
|
|
11
11
|
export * from "./frame/index.js";
|
|
12
12
|
export * from "./gantt/index.js";
|
|
13
|
+
export * from "./guide/index.js";
|
|
13
14
|
export * from "./lines/index.js";
|
|
14
15
|
export * from "./listing/index.js";
|
|
15
16
|
export * from "./navigation/index.js";
|
|
@@ -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
|
}
|
|
@@ -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
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
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
|
|
@@ -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. */
|
|
@@ -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 })),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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 })),
|
|
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.
|
|
@@ -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", "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
|
+
? 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,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
|
-
*
|
|
12
|
-
*
|
|
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
|
|
15
|
-
*
|
|
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,9 +21,11 @@ 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
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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. */
|
|
27
29
|
export declare function DirtyActions({ onSave, onDiscard, saving, label, blocked, changes, }: DirtyState): import("react").JSX.Element;
|
|
28
30
|
/**
|
|
29
31
|
* Whether the record has JUST been saved: `dirty` went from saving straight to gone.
|
|
@@ -11,21 +11,26 @@ 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
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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. */
|
|
17
19
|
export function DirtyActions({ onSave, onDiscard, saving = false, label, blocked, changes, }) {
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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, hidden: true, children: fillCopy(changes === 1 ? copy.record.unsavedOne : copy.record.unsavedMany, {
|
|
32
|
+
count: changes.toLocaleString(copy.locale),
|
|
33
|
+
}) })) : null, _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, ...(describedBy === "" ? {} : { "aria-describedby": describedBy }), children: saving ? copy.record.saving : (label ?? copy.record.save) })] }));
|
|
29
34
|
}
|
|
30
35
|
/** The one action a view leads with: the element written with `role="primary"` — the
|
|
31
36
|
* same prop that paints it gold and that `make smoke` counts, so there is no second way to
|
|
@@ -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
|
|
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.
|
|
@@ -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,
|