@activecollab/components 2.0.245 → 2.0.246

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/index.js CHANGED
@@ -20419,7 +20419,7 @@
20419
20419
  var StyledHeader = styled__default["default"](Paper).withConfig({
20420
20420
  displayName: "Styles__StyledHeader",
20421
20421
  componentId: "sc-xrlqib-0"
20422
- })(["", " ", " padding:0 1rem;display:flex;overflow:hidden;min-width:350px;@media screen and (max-width:350px){overflow:auto;}"], function (props) {
20422
+ })(["", " ", " padding:0 1rem;display:flex;overflow:hidden;@media screen and (max-width:350px){overflow:auto;}"], function (props) {
20423
20423
  return props.size === "big" && styled.css(["height:140px;"]);
20424
20424
  }, function (props) {
20425
20425
  return props.size === "small" && styled.css(["height:4rem;"]);
@@ -22338,14 +22338,46 @@
22338
22338
  });
22339
22339
  EditableContent.displayName = "EditableContent";
22340
22340
 
22341
- var _excluded$f = ["onSave", "onCancel", "value", "inputProps", "allowEmptyString"];
22342
- var EditableText = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
22343
- var onSave = _ref.onSave,
22344
- onCancel = _ref.onCancel,
22345
- value = _ref.value,
22346
- inputProps = _ref.inputProps,
22347
- allowEmptyString = _ref.allowEmptyString,
22348
- props = _objectWithoutProperties(_ref, _excluded$f);
22341
+ var _excluded$f = ["onSave", "onCancel", "value", "inputProps", "allowEmptyString", "multiline", "variant", "weight", "disabled", "invalid", "wrapRef", "children"];
22342
+ var StyledTextareaSpan = styled__default["default"](Typography).withConfig({
22343
+ displayName: "EditableText__StyledTextareaSpan",
22344
+ componentId: "sc-j2ewzm-0"
22345
+ })(["", " background-color:var(--input-background-color,#ffffff);padding-left:4px;padding-right:4px;padding-top:1px;padding-bottom:1px;font-variant-numeric:tabular-nums;outline-width:0px;outline:none;resize:none;white-space:pre-wrap;overflow-wrap:break-word;height:calc(1.5em * 3 + 2px);min-height:calc(1.5em * 3 + 2px);opacity:0;&:focus{opacity:1;background-color:var(--input-background-color,#f8f9fa);}&:disabled{opacity:0;}", ""], {
22346
+ "position": "absolute",
22347
+ "inset": "0px",
22348
+ "boxSizing": "border-box",
22349
+ "width": "100%",
22350
+ "borderRadius": "0.375rem",
22351
+ "borderWidth": "1px",
22352
+ "borderStyle": "solid",
22353
+ "borderColor": "transparent",
22354
+ ":focus-within": {
22355
+ "borderColor": "var(--color-theme-700)"
22356
+ },
22357
+ ":hover": {
22358
+ "borderColor": "var(--color-theme-700)"
22359
+ }
22360
+ }, function (_ref) {
22361
+ var invalid = _ref.invalid;
22362
+ return invalid && styled.css(["border-color:var(--red-alert) !important;"]);
22363
+ });
22364
+ var EditableText = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
22365
+ var onSave = _ref2.onSave,
22366
+ onCancel = _ref2.onCancel,
22367
+ value = _ref2.value,
22368
+ inputProps = _ref2.inputProps,
22369
+ allowEmptyString = _ref2.allowEmptyString,
22370
+ _ref2$multiline = _ref2.multiline,
22371
+ multiline = _ref2$multiline === void 0 ? false : _ref2$multiline,
22372
+ _ref2$variant = _ref2.variant,
22373
+ variant = _ref2$variant === void 0 ? "Body 2" : _ref2$variant,
22374
+ weight = _ref2.weight,
22375
+ _ref2$disabled = _ref2.disabled,
22376
+ disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
22377
+ invalid = _ref2.invalid,
22378
+ wrapRef = _ref2.wrapRef,
22379
+ children = _ref2.children,
22380
+ props = _objectWithoutProperties(_ref2, _excluded$f);
22349
22381
  var _useState = React.useState(value),
22350
22382
  _useState2 = _slicedToArray(_useState, 2),
22351
22383
  currentValue = _useState2[0],
@@ -22355,6 +22387,11 @@
22355
22387
  prevValue = _useState4[0],
22356
22388
  setPrevValue = _useState4[1];
22357
22389
  var escapeRef = React.useRef(false);
22390
+ var intTextareaRef = React.useRef(null);
22391
+ var _useState5 = React.useState(false),
22392
+ _useState6 = _slicedToArray(_useState5, 2),
22393
+ isTextareaFocused = _useState6[0],
22394
+ setIsTextareaFocused = _useState6[1];
22358
22395
  React.useEffect(function () {
22359
22396
  if (currentValue !== value) {
22360
22397
  setCurrentValue(value);
@@ -22363,6 +22400,7 @@
22363
22400
  // eslint-disable-next-line react-hooks/exhaustive-deps
22364
22401
  }, [value]);
22365
22402
  var handleBlur = React.useCallback(function (e) {
22403
+ setIsTextareaFocused(false);
22366
22404
  if (escapeRef.current) {
22367
22405
  setCurrentValue(prevValue);
22368
22406
  escapeRef.current = false;
@@ -22375,9 +22413,16 @@
22375
22413
  !allowEmptyString ? setCurrentValue(prevValue) : typeof onSave === "function" && prevValue !== e.target.value && onSave(e);
22376
22414
  }
22377
22415
  }
22378
- }, [allowEmptyString, onSave, prevValue]);
22416
+ // Reset scroll position for textarea
22417
+ if (multiline && intTextareaRef !== null && intTextareaRef !== void 0 && intTextareaRef.current) {
22418
+ intTextareaRef.current.scrollLeft = 0;
22419
+ }
22420
+ }, [allowEmptyString, onSave, prevValue, multiline]);
22421
+ var handleFocus = React.useCallback(function () {
22422
+ setIsTextareaFocused(true);
22423
+ }, []);
22379
22424
  var handleKeyDown = React.useCallback(function (e) {
22380
- if (e.key === "Enter") {
22425
+ if (e.key === "Enter" && !multiline) {
22381
22426
  e.target.blur();
22382
22427
  }
22383
22428
  if (e.key === "Escape") {
@@ -22385,11 +22430,43 @@
22385
22430
  e.target.blur();
22386
22431
  typeof onCancel === "function" && onCancel();
22387
22432
  }
22388
- }, [onCancel]);
22433
+ }, [onCancel, multiline]);
22389
22434
  var handleChange = React.useCallback(function (e) {
22390
22435
  setCurrentValue(e.target.value);
22391
22436
  }, []);
22437
+ if (multiline) {
22438
+ return /*#__PURE__*/React__default["default"].createElement(StyledDiv, _extends({
22439
+ ref: wrapRef
22440
+ }, props), /*#__PURE__*/React__default["default"].createElement(StyledSpan, {
22441
+ variant: variant,
22442
+ forwardedAs: "span",
22443
+ weight: weight,
22444
+ $disabled: !isTextareaFocused,
22445
+ className: "presentation"
22446
+ }, children ? children : String(currentValue || "").replace(/\n/g, " ")), /*#__PURE__*/React__default["default"].createElement(StyledTextareaSpan, _extends({
22447
+ ref: intTextareaRef,
22448
+ forwardedAs: "textarea",
22449
+ variant: variant,
22450
+ weight: weight,
22451
+ value: currentValue !== null && currentValue !== void 0 ? currentValue : "",
22452
+ onFocus: handleFocus,
22453
+ onBlur: handleBlur,
22454
+ onKeyDown: handleKeyDown,
22455
+ onChange: handleChange,
22456
+ disabled: disabled,
22457
+ invalid: invalid,
22458
+ "data-form-type": "other",
22459
+ placeholder: inputProps === null || inputProps === void 0 ? void 0 : inputProps.placeholder,
22460
+ className: classNames__default["default"]("c-textarea", inputProps === null || inputProps === void 0 ? void 0 : inputProps.className),
22461
+ rows: 3
22462
+ }, inputProps)));
22463
+ }
22392
22464
  return /*#__PURE__*/React__default["default"].createElement(EditableContent, _extends({}, props, {
22465
+ variant: variant,
22466
+ weight: weight,
22467
+ disabled: disabled,
22468
+ invalid: invalid,
22469
+ wrapRef: wrapRef,
22393
22470
  ref: ref,
22394
22471
  inputProps: _objectSpread2(_objectSpread2({}, inputProps), {}, {
22395
22472
  value: currentValue !== null && currentValue !== void 0 ? currentValue : "",
@@ -22399,7 +22476,7 @@
22399
22476
  type: "text",
22400
22477
  className: classNames__default["default"]("c-input", inputProps === null || inputProps === void 0 ? void 0 : inputProps.className)
22401
22478
  })
22402
- }));
22479
+ }), children);
22403
22480
  });
22404
22481
  EditableText.displayName = "EditableText";
22405
22482