@salutejs/plasma-new-hope 0.92.0-canary.1253.9663882094.0 → 0.92.0-canary.1261.9663085538.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/cjs/components/Range/Range.css +6 -6
  2. package/cjs/components/Slider/Slider.css +6 -6
  3. package/cjs/components/Slider/components/Double/Double.css +6 -6
  4. package/cjs/components/TextArea/TextArea.js +6 -4
  5. package/cjs/components/TextArea/TextArea.js.map +1 -1
  6. package/cjs/components/TextArea/hooks/useAutoResize.js +10 -4
  7. package/cjs/components/TextArea/hooks/useAutoResize.js.map +1 -1
  8. package/cjs/components/TextField/TextField.styles.js +1 -1
  9. package/cjs/components/TextField/TextField.styles.js.map +1 -1
  10. package/cjs/components/TextField/{TextField.styles_9fkr1l.css → TextField.styles_aqmut.css} +2 -2
  11. package/cjs/index.css +6 -6
  12. package/es/components/Range/Range.css +6 -6
  13. package/es/components/Slider/Slider.css +6 -6
  14. package/es/components/Slider/components/Double/Double.css +6 -6
  15. package/es/components/TextArea/TextArea.js +7 -5
  16. package/es/components/TextArea/TextArea.js.map +1 -1
  17. package/es/components/TextArea/hooks/useAutoResize.js +10 -4
  18. package/es/components/TextArea/hooks/useAutoResize.js.map +1 -1
  19. package/es/components/TextField/TextField.styles.js +1 -1
  20. package/es/components/TextField/TextField.styles.js.map +1 -1
  21. package/es/components/TextField/{TextField.styles_9fkr1l.css → TextField.styles_aqmut.css} +2 -2
  22. package/es/index.css +6 -6
  23. package/package.json +2 -2
  24. package/styled-components/cjs/components/TextArea/TextArea.js +11 -4
  25. package/styled-components/cjs/components/TextArea/TextArea.template-doc.mdx +45 -6
  26. package/styled-components/cjs/components/TextArea/hooks/useAutoResize.js +10 -4
  27. package/styled-components/cjs/components/TextField/TextField.styles.js +2 -2
  28. package/styled-components/es/components/TextArea/TextArea.js +12 -4
  29. package/styled-components/es/components/TextArea/TextArea.template-doc.mdx +45 -6
  30. package/styled-components/es/components/TextArea/hooks/useAutoResize.js +10 -4
  31. package/styled-components/es/components/TextField/TextField.styles.js +2 -2
  32. package/types/components/TextArea/TextArea.d.ts +2 -2
  33. package/types/components/TextArea/TextArea.d.ts.map +1 -1
  34. package/types/components/TextArea/TextArea.types.d.ts +49 -23
  35. package/types/components/TextArea/TextArea.types.d.ts.map +1 -1
  36. package/types/components/TextArea/hooks/useAutoResize.d.ts +1 -1
  37. package/types/components/TextArea/hooks/useAutoResize.d.ts.map +1 -1
  38. package/types/components/TextField/TextField.styles.d.ts.map +1 -1
  39. package/types/examples/plasma_b2c/components/TextArea/TextArea.d.ts +31 -1
  40. package/types/examples/plasma_b2c/components/TextArea/TextArea.d.ts.map +1 -1
  41. package/types/examples/plasma_web/components/TextArea/TextArea.d.ts +31 -1
  42. package/types/examples/plasma_web/components/TextArea/TextArea.d.ts.map +1 -1
  43. package/types/examples/sds_engineer/components/TextArea/TextArea.d.ts +31 -1
  44. package/types/examples/sds_engineer/components/TextArea/TextArea.d.ts.map +1 -1
@@ -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 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;;;;"}
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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AC/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,4 +1,4 @@
1
- import './TextField.styles_9fkr1l.css';
1
+ import './TextField.styles_aqmut.css';
2
2
  import { styled } from '@linaria/react';
3
3
 
4
4
  var InputWrapper = /*#__PURE__*/styled('div')({
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.styles.js","sources":["../../../src/components/TextField/TextField.styles.ts"],"sourcesContent":["import { styled } from '@linaria/react';\n\nimport { classes, tokens } from './TextField.tokens';\n\nexport const InputWrapper = styled.div`\n position: relative;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n`;\n\nexport const InputLabelWrapper = styled.div`\n flex: 1;\n overflow: scroll;\n position: relative;\n width: 100%;\n display: inline-flex;\n align-items: center;\n\n ::-webkit-scrollbar {\n display: none;\n }\n\n scrollbar-width: none;\n\n overscroll-behavior: contain;\n\n &.${String(classes.hasChips)} {\n height: var(${tokens.chipHeight});\n border-radius: var(${tokens.chipBorderRadius});\n }\n`;\n\nexport const StyledChips = styled.div`\n display: flex;\n gap: var(${tokens.chipGap});\n margin-right: var(${tokens.chipGap});\n user-select: none;\n`;\n\nexport const Input = styled.input`\n box-sizing: border-box;\n appearance: none;\n border: 0;\n padding: 0;\n background-color: transparent;\n outline: none;\n flex: 1;\n min-width: 60%;\n`;\n\nexport const Label = styled.label``;\n\nexport const StyledContentLeft = styled.div`\n margin: var(${tokens.leftContentMargin});\n line-height: 0;\n`;\n\nexport const StyledContentRight = styled.div`\n margin: var(${tokens.rightContentMargin});\n line-height: 0;\n`;\n\nexport const LeftHelper = styled.div``;\n\nexport const StyledTextBefore = styled.div``;\n\nexport const StyledTextAfter = styled.div``;\n"],"names":["InputWrapper","styled","name","class","propsAsIs","InputLabelWrapper","StyledChips","Input","Label","StyledContentLeft","StyledContentRight","LeftHelper","StyledTextBefore","StyledTextAfter"],"mappings":";;AAIO,IAAMA,YAAY,gBAAGC,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,cAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAKjC,EAAA;AAEM,IAAMC,iBAAiB,gBAAGJ,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,mBAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAoBtC,EAAA;AAEM,IAAME,WAAW,gBAAGL,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,aAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAKhC,EAAA;AAEM,IAAMG,KAAK,gBAAGN,MAAM,CAAA,OAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,OAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAS1B,EAAA;AAEM,IAAMI,KAAK,gBAAGP,MAAM,CAAA,OAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,OAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAAQ,EAAA;AAE5B,IAAMK,iBAAiB,gBAAGR,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,mBAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAGtC,EAAA;AAEM,IAAMM,kBAAkB,gBAAGT,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,oBAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAGvC,EAAA;AAEM,IAAMO,UAAU,gBAAGV,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,YAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAAM,EAAA;AAE/B,IAAMQ,gBAAgB,gBAAGX,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,kBAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAAM,EAAA;AAErC,IAAMS,eAAe,gBAAGZ,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,iBAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAAM;;;;"}
1
+ {"version":3,"file":"TextField.styles.js","sources":["../../../src/components/TextField/TextField.styles.ts"],"sourcesContent":["import { styled } from '@linaria/react';\n\nimport { classes, tokens } from './TextField.tokens';\n\nexport const InputWrapper = styled.div`\n position: relative;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n`;\n\nexport const InputLabelWrapper = styled.div`\n flex: 1;\n overflow: scroll;\n position: relative;\n width: 100%;\n display: inline-flex;\n align-items: center;\n\n ::-webkit-scrollbar {\n display: none;\n }\n\n scrollbar-width: none;\n\n overscroll-behavior: contain;\n\n &.${String(classes.hasChips)} {\n height: var(${tokens.chipHeight});\n border-radius: var(${tokens.chipBorderRadius});\n }\n`;\n\nexport const StyledChips = styled.div`\n display: flex;\n gap: var(${tokens.chipGap});\n margin-right: var(${tokens.chipGap});\n user-select: none;\n`;\n\nexport const Input = styled.input`\n box-sizing: border-box;\n appearance: none;\n border: 0;\n padding: 0;\n background-color: transparent;\n outline: none;\n flex: 1;\n min-width: 60%;\n`;\n\nexport const Label = styled.label``;\n\nexport const StyledContentLeft = styled.div`\n margin: var(${tokens.leftContentMargin});\n`;\n\nexport const StyledContentRight = styled.div`\n margin: var(${tokens.rightContentMargin});\n`;\n\nexport const LeftHelper = styled.div``;\n\nexport const StyledTextBefore = styled.div``;\n\nexport const StyledTextAfter = styled.div``;\n"],"names":["InputWrapper","styled","name","class","propsAsIs","InputLabelWrapper","StyledChips","Input","Label","StyledContentLeft","StyledContentRight","LeftHelper","StyledTextBefore","StyledTextAfter"],"mappings":";;AAIO,IAAMA,YAAY,gBAAGC,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,cAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAKjC,EAAA;AAEM,IAAMC,iBAAiB,gBAAGJ,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,mBAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAoBtC,EAAA;AAEM,IAAME,WAAW,gBAAGL,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,aAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAKhC,EAAA;AAEM,IAAMG,KAAK,gBAAGN,MAAM,CAAA,OAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,OAA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;gap:var(--plasma-textfield__chip-gap);margin-right:var(--plasma-textfield__chip-gap);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}
4
4
  .io4bpie{box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;padding:0;background-color:transparent;outline:none;-webkit-flex:1;-ms-flex:1;flex:1;min-width:60%;}
5
5
 
6
- .s19ry60d{margin:var(--plasma-textfield__left-content-margin);line-height:0;}
7
- .sbt1ohz{margin:var(--plasma-textfield__right-content-margin);line-height:0;}
6
+ .s19ry60d{margin:var(--plasma-textfield__left-content-margin);}
7
+ .sbt1ohz{margin:var(--plasma-textfield__right-content-margin);}
8
8
 
9
9
 
10
10
 
package/es/index.css CHANGED
@@ -128,13 +128,13 @@
128
128
 
129
129
  .base_134hshp_b1w985rt__3851a304[readonly] .base_134hshp_iq39zt5__3851a304{color:var(--plasma-textfield-color-readonly);background-color:var(--plasma-textfield-bg-color-readonly);box-shadow:inset 0 0 0 var(--plasmas-textfield-border-width) var(--plasma-textfield-border-color-readonly);}.base_134hshp_b1w985rt__3851a304[readonly] .base_134hshp_iq39zt5__3851a304:hover{background-color:var(--plasma-textfield-bg-color-readonly);}.base_134hshp_b1w985rt__3851a304[readonly] .base_134hshp_io4bpie__3851a304::-webkit-input-placeholder{color:var(--plasma-textfield__placeholder-color-readonly);}.base_134hshp_b1w985rt__3851a304[readonly] .base_134hshp_io4bpie__3851a304::-moz-placeholder{color:var(--plasma-textfield__placeholder-color-readonly);}.base_134hshp_b1w985rt__3851a304[readonly] .base_134hshp_io4bpie__3851a304:-ms-input-placeholder{color:var(--plasma-textfield__placeholder-color-readonly);}.base_134hshp_b1w985rt__3851a304[readonly] .base_134hshp_io4bpie__3851a304::placeholder{color:var(--plasma-textfield__placeholder-color-readonly);}.base_134hshp_b1w985rt__3851a304[readonly] .base_134hshp_io4bpie__3851a304{color:var(--plasma-textfield-color-readonly);cursor:default;min-width:unset;}.base_134hshp_b1w985rt__3851a304[readonly] .base_134hshp_llv9av6__3851a304{color:var(--plasma-textfield__left-helper-color-readonly);}.base_134hshp_b1w985rt__3851a304[readonly] .base_134hshp_l13qvwoy__3851a304{color:var(--plasma-textfield__label-color-readonly);}
130
130
 
131
- .TextField_styles_9fkr1l_iq39zt5__db7f1e30{position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;box-sizing:border-box;}
132
- .TextField_styles_9fkr1l_i1j28rg8__db7f1e30{-webkit-flex:1;-ms-flex:1;flex:1;overflow:scroll;position:relative;width:100%;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-scrollbar-width:none;-moz-scrollbar-width:none;-ms-scrollbar-width:none;scrollbar-width:none;overscroll-behavior:contain;}.TextField_styles_9fkr1l_i1j28rg8__db7f1e30::-webkit-scrollbar{display:none;}.TextField_styles_9fkr1l_i1j28rg8__db7f1e30.TextField_styles_9fkr1l_hasChips__db7f1e30{height:var(--plasma-textfield__chip-height);border-radius:var(--plasma-textfield__chip-border-radius);}
133
- .TextField_styles_9fkr1l_s13zudoe__db7f1e30{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:var(--plasma-textfield__chip-gap);margin-right:var(--plasma-textfield__chip-gap);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}
134
- .TextField_styles_9fkr1l_io4bpie__db7f1e30{box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;padding:0;background-color:transparent;outline:none;-webkit-flex:1;-ms-flex:1;flex:1;min-width:60%;}
131
+ .TextField_styles_aqmut_iq39zt5__4a8fddcd{position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;box-sizing:border-box;}
132
+ .TextField_styles_aqmut_i1j28rg8__4a8fddcd{-webkit-flex:1;-ms-flex:1;flex:1;overflow:scroll;position:relative;width:100%;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-scrollbar-width:none;-moz-scrollbar-width:none;-ms-scrollbar-width:none;scrollbar-width:none;overscroll-behavior:contain;}.TextField_styles_aqmut_i1j28rg8__4a8fddcd::-webkit-scrollbar{display:none;}.TextField_styles_aqmut_i1j28rg8__4a8fddcd.TextField_styles_aqmut_hasChips__4a8fddcd{height:var(--plasma-textfield__chip-height);border-radius:var(--plasma-textfield__chip-border-radius);}
133
+ .TextField_styles_aqmut_s13zudoe__4a8fddcd{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:var(--plasma-textfield__chip-gap);margin-right:var(--plasma-textfield__chip-gap);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}
134
+ .TextField_styles_aqmut_io4bpie__4a8fddcd{box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;padding:0;background-color:transparent;outline:none;-webkit-flex:1;-ms-flex:1;flex:1;min-width:60%;}
135
135
 
136
- .TextField_styles_9fkr1l_s19ry60d__db7f1e30{margin:var(--plasma-textfield__left-content-margin);line-height:0;}
137
- .TextField_styles_9fkr1l_sbt1ohz__db7f1e30{margin:var(--plasma-textfield__right-content-margin);line-height:0;}
136
+ .TextField_styles_aqmut_s19ry60d__4a8fddcd{margin:var(--plasma-textfield__left-content-margin);}
137
+ .TextField_styles_aqmut_sbt1ohz__4a8fddcd{margin:var(--plasma-textfield__right-content-margin);}
138
138
 
139
139
 
140
140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salutejs/plasma-new-hope",
3
- "version": "0.92.0-canary.1253.9663882094.0",
3
+ "version": "0.92.0-canary.1261.9663085538.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": "3390b7f8316c5430032acf2c64f589eef46a3b1e"
108
+ "gitHead": "4275dec0ca7abf4f61501a6aedcac2197cddac85"
109
109
  }
@@ -24,6 +24,11 @@ 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); }
27
32
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
28
33
  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."); }
29
34
  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); }
@@ -144,15 +149,17 @@ var textAreaRoot = exports.textAreaRoot = function textAreaRoot(Root) {
144
149
  }
145
150
  onChange === null || onChange === void 0 || onChange(event);
146
151
  }, [value, onChange]);
147
- var dynamicLabelClasses = getDynamicLabelClasses({
152
+ var dynamicLabelClasses = getDynamicLabelClasses(_objectSpread({
148
153
  size: size,
149
154
  readOnly: readOnly,
150
155
  label: label,
151
156
  labelPlacement: labelPlacement,
152
- autoResize: autoResize,
153
- rows: rows,
154
157
  value: value || uncontrolledValue || defaultValue
155
- }, focused);
158
+ }, rows ? {
159
+ rows: rows
160
+ } : {
161
+ autoResize: autoResize
162
+ }), focused);
156
163
  return /*#__PURE__*/_react["default"].createElement(Root, {
157
164
  view: overriddenView,
158
165
  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,16 +31,55 @@ export function App() {
31
31
  }
32
32
  ```
33
33
 
34
- Также можно регулировать высоту и ширину, используя свойства `height` и `width`,
34
+ ### Размеры компонента
35
+ Высоту и ширину можно регулировать с помощью свойств `height` и `width`,
35
36
  указав значения в `rem` или соответствующие свойствам css значения.
37
+ `height` и `width` отвечают за **всю** высоту и ширину компонента.
36
38
 
37
- ## Autoresize
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
38
78
  Также можно включить автоматическое регулирование высоты поля ввода по длине контента внутри (параметра `value`).
39
79
  Для этого необходимо использовать свойство `autoResize`.
40
80
  При этом, если пользователь вручную регулирует высоту(`resize`), то она так и остается пользовательской.
41
81
 
42
- В этом режиме можно указать крайние значения высоты поля ввода, используя свойства `autoMin`, `autoMax`,
43
- указав их в `rem`.
82
+ Свойства `minAuto`, `maxAuto` указываются в абсолютных единицах и отвечают за минимальное и максимальное количество строк.
44
83
 
45
84
  ```tsx live
46
85
  import React from 'react';
@@ -85,4 +124,4 @@ export function App() {
85
124
  </div>
86
125
  );
87
126
  }
88
- ```
127
+ ```
@@ -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, minHeight, maxHeight) {
9
+ var useAutoResize = exports.useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto) {
10
10
  var isManualResize = (0, _react.useRef)(false);
11
11
  var previousHeight = (0, _react.useRef)();
12
12
  (0, _react.useEffect)(function () {
@@ -17,9 +17,15 @@ var useAutoResize = exports.useAutoResize = function useAutoResize(active, ref,
17
17
  isManualResize.current = true;
18
18
  return;
19
19
  }
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);
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);
23
29
  ref.current.style.height = "".concat(newHeight, "rem");
24
30
  previousHeight.current = newHeight;
25
31
  }
@@ -24,10 +24,10 @@ var Label = exports.Label = /*#__PURE__*/_styledComponents["default"].label.with
24
24
  })([""]);
25
25
  var StyledContentLeft = exports.StyledContentLeft = /*#__PURE__*/_styledComponents["default"].div.withConfig({
26
26
  componentId: "plasma-new-hope__sc-g4vxbb-5"
27
- })(["margin:var(", ");line-height:0;"], _TextField.tokens.leftContentMargin);
27
+ })(["margin:var(", ");"], _TextField.tokens.leftContentMargin);
28
28
  var StyledContentRight = exports.StyledContentRight = /*#__PURE__*/_styledComponents["default"].div.withConfig({
29
29
  componentId: "plasma-new-hope__sc-g4vxbb-6"
30
- })(["margin:var(", ");line-height:0;"], _TextField.tokens.rightContentMargin);
30
+ })(["margin:var(", ");"], _TextField.tokens.rightContentMargin);
31
31
  var LeftHelper = exports.LeftHelper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
32
32
  componentId: "plasma-new-hope__sc-g4vxbb-7"
33
33
  })([""]);
@@ -1,9 +1,15 @@
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); }
1
2
  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"];
2
3
  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
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
5
  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."); }
5
6
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
7
  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); }
7
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
14
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
15
  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); }
@@ -135,15 +141,17 @@ export var textAreaRoot = function textAreaRoot(Root) {
135
141
  }
136
142
  onChange === null || onChange === void 0 || onChange(event);
137
143
  }, [value, onChange]);
138
- var dynamicLabelClasses = getDynamicLabelClasses({
144
+ var dynamicLabelClasses = getDynamicLabelClasses(_objectSpread({
139
145
  size: size,
140
146
  readOnly: readOnly,
141
147
  label: label,
142
148
  labelPlacement: labelPlacement,
143
- autoResize: autoResize,
144
- rows: rows,
145
149
  value: value || uncontrolledValue || defaultValue
146
- }, focused);
150
+ }, rows ? {
151
+ rows: rows
152
+ } : {
153
+ autoResize: autoResize
154
+ }), focused);
147
155
  return /*#__PURE__*/React.createElement(Root, {
148
156
  view: overriddenView,
149
157
  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,16 +31,55 @@ export function App() {
31
31
  }
32
32
  ```
33
33
 
34
- Также можно регулировать высоту и ширину, используя свойства `height` и `width`,
34
+ ### Размеры компонента
35
+ Высоту и ширину можно регулировать с помощью свойств `height` и `width`,
35
36
  указав значения в `rem` или соответствующие свойствам css значения.
37
+ `height` и `width` отвечают за **всю** высоту и ширину компонента.
36
38
 
37
- ## Autoresize
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
38
78
  Также можно включить автоматическое регулирование высоты поля ввода по длине контента внутри (параметра `value`).
39
79
  Для этого необходимо использовать свойство `autoResize`.
40
80
  При этом, если пользователь вручную регулирует высоту(`resize`), то она так и остается пользовательской.
41
81
 
42
- В этом режиме можно указать крайние значения высоты поля ввода, используя свойства `autoMin`, `autoMax`,
43
- указав их в `rem`.
82
+ Свойства `minAuto`, `maxAuto` указываются в абсолютных единицах и отвечают за минимальное и максимальное количество строк.
44
83
 
45
84
  ```tsx live
46
85
  import React from 'react';
@@ -85,4 +124,4 @@ export function App() {
85
124
  </div>
86
125
  );
87
126
  }
88
- ```
127
+ ```
@@ -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, minHeight, maxHeight) {
3
+ export var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto) {
4
4
  var isManualResize = useRef(false);
5
5
  var previousHeight = useRef();
6
6
  useEffect(function () {
@@ -11,9 +11,15 @@ export var useAutoResize = function useAutoResize(active, ref, value, minHeight,
11
11
  isManualResize.current = true;
12
12
  return;
13
13
  }
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);
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);
17
23
  ref.current.style.height = "".concat(newHeight, "rem");
18
24
  previousHeight.current = newHeight;
19
25
  }
@@ -17,10 +17,10 @@ export var Label = /*#__PURE__*/styled.label.withConfig({
17
17
  })([""]);
18
18
  export var StyledContentLeft = /*#__PURE__*/styled.div.withConfig({
19
19
  componentId: "plasma-new-hope__sc-g4vxbb-5"
20
- })(["margin:var(", ");line-height:0;"], tokens.leftContentMargin);
20
+ })(["margin:var(", ");"], tokens.leftContentMargin);
21
21
  export var StyledContentRight = /*#__PURE__*/styled.div.withConfig({
22
22
  componentId: "plasma-new-hope__sc-g4vxbb-6"
23
- })(["margin:var(", ");line-height:0;"], tokens.rightContentMargin);
23
+ })(["margin:var(", ");"], tokens.rightContentMargin);
24
24
  export var LeftHelper = /*#__PURE__*/styled.div.withConfig({
25
25
  componentId: "plasma-new-hope__sc-g4vxbb-7"
26
26
  })([""]);
@@ -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<import("../../types").TextareaHTMLAttributes<HTMLTextAreaElement> & import("./TextArea.types").TextAreaPropsExtends & React.RefAttributes<HTMLTextAreaElement>>;
5
+ export declare const textAreaRoot: (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) => React.ForwardRefExoticComponent<TextAreaProps & 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<import("../../types").TextareaHTMLAttributes<HTMLTextAreaElement> & import("./TextArea.types").TextAreaPropsExtends & React.RefAttributes<HTMLTextAreaElement>>;
9
+ layout: (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) => React.ForwardRefExoticComponent<TextAreaProps & 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,oMAkJ1E,CAAC;AAEP,eAAO,MAAM,cAAc;;;mBApJQ,UAAU,mBAAmB,EAAE,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;CA4K/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,8FAiJ1E,CAAC;AAEP,eAAO,MAAM,cAAc;;;mBAnJQ,UAAU,mBAAmB,EAAE,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;CA2K/E,CAAC"}
@@ -1,5 +1,52 @@
1
1
  /// <reference types="react" />
2
2
  import { TextareaHTMLAttributes } from '../../types';
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>;
3
50
  export interface TextAreaPropsBase {
4
51
  /**
5
52
  * Статус компонента: заполнен успешно / с предупреждением / с ошибкой.
@@ -23,16 +70,6 @@ export interface TextAreaPropsBase {
23
70
  * @deprecated устаревшее свойство
24
71
  */
25
72
  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;
36
73
  /**
37
74
  * Вспомогательный текст снизу слева для поля ввода.
38
75
  * @deprecated свойство устарело, необходимо использовать `leftHelper`.
@@ -46,18 +83,6 @@ export interface TextAreaPropsBase {
46
83
  * Вспомогательный текст снизу справа для поля ввода.
47
84
  */
48
85
  rightHelper?: string;
49
- /**
50
- * Автоматическая высота поля ввода.
51
- */
52
- autoResize?: boolean;
53
- /**
54
- * Максимальная высота поля ввода в автоматическом режиме(в rem).
55
- */
56
- maxAuto?: number;
57
- /**
58
- * Минимальная высота поля ввода в автоматическом режиме(в rem).
59
- */
60
- minAuto?: number;
61
86
  }
62
87
  export interface TextAreaPropsExtends extends TextAreaPropsBase {
63
88
  /**
@@ -69,5 +94,6 @@ export interface TextAreaPropsExtends extends TextAreaPropsBase {
69
94
  */
70
95
  view?: string;
71
96
  }
72
- export declare type TextAreaProps = TextareaHTMLAttributes<HTMLTextAreaElement> & TextAreaPropsExtends;
97
+ export declare type TextAreaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'rows' | 'cols'> & TextAreaPropsExtends & TextAreaDimensionsProps;
98
+ export {};
73
99
  //# 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,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
+ {"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,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,EA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AC,EAAE,MAAM,CAAC;CACjB;AAED,oBAAY,aAAa,GAAG,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,GAC1F,oBAAoB,GACpB,uBAAuB,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, minHeight?: number | undefined, maxHeight?: number | undefined) => void;
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;
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,mKA0BlB,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,+JAoClB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.styles.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.styles.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,YAAY,qKAKxB,CAAC;AAEF,eAAO,MAAM,iBAAiB,qKAoB7B,CAAC;AAEF,eAAO,MAAM,WAAW,qKAKvB,CAAC;AAEF,eAAO,MAAM,KAAK,8KASjB,CAAC;AAEF,eAAO,MAAM,KAAK,8KAAiB,CAAC;AAEpC,eAAO,MAAM,iBAAiB,qKAG7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,qKAG9B,CAAC;AAEF,eAAO,MAAM,UAAU,qKAAe,CAAC;AAEvC,eAAO,MAAM,gBAAgB,qKAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,qKAAe,CAAC"}
1
+ {"version":3,"file":"TextField.styles.d.ts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.styles.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,YAAY,qKAKxB,CAAC;AAEF,eAAO,MAAM,iBAAiB,qKAoB7B,CAAC;AAEF,eAAO,MAAM,WAAW,qKAKvB,CAAC;AAEF,eAAO,MAAM,KAAK,8KASjB,CAAC;AAEF,eAAO,MAAM,KAAK,8KAAiB,CAAC;AAEpC,eAAO,MAAM,iBAAiB,qKAE7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,qKAE9B,CAAC;AAEF,eAAO,MAAM,UAAU,qKAAe,CAAC;AAEvC,eAAO,MAAM,gBAAgB,qKAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,qKAAe,CAAC"}
@@ -15,5 +15,35 @@ export declare const TextArea: import("react").FunctionComponent<import("../../.
15
15
  disabled: {
16
16
  true: import("@linaria/core").LinariaClassName;
17
17
  };
18
- }> & import("../../../../types").TextareaHTMLAttributes<HTMLTextAreaElement> & import("../../../../components/TextArea/TextArea.types").TextAreaPropsExtends & import("react").RefAttributes<HTMLTextAreaElement>>;
18
+ }> & ((Omit<import("../../../../types").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("../../../../types").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("../../../../types").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>))>;
19
49
  //# 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;;;;;;;;;;;;;;;;kNAA0B,CAAC"}
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"}