@sincpro/web-ui 2.13.0 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -6
- package/dist/components/gallery/Gallery.d.ts +29 -0
- package/dist/components/gallery/Gallery.js +78 -0
- package/dist/components/gallery/Lightbox.d.ts +28 -0
- package/dist/components/gallery/Lightbox.js +59 -0
- package/dist/components/gallery/index.d.ts +2 -0
- package/dist/components/gallery/index.js +3 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/listing/ColumnsMenu.js +4 -2
- package/dist/components/listing/columns.d.ts +3 -0
- package/dist/components/listing/columns.js +4 -0
- package/dist/components/plans/PlanCard.d.ts +43 -0
- package/dist/components/plans/PlanCard.js +35 -0
- package/dist/components/plans/index.d.ts +1 -0
- package/dist/components/plans/index.js +2 -0
- package/dist/components/search/CriteriaChips.d.ts +14 -1
- package/dist/components/search/CriteriaChips.js +131 -14
- package/dist/components/search/JoinWord.js +8 -14
- package/dist/components/search/SearchBar.d.ts +10 -1
- package/dist/components/search/SearchBar.js +715 -176
- package/dist/components/search/WordChoice.d.ts +19 -0
- package/dist/components/search/WordChoice.js +8 -0
- package/dist/components/search/criteria.d.ts +47 -4
- package/dist/components/search/criteria.js +75 -2
- package/dist/components/search/index.d.ts +2 -2
- package/dist/components/search/index.js +2 -2
- package/dist/components/search/query.d.ts +24 -0
- package/dist/components/search/query.js +29 -0
- package/dist/components/shell/AppFrame.d.ts +4 -0
- package/dist/components/shell/AppFrame.js +4 -1
- package/dist/components/shell/Inbox.d.ts +53 -0
- package/dist/components/shell/Inbox.js +55 -0
- package/dist/components/shell/SearchEntry.js +2 -3
- package/dist/components/shell/TopBar.d.ts +4 -2
- package/dist/components/shell/TopBar.js +3 -3
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +3 -0
- package/dist/foundations/copy.es.js +60 -1
- package/dist/foundations/form.d.ts +7 -0
- package/dist/foundations/form.js +1 -0
- package/dist/foundations/uiCopy.d.ts +85 -2
- package/dist/foundations/uiCopy.js +60 -1
- package/dist/primitives/choice/RadioGroup.d.ts +1 -1
- package/dist/primitives/choice/RadioGroup.js +29 -0
- package/dist/primitives/choice/Rating.d.ts +32 -0
- package/dist/primitives/choice/Rating.js +75 -0
- package/dist/primitives/choice/Slider.d.ts +19 -0
- package/dist/primitives/choice/Slider.js +27 -2
- package/dist/primitives/choice/index.d.ts +2 -1
- package/dist/primitives/choice/index.js +4 -1
- package/dist/primitives/choice/options.d.ts +4 -0
- package/dist/primitives/field/Field.js +1 -0
- package/dist/primitives/hint/Kbd.d.ts +23 -0
- package/dist/primitives/hint/Kbd.js +23 -0
- package/dist/primitives/hint/index.d.ts +1 -0
- package/dist/primitives/hint/index.js +2 -0
- package/dist/primitives/menu/ContextMenu.d.ts +29 -0
- package/dist/primitives/menu/ContextMenu.js +74 -0
- package/dist/primitives/menu/Menu.d.ts +4 -1
- package/dist/primitives/menu/Menu.js +2 -2
- package/dist/primitives/menu/index.d.ts +1 -0
- package/dist/primitives/menu/index.js +2 -0
- package/dist/primitives/notice/Banner.d.ts +27 -0
- package/dist/primitives/notice/Banner.js +21 -0
- package/dist/primitives/notice/Callout.d.ts +4 -4
- package/dist/primitives/notice/Callout.js +8 -19
- package/dist/primitives/notice/Notice.d.ts +38 -10
- package/dist/primitives/notice/Notice.js +48 -9
- package/dist/primitives/notice/index.d.ts +3 -1
- package/dist/primitives/notice/index.js +3 -0
- package/dist/primitives/notice/tones.d.ts +8 -0
- package/dist/primitives/notice/tones.js +22 -0
- package/dist/primitives/table/DataTable.js +2 -1
- package/dist/primitives/table/index.d.ts +1 -0
- package/dist/primitives/table/index.js +1 -0
- package/dist/primitives/table/levels.d.ts +13 -0
- package/dist/primitives/table/levels.js +11 -0
- package/dist/primitives/value/Price.d.ts +31 -0
- package/dist/primitives/value/Price.js +32 -0
- package/dist/primitives/value/QrCode.d.ts +32 -0
- package/dist/primitives/value/QrCode.js +53 -0
- package/dist/primitives/value/index.d.ts +3 -0
- package/dist/primitives/value/index.js +6 -0
- package/dist/primitives/value/priceFormat.d.ts +12 -0
- package/dist/primitives/value/priceFormat.js +22 -0
- package/dist/tokens.css +39 -0
- package/dist/views/list/ListView.js +24 -4
- package/dist/views/list/derive.js +3 -2
- package/dist/views/list/types.d.ts +8 -0
- package/package.json +3 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface WordOption<K extends string> {
|
|
2
|
+
id: K;
|
|
3
|
+
label: string;
|
|
4
|
+
/** What tells it apart when the word alone does not: «<=» beside «como mucho». */
|
|
5
|
+
note?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function WordChoice<K extends string>({ value, options, onChange, label, word, className, }: {
|
|
8
|
+
value: K;
|
|
9
|
+
options: readonly WordOption<K>[];
|
|
10
|
+
onChange: (next: K) => void;
|
|
11
|
+
/** What the word decides — the trigger's and the list's name. */
|
|
12
|
+
label: string;
|
|
13
|
+
/** The word as it reads in the bar —«como mucho», «todas»—. It STARTS the trigger's name
|
|
14
|
+
* («como mucho, comparar total de otra manera»): a name that does not hold what is seen
|
|
15
|
+
* fails whoever drives the screen by voice, saying the word they read. */
|
|
16
|
+
word: string;
|
|
17
|
+
/** How the word looks; the trigger is a button and takes the focus ring from here. */
|
|
18
|
+
className: string;
|
|
19
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Popover } from "../../primitives/overlay/Popover.js";
|
|
4
|
+
import { Check } from "lucide-react";
|
|
5
|
+
import { Button as AriaButton, Menu as AriaMenu, MenuItem, MenuTrigger, } from "react-aria-components";
|
|
6
|
+
export function WordChoice({ value, options, onChange, label, word, className, }) {
|
|
7
|
+
return (_jsxs(MenuTrigger, { children: [_jsx(AriaButton, { "aria-label": `${word}, ${label.toLocaleLowerCase()}`, className: className, children: word }), _jsx(Popover, { placement: "bottom start", className: "min-w-36 p-1", children: _jsx(AriaMenu, { "aria-label": label, selectionMode: "single", selectedKeys: [value], disallowEmptySelection: true, autoFocus: "first", onAction: (key) => onChange(String(key)), className: "flex max-h-72 flex-col gap-0.5 overflow-y-auto outline-0", children: options.map((one) => (_jsx(MenuItem, { id: one.id, textValue: one.label, className: "flex cursor-pointer items-center gap-2 rounded-ui-option px-2 py-1 text-meta text-ink outline-0 transition-colors duration-(--duration-instant) data-focused:bg-ui-option-active", children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: "flex size-(--size-icon-sm) shrink-0 items-center justify-center", children: isSelected ? (_jsx(Check, { className: "size-(--size-icon-sm) text-primary", strokeWidth: 2.5, "aria-hidden": true })) : null }), _jsx("span", { className: `min-w-0 flex-1 truncate ${isSelected ? "font-medium" : ""}`, children: one.label }), one.note === undefined ? null : (_jsx("span", { className: "shrink-0 font-mono text-micro text-muted", children: one.note }))] })) }, one.id))) }) })] }));
|
|
8
|
+
}
|
|
@@ -101,6 +101,16 @@ export type SearchCriteria = {
|
|
|
101
101
|
* lands here (`withValue`), and the chip says «Cliente: Andrés Pérez o Andrés Gutiérrez».
|
|
102
102
|
*/
|
|
103
103
|
values?: readonly RecordOption[];
|
|
104
|
+
/**
|
|
105
|
+
* The named filters of ONE group this chip holds, when they were declared with a `group`
|
|
106
|
+
* (`toggleNamed`): Odoo's rule — filters of the same group are OR'd, groups are AND'd.
|
|
107
|
+
* «Pedidos» + «Trabajando» are one chip, «Pedidos o Trabajando», whose `selection` is
|
|
108
|
+
* `{ any: [...] }`; ticking a third adds it there, unticking the last removes the chip.
|
|
109
|
+
*/
|
|
110
|
+
named?: {
|
|
111
|
+
group: string;
|
|
112
|
+
members: readonly NamedFilterSpec[];
|
|
113
|
+
};
|
|
104
114
|
} | {
|
|
105
115
|
id: string;
|
|
106
116
|
kind: "join";
|
|
@@ -121,6 +131,14 @@ export type GroupCriteria = Extract<SearchCriteria, {
|
|
|
121
131
|
export declare function groupsOf(all: readonly SearchCriteria[]): GroupCriteria[];
|
|
122
132
|
/** The filter ones, which are the ones that nest. */
|
|
123
133
|
export declare function filtersOf(all: readonly SearchCriteria[]): SearchCriteria[];
|
|
134
|
+
/**
|
|
135
|
+
* The PIECES the bar draws, in its order, each with the top-level paths it covers: the
|
|
136
|
+
* grouping chain first —every level in ONE piece—, then each filter on top.
|
|
137
|
+
*
|
|
138
|
+
* It is what the keyboard walks: ← on the empty bar marks the last piece, and removing a
|
|
139
|
+
* piece removes everything it covers — the whole chain, or one filter with its nesting.
|
|
140
|
+
*/
|
|
141
|
+
export declare function facetPaths(all: readonly SearchCriteria[]): CriteriaPath[][];
|
|
124
142
|
/** The instance at that path, if there is one. */
|
|
125
143
|
export declare function at(all: readonly SearchCriteria[], path: CriteriaPath): SearchCriteria | undefined;
|
|
126
144
|
/** The same tree with one instance changed. Returning a new one and not touching the
|
|
@@ -133,6 +151,25 @@ export declare function replaceAt(all: readonly SearchCriteria[], path: Criteria
|
|
|
133
151
|
* parenthesis around nothing, and leaving it forces reading a group that does not group.
|
|
134
152
|
*/
|
|
135
153
|
export declare function removeAt(all: readonly SearchCriteria[], path: CriteriaPath): SearchCriteria[];
|
|
154
|
+
/** What was removed, and how to put it back: «Quitado: cliente contiene andina · Deshacer». */
|
|
155
|
+
export type Removal = {
|
|
156
|
+
label: string;
|
|
157
|
+
removed: readonly {
|
|
158
|
+
path: CriteriaPath;
|
|
159
|
+
node: SearchCriteria;
|
|
160
|
+
}[];
|
|
161
|
+
before: readonly SearchCriteria[];
|
|
162
|
+
after: readonly SearchCriteria[];
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* What was removed, back in the list as it is NOW.
|
|
166
|
+
*
|
|
167
|
+
* A removed piece on top goes back to its place even if something was set after it — undoing
|
|
168
|
+
* one chip must not take away the next one. A piece removed from inside a group can only go
|
|
169
|
+
* back while nothing changed since: its group may be gone (`removeAt` dismantles a group left
|
|
170
|
+
* with one), and guessing where it lands is worse than not offering it.
|
|
171
|
+
*/
|
|
172
|
+
export declare function restoreRemoval(current: readonly SearchCriteria[], removal: Removal): SearchCriteria[] | null;
|
|
136
173
|
/** How a node's instances are joined: `all` → `any` → `not` and round again. It is
|
|
137
174
|
* the same wheel the selector shows open, for whoever prefers the
|
|
138
175
|
* shortcut. */
|
|
@@ -168,6 +205,14 @@ export type { GroupGrain, GroupLevel };
|
|
|
168
205
|
* The group ones stay IN FRONT, which is where they are drawn.
|
|
169
206
|
*/
|
|
170
207
|
export declare function withLevels(all: readonly SearchCriteria[], levels: readonly GroupLevel[], labelOf: (level: GroupLevel) => string): SearchCriteria[];
|
|
208
|
+
/** A filter declared in code: its id, its words and what it keeps. With a `group`, it is OR'd
|
|
209
|
+
* with the others of its group that are set (one chip), and AND'd with everything else. */
|
|
210
|
+
export type NamedFilterSpec = {
|
|
211
|
+
id: string;
|
|
212
|
+
label: string;
|
|
213
|
+
selection?: BuiltCondition | BuiltFilter;
|
|
214
|
+
group?: string;
|
|
215
|
+
};
|
|
171
216
|
/**
|
|
172
217
|
* A NAMED filter, set or removed.
|
|
173
218
|
*
|
|
@@ -176,10 +221,8 @@ export declare function withLevels(all: readonly SearchCriteria[], levels: reado
|
|
|
176
221
|
* by its `id` — the one declared by whoever wrote it, so it survives
|
|
177
222
|
* being saved as a favourite and read back.
|
|
178
223
|
*/
|
|
179
|
-
export declare function toggleNamed(all: readonly SearchCriteria[], named: {
|
|
180
|
-
|
|
181
|
-
label: string;
|
|
182
|
-
selection?: BuiltCondition | BuiltFilter;
|
|
224
|
+
export declare function toggleNamed(all: readonly SearchCriteria[], named: NamedFilterSpec, words?: {
|
|
225
|
+
or?: string;
|
|
183
226
|
}): SearchCriteria[];
|
|
184
227
|
/** Whether that named filter is set. The panel uses it to draw the mark:
|
|
185
228
|
* the mark comes from what is SET and not from a separate state that could disagree. */
|
|
@@ -7,6 +7,18 @@ export function groupsOf(all) {
|
|
|
7
7
|
export function filtersOf(all) {
|
|
8
8
|
return all.filter((one) => one.kind !== "group");
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* The PIECES the bar draws, in its order, each with the top-level paths it covers: the
|
|
12
|
+
* grouping chain first —every level in ONE piece—, then each filter on top.
|
|
13
|
+
*
|
|
14
|
+
* It is what the keyboard walks: ← on the empty bar marks the last piece, and removing a
|
|
15
|
+
* piece removes everything it covers — the whole chain, or one filter with its nesting.
|
|
16
|
+
*/
|
|
17
|
+
export function facetPaths(all) {
|
|
18
|
+
const groups = all.flatMap((one, index) => (one.kind === "group" ? [[index]] : []));
|
|
19
|
+
const filters = all.flatMap((one, index) => (one.kind === "group" ? [] : [[[index]]]));
|
|
20
|
+
return [...(groups.length === 0 ? [] : [groups]), ...filters];
|
|
21
|
+
}
|
|
10
22
|
/** The instance at that path, if there is one. */
|
|
11
23
|
export function at(all, path) {
|
|
12
24
|
const [head, ...rest] = path;
|
|
@@ -56,6 +68,27 @@ export function removeAt(all, path) {
|
|
|
56
68
|
return [{ ...one, of: inside }];
|
|
57
69
|
});
|
|
58
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* What was removed, back in the list as it is NOW.
|
|
73
|
+
*
|
|
74
|
+
* A removed piece on top goes back to its place even if something was set after it — undoing
|
|
75
|
+
* one chip must not take away the next one. A piece removed from inside a group can only go
|
|
76
|
+
* back while nothing changed since: its group may be gone (`removeAt` dismantles a group left
|
|
77
|
+
* with one), and guessing where it lands is worse than not offering it.
|
|
78
|
+
*/
|
|
79
|
+
export function restoreRemoval(current, removal) {
|
|
80
|
+
if (removal.removed.every((one) => one.path.length === 1)) {
|
|
81
|
+
const next = [...current];
|
|
82
|
+
const ordered = [...removal.removed].sort((a, b) => (a.path[0] ?? 0) - (b.path[0] ?? 0));
|
|
83
|
+
for (const one of ordered) {
|
|
84
|
+
if (next.some((each) => each.id === one.node.id))
|
|
85
|
+
continue;
|
|
86
|
+
next.splice(Math.min(one.path[0] ?? next.length, next.length), 0, one.node);
|
|
87
|
+
}
|
|
88
|
+
return next;
|
|
89
|
+
}
|
|
90
|
+
return current === removal.after ? [...removal.before] : null;
|
|
91
|
+
}
|
|
59
92
|
/** How a node's instances are joined: `all` → `any` → `not` and round again. It is
|
|
60
93
|
* the same wheel the selector shows open, for whoever prefers the
|
|
61
94
|
* shortcut. */
|
|
@@ -139,6 +172,30 @@ export function levelsOf(all) {
|
|
|
139
172
|
export function withLevels(all, levels, labelOf) {
|
|
140
173
|
return [...levels.map((level) => groupCriteria(level, labelOf(level))), ...filtersOf(all)];
|
|
141
174
|
}
|
|
175
|
+
/** The chip of a group of named filters: the members' words joined by `or`, and what any of
|
|
176
|
+
* them keeps. A member that carries no selection makes the chip one its declarer answers. */
|
|
177
|
+
function namedGroupChip(group, members, or) {
|
|
178
|
+
const asked = members.flatMap((one) => one.selection === undefined ? [] : [one.selection]);
|
|
179
|
+
const selection = asked.length !== members.length
|
|
180
|
+
? undefined
|
|
181
|
+
: asked.length === 1
|
|
182
|
+
? asked[0]
|
|
183
|
+
: { any: asked };
|
|
184
|
+
return {
|
|
185
|
+
id: `named:${group}`,
|
|
186
|
+
kind: "filter",
|
|
187
|
+
label: members.map((one) => one.label).join(` ${or} `),
|
|
188
|
+
...(selection === undefined ? {} : { selection }),
|
|
189
|
+
named: {
|
|
190
|
+
group,
|
|
191
|
+
members: members.map(({ id, label, selection: kept }) => ({
|
|
192
|
+
id,
|
|
193
|
+
label,
|
|
194
|
+
...(kept === undefined ? {} : { selection: kept }),
|
|
195
|
+
})),
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
142
199
|
/**
|
|
143
200
|
* A NAMED filter, set or removed.
|
|
144
201
|
*
|
|
@@ -147,7 +204,21 @@ export function withLevels(all, levels, labelOf) {
|
|
|
147
204
|
* by its `id` — the one declared by whoever wrote it, so it survives
|
|
148
205
|
* being saved as a favourite and read back.
|
|
149
206
|
*/
|
|
150
|
-
export function toggleNamed(all, named) {
|
|
207
|
+
export function toggleNamed(all, named, words = {}) {
|
|
208
|
+
if (named.group !== undefined) {
|
|
209
|
+
/* One chip per group: its members are OR'd («Pedidos o Trabajando»). */
|
|
210
|
+
const id = `named:${named.group}`;
|
|
211
|
+
const at = all.findIndex((one) => one.id === id);
|
|
212
|
+
const found = at >= 0 ? all[at] : undefined;
|
|
213
|
+
const members = found?.kind === "filter" ? (found.named?.members ?? []) : [];
|
|
214
|
+
const next = members.some((one) => one.id === named.id)
|
|
215
|
+
? members.filter((one) => one.id !== named.id)
|
|
216
|
+
: [...members, named];
|
|
217
|
+
if (next.length === 0)
|
|
218
|
+
return all.filter((_, index) => index !== at);
|
|
219
|
+
const chip = namedGroupChip(named.group, next, words.or ?? "or");
|
|
220
|
+
return at >= 0 ? all.map((one, index) => (index === at ? chip : one)) : [...all, chip];
|
|
221
|
+
}
|
|
151
222
|
const at = all.findIndex((one) => one.id === named.id);
|
|
152
223
|
if (at >= 0)
|
|
153
224
|
return all.filter((_, index) => index !== at);
|
|
@@ -156,5 +227,7 @@ export function toggleNamed(all, named) {
|
|
|
156
227
|
/** Whether that named filter is set. The panel uses it to draw the mark:
|
|
157
228
|
* the mark comes from what is SET and not from a separate state that could disagree. */
|
|
158
229
|
export function hasNamed(all, id) {
|
|
159
|
-
return all.some((one) => one.id === id
|
|
230
|
+
return all.some((one) => one.id === id ||
|
|
231
|
+
(one.kind === "filter" &&
|
|
232
|
+
(one.named?.members.some((member) => member.id === id) ?? false)));
|
|
160
233
|
}
|
|
@@ -7,10 +7,10 @@ export { formatJson } from "./formatJson.js";
|
|
|
7
7
|
export { JsonEditor } from "./JsonEditor.js";
|
|
8
8
|
export { createModelCache, type FieldPathStep, type FieldPathValue, isRelation, isToMany, type LoadModel, type ModelCache, pathLabel, peekLabels, resolvePath, } from "./paths.js";
|
|
9
9
|
export { SearchBar, type SearchBarProps, type SearchFacet, } from "./SearchBar.js";
|
|
10
|
-
export { at, criteriaId, type CriteriaJoin, type CriteriaPath, filterCriteria, filtersOf, type GroupCriteria, groupCriteria, groupsOf, hasNamed, levelsOf, nextJoin, type RecordKey, type RecordOption, removeAt, replaceAt, type SearchCriteria, selectionOf, toggleNamed, withLevels, } from "./criteria.js";
|
|
10
|
+
export { at, criteriaId, type CriteriaJoin, type CriteriaPath, facetPaths, filterCriteria, filtersOf, type GroupCriteria, groupCriteria, groupsOf, hasNamed, levelsOf, type NamedFilterSpec, nextJoin, type RecordKey, type RecordOption, type Removal, removeAt, replaceAt, restoreRemoval, type SearchCriteria, selectionOf, toggleNamed, withLevels, } from "./criteria.js";
|
|
11
11
|
export { CriteriaChips, type CriteriaChipsProps, } from "./CriteriaChips.js";
|
|
12
12
|
export { choiceLabel, type FieldDefinition, fieldLabel, filterableNames, isFilterable, isNumericType, type ModelDefinition, type ModelTranslations, } from "./model.js";
|
|
13
|
-
export { answers, choiceValues, conditionCriteria, defaultOp, describeCondition, fieldKey, globToLike, opLabel, type QueryDraft, type QueryField, queryField, queryFields, type QueryKind, type QuerySuggestion, readTyped, sayValues, suggest, type TypedValue, valueFor, valueLabel, valuesCriteria, type ValueShape, valuesSelection, withoutValue, withValue, } from "./query.js";
|
|
13
|
+
export { answers, type ChipParts, chipParts, choiceValues, conditionCriteria, defaultOp, describeCondition, fieldKey, globToLike, opLabel, type QueryDraft, type QueryField, queryField, queryFields, type QueryKind, type QuerySuggestion, readTyped, sayValues, suggest, type TypedValue, valueFor, valueLabel, valuesCriteria, type ValueShape, valuesSelection, withoutValue, withParts, withValue, } from "./query.js";
|
|
14
14
|
export { SearchProvider, type SearchSettings, useSearchSettings, type ValueEditor, type ValueEditorProps, } from "./context.js";
|
|
15
15
|
export { type BrowseRecords, type RecordBrowse, type RecordSearch, recordsFilter, recordsOf, type RecordTarget, recordTarget, sameKey, type SearchRecords, } from "./records.js";
|
|
16
16
|
export { RuleValue } from "./RuleValue.js";
|
|
@@ -15,7 +15,7 @@ export { SearchBar, } from "./SearchBar.js";
|
|
|
15
15
|
/* WHAT THE BAR HAS SET: instances. A single thing for both kinds
|
|
16
16
|
—group and filter—, with their UI metadata outside and the engine's object
|
|
17
17
|
inside, intact. */
|
|
18
|
-
export { at, criteriaId, filterCriteria, filtersOf, groupCriteria, groupsOf, hasNamed, levelsOf, nextJoin, removeAt, replaceAt, selectionOf, toggleNamed, withLevels, } from "./criteria.js";
|
|
18
|
+
export { at, criteriaId, facetPaths, filterCriteria, filtersOf, groupCriteria, groupsOf, hasNamed, levelsOf, nextJoin, removeAt, replaceAt, restoreRemoval, selectionOf, toggleNamed, withLevels, } from "./criteria.js";
|
|
19
19
|
export { CriteriaChips, } from "./CriteriaChips.js";
|
|
20
20
|
/* THE MODEL'S VOCABULARY — what the server publishes about its fields. The
|
|
21
21
|
filter builder, the criteria builder and the search bar speak it, so
|
|
@@ -23,7 +23,7 @@ export { CriteriaChips, } from "./CriteriaChips.js";
|
|
|
23
23
|
export { choiceLabel, fieldLabel, filterableNames, isFilterable, isNumericType, } from "./model.js";
|
|
24
24
|
/* THE BAR'S GRAMMAR: what can be asked about a model, and with what.
|
|
25
25
|
Three steps —field, operator, value— that can be written as one. */
|
|
26
|
-
export { answers, choiceValues, conditionCriteria, defaultOp, describeCondition, fieldKey, globToLike, opLabel, queryField, queryFields, readTyped, sayValues, suggest, valueFor, valueLabel, valuesCriteria, valuesSelection, withoutValue, withValue, } from "./query.js";
|
|
26
|
+
export { answers, chipParts, choiceValues, conditionCriteria, defaultOp, describeCondition, fieldKey, globToLike, opLabel, queryField, queryFields, readTyped, sayValues, suggest, valueFor, valueLabel, valuesCriteria, valuesSelection, withoutValue, withParts, withValue, } from "./query.js";
|
|
27
27
|
/* THE RECORDS OF A RELATION: chosen by name, sent by key. The application gives ONE search
|
|
28
28
|
(`searchRecords`) — by prop, or once for every bar and builder with `SearchProvider` — and
|
|
29
29
|
its own value controls (`valueEditor`) for the fields it draws its way. */
|
|
@@ -236,6 +236,30 @@ export declare function describeCondition(field: QueryField, op: string, value:
|
|
|
236
236
|
/** The question about one field as a chip — what the bar puts when a condition is chosen:
|
|
237
237
|
* «nombre contiene test». */
|
|
238
238
|
export declare function conditionCriteria(field: QueryField, op: string, value: string): SearchCriteria;
|
|
239
|
+
/**
|
|
240
|
+
* A chip's PARTS — the field, the comparison and the value —, when the chip is a question the
|
|
241
|
+
* bar itself writes.
|
|
242
|
+
*
|
|
243
|
+
* Context: «total como mucho 1000» read at one weight, and changing 1000 to 2000 meant opening
|
|
244
|
+
* the whole builder. Split, the chip reads the way the eye scans it —the field quiet, the
|
|
245
|
+
* comparison a small word, the value strong— and each part is touched on its own. Only a chip
|
|
246
|
+
* that DESCRIBES itself splits: a declared one keeps its name («sólo vencidas») and is one
|
|
247
|
+
* piece, since that name is somebody's decision and not the condition read aloud.
|
|
248
|
+
*/
|
|
249
|
+
export type ChipParts = {
|
|
250
|
+
kind: "condition";
|
|
251
|
+
field: QueryField;
|
|
252
|
+
op: string;
|
|
253
|
+
value: string;
|
|
254
|
+
} | {
|
|
255
|
+
kind: "values";
|
|
256
|
+
field: QueryField;
|
|
257
|
+
values: readonly RecordOption[];
|
|
258
|
+
};
|
|
259
|
+
export declare function chipParts(node: SearchCriteria, fields: readonly QueryField[]): ChipParts | undefined;
|
|
260
|
+
/** The same chip asking with another comparison or value — its identity (`id`) kept, so it
|
|
261
|
+
* stays where it was and nothing that points at it loses it. */
|
|
262
|
+
export declare function withParts(node: SearchCriteria, field: QueryField, op: string, value: string): SearchCriteria;
|
|
239
263
|
/** What asks for these values of a field: records of a relation by their key (see
|
|
240
264
|
* `recordsFilter`), values of an enum or of any column with `=` / `in`. */
|
|
241
265
|
export declare function valuesSelection(field: QueryField, values: readonly RecordOption[]): BuiltCondition | BuiltFilter;
|
|
@@ -617,6 +617,35 @@ export function conditionCriteria(field, op, value) {
|
|
|
617
617
|
«está vacío»: sending it the empty string would be asking for the field that is "". */
|
|
618
618
|
{ field: field.field, operator: op, value: withoutValue(op) ? true : value }, describeCondition(field, op, value));
|
|
619
619
|
}
|
|
620
|
+
export function chipParts(node, fields) {
|
|
621
|
+
if (node.kind !== "filter" || node.selection === undefined)
|
|
622
|
+
return undefined;
|
|
623
|
+
if (node.values !== undefined) {
|
|
624
|
+
const field = fields.find((one) => node.id === `v:${fieldKey(one)}`);
|
|
625
|
+
return field === undefined || node.values.length === 0
|
|
626
|
+
? undefined
|
|
627
|
+
: { kind: "values", field, values: node.values };
|
|
628
|
+
}
|
|
629
|
+
const selection = node.selection;
|
|
630
|
+
if (!("operator" in selection))
|
|
631
|
+
return undefined;
|
|
632
|
+
const op = selection.operator;
|
|
633
|
+
const raw = selection.value;
|
|
634
|
+
const value = withoutValue(op)
|
|
635
|
+
? ""
|
|
636
|
+
: typeof raw === "string" || typeof raw === "number"
|
|
637
|
+
? String(raw)
|
|
638
|
+
: undefined;
|
|
639
|
+
if (value === undefined)
|
|
640
|
+
return undefined;
|
|
641
|
+
const field = fields.find((one) => one.field === selection.field && node.label === describeCondition(one, op, value));
|
|
642
|
+
return field === undefined ? undefined : { kind: "condition", field, op, value };
|
|
643
|
+
}
|
|
644
|
+
/** The same chip asking with another comparison or value — its identity (`id`) kept, so it
|
|
645
|
+
* stays where it was and nothing that points at it loses it. */
|
|
646
|
+
export function withParts(node, field, op, value) {
|
|
647
|
+
return { ...conditionCriteria(field, op, value), id: node.id };
|
|
648
|
+
}
|
|
620
649
|
/** What asks for these values of a field: records of a relation by their key (see
|
|
621
650
|
* `recordsFilter`), values of an enum or of any column with `=` / `in`. */
|
|
622
651
|
export function valuesSelection(field, values) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Surface } from "../../foundations/types.js";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
export declare function AppFrame({
|
|
4
|
+
/** A notice about the whole application — a `Banner` — above the bar, edge to edge. It
|
|
5
|
+
* scrolls away with the page: stuck on top it would take a line from every screen. */
|
|
6
|
+
banner,
|
|
4
7
|
/** The bar at the top. It stays in view while scrolling. */
|
|
5
8
|
menu,
|
|
6
9
|
/** The band at the bottom. It goes AFTER the content, not pinned to the
|
|
@@ -20,6 +23,7 @@ sidebarSurface,
|
|
|
20
23
|
/** Who scrolls. `page` (the default): the whole page, with the bars stuck on top. `view`:
|
|
21
24
|
* the frame is the window's height and the view scrolls inside itself — a workspace. */
|
|
22
25
|
scroll, children, }: {
|
|
26
|
+
banner?: ReactNode;
|
|
23
27
|
menu?: ReactNode;
|
|
24
28
|
status?: ReactNode;
|
|
25
29
|
sidebar?: ReactNode;
|
|
@@ -134,6 +134,9 @@ function SidebarDrawerPanel({ id, open, onClose, surface, children, }) {
|
|
|
134
134
|
}, isDismissable: true, className: ({ isEntering, isExiting }) => `fixed inset-0 z-50 bg-scrim/40 transition-opacity duration-(--duration-quick) ease-(--ease-out) sm:hidden print:hidden ${isEntering || isExiting ? "opacity-0" : ""}`, children: _jsx(Modal, { className: ({ isEntering, isExiting }) => `fixed inset-y-0 start-0 flex w-(--container-drawer) flex-col border-e shadow-window outline-0 transition-[translate] duration-(--duration-panel) ease-(--ease-out) ${bySurface(surface, "border-line-strong bg-ground", "border-chrome-edge bg-chrome")} ${isEntering || isExiting ? "-translate-x-full rtl:translate-x-full" : ""}`, children: _jsx(AriaDialog, { id: id, "aria-label": copy.shell.navigation, className: "flex min-h-0 flex-1 flex-col outline-0", children: _jsxs(SurfaceProvider, { value: surface, children: [_jsx("div", { className: "flex shrink-0 justify-end px-2 pt-2", children: _jsx(IconButton, { icon: X, label: copy.shell.close, onClick: onClose }) }), _jsx("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto", onClickCapture: closeOnLink(onClose), children: children })] }) }) }) }));
|
|
135
135
|
}
|
|
136
136
|
export function AppFrame({
|
|
137
|
+
/** A notice about the whole application — a `Banner` — above the bar, edge to edge. It
|
|
138
|
+
* scrolls away with the page: stuck on top it would take a line from every screen. */
|
|
139
|
+
banner,
|
|
137
140
|
/** The bar at the top. It stays in view while scrolling. */
|
|
138
141
|
menu,
|
|
139
142
|
/** The band at the bottom. It goes AFTER the content, not pinned to the
|
|
@@ -201,7 +204,7 @@ scroll = "page", children, }) {
|
|
|
201
204
|
for both made the navigation read as part of the list bar. On the chrome it wears the
|
|
202
205
|
brand's colour. On a phone it is hidden: the drawer shows it. */
|
|
203
206
|
const aside = sidebar === undefined ? null : (_jsx("aside", { className: `sticky w-(--container-sidebar) shrink-0 self-start overflow-y-auto overscroll-contain border-r max-sm:hidden print:hidden ${bySurface(sidebarSurface, "border-ui-sidebar-border bg-ui-sidebar", "border-chrome-edge bg-chrome")}`, style: { ...stickyTop, height: "calc(100dvh - var(--sticky-top, 0px))" }, "data-ui": "frame.sidebar", children: _jsx(SurfaceProvider, { value: sidebarSurface, children: sidebar }) }));
|
|
204
|
-
return (_jsx(SidebarDrawerContext, { value: drawer, children: _jsxs("div", { className: `relative flex min-w-0 flex-col bg-ground ${fills ? "h-dvh overflow-hidden print:h-auto print:overflow-visible" : "min-h-dvh"}`, "data-ui": "frame", "data-scroll": scroll, children: [top === undefined ? null : (
|
|
207
|
+
return (_jsx(SidebarDrawerContext, { value: drawer, children: _jsxs("div", { className: `relative flex min-w-0 flex-col bg-ground ${fills ? "h-dvh overflow-hidden print:h-auto print:overflow-visible" : "min-h-dvh"}`, "data-ui": "frame", "data-scroll": scroll, children: [banner === undefined ? null : (_jsx("div", { className: "shrink-0", "data-ui": "frame.banner", children: banner })), top === undefined ? null : (
|
|
205
208
|
/* Hidden on a wide screen when it is only the phone's bar: it measures 0 there, so
|
|
206
209
|
nothing below is pushed down by it. */
|
|
207
210
|
_jsx("div", { ref: bar.ref, className: `sticky top-0 z-40 print:hidden ${sidebarIsChrome ? "sm:hidden" : ""}`, "data-ui": "frame.bar", children: top })), sidebar === undefined ? (_jsx("main", { className: `flex min-w-0 flex-1 flex-col ${mainScroll}`, style: fills ? stickyReset() : bar.below, "data-ui": "frame.main", children: children })) : sidebarIsChrome ? (_jsxs("div", { className: `flex min-w-0 flex-1 items-start ${region}`, style: bar.below, children: [aside, _jsx("main", { className: `flex min-w-0 flex-1 flex-col self-stretch ${mainScroll}`, ...(fills ? { style: stickyReset() } : {}), "data-ui": "frame.main", children: children })] })) : (_jsx(HeaderSlotContext, { value: slot, children: _jsxs("div", { className: `flex min-w-0 flex-1 flex-col ${region}`, style: bar.below, children: [_jsx("div", { ref: (node) => {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Tone } from "../../foundations/types.js";
|
|
2
|
+
import { type LucideIcon } from "lucide-react";
|
|
3
|
+
export type InboxItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
/** What happened, in a line: «Tu pedido 0047 salió a reparto». */
|
|
6
|
+
title: string;
|
|
7
|
+
/** The rest, two lines at most. */
|
|
8
|
+
detail?: string;
|
|
9
|
+
when: Date | string;
|
|
10
|
+
/** Not seen yet: a dot, the title in bold, and said. */
|
|
11
|
+
unread?: boolean;
|
|
12
|
+
/** When it is a notice of a degree — a payment rejected (`bad`), a stock low (`warn`). Its
|
|
13
|
+
* icon comes with it, as in a `Callout`. */
|
|
14
|
+
tone?: Extract<Tone, "info" | "warn" | "bad" | "good">;
|
|
15
|
+
/** An icon of its own (a truck, a message) when it is not a notice of a degree. */
|
|
16
|
+
icon?: LucideIcon;
|
|
17
|
+
};
|
|
18
|
+
export type InboxListProps = {
|
|
19
|
+
items: readonly InboxItem[];
|
|
20
|
+
/** Pressing one: the application opens what it is about (and marks it read). */
|
|
21
|
+
onOpen?: (id: string) => void;
|
|
22
|
+
/** «Marcar todo como leído» — drawn while something is unread. */
|
|
23
|
+
onMarkAllRead?: () => void;
|
|
24
|
+
/** «Ver todas» — the page with the whole history, when the application has one. */
|
|
25
|
+
onSeeAll?: () => void;
|
|
26
|
+
/** «Notificaciones» by default. */
|
|
27
|
+
title?: string;
|
|
28
|
+
/** The clock the times are read against; now by default (a test passes a fixed one). */
|
|
29
|
+
now?: Date;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The notifications themselves, as a list: in the bar's popover (`Inbox`), or as the whole
|
|
33
|
+
* page of a portal's «Notificaciones».
|
|
34
|
+
*
|
|
35
|
+
* Context: unread is not only a colour — the dot goes with the title in bold and with the word
|
|
36
|
+
* said to a screen reader. The time is relative while it is recent («hace 5 minutos») and a
|
|
37
|
+
* date after a week, the way the activity writes it. The newest first is the application's
|
|
38
|
+
* order: it is passed already sorted, as a list is.
|
|
39
|
+
*/
|
|
40
|
+
export declare function InboxList({ items, onOpen, onMarkAllRead, onSeeAll, title, now, }: InboxListProps): import("react").JSX.Element;
|
|
41
|
+
export type InboxProps = InboxListProps & {
|
|
42
|
+
/** The bell by default. */
|
|
43
|
+
icon?: LucideIcon;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The notifications, from the bar: a bell with how many are unread, and the list in a
|
|
47
|
+
* popover — the portal's «tu pedido salió», the ERP's «te asignaron una tarea».
|
|
48
|
+
*
|
|
49
|
+
* Context: the bell is a `SystrayButton` — zero is not drawn, past 99 it says «99+», and the
|
|
50
|
+
* number is in its name — and the list is `InboxList` on the paper even under the navy bar.
|
|
51
|
+
* Opening one closes the popover: what it is about takes the screen.
|
|
52
|
+
*/
|
|
53
|
+
export declare function Inbox({ icon, onOpen, ...list }: InboxProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { SystrayButton } from "./TopBar.js";
|
|
4
|
+
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
5
|
+
import { SurfaceProvider } from "../../foundations/surface.js";
|
|
6
|
+
import { Button } from "../../primitives/button/Button.js";
|
|
7
|
+
import { Empty } from "../../primitives/notice/Notice.js";
|
|
8
|
+
import { NOTICE_ICON } from "../../primitives/notice/tones.js";
|
|
9
|
+
import { Popover } from "../../primitives/overlay/Popover.js";
|
|
10
|
+
import { formatRelative } from "../../primitives/value/format.js";
|
|
11
|
+
import { Bell } from "lucide-react";
|
|
12
|
+
import { useState } from "react";
|
|
13
|
+
import { Dialog, DialogTrigger, Heading, Pressable } from "react-aria-components";
|
|
14
|
+
const ICON_TONE = {
|
|
15
|
+
info: "text-info",
|
|
16
|
+
good: "text-good",
|
|
17
|
+
warn: "text-warn",
|
|
18
|
+
bad: "text-bad",
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The notifications themselves, as a list: in the bar's popover (`Inbox`), or as the whole
|
|
22
|
+
* page of a portal's «Notificaciones».
|
|
23
|
+
*
|
|
24
|
+
* Context: unread is not only a colour — the dot goes with the title in bold and with the word
|
|
25
|
+
* said to a screen reader. The time is relative while it is recent («hace 5 minutos») and a
|
|
26
|
+
* date after a week, the way the activity writes it. The newest first is the application's
|
|
27
|
+
* order: it is passed already sorted, as a list is.
|
|
28
|
+
*/
|
|
29
|
+
export function InboxList({ items, onOpen, onMarkAllRead, onSeeAll, title, now, }) {
|
|
30
|
+
const copy = useUiCopy();
|
|
31
|
+
const unread = items.filter((item) => item.unread === true).length;
|
|
32
|
+
return (_jsxs("div", { "data-ui": "inbox", className: "flex min-w-0 flex-col", children: [_jsxs("div", { className: "flex items-center justify-between gap-3 border-b border-line px-3 py-2", children: [_jsxs(Heading, { slot: "title", level: 2, className: "text-meta font-semibold text-ink", children: [title ?? copy.inbox.label, unread === 0 ? null : (_jsx("span", { className: "ml-1.5 font-normal text-muted tabular-nums", children: fillCopy(copy.inbox.unreadCount, { count: unread }) }))] }), onMarkAllRead === undefined || unread === 0 ? null : (_jsx(Button, { role: "ghost", size: "sm", onClick: onMarkAllRead, children: copy.inbox.markAllRead }))] }), items.length === 0 ? (_jsx(Empty, { sentence: copy.inbox.empty })) : (_jsx("ul", { className: "flex flex-col divide-y divide-line", children: items.map((item) => {
|
|
33
|
+
const Icon = item.icon ?? (item.tone === undefined ? undefined : NOTICE_ICON[item.tone]);
|
|
34
|
+
const fresh = item.unread === true;
|
|
35
|
+
return (_jsx("li", { children: _jsxs("button", { type: "button", "data-ui": "inbox.item", "data-unread": fresh ? "" : undefined, onClick: () => onOpen?.(item.id), className: `flex w-full items-start gap-3 px-3 py-2.5 text-left transition-colors duration-(--duration-instant) hover:bg-ink/4 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${fresh ? "bg-primary/4" : ""}`, children: [Icon === undefined ? null : (_jsx(Icon, { "aria-hidden": true, strokeWidth: 2, className: `mt-0.5 size-(--size-icon-md) shrink-0 ${item.tone === undefined ? "text-muted" : ICON_TONE[item.tone]}` })), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [_jsxs("span", { className: `text-meta text-ink ${fresh ? "font-semibold" : "font-normal"}`, children: [fresh ? _jsxs("span", { className: "sr-only", children: [copy.inbox.unread, ": "] }) : null, item.title] }), item.detail === undefined ? null : (_jsx("span", { className: "line-clamp-2 text-meta text-muted", children: item.detail })), _jsx("span", { className: "text-micro text-muted tabular-nums", children: formatRelative(new Date(item.when), now, copy) })] }), fresh ? (_jsx("span", { "aria-hidden": true, className: "mt-1.5 size-2 shrink-0 rounded-pill bg-primary" })) : null] }) }, item.id));
|
|
36
|
+
}) })), onSeeAll === undefined ? null : (_jsx("div", { className: "border-t border-line px-1 py-1", children: _jsx(Button, { role: "ghost", size: "sm", onClick: onSeeAll, children: copy.inbox.seeAll }) }))] }));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The notifications, from the bar: a bell with how many are unread, and the list in a
|
|
40
|
+
* popover — the portal's «tu pedido salió», the ERP's «te asignaron una tarea».
|
|
41
|
+
*
|
|
42
|
+
* Context: the bell is a `SystrayButton` — zero is not drawn, past 99 it says «99+», and the
|
|
43
|
+
* number is in its name — and the list is `InboxList` on the paper even under the navy bar.
|
|
44
|
+
* Opening one closes the popover: what it is about takes the screen.
|
|
45
|
+
*/
|
|
46
|
+
export function Inbox({ icon = Bell, onOpen, ...list }) {
|
|
47
|
+
const copy = useUiCopy();
|
|
48
|
+
const [open, setOpen] = useState(false);
|
|
49
|
+
const unread = list.items.filter((item) => item.unread === true).length;
|
|
50
|
+
const label = list.title ?? copy.inbox.label;
|
|
51
|
+
return (_jsxs(DialogTrigger, { isOpen: open, onOpenChange: setOpen, children: [_jsx(Pressable, { children: _jsx(SystrayButton, { icon: icon, label: label, count: unread, active: open, "aria-haspopup": "dialog", "aria-expanded": open }) }), _jsx(Popover, { placement: "bottom end", children: _jsx(Dialog, { "aria-label": label, className: "max-h-[inherit] w-(--container-inbox) overflow-auto outline-0", children: _jsx(SurfaceProvider, { value: "canvas", children: _jsx(InboxList, { ...list, onOpen: (id) => {
|
|
52
|
+
setOpen(false);
|
|
53
|
+
onOpen?.(id);
|
|
54
|
+
} }) }) }) })] }));
|
|
55
|
+
}
|
|
@@ -4,15 +4,14 @@ import { useSidebarDrawer } from "./sidebarDrawer.js";
|
|
|
4
4
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
5
5
|
import { modShortcut, useKeyboardPlatform } from "../../foundations/shortcut.js";
|
|
6
6
|
import { useSurface } from "../../foundations/surface.js";
|
|
7
|
+
import { Kbd } from "../../primitives/hint/Kbd.js";
|
|
7
8
|
import { Search } from "lucide-react";
|
|
8
9
|
const SKIN = {
|
|
9
10
|
canvas: {
|
|
10
11
|
box: "border-ui-control-border bg-ui-control text-muted hover:border-line-strong hover:text-ink focus-visible:outline-primary",
|
|
11
|
-
keys: "border-line text-muted",
|
|
12
12
|
},
|
|
13
13
|
chrome: {
|
|
14
14
|
box: "border-chrome-ink/15 bg-chrome-ink/6 text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink focus-visible:outline-chrome-link",
|
|
15
|
-
keys: "border-chrome-ink/20 text-chrome-muted",
|
|
16
15
|
},
|
|
17
16
|
};
|
|
18
17
|
export function SearchEntry({ onSearch, label, shortcut = "K", layout = "row", surface, }) {
|
|
@@ -30,5 +29,5 @@ export function SearchEntry({ onSearch, label, shortcut = "K", layout = "row", s
|
|
|
30
29
|
}, ...(keys === null ? {} : { "aria-keyshortcuts": keys.aria }), className: `flex h-(--size-control-sm) min-w-0 cursor-pointer items-center gap-2 rounded-ui-control border px-2 text-meta transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 ${bar ? "shrink-0 max-sm:w-(--size-control-sm) max-sm:justify-center" : "w-full"} ${skin.box}`, "data-ui": "search-entry", "data-surface": sup, children: [_jsx(Search, { className: "size-(--size-icon-md) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-left ${bar ? "max-sm:sr-only" : ""}`, children: label ?? copy.shell.search }), keys === null ? null : (
|
|
31
30
|
/* Seen, not heard: `aria-keyshortcuts` already tells a screen reader, and «⌘K» read
|
|
32
31
|
aloud is noise after the name. Not drawn for a finger: a phone has no ⌘. */
|
|
33
|
-
_jsx("
|
|
32
|
+
_jsx("span", { className: `inline-flex shrink-0 ${bar ? "max-sm:hidden" : ""}`, "data-ui": "search-entry.keys", children: _jsx(Kbd, { surface: sup, children: keys.label }) }))] }));
|
|
34
33
|
}
|
|
@@ -2,7 +2,7 @@ import { type BrandLogo } from "./brandMark.js";
|
|
|
2
2
|
import { type SearchEntryProps } from "./SearchEntry.js";
|
|
3
3
|
import { type MenuGroup } from "../../primitives/menu/Menu.js";
|
|
4
4
|
import { type LucideIcon } from "lucide-react";
|
|
5
|
-
import { type ReactNode } from "react";
|
|
5
|
+
import { type ButtonHTMLAttributes, type ReactNode, type Ref } from "react";
|
|
6
6
|
export interface AppEntry {
|
|
7
7
|
id: string;
|
|
8
8
|
label: string;
|
|
@@ -68,13 +68,15 @@ export declare function AppSwitcher({ apps, current, onSelect, }: {
|
|
|
68
68
|
* Zero is NOT drawn: a bell with a «0» next to it forces you to read a number
|
|
69
69
|
* to discover there is nothing. With no count you can already see there is
|
|
70
70
|
* nothing. */
|
|
71
|
-
export declare function SystrayButton({ icon: Icon, label, count, tone, onClick, active, }: {
|
|
71
|
+
export declare function SystrayButton({ icon: Icon, label, count, tone, onClick, active, ref, ...native }: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "type" | "onClick"> & {
|
|
72
72
|
icon: LucideIcon;
|
|
73
73
|
label: string;
|
|
74
74
|
count?: number;
|
|
75
75
|
tone?: "info" | "warn" | "bad";
|
|
76
76
|
onClick?: () => void;
|
|
77
77
|
active?: boolean;
|
|
78
|
+
/** Forwarded, with the native props, so a popover or a menu can open from it — `Inbox`. */
|
|
79
|
+
ref?: Ref<HTMLButtonElement>;
|
|
78
80
|
}): import("react").JSX.Element;
|
|
79
81
|
/** Who I am and how I leave. The name is drawn when there is width; when narrow
|
|
80
82
|
* only the avatar stays, which is what gets recognised without reading. */
|
|
@@ -9,7 +9,7 @@ import { Menu } from "../../primitives/menu/Menu.js";
|
|
|
9
9
|
import { Count, countText } from "../../primitives/tag/Count.js";
|
|
10
10
|
import { Avatar } from "../../primitives/value/Person.js";
|
|
11
11
|
import { Grid3x3 } from "lucide-react";
|
|
12
|
-
import { useMemo, useState } from "react";
|
|
12
|
+
import { useMemo, useState, } from "react";
|
|
13
13
|
export function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, search, systray, user, onUserSelect, userGroups, }) {
|
|
14
14
|
const copy = useUiCopy();
|
|
15
15
|
const actual = apps?.find((a) => a.id === currentApp);
|
|
@@ -42,13 +42,13 @@ const SYSTRAY_MAX = 99;
|
|
|
42
42
|
* Zero is NOT drawn: a bell with a «0» next to it forces you to read a number
|
|
43
43
|
* to discover there is nothing. With no count you can already see there is
|
|
44
44
|
* nothing. */
|
|
45
|
-
export function SystrayButton({ icon: Icon, label, count = 0, tone = "info", onClick, active = false, }) {
|
|
45
|
+
export function SystrayButton({ icon: Icon, label, count = 0, tone = "info", onClick, active = false, ref, ...native }) {
|
|
46
46
|
const copy = useUiCopy();
|
|
47
47
|
const number = useMemo(() => new Intl.NumberFormat(copy.locale), [copy.locale]);
|
|
48
48
|
/* The button says the number in its name, so the badge is only seen — and both say the
|
|
49
49
|
same «99+», not a badge that is cut and a name that is not. */
|
|
50
50
|
const said = countText(count, number.format, SYSTRAY_MAX);
|
|
51
|
-
return (_jsxs("button", { type: "button", onClick: onClick, title: count > 0 ? `${label} (${said})` : label, "aria-label": count > 0 ? `${label}: ${said}` : label, className: `relative inline-flex size-(--size-control-md) items-center justify-center rounded-pill transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-link ${active
|
|
51
|
+
return (_jsxs("button", { ...native, ref: ref, type: "button", onClick: onClick, title: count > 0 ? `${label} (${said})` : label, "aria-label": count > 0 ? `${label}: ${said}` : label, className: `relative inline-flex size-(--size-control-md) items-center justify-center rounded-pill transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-link ${active
|
|
52
52
|
? "bg-chrome-ink/12 text-chrome-ink"
|
|
53
53
|
: "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink"}`, children: [_jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 2, "aria-hidden": true }), count <= 0 ? null : (_jsx("span", { className: "absolute -top-0.5 -right-0.5 flex", children: _jsx(Count, { value: count, tone: tone, solid: true, max: SYSTRAY_MAX, surface: "chrome", "aria-hidden": true }) }))] }));
|
|
54
54
|
}
|
|
@@ -4,5 +4,6 @@ export { Sidebar, type SidebarAction, type SidebarProps, } from "./Sidebar.js";
|
|
|
4
4
|
export { SearchEntry, type SearchEntryProps, } from "./SearchEntry.js";
|
|
5
5
|
export { type SidebarDrawer, SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
6
6
|
export { type AppEntry, SystrayButton, TopBar, type TopMenu, } from "./TopBar.js";
|
|
7
|
+
export { Inbox, type InboxItem, InboxList, type InboxListProps, type InboxProps, } from "./Inbox.js";
|
|
7
8
|
export { KioskFrame, type KioskFrameProps, } from "./KioskFrame.js";
|
|
8
9
|
export { Pane, Panes } from "./Panes.js";
|
|
@@ -10,6 +10,9 @@ export { SearchEntry, } from "./SearchEntry.js";
|
|
|
10
10
|
/* The sidebar's phone drawer, for a bar an application writes itself. */
|
|
11
11
|
export { SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
12
12
|
export { SystrayButton, TopBar, } from "./TopBar.js";
|
|
13
|
+
/* The notifications: a bell with how many are unread and the list in a popover — or the list
|
|
14
|
+
alone, as a portal's page. */
|
|
15
|
+
export { Inbox, InboxList, } from "./Inbox.js";
|
|
13
16
|
/* A screen of N sets side by side — the reconciliation: each pane scrolls on its own. */
|
|
14
17
|
export { KioskFrame, } from "./KioskFrame.js";
|
|
15
18
|
export { Pane, Panes } from "./Panes.js";
|