@economic/taco 2.7.4 → 2.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -10531,10 +10531,8 @@ const Select2 = /*#__PURE__*/React__default.forwardRef(function Select2(props, r
10531
10531
  }), flattenedChildren)), /*#__PURE__*/React__default.createElement(PopoverPrimitive.Portal, null, /*#__PURE__*/React__default.createElement(PopoverPrimitive.Content, {
10532
10532
  asChild: true,
10533
10533
  align: "start",
10534
- onOpenAutoFocus: event => {
10534
+ onOpenAutoFocus: () => {
10535
10535
  var _internalRef$current;
10536
- event.preventDefault();
10537
- event.stopPropagation();
10538
10536
  (_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.focus();
10539
10537
  },
10540
10538
  onCloseAutoFocus: event => {
@@ -17604,6 +17602,22 @@ const Textarea = /*#__PURE__*/React.forwardRef(function Textarea(props, ref) {
17604
17602
  }));
17605
17603
  });
17606
17604
 
17605
+ // By UX design, textarea should fold to min size when blured and extend to max 5 lines height when edited in enableTruncate mode,
17606
+ // for this reason we need to set min/max height limits for each font size value.
17607
+ const heights = {
17608
+ small: {
17609
+ min: 24,
17610
+ max: 86
17611
+ },
17612
+ medium: {
17613
+ min: 34,
17614
+ max: 100
17615
+ },
17616
+ large: {
17617
+ min: 40,
17618
+ max: 140
17619
+ }
17620
+ };
17607
17621
  const TextareaControl = /*#__PURE__*/React__default.forwardRef(function TextareaControl(props, externalRef) {
17608
17622
  const {
17609
17623
  onKeyDown: handleKeyDown,
@@ -17613,19 +17627,25 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
17613
17627
  align,
17614
17628
  isCurrentRow,
17615
17629
  value,
17630
+ fontSize,
17616
17631
  ...attributes
17617
17632
  } = props;
17618
- const textareaMaxHeight = 120;
17619
- const textareaMinHeight = 32;
17633
+ const minMaxHeight = heights[fontSize];
17620
17634
  const columnMeta = column.columnDef.meta;
17621
17635
  const ref = useMergedRef(externalRef);
17622
17636
  React__default.useEffect(() => {
17623
- // If truncation is not enabled, then textarea should re-calculate it's height to fit with it's own content, when initialized.
17624
- if (ref !== null && ref !== void 0 && ref.current && !(columnMeta !== null && columnMeta !== void 0 && columnMeta.enableTruncate)) {
17625
- const textareaElement = ref === null || ref === void 0 ? void 0 : ref.current;
17626
- resizeTextArea(textareaElement);
17637
+ if (ref !== null && ref !== void 0 && ref.current) {
17638
+ // Need to reset textarea to min height when font size got changed and if column in enable truncate mode.
17639
+ if (columnMeta !== null && columnMeta !== void 0 && columnMeta.enableTruncate) {
17640
+ const textareaElement = ref === null || ref === void 0 ? void 0 : ref.current;
17641
+ textareaElement.style.height = `${minMaxHeight.min}px`;
17642
+ // If truncation is not enabled, then textarea should re-calculate it's height to fit with it's own content, when initialized or fonsSize got changed.
17643
+ } else {
17644
+ const textareaElement = ref === null || ref === void 0 ? void 0 : ref.current;
17645
+ resizeTextArea(textareaElement);
17646
+ }
17627
17647
  }
17628
- }, []);
17648
+ }, [fontSize]);
17629
17649
  React__default.useEffect(() => {
17630
17650
  // If truncation is enabled, then textarea should only adjust to it's own content, when in detail mode.
17631
17651
  // Otherwise it should collapse to minimal height.
@@ -17634,7 +17654,7 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
17634
17654
  if (isCellInDetailMode) {
17635
17655
  resizeTextArea(textareaElement);
17636
17656
  } else {
17637
- textareaElement.style.height = `${textareaMinHeight}px`;
17657
+ textareaElement.style.height = `${minMaxHeight.min}px`;
17638
17658
  }
17639
17659
  }
17640
17660
  }, [isCellInDetailMode]);
@@ -17644,9 +17664,9 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
17644
17664
  const textareaRect = textareaElement.getBoundingClientRect();
17645
17665
  const prevHeight = textareaRect.height;
17646
17666
  if (columnMeta !== null && columnMeta !== void 0 && columnMeta.enableTruncate) {
17647
- if (prevHeight < textareaMaxHeight) {
17667
+ if (prevHeight < minMaxHeight.max) {
17648
17668
  textareaElement.style.height = 'inherit';
17649
- textareaElement.style.height = `${Math.min(textareaElement.scrollHeight, textareaMaxHeight)}px`;
17669
+ textareaElement.style.height = `${Math.min(textareaElement.scrollHeight, minMaxHeight.max)}px`;
17650
17670
  }
17651
17671
  } else {
17652
17672
  textareaElement.style.height = 'inherit';
@@ -17683,13 +17703,13 @@ const TextareaControl = /*#__PURE__*/React__default.forwardRef(function Textarea
17683
17703
  // If truncation is enabled, then textarea should shring back to min height, when loosing focus.
17684
17704
  if (columnMeta !== null && columnMeta !== void 0 && columnMeta.enableTruncate) {
17685
17705
  const textareaElement = event.currentTarget;
17686
- textareaElement.style.height = `${textareaMinHeight}px`;
17706
+ textareaElement.style.height = `${minMaxHeight.min}px`;
17687
17707
  }
17688
17708
  },
17689
17709
  className: cn(getCellAlignmentClasses$1(align), `z-20 h-fit resize-none`, {
17690
- [`!min-h-[${textareaMinHeight}px]`]: columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate,
17710
+ [`!min-h-[${minMaxHeight.min}px]`]: columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate,
17691
17711
  '!yt-focus-dark': isCellInDetailMode,
17692
- [`h-[${textareaMinHeight}px]`]: !isCellInDetailMode && (columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate),
17712
+ [`h-[${minMaxHeight.min}px]`]: !isCellInDetailMode && (columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate),
17693
17713
  // Only allow resizing when focused and truncation enabled
17694
17714
  'focus:resize-y': isCurrentRow && (columnMeta === null || columnMeta === void 0 ? void 0 : columnMeta.enableTruncate)
17695
17715
  }),
@@ -17825,7 +17845,8 @@ const EditingControl = /*#__PURE__*/React__default.forwardRef(function Control(p
17825
17845
  return /*#__PURE__*/React__default.createElement(TextareaControl, Object.assign({}, props, {
17826
17846
  isCellInDetailMode: isCellInDetailMode,
17827
17847
  onKeyDown: handleInputKeyDown,
17828
- ref: refCallback
17848
+ ref: refCallback,
17849
+ fontSize: tableMeta.fontSize.size
17829
17850
  }));
17830
17851
  }
17831
17852
  return /*#__PURE__*/React__default.createElement(Input, Object.assign({}, attributes, {
@@ -17936,11 +17957,9 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
17936
17957
  const controlRenderer = (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.control;
17937
17958
  const className = cn('!px-[0.4375rem] py-[calc(var(--table3-row-padding)_-_0.06rem)]', {
17938
17959
  relative: (isCurrentRow || isHovered) && controlRenderer === 'textarea',
17939
- // Need to set higher z-index, so that the current row textarea (in expanded state) overlaps rows below
17940
- 'z-10': isCurrentRow,
17941
- // 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),
17942
- // as result we need to set lower z-index for the hovered row -> cell.
17943
- 'z-0': isHovered
17960
+ // Need to set higher z-index, so that the current row textarea (in expanded state, when positioned absolute) overlaps rows below,
17961
+ // but at the same time it should not overlap the table headers which has z-10.
17962
+ 'z-[9]': isCurrentRow && controlRenderer === 'textarea'
17944
17963
  },
17945
17964
  // component overrides - grayscale for editing hover
17946
17965
  '[[role="row"][data-current="false"]:hover_&>*]:!grayscale [[role="row"][data-current="false"]:hover_&_.bg-white]:!bg-grey-100',