@vibe/core 3.13.0-alpha-b02ef.0 → 3.13.0
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/mocked_classnames/src/components/EditableTypography/EditableTypography.js +1 -1
- package/dist/mocked_classnames/src/components/EditableTypography/EditableTypography.js.map +1 -1
- package/dist/mocked_classnames/src/components/EditableTypography/EditableTypography.module.scss.js +1 -1
- package/dist/mocked_classnames/src/components/Tooltip/Tooltip.module.scss.js +1 -1
- package/dist/src/components/EditableTypography/EditableTypography.js +1 -1
- package/dist/src/components/EditableTypography/EditableTypography.js.map +1 -1
- package/dist/src/components/EditableTypography/EditableTypography.module.scss.js +1 -1
- package/dist/src/components/Tooltip/Tooltip.module.scss.js +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as
|
|
1
|
+
import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as o,useRef as n,useState as a,useEffect as l}from"react";import i from"classnames";import u from"../../hooks/useMergeRef.js";import s from"./EditableTypography.module.scss.js";import{keyCodes as c}from"../../constants/keyCodes.js";import"../../constants/sizes.js";import{useKeyboardButtonPressedFunc as d}from"../../hooks/useKeyboardButtonPressedFunc.js";import p from"../../hooks/usePrevious/index.js";var f=o((function(o,f){var m=o.id,h=o.className,v=o["data-testid"],g=o.value,y=o.onChange,b=o.onClick,E=o.readOnly,w=void 0!==E&&E,C=o.ariaLabel,x=void 0===C?"":C,P=o.placeholder,k=o.clearable,j=o.typographyClassName,B=o.component,F=o.isEditMode,N=o.autoSelectTextOnEditMode,T=o.onEditModeChange,D=o.tooltipProps,K=o.type,M=o.weight,R=o.multiline,S=void 0!==R&&R,A=n(null),H=u(f,A),O=a(F||!1),W=e(O,2),_=W[0],q=W[1],z=a(g),I=e(z,2),L=I[0],G=I[1],J=a(0),Q=e(J,2),U=Q[0],V=Q[1],X=a(0),Y=e(X,2),Z=Y[0],$=Y[1],ee=n(0),te=n(0),re=p(g),oe=n(null),ne=n(null);function ae(e){w||_||(e.preventDefault(),le(!0))}function le(e){null==T||T(e),q(e)}function ie(){(le(!1),g!==L)&&(L||k&&P?(G(L),null==y||y(L)):G(g))}function ue(){ie()}function se(e){if(e.key===c.ENTER){if(S&&e.shiftKey)return;e.preventDefault(),e.stopPropagation(),ie()}e.key===c.ESCAPE&&(e.preventDefault(),e.stopPropagation(),le(!1),G(g))}function ce(e){G(e.target.value),S&&fe()}l((function(){_||g===re||g===L||G(g)}),[re,_,g,L]),l((function(){q(F)}),[F]);var de=d(ae);function pe(){var e,t;if(null===(t=null===(e=oe.current)||void 0===e?void 0:e.focus)||void 0===t||t.call(e),oe.current){var r=oe.current,o=r.value.length;r.setSelectionRange(o,o)}S&&function(){if(S&&oe.current){var e=oe.current;if(!e)return;var t=window.getComputedStyle(e),r=parseFloat(t.lineHeight)||16,o=parseFloat(t.paddingTop)||0,n=parseFloat(t.paddingBottom)||0,a=parseFloat(t.borderTopWidth)||0,l=parseFloat(t.borderBottomWidth)||0;te.current=r,ee.current=o+n+a+l,fe()}}()}function fe(){oe.current&&($("auto"),requestAnimationFrame((function(){var e=oe.current;e&&$(Math.max(e.scrollHeight+ee.current,te.current+ee.current))})))}return l((function(){var e,t;_&&(pe(),N&&(null===(t=null===(e=oe.current)||void 0===e?void 0:e.select)||void 0===t||t.call(e)))}),[N,_]),l((function(){if(ne.current){var e=ne.current.getBoundingClientRect();V(e.width)}}),[L,_]),r.createElement("div",{ref:H,id:m,"aria-label":x,"data-testid":v,className:i(s.editableTypography,h),role:_?null:"button",onClick:function(e){null==b||b(e),ae(e)},onKeyDown:de},_&&(S?r.createElement("textarea",{ref:oe,className:i(s.textarea,j),value:L,onChange:ce,onKeyDown:se,onBlur:ue,"aria-label":x,placeholder:P,style:{width:U,height:Z},role:"textbox",rows:1}):r.createElement("input",{ref:oe,className:i(s.input,j),value:L,onChange:ce,onKeyDown:se,onBlur:ue,"aria-label":x,placeholder:P,style:{width:U},role:"input"})),r.createElement(B,{ref:ne,"aria-hidden":_,className:i(s.typography,j,t(t(t(t({},s.hidden,_),s.disabled,w),s.placeholder,!L&&P),s.multiline,!_&&S)),tabIndex:0,tooltipProps:D,weight:M,type:K,ellipsis:!S},L||P))}));export{f as default};
|
|
2
2
|
//# sourceMappingURL=EditableTypography.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableTypography.js","sources":["../../../../../src/components/EditableTypography/EditableTypography.tsx"],"sourcesContent":["import React, { ElementType, forwardRef, useEffect, useRef, useState, useLayoutEffect } from \"react\";\nimport cx from \"classnames\";\nimport useMergeRef from \"../../hooks/useMergeRef\";\nimport VibeComponentProps from \"../../types/VibeComponentProps\";\nimport VibeComponent from \"../../types/VibeComponent\";\nimport styles from \"./EditableTypography.module.scss\";\nimport { keyCodes } from \"../../constants\";\nimport { useKeyboardButtonPressedFunc } from \"../../hooks/useKeyboardButtonPressedFunc\";\nimport { TooltipProps } from \"../Tooltip/Tooltip\";\nimport usePrevious from \"../../hooks/usePrevious\";\nimport { TextType, TextWeight } from \"../Text/Text.types\";\nimport { HeadingType, HeadingWeight } from \"../Heading/Heading.types\";\n\nexport interface EditableTypographyImplementationProps {\n /** Value of the text */\n value: string;\n /** Will be called whenever the current value changes to a non-empty value */\n onChange?: (value: string) => void;\n /** Will be called whenever the component gets clicked */\n onClick?: (event: React.KeyboardEvent | React.MouseEvent) => void;\n /** Disables editing mode - component will be just a typography element */\n readOnly?: boolean;\n /** Shown in edit mode when the text value is empty */\n placeholder?: string;\n /** ARIA Label */\n ariaLabel?: string;\n /** Controls the mode of the component (i.e. view/edit mode) */\n isEditMode?: boolean;\n /** If true, automatically select all text when entering edit mode */\n autoSelectTextOnEditMode?: boolean;\n /** Will be called when the mode of the component changes */\n onEditModeChange?: (isEditMode: boolean) => void;\n /** Override Tooltip props when needed */\n tooltipProps?: Partial<TooltipProps>;\n}\n\nexport interface EditableTypographyProps extends VibeComponentProps, EditableTypographyImplementationProps {\n /** A typography component that is being rendered in view mode */\n component: ElementType;\n /** Controls the style of the typography component in view mode */\n typographyClassName: string;\n /** Shows placeholder when empty, if provided */\n clearable?: boolean;\n /** Sets the Text/Heading type */\n type?: TextType | HeadingType;\n /** Sets the Text/Heading weight */\n weight?: TextWeight | HeadingWeight;\n /** Controls whether a textarea or a simple input would be rendered, allowing multi-lines */\n multiline?: boolean;\n}\n\nconst EditableTypography: VibeComponent<EditableTypographyProps, HTMLElement> = forwardRef(\n (\n {\n id,\n className,\n \"data-testid\": dataTestId,\n value,\n onChange,\n onClick,\n readOnly = false,\n ariaLabel = \"\",\n placeholder,\n clearable,\n typographyClassName,\n component: TypographyComponent,\n isEditMode,\n autoSelectTextOnEditMode,\n onEditModeChange,\n tooltipProps,\n type,\n weight,\n multiline = false\n }: EditableTypographyProps,\n ref\n ) => {\n const componentRef = useRef(null);\n const mergedRef = useMergeRef(ref, componentRef);\n\n const [isEditing, setIsEditing] = useState(isEditMode || false);\n const [inputValue, setInputValue] = useState(value);\n const textareaBorderBoxSizing = useRef(0);\n const textareaLineHeight = useRef(0);\n\n const prevValue = usePrevious(value);\n\n const inputRef = useRef(null);\n const typographyRef = useRef(null);\n\n useEffect(() => {\n if (!isEditing && value !== prevValue && value !== inputValue) {\n setInputValue(value);\n }\n }, [prevValue, isEditing, value, inputValue]);\n\n useEffect(() => {\n setIsEditing(isEditMode);\n }, [isEditMode]);\n\n function onTypographyClick(event: React.KeyboardEvent | React.MouseEvent) {\n onClick?.(event);\n toggleEditMode(event);\n }\n\n function toggleEditMode(event: React.KeyboardEvent | React.MouseEvent) {\n if (readOnly || isEditing) {\n return;\n }\n event.preventDefault();\n handleEditModeChange(true);\n }\n\n function handleEditModeChange(value: boolean) {\n onEditModeChange?.(value);\n setIsEditing(value);\n }\n\n function handleInputValueChange() {\n handleEditModeChange(false);\n\n if (value === inputValue) {\n return;\n }\n\n const shouldShowPlaceholderWhenEmpty = clearable && placeholder;\n if (!inputValue && !shouldShowPlaceholderWhenEmpty) {\n setInputValue(value);\n return;\n }\n setInputValue(inputValue);\n onChange?.(inputValue);\n }\n\n function handleBlur() {\n handleInputValueChange();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) {\n if (event.key === keyCodes.ENTER) {\n if (multiline && event.shiftKey) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n handleInputValueChange();\n }\n if (event.key === keyCodes.ESCAPE) {\n event.preventDefault();\n event.stopPropagation();\n handleEditModeChange(false);\n setInputValue(value);\n }\n }\n\n function handleChange(event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) {\n setInputValue(event.target.value);\n\n if (multiline) {\n resizeTextarea();\n }\n }\n\n const toggleKeyboardEditMode = useKeyboardButtonPressedFunc(toggleEditMode);\n\n function focus() {\n inputRef.current?.focus?.();\n\n if (inputRef.current) {\n const inputElement = inputRef.current as HTMLInputElement | HTMLTextAreaElement;\n const textLength = inputElement.value.length;\n inputElement.setSelectionRange(textLength, textLength);\n }\n\n if (multiline) {\n calculateTextareaHeightAttrs();\n }\n }\n\n /* Dynamically resizes the textarea to fit its content */\n function resizeTextarea() {\n if (inputRef.current) {\n // Temporarily set the height to \"auto\" to accurately measure the scroll height of the content inside the textarea.\n inputRef?.current?.style.setProperty(\"--input-height\", \"auto\");\n\n requestAnimationFrame(() => {\n const textarea = inputRef.current as HTMLTextAreaElement;\n\n if (!textarea) {\n return;\n }\n\n // Ensure we at least have 1 line\n const height = Math.max(\n textarea.scrollHeight + textareaBorderBoxSizing.current,\n textareaLineHeight.current + textareaBorderBoxSizing.current\n );\n inputRef?.current?.style.setProperty(\"--input-height\", `${height}px`);\n });\n }\n }\n\n function selectAllInputText() {\n inputRef.current?.select?.();\n }\n\n useEffect(() => {\n if (!isEditing) return;\n focus();\n if (autoSelectTextOnEditMode) {\n selectAllInputText();\n }\n }, [autoSelectTextOnEditMode, isEditing]);\n\n useLayoutEffect(() => {\n if (!typographyRef.current) {\n return;\n }\n\n const { width } = typographyRef.current.getBoundingClientRect();\n inputRef?.current?.style.setProperty(\"--input-width\", `${width}px`);\n }, [inputValue, isEditing]);\n\n /* Calculate the minimual textarea height, taking its applied styles (padding, border width) into consideration \n This is done only on focus, so that we don't need to get the computed style every time.\n */\n function calculateTextareaHeightAttrs() {\n if (multiline && inputRef.current) {\n const textarea = inputRef.current as HTMLTextAreaElement;\n\n if (!textarea) {\n return;\n }\n\n const computedStyle = window.getComputedStyle(textarea);\n\n // Calculate the appropriate height by taking into account the scrollable content inside the textarea,\n // as well as the styles applied to it, such as padding and border widths.\n const lineHeight = parseFloat(computedStyle.lineHeight) || 16;\n const paddingTop = parseFloat(computedStyle.paddingTop) || 0;\n const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;\n const borderTopWidth = parseFloat(computedStyle.borderTopWidth) || 0;\n const borderBottomWidth = parseFloat(computedStyle.borderBottomWidth) || 0;\n\n textareaLineHeight.current = lineHeight;\n textareaBorderBoxSizing.current = paddingTop + paddingBottom + borderTopWidth + borderBottomWidth;\n resizeTextarea();\n }\n }\n\n return (\n <div\n ref={mergedRef}\n id={id}\n aria-label={ariaLabel}\n data-testid={dataTestId}\n className={cx(styles.editableTypography, className)}\n role={isEditing ? null : \"button\"}\n onClick={onTypographyClick}\n onKeyDown={toggleKeyboardEditMode}\n >\n {isEditing &&\n (multiline ? (\n <textarea\n ref={inputRef}\n className={cx(styles.textarea, typographyClassName)}\n value={inputValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n aria-label={ariaLabel}\n placeholder={placeholder}\n // style={{ width: inputWidth, height: inputHeight }}\n role=\"textbox\"\n rows={1}\n />\n ) : (\n <input\n ref={inputRef}\n className={cx(styles.input, typographyClassName)}\n value={inputValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n aria-label={ariaLabel}\n placeholder={placeholder}\n role=\"input\"\n />\n ))}\n <TypographyComponent\n ref={typographyRef}\n aria-hidden={isEditing}\n className={cx(styles.typography, typographyClassName, {\n [styles.hidden]: isEditing,\n [styles.disabled]: readOnly,\n [styles.placeholder]: !inputValue && placeholder,\n [styles.multiline]: !isEditing && multiline\n })}\n tabIndex={0}\n tooltipProps={tooltipProps}\n weight={weight}\n type={type}\n ellipsis={!multiline}\n >\n {inputValue || placeholder}\n </TypographyComponent>\n </div>\n );\n }\n);\n\nexport default EditableTypography;\n"],"names":["EditableTypography","forwardRef","_ref","ref","id","className","dataTestId","value","onChange","onClick","_ref$readOnly","readOnly","_ref$ariaLabel","ariaLabel","placeholder","clearable","typographyClassName","TypographyComponent","component","isEditMode","autoSelectTextOnEditMode","onEditModeChange","tooltipProps","type","weight","_ref$multiline","multiline","componentRef","useRef","mergedRef","useMergeRef","_useState","useState","_useState2","_slicedToArray","isEditing","setIsEditing","_useState3","_useState4","inputValue","setInputValue","textareaBorderBoxSizing","textareaLineHeight","prevValue","usePrevious","inputRef","typographyRef","toggleEditMode","event","preventDefault","handleEditModeChange","handleInputValueChange","handleBlur","handleKeyDown","key","keyCodes","ENTER","shiftKey","stopPropagation","ESCAPE","handleChange","target","resizeTextarea","useEffect","toggleKeyboardEditMode","useKeyboardButtonPressedFunc","focus","_b","current","_a","inputElement","textLength","length","setSelectionRange","textarea","computedStyle","window","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","calculateTextareaHeightAttrs","style","setProperty","requestAnimationFrame","concat","Math","max","scrollHeight","select","useLayoutEffect","_typographyRef$curren","getBoundingClientRect","width","React","createElement","cx","styles","editableTypography","role","onKeyDown","onBlur","rows","input","typography","_defineProperty","hidden","disabled","tabIndex","ellipsis"],"mappings":"iiBAmDMA,IAAAA,EAA0EC,GAC9E,SAAAC,EAsBEC,GACE,IArBAC,EAAEF,EAAFE,GACAC,EAASH,EAATG,UACeC,EAAUJ,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AAY3F,EAAmB4F,EAAAA,EAAAA,EAAAA,KACjDR,EAAOS,OAAS1E,GAChBiE,EAAOU,SAAWnG,GAClByF,EAAOtF,aAAeyB,GAAczB,GACpCsF,EAAO1E,WAAaS,GAAaT,IAEpCqF,SAAU,EACVzF,aAAcA,EACdE,OAAQA,EACRD,KAAMA,EACNyF,UAAWtF,GAEVa,GAAczB,GAIvB"}
|
|
1
|
+
{"version":3,"file":"EditableTypography.js","sources":["../../../../../src/components/EditableTypography/EditableTypography.tsx"],"sourcesContent":["import React, { ElementType, forwardRef, useEffect, useRef, useState } from \"react\";\nimport cx from \"classnames\";\nimport useMergeRef from \"../../hooks/useMergeRef\";\nimport VibeComponentProps from \"../../types/VibeComponentProps\";\nimport VibeComponent from \"../../types/VibeComponent\";\nimport styles from \"./EditableTypography.module.scss\";\nimport { keyCodes } from \"../../constants\";\nimport { useKeyboardButtonPressedFunc } from \"../../hooks/useKeyboardButtonPressedFunc\";\nimport { TooltipProps } from \"../Tooltip/Tooltip\";\nimport usePrevious from \"../../hooks/usePrevious\";\nimport { TextType, TextWeight } from \"../Text/Text.types\";\nimport { HeadingType, HeadingWeight } from \"../Heading/Heading.types\";\n\nexport interface EditableTypographyImplementationProps {\n /** Value of the text */\n value: string;\n /** Will be called whenever the current value changes to a non-empty value */\n onChange?: (value: string) => void;\n /** Will be called whenever the component gets clicked */\n onClick?: (event: React.KeyboardEvent | React.MouseEvent) => void;\n /** Disables editing mode - component will be just a typography element */\n readOnly?: boolean;\n /** Shown in edit mode when the text value is empty */\n placeholder?: string;\n /** ARIA Label */\n ariaLabel?: string;\n /** Controls the mode of the component (i.e. view/edit mode) */\n isEditMode?: boolean;\n /** If true, automatically select all text when entering edit mode */\n autoSelectTextOnEditMode?: boolean;\n /** Will be called when the mode of the component changes */\n onEditModeChange?: (isEditMode: boolean) => void;\n /** Override Tooltip props when needed */\n tooltipProps?: Partial<TooltipProps>;\n}\n\nexport interface EditableTypographyProps extends VibeComponentProps, EditableTypographyImplementationProps {\n /** A typography component that is being rendered in view mode */\n component: ElementType;\n /** Controls the style of the typography component in view mode */\n typographyClassName: string;\n /** Shows placeholder when empty, if provided */\n clearable?: boolean;\n /** Sets the Text/Heading type */\n type?: TextType | HeadingType;\n /** Sets the Text/Heading weight */\n weight?: TextWeight | HeadingWeight;\n /** Controls whether a textarea or a simple input would be rendered, allowing multi-lines */\n multiline?: boolean;\n}\n\nconst EditableTypography: VibeComponent<EditableTypographyProps, HTMLElement> = forwardRef(\n (\n {\n id,\n className,\n \"data-testid\": dataTestId,\n value,\n onChange,\n onClick,\n readOnly = false,\n ariaLabel = \"\",\n placeholder,\n clearable,\n typographyClassName,\n component: TypographyComponent,\n isEditMode,\n autoSelectTextOnEditMode,\n onEditModeChange,\n tooltipProps,\n type,\n weight,\n multiline = false\n }: EditableTypographyProps,\n ref\n ) => {\n const componentRef = useRef(null);\n const mergedRef = useMergeRef(ref, componentRef);\n\n const [isEditing, setIsEditing] = useState(isEditMode || false);\n const [inputValue, setInputValue] = useState(value);\n const [inputWidth, setInputWidth] = useState(0);\n const [inputHeight, setInputHeight] = useState<number | string>(0);\n const textareaBorderBoxSizing = useRef(0);\n const textareaLineHeight = useRef(0);\n\n const prevValue = usePrevious(value);\n\n const inputRef = useRef(null);\n const typographyRef = useRef(null);\n\n useEffect(() => {\n if (!isEditing && value !== prevValue && value !== inputValue) {\n setInputValue(value);\n }\n }, [prevValue, isEditing, value, inputValue]);\n\n useEffect(() => {\n setIsEditing(isEditMode);\n }, [isEditMode]);\n\n function onTypographyClick(event: React.KeyboardEvent | React.MouseEvent) {\n onClick?.(event);\n toggleEditMode(event);\n }\n\n function toggleEditMode(event: React.KeyboardEvent | React.MouseEvent) {\n if (readOnly || isEditing) {\n return;\n }\n event.preventDefault();\n handleEditModeChange(true);\n }\n\n function handleEditModeChange(value: boolean) {\n onEditModeChange?.(value);\n setIsEditing(value);\n }\n\n function handleInputValueChange() {\n handleEditModeChange(false);\n\n if (value === inputValue) {\n return;\n }\n\n const shouldShowPlaceholderWhenEmpty = clearable && placeholder;\n if (!inputValue && !shouldShowPlaceholderWhenEmpty) {\n setInputValue(value);\n return;\n }\n setInputValue(inputValue);\n onChange?.(inputValue);\n }\n\n function handleBlur() {\n handleInputValueChange();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) {\n if (event.key === keyCodes.ENTER) {\n if (multiline && event.shiftKey) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n handleInputValueChange();\n }\n if (event.key === keyCodes.ESCAPE) {\n event.preventDefault();\n event.stopPropagation();\n handleEditModeChange(false);\n setInputValue(value);\n }\n }\n\n function handleChange(event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) {\n setInputValue(event.target.value);\n\n if (multiline) {\n resizeTextarea();\n }\n }\n\n const toggleKeyboardEditMode = useKeyboardButtonPressedFunc(toggleEditMode);\n\n function focus() {\n inputRef.current?.focus?.();\n\n if (inputRef.current) {\n const inputElement = inputRef.current as HTMLInputElement | HTMLTextAreaElement;\n const textLength = inputElement.value.length;\n inputElement.setSelectionRange(textLength, textLength);\n }\n\n if (multiline) {\n calculateTextareaHeightAttrs();\n }\n }\n\n /* Dynamically resizes the textarea to fit its content */\n function resizeTextarea() {\n if (inputRef.current) {\n // Temporarily set the height to \"auto\" to accurately measure the scroll height of the content inside the textarea.\n setInputHeight(\"auto\");\n\n requestAnimationFrame(() => {\n const textarea = inputRef.current as HTMLTextAreaElement;\n\n if (!textarea) {\n return;\n }\n\n // Ensure we at least have 1 line\n setInputHeight(\n Math.max(\n textarea.scrollHeight + textareaBorderBoxSizing.current,\n textareaLineHeight.current + textareaBorderBoxSizing.current\n )\n );\n });\n }\n }\n\n function selectAllInputText() {\n inputRef.current?.select?.();\n }\n\n useEffect(() => {\n if (!isEditing) return;\n focus();\n if (autoSelectTextOnEditMode) {\n selectAllInputText();\n }\n }, [autoSelectTextOnEditMode, isEditing]);\n\n useEffect(() => {\n if (!typographyRef.current) {\n return;\n }\n\n const { width } = typographyRef.current.getBoundingClientRect();\n setInputWidth(width);\n }, [inputValue, isEditing]);\n\n /* Calculate the minimual textarea height, taking its applied styles (padding, border width) into consideration \n This is done only on focus, so that we don't need to get the computed style every time.\n */\n function calculateTextareaHeightAttrs() {\n if (multiline && inputRef.current) {\n const textarea = inputRef.current as HTMLTextAreaElement;\n\n if (!textarea) {\n return;\n }\n\n const computedStyle = window.getComputedStyle(textarea);\n\n // Calculate the appropriate height by taking into account the scrollable content inside the textarea,\n // as well as the styles applied to it, such as padding and border widths.\n const lineHeight = parseFloat(computedStyle.lineHeight) || 16;\n const paddingTop = parseFloat(computedStyle.paddingTop) || 0;\n const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;\n const borderTopWidth = parseFloat(computedStyle.borderTopWidth) || 0;\n const borderBottomWidth = parseFloat(computedStyle.borderBottomWidth) || 0;\n\n textareaLineHeight.current = lineHeight;\n textareaBorderBoxSizing.current = paddingTop + paddingBottom + borderTopWidth + borderBottomWidth;\n resizeTextarea();\n }\n }\n\n return (\n <div\n ref={mergedRef}\n id={id}\n aria-label={ariaLabel}\n data-testid={dataTestId}\n className={cx(styles.editableTypography, className)}\n role={isEditing ? null : \"button\"}\n onClick={onTypographyClick}\n onKeyDown={toggleKeyboardEditMode}\n >\n {isEditing &&\n (multiline ? (\n <textarea\n ref={inputRef}\n className={cx(styles.textarea, typographyClassName)}\n value={inputValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n aria-label={ariaLabel}\n placeholder={placeholder}\n style={{ width: inputWidth, height: inputHeight }}\n role=\"textbox\"\n rows={1}\n />\n ) : (\n <input\n ref={inputRef}\n className={cx(styles.input, typographyClassName)}\n value={inputValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n aria-label={ariaLabel}\n placeholder={placeholder}\n style={{ width: inputWidth }}\n role=\"input\"\n />\n ))}\n <TypographyComponent\n ref={typographyRef}\n aria-hidden={isEditing}\n className={cx(styles.typography, typographyClassName, {\n [styles.hidden]: isEditing,\n [styles.disabled]: readOnly,\n [styles.placeholder]: !inputValue && placeholder,\n [styles.multiline]: !isEditing && multiline\n })}\n tabIndex={0}\n tooltipProps={tooltipProps}\n weight={weight}\n type={type}\n ellipsis={!multiline}\n >\n {inputValue || placeholder}\n </TypographyComponent>\n </div>\n );\n }\n);\n\nexport default EditableTypography;\n"],"names":["EditableTypography","forwardRef","_ref","ref","id","className","dataTestId","value","onChange","onClick","_ref$readOnly","readOnly","_ref$ariaLabel","ariaLabel","placeholder","clearable","typographyClassName","TypographyComponent","component","isEditMode","autoSelectTextOnEditMode","onEditModeChange","tooltipProps","type","weight","_ref$multiline","multiline","componentRef","useRef","mergedRef","useMergeRef","_useState","useState","_useState2","_slicedToArray","isEditing","setIsEditing","_useState3","_useState4","inputValue","setInputValue","_useState5","_useState6","inputWidth","setInputWidth","_useState7","_useState8","inputHeight","setInputHeight","textareaBorderBoxSizing","textareaLineHeight","prevValue","usePrevious","inputRef","typographyRef","toggleEditMode","event","preventDefault","handleEditModeChange","handleInputValueChange","handleBlur","handleKeyDown","key","keyCodes","ENTER","shiftKey","stopPropagation","ESCAPE","handleChange","target","resizeTextarea","useEffect","toggleKeyboardEditMode","useKeyboardButtonPressedFunc","focus","_b","current","_a","inputElement","textLength","length","setSelectionRange","textarea","computedStyle","window","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","calculateTextareaHeightAttrs","requestAnimationFrame","Math","max","scrollHeight","select","_typographyRef$curren","getBoundingClientRect","width","React","createElement","cx","styles","editableTypography","role","onKeyDown","onBlur","style","height","rows","input","typography","_defineProperty","hidden","disabled","tabIndex","ellipsis"],"mappings":"4gBAmDMA,IAAAA,EAA0EC,GAC9E,SAAAC,EAsBEC,GACE,IArBAC,EAAEF,EAAFE,GACAC,EAASH,EAATG,UACeC,EAAUJ,EAAzB,eACAK,EAAKL,EAALK,MACAC,EAAQN,EAARM,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,EAAAA,EAAAA,EAAAA,KACjDV,EAAOW,OAAShF,GAChBqE,EAAOY,SAAWzG,GAClB6F,EAAO1F,aAAeyB,GAAczB,GACpC0F,EAAO9E,WAAaS,GAAaT,IAEpC2F,SAAU,EACV/F,aAAcA,EACdE,OAAQA,EACRD,KAAMA,EACN+F,UAAW5F,GAEVa,GAAczB,GAIvB"}
|
package/dist/mocked_classnames/src/components/EditableTypography/EditableTypography.module.scss.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={editableTypography:"editableTypography",input:"input",textarea:"textarea",typography:"typography",disabled:"disabled",hidden:"hidden",placeholder:"placeholder",multiline:"multiline"};!function(e){const
|
|
1
|
+
var e={editableTypography:"editableTypography",input:"input",textarea:"textarea",typography:"typography",disabled:"disabled",hidden:"hidden",placeholder:"placeholder",multiline:"multiline"};!function(e){const a="s_id-ae5d3ede7a9c_3_12_3";if("undefined"!=typeof document){const n=document.head||document.getElementsByTagName("head")[0];if(n.querySelector("#"+a))return;const r=document.createElement("style");r.id=a,n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.appendChild(document.createTextNode(e))}else globalThis.injectedStyles&&(globalThis.injectedStyles[a]=e)}(".editableTypography {\n display: inline-flex;\n min-width: 0;\n max-width: 100%;\n margin-left: -6px;\n overflow: hidden;\n position: relative;\n}\n.editableTypography .input, .editableTypography .textarea {\n display: inline-block;\n max-width: 100%;\n min-width: 64px;\n padding: 0 var(--spacing-xs);\n outline: none;\n border: 1px solid var(--primary-color);\n border-radius: var(--border-radius-small);\n color: var(--primary-text-color);\n background-color: transparent;\n}\n.editableTypography .input:focus, .editableTypography .input:active, .editableTypography .textarea:focus, .editableTypography .textarea:active {\n outline: none;\n}\n.editableTypography .textarea {\n resize: none;\n}\n.editableTypography .typography {\n border: 1px solid transparent;\n padding: 0 var(--spacing-xs);\n border-radius: var(--border-radius-small);\n}\n.editableTypography .typography:hover:not(.disabled) {\n border-color: var(--ui-border-color);\n}\n.editableTypography .typography.hidden {\n position: absolute;\n opacity: 0;\n height: 0;\n visibility: hidden;\n white-space: pre;\n}\n.editableTypography .typography.placeholder {\n color: var(--secondary-text-color);\n}\n.editableTypography .typography.multiline {\n white-space: pre-wrap;\n}");export{e as default};
|
|
2
2
|
//# sourceMappingURL=EditableTypography.module.scss.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o={tooltip:"tooltip",image:"image",title:"title",content:"content",paddingSizeMd:"paddingSizeMd",tooltipWhiteLink:"tooltipWhiteLink",arrow:"arrow",dark:"dark",primary:"primary"};!function(o){const n="s_id-
|
|
1
|
+
var o={tooltip:"tooltip",image:"image",title:"title",content:"content",paddingSizeMd:"paddingSizeMd",tooltipWhiteLink:"tooltipWhiteLink",arrow:"arrow",dark:"dark",primary:"primary"};!function(o){const n="s_id-0ff838e09a5f_3_12_3";if("undefined"!=typeof document){const r=document.head||document.getElementsByTagName("head")[0];if(r.querySelector("#"+n))return;const t=document.createElement("style");t.id=n,r.firstChild?r.insertBefore(t,r.firstChild):r.appendChild(t),t.appendChild(document.createTextNode(o))}else globalThis.injectedStyles&&(globalThis.injectedStyles[n]=o)}(".tooltip {\n position: relative;\n display: inline-block;\n border-radius: var(--tooltip-border-radius, var(--border-radius-small));\n box-shadow: var(--box-shadow-medium);\n font: var(--font-text2-normal);\n max-width: var(--tooltip-max-width, 50vw);\n word-break: break-word;\n background-color: var(--inverted-color-background);\n color: var(--text-color-on-inverted);\n --tooltip-max-width: 240px;\n white-space: pre-wrap;\n}\n.tooltip .image {\n display: block;\n position: relative;\n border-top-right-radius: 2px;\n border-top-left-radius: 2px;\n padding: 2px 2px 0 2px;\n object-fit: cover;\n width: 100%;\n height: 100%;\n min-width: var(--tooltip-max-width);\n z-index: 1;\n}\n.tooltip .title {\n font: var(--font-text2-bold);\n}\n.tooltip .content {\n word-break: break-word;\n display: inline-block;\n padding: var(--tooltip-padding, var(--spacing-small) var(--spacing-medium));\n}\n.tooltip.paddingSizeMd {\n border-radius: var(--border-radius-medium);\n padding: var(--spacing-medium);\n font: var(--font-text2-normal);\n}\n.tooltip a.tooltipWhiteLink {\n color: #fff;\n}\n.arrow,\n.dark,\n.arrow.dark {\n background-color: var(--inverted-color-background);\n color: var(--text-color-on-inverted);\n}\n.primary,\n.arrow.primary {\n background-color: var(--primary-color);\n color: var(--text-color-on-primary);\n}");export{o as default};
|
|
2
2
|
//# sourceMappingURL=Tooltip.module.scss.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as
|
|
1
|
+
import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as o,useRef as n,useState as a,useEffect as l}from"react";import i from"classnames";import u from"../../hooks/useMergeRef.js";import s from"./EditableTypography.module.scss.js";import{keyCodes as c}from"../../constants/keyCodes.js";import"../../constants/sizes.js";import{useKeyboardButtonPressedFunc as d}from"../../hooks/useKeyboardButtonPressedFunc.js";import p from"../../hooks/usePrevious/index.js";var f=o((function(o,f){var m=o.id,h=o.className,v=o["data-testid"],g=o.value,y=o.onChange,b=o.onClick,E=o.readOnly,w=void 0!==E&&E,C=o.ariaLabel,x=void 0===C?"":C,P=o.placeholder,k=o.clearable,j=o.typographyClassName,B=o.component,F=o.isEditMode,N=o.autoSelectTextOnEditMode,T=o.onEditModeChange,D=o.tooltipProps,K=o.type,M=o.weight,R=o.multiline,S=void 0!==R&&R,A=n(null),H=u(f,A),O=a(F||!1),W=e(O,2),_=W[0],q=W[1],z=a(g),I=e(z,2),L=I[0],G=I[1],J=a(0),Q=e(J,2),U=Q[0],V=Q[1],X=a(0),Y=e(X,2),Z=Y[0],$=Y[1],ee=n(0),te=n(0),re=p(g),oe=n(null),ne=n(null);function ae(e){w||_||(e.preventDefault(),le(!0))}function le(e){null==T||T(e),q(e)}function ie(){(le(!1),g!==L)&&(L||k&&P?(G(L),null==y||y(L)):G(g))}function ue(){ie()}function se(e){if(e.key===c.ENTER){if(S&&e.shiftKey)return;e.preventDefault(),e.stopPropagation(),ie()}e.key===c.ESCAPE&&(e.preventDefault(),e.stopPropagation(),le(!1),G(g))}function ce(e){G(e.target.value),S&&fe()}l((function(){_||g===re||g===L||G(g)}),[re,_,g,L]),l((function(){q(F)}),[F]);var de=d(ae);function pe(){var e,t;if(null===(t=null===(e=oe.current)||void 0===e?void 0:e.focus)||void 0===t||t.call(e),oe.current){var r=oe.current,o=r.value.length;r.setSelectionRange(o,o)}S&&function(){if(S&&oe.current){var e=oe.current;if(!e)return;var t=window.getComputedStyle(e),r=parseFloat(t.lineHeight)||16,o=parseFloat(t.paddingTop)||0,n=parseFloat(t.paddingBottom)||0,a=parseFloat(t.borderTopWidth)||0,l=parseFloat(t.borderBottomWidth)||0;te.current=r,ee.current=o+n+a+l,fe()}}()}function fe(){oe.current&&($("auto"),requestAnimationFrame((function(){var e=oe.current;e&&$(Math.max(e.scrollHeight+ee.current,te.current+ee.current))})))}return l((function(){var e,t;_&&(pe(),N&&(null===(t=null===(e=oe.current)||void 0===e?void 0:e.select)||void 0===t||t.call(e)))}),[N,_]),l((function(){if(ne.current){var e=ne.current.getBoundingClientRect();V(e.width)}}),[L,_]),r.createElement("div",{ref:H,id:m,"aria-label":x,"data-testid":v,className:i(s.editableTypography,h),role:_?null:"button",onClick:function(e){null==b||b(e),ae(e)},onKeyDown:de},_&&(S?r.createElement("textarea",{ref:oe,className:i(s.textarea,j),value:L,onChange:ce,onKeyDown:se,onBlur:ue,"aria-label":x,placeholder:P,style:{width:U,height:Z},role:"textbox",rows:1}):r.createElement("input",{ref:oe,className:i(s.input,j),value:L,onChange:ce,onKeyDown:se,onBlur:ue,"aria-label":x,placeholder:P,style:{width:U},role:"input"})),r.createElement(B,{ref:ne,"aria-hidden":_,className:i(s.typography,j,t(t(t(t({},s.hidden,_),s.disabled,w),s.placeholder,!L&&P),s.multiline,!_&&S)),tabIndex:0,tooltipProps:D,weight:M,type:K,ellipsis:!S},L||P))}));export{f as default};
|
|
2
2
|
//# sourceMappingURL=EditableTypography.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableTypography.js","sources":["../../../../src/components/EditableTypography/EditableTypography.tsx"],"sourcesContent":["import React, { ElementType, forwardRef, useEffect, useRef, useState, useLayoutEffect } from \"react\";\nimport cx from \"classnames\";\nimport useMergeRef from \"../../hooks/useMergeRef\";\nimport VibeComponentProps from \"../../types/VibeComponentProps\";\nimport VibeComponent from \"../../types/VibeComponent\";\nimport styles from \"./EditableTypography.module.scss\";\nimport { keyCodes } from \"../../constants\";\nimport { useKeyboardButtonPressedFunc } from \"../../hooks/useKeyboardButtonPressedFunc\";\nimport { TooltipProps } from \"../Tooltip/Tooltip\";\nimport usePrevious from \"../../hooks/usePrevious\";\nimport { TextType, TextWeight } from \"../Text/Text.types\";\nimport { HeadingType, HeadingWeight } from \"../Heading/Heading.types\";\n\nexport interface EditableTypographyImplementationProps {\n /** Value of the text */\n value: string;\n /** Will be called whenever the current value changes to a non-empty value */\n onChange?: (value: string) => void;\n /** Will be called whenever the component gets clicked */\n onClick?: (event: React.KeyboardEvent | React.MouseEvent) => void;\n /** Disables editing mode - component will be just a typography element */\n readOnly?: boolean;\n /** Shown in edit mode when the text value is empty */\n placeholder?: string;\n /** ARIA Label */\n ariaLabel?: string;\n /** Controls the mode of the component (i.e. view/edit mode) */\n isEditMode?: boolean;\n /** If true, automatically select all text when entering edit mode */\n autoSelectTextOnEditMode?: boolean;\n /** Will be called when the mode of the component changes */\n onEditModeChange?: (isEditMode: boolean) => void;\n /** Override Tooltip props when needed */\n tooltipProps?: Partial<TooltipProps>;\n}\n\nexport interface EditableTypographyProps extends VibeComponentProps, EditableTypographyImplementationProps {\n /** A typography component that is being rendered in view mode */\n component: ElementType;\n /** Controls the style of the typography component in view mode */\n typographyClassName: string;\n /** Shows placeholder when empty, if provided */\n clearable?: boolean;\n /** Sets the Text/Heading type */\n type?: TextType | HeadingType;\n /** Sets the Text/Heading weight */\n weight?: TextWeight | HeadingWeight;\n /** Controls whether a textarea or a simple input would be rendered, allowing multi-lines */\n multiline?: boolean;\n}\n\nconst EditableTypography: VibeComponent<EditableTypographyProps, HTMLElement> = forwardRef(\n (\n {\n id,\n className,\n \"data-testid\": dataTestId,\n value,\n onChange,\n onClick,\n readOnly = false,\n ariaLabel = \"\",\n placeholder,\n clearable,\n typographyClassName,\n component: TypographyComponent,\n isEditMode,\n autoSelectTextOnEditMode,\n onEditModeChange,\n tooltipProps,\n type,\n weight,\n multiline = false\n }: EditableTypographyProps,\n ref\n ) => {\n const componentRef = useRef(null);\n const mergedRef = useMergeRef(ref, componentRef);\n\n const [isEditing, setIsEditing] = useState(isEditMode || false);\n const [inputValue, setInputValue] = useState(value);\n const textareaBorderBoxSizing = useRef(0);\n const textareaLineHeight = useRef(0);\n\n const prevValue = usePrevious(value);\n\n const inputRef = useRef(null);\n const typographyRef = useRef(null);\n\n useEffect(() => {\n if (!isEditing && value !== prevValue && value !== inputValue) {\n setInputValue(value);\n }\n }, [prevValue, isEditing, value, inputValue]);\n\n useEffect(() => {\n setIsEditing(isEditMode);\n }, [isEditMode]);\n\n function onTypographyClick(event: React.KeyboardEvent | React.MouseEvent) {\n onClick?.(event);\n toggleEditMode(event);\n }\n\n function toggleEditMode(event: React.KeyboardEvent | React.MouseEvent) {\n if (readOnly || isEditing) {\n return;\n }\n event.preventDefault();\n handleEditModeChange(true);\n }\n\n function handleEditModeChange(value: boolean) {\n onEditModeChange?.(value);\n setIsEditing(value);\n }\n\n function handleInputValueChange() {\n handleEditModeChange(false);\n\n if (value === inputValue) {\n return;\n }\n\n const shouldShowPlaceholderWhenEmpty = clearable && placeholder;\n if (!inputValue && !shouldShowPlaceholderWhenEmpty) {\n setInputValue(value);\n return;\n }\n setInputValue(inputValue);\n onChange?.(inputValue);\n }\n\n function handleBlur() {\n handleInputValueChange();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) {\n if (event.key === keyCodes.ENTER) {\n if (multiline && event.shiftKey) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n handleInputValueChange();\n }\n if (event.key === keyCodes.ESCAPE) {\n event.preventDefault();\n event.stopPropagation();\n handleEditModeChange(false);\n setInputValue(value);\n }\n }\n\n function handleChange(event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) {\n setInputValue(event.target.value);\n\n if (multiline) {\n resizeTextarea();\n }\n }\n\n const toggleKeyboardEditMode = useKeyboardButtonPressedFunc(toggleEditMode);\n\n function focus() {\n inputRef.current?.focus?.();\n\n if (inputRef.current) {\n const inputElement = inputRef.current as HTMLInputElement | HTMLTextAreaElement;\n const textLength = inputElement.value.length;\n inputElement.setSelectionRange(textLength, textLength);\n }\n\n if (multiline) {\n calculateTextareaHeightAttrs();\n }\n }\n\n /* Dynamically resizes the textarea to fit its content */\n function resizeTextarea() {\n if (inputRef.current) {\n // Temporarily set the height to \"auto\" to accurately measure the scroll height of the content inside the textarea.\n inputRef?.current?.style.setProperty(\"--input-height\", \"auto\");\n\n requestAnimationFrame(() => {\n const textarea = inputRef.current as HTMLTextAreaElement;\n\n if (!textarea) {\n return;\n }\n\n // Ensure we at least have 1 line\n const height = Math.max(\n textarea.scrollHeight + textareaBorderBoxSizing.current,\n textareaLineHeight.current + textareaBorderBoxSizing.current\n );\n inputRef?.current?.style.setProperty(\"--input-height\", `${height}px`);\n });\n }\n }\n\n function selectAllInputText() {\n inputRef.current?.select?.();\n }\n\n useEffect(() => {\n if (!isEditing) return;\n focus();\n if (autoSelectTextOnEditMode) {\n selectAllInputText();\n }\n }, [autoSelectTextOnEditMode, isEditing]);\n\n useLayoutEffect(() => {\n if (!typographyRef.current) {\n return;\n }\n\n const { width } = typographyRef.current.getBoundingClientRect();\n inputRef?.current?.style.setProperty(\"--input-width\", `${width}px`);\n }, [inputValue, isEditing]);\n\n /* Calculate the minimual textarea height, taking its applied styles (padding, border width) into consideration \n This is done only on focus, so that we don't need to get the computed style every time.\n */\n function calculateTextareaHeightAttrs() {\n if (multiline && inputRef.current) {\n const textarea = inputRef.current as HTMLTextAreaElement;\n\n if (!textarea) {\n return;\n }\n\n const computedStyle = window.getComputedStyle(textarea);\n\n // Calculate the appropriate height by taking into account the scrollable content inside the textarea,\n // as well as the styles applied to it, such as padding and border widths.\n const lineHeight = parseFloat(computedStyle.lineHeight) || 16;\n const paddingTop = parseFloat(computedStyle.paddingTop) || 0;\n const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;\n const borderTopWidth = parseFloat(computedStyle.borderTopWidth) || 0;\n const borderBottomWidth = parseFloat(computedStyle.borderBottomWidth) || 0;\n\n textareaLineHeight.current = lineHeight;\n textareaBorderBoxSizing.current = paddingTop + paddingBottom + borderTopWidth + borderBottomWidth;\n resizeTextarea();\n }\n }\n\n return (\n <div\n ref={mergedRef}\n id={id}\n aria-label={ariaLabel}\n data-testid={dataTestId}\n className={cx(styles.editableTypography, className)}\n role={isEditing ? null : \"button\"}\n onClick={onTypographyClick}\n onKeyDown={toggleKeyboardEditMode}\n >\n {isEditing &&\n (multiline ? (\n <textarea\n ref={inputRef}\n className={cx(styles.textarea, typographyClassName)}\n value={inputValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n aria-label={ariaLabel}\n placeholder={placeholder}\n // style={{ width: inputWidth, height: inputHeight }}\n role=\"textbox\"\n rows={1}\n />\n ) : (\n <input\n ref={inputRef}\n className={cx(styles.input, typographyClassName)}\n value={inputValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n aria-label={ariaLabel}\n placeholder={placeholder}\n role=\"input\"\n />\n ))}\n <TypographyComponent\n ref={typographyRef}\n aria-hidden={isEditing}\n className={cx(styles.typography, typographyClassName, {\n [styles.hidden]: isEditing,\n [styles.disabled]: readOnly,\n [styles.placeholder]: !inputValue && placeholder,\n [styles.multiline]: !isEditing && multiline\n })}\n tabIndex={0}\n tooltipProps={tooltipProps}\n weight={weight}\n type={type}\n ellipsis={!multiline}\n >\n {inputValue || placeholder}\n </TypographyComponent>\n </div>\n );\n }\n);\n\nexport default EditableTypography;\n"],"names":["EditableTypography","forwardRef","_ref","ref","id","className","dataTestId","value","onChange","onClick","_ref$readOnly","readOnly","_ref$ariaLabel","ariaLabel","placeholder","clearable","typographyClassName","TypographyComponent","component","isEditMode","autoSelectTextOnEditMode","onEditModeChange","tooltipProps","type","weight","_ref$multiline","multiline","componentRef","useRef","mergedRef","useMergeRef","_useState","useState","_useState2","_slicedToArray","isEditing","setIsEditing","_useState3","_useState4","inputValue","setInputValue","textareaBorderBoxSizing","textareaLineHeight","prevValue","usePrevious","inputRef","typographyRef","toggleEditMode","event","preventDefault","handleEditModeChange","handleInputValueChange","handleBlur","handleKeyDown","key","keyCodes","ENTER","shiftKey","stopPropagation","ESCAPE","handleChange","target","resizeTextarea","useEffect","toggleKeyboardEditMode","useKeyboardButtonPressedFunc","focus","_b","current","_a","inputElement","textLength","length","setSelectionRange","textarea","computedStyle","window","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","calculateTextareaHeightAttrs","style","setProperty","requestAnimationFrame","concat","Math","max","scrollHeight","select","useLayoutEffect","_typographyRef$curren","getBoundingClientRect","width","React","createElement","cx","styles","editableTypography","role","onKeyDown","onBlur","rows","input","typography","_defineProperty","hidden","disabled","tabIndex","ellipsis"],"mappings":"iiBAmDMA,IAAAA,EAA0EC,GAC9E,SAAAC,EAsBEC,GACE,IArBAC,EAAEF,EAAFE,GACAC,EAASH,EAATG,UACeC,EAAUJ,EAAzB,eACAK,EAAKL,EAALK,MACAC,EAAQN,EAARM,SACAC,EAAOP,EAAPO,QAAOC,EAAAR,EACPS,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAAV,EAChBW,UAAAA,OAAY,IAAHD,EAAG,GAAEA,EACdE,EAAWZ,EAAXY,YACAC,EAASb,EAATa,UACAC,EAAmBd,E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a,GAAczB,GAIvB"}
|
|
1
|
+
{"version":3,"file":"EditableTypography.js","sources":["../../../../src/components/EditableTypography/EditableTypography.tsx"],"sourcesContent":["import React, { ElementType, forwardRef, useEffect, useRef, useState } from \"react\";\nimport cx from \"classnames\";\nimport useMergeRef from \"../../hooks/useMergeRef\";\nimport VibeComponentProps from \"../../types/VibeComponentProps\";\nimport VibeComponent from \"../../types/VibeComponent\";\nimport styles from \"./EditableTypography.module.scss\";\nimport { keyCodes } from \"../../constants\";\nimport { useKeyboardButtonPressedFunc } from \"../../hooks/useKeyboardButtonPressedFunc\";\nimport { TooltipProps } from \"../Tooltip/Tooltip\";\nimport usePrevious from \"../../hooks/usePrevious\";\nimport { TextType, TextWeight } from \"../Text/Text.types\";\nimport { HeadingType, HeadingWeight } from \"../Heading/Heading.types\";\n\nexport interface EditableTypographyImplementationProps {\n /** Value of the text */\n value: string;\n /** Will be called whenever the current value changes to a non-empty value */\n onChange?: (value: string) => void;\n /** Will be called whenever the component gets clicked */\n onClick?: (event: React.KeyboardEvent | React.MouseEvent) => void;\n /** Disables editing mode - component will be just a typography element */\n readOnly?: boolean;\n /** Shown in edit mode when the text value is empty */\n placeholder?: string;\n /** ARIA Label */\n ariaLabel?: string;\n /** Controls the mode of the component (i.e. view/edit mode) */\n isEditMode?: boolean;\n /** If true, automatically select all text when entering edit mode */\n autoSelectTextOnEditMode?: boolean;\n /** Will be called when the mode of the component changes */\n onEditModeChange?: (isEditMode: boolean) => void;\n /** Override Tooltip props when needed */\n tooltipProps?: Partial<TooltipProps>;\n}\n\nexport interface EditableTypographyProps extends VibeComponentProps, EditableTypographyImplementationProps {\n /** A typography component that is being rendered in view mode */\n component: ElementType;\n /** Controls the style of the typography component in view mode */\n typographyClassName: string;\n /** Shows placeholder when empty, if provided */\n clearable?: boolean;\n /** Sets the Text/Heading type */\n type?: TextType | HeadingType;\n /** Sets the Text/Heading weight */\n weight?: TextWeight | HeadingWeight;\n /** Controls whether a textarea or a simple input would be rendered, allowing multi-lines */\n multiline?: boolean;\n}\n\nconst EditableTypography: VibeComponent<EditableTypographyProps, HTMLElement> = forwardRef(\n (\n {\n id,\n className,\n \"data-testid\": dataTestId,\n value,\n onChange,\n onClick,\n readOnly = false,\n ariaLabel = \"\",\n placeholder,\n clearable,\n typographyClassName,\n component: TypographyComponent,\n isEditMode,\n autoSelectTextOnEditMode,\n onEditModeChange,\n tooltipProps,\n type,\n weight,\n multiline = false\n }: EditableTypographyProps,\n ref\n ) => {\n const componentRef = useRef(null);\n const mergedRef = useMergeRef(ref, componentRef);\n\n const [isEditing, setIsEditing] = useState(isEditMode || false);\n const [inputValue, setInputValue] = useState(value);\n const [inputWidth, setInputWidth] = useState(0);\n const [inputHeight, setInputHeight] = useState<number | string>(0);\n const textareaBorderBoxSizing = useRef(0);\n const textareaLineHeight = useRef(0);\n\n const prevValue = usePrevious(value);\n\n const inputRef = useRef(null);\n const typographyRef = useRef(null);\n\n useEffect(() => {\n if (!isEditing && value !== prevValue && value !== inputValue) {\n setInputValue(value);\n }\n }, [prevValue, isEditing, value, inputValue]);\n\n useEffect(() => {\n setIsEditing(isEditMode);\n }, [isEditMode]);\n\n function onTypographyClick(event: React.KeyboardEvent | React.MouseEvent) {\n onClick?.(event);\n toggleEditMode(event);\n }\n\n function toggleEditMode(event: React.KeyboardEvent | React.MouseEvent) {\n if (readOnly || isEditing) {\n return;\n }\n event.preventDefault();\n handleEditModeChange(true);\n }\n\n function handleEditModeChange(value: boolean) {\n onEditModeChange?.(value);\n setIsEditing(value);\n }\n\n function handleInputValueChange() {\n handleEditModeChange(false);\n\n if (value === inputValue) {\n return;\n }\n\n const shouldShowPlaceholderWhenEmpty = clearable && placeholder;\n if (!inputValue && !shouldShowPlaceholderWhenEmpty) {\n setInputValue(value);\n return;\n }\n setInputValue(inputValue);\n onChange?.(inputValue);\n }\n\n function handleBlur() {\n handleInputValueChange();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) {\n if (event.key === keyCodes.ENTER) {\n if (multiline && event.shiftKey) {\n return;\n }\n\n event.preventDefault();\n event.stopPropagation();\n handleInputValueChange();\n }\n if (event.key === keyCodes.ESCAPE) {\n event.preventDefault();\n event.stopPropagation();\n handleEditModeChange(false);\n setInputValue(value);\n }\n }\n\n function handleChange(event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) {\n setInputValue(event.target.value);\n\n if (multiline) {\n resizeTextarea();\n }\n }\n\n const toggleKeyboardEditMode = useKeyboardButtonPressedFunc(toggleEditMode);\n\n function focus() {\n inputRef.current?.focus?.();\n\n if (inputRef.current) {\n const inputElement = inputRef.current as HTMLInputElement | HTMLTextAreaElement;\n const textLength = inputElement.value.length;\n inputElement.setSelectionRange(textLength, textLength);\n }\n\n if (multiline) {\n calculateTextareaHeightAttrs();\n }\n }\n\n /* Dynamically resizes the textarea to fit its content */\n function resizeTextarea() {\n if (inputRef.current) {\n // Temporarily set the height to \"auto\" to accurately measure the scroll height of the content inside the textarea.\n setInputHeight(\"auto\");\n\n requestAnimationFrame(() => {\n const textarea = inputRef.current as HTMLTextAreaElement;\n\n if (!textarea) {\n return;\n }\n\n // Ensure we at least have 1 line\n setInputHeight(\n Math.max(\n textarea.scrollHeight + textareaBorderBoxSizing.current,\n textareaLineHeight.current + textareaBorderBoxSizing.current\n )\n );\n });\n }\n }\n\n function selectAllInputText() {\n inputRef.current?.select?.();\n }\n\n useEffect(() => {\n if (!isEditing) return;\n focus();\n if (autoSelectTextOnEditMode) {\n selectAllInputText();\n }\n }, [autoSelectTextOnEditMode, isEditing]);\n\n useEffect(() => {\n if (!typographyRef.current) {\n return;\n }\n\n const { width } = typographyRef.current.getBoundingClientRect();\n setInputWidth(width);\n }, [inputValue, isEditing]);\n\n /* Calculate the minimual textarea height, taking its applied styles (padding, border width) into consideration \n This is done only on focus, so that we don't need to get the computed style every time.\n */\n function calculateTextareaHeightAttrs() {\n if (multiline && inputRef.current) {\n const textarea = inputRef.current as HTMLTextAreaElement;\n\n if (!textarea) {\n return;\n }\n\n const computedStyle = window.getComputedStyle(textarea);\n\n // Calculate the appropriate height by taking into account the scrollable content inside the textarea,\n // as well as the styles applied to it, such as padding and border widths.\n const lineHeight = parseFloat(computedStyle.lineHeight) || 16;\n const paddingTop = parseFloat(computedStyle.paddingTop) || 0;\n const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;\n const borderTopWidth = parseFloat(computedStyle.borderTopWidth) || 0;\n const borderBottomWidth = parseFloat(computedStyle.borderBottomWidth) || 0;\n\n textareaLineHeight.current = lineHeight;\n textareaBorderBoxSizing.current = paddingTop + paddingBottom + borderTopWidth + borderBottomWidth;\n resizeTextarea();\n }\n }\n\n return (\n <div\n ref={mergedRef}\n id={id}\n aria-label={ariaLabel}\n data-testid={dataTestId}\n className={cx(styles.editableTypography, className)}\n role={isEditing ? null : \"button\"}\n onClick={onTypographyClick}\n onKeyDown={toggleKeyboardEditMode}\n >\n {isEditing &&\n (multiline ? (\n <textarea\n ref={inputRef}\n className={cx(styles.textarea, typographyClassName)}\n value={inputValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n aria-label={ariaLabel}\n placeholder={placeholder}\n style={{ width: inputWidth, height: inputHeight }}\n role=\"textbox\"\n rows={1}\n />\n ) : (\n <input\n ref={inputRef}\n className={cx(styles.input, typographyClassName)}\n value={inputValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n aria-label={ariaLabel}\n placeholder={placeholder}\n style={{ width: inputWidth }}\n role=\"input\"\n />\n ))}\n <TypographyComponent\n ref={typographyRef}\n aria-hidden={isEditing}\n className={cx(styles.typography, typographyClassName, {\n [styles.hidden]: isEditing,\n [styles.disabled]: readOnly,\n [styles.placeholder]: !inputValue && placeholder,\n [styles.multiline]: !isEditing && multiline\n })}\n tabIndex={0}\n tooltipProps={tooltipProps}\n weight={weight}\n type={type}\n ellipsis={!multiline}\n >\n {inputValue || placeholder}\n </TypographyComponent>\n </div>\n );\n }\n);\n\nexport default EditableTypography;\n"],"names":["EditableTypography","forwardRef","_ref","ref","id","className","dataTestId","value","onChange","onClick","_ref$readOnly","readOnly","_ref$ariaLabel","ariaLabel","placeholder","clearable","typographyClassName","TypographyComponent","component","isEditMode","autoSelectTextOnEditMode","onEditModeChange","tooltipProps","type","weight","_ref$multiline","multiline","componentRef","useRef","mergedRef","useMergeRef","_useState","useState","_useState2","_slicedToArray","isEditing","setIsEditing","_useState3","_useState4","inputValue","setInputValue","_useState5","_useState6","inputWidth","setInputWidth","_useState7","_useState8","inputHeight","setInputHeight","textareaBorderBoxSizing","textareaLineHeight","prevValue","usePrevious","inputRef","typographyRef","toggleEditMode","event","preventDefault","handleEditModeChange","handleInputValueChange","handleBlur","handleKeyDown","key","keyCodes","ENTER","shiftKey","stopPropagation","ESCAPE","handleChange","target","resizeTextarea","useEffect","toggleKeyboardEditMode","useKeyboardButtonPressedFunc","focus","_b","current","_a","inputElement","textLength","length","setSelectionRange","textarea","computedStyle","window","getComputedStyle","lineHeight","parseFloat","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth","calculateTextareaHeightAttrs","requestAnimationFrame","Math","max","scrollHeight","select","_typographyRef$curren","getBoundingClientRect","width","React","createElement","cx","styles","editableTypography","role","onKeyDown","onBlur","style","height","rows","input","typography","_defineProperty","hidden","disabled","tabIndex","ellipsis"],"mappings":"4gBAmDMA,IAAAA,EAA0EC,GAC9E,SAAAC,EAsBEC,GACE,IArBAC,EAAEF,EAAFE,GACAC,EAASH,EAATG,UACeC,EAAUJ,EAAzB,eACAK,EAAKL,EAALK,MACAC,EAAQN,EAARM,SACAC,EAAOP,EAAPO,QAAOC,EAAAR,EACPS,SAAAA,OAAW,IAAHD,GAAQA,EAAAE,EAAAV,EAChBW,UAAAA,OAAY,IAAHD,EAAG,GAAEA,EACdE,EAAWZ,EAAXY,YACAC,EAASb,EAATa,UACAC,EAAmBd,EAAnBc,oBACWC,EAAmBf,EAA9BgB,UACAC,EAAUjB,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}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={editableTypography:"editableTypography_fd533ed4b4",input:"input_1319196700",textarea:"
|
|
1
|
+
var e={editableTypography:"editableTypography_fd533ed4b4",input:"input_1319196700",textarea:"textarea_830f6de23b",typography:"typography_057ee5fa59",disabled:"disabled_e1050254a9",hidden:"hidden_322339211d",placeholder:"placeholder_5b87804f19",multiline:"multiline_0cfdb1d3a0"};!function(e){const d="s_id-ae5d3ede7a9c_3_12_3";if("undefined"!=typeof document){const a=document.head||document.getElementsByTagName("head")[0];if(a.querySelector("#"+d))return;const n=document.createElement("style");n.id=d,a.firstChild?a.insertBefore(n,a.firstChild):a.appendChild(n),n.appendChild(document.createTextNode(e))}else globalThis.injectedStyles&&(globalThis.injectedStyles[d]=e)}(".editableTypography_fd533ed4b4 {\n display: inline-flex;\n min-width: 0;\n max-width: 100%;\n margin-left: -6px;\n overflow: hidden;\n position: relative;\n}\n.editableTypography_fd533ed4b4 .input_1319196700, .editableTypography_fd533ed4b4 .textarea_830f6de23b {\n display: inline-block;\n max-width: 100%;\n min-width: 64px;\n padding: 0 var(--spacing-xs);\n outline: none;\n border: 1px solid var(--primary-color);\n border-radius: var(--border-radius-small);\n color: var(--primary-text-color);\n background-color: transparent;\n}\n.editableTypography_fd533ed4b4 .input_1319196700:focus, .editableTypography_fd533ed4b4 .input_1319196700:active, .editableTypography_fd533ed4b4 .textarea_830f6de23b:focus, .editableTypography_fd533ed4b4 .textarea_830f6de23b:active {\n outline: none;\n}\n.editableTypography_fd533ed4b4 .textarea_830f6de23b {\n resize: none;\n}\n.editableTypography_fd533ed4b4 .typography_057ee5fa59 {\n border: 1px solid transparent;\n padding: 0 var(--spacing-xs);\n border-radius: var(--border-radius-small);\n}\n.editableTypography_fd533ed4b4 .typography_057ee5fa59:hover:not(.disabled_e1050254a9) {\n border-color: var(--ui-border-color);\n}\n.editableTypography_fd533ed4b4 .typography_057ee5fa59.hidden_322339211d {\n position: absolute;\n opacity: 0;\n height: 0;\n visibility: hidden;\n white-space: pre;\n}\n.editableTypography_fd533ed4b4 .typography_057ee5fa59.placeholder_5b87804f19 {\n color: var(--secondary-text-color);\n}\n.editableTypography_fd533ed4b4 .typography_057ee5fa59.multiline_0cfdb1d3a0 {\n white-space: pre-wrap;\n}");export{e as default};
|
|
2
2
|
//# sourceMappingURL=EditableTypography.module.scss.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var o={tooltip:"
|
|
1
|
+
var o={tooltip:"tooltip_4943b384c0",image:"image_2be809ac51",title:"title_f12c0dd7bd",content:"content_64250cd12d",paddingSizeMd:"paddingSizeMd_b3a6c9a822",tooltipWhiteLink:"tooltipWhiteLink_dc6899b92e",arrow:"arrow_81199f0418",dark:"dark_a07da74724",primary:"primary_ccfd9c16bb"};!function(o){const n="s_id-0ff838e09a5f_3_12_3";if("undefined"!=typeof document){const r=document.head||document.getElementsByTagName("head")[0];if(r.querySelector("#"+n))return;const t=document.createElement("style");t.id=n,r.firstChild?r.insertBefore(t,r.firstChild):r.appendChild(t),t.appendChild(document.createTextNode(o))}else globalThis.injectedStyles&&(globalThis.injectedStyles[n]=o)}(".tooltip_4943b384c0 {\n position: relative;\n display: inline-block;\n border-radius: var(--tooltip-border-radius, var(--border-radius-small));\n box-shadow: var(--box-shadow-medium);\n font: var(--font-text2-normal);\n max-width: var(--tooltip-max-width, 50vw);\n word-break: break-word;\n background-color: var(--inverted-color-background);\n color: var(--text-color-on-inverted);\n --tooltip-max-width: 240px;\n white-space: pre-wrap;\n}\n.tooltip_4943b384c0 .image_2be809ac51 {\n display: block;\n position: relative;\n border-top-right-radius: 2px;\n border-top-left-radius: 2px;\n padding: 2px 2px 0 2px;\n object-fit: cover;\n width: 100%;\n height: 100%;\n min-width: var(--tooltip-max-width);\n z-index: 1;\n}\n.tooltip_4943b384c0 .title_f12c0dd7bd {\n font: var(--font-text2-bold);\n}\n.tooltip_4943b384c0 .content_64250cd12d {\n word-break: break-word;\n display: inline-block;\n padding: var(--tooltip-padding, var(--spacing-small) var(--spacing-medium));\n}\n.tooltip_4943b384c0.paddingSizeMd_b3a6c9a822 {\n border-radius: var(--border-radius-medium);\n padding: var(--spacing-medium);\n font: var(--font-text2-normal);\n}\n.tooltip_4943b384c0 a.tooltipWhiteLink_dc6899b92e {\n color: #fff;\n}\n.arrow_81199f0418,\n.dark_a07da74724,\n.arrow_81199f0418.dark_a07da74724 {\n background-color: var(--inverted-color-background);\n color: var(--text-color-on-inverted);\n}\n.primary_ccfd9c16bb,\n.arrow_81199f0418.primary_ccfd9c16bb {\n background-color: var(--primary-color);\n color: var(--text-color-on-primary);\n}");export{o as default};
|
|
2
2
|
//# sourceMappingURL=Tooltip.module.scss.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibe/core",
|
|
3
|
-
"version": "3.13.0
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "Official monday.com UI resources for application development in React.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -268,5 +268,5 @@
|
|
|
268
268
|
"browserslist": [
|
|
269
269
|
"extends browserslist-config-monday"
|
|
270
270
|
],
|
|
271
|
-
"gitHead": "
|
|
271
|
+
"gitHead": "1bb3fbeb3ed8b398ea903efebfc2726fdbdf9a67"
|
|
272
272
|
}
|