@box/blueprint-web 17.15.1 → 17.15.3
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/combobox/combobox.module.js +1 -1
- package/dist/lib-esm/components.css +137 -124
- package/dist/lib-esm/index.css +137 -124
- package/dist/lib-esm/list-item/cell/action-cell.js +9 -1
- package/dist/lib-esm/list-item/index.d.ts +1 -0
- package/dist/lib-esm/list-item/index.js +1 -1
- package/dist/lib-esm/list-item/list-item.d.ts +1 -0
- package/dist/lib-esm/list-item/main.module.js +1 -1
- package/dist/lib-esm/list-item/table.d.ts +11 -0
- package/dist/lib-esm/list-item/table.js +32 -27
- package/dist/lib-esm/list-item/utils/custom-table-options-context/customTableOptionsContext.d.ts +16 -0
- package/dist/lib-esm/list-item/utils/custom-table-options-context/customTableOptionsContext.js +26 -0
- package/package.json +3 -3
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import clsx from 'clsx';
|
|
2
3
|
import { forwardRef, useRef } from 'react';
|
|
3
4
|
import { useTableOptions } from 'react-aria-components';
|
|
4
5
|
import { ListCheckbox } from '../../util-components/list-checkbox/list-checkbox.js';
|
|
5
6
|
import styles from '../main.module.js';
|
|
7
|
+
import { useCustomTableOptions } from '../utils/custom-table-options-context/customTableOptionsContext.js';
|
|
6
8
|
import { Cell } from './cell.js';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -22,6 +24,9 @@ const ActionCell = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
22
24
|
selectionBehavior,
|
|
23
25
|
selectionMode
|
|
24
26
|
} = useTableOptions();
|
|
27
|
+
const {
|
|
28
|
+
selectionVisibility
|
|
29
|
+
} = useCustomTableOptions();
|
|
25
30
|
const divRef = useRef(null);
|
|
26
31
|
// Allows consumer to sync changes to dropdown `open` state. Ensures actions are shown when dropdown is open
|
|
27
32
|
// TODO(DSYS-1175): Once we have feature complete dropdown, this could be built-in.
|
|
@@ -31,13 +36,16 @@ const ActionCell = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
31
36
|
}
|
|
32
37
|
};
|
|
33
38
|
const shouldShowCheckbox = selectionBehavior === 'toggle' && selectionMode === 'multiple';
|
|
39
|
+
const alwaysShowSelection = selectionVisibility === 'always' && shouldShowCheckbox;
|
|
34
40
|
return jsx(Cell, {
|
|
35
41
|
className: styles.actions,
|
|
36
42
|
...rest,
|
|
37
43
|
ref: ref,
|
|
38
44
|
children: !!children && !loading ? jsxs("div", {
|
|
39
45
|
ref: divRef,
|
|
40
|
-
className: styles.actionsWrapper,
|
|
46
|
+
className: clsx(styles.actionsWrapper, {
|
|
47
|
+
[styles.alwaysShowSelection]: alwaysShowSelection
|
|
48
|
+
}),
|
|
41
49
|
"data-actionswrapper": true,
|
|
42
50
|
children: [jsx("div", {
|
|
43
51
|
className: styles.actionChildren,
|
|
@@ -11,6 +11,7 @@ export declare const Table: import("react").ForwardRefExoticComponent<import("re
|
|
|
11
11
|
onSortChange?: (sortDescriptor: import("react-stately").SortDescriptor) => void;
|
|
12
12
|
sortDescriptor?: import("react-stately").SortDescriptor;
|
|
13
13
|
defaultSortDescriptor?: import("react-stately").SortDescriptor;
|
|
14
|
+
selectionVisibility?: import("./utils/custom-table-options-context/customTableOptionsContext").SelectionVisibility;
|
|
14
15
|
} & import("react").RefAttributes<HTMLTableElement>>;
|
|
15
16
|
export declare const Cell: import("react").ForwardRefExoticComponent<import("./cell/cell").CellProps & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
16
17
|
export declare const Column: (props: ColumnProps & {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'react/jsx-runtime';
|
|
2
|
+
import 'clsx';
|
|
2
3
|
import 'react';
|
|
3
4
|
import 'react-aria-components';
|
|
4
5
|
import '@box/blueprint-web-assets/icons/Fill';
|
|
5
6
|
import '@box/blueprint-web-assets/tokens/tokens';
|
|
6
|
-
import 'clsx';
|
|
7
7
|
import { Cell as Cell$1 } from './cell/cell.js';
|
|
8
8
|
import '../utils/useBreakpoint.js';
|
|
9
9
|
import '@box/blueprint-web-assets/icons/Medium';
|
|
@@ -11,6 +11,7 @@ export declare const Table: import("react").ForwardRefExoticComponent<import("re
|
|
|
11
11
|
onSortChange?: (sortDescriptor: import("react-stately").SortDescriptor) => void;
|
|
12
12
|
sortDescriptor?: import("react-stately").SortDescriptor;
|
|
13
13
|
defaultSortDescriptor?: import("react-stately").SortDescriptor;
|
|
14
|
+
selectionVisibility?: import("./utils/custom-table-options-context/customTableOptionsContext").SelectionVisibility;
|
|
14
15
|
} & import("react").RefAttributes<HTMLTableElement>>;
|
|
15
16
|
export declare const Cell: import("react").ForwardRefExoticComponent<import("./cell/cell").CellProps & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
16
17
|
export declare const Column: (props: ColumnProps & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '../index.css';
|
|
2
|
-
var styles = {"tableSortingContainer":"bp_main_module_tableSortingContainer--
|
|
2
|
+
var styles = {"tableSortingContainer":"bp_main_module_tableSortingContainer--4cb60","resizableTableContainer":"bp_main_module_resizableTableContainer--4cb60","resizableTable":"bp_main_module_resizableTable--4cb60","tableHeader":"bp_main_module_tableHeader--4cb60","column":"bp_main_module_column--4cb60","columnNameWrapper":"bp_main_module_columnNameWrapper--4cb60","columnName":"bp_main_module_columnName--4cb60","focusVisible":"bp_main_module_focusVisible--4cb60","sorted":"bp_main_module_sorted--4cb60","sortingFlexWrapper":"bp_main_module_sortingFlexWrapper--4cb60","columnResizer":"bp_main_module_columnResizer--4cb60","dropdownHeaderContainer":"bp_main_module_dropdownHeaderContainer--4cb60","droppableColumn":"bp_main_module_droppableColumn--4cb60","actionColumn":"bp_main_module_actionColumn--4cb60","hiddenColumn":"bp_main_module_hiddenColumn--4cb60","tableBody":"bp_main_module_tableBody--4cb60","row":"bp_main_module_row--4cb60","cell":"bp_main_module_cell--4cb60","actionsWrapper":"bp_main_module_actionsWrapper--4cb60","actionChildren":"bp_main_module_actionChildren--4cb60","actions":"bp_main_module_actions--4cb60","alwaysShowSelection":"bp_main_module_alwaysShowSelection--4cb60","isCellHidden":"bp_main_module_isCellHidden--4cb60"};
|
|
3
3
|
|
|
4
4
|
export { styles as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type TableProps as PrimitiveTableProps, type ResizableTableContainerProps, type SortDescriptor } from 'react-aria-components';
|
|
2
2
|
import { type OnColumnVisibilityChange } from './utils/column-visibility-context/column-metadata';
|
|
3
|
+
import { type SelectionVisibility } from './utils/custom-table-options-context/customTableOptionsContext';
|
|
3
4
|
export type TableProps = PrimitiveTableProps & {
|
|
4
5
|
/**
|
|
5
6
|
* Setting this to true enables the column dropping functionality.
|
|
@@ -32,6 +33,11 @@ export type TableProps = PrimitiveTableProps & {
|
|
|
32
33
|
* Default sort descriptor when uncontrolled.
|
|
33
34
|
*/
|
|
34
35
|
defaultSortDescriptor?: SortDescriptor;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the row selection checkbox in `ActionCell` is always visible or only on hover/focus/selection.
|
|
38
|
+
* UXF-1344: `always` is not supported with `selectionMode` `single` (aka single select) yet. Omitted = hover.
|
|
39
|
+
*/
|
|
40
|
+
selectionVisibility?: SelectionVisibility;
|
|
35
41
|
};
|
|
36
42
|
/**
|
|
37
43
|
* Based on React Aria Components `Table`
|
|
@@ -69,4 +75,9 @@ export declare const Table: import("react").ForwardRefExoticComponent<PrimitiveT
|
|
|
69
75
|
* Default sort descriptor when uncontrolled.
|
|
70
76
|
*/
|
|
71
77
|
defaultSortDescriptor?: SortDescriptor;
|
|
78
|
+
/**
|
|
79
|
+
* Whether the row selection checkbox in `ActionCell` is always visible or only on hover/focus/selection.
|
|
80
|
+
* UXF-1344: `always` is not supported with `selectionMode` `single` (aka single select) yet. Omitted = hover.
|
|
81
|
+
*/
|
|
82
|
+
selectionVisibility?: SelectionVisibility;
|
|
72
83
|
} & import("react").RefAttributes<HTMLTableElement>>;
|
|
@@ -5,6 +5,7 @@ import clsx from 'clsx';
|
|
|
5
5
|
import { noop } from '../utils/noop.js';
|
|
6
6
|
import styles from './main.module.js';
|
|
7
7
|
import { ColumnVisibilityProvider, useColumnVisibilityContext } from './utils/column-visibility-context/columnVisibilityContext.js';
|
|
8
|
+
import { CustomTableOptionsProvider } from './utils/custom-table-options-context/customTableOptionsContext.js';
|
|
8
9
|
import { TableSortingProvider, useTableSortingContext } from './utils/table-sorting-context/tableSortingContext.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -23,39 +24,43 @@ const Table = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
23
24
|
defaultSortDescriptor,
|
|
24
25
|
onSortChange,
|
|
25
26
|
resizableTableContainerProps,
|
|
27
|
+
selectionVisibility,
|
|
26
28
|
...rest
|
|
27
29
|
} = props;
|
|
28
30
|
const resizableContainerRef = useRef(null);
|
|
29
31
|
const dropdownHeaderContainerRef = useRef(null);
|
|
30
32
|
const enableModernizedComponents = true;
|
|
31
|
-
return jsx(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
children:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
return jsx(CustomTableOptionsProvider, {
|
|
34
|
+
selectionVisibility: selectionVisibility,
|
|
35
|
+
children: jsx(TableSortingProvider, {
|
|
36
|
+
defaultSortDescriptor: defaultSortDescriptor,
|
|
37
|
+
dropdownHeaderContainerRef: dropdownHeaderContainerRef,
|
|
38
|
+
onSortChange: onSortChange,
|
|
39
|
+
sortDescriptor: sortDescriptor,
|
|
40
|
+
children: jsxs("div", {
|
|
41
|
+
className: styles.tableSortingContainer,
|
|
42
|
+
children: [jsx("div", {
|
|
43
|
+
ref: dropdownHeaderContainerRef
|
|
44
|
+
}), jsx(ColumnVisibilityProvider, {
|
|
45
|
+
containerRef: resizableContainerRef,
|
|
46
|
+
isColumnDroppingEnabled: isColumnDroppingEnabled,
|
|
47
|
+
isColumnResizingEnabled: isColumnResizingEnabled,
|
|
48
|
+
onVisibleColumnsChange: onVisibleColumnsChange,
|
|
49
|
+
children: jsx(ResizableTableContainer, {
|
|
50
|
+
ref: resizableContainerRef,
|
|
51
|
+
className: styles.resizableTableContainer,
|
|
52
|
+
"data-modern": enableModernizedComponents,
|
|
53
|
+
...resizableTableContainerProps,
|
|
54
|
+
children: jsx(TableInner, {
|
|
55
|
+
ref: ref,
|
|
56
|
+
...rest,
|
|
57
|
+
className: className,
|
|
58
|
+
onRowAction: onRowAction,
|
|
59
|
+
children: children
|
|
60
|
+
})
|
|
56
61
|
})
|
|
57
|
-
})
|
|
58
|
-
})
|
|
62
|
+
})]
|
|
63
|
+
})
|
|
59
64
|
})
|
|
60
65
|
});
|
|
61
66
|
});
|
package/dist/lib-esm/list-item/utils/custom-table-options-context/customTableOptionsContext.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type SelectionVisibility = 'hover' | 'always';
|
|
3
|
+
export interface CustomTableOptions {
|
|
4
|
+
selectionVisibility: SelectionVisibility;
|
|
5
|
+
}
|
|
6
|
+
interface CustomTableOptionsProviderProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
selectionVisibility?: SelectionVisibility;
|
|
9
|
+
}
|
|
10
|
+
export declare const CustomTableOptionsProvider: ({ children, selectionVisibility, }: CustomTableOptionsProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* RAC Table comes with a default context useTableOptions
|
|
13
|
+
* This context is for custom options not included in RAC Table
|
|
14
|
+
*/
|
|
15
|
+
export declare const useCustomTableOptions: () => CustomTableOptions;
|
|
16
|
+
export {};
|
package/dist/lib-esm/list-item/utils/custom-table-options-context/customTableOptionsContext.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useContext, createContext } from 'react';
|
|
3
|
+
|
|
4
|
+
const DEFAULT_CUSTOM_TABLE_OPTIONS = {
|
|
5
|
+
selectionVisibility: 'hover'
|
|
6
|
+
};
|
|
7
|
+
const CustomTableOptionsContext = /*#__PURE__*/createContext(null);
|
|
8
|
+
const CustomTableOptionsProvider = ({
|
|
9
|
+
children,
|
|
10
|
+
selectionVisibility = DEFAULT_CUSTOM_TABLE_OPTIONS.selectionVisibility
|
|
11
|
+
}) => jsx(CustomTableOptionsContext.Provider, {
|
|
12
|
+
value: {
|
|
13
|
+
selectionVisibility
|
|
14
|
+
},
|
|
15
|
+
children: children
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* RAC Table comes with a default context useTableOptions
|
|
19
|
+
* This context is for custom options not included in RAC Table
|
|
20
|
+
*/
|
|
21
|
+
const useCustomTableOptions = () => {
|
|
22
|
+
const context = useContext(CustomTableOptionsContext);
|
|
23
|
+
return context ?? DEFAULT_CUSTOM_TABLE_OPTIONS;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { CustomTableOptionsProvider, useCustomTableOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/blueprint-web",
|
|
3
|
-
"version": "17.15.
|
|
3
|
+
"version": "17.15.3",
|
|
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.10.
|
|
58
|
+
"@box/blueprint-web-assets": "^5.10.25",
|
|
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",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@box/box-test-client": "^3.2.7",
|
|
88
88
|
"@box/playwright-utils": "^2.8.5",
|
|
89
|
-
"@box/storybook-utils": "^1.2.
|
|
89
|
+
"@box/storybook-utils": "^1.2.69",
|
|
90
90
|
"@figma/code-connect": "1.4.4",
|
|
91
91
|
"@playwright/test": "1.46.1",
|
|
92
92
|
"@types/js-yaml": "^4.0.9",
|