@box/blueprint-web 18.9.3 → 18.10.1
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/dist/lib-esm/components.css +288 -269
- package/dist/lib-esm/index.css +288 -269
- package/dist/lib-esm/list-item/cell/action-cell.d.ts +9 -0
- package/dist/lib-esm/list-item/cell/action-cell.js +4 -1
- package/dist/lib-esm/toolbar/toolbar.module.js +1 -1
- package/dist/lib-esm/util-components/base-grid-list-item/base-grid-list-item-actions.js +10 -2
- package/dist/lib-esm/util-components/base-grid-list-item/base-grid-list-item.js +7 -4
- package/dist/lib-esm/util-components/base-grid-list-item/base-grid-list-item.module.js +1 -1
- package/dist/lib-esm/util-components/base-grid-list-item/base-grid-list.js +5 -5
- package/dist/lib-esm/util-components/base-grid-list-item/grid-list-interaction-utils.d.ts +9 -4
- package/dist/lib-esm/util-components/base-grid-list-item/grid-list-interaction-utils.js +10 -5
- package/dist/lib-esm/util-components/base-grid-list-item/types.d.ts +17 -3
- package/package.json +3 -3
|
@@ -3,6 +3,15 @@ import { type CellProps } from './cell';
|
|
|
3
3
|
export interface ActionCellProps extends Omit<CellProps, 'variant' | 'children'> {
|
|
4
4
|
loading?: boolean;
|
|
5
5
|
isCheckboxDisabled?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Hides the multi-select checkbox. The row can still be selected (e.g. with Space or select all)
|
|
8
|
+
* unless its key is in the table's `disabledKeys`.
|
|
9
|
+
*/
|
|
10
|
+
isCheckboxHidden?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* `data-target-id` for the multi-select checkbox, applied to its clickable label (e.g. for analytics).
|
|
13
|
+
*/
|
|
14
|
+
checkboxDataTargetId?: string;
|
|
6
15
|
children: (onOpenChange: (isOpen: boolean) => void) => ReactNode;
|
|
7
16
|
}
|
|
8
17
|
/**
|
|
@@ -17,7 +17,9 @@ const ActionCell = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
17
17
|
const {
|
|
18
18
|
children,
|
|
19
19
|
loading,
|
|
20
|
+
checkboxDataTargetId,
|
|
20
21
|
isCheckboxDisabled,
|
|
22
|
+
isCheckboxHidden,
|
|
21
23
|
...rest
|
|
22
24
|
} = props;
|
|
23
25
|
const {
|
|
@@ -35,7 +37,7 @@ const ActionCell = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
35
37
|
divRef.current.setAttribute('data-state', isOpen ? 'open' : 'closed');
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
|
-
const shouldShowCheckbox = selectionBehavior === 'toggle' && selectionMode === 'multiple';
|
|
40
|
+
const shouldShowCheckbox = selectionBehavior === 'toggle' && selectionMode === 'multiple' && !isCheckboxHidden;
|
|
39
41
|
const alwaysShowSelection = selectionVisibility === 'always' && shouldShowCheckbox;
|
|
40
42
|
return jsx(Cell, {
|
|
41
43
|
className: styles.actions,
|
|
@@ -51,6 +53,7 @@ const ActionCell = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
51
53
|
className: styles.actionChildren,
|
|
52
54
|
children: children(onOpenChange)
|
|
53
55
|
}), shouldShowCheckbox && jsx(ListCheckbox, {
|
|
56
|
+
"data-target-id": checkboxDataTargetId,
|
|
54
57
|
isDisabled: isCheckboxDisabled
|
|
55
58
|
})]
|
|
56
59
|
}) : null
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"dropdownIndicator":"bp_toolbar_module_dropdownIndicator--
|
|
2
|
+
var styles = {"dropdownIndicator":"bp_toolbar_module_dropdownIndicator--73c52","invertCaret":"bp_toolbar_module_invertCaret--73c52","toolbarRoot":"bp_toolbar_module_toolbarRoot--73c52","ScrollableToolbarWithReducedPadding":"bp_toolbar_module_ScrollableToolbarWithReducedPadding--73c52","toolbarItem":"bp_toolbar_module_toolbarItem--73c52","toolbarButton":"bp_toolbar_module_toolbarButton--73c52","toolbarTextToggleItem":"bp_toolbar_module_toolbarTextToggleItem--73c52","toolbarLink":"bp_toolbar_module_toolbarLink--73c52","scrollButtonWrapper":"bp_toolbar_module_scrollButtonWrapper--73c52","hidden":"bp_toolbar_module_hidden--73c52","scrollableChildrenWrapper":"bp_toolbar_module_scrollableChildrenWrapper--73c52","separator":"bp_toolbar_module_separator--73c52","toggleGroup":"bp_toolbar_module_toggleGroup--73c52","toolbarToggle":"bp_toolbar_module_toolbarToggle--73c52","triggerButtonSelectedWithColor":"bp_toolbar_module_triggerButtonSelectedWithColor--73c52","toolbarIcon":"bp_toolbar_module_toolbarIcon--73c52","toolbarLinkText":"bp_toolbar_module_toolbarLinkText--73c52","toolbarInputContainer":"bp_toolbar_module_toolbarInputContainer--73c52","toolbarInput":"bp_toolbar_module_toolbarInput--73c52","toolbarInputErrorIcon":"bp_toolbar_module_toolbarInputErrorIcon--73c52","toolbarInputError":"bp_toolbar_module_toolbarInputError--73c52","toolbarInputErrorIconHidden":"bp_toolbar_module_toolbarInputErrorIconHidden--73c52"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -18,7 +18,8 @@ const hasChildren = children => children !== null && children !== undefined && c
|
|
|
18
18
|
const BaseListActions = ({
|
|
19
19
|
children,
|
|
20
20
|
selectionEnabled,
|
|
21
|
-
isSelectionCheckboxDisabled
|
|
21
|
+
isSelectionCheckboxDisabled,
|
|
22
|
+
selectionCheckboxDataTargetId
|
|
22
23
|
}) => {
|
|
23
24
|
return jsxs(Fragment, {
|
|
24
25
|
children: [jsx("div", {
|
|
@@ -30,6 +31,7 @@ const BaseListActions = ({
|
|
|
30
31
|
children: children
|
|
31
32
|
}) : null, selectionEnabled && jsx(ListCheckbox, {
|
|
32
33
|
className: styles.selection,
|
|
34
|
+
"data-target-id": selectionCheckboxDataTargetId,
|
|
33
35
|
isDisabled: isSelectionCheckboxDisabled
|
|
34
36
|
})]
|
|
35
37
|
})]
|
|
@@ -39,6 +41,7 @@ const GridListActions = ({
|
|
|
39
41
|
children,
|
|
40
42
|
selectionEnabled,
|
|
41
43
|
isSelectionCheckboxDisabled,
|
|
44
|
+
selectionCheckboxDataTargetId,
|
|
42
45
|
centerText,
|
|
43
46
|
setHasActions
|
|
44
47
|
}) => {
|
|
@@ -49,6 +52,7 @@ const GridListActions = ({
|
|
|
49
52
|
return jsxs(Fragment, {
|
|
50
53
|
children: [selectionEnabled && jsx(ListCheckbox, {
|
|
51
54
|
className: styles.selection,
|
|
55
|
+
"data-target-id": selectionCheckboxDataTargetId,
|
|
52
56
|
isDisabled: isSelectionCheckboxDisabled
|
|
53
57
|
}), jsx("div", {
|
|
54
58
|
className: clsx(styles.inner, {
|
|
@@ -112,6 +116,8 @@ const BaseGridListActions = /*#__PURE__*/forwardRef(function BaseGridListActions
|
|
|
112
116
|
children,
|
|
113
117
|
className,
|
|
114
118
|
isSelectionCheckboxDisabled,
|
|
119
|
+
isSelectionCheckboxHidden,
|
|
120
|
+
selectionCheckboxDataTargetId,
|
|
115
121
|
...rest
|
|
116
122
|
} = props;
|
|
117
123
|
const {
|
|
@@ -128,7 +134,7 @@ const BaseGridListActions = /*#__PURE__*/forwardRef(function BaseGridListActions
|
|
|
128
134
|
}
|
|
129
135
|
const isList = layoutStyle === 'list' || layoutStyle === 'list-v2' || layoutStyle === 'small-list';
|
|
130
136
|
const isGridV2 = layoutStyle === 'grid-v2';
|
|
131
|
-
const isSelectionEnabled = selectionMode === 'multiple';
|
|
137
|
+
const isSelectionEnabled = selectionMode === 'multiple' && !isSelectionCheckboxHidden;
|
|
132
138
|
const isRenderPropUsed = typeof children === 'function';
|
|
133
139
|
const alwaysShowSelection = selectionVisibility === 'always' && isSelectionEnabled;
|
|
134
140
|
return jsxs(Fragment, {
|
|
@@ -138,11 +144,13 @@ const BaseGridListActions = /*#__PURE__*/forwardRef(function BaseGridListActions
|
|
|
138
144
|
className: clsx(styles.actions, alwaysShowSelection && styles.alwaysShowSelection, className),
|
|
139
145
|
children: isList ? jsx(BaseListActions, {
|
|
140
146
|
isSelectionCheckboxDisabled: isSelectionCheckboxDisabled,
|
|
147
|
+
selectionCheckboxDataTargetId: selectionCheckboxDataTargetId,
|
|
141
148
|
selectionEnabled: isSelectionEnabled,
|
|
142
149
|
children: isRenderPropUsed ? children(setIsItemInteracted) : children
|
|
143
150
|
}) : jsx(GridListActions, {
|
|
144
151
|
centerText: isGridV2 && centerText,
|
|
145
152
|
isSelectionCheckboxDisabled: isSelectionCheckboxDisabled,
|
|
153
|
+
selectionCheckboxDataTargetId: selectionCheckboxDataTargetId,
|
|
146
154
|
selectionEnabled: isSelectionEnabled,
|
|
147
155
|
setHasActions: setHasActions,
|
|
148
156
|
children: isRenderPropUsed ? children(setIsItemInteracted) : children
|
|
@@ -6,7 +6,7 @@ import { noop } from '../../utils/noop.js';
|
|
|
6
6
|
import { useDebounce } from '../../utils/use-debounce.js';
|
|
7
7
|
import { useBaseGridListContext } from './base-grid-list.js';
|
|
8
8
|
import styles from './base-grid-list-item.module.js';
|
|
9
|
-
import {
|
|
9
|
+
import { isV2SingleSelect, GRID_LIST_ITEM_NUMERIC_KEY_ATTR, isGridListContentTarget, isGridListItemTargetDisabled, getGridListItemKeyFromTarget } from './grid-list-interaction-utils.js';
|
|
10
10
|
import { StaticGridListItem } from './static-grid-list-item.js';
|
|
11
11
|
|
|
12
12
|
const BaseGridListItemContext = /*#__PURE__*/createContext({
|
|
@@ -25,6 +25,7 @@ const BaseGridListItem = /*#__PURE__*/forwardRef(function BaseGridListItem(props
|
|
|
25
25
|
const {
|
|
26
26
|
children,
|
|
27
27
|
className,
|
|
28
|
+
isActionable = true,
|
|
28
29
|
isDroppableTarget = true,
|
|
29
30
|
isHighlighted = false,
|
|
30
31
|
loading = false,
|
|
@@ -73,7 +74,7 @@ const BaseGridListItem = /*#__PURE__*/forwardRef(function BaseGridListItem(props
|
|
|
73
74
|
const isGridV2 = layoutStyle === 'grid-v2';
|
|
74
75
|
const isListV2 = layoutStyle === 'list-v2';
|
|
75
76
|
const isV2Layout = isGridV2 || isListV2;
|
|
76
|
-
const ownsAction =
|
|
77
|
+
const ownsAction = isV2SingleSelect(selectionMode, layoutStyle);
|
|
77
78
|
const fireAction = itemKey => {
|
|
78
79
|
// 0 is a valid React Aria key, so this cannot be a truthiness check. An empty string is
|
|
79
80
|
// still rejected: it only ever comes from a blank textValue fallback, never a real key.
|
|
@@ -98,7 +99,7 @@ const BaseGridListItem = /*#__PURE__*/forwardRef(function BaseGridListItem(props
|
|
|
98
99
|
* onAction waits for click rather than pointerdown so that starting a drag, or a touch scroll,
|
|
99
100
|
* does not also activate the item. Browsers do not fire click after a native drag.
|
|
100
101
|
*
|
|
101
|
-
*
|
|
102
|
+
* V2 single-select is the exception: content clicks propagate so React Aria selects the
|
|
102
103
|
* item, and onAction fires afterwards from handleContentClick.
|
|
103
104
|
*/
|
|
104
105
|
const handleContentPointerDown = e => {
|
|
@@ -115,7 +116,7 @@ const BaseGridListItem = /*#__PURE__*/forwardRef(function BaseGridListItem(props
|
|
|
115
116
|
// The key comes from the DOM so that onAction and onSelectionChange always report the same
|
|
116
117
|
// React Aria collection key, including when the consumer relies on an auto-generated one.
|
|
117
118
|
const handleContentClick = e => {
|
|
118
|
-
if (!isGridListContentTarget(e.target)) {
|
|
119
|
+
if (!isGridListContentTarget(e.target) || isGridListItemTargetDisabled(e.target)) {
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
122
|
if (ownsAction) {
|
|
@@ -145,6 +146,8 @@ const BaseGridListItem = /*#__PURE__*/forwardRef(function BaseGridListItem(props
|
|
|
145
146
|
[styles.droppableTarget]: isDroppableTarget
|
|
146
147
|
}, {
|
|
147
148
|
[styles.highlighted]: isHighlighted
|
|
149
|
+
}, {
|
|
150
|
+
[styles.actionable]: isActionable
|
|
148
151
|
}, className),
|
|
149
152
|
textValue: textValue,
|
|
150
153
|
children: jsxs(BaseGridListItemContext.Provider, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../../index.css';
|
|
2
|
-
var styles = {"smallList":"bp_base_grid_list_item_module_smallList--
|
|
2
|
+
var styles = {"smallList":"bp_base_grid_list_item_module_smallList--5107e","smallListItem":"bp_base_grid_list_item_module_smallListItem--5107e","loading":"bp_base_grid_list_item_module_loading--5107e","thumbnail":"bp_base_grid_list_item_module_thumbnail--5107e","thumbnailContent":"bp_base_grid_list_item_module_thumbnailContent--5107e","header":"bp_base_grid_list_item_module_header--5107e","subtitle":"bp_base_grid_list_item_module_subtitle--5107e","actions":"bp_base_grid_list_item_module_actions--5107e","selection":"bp_base_grid_list_item_module_selection--5107e","inner":"bp_base_grid_list_item_module_inner--5107e","actionsCheckboxWrapper":"bp_base_grid_list_item_module_actionsCheckboxWrapper--5107e","largeList":"bp_base_grid_list_item_module_largeList--5107e","largeListItem":"bp_base_grid_list_item_module_largeListItem--5107e","fade":"bp_base_grid_list_item_module_fade--5107e","description":"bp_base_grid_list_item_module_description--5107e","snippet":"bp_base_grid_list_item_module_snippet--5107e","snippetContent":"bp_base_grid_list_item_module_snippetContent--5107e","gridList":"bp_base_grid_list_item_module_gridList--5107e","gridListItem":"bp_base_grid_list_item_module_gridListItem--5107e","statusPin":"bp_base_grid_list_item_module_statusPin--5107e","isItemInteracted":"bp_base_grid_list_item_module_isItemInteracted--5107e","tooltipContent":"bp_base_grid_list_item_module_tooltipContent--5107e","tooltipArrow":"bp_base_grid_list_item_module_tooltipArrow--5107e","gridListV2":"bp_base_grid_list_item_module_gridListV2--5107e","gridListV2Item":"bp_base_grid_list_item_module_gridListV2Item--5107e","droppableTarget":"bp_base_grid_list_item_module_droppableTarget--5107e","actionable":"bp_base_grid_list_item_module_actionable--5107e","noActions":"bp_base_grid_list_item_module_noActions--5107e","thumbnailBadges":"bp_base_grid_list_item_module_thumbnailBadges--5107e","statusBadge":"bp_base_grid_list_item_module_statusBadge--5107e","fileTypePill":"bp_base_grid_list_item_module_fileTypePill--5107e","alwaysShowSelection":"bp_base_grid_list_item_module_alwaysShowSelection--5107e","textCentered":"bp_base_grid_list_item_module_textCentered--5107e","innerCentered":"bp_base_grid_list_item_module_innerCentered--5107e","highlighted":"bp_base_grid_list_item_module_highlighted--5107e","gridListV2Small":"bp_base_grid_list_item_module_gridListV2Small--5107e","gridListV2XSmall":"bp_base_grid_list_item_module_gridListV2XSmall--5107e","gridListV2XSmallBordered":"bp_base_grid_list_item_module_gridListV2XSmallBordered--5107e","gridV2ClickShield":"bp_base_grid_list_item_module_gridV2ClickShield--5107e","listV2ClickShield":"bp_base_grid_list_item_module_listV2ClickShield--5107e","listV2":"bp_base_grid_list_item_module_listV2--5107e","listV2Item":"bp_base_grid_list_item_module_listV2Item--5107e","listV2Divider":"bp_base_grid_list_item_module_listV2Divider--5107e","content":"bp_base_grid_list_item_module_content--5107e","listV2Description":"bp_base_grid_list_item_module_listV2Description--5107e","staticList":"bp_base_grid_list_item_module_staticList--5107e","staticListItem":"bp_base_grid_list_item_module_staticListItem--5107e"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -5,7 +5,7 @@ import { GridList } from 'react-aria-components';
|
|
|
5
5
|
import { noop } from '../../utils/noop.js';
|
|
6
6
|
import { isCtrlKeyPressed } from '../../utils/keyboardUtils.js';
|
|
7
7
|
import styles from './base-grid-list-item.module.js';
|
|
8
|
-
import {
|
|
8
|
+
import { isV2SingleSelect, isGridListContentTarget, isGridListItemTargetDisabled, getGridListItemKeyFromTarget } from './grid-list-interaction-utils.js';
|
|
9
9
|
import { StaticGridList } from './static-grid-list.js';
|
|
10
10
|
|
|
11
11
|
const BaseGridListContext = /*#__PURE__*/createContext({
|
|
@@ -35,10 +35,10 @@ const BaseGridList = /*#__PURE__*/forwardRef(function BaseGridList(props, forwar
|
|
|
35
35
|
...rest
|
|
36
36
|
} = props;
|
|
37
37
|
const handleOnAction = onAction || noop;
|
|
38
|
-
// In
|
|
38
|
+
// In V2 single-select, React Aria must only ever select on press: passing it onAction would
|
|
39
39
|
// make it treat rows as actionable and swallow the selection. Blueprint fires onAction itself,
|
|
40
40
|
// from the item's click shield and from the Enter handler below.
|
|
41
|
-
const ownsAction =
|
|
41
|
+
const ownsAction = isV2SingleSelect(rest.selectionMode, layoutStyle);
|
|
42
42
|
const context = useMemo(() => ({
|
|
43
43
|
selectionMode: rest.selectionMode,
|
|
44
44
|
selectionBehavior: rest.selectionBehavior,
|
|
@@ -84,13 +84,13 @@ const BaseGridList = /*#__PURE__*/forwardRef(function BaseGridList(props, forwar
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
// React Aria's GridListItem filters onKeyDown out of its DOM props, so Enter -> onAction for
|
|
87
|
-
//
|
|
87
|
+
// V2 single-select is handled here. It has to run on capture because React Aria's own
|
|
88
88
|
// press handling stops propagation, which would keep the event from bubbling back up. Selection
|
|
89
89
|
// is committed during that bubble phase, so onAction is deferred to a microtask to stay ordered
|
|
90
90
|
// after it.
|
|
91
91
|
const handleKeyDownCapture = e => {
|
|
92
92
|
stopPropagationForNonSpecialKeys(e);
|
|
93
|
-
if (!ownsAction || e.key !== 'Enter' || !isGridListContentTarget(e.target)) {
|
|
93
|
+
if (!ownsAction || e.key !== 'Enter' || !isGridListContentTarget(e.target) || isGridListItemTargetDisabled(e.target)) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
const key = getGridListItemKeyFromTarget(e.target);
|
|
@@ -17,13 +17,18 @@ export declare const GRID_LIST_ITEM_DATA_KEY_ATTR = "data-key";
|
|
|
17
17
|
export declare const GRID_LIST_ITEM_NUMERIC_KEY_ATTR = "data-grid-list-numeric-key";
|
|
18
18
|
/**
|
|
19
19
|
* React Aria treats an item with an onAction as "actionable", which makes a press run the action
|
|
20
|
-
* instead of selecting. GridListV2 single-select
|
|
21
|
-
* onAction from React Aria there and fires it itself. Every other layout and selection mode
|
|
22
|
-
* React Aria's own onAction forwarding.
|
|
20
|
+
* instead of selecting. GridListV2 and LargeListV2 single-select need the press to select, so Blueprint
|
|
21
|
+
* withholds onAction from React Aria there and fires it itself. Every other layout and selection mode
|
|
22
|
+
* keeps React Aria's own onAction forwarding.
|
|
23
23
|
*/
|
|
24
|
-
export declare const
|
|
24
|
+
export declare const isV2SingleSelect: (selectionMode: BaseGridListProps["selectionMode"], layoutStyle: BaseGridListLayoutProp["layoutStyle"] | undefined) => boolean;
|
|
25
25
|
/** Whether a click/keyboard target is item content rather than the checkbox or an action control. */
|
|
26
26
|
export declare const isGridListContentTarget: (target: EventTarget | null) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether `target` is inside a row React Aria has disabled for all interactions. React Aria only sets
|
|
29
|
+
* `data-disabled` when `disabledBehavior` is `all`, so rows that only have selection disabled keep their action.
|
|
30
|
+
*/
|
|
31
|
+
export declare const isGridListItemTargetDisabled: (target: EventTarget | null) => boolean;
|
|
27
32
|
/**
|
|
28
33
|
* Resolve the React Aria collection key of the row containing `target`, restoring a numeric key's
|
|
29
34
|
* original type when the row is marked as numeric. Auto-generated keys have no representation other
|
|
@@ -22,11 +22,11 @@ const CHECKBOX_SELECTOR = '[class*="selection"], input[type="checkbox"]';
|
|
|
22
22
|
const INTERACTIVE_SELECTOR = 'button, a, input, [role="button"], [class*="actions"]';
|
|
23
23
|
/**
|
|
24
24
|
* React Aria treats an item with an onAction as "actionable", which makes a press run the action
|
|
25
|
-
* instead of selecting. GridListV2 single-select
|
|
26
|
-
* onAction from React Aria there and fires it itself. Every other layout and selection mode
|
|
27
|
-
* React Aria's own onAction forwarding.
|
|
25
|
+
* instead of selecting. GridListV2 and LargeListV2 single-select need the press to select, so Blueprint
|
|
26
|
+
* withholds onAction from React Aria there and fires it itself. Every other layout and selection mode
|
|
27
|
+
* keeps React Aria's own onAction forwarding.
|
|
28
28
|
*/
|
|
29
|
-
const
|
|
29
|
+
const isV2SingleSelect = (selectionMode, layoutStyle) => selectionMode === 'single' && (layoutStyle === 'grid-v2' || layoutStyle === 'list-v2');
|
|
30
30
|
/** Whether a click/keyboard target is item content rather than the checkbox or an action control. */
|
|
31
31
|
const isGridListContentTarget = target => {
|
|
32
32
|
// SVG thumbnails are SVGElement rather than HTMLElement; Element covers both.
|
|
@@ -35,6 +35,11 @@ const isGridListContentTarget = target => {
|
|
|
35
35
|
}
|
|
36
36
|
return !target.closest(CHECKBOX_SELECTOR) && !target.closest(INTERACTIVE_SELECTOR);
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Whether `target` is inside a row React Aria has disabled for all interactions. React Aria only sets
|
|
40
|
+
* `data-disabled` when `disabledBehavior` is `all`, so rows that only have selection disabled keep their action.
|
|
41
|
+
*/
|
|
42
|
+
const isGridListItemTargetDisabled = target => target instanceof Element && !!target.closest(`[${GRID_LIST_ITEM_DATA_KEY_ATTR}]`)?.hasAttribute('data-disabled');
|
|
38
43
|
/**
|
|
39
44
|
* Resolve the React Aria collection key of the row containing `target`, restoring a numeric key's
|
|
40
45
|
* original type when the row is marked as numeric. Auto-generated keys have no representation other
|
|
@@ -52,4 +57,4 @@ const getGridListItemKeyFromTarget = target => {
|
|
|
52
57
|
return row?.hasAttribute(GRID_LIST_ITEM_NUMERIC_KEY_ATTR) ? Number(key) : key;
|
|
53
58
|
};
|
|
54
59
|
|
|
55
|
-
export { GRID_LIST_ITEM_DATA_KEY_ATTR, GRID_LIST_ITEM_NUMERIC_KEY_ATTR, getGridListItemKeyFromTarget, isGridListContentTarget,
|
|
60
|
+
export { GRID_LIST_ITEM_DATA_KEY_ATTR, GRID_LIST_ITEM_NUMERIC_KEY_ATTR, getGridListItemKeyFromTarget, isGridListContentTarget, isGridListItemTargetDisabled, isV2SingleSelect };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type ComponentPropsWithRef, type ReactNode } from 'react';
|
|
2
2
|
import { type GridListItemProps, type GridListProps as RAGridListProps } from 'react-aria-components';
|
|
3
3
|
import { type IconButtonProps } from '../../primitives/icon-button';
|
|
4
|
-
import { type Modify } from '../../types/modify';
|
|
5
4
|
import { type SelectionVisibility } from '../../types/selection-visibility';
|
|
6
5
|
export interface BaseGridListLayoutProp {
|
|
7
6
|
layoutStyle: 'grid' | 'grid-v2' | 'list' | 'list-v2' | 'small-list';
|
|
@@ -131,10 +130,19 @@ export type BaseGridListSubtitleProps = ComponentPropsWithRef<'span'>;
|
|
|
131
130
|
export type BaseGridListDescriptionProps = ComponentPropsWithRef<'p'>;
|
|
132
131
|
/** LargeListV2 description. A div so it can wrap non-phrasing content (v1 uses `p`). */
|
|
133
132
|
export type BaseGridListV2DescriptionProps = ComponentPropsWithRef<'div'>;
|
|
134
|
-
export
|
|
133
|
+
export interface BaseGridListActionsProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
|
|
135
134
|
children: ReactNode | ((setIsInteracted: (open: boolean) => void) => ReactNode);
|
|
136
135
|
isSelectionCheckboxDisabled?: boolean;
|
|
137
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Hides the multi-select checkbox. The item can still be selected (e.g. with Space or select all)
|
|
138
|
+
* unless its key is in the list's `disabledKeys`.
|
|
139
|
+
*/
|
|
140
|
+
isSelectionCheckboxHidden?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* `data-target-id` for the multi-select checkbox, applied to its clickable label (e.g. for analytics).
|
|
143
|
+
*/
|
|
144
|
+
selectionCheckboxDataTargetId?: string;
|
|
145
|
+
}
|
|
138
146
|
export type BaseGridListActionIconButtonProps = IconButtonProps;
|
|
139
147
|
export interface BaseGridListProps extends Omit<RAGridListProps<object>, 'layout'>, CustomGridListProps {
|
|
140
148
|
}
|
|
@@ -159,5 +167,11 @@ export interface BaseGridListItemProps extends GridListItemProps, Omit<BaseGridL
|
|
|
159
167
|
* The fade runs once each time this becomes `true`. Supported in `grid-v2` and `list-v2` layouts.
|
|
160
168
|
*/
|
|
161
169
|
isHighlighted?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Whether to style the item as clickable. When false, the cursor stays default
|
|
172
|
+
* and does not show the lift animation on hover.
|
|
173
|
+
* @default true
|
|
174
|
+
*/
|
|
175
|
+
isActionable?: boolean;
|
|
162
176
|
}
|
|
163
177
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.10.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"publishConfig": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@ariakit/react": "0.4.21",
|
|
57
57
|
"@ariakit/react-core": "0.4.21",
|
|
58
|
-
"@box/blueprint-web-assets": "^5.14.
|
|
58
|
+
"@box/blueprint-web-assets": "^5.14.2",
|
|
59
59
|
"@internationalized/date": "^3.12.0",
|
|
60
60
|
"@radix-ui/react-accordion": "1.1.2",
|
|
61
61
|
"@radix-ui/react-checkbox": "1.0.4",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@box/box-test-client": "^3.2.7",
|
|
87
87
|
"@box/playwright-utils": "^2.8.5",
|
|
88
|
-
"@box/storybook-utils": "^1.4.
|
|
88
|
+
"@box/storybook-utils": "^1.4.32",
|
|
89
89
|
"@figma/code-connect": "1.4.4",
|
|
90
90
|
"@playwright/test": "1.46.1",
|
|
91
91
|
"@types/js-yaml": "^4.0.9",
|