@economic/taco 2.9.2 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/IconButton/IconButton.d.ts +2 -2
- package/dist/components/Provider/Localization.d.ts +6 -0
- package/dist/components/Table3/components/columns/header/Header.d.ts +6 -1
- package/dist/components/Table3/components/columns/header/Menu.d.ts +4 -0
- package/dist/components/Table3/hooks/features/useCurrentRow.d.ts +4 -3
- package/dist/components/Table3/hooks/useCssVars.d.ts +2 -1
- package/dist/components/Table3/hooks/useTable.d.ts +1 -0
- package/dist/components/Table3/types.d.ts +7 -0
- package/dist/esm/index.css +92 -16
- package/dist/esm/packages/taco/src/components/Button/util.js +5 -1
- package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Content.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +7 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +11 -4
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +3 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +5 -3
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +5 -3
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js +0 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js +30 -6
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +36 -10
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +3 -3
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Drag.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Drag.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Expansion.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Expansion.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +100 -44
- package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +10 -0
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js +15 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js +5 -2
- package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js +2 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js +8 -4
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +2 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js +15 -2
- package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
- package/dist/index.css +92 -16
- package/dist/taco.cjs.development.js +270 -97
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
- package/types.json +5803 -5242
@@ -4024,10 +4024,14 @@ const getAppearanceClasses = (value, icon = false) => {
|
|
4024
4024
|
case 'discrete':
|
4025
4025
|
{
|
4026
4026
|
if (icon) {
|
4027
|
-
return `bg-transparent text-black enabled:hover:bg-
|
4027
|
+
return `bg-transparent text-black enabled:hover:bg-[#000]/[0.08] disabled:text-black/30`;
|
4028
4028
|
}
|
4029
4029
|
return `bg-transparent text-blue-500 enabled:hover:text-blue-700 disabled:text-blue-500/50`;
|
4030
4030
|
}
|
4031
|
+
case 'transparent':
|
4032
|
+
{
|
4033
|
+
return `bg-transparent text-black enabled:hover:text-black enabled:hover:bg-[#000]/[0.08] disabled:text-black/30`;
|
4034
|
+
}
|
4031
4035
|
default:
|
4032
4036
|
return `wcag-grey-200 enabled:hover:wcag-grey-300 disabled:bg-grey-200/50 disabled:text-black/30`;
|
4033
4037
|
}
|
@@ -4321,7 +4325,13 @@ const defaultLocalisationTexts = {
|
|
4321
4325
|
freezeColumns: (count = 1) => count === 1 ? 'Freeze the first column' : `Freeze first ${count} columns`,
|
4322
4326
|
gotoRow: 'Go to',
|
4323
4327
|
hideColumn: 'Hide column',
|
4324
|
-
unfreezeColumns: 'Unfreeze all columns'
|
4328
|
+
unfreezeColumns: 'Unfreeze all columns',
|
4329
|
+
sorting: 'Sorting',
|
4330
|
+
sortingOrder: {
|
4331
|
+
ascending: 'Ascending order',
|
4332
|
+
descending: 'Descending order',
|
4333
|
+
unsorted: 'No sorting'
|
4334
|
+
}
|
4325
4335
|
},
|
4326
4336
|
resize: {
|
4327
4337
|
tooltip: 'Resize column'
|
@@ -7474,7 +7484,7 @@ const Content$8 = /*#__PURE__*/React.forwardRef(function MenuContent(props, ref)
|
|
7474
7484
|
return () => {
|
7475
7485
|
shortcuts.forEach(handler => document.removeEventListener('keydown', handler));
|
7476
7486
|
};
|
7477
|
-
}, []);
|
7487
|
+
}, [childrenWithRefs]);
|
7478
7488
|
return /*#__PURE__*/React.createElement(DropdownMenuPrimitive.Portal, null, /*#__PURE__*/React.createElement(DropdownMenuPrimitive.Content, Object.assign({}, otherProps, {
|
7479
7489
|
align: align,
|
7480
7490
|
className: className,
|
@@ -15933,11 +15943,14 @@ function Menu$3(props) {
|
|
15933
15943
|
const {
|
15934
15944
|
canFreeze,
|
15935
15945
|
canHide,
|
15946
|
+
canSort,
|
15936
15947
|
index,
|
15937
15948
|
menu,
|
15938
15949
|
onGoto: handleGoto,
|
15939
15950
|
onHide: handleHide,
|
15951
|
+
onSortToggle: handleSortToggle,
|
15940
15952
|
scrollToIndex,
|
15953
|
+
sortDirection,
|
15941
15954
|
table
|
15942
15955
|
} = props;
|
15943
15956
|
const tableMeta = table.options.meta;
|
@@ -15945,6 +15958,11 @@ function Menu$3(props) {
|
|
15945
15958
|
texts
|
15946
15959
|
} = useLocalization();
|
15947
15960
|
const [popover, setPopover] = React__default.useState(undefined);
|
15961
|
+
const [sortDirectionState, setSortDirectionState] = React__default.useState(sortDirection);
|
15962
|
+
const handleSortMenuRadioGroupChange = newSortDirection => {
|
15963
|
+
setSortDirectionState(newSortDirection);
|
15964
|
+
handleSortToggle(newSortDirection);
|
15965
|
+
};
|
15948
15966
|
let popoverElement;
|
15949
15967
|
if (popover) {
|
15950
15968
|
const handleClosePopover = () => setPopover(undefined);
|
@@ -15982,18 +16000,11 @@ function Menu$3(props) {
|
|
15982
16000
|
}
|
15983
16001
|
}
|
15984
16002
|
}
|
15985
|
-
const className = cn('-my-0.5 -mr-1 -ml-0.5 !h-6 !min-h-[theme(spacing.6)] !w-
|
15986
|
-
'!
|
16003
|
+
const className = cn('-my-0.5 -mr-1 -ml-0.5 !h-6 !min-h-[theme(spacing.6)] flex-shrink-0 justify-end !w-0 !min-w-0 !overflow-hidden', 'aria-expanded:!min-w-[theme(spacing.6)] aria-expanded:!w-6 aria-expanded:!overflow-auto', 'focus:!min-w-[theme(spacing.6)] focus:!w-6 focus:!overflow-auto', 'group-hover/column:!min-w-[theme(spacing.6)] group-hover/column:!w-6 group-hover/column:!overflow-auto', {
|
16004
|
+
'!w-6 !min-w-[theme(spacing.6)] !overflow-auto': !!popoverElement
|
15987
16005
|
}, props.className);
|
15988
16006
|
const memoedMenuItems = React__default.useMemo(() => {
|
15989
16007
|
const menuItems = [];
|
15990
|
-
if (handleGoto) {
|
15991
|
-
menuItems.push( /*#__PURE__*/React__default.createElement(Menu$1.Item, {
|
15992
|
-
icon: "move",
|
15993
|
-
onClick: () => setPopover('goto'),
|
15994
|
-
shortcut: "g"
|
15995
|
-
}, texts.table3.columns.menu.gotoRow, "..."));
|
15996
|
-
}
|
15997
16008
|
if (canHide) {
|
15998
16009
|
// we do this in the next tick, otherwise the menu closes and react throws a "state update on unmounted component" error
|
15999
16010
|
const handleClick = event => setTimeout(() => handleHide(event), 1);
|
@@ -16002,6 +16013,30 @@ function Menu$3(props) {
|
|
16002
16013
|
onClick: handleClick
|
16003
16014
|
}, texts.table3.columns.menu.hideColumn));
|
16004
16015
|
}
|
16016
|
+
// We rely on canSort value instead of onSort function's value because some columns might have sorting disabled,
|
16017
|
+
// so even though onSort is truthy, we don't want to show sorting menu.
|
16018
|
+
if (canSort) {
|
16019
|
+
menuItems.push( /*#__PURE__*/React__default.createElement(Menu$1.Item, {
|
16020
|
+
icon: "sort-by",
|
16021
|
+
subMenu: () => /*#__PURE__*/React__default.createElement(Menu$1.SubMenu, null, /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup, {
|
16022
|
+
onChange: handleSortMenuRadioGroupChange,
|
16023
|
+
value: sortDirectionState
|
16024
|
+
}, /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
|
16025
|
+
value: SORT_DIRECTION.ASC
|
16026
|
+
}, texts.table3.columns.menu.sortingOrder.ascending), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
|
16027
|
+
value: SORT_DIRECTION.DESC
|
16028
|
+
}, texts.table3.columns.menu.sortingOrder.descending), /*#__PURE__*/React__default.createElement(Menu$1.RadioGroup.Item, {
|
16029
|
+
value: false
|
16030
|
+
}, texts.table3.columns.menu.sortingOrder.unsorted)))
|
16031
|
+
}, texts.table3.columns.menu.sorting));
|
16032
|
+
}
|
16033
|
+
if (handleGoto) {
|
16034
|
+
menuItems.push( /*#__PURE__*/React__default.createElement(Menu$1.Item, {
|
16035
|
+
icon: "move",
|
16036
|
+
onClick: () => setPopover('goto'),
|
16037
|
+
shortcut: "g"
|
16038
|
+
}, texts.table3.columns.menu.gotoRow, "..."));
|
16039
|
+
}
|
16005
16040
|
if (canFreeze) {
|
16006
16041
|
const frozenIndex = index - tableMeta.columnFreezing.frozenInternalColumnCount;
|
16007
16042
|
const handleClick = () => tableMeta.columnFreezing.setFrozenColumnIndex(frozenIndex);
|
@@ -16034,7 +16069,7 @@ function Menu$3(props) {
|
|
16034
16069
|
return menuItems.map((item, key) => /*#__PURE__*/React__default.cloneElement(item, {
|
16035
16070
|
key
|
16036
16071
|
}));
|
16037
|
-
}, [menu, index, canFreeze, canHide, handleGoto, tableMeta.columnFreezing.frozenColumnIndex]);
|
16072
|
+
}, [menu, index, canFreeze, canHide, canSort, handleGoto, handleSortToggle, sortDirection, tableMeta.columnFreezing.frozenColumnIndex]);
|
16038
16073
|
return /*#__PURE__*/React__default.createElement(IconButton, {
|
16039
16074
|
className: className,
|
16040
16075
|
icon: "more",
|
@@ -16112,6 +16147,10 @@ function getSortAttributes(toggleSorting, sortDirection) {
|
|
16112
16147
|
};
|
16113
16148
|
}
|
16114
16149
|
|
16150
|
+
const SORT_DIRECTION = {
|
16151
|
+
ASC: 'asc',
|
16152
|
+
DESC: 'desc'
|
16153
|
+
};
|
16115
16154
|
function Header$2(props) {
|
16116
16155
|
const {
|
16117
16156
|
children,
|
@@ -16123,11 +16162,19 @@ function Header$2(props) {
|
|
16123
16162
|
const tableMeta = table.options.meta;
|
16124
16163
|
const columnMeta = React__default.useMemo(() => column.columnDef.meta, []);
|
16125
16164
|
const canSort = column.getCanSort();
|
16165
|
+
const hasGoto = isGotoAvailable(table, header);
|
16126
16166
|
// passing header or column results in re-renders on scroll, so anything from those objects as memoed props
|
16167
|
+
const handleHide = React__default.useMemo(() => header.column.getToggleVisibilityHandler(), []);
|
16127
16168
|
const handleResize = React__default.useMemo(() => header.getResizeHandler(), []);
|
16128
16169
|
const handleSort = React__default.useMemo(() => header.column.getToggleSortingHandler(), []);
|
16129
|
-
const
|
16130
|
-
|
16170
|
+
const handleSortToggle = React__default.useCallback(sortDirection => {
|
16171
|
+
// When sorting is not applied, sortDirection is false.
|
16172
|
+
if (sortDirection === false) {
|
16173
|
+
header.column.clearSorting();
|
16174
|
+
} else {
|
16175
|
+
header.column.toggleSorting(sortDirection === SORT_DIRECTION.DESC);
|
16176
|
+
}
|
16177
|
+
}, []);
|
16131
16178
|
const sorting = table.getState().sorting;
|
16132
16179
|
const filters = table.getState().columnFilters;
|
16133
16180
|
const search = table.getState().globalFilter;
|
@@ -16148,6 +16195,7 @@ function Header$2(props) {
|
|
16148
16195
|
id: header.id,
|
16149
16196
|
index: header.index,
|
16150
16197
|
isFrozen: isFrozenColumn(header, table),
|
16198
|
+
isPrinting: tableMeta.isPrinting,
|
16151
16199
|
isResizing: column.getIsResizing(),
|
16152
16200
|
length: table.getRowModel().rows.length,
|
16153
16201
|
meta: columnMeta,
|
@@ -16155,6 +16203,7 @@ function Header$2(props) {
|
|
16155
16203
|
onHide: handleHide,
|
16156
16204
|
onResize: handleResize,
|
16157
16205
|
onSort: handleSort,
|
16206
|
+
onSortToggle: handleSortToggle,
|
16158
16207
|
scrollToIndex,
|
16159
16208
|
sortDirection: column.getIsSorted(),
|
16160
16209
|
table
|
@@ -16174,6 +16223,7 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
|
|
16174
16223
|
id,
|
16175
16224
|
index,
|
16176
16225
|
isFrozen,
|
16226
|
+
isPrinting,
|
16177
16227
|
isResizing,
|
16178
16228
|
length,
|
16179
16229
|
meta,
|
@@ -16181,13 +16231,17 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
|
|
16181
16231
|
onHide: handleHide,
|
16182
16232
|
onResize: handleResize,
|
16183
16233
|
onSort: handleSort,
|
16234
|
+
onSortToggle: handleSortToggle,
|
16184
16235
|
scrollToIndex,
|
16185
16236
|
sortDirection,
|
16186
16237
|
table
|
16187
16238
|
} = props;
|
16188
|
-
const className = cn('sticky top-0 border-b-2 font-bold
|
16239
|
+
const className = cn('sticky top-0 border-b-2 font-bold box-content group/column relative', '[[role="table"][data-resizing="true"]_&]:pointer-events-none', 'px-[var(--table3-cell-padding-x)]', {
|
16240
|
+
'h-10 items-center': !isPrinting,
|
16241
|
+
'pb-2': isPrinting,
|
16189
16242
|
'cursor-pointer select-none': canSort,
|
16190
16243
|
'hover:bg-grey-100': canSort || canResize || hasMenu,
|
16244
|
+
'focus-within:bg-grey-100': hasMenu,
|
16191
16245
|
'!pointer-events-all !bg-grey-100': isResizing,
|
16192
16246
|
// z-indexes
|
16193
16247
|
'z-10 hover:z-20': !isFrozen && !isResizing,
|
@@ -16221,13 +16275,16 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
|
|
16221
16275
|
title: String((_meta$tooltip = meta === null || meta === void 0 ? void 0 : meta.tooltip) !== null && _meta$tooltip !== void 0 ? _meta$tooltip : children),
|
16222
16276
|
placement: "top"
|
16223
16277
|
}, /*#__PURE__*/React__default.createElement("span", {
|
16224
|
-
className:
|
16278
|
+
className: cn({
|
16279
|
+
truncate: !isPrinting
|
16280
|
+
})
|
16225
16281
|
}, children)), canSort ? /*#__PURE__*/React__default.createElement(SortIndicator, {
|
16226
16282
|
direction: sortDirection
|
16227
16283
|
}) : null, hasMenu ? /*#__PURE__*/React__default.createElement(Menu$3, {
|
16228
16284
|
canFreeze: canFreeze,
|
16229
16285
|
canHide: canHide,
|
16230
|
-
|
16286
|
+
canSort: canSort,
|
16287
|
+
className: cn({
|
16231
16288
|
'ml-auto': align !== 'right',
|
16232
16289
|
'ml-2': align === 'right'
|
16233
16290
|
}),
|
@@ -16235,7 +16292,9 @@ const MemoedHeader = /*#__PURE__*/React__default.memo(function MemoedHeader(prop
|
|
16235
16292
|
menu: meta.menu,
|
16236
16293
|
onGoto: handleGoto,
|
16237
16294
|
onHide: handleHide,
|
16295
|
+
onSortToggle: handleSortToggle,
|
16238
16296
|
scrollToIndex: scrollToIndex,
|
16297
|
+
sortDirection: sortDirection,
|
16239
16298
|
table: table
|
16240
16299
|
}) : null, canResize ? /*#__PURE__*/React__default.createElement(Resizer, {
|
16241
16300
|
isResizing: isResizing,
|
@@ -16328,7 +16387,7 @@ const MemoedDisplayCell = /*#__PURE__*/React__default.memo(function MemoedDispla
|
|
16328
16387
|
index,
|
16329
16388
|
tableRef
|
16330
16389
|
} = props;
|
16331
|
-
const layoutClassName = cn('py-[var(--table3-
|
16390
|
+
const layoutClassName = cn('py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none', customClassName);
|
16332
16391
|
const className = highlighted ? undefined : layoutClassName;
|
16333
16392
|
const content = enableTruncate ? /*#__PURE__*/React__default.createElement("span", {
|
16334
16393
|
className: "truncate"
|
@@ -16341,7 +16400,9 @@ const MemoedDisplayCell = /*#__PURE__*/React__default.memo(function MemoedDispla
|
|
16341
16400
|
"data-align": align,
|
16342
16401
|
"data-column-index": index,
|
16343
16402
|
"data-highlighted": highlighted,
|
16344
|
-
role: "cell"
|
16403
|
+
role: "cell",
|
16404
|
+
// cells must be focusable (but not included in tabbing - hence -1)
|
16405
|
+
tabIndex: -1
|
16345
16406
|
}, highlighted ? /*#__PURE__*/React__default.createElement(Highlight, {
|
16346
16407
|
className: layoutClassName,
|
16347
16408
|
current: highlightedAsCurrent,
|
@@ -16359,7 +16420,7 @@ const Highlight = props => {
|
|
16359
16420
|
...attributes
|
16360
16421
|
} = props;
|
16361
16422
|
const ref = React__default.useRef(null);
|
16362
|
-
const className = cn('h-full flex
|
16423
|
+
const className = cn('h-full flex [justify-content:inherit] [text-align:inherit]', props.className, {
|
16363
16424
|
// normal row
|
16364
16425
|
'bg-blue-200/25': !current,
|
16365
16426
|
// current row
|
@@ -16472,7 +16533,7 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
|
|
16472
16533
|
var _ref, _button$props$tooltip;
|
16473
16534
|
const tooltip = String((_ref = (_button$props$tooltip = button.props.tooltip) !== null && _button$props$tooltip !== void 0 ? _button$props$tooltip : button.props['aria-label']) !== null && _ref !== void 0 ? _ref : '');
|
16474
16535
|
return /*#__PURE__*/React__default.cloneElement(button, {
|
16475
|
-
appearance: '
|
16536
|
+
appearance: 'transparent',
|
16476
16537
|
key: index,
|
16477
16538
|
tabIndex: isCurrentRow ? 0 : -1,
|
16478
16539
|
tooltip: button.props.shortcut ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, tooltip, /*#__PURE__*/React__default.createElement(Shortcut, {
|
@@ -16481,7 +16542,7 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
|
|
16481
16542
|
})) : tooltip
|
16482
16543
|
});
|
16483
16544
|
}), actionsInMenu.length ? /*#__PURE__*/React__default.createElement(IconButton, {
|
16484
|
-
appearance: "
|
16545
|
+
appearance: "transparent",
|
16485
16546
|
"aria-label": texts.table3.columns.actions.tooltip,
|
16486
16547
|
icon: "more",
|
16487
16548
|
tabIndex: isCurrentRow ? 0 : -1,
|
@@ -16517,7 +16578,7 @@ function createRowActionsColumn$1() {
|
|
16517
16578
|
footer: Footer$4,
|
16518
16579
|
meta: {
|
16519
16580
|
align: 'right',
|
16520
|
-
className: cn('!pt-[var(--table3-
|
16581
|
+
className: cn('!pt-[var(--table3-cell-padding-y)] print:opacity-0 [[role="table"][data-editing="false"]_&]:group-[[data-current="true"]]/row:sticky [[role="table"][data-pause-hover="false"][data-editing="false"]_&]:group-hover/row:sticky right-0 !pl-1 !pr-1', 'shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]', 'group-[[data-current="true"][data-selected="false"]]/row:text-grey-200', 'group-[[data-selected="true"]]/row:text-blue-100', 'group-[[data-selected="false"]:hover]/row:text-grey-100'),
|
16521
16582
|
enableOrdering: false,
|
16522
16583
|
enableSearch: false,
|
16523
16584
|
enableTruncate: false,
|
@@ -16652,7 +16713,7 @@ const useCssGrid = (table, isPrintTable = false) => {
|
|
16652
16713
|
};
|
16653
16714
|
};
|
16654
16715
|
|
16655
|
-
function useCurrentRow(defaultCurrentRowIndex
|
16716
|
+
function useCurrentRow(defaultCurrentRowIndex) {
|
16656
16717
|
const [currentRowIndex, setCurrentRowIndex] = React__default.useState(defaultCurrentRowIndex);
|
16657
16718
|
const move = (direction, length, scrollToIndex) => setCurrentRowIndex(currentIndex => {
|
16658
16719
|
const nextIndex = currentIndex !== undefined ? getNextIndex$2(direction, currentIndex, length) : 0;
|
@@ -16687,9 +16748,23 @@ function useCurrentRow(defaultCurrentRowIndex = 0) {
|
|
16687
16748
|
return;
|
16688
16749
|
}
|
16689
16750
|
}, []);
|
16751
|
+
const onFocus = React__default.useCallback((event, length, scrollToIndex) => {
|
16752
|
+
if (event.isDefaultPrevented()) {
|
16753
|
+
return;
|
16754
|
+
}
|
16755
|
+
if (currentRowIndex === undefined && length > 0) {
|
16756
|
+
// do it in the next tick, otherwise it prevents internal focus from working
|
16757
|
+
// meaning you have to tab twice to get to the first focusable element
|
16758
|
+
setTimeout(() => {
|
16759
|
+
setCurrentRowIndex(0);
|
16760
|
+
scrollToIndex(0);
|
16761
|
+
}, 1);
|
16762
|
+
}
|
16763
|
+
}, [currentRowIndex, length]);
|
16690
16764
|
return {
|
16691
16765
|
currentRowIndex,
|
16692
16766
|
setCurrentRowIndex,
|
16767
|
+
handleFocus: onFocus,
|
16693
16768
|
handleKeyDown: onKeyDown
|
16694
16769
|
};
|
16695
16770
|
}
|
@@ -17072,7 +17147,8 @@ function useCurrentRowListener(table) {
|
|
17072
17147
|
const meta = table.options.meta;
|
17073
17148
|
const rows = table.getRowModel().rows;
|
17074
17149
|
React__default.useEffect(() => {
|
17075
|
-
|
17150
|
+
const currentRowIndex = meta.currentRow.currentRowIndex;
|
17151
|
+
if (currentRowIndex !== undefined && currentRowIndex > rows.length) {
|
17076
17152
|
meta.currentRow.setCurrentRowIndex(0);
|
17077
17153
|
}
|
17078
17154
|
}, [rows.length]);
|
@@ -17183,9 +17259,12 @@ function useRowSelection() {
|
|
17183
17259
|
const rows = table.getRowModel().rows;
|
17184
17260
|
const tableMeta = table.options.meta;
|
17185
17261
|
if (event.key === ' ') {
|
17186
|
-
var _rows$tableMeta$curre;
|
17187
17262
|
event.preventDefault();
|
17188
|
-
|
17263
|
+
const currentRowIndex = tableMeta.currentRow.currentRowIndex;
|
17264
|
+
if (currentRowIndex !== undefined) {
|
17265
|
+
var _rows$currentRowIndex;
|
17266
|
+
(_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.toggleSelected();
|
17267
|
+
}
|
17189
17268
|
return;
|
17190
17269
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
|
17191
17270
|
event.preventDefault();
|
@@ -17208,7 +17287,7 @@ function useRowClick(onRowClick) {
|
|
17208
17287
|
const tableMeta = table.options.meta;
|
17209
17288
|
if (event.key === 'Enter') {
|
17210
17289
|
event.preventDefault();
|
17211
|
-
if (onRowClick) {
|
17290
|
+
if (onRowClick && tableMeta.currentRow.currentRowIndex !== undefined) {
|
17212
17291
|
onRowClick(rows[tableMeta.currentRow.currentRowIndex].original);
|
17213
17292
|
}
|
17214
17293
|
return;
|
@@ -17462,7 +17541,7 @@ const MemoedCell$1 = /*#__PURE__*/React__default.memo(function MemoedCell(props)
|
|
17462
17541
|
}
|
17463
17542
|
if (isEditing && isCurrentRow) {
|
17464
17543
|
content = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, content, /*#__PURE__*/React__default.createElement(IconButton, {
|
17465
|
-
appearance: "
|
17544
|
+
appearance: "transparent",
|
17466
17545
|
"aria-label": texts.table3.editing.actions.tooltip,
|
17467
17546
|
icon: "more",
|
17468
17547
|
menu: menuProps => /*#__PURE__*/React__default.createElement(Menu$1, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu$1.Content, null, /*#__PURE__*/React__default.createElement(Menu$1.Item, {
|
@@ -17780,7 +17859,7 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
|
|
17780
17859
|
resizeTextArea(e.target);
|
17781
17860
|
};
|
17782
17861
|
const textareaContainerClassName = cn('w-full', {
|
17783
|
-
'focus-within:absolute focus-within:left-0 focus-within:top-0 focus-within:z-20 focus-within:px-
|
17862
|
+
'focus-within:absolute focus-within:left-0 focus-within:top-0 focus-within:z-20 focus-within:px-[var(--table3-cell-padding-x)] focus-within:pt-[var(--table3-cell-padding-y)]': columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate
|
17784
17863
|
});
|
17785
17864
|
const handleTextareaKeyDown = event => {
|
17786
17865
|
// By default Shift + Enter in textarea makes a new line, we want to keep this behaviour
|
@@ -17948,7 +18027,6 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
|
|
17948
18027
|
}));
|
17949
18028
|
} else if (controlRenderer === 'switch') {
|
17950
18029
|
return /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, attributes, {
|
17951
|
-
className: "mx-2 mt-1.5",
|
17952
18030
|
checked: Boolean(value),
|
17953
18031
|
onChange: handleChange,
|
17954
18032
|
ref: refCallback
|
@@ -17987,7 +18065,7 @@ function EditingCell$1(props) {
|
|
17987
18065
|
}));
|
17988
18066
|
}
|
17989
18067
|
const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
|
17990
|
-
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$
|
18068
|
+
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$currentRowIndex, _column$columnDef$met;
|
17991
18069
|
const {
|
17992
18070
|
cell,
|
17993
18071
|
column,
|
@@ -18039,7 +18117,8 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
18039
18117
|
// row move indicator
|
18040
18118
|
const moveReason = (_tableMeta$editing$ro = tableMeta.editing.rowMoveReason[cell.column.id]) !== null && _tableMeta$editing$ro !== void 0 ? _tableMeta$editing$ro : null;
|
18041
18119
|
const rows = table.getRowModel().rows;
|
18042
|
-
const
|
18120
|
+
const currentRowIndex = tableMeta.currentRow.currentRowIndex;
|
18121
|
+
const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
|
18043
18122
|
const mountNode = React__default.useMemo(() => {
|
18044
18123
|
if (moveReason) {
|
18045
18124
|
var _cellRef$current2, _cellRef$current2$par;
|
@@ -18067,7 +18146,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
18067
18146
|
return removeMoveReason;
|
18068
18147
|
}, [value]);
|
18069
18148
|
const controlRenderer = (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.control;
|
18070
|
-
const className = cn('
|
18149
|
+
const className = cn('py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]', {
|
18071
18150
|
relative: (isCurrentRow || isHovered) && controlRenderer === 'textarea',
|
18072
18151
|
// Need to set higher z-index, so that the current row textarea (in expanded state, when positioned absolute) overlaps rows below,
|
18073
18152
|
// but at the same time it should not overlap the table headers which has z-10.
|
@@ -18087,6 +18166,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
18087
18166
|
className: className,
|
18088
18167
|
"data-align": columnMeta.align,
|
18089
18168
|
"data-column-index": index,
|
18169
|
+
"data-editable": true,
|
18090
18170
|
role: "cell",
|
18091
18171
|
ref: cellRef
|
18092
18172
|
}, /*#__PURE__*/React__default.createElement(EditingControl, {
|
@@ -18129,7 +18209,7 @@ function getRowMoveReason(table, rowIndex, rowValues, cell, newValue) {
|
|
18129
18209
|
}
|
18130
18210
|
|
18131
18211
|
function Cell$3(props) {
|
18132
|
-
var _rows$
|
18212
|
+
var _rows$currentRowIndex;
|
18133
18213
|
const {
|
18134
18214
|
column,
|
18135
18215
|
row,
|
@@ -18141,7 +18221,8 @@ function Cell$3(props) {
|
|
18141
18221
|
const rows = table.getRowModel().rows;
|
18142
18222
|
const tableMeta = table.options.meta;
|
18143
18223
|
const columnMeta = column.columnDef.meta;
|
18144
|
-
const
|
18224
|
+
const currentRowIndex = tableMeta.currentRow.currentRowIndex;
|
18225
|
+
const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
|
18145
18226
|
if (tableMeta.editing.isEditing && columnMeta.control && (isCurrentRow || isHoveredRow && !tableMeta.hoverState.isPaused)) {
|
18146
18227
|
return /*#__PURE__*/React__default.createElement(EditingCell$1, Object.assign({}, props));
|
18147
18228
|
}
|
@@ -18249,7 +18330,7 @@ function createRowSelectionColumn$1(hasDrag, hasExpansion) {
|
|
18249
18330
|
footer: Footer$4,
|
18250
18331
|
meta: {
|
18251
18332
|
align: 'center',
|
18252
|
-
className: cn('!pt-[var(--table3-
|
18333
|
+
className: cn('!pt-[var(--table3-cell-padding-y)] !justify-end !p-0', {
|
18253
18334
|
'!pr-0.5': hasExpansion,
|
18254
18335
|
'!pr-3': !hasExpansion
|
18255
18336
|
}),
|
@@ -18283,7 +18364,7 @@ function Header$4(context) {
|
|
18283
18364
|
return /*#__PURE__*/React__default.createElement(Header$2, Object.assign({}, context), /*#__PURE__*/React__default.createElement(Tooltip, {
|
18284
18365
|
title: title
|
18285
18366
|
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
18286
|
-
appearance: "
|
18367
|
+
appearance: "transparent",
|
18287
18368
|
icon: isSomeRowsExpanded ? 'chevron-down-double' : 'chevron-right-double',
|
18288
18369
|
onClick: handleClick,
|
18289
18370
|
tabIndex: -1,
|
@@ -18349,7 +18430,7 @@ function createRowExpansionColumn$1(expandedRowRenderer) {
|
|
18349
18430
|
footer: Footer$4,
|
18350
18431
|
meta: {
|
18351
18432
|
align: 'center',
|
18352
|
-
className: '!p-0 !pt-[var(--table3-
|
18433
|
+
className: '!p-0 !pt-[var(--table3-cell-padding-y)]',
|
18353
18434
|
enableOrdering: false,
|
18354
18435
|
enableSearch: false,
|
18355
18436
|
enableTruncate: false,
|
@@ -18425,7 +18506,7 @@ function createRowDragColumn(onRowDrag) {
|
|
18425
18506
|
footer: Footer$4,
|
18426
18507
|
meta: {
|
18427
18508
|
align: 'center',
|
18428
|
-
className: '!p-0 !pt-[var(--table3-
|
18509
|
+
className: '!p-0 !pt-[var(--table3-cell-padding-y)]',
|
18429
18510
|
enableOrdering: false,
|
18430
18511
|
enableSearch: false,
|
18431
18512
|
enableTruncate: false,
|
@@ -18467,7 +18548,7 @@ function useConvertChildrenToColumns(props, options, editing) {
|
|
18467
18548
|
React__default.Children.toArray(props.children).filter(child => !!child) // remove falsey children
|
18468
18549
|
.forEach(child => {
|
18469
18550
|
if ( /*#__PURE__*/React__default.isValidElement(child) && child.props.accessor) {
|
18470
|
-
var _child$props$enableRe, _child$props$enableFi, _child$props$enableSo, _child$props$enableHi, _child$props$enableOr, _child$props$enableSe, _child$props$enableTr;
|
18551
|
+
var _child$props$enableRe, _child$props$enableFi, _child$props$enableSo, _child$props$enableHi, _child$props$enableOr, _child$props$enablePr, _child$props$enableSe, _child$props$enableTr;
|
18471
18552
|
if (child.props.defaultWidth) {
|
18472
18553
|
defaultColumnSizing[child.props.accessor] = child.props.defaultWidth === 'grow' ? '1fr' : child.props.defaultWidth;
|
18473
18554
|
}
|
@@ -18506,6 +18587,7 @@ function useConvertChildrenToColumns(props, options, editing) {
|
|
18506
18587
|
control: child.props.control,
|
18507
18588
|
dataType: child.props.dataType,
|
18508
18589
|
enableOrdering: (_child$props$enableOr = child.props.enableOrdering) !== null && _child$props$enableOr !== void 0 ? _child$props$enableOr : true,
|
18590
|
+
enablePrinting: (_child$props$enablePr = child.props.enablePrinting) !== null && _child$props$enablePr !== void 0 ? _child$props$enablePr : true,
|
18509
18591
|
enableSearch: (_child$props$enableSe = child.props.enableSearch) !== null && _child$props$enableSe !== void 0 ? _child$props$enableSe : true,
|
18510
18592
|
enableTruncate: (_child$props$enableTr = child.props.enableTruncate) !== null && _child$props$enableTr !== void 0 ? _child$props$enableTr : false,
|
18511
18593
|
filters: child.props.filters,
|
@@ -18560,7 +18642,7 @@ function useShortcutsListener(table, shortcuts) {
|
|
18560
18642
|
const shortcutKeys = Object.keys(shortcuts !== null && shortcuts !== void 0 ? shortcuts : {});
|
18561
18643
|
const globalHandlers = [];
|
18562
18644
|
// convert the shortcut into the correct format to register it
|
18563
|
-
if (shortcuts && shortcutKeys.length) {
|
18645
|
+
if (shortcuts && shortcutKeys.length && meta.currentRow.currentRowIndex !== undefined) {
|
18564
18646
|
const currentRow = rows[meta.currentRow.currentRowIndex];
|
18565
18647
|
shortcutKeys.forEach(key => {
|
18566
18648
|
const handler = shortcuts[key];
|
@@ -18628,10 +18710,14 @@ function useEditingStateListener(table) {
|
|
18628
18710
|
}, [meta.currentRow.currentRowIndex]);
|
18629
18711
|
// save if editing gets toggled off
|
18630
18712
|
React__default.useEffect(() => {
|
18631
|
-
if (meta.editing.isEnabled
|
18632
|
-
|
18633
|
-
|
18634
|
-
|
18713
|
+
if (meta.editing.isEnabled) {
|
18714
|
+
if (!meta.editing.isEditing) {
|
18715
|
+
requestAnimationFrame(() => {
|
18716
|
+
meta.editing.saveChangesIfNeeded();
|
18717
|
+
});
|
18718
|
+
} else if (meta.currentRow.currentRowIndex === undefined) {
|
18719
|
+
meta.currentRow.setCurrentRowIndex(0);
|
18720
|
+
}
|
18635
18721
|
}
|
18636
18722
|
}, [meta.editing.isEditing]);
|
18637
18723
|
}
|
@@ -18855,6 +18941,7 @@ function useTable$2(props) {
|
|
18855
18941
|
enableFooter: options.enableFooter,
|
18856
18942
|
fontSize,
|
18857
18943
|
hoverState,
|
18944
|
+
isPrinting: props.id.endsWith('_print'),
|
18858
18945
|
isUsingServer: !!props.loadPage,
|
18859
18946
|
printing,
|
18860
18947
|
rowActions: rowActions,
|
@@ -18882,12 +18969,56 @@ function useTable$2(props) {
|
|
18882
18969
|
};
|
18883
18970
|
}
|
18884
18971
|
|
18972
|
+
const FOCUS_MANAGER_OPTIONS = {
|
18973
|
+
tabbable: true
|
18974
|
+
};
|
18885
18975
|
function Row$2(props) {
|
18976
|
+
const focusManager = focus.useFocusManager();
|
18886
18977
|
const tableMeta = props.table.options.meta;
|
18887
18978
|
const isCurrentRow = tableMeta.currentRow.currentRowIndex === props.index;
|
18888
18979
|
const isDraggingRow = tableMeta.rowDrag.dragging[props.row.id];
|
18980
|
+
const isFirstRow = props.index === 0;
|
18889
18981
|
// we use non-css hovered state to determine whether to render actions or not, for performance
|
18890
18982
|
const [isHovered, setIsHovered] = React__default.useState(false);
|
18983
|
+
// tab behaviour is consistent across normal mode and edit mode, handle it here
|
18984
|
+
const handleKeyDown = event => {
|
18985
|
+
if (event.isDefaultPrevented() || event.isPropagationStopped()) {
|
18986
|
+
return;
|
18987
|
+
}
|
18988
|
+
if (event.key === 'Tab') {
|
18989
|
+
tableMeta.hoverState.pause(true);
|
18990
|
+
let focusedElement;
|
18991
|
+
if (event.shiftKey) {
|
18992
|
+
// looping backwards
|
18993
|
+
focusedElement = focusManager.focusPrevious(FOCUS_MANAGER_OPTIONS);
|
18994
|
+
if (focusedElement) {
|
18995
|
+
// override default behaviour, since we're handling focus internally now
|
18996
|
+
event.preventDefault();
|
18997
|
+
} else {
|
18998
|
+
// there are no previous elements to focus, go up a row or go outside the table
|
18999
|
+
if (!isFirstRow) {
|
19000
|
+
event.preventDefault();
|
19001
|
+
tableMeta.currentRow.setCurrentRowIndex(props.index - 1);
|
19002
|
+
setTimeout(() => focusManager.focusLast(FOCUS_MANAGER_OPTIONS), 1);
|
19003
|
+
}
|
19004
|
+
}
|
19005
|
+
} else {
|
19006
|
+
// looping forwards
|
19007
|
+
focusedElement = focusManager.focusNext(FOCUS_MANAGER_OPTIONS);
|
19008
|
+
if (focusedElement) {
|
19009
|
+
// override default behaviour, since we're handling focus internally now
|
19010
|
+
event.preventDefault();
|
19011
|
+
} else {
|
19012
|
+
// there are no next elements to focus, go down a row or go outside the table
|
19013
|
+
if (!props.isLastRow) {
|
19014
|
+
event.preventDefault();
|
19015
|
+
tableMeta.currentRow.setCurrentRowIndex(props.index + 1);
|
19016
|
+
setTimeout(() => focusManager.focusFirst(FOCUS_MANAGER_OPTIONS), 1);
|
19017
|
+
}
|
19018
|
+
}
|
19019
|
+
}
|
19020
|
+
}
|
19021
|
+
};
|
18891
19022
|
// rows are heavily memoized because performance in our table is critical
|
18892
19023
|
// be careful and selective about props that you pass to the row
|
18893
19024
|
const memoedProps = {
|
@@ -18898,12 +19029,13 @@ function Row$2(props) {
|
|
18898
19029
|
draggable: tableMeta.rowDrag.isEnabled,
|
18899
19030
|
index: props.index,
|
18900
19031
|
onClick: tableMeta.rowClick.handleClick,
|
18901
|
-
onDrop: tableMeta.rowDrop.isEnabled ? tableMeta.rowDrop.handleDrop : undefined
|
19032
|
+
onDrop: tableMeta.rowDrop.isEnabled ? tableMeta.rowDrop.handleDrop : undefined,
|
19033
|
+
onKeyDown: handleKeyDown
|
18902
19034
|
};
|
18903
19035
|
let output = /*#__PURE__*/React__default.createElement(MemoedRow, Object.assign({}, props, memoedProps));
|
18904
19036
|
if (tableMeta.editing.isEditing && (isCurrentRow || isHovered && !tableMeta.hoverState.isPaused)) {
|
18905
19037
|
output = /*#__PURE__*/React__default.createElement(EditingRow, Object.assign({}, props, memoedProps, {
|
18906
|
-
|
19038
|
+
isFirstRow: isFirstRow,
|
18907
19039
|
setCurrentRowIndex: tableMeta.currentRow.setCurrentRowIndex
|
18908
19040
|
}));
|
18909
19041
|
}
|
@@ -18943,79 +19075,80 @@ const unhoverPreviousRow = tableRef => {
|
|
18943
19075
|
};
|
18944
19076
|
function EditingRow(props) {
|
18945
19077
|
const {
|
19078
|
+
isFirstRow,
|
18946
19079
|
isLastRow,
|
19080
|
+
onKeyDown,
|
18947
19081
|
setCurrentRowIndex,
|
18948
19082
|
virtualiser,
|
18949
19083
|
...attributes
|
18950
19084
|
} = props;
|
18951
19085
|
const focusManager = focus.useFocusManager();
|
18952
|
-
const focusManagerOptions = {
|
18953
|
-
tabbable: true
|
18954
|
-
};
|
18955
19086
|
const tableMeta = props.table.options.meta;
|
18956
19087
|
const handleClickCapture = event => {
|
18957
19088
|
lastIndex = getColumnIndex(event.target);
|
18958
19089
|
};
|
18959
19090
|
const handleArrowLeftKey = event => {
|
18960
19091
|
let focusedElement;
|
18961
|
-
if (event.key === 'ArrowLeft'
|
18962
|
-
//
|
18963
|
-
// and will lead to looping focus. Also we still need to perform special behaviour when focus reaches the end of the row,
|
19092
|
+
if (event.key === 'ArrowLeft') {
|
19093
|
+
// We need to perform special behaviour when focus reaches the end of the row,
|
18964
19094
|
// so we don't need default browser behaviour.
|
18965
19095
|
event.stopPropagation();
|
18966
19096
|
event.preventDefault();
|
18967
19097
|
// "CTRL + ArrowLeft" or "META + ArrowLeft" should focus first focusable element of the row
|
18968
19098
|
if (event.ctrlKey || event.metaKey) {
|
18969
19099
|
event.target.blur();
|
18970
|
-
focusedElement = focusManager.focusFirst(
|
19100
|
+
focusedElement = focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);
|
18971
19101
|
lastIndex = getColumnIndex(focusedElement);
|
18972
19102
|
} else {
|
18973
|
-
//
|
18974
|
-
focusedElement = focusManager.focusPrevious(
|
18975
|
-
|
18976
|
-
// if there is no previous focusable element in current row
|
18977
|
-
if (props.index !== 0 && (!focusedElement || !event.currentTarget.contains(focusedElement))) {
|
18978
|
-
tableMeta.hoverState.pause(true);
|
18979
|
-
setCurrentRowIndex(props.index - 1);
|
18980
|
-
setTimeout(() => {
|
18981
|
-
focusedElement = focusManager.focusLast(focusManagerOptions);
|
18982
|
-
// Need to update lastIndex when row got changed and last element got selected.
|
18983
|
-
lastIndex = getColumnIndex(focusedElement);
|
18984
|
-
}, 1);
|
18985
|
-
} else {
|
19103
|
+
// looping backwards
|
19104
|
+
focusedElement = focusManager.focusPrevious(FOCUS_MANAGER_OPTIONS);
|
19105
|
+
if (focusedElement) {
|
18986
19106
|
lastIndex = getColumnIndex(focusedElement);
|
19107
|
+
} else {
|
19108
|
+
// there are no previous elements to focus, go up a row (if there are rows above)
|
19109
|
+
if (!isFirstRow) {
|
19110
|
+
event.preventDefault();
|
19111
|
+
tableMeta.hoverState.pause(true);
|
19112
|
+
tableMeta.currentRow.setCurrentRowIndex(props.index - 1);
|
19113
|
+
setTimeout(() => {
|
19114
|
+
focusManager.focusLast(FOCUS_MANAGER_OPTIONS);
|
19115
|
+
// Need to update lastIndex when row got changed and last element got selected.
|
19116
|
+
lastIndex = getColumnIndex(focusedElement);
|
19117
|
+
}, 1);
|
19118
|
+
}
|
18987
19119
|
}
|
18988
19120
|
}
|
18989
19121
|
}
|
18990
19122
|
};
|
18991
19123
|
const handleArrowRightKey = event => {
|
18992
19124
|
let focusedElement;
|
18993
|
-
if (event.key === 'ArrowRight'
|
18994
|
-
//
|
18995
|
-
// and will lead to looping focus. Also we still need to perform special behaviour when focus reaches the end of the row,
|
19125
|
+
if (event.key === 'ArrowRight') {
|
19126
|
+
// We need to perform special behaviour when focus reaches the end of the row,
|
18996
19127
|
// so we don't need default browser behaviour.
|
18997
19128
|
event.stopPropagation();
|
18998
19129
|
event.preventDefault();
|
18999
19130
|
// "CTRL + ArrowRight" or "META + ArrowRight" should focus last focusable element of the row
|
19000
19131
|
if (event.ctrlKey || event.metaKey) {
|
19001
19132
|
event.target.blur();
|
19002
|
-
focusedElement = focusManager.focusLast(
|
19133
|
+
focusedElement = focusManager.focusLast(FOCUS_MANAGER_OPTIONS);
|
19003
19134
|
lastIndex = getColumnIndex(focusedElement);
|
19004
19135
|
} else {
|
19005
|
-
//
|
19006
|
-
focusedElement = focusManager.focusNext(
|
19007
|
-
|
19008
|
-
// if there is no next focusable element in current row
|
19009
|
-
if (!isLastRow && (!focusedElement || !event.currentTarget.contains(focusedElement))) {
|
19010
|
-
tableMeta.hoverState.pause(true);
|
19011
|
-
setCurrentRowIndex(props.index + 1);
|
19012
|
-
setTimeout(() => {
|
19013
|
-
focusedElement = focusManager.focusFirst(focusManagerOptions);
|
19014
|
-
// Need to update lastIndex when row got changed and first element got selected.
|
19015
|
-
lastIndex = getColumnIndex(focusedElement);
|
19016
|
-
}, 1);
|
19017
|
-
} else {
|
19136
|
+
// looping forwards
|
19137
|
+
focusedElement = focusManager.focusNext(FOCUS_MANAGER_OPTIONS);
|
19138
|
+
if (focusedElement) {
|
19018
19139
|
lastIndex = getColumnIndex(focusedElement);
|
19140
|
+
} else {
|
19141
|
+
// there are no next elements to focus, go down a row or go outside the table
|
19142
|
+
if (!props.isLastRow) {
|
19143
|
+
event.preventDefault();
|
19144
|
+
tableMeta.hoverState.pause(true);
|
19145
|
+
tableMeta.currentRow.setCurrentRowIndex(props.index + 1);
|
19146
|
+
setTimeout(() => {
|
19147
|
+
focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);
|
19148
|
+
// Need to update lastIndex when row got changed and last element got selected.
|
19149
|
+
lastIndex = getColumnIndex(focusedElement);
|
19150
|
+
}, 1);
|
19151
|
+
}
|
19019
19152
|
}
|
19020
19153
|
}
|
19021
19154
|
}
|
@@ -19030,6 +19163,7 @@ function EditingRow(props) {
|
|
19030
19163
|
if (event.isDefaultPrevented() || event.isPropagationStopped() || tableMeta.editing.detailModeEditing) {
|
19031
19164
|
return;
|
19032
19165
|
}
|
19166
|
+
onKeyDown(event); // handles tab behaviour
|
19033
19167
|
handleArrowLeftKey(event);
|
19034
19168
|
handleArrowRightKey(event);
|
19035
19169
|
};
|
@@ -19041,7 +19175,7 @@ function EditingRow(props) {
|
|
19041
19175
|
const lastIndexCell = (_props$tableRef$curre = props.tableRef.current) === null || _props$tableRef$curre === void 0 ? void 0 : _props$tableRef$curre.querySelector(`[role="row"][data-current="true"] [data-column-index="${lastIndex}"]`);
|
19042
19176
|
lastIndexCell === null || lastIndexCell === void 0 ? void 0 : (_lastIndexCell$queryS = lastIndexCell.querySelector(focusableSelector)) === null || _lastIndexCell$queryS === void 0 ? void 0 : _lastIndexCell$queryS.focus();
|
19043
19177
|
} else {
|
19044
|
-
focusManager.focusFirst(
|
19178
|
+
focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);
|
19045
19179
|
}
|
19046
19180
|
}
|
19047
19181
|
// Need to subscribe to current row index and check is it a current row,
|
@@ -19072,10 +19206,19 @@ const MemoedRow = /*#__PURE__*/React__default.memo(function MemoedRow(props) {
|
|
19072
19206
|
const {
|
19073
19207
|
setIsHovered
|
19074
19208
|
} = useRowContext$1();
|
19209
|
+
const isCurrentRow = Boolean(attributes['data-current']);
|
19210
|
+
// we want tabbing to "start" again at the start of the row each time, only after pressing tab though
|
19211
|
+
// so we focus the first cell so when tab is pressed it moves inside the row
|
19212
|
+
React__default.useEffect(() => {
|
19213
|
+
if (isCurrentRow) {
|
19214
|
+
var _ref$current, _ref$current$querySel;
|
19215
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : (_ref$current$querySel = _ref$current.querySelector('[role="cell"]:first-child')) === null || _ref$current$querySel === void 0 ? void 0 : _ref$current$querySel.focus();
|
19216
|
+
}
|
19217
|
+
}, [isCurrentRow]);
|
19075
19218
|
// we measure the first cell (since the row has display: contents) so that the virtualiser height is correct
|
19076
19219
|
React__default.useEffect(() => {
|
19077
|
-
var _ref$
|
19078
|
-
const firstCell = (_ref$
|
19220
|
+
var _ref$current2;
|
19221
|
+
const firstCell = (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.querySelector('[role=cell]:first-child');
|
19079
19222
|
if (firstCell) {
|
19080
19223
|
measureRef(firstCell);
|
19081
19224
|
}
|
@@ -19090,9 +19233,9 @@ const MemoedRow = /*#__PURE__*/React__default.memo(function MemoedRow(props) {
|
|
19090
19233
|
};
|
19091
19234
|
const handleClick = event => {
|
19092
19235
|
if (typeof onClick === 'function') {
|
19093
|
-
var _ref$
|
19236
|
+
var _ref$current3;
|
19094
19237
|
const clickedElement = event.target;
|
19095
|
-
if (!((_ref$
|
19238
|
+
if (!((_ref$current3 = ref.current) !== null && _ref$current3 !== void 0 && _ref$current3.contains(event.target)) || clickableElements.includes(clickedElement.tagName.toLowerCase()) || clickedElement.closest(clickableElements.map(tag => `[role=row] ${tag}`).join(','))) {
|
19096
19239
|
return;
|
19097
19240
|
}
|
19098
19241
|
onClick(row.original);
|
@@ -20333,8 +20476,18 @@ function PrintButton(props) {
|
|
20333
20476
|
columnFilters: state.columnFilters,
|
20334
20477
|
globalFilter: state.globalFilter
|
20335
20478
|
}), [tableMeta.columnFreezing.frozenColumnIndex, state.columnOrder, state.columnSizing, state.columnVisibility, excludeUnmatchedResults, tableMeta.fontSize.size, tableMeta.rowHeight.height, state.sorting, state.columnFilters, state.globalFilter]);
|
20479
|
+
const iframeTableChildren = React__default.useMemo(() => React__default.Children.toArray(tableProps.children).filter(child => {
|
20480
|
+
var _child$props;
|
20481
|
+
const enableColumnInPrinting = (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.enablePrinting;
|
20482
|
+
// For table children, only include columns doesn't have 'false' value for enablePrinting prop.
|
20483
|
+
if ( /*#__PURE__*/React__default.isValidElement(child) && enableColumnInPrinting === false) {
|
20484
|
+
return false;
|
20485
|
+
}
|
20486
|
+
return true;
|
20487
|
+
}), [tableProps.children]);
|
20336
20488
|
const iframeTableProps = {
|
20337
20489
|
...tableProps,
|
20490
|
+
children: iframeTableChildren,
|
20338
20491
|
defaultSettings,
|
20339
20492
|
id: printTableId
|
20340
20493
|
};
|
@@ -20767,7 +20920,7 @@ function Summary$1(props) {
|
|
20767
20920
|
}
|
20768
20921
|
|
20769
20922
|
// we cannot just use a fixed height because our rows need to grow in height (images, edit mode validation etc)
|
20770
|
-
const
|
20923
|
+
const getCellHeightPadding = (height, fontSize) => {
|
20771
20924
|
// TODO: can we get the rem values from tailwind
|
20772
20925
|
switch (height) {
|
20773
20926
|
case 'short':
|
@@ -20816,9 +20969,22 @@ const getRowHeightSizing = (height, fontSize) => {
|
|
20816
20969
|
}
|
20817
20970
|
}
|
20818
20971
|
};
|
20972
|
+
const getCellWidthPadding = fontSize => {
|
20973
|
+
switch (fontSize) {
|
20974
|
+
case 'small':
|
20975
|
+
return '8px';
|
20976
|
+
case 'medium':
|
20977
|
+
return '12px';
|
20978
|
+
default:
|
20979
|
+
return '16px';
|
20980
|
+
// py-1.5
|
20981
|
+
}
|
20982
|
+
};
|
20983
|
+
|
20819
20984
|
const useCssVars = (height, fontSize) => {
|
20820
20985
|
const style = {
|
20821
|
-
'--table3-
|
20986
|
+
'--table3-cell-padding-x': getCellWidthPadding(fontSize),
|
20987
|
+
'--table3-cell-padding-y': getCellHeightPadding(height, fontSize)
|
20822
20988
|
};
|
20823
20989
|
return {
|
20824
20990
|
style
|
@@ -21008,6 +21174,9 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21008
21174
|
const handleBlur = event => {
|
21009
21175
|
tableMeta.editing.handleBlur(event);
|
21010
21176
|
};
|
21177
|
+
const handleFocus = event => {
|
21178
|
+
tableMeta.currentRow.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);
|
21179
|
+
};
|
21011
21180
|
const handleScroll = function (event) {
|
21012
21181
|
try {
|
21013
21182
|
tableMeta.columnFreezing.handleScroll(event);
|
@@ -21016,7 +21185,7 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21016
21185
|
return Promise.reject(e);
|
21017
21186
|
}
|
21018
21187
|
};
|
21019
|
-
const className = cn('border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px]', '[&[data-resizing="true"]]:select-none', {
|
21188
|
+
const className = cn('border-grey-300 relative grid h-full w-full flex-grow overflow-auto rounded border bg-white scroll-mt-[41px] focus-visible:outline-none', '[&[data-resizing="true"]]:select-none', {
|
21020
21189
|
'text-xs': tableMeta.fontSize.size === 'small',
|
21021
21190
|
'text-sm': tableMeta.fontSize.size === 'medium',
|
21022
21191
|
'text-base': tableMeta.fontSize.size === 'large'
|
@@ -21025,7 +21194,7 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21025
21194
|
// if the table is a print table or not.
|
21026
21195
|
const {
|
21027
21196
|
style: cssGridStyle
|
21028
|
-
} = useCssGrid(table,
|
21197
|
+
} = useCssGrid(table, tableMeta.isPrinting);
|
21029
21198
|
const {
|
21030
21199
|
style: cssVars
|
21031
21200
|
} = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);
|
@@ -21057,10 +21226,12 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21057
21226
|
"data-resizing": !!state.columnSizingInfo.isResizingColumn,
|
21058
21227
|
"data-taco": "table2",
|
21059
21228
|
onBlur: handleBlur,
|
21229
|
+
onFocus: handleFocus,
|
21060
21230
|
onScroll: handleScroll,
|
21061
21231
|
ref: internalRef,
|
21062
21232
|
role: "table",
|
21063
|
-
style: style
|
21233
|
+
style: style,
|
21234
|
+
tabIndex: -1
|
21064
21235
|
}, isServerLoadingAndNotReady ? null : /*#__PURE__*/React__default.createElement("div", {
|
21065
21236
|
className: "group/header contents",
|
21066
21237
|
"data-taco": "table2-header",
|
@@ -21074,7 +21245,9 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21074
21245
|
}, reactTable$1.flexRender(header.column.columnDef.header, {
|
21075
21246
|
...header.getContext(),
|
21076
21247
|
scrollToIndex
|
21077
|
-
})))))), table.getRowModel().rows.length ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(focus.FocusScope,
|
21248
|
+
})))))), table.getRowModel().rows.length ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(focus.FocusScope, {
|
21249
|
+
autoFocus: tableMeta.editing.isEditing
|
21250
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
21078
21251
|
className: "group/body contents",
|
21079
21252
|
"data-taco": "table2-body",
|
21080
21253
|
role: "rowgroup",
|