@tangible/ui 0.2.15 → 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.
@@ -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;
package/figma-tokens.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.15",
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.15",
3
+ "version": "0.2.16",
4
4
  "description": "Tangible Design System",
5
5
  "type": "module",
6
6
  "main": "./components/index.js",
@@ -228,6 +228,48 @@ 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
+
231
273
  ### Replacing a trigger with `asChild`
232
274
 
233
275
  `Select.Trigger`, `Dropdown.Trigger`, `Popover.Trigger`, `Tooltip.Trigger`, `Accordion.Trigger`,
@@ -327,10 +369,17 @@ There are no device icons (monitor / tablet / phone) in any set.
327
369
  `data-testid` pass-through is uneven, and the split is not the one you would guess. These spread
328
370
  rest props onto their primary element: **Button, Card, Checkbox, Chip, ColorPicker, ColorField,
329
371
  `Field`'s slots, GradientPicker, IconButton, Modal, Notice, SearchInput, SearchSelect, Switch,
330
- 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,
331
374
  including several that look like they would take them — Dropdown, Popover, Tooltip, Select,
332
- MultiSelect, Combobox, MultiCombobox, Tabs, Sidebar, Toolbar, Pager, Radio, Rating, Progress,
333
- 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.
334
383
 
335
384
  Typecheck will not save you here: TypeScript exempts **hyphenated** JSX attributes from excess
336
385
  property checking, so `<Select data-testid="x" />` compiles clean against a prop type that has no
package/tui-manifest.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.2.15",
3
- "generated": "2026-08-25T23:43:50.070Z",
2
+ "version": "0.2.16",
3
+ "generated": "2026-08-28T00:03:33.562Z",
4
4
  "components": {
5
5
  "Accordion": {
6
6
  "props": {
@@ -2490,6 +2490,30 @@
2490
2490
  "className": {
2491
2491
  "type": "string",
2492
2492
  "required": false
2493
+ },
2494
+ "style": {
2495
+ "type": "CSSProperties",
2496
+ "required": false
2497
+ },
2498
+ "title": {
2499
+ "type": "string",
2500
+ "required": false
2501
+ },
2502
+ "id": {
2503
+ "type": "string",
2504
+ "required": false
2505
+ },
2506
+ "rel": {
2507
+ "type": "string",
2508
+ "required": false
2509
+ },
2510
+ "onChange": {
2511
+ "type": "FormEventHandler<HTMLDivElement>",
2512
+ "required": false
2513
+ },
2514
+ "onClick": {
2515
+ "type": "MouseEventHandler<HTMLDivElement>",
2516
+ "required": false
2493
2517
  }
2494
2518
  },
2495
2519
  "cssTokens": [