@deque/cauldron-react 7.5.0-canary.fa33d43b → 7.6.0-canary.0419668f
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/cauldron.css +0 -4
- package/lib/components/TreeView/index.d.ts +17 -2
- package/lib/index.js +29 -6
- package/package.json +4 -4
package/lib/cauldron.css
CHANGED
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/* Dark Theme */
|
|
30
|
-
|
|
31
30
|
.cauldron--theme-dark {
|
|
32
31
|
--expandcollapse-trigger-color: var(--white);
|
|
33
32
|
--expandcollapse-panel-color: var(--accent-light);
|
|
@@ -38,7 +37,6 @@
|
|
|
38
37
|
animation: none !important;
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
a.Button--primary,
|
|
43
41
|
a.Button--secondary,
|
|
44
42
|
a.Button--thin {
|
|
@@ -53,7 +51,6 @@ a.Button--secondary {
|
|
|
53
51
|
a.Button--thin {
|
|
54
52
|
padding: 0 var(--space-small);
|
|
55
53
|
}
|
|
56
|
-
|
|
57
54
|
.Icon {
|
|
58
55
|
display: inline-block;
|
|
59
56
|
vertical-align: middle;
|
|
@@ -66,7 +63,6 @@ a.Button--thin {
|
|
|
66
63
|
}
|
|
67
64
|
|
|
68
65
|
/* Icon--down is the default orientation */
|
|
69
|
-
|
|
70
66
|
.Icon__down {
|
|
71
67
|
}
|
|
72
68
|
|
|
@@ -2,7 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { Cauldron } from '../../types';
|
|
3
3
|
import { TreeViewNode } from './types';
|
|
4
4
|
export type { TreeViewNode } from './types';
|
|
5
|
-
|
|
5
|
+
/** Seeds the initial scroll math. Keep in step with `--tree-view-row-height`,
|
|
6
|
+
* which sizes a virtualized row — see the spacing-parity test. */
|
|
7
|
+
export declare const ESTIMATED_ROW_HEIGHT = 36;
|
|
8
|
+
/** Keep in step with `--space-quarter` / `--space-half`, which `.TreeView` uses
|
|
9
|
+
* for its flex spacing — see the spacing-parity test. */
|
|
10
|
+
export declare const ROW_GAP = 2;
|
|
11
|
+
export declare const LIST_PADDING = 4;
|
|
12
|
+
type TreeViewProps = Cauldron.LabelProps & Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'role' | 'dangerouslySetInnerHTML'> & {
|
|
6
13
|
items: TreeViewNode[];
|
|
7
14
|
onAction?: (key: string) => void;
|
|
8
15
|
selectionMode?: 'none' | 'single' | 'multiple';
|
|
@@ -13,7 +20,15 @@ type TreeViewProps = Cauldron.LabelProps & {
|
|
|
13
20
|
* all of its descendants. */
|
|
14
21
|
cascadeDeselect?: boolean;
|
|
15
22
|
defaultExpandedKeys?: string[];
|
|
16
|
-
|
|
23
|
+
/** Render only the rows in view. Use for long lists, where rendering every
|
|
24
|
+
* row makes selection changes slow enough to look frozen. Needs a height —
|
|
25
|
+
* from `height`, `style`, or CSS — or no rows render. Toggling this at
|
|
26
|
+
* runtime remounts the tree, which resets expansion and scroll position. */
|
|
27
|
+
virtualized?: boolean;
|
|
28
|
+
/** Height of the scroll region, taking precedence over `style.height`. Only
|
|
29
|
+
* applies when `virtualized` is set. A relative unit (`"20rem"`) keeps the
|
|
30
|
+
* visible row count stable at zoom. */
|
|
31
|
+
height?: number | string;
|
|
17
32
|
};
|
|
18
33
|
declare const TreeView: React.ForwardRefExoticComponent<TreeViewProps & React.RefAttributes<HTMLDivElement>>;
|
|
19
34
|
export default TreeView;
|
package/lib/index.js
CHANGED
|
@@ -5681,9 +5681,16 @@ function applyCascade(nodes, previous, next, selectionMode, _a) {
|
|
|
5681
5681
|
return result;
|
|
5682
5682
|
}
|
|
5683
5683
|
|
|
5684
|
+
/** Seeds the initial scroll math. Keep in step with `--tree-view-row-height`,
|
|
5685
|
+
* which sizes a virtualized row — see the spacing-parity test. */
|
|
5686
|
+
var ESTIMATED_ROW_HEIGHT = 36;
|
|
5687
|
+
/** Keep in step with `--space-quarter` / `--space-half`, which `.TreeView` uses
|
|
5688
|
+
* for its flex spacing — see the spacing-parity test. */
|
|
5689
|
+
var ROW_GAP = 2;
|
|
5690
|
+
var LIST_PADDING = 4;
|
|
5684
5691
|
var TreeView = React.forwardRef(function (_a, ref) {
|
|
5685
|
-
var items = _a.items, onAction = _a.onAction, _b = _a.selectionMode, selectionMode = _b === void 0 ? 'none' : _b, _c = _a.cascadeSelect, cascadeSelect = _c === void 0 ? false : _c, _d = _a.cascadeDeselect, cascadeDeselect = _d === void 0 ? false : _d, defaultExpandedKeys = _a.defaultExpandedKeys, className = _a.className, other = tslib.__rest(_a, ["items", "onAction", "selectionMode", "cascadeSelect", "cascadeDeselect", "defaultExpandedKeys", "className"]);
|
|
5686
|
-
var
|
|
5692
|
+
var items = _a.items, onAction = _a.onAction, _b = _a.selectionMode, selectionMode = _b === void 0 ? 'none' : _b, _c = _a.cascadeSelect, cascadeSelect = _c === void 0 ? false : _c, _d = _a.cascadeDeselect, cascadeDeselect = _d === void 0 ? false : _d, defaultExpandedKeys = _a.defaultExpandedKeys, _e = _a.virtualized, virtualized = _e === void 0 ? false : _e, height = _a.height, className = _a.className, style = _a.style, other = tslib.__rest(_a, ["items", "onAction", "selectionMode", "cascadeSelect", "cascadeDeselect", "defaultExpandedKeys", "virtualized", "height", "className", "style"]);
|
|
5693
|
+
var _f = tslib.__read(React.useState(new Set()), 2), selectedKeys = _f[0], setSelectedKeys = _f[1];
|
|
5687
5694
|
var cascade = { cascadeSelect: cascadeSelect, cascadeDeselect: cascadeDeselect };
|
|
5688
5695
|
// Cascade only applies to multiple selection.
|
|
5689
5696
|
var isCascade = selectionMode === 'multiple' && (cascadeSelect || cascadeDeselect);
|
|
@@ -5709,12 +5716,28 @@ var TreeView = React.forwardRef(function (_a, ref) {
|
|
|
5709
5716
|
};
|
|
5710
5717
|
// Disabled nodes are non-selectable; react-aria disables them via disabledKeys.
|
|
5711
5718
|
var disabledKeys = React.useMemo(function () { return collectDisabledKeys(items); }, [items]);
|
|
5712
|
-
//
|
|
5713
|
-
//
|
|
5714
|
-
|
|
5719
|
+
// Always control selection: react-aria's own state is lost if the tree
|
|
5720
|
+
// remounts (which toggling `virtualized` does), taking the user's checkboxes
|
|
5721
|
+
// with it.
|
|
5722
|
+
var selectionProps = selectionMode !== 'none'
|
|
5715
5723
|
? { selectedKeys: selectedKeys, onSelectionChange: handleSelectionChange }
|
|
5716
5724
|
: {};
|
|
5717
|
-
|
|
5725
|
+
// The `height` prop outranks `style.height`, but only when it is actually
|
|
5726
|
+
// set — spreading an undefined `height` would wipe the caller's own.
|
|
5727
|
+
var mergedStyle = virtualized && height !== undefined ? tslib.__assign(tslib.__assign({}, style), { height: height }) : style;
|
|
5728
|
+
var tree = (React__default["default"].createElement(reactAriaComponents.Tree, tslib.__assign({ ref: ref, className: classNames__default["default"]('TreeView', className, {
|
|
5729
|
+
'TreeView--virtualized': virtualized
|
|
5730
|
+
}), selectionMode: selectionMode, defaultExpandedKeys: defaultExpandedKeys }, (disabledKeys.length > 0 ? { disabledKeys: disabledKeys } : {}), (onAction ? { onAction: handleAction } : {}), selectionProps, other, { style: mergedStyle }), items.map(function (item) { return (React__default["default"].createElement(TreeViewItem, tslib.__assign({ key: item.id }, item))); })));
|
|
5731
|
+
// Rows are absolutely positioned here, so the list layout owns their spacing
|
|
5732
|
+
// rather than `.TreeView`'s flex `gap`/`padding`.
|
|
5733
|
+
if (virtualized) {
|
|
5734
|
+
return (React__default["default"].createElement(reactAriaComponents.Virtualizer, { layout: reactAriaComponents.ListLayout, layoutOptions: {
|
|
5735
|
+
estimatedRowHeight: ESTIMATED_ROW_HEIGHT,
|
|
5736
|
+
gap: ROW_GAP,
|
|
5737
|
+
padding: LIST_PADDING
|
|
5738
|
+
} }, tree));
|
|
5739
|
+
}
|
|
5740
|
+
return tree;
|
|
5718
5741
|
});
|
|
5719
5742
|
TreeView.displayName = 'TreeView';
|
|
5720
5743
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deque/cauldron-react",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0-canary.0419668f",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Fully accessible react components library for Deque Cauldron",
|
|
6
6
|
"homepage": "https://cauldron.dequelabs.com/",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"lib/"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@floating-ui/dom": "^1.
|
|
17
|
+
"@floating-ui/dom": "^1.8.0",
|
|
18
18
|
"@floating-ui/react-dom": "^2.1.2",
|
|
19
19
|
"classnames": "^2.2.6",
|
|
20
20
|
"focusable": "^2.3.0",
|
|
21
21
|
"keyname": "^0.1.0",
|
|
22
|
-
"react-aria-components": "^1.
|
|
22
|
+
"react-aria-components": "^1.20.0",
|
|
23
23
|
"react-id-generator": "^3.0.1",
|
|
24
24
|
"react-syntax-highlighter": "^16.1.1",
|
|
25
25
|
"tslib": "^2.4.0"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"jest-axe": "^10.0.0",
|
|
57
57
|
"jest-environment-jsdom": "^29.7.0",
|
|
58
58
|
"nyc": "^15.0.1",
|
|
59
|
-
"postcss": "^8.5.
|
|
59
|
+
"postcss": "^8.5.28",
|
|
60
60
|
"postcss-cli": "^11.0.1",
|
|
61
61
|
"postcss-import": "^16.1.1",
|
|
62
62
|
"postcss-loader": "^8.2.1",
|