@economic/taco 2.9.2 → 2.10.1
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 +6 -5
- 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 +13 -6
- 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 +87 -40
- 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 +28 -2
- 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 +272 -96
- 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;
|
@@ -16661,7 +16722,13 @@ function useCurrentRow(defaultCurrentRowIndex = 0) {
|
|
16661
16722
|
});
|
16662
16723
|
const moveUp = (length, callback) => move(-1, length, callback);
|
16663
16724
|
const moveDown = (length, callback) => move(1, length, callback);
|
16664
|
-
const
|
16725
|
+
const focusFirstElementInCurrentRow = tableRef => {
|
16726
|
+
setTimeout(() => {
|
16727
|
+
var _tableRef$current, _tableRef$current$que;
|
16728
|
+
(_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$que = _tableRef$current.querySelector('[data-taco="table2-body"] [role="row"] [role="cell"]:first-child')) === null || _tableRef$current$que === void 0 ? void 0 : _tableRef$current$que.focus();
|
16729
|
+
}, 1);
|
16730
|
+
};
|
16731
|
+
const onKeyDown = React__default.useCallback((event, length, scrollToIndex, isEditing, tableRef) => {
|
16665
16732
|
if (event.defaultPrevented) {
|
16666
16733
|
return;
|
16667
16734
|
}
|
@@ -16674,6 +16741,9 @@ function useCurrentRow(defaultCurrentRowIndex = 0) {
|
|
16674
16741
|
} else {
|
16675
16742
|
moveUp(length, scrollToIndex);
|
16676
16743
|
}
|
16744
|
+
if (!isEditing) {
|
16745
|
+
focusFirstElementInCurrentRow(tableRef);
|
16746
|
+
}
|
16677
16747
|
return;
|
16678
16748
|
} else if (event.key === 'ArrowDown') {
|
16679
16749
|
event.preventDefault();
|
@@ -16684,12 +16754,29 @@ function useCurrentRow(defaultCurrentRowIndex = 0) {
|
|
16684
16754
|
} else {
|
16685
16755
|
moveDown(length, scrollToIndex);
|
16686
16756
|
}
|
16757
|
+
if (!isEditing) {
|
16758
|
+
focusFirstElementInCurrentRow(tableRef);
|
16759
|
+
}
|
16687
16760
|
return;
|
16688
16761
|
}
|
16689
16762
|
}, []);
|
16763
|
+
const onFocus = React__default.useCallback((event, length, scrollToIndex) => {
|
16764
|
+
if (event.isDefaultPrevented()) {
|
16765
|
+
return;
|
16766
|
+
}
|
16767
|
+
if (currentRowIndex === undefined && length > 0) {
|
16768
|
+
// do it in the next tick, otherwise it prevents internal focus from working
|
16769
|
+
// meaning you have to tab twice to get to the first focusable element
|
16770
|
+
setTimeout(() => {
|
16771
|
+
setCurrentRowIndex(0);
|
16772
|
+
scrollToIndex(0);
|
16773
|
+
}, 1);
|
16774
|
+
}
|
16775
|
+
}, [currentRowIndex, length]);
|
16690
16776
|
return {
|
16691
16777
|
currentRowIndex,
|
16692
16778
|
setCurrentRowIndex,
|
16779
|
+
handleFocus: onFocus,
|
16693
16780
|
handleKeyDown: onKeyDown
|
16694
16781
|
};
|
16695
16782
|
}
|
@@ -17072,7 +17159,8 @@ function useCurrentRowListener(table) {
|
|
17072
17159
|
const meta = table.options.meta;
|
17073
17160
|
const rows = table.getRowModel().rows;
|
17074
17161
|
React__default.useEffect(() => {
|
17075
|
-
|
17162
|
+
const currentRowIndex = meta.currentRow.currentRowIndex;
|
17163
|
+
if (currentRowIndex !== undefined && currentRowIndex > rows.length) {
|
17076
17164
|
meta.currentRow.setCurrentRowIndex(0);
|
17077
17165
|
}
|
17078
17166
|
}, [rows.length]);
|
@@ -17183,9 +17271,12 @@ function useRowSelection() {
|
|
17183
17271
|
const rows = table.getRowModel().rows;
|
17184
17272
|
const tableMeta = table.options.meta;
|
17185
17273
|
if (event.key === ' ') {
|
17186
|
-
var _rows$tableMeta$curre;
|
17187
17274
|
event.preventDefault();
|
17188
|
-
|
17275
|
+
const currentRowIndex = tableMeta.currentRow.currentRowIndex;
|
17276
|
+
if (currentRowIndex !== undefined) {
|
17277
|
+
var _rows$currentRowIndex;
|
17278
|
+
(_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.toggleSelected();
|
17279
|
+
}
|
17189
17280
|
return;
|
17190
17281
|
} else if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
|
17191
17282
|
event.preventDefault();
|
@@ -17208,7 +17299,7 @@ function useRowClick(onRowClick) {
|
|
17208
17299
|
const tableMeta = table.options.meta;
|
17209
17300
|
if (event.key === 'Enter') {
|
17210
17301
|
event.preventDefault();
|
17211
|
-
if (onRowClick) {
|
17302
|
+
if (onRowClick && tableMeta.currentRow.currentRowIndex !== undefined) {
|
17212
17303
|
onRowClick(rows[tableMeta.currentRow.currentRowIndex].original);
|
17213
17304
|
}
|
17214
17305
|
return;
|
@@ -17462,7 +17553,7 @@ const MemoedCell$1 = /*#__PURE__*/React__default.memo(function MemoedCell(props)
|
|
17462
17553
|
}
|
17463
17554
|
if (isEditing && isCurrentRow) {
|
17464
17555
|
content = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, content, /*#__PURE__*/React__default.createElement(IconButton, {
|
17465
|
-
appearance: "
|
17556
|
+
appearance: "transparent",
|
17466
17557
|
"aria-label": texts.table3.editing.actions.tooltip,
|
17467
17558
|
icon: "more",
|
17468
17559
|
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 +17871,7 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
|
|
17780
17871
|
resizeTextArea(e.target);
|
17781
17872
|
};
|
17782
17873
|
const textareaContainerClassName = cn('w-full', {
|
17783
|
-
'focus-within:absolute focus-within:left-0 focus-within:top-0 focus-within:z-20 focus-within:px-
|
17874
|
+
'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
17875
|
});
|
17785
17876
|
const handleTextareaKeyDown = event => {
|
17786
17877
|
// By default Shift + Enter in textarea makes a new line, we want to keep this behaviour
|
@@ -17948,7 +18039,6 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
|
|
17948
18039
|
}));
|
17949
18040
|
} else if (controlRenderer === 'switch') {
|
17950
18041
|
return /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, attributes, {
|
17951
|
-
className: "mx-2 mt-1.5",
|
17952
18042
|
checked: Boolean(value),
|
17953
18043
|
onChange: handleChange,
|
17954
18044
|
ref: refCallback
|
@@ -17987,7 +18077,7 @@ function EditingCell$1(props) {
|
|
17987
18077
|
}));
|
17988
18078
|
}
|
17989
18079
|
const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
|
17990
|
-
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$
|
18080
|
+
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$currentRowIndex, _column$columnDef$met;
|
17991
18081
|
const {
|
17992
18082
|
cell,
|
17993
18083
|
column,
|
@@ -18039,7 +18129,8 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
18039
18129
|
// row move indicator
|
18040
18130
|
const moveReason = (_tableMeta$editing$ro = tableMeta.editing.rowMoveReason[cell.column.id]) !== null && _tableMeta$editing$ro !== void 0 ? _tableMeta$editing$ro : null;
|
18041
18131
|
const rows = table.getRowModel().rows;
|
18042
|
-
const
|
18132
|
+
const currentRowIndex = tableMeta.currentRow.currentRowIndex;
|
18133
|
+
const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
|
18043
18134
|
const mountNode = React__default.useMemo(() => {
|
18044
18135
|
if (moveReason) {
|
18045
18136
|
var _cellRef$current2, _cellRef$current2$par;
|
@@ -18067,7 +18158,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
18067
18158
|
return removeMoveReason;
|
18068
18159
|
}, [value]);
|
18069
18160
|
const controlRenderer = (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.control;
|
18070
|
-
const className = cn('
|
18161
|
+
const className = cn('py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]', {
|
18071
18162
|
relative: (isCurrentRow || isHovered) && controlRenderer === 'textarea',
|
18072
18163
|
// Need to set higher z-index, so that the current row textarea (in expanded state, when positioned absolute) overlaps rows below,
|
18073
18164
|
// but at the same time it should not overlap the table headers which has z-10.
|
@@ -18087,6 +18178,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
18087
18178
|
className: className,
|
18088
18179
|
"data-align": columnMeta.align,
|
18089
18180
|
"data-column-index": index,
|
18181
|
+
"data-editable": true,
|
18090
18182
|
role: "cell",
|
18091
18183
|
ref: cellRef
|
18092
18184
|
}, /*#__PURE__*/React__default.createElement(EditingControl, {
|
@@ -18129,7 +18221,7 @@ function getRowMoveReason(table, rowIndex, rowValues, cell, newValue) {
|
|
18129
18221
|
}
|
18130
18222
|
|
18131
18223
|
function Cell$3(props) {
|
18132
|
-
var _rows$
|
18224
|
+
var _rows$currentRowIndex;
|
18133
18225
|
const {
|
18134
18226
|
column,
|
18135
18227
|
row,
|
@@ -18141,7 +18233,8 @@ function Cell$3(props) {
|
|
18141
18233
|
const rows = table.getRowModel().rows;
|
18142
18234
|
const tableMeta = table.options.meta;
|
18143
18235
|
const columnMeta = column.columnDef.meta;
|
18144
|
-
const
|
18236
|
+
const currentRowIndex = tableMeta.currentRow.currentRowIndex;
|
18237
|
+
const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
|
18145
18238
|
if (tableMeta.editing.isEditing && columnMeta.control && (isCurrentRow || isHoveredRow && !tableMeta.hoverState.isPaused)) {
|
18146
18239
|
return /*#__PURE__*/React__default.createElement(EditingCell$1, Object.assign({}, props));
|
18147
18240
|
}
|
@@ -18249,7 +18342,7 @@ function createRowSelectionColumn$1(hasDrag, hasExpansion) {
|
|
18249
18342
|
footer: Footer$4,
|
18250
18343
|
meta: {
|
18251
18344
|
align: 'center',
|
18252
|
-
className: cn('!pt-[var(--table3-
|
18345
|
+
className: cn('!pt-[var(--table3-cell-padding-y)] !justify-end !p-0', {
|
18253
18346
|
'!pr-0.5': hasExpansion,
|
18254
18347
|
'!pr-3': !hasExpansion
|
18255
18348
|
}),
|
@@ -18283,7 +18376,7 @@ function Header$4(context) {
|
|
18283
18376
|
return /*#__PURE__*/React__default.createElement(Header$2, Object.assign({}, context), /*#__PURE__*/React__default.createElement(Tooltip, {
|
18284
18377
|
title: title
|
18285
18378
|
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
18286
|
-
appearance: "
|
18379
|
+
appearance: "transparent",
|
18287
18380
|
icon: isSomeRowsExpanded ? 'chevron-down-double' : 'chevron-right-double',
|
18288
18381
|
onClick: handleClick,
|
18289
18382
|
tabIndex: -1,
|
@@ -18349,7 +18442,7 @@ function createRowExpansionColumn$1(expandedRowRenderer) {
|
|
18349
18442
|
footer: Footer$4,
|
18350
18443
|
meta: {
|
18351
18444
|
align: 'center',
|
18352
|
-
className: '!p-0 !pt-[var(--table3-
|
18445
|
+
className: '!p-0 !pt-[var(--table3-cell-padding-y)]',
|
18353
18446
|
enableOrdering: false,
|
18354
18447
|
enableSearch: false,
|
18355
18448
|
enableTruncate: false,
|
@@ -18425,7 +18518,7 @@ function createRowDragColumn(onRowDrag) {
|
|
18425
18518
|
footer: Footer$4,
|
18426
18519
|
meta: {
|
18427
18520
|
align: 'center',
|
18428
|
-
className: '!p-0 !pt-[var(--table3-
|
18521
|
+
className: '!p-0 !pt-[var(--table3-cell-padding-y)]',
|
18429
18522
|
enableOrdering: false,
|
18430
18523
|
enableSearch: false,
|
18431
18524
|
enableTruncate: false,
|
@@ -18467,7 +18560,7 @@ function useConvertChildrenToColumns(props, options, editing) {
|
|
18467
18560
|
React__default.Children.toArray(props.children).filter(child => !!child) // remove falsey children
|
18468
18561
|
.forEach(child => {
|
18469
18562
|
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;
|
18563
|
+
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
18564
|
if (child.props.defaultWidth) {
|
18472
18565
|
defaultColumnSizing[child.props.accessor] = child.props.defaultWidth === 'grow' ? '1fr' : child.props.defaultWidth;
|
18473
18566
|
}
|
@@ -18506,6 +18599,7 @@ function useConvertChildrenToColumns(props, options, editing) {
|
|
18506
18599
|
control: child.props.control,
|
18507
18600
|
dataType: child.props.dataType,
|
18508
18601
|
enableOrdering: (_child$props$enableOr = child.props.enableOrdering) !== null && _child$props$enableOr !== void 0 ? _child$props$enableOr : true,
|
18602
|
+
enablePrinting: (_child$props$enablePr = child.props.enablePrinting) !== null && _child$props$enablePr !== void 0 ? _child$props$enablePr : true,
|
18509
18603
|
enableSearch: (_child$props$enableSe = child.props.enableSearch) !== null && _child$props$enableSe !== void 0 ? _child$props$enableSe : true,
|
18510
18604
|
enableTruncate: (_child$props$enableTr = child.props.enableTruncate) !== null && _child$props$enableTr !== void 0 ? _child$props$enableTr : false,
|
18511
18605
|
filters: child.props.filters,
|
@@ -18560,7 +18654,7 @@ function useShortcutsListener(table, shortcuts) {
|
|
18560
18654
|
const shortcutKeys = Object.keys(shortcuts !== null && shortcuts !== void 0 ? shortcuts : {});
|
18561
18655
|
const globalHandlers = [];
|
18562
18656
|
// convert the shortcut into the correct format to register it
|
18563
|
-
if (shortcuts && shortcutKeys.length) {
|
18657
|
+
if (shortcuts && shortcutKeys.length && meta.currentRow.currentRowIndex !== undefined) {
|
18564
18658
|
const currentRow = rows[meta.currentRow.currentRowIndex];
|
18565
18659
|
shortcutKeys.forEach(key => {
|
18566
18660
|
const handler = shortcuts[key];
|
@@ -18628,10 +18722,14 @@ function useEditingStateListener(table) {
|
|
18628
18722
|
}, [meta.currentRow.currentRowIndex]);
|
18629
18723
|
// save if editing gets toggled off
|
18630
18724
|
React__default.useEffect(() => {
|
18631
|
-
if (meta.editing.isEnabled
|
18632
|
-
|
18633
|
-
|
18634
|
-
|
18725
|
+
if (meta.editing.isEnabled) {
|
18726
|
+
if (!meta.editing.isEditing) {
|
18727
|
+
requestAnimationFrame(() => {
|
18728
|
+
meta.editing.saveChangesIfNeeded();
|
18729
|
+
});
|
18730
|
+
} else if (meta.currentRow.currentRowIndex === undefined) {
|
18731
|
+
meta.currentRow.setCurrentRowIndex(0);
|
18732
|
+
}
|
18635
18733
|
}
|
18636
18734
|
}, [meta.editing.isEditing]);
|
18637
18735
|
}
|
@@ -18855,6 +18953,7 @@ function useTable$2(props) {
|
|
18855
18953
|
enableFooter: options.enableFooter,
|
18856
18954
|
fontSize,
|
18857
18955
|
hoverState,
|
18956
|
+
isPrinting: props.id.endsWith('_print'),
|
18858
18957
|
isUsingServer: !!props.loadPage,
|
18859
18958
|
printing,
|
18860
18959
|
rowActions: rowActions,
|
@@ -18882,12 +18981,56 @@ function useTable$2(props) {
|
|
18882
18981
|
};
|
18883
18982
|
}
|
18884
18983
|
|
18984
|
+
const FOCUS_MANAGER_OPTIONS = {
|
18985
|
+
tabbable: true
|
18986
|
+
};
|
18885
18987
|
function Row$2(props) {
|
18988
|
+
const focusManager = focus.useFocusManager();
|
18886
18989
|
const tableMeta = props.table.options.meta;
|
18887
18990
|
const isCurrentRow = tableMeta.currentRow.currentRowIndex === props.index;
|
18888
18991
|
const isDraggingRow = tableMeta.rowDrag.dragging[props.row.id];
|
18992
|
+
const isFirstRow = props.index === 0;
|
18889
18993
|
// we use non-css hovered state to determine whether to render actions or not, for performance
|
18890
18994
|
const [isHovered, setIsHovered] = React__default.useState(false);
|
18995
|
+
// tab behaviour is consistent across normal mode and edit mode, handle it here
|
18996
|
+
const handleKeyDown = event => {
|
18997
|
+
if (event.isDefaultPrevented() || event.isPropagationStopped()) {
|
18998
|
+
return;
|
18999
|
+
}
|
19000
|
+
if (event.key === 'Tab') {
|
19001
|
+
tableMeta.hoverState.pause(true);
|
19002
|
+
let focusedElement;
|
19003
|
+
if (event.shiftKey) {
|
19004
|
+
// looping backwards
|
19005
|
+
focusedElement = focusManager.focusPrevious(FOCUS_MANAGER_OPTIONS);
|
19006
|
+
if (focusedElement) {
|
19007
|
+
// override default behaviour, since we're handling focus internally now
|
19008
|
+
event.preventDefault();
|
19009
|
+
} else {
|
19010
|
+
// there are no previous elements to focus, go up a row or go outside the table
|
19011
|
+
if (!isFirstRow) {
|
19012
|
+
event.preventDefault();
|
19013
|
+
tableMeta.currentRow.setCurrentRowIndex(props.index - 1);
|
19014
|
+
setTimeout(() => focusManager.focusLast(FOCUS_MANAGER_OPTIONS), 1);
|
19015
|
+
}
|
19016
|
+
}
|
19017
|
+
} else {
|
19018
|
+
// looping forwards
|
19019
|
+
focusedElement = focusManager.focusNext(FOCUS_MANAGER_OPTIONS);
|
19020
|
+
if (focusedElement) {
|
19021
|
+
// override default behaviour, since we're handling focus internally now
|
19022
|
+
event.preventDefault();
|
19023
|
+
} else {
|
19024
|
+
// there are no next elements to focus, go down a row or go outside the table
|
19025
|
+
if (!props.isLastRow) {
|
19026
|
+
event.preventDefault();
|
19027
|
+
tableMeta.currentRow.setCurrentRowIndex(props.index + 1);
|
19028
|
+
setTimeout(() => focusManager.focusFirst(FOCUS_MANAGER_OPTIONS), 1);
|
19029
|
+
}
|
19030
|
+
}
|
19031
|
+
}
|
19032
|
+
}
|
19033
|
+
};
|
18891
19034
|
// rows are heavily memoized because performance in our table is critical
|
18892
19035
|
// be careful and selective about props that you pass to the row
|
18893
19036
|
const memoedProps = {
|
@@ -18898,12 +19041,13 @@ function Row$2(props) {
|
|
18898
19041
|
draggable: tableMeta.rowDrag.isEnabled,
|
18899
19042
|
index: props.index,
|
18900
19043
|
onClick: tableMeta.rowClick.handleClick,
|
18901
|
-
onDrop: tableMeta.rowDrop.isEnabled ? tableMeta.rowDrop.handleDrop : undefined
|
19044
|
+
onDrop: tableMeta.rowDrop.isEnabled ? tableMeta.rowDrop.handleDrop : undefined,
|
19045
|
+
onKeyDown: handleKeyDown
|
18902
19046
|
};
|
18903
19047
|
let output = /*#__PURE__*/React__default.createElement(MemoedRow, Object.assign({}, props, memoedProps));
|
18904
19048
|
if (tableMeta.editing.isEditing && (isCurrentRow || isHovered && !tableMeta.hoverState.isPaused)) {
|
18905
19049
|
output = /*#__PURE__*/React__default.createElement(EditingRow, Object.assign({}, props, memoedProps, {
|
18906
|
-
|
19050
|
+
isFirstRow: isFirstRow,
|
18907
19051
|
setCurrentRowIndex: tableMeta.currentRow.setCurrentRowIndex
|
18908
19052
|
}));
|
18909
19053
|
}
|
@@ -18943,79 +19087,80 @@ const unhoverPreviousRow = tableRef => {
|
|
18943
19087
|
};
|
18944
19088
|
function EditingRow(props) {
|
18945
19089
|
const {
|
19090
|
+
isFirstRow,
|
18946
19091
|
isLastRow,
|
19092
|
+
onKeyDown,
|
18947
19093
|
setCurrentRowIndex,
|
18948
19094
|
virtualiser,
|
18949
19095
|
...attributes
|
18950
19096
|
} = props;
|
18951
19097
|
const focusManager = focus.useFocusManager();
|
18952
|
-
const focusManagerOptions = {
|
18953
|
-
tabbable: true
|
18954
|
-
};
|
18955
19098
|
const tableMeta = props.table.options.meta;
|
18956
19099
|
const handleClickCapture = event => {
|
18957
19100
|
lastIndex = getColumnIndex(event.target);
|
18958
19101
|
};
|
18959
19102
|
const handleArrowLeftKey = event => {
|
18960
19103
|
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,
|
19104
|
+
if (event.key === 'ArrowLeft') {
|
19105
|
+
// We need to perform special behaviour when focus reaches the end of the row,
|
18964
19106
|
// so we don't need default browser behaviour.
|
18965
19107
|
event.stopPropagation();
|
18966
19108
|
event.preventDefault();
|
18967
19109
|
// "CTRL + ArrowLeft" or "META + ArrowLeft" should focus first focusable element of the row
|
18968
19110
|
if (event.ctrlKey || event.metaKey) {
|
18969
19111
|
event.target.blur();
|
18970
|
-
focusedElement = focusManager.focusFirst(
|
19112
|
+
focusedElement = focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);
|
18971
19113
|
lastIndex = getColumnIndex(focusedElement);
|
18972
19114
|
} 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 {
|
19115
|
+
// looping backwards
|
19116
|
+
focusedElement = focusManager.focusPrevious(FOCUS_MANAGER_OPTIONS);
|
19117
|
+
if (focusedElement) {
|
18986
19118
|
lastIndex = getColumnIndex(focusedElement);
|
19119
|
+
} else {
|
19120
|
+
// there are no previous elements to focus, go up a row (if there are rows above)
|
19121
|
+
if (!isFirstRow) {
|
19122
|
+
event.preventDefault();
|
19123
|
+
tableMeta.hoverState.pause(true);
|
19124
|
+
tableMeta.currentRow.setCurrentRowIndex(props.index - 1);
|
19125
|
+
setTimeout(() => {
|
19126
|
+
focusManager.focusLast(FOCUS_MANAGER_OPTIONS);
|
19127
|
+
// Need to update lastIndex when row got changed and last element got selected.
|
19128
|
+
lastIndex = getColumnIndex(focusedElement);
|
19129
|
+
}, 1);
|
19130
|
+
}
|
18987
19131
|
}
|
18988
19132
|
}
|
18989
19133
|
}
|
18990
19134
|
};
|
18991
19135
|
const handleArrowRightKey = event => {
|
18992
19136
|
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,
|
19137
|
+
if (event.key === 'ArrowRight') {
|
19138
|
+
// We need to perform special behaviour when focus reaches the end of the row,
|
18996
19139
|
// so we don't need default browser behaviour.
|
18997
19140
|
event.stopPropagation();
|
18998
19141
|
event.preventDefault();
|
18999
19142
|
// "CTRL + ArrowRight" or "META + ArrowRight" should focus last focusable element of the row
|
19000
19143
|
if (event.ctrlKey || event.metaKey) {
|
19001
19144
|
event.target.blur();
|
19002
|
-
focusedElement = focusManager.focusLast(
|
19145
|
+
focusedElement = focusManager.focusLast(FOCUS_MANAGER_OPTIONS);
|
19003
19146
|
lastIndex = getColumnIndex(focusedElement);
|
19004
19147
|
} 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 {
|
19148
|
+
// looping forwards
|
19149
|
+
focusedElement = focusManager.focusNext(FOCUS_MANAGER_OPTIONS);
|
19150
|
+
if (focusedElement) {
|
19018
19151
|
lastIndex = getColumnIndex(focusedElement);
|
19152
|
+
} else {
|
19153
|
+
// there are no next elements to focus, go down a row or go outside the table
|
19154
|
+
if (!props.isLastRow) {
|
19155
|
+
event.preventDefault();
|
19156
|
+
tableMeta.hoverState.pause(true);
|
19157
|
+
tableMeta.currentRow.setCurrentRowIndex(props.index + 1);
|
19158
|
+
setTimeout(() => {
|
19159
|
+
focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);
|
19160
|
+
// Need to update lastIndex when row got changed and last element got selected.
|
19161
|
+
lastIndex = getColumnIndex(focusedElement);
|
19162
|
+
}, 1);
|
19163
|
+
}
|
19019
19164
|
}
|
19020
19165
|
}
|
19021
19166
|
}
|
@@ -19030,6 +19175,7 @@ function EditingRow(props) {
|
|
19030
19175
|
if (event.isDefaultPrevented() || event.isPropagationStopped() || tableMeta.editing.detailModeEditing) {
|
19031
19176
|
return;
|
19032
19177
|
}
|
19178
|
+
onKeyDown(event); // handles tab behaviour
|
19033
19179
|
handleArrowLeftKey(event);
|
19034
19180
|
handleArrowRightKey(event);
|
19035
19181
|
};
|
@@ -19041,7 +19187,7 @@ function EditingRow(props) {
|
|
19041
19187
|
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
19188
|
lastIndexCell === null || lastIndexCell === void 0 ? void 0 : (_lastIndexCell$queryS = lastIndexCell.querySelector(focusableSelector)) === null || _lastIndexCell$queryS === void 0 ? void 0 : _lastIndexCell$queryS.focus();
|
19043
19189
|
} else {
|
19044
|
-
focusManager.focusFirst(
|
19190
|
+
focusManager.focusFirst(FOCUS_MANAGER_OPTIONS);
|
19045
19191
|
}
|
19046
19192
|
}
|
19047
19193
|
// Need to subscribe to current row index and check is it a current row,
|
@@ -20333,8 +20479,18 @@ function PrintButton(props) {
|
|
20333
20479
|
columnFilters: state.columnFilters,
|
20334
20480
|
globalFilter: state.globalFilter
|
20335
20481
|
}), [tableMeta.columnFreezing.frozenColumnIndex, state.columnOrder, state.columnSizing, state.columnVisibility, excludeUnmatchedResults, tableMeta.fontSize.size, tableMeta.rowHeight.height, state.sorting, state.columnFilters, state.globalFilter]);
|
20482
|
+
const iframeTableChildren = React__default.useMemo(() => React__default.Children.toArray(tableProps.children).filter(child => {
|
20483
|
+
var _child$props;
|
20484
|
+
const enableColumnInPrinting = (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.enablePrinting;
|
20485
|
+
// For table children, only include columns doesn't have 'false' value for enablePrinting prop.
|
20486
|
+
if ( /*#__PURE__*/React__default.isValidElement(child) && enableColumnInPrinting === false) {
|
20487
|
+
return false;
|
20488
|
+
}
|
20489
|
+
return true;
|
20490
|
+
}), [tableProps.children]);
|
20336
20491
|
const iframeTableProps = {
|
20337
20492
|
...tableProps,
|
20493
|
+
children: iframeTableChildren,
|
20338
20494
|
defaultSettings,
|
20339
20495
|
id: printTableId
|
20340
20496
|
};
|
@@ -20767,7 +20923,7 @@ function Summary$1(props) {
|
|
20767
20923
|
}
|
20768
20924
|
|
20769
20925
|
// we cannot just use a fixed height because our rows need to grow in height (images, edit mode validation etc)
|
20770
|
-
const
|
20926
|
+
const getCellHeightPadding = (height, fontSize) => {
|
20771
20927
|
// TODO: can we get the rem values from tailwind
|
20772
20928
|
switch (height) {
|
20773
20929
|
case 'short':
|
@@ -20816,9 +20972,22 @@ const getRowHeightSizing = (height, fontSize) => {
|
|
20816
20972
|
}
|
20817
20973
|
}
|
20818
20974
|
};
|
20975
|
+
const getCellWidthPadding = fontSize => {
|
20976
|
+
switch (fontSize) {
|
20977
|
+
case 'small':
|
20978
|
+
return '8px';
|
20979
|
+
case 'medium':
|
20980
|
+
return '12px';
|
20981
|
+
default:
|
20982
|
+
return '16px';
|
20983
|
+
// py-1.5
|
20984
|
+
}
|
20985
|
+
};
|
20986
|
+
|
20819
20987
|
const useCssVars = (height, fontSize) => {
|
20820
20988
|
const style = {
|
20821
|
-
'--table3-
|
20989
|
+
'--table3-cell-padding-x': getCellWidthPadding(fontSize),
|
20990
|
+
'--table3-cell-padding-y': getCellHeightPadding(height, fontSize)
|
20822
20991
|
};
|
20823
20992
|
return {
|
20824
20993
|
style
|
@@ -20991,7 +21160,7 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
20991
21160
|
return;
|
20992
21161
|
}
|
20993
21162
|
tableMeta.hoverState.handleKeyDown(event);
|
20994
|
-
tableMeta.currentRow.handleKeyDown(event, table.getRowModel().rows.length, scrollToIndex);
|
21163
|
+
tableMeta.currentRow.handleKeyDown(event, table.getRowModel().rows.length, scrollToIndex, tableMeta.editing.isEditing, internalRef);
|
20995
21164
|
tableMeta.rowClick.handleKeyDown(event, table);
|
20996
21165
|
tableMeta.rowSelection.handleKeyDown(event, table);
|
20997
21166
|
tableMeta.editing.handleKeyDown(event);
|
@@ -21004,10 +21173,13 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21004
21173
|
// See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143
|
21005
21174
|
// scrollToIndex function changes when row count changes, so it is important to update handlers with new
|
21006
21175
|
// scrollToIndex function.
|
21007
|
-
[scrollToIndex, internalRef.current]);
|
21176
|
+
[scrollToIndex, tableMeta.editing.isEditing, internalRef.current]);
|
21008
21177
|
const handleBlur = event => {
|
21009
21178
|
tableMeta.editing.handleBlur(event);
|
21010
21179
|
};
|
21180
|
+
const handleFocus = event => {
|
21181
|
+
tableMeta.currentRow.handleFocus(event, table.getRowModel().rows.length, scrollToIndex);
|
21182
|
+
};
|
21011
21183
|
const handleScroll = function (event) {
|
21012
21184
|
try {
|
21013
21185
|
tableMeta.columnFreezing.handleScroll(event);
|
@@ -21016,7 +21188,7 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21016
21188
|
return Promise.reject(e);
|
21017
21189
|
}
|
21018
21190
|
};
|
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', {
|
21191
|
+
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
21192
|
'text-xs': tableMeta.fontSize.size === 'small',
|
21021
21193
|
'text-sm': tableMeta.fontSize.size === 'medium',
|
21022
21194
|
'text-base': tableMeta.fontSize.size === 'large'
|
@@ -21025,7 +21197,7 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21025
21197
|
// if the table is a print table or not.
|
21026
21198
|
const {
|
21027
21199
|
style: cssGridStyle
|
21028
|
-
} = useCssGrid(table,
|
21200
|
+
} = useCssGrid(table, tableMeta.isPrinting);
|
21029
21201
|
const {
|
21030
21202
|
style: cssVars
|
21031
21203
|
} = useCssVars(tableMeta.rowHeight.height, tableMeta.fontSize.size);
|
@@ -21057,10 +21229,12 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21057
21229
|
"data-resizing": !!state.columnSizingInfo.isResizingColumn,
|
21058
21230
|
"data-taco": "table2",
|
21059
21231
|
onBlur: handleBlur,
|
21232
|
+
onFocus: handleFocus,
|
21060
21233
|
onScroll: handleScroll,
|
21061
21234
|
ref: internalRef,
|
21062
21235
|
role: "table",
|
21063
|
-
style: style
|
21236
|
+
style: style,
|
21237
|
+
tabIndex: -1
|
21064
21238
|
}, isServerLoadingAndNotReady ? null : /*#__PURE__*/React__default.createElement("div", {
|
21065
21239
|
className: "group/header contents",
|
21066
21240
|
"data-taco": "table2-header",
|
@@ -21074,7 +21248,9 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
21074
21248
|
}, reactTable$1.flexRender(header.column.columnDef.header, {
|
21075
21249
|
...header.getContext(),
|
21076
21250
|
scrollToIndex
|
21077
|
-
})))))), table.getRowModel().rows.length ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(focus.FocusScope,
|
21251
|
+
})))))), table.getRowModel().rows.length ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(focus.FocusScope, {
|
21252
|
+
autoFocus: tableMeta.editing.isEditing
|
21253
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
21078
21254
|
className: "group/body contents",
|
21079
21255
|
"data-taco": "table2-body",
|
21080
21256
|
role: "rowgroup",
|