@economic/taco 2.6.0 → 2.7.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/Icon/components/AttachWarning.d.ts +3 -0
- package/dist/components/Icon/components/index.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Menu/components/Item.d.ts +1 -1
- package/dist/components/Menu/components/Link.d.ts +1 -1
- package/dist/components/Navigation2/components/Link.d.ts +1 -1
- package/dist/components/Select2/components/Option.d.ts +1 -1
- package/dist/components/Select2/components/Search.d.ts +1 -1
- package/dist/components/Select2/components/Trigger.d.ts +1 -1
- package/dist/components/Table3/components/columns/cell/EditingCell.d.ts +5 -2
- package/dist/components/Table3/components/columns/cell/EditingControl.d.ts +21 -0
- package/dist/components/Table3/components/columns/cell/controls/TextAreaControl.d.ts +2 -0
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/esm/index.css +85 -22
- package/dist/esm/packages/taco/src/components/Icon/components/AttachWarning.js +19 -0
- package/dist/esm/packages/taco/src/components/Icon/components/AttachWarning.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js +2 -0
- package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +10 -3
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +27 -145
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js +158 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextAreaControl.js +102 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextAreaControl.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -1
- package/dist/index.css +85 -22
- package/dist/primitives/Listbox2/components/Root.d.ts +1 -1
- package/dist/primitives/Listbox2/types.d.ts +1 -1
- package/dist/taco.cjs.development.js +310 -163
- 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 +14876 -12163
@@ -318,6 +318,21 @@ function IconAttachCancel(props, svgRef) {
|
|
318
318
|
}
|
319
319
|
var AttachCancel = /*#__PURE__*/React.forwardRef(IconAttachCancel);
|
320
320
|
|
321
|
+
function IconAttachWarning(props, svgRef) {
|
322
|
+
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
323
|
+
fill: "none",
|
324
|
+
xmlns: "http://www.w3.org/2000/svg",
|
325
|
+
viewBox: "0 0 24 24",
|
326
|
+
ref: svgRef
|
327
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
328
|
+
fillRule: "evenodd",
|
329
|
+
clipRule: "evenodd",
|
330
|
+
d: "M12.38 3.688a3.75 3.75 0 015.44 5.16l-.137.144-9.132 9.131a2.25 2.25 0 01-3.287-3.069l.105-.113 6.657-6.656a.75.75 0 011.128.983l-.068.077-6.656 6.657a.75.75 0 00.984 1.128l.076-.067 9.132-9.132a2.25 2.25 0 00-3.07-3.287l-.112.105-9.132 9.132a3.75 3.75 0 005.16 5.44l.144-.137 1.934-1.935a6.062 6.062 0 00.09 2.031l-.964.965a5.25 5.25 0 01-7.574-7.269l.15-.156 9.131-9.132zM22 18a4.5 4.5 0 10-9 0 4.5 4.5 0 009 0zm-5.243-2.852a.75.75 0 011.493.102v3.5l-.007.102a.75.75 0 01-1.493-.102v-3.5l.007-.102zM17.5 20a.75.75 0 100 1.5.75.75 0 000-1.5z",
|
331
|
+
fill: "currentColor"
|
332
|
+
}));
|
333
|
+
}
|
334
|
+
var AttachWarning = /*#__PURE__*/React.forwardRef(IconAttachWarning);
|
335
|
+
|
321
336
|
function IconAttach(props, svgRef) {
|
322
337
|
return /*#__PURE__*/React.createElement("svg", Object.assign({
|
323
338
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -3201,6 +3216,7 @@ const icons = {
|
|
3201
3216
|
'arrow-up': ArrowUp,
|
3202
3217
|
'attach-auto': AttachAuto,
|
3203
3218
|
'attach-cancel': AttachCancel,
|
3219
|
+
'attach-warning': AttachWarning,
|
3204
3220
|
attach: Attach,
|
3205
3221
|
'autotext-insert': AutotextInsert,
|
3206
3222
|
autotext: Autotext,
|
@@ -9953,7 +9969,7 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
9953
9969
|
}, /*#__PURE__*/React__default.createElement("div", {
|
9954
9970
|
className: "flex flex-wrap gap-1"
|
9955
9971
|
}, valuesAsChildren.map(child => /*#__PURE__*/React__default.createElement(Tag$1, {
|
9956
|
-
key: child.props.value,
|
9972
|
+
key: String(child.props.value),
|
9957
9973
|
className: "truncate",
|
9958
9974
|
color: tags ? child.props.color : undefined,
|
9959
9975
|
disabled: disabled,
|
@@ -16294,7 +16310,7 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
|
|
16294
16310
|
className: className,
|
16295
16311
|
"data-align": align,
|
16296
16312
|
"data-column-index": index,
|
16297
|
-
role: "
|
16313
|
+
role: "columnheader"
|
16298
16314
|
}, typeof meta.footer === 'function' ? /*#__PURE__*/React__default.createElement("span", {
|
16299
16315
|
className: "flex-grow truncate"
|
16300
16316
|
}, meta.footer(table.getRowModel().rows.map(row => row.original[id]))) : null);
|
@@ -16340,7 +16356,7 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
|
|
16340
16356
|
const actionsOnRow = visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);
|
16341
16357
|
const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);
|
16342
16358
|
content = /*#__PURE__*/React__default.createElement("span", {
|
16343
|
-
className: "-mb-2 -mt-
|
16359
|
+
className: "-mb-2 -mt-1.5 flex justify-end pl-2 text-right",
|
16344
16360
|
ref: ref
|
16345
16361
|
}, actionsOnRow.map((button, index) => {
|
16346
16362
|
var _ref, _button$props$tooltip;
|
@@ -16390,7 +16406,7 @@ function createRowActionsColumn$1() {
|
|
16390
16406
|
footer: Footer$4,
|
16391
16407
|
meta: {
|
16392
16408
|
align: 'right',
|
16393
|
-
className: cn('!pt-[var(--table3-row-padding)] print:opacity-0 [[role="table"][data-editing="false"]_&]:group-[[data-current="true"]]/row:sticky [[role="table"][data-pause-hover="false"][data-editing="false"]_&]:group-hover/row:sticky right-0 !pl-1 !pr-1', '
|
16409
|
+
className: cn('!pt-[var(--table3-row-padding)] print:opacity-0 [[role="table"][data-editing="false"]_&]:group-[[data-current="true"]]/row:sticky [[role="table"][data-pause-hover="false"][data-editing="false"]_&]:group-hover/row:sticky right-0 !pl-1 !pr-1', 'shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]', 'group-[[data-current="true"][data-selected="false"]]/row:text-grey-200', 'group-[[data-selected="true"]]/row:text-blue-100', 'group-[[data-selected="false"]:hover]/row:text-grey-100'),
|
16394
16410
|
enableOrdering: false,
|
16395
16411
|
enableSearch: false,
|
16396
16412
|
enableTruncate: false,
|
@@ -17529,121 +17545,133 @@ const willRowMoveAfterSorting$1 = (value, cell, rowIndex, rows, desc) => {
|
|
17529
17545
|
return ((_resortedRows$index = resortedRows[index]) === null || _resortedRows$index === void 0 ? void 0 : _resortedRows$index.id) !== cell.row.id;
|
17530
17546
|
};
|
17531
17547
|
|
17532
|
-
function
|
17533
|
-
return /*#__PURE__*/React__default.createElement(MemoedEditingCell, Object.assign({}, props));
|
17534
|
-
}
|
17535
|
-
const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
|
17536
|
-
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$curre;
|
17548
|
+
const Textarea = /*#__PURE__*/React.forwardRef(function Textarea(props, ref) {
|
17537
17549
|
const {
|
17538
|
-
|
17550
|
+
defaultValue: _,
|
17551
|
+
highlighted,
|
17552
|
+
invalid,
|
17553
|
+
onKeyDown,
|
17554
|
+
...otherProps
|
17555
|
+
} = props;
|
17556
|
+
const classNames = cn(getInputClasses(props), 'py-1 min-h-[75px] disabled:resize-none', props.className);
|
17557
|
+
// home and end keys only navigate to the start/end of textarea value if the textarea container does not scroll
|
17558
|
+
// if it has scroll height then the browser reverts to native scrolling behaviour only
|
17559
|
+
// so we manually override it to ensure _our_ desired behaviour remains intact
|
17560
|
+
const handleKeyDown = event => {
|
17561
|
+
if (event.key === 'Home' || event.key === 'End') {
|
17562
|
+
event.preventDefault();
|
17563
|
+
const position = event.key === 'End' ? event.currentTarget.value.length : 0;
|
17564
|
+
event.currentTarget.setSelectionRange(position, position);
|
17565
|
+
event.currentTarget.scrollTop = event.key === 'End' ? event.currentTarget.scrollHeight : 0;
|
17566
|
+
}
|
17567
|
+
if (onKeyDown) {
|
17568
|
+
onKeyDown(event);
|
17569
|
+
}
|
17570
|
+
};
|
17571
|
+
return /*#__PURE__*/React.createElement("textarea", Object.assign({}, otherProps, {
|
17572
|
+
className: classNames,
|
17573
|
+
"data-taco": "textarea",
|
17574
|
+
onKeyDown: handleKeyDown,
|
17575
|
+
ref: ref
|
17576
|
+
}));
|
17577
|
+
});
|
17578
|
+
|
17579
|
+
const TextAreaControl = /*#__PURE__*/React__default.forwardRef(function TextAreaControl(props, externalRef) {
|
17580
|
+
const {
|
17581
|
+
onKeyDown: handleKeyDown,
|
17582
|
+
onChange: handleChange,
|
17539
17583
|
column,
|
17540
|
-
|
17541
|
-
|
17542
|
-
|
17543
|
-
|
17544
|
-
|
17584
|
+
isCellInDetailMode,
|
17585
|
+
align,
|
17586
|
+
isCurrentRow,
|
17587
|
+
value,
|
17588
|
+
...attributes
|
17545
17589
|
} = props;
|
17546
|
-
const
|
17590
|
+
const textareaMaxHeight = 120;
|
17591
|
+
const textareaMinHeight = 32;
|
17547
17592
|
const columnMeta = column.columnDef.meta;
|
17548
|
-
const
|
17549
|
-
|
17550
|
-
|
17551
|
-
|
17552
|
-
|
17553
|
-
|
17554
|
-
|
17555
|
-
|
17556
|
-
|
17557
|
-
|
17558
|
-
|
17559
|
-
|
17560
|
-
const
|
17561
|
-
|
17562
|
-
|
17563
|
-
|
17564
|
-
|
17565
|
-
const pinnedColumnsWidth = lastFrozenRect.left + lastFrozenRect.width;
|
17566
|
-
tableElement.scrollTo(cellRect.left - pinnedColumnsWidth, tableElement.scrollTop);
|
17567
|
-
// Check for editing actions overlap
|
17568
|
-
} else if (cellRect && tableRect && cellRect.right > tableRect.right - EDITING_ACTIONS_WIDTH) {
|
17569
|
-
const spaceBetweenCellAndEditingActions = 10;
|
17570
|
-
tableElement.scrollTo(
|
17571
|
-
// Need to take into account if table has been already scrolled.
|
17572
|
-
tableElement.scrollLeft + EDITING_ACTIONS_WIDTH + spaceBetweenCellAndEditingActions, tableElement.scrollTop);
|
17593
|
+
const ref = useMergedRef(externalRef);
|
17594
|
+
React__default.useEffect(() => {
|
17595
|
+
// If truncation is not enabled, then textarea should re-calculate it's height to fit with it's own content, when initialized.
|
17596
|
+
if (ref !== null && ref !== void 0 && ref.current && !(columnMeta !== null && columnMeta !== void 0 && columnMeta.enableTruncate)) {
|
17597
|
+
const textareaElement = ref === null || ref === void 0 ? void 0 : ref.current;
|
17598
|
+
resizeTextArea(textareaElement);
|
17599
|
+
}
|
17600
|
+
}, []);
|
17601
|
+
React__default.useEffect(() => {
|
17602
|
+
// If truncation is enabled, then textarea should only adjust to it's own content, when in detail mode.
|
17603
|
+
// Otherwise it should collapse to minimal height.
|
17604
|
+
if (ref !== null && ref !== void 0 && ref.current && columnMeta !== null && columnMeta !== void 0 && columnMeta.enableTruncate) {
|
17605
|
+
const textareaElement = ref === null || ref === void 0 ? void 0 : ref.current;
|
17606
|
+
if (isCellInDetailMode) {
|
17607
|
+
resizeTextArea(textareaElement);
|
17608
|
+
} else {
|
17609
|
+
textareaElement.style.height = `${textareaMinHeight}px`;
|
17573
17610
|
}
|
17574
17611
|
}
|
17575
|
-
|
17576
|
-
|
17577
|
-
|
17578
|
-
|
17612
|
+
}, [isCellInDetailMode]);
|
17613
|
+
const resizeTextArea = textareaElement => {
|
17614
|
+
// Need to set inherit before calculating height, so that browser sets the scrollHeight properly,
|
17615
|
+
// depending on text inside.
|
17616
|
+
const textareaRect = textareaElement.getBoundingClientRect();
|
17617
|
+
const prevHeight = textareaRect.height;
|
17618
|
+
if (columnMeta !== null && columnMeta !== void 0 && columnMeta.enableTruncate) {
|
17619
|
+
if (prevHeight < textareaMaxHeight) {
|
17620
|
+
textareaElement.style.height = 'inherit';
|
17621
|
+
textareaElement.style.height = `${Math.min(textareaElement.scrollHeight, textareaMaxHeight)}px`;
|
17622
|
+
}
|
17623
|
+
} else {
|
17624
|
+
textareaElement.style.height = 'inherit';
|
17625
|
+
textareaElement.style.height = `${textareaElement.scrollHeight}px`;
|
17579
17626
|
}
|
17580
17627
|
};
|
17581
|
-
const
|
17582
|
-
|
17583
|
-
};
|
17584
|
-
// row move indicator
|
17585
|
-
const moveReason = (_tableMeta$editing$ro = tableMeta.editing.rowMoveReason[cell.column.id]) !== null && _tableMeta$editing$ro !== void 0 ? _tableMeta$editing$ro : null;
|
17586
|
-
const rows = table.getRowModel().rows;
|
17587
|
-
const isCurrentRow = ((_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.id) === row.id;
|
17588
|
-
const mountNode = React__default.useMemo(() => {
|
17589
|
-
if (moveReason) {
|
17590
|
-
var _cellRef$current2, _cellRef$current2$par;
|
17591
|
-
return (_cellRef$current2 = cellRef.current) === null || _cellRef$current2 === void 0 ? void 0 : (_cellRef$current2$par = _cellRef$current2.parentElement) === null || _cellRef$current2$par === void 0 ? void 0 : _cellRef$current2$par.firstChild;
|
17592
|
-
}
|
17593
|
-
return null;
|
17594
|
-
}, [moveReason, cellRef]);
|
17595
|
-
const removeMoveReason = () => {
|
17596
|
-
tableMeta.editing.removeRowMoveReason(cell.column.id);
|
17628
|
+
const handleTextareaChange = e => {
|
17629
|
+
resizeTextArea(e.target);
|
17597
17630
|
};
|
17598
|
-
|
17599
|
-
|
17600
|
-
|
17601
|
-
|
17631
|
+
const textareaContainerClassName = cn('w-full', {
|
17632
|
+
'focus-within:absolute focus-within:left-0 focus-within:top-0 focus-within:z-20 focus-within:px-2 focus-within:pt-[var(--table3-row-padding)]': columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate
|
17633
|
+
});
|
17634
|
+
const handleTextareaKeyDown = event => {
|
17635
|
+
// By default Shift + Enter in textarea makes a new line, we want to keep this behaviour
|
17636
|
+
if (event.shiftKey && event.key === 'Enter') {
|
17602
17637
|
return;
|
17603
|
-
}
|
17604
|
-
if (hasChanged$1(getValue(), value)) {
|
17605
|
-
const moveReason = getRowMoveReason(table, row.index, row.original, cell, value);
|
17606
|
-
tableMeta.editing.setRowMoveReason({
|
17607
|
-
[cell.column.id]: moveReason
|
17608
|
-
});
|
17609
17638
|
} else {
|
17610
|
-
|
17639
|
+
handleKeyDown(event);
|
17611
17640
|
}
|
17612
|
-
|
17613
|
-
|
17614
|
-
|
17615
|
-
|
17616
|
-
|
17617
|
-
|
17618
|
-
|
17619
|
-
|
17620
|
-
|
17621
|
-
|
17622
|
-
|
17623
|
-
|
17624
|
-
|
17625
|
-
|
17626
|
-
|
17627
|
-
|
17628
|
-
|
17629
|
-
|
17630
|
-
|
17631
|
-
|
17632
|
-
|
17633
|
-
|
17634
|
-
|
17635
|
-
|
17636
|
-
|
17637
|
-
|
17638
|
-
|
17639
|
-
|
17640
|
-
|
17641
|
-
value: value,
|
17642
|
-
cell: cell
|
17641
|
+
};
|
17642
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
17643
|
+
className: textareaContainerClassName,
|
17644
|
+
"data-taco": "input-container"
|
17645
|
+
}, /*#__PURE__*/React__default.createElement(Textarea, Object.assign({}, attributes, {
|
17646
|
+
onChange: event => {
|
17647
|
+
handleChange(event.target.value);
|
17648
|
+
handleTextareaChange(event);
|
17649
|
+
},
|
17650
|
+
rows: 1,
|
17651
|
+
onKeyDown: e => {
|
17652
|
+
handleTextareaKeyDown(e);
|
17653
|
+
},
|
17654
|
+
onBlur: event => {
|
17655
|
+
// If truncation is enabled, then textarea should shring back to min height, when loosing focus.
|
17656
|
+
if (columnMeta !== null && columnMeta !== void 0 && columnMeta.enableTruncate) {
|
17657
|
+
const textareaElement = event.currentTarget;
|
17658
|
+
textareaElement.style.height = `${textareaMinHeight}px`;
|
17659
|
+
}
|
17660
|
+
},
|
17661
|
+
className: cn(getCellAlignmentClasses$1(align), `z-20 h-fit resize-none`, {
|
17662
|
+
[`!min-h-[${textareaMinHeight}px]`]: columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate,
|
17663
|
+
'!yt-focus-dark': isCellInDetailMode,
|
17664
|
+
[`h-[${textareaMinHeight}px]`]: !isCellInDetailMode && (columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate),
|
17665
|
+
// Only allow resizing when focused and truncation enabled
|
17666
|
+
'focus:resize-y': isCurrentRow && (columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate)
|
17667
|
+
}),
|
17668
|
+
ref: ref,
|
17669
|
+
value: String(value !== null && value !== void 0 ? value : '')
|
17643
17670
|
})));
|
17644
17671
|
});
|
17645
|
-
|
17646
|
-
|
17672
|
+
|
17673
|
+
const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(props, externalRef) {
|
17674
|
+
var _ref$current;
|
17647
17675
|
const {
|
17648
17676
|
align,
|
17649
17677
|
column,
|
@@ -17654,11 +17682,16 @@ const Control = /*#__PURE__*/React__default.forwardRef(function Control(props, r
|
|
17654
17682
|
tableRef,
|
17655
17683
|
value,
|
17656
17684
|
cell,
|
17685
|
+
isCurrentRow,
|
17657
17686
|
...attributes
|
17658
17687
|
} = props;
|
17659
17688
|
const tableMeta = table.options.meta;
|
17660
|
-
const
|
17689
|
+
const ref = React__default.useRef();
|
17690
|
+
const refCallback = mergeRefs([ref, externalRef]);
|
17691
|
+
const columnMeta = column.columnDef.meta;
|
17692
|
+
const controlRenderer = columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.control;
|
17661
17693
|
const isCellInDetailMode = tableMeta.editing.detailModeEditing && (ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains(document.activeElement));
|
17694
|
+
// Revert to initial value if escape was pressed
|
17662
17695
|
const handleKeyDown = event => {
|
17663
17696
|
const target = event.target;
|
17664
17697
|
if (target.readOnly) {
|
@@ -17666,12 +17699,10 @@ const Control = /*#__PURE__*/React__default.forwardRef(function Control(props, r
|
|
17666
17699
|
}
|
17667
17700
|
// prevent row arrow shortcuts triggering when in detail mode
|
17668
17701
|
if (tableMeta.editing.detailModeEditing && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) {
|
17669
|
-
event.preventDefault();
|
17670
17702
|
event.stopPropagation();
|
17671
17703
|
}
|
17672
17704
|
if (event.key === 'Escape') {
|
17673
17705
|
event.preventDefault();
|
17674
|
-
// Revert to initial value if escape was pressed in detail mode.
|
17675
17706
|
if (tableMeta.editing.detailModeEditing) {
|
17676
17707
|
tableMeta.editing.setDetailModeEditing(false);
|
17677
17708
|
if (value !== initialValue) {
|
@@ -17689,7 +17720,9 @@ const Control = /*#__PURE__*/React__default.forwardRef(function Control(props, r
|
|
17689
17720
|
}
|
17690
17721
|
}
|
17691
17722
|
} else {
|
17723
|
+
var _tableRef$current;
|
17692
17724
|
tableMeta.editing.toggleEditing(false);
|
17725
|
+
(_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.focus();
|
17693
17726
|
}
|
17694
17727
|
return;
|
17695
17728
|
}
|
@@ -17707,6 +17740,15 @@ const Control = /*#__PURE__*/React__default.forwardRef(function Control(props, r
|
|
17707
17740
|
return;
|
17708
17741
|
}
|
17709
17742
|
};
|
17743
|
+
const isNumber = typeof value === 'number';
|
17744
|
+
const handleInputKeyDown = event => {
|
17745
|
+
handleKeyDown(event);
|
17746
|
+
// Switching to editing mode, when key pressed any alphabetical character or number
|
17747
|
+
if (/^[a-z0-9]$/i.test(event.key)) {
|
17748
|
+
tableMeta.editing.setDetailModeEditing(true);
|
17749
|
+
return;
|
17750
|
+
}
|
17751
|
+
};
|
17710
17752
|
const handleDatepickerChange = event => {
|
17711
17753
|
// When datepicker looses focus, it triggers change event, even if date wasn't changed,
|
17712
17754
|
// so adding additional check here to prevent adding change to the edititng state.
|
@@ -17719,7 +17761,7 @@ const Control = /*#__PURE__*/React__default.forwardRef(function Control(props, r
|
|
17719
17761
|
if (typeof controlRenderer === 'function') {
|
17720
17762
|
return controlRenderer({
|
17721
17763
|
...attributes,
|
17722
|
-
ref,
|
17764
|
+
ref: ref,
|
17723
17765
|
setValue: nextValue => {
|
17724
17766
|
if (nextValue !== value) {
|
17725
17767
|
handleChange(nextValue);
|
@@ -17741,7 +17783,7 @@ const Control = /*#__PURE__*/React__default.forwardRef(function Control(props, r
|
|
17741
17783
|
}),
|
17742
17784
|
onChange: handleDatepickerChange,
|
17743
17785
|
onKeyDown: handleDatepickerKeyDown,
|
17744
|
-
ref:
|
17786
|
+
ref: refCallback,
|
17745
17787
|
value: value
|
17746
17788
|
}));
|
17747
17789
|
} else if (controlRenderer === 'switch') {
|
@@ -17749,18 +17791,15 @@ const Control = /*#__PURE__*/React__default.forwardRef(function Control(props, r
|
|
17749
17791
|
className: "mx-2 mt-1.5",
|
17750
17792
|
checked: Boolean(value),
|
17751
17793
|
onChange: handleChange,
|
17752
|
-
ref:
|
17794
|
+
ref: refCallback
|
17795
|
+
}));
|
17796
|
+
} else if (controlRenderer === 'textarea') {
|
17797
|
+
return /*#__PURE__*/React__default.createElement(TextAreaControl, Object.assign({}, props, {
|
17798
|
+
isCellInDetailMode: isCellInDetailMode,
|
17799
|
+
onKeyDown: handleInputKeyDown,
|
17800
|
+
ref: refCallback
|
17753
17801
|
}));
|
17754
17802
|
}
|
17755
|
-
const isNumber = typeof value === 'number';
|
17756
|
-
const handleInputKeyDown = event => {
|
17757
|
-
handleKeyDown(event);
|
17758
|
-
// Switching to editing mode, when key pressed any alphabetical character or number
|
17759
|
-
if (/^[a-z0-9]$/i.test(event.key)) {
|
17760
|
-
tableMeta.editing.setDetailModeEditing(true);
|
17761
|
-
return;
|
17762
|
-
}
|
17763
|
-
};
|
17764
17803
|
return /*#__PURE__*/React__default.createElement(Input, Object.assign({}, attributes, {
|
17765
17804
|
className: cn(getInputAppearanceClassnames(), getCellAlignmentClasses$1(align), {
|
17766
17805
|
'!yt-focus-dark': isCellInDetailMode
|
@@ -17769,11 +17808,143 @@ const Control = /*#__PURE__*/React__default.forwardRef(function Control(props, r
|
|
17769
17808
|
handleChange(event.target.value);
|
17770
17809
|
},
|
17771
17810
|
onKeyDown: handleInputKeyDown,
|
17772
|
-
ref:
|
17811
|
+
ref: refCallback,
|
17773
17812
|
type: isNumber ? 'number' : undefined,
|
17774
17813
|
value: isNumber ? value : String(value !== null && value !== void 0 ? value : '')
|
17775
17814
|
}));
|
17776
17815
|
});
|
17816
|
+
|
17817
|
+
function EditingCell$1(props) {
|
17818
|
+
const {
|
17819
|
+
isHovered
|
17820
|
+
} = useRowContext$1();
|
17821
|
+
// Need to explicitly pass tableMeta, because just passing the table object will not trigger editing change since table object is not mutatable.
|
17822
|
+
const tableMeta = props.table.options.meta;
|
17823
|
+
return /*#__PURE__*/React__default.createElement(MemoedEditingCell, Object.assign({}, props, {
|
17824
|
+
isHovered: isHovered,
|
17825
|
+
tableMeta: tableMeta
|
17826
|
+
}));
|
17827
|
+
}
|
17828
|
+
const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditingCell(props) {
|
17829
|
+
var _tableMeta$editing$ge, _tableMeta$editing$ro, _rows$tableMeta$curre, _column$columnDef$met;
|
17830
|
+
const {
|
17831
|
+
cell,
|
17832
|
+
column,
|
17833
|
+
index,
|
17834
|
+
getValue,
|
17835
|
+
table,
|
17836
|
+
tableRef,
|
17837
|
+
row,
|
17838
|
+
isHovered,
|
17839
|
+
tableMeta
|
17840
|
+
} = props;
|
17841
|
+
const columnMeta = column.columnDef.meta;
|
17842
|
+
const cellRef = React__default.useRef(null);
|
17843
|
+
const controlRef = React__default.useRef(null);
|
17844
|
+
const handleChange = value => tableMeta.editing.setCellValue(cell, value);
|
17845
|
+
const value = (_tableMeta$editing$ge = tableMeta.editing.getCellValue(cell)) !== null && _tableMeta$editing$ge !== void 0 ? _tableMeta$editing$ge : getValue();
|
17846
|
+
const handleFocus = event => {
|
17847
|
+
var _event$target;
|
17848
|
+
// Check if cell is hidden behind pinned columns or edititng actions, and scroll to it.
|
17849
|
+
const frozenColumnIndex = tableMeta.columnFreezing.frozenColumnIndex;
|
17850
|
+
const tableElement = tableRef.current;
|
17851
|
+
if (tableElement && frozenColumnIndex !== undefined && index > frozenColumnIndex) {
|
17852
|
+
var _cellRef$current;
|
17853
|
+
const lastFrozenColumnElement = getCurrentRowCellElement(frozenColumnIndex, tableElement);
|
17854
|
+
const cellRect = (_cellRef$current = cellRef.current) === null || _cellRef$current === void 0 ? void 0 : _cellRef$current.getBoundingClientRect();
|
17855
|
+
const lastFrozenRect = lastFrozenColumnElement === null || lastFrozenColumnElement === void 0 ? void 0 : lastFrozenColumnElement.getBoundingClientRect();
|
17856
|
+
const tableRect = tableElement.getBoundingClientRect();
|
17857
|
+
// Check for pinned columns overlap
|
17858
|
+
if (cellRect && lastFrozenRect && cellRect.left < lastFrozenRect.left + lastFrozenRect.width) {
|
17859
|
+
const pinnedColumnsWidth = lastFrozenRect.left + lastFrozenRect.width;
|
17860
|
+
tableElement.scrollTo(cellRect.left - pinnedColumnsWidth, tableElement.scrollTop);
|
17861
|
+
// Check for editing actions overlap
|
17862
|
+
} else if (cellRect && tableRect && cellRect.right > tableRect.right - EDITING_ACTIONS_WIDTH) {
|
17863
|
+
const spaceBetweenCellAndEditingActions = 10;
|
17864
|
+
tableElement.scrollTo(
|
17865
|
+
// Need to take into account if table has been already scrolled.
|
17866
|
+
tableElement.scrollLeft + EDITING_ACTIONS_WIDTH + spaceBetweenCellAndEditingActions, tableElement.scrollTop);
|
17867
|
+
}
|
17868
|
+
}
|
17869
|
+
if ((_event$target = event.target) !== null && _event$target !== void 0 && _event$target.select) {
|
17870
|
+
requestAnimationFrame(() => {
|
17871
|
+
event.target.select();
|
17872
|
+
});
|
17873
|
+
}
|
17874
|
+
};
|
17875
|
+
const handleBlur = () => {
|
17876
|
+
tableMeta.editing.setDetailModeEditing(false);
|
17877
|
+
};
|
17878
|
+
// row move indicator
|
17879
|
+
const moveReason = (_tableMeta$editing$ro = tableMeta.editing.rowMoveReason[cell.column.id]) !== null && _tableMeta$editing$ro !== void 0 ? _tableMeta$editing$ro : null;
|
17880
|
+
const rows = table.getRowModel().rows;
|
17881
|
+
const isCurrentRow = ((_rows$tableMeta$curre = rows[tableMeta.currentRow.currentRowIndex]) === null || _rows$tableMeta$curre === void 0 ? void 0 : _rows$tableMeta$curre.id) === row.id;
|
17882
|
+
const mountNode = React__default.useMemo(() => {
|
17883
|
+
if (moveReason) {
|
17884
|
+
var _cellRef$current2, _cellRef$current2$par;
|
17885
|
+
return (_cellRef$current2 = cellRef.current) === null || _cellRef$current2 === void 0 ? void 0 : (_cellRef$current2$par = _cellRef$current2.parentElement) === null || _cellRef$current2$par === void 0 ? void 0 : _cellRef$current2$par.firstChild;
|
17886
|
+
}
|
17887
|
+
return null;
|
17888
|
+
}, [moveReason, cellRef]);
|
17889
|
+
const removeMoveReason = () => {
|
17890
|
+
tableMeta.editing.removeRowMoveReason(cell.column.id);
|
17891
|
+
};
|
17892
|
+
React__default.useEffect(() => {
|
17893
|
+
// To avoid reseting move reason on another row hover,
|
17894
|
+
// we need to check for changes only if value got changed in the current row.
|
17895
|
+
if (!isCurrentRow) {
|
17896
|
+
return;
|
17897
|
+
}
|
17898
|
+
if (hasChanged$1(getValue(), value)) {
|
17899
|
+
const moveReason = getRowMoveReason(table, row.index, row.original, cell, value);
|
17900
|
+
tableMeta.editing.setRowMoveReason({
|
17901
|
+
[cell.column.id]: moveReason
|
17902
|
+
});
|
17903
|
+
} else {
|
17904
|
+
removeMoveReason();
|
17905
|
+
}
|
17906
|
+
return removeMoveReason;
|
17907
|
+
}, [value]);
|
17908
|
+
const controlRenderer = (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.control;
|
17909
|
+
const className = cn('!px-2 py-[var(--table3-row-padding)]', {
|
17910
|
+
relative: (isCurrentRow || isHovered) && controlRenderer === 'textarea',
|
17911
|
+
// Need to set higher z-index, so that the current row textarea (in expanded state) overlaps rows below
|
17912
|
+
'z-10': isCurrentRow,
|
17913
|
+
// When row is hovered and located below, then the hovered textarea overlaps the current row textarea(if the current row textarea is expanded to support multiple lines),
|
17914
|
+
// as result we need to set lower z-index for the hovered row -> cell.
|
17915
|
+
'z-0': isHovered
|
17916
|
+
},
|
17917
|
+
// component overrides - grayscale for editing hover
|
17918
|
+
'[[role="row"][data-current="false"]:hover_&>*]:!grayscale [[role="row"][data-current="false"]:hover_&_.bg-white]:!bg-grey-100',
|
17919
|
+
// we alias to any because className conflicts with the Table2 definition,
|
17920
|
+
// when Table2 is gone, remove this as any
|
17921
|
+
typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
|
17922
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, moveReason !== null && mountNode && /*#__PURE__*/React__default.createElement(Indicator$1, {
|
17923
|
+
reason: moveReason,
|
17924
|
+
columnName: String(cell.column.columnDef.header),
|
17925
|
+
mountNode: mountNode,
|
17926
|
+
validationErrors: []
|
17927
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
17928
|
+
className: className,
|
17929
|
+
"data-column-index": index,
|
17930
|
+
role: "cell",
|
17931
|
+
ref: cellRef
|
17932
|
+
}, /*#__PURE__*/React__default.createElement(EditingControl, {
|
17933
|
+
align: columnMeta.align,
|
17934
|
+
column: cell.column,
|
17935
|
+
data: cell.row.original,
|
17936
|
+
initialValue: getValue(),
|
17937
|
+
onBlur: handleBlur,
|
17938
|
+
onFocus: handleFocus,
|
17939
|
+
onChange: handleChange,
|
17940
|
+
ref: controlRef,
|
17941
|
+
table: table,
|
17942
|
+
tableRef: tableRef,
|
17943
|
+
value: value,
|
17944
|
+
cell: cell,
|
17945
|
+
isCurrentRow: isCurrentRow
|
17946
|
+
})));
|
17947
|
+
});
|
17777
17948
|
function getRowMoveReason(table, rowIndex, rowValues, cell, newValue) {
|
17778
17949
|
var _table$getState$sorti;
|
17779
17950
|
let rowMoveReason = null;
|
@@ -17910,7 +18081,7 @@ const Cell$4 = /*#__PURE__*/React__default.memo(function MemoedCell(context) {
|
|
17910
18081
|
return newTableMeta.currentRow.currentRowIndex === oldTableMeta.currentRow.currentRowIndex && newProps.row.getIsSelected() !== oldProps.row.getIsSelected();
|
17911
18082
|
});
|
17912
18083
|
function createRowSelectionColumn$1(hasDrag, hasExpansion) {
|
17913
|
-
const size = hasDrag && hasExpansion ? 22 :
|
18084
|
+
const size = hasDrag && hasExpansion ? 22 : 4;
|
17914
18085
|
return {
|
17915
18086
|
id: COLUMN_ID$2,
|
17916
18087
|
header: Header$3,
|
@@ -18209,7 +18380,7 @@ function useConvertChildrenToColumns(props, options, editing) {
|
|
18209
18380
|
defaultColumnVisibility,
|
18210
18381
|
defaultSorting
|
18211
18382
|
};
|
18212
|
-
}, [
|
18383
|
+
}, []);
|
18213
18384
|
}
|
18214
18385
|
|
18215
18386
|
function usePrinting(isEnabled, loadAll, showWarningWhenPrintingLargeDataset = true) {
|
@@ -19356,11 +19527,11 @@ function FilterValue(props) {
|
|
19356
19527
|
if (((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.dataType) === 'datetime') {
|
19357
19528
|
return /*#__PURE__*/React__default.createElement("div", {
|
19358
19529
|
className: "flex flex-grow items-center gap-2"
|
19359
|
-
}, /*#__PURE__*/React__default.createElement(Control
|
19530
|
+
}, /*#__PURE__*/React__default.createElement(Control, {
|
19360
19531
|
column: column,
|
19361
19532
|
onChange: value => handleChange([value, toValue]),
|
19362
19533
|
value: fromValue
|
19363
|
-
}), /*#__PURE__*/React__default.createElement(Control
|
19534
|
+
}), /*#__PURE__*/React__default.createElement(Control, {
|
19364
19535
|
column: column,
|
19365
19536
|
onChange: value => handleChange([fromValue, value]),
|
19366
19537
|
value: toValue
|
@@ -19368,26 +19539,26 @@ function FilterValue(props) {
|
|
19368
19539
|
}
|
19369
19540
|
return /*#__PURE__*/React__default.createElement("div", {
|
19370
19541
|
className: "flex flex-grow items-center gap-2"
|
19371
|
-
}, /*#__PURE__*/React__default.createElement(Control
|
19542
|
+
}, /*#__PURE__*/React__default.createElement(Control, {
|
19372
19543
|
column: column,
|
19373
19544
|
onChange: value => handleChange([isNaN(value) ? undefined : value, toValue]),
|
19374
19545
|
placeholder: "from",
|
19375
19546
|
value: fromValue !== null && fromValue !== void 0 ? fromValue : ''
|
19376
|
-
}), /*#__PURE__*/React__default.createElement(Control
|
19547
|
+
}), /*#__PURE__*/React__default.createElement(Control, {
|
19377
19548
|
column: column,
|
19378
19549
|
onChange: value => handleChange([fromValue, isNaN(value) ? undefined : value]),
|
19379
19550
|
placeholder: "to",
|
19380
19551
|
value: toValue !== null && toValue !== void 0 ? toValue : ''
|
19381
19552
|
}));
|
19382
19553
|
}
|
19383
|
-
return /*#__PURE__*/React__default.createElement(Control
|
19554
|
+
return /*#__PURE__*/React__default.createElement(Control, {
|
19384
19555
|
comparator: comparator,
|
19385
19556
|
column: column,
|
19386
19557
|
onChange: handleChange,
|
19387
19558
|
value: value
|
19388
19559
|
});
|
19389
19560
|
}
|
19390
|
-
function Control
|
19561
|
+
function Control(props) {
|
19391
19562
|
var _column$columnDef$met2, _column$columnDef$met3;
|
19392
19563
|
const {
|
19393
19564
|
column,
|
@@ -20517,10 +20688,12 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
20517
20688
|
} = useTableRenderStrategy$1(props, table, internalRef);
|
20518
20689
|
const tableMeta = table.options.meta;
|
20519
20690
|
const state = table.getState();
|
20691
|
+
const bodyRef = React__default.useRef(null);
|
20520
20692
|
React__default.useEffect(() => {
|
20521
20693
|
const handleKeyDown = event => {
|
20694
|
+
var _bodyRef$current;
|
20522
20695
|
// prevent global shortcuts activating while active in other elements, like inputs or buttons
|
20523
|
-
if (isEventTriggeredOnInteractiveElement(event.target)) {
|
20696
|
+
if (isEventTriggeredOnInteractiveElement(event.target) && !(bodyRef !== null && bodyRef !== void 0 && (_bodyRef$current = bodyRef.current) !== null && _bodyRef$current !== void 0 && _bodyRef$current.contains(event.target))) {
|
20524
20697
|
return;
|
20525
20698
|
}
|
20526
20699
|
tableMeta.hoverState.handleKeyDown(event);
|
@@ -20533,7 +20706,11 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
20533
20706
|
return () => {
|
20534
20707
|
document.removeEventListener('keydown', handleKeyDown);
|
20535
20708
|
};
|
20536
|
-
},
|
20709
|
+
},
|
20710
|
+
// See https://github.com/e-conomic/taco/blob/dev/packages/taco/src/components/Table3/strategies/virtualised.tsx#L143
|
20711
|
+
// scrollToIndex function changes when row count changes, so it is important to update handlers with new
|
20712
|
+
// scrollToIndex function.
|
20713
|
+
[scrollToIndex]);
|
20537
20714
|
const handleBlur = event => {
|
20538
20715
|
tableMeta.editing.handleBlur(event);
|
20539
20716
|
};
|
@@ -20604,7 +20781,8 @@ const Table$1 = /*#__PURE__*/fixedForwardRef(function Table3(props, ref) {
|
|
20604
20781
|
})))))), table.getRowModel().rows.length ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(focus.FocusScope, null, /*#__PURE__*/React__default.createElement("div", {
|
20605
20782
|
className: "group/body contents",
|
20606
20783
|
"data-taco": "table2-body",
|
20607
|
-
role: "rowgroup"
|
20784
|
+
role: "rowgroup",
|
20785
|
+
ref: bodyRef
|
20608
20786
|
}, renderBody())), /*#__PURE__*/React__default.createElement("div", {
|
20609
20787
|
className: "border-grey-300 col-span-full -mt-px border-t"
|
20610
20788
|
}), tableMeta.enableFooter ? /*#__PURE__*/React__default.createElement("div", {
|
@@ -20718,37 +20896,6 @@ Tabs.List = TabList;
|
|
20718
20896
|
Tabs.Trigger = TabTrigger;
|
20719
20897
|
Tabs.Content = TabContent;
|
20720
20898
|
|
20721
|
-
const Textarea = /*#__PURE__*/React.forwardRef(function Textarea(props, ref) {
|
20722
|
-
const {
|
20723
|
-
defaultValue: _,
|
20724
|
-
highlighted,
|
20725
|
-
invalid,
|
20726
|
-
onKeyDown,
|
20727
|
-
...otherProps
|
20728
|
-
} = props;
|
20729
|
-
const classNames = cn(getInputClasses(props), 'py-1 min-h-[75px] disabled:resize-none', props.className);
|
20730
|
-
// home and end keys only navigate to the start/end of textarea value if the textarea container does not scroll
|
20731
|
-
// if it has scroll height then the browser reverts to native scrolling behaviour only
|
20732
|
-
// so we manually override it to ensure _our_ desired behaviour remains intact
|
20733
|
-
const handleKeyDown = event => {
|
20734
|
-
if (event.key === 'Home' || event.key === 'End') {
|
20735
|
-
event.preventDefault();
|
20736
|
-
const position = event.key === 'End' ? event.currentTarget.value.length : 0;
|
20737
|
-
event.currentTarget.setSelectionRange(position, position);
|
20738
|
-
event.currentTarget.scrollTop = event.key === 'End' ? event.currentTarget.scrollHeight : 0;
|
20739
|
-
}
|
20740
|
-
if (onKeyDown) {
|
20741
|
-
onKeyDown(event);
|
20742
|
-
}
|
20743
|
-
};
|
20744
|
-
return /*#__PURE__*/React.createElement("textarea", Object.assign({}, otherProps, {
|
20745
|
-
className: classNames,
|
20746
|
-
"data-taco": "textarea",
|
20747
|
-
onKeyDown: handleKeyDown,
|
20748
|
-
ref: ref
|
20749
|
-
}));
|
20750
|
-
});
|
20751
|
-
|
20752
20899
|
const Tooltip$1 = ({
|
20753
20900
|
continuous,
|
20754
20901
|
index,
|