@tangible/ui 0.2.27 → 0.2.29
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/Button/Button.js +29 -3
- package/components/Button/types.d.ts +6 -1
- package/components/IconButton/IconButton.js +14 -3
- package/components/IconButton/types.d.ts +6 -1
- package/components/Modal/Modal.d.ts +12 -3
- package/components/Modal/Modal.js +38 -13
- package/figma-tokens.json +1 -1
- package/package.json +8 -2
- package/skills/building-with-tui/SKILL.md +49 -14
- package/styles/all.css +1 -1
- package/styles/all.expanded.css +37 -0
- package/styles/all.expanded.unlayered.css +37 -0
- package/styles/all.unlayered.css +1 -1
- package/styles/components/modal.scss +61 -0
- package/tui-manifest.json +10 -5
- package/utils/focus-trap.d.ts +1 -14
- package/utils/focus-trap.js +3 -43
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
2
|
+
import React, { forwardRef, useEffect, useRef } from 'react';
|
|
3
|
+
import { isDev } from '../../utils/is-dev.js';
|
|
3
4
|
import { cx } from '../../utils/cx.js';
|
|
4
5
|
import { Icon } from '../Icon/index.js';
|
|
5
6
|
import { getSafeRel } from '../../utils/polymorphic.js';
|
|
@@ -7,7 +8,22 @@ import { defaultButtonLabels } from './types.js';
|
|
|
7
8
|
export const Button = forwardRef(({ label, children, size = 'md', theme = 'primary', variant = 'solid', fullWidth, disabled = false, loading = false, loadingLabel: loadingLabelProp, labels: labelsProp, leftIconName, rightIconName, leftIcon, rightIcon, className, target, rel, onClick, style, ...rest }, ref) => {
|
|
8
9
|
const isLink = typeof rest.href === 'string';
|
|
9
10
|
const isDisabled = disabled || loading;
|
|
11
|
+
// Loading must not take focus away: native `disabled` on a focused button
|
|
12
|
+
// (or dropping a focused link's href) sends focus to <body>, so keyboard
|
|
13
|
+
// users lose their place on every async action (WCAG 2.4.3). Loading is
|
|
14
|
+
// aria-disabled and blocked in the click handler; only an explicit
|
|
15
|
+
// `disabled` goes native.
|
|
16
|
+
const loadingOnly = loading && !disabled;
|
|
10
17
|
const labels = { ...defaultButtonLabels, ...labelsProp };
|
|
18
|
+
// A non-string label can't compose "X, loading", so without loadingLabel
|
|
19
|
+
// the busy state has no name change at all.
|
|
20
|
+
const loadingWarned = useRef(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (isDev() && loading && typeof label !== 'string' && !loadingLabelProp && !loadingWarned.current) {
|
|
23
|
+
loadingWarned.current = true;
|
|
24
|
+
console.warn('Button: `loading` with a non-string `label` needs `loadingLabel`, or the loading state has no accessible name.');
|
|
25
|
+
}
|
|
26
|
+
}, [loading, label, loadingLabelProp]);
|
|
11
27
|
// Compose loading state into aria-label for screen readers
|
|
12
28
|
const loadingLabel = loading
|
|
13
29
|
? (loadingLabelProp ?? (typeof label === 'string' ? `${label}, loading` : undefined))
|
|
@@ -32,9 +48,19 @@ export const Button = forwardRef(({ label, children, size = 'md', theme = 'prima
|
|
|
32
48
|
}
|
|
33
49
|
onClick?.(e);
|
|
34
50
|
};
|
|
35
|
-
return (_jsxs("a", { ref: ref, href:
|
|
51
|
+
return (_jsxs("a", { ref: ref, href: disabled ? undefined : href, className: classes, "aria-label": loadingLabel, "aria-disabled": isDisabled || undefined, "aria-busy": loading || undefined, tabIndex: disabled ? -1 : tabIndex, onClick: handleClick, "data-loading": loading || undefined, target: target, rel: safeRel, style: style, ...anchorRest, children: [content, target === '_blank' && (_jsx("span", { className: "tui-visually-hidden", children: labels.newTab }))] }));
|
|
36
52
|
}
|
|
37
53
|
const buttonRest = rest;
|
|
38
|
-
|
|
54
|
+
// Enter/Space and implicit form submission all arrive as a click, so one
|
|
55
|
+
// guard covers them; preventDefault cancels a submit.
|
|
56
|
+
const handleButtonClick = (e) => {
|
|
57
|
+
if (loadingOnly) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
onClick?.(e);
|
|
63
|
+
};
|
|
64
|
+
return (_jsx("button", { ref: ref, type: buttonRest.type ?? 'button', className: classes, "aria-label": loadingLabel, disabled: disabled, "aria-disabled": loadingOnly || undefined, "aria-busy": loading || undefined, onClick: handleButtonClick, "data-loading": loading || undefined, style: style, ...buttonRest, children: content }));
|
|
39
65
|
});
|
|
40
66
|
Button.displayName = 'Button';
|
|
@@ -66,7 +66,12 @@ type CommonProps = {
|
|
|
66
66
|
*/
|
|
67
67
|
disabled?: boolean;
|
|
68
68
|
/**
|
|
69
|
-
* Loading state
|
|
69
|
+
* Loading state: shows a spinner and blocks activation while keeping the
|
|
70
|
+
* button focusable (`aria-disabled`, not native `disabled`), so a
|
|
71
|
+
* keyboard user who triggered it keeps their place. Only `onClick` is
|
|
72
|
+
* guarded: put the action there, not in `onKeyDown`/`onPointerDown`.
|
|
73
|
+
* The start and end of loading aren't announced; confirm completion
|
|
74
|
+
* through your own status message (a Toast, say).
|
|
70
75
|
* @default false
|
|
71
76
|
*/
|
|
72
77
|
loading?: boolean;
|
|
@@ -20,6 +20,9 @@ export const IconButton = forwardRef((props, ref) => {
|
|
|
20
20
|
const { icon, label, size = 'sm', theme = 'secondary', variant = 'ghost', disabled = false, loading = false, loadingLabel: loadingLabelProp, pressed, shape = 'square', showTooltip = false, tooltipSide = 'top', className, ...rest } = props;
|
|
21
21
|
const isLink = typeof rest.href === 'string';
|
|
22
22
|
const isDisabled = disabled || loading;
|
|
23
|
+
// Loading keeps focus (see Button): aria-disabled plus a click guard, never
|
|
24
|
+
// native `disabled` or a dropped href. Only explicit `disabled` goes native.
|
|
25
|
+
const loadingOnly = loading && !disabled;
|
|
23
26
|
const resolvedLabel = loading ? (loadingLabelProp ?? `${label}, loading`) : label;
|
|
24
27
|
const classes = cx('tui-icon-button', `is-size-${size}`, `is-theme-${theme}`, `is-style-${variant}`, isDisabled && 'is-disabled', shape === 'circle' && 'is-shape-circle', className);
|
|
25
28
|
const iconContent = (_jsxs(_Fragment, { children: [_jsx(Icon, { name: icon }), loading && _jsx("span", { className: "tui-icon-button__spinner", "aria-hidden": "true" })] }));
|
|
@@ -36,11 +39,19 @@ export const IconButton = forwardRef((props, ref) => {
|
|
|
36
39
|
}
|
|
37
40
|
onClick?.(e);
|
|
38
41
|
};
|
|
39
|
-
element = (_jsx("a", { ref: ref, href:
|
|
42
|
+
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 }));
|
|
40
43
|
}
|
|
41
44
|
else {
|
|
42
|
-
const buttonRest = rest;
|
|
43
|
-
|
|
45
|
+
const { onClick, ...buttonRest } = rest;
|
|
46
|
+
const handleButtonClick = (e) => {
|
|
47
|
+
if (loadingOnly) {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
onClick?.(e);
|
|
53
|
+
};
|
|
54
|
+
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 }));
|
|
44
55
|
}
|
|
45
56
|
// Wrap in tooltip if requested
|
|
46
57
|
if (showTooltip) {
|
|
@@ -50,7 +50,12 @@ type IconButtonBaseProps = {
|
|
|
50
50
|
*/
|
|
51
51
|
disabled?: boolean;
|
|
52
52
|
/**
|
|
53
|
-
* Loading state
|
|
53
|
+
* Loading state: shows a spinner and blocks activation while keeping the
|
|
54
|
+
* button focusable (`aria-disabled`, not native `disabled`), so a
|
|
55
|
+
* keyboard user who triggered it keeps their place. Only `onClick` is
|
|
56
|
+
* guarded: put the action there, not in `onKeyDown`/`onPointerDown`.
|
|
57
|
+
* The start and end of loading aren't announced; confirm completion
|
|
58
|
+
* through your own status message (a Toast, say).
|
|
54
59
|
*/
|
|
55
60
|
loading?: boolean;
|
|
56
61
|
/**
|
|
@@ -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,12 @@ 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';
|
|
10
11
|
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 }) {
|
|
12
|
+
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
13
|
const dialogRef = useRef(null);
|
|
13
14
|
const anchorRef = useRef(null);
|
|
14
15
|
const restoreRef = useRef(null);
|
|
@@ -110,25 +111,48 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
|
|
|
110
111
|
'hidden container, or pass an explicit `container`.', buried);
|
|
111
112
|
}
|
|
112
113
|
}, [open, mount]);
|
|
113
|
-
//
|
|
114
|
+
// Read at close time, not dependencies: the effect must run on close only.
|
|
115
|
+
const preventScrollOnRestoreRef = useRef(preventScrollOnRestore);
|
|
116
|
+
preventScrollOnRestoreRef.current = preventScrollOnRestore;
|
|
117
|
+
const restoreFocusToRef = useRef(restoreFocusTo);
|
|
118
|
+
restoreFocusToRef.current = restoreFocusTo;
|
|
119
|
+
// Reset state when modal closes, restore focus: `restoreFocusTo` first, then
|
|
120
|
+
// whatever had focus at open. Each must still be in the document and
|
|
121
|
+
// actually take focus; a removed trigger's focus() is a silent no-op (#133).
|
|
114
122
|
useEffect(() => {
|
|
115
123
|
if (open)
|
|
116
124
|
return;
|
|
117
|
-
const
|
|
118
|
-
if (el && typeof el.focus === 'function') {
|
|
119
|
-
el.focus({ preventScroll: preventScrollOnRestore });
|
|
120
|
-
}
|
|
125
|
+
const captured = restoreRef.current;
|
|
121
126
|
restoreRef.current = null;
|
|
122
127
|
setMount(null);
|
|
128
|
+
if (!captured)
|
|
129
|
+
return; // no open cycle to close
|
|
130
|
+
const target = restoreFocusToRef.current;
|
|
131
|
+
const explicit = typeof target === 'function' ? target() : target?.current ?? null;
|
|
132
|
+
const candidates = [explicit, captured];
|
|
133
|
+
for (const el of candidates) {
|
|
134
|
+
if (!el || !el.isConnected || el === document.body)
|
|
135
|
+
continue;
|
|
136
|
+
el.focus({ preventScroll: preventScrollOnRestoreRef.current });
|
|
137
|
+
if (document.activeElement === el)
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Only when a real target was lost. On WebKit a click doesn't focus the
|
|
141
|
+
// trigger, so `captured` is often <body> for an ordinary close; warning
|
|
142
|
+
// there would teach consumers to ignore the message.
|
|
143
|
+
if (isDev() && (explicit || captured !== document.body)) {
|
|
144
|
+
console.warn('[TUI Modal] Focus had nowhere to return on close: the element focused at open is ' +
|
|
145
|
+
'gone or can\'t take focus, so focus fell to <body> (WCAG 2.4.3). Pass `restoreFocusTo` ' +
|
|
146
|
+
'with an element that will still be there, such as the next row or the list heading.');
|
|
147
|
+
}
|
|
123
148
|
}, [open]);
|
|
124
|
-
// Body scroll lock
|
|
149
|
+
// Body scroll lock, counted, so closing this modal doesn't unlock the page
|
|
150
|
+
// under another one (nested, or a vanilla modal open alongside).
|
|
125
151
|
useEffect(() => {
|
|
126
152
|
if (!open)
|
|
127
153
|
return;
|
|
128
|
-
|
|
129
|
-
return
|
|
130
|
-
document.body.classList.remove('tui-modal-open');
|
|
131
|
-
};
|
|
154
|
+
lockScroll();
|
|
155
|
+
return unlockScroll;
|
|
132
156
|
}, [open]);
|
|
133
157
|
// Inert sibling trees so screen readers cannot escape the dialog.
|
|
134
158
|
// aria-modal alone is unreliable — NVDA/JAWS virtual cursor can still
|
|
@@ -185,7 +209,8 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
|
|
|
185
209
|
}
|
|
186
210
|
}
|
|
187
211
|
if (!target) {
|
|
188
|
-
|
|
212
|
+
// The close button only when nothing else can take focus (#135).
|
|
213
|
+
target = getInitialFocus(dialog, undefined, { lastResort: '.tui-modal__close' });
|
|
189
214
|
}
|
|
190
215
|
target.focus({ preventScroll: true });
|
|
191
216
|
// Development warning for missing labelledBy target
|
|
@@ -213,7 +238,7 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
|
|
|
213
238
|
// Unmounts on the very next render (pre-paint), so it never lays anything out.
|
|
214
239
|
if (!mount)
|
|
215
240
|
return _jsx("span", { ref: anchorRef, hidden: true });
|
|
216
|
-
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: "system/close", label: closeLabel, variant: "ghost", size: "sm", onClick: onClose, className: "tui-modal__close", showTooltip: true }))
|
|
241
|
+
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: "system/close", label: closeLabel, variant: "ghost", size: "sm", onClick: onClose, className: "tui-modal__close", showTooltip: true }))] })] }) }), mount);
|
|
217
242
|
}
|
|
218
243
|
function ModalClose({ label = 'Close', className }) {
|
|
219
244
|
const { onClose } = useModalContext();
|
package/figma-tokens.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.2.
|
|
2
|
+
"version": "0.2.29",
|
|
3
3
|
"source": "publish/styles/all.expanded.css",
|
|
4
4
|
"prefix": "tui-",
|
|
5
5
|
"note": "Layer 1 primitives only. Component API tokens (--tui-{component}-*) are never defined in CSS — they exist only as fallback reads — so they have no Figma representation. CONTRACT: consumers read TUI defaults from this file at build time (variables[].cssVar, the \"Light\"/\"Dark\" mode names, and alias chains into TUI/Primitives). Renaming a cssVar or a mode is a breaking change to those consumers even when the CSS value is unchanged — a rename silently becomes an undefined default downstream — so treat it as at least a minor bump and call it out in the CHANGELOG.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangible/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.29",
|
|
4
4
|
"description": "Tangible Design System",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./components/index.js",
|
|
@@ -58,6 +58,11 @@
|
|
|
58
58
|
"./manifest.json": "./tui-manifest.json",
|
|
59
59
|
"./skill": "./skills/building-with-tui/SKILL.md",
|
|
60
60
|
"./figma-tokens.json": "./figma-tokens.json",
|
|
61
|
+
"./vanilla/modal": {
|
|
62
|
+
"import": "./vanilla/modal.js",
|
|
63
|
+
"types": "./vanilla/modal.d.ts"
|
|
64
|
+
},
|
|
65
|
+
"./vanilla/*": "./vanilla/*",
|
|
61
66
|
"./components/Accordion": {
|
|
62
67
|
"import": "./components/Accordion/index.js",
|
|
63
68
|
"types": "./components/Accordion/index.d.ts"
|
|
@@ -270,7 +275,8 @@
|
|
|
270
275
|
"tui-manifest.json",
|
|
271
276
|
"figma-tokens.json",
|
|
272
277
|
"types",
|
|
273
|
-
"utils"
|
|
278
|
+
"utils",
|
|
279
|
+
"vanilla"
|
|
274
280
|
],
|
|
275
281
|
"sideEffects": [
|
|
276
282
|
"*.css",
|
|
@@ -11,8 +11,10 @@ the repo's own CLAUDE.md and `.claude/agents/*`.)
|
|
|
11
11
|
The API is on disk and does not need guessing. What costs hours is the **wiring and the a11y
|
|
12
12
|
plumbing**, because both fail silently rather than erroring. That is most of what follows.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Inventory figures (component counts, manifest coverage, subpaths, icons, `data-testid` pass-through)
|
|
15
|
+
were re-measured against **0.2.28** (Oct 13 2026). Other sections were last verified against
|
|
16
|
+
**0.2.11 + main** (Aug 22 2026) unless a claim carries its own date. Re-check anything that reads as
|
|
17
|
+
surprising.
|
|
16
18
|
|
|
17
19
|
## The minimum that works
|
|
18
20
|
|
|
@@ -41,9 +43,9 @@ there is no CSS at all.
|
|
|
41
43
|
| which Storybook page is this? | `tui-manifest.json` → `components.<Name>.story.title` |
|
|
42
44
|
|
|
43
45
|
Directory and file name match, with two exceptions: `Table/DataTable.d.ts` and
|
|
44
|
-
`ColorPicker/ColorField.d.ts`. Props live in `types.d.ts` for
|
|
46
|
+
`ColorPicker/ColorField.d.ts`. Props live in `types.d.ts` for 35 of 46 components; the other eleven
|
|
45
47
|
declare them in the component file (Card, Chip, Chips, ColorPicker, Field, GradientPicker, Icon,
|
|
46
|
-
Modal, Notice, OverlapStack).
|
|
48
|
+
Modal, Notice, OverlapStack, Toast).
|
|
47
49
|
`<Dir>.d.ts` is still the better read for the **compound shape** — it spells out
|
|
48
50
|
`type SelectCompound = … & { Trigger; Content; Option; Group; Label }` in one place, which the
|
|
49
51
|
barrel's flat export list only implies.
|
|
@@ -58,21 +60,21 @@ the filter drops load-bearing API:
|
|
|
58
60
|
- Any prop without a JSDoc comment is dropped, required or not. The clearest tell: the manifest's
|
|
59
61
|
**`Checkbox` entry lists `rel` and `title` but not `checked`, `defaultChecked`, `indeterminate`
|
|
60
62
|
or `onCheckedChange`** — the entire state API is missing while inherited HTML noise survives.
|
|
61
|
-
-
|
|
63
|
+
- 39 components report `subcomponents: null`, and for 13 of those the compound API is real
|
|
62
64
|
(Select, MultiSelect, SearchSelect, Combobox, MultiCombobox, Dropdown, Popover, Tooltip, Field,
|
|
63
|
-
Sidebar, StepList, Toolbar) — [#87](https://github.com/TangibleInc/tangible-ui/issues/87).
|
|
64
|
-
- Only 8 of
|
|
65
|
+
Sidebar, StepList, Toolbar, NavMenu) — [#87](https://github.com/TangibleInc/tangible-ui/issues/87).
|
|
66
|
+
- Only 8 of 46 entries carry a `description`, and 4 carry `use`/`notFor`, so it is a thin guide to
|
|
65
67
|
*which* component too. The two `guides` entries (Tabs vs SegmentedControl, Chip vs Button) are
|
|
66
68
|
worth reading; the rest of that judgement is not in the file.
|
|
67
69
|
|
|
68
|
-
**Manifest silence is not absence.** What it *is* good for: `cssTokens` (
|
|
70
|
+
**Manifest silence is not absence.** What it *is* good for: `cssTokens` (43 of 46 components list
|
|
69
71
|
their full `--tui-<component>-*` API — the only shipped listing, since consumers have no SCSS) and
|
|
70
|
-
`story` (all
|
|
72
|
+
`story` (all 46, pointing into <https://storybook-tangible-ui.pages.dev>).
|
|
71
73
|
|
|
72
74
|
### Types that will not resolve from the barrel
|
|
73
75
|
|
|
74
76
|
`@tangible/ui` re-exports the main `*Props` types but systematically omits others. Import those from
|
|
75
|
-
`@tangible/ui/components/<Dir>` — all
|
|
77
|
+
`@tangible/ui/components/<Dir>` — all 46 component subpaths are exported.
|
|
76
78
|
|
|
77
79
|
- **Nearly every `*Labels` type** (the i18n prop): `ButtonLabels`, `FieldLabels`,
|
|
78
80
|
`ComboboxLabels`, `MultiSelectLabels`, `RatingLabels`, `DataTableLabels`, `AvatarLabels`,
|
|
@@ -404,7 +406,10 @@ synthesise a second toggle. For a second control that toggles the same item (an
|
|
|
404
406
|
**ConfirmDialog / AlertDialog → `Modal role="alertdialog"`** (needs both `aria-labelledby` and
|
|
405
407
|
`aria-describedby`; the backdrop stops dismissing by default, Escape still cancels; put the actions in
|
|
406
408
|
`Modal.Foot`, which is already an end-aligned flex row — `justify="between"` separates a destructive one).
|
|
407
|
-
**Snackbar → `Toast`** (`ToastProvider` + `useToast()`).
|
|
409
|
+
**Snackbar → `Toast`** (`ToastProvider` + `useToast()`).
|
|
410
|
+
**Password / API key / token field → `SecretInput`** (a `TextInput` variant: masked, with a reveal
|
|
411
|
+
toggle whose name flips Show/Hide; `isSet` is a boolean so a stored secret never reaches the client,
|
|
412
|
+
it shows a "Saved" placeholder and typing replaces it; `locked` makes it read-only with no toggle). No Breadcrumb, no Skeleton, and no *standalone* time picker — but
|
|
408
413
|
`DatePicker` / `DateRangePicker` take `withTime` for an hour/minute field (12- or 24-hour via
|
|
409
414
|
`hour12`) plus a display-only `zoneLabel`; the value is a plain `Date` with wall-clock semantics,
|
|
410
415
|
so timezone interpretation stays yours.
|
|
@@ -420,7 +425,7 @@ Two clusters are easy to pick wrong:
|
|
|
420
425
|
chips in the trigger), `MultiCombobox` (multi, free-typing token field). All five share one
|
|
421
426
|
listbox engine, so navigation and ARIA behave identically; the trigger is the choice.
|
|
422
427
|
|
|
423
|
-
Icons are a registry, six sets,
|
|
428
|
+
Icons are a registry, six sets, 255 entries (Oct 13 2026): `system` (116), `lms` (45), `reaction`
|
|
424
429
|
(36), `player` (24), `membersync` (22), `cred` (12). `@tangible/ui/icons/manifest` is the
|
|
425
430
|
machine-readable list.
|
|
426
431
|
|
|
@@ -435,8 +440,8 @@ There are no device icons (monitor / tablet / phone) in any set.
|
|
|
435
440
|
|
|
436
441
|
`data-testid` pass-through is uneven, and the split is not the one you would guess. These spread
|
|
437
442
|
rest props onto their primary element: **Button, Card, Checkbox, Chip, ColorPicker, ColorField,
|
|
438
|
-
`Field`'s slots, GradientPicker, IconButton, Modal,
|
|
439
|
-
Textarea, TextInput**, **DataTable** (onto the `<table>`), and — since 0.2.16 — the group members
|
|
443
|
+
`Field`'s slots, GradientPicker, IconButton, Modal, NavMenu (root, `.Group`, `.Sub`, `.Item`),
|
|
444
|
+
Notice, SearchInput, SearchSelect, SecretInput, Switch, Textarea, TextInput, Toast**, **DataTable** (onto the `<table>`), and — since 0.2.16 — the group members
|
|
440
445
|
**SegmentedControl.Item, Tabs.Tab and Radio**. Everything else drops them silently,
|
|
441
446
|
including several that look like they would take them — Dropdown, Popover, Tooltip, Select,
|
|
442
447
|
MultiSelect, Combobox, MultiCombobox, Sidebar, Toolbar, Pager, Rating, Progress,
|
|
@@ -467,6 +472,36 @@ One live trap there: **memoize `data`, or pass `autoResetPageIndex={false}`.** A
|
|
|
467
472
|
a new identity every render, TanStack queues a page-0 reset on every `data` identity change, and
|
|
468
473
|
with a controlled `pageIndex` that races your parent back to page 0 permanently.
|
|
469
474
|
|
|
475
|
+
## Vanilla modal (no React)
|
|
476
|
+
|
|
477
|
+
For templates and plugin PHP with no React build (Tangible Blocks, L&L): `@tangible/ui` ships a framework-free modal on the native `<dialog>`. It replaces MicroModal; there is no compat layer, so the markup differs.
|
|
478
|
+
|
|
479
|
+
```html
|
|
480
|
+
<link rel="stylesheet" href="https://unpkg.com/@tangible/ui/vanilla/styles.css"> <!-- or all.css, not both -->
|
|
481
|
+
<script src="https://unpkg.com/@tangible/ui/vanilla/modal.min.js" defer></script>
|
|
482
|
+
|
|
483
|
+
<button type="button" data-tui-modal-open="intro">Watch</button>
|
|
484
|
+
|
|
485
|
+
<dialog id="intro" class="tui-interface tui-modal" aria-labelledby="intro-title">
|
|
486
|
+
<div class="tui-modal__dialog is-size-lg"> <!-- required: a click on the <dialog> itself is the backdrop -->
|
|
487
|
+
<div class="tui-modal__head"><h2 id="intro-title">Intro</h2></div>
|
|
488
|
+
<div class="tui-modal__body"><div class="tui-modal__body-inner">
|
|
489
|
+
<iframe class="tui-modal__embed" title="Intro video" data-tui-modal-src="https://www.youtube.com/embed/ID?autoplay=1"></iframe>
|
|
490
|
+
</div></div>
|
|
491
|
+
<div class="tui-modal__foot">
|
|
492
|
+
<button type="button" class="tui-button" data-tui-modal-close>Close</button>
|
|
493
|
+
</div>
|
|
494
|
+
</div>
|
|
495
|
+
</dialog>
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
- **Attributes.** `data-tui-modal-open="<id>"` and `data-tui-modal-close` go on any element (delegated, so markup added later works; `aria-disabled` triggers are ignored). On the dialog, `role="alertdialog"` (add `aria-describedby`) and `data-tui-modal-backdrop="dismiss" | "static"`; alertdialog defaults to static. `[autofocus]` / `[data-autofocus]` picks initial focus. A submit button or link carrying `data-tui-modal-close` keeps its default action. `data-tui-modal-restore-focus="<id>"` on the dialog names where focus goes on close, for when the opener is gone (a Delete-row confirm); otherwise it returns to the opener. Put `.tui-modal__close` last in the box: initial focus skips it unless it's the only control.
|
|
499
|
+
- **State and events.** The script sets `data-state` to `open`, `closing` or `closed`. `tui-modal-open` and `tui-modal-close` bubble from the dialog; close's `detail.returnValue` is the submitting button's value in a `<form method="dialog">`. `window.TangibleUI.modal` exposes `open(idOrDialog)` and `close(...)`.
|
|
500
|
+
- **Embeds.** `data-tui-modal-src` loads on open and is dropped on close, which stops a YouTube or Vimeo player with no `postMessage` script. `<audio>`/`<video>` pause. Always give the iframe a `title`.
|
|
501
|
+
- **Name it.** The dialog needs `aria-labelledby` pointing at an element that exists (a phantom id leaves it unnamed) or an `aria-label`, and an icon-only close needs its own `aria-label` (the script can't see that one). The script warns in the console about a missing or phantom name, a dangling `aria-describedby`, an alertdialog without `aria-describedby`, a missing `.tui-modal__dialog` box and no close control; warnings are always on.
|
|
502
|
+
- **Two enqueues are fine.** If Blocks and L&L both load the script, only the first copy installs.
|
|
503
|
+
- **Limit: the top layer.** A native modal puts everything else inert and renders above it. A React Select, datepicker or any widget portaled to `<body>` renders under the dialog and can't be used inside it. Keep such controls in the dialog's own markup.
|
|
504
|
+
|
|
470
505
|
## Known issues
|
|
471
506
|
|
|
472
507
|
Each is tracked in the repo, so **follow the link for current state rather than trusting this
|