@salutejs/plasma-new-hope 0.91.1-canary.1265.9664294667.0 → 0.92.0-canary.1252.9663899697.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/cjs/components/Segment/SegmentProvider/SegmentProvider.js +4 -1
  2. package/cjs/components/Segment/SegmentProvider/SegmentProvider.js.map +1 -1
  3. package/cjs/components/Segment/ui/SegmentGroup/SegmentGroup.js +9 -2
  4. package/cjs/components/Segment/ui/SegmentGroup/SegmentGroup.js.map +1 -1
  5. package/cjs/components/TextArea/TextArea.js +4 -6
  6. package/cjs/components/TextArea/TextArea.js.map +1 -1
  7. package/cjs/components/TextArea/hooks/useAutoResize.js +4 -10
  8. package/cjs/components/TextArea/hooks/useAutoResize.js.map +1 -1
  9. package/es/components/Segment/SegmentProvider/SegmentProvider.js +4 -1
  10. package/es/components/Segment/SegmentProvider/SegmentProvider.js.map +1 -1
  11. package/es/components/Segment/ui/SegmentGroup/SegmentGroup.js +9 -2
  12. package/es/components/Segment/ui/SegmentGroup/SegmentGroup.js.map +1 -1
  13. package/es/components/TextArea/TextArea.js +5 -7
  14. package/es/components/TextArea/TextArea.js.map +1 -1
  15. package/es/components/TextArea/hooks/useAutoResize.js +4 -10
  16. package/es/components/TextArea/hooks/useAutoResize.js.map +1 -1
  17. package/package.json +2 -2
  18. package/styled-components/cjs/components/Segment/Segment.template-doc.mdx +6 -1
  19. package/styled-components/cjs/components/Segment/SegmentProvider/SegmentProvider.js +4 -1
  20. package/styled-components/cjs/components/Segment/ui/SegmentGroup/SegmentGroup.js +9 -2
  21. package/styled-components/cjs/components/TextArea/TextArea.js +4 -11
  22. package/styled-components/cjs/components/TextArea/TextArea.template-doc.mdx +6 -45
  23. package/styled-components/cjs/components/TextArea/hooks/useAutoResize.js +4 -10
  24. package/styled-components/es/components/Segment/Segment.template-doc.mdx +6 -1
  25. package/styled-components/es/components/Segment/SegmentProvider/SegmentProvider.js +4 -1
  26. package/styled-components/es/components/Segment/ui/SegmentGroup/SegmentGroup.js +9 -2
  27. package/styled-components/es/components/TextArea/TextArea.js +4 -12
  28. package/styled-components/es/components/TextArea/TextArea.template-doc.mdx +6 -45
  29. package/styled-components/es/components/TextArea/hooks/useAutoResize.js +4 -10
  30. package/types/components/Segment/SegmentProvider/SegmentProvider.d.ts.map +1 -1
  31. package/types/components/Segment/SegmentProvider/SegmentProvider.types.d.ts +4 -3
  32. package/types/components/Segment/SegmentProvider/SegmentProvider.types.d.ts.map +1 -1
  33. package/types/components/Segment/ui/SegmentGroup/SegmentGroup.d.ts +2 -0
  34. package/types/components/Segment/ui/SegmentGroup/SegmentGroup.d.ts.map +1 -1
  35. package/types/components/Segment/ui/SegmentGroup/SegmentGroup.types.d.ts +5 -0
  36. package/types/components/Segment/ui/SegmentGroup/SegmentGroup.types.d.ts.map +1 -1
  37. package/types/components/TextArea/TextArea.d.ts +2 -2
  38. package/types/components/TextArea/TextArea.d.ts.map +1 -1
  39. package/types/components/TextArea/TextArea.types.d.ts +23 -49
  40. package/types/components/TextArea/TextArea.types.d.ts.map +1 -1
  41. package/types/components/TextArea/hooks/useAutoResize.d.ts +1 -1
  42. package/types/components/TextArea/hooks/useAutoResize.d.ts.map +1 -1
  43. package/types/examples/plasma_b2c/components/Segment/Segment.d.ts +1 -0
  44. package/types/examples/plasma_b2c/components/Segment/Segment.d.ts.map +1 -1
  45. package/types/examples/plasma_b2c/components/TextArea/TextArea.d.ts +1 -31
  46. package/types/examples/plasma_b2c/components/TextArea/TextArea.d.ts.map +1 -1
  47. package/types/examples/plasma_web/components/Segment/Segment.d.ts +1 -0
  48. package/types/examples/plasma_web/components/Segment/Segment.d.ts.map +1 -1
  49. package/types/examples/plasma_web/components/TextArea/TextArea.d.ts +1 -31
  50. package/types/examples/plasma_web/components/TextArea/TextArea.d.ts.map +1 -1
  51. package/types/examples/sds_engineer/components/Segment/Segment.d.ts +1 -0
  52. package/types/examples/sds_engineer/components/Segment/Segment.d.ts.map +1 -1
  53. package/types/examples/sds_engineer/components/TextArea/TextArea.d.ts +1 -31
  54. package/types/examples/sds_engineer/components/TextArea/TextArea.d.ts.map +1 -1
@@ -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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C,iBAAkB;AAC7B4G,MAAAA,OAAO,EAAElE,EAAAA;KAER4B,EAAAA,UACc,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;A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,GAAG;AACTyB,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;"}
@@ -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,GA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}
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,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.1-canary.1265.9664294667.0",
3
+ "version": "0.92.0-canary.1252.9663899697.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": "12f9c757e5fa78b4f33b8d8afd4d9f83454bd8c9"
108
+ "gitHead": "9f089493138ac54e1c09864574b2564ec0f8e2dd"
109
109
  }
@@ -24,6 +24,11 @@ import { PropsTable, Description } from '@site/src/components';
24
24
  Оберните в `SegmentProvider` компонент, в котором будут использованы SegmentGroup с SegmentItem.
25
25
  Внутри данного провайдера есть доступ к хуку `useSegment`.
26
26
 
27
+ ### Выбранные по умолчанию SegmentItem
28
+
29
+ Можно задать выбранные по умолчанию сегменты с помощью свойства `defaultSelected`.
30
+ Оно передается в `SegmentGroup`, в виде массива `value` элеметов.
31
+
27
32
  ```tsx live
28
33
  import React from 'react';
29
34
  import { SegmentGroup, SegmentItem, SegmentProvider, useSegment } from '@salutejs/{{ package }}';
@@ -37,7 +42,7 @@ export function App() {
37
42
  return (
38
43
  <>
39
44
  <div>Выбранные элементы: {selectedSegmentItems.join(', ')}</div>
40
- <SegmentGroup view='filled' selectionMode='multiple' filledBackground pilled>
45
+ <SegmentGroup defaultSelected={['label_1']} view='filled' selectionMode='multiple' filledBackground pilled>
41
46
  {items.map((_, i) => (
42
47
  <SegmentItem
43
48
  label={`Label ${i}`}
@@ -62,6 +62,7 @@ var SegmentProvider = exports.SegmentProvider = function SegmentProvider(_ref) {
62
62
  }, [selectionMode, setSelectedSegmentItems]);
63
63
  var contextValue = {
64
64
  selectedSegmentItems: selectedSegmentItems,
65
+ setSelectedSegmentItems: setSelectedSegmentItems,
65
66
  handleSelect: handleSelect,
66
67
  selectionMode: selectionMode,
67
68
  setSelectionMode: setSelectionMode,
@@ -69,7 +70,9 @@ var SegmentProvider = exports.SegmentProvider = function SegmentProvider(_ref) {
69
70
  setDisabledGroup: setDisabledGroup
70
71
  };
71
72
  (0, _react.useEffect)(function () {
72
- setSelectedSegmentItems([]);
73
+ if (selectionMode === 'single' && (selectedSegmentItems === null || selectedSegmentItems === void 0 ? void 0 : selectedSegmentItems.length) > 0) {
74
+ setSelectedSegmentItems([selectedSegmentItems[0]]);
75
+ }
73
76
  }, [selectionMode]);
74
77
  return /*#__PURE__*/_react["default"].createElement(SegmentContext.Provider, {
75
78
  value: contextValue
@@ -18,7 +18,7 @@ var _base4 = /*#__PURE__*/require("./variations/_pilled/base");
18
18
  var _base5 = /*#__PURE__*/require("./variations/_filledBackgound/base");
19
19
  var _base6 = /*#__PURE__*/require("./variations/_stretch/base");
20
20
  var _SegmentGroup = /*#__PURE__*/require("./SegmentGroup.styles");
21
- var _excluded = ["id", "selectionMode", "pilled", "stretch", "filledBackground", "disabled", "size", "view", "children"];
21
+ var _excluded = ["id", "selectionMode", "pilled", "stretch", "filledBackground", "disabled", "size", "view", "children", "defaultSelected"];
22
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
23
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
24
24
  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); }
@@ -43,10 +43,12 @@ var segmentGroupRoot = exports.segmentGroupRoot = function segmentGroupRoot(Root
43
43
  size = props.size,
44
44
  view = props.view,
45
45
  children = props.children,
46
+ defaultSelected = props.defaultSelected,
46
47
  rest = _objectWithoutProperties(props, _excluded);
47
48
  var _useSegmentInner = (0, _SegmentProvider.useSegmentInner)(),
48
49
  setSelectionMode = _useSegmentInner.setSelectionMode,
49
- setDisabledGroup = _useSegmentInner.setDisabledGroup;
50
+ setDisabledGroup = _useSegmentInner.setDisabledGroup,
51
+ setSelectedSegmentItems = _useSegmentInner.setSelectedSegmentItems;
50
52
  var _useState = (0, _react.useState)(0),
51
53
  _useState2 = _slicedToArray(_useState, 2),
52
54
  index = _useState2[0],
@@ -130,6 +132,11 @@ var segmentGroupRoot = exports.segmentGroupRoot = function segmentGroupRoot(Root
130
132
  selectionMode && setSelectionMode(selectionMode);
131
133
  setDisabledGroup(disabled);
132
134
  }, [selectionMode, disabled]);
135
+ (0, _react.useEffect)(function () {
136
+ if (defaultSelected !== null && defaultSelected !== void 0 && defaultSelected.length) {
137
+ setSelectedSegmentItems(defaultSelected);
138
+ }
139
+ }, [defaultSelected]);
133
140
  (0, _react.useEffect)(function () {
134
141
  var _trackRef$current;
135
142
  // Intersection observer для первого сегмента
@@ -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
  }
@@ -24,6 +24,11 @@ import { PropsTable, Description } from '@site/src/components';
24
24
  Оберните в `SegmentProvider` компонент, в котором будут использованы SegmentGroup с SegmentItem.
25
25
  Внутри данного провайдера есть доступ к хуку `useSegment`.
26
26
 
27
+ ### Выбранные по умолчанию SegmentItem
28
+
29
+ Можно задать выбранные по умолчанию сегменты с помощью свойства `defaultSelected`.
30
+ Оно передается в `SegmentGroup`, в виде массива `value` элеметов.
31
+
27
32
  ```tsx live
28
33
  import React from 'react';
29
34
  import { SegmentGroup, SegmentItem, SegmentProvider, useSegment } from '@salutejs/{{ package }}';
@@ -37,7 +42,7 @@ export function App() {
37
42
  return (
38
43
  <>
39
44
  <div>Выбранные элементы: {selectedSegmentItems.join(', ')}</div>
40
- <SegmentGroup view='filled' selectionMode='multiple' filledBackground pilled>
45
+ <SegmentGroup defaultSelected={['label_1']} view='filled' selectionMode='multiple' filledBackground pilled>
41
46
  {items.map((_, i) => (
42
47
  <SegmentItem
43
48
  label={`Label ${i}`}
@@ -53,6 +53,7 @@ export var SegmentProvider = function SegmentProvider(_ref) {
53
53
  }, [selectionMode, setSelectedSegmentItems]);
54
54
  var contextValue = {
55
55
  selectedSegmentItems: selectedSegmentItems,
56
+ setSelectedSegmentItems: setSelectedSegmentItems,
56
57
  handleSelect: handleSelect,
57
58
  selectionMode: selectionMode,
58
59
  setSelectionMode: setSelectionMode,
@@ -60,7 +61,9 @@ export var SegmentProvider = function SegmentProvider(_ref) {
60
61
  setDisabledGroup: setDisabledGroup
61
62
  };
62
63
  useEffect(function () {
63
- setSelectedSegmentItems([]);
64
+ if (selectionMode === 'single' && (selectedSegmentItems === null || selectedSegmentItems === void 0 ? void 0 : selectedSegmentItems.length) > 0) {
65
+ setSelectedSegmentItems([selectedSegmentItems[0]]);
66
+ }
64
67
  }, [selectionMode]);
65
68
  return /*#__PURE__*/React.createElement(SegmentContext.Provider, {
66
69
  value: contextValue
@@ -1,4 +1,4 @@
1
- var _excluded = ["id", "selectionMode", "pilled", "stretch", "filledBackground", "disabled", "size", "view", "children"];
1
+ var _excluded = ["id", "selectionMode", "pilled", "stretch", "filledBackground", "disabled", "size", "view", "children", "defaultSelected"];
2
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); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  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,10 +34,12 @@ export var segmentGroupRoot = function segmentGroupRoot(Root) {
34
34
  size = props.size,
35
35
  view = props.view,
36
36
  children = props.children,
37
+ defaultSelected = props.defaultSelected,
37
38
  rest = _objectWithoutProperties(props, _excluded);
38
39
  var _useSegmentInner = useSegmentInner(),
39
40
  setSelectionMode = _useSegmentInner.setSelectionMode,
40
- setDisabledGroup = _useSegmentInner.setDisabledGroup;
41
+ setDisabledGroup = _useSegmentInner.setDisabledGroup,
42
+ setSelectedSegmentItems = _useSegmentInner.setSelectedSegmentItems;
41
43
  var _useState = useState(0),
42
44
  _useState2 = _slicedToArray(_useState, 2),
43
45
  index = _useState2[0],
@@ -121,6 +123,11 @@ export var segmentGroupRoot = function segmentGroupRoot(Root) {
121
123
  selectionMode && setSelectionMode(selectionMode);
122
124
  setDisabledGroup(disabled);
123
125
  }, [selectionMode, disabled]);
126
+ useEffect(function () {
127
+ if (defaultSelected !== null && defaultSelected !== void 0 && defaultSelected.length) {
128
+ setSelectedSegmentItems(defaultSelected);
129
+ }
130
+ }, [defaultSelected]);
124
131
  useEffect(function () {
125
132
  var _trackRef$current;
126
133
  // Intersection observer для первого сегмента
@@ -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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAC3F,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAwB,MAAM,yBAAyB,CAAC;AAEnF,eAAO,MAAM,cAAc,+CAA2D,CAAC;AAEvF,eAAO,MAAM,eAAe,0BAM3B,CAAC;AAEF,eAAO,MAAM,UAAU;;CAGtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,iBAAiB,CAiCjD,CAAC"}
1
+ {"version":3,"file":"SegmentProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAC3F,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAwB,MAAM,yBAAyB,CAAC;AAEnF,eAAO,MAAM,cAAc,+CAA2D,CAAC;AAEvF,eAAO,MAAM,eAAe,0BAM3B,CAAC;AAEF,eAAO,MAAM,UAAU;;CAGtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,iBAAiB,CAoCjD,CAAC"}