@cakemail-org/ui-components-v2 2.1.17 → 2.1.19

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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import "./styles.scss";
3
3
  import { TInlineTextEdit } from "./types";
4
- export declare function InlineTextEdit({ children, disabled, tooltipTitle, tooltipPlacement, value, defaultValue, name, onChange, onTimeoutChange, onConfirm, onCancel, placeholder, showActionButtons, maxRows, maxLength }: TInlineTextEdit): React.JSX.Element;
4
+ export declare function InlineTextEdit({ children, disabled, tooltipTitle, tooltipPlacement, defaultValue, name, onConfirm, onCancel, placeholder, showActionButtons, maxRows, maxLength }: TInlineTextEdit): React.JSX.Element;
5
5
  export default InlineTextEdit;
6
6
  export * from "./types";
@@ -1,15 +1,11 @@
1
1
  import { TTooltipPlacement } from "../header/types";
2
- import { TTextFieldChange } from "../textField/types";
3
2
  export type TInlineTextEdit = {
4
3
  children: any;
5
4
  tooltipTitle: string;
6
5
  tooltipPlacement?: TTooltipPlacement;
7
- value?: string;
8
6
  defaultValue?: string;
9
7
  placeholder?: string;
10
8
  name?: string;
11
- onChange?: TTextFieldChange;
12
- onTimeoutChange?: TTextFieldChange;
13
9
  onConfirm: TInlineTextEditActions;
14
10
  onCancel?: TInlineTextEditActions;
15
11
  showActionButtons?: boolean;
package/dist/cjs/index.js CHANGED
@@ -10736,11 +10736,11 @@ styleInject(css_248z$5);
10736
10736
 
10737
10737
  function InlineTextEdit(_a) {
10738
10738
  var _b, _c;
10739
- var children = _a.children, disabled = _a.disabled, tooltipTitle = _a.tooltipTitle, tooltipPlacement = _a.tooltipPlacement, value = _a.value, defaultValue = _a.defaultValue, name = _a.name, onChange = _a.onChange, onTimeoutChange = _a.onTimeoutChange, onConfirm = _a.onConfirm, onCancel = _a.onCancel, placeholder = _a.placeholder, showActionButtons = _a.showActionButtons, maxRows = _a.maxRows, maxLength = _a.maxLength;
10739
+ var children = _a.children, disabled = _a.disabled, tooltipTitle = _a.tooltipTitle, tooltipPlacement = _a.tooltipPlacement, defaultValue = _a.defaultValue, name = _a.name, onConfirm = _a.onConfirm, onCancel = _a.onCancel, placeholder = _a.placeholder, showActionButtons = _a.showActionButtons, maxRows = _a.maxRows, maxLength = _a.maxLength;
10740
10740
  var _d = React.useState(false), editing = _d[0], setEditing = _d[1];
10741
10741
  var id = React.useRef(Math.floor(Math.random() * 1000000000));
10742
10742
  var spanRef = React.useRef(null);
10743
- var valueRef = React.useRef(value || defaultValue);
10743
+ var _e = React.useState(defaultValue), value = _e[0], setValue = _e[1];
10744
10744
  maxRows = maxRows || 1;
10745
10745
  var multiline = maxRows > 1;
10746
10746
  React.useLayoutEffect(function () {
@@ -10750,26 +10750,24 @@ function InlineTextEdit(_a) {
10750
10750
  input.focus();
10751
10751
  }
10752
10752
  }, [editing]);
10753
- React.useLayoutEffect(function () {
10754
- }, [value]);
10755
10753
  function handleClick() {
10756
10754
  setEditing(!editing);
10757
10755
  }
10758
10756
  function handleClose() {
10759
10757
  handleClick();
10760
- onCancel && onCancel({ name: name, value: value || valueRef.current });
10758
+ setValue(defaultValue);
10759
+ onCancel && onCancel({ name: name, value: value });
10761
10760
  }
10762
10761
  function handleConfirm() {
10763
10762
  handleClick();
10764
- onConfirm && onConfirm({ name: name, value: value || valueRef.current });
10763
+ onConfirm && onConfirm({ name: name, value: value });
10765
10764
  }
10766
10765
  function handleOnClickAway() {
10767
10766
  if (!showActionButtons && editing)
10768
10767
  handleConfirm();
10769
10768
  }
10770
10769
  function handleOnChange(e) {
10771
- valueRef.current = e.target.value;
10772
- onChange && onChange(e);
10770
+ setValue(e.target.value);
10773
10771
  }
10774
10772
  tooltipPlacement = tooltipPlacement || "right";
10775
10773
  var offsetWidthOfSpan = ((_b = spanRef === null || spanRef === void 0 ? void 0 : spanRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 150;
@@ -10777,6 +10775,7 @@ function InlineTextEdit(_a) {
10777
10775
  offsetWidthOfSpan = 150;
10778
10776
  }
10779
10777
  var offsetHeightOfSpan = ((_c = spanRef === null || spanRef === void 0 ? void 0 : spanRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) || 20;
10778
+ console.log("offsetWidthOfSpan", value);
10780
10779
  var classes = classNames("inlineTextEdit-component-v2", {
10781
10780
  "editing": editing,
10782
10781
  "disabled": disabled
@@ -10787,9 +10786,7 @@ function InlineTextEdit(_a) {
10787
10786
  React.createElement(Tooltip, { title: tooltipTitle, arrow: true, placement: tooltipPlacement },
10788
10787
  React.createElement(Box, { component: "span", className: "".concat(!children && placeholder ? "hasPlaceholder" : "", " pointer"), onClick: handleClick, style: { maxHeight: offsetHeightOfSpan * maxRows } }, children || placeholder)),
10789
10788
  React.createElement(Box, { className: editing ? "" : "hidden" },
10790
- React.createElement(TextField, { disabled: disabled, inputProps: { maxLength: maxLength || 256 }, maxRows: maxRows, multiline: multiline, placeholder: placeholder, variant: "standard", name: name, style: { width: "".concat(offsetWidthOfSpan, "px") }, defaultValue: defaultValue, value: value, onChange: handleOnChange, timeout: onTimeoutChange && {
10791
- callback: onTimeoutChange
10792
- } }),
10789
+ React.createElement(TextField, { disabled: disabled, inputProps: { maxLength: maxLength || 256 }, maxRows: maxRows, multiline: multiline, placeholder: placeholder, variant: "standard", name: name, style: { width: "".concat(offsetWidthOfSpan, "px") }, value: value, onChange: handleOnChange }),
10793
10790
  showActionButtons &&
10794
10791
  React.createElement(material.Stack, { className: "actions", direction: "row", justifyContent: "center", alignContent: "center" },
10795
10792
  React.createElement(Button, { onClick: handleConfirm, className: "confirm", color: "body1", size: "small" },
@@ -10798,9 +10795,37 @@ function InlineTextEdit(_a) {
10798
10795
  React.createElement(Icon, { name: "X18", color: "white" })))),
10799
10796
  React.createElement("span", { ref: spanRef, style: {
10800
10797
  visibility: 'hidden',
10801
- whiteSpace: 'pre', // To respect spaces in the input
10798
+ whiteSpace: multiline ? 'pre-wrap' : 'pre', // For multiline, allow wrapping
10802
10799
  position: 'absolute',
10803
- padding: multiline ? "0 8px" : "0 4px"
10800
+ top: '-9999px', // Move completely off-screen
10801
+ left: '-9999px',
10802
+ padding: '0', // Remove padding to match input exactly
10803
+ margin: '0',
10804
+ border: 'none',
10805
+ outline: 'none',
10806
+ fontFamily: 'inherit',
10807
+ fontSize: 'inherit',
10808
+ fontWeight: 'inherit',
10809
+ lineHeight: 'inherit',
10810
+ letterSpacing: 'inherit',
10811
+ wordSpacing: 'inherit',
10812
+ textTransform: 'inherit',
10813
+ fontVariant: 'inherit',
10814
+ fontStretch: 'inherit',
10815
+ fontStyle: 'inherit',
10816
+ textDecoration: 'inherit',
10817
+ textAlign: 'inherit',
10818
+ textIndent: 'inherit',
10819
+ textShadow: 'inherit',
10820
+ textOverflow: 'inherit',
10821
+ textRendering: 'inherit',
10822
+ unicodeBidi: 'inherit',
10823
+ writingMode: 'inherit',
10824
+ direction: 'inherit',
10825
+ // Ensure the span behaves like an input field
10826
+ display: 'inline-block',
10827
+ minWidth: '1px',
10828
+ width: 'auto', // Use available width for multiline
10804
10829
  } }, value || ' ')));
10805
10830
  }
10806
10831
 
@@ -17172,6 +17197,20 @@ var CommonFormModel = /** @class */ (function () {
17172
17197
  });
17173
17198
  });
17174
17199
  };
17200
+ CommonFormModel.prototype.save = function () {
17201
+ return __awaiter(this, void 0, void 0, function () {
17202
+ var _this = this;
17203
+ return __generator(this, function (_a) {
17204
+ if (!this.id) {
17205
+ throw new Error("Form was not initialized");
17206
+ }
17207
+ return [2 /*return*/, patchForm({ id: this.id.toString(), data: this.toJson() }).then(function (data) {
17208
+ trackEvent(exports.EEvents.FORM_UPDATED, { id: _this.id });
17209
+ return data.data;
17210
+ })];
17211
+ });
17212
+ });
17213
+ };
17175
17214
  return CommonFormModel;
17176
17215
  }());
17177
17216
  var FormModel = /** @class */ (function (_super) {
@@ -17276,20 +17315,6 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
17276
17315
  });
17277
17316
  });
17278
17317
  };
17279
- SummaryEnhancedFormModel.prototype.save = function () {
17280
- return __awaiter(this, void 0, void 0, function () {
17281
- var _this = this;
17282
- return __generator(this, function (_a) {
17283
- if (!this.id) {
17284
- throw new Error("Form was not initialized");
17285
- }
17286
- return [2 /*return*/, patchForm({ id: this.id.toString(), data: this.toJson() }).then(function (data) {
17287
- trackEvent(exports.EEvents.FORM_UPDATED, { id: _this.id });
17288
- return data.data;
17289
- })];
17290
- });
17291
- });
17292
- };
17293
17318
  SummaryEnhancedFormModel.prototype.toJson = function () {
17294
17319
  return modelToJson(this);
17295
17320
  };
@@ -14,6 +14,7 @@ export declare class CommonFormModel {
14
14
  toJson(): any;
15
15
  set<T extends keyof this>(property: T, value: this[T]): void;
16
16
  delete(): Promise<TDeleteApiResource>;
17
+ save(): Promise<EnhancedFormModel>;
17
18
  }
18
19
  export declare class FormModel extends CommonFormModel {
19
20
  readonly status: string;
@@ -59,7 +60,6 @@ export declare class SummaryEnhancedFormModel extends CommonFormModel {
59
60
  disable(): Promise<EnhancedFormModel>;
60
61
  publish(): Promise<EnhancedFormModel>;
61
62
  render(published?: boolean): Promise<string>;
62
- save(): Promise<EnhancedFormModel>;
63
63
  toJson(): any;
64
64
  set<T extends keyof this>(property: T, value: this[T]): void;
65
65
  }
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import "./styles.scss";
3
3
  import { TInlineTextEdit } from "./types";
4
- export declare function InlineTextEdit({ children, disabled, tooltipTitle, tooltipPlacement, value, defaultValue, name, onChange, onTimeoutChange, onConfirm, onCancel, placeholder, showActionButtons, maxRows, maxLength }: TInlineTextEdit): React.JSX.Element;
4
+ export declare function InlineTextEdit({ children, disabled, tooltipTitle, tooltipPlacement, defaultValue, name, onConfirm, onCancel, placeholder, showActionButtons, maxRows, maxLength }: TInlineTextEdit): React.JSX.Element;
5
5
  export default InlineTextEdit;
6
6
  export * from "./types";
@@ -1,15 +1,11 @@
1
1
  import { TTooltipPlacement } from "../header/types";
2
- import { TTextFieldChange } from "../textField/types";
3
2
  export type TInlineTextEdit = {
4
3
  children: any;
5
4
  tooltipTitle: string;
6
5
  tooltipPlacement?: TTooltipPlacement;
7
- value?: string;
8
6
  defaultValue?: string;
9
7
  placeholder?: string;
10
8
  name?: string;
11
- onChange?: TTextFieldChange;
12
- onTimeoutChange?: TTextFieldChange;
13
9
  onConfirm: TInlineTextEditActions;
14
10
  onCancel?: TInlineTextEditActions;
15
11
  showActionButtons?: boolean;
package/dist/esm/index.js CHANGED
@@ -10716,11 +10716,11 @@ styleInject(css_248z$5);
10716
10716
 
10717
10717
  function InlineTextEdit(_a) {
10718
10718
  var _b, _c;
10719
- var children = _a.children, disabled = _a.disabled, tooltipTitle = _a.tooltipTitle, tooltipPlacement = _a.tooltipPlacement, value = _a.value, defaultValue = _a.defaultValue, name = _a.name, onChange = _a.onChange, onTimeoutChange = _a.onTimeoutChange, onConfirm = _a.onConfirm, onCancel = _a.onCancel, placeholder = _a.placeholder, showActionButtons = _a.showActionButtons, maxRows = _a.maxRows, maxLength = _a.maxLength;
10719
+ var children = _a.children, disabled = _a.disabled, tooltipTitle = _a.tooltipTitle, tooltipPlacement = _a.tooltipPlacement, defaultValue = _a.defaultValue, name = _a.name, onConfirm = _a.onConfirm, onCancel = _a.onCancel, placeholder = _a.placeholder, showActionButtons = _a.showActionButtons, maxRows = _a.maxRows, maxLength = _a.maxLength;
10720
10720
  var _d = useState(false), editing = _d[0], setEditing = _d[1];
10721
10721
  var id = useRef(Math.floor(Math.random() * 1000000000));
10722
10722
  var spanRef = useRef(null);
10723
- var valueRef = useRef(value || defaultValue);
10723
+ var _e = useState(defaultValue), value = _e[0], setValue = _e[1];
10724
10724
  maxRows = maxRows || 1;
10725
10725
  var multiline = maxRows > 1;
10726
10726
  useLayoutEffect(function () {
@@ -10730,26 +10730,24 @@ function InlineTextEdit(_a) {
10730
10730
  input.focus();
10731
10731
  }
10732
10732
  }, [editing]);
10733
- useLayoutEffect(function () {
10734
- }, [value]);
10735
10733
  function handleClick() {
10736
10734
  setEditing(!editing);
10737
10735
  }
10738
10736
  function handleClose() {
10739
10737
  handleClick();
10740
- onCancel && onCancel({ name: name, value: value || valueRef.current });
10738
+ setValue(defaultValue);
10739
+ onCancel && onCancel({ name: name, value: value });
10741
10740
  }
10742
10741
  function handleConfirm() {
10743
10742
  handleClick();
10744
- onConfirm && onConfirm({ name: name, value: value || valueRef.current });
10743
+ onConfirm && onConfirm({ name: name, value: value });
10745
10744
  }
10746
10745
  function handleOnClickAway() {
10747
10746
  if (!showActionButtons && editing)
10748
10747
  handleConfirm();
10749
10748
  }
10750
10749
  function handleOnChange(e) {
10751
- valueRef.current = e.target.value;
10752
- onChange && onChange(e);
10750
+ setValue(e.target.value);
10753
10751
  }
10754
10752
  tooltipPlacement = tooltipPlacement || "right";
10755
10753
  var offsetWidthOfSpan = ((_b = spanRef === null || spanRef === void 0 ? void 0 : spanRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 150;
@@ -10757,6 +10755,7 @@ function InlineTextEdit(_a) {
10757
10755
  offsetWidthOfSpan = 150;
10758
10756
  }
10759
10757
  var offsetHeightOfSpan = ((_c = spanRef === null || spanRef === void 0 ? void 0 : spanRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) || 20;
10758
+ console.log("offsetWidthOfSpan", value);
10760
10759
  var classes = classNames("inlineTextEdit-component-v2", {
10761
10760
  "editing": editing,
10762
10761
  "disabled": disabled
@@ -10767,9 +10766,7 @@ function InlineTextEdit(_a) {
10767
10766
  React__default.createElement(Tooltip$1, { title: tooltipTitle, arrow: true, placement: tooltipPlacement },
10768
10767
  React__default.createElement(Box$1, { component: "span", className: "".concat(!children && placeholder ? "hasPlaceholder" : "", " pointer"), onClick: handleClick, style: { maxHeight: offsetHeightOfSpan * maxRows } }, children || placeholder)),
10769
10768
  React__default.createElement(Box$1, { className: editing ? "" : "hidden" },
10770
- React__default.createElement(TextField, { disabled: disabled, inputProps: { maxLength: maxLength || 256 }, maxRows: maxRows, multiline: multiline, placeholder: placeholder, variant: "standard", name: name, style: { width: "".concat(offsetWidthOfSpan, "px") }, defaultValue: defaultValue, value: value, onChange: handleOnChange, timeout: onTimeoutChange && {
10771
- callback: onTimeoutChange
10772
- } }),
10769
+ React__default.createElement(TextField, { disabled: disabled, inputProps: { maxLength: maxLength || 256 }, maxRows: maxRows, multiline: multiline, placeholder: placeholder, variant: "standard", name: name, style: { width: "".concat(offsetWidthOfSpan, "px") }, value: value, onChange: handleOnChange }),
10773
10770
  showActionButtons &&
10774
10771
  React__default.createElement(Stack$1, { className: "actions", direction: "row", justifyContent: "center", alignContent: "center" },
10775
10772
  React__default.createElement(Button, { onClick: handleConfirm, className: "confirm", color: "body1", size: "small" },
@@ -10778,9 +10775,37 @@ function InlineTextEdit(_a) {
10778
10775
  React__default.createElement(Icon, { name: "X18", color: "white" })))),
10779
10776
  React__default.createElement("span", { ref: spanRef, style: {
10780
10777
  visibility: 'hidden',
10781
- whiteSpace: 'pre', // To respect spaces in the input
10778
+ whiteSpace: multiline ? 'pre-wrap' : 'pre', // For multiline, allow wrapping
10782
10779
  position: 'absolute',
10783
- padding: multiline ? "0 8px" : "0 4px"
10780
+ top: '-9999px', // Move completely off-screen
10781
+ left: '-9999px',
10782
+ padding: '0', // Remove padding to match input exactly
10783
+ margin: '0',
10784
+ border: 'none',
10785
+ outline: 'none',
10786
+ fontFamily: 'inherit',
10787
+ fontSize: 'inherit',
10788
+ fontWeight: 'inherit',
10789
+ lineHeight: 'inherit',
10790
+ letterSpacing: 'inherit',
10791
+ wordSpacing: 'inherit',
10792
+ textTransform: 'inherit',
10793
+ fontVariant: 'inherit',
10794
+ fontStretch: 'inherit',
10795
+ fontStyle: 'inherit',
10796
+ textDecoration: 'inherit',
10797
+ textAlign: 'inherit',
10798
+ textIndent: 'inherit',
10799
+ textShadow: 'inherit',
10800
+ textOverflow: 'inherit',
10801
+ textRendering: 'inherit',
10802
+ unicodeBidi: 'inherit',
10803
+ writingMode: 'inherit',
10804
+ direction: 'inherit',
10805
+ // Ensure the span behaves like an input field
10806
+ display: 'inline-block',
10807
+ minWidth: '1px',
10808
+ width: 'auto', // Use available width for multiline
10784
10809
  } }, value || ' ')));
10785
10810
  }
10786
10811
 
@@ -17152,6 +17177,20 @@ var CommonFormModel = /** @class */ (function () {
17152
17177
  });
17153
17178
  });
17154
17179
  };
17180
+ CommonFormModel.prototype.save = function () {
17181
+ return __awaiter(this, void 0, void 0, function () {
17182
+ var _this = this;
17183
+ return __generator(this, function (_a) {
17184
+ if (!this.id) {
17185
+ throw new Error("Form was not initialized");
17186
+ }
17187
+ return [2 /*return*/, patchForm({ id: this.id.toString(), data: this.toJson() }).then(function (data) {
17188
+ trackEvent(EEvents.FORM_UPDATED, { id: _this.id });
17189
+ return data.data;
17190
+ })];
17191
+ });
17192
+ });
17193
+ };
17155
17194
  return CommonFormModel;
17156
17195
  }());
17157
17196
  var FormModel = /** @class */ (function (_super) {
@@ -17256,20 +17295,6 @@ var SummaryEnhancedFormModel = /** @class */ (function (_super) {
17256
17295
  });
17257
17296
  });
17258
17297
  };
17259
- SummaryEnhancedFormModel.prototype.save = function () {
17260
- return __awaiter(this, void 0, void 0, function () {
17261
- var _this = this;
17262
- return __generator(this, function (_a) {
17263
- if (!this.id) {
17264
- throw new Error("Form was not initialized");
17265
- }
17266
- return [2 /*return*/, patchForm({ id: this.id.toString(), data: this.toJson() }).then(function (data) {
17267
- trackEvent(EEvents.FORM_UPDATED, { id: _this.id });
17268
- return data.data;
17269
- })];
17270
- });
17271
- });
17272
- };
17273
17298
  SummaryEnhancedFormModel.prototype.toJson = function () {
17274
17299
  return modelToJson(this);
17275
17300
  };
@@ -14,6 +14,7 @@ export declare class CommonFormModel {
14
14
  toJson(): any;
15
15
  set<T extends keyof this>(property: T, value: this[T]): void;
16
16
  delete(): Promise<TDeleteApiResource>;
17
+ save(): Promise<EnhancedFormModel>;
17
18
  }
18
19
  export declare class FormModel extends CommonFormModel {
19
20
  readonly status: string;
@@ -59,7 +60,6 @@ export declare class SummaryEnhancedFormModel extends CommonFormModel {
59
60
  disable(): Promise<EnhancedFormModel>;
60
61
  publish(): Promise<EnhancedFormModel>;
61
62
  render(published?: boolean): Promise<string>;
62
- save(): Promise<EnhancedFormModel>;
63
63
  toJson(): any;
64
64
  set<T extends keyof this>(property: T, value: this[T]): void;
65
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cakemail-org/ui-components-v2",
3
- "version": "2.1.17",
3
+ "version": "2.1.19",
4
4
  "description": "ui library kit made with material UI",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",