@economic/taco 1.32.0 → 1.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Provider/Localization.d.ts +1 -6
- package/dist/components/Table2/Table2.d.ts +10 -7
- package/dist/components/Table2/components/ColumnSettingsButton.d.ts +4 -5
- package/dist/components/Table2/components/column/utils.d.ts +1 -0
- package/dist/components/Table2/types.d.ts +2 -0
- package/dist/components/Table2/utilities/cell.d.ts +1 -0
- package/dist/components/Table2/utilities/columns.d.ts +2 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +2 -7
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/Table2.js +10 -0
- package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js +80 -335
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +12 -5
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js +2 -1
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js +6 -3
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +3 -2
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/types.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js +2 -2
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +37 -1
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +1 -1
- package/dist/taco.cjs.development.js +155 -359
- 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/types.json +79 -20
|
@@ -39,7 +39,7 @@ var reactTable$1 = require('@tanstack/react-table');
|
|
|
39
39
|
var ReactDOM = _interopDefault(require('react-dom'));
|
|
40
40
|
var reactVirtual = require('react-virtual');
|
|
41
41
|
var core = require('@dnd-kit/core');
|
|
42
|
-
var
|
|
42
|
+
var SortablePrimitive = require('@dnd-kit/sortable');
|
|
43
43
|
var utilities = require('@dnd-kit/utilities');
|
|
44
44
|
var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
45
45
|
var Joyride = require('react-joyride');
|
|
@@ -3962,15 +3962,10 @@ const defaultLocalisationTexts = {
|
|
|
3962
3962
|
}
|
|
3963
3963
|
},
|
|
3964
3964
|
columnSettings: {
|
|
3965
|
-
columnsHidden: 'Hidden columns',
|
|
3966
|
-
columnsHiddenDrop: 'Drop column here to hide',
|
|
3967
|
-
columnsVisible: 'Visible columns',
|
|
3968
|
-
columnsVisibleDrop: 'Drop column here to show',
|
|
3969
|
-
noHiddenColumns: 'No hidden columns',
|
|
3970
|
-
noVisibleColumns: 'No visible columns',
|
|
3971
3965
|
search: 'Search column...',
|
|
3972
3966
|
tooltip: 'Column settings',
|
|
3973
|
-
button: 'Columns'
|
|
3967
|
+
button: 'Columns',
|
|
3968
|
+
noResults: 'No results'
|
|
3974
3969
|
},
|
|
3975
3970
|
editing: {
|
|
3976
3971
|
button: 'Edit',
|
|
@@ -11821,6 +11816,42 @@ function createRowActionsColumn(rowActions, rowActionsLength, texts) {
|
|
|
11821
11816
|
enableResizing: false
|
|
11822
11817
|
};
|
|
11823
11818
|
}
|
|
11819
|
+
function ensureOrdering(columns, settingsOrder) {
|
|
11820
|
+
const fixedOrder = [];
|
|
11821
|
+
const disabledOrder = [];
|
|
11822
|
+
const enabledOrder = [];
|
|
11823
|
+
if (Array.isArray(settingsOrder)) {
|
|
11824
|
+
const firstNonInternalColumnIndex = settingsOrder.findIndex(id => !(id !== null && id !== void 0 && id.startsWith('__')) && id !== COLUMN_ID_FOR_ACTIONS);
|
|
11825
|
+
if (firstNonInternalColumnIndex > -1) {
|
|
11826
|
+
fixedOrder.push(...settingsOrder.slice(0, firstNonInternalColumnIndex));
|
|
11827
|
+
}
|
|
11828
|
+
settingsOrder.forEach(id => {
|
|
11829
|
+
var _columns$find, _columns$find$meta;
|
|
11830
|
+
if ((_columns$find = columns.find(column => column.id === id)) !== null && _columns$find !== void 0 && (_columns$find$meta = _columns$find.meta) !== null && _columns$find$meta !== void 0 && _columns$find$meta.disableReordering) {
|
|
11831
|
+
disabledOrder.unshift(id);
|
|
11832
|
+
} else {
|
|
11833
|
+
enabledOrder.push(id);
|
|
11834
|
+
}
|
|
11835
|
+
});
|
|
11836
|
+
} else {
|
|
11837
|
+
const firstNonInternalColumnIndex = columns.findIndex(column => {
|
|
11838
|
+
var _column$id;
|
|
11839
|
+
return !((_column$id = column.id) !== null && _column$id !== void 0 && _column$id.startsWith('__')) && column.id !== COLUMN_ID_FOR_ACTIONS;
|
|
11840
|
+
});
|
|
11841
|
+
if (firstNonInternalColumnIndex > -1) {
|
|
11842
|
+
fixedOrder.push(...columns.slice(0, firstNonInternalColumnIndex).map(column => column.id));
|
|
11843
|
+
}
|
|
11844
|
+
columns.slice(firstNonInternalColumnIndex).forEach(column => {
|
|
11845
|
+
var _column$meta;
|
|
11846
|
+
if ((_column$meta = column.meta) !== null && _column$meta !== void 0 && _column$meta.disableReordering) {
|
|
11847
|
+
disabledOrder.push(column.id);
|
|
11848
|
+
} else {
|
|
11849
|
+
enabledOrder.push(column.id);
|
|
11850
|
+
}
|
|
11851
|
+
});
|
|
11852
|
+
}
|
|
11853
|
+
return [...fixedOrder, ...disabledOrder, ...enabledOrder];
|
|
11854
|
+
}
|
|
11824
11855
|
|
|
11825
11856
|
const getDensitySizing = (density, editing = false) => {
|
|
11826
11857
|
switch (density) {
|
|
@@ -11853,8 +11884,8 @@ const getFrozenShadowClasses = (column, frozenColumns, isHorizontallyOffset) =>
|
|
|
11853
11884
|
'shadow-[1px_0px_0px_theme(colors.grey.300)]': isLastFrozen && !isHorizontallyOffset && !hideFrozenShadow
|
|
11854
11885
|
};
|
|
11855
11886
|
};
|
|
11887
|
+
const focussableNodeNames = ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS'];
|
|
11856
11888
|
const isKeyboardFocusableElement = element => {
|
|
11857
|
-
const focussableNodeNames = ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS'];
|
|
11858
11889
|
return focussableNodeNames.includes(element.nodeName) && !element.hasAttribute('disabled') && !element.hasAttribute('readonly') && !element.getAttribute('aria-hidden');
|
|
11859
11890
|
};
|
|
11860
11891
|
|
|
@@ -12238,6 +12269,7 @@ const willRowMoveAfterSorting = (value, cell, rowIndex, rows, desc) => {
|
|
|
12238
12269
|
}
|
|
12239
12270
|
return resortedRows[index].id !== cell.row.id;
|
|
12240
12271
|
};
|
|
12272
|
+
const clickableNodeNames = ['INPUT', 'BUTTON', 'A', 'SELECT', 'OPTION', 'LABEL', 'TEXTAREA', 'DETAILS'];
|
|
12241
12273
|
|
|
12242
12274
|
const Cell = function Cell(props) {
|
|
12243
12275
|
var _cell$column$columnDe, _cell$column$columnDe2, _table$options$meta;
|
|
@@ -12529,11 +12561,18 @@ const Cell = function Cell(props) {
|
|
|
12529
12561
|
} else {
|
|
12530
12562
|
if (meta.onRowClick) {
|
|
12531
12563
|
attributes.onClick = event => {
|
|
12532
|
-
|
|
12533
|
-
|
|
12534
|
-
|
|
12564
|
+
const {
|
|
12565
|
+
target
|
|
12566
|
+
} = event;
|
|
12567
|
+
// This check prevents triggering row click, when a click is performed in the dropdown (e.g. Select option or DayPicker date selection)
|
|
12568
|
+
if (internalRef.current && target instanceof HTMLElement && internalRef.current.contains(target)) {
|
|
12569
|
+
var _meta$onRowClick;
|
|
12570
|
+
// Checking that target is clickable element or it is a child of clickable element
|
|
12571
|
+
if (clickableNodeNames.includes(target.tagName) || target.closest(clickableNodeNames.map(tag => `[role=row] ${tag}`).join(','))) {
|
|
12572
|
+
return;
|
|
12573
|
+
}
|
|
12574
|
+
(_meta$onRowClick = meta.onRowClick) === null || _meta$onRowClick === void 0 ? void 0 : _meta$onRowClick.call(meta, cell.row.original);
|
|
12535
12575
|
}
|
|
12536
|
-
(_meta$onRowClick = meta.onRowClick) === null || _meta$onRowClick === void 0 ? void 0 : _meta$onRowClick.call(meta, cell.row.original);
|
|
12537
12576
|
};
|
|
12538
12577
|
}
|
|
12539
12578
|
}
|
|
@@ -13116,7 +13155,7 @@ function useColumnDefinitions(children, options, tableRef) {
|
|
|
13116
13155
|
size: child.props.defaultWidth,
|
|
13117
13156
|
// sorting
|
|
13118
13157
|
enableSorting: !child.props.disableSorting,
|
|
13119
|
-
sortingFn: getSortingFn(child.props.dataType)
|
|
13158
|
+
sortingFn: getSortingFn(child.props.dataType, child.props.sortFn)
|
|
13120
13159
|
});
|
|
13121
13160
|
}
|
|
13122
13161
|
});
|
|
@@ -13145,12 +13184,15 @@ function useColumnDefinitions(children, options, tableRef) {
|
|
|
13145
13184
|
};
|
|
13146
13185
|
}, [children]);
|
|
13147
13186
|
}
|
|
13148
|
-
|
|
13187
|
+
function getSortingFn(dataType, customFn) {
|
|
13188
|
+
if (customFn) {
|
|
13189
|
+
return (rowA, rowB, columnId) => customFn(rowA.original, rowB.original, columnId);
|
|
13190
|
+
}
|
|
13149
13191
|
if (dataType && dataType !== 'boolean') {
|
|
13150
13192
|
return dataType;
|
|
13151
13193
|
}
|
|
13152
13194
|
return 'auto';
|
|
13153
|
-
}
|
|
13195
|
+
}
|
|
13154
13196
|
|
|
13155
13197
|
// frozen columns have position sticky, and because we support more than one of them
|
|
13156
13198
|
// we must set a 'left' css value. this hook listens to changes on state that will
|
|
@@ -13263,7 +13305,7 @@ const useFilterStateListener = (table, onRowSelect) => {
|
|
|
13263
13305
|
|
|
13264
13306
|
const ACTIONS_ON_ROW_LENGTH = 4;
|
|
13265
13307
|
function useTable$1(children, props, ref) {
|
|
13266
|
-
var _settings$frozenColum, _settings$
|
|
13308
|
+
var _settings$frozenColum, _settings$columnSizin, _settings$columnVisib, _settings$rowDensity;
|
|
13267
13309
|
const {
|
|
13268
13310
|
actionsForRow = [],
|
|
13269
13311
|
actionsForRowLength = ACTIONS_ON_ROW_LENGTH,
|
|
@@ -13320,7 +13362,7 @@ function useTable$1(children, props, ref) {
|
|
|
13320
13362
|
const frozenColumns = columns.slice(0, totalFrozenColumns).map(column => column.id);
|
|
13321
13363
|
// defaults
|
|
13322
13364
|
const initialState = {
|
|
13323
|
-
columnOrder: (
|
|
13365
|
+
columnOrder: ensureOrdering(columns, settings === null || settings === void 0 ? void 0 : settings.columnOrder),
|
|
13324
13366
|
columnPinning: {
|
|
13325
13367
|
left: frozenColumns,
|
|
13326
13368
|
right: []
|
|
@@ -13634,7 +13676,7 @@ function Item$3(props) {
|
|
|
13634
13676
|
setNodeRef,
|
|
13635
13677
|
transform,
|
|
13636
13678
|
transition
|
|
13637
|
-
} =
|
|
13679
|
+
} = SortablePrimitive.useSortable({
|
|
13638
13680
|
disabled,
|
|
13639
13681
|
id
|
|
13640
13682
|
});
|
|
@@ -13674,10 +13716,10 @@ function List$1(externalProps) {
|
|
|
13674
13716
|
id
|
|
13675
13717
|
});
|
|
13676
13718
|
const items = React__default.Children.toArray(children).map(child => child.props);
|
|
13677
|
-
return /*#__PURE__*/React__default.createElement(
|
|
13719
|
+
return /*#__PURE__*/React__default.createElement(SortablePrimitive.SortableContext, {
|
|
13678
13720
|
id: id,
|
|
13679
13721
|
items: items,
|
|
13680
|
-
strategy:
|
|
13722
|
+
strategy: SortablePrimitive.verticalListSortingStrategy
|
|
13681
13723
|
}, /*#__PURE__*/React__default.createElement("div", Object.assign({}, props, {
|
|
13682
13724
|
ref: id ? setNodeRef : undefined
|
|
13683
13725
|
}), children));
|
|
@@ -13709,363 +13751,107 @@ const Truncate = ({
|
|
|
13709
13751
|
return clonedChildrenWithRef;
|
|
13710
13752
|
};
|
|
13711
13753
|
|
|
13712
|
-
|
|
13754
|
+
function getColumnName(column) {
|
|
13713
13755
|
var _ref, _column$columnDef$hea, _column$columnDef$hea2;
|
|
13756
|
+
return (_ref = (_column$columnDef$hea = (_column$columnDef$hea2 = column.columnDef.header) === null || _column$columnDef$hea2 === void 0 ? void 0 : _column$columnDef$hea2.toString()) !== null && _column$columnDef$hea !== void 0 ? _column$columnDef$hea : column.columnDef.id) !== null && _ref !== void 0 ? _ref : '';
|
|
13757
|
+
}
|
|
13758
|
+
const Column$1 = /*#__PURE__*/React__default.forwardRef(function Column(props, ref) {
|
|
13714
13759
|
const {
|
|
13715
|
-
canBeReordered,
|
|
13716
13760
|
column,
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
...
|
|
13761
|
+
draggable = false,
|
|
13762
|
+
isOrderingEnabled,
|
|
13763
|
+
...dragAttributes
|
|
13720
13764
|
} = props;
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
icon = /*#__PURE__*/React__default.createElement("span", {
|
|
13730
|
-
className: "mr-0.5 inline-flex w-4"
|
|
13731
|
-
});
|
|
13732
|
-
}
|
|
13733
|
-
// columnName should be a string
|
|
13734
|
-
const columnName = (_ref = (_column$columnDef$hea = (_column$columnDef$hea2 = column.columnDef.header) === null || _column$columnDef$hea2 === void 0 ? void 0 : _column$columnDef$hea2.toString()) !== null && _column$columnDef$hea !== void 0 ? _column$columnDef$hea : column.columnDef.id) !== null && _ref !== void 0 ? _ref : '';
|
|
13765
|
+
const canHide = column.getCanHide();
|
|
13766
|
+
const className = cn('group/column flex items-center gap-x-2 rounded py-1 px-2', {
|
|
13767
|
+
'hover:bg-grey-200': canHide || draggable,
|
|
13768
|
+
'hover:cursor-pointer': canHide,
|
|
13769
|
+
'active:cursor-move active:bg-grey-300': draggable
|
|
13770
|
+
});
|
|
13771
|
+
const attributes = draggable ? dragAttributes : undefined;
|
|
13772
|
+
const text = getColumnName(column);
|
|
13735
13773
|
return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
|
|
13736
|
-
|
|
13774
|
+
key: column.id,
|
|
13775
|
+
className: className,
|
|
13776
|
+
onClick: () => column.toggleVisibility(),
|
|
13737
13777
|
ref: ref
|
|
13738
|
-
}), /*#__PURE__*/React__default.createElement(
|
|
13739
|
-
|
|
13778
|
+
}), draggable ? /*#__PURE__*/React__default.createElement(Icon, {
|
|
13779
|
+
name: "drag",
|
|
13780
|
+
className: "text-grey-500 group-hover/column:text-grey-700 -mx-2 !h-5"
|
|
13781
|
+
}) : isOrderingEnabled ? /*#__PURE__*/React__default.createElement("span", {
|
|
13782
|
+
className: "flex w-2"
|
|
13783
|
+
}) : null, /*#__PURE__*/React__default.createElement(Truncate, {
|
|
13784
|
+
tooltip: text
|
|
13740
13785
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
13741
|
-
className: "select-none"
|
|
13742
|
-
},
|
|
13786
|
+
className: "flex-grow select-none"
|
|
13787
|
+
}, text)), canHide ? /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
13788
|
+
checked: column.getIsVisible(),
|
|
13789
|
+
onChange: column.toggleVisibility
|
|
13790
|
+
}) : null);
|
|
13743
13791
|
});
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
};
|
|
13749
|
-
const isColumnOrderingDisabled = (table, column) => {
|
|
13750
|
-
var _column$columnDef$met2;
|
|
13751
|
-
const meta = table.options.meta;
|
|
13752
|
-
return meta.enableColumnReordering && !!((_column$columnDef$met2 = column.columnDef.meta) !== null && _column$columnDef$met2 !== void 0 && _column$columnDef$met2.disableReordering);
|
|
13753
|
-
};
|
|
13754
|
-
const SortableColumnContainer = ({
|
|
13755
|
-
state,
|
|
13756
|
-
moveColumn,
|
|
13757
|
-
reorderColumn,
|
|
13758
|
-
table,
|
|
13759
|
-
query
|
|
13760
|
-
}) => {
|
|
13792
|
+
function ColumnSettingsButton(props) {
|
|
13793
|
+
const {
|
|
13794
|
+
table
|
|
13795
|
+
} = props;
|
|
13761
13796
|
const {
|
|
13762
13797
|
texts
|
|
13763
13798
|
} = useLocalization();
|
|
13764
|
-
const
|
|
13765
|
-
const
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
|
|
13799
|
+
const [query, setQuery] = React__default.useState('');
|
|
13800
|
+
const allColumns = table.getAllLeafColumns();
|
|
13801
|
+
const tableMeta = table.options.meta;
|
|
13802
|
+
const columns = React__default.useMemo(() => allColumns.filter(column => !isInternalColumn(column.id)).filter(column => query !== null && query !== void 0 && query.length ? getColumnName(column).toLowerCase().includes(query.toLowerCase()) : true), [allColumns, query]);
|
|
13803
|
+
const listClassName = 'flex max-h-64 flex-col gap-y-px overflow-auto';
|
|
13804
|
+
const handleReorder = (activeId, overId) => {
|
|
13805
|
+
const items = columns.map(column => column.id);
|
|
13806
|
+
if (columns.find(column => {
|
|
13807
|
+
var _column$columnDef$met;
|
|
13808
|
+
return column.id === overId && ((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.disableReordering);
|
|
13809
|
+
})) {
|
|
13810
|
+
return;
|
|
13776
13811
|
}
|
|
13812
|
+
table.setColumnOrder(currentOrder => {
|
|
13813
|
+
const firstNonInternalColumnIndex = currentOrder.findIndex(id => !id.startsWith('__') && id !== COLUMN_ID_FOR_ACTIONS);
|
|
13814
|
+
return [...currentOrder.slice(0, firstNonInternalColumnIndex), ...SortablePrimitive.arrayMove(items, items.findIndex(c => c === activeId), items.findIndex(c => c === overId))];
|
|
13815
|
+
});
|
|
13777
13816
|
};
|
|
13778
|
-
const
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
const filteredVisibleColumns = state.visible.filter(column => {
|
|
13789
|
-
var _column$columnDef$hea4;
|
|
13790
|
-
return (_column$columnDef$hea4 = column.columnDef.header) === null || _column$columnDef$hea4 === void 0 ? void 0 : _column$columnDef$hea4.toString().toLowerCase().includes(query.toLowerCase());
|
|
13791
|
-
});
|
|
13792
|
-
const visibleListDescriptionText = isQueryFilterNotApplied ? texts.table2.columnSettings.columnsVisibleDrop : texts.table2.columnSettings.noVisibleColumns;
|
|
13793
|
-
const hiddenListDescriptionText = isQueryFilterNotApplied ? texts.table2.columnSettings.columnsHiddenDrop : texts.table2.columnSettings.noHiddenColumns;
|
|
13794
|
-
if (isColumnHidingAllowed) {
|
|
13795
|
-
return /*#__PURE__*/React__default.createElement(Container, {
|
|
13796
|
-
reorder: reorder,
|
|
13797
|
-
move: move
|
|
13798
|
-
}, /*#__PURE__*/React__default.createElement(Truncate, {
|
|
13799
|
-
tooltip: texts.table2.columnSettings.columnsVisible
|
|
13800
|
-
}, /*#__PURE__*/React__default.createElement("h5", {
|
|
13801
|
-
className: "mx-4 my-[6px]"
|
|
13802
|
-
}, texts.table2.columnSettings.columnsVisible)), /*#__PURE__*/React__default.createElement(List$1, {
|
|
13803
|
-
id: "visible",
|
|
13804
|
-
className: "flex min-h-[theme(spacing.8)] flex-col overflow-hidden px-2"
|
|
13805
|
-
}, filteredVisibleColumns.length ? filteredVisibleColumns.map(column => {
|
|
13806
|
-
// When searching a column, we disable reordering and make it fixed
|
|
13807
|
-
const canBeReordered = isOrderingAllowed(table, column) && isQueryFilterNotApplied;
|
|
13808
|
-
const isColumnFixed = isColumnOrderingDisabled(table, column) && isQueryFilterNotApplied;
|
|
13809
|
-
return /*#__PURE__*/React__default.createElement(Item$3, {
|
|
13810
|
-
key: column.id,
|
|
13811
|
-
disabled: !canBeReordered,
|
|
13812
|
-
id: column.id,
|
|
13813
|
-
asChild: true
|
|
13814
|
-
}, /*#__PURE__*/React__default.createElement(OrderableColumn, {
|
|
13815
|
-
canBeReordered: canBeReordered,
|
|
13816
|
-
column: column,
|
|
13817
|
-
isColumnFixed: isColumnFixed
|
|
13818
|
-
}, column.getCanHide() ? /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
13819
|
-
className: "!mt-0",
|
|
13820
|
-
checked: column.getIsVisible(),
|
|
13821
|
-
onChange: handleColumnCheckboxChange(column)
|
|
13822
|
-
}) : null));
|
|
13823
|
-
}) :
|
|
13824
|
-
/*#__PURE__*/
|
|
13825
|
-
// For some reason wrapping this paragraph with Truncate will throw error in scenarios where
|
|
13826
|
-
// we conditionally hide or show the paragraph e.g. moving the last column to the hide list
|
|
13827
|
-
React__default.createElement("p", {
|
|
13828
|
-
className: "text-grey-500 mb-0 flex h-8 items-center truncate px-2"
|
|
13829
|
-
}, visibleListDescriptionText)), /*#__PURE__*/React__default.createElement(Truncate, {
|
|
13830
|
-
tooltip: texts.table2.columnSettings.columnsHidden
|
|
13831
|
-
}, /*#__PURE__*/React__default.createElement("h5", {
|
|
13832
|
-
className: "mx-4 my-[6px] truncate"
|
|
13833
|
-
}, texts.table2.columnSettings.columnsHidden)), /*#__PURE__*/React__default.createElement(List$1, {
|
|
13834
|
-
id: "hidden",
|
|
13835
|
-
className: "flex min-h-[theme(spacing.8)] flex-col gap-y-px overflow-hidden px-2"
|
|
13836
|
-
}, filteredHiddenColumns.length ? filteredHiddenColumns.map(column => {
|
|
13837
|
-
// When searching a column, we disable reordering and make it fixed
|
|
13838
|
-
const canBeReordered = isOrderingAllowed(table, column) && isQueryFilterNotApplied;
|
|
13839
|
-
const isColumnFixed = isColumnOrderingDisabled(table, column) && isQueryFilterNotApplied;
|
|
13840
|
-
return /*#__PURE__*/React__default.createElement(Item$3, {
|
|
13841
|
-
key: column.id,
|
|
13842
|
-
disabled: !canBeReordered,
|
|
13843
|
-
id: column.id,
|
|
13844
|
-
asChild: true
|
|
13845
|
-
}, /*#__PURE__*/React__default.createElement(OrderableColumn, {
|
|
13846
|
-
canBeReordered: canBeReordered,
|
|
13847
|
-
column: column,
|
|
13848
|
-
isColumnFixed: isColumnFixed
|
|
13849
|
-
}, column.getCanHide() ? /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
13850
|
-
className: "!mt-0",
|
|
13851
|
-
checked: column.getIsVisible(),
|
|
13852
|
-
onChange: handleColumnCheckboxChange(column)
|
|
13853
|
-
}) : null));
|
|
13854
|
-
}) :
|
|
13855
|
-
/*#__PURE__*/
|
|
13856
|
-
// For some reason wrapping this paragraph with Truncate will throw error in scenarios where
|
|
13857
|
-
// we conditionally hide or show the paragraph e.g. moving the last column to the visible list
|
|
13858
|
-
React__default.createElement("p", {
|
|
13859
|
-
className: "text-grey-500 mb-0 flex h-8 items-center truncate px-2"
|
|
13860
|
-
}, hiddenListDescriptionText)));
|
|
13861
|
-
}
|
|
13862
|
-
return /*#__PURE__*/React__default.createElement(Container, {
|
|
13863
|
-
reorder: reorder,
|
|
13864
|
-
move: move
|
|
13817
|
+
const popover = popoverProps => /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps), /*#__PURE__*/React__default.createElement(Popover.Content, {
|
|
13818
|
+
align: "end"
|
|
13819
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
13820
|
+
className: "flex w-60 flex-col gap-2"
|
|
13821
|
+
}, table.options.enableHiding ? /*#__PURE__*/React__default.createElement(Input, {
|
|
13822
|
+
onChange: event => setQuery(event.target.value),
|
|
13823
|
+
placeholder: texts.table2.columnSettings.search,
|
|
13824
|
+
value: query
|
|
13825
|
+
}) : null, tableMeta.enableColumnReordering && columns.length && !(query !== null && query !== void 0 && query.length) ? /*#__PURE__*/React__default.createElement(Container, {
|
|
13826
|
+
reorder: handleReorder
|
|
13865
13827
|
}, /*#__PURE__*/React__default.createElement(List$1, {
|
|
13866
|
-
id: "
|
|
13867
|
-
className:
|
|
13868
|
-
},
|
|
13869
|
-
var _column$columnDef$
|
|
13870
|
-
return (_column$columnDef$hea5 = column.columnDef.header) === null || _column$columnDef$hea5 === void 0 ? void 0 : _column$columnDef$hea5.toString().toLowerCase().includes(query.toLowerCase());
|
|
13871
|
-
}).map(column => {
|
|
13872
|
-
// When searching a column, we disable reordering and make it fixed
|
|
13873
|
-
const canBeReordered = isOrderingAllowed(table, column) && isQueryFilterNotApplied;
|
|
13874
|
-
const isColumnFixed = isColumnOrderingDisabled(table, column) && isQueryFilterNotApplied;
|
|
13828
|
+
id: "columns",
|
|
13829
|
+
className: listClassName
|
|
13830
|
+
}, columns.map(column => {
|
|
13831
|
+
var _column$columnDef$met2, _column$columnDef$met3;
|
|
13875
13832
|
return /*#__PURE__*/React__default.createElement(Item$3, {
|
|
13876
13833
|
key: column.id,
|
|
13877
|
-
disabled: !canBeReordered,
|
|
13878
13834
|
id: column.id,
|
|
13835
|
+
disabled: (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.disableReordering,
|
|
13879
13836
|
asChild: true
|
|
13880
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
13881
|
-
canBeReordered: canBeReordered,
|
|
13837
|
+
}, /*#__PURE__*/React__default.createElement(Column$1, {
|
|
13882
13838
|
column: column,
|
|
13883
|
-
|
|
13839
|
+
draggable: !((_column$columnDef$met3 = column.columnDef.meta) !== null && _column$columnDef$met3 !== void 0 && _column$columnDef$met3.disableReordering),
|
|
13840
|
+
isOrderingEnabled: true
|
|
13884
13841
|
}));
|
|
13885
|
-
}) :
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
13890
|
-
|
|
13891
|
-
};
|
|
13892
|
-
const ColumnSettingsButton = ({
|
|
13893
|
-
table
|
|
13894
|
-
}) => {
|
|
13895
|
-
const {
|
|
13896
|
-
texts
|
|
13897
|
-
} = useLocalization();
|
|
13898
|
-
const [query, setQuery] = React__default.useState('');
|
|
13899
|
-
const columns = table.getAllLeafColumns().filter(column => !isInternalColumn(column.id));
|
|
13900
|
-
const [state, setState] = React__default.useState({
|
|
13901
|
-
visible: columns.filter(column => column.getIsVisible()),
|
|
13902
|
-
hidden: columns.filter(column => !column.getIsVisible())
|
|
13903
|
-
});
|
|
13904
|
-
const initialOrderedColumns = React__default.useRef(columns);
|
|
13905
|
-
const moveColumnToList = column => {
|
|
13906
|
-
// If column can't hide then don't toggle visiblity
|
|
13907
|
-
if (column.getCanHide()) {
|
|
13908
|
-
column.toggleVisibility();
|
|
13909
|
-
}
|
|
13910
|
-
if (state.visible.find(c => c.id === column.id)) {
|
|
13911
|
-
setState(currentState => {
|
|
13912
|
-
const filteredColumns = currentState.visible.filter(c => c.id !== column.id);
|
|
13913
|
-
if (column.getCanHide()) {
|
|
13914
|
-
const hiddenColumns = [column].concat(...currentState.hidden);
|
|
13915
|
-
// Sort the hidden column so that they follow the initial order of fixed columns
|
|
13916
|
-
const sortedFixedHiddenColumns = hiddenColumns.filter(hiddenColumn => {
|
|
13917
|
-
var _hiddenColumn$columnD;
|
|
13918
|
-
return !!((_hiddenColumn$columnD = hiddenColumn.columnDef.meta) !== null && _hiddenColumn$columnD !== void 0 && _hiddenColumn$columnD.disableReordering);
|
|
13919
|
-
}).sort((colA, colB) => {
|
|
13920
|
-
const indexA = initialOrderedColumns.current.indexOf(colA);
|
|
13921
|
-
const indexB = initialOrderedColumns.current.indexOf(colB);
|
|
13922
|
-
return indexA - indexB;
|
|
13923
|
-
});
|
|
13924
|
-
const reorderableHiddenColumns = hiddenColumns.filter(hiddenColumn => {
|
|
13925
|
-
var _hiddenColumn$columnD2;
|
|
13926
|
-
return !((_hiddenColumn$columnD2 = hiddenColumn.columnDef.meta) !== null && _hiddenColumn$columnD2 !== void 0 && _hiddenColumn$columnD2.disableReordering);
|
|
13927
|
-
});
|
|
13928
|
-
return {
|
|
13929
|
-
visible: filteredColumns,
|
|
13930
|
-
hidden: [...sortedFixedHiddenColumns, ...reorderableHiddenColumns]
|
|
13931
|
-
};
|
|
13932
|
-
}
|
|
13933
|
-
// If column can't hide and it is dragged to hidden column list then move the column to the bottom of
|
|
13934
|
-
// the visible column list
|
|
13935
|
-
return {
|
|
13936
|
-
visible: filteredColumns.concat(column),
|
|
13937
|
-
hidden: currentState.hidden
|
|
13938
|
-
};
|
|
13939
|
-
});
|
|
13940
|
-
} else {
|
|
13941
|
-
setState(currentState => {
|
|
13942
|
-
let visibleColumns = [];
|
|
13943
|
-
// If ordering is allowed then we don't care about the previous column order
|
|
13944
|
-
if (isOrderingAllowed(table, column)) {
|
|
13945
|
-
visibleColumns = currentState.visible.concat(column);
|
|
13946
|
-
} else {
|
|
13947
|
-
const orderedVisibleColumns = initialOrderedColumns.current.filter(orderedColumn => !state.hidden.find(c => c.id === orderedColumn.id) || orderedColumn.id === column.id).map(({
|
|
13948
|
-
id
|
|
13949
|
-
}) => id);
|
|
13950
|
-
const movedColumnIndex = orderedVisibleColumns.indexOf(column.id);
|
|
13951
|
-
// Index of the column that is moved to visible list
|
|
13952
|
-
// Intial value for the index is the last item in visible list
|
|
13953
|
-
let index = currentState.visible.length;
|
|
13954
|
-
currentState.visible.find((col, colIndex) => {
|
|
13955
|
-
const columnIndex = orderedVisibleColumns.indexOf(col.id);
|
|
13956
|
-
// Index where the moved column should be shown in visible list
|
|
13957
|
-
if (movedColumnIndex < columnIndex) {
|
|
13958
|
-
index = colIndex;
|
|
13959
|
-
return true;
|
|
13960
|
-
}
|
|
13961
|
-
return false;
|
|
13962
|
-
});
|
|
13963
|
-
visibleColumns = currentState.visible.slice(0, index).concat(column).concat(currentState.visible.slice(index));
|
|
13964
|
-
}
|
|
13965
|
-
return {
|
|
13966
|
-
visible: visibleColumns,
|
|
13967
|
-
hidden: currentState.hidden.filter(c => c.id !== column.id)
|
|
13968
|
-
};
|
|
13969
|
-
});
|
|
13970
|
-
}
|
|
13971
|
-
};
|
|
13972
|
-
const reorderColumnInList = (draggedColumnId, targetColumnId, isVisible) => {
|
|
13973
|
-
var _columns$find, _columns$find$columnD;
|
|
13974
|
-
const isTargetColumnFixed = !!((_columns$find = columns.find(column => column.id === targetColumnId)) !== null && _columns$find !== void 0 && (_columns$find$columnD = _columns$find.columnDef.meta) !== null && _columns$find$columnD !== void 0 && _columns$find$columnD.disableReordering);
|
|
13975
|
-
if (isVisible) {
|
|
13976
|
-
let firstReorderableVisibleColumnId = targetColumnId;
|
|
13977
|
-
if (isTargetColumnFixed) {
|
|
13978
|
-
var _state$visible$find$i, _state$visible$find;
|
|
13979
|
-
firstReorderableVisibleColumnId = (_state$visible$find$i = (_state$visible$find = state.visible.find(visibleColumn => {
|
|
13980
|
-
var _visibleColumn$column;
|
|
13981
|
-
return !((_visibleColumn$column = visibleColumn.columnDef.meta) !== null && _visibleColumn$column !== void 0 && _visibleColumn$column.disableReordering);
|
|
13982
|
-
})) === null || _state$visible$find === void 0 ? void 0 : _state$visible$find.id) !== null && _state$visible$find$i !== void 0 ? _state$visible$find$i : targetColumnId;
|
|
13983
|
-
}
|
|
13984
|
-
setState(currentState => ({
|
|
13985
|
-
...currentState,
|
|
13986
|
-
visible: reorder(draggedColumnId, firstReorderableVisibleColumnId, currentState.visible)
|
|
13987
|
-
}));
|
|
13988
|
-
} else {
|
|
13989
|
-
let firstReorderableHiddenColumnId = targetColumnId;
|
|
13990
|
-
if (isTargetColumnFixed) {
|
|
13991
|
-
var _state$hidden$find$id, _state$hidden$find;
|
|
13992
|
-
firstReorderableHiddenColumnId = (_state$hidden$find$id = (_state$hidden$find = state.hidden.find(visibleColumn => {
|
|
13993
|
-
var _visibleColumn$column2;
|
|
13994
|
-
return !((_visibleColumn$column2 = visibleColumn.columnDef.meta) !== null && _visibleColumn$column2 !== void 0 && _visibleColumn$column2.disableReordering);
|
|
13995
|
-
})) === null || _state$hidden$find === void 0 ? void 0 : _state$hidden$find.id) !== null && _state$hidden$find$id !== void 0 ? _state$hidden$find$id : targetColumnId;
|
|
13996
|
-
}
|
|
13997
|
-
setState(currentState => ({
|
|
13998
|
-
...currentState,
|
|
13999
|
-
hidden: reorder(draggedColumnId, firstReorderableHiddenColumnId, currentState.hidden)
|
|
14000
|
-
}));
|
|
14001
|
-
}
|
|
14002
|
-
};
|
|
14003
|
-
const changeColumnOrder = newColumnOrder => {
|
|
14004
|
-
const internals = [];
|
|
14005
|
-
if (table.options.enableRowSelection) {
|
|
14006
|
-
internals.push(COLUMN_ID_FOR_SELECTION);
|
|
14007
|
-
}
|
|
14008
|
-
if (table.options.enableExpanding) {
|
|
14009
|
-
internals.push(COLUMN_ID_FOR_EXPANSION);
|
|
14010
|
-
}
|
|
14011
|
-
table.setColumnOrder(internals.concat(newColumnOrder.map(c => c.id)));
|
|
14012
|
-
};
|
|
14013
|
-
// probably a more elegant way to do this without local state but had
|
|
14014
|
-
// a range of issues using the native apis directly
|
|
14015
|
-
React__default.useEffect(() => {
|
|
14016
|
-
changeColumnOrder([...state.visible, ...state.hidden]);
|
|
14017
|
-
}, [state]);
|
|
14018
|
-
// This effect moves up all fixed/unorderable columns before orderable columns.
|
|
14019
|
-
// For custom column order, the fixed/unorderable columns will also move up before orderable columns.
|
|
14020
|
-
// The order between all fixed/unorderable column items, and all orderable column items will be same as it was
|
|
14021
|
-
// specified by the consumer.
|
|
14022
|
-
React__default.useEffect(() => {
|
|
14023
|
-
const orderableColumns = [];
|
|
14024
|
-
const fixedColumns = [];
|
|
14025
|
-
columns.forEach(column => {
|
|
14026
|
-
var _column$columnDef$met3;
|
|
14027
|
-
const isColumnFixed = !!((_column$columnDef$met3 = column.columnDef.meta) !== null && _column$columnDef$met3 !== void 0 && _column$columnDef$met3.disableReordering);
|
|
14028
|
-
if (isColumnFixed) {
|
|
14029
|
-
fixedColumns.push(column);
|
|
14030
|
-
} else {
|
|
14031
|
-
orderableColumns.push(column);
|
|
14032
|
-
}
|
|
14033
|
-
});
|
|
14034
|
-
const newOrderedColumns = [...fixedColumns, ...orderableColumns];
|
|
14035
|
-
// Changes order in the table
|
|
14036
|
-
changeColumnOrder(newOrderedColumns);
|
|
14037
|
-
// Changes order in the column settings button popover
|
|
14038
|
-
setState({
|
|
14039
|
-
visible: newOrderedColumns.filter(column => column.getIsVisible()),
|
|
14040
|
-
hidden: newOrderedColumns.filter(column => !column.getIsVisible())
|
|
14041
|
-
});
|
|
14042
|
-
// update initial column order
|
|
14043
|
-
initialOrderedColumns.current = newOrderedColumns;
|
|
14044
|
-
}, []);
|
|
13842
|
+
}))) : /*#__PURE__*/React__default.createElement("div", {
|
|
13843
|
+
className: listClassName
|
|
13844
|
+
}, columns.length ? columns.map(column => /*#__PURE__*/React__default.createElement(Column$1, {
|
|
13845
|
+
column: column,
|
|
13846
|
+
key: column.id
|
|
13847
|
+
})) : texts.table2.columnSettings.noResults))));
|
|
14045
13848
|
return /*#__PURE__*/React__default.createElement(Button$1, {
|
|
14046
|
-
|
|
14047
|
-
popover: popoverProps => /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps), /*#__PURE__*/React__default.createElement(Popover.Content, {
|
|
14048
|
-
align: "end"
|
|
14049
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
14050
|
-
className: "flex w-60 flex-col gap-2"
|
|
14051
|
-
}, table.options.enableHiding ? /*#__PURE__*/React__default.createElement(Input, {
|
|
14052
|
-
onChange: event => setQuery(event.target.value),
|
|
14053
|
-
placeholder: texts.table2.columnSettings.search,
|
|
14054
|
-
value: query
|
|
14055
|
-
}) : null, /*#__PURE__*/React__default.createElement("div", {
|
|
14056
|
-
className: "-ml-[calc(theme(spacing.4)_-_2px)] -mb-2 max-h-64 w-[calc(100%_+_theme(spacing.7)_-_1px)] overflow-auto"
|
|
14057
|
-
}, /*#__PURE__*/React__default.createElement(SortableColumnContainer, {
|
|
14058
|
-
state: state,
|
|
14059
|
-
moveColumn: moveColumnToList,
|
|
14060
|
-
reorderColumn: reorderColumnInList,
|
|
14061
|
-
table: table,
|
|
14062
|
-
query: query
|
|
14063
|
-
}))))),
|
|
13849
|
+
popover: popover,
|
|
14064
13850
|
tooltip: texts.table2.columnSettings.tooltip
|
|
14065
13851
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
|
14066
13852
|
name: "columns"
|
|
14067
|
-
}), texts.table2.columnSettings.button);
|
|
14068
|
-
}
|
|
13853
|
+
}), " ", texts.table2.columnSettings.button);
|
|
13854
|
+
}
|
|
14069
13855
|
|
|
14070
13856
|
const ExpandedRow = ({
|
|
14071
13857
|
index,
|
|
@@ -14218,7 +14004,7 @@ const Row$1 = props => {
|
|
|
14218
14004
|
}, /*#__PURE__*/React__default.createElement(InternalRow, Object.assign({}, props)));
|
|
14219
14005
|
};
|
|
14220
14006
|
|
|
14221
|
-
const Column$
|
|
14007
|
+
const Column$2 = ({
|
|
14222
14008
|
allColumns,
|
|
14223
14009
|
column,
|
|
14224
14010
|
index,
|
|
@@ -14459,7 +14245,7 @@ const ColumnFilter = props => {
|
|
|
14459
14245
|
className: "mb-2 flex gap-2"
|
|
14460
14246
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
14461
14247
|
className: "flex w-14 flex-shrink-0 items-center justify-end pr-2 text-right"
|
|
14462
|
-
}, index === 0 ? 'Where' : 'And'), /*#__PURE__*/React__default.createElement(Column$
|
|
14248
|
+
}, index === 0 ? 'Where' : 'And'), /*#__PURE__*/React__default.createElement(Column$2, {
|
|
14463
14249
|
className: "!w-32 flex-shrink-0",
|
|
14464
14250
|
allColumns: allColumns,
|
|
14465
14251
|
column: column,
|
|
@@ -14715,10 +14501,10 @@ const EditModeButton = /*#__PURE__*/React__default.forwardRef(function EditModeB
|
|
|
14715
14501
|
}), texts.table2.editing.button);
|
|
14716
14502
|
});
|
|
14717
14503
|
|
|
14718
|
-
function Column$
|
|
14504
|
+
function Column$3(_) {
|
|
14719
14505
|
return null;
|
|
14720
14506
|
}
|
|
14721
|
-
Column$
|
|
14507
|
+
Column$3.displayName = 'Table2Column';
|
|
14722
14508
|
const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref) {
|
|
14723
14509
|
// dom
|
|
14724
14510
|
const {
|
|
@@ -14747,6 +14533,16 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
|
|
|
14747
14533
|
columnOrder,
|
|
14748
14534
|
globalFilter
|
|
14749
14535
|
} = table.getState();
|
|
14536
|
+
React__default.useEffect(() => {
|
|
14537
|
+
if (tableRef.current) {
|
|
14538
|
+
tableRef.current.instance = {
|
|
14539
|
+
resetFiltering: () => table.resetColumnFilters(),
|
|
14540
|
+
resetRowExpansion: () => table.resetExpanded(),
|
|
14541
|
+
resetRowSelection: () => table.resetRowSelection(),
|
|
14542
|
+
resetSorting: () => table.resetSorting()
|
|
14543
|
+
};
|
|
14544
|
+
}
|
|
14545
|
+
}, [table, tableRef.current]);
|
|
14750
14546
|
// If column visibility or order changes then we turn off the edit mode so that control indexes gets computed
|
|
14751
14547
|
// when user turns on the editing mode again. This is a temporary solution to make sure the keyboard navigation
|
|
14752
14548
|
// still keeps working on changes in column visibility, order, or both
|
|
@@ -15077,7 +14873,7 @@ const Table2 = /*#__PURE__*/React__default.forwardRef(function Table2(props, ref
|
|
|
15077
14873
|
table: table
|
|
15078
14874
|
}) : null);
|
|
15079
14875
|
});
|
|
15080
|
-
Table2.Column = Column$
|
|
14876
|
+
Table2.Column = Column$3;
|
|
15081
14877
|
|
|
15082
14878
|
const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(props, ref) {
|
|
15083
14879
|
const {
|