@tangible/ui 0.2.14 → 0.2.16

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.
@@ -10,6 +10,7 @@ import { IconButton } from '../IconButton/index.js';
10
10
  const isBrowser = typeof document !== 'undefined';
11
11
  function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, initialFocusSelector, container, showCloseButton, closeLabel = 'Close', closeOnBackdropClick = true, closeOnEscape = true, preventScrollOnRestore = false, className, children, ...rest }) {
12
12
  const dialogRef = useRef(null);
13
+ const anchorRef = useRef(null);
13
14
  const restoreRef = useRef(null);
14
15
  const warnedRef = useRef(false);
15
16
  const warnedAriaLabelRef = useRef(false);
@@ -32,24 +33,58 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
32
33
  'to provide an accessible name (WCAG 4.1.2).');
33
34
  }
34
35
  }, [open, labelledBy]);
35
- // Capture trigger element and compute portal mount point when modal opens.
36
+ // Compute portal mount point and capture the focus-restore target on open.
36
37
  // Uses useLayoutEffect to run before paint — both renders complete before
37
38
  // the browser shows anything, so no visible delay.
38
39
  //
39
- // NOTE: This assumes document.activeElement is the trigger at open time.
40
- // True for click/keyboard handlers. For programmatic opens (timers, effects),
41
- // the captured element may not be meaningful — focus restore still works,
42
- // portal scoping may fall back to global interface.
40
+ // Portal scoping resolves from `anchorRef` — a throwaway span rendered at the
41
+ // Modal's own position in the tree (see the first-render branch below) — NOT
42
+ // from document.activeElement. activeElement is not a reliable stand-in for
43
+ // the trigger: Safari/WebKit does not focus a <button> on click, so focus can
44
+ // still be sitting in a hidden, inert tab panel that a click moved away from.
45
+ // Scoping off it portalled the dialog into that hidden subtree, where the
46
+ // focus trap and scroll lock engaged around an invisible modal.
47
+ //
48
+ // Focus restore still reads activeElement (it wants "whatever had focus", and
49
+ // Modal has no reference to the trigger), so on WebKit it can restore to the
50
+ // pre-click element rather than the trigger. Cosmetic by comparison, and it
51
+ // cannot strand the user.
43
52
  useLayoutEffect(() => {
44
53
  if (!open || !isBrowser) {
45
54
  return;
46
55
  }
47
56
  if (mount)
48
57
  return; // Already captured for this open cycle
49
- const trigger = document.activeElement;
50
- restoreRef.current = trigger;
51
- setMount(container ?? getPortalRootFor(trigger));
58
+ restoreRef.current = document.activeElement;
59
+ setMount(container ?? getPortalRootFor(anchorRef.current));
52
60
  }, [open, container, mount]);
61
+ // Dev warning: a mount buried in a hidden/inert subtree renders an invisible
62
+ // modal with a live focus trap — the exact failure the anchor fix removes,
63
+ // now only reachable by rendering <Modal> inside a hidden panel yourself.
64
+ useEffect(() => {
65
+ if (!isDev() || !open || !mount)
66
+ return;
67
+ let node = mount;
68
+ let buried = null;
69
+ while (node && node !== document.body) {
70
+ const el = node;
71
+ if (el.hasAttribute('hidden') || el.hasAttribute('inert')) {
72
+ buried = el;
73
+ break;
74
+ }
75
+ if (isBrowser && getComputedStyle(el).display === 'none') {
76
+ buried = el;
77
+ break;
78
+ }
79
+ node = el.parentElement;
80
+ }
81
+ if (buried) {
82
+ console.warn('[TUI Modal] Portal target is inside a hidden or inert subtree, so the dialog ' +
83
+ 'will not be visible while its focus trap and scroll lock are active. The mount ' +
84
+ 'point is resolved from where <Modal> sits in the tree — move it out of the ' +
85
+ 'hidden container, or pass an explicit `container`.', buried);
86
+ }
87
+ }, [open, mount]);
53
88
  // Reset state when modal closes, restore focus to trigger.
54
89
  useEffect(() => {
55
90
  if (open)
@@ -139,8 +174,13 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
139
174
  }, [open, mount, initialFocusSelector, labelledBy]);
140
175
  // Memoize context value to prevent unnecessary re-renders
141
176
  const contextValue = useMemo(() => ({ onClose }), [onClose]);
142
- if (!open || !mount)
177
+ if (!open)
143
178
  return null;
179
+ // First render of an open cycle: nothing but an in-tree anchor, so the layout
180
+ // effect above can resolve the portal root from the Modal's own DOM position.
181
+ // Unmounts on the very next render (pre-paint), so it never lays anything out.
182
+ if (!mount)
183
+ return _jsx("span", { ref: anchorRef, hidden: true });
144
184
  return createPortal(_jsx(ModalContext.Provider, { value: contextValue, children: _jsxs("div", { className: "tui-modal", "data-state": "open", style: { pointerEvents: 'auto' }, children: [_jsx("div", { className: "tui-modal__backdrop", "aria-hidden": "true", onClick: closeOnBackdropClick ? onClose : undefined }), _jsxs("div", { ref: dialogRef, role: "dialog", "aria-modal": "true", "aria-labelledby": labelledBy, "aria-describedby": describedBy, className: cx('tui-modal__dialog', `is-size-${size}`, stickyHead && 'is-sticky-head', stickyFoot && 'is-sticky-foot', className), tabIndex: -1, ...rest, children: [showCloseButton && (_jsx(IconButton, { icon: "system/close", label: closeLabel, variant: "ghost", size: "sm", onClick: onClose, className: "tui-modal__close", showTooltip: true })), children] })] }) }), mount);
145
185
  }
146
186
  function ModalClose({ label = 'Close', className }) {
@@ -87,8 +87,21 @@ function PopoverTriggerComponent({ asChild = false, children }) {
87
87
  'data-popover-open': open || undefined,
88
88
  };
89
89
  if (asChild && isValidElement(children)) {
90
+ // Compose, don't clobber: an asChild trigger that brings its own onClick
91
+ // (an IconButton with an analytics call, a picker's own handler) used to
92
+ // lose it silently to the spread below. The child runs first, and opts out
93
+ // of toggling the popover by calling preventDefault — same contract as
94
+ // Select.Trigger's composed handlers.
95
+ const childOnClick = children.props.onClick;
90
96
  return cloneElement(children, {
91
97
  ...triggerProps,
98
+ onClick: childOnClick
99
+ ? (e) => {
100
+ childOnClick(e);
101
+ if (!e.defaultPrevented)
102
+ handleClick();
103
+ }
104
+ : handleClick,
92
105
  ref: setRefs,
93
106
  });
94
107
  }
@@ -1,6 +1,14 @@
1
- import type { RadioProps } from './types';
2
1
  /**
3
2
  * Ref targets the inner `<button role="radio">`, not the outer wrapper `<div>`.
4
3
  * This is intentional — roving tabindex and focus management operate on the button.
5
4
  */
6
- export declare const Radio: import("react").ForwardRefExoticComponent<RadioProps & import("react").RefAttributes<HTMLButtonElement>>;
5
+ export declare const Radio: import("react").ForwardRefExoticComponent<{
6
+ value: import("..").MultiSelectOptionValue;
7
+ label?: import("react").ReactNode;
8
+ description?: string;
9
+ disabled?: boolean;
10
+ 'aria-label'?: string;
11
+ 'aria-labelledby'?: string;
12
+ className?: string;
13
+ children?: import("react").ReactNode;
14
+ } & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "hidden" | "className" | "role" | "aria-hidden" | "children" | "aria-label" | "tabIndex" | "aria-labelledby" | "inert"> & import("react").RefAttributes<HTMLButtonElement>>;
@@ -18,7 +18,7 @@ import { useRadioGroupContext } from './RadioGroupContext.js';
18
18
  * Ref targets the inner `<button role="radio">`, not the outer wrapper `<div>`.
19
19
  * This is intentional — roving tabindex and focus management operate on the button.
20
20
  */
21
- export const Radio = forwardRef(function Radio({ value, label, description, disabled = false, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className, children, }, externalRef) {
21
+ export const Radio = forwardRef(function Radio({ value, label, description, disabled = false, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className, children, ...rest }, externalRef) {
22
22
  const { selectedValue, focusableValue, rootDisabled, registerItem, unregisterItem, onSelect, } = useRadioGroupContext();
23
23
  const id = useId();
24
24
  const descriptionId = `${id}-desc`;
@@ -52,7 +52,7 @@ export const Radio = forwardRef(function Radio({ value, label, description, disa
52
52
  onSelect(value);
53
53
  };
54
54
  const hasExpandedContent = !!(description || children);
55
- return (_jsxs("div", { className: cx('tui-radio', hasExpandedContent && 'has-content', className), children: [_jsxs("button", { ref: composeRefs(callbackRef, externalRef), type: "button", role: "radio", className: "tui-radio__control", "aria-checked": isSelected, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": description ? descriptionId : undefined,
55
+ return (_jsxs("div", { ...rest, "aria-hidden": undefined, className: cx('tui-radio', hasExpandedContent && 'has-content', className), "data-value": value, "data-state": isSelected ? 'active' : 'inactive', "data-disabled": isDisabled || undefined, children: [_jsxs("button", { ref: composeRefs(callbackRef, externalRef), type: "button", role: "radio", className: "tui-radio__control", "aria-checked": isSelected, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": description ? descriptionId : undefined,
56
56
  // Item-level disabled: native disabled (removes from focus cycle).
57
57
  // Group-level disabled: aria-disabled (preserves AT group context).
58
58
  disabled: disabled || undefined, "aria-disabled": rootDisabled || undefined, tabIndex: isFocusable ? 0 : -1, onClick: handleClick, children: [_jsx("span", { className: "tui-radio__indicator", "aria-hidden": "true" }), label && _jsx("span", { className: "tui-radio__label", children: label })] }), hasExpandedContent && (_jsxs("div", { className: "tui-radio__body", children: [description && (_jsx("p", { id: descriptionId, className: "tui-radio__description", children: description })), children] }))] }));
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import type { ComponentPropsWithoutRef, ReactNode } from 'react';
2
2
  import type { OptionValue } from '../../utils/value-key';
3
3
  import type { RovingItemRecord } from '../../utils/use-roving-group';
4
4
  export type RadioGroupProps = {
@@ -28,7 +28,7 @@ export type RadioProps = {
28
28
  'aria-labelledby'?: string;
29
29
  className?: string;
30
30
  children?: ReactNode;
31
- };
31
+ } & Omit<ComponentPropsWithoutRef<'div'>, 'className' | 'children' | 'aria-label' | 'aria-labelledby' | 'role' | 'tabIndex' | 'aria-hidden' | 'inert' | 'hidden'>;
32
32
  export type RadioItemRecord = RovingItemRecord;
33
33
  export type RadioGroupContextValue = {
34
34
  selectedValue: OptionValue | undefined;
@@ -5,6 +5,6 @@ type SegmentedControlCompound = {
5
5
  displayName?: string;
6
6
  Item: typeof Item;
7
7
  };
8
- declare function Item({ value, disabled, icon, 'aria-label': ariaLabel, className, children, }: SegmentedControlItemProps): import("react/jsx-runtime").JSX.Element;
8
+ declare function Item({ value, disabled, icon, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className, children, ...rest }: SegmentedControlItemProps): import("react/jsx-runtime").JSX.Element;
9
9
  export declare const SegmentedControl: SegmentedControlCompound;
10
10
  export {};
@@ -66,7 +66,7 @@ function SegmentedControlRoot({ value: controlledValue, defaultValue, onValueCha
66
66
  // =============================================================================
67
67
  // SegmentedControl.Item
68
68
  // =============================================================================
69
- function Item({ value, disabled = false, icon, 'aria-label': ariaLabel, className, children, }) {
69
+ function Item({ value, disabled = false, icon, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className, children, ...rest }) {
70
70
  const { selectedValue, focusableValue, rootDisabled, registerItem, unregisterItem, onSelect, } = useSegmentedControlContext();
71
71
  const isSelected = selectedValue !== undefined && toKey(selectedValue) === toKey(value);
72
72
  const isDisabled = rootDisabled || disabled;
@@ -90,7 +90,7 @@ function Item({ value, disabled = false, icon, 'aria-label': ariaLabel, classNam
90
90
  };
91
91
  const hasIcon = icon !== undefined && icon !== null;
92
92
  const hasChildren = children !== undefined && children !== null;
93
- return (_jsxs("button", { ref: callbackRef, type: "button", role: "radio", className: cx('tui-segmented__item', className), "aria-checked": isSelected, "aria-disabled": isDisabled || undefined, "aria-label": ariaLabel, tabIndex: isDisabled ? -1 : isFocusable ? 0 : -1, onClick: handleClick, children: [hasIcon && _jsx("span", { className: "tui-segmented__item-icon", children: icon }), hasChildren && _jsx("span", { className: "tui-segmented__item-label", children: children })] }));
93
+ return (_jsxs("button", { ...rest, "aria-hidden": undefined, ref: callbackRef, type: "button", role: "radio", className: cx('tui-segmented__item', className), "data-value": value, "data-state": isSelected ? 'active' : 'inactive', "data-disabled": isDisabled || undefined, "aria-checked": isSelected, "aria-disabled": isDisabled || undefined, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, tabIndex: isDisabled ? -1 : isFocusable ? 0 : -1, onClick: handleClick, children: [hasIcon && _jsx("span", { className: "tui-segmented__item-icon", children: icon }), hasChildren && _jsx("span", { className: "tui-segmented__item-label", children: children })] }));
94
94
  }
95
95
  // =============================================================================
96
96
  // Compound Component Export
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import type { ComponentPropsWithoutRef, ReactNode } from 'react';
2
2
  import type { RovingItemRecord } from '../../utils/use-roving-group';
3
3
  import type { Size } from '../../types/sizes';
4
4
  export type SegmentedControlValue = string | number;
@@ -50,11 +50,21 @@ export type SegmentedControlItemProps = {
50
50
  icon?: ReactNode;
51
51
  /** Accessible label — required for icon-only items */
52
52
  'aria-label'?: string;
53
+ /**
54
+ * Accessible name by reference. Modelled explicitly, like `aria-label`
55
+ * above and like the group root already does — otherwise it rides
56
+ * `...rest` and its ordering relative to the group's own attributes is
57
+ * incidental. Forwarding is deliberate: it is a legitimate way to name an
58
+ * item from visible text elsewhere. It does OUTRANK the item's own label
59
+ * (AccName 2A), and an id that resolves to nothing empties the name
60
+ * entirely (step 2B) — so point it at an element that exists.
61
+ */
62
+ 'aria-labelledby'?: string;
53
63
  /** Additional classes */
54
64
  className?: string;
55
65
  /** Label content */
56
66
  children?: ReactNode;
57
- };
67
+ } & Omit<ComponentPropsWithoutRef<'button'>, 'value' | 'type' | 'role' | 'aria-checked' | 'aria-disabled' | 'tabIndex' | 'onClick' | 'disabled' | 'aria-label' | 'aria-labelledby' | 'className' | 'children' | 'aria-hidden' | 'inert' | 'hidden'>;
58
68
  export type ItemRecord = RovingItemRecord;
59
69
  export type SegmentedControlContextValue = {
60
70
  variant: SegmentedControlVariant;
@@ -11,7 +11,7 @@ declare function TabsList({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabe
11
11
  declare namespace TabsList {
12
12
  var displayName: string;
13
13
  }
14
- declare function Tab({ value, icon, 'aria-label': ariaLabel, disabled, className, children }: TabProps): import("react/jsx-runtime").JSX.Element;
14
+ declare function Tab({ value, icon, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, disabled, className, children, ...rest }: TabProps): import("react/jsx-runtime").JSX.Element;
15
15
  declare namespace Tab {
16
16
  var displayName: string;
17
17
  }
@@ -259,7 +259,7 @@ function TabsList({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy,
259
259
  // =============================================================================
260
260
  // Tabs.Tab
261
261
  // =============================================================================
262
- function Tab({ value, icon, 'aria-label': ariaLabel, disabled = false, className, children }) {
262
+ function Tab({ value, icon, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, disabled = false, className, children, ...rest }) {
263
263
  const { activationMode, activeValue, focusedValue, registerTab, unregisterTab, onSelect, getTabId, getPanelId, } = useTabsContext();
264
264
  const tabId = getTabId(value);
265
265
  const panelId = getPanelId(value);
@@ -299,7 +299,7 @@ function Tab({ value, icon, 'aria-label': ariaLabel, disabled = false, className
299
299
  onSelect(value);
300
300
  }
301
301
  };
302
- return (_jsxs("button", { ref: callbackRef, type: "button", role: "tab", id: tabId, className: cx('tui-tabs__tab', className), "data-tui-tab-value": value, "data-state": isActive ? 'active' : 'inactive', "aria-selected": isActive, "aria-controls": panelId, "aria-label": ariaLabel, "aria-disabled": disabled || undefined, tabIndex: disabled ? -1 : isFocusable ? 0 : -1, "data-disabled": disabled || undefined, onClick: handleClick, children: [icon && _jsx(Icon, { name: icon, "aria-hidden": "true" }), children && _jsx("span", { className: "tui-tabs__tab-label", children: children })] }));
302
+ return (_jsxs("button", { ...rest, "aria-hidden": undefined, ref: callbackRef, type: "button", role: "tab", id: tabId, className: cx('tui-tabs__tab', className), "data-tui-tab-value": value, "data-value": value, "data-state": isActive ? 'active' : 'inactive', "aria-selected": isActive, "aria-controls": panelId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-disabled": disabled || undefined, tabIndex: disabled ? -1 : isFocusable ? 0 : -1, "data-disabled": disabled || undefined, onClick: handleClick, children: [icon && _jsx(Icon, { name: icon, "aria-hidden": "true" }), children && _jsx("span", { className: "tui-tabs__tab-label", children: children })] }));
303
303
  }
304
304
  // =============================================================================
305
305
  // Tabs.Panel
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import type { ComponentPropsWithoutRef, ReactNode } from 'react';
2
2
  import type { IconName } from '../../icons/registry';
3
3
  export type TabsVariant = 'pill' | 'underline' | 'outline';
4
4
  export type TabsActivationMode = 'auto' | 'manual';
@@ -48,12 +48,22 @@ export type TabProps = {
48
48
  * without an accessible name, making it invisible to screen readers.
49
49
  */
50
50
  'aria-label'?: string;
51
+ /**
52
+ * Accessible name by reference. Modelled explicitly, like `aria-label`
53
+ * above and like the group root already does — otherwise it rides
54
+ * `...rest` and its ordering relative to the group's own attributes is
55
+ * incidental. Forwarding is deliberate: it is a legitimate way to name an
56
+ * item from visible text elsewhere. It does OUTRANK the item's own label
57
+ * (AccName 2A), and an id that resolves to nothing empties the name
58
+ * entirely (step 2B) — so point it at an element that exists.
59
+ */
60
+ 'aria-labelledby'?: string;
51
61
  /** Disable tab (skipped in keyboard nav) */
52
62
  disabled?: boolean;
53
63
  /** Additional classes */
54
64
  className?: string;
55
65
  children?: ReactNode;
56
- };
66
+ } & Omit<ComponentPropsWithoutRef<'button'>, 'value' | 'type' | 'role' | 'id' | 'aria-selected' | 'aria-controls' | 'aria-disabled' | 'tabIndex' | 'onClick' | 'disabled' | 'aria-label' | 'aria-labelledby' | 'className' | 'children' | 'aria-hidden' | 'inert' | 'hidden'>;
57
67
  export type TabPanelProps = {
58
68
  /** Must match a Tab value */
59
69
  value: string;
@@ -12,7 +12,7 @@ export { Chips } from './Chips';
12
12
  export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker';
13
13
  export { GradientPicker, GradientBar, defaultGradientPickerLabels } from './GradientPicker';
14
14
  export { ContentIndicator } from './ContentIndicator';
15
- export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker';
15
+ export { Calendar, DatePicker, DatePickerTrigger, DateRangePicker, DateRangePickerTrigger, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker';
16
16
  export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox';
17
17
  export { MultiCombobox, MultiComboboxContent, MultiComboboxOption, MultiComboboxGroup, MultiComboboxLabel, useMultiCombobox } from './MultiCombobox';
18
18
  export { Dropdown, DropdownTrigger, DropdownContent, DropdownItem, DropdownSeparator, DropdownHeader, useDropdown } from './Dropdown';
@@ -10,7 +10,7 @@ export { Chips } from './Chips/index.js';
10
10
  export { ColorPicker, ColorField, ColorArea, ColorSlider, defaultColorPickerLabels } from './ColorPicker/index.js';
11
11
  export { GradientPicker, GradientBar, defaultGradientPickerLabels } from './GradientPicker/index.js';
12
12
  export { ContentIndicator } from './ContentIndicator/index.js';
13
- export { Calendar, DatePicker, DateRangePicker, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker/index.js';
13
+ export { Calendar, DatePicker, DatePickerTrigger, DateRangePicker, DateRangePickerTrigger, defaultDateRangePresets, defaultCalendarLabels, defaultDatePickerLabels, defaultDateRangePickerLabels, } from './DatePicker/index.js';
14
14
  export { Combobox, ComboboxContent, ComboboxOption, ComboboxGroup, ComboboxLabel, useCombobox } from './Combobox/index.js';
15
15
  export { MultiCombobox, MultiComboboxContent, MultiComboboxOption, MultiComboboxGroup, MultiComboboxLabel, useMultiCombobox } from './MultiCombobox/index.js';
16
16
  export { Dropdown, DropdownTrigger, DropdownContent, DropdownItem, DropdownSeparator, DropdownHeader, useDropdown } from './Dropdown/index.js';
package/figma-tokens.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.14",
2
+ "version": "0.2.16",
3
3
  "source": "publish/styles/all.expanded.css",
4
4
  "prefix": "tui-",
5
5
  "note": "Layer 1 primitives only. Component API tokens (--tui-{component}-*) are never defined in CSS — they exist only as fallback reads — so they have no Figma representation.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangible/ui",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "Tangible Design System",
5
5
  "type": "module",
6
6
  "main": "./components/index.js",
@@ -228,13 +228,119 @@ Useful primitives:
228
228
  `className` is for layout integration (margin, grid placement), not appearance. Beyond the token
229
229
  API the sanctioned escape hatch is to **swizzle** — copy the component source and own the fork.
230
230
 
231
+ ### Styling one member of a group
232
+
233
+ Selection components expose their state as attributes, so you can style a *particular* option
234
+ without threading a `className` through every item. `SegmentedControl.Item`, `Tabs.Tab` and `Radio`
235
+ carry `data-value` (the item's own value) and `data-state` (`active` / `inactive`), plus
236
+ `data-disabled` when disabled; `data-state` is the same vocabulary Accordion, Modal, Sidebar and
237
+ DataTable already use.
238
+
239
+ ```css
240
+ /* Grading control: failing red, passing green — only when chosen. */
241
+ .tui-segmented__item[data-value='fail'] {
242
+ --tui-segmented-item-bg-active: var(--tui-theme-danger-subtlest);
243
+ --tui-segmented-item-fg-active: var(--tui-theme-danger-stronger);
244
+ }
245
+ .tui-segmented__item[data-value='pass'] {
246
+ --tui-segmented-item-bg-active: var(--tui-theme-success-subtlest);
247
+ --tui-segmented-item-fg-active: var(--tui-theme-success-stronger);
248
+ }
249
+ ```
250
+
251
+ Reach for the component's own tokens inside the rule, as above, rather than setting `background`
252
+ directly — that keeps the hover and focus treatments the component already derives. Note that
253
+ `--tui-segmented-item-bg-active` only applies when the item *is* active, so the selector above does
254
+ not need `[data-state='active']` as well; add it when the property you are setting is not already
255
+ state-scoped. Token names come from `tui-manifest.json` → `cssTokens`.
256
+
257
+ **Recolour the foreground with the background.** The pairing above is `-subtlest` fill with
258
+ `-stronger` text — the two-sided pairing Chip already uses, and both halves move with the theme.
259
+ Setting only the fill to a `-base` tone leaves the default white-on-accent foreground behind, which
260
+ clears 4.5:1 in light mode and then fails it in dark, because the dark ladder lightens: danger drops
261
+ to 3.7:1 and success to 3.4:1. The ladder cannot rescue this on its own — "stronger" means more
262
+ contrast against the *page*, so in dark mode it moves the fill towards the text, not away from it.
263
+
264
+ All three items accept `aria-label` and `aria-labelledby` as declared props, so naming one from
265
+ visible text elsewhere is supported — but `aria-labelledby` **replaces** the item's own label
266
+ rather than adding to it, and an id that matches nothing empties the name completely. Point it at
267
+ an element that exists, and check the name you actually get.
268
+
269
+ `Radio` puts these on the wrapper `<div class="tui-radio">`, so a rule can reach the label and
270
+ description too. `Tabs.Tab` also carries `data-tui-tab-value`; that one is internal (Tabs reads it
271
+ back for focus lookup) — style against `data-value`.
272
+
273
+ ### Replacing a trigger with `asChild`
274
+
275
+ `Select.Trigger`, `Dropdown.Trigger`, `Popover.Trigger`, `Tooltip.Trigger`, `Accordion.Trigger`,
276
+ `MultiSelect.Trigger`, `DatePicker.Trigger` and `DateRangePicker.Trigger` all take `asChild`,
277
+ rendering your element in place of theirs.
278
+
279
+ The two pickers render their trigger automatically when the root has no children, so
280
+ `<DatePicker />` is unchanged. Reach for `DatePicker.Trigger` when you want to place the trigger
281
+ yourself — which is what lets the whole popover (time field, Now, month/day/year, calendar) hang off
282
+ a text field the user can also type into freely:
283
+
284
+ ```tsx
285
+ <DatePicker withTime onChange={(date) => setText(format(date))}>
286
+ <TextInput
287
+ value={text}
288
+ onChange={(e) => setText(e.target.value)}
289
+ suffix={
290
+ <DatePicker.Trigger asChild>
291
+ <IconButton icon="lms/calendar" label="Pick a date" variant="ghost" size="sm" />
292
+ </DatePicker.Trigger>
293
+ }
294
+ />
295
+ </DatePicker>
296
+ ```
297
+
298
+ TUI never writes into the field: `onChange` hands you a `Date` and you decide what string goes in,
299
+ which is why this works with formats TUI knows nothing about ("3pm ET" survives being typed).
300
+ Children with no `Trigger` among them leave the picker unopenable — a dev warning fires.
301
+
302
+ **Size a slot button one tier below the field** (`md` field → `sm` button). Button and IconButton
303
+ anchor to `--tui-control-height-*`, which is the *whole field's* height; TUI cancels the group's
304
+ padding so it no longer inflates the field, but a same-tier button still fills the content box edge
305
+ to edge.
306
+
307
+ Four things change versus a picker's default trigger, all deliberate:
308
+
309
+ - **Your element owns its accessible name**, so name it for the action ("Pick a date"). The default
310
+ trigger appends its value text to the name; `asChild` cannot, because there is no value span —
311
+ and a dangling `aria-labelledby` id would resolve the *entire* name to empty.
312
+ - **No `tui-input-group` chrome** is applied. That is the point (a bare button, not a bordered
313
+ field) and it is where the pickers diverge from `Select.Trigger`, which force-applies the class
314
+ even under `asChild`. It also means `aria-invalid` still lands on your element but paints nothing,
315
+ so an invalid trigger inside a `Field` needs one rule of your own:
316
+
317
+ ```css
318
+ .my-date-trigger[aria-invalid='true'] {
319
+ border-color: var(--tui-theme-danger-base);
320
+ color: var(--tui-theme-danger-base);
321
+ }
322
+ ```
323
+
324
+ Everything else `Field` injects works unchanged — `Field.Label` reaches the accessible name, and
325
+ `Field.Error` is announced via `aria-describedby`.
326
+ - **`disabled` arrives as `aria-disabled` + `data-disabled`**, since your element may not be a
327
+ `<button>`. The popover refuses to open either way, in the open direction only — closing is never
328
+ blocked, so disabling a form mid-submit cannot strand an open popover.
329
+ - **Your element must be natively focusable and keyboard-activatable** — a `<button>` or `<a>`, not
330
+ a styled `<div>`. No key handler is attached under `asChild`; it relies on the child turning
331
+ Enter/Space into a click, which only real interactive elements do.
332
+
333
+ Your child's `onClick` still runs; call `preventDefault()` in it to suppress the toggle.
334
+
231
335
  ## Component names, and what isn't there
232
336
 
233
337
  43 components. If you are hunting for a name: **Alert → `Notice`**, **Menu → `Dropdown`**,
234
338
  **Table → `DataTable`**, **Pagination → `Pager`**, **Drawer → `Sidebar`** (drawer mode),
235
339
  **Badge → `Chip`** or `ContentIndicator`, **Spinner → `Progress`** or `Button loading`.
236
- No Toast/Snackbar, no Breadcrumb, no Skeleton, and no time picker — `DatePicker` and
237
- `DateRangePicker` are dates only.
340
+ No Toast/Snackbar, no Breadcrumb, no Skeleton, and no *standalone* time picker — but
341
+ `DatePicker` / `DateRangePicker` take `withTime` for an hour/minute field (12- or 24-hour via
342
+ `hour12`) plus a display-only `zoneLabel`; the value is a plain `Date` with wall-clock semantics,
343
+ so timezone interpretation stays yours.
238
344
 
239
345
  Two clusters are easy to pick wrong:
240
346
 
@@ -263,10 +369,17 @@ There are no device icons (monitor / tablet / phone) in any set.
263
369
  `data-testid` pass-through is uneven, and the split is not the one you would guess. These spread
264
370
  rest props onto their primary element: **Button, Card, Checkbox, Chip, ColorPicker, ColorField,
265
371
  `Field`'s slots, GradientPicker, IconButton, Modal, Notice, SearchInput, SearchSelect, Switch,
266
- Textarea, TextInput**, and **DataTable** (onto the `<table>`). Everything else drops them silently,
372
+ Textarea, TextInput**, **DataTable** (onto the `<table>`), and — since 0.2.16 — the group members
373
+ **SegmentedControl.Item, Tabs.Tab and Radio**. Everything else drops them silently,
267
374
  including several that look like they would take them — Dropdown, Popover, Tooltip, Select,
268
- MultiSelect, Combobox, MultiCombobox, Tabs, Sidebar, Toolbar, Pager, Radio, Rating, Progress,
269
- Avatar, Icon, Slider, MoveHandle, StepList, SegmentedControl, DatePicker.
375
+ MultiSelect, Combobox, MultiCombobox, Sidebar, Toolbar, Pager, Rating, Progress,
376
+ Avatar, Icon, Slider, MoveHandle, StepList, DatePicker.
377
+
378
+ Two notes on those three. **Radio spreads onto the wrapper `<div class="tui-radio">`, not the
379
+ control its ref targets** — the wrapper is where `className` already goes, and it is the element
380
+ holding the label and description. And on all three the spread is applied *before* the component's
381
+ own attributes, so a forwarded `role` or `aria-checked` cannot desynchronise the group from what it
382
+ announces; the props types omit those, so TypeScript rejects them rather than dropping them.
270
383
 
271
384
  Typecheck will not save you here: TypeScript exempts **hyphenated** JSX attributes from excess
272
385
  property checking, so `<Select data-testid="x" />` compiles clean against a prop type that has no