@tangible/ui 0.2.37 → 0.2.38

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.
@@ -0,0 +1,79 @@
1
+ import type { HTMLAttributes, ReactNode, RefObject } from 'react';
2
+ import type { SizeStandard } from '../../types/sizes';
3
+ import type { TraySaveLabels } from './labels';
4
+ export type TrayPlacement = 'sticky' | 'fixed';
5
+ type FocusTarget = RefObject<HTMLElement | null> | (() => HTMLElement | null);
6
+ export interface TrayProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role'> {
7
+ /**
8
+ * Whether the tray is showing. Controlled only, like Modal: the state it
9
+ * reports (unsaved edits, a selection, an undo stack) is the app's, and the
10
+ * tray never asks to close itself, so there is no `onOpenChange`.
11
+ */
12
+ open: boolean;
13
+ /**
14
+ * `sticky` pins it to the bottom of its scroll container (the default);
15
+ * `fixed` pins it to the viewport. A fixed tray breaks out of the viewport's
16
+ * frame under a transformed, filtered or contained ancestor, as any
17
+ * `position: fixed` does; the page reserves room at its own bottom for it.
18
+ * @default 'sticky'
19
+ */
20
+ placement?: TrayPlacement;
21
+ /**
22
+ * Where focus goes if the tray closes while focus is inside it. Read at close.
23
+ * Defaults to the element focus entered the tray from.
24
+ */
25
+ restoreFocusTo?: FocusTarget;
26
+ children?: ReactNode;
27
+ }
28
+ export interface TrayMessageProps extends HTMLAttributes<HTMLDivElement> {
29
+ /**
30
+ * What to announce, when the spoken sentence should differ from the visible
31
+ * message (e.g. visible `Approved "X"` styled in parts, spoken as one
32
+ * sentence). Defaults to the message's text.
33
+ */
34
+ announcement?: string;
35
+ children?: ReactNode;
36
+ }
37
+ export interface TrayActionsProps extends HTMLAttributes<HTMLDivElement> {
38
+ children?: ReactNode;
39
+ }
40
+ export interface TraySaveActionsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
41
+ /** Discard the pending changes. The tray never discards on its own (no Escape). */
42
+ onDiscard: () => void;
43
+ /** Save. Alternatively pass `formId` to make Save submit that form; then `onSave` is not called. */
44
+ onSave?: () => void;
45
+ /** Id of the form Save submits (`type="submit" form={formId}`). Takes precedence over `onSave`. */
46
+ formId?: string;
47
+ /**
48
+ * A save is in flight: Save shows a spinner and ignores activation, but keeps
49
+ * focus. Named for the domain; it drives Button's `loading`.
50
+ */
51
+ saving?: boolean;
52
+ /**
53
+ * Save is unavailable (e.g. the form is invalid). It stays focusable and is
54
+ * announced as dimmed (`aria-disabled`), so a keyboard user can still find it
55
+ * and hear why; activation does nothing. Pair with `saveDescription`.
56
+ */
57
+ saveDisabled?: boolean;
58
+ /** Why Save is unavailable, e.g. "Fix 2 errors to save". Wired to Save via `aria-describedby`. */
59
+ saveDescription?: string;
60
+ /**
61
+ * Button labels, for translation. Defaults are exported as
62
+ * {@link defaultTraySaveLabels}; a partial object overrides only its keys.
63
+ */
64
+ labels?: TraySaveLabels;
65
+ /** Size of both buttons. @default 'md' */
66
+ size?: SizeStandard;
67
+ }
68
+ /**
69
+ * A non-modal bar at the bottom of its scroll container or the viewport,
70
+ * holding a short message and a few actions: unsaved changes
71
+ * (`Tray.SaveActions`), an undo stack, a bulk selection. Announced politely;
72
+ * never takes focus; returns focus if it closes with focus inside.
73
+ */
74
+ export declare const Tray: import("react").ForwardRefExoticComponent<TrayProps & import("react").RefAttributes<HTMLDivElement>> & {
75
+ Message: import("react").ForwardRefExoticComponent<TrayMessageProps & import("react").RefAttributes<HTMLDivElement>>;
76
+ Actions: import("react").ForwardRefExoticComponent<TrayActionsProps & import("react").RefAttributes<HTMLDivElement>>;
77
+ SaveActions: import("react").ForwardRefExoticComponent<TraySaveActionsProps & import("react").RefAttributes<HTMLDivElement>>;
78
+ };
79
+ export {};
@@ -0,0 +1,229 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState, } from 'react';
3
+ import { cx } from '../../utils/cx.js';
4
+ import { composeRefs } from '../../utils/compose-refs.js';
5
+ import { isDev } from '../../utils/is-dev.js';
6
+ import { getTabbable, isTabbable } from '../../utils/tabbable.js';
7
+ import { Button } from '../Button/index.js';
8
+ import { defaultTraySaveLabels } from './labels.js';
9
+ const EXIT_FALLBACK_MS = 400;
10
+ const TrayContext = createContext(null);
11
+ function useTrayContext(part) {
12
+ const ctx = useContext(TrayContext);
13
+ if (!ctx)
14
+ throw new Error(`<Tray.${part}> must be rendered inside <Tray>.`);
15
+ return ctx;
16
+ }
17
+ function resolveTarget(target) {
18
+ if (!target)
19
+ return null;
20
+ return (typeof target === 'function' ? target() : target.current) ?? null;
21
+ }
22
+ function tryFocus(el) {
23
+ if (!el || !el.isConnected)
24
+ return false;
25
+ el.focus({ preventScroll: true });
26
+ return document.activeElement === el;
27
+ }
28
+ /**
29
+ * Last resort when neither `restoreFocusTo` nor the entry element can take
30
+ * focus (the field was disabled during the save, the selected rows were
31
+ * deleted): the nearest tabbable before the tray in DOM order, else after it.
32
+ */
33
+ function neighbourOf(root) {
34
+ const outside = getTabbable(document.body).filter((el) => !root.contains(el));
35
+ const before = outside.filter((el) => root.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_PRECEDING);
36
+ return before.at(-1) ?? outside.find((el) => !before.includes(el)) ?? null;
37
+ }
38
+ const TrayRoot = forwardRef(function Tray({ open, placement = 'sticky', restoreFocusTo, className, children, onFocus, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, ...rest }, forwardedRef) {
39
+ const rootRef = useRef(null);
40
+ const [state, setState] = useState(open ? 'open' : 'closed');
41
+ const [messageId, setMessageId] = useState(null);
42
+ const entryRef = useRef(null);
43
+ // --- Open / close -----------------------------------------------------
44
+ // Animate in only when it opens on the page, not when it's already open at
45
+ // mount (a page that loads with unsaved edits shouldn't slide anything in).
46
+ const [entering, setEntering] = useState(false);
47
+ const mountedRef = useRef(false);
48
+ useLayoutEffect(() => {
49
+ const firstRun = !mountedRef.current;
50
+ mountedRef.current = true;
51
+ if (open) {
52
+ if (!firstRun)
53
+ setEntering(true);
54
+ setState('open');
55
+ return;
56
+ }
57
+ setEntering(false);
58
+ setState((s) => (s === 'closed' ? s : 'closing'));
59
+ }, [open]);
60
+ const finishClose = useCallback(() => {
61
+ setState((s) => (s === 'closing' ? 'closed' : s));
62
+ }, []);
63
+ const restoreRef = useRef(restoreFocusTo);
64
+ restoreRef.current = restoreFocusTo;
65
+ // One layout effect, in this order: move focus out, THEN make the tray
66
+ // inert. Browsers blur a focused element the moment an ancestor goes inert,
67
+ // so the other order finds focus already on <body> and restores nothing.
68
+ // `inert` is set as a DOM property, as Tabs and Accordion do: React 18
69
+ // doesn't treat it as a boolean attribute.
70
+ useLayoutEffect(() => {
71
+ const root = rootRef.current;
72
+ if (!root)
73
+ return;
74
+ if (state === 'closing' && root.contains(document.activeElement)) {
75
+ const explicit = resolveTarget(restoreRef.current);
76
+ const entry = entryRef.current;
77
+ if (!tryFocus(explicit) &&
78
+ !(entry && isTabbable(entry) && tryFocus(entry)) &&
79
+ !tryFocus(neighbourOf(root))) {
80
+ if (isDev()) {
81
+ console.warn('[Tray] Closed while focus was inside it, and there was nowhere to ' +
82
+ 'return focus. Pass `restoreFocusTo`.');
83
+ }
84
+ }
85
+ }
86
+ root.inert = state !== 'open';
87
+ }, [state]);
88
+ useEffect(() => {
89
+ if (state !== 'closing')
90
+ return;
91
+ const root = rootRef.current;
92
+ // No animation to wait for (reduced motion, or the stylesheet missing).
93
+ if (!root || getComputedStyle(root).animationName === 'none') {
94
+ finishClose();
95
+ return;
96
+ }
97
+ // Raced against a timeout: a tray in a hidden panel never animates.
98
+ const timer = setTimeout(finishClose, EXIT_FALLBACK_MS);
99
+ return () => clearTimeout(timer);
100
+ }, [state, finishClose]);
101
+ // --- Announcer -------------------------------------------------------
102
+ const [announcement, setAnnouncement] = useState('');
103
+ const seqRef = useRef(0);
104
+ const clearRef = useRef(null);
105
+ const announce = useCallback((text) => {
106
+ if (!text)
107
+ return;
108
+ seqRef.current += 1;
109
+ // Alternating trailing NBSP: identical consecutive text is still a DOM
110
+ // mutation, so it is still announced.
111
+ setAnnouncement(text + (seqRef.current % 2 ? '\u00a0' : ''));
112
+ if (clearRef.current)
113
+ clearTimeout(clearRef.current);
114
+ // Clear once spoken, so browse mode can't find stale text.
115
+ clearRef.current = setTimeout(() => setAnnouncement(''), 3000);
116
+ }, []);
117
+ useEffect(() => () => {
118
+ if (clearRef.current)
119
+ clearTimeout(clearRef.current);
120
+ }, []);
121
+ // --- Naming ----------------------------------------------------------
122
+ const warnedName = useRef(false);
123
+ useEffect(() => {
124
+ if (isDev() && open && !ariaLabel && !ariaLabelledBy && !messageId && !warnedName.current) {
125
+ warnedName.current = true;
126
+ console.warn('[Tray] Give it a <Tray.Message> or an `aria-label`: the region needs a name.');
127
+ }
128
+ }, [open, ariaLabel, ariaLabelledBy, messageId]);
129
+ const labelledBy = ariaLabel ? ariaLabelledBy : (ariaLabelledBy ?? messageId ?? undefined);
130
+ const handleAnimationEnd = (e) => {
131
+ if (e.target === e.currentTarget) {
132
+ if (state === 'closing')
133
+ finishClose();
134
+ else
135
+ setEntering(false);
136
+ }
137
+ rest.onAnimationEnd?.(e);
138
+ };
139
+ return (_jsxs(TrayContext.Provider, { value: { open, announce, registerMessage: setMessageId }, children: [_jsx("div", { className: "tui-tray__announcer", "aria-live": "polite", "aria-atomic": "true", children: announcement }), _jsx("div", { ...rest, ref: composeRefs(forwardedRef, rootRef), role: "region", "aria-label": ariaLabel, "aria-labelledby": labelledBy, className: cx('tui-tray', `is-placement-${placement}`, className), "data-state": state, "data-entering": entering && state === 'open' ? '' : undefined, onFocus: (e) => {
140
+ // Record where focus came from. From nowhere (null: the page, or a
141
+ // Safari click on a button) means there's no entry to return to; a
142
+ // stale one from an earlier visit would be worse than the fallback.
143
+ const from = e.relatedTarget;
144
+ if (!e.currentTarget.contains(from))
145
+ entryRef.current = from;
146
+ onFocus?.(e);
147
+ }, onAnimationEnd: handleAnimationEnd, children: children })] }));
148
+ });
149
+ /** The tray's message: names the region, and its text is announced on open and on change. */
150
+ const TrayMessage = forwardRef(function TrayMessage({ announcement, className, id: idProp, children, ...rest }, forwardedRef) {
151
+ const ctx = useTrayContext('Message');
152
+ const autoId = useId();
153
+ const id = idProp ?? `tui-tray-message-${autoId}`;
154
+ const ref = useRef(null);
155
+ const lastRef = useRef(null);
156
+ const { registerMessage, announce, open } = ctx;
157
+ useLayoutEffect(() => {
158
+ registerMessage(id);
159
+ return () => registerMessage(null);
160
+ }, [id, registerMessage]);
161
+ // Announce on open and whenever the spoken text changes while open.
162
+ useEffect(() => {
163
+ if (!open) {
164
+ lastRef.current = null;
165
+ return;
166
+ }
167
+ const spoken = (announcement ?? ref.current?.textContent ?? '').trim();
168
+ if (spoken && spoken !== lastRef.current) {
169
+ lastRef.current = spoken;
170
+ announce(spoken);
171
+ }
172
+ });
173
+ return (_jsx("div", { ...rest, ref: composeRefs(forwardedRef, ref), id: id, className: cx('tui-tray__message', className), children: children }));
174
+ });
175
+ /** A row of actions, end-aligned. Use it for anything other than the save recipe. */
176
+ const TrayActions = forwardRef(function TrayActions({ className, children, ...rest }, ref) {
177
+ useTrayContext('Actions');
178
+ return (_jsx("div", { ...rest, ref: ref, className: cx('tui-tray__actions', className), children: children }));
179
+ });
180
+ /** The unsaved-changes recipe: Discard then Save, with busy and unavailable states. */
181
+ const TraySaveActions = forwardRef(function TraySaveActions({ onDiscard, onSave, formId, saving = false, saveDisabled = false, saveDescription, labels: labelsProp, size, className, ...rest }, ref) {
182
+ useTrayContext('SaveActions');
183
+ const labels = { ...defaultTraySaveLabels, ...labelsProp };
184
+ const descId = `tui-tray-save-desc-${useId()}`;
185
+ const blocked = saveDisabled && !saving;
186
+ const warnedAction = useRef(false);
187
+ const warnedDescription = useRef(false);
188
+ useEffect(() => {
189
+ if (!isDev() || warnedAction.current)
190
+ return;
191
+ if (!onSave && !formId) {
192
+ warnedAction.current = true;
193
+ console.warn('[Tray.SaveActions] Pass `onSave` or `formId`, or Save does nothing.');
194
+ }
195
+ else if (onSave && formId) {
196
+ warnedAction.current = true;
197
+ console.warn('[Tray.SaveActions] Both `onSave` and `formId` given: Save submits the form and `onSave` is not called.');
198
+ }
199
+ }, [onSave, formId]);
200
+ useEffect(() => {
201
+ if (isDev() && saveDisabled && !saveDescription && !warnedDescription.current) {
202
+ warnedDescription.current = true;
203
+ console.warn('[Tray.SaveActions] `saveDisabled` without `saveDescription`: say why Save is unavailable.');
204
+ }
205
+ }, [saveDisabled, saveDescription]);
206
+ return (
207
+ // DOM order matches visual order: Discard, then Save.
208
+ _jsxs("div", { ...rest, ref: ref, className: cx('tui-tray__actions', className), children: [_jsx(Button, { size: size, theme: "secondary", variant: "outline", label: labels.discard, onClick: onDiscard }), _jsx(Button, { size: size, theme: "primary", label: labels.save, loading: saving, loadingLabel: labels.saving, type: formId ? 'submit' : 'button', form: formId, "aria-disabled": blocked || undefined, "aria-describedby": saveDescription ? descId : undefined, onClick: (e) => {
209
+ // Enter, Space and implicit submission arrive as a click; one guard
210
+ // covers them, and preventDefault cancels a submit.
211
+ if (blocked) {
212
+ e.preventDefault();
213
+ return;
214
+ }
215
+ if (!formId)
216
+ onSave?.();
217
+ } }), saveDescription && (_jsx("span", { id: descId, className: "tui-tray__description", children: saveDescription }))] }));
218
+ });
219
+ /**
220
+ * A non-modal bar at the bottom of its scroll container or the viewport,
221
+ * holding a short message and a few actions: unsaved changes
222
+ * (`Tray.SaveActions`), an undo stack, a bulk selection. Announced politely;
223
+ * never takes focus; returns focus if it closes with focus inside.
224
+ */
225
+ export const Tray = Object.assign(TrayRoot, {
226
+ Message: TrayMessage,
227
+ Actions: TrayActions,
228
+ SaveActions: TraySaveActions,
229
+ });
@@ -0,0 +1,4 @@
1
+ export { Tray } from './Tray';
2
+ export { defaultTraySaveLabels } from './labels';
3
+ export type { TraySaveLabels } from './labels';
4
+ export type { TrayProps, TrayPlacement, TrayMessageProps, TrayActionsProps, TraySaveActionsProps, } from './Tray';
@@ -0,0 +1,2 @@
1
+ export { Tray } from './Tray.js';
2
+ export { defaultTraySaveLabels } from './labels.js';
@@ -0,0 +1,9 @@
1
+ export type TraySaveLabels = {
2
+ /** @default 'Discard' */
3
+ discard?: string;
4
+ /** @default 'Save changes' */
5
+ save?: string;
6
+ /** Save's accessible name while `saving`. Defaults to Button's `'{save}, loading'`. */
7
+ saving?: string;
8
+ };
9
+ export declare const defaultTraySaveLabels: Required<Omit<TraySaveLabels, 'saving'>>;
@@ -0,0 +1,6 @@
1
+ // Kept out of Tray.tsx so that file exports components only (fast refresh).
2
+ // Same shape as Sidebar's toggle labels: every key optional, a full default.
3
+ export const defaultTraySaveLabels = {
4
+ discard: 'Discard',
5
+ save: 'Save changes',
6
+ };
@@ -45,6 +45,7 @@ export { Tabs } from './Tabs';
45
45
  export { Textarea } from './Textarea';
46
46
  export { TextInput } from './TextInput';
47
47
  export { Toast, ToastProvider, useToast } from './Toast';
48
+ export { Tray, defaultTraySaveLabels } from './Tray';
48
49
  export { Toolbar } from './Toolbar';
49
50
  export { Tooltip, TooltipProvider, TooltipTrigger, TooltipContent } from './Tooltip';
50
51
  export type { AccordionProps, AccordionSingleProps, AccordionMultipleProps, AccordionItemProps, AccordionTriggerProps, AccordionPanelProps, AccordionVariant, AccordionItemState, } from './Accordion';
@@ -90,6 +91,7 @@ export type { SwitchProps } from './Switch';
90
91
  export type { TextareaProps, TextareaResize } from './Textarea';
91
92
  export type { TextInputProps, TextInputType } from './TextInput';
92
93
  export type { ToastProps, ToastHandle, ToastTheme, ToastAnnounce, ToastPlacement, ToastOptions, ToastContextValue, ToastProviderProps, } from './Toast';
94
+ export type { TrayProps, TrayPlacement, TrayMessageProps, TrayActionsProps, TraySaveActionsProps, TraySaveLabels, } from './Tray';
93
95
  export type { ToolbarProps, ToolbarGroupProps, ToolbarItemProps, ToolbarOrientation } from './Toolbar';
94
96
  export type { TooltipProps, TooltipProviderProps, TooltipTriggerProps, TooltipContentProps, TooltipType } from './Tooltip';
95
97
  export { GENERATIVE_COLORS, stringToGenerativeColor } from '../utils/generative';
@@ -43,6 +43,7 @@ export { Tabs } from './Tabs/index.js';
43
43
  export { Textarea } from './Textarea/index.js';
44
44
  export { TextInput } from './TextInput/index.js';
45
45
  export { Toast, ToastProvider, useToast } from './Toast/index.js';
46
+ export { Tray, defaultTraySaveLabels } from './Tray/index.js';
46
47
  export { Toolbar } from './Toolbar/index.js';
47
48
  export { Tooltip, TooltipProvider, TooltipTrigger, TooltipContent } from './Tooltip/index.js';
48
49
  // Generative colors (The Jellybean Bag) — deterministic identity colors
package/figma-tokens.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.37",
2
+ "version": "0.2.38",
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/icons/icons.svg CHANGED
@@ -1,4 +1,4 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" data-tui-icon-sprite="all" data-tui-icon-sprite-version="0.2.37" aria-hidden="true" focusable="false" style="position:absolute;width:0;height:0;overflow:hidden">
1
+ <svg xmlns="http://www.w3.org/2000/svg" data-tui-icon-sprite="all" data-tui-icon-sprite-version="0.2.38" aria-hidden="true" focusable="false" style="position:absolute;width:0;height:0;overflow:hidden">
2
2
  <symbol id="tui-cred-badge-check" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M10.893 4.558a1.377 1.377 0 0 1 2.214 0c.381.515 1.068.7 1.656.444a1.377 1.377 0 0 1 1.917 1.106c.072.637.575 1.14 1.212 1.213a1.377 1.377 0 0 1 1.106 1.916 1.38 1.38 0 0 0 .444 1.656c.744.55.744 1.663 0 2.214a1.38 1.38 0 0 0-.444 1.656 1.377 1.377 0 0 1-1.106 1.917 1.38 1.38 0 0 0-1.212 1.212 1.377 1.377 0 0 1-1.917 1.106 1.38 1.38 0 0 0-1.656.444 1.377 1.377 0 0 1-2.214 0 1.38 1.38 0 0 0-1.656-.444 1.377 1.377 0 0 1-1.916-1.106 1.38 1.38 0 0 0-1.213-1.212 1.377 1.377 0 0 1-1.106-1.917 1.38 1.38 0 0 0-.444-1.656 1.377 1.377 0 0 1 0-2.214c.515-.381.7-1.068.444-1.656a1.377 1.377 0 0 1 1.106-1.916 1.38 1.38 0 0 0 1.213-1.213 1.377 1.377 0 0 1 1.916-1.106 1.38 1.38 0 0 0 1.656-.444m5.193 5.91a.75.75 0 0 0-1.172-.936l-3.531 4.414-1.914-1.532a.75.75 0 1 0-.937 1.172l3.085 2.468z" clip-rule="evenodd"/></symbol>
3
3
  <symbol id="tui-cred-badge-ribbon" viewBox="0 0 24 24"><path d="M11.032 3.488a1.205 1.205 0 0 1 1.936 0c.334.451.935.612 1.45.388a1.205 1.205 0 0 1 1.677.969c.063.557.503.997 1.06 1.06.805.092 1.291.935.969 1.678a1.204 1.204 0 0 0 .388 1.449c.65.481.65 1.455 0 1.936a1.205 1.205 0 0 0-.388 1.45 1.205 1.205 0 0 1-.969 1.677 1.204 1.204 0 0 0-1.06 1.06 1.205 1.205 0 0 1-1.678.969 1.205 1.205 0 0 0-1.449.388c-.481.65-1.455.65-1.936 0a1.204 1.204 0 0 0-1.45-.388 1.205 1.205 0 0 1-1.677-.969 1.205 1.205 0 0 0-1.06-1.06 1.205 1.205 0 0 1-.969-1.678 1.205 1.205 0 0 0-.388-1.449 1.205 1.205 0 0 1 0-1.936c.451-.334.612-.935.388-1.45a1.205 1.205 0 0 1 .969-1.677 1.205 1.205 0 0 0 1.06-1.06 1.205 1.205 0 0 1 1.678-.969 1.205 1.205 0 0 0 1.449-.388M8 17.482c.442.175.953.185 1.437-.025a.88.88 0 0 1 1.054.282 1.877 1.877 0 0 0 3.018 0 .88.88 0 0 1 1.054-.282c.484.21.995.2 1.437.025V21l-4-2.286L8 21z"/></symbol>
4
4
  <symbol id="tui-cred-badge" viewBox="0 0 24 24"><path d="M13.107 4.558a1.377 1.377 0 0 0-2.214 0c-.381.515-1.068.7-1.656.444a1.377 1.377 0 0 0-1.916 1.106 1.38 1.38 0 0 1-1.213 1.213 1.377 1.377 0 0 0-1.106 1.916 1.38 1.38 0 0 1-.444 1.656 1.377 1.377 0 0 0 0 2.214c.515.381.7 1.068.444 1.656a1.377 1.377 0 0 0 1.106 1.917c.637.072 1.14.575 1.213 1.212a1.377 1.377 0 0 0 1.916 1.106 1.38 1.38 0 0 1 1.656.444c.55.744 1.663.744 2.214 0a1.38 1.38 0 0 1 1.656-.444 1.377 1.377 0 0 0 1.917-1.106 1.38 1.38 0 0 1 1.212-1.212 1.377 1.377 0 0 0 1.106-1.917 1.38 1.38 0 0 1 .444-1.656 1.377 1.377 0 0 0 0-2.214 1.38 1.38 0 0 1-.444-1.656 1.377 1.377 0 0 0-1.106-1.916 1.38 1.38 0 0 1-1.212-1.213 1.377 1.377 0 0 0-1.917-1.106 1.38 1.38 0 0 1-1.656-.444"/></symbol>
@@ -1 +1 @@
1
- export const SPRITE_VERSION = '0.2.37';
1
+ export const SPRITE_VERSION = '0.2.38';
package/icons/sprite.php CHANGED
@@ -21,7 +21,7 @@
21
21
  */
22
22
 
23
23
  // Replaced with the package version at build time.
24
- $GLOBALS['tangible_ui_icon_sprite_copies'][__DIR__] = '0.2.37';
24
+ $GLOBALS['tangible_ui_icon_sprite_copies'][__DIR__] = '0.2.38';
25
25
 
26
26
  if (!function_exists('tangible_ui_print_icon_sprite')) {
27
27
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangible/ui",
3
- "version": "0.2.37",
3
+ "version": "0.2.38",
4
4
  "description": "Tangible Design System",
5
5
  "type": "module",
6
6
  "main": "./components/index.js",
@@ -259,6 +259,10 @@
259
259
  "./components/Tooltip": {
260
260
  "import": "./components/Tooltip/index.js",
261
261
  "types": "./components/Tooltip/index.d.ts"
262
+ },
263
+ "./components/Tray": {
264
+ "import": "./components/Tray/index.js",
265
+ "types": "./components/Tray/index.d.ts"
262
266
  }
263
267
  },
264
268
  "dependencies": {
@@ -316,6 +316,24 @@ build), which is why it isn't for WordPress. Fonts and page layout stay yours. D
316
316
  screen-reader-only text or skip links: `.tui-visually-hidden` and `.tui-visually-hidden--focusable`
317
317
  already work when `<body>` is the interface.
318
318
 
319
+ **7. A Tray needs room reserved at the bottom of its scroll container.** `Tray` (an unsaved-changes,
320
+ undo or bulk-selection bar) is sticky at the end of its scroll container, or `placement="fixed"` to the
321
+ viewport. It can cover the field that has focus (WCAG 2.4.11). Reserve its height while it is open, on the
322
+ scroll container (or `html` when the document scrolls):
323
+
324
+ ```css
325
+ html:has(.tui-tray[data-state="open"]) {
326
+ scroll-padding-block-end: calc(var(--tui-tray-block-size, 4rem) + var(--tui-tray-offset, 1rem));
327
+ }
328
+ ```
329
+
330
+ This reduces the risk; it doesn't remove it (a field already half under the tray when focused can stay
331
+ partly covered). A fixed tray also needs the page to pad its own bottom by the same amount, and breaks out
332
+ of the viewport under a transformed, filtered or contained ancestor. Place the Tray in the DOM where it
333
+ belongs in the Tab order (after the form's fields); it never takes focus. It renders its live region as a
334
+ sibling, so it adds two children to its parent, not one. A save announcement ("Saved") is a Toast's job:
335
+ the tray just closes.
336
+
319
337
  ## Labels and errors: `Field` composition
320
338
 
321
339
  `Field` wires `id` / `aria-labelledby` / `aria-describedby` / `aria-invalid` / `aria-required`