@cakemail-org/ui-components-v2 2.1.18 → 2.1.20
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/cjs/components/inlineTextEdit/index.d.ts +1 -1
- package/dist/cjs/components/inlineTextEdit/types.d.ts +0 -5
- package/dist/cjs/index.js +39 -14
- package/dist/esm/components/inlineTextEdit/index.d.ts +1 -1
- package/dist/esm/components/inlineTextEdit/types.d.ts +0 -5
- package/dist/esm/index.js +39 -14
- package/package.json +1 -1
|
@@ -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({
|
|
4
|
+
export declare function InlineTextEdit({ 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,10 @@
|
|
|
1
1
|
import { TTooltipPlacement } from "../header/types";
|
|
2
|
-
import { TTextFieldChange } from "../textField/types";
|
|
3
2
|
export type TInlineTextEdit = {
|
|
4
|
-
children: any;
|
|
5
3
|
tooltipTitle: string;
|
|
6
4
|
tooltipPlacement?: TTooltipPlacement;
|
|
7
|
-
value?: string;
|
|
8
5
|
defaultValue?: string;
|
|
9
6
|
placeholder?: string;
|
|
10
7
|
name?: string;
|
|
11
|
-
onChange?: TTextFieldChange;
|
|
12
|
-
onTimeoutChange?: TTextFieldChange;
|
|
13
8
|
onConfirm: TInlineTextEditActions;
|
|
14
9
|
onCancel?: TInlineTextEditActions;
|
|
15
10
|
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
|
|
10739
|
+
var 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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
@@ -10785,11 +10784,9 @@ function InlineTextEdit(_a) {
|
|
|
10785
10784
|
React.createElement(Box, { id: "inlineTextEdit-id-" + id.current, className: classes },
|
|
10786
10785
|
!editing &&
|
|
10787
10786
|
React.createElement(Tooltip, { title: tooltipTitle, arrow: true, placement: tooltipPlacement },
|
|
10788
|
-
React.createElement(Box, { component: "span", className: "".concat(!
|
|
10787
|
+
React.createElement(Box, { component: "span", className: "".concat(!value && placeholder ? "hasPlaceholder" : "", " pointer"), onClick: handleClick, style: { maxHeight: offsetHeightOfSpan * maxRows } }, value || 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") },
|
|
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', //
|
|
10798
|
+
whiteSpace: multiline ? 'pre-wrap' : 'pre', // For multiline, allow wrapping
|
|
10802
10799
|
position: 'absolute',
|
|
10803
|
-
|
|
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
|
|
|
@@ -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({
|
|
4
|
+
export declare function InlineTextEdit({ 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,10 @@
|
|
|
1
1
|
import { TTooltipPlacement } from "../header/types";
|
|
2
|
-
import { TTextFieldChange } from "../textField/types";
|
|
3
2
|
export type TInlineTextEdit = {
|
|
4
|
-
children: any;
|
|
5
3
|
tooltipTitle: string;
|
|
6
4
|
tooltipPlacement?: TTooltipPlacement;
|
|
7
|
-
value?: string;
|
|
8
5
|
defaultValue?: string;
|
|
9
6
|
placeholder?: string;
|
|
10
7
|
name?: string;
|
|
11
|
-
onChange?: TTextFieldChange;
|
|
12
|
-
onTimeoutChange?: TTextFieldChange;
|
|
13
8
|
onConfirm: TInlineTextEditActions;
|
|
14
9
|
onCancel?: TInlineTextEditActions;
|
|
15
10
|
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
|
|
10719
|
+
var 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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
@@ -10765,11 +10764,9 @@ function InlineTextEdit(_a) {
|
|
|
10765
10764
|
React__default.createElement(Box$1, { id: "inlineTextEdit-id-" + id.current, className: classes },
|
|
10766
10765
|
!editing &&
|
|
10767
10766
|
React__default.createElement(Tooltip$1, { title: tooltipTitle, arrow: true, placement: tooltipPlacement },
|
|
10768
|
-
React__default.createElement(Box$1, { component: "span", className: "".concat(!
|
|
10767
|
+
React__default.createElement(Box$1, { component: "span", className: "".concat(!value && placeholder ? "hasPlaceholder" : "", " pointer"), onClick: handleClick, style: { maxHeight: offsetHeightOfSpan * maxRows } }, value || 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") },
|
|
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', //
|
|
10778
|
+
whiteSpace: multiline ? 'pre-wrap' : 'pre', // For multiline, allow wrapping
|
|
10782
10779
|
position: 'absolute',
|
|
10783
|
-
|
|
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
|
|