@tangible/ui 0.2.39 → 0.2.40

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 (69) hide show
  1. package/README.md +2 -2
  2. package/components/Avatar/Avatar.js +20 -5
  3. package/components/Avatar/types.d.ts +15 -0
  4. package/components/Button/Button.js +10 -3
  5. package/components/Button/types.d.ts +31 -3
  6. package/components/Button/types.js +2 -0
  7. package/components/ColorPicker/ColorField.d.ts +1 -1
  8. package/components/ColorPicker/ColorField.js +9 -1
  9. package/components/DatePicker/DateRangePicker.d.ts +1 -0
  10. package/components/DatePicker/DateRangePicker.js +24 -6
  11. package/components/DatePicker/PickerTrigger.js +1 -1
  12. package/components/DatePicker/types.d.ts +20 -3
  13. package/components/DatePicker/types.js +1 -0
  14. package/components/IconButton/IconButtonCore.js +13 -5
  15. package/components/IconButton/index.d.ts +2 -1
  16. package/components/IconButton/index.js +1 -0
  17. package/components/IconButton/types.d.ts +37 -2
  18. package/components/IconButton/types.js +4 -1
  19. package/components/MultiSelect/MultiSelect.js +9 -3
  20. package/components/NavMenu/NavMenu.js +37 -3
  21. package/components/Progress/Progress.js +73 -2
  22. package/components/Progress/index.d.ts +2 -1
  23. package/components/Progress/index.js +1 -0
  24. package/components/Progress/types.d.ts +130 -2
  25. package/components/Progress/types.js +3 -1
  26. package/components/Select/Select.js +2 -1
  27. package/components/Tooltip/Tooltip.js +23 -0
  28. package/components/index.d.ts +28 -26
  29. package/components/index.js +10 -10
  30. package/figma-tokens.json +1 -1
  31. package/icons/icons.svg +15 -5
  32. package/icons/lms/index.d.ts +7 -4
  33. package/icons/lms/index.js +9 -44
  34. package/icons/lms.svg +4 -4
  35. package/icons/manifest.json +96 -12
  36. package/icons/registry.d.ts +20 -0
  37. package/icons/registry.js +11 -0
  38. package/icons/searchsync/index.d.ts +21 -0
  39. package/icons/searchsync/index.js +82 -0
  40. package/icons/searchsync.svg +9 -0
  41. package/icons/sprite-registry.js +10 -0
  42. package/icons/sprite-version.js +1 -1
  43. package/icons/sprite.d.ts +1 -1
  44. package/icons/sprite.js +2 -1
  45. package/icons/sprite.php +3 -2
  46. package/icons/system/index.d.ts +6 -0
  47. package/icons/system/index.js +33 -0
  48. package/icons/system.svg +3 -0
  49. package/package.json +1 -1
  50. package/skills/building-with-tui/SKILL.md +77 -30
  51. package/styles/all.css +1 -1
  52. package/styles/all.expanded.css +180 -44
  53. package/styles/all.expanded.unlayered.css +180 -44
  54. package/styles/all.unlayered.css +1 -1
  55. package/styles/components/button.scss +18 -0
  56. package/styles/components/checkbox.scss +21 -13
  57. package/styles/components/icon-button.scss +44 -25
  58. package/styles/components/nav-menu.scss +3 -0
  59. package/styles/components/notice.scss +4 -0
  60. package/styles/components/progress.scss +96 -0
  61. package/styles/components/radio.scss +35 -7
  62. package/styles/components/segmented-control.scss +98 -18
  63. package/tui-manifest.json +142 -39
  64. package/utils/portal.d.ts +4 -3
  65. package/utils/portal.js +16 -2
  66. package/utils/use-loading-announcer.d.ts +2 -0
  67. package/utils/use-loading-announcer.js +101 -0
  68. package/vanilla/styles.css +1 -1
  69. package/vanilla/styles.unlayered.css +1 -1
package/README.md CHANGED
@@ -201,8 +201,8 @@ All form controls share a unified sizing system:
201
201
 
202
202
  ### Icons
203
203
 
204
- Six sets in the registry, 237 icons: `system` (99), `lms` (44), `reaction` (36), `player` (24),
205
- `membersync` (22), `cred` (12). Reference one by path; `IconName` is a literal union, so a typo
204
+ Seven sets in the registry, 290 icons: `system` (144), `lms` (45), `reaction` (36), `player` (24),
205
+ `membersync` (22), `cred` (12), `searchsync` (7). Reference one by path; `IconName` is a literal union, so a typo
206
206
  fails typecheck. `@tangible/ui/icons/manifest` is the machine-readable list.
207
207
 
208
208
  ```tsx
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useState, useMemo } from 'react';
2
+ import React, { useState, useMemo, useEffect, useRef } from 'react';
3
3
  import { cx } from '../../utils/cx.js';
4
+ import { isDev } from '../../utils/is-dev.js';
4
5
  import { stringToGenerativeColor } from '../../utils/generative.js';
5
6
  import { Icon } from '../Icon/index.js';
6
7
  import { Tooltip } from '../Tooltip/index.js';
@@ -28,7 +29,7 @@ function getInitials(name) {
28
29
  * Bag), derived from the name hash for consistency; name-less avatars
29
30
  * fall back to the neutral `slate`
30
31
  */
31
- export const Avatar = React.memo(React.forwardRef(({ src, name, size = 'md', shape = 'circle', color, indicator, indicatorLabel, indicatorPosition = 'bottom-right', tooltip, labels: labelsProp, className, }, ref) => {
32
+ export const Avatar = React.memo(React.forwardRef(({ src, name, size = 'md', shape = 'circle', color, indicator, indicatorLabel, indicatorPosition = 'bottom-right', tooltip, decorative = false, labels: labelsProp, className, }, ref) => {
32
33
  const [imgError, setImgError] = useState(false);
33
34
  // Reset error state when src changes
34
35
  React.useEffect(() => {
@@ -40,9 +41,23 @@ export const Avatar = React.memo(React.forwardRef(({ src, name, size = 'md', sha
40
41
  const showImage = src && !imgError;
41
42
  const showInitials = !showImage && initials;
42
43
  const showPlaceholder = !showImage && !initials;
43
- // Avatars with no name and no indicator label have no meaningful identity
44
- const isDecorative = !name && !indicatorLabel;
45
- const showTooltip = tooltip && !!name;
44
+ // Decorative on request (the person is named beside the avatar), or
45
+ // implicitly when there's no name and no indicator label to announce.
46
+ const isDecorative = decorative || (!name && !indicatorLabel);
47
+ // A decorative avatar is hidden from AT, so a tooltip naming it would be
48
+ // hover-only content with no AT equivalent; the visible name beside it
49
+ // already does that job.
50
+ const showTooltip = tooltip && !!name && !decorative;
51
+ // `decorative` hides everything, the indicator's meaning included.
52
+ const warnedRef = useRef(false);
53
+ useEffect(() => {
54
+ if (!isDev() || warnedRef.current || !decorative || !indicatorLabel)
55
+ return;
56
+ warnedRef.current = true;
57
+ console.warn(`[Avatar] \`decorative\` hides the avatar from assistive tech, so its ` +
58
+ `indicatorLabel ("${indicatorLabel}") is never announced. Convey the ` +
59
+ 'status in the visible text beside the avatar, or drop `decorative`.');
60
+ }, [decorative, indicatorLabel]);
46
61
  const avatarElement = (_jsxs("span", { ref: ref, className: cx('tui-avatar', `is-size-${size}`, `is-shape-${shape}`, !showImage && `is-color-${derivedColor}`, className), ...(isDecorative
47
62
  ? { 'aria-hidden': true }
48
63
  : {
@@ -39,6 +39,21 @@ export type AvatarProps = {
39
39
  * Has no effect when `name` is not provided.
40
40
  */
41
41
  tooltip?: boolean;
42
+ /**
43
+ * Hide the avatar from assistive tech while keeping its picture, initials
44
+ * and color. Use it when the person is already named in visible text
45
+ * beside the avatar, e.g. an account-menu button holding an avatar and an
46
+ * email: without it, the avatar's `role="img"` name is concatenated into
47
+ * the button's accessible name.
48
+ *
49
+ * Renders `aria-hidden="true"` with no `role` and no `aria-label`. `name`
50
+ * still drives the initials and color. `tooltip` is ignored, and
51
+ * `indicatorLabel` is never announced (a dev warning fires), so put any
52
+ * status in the visible text too.
53
+ *
54
+ * @default false
55
+ */
56
+ decorative?: boolean;
42
57
  /** Overridable strings for i18n. */
43
58
  labels?: AvatarLabels;
44
59
  /** Additional CSS class */
@@ -1,9 +1,11 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { forwardRef, useEffect, useRef } from 'react';
2
+ import React, { forwardRef, useEffect, useMemo, useRef } from 'react';
3
3
  import { isDev } from '../../utils/is-dev.js';
4
4
  import { cx } from '../../utils/cx.js';
5
5
  import { Icon } from '../Icon/index.js';
6
6
  import { getSafeRel } from '../../utils/polymorphic.js';
7
+ import { composeRefs } from '../../utils/compose-refs.js';
8
+ import { useLoadingAnnouncer } from '../../utils/use-loading-announcer.js';
7
9
  import { defaultButtonLabels } from './types.js';
8
10
  export const Button = forwardRef(({ label, children, size = 'md', theme = 'primary', variant = 'solid', fullWidth, disabled = false, loading = false, loadingLabel: loadingLabelProp, labels: labelsProp, leftIconName, rightIconName, leftIcon, rightIcon, className, target, rel, onClick, style, ...rest }, ref) => {
9
11
  const isLink = typeof rest.href === 'string';
@@ -15,6 +17,11 @@ export const Button = forwardRef(({ label, children, size = 'md', theme = 'prima
15
17
  // `disabled` goes native.
16
18
  const loadingOnly = loading && !disabled;
17
19
  const labels = { ...defaultButtonLabels, ...labelsProp };
20
+ // Opt-in loading announcements (#131): portaled, so no DOM sibling.
21
+ const elementRef = useRef(null);
22
+ const announcer = useLoadingAnnouncer(elementRef, loading, labels.loadingStart, labels.loadingEnd);
23
+ // Memoised so the consumer's ref isn't detached and reattached every render.
24
+ const mergedRef = useMemo(() => composeRefs(ref, elementRef), [ref]);
18
25
  // A non-string label can't compose "X, loading", so without loadingLabel
19
26
  // the busy state has no name change at all.
20
27
  const loadingWarned = useRef(false);
@@ -48,7 +55,7 @@ export const Button = forwardRef(({ label, children, size = 'md', theme = 'prima
48
55
  }
49
56
  onClick?.(e);
50
57
  };
51
- return (_jsxs("a", { ref: ref, href: disabled ? undefined : href, className: classes, "aria-label": loadingLabel, "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, tabIndex: disabled ? -1 : tabIndex, onClick: handleClick, "data-loading": loading || undefined, target: target, rel: safeRel, style: style, ...anchorRest, children: [content, target === '_blank' && (_jsx("span", { className: "tui-visually-hidden", children: labels.newTab }))] }));
58
+ return (_jsxs(_Fragment, { children: [_jsxs("a", { ref: mergedRef, href: disabled ? undefined : href, className: classes, "aria-label": loadingLabel, "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, tabIndex: disabled ? -1 : tabIndex, onClick: handleClick, "data-loading": loading || undefined, target: target, rel: safeRel, style: style, ...anchorRest, children: [content, target === '_blank' && (_jsx("span", { className: "tui-visually-hidden", children: labels.newTab }))] }), announcer] }));
52
59
  }
53
60
  const buttonRest = rest;
54
61
  // Enter/Space and implicit form submission all arrive as a click, so one
@@ -61,6 +68,6 @@ export const Button = forwardRef(({ label, children, size = 'md', theme = 'prima
61
68
  }
62
69
  onClick?.(e);
63
70
  };
64
- return (_jsx("button", { ref: ref, type: buttonRest.type ?? 'button', className: classes, "aria-label": loadingLabel, disabled: disabled, "aria-disabled": loadingOnly || undefined, "aria-busy": loading || undefined, onClick: handleButtonClick, "data-loading": loading || undefined, style: style, ...buttonRest, children: content }));
71
+ return (_jsxs(_Fragment, { children: [_jsx("button", { ref: mergedRef, type: buttonRest.type ?? 'button', className: classes, "aria-label": loadingLabel, disabled: disabled, "aria-disabled": loadingOnly || undefined, "aria-busy": loading || undefined, onClick: handleButtonClick, "data-loading": loading || undefined, style: style, ...buttonRest, children: content }), announcer] }));
65
72
  });
66
73
  Button.displayName = 'Button';
@@ -25,6 +25,18 @@ export type Variant = 'solid' | 'outline' | 'ghost' | 'link';
25
25
  export type ButtonLabels = {
26
26
  /** Label for the "(opens in new tab)" visually-hidden hint on external links. */
27
27
  newTab?: string;
28
+ /**
29
+ * Spoken politely when `loading` turns on, e.g. "Saving…". Setting this
30
+ * or `loadingEnd` opts the button into loading announcements (#131).
31
+ * @default '' (not announced)
32
+ */
33
+ loadingStart?: string;
34
+ /**
35
+ * Spoken politely when `loading` turns off, e.g. "Saved". Says the action
36
+ * finished, which the silent revert of the loading name never did.
37
+ * @default '' (not announced)
38
+ */
39
+ loadingEnd?: string;
28
40
  };
29
41
  export declare const defaultButtonLabels: Required<ButtonLabels>;
30
42
  type CommonProps = {
@@ -70,8 +82,23 @@ type CommonProps = {
70
82
  * button focusable (`aria-disabled`, not native `disabled`), so a
71
83
  * keyboard user who triggered it keeps their place. Only `onClick` is
72
84
  * guarded: put the action there, not in `onKeyDown`/`onPointerDown`.
73
- * The start and end of loading aren't announced; confirm completion
74
- * through your own status message (a Toast, say).
85
+ *
86
+ * By default the start and end of loading aren't announced: the busy
87
+ * name ("Save, loading") is set on the focused button, which screen
88
+ * readers rarely re-read, and it reverts silently. Opt in with
89
+ * `labels={{ loadingStart: 'Saving…', loadingEnd: 'Saved' }}` to speak
90
+ * each transition through a pre-mounted polite live region (portaled, so
91
+ * it never becomes a DOM sibling of the button). If the button unmounts
92
+ * when the action completes (a dialog closing), the end can't be spoken
93
+ * from here: confirm through your own status message (a Toast).
94
+ *
95
+ * With `loadingStart`, don't set `aria-busy` on an ancestor of the
96
+ * button: NVDA and Chromium hold live-region output under a busy ancestor.
97
+ * Test with a screen reader: some also re-read the busy name ("Save,
98
+ * loading"), which can double up with `loadingStart`.
99
+ *
100
+ * While loading, the button stays focusable, so it mutes its colors rather
101
+ * than dimming the whole element: the focus ring keeps full contrast.
75
102
  * @default false
76
103
  */
77
104
  loading?: boolean;
@@ -82,7 +109,8 @@ type CommonProps = {
82
109
  */
83
110
  loadingLabel?: string;
84
111
  /**
85
- * Override default English strings for i18n.
112
+ * Override default English strings for i18n, and opt in to loading
113
+ * announcements (`loadingStart` / `loadingEnd`, empty by default).
86
114
  * Covers strings not already handled by existing props (e.g. `loadingLabel`).
87
115
  */
88
116
  labels?: ButtonLabels;
@@ -1,3 +1,5 @@
1
1
  export const defaultButtonLabels = {
2
2
  newTab: ' (opens in new tab)',
3
+ loadingStart: '',
4
+ loadingEnd: '',
3
5
  };
@@ -109,4 +109,4 @@ export type ColorFieldProps = {
109
109
  * and a label that opens a {@link ColorPicker} in a dialog popover. This is the
110
110
  * reusable field-level control for colour inputs; the picker itself is the panel.
111
111
  */
112
- export declare function ColorField({ value: controlledValue, defaultValue, onValueChange, format: controlledFormat, defaultFormat, onFormatChange, formats, alpha, gradient, disabled, label, showLabel, showSwatch, variant, dynamic, icon, size, side, align, open, defaultOpen, onOpenChange, labels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, className, id, ...rest }: ColorFieldProps): import("react/jsx-runtime").JSX.Element;
112
+ export declare function ColorField({ value: controlledValue, defaultValue, onValueChange, format: controlledFormat, defaultFormat, onFormatChange, formats, alpha, gradient, disabled, label, showLabel, showSwatch, variant, dynamic, icon, size, side, align, open, defaultOpen, onOpenChange, labels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-required': _ariaRequired, className, id, ...rest }: ColorFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -68,7 +68,15 @@ function nodeToText(node) {
68
68
  * and a label that opens a {@link ColorPicker} in a dialog popover. This is the
69
69
  * reusable field-level control for colour inputs; the picker itself is the panel.
70
70
  */
71
- export function ColorField({ value: controlledValue, defaultValue = '#000000', onValueChange, format: controlledFormat, defaultFormat = 'hex', onFormatChange, formats, alpha = true, gradient = false, disabled, label, showLabel = true, showSwatch = true, variant = 'field', dynamic = false, icon, size = 'md', side = 'bottom', align = 'start', open, defaultOpen, onOpenChange, labels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, className, id, ...rest }) {
71
+ export function ColorField({ value: controlledValue, defaultValue = '#000000', onValueChange, format: controlledFormat, defaultFormat = 'hex', onFormatChange, formats, alpha = true, gradient = false, disabled, label, showLabel = true, showSwatch = true, variant = 'field', dynamic = false, icon, size = 'md', side = 'bottom', align = 'start', open, defaultOpen, onOpenChange, labels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby,
72
+ // Pulled out of `rest` and dropped, on purpose (#91). The trigger is a plain
73
+ // <button> with aria-haspopup="dialog", so its role is `button`, which does
74
+ // not support aria-required (ARIA 1.2; axe: aria-allowed-attr). Field.Control
75
+ // injects it under <Field required>; Field.Label's visually hidden "required"
76
+ // text carries the requirement instead, as for SearchSelect and DatePicker.
77
+ // aria-invalid and aria-describedby are legal on a button and still forward.
78
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
79
+ 'aria-required': _ariaRequired, className, id, ...rest }) {
72
80
  const triggerRef = useRef(null);
73
81
  const isValueControlled = useRef(controlledValue !== undefined).current;
74
82
  const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
@@ -6,6 +6,7 @@ declare const DateRangePickerRoot: React.ForwardRefExoticComponent<import("./typ
6
6
  value?: DateRange | null;
7
7
  defaultValue?: DateRange | null;
8
8
  onChange?: (range: DateRange) => void;
9
+ allowOpenEnd?: boolean;
9
10
  withTime?: boolean;
10
11
  presets?: DateRangePreset[] | false;
11
12
  disabled?: boolean;
@@ -18,9 +18,13 @@ import { defaultDateRangePickerLabels } from './types.js';
18
18
  // build a draft (first click sets From, second sets To, swapping if needed),
19
19
  // and only Apply commits it — Cancel or dismissal discards the draft.
20
20
  //
21
+ // Apply needs both endpoints unless `allowOpenEnd` is set (#86): then a start
22
+ // alone commits as `{ from, to: null }`, the trigger reads `labels.openEnd`,
23
+ // and committing the To field empty clears the end.
24
+ //
21
25
  // =============================================================================
22
26
  const EMPTY_RANGE = { from: null, to: null };
23
- const DateRangePickerRoot = React.forwardRef(function DateRangePicker({ value: valueProp, defaultValue, onChange, withTime = false, presets = defaultDateRangePresets, min, max, isDayDisabled, weekStartsOn = 1, locale: localeProp, disabled, labels: labelsProp, calendarLabels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, className, id, children, }, ref) {
27
+ const DateRangePickerRoot = React.forwardRef(function DateRangePicker({ value: valueProp, defaultValue, onChange, withTime = false, allowOpenEnd = false, presets = defaultDateRangePresets, min, max, isDayDisabled, weekStartsOn = 1, locale: localeProp, disabled, labels: labelsProp, calendarLabels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, className, id, children, }, ref) {
24
28
  const labels = { ...defaultDateRangePickerLabels, ...labelsProp };
25
29
  const locale = resolveLocale(localeProp);
26
30
  const [open, setOpen] = React.useState(false);
@@ -51,8 +55,10 @@ const DateRangePickerRoot = React.forwardRef(function DateRangePicker({ value: v
51
55
  }
52
56
  setOpen(next);
53
57
  };
58
+ // Both endpoints, or a start alone when an open end is allowed.
59
+ const canApply = Boolean(draft.from && (draft.to || allowOpenEnd));
54
60
  const apply = () => {
55
- if (!draft.from || !draft.to)
61
+ if (!canApply)
56
62
  return;
57
63
  setValue(draft);
58
64
  setOpen(false);
@@ -83,7 +89,13 @@ const DateRangePickerRoot = React.forwardRef(function DateRangePicker({ value: v
83
89
  setViewMonth(startOfMonth(range.from));
84
90
  };
85
91
  const format = (d) => withTime ? formatDayTime(d, locale) : formatDay(d, locale);
86
- const formatted = value?.from && value?.to ? `${format(value.from)} - ${format(value.to)}` : null;
92
+ const formatted = value?.from
93
+ ? value.to
94
+ ? `${format(value.from)} - ${format(value.to)}`
95
+ : allowOpenEnd
96
+ ? labels.openEnd(format(value.from))
97
+ : null
98
+ : null;
87
99
  const fieldText = (d) => (d ? formatNumeric(d, locale, withTime) : '');
88
100
  const rightMonth = addMonths(viewMonth, 1);
89
101
  // Second calendar stays one month ahead; hide nav overlap by letting the
@@ -134,12 +146,14 @@ const DateRangePickerRoot = React.forwardRef(function DateRangePicker({ value: v
134
146
  setDraft((prev) => prev.from && isBeforeDay(d, prev.from)
135
147
  ? { from: d, to: prev.from }
136
148
  : { ...prev, to: d });
137
- } })] }), _jsxs("div", { className: "tui-date-range-picker__calendars", children: [_jsx(Calendar, { className: "tui-date-range-picker__calendar", month: viewMonth, onMonthChange: (m) => {
149
+ },
150
+ // Emptying To is how an open end is made from a full range.
151
+ onClear: allowOpenEnd ? () => setDraft((prev) => ({ ...prev, to: null })) : undefined })] }), _jsxs("div", { className: "tui-date-range-picker__calendars", children: [_jsx(Calendar, { className: "tui-date-range-picker__calendar", month: viewMonth, onMonthChange: (m) => {
138
152
  // Keep the pair adjacent whichever side navigated.
139
153
  setViewMonth(isSameMonth(m, rightMonth) ? addMonths(viewMonth, 1) : m);
140
154
  }, onChange: pickDay, range: draft, min: min, max: max, isDayDisabled: isDayDisabled, weekStartsOn: weekStartsOn, locale: locale, labels: calendarLabels }), _jsx(Calendar, { className: "tui-date-range-picker__calendar", month: rightMonth, onMonthChange: (m) => {
141
155
  setViewMonth(addMonths(m, -1));
142
- }, onChange: pickDay, range: draft, min: min, max: max, isDayDisabled: isDayDisabled, weekStartsOn: weekStartsOn, locale: locale, labels: calendarLabels })] })] })] }), _jsxs("div", { className: "tui-date-range-picker__foot", children: [_jsx(Button, { className: "tui-date-range-picker__cancel", variant: "outline", theme: "primary", label: labels.cancel, onClick: () => setOpen(false) }), _jsx(Button, { className: "tui-date-range-picker__apply", theme: "primary", label: labels.apply, disabled: !draft.from || !draft.to, onClick: apply })] })] })] }) }));
156
+ }, onChange: pickDay, range: draft, min: min, max: max, isDayDisabled: isDayDisabled, weekStartsOn: weekStartsOn, locale: locale, labels: calendarLabels })] })] })] }), _jsxs("div", { className: "tui-date-range-picker__foot", children: [_jsx(Button, { className: "tui-date-range-picker__cancel", variant: "outline", theme: "primary", label: labels.cancel, onClick: () => setOpen(false) }), _jsx(Button, { className: "tui-date-range-picker__apply", theme: "primary", label: labels.apply, disabled: !canApply, onClick: apply })] })] })] }) }));
143
157
  });
144
158
  DateRangePickerRoot.displayName = 'DateRangePicker';
145
159
  // =============================================================================
@@ -159,10 +173,14 @@ export const DateRangePicker = DateRangePickerRoot;
159
173
  DateRangePicker.Trigger = DateRangePickerTriggerComponent;
160
174
  export const DateRangePickerTrigger = DateRangePickerTriggerComponent;
161
175
  /** Editable From/To text field: shows the formatted value, parses on commit. */
162
- function RangeField({ label, value, locale, onCommit, }) {
176
+ function RangeField({ label, value, locale, onCommit, onClear, }) {
163
177
  const [text, setText] = React.useState(null);
164
178
  const commit = (raw) => {
165
179
  setText(null);
180
+ if (onClear && raw.trim() === '') {
181
+ onClear();
182
+ return;
183
+ }
166
184
  const parsed = parseNumeric(raw, locale);
167
185
  if (parsed)
168
186
  onCommit(parsed);
@@ -4,7 +4,7 @@ import { cx } from '../../utils/cx.js';
4
4
  import { composeRefs, getElementRef } from '../../utils/compose-refs.js';
5
5
  import { Icon } from '../Icon/index.js';
6
6
  import { PopoverTrigger } from '../Popover/index.js';
7
- import { Calendar as CalendarIcon } from '../../icons/lms/index.js';
7
+ import { Calendar as CalendarIcon } from '../../icons/system/index.js';
8
8
  const PickerTriggerContext = React.createContext(null);
9
9
  export const PickerTriggerProvider = PickerTriggerContext.Provider;
10
10
  export function PickerTrigger({ asChild = false, children, className }) {
@@ -130,7 +130,7 @@ export type DatePickerProps = CalendarBaseProps & {
130
130
  * onChange={(e) => setText(e.target.value)}
131
131
  * suffix={
132
132
  * <DatePicker.Trigger asChild>
133
- * <IconButton icon="lms/calendar" label="Pick a date" />
133
+ * <IconButton icon="system/calendar" label="Pick a date" />
134
134
  * </DatePicker.Trigger>
135
135
  * }
136
136
  * />
@@ -171,13 +171,30 @@ export type DateRangePickerLabels = {
171
171
  presets?: string;
172
172
  trigger?: (formatted: string) => string;
173
173
  triggerEmpty?: string;
174
+ /**
175
+ * Trigger text for an open-ended range (`allowOpenEnd`), given the formatted
176
+ * start date. Also what `trigger` receives as `formatted` for that range.
177
+ */
178
+ openEnd?: (from: string) => string;
174
179
  };
175
180
  export declare const defaultDateRangePickerLabels: Required<DateRangePickerLabels>;
176
181
  export type DateRangePickerProps = CalendarBaseProps & {
177
182
  value?: DateRange | null;
178
183
  defaultValue?: DateRange | null;
179
- /** Fires on Apply with a complete range. */
184
+ /**
185
+ * Fires on Apply with a complete range, or with `to: null` for an
186
+ * open-ended one when `allowOpenEnd` is set.
187
+ */
180
188
  onChange?: (range: DateRange) => void;
189
+ /**
190
+ * Let Apply commit a range with a start and no end (`{ from, to: null }`):
191
+ * memberships, subscriptions, "starts now" windows. The trigger then reads
192
+ * `labels.openEnd` ("From 3 Mar 2026"), and emptying the To field clears the
193
+ * end. Off by default, so a committed range always has both endpoints.
194
+ * `DateRange` already types `to` as `Date | null`, so no type changes.
195
+ * @default false
196
+ */
197
+ allowOpenEnd?: boolean;
181
198
  /** Show times in the trigger and From/To fields. */
182
199
  withTime?: boolean;
183
200
  /**
@@ -221,7 +238,7 @@ export type DateRangePickerProps = CalendarBaseProps & {
221
238
  * onChange={(e) => setText(e.target.value)}
222
239
  * suffix={
223
240
  * <DateRangePicker.Trigger asChild>
224
- * <IconButton icon="lms/calendar" label="Pick a date range" />
241
+ * <IconButton icon="system/calendar" label="Pick a date range" />
225
242
  * </DateRangePicker.Trigger>
226
243
  * }
227
244
  * />
@@ -36,4 +36,5 @@ export const defaultDateRangePickerLabels = {
36
36
  presets: 'Quick ranges',
37
37
  trigger: (formatted) => `Change date range, ${formatted}`,
38
38
  triggerEmpty: 'Select date range',
39
+ openEnd: (from) => `From ${from}`,
39
40
  };
@@ -1,9 +1,12 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useEffect } from 'react';
2
+ import { forwardRef, useEffect, useMemo, useRef } from 'react';
3
3
  import { cx } from '../../utils/cx.js';
4
4
  import { Icon } from '../Icon/index.js';
5
5
  import { getSafeRel } from '../../utils/polymorphic.js';
6
6
  import { isDev } from '../../utils/is-dev.js';
7
+ import { composeRefs } from '../../utils/compose-refs.js';
8
+ import { useLoadingAnnouncer } from '../../utils/use-loading-announcer.js';
9
+ import { defaultIconButtonLabels } from './types.js';
7
10
  // =============================================================================
8
11
  // IconButtonCore (@internal)
9
12
  // =============================================================================
@@ -27,7 +30,7 @@ import { isDev } from '../../utils/is-dev.js';
27
30
  //
28
31
  // =============================================================================
29
32
  export const IconButtonCore = forwardRef((props, ref) => {
30
- const { icon, label, size = 'sm', theme = 'secondary', variant = 'ghost', disabled = false, loading = false, loadingLabel: loadingLabelProp, pressed, shape = 'square', className, ...restWithStray } = props;
33
+ const { icon, label, size = 'sm', theme = 'secondary', variant = 'ghost', disabled = false, loading = false, loadingLabel: loadingLabelProp, labels: labelsProp, pressed, shape = 'square', className, ...restWithStray } = props;
31
34
  const stray = restWithStray;
32
35
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
36
  const { showTooltip: strayShowTooltip, tooltipSide: _tooltipSide, ...rest } = stray;
@@ -42,6 +45,11 @@ export const IconButtonCore = forwardRef((props, ref) => {
42
45
  // native `disabled` or a dropped href. Only explicit `disabled` goes native.
43
46
  const loadingOnly = loading && !disabled;
44
47
  const resolvedLabel = loading ? (loadingLabelProp ?? `${label}, loading`) : label;
48
+ const labels = { ...defaultIconButtonLabels, ...labelsProp };
49
+ // Opt-in loading announcements (#131): portaled, so no DOM sibling.
50
+ const elementRef = useRef(null);
51
+ const announcer = useLoadingAnnouncer(elementRef, loading, labels.loadingStart, labels.loadingEnd);
52
+ const mergedRef = useMemo(() => composeRefs(ref, elementRef), [ref]);
45
53
  const classes = cx('tui-icon-button', `is-size-${size}`, `is-theme-${theme}`, `is-style-${variant}`, isDisabled && 'is-disabled', shape === 'circle' && 'is-shape-circle', className);
46
54
  const iconContent = (_jsxs(_Fragment, { children: [_jsx(Icon, { name: icon }), loading && _jsx("span", { className: "tui-icon-button__spinner", "aria-hidden": "true" })] }));
47
55
  // Render the base element (button or anchor)
@@ -57,7 +65,7 @@ export const IconButtonCore = forwardRef((props, ref) => {
57
65
  }
58
66
  onClick?.(e);
59
67
  };
60
- element = (_jsx("a", { ref: ref, href: disabled ? undefined : href, className: classes, "aria-label": resolvedLabel, "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, tabIndex: disabled ? -1 : tabIndex, onClick: handleClick, target: target, rel: safeRel, ...anchorRest, children: iconContent }));
68
+ element = (_jsx("a", { ref: mergedRef, href: disabled ? undefined : href, className: classes, "aria-label": resolvedLabel, "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, "data-loading": loading || undefined, tabIndex: disabled ? -1 : tabIndex, onClick: handleClick, target: target, rel: safeRel, ...anchorRest, children: iconContent }));
61
69
  }
62
70
  else {
63
71
  const { onClick, ...buttonRest } = rest;
@@ -69,8 +77,8 @@ export const IconButtonCore = forwardRef((props, ref) => {
69
77
  }
70
78
  onClick?.(e);
71
79
  };
72
- element = (_jsx("button", { ref: ref, type: buttonRest.type ?? 'button', className: classes, "aria-label": resolvedLabel, disabled: disabled, "aria-disabled": loadingOnly || undefined, "aria-busy": loading || undefined, "aria-pressed": pressed, onClick: handleButtonClick, ...buttonRest, children: iconContent }));
80
+ element = (_jsx("button", { ref: mergedRef, type: buttonRest.type ?? 'button', className: classes, "aria-label": resolvedLabel, disabled: disabled, "aria-disabled": loadingOnly || undefined, "aria-busy": loading || undefined, "data-loading": loading || undefined, "aria-pressed": pressed, onClick: handleButtonClick, ...buttonRest, children: iconContent }));
73
81
  }
74
- return element;
82
+ return (_jsxs(_Fragment, { children: [element, announcer] }));
75
83
  });
76
84
  IconButtonCore.displayName = 'IconButtonCore';
@@ -1,2 +1,3 @@
1
1
  export { IconButton } from './IconButton';
2
- export type { IconButtonProps, Shape, Size, Theme, Variant } from './types';
2
+ export type { IconButtonProps, IconButtonLabels, Shape, Size, Theme, Variant } from './types';
3
+ export { defaultIconButtonLabels } from './types';
@@ -1 +1,2 @@
1
1
  export { IconButton } from './IconButton.js';
2
+ export { defaultIconButtonLabels } from './types.js';
@@ -4,6 +4,20 @@ export type { Size };
4
4
  export type Theme = ThemeIntent | ThemeStatus;
5
5
  export type Variant = 'solid' | 'outline' | 'ghost';
6
6
  export type Shape = 'square' | 'circle';
7
+ export type IconButtonLabels = {
8
+ /**
9
+ * Spoken politely when `loading` turns on, e.g. "Saving…". Setting this
10
+ * or `loadingEnd` opts the button into loading announcements (#131).
11
+ * @default '' (not announced)
12
+ */
13
+ loadingStart?: string;
14
+ /**
15
+ * Spoken politely when `loading` turns off, e.g. "Saved".
16
+ * @default '' (not announced)
17
+ */
18
+ loadingEnd?: string;
19
+ };
20
+ export declare const defaultIconButtonLabels: Required<IconButtonLabels>;
7
21
  type IconButtonBaseProps = {
8
22
  /**
9
23
  * Icon to display: a registry path or an icon component. Required — this is
@@ -55,8 +69,23 @@ type IconButtonBaseProps = {
55
69
  * button focusable (`aria-disabled`, not native `disabled`), so a
56
70
  * keyboard user who triggered it keeps their place. Only `onClick` is
57
71
  * guarded: put the action there, not in `onKeyDown`/`onPointerDown`.
58
- * The start and end of loading aren't announced; confirm completion
59
- * through your own status message (a Toast, say).
72
+ *
73
+ * By default the start and end of loading aren't announced: the busy
74
+ * name ("Save, loading") is set on the focused button, which screen
75
+ * readers rarely re-read, and it reverts silently. Opt in with
76
+ * `labels={{ loadingStart: 'Saving…', loadingEnd: 'Saved' }}` to speak
77
+ * each transition through a pre-mounted polite live region (portaled, so
78
+ * it never becomes a DOM sibling of the button). If the button unmounts
79
+ * when the action completes, the end can't be spoken from here: confirm
80
+ * through your own status message (a Toast).
81
+ *
82
+ * With `loadingStart`, don't set `aria-busy` on an ancestor of the
83
+ * button: NVDA and Chromium hold live-region output under a busy ancestor.
84
+ * Test with a screen reader: some also re-read the busy name ("Save,
85
+ * loading"), which can double up with `loadingStart`.
86
+ *
87
+ * While loading, the button stays focusable, so it mutes its colors rather
88
+ * than dimming the whole element: the focus ring keeps full contrast.
60
89
  */
61
90
  loading?: boolean;
62
91
  /**
@@ -64,6 +93,12 @@ type IconButtonBaseProps = {
64
93
  * @default `${label}, loading` (English)
65
94
  */
66
95
  loadingLabel?: string;
96
+ /**
97
+ * Override default strings for i18n, and opt in to loading announcements
98
+ * (`loadingStart` / `loadingEnd`, empty by default). The button's name is
99
+ * `label`; the busy name is `loadingLabel`.
100
+ */
101
+ labels?: IconButtonLabels;
67
102
  /**
68
103
  * Pressed state for toggle buttons.
69
104
  * When true, applies aria-pressed="true" and active styling.
@@ -1 +1,4 @@
1
- export {};
1
+ export const defaultIconButtonLabels = {
2
+ loadingStart: '',
3
+ loadingEnd: '',
4
+ };
@@ -366,10 +366,16 @@ function MultiSelectTriggerComponent({ asChild = false, className, children, })
366
366
  // No size prop: token-field chips size em-relative to the host control
367
367
  // (0.875em in styles.scss), which outranks Chip's font-size presets — a
368
368
  // size here would be dead code that reads as if it did something.
369
- return (_jsxs("span", { className: "tui-multiselect__chips", children: [visibleChips.map((opt) => (_jsx(Chip, { className: "tui-multiselect__chip", children: opt.textValue }, toKey(opt.value)))), overflow > 0 && (_jsx("span", { className: "tui-multiselect__more", children: labels.more(overflow) }))] }));
369
+ // The literal ' ' text nodes keep the chips apart in the trigger's
370
+ // accessible name ("Country Canada Mexico", not "CanadaMexico" — this span
371
+ // is referenced from aria-labelledby, #89). The container is flex, and a
372
+ // flex container does not render whitespace-only text, so layout is
373
+ // untouched; same technique as NavMenu's slots.
374
+ return (_jsxs("span", { className: "tui-multiselect__chips", children: [visibleChips.map((opt, i) => (_jsxs(React.Fragment, { children: [i > 0 && ' ', _jsx(Chip, { className: "tui-multiselect__chip", children: opt.textValue })] }, toKey(opt.value)))), overflow > 0 && (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "tui-multiselect__more", children: labels.more(overflow) })] }))] }));
370
375
  };
371
376
  // Default trigger content (when not using asChild or custom children)
372
- const defaultTriggerContent = (_jsxs(_Fragment, { children: [_jsx("span", { className: "tui-multiselect__value", children: renderTriggerContent() }), hasSelection && (_jsx("span", { className: "tui-multiselect__clear", onClick: handleClearClick, "aria-hidden": "true", children: _jsx(Icon, { name: CloseIcon }) })), _jsx(Icon, { name: ChevronDownIcon, className: "tui-multiselect__icon", "aria-hidden": "true" })] }));
377
+ const valueId = `${triggerId}-value`;
378
+ const defaultTriggerContent = (_jsxs(_Fragment, { children: [_jsx("span", { id: valueId, className: "tui-multiselect__value", children: renderTriggerContent() }), hasSelection && (_jsx("span", { className: "tui-multiselect__clear", onClick: handleClearClick, "aria-hidden": "true", children: _jsx(Icon, { name: CloseIcon }) })), _jsx(Icon, { name: ChevronDownIcon, className: "tui-multiselect__icon", "aria-hidden": "true" })] }));
373
379
  // Generate status message for screen readers
374
380
  const statusMessage = labels.status(selectedOptions.length, max);
375
381
  // Live region (rendered outside button, sibling to trigger)
@@ -461,7 +467,7 @@ function MultiSelectTriggerComponent({ asChild = false, className, children, })
461
467
  }
462
468
  // Default: render button with optional custom content
463
469
  const triggerContent = children ?? defaultTriggerContent;
464
- return (_jsxs(_Fragment, { children: [_jsx("button", { ref: refs.setReference, type: "button", id: triggerId, className: cx('tui-input-group', 'tui-multiselect__trigger', sizeClass, className), disabled: disabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "data-state": open ? 'open' : 'closed', ...floatingProps,
470
+ return (_jsxs(_Fragment, { children: [_jsx("button", { ref: refs.setReference, type: "button", id: triggerId, className: cx('tui-input-group', 'tui-multiselect__trigger', sizeClass, className), disabled: disabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy && children == null ? `${ariaLabelledBy} ${valueId}` : ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "data-state": open ? 'open' : 'closed', ...floatingProps,
465
471
  // Handle Backspace/Delete AFTER floatingProps to ensure we catch it
466
472
  // (typeahead may intercept these for its buffer)
467
473
  onKeyDown: (e) => {
@@ -22,8 +22,10 @@ const INTERACTIVE = [
22
22
  const PRIMED_WINDOW = 400;
23
23
  // Grace period for crossing into the panel.
24
24
  const HOVER_CLOSE_DELAY = 300;
25
- // Items render <li>, so they're only valid inside a Group or Sub list. The
26
- // context exists to warn when one isn't.
25
+ // Items render <li>, so they're only valid inside a list: a Group's, a Sub's,
26
+ // or the implicit one the root wraps loose items in. The context exists to
27
+ // warn when an Item still lands outside one (a consumer component wrapping
28
+ // NavMenu.Item, which the root can't see through).
27
29
  const ListContext = createContext(false);
28
30
  const RootContext = createContext({
29
31
  orientation: 'vertical',
@@ -54,8 +56,40 @@ const NavMenuRoot = forwardRef(function NavMenu({ orientation = 'vertical', flyo
54
56
  // One warmth group per bar, created once (useState's lazy init).
55
57
  const [warmth] = useState(createHoverWarmth);
56
58
  const value = useMemo(() => ({ orientation, flyoutTrigger, labels: { ...defaultNavMenuLabels, ...labels }, openId, setOpenId, rootRef, warmth }), [orientation, flyoutTrigger, labels, openId, warmth]);
57
- return (_jsx("div", { ref: composeRefs(ref, rootRef), ...rest, "data-orientation": orientation, className: cx('tui-nav-menu', orientation === 'horizontal' && 'is-horizontal', className), children: _jsx(RootContext.Provider, { value: value, children: children }) }));
59
+ return (_jsx("div", { ref: composeRefs(ref, rootRef), ...rest, "data-orientation": orientation, className: cx('tui-nav-menu', orientation === 'horizontal' && 'is-horizontal', className), children: _jsx(RootContext.Provider, { value: value, children: wrapLooseItems(children) }) }));
58
60
  });
61
+ /**
62
+ * Items placed straight in the root (no Group) would render <li>s inside a
63
+ * <div>: invalid, and AT loses the list and its item count (#140). Each run
64
+ * of consecutive loose Items goes into an implicit, unlabelled list, the same
65
+ * <ul> an unlabelled Group renders, so a bar of plain links needs no Group.
66
+ * Groups, Subs (already a list) and anything else pass through untouched.
67
+ * Only direct NavMenu.Item elements (and arrays of them) are seen; an Item
68
+ * behind a consumer wrapper or a fragment still warns in dev.
69
+ */
70
+ function wrapLooseItems(children) {
71
+ const out = [];
72
+ let run = [];
73
+ const flush = () => {
74
+ if (run.length === 0)
75
+ return;
76
+ // Keyed by its first item, so a Group added or removed before it doesn't
77
+ // remount the list (and close an open flyout).
78
+ out.push(_jsx("ul", { className: "tui-nav-menu__list", children: _jsx(ListContext.Provider, { value: true, children: run }) }, `loose:${run[0].key}`));
79
+ run = [];
80
+ };
81
+ Children.toArray(children).forEach((child) => {
82
+ if (isValidElement(child) && child.type === NavMenuItem) {
83
+ run.push(child);
84
+ }
85
+ else {
86
+ flush();
87
+ out.push(child);
88
+ }
89
+ });
90
+ flush();
91
+ return out;
92
+ }
59
93
  // =============================================================================
60
94
  // NavMenu.Group
61
95
  // =============================================================================