@activecollab/components 2.0.493 → 2.0.495
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/EditableContent.js +12 -19
- package/dist/cjs/components/EditableContent/EditableContent.js.map +1 -1
- package/dist/cjs/components/EditableContent/Styles.js +16 -1
- package/dist/cjs/components/EditableContent/Styles.js.map +1 -1
- package/dist/cjs/components/EditableContent/useHoverSuppression.js +34 -0
- package/dist/cjs/components/EditableContent/useHoverSuppression.js.map +1 -0
- package/dist/cjs/components/EditableText/EditableText.js +65 -60
- package/dist/cjs/components/EditableText/EditableText.js.map +1 -1
- package/dist/cjs/components/EditableText/useEditableText.js +90 -0
- package/dist/cjs/components/EditableText/useEditableText.js.map +1 -0
- package/dist/cjs/components/EmptySlate/EmptySlate.js +28 -3
- package/dist/cjs/components/EmptySlate/EmptySlate.js.map +1 -1
- package/dist/cjs/components/EmptySlate/EmptySlate.styles.js +4 -1
- package/dist/cjs/components/EmptySlate/EmptySlate.styles.js.map +1 -1
- package/dist/esm/components/EditableContent/EditableContent.d.ts.map +1 -1
- package/dist/esm/components/EditableContent/EditableContent.js +13 -13
- package/dist/esm/components/EditableContent/EditableContent.js.map +1 -1
- package/dist/esm/components/EditableContent/Styles.d.ts +9 -0
- package/dist/esm/components/EditableContent/Styles.d.ts.map +1 -1
- package/dist/esm/components/EditableContent/Styles.js +15 -0
- package/dist/esm/components/EditableContent/Styles.js.map +1 -1
- package/dist/esm/components/EditableContent/useHoverSuppression.d.ts +9 -0
- package/dist/esm/components/EditableContent/useHoverSuppression.d.ts.map +1 -0
- package/dist/esm/components/EditableContent/useHoverSuppression.js +20 -0
- package/dist/esm/components/EditableContent/useHoverSuppression.js.map +1 -0
- package/dist/esm/components/EditableText/EditableText.d.ts +2 -0
- package/dist/esm/components/EditableText/EditableText.d.ts.map +1 -1
- package/dist/esm/components/EditableText/EditableText.js +67 -54
- package/dist/esm/components/EditableText/EditableText.js.map +1 -1
- package/dist/esm/components/EditableText/useEditableText.d.ts +18 -0
- package/dist/esm/components/EditableText/useEditableText.d.ts.map +1 -0
- package/dist/esm/components/EditableText/useEditableText.js +74 -0
- package/dist/esm/components/EditableText/useEditableText.js.map +1 -0
- package/dist/esm/components/EmptySlate/EmptySlate.d.ts.map +1 -1
- package/dist/esm/components/EmptySlate/EmptySlate.js +16 -2
- package/dist/esm/components/EmptySlate/EmptySlate.js.map +1 -1
- package/dist/esm/components/EmptySlate/EmptySlate.styles.d.ts +3 -1
- package/dist/esm/components/EmptySlate/EmptySlate.styles.d.ts.map +1 -1
- package/dist/esm/components/EmptySlate/EmptySlate.styles.js +4 -1
- package/dist/esm/components/EmptySlate/EmptySlate.styles.js.map +1 -1
- package/dist/index.js +187 -45
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEditableText.js","names":["_react","require","_slicedToArray","r","e","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","t","toString","call","slice","constructor","name","Array","from","test","length","n","l","Symbol","iterator","i","u","f","o","next","Object","done","push","value","return","isArray","withoutLineBreaks","text","replace","useEditableText","exports","_ref","onSave","onCancel","allowEmptyString","_ref$submitOnMetaEnte","submitOnMetaEnter","mode","_useState","useState","_useState2","currentValue","setCurrentValue","_useState3","_useState4","prevValue","setPrevValue","escapeRef","useRef","multiline","useEffect","handleBlur","useCallback","current","target","trim","scrollLeft","scrollTop","handleKeyDown","key","preventDefault","blur","metaKey","ctrlKey","stopPropagation","handleChange"],"sources":["../../../../src/components/EditableText/useEditableText.ts"],"sourcesContent":["import { ChangeEvent, useCallback, useEffect, useRef, useState } from \"react\";\n\nexport type EditableTextMode = \"single\" | \"multiline\" | \"wrap\";\n\ninterface UseEditableTextArgs {\n value?: string | null;\n onSave?: (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;\n onCancel?: (e) => void;\n allowEmptyString?: boolean;\n submitOnMetaEnter?: boolean;\n mode: EditableTextMode;\n}\n\nconst withoutLineBreaks = (text: string) => text.replace(/\\s*[\\r\\n]+\\s*/g, \" \");\n\nexport const useEditableText = ({\n value,\n onSave,\n onCancel,\n allowEmptyString,\n submitOnMetaEnter = false,\n mode,\n}: UseEditableTextArgs) => {\n const [currentValue, setCurrentValue] = useState(value);\n const [prevValue, setPrevValue] = useState(value);\n const escapeRef = useRef(false);\n const multiline = mode === \"multiline\";\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 (e.target.value.trim().length > 0 && prevValue !== e.target.value) {\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 if (mode !== \"single\") {\n e.target.scrollLeft = 0;\n }\n if (mode === \"wrap\") {\n e.target.scrollTop = 0;\n }\n },\n [allowEmptyString, onSave, prevValue, mode]\n );\n\n const handleKeyDown = useCallback(\n (e) => {\n if (e.key === \"Enter\" && !multiline) {\n // A textarea must not get the line break.\n mode === \"wrap\" && e.preventDefault();\n e.target.blur();\n }\n if (\n e.key === \"Enter\" &&\n multiline &&\n submitOnMetaEnter &&\n (e.metaKey || e.ctrlKey)\n ) {\n e.preventDefault();\n e.target.blur();\n }\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n escapeRef.current = true;\n e.target.blur();\n typeof onCancel === \"function\" && onCancel(e);\n }\n },\n [onCancel, multiline, mode, submitOnMetaEnter]\n );\n\n const handleChange = useCallback(\n (e) =>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AIA,QAAQ,CAACxC,CAAC,CAAC;IAC/C;EACF,CAAC,EACD,CAACwC,QAAQ,EAAEgB,SAAS,EAAEZ,IAAI,EAAED,iBAAiB,CAC/C,CAAC;EAED,IAAM6B,YAAY,GAAG,IAAAb,kBAAW,EAC9B,UAAC3D,CAAC,EAAK;IACLiD,eAAe,CACbL,IAAI,KAAK,MAAM,GAAGX,iBAAiB,CAACjC,CAAC,CAAC6D,MAAM,CAAC/B,KAAK,CAAC,GAAG9B,CAAC,CAAC6D,MAAM,CAAC/B,KACjE,CAAC;EACH,CAAC,EACD,CAACc,IAAI,CACP,CAAC;EAED,OAAO;IAAEI,YAAY;IAAEU,UAAU;IAAEO,aAAa;IAAEO;EAAa,CAAC;AAClE,CAAC","ignoreList":[]}
|
|
@@ -4,14 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EmptySlate = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _EmptySlate = require("./EmptySlate.styles");
|
|
9
9
|
var _EmptySlateFooter = require("./EmptySlateFooter");
|
|
10
10
|
var _excluded = ["title", "description", "src", "alt", "children"];
|
|
11
|
-
function
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
12
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
14
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
16
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
18
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
19
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
14
20
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
21
|
+
var isAlreadyLoaded = function isAlreadyLoaded(image) {
|
|
22
|
+
return !!image && image.complete && image.naturalWidth > 0;
|
|
23
|
+
};
|
|
15
24
|
var EmptySlate = exports.EmptySlate = function EmptySlate(_ref) {
|
|
16
25
|
var title = _ref.title,
|
|
17
26
|
description = _ref.description,
|
|
@@ -19,11 +28,27 @@ var EmptySlate = exports.EmptySlate = function EmptySlate(_ref) {
|
|
|
19
28
|
alt = _ref.alt,
|
|
20
29
|
children = _ref.children,
|
|
21
30
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
31
|
+
var imageRef = (0, _react.useRef)(null);
|
|
32
|
+
var _useState = (0, _react.useState)(),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
loadedSrc = _useState2[0],
|
|
35
|
+
setLoadedSrc = _useState2[1];
|
|
36
|
+
var markLoaded = (0, _react.useCallback)(function () {
|
|
37
|
+
return setLoadedSrc(src);
|
|
38
|
+
}, [src]);
|
|
39
|
+
(0, _react.useLayoutEffect)(function () {
|
|
40
|
+
if (isAlreadyLoaded(imageRef.current)) {
|
|
41
|
+
markLoaded();
|
|
42
|
+
}
|
|
43
|
+
}, [markLoaded]);
|
|
22
44
|
return /*#__PURE__*/_react.default.createElement(_EmptySlate.Container, _extends({}, rest, {
|
|
23
45
|
role: "status"
|
|
24
46
|
}), /*#__PURE__*/_react.default.createElement(_EmptySlate.StyledImg, {
|
|
47
|
+
ref: imageRef,
|
|
25
48
|
src: src,
|
|
26
|
-
alt: alt
|
|
49
|
+
alt: alt,
|
|
50
|
+
onLoad: markLoaded,
|
|
51
|
+
$loaded: loadedSrc === src
|
|
27
52
|
}), /*#__PURE__*/_react.default.createElement(_EmptySlate.SubContainer, null, /*#__PURE__*/_react.default.createElement(_EmptySlate.Title, {
|
|
28
53
|
weight: "light",
|
|
29
54
|
variant: "Title 1"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptySlate.js","names":["_react","
|
|
1
|
+
{"version":3,"file":"EmptySlate.js","names":["_react","_interopRequireWildcard","require","_EmptySlate","_EmptySlateFooter","_excluded","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","l","Symbol","iterator","u","next","done","push","value","return","isArray","_objectWithoutProperties","_objectWithoutPropertiesLoose","getOwnPropertySymbols","indexOf","propertyIsEnumerable","isAlreadyLoaded","image","complete","naturalWidth","EmptySlate","exports","_ref","title","description","src","alt","children","rest","imageRef","useRef","_useState","useState","_useState2","loadedSrc","setLoadedSrc","markLoaded","useCallback","useLayoutEffect","current","createElement","Container","role","StyledImg","ref","onLoad","$loaded","SubContainer","Title","weight","variant","Description","color","Footer","EmptySlateFooter","displayName"],"sources":["../../../../src/components/EmptySlate/EmptySlate.tsx"],"sourcesContent":["import React, {\n HTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\n\nimport {\n Container,\n Description,\n SubContainer,\n Title,\n StyledImg,\n} from \"./EmptySlate.styles\";\nimport { EmptySlateFooter } from \"./EmptySlateFooter\";\n\nexport interface EmptySlateProps extends HTMLAttributes<HTMLDivElement> {\n src: string;\n alt: string;\n title: string;\n description?: string;\n}\n\nconst isAlreadyLoaded = (image: HTMLImageElement | null) =>\n !!image && image.complete && image.naturalWidth > 0;\n\nexport const EmptySlate = ({\n title,\n description,\n src,\n alt,\n children,\n ...rest\n}: EmptySlateProps) => {\n const imageRef = useRef<HTMLImageElement>(null);\n const [loadedSrc, setLoadedSrc] = useState<string>();\n\n const markLoaded = useCallback(() => setLoadedSrc(src), [src]);\n\n useLayoutEffect(() => {\n if (isAlreadyLoaded(imageRef.current)) {\n markLoaded();\n }\n }, [markLoaded]);\n\n return (\n <Container {...rest} role=\"status\">\n <StyledImg\n ref={imageRef}\n src={src}\n alt={alt}\n onLoad={markLoaded}\n $loaded={loadedSrc === src}\n />\n <SubContainer>\n <Title weight=\"light\" variant=\"Title 1\">\n {title}\n </Title>\n {description && (\n <Description color=\"tertiary\" variant=\"Body 1\">\n {description}\n </Description>\n )}\n\n {children}\n </SubContainer>\n </Container>\n );\n};\n\nEmptySlate.Footer = EmptySlateFooter;\n\nEmptySlate.displayName = \"EmptySlate\";\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAQA,IAAAC,WAAA,GAAAD,OAAA;AAOA,IAAAE,iBAAA,GAAAF,OAAA;AAAsD,IAAAG,SAAA;AAAA,SAAAJ,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,wBAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CA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AAAsE,aAAA,CAACnF,WAAA,CAAA8F,WAAW;IAACC,KAAK,EAAC,UAAU;IAACF,OAAO,EAAC;EAAQ,GAC3C1B,WACU,CACd,EAEAG,QACW,CACL,CAAC;AAEhB,CAAC;AAEDP,UAAU,CAACiC,MAAM,GAAGC,kCAAgB;AAEpClC,UAAU,CAACmC,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
@@ -19,7 +19,10 @@ var SubContainer = exports.SubContainer = _styledComponents.default.div.withConf
|
|
|
19
19
|
var StyledImg = exports.StyledImg = _styledComponents.default.img.withConfig({
|
|
20
20
|
displayName: "EmptySlatestyles__StyledImg",
|
|
21
21
|
componentId: "sc-jfbqky-2"
|
|
22
|
-
})(["width:280px;height:280px;"])
|
|
22
|
+
})(["width:280px;height:280px;visibility:", ";"], function (_ref) {
|
|
23
|
+
var $loaded = _ref.$loaded;
|
|
24
|
+
return $loaded ? "visible" : "hidden";
|
|
25
|
+
});
|
|
23
26
|
var Title = exports.Title = (0, _styledComponents.default)(_Typography.Typography).withConfig({
|
|
24
27
|
displayName: "EmptySlatestyles__Title",
|
|
25
28
|
componentId: "sc-jfbqky-3"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptySlate.styles.js","names":["_styledComponents","_interopRequireDefault","require","_BreakPoints","_Typography","e","__esModule","default","Container","exports","styled","div","withConfig","displayName","componentId","screen","lg","SubContainer","StyledImg","img","Title","Typography","Description","FooterContainer"],"sources":["../../../../src/components/EmptySlate/EmptySlate.styles.ts"],"sourcesContent":["import styled from \"styled-components\";\n\nimport { screen } from \"../BreakPoints\";\nimport { Typography } from \"../Typography/Typography\";\n\nexport const Container = styled.div`\n display: flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n text-align: center;\n gap: 24px;\n\n ${screen.lg} {\n flex-direction: row;\n }\n`;\n\nexport const SubContainer = styled.div`\n display: flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n max-width: 400px;\n padding-left: 20px;\n padding-right: 20px;\n\n ${screen.lg} {\n align-items: flex-start;\n }\n`;\n\nexport const StyledImg = styled.img
|
|
1
|
+
{"version":3,"file":"EmptySlate.styles.js","names":["_styledComponents","_interopRequireDefault","require","_BreakPoints","_Typography","e","__esModule","default","Container","exports","styled","div","withConfig","displayName","componentId","screen","lg","SubContainer","StyledImg","img","_ref","$loaded","Title","Typography","Description","FooterContainer"],"sources":["../../../../src/components/EmptySlate/EmptySlate.styles.ts"],"sourcesContent":["import styled from \"styled-components\";\n\nimport { screen } from \"../BreakPoints\";\nimport { Typography } from \"../Typography/Typography\";\n\nexport const Container = styled.div`\n display: flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n text-align: center;\n gap: 24px;\n\n ${screen.lg} {\n flex-direction: row;\n }\n`;\n\nexport const SubContainer = styled.div`\n display: flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n max-width: 400px;\n padding-left: 20px;\n padding-right: 20px;\n\n ${screen.lg} {\n align-items: flex-start;\n }\n`;\n\nexport const StyledImg = styled.img<{ $loaded: boolean }>`\n width: 280px;\n height: 280px;\n visibility: ${({ $loaded }) => ($loaded ? \"visible\" : \"hidden\")};\n`;\n\nexport const Title = styled(Typography)`\n margin-block-end: 8px;\n text-align: center;\n\n ${screen.lg} {\n text-align: start;\n }\n`;\n\nexport const Description = styled(Typography)`\n text-align: center;\n\n ${screen.lg} {\n text-align: start;\n }\n`;\n\nexport const FooterContainer = styled.div`\n margin-block-start: 24px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n align-items: center;\n\n ${screen.lg} {\n flex-direction: row;\n }\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAAsD,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/C,IAAMG,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAGE,yBAAM,CAACC,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,0IAQ/BC,mBAAM,CAACC,EAAE,CAGZ;AAEM,IAAMC,YAAY,GAAAR,OAAA,CAAAQ,YAAA,GAAGP,yBAAM,CAACC,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,wKASlCC,mBAAM,CAACC,EAAE,CAGZ;AAEM,IAAME,SAAS,GAAAT,OAAA,CAAAS,SAAA,GAAGR,yBAAM,CAACS,GAAG,CAAAP,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,kDAGnB,UAAAM,IAAA;EAAA,IAAGC,OAAO,GAAAD,IAAA,CAAPC,OAAO;EAAA,OAAQA,OAAO,GAAG,SAAS,GAAG,QAAQ;AAAA,CAAC,CAChE;AAEM,IAAMC,KAAK,GAAAb,OAAA,CAAAa,KAAA,GAAG,IAAAZ,yBAAM,EAACa,sBAAU,CAAC,CAAAX,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,uEAInCC,mBAAM,CAACC,EAAE,CAGZ;AAEM,IAAMQ,WAAW,GAAAf,OAAA,CAAAe,WAAA,GAAG,IAAAd,yBAAM,EAACa,sBAAU,CAAC,CAAAX,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,kDAGzCC,mBAAM,CAACC,EAAE,CAGZ;AAEM,IAAMS,eAAe,GAAAhB,OAAA,CAAAgB,eAAA,GAAGf,yBAAM,CAACC,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,yHAOrCC,mBAAM,CAACC,EAAE,CAGZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableContent.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableContent/EditableContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"EditableContent.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableContent/EditableContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,GAAG,EAAuB,MAAM,OAAO,CAAC;AAKpE,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,MAAM,WAAW,wBAAwB;IACvC,0BAA0B;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yBAAyB;IACzB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IACjD,mBAAmB;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9D,yBAAyB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yBAAyB;IACzB,OAAO,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC/B;AAED,eAAO,MAAM,eAAe,oOA8F3B,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["className", "variant", "weight", "disabled", "inputProps", "wrapRef", "children", "invalid", "onMouseLeave"];
|
|
4
|
-
import React, { forwardRef, useCallback, useRef
|
|
4
|
+
import React, { forwardRef, useCallback, useRef } from "react";
|
|
5
5
|
import { StyledDiv, StyledInput, StyledSpan } from "./Styles";
|
|
6
|
+
import { useHoverSuppression } from "./useHoverSuppression";
|
|
6
7
|
import { useForkRef } from "../../utils";
|
|
7
8
|
export const EditableContent = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
8
9
|
let className = _ref.className,
|
|
@@ -19,9 +20,10 @@ export const EditableContent = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
19
20
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
20
21
|
const intInputRef = useRef(null);
|
|
21
22
|
const handleRef = useForkRef(ref, intInputRef);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const _useHoverSuppression = useHoverSuppression(),
|
|
24
|
+
hoverSuppressed = _useHoverSuppression.hoverSuppressed,
|
|
25
|
+
suppressHoverOnKey = _useHoverSuppression.suppressHoverOnKey,
|
|
26
|
+
releaseHover = _useHoverSuppression.releaseHover;
|
|
25
27
|
const handleBlur = useCallback(evt => {
|
|
26
28
|
if (intInputRef != null && intInputRef.current) {
|
|
27
29
|
intInputRef.current.scrollLeft = 0;
|
|
@@ -29,19 +31,17 @@ export const EditableContent = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
29
31
|
typeof (inputProps == null ? void 0 : inputProps.onBlur) === "function" && (inputProps == null ? void 0 : inputProps.onBlur(evt));
|
|
30
32
|
}, [inputProps]);
|
|
31
33
|
const handleKeyDown = useCallback(evt => {
|
|
32
|
-
|
|
33
|
-
setSuppressHover(true);
|
|
34
|
-
}
|
|
34
|
+
suppressHoverOnKey(evt);
|
|
35
35
|
typeof (inputProps == null ? void 0 : inputProps.onKeyDown) === "function" && inputProps.onKeyDown(evt);
|
|
36
|
-
}, [inputProps]);
|
|
36
|
+
}, [inputProps, suppressHoverOnKey]);
|
|
37
37
|
const handleFocus = useCallback(evt => {
|
|
38
|
-
|
|
38
|
+
releaseHover();
|
|
39
39
|
typeof (inputProps == null ? void 0 : inputProps.onFocus) === "function" && inputProps.onFocus(evt);
|
|
40
|
-
}, [inputProps]);
|
|
40
|
+
}, [inputProps, releaseHover]);
|
|
41
41
|
const handleMouseLeave = useCallback(evt => {
|
|
42
|
-
|
|
42
|
+
releaseHover();
|
|
43
43
|
typeof onMouseLeave === "function" && onMouseLeave(evt);
|
|
44
|
-
}, [onMouseLeave]);
|
|
44
|
+
}, [onMouseLeave, releaseHover]);
|
|
45
45
|
return /*#__PURE__*/React.createElement(StyledDiv, _extends({
|
|
46
46
|
className: className,
|
|
47
47
|
ref: wrapRef
|
|
@@ -64,7 +64,7 @@ export const EditableContent = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
64
64
|
onFocus: handleFocus,
|
|
65
65
|
disabled: disabled,
|
|
66
66
|
"data-form-type": "other",
|
|
67
|
-
"data-hover-suppressed":
|
|
67
|
+
"data-hover-suppressed": hoverSuppressed,
|
|
68
68
|
invalid: invalid
|
|
69
69
|
})));
|
|
70
70
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableContent.js","names":["React","forwardRef","useCallback","useRef","
|
|
1
|
+
{"version":3,"file":"EditableContent.js","names":["React","forwardRef","useCallback","useRef","StyledDiv","StyledInput","StyledSpan","useHoverSuppression","useForkRef","EditableContent","_ref","ref","className","_ref$variant","variant","weight","_ref$disabled","disabled","inputProps","wrapRef","children","invalid","onMouseLeave","props","_objectWithoutPropertiesLoose","_excluded","intInputRef","handleRef","_useHoverSuppression","hoverSuppressed","suppressHoverOnKey","releaseHover","handleBlur","evt","current","scrollLeft","onBlur","handleKeyDown","onKeyDown","handleFocus","onFocus","handleMouseLeave","createElement","_extends","forwardedAs","$disabled","value","displayName"],"sources":["../../../../src/components/EditableContent/EditableContent.tsx"],"sourcesContent":["import React, { forwardRef, Ref, useCallback, useRef } from \"react\";\n\nimport { StyledDiv, StyledInput, StyledSpan } from \"./Styles\";\nimport { useHoverSuppression } from \"./useHoverSuppression\";\nimport { useForkRef } from \"../../utils\";\nimport { Variant } from \"../Typography/Typography\";\n\nexport interface EditableContentInterface {\n /** Typography variant. */\n variant?: Variant;\n /** Typography weight. */\n weight?: \"light\" | \"regular\" | \"bold\" | \"medium\";\n /** Input props. */\n inputProps?: Partial<React.ComponentPropsWithoutRef<\"input\">>;\n /** Disable edit mode. */\n disabled?: boolean;\n invalid?: boolean;\n /** Wrapper reference. */\n wrapRef?: Ref<HTMLDivElement>;\n}\n\nexport const EditableContent = forwardRef<\n HTMLDivElement,\n EditableContentInterface &\n Omit<React.ComponentPropsWithoutRef<\"div\">, keyof EditableContentInterface>\n>(\n (\n {\n className,\n variant = \"Body 2\",\n weight,\n disabled = false,\n inputProps,\n wrapRef,\n children,\n invalid,\n onMouseLeave,\n ...props\n },\n ref\n ) => {\n const intInputRef = useRef<HTMLInputElement>(null);\n const handleRef = useForkRef(ref, intInputRef);\n const { hoverSuppressed, suppressHoverOnKey, releaseHover } =\n useHoverSuppression();\n\n const handleBlur = useCallback(\n (evt) => {\n if (intInputRef?.current) {\n intInputRef.current.scrollLeft = 0;\n }\n typeof inputProps?.onBlur === `function` && inputProps?.onBlur(evt);\n },\n [inputProps]\n );\n\n const handleKeyDown = useCallback(\n (evt) => {\n suppressHoverOnKey(evt);\n typeof inputProps?.onKeyDown === \"function\" &&\n inputProps.onKeyDown(evt);\n },\n [inputProps, suppressHoverOnKey]\n );\n\n const handleFocus = useCallback(\n (evt) => {\n releaseHover();\n typeof inputProps?.onFocus === \"function\" && inputProps.onFocus(evt);\n },\n [inputProps, releaseHover]\n );\n\n const handleMouseLeave = useCallback(\n (evt) => {\n releaseHover();\n typeof onMouseLeave === \"function\" && onMouseLeave(evt);\n },\n [onMouseLeave, releaseHover]\n );\n\n return (\n <StyledDiv\n className={className}\n ref={wrapRef}\n {...props}\n onMouseLeave={handleMouseLeave}\n >\n <StyledSpan\n variant={variant}\n forwardedAs=\"span\"\n weight={weight}\n $disabled={disabled}\n className=\"presentation\"\n >\n {children ? children : inputProps?.value}\n </StyledSpan>\n <StyledInput\n {...inputProps}\n ref={handleRef}\n forwardedAs=\"input\"\n variant={variant}\n weight={weight}\n value={inputProps?.value}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n disabled={disabled}\n data-form-type=\"other\"\n data-hover-suppressed={hoverSuppressed}\n invalid={invalid}\n />\n </StyledDiv>\n );\n }\n);\n\nEditableContent.displayName = \"EditableContent\";\n"],"mappings":";;;AAAA,OAAOA,KAA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AAVA,UAAU,CAAE4B,KACzB,CAAC,eACb9C,KAAA,CAAA0C,aAAA,CAACrC,WAAW,EAAAsC,QAAA,KACNzB,UAAU;IACdP,GAAG,EAAEgB,SAAU;IACfiB,WAAW,EAAC,OAAO;IACnB9B,OAAO,EAAEA,OAAQ;IACjBC,MAAM,EAAEA,MAAO;IACf+B,KAAK,EAAE5B,UAAU,oBAAVA,UAAU,CAAE4B,KAAM;IACzBV,MAAM,EAAEJ,UAAW;IACnBM,SAAS,EAAED,aAAc;IACzBG,OAAO,EAAED,WAAY;IACrBtB,QAAQ,EAAEA,QAAS;IACnB,kBAAe,OAAO;IACtB,yBAAuBY,eAAgB;IACvCR,OAAO,EAAEA;EAAQ,EAClB,CACQ,CAAC;AAEhB,CACF,CAAC;AAEDZ,eAAe,CAACsC,WAAW,GAAG,iBAAiB","ignoreList":[]}
|
|
@@ -17,4 +17,13 @@ export declare const StyledMultilineSpan: import("styled-components").StyledComp
|
|
|
17
17
|
export declare const StyledTextareaSpan: import("styled-components").StyledComponent<import("../Typography/Typography").TypographyComponent & {
|
|
18
18
|
displayName?: string;
|
|
19
19
|
}, any, {}, never>;
|
|
20
|
+
export declare const StyledWrapRoot: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
21
|
+
export declare const StyledWrapSpan: import("styled-components").StyledComponent<import("../Typography/Typography").TypographyComponent & {
|
|
22
|
+
displayName?: string;
|
|
23
|
+
}, any, {
|
|
24
|
+
$disabled?: boolean;
|
|
25
|
+
}, never>;
|
|
26
|
+
export declare const StyledWrapTextarea: import("styled-components").StyledComponent<import("../Typography/Typography").TypographyComponent & {
|
|
27
|
+
displayName?: string;
|
|
28
|
+
}, any, {}, never>;
|
|
20
29
|
//# sourceMappingURL=Styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableContent/Styles.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS;iBAA6B,OAAO;SAazD,CAAC;AAEF,eAAO,MAAM,UAAU;;;gBAAoC,OAAO;SAgCjE,CAAC;AAIF,eAAO,MAAM,WAAW;;kBAwCvB,CAAC;AAIF,eAAO,MAAM,mBAAmB;;;gBAhF2B,OAAO;SA8FjE,CAAC;AAIF,eAAO,MAAM,kBAAkB;;kBA+C9B,CAAC"}
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableContent/Styles.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS;iBAA6B,OAAO;SAazD,CAAC;AAEF,eAAO,MAAM,UAAU;;;gBAAoC,OAAO;SAgCjE,CAAC;AAIF,eAAO,MAAM,WAAW;;kBAwCvB,CAAC;AAIF,eAAO,MAAM,mBAAmB;;;gBAhF2B,OAAO;SA8FjE,CAAC;AAIF,eAAO,MAAM,kBAAkB;;kBA+C9B,CAAC;AAIF,eAAO,MAAM,cAAc,qEAS1B,CAAC;AAIF,eAAO,MAAM,cAAc;;;gBAlKgC,OAAO;SAuKjE,CAAC;AAIF,eAAO,MAAM,kBAAkB;;kBAW9B,CAAC"}
|
|
@@ -75,4 +75,19 @@ export const StyledTextareaSpan = styled(Typography).withConfig({
|
|
|
75
75
|
return invalid && css(["border-color:var(--red-alert) !important;"]);
|
|
76
76
|
});
|
|
77
77
|
StyledTextareaSpan.displayName = "StyledTextareaSpan";
|
|
78
|
+
export const StyledWrapRoot = styled.span.withConfig({
|
|
79
|
+
displayName: "Styles__StyledWrapRoot",
|
|
80
|
+
componentId: "sc-1wapx2a-5"
|
|
81
|
+
})(["", " ", " position:relative;display:inline-block;vertical-align:top;min-width:10px;max-width:100%;"], FontStyle, BoxSizingStyle);
|
|
82
|
+
StyledWrapRoot.displayName = "StyledWrapRoot";
|
|
83
|
+
export const StyledWrapSpan = styled(StyledSpan).withConfig({
|
|
84
|
+
displayName: "Styles__StyledWrapSpan",
|
|
85
|
+
componentId: "sc-1wapx2a-6"
|
|
86
|
+
})(["overflow:visible;text-overflow:clip;white-space:pre-wrap;overflow-wrap:anywhere;"]);
|
|
87
|
+
StyledWrapSpan.displayName = "StyledWrapSpan";
|
|
88
|
+
export const StyledWrapTextarea = styled(StyledInput).withConfig({
|
|
89
|
+
displayName: "Styles__StyledWrapTextarea",
|
|
90
|
+
componentId: "sc-1wapx2a-7"
|
|
91
|
+
})(["height:100%;margin:0;resize:none;white-space:pre-wrap;overflow-wrap:anywhere;&,&:focus-within{overflow:hidden;}"]);
|
|
92
|
+
StyledWrapTextarea.displayName = "StyledWrapTextarea";
|
|
78
93
|
//# sourceMappingURL=Styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["styled","css","BoxSizingStyle","FontStyle","Typography","StyledDiv","div","withConfig","displayName","componentId","_ref","$multiline","StyledSpan","_ref2","$disabled","_ref3","invalid","StyledInput","_ref4","StyledMultilineSpan","_ref5","_ref6","StyledTextareaSpan","_ref7"],"sources":["../../../../src/components/EditableContent/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport tw from \"twin.macro\";\n\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { FontStyle } from \"../FontStyle\";\nimport { Typography } from \"../Typography/Typography\";\n\nexport const StyledDiv = styled.div<{ $multiline?: boolean }>`\n ${FontStyle}\n ${BoxSizingStyle}\n\n\n\n ${tw`tw-relative tw-inline-block tw-max-w-full`}\n ${({ $multiline }) =>\n $multiline &&\n css`\n position: relative;\n display: flex;\n `}\n`;\n\nexport const StyledSpan = styled(Typography)<{ $disabled?: boolean }>`\n visibility: hidden;\n display: block;\n padding-left: 4px;\n padding-right: 4px;\n padding-top: 1px;\n padding-bottom: 1px;\n position: relative;\n border: 1px solid transparent;\n border-radius: 6px;\n max-width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: pre;\n font-variant-numeric: tabular-nums;\n\n ${({ $disabled }) =>\n $disabled &&\n css`\n visibility: visible;\n cursor: default !important;\n `}\n\n ${({ invalid }) =>\n invalid &&\n css`\n border: 1px solid var(--red-alert);\n `}\n\n &:empty:before {\n content: \" \";\n }\n`;\n\nStyledSpan.displayName = \"StyledSpan\";\n\nexport const StyledInput = styled(Typography)`\n ${tw`\n tw-absolute\n tw-inset-0\n tw-border\n tw-border-transparent\n tw-border-solid\n focus-within:tw-border-theme-700\n tw-rounded-md\n tw-box-border\n tw-overflow-hidden\n tw-whitespace-nowrap\n focus-within:tw-overflow-scroll\n tw-w-full`}\n\n background-color: inherit;\n padding-left: 4px;\n padding-right: 4px;\n padding-top: 1px;\n padding-bottom: 1px;\n text-overflow: ellipsis;\n font-variant-numeric: tabular-nums;\n &:focus-whitin {\n text-overflow: clip;\n }\n outline-width: 0px;\n outline: none;\n &:disabled {\n opacity: 0;\n }\n\n &:not([data-hover-suppressed]):hover {\n border-color: var(--color-theme-700);\n }\n\n ${({ invalid }) =>\n invalid &&\n css`\n border-color: var(--red-alert) !important;\n `}\n`;\n\nStyledInput.displayName = \"StyledInput\";\n\nexport const StyledMultilineSpan = styled(StyledSpan)`\n cursor: ${({ $disabled }) => ($disabled ? \"default\" : \"text !important\")};\n z-index: 2;\n width: 100%;\n visibility: visible !important;\n\n &:hover {\n border-color: ${({ invalid, $disabled }) =>\n invalid\n ? \"var(--red-alert)\"\n : $disabled\n ? \"transparent\"\n : \"var(--border-primary)\"};\n }\n`;\n\nStyledMultilineSpan.displayName = \"StyledMultilineSpan\";\n\nexport const StyledTextareaSpan = styled(Typography)`\n ${tw`\n tw-absolute\n tw-inset-0\n tw-border\n tw-border-solid\n tw-rounded-md\n tw-box-border\n tw-w-full`}\n\n background-color: var(--input-background-color);\n border-color: var(--color-theme-500);\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 pointer-events: none;\n z-index: 1;\n\n &:focus {\n opacity: 1;\n pointer-events: auto;\n background-color: var(--input-background-color);\n border-color: var(--color-primary);\n outline: none;\n z-index: 3;\n }\n\n &:disabled {\n opacity: 0;\n pointer-events: none;\n }\n\n ${({ invalid }) =>\n invalid &&\n css`\n border-color: var(--red-alert) !important;\n `}\n`;\n\nStyledTextareaSpan.displayName = \"StyledTextareaSpan\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAG/C,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,UAAU,QAAQ,0BAA0B;AAErD,OAAO,MAAMC,SAAS,GAAGL,MAAM,CAACM,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,4BAC/BN,SAAS,EACTD,cAAc,EAIZ;EAAA;EAAA;EAAA;AAA0C,CAAC,EAC7CQ,IAAA;EAAA,IAAGC,UAAU,GAAAD,IAAA,CAAVC,UAAU;EAAA,OACbA,UAAU,IACVV,GAAG,qCAGF;AAAA,EACJ;AAED,OAAO,MAAMW,UAAU,GAAGZ,MAAM,CAACI,UAAU,CAAC,CAAAG,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,gUAgBxCI,KAAA;EAAA,IAAGC,SAAS,GAAAD,KAAA,CAATC,SAAS;EAAA,OACZA,SAAS,IACTb,GAAG,mDAGF;AAAA,GAEDc,KAAA;EAAA,IAAGC,OAAO,GAAAD,KAAA,CAAPC,OAAO;EAAA,OACVA,OAAO,IACPf,GAAG,wCAEF;AAAA,EAKJ;AAEDW,UAAU,CAACJ,WAAW,GAAG,YAAY;AAErC,OAAO,MAAMS,WAAW,GAAGjB,MAAM,CAACI,UAAU,CAAC,CAAAG,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,4UACvC;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;AAYO,CAAC,EAsBVS,KAAA;EAAA,IAAGF,OAAO,GAAAE,KAAA,CAAPF,OAAO;EAAA,OACVA,OAAO,IACPf,GAAG,+CAEF;AAAA,EACJ;AAEDgB,WAAW,CAACT,WAAW,GAAG,aAAa;AAEvC,OAAO,MAAMW,mBAAmB,GAAGnB,MAAM,CAACY,UAAU,CAAC,CAAAL,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,mGACzCW,KAAA;EAAA,IAAGN,SAAS,GAAAM,KAAA,CAATN,SAAS;EAAA,OAAQA,SAAS,GAAG,SAAS,GAAG,iBAAiB;AAAA,CAAC,EAMtDO,KAAA;EAAA,IAAGL,OAAO,GAAAK,KAAA,CAAPL,OAAO;IAAEF,SAAS,GAAAO,KAAA,CAATP,SAAS;EAAA,OACnCE,OAAO,GACH,kBAAkB,GAClBF,SAAS,GACT,aAAa,GACb,uBAAuB;AAAA,EAEhC;AAEDK,mBAAmB,CAACX,WAAW,GAAG,qBAAqB;AAEvD,OAAO,MAAMc,kBAAkB,GAAGtB,MAAM,CAACI,UAAU,CAAC,CAAAG,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,qkBAC9C;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAOO,CAAC,EAkCVc,KAAA;EAAA,IAAGP,OAAO,GAAAO,KAAA,CAAPP,OAAO;EAAA,OACVA,OAAO,IACPf,GAAG,+CAEF;AAAA,EACJ;AAEDqB,kBAAkB,CAACd,WAAW,GAAG,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["styled","css","BoxSizingStyle","FontStyle","Typography","StyledDiv","div","withConfig","displayName","componentId","_ref","$multiline","StyledSpan","_ref2","$disabled","_ref3","invalid","StyledInput","_ref4","StyledMultilineSpan","_ref5","_ref6","StyledTextareaSpan","_ref7","StyledWrapRoot","span","StyledWrapSpan","StyledWrapTextarea"],"sources":["../../../../src/components/EditableContent/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\nimport tw from \"twin.macro\";\n\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { FontStyle } from \"../FontStyle\";\nimport { Typography } from \"../Typography/Typography\";\n\nexport const StyledDiv = styled.div<{ $multiline?: boolean }>`\n ${FontStyle}\n ${BoxSizingStyle}\n\n\n\n ${tw`tw-relative tw-inline-block tw-max-w-full`}\n ${({ $multiline }) =>\n $multiline &&\n css`\n position: relative;\n display: flex;\n `}\n`;\n\nexport const StyledSpan = styled(Typography)<{ $disabled?: boolean }>`\n visibility: hidden;\n display: block;\n padding-left: 4px;\n padding-right: 4px;\n padding-top: 1px;\n padding-bottom: 1px;\n position: relative;\n border: 1px solid transparent;\n border-radius: 6px;\n max-width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: pre;\n font-variant-numeric: tabular-nums;\n\n ${({ $disabled }) =>\n $disabled &&\n css`\n visibility: visible;\n cursor: default !important;\n `}\n\n ${({ invalid }) =>\n invalid &&\n css`\n border: 1px solid var(--red-alert);\n `}\n\n &:empty:before {\n content: \" \";\n }\n`;\n\nStyledSpan.displayName = \"StyledSpan\";\n\nexport const StyledInput = styled(Typography)`\n ${tw`\n tw-absolute\n tw-inset-0\n tw-border\n tw-border-transparent\n tw-border-solid\n focus-within:tw-border-theme-700\n tw-rounded-md\n tw-box-border\n tw-overflow-hidden\n tw-whitespace-nowrap\n focus-within:tw-overflow-scroll\n tw-w-full`}\n\n background-color: inherit;\n padding-left: 4px;\n padding-right: 4px;\n padding-top: 1px;\n padding-bottom: 1px;\n text-overflow: ellipsis;\n font-variant-numeric: tabular-nums;\n &:focus-whitin {\n text-overflow: clip;\n }\n outline-width: 0px;\n outline: none;\n &:disabled {\n opacity: 0;\n }\n\n &:not([data-hover-suppressed]):hover {\n border-color: var(--color-theme-700);\n }\n\n ${({ invalid }) =>\n invalid &&\n css`\n border-color: var(--red-alert) !important;\n `}\n`;\n\nStyledInput.displayName = \"StyledInput\";\n\nexport const StyledMultilineSpan = styled(StyledSpan)`\n cursor: ${({ $disabled }) => ($disabled ? \"default\" : \"text !important\")};\n z-index: 2;\n width: 100%;\n visibility: visible !important;\n\n &:hover {\n border-color: ${({ invalid, $disabled }) =>\n invalid\n ? \"var(--red-alert)\"\n : $disabled\n ? \"transparent\"\n : \"var(--border-primary)\"};\n }\n`;\n\nStyledMultilineSpan.displayName = \"StyledMultilineSpan\";\n\nexport const StyledTextareaSpan = styled(Typography)`\n ${tw`\n tw-absolute\n tw-inset-0\n tw-border\n tw-border-solid\n tw-rounded-md\n tw-box-border\n tw-w-full`}\n\n background-color: var(--input-background-color);\n border-color: var(--color-theme-500);\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 pointer-events: none;\n z-index: 1;\n\n &:focus {\n opacity: 1;\n pointer-events: auto;\n background-color: var(--input-background-color);\n border-color: var(--color-primary);\n outline: none;\n z-index: 3;\n }\n\n &:disabled {\n opacity: 0;\n pointer-events: none;\n }\n\n ${({ invalid }) =>\n invalid &&\n css`\n border-color: var(--red-alert) !important;\n `}\n`;\n\nStyledTextareaSpan.displayName = \"StyledTextareaSpan\";\n\nexport const StyledWrapRoot = styled.span`\n ${FontStyle}\n ${BoxSizingStyle}\n\n position: relative;\n display: inline-block;\n vertical-align: top;\n min-width: 10px;\n max-width: 100%;\n`;\n\nStyledWrapRoot.displayName = \"StyledWrapRoot\";\n\nexport const StyledWrapSpan = styled(StyledSpan)`\n overflow: visible;\n text-overflow: clip;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n`;\n\nStyledWrapSpan.displayName = \"StyledWrapSpan\";\n\nexport const StyledWrapTextarea = styled(StyledInput)`\n height: 100%;\n margin: 0;\n resize: none;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n\n &,\n &:focus-within {\n overflow: hidden;\n }\n`;\n\nStyledWrapTextarea.displayName = \"StyledWrapTextarea\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAG/C,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,UAAU,QAAQ,0BAA0B;AAErD,OAAO,MAAMC,SAAS,GAAGL,MAAM,CAACM,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,4BAC/BN,SAAS,EACTD,cAAc,EAIZ;EAAA;EAAA;EAAA;AAA0C,CAAC,EAC7CQ,IAAA;EAAA,IAAGC,UAAU,GAAAD,IAAA,CAAVC,UAAU;EAAA,OACbA,UAAU,IACVV,GAAG,qCAGF;AAAA,EACJ;AAED,OAAO,MAAMW,UAAU,GAAGZ,MAAM,CAACI,UAAU,CAAC,CAAAG,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,gUAgBxCI,KAAA;EAAA,IAAGC,SAAS,GAAAD,KAAA,CAATC,SAAS;EAAA,OACZA,SAAS,IACTb,GAAG,mDAGF;AAAA,GAEDc,KAAA;EAAA,IAAGC,OAAO,GAAAD,KAAA,CAAPC,OAAO;EAAA,OACVA,OAAO,IACPf,GAAG,wCAEF;AAAA,EAKJ;AAEDW,UAAU,CAACJ,WAAW,GAAG,YAAY;AAErC,OAAO,MAAMS,WAAW,GAAGjB,MAAM,CAACI,UAAU,CAAC,CAAAG,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,4UACvC;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;AAYO,CAAC,EAsBVS,KAAA;EAAA,IAAGF,OAAO,GAAAE,KAAA,CAAPF,OAAO;EAAA,OACVA,OAAO,IACPf,GAAG,+CAEF;AA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AAC,WAAA;EAAAC,WAAA;AAAA,uHAWpD;AAEDkB,kBAAkB,CAACnB,WAAW,GAAG,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Holds back the hover look after Enter or Escape, until the pointer leaves or the field gets focus. */
|
|
2
|
+
export declare const useHoverSuppression: () => {
|
|
3
|
+
hoverSuppressed: string | undefined;
|
|
4
|
+
suppressHoverOnKey: (evt: {
|
|
5
|
+
key: string;
|
|
6
|
+
}) => void;
|
|
7
|
+
releaseHover: () => void;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useHoverSuppression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHoverSuppression.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableContent/useHoverSuppression.ts"],"names":[],"mappings":"AAEA,yGAAyG;AACzG,eAAO,MAAM,mBAAmB;;8BAGe;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;;CAa7D,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
/** Holds back the hover look after Enter or Escape, until the pointer leaves or the field gets focus. */
|
|
4
|
+
export const useHoverSuppression = () => {
|
|
5
|
+
const _useState = useState(false),
|
|
6
|
+
suppressHover = _useState[0],
|
|
7
|
+
setSuppressHover = _useState[1];
|
|
8
|
+
const suppressHoverOnKey = useCallback(evt => {
|
|
9
|
+
if (evt.key === "Enter" || evt.key === "Escape") {
|
|
10
|
+
setSuppressHover(true);
|
|
11
|
+
}
|
|
12
|
+
}, []);
|
|
13
|
+
const releaseHover = useCallback(() => setSuppressHover(false), []);
|
|
14
|
+
return {
|
|
15
|
+
hoverSuppressed: suppressHover ? "" : undefined,
|
|
16
|
+
suppressHoverOnKey,
|
|
17
|
+
releaseHover
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useHoverSuppression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHoverSuppression.js","names":["useCallback","useState","useHoverSuppression","_useState","suppressHover","setSuppressHover","suppressHoverOnKey","evt","key","releaseHover","hoverSuppressed","undefined"],"sources":["../../../../src/components/EditableContent/useHoverSuppression.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\n/** Holds back the hover look after Enter or Escape, until the pointer leaves or the field gets focus. */\nexport const useHoverSuppression = () => {\n const [suppressHover, setSuppressHover] = useState(false);\n\n const suppressHoverOnKey = useCallback((evt: { key: string }) => {\n if (evt.key === \"Enter\" || evt.key === \"Escape\") {\n setSuppressHover(true);\n }\n }, []);\n\n const releaseHover = useCallback(() => setSuppressHover(false), []);\n\n return {\n hoverSuppressed: suppressHover ? \"\" : undefined,\n suppressHoverOnKey,\n releaseHover,\n };\n};\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;;AAE7C;AACA,OAAO,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EACvC,MAAAC,SAAA,GAA0CF,QAAQ,CAAC,KAAK,CAAC;IAAlDG,aAAa,GAAAD,SAAA;IAAEE,gBAAgB,GAAAF,SAAA;EAEtC,MAAMG,kBAAkB,GAAGN,WAAW,CAAEO,GAAoB,IAAK;IAC/D,IAAIA,GAAG,CAACC,GAAG,KAAK,OAAO,IAAID,GAAG,CAACC,GAAG,KAAK,QAAQ,EAAE;MAC/CH,gBAAgB,CAAC,IAAI,CAAC;IACxB;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMI,YAAY,GAAGT,WAAW,CAAC,MAAMK,gBAAgB,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;EAEnE,OAAO;IACLK,eAAe,EAAEN,aAAa,GAAG,EAAE,GAAGO,SAAS;IAC/CL,kBAAkB;IAClBG;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -13,6 +13,8 @@ export interface EditableTextInterface extends EditableContentInterface {
|
|
|
13
13
|
multiline?: boolean;
|
|
14
14
|
/** If true, Cmd/Ctrl+Enter commits a multiline edit (plain Enter keeps inserting a newline). */
|
|
15
15
|
submitOnMetaEnter?: boolean;
|
|
16
|
+
/** If true, the field is as wide as its text, wraps at the container width and grows down. Enter commits, the value never holds a line break. */
|
|
17
|
+
wrap?: boolean;
|
|
16
18
|
/** Children content to display */
|
|
17
19
|
children?: React.ReactNode;
|
|
18
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableText.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableText/EditableText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,WAAW,
|
|
1
|
+
{"version":3,"file":"EditableText.d.ts","sourceRoot":"","sources":["../../../../src/components/EditableText/EditableText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,WAAW,EAKZ,MAAM,OAAO,CAAC;AAKf,OAAO,EAEL,wBAAwB,EACzB,MAAM,oCAAoC,CAAC;AAW5C,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;IACrE,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gEAAgE;IAChE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,KAAK,IAAI,CAAC;IAC1E,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAA,KAAK,IAAI,CAAC;IACvB,sFAAsF;IACtF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wEAAwE;IACxE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gGAAgG;IAChG,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iJAAiJ;IACjJ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kCAAkC;IAClC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,YAAY,8FA6KxB,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["onSave", "onCancel", "value", "inputProps", "allowEmptyString", "multiline", "submitOnMetaEnter", "variant", "weight", "disabled", "invalid", "wrapRef", "children"]
|
|
4
|
-
|
|
3
|
+
const _excluded = ["onSave", "onCancel", "value", "inputProps", "allowEmptyString", "multiline", "submitOnMetaEnter", "wrap", "variant", "weight", "disabled", "invalid", "wrapRef", "children"],
|
|
4
|
+
_excluded2 = ["onMouseLeave"];
|
|
5
|
+
import React, { forwardRef, useCallback, useRef } from "react";
|
|
5
6
|
import classNames from "classnames";
|
|
7
|
+
import { useEditableText } from "./useEditableText";
|
|
6
8
|
import { EditableContent } from "../EditableContent/EditableContent";
|
|
7
|
-
import { StyledDiv, StyledMultilineSpan, StyledTextareaSpan } from "../EditableContent/Styles";
|
|
9
|
+
import { StyledDiv, StyledMultilineSpan, StyledTextareaSpan, StyledWrapRoot, StyledWrapSpan, StyledWrapTextarea } from "../EditableContent/Styles";
|
|
10
|
+
import { useHoverSuppression } from "../EditableContent/useHoverSuppression";
|
|
8
11
|
export const EditableText = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
9
12
|
let onSave = _ref.onSave,
|
|
10
13
|
onCancel = _ref.onCancel,
|
|
@@ -15,6 +18,8 @@ export const EditableText = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
15
18
|
multiline = _ref$multiline === void 0 ? false : _ref$multiline,
|
|
16
19
|
_ref$submitOnMetaEnte = _ref.submitOnMetaEnter,
|
|
17
20
|
submitOnMetaEnter = _ref$submitOnMetaEnte === void 0 ? false : _ref$submitOnMetaEnte,
|
|
21
|
+
_ref$wrap = _ref.wrap,
|
|
22
|
+
wrap = _ref$wrap === void 0 ? false : _ref$wrap,
|
|
18
23
|
_ref$variant = _ref.variant,
|
|
19
24
|
variant = _ref$variant === void 0 ? "Body 2" : _ref$variant,
|
|
20
25
|
weight = _ref.weight,
|
|
@@ -24,39 +29,24 @@ export const EditableText = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
24
29
|
wrapRef = _ref.wrapRef,
|
|
25
30
|
children = _ref.children,
|
|
26
31
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const mode = wrap ? "wrap" : multiline ? "multiline" : "single";
|
|
33
|
+
const _useEditableText = useEditableText({
|
|
34
|
+
value,
|
|
35
|
+
onSave,
|
|
36
|
+
onCancel,
|
|
37
|
+
allowEmptyString,
|
|
38
|
+
submitOnMetaEnter,
|
|
39
|
+
mode
|
|
40
|
+
}),
|
|
41
|
+
currentValue = _useEditableText.currentValue,
|
|
42
|
+
handleBlur = _useEditableText.handleBlur,
|
|
43
|
+
handleKeyDown = _useEditableText.handleKeyDown,
|
|
44
|
+
handleChange = _useEditableText.handleChange;
|
|
45
|
+
const _useHoverSuppression = useHoverSuppression(),
|
|
46
|
+
hoverSuppressed = _useHoverSuppression.hoverSuppressed,
|
|
47
|
+
suppressHoverOnKey = _useHoverSuppression.suppressHoverOnKey,
|
|
48
|
+
releaseHover = _useHoverSuppression.releaseHover;
|
|
34
49
|
const intTextareaRef = useRef(null);
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (currentValue !== value) {
|
|
37
|
-
setCurrentValue(value);
|
|
38
|
-
setPrevValue(value);
|
|
39
|
-
}
|
|
40
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
-
}, [value]);
|
|
42
|
-
const handleBlur = useCallback(e => {
|
|
43
|
-
if (escapeRef.current) {
|
|
44
|
-
setCurrentValue(prevValue);
|
|
45
|
-
escapeRef.current = false;
|
|
46
|
-
} else {
|
|
47
|
-
if (e.target.value.trim().length > 0 && prevValue !== e.target.value) {
|
|
48
|
-
setPrevValue(e.target.value);
|
|
49
|
-
setCurrentValue(e.target.value);
|
|
50
|
-
typeof onSave === "function" && onSave(e);
|
|
51
|
-
} else {
|
|
52
|
-
!allowEmptyString ? setCurrentValue(prevValue) : typeof onSave === "function" && prevValue !== e.target.value && onSave(e);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// Reset scroll position for textarea
|
|
56
|
-
if (multiline && intTextareaRef != null && intTextareaRef.current) {
|
|
57
|
-
intTextareaRef.current.scrollLeft = 0;
|
|
58
|
-
}
|
|
59
|
-
}, [allowEmptyString, onSave, prevValue, multiline]);
|
|
60
50
|
const handleFocus = useCallback(e => {
|
|
61
51
|
if (multiline) {
|
|
62
52
|
const textarea = e.target;
|
|
@@ -64,25 +54,48 @@ export const EditableText = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
64
54
|
textarea.setSelectionRange(length, length);
|
|
65
55
|
}
|
|
66
56
|
}, [multiline]);
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
57
|
+
const handleWrapKeyDown = useCallback(e => {
|
|
58
|
+
suppressHoverOnKey(e);
|
|
59
|
+
handleKeyDown(e);
|
|
60
|
+
}, [handleKeyDown, suppressHoverOnKey]);
|
|
61
|
+
const _ref2 = props,
|
|
62
|
+
onMouseLeave = _ref2.onMouseLeave,
|
|
63
|
+
wrapProps = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
64
|
+
const handleWrapMouseLeave = useCallback(e => {
|
|
65
|
+
releaseHover();
|
|
66
|
+
typeof onMouseLeave === "function" && onMouseLeave(e);
|
|
67
|
+
}, [onMouseLeave, releaseHover]);
|
|
68
|
+
if (wrap) {
|
|
69
|
+
const text = String(currentValue != null ? currentValue : "");
|
|
70
|
+
return /*#__PURE__*/React.createElement(StyledWrapRoot, _extends({
|
|
71
|
+
ref: ref || wrapRef
|
|
72
|
+
}, wrapProps, {
|
|
73
|
+
onMouseLeave: handleWrapMouseLeave
|
|
74
|
+
}), /*#__PURE__*/React.createElement(StyledWrapSpan, {
|
|
75
|
+
variant: variant,
|
|
76
|
+
forwardedAs: "span",
|
|
77
|
+
weight: weight,
|
|
78
|
+
$disabled: disabled,
|
|
79
|
+
className: "presentation",
|
|
80
|
+
"aria-hidden": disabled ? undefined : true
|
|
81
|
+
}, children ? children : (text || !disabled && (inputProps == null ? void 0 : inputProps.placeholder) || "") + " "), /*#__PURE__*/React.createElement(StyledWrapTextarea, _extends({}, inputProps, {
|
|
82
|
+
ref: intTextareaRef,
|
|
83
|
+
forwardedAs: "textarea",
|
|
84
|
+
variant: variant,
|
|
85
|
+
weight: weight,
|
|
86
|
+
rows: 1,
|
|
87
|
+
value: text,
|
|
88
|
+
onFocus: releaseHover,
|
|
89
|
+
onBlur: handleBlur,
|
|
90
|
+
onKeyDown: handleWrapKeyDown,
|
|
91
|
+
onChange: handleChange,
|
|
92
|
+
disabled: disabled,
|
|
93
|
+
invalid: invalid,
|
|
94
|
+
"data-form-type": "other",
|
|
95
|
+
"data-hover-suppressed": hoverSuppressed,
|
|
96
|
+
className: classNames("c-textarea", inputProps == null ? void 0 : inputProps.className)
|
|
97
|
+
})));
|
|
98
|
+
}
|
|
86
99
|
if (multiline) {
|
|
87
100
|
return /*#__PURE__*/React.createElement(StyledDiv, _extends({
|
|
88
101
|
ref: ref || wrapRef
|