@sincpro/web-ui 2.12.0 → 2.14.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 (137) hide show
  1. package/README.md +56 -21
  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 +3 -0
  9. package/dist/components/index.js +3 -0
  10. package/dist/components/listing/BoardColumns.js +10 -6
  11. package/dist/components/listing/ColumnsMenu.js +4 -2
  12. package/dist/components/listing/Listing.js +3 -1
  13. package/dist/components/listing/ListingBar.d.ts +16 -94
  14. package/dist/components/listing/ListingBar.js +24 -2
  15. package/dist/components/listing/RecordCard.d.ts +41 -3
  16. package/dist/components/listing/RecordCard.js +63 -22
  17. package/dist/components/listing/Row.js +5 -2
  18. package/dist/components/listing/columns.d.ts +3 -0
  19. package/dist/components/listing/columns.js +4 -0
  20. package/dist/components/listing/index.d.ts +2 -2
  21. package/dist/components/listing/index.js +2 -2
  22. package/dist/components/listing/set.d.ts +1 -1
  23. package/dist/components/plans/PlanCard.d.ts +43 -0
  24. package/dist/components/plans/PlanCard.js +35 -0
  25. package/dist/components/plans/index.d.ts +1 -0
  26. package/dist/components/plans/index.js +2 -0
  27. package/dist/components/receipt/Receipt.d.ts +51 -0
  28. package/dist/components/receipt/Receipt.js +23 -0
  29. package/dist/components/receipt/index.d.ts +1 -0
  30. package/dist/components/receipt/index.js +3 -0
  31. package/dist/components/search/CriteriaChips.d.ts +14 -1
  32. package/dist/components/search/CriteriaChips.js +123 -13
  33. package/dist/components/search/JoinWord.js +8 -14
  34. package/dist/components/search/SearchBar.d.ts +10 -1
  35. package/dist/components/search/SearchBar.js +715 -176
  36. package/dist/components/search/WordChoice.d.ts +19 -0
  37. package/dist/components/search/WordChoice.js +8 -0
  38. package/dist/components/search/criteria.d.ts +27 -0
  39. package/dist/components/search/criteria.js +33 -0
  40. package/dist/components/search/index.d.ts +2 -2
  41. package/dist/components/search/index.js +2 -2
  42. package/dist/components/search/query.d.ts +24 -0
  43. package/dist/components/search/query.js +29 -0
  44. package/dist/components/shell/AppFrame.d.ts +4 -0
  45. package/dist/components/shell/AppFrame.js +4 -1
  46. package/dist/components/shell/Inbox.d.ts +53 -0
  47. package/dist/components/shell/Inbox.js +55 -0
  48. package/dist/components/shell/KioskFrame.d.ts +35 -0
  49. package/dist/components/shell/KioskFrame.js +39 -0
  50. package/dist/components/shell/SearchEntry.js +2 -3
  51. package/dist/components/shell/TopBar.d.ts +4 -2
  52. package/dist/components/shell/TopBar.js +3 -3
  53. package/dist/components/shell/index.d.ts +2 -0
  54. package/dist/components/shell/index.js +4 -0
  55. package/dist/foundations/clock.d.ts +3 -0
  56. package/dist/foundations/clock.js +41 -0
  57. package/dist/foundations/copy.es.js +86 -1
  58. package/dist/foundations/form.d.ts +7 -0
  59. package/dist/foundations/form.js +1 -0
  60. package/dist/foundations/idle.d.ts +1 -0
  61. package/dist/foundations/idle.js +34 -0
  62. package/dist/foundations/index.d.ts +3 -0
  63. package/dist/foundations/index.js +7 -0
  64. package/dist/foundations/pointer.d.ts +25 -0
  65. package/dist/foundations/pointer.js +28 -0
  66. package/dist/foundations/uiCopy.d.ts +123 -2
  67. package/dist/foundations/uiCopy.js +86 -1
  68. package/dist/primitives/choice/RadioGroup.d.ts +8 -1
  69. package/dist/primitives/choice/RadioGroup.js +38 -1
  70. package/dist/primitives/choice/Rating.d.ts +32 -0
  71. package/dist/primitives/choice/Rating.js +75 -0
  72. package/dist/primitives/choice/Slider.d.ts +19 -0
  73. package/dist/primitives/choice/Slider.js +27 -2
  74. package/dist/primitives/choice/index.d.ts +2 -1
  75. package/dist/primitives/choice/index.js +4 -1
  76. package/dist/primitives/choice/options.d.ts +7 -0
  77. package/dist/primitives/field/Field.js +1 -0
  78. package/dist/primitives/field/Keypad.d.ts +43 -0
  79. package/dist/primitives/field/Keypad.js +62 -0
  80. package/dist/primitives/field/Stepper.d.ts +28 -0
  81. package/dist/primitives/field/Stepper.js +52 -0
  82. package/dist/primitives/field/clipboard.js +1 -1
  83. package/dist/primitives/field/index.d.ts +3 -0
  84. package/dist/primitives/field/index.js +6 -0
  85. package/dist/primitives/field/keypadKeys.d.ts +24 -0
  86. package/dist/primitives/field/keypadKeys.js +80 -0
  87. package/dist/primitives/hint/Hint.js +1 -1
  88. package/dist/primitives/hint/Kbd.d.ts +23 -0
  89. package/dist/primitives/hint/Kbd.js +23 -0
  90. package/dist/primitives/hint/index.d.ts +1 -0
  91. package/dist/primitives/hint/index.js +2 -0
  92. package/dist/primitives/menu/ContextMenu.d.ts +29 -0
  93. package/dist/primitives/menu/ContextMenu.js +74 -0
  94. package/dist/primitives/menu/Menu.d.ts +4 -1
  95. package/dist/primitives/menu/Menu.js +2 -2
  96. package/dist/primitives/menu/index.d.ts +1 -0
  97. package/dist/primitives/menu/index.js +2 -0
  98. package/dist/primitives/notice/Banner.d.ts +27 -0
  99. package/dist/primitives/notice/Banner.js +21 -0
  100. package/dist/primitives/notice/Callout.d.ts +4 -4
  101. package/dist/primitives/notice/Callout.js +8 -19
  102. package/dist/primitives/notice/Flag.js +1 -1
  103. package/dist/primitives/notice/Notice.d.ts +38 -10
  104. package/dist/primitives/notice/Notice.js +48 -9
  105. package/dist/primitives/notice/Outcome.d.ts +28 -0
  106. package/dist/primitives/notice/Outcome.js +28 -0
  107. package/dist/primitives/notice/index.d.ts +4 -1
  108. package/dist/primitives/notice/index.js +5 -0
  109. package/dist/primitives/notice/tones.d.ts +8 -0
  110. package/dist/primitives/notice/tones.js +22 -0
  111. package/dist/primitives/table/CellCopy.js +1 -1
  112. package/dist/primitives/table/ReportTable.js +1 -1
  113. package/dist/primitives/table/RowActions.js +1 -1
  114. package/dist/primitives/table/Table.js +9 -5
  115. package/dist/primitives/tag/Tags.d.ts +22 -1
  116. package/dist/primitives/tag/Tags.js +57 -14
  117. package/dist/primitives/tag/index.d.ts +1 -1
  118. package/dist/primitives/value/Elapsed.d.ts +16 -0
  119. package/dist/primitives/value/Elapsed.js +37 -0
  120. package/dist/primitives/value/Price.d.ts +31 -0
  121. package/dist/primitives/value/Price.js +32 -0
  122. package/dist/primitives/value/QrCode.d.ts +32 -0
  123. package/dist/primitives/value/QrCode.js +53 -0
  124. package/dist/primitives/value/elapsedTime.d.ts +26 -0
  125. package/dist/primitives/value/elapsedTime.js +32 -0
  126. package/dist/primitives/value/index.d.ts +5 -0
  127. package/dist/primitives/value/index.js +10 -0
  128. package/dist/primitives/value/priceFormat.d.ts +12 -0
  129. package/dist/primitives/value/priceFormat.js +22 -0
  130. package/dist/tokens.css +126 -1
  131. package/dist/views/list/List.d.ts +11 -0
  132. package/dist/views/list/List.js +14 -3
  133. package/dist/views/list/ListView.d.ts +1 -1
  134. package/dist/views/list/ListView.js +48 -9
  135. package/dist/views/list/types.d.ts +15 -0
  136. package/dist/views/record/Record.js +1 -1
  137. package/package.json +3 -2
@@ -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";
@@ -12,6 +12,13 @@ export interface ChoiceOption {
12
12
  /** A second, muted line: what the option IS (a tax id, a city), not a second name. */
13
13
  description?: string;
14
14
  disabled?: boolean;
15
+ /** Drawn on the option when the choice is shown as cards (`RadioGroup look="cards"`): the
16
+ * card of «Efectivo», «QR», «Tarjeta». Beside the label, never instead of it. */
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;
15
22
  }
16
23
  /** One segment of a `SegmentedControl`. The icon goes before the label, never instead of it. */
17
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,43 @@
1
+ import type { ReactNode } from "react";
2
+ export type KeypadProps = {
3
+ /** The number being typed, in the machine's form: «1250.5». */
4
+ value: string;
5
+ onChange: (next: string) => void;
6
+ /** Decimals the number takes — `0` for units (no decimal key), `2` for money. */
7
+ decimals?: number;
8
+ /** The key beside the zero: the decimal point (default, unless `decimals` is 0), «00» for a
9
+ * till that types prices in cents, or «±» for an amount that can be negative. */
10
+ extra?: "decimal" | "double-zero" | "sign";
11
+ /** `lg` for a till or a kiosk — keys a thumb hits without looking; `md` beside a form. */
12
+ size?: "md" | "lg";
13
+ /** A wide key under the pad: «Cantidad», «Cobrar» — what the number is FOR. */
14
+ children?: ReactNode;
15
+ /**
16
+ * The pad's screen, on top, as a calculator has: what is being typed, big and right-aligned,
17
+ * and what it is («Capuchino · Cant.»). Without it the screen is the application's. `value`
18
+ * is already written for the person (`«12,50»`), the pad does not format it.
19
+ */
20
+ screen?: {
21
+ label?: ReactNode;
22
+ value: ReactNode;
23
+ };
24
+ /** The pad's accessible name, when no `Field` names it. */
25
+ "aria-label"?: string;
26
+ id?: string;
27
+ disabled?: boolean;
28
+ };
29
+ /**
30
+ * The on-screen number pad of a till, a kiosk, a scale — the calculator's layout (7 8 9 on
31
+ * top), keys a thumb hits.
32
+ *
33
+ * Context: a cashier types quantities and prices all day on a touch screen with no keyboard,
34
+ * and the phone's numeric keyboard covers half the ticket. The pad is a CONTROL: it edits a
35
+ * value (`value` / `onChange`, the machine's «1250.5»), and what it is for — quantity,
36
+ * discount, price — is the screen's, as a `SegmentedControl` over it. The rules of each key
37
+ * are pure (`applyKey`), the same ones a physical keyboard follows here: with the pad
38
+ * focused, digits, «,» or «.», Backspace, Delete and «-» do what their key does.
39
+ *
40
+ * The decimal key shows the person's separator («,» in Bolivia) but writes «.»: the screen
41
+ * formats, the value travels in one form.
42
+ */
43
+ export declare function Keypad({ value, onChange, decimals, extra, size, children, "aria-label": ariaLabel, id: ownId, disabled, screen, }: KeypadProps): import("react").JSX.Element;
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useUiCopy } from "../../foundations/copy.js";
4
+ import { useFieldIds } from "../../foundations/form.js";
5
+ import { buttonClasses } from "../button/classes.js";
6
+ import { applyKey, keyOfKeyboard, } from "./keypadKeys.js";
7
+ import { Delete } from "lucide-react";
8
+ const ROWS = [
9
+ ["7", "8", "9"],
10
+ ["4", "5", "6"],
11
+ ["1", "2", "3"],
12
+ ];
13
+ /**
14
+ * The on-screen number pad of a till, a kiosk, a scale — the calculator's layout (7 8 9 on
15
+ * top), keys a thumb hits.
16
+ *
17
+ * Context: a cashier types quantities and prices all day on a touch screen with no keyboard,
18
+ * and the phone's numeric keyboard covers half the ticket. The pad is a CONTROL: it edits a
19
+ * value (`value` / `onChange`, the machine's «1250.5»), and what it is for — quantity,
20
+ * discount, price — is the screen's, as a `SegmentedControl` over it. The rules of each key
21
+ * are pure (`applyKey`), the same ones a physical keyboard follows here: with the pad
22
+ * focused, digits, «,» or «.», Backspace, Delete and «-» do what their key does.
23
+ *
24
+ * The decimal key shows the person's separator («,» in Bolivia) but writes «.»: the screen
25
+ * formats, the value travels in one form.
26
+ */
27
+ export function Keypad({ value, onChange, decimals, extra = decimals === 0 ? "double-zero" : "decimal", size = "lg", children, "aria-label": ariaLabel, id: ownId, disabled = false, screen, }) {
28
+ const copy = useUiCopy();
29
+ const { id, labelledBy, describedBy } = useFieldIds({ id: ownId });
30
+ const rules = decimals === undefined ? {} : { decimals };
31
+ const press = (key) => onChange(applyKey(value, key, rules));
32
+ const separator = new Intl.NumberFormat(copy.locale).formatToParts(1.5).find((p) => p.type === "decimal")
33
+ ?.value ?? ".";
34
+ const onKeyDown = (event) => {
35
+ if (disabled || event.altKey || event.ctrlKey || event.metaKey)
36
+ return;
37
+ const key = keyOfKeyboard(event.key);
38
+ if (key === null)
39
+ return;
40
+ if (key === "decimal" && extra !== "decimal")
41
+ return;
42
+ if (key === "sign" && extra !== "sign")
43
+ return;
44
+ event.preventDefault();
45
+ press(key);
46
+ };
47
+ const keyClass = `${buttonClasses("secondary", size)} w-full font-medium tabular-nums ${size === "lg" ? "h-14 text-title" : "text-lead"}`;
48
+ const key = (k, face, label) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => press(k), ...(label === undefined ? {} : { "aria-label": label }), "data-ui": "keypad.key", className: keyClass, children: face }, k));
49
+ const extraKey = extra === "decimal"
50
+ ? key("decimal", separator, copy.keypad.decimal)
51
+ : extra === "sign"
52
+ ? key("sign", "±", copy.keypad.sign)
53
+ : key("00", "00");
54
+ return (
55
+ /* A group, not a grid: the keys are reached by Tab in reading order, and the group itself
56
+ takes the physical keyboard while focus is inside it. */
57
+ _jsxs("div", { role: "group", "data-ui": "keypad", "data-size": size, ...(id === undefined ? {} : { id }), ...(labelledBy === undefined
58
+ ? { "aria-label": ariaLabel ?? copy.keypad.label }
59
+ : { "aria-labelledby": labelledBy }), ...(describedBy === undefined ? {} : { "aria-describedby": describedBy }), onKeyDown: onKeyDown, className: "grid w-full min-w-0 grid-cols-3 gap-1.5", children: [screen === undefined ? null : (
60
+ /* Live, so a screen reader hears the number as it is typed. */
61
+ _jsxs("div", { "data-ui": "keypad.screen", "aria-live": "polite", className: "col-span-3 flex min-w-0 flex-col items-end rounded-control border border-line bg-ink/4 px-3 py-2", children: [screen.label === undefined ? null : (_jsx("span", { className: "min-w-0 max-w-full truncate text-micro text-muted", children: screen.label })), _jsx("span", { className: "text-display leading-none font-semibold text-ink tabular-nums", children: screen.value })] })), ROWS.flat().map((k) => key(k, k)), extraKey, key("0", "0"), key("backspace", _jsx(Delete, { "aria-hidden": true, className: "size-(--size-icon-lg)" }), copy.keypad.backspace), children === undefined ? null : (_jsx("div", { className: "col-span-3 flex min-w-0", children: children }))] }));
62
+ }
@@ -0,0 +1,28 @@
1
+ import { type ControlProps } from "./Field.js";
2
+ export type StepperProps = Omit<ControlProps, "describedBy" | "invalid"> & {
3
+ value: number;
4
+ onChange: (next: number) => void;
5
+ min?: number;
6
+ max?: number;
7
+ step?: number;
8
+ /** `lg` for a kiosk or a till — targets a thumb hits; `md` in a line of a form or a cart. */
9
+ size?: "md" | "lg";
10
+ /**
11
+ * At the minimum, «−» becomes «remove» (a bin) and calls this: a cart's line goes from 1 to
12
+ * nothing in the same place, the way a shop's and a kiosk's do. Without it, «−» stops at
13
+ * `min`.
14
+ */
15
+ onRemove?: () => void;
16
+ /** What one unit is called, for the buttons' names: «Quitar un Capuchino». */
17
+ unitLabel?: string;
18
+ };
19
+ /**
20
+ * A quantity with «−» and «+» — a cart's line, a kiosk's item, the people at a table.
21
+ *
22
+ * Context: `NumberInput` is for typing a number; its small step buttons are for a mouse.
23
+ * On a touch screen a quantity is changed by pressing, not typing: two targets as big as a
24
+ * control, the figure between them in tabular digits so it does not jump. The arrows step it
25
+ * from the keyboard (the group is one stop, a spin button), Home and End go to the limits.
26
+ * With `onRemove`, «−» at the minimum is a bin and takes the line away — no second control.
27
+ */
28
+ export declare function Stepper({ value, onChange, min, max, step, size, onRemove, unitLabel, id: ownId, disabled, mode, "aria-label": ariaLabel, }: StepperProps): import("react").JSX.Element;
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { controlName } from "../../foundations/controlName.js";
4
+ import { useUiCopy } from "../../foundations/copy.js";
5
+ import { useFieldIds, useFormMode } from "../../foundations/form.js";
6
+ import { buttonClasses } from "../button/classes.js";
7
+ import { ReadValue } from "./Field.js";
8
+ import { Minus, Plus, Trash2 } from "lucide-react";
9
+ /**
10
+ * A quantity with «−» and «+» — a cart's line, a kiosk's item, the people at a table.
11
+ *
12
+ * Context: `NumberInput` is for typing a number; its small step buttons are for a mouse.
13
+ * On a touch screen a quantity is changed by pressing, not typing: two targets as big as a
14
+ * control, the figure between them in tabular digits so it does not jump. The arrows step it
15
+ * from the keyboard (the group is one stop, a spin button), Home and End go to the limits.
16
+ * With `onRemove`, «−» at the minimum is a bin and takes the line away — no second control.
17
+ */
18
+ export function Stepper({ value, onChange, min = 0, max, step = 1, size = "md", onRemove, unitLabel, id: ownId, disabled = false, mode, "aria-label": ariaLabel, }) {
19
+ const copy = useUiCopy();
20
+ const { id, labelledBy, describedBy } = useFieldIds({ id: ownId });
21
+ if (useFormMode(mode) === "read")
22
+ return _jsx(ReadValue, { value: value });
23
+ const atMin = value <= min;
24
+ const atMax = max !== undefined && value >= max;
25
+ const removes = atMin && onRemove !== undefined;
26
+ const clamp = (n) => Math.min(max ?? Number.POSITIVE_INFINITY, Math.max(min, n));
27
+ /* «Sumar uno: Capuchino» — the unit after the verb, so a list of steppers is told apart. */
28
+ const named = (verb) => (unitLabel === undefined ? verb : `${verb}: ${unitLabel}`);
29
+ const lower = () => (removes ? onRemove() : onChange(clamp(value - step)));
30
+ const raise = () => onChange(clamp(value + step));
31
+ const onKeyDown = (event) => {
32
+ if (disabled)
33
+ return;
34
+ const keys = {
35
+ ArrowUp: raise,
36
+ ArrowRight: raise,
37
+ ArrowDown: () => !atMin && onChange(clamp(value - step)),
38
+ ArrowLeft: () => !atMin && onChange(clamp(value - step)),
39
+ Home: () => onChange(min),
40
+ ...(max === undefined ? {} : { End: () => onChange(max) }),
41
+ };
42
+ const run = keys[event.key];
43
+ if (run === undefined)
44
+ return;
45
+ event.preventDefault();
46
+ run();
47
+ };
48
+ const button = `${buttonClasses("secondary", size === "lg" ? "lg" : "sm")} aspect-square px-0`;
49
+ return (_jsxs("div", { "data-ui": "stepper", "data-size": size, className: "inline-flex min-w-0 items-center gap-1.5", children: [_jsx("button", { type: "button", tabIndex: -1, disabled: disabled || (atMin && !removes), onClick: lower, "aria-label": named(removes ? copy.stepper.remove : copy.stepper.decrease), className: button, children: removes ? (_jsx(Trash2, { "aria-hidden": true, className: "size-(--size-icon-md)" })) : (_jsx(Minus, { "aria-hidden": true, className: "size-(--size-icon-md)" })) }), _jsx("div", { role: "spinbutton", tabIndex: disabled ? -1 : 0, ...(id === undefined ? {} : { id }), "aria-valuenow": value, "aria-valuemin": min, ...(max === undefined ? {} : { "aria-valuemax": max }), ...(labelledBy === undefined
50
+ ? { "aria-label": controlName(undefined, ariaLabel, copy.stepper.label) }
51
+ : { "aria-labelledby": labelledBy }), ...(describedBy === undefined ? {} : { "aria-describedby": describedBy }), "aria-disabled": disabled || undefined, onKeyDown: onKeyDown, className: `min-w-8 rounded-control text-center font-semibold text-ink tabular-nums outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${size === "lg" ? "text-title" : "text-body"}`, children: value }), _jsx("button", { type: "button", tabIndex: -1, disabled: disabled || atMax, onClick: raise, "aria-label": named(copy.stepper.increase), className: button, children: _jsx(Plus, { "aria-hidden": true, className: "size-(--size-icon-md)" }) })] }));
52
+ }
@@ -66,5 +66,5 @@ export function shownText(root) {
66
66
  /** The button by a field's label. `scope` is the field's value area. */
67
67
  export function FieldCopy({ label, scope, value, }) {
68
68
  const ui = useUiCopy();
69
- return (_jsx("span", { "data-copy-skip": "", className: "inline-flex shrink-0 opacity-0 transition-opacity duration-(--duration-instant) group-hover/field:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100", children: _jsx(CopyButton, { label: fillCopy(ui.copyable.field, { label }), value: () => value ?? (scope.current === null ? "" : shownText(scope.current)) }) }));
69
+ return (_jsx("span", { "data-copy-skip": "", className: "inline-flex shrink-0 opacity-0 transition-opacity duration-(--duration-instant) group-hover/field:opacity-100 focus-within:opacity-100 touch:opacity-100", children: _jsx(CopyButton, { label: fillCopy(ui.copyable.field, { label }), value: () => value ?? (scope.current === null ? "" : shownText(scope.current)) }) }));
70
70
  }
@@ -5,6 +5,9 @@ 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";
7
7
  export { EmailInput, PhoneInput, UrlInput, } from "./ContactInputs.js";
8
+ export { Keypad, type KeypadProps } from "./Keypad.js";
9
+ export { applyKey, isKeypadKey, keyOfKeyboard, type KeypadKey, type KeypadRules, } from "./keypadKeys.js";
10
+ export { Stepper, type StepperProps } from "./Stepper.js";
8
11
  export { FieldCopyProvider, shownText, useFieldCopy, } from "./clipboard.js";
9
12
  export { DropZone, type DropZoneProps } from "./DropZone.js";
10
13
  export { formatDuration, parseDuration } from "./duration.js";
@@ -10,9 +10,15 @@ export { CardCodeInput, CardExpiryInput, CardNumberInput, } from "./CardNumberIn
10
10
  /* An address to reach someone: typed with its keyboard, read as a link. */
11
11
  export { Checkbox, CheckList, CheckMark, } from "./Checks.js";
12
12
  export { CodeInput } from "./CodeInput.js";
13
+ /* THE PAD — a till's or a kiosk's on-screen numbers. Its rules are pure (`keypadKeys.ts`), so a
14
+ physical keyboard or a test applies the same. */
13
15
  export { ColorInput } from "./ColorInput.js";
14
16
  export { emailHref, isEmail, isUrl, telHref, urlHref, urlLabel, whatsappHref, } from "./contact.js";
15
17
  export { EmailInput, PhoneInput, UrlInput, } from "./ContactInputs.js";
18
+ export { Keypad } from "./Keypad.js";
19
+ /* A QUANTITY pressed, not typed — a cart's line, a kiosk's item. */
20
+ export { applyKey, isKeypadKey, keyOfKeyboard, } from "./keypadKeys.js";
21
+ export { Stepper } from "./Stepper.js";
16
22
  /* The copy button every field carries by its label — on by default, off by field or by form. */
17
23
  export { FieldCopyProvider, shownText, useFieldCopy, } from "./clipboard.js";
18
24
  export { DropZone } from "./DropZone.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * WHAT A KEY OF THE PAD DOES TO THE NUMBER BEING TYPED — pure, so a test, a server or a
3
+ * keyboard handler applies the same rules as the on-screen pad (`Keypad`).
4
+ *
5
+ * Context: a till types quantities, discounts and prices with a thumb. The text is kept in
6
+ * the machine's form — digits, one «.», an optional leading «-» — and the screen formats it
7
+ * in the person's locale: what travels is «1250.5», what is read is «1.250,5». The rules
8
+ * are the ones a cashier expects from a calculator: «0» then «5» is «5», not «05»; a second
9
+ * decimal point does nothing; past the allowed decimals a digit does nothing; ⌫ on «-» leaves
10
+ * nothing.
11
+ */
12
+ export type KeypadKey = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "00" | "decimal" | "backspace" | "clear" | "sign";
13
+ export type KeypadRules = {
14
+ /** How many decimals the number takes — `0` for a quantity of units, `2` for money. A
15
+ * digit past them does nothing. Without it, any. */
16
+ decimals?: number;
17
+ };
18
+ /** True for a key of the pad: what comes from a physical keyboard is a string. */
19
+ export declare function isKeypadKey(key: string): key is KeypadKey;
20
+ /** The text after pressing `key`. */
21
+ export declare function applyKey(text: string, key: KeypadKey, rules?: KeypadRules): string;
22
+ /** The key a physical keyboard's key stands for, or `null`: digits, «.» and «,» (the decimal
23
+ * point whatever the locale), Backspace, Delete / Escape (clear), «-» (sign). */
24
+ export declare function keyOfKeyboard(key: string): KeypadKey | null;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * WHAT A KEY OF THE PAD DOES TO THE NUMBER BEING TYPED — pure, so a test, a server or a
3
+ * keyboard handler applies the same rules as the on-screen pad (`Keypad`).
4
+ *
5
+ * Context: a till types quantities, discounts and prices with a thumb. The text is kept in
6
+ * the machine's form — digits, one «.», an optional leading «-» — and the screen formats it
7
+ * in the person's locale: what travels is «1250.5», what is read is «1.250,5». The rules
8
+ * are the ones a cashier expects from a calculator: «0» then «5» is «5», not «05»; a second
9
+ * decimal point does nothing; past the allowed decimals a digit does nothing; ⌫ on «-» leaves
10
+ * nothing.
11
+ */
12
+ const DIGITS = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);
13
+ /** True for a key of the pad: what comes from a physical keyboard is a string. */
14
+ export function isKeypadKey(key) {
15
+ return (DIGITS.has(key) ||
16
+ key === "00" ||
17
+ key === "decimal" ||
18
+ key === "backspace" ||
19
+ key === "clear" ||
20
+ key === "sign");
21
+ }
22
+ function appendDigits(text, digits, rules) {
23
+ let next = text;
24
+ for (const digit of digits) {
25
+ const sign = next.startsWith("-") ? "-" : "";
26
+ const body = next.slice(sign.length);
27
+ const point = body.indexOf(".");
28
+ if (point >= 0 &&
29
+ rules.decimals !== undefined &&
30
+ body.length - point - 1 >= rules.decimals) {
31
+ return next;
32
+ }
33
+ /* A lone zero is replaced, not prefixed: «0» then «5» is «5». */
34
+ next = body === "0" ? `${sign}${digit}` : `${next}${digit}`;
35
+ }
36
+ return next;
37
+ }
38
+ /** The text after pressing `key`. */
39
+ export function applyKey(text, key, rules = {}) {
40
+ if (key === "clear")
41
+ return "";
42
+ if (key === "backspace") {
43
+ const next = text.slice(0, -1);
44
+ return next === "-" ? "" : next;
45
+ }
46
+ if (key === "sign") {
47
+ if (text === "")
48
+ return text;
49
+ return text.startsWith("-") ? text.slice(1) : `-${text}`;
50
+ }
51
+ if (key === "decimal") {
52
+ if (rules.decimals === 0 || text.includes("."))
53
+ return text;
54
+ const sign = text.startsWith("-") ? "-" : "";
55
+ const body = text.slice(sign.length);
56
+ return `${sign}${body === "" ? "0" : body}.`;
57
+ }
58
+ if (key === "00") {
59
+ /* Two zeros on nothing is still nothing typed: «00» is how a cashier writes hundreds. */
60
+ if (text === "" || text === "-" || text === "0")
61
+ return text;
62
+ return appendDigits(text, "00", rules);
63
+ }
64
+ return appendDigits(text, key, rules);
65
+ }
66
+ /** The key a physical keyboard's key stands for, or `null`: digits, «.» and «,» (the decimal
67
+ * point whatever the locale), Backspace, Delete / Escape (clear), «-» (sign). */
68
+ export function keyOfKeyboard(key) {
69
+ if (DIGITS.has(key))
70
+ return key;
71
+ if (key === "." || key === ",")
72
+ return "decimal";
73
+ if (key === "Backspace")
74
+ return "backspace";
75
+ if (key === "Delete" || key === "Escape")
76
+ return "clear";
77
+ if (key === "-")
78
+ return "sign";
79
+ return null;
80
+ }
@@ -6,7 +6,7 @@ import { CircleHelp } from "lucide-react";
6
6
  import { useId } from "react";
7
7
  import { Button, Dialog, DialogTrigger } from "react-aria-components";
8
8
  const mark = tv({
9
- base: "inline-flex size-4 shrink-0 cursor-help items-center justify-center rounded-pill text-muted outline-0 transition-colors duration-(--duration-instant) hover:bg-ink/8 hover:text-ink aria-expanded:bg-ink/8 aria-expanded:text-ink forced-colors:text-[ButtonText]",
9
+ base: "hit-target inline-flex size-4 shrink-0 cursor-help items-center justify-center rounded-pill text-muted outline-0 transition-colors duration-(--duration-instant) hover:bg-ink/8 hover:text-ink aria-expanded:bg-ink/8 aria-expanded:text-ink forced-colors:text-[ButtonText]",
10
10
  variants: {
11
11
  isFocusVisible: {
12
12
  true: "outline-2 outline-offset-1 outline-primary forced-colors:outline-[Highlight]",
@@ -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";