@activecollab/components 2.0.260 → 2.0.262
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/EditableContent/Styles.js +40 -9
- package/dist/cjs/components/EditableContent/Styles.js.map +1 -1
- package/dist/cjs/components/EditableText/EditableText.js +37 -54
- package/dist/cjs/components/EditableText/EditableText.js.map +1 -1
- package/dist/esm/components/EditableContent/Styles.d.ts +11 -1
- package/dist/esm/components/EditableContent/Styles.d.ts.map +1 -1
- package/dist/esm/components/EditableContent/Styles.js +47 -8
- package/dist/esm/components/EditableContent/Styles.js.map +1 -1
- package/dist/esm/components/EditableText/EditableText.d.ts.map +1 -1
- package/dist/esm/components/EditableText/EditableText.js +22 -38
- package/dist/esm/components/EditableText/EditableText.js.map +1 -1
- package/dist/index.js +75 -59
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableText.js","names":["React","forwardRef","useCallback","useEffect","useRef","useState","classNames","styled","css","EditableContent","StyledDiv","StyledSpan","Typography","StyledTextareaSpan","withConfig","displayName","componentId","_ref","invalid","EditableText","_ref2","ref","onSave","onCancel","value","inputProps","allowEmptyString","multiline","variant","weight","disabled","wrapRef","children","props","currentValue","setCurrentValue","prevValue","setPrevValue","escapeRef","intTextareaRef","isTextareaFocused","setIsTextareaFocused","handleBlur","e","current","target","trim","length","scrollLeft","handleFocus","handleKeyDown","key","blur","handleChange","createElement","_extends","forwardedAs","$disabled","className","String","replace","onFocus","onBlur","onKeyDown","onChange","placeholder","rows","type"],"sources":["../../../../src/components/EditableText/EditableText.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nimport classNames from \"classnames\";\nimport styled, { css } from \"styled-components\";\nimport tw from \"twin.macro\";\n\nimport {\n EditableContent,\n EditableContentInterface,\n} from \"../EditableContent/EditableContent\";\nimport { StyledDiv, StyledSpan } from \"../EditableContent/Styles\";\nimport { Typography } from \"../Typography/Typography\";\n\nconst StyledTextareaSpan = styled(Typography)`\n ${tw`\n tw-absolute\n tw-inset-0\n tw-border\n tw-border-transparent\n tw-border-solid\n hover:tw-border-theme-700\n focus-within:tw-border-theme-700\n tw-rounded-md\n tw-box-border\n tw-w-full`}\n\n background-color: var(--input-background-color, #ffffff);\n padding-left: 4px;\n padding-right: 4px;\n padding-top: 1px;\n padding-bottom: 1px;\n font-variant-numeric: tabular-nums;\n outline-width: 0px;\n outline: none;\n resize: none;\n white-space: pre-wrap;\n overflow-wrap: break-word;\n height: calc(1.5em * 3 + 2px); /* 3 rows height: line-height * 3 + padding */\n min-height: calc(1.5em * 3 + 2px);\n opacity: 0;\n\n &:focus {\n opacity: 1;\n background-color: var(--input-background-color, #f8f9fa);\n }\n\n &:disabled {\n opacity: 0;\n }\n\n ${({ invalid }) =>\n invalid &&\n css`\n border-color: var(--red-alert) !important;\n `}\n`;\n\nexport interface EditableTextInterface extends EditableContentInterface {\n /** Value to display. */\n value?: string | null;\n /** Optional callback called on enter, click outside and tab. */\n onSave?: (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;\n /** Optional callback called on input reset. */\n onCancel?: () => void;\n /** If true, setting empty value will save it, instead of revert to previous value. */\n allowEmptyString?: boolean;\n /** If true, shows a textarea instead of input for multiline editing. */\n multiline?: boolean;\n /** Children content to display */\n children?: React.ReactNode;\n}\n\nexport const EditableText = forwardRef<HTMLDivElement, EditableTextInterface>(\n (\n {\n onSave,\n onCancel,\n value,\n inputProps,\n allowEmptyString,\n multiline = false,\n variant = \"Body 2\",\n weight,\n disabled = false,\n invalid,\n wrapRef,\n children,\n ...props\n },\n ref\n ) => {\n const [currentValue, setCurrentValue] = useState(value);\n const [prevValue, setPrevValue] = useState(value);\n const escapeRef = useRef(false);\n const intTextareaRef = useRef<HTMLTextAreaElement>(null);\n const [isTextareaFocused, setIsTextareaFocused] = useState(false);\n\n useEffect(() => {\n if (currentValue !== value) {\n setCurrentValue(value);\n setPrevValue(value);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value]);\n\n const handleBlur = useCallback(\n (e) => {\n setIsTextareaFocused(false);\n if (escapeRef.current) {\n setCurrentValue(prevValue);\n escapeRef.current = false;\n } else {\n if (\n e.target.value.trim().length > 0 &&\n prevValue !== e.target.value\n ) {\n setPrevValue(e.target.value);\n setCurrentValue(e.target.value);\n typeof onSave === \"function\" && onSave(e);\n } else {\n !allowEmptyString\n ? setCurrentValue(prevValue)\n : typeof onSave === \"function\" &&\n prevValue !== e.target.value &&\n onSave(e);\n }\n }\n // Reset scroll position for textarea\n if (multiline && intTextareaRef?.current) {\n intTextareaRef.current.scrollLeft = 0;\n }\n },\n [allowEmptyString, onSave, prevValue, multiline]\n );\n\n const handleFocus = useCallback(() => {\n setIsTextareaFocused(true);\n }, []);\n\n const handleKeyDown = useCallback(\n (e) => {\n if (e.key === \"Enter\" && !multiline) {\n e.target.blur();\n }\n if (e.key === \"Escape\") {\n escapeRef.current = true;\n e.target.blur();\n typeof onCancel === \"function\" && onCancel();\n }\n },\n [onCancel, multiline]\n );\n\n const handleChange = useCallback((e) => {\n setCurrentValue(e.target.value);\n }, []);\n\n if (multiline) {\n return (\n <StyledDiv ref={wrapRef} {...props}>\n <StyledSpan\n variant={variant}\n forwardedAs=\"span\"\n weight={weight}\n $disabled={!isTextareaFocused}\n className=\"presentation\"\n >\n {children\n ? children\n : String(currentValue || \"\").replace(/\\n/g, \" \")}\n </StyledSpan>\n <StyledTextareaSpan\n ref={intTextareaRef}\n forwardedAs=\"textarea\"\n variant={variant}\n weight={weight}\n value={currentValue ?? \"\"}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n disabled={disabled}\n invalid={invalid}\n data-form-type=\"other\"\n placeholder={inputProps?.placeholder}\n className={classNames(\"c-textarea\", inputProps?.className)}\n rows={3}\n {...inputProps}\n />\n </StyledDiv>\n );\n }\n\n return (\n <EditableContent\n {...props}\n variant={variant}\n weight={weight}\n disabled={disabled}\n invalid={invalid}\n wrapRef={wrapRef}\n ref={ref}\n inputProps={{\n ...inputProps,\n value: currentValue ?? \"\",\n onBlur: handleBlur,\n onKeyDown: handleKeyDown,\n onChange: handleChange,\n type: \"text\",\n className: classNames(\"c-input\", inputProps?.className),\n }}\n >\n {children}\n </EditableContent>\n );\n }\n);\n\nEditableText.displayName = \"EditableText\";\n"],"mappings":";AAAA,OAAOA,KAAK,IAEVC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAG/C,SACEC,eAAe,QAEV,oCAAoC;AAC3C,SAASC,SAAS,EAAEC,UAAU,QAAQ,2BAA2B;AACjE,SAASC,UAAU,QAAQ,0BAA0B;AAErD,MAAMC,kBAAkB,GAAGN,MAAM,CAACK,UAAU,CAAC,CAAAE,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,kbACvC;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;AAUO,CAAC,EA0BVC,IAAA;EAAA,IAAC;IAAEC;EAAQ,CAAC,GAAAD,IAAA;EAAA,OACZC,OAAO,IACPV,GAAG,+CAEF;AAAA,EACJ;AAiBD,OAAO,MAAMW,YAAY,gBAAGlB,UAAU,CACpC,CAAAmB,KAAA,EAgBEC,GAAG,KACA;EAAA,IAhBH;IACEC,MAAM;IACNC,QAAQ;IACRC,KAAK;IACLC,UAAU;IACVC,gBAAgB;IAChBC,SAAS,GAAG,KAAK;IACjBC,OAAO,GAAG,QAAQ;IAClBC,MAAM;IACNC,QAAQ,GAAG,KAAK;IAChBZ,OAAO;IACPa,OAAO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ACtBc,IAAI,EAAE,MAAM;MACZT,SAAS,EAAEpD,UAAU,CAAC,SAAS,EAAEmB,UAAU,oBAAVA,UAAU,CAAEiC,SAAS;IACxD;EAAE,IAED1B,QACc,CAAC;AAEtB,CACF,CAAC;AAEDb,YAAY,CAACJ,WAAW,GAAG,cAAc"}
|
|
1
|
+
{"version":3,"file":"EditableText.js","names":["React","forwardRef","useCallback","useEffect","useRef","useState","classNames","EditableContent","StyledDiv","StyledMultilineSpan","StyledTextareaSpan","EditableText","_ref","ref","onSave","onCancel","value","inputProps","allowEmptyString","multiline","variant","weight","disabled","invalid","wrapRef","children","props","currentValue","setCurrentValue","prevValue","setPrevValue","escapeRef","intTextareaRef","handleBlur","e","current","target","trim","length","scrollLeft","handleFocus","textarea","setSelectionRange","handleKeyDown","key","blur","handleChange","createElement","_extends","$multiline","forwardedAs","$disabled","className","onClick","focus","String","replace","onFocus","onBlur","onKeyDown","onChange","placeholder","rows","type","displayName"],"sources":["../../../../src/components/EditableText/EditableText.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n forwardRef,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nimport classNames from \"classnames\";\n\nimport {\n EditableContent,\n EditableContentInterface,\n} from \"../EditableContent/EditableContent\";\nimport {\n StyledDiv,\n StyledMultilineSpan,\n StyledTextareaSpan,\n} from \"../EditableContent/Styles\";\n\nexport interface EditableTextInterface extends EditableContentInterface {\n /** Value to display. */\n value?: string | null;\n /** Optional callback called on enter, click outside and tab. */\n onSave?: (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;\n /** Optional callback called on input reset. */\n onCancel?: () => void;\n /** If true, setting empty value will save it, instead of revert to previous value. */\n allowEmptyString?: boolean;\n /** If true, shows a textarea instead of input for multiline editing. */\n multiline?: boolean;\n /** Children content to display */\n children?: React.ReactNode;\n}\n\nexport const EditableText = forwardRef<HTMLDivElement, EditableTextInterface>(\n (\n {\n onSave,\n onCancel,\n value,\n inputProps,\n allowEmptyString,\n multiline = false,\n variant = \"Body 2\",\n weight,\n disabled = false,\n invalid,\n wrapRef,\n children,\n ...props\n },\n ref\n ) => {\n const [currentValue, setCurrentValue] = useState(value);\n const [prevValue, setPrevValue] = useState(value);\n const escapeRef = useRef(false);\n const intTextareaRef = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (currentValue !== value) {\n setCurrentValue(value);\n setPrevValue(value);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value]);\n\n const handleBlur = useCallback(\n (e) => {\n if (escapeRef.current) {\n setCurrentValue(prevValue);\n escapeRef.current = false;\n } else {\n if (\n e.target.value.trim().length > 0 &&\n prevValue !== e.target.value\n ) {\n setPrevValue(e.target.value);\n setCurrentValue(e.target.value);\n typeof onSave === \"function\" && onSave(e);\n } else {\n !allowEmptyString\n ? setCurrentValue(prevValue)\n : typeof onSave === \"function\" &&\n prevValue !== e.target.value &&\n onSave(e);\n }\n }\n // Reset scroll position for textarea\n if (multiline && intTextareaRef?.current) {\n intTextareaRef.current.scrollLeft = 0;\n }\n },\n [allowEmptyString, onSave, prevValue, multiline]\n );\n\n const handleFocus = useCallback(\n (e) => {\n if (multiline) {\n const textarea = e.target;\n const length = textarea.value.length;\n textarea.setSelectionRange(length, length);\n }\n },\n [multiline]\n );\n\n const handleKeyDown = useCallback(\n (e) => {\n if (e.key === \"Enter\" && !multiline) {\n e.target.blur();\n }\n if (e.key === \"Escape\") {\n escapeRef.current = true;\n e.target.blur();\n typeof onCancel === \"function\" && onCancel();\n }\n },\n [onCancel, multiline]\n );\n\n const handleChange = useCallback((e) => {\n setCurrentValue(e.target.value);\n }, []);\n\n if (multiline) {\n return (\n <StyledDiv ref={ref || wrapRef} {...props} $multiline={multiline}>\n <StyledMultilineSpan\n variant={variant}\n forwardedAs=\"span\"\n weight={weight}\n $disabled={disabled}\n invalid={invalid}\n className=\"presentation\"\n onClick={() => {\n if (!disabled && intTextareaRef.current) {\n intTextareaRef.current.focus();\n }\n }}\n >\n {children\n ? children\n : String(currentValue || \"\").replace(/\\n/g, \" \")}\n </StyledMultilineSpan>\n <StyledTextareaSpan\n ref={intTextareaRef}\n forwardedAs=\"textarea\"\n variant={variant}\n weight={weight}\n value={currentValue ?? \"\"}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n disabled={disabled}\n invalid={invalid}\n data-form-type=\"other\"\n placeholder={inputProps?.placeholder}\n className={classNames(\"c-textarea\", inputProps?.className)}\n rows={3}\n {...inputProps}\n />\n </StyledDiv>\n );\n }\n\n return (\n <EditableContent\n {...props}\n variant={variant}\n weight={weight}\n disabled={disabled}\n invalid={invalid}\n wrapRef={wrapRef}\n ref={ref}\n inputProps={{\n ...inputProps,\n value: currentValue ?? \"\",\n onBlur: handleBlur,\n onKeyDown: handleKeyDown,\n onChange: handleChange,\n type: \"text\",\n className: classNames(\"c-input\", inputProps?.className),\n }}\n >\n {children}\n </EditableContent>\n );\n }\n);\n\nEditableText.displayName = \"EditableText\";\n"],"mappings":";AAAA,OAAOA,KAAK,IAEVC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,eAAe,QAEV,oCAAoC;AAC3C,SACEC,SAAS,EACTC,mBAAmB,EACnBC,kBAAkB,QACb,2BAA2B;AAiBlC,OAAO,MAAMC,YAAY,gBAAGV,UAAU,CACpC,CAAAW,IAAA,EAgBEC,GAAG,KACA;EAAA,IAhBH;IACEC,MAAM;IACNC,QAAQ;IACRC,KAAK;IACLC,UAAU;IACVC,gBAAgB;IAChBC,SAAS,GAAG,KAAK;IACjBC,OAAO,GAAG,QAAQ;IAClBC,MAAM;IACNC,QAAQ,GAAG,KAAK;IAChBC,OAAO;IACPC,OAAO;IACPC,QAAQ;IACR,GAAGC;EACL,CAAC,GAAAd,IAAA;EAGD,MAAM,CAACe,YAAY,EAAEC,eAAe,CAAC,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EA,GAAI;IACTI,UAAU,EAAE;MACV,GAAGA,UAAU;MACbD,KAAK,EAAEW,YAAY,WAAZA,YAAY,GAAI,EAAE;MACzB+B,MAAM,EAAEzB,UAAU;MAClB0B,SAAS,EAAEhB,aAAa;MACxBiB,QAAQ,EAAEd,YAAY;MACtBiB,IAAI,EAAE,MAAM;MACZX,SAAS,EAAE9C,UAAU,CAAC,SAAS,EAAEW,UAAU,oBAAVA,UAAU,CAAEmC,SAAS;IACxD;EAAE,IAED3B,QACc,CAAC;AAEtB,CACF,CAAC;AAEDd,YAAY,CAACqD,WAAW,GAAG,cAAc"}
|
package/dist/index.js
CHANGED
|
@@ -22499,19 +22499,22 @@
|
|
|
22499
22499
|
var StyledDiv = styled__default["default"].div.withConfig({
|
|
22500
22500
|
displayName: "Styles__StyledDiv",
|
|
22501
22501
|
componentId: "sc-1wapx2a-0"
|
|
22502
|
-
})(["", " ", " ", ""], FontStyle, BoxSizingStyle, {
|
|
22502
|
+
})(["", " ", " ", " ", ""], FontStyle, BoxSizingStyle, {
|
|
22503
22503
|
"position": "relative",
|
|
22504
22504
|
"display": "inline-block",
|
|
22505
22505
|
"maxWidth": "100%"
|
|
22506
|
+
}, function (_ref) {
|
|
22507
|
+
var $multiline = _ref.$multiline;
|
|
22508
|
+
return $multiline && styled.css(["position:relative;display:flex;"]);
|
|
22506
22509
|
});
|
|
22507
22510
|
var StyledSpan = styled__default["default"](Typography).withConfig({
|
|
22508
22511
|
displayName: "Styles__StyledSpan",
|
|
22509
22512
|
componentId: "sc-1wapx2a-1"
|
|
22510
|
-
})(["visibility:hidden;display:block;padding-left:4px;padding-right:4px;padding-top:1px;padding-bottom:1px;position:relative;border:1px solid transparent;border-radius:6px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:pre;font-variant-numeric:tabular-nums;", " ", " &:empty:before{content:\" \";}"], function (
|
|
22511
|
-
var $disabled =
|
|
22512
|
-
return $disabled && styled.css(["visibility:visible;"]);
|
|
22513
|
-
}, function (
|
|
22514
|
-
var invalid =
|
|
22513
|
+
})(["visibility:hidden;display:block;padding-left:4px;padding-right:4px;padding-top:1px;padding-bottom:1px;position:relative;border:1px solid transparent;border-radius:6px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:pre;font-variant-numeric:tabular-nums;", " ", " &:empty:before{content:\" \";}"], function (_ref2) {
|
|
22514
|
+
var $disabled = _ref2.$disabled;
|
|
22515
|
+
return $disabled && styled.css(["visibility:visible;cursor:default !important;"]);
|
|
22516
|
+
}, function (_ref3) {
|
|
22517
|
+
var invalid = _ref3.invalid;
|
|
22515
22518
|
return invalid && styled.css(["border:1px solid var(--red-alert);"]);
|
|
22516
22519
|
});
|
|
22517
22520
|
StyledSpan.displayName = "StyledSpan";
|
|
@@ -22536,11 +22539,39 @@
|
|
|
22536
22539
|
":hover": {
|
|
22537
22540
|
"borderColor": "var(--color-theme-700)"
|
|
22538
22541
|
}
|
|
22539
|
-
}, function (
|
|
22540
|
-
var invalid =
|
|
22542
|
+
}, function (_ref4) {
|
|
22543
|
+
var invalid = _ref4.invalid;
|
|
22541
22544
|
return invalid && styled.css(["border-color:var(--red-alert) !important;"]);
|
|
22542
22545
|
});
|
|
22543
22546
|
StyledInput$1.displayName = "StyledInput";
|
|
22547
|
+
var StyledMultilineSpan = styled__default["default"](StyledSpan).withConfig({
|
|
22548
|
+
displayName: "Styles__StyledMultilineSpan",
|
|
22549
|
+
componentId: "sc-1wapx2a-3"
|
|
22550
|
+
})(["cursor:", ";z-index:2;width:100%;visibility:visible !important;&:hover{border-color:", ";}"], function (_ref5) {
|
|
22551
|
+
var $disabled = _ref5.$disabled;
|
|
22552
|
+
return $disabled ? "default" : "text !important";
|
|
22553
|
+
}, function (_ref6) {
|
|
22554
|
+
var invalid = _ref6.invalid,
|
|
22555
|
+
$disabled = _ref6.$disabled;
|
|
22556
|
+
return invalid ? "var(--red-alert)" : $disabled ? "transparent" : "var(--border-primary)";
|
|
22557
|
+
});
|
|
22558
|
+
StyledMultilineSpan.displayName = "StyledMultilineSpan";
|
|
22559
|
+
var StyledTextareaSpan = styled__default["default"](Typography).withConfig({
|
|
22560
|
+
displayName: "Styles__StyledTextareaSpan",
|
|
22561
|
+
componentId: "sc-1wapx2a-4"
|
|
22562
|
+
})(["", " background-color:var(--input-background-color);border-color:var(--color-theme-500);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;pointer-events:none;z-index:1;&:focus{opacity:1;pointer-events:auto;background-color:var(--input-background-color);border-color:var(--color-primary);outline:none;z-index:3;}&:disabled{opacity:0;pointer-events:none;}", ""], {
|
|
22563
|
+
"position": "absolute",
|
|
22564
|
+
"inset": "0px",
|
|
22565
|
+
"boxSizing": "border-box",
|
|
22566
|
+
"width": "100%",
|
|
22567
|
+
"borderRadius": "0.375rem",
|
|
22568
|
+
"borderWidth": "1px",
|
|
22569
|
+
"borderStyle": "solid"
|
|
22570
|
+
}, function (_ref7) {
|
|
22571
|
+
var invalid = _ref7.invalid;
|
|
22572
|
+
return invalid && styled.css(["border-color:var(--red-alert) !important;"]);
|
|
22573
|
+
});
|
|
22574
|
+
StyledTextareaSpan.displayName = "StyledTextareaSpan";
|
|
22544
22575
|
|
|
22545
22576
|
var _excluded$g = ["className", "variant", "weight", "disabled", "inputProps", "wrapRef", "children", "invalid"];
|
|
22546
22577
|
var EditableContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
@@ -22587,45 +22618,23 @@
|
|
|
22587
22618
|
EditableContent.displayName = "EditableContent";
|
|
22588
22619
|
|
|
22589
22620
|
var _excluded$f = ["onSave", "onCancel", "value", "inputProps", "allowEmptyString", "multiline", "variant", "weight", "disabled", "invalid", "wrapRef", "children"];
|
|
22590
|
-
var
|
|
22591
|
-
|
|
22592
|
-
|
|
22593
|
-
|
|
22594
|
-
|
|
22595
|
-
|
|
22596
|
-
|
|
22597
|
-
|
|
22598
|
-
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
|
|
22605
|
-
|
|
22606
|
-
|
|
22607
|
-
}
|
|
22608
|
-
}, function (_ref) {
|
|
22609
|
-
var invalid = _ref.invalid;
|
|
22610
|
-
return invalid && styled.css(["border-color:var(--red-alert) !important;"]);
|
|
22611
|
-
});
|
|
22612
|
-
var EditableText = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
22613
|
-
var onSave = _ref2.onSave,
|
|
22614
|
-
onCancel = _ref2.onCancel,
|
|
22615
|
-
value = _ref2.value,
|
|
22616
|
-
inputProps = _ref2.inputProps,
|
|
22617
|
-
allowEmptyString = _ref2.allowEmptyString,
|
|
22618
|
-
_ref2$multiline = _ref2.multiline,
|
|
22619
|
-
multiline = _ref2$multiline === void 0 ? false : _ref2$multiline,
|
|
22620
|
-
_ref2$variant = _ref2.variant,
|
|
22621
|
-
variant = _ref2$variant === void 0 ? "Body 2" : _ref2$variant,
|
|
22622
|
-
weight = _ref2.weight,
|
|
22623
|
-
_ref2$disabled = _ref2.disabled,
|
|
22624
|
-
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
22625
|
-
invalid = _ref2.invalid,
|
|
22626
|
-
wrapRef = _ref2.wrapRef,
|
|
22627
|
-
children = _ref2.children,
|
|
22628
|
-
props = _objectWithoutProperties(_ref2, _excluded$f);
|
|
22621
|
+
var EditableText = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
22622
|
+
var onSave = _ref.onSave,
|
|
22623
|
+
onCancel = _ref.onCancel,
|
|
22624
|
+
value = _ref.value,
|
|
22625
|
+
inputProps = _ref.inputProps,
|
|
22626
|
+
allowEmptyString = _ref.allowEmptyString,
|
|
22627
|
+
_ref$multiline = _ref.multiline,
|
|
22628
|
+
multiline = _ref$multiline === void 0 ? false : _ref$multiline,
|
|
22629
|
+
_ref$variant = _ref.variant,
|
|
22630
|
+
variant = _ref$variant === void 0 ? "Body 2" : _ref$variant,
|
|
22631
|
+
weight = _ref.weight,
|
|
22632
|
+
_ref$disabled = _ref.disabled,
|
|
22633
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
22634
|
+
invalid = _ref.invalid,
|
|
22635
|
+
wrapRef = _ref.wrapRef,
|
|
22636
|
+
children = _ref.children,
|
|
22637
|
+
props = _objectWithoutProperties(_ref, _excluded$f);
|
|
22629
22638
|
var _useState = React.useState(value),
|
|
22630
22639
|
_useState2 = _slicedToArray(_useState, 2),
|
|
22631
22640
|
currentValue = _useState2[0],
|
|
@@ -22636,10 +22645,6 @@
|
|
|
22636
22645
|
setPrevValue = _useState4[1];
|
|
22637
22646
|
var escapeRef = React.useRef(false);
|
|
22638
22647
|
var intTextareaRef = React.useRef(null);
|
|
22639
|
-
var _useState5 = React.useState(false),
|
|
22640
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
22641
|
-
isTextareaFocused = _useState6[0],
|
|
22642
|
-
setIsTextareaFocused = _useState6[1];
|
|
22643
22648
|
React.useEffect(function () {
|
|
22644
22649
|
if (currentValue !== value) {
|
|
22645
22650
|
setCurrentValue(value);
|
|
@@ -22648,7 +22653,6 @@
|
|
|
22648
22653
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22649
22654
|
}, [value]);
|
|
22650
22655
|
var handleBlur = React.useCallback(function (e) {
|
|
22651
|
-
setIsTextareaFocused(false);
|
|
22652
22656
|
if (escapeRef.current) {
|
|
22653
22657
|
setCurrentValue(prevValue);
|
|
22654
22658
|
escapeRef.current = false;
|
|
@@ -22666,9 +22670,13 @@
|
|
|
22666
22670
|
intTextareaRef.current.scrollLeft = 0;
|
|
22667
22671
|
}
|
|
22668
22672
|
}, [allowEmptyString, onSave, prevValue, multiline]);
|
|
22669
|
-
var handleFocus = React.useCallback(function () {
|
|
22670
|
-
|
|
22671
|
-
|
|
22673
|
+
var handleFocus = React.useCallback(function (e) {
|
|
22674
|
+
if (multiline) {
|
|
22675
|
+
var textarea = e.target;
|
|
22676
|
+
var length = textarea.value.length;
|
|
22677
|
+
textarea.setSelectionRange(length, length);
|
|
22678
|
+
}
|
|
22679
|
+
}, [multiline]);
|
|
22672
22680
|
var handleKeyDown = React.useCallback(function (e) {
|
|
22673
22681
|
if (e.key === "Enter" && !multiline) {
|
|
22674
22682
|
e.target.blur();
|
|
@@ -22684,13 +22692,21 @@
|
|
|
22684
22692
|
}, []);
|
|
22685
22693
|
if (multiline) {
|
|
22686
22694
|
return /*#__PURE__*/React__default["default"].createElement(StyledDiv, _extends({
|
|
22687
|
-
ref: wrapRef
|
|
22688
|
-
}, props
|
|
22695
|
+
ref: ref || wrapRef
|
|
22696
|
+
}, props, {
|
|
22697
|
+
$multiline: multiline
|
|
22698
|
+
}), /*#__PURE__*/React__default["default"].createElement(StyledMultilineSpan, {
|
|
22689
22699
|
variant: variant,
|
|
22690
22700
|
forwardedAs: "span",
|
|
22691
22701
|
weight: weight,
|
|
22692
|
-
$disabled:
|
|
22693
|
-
|
|
22702
|
+
$disabled: disabled,
|
|
22703
|
+
invalid: invalid,
|
|
22704
|
+
className: "presentation",
|
|
22705
|
+
onClick: function onClick() {
|
|
22706
|
+
if (!disabled && intTextareaRef.current) {
|
|
22707
|
+
intTextareaRef.current.focus();
|
|
22708
|
+
}
|
|
22709
|
+
}
|
|
22694
22710
|
}, children ? children : String(currentValue || "").replace(/\n/g, " ")), /*#__PURE__*/React__default["default"].createElement(StyledTextareaSpan, _extends({
|
|
22695
22711
|
ref: intTextareaRef,
|
|
22696
22712
|
forwardedAs: "textarea",
|