@deque/cauldron-react 7.1.0-canary.e2c7e4c9 → 7.1.0-canary.e47d2a2d
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/Icon/types.d.ts +1 -1
- package/lib/components/MenuItem/index.d.ts +1 -6
- package/lib/components/TreeView/helpers.d.ts +33 -0
- package/lib/components/TreeView/index.d.ts +6 -0
- package/lib/components/TreeView/types.d.ts +3 -0
- package/lib/index.js +162 -34
- package/lib/star-outline.js +36 -0
- package/lib/star.js +3 -6
- package/package.json +7 -6
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* GENERATED CODE. DO NOT EDIT DIRECTLY!
|
|
3
3
|
*/
|
|
4
4
|
/** IconType represents each valid icon type. */
|
|
5
|
-
export type IconType = 'add-user' | 'arrow-circle-up' | 'arrow-circle-down' | 'arrow-circle-left' | 'arrow-circle-right' | 'arrow-up' | 'arrow-down' | 'arrow-left' | 'arrow-right' | 'arrows-alt' | 'bolt' | 'broken-image' | 'caution' | 'check-circle' | 'check-shield' | 'check-solid' | 'check' | 'checkbox-checked' | 'checkbox-unchecked' | 'chevron-double-up' | 'chevron-double-down' | 'chevron-double-left' | 'chevron-double-right' | 'chevron-up' | 'chevron-down' | 'chevron-left' | 'chevron-right' | 'clipboard' | 'clock' | 'close' | 'code' | 'copy' | 'download' | 'dropper' | 'exchange' | 'export-solid' | 'external-link' | 'eye' | 'filter' | 'flag' | 'gears' | 'github' | 'grid' | 'hamburger-menu' | 'hashtag' | 'highlight' | 'images' | 'info-circle-alt' | 'info-circle' | 'info-square' | 'kabob' | 'link' | 'linkedin' | 'list' | 'lock' | 'magnifying-glass' | 'menu' | 'minus' | 'new-releases' | 'new' | 'no' | 'pause' | 'pencil' | 'person-running' | 'play' | 'plus' | 'question-circle-alt' | 'question-circle' | 'radio-checked' | 'radio-unchecked' | 'recycle-square' | 'recycle' | 'resend' | 'robot' | 'run-again' | 'save' | 'share-nodes' | 'share' | 'sort-triangle' | 'sort' | 'star' | 'step-back' | 'step-forward' | 'sun' | 'table-sort-ascending' | 'table-sort-descending' | 'tag' | 'target' | 'trash' | 'triangle-up' | 'triangle-down' | 'triangle-left' | 'triangle-right' | 'twitter' | 'upload' | 'filter-solid';
|
|
5
|
+
export type IconType = 'add-user' | 'arrow-circle-up' | 'arrow-circle-down' | 'arrow-circle-left' | 'arrow-circle-right' | 'arrow-up' | 'arrow-down' | 'arrow-left' | 'arrow-right' | 'arrows-alt' | 'bolt' | 'broken-image' | 'caution' | 'check-circle' | 'check-shield' | 'check-solid' | 'check' | 'checkbox-checked' | 'checkbox-unchecked' | 'chevron-double-up' | 'chevron-double-down' | 'chevron-double-left' | 'chevron-double-right' | 'chevron-up' | 'chevron-down' | 'chevron-left' | 'chevron-right' | 'clipboard' | 'clock' | 'close' | 'code' | 'copy' | 'download' | 'dropper' | 'exchange' | 'export-solid' | 'external-link' | 'eye' | 'filter' | 'flag' | 'gears' | 'github' | 'grid' | 'hamburger-menu' | 'hashtag' | 'highlight' | 'images' | 'info-circle-alt' | 'info-circle' | 'info-square' | 'kabob' | 'link' | 'linkedin' | 'list' | 'lock' | 'magnifying-glass' | 'menu' | 'minus' | 'new-releases' | 'new' | 'no' | 'pause' | 'pencil' | 'person-running' | 'play' | 'plus' | 'question-circle-alt' | 'question-circle' | 'radio-checked' | 'radio-unchecked' | 'recycle-square' | 'recycle' | 'resend' | 'robot' | 'run-again' | 'save' | 'share-nodes' | 'share' | 'sort-triangle' | 'sort' | 'star-outline' | 'star' | 'step-back' | 'step-forward' | 'sun' | 'table-sort-ascending' | 'table-sort-descending' | 'tag' | 'target' | 'trash' | 'triangle-up' | 'triangle-down' | 'triangle-left' | 'triangle-right' | 'twitter' | 'upload' | 'filter-solid';
|
|
6
6
|
/** iconTypes holds each valid icon type. */
|
|
7
7
|
export declare const iconTypes: string[];
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
interface MenuItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
menuItemRef
|
|
5
|
-
onClick: (e: React.MouseEvent<HTMLLIElement>) => void;
|
|
6
|
-
onKeyDown: (e: React.KeyboardEvent<HTMLLIElement>) => void;
|
|
4
|
+
menuItemRef?: React.Ref<HTMLLIElement>;
|
|
7
5
|
autoClickLink?: boolean;
|
|
8
6
|
}
|
|
9
7
|
export default class MenuItem extends Component<MenuItemProps> {
|
|
10
8
|
static displayName: string;
|
|
11
9
|
static defaultProps: {
|
|
12
|
-
menuItemRef: () => void;
|
|
13
|
-
onClick: () => void;
|
|
14
|
-
onKeyDown: () => void;
|
|
15
10
|
autoClickLink: boolean;
|
|
16
11
|
};
|
|
17
12
|
private item;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Key, type Selection } from 'react-aria-components';
|
|
2
|
+
import { TreeViewNode } from './types';
|
|
3
|
+
/** Every node id in the tree, flattened depth-first. */
|
|
4
|
+
export declare function collectAllKeys(nodes: TreeViewNode[]): Key[];
|
|
5
|
+
/** Normalize react-aria's `Selection` ("all" | Set) into a concrete Set of keys. */
|
|
6
|
+
export declare function toKeySet(selection: Selection, nodes: TreeViewNode[]): Set<Key>;
|
|
7
|
+
/** Locate a node anywhere in the tree by its id. */
|
|
8
|
+
export declare function findNode(nodes: TreeViewNode[], key: Key): TreeViewNode | undefined;
|
|
9
|
+
/** All descendant ids of a node (not including the node itself). */
|
|
10
|
+
export declare function collectDescendantKeys(node: TreeViewNode): Key[];
|
|
11
|
+
/** Ids of all disabled nodes (rendered disabled / non-selectable). */
|
|
12
|
+
export declare function collectDisabledKeys(nodes: TreeViewNode[]): Key[];
|
|
13
|
+
interface CascadeOptions {
|
|
14
|
+
cascadeSelect: boolean;
|
|
15
|
+
cascadeDeselect: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Toggle a single node, applying cascade per the options (multiple mode only):
|
|
19
|
+
* - selecting + `cascadeSelect`: also selects all (non-disabled) descendants.
|
|
20
|
+
* - deselecting + `cascadeDeselect`: also deselects all descendants.
|
|
21
|
+
*
|
|
22
|
+
* In `single` mode only the clicked node is selected (clicking it again clears
|
|
23
|
+
* it); cascade does not apply.
|
|
24
|
+
*/
|
|
25
|
+
export declare function toggleSelection(nodes: TreeViewNode[], previous: Set<Key>, key: Key, selectionMode: 'single' | 'multiple', { cascadeSelect, cascadeDeselect }: CascadeOptions): Set<Key>;
|
|
26
|
+
/**
|
|
27
|
+
* Apply react-aria's proposed selection while enforcing cascade. Each key
|
|
28
|
+
* react-aria added cascades to its descendants when `cascadeSelect` is set; each
|
|
29
|
+
* key it removed cascades when `cascadeDeselect` is set. In non-multiple modes
|
|
30
|
+
* (or with both toggles off) the proposed selection is used as-is.
|
|
31
|
+
*/
|
|
32
|
+
export declare function applyCascade(nodes: TreeViewNode[], previous: Set<Key>, next: Set<Key>, selectionMode: 'none' | 'single' | 'multiple', { cascadeSelect, cascadeDeselect }: CascadeOptions): Set<Key>;
|
|
33
|
+
export {};
|
|
@@ -6,6 +6,12 @@ type TreeViewProps = Cauldron.LabelProps & {
|
|
|
6
6
|
items: TreeViewNode[];
|
|
7
7
|
onAction?: (key: string) => void;
|
|
8
8
|
selectionMode?: 'none' | 'single' | 'multiple';
|
|
9
|
+
/** When true (multiple selection only), selecting a parent also selects all
|
|
10
|
+
* of its (non-disabled) descendants. */
|
|
11
|
+
cascadeSelect?: boolean;
|
|
12
|
+
/** When true (multiple selection only), deselecting a parent also deselects
|
|
13
|
+
* all of its descendants. */
|
|
14
|
+
cascadeDeselect?: boolean;
|
|
9
15
|
defaultExpandedKeys?: string[];
|
|
10
16
|
className?: string;
|
|
11
17
|
};
|
package/lib/index.js
CHANGED
|
@@ -185,6 +185,7 @@ var iconTypes = [
|
|
|
185
185
|
'share',
|
|
186
186
|
'sort-triangle',
|
|
187
187
|
'sort',
|
|
188
|
+
'star-outline',
|
|
188
189
|
'star',
|
|
189
190
|
'step-back',
|
|
190
191
|
'step-forward',
|
|
@@ -273,6 +274,7 @@ function __variableDynamicImportRuntime0__(path) {
|
|
|
273
274
|
case './icons/share.svg': return Promise.resolve().then(function () { return require('./share.js'); });
|
|
274
275
|
case './icons/sort-triangle.svg': return Promise.resolve().then(function () { return require('./sort-triangle.js'); });
|
|
275
276
|
case './icons/sort.svg': return Promise.resolve().then(function () { return require('./sort.js'); });
|
|
277
|
+
case './icons/star-outline.svg': return Promise.resolve().then(function () { return require('./star-outline.js'); });
|
|
276
278
|
case './icons/star.svg': return Promise.resolve().then(function () { return require('./star.js'); });
|
|
277
279
|
case './icons/step-back.svg': return Promise.resolve().then(function () { return require('./step-back.js'); });
|
|
278
280
|
case './icons/step-forward.svg': return Promise.resolve().then(function () { return require('./step-forward.js'); });
|
|
@@ -623,16 +625,16 @@ var MenuItem = /** @class */ (function (_super) {
|
|
|
623
625
|
if (autoClickLink) {
|
|
624
626
|
clickLink(e.target, this.item);
|
|
625
627
|
}
|
|
626
|
-
onClick(e);
|
|
628
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
627
629
|
};
|
|
628
630
|
MenuItem.prototype.onKeyDown = function (e) {
|
|
629
|
-
var _a;
|
|
631
|
+
var _a, _b, _c;
|
|
630
632
|
var key = keyname__default["default"](e.which);
|
|
631
633
|
if (key === 'enter' || key === 'space') {
|
|
632
634
|
e.preventDefault();
|
|
633
635
|
(_a = this.item) === null || _a === void 0 ? void 0 : _a.click();
|
|
634
636
|
}
|
|
635
|
-
this.props.onKeyDown(e);
|
|
637
|
+
(_c = (_b = this.props).onKeyDown) === null || _c === void 0 ? void 0 : _c.call(_b, e);
|
|
636
638
|
};
|
|
637
639
|
MenuItem.prototype.render = function () {
|
|
638
640
|
var _this = this;
|
|
@@ -645,12 +647,6 @@ var MenuItem = /** @class */ (function (_super) {
|
|
|
645
647
|
};
|
|
646
648
|
MenuItem.displayName = 'MenuItem';
|
|
647
649
|
MenuItem.defaultProps = {
|
|
648
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
649
|
-
menuItemRef: function () { },
|
|
650
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
651
|
-
onClick: function () { },
|
|
652
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
653
|
-
onKeyDown: function () { },
|
|
654
650
|
autoClickLink: true
|
|
655
651
|
};
|
|
656
652
|
return MenuItem;
|
|
@@ -2218,7 +2214,7 @@ var typeMap = {
|
|
|
2218
2214
|
};
|
|
2219
2215
|
var tabIndexHandler = function (reset, toast) {
|
|
2220
2216
|
if (reset) {
|
|
2221
|
-
// restore tab
|
|
2217
|
+
// restore tab indices that we clobbered
|
|
2222
2218
|
return queryAll('[data-cached-tabindex]').forEach(function (el) {
|
|
2223
2219
|
el.tabIndex = Number(el.getAttribute('data-cached-tabindex'));
|
|
2224
2220
|
});
|
|
@@ -3634,7 +3630,7 @@ var TwoColumnPanel = React.forwardRef(function (_a, ref) {
|
|
|
3634
3630
|
(_a = columnLeftRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('transitionend', handleTransitionEnd);
|
|
3635
3631
|
};
|
|
3636
3632
|
}, [columnLeftRef.current, isCollapsed]);
|
|
3637
|
-
// When the
|
|
3633
|
+
// When the collapsible panel starts to overlay content, it needs to become a focus trap and collapsed by default
|
|
3638
3634
|
React.useLayoutEffect(function () {
|
|
3639
3635
|
var mediaQueryList = matchMedia(collapsedMediaQuery);
|
|
3640
3636
|
var handleMatch = function (matches) {
|
|
@@ -5438,49 +5434,181 @@ var TreeViewItem = function (_a) {
|
|
|
5438
5434
|
var checkboxId = React.useMemo(function () { return nextId__default["default"]('tree-view-item-'); }, []);
|
|
5439
5435
|
return (React__default["default"].createElement(reactAriaComponents.TreeItem, { id: id, textValue: textValue, className: "TreeView__item" },
|
|
5440
5436
|
React__default["default"].createElement(reactAriaComponents.TreeItemContent, null, function (_a) {
|
|
5441
|
-
var selectionMode = _a.selectionMode, isSelected = _a.isSelected;
|
|
5437
|
+
var selectionMode = _a.selectionMode, isSelected = _a.isSelected, isDisabled = _a.isDisabled;
|
|
5442
5438
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5443
5439
|
React__default["default"].createElement(reactAriaComponents.Button, { slot: "chevron", className: "TreeView__chevron" },
|
|
5444
5440
|
React__default["default"].createElement(Icon, { type: "chevron-right" })),
|
|
5445
|
-
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))));
|
|
5441
|
+
selectionMode !== 'none' ? (React__default["default"].createElement(Checkbox, { id: checkboxId, label: textValue, checked: isSelected, disabled: isDisabled, controlled: true, tabIndex: -1 })) : (React__default["default"].createElement(React__default["default"].Fragment, null, textValue))));
|
|
5446
5442
|
}),
|
|
5447
5443
|
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))); })))));
|
|
5448
5444
|
};
|
|
5449
5445
|
TreeViewItem.displayName = 'TreeViewItem';
|
|
5450
5446
|
|
|
5447
|
+
/** Every node id in the tree, flattened depth-first. */
|
|
5451
5448
|
function collectAllKeys(nodes) {
|
|
5452
5449
|
return nodes.flatMap(function (node) { return tslib.__spreadArray([
|
|
5453
5450
|
node.id
|
|
5454
5451
|
], tslib.__read((node.children ? collectAllKeys(node.children) : [])), false); });
|
|
5455
5452
|
}
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5453
|
+
/** Normalize react-aria's `Selection` ("all" | Set) into a concrete Set of keys. */
|
|
5454
|
+
function toKeySet(selection, nodes) {
|
|
5455
|
+
if (selection !== 'all') {
|
|
5456
|
+
return new Set(selection);
|
|
5457
|
+
}
|
|
5458
|
+
// "Select all" only includes selectable (non-disabled) nodes.
|
|
5459
|
+
var disabled = new Set(collectDisabledKeys(nodes));
|
|
5460
|
+
return new Set(collectAllKeys(nodes).filter(function (key) { return !disabled.has(key); }));
|
|
5461
|
+
}
|
|
5462
|
+
/** Locate a node anywhere in the tree by its id. */
|
|
5463
|
+
function findNode(nodes, key) {
|
|
5464
|
+
var e_1, _a;
|
|
5465
|
+
try {
|
|
5466
|
+
for (var nodes_1 = tslib.__values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
|
5467
|
+
var node = nodes_1_1.value;
|
|
5468
|
+
if (node.id === key) {
|
|
5469
|
+
return node;
|
|
5465
5470
|
}
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5471
|
+
if (node.children) {
|
|
5472
|
+
var found = findNode(node.children, key);
|
|
5473
|
+
if (found) {
|
|
5474
|
+
return found;
|
|
5469
5475
|
}
|
|
5470
|
-
next.add(key);
|
|
5471
5476
|
}
|
|
5472
|
-
|
|
5477
|
+
}
|
|
5478
|
+
}
|
|
5479
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5480
|
+
finally {
|
|
5481
|
+
try {
|
|
5482
|
+
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
|
5483
|
+
}
|
|
5484
|
+
finally { if (e_1) throw e_1.error; }
|
|
5485
|
+
}
|
|
5486
|
+
return undefined;
|
|
5487
|
+
}
|
|
5488
|
+
/** All descendant ids of a node (not including the node itself). */
|
|
5489
|
+
function collectDescendantKeys(node) {
|
|
5490
|
+
if (!node.children) {
|
|
5491
|
+
return [];
|
|
5492
|
+
}
|
|
5493
|
+
return node.children.flatMap(function (child) { return tslib.__spreadArray([
|
|
5494
|
+
child.id
|
|
5495
|
+
], tslib.__read(collectDescendantKeys(child)), false); });
|
|
5496
|
+
}
|
|
5497
|
+
/** Ids of all disabled nodes (rendered disabled / non-selectable). */
|
|
5498
|
+
function collectDisabledKeys(nodes) {
|
|
5499
|
+
return nodes.flatMap(function (node) { return tslib.__spreadArray(tslib.__spreadArray([], tslib.__read((node.disabled ? [node.id] : [])), false), tslib.__read((node.children ? collectDisabledKeys(node.children) : [])), false); });
|
|
5500
|
+
}
|
|
5501
|
+
/**
|
|
5502
|
+
* Toggle a single node, applying cascade per the options (multiple mode only):
|
|
5503
|
+
* - selecting + `cascadeSelect`: also selects all (non-disabled) descendants.
|
|
5504
|
+
* - deselecting + `cascadeDeselect`: also deselects all descendants.
|
|
5505
|
+
*
|
|
5506
|
+
* In `single` mode only the clicked node is selected (clicking it again clears
|
|
5507
|
+
* it); cascade does not apply.
|
|
5508
|
+
*/
|
|
5509
|
+
function toggleSelection(nodes, previous, key, selectionMode, _a) {
|
|
5510
|
+
var cascadeSelect = _a.cascadeSelect, cascadeDeselect = _a.cascadeDeselect;
|
|
5511
|
+
if (selectionMode === 'single') {
|
|
5512
|
+
var result_1 = new Set();
|
|
5513
|
+
if (!previous.has(key)) {
|
|
5514
|
+
result_1.add(key);
|
|
5515
|
+
}
|
|
5516
|
+
return result_1;
|
|
5517
|
+
}
|
|
5518
|
+
var result = new Set(previous);
|
|
5519
|
+
var node = findNode(nodes, key);
|
|
5520
|
+
var descendants = node ? collectDescendantKeys(node) : [];
|
|
5521
|
+
var disabled = new Set(collectDisabledKeys(nodes));
|
|
5522
|
+
if (!previous.has(key)) {
|
|
5523
|
+
result.add(key);
|
|
5524
|
+
if (cascadeSelect) {
|
|
5525
|
+
descendants.forEach(function (k) {
|
|
5526
|
+
if (!disabled.has(k)) {
|
|
5527
|
+
result.add(k);
|
|
5528
|
+
}
|
|
5529
|
+
});
|
|
5530
|
+
}
|
|
5531
|
+
}
|
|
5532
|
+
else {
|
|
5533
|
+
result.delete(key);
|
|
5534
|
+
if (cascadeDeselect) {
|
|
5535
|
+
descendants.forEach(function (k) { return result.delete(k); });
|
|
5536
|
+
}
|
|
5537
|
+
}
|
|
5538
|
+
return result;
|
|
5539
|
+
}
|
|
5540
|
+
/**
|
|
5541
|
+
* Apply react-aria's proposed selection while enforcing cascade. Each key
|
|
5542
|
+
* react-aria added cascades to its descendants when `cascadeSelect` is set; each
|
|
5543
|
+
* key it removed cascades when `cascadeDeselect` is set. In non-multiple modes
|
|
5544
|
+
* (or with both toggles off) the proposed selection is used as-is.
|
|
5545
|
+
*/
|
|
5546
|
+
function applyCascade(nodes, previous, next, selectionMode, _a) {
|
|
5547
|
+
var cascadeSelect = _a.cascadeSelect, cascadeDeselect = _a.cascadeDeselect;
|
|
5548
|
+
if (selectionMode !== 'multiple' || (!cascadeSelect && !cascadeDeselect)) {
|
|
5549
|
+
return next;
|
|
5550
|
+
}
|
|
5551
|
+
var result = new Set(previous);
|
|
5552
|
+
var added = tslib.__spreadArray([], tslib.__read(next), false).filter(function (key) { return !previous.has(key); });
|
|
5553
|
+
var removed = tslib.__spreadArray([], tslib.__read(previous), false).filter(function (key) { return !next.has(key); });
|
|
5554
|
+
var disabled = new Set(collectDisabledKeys(nodes));
|
|
5555
|
+
added.forEach(function (key) {
|
|
5556
|
+
result.add(key);
|
|
5557
|
+
if (cascadeSelect) {
|
|
5558
|
+
var node = findNode(nodes, key);
|
|
5559
|
+
(node ? collectDescendantKeys(node) : []).forEach(function (k) {
|
|
5560
|
+
if (!disabled.has(k)) {
|
|
5561
|
+
result.add(k);
|
|
5562
|
+
}
|
|
5563
|
+
});
|
|
5564
|
+
}
|
|
5565
|
+
});
|
|
5566
|
+
removed.forEach(function (key) {
|
|
5567
|
+
result.delete(key);
|
|
5568
|
+
if (cascadeDeselect) {
|
|
5569
|
+
var node = findNode(nodes, key);
|
|
5570
|
+
(node ? collectDescendantKeys(node) : []).forEach(function (k) {
|
|
5571
|
+
return result.delete(k);
|
|
5572
|
+
});
|
|
5573
|
+
}
|
|
5574
|
+
});
|
|
5575
|
+
return result;
|
|
5576
|
+
}
|
|
5577
|
+
|
|
5578
|
+
var TreeView = React.forwardRef(function (_a, ref) {
|
|
5579
|
+
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"]);
|
|
5580
|
+
var _e = tslib.__read(React.useState(new Set()), 2), selectedKeys = _e[0], setSelectedKeys = _e[1];
|
|
5581
|
+
var cascade = { cascadeSelect: cascadeSelect, cascadeDeselect: cascadeDeselect };
|
|
5582
|
+
// Cascade only applies to multiple selection.
|
|
5583
|
+
var isCascade = selectionMode === 'multiple' && (cascadeSelect || cascadeDeselect);
|
|
5584
|
+
// Selection driven by react-aria (row/checkbox press, keyboard). When
|
|
5585
|
+
// cascading, reconcile the proposed change; otherwise store react-aria's
|
|
5586
|
+
// selection as-is so the `'all'` sentinel (Ctrl+A) is preserved.
|
|
5587
|
+
var handleSelectionChange = function (selection) {
|
|
5588
|
+
setSelectedKeys(function (prev) {
|
|
5589
|
+
return isCascade
|
|
5590
|
+
? applyCascade(items, toKeySet(prev, items), toKeySet(selection, items), selectionMode, cascade)
|
|
5591
|
+
: selection;
|
|
5473
5592
|
});
|
|
5474
|
-
onAction === null || onAction === void 0 ? void 0 : onAction(key);
|
|
5475
5593
|
};
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5594
|
+
// When `onAction` is set, react-aria treats a row press as an action rather
|
|
5595
|
+
// than a selection, so we toggle selection here ourselves.
|
|
5596
|
+
var handleAction = function (key) {
|
|
5597
|
+
if (selectionMode !== 'none') {
|
|
5598
|
+
setSelectedKeys(function (prev) {
|
|
5599
|
+
return toggleSelection(items, toKeySet(prev, items), key, selectionMode, cascade);
|
|
5600
|
+
});
|
|
5481
5601
|
}
|
|
5602
|
+
onAction === null || onAction === void 0 ? void 0 : onAction(key);
|
|
5603
|
+
};
|
|
5604
|
+
// Disabled nodes are non-selectable; react-aria disables them via disabledKeys.
|
|
5605
|
+
var disabledKeys = React.useMemo(function () { return collectDisabledKeys(items); }, [items]);
|
|
5606
|
+
// Cascade requires controlling selection. Without it, preserve the original
|
|
5607
|
+
// behavior: selection is only controlled when an `onAction` handler is set.
|
|
5608
|
+
var selectionProps = selectionMode !== 'none' && (isCascade || onAction)
|
|
5609
|
+
? { selectedKeys: selectedKeys, onSelectionChange: handleSelectionChange }
|
|
5482
5610
|
: {};
|
|
5483
|
-
return (React__default["default"].createElement(reactAriaComponents.Tree, tslib.__assign({ ref: ref, className: classNames__default["default"]('TreeView', className), selectionMode: selectionMode, defaultExpandedKeys: defaultExpandedKeys },
|
|
5611
|
+
return (React__default["default"].createElement(reactAriaComponents.Tree, tslib.__assign({ ref: ref, className: classNames__default["default"]('TreeView', className), selectionMode: selectionMode, defaultExpandedKeys: defaultExpandedKeys }, (disabledKeys.length > 0 ? { disabledKeys: disabledKeys } : {}), (onAction ? { onAction: handleAction } : {}), selectionProps, other), items.map(function (item) { return (React__default["default"].createElement(TreeViewItem, tslib.__assign({ key: item.id }, item))); })));
|
|
5484
5612
|
});
|
|
5485
5613
|
TreeView.displayName = 'TreeView';
|
|
5486
5614
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopNamespace(e) {
|
|
6
|
+
if (e && e.__esModule) return e;
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n["default"] = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
24
|
+
|
|
25
|
+
var _path;
|
|
26
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
27
|
+
const SvgStarOutline = props => /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
28
|
+
fill: "currentColor",
|
|
29
|
+
viewBox: "0 -960 960 960",
|
|
30
|
+
height: 24,
|
|
31
|
+
width: 24
|
|
32
|
+
}, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
33
|
+
d: "m354-287 126-76 126 77-33-144 111-96-146-13-58-136-58 135-146 13 111 97zM233-120l65-281L80-590l288-25 112-265 112 265 288 25-218 189 65 281-247-149zm247-350"
|
|
34
|
+
})));
|
|
35
|
+
|
|
36
|
+
exports["default"] = SvgStarOutline;
|
package/lib/star.js
CHANGED
|
@@ -25,15 +25,12 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
25
25
|
var _path;
|
|
26
26
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
27
27
|
const SvgStar = props => /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
viewBox: "0 0 24 24",
|
|
28
|
+
fill: "currentColor",
|
|
29
|
+
viewBox: "0 -960 960 960",
|
|
31
30
|
height: 24,
|
|
32
31
|
width: 24
|
|
33
32
|
}, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
34
|
-
d: "
|
|
35
|
-
vectorEffect: "non-scaling-stroke",
|
|
36
|
-
fill: "currentColor"
|
|
33
|
+
d: "m233-120 65-281L80-590l288-25 112-265 112 265 288 25-218 189 65 281-247-149z"
|
|
37
34
|
})));
|
|
38
35
|
|
|
39
36
|
exports["default"] = SvgStar;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deque/cauldron-react",
|
|
3
|
-
"version": "7.1.0-canary.
|
|
3
|
+
"version": "7.1.0-canary.e47d2a2d",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Fully accessible react components library for Deque Cauldron",
|
|
6
6
|
"homepage": "https://cauldron.dequelabs.com/",
|
|
@@ -47,17 +47,18 @@
|
|
|
47
47
|
"@types/react-dom": "^19.0.0",
|
|
48
48
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
49
49
|
"@types/sinon": "^10",
|
|
50
|
-
"autoprefixer": "^
|
|
50
|
+
"autoprefixer": "^10.5.0",
|
|
51
51
|
"babel-plugin-module-resolver": "^5.0.3",
|
|
52
52
|
"babel-plugin-transform-export-extensions": "^6.22.0",
|
|
53
53
|
"concurrently": "^5.3.0",
|
|
54
54
|
"jest": "^29.7.0",
|
|
55
|
-
"jest-axe": "^
|
|
55
|
+
"jest-axe": "^10.0.0",
|
|
56
56
|
"jest-environment-jsdom": "^29.7.0",
|
|
57
57
|
"nyc": "^15.0.1",
|
|
58
|
-
"postcss
|
|
59
|
-
"postcss-
|
|
60
|
-
"postcss-
|
|
58
|
+
"postcss": "^8.5.15",
|
|
59
|
+
"postcss-cli": "^11.0.1",
|
|
60
|
+
"postcss-import": "^16.1.1",
|
|
61
|
+
"postcss-loader": "^8.2.1",
|
|
61
62
|
"prop-types": "^15.8.1",
|
|
62
63
|
"react": "^19",
|
|
63
64
|
"react-dom": "^19",
|