@sincpro/web-ui 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +111 -0
  2. package/dist/components/attachments/Attachments.d.ts +7 -1
  3. package/dist/components/attachments/Attachments.js +8 -2
  4. package/dist/components/board/Board.d.ts +32 -2
  5. package/dist/components/board/Board.js +27 -4
  6. package/dist/components/board/index.d.ts +1 -1
  7. package/dist/components/board/index.js +2 -1
  8. package/dist/components/listing/GroupingLevels.js +11 -9
  9. package/dist/components/listing/RecordCard.js +1 -1
  10. package/dist/components/listing/Row.js +2 -2
  11. package/dist/components/navigation/NavigationTree.js +37 -10
  12. package/dist/components/search/CriteriaBuilder.js +3 -2
  13. package/dist/components/search/CriteriaChips.js +6 -5
  14. package/dist/components/search/JoinWord.js +1 -1
  15. package/dist/components/search/SearchBar.js +68 -29
  16. package/dist/components/shell/AppFrame.d.ts +18 -2
  17. package/dist/components/shell/AppFrame.js +143 -12
  18. package/dist/components/shell/Sidebar.d.ts +39 -0
  19. package/dist/components/shell/Sidebar.js +57 -0
  20. package/dist/components/shell/TopBar.d.ts +10 -1
  21. package/dist/components/shell/TopBar.js +18 -13
  22. package/dist/components/shell/brandMark.d.ts +17 -0
  23. package/dist/components/shell/brandMark.js +9 -0
  24. package/dist/components/shell/index.d.ts +3 -0
  25. package/dist/components/shell/index.js +6 -0
  26. package/dist/components/shell/sidebarDrawer.d.ts +26 -0
  27. package/dist/components/shell/sidebarDrawer.js +22 -0
  28. package/dist/foundations/copy.d.ts +13 -0
  29. package/dist/foundations/copy.es.js +12 -5
  30. package/dist/foundations/copy.js +12 -5
  31. package/dist/foundations/variants.js +19 -2
  32. package/dist/primitives/block/Block.js +1 -1
  33. package/dist/primitives/button/Button.d.ts +3 -1
  34. package/dist/primitives/button/Button.js +6 -6
  35. package/dist/primitives/choice/SegmentedControl.d.ts +4 -1
  36. package/dist/primitives/choice/SegmentedControl.js +35 -7
  37. package/dist/primitives/dialog/Dialog.d.ts +1 -1
  38. package/dist/primitives/dialog/Dialog.js +2 -2
  39. package/dist/primitives/field/CardNumberInput.js +1 -1
  40. package/dist/primitives/field/Checks.d.ts +14 -0
  41. package/dist/primitives/field/Checks.js +12 -4
  42. package/dist/primitives/field/DropZone.d.ts +22 -3
  43. package/dist/primitives/field/DropZone.js +33 -12
  44. package/dist/primitives/field/DurationInput.js +1 -1
  45. package/dist/primitives/field/Field.js +7 -7
  46. package/dist/primitives/field/PatternInput.js +1 -1
  47. package/dist/primitives/field/RichTextEditor.js +2 -2
  48. package/dist/primitives/field/SignatureInput.js +1 -1
  49. package/dist/primitives/field/aria.d.ts +2 -2
  50. package/dist/primitives/field/aria.js +5 -5
  51. package/dist/primitives/field/index.d.ts +1 -1
  52. package/dist/primitives/field/index.js +1 -1
  53. package/dist/primitives/menu/Menu.d.ts +29 -9
  54. package/dist/primitives/menu/Menu.js +77 -22
  55. package/dist/primitives/overlay/Popover.js +2 -2
  56. package/dist/primitives/picker/Picker.js +3 -3
  57. package/dist/primitives/picker/TagsField.js +1 -1
  58. package/dist/primitives/table/EditableTable.js +2 -2
  59. package/dist/primitives/table/ReportTable.js +1 -1
  60. package/dist/primitives/table/Table.js +2 -2
  61. package/dist/primitives/tabs/Tabs.js +2 -28
  62. package/dist/primitives/tag/Count.d.ts +23 -0
  63. package/dist/primitives/tag/Count.js +59 -0
  64. package/dist/primitives/tag/Tag.d.ts +9 -0
  65. package/dist/primitives/tag/Tag.js +14 -1
  66. package/dist/primitives/tag/Tags.js +6 -7
  67. package/dist/primitives/tag/index.d.ts +1 -0
  68. package/dist/primitives/tag/index.js +3 -0
  69. package/dist/primitives/value/Metric.d.ts +7 -2
  70. package/dist/primitives/value/Metric.js +14 -6
  71. package/dist/tokens.css +306 -72
  72. package/package.json +1 -1
@@ -6,7 +6,15 @@ import { useFormMode } from "../../foundations/form.js";
6
6
  import { Check, Minus } from "lucide-react";
7
7
  import { useId } from "react";
8
8
  import { Checkbox as AriaCheckbox, ListBox, ListBoxItem, } from "react-aria-components";
9
- function Mark({ on, mixed, focus = false, invalid = false, }) {
9
+ /**
10
+ * The drawn box of a check, with no behaviour of its own.
11
+ *
12
+ * Context: exported for the rows that ARE a multiple choice without being a form input —
13
+ * the filters of the search panel, a grouping level — so they mark «on» with the same box
14
+ * as `Checkbox`. The host carries the semantics (`aria-pressed`, a listbox option); this
15
+ * is `aria-hidden`.
16
+ */
17
+ export function CheckMark({ on, mixed = false, focus = false, invalid = false, }) {
10
18
  return (_jsx("span", { "aria-hidden": true, className: `inline-flex size-4 shrink-0 items-center justify-center rounded-mark border transition-colors duration-(--duration-instant) forced-color-adjust-none ${on
11
19
  ? "border-primary bg-primary text-surface forced-colors:border-[Highlight] forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]"
12
20
  : `bg-surface text-transparent ${invalid ? "border-danger" : "border-line-strong"} forced-colors:border-[ButtonBorder]`} ${focus ? "outline-2 outline-offset-2 outline-primary forced-colors:outline-[Highlight]" : ""}`, children: mixed ? (_jsx(Minus, { className: "size-3", strokeWidth: 2.5 })) : (_jsx(Check, { className: "size-3", strokeWidth: 2.5 })) }));
@@ -33,9 +41,9 @@ export function Checkbox({ checked, mixed = false, onChange, label, disabled = f
33
41
  const textId = useId();
34
42
  const on = checked || mixed;
35
43
  if (useFormMode(mode) === "read") {
36
- return (_jsxs("span", { className: "flex min-h-(--size-control-md) items-center gap-2 text-meta text-ink", children: [_jsx(Mark, { on: on, mixed: mixed && !checked }), label] }));
44
+ return (_jsxs("span", { className: "flex min-h-(--size-control-md) items-center gap-2 text-meta text-ink", children: [_jsx(CheckMark, { on: on, mixed: mixed && !checked }), label] }));
37
45
  }
38
- return (_jsx(AriaCheckbox, { id: id, "aria-labelledby": labelledBy === undefined ? undefined : `${labelledBy} ${textId}`, "aria-describedby": describedBy, isSelected: checked, isIndeterminate: mixed, onChange: (next) => onChange?.(mixed ? true : next), isDisabled: disabled, isInvalid: invalid, className: "group inline-flex min-w-0 cursor-pointer items-center gap-2.5 text-meta text-ink disabled:cursor-not-allowed disabled:opacity-45", children: ({ isSelected, isIndeterminate, isFocusVisible, isInvalid }) => (_jsxs(_Fragment, { children: [_jsx(Mark, { on: isSelected || isIndeterminate, mixed: isIndeterminate, focus: isFocusVisible, invalid: isInvalid }), _jsx("span", { id: textId, className: "min-w-0", children: label })] })) }));
46
+ return (_jsx(AriaCheckbox, { id: id, "aria-labelledby": labelledBy === undefined ? undefined : `${labelledBy} ${textId}`, "aria-describedby": describedBy, isSelected: checked, isIndeterminate: mixed, onChange: (next) => onChange?.(mixed ? true : next), isDisabled: disabled, isInvalid: invalid, className: "group inline-flex min-w-0 cursor-pointer items-center gap-2.5 text-meta text-ink disabled:cursor-not-allowed disabled:opacity-45", children: ({ isSelected, isIndeterminate, isFocusVisible, isInvalid }) => (_jsxs(_Fragment, { children: [_jsx(CheckMark, { on: isSelected || isIndeterminate, mixed: isIndeterminate, focus: isFocusVisible, invalid: isInvalid }), _jsx("span", { id: textId, className: "min-w-0", children: label })] })) }));
39
47
  }
40
48
  /** The chosen values, in the order the person picked them — what `onChange` hands back. */
41
49
  function valuesOf(keys, items) {
@@ -68,5 +76,5 @@ export function CheckList({ label, items, value, onChange, mono = false, emptyLa
68
76
  }
69
77
  return (_jsxs("div", { className: "flex min-w-0 flex-col gap-1.5", children: [_jsx("p", { id: labelId, className: "text-micro text-muted", children: label }), _jsx(ListBox, { "aria-labelledby": labelId, "aria-describedby": describedBy, items: items, selectionMode: "multiple", selectedKeys: value, onSelectionChange: (keys) => onChange?.(valuesOf(keys, items)), disabledKeys: items.filter((item) => item.disabled).map((item) => item.value), shouldFocusWrap: true, className: "flex flex-col overflow-hidden rounded-box border border-line bg-surface outline-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary", children: (item) => (_jsx(ListBoxItem, { id: item.value, textValue: item.label, className: ({ isSelected, isFocusVisible, isDisabled }) => `flex min-w-0 cursor-pointer items-center gap-2.5 border-b border-line px-3 py-2 text-left outline-0 last:border-b-0 ${isFocusVisible
70
78
  ? "outline-2 -outline-offset-2 outline-primary forced-colors:outline-[Highlight]"
71
- : ""} ${isDisabled ? "cursor-not-allowed opacity-45" : ""} ${isSelected ? "bg-primary/8" : "hover:bg-ink/4"}`, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx(Mark, { on: isSelected, mixed: false }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: `truncate text-meta text-ink ${mono ? "font-mono" : ""}`, children: item.label }), item.detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-muted", children: item.detail }))] })] })) })) })] }));
79
+ : ""} ${isDisabled ? "cursor-not-allowed opacity-45" : ""} ${isSelected ? "bg-primary/8" : "hover:bg-ink/4"}`, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx(CheckMark, { on: isSelected }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: `truncate text-meta text-ink ${mono ? "font-mono" : ""}`, children: item.label }), item.detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-muted", children: item.detail }))] })] })) })) })] }));
72
80
  }
@@ -17,8 +17,17 @@ import { type FormMode } from "../../foundations/form.js";
17
17
  * say a dragged file's extension until it lands, and a drop that silently does
18
18
  * nothing reads as a broken zone. The file reaches `onFile`, and the consumer
19
19
  * answers with `error` when it cannot read it.
20
+ *
21
+ * ── One file, or several ─────────────────────────────────────────────
22
+ *
23
+ * `multiple` takes every file of a drop or of the dialog in ONE call to `onFiles` —
24
+ * a gallery gets its thirty photos as one batch, not thirty events. Listing what
25
+ * was chosen, with its thumbnails and per-file removal, is `Attachments`, which
26
+ * draws this zone: the zone takes files, it does not keep them. `max` caps the
27
+ * batch: the first `max` go through and the zone SAYS how many were left out — a
28
+ * silent cut is a photo nobody knows is missing.
20
29
  */
21
- export type DropZoneProps = {
30
+ type DropZoneCommon = {
22
31
  /** The browser's `accept` list: extensions and MIME types, comma-separated
23
32
  * (`".pdf,application/pdf"`). */
24
33
  accept?: string;
@@ -29,7 +38,6 @@ export type DropZoneProps = {
29
38
  fileName?: string;
30
39
  fileDetail?: string;
31
40
  error?: string | null;
32
- onFile: (file: File) => void;
33
41
  onCancel?: () => void;
34
42
  onRetry?: () => void;
35
43
  id?: string;
@@ -39,4 +47,15 @@ export type DropZoneProps = {
39
47
  * file's name. */
40
48
  mode?: FormMode;
41
49
  };
42
- export declare function DropZone({ accept, label, busy, progress, fileName, fileDetail, error, onFile, onCancel, onRetry, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, }: DropZoneProps): import("react").JSX.Element;
50
+ export type DropZoneProps = DropZoneCommon & ({
51
+ multiple?: false;
52
+ onFile: (file: File) => void;
53
+ } | {
54
+ multiple: true;
55
+ /** Every file of one drop, paste or choice, in their order. */
56
+ onFiles: (files: File[]) => void;
57
+ /** At most this many per batch; the rest are left out, and the zone says so. */
58
+ max?: number;
59
+ });
60
+ export declare function DropZone(props: DropZoneProps): import("react").JSX.Element;
61
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useUiCopy } from "../../foundations/copy.js";
3
+ import { fillCopy, useUiCopy } from "../../foundations/copy.js";
4
4
  import { useFieldIds } from "../../foundations/form.js";
5
5
  import { useFormMode } from "../../foundations/form.js";
6
6
  import { cn } from "../../foundations/variants.js";
@@ -8,9 +8,13 @@ import { Button, buttonClasses } from "../button/Button.js";
8
8
  import { ReadValue } from "./Field.js";
9
9
  import { Failed } from "../notice/Notice.js";
10
10
  import { ProgressBar } from "../value/ProgressBar.js";
11
+ import { useState } from "react";
11
12
  import { Button as AriaButton, DropZone as AriaDropZone, FileTrigger, } from "react-aria-components";
12
- export function DropZone({ accept, label, busy = false, progress, fileName, fileDetail, error, onFile, onCancel, onRetry, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, }) {
13
+ export function DropZone(props) {
14
+ const { accept, label, busy = false, progress, fileName, fileDetail, error, onCancel, onRetry, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, } = props;
13
15
  const copy = useUiCopy();
16
+ /* How many the last batch left out, said under the zone until the next batch. */
17
+ const [leftOut, setLeftOut] = useState(null);
14
18
  const { id, labelledBy, describedBy, invalid } = useFieldIds({
15
19
  id: ownId,
16
20
  describedBy: ownDescribedBy,
@@ -19,20 +23,36 @@ export function DropZone({ accept, label, busy = false, progress, fileName, file
19
23
  const readMode = useFormMode(mode) === "read";
20
24
  if (readMode)
21
25
  return _jsx(ReadValue, { value: fileName ?? null });
22
- const sentence = label ?? copy.field.drop;
26
+ const many = props.multiple === true;
27
+ const sentence = label ?? (many ? copy.field.dropMany : copy.field.drop);
23
28
  const types = accept
24
29
  ?.split(",")
25
30
  .map((t) => t.trim())
26
31
  .filter((t) => t !== "");
32
+ function take(files) {
33
+ if (files.length === 0)
34
+ return;
35
+ if (props.multiple !== true) {
36
+ props.onFile(files[0]);
37
+ return;
38
+ }
39
+ const max = props.max;
40
+ const taken = max === undefined ? files : files.slice(0, max);
41
+ setLeftOut(taken.length < files.length ? { taken: taken.length, of: files.length } : null);
42
+ props.onFiles([...taken]);
43
+ }
27
44
  async function onDrop(items) {
28
45
  if (busy)
29
46
  return;
47
+ const files = [];
30
48
  for (const item of items) {
31
- if (item.kind === "file") {
32
- onFile(await item.getFile());
33
- return;
34
- }
49
+ if (item.kind !== "file")
50
+ continue;
51
+ files.push(await item.getFile());
52
+ if (!many)
53
+ break;
35
54
  }
55
+ take(files);
36
56
  }
37
57
  return (_jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsxs(AriaDropZone, { ...(labelledBy === undefined
38
58
  ? { "aria-label": sentence }
@@ -40,11 +60,12 @@ export function DropZone({ accept, label, busy = false, progress, fileName, file
40
60
  ? "border-primary bg-primary/8 forced-colors:border-[Highlight]"
41
61
  : invalid
42
62
  ? "border-danger bg-surface"
43
- : "border-line-strong bg-surface", isFocusVisible ? "outline-2" : "outline-0"), children: [_jsx("p", { className: "text-body text-muted", children: sentence }), busy ? (_jsxs("div", { className: "flex w-full max-w-sm flex-col items-center gap-2", children: [fileName === undefined ? null : (_jsx("p", { className: "max-w-full truncate text-body text-ink", children: fileName })), _jsx("div", { className: "w-full", children: _jsx(ProgressBar, { value: progress ?? 0, label: copy.field.uploadProgress, width: "w-full" }) }), fileDetail === undefined ? null : (_jsx("p", { className: "text-meta text-muted", children: fileDetail }))] })) : (_jsxs("div", { className: "flex flex-wrap items-center justify-center gap-3", children: [_jsx(FileTrigger, { ...(types === undefined ? {} : { acceptedFileTypes: types }), onSelect: (files) => {
44
- const file = files?.[0];
45
- if (file !== undefined)
46
- onFile(file);
47
- }, children: _jsx(AriaButton, { id: id, "data-emphasis": "secondary", className: buttonClasses("secondary", "md"), children: copy.field.chooseFile }) }), onCancel === undefined ? null : (_jsx(Button, { role: "ghost", onClick: onCancel, children: copy.field.cancel }))] }))] }), error === undefined || error === null ? null : (_jsx(Failed, { heading: copy.field.fileUnreadable, sentence: error, ...(onRetry === undefined
63
+ : "border-line-strong bg-surface", isFocusVisible ? "outline-2" : "outline-0"), children: [_jsx("p", { className: "text-body text-muted", children: sentence }), busy ? (_jsxs("div", { className: "flex w-full max-w-sm flex-col items-center gap-2", children: [fileName === undefined ? null : (_jsx("p", { className: "max-w-full truncate text-body text-ink", children: fileName })), _jsx("div", { className: "w-full", children: _jsx(ProgressBar, { value: progress ?? 0, label: copy.field.uploadProgress, width: "w-full" }) }), fileDetail === undefined ? null : (_jsx("p", { className: "text-meta text-muted", children: fileDetail }))] })) : (_jsxs("div", { className: "flex flex-wrap items-center justify-center gap-3", children: [_jsx(FileTrigger, { ...(types === undefined ? {} : { acceptedFileTypes: types }), allowsMultiple: many, onSelect: (files) => take(files === null ? [] : Array.from(files)), children: _jsx(AriaButton, { id: id, "data-emphasis": "secondary", className: buttonClasses("secondary", "md"), children: many ? copy.field.chooseFiles : copy.field.chooseFile }) }), onCancel === undefined ? null : (_jsx(Button, { role: "ghost", onClick: onCancel, children: copy.field.cancel }))] }))] }), _jsx("p", { role: "status", className: leftOut === null ? "sr-only" : "text-meta text-warn", children: leftOut === null
64
+ ? null
65
+ : fillCopy(copy.field.tooManyFiles, {
66
+ max: leftOut.taken.toLocaleString(copy.locale),
67
+ count: leftOut.of.toLocaleString(copy.locale),
68
+ }) }), error === undefined || error === null ? null : (_jsx(Failed, { heading: copy.field.fileUnreadable, sentence: error, ...(onRetry === undefined
48
69
  ? {}
49
70
  : {
50
71
  action: (_jsx(Button, { role: "ghost", onClick: onRetry, children: copy.field.tryAnother })),
@@ -50,5 +50,5 @@ export function DurationInput({ id: ownId, value, onChange, placeholder = "0:00"
50
50
  setDraft(null);
51
51
  onChange?.(minutes / 60);
52
52
  };
53
- return (_jsxs(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: draft ?? shown, onChange: setDraft, inputMode: "decimal", isInvalid: invalid, isDisabled: disabled, className: "flex w-full min-w-0 items-center gap-2", children: [_jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, onBlur: commit, onKeyDown: arrows, className: `${controlClasses(invalid)} tabular-nums` }), _jsx("span", { className: "shrink-0 text-meta text-muted", children: copy.field.hours })] }));
53
+ return (_jsxs(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: draft ?? shown, onChange: setDraft, inputMode: "decimal", isInvalid: invalid, isDisabled: disabled, className: "flex w-full min-w-0 items-center gap-2", children: [_jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, onBlur: commit, onKeyDown: arrows, "data-ui": "control", className: `${controlClasses(invalid)} tabular-nums` }), _jsx("span", { className: "shrink-0 text-meta text-muted", children: copy.field.hours })] }));
54
54
  }
@@ -128,9 +128,9 @@ export function ReadValue({ value, mono = false }) {
128
128
  * be born with another height, another radius or another focus. That was the
129
129
  * original defect: every file wrote its own `<input className="…">`. */
130
130
  export function controlClasses(invalid = false) {
131
- return `h-(--size-control-md) w-full min-w-0 rounded-control border bg-surface px-2.5 text-meta text-ink transition-colors duration-(--duration-instant) placeholder:text-muted focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:bg-ground disabled:text-muted ${invalid
131
+ return `h-(--size-control-md) w-full min-w-0 rounded-ui-control border bg-ui-control px-2.5 text-meta text-ink transition-colors duration-(--duration-instant) placeholder:text-muted focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:bg-ground disabled:text-muted ${invalid
132
132
  ? "border-danger focus-visible:border-danger focus-visible:outline-danger"
133
- : "border-line-strong focus-visible:border-primary focus-visible:outline-primary"}`;
133
+ : "border-ui-control-border focus-visible:border-primary focus-visible:outline-primary"}`;
134
134
  }
135
135
  /* `aria-describedby` goes on the INPUT and not on React Aria's field: the field adds the ids
136
136
  of its own description and error slots, which this system never renders (`Field` draws
@@ -157,7 +157,7 @@ export function TextInput({ id: ownId, value, onChange, placeholder, describedBy
157
157
  });
158
158
  if (useFormMode(mode) === "read")
159
159
  return _jsx(ReadValue, { value: value, mono: mono });
160
- return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: spellCheck, className: `${controlClasses(invalid)} ${mono ? "font-mono tabular-nums" : ""}` }) }));
160
+ return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: spellCheck, "data-ui": "control", className: `${controlClasses(invalid)} ${mono ? "font-mono tabular-nums" : ""}` }) }));
161
161
  }
162
162
  /** The amount, the quantity, the percentage — read in the copy's locale, every time. */
163
163
  function useReadNumber(format) {
@@ -224,17 +224,17 @@ export function TextArea({ id: ownId, value, onChange, placeholder, rows = 3, de
224
224
  if (useFormMode(mode) === "read") {
225
225
  return value === "" ? (_jsx(ReadValue, { value: null })) : (_jsx("span", { className: "text-meta whitespace-pre-line text-ink", children: value }));
226
226
  }
227
- return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(AriaTextArea, { "aria-describedby": describedBy, rows: rows, placeholder: placeholder, className: `${controlClasses(invalid)} h-auto resize-y py-1.5 leading-relaxed` }) }));
227
+ return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(AriaTextArea, { "aria-describedby": describedBy, rows: rows, placeholder: placeholder, "data-ui": "control", className: `${controlClasses(invalid)} h-auto resize-y py-1.5 leading-relaxed` }) }));
228
228
  }
229
229
  const selectTrigger = tv({
230
230
  extend: focusRing,
231
- base: "flex h-(--size-control-md) w-full min-w-0 cursor-default items-center gap-2 rounded-control border bg-surface pr-2 pl-2.5 text-start text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]",
231
+ base: "flex h-(--size-control-md) w-full min-w-0 cursor-default items-center gap-2 rounded-ui-control border bg-ui-control pr-2 pl-2.5 text-start text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]",
232
232
  variants: {
233
233
  isFocusVisible: {
234
234
  true: "border-primary",
235
235
  },
236
236
  isInvalid: {
237
- false: "border-line-strong forced-colors:border-[ButtonBorder]",
237
+ false: "border-ui-control-border forced-colors:border-[ButtonBorder]",
238
238
  true: "border-danger outline-danger forced-colors:border-[Mark]",
239
239
  },
240
240
  isDisabled: {
@@ -265,5 +265,5 @@ export function Select({ id: ownId, value, options, onChange, describedBy: ownDe
265
265
  if (useFormMode(mode) === "read") {
266
266
  return _jsx(ReadValue, { value: options.find((o) => o.value === value)?.label ?? null });
267
267
  }
268
- return (_jsx(AriaLocale, { children: _jsxs(AriaSelect, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), "aria-describedby": describedBy, value: value === "" ? null : value, onChange: (next) => onChange?.(next === null ? "" : String(next)), placeholder: placeholder, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: [_jsxs(AriaButton, { className: (state) => selectTrigger({ ...state, isInvalid: invalid }), children: [_jsx(SelectValue, { className: "min-w-0 flex-1 truncate data-placeholder:text-muted", children: ({ isPlaceholder, selectedText, defaultChildren }) => isPlaceholder ? defaultChildren : selectedText }), _jsx(ChevronDown, { "aria-hidden": true, className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2 })] }), _jsx(Popover, { placement: "bottom start", className: "min-w-(--trigger-width)", children: _jsx(ListBox, { items: options, className: "max-h-[inherit] overflow-auto p-1 outline-0", children: (option) => (_jsx(ListBoxItem, { id: option.value, textValue: option.label, isDisabled: option.disabled, className: listOptionStyles, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: `min-w-0 flex-1 truncate ${isSelected ? "font-medium" : ""}`, children: option.label }), _jsx("span", { className: "flex size-(--size-icon-md) shrink-0 items-center justify-center", children: isSelected ? (_jsx(Check, { "aria-hidden": true, className: "size-(--size-icon-md) text-primary forced-colors:text-[HighlightText]", strokeWidth: 2 })) : null })] })) })) }) })] }) }));
268
+ return (_jsx(AriaLocale, { children: _jsxs(AriaSelect, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), "aria-describedby": describedBy, value: value === "" ? null : value, onChange: (next) => onChange?.(next === null ? "" : String(next)), placeholder: placeholder, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: [_jsxs(AriaButton, { "data-ui": "control", className: (state) => selectTrigger({ ...state, isInvalid: invalid }), children: [_jsx(SelectValue, { className: "min-w-0 flex-1 truncate data-placeholder:text-muted", children: ({ isPlaceholder, selectedText, defaultChildren }) => isPlaceholder ? defaultChildren : selectedText }), _jsx(ChevronDown, { "aria-hidden": true, className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2 })] }), _jsx(Popover, { placement: "bottom start", className: "min-w-(--trigger-width)", children: _jsx(ListBox, { items: options, className: "max-h-[inherit] overflow-auto p-1 outline-0", children: (option) => (_jsx(ListBoxItem, { id: option.value, textValue: option.label, isDisabled: option.disabled, className: listOptionStyles, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: `min-w-0 flex-1 truncate ${isSelected ? "font-medium" : ""}`, children: option.label }), _jsx("span", { className: "flex size-(--size-icon-md) shrink-0 items-center justify-center", children: isSelected ? (_jsx(Check, { "aria-hidden": true, className: "size-(--size-icon-md) text-primary forced-colors:text-[HighlightText]", strokeWidth: 2 })) : null })] })) })) }) })] }) }));
269
269
  }
@@ -44,5 +44,5 @@ export function PatternInput({ id: ownId, value, onChange, pattern, placeholder,
44
44
  onChange?.(next);
45
45
  };
46
46
  const shown = placeholder ?? pattern.replace(/#/g, "0").replace(/\*/g, "X");
47
- return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, shown), value: drawn, onChange: change, inputMode: /[A*]/.test(pattern) ? "text" : "numeric", isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ref: input, "aria-describedby": describedBy, placeholder: shown, spellCheck: false, autoCapitalize: "characters", className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
47
+ return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, shown), value: drawn, onChange: change, inputMode: /[A*]/.test(pattern) ? "text" : "numeric", isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ref: input, "aria-describedby": describedBy, placeholder: shown, spellCheck: false, autoCapitalize: "characters", "data-ui": "control", className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
48
48
  }
@@ -86,10 +86,10 @@ function MentionList({ asking, active, listId, }) {
86
86
  const rect = asking.rect;
87
87
  if (rect === null)
88
88
  return null;
89
- return (_jsx("ul", { id: listId, role: "listbox", "aria-label": copy.mentions, className: "fixed z-50 flex w-64 flex-col rounded-panel border border-line-strong bg-surface p-1 shadow-float", style: { left: rect.left, top: rect.bottom + 4 }, children: asking.items.length === 0 ? (_jsx("li", { role: "option", "aria-selected": false, "aria-disabled": true, className: "px-2 py-1 text-meta text-muted", children: copy.noMatches })) : (asking.items.map((item, index) => (_jsx("li", { id: `${listId}-${index}`, role: "option", "aria-selected": index === active, onMouseDown: (event) => {
89
+ return (_jsx("ul", { id: listId, role: "listbox", "aria-label": copy.mentions, "data-ui": "popover", className: "fixed z-50 flex w-64 flex-col rounded-ui-popover border border-ui-popover-border bg-ui-popover p-1 shadow-ui-popover", style: { left: rect.left, top: rect.bottom + 4 }, children: asking.items.length === 0 ? (_jsx("li", { role: "option", "aria-selected": false, "aria-disabled": true, className: "px-2 py-1 text-meta text-muted", children: copy.noMatches })) : (asking.items.map((item, index) => (_jsx("li", { id: `${listId}-${index}`, role: "option", "aria-selected": index === active, onMouseDown: (event) => {
90
90
  event.preventDefault();
91
91
  asking.pick(item);
92
- }, className: `cursor-default rounded-control px-2 py-1 text-meta text-ink ${index === active ? "bg-primary/8" : ""}`, children: item.label }, item.id)))) }));
92
+ }, className: `cursor-default rounded-control px-2 py-1 text-meta text-ink ${index === active ? "bg-ui-option-active" : ""}`, children: item.label }, item.id)))) }));
93
93
  }
94
94
  export function RichTextEditor({ id, labelledBy, describedBy, invalid, ariaLabel, value, onChange, placeholder, disabled, toolbar, mentions, }) {
95
95
  const changed = useRef(onChange);
@@ -211,5 +211,5 @@ export function SignatureInput({ id: ownId, value, onChange, name = "", alt, des
211
211
  const paper = cn("relative h-32 w-full overflow-clip rounded-control border bg-surface font-sans text-ink", invalid ? "border-danger" : "border-line-strong", disabled ? "bg-ground" : "");
212
212
  return (_jsxs("div", { id: id, role: "group", "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel), "aria-describedby": describedBy, className: "flex w-full min-w-0 flex-col gap-2", children: [_jsxs("div", { ref: pad, "data-theme": "light", className: paper, children: [stored || (typing && has) ? (_jsx("img", { src: value ?? "", alt: label, className: "size-full object-contain object-left" })) : typing ? null : (_jsx("canvas", { ref: canvas, role: "img", "aria-label": copy.media.signaturePad, "aria-describedby": helpId, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, className: cn("absolute inset-0 size-full touch-none", disabled ? "cursor-not-allowed" : "cursor-crosshair") })), _jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-x-4 bottom-1/4 border-t border-line-strong" })] }), typing ? (_jsxs("label", { className: "flex flex-col gap-1 text-micro font-medium text-muted", children: [copy.media.typedName, _jsx("input", {
213
213
  /* The person asked for this box by pressing the button: the focus goes there. */
214
- autoFocus: true, value: typed, disabled: disabled, autoComplete: "name", onChange: (event) => writeTyped(event.target.value), className: `${controlClasses(invalid)} font-normal` })] })) : (_jsx("p", { id: helpId, className: "text-micro text-muted", children: copy.media.signatureHelp })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Button, { size: "sm", icon: typing ? PenLine : Type, disabled: disabled, onClick: switchMode, children: typing ? copy.media.drawInstead : copy.media.typeName }), _jsx(Button, { role: "ghost", size: "sm", icon: Eraser, disabled: disabled, onClick: clear, children: copy.media.clear })] })] }));
214
+ autoFocus: true, value: typed, disabled: disabled, autoComplete: "name", onChange: (event) => writeTyped(event.target.value), "data-ui": "control", className: `${controlClasses(invalid)} font-normal` })] })) : (_jsx("p", { id: helpId, className: "text-micro text-muted", children: copy.media.signatureHelp })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Button, { size: "sm", icon: typing ? PenLine : Type, disabled: disabled, onClick: switchMode, children: typing ? copy.media.drawInstead : copy.media.typeName }), _jsx(Button, { role: "ghost", size: "sm", icon: Eraser, disabled: disabled, onClick: clear, children: copy.media.clear })] })] }));
215
215
  }
@@ -20,7 +20,7 @@ export declare const fieldGroupStyles: import("tailwind-variants/config").TVRetu
20
20
  isDisabled: {
21
21
  true: string;
22
22
  };
23
- }, undefined, "group flex h-(--size-control-md) w-full min-w-0 items-center overflow-hidden rounded-control border bg-surface text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]", {
23
+ }, undefined, "group flex h-(--size-control-md) w-full min-w-0 items-center overflow-hidden rounded-ui-control border bg-ui-control text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]", {
24
24
  isFocusVisible: {
25
25
  false: string;
26
26
  true: string;
@@ -56,6 +56,6 @@ export declare const listOptionStyles: import("tailwind-variants/config").TVRetu
56
56
  isDisabled: {
57
57
  true: string;
58
58
  };
59
- }, undefined, "group flex min-h-(--size-control-md) cursor-default items-center gap-2 rounded-control px-2 py-1 text-meta text-ink outline-0 select-none forced-color-adjust-none", undefined, undefined, undefined>;
59
+ }, undefined, "group flex min-h-(--size-control-md) cursor-default items-center gap-2 rounded-ui-option px-2 py-1 text-meta text-ink outline-0 select-none forced-color-adjust-none", undefined, undefined, undefined>;
60
60
  /** For a control that only adds to the system's classes. */
61
61
  export { composeClasses };
@@ -12,10 +12,10 @@ import { Button as AriaButton, composeRenderProps, Group, } from "react-aria-com
12
12
  */
13
13
  export const fieldGroupStyles = tv({
14
14
  extend: focusRing,
15
- base: "group flex h-(--size-control-md) w-full min-w-0 items-center overflow-hidden rounded-control border bg-surface text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]",
15
+ base: "group flex h-(--size-control-md) w-full min-w-0 items-center overflow-hidden rounded-ui-control border bg-ui-control text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]",
16
16
  variants: {
17
17
  isFocusWithin: {
18
- false: "border-line-strong forced-colors:border-[ButtonBorder]",
18
+ false: "border-ui-control-border forced-colors:border-[ButtonBorder]",
19
19
  true: "border-primary forced-colors:border-[Highlight]",
20
20
  },
21
21
  isInvalid: {
@@ -30,7 +30,7 @@ export const fieldGroupStyles = tv({
30
30
  * reaches the box (React 19: a plain prop) — a control that floats a list as wide as the
31
31
  * box, like `TagsField`, measures it. */
32
32
  export function FieldGroup({ ref, ...props }) {
33
- return (_jsx(Group, { ref: ref, ...props, className: composeRenderProps(props.className, (className, state) => fieldGroupStyles({ ...state, className })) }));
33
+ return (_jsx(Group, { ref: ref, "data-ui": "control", ...props, className: composeRenderProps(props.className, (className, state) => fieldGroupStyles({ ...state, className })) }));
34
34
  }
35
35
  const fieldButton = tv({
36
36
  extend: focusRing,
@@ -53,10 +53,10 @@ export function FieldButton(props) {
53
53
  * control opened it.
54
54
  */
55
55
  export const listOptionStyles = tv({
56
- base: "group flex min-h-(--size-control-md) cursor-default items-center gap-2 rounded-control px-2 py-1 text-meta text-ink outline-0 select-none forced-color-adjust-none",
56
+ base: "group flex min-h-(--size-control-md) cursor-default items-center gap-2 rounded-ui-option px-2 py-1 text-meta text-ink outline-0 select-none forced-color-adjust-none",
57
57
  variants: {
58
58
  isFocused: {
59
- true: "bg-primary/8 forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
59
+ true: "bg-ui-option-active forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
60
60
  },
61
61
  isPressed: {
62
62
  true: "bg-primary/12",
@@ -1,6 +1,6 @@
1
1
  export { CARD_MAX_DIGITS, type CardBrand, cardBrand, cardBrandName, cardCodeLength, cardDigits, expiryDigits, expiryParts, formatCardNumber, formatExpiry, isExpiryValid, isValidCardNumber, luhnValid, maskCardNumber, } from "./card.js";
2
2
  export { CardCodeInput, CardExpiryInput, CardNumberInput, } from "./CardNumberInput.js";
3
- export { Checkbox, type CheckItem, CheckList } from "./Checks.js";
3
+ export { Checkbox, type CheckItem, CheckList, CheckMark, } from "./Checks.js";
4
4
  export { CodeInput } from "./CodeInput.js";
5
5
  export { ColorInput } from "./ColorInput.js";
6
6
  export { emailHref, isEmail, isUrl, telHref, urlHref, urlLabel, whatsappHref, } from "./contact.js";
@@ -8,7 +8,7 @@
8
8
  export { CARD_MAX_DIGITS, cardBrand, cardBrandName, cardCodeLength, cardDigits, expiryDigits, expiryParts, formatCardNumber, formatExpiry, isExpiryValid, isValidCardNumber, luhnValid, maskCardNumber, } from "./card.js";
9
9
  export { CardCodeInput, CardExpiryInput, CardNumberInput, } from "./CardNumberInput.js";
10
10
  /* An address to reach someone: typed with its keyboard, read as a link. */
11
- export { Checkbox, CheckList } from "./Checks.js";
11
+ export { Checkbox, CheckList, CheckMark, } from "./Checks.js";
12
12
  export { CodeInput } from "./CodeInput.js";
13
13
  export { ColorInput } from "./ColorInput.js";
14
14
  export { emailHref, isEmail, isUrl, telHref, urlHref, urlLabel, whatsappHref, } from "./contact.js";
@@ -1,6 +1,6 @@
1
1
  import { type ButtonRole, type ButtonSize } from "../button/Button.js";
2
2
  import type { LucideIcon } from "lucide-react";
3
- import type { ReactNode } from "react";
3
+ import { type ReactNode } from "react";
4
4
  import { type Key } from "react-aria-components";
5
5
  export interface MenuOption {
6
6
  id: string;
@@ -21,8 +21,8 @@ export interface MenuOption {
21
21
  onRemove?: () => void;
22
22
  disabled?: boolean;
23
23
  /** Visual mark at the end of the label. A string is drawn as a pill
24
- * —"maqueta", "nuevo"—; anything else is drawn as is, which is how a status
25
- * `Tag` or an already formatted counter comes in. */
24
+ * —"maqueta", "nuevo"—; a number as a `Count` —«Por aprobar 3», no zero—;
25
+ * anything else is drawn as is, which is how a status `Tag` comes in. */
26
26
  badge?: ReactNode;
27
27
  /** What THIS option does. It exists on top of the menu's `onSelect` because a
28
28
  * menu built from a registry —twenty-five operations, each one with its own
@@ -43,15 +43,21 @@ export interface MenuGroup {
43
43
  /** The group's label, in the brand voice. Without a label, the group is just
44
44
  * a separator — which also serves a purpose. */
45
45
  label?: string;
46
+ /** Drawn beside the label: the sections of a big menu are told apart before they are
47
+ * read. Only with a `label`. */
48
+ icon?: LucideIcon;
46
49
  /**
47
50
  * The group folds under its label, and starts folded unless something in it
48
51
  * is ticked.
49
52
  *
50
53
  * It exists for the DATE narrowings. «Fecha de pedido» is not one option, it
51
54
  * is eleven —three months, four quarters, three years— and eleven options
52
- * always open push the rest of the panel off the screen. A date is the only
53
- * field that brings its own little calendar, so it is the only one that
54
- * folds; the others are a list and a list does not need a door.
55
+ * always open push the rest of the panel off the screen.
56
+ *
57
+ * In a `Menu` it is the section that is there without taking the room: «Reportes
58
+ * financieros ▾» is one row, and pressing it unfolds its nine reports in place —
59
+ * the menu stays open. A menu with a search box shows every section open: a fold
60
+ * would hide what the search finds.
55
61
  */
56
62
  collapsible?: boolean;
57
63
  options: MenuOption[];
@@ -73,10 +79,12 @@ export declare function indexOptions(options: readonly MenuOption[], into?: Map<
73
79
  * criteria) still has to look like its neighbours; copying these classes is how the third
74
80
  * trigger ends up one pixel off. Same reason `buttonClasses` exists.
75
81
  */
76
- export declare function menuTriggerClasses({ variant, surface, active, open, focusVisible, iconOnly, }: {
82
+ export declare function menuTriggerClasses({ variant, surface, active, current, open, focusVisible, iconOnly, }: {
77
83
  variant?: "button" | "text";
78
84
  surface?: "canvas" | "chrome";
79
85
  active?: boolean;
86
+ /** The screen on view is inside this menu: a bar under the label. */
87
+ current?: boolean;
80
88
  open?: boolean;
81
89
  focusVisible?: boolean;
82
90
  iconOnly?: boolean;
@@ -84,7 +92,7 @@ export declare function menuTriggerClasses({ variant, surface, active, open, foc
84
92
  export declare function Menu({ label, groups, onSelect, surface, align, icon: Trigger,
85
93
  /** The menu as a control of a list ("filters ▾") carries the chevron; the
86
94
  * actions `⋯` does not, because the icon already says there is more. */
87
- chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, size, title, closeOnSelect, }: {
95
+ chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, size, title, closeOnSelect, count, current, layout, }: {
88
96
  label: string;
89
97
  groups: readonly MenuGroup[];
90
98
  onSelect?: (id: string) => void;
@@ -126,6 +134,15 @@ chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, s
126
134
  /** Column and filter menus toggle several options in a row. Closing after
127
135
  * each click turns three hides into three open-close round trips. */
128
136
  closeOnSelect?: boolean;
137
+ /** What is waiting inside, on the trigger: «Pagos 5» in an application bar says it
138
+ * without opening the menu. Zero is not drawn. Not with `iconOnly`, where there is no
139
+ * label for it to belong to. */
140
+ count?: number;
141
+ /** The screen on view is inside this menu — an application bar's «here». */
142
+ current?: boolean;
143
+ /** `columns` lays the sections side by side: a big menu of an application bar, seen
144
+ * whole. Stacked on a phone. */
145
+ layout?: "list" | "columns";
129
146
  }): import("react").JSX.Element;
130
147
  /**
131
148
  * The panel of a `Menu`: its groups and rows, and the submenus hanging from them. Internal —
@@ -133,12 +150,15 @@ chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, s
133
150
  * submenu is this same panel one level down, and a panel can be rendered on the server
134
151
  * without the trigger's popover, which is how the tests see the rows.
135
152
  */
136
- export declare function MenuList({ label, groups, onAction, closeOnSelect, emptyText, width, }: {
153
+ export declare function MenuList({ label, groups, onAction, closeOnSelect, emptyText, width, layout, foldable, }: {
137
154
  label: string;
138
155
  groups: readonly MenuGroup[];
139
156
  onAction: (key: Key) => void;
140
157
  closeOnSelect: boolean;
141
158
  emptyText: string;
142
159
  width?: keyof typeof WIDTH;
160
+ layout?: "list" | "columns";
161
+ /** `false` shows every `collapsible` section open — under a search box. */
162
+ foldable?: boolean;
143
163
  }): import("react").JSX.Element;
144
164
  export {};