@salutejs/plasma-new-hope 0.91.0-canary.1261.9609334871.0 → 0.91.0-canary.1263.9643629084.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/cjs/components/TextArea/TextArea.js +4 -6
  2. package/cjs/components/TextArea/TextArea.js.map +1 -1
  3. package/cjs/components/TextArea/hooks/useAutoResize.js +4 -10
  4. package/cjs/components/TextArea/hooks/useAutoResize.js.map +1 -1
  5. package/es/components/TextArea/TextArea.js +5 -7
  6. package/es/components/TextArea/TextArea.js.map +1 -1
  7. package/es/components/TextArea/hooks/useAutoResize.js +4 -10
  8. package/es/components/TextArea/hooks/useAutoResize.js.map +1 -1
  9. package/package.json +2 -2
  10. package/styled-components/cjs/components/TextArea/TextArea.js +4 -11
  11. package/styled-components/cjs/components/TextArea/TextArea.template-doc.mdx +6 -45
  12. package/styled-components/cjs/components/TextArea/hooks/useAutoResize.js +4 -10
  13. package/styled-components/cjs/types/TextareaHTMLAttributes.js +5 -0
  14. package/styled-components/es/components/TextArea/TextArea.js +4 -12
  15. package/styled-components/es/components/TextArea/TextArea.template-doc.mdx +6 -45
  16. package/styled-components/es/components/TextArea/hooks/useAutoResize.js +4 -10
  17. package/styled-components/es/types/TextareaHTMLAttributes.js +1 -0
  18. package/types/components/TextArea/TextArea.d.ts +2 -2
  19. package/types/components/TextArea/TextArea.d.ts.map +1 -1
  20. package/types/components/TextArea/TextArea.types.d.ts +24 -50
  21. package/types/components/TextArea/TextArea.types.d.ts.map +1 -1
  22. package/types/components/TextArea/hooks/useAutoResize.d.ts +1 -1
  23. package/types/components/TextArea/hooks/useAutoResize.d.ts.map +1 -1
  24. package/types/components/TextArea/index.d.ts +1 -0
  25. package/types/components/TextArea/index.d.ts.map +1 -1
  26. package/types/examples/plasma_b2c/components/TextArea/TextArea.d.ts +1 -31
  27. package/types/examples/plasma_b2c/components/TextArea/TextArea.d.ts.map +1 -1
  28. package/types/examples/plasma_web/components/TextArea/TextArea.d.ts +1 -31
  29. package/types/examples/plasma_web/components/TextArea/TextArea.d.ts.map +1 -1
  30. package/types/examples/sds_engineer/components/TextArea/TextArea.d.ts +1 -31
  31. package/types/examples/sds_engineer/components/TextArea/TextArea.d.ts.map +1 -1
  32. package/types/types/TextareaHTMLAttributes.d.ts +52 -0
  33. package/types/types/TextareaHTMLAttributes.d.ts.map +1 -0
  34. package/types/types/index.d.ts +1 -0
  35. package/types/types/index.d.ts.map +1 -1
@@ -127,17 +127,15 @@ var textAreaRoot = function textAreaRoot(Root) {
127
127
  }
128
128
  onChange === null || onChange === void 0 || onChange(event);
129
129
  }, [value, onChange]);
130
- var dynamicLabelClasses = getDynamicLabelClasses(_rollupPluginBabelHelpers.objectSpread2({
130
+ var dynamicLabelClasses = getDynamicLabelClasses({
131
131
  size: size,
132
132
  readOnly: readOnly,
133
133
  label: label,
134
134
  labelPlacement: labelPlacement,
135
+ autoResize: autoResize,
136
+ rows: rows,
135
137
  value: value || uncontrolledValue || defaultValue
136
- }, rows ? {
137
- rows: rows
138
- } : {
139
- autoResize: autoResize
140
- }), focused);
138
+ }, focused);
141
139
  return /*#__PURE__*/React.createElement(Root, {
142
140
  view: overriddenView,
143
141
  size: size,
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import React, { forwardRef, useState, createRef, useCallback } from 'react';\nimport { css } from '@linaria/core';\nimport { useResizeObserver } from '@salutejs/plasma-core';\n\nimport { cx } from '../../utils';\nimport type { RootProps } from '../../engines/types';\n\nimport { applyDynamicLabel } from './mixins';\nimport { useAutoResize, ROOT_FONT_SIZE } from './hooks';\nimport {\n StyledContent,\n StyledHelpers,\n StyledLeftHelper,\n StyledRightHelper,\n StyledLabel,\n StyledPlaceholder,\n StyledTextArea,\n StyledTextAreaWrapper,\n StyledContainer,\n} from './TextArea.styles';\nimport { classes } from './TextArea.tokens';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport type { TextAreaProps } from './TextArea.types';\n\nconst {\n innerPlaceholderUp,\n focusedOuterPlaceholderColor,\n hidePlaceHolder,\n styledContainer,\n styledTextArea,\n styledTextAreaWrapper,\n styledPlaceholder,\n styledHelpers,\n} = classes;\n\nconst base = css`\n ${applyDynamicLabel};\n\n position: relative;\n box-sizing: border-box;\n`;\n\n// TODO: Удалить после отказа от старых библиотек plasma-web / plasma-b2c\nconst fallbackStatusMap = {\n '': 'primary',\n success: 'positive',\n warning: 'warning',\n error: 'negative',\n};\n\n// TODO: Перенести этот метод в файл applyDynamicLabel.ts\nexport const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) => {\n const { readOnly, label, labelPlacement, autoResize, rows, value, size } = props;\n\n // Добавить класс отвечающий за изменение цвета плейсхолдера при фокусе\n const withFocusedOuterUpPlaceholder =\n !readOnly && focused && (!label || labelPlacement === 'outer') ? focusedOuterPlaceholderColor : undefined;\n\n // Добавить класс отвечающий за поднятие и уменьшение плейсхолдера\n const withInnerPlaceholderUp =\n labelPlacement === 'inner' &&\n label &&\n !autoResize &&\n !rows &&\n size !== 'xs' &&\n ((!readOnly && (value || focused)) || (readOnly && value))\n ? innerPlaceholderUp\n : undefined;\n\n // Добавить класс отвечающий за скрытие плейсхолдера\n const withHidePlaceholder =\n (value && !label) ||\n (labelPlacement === 'inner' && ((focused && !readOnly) || value) && label && (rows || autoResize)) ||\n (labelPlacement === 'outer' && value) ||\n (labelPlacement === 'inner' && size === 'xs' && value)\n ? hidePlaceHolder\n : undefined;\n\n return [withFocusedOuterUpPlaceholder, withInnerPlaceholderUp, withHidePlaceholder];\n};\n\nexport const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) =>\n forwardRef<HTMLTextAreaElement, TextAreaProps>((props, innerRef) => {\n const {\n helperText,\n status,\n resize,\n rightHelper,\n leftHelper,\n contentRight,\n autoResize = false,\n minAuto = 0,\n maxAuto,\n label,\n labelPlacement = 'inner',\n placeholder,\n defaultValue,\n height,\n width,\n value,\n disabled,\n size,\n view,\n id,\n style,\n className,\n readOnly,\n rows,\n cols,\n onChange,\n ...rest\n } = props;\n\n const [helperWidth, setHelperWidth] = useState<string>(width ? `${width}rem` : '100%');\n const [focused, setFocused] = useState(false);\n const [uncontrolledValue, setUncontrolledValue] = useState<string | undefined>();\n\n const outerRef = innerRef && 'current' in innerRef ? innerRef : createRef<HTMLTextAreaElement>();\n const hasHelper = Boolean(leftHelper || rightHelper || helperText);\n const overriddenView = status !== undefined ? fallbackStatusMap[status] : view;\n const textareaHelperId = id ? `${id}-helper` : undefined;\n const applyCustomWidth = resize !== 'horizontal' && resize !== 'both' && !cols;\n const placeLabel = labelPlacement === 'inner' && label && size !== 'xs' ? label : placeholder;\n\n useResizeObserver(outerRef, (currentElement) => {\n const { width: inlineWidth, height: inlineHeight } = currentElement.style;\n\n if (inlineWidth || inlineHeight || cols) {\n const { width: elementWidth } = currentElement.getBoundingClientRect();\n setHelperWidth(`${elementWidth / ROOT_FONT_SIZE}rem`);\n }\n });\n\n useAutoResize(autoResize, outerRef, value, minAuto, maxAuto);\n\n const onFocusHandler = useCallback(() => {\n setFocused(true);\n }, []);\n const onBlurHandler = useCallback(() => {\n setFocused(false);\n }, []);\n\n const onChangeHandler = useCallback(\n (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n // INFO: Для крайне редких кейсов, когда value снаружи не контролируется\n if (value === undefined) {\n setUncontrolledValue(event?.target.value);\n }\n\n onChange?.(event);\n },\n [value, onChange],\n );\n\n const dynamicLabelClasses = getDynamicLabelClasses(\n {\n size,\n readOnly,\n label,\n labelPlacement,\n value: value || uncontrolledValue || defaultValue,\n ...(rows ? { rows } : { autoResize }),\n },\n focused,\n );\n\n return (\n <Root\n view={overriddenView}\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n style={style}\n className={className}\n >\n {label && labelPlacement === 'outer' && <StyledLabel>{label}</StyledLabel>}\n <StyledContainer\n className={cx(styledContainer, ...dynamicLabelClasses)}\n width={helperWidth}\n onFocus={onFocusHandler}\n onBlur={onBlurHandler}\n >\n {contentRight && <StyledContent>{contentRight}</StyledContent>}\n <StyledTextAreaWrapper className={styledTextAreaWrapper} hasHelper={hasHelper}>\n <StyledTextArea\n className={styledTextArea}\n id={id}\n hasContentRight={Boolean(contentRight)}\n hasHelper={hasHelper}\n applyCustomWidth={applyCustomWidth}\n ref={outerRef}\n disabled={disabled}\n height={autoResize ? minAuto : height}\n width={width}\n placeholder={placeLabel}\n aria-describedby={textareaHelperId}\n value={value}\n readOnly={readOnly}\n rows={rows}\n cols={cols}\n resize={resize}\n defaultValue={defaultValue}\n onChange={onChangeHandler}\n {...rest}\n />\n </StyledTextAreaWrapper>\n {hasHelper && (\n <StyledHelpers className={styledHelpers} id={textareaHelperId}>\n {(leftHelper || helperText) && (\n <StyledLeftHelper>{leftHelper || helperText}</StyledLeftHelper>\n )}\n {rightHelper && <StyledRightHelper>{rightHelper}</StyledRightHelper>}\n </StyledHelpers>\n )}\n {placeLabel && (\n <StyledPlaceholder\n hasContentRight={Boolean(contentRight)}\n className={styledPlaceholder}\n htmlFor={id}\n >\n {placeLabel}\n </StyledPlaceholder>\n )}\n </StyledContainer>\n </Root>\n );\n });\n\nexport const textAreaConfig = {\n name: 'TextArea',\n tag: 'div',\n layout: textAreaRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n readOnly: {\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'primary',\n },\n};\n"],"names":["innerPlaceholderUp","classes","focusedOuterPlaceholderColor","hidePlaceHolder","styledContainer","styledTextArea","styledTextAreaWrapper","styledPlaceholder","styledHelpers","base","fallbackStatusMap","success","warning","error","getDynamicLabelClasses","props","focused","readOnly","label","labelPlacement","autoResize","rows","value","size","withFocusedOuterUpPlaceholder","undefined","withInnerPlaceholderUp","withHidePlaceholder","textAreaRoot","Root","forwardRef","innerRef","helperText","status","resize","rightHelper","leftHelper","contentRight","_props$autoResize","_props$minAuto","minAuto","maxAuto","_props$labelPlacement","placeholder","defaultValue","height","width","disabled","view","id","style","className","cols","onChange","rest","_excluded","_useState","useState","concat","_useState2","_slicedToArray","helperWidth","setHelperWidth","_useState3","_useState4","setFocused","_useState5","_useState6","uncontrolledValue","setUncontrolledValue","outerRef","createRef","hasHelper","Boolean","overriddenView","textareaHelperId","applyCustomWidth","placeLabel","useResizeObserver","currentElement","_currentElement$style","inlineWidth","inlineHeight","_currentElement$getBo","getBoundingClientRect","elementWidth","ROOT_FONT_SIZE","useAutoResize","onFocusHandler","useCallback","onBlurHandler","onChangeHandler","event","target","dynamicLabelClasses","_objectSpread","React","createElement","StyledLabel","StyledContainer","cx","apply","_toConsumableArray","onFocus","onBlur","StyledContent","StyledTextAreaWrapper","StyledTextArea","_extends","hasContentRight","ref","StyledHelpers","StyledLeftHelper","StyledRightHelper","StyledPlaceholder","htmlFor","textAreaConfig","name","tag","layout","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;;;;;AA0BA,IACIA,kBAAkB,GAQlBC,uBAAO,CARPD,kBAAkB;EAClBE,4BAA4B,GAO5BD,uBAAO,CAPPC,4BAA4B;EAC5BC,eAAe,GAMfF,uBAAO,CANPE,eAAe;EACfC,eAAe,GAKfH,uBAAO,CALPG,eAAe;EACfC,cAAc,GAIdJ,uBAAO,CAJPI,cAAc;EACdC,qBAAqB,GAGrBL,uBAAO,CAHPK,qBAAqB;EACrBC,iBAAiB,GAEjBN,uBAAO,CAFPM,iBAAiB;EACjBC,aAAAA,GACAP,uBAAO,CADPO,aAAAA,CAAAA;AAGJ,IAAMC,IAAI,GAKT,SAAA,CAAA;;AAED;AACA,IAAMC,iBAAiB,GAAG;AACtB,EAAA,EAAE,EAAE,SAAS;AACbC,EAAAA,OAAO,EAAE,UAAU;AACnBC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,KAAK,EAAE,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AA;KACV;AACD5G,IAAAA,QAAQ,EAAE;AACN4G,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNvG,IAAAA,IAAI,EAAE,GAAG;AACTyB,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;;;"}
1
+ {"version":3,"file":"TextArea.js","sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import React, { forwardRef, useState, createRef, useCallback } from 'react';\nimport { css } from '@linaria/core';\nimport { useResizeObserver } from '@salutejs/plasma-core';\n\nimport { cx } from '../../utils';\nimport type { RootProps } from '../../engines/types';\n\nimport { applyDynamicLabel } from './mixins';\nimport { useAutoResize, ROOT_FONT_SIZE } from './hooks';\nimport {\n StyledContent,\n StyledHelpers,\n StyledLeftHelper,\n StyledRightHelper,\n StyledLabel,\n StyledPlaceholder,\n StyledTextArea,\n StyledTextAreaWrapper,\n StyledContainer,\n} from './TextArea.styles';\nimport { classes } from './TextArea.tokens';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport type { TextAreaProps } from './TextArea.types';\n\nconst {\n innerPlaceholderUp,\n focusedOuterPlaceholderColor,\n hidePlaceHolder,\n styledContainer,\n styledTextArea,\n styledTextAreaWrapper,\n styledPlaceholder,\n styledHelpers,\n} = classes;\n\nconst base = css`\n ${applyDynamicLabel};\n\n position: relative;\n box-sizing: border-box;\n`;\n\n// TODO: Удалить после отказа от старых библиотек plasma-web / plasma-b2c\nconst fallbackStatusMap = {\n '': 'primary',\n success: 'positive',\n warning: 'warning',\n error: 'negative',\n};\n\n// TODO: Перенести этот метод в файл applyDynamicLabel.ts\nexport const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) => {\n const { readOnly, label, labelPlacement, autoResize, rows, value, size } = props;\n\n // Добавить класс отвечающий за изменение цвета плейсхолдера при фокусе\n const withFocusedOuterUpPlaceholder =\n !readOnly && focused && (!label || labelPlacement === 'outer') ? focusedOuterPlaceholderColor : undefined;\n\n // Добавить класс отвечающий за поднятие и уменьшение плейсхолдера\n const withInnerPlaceholderUp =\n labelPlacement === 'inner' &&\n label &&\n !autoResize &&\n !rows &&\n size !== 'xs' &&\n ((!readOnly && (value || focused)) || (readOnly && value))\n ? innerPlaceholderUp\n : undefined;\n\n // Добавить класс отвечающий за скрытие плейсхолдера\n const withHidePlaceholder =\n (value && !label) ||\n (labelPlacement === 'inner' && ((focused && !readOnly) || value) && label && (rows || autoResize)) ||\n (labelPlacement === 'outer' && value) ||\n (labelPlacement === 'inner' && size === 'xs' && value)\n ? hidePlaceHolder\n : undefined;\n\n return [withFocusedOuterUpPlaceholder, withInnerPlaceholderUp, withHidePlaceholder];\n};\n\nexport const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) =>\n forwardRef<HTMLTextAreaElement, TextAreaProps>((props, innerRef) => {\n const {\n helperText,\n status,\n resize,\n rightHelper,\n leftHelper,\n contentRight,\n autoResize = false,\n minAuto = 0,\n maxAuto,\n label,\n labelPlacement = 'inner',\n placeholder,\n defaultValue,\n height,\n width,\n value,\n disabled,\n size,\n view,\n id,\n style,\n className,\n readOnly,\n rows,\n cols,\n onChange,\n ...rest\n } = props;\n\n const [helperWidth, setHelperWidth] = useState<string>(width ? `${width}rem` : '100%');\n const [focused, setFocused] = useState(false);\n const [uncontrolledValue, setUncontrolledValue] = useState<string | undefined>();\n\n const outerRef = innerRef && 'current' in innerRef ? innerRef : createRef<HTMLTextAreaElement>();\n const hasHelper = Boolean(leftHelper || rightHelper || helperText);\n const overriddenView = status !== undefined ? fallbackStatusMap[status] : view;\n const textareaHelperId = id ? `${id}-helper` : undefined;\n const applyCustomWidth = resize !== 'horizontal' && resize !== 'both' && !cols;\n const placeLabel = labelPlacement === 'inner' && label && size !== 'xs' ? label : placeholder;\n\n useResizeObserver(outerRef, (currentElement) => {\n const { width: inlineWidth, height: inlineHeight } = currentElement.style;\n\n if (inlineWidth || inlineHeight || cols) {\n const { width: elementWidth } = currentElement.getBoundingClientRect();\n setHelperWidth(`${elementWidth / ROOT_FONT_SIZE}rem`);\n }\n });\n\n useAutoResize(autoResize, outerRef, value, minAuto, maxAuto);\n\n const onFocusHandler = useCallback(() => {\n setFocused(true);\n }, []);\n const onBlurHandler = useCallback(() => {\n setFocused(false);\n }, []);\n\n const onChangeHandler = useCallback(\n (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n // INFO: Для крайне редких кейсов, когда value снаружи не контролируется\n if (value === undefined) {\n setUncontrolledValue(event?.target.value);\n }\n\n onChange?.(event);\n },\n [value, onChange],\n );\n\n const dynamicLabelClasses = getDynamicLabelClasses(\n {\n size,\n readOnly,\n label,\n labelPlacement,\n autoResize,\n rows,\n value: value || uncontrolledValue || defaultValue,\n },\n focused,\n );\n\n return (\n <Root\n view={overriddenView}\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n style={style}\n className={className}\n >\n {label && labelPlacement === 'outer' && <StyledLabel>{label}</StyledLabel>}\n <StyledContainer\n className={cx(styledContainer, ...dynamicLabelClasses)}\n width={helperWidth}\n onFocus={onFocusHandler}\n onBlur={onBlurHandler}\n >\n {contentRight && <StyledContent>{contentRight}</StyledContent>}\n <StyledTextAreaWrapper className={styledTextAreaWrapper} hasHelper={hasHelper}>\n <StyledTextArea\n className={styledTextArea}\n id={id}\n hasContentRight={Boolean(contentRight)}\n hasHelper={hasHelper}\n applyCustomWidth={applyCustomWidth}\n ref={outerRef}\n disabled={disabled}\n height={autoResize ? minAuto : height}\n width={width}\n placeholder={placeLabel}\n aria-describedby={textareaHelperId}\n value={value}\n readOnly={readOnly}\n rows={rows}\n cols={cols}\n resize={resize}\n defaultValue={defaultValue}\n onChange={onChangeHandler}\n {...rest}\n />\n </StyledTextAreaWrapper>\n {hasHelper && (\n <StyledHelpers className={styledHelpers} id={textareaHelperId}>\n {(leftHelper || helperText) && (\n <StyledLeftHelper>{leftHelper || helperText}</StyledLeftHelper>\n )}\n {rightHelper && <StyledRightHelper>{rightHelper}</StyledRightHelper>}\n </StyledHelpers>\n )}\n {placeLabel && (\n <StyledPlaceholder\n hasContentRight={Boolean(contentRight)}\n className={styledPlaceholder}\n htmlFor={id}\n >\n {placeLabel}\n </StyledPlaceholder>\n )}\n </StyledContainer>\n </Root>\n );\n });\n\nexport const textAreaConfig = {\n name: 'TextArea',\n tag: 'div',\n layout: textAreaRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n readOnly: {\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'primary',\n },\n};\n"],"names":["innerPlaceholderUp","classes","focusedOuterPlaceholderColor","hidePlaceHolder","styledContainer","styledTextArea","styledTextAreaWrapper","styledPlaceholder","styledHelpers","base","fallbackStatusMap","success","warning","error","getDynamicLabelClasses","props","focused","readOnly","label","labelPlacement","autoResize","rows","value","size","withFocusedOuterUpPlaceholder","undefined","withInnerPlaceholderUp","withHidePlaceholder","textAreaRoot","Root","forwardRef","innerRef","helperText","status","resize","rightHelper","leftHelper","contentRight","_props$autoResize","_props$minAuto","minAuto","maxAuto","_props$labelPlacement","placeholder","defaultValue","height","width","disabled","view","id","style","className","cols","onChange","rest","_excluded","_useState","useState","concat","_useState2","_slicedToArray","helperWidth","setHelperWidth","_useState3","_useState4","setFocused","_useState5","_useState6","uncontrolledValue","setUncontrolledValue","outerRef","createRef","hasHelper","Boolean","overriddenView","textareaHelperId","applyCustomWidth","placeLabel","useResizeObserver","currentElement","_currentElement$style","inlineWidth","inlineHeight","_currentElement$getBo","getBoundingClientRect","elementWidth","ROOT_FONT_SIZE","useAutoResize","onFocusHandler","useCallback","onBlurHandler","onChangeHandler","event","target","dynamicLabelClasses","React","createElement","StyledLabel","StyledContainer","cx","apply","_toConsumableArray","onFocus","onBlur","StyledContent","StyledTextAreaWrapper","StyledTextArea","_extends","hasContentRight","ref","StyledHelpers","StyledLeftHelper","StyledRightHelper","StyledPlaceholder","htmlFor","textAreaConfig","name","tag","layout","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;;;;;AA0BA,IACIA,kBAAkB,GAQlBC,uBAAO,CARPD,kBAAkB;EAClBE,4BAA4B,GAO5BD,uBAAO,CAPPC,4BAA4B;EAC5BC,eAAe,GAMfF,uBAAO,CANPE,eAAe;EACfC,eAAe,GAKfH,uBAAO,CALPG,eAAe;EACfC,cAAc,GAIdJ,uBAAO,CAJPI,cAAc;EACdC,qBAAqB,GAGrBL,uBAAO,CAHPK,qBAAqB;EACrBC,iBAAiB,GAEjBN,uBAAO,CAFPM,iBAAiB;EACjBC,aAAAA,GACAP,uBAAO,CADPO,aAAAA,CAAAA;AAGJ,IAAMC,IAAI,GAKT,SAAA,CAAA;;AAED;AACA,IAAMC,iBAAiB,GAAG;AACtB,EAAA,EAAE,EAAE,SAAS;AACbC,EAAAA,OAAO,EAAE,UAAU;AACnBC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,KAAK,EAAE,UAAA;AACX,CAAC,CAAA;;AAED;AACO,IAAMC,sBAAsB,GAAGA,SAAzBA,sBAAsBA,CAAIC,KAAoB,EAAEC,OAAgB,EAAK;AAC9E,EAAA,IAAQC,QAAQ,GAA2DF,KAAK,CAAxEE,QAAQ;IAAEC,KAAK,GAAoDH,KAAK,CAA9DG,KAAK;IAAEC,cAAc,GAAoCJ,KAAK,CAAvDI,cAAc;IAAEC,UAAU,GAAwBL,KAAK,CAAvCK,UAAU;IAAEC,IAAI,GAAkBN,KAAK,CAA3BM,IAAI;IAAEC,KAAK,GAAWP,KAAK,CAArBO,KAAK;IAAEC,IAAAA,GAASR,KAAK,CAAdQ,IAAAA,CAAAA;;AAElE;AACA,EAAA,IAAMC,6BAA6B,GAC/B,CAACP,QAAQ,IAAID,OAAO,KAAK,CAACE,KAAK,IAAIC,cAAc,KAAK,OAAO,CAAC,GAAGjB,4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C,OAAO,CAACpC,YAAY,CAAE;AACvCc,MAAAA,SAAS,EAAE5C,iBAAkB;AAC7B2G,MAAAA,OAAO,EAAEjE,EAAAA;KAER4B,EAAAA,UACc,CAEV,CACf,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMsC,cAAc,GAAG;AAC1BC,EAAAA,IAAI,EAAE,UAAU;AAChBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE1F,YAAY;AACpBnB,EAAAA,IAAI,EAAJA,IAAI;AACJ8G,EAAAA,UAAU,EAAE;AACRhG,IAAAA,IAAI,EAAE;AACFiG,MAAAA,GAAG,EAAEC,WAAAA;KACR;AACDzE,IAAAA,IAAI,EAAE;AACFwE,MAAAA,GAAG,EAAEE,WAAAA;KACR;AACD3E,IAAAA,QAAQ,EAAE;AACNyE,MAAAA,GAAG,EAAEG,WAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACD3G,IAAAA,QAAQ,EAAE;AACN2G,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNtG,IAAAA,IAAI,EAAE,GAAG;AACTyB,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;;;"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var React = require('react');
6
6
 
7
7
  var ROOT_FONT_SIZE = 16;
8
- var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto) {
8
+ var useAutoResize = function useAutoResize(active, ref, value, minHeight, maxHeight) {
9
9
  var isManualResize = React.useRef(false);
10
10
  var previousHeight = React.useRef();
11
11
  React.useEffect(function () {
@@ -16,15 +16,9 @@ var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto)
16
16
  isManualResize.current = true;
17
17
  return;
18
18
  }
19
- var style = getComputedStyle(ref.current);
20
- var lineHeight = parseInt(style.lineHeight, 10);
21
- var lineHeightInRem = lineHeight / ROOT_FONT_SIZE;
22
- var minAutoHeight = minAuto ? minAuto * lineHeightInRem : 0;
23
- ref.current.style.height = "".concat(minAutoHeight, "rem");
24
- var lines = Math.floor(ref.current.scrollHeight / lineHeight);
25
- var newScrollHeight = lines * lineHeightInRem;
26
- var maxAutoHeight = maxAuto ? maxAuto * lineHeightInRem : newScrollHeight;
27
- var newHeight = Math.min(newScrollHeight, maxAutoHeight);
19
+ ref.current.style.height = "".concat(minHeight ? minHeight + 1 : '0', "rem");
20
+ var scrollHeight = ref.current.scrollHeight / ROOT_FONT_SIZE;
21
+ var newHeight = Math.min(scrollHeight, maxHeight ? maxHeight + 1 : scrollHeight);
28
22
  ref.current.style.height = "".concat(newHeight, "rem");
29
23
  previousHeight.current = newHeight;
30
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useAutoResize.js","sources":["../../../../src/components/TextArea/hooks/useAutoResize.ts"],"sourcesContent":["import { useEffect, useRef, MutableRefObject } from 'react';\n\nexport const ROOT_FONT_SIZE = 16;\n\nexport const useAutoResize = <T extends HTMLTextAreaElement>(\n active: boolean,\n ref: MutableRefObject<T | null>,\n value?: string | ReadonlyArray<string> | number,\n minAuto?: number,\n maxAuto?: number,\n) => {\n const isManualResize = useRef<boolean>(false);\n const previousHeight = useRef<number | undefined>();\n\n useEffect(() => {\n if (active && ref && ref.current && !isManualResize.current) {\n // проверка на пользовательский resize (вручную)\n const height = ref.current.clientHeight / ROOT_FONT_SIZE;\n if (previousHeight.current !== undefined && previousHeight.current !== height) {\n isManualResize.current = true;\n return;\n }\n\n const style = getComputedStyle(ref.current);\n const lineHeight = parseInt(style.lineHeight, 10);\n const lineHeightInRem = lineHeight / ROOT_FONT_SIZE;\n\n const minAutoHeight = minAuto ? minAuto * lineHeightInRem : 0;\n ref.current.style.height = `${minAutoHeight}rem`;\n\n const lines = Math.floor(ref.current.scrollHeight / lineHeight);\n const newScrollHeight = lines * lineHeightInRem;\n\n const maxAutoHeight = maxAuto ? maxAuto * lineHeightInRem : newScrollHeight;\n\n const newHeight = Math.min(newScrollHeight, maxAutoHeight);\n\n ref.current.style.height = `${newHeight}rem`;\n previousHeight.current = newHeight;\n }\n }, [ref, active, value]);\n};\n"],"names":["ROOT_FONT_SIZE","useAutoResize","active","ref","value","minAuto","maxAuto","isManualResize","useRef","previousHeight","useEffect","current","height","clientHeight","undefined","style","getComputedStyle","lineHeight","parseInt","lineHeightInRem","minAutoHeight","concat","lines","Math","floor","scrollHeight","newScrollHeight","maxAutoHeight","newHeight","min"],"mappings":";;;;;;AAEO,IAAMA,cAAc,GAAG,GAAE;AAEnBC,IAAAA,aAAa,GAAG,SAAhBA,aAAaA,CACtBC,MAAe,EACfC,GAA+B,EAC/BC,KAA+C,EAC/CC,OAAgB,EAChBC,OAAgB,EACf;AACD,EAAA,IAAMC,cAAc,GAAGC,YAAM,CAAU,KAAK,CAAC,CAAA;AAC7C,EAAA,IAAMC,cAAc,GAAGD,YAAM,EAAsB,CAAA;AAEnDE,EAAAA,eAAS,CAAC,YAAM;AACZ,IAAA,IAAIR,MAAM,IAAIC,GAAG,IAAIA,GAAG,CAACQ,OAAO,IAAI,CAACJ,cAAc,CAACI,OAAO,EAAE;AACzD;MACA,IAAMC,MAAM,GAAGT,GAAG,CAACQ,OAAO,CAACE,YAAY,GAAGb,cAAc,CAAA;MACxD,IAAIS,cAAc,CAACE,OAAO,KAAKG,SAAS,IAAIL,cAAc,CAACE,OAAO,KAAKC,MAAM,EAAE;QAC3EL,cAAc,CAACI,OAAO,GAAG,IAAI,CAAA;AAC7B,QAAA,OAAA;AACJ,OAAA;AAEA,MAAA,IAAMI,KAAK,GAAGC,gBAAgB,CAACb,GAAG,CAACQ,OAAO,CAAC,CAAA;MAC3C,IAAMM,UAAU,GAAGC,QAAQ,CAACH,KAAK,CAACE,UAAU,EAAE,EAAE,CAAC,CAAA;AACjD,MAAA,IAAME,eAAe,GAAGF,UAAU,GAAGjB,cAAc,CAAA;MAEnD,IAAMoB,aAAa,GAAGf,OAAO,GAAGA,OAAO,GAAGc,eAAe,GAAG,CAAC,CAAA;MAC7DhB,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAS,EAAAA,CAAAA,MAAA,CAAMD,aAAa,EAAK,KAAA,CAAA,CAAA;AAEhD,MAAA,IAAME,KAAK,GAAGC,IAAI,CAACC,KAAK,CAACrB,GAAG,CAACQ,OAAO,CAACc,YAAY,GAAGR,UAAU,CAAC,CAAA;AAC/D,MAAA,IAAMS,eAAe,GAAGJ,KAAK,GAAGH,eAAe,CAAA;MAE/C,IAAMQ,aAAa,GAAGrB,OAAO,GAAGA,OAAO,GAAGa,eAAe,GAAGO,eAAe,CAAA;MAE3E,IAAME,SAAS,GAAGL,IAAI,CAACM,GAAG,CAACH,eAAe,EAAEC,aAAa,CAAC,CAAA;MAE1DxB,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAS,EAAAA,CAAAA,MAAA,CAAMO,SAAS,EAAK,KAAA,CAAA,CAAA;MAC5CnB,cAAc,CAACE,OAAO,GAAGiB,SAAS,CAAA;AACtC,KAAA;GACH,EAAE,CAACzB,GAAG,EAAED,MAAM,EAAEE,KAAK,CAAC,CAAC,CAAA;AAC5B;;;;;"}
1
+ {"version":3,"file":"useAutoResize.js","sources":["../../../../src/components/TextArea/hooks/useAutoResize.ts"],"sourcesContent":["import { useEffect, useRef, MutableRefObject } from 'react';\n\nexport const ROOT_FONT_SIZE = 16;\n\nexport const useAutoResize = <T extends HTMLTextAreaElement>(\n active: boolean,\n ref: MutableRefObject<T | null>,\n value?: string | ReadonlyArray<string> | number,\n minHeight?: number,\n maxHeight?: number,\n) => {\n const isManualResize = useRef<boolean>(false);\n const previousHeight = useRef<number | undefined>();\n\n useEffect(() => {\n if (active && ref && ref.current && !isManualResize.current) {\n // проверка на пользовательский resize (вручную)\n const height = ref.current.clientHeight / ROOT_FONT_SIZE;\n if (previousHeight.current !== undefined && previousHeight.current !== height) {\n isManualResize.current = true;\n return;\n }\n\n ref.current.style.height = `${minHeight ? minHeight + 1 : '0'}rem`;\n const scrollHeight = ref.current.scrollHeight / ROOT_FONT_SIZE;\n const newHeight = Math.min(scrollHeight, maxHeight ? maxHeight + 1 : scrollHeight);\n\n ref.current.style.height = `${newHeight}rem`;\n previousHeight.current = newHeight;\n }\n }, [ref, active, value]);\n};\n"],"names":["ROOT_FONT_SIZE","useAutoResize","active","ref","value","minHeight","maxHeight","isManualResize","useRef","previousHeight","useEffect","current","height","clientHeight","undefined","style","concat","scrollHeight","newHeight","Math","min"],"mappings":";;;;;;AAEO,IAAMA,cAAc,GAAG,GAAE;AAEnBC,IAAAA,aAAa,GAAG,SAAhBA,aAAaA,CACtBC,MAAe,EACfC,GAA+B,EAC/BC,KAA+C,EAC/CC,SAAkB,EAClBC,SAAkB,EACjB;AACD,EAAA,IAAMC,cAAc,GAAGC,YAAM,CAAU,KAAK,CAAC,CAAA;AAC7C,EAAA,IAAMC,cAAc,GAAGD,YAAM,EAAsB,CAAA;AAEnDE,EAAAA,eAAS,CAAC,YAAM;AACZ,IAAA,IAAIR,MAAM,IAAIC,GAAG,IAAIA,GAAG,CAACQ,OAAO,IAAI,CAACJ,cAAc,CAACI,OAAO,EAAE;AACzD;MACA,IAAMC,MAAM,GAAGT,GAAG,CAACQ,OAAO,CAACE,YAAY,GAAGb,cAAc,CAAA;MACxD,IAAIS,cAAc,CAACE,OAAO,KAAKG,SAAS,IAAIL,cAAc,CAACE,OAAO,KAAKC,MAAM,EAAE;QAC3EL,cAAc,CAACI,OAAO,GAAG,IAAI,CAAA;AAC7B,QAAA,OAAA;AACJ,OAAA;AAEAR,MAAAA,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAI,EAAAA,CAAAA,MAAA,CAAMX,SAAS,GAAGA,SAAS,GAAG,CAAC,GAAG,GAAG,EAAK,KAAA,CAAA,CAAA;MAClE,IAAMY,YAAY,GAAGd,GAAG,CAACQ,OAAO,CAACM,YAAY,GAAGjB,cAAc,CAAA;AAC9D,MAAA,IAAMkB,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACH,YAAY,EAAEX,SAAS,GAAGA,SAAS,GAAG,CAAC,GAAGW,YAAY,CAAC,CAAA;MAElFd,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAI,EAAAA,CAAAA,MAAA,CAAME,SAAS,EAAK,KAAA,CAAA,CAAA;MAC5CT,cAAc,CAACE,OAAO,GAAGO,SAAS,CAAA;AACtC,KAAA;GACH,EAAE,CAACf,GAAG,EAAED,MAAM,EAAEE,KAAK,CAAC,CAAC,CAAA;AAC5B;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import './TextArea_ob9y3r.css';
2
- import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
3
3
  import React, { forwardRef, useState, useCallback, createRef } from 'react';
4
4
  import { useResizeObserver } from '@salutejs/plasma-core';
5
5
  import { cx } from '../../utils/index.js';
@@ -123,17 +123,15 @@ var textAreaRoot = function textAreaRoot(Root) {
123
123
  }
124
124
  onChange === null || onChange === void 0 || onChange(event);
125
125
  }, [value, onChange]);
126
- var dynamicLabelClasses = getDynamicLabelClasses(_objectSpread2({
126
+ var dynamicLabelClasses = getDynamicLabelClasses({
127
127
  size: size,
128
128
  readOnly: readOnly,
129
129
  label: label,
130
130
  labelPlacement: labelPlacement,
131
+ autoResize: autoResize,
132
+ rows: rows,
131
133
  value: value || uncontrolledValue || defaultValue
132
- }, rows ? {
133
- rows: rows
134
- } : {
135
- autoResize: autoResize
136
- }), focused);
134
+ }, focused);
137
135
  return /*#__PURE__*/React.createElement(Root, {
138
136
  view: overriddenView,
139
137
  size: size,
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import React, { forwardRef, useState, createRef, useCallback } from 'react';\nimport { css } from '@linaria/core';\nimport { useResizeObserver } from '@salutejs/plasma-core';\n\nimport { cx } from '../../utils';\nimport type { RootProps } from '../../engines/types';\n\nimport { applyDynamicLabel } from './mixins';\nimport { useAutoResize, ROOT_FONT_SIZE } from './hooks';\nimport {\n StyledContent,\n StyledHelpers,\n StyledLeftHelper,\n StyledRightHelper,\n StyledLabel,\n StyledPlaceholder,\n StyledTextArea,\n StyledTextAreaWrapper,\n StyledContainer,\n} from './TextArea.styles';\nimport { classes } from './TextArea.tokens';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport type { TextAreaProps } from './TextArea.types';\n\nconst {\n innerPlaceholderUp,\n focusedOuterPlaceholderColor,\n hidePlaceHolder,\n styledContainer,\n styledTextArea,\n styledTextAreaWrapper,\n styledPlaceholder,\n styledHelpers,\n} = classes;\n\nconst base = css`\n ${applyDynamicLabel};\n\n position: relative;\n box-sizing: border-box;\n`;\n\n// TODO: Удалить после отказа от старых библиотек plasma-web / plasma-b2c\nconst fallbackStatusMap = {\n '': 'primary',\n success: 'positive',\n warning: 'warning',\n error: 'negative',\n};\n\n// TODO: Перенести этот метод в файл applyDynamicLabel.ts\nexport const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) => {\n const { readOnly, label, labelPlacement, autoResize, rows, value, size } = props;\n\n // Добавить класс отвечающий за изменение цвета плейсхолдера при фокусе\n const withFocusedOuterUpPlaceholder =\n !readOnly && focused && (!label || labelPlacement === 'outer') ? focusedOuterPlaceholderColor : undefined;\n\n // Добавить класс отвечающий за поднятие и уменьшение плейсхолдера\n const withInnerPlaceholderUp =\n labelPlacement === 'inner' &&\n label &&\n !autoResize &&\n !rows &&\n size !== 'xs' &&\n ((!readOnly && (value || focused)) || (readOnly && value))\n ? innerPlaceholderUp\n : undefined;\n\n // Добавить класс отвечающий за скрытие плейсхолдера\n const withHidePlaceholder =\n (value && !label) ||\n (labelPlacement === 'inner' && ((focused && !readOnly) || value) && label && (rows || autoResize)) ||\n (labelPlacement === 'outer' && value) ||\n (labelPlacement === 'inner' && size === 'xs' && value)\n ? hidePlaceHolder\n : undefined;\n\n return [withFocusedOuterUpPlaceholder, withInnerPlaceholderUp, withHidePlaceholder];\n};\n\nexport const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) =>\n forwardRef<HTMLTextAreaElement, TextAreaProps>((props, innerRef) => {\n const {\n helperText,\n status,\n resize,\n rightHelper,\n leftHelper,\n contentRight,\n autoResize = false,\n minAuto = 0,\n maxAuto,\n label,\n labelPlacement = 'inner',\n placeholder,\n defaultValue,\n height,\n width,\n value,\n disabled,\n size,\n view,\n id,\n style,\n className,\n readOnly,\n rows,\n cols,\n onChange,\n ...rest\n } = props;\n\n const [helperWidth, setHelperWidth] = useState<string>(width ? `${width}rem` : '100%');\n const [focused, setFocused] = useState(false);\n const [uncontrolledValue, setUncontrolledValue] = useState<string | undefined>();\n\n const outerRef = innerRef && 'current' in innerRef ? innerRef : createRef<HTMLTextAreaElement>();\n const hasHelper = Boolean(leftHelper || rightHelper || helperText);\n const overriddenView = status !== undefined ? fallbackStatusMap[status] : view;\n const textareaHelperId = id ? `${id}-helper` : undefined;\n const applyCustomWidth = resize !== 'horizontal' && resize !== 'both' && !cols;\n const placeLabel = labelPlacement === 'inner' && label && size !== 'xs' ? label : placeholder;\n\n useResizeObserver(outerRef, (currentElement) => {\n const { width: inlineWidth, height: inlineHeight } = currentElement.style;\n\n if (inlineWidth || inlineHeight || cols) {\n const { width: elementWidth } = currentElement.getBoundingClientRect();\n setHelperWidth(`${elementWidth / ROOT_FONT_SIZE}rem`);\n }\n });\n\n useAutoResize(autoResize, outerRef, value, minAuto, maxAuto);\n\n const onFocusHandler = useCallback(() => {\n setFocused(true);\n }, []);\n const onBlurHandler = useCallback(() => {\n setFocused(false);\n }, []);\n\n const onChangeHandler = useCallback(\n (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n // INFO: Для крайне редких кейсов, когда value снаружи не контролируется\n if (value === undefined) {\n setUncontrolledValue(event?.target.value);\n }\n\n onChange?.(event);\n },\n [value, onChange],\n );\n\n const dynamicLabelClasses = getDynamicLabelClasses(\n {\n size,\n readOnly,\n label,\n labelPlacement,\n value: value || uncontrolledValue || defaultValue,\n ...(rows ? { rows } : { autoResize }),\n },\n focused,\n );\n\n return (\n <Root\n view={overriddenView}\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n style={style}\n className={className}\n >\n {label && labelPlacement === 'outer' && <StyledLabel>{label}</StyledLabel>}\n <StyledContainer\n className={cx(styledContainer, ...dynamicLabelClasses)}\n width={helperWidth}\n onFocus={onFocusHandler}\n onBlur={onBlurHandler}\n >\n {contentRight && <StyledContent>{contentRight}</StyledContent>}\n <StyledTextAreaWrapper className={styledTextAreaWrapper} hasHelper={hasHelper}>\n <StyledTextArea\n className={styledTextArea}\n id={id}\n hasContentRight={Boolean(contentRight)}\n hasHelper={hasHelper}\n applyCustomWidth={applyCustomWidth}\n ref={outerRef}\n disabled={disabled}\n height={autoResize ? minAuto : height}\n width={width}\n placeholder={placeLabel}\n aria-describedby={textareaHelperId}\n value={value}\n readOnly={readOnly}\n rows={rows}\n cols={cols}\n resize={resize}\n defaultValue={defaultValue}\n onChange={onChangeHandler}\n {...rest}\n />\n </StyledTextAreaWrapper>\n {hasHelper && (\n <StyledHelpers className={styledHelpers} id={textareaHelperId}>\n {(leftHelper || helperText) && (\n <StyledLeftHelper>{leftHelper || helperText}</StyledLeftHelper>\n )}\n {rightHelper && <StyledRightHelper>{rightHelper}</StyledRightHelper>}\n </StyledHelpers>\n )}\n {placeLabel && (\n <StyledPlaceholder\n hasContentRight={Boolean(contentRight)}\n className={styledPlaceholder}\n htmlFor={id}\n >\n {placeLabel}\n </StyledPlaceholder>\n )}\n </StyledContainer>\n </Root>\n );\n });\n\nexport const textAreaConfig = {\n name: 'TextArea',\n tag: 'div',\n layout: textAreaRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n readOnly: {\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'primary',\n },\n};\n"],"names":["innerPlaceholderUp","classes","focusedOuterPlaceholderColor","hidePlaceHolder","styledContainer","styledTextArea","styledTextAreaWrapper","styledPlaceholder","styledHelpers","base","fallbackStatusMap","success","warning","error","getDynamicLabelClasses","props","focused","readOnly","label","labelPlacement","autoResize","rows","value","size","withFocusedOuterUpPlaceholder","undefined","withInnerPlaceholderUp","withHidePlaceholder","textAreaRoot","Root","forwardRef","innerRef","helperText","status","resize","rightHelper","leftHelper","contentRight","_props$autoResize","_props$minAuto","minAuto","maxAuto","_props$labelPlacement","placeholder","defaultValue","height","width","disabled","view","id","style","className","cols","onChange","rest","_excluded","_useState","useState","concat","_useState2","_slicedToArray","helperWidth","setHelperWidth","_useState3","_useState4","setFocused","_useState5","_useState6","uncontrolledValue","setUncontrolledValue","outerRef","createRef","hasHelper","Boolean","overriddenView","textareaHelperId","applyCustomWidth","placeLabel","useResizeObserver","currentElement","_currentElement$style","inlineWidth","inlineHeight","_currentElement$getBo","getBoundingClientRect","elementWidth","ROOT_FONT_SIZE","useAutoResize","onFocusHandler","useCallback","onBlurHandler","onChangeHandler","event","target","dynamicLabelClasses","_objectSpread","React","createElement","StyledLabel","StyledContainer","cx","apply","_toConsumableArray","onFocus","onBlur","StyledContent","StyledTextAreaWrapper","StyledTextArea","_extends","hasContentRight","ref","StyledHelpers","StyledLeftHelper","StyledRightHelper","StyledPlaceholder","htmlFor","textAreaConfig","name","tag","layout","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;AA0BA,IACIA,kBAAkB,GAQlBC,OAAO,CARPD,kBAAkB;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,CAEV,CACf,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMuC,cAAc,GAAG;AAC1BC,EAAAA,IAAI,EAAE,UAAU;AAChBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE3F,YAAY;AACpBnB,EAAAA,IAAI,EAAJA,IAAI;AACJ+G,EAAAA,UAAU,EAAE;AACRjG,IAAAA,IAAI,EAAE;AACFkG,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACD1E,IAAAA,IAAI,EAAE;AACFyE,MAAAA,GAAG,EAAEE,MAAAA;KACR;AACD5E,IAAAA,QAAQ,EAAE;AACN0E,MAAAA,GAAG,EAAEG,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACD5G,IAAAA,QAAQ,EAAE;AACN4G,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNvG,IAAAA,IAAI,EAAE,GAAG;AACTyB,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;"}
1
+ {"version":3,"file":"TextArea.js","sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import React, { forwardRef, useState, createRef, useCallback } from 'react';\nimport { css } from '@linaria/core';\nimport { useResizeObserver } from '@salutejs/plasma-core';\n\nimport { cx } from '../../utils';\nimport type { RootProps } from '../../engines/types';\n\nimport { applyDynamicLabel } from './mixins';\nimport { useAutoResize, ROOT_FONT_SIZE } from './hooks';\nimport {\n StyledContent,\n StyledHelpers,\n StyledLeftHelper,\n StyledRightHelper,\n StyledLabel,\n StyledPlaceholder,\n StyledTextArea,\n StyledTextAreaWrapper,\n StyledContainer,\n} from './TextArea.styles';\nimport { classes } from './TextArea.tokens';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport type { TextAreaProps } from './TextArea.types';\n\nconst {\n innerPlaceholderUp,\n focusedOuterPlaceholderColor,\n hidePlaceHolder,\n styledContainer,\n styledTextArea,\n styledTextAreaWrapper,\n styledPlaceholder,\n styledHelpers,\n} = classes;\n\nconst base = css`\n ${applyDynamicLabel};\n\n position: relative;\n box-sizing: border-box;\n`;\n\n// TODO: Удалить после отказа от старых библиотек plasma-web / plasma-b2c\nconst fallbackStatusMap = {\n '': 'primary',\n success: 'positive',\n warning: 'warning',\n error: 'negative',\n};\n\n// TODO: Перенести этот метод в файл applyDynamicLabel.ts\nexport const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) => {\n const { readOnly, label, labelPlacement, autoResize, rows, value, size } = props;\n\n // Добавить класс отвечающий за изменение цвета плейсхолдера при фокусе\n const withFocusedOuterUpPlaceholder =\n !readOnly && focused && (!label || labelPlacement === 'outer') ? focusedOuterPlaceholderColor : undefined;\n\n // Добавить класс отвечающий за поднятие и уменьшение плейсхолдера\n const withInnerPlaceholderUp =\n labelPlacement === 'inner' &&\n label &&\n !autoResize &&\n !rows &&\n size !== 'xs' &&\n ((!readOnly && (value || focused)) || (readOnly && value))\n ? innerPlaceholderUp\n : undefined;\n\n // Добавить класс отвечающий за скрытие плейсхолдера\n const withHidePlaceholder =\n (value && !label) ||\n (labelPlacement === 'inner' && ((focused && !readOnly) || value) && label && (rows || autoResize)) ||\n (labelPlacement === 'outer' && value) ||\n (labelPlacement === 'inner' && size === 'xs' && value)\n ? hidePlaceHolder\n : undefined;\n\n return [withFocusedOuterUpPlaceholder, withInnerPlaceholderUp, withHidePlaceholder];\n};\n\nexport const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) =>\n forwardRef<HTMLTextAreaElement, TextAreaProps>((props, innerRef) => {\n const {\n helperText,\n status,\n resize,\n rightHelper,\n leftHelper,\n contentRight,\n autoResize = false,\n minAuto = 0,\n maxAuto,\n label,\n labelPlacement = 'inner',\n placeholder,\n defaultValue,\n height,\n width,\n value,\n disabled,\n size,\n view,\n id,\n style,\n className,\n readOnly,\n rows,\n cols,\n onChange,\n ...rest\n } = props;\n\n const [helperWidth, setHelperWidth] = useState<string>(width ? `${width}rem` : '100%');\n const [focused, setFocused] = useState(false);\n const [uncontrolledValue, setUncontrolledValue] = useState<string | undefined>();\n\n const outerRef = innerRef && 'current' in innerRef ? innerRef : createRef<HTMLTextAreaElement>();\n const hasHelper = Boolean(leftHelper || rightHelper || helperText);\n const overriddenView = status !== undefined ? fallbackStatusMap[status] : view;\n const textareaHelperId = id ? `${id}-helper` : undefined;\n const applyCustomWidth = resize !== 'horizontal' && resize !== 'both' && !cols;\n const placeLabel = labelPlacement === 'inner' && label && size !== 'xs' ? label : placeholder;\n\n useResizeObserver(outerRef, (currentElement) => {\n const { width: inlineWidth, height: inlineHeight } = currentElement.style;\n\n if (inlineWidth || inlineHeight || cols) {\n const { width: elementWidth } = currentElement.getBoundingClientRect();\n setHelperWidth(`${elementWidth / ROOT_FONT_SIZE}rem`);\n }\n });\n\n useAutoResize(autoResize, outerRef, value, minAuto, maxAuto);\n\n const onFocusHandler = useCallback(() => {\n setFocused(true);\n }, []);\n const onBlurHandler = useCallback(() => {\n setFocused(false);\n }, []);\n\n const onChangeHandler = useCallback(\n (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n // INFO: Для крайне редких кейсов, когда value снаружи не контролируется\n if (value === undefined) {\n setUncontrolledValue(event?.target.value);\n }\n\n onChange?.(event);\n },\n [value, onChange],\n );\n\n const dynamicLabelClasses = getDynamicLabelClasses(\n {\n size,\n readOnly,\n label,\n labelPlacement,\n autoResize,\n rows,\n value: value || uncontrolledValue || defaultValue,\n },\n focused,\n );\n\n return (\n <Root\n view={overriddenView}\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n style={style}\n className={className}\n >\n {label && labelPlacement === 'outer' && <StyledLabel>{label}</StyledLabel>}\n <StyledContainer\n className={cx(styledContainer, ...dynamicLabelClasses)}\n width={helperWidth}\n onFocus={onFocusHandler}\n onBlur={onBlurHandler}\n >\n {contentRight && <StyledContent>{contentRight}</StyledContent>}\n <StyledTextAreaWrapper className={styledTextAreaWrapper} hasHelper={hasHelper}>\n <StyledTextArea\n className={styledTextArea}\n id={id}\n hasContentRight={Boolean(contentRight)}\n hasHelper={hasHelper}\n applyCustomWidth={applyCustomWidth}\n ref={outerRef}\n disabled={disabled}\n height={autoResize ? minAuto : height}\n width={width}\n placeholder={placeLabel}\n aria-describedby={textareaHelperId}\n value={value}\n readOnly={readOnly}\n rows={rows}\n cols={cols}\n resize={resize}\n defaultValue={defaultValue}\n onChange={onChangeHandler}\n {...rest}\n />\n </StyledTextAreaWrapper>\n {hasHelper && (\n <StyledHelpers className={styledHelpers} id={textareaHelperId}>\n {(leftHelper || helperText) && (\n <StyledLeftHelper>{leftHelper || helperText}</StyledLeftHelper>\n )}\n {rightHelper && <StyledRightHelper>{rightHelper}</StyledRightHelper>}\n </StyledHelpers>\n )}\n {placeLabel && (\n <StyledPlaceholder\n hasContentRight={Boolean(contentRight)}\n className={styledPlaceholder}\n htmlFor={id}\n >\n {placeLabel}\n </StyledPlaceholder>\n )}\n </StyledContainer>\n </Root>\n );\n });\n\nexport const textAreaConfig = {\n name: 'TextArea',\n tag: 'div',\n layout: textAreaRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n readOnly: {\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'primary',\n },\n};\n"],"names":["innerPlaceholderUp","classes","focusedOuterPlaceholderColor","hidePlaceHolder","styledContainer","styledTextArea","styledTextAreaWrapper","styledPlaceholder","styledHelpers","base","fallbackStatusMap","success","warning","error","getDynamicLabelClasses","props","focused","readOnly","label","labelPlacement","autoResize","rows","value","size","withFocusedOuterUpPlaceholder","undefined","withInnerPlaceholderUp","withHidePlaceholder","textAreaRoot","Root","forwardRef","innerRef","helperText","status","resize","rightHelper","leftHelper","contentRight","_props$autoResize","_props$minAuto","minAuto","maxAuto","_props$labelPlacement","placeholder","defaultValue","height","width","disabled","view","id","style","className","cols","onChange","rest","_excluded","_useState","useState","concat","_useState2","_slicedToArray","helperWidth","setHelperWidth","_useState3","_useState4","setFocused","_useState5","_useState6","uncontrolledValue","setUncontrolledValue","outerRef","createRef","hasHelper","Boolean","overriddenView","textareaHelperId","applyCustomWidth","placeLabel","useResizeObserver","currentElement","_currentElement$style","inlineWidth","inlineHeight","_currentElement$getBo","getBoundingClientRect","elementWidth","ROOT_FONT_SIZE","useAutoResize","onFocusHandler","useCallback","onBlurHandler","onChangeHandler","event","target","dynamicLabelClasses","React","createElement","StyledLabel","StyledContainer","cx","apply","_toConsumableArray","onFocus","onBlur","StyledContent","StyledTextAreaWrapper","StyledTextArea","_extends","hasContentRight","ref","StyledHelpers","StyledLeftHelper","StyledRightHelper","StyledPlaceholder","htmlFor","textAreaConfig","name","tag","layout","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;AA0BA,IACIA,kBAAkB,GAQlBC,OAAO,CARPD,kBAAkB;EAClBE,4BAA4B,GAO5BD,OAAO,CAPPC,4BAA4B;EAC5BC,eAAe,GAMfF,OAAO,CANPE,eAAe;EACfC,eAAe,GAKfH,OAAO,CALPG,eAAe;EACfC,cAAc,GAIdJ,OAAO,CAJPI,cAAc;EACdC,qBAAqB,GAGrBL,OAAO,CAHPK,qBAAqB;EACrBC,iBAAiB,GAEjBN,OAAO,CAFPM,iBAAiB;EACjBC,aAAAA,GACAP,OAAO,CADPO,aAAAA,CAAAA;AAGJ,IAAMC,IAAI,GAKT,SAAA,CAAA;;AAED;AACA,IAAMC,iBAAiB,GAAG;AACtB,EAAA,EAAE,EAAE,SAAS;AACbC,EAAAA,OAAO,EAAE,UAAU;AACnBC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,KAAK,EAAE,UAAA;AACX,CAAC,CAAA;;AAED;AACO,IAAMC,sBAAsB,GAAGA,SAAzBA,sBAAsBA,CAAIC,KAAoB,EAAEC,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 -1,7 +1,7 @@
1
1
  import { useRef, useEffect } from 'react';
2
2
 
3
3
  var ROOT_FONT_SIZE = 16;
4
- var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto) {
4
+ var useAutoResize = function useAutoResize(active, ref, value, minHeight, maxHeight) {
5
5
  var isManualResize = useRef(false);
6
6
  var previousHeight = useRef();
7
7
  useEffect(function () {
@@ -12,15 +12,9 @@ var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto)
12
12
  isManualResize.current = true;
13
13
  return;
14
14
  }
15
- var style = getComputedStyle(ref.current);
16
- var lineHeight = parseInt(style.lineHeight, 10);
17
- var lineHeightInRem = lineHeight / ROOT_FONT_SIZE;
18
- var minAutoHeight = minAuto ? minAuto * lineHeightInRem : 0;
19
- ref.current.style.height = "".concat(minAutoHeight, "rem");
20
- var lines = Math.floor(ref.current.scrollHeight / lineHeight);
21
- var newScrollHeight = lines * lineHeightInRem;
22
- var maxAutoHeight = maxAuto ? maxAuto * lineHeightInRem : newScrollHeight;
23
- var newHeight = Math.min(newScrollHeight, maxAutoHeight);
15
+ ref.current.style.height = "".concat(minHeight ? minHeight + 1 : '0', "rem");
16
+ var scrollHeight = ref.current.scrollHeight / ROOT_FONT_SIZE;
17
+ var newHeight = Math.min(scrollHeight, maxHeight ? maxHeight + 1 : scrollHeight);
24
18
  ref.current.style.height = "".concat(newHeight, "rem");
25
19
  previousHeight.current = newHeight;
26
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useAutoResize.js","sources":["../../../../src/components/TextArea/hooks/useAutoResize.ts"],"sourcesContent":["import { useEffect, useRef, MutableRefObject } from 'react';\n\nexport const ROOT_FONT_SIZE = 16;\n\nexport const useAutoResize = <T extends HTMLTextAreaElement>(\n active: boolean,\n ref: MutableRefObject<T | null>,\n value?: string | ReadonlyArray<string> | number,\n minAuto?: number,\n maxAuto?: number,\n) => {\n const isManualResize = useRef<boolean>(false);\n const previousHeight = useRef<number | undefined>();\n\n useEffect(() => {\n if (active && ref && ref.current && !isManualResize.current) {\n // проверка на пользовательский resize (вручную)\n const height = ref.current.clientHeight / ROOT_FONT_SIZE;\n if (previousHeight.current !== undefined && previousHeight.current !== height) {\n isManualResize.current = true;\n return;\n }\n\n const style = getComputedStyle(ref.current);\n const lineHeight = parseInt(style.lineHeight, 10);\n const lineHeightInRem = lineHeight / ROOT_FONT_SIZE;\n\n const minAutoHeight = minAuto ? minAuto * lineHeightInRem : 0;\n ref.current.style.height = `${minAutoHeight}rem`;\n\n const lines = Math.floor(ref.current.scrollHeight / lineHeight);\n const newScrollHeight = lines * lineHeightInRem;\n\n const maxAutoHeight = maxAuto ? maxAuto * lineHeightInRem : newScrollHeight;\n\n const newHeight = Math.min(newScrollHeight, maxAutoHeight);\n\n ref.current.style.height = `${newHeight}rem`;\n previousHeight.current = newHeight;\n }\n }, [ref, active, value]);\n};\n"],"names":["ROOT_FONT_SIZE","useAutoResize","active","ref","value","minAuto","maxAuto","isManualResize","useRef","previousHeight","useEffect","current","height","clientHeight","undefined","style","getComputedStyle","lineHeight","parseInt","lineHeightInRem","minAutoHeight","concat","lines","Math","floor","scrollHeight","newScrollHeight","maxAutoHeight","newHeight","min"],"mappings":";;AAEO,IAAMA,cAAc,GAAG,GAAE;AAEnBC,IAAAA,aAAa,GAAG,SAAhBA,aAAaA,CACtBC,MAAe,EACfC,GAA+B,EAC/BC,KAA+C,EAC/CC,OAAgB,EAChBC,OAAgB,EACf;AACD,EAAA,IAAMC,cAAc,GAAGC,MAAM,CAAU,KAAK,CAAC,CAAA;AAC7C,EAAA,IAAMC,cAAc,GAAGD,MAAM,EAAsB,CAAA;AAEnDE,EAAAA,SAAS,CAAC,YAAM;AACZ,IAAA,IAAIR,MAAM,IAAIC,GAAG,IAAIA,GAAG,CAACQ,OAAO,IAAI,CAACJ,cAAc,CAACI,OAAO,EAAE;AACzD;MACA,IAAMC,MAAM,GAAGT,GAAG,CAACQ,OAAO,CAACE,YAAY,GAAGb,cAAc,CAAA;MACxD,IAAI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"],"sourcesContent":["import { useEffect, useRef, MutableRefObject } from 'react';\n\nexport const ROOT_FONT_SIZE = 16;\n\nexport const useAutoResize = <T extends HTMLTextAreaElement>(\n active: boolean,\n ref: MutableRefObject<T | null>,\n value?: string | ReadonlyArray<string> | number,\n minHeight?: number,\n maxHeight?: number,\n) => {\n const isManualResize = useRef<boolean>(false);\n const previousHeight = useRef<number | undefined>();\n\n useEffect(() => {\n if (active && ref && ref.current && !isManualResize.current) {\n // проверка на пользовательский resize (вручную)\n const height = ref.current.clientHeight / ROOT_FONT_SIZE;\n if (previousHeight.current !== undefined && previousHeight.current !== height) {\n isManualResize.current = true;\n return;\n }\n\n ref.current.style.height = `${minHeight ? minHeight + 1 : '0'}rem`;\n const scrollHeight = ref.current.scrollHeight / ROOT_FONT_SIZE;\n const newHeight = Math.min(scrollHeight, maxHeight ? maxHeight + 1 : scrollHeight);\n\n ref.current.style.height = `${newHeight}rem`;\n previousHeight.current = newHeight;\n }\n }, [ref, active, value]);\n};\n"],"names":["ROOT_FONT_SIZE","useAutoResize","active","ref","value","minHeight","maxHeight","isManualResize","useRef","previousHeight","useEffect","current","height","clientHeight","undefined","style","concat","scrollHeight","newHeight","Math","min"],"mappings":";;AAEO,IAAMA,cAAc,GAAG,GAAE;AAEnBC,IAAAA,aAAa,GAAG,SAAhBA,aAAaA,CACtBC,MAAe,EACfC,GAA+B,EAC/BC,KAA+C,EAC/CC,SAAkB,EAClBC,SAAkB,EACjB;AACD,EAAA,IAAMC,cAAc,GAAGC,MAAM,CAAU,KAAK,CAAC,CAAA;AAC7C,EAAA,IAAMC,cAAc,GAAGD,MAAM,EAAsB,CAAA;AAEnDE,EAAAA,SAAS,CAAC,YAAM;AACZ,IAAA,IAAIR,MAAM,IAAIC,GAAG,IAAIA,GAAG,CAACQ,OAAO,IAAI,CAACJ,cAAc,CAACI,OAAO,EAAE;AACzD;MACA,IAAMC,MAAM,GAAGT,GAAG,CAACQ,OAAO,CAACE,YAAY,GAAGb,cAAc,CAAA;MACxD,IAAIS,cAAc,CAACE,OAAO,KAAKG,SAAS,IAAIL,cAAc,CAACE,OAAO,KAAKC,MAAM,EAAE;QAC3EL,cAAc,CAACI,OAAO,GAAG,IAAI,CAAA;AAC7B,QAAA,OAAA;AACJ,OAAA;AAEAR,MAAAA,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAI,EAAAA,CAAAA,MAAA,CAAMX,SAAS,GAAGA,SAAS,GAAG,CAAC,GAAG,GAAG,EAAK,KAAA,CAAA,CAAA;MAClE,IAAMY,YAAY,GAAGd,GAAG,CAACQ,OAAO,CAACM,YAAY,GAAGjB,cAAc,CAAA;AAC9D,MAAA,IAAMkB,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACH,YAAY,EAAEX,SAAS,GAAGA,SAAS,GAAG,CAAC,GAAGW,YAAY,CAAC,CAAA;MAElFd,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAI,EAAAA,CAAAA,MAAA,CAAME,SAAS,EAAK,KAAA,CAAA,CAAA;MAC5CT,cAAc,CAACE,OAAO,GAAGO,SAAS,CAAA;AACtC,KAAA;GACH,EAAE,CAACf,GAAG,EAAED,MAAM,EAAEE,KAAK,CAAC,CAAC,CAAA;AAC5B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salutejs/plasma-new-hope",
3
- "version": "0.91.0-canary.1261.9609334871.0",
3
+ "version": "0.91.0-canary.1263.9643629084.0",
4
4
  "description": "Salute Design System blueprint",
5
5
  "main": "cjs/index.js",
6
6
  "module": "es/index.js",
@@ -105,5 +105,5 @@
105
105
  "react-popper": "2.3.0",
106
106
  "storeon": "3.1.5"
107
107
  },
108
- "gitHead": "6a4e6a1066217e44a5f3ce7b25ddb4bd373e0390"
108
+ "gitHead": "256f005743df13c0eb6628e00de4809431152574"
109
109
  }
@@ -24,11 +24,6 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
24
24
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
25
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
26
26
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
27
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
31
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
32
27
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
28
  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."); }
34
29
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -149,17 +144,15 @@ var textAreaRoot = exports.textAreaRoot = function textAreaRoot(Root) {
149
144
  }
150
145
  onChange === null || onChange === void 0 || onChange(event);
151
146
  }, [value, onChange]);
152
- var dynamicLabelClasses = getDynamicLabelClasses(_objectSpread({
147
+ var dynamicLabelClasses = getDynamicLabelClasses({
153
148
  size: size,
154
149
  readOnly: readOnly,
155
150
  label: label,
156
151
  labelPlacement: labelPlacement,
152
+ autoResize: autoResize,
153
+ rows: rows,
157
154
  value: value || uncontrolledValue || defaultValue
158
- }, rows ? {
159
- rows: rows
160
- } : {
161
- autoResize: autoResize
162
- }), focused);
155
+ }, focused);
163
156
  return /*#__PURE__*/_react["default"].createElement(Root, {
164
157
  view: overriddenView,
165
158
  size: size,
@@ -11,7 +11,7 @@ import { PropsTable, Description } from '@site/src/components';
11
11
 
12
12
  ## Использование
13
13
  Компонент `TextArea` может содержать иконку (или кнопку) справа.
14
- Для этого используйте свойство `contentRight`:
14
+ Для этого используйте свойство и `contentRight`:
15
15
 
16
16
  ```tsx live
17
17
  import React from 'react';
@@ -31,55 +31,16 @@ export function App() {
31
31
  }
32
32
  ```
33
33
 
34
- ### Размеры компонента
35
- Высоту и ширину можно регулировать с помощью свойств `height` и `width`,
34
+ Также можно регулировать высоту и ширину, используя свойства `height` и `width`,
36
35
  указав значения в `rem` или соответствующие свойствам css значения.
37
- `height` и `width` отвечают за **всю** высоту и ширину компонента.
38
36
 
39
- ```tsx live
40
- import React from 'react';
41
- import { TextArea } from '@salutejs/{{ package }}';
42
-
43
- export function App() {
44
- return (
45
- <div>
46
- <TextArea
47
- placeholder="Введите значение"
48
- defaultValue="Значение"
49
- height={10}
50
- width={20}
51
- />
52
- </div>
53
- );
54
- }
55
- ```
56
-
57
- Свойства `rows` и `cols` указываются в абсолютных единицах, отвечают за фиксированное количество строк и столбцов.
58
-
59
- ```tsx live
60
- import React from 'react';
61
- import { TextArea } from '@salutejs/{{ package }}';
62
-
63
- export function App() {
64
- return (
65
- <div>
66
- <TextArea
67
- placeholder="Введите значение"
68
- defaultValue="Значение"
69
- rows={5}
70
- cols={20}
71
- />
72
- </div>
73
- );
74
- }
75
- ```
76
-
77
- ### Autoresize
37
+ ## Autoresize
78
38
  Также можно включить автоматическое регулирование высоты поля ввода по длине контента внутри (параметра `value`).
79
39
  Для этого необходимо использовать свойство `autoResize`.
80
40
  При этом, если пользователь вручную регулирует высоту(`resize`), то она так и остается пользовательской.
81
41
 
82
- Свойства `minAuto`, `maxAuto` указываются в абсолютных единицах и отвечают за минимальное и максимальное количество строк.
42
+ В этом режиме можно указать крайние значения высоты поля ввода, используя свойства `autoMin`, `autoMax`,
43
+ указав их в `rem`.
83
44
 
84
45
  ```tsx live
85
46
  import React from 'react';
@@ -124,4 +85,4 @@ export function App() {
124
85
  </div>
125
86
  );
126
87
  }
127
- ```
88
+ ```
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useAutoResize = exports.ROOT_FONT_SIZE = void 0;
7
7
  var _react = /*#__PURE__*/require("react");
8
8
  var ROOT_FONT_SIZE = exports.ROOT_FONT_SIZE = 16;
9
- var useAutoResize = exports.useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto) {
9
+ var useAutoResize = exports.useAutoResize = function useAutoResize(active, ref, value, minHeight, maxHeight) {
10
10
  var isManualResize = (0, _react.useRef)(false);
11
11
  var previousHeight = (0, _react.useRef)();
12
12
  (0, _react.useEffect)(function () {
@@ -17,15 +17,9 @@ var useAutoResize = exports.useAutoResize = function useAutoResize(active, ref,
17
17
  isManualResize.current = true;
18
18
  return;
19
19
  }
20
- var style = getComputedStyle(ref.current);
21
- var lineHeight = parseInt(style.lineHeight, 10);
22
- var lineHeightInRem = lineHeight / ROOT_FONT_SIZE;
23
- var minAutoHeight = minAuto ? minAuto * lineHeightInRem : 0;
24
- ref.current.style.height = "".concat(minAutoHeight, "rem");
25
- var lines = Math.floor(ref.current.scrollHeight / lineHeight);
26
- var newScrollHeight = lines * lineHeightInRem;
27
- var maxAutoHeight = maxAuto ? maxAuto * lineHeightInRem : newScrollHeight;
28
- var newHeight = Math.min(newScrollHeight, maxAutoHeight);
20
+ ref.current.style.height = "".concat(minHeight ? minHeight + 1 : '0', "rem");
21
+ var scrollHeight = ref.current.scrollHeight / ROOT_FONT_SIZE;
22
+ var newHeight = Math.min(scrollHeight, maxHeight ? maxHeight + 1 : scrollHeight);
29
23
  ref.current.style.height = "".concat(newHeight, "rem");
30
24
  previousHeight.current = newHeight;
31
25
  }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,15 +1,9 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
1
  var _excluded = ["helperText", "status", "resize", "rightHelper", "leftHelper", "contentRight", "autoResize", "minAuto", "maxAuto", "label", "labelPlacement", "placeholder", "defaultValue", "height", "width", "value", "disabled", "size", "view", "id", "style", "className", "readOnly", "rows", "cols", "onChange"];
3
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
4
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
8
  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
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -141,17 +135,15 @@ export var textAreaRoot = function textAreaRoot(Root) {
141
135
  }
142
136
  onChange === null || onChange === void 0 || onChange(event);
143
137
  }, [value, onChange]);
144
- var dynamicLabelClasses = getDynamicLabelClasses(_objectSpread({
138
+ var dynamicLabelClasses = getDynamicLabelClasses({
145
139
  size: size,
146
140
  readOnly: readOnly,
147
141
  label: label,
148
142
  labelPlacement: labelPlacement,
143
+ autoResize: autoResize,
144
+ rows: rows,
149
145
  value: value || uncontrolledValue || defaultValue
150
- }, rows ? {
151
- rows: rows
152
- } : {
153
- autoResize: autoResize
154
- }), focused);
146
+ }, focused);
155
147
  return /*#__PURE__*/React.createElement(Root, {
156
148
  view: overriddenView,
157
149
  size: size,
@@ -11,7 +11,7 @@ import { PropsTable, Description } from '@site/src/components';
11
11
 
12
12
  ## Использование
13
13
  Компонент `TextArea` может содержать иконку (или кнопку) справа.
14
- Для этого используйте свойство `contentRight`:
14
+ Для этого используйте свойство и `contentRight`:
15
15
 
16
16
  ```tsx live
17
17
  import React from 'react';
@@ -31,55 +31,16 @@ export function App() {
31
31
  }
32
32
  ```
33
33
 
34
- ### Размеры компонента
35
- Высоту и ширину можно регулировать с помощью свойств `height` и `width`,
34
+ Также можно регулировать высоту и ширину, используя свойства `height` и `width`,
36
35
  указав значения в `rem` или соответствующие свойствам css значения.
37
- `height` и `width` отвечают за **всю** высоту и ширину компонента.
38
36
 
39
- ```tsx live
40
- import React from 'react';
41
- import { TextArea } from '@salutejs/{{ package }}';
42
-
43
- export function App() {
44
- return (
45
- <div>
46
- <TextArea
47
- placeholder="Введите значение"
48
- defaultValue="Значение"
49
- height={10}
50
- width={20}
51
- />
52
- </div>
53
- );
54
- }
55
- ```
56
-
57
- Свойства `rows` и `cols` указываются в абсолютных единицах, отвечают за фиксированное количество строк и столбцов.
58
-
59
- ```tsx live
60
- import React from 'react';
61
- import { TextArea } from '@salutejs/{{ package }}';
62
-
63
- export function App() {
64
- return (
65
- <div>
66
- <TextArea
67
- placeholder="Введите значение"
68
- defaultValue="Значение"
69
- rows={5}
70
- cols={20}
71
- />
72
- </div>
73
- );
74
- }
75
- ```
76
-
77
- ### Autoresize
37
+ ## Autoresize
78
38
  Также можно включить автоматическое регулирование высоты поля ввода по длине контента внутри (параметра `value`).
79
39
  Для этого необходимо использовать свойство `autoResize`.
80
40
  При этом, если пользователь вручную регулирует высоту(`resize`), то она так и остается пользовательской.
81
41
 
82
- Свойства `minAuto`, `maxAuto` указываются в абсолютных единицах и отвечают за минимальное и максимальное количество строк.
42
+ В этом режиме можно указать крайние значения высоты поля ввода, используя свойства `autoMin`, `autoMax`,
43
+ указав их в `rem`.
83
44
 
84
45
  ```tsx live
85
46
  import React from 'react';
@@ -124,4 +85,4 @@ export function App() {
124
85
  </div>
125
86
  );
126
87
  }
127
- ```
88
+ ```
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  export var ROOT_FONT_SIZE = 16;
3
- export var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto) {
3
+ export var useAutoResize = function useAutoResize(active, ref, value, minHeight, maxHeight) {
4
4
  var isManualResize = useRef(false);
5
5
  var previousHeight = useRef();
6
6
  useEffect(function () {
@@ -11,15 +11,9 @@ export var useAutoResize = function useAutoResize(active, ref, value, minAuto, m
11
11
  isManualResize.current = true;
12
12
  return;
13
13
  }
14
- var style = getComputedStyle(ref.current);
15
- var lineHeight = parseInt(style.lineHeight, 10);
16
- var lineHeightInRem = lineHeight / ROOT_FONT_SIZE;
17
- var minAutoHeight = minAuto ? minAuto * lineHeightInRem : 0;
18
- ref.current.style.height = "".concat(minAutoHeight, "rem");
19
- var lines = Math.floor(ref.current.scrollHeight / lineHeight);
20
- var newScrollHeight = lines * lineHeightInRem;
21
- var maxAutoHeight = maxAuto ? maxAuto * lineHeightInRem : newScrollHeight;
22
- var newHeight = Math.min(newScrollHeight, maxAutoHeight);
14
+ ref.current.style.height = "".concat(minHeight ? minHeight + 1 : '0', "rem");
15
+ var scrollHeight = ref.current.scrollHeight / ROOT_FONT_SIZE;
16
+ var newHeight = Math.min(scrollHeight, maxHeight ? maxHeight + 1 : scrollHeight);
23
17
  ref.current.style.height = "".concat(newHeight, "rem");
24
18
  previousHeight.current = newHeight;
25
19
  }
@@ -2,11 +2,11 @@ import React from 'react';
2
2
  import type { RootProps } from '../../engines/types';
3
3
  import type { TextAreaProps } from './TextArea.types';
4
4
  export declare const getDynamicLabelClasses: (props: TextAreaProps, focused: boolean) => (string | undefined)[];
5
- export declare const textAreaRoot: (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) => React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
5
+ export declare const textAreaRoot: (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) => React.ForwardRefExoticComponent<import("../../types").TextareaHTMLAttributes<HTMLTextAreaElement> & import("./TextArea.types").TextAreaPropsExtends & React.RefAttributes<HTMLTextAreaElement>>;
6
6
  export declare const textAreaConfig: {
7
7
  name: string;
8
8
  tag: string;
9
- layout: (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) => React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
9
+ layout: (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) => React.ForwardRefExoticComponent<import("../../types").TextareaHTMLAttributes<HTMLTextAreaElement> & import("./TextArea.types").TextAreaPropsExtends & React.RefAttributes<HTMLTextAreaElement>>;
10
10
  base: import("@linaria/core").LinariaClassName;
11
11
  variations: {
12
12
  size: {
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAK5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAmBrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AA6BtD,eAAO,MAAM,sBAAsB,UAAW,aAAa,WAAW,OAAO,2BA4B5E,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,UAAU,mBAAmB,EAAE,aAAa,CAAC,8FAiJ1E,CAAC;AAEP,eAAO,MAAM,cAAc;;;mBAnJQ,UAAU,mBAAmB,EAAE,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;CA2K/E,CAAC"}
1
+ {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAK5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAmBrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AA6BtD,eAAO,MAAM,sBAAsB,UAAW,aAAa,WAAW,OAAO,2BA4B5E,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,UAAU,mBAAmB,EAAE,aAAa,CAAC,oMAkJ1E,CAAC;AAEP,eAAO,MAAM,cAAc;;;mBApJQ,UAAU,mBAAmB,EAAE,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;CA4K/E,CAAC"}
@@ -1,52 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { TextareaHTMLAttributes } from '@salutejs/plasma-core';
3
- declare type Only<T, U, R> = {
4
- [P in keyof T]: T[P];
5
- } & {
6
- [P in keyof U]?: never;
7
- } & {
8
- [P in keyof R]?: never;
9
- };
10
- declare type OneOf<T, U, R> = Only<T, U, R> | Only<U, T, R> | Only<R, T, U>;
11
- export declare type TextAreaPropsAutoResize = {
12
- /**
13
- * Автоматическая высота поля ввода.
14
- */
15
- autoResize?: boolean;
16
- /**
17
- * Максимальная высота поля ввода в автоматическом режиме (в абсолютных единицах).
18
- * @example maxAuto="5", maxAuto={5}
19
- */
20
- maxAuto?: number;
21
- /**
22
- * Минимальная высота поля ввода в автоматическом режиме (в абсолютных единицах).
23
- * @example minAuto="5", minAuto={5}
24
- */
25
- minAuto?: number;
26
- };
27
- export declare type TextAreaPropsHeightWidth = {
28
- /**
29
- * Высота текстового поля, значения в rem. Отвечает за ВСЮ высоту компонента.
30
- * @example height="10", height={10}
31
- */
32
- height?: number | string;
33
- /**
34
- * Ширина текстового поля, значения в rem. Отвечает за ВСЮ ширину компонента.
35
- * @example width="10", width={10}
36
- */
37
- width?: number | string;
38
- };
39
- export declare type TextAreaPropsRowsCols = {
40
- /**
41
- * Высота текстового поля (в абсолютных единицах) – фиксированное число отображаемых строк без прокрутки.
42
- */
43
- rows?: number;
44
- /**
45
- * Ширина текстового поля (в абсолютных единицах) – фиксированное число столбцов.
46
- */
47
- cols?: number;
48
- };
49
- export declare type TextAreaDimensionsProps = OneOf<TextAreaPropsAutoResize, TextAreaPropsHeightWidth, TextAreaPropsRowsCols>;
2
+ import { TextareaHTMLAttributes } from '../../types';
50
3
  export interface TextAreaPropsBase {
51
4
  /**
52
5
  * Статус компонента: заполнен успешно / с предупреждением / с ошибкой.
@@ -70,6 +23,16 @@ export interface TextAreaPropsBase {
70
23
  * @deprecated устаревшее свойство
71
24
  */
72
25
  resize?: 'none' | 'both' | 'horizontal' | 'vertical';
26
+ /**
27
+ * Высота текстового поля, значения в rem
28
+ * @example height="10", height={10}
29
+ */
30
+ height?: number | string;
31
+ /**
32
+ * Ширина текстового поля, значения в rem
33
+ * @example width="10", width={10}
34
+ */
35
+ width?: number | string;
73
36
  /**
74
37
  * Вспомогательный текст снизу слева для поля ввода.
75
38
  * @deprecated свойство устарело, необходимо использовать `leftHelper`.
@@ -83,6 +46,18 @@ export interface TextAreaPropsBase {
83
46
  * Вспомогательный текст снизу справа для поля ввода.
84
47
  */
85
48
  rightHelper?: string;
49
+ /**
50
+ * Автоматическая высота поля ввода.
51
+ */
52
+ autoResize?: boolean;
53
+ /**
54
+ * Максимальная высота поля ввода в автоматическом режиме(в rem).
55
+ */
56
+ maxAuto?: number;
57
+ /**
58
+ * Минимальная высота поля ввода в автоматическом режиме(в rem).
59
+ */
60
+ minAuto?: number;
86
61
  }
87
62
  export interface TextAreaPropsExtends extends TextAreaPropsBase {
88
63
  /**
@@ -94,6 +69,5 @@ export interface TextAreaPropsExtends extends TextAreaPropsBase {
94
69
  */
95
70
  view?: string;
96
71
  }
97
- export declare type TextAreaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'rows' | 'cols'> & TextAreaPropsExtends & TextAreaDimensionsProps;
98
- export {};
72
+ export declare type TextAreaProps = TextareaHTMLAttributes<HTMLTextAreaElement> & TextAreaPropsExtends;
99
73
  //# sourceMappingURL=TextArea.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.types.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.types.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,aAAK,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI;KAChB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACvB,GACG;KACK,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK;CACzB,GACD;KACK,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK;CACzB,CAAC;AAEN,aAAK,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEp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;AAED,oBAAY,aAAa,GAAG,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,GAC1F,oBAAoB,GACpB,uBAAuB,CAAC"}
1
+ {"version":3,"file":"TextArea.types.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.types.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAC9B;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAC9C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACnC;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC;IACrD;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC3D;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,oBAAY,aAAa,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,GAAG,oBAAoB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import { MutableRefObject } from 'react';
2
2
  export declare const ROOT_FONT_SIZE = 16;
3
- export declare const useAutoResize: <T extends HTMLTextAreaElement>(active: boolean, ref: MutableRefObject<T | null>, value?: string | number | readonly string[] | undefined, minAuto?: number | undefined, maxAuto?: number | undefined) => void;
3
+ export declare const useAutoResize: <T extends HTMLTextAreaElement>(active: boolean, ref: MutableRefObject<T | null>, value?: string | number | readonly string[] | undefined, minHeight?: number | undefined, maxHeight?: number | undefined) => void;
4
4
  //# sourceMappingURL=useAutoResize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAutoResize.d.ts","sourceRoot":"","sources":["../../../../src/components/TextArea/hooks/useAutoResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE5D,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,eAAO,MAAM,aAAa,0CACd,OAAO,+JAoClB,CAAC"}
1
+ {"version":3,"file":"useAutoResize.d.ts","sourceRoot":"","sources":["../../../../src/components/TextArea/hooks/useAutoResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE5D,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,eAAO,MAAM,aAAa,0CACd,OAAO,mKA0BlB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { textAreaRoot, textAreaConfig } from './TextArea';
2
2
  export { tokens as textAreaTokens } from './TextArea.tokens';
3
+ export type { TextAreaProps } from './TextArea.types';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -15,35 +15,5 @@ export declare const TextArea: import("react").FunctionComponent<import("../../.
15
15
  disabled: {
16
16
  true: import("@linaria/core").LinariaClassName;
17
17
  };
18
- }> & ((Omit<import("@salutejs/plasma-core").TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "cols"> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & {
19
- autoResize?: boolean | undefined;
20
- maxAuto?: number | undefined;
21
- minAuto?: number | undefined;
22
- } & {
23
- height?: undefined;
24
- width?: undefined;
25
- } & {
26
- rows?: undefined;
27
- cols?: undefined;
28
- } & import("react").RefAttributes<HTMLTextAreaElement>) | (Omit<import("@salutejs/plasma-core").TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "cols"> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & {
29
- height?: string | number | undefined;
30
- width?: string | number | undefined;
31
- } & {
32
- autoResize?: undefined;
33
- maxAuto?: undefined;
34
- minAuto?: undefined;
35
- } & {
36
- rows?: undefined;
37
- cols?: undefined;
38
- } & import("react").RefAttributes<HTMLTextAreaElement>) | (Omit<import("@salutejs/plasma-core").TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "cols"> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & {
39
- rows?: number | undefined;
40
- cols?: number | undefined;
41
- } & {
42
- autoResize?: undefined;
43
- maxAuto?: undefined;
44
- minAuto?: undefined;
45
- } & {
46
- height?: undefined;
47
- width?: undefined;
48
- } & import("react").RefAttributes<HTMLTextAreaElement>))>;
18
+ }> & import("../../../../types").TextareaHTMLAttributes<HTMLTextAreaElement> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & import("react").RefAttributes<HTMLTextAreaElement>>;
49
19
  //# sourceMappingURL=TextArea.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../../../src/examples/plasma_b2c/components/TextArea/TextArea.ts"],"names":[],"mappings":";AAOA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDAA0B,CAAC"}
1
+ {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../../../src/examples/plasma_b2c/components/TextArea/TextArea.ts"],"names":[],"mappings":";AAOA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;kNAA0B,CAAC"}
@@ -15,35 +15,5 @@ export declare const TextArea: import("react").FunctionComponent<import("../../.
15
15
  disabled: {
16
16
  true: import("@linaria/core").LinariaClassName;
17
17
  };
18
- }> & ((Omit<import("@salutejs/plasma-core").TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "cols"> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & {
19
- autoResize?: boolean | undefined;
20
- maxAuto?: number | undefined;
21
- minAuto?: number | undefined;
22
- } & {
23
- height?: undefined;
24
- width?: undefined;
25
- } & {
26
- rows?: undefined;
27
- cols?: undefined;
28
- } & import("react").RefAttributes<HTMLTextAreaElement>) | (Omit<import("@salutejs/plasma-core").TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "cols"> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & {
29
- height?: string | number | undefined;
30
- width?: string | number | undefined;
31
- } & {
32
- autoResize?: undefined;
33
- maxAuto?: undefined;
34
- minAuto?: undefined;
35
- } & {
36
- rows?: undefined;
37
- cols?: undefined;
38
- } & import("react").RefAttributes<HTMLTextAreaElement>) | (Omit<import("@salutejs/plasma-core").TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "cols"> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & {
39
- rows?: number | undefined;
40
- cols?: number | undefined;
41
- } & {
42
- autoResize?: undefined;
43
- maxAuto?: undefined;
44
- minAuto?: undefined;
45
- } & {
46
- height?: undefined;
47
- width?: undefined;
48
- } & import("react").RefAttributes<HTMLTextAreaElement>))>;
18
+ }> & import("../../../../types").TextareaHTMLAttributes<HTMLTextAreaElement> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & import("react").RefAttributes<HTMLTextAreaElement>>;
49
19
  //# sourceMappingURL=TextArea.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../../../src/examples/plasma_web/components/TextArea/TextArea.ts"],"names":[],"mappings":";AAOA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDAA0B,CAAC"}
1
+ {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../../../src/examples/plasma_web/components/TextArea/TextArea.ts"],"names":[],"mappings":";AAOA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;kNAA0B,CAAC"}
@@ -12,35 +12,5 @@ export declare const TextArea: import("react").FunctionComponent<import("../../.
12
12
  disabled: {
13
13
  true: import("@linaria/core").LinariaClassName;
14
14
  };
15
- }> & ((Omit<import("@salutejs/plasma-core").TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "cols"> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & {
16
- autoResize?: boolean | undefined;
17
- maxAuto?: number | undefined;
18
- minAuto?: number | undefined;
19
- } & {
20
- height?: undefined;
21
- width?: undefined;
22
- } & {
23
- rows?: undefined;
24
- cols?: undefined;
25
- } & import("react").RefAttributes<HTMLTextAreaElement>) | (Omit<import("@salutejs/plasma-core").TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "cols"> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & {
26
- height?: string | number | undefined;
27
- width?: string | number | undefined;
28
- } & {
29
- autoResize?: undefined;
30
- maxAuto?: undefined;
31
- minAuto?: undefined;
32
- } & {
33
- rows?: undefined;
34
- cols?: undefined;
35
- } & import("react").RefAttributes<HTMLTextAreaElement>) | (Omit<import("@salutejs/plasma-core").TextareaHTMLAttributes<HTMLTextAreaElement>, "rows" | "cols"> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & {
36
- rows?: number | undefined;
37
- cols?: number | undefined;
38
- } & {
39
- autoResize?: undefined;
40
- maxAuto?: undefined;
41
- minAuto?: undefined;
42
- } & {
43
- height?: undefined;
44
- width?: undefined;
45
- } & import("react").RefAttributes<HTMLTextAreaElement>))>;
15
+ }> & import("../../../../types").TextareaHTMLAttributes<HTMLTextAreaElement> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & import("react").RefAttributes<HTMLTextAreaElement>>;
46
16
  //# sourceMappingURL=TextArea.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../../../src/examples/sds_engineer/components/TextArea/TextArea.ts"],"names":[],"mappings":";AAOA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDAA0B,CAAC"}
1
+ {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../../../src/examples/sds_engineer/components/TextArea/TextArea.ts"],"names":[],"mappings":";AAOA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;kNAA0B,CAAC"}
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { DisabledProps } from '../mixins';
3
+ export interface TextareaHTMLAttributes<T> extends DisabledProps, React.TextareaHTMLAttributes<T> {
4
+ autoComplete?: string;
5
+ autoFocus?: boolean;
6
+ cols?: number;
7
+ dirName?: string;
8
+ form?: string;
9
+ /**
10
+ * Минимальная длина значения поля
11
+ */
12
+ minLength?: number;
13
+ /**
14
+ * Максимальная длина значения поля
15
+ */
16
+ maxLength?: number;
17
+ /**
18
+ * Определяет уникальное имя элемента формы
19
+ */
20
+ name?: string;
21
+ /**
22
+ * Выводит текст внутри поля формы, который исчезает при получении фокуса
23
+ */
24
+ placeholder?: string;
25
+ /**
26
+ * Элемент формы не может изменяться пользователем
27
+ */
28
+ readOnly?: boolean;
29
+ /**
30
+ * Флаг обязательности поля
31
+ */
32
+ required?: boolean;
33
+ rows?: number;
34
+ /**
35
+ * Определяет значение элемента формы
36
+ */
37
+ value?: string | ReadonlyArray<string> | number;
38
+ wrap?: string;
39
+ /**
40
+ * Обработчик изменения элемента формы
41
+ */
42
+ onChange?: React.TextareaHTMLAttributes<T>['onChange'];
43
+ /**
44
+ * Обработчик фокуса на элементе формы
45
+ */
46
+ onFocus?: React.TextareaHTMLAttributes<T>['onFocus'];
47
+ /**
48
+ * Обработчик блюра на элементе формы
49
+ */
50
+ onBlur?: React.TextareaHTMLAttributes<T>['onBlur'];
51
+ }
52
+ //# sourceMappingURL=TextareaHTMLAttributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextareaHTMLAttributes.d.ts","sourceRoot":"","sources":["../../src/types/TextareaHTMLAttributes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,WAAW,sBAAsB,CAAC,CAAC,CAAE,SAAQ,aAAa,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;IAC7F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACvD;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACrD;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CACtD"}
@@ -1,4 +1,5 @@
1
1
  export type { AsProps } from './AsProps';
2
2
  export type { NumericRange, CreateArrayWithLengthX } from './Range';
3
3
  export type { InputHTMLAttributes } from './InputHTMLAttributes';
4
+ export type { TextareaHTMLAttributes } from './TextareaHTMLAttributes';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACpE,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACpE,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}