@tangible/ui 0.2.28 → 0.2.30
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/components/Accordion/Accordion.js +2 -1
- package/components/Avatar/Avatar.js +6 -2
- package/components/Button/types.d.ts +5 -5
- package/components/Chip/Chip.js +2 -1
- package/components/ChipGroup/ChipGroup.js +1 -1
- package/components/ChipGroup/types.d.ts +2 -1
- package/components/Chips/Chips.d.ts +2 -0
- package/components/Chips/Chips.js +2 -16
- package/components/ColorPicker/ColorField.d.ts +3 -3
- package/components/ColorPicker/ColorField.js +2 -1
- package/components/ColorPicker/ColorPicker.js +2 -1
- package/components/ColorPicker/usePointerDrag.d.ts +7 -0
- package/components/ColorPicker/usePointerDrag.js +15 -1
- package/components/Combobox/Combobox.js +3 -2
- package/components/ContentIndicator/types.d.ts +3 -3
- package/components/DatePicker/Calendar.js +4 -3
- package/components/DatePicker/DatePicker.js +3 -2
- package/components/DatePicker/PickerTrigger.js +2 -1
- package/components/DatePicker/types.d.ts +1 -1
- package/components/GradientPicker/GradientBar.js +3 -1
- package/components/GradientPicker/GradientPicker.js +4 -3
- package/components/Icon/Icon.d.ts +9 -2
- package/components/Icon/Icon.js +4 -3
- package/components/Icon/index.d.ts +1 -1
- package/components/IconButton/IconButton.js +13 -45
- package/components/IconButton/IconButtonCore.d.ts +9 -0
- package/components/IconButton/IconButtonCore.js +76 -0
- package/components/IconButton/types.d.ts +4 -3
- package/components/Modal/Modal.d.ts +12 -3
- package/components/Modal/Modal.js +38 -15
- package/components/MoveHandle/MoveHandle.js +3 -2
- package/components/MultiCombobox/MultiCombobox.js +3 -2
- package/components/MultiSelect/MultiSelect.js +3 -2
- package/components/NavMenu/NavMenu.js +2 -1
- package/components/NavMenu/types.d.ts +3 -3
- package/components/Notice/Notice.d.ts +7 -0
- package/components/Notice/Notice.js +6 -5
- package/components/Pager/Pager.js +5 -4
- package/components/Rating/Rating.js +2 -1
- package/components/SearchInput/SearchInput.js +3 -2
- package/components/SearchSelect/SearchSelect.js +3 -2
- package/components/SecretInput/SecretInput.js +3 -2
- package/components/Select/Select.js +3 -2
- package/components/Sidebar/Sidebar.js +2 -1
- package/components/StepIndicator/StepIndicator.js +4 -2
- package/components/StepIndicator/types.d.ts +2 -2
- package/components/StepList/types.d.ts +2 -2
- package/components/Tabs/types.d.ts +3 -3
- package/components/Toast/Toast.d.ts +5 -1
- package/components/Toast/Toast.js +3 -3
- package/components/Tooltip/Tooltip.d.ts +1 -1
- package/components/Tooltip/Tooltip.js +28 -6
- package/components/Tooltip/index.d.ts +1 -1
- package/components/Tooltip/types.d.ts +18 -0
- package/components/index.d.ts +2 -2
- package/figma-tokens.json +6 -4
- package/icons/cred/index.js +1 -0
- package/icons/icons.svg +7 -3
- package/icons/lms/index.d.ts +0 -3
- package/icons/lms/index.js +6 -33
- package/icons/manifest.json +71 -9
- package/icons/membersync/index.js +1 -0
- package/icons/player/index.js +1 -0
- package/icons/reaction/index.js +1 -0
- package/icons/registry.d.ts +14 -0
- package/icons/registry.js +7 -0
- package/icons/system/index.d.ts +11 -0
- package/icons/system/index.js +48 -0
- package/package.json +9 -2
- package/skills/building-with-tui/SKILL.md +249 -17
- package/styles/all.css +1 -1
- package/styles/all.expanded.css +127 -13
- package/styles/all.expanded.unlayered.css +127 -13
- package/styles/all.unlayered.css +1 -1
- package/styles/app.css +41 -0
- package/styles/components/_bundle.scss +2 -0
- package/styles/components/button.scss +6 -1
- package/styles/components/card.scss +17 -1
- package/styles/components/chip-group.scss +45 -28
- package/styles/components/chips.scss +21 -0
- package/styles/components/color-picker.scss +15 -1
- package/styles/components/gradient-picker.scss +2 -2
- package/styles/components/modal.scss +61 -0
- package/styles/components/tooltip.scss +8 -1
- package/styles/core.css +1 -1
- package/styles/core.unlayered.css +1 -1
- package/styles/system/_text-styles.scss +4 -0
- package/styles/system/_tokens.scss +7 -2
- package/styles/utilities/_index.scss +3 -0
- package/tui-manifest.json +46 -19
- package/utils/focus-trap.d.ts +1 -24
- package/utils/focus-trap.js +2 -65
- package/utils/scroll-lock.d.ts +4 -0
- package/utils/scroll-lock.js +25 -0
- package/utils/tabbable.d.ts +29 -0
- package/utils/tabbable.js +74 -0
- package/vanilla/modal.d.ts +37 -0
- package/vanilla/modal.js +453 -0
- package/vanilla/modal.min.js +1 -0
- package/vanilla/styles.css +1 -0
- package/vanilla/styles.unlayered.css +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect } from 'react';
|
|
3
|
+
import { cx } from '../../utils/cx.js';
|
|
4
|
+
import { Icon } from '../Icon/index.js';
|
|
5
|
+
import { getSafeRel } from '../../utils/polymorphic.js';
|
|
6
|
+
import { isDev } from '../../utils/is-dev.js';
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// IconButtonCore (@internal)
|
|
9
|
+
// =============================================================================
|
|
10
|
+
//
|
|
11
|
+
// IconButton without its tooltip, so it doesn't import Tooltip and
|
|
12
|
+
// @floating-ui (~39 KB min / 15 KB gzip). A module can't be tree-shaken on a
|
|
13
|
+
// prop value, so a static Tooltip import made every IconButton pay for it,
|
|
14
|
+
// including the many that never set `showTooltip` — Notice's dismiss ×,
|
|
15
|
+
// Calendar's month arrows.
|
|
16
|
+
//
|
|
17
|
+
// TUI components that never show the tooltip render this; eslint enforces the
|
|
18
|
+
// choice at each import (eslint.config.js). Consumers use IconButton, which
|
|
19
|
+
// wraps this and adds the tooltip when `showTooltip` is set. Not exported: a
|
|
20
|
+
// second public IconButton named after its implementation isn't an API. If
|
|
21
|
+
// consumers want the saving, the shape is a light IconButton they wrap in
|
|
22
|
+
// Tooltip themselves — a deliberate `showTooltip` deprecation, not this file.
|
|
23
|
+
//
|
|
24
|
+
// A component whose own props accept `showTooltip` (Sidebar.Toggle) must use
|
|
25
|
+
// IconButton: here the prop would do nothing. Stray tooltip props are dropped
|
|
26
|
+
// rather than reaching the DOM, with a dev warning.
|
|
27
|
+
//
|
|
28
|
+
// =============================================================================
|
|
29
|
+
export const IconButtonCore = forwardRef((props, ref) => {
|
|
30
|
+
const { icon, label, size = 'sm', theme = 'secondary', variant = 'ghost', disabled = false, loading = false, loadingLabel: loadingLabelProp, pressed, shape = 'square', className, ...restWithStray } = props;
|
|
31
|
+
const stray = restWithStray;
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
const { showTooltip: strayShowTooltip, tooltipSide: _tooltipSide, ...rest } = stray;
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (isDev() && strayShowTooltip) {
|
|
36
|
+
console.warn(`IconButtonCore ("${label}"): \`showTooltip\` does nothing here. A component that offers the tooltip must render IconButton.`);
|
|
37
|
+
}
|
|
38
|
+
}, [strayShowTooltip, label]);
|
|
39
|
+
const isLink = typeof rest.href === 'string';
|
|
40
|
+
const isDisabled = disabled || loading;
|
|
41
|
+
// Loading keeps focus (see Button): aria-disabled plus a click guard, never
|
|
42
|
+
// native `disabled` or a dropped href. Only explicit `disabled` goes native.
|
|
43
|
+
const loadingOnly = loading && !disabled;
|
|
44
|
+
const resolvedLabel = loading ? (loadingLabelProp ?? `${label}, loading`) : label;
|
|
45
|
+
const classes = cx('tui-icon-button', `is-size-${size}`, `is-theme-${theme}`, `is-style-${variant}`, isDisabled && 'is-disabled', shape === 'circle' && 'is-shape-circle', className);
|
|
46
|
+
const iconContent = (_jsxs(_Fragment, { children: [_jsx(Icon, { name: icon }), loading && _jsx("span", { className: "tui-icon-button__spinner", "aria-hidden": "true" })] }));
|
|
47
|
+
// Render the base element (button or anchor)
|
|
48
|
+
let element;
|
|
49
|
+
if (isLink) {
|
|
50
|
+
const { href, target, rel, tabIndex, onClick, ...anchorRest } = rest;
|
|
51
|
+
const safeRel = getSafeRel(target, rel);
|
|
52
|
+
const handleClick = (e) => {
|
|
53
|
+
if (isDisabled) {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
onClick?.(e);
|
|
59
|
+
};
|
|
60
|
+
element = (_jsx("a", { ref: ref, href: disabled ? undefined : href, className: classes, "aria-label": resolvedLabel, "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, tabIndex: disabled ? -1 : tabIndex, onClick: handleClick, target: target, rel: safeRel, ...anchorRest, children: iconContent }));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const { onClick, ...buttonRest } = rest;
|
|
64
|
+
const handleButtonClick = (e) => {
|
|
65
|
+
if (loadingOnly) {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
onClick?.(e);
|
|
71
|
+
};
|
|
72
|
+
element = (_jsx("button", { ref: ref, type: buttonRest.type ?? 'button', className: classes, "aria-label": resolvedLabel, disabled: disabled, "aria-disabled": loadingOnly || undefined, "aria-busy": loading || undefined, "aria-pressed": pressed, onClick: handleButtonClick, ...buttonRest, children: iconContent }));
|
|
73
|
+
}
|
|
74
|
+
return element;
|
|
75
|
+
});
|
|
76
|
+
IconButtonCore.displayName = 'IconButtonCore';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IconSource } from '../Icon/Icon';
|
|
2
2
|
import type { Size, ThemeIntent, ThemeStatus } from '../../types';
|
|
3
3
|
export type { Size };
|
|
4
4
|
export type Theme = ThemeIntent | ThemeStatus;
|
|
@@ -6,10 +6,11 @@ export type Variant = 'solid' | 'outline' | 'ghost';
|
|
|
6
6
|
export type Shape = 'square' | 'circle';
|
|
7
7
|
type IconButtonBaseProps = {
|
|
8
8
|
/**
|
|
9
|
-
* Icon to display. Required — this is
|
|
9
|
+
* Icon to display: a registry path or an icon component. Required — this is
|
|
10
|
+
* the button's visual content.
|
|
10
11
|
* @example icon="system/close"
|
|
11
12
|
*/
|
|
12
|
-
icon:
|
|
13
|
+
icon: IconSource;
|
|
13
14
|
/**
|
|
14
15
|
* Accessible label. Required — icon-only buttons must have a label
|
|
15
16
|
* for screen readers since there's no visible text.
|
|
@@ -25,8 +25,9 @@ export type ModalProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'role' | 'ar
|
|
|
25
25
|
* backdrop stops dismissing on click unless `closeOnBackdropClick` says otherwise, since a
|
|
26
26
|
* stray click outside is not a response. Escape still closes: it is the keyboard "cancel".
|
|
27
27
|
*
|
|
28
|
-
* Initial focus lands on the first focusable element in DOM order
|
|
29
|
-
* `initialFocusSelector` says otherwise), and the APG wants that to be
|
|
28
|
+
* Initial focus lands on the first focusable element in DOM order, skipping the built-in
|
|
29
|
+
* close button (unless `initialFocusSelector` says otherwise), and the APG wants that to be
|
|
30
|
+
* the safest action —
|
|
30
31
|
* so put Cancel before the destructive action in `Modal.Foot`. If the visual order must
|
|
31
32
|
* differ (`Modal.Foot justify="between"` with a destructive action first), point
|
|
32
33
|
* `initialFocusSelector` at the safe one.
|
|
@@ -44,12 +45,20 @@ export type ModalProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'role' | 'ar
|
|
|
44
45
|
* when focus is restored on close. Useful when the trigger may be off-screen
|
|
45
46
|
* inside a scrollable container. Default: false. */
|
|
46
47
|
preventScrollOnRestore?: boolean;
|
|
48
|
+
/** Where focus goes on close, read at close time. Defaults to whatever had
|
|
49
|
+
* focus when the modal opened. Set it when that element can be gone by then:
|
|
50
|
+
* a "Delete" in a list row whose confirm removes the row. Point it at the
|
|
51
|
+
* next row, the list heading or the "Add" button. A function suits a target
|
|
52
|
+
* that only exists by close time (the row after the deleted one). If neither
|
|
53
|
+
* this nor the captured element can take focus, focus falls to <body> and a
|
|
54
|
+
* dev warning names this prop (WCAG 2.4.3). */
|
|
55
|
+
restoreFocusTo?: React.RefObject<HTMLElement | null> | (() => HTMLElement | null);
|
|
47
56
|
/** Additional class names applied to the dialog element (`.tui-modal__dialog`).
|
|
48
57
|
* Use for layout tweaks, custom widths, or context-specific theming. */
|
|
49
58
|
className?: string;
|
|
50
59
|
children?: React.ReactNode;
|
|
51
60
|
};
|
|
52
|
-
declare function ModalRoot({ open, onClose, size, stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, role, initialFocusSelector, container, showCloseButton, closeLabel, closeOnBackdropClick, closeOnEscape, preventScrollOnRestore, className, children, ...rest }: ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
61
|
+
declare function ModalRoot({ open, onClose, size, stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, role, initialFocusSelector, container, showCloseButton, closeLabel, closeOnBackdropClick, closeOnEscape, preventScrollOnRestore, restoreFocusTo, className, children, ...rest }: ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
53
62
|
type ModalCloseProps = {
|
|
54
63
|
label?: string;
|
|
55
64
|
className?: string;
|
|
@@ -4,11 +4,13 @@ import { createPortal } from 'react-dom';
|
|
|
4
4
|
import { cx } from '../../utils/cx.js';
|
|
5
5
|
import { isDev } from '../../utils/is-dev.js';
|
|
6
6
|
import { getPortalRootFor } from '../../utils/portal.js';
|
|
7
|
+
import { lockScroll, unlockScroll } from '../../utils/scroll-lock.js';
|
|
7
8
|
import { useFocusTrap, getInitialFocus } from '../../utils/focus-trap.js';
|
|
8
9
|
import { ModalContext, useModalContext } from './context.js';
|
|
9
10
|
import { IconButton } from '../IconButton/index.js';
|
|
11
|
+
import { Close as CloseIcon } from '../../icons/system/index.js';
|
|
10
12
|
const isBrowser = typeof document !== 'undefined';
|
|
11
|
-
function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, role = 'dialog', initialFocusSelector, container, showCloseButton, closeLabel = 'Close', closeOnBackdropClick, closeOnEscape = true, preventScrollOnRestore = false, className, children, ...rest }) {
|
|
13
|
+
function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, role = 'dialog', initialFocusSelector, container, showCloseButton, closeLabel = 'Close', closeOnBackdropClick, closeOnEscape = true, preventScrollOnRestore = false, restoreFocusTo, className, children, ...rest }) {
|
|
12
14
|
const dialogRef = useRef(null);
|
|
13
15
|
const anchorRef = useRef(null);
|
|
14
16
|
const restoreRef = useRef(null);
|
|
@@ -110,28 +112,48 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
|
|
|
110
112
|
'hidden container, or pass an explicit `container`.', buried);
|
|
111
113
|
}
|
|
112
114
|
}, [open, mount]);
|
|
113
|
-
// Read at close time, not
|
|
115
|
+
// Read at close time, not dependencies: the effect must run on close only.
|
|
114
116
|
const preventScrollOnRestoreRef = useRef(preventScrollOnRestore);
|
|
115
117
|
preventScrollOnRestoreRef.current = preventScrollOnRestore;
|
|
116
|
-
|
|
118
|
+
const restoreFocusToRef = useRef(restoreFocusTo);
|
|
119
|
+
restoreFocusToRef.current = restoreFocusTo;
|
|
120
|
+
// Reset state when modal closes, restore focus: `restoreFocusTo` first, then
|
|
121
|
+
// whatever had focus at open. Each must still be in the document and
|
|
122
|
+
// actually take focus; a removed trigger's focus() is a silent no-op (#133).
|
|
117
123
|
useEffect(() => {
|
|
118
124
|
if (open)
|
|
119
125
|
return;
|
|
120
|
-
const
|
|
121
|
-
if (el && typeof el.focus === 'function') {
|
|
122
|
-
el.focus({ preventScroll: preventScrollOnRestoreRef.current });
|
|
123
|
-
}
|
|
126
|
+
const captured = restoreRef.current;
|
|
124
127
|
restoreRef.current = null;
|
|
125
128
|
setMount(null);
|
|
129
|
+
if (!captured)
|
|
130
|
+
return; // no open cycle to close
|
|
131
|
+
const target = restoreFocusToRef.current;
|
|
132
|
+
const explicit = typeof target === 'function' ? target() : target?.current ?? null;
|
|
133
|
+
const candidates = [explicit, captured];
|
|
134
|
+
for (const el of candidates) {
|
|
135
|
+
if (!el || !el.isConnected || el === document.body)
|
|
136
|
+
continue;
|
|
137
|
+
el.focus({ preventScroll: preventScrollOnRestoreRef.current });
|
|
138
|
+
if (document.activeElement === el)
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// Only when a real target was lost. On WebKit a click doesn't focus the
|
|
142
|
+
// trigger, so `captured` is often <body> for an ordinary close; warning
|
|
143
|
+
// there would teach consumers to ignore the message.
|
|
144
|
+
if (isDev() && (explicit || captured !== document.body)) {
|
|
145
|
+
console.warn('[TUI Modal] Focus had nowhere to return on close: the element focused at open is ' +
|
|
146
|
+
'gone or can\'t take focus, so focus fell to <body> (WCAG 2.4.3). Pass `restoreFocusTo` ' +
|
|
147
|
+
'with an element that will still be there, such as the next row or the list heading.');
|
|
148
|
+
}
|
|
126
149
|
}, [open]);
|
|
127
|
-
// Body scroll lock
|
|
150
|
+
// Body scroll lock, counted, so closing this modal doesn't unlock the page
|
|
151
|
+
// under another one (nested, or a vanilla modal open alongside).
|
|
128
152
|
useEffect(() => {
|
|
129
153
|
if (!open)
|
|
130
154
|
return;
|
|
131
|
-
|
|
132
|
-
return
|
|
133
|
-
document.body.classList.remove('tui-modal-open');
|
|
134
|
-
};
|
|
155
|
+
lockScroll();
|
|
156
|
+
return unlockScroll;
|
|
135
157
|
}, [open]);
|
|
136
158
|
// Inert sibling trees so screen readers cannot escape the dialog.
|
|
137
159
|
// aria-modal alone is unreliable — NVDA/JAWS virtual cursor can still
|
|
@@ -188,7 +210,8 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
|
|
|
188
210
|
}
|
|
189
211
|
}
|
|
190
212
|
if (!target) {
|
|
191
|
-
|
|
213
|
+
// The close button only when nothing else can take focus (#135).
|
|
214
|
+
target = getInitialFocus(dialog, undefined, { lastResort: '.tui-modal__close' });
|
|
192
215
|
}
|
|
193
216
|
target.focus({ preventScroll: true });
|
|
194
217
|
// Development warning for missing labelledBy target
|
|
@@ -216,11 +239,11 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
|
|
|
216
239
|
// Unmounts on the very next render (pre-paint), so it never lays anything out.
|
|
217
240
|
if (!mount)
|
|
218
241
|
return _jsx("span", { ref: anchorRef, hidden: true });
|
|
219
|
-
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: backdropDismisses ? onClose : undefined }), _jsxs("div", { ref: dialogRef, role: role, "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:
|
|
242
|
+
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: backdropDismisses ? onClose : undefined }), _jsxs("div", { ref: dialogRef, role: role, "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: [children, showCloseButton && (_jsx(IconButton, { icon: CloseIcon, label: closeLabel, variant: "ghost", size: "sm", onClick: onClose, className: "tui-modal__close", showTooltip: true }))] })] }) }), mount);
|
|
220
243
|
}
|
|
221
244
|
function ModalClose({ label = 'Close', className }) {
|
|
222
245
|
const { onClose } = useModalContext();
|
|
223
|
-
return (_jsx(IconButton, { icon:
|
|
246
|
+
return (_jsx(IconButton, { icon: CloseIcon, label: label, variant: "ghost", size: "sm", onClick: onClose, className: cx('tui-modal__close', className), showTooltip: true }));
|
|
224
247
|
}
|
|
225
248
|
ModalClose.displayName = 'Modal.Close';
|
|
226
249
|
function ModalHead({ className, children, subtitle, icon, ...rest }) {
|
|
@@ -3,6 +3,7 @@ import { forwardRef, memo, useCallback, useEffect, useId, useRef, useState } fro
|
|
|
3
3
|
import { cx } from '../../utils/cx.js';
|
|
4
4
|
import { isDev } from '../../utils/is-dev.js';
|
|
5
5
|
import { Icon } from '../Icon/index.js';
|
|
6
|
+
import { ChevronDown as ChevronDownIcon, ChevronUp as ChevronUpIcon, Drag as DragIcon, HandleAlt as HandleAltIcon, LockFill as LockFillIcon } from '../../icons/system/index.js';
|
|
6
7
|
// =============================================================================
|
|
7
8
|
// MoveHandle Component
|
|
8
9
|
// =============================================================================
|
|
@@ -97,7 +98,7 @@ export const MoveHandle = memo(forwardRef(function MoveHandle({ mode = 'full', s
|
|
|
97
98
|
// Uses ref directly (not mergedRef) — innerRef is unused for this path.
|
|
98
99
|
// Focus recovery and dev warning effects early-return for handle mode.
|
|
99
100
|
if (mode === 'handle') {
|
|
100
|
-
return (_jsx("button", { ref: ref, type: "button", className: cx('tui-move-handle', 'is-handle', `is-size-${size}`, className), "aria-label": resolvedDragLabel, ...restDragProps, children: _jsx(Icon, { name:
|
|
101
|
+
return (_jsx("button", { ref: ref, type: "button", className: cx('tui-move-handle', 'is-handle', `is-size-${size}`, className), "aria-label": resolvedDragLabel, ...restDragProps, children: _jsx(Icon, { name: DragIcon }) }));
|
|
101
102
|
}
|
|
102
103
|
// ----- Full / arrows mode -----
|
|
103
104
|
const isArrows = mode === 'arrows';
|
|
@@ -113,5 +114,5 @@ export const MoveHandle = memo(forwardRef(function MoveHandle({ mode = 'full', s
|
|
|
113
114
|
return (_jsxs("div", { ref: mergedRef, role: "group", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": locked ? lockedDescId : undefined, "aria-disabled": locked || undefined,
|
|
114
115
|
// Focus-recovery target for arrows mode (see the effect above). Not in
|
|
115
116
|
// the tab order; only reached programmatically.
|
|
116
|
-
tabIndex: isArrows ? -1 : undefined, className: cx('tui-move-handle', `is-size-${size}`, isArrows && 'is-arrows', locked && 'is-locked', hasIndex && 'has-index', className), children: [locked && (_jsx("span", { id: lockedDescId, className: "tui-visually-hidden", children: resolvedLockedDesc })), onMoveUp && (_jsx("button", { type: "button", className: "tui-move-handle__up", "data-direction": "up", "aria-label": labels?.moveUp ?? 'Move up', disabled: locked || !canMoveUp, onClick: onMoveUp, children: _jsx(Icon, { name:
|
|
117
|
+
tabIndex: isArrows ? -1 : undefined, className: cx('tui-move-handle', `is-size-${size}`, isArrows && 'is-arrows', locked && 'is-locked', hasIndex && 'has-index', className), children: [locked && (_jsx("span", { id: lockedDescId, className: "tui-visually-hidden", children: resolvedLockedDesc })), onMoveUp && (_jsx("button", { type: "button", className: "tui-move-handle__up", "data-direction": "up", "aria-label": labels?.moveUp ?? 'Move up', disabled: locked || !canMoveUp, onClick: onMoveUp, children: _jsx(Icon, { name: ChevronUpIcon }) })), showCenter && isArrows && (_jsx("div", { className: "tui-move-handle__center", children: _jsx("span", { className: "tui-move-handle__index", "aria-hidden": "true", children: index }) })), showCenter && !isArrows && (_jsx("div", { className: "tui-move-handle__center", children: showLockIcon ? (_jsx("span", { className: "tui-move-handle__lock", "aria-hidden": "true", children: _jsx(Icon, { name: LockFillIcon }) })) : (_jsxs(_Fragment, { children: [hasIndex && (_jsx("span", { className: "tui-move-handle__index", "aria-hidden": "true", children: index })), _jsx("button", { type: "button", className: "tui-move-handle__handle", "data-role": "drag-handle", "aria-label": resolvedDragLabel, tabIndex: hasArrows ? -1 : 0, ...restDragProps, children: _jsx(Icon, { name: HandleAltIcon }) })] })) })), onMoveDown && (_jsx("button", { type: "button", className: "tui-move-handle__down", "data-direction": "down", "aria-label": labels?.moveDown ?? 'Move down', disabled: locked || !canMoveDown, onClick: onMoveDown, children: _jsx(Icon, { name: ChevronDownIcon }) }))] }));
|
|
117
118
|
}));
|
|
@@ -10,6 +10,7 @@ import { Icon } from '../Icon/index.js';
|
|
|
10
10
|
import { Chip } from '../Chip/index.js';
|
|
11
11
|
import { MultiComboboxActionsContext, MultiComboboxStateContext, MultiComboboxContentContext, useMultiComboboxContext, useMultiComboboxContentContext, } from './MultiComboboxContext.js';
|
|
12
12
|
import { defaultMultiComboboxLabels } from './types.js';
|
|
13
|
+
import { Check as CheckIcon, ChevronDown as ChevronDownIcon, Close as CloseIcon } from '../../icons/system/index.js';
|
|
13
14
|
// Stable empty value so an unset controlled `value` doesn't churn identity
|
|
14
15
|
// (which would re-run isSelected/state memos every render).
|
|
15
16
|
const EMPTY_VALUE = [];
|
|
@@ -389,7 +390,7 @@ function MultiComboboxRoot({ value: controlledValue, defaultValue, onValueChange
|
|
|
389
390
|
return (_jsx(Chip, { className: "tui-multicombobox__chip", disabled: disabled, removeLabel: labels.remove(label), onRemove: () => removeValue(v), children: label }, toKey(v)));
|
|
390
391
|
}), _jsx("input", { ref: (node) => {
|
|
391
392
|
inputRef.current = node;
|
|
392
|
-
}, type: "text", id: inputId, className: cx('tui-multicombobox__input', inputClassName), role: "combobox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "aria-autocomplete": "list", "aria-activedescendant": activeOptionId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, disabled: disabled, placeholder: hasValue ? undefined : placeholder, value: inputValue, autoComplete: "off", ...referenceProps, onChange: handleInputChange })] }), clearable && hasValue && !disabled && (_jsx("button", { type: "button", className: "tui-multicombobox__clear", onClick: handleClear, onMouseDown: (e) => e.preventDefault(), "aria-label": labels.clear, tabIndex: -1, children: _jsx(Icon, { name:
|
|
393
|
+
}, type: "text", id: inputId, className: cx('tui-multicombobox__input', inputClassName), role: "combobox", "aria-expanded": open, "aria-controls": open ? listboxId : undefined, "aria-autocomplete": "list", "aria-activedescendant": activeOptionId, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, disabled: disabled, placeholder: hasValue ? undefined : placeholder, value: inputValue, autoComplete: "off", ...referenceProps, onChange: handleInputChange })] }), clearable && hasValue && !disabled && (_jsx("button", { type: "button", className: "tui-multicombobox__clear", onClick: handleClear, onMouseDown: (e) => e.preventDefault(), "aria-label": labels.clear, tabIndex: -1, children: _jsx(Icon, { name: CloseIcon }) })), _jsx("span", { className: "tui-multicombobox__icon", "aria-hidden": "true", children: _jsx(Icon, { name: ChevronDownIcon }) })] }), children, _jsx("div", { className: "tui-visually-hidden", role: "status", children: labels.status(value.length, max) })] }) }) }));
|
|
393
394
|
}
|
|
394
395
|
MultiComboboxRoot.displayName = 'MultiCombobox';
|
|
395
396
|
// =============================================================================
|
|
@@ -457,7 +458,7 @@ function MultiComboboxOptionComponent({ value: optionValue, disabled = false, te
|
|
|
457
458
|
const itemProps = getItemProps({
|
|
458
459
|
onClick: handleClick,
|
|
459
460
|
});
|
|
460
|
-
return (_jsxs("div", { ref: ref, id: optionId, role: "option", className: cx('tui-multicombobox__option', className), "aria-selected": selected, "aria-disabled": blocked || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": blocked || undefined, "data-selected": selected || undefined, ...itemProps, onPointerDown: composeEventHandlers(handlePointerDown, itemProps.onPointerDown), children: [_jsx("span", { className: "tui-multicombobox__option-check", "aria-hidden": "true", children: selected && _jsx(Icon, { name:
|
|
461
|
+
return (_jsxs("div", { ref: ref, id: optionId, role: "option", className: cx('tui-multicombobox__option', className), "aria-selected": selected, "aria-disabled": blocked || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": blocked || undefined, "data-selected": selected || undefined, ...itemProps, onPointerDown: composeEventHandlers(handlePointerDown, itemProps.onPointerDown), children: [_jsx("span", { className: "tui-multicombobox__option-check", "aria-hidden": "true", children: selected && _jsx(Icon, { name: CheckIcon }) }), _jsx("span", { className: "tui-multicombobox__option-content", children: children })] }));
|
|
461
462
|
}
|
|
462
463
|
MultiComboboxOptionComponent.displayName = 'MultiCombobox.Option';
|
|
463
464
|
// =============================================================================
|
|
@@ -9,6 +9,7 @@ import { Icon } from '../Icon/index.js';
|
|
|
9
9
|
import { Chip } from '../Chip/index.js';
|
|
10
10
|
import { MultiSelectActionsContext, MultiSelectStateContext, MultiSelectContentContext, useMultiSelectContext, useMultiSelectContentContext, } from './MultiSelectContext.js';
|
|
11
11
|
import { toKey, defaultMultiSelectLabels, } from './types.js';
|
|
12
|
+
import { Check as CheckIcon, ChevronDown as ChevronDownIcon, Close as CloseIcon } from '../../icons/system/index.js';
|
|
12
13
|
// =============================================================================
|
|
13
14
|
// MultiSelect Root
|
|
14
15
|
// =============================================================================
|
|
@@ -368,7 +369,7 @@ function MultiSelectTriggerComponent({ asChild = false, className, children, })
|
|
|
368
369
|
return (_jsxs("span", { className: "tui-multiselect__chips", children: [visibleChips.map((opt) => (_jsx(Chip, { className: "tui-multiselect__chip", children: opt.textValue }, toKey(opt.value)))), overflow > 0 && (_jsx("span", { className: "tui-multiselect__more", children: labels.more(overflow) }))] }));
|
|
369
370
|
};
|
|
370
371
|
// Default trigger content (when not using asChild or custom children)
|
|
371
|
-
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:
|
|
372
|
+
const defaultTriggerContent = (_jsxs(_Fragment, { children: [_jsx("span", { className: "tui-multiselect__value", children: renderTriggerContent() }), hasSelection && (_jsx("span", { className: "tui-multiselect__clear", onClick: handleClearClick, "aria-hidden": "true", children: _jsx(Icon, { name: CloseIcon }) })), _jsx(Icon, { name: ChevronDownIcon, className: "tui-multiselect__icon", "aria-hidden": "true" })] }));
|
|
372
373
|
// Generate status message for screen readers
|
|
373
374
|
const statusMessage = labels.status(selectedOptions.length, max);
|
|
374
375
|
// Live region (rendered outside button, sibling to trigger)
|
|
@@ -544,7 +545,7 @@ function MultiSelectOptionComponent({ value: optionValue, disabled = false, text
|
|
|
544
545
|
return (_jsxs("div", { ref: ref, id: optionIdForIndex(listboxId, index), role: "option", className: cx('tui-multiselect__option', className), "aria-selected": selected, "aria-disabled": !isSelectable || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": disabled || undefined, "data-blocked": isBlocked || undefined, ...getItemProps({
|
|
545
546
|
onClick: isSelectable ? handleClick : undefined,
|
|
546
547
|
onPointerDown: handlePointerDown,
|
|
547
|
-
}), children: [_jsx("span", { className: cx('tui-multiselect__checkbox', selected && 'is-checked'), "aria-hidden": "true", children: selected && _jsx(Icon, { name:
|
|
548
|
+
}), children: [_jsx("span", { className: cx('tui-multiselect__checkbox', selected && 'is-checked'), "aria-hidden": "true", children: selected && _jsx(Icon, { name: CheckIcon, size: "xs" }) }), _jsx("span", { className: "tui-multiselect__option-content", children: children })] }));
|
|
548
549
|
}
|
|
549
550
|
MultiSelectOptionComponent.displayName = 'MultiSelect.Option';
|
|
550
551
|
// =============================================================================
|
|
@@ -8,6 +8,7 @@ import { composeRefs, getElementRef } from '../../utils/compose-refs.js';
|
|
|
8
8
|
import { Icon } from '../Icon/index.js';
|
|
9
9
|
import { createHoverWarmth, isWarm, markClosed, markOpen, sampleHoverIntent } from '../../utils/hover-intent.js';
|
|
10
10
|
import { defaultNavMenuLabels } from './types.js';
|
|
11
|
+
import { ChevronDownSmall as ChevronDownSmallIcon } from '../../icons/system/index.js';
|
|
11
12
|
// Hover intent and warmth come from utils/hover-intent (shared with tooltips).
|
|
12
13
|
// A panel opens when the pointer settles, not after a fixed delay; once the
|
|
13
14
|
// bar is warm (a panel open, or one closed within PRIMED_WINDOW) the next
|
|
@@ -349,7 +350,7 @@ const NavMenuItem = forwardRef(function NavMenuItem(props, ref) {
|
|
|
349
350
|
// name ("Inbox 3 unread", not "Inbox3 unread"). A flex container doesn't
|
|
350
351
|
// render whitespace-only text, so layout is unaffected.
|
|
351
352
|
const content = (inner) => (_jsxs(_Fragment, { children: [leading, leading && prefix != null && ' ', _jsx("span", { className: "tui-nav-menu__label", id: flyout ? labelId : undefined, children: inner }), suffix != null && (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "tui-nav-menu__suffix", ref: suffixRef, children: suffix })] }))] }));
|
|
352
|
-
const chevron = (_jsx("span", { className: "tui-nav-menu__chevron", "aria-hidden": "true", children: _jsx(Icon, { name:
|
|
353
|
+
const chevron = (_jsx("span", { className: "tui-nav-menu__chevron", "aria-hidden": "true", children: _jsx(Icon, { name: ChevronDownSmallIcon }) }));
|
|
353
354
|
let row;
|
|
354
355
|
// A flyout parent with no destination of its own: the row IS the toggle.
|
|
355
356
|
const rowIsToggle = flyout && !asChild && props.href === undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IconSource } from '../Icon/Icon';
|
|
3
3
|
export type NavMenuOrientation = 'vertical' | 'horizontal';
|
|
4
4
|
export type NavMenuFlyoutTrigger = 'click' | 'hover';
|
|
5
5
|
/** Visually hidden strings, for localisation. */
|
|
@@ -71,8 +71,8 @@ export type NavMenuCurrent = boolean | 'page' | 'step' | 'location' | 'date' | '
|
|
|
71
71
|
type NavMenuItemBaseProps = {
|
|
72
72
|
/** Marks the current item; see {@link NavMenuCurrent}. */
|
|
73
73
|
current?: NavMenuCurrent;
|
|
74
|
-
/** Leading icon
|
|
75
|
-
icon?:
|
|
74
|
+
/** Leading icon: a registry path or an icon component. Sized by `--tui-nav-menu-icon-size`. */
|
|
75
|
+
icon?: IconSource;
|
|
76
76
|
/**
|
|
77
77
|
* Custom leading content in the icon's place (an avatar, a glyph not in the
|
|
78
78
|
* registry). Replaces `icon` when both are set. Unlike `icon`, it isn't
|
|
@@ -48,6 +48,13 @@ export type NoticeProps<TAs extends RootAs = 'section'> = CommonProps & {
|
|
|
48
48
|
dismissible?: boolean;
|
|
49
49
|
onDismiss?: () => void;
|
|
50
50
|
dismissLabel?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Announced to screen readers after the dismiss button removes the notice
|
|
53
|
+
* (not on a programmatic `exit()`). Default 'Notification dismissed'.
|
|
54
|
+
* Override it to translate. If Notice gains more built-in strings, move
|
|
55
|
+
* this and `dismissLabel` into a `labels` object together.
|
|
56
|
+
*/
|
|
57
|
+
dismissedMessage?: string;
|
|
51
58
|
/**
|
|
52
59
|
* Exit animation to play when dismissed.
|
|
53
60
|
* - none: onDismiss called immediately (default)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { forwardRef, useId, useMemo, useState, useRef, useImperativeHandle, useCallback, useEffect, useLayoutEffect, useContext, createContext } from 'react';
|
|
3
3
|
import { cx } from '../../utils/cx.js';
|
|
4
|
-
import {
|
|
4
|
+
import { IconButtonCore } from '../IconButton/IconButtonCore.js';
|
|
5
|
+
import { Close as CloseIcon } from '../../icons/system/index.js';
|
|
5
6
|
const NoticeContext = createContext(null);
|
|
6
7
|
/** Check if user prefers reduced motion */
|
|
7
8
|
function prefersReducedMotion() {
|
|
@@ -9,7 +10,7 @@ function prefersReducedMotion() {
|
|
|
9
10
|
return false;
|
|
10
11
|
return window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
11
12
|
}
|
|
12
|
-
export const Notice = forwardRef(function Notice({ as = 'section', inline, elevated, interactive, disabled, stripe, size, className, style, onClick, theme = 'info', announce = 'off', 'aria-label': ariaLabel, dismissible, onDismiss, dismissLabel = 'Dismiss', exitAnimation = 'none', focusable, children, ...rest }, ref) {
|
|
13
|
+
export const Notice = forwardRef(function Notice({ as = 'section', inline, elevated, interactive, disabled, stripe, size, className, style, onClick, theme = 'info', announce = 'off', 'aria-label': ariaLabel, dismissible, onDismiss, dismissLabel = 'Dismiss', dismissedMessage = 'Notification dismissed', exitAnimation = 'none', focusable, children, ...rest }, ref) {
|
|
13
14
|
const Tag = as;
|
|
14
15
|
const innerRef = useRef(null);
|
|
15
16
|
const [isExiting, setIsExiting] = useState(false);
|
|
@@ -87,10 +88,10 @@ export const Notice = forwardRef(function Notice({ as = 'section', inline, eleva
|
|
|
87
88
|
el.style.cssText =
|
|
88
89
|
'position:absolute;width:1px;height:1px;padding:0;margin:-1px;' +
|
|
89
90
|
'overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;';
|
|
90
|
-
el.textContent =
|
|
91
|
+
el.textContent = dismissedMessage;
|
|
91
92
|
document.body.appendChild(el);
|
|
92
93
|
setTimeout(() => el.remove(), 1000);
|
|
93
|
-
}, []);
|
|
94
|
+
}, [dismissedMessage]);
|
|
94
95
|
// Handle dismiss button click
|
|
95
96
|
const handleDismiss = useCallback(async () => {
|
|
96
97
|
if (disabled)
|
|
@@ -128,7 +129,7 @@ export const Notice = forwardRef(function Notice({ as = 'section', inline, eleva
|
|
|
128
129
|
const computedAriaLabel = hasTitle ? undefined : (ariaLabel || undefined);
|
|
129
130
|
const classes = cx('tui-notice', `is-theme-${theme}`, size && size !== 'md' && `is-size-${size}`, inline && 'is-layout-inline', elevated && 'is-style-elevated', interactive && 'has-interaction', disabled && 'is-disabled', stripe && 'has-stripe', dismissible && 'is-dismissible', focusable && 'is-focusable', isExiting && exitType && `is-exiting-${exitType}`, className);
|
|
130
131
|
// Dismiss button component
|
|
131
|
-
const dismissButton = dismissible && (_jsx(
|
|
132
|
+
const dismissButton = dismissible && (_jsx(IconButtonCore, { icon: CloseIcon, label: dismissLabel, size: "sm", variant: "ghost", className: "tui-notice__dismiss", onClick: (e) => {
|
|
132
133
|
e.stopPropagation();
|
|
133
134
|
handleDismiss();
|
|
134
135
|
}, disabled: disabled || isExiting }));
|
|
@@ -4,6 +4,7 @@ import { cx } from '../../utils/cx.js';
|
|
|
4
4
|
import { Button } from '../Button/index.js';
|
|
5
5
|
import { IconButton } from '../IconButton/index.js';
|
|
6
6
|
import { defaultPagerLabels } from './types.js';
|
|
7
|
+
import { ChevronLeft as ChevronLeftIcon, ChevronLeftDouble as ChevronLeftDoubleIcon, ChevronRight as ChevronRightIcon, ChevronRightDouble as ChevronRightDoubleIcon } from '../../icons/system/index.js';
|
|
7
8
|
// =============================================================================
|
|
8
9
|
// Pager Component
|
|
9
10
|
// =============================================================================
|
|
@@ -23,10 +24,10 @@ const DEFAULT_MAX_SLOTS = 7;
|
|
|
23
24
|
* would not have been.
|
|
24
25
|
*/
|
|
25
26
|
const NAV_ICONS = {
|
|
26
|
-
first:
|
|
27
|
-
prev:
|
|
28
|
-
next:
|
|
29
|
-
last:
|
|
27
|
+
first: ChevronLeftDoubleIcon,
|
|
28
|
+
prev: ChevronLeftIcon,
|
|
29
|
+
next: ChevronRightIcon,
|
|
30
|
+
last: ChevronRightDoubleIcon,
|
|
30
31
|
};
|
|
31
32
|
/**
|
|
32
33
|
* Build a stable-width list of page tokens (numbers + ellipses).
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { cx } from '../../utils/cx.js';
|
|
4
4
|
import { Icon } from '../Icon/index.js';
|
|
5
5
|
import { defaultRatingLabels } from './types.js';
|
|
6
|
+
import { StarFill as StarFillIcon, StarOutline as StarOutlineIcon } from '../../icons/system/index.js';
|
|
6
7
|
export function Rating({ value, defaultValue = 0, max = 5, disabled, readOnly, name, size = 'lg', theme = 'secondary', onValueChange, allowClear, className, gap, 'aria-label': ariaLabel, labels: labelsProp, }) {
|
|
7
8
|
const isControlled = value != null;
|
|
8
9
|
const [internal, setInternal] = React.useState(defaultValue);
|
|
@@ -73,6 +74,6 @@ export function Rating({ value, defaultValue = 0, max = 5, disabled, readOnly, n
|
|
|
73
74
|
const n = i + 1;
|
|
74
75
|
const checked = current >= n;
|
|
75
76
|
const id = `${groupName}__star-${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 ?
|
|
77
|
+
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 ? StarFillIcon : StarOutlineIcon }) })) : (_jsxs("label", { className: cx('tui-rating__star', checked && 'is-active'), htmlFor: id, tabIndex: -1, children: [_jsx(Icon, { name: checked ? StarFillIcon : StarOutlineIcon }), _jsx("span", { className: "tui-visually-hidden", children: labels.value(n, max) })] }))] }, n));
|
|
77
78
|
}) }));
|
|
78
79
|
}
|
|
@@ -5,6 +5,7 @@ import { composeRefs } from '../../utils/compose-refs.js';
|
|
|
5
5
|
import { useControllableState } from '../../utils/use-controllable-state.js';
|
|
6
6
|
import { Icon } from '../Icon/index.js';
|
|
7
7
|
import { TextInput } from '../TextInput/index.js';
|
|
8
|
+
import { CloseSmall as CloseSmallIcon, Search as SearchIcon } from '../../icons/system/index.js';
|
|
8
9
|
// =============================================================================
|
|
9
10
|
// SearchInput Component
|
|
10
11
|
// =============================================================================
|
|
@@ -52,7 +53,7 @@ export const SearchInput = forwardRef(function SearchInput({ value: valueProp, d
|
|
|
52
53
|
const clearable = !hideClear && !disabled;
|
|
53
54
|
// Whether the button is currently shown (there's something to clear).
|
|
54
55
|
const showClear = clearable && value.length > 0;
|
|
55
|
-
const icon = searchIcon ?? _jsx(Icon, { name:
|
|
56
|
+
const icon = searchIcon ?? _jsx(Icon, { name: SearchIcon });
|
|
56
57
|
// With onSearch the leading icon is the submit control; otherwise it stays a
|
|
57
58
|
// decorative glyph (Icon renders decorative-by-default with no `label`).
|
|
58
59
|
const prefix = onSearch && !disabled ? (_jsx("button", { type: "button", className: "tui-search-input__submit", "aria-label": searchLabel, onClick: submit,
|
|
@@ -72,5 +73,5 @@ export const SearchInput = forwardRef(function SearchInput({ value: valueProp, d
|
|
|
72
73
|
// the input never reflows as the button appears/disappears.
|
|
73
74
|
// `visibility: hidden` (vs. unmounting) also drops the empty-state
|
|
74
75
|
// button from the tab order and the a11y tree.
|
|
75
|
-
style: showClear ? undefined : { visibility: 'hidden' }, children: _jsx(Icon, { name:
|
|
76
|
+
style: showClear ? undefined : { visibility: 'hidden' }, children: _jsx(Icon, { name: CloseSmallIcon }) })) : undefined }));
|
|
76
77
|
});
|
|
@@ -9,6 +9,7 @@ import { Icon } from '../Icon/index.js';
|
|
|
9
9
|
import { SearchInput } from '../SearchInput/index.js';
|
|
10
10
|
import { SearchSelectContext, SearchSelectContentContext, useSearchSelectContext, useSearchSelectContentContext, } from './SearchSelectContext.js';
|
|
11
11
|
import { defaultSearchSelectLabels, } from './types.js';
|
|
12
|
+
import { Check as CheckIcon, ChevronDown as ChevronDownIcon } from '../../icons/system/index.js';
|
|
12
13
|
// Default filter: case-insensitive substring on textValue.
|
|
13
14
|
const defaultFilter = (textValue, query) => textValue.toLowerCase().includes(query.trim().toLowerCase());
|
|
14
15
|
// =============================================================================
|
|
@@ -324,7 +325,7 @@ function SearchSelectTriggerComponent({ className, children, onClick: onClickPro
|
|
|
324
325
|
pointerDownFix(e);
|
|
325
326
|
}, [onPointerDownProp, pointerDownFix]);
|
|
326
327
|
return (_jsxs("button", { ...rest, ref: handleRef, type: "button", id: triggerId, className: cx('tui-input-group', 'tui-search-select__trigger', size !== 'md' && `is-size-${size}`, className), disabled: disabled, "aria-haspopup": "dialog", "aria-expanded": open, "aria-controls": open ? panelId : undefined, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy ? `${ariaLabelledBy} ${valueId}` : undefined, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "data-state": open ? 'open' : 'closed', onClick: handleClick, onKeyDown: handleKeyDown, onPointerDown: handlePointerDown, children: [_jsx("span", { id: valueId, className: "tui-search-select__value", children: children ??
|
|
327
|
-
(hasValue ? (labelFor(value)) : (_jsx("span", { className: "tui-search-select__placeholder", children: placeholder }))) }), _jsx(Icon, { name:
|
|
328
|
+
(hasValue ? (labelFor(value)) : (_jsx("span", { className: "tui-search-select__placeholder", children: placeholder }))) }), _jsx(Icon, { name: ChevronDownIcon, className: "tui-search-select__icon" })] }));
|
|
328
329
|
}
|
|
329
330
|
SearchSelectTriggerComponent.displayName = 'SearchSelect.Trigger';
|
|
330
331
|
// =============================================================================
|
|
@@ -438,7 +439,7 @@ function SearchSelectOptionComponent({ value: optionValue, disabled = false, tex
|
|
|
438
439
|
return (_jsxs("div", { ref: ref, id: optionIdForValue(listboxId, optionValue), role: "option", className: cx('tui-search-select__option', className), "aria-selected": isSelected, "aria-disabled": disabled || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": disabled || undefined, ...getItemProps({
|
|
439
440
|
onClick: handleClick,
|
|
440
441
|
onPointerDown: handlePointerDown,
|
|
441
|
-
}), children: [_jsx("span", { className: "tui-search-select__option-content", children: children }), isSelected && _jsx(Icon, { name:
|
|
442
|
+
}), children: [_jsx("span", { className: "tui-search-select__option-content", children: children }), isSelected && _jsx(Icon, { name: CheckIcon, className: "tui-search-select__option-check" })] }));
|
|
442
443
|
}
|
|
443
444
|
SearchSelectOptionComponent.displayName = 'SearchSelect.Option';
|
|
444
445
|
// =============================================================================
|
|
@@ -6,6 +6,7 @@ import { isDev } from '../../utils/is-dev.js';
|
|
|
6
6
|
import { Icon } from '../Icon/index.js';
|
|
7
7
|
import { TextInput } from '../TextInput/index.js';
|
|
8
8
|
import { defaultSecretInputLabels } from './types.js';
|
|
9
|
+
import { LockSmall as LockSmallIcon, View as ViewIcon, ViewOff as ViewOffIcon } from '../../icons/system/index.js';
|
|
9
10
|
// =============================================================================
|
|
10
11
|
// SecretInput Component
|
|
11
12
|
// =============================================================================
|
|
@@ -140,7 +141,7 @@ export const SecretInput = forwardRef(function SecretInput({ isSet = false, reve
|
|
|
140
141
|
// tui-input-reset strips native in-field chrome — here Edge's own
|
|
141
142
|
// ::-ms-reveal eye, which would sit beside our toggle AND unmask the
|
|
142
143
|
// field without changing `type`, so the toggle's state would be wrong.
|
|
143
|
-
inputClassName: cx('tui-input-reset', 'tui-secret-input__input', inputClassName), suffix: _jsxs(_Fragment, { children: [describeSetState && (_jsx("span", { id: setDescId, className: "tui-visually-hidden", children: text.valueSetDescription })), locked ? (_jsxs(_Fragment, { children: [_jsx("span", { id: lockedDescId, className: "tui-visually-hidden", children: lockedMessage ?? text.locked }), _jsx(Icon, { name:
|
|
144
|
+
inputClassName: cx('tui-input-reset', 'tui-secret-input__input', inputClassName), suffix: _jsxs(_Fragment, { children: [describeSetState && (_jsx("span", { id: setDescId, className: "tui-visually-hidden", children: text.valueSetDescription })), locked ? (_jsxs(_Fragment, { children: [_jsx("span", { id: lockedDescId, className: "tui-visually-hidden", children: lockedMessage ?? text.locked }), _jsx(Icon, { name: LockSmallIcon, className: "tui-secret-input__lock" })] })) : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "tui-secret-input__reveal", "aria-label": revealed ? text.hide : text.reveal, "data-revealed": revealed ? 'true' : undefined, disabled: disabled, onClick: handleToggleClick,
|
|
144
145
|
// Keep pointerdown from stealing focus before the click fires.
|
|
145
|
-
onPointerDown: (e) => e.preventDefault(), children: _jsx(Icon, { name: revealed ?
|
|
146
|
+
onPointerDown: (e) => e.preventDefault(), children: _jsx(Icon, { name: revealed ? ViewOffIcon : ViewIcon }) }), _jsx("span", { role: "status", "aria-live": "polite", className: "tui-visually-hidden", children: announcement })] }))] }) }));
|
|
146
147
|
});
|
|
@@ -9,6 +9,7 @@ import { useOptionRegistry, useOptionRegistration, useListboxIds, useListboxFloa
|
|
|
9
9
|
import { Icon } from '../Icon/index.js';
|
|
10
10
|
import { SelectContext, SelectContentContext, useSelectContext, useSelectContentContext, } from './SelectContext.js';
|
|
11
11
|
import { toPlacement, } from './types.js';
|
|
12
|
+
import { Check as CheckIcon, ChevronDown as ChevronDownIcon, Close as CloseIcon } from '../../icons/system/index.js';
|
|
12
13
|
// =============================================================================
|
|
13
14
|
// Select Root
|
|
14
15
|
// =============================================================================
|
|
@@ -348,7 +349,7 @@ function SelectTriggerComponent({ asChild = false, className, children, }) {
|
|
|
348
349
|
// Wrap in a relative container so the clear button can be a sibling of the
|
|
349
350
|
// trigger <button> — nesting <button> inside <button> is invalid HTML and
|
|
350
351
|
// causes browsers to eject the inner button via the adoption agency algorithm.
|
|
351
|
-
return (_jsxs("div", { className: cx('tui-select__trigger-wrap', showClear && 'has-clear'), children: [_jsxs("button", { ref: refs.setReference, type: "button", className: cx('tui-input-group', '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:
|
|
352
|
+
return (_jsxs("div", { className: cx('tui-select__trigger-wrap', showClear && 'has-clear'), children: [_jsxs("button", { ref: refs.setReference, type: "button", className: cx('tui-input-group', '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: ChevronDownIcon, 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: CloseIcon }) }))] }));
|
|
352
353
|
}
|
|
353
354
|
SelectTriggerComponent.displayName = 'Select.Trigger';
|
|
354
355
|
// =============================================================================
|
|
@@ -414,7 +415,7 @@ function SelectOptionComponent({ value: optionValue, disabled = false, textValue
|
|
|
414
415
|
}, [disabled, optionValue, textValue, setValue, setOpen]);
|
|
415
416
|
return (_jsxs("div", { ref: ref, id: optionIdForIndex(listboxId, index), role: "option", className: cx('tui-select__option', className), "aria-selected": isSelected, "aria-disabled": disabled || undefined, "data-highlighted": isHighlighted || undefined, "data-disabled": disabled || undefined, ...getItemProps({
|
|
416
417
|
onClick: handleClick,
|
|
417
|
-
}), children: [_jsx("span", { className: "tui-select__option-content", children: children }), isSelected && (_jsx(Icon, { name:
|
|
418
|
+
}), children: [_jsx("span", { className: "tui-select__option-content", children: children }), isSelected && (_jsx(Icon, { name: CheckIcon, className: "tui-select__option-check", "aria-hidden": "true" }))] }));
|
|
418
419
|
}
|
|
419
420
|
SelectOptionComponent.displayName = 'Select.Option';
|
|
420
421
|
// =============================================================================
|
|
@@ -5,6 +5,7 @@ import { useFocusTrap, getInitialFocus } from '../../utils/focus-trap.js';
|
|
|
5
5
|
import { useControllableState } from '../../utils/use-controllable-state.js';
|
|
6
6
|
import { isDev } from '../../utils/is-dev.js';
|
|
7
7
|
import { IconButton } from '../IconButton/index.js';
|
|
8
|
+
import { SidebarCollapse as SidebarCollapseIcon, SidebarExpand as SidebarExpandIcon } from '../../icons/system/index.js';
|
|
8
9
|
const isBrowser = typeof document !== 'undefined';
|
|
9
10
|
const SidebarCollapseContext = createContext(null);
|
|
10
11
|
// =============================================================================
|
|
@@ -259,7 +260,7 @@ function SidebarToggle(props) {
|
|
|
259
260
|
const pointsInward = position === 'left' ? !collapsed : collapsed;
|
|
260
261
|
return (_jsx(IconButton, { ...rest, ref: (node) => {
|
|
261
262
|
toggleRef.current = node;
|
|
262
|
-
}, icon: pointsInward ?
|
|
263
|
+
}, icon: pointsInward ? SidebarCollapseIcon : SidebarExpandIcon, label: collapsed ? text.expand : text.collapse, className: ['tui-sidebar__toggle', className].filter(Boolean).join(' '), "aria-expanded": !collapsed, onClick: toggle }));
|
|
263
264
|
}
|
|
264
265
|
SidebarHeader.displayName = 'Sidebar.Header';
|
|
265
266
|
SidebarFooter.displayName = 'Sidebar.Footer';
|