@prt-ts/fluent-react-table-v2 9.46.8-build.9.0 → 9.47.1-build-2.0
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/index.cjs.js +106 -59
- package/index.esm.js +88 -45
- package/package.json +2 -2
- package/src/lib/components/extensions/PinRowAction.d.ts +6 -0
- package/src/lib/components/extensions/SelectRowCheckbox.d.ts +6 -0
- package/src/lib/components/extensions/SelectRowRadio.d.ts +6 -0
- package/src/lib/components/extensions/index.d.ts +3 -0
- package/src/lib/components/filters/Filter.d.ts +1 -1
- package/src/lib/components/filters/FilterMultiSelectCheckbox.d.ts +1 -1
- package/src/lib/components/filters/FilterSelectRadio.d.ts +1 -1
- package/src/lib/components/tbody/TableRow.d.ts +7 -5
- package/src/lib/components/thead/HeaderCell.d.ts +2 -4
- package/src/lib/components/thead/HeaderRow.d.ts +0 -2
- package/src/lib/components/thead/useTableHeaderStyles.d.ts +1 -1
- package/src/lib/helpers/Shorthands.d.ts +10 -0
- package/src/lib/helpers/StylesHelper.d.ts +2 -1
- package/src/lib/index.d.ts +5 -2
- package/src/lib/types/TableProps.d.ts +7 -0
package/index.cjs.js
CHANGED
|
@@ -15,25 +15,36 @@ var core = require('@dnd-kit/core');
|
|
|
15
15
|
var modifiers = require('@dnd-kit/modifiers');
|
|
16
16
|
|
|
17
17
|
function _interopNamespace(e) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
if (e && e.__esModule) return e;
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
Object.keys(e).forEach(function (k) {
|
|
22
|
+
if (k !== 'default') {
|
|
23
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
24
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return e[k]; }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
27
29
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
n["default"] = e;
|
|
32
|
-
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
n["default"] = e;
|
|
32
|
+
return Object.freeze(n);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
36
36
|
|
|
37
|
+
const disableAllShorthand = {
|
|
38
|
+
enableGrouping: false,
|
|
39
|
+
enableHiding: false,
|
|
40
|
+
enablePinning: false,
|
|
41
|
+
enableSorting: false,
|
|
42
|
+
enableColumnFilter: false,
|
|
43
|
+
enableGlobalFilter: false,
|
|
44
|
+
enableMultiSort: false,
|
|
45
|
+
enableResizing: false,
|
|
46
|
+
};
|
|
47
|
+
|
|
37
48
|
const useStaticStyles = reactComponents.makeStaticStyles({
|
|
38
49
|
"*": {
|
|
39
50
|
boxSizing: "border-box",
|
|
@@ -1041,6 +1052,9 @@ const SaveFilled = /*#__PURE__*/createFluentIcon('SaveFilled', "1em", ["M3 5c0-1
|
|
|
1041
1052
|
const SaveRegular = /*#__PURE__*/createFluentIcon('SaveRegular', "1em", ["M3 5c0-1.1.9-2 2-2h8.38a2 2 0 0 1 1.41.59l1.62 1.62A2 2 0 0 1 17 6.62V15a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm2-1a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1v-4.5c0-.83.67-1.5 1.5-1.5h7c.83 0 1.5.67 1.5 1.5V16a1 1 0 0 0 1-1V6.62a1 1 0 0 0-.3-.7L14.1 4.28a1 1 0 0 0-.71-.29H13v2.5c0 .83-.67 1.5-1.5 1.5h-4A1.5 1.5 0 0 1 6 6.5V4H5Zm2 0v2.5c0 .28.22.5.5.5h4a.5.5 0 0 0 .5-.5V4H7Zm7 12v-4.5a.5.5 0 0 0-.5-.5h-7a.5.5 0 0 0-.5.5V16h8Z"]);
|
|
1042
1053
|
const SearchFilled = /*#__PURE__*/createFluentIcon('SearchFilled', "1em", ["M8.5 3a5.5 5.5 0 0 1 4.38 8.82l4.15 4.15a.75.75 0 0 1-.98 1.13l-.08-.07-4.15-4.15A5.5 5.5 0 1 1 8.5 3Zm0 1.5a4 4 0 1 0 0 8 4 4 0 0 0 0-8Z"]);
|
|
1043
1054
|
const SearchRegular = /*#__PURE__*/createFluentIcon('SearchRegular', "1em", ["M8.5 3a5.5 5.5 0 0 1 4.23 9.02l4.12 4.13a.5.5 0 0 1-.63.76l-.07-.06-4.13-4.12A5.5 5.5 0 1 1 8.5 3Zm0 1a4.5 4.5 0 1 0 0 9 4.5 4.5 0 0 0 0-9Z"]);
|
|
1055
|
+
const StarRegular = /*#__PURE__*/createFluentIcon('StarRegular', "1em", ["M9.1 2.9a1 1 0 0 1 1.8 0l1.93 3.91 4.31.63a1 1 0 0 1 .56 1.7l-3.12 3.05.73 4.3a1 1 0 0 1-1.45 1.05L10 15.51l-3.86 2.03a1 1 0 0 1-1.45-1.05l.74-4.3L2.3 9.14a1 1 0 0 1 .56-1.7l4.31-.63L9.1 2.9Zm.9.44L8.07 7.25a1 1 0 0 1-.75.55L3 8.43l3.12 3.04a1 1 0 0 1 .3.89l-.75 4.3 3.87-2.03a1 1 0 0 1 .93 0l3.86 2.03-.74-4.3a1 1 0 0 1 .29-.89L17 8.43l-4.32-.63a1 1 0 0 1-.75-.55L10 3.35Z"]);
|
|
1056
|
+
const SwipeDownFilled = /*#__PURE__*/createFluentIcon('SwipeDownFilled', "1em", ["M14 6a4 4 0 0 1-2.25 3.6V8.44a3 3 0 1 0-3.5 0V9.6A4 4 0 1 1 14 6ZM9.47 17.78c.3.3.77.3 1.06 0l2.5-2.5a.75.75 0 1 0-1.06-1.06l-1.22 1.22V5.75a.75.75 0 0 0-1.5 0v9.69l-1.22-1.22a.75.75 0 0 0-1.06 1.06l2.5 2.5Z"]);
|
|
1057
|
+
const SwipeUpFilled = /*#__PURE__*/createFluentIcon('SwipeUpFilled', "1em", ["M10.53 2.22a.75.75 0 0 0-1.06 0l-2.5 2.5a.75.75 0 0 0 1.06 1.06l1.22-1.22v9.69a.75.75 0 0 0 1.5 0V4.56l1.22 1.22a.75.75 0 1 0 1.06-1.06l-2.5-2.5ZM6 14a4 4 0 0 1 2.25-3.6v1.16a3 3 0 1 0 3.5 0V10.4A4 4 0 1 1 6 14Z"]);
|
|
1044
1058
|
|
|
1045
1059
|
const TableSimpleCheckmarkFilled = /*#__PURE__*/createFluentIcon('TableSimpleCheckmarkFilled', "1em", ["M14 17h-3.5v-6.5H17V14a3 3 0 0 1-3 3Zm3-7.5h-6.5V3H14a3 3 0 0 1 3 3v3.5Zm-7.5 0V3H6a3 3 0 0 0-3 3v3.5h6.5Zm0 7.5v-6.5H3V14a3 3 0 0 0 3 3h3.5Zm5.85-3.9a.5.5 0 0 0-.7-.7l-1.4 1.4-.4-.4a.5.5 0 0 0-.7.7l.75.75c.2.2.5.2.7 0l1.75-1.75Z"]);
|
|
1046
1060
|
const TableSimpleCheckmarkRegular = /*#__PURE__*/createFluentIcon('TableSimpleCheckmarkRegular', "1em", ["M6 3a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V6a3 3 0 0 0-3-3H6ZM4 6c0-1.1.9-2 2-2h3.5v5.5H4V6Zm6.5 3.5V4H14a2 2 0 0 1 2 2v3.5h-5.5Zm-6.5 1h5.5V16H6a2 2 0 0 1-2-2v-3.5Zm10.86 1.4c.2.2.2.5 0 .7l-1.75 1.75a.5.5 0 0 1-.71 0l-.75-.75a.5.5 0 0 1 .7-.7l.4.4 1.4-1.4c.2-.2.51-.2.7 0Z"]);
|
|
@@ -1176,10 +1190,11 @@ const useGridHeaderStyles = reactComponents.makeStyles({
|
|
|
1176
1190
|
|
|
1177
1191
|
const GridHeader = (props) => {
|
|
1178
1192
|
const { table, gridTitle, globalFilter, setGlobalFilter } = props;
|
|
1193
|
+
const focusAttribute = reactComponents.useArrowNavigationGroup({ axis: "horizontal", circular: true });
|
|
1179
1194
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1180
1195
|
const { dispatchDrawerAction, drawerState } = table.options.meta;
|
|
1181
1196
|
const styles = useGridHeaderStyles();
|
|
1182
|
-
return (jsxRuntime.jsxs("div", { className: styles.tableTopHeaderContainer, children: [jsxRuntime.jsx("div", { className: styles.tableTopHeaderLeft, children: gridTitle }), jsxRuntime.jsxs("div", { className: styles.tableTopHeaderRight, children: [props.headerMenu, props.headerMenu && jsxRuntime.jsx(reactComponents.Divider, { vertical: true }), jsxRuntime.jsxs(reactComponents.Popover, { withArrow: true, children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Toggle Group Column', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) }) }), jsxRuntime.jsx(reactComponents.PopoverSurface, { className: styles.popoverSurface, children: jsxRuntime.jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsxRuntime.jsx(reactComponents.MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
1197
|
+
return (jsxRuntime.jsxs("div", { className: styles.tableTopHeaderContainer, children: [jsxRuntime.jsx("div", { className: styles.tableTopHeaderLeft, children: gridTitle }), jsxRuntime.jsxs("div", Object.assign({ className: styles.tableTopHeaderRight }, focusAttribute, { children: [props.headerMenu, props.headerMenu && jsxRuntime.jsx(reactComponents.Divider, { vertical: true }), jsxRuntime.jsxs(reactComponents.Popover, { withArrow: true, children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Toggle Group Column', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) }) }), jsxRuntime.jsx(reactComponents.PopoverSurface, { className: styles.popoverSurface, children: jsxRuntime.jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsxRuntime.jsx(reactComponents.MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
1183
1198
|
if (column.id === 'select')
|
|
1184
1199
|
return null;
|
|
1185
1200
|
if (column.id === 'id')
|
|
@@ -1191,7 +1206,7 @@ const GridHeader = (props) => {
|
|
|
1191
1206
|
return (jsxRuntime.jsx(reactComponents.Checkbox, { checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), label: column.id, disabled: !column.getCanHide() }, column.id));
|
|
1192
1207
|
})] }) })] }), jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Table Views Management', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { onClick: () => {
|
|
1193
1208
|
dispatchDrawerAction === null || dispatchDrawerAction === void 0 ? void 0 : dispatchDrawerAction({ type: "TOGGLE_VIEW_DRAWER" });
|
|
1194
|
-
}, icon: jsxRuntime.jsx(Album24Regular, {}), "aria-label": "View Menu" }) }), jsxRuntime.jsx(DebouncedInput, { value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : '', onChange: (value) => setGlobalFilter(String(value)), className: "p-2 font-lg shadow border border-block", placeholder: "Search all columns...", dispatch: dispatchDrawerAction, drawerState: drawerState })] })] }));
|
|
1209
|
+
}, icon: jsxRuntime.jsx(Album24Regular, {}), "aria-label": "View Menu" }) }), jsxRuntime.jsx(DebouncedInput, { value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : '', onChange: (value) => setGlobalFilter(String(value)), className: "p-2 font-lg shadow border border-block", placeholder: "Search all columns...", dispatch: dispatchDrawerAction, drawerState: drawerState })] }))] }));
|
|
1195
1210
|
};
|
|
1196
1211
|
// A debounced input react component
|
|
1197
1212
|
function DebouncedInput({ value: initialValue, onChange, debounce = 500, drawerState, dispatch, }) {
|
|
@@ -1297,7 +1312,7 @@ function tableReducer(state, action) {
|
|
|
1297
1312
|
}
|
|
1298
1313
|
|
|
1299
1314
|
const useGridContainer = (props, ref) => {
|
|
1300
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1315
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1301
1316
|
const { defaultColumn, columns, data, rowSelectionMode, autoResetPageIndex, onUpdateData } = props;
|
|
1302
1317
|
const [drawerState, dispatch] = React__namespace.useReducer(tableReducer, {
|
|
1303
1318
|
isFilterDrawerOpen: false,
|
|
@@ -1354,7 +1369,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1354
1369
|
rowPinning
|
|
1355
1370
|
},
|
|
1356
1371
|
getRowId(originalRow, index, parent) {
|
|
1357
|
-
const keyProps = props.dataPrimaryKye
|
|
1372
|
+
const keyProps = props.dataPrimaryKye;
|
|
1358
1373
|
return originalRow[keyProps] || `${index}`;
|
|
1359
1374
|
},
|
|
1360
1375
|
columnResizeMode: 'onChange',
|
|
@@ -1409,7 +1424,8 @@ const useGridContainer = (props, ref) => {
|
|
|
1409
1424
|
setExpanded,
|
|
1410
1425
|
setColumnPinning,
|
|
1411
1426
|
setColumnSizing,
|
|
1412
|
-
setRowPinning
|
|
1427
|
+
setRowPinning,
|
|
1428
|
+
tableSettings: (_l = props.tableSettings) !== null && _l !== void 0 ? _l : {},
|
|
1413
1429
|
}
|
|
1414
1430
|
});
|
|
1415
1431
|
const tableViews = React__namespace.useMemo(() => { var _a; return (_a = props.views) !== null && _a !== void 0 ? _a : []; }, [props.views]);
|
|
@@ -1544,6 +1560,7 @@ const useTableHeaderStyles = reactComponents.makeStyles({
|
|
|
1544
1560
|
height: '100%',
|
|
1545
1561
|
cursor: 'grab',
|
|
1546
1562
|
},
|
|
1563
|
+
tHeadCellDraggableDragging: Object.assign(Object.assign({}, reactComponents.shorthands.borderLeft(reactComponents.tokens.strokeWidthThin, 'solid', reactComponents.tokens.colorBrandBackgroundInverted)), reactComponents.shorthands.padding(0, reactComponents.tokens.spacingHorizontalXS)),
|
|
1547
1564
|
tHeadCellDragging: {
|
|
1548
1565
|
opacity: 0.5,
|
|
1549
1566
|
cursor: 'grabbing',
|
|
@@ -1585,6 +1602,10 @@ const getBodyCellPinningStyles = (column, isDragging, additionalStyles) => {
|
|
|
1585
1602
|
: undefined, left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined, right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined, position: isPinned ? 'sticky' : 'relative', opacity: isDragging ? 0.85 : (isPinned ? 0.95 : 1), zIndex: isDragging ? 2 : (isPinned ? 1 : 0) }, additionalStyles);
|
|
1586
1603
|
return styles;
|
|
1587
1604
|
};
|
|
1605
|
+
const getRowPinningStyles = (row, bottomRowLength, headerGroupLength, additionalStyles) => {
|
|
1606
|
+
const styles = Object.assign({ backgroundColor: reactComponents.tokens.colorPaletteYellowBackground2, position: 'sticky', top: row.getIsPinned() === 'top' ? `${row.getPinnedIndex() * 35 + (39 * headerGroupLength)}px` : undefined, bottom: row.getIsPinned() === 'bottom' ? `${((bottomRowLength || 0) - 1 - row.getPinnedIndex()) * 35}px` : undefined }, additionalStyles);
|
|
1607
|
+
return styles;
|
|
1608
|
+
};
|
|
1588
1609
|
|
|
1589
1610
|
const MoreIcon = bundleIcon$1(MoreVerticalFilled, MoreVerticalRegular);
|
|
1590
1611
|
const SortAscIcon = bundleIcon$1(ArrowSortDown20Filled, ArrowSortDown20Regular);
|
|
@@ -1593,24 +1614,24 @@ const PinIcon = bundleIcon$1(PinFilled, PinRegular);
|
|
|
1593
1614
|
const HideColumnIcon = bundleIcon$1(EyeTrackingOffFilled, EyeTrackingOffRegular);
|
|
1594
1615
|
const GroupExpandIcon = bundleIcon$1(TextExpandFilled, TextExpandRegular);
|
|
1595
1616
|
const GroupCollapseIcon = bundleIcon$1(TextCollapseFilled, TextCollapseRegular);
|
|
1596
|
-
function HeaderCell({ header, table,
|
|
1597
|
-
var _a;
|
|
1598
|
-
const { column } = header;
|
|
1617
|
+
function HeaderCell({ header, table, tabAttributes }) {
|
|
1618
|
+
var _a, _b, _c;
|
|
1619
|
+
const { column, id } = header;
|
|
1599
1620
|
const { isDragging, attributes, listeners, setNodeRef, transform, transition, } = sortable.useSortable({
|
|
1600
|
-
id:
|
|
1621
|
+
id: id
|
|
1601
1622
|
});
|
|
1602
1623
|
const dndStyle = {
|
|
1603
1624
|
transform: utilities.CSS.Translate.toString(transform),
|
|
1604
1625
|
transition
|
|
1605
1626
|
};
|
|
1606
1627
|
const styles = useTableHeaderStyles();
|
|
1607
|
-
const isLeafHeaders =
|
|
1628
|
+
const isLeafHeaders = ((_b = (_a = `${id}`) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b.length) === 1;
|
|
1608
1629
|
const headerCellCombinedStyles = getHeaderCellPinningStyles(column, isDragging, dndStyle);
|
|
1609
1630
|
if (header.isPlaceholder) {
|
|
1610
|
-
return (jsxRuntime.jsx("th", { colSpan: header.colSpan, className: styles.tHeadCell, style: headerCellCombinedStyles, ref: setNodeRef, children: jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) }));
|
|
1631
|
+
return (jsxRuntime.jsx("th", Object.assign({ colSpan: header.colSpan, className: styles.tHeadCell, style: headerCellCombinedStyles, ref: setNodeRef }, attributes, listeners, { children: jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) })));
|
|
1611
1632
|
}
|
|
1612
1633
|
const columnName = reactTable.flexRender(header.column.columnDef.header, header.getContext());
|
|
1613
|
-
return (jsxRuntime.jsxs("th", { colSpan: header.colSpan, className: reactComponents.mergeClasses(styles.tHeadCell, isLeafHeaders && styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging), style: headerCellCombinedStyles, ref: setNodeRef, children: [jsxRuntime.jsx("div", Object.assign({ className: styles.tHeadCellDraggable }, attributes, listeners, { children: jsxRuntime.jsxs("div", { className: isLeafHeaders
|
|
1634
|
+
return (jsxRuntime.jsxs("th", Object.assign({ colSpan: header.colSpan, className: reactComponents.mergeClasses(styles.tHeadCell, isLeafHeaders && styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging), style: headerCellCombinedStyles, ref: setNodeRef }, tabAttributes, { tabIndex: 0, children: [jsxRuntime.jsx("div", Object.assign({ className: reactComponents.mergeClasses(styles.tHeadCellDraggable, isDragging && styles.tHeadCellDraggableDragging) }, attributes, listeners, { children: jsxRuntime.jsxs("div", { className: isLeafHeaders
|
|
1614
1635
|
? styles.tLeafHeadCellContent
|
|
1615
1636
|
: styles.tNonLeafHeadCellContent, children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx(reactControlFlow.Show, { when: !header.isPlaceholder, children: jsxRuntime.jsxs(reactComponents.Button, { style: {
|
|
1616
1637
|
display: 'flex',
|
|
@@ -1625,21 +1646,17 @@ function HeaderCell({ header, table, hideMenu, headerDepth, totalNumberOfHeaderD
|
|
|
1625
1646
|
if (!header.column.getCanGroup())
|
|
1626
1647
|
return;
|
|
1627
1648
|
header.column.getToggleGroupingHandler()();
|
|
1628
|
-
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (
|
|
1649
|
+
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_c = {
|
|
1629
1650
|
asc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortAscIcon, {}) })),
|
|
1630
1651
|
desc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortDescIcon, {}) })),
|
|
1631
|
-
}[header.column.getIsSorted()]) !== null &&
|
|
1652
|
+
}[header.column.getIsSorted()]) !== null && _c !== void 0 ? _c : undefined, iconPosition: "after", children: [jsxRuntime.jsx("strong", { children: columnName }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsGrouped(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(GroupListRegular, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsFiltered(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(FilterFilled, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsPinned(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(PinRegular, {}) }) })] }) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: isLeafHeaders, children: jsxRuntime.jsx(HeaderMenu, { header: header, table: table }) })] }) })), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: !isLeafHeaders, children: jsxRuntime.jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] })));
|
|
1632
1653
|
}
|
|
1633
1654
|
function HeaderMenu(props) {
|
|
1634
|
-
const { header, table
|
|
1655
|
+
const { header, table } = props;
|
|
1635
1656
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1636
1657
|
const { dispatchDrawerAction, drawerState } = table.options.meta;
|
|
1637
1658
|
const styles = useTableHeaderStyles();
|
|
1638
|
-
|
|
1639
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }));
|
|
1640
|
-
const canHavePopOver = header.column.getCanSort() ||
|
|
1641
|
-
header.column.getCanGroup() ||
|
|
1642
|
-
header.column.getCanFilter();
|
|
1659
|
+
const canHavePopOver = header.column.getCanSort() || header.column.getCanGroup() || header.column.getCanFilter();
|
|
1643
1660
|
if (!canHavePopOver)
|
|
1644
1661
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }));
|
|
1645
1662
|
const columnName = reactTable.flexRender(header.column.columnDef.header, header.getContext());
|
|
@@ -1686,19 +1703,24 @@ function HeaderMenu(props) {
|
|
|
1686
1703
|
}
|
|
1687
1704
|
|
|
1688
1705
|
function HeaderRow(props) {
|
|
1706
|
+
var _a;
|
|
1689
1707
|
const styles = useTableHeaderStyles();
|
|
1690
|
-
const { table, headerGroup,
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1708
|
+
const { table, headerGroup, headerGroupsLength } = props;
|
|
1709
|
+
const { rowSelectionMode, tableSettings } = (_a = table.options.meta) !== null && _a !== void 0 ? _a : {};
|
|
1710
|
+
const headerCellTabAttributes = reactComponents.useFocusableGroup({ tabBehavior: "limited" });
|
|
1711
|
+
const isLeafHeaders = headerGroup.depth === headerGroupsLength - 1;
|
|
1712
|
+
return (jsxRuntime.jsxs("tr", { className: styles.tHeadRow, children: [jsxRuntime.jsx(reactControlFlow.Show, { when: !(tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.enableManualSelection), children: jsxRuntime.jsxs(reactControlFlow.Switch, { when: rowSelectionMode, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: "multiple", children: jsxRuntime.jsx("th", { style: { width: '1rem' }, "aria-label": "Select All Row", children: jsxRuntime.jsx(reactControlFlow.Show, { when: isLeafHeaders, children: jsxRuntime.jsx(reactComponents.Checkbox, { checked: table.getIsSomeRowsSelected()
|
|
1713
|
+
? 'mixed'
|
|
1714
|
+
: table.getIsAllRowsSelected(), onChange: table.getToggleAllRowsSelectedHandler(), "aria-label": "Select All Rows", title: 'Select All Rows' }) }) }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: "single", children: jsxRuntime.jsx("th", { style: { width: '1rem' }, "aria-label": "Select All Row Column", children: ' ' }) })] }) }), jsxRuntime.jsx(reactControlFlow.For, { each: headerGroup.headers, children: (header, index) => {
|
|
1715
|
+
return (jsxRuntime.jsx(HeaderCell, { header: header, table: table, tabAttributes: headerCellTabAttributes }, `${header.id}_${index}`));
|
|
1716
|
+
} })] }, headerGroup.id));
|
|
1696
1717
|
}
|
|
1697
1718
|
|
|
1698
1719
|
function TableHeader(props) {
|
|
1699
1720
|
const styles = useTableHeaderStyles();
|
|
1700
1721
|
const { table, headerGroups, rowSelectionMode } = props;
|
|
1701
|
-
|
|
1722
|
+
const focusAttribute = reactComponents.useFocusableGroup({ tabBehavior: "limited-trap-focus" });
|
|
1723
|
+
return (jsxRuntime.jsx("thead", Object.assign({ className: styles.tHead, style: { zIndex: 99 } }, focusAttribute, { tabIndex: 0, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsxRuntime.jsx(HeaderRow, { table: table, rowSelectionMode: rowSelectionMode, headerGroup: headerGroup, headerGroupsLength: headerGroups.length }, headerGroup.id))) })));
|
|
1702
1724
|
}
|
|
1703
1725
|
|
|
1704
1726
|
const useLoadingStyles = reactComponents.makeStyles({
|
|
@@ -1821,31 +1843,51 @@ function TableCell({ cell, row }) {
|
|
|
1821
1843
|
return (jsxRuntime.jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
1822
1844
|
}
|
|
1823
1845
|
|
|
1824
|
-
|
|
1846
|
+
const PinRowAction = ({ row }) => {
|
|
1847
|
+
const isPinned = row.getIsPinned();
|
|
1848
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactControlFlow.Show, { when: isPinned, children: jsxRuntime.jsx(reactComponents.Button, { size: "small", shape: "circular", onClick: () => row.pin(false, true, false), icon: jsxRuntime.jsx(PinOffRegular, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: !isPinned, children: jsxRuntime.jsx("div", { children: jsxRuntime.jsxs(reactComponents.Menu, { children: [jsxRuntime.jsx(reactComponents.MenuTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(StarRegular, {}), shape: "circular", size: "small" }) }), jsxRuntime.jsx(reactComponents.MenuPopover, { children: jsxRuntime.jsxs(reactComponents.MenuList, { children: [jsxRuntime.jsx(reactComponents.MenuItem, { icon: jsxRuntime.jsx(SwipeUpFilled, {}), onClick: () => row.pin('top', true, false), children: "Top" }), jsxRuntime.jsx(reactComponents.MenuItem, { icon: jsxRuntime.jsx(SwipeDownFilled, {}), onClick: () => row.pin('bottom', true, true), children: "Bottom" })] }) })] }) }) })] }));
|
|
1849
|
+
};
|
|
1850
|
+
|
|
1851
|
+
const SelectRowCheckbox = ({ row }) => {
|
|
1852
|
+
const canCheck = row.getCanSelect();
|
|
1853
|
+
const isChecked = row.getIsSomeSelected() ? 'mixed' : (row.getIsSelected() || row.getIsAllSubRowsSelected());
|
|
1854
|
+
return (jsxRuntime.jsx(reactComponents.Checkbox, { checked: isChecked, disabled: !canCheck, onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }));
|
|
1855
|
+
};
|
|
1856
|
+
|
|
1857
|
+
const SelectRowRadio = ({ row }) => {
|
|
1858
|
+
const canCheck = row.getCanSelect();
|
|
1859
|
+
const isChecked = row.getIsSelected();
|
|
1860
|
+
return (jsxRuntime.jsx(reactComponents.Radio, { checked: isChecked, disabled: !canCheck, onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }));
|
|
1861
|
+
};
|
|
1862
|
+
|
|
1863
|
+
function TableRowRaw({ row, table, style, tabAttributes }) {
|
|
1864
|
+
var _a;
|
|
1825
1865
|
const styles = useTableBodyStyles();
|
|
1826
|
-
|
|
1866
|
+
const { rowSelectionMode, tableSettings } = (_a = table.options.meta) !== null && _a !== void 0 ? _a : {};
|
|
1867
|
+
return (jsxRuntime.jsxs("tr", Object.assign({ className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
1827
1868
|
? styles.tBodySelectedRow
|
|
1828
|
-
: styles.tBodyRow, style: style, children: [jsxRuntime.jsxs(reactControlFlow.Switch, { when: rowSelectionMode, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: 'multiple', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row
|
|
1829
|
-
? 'mixed'
|
|
1830
|
-
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: 'single', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(reactComponents.Radio, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) })] }), row.getVisibleCells().map((cell) => (jsxRuntime.jsx(TableCell, { cell: cell, row: row }, cell.id)))] }, row.id));
|
|
1869
|
+
: styles.tBodyRow, style: style }, tabAttributes, { tabIndex: 0, children: [jsxRuntime.jsx(reactControlFlow.Show, { when: !(tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.enableManualSelection), children: jsxRuntime.jsxs(reactControlFlow.Switch, { when: rowSelectionMode, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: 'multiple', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row", children: jsxRuntime.jsx(SelectRowCheckbox, { row: row }) }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: 'single', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row", children: jsxRuntime.jsx(SelectRowRadio, { row: row }) }) })] }) }), row.getVisibleCells().map((cell) => (jsxRuntime.jsx(TableCell, { cell: cell, row: row }, cell.id)))] }), row.id));
|
|
1831
1870
|
}
|
|
1832
|
-
function
|
|
1871
|
+
function PinnedRowRaw({ row, table, style, bottomRowLength, tabAttributes }) {
|
|
1872
|
+
var _a;
|
|
1833
1873
|
const styles = useTableBodyStyles();
|
|
1834
|
-
const
|
|
1835
|
-
|
|
1874
|
+
const headerGroupLength = table.getHeaderGroups().length;
|
|
1875
|
+
const pinnedRowRawStyle = getRowPinningStyles(row, bottomRowLength || 0, headerGroupLength, style || {});
|
|
1876
|
+
const { rowSelectionMode, tableSettings } = (_a = table.options.meta) !== null && _a !== void 0 ? _a : {};
|
|
1877
|
+
return (jsxRuntime.jsxs("tr", Object.assign({ className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
1836
1878
|
? styles.tBodySelectedRow
|
|
1837
|
-
: styles.tBodyRow, style: pinnedRowRawStyle, children: [jsxRuntime.jsxs(reactControlFlow.Switch, { when: rowSelectionMode, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: 'multiple', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(
|
|
1838
|
-
? 'mixed'
|
|
1839
|
-
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: 'single', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(reactComponents.Radio, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) })] }), row.getVisibleCells().map(cell => {
|
|
1879
|
+
: styles.tBodyRow, style: pinnedRowRawStyle }, tabAttributes, { tabIndex: 0, children: [jsxRuntime.jsx(reactControlFlow.Show, { when: !(tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.enableManualSelection), children: jsxRuntime.jsxs(reactControlFlow.Switch, { when: rowSelectionMode, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: 'multiple', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(SelectRowCheckbox, { row: row }) }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: 'single', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(SelectRowRadio, { row: row }) }) })] }) }), row.getVisibleCells().map(cell => {
|
|
1840
1880
|
return (jsxRuntime.jsx(TableCell, { cell: cell, row: row }, cell.id));
|
|
1841
|
-
})] }, row.id));
|
|
1881
|
+
})] }), row.id));
|
|
1842
1882
|
}
|
|
1883
|
+
const TableRow = TableRowRaw;
|
|
1884
|
+
const PinnedRow = PinnedRowRaw;
|
|
1843
1885
|
|
|
1844
1886
|
function TableBody(props) {
|
|
1845
1887
|
var _a, _b, _c;
|
|
1846
1888
|
const styles = useTableBodyStyles();
|
|
1847
1889
|
const { table, tableContainerRef } = props;
|
|
1848
|
-
const rowSelectionMode = (_a = table.options.meta)
|
|
1890
|
+
const { rowSelectionMode } = (_a = table.options.meta) !== null && _a !== void 0 ? _a : {};
|
|
1849
1891
|
let rows = [];
|
|
1850
1892
|
let topRows = [];
|
|
1851
1893
|
let bottomRows = [];
|
|
@@ -1869,13 +1911,14 @@ function TableBody(props) {
|
|
|
1869
1911
|
const paddingBottom = virtualRows.length > 0
|
|
1870
1912
|
? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
|
|
1871
1913
|
: 0;
|
|
1914
|
+
const tabAttributes = reactComponents.useFocusableGroup({ tabBehavior: "limited" });
|
|
1872
1915
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactControlFlow.Show, { when: (topRows === null || topRows === void 0 ? void 0 : topRows.length) > 0, children: jsxRuntime.jsx("thead", { style: {
|
|
1873
1916
|
position: "sticky",
|
|
1874
1917
|
top: 0,
|
|
1875
1918
|
zIndex: 9
|
|
1876
|
-
}, children: jsxRuntime.jsx(reactControlFlow.For, { each: topRows, children: (row, index) => (jsxRuntime.jsx(PinnedRow, { row: row,
|
|
1919
|
+
}, children: jsxRuntime.jsx(reactControlFlow.For, { each: topRows, children: (row, index) => (jsxRuntime.jsx(PinnedRow, { row: row, table: table, bottomRowLength: bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length, tabAttributes: tabAttributes }, `${row.id}_${index}`)) }) }) }), jsxRuntime.jsxs("tbody", { className: styles.tBody, children: [paddingTop > 0 && (jsxRuntime.jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsxRuntime.jsx("td", { style: { height: `${paddingTop}px` } }) })), jsxRuntime.jsx(reactControlFlow.For, { each: virtualRows || [], children: (virtualRow) => {
|
|
1877
1920
|
const row = rows[virtualRow.index];
|
|
1878
|
-
return (jsxRuntime.jsx(TableRow, { row: row,
|
|
1921
|
+
return (jsxRuntime.jsx(TableRow, { row: row, table: table, tabAttributes: tabAttributes }, row.id));
|
|
1879
1922
|
} }), paddingBottom > 0 && (jsxRuntime.jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsxRuntime.jsx("td", { style: { height: `${paddingBottom}px` } }) }))] }), jsxRuntime.jsx(reactControlFlow.Show, { when: rowSelectionMode === 'multiple' && (rows === null || rows === void 0 ? void 0 : rows.length) > 0, children: jsxRuntime.jsx("tfoot", { style: {
|
|
1880
1923
|
position: "sticky",
|
|
1881
1924
|
bottom: 0,
|
|
@@ -1886,7 +1929,7 @@ function TableBody(props) {
|
|
|
1886
1929
|
position: "sticky",
|
|
1887
1930
|
bottom: 0,
|
|
1888
1931
|
zIndex: 9
|
|
1889
|
-
}, children: jsxRuntime.jsx(reactControlFlow.For, { each: bottomRows, children: (row) => (jsxRuntime.jsx(PinnedRow, { row: row,
|
|
1932
|
+
}, children: jsxRuntime.jsx(reactControlFlow.For, { each: bottomRows, children: (row) => (jsxRuntime.jsx(PinnedRow, { row: row, table: table, bottomRowLength: bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length, tabAttributes: tabAttributes }, row.id)) }) }) })] }));
|
|
1890
1933
|
}
|
|
1891
1934
|
|
|
1892
1935
|
const TableContainer = (props) => {
|
|
@@ -2380,8 +2423,12 @@ function useSkipper() {
|
|
|
2380
2423
|
}
|
|
2381
2424
|
|
|
2382
2425
|
Object.defineProperty(exports, 'createColumnHelper', {
|
|
2383
|
-
|
|
2384
|
-
|
|
2426
|
+
enumerable: true,
|
|
2427
|
+
get: function () { return reactTable.createColumnHelper; }
|
|
2385
2428
|
});
|
|
2429
|
+
exports.PinRowAction = PinRowAction;
|
|
2430
|
+
exports.SelectRowCheckbox = SelectRowCheckbox;
|
|
2431
|
+
exports.SelectRowRadio = SelectRowRadio;
|
|
2386
2432
|
exports.Table = ForwardedAdvancedTable;
|
|
2433
|
+
exports.disableAllShorthand = disableAllShorthand;
|
|
2387
2434
|
exports.useSkipper = useSkipper;
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import { makeStaticStyles, makeStyles, shorthands, tokens, useId, Dropdown, Option, Input, Button, Divider, Popover, PopoverTrigger, Tooltip, PopoverSurface, MenuGroupHeader, Checkbox, mergeClasses as mergeClasses$1, Menu, MenuTrigger, MenuButton, MenuPopover, MenuList, MenuGroup, MenuItem, MenuDivider, Skeleton, SkeletonItem, Subtitle2Stronger, Radio, RadioGroup, Field, InlineDrawer, DrawerHeader, DrawerHeaderTitle, DrawerBody, Accordion, AccordionItem, AccordionHeader, Caption1Stronger, AccordionPanel, DrawerFooter, MenuItemRadio } from '@fluentui/react-components';
|
|
4
|
+
import { makeStaticStyles, makeStyles, shorthands, tokens, useId, Dropdown, Option, Input, Button, useArrowNavigationGroup, Divider, Popover, PopoverTrigger, Tooltip, PopoverSurface, MenuGroupHeader, Checkbox, mergeClasses as mergeClasses$1, Menu, MenuTrigger, MenuButton, MenuPopover, MenuList, MenuGroup, MenuItem, MenuDivider, useFocusableGroup, Skeleton, SkeletonItem, Subtitle2Stronger, Radio, RadioGroup, Field, InlineDrawer, DrawerHeader, DrawerHeaderTitle, DrawerBody, Accordion, AccordionItem, AccordionHeader, Caption1Stronger, AccordionPanel, DrawerFooter, MenuItemRadio } from '@fluentui/react-components';
|
|
5
5
|
import { Show, For, Switch, Case } from '@prt-ts/react-control-flow';
|
|
6
6
|
import { useReactTable, getCoreRowModel, getPaginationRowModel, getSortedRowModel, getFilteredRowModel, getGroupedRowModel, getExpandedRowModel, getFacetedUniqueValues, getFacetedMinMaxValues, flexRender } from '@tanstack/react-table';
|
|
7
7
|
export { createColumnHelper } from '@tanstack/react-table';
|
|
@@ -12,6 +12,17 @@ import { DatePicker } from '@fluentui/react-datepicker-compat';
|
|
|
12
12
|
import { useSensor, PointerSensor, MouseSensor, TouchSensor, KeyboardSensor, useSensors, DndContext, closestCenter } from '@dnd-kit/core';
|
|
13
13
|
import { restrictToHorizontalAxis } from '@dnd-kit/modifiers';
|
|
14
14
|
|
|
15
|
+
const disableAllShorthand = {
|
|
16
|
+
enableGrouping: false,
|
|
17
|
+
enableHiding: false,
|
|
18
|
+
enablePinning: false,
|
|
19
|
+
enableSorting: false,
|
|
20
|
+
enableColumnFilter: false,
|
|
21
|
+
enableGlobalFilter: false,
|
|
22
|
+
enableMultiSort: false,
|
|
23
|
+
enableResizing: false,
|
|
24
|
+
};
|
|
25
|
+
|
|
15
26
|
const useStaticStyles = makeStaticStyles({
|
|
16
27
|
"*": {
|
|
17
28
|
boxSizing: "border-box",
|
|
@@ -1019,6 +1030,9 @@ const SaveFilled = /*#__PURE__*/createFluentIcon('SaveFilled', "1em", ["M3 5c0-1
|
|
|
1019
1030
|
const SaveRegular = /*#__PURE__*/createFluentIcon('SaveRegular', "1em", ["M3 5c0-1.1.9-2 2-2h8.38a2 2 0 0 1 1.41.59l1.62 1.62A2 2 0 0 1 17 6.62V15a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm2-1a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1v-4.5c0-.83.67-1.5 1.5-1.5h7c.83 0 1.5.67 1.5 1.5V16a1 1 0 0 0 1-1V6.62a1 1 0 0 0-.3-.7L14.1 4.28a1 1 0 0 0-.71-.29H13v2.5c0 .83-.67 1.5-1.5 1.5h-4A1.5 1.5 0 0 1 6 6.5V4H5Zm2 0v2.5c0 .28.22.5.5.5h4a.5.5 0 0 0 .5-.5V4H7Zm7 12v-4.5a.5.5 0 0 0-.5-.5h-7a.5.5 0 0 0-.5.5V16h8Z"]);
|
|
1020
1031
|
const SearchFilled = /*#__PURE__*/createFluentIcon('SearchFilled', "1em", ["M8.5 3a5.5 5.5 0 0 1 4.38 8.82l4.15 4.15a.75.75 0 0 1-.98 1.13l-.08-.07-4.15-4.15A5.5 5.5 0 1 1 8.5 3Zm0 1.5a4 4 0 1 0 0 8 4 4 0 0 0 0-8Z"]);
|
|
1021
1032
|
const SearchRegular = /*#__PURE__*/createFluentIcon('SearchRegular', "1em", ["M8.5 3a5.5 5.5 0 0 1 4.23 9.02l4.12 4.13a.5.5 0 0 1-.63.76l-.07-.06-4.13-4.12A5.5 5.5 0 1 1 8.5 3Zm0 1a4.5 4.5 0 1 0 0 9 4.5 4.5 0 0 0 0-9Z"]);
|
|
1033
|
+
const StarRegular = /*#__PURE__*/createFluentIcon('StarRegular', "1em", ["M9.1 2.9a1 1 0 0 1 1.8 0l1.93 3.91 4.31.63a1 1 0 0 1 .56 1.7l-3.12 3.05.73 4.3a1 1 0 0 1-1.45 1.05L10 15.51l-3.86 2.03a1 1 0 0 1-1.45-1.05l.74-4.3L2.3 9.14a1 1 0 0 1 .56-1.7l4.31-.63L9.1 2.9Zm.9.44L8.07 7.25a1 1 0 0 1-.75.55L3 8.43l3.12 3.04a1 1 0 0 1 .3.89l-.75 4.3 3.87-2.03a1 1 0 0 1 .93 0l3.86 2.03-.74-4.3a1 1 0 0 1 .29-.89L17 8.43l-4.32-.63a1 1 0 0 1-.75-.55L10 3.35Z"]);
|
|
1034
|
+
const SwipeDownFilled = /*#__PURE__*/createFluentIcon('SwipeDownFilled', "1em", ["M14 6a4 4 0 0 1-2.25 3.6V8.44a3 3 0 1 0-3.5 0V9.6A4 4 0 1 1 14 6ZM9.47 17.78c.3.3.77.3 1.06 0l2.5-2.5a.75.75 0 1 0-1.06-1.06l-1.22 1.22V5.75a.75.75 0 0 0-1.5 0v9.69l-1.22-1.22a.75.75 0 0 0-1.06 1.06l2.5 2.5Z"]);
|
|
1035
|
+
const SwipeUpFilled = /*#__PURE__*/createFluentIcon('SwipeUpFilled', "1em", ["M10.53 2.22a.75.75 0 0 0-1.06 0l-2.5 2.5a.75.75 0 0 0 1.06 1.06l1.22-1.22v9.69a.75.75 0 0 0 1.5 0V4.56l1.22 1.22a.75.75 0 1 0 1.06-1.06l-2.5-2.5ZM6 14a4 4 0 0 1 2.25-3.6v1.16a3 3 0 1 0 3.5 0V10.4A4 4 0 1 1 6 14Z"]);
|
|
1022
1036
|
|
|
1023
1037
|
const TableSimpleCheckmarkFilled = /*#__PURE__*/createFluentIcon('TableSimpleCheckmarkFilled', "1em", ["M14 17h-3.5v-6.5H17V14a3 3 0 0 1-3 3Zm3-7.5h-6.5V3H14a3 3 0 0 1 3 3v3.5Zm-7.5 0V3H6a3 3 0 0 0-3 3v3.5h6.5Zm0 7.5v-6.5H3V14a3 3 0 0 0 3 3h3.5Zm5.85-3.9a.5.5 0 0 0-.7-.7l-1.4 1.4-.4-.4a.5.5 0 0 0-.7.7l.75.75c.2.2.5.2.7 0l1.75-1.75Z"]);
|
|
1024
1038
|
const TableSimpleCheckmarkRegular = /*#__PURE__*/createFluentIcon('TableSimpleCheckmarkRegular', "1em", ["M6 3a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V6a3 3 0 0 0-3-3H6ZM4 6c0-1.1.9-2 2-2h3.5v5.5H4V6Zm6.5 3.5V4H14a2 2 0 0 1 2 2v3.5h-5.5Zm-6.5 1h5.5V16H6a2 2 0 0 1-2-2v-3.5Zm10.86 1.4c.2.2.2.5 0 .7l-1.75 1.75a.5.5 0 0 1-.71 0l-.75-.75a.5.5 0 0 1 .7-.7l.4.4 1.4-1.4c.2-.2.51-.2.7 0Z"]);
|
|
@@ -1154,10 +1168,11 @@ const useGridHeaderStyles = makeStyles({
|
|
|
1154
1168
|
|
|
1155
1169
|
const GridHeader = (props) => {
|
|
1156
1170
|
const { table, gridTitle, globalFilter, setGlobalFilter } = props;
|
|
1171
|
+
const focusAttribute = useArrowNavigationGroup({ axis: "horizontal", circular: true });
|
|
1157
1172
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1158
1173
|
const { dispatchDrawerAction, drawerState } = table.options.meta;
|
|
1159
1174
|
const styles = useGridHeaderStyles();
|
|
1160
|
-
return (jsxs("div", { className: styles.tableTopHeaderContainer, children: [jsx("div", { className: styles.tableTopHeaderLeft, children: gridTitle }), jsxs("div", { className: styles.tableTopHeaderRight, children: [props.headerMenu, props.headerMenu && jsx(Divider, { vertical: true }), jsxs(Popover, { withArrow: true, children: [jsx(PopoverTrigger, { disableButtonEnhancement: true, children: jsx(Tooltip, { content: 'Toggle Group Column', relationship: "label", children: jsx(Button, { icon: jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) }) }), jsx(PopoverSurface, { className: styles.popoverSurface, children: jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsx(MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
1175
|
+
return (jsxs("div", { className: styles.tableTopHeaderContainer, children: [jsx("div", { className: styles.tableTopHeaderLeft, children: gridTitle }), jsxs("div", Object.assign({ className: styles.tableTopHeaderRight }, focusAttribute, { children: [props.headerMenu, props.headerMenu && jsx(Divider, { vertical: true }), jsxs(Popover, { withArrow: true, children: [jsx(PopoverTrigger, { disableButtonEnhancement: true, children: jsx(Tooltip, { content: 'Toggle Group Column', relationship: "label", children: jsx(Button, { icon: jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) }) }), jsx(PopoverSurface, { className: styles.popoverSurface, children: jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsx(MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
1161
1176
|
if (column.id === 'select')
|
|
1162
1177
|
return null;
|
|
1163
1178
|
if (column.id === 'id')
|
|
@@ -1169,7 +1184,7 @@ const GridHeader = (props) => {
|
|
|
1169
1184
|
return (jsx(Checkbox, { checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), label: column.id, disabled: !column.getCanHide() }, column.id));
|
|
1170
1185
|
})] }) })] }), jsx(Tooltip, { content: 'Table Views Management', relationship: "label", children: jsx(Button, { onClick: () => {
|
|
1171
1186
|
dispatchDrawerAction === null || dispatchDrawerAction === void 0 ? void 0 : dispatchDrawerAction({ type: "TOGGLE_VIEW_DRAWER" });
|
|
1172
|
-
}, icon: jsx(Album24Regular, {}), "aria-label": "View Menu" }) }), jsx(DebouncedInput, { value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : '', onChange: (value) => setGlobalFilter(String(value)), className: "p-2 font-lg shadow border border-block", placeholder: "Search all columns...", dispatch: dispatchDrawerAction, drawerState: drawerState })] })] }));
|
|
1187
|
+
}, icon: jsx(Album24Regular, {}), "aria-label": "View Menu" }) }), jsx(DebouncedInput, { value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : '', onChange: (value) => setGlobalFilter(String(value)), className: "p-2 font-lg shadow border border-block", placeholder: "Search all columns...", dispatch: dispatchDrawerAction, drawerState: drawerState })] }))] }));
|
|
1173
1188
|
};
|
|
1174
1189
|
// A debounced input react component
|
|
1175
1190
|
function DebouncedInput({ value: initialValue, onChange, debounce = 500, drawerState, dispatch, }) {
|
|
@@ -1275,7 +1290,7 @@ function tableReducer(state, action) {
|
|
|
1275
1290
|
}
|
|
1276
1291
|
|
|
1277
1292
|
const useGridContainer = (props, ref) => {
|
|
1278
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1293
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1279
1294
|
const { defaultColumn, columns, data, rowSelectionMode, autoResetPageIndex, onUpdateData } = props;
|
|
1280
1295
|
const [drawerState, dispatch] = React.useReducer(tableReducer, {
|
|
1281
1296
|
isFilterDrawerOpen: false,
|
|
@@ -1332,7 +1347,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1332
1347
|
rowPinning
|
|
1333
1348
|
},
|
|
1334
1349
|
getRowId(originalRow, index, parent) {
|
|
1335
|
-
const keyProps = props.dataPrimaryKye
|
|
1350
|
+
const keyProps = props.dataPrimaryKye;
|
|
1336
1351
|
return originalRow[keyProps] || `${index}`;
|
|
1337
1352
|
},
|
|
1338
1353
|
columnResizeMode: 'onChange',
|
|
@@ -1387,7 +1402,8 @@ const useGridContainer = (props, ref) => {
|
|
|
1387
1402
|
setExpanded,
|
|
1388
1403
|
setColumnPinning,
|
|
1389
1404
|
setColumnSizing,
|
|
1390
|
-
setRowPinning
|
|
1405
|
+
setRowPinning,
|
|
1406
|
+
tableSettings: (_l = props.tableSettings) !== null && _l !== void 0 ? _l : {},
|
|
1391
1407
|
}
|
|
1392
1408
|
});
|
|
1393
1409
|
const tableViews = React.useMemo(() => { var _a; return (_a = props.views) !== null && _a !== void 0 ? _a : []; }, [props.views]);
|
|
@@ -1522,6 +1538,7 @@ const useTableHeaderStyles = makeStyles({
|
|
|
1522
1538
|
height: '100%',
|
|
1523
1539
|
cursor: 'grab',
|
|
1524
1540
|
},
|
|
1541
|
+
tHeadCellDraggableDragging: Object.assign(Object.assign({}, shorthands.borderLeft(tokens.strokeWidthThin, 'solid', tokens.colorBrandBackgroundInverted)), shorthands.padding(0, tokens.spacingHorizontalXS)),
|
|
1525
1542
|
tHeadCellDragging: {
|
|
1526
1543
|
opacity: 0.5,
|
|
1527
1544
|
cursor: 'grabbing',
|
|
@@ -1563,6 +1580,10 @@ const getBodyCellPinningStyles = (column, isDragging, additionalStyles) => {
|
|
|
1563
1580
|
: undefined, left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined, right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined, position: isPinned ? 'sticky' : 'relative', opacity: isDragging ? 0.85 : (isPinned ? 0.95 : 1), zIndex: isDragging ? 2 : (isPinned ? 1 : 0) }, additionalStyles);
|
|
1564
1581
|
return styles;
|
|
1565
1582
|
};
|
|
1583
|
+
const getRowPinningStyles = (row, bottomRowLength, headerGroupLength, additionalStyles) => {
|
|
1584
|
+
const styles = Object.assign({ backgroundColor: tokens.colorPaletteYellowBackground2, position: 'sticky', top: row.getIsPinned() === 'top' ? `${row.getPinnedIndex() * 35 + (39 * headerGroupLength)}px` : undefined, bottom: row.getIsPinned() === 'bottom' ? `${((bottomRowLength || 0) - 1 - row.getPinnedIndex()) * 35}px` : undefined }, additionalStyles);
|
|
1585
|
+
return styles;
|
|
1586
|
+
};
|
|
1566
1587
|
|
|
1567
1588
|
const MoreIcon = bundleIcon$1(MoreVerticalFilled, MoreVerticalRegular);
|
|
1568
1589
|
const SortAscIcon = bundleIcon$1(ArrowSortDown20Filled, ArrowSortDown20Regular);
|
|
@@ -1571,24 +1592,24 @@ const PinIcon = bundleIcon$1(PinFilled, PinRegular);
|
|
|
1571
1592
|
const HideColumnIcon = bundleIcon$1(EyeTrackingOffFilled, EyeTrackingOffRegular);
|
|
1572
1593
|
const GroupExpandIcon = bundleIcon$1(TextExpandFilled, TextExpandRegular);
|
|
1573
1594
|
const GroupCollapseIcon = bundleIcon$1(TextCollapseFilled, TextCollapseRegular);
|
|
1574
|
-
function HeaderCell({ header, table,
|
|
1575
|
-
var _a;
|
|
1576
|
-
const { column } = header;
|
|
1595
|
+
function HeaderCell({ header, table, tabAttributes }) {
|
|
1596
|
+
var _a, _b, _c;
|
|
1597
|
+
const { column, id } = header;
|
|
1577
1598
|
const { isDragging, attributes, listeners, setNodeRef, transform, transition, } = useSortable({
|
|
1578
|
-
id:
|
|
1599
|
+
id: id
|
|
1579
1600
|
});
|
|
1580
1601
|
const dndStyle = {
|
|
1581
1602
|
transform: CSS.Translate.toString(transform),
|
|
1582
1603
|
transition
|
|
1583
1604
|
};
|
|
1584
1605
|
const styles = useTableHeaderStyles();
|
|
1585
|
-
const isLeafHeaders =
|
|
1606
|
+
const isLeafHeaders = ((_b = (_a = `${id}`) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b.length) === 1;
|
|
1586
1607
|
const headerCellCombinedStyles = getHeaderCellPinningStyles(column, isDragging, dndStyle);
|
|
1587
1608
|
if (header.isPlaceholder) {
|
|
1588
|
-
return (jsx("th", { colSpan: header.colSpan, className: styles.tHeadCell, style: headerCellCombinedStyles, ref: setNodeRef, children: jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) }));
|
|
1609
|
+
return (jsx("th", Object.assign({ colSpan: header.colSpan, className: styles.tHeadCell, style: headerCellCombinedStyles, ref: setNodeRef }, attributes, listeners, { children: jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) })));
|
|
1589
1610
|
}
|
|
1590
1611
|
const columnName = flexRender(header.column.columnDef.header, header.getContext());
|
|
1591
|
-
return (jsxs("th", { colSpan: header.colSpan, className: mergeClasses$1(styles.tHeadCell, isLeafHeaders && styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging), style: headerCellCombinedStyles, ref: setNodeRef, children: [jsx("div", Object.assign({ className: styles.tHeadCellDraggable }, attributes, listeners, { children: jsxs("div", { className: isLeafHeaders
|
|
1612
|
+
return (jsxs("th", Object.assign({ colSpan: header.colSpan, className: mergeClasses$1(styles.tHeadCell, isLeafHeaders && styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging), style: headerCellCombinedStyles, ref: setNodeRef }, tabAttributes, { tabIndex: 0, children: [jsx("div", Object.assign({ className: mergeClasses$1(styles.tHeadCellDraggable, isDragging && styles.tHeadCellDraggableDragging) }, attributes, listeners, { children: jsxs("div", { className: isLeafHeaders
|
|
1592
1613
|
? styles.tLeafHeadCellContent
|
|
1593
1614
|
: styles.tNonLeafHeadCellContent, children: [jsx("div", { children: jsx(Show, { when: !header.isPlaceholder, children: jsxs(Button, { style: {
|
|
1594
1615
|
display: 'flex',
|
|
@@ -1603,21 +1624,17 @@ function HeaderCell({ header, table, hideMenu, headerDepth, totalNumberOfHeaderD
|
|
|
1603
1624
|
if (!header.column.getCanGroup())
|
|
1604
1625
|
return;
|
|
1605
1626
|
header.column.getToggleGroupingHandler()();
|
|
1606
|
-
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (
|
|
1627
|
+
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_c = {
|
|
1607
1628
|
asc: (jsx("strong", { children: jsx(SortAscIcon, {}) })),
|
|
1608
1629
|
desc: (jsx("strong", { children: jsx(SortDescIcon, {}) })),
|
|
1609
|
-
}[header.column.getIsSorted()]) !== null &&
|
|
1630
|
+
}[header.column.getIsSorted()]) !== null && _c !== void 0 ? _c : undefined, iconPosition: "after", children: [jsx("strong", { children: columnName }), jsx(Show, { when: header.column.getIsGrouped(), children: jsx("strong", { children: jsx(GroupListRegular, {}) }) }), jsx(Show, { when: header.column.getIsFiltered(), children: jsx("strong", { children: jsx(FilterFilled, {}) }) }), jsx(Show, { when: header.column.getIsPinned(), children: jsx("strong", { children: jsx(PinRegular, {}) }) })] }) }) }), jsx(Show, { when: isLeafHeaders, children: jsx(HeaderMenu, { header: header, table: table }) })] }) })), jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsx(Show, { when: !isLeafHeaders, children: jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] })));
|
|
1610
1631
|
}
|
|
1611
1632
|
function HeaderMenu(props) {
|
|
1612
|
-
const { header, table
|
|
1633
|
+
const { header, table } = props;
|
|
1613
1634
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1614
1635
|
const { dispatchDrawerAction, drawerState } = table.options.meta;
|
|
1615
1636
|
const styles = useTableHeaderStyles();
|
|
1616
|
-
|
|
1617
|
-
return (jsx(Fragment, { children: " " }));
|
|
1618
|
-
const canHavePopOver = header.column.getCanSort() ||
|
|
1619
|
-
header.column.getCanGroup() ||
|
|
1620
|
-
header.column.getCanFilter();
|
|
1637
|
+
const canHavePopOver = header.column.getCanSort() || header.column.getCanGroup() || header.column.getCanFilter();
|
|
1621
1638
|
if (!canHavePopOver)
|
|
1622
1639
|
return (jsx(Fragment, { children: " " }));
|
|
1623
1640
|
const columnName = flexRender(header.column.columnDef.header, header.getContext());
|
|
@@ -1664,19 +1681,24 @@ function HeaderMenu(props) {
|
|
|
1664
1681
|
}
|
|
1665
1682
|
|
|
1666
1683
|
function HeaderRow(props) {
|
|
1684
|
+
var _a;
|
|
1667
1685
|
const styles = useTableHeaderStyles();
|
|
1668
|
-
const { table, headerGroup,
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1686
|
+
const { table, headerGroup, headerGroupsLength } = props;
|
|
1687
|
+
const { rowSelectionMode, tableSettings } = (_a = table.options.meta) !== null && _a !== void 0 ? _a : {};
|
|
1688
|
+
const headerCellTabAttributes = useFocusableGroup({ tabBehavior: "limited" });
|
|
1689
|
+
const isLeafHeaders = headerGroup.depth === headerGroupsLength - 1;
|
|
1690
|
+
return (jsxs("tr", { className: styles.tHeadRow, children: [jsx(Show, { when: !(tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.enableManualSelection), children: jsxs(Switch, { when: rowSelectionMode, children: [jsx(Case, { value: "multiple", children: jsx("th", { style: { width: '1rem' }, "aria-label": "Select All Row", children: jsx(Show, { when: isLeafHeaders, children: jsx(Checkbox, { checked: table.getIsSomeRowsSelected()
|
|
1691
|
+
? 'mixed'
|
|
1692
|
+
: table.getIsAllRowsSelected(), onChange: table.getToggleAllRowsSelectedHandler(), "aria-label": "Select All Rows", title: 'Select All Rows' }) }) }) }), jsx(Case, { value: "single", children: jsx("th", { style: { width: '1rem' }, "aria-label": "Select All Row Column", children: ' ' }) })] }) }), jsx(For, { each: headerGroup.headers, children: (header, index) => {
|
|
1693
|
+
return (jsx(HeaderCell, { header: header, table: table, tabAttributes: headerCellTabAttributes }, `${header.id}_${index}`));
|
|
1694
|
+
} })] }, headerGroup.id));
|
|
1674
1695
|
}
|
|
1675
1696
|
|
|
1676
1697
|
function TableHeader(props) {
|
|
1677
1698
|
const styles = useTableHeaderStyles();
|
|
1678
1699
|
const { table, headerGroups, rowSelectionMode } = props;
|
|
1679
|
-
|
|
1700
|
+
const focusAttribute = useFocusableGroup({ tabBehavior: "limited-trap-focus" });
|
|
1701
|
+
return (jsx("thead", Object.assign({ className: styles.tHead, style: { zIndex: 99 } }, focusAttribute, { tabIndex: 0, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsx(HeaderRow, { table: table, rowSelectionMode: rowSelectionMode, headerGroup: headerGroup, headerGroupsLength: headerGroups.length }, headerGroup.id))) })));
|
|
1680
1702
|
}
|
|
1681
1703
|
|
|
1682
1704
|
const useLoadingStyles = makeStyles({
|
|
@@ -1799,31 +1821,51 @@ function TableCell({ cell, row }) {
|
|
|
1799
1821
|
return (jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
1800
1822
|
}
|
|
1801
1823
|
|
|
1802
|
-
|
|
1824
|
+
const PinRowAction = ({ row }) => {
|
|
1825
|
+
const isPinned = row.getIsPinned();
|
|
1826
|
+
return (jsxs(Fragment, { children: [jsx(Show, { when: isPinned, children: jsx(Button, { size: "small", shape: "circular", onClick: () => row.pin(false, true, false), icon: jsx(PinOffRegular, {}) }) }), jsx(Show, { when: !isPinned, children: jsx("div", { children: jsxs(Menu, { children: [jsx(MenuTrigger, { disableButtonEnhancement: true, children: jsx(Button, { icon: jsx(StarRegular, {}), shape: "circular", size: "small" }) }), jsx(MenuPopover, { children: jsxs(MenuList, { children: [jsx(MenuItem, { icon: jsx(SwipeUpFilled, {}), onClick: () => row.pin('top', true, false), children: "Top" }), jsx(MenuItem, { icon: jsx(SwipeDownFilled, {}), onClick: () => row.pin('bottom', true, true), children: "Bottom" })] }) })] }) }) })] }));
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1829
|
+
const SelectRowCheckbox = ({ row }) => {
|
|
1830
|
+
const canCheck = row.getCanSelect();
|
|
1831
|
+
const isChecked = row.getIsSomeSelected() ? 'mixed' : (row.getIsSelected() || row.getIsAllSubRowsSelected());
|
|
1832
|
+
return (jsx(Checkbox, { checked: isChecked, disabled: !canCheck, onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }));
|
|
1833
|
+
};
|
|
1834
|
+
|
|
1835
|
+
const SelectRowRadio = ({ row }) => {
|
|
1836
|
+
const canCheck = row.getCanSelect();
|
|
1837
|
+
const isChecked = row.getIsSelected();
|
|
1838
|
+
return (jsx(Radio, { checked: isChecked, disabled: !canCheck, onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }));
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
function TableRowRaw({ row, table, style, tabAttributes }) {
|
|
1842
|
+
var _a;
|
|
1803
1843
|
const styles = useTableBodyStyles();
|
|
1804
|
-
|
|
1844
|
+
const { rowSelectionMode, tableSettings } = (_a = table.options.meta) !== null && _a !== void 0 ? _a : {};
|
|
1845
|
+
return (jsxs("tr", Object.assign({ className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
1805
1846
|
? styles.tBodySelectedRow
|
|
1806
|
-
: styles.tBodyRow, style: style, children: [jsxs(Switch, { when: rowSelectionMode, children: [jsx(Case, { value: 'multiple', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row
|
|
1807
|
-
? 'mixed'
|
|
1808
|
-
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) }), jsx(Case, { value: 'single', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(Radio, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) })] }), row.getVisibleCells().map((cell) => (jsx(TableCell, { cell: cell, row: row }, cell.id)))] }, row.id));
|
|
1847
|
+
: styles.tBodyRow, style: style }, tabAttributes, { tabIndex: 0, children: [jsx(Show, { when: !(tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.enableManualSelection), children: jsxs(Switch, { when: rowSelectionMode, children: [jsx(Case, { value: 'multiple', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row", children: jsx(SelectRowCheckbox, { row: row }) }) }), jsx(Case, { value: 'single', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row", children: jsx(SelectRowRadio, { row: row }) }) })] }) }), row.getVisibleCells().map((cell) => (jsx(TableCell, { cell: cell, row: row }, cell.id)))] }), row.id));
|
|
1809
1848
|
}
|
|
1810
|
-
function
|
|
1849
|
+
function PinnedRowRaw({ row, table, style, bottomRowLength, tabAttributes }) {
|
|
1850
|
+
var _a;
|
|
1811
1851
|
const styles = useTableBodyStyles();
|
|
1812
|
-
const
|
|
1813
|
-
|
|
1852
|
+
const headerGroupLength = table.getHeaderGroups().length;
|
|
1853
|
+
const pinnedRowRawStyle = getRowPinningStyles(row, bottomRowLength || 0, headerGroupLength, style || {});
|
|
1854
|
+
const { rowSelectionMode, tableSettings } = (_a = table.options.meta) !== null && _a !== void 0 ? _a : {};
|
|
1855
|
+
return (jsxs("tr", Object.assign({ className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
1814
1856
|
? styles.tBodySelectedRow
|
|
1815
|
-
: styles.tBodyRow, style: pinnedRowRawStyle, children: [jsxs(Switch, { when: rowSelectionMode, children: [jsx(Case, { value: 'multiple', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(
|
|
1816
|
-
? 'mixed'
|
|
1817
|
-
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) }), jsx(Case, { value: 'single', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(Radio, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) })] }), row.getVisibleCells().map(cell => {
|
|
1857
|
+
: styles.tBodyRow, style: pinnedRowRawStyle }, tabAttributes, { tabIndex: 0, children: [jsx(Show, { when: !(tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.enableManualSelection), children: jsxs(Switch, { when: rowSelectionMode, children: [jsx(Case, { value: 'multiple', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(SelectRowCheckbox, { row: row }) }) }), jsx(Case, { value: 'single', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(SelectRowRadio, { row: row }) }) })] }) }), row.getVisibleCells().map(cell => {
|
|
1818
1858
|
return (jsx(TableCell, { cell: cell, row: row }, cell.id));
|
|
1819
|
-
})] }, row.id));
|
|
1859
|
+
})] }), row.id));
|
|
1820
1860
|
}
|
|
1861
|
+
const TableRow = TableRowRaw;
|
|
1862
|
+
const PinnedRow = PinnedRowRaw;
|
|
1821
1863
|
|
|
1822
1864
|
function TableBody(props) {
|
|
1823
1865
|
var _a, _b, _c;
|
|
1824
1866
|
const styles = useTableBodyStyles();
|
|
1825
1867
|
const { table, tableContainerRef } = props;
|
|
1826
|
-
const rowSelectionMode = (_a = table.options.meta)
|
|
1868
|
+
const { rowSelectionMode } = (_a = table.options.meta) !== null && _a !== void 0 ? _a : {};
|
|
1827
1869
|
let rows = [];
|
|
1828
1870
|
let topRows = [];
|
|
1829
1871
|
let bottomRows = [];
|
|
@@ -1847,13 +1889,14 @@ function TableBody(props) {
|
|
|
1847
1889
|
const paddingBottom = virtualRows.length > 0
|
|
1848
1890
|
? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
|
|
1849
1891
|
: 0;
|
|
1892
|
+
const tabAttributes = useFocusableGroup({ tabBehavior: "limited" });
|
|
1850
1893
|
return (jsxs(Fragment, { children: [jsx(Show, { when: (topRows === null || topRows === void 0 ? void 0 : topRows.length) > 0, children: jsx("thead", { style: {
|
|
1851
1894
|
position: "sticky",
|
|
1852
1895
|
top: 0,
|
|
1853
1896
|
zIndex: 9
|
|
1854
|
-
}, children: jsx(For, { each: topRows, children: (row, index) => (jsx(PinnedRow, { row: row,
|
|
1897
|
+
}, children: jsx(For, { each: topRows, children: (row, index) => (jsx(PinnedRow, { row: row, table: table, bottomRowLength: bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length, tabAttributes: tabAttributes }, `${row.id}_${index}`)) }) }) }), jsxs("tbody", { className: styles.tBody, children: [paddingTop > 0 && (jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsx("td", { style: { height: `${paddingTop}px` } }) })), jsx(For, { each: virtualRows || [], children: (virtualRow) => {
|
|
1855
1898
|
const row = rows[virtualRow.index];
|
|
1856
|
-
return (jsx(TableRow, { row: row,
|
|
1899
|
+
return (jsx(TableRow, { row: row, table: table, tabAttributes: tabAttributes }, row.id));
|
|
1857
1900
|
} }), paddingBottom > 0 && (jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsx("td", { style: { height: `${paddingBottom}px` } }) }))] }), jsx(Show, { when: rowSelectionMode === 'multiple' && (rows === null || rows === void 0 ? void 0 : rows.length) > 0, children: jsx("tfoot", { style: {
|
|
1858
1901
|
position: "sticky",
|
|
1859
1902
|
bottom: 0,
|
|
@@ -1864,7 +1907,7 @@ function TableBody(props) {
|
|
|
1864
1907
|
position: "sticky",
|
|
1865
1908
|
bottom: 0,
|
|
1866
1909
|
zIndex: 9
|
|
1867
|
-
}, children: jsx(For, { each: bottomRows, children: (row) => (jsx(PinnedRow, { row: row,
|
|
1910
|
+
}, children: jsx(For, { each: bottomRows, children: (row) => (jsx(PinnedRow, { row: row, table: table, bottomRowLength: bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length, tabAttributes: tabAttributes }, row.id)) }) }) })] }));
|
|
1868
1911
|
}
|
|
1869
1912
|
|
|
1870
1913
|
const TableContainer = (props) => {
|
|
@@ -2357,4 +2400,4 @@ function useSkipper() {
|
|
|
2357
2400
|
return [shouldSkip, skip];
|
|
2358
2401
|
}
|
|
2359
2402
|
|
|
2360
|
-
export { ForwardedAdvancedTable as Table, useSkipper };
|
|
2403
|
+
export { PinRowAction, SelectRowCheckbox, SelectRowRadio, ForwardedAdvancedTable as Table, disableAllShorthand, useSkipper };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prt-ts/fluent-react-table-v2",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.47.1-build-2.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=17.0.0",
|
|
6
6
|
"react-dom": ">=17.0.0",
|
|
7
|
-
"@fluentui/react-components": ">=9.
|
|
7
|
+
"@fluentui/react-components": ">=9.47.1",
|
|
8
8
|
"@fluentui/react-datepicker-compat": ">=0.4.5"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Row, RowData } from "@tanstack/react-table";
|
|
2
|
+
type PinRowActionProps<TData extends RowData> = {
|
|
3
|
+
row: Row<TData>;
|
|
4
|
+
};
|
|
5
|
+
export declare const PinRowAction: <TData extends unknown>({ row }: PinRowActionProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Row, RowData } from "@tanstack/react-table";
|
|
2
|
+
type SelectRowCheckboxProps<TData extends RowData> = {
|
|
3
|
+
row: Row<TData>;
|
|
4
|
+
};
|
|
5
|
+
export declare const SelectRowCheckbox: <TData extends unknown>({ row }: SelectRowCheckboxProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Row, RowData } from "@tanstack/react-table";
|
|
2
|
+
type SelectRowRadioProps<TData extends RowData> = {
|
|
3
|
+
row: Row<TData>;
|
|
4
|
+
};
|
|
5
|
+
export declare const SelectRowRadio: <TData extends unknown>({ row }: SelectRowRadioProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Column, Table } from '@tanstack/react-table';
|
|
2
|
-
export declare const FilterMultiSelectCheckbox: <TItem extends
|
|
2
|
+
export declare const FilterMultiSelectCheckbox: <TItem extends unknown>({ column, table, }: {
|
|
3
3
|
column: Column<TItem, unknown>;
|
|
4
4
|
table: Table<TItem>;
|
|
5
5
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Column, Table } from "@tanstack/react-table";
|
|
2
|
-
export declare const FilterSelectRadio: <TItem extends
|
|
2
|
+
export declare const FilterSelectRadio: <TItem extends unknown>({ column, table, }: {
|
|
3
3
|
column: Column<TItem, unknown>;
|
|
4
4
|
table: Table<TItem>;
|
|
5
5
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Row, RowData } from '@tanstack/react-table';
|
|
3
|
-
import { TableProps } from '../../types';
|
|
2
|
+
import { Row, RowData, Table } from '@tanstack/react-table';
|
|
4
3
|
type TableRowProps<TItem extends RowData> = {
|
|
4
|
+
table: Table<TItem>;
|
|
5
5
|
row: Row<TItem>;
|
|
6
|
-
rowSelectionMode?: TableProps<TItem>['rowSelectionMode'];
|
|
7
6
|
bottomRowLength?: number;
|
|
8
7
|
style?: React.CSSProperties;
|
|
8
|
+
tabAttributes: any;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
declare function TableRowRaw<TItem extends RowData>({ row, table, style, tabAttributes }: TableRowProps<TItem>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare function PinnedRowRaw<TItem extends RowData>({ row, table, style, bottomRowLength, tabAttributes }: TableRowProps<TItem>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const TableRow: typeof TableRowRaw;
|
|
13
|
+
export declare const PinnedRow: typeof PinnedRowRaw;
|
|
12
14
|
export {};
|
|
@@ -2,9 +2,7 @@ import { Header, RowData, Table } from "@tanstack/react-table";
|
|
|
2
2
|
type HeaderCellProps<TItem extends RowData> = {
|
|
3
3
|
header: Header<TItem, unknown>;
|
|
4
4
|
table: Table<TItem>;
|
|
5
|
-
|
|
6
|
-
headerDepth: number;
|
|
7
|
-
totalNumberOfHeaderDepth: number;
|
|
5
|
+
tabAttributes: any;
|
|
8
6
|
};
|
|
9
|
-
export declare function HeaderCell<TItem extends RowData>({ header, table,
|
|
7
|
+
export declare function HeaderCell<TItem extends RowData>({ header, table, tabAttributes }: HeaderCellProps<TItem>): import("react/jsx-runtime").JSX.Element;
|
|
10
8
|
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { HeaderGroup, RowData, Table } from '@tanstack/react-table';
|
|
2
|
-
import { TableProps } from '../../types';
|
|
3
2
|
type HeaderRowProps<TItem extends RowData> = {
|
|
4
3
|
table: Table<TItem>;
|
|
5
|
-
rowSelectionMode?: TableProps<TItem>['rowSelectionMode'];
|
|
6
4
|
headerGroup: HeaderGroup<TItem>;
|
|
7
5
|
headerGroupsLength: number;
|
|
8
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useTableHeaderStyles: () => Record<"tHead" | "tHeadRow" | "tHeadCell" | "tHeadNonLeafCell" | "tHeadNonLeafCellFakeBorder" | "tHeadCellDraggable" | "tHeadCellDragging" | "tHeadCellOver" | "tLeafHeadCellContent" | "tNonLeafHeadCellContent" | "tHeadContentBtn" | "tHeadMenuPopover" | "resizer" | "resizerActive", string>;
|
|
1
|
+
export declare const useTableHeaderStyles: () => Record<"tHead" | "tHeadRow" | "tHeadCell" | "tHeadNonLeafCell" | "tHeadNonLeafCellFakeBorder" | "tHeadCellDraggable" | "tHeadCellDraggableDragging" | "tHeadCellDragging" | "tHeadCellOver" | "tLeafHeadCellContent" | "tNonLeafHeadCellContent" | "tHeadContentBtn" | "tHeadMenuPopover" | "resizer" | "resizerActive", string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const disableAllShorthand: {
|
|
2
|
+
enableGrouping: boolean;
|
|
3
|
+
enableHiding: boolean;
|
|
4
|
+
enablePinning: boolean;
|
|
5
|
+
enableSorting: boolean;
|
|
6
|
+
enableColumnFilter: boolean;
|
|
7
|
+
enableGlobalFilter: boolean;
|
|
8
|
+
enableMultiSort: boolean;
|
|
9
|
+
enableResizing: boolean;
|
|
10
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Column } from "@tanstack/react-table";
|
|
1
|
+
import { Column, Row } from "@tanstack/react-table";
|
|
2
2
|
import { CSSProperties } from "react";
|
|
3
3
|
export declare const getHeaderCellPinningStyles: <TItem extends unknown>(column: Column<TItem, unknown>, isDragging: boolean, additionalStyles: CSSProperties) => CSSProperties;
|
|
4
4
|
export declare const getBodyCellPinningStyles: <TItem extends unknown>(column: Column<TItem, unknown>, isDragging: boolean, additionalStyles: CSSProperties) => CSSProperties;
|
|
5
|
+
export declare const getRowPinningStyles: <TItem extends unknown>(row: Row<TItem>, bottomRowLength: number, headerGroupLength: number, additionalStyles: CSSProperties) => CSSProperties;
|
package/src/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingState, ExpandedState, FilterFn, GroupingState, PaginationState, RowData, RowPinningState, RowSelectionState, SortingState, VisibilityState } from "@tanstack/react-table";
|
|
3
|
-
import { TableProps } from "./types";
|
|
3
|
+
import { TableProps, TableSettings } from "./types";
|
|
4
4
|
import { ActionType, DrawerTableState } from "./components/reducer";
|
|
5
|
+
export { disableAllShorthand } from "./helpers/Shorthands";
|
|
6
|
+
export { Table, useSkipper } from "./components";
|
|
7
|
+
export * from "./components/extensions";
|
|
5
8
|
declare module '@tanstack/table-core' {
|
|
6
9
|
interface FilterFns {
|
|
7
10
|
arrIncludesSome: FilterFn<unknown>;
|
|
@@ -37,9 +40,9 @@ declare module '@tanstack/react-table' {
|
|
|
37
40
|
setColumnPinning: React.Dispatch<React.SetStateAction<ColumnPinningState>>;
|
|
38
41
|
setColumnSizing: React.Dispatch<React.SetStateAction<ColumnSizingState>>;
|
|
39
42
|
setRowPinning: React.Dispatch<React.SetStateAction<RowPinningState>>;
|
|
43
|
+
tableSettings: TableSettings;
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
|
-
export { Table, useSkipper } from "./components";
|
|
43
46
|
export type { TableProps, TableRef, TableView } from "./types";
|
|
44
47
|
export type { TableState, ColumnDef, Column as ColumnType, Row as RowType, RowData as RowDataType, Table as TableType } from '@tanstack/react-table';
|
|
45
48
|
export { createColumnHelper } from "@tanstack/react-table";
|
|
@@ -113,4 +113,11 @@ export type TableProps<TItem extends RowData> = {
|
|
|
113
113
|
* disable table header
|
|
114
114
|
*/
|
|
115
115
|
disableTableHeader?: boolean;
|
|
116
|
+
tableSettings?: TableSettings;
|
|
117
|
+
};
|
|
118
|
+
export type TableSettings = {
|
|
119
|
+
/**
|
|
120
|
+
* Enable manual selection of table view
|
|
121
|
+
*/
|
|
122
|
+
enableManualSelection?: boolean;
|
|
116
123
|
};
|