@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.
Files changed (91) hide show
  1. package/README.md +16 -6
  2. package/dist/components/gallery/Gallery.d.ts +29 -0
  3. package/dist/components/gallery/Gallery.js +78 -0
  4. package/dist/components/gallery/Lightbox.d.ts +28 -0
  5. package/dist/components/gallery/Lightbox.js +59 -0
  6. package/dist/components/gallery/index.d.ts +2 -0
  7. package/dist/components/gallery/index.js +3 -0
  8. package/dist/components/index.d.ts +2 -0
  9. package/dist/components/index.js +2 -0
  10. package/dist/components/listing/ColumnsMenu.js +4 -2
  11. package/dist/components/listing/columns.d.ts +3 -0
  12. package/dist/components/listing/columns.js +4 -0
  13. package/dist/components/plans/PlanCard.d.ts +43 -0
  14. package/dist/components/plans/PlanCard.js +35 -0
  15. package/dist/components/plans/index.d.ts +1 -0
  16. package/dist/components/plans/index.js +2 -0
  17. package/dist/components/search/CriteriaChips.d.ts +14 -1
  18. package/dist/components/search/CriteriaChips.js +131 -14
  19. package/dist/components/search/JoinWord.js +8 -14
  20. package/dist/components/search/SearchBar.d.ts +10 -1
  21. package/dist/components/search/SearchBar.js +715 -176
  22. package/dist/components/search/WordChoice.d.ts +19 -0
  23. package/dist/components/search/WordChoice.js +8 -0
  24. package/dist/components/search/criteria.d.ts +47 -4
  25. package/dist/components/search/criteria.js +75 -2
  26. package/dist/components/search/index.d.ts +2 -2
  27. package/dist/components/search/index.js +2 -2
  28. package/dist/components/search/query.d.ts +24 -0
  29. package/dist/components/search/query.js +29 -0
  30. package/dist/components/shell/AppFrame.d.ts +4 -0
  31. package/dist/components/shell/AppFrame.js +4 -1
  32. package/dist/components/shell/Inbox.d.ts +53 -0
  33. package/dist/components/shell/Inbox.js +55 -0
  34. package/dist/components/shell/SearchEntry.js +2 -3
  35. package/dist/components/shell/TopBar.d.ts +4 -2
  36. package/dist/components/shell/TopBar.js +3 -3
  37. package/dist/components/shell/index.d.ts +1 -0
  38. package/dist/components/shell/index.js +3 -0
  39. package/dist/foundations/copy.es.js +60 -1
  40. package/dist/foundations/form.d.ts +7 -0
  41. package/dist/foundations/form.js +1 -0
  42. package/dist/foundations/uiCopy.d.ts +85 -2
  43. package/dist/foundations/uiCopy.js +60 -1
  44. package/dist/primitives/choice/RadioGroup.d.ts +1 -1
  45. package/dist/primitives/choice/RadioGroup.js +29 -0
  46. package/dist/primitives/choice/Rating.d.ts +32 -0
  47. package/dist/primitives/choice/Rating.js +75 -0
  48. package/dist/primitives/choice/Slider.d.ts +19 -0
  49. package/dist/primitives/choice/Slider.js +27 -2
  50. package/dist/primitives/choice/index.d.ts +2 -1
  51. package/dist/primitives/choice/index.js +4 -1
  52. package/dist/primitives/choice/options.d.ts +4 -0
  53. package/dist/primitives/field/Field.js +1 -0
  54. package/dist/primitives/hint/Kbd.d.ts +23 -0
  55. package/dist/primitives/hint/Kbd.js +23 -0
  56. package/dist/primitives/hint/index.d.ts +1 -0
  57. package/dist/primitives/hint/index.js +2 -0
  58. package/dist/primitives/menu/ContextMenu.d.ts +29 -0
  59. package/dist/primitives/menu/ContextMenu.js +74 -0
  60. package/dist/primitives/menu/Menu.d.ts +4 -1
  61. package/dist/primitives/menu/Menu.js +2 -2
  62. package/dist/primitives/menu/index.d.ts +1 -0
  63. package/dist/primitives/menu/index.js +2 -0
  64. package/dist/primitives/notice/Banner.d.ts +27 -0
  65. package/dist/primitives/notice/Banner.js +21 -0
  66. package/dist/primitives/notice/Callout.d.ts +4 -4
  67. package/dist/primitives/notice/Callout.js +8 -19
  68. package/dist/primitives/notice/Notice.d.ts +38 -10
  69. package/dist/primitives/notice/Notice.js +48 -9
  70. package/dist/primitives/notice/index.d.ts +3 -1
  71. package/dist/primitives/notice/index.js +3 -0
  72. package/dist/primitives/notice/tones.d.ts +8 -0
  73. package/dist/primitives/notice/tones.js +22 -0
  74. package/dist/primitives/table/DataTable.js +2 -1
  75. package/dist/primitives/table/index.d.ts +1 -0
  76. package/dist/primitives/table/index.js +1 -0
  77. package/dist/primitives/table/levels.d.ts +13 -0
  78. package/dist/primitives/table/levels.js +11 -0
  79. package/dist/primitives/value/Price.d.ts +31 -0
  80. package/dist/primitives/value/Price.js +32 -0
  81. package/dist/primitives/value/QrCode.d.ts +32 -0
  82. package/dist/primitives/value/QrCode.js +53 -0
  83. package/dist/primitives/value/index.d.ts +3 -0
  84. package/dist/primitives/value/index.js +6 -0
  85. package/dist/primitives/value/priceFormat.d.ts +12 -0
  86. package/dist/primitives/value/priceFormat.js +22 -0
  87. package/dist/tokens.css +39 -0
  88. package/dist/views/list/ListView.js +24 -4
  89. package/dist/views/list/derive.js +3 -2
  90. package/dist/views/list/types.d.ts +8 -0
  91. package/package.json +3 -2
@@ -191,7 +191,23 @@ export const SPANISH_COPY = {
191
191
  recordsFailed: "No se pudo buscar",
192
192
  moreRecords: "Buscar más…",
193
193
  advanced: "Búsqueda avanzada…",
194
- keysHint: "↑↓ moverse · Enter poner · → abrir · Esc deshacer",
194
+ keys: {
195
+ move: "moverse",
196
+ put: "poner",
197
+ open: "abrir",
198
+ complete: "completar",
199
+ undo: "deshacer",
200
+ panel: "filtros",
201
+ advanced: "avanzada",
202
+ },
203
+ recent: "Recientes",
204
+ searchBy: "Buscar por",
205
+ removed: "Quitado: {label}",
206
+ undo: "Deshacer",
207
+ chipMarked: "{label} marcado. Supr lo quita, Enter lo edita, las flechas se mueven.",
208
+ editValue: "Cambiar el valor de {label}",
209
+ changeOp: "Comparar {field} de otra manera",
210
+ findIn: "Buscar en {column}",
195
211
  landsHere: "acá cae lo próximo",
196
212
  closeGroup: "Cerrar este grupo",
197
213
  condition: "{field} {op} {value}",
@@ -577,6 +593,49 @@ export const SPANISH_COPY = {
577
593
  increase: "Uno más",
578
594
  remove: "Quitar",
579
595
  },
596
+ plans: {
597
+ current: "Tu plan",
598
+ included: "Incluye",
599
+ excluded: "No incluye",
600
+ onRequest: "A convenir",
601
+ },
602
+ range: {
603
+ min: "Mínimo",
604
+ max: "Máximo",
605
+ },
606
+ price: {
607
+ now: "Ahora",
608
+ before: "Antes",
609
+ free: "Gratis",
610
+ per: "por",
611
+ off: "{percent} % menos",
612
+ },
613
+ rating: {
614
+ label: "Calificación",
615
+ average: "{value} de {max}",
616
+ count: "{count} opiniones",
617
+ countOne: "{count} opinión",
618
+ none: "todavía sin calificar",
619
+ stars: "{value} de {max} estrellas",
620
+ },
621
+ gallery: {
622
+ label: "Imágenes",
623
+ roledescription: "galería",
624
+ previous: "Imagen anterior",
625
+ next: "Imagen siguiente",
626
+ position: "Imagen {index} de {total}",
627
+ open: "Ver en tamaño completo",
628
+ close: "Cerrar",
629
+ empty: "Todavía no hay imágenes",
630
+ },
631
+ inbox: {
632
+ label: "Notificaciones",
633
+ unread: "Sin leer",
634
+ unreadCount: "{count} sin leer",
635
+ markAllRead: "Marcar todo como leído",
636
+ seeAll: "Ver todas",
637
+ empty: "Nada nuevo por acá",
638
+ },
580
639
  outcome: {
581
640
  figure: "Número",
582
641
  },
@@ -15,6 +15,12 @@ export type FieldIds = {
15
15
  /** The id of the field's label. A native input is named by `<label for>`; a React Aria
16
16
  * control — a date picker, a combobox — is a group of elements, and is named by this. */
17
17
  labelId: string;
18
+ /** The label's words. A control that is a group of inputs needs them as a NAME and not as
19
+ * a reference: React Aria names each slider thumb by pointing at the group, and a group
20
+ * named only through `aria-labelledby` is read by its whole text when pointed at (the
21
+ * accessible-name rules do not follow a reference twice) — the thumb said «Bs 50 – Bs 300
22
+ * Precio». With the words, the group carries them as `aria-label` too. */
23
+ label?: string;
18
24
  describedBy: string | undefined;
19
25
  invalid: boolean;
20
26
  };
@@ -57,6 +63,7 @@ export declare function useFieldIds(own: {
57
63
  }): {
58
64
  id: string | undefined;
59
65
  labelledBy: string | undefined;
66
+ label: string | undefined;
60
67
  describedBy: string | undefined;
61
68
  invalid: boolean;
62
69
  };
@@ -25,6 +25,7 @@ export function useFieldIds(own) {
25
25
  return {
26
26
  id: own.id ?? field?.id,
27
27
  labelledBy: field?.labelId,
28
+ label: field?.label,
28
29
  describedBy: own.describedBy ?? field?.describedBy ?? place?.describedBy,
29
30
  invalid: own.invalid ?? field?.invalid ?? place?.invalid ?? false,
30
31
  };
@@ -288,8 +288,30 @@ export type UiCopy = {
288
288
  moreRecords: string;
289
289
  /** The way into the builder — in the dropdown, under what is offered, and in the panel. */
290
290
  advanced: string;
291
- /** The keys of the dropdown, said once at its foot. */
292
- keysHint: string;
291
+ /** The keys of the dropdown, said once at its foot: each word goes beside its key, drawn
292
+ * the way this keyboard writes it. */
293
+ keys: {
294
+ move: string;
295
+ put: string;
296
+ open: string;
297
+ complete: string;
298
+ undo: string;
299
+ panel: string;
300
+ advanced: string;
301
+ };
302
+ /** The bar offers before anything is typed: what was searched lately, and by what. */
303
+ recent: string;
304
+ searchBy: string;
305
+ /** A removed instance, said where it can be taken back. */
306
+ removed: string;
307
+ undo: string;
308
+ /** A chip marked from the keyboard (← on the empty bar): what it is and what can be done. */
309
+ chipMarked: string;
310
+ /** The parts of a chip, each touched on its own. */
311
+ editValue: string;
312
+ changeOp: string;
313
+ /** The box that narrows a long column of the panel. */
314
+ findIn: string;
293
315
  placeholder: string;
294
316
  /** The titles of the three columns of the tools panel. */
295
317
  filters: string;
@@ -860,6 +882,67 @@ export type UiCopy = {
860
882
  /** «−» at the minimum, when it takes the line away. */
861
883
  remove: string;
862
884
  };
885
+ /** An offer's plans (`PlanCard`). */
886
+ plans: {
887
+ /** The tag on the plan the person is on. */
888
+ current: string;
889
+ /** Said before a feature, for a screen reader: the icon says it to the eye. */
890
+ included: string;
891
+ excluded: string;
892
+ /** Where the price goes when there is none. */
893
+ onRequest: string;
894
+ };
895
+ /** The two ends of a `RangeSlider`, each thumb's own name after the field's. */
896
+ range: {
897
+ min: string;
898
+ max: string;
899
+ };
900
+ /** A price as a shelf says it (`Price`). Each figure is named for a screen reader. */
901
+ price: {
902
+ now: string;
903
+ before: string;
904
+ /** What a price of zero says. */
905
+ free: string;
906
+ /** Between the price and its unit — «Bs 120,00 por mes» — said, not drawn. */
907
+ per: string;
908
+ /** The discount tag's title. `{percent}` is the whole number. */
909
+ off: string;
910
+ };
911
+ /** Stars for how good (`Rating`). */
912
+ rating: {
913
+ label: string;
914
+ /** `{value}` is «4,5», `{max}` is 5. */
915
+ average: string;
916
+ /** `{count}` opinions, already written in the locale — and the one for a single one. */
917
+ count: string;
918
+ countOne: string;
919
+ none: string;
920
+ /** Each star of the question: «3 de 5 estrellas». */
921
+ stars: string;
922
+ };
923
+ /** The images of one thing (`Gallery`, `Lightbox`). */
924
+ gallery: {
925
+ label: string;
926
+ /** What assistive technology calls the group. */
927
+ roledescription: string;
928
+ previous: string;
929
+ next: string;
930
+ /** `{index}` of `{total}`. */
931
+ position: string;
932
+ open: string;
933
+ close: string;
934
+ empty: string;
935
+ };
936
+ /** The notifications (`Inbox`, `InboxList`). */
937
+ inbox: {
938
+ label: string;
939
+ unread: string;
940
+ /** Beside the title: «3 sin leer». */
941
+ unreadCount: string;
942
+ markAllRead: string;
943
+ seeAll: string;
944
+ empty: string;
945
+ };
863
946
  /** A finished operation, said big (`Outcome`). */
864
947
  outcome: {
865
948
  /** Read before the figure: «Tu número: 118». */
@@ -167,7 +167,23 @@ export const ENGLISH_COPY = {
167
167
  recordsFailed: "The search could not be done",
168
168
  moreRecords: "Search more…",
169
169
  advanced: "Advanced search…",
170
- keysHint: "↑↓ move · Enter set · → open · Esc undo",
170
+ keys: {
171
+ move: "move",
172
+ put: "set",
173
+ open: "open",
174
+ complete: "complete",
175
+ undo: "undo",
176
+ panel: "filters",
177
+ advanced: "advanced",
178
+ },
179
+ recent: "Recent",
180
+ searchBy: "Search by",
181
+ removed: "Removed: {label}",
182
+ undo: "Undo",
183
+ chipMarked: "{label} marked. Delete removes it, Enter edits it, arrows move.",
184
+ editValue: "Change the value of {label}",
185
+ changeOp: "Compare {field} another way",
186
+ findIn: "Search in {column}",
171
187
  placeholder: "search…",
172
188
  filters: "Filters",
173
189
  groupBy: "Group by",
@@ -562,6 +578,49 @@ export const ENGLISH_COPY = {
562
578
  increase: "One more",
563
579
  remove: "Remove",
564
580
  },
581
+ plans: {
582
+ current: "Your plan",
583
+ included: "Included",
584
+ excluded: "Not included",
585
+ onRequest: "On request",
586
+ },
587
+ range: {
588
+ min: "Minimum",
589
+ max: "Maximum",
590
+ },
591
+ price: {
592
+ now: "Now",
593
+ before: "Before",
594
+ free: "Free",
595
+ per: "per",
596
+ off: "{percent}% off",
597
+ },
598
+ rating: {
599
+ label: "Rating",
600
+ average: "{value} out of {max}",
601
+ count: "{count} reviews",
602
+ countOne: "{count} review",
603
+ none: "not rated yet",
604
+ stars: "{value} of {max} stars",
605
+ },
606
+ gallery: {
607
+ label: "Images",
608
+ roledescription: "gallery",
609
+ previous: "Previous image",
610
+ next: "Next image",
611
+ position: "Image {index} of {total}",
612
+ open: "Open full size",
613
+ close: "Close",
614
+ empty: "No images yet",
615
+ },
616
+ inbox: {
617
+ label: "Notifications",
618
+ unread: "Unread",
619
+ unreadCount: "{count} unread",
620
+ markAllRead: "Mark all as read",
621
+ seeAll: "See all",
622
+ empty: "Nothing new",
623
+ },
565
624
  outcome: {
566
625
  figure: "Number",
567
626
  },
@@ -20,6 +20,6 @@ export type RadioGroupProps = {
20
20
  * by a finger, where the dot of a list is too small a target. The grid fits as many as the
21
21
  * width takes. It is still one radio group: arrows move, one is chosen.
22
22
  */
23
- look?: "list" | "cards";
23
+ look?: "list" | "cards" | "swatches";
24
24
  };
25
25
  export declare function RadioGroup({ value, onChange, options, orientation, disabled, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, look, }: RadioGroupProps): import("react").JSX.Element;
@@ -33,6 +33,32 @@ const mark = tv({
33
33
  },
34
34
  },
35
35
  });
36
+ /**
37
+ * A product's variants: a colour as its swatch, a size as a small box with its word.
38
+ *
39
+ * Context: the third way to show one-of-few, for a shop's page and a catalogue's line — the
40
+ * colour is seen, not read, so the option IS the colour (`ChoiceOption.swatch`); a size has no
41
+ * colour, so it is its word in a box. Colour is never alone: each swatch is named by its label
42
+ * (and shows it on hover), and the chosen one is WRITTEN after the swatches («Roble»). One not
43
+ * in stock stays in sight, struck through — knowing it exists is part of the choice — and its
44
+ * `description` («Sin stock en tu talla») is its title. Still one radio group: arrows move.
45
+ */
46
+ function Swatches({ value, onChange, options, id, labelledBy, describedBy, invalid, disabled, }) {
47
+ const colours = options.some((o) => o.swatch !== undefined);
48
+ const chosen = labelOf(options, value);
49
+ /* On what is drawn, not on the radio: React Aria's button does not pass a `title` on. */
50
+ const titleOf = (o) => o.description === undefined ? o.label : `${o.label} · ${o.description}`;
51
+ return (_jsxs(AriaRadioGroup, { id: id, "aria-labelledby": labelledBy, "aria-describedby": describedBy, value: value, onChange: (next) => onChange?.(next), orientation: "horizontal", isInvalid: invalid, isDisabled: disabled, "data-ui": "radio-group", "data-look": "swatches", className: "flex min-w-0 flex-wrap items-center gap-2 py-1", children: [options.map((o) => (_jsx(RadioField, { value: o.value, isDisabled: o.disabled, className: "flex", children: _jsx(RadioButton, { "data-ui": "radio-group.swatch", className: ({ isSelected, isFocusVisible, isDisabled }) => `relative flex shrink-0 cursor-pointer items-center justify-center transition-colors duration-(--duration-instant) ${o.swatch === undefined
52
+ ? `h-(--size-control-md) min-w-(--size-control-md) rounded-ui-control border px-3 text-meta font-medium ${isSelected
53
+ ? "border-primary bg-primary/6 text-ink ring-1 ring-primary"
54
+ : "border-line-strong bg-surface text-ink hover:border-ink/40"}`
55
+ : `size-(--size-control-md) rounded-pill border-2 p-0.5 ${isSelected
56
+ ? "border-primary"
57
+ : "border-transparent hover:border-line-strong"}`} ${isFocusVisible ? "outline-2 outline-offset-2 outline-primary" : ""} ${isDisabled ? "cursor-not-allowed text-muted" : ""}`, children: ({ isDisabled }) => (_jsxs(_Fragment, { children: [o.swatch === undefined ? (_jsx("span", { title: titleOf(o), className: isDisabled ? "line-through" : "", children: o.label })) : (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, title: titleOf(o), className: "size-full rounded-pill border border-ink/15", style: { background: o.swatch } }), _jsx("span", { className: "sr-only", children: o.label })] })), isDisabled && o.swatch !== undefined ? (
58
+ /* Struck through, not hidden: a colour out of stock is still a colour that
59
+ exists. */
60
+ _jsx("span", { "aria-hidden": true, className: "absolute inset-x-1 top-1/2 h-0.5 -rotate-45 rounded-pill bg-ink/55" })) : null] })) }) }, o.value))), colours && chosen !== null ? (_jsx("span", { "aria-hidden": true, "data-ui": "radio-group.chosen", className: "ml-1 text-meta text-muted", children: chosen })) : null] }));
61
+ }
36
62
  export function RadioGroup({ value, onChange, options, orientation = "vertical", disabled = false, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, look = "list", }) {
37
63
  const { id, labelledBy, describedBy, invalid } = useFieldIds({
38
64
  id: ownId,
@@ -41,6 +67,9 @@ export function RadioGroup({ value, onChange, options, orientation = "vertical",
41
67
  });
42
68
  if (useFormMode(mode) === "read")
43
69
  return _jsx(ReadValue, { value: labelOf(options, value) });
70
+ if (look === "swatches") {
71
+ return (_jsx(Swatches, { value: value, onChange: onChange, options: options, id: id, labelledBy: labelledBy, describedBy: describedBy, invalid: invalid, disabled: disabled }));
72
+ }
44
73
  if (look === "cards") {
45
74
  return (_jsx(AriaRadioGroup, { id: id, "aria-labelledby": labelledBy, "aria-describedby": describedBy, value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, "data-ui": "radio-group", "data-look": "cards", className: "grid min-w-0 grid-cols-(--grid-tiles-sm) gap-2", children: options.map((o) => {
46
75
  const Icon = o.icon;
@@ -0,0 +1,32 @@
1
+ declare const STAR: {
2
+ readonly sm: "size-(--size-icon-sm)";
3
+ readonly md: "size-(--size-icon-md)";
4
+ readonly lg: "size-(--size-icon-lg)";
5
+ };
6
+ export type RatingProps = {
7
+ /** The average shown (`4.5`), or the stars given when it asks. 0 is «sin calificar». */
8
+ value: number;
9
+ /** How many stars. Five by default. */
10
+ max?: number;
11
+ /** How many opinions the average comes from — written after it: «4,5 (128)». */
12
+ count?: number;
13
+ /** Present = it asks: a star per radio, arrows move. Absent = it shows. */
14
+ onChange?: (next: number) => void;
15
+ /** The group's name when it is not inside a `Field` and not «Calificación». */
16
+ label?: string;
17
+ size?: keyof typeof STAR;
18
+ };
19
+ /**
20
+ * Stars: an average of opinions shown (a product, a supplier, a technician), or the opinion
21
+ * asked (a survey, closing a ticket).
22
+ *
23
+ * Context: `Priority` is the sibling — Odoo's three stars of urgency, whole, no figure. This is
24
+ * the other question, «how good»: an average, so it draws half stars, and the FIGURE beside
25
+ * them, because «4,5» is read where four and a half stars are only estimated; and how many
26
+ * opinions, because 5 out of 2 is not 4,6 out of 900. Shown, it is one image with one name —
27
+ * «Calificación: 4,5 de 5, 128 opiniones» — so it is never colour alone. Asked, it is a radio
28
+ * group named by its `Field`, one tab stop and the arrows inside; in read mode it is shown.
29
+ * In `warn` like `Priority`: the gold is the screen's primary action.
30
+ */
31
+ export declare function Rating({ value, max, count, onChange, label, size }: RatingProps): import("react").JSX.Element;
32
+ export {};
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { fillCopy, useUiCopy } from "../../foundations/copy.js";
4
+ import { useFieldIds, useFormMode } from "../../foundations/form.js";
5
+ import { formatCount, formatWith } from "../value/format.js";
6
+ import { Star } from "lucide-react";
7
+ import { useRef } from "react";
8
+ const STAR = {
9
+ sm: "size-(--size-icon-sm)",
10
+ md: "size-(--size-icon-md)",
11
+ lg: "size-(--size-icon-lg)",
12
+ };
13
+ const FIGURE = { sm: "text-micro", md: "text-meta", lg: "text-body" };
14
+ /* Half stars and no finer: 4.3 drawn as 43 % of a star is a difference nobody sees, and the
15
+ figure beside it already says it exactly. */
16
+ const half = (value) => Math.round(value * 2) / 2;
17
+ function StarMark({ fill, size }) {
18
+ return (_jsxs("span", { "aria-hidden": true, className: "relative inline-flex shrink-0", children: [_jsx(Star, { className: `${STAR[size]} text-line-strong`, strokeWidth: 1.75 }), fill === 0 ? null : (_jsx("span", { className: `absolute inset-y-0 left-0 overflow-hidden ${fill === 1 ? "w-full" : "w-1/2"}`, children: _jsx(Star, { className: `${STAR[size]} fill-warn text-warn`, strokeWidth: 1.75 }) }))] }));
19
+ }
20
+ const fillOf = (value, n) => value >= n ? 1 : value >= n - 0.5 ? 0.5 : 0;
21
+ /**
22
+ * Stars: an average of opinions shown (a product, a supplier, a technician), or the opinion
23
+ * asked (a survey, closing a ticket).
24
+ *
25
+ * Context: `Priority` is the sibling — Odoo's three stars of urgency, whole, no figure. This is
26
+ * the other question, «how good»: an average, so it draws half stars, and the FIGURE beside
27
+ * them, because «4,5» is read where four and a half stars are only estimated; and how many
28
+ * opinions, because 5 out of 2 is not 4,6 out of 900. Shown, it is one image with one name —
29
+ * «Calificación: 4,5 de 5, 128 opiniones» — so it is never colour alone. Asked, it is a radio
30
+ * group named by its `Field`, one tab stop and the arrows inside; in read mode it is shown.
31
+ * In `warn` like `Priority`: the gold is the screen's primary action.
32
+ */
33
+ export function Rating({ value, max = 5, count, onChange, label, size = "md" }) {
34
+ const copy = useUiCopy();
35
+ const ids = useFieldIds({});
36
+ const mode = useFormMode();
37
+ const buttons = useRef([]);
38
+ const name = label ?? copy.rating.label;
39
+ const stars = Array.from({ length: max }, (_, at) => at + 1);
40
+ const figure = formatWith(value, { maximumFractionDigits: 1, minimumFractionDigits: 1 }, copy.locale);
41
+ if (onChange === undefined || mode === "read") {
42
+ const shown = half(value);
43
+ const said = value === 0
44
+ ? copy.rating.none
45
+ : fillCopy(copy.rating.average, { value: figure, max }) +
46
+ (count === undefined
47
+ ? ""
48
+ : `, ${fillCopy(count === 1 ? copy.rating.countOne : copy.rating.count, { count: formatCount(count, copy.locale) })}`);
49
+ return (_jsxs("span", { role: "img", "aria-label": `${name}: ${said}`, "data-ui": "rating", "data-size": size, className: "inline-flex items-center gap-1.5", children: [_jsx("span", { className: "inline-flex items-center gap-0.5", children: stars.map((n) => (_jsx(StarMark, { fill: fillOf(shown, n), size: size }, n))) }), value === 0 ? null : (_jsx("span", { "aria-hidden": true, className: `font-medium text-ink tabular-nums ${FIGURE[size]}`, children: figure })), count === undefined ? null : (_jsxs("span", { "aria-hidden": true, className: `text-muted tabular-nums ${FIGURE[size]}`, children: ["(", formatCount(count, copy.locale), ")"] }))] }));
50
+ }
51
+ const given = Math.round(value);
52
+ const step = (event, n) => {
53
+ const next = event.key === "ArrowRight" || event.key === "ArrowUp"
54
+ ? Math.min(max, n + 1)
55
+ : event.key === "ArrowLeft" || event.key === "ArrowDown"
56
+ ? Math.max(1, n - 1)
57
+ : event.key === "Home"
58
+ ? 1
59
+ : event.key === "End"
60
+ ? max
61
+ : null;
62
+ if (next === null)
63
+ return;
64
+ event.preventDefault();
65
+ onChange(next);
66
+ buttons.current[next - 1]?.focus();
67
+ };
68
+ return (_jsx("span", { role: "radiogroup", ...(ids.labelledBy === undefined
69
+ ? { "aria-label": name }
70
+ : { "aria-labelledby": ids.labelledBy }), ...(ids.describedBy === undefined ? {} : { "aria-describedby": ids.describedBy }), ...(ids.invalid ? { "aria-invalid": true } : {}), id: ids.id, "data-ui": "rating", "data-size": size, className: "inline-flex items-center gap-0.5", children: stars.map((n) => (_jsx("button", { ref: (node) => {
71
+ buttons.current[n - 1] = node;
72
+ }, type: "button", role: "radio", "aria-checked": given === n, "aria-label": fillCopy(copy.rating.stars, { value: n, max }),
73
+ /* One stop in the tab order — the given star, or the first — and the arrows inside. */
74
+ tabIndex: n === Math.max(given, 1) ? 0 : -1, onClick: () => onChange(n), onKeyDown: (event) => step(event, n), className: "hit-target rounded-control p-0.5 transition-colors duration-(--duration-instant) hover:bg-ink/6 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: _jsx(StarMark, { fill: n <= given ? 1 : 0, size: size }) }, n))) }));
75
+ }
@@ -19,3 +19,22 @@ export type SliderProps = {
19
19
  output?: boolean;
20
20
  };
21
21
  export declare function Slider({ value, onChange, min, max, step, format, disabled, id: ownId, describedBy: ownDescribedBy, mode, "aria-label": ariaLabel, output, }: SliderProps): import("react").JSX.Element;
22
+ export type RangeSliderProps = Omit<SliderProps, "value" | "onChange"> & {
23
+ /** The two ends, low first. */
24
+ value: readonly [number, number];
25
+ onChange?: (next: [number, number]) => void;
26
+ /** Called once when a drag ends — where a list re-queries, not on every pixel. */
27
+ onChangeEnd?: (next: [number, number]) => void;
28
+ };
29
+ /**
30
+ * A range with two ends: a shop's «precio entre», an ERP's «monto entre», a tolerance band.
31
+ *
32
+ * Context: the `Slider`'s sibling, with the same track, thumbs and figure, so a filter panel
33
+ * reads the same with one or two. Each thumb is its own input and says which end it is
34
+ * («Mínimo», «Máximo») with the field's name — two thumbs both called «Precio» leave a screen
35
+ * reader guessing. The thumbs cannot cross: React Aria keeps the low one below the high one.
36
+ * The figure writes both ends («Bs 50 – Bs 300»), in a wider column than one value's. A list
37
+ * filtered by it should listen to `onChangeEnd`: re-querying on every pixel of a drag is what
38
+ * makes a shop's filter stutter.
39
+ */
40
+ export declare function RangeSlider({ value, onChange, onChangeEnd, min, max, step, format, disabled, id: ownId, describedBy: ownDescribedBy, mode, "aria-label": ariaLabel, output, }: RangeSliderProps): import("react").JSX.Element;
@@ -35,12 +35,37 @@ const thumb = tv({
35
35
  });
36
36
  export function Slider({ value, onChange, min, max, step = 1, format, disabled = false, id: ownId, describedBy: ownDescribedBy, mode, "aria-label": ariaLabel, output = true, }) {
37
37
  const copy = useUiCopy();
38
- const { id, labelledBy, describedBy } = useFieldIds({
38
+ const { id, labelledBy, label, describedBy } = useFieldIds({
39
39
  id: ownId,
40
40
  describedBy: ownDescribedBy,
41
41
  });
42
42
  if (useFormMode(mode) === "read") {
43
43
  return _jsx(ReadValue, { value: new Intl.NumberFormat(copy.locale, format).format(value) });
44
44
  }
45
- return (_jsx(AriaLocale, { children: _jsxs(AriaSlider, { id: id, "aria-labelledby": labelledBy, "aria-label": controlName(labelledBy, ariaLabel), "aria-describedby": describedBy, value: value, onChange: (next) => onChange?.(next), minValue: min, maxValue: max, step: step, formatOptions: format, isDisabled: disabled, className: "flex h-(--size-control-md) w-full min-w-0 items-center gap-3 disabled:opacity-45", children: [_jsxs(SliderTrack, { className: "relative flex h-(--size-control-md) min-w-0 flex-1 cursor-pointer items-center disabled:cursor-not-allowed", children: [_jsx("span", { className: "relative h-1 w-full rounded-pill bg-line-strong forced-colors:bg-[ButtonBorder]", children: _jsx(SliderFill, { className: "rounded-pill bg-primary disabled:bg-muted forced-colors:bg-[Highlight]" }) }), _jsx(SliderThumb, { "aria-labelledby": labelledBy, "aria-label": controlName(labelledBy, ariaLabel), "aria-describedby": describedBy, className: thumb })] }), output ? (_jsx(SliderOutput, { className: "w-14 shrink-0 text-right text-meta text-ink tabular-nums" })) : null] }) }));
45
+ return (_jsx(AriaLocale, { children: _jsxs(AriaSlider, { id: id, "aria-labelledby": label === undefined ? labelledBy : undefined, "aria-label": label ?? controlName(labelledBy, ariaLabel), "aria-describedby": describedBy, value: value, onChange: (next) => onChange?.(next), minValue: min, maxValue: max, step: step, formatOptions: format, isDisabled: disabled, className: "flex h-(--size-control-md) w-full min-w-0 items-center gap-3 disabled:opacity-45", children: [_jsxs(SliderTrack, { className: "relative flex h-(--size-control-md) min-w-0 flex-1 cursor-pointer items-center disabled:cursor-not-allowed", children: [_jsx("span", { className: "relative h-1 w-full rounded-pill bg-line-strong forced-colors:bg-[ButtonBorder]", children: _jsx(SliderFill, { className: "rounded-pill bg-primary disabled:bg-muted forced-colors:bg-[Highlight]" }) }), _jsx(SliderThumb, { "aria-describedby": describedBy, className: thumb })] }), output ? (_jsx(SliderOutput, { className: "w-14 shrink-0 text-right text-meta text-ink tabular-nums" })) : null] }) }));
46
+ }
47
+ /**
48
+ * A range with two ends: a shop's «precio entre», an ERP's «monto entre», a tolerance band.
49
+ *
50
+ * Context: the `Slider`'s sibling, with the same track, thumbs and figure, so a filter panel
51
+ * reads the same with one or two. Each thumb is its own input and says which end it is
52
+ * («Mínimo», «Máximo») with the field's name — two thumbs both called «Precio» leave a screen
53
+ * reader guessing. The thumbs cannot cross: React Aria keeps the low one below the high one.
54
+ * The figure writes both ends («Bs 50 – Bs 300»), in a wider column than one value's. A list
55
+ * filtered by it should listen to `onChangeEnd`: re-querying on every pixel of a drag is what
56
+ * makes a shop's filter stutter.
57
+ */
58
+ export function RangeSlider({ value, onChange, onChangeEnd, min, max, step = 1, format, disabled = false, id: ownId, describedBy: ownDescribedBy, mode, "aria-label": ariaLabel, output = true, }) {
59
+ const copy = useUiCopy();
60
+ const { id, labelledBy, label, describedBy } = useFieldIds({
61
+ id: ownId,
62
+ describedBy: ownDescribedBy,
63
+ });
64
+ const name = label ?? controlName(labelledBy, ariaLabel);
65
+ const written = (n) => new Intl.NumberFormat(copy.locale, format).format(n);
66
+ if (useFormMode(mode) === "read") {
67
+ return _jsx(ReadValue, { value: `${written(value[0])} – ${written(value[1])}` });
68
+ }
69
+ const pair = (next) => Array.isArray(next) ? [next[0] ?? min, next[1] ?? max] : [next, next];
70
+ return (_jsx(AriaLocale, { children: _jsxs(AriaSlider, { id: id, "aria-labelledby": label === undefined ? labelledBy : undefined, "aria-label": name, "aria-describedby": describedBy, value: [value[0], value[1]], onChange: (next) => onChange?.(pair(next)), onChangeEnd: (next) => onChangeEnd?.(pair(next)), minValue: min, maxValue: max, step: step, formatOptions: format, isDisabled: disabled, "data-ui": "range-slider", className: "flex h-(--size-control-md) w-full min-w-0 items-center gap-3 disabled:opacity-45", children: [_jsxs(SliderTrack, { className: "relative flex h-(--size-control-md) min-w-0 flex-1 cursor-pointer items-center disabled:cursor-not-allowed", children: [_jsx("span", { className: "relative h-1 w-full rounded-pill bg-line-strong forced-colors:bg-[ButtonBorder]", children: _jsx(SliderFill, { className: "rounded-pill bg-primary disabled:bg-muted forced-colors:bg-[Highlight]" }) }), [0, 1].map((index) => (_jsx(SliderThumb, { index: index, "aria-label": index === 0 ? copy.range.min : copy.range.max, "aria-describedby": describedBy, className: thumb }, index)))] }), output ? (_jsx(SliderOutput, { className: "w-36 shrink-0 text-right text-meta whitespace-nowrap text-ink tabular-nums", children: ({ state }) => `${state.getThumbValueLabel(0)} – ${state.getThumbValueLabel(1)}` })) : null] }) }));
46
71
  }
@@ -3,8 +3,9 @@ export { KanbanState, type KanbanStateValue, } from "./KanbanState.js";
3
3
  export { type ChoiceOption, type SegmentOption, } from "./options.js";
4
4
  export { Priority, type PriorityProps } from "./Priority.js";
5
5
  export { RadioGroup, type RadioGroupProps, } from "./RadioGroup.js";
6
+ export { Rating, type RatingProps } from "./Rating.js";
6
7
  export { SearchField, type SearchFieldProps, } from "./SearchField.js";
7
8
  export { SegmentedControl, type SegmentedControlProps, } from "./SegmentedControl.js";
8
- export { Slider, type SliderProps } from "./Slider.js";
9
+ export { RangeSlider, type RangeSliderProps, Slider, type SliderProps, } from "./Slider.js";
9
10
  export { Switch, type SwitchProps } from "./Switch.js";
10
11
  export { ThemeSwitcher } from "./ThemeSwitcher.js";
@@ -5,9 +5,12 @@ export { ComboBox } from "./ComboBox.js";
5
5
  export { KanbanState, } from "./KanbanState.js";
6
6
  export {} from "./options.js";
7
7
  export { Priority } from "./Priority.js";
8
+ /* Stars for HOW GOOD: an average shown with its figure and how many opinions, or the opinion
9
+ asked — `Priority`'s sibling. */
8
10
  export { RadioGroup, } from "./RadioGroup.js";
11
+ export { Rating } from "./Rating.js";
9
12
  export { SearchField, } from "./SearchField.js";
10
13
  export { SegmentedControl, } from "./SegmentedControl.js";
11
- export { Slider } from "./Slider.js";
14
+ export { RangeSlider, Slider, } from "./Slider.js";
12
15
  export { Switch } from "./Switch.js";
13
16
  export { ThemeSwitcher } from "./ThemeSwitcher.js";
@@ -15,6 +15,10 @@ export interface ChoiceOption {
15
15
  /** Drawn on the option when the choice is shown as cards (`RadioGroup look="cards"`): the
16
16
  * card of «Efectivo», «QR», «Tarjeta». Beside the label, never instead of it. */
17
17
  icon?: LucideIcon;
18
+ /** The colour itself, for a variant drawn as a swatch (`RadioGroup look="swatches"`): any CSS
19
+ * colour the application has for it («#c8a27a», «oklch(…)»). Without it the swatch is the
20
+ * label in a box — a size, a capacity. The colour is never alone: its label names it. */
21
+ swatch?: string;
18
22
  }
19
23
  /** One segment of a `SegmentedControl`. The icon goes before the label, never instead of it. */
20
24
  export interface SegmentOption {
@@ -89,6 +89,7 @@ export function Field({ label, hint, error, required = false, children, htmlFor,
89
89
  const ids = {
90
90
  id,
91
91
  labelId: `${id}-label`,
92
+ label,
92
93
  describedBy,
93
94
  invalid: error !== undefined,
94
95
  };
@@ -0,0 +1,23 @@
1
+ import type { Keys } from "../../foundations/keys.js";
2
+ import type { Surface } from "../../foundations/types.js";
3
+ import type { ReactNode } from "react";
4
+ export type KbdProps = {
5
+ /** A combination written the system's way («Mod+K», «Alt+ArrowDown»): drawn the way THIS
6
+ * keyboard says it — «⌘K» on a Mac, «Ctrl K» elsewhere. Nothing is drawn until the
7
+ * platform is known, rather than a «Ctrl» on a Mac corrected in front of the person. */
8
+ keys?: Keys;
9
+ /** A key written as is — «Tab», «/», «Enter» — when there is no platform to ask. */
10
+ children?: ReactNode;
11
+ surface?: Surface;
12
+ };
13
+ /**
14
+ * A key, drawn as a key: «⌘K» at the end of the search entry, «Tab» after a completion, the
15
+ * legend of what each key does.
16
+ *
17
+ * Context: four places drew their own `<kbd>` — two paddings, two line heights, one with a
18
+ * minimum width — and a key looked a little different in each. It is a reference, not an
19
+ * action: mono, the quiet size, muted, a hairline around it. Seen, not heard (`aria-hidden`):
20
+ * the control it belongs to says its shortcut with `aria-keyshortcuts`, and «⌘K» read aloud
21
+ * after the name is noise. Not drawn under a finger: a touch screen has no keyboard.
22
+ */
23
+ export declare function Kbd({ keys, children, surface: surfaceProp }: KbdProps): import("react").JSX.Element | null;
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { keysLabel } from "../../foundations/keys.js";
4
+ import { useKeyboardPlatform } from "../../foundations/shortcut.js";
5
+ import { bySurface, useSurface } from "../../foundations/surface.js";
6
+ /**
7
+ * A key, drawn as a key: «⌘K» at the end of the search entry, «Tab» after a completion, the
8
+ * legend of what each key does.
9
+ *
10
+ * Context: four places drew their own `<kbd>` — two paddings, two line heights, one with a
11
+ * minimum width — and a key looked a little different in each. It is a reference, not an
12
+ * action: mono, the quiet size, muted, a hairline around it. Seen, not heard (`aria-hidden`):
13
+ * the control it belongs to says its shortcut with `aria-keyshortcuts`, and «⌘K» read aloud
14
+ * after the name is noise. Not drawn under a finger: a touch screen has no keyboard.
15
+ */
16
+ export function Kbd({ keys, children, surface: surfaceProp }) {
17
+ const surface = useSurface(surfaceProp);
18
+ const platform = useKeyboardPlatform();
19
+ const label = keys === undefined ? children : platform === null ? null : keysLabel(keys, platform);
20
+ if (label === null || label === undefined)
21
+ return null;
22
+ return (_jsx("kbd", { "aria-hidden": true, "data-ui": "kbd", "data-surface": surface, className: `inline-flex min-w-5 shrink-0 items-center justify-center rounded-control border px-1 font-mono text-micro leading-tight touch:hidden ${bySurface(surface, "border-line bg-surface text-muted", "border-chrome-ink/30 text-chrome-muted")}`, children: label }));
23
+ }
@@ -1 +1,2 @@
1
1
  export { Hint } from "./Hint.js";
2
+ export { Kbd, type KbdProps } from "./Kbd.js";
@@ -1 +1,3 @@
1
1
  export { Hint } from "./Hint.js";
2
+ /* A key drawn as a key — «⌘K» the way this keyboard says it, «Tab», «/». */
3
+ export { Kbd } from "./Kbd.js";