@mistriwork/ui 1.0.0-rc.18 → 1.0.0-rc.20

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 (2) hide show
  1. package/dist/Dropdown.js +7 -2
  2. package/package.json +1 -1
package/dist/Dropdown.js CHANGED
@@ -15,7 +15,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  * run rather than become the value: the value stays what the caller says
16
16
  * it is, so choosing "re-read the schema" cannot select it.
17
17
  */
18
- import { useEffect, useRef, useState } from 'react';
18
+ import { useEffect, useId, useRef, useState } from 'react';
19
19
  import { Select } from '@base-ui/react/select';
20
20
  import { layoutViewport, zoomAnchor } from './internal/anchor.js';
21
21
  import { popupContainer } from './internal/popups.js';
@@ -31,6 +31,11 @@ export function MultiDropdown(props) {
31
31
  function DropdownList(props) {
32
32
  const { items, ariaLabel, ariaInvalid, ariaDescribedBy, ariaLabelledBy, id, buttonRef, popupRef, onOpenChange, disabled, readOnly, valueClassName, actions = [], buttonClassName, listClassName, valueId, placeholder, } = props;
33
33
  const many = props.multiple === true;
34
+ /* A button named only by `ariaLabel` is named by it and then by the value it shows (WCAG 2.5.3, label in name): its
35
+ own label first, the shown value after, as a field's `labelledby` names it with `valueId`. */
36
+ const own = useId();
37
+ const shownId = useId();
38
+ const buttonId = id ?? own;
34
39
  const chosen = props.multiple === true ? props.value : [props.value];
35
40
  const selected = items.find((i) => i.value === chosen[0]);
36
41
  /* Nothing chosen: a value no item carries (a form's empty answer) reads as no selection, not as a stray one. */
@@ -81,5 +86,5 @@ function DropdownList(props) {
81
86
  }
82
87
  if (next !== props.value)
83
88
  props.onChange(next);
84
- }, children: [_jsxs(Select.Trigger, { render: _jsx("button", { type: "button", role: "button", id: id, className: buttonClassName ? `dd-button ${buttonClassName}` : 'dd-button', ref: setTrigger, "aria-label": ariaLabelledBy ? undefined : ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-invalid": ariaInvalid || undefined, "aria-describedby": ariaDescribedBy, title: selected?.detail ?? '' }), children: [selected?.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: selected.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsx("span", { id: valueId, className: `dd-value${valueClassName ? ` ${valueClassName}` : ''}${said ? '' : ' is-empty'}`, children: said || placeholder || '—' }), _jsx("span", { className: "dd-caret", "aria-hidden": "true", children: "\u25BE" })] }), _jsx(Select.Portal, { container: container ?? popupContainer(), children: _jsx(Select.Positioner, { anchor: () => (trigger.current ? zoomAnchor(trigger.current) : null), alignItemWithTrigger: false, positionMethod: "fixed", side: "bottom", align: "start", sideOffset: 4, collisionBoundary: layoutViewport(), collisionPadding: 8, style: { zIndex: 40 }, children: _jsx(Select.Popup, { ref: popupRef, className: "dd-popup", children: _jsxs(Select.List, { className: ['dd-list', many ? 'dd-list-multi' : '', listClassName].filter(Boolean).join(' '), "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : ariaLabelledBy?.split(' ')[0], children: [items.map((item) => (_jsxs(Select.Item, { value: item.value, label: item.label, disabled: item.disabled, className: (s) => `dd-option${s.selected ? ' selected' : ''}${item.disabled ? ' disabled' : ''}${item.tone ? ` dd-tone-${item.tone}` : ''}${s.highlighted ? ' active' : ''}`, children: [many ? (_jsx("span", { className: "dd-box", "aria-hidden": "true" })) : (_jsx("span", { className: "dd-check", "aria-hidden": "true", children: item.value === props.value ? '✓' : '' })), item.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: item.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsxs("span", { className: "dd-text", children: [_jsx("span", { className: "dd-label", children: item.label }), item.detail && _jsx("span", { className: "dd-detail", children: item.detail })] }), item.badge && _jsx("span", { className: "dd-badge", children: item.badge })] }, item.value))), actions.length ? _jsx("div", { className: "dd-divider", role: "presentation" }) : null, actions.map((action, i) => (_jsxs(Select.Item, { value: `${ACTION}${i}`, label: action.label, className: (s) => `dd-option dd-action${s.highlighted ? ' active' : ''}`, children: [_jsx("span", { className: "dd-check", "aria-hidden": "true" }), _jsx("span", { className: "dd-text", children: _jsx("span", { className: "dd-label", children: action.label }) })] }, action.label)))] }) }) }) })] }) }));
89
+ }, children: [_jsxs(Select.Trigger, { render: _jsx("button", { type: "button", role: "button", id: buttonId, className: buttonClassName ? `dd-button ${buttonClassName}` : 'dd-button', ref: setTrigger, "aria-label": ariaLabelledBy ? undefined : ariaLabel, "aria-labelledby": ariaLabelledBy ?? (ariaLabel ? `${buttonId} ${valueId ?? shownId}` : undefined), "aria-invalid": ariaInvalid || undefined, "aria-describedby": ariaDescribedBy, title: selected?.detail ?? '' }), children: [selected?.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: selected.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsx("span", { id: valueId ?? shownId, className: `dd-value${valueClassName ? ` ${valueClassName}` : ''}${said ? '' : ' is-empty'}`, children: said || placeholder || '—' }), _jsx("span", { className: "dd-caret", "aria-hidden": "true", children: "\u25BE" })] }), _jsx(Select.Portal, { container: container ?? popupContainer(), children: _jsx(Select.Positioner, { anchor: () => (trigger.current ? zoomAnchor(trigger.current) : null), alignItemWithTrigger: false, positionMethod: "fixed", side: "bottom", align: "start", sideOffset: 4, collisionBoundary: layoutViewport(), collisionPadding: 8, style: { zIndex: 40 }, children: _jsx(Select.Popup, { ref: popupRef, className: "dd-popup", children: _jsxs(Select.List, { className: ['dd-list', many ? 'dd-list-multi' : '', listClassName].filter(Boolean).join(' '), "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : ariaLabelledBy?.split(' ')[0], children: [items.map((item) => (_jsxs(Select.Item, { value: item.value, label: item.label, disabled: item.disabled, className: (s) => `dd-option${s.selected ? ' selected' : ''}${item.disabled ? ' disabled' : ''}${item.tone ? ` dd-tone-${item.tone}` : ''}${s.highlighted ? ' active' : ''}`, children: [many ? (_jsx("span", { className: "dd-box", "aria-hidden": "true" })) : (_jsx("span", { className: "dd-check", "aria-hidden": "true", children: item.value === props.value ? '✓' : '' })), item.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: item.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsxs("span", { className: "dd-text", children: [_jsx("span", { className: "dd-label", children: item.label }), item.detail && _jsx("span", { className: "dd-detail", children: item.detail })] }), item.badge && _jsx("span", { className: "dd-badge", children: item.badge })] }, item.value))), actions.length ? _jsx("div", { className: "dd-divider", role: "presentation" }) : null, actions.map((action, i) => (_jsxs(Select.Item, { value: `${ACTION}${i}`, label: action.label, className: (s) => `dd-option dd-action${s.highlighted ? ' active' : ''}`, children: [_jsx("span", { className: "dd-check", "aria-hidden": "true" }), _jsx("span", { className: "dd-text", children: _jsx("span", { className: "dd-label", children: action.label }) })] }, action.label)))] }) }) }) })] }) }));
85
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/ui",
3
- "version": "1.0.0-rc.18",
3
+ "version": "1.0.0-rc.20",
4
4
  "description": "The standalone React primitives both shells are drawn with: Modal, DropMenu, Dropdown, Typeahead, Button, Field, Icon and DateField over Base UI, Switch, Tabs, Drawer, Popover, Avatar, Pagination, Carousel, Resizable, ScrollArea and Tooltip, the form controls built on them (text, masked, money and sensitive boxes, listboxes, choices, slider, progress and action bar; Preview), the landing hero's blocks (badge, photo tiles, icon rows; Preview), their tokens and stylesheet, and the zoom-aware ruler their popups are placed by.",
5
5
  "homepage": "https://mistriwork.dev",
6
6
  "bugs": {