@economic/taco 2.43.0 → 2.44.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Report/Report.d.ts +1 -1
- package/dist/components/Table3/features/useTableEditing.d.ts +8 -8
- package/dist/esm/index.css +44 -22
- package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js +7 -1
- package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js +3 -2
- package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +6 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/util.js +4 -3
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +17 -3
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +1 -11
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +7 -5
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +36 -47
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +9 -0
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tooltip/Tooltip.js +1 -1
- package/dist/esm/packages/taco/src/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +0 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +1 -8
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +85 -109
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js +4 -9
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +12 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js +1 -7
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js +17 -10
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +4 -6
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/index.css +44 -22
- package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +1 -2
- package/dist/primitives/Table/types.d.ts +0 -1
- package/dist/primitives/Table/useTableManager/util/columns.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/util/search.d.ts +2 -2
- package/dist/taco.cjs.development.js +219 -228
- 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/package.json +2 -2
package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Actions.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext as ReactTableCellContext, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { IconButton } from '../../../../../../components/IconButton/IconButton';\nimport { Menu } from '../../../../../../components/Menu/Menu';\nimport { Shortcut } from '../../../../../../components/Shortcut/Shortcut';\nimport {
|
1
|
+
{"version":3,"file":"Actions.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext as ReactTableCellContext, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { IconButton } from '../../../../../../components/IconButton/IconButton';\nimport { Menu } from '../../../../../../components/Menu/Menu';\nimport { Shortcut } from '../../../../../../components/Shortcut/Shortcut';\nimport { TableRowActionRenderer } from '../../../../types';\nimport { RowContext } from '../../Row/RowContext';\nimport { useTableManagerInternalColumn } from '../../../../useTableManager/types';\n\nexport type ActionsProps<TType = unknown> = {\n actions: TableRowActionRenderer<TType>[];\n actionsLength: number;\n data: any;\n isActiveRow: boolean;\n rowId: string;\n};\nexport function Actions<TType = unknown>(props: ActionsProps<TType>) {\n const { actions, actionsLength, data, isActiveRow, rowId } = props;\n const { texts } = useLocalization();\n const visibleActions = actions.map(action => action(data, rowId)).filter(action => !!action) as JSX.Element[];\n\n const actionsOnRow = visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);\n const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);\n\n const className = cn(\n 'flex justify-end text-right bg-[inherit] shadow-[-6px_0px_6px_var(--table-row-actions-shadow)] print:hidden'\n );\n\n return (\n <span className={className}>\n {actionsOnRow.map((button, index) => {\n const tooltip = String(button.props.tooltip ?? button.props['aria-label'] ?? '');\n\n return React.cloneElement(button, {\n appearance: 'transparent',\n key: index,\n tabIndex: isActiveRow ? 0 : -1,\n tooltip: button.props.shortcut ? (\n <>\n {tooltip}\n <Shortcut className=\"ml-2\" keys={button.props.shortcut} />\n </>\n ) : (\n tooltip\n ),\n });\n })}\n {actionsInMenu.length ? (\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table.columns.actions.tooltip}\n icon=\"more\"\n tabIndex={isActiveRow ? 0 : -1}\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n {actionsInMenu.map((action, i) => (\n <Menu.Item key={i} {...action.props} shortcut={action.props.shortcut}>\n {action.props['aria-label']}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu>\n )}\n />\n ) : null}\n </span>\n );\n}\n\nfunction Header() {\n return null;\n}\n\nconst Cell = React.memo(function MemoedCell<TType = unknown>(context: ReactTableCellContext<TType, unknown>) {\n const { row, table } = context;\n const { isHovered, rowIndex } = React.useContext(RowContext);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const actions = tableMeta.rowActions.rowActions;\n const actionsLength = tableMeta.rowActions.rowActionsLength;\n\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === rowIndex;\n const isResizingColumn = !!table.getState().columnSizingInfo.isResizingColumn;\n const isHoverStatePaused = tableMeta.rowActive.isHoverStatePaused;\n\n // We don't want to show actions in edit mode, since we have editing actions,\n // which is shown in edit mode instead.\n if (actions?.length && (isActiveRow || (isHovered && !isHoverStatePaused && !isResizingColumn))) {\n return (\n <Actions\n actions={actions}\n actionsLength={actionsLength}\n data={row.original}\n isActiveRow={isActiveRow}\n rowId={row.id}\n />\n );\n }\n\n return null;\n}) as <TType = unknown>(context: ReactTableCellContext<TType, unknown>) => JSX.Element;\n\nexport const renderer: useTableManagerInternalColumn = {\n header: Header,\n renderer: Cell,\n meta: {\n align: 'right',\n className: cn(\n 'print:opacity-0 !px-0 !pr-1 overflow-hidden [table_&]:group-[[data-row-active=\"true\"]]/row:sticky right-0',\n 'group-[[data-row-active=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-row-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-row-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n // TODO: remove when table3 is migrated, this satisfies the legacy table3 type\n enableSearch: false,\n header: '',\n },\n};\n"],"names":["Actions","props","actions","actionsLength","data","isActiveRow","rowId","texts","useLocalization","visibleActions","map","action","filter","actionsOnRow","length","slice","actionsInMenu","className","cn","React","button","index","tooltip","String","_ref","_button$props$tooltip","cloneElement","appearance","key","tabIndex","shortcut","Shortcut","keys","IconButton","table","columns","icon","menu","menuProps","Menu","Content","i","Item","Header","Cell","memo","MemoedCell","context","row","isHovered","rowIndex","useContext","RowContext","tableMeta","options","meta","rowActions","rowActionsLength","rowActive","rowActiveIndex","isResizingColumn","getState","columnSizingInfo","isHoverStatePaused","original","id","renderer","header","align","enableSearch"],"mappings":";;;;;;;;SAkBgBA,OAAOA,CAAkBC,KAA0B;EAC/D,MAAM;IAAEC,OAAO;IAAEC,aAAa;IAAEC,IAAI;IAAEC,WAAW;IAAEC;GAAO,GAAGL,KAAK;EAClE,MAAM;IAAEM;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,SAAS,CAACK,SAAS,CAACK,kBAAkB;;;EAIjE,IAAI7D,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEY,MAAM,KAAKT,WAAW,IAAK4C,SAAS,IAAI,CAACc,kBAAkB,IAAI,CAACH,gBAAiB,CAAC,EAAE;IAC7F,oBACIzC,6BAACnB,OAAO;MACJE,OAAO,EAAEA,OAAO;MAChBC,aAAa,EAAEA,aAAa;MAC5BC,IAAI,EAAE4C,GAAG,CAACgB,QAAQ;MAClB3D,WAAW,EAAEA,WAAW;MACxBC,KAAK,EAAE0C,GAAG,CAACiB;MACb;;EAIV,OAAO,IAAI;AACf,CAAC,CAAqF;MAEzEC,QAAQ,GAAkC;EACnDC,MAAM,EAAExB,MAAM;EACduB,QAAQ,EAAEtB,IAAI;EACdW,IAAI,EAAE;IACFa,KAAK,EAAE,OAAO;IACdnD,SAAS,eAAEC,EAAE,CACT,2GAA2G,EAC3G,2EAA2E,EAC3E,sDAAsD,EACtD,6DAA6D,CAChE;;IAEDmD,YAAY,EAAE,KAAK;IACnBF,MAAM,EAAE;;;;;;"}
|
package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
-
import cn from 'clsx';
|
3
2
|
import { Tooltip } from '../../../../../../components/Tooltip/Tooltip.js';
|
4
3
|
import { useLocalization } from '../../../../../../components/Provider/Localization.js';
|
5
4
|
import { Checkbox } from '../../../../../../components/Checkbox/Checkbox.js';
|
6
5
|
import { Shortcut } from '../../../../../../components/Shortcut/Shortcut.js';
|
7
|
-
import { getRadioClassnames } from '../../../../../../components/RadioGroup/util.js';
|
8
6
|
import { TableServerLoadAllState } from '../../../../types.js';
|
9
7
|
import { RowContext } from '../../Row/RowContext.js';
|
10
8
|
|
@@ -16,39 +14,36 @@ function Header(context) {
|
|
16
14
|
table
|
17
15
|
} = context;
|
18
16
|
const tableMeta = table.options.meta;
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
table.toggleAllRowsSelected(checked);
|
27
|
-
}
|
28
|
-
const _temp = function () {
|
29
|
-
if (tableMeta.server.loadAllIfNeeded) {
|
30
|
-
// don't pass the search query because we need all data - not filtered data
|
31
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
32
|
-
}
|
33
|
-
}();
|
34
|
-
// load all data if that is possible
|
35
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
36
|
-
} catch (e) {
|
37
|
-
return Promise.reject(e);
|
17
|
+
const isAllRowsSelected = table.getIsAllRowsSelected();
|
18
|
+
const isSomeRowsSelected = table.getIsSomeRowsSelected();
|
19
|
+
const title = isAllRowsSelected ? texts.table.columns.select.deselectAll : texts.table.columns.select.selectAll;
|
20
|
+
const handleChange = function (checked) {
|
21
|
+
try {
|
22
|
+
function _temp2() {
|
23
|
+
table.toggleAllRowsSelected(checked);
|
38
24
|
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}
|
50
|
-
}
|
51
|
-
return
|
25
|
+
const _temp = function () {
|
26
|
+
if (tableMeta.server.loadAllIfNeeded) {
|
27
|
+
// don't pass the search query because we need all data - not filtered data
|
28
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
29
|
+
}
|
30
|
+
}();
|
31
|
+
// load all data if that is possible
|
32
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
33
|
+
} catch (e) {
|
34
|
+
return Promise.reject(e);
|
35
|
+
}
|
36
|
+
};
|
37
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
38
|
+
title: title
|
39
|
+
}, /*#__PURE__*/React__default.createElement(Checkbox, {
|
40
|
+
"aria-label": title,
|
41
|
+
className: "hover:border-blue !-mt-px",
|
42
|
+
checked: isAllRowsSelected,
|
43
|
+
indeterminate: isSomeRowsSelected && !isAllRowsSelected,
|
44
|
+
loading: tableMeta.server.loadAllStatus === TableServerLoadAllState.Loading,
|
45
|
+
onChange: handleChange
|
46
|
+
}));
|
52
47
|
}
|
53
48
|
const toggleBetween = (fromRowIndex, toRowIndex) => {
|
54
49
|
const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;
|
@@ -74,83 +69,64 @@ function Cell(context) {
|
|
74
69
|
const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();
|
75
70
|
const canSelect = row.getCanSelect();
|
76
71
|
const title = isSelected ? texts.table.columns.select.deselect : texts.table.columns.select.select;
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;
|
82
|
-
}
|
83
|
-
event.stopPropagation();
|
84
|
-
const _temp6 = function () {
|
85
|
-
if (row.getIsGrouped()) {
|
86
|
-
row.subRows.forEach(row => row.toggleSelected());
|
87
|
-
} else {
|
88
|
-
const _temp5 = function () {
|
89
|
-
if (event.shiftKey) {
|
90
|
-
var _tableMeta$rowSelecti;
|
91
|
-
function _temp4() {
|
92
|
-
table.setRowSelection(currentRowSelection => ({
|
93
|
-
...currentRowSelection,
|
94
|
-
...selectedRows.filter(row => row.getCanSelect()).reduce((state, row) => ({
|
95
|
-
...state,
|
96
|
-
[row.id]: true
|
97
|
-
}), {})
|
98
|
-
}));
|
99
|
-
}
|
100
|
-
const [fromIndex, toIndex] = toggleBetween((_tableMeta$rowSelecti = tableMeta.rowSelection.lastSelectedRowIndex.current) !== null && _tableMeta$rowSelecti !== void 0 ? _tableMeta$rowSelecti : 0, rowIndex);
|
101
|
-
const selectedRows = table.getRowModel().rows.slice(fromIndex, toIndex + 1);
|
102
|
-
const _temp3 = function () {
|
103
|
-
if (tableMeta.server.loadAllIfNeeded && selectedRows.some(row => row.original === undefined)) {
|
104
|
-
// don't pass the search query because we need all data - not filtered data
|
105
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
106
|
-
}
|
107
|
-
}();
|
108
|
-
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
109
|
-
} else {
|
110
|
-
row.toggleSelected();
|
111
|
-
}
|
112
|
-
}();
|
113
|
-
if (_temp5 && _temp5.then) return _temp5.then(function () {});
|
114
|
-
}
|
115
|
-
}();
|
116
|
-
return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6));
|
117
|
-
} catch (e) {
|
118
|
-
return Promise.reject(e);
|
72
|
+
const handleClick = function (event) {
|
73
|
+
try {
|
74
|
+
function _temp7() {
|
75
|
+
tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;
|
119
76
|
}
|
120
|
-
};
|
121
|
-
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
122
|
-
hidden: !canSelect,
|
123
|
-
title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, title, /*#__PURE__*/React__default.createElement(Shortcut, {
|
124
|
-
className: "ml-2",
|
125
|
-
keys: "Space"
|
126
|
-
}))
|
127
|
-
}, /*#__PURE__*/React__default.createElement(Checkbox, {
|
128
|
-
"aria-label": title,
|
129
|
-
className: "!mt-0",
|
130
|
-
checked: isSelected,
|
131
|
-
onClick: handleClick,
|
132
|
-
disabled: !canSelect,
|
133
|
-
// this is necessary to remove console spam from eslint
|
134
|
-
onChange: () => false
|
135
|
-
}));
|
136
|
-
} else {
|
137
|
-
const className = cn('!mt-0', getRadioClassnames(!canSelect));
|
138
|
-
const handleClick = event => {
|
139
77
|
event.stopPropagation();
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
78
|
+
const _temp6 = function () {
|
79
|
+
if (row.getIsGrouped()) {
|
80
|
+
row.subRows.forEach(row => row.toggleSelected());
|
81
|
+
} else {
|
82
|
+
const _temp5 = function () {
|
83
|
+
if (event.shiftKey) {
|
84
|
+
var _tableMeta$rowSelecti;
|
85
|
+
function _temp4() {
|
86
|
+
table.setRowSelection(currentRowSelection => ({
|
87
|
+
...currentRowSelection,
|
88
|
+
...selectedRows.filter(row => row.getCanSelect()).reduce((state, row) => ({
|
89
|
+
...state,
|
90
|
+
[row.id]: true
|
91
|
+
}), {})
|
92
|
+
}));
|
93
|
+
}
|
94
|
+
const [fromIndex, toIndex] = toggleBetween((_tableMeta$rowSelecti = tableMeta.rowSelection.lastSelectedRowIndex.current) !== null && _tableMeta$rowSelecti !== void 0 ? _tableMeta$rowSelecti : 0, rowIndex);
|
95
|
+
const selectedRows = table.getRowModel().rows.slice(fromIndex, toIndex + 1);
|
96
|
+
const _temp3 = function () {
|
97
|
+
if (tableMeta.server.loadAllIfNeeded && selectedRows.some(row => row.original === undefined)) {
|
98
|
+
// don't pass the search query because we need all data - not filtered data
|
99
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
100
|
+
}
|
101
|
+
}();
|
102
|
+
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
103
|
+
} else {
|
104
|
+
row.toggleSelected();
|
105
|
+
}
|
106
|
+
}();
|
107
|
+
if (_temp5 && _temp5.then) return _temp5.then(function () {});
|
108
|
+
}
|
109
|
+
}();
|
110
|
+
return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6));
|
111
|
+
} catch (e) {
|
112
|
+
return Promise.reject(e);
|
113
|
+
}
|
114
|
+
};
|
115
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
116
|
+
hidden: !canSelect,
|
117
|
+
title: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, title, /*#__PURE__*/React__default.createElement(Shortcut, {
|
118
|
+
className: "ml-2",
|
119
|
+
keys: "Space"
|
120
|
+
}))
|
121
|
+
}, /*#__PURE__*/React__default.createElement(Checkbox, {
|
122
|
+
"aria-label": title,
|
123
|
+
className: "!mt-0",
|
124
|
+
checked: isSelected,
|
125
|
+
onClick: handleClick,
|
126
|
+
disabled: !canSelect,
|
127
|
+
// this is necessary to remove console spam from eslint
|
128
|
+
onChange: () => false
|
129
|
+
}));
|
154
130
|
}
|
155
131
|
const renderer = {
|
156
132
|
header: Header,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Selection.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Internal/Selection.tsx"],"sourcesContent":["import React from 'react';\nimport {\n HeaderContext as ReactTableHeaderContext,\n CellContext as ReactTableCellContext,\n TableMeta as ReactTableMeta,\n RowSelectionState,\n} from '@tanstack/react-table';\nimport cn from 'clsx';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { Tooltip } from '../../../../../../components/Tooltip/Tooltip';\nimport { Checkbox } from '../../../../../../components/Checkbox/Checkbox';\nimport { Shortcut } from '../../../../../../components/Shortcut/Shortcut';\nimport { getRadioClassnames } from '../../../../../../components/RadioGroup/util';\nimport { TableServerLoadAllState } from '../../../../types';\nimport { RowContext } from '../../Row/RowContext';\nimport { useTableManagerInternalColumn } from '../../../../useTableManager/types';\n\nfunction Header<TType = unknown>(context: ReactTableHeaderContext<TType, unknown>) {\n const { texts } = useLocalization();\n const { table } = context;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (table.options.enableMultiRowSelection) {\n const isAllRowsSelected = table.getIsAllRowsSelected();\n const isSomeRowsSelected = table.getIsSomeRowsSelected();\n const title = isAllRowsSelected ? texts.table.columns.select.deselectAll : texts.table.columns.select.selectAll;\n\n const handleChange = async (checked: boolean) => {\n // load all data if that is possible\n if (tableMeta.server.loadAllIfNeeded) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n\n table.toggleAllRowsSelected(checked);\n };\n\n return (\n <Tooltip title={title}>\n <Checkbox\n aria-label={title}\n className=\"hover:border-blue !-mt-px\"\n checked={isAllRowsSelected}\n indeterminate={isSomeRowsSelected && !isAllRowsSelected}\n loading={tableMeta.server.loadAllStatus === TableServerLoadAllState.Loading}\n onChange={handleChange}\n />\n </Tooltip>\n );\n }\n\n return null;\n}\n\nconst toggleBetween = (fromRowIndex: number, toRowIndex: number): [number, number] => {\n const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;\n const toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;\n\n return [fromIndex, toIndex];\n};\n\nfunction Cell<TType = unknown>(context: ReactTableCellContext<TType, unknown>) {\n const { texts } = useLocalization();\n const { row, table } = context;\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (table.options.enableGrouping && table.getState().grouping?.length && !row.getIsGrouped()) {\n return null;\n }\n\n const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();\n const canSelect = row.getCanSelect();\n const title = isSelected ? texts.table.columns.select.deselect : texts.table.columns.select.select;\n\n if (table.options.enableMultiRowSelection) {\n const handleClick = async (event: React.MouseEvent) => {\n event.stopPropagation();\n\n if (row.getIsGrouped()) {\n row.subRows.forEach(row => row.toggleSelected());\n } else if (event.shiftKey) {\n const [fromIndex, toIndex] = toggleBetween(tableMeta.rowSelection.lastSelectedRowIndex.current ?? 0, rowIndex);\n const selectedRows = table.getRowModel().rows.slice(fromIndex, toIndex + 1);\n\n if (tableMeta.server.loadAllIfNeeded && selectedRows.some(row => row.original === undefined)) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n\n table.setRowSelection((currentRowSelection: RowSelectionState) => ({\n ...currentRowSelection,\n ...selectedRows.filter(row => row.getCanSelect()).reduce((state, row) => ({ ...state, [row.id]: true }), {}),\n }));\n } else {\n row.toggleSelected();\n }\n\n tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;\n };\n\n return (\n <Tooltip\n hidden={!canSelect}\n title={\n <>\n {title}\n <Shortcut className=\"ml-2\" keys=\"Space\" />\n </>\n }>\n <Checkbox\n aria-label={title}\n className=\"!mt-0\"\n checked={isSelected}\n onClick={handleClick}\n disabled={!canSelect}\n // this is necessary to remove console spam from eslint\n onChange={() => false}\n />\n </Tooltip>\n );\n } else {\n const className = cn('!mt-0', getRadioClassnames(!canSelect));\n\n const handleClick = (event: React.MouseEvent): void => {\n event.stopPropagation();\n row.toggleSelected();\n tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;\n };\n\n return (\n <button\n className={className}\n aria-checked={canSelect && isSelected}\n disabled={!canSelect}\n onClick={handleClick}\n role=\"radio\"\n type=\"button\">\n {isSelected ? <span className=\"h-2 w-2 rounded-full bg-white\" /> : null}\n </button>\n );\n }\n}\n\nexport const renderer: useTableManagerInternalColumn = {\n header: Header,\n renderer: Cell,\n size: 40,\n meta: {\n align: 'center',\n className: '!px-1',\n // TODO: remove when table3 is migrated, this satisfies the legacy table3 type\n enableSearch: false,\n header: '',\n headerClassName: '!px-1',\n },\n};\n"],"names":["Header","context","texts","useLocalization","table","tableMeta","options","meta","enableMultiRowSelection","isAllRowsSelected","getIsAllRowsSelected","isSomeRowsSelected","getIsSomeRowsSelected","title","columns","select","deselectAll","selectAll","handleChange","checked","toggleAllRowsSelected","_temp","server","loadAllIfNeeded","Promise","resolve","getState","sorting","columnFilters","then","_temp2","e","reject","React","Tooltip","Checkbox","className","indeterminate","loading","loadAllStatus","TableServerLoadAllState","Loading","onChange","toggleBetween","fromRowIndex","toRowIndex","fromIndex","toIndex","Cell","row","rowIndex","useContext","RowContext","enableGrouping","_table$getState$group","grouping","length","getIsGrouped","isSelected","getIsAllSubRowsSelected","getIsSelected","canSelect","getCanSelect","deselect","handleClick","event","rowSelection","lastSelectedRowIndex","current","index","stopPropagation","_temp6","subRows","forEach","toggleSelected","_temp5","shiftKey","_tableMeta$rowSelecti","_temp4","setRowSelection","currentRowSelection","selectedRows","filter","reduce","state","id","getRowModel","rows","slice","_temp3","some","original","undefined","_temp7","hidden","Shortcut","keys","onClick","disabled","cn","getRadioClassnames","role","type","renderer","header","size","align","enableSearch","headerClassName"],"mappings":";;;;;;;;;;AAiBA,SAASA,MAAMA,CAAkBC,OAAgD;EAC7E,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM;IAAEC;GAAO,GAAGH,OAAO;EACzB,MAAMI,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAE7D,IAAIH,KAAK,CAACE,OAAO,CAACE,uBAAuB,EAAE;IACvC,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,oBAAoB,EAAE;IACtD,MAAMC,kBAAkB,GAAGP,KAAK,CAACQ,qBAAqB,EAAE;IACxD,MAAMC,KAAK,GAAGJ,iBAAiB,GAAGP,KAAK,CAACE,KAAK,CAACU,OAAO,CAACC,MAAM,CAACC,WAAW,GAAGd,KAAK,CAACE,KAAK,CAACU,OAAO,CAACC,MAAM,CAACE,SAAS;IAE/G,MAAMC,YAAY,aAAUC,OAAgB;MAAA;;UAOxCf,KAAK,CAACgB,qBAAqB,CAACD,OAAO,CAAC;;QAAC,MAAAE,KAAA;UAAA,IALjChB,SAAS,CAACiB,MAAM,CAACC,eAAe;;YAChC,OAAAC,OAAA,CAAAC,OAAA,CACMpB,SAAS,CAACiB,MAAM,CAACC,eAAe,CAACnB,KAAK,CAACsB,QAAQ,EAAE,CAACC,OAAO,EAAEvB,KAAK,CAACsB,QAAQ,EAAE,CAACE,aAAa,CAAC,EAAAC,IAAA;;;;QAHpG,OAAAL,OAAA,CAAAC,OAAA,CAAAJ,KAAA,IAAAA,KAAA,CAAAQ,IAAA,GAAAR,KAAA,CAAAQ,IAAA,CAA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C,WAAW;MACpBkC,QAAQ,EAAE,CAACrC,SAAS;;MAEpBnB,QAAQ,EAAEA,MAAM;MAClB,CACI;GAEjB,MAAM;IACH,MAAMN,SAAS,GAAG+D,EAAE,CAAC,OAAO,EAAEC,kBAAkB,CAAC,CAACvC,SAAS,CAAC,CAAC;IAE7D,MAAMG,WAAW,GAAIC,KAAuB;MACxCA,KAAK,CAACK,eAAe,EAAE;MACvBrB,GAAG,CAACyB,cAAc,EAAE;MACpBrE,SAAS,CAAC6D,YAAY,CAACC,oBAAoB,CAACC,OAAO,GAAGnB,GAAG,CAACoB,KAAK;KAClE;IAED,oBACIpC;MACIG,SAAS,EAAEA,SAAS;sBACNyB,SAAS,IAAIH,UAAU;MACrCwC,QAAQ,EAAE,CAACrC,SAAS;MACpBoC,OAAO,EAAEjC,WAAW;MACpBqC,IAAI,EAAC,OAAO;MACZC,IAAI,EAAC;OACJ5C,UAAU,gBAAGzB;MAAMG,SAAS,EAAC;MAAkC,GAAG,IAAI,CAClE;;AAGrB;MAEamE,QAAQ,GAAkC;EACnDC,MAAM,EAAExG,MAAM;EACduG,QAAQ,EAAEvD,IAAI;EACdyD,IAAI,EAAE,EAAE;EACRlG,IAAI,EAAE;IACFmG,KAAK,EAAE,QAAQ;IACftE,SAAS,EAAE,OAAO;;IAElBuE,YAAY,EAAE,KAAK;IACnBH,MAAM,EAAE,EAAE;IACVI,eAAe,EAAE;;;;;;"}
|
1
|
+
{"version":3,"file":"Selection.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Columns/Internal/Selection.tsx"],"sourcesContent":["import React from 'react';\nimport {\n HeaderContext as ReactTableHeaderContext,\n CellContext as ReactTableCellContext,\n TableMeta as ReactTableMeta,\n RowSelectionState,\n} from '@tanstack/react-table';\nimport { useLocalization } from '../../../../../../components/Provider/Localization';\nimport { Tooltip } from '../../../../../../components/Tooltip/Tooltip';\nimport { Checkbox } from '../../../../../../components/Checkbox/Checkbox';\nimport { Shortcut } from '../../../../../../components/Shortcut/Shortcut';\nimport { TableServerLoadAllState } from '../../../../types';\nimport { RowContext } from '../../Row/RowContext';\nimport { useTableManagerInternalColumn } from '../../../../useTableManager/types';\n\nfunction Header<TType = unknown>(context: ReactTableHeaderContext<TType, unknown>) {\n const { texts } = useLocalization();\n const { table } = context;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n const isAllRowsSelected = table.getIsAllRowsSelected();\n const isSomeRowsSelected = table.getIsSomeRowsSelected();\n const title = isAllRowsSelected ? texts.table.columns.select.deselectAll : texts.table.columns.select.selectAll;\n\n const handleChange = async (checked: boolean) => {\n // load all data if that is possible\n if (tableMeta.server.loadAllIfNeeded) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n\n table.toggleAllRowsSelected(checked);\n };\n\n return (\n <Tooltip title={title}>\n <Checkbox\n aria-label={title}\n className=\"hover:border-blue !-mt-px\"\n checked={isAllRowsSelected}\n indeterminate={isSomeRowsSelected && !isAllRowsSelected}\n loading={tableMeta.server.loadAllStatus === TableServerLoadAllState.Loading}\n onChange={handleChange}\n />\n </Tooltip>\n );\n}\n\nconst toggleBetween = (fromRowIndex: number, toRowIndex: number): [number, number] => {\n const fromIndex = toRowIndex < fromRowIndex ? toRowIndex : fromRowIndex;\n const toIndex = toRowIndex > fromRowIndex ? toRowIndex : fromRowIndex;\n\n return [fromIndex, toIndex];\n};\n\nfunction Cell<TType = unknown>(context: ReactTableCellContext<TType, unknown>) {\n const { texts } = useLocalization();\n const { row, table } = context;\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (table.options.enableGrouping && table.getState().grouping?.length && !row.getIsGrouped()) {\n return null;\n }\n\n const isSelected = row.getIsGrouped() ? row.getIsAllSubRowsSelected() : row.getIsSelected();\n const canSelect = row.getCanSelect();\n const title = isSelected ? texts.table.columns.select.deselect : texts.table.columns.select.select;\n\n const handleClick = async (event: React.MouseEvent) => {\n event.stopPropagation();\n\n if (row.getIsGrouped()) {\n row.subRows.forEach(row => row.toggleSelected());\n } else if (event.shiftKey) {\n const [fromIndex, toIndex] = toggleBetween(tableMeta.rowSelection.lastSelectedRowIndex.current ?? 0, rowIndex);\n const selectedRows = table.getRowModel().rows.slice(fromIndex, toIndex + 1);\n\n if (tableMeta.server.loadAllIfNeeded && selectedRows.some(row => row.original === undefined)) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n\n table.setRowSelection((currentRowSelection: RowSelectionState) => ({\n ...currentRowSelection,\n ...selectedRows.filter(row => row.getCanSelect()).reduce((state, row) => ({ ...state, [row.id]: true }), {}),\n }));\n } else {\n row.toggleSelected();\n }\n\n tableMeta.rowSelection.lastSelectedRowIndex.current = row.index;\n };\n\n return (\n <Tooltip\n hidden={!canSelect}\n title={\n <>\n {title}\n <Shortcut className=\"ml-2\" keys=\"Space\" />\n </>\n }>\n <Checkbox\n aria-label={title}\n className=\"!mt-0\"\n checked={isSelected}\n onClick={handleClick}\n disabled={!canSelect}\n // this is necessary to remove console spam from eslint\n onChange={() => false}\n />\n </Tooltip>\n );\n}\n\nexport const renderer: useTableManagerInternalColumn = {\n header: Header,\n renderer: Cell,\n size: 40,\n meta: {\n align: 'center',\n className: '!px-1',\n // TODO: remove when table3 is migrated, this satisfies the legacy table3 type\n enableSearch: false,\n header: '',\n headerClassName: '!px-1',\n },\n};\n"],"names":["Header","context","texts","useLocalization","table","tableMeta","options","meta","isAllRowsSelected","getIsAllRowsSelected","isSomeRowsSelected","getIsSomeRowsSelected","title","columns","select","deselectAll","selectAll","handleChange","checked","toggleAllRowsSelected","_temp","server","loadAllIfNeeded","Promise","resolve","getState","sorting","columnFilters","then","_temp2","e","reject","React","Tooltip","Checkbox","className","indeterminate","loading","loadAllStatus","TableServerLoadAllState","Loading","onChange","toggleBetween","fromRowIndex","toRowIndex","fromIndex","toIndex","Cell","row","rowIndex","useContext","RowContext","enableGrouping","_table$getState$group","grouping","length","getIsGrouped","isSelected","getIsAllSubRowsSelected","getIsSelected","canSelect","getCanSelect","deselect","handleClick","event","rowSelection","lastSelectedRowIndex","current","index","stopPropagation","_temp6","subRows","forEach","toggleSelected","_temp5","shiftKey","_tableMeta$rowSelecti","_temp4","setRowSelection","currentRowSelection","selectedRows","filter","reduce","state","id","getRowModel","rows","slice","_temp3","some","original","undefined","_temp7","hidden","Shortcut","keys","onClick","disabled","renderer","header","size","align","enableSearch","headerClassName"],"mappings":";;;;;;;;AAeA,SAASA,MAAMA,CAAkBC,OAAgD;EAC7E,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM;IAAEC;GAAO,GAAGH,OAAO;EACzB,MAAMI,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAE7D,MAAMC,iBAAiB,GAAGJ,KAAK,CAACK,oBAAoB,EAAE;EACtD,MAAMC,kBAAkB,GAAGN,KAAK,CAACO,qBAAqB,EAAE;EACxD,MAAMC,KAAK,GAAGJ,iBAAiB,GAAGN,KAAK,CAACE,KAAK,CAACS,OAAO,CAACC,MAAM,CAACC,WAAW,GAAGb,KAAK,CAACE,KAAK,CAACS,OAAO,CAACC,MAAM,CAACE,SAAS;EAE/G,MAAMC,YAAY,aAAUC,OAAgB;IAAA;;QAOxCd,KAAK,CAACe,qBAAqB,CAACD,OAAO,CAAC;;MAAC,MAAAE,KAAA;QAAA,IALjCf,SAAS,CAACgB,MAAM,CAACC,eAAe;;UAChC,OAAAC,OAAA,CAAAC,OAAA,CACMnB,SAAS,CAACgB,MAAM,CAACC,eAAe,CAAClB,KAAK,CAACqB,QAAQ,EAAE,CAACC,OAAO,EAAEtB,KAAK,CAACqB,QAAQ,EAAE,CAACE,aAAa,CAAC,EAAAC,IAAA;;;;MAHpG,OAAAL,OAAA,CAAAC,OAAA,CAAAJ,KAAA,IAAAA,KAAA,CAAAQ,IAAA,GAAAR,KAAA,CAAAQ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,MAAM;IAClB,CACI;AAElB;MAEayD,QAAQ,GAAkC;EACnDC,MAAM,EAAEnG,MAAM;EACdkG,QAAQ,EAAEnD,IAAI;EACdqD,IAAI,EAAE,EAAE;EACR7F,IAAI,EAAE;IACF8F,KAAK,EAAE,QAAQ;IACflE,SAAS,EAAE,OAAO;;IAElBmE,YAAY,EAAE,KAAK;IACnBH,MAAM,EAAE,EAAE;IACVI,eAAe,EAAE;;;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType, internalRowId: string) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void | Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableSearchHandler = (search: string | undefined) => void | Promise<void>;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void | Promise<void>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n enableRowSelectionSingle?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityColumnId?: string;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAkHrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType, internalRowId: string) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void | Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableSearchHandler = (search: string | undefined) => void | Promise<void>;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void | Promise<void>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityColumnId?: string;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAkHrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
|
@@ -6,20 +6,15 @@ function useTableRowSelectionListener(table, onRowSelect) {
|
|
6
6
|
const rowSelection = React__default.useMemo(() => rows.map(row => row.original), [rows]);
|
7
7
|
useLazyEffect(() => {
|
8
8
|
if (table.options.enableRowSelection && typeof onRowSelect === 'function') {
|
9
|
-
|
10
|
-
onRowSelect(rowSelection);
|
11
|
-
} else {
|
12
|
-
var _ref;
|
13
|
-
onRowSelect((_ref = [rowSelection[0]]) !== null && _ref !== void 0 ? _ref : []);
|
14
|
-
}
|
9
|
+
onRowSelect(rowSelection);
|
15
10
|
}
|
16
11
|
/**
|
17
|
-
* Casting to a boolean, since enableRowSelection
|
12
|
+
* Casting to a boolean, since enableRowSelection can be a function,
|
18
13
|
* and setting a function as depoendency will lead to infinity loop. And in case of row selection useEffect,
|
19
|
-
* we only need to know if selection was enabled or disabled, because enableRowSelection
|
14
|
+
* we only need to know if selection was enabled or disabled, because enableRowSelection function
|
20
15
|
* will be applied directly to particular rows.
|
21
16
|
*/
|
22
|
-
}, [!!table.options.enableRowSelection,
|
17
|
+
}, [!!table.options.enableRowSelection, JSON.stringify(rowSelection)]);
|
23
18
|
}
|
24
19
|
|
25
20
|
export { useTableRowSelectionListener };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\nimport React from 'react';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n const rows = table.getSelectedRowModel().flatRows;\n const rowSelection = React.useMemo(() => rows.map(row => row.original), [rows]);\n\n useLazyEffect(() => {\n if (table.options.enableRowSelection && typeof onRowSelect === 'function') {\n
|
1
|
+
{"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\nimport React from 'react';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n const rows = table.getSelectedRowModel().flatRows;\n const rowSelection = React.useMemo(() => rows.map(row => row.original), [rows]);\n\n useLazyEffect(() => {\n if (table.options.enableRowSelection && typeof onRowSelect === 'function') {\n onRowSelect(rowSelection);\n }\n /**\n * Casting to a boolean, since enableRowSelection can be a function,\n * and setting a function as depoendency will lead to infinity loop. And in case of row selection useEffect,\n * we only need to know if selection was enabled or disabled, because enableRowSelection function\n * will be applied directly to particular rows.\n */\n }, [!!table.options.enableRowSelection, JSON.stringify(rowSelection)]);\n}\n"],"names":["useTableRowSelectionListener","table","onRowSelect","rows","getSelectedRowModel","flatRows","rowSelection","React","useMemo","map","row","original","useLazyEffect","options","enableRowSelection","JSON","stringify"],"mappings":";;;SAKgBA,4BAA4BA,CACxCC,KAAwB,EACxBC,WAA0C;EAE1C,MAAMC,IAAI,GAAGF,KAAK,CAACG,mBAAmB,EAAE,CAACC,QAAQ;EACjD,MAAMC,YAAY,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAML,IAAI,CAACM,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,CAAC,EAAE,CAACR,IAAI,CAAC,CAAC;EAE/ES,aAAa,CAAC;IACV,IAAIX,KAAK,CAACY,OAAO,CAACC,kBAAkB,IAAI,OAAOZ,WAAW,KAAK,UAAU,EAAE;MACvEA,WAAW,CAACI,YAAY,CAAC;;;;;;;;GAQhC,EAAE,CAAC,CAAC,CAACL,KAAK,CAACY,OAAO,CAACC,kBAAkB,EAAEC,IAAI,CAACC,SAAS,CAACV,YAAY,CAAC,CAAC,CAAC;AAC1E;;;;"}
|
@@ -5,6 +5,17 @@ import { resetHighlightedColumnIndexes } from '../util/search.js';
|
|
5
5
|
function useTableSearchListener(table, onChangeSearch) {
|
6
6
|
const meta = table.options.meta;
|
7
7
|
const localization = useLocalization();
|
8
|
+
const visibleColumns = table.getVisibleFlatColumns();
|
9
|
+
// Need to re-run search when columns are getting shown/hidden.
|
10
|
+
React__default.useEffect(() => {
|
11
|
+
if (meta.search.isEnabled && visibleColumns.length > 0) {
|
12
|
+
const currentFilter = table.getState().globalFilter;
|
13
|
+
requestAnimationFrame(() => {
|
14
|
+
table.resetGlobalFilter();
|
15
|
+
table.setGlobalFilter(currentFilter);
|
16
|
+
});
|
17
|
+
}
|
18
|
+
}, [visibleColumns.length]);
|
8
19
|
// recalculates highlighted indexes whenever something important changes
|
9
20
|
React__default.useEffect(() => {
|
10
21
|
if (meta.search.isEnabled) {
|
@@ -14,7 +25,7 @@ function useTableSearchListener(table, onChangeSearch) {
|
|
14
25
|
onChangeSearch(query);
|
15
26
|
}
|
16
27
|
}
|
17
|
-
}, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting),
|
28
|
+
}, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), onChangeSearch]);
|
18
29
|
}
|
19
30
|
|
20
31
|
export { useTableSearchListener };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableSearchListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSearchListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { resetHighlightedColumnIndexes } from '../util/search';\nimport { TableSearchHandler } from '../../types';\nimport { useLocalization } from '../../../../components/Provider/Localization';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>, onChangeSearch?: TableSearchHandler) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const localization = useLocalization();\n\n // recalculates highlighted indexes whenever something important changes\n React.useEffect(() => {\n if (meta.search.isEnabled) {\n const query = table.getState().globalFilter;\n resetHighlightedColumnIndexes(query, table, localization);\n\n if (typeof onChangeSearch === 'function') {\n onChangeSearch(query);\n }\n }\n }, [\n meta.server.loadAllStatus,\n meta.search.isEnabled,\n meta.search.enableGlobalFilter,\n table.getRowModel().rows.length,\n table.getState().globalFilter,\n JSON.stringify(table.getState().sorting),\n
|
1
|
+
{"version":3,"file":"useTableSearchListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSearchListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { resetHighlightedColumnIndexes } from '../util/search';\nimport { TableSearchHandler } from '../../types';\nimport { useLocalization } from '../../../../components/Provider/Localization';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>, onChangeSearch?: TableSearchHandler) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const localization = useLocalization();\n\n const visibleColumns = table.getVisibleFlatColumns();\n\n // Need to re-run search when columns are getting shown/hidden.\n React.useEffect(() => {\n if (meta.search.isEnabled && visibleColumns.length > 0) {\n const currentFilter = table.getState().globalFilter;\n requestAnimationFrame(() => {\n table.resetGlobalFilter();\n table.setGlobalFilter(currentFilter);\n });\n }\n }, [visibleColumns.length]);\n\n // recalculates highlighted indexes whenever something important changes\n React.useEffect(() => {\n if (meta.search.isEnabled) {\n const query = table.getState().globalFilter;\n resetHighlightedColumnIndexes(query, table, localization);\n\n if (typeof onChangeSearch === 'function') {\n onChangeSearch(query);\n }\n }\n }, [\n meta.server.loadAllStatus,\n meta.search.isEnabled,\n meta.search.enableGlobalFilter,\n table.getRowModel().rows.length,\n table.getState().globalFilter,\n JSON.stringify(table.getState().sorting),\n onChangeSearch,\n ]);\n}\n"],"names":["useTableSearchListener","table","onChangeSearch","meta","options","localization","useLocalization","visibleColumns","getVisibleFlatColumns","React","useEffect","search","isEnabled","length","currentFilter","getState","globalFilter","requestAnimationFrame","resetGlobalFilter","setGlobalFilter","query","resetHighlightedColumnIndexes","server","loadAllStatus","enableGlobalFilter","getRowModel","rows","JSON","stringify","sorting"],"mappings":";;;;SAMgBA,sBAAsBA,CAAkBC,KAAwB,EAAEC,cAAmC;EACjH,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,YAAY,GAAGC,eAAe,EAAE;EAEtC,MAAMC,cAAc,GAAGN,KAAK,CAACO,qBAAqB,EAAE;;EAGpDC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,IAAI,CAACQ,MAAM,CAACC,SAAS,IAAIL,cAAc,CAACM,MAAM,GAAG,CAAC,EAAE;MACpD,MAAMC,aAAa,GAAGb,KAAK,CAACc,QAAQ,EAAE,CAACC,YAAY;MACnDC,qBAAqB,CAAC;QAClBhB,KAAK,CAACiB,iBAAiB,EAAE;QACzBjB,KAAK,CAACkB,eAAe,CAACL,aAAa,CAAC;OACvC,CAAC;;GAET,EAAE,CAACP,cAAc,CAACM,MAAM,CAAC,CAAC;;EAG3BJ,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,IAAI,CAACQ,MAAM,CAACC,SAAS,EAAE;MACvB,MAAMQ,KAAK,GAAGnB,KAAK,CAACc,QAAQ,EAAE,CAACC,YAAY;MAC3CK,6BAA6B,CAACD,KAAK,EAAEnB,KAAK,EAAEI,YAAY,CAAC;MAEzD,IAAI,OAAOH,cAAc,KAAK,UAAU,EAAE;QACtCA,cAAc,CAACkB,KAAK,CAAC;;;GAGhC,EAAE,CACCjB,IAAI,CAACmB,MAAM,CAACC,aAAa,EACzBpB,IAAI,CAACQ,MAAM,CAACC,SAAS,EACrBT,IAAI,CAACQ,MAAM,CAACa,kBAAkB,EAC9BvB,KAAK,CAACwB,WAAW,EAAE,CAACC,IAAI,CAACb,MAAM,EAC/BZ,KAAK,CAACc,QAAQ,EAAE,CAACC,YAAY,EAC7BW,IAAI,CAACC,SAAS,CAAC3B,KAAK,CAACc,QAAQ,EAAE,CAACc,OAAO,CAAC,EACxC3B,cAAc,CACjB,CAAC;AACN;;;;"}
|
@@ -8,7 +8,6 @@ const DEFAULT_PRESET = {
|
|
8
8
|
enableColumnResizing: false,
|
9
9
|
enableRowExpansion: false,
|
10
10
|
enableRowSelection: false,
|
11
|
-
enableRowSelectionSingle: false,
|
12
11
|
// custom -- common between all table types
|
13
12
|
enableColumnOrdering: false,
|
14
13
|
enableFontSize: false,
|
@@ -35,7 +34,6 @@ const presets = {
|
|
35
34
|
enableColumnResizing: true,
|
36
35
|
enableRowExpansion: true,
|
37
36
|
enableRowSelection: true,
|
38
|
-
enableRowSelectionSingle: false,
|
39
37
|
// custom -- common between all table types
|
40
38
|
enableColumnOrdering: true,
|
41
39
|
enableFontSize: true,
|
@@ -61,7 +59,6 @@ const presets = {
|
|
61
59
|
enableColumnResizing: false,
|
62
60
|
enableRowExpansion: true,
|
63
61
|
enableRowSelection: true,
|
64
|
-
enableRowSelectionSingle: false,
|
65
62
|
// custom -- common between all table types
|
66
63
|
enableColumnOrdering: false,
|
67
64
|
enableFontSize: false,
|
@@ -87,7 +84,6 @@ const presets = {
|
|
87
84
|
enableColumnResizing: false,
|
88
85
|
enableRowExpansion: true,
|
89
86
|
enableRowSelection: false,
|
90
|
-
enableRowSelectionSingle: false,
|
91
87
|
// custom -- common between all table types
|
92
88
|
enableColumnOrdering: false,
|
93
89
|
enableFontSize: false,
|
@@ -104,7 +100,7 @@ const presets = {
|
|
104
100
|
}
|
105
101
|
};
|
106
102
|
function getTableFeaturePreset(props) {
|
107
|
-
var _props$enableRowActio, _props$enableRowClick, _props$enableRowDrag, _props$enableRowDrop, _props$enableRowGoto, _props$enableRowExpan, _props$enableRowSelec, _props$
|
103
|
+
var _props$enableRowActio, _props$enableRowClick, _props$enableRowDrag, _props$enableRowDrop, _props$enableRowGoto, _props$enableRowExpan, _props$enableRowSelec, _props$enableFilterin, _props$enableSearch, _props$enableSorting, _props$enableColumnFr, _props$enableColumnHi, _props$enableColumnRe, _props$enableColumnOr, _props$enableFontSize, _props$enableFooter, _props$enablePrinting, _props$enableRowActiv, _props$rowActions, _props$enableRowHeigh, _props$enableSaveSett;
|
108
104
|
const presetOptions = props.preset ? presets[props.preset] : DEFAULT_PRESET;
|
109
105
|
const enableRowActions = (_props$enableRowActio = props.enableRowActions) !== null && _props$enableRowActio !== void 0 ? _props$enableRowActio : presetOptions.enableRowActions;
|
110
106
|
const enableRowClick = (_props$enableRowClick = props.enableRowClick) !== null && _props$enableRowClick !== void 0 ? _props$enableRowClick : presetOptions.enableRowClick;
|
@@ -113,7 +109,6 @@ function getTableFeaturePreset(props) {
|
|
113
109
|
const enableRowGoto = (_props$enableRowGoto = props.enableRowGoto) !== null && _props$enableRowGoto !== void 0 ? _props$enableRowGoto : presetOptions.enableRowGoto;
|
114
110
|
const enableRowExpansion = (_props$enableRowExpan = props.enableRowExpansion) !== null && _props$enableRowExpan !== void 0 ? _props$enableRowExpan : presetOptions.enableRowExpansion;
|
115
111
|
const enableRowSelection = (_props$enableRowSelec = props.enableRowSelection) !== null && _props$enableRowSelec !== void 0 ? _props$enableRowSelec : presetOptions.enableRowSelection;
|
116
|
-
const enableRowSelectionSingle = (_props$enableRowSelec2 = props.enableRowSelectionSingle) !== null && _props$enableRowSelec2 !== void 0 ? _props$enableRowSelec2 : presetOptions.enableRowSelectionSingle;
|
117
112
|
return {
|
118
113
|
// react-table built-in
|
119
114
|
enableFiltering: (_props$enableFilterin = props.enableFiltering) !== null && _props$enableFilterin !== void 0 ? _props$enableFilterin : presetOptions.enableFiltering,
|
@@ -124,7 +119,6 @@ function getTableFeaturePreset(props) {
|
|
124
119
|
enableColumnResizing: (_props$enableColumnRe = props.enableColumnResizing) !== null && _props$enableColumnRe !== void 0 ? _props$enableColumnRe : presetOptions.enableColumnResizing,
|
125
120
|
enableRowExpansion: enableRowExpansion && !!props.rowExpansionRenderer,
|
126
121
|
enableRowSelection: !!props.onRowSelect && enableRowSelection,
|
127
|
-
enableRowSelectionSingle: !!props.onRowSelect && enableRowSelectionSingle,
|
128
122
|
// custom -- common between all table types
|
129
123
|
enableColumnOrdering: (_props$enableColumnOr = props.enableColumnOrdering) !== null && _props$enableColumnOr !== void 0 ? _props$enableColumnOr : presetOptions.enableColumnOrdering,
|
130
124
|
enableFontSize: (_props$enableFontSize = props.enableFontSize) !== null && _props$enableFontSize !== void 0 ? _props$enableFontSize : presetOptions.enableFontSize,
|