@cakemail-org/ui-components-v2 2.0.90 → 2.0.93
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.
|
@@ -8,7 +8,7 @@ export type TInlineTextEdit = {
|
|
|
8
8
|
defaultValue?: string;
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
name?: string;
|
|
11
|
-
onChange
|
|
11
|
+
onChange?: TTextFieldChange;
|
|
12
12
|
onTimeoutChange?: TTextFieldChange;
|
|
13
13
|
onConfirm: TInlineTextEditActions;
|
|
14
14
|
onCancel?: TInlineTextEditActions;
|
package/dist/cjs/index.js
CHANGED
|
@@ -10399,6 +10399,7 @@ function InlineTextEdit(_a) {
|
|
|
10399
10399
|
var _d = React.useState(false), editing = _d[0], setEditing = _d[1];
|
|
10400
10400
|
var id = React.useRef(Math.floor(Math.random() * 1000000000));
|
|
10401
10401
|
var spanRef = React.useRef(null);
|
|
10402
|
+
var valueRef = React.useRef(value || defaultValue);
|
|
10402
10403
|
maxRows = maxRows || 1;
|
|
10403
10404
|
var multiline = maxRows > 1;
|
|
10404
10405
|
React.useLayoutEffect(function () {
|
|
@@ -10415,16 +10416,20 @@ function InlineTextEdit(_a) {
|
|
|
10415
10416
|
}
|
|
10416
10417
|
function handleClose() {
|
|
10417
10418
|
handleClick();
|
|
10418
|
-
onCancel && onCancel({ name: name, value: value });
|
|
10419
|
+
onCancel && onCancel({ name: name, value: value || valueRef.current });
|
|
10419
10420
|
}
|
|
10420
10421
|
function handleConfirm() {
|
|
10421
10422
|
handleClick();
|
|
10422
|
-
onConfirm && onConfirm({ name: name, value: value });
|
|
10423
|
+
onConfirm && onConfirm({ name: name, value: value || valueRef.current });
|
|
10423
10424
|
}
|
|
10424
10425
|
function handleOnClickAway() {
|
|
10425
10426
|
if (!showActionButtons && editing)
|
|
10426
10427
|
handleConfirm();
|
|
10427
10428
|
}
|
|
10429
|
+
function handleOnChange(e) {
|
|
10430
|
+
valueRef.current = e.target.value;
|
|
10431
|
+
onChange && onChange(e);
|
|
10432
|
+
}
|
|
10428
10433
|
tooltipPlacement = tooltipPlacement || "right";
|
|
10429
10434
|
var offsetWidthOfSpan = ((_b = spanRef === null || spanRef === void 0 ? void 0 : spanRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 150;
|
|
10430
10435
|
if (offsetWidthOfSpan < 150) {
|
|
@@ -10440,8 +10445,8 @@ function InlineTextEdit(_a) {
|
|
|
10440
10445
|
!editing &&
|
|
10441
10446
|
React.createElement(Tooltip, { title: tooltipTitle, arrow: true, placement: tooltipPlacement },
|
|
10442
10447
|
React.createElement(Box, { component: "span", className: "".concat(!children && placeholder ? "hasPlaceholder" : "", " pointer"), onClick: handleClick, style: { maxHeight: offsetHeightOfSpan * maxRows } }, children || placeholder)),
|
|
10443
|
-
|
|
10444
|
-
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:
|
|
10448
|
+
React.createElement(Box, { className: editing ? "" : "hidden" },
|
|
10449
|
+
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 && {
|
|
10445
10450
|
callback: onTimeoutChange
|
|
10446
10451
|
} }),
|
|
10447
10452
|
showActionButtons &&
|
|
@@ -8,7 +8,7 @@ export type TInlineTextEdit = {
|
|
|
8
8
|
defaultValue?: string;
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
name?: string;
|
|
11
|
-
onChange
|
|
11
|
+
onChange?: TTextFieldChange;
|
|
12
12
|
onTimeoutChange?: TTextFieldChange;
|
|
13
13
|
onConfirm: TInlineTextEditActions;
|
|
14
14
|
onCancel?: TInlineTextEditActions;
|
package/dist/esm/index.js
CHANGED
|
@@ -10379,6 +10379,7 @@ function InlineTextEdit(_a) {
|
|
|
10379
10379
|
var _d = useState(false), editing = _d[0], setEditing = _d[1];
|
|
10380
10380
|
var id = useRef(Math.floor(Math.random() * 1000000000));
|
|
10381
10381
|
var spanRef = useRef(null);
|
|
10382
|
+
var valueRef = useRef(value || defaultValue);
|
|
10382
10383
|
maxRows = maxRows || 1;
|
|
10383
10384
|
var multiline = maxRows > 1;
|
|
10384
10385
|
useLayoutEffect(function () {
|
|
@@ -10395,16 +10396,20 @@ function InlineTextEdit(_a) {
|
|
|
10395
10396
|
}
|
|
10396
10397
|
function handleClose() {
|
|
10397
10398
|
handleClick();
|
|
10398
|
-
onCancel && onCancel({ name: name, value: value });
|
|
10399
|
+
onCancel && onCancel({ name: name, value: value || valueRef.current });
|
|
10399
10400
|
}
|
|
10400
10401
|
function handleConfirm() {
|
|
10401
10402
|
handleClick();
|
|
10402
|
-
onConfirm && onConfirm({ name: name, value: value });
|
|
10403
|
+
onConfirm && onConfirm({ name: name, value: value || valueRef.current });
|
|
10403
10404
|
}
|
|
10404
10405
|
function handleOnClickAway() {
|
|
10405
10406
|
if (!showActionButtons && editing)
|
|
10406
10407
|
handleConfirm();
|
|
10407
10408
|
}
|
|
10409
|
+
function handleOnChange(e) {
|
|
10410
|
+
valueRef.current = e.target.value;
|
|
10411
|
+
onChange && onChange(e);
|
|
10412
|
+
}
|
|
10408
10413
|
tooltipPlacement = tooltipPlacement || "right";
|
|
10409
10414
|
var offsetWidthOfSpan = ((_b = spanRef === null || spanRef === void 0 ? void 0 : spanRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 150;
|
|
10410
10415
|
if (offsetWidthOfSpan < 150) {
|
|
@@ -10420,8 +10425,8 @@ function InlineTextEdit(_a) {
|
|
|
10420
10425
|
!editing &&
|
|
10421
10426
|
React__default.createElement(Tooltip$1, { title: tooltipTitle, arrow: true, placement: tooltipPlacement },
|
|
10422
10427
|
React__default.createElement(Box$1, { component: "span", className: "".concat(!children && placeholder ? "hasPlaceholder" : "", " pointer"), onClick: handleClick, style: { maxHeight: offsetHeightOfSpan * maxRows } }, children || placeholder)),
|
|
10423
|
-
|
|
10424
|
-
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:
|
|
10428
|
+
React__default.createElement(Box$1, { className: editing ? "" : "hidden" },
|
|
10429
|
+
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 && {
|
|
10425
10430
|
callback: onTimeoutChange
|
|
10426
10431
|
} }),
|
|
10427
10432
|
showActionButtons &&
|