@deque/cauldron-react 6.27.0-canary.06fc1451 → 6.27.0-canary.0c785dbd
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/lib/components/Checkbox/index.d.ts +2 -0
- package/lib/components/Dialog/DialogContext.d.ts +1 -0
- package/lib/components/Dialog/index.d.ts +1 -0
- package/lib/components/Modal/index.d.ts +2 -1
- package/lib/components/Toast/index.d.ts +7 -27
- package/lib/components/TreeView/TreeViewItem.d.ts +7 -0
- package/lib/components/TreeView/index.d.ts +13 -0
- package/lib/components/TreeView/types.d.ts +5 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +188 -156
- package/package.json +2 -1
|
@@ -7,6 +7,8 @@ export interface CheckboxProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
7
7
|
customIcon?: React.ReactNode;
|
|
8
8
|
checkboxRef?: React.ForwardedRef<HTMLInputElement>;
|
|
9
9
|
indeterminate?: boolean;
|
|
10
|
+
/** When true, the component does not manage its own checked state — it renders what you pass via `checked` and reports interactions through `onChange`. Use when state is managed by a parent component. */
|
|
11
|
+
controlled?: boolean;
|
|
10
12
|
}
|
|
11
13
|
declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
12
14
|
export default Checkbox;
|
|
@@ -12,6 +12,7 @@ export interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
12
12
|
};
|
|
13
13
|
closeButtonText?: string;
|
|
14
14
|
portal?: React.RefObject<HTMLElement> | HTMLElement;
|
|
15
|
+
scrollable?: boolean;
|
|
15
16
|
}
|
|
16
17
|
declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<HTMLDivElement>>;
|
|
17
18
|
export default Dialog;
|
|
@@ -2,8 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { DialogProps } from '../Dialog';
|
|
3
3
|
interface ModalProps extends Omit<DialogProps, 'forceAction'> {
|
|
4
4
|
variant?: 'info';
|
|
5
|
+
scrollable?: boolean;
|
|
5
6
|
}
|
|
6
|
-
declare const Modal: ({ children, className, variant, ...other }: ModalProps) => React.JSX.Element;
|
|
7
|
+
declare const Modal: ({ children, className, variant, scrollable, ...other }: ModalProps) => React.JSX.Element;
|
|
7
8
|
declare const ModalHeader: {
|
|
8
9
|
({ children, className, ...other }: import("../Dialog").DialogHeaderProps): React.JSX.Element;
|
|
9
10
|
displayName: string;
|
|
@@ -1,39 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import AriaIsolate from '../../utils/aria-isolate';
|
|
3
2
|
export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
3
|
type: 'confirmation' | 'caution' | 'error' | 'action-needed' | 'info';
|
|
5
|
-
onDismiss
|
|
4
|
+
onDismiss?: () => void;
|
|
6
5
|
dismissText?: string;
|
|
7
|
-
toastRef
|
|
6
|
+
toastRef?: React.Ref<HTMLDivElement>;
|
|
8
7
|
focus?: boolean;
|
|
9
8
|
show?: boolean;
|
|
10
9
|
dismissible?: boolean;
|
|
11
10
|
children: React.ReactNode;
|
|
12
11
|
}
|
|
13
|
-
interface ToastState {
|
|
14
|
-
animationClass: string;
|
|
15
|
-
isolator?: AriaIsolate;
|
|
16
|
-
}
|
|
17
12
|
/**
|
|
18
13
|
* The cauldron toast notification component
|
|
19
14
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
focus: boolean;
|
|
26
|
-
show: boolean;
|
|
27
|
-
dismissible: boolean;
|
|
28
|
-
};
|
|
29
|
-
static displayName: string;
|
|
30
|
-
private el;
|
|
31
|
-
constructor(props: ToastProps);
|
|
32
|
-
componentDidMount(): void;
|
|
33
|
-
componentDidUpdate(prevProps: ToastProps): void;
|
|
34
|
-
componentWillUnmount(): void;
|
|
35
|
-
render(): React.JSX.Element;
|
|
36
|
-
dismissToast(): void;
|
|
37
|
-
showToast(): void;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
15
|
+
declare const Toast: {
|
|
16
|
+
({ type, children, onDismiss, dismissText, toastRef, focus, show, dismissible, className, ...otherProps }: ToastProps): React.JSX.Element;
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
19
|
+
export default Toast;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Cauldron } from '../../types';
|
|
3
|
+
import { TreeViewNode } from './types';
|
|
4
|
+
export type { TreeViewNode } from './types';
|
|
5
|
+
type TreeViewProps = Cauldron.LabelProps & {
|
|
6
|
+
items: TreeViewNode[];
|
|
7
|
+
onAction?: (key: string) => void;
|
|
8
|
+
selectionMode?: 'none' | 'single' | 'multiple';
|
|
9
|
+
defaultExpandedKeys?: string[];
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const TreeView: React.ForwardRefExoticComponent<TreeViewProps & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export default TreeView;
|
package/lib/index.d.ts
CHANGED
|
@@ -68,6 +68,7 @@ export { default as SectionHeader } from './components/SectionHeader';
|
|
|
68
68
|
export { default as EmptyState } from './components/EmptyState';
|
|
69
69
|
export { ActionList, ActionListItem, ActionListGroup, ActionListSeparator, ActionListLinkItem } from './components/ActionList';
|
|
70
70
|
export { ActionMenu } from './components/ActionMenu';
|
|
71
|
+
export { default as TreeView, type TreeViewNode } from './components/TreeView';
|
|
71
72
|
/**
|
|
72
73
|
* Helpers / Utils
|
|
73
74
|
*/
|
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var js = require('react-syntax-highlighter/dist/cjs/languages/hljs/javascript');
|
|
|
16
16
|
var css = require('react-syntax-highlighter/dist/cjs/languages/hljs/css');
|
|
17
17
|
var xml = require('react-syntax-highlighter/dist/cjs/languages/hljs/xml');
|
|
18
18
|
var yaml = require('react-syntax-highlighter/dist/cjs/languages/hljs/yaml');
|
|
19
|
+
var reactAriaComponents = require('react-aria-components');
|
|
19
20
|
|
|
20
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
22
|
|
|
@@ -1357,6 +1358,7 @@ function useSharedRef(ref) {
|
|
|
1357
1358
|
var internalRef = React.useRef();
|
|
1358
1359
|
React.useEffect(function () {
|
|
1359
1360
|
setRef(ref, internalRef.current);
|
|
1361
|
+
return function () { return setRef(ref, null); };
|
|
1360
1362
|
}, [ref]);
|
|
1361
1363
|
return internalRef;
|
|
1362
1364
|
}
|
|
@@ -1532,9 +1534,9 @@ var isEscape = function (event) {
|
|
|
1532
1534
|
return event.key === 'Escape' || event.key === 'Esc' || event.keyCode === 27;
|
|
1533
1535
|
};
|
|
1534
1536
|
var Dialog = React.forwardRef(function (_a, ref) {
|
|
1535
|
-
var dialogRefProp = _a.dialogRef, _b = _a.forceAction, forceAction = _b === void 0 ? false : _b, className = _a.className, children = _a.children, _c = _a.closeButtonText, closeButtonText = _c === void 0 ? 'Close' : _c, heading = _a.heading, _d = _a.show, show = _d === void 0 ? false : _d, portal = _a.portal, _e = _a.onClose, onClose =
|
|
1537
|
+
var dialogRefProp = _a.dialogRef, _b = _a.forceAction, forceAction = _b === void 0 ? false : _b, className = _a.className, children = _a.children, _c = _a.closeButtonText, closeButtonText = _c === void 0 ? 'Close' : _c, heading = _a.heading, _d = _a.show, show = _d === void 0 ? false : _d, portal = _a.portal, _e = _a.scrollable, scrollable = _e === void 0 ? false : _e, _f = _a.onClose, onClose = _f === void 0 ? function () { return null; } : _f, other = tslib.__rest(_a, ["dialogRef", "forceAction", "className", "children", "closeButtonText", "heading", "show", "portal", "scrollable", "onClose"]);
|
|
1536
1538
|
var dialogRef = useSharedRef(dialogRefProp || ref);
|
|
1537
|
-
var
|
|
1539
|
+
var _g = tslib.__read(nextId.useId(1, 'dialog-title-'), 1), headingId = _g[0];
|
|
1538
1540
|
var headingRef = React.useRef(null);
|
|
1539
1541
|
var isolatorRef = React.useRef();
|
|
1540
1542
|
var headingLevel = typeof heading === 'object' && 'level' in heading && heading.level
|
|
@@ -1605,14 +1607,16 @@ var Dialog = React.forwardRef(function (_a, ref) {
|
|
|
1605
1607
|
headingLevel: headingLevel,
|
|
1606
1608
|
onClose: handleClose,
|
|
1607
1609
|
forceAction: forceAction,
|
|
1608
|
-
closeButtonText: closeButtonText
|
|
1610
|
+
closeButtonText: closeButtonText,
|
|
1611
|
+
scrollable: scrollable
|
|
1609
1612
|
}); }, [
|
|
1610
1613
|
headingId,
|
|
1611
1614
|
headingRef,
|
|
1612
1615
|
headingLevel,
|
|
1613
1616
|
handleClose,
|
|
1614
1617
|
forceAction,
|
|
1615
|
-
closeButtonText
|
|
1618
|
+
closeButtonText,
|
|
1619
|
+
scrollable
|
|
1616
1620
|
]);
|
|
1617
1621
|
if (!show || !isBrowser()) {
|
|
1618
1622
|
return null;
|
|
@@ -1642,11 +1646,12 @@ var Dialog = React.forwardRef(function (_a, ref) {
|
|
|
1642
1646
|
Dialog.displayName = 'Dialog';
|
|
1643
1647
|
var DialogContent = function (_a) {
|
|
1644
1648
|
var children = _a.children, className = _a.className, align = _a.align, other = tslib.__rest(_a, ["children", "className", "align"]);
|
|
1649
|
+
var context = React.useContext(DialogContext);
|
|
1645
1650
|
return (React__default["default"].createElement("div", tslib.__assign({ className: classNames__default["default"]('Dialog__content', className, {
|
|
1646
1651
|
'text--align-left': align === 'left',
|
|
1647
1652
|
'text--align-center': align === 'center',
|
|
1648
1653
|
'text--align-right': align === 'right'
|
|
1649
|
-
}) }, other), children));
|
|
1654
|
+
}), tabIndex: (context === null || context === void 0 ? void 0 : context.scrollable) ? -1 : undefined }, other), children));
|
|
1650
1655
|
};
|
|
1651
1656
|
DialogContent.displayName = 'DialogContent';
|
|
1652
1657
|
var DialogFooter = function (_a) {
|
|
@@ -1700,10 +1705,11 @@ var AlertContent = DialogContent;
|
|
|
1700
1705
|
var AlertActions = DialogFooter;
|
|
1701
1706
|
|
|
1702
1707
|
var Modal = function (_a) {
|
|
1703
|
-
var children = _a.children, className = _a.className, variant = _a.variant, other = tslib.__rest(_a, ["children", "className", "variant"]);
|
|
1708
|
+
var children = _a.children, className = _a.className, variant = _a.variant, scrollable = _a.scrollable, other = tslib.__rest(_a, ["children", "className", "variant", "scrollable"]);
|
|
1704
1709
|
return (React__default["default"].createElement(Dialog, tslib.__assign({ className: classNames__default["default"]('Modal', className, {
|
|
1705
|
-
'Modal--info': variant === 'info'
|
|
1706
|
-
|
|
1710
|
+
'Modal--info': variant === 'info',
|
|
1711
|
+
'Modal--scrollable': scrollable
|
|
1712
|
+
}) }, other, { scrollable: scrollable, forceAction: false }), children));
|
|
1707
1713
|
};
|
|
1708
1714
|
var ModalHeader = DialogHeader;
|
|
1709
1715
|
var ModalHeading = DialogHeading;
|
|
@@ -2029,10 +2035,17 @@ function Tooltip(_a) {
|
|
|
2029
2035
|
fireCustomEvent(false, targetElement);
|
|
2030
2036
|
}, TIP_HIDE_DELAY);
|
|
2031
2037
|
}
|
|
2038
|
+
}, [target]);
|
|
2039
|
+
// Cancel any pending hide timeout when the Tooltip unmounts so it
|
|
2040
|
+
// does not fire setShowTooltip on an unmounted component.
|
|
2041
|
+
React.useEffect(function () {
|
|
2032
2042
|
return function () {
|
|
2033
|
-
|
|
2043
|
+
if (hideTimeoutRef.current) {
|
|
2044
|
+
clearTimeout(hideTimeoutRef.current);
|
|
2045
|
+
hideTimeoutRef.current = null;
|
|
2046
|
+
}
|
|
2034
2047
|
};
|
|
2035
|
-
}, [
|
|
2048
|
+
}, []);
|
|
2036
2049
|
React.useEffect(function () {
|
|
2037
2050
|
if (typeof showProp === 'boolean') {
|
|
2038
2051
|
setShowTooltip(showProp);
|
|
@@ -2209,126 +2222,110 @@ var tabIndexHandler = function (reset, toast) {
|
|
|
2209
2222
|
};
|
|
2210
2223
|
|
|
2211
2224
|
/**
|
|
2212
|
-
*
|
|
2225
|
+
* Hook to be used similarly to the React.Component#componentDidMount.
|
|
2226
|
+
* Executes the provided `effect` when `dependencies` change but does not
|
|
2227
|
+
* execute the effect initially (on mount) - only on update.
|
|
2228
|
+
*
|
|
2229
|
+
* @param effect {Function} function to be executed when dependencies update
|
|
2230
|
+
* @param dependencies {Any} any valid dependency argument to React.useEffect
|
|
2213
2231
|
*/
|
|
2214
|
-
var
|
|
2215
|
-
|
|
2216
|
-
function
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
};
|
|
2221
|
-
_this.dismissToast = _this.dismissToast.bind(_this);
|
|
2222
|
-
_this.showToast = _this.showToast.bind(_this);
|
|
2223
|
-
return _this;
|
|
2224
|
-
}
|
|
2225
|
-
Toast.prototype.componentDidMount = function () {
|
|
2226
|
-
var show = this.props.show;
|
|
2227
|
-
if (show) {
|
|
2228
|
-
// Timeout because CSS display: none/block and opacity:
|
|
2229
|
-
// 0/1 properties cannot be toggled in the same tick
|
|
2230
|
-
// see: https://codepen.io/isnerms/pen/eyQaLP
|
|
2231
|
-
setTimeout(this.showToast);
|
|
2232
|
+
var useDidUpdate = function (effect, dependencies) {
|
|
2233
|
+
var mounted = React__default["default"].useRef(false);
|
|
2234
|
+
React__default["default"].useEffect(function () {
|
|
2235
|
+
if (!mounted.current) {
|
|
2236
|
+
mounted.current = true;
|
|
2237
|
+
return;
|
|
2232
2238
|
}
|
|
2239
|
+
effect();
|
|
2240
|
+
}, dependencies);
|
|
2241
|
+
};
|
|
2242
|
+
|
|
2243
|
+
/**
|
|
2244
|
+
* The cauldron toast notification component
|
|
2245
|
+
*/
|
|
2246
|
+
var Toast = function (_a) {
|
|
2247
|
+
var type = _a.type, children = _a.children, _b = _a.onDismiss, onDismiss = _b === void 0 ? function () {
|
|
2248
|
+
// noop
|
|
2249
|
+
} : _b, _c = _a.dismissText, dismissText = _c === void 0 ? 'Dismiss' : _c, toastRef = _a.toastRef, _d = _a.focus, focus = _d === void 0 ? true : _d, _e = _a.show, show = _e === void 0 ? false : _e, _f = _a.dismissible, dismissible = _f === void 0 ? true : _f, className = _a.className, otherProps = tslib.__rest(_a, ["type", "children", "onDismiss", "dismissText", "toastRef", "focus", "show", "dismissible", "className"]);
|
|
2250
|
+
var elRef = useSharedRef(toastRef !== null && toastRef !== void 0 ? toastRef : null);
|
|
2251
|
+
var isolatorRef = React.useRef(null);
|
|
2252
|
+
var timeoutsRef = React.useRef(new Set());
|
|
2253
|
+
var _g = tslib.__read(React.useState(show ? 'FadeIn--flex' : 'is--hidden'), 2), animationClass = _g[0], setAnimationClass = _g[1];
|
|
2254
|
+
// Timeout because CSS display: none/block and opacity:
|
|
2255
|
+
// 0/1 properties cannot be toggled in the same tick
|
|
2256
|
+
// see: https://codepen.io/isnerms/pen/eyQaLP
|
|
2257
|
+
var scheduleNextTick = function (fn) {
|
|
2258
|
+
var id = setTimeout(function () {
|
|
2259
|
+
timeoutsRef.current.delete(id);
|
|
2260
|
+
fn();
|
|
2261
|
+
});
|
|
2262
|
+
timeoutsRef.current.add(id);
|
|
2233
2263
|
};
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
});
|
|
2242
|
-
}
|
|
2243
|
-
else {
|
|
2244
|
-
this.dismissToast();
|
|
2245
|
-
}
|
|
2264
|
+
var showToast = React.useCallback(function () {
|
|
2265
|
+
setAnimationClass('FadeIn--flex FadeIn');
|
|
2266
|
+
if (type === 'action-needed' && elRef.current) {
|
|
2267
|
+
var isolator = new AriaIsolate(elRef.current);
|
|
2268
|
+
tabIndexHandler(false, elRef.current);
|
|
2269
|
+
isolatorRef.current = isolator;
|
|
2270
|
+
isolator.activate();
|
|
2246
2271
|
}
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
var isolator = this.state.isolator;
|
|
2250
|
-
isolator === null || isolator === void 0 ? void 0 : isolator.deactivate();
|
|
2251
|
-
};
|
|
2252
|
-
Toast.prototype.render = function () {
|
|
2253
|
-
var _this = this;
|
|
2254
|
-
var animationClass = this.state.animationClass;
|
|
2255
|
-
var _a = this.props, type = _a.type, children = _a.children;
|
|
2256
|
-
// prevent `onDismiss` from being passed-through to DOM
|
|
2257
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2258
|
-
_a.onDismiss; var dismissText = _a.dismissText, toastRef = _a.toastRef, focus = _a.focus, show = _a.show, dismissible = _a.dismissible, className = _a.className, otherProps = tslib.__rest(_a, ["type", "children", "onDismiss", "dismissText", "toastRef", "focus", "show", "dismissible", "className"]);
|
|
2259
|
-
var scrim = type === 'action-needed' && show ? (React__default["default"].createElement("div", { className: "Scrim--light Scrim--show Scrim--fade-in" })) : null;
|
|
2260
|
-
var defaultProps = {
|
|
2261
|
-
tabIndex: -1,
|
|
2262
|
-
className: classNames__default["default"]('Toast', "Toast--".concat(typeMap[type].className), animationClass, { 'Toast--non-dismissible': !dismissible }, className)
|
|
2263
|
-
};
|
|
2264
|
-
if (!focus) {
|
|
2265
|
-
defaultProps.role = 'alert';
|
|
2272
|
+
if (elRef.current && !!focus) {
|
|
2273
|
+
elRef.current.focus();
|
|
2266
2274
|
}
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
setRef(toastRef, el);
|
|
2271
|
-
} }, defaultProps, otherProps),
|
|
2272
|
-
React__default["default"].createElement("div", { className: "Toast__message" },
|
|
2273
|
-
React__default["default"].createElement(Icon, { type: typeMap[type].icon }),
|
|
2274
|
-
React__default["default"].createElement("div", { className: "Toast__message-content" }, children)),
|
|
2275
|
-
type !== 'action-needed' && dismissible && (React__default["default"].createElement("button", { type: "button", className: 'Toast__dismiss', "aria-label": dismissText, onClick: this.dismissToast },
|
|
2276
|
-
React__default["default"].createElement(Icon, { type: "close" })))),
|
|
2277
|
-
scrim));
|
|
2278
|
-
};
|
|
2279
|
-
Toast.prototype.dismissToast = function () {
|
|
2280
|
-
var _this = this;
|
|
2281
|
-
if (!this.el) {
|
|
2275
|
+
}, [type, focus]);
|
|
2276
|
+
var dismissToast = React.useCallback(function () {
|
|
2277
|
+
if (!elRef.current) {
|
|
2282
2278
|
return;
|
|
2283
2279
|
}
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
animationClass: 'FadeIn--flex'
|
|
2288
|
-
}, function () {
|
|
2289
|
-
// Timeout because CSS display: none/block and opacity:
|
|
2290
|
-
// 0/1 properties cannot be toggled in the same tick
|
|
2291
|
-
// see: https://codepen.io/isnerms/pen/eyQaLP
|
|
2292
|
-
setTimeout(function () {
|
|
2293
|
-
if (type === 'action-needed') {
|
|
2294
|
-
tabIndexHandler(true, _this.el);
|
|
2295
|
-
isolator === null || isolator === void 0 ? void 0 : isolator.deactivate();
|
|
2296
|
-
}
|
|
2297
|
-
_this.setState({ animationClass: 'is--hidden' }, onDismiss);
|
|
2298
|
-
});
|
|
2299
|
-
});
|
|
2300
|
-
};
|
|
2301
|
-
Toast.prototype.showToast = function () {
|
|
2302
|
-
var _this = this;
|
|
2303
|
-
var _a = this.props, type = _a.type, focus = _a.focus;
|
|
2304
|
-
this.setState({
|
|
2305
|
-
animationClass: 'FadeIn--flex FadeIn'
|
|
2306
|
-
}, function () {
|
|
2280
|
+
setAnimationClass('FadeIn--flex');
|
|
2281
|
+
scheduleNextTick(function () {
|
|
2282
|
+
var _a;
|
|
2307
2283
|
if (type === 'action-needed') {
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
_this.setState({ isolator: isolator });
|
|
2311
|
-
isolator.activate();
|
|
2312
|
-
}
|
|
2313
|
-
if (_this.el && !!focus) {
|
|
2314
|
-
// focus the toast
|
|
2315
|
-
_this.el.focus();
|
|
2284
|
+
tabIndexHandler(true, elRef.current);
|
|
2285
|
+
(_a = isolatorRef.current) === null || _a === void 0 ? void 0 : _a.deactivate();
|
|
2316
2286
|
}
|
|
2287
|
+
setAnimationClass('is--hidden');
|
|
2288
|
+
onDismiss();
|
|
2317
2289
|
});
|
|
2290
|
+
}, [type, onDismiss]);
|
|
2291
|
+
React.useEffect(function () {
|
|
2292
|
+
if (show) {
|
|
2293
|
+
scheduleNextTick(showToast);
|
|
2294
|
+
}
|
|
2295
|
+
return function () {
|
|
2296
|
+
var _a;
|
|
2297
|
+
timeoutsRef.current.forEach(clearTimeout);
|
|
2298
|
+
timeoutsRef.current.clear();
|
|
2299
|
+
(_a = isolatorRef.current) === null || _a === void 0 ? void 0 : _a.deactivate();
|
|
2300
|
+
};
|
|
2301
|
+
}, []);
|
|
2302
|
+
useDidUpdate(function () {
|
|
2303
|
+
if (show) {
|
|
2304
|
+
setAnimationClass('FadeIn--flex');
|
|
2305
|
+
scheduleNextTick(showToast);
|
|
2306
|
+
}
|
|
2307
|
+
else {
|
|
2308
|
+
dismissToast();
|
|
2309
|
+
}
|
|
2310
|
+
}, [show]);
|
|
2311
|
+
var scrim = type === 'action-needed' && show ? (React__default["default"].createElement("div", { className: "Scrim--light Scrim--show Scrim--fade-in" })) : null;
|
|
2312
|
+
var defaultProps = {
|
|
2313
|
+
tabIndex: -1,
|
|
2314
|
+
className: classNames__default["default"]('Toast', "Toast--".concat(typeMap[type].className), animationClass, { 'Toast--non-dismissible': !dismissible }, className)
|
|
2318
2315
|
};
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2316
|
+
if (!focus) {
|
|
2317
|
+
defaultProps.role = 'alert';
|
|
2318
|
+
}
|
|
2319
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2320
|
+
React__default["default"].createElement("div", tslib.__assign({ ref: elRef }, defaultProps, otherProps),
|
|
2321
|
+
React__default["default"].createElement("div", { className: "Toast__message" },
|
|
2322
|
+
React__default["default"].createElement(Icon, { type: typeMap[type].icon }),
|
|
2323
|
+
React__default["default"].createElement("div", { className: "Toast__message-content" }, children)),
|
|
2324
|
+
type !== 'action-needed' && dismissible && (React__default["default"].createElement("button", { type: "button", className: "Toast__dismiss", "aria-label": dismissText, onClick: dismissToast },
|
|
2325
|
+
React__default["default"].createElement(Icon, { type: "close" })))),
|
|
2326
|
+
scrim));
|
|
2327
|
+
};
|
|
2328
|
+
Toast.displayName = 'Toast';
|
|
2332
2329
|
|
|
2333
2330
|
var Link = React.forwardRef(function (_a, ref) {
|
|
2334
2331
|
var children = _a.children, linkRef = _a.linkRef, className = _a.className, variant = _a.variant, thin = _a.thin, other = tslib.__rest(_a, ["children", "linkRef", "className", "variant", "thin"]);
|
|
@@ -2595,10 +2592,10 @@ var RadioCardGroup = function (_a) {
|
|
|
2595
2592
|
RadioCardGroup.displayName = 'RadioCardGroup';
|
|
2596
2593
|
|
|
2597
2594
|
var Checkbox = React.forwardRef(function (_a, ref) {
|
|
2598
|
-
var id = _a.id, label = _a.label, labelDescription = _a.labelDescription, error = _a.error, checkboxRef = _a.checkboxRef, className = _a.className, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur, ariaDescribedby = _a["aria-describedby"],
|
|
2599
|
-
var
|
|
2600
|
-
var
|
|
2601
|
-
var
|
|
2595
|
+
var id = _a.id, label = _a.label, labelDescription = _a.labelDescription, error = _a.error, checkboxRef = _a.checkboxRef, className = _a.className, onChange = _a.onChange, _b = _a.controlled, controlled = _b === void 0 ? false : _b, onFocus = _a.onFocus, onBlur = _a.onBlur, ariaDescribedby = _a["aria-describedby"], _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.checked, checked = _d === void 0 ? false : _d, _e = _a.indeterminate, indeterminate = _e === void 0 ? false : _e; _a.children; var other = tslib.__rest(_a, ["id", "label", "labelDescription", "error", "checkboxRef", "className", "onChange", "controlled", "onFocus", "onBlur", 'aria-describedby', "disabled", "checked", "indeterminate", "children"]);
|
|
2596
|
+
var _f = tslib.__read(React.useState(checked), 2), isChecked = _f[0], setIsChecked = _f[1];
|
|
2597
|
+
var _g = tslib.__read(React.useState(indeterminate), 2), isIndeterminate = _g[0], setIsIndeterminate = _g[1];
|
|
2598
|
+
var _h = tslib.__read(React.useState(false), 2), focused = _h[0], setFocused = _h[1];
|
|
2602
2599
|
var checkRef = React.useRef(null);
|
|
2603
2600
|
React.useEffect(function () {
|
|
2604
2601
|
setIsChecked(checked);
|
|
@@ -2610,12 +2607,12 @@ var Checkbox = React.forwardRef(function (_a, ref) {
|
|
|
2610
2607
|
if (typeof refProp === 'function') {
|
|
2611
2608
|
refProp(checkRef.current);
|
|
2612
2609
|
}
|
|
2613
|
-
var
|
|
2610
|
+
var _j = React.useMemo(function () {
|
|
2614
2611
|
return {
|
|
2615
2612
|
labelDescriptionId: nextId__default["default"](),
|
|
2616
2613
|
errorId: nextId__default["default"]()
|
|
2617
2614
|
};
|
|
2618
|
-
}, []), errorId =
|
|
2615
|
+
}, []), errorId = _j.errorId, labelDescriptionId = _j.labelDescriptionId;
|
|
2619
2616
|
var ariaDescribedbyId = ariaDescribedby;
|
|
2620
2617
|
if (error) {
|
|
2621
2618
|
ariaDescribedbyId = addIdRef(ariaDescribedbyId, errorId);
|
|
@@ -2654,7 +2651,9 @@ var Checkbox = React.forwardRef(function (_a, ref) {
|
|
|
2654
2651
|
if (isIndeterminate) {
|
|
2655
2652
|
setIsIndeterminate(false);
|
|
2656
2653
|
}
|
|
2657
|
-
|
|
2654
|
+
if (!controlled) {
|
|
2655
|
+
setIsChecked(e.target.checked);
|
|
2656
|
+
}
|
|
2658
2657
|
if (onChange) {
|
|
2659
2658
|
onChange(e);
|
|
2660
2659
|
}
|
|
@@ -3227,25 +3226,6 @@ var Tab = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
3227
3226
|
});
|
|
3228
3227
|
Tab.displayName = 'Tab';
|
|
3229
3228
|
|
|
3230
|
-
/**
|
|
3231
|
-
* Hook to be used similarly to the React.Component#componentDidMount.
|
|
3232
|
-
* Executes the provided `effect` when `dependencies` change but does not
|
|
3233
|
-
* execute the effect initially (on mount) - only on update.
|
|
3234
|
-
*
|
|
3235
|
-
* @param effect {Function} function to be executed when dependencies update
|
|
3236
|
-
* @param dependencies {Any} any valid dependency argument to React.useEffect
|
|
3237
|
-
*/
|
|
3238
|
-
var useDidUpdate = function (effect, dependencies) {
|
|
3239
|
-
var mounted = React__default["default"].useRef(false);
|
|
3240
|
-
React__default["default"].useEffect(function () {
|
|
3241
|
-
if (!mounted.current) {
|
|
3242
|
-
mounted.current = true;
|
|
3243
|
-
return;
|
|
3244
|
-
}
|
|
3245
|
-
effect();
|
|
3246
|
-
}, dependencies);
|
|
3247
|
-
};
|
|
3248
|
-
|
|
3249
3229
|
var Tabs = function (_a) {
|
|
3250
3230
|
var children = _a.children, thin = _a.thin, _b = _a.orientation, orientation = _b === void 0 ? 'horizontal' : _b, _c = _a.initialActiveIndex, initialActiveIndex = _c === void 0 ? 0 : _c, className = _a.className, onChange = _a.onChange, labelProp = tslib.__rest(_a, ["children", "thin", "orientation", "initialActiveIndex", "className", "onChange"]);
|
|
3251
3231
|
var _d = tslib.__read(React.useState(initialActiveIndex), 2), activeIndex = _d[0], setActiveIndex = _d[1];
|
|
@@ -4602,16 +4582,6 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4602
4582
|
: ComboboxNoResults;
|
|
4603
4583
|
}, [renderNoResults]);
|
|
4604
4584
|
var noMatchingOptions = !!inputValue && !matchingOptions.size && (React__default["default"].createElement(NoMatchingOptions, null));
|
|
4605
|
-
var comboboxListbox = (
|
|
4606
|
-
// eslint-disable-next-line
|
|
4607
|
-
// @ts-expect-error
|
|
4608
|
-
// multiselect & value props are passed to Listbox, but TS is unable to infer that
|
|
4609
|
-
// it's a correct mapping from Combobox's multiselect & value props
|
|
4610
|
-
React__default["default"].createElement(Listbox, { className: classNames__default["default"]('Combobox__listbox', {
|
|
4611
|
-
'Combobox__listbox--open': open
|
|
4612
|
-
}), role: noMatchingOptions ? 'presentation' : 'listbox', "aria-labelledby": noMatchingOptions ? undefined : "".concat(id, "-label"), id: "".concat(id, "-listbox"), value: multiselect ? selectedValues : selectedValues[0], onMouseDown: handleComboboxOptionMouseDown, onClick: handleComboboxOptionClick, onSelectionChange: handleSelectionChange, onActiveChange: handleActiveChange, ref: listboxRef, tabIndex: noMatchingOptions ? undefined : -1, "aria-activedescendant": undefined, multiselect: multiselect, disabled: disabled },
|
|
4613
|
-
comboboxOptions,
|
|
4614
|
-
noMatchingOptions));
|
|
4615
4585
|
var errorId = "".concat(id, "-error");
|
|
4616
4586
|
var descriptionId = "".concat(id, "-description");
|
|
4617
4587
|
var describedby = ariaDescribedby;
|
|
@@ -4622,6 +4592,16 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4622
4592
|
describedby = addIdRef(describedby, errorId);
|
|
4623
4593
|
}
|
|
4624
4594
|
var inputProps = tslib.__assign(tslib.__assign({}, props), { 'aria-describedby': describedby });
|
|
4595
|
+
var comboboxListbox = (
|
|
4596
|
+
// eslint-disable-next-line
|
|
4597
|
+
// @ts-expect-error
|
|
4598
|
+
// multiselect & value props are passed to Listbox, but TS is unable to infer that
|
|
4599
|
+
// it's a correct mapping from Combobox's multiselect & value props
|
|
4600
|
+
React__default["default"].createElement(Listbox, { className: classNames__default["default"]('Combobox__listbox', {
|
|
4601
|
+
'Combobox__listbox--open': open
|
|
4602
|
+
}), role: noMatchingOptions ? 'presentation' : 'listbox', "aria-labelledby": noMatchingOptions ? undefined : "".concat(id, "-label"), "aria-describedby": describedby, id: "".concat(id, "-listbox"), value: multiselect ? selectedValues : selectedValues[0], onMouseDown: handleComboboxOptionMouseDown, onClick: handleComboboxOptionClick, onSelectionChange: handleSelectionChange, onActiveChange: handleActiveChange, ref: listboxRef, tabIndex: noMatchingOptions ? undefined : -1, "aria-activedescendant": undefined, multiselect: multiselect, disabled: disabled },
|
|
4603
|
+
comboboxOptions,
|
|
4604
|
+
noMatchingOptions));
|
|
4625
4605
|
return (React__default["default"].createElement("div", { id: id, className: classNames__default["default"]('Combobox', { 'Combobox--multiselect': multiselect }, className), ref: comboboxRef },
|
|
4626
4606
|
name &&
|
|
4627
4607
|
formValues.map(function (formValue, index) { return (React__default["default"].createElement("input", { type: "hidden", key: index, name: name, value: formValue })); }),
|
|
@@ -4654,7 +4634,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
|
|
|
4654
4634
|
};
|
|
4655
4635
|
return (React__default["default"].createElement(ComboboxPill, { ref: refCallback, key: value, value: value, removeOptionLabel: removeOptionLabels[index], disabled: disabled, onClick: handleClick, onKeyDown: handlePillKeyDown }));
|
|
4656
4636
|
}),
|
|
4657
|
-
React__default["default"].createElement("input", tslib.__assign({ type: "text", id: "".concat(id, "-input"), ref: inputRef, value: inputValue, role: "combobox", disabled: disabled, "aria-autocomplete": !isAutoComplete ? 'none' : 'list', "aria-controls": "".concat(id, "-listbox"), "aria-expanded": open, "aria-haspopup": "listbox", "aria-activedescendant": open && activeDescendant ? activeDescendant.element.id : undefined }, inputProps, { onChange: handleChange, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur })),
|
|
4637
|
+
React__default["default"].createElement("input", tslib.__assign({ type: "text", id: "".concat(id, "-input"), ref: inputRef, value: inputValue, role: "combobox", disabled: disabled, "aria-invalid": error ? true : undefined, "aria-autocomplete": !isAutoComplete ? 'none' : 'list', "aria-controls": "".concat(id, "-listbox"), "aria-expanded": open, "aria-haspopup": "listbox", "aria-activedescendant": open && activeDescendant ? activeDescendant.element.id : undefined }, inputProps, { onChange: handleChange, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur })),
|
|
4658
4638
|
React__default["default"].createElement("span", { className: "Combobox__arrow" })),
|
|
4659
4639
|
React__default["default"].createElement(ComboboxProvider, { autocomplete: autocomplete, inputValue: inputValue, formValues: formValues, selectedValues: selectedValues, removeOptionLabels: removeOptionLabels, setRemoveOptionLabels: setRemoveOptionLabels, matches: !isAutoComplete || defaultAutoCompleteMatches, matchingOptions: matchingOptions, setMatchingOptions: setMatchingOptions, setFormValues: setFormValues }, portal && typeof document !== 'undefined'
|
|
4660
4640
|
? reactDom.createPortal(comboboxListbox,
|
|
@@ -5421,6 +5401,57 @@ var ActionMenu = React.forwardRef(function (_a, ref) {
|
|
|
5421
5401
|
});
|
|
5422
5402
|
ActionMenu.displayName = 'ActionMenu';
|
|
5423
5403
|
|
|
5404
|
+
var TreeViewItem = function (_a) {
|
|
5405
|
+
var id = _a.id, textValue = _a.textValue, children = _a.children;
|
|
5406
|
+
var checkboxId = React.useMemo(function () { return nextId__default["default"]('tree-view-item-'); }, []);
|
|
5407
|
+
return (React__default["default"].createElement(reactAriaComponents.TreeItem, { id: id, textValue: textValue, className: "TreeView__item" },
|
|
5408
|
+
React__default["default"].createElement(reactAriaComponents.TreeItemContent, null, function (_a) {
|
|
5409
|
+
var selectionMode = _a.selectionMode, isSelected = _a.isSelected;
|
|
5410
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5411
|
+
React__default["default"].createElement(reactAriaComponents.Button, { slot: "chevron", className: "TreeView__chevron" },
|
|
5412
|
+
React__default["default"].createElement(Icon, { type: "chevron-right" })),
|
|
5413
|
+
selectionMode !== 'none' ? (React__default["default"].createElement(Checkbox, { id: checkboxId, label: textValue, checked: isSelected, controlled: true, tabIndex: -1 })) : (React__default["default"].createElement(React__default["default"].Fragment, null, textValue))));
|
|
5414
|
+
}),
|
|
5415
|
+
children && children.length > 0 && (React__default["default"].createElement(reactAriaComponents.Collection, null, children.map(function (child) { return (React__default["default"].createElement(TreeViewItem, tslib.__assign({ key: child.id }, child))); })))));
|
|
5416
|
+
};
|
|
5417
|
+
TreeViewItem.displayName = 'TreeViewItem';
|
|
5418
|
+
|
|
5419
|
+
function collectAllKeys(nodes) {
|
|
5420
|
+
return nodes.flatMap(function (node) { return tslib.__spreadArray([
|
|
5421
|
+
node.id
|
|
5422
|
+
], tslib.__read((node.children ? collectAllKeys(node.children) : [])), false); });
|
|
5423
|
+
}
|
|
5424
|
+
var TreeView = React.forwardRef(function (_a, ref) {
|
|
5425
|
+
var items = _a.items, onAction = _a.onAction, _b = _a.selectionMode, selectionMode = _b === void 0 ? 'none' : _b, defaultExpandedKeys = _a.defaultExpandedKeys, className = _a.className, other = tslib.__rest(_a, ["items", "onAction", "selectionMode", "defaultExpandedKeys", "className"]);
|
|
5426
|
+
var _c = tslib.__read(React.useState(new Set()), 2), selectedKeys = _c[0], setSelectedKeys = _c[1];
|
|
5427
|
+
var handleAction = function (key) {
|
|
5428
|
+
setSelectedKeys(function (prev) {
|
|
5429
|
+
var prevSet = prev === 'all' ? new Set(collectAllKeys(items)) : new Set(prev);
|
|
5430
|
+
var next = new Set(prevSet);
|
|
5431
|
+
if (next.has(key)) {
|
|
5432
|
+
next.delete(key);
|
|
5433
|
+
}
|
|
5434
|
+
else {
|
|
5435
|
+
if (selectionMode === 'single') {
|
|
5436
|
+
next.clear();
|
|
5437
|
+
}
|
|
5438
|
+
next.add(key);
|
|
5439
|
+
}
|
|
5440
|
+
return next;
|
|
5441
|
+
});
|
|
5442
|
+
onAction === null || onAction === void 0 ? void 0 : onAction(key);
|
|
5443
|
+
};
|
|
5444
|
+
var actionProps = onAction
|
|
5445
|
+
? {
|
|
5446
|
+
onAction: handleAction,
|
|
5447
|
+
selectedKeys: selectedKeys,
|
|
5448
|
+
onSelectionChange: setSelectedKeys
|
|
5449
|
+
}
|
|
5450
|
+
: {};
|
|
5451
|
+
return (React__default["default"].createElement(reactAriaComponents.Tree, tslib.__assign({ ref: ref, className: classNames__default["default"]('TreeView', className), selectionMode: selectionMode, defaultExpandedKeys: defaultExpandedKeys }, actionProps, other), items.map(function (item) { return (React__default["default"].createElement(TreeViewItem, tslib.__assign({ key: item.id }, item))); })));
|
|
5452
|
+
});
|
|
5453
|
+
TreeView.displayName = 'TreeView';
|
|
5454
|
+
|
|
5424
5455
|
var LIGHT_THEME_CLASS = 'cauldron--theme-light';
|
|
5425
5456
|
var DARK_THEME_CLASS = 'cauldron--theme-dark';
|
|
5426
5457
|
var ThemeContext = React.createContext({
|
|
@@ -5616,6 +5647,7 @@ exports.TopBar = TopBar;
|
|
|
5616
5647
|
exports.TopBarItem = MenuItem;
|
|
5617
5648
|
exports.TopBarMenu = TopBarMenu;
|
|
5618
5649
|
exports.TopBarTrigger = TopBarTrigger;
|
|
5650
|
+
exports.TreeView = TreeView;
|
|
5619
5651
|
exports.TwoColumnPanel = TwoColumnPanel;
|
|
5620
5652
|
exports.Workspace = Workspace;
|
|
5621
5653
|
exports.focusableSelector = focusableSelector;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deque/cauldron-react",
|
|
3
|
-
"version": "6.27.0-canary.
|
|
3
|
+
"version": "6.27.0-canary.0c785dbd",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Fully accessible react components library for Deque Cauldron",
|
|
6
6
|
"homepage": "https://cauldron.dequelabs.com/",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
28
|
"focusable": "^2.3.0",
|
|
29
29
|
"keyname": "^0.1.0",
|
|
30
|
+
"react-aria-components": "^1.13.0",
|
|
30
31
|
"react-id-generator": "^3.0.1",
|
|
31
32
|
"react-syntax-highlighter": "^16.0.1",
|
|
32
33
|
"tslib": "^2.4.0"
|