@tangible/ui 0.0.19 → 0.0.21
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.
- package/README.md +1 -0
- package/components/Accordion/Accordion.js +1 -1
- package/components/Avatar/Avatar.d.ts +3 -1
- package/components/Avatar/Avatar.js +6 -25
- package/components/Avatar/index.d.ts +2 -2
- package/components/Avatar/index.js +1 -1
- package/components/Avatar/types.d.ts +8 -8
- package/components/Avatar/types.js +0 -12
- package/components/Combobox/Combobox.js +2 -2
- package/components/Icon/Icon.d.ts +10 -1
- package/components/Icon/Icon.js +5 -1
- package/components/Modal/Modal.js +1 -1
- package/components/MultiSelect/MultiSelect.js +1 -1
- package/components/Notice/Notice.d.ts +2 -2
- package/components/OverlapStack/OverlapStack.js +4 -2
- package/components/Pager/Pager.js +9 -3
- package/components/Pager/types.d.ts +9 -0
- package/components/Pager/types.js +2 -0
- package/components/Progress/Progress.js +3 -3
- package/components/Rating/Rating.js +4 -2
- package/components/Rating/types.d.ts +5 -1
- package/components/Rating/types.js +1 -0
- package/components/Select/Select.d.ts +1 -1
- package/components/Select/Select.js +6 -4
- package/components/Select/types.d.ts +5 -0
- package/components/StepIndicator/StepIndicator.js +6 -2
- package/components/StepIndicator/types.d.ts +3 -0
- package/components/StepIndicator/types.js +1 -0
- package/components/Table/BulkActionsBar.js +4 -1
- package/components/Table/DataTable.js +8 -5
- package/components/Tabs/Tabs.js +1 -1
- package/components/index.d.ts +3 -2
- package/components/index.js +2 -1
- package/icons/icons.svg +6 -2
- package/icons/lms/index.js +1 -1
- package/icons/manifest.json +32 -0
- package/icons/registry.d.ts +8 -0
- package/icons/registry.js +4 -0
- package/icons/system/index.d.ts +8 -0
- package/icons/system/index.js +45 -1
- package/package.json +1 -1
- package/styles/all.css +1 -1
- package/styles/all.expanded.css +266 -106
- package/styles/all.expanded.unlayered.css +266 -106
- package/styles/all.unlayered.css +1 -1
- package/styles/components/accordion.scss +5 -2
- package/styles/components/avatar.scss +15 -63
- package/styles/components/button.scss +9 -2
- package/styles/components/chip.scss +9 -1
- package/styles/components/combobox.scss +4 -2
- package/styles/components/dropdown.scss +2 -2
- package/styles/components/icon.scss +14 -3
- package/styles/components/input/index.scss +6 -1
- package/styles/components/move-handle.scss +1 -1
- package/styles/components/multi-select.scss +6 -3
- package/styles/components/notice.scss +30 -6
- package/styles/components/overlap-stack.scss +4 -3
- package/styles/components/pager.scss +6 -3
- package/styles/components/progress.scss +17 -5
- package/styles/components/rating.scss +2 -2
- package/styles/components/segmented-control.scss +2 -2
- package/styles/components/select.scss +13 -4
- package/styles/components/step-indicator.scss +8 -8
- package/styles/components/step-list.scss +1 -1
- package/styles/components/table.scss +2 -1
- package/styles/components/tabs.scss +2 -2
- package/styles/components/text-input.scss +5 -1
- package/styles/core.css +1 -1
- package/styles/core.unlayered.css +1 -1
- package/styles/index.scss +5 -2
- package/styles/system/_constants.scss +2 -2
- package/styles/system/_motion.scss +20 -18
- package/styles/system/_tokens.scss +89 -10
- package/tui-manifest.json +19 -6
- package/utils/generative.d.ts +16 -0
- package/utils/generative.js +45 -0
package/README.md
CHANGED
|
@@ -224,6 +224,7 @@ npm run test:visual:update # Regenerate visual baselines
|
|
|
224
224
|
|
|
225
225
|
## Documentation
|
|
226
226
|
|
|
227
|
+
- `CONTRIBUTING.md` — The pattern language: how components are built here
|
|
227
228
|
- `CLAUDE.md` — Architecture, patterns, conventions, gotchas
|
|
228
229
|
- `CONTEXT.md` — Project background and design philosophy
|
|
229
230
|
- `TIMELINE.md` — Development roadmap
|
|
@@ -233,7 +233,7 @@ function AccordionTrigger({ asChild = false, 'aria-label': ariaLabel, children,
|
|
|
233
233
|
return element;
|
|
234
234
|
}
|
|
235
235
|
// Default: render as button with built-in chevron indicator
|
|
236
|
-
const button = (_jsxs("button", { ref: triggerRef, type: "button", id: triggerId, className: cx('tui-accordion__trigger', className), "aria-expanded": isOpen, "aria-controls": panelId, "aria-label": ariaLabel, disabled: disabled, "data-state": state, "data-disabled": disabled || undefined, onClick: handleClick, onKeyDown: handleKeyDown, children: [children && _jsx("span", { className: "tui-accordion__trigger-content", children: children }), _jsx(Icon, { name: "system/chevron-down",
|
|
236
|
+
const button = (_jsxs("button", { ref: triggerRef, type: "button", id: triggerId, className: cx('tui-accordion__trigger', className), "aria-expanded": isOpen, "aria-controls": panelId, "aria-label": ariaLabel, disabled: disabled, "data-state": state, "data-disabled": disabled || undefined, onClick: handleClick, onKeyDown: handleKeyDown, children: [children && _jsx("span", { className: "tui-accordion__trigger-content", children: children }), _jsx(Icon, { name: "system/chevron-down", className: "tui-accordion__indicator", "aria-hidden": "true" })] }));
|
|
237
237
|
// Wrap in heading if headingLevel is specified
|
|
238
238
|
if (headingLevel) {
|
|
239
239
|
const Heading = `h${headingLevel}`;
|
|
@@ -6,6 +6,8 @@ import type { AvatarProps } from './types';
|
|
|
6
6
|
* - Loads image from `src` prop
|
|
7
7
|
* - Falls back to initials from `name` if image fails or isn't provided
|
|
8
8
|
* - Shows placeholder icon if neither `src` nor `name` provided
|
|
9
|
-
* - Colors for initials
|
|
9
|
+
* - Colors for initials come from the generative palette (The Jellybean
|
|
10
|
+
* Bag), derived from the name hash for consistency; name-less avatars
|
|
11
|
+
* fall back to the neutral `slate`
|
|
10
12
|
*/
|
|
11
13
|
export declare const Avatar: React.MemoExoticComponent<React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLSpanElement>>>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useState, useMemo } from 'react';
|
|
3
3
|
import { cx } from '../../utils/cx.js';
|
|
4
|
+
import { stringToGenerativeColor } from '../../utils/generative.js';
|
|
4
5
|
import { Icon } from '../Icon/index.js';
|
|
5
6
|
import { Tooltip } from '../Tooltip/index.js';
|
|
6
|
-
import {
|
|
7
|
+
import { defaultAvatarLabels } from './types.js';
|
|
7
8
|
/**
|
|
8
9
|
* Generate initials from a name.
|
|
9
10
|
* "Mary Ghen" → "MG", "Bob" → "B", "Jean-Luc Picard" → "JP"
|
|
@@ -16,35 +17,15 @@ function getInitials(name) {
|
|
|
16
17
|
return parts[0].charAt(0).toUpperCase();
|
|
17
18
|
return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase();
|
|
18
19
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Simple hash function for consistent color assignment.
|
|
21
|
-
* Same name always gets the same color.
|
|
22
|
-
*/
|
|
23
|
-
function hashString(str) {
|
|
24
|
-
if (!str)
|
|
25
|
-
return 0;
|
|
26
|
-
let hash = 0;
|
|
27
|
-
for (let i = 0; i < str.length; i++) {
|
|
28
|
-
const char = str.charCodeAt(i);
|
|
29
|
-
hash = ((hash << 5) - hash) + char;
|
|
30
|
-
hash = hash & hash; // Convert to 32-bit integer
|
|
31
|
-
}
|
|
32
|
-
return Math.abs(hash);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get a consistent color for a name.
|
|
36
|
-
*/
|
|
37
|
-
function getColorFromName(name, colors) {
|
|
38
|
-
const hash = hashString(name.toLowerCase());
|
|
39
|
-
return colors[hash % colors.length];
|
|
40
|
-
}
|
|
41
20
|
/**
|
|
42
21
|
* Avatar displays a user's profile image, initials, or a placeholder icon.
|
|
43
22
|
*
|
|
44
23
|
* - Loads image from `src` prop
|
|
45
24
|
* - Falls back to initials from `name` if image fails or isn't provided
|
|
46
25
|
* - Shows placeholder icon if neither `src` nor `name` provided
|
|
47
|
-
* - Colors for initials
|
|
26
|
+
* - Colors for initials come from the generative palette (The Jellybean
|
|
27
|
+
* Bag), derived from the name hash for consistency; name-less avatars
|
|
28
|
+
* fall back to the neutral `slate`
|
|
48
29
|
*/
|
|
49
30
|
export const Avatar = React.memo(React.forwardRef(({ src, name, size = 'md', shape = 'circle', color, indicator, indicatorLabel, indicatorPosition = 'bottom-right', tooltip, labels: labelsProp, className, }, ref) => {
|
|
50
31
|
const [imgError, setImgError] = useState(false);
|
|
@@ -53,7 +34,7 @@ export const Avatar = React.memo(React.forwardRef(({ src, name, size = 'md', sha
|
|
|
53
34
|
setImgError(false);
|
|
54
35
|
}, [src]);
|
|
55
36
|
const initials = useMemo(() => (name ? getInitials(name) : ''), [name]);
|
|
56
|
-
const derivedColor = useMemo(() => color ?? (name ?
|
|
37
|
+
const derivedColor = useMemo(() => color ?? (name ? stringToGenerativeColor(name) : 'slate'), [color, name]);
|
|
57
38
|
const labels = useMemo(() => ({ ...defaultAvatarLabels, ...labelsProp }), [labelsProp]);
|
|
58
39
|
const showImage = src && !imgError;
|
|
59
40
|
const showInitials = !showImage && initials;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Avatar as AvatarBase } from './Avatar';
|
|
2
2
|
import { AvatarGroup } from './AvatarGroup';
|
|
3
|
-
export type { AvatarProps, AvatarGroupProps, AvatarGroupLabels, AvatarLabels, AvatarSize, AvatarShape,
|
|
4
|
-
export {
|
|
3
|
+
export type { AvatarProps, AvatarGroupProps, AvatarGroupLabels, AvatarLabels, AvatarSize, AvatarShape, IndicatorPosition, } from './types';
|
|
4
|
+
export { defaultAvatarGroupLabels, defaultAvatarLabels } from './types';
|
|
5
5
|
type AvatarCompound = typeof AvatarBase & {
|
|
6
6
|
Group: typeof AvatarGroup;
|
|
7
7
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Avatar as AvatarBase } from './Avatar.js';
|
|
2
2
|
import { AvatarGroup } from './AvatarGroup.js';
|
|
3
|
-
export {
|
|
3
|
+
export { defaultAvatarGroupLabels, defaultAvatarLabels } from './types.js';
|
|
4
4
|
export const Avatar = AvatarBase;
|
|
5
5
|
Avatar.Group = AvatarGroup;
|
|
6
6
|
// Named export for direct import
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import type { SizeExtended } from '../../types';
|
|
2
|
+
import type { GenerativeColor } from '../../utils/generative';
|
|
2
3
|
export type AvatarSize = SizeExtended;
|
|
3
4
|
export type AvatarShape = 'circle' | 'square';
|
|
4
5
|
export type IndicatorPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
5
|
-
/**
|
|
6
|
-
* Avatar palette colors for initials backgrounds.
|
|
7
|
-
* These are not tied to semantic themes - they provide visual variety.
|
|
8
|
-
*/
|
|
9
|
-
export type AvatarColor = 'coral' | 'amber' | 'lime' | 'teal' | 'cyan' | 'blue' | 'violet' | 'pink' | 'slate' | 'emerald';
|
|
10
|
-
export declare const AVATAR_COLORS: AvatarColor[];
|
|
11
6
|
/**
|
|
12
7
|
* Overridable strings for Avatar i18n.
|
|
13
8
|
*/
|
|
@@ -25,8 +20,13 @@ export type AvatarProps = {
|
|
|
25
20
|
size?: AvatarSize;
|
|
26
21
|
/** Shape of the avatar */
|
|
27
22
|
shape?: AvatarShape;
|
|
28
|
-
/**
|
|
29
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Explicit color for initials background (otherwise derived from name via
|
|
25
|
+
* `stringToGenerativeColor`). `slate` is the neutral fallback for
|
|
26
|
+
* name-less avatars — deliberately not in the hash bag, grey means
|
|
27
|
+
* "no identity", not a flavour.
|
|
28
|
+
*/
|
|
29
|
+
color?: GenerativeColor | 'slate';
|
|
30
30
|
/** Status indicator element (icon, badge, etc.) */
|
|
31
31
|
indicator?: React.ReactNode;
|
|
32
32
|
/** Accessible label for the indicator (e.g., "Online", "Verified", "3 notifications") */
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
export const AVATAR_COLORS = [
|
|
2
|
-
'coral',
|
|
3
|
-
'amber',
|
|
4
|
-
'lime',
|
|
5
|
-
'teal',
|
|
6
|
-
'cyan',
|
|
7
|
-
'blue',
|
|
8
|
-
'violet',
|
|
9
|
-
'pink',
|
|
10
|
-
'slate',
|
|
11
|
-
'emerald',
|
|
12
|
-
];
|
|
13
1
|
export const defaultAvatarLabels = {
|
|
14
2
|
description: (name, indicatorLabel) => `${name}, ${indicatorLabel}`,
|
|
15
3
|
};
|
|
@@ -386,7 +386,7 @@ function ComboboxRoot({ value: controlledValue, defaultValue, onValueChange, inp
|
|
|
386
386
|
return (_jsx(ComboboxActionsContext.Provider, { value: actionsValue, children: _jsx(ComboboxStateContext.Provider, { value: stateValue, children: _jsxs("div", { className: "tui-combobox", children: [_jsxs("div", { className: "tui-combobox__input-wrapper", children: [_jsx("input", { ref: (node) => {
|
|
387
387
|
inputRef.current = node;
|
|
388
388
|
refs.setReference(node);
|
|
389
|
-
}, type: "text", id: inputId, className: cx('tui-combobox__input', size !== 'md' && `is-size-${size}`, inputClassName), role: "combobox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "aria-autocomplete": "list", "aria-activedescendant": activeOptionId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, disabled: disabled, placeholder: placeholder, value: inputValue, autoComplete: "off", ...referenceProps, onChange: handleInputChange }), clearable && inputValue && !disabled && (_jsx("button", { type: "button", className: "tui-combobox__clear", onClick: handleClear, onMouseDown: (e) => e.preventDefault(), "aria-label": labels.clear, tabIndex: -1, children: _jsx(Icon, { name: "system/close"
|
|
389
|
+
}, type: "text", id: inputId, className: cx('tui-combobox__input', size !== 'md' && `is-size-${size}`, inputClassName), role: "combobox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "aria-autocomplete": "list", "aria-activedescendant": activeOptionId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, disabled: disabled, placeholder: placeholder, value: inputValue, autoComplete: "off", ...referenceProps, onChange: handleInputChange }), clearable && inputValue && !disabled && (_jsx("button", { type: "button", className: "tui-combobox__clear", onClick: handleClear, onMouseDown: (e) => e.preventDefault(), "aria-label": labels.clear, tabIndex: -1, children: _jsx(Icon, { name: "system/close" }) })), _jsx("span", { className: "tui-combobox__icon", "aria-hidden": "true", children: _jsx(Icon, { name: "system/chevron-down" }) })] }), children] }) }) }));
|
|
390
390
|
}
|
|
391
391
|
ComboboxRoot.displayName = 'Combobox';
|
|
392
392
|
// =============================================================================
|
|
@@ -461,7 +461,7 @@ function ComboboxOptionComponent({ value: optionValue, disabled = false, textVal
|
|
|
461
461
|
const itemProps = getItemProps({
|
|
462
462
|
onClick: handleClick,
|
|
463
463
|
});
|
|
464
|
-
return (_jsxs("div", { ref: ref, id: optionId, role: "option", className: cx('tui-combobox__option', className), "aria-selected": isSelected, "aria-disabled": disabled || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": disabled || undefined, ...itemProps, onPointerDown: composeEventHandlers(handlePointerDown, itemProps.onPointerDown), children: [_jsx("span", { className: "tui-combobox__option-content", children: children }), isSelected && (_jsx(Icon, { name: "system/check",
|
|
464
|
+
return (_jsxs("div", { ref: ref, id: optionId, role: "option", className: cx('tui-combobox__option', className), "aria-selected": isSelected, "aria-disabled": disabled || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": disabled || undefined, ...itemProps, onPointerDown: composeEventHandlers(handlePointerDown, itemProps.onPointerDown), children: [_jsx("span", { className: "tui-combobox__option-content", children: children }), isSelected && (_jsx(Icon, { name: "system/check", className: "tui-combobox__option-check", "aria-hidden": "true" }))] }));
|
|
465
465
|
}
|
|
466
466
|
ComboboxOptionComponent.displayName = 'Combobox.Option';
|
|
467
467
|
// =============================================================================
|
|
@@ -4,7 +4,16 @@ import type { SizeExtended } from '../../types';
|
|
|
4
4
|
export interface IconProps {
|
|
5
5
|
/** Icon name from registry (e.g., "system/check") */
|
|
6
6
|
name?: IconName;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Emoji or unicode character (alternative to name). The same labelling
|
|
9
|
+
* contract as `name` applies: pass `label` when the emoji conveys meaning
|
|
10
|
+
* not available from surrounding text (🔒 for locked, ⚠️ for a warning);
|
|
11
|
+
* omit it only for decoration.
|
|
12
|
+
*
|
|
13
|
+
* @remarks Emoji render with the platform's native emoji font — size and
|
|
14
|
+
* baseline alignment differ across macOS/Windows/Android, so avoid mixing
|
|
15
|
+
* emoji with SVG icons in sets that must align (e.g. status columns).
|
|
16
|
+
*/
|
|
8
17
|
emoji?: string;
|
|
9
18
|
/** Accessible label for informative icons. Required if icon conveys meaning. */
|
|
10
19
|
label?: string;
|
package/components/Icon/Icon.js
CHANGED
|
@@ -18,7 +18,11 @@ export const Icon = React.memo(React.forwardRef(({ name, emoji, label, size, cla
|
|
|
18
18
|
}
|
|
19
19
|
// Decorative if no label provided
|
|
20
20
|
const isDecorative = !label;
|
|
21
|
-
|
|
21
|
+
// A name that misses the registry (typo, or a runtime-dynamic name from
|
|
22
|
+
// config/API data) renders an empty span in production — mark it so the
|
|
23
|
+
// void is findable in DevTools instead of failing silently.
|
|
24
|
+
const isMissing = Boolean(name && !SvgIcon && !emoji);
|
|
25
|
+
return (_jsxs("span", { ref: ref, className: cx('tui-icon', size && `is-size-${size}`, className), ...(isMissing ? { 'data-tui-icon-missing': name } : {}), ...(isDecorative
|
|
22
26
|
? { 'aria-hidden': true }
|
|
23
27
|
: { role: 'img', 'aria-label': label }), children: [SvgIcon && _jsx(SvgIcon, { "aria-hidden": "true", focusable: "false" }), !SvgIcon && emoji] }));
|
|
24
28
|
}));
|
|
@@ -141,7 +141,7 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
|
|
|
141
141
|
const contextValue = useMemo(() => ({ onClose }), [onClose]);
|
|
142
142
|
if (!open || !mount)
|
|
143
143
|
return null;
|
|
144
|
-
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", 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);
|
|
144
|
+
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
145
|
}
|
|
146
146
|
function ModalClose({ label = 'Close', className }) {
|
|
147
147
|
const { onClose } = useModalContext();
|
|
@@ -451,7 +451,7 @@ function MultiSelectTriggerComponent({ asChild = false, className, children, })
|
|
|
451
451
|
return (_jsxs("span", { className: "tui-multiselect__chips", children: [visibleChips.map((opt) => (_jsx("span", { className: "tui-multiselect__chip", children: opt.textValue }, toKey(opt.value)))), overflow > 0 && (_jsx("span", { className: "tui-multiselect__more", children: labels.more(overflow) }))] }));
|
|
452
452
|
};
|
|
453
453
|
// Default trigger content (when not using asChild or custom children)
|
|
454
|
-
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: "system/close"
|
|
454
|
+
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: "system/close" }) })), _jsx(Icon, { name: "system/chevron-down", className: "tui-multiselect__icon", "aria-hidden": "true" })] }));
|
|
455
455
|
// Generate status message for screen readers
|
|
456
456
|
const statusMessage = labels.status(selectedOptions.length, max);
|
|
457
457
|
// Live region (rendered outside button, sibling to trigger)
|
|
@@ -3,7 +3,7 @@ import type { JSX } from 'react';
|
|
|
3
3
|
import type { ThemeStatus, SizeStandard } from '../../types';
|
|
4
4
|
type RootAs = 'section' | 'div';
|
|
5
5
|
type HeadingAs = 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
6
|
-
type NoticeTheme = ThemeStatus;
|
|
6
|
+
type NoticeTheme = ThemeStatus | 'neutral';
|
|
7
7
|
type NoticeAnnounce = 'off' | 'polite' | 'assertive';
|
|
8
8
|
export type NoticeExitAnimation = 'collapse' | 'fade' | 'none';
|
|
9
9
|
type CommonProps = {
|
|
@@ -68,7 +68,7 @@ type SlotProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
68
68
|
className?: string;
|
|
69
69
|
children?: React.ReactNode;
|
|
70
70
|
};
|
|
71
|
-
type HeadSlotProps = SlotProps & {
|
|
71
|
+
type HeadSlotProps = Omit<SlotProps, 'title'> & {
|
|
72
72
|
/** Icon content */
|
|
73
73
|
icon?: React.ReactNode;
|
|
74
74
|
/** Title text */
|
|
@@ -5,7 +5,9 @@ import { cx } from '../../utils/cx.js';
|
|
|
5
5
|
// Overflow Component
|
|
6
6
|
// =============================================================================
|
|
7
7
|
const OverlapStackOverflow = forwardRef(function OverlapStackOverflow({ children, className, style, 'aria-label': ariaLabel }, ref) {
|
|
8
|
-
return (_jsx("span", { ref: ref, className: cx('tui-overlap-stack__overflow', className), style: style,
|
|
8
|
+
return (_jsx("span", { ref: ref, className: cx('tui-overlap-stack__overflow', className), style: style,
|
|
9
|
+
// aria-label on a generic span is prohibited (ARIA 1.2) — img names it
|
|
10
|
+
role: ariaLabel !== undefined ? 'img' : undefined, "aria-label": ariaLabel, children: children }));
|
|
9
11
|
});
|
|
10
12
|
// =============================================================================
|
|
11
13
|
// Main Component
|
|
@@ -29,7 +31,7 @@ const OverlapStackRoot = forwardRef(function OverlapStack({ overlap, max, frame,
|
|
|
29
31
|
// Default overflow renderer uses overflowLabel for i18n
|
|
30
32
|
const defaultOverflow = (count) => (_jsxs(OverlapStackOverflow, { "aria-label": overflowLabel(count), children: ["+", count] }));
|
|
31
33
|
const overflowRenderer = renderOverflow ?? defaultOverflow;
|
|
32
|
-
return (_jsxs("div", { ref: ref, role: hasAccessibleName ? 'group' : undefined, className: cx('tui-overlap-stack', className), style: { ...cssVars, ...style }, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, children: [visibleChildren.map((child, index) => (_jsx("span", { className: cx('tui-overlap-stack__item', frame && 'is-framed'), style: { zIndex: Z_INDEX_BASE
|
|
34
|
+
return (_jsxs("div", { ref: ref, role: hasAccessibleName ? 'group' : undefined, className: cx('tui-overlap-stack', className), style: { ...cssVars, ...style }, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, children: [visibleChildren.map((child, index) => (_jsx("span", { className: cx('tui-overlap-stack__item', frame && 'is-framed'), style: { zIndex: Z_INDEX_BASE + index }, children: child }, child.key ?? index))), hasOverflow && (_jsx("span", { className: cx('tui-overlap-stack__item', frame && 'is-framed'), style: { zIndex: Z_INDEX_BASE + visibleChildren.length }, children: overflowRenderer(overflowCount) }))] }));
|
|
33
35
|
});
|
|
34
36
|
// Display names for React DevTools
|
|
35
37
|
OverlapStackRoot.displayName = 'OverlapStack';
|
|
@@ -128,11 +128,17 @@ export function Pager({ currentPage, totalPages, onPageChange, pageSize, pageSiz
|
|
|
128
128
|
const total = Math.max(1, totalPages);
|
|
129
129
|
const current = Math.min(total, Math.max(1, currentPage));
|
|
130
130
|
const items = React.useMemo(() => buildItems(total, current, mode, maxNumbers), [total, current, mode, maxNumbers]);
|
|
131
|
-
|
|
131
|
+
// Live-region text: page changes are announced politely. Empty until the
|
|
132
|
+
// first user-driven change so mount announces nothing.
|
|
133
|
+
const [announcement, setAnnouncement] = React.useState('');
|
|
134
|
+
const go = React.useCallback((page) => {
|
|
135
|
+
setAnnouncement(labels.pageStatus(page, total));
|
|
136
|
+
onPageChange(page);
|
|
137
|
+
}, [onPageChange, labels, total]);
|
|
132
138
|
if (hidden)
|
|
133
139
|
return null;
|
|
134
140
|
const showPageSizeSelector = pageSizeOptions && pageSizeOptions.length > 0 && onPageSizeChange;
|
|
135
|
-
return (_jsxs("div", { className: cx('tui-pager', className), children: [_jsx("nav", { className: "tui-pager__nav", "aria-label": labels.navigation, children: items.map((it, i) => {
|
|
141
|
+
return (_jsxs("div", { className: cx('tui-pager', className), children: [_jsx("span", { role: "status", "aria-atomic": "true", className: "tui-visually-hidden", children: announcement }), _jsx("nav", { className: "tui-pager__nav", "aria-label": labels.navigation, children: items.map((it, i) => {
|
|
136
142
|
if (it.kind === 'ellipsis') {
|
|
137
143
|
return (_jsx("span", { className: "tui-pager__ellipsis", "aria-hidden": true, children: "..." }, `e${i}`));
|
|
138
144
|
}
|
|
@@ -142,7 +148,7 @@ export function Pager({ currentPage, totalPages, onPageChange, pageSize, pageSiz
|
|
|
142
148
|
if (navStyle === 'icon') {
|
|
143
149
|
return (_jsx(IconButton, { icon: isPrev ? 'system/chevron-left' : 'system/chevron-right', label: label, showTooltip: true, size: "sm", theme: "secondary", variant: "outline", disabled: it.disabled, onClick: () => go(it.page), className: "tui-pager__item" }, it.kind));
|
|
144
150
|
}
|
|
145
|
-
return (_jsx(Button, { size: "sm", theme: "secondary", variant: "outline", disabled: it.disabled, onClick: () => go(it.page), "aria-label": label, className: "tui-pager__item", children: isPrev ?
|
|
151
|
+
return (_jsx(Button, { size: "sm", theme: "secondary", variant: "outline", disabled: it.disabled, onClick: () => go(it.page), "aria-label": label, className: "tui-pager__item", children: isPrev ? labels.previousText : labels.nextText }, it.kind));
|
|
146
152
|
}
|
|
147
153
|
// Page number
|
|
148
154
|
if (it.kind === 'page') {
|
|
@@ -13,6 +13,15 @@ export type PagerLabels = {
|
|
|
13
13
|
* @default "Next page"
|
|
14
14
|
*/
|
|
15
15
|
next?: string;
|
|
16
|
+
/** VISIBLE text on the previous button (text nav style). Must be contained
|
|
17
|
+
* in `previous` (the accessible name) to satisfy WCAG 2.5.3 Label in Name.
|
|
18
|
+
* @default "Prev"
|
|
19
|
+
*/
|
|
20
|
+
previousText?: string;
|
|
21
|
+
/** Visible text on the next button — same containment rule as previousText.
|
|
22
|
+
* @default "Next"
|
|
23
|
+
*/
|
|
24
|
+
nextText?: string;
|
|
16
25
|
/** Label for individual page buttons.
|
|
17
26
|
* @default (n) => `Page ${n}`
|
|
18
27
|
*/
|
|
@@ -89,13 +89,13 @@ export const Progress = memo(function Progress(props) {
|
|
|
89
89
|
// ==========================================================================
|
|
90
90
|
// No labels to show
|
|
91
91
|
if (!showLabels || !hasLabels || isSegmented) {
|
|
92
|
-
return (_jsxs("div", { ...rootProps, children: [trackContent, !labelledBy && !ariaLabel && defaultLabel && (_jsx("span", { className: "visually-hidden", children: defaultLabel }))] }));
|
|
92
|
+
return (_jsxs("div", { ...rootProps, children: [trackContent, !labelledBy && !ariaLabel && defaultLabel && (_jsx("span", { className: "tui-visually-hidden", children: defaultLabel }))] }));
|
|
93
93
|
}
|
|
94
94
|
// Inside position: labels are rendered within trackContent above
|
|
95
95
|
if (labelPosition === 'inside') {
|
|
96
|
-
return (_jsxs("div", { ...rootProps, children: [trackContent, !labelledBy && !ariaLabel && defaultLabel && (_jsx("span", { className: "visually-hidden", children: defaultLabel }))] }));
|
|
96
|
+
return (_jsxs("div", { ...rootProps, children: [trackContent, !labelledBy && !ariaLabel && defaultLabel && (_jsx("span", { className: "tui-visually-hidden", children: defaultLabel }))] }));
|
|
97
97
|
}
|
|
98
98
|
// Above/below/inline positions: render labels outside the track
|
|
99
99
|
const labelRow = (_jsxs("div", { className: "tui-progress__labels", children: [labelStart && _jsx("span", { className: "tui-progress__label is-start", children: labelStart }), labelEnd && _jsx("span", { className: "tui-progress__label is-end", children: labelEnd })] }));
|
|
100
|
-
return (_jsxs("div", { ...rootProps, children: [labelPosition === 'above' && labelRow, labelPosition === 'inline' ? (_jsxs("div", { className: "tui-progress__inline", children: [labelStart && _jsx("span", { className: "tui-progress__label is-start", children: labelStart }), trackContent, labelEnd && _jsx("span", { className: "tui-progress__label is-end", children: labelEnd })] })) : (trackContent), labelPosition === 'below' && labelRow, !labelledBy && !ariaLabel && defaultLabel && (_jsx("span", { className: "visually-hidden", children: defaultLabel }))] }));
|
|
100
|
+
return (_jsxs("div", { ...rootProps, children: [labelPosition === 'above' && labelRow, labelPosition === 'inline' ? (_jsxs("div", { className: "tui-progress__inline", children: [labelStart && _jsx("span", { className: "tui-progress__label is-start", children: labelStart }), trackContent, labelEnd && _jsx("span", { className: "tui-progress__label is-end", children: labelEnd })] })) : (trackContent), labelPosition === 'below' && labelRow, !labelledBy && !ariaLabel && defaultLabel && (_jsx("span", { className: "tui-visually-hidden", children: defaultLabel }))] }));
|
|
101
101
|
});
|
|
@@ -64,13 +64,15 @@ export function Rating({ value, defaultValue = 0, max = 5, disabled, readOnly, n
|
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
|
|
67
|
+
// Read-only: the img label carries the value. Interactive: the group label
|
|
68
|
+
// must not — each radio announces its own checked state (double-announce).
|
|
69
|
+
const defaultAriaLabel = readOnly ? labels.rating(current, max) : labels.group;
|
|
68
70
|
// Roving tabindex: only the selected radio (or first if none) is in tab order
|
|
69
71
|
const focusableIndex = current > 0 ? current : 1;
|
|
70
72
|
return (_jsx("div", { className: cx('tui-rating', `is-size-${size}`, `is-theme-${theme}`, disabled && 'is-disabled', className), style: { gap }, role: readOnly ? 'img' : 'radiogroup', "aria-label": ariaLabel ?? defaultAriaLabel, onKeyDown: readOnly ? undefined : onKeyDown, children: Array.from({ length: max }).map((_, i) => {
|
|
71
73
|
const n = i + 1;
|
|
72
74
|
const checked = current >= n;
|
|
73
75
|
const id = `${groupName}__star-${n}`;
|
|
74
|
-
return (_jsxs("div", { className: "tui-rating__item", children: [!readOnly && (_jsx("input", { className: "tui-visually-hidden", type: "radio", id: id, name: groupName, value: n, checked: current === n,
|
|
76
|
+
return (_jsxs("div", { className: "tui-rating__item", children: [!readOnly && (_jsx("input", { className: "tui-visually-hidden", type: "radio", id: id, name: groupName, value: n, checked: current === n, tabIndex: n === focusableIndex ? 0 : -1, onChange: () => handleSelect(n), disabled: disabled })), readOnly ? (_jsx("span", { className: cx('tui-rating__star', checked && 'is-active'), children: _jsx(Icon, { name: checked ? 'system/star-fill' : 'system/star-outline' }) })) : (_jsxs("label", { className: cx('tui-rating__star', checked && 'is-active'), htmlFor: id, tabIndex: -1, children: [_jsx(Icon, { name: checked ? 'system/star-fill' : 'system/star-outline' }), _jsx("span", { className: "tui-visually-hidden", children: labels.value(n, max) })] }))] }, n));
|
|
75
77
|
}) }));
|
|
76
78
|
}
|
|
@@ -2,8 +2,12 @@ import type { SizeStandard, Theme as ThemeFull } from '../../types';
|
|
|
2
2
|
export type Size = SizeStandard;
|
|
3
3
|
export type Theme = ThemeFull;
|
|
4
4
|
export type RatingLabels = {
|
|
5
|
-
/** Group label for the
|
|
5
|
+
/** Group label for the read-only img role. Receives current value and max. */
|
|
6
6
|
rating?: (value: number, max: number) => string;
|
|
7
|
+
/** Group label for the interactive radiogroup. Must NOT encode the current
|
|
8
|
+
* value — the focused radio announces its own state, and a value-bearing
|
|
9
|
+
* group label double-announces. */
|
|
10
|
+
group?: string;
|
|
7
11
|
/** Visually-hidden label for each star. Receives star number and max. */
|
|
8
12
|
value?: (n: number, max: number) => string;
|
|
9
13
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SelectProps, type SelectTriggerProps, type SelectContentProps, type SelectOptionProps, type SelectGroupProps, type SelectLabelProps } from './types';
|
|
2
|
-
declare function SelectRoot({ id: triggerIdProp, value: controlledValue, defaultValue, onValueChange, open: controlledOpen, defaultOpen, onOpenChange, disabled, placeholder, size, side, align, sideOffset, clearable, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, children, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare function SelectRoot({ id: triggerIdProp, value: controlledValue, defaultValue, onValueChange, open: controlledOpen, defaultOpen, onOpenChange, disabled, placeholder, size, side, align, sideOffset, clearable, clearLabel, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, children, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
declare namespace SelectRoot {
|
|
4
4
|
var displayName: string;
|
|
5
5
|
}
|
|
@@ -11,7 +11,7 @@ import { toPlacement, } from './types.js';
|
|
|
11
11
|
// =============================================================================
|
|
12
12
|
// Select Root
|
|
13
13
|
// =============================================================================
|
|
14
|
-
function SelectRoot({ id: triggerIdProp, value: controlledValue, defaultValue, onValueChange, open: controlledOpen, defaultOpen, onOpenChange, disabled = false, placeholder = '', size = 'md', side = 'bottom', align = 'start', sideOffset = 4, clearable = false, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, children, }) {
|
|
14
|
+
function SelectRoot({ id: triggerIdProp, value: controlledValue, defaultValue, onValueChange, open: controlledOpen, defaultOpen, onOpenChange, disabled = false, placeholder = '', size = 'md', side = 'bottom', align = 'start', sideOffset = 4, clearable = false, clearLabel = 'Clear selection', 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, children, }) {
|
|
15
15
|
// Controlled/uncontrolled value — lock decision at mount time to prevent
|
|
16
16
|
// switching modes when controlled value is cleared to undefined
|
|
17
17
|
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
@@ -245,6 +245,7 @@ function SelectRoot({ id: triggerIdProp, value: controlledValue, defaultValue, o
|
|
|
245
245
|
disabled,
|
|
246
246
|
placeholder,
|
|
247
247
|
clearable,
|
|
248
|
+
clearLabel,
|
|
248
249
|
size,
|
|
249
250
|
// ARIA IDs
|
|
250
251
|
triggerId,
|
|
@@ -279,6 +280,7 @@ function SelectRoot({ id: triggerIdProp, value: controlledValue, defaultValue, o
|
|
|
279
280
|
disabled,
|
|
280
281
|
placeholder,
|
|
281
282
|
clearable,
|
|
283
|
+
clearLabel,
|
|
282
284
|
size,
|
|
283
285
|
triggerId,
|
|
284
286
|
listboxId,
|
|
@@ -311,7 +313,7 @@ SelectRoot.displayName = 'Select';
|
|
|
311
313
|
// Select.Trigger
|
|
312
314
|
// =============================================================================
|
|
313
315
|
function SelectTriggerComponent({ asChild = false, className, children, }) {
|
|
314
|
-
const { open, setOpen, disabled, placeholder, clearable, size, triggerId, listboxId, ariaLabel, ariaLabelledBy, ariaDescribedBy, displayText, setValue, refs, getReferenceProps, activeIndex, handleSelect, justClearedRef, } = useSelectContext();
|
|
316
|
+
const { open, setOpen, disabled, placeholder, clearable, clearLabel, size, triggerId, listboxId, ariaLabel, ariaLabelledBy, ariaDescribedBy, displayText, setValue, refs, getReferenceProps, activeIndex, handleSelect, justClearedRef, } = useSelectContext();
|
|
315
317
|
const sizeClass = size !== 'md' ? `is-size-${size}` : undefined;
|
|
316
318
|
const hasValue = displayText !== undefined;
|
|
317
319
|
// Ensure trigger has focus when dropdown opens (Safari doesn't focus buttons on click)
|
|
@@ -427,7 +429,7 @@ function SelectTriggerComponent({ asChild = false, className, children, }) {
|
|
|
427
429
|
// Wrap in a relative container so the clear button can be a sibling of the
|
|
428
430
|
// trigger <button> — nesting <button> inside <button> is invalid HTML and
|
|
429
431
|
// causes browsers to eject the inner button via the adoption agency algorithm.
|
|
430
|
-
return (_jsxs("div", { className: cx('tui-select__trigger-wrap', showClear && 'has-clear'), children: [_jsxs("button", { ref: refs.setReference, type: "button", className: cx('tui-select__trigger', sizeClass, className), disabled: disabled, ...triggerProps, children: [_jsx("span", { className: "tui-select__value", children: displayText ?? _jsx("span", { className: "tui-select__placeholder", children: placeholder }) }), _jsx(Icon, { name: "system/chevron-down",
|
|
432
|
+
return (_jsxs("div", { className: cx('tui-select__trigger-wrap', showClear && 'has-clear'), children: [_jsxs("button", { ref: refs.setReference, type: "button", className: cx('tui-select__trigger', sizeClass, className), disabled: disabled, ...triggerProps, children: [_jsx("span", { className: "tui-select__value", children: displayText ?? _jsx("span", { className: "tui-select__placeholder", children: placeholder }) }), _jsx(Icon, { name: "system/chevron-down", className: "tui-select__icon", "aria-hidden": "true" })] }), showClear && (_jsx("button", { type: "button", className: "tui-select__clear", onClick: handleClear, "aria-label": clearLabel, tabIndex: -1, children: _jsx(Icon, { name: "system/close" }) }))] }));
|
|
431
433
|
}
|
|
432
434
|
SelectTriggerComponent.displayName = 'Select.Trigger';
|
|
433
435
|
// =============================================================================
|
|
@@ -497,7 +499,7 @@ function SelectOptionComponent({ value: optionValue, disabled = false, textValue
|
|
|
497
499
|
}, [disabled, optionValue, textValue, setValue, setOpen]);
|
|
498
500
|
return (_jsxs("div", { ref: ref, id: index >= 0 ? `${listboxId}-option-${index}` : undefined, role: "option", className: cx('tui-select__option', className), "aria-selected": isSelected, "aria-disabled": disabled || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": disabled || undefined, ...getItemProps({
|
|
499
501
|
onClick: handleClick,
|
|
500
|
-
}), children: [_jsx("span", { className: "tui-select__option-content", children: children }), isSelected && (_jsx(Icon, { name: "system/check",
|
|
502
|
+
}), children: [_jsx("span", { className: "tui-select__option-content", children: children }), isSelected && (_jsx(Icon, { name: "system/check", className: "tui-select__option-check", "aria-hidden": "true" }))] }));
|
|
501
503
|
}
|
|
502
504
|
SelectOptionComponent.displayName = 'Select.Option';
|
|
503
505
|
// =============================================================================
|
|
@@ -71,6 +71,10 @@ export type SelectProps = {
|
|
|
71
71
|
* @default false
|
|
72
72
|
*/
|
|
73
73
|
clearable?: boolean;
|
|
74
|
+
/** Accessible label for the clear button (i18n).
|
|
75
|
+
* @default "Clear selection"
|
|
76
|
+
*/
|
|
77
|
+
clearLabel?: string;
|
|
74
78
|
/**
|
|
75
79
|
* Accessible name for the select.
|
|
76
80
|
*/
|
|
@@ -169,6 +173,7 @@ export type SelectContextValue = {
|
|
|
169
173
|
disabled: boolean;
|
|
170
174
|
placeholder: string;
|
|
171
175
|
clearable: boolean;
|
|
176
|
+
clearLabel: string;
|
|
172
177
|
size: SizeStandard;
|
|
173
178
|
triggerId: string;
|
|
174
179
|
listboxId: string;
|
|
@@ -52,8 +52,12 @@ export const StepIndicator = memo(function StepIndicator(props) {
|
|
|
52
52
|
complete: labels.complete,
|
|
53
53
|
locked: labels.locked,
|
|
54
54
|
};
|
|
55
|
-
// Accessible label
|
|
56
|
-
const
|
|
55
|
+
// Accessible label — when a percentage is visible, it must be announced too
|
|
56
|
+
const showsValue = showValue && status === 'in-progress';
|
|
57
|
+
const ariaLabel = label ??
|
|
58
|
+
(showsValue
|
|
59
|
+
? labels.statusWithValue(statusLabelMap[status], Math.round(displayValue))
|
|
60
|
+
: labels.status(statusLabelMap[status]));
|
|
57
61
|
// Build class names
|
|
58
62
|
const rootClassName = [
|
|
59
63
|
'tui-step-indicator',
|
|
@@ -20,6 +20,9 @@ export type StepIndicatorLabels = {
|
|
|
20
20
|
locked?: string;
|
|
21
21
|
/** Full aria-label template. Receives the resolved status label string. */
|
|
22
22
|
status?: (statusLabel: string) => string;
|
|
23
|
+
/** aria-label template when a visible percentage is shown (showValue +
|
|
24
|
+
* in-progress) — the label must carry what the eye can see. */
|
|
25
|
+
statusWithValue?: (statusLabel: string, value: number) => string;
|
|
23
26
|
};
|
|
24
27
|
export declare const defaultStepIndicatorLabels: Required<StepIndicatorLabels>;
|
|
25
28
|
export type StepIndicatorProps = {
|
|
@@ -6,5 +6,8 @@ export function BulkActionsBar({ count, onClear, clearLabel = 'Clear', children,
|
|
|
6
6
|
const labels = { ...defaultBulkActionsBarLabels, ...labelsProp };
|
|
7
7
|
if (count === 0)
|
|
8
8
|
return null;
|
|
9
|
-
return (
|
|
9
|
+
return (
|
|
10
|
+
// role="group", not "toolbar" — toolbar implies roving arrow-key
|
|
11
|
+
// navigation these independently-focusable controls don't implement.
|
|
12
|
+
_jsxs("div", { role: "group", "aria-label": labels.actions(count), "aria-controls": ariaControls, className: cx('tui-table__bulkActions', className), children: [_jsx("span", { className: "tui-table__bulkActions__count", children: labels.selected(count) }), _jsxs("div", { className: "tui-table__bulkActions__actions", children: [children, onClear && (_jsx("button", { type: "button", onClick: onClear, className: "tui-table__bulkActions__clear tui-button is-style-outline is-size-xs", children: clearLabel }))] })] }));
|
|
10
13
|
}
|
|
@@ -31,7 +31,7 @@ enableRowSelection = false, getRowId, getRowLabelForSelection, onSelectionChange
|
|
|
31
31
|
const isAllSelected = table.getIsAllPageRowsSelected();
|
|
32
32
|
const isSomeSelected = table.getIsSomePageRowsSelected();
|
|
33
33
|
const isIndeterminate = isSomeSelected && !isAllSelected;
|
|
34
|
-
return (_jsx("input", { type: "checkbox", "aria-label": labels.selectAll,
|
|
34
|
+
return (_jsx("input", { type: "checkbox", "aria-label": labels.selectAll, checked: isAllSelected, ref: (el) => {
|
|
35
35
|
if (el)
|
|
36
36
|
el.indeterminate = isIndeterminate;
|
|
37
37
|
}, onChange: table.getToggleAllPageRowsSelectedHandler() }));
|
|
@@ -70,7 +70,7 @@ enableRowSelection = false, getRowId, getRowLabelForSelection, onSelectionChange
|
|
|
70
70
|
};
|
|
71
71
|
const isSelected = row.getIsSelected();
|
|
72
72
|
const isSomeSelected = row.getIsSomeSelected();
|
|
73
|
-
return (_jsx("input", { type: "checkbox", "aria-label": labelText,
|
|
73
|
+
return (_jsx("input", { type: "checkbox", "aria-label": labelText, checked: isSelected, ref: (el) => {
|
|
74
74
|
if (el)
|
|
75
75
|
el.indeterminate = isSomeSelected;
|
|
76
76
|
}, onChange: handleChange }));
|
|
@@ -157,7 +157,10 @@ enableRowSelection = false, getRowId, getRowLabelForSelection, onSelectionChange
|
|
|
157
157
|
prevPageRef.current = currentPageIndex;
|
|
158
158
|
prevSortRef.current = currentSorting;
|
|
159
159
|
}, [currentPageIndex, currentSorting, pageCount, columns, labels]);
|
|
160
|
-
return (
|
|
160
|
+
return (
|
|
161
|
+
// The container scrolls horizontally (overflow-x) — it must be keyboard
|
|
162
|
+
// reachable and named, or clipped content is mouse-only (WCAG 2.1.1).
|
|
163
|
+
_jsxs("div", { className: cx('tui-table-container', className), role: "region", tabIndex: 0, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children: [_jsx("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: "tui-visually-hidden", children: announcement }), showBulkBar && (renderBulkBar ? (renderBulkBar({
|
|
161
164
|
selectedRows,
|
|
162
165
|
selectedRowIds,
|
|
163
166
|
clearSelection: () => table.resetRowSelection(),
|
|
@@ -169,7 +172,7 @@ enableRowSelection = false, getRowId, getRowLabelForSelection, onSelectionChange
|
|
|
169
172
|
const headerContent = flexRender(headerDef, header.getContext());
|
|
170
173
|
// Use header string for aria-label, fallback to column id
|
|
171
174
|
const headerLabel = typeof headerDef === 'string' ? headerDef : header.id;
|
|
172
|
-
return (_jsx("th", { className: "tui-table__cell tui-table__cell--head", "aria-sort": canSort
|
|
175
|
+
return (_jsx("th", { scope: "col", className: "tui-table__cell tui-table__cell--head", "aria-sort": canSort
|
|
173
176
|
? sortDirection === 'asc'
|
|
174
177
|
? 'ascending'
|
|
175
178
|
: sortDirection === 'desc'
|
|
@@ -180,7 +183,7 @@ enableRowSelection = false, getRowId, getRowLabelForSelection, onSelectionChange
|
|
|
180
183
|
: sortDirection === 'desc'
|
|
181
184
|
? '▼'
|
|
182
185
|
: '' })] })) : (headerContent) }, header.id));
|
|
183
|
-
}) }, headerGroup.id))) }), _jsx("tbody", { className: "tui-table__body",
|
|
186
|
+
}) }, headerGroup.id))) }), _jsx("tbody", { className: "tui-table__body", children: loading ? (_jsx("tr", { className: "tui-table__row tui-table__row--loading", children: _jsx("td", { className: "tui-table__cell tui-table__cell--body", colSpan: table.getAllLeafColumns().length, children: loadingMessage }) })) : isEmpty ? (_jsx("tr", { className: "tui-table__row tui-table__row--empty", children: _jsx("td", { className: "tui-table__cell tui-table__cell--body", colSpan: table.getAllLeafColumns().length, role: "status", children: emptyMessage }) })) : (rows.map((row) => (_jsx("tr", { className: cx('tui-table__row', 'tui-table__row--body', row.getIsSelected() && 'is-selected'), "data-selected": row.getIsSelected() ? 'true' : 'false', children: row.getVisibleCells().map((cell) => (_jsx("td", { className: "tui-table__cell tui-table__cell--body", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id)))) })] }), renderPagination
|
|
184
187
|
? renderPagination(table)
|
|
185
188
|
: (_jsx(Pagination, { table: table, mode: paginationMode, showPager: showPager, maxNumbers: paginationMaxNumbers, navStyle: paginationNavStyle, pageSizeOptions: pageSizeOptions }))] }));
|
|
186
189
|
}
|