@tangible/ui 0.0.12 → 0.0.13
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/Modal/Modal.d.ts +6 -3
- package/components/Modal/Modal.js +13 -2
- package/components/Notice/Notice.d.ts +6 -1
- package/components/Notice/Notice.js +2 -2
- package/package.json +1 -1
- package/styles/all.css +1 -1
- package/styles/all.expanded.css +96 -60
- package/styles/all.expanded.unlayered.css +96 -60
- package/styles/all.unlayered.css +1 -1
- package/styles/utilities/_index.scss +47 -14
- package/tui-manifest.json +37 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SizeStandard } from '../../types';
|
|
3
|
-
type Size = SizeStandard;
|
|
4
|
-
export type ModalProps = {
|
|
3
|
+
type Size = SizeStandard | 'xl';
|
|
4
|
+
export type ModalProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'role' | 'aria-modal' | 'tabIndex' | 'children'> & {
|
|
5
5
|
open: boolean;
|
|
6
6
|
onClose: () => void;
|
|
7
7
|
size?: Size;
|
|
@@ -21,9 +21,12 @@ export type ModalProps = {
|
|
|
21
21
|
* when focus is restored on close. Useful when the trigger may be off-screen
|
|
22
22
|
* inside a scrollable container. Default: false. */
|
|
23
23
|
preventScrollOnRestore?: boolean;
|
|
24
|
+
/** Additional class names applied to the dialog element (`.tui-modal__dialog`).
|
|
25
|
+
* Use for layout tweaks, custom widths, or context-specific theming. */
|
|
26
|
+
className?: string;
|
|
24
27
|
children?: React.ReactNode;
|
|
25
28
|
};
|
|
26
|
-
declare function ModalRoot({ open, onClose, size, stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, initialFocusSelector, container, showCloseButton, closeLabel, closeOnBackdropClick, closeOnEscape, preventScrollOnRestore, children, }: ModalProps): React.ReactPortal | null;
|
|
29
|
+
declare function ModalRoot({ open, onClose, size, stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, initialFocusSelector, container, showCloseButton, closeLabel, closeOnBackdropClick, closeOnEscape, preventScrollOnRestore, className, children, ...rest }: ModalProps): React.ReactPortal | null;
|
|
27
30
|
type ModalCloseProps = {
|
|
28
31
|
label?: string;
|
|
29
32
|
className?: string;
|
|
@@ -8,11 +8,22 @@ import { useFocusTrap, getInitialFocus } from '../../utils/focus-trap.js';
|
|
|
8
8
|
import { ModalContext, useModalContext } from './context.js';
|
|
9
9
|
import { IconButton } from '../IconButton/index.js';
|
|
10
10
|
const isBrowser = typeof document !== 'undefined';
|
|
11
|
-
function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, initialFocusSelector, container, showCloseButton, closeLabel = 'Close', closeOnBackdropClick = true, closeOnEscape = true, preventScrollOnRestore = false, children, }) {
|
|
11
|
+
function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, initialFocusSelector, container, showCloseButton, closeLabel = 'Close', closeOnBackdropClick = true, closeOnEscape = true, preventScrollOnRestore = false, className, children, ...rest }) {
|
|
12
12
|
const dialogRef = useRef(null);
|
|
13
13
|
const restoreRef = useRef(null);
|
|
14
14
|
const warnedRef = useRef(false);
|
|
15
|
+
const warnedAriaLabelRef = useRef(false);
|
|
15
16
|
const [mount, setMount] = useState(null);
|
|
17
|
+
// Dev warning: aria-label via ...rest silently competes with aria-labelledby
|
|
18
|
+
// (labelledby wins per AccName 1.2 step 2B, leaving aria-label dead code).
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (isDev() && !warnedAriaLabelRef.current && open && labelledBy && 'aria-label' in rest) {
|
|
21
|
+
warnedAriaLabelRef.current = true;
|
|
22
|
+
console.warn('[TUI Modal] Both `aria-labelledby` and `aria-label` are set. ' +
|
|
23
|
+
'`aria-labelledby` takes precedence; `aria-label` is ignored. ' +
|
|
24
|
+
'Remove one. Prefer `aria-labelledby` referencing a visible heading.');
|
|
25
|
+
}
|
|
26
|
+
}, [open, labelledBy, rest]);
|
|
16
27
|
// Dev warning: Modal should have an accessible name
|
|
17
28
|
useEffect(() => {
|
|
18
29
|
if (isDev() && !warnedRef.current && open && !labelledBy) {
|
|
@@ -130,7 +141,7 @@ function ModalRoot({ open, onClose, size = 'md', stickyHead, stickyFoot, 'aria-l
|
|
|
130
141
|
const contextValue = useMemo(() => ({ onClose }), [onClose]);
|
|
131
142
|
if (!open || !mount)
|
|
132
143
|
return null;
|
|
133
|
-
return createPortal(_jsx(ModalContext.Provider, { value: contextValue, children: _jsxs("div", { className: "tui-modal", "data-state": "open", style: { pointerEvents: 'auto' }, children: [_jsx("div", { className: "tui-modal__backdrop", onClick: closeOnBackdropClick ? onClose : undefined }), _jsxs("div", { ref: dialogRef, role: "dialog", "aria-modal": "true", "aria-labelledby": labelledBy, "aria-describedby": describedBy, className: cx('tui-modal__dialog', `is-size-${size}`, stickyHead && 'is-sticky-head', stickyFoot && 'is-sticky-foot'), tabIndex: -1, children: [showCloseButton && (_jsx(IconButton, { icon: "system/close", label: closeLabel, variant: "ghost", size: "sm", onClick: onClose, className: "tui-modal__close", showTooltip: true })), children] })] }) }), mount);
|
|
144
|
+
return createPortal(_jsx(ModalContext.Provider, { value: contextValue, children: _jsxs("div", { className: "tui-modal", "data-state": "open", style: { pointerEvents: 'auto' }, children: [_jsx("div", { className: "tui-modal__backdrop", onClick: closeOnBackdropClick ? onClose : undefined }), _jsxs("div", { ref: dialogRef, role: "dialog", "aria-modal": "true", "aria-labelledby": labelledBy, "aria-describedby": describedBy, className: cx('tui-modal__dialog', `is-size-${size}`, stickyHead && 'is-sticky-head', stickyFoot && 'is-sticky-foot', className), tabIndex: -1, ...rest, children: [showCloseButton && (_jsx(IconButton, { icon: "system/close", label: closeLabel, variant: "ghost", size: "sm", onClick: onClose, className: "tui-modal__close", showTooltip: true })), children] })] }) }), mount);
|
|
134
145
|
}
|
|
135
146
|
function ModalClose({ label = 'Close', className }) {
|
|
136
147
|
const { onClose } = useModalContext();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { JSX } from 'react';
|
|
3
|
-
import type { ThemeStatus } from '../../types';
|
|
3
|
+
import type { ThemeStatus, SizeStandard } from '../../types';
|
|
4
4
|
type RootAs = 'section' | 'div';
|
|
5
5
|
type HeadingAs = 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
6
6
|
type NoticeTheme = ThemeStatus;
|
|
@@ -20,6 +20,11 @@ type CommonProps = {
|
|
|
20
20
|
disabled?: boolean;
|
|
21
21
|
/** Show left accent stripe in theme color */
|
|
22
22
|
stripe?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Scale of padding, internal gap, title typography, and body text.
|
|
25
|
+
* Default 'md' emits no class.
|
|
26
|
+
*/
|
|
27
|
+
size?: SizeStandard;
|
|
23
28
|
className?: string;
|
|
24
29
|
style?: React.CSSProperties;
|
|
25
30
|
};
|
|
@@ -9,7 +9,7 @@ function prefersReducedMotion() {
|
|
|
9
9
|
return false;
|
|
10
10
|
return window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
11
11
|
}
|
|
12
|
-
export const Notice = forwardRef(function Notice({ as = 'section', inline, elevated, interactive, disabled, stripe, className, style, onClick, theme = 'info', announce = 'off', 'aria-label': ariaLabel, dismissible, onDismiss, dismissLabel = 'Dismiss', exitAnimation = 'none', focusable, children, ...rest }, ref) {
|
|
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
13
|
const Tag = as;
|
|
14
14
|
const innerRef = useRef(null);
|
|
15
15
|
const [isExiting, setIsExiting] = useState(false);
|
|
@@ -119,7 +119,7 @@ export const Notice = forwardRef(function Notice({ as = 'section', inline, eleva
|
|
|
119
119
|
// useLayoutEffect in NoticeHead ensures hasTitle is set before first paint.
|
|
120
120
|
const computedLabelledBy = hasTitle ? titleId : undefined;
|
|
121
121
|
const computedAriaLabel = hasTitle ? undefined : (ariaLabel || undefined);
|
|
122
|
-
const classes = cx('tui-notice', `is-theme-${theme}`, 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);
|
|
122
|
+
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);
|
|
123
123
|
// Dismiss button component
|
|
124
124
|
const dismissButton = dismissible && (_jsx(IconButton, { icon: "system/close", label: dismissLabel, size: "sm", variant: "ghost", className: "tui-notice__dismiss", onClick: (e) => {
|
|
125
125
|
e.stopPropagation();
|