@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
@@ -49,6 +49,7 @@ var SegmentProvider = function SegmentProvider(_ref) {
49
49
  }, [selectionMode, setSelectedSegmentItems]);
50
50
  var contextValue = {
51
51
  selectedSegmentItems: selectedSegmentItems,
52
+ setSelectedSegmentItems: setSelectedSegmentItems,
52
53
  handleSelect: handleSelect,
53
54
  selectionMode: selectionMode,
54
55
  setSelectionMode: setSelectionMode,
@@ -56,7 +57,9 @@ var SegmentProvider = function SegmentProvider(_ref) {
56
57
  setDisabledGroup: setDisabledGroup
57
58
  };
58
59
  React.useEffect(function () {
59
- setSelectedSegmentItems([]);
60
+ if (selectionMode === 'single' && (selectedSegmentItems === null || selectedSegmentItems === void 0 ? void 0 : selectedSegmentItems.length) > 0) {
61
+ setSelectedSegmentItems([selectedSegmentItems[0]]);
62
+ }
60
63
  }, [selectionMode]);
61
64
  return /*#__PURE__*/React.createElement(SegmentContext.Provider, {
62
65
  value: contextValue
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentProvider.js","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { SegmentContextType, SegmentSelectionMode } from './SegmentProvider.types';\n\nexport const SegmentContext = createContext<SegmentContextType | undefined>(undefined);\n\nexport const useSegmentInner = () => {\n const context = useContext(SegmentContext);\n if (!context) {\n throw new Error('useSegment must be used within a SegmentProvider');\n }\n return context;\n};\n\nexport const useSegment = () => {\n const { selectedSegmentItems } = useSegmentInner();\n return { selectedSegmentItems };\n};\n\nexport const SegmentProvider: FC<PropsWithChildren> = ({ children }) => {\n const [selectedSegmentItems, setSelectedSegmentItems] = useState<string[]>([]);\n const [selectionMode, setSelectionMode] = useState<SegmentSelectionMode>('single');\n const [disabledGroup, setDisabledGroup] = useState(false);\n\n const handleSelect = useCallback(\n (label: string) => {\n if (selectionMode !== 'multiple') {\n setSelectedSegmentItems((prevSelected) => (prevSelected.includes(label) ? [] : [label]));\n return;\n }\n\n setSelectedSegmentItems((prevSelected) =>\n prevSelected.includes(label) ? prevSelected.filter((item) => item !== label) : [...prevSelected, label],\n );\n },\n [selectionMode, setSelectedSegmentItems],\n );\n\n const contextValue: SegmentContextType = {\n selectedSegmentItems,\n handleSelect,\n selectionMode,\n setSelectionMode,\n disabledGroup,\n setDisabledGroup,\n };\n\n useEffect(() => {\n setSelectedSegmentItems([]);\n }, [selectionMode]);\n\n return <SegmentContext.Provider value={contextValue}>{children}</SegmentContext.Provider>;\n};\n"],"names":["SegmentContext","createContext","undefined","useSegmentInner","context","useContext","Error","useSegment","_useSegmentInner","selectedSegmentItems","SegmentProvider","_ref","children","_useState","useState","_useState2","_slicedToArray","setSelectedSegmentItems","_useState3","_useState4","selectionMode","setSelectionMode","_useState5","_useState6","disabledGroup","setDisabledGroup","handleSelect","useCallback","label","prevSelected","includes","filter","item","concat","_toConsumableArray","contextValue","useEffect","React","createElement","Provider","value"],"mappings":";;;;;;;IAKaA,cAAc,gBAAGC,mBAAa,CAAiCC,SAAS,EAAC;IAEzEC,eAAe,GAAG,SAAlBA,eAAeA,GAAS;AACjC,EAAA,IAAMC,OAAO,GAAGC,gBAAU,CAACL,cAAc,CAAC,CAAA;EAC1C,IAAI,CAACI,OAAO,EAAE;AACV,IAAA,MAAM,IAAIE,KAAK,CAAC,kDAAkD,CAAC,CAAA;AACvE,GAAA;AACA,EAAA,OAAOF,OAAO,CAAA;AAClB,EAAC;IAEYG,UAAU,GAAG,SAAbA,UAAUA,GAAS;AAC5B,EAAA,IAAAC,gBAAA,GAAiCL,eAAe,EAAE;IAA1CM,oBAAoB,GAAAD,gBAAA,CAApBC,oBAAoB,CAAA;EAC5B,OAAO;AAAEA,IAAAA,oBAAoB,EAApBA,oBAAAA;GAAsB,CAAA;AACnC,EAAC;IAEYC,eAAsC,GAAG,SAAzCA,eAAsCA,CAAAC,IAAA,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AAK,CAAA;OAAC,CAAA,GAAA,EAAA,CAAAK,MAAA,CAAAC,2CAAA,CAAOL,YAAY,CAAA,EAAA,CAAED,KAAK,CAAC,CAAA,CAAA;AAAA,KAC3G,CAAC,CAAA;AACL,GAAC,EACD,CAACR,aAAa,EAAEH,uBAAuB,CAC3C,CAAC,CAAA;AAED,EAAA,IAAMkB,YAAgC,GAAG;AACrC1B,IAAAA,oBAAoB,EAApBA,oBAAoB;AACpBiB,IAAAA,YAAY,EAAZA,YAAY;AACZN,IAAAA,aAAa,EAAbA,aAAa;AACbC,IAAAA,gBAAgB,EAAhBA,gBAAgB;AAChBG,IAAAA,aAAa,EAAbA,aAAa;AACbC,IAAAA,gBAAgB,EAAhBA,gBAAAA;GACH,CAAA;AAEDW,EAAAA,eAAS,CAAC,YAAM;IACZnB,uBAAuB,CAAC,EAAE,CAAC,CAAA;AAC/B,GAAC,EAAE,CAACG,aAAa,CAAC,CAAC,CAAA;AAEnB,EAAA,oBAAOiB,KAAA,CAAAC,aAAA,CAACtC,cAAc,CAACuC,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEL,YAAAA;AAAa,GAAA,EAAEvB,QAAkC,CAAC,CAAA;AAC7F;;;;;;;"}
1
+ {"version":3,"file":"SegmentProvider.js","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { SegmentContextType, SegmentSelectionMode } from './SegmentProvider.types';\n\nexport const SegmentContext = createContext<SegmentContextType | undefined>(undefined);\n\nexport const useSegmentInner = () => {\n const context = useContext(SegmentContext);\n if (!context) {\n throw new Error('useSegment must be used within a SegmentProvider');\n }\n return context;\n};\n\nexport const useSegment = () => {\n const { selectedSegmentItems } = useSegmentInner();\n return { selectedSegmentItems };\n};\n\nexport const SegmentProvider: FC<PropsWithChildren> = ({ children }) => {\n const [selectedSegmentItems, setSelectedSegmentItems] = useState<string[]>([]);\n const [selectionMode, setSelectionMode] = useState<SegmentSelectionMode>('single');\n const [disabledGroup, setDisabledGroup] = useState(false);\n\n const handleSelect = useCallback(\n (label: string) => {\n if (selectionMode !== 'multiple') {\n setSelectedSegmentItems((prevSelected) => (prevSelected.includes(label) ? [] : [label]));\n return;\n }\n\n setSelectedSegmentItems((prevSelected) =>\n prevSelected.includes(label) ? prevSelected.filter((item) => item !== label) : [...prevSelected, label],\n );\n },\n [selectionMode, setSelectedSegmentItems],\n );\n\n const contextValue: SegmentContextType = {\n selectedSegmentItems,\n setSelectedSegmentItems,\n handleSelect,\n selectionMode,\n setSelectionMode,\n disabledGroup,\n setDisabledGroup,\n };\n\n useEffect(() => {\n if (selectionMode === 'single' && selectedSegmentItems?.length > 0) {\n setSelectedSegmentItems([selectedSegmentItems[0]]);\n }\n }, [selectionMode]);\n\n return <SegmentContext.Provider value={contextValue}>{children}</SegmentContext.Provider>;\n};\n"],"names":["SegmentContext","createContext","undefined","useSegmentInner","context","useContext","Error","useSegment","_useSegmentInner","selectedSegmentItems","SegmentProvider","_ref","children","_useState","useState","_useState2","_slicedToArray","setSelectedSegmentItems","_useState3","_useState4","selectionMode","setSelectionMode","_useState5","_useState6","disabledGroup","setDisabledGroup","handleSelect","useCallback","label","prevSelected","includes","filter","item","concat","_toConsumableArray","contextValue","useEffect","length","React","createElement","Provider","value"],"mappings":";;;;;;;IAKaA,cAAc,gBAAGC,mBAAa,CAAiCC,SAAS,EAAC;IAEzEC,eAAe,GAAG,SAAlBA,eAAeA,GAAS;AACjC,EAAA,IAAMC,OAAO,GAAGC,gBAAU,CAACL,cAAc,CAAC,CAAA;EAC1C,IAAI,CAACI,OAAO,EAAE;AACV,IAAA,MAAM,IAAIE,KAAK,CAAC,kDAAkD,CAAC,CAAA;AACvE,GAAA;AACA,EAAA,OAAOF,OAAO,CAAA;AAClB,EAAC;IAEYG,UAAU,GAAG,SAAbA,UAAUA,GAAS;AAC5B,EAAA,IAAAC,gBAAA,GAAi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@@ var base$5 = require('./variations/_filledBackgound/base.js');
19
19
  var base$4 = require('./variations/_stretch/base.js');
20
20
  var SegmentGroup_styles = require('./SegmentGroup.styles.js');
21
21
 
22
- var _excluded = ["id", "selectionMode", "pilled", "stretch", "filledBackground", "disabled", "size", "view", "children"];
22
+ var _excluded = ["id", "selectionMode", "pilled", "stretch", "filledBackground", "disabled", "size", "view", "children", "defaultSelected"];
23
23
  var segmentGroupRoot = function segmentGroupRoot(Root) {
24
24
  return /*#__PURE__*/React.forwardRef(function (props, outerRef) {
25
25
  var id = props.id,
@@ -33,10 +33,12 @@ var segmentGroupRoot = function segmentGroupRoot(Root) {
33
33
  size = props.size,
34
34
  view = props.view,
35
35
  children = props.children,
36
+ defaultSelected = props.defaultSelected,
36
37
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
37
38
  var _useSegmentInner = SegmentProvider.useSegmentInner(),
38
39
  setSelectionMode = _useSegmentInner.setSelectionMode,
39
- setDisabledGroup = _useSegmentInner.setDisabledGroup;
40
+ setDisabledGroup = _useSegmentInner.setDisabledGroup,
41
+ setSelectedSegmentItems = _useSegmentInner.setSelectedSegmentItems;
40
42
  var _useState = React.useState(0),
41
43
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
42
44
  index$1 = _useState2[0],
@@ -120,6 +122,11 @@ var segmentGroupRoot = function segmentGroupRoot(Root) {
120
122
  selectionMode && setSelectionMode(selectionMode);
121
123
  setDisabledGroup(disabled);
122
124
  }, [selectionMode, disabled]);
125
+ React.useEffect(function () {
126
+ if (defaultSelected !== null && defaultSelected !== void 0 && defaultSelected.length) {
127
+ setSelectedSegmentItems(defaultSelected);
128
+ }
129
+ }, [defaultSelected]);
123
130
  React.useEffect(function () {
124
131
  var _trackRef$current;
125
132
  // Intersection observer для первого сегмента
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentGroup.js","sources":["../../../../../src/components/Segment/ui/SegmentGroup/SegmentGroup.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, Children, useEffect } from 'react';\nimport type { SetStateAction, RefObject, MutableRefObject } from 'react';\nimport { safeUseId, useCarousel } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { useSegmentInner } from '../../SegmentProvider/SegmentProvider';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as filledBackgroundCSS } from './variations/_filledBackgound/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport type { SegmentGroupProps } from './SegmentGroup.types';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './SegmentGroup.styles';\n\nexport const segmentGroupRoot = (Root: RootProps<HTMLDivElement, SegmentGroupProps>) =>\n forwardRef<HTMLDivElement, SegmentGroupProps>((props, outerRef) => {\n const {\n id,\n selectionMode,\n pilled,\n stretch,\n filledBackground = false,\n disabled = false,\n size,\n view,\n children,\n ...rest\n } = props;\n\n const { setSelectionMode, setDisabledGroup } = useSegmentInner();\n\n const [index, setIndex] = useState(0);\n const [firstItemVisible, setFirstItemVisible] = useState(false);\n const [lastItemVisible, setLastItemVisible] = useState(false);\n\n const uniqId = safeUseId();\n const segmentGroupId = id || uniqId;\n\n const pilledAttr = view !== 'clear' && pilled;\n const filledBackgroundAttr = view !== 'clear' && filledBackground;\n const pilledClass = pilledAttr ? classes.segmentPilled : undefined;\n const filledClass = filledBackgroundAttr ? classes.segmentGroupFilledBackground : undefined;\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.segmentStretch : undefined;\n\n const items = Children?.map(children, (child) => child) || [];\n\n const onPrev = useCallback(() => {\n !disabled && setIndex((prevIndex) => (prevIndex > 0 ? prevIndex - 1 : 0));\n }, [disabled]);\n\n const onNext = useCallback(() => {\n !disabled && setIndex((prevIndex) => (prevIndex < items.length - 1 ? prevIndex + 1 : prevIndex));\n }, [disabled]);\n\n const onIntersecting = (setVisible: (value: SetStateAction<boolean>) => void) => (\n entries: IntersectionObserverEntry[],\n ) => {\n /*\n * Пробегаемся по элементам на которых есть слушатель события появления.\n * Если элемент находится в зоне видимости или выходит из нее, меняем значение флага видимости\n */\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setVisible(true);\n } else {\n setVisible(false);\n }\n });\n };\n\n const { scrollRef, trackRef } = useCarousel({\n index,\n axis: 'x',\n scrollAlign: 'start',\n detectActive: true,\n debounceMs: 250,\n onIndexChange: setIndex,\n });\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий сегмент\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий сегмент\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext],\n );\n\n useEffect(() => {\n selectionMode && setSelectionMode(selectionMode);\n setDisabledGroup(disabled);\n }, [selectionMode, disabled]);\n\n useEffect(() => {\n // Intersection observer для первого сегмента\n const observeFirstItem = new IntersectionObserver(onIntersecting(setFirstItemVisible), {\n root: null,\n rootMargin: '0px',\n threshold: 0.5,\n });\n\n // Intersection observer для последнего сегмента\n const observeLastItem = new IntersectionObserver(onIntersecting(setLastItemVisible), {\n root: null,\n rootMargin: '0px',\n threshold: 0.5,\n });\n\n // получаем список сегментов внутри SegmentGroup\n const childrenArray = Array.from(trackRef.current?.children || []) as Array<Element>;\n if (childrenArray.length) {\n // подписываемся на событие появление внутри SegmentGroup\n observeFirstItem.observe(childrenArray[0]);\n observeLastItem.observe(childrenArray[childrenArray.length - 1]);\n }\n\n return () => {\n // отписываемся от события появления внутри SegmentGroup\n observeFirstItem.disconnect();\n observeLastItem.disconnect();\n };\n }, [children]);\n\n return (\n <Root\n view={view}\n size={size}\n id={segmentGroupId}\n ref={outerRef}\n filledBackground={filledBackgroundAttr}\n disabled={disabled}\n pilled={pilledAttr}\n className={cx(pilledClass, filledClass, stretchClass)}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper ref={scrollRef as RefObject<HTMLDivElement>}>\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>{children}</StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n );\n });\n\nexport const segmentGroupConfig = {\n name: 'SegmentGroup',\n tag: 'div',\n layout: segmentGroupRoot,\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 pilled: {\n css: pilledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n filledBackground: {\n css: filledBackgroundCSS,\n attrs: true,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["segmentGroupRoot","Root","forwardRef","props","outerRef","id","selectionMode","pilled","stretch","_props$filledBackgrou","filledBackground","_props$disabled","disabled","size","view","children","rest","_objectWithoutProperties","_excluded","_useSegmentInner","useSegmentInner","setSelectionMode","setDisabledGroup","_useState","useState","_useState2","_slicedToArray","index","setIndex","_useState3","_useState4","firstItemVisible","setFirstItemVisible","_useState5","_useState6","lastItemVisible","setLastItemVisible","uniqId","safeUseId","segmentGroupId","pilledAttr","filledBackgroundAttr","pilledClass","classes","segmentPilled","undefined","filledClass","segmentGroupFilledBackground","stretchClass","segmentStretch","items","Children","map","child","onPrev","useCallback","prevIndex","onNext","length","onIntersecting","setVisible","entries","forEach","entry","isIntersecting","_useCarousel","useCarousel","axis","scrollAlign","detectActive","debounceMs","onIndexChange","scrollRef","trackRef","PreviousButton","useMemo","React","createElement","StyledArrow","type","onClick","tabIndex","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","useEffect","_trackRef$current","observeFirstItem","IntersectionObserver","root","rootMargin","threshold","observeLastItem","childrenArray","Array","from","current","observe","disconnect","_extends","ref","className","cx","StyledContentWrapper","StyledContent","segmentGroupConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","pilledCSS","stretchCSS","filledBackgroundCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAmBaA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,IAAkD,EAAA;AAAA,EAAA,oBAC/EC,gBAAU,CAAoC,UAACC,KAAK,EAAEC,QAAQ,EAAK;AAC/D,IAAA,IACIC,EAAE,GAUFF,KAAK,CAVLE,EAAE;MACFC,aAAa,GASbH,KAAK,CATLG,aAAa;MACbC,MAAM,GAQNJ,KAAK,CARLI,MAAM;MACNC,OAAO,GAOPL,KAAK,CAPLK,OAAO;MAAAC,qBAAA,GAOPN,KAAK,CANLO,gBAAgB;AAAhBA,MAAAA,gBAAgB,GAAAD,qBAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,qBAAA;MAAAE,eAAA,GAMxBR,KAAK,CALLS,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,eAAA;MAChBE,IAAI,GAIJV,KAAK,CAJLU,IAAI;MACJC,IAAI,GAGJX,KAAK,CAHLW,IAAI;MACJC,QAAQ,GAERZ,KAAK,CAFLY,QAAQ;AACLC,MAAAA,IAAI,GAAAC,iDAAA,CACPd,KAAK,EAAAe,SAAA,CAAA,CAAA;AAET,IAAA,IAAAC,gBAAA,GAA+CC,+BAAe,EAAE;MAAxDC,gBAAgB,GAAAF,gBAAA,CAAhBE,gBAAgB;MAAEC,gBAAgB,GAAAH,gBAAA,CAA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EAAE;AACFsG,MAAAA,GAAG,EAAEC,SAAAA;KACR;AACDtG,IAAAA,IAAI,EAAE;AACFqG,MAAAA,GAAG,EAAEE,WAAAA;KACR;AACDzG,IAAAA,QAAQ,EAAE;AACNuG,MAAAA,GAAG,EAAEG,WAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDhH,IAAAA,MAAM,EAAE;AACJ4G,MAAAA,GAAG,EAAEK,WAAS;AACdD,MAAAA,KAAK,EAAE,IAAA;KACV;AACD/G,IAAAA,OAAO,EAAE;AACL2G,MAAAA,GAAG,EAAEM,WAAU;AACfF,MAAAA,KAAK,EAAE,IAAA;KACV;AACD7G,IAAAA,gBAAgB,EAAE;AACdyG,MAAAA,GAAG,EAAEO,WAAmB;AACxBH,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDI,EAAAA,QAAQ,EAAE;AACN7G,IAAAA,IAAI,EAAE,OAAO;AACbD,IAAAA,IAAI,EAAE,IAAA;AACV,GAAA;AACJ;;;;;"}
1
+ {"version":3,"file":"SegmentGroup.js","sources":["../../../../../src/components/Segment/ui/SegmentGroup/SegmentGroup.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, Children, useEffect } from 'react';\nimport type { SetStateAction, RefObject, MutableRefObject } from 'react';\nimport { safeUseId, useCarousel } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { useSegmentInner } from '../../SegmentProvider/SegmentProvider';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as filledBackgroundCSS } from './variations/_filledBackgound/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport type { SegmentGroupProps } from './SegmentGroup.types';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './SegmentGroup.styles';\n\nexport const segmentGroupRoot = (Root: RootProps<HTMLDivElement, SegmentGroupProps>) =>\n forwardRef<HTMLDivElement, SegmentGroupProps>((props, outerRef) => {\n const {\n id,\n selectionMode,\n pilled,\n stretch,\n filledBackground = false,\n disabled = false,\n size,\n view,\n children,\n defaultSelected,\n ...rest\n } = props;\n\n const { setSelectionMode, setDisabledGroup, setSelectedSegmentItems } = useSegmentInner();\n\n const [index, setIndex] = useState(0);\n const [firstItemVisible, setFirstItemVisible] = useState(false);\n const [lastItemVisible, setLastItemVisible] = useState(false);\n\n const uniqId = safeUseId();\n const segmentGroupId = id || uniqId;\n\n const pilledAttr = view !== 'clear' && pilled;\n const filledBackgroundAttr = view !== 'clear' && filledBackground;\n const pilledClass = pilledAttr ? classes.segmentPilled : undefined;\n const filledClass = filledBackgroundAttr ? classes.segmentGroupFilledBackground : undefined;\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.segmentStretch : undefined;\n\n const items = Children?.map(children, (child) => child) || [];\n\n const onPrev = useCallback(() => {\n !disabled && setIndex((prevIndex) => (prevIndex > 0 ? prevIndex - 1 : 0));\n }, [disabled]);\n\n const onNext = useCallback(() => {\n !disabled && setIndex((prevIndex) => (prevIndex < items.length - 1 ? prevIndex + 1 : prevIndex));\n }, [disabled]);\n\n const onIntersecting = (setVisible: (value: SetStateAction<boolean>) => void) => (\n entries: IntersectionObserverEntry[],\n ) => {\n /*\n * Пробегаемся по элементам на которых есть слушатель события появления.\n * Если элемент находится в зоне видимости или выходит из нее, меняем значение флага видимости\n */\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setVisible(true);\n } else {\n setVisible(false);\n }\n });\n };\n\n const { scrollRef, trackRef } = useCarousel({\n index,\n axis: 'x',\n scrollAlign: 'start',\n detectActive: true,\n debounceMs: 250,\n onIndexChange: setIndex,\n });\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий сегмент\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий сегмент\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext],\n );\n\n useEffect(() => {\n selectionMode && setSelectionMode(selectionMode);\n setDisabledGroup(disabled);\n }, [selectionMode, disabled]);\n\n useEffect(() => {\n if (defaultSelected?.length) {\n setSelectedSegmentItems(defaultSelected);\n }\n }, [defaultSelected]);\n\n useEffect(() => {\n // Intersection observer для первого сегмента\n const observeFirstItem = new IntersectionObserver(onIntersecting(setFirstItemVisible), {\n root: null,\n rootMargin: '0px',\n threshold: 0.5,\n });\n\n // Intersection observer для последнего сегмента\n const observeLastItem = new IntersectionObserver(onIntersecting(setLastItemVisible), {\n root: null,\n rootMargin: '0px',\n threshold: 0.5,\n });\n\n // получаем список сегментов внутри SegmentGroup\n const childrenArray = Array.from(trackRef.current?.children || []) as Array<Element>;\n if (childrenArray.length) {\n // подписываемся на событие появление внутри SegmentGroup\n observeFirstItem.observe(childrenArray[0]);\n observeLastItem.observe(childrenArray[childrenArray.length - 1]);\n }\n\n return () => {\n // отписываемся от события появления внутри SegmentGroup\n observeFirstItem.disconnect();\n observeLastItem.disconnect();\n };\n }, [children]);\n\n return (\n <Root\n view={view}\n size={size}\n id={segmentGroupId}\n ref={outerRef}\n filledBackground={filledBackgroundAttr}\n disabled={disabled}\n pilled={pilledAttr}\n className={cx(pilledClass, filledClass, stretchClass)}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper ref={scrollRef as RefObject<HTMLDivElement>}>\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>{children}</StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n );\n });\n\nexport const segmentGroupConfig = {\n name: 'SegmentGroup',\n tag: 'div',\n layout: segmentGroupRoot,\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 pilled: {\n css: pilledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n filledBackground: {\n css: filledBackgroundCSS,\n attrs: true,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["segmentGroupRoot","Root","forwardRef","props","outerRef","id","selectionMode","pilled","stretch","_props$filledBackgrou","filledBackground","_props$disabled","disabled","size","view","children","defaultSelected","rest","_objectWithoutProperties","_excluded","_useSegmentInner","useSegmentInner","setSelectionMode","setDisabledGroup","setSelectedSegmentItems","_useState","useState","_useState2","_slicedToArray","index","setIndex","_useState3","_useState4","firstItemVisible","setFirstItemVisible","_useState5","_useState6","lastItemVisible","setLastItemVisible","uniqId","safeUseId","segmentGroupId","pilledAttr","filledBackgroundAttr","pilledClass","classes","segmentPilled","undefined","filledClass","segmentGroupFilledBackground","stretchClass","segmentStretch","items","Children","map","child","onPrev","useCallback","prevIndex","onNext","length","onIntersecting","setVisible","entries","forEach","entry","isIntersecting","_useCarousel","useCarousel","axis","scrollAlign","detectActive","debounceMs","onIndexChange","scrollRef","trackRef","PreviousButton","useMemo","React","createElement","StyledArrow","type","onClick","tabIndex","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","useEffect","_trackRef$current","observeFirstItem","IntersectionObserver","root","rootMargin","threshold","observeLastItem","childrenArray","Array","from","current","observe","disconnect","_extends","ref","className","cx","StyledContentWrapper","StyledContent","segmentGroupConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","pilledCSS","stretchCSS","filledBackgroundCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAm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AAI,EAAE;AACFuG,MAAAA,GAAG,EAAEE,WAAAA;KACR;AACD3G,IAAAA,QAAQ,EAAE;AACNyG,MAAAA,GAAG,EAAEG,WAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDlH,IAAAA,MAAM,EAAE;AACJ8G,MAAAA,GAAG,EAAEK,WAAS;AACdD,MAAAA,KAAK,EAAE,IAAA;KACV;AACDjH,IAAAA,OAAO,EAAE;AACL6G,MAAAA,GAAG,EAAEM,WAAU;AACfF,MAAAA,KAAK,EAAE,IAAA;KACV;AACD/G,IAAAA,gBAAgB,EAAE;AACd2G,MAAAA,GAAG,EAAEO,WAAmB;AACxBH,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDI,EAAAA,QAAQ,EAAE;AACN/G,IAAAA,IAAI,EAAE,OAAO;AACbD,IAAAA,IAAI,EAAE,IAAA;AACV,GAAA;AACJ;;;;;"}
@@ -127,17 +127,15 @@ var textAreaRoot = function textAreaRoot(Root) {
127
127
  }
128
128
  onChange === null || onChange === void 0 || onChange(event);
129
129
  }, [value, onChange]);
130
- var dynamicLabelClasses = getDynamicLabelClasses(_rollupPluginBabelHelpers.objectSpread2({
130
+ var dynamicLabelClasses = getDynamicLabelClasses({
131
131
  size: size,
132
132
  readOnly: readOnly,
133
133
  label: label,
134
134
  labelPlacement: labelPlacement,
135
+ autoResize: autoResize,
136
+ rows: rows,
135
137
  value: value || uncontrolledValue || defaultValue
136
- }, rows ? {
137
- rows: rows
138
- } : {
139
- autoResize: autoResize
140
- }), focused);
138
+ }, focused);
141
139
  return /*#__PURE__*/React.createElement(Root, {
142
140
  view: overriddenView,
143
141
  size: size,
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import React, { forwardRef, useState, createRef, useCallback } from 'react';\nimport { css } from '@linaria/core';\nimport { useResizeObserver } from '@salutejs/plasma-core';\n\nimport { cx } from '../../utils';\nimport type { RootProps } from '../../engines/types';\n\nimport { applyDynamicLabel } from './mixins';\nimport { useAutoResize, ROOT_FONT_SIZE } from './hooks';\nimport {\n StyledContent,\n StyledHelpers,\n StyledLeftHelper,\n StyledRightHelper,\n StyledLabel,\n StyledPlaceholder,\n StyledTextArea,\n StyledTextAreaWrapper,\n StyledContainer,\n} from './TextArea.styles';\nimport { classes } from './TextArea.tokens';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport type { TextAreaProps } from './TextArea.types';\n\nconst {\n innerPlaceholderUp,\n focusedOuterPlaceholderColor,\n hidePlaceHolder,\n styledContainer,\n styledTextArea,\n styledTextAreaWrapper,\n styledPlaceholder,\n styledHelpers,\n} = classes;\n\nconst base = css`\n ${applyDynamicLabel};\n\n position: relative;\n box-sizing: border-box;\n`;\n\n// TODO: Удалить после отказа от старых библиотек plasma-web / plasma-b2c\nconst fallbackStatusMap = {\n '': 'primary',\n success: 'positive',\n warning: 'warning',\n error: 'negative',\n};\n\n// TODO: Перенести этот метод в файл applyDynamicLabel.ts\nexport const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) => {\n const { readOnly, label, labelPlacement, autoResize, rows, value, size } = props;\n\n // Добавить класс отвечающий за изменение цвета плейсхолдера при фокусе\n const withFocusedOuterUpPlaceholder =\n !readOnly && focused && (!label || labelPlacement === 'outer') ? focusedOuterPlaceholderColor : undefined;\n\n // Добавить класс отвечающий за поднятие и уменьшение плейсхолдера\n const withInnerPlaceholderUp =\n labelPlacement === 'inner' &&\n label &&\n !autoResize &&\n !rows &&\n size !== 'xs' &&\n ((!readOnly && (value || focused)) || (readOnly && value))\n ? innerPlaceholderUp\n : undefined;\n\n // Добавить класс отвечающий за скрытие плейсхолдера\n const withHidePlaceholder =\n (value && !label) ||\n (labelPlacement === 'inner' && ((focused && !readOnly) || value) && label && (rows || autoResize)) ||\n (labelPlacement === 'outer' && value) ||\n (labelPlacement === 'inner' && size === 'xs' && value)\n ? hidePlaceHolder\n : undefined;\n\n return [withFocusedOuterUpPlaceholder, withInnerPlaceholderUp, withHidePlaceholder];\n};\n\nexport const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) =>\n forwardRef<HTMLTextAreaElement, TextAreaProps>((props, innerRef) => {\n const {\n helperText,\n status,\n resize,\n rightHelper,\n leftHelper,\n contentRight,\n autoResize = false,\n minAuto = 0,\n maxAuto,\n label,\n labelPlacement = 'inner',\n placeholder,\n defaultValue,\n height,\n width,\n value,\n disabled,\n size,\n view,\n id,\n style,\n className,\n readOnly,\n rows,\n cols,\n onChange,\n ...rest\n } = props;\n\n const [helperWidth, setHelperWidth] = useState<string>(width ? `${width}rem` : '100%');\n const [focused, setFocused] = useState(false);\n const [uncontrolledValue, setUncontrolledValue] = useState<string | undefined>();\n\n const outerRef = innerRef && 'current' in innerRef ? innerRef : createRef<HTMLTextAreaElement>();\n const hasHelper = Boolean(leftHelper || rightHelper || helperText);\n const overriddenView = status !== undefined ? fallbackStatusMap[status] : view;\n const textareaHelperId = id ? `${id}-helper` : undefined;\n const applyCustomWidth = resize !== 'horizontal' && resize !== 'both' && !cols;\n const placeLabel = labelPlacement === 'inner' && label && size !== 'xs' ? label : placeholder;\n\n useResizeObserver(outerRef, (currentElement) => {\n const { width: inlineWidth, height: inlineHeight } = currentElement.style;\n\n if (inlineWidth || inlineHeight || cols) {\n const { width: elementWidth } = currentElement.getBoundingClientRect();\n setHelperWidth(`${elementWidth / ROOT_FONT_SIZE}rem`);\n }\n });\n\n useAutoResize(autoResize, outerRef, value, minAuto, maxAuto);\n\n const onFocusHandler = useCallback(() => {\n setFocused(true);\n }, []);\n const onBlurHandler = useCallback(() => {\n setFocused(false);\n }, []);\n\n const onChangeHandler = useCallback(\n (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n // INFO: Для крайне редких кейсов, когда value снаружи не контролируется\n if (value === undefined) {\n setUncontrolledValue(event?.target.value);\n }\n\n onChange?.(event);\n },\n [value, onChange],\n );\n\n const dynamicLabelClasses = getDynamicLabelClasses(\n {\n size,\n readOnly,\n label,\n labelPlacement,\n value: value || uncontrolledValue || defaultValue,\n ...(rows ? { rows } : { autoResize }),\n },\n focused,\n );\n\n return (\n <Root\n view={overriddenView}\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n style={style}\n className={className}\n >\n {label && labelPlacement === 'outer' && <StyledLabel>{label}</StyledLabel>}\n <StyledContainer\n className={cx(styledContainer, ...dynamicLabelClasses)}\n width={helperWidth}\n onFocus={onFocusHandler}\n onBlur={onBlurHandler}\n >\n {contentRight && <StyledContent>{contentRight}</StyledContent>}\n <StyledTextAreaWrapper className={styledTextAreaWrapper} hasHelper={hasHelper}>\n <StyledTextArea\n className={styledTextArea}\n id={id}\n hasContentRight={Boolean(contentRight)}\n hasHelper={hasHelper}\n applyCustomWidth={applyCustomWidth}\n ref={outerRef}\n disabled={disabled}\n height={autoResize ? minAuto : height}\n width={width}\n placeholder={placeLabel}\n aria-describedby={textareaHelperId}\n value={value}\n readOnly={readOnly}\n rows={rows}\n cols={cols}\n resize={resize}\n defaultValue={defaultValue}\n onChange={onChangeHandler}\n {...rest}\n />\n </StyledTextAreaWrapper>\n {hasHelper && (\n <StyledHelpers className={styledHelpers} id={textareaHelperId}>\n {(leftHelper || helperText) && (\n <StyledLeftHelper>{leftHelper || helperText}</StyledLeftHelper>\n )}\n {rightHelper && <StyledRightHelper>{rightHelper}</StyledRightHelper>}\n </StyledHelpers>\n )}\n {placeLabel && (\n <StyledPlaceholder\n hasContentRight={Boolean(contentRight)}\n className={styledPlaceholder}\n htmlFor={id}\n >\n {placeLabel}\n </StyledPlaceholder>\n )}\n </StyledContainer>\n </Root>\n );\n });\n\nexport const textAreaConfig = {\n name: 'TextArea',\n tag: 'div',\n layout: textAreaRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n readOnly: {\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'primary',\n },\n};\n"],"names":["innerPlaceholderUp","classes","focusedOuterPlaceholderColor","hidePlaceHolder","styledContainer","styledTextArea","styledTextAreaWrapper","styledPlaceholder","styledHelpers","base","fallbackStatusMap","success","warning","error","getDynamicLabelClasses","props","focused","readOnly","label","labelPlacement","autoResize","rows","value","size","withFocusedOuterUpPlaceholder","undefined","withInnerPlaceholderUp","withHidePlaceholder","textAreaRoot","Root","forwardRef","innerRef","helperText","status","resize","rightHelper","leftHelper","contentRight","_props$autoResize","_props$minAuto","minAuto","maxAuto","_props$labelPlacement","placeholder","defaultValue","height","width","disabled","view","id","style","className","cols","onChange","rest","_excluded","_useState","useState","concat","_useState2","_slicedToArray","helperWidth","setHelperWidth","_useState3","_useState4","setFocused","_useState5","_useState6","uncontrolledValue","setUncontrolledValue","outerRef","createRef","hasHelper","Boolean","overriddenView","textareaHelperId","applyCustomWidth","placeLabel","useResizeObserver","currentElement","_currentElement$style","inlineWidth","inlineHeight","_currentElement$getBo","getBoundingClientRect","elementWidth","ROOT_FONT_SIZE","useAutoResize","onFocusHandler","useCallback","onBlurHandler","onChangeHandler","event","target","dynamicLabelClasses","_objectSpread","React","createElement","StyledLabel","StyledContainer","cx","apply","_toConsumableArray","onFocus","onBlur","StyledContent","StyledTextAreaWrapper","StyledTextArea","_extends","hasContentRight","ref","StyledHelpers","StyledLeftHelper","StyledRightHelper","StyledPlaceholder","htmlFor","textAreaConfig","name","tag","layout","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;;;;;AA0BA,IACIA,kBAAkB,GAQlBC,uBAAO,CARPD,kBAAkB;EAClBE,4BAA4B,GAO5BD,uBAAO,CAPPC,4BAA4B;EAC5BC,eAAe,GAMfF,uBAAO,CANPE,eAAe;EACfC,eAAe,GAKfH,uBAAO,CALPG,eAAe;EACfC,cAAc,GAIdJ,uBAAO,CAJPI,cAAc;EACdC,qBAAqB,GAGrB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AAAA,MAAM,EAAE3F,YAAY;AACpBnB,EAAAA,IAAI,EAAJA,IAAI;AACJ+G,EAAAA,UAAU,EAAE;AACRjG,IAAAA,IAAI,EAAE;AACFkG,MAAAA,GAAG,EAAEC,WAAAA;KACR;AACD1E,IAAAA,IAAI,EAAE;AACFyE,MAAAA,GAAG,EAAEE,WAAAA;KACR;AACD5E,IAAAA,QAAQ,EAAE;AACN0E,MAAAA,GAAG,EAAEG,WAAW;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,uBAAO,CARPD,kBAAkB;EAClBE,4BAA4B,GAO5BD,uBAAO,CAPPC,4BAA4B;EAC5BC,eAAe,GAMfF,uBAAO,CANPE,eAAe;EACfC,eAAe,GAKfH,uBAAO,CALPG,eAAe;EACfC,cAAc,GAIdJ,uBAAO,CAJPI,cAAc;EACdC,qBAAqB,GAGrBL,uBAAO,CAHPK,qBAAqB;EACrBC,iBAAiB,GAEjBN,uBAAO,CAFPM,iBAAiB;EACjBC,aAAAA,GACAP,uBAAO,CADPO,aAAAA,CAAAA;AAGJ,IAAMC,IAAI,GAKT,SAAA,CAAA;;AAED;AACA,IAAMC,iBAAiB,GAAG;AACtB,EAAA,EAAE,EAAE,SAAS;AACbC,EAAAA,OAAO,EAAE,UAAU;AACnBC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,KAAK,EAAE,UAAA;AACX,CAAC,CAAA;;AAED;AACO,IAAMC,sBAAsB,GAAGA,SAAzBA,sBAAsBA,CAAIC,KAAoB,EAAEC,OAAgB,EAAK;AAC9E,EAAA,IAAQC,QAAQ,GAA2DF,KAAK,CAAxEE,QAAQ;IAAEC,KAAK,GAAoDH,KAAK,CAA9DG,KAAK;IAAEC,cAAc,GAAoCJ,KAAK,C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AAiB,KAAA,EACzD,CAACvC,UAAU,IAAIJ,UAAU,kBACtB+D,KAAA,CAAAC,aAAA,CAACe,gCAAgB,EAAE3E,IAAAA,EAAAA,UAAU,IAAIJ,UAA6B,CACjE,EACAG,WAAW,iBAAI4D,KAAA,CAAAC,aAAA,CAACgB,iCAAiB,QAAE7E,WAA+B,CACxD,CAClB,EACA0C,UAAU,iBACPkB,KAAA,CAAAC,aAAA,CAACiB,iCAAiB,EAAA;AACdL,MAAAA,eAAe,EAAEnC,OAAO,CAACpC,YAAY,CAAE;AACvCc,MAAAA,SAAS,EAAE5C,iBAAkB;AAC7B2G,MAAAA,OAAO,EAAEjE,EAAAA;KAER4B,EAAAA,UACc,CAEV,CACf,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMsC,cAAc,GAAG;AAC1BC,EAAAA,IAAI,EAAE,UAAU;AAChBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE1F,YAAY;AACpBnB,EAAAA,IAAI,EAAJA,IAAI;AACJ8G,EAAAA,UAAU,EAAE;AACRhG,IAAAA,IAAI,EAAE;AACFiG,MAAAA,GAAG,EAAEC,WAAAA;KACR;AACDzE,IAAAA,IAAI,EAAE;AACFwE,MAAAA,GAAG,EAAEE,WAAAA;KACR;AACD3E,IAAAA,QAAQ,EAAE;AACNyE,MAAAA,GAAG,EAAEG,WAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACD3G,IAAAA,QAAQ,EAAE;AACN2G,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNtG,IAAAA,IAAI,EAAE,GAAG;AACTyB,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;;;"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var React = require('react');
6
6
 
7
7
  var ROOT_FONT_SIZE = 16;
8
- var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto) {
8
+ var useAutoResize = function useAutoResize(active, ref, value, minHeight, maxHeight) {
9
9
  var isManualResize = React.useRef(false);
10
10
  var previousHeight = React.useRef();
11
11
  React.useEffect(function () {
@@ -16,15 +16,9 @@ var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto)
16
16
  isManualResize.current = true;
17
17
  return;
18
18
  }
19
- var style = getComputedStyle(ref.current);
20
- var lineHeight = parseInt(style.lineHeight, 10);
21
- var lineHeightInRem = lineHeight / ROOT_FONT_SIZE;
22
- var minAutoHeight = minAuto ? minAuto * lineHeightInRem : 0;
23
- ref.current.style.height = "".concat(minAutoHeight, "rem");
24
- var lines = Math.floor(ref.current.scrollHeight / lineHeight);
25
- var newScrollHeight = lines * lineHeightInRem;
26
- var maxAutoHeight = maxAuto ? maxAuto * lineHeightInRem : newScrollHeight;
27
- var newHeight = Math.min(newScrollHeight, maxAutoHeight);
19
+ ref.current.style.height = "".concat(minHeight ? minHeight + 1 : '0', "rem");
20
+ var scrollHeight = ref.current.scrollHeight / ROOT_FONT_SIZE;
21
+ var newHeight = Math.min(scrollHeight, maxHeight ? maxHeight + 1 : scrollHeight);
28
22
  ref.current.style.height = "".concat(newHeight, "rem");
29
23
  previousHeight.current = newHeight;
30
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useAutoResize.js","sources":["../../../../src/components/TextArea/hooks/useAutoResize.ts"],"sourcesContent":["import { useEffect, useRef, MutableRefObject } from 'react';\n\nexport const ROOT_FONT_SIZE = 16;\n\nexport const useAutoResize = <T extends HTMLTextAreaElement>(\n active: boolean,\n ref: MutableRefObject<T | null>,\n value?: string | ReadonlyArray<string> | number,\n minAuto?: number,\n maxAuto?: number,\n) => {\n const isManualResize = useRef<boolean>(false);\n const previousHeight = useRef<number | undefined>();\n\n useEffect(() => {\n if (active && ref && ref.current && !isManualResize.current) {\n // проверка на пользовательский resize (вручную)\n const height = ref.current.clientHeight / ROOT_FONT_SIZE;\n if (previousHeight.current !== undefined && previousHeight.current !== height) {\n isManualResize.current = true;\n return;\n }\n\n const style = getComputedStyle(ref.current);\n const lineHeight = parseInt(style.lineHeight, 10);\n const lineHeightInRem = lineHeight / ROOT_FONT_SIZE;\n\n const minAutoHeight = minAuto ? minAuto * lineHeightInRem : 0;\n ref.current.style.height = `${minAutoHeight}rem`;\n\n const lines = Math.floor(ref.current.scrollHeight / lineHeight);\n const newScrollHeight = lines * lineHeightInRem;\n\n const maxAutoHeight = maxAuto ? maxAuto * lineHeightInRem : newScrollHeight;\n\n const newHeight = Math.min(newScrollHeight, maxAutoHeight);\n\n ref.current.style.height = `${newHeight}rem`;\n previousHeight.current = newHeight;\n }\n }, [ref, active, value]);\n};\n"],"names":["ROOT_FONT_SIZE","useAutoResize","active","ref","value","minAuto","maxAuto","isManualResize","useRef","previousHeight","useEffect","current","height","clientHeight","undefined","style","getComputedStyle","lineHeight","parseInt","lineHeightInRem","minAutoHeight","concat","lines","Math","floor","scrollHeight","newScrollHeight","maxAutoHeight","newHeight","min"],"mappings":";;;;;;AAEO,IAAMA,cAAc,GAAG,GAAE;AAEnBC,IAAAA,aAAa,GAAG,SAAhBA,aAAaA,CACtBC,MAAe,EACfC,GAA+B,EAC/BC,KAA+C,EAC/CC,OAAgB,EAChBC,OAAgB,EACf;AACD,EAAA,IAAMC,cAAc,GAAGC,YAAM,CAAU,KAAK,CAAC,CAAA;AAC7C,EAAA,IAAMC,cAAc,GAAGD,YAAM,EAAsB,CAAA;AAEnDE,EAAAA,eAAS,CAAC,YAAM;AACZ,IAAA,IAAIR,MAAM,IAAIC,GAAG,IAAIA,GAAG,CAACQ,OAAO,IAAI,CAACJ,cAAc,CAACI,OAAO,EAAE;AACzD;MACA,IAAMC,MAAM,GAAGT,GAAG,CAACQ,OAAO,CAACE,YAAY,GAAGb,cAAc,CAAA;MACxD,IAAIS,cAAc,CAACE,OAAO,KAAKG,SAAS,IAAIL,cAAc,CAACE,OAAO,KAAKC,MAAM,EAAE;QAC3EL,cAAc,CAACI,OAAO,GAAG,IAAI,CAAA;AAC7B,QAAA,OAAA;AACJ,OAAA;AAEA,MAAA,IAAMI,KAAK,GAAGC,gBAAgB,CAACb,GAAG,CAACQ,OAAO,CAAC,CAAA;MAC3C,IAAMM,UAAU,GAAGC,QAAQ,CAACH,KAAK,CAACE,UAAU,EAAE,EAAE,CAAC,CAAA;AACjD,MAAA,IAAME,eAAe,GAAGF,UAAU,GAAGjB,cAAc,CAAA;MAEnD,IAAMoB,aAAa,GAAGf,OAAO,GAAGA,OAAO,GAAGc,eAAe,GAAG,CAAC,CAAA;MAC7DhB,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAS,EAAAA,CAAAA,MAAA,CAAMD,aAAa,EAAK,KAAA,CAAA,CAAA;AAEhD,MAAA,IAAME,KAAK,GAAGC,IAAI,CAACC,KAAK,CAACrB,GAAG,CAACQ,OAAO,CAACc,YAAY,GAAGR,UAAU,CAAC,CAAA;AAC/D,MAAA,IAAMS,eAAe,GAAGJ,KAAK,GAAGH,eAAe,CAAA;MAE/C,IAAMQ,aAAa,GAAGrB,OAAO,GAAGA,OAAO,GAAGa,eAAe,GAAGO,eAAe,CAAA;MAE3E,IAAME,SAAS,GAAGL,IAAI,CAACM,GAAG,CAACH,eAAe,EAAEC,aAAa,CAAC,CAAA;MAE1DxB,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAS,EAAAA,CAAAA,MAAA,CAAMO,SAAS,EAAK,KAAA,CAAA,CAAA;MAC5CnB,cAAc,CAACE,OAAO,GAAGiB,SAAS,CAAA;AACtC,KAAA;GACH,EAAE,CAACzB,GAAG,EAAED,MAAM,EAAEE,KAAK,CAAC,CAAC,CAAA;AAC5B;;;;;"}
1
+ {"version":3,"file":"useAutoResize.js","sources":["../../../../src/components/TextArea/hooks/useAutoResize.ts"],"sourcesContent":["import { useEffect, useRef, MutableRefObject } from 'react';\n\nexport const ROOT_FONT_SIZE = 16;\n\nexport const useAutoResize = <T extends HTMLTextAreaElement>(\n active: boolean,\n ref: MutableRefObject<T | null>,\n value?: string | ReadonlyArray<string> | number,\n minHeight?: number,\n maxHeight?: number,\n) => {\n const isManualResize = useRef<boolean>(false);\n const previousHeight = useRef<number | undefined>();\n\n useEffect(() => {\n if (active && ref && ref.current && !isManualResize.current) {\n // проверка на пользовательский resize (вручную)\n const height = ref.current.clientHeight / ROOT_FONT_SIZE;\n if (previousHeight.current !== undefined && previousHeight.current !== height) {\n isManualResize.current = true;\n return;\n }\n\n ref.current.style.height = `${minHeight ? minHeight + 1 : '0'}rem`;\n const scrollHeight = ref.current.scrollHeight / ROOT_FONT_SIZE;\n const newHeight = Math.min(scrollHeight, maxHeight ? maxHeight + 1 : scrollHeight);\n\n ref.current.style.height = `${newHeight}rem`;\n previousHeight.current = newHeight;\n }\n }, [ref, active, value]);\n};\n"],"names":["ROOT_FONT_SIZE","useAutoResize","active","ref","value","minHeight","maxHeight","isManualResize","useRef","previousHeight","useEffect","current","height","clientHeight","undefined","style","concat","scrollHeight","newHeight","Math","min"],"mappings":";;;;;;AAEO,IAAMA,cAAc,GAAG,GAAE;AAEnBC,IAAAA,aAAa,GAAG,SAAhBA,aAAaA,CACtBC,MAAe,EACfC,GAA+B,EAC/BC,KAA+C,EAC/CC,SAAkB,EAClBC,SAAkB,EACjB;AACD,EAAA,IAAMC,cAAc,GAAGC,YAAM,CAAU,KAAK,CAAC,CAAA;AAC7C,EAAA,IAAMC,cAAc,GAAGD,YAAM,EAAsB,CAAA;AAEnDE,EAAAA,eAAS,CAAC,YAAM;AACZ,IAAA,IAAIR,MAAM,IAAIC,GAAG,IAAIA,GAAG,CAACQ,OAAO,IAAI,CAACJ,cAAc,CAACI,OAAO,EAAE;AACzD;MACA,IAAMC,MAAM,GAAGT,GAAG,CAACQ,OAAO,CAACE,YAAY,GAAGb,cAAc,CAAA;MACxD,IAAIS,cAAc,CAACE,OAAO,KAAKG,SAAS,IAAIL,cAAc,CAACE,OAAO,KAAKC,MAAM,EAAE;QAC3EL,cAAc,CAACI,OAAO,GAAG,IAAI,CAAA;AAC7B,QAAA,OAAA;AACJ,OAAA;AAEAR,MAAAA,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAI,EAAAA,CAAAA,MAAA,CAAMX,SAAS,GAAGA,SAAS,GAAG,CAAC,GAAG,GAAG,EAAK,KAAA,CAAA,CAAA;MAClE,IAAMY,YAAY,GAAGd,GAAG,CAACQ,OAAO,CAACM,YAAY,GAAGjB,cAAc,CAAA;AAC9D,MAAA,IAAMkB,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACH,YAAY,EAAEX,SAAS,GAAGA,SAAS,GAAG,CAAC,GAAGW,YAAY,CAAC,CAAA;MAElFd,GAAG,CAACQ,OAAO,CAACI,KAAK,CAACH,MAAM,GAAAI,EAAAA,CAAAA,MAAA,CAAME,SAAS,EAAK,KAAA,CAAA,CAAA;MAC5CT,cAAc,CAACE,OAAO,GAAGO,SAAS,CAAA;AACtC,KAAA;GACH,EAAE,CAACf,GAAG,EAAED,MAAM,EAAEE,KAAK,CAAC,CAAC,CAAA;AAC5B;;;;;"}
@@ -45,6 +45,7 @@ var SegmentProvider = function SegmentProvider(_ref) {
45
45
  }, [selectionMode, setSelectedSegmentItems]);
46
46
  var contextValue = {
47
47
  selectedSegmentItems: selectedSegmentItems,
48
+ setSelectedSegmentItems: setSelectedSegmentItems,
48
49
  handleSelect: handleSelect,
49
50
  selectionMode: selectionMode,
50
51
  setSelectionMode: setSelectionMode,
@@ -52,7 +53,9 @@ var SegmentProvider = function SegmentProvider(_ref) {
52
53
  setDisabledGroup: setDisabledGroup
53
54
  };
54
55
  useEffect(function () {
55
- setSelectedSegmentItems([]);
56
+ if (selectionMode === 'single' && (selectedSegmentItems === null || selectedSegmentItems === void 0 ? void 0 : selectedSegmentItems.length) > 0) {
57
+ setSelectedSegmentItems([selectedSegmentItems[0]]);
58
+ }
56
59
  }, [selectionMode]);
57
60
  return /*#__PURE__*/React.createElement(SegmentContext.Provider, {
58
61
  value: contextValue
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentProvider.js","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { SegmentContextType, SegmentSelectionMode } from './SegmentProvider.types';\n\nexport const SegmentContext = createContext<SegmentContextType | undefined>(undefined);\n\nexport const useSegmentInner = () => {\n const context = useContext(SegmentContext);\n if (!context) {\n throw new Error('useSegment must be used within a SegmentProvider');\n }\n return context;\n};\n\nexport const useSegment = () => {\n const { selectedSegmentItems } = useSegmentInner();\n return { selectedSegmentItems };\n};\n\nexport const SegmentProvider: FC<PropsWithChildren> = ({ children }) => {\n const [selectedSegmentItems, setSelectedSegmentItems] = useState<string[]>([]);\n const [selectionMode, setSelectionMode] = useState<SegmentSelectionMode>('single');\n const [disabledGroup, setDisabledGroup] = useState(false);\n\n const handleSelect = useCallback(\n (label: string) => {\n if (selectionMode !== 'multiple') {\n setSelectedSegmentItems((prevSelected) => (prevSelected.includes(label) ? [] : [label]));\n return;\n }\n\n setSelectedSegmentItems((prevSelected) =>\n prevSelected.includes(label) ? prevSelected.filter((item) => item !== label) : [...prevSelected, label],\n );\n },\n [selectionMode, setSelectedSegmentItems],\n );\n\n const contextValue: SegmentContextType = {\n selectedSegmentItems,\n handleSelect,\n selectionMode,\n setSelectionMode,\n disabledGroup,\n setDisabledGroup,\n };\n\n useEffect(() => {\n setSelectedSegmentItems([]);\n }, [selectionMode]);\n\n return <SegmentContext.Provider value={contextValue}>{children}</SegmentContext.Provider>;\n};\n"],"names":["SegmentContext","createContext","undefined","useSegmentInner","context","useContext","Error","useSegment","_useSegmentInner","selectedSegmentItems","SegmentProvider","_ref","children","_useState","useState","_useState2","_slicedToArray","setSelectedSegmentItems","_useState3","_useState4","selectionMode","setSelectionMode","_useState5","_useState6","disabledGroup","setDisabledGroup","handleSelect","useCallback","label","prevSelected","includes","filter","item","concat","_toConsumableArray","contextValue","useEffect","React","createElement","Provider","value"],"mappings":";;;IAKaA,cAAc,gBAAGC,aAAa,CAAiCC,SAAS,EAAC;IAEzEC,eAAe,GAAG,SAAlBA,eAAeA,GAAS;AACjC,EAAA,IAAMC,OAAO,GAAGC,UAAU,CAACL,cAAc,CAAC,CAAA;EAC1C,IAAI,CAACI,OAAO,EAAE;AACV,IAAA,MAAM,IAAIE,KAAK,CAAC,kDAAkD,CAAC,CAAA;AACvE,GAAA;AACA,EAAA,OAAOF,OAAO,CAAA;AAClB,EAAC;IAEYG,UAAU,GAAG,SAAbA,UAAUA,GAAS;AAC5B,EAAA,IAAAC,gBAAA,GAAiCL,eAAe,EAAE;IAA1CM,oBAAoB,GAAAD,gBAAA,CAApBC,oBAAoB,CAAA;EAC5B,OAAO;AAAEA,IAAAA,oBAAoB,EAApBA,oBAAAA;GAAsB,CAAA;AACnC,EAAC;IAEYC,eAAsC,GAAG,SAAzCA,eAAsCA,CAAAC,IAAA,EAAqB;AAAA,EAAA,IAAfC,QAAQ,GAAAD,IAAA,CAARC,QAAQ,CAAA;AAC7D,EAAA,IAAAC,SAAA,GAAwDC,QAAQ,CAAW,EAAE,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAvEJ,IAAAA,oBAAoB,GAAAM,UAAA,CAAA,CAAA,CAAA;AAAEE,IAAAA,uBAAuB,GAAAF,UAAA,CAAA,CAAA,CAAA,CAAA;AACpD,EAAA,IAAAG,UAAA,GAA0CJ,QAAQ,CAAuB,QAAQ,CAAC;IAAAK,UAAA,GAAAH,cAAA,CAAAE,UAAA,EAAA,CAAA,CAAA;AAA3EE,IAAAA,aAAa,GAAAD,UAAA,CAAA,CAAA,CAAA;AAAEE,IAAAA,gBAAgB,GAAAF,UAAA,CAAA,CAAA,CAAA,CAAA;AACtC,EAAA,IAAAG,UAAA,GAA0CR,QAAQ,CAAC,KAAK,CAAC;IAAAS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AAOiB,KAAA,CAAAC,aAAA,CAACtC,cAAc,CAACuC,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEL,YAAAA;AAAa,GAAA,EAAEvB,QAAkC,CAAC,CAAA;AAC7F;;;;"}
1
+ {"version":3,"file":"SegmentProvider.js","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { SegmentContextType, SegmentSelectionMode } from './SegmentProvider.types';\n\nexport const SegmentContext = createContext<SegmentContextType | undefined>(undefined);\n\nexport const useSegmentInner = () => {\n const context = useContext(SegmentContext);\n if (!context) {\n throw new Error('useSegment must be used within a SegmentProvider');\n }\n return context;\n};\n\nexport const useSegment = () => {\n const { selectedSegmentItems } = useSegmentInner();\n return { selectedSegmentItems };\n};\n\nexport const SegmentProvider: FC<PropsWithChildren> = ({ children }) => {\n const [selectedSegmentItems, setSelectedSegmentItems] = useState<string[]>([]);\n const [selectionMode, setSelectionMode] = useState<SegmentSelectionMode>('single');\n const [disabledGroup, setDisabledGroup] = useState(false);\n\n const handleSelect = useCallback(\n (label: string) => {\n if (selectionMode !== 'multiple') {\n setSelectedSegmentItems((prevSelected) => (prevSelected.includes(label) ? [] : [label]));\n return;\n }\n\n setSelectedSegmentItems((prevSelected) =>\n prevSelected.includes(label) ? prevSelected.filter((item) => item !== label) : [...prevSelected, label],\n );\n },\n [selectionMode, setSelectedSegmentItems],\n );\n\n const contextValue: SegmentContextType = {\n selectedSegmentItems,\n setSelectedSegmentItems,\n handleSelect,\n selectionMode,\n setSelectionMode,\n disabledGroup,\n setDisabledGroup,\n };\n\n useEffect(() => {\n if (selectionMode === 'single' && selectedSegmentItems?.length > 0) {\n setSelectedSegmentItems([selectedSegmentItems[0]]);\n }\n }, [selectionMode]);\n\n return <SegmentContext.Provider value={contextValue}>{children}</SegmentContext.Provider>;\n};\n"],"names":["SegmentContext","createContext","undefined","useSegmentInner","context","useContext","Error","useSegment","_useSegmentInner","selectedSegmentItems","SegmentProvider","_ref","children","_useState","useState","_useState2","_slicedToArray","setSelectedSegmentItems","_useState3","_useState4","selectionMode","setSelectionMode","_useState5","_useState6","disabledGroup","setDisabledGroup","handleSelect","useCallback","label","prevSelected","includes","filter","item","concat","_toConsumableArray","contextValue","useEffect","length","React","createElement","Provider","value"],"mappings":";;;IAKaA,cAAc,gBAAGC,aAAa,CAAiCC,SAAS,EAAC;IAEzEC,eAAe,GAAG,SAAlBA,eAAeA,GAAS;AACjC,EAAA,IAAMC,OAAO,GAAGC,UAAU,CAACL,cAAc,CAAC,CAAA;EAC1C,IAAI,CAACI,OAAO,EAAE;AACV,IAAA,MAAM,IAAIE,KAAK,CAAC,kDAAkD,CAAC,CAAA;AACvE,GAAA;AACA,EAAA,OAAOF,OAAO,CAAA;AAClB,EAAC;IAEYG,UAAU,GAAG,SAAbA,UAAUA,GAAS;AAC5B,EAAA,IAAAC,gBAAA,GAAiCL,eAAe,EAAE;IAA1CM,oBAAoB,GAAAD,gBAAA,CAApBC,oBAAoB,CAAA;EAC5B,OAAO;AAAEA,IAAAA,oBAAoB,EAApBA,oBAAAA;GAAsB,CAAA;AACnC,EAAC;IAEYC,eAAsC,GAAG,SAAzCA,eAAsCA,CAAAC,IAAA,EAAqB;AAAA,EAAA,IAAfC,QAAQ,GAAAD,IAAA,CAARC,QAAQ,CAAA;AAC7D,EAAA,IAAAC,SAAA,GAAwDC,QAAQ,CAAW,EAAE,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAvEJ,IAAAA,oBAAoB,GAAAM,UAAA,CAAA,CAAA,CAAA;AAAEE,IAAAA,uBAAuB,GAAAF,UAAA,CAAA,CAAA,CAAA,CAAA;AACpD,EAAA,IAAAG,UAAA,GAA0CJ,QAAQ,CAAuB,QAAQ,CAAC;IAAAK,UAAA,GAAAH,cAAA,CAAAE,UAAA,EAAA,CAAA,CAA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AAChBG,IAAAA,aAAa,EAAbA,aAAa;AACbC,IAAAA,gBAAgB,EAAhBA,gBAAAA;GACH,CAAA;AAEDW,EAAAA,SAAS,CAAC,YAAM;AACZ,IAAA,IAAIhB,aAAa,KAAK,QAAQ,IAAI,CAAAX,oBAAoB,KAAA,IAAA,IAApBA,oBAAoB,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAApBA,oBAAoB,CAAE4B,MAAM,IAAG,CAAC,EAAE;AAChEpB,MAAAA,uBAAuB,CAAC,CAACR,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACtD,KAAA;AACJ,GAAC,EAAE,CAACW,aAAa,CAAC,CAAC,CAAA;AAEnB,EAAA,oBAAOkB,KAAA,CAAAC,aAAA,CAACvC,cAAc,CAACwC,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEN,YAAAA;AAAa,GAAA,EAAEvB,QAAkC,CAAC,CAAA;AAC7F;;;;"}
@@ -15,7 +15,7 @@ import { base as base$6 } from './variations/_filledBackgound/base.js';
15
15
  import { base as base$5 } from './variations/_stretch/base.js';
16
16
  import { StyledArrow, StyledContentWrapper, StyledContent, base } from './SegmentGroup.styles.js';
17
17
 
18
- var _excluded = ["id", "selectionMode", "pilled", "stretch", "filledBackground", "disabled", "size", "view", "children"];
18
+ var _excluded = ["id", "selectionMode", "pilled", "stretch", "filledBackground", "disabled", "size", "view", "children", "defaultSelected"];
19
19
  var segmentGroupRoot = function segmentGroupRoot(Root) {
20
20
  return /*#__PURE__*/forwardRef(function (props, outerRef) {
21
21
  var id = props.id,
@@ -29,10 +29,12 @@ var segmentGroupRoot = function segmentGroupRoot(Root) {
29
29
  size = props.size,
30
30
  view = props.view,
31
31
  children = props.children,
32
+ defaultSelected = props.defaultSelected,
32
33
  rest = _objectWithoutProperties(props, _excluded);
33
34
  var _useSegmentInner = useSegmentInner(),
34
35
  setSelectionMode = _useSegmentInner.setSelectionMode,
35
- setDisabledGroup = _useSegmentInner.setDisabledGroup;
36
+ setDisabledGroup = _useSegmentInner.setDisabledGroup,
37
+ setSelectedSegmentItems = _useSegmentInner.setSelectedSegmentItems;
36
38
  var _useState = useState(0),
37
39
  _useState2 = _slicedToArray(_useState, 2),
38
40
  index = _useState2[0],
@@ -116,6 +118,11 @@ var segmentGroupRoot = function segmentGroupRoot(Root) {
116
118
  selectionMode && setSelectionMode(selectionMode);
117
119
  setDisabledGroup(disabled);
118
120
  }, [selectionMode, disabled]);
121
+ useEffect(function () {
122
+ if (defaultSelected !== null && defaultSelected !== void 0 && defaultSelected.length) {
123
+ setSelectedSegmentItems(defaultSelected);
124
+ }
125
+ }, [defaultSelected]);
119
126
  useEffect(function () {
120
127
  var _trackRef$current;
121
128
  // Intersection observer для первого сегмента
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentGroup.js","sources":["../../../../../src/components/Segment/ui/SegmentGroup/SegmentGroup.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, Children, useEffect } from 'react';\nimport type { SetStateAction, RefObject, MutableRefObject } from 'react';\nimport { safeUseId, useCarousel } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { useSegmentInner } from '../../SegmentProvider/SegmentProvider';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as filledBackgroundCSS } from './variations/_filledBackgound/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport type { SegmentGroupProps } from './SegmentGroup.types';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './SegmentGroup.styles';\n\nexport const segmentGroupRoot = (Root: RootProps<HTMLDivElement, SegmentGroupProps>) =>\n forwardRef<HTMLDivElement, SegmentGroupProps>((props, outerRef) => {\n const {\n id,\n selectionMode,\n pilled,\n stretch,\n filledBackground = false,\n disabled = false,\n size,\n view,\n children,\n ...rest\n } = props;\n\n const { setSelectionMode, setDisabledGroup } = useSegmentInner();\n\n const [index, setIndex] = useState(0);\n const [firstItemVisible, setFirstItemVisible] = useState(false);\n const [lastItemVisible, setLastItemVisible] = useState(false);\n\n const uniqId = safeUseId();\n const segmentGroupId = id || uniqId;\n\n const pilledAttr = view !== 'clear' && pilled;\n const filledBackgroundAttr = view !== 'clear' && filledBackground;\n const pilledClass = pilledAttr ? classes.segmentPilled : undefined;\n const filledClass = filledBackgroundAttr ? classes.segmentGroupFilledBackground : undefined;\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.segmentStretch : undefined;\n\n const items = Children?.map(children, (child) => child) || [];\n\n const onPrev = useCallback(() => {\n !disabled && setIndex((prevIndex) => (prevIndex > 0 ? prevIndex - 1 : 0));\n }, [disabled]);\n\n const onNext = useCallback(() => {\n !disabled && setIndex((prevIndex) => (prevIndex < items.length - 1 ? prevIndex + 1 : prevIndex));\n }, [disabled]);\n\n const onIntersecting = (setVisible: (value: SetStateAction<boolean>) => void) => (\n entries: IntersectionObserverEntry[],\n ) => {\n /*\n * Пробегаемся по элементам на которых есть слушатель события появления.\n * Если элемент находится в зоне видимости или выходит из нее, меняем значение флага видимости\n */\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setVisible(true);\n } else {\n setVisible(false);\n }\n });\n };\n\n const { scrollRef, trackRef } = useCarousel({\n index,\n axis: 'x',\n scrollAlign: 'start',\n detectActive: true,\n debounceMs: 250,\n onIndexChange: setIndex,\n });\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий сегмент\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий сегмент\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext],\n );\n\n useEffect(() => {\n selectionMode && setSelectionMode(selectionMode);\n setDisabledGroup(disabled);\n }, [selectionMode, disabled]);\n\n useEffect(() => {\n // Intersection observer для первого сегмента\n const observeFirstItem = new IntersectionObserver(onIntersecting(setFirstItemVisible), {\n root: null,\n rootMargin: '0px',\n threshold: 0.5,\n });\n\n // Intersection observer для последнего сегмента\n const observeLastItem = new IntersectionObserver(onIntersecting(setLastItemVisible), {\n root: null,\n rootMargin: '0px',\n threshold: 0.5,\n });\n\n // получаем список сегментов внутри SegmentGroup\n const childrenArray = Array.from(trackRef.current?.children || []) as Array<Element>;\n if (childrenArray.length) {\n // подписываемся на событие появление внутри SegmentGroup\n observeFirstItem.observe(childrenArray[0]);\n observeLastItem.observe(childrenArray[childrenArray.length - 1]);\n }\n\n return () => {\n // отписываемся от события появления внутри SegmentGroup\n observeFirstItem.disconnect();\n observeLastItem.disconnect();\n };\n }, [children]);\n\n return (\n <Root\n view={view}\n size={size}\n id={segmentGroupId}\n ref={outerRef}\n filledBackground={filledBackgroundAttr}\n disabled={disabled}\n pilled={pilledAttr}\n className={cx(pilledClass, filledClass, stretchClass)}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper ref={scrollRef as RefObject<HTMLDivElement>}>\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>{children}</StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n );\n });\n\nexport const segmentGroupConfig = {\n name: 'SegmentGroup',\n tag: 'div',\n layout: segmentGroupRoot,\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 pilled: {\n css: pilledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n filledBackground: {\n css: filledBackgroundCSS,\n attrs: true,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["segmentGroupRoot","Root","forwardRef","props","outerRef","id","selectionMode","pilled","stretch","_props$filledBackgrou","filledBackground","_props$disabled","disabled","size","view","children","rest","_objectWithoutProperties","_excluded","_useSegmentInner","useSegmentInner","setSelectionMode","setDisabledGroup","_useState","useState","_useState2","_slicedToArray","index","setIndex","_useState3","_useState4","firstItemVisible","setFirstItemVisible","_useState5","_useState6","lastItemVisible","setLastItemVisible","uniqId","safeUseId","segmentGroupId","pilledAttr","filledBackgroundAttr","pilledClass","classes","segmentPilled","undefined","filledClass","segmentGroupFilledBackground","stretchClass","segmentStretch","items","Children","map","child","onPrev","useCallback","prevIndex","onNext","length","onIntersecting","setVisible","entries","forEach","entry","isIntersecting","_useCarousel","useCarousel","axis","scrollAlign","detectActive","debounceMs","onIndexChange","scrollRef","trackRef","PreviousButton","useMemo","React","createElement","StyledArrow","type","onClick","tabIndex","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","useEffect","_trackRef$current","observeFirstItem","IntersectionObserver","root","rootMargin","threshold","observeLastItem","childrenArray","Array","from","current","observe","disconnect","_extends","ref","className","cx","StyledContentWrapper","StyledContent","segmentGroupConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","pilledCSS","stretchCSS","filledBackgroundCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;IAmBaA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,IAAkD,EAAA;AAAA,EAAA,oBAC/EC,UAAU,CAAoC,UAACC,KAAK,EAAEC,QAAQ,EAAK;AAC/D,IAAA,IACIC,EAAE,GAUFF,KAAK,CAVLE,EAAE;MACFC,aAAa,GASbH,KAAK,CATLG,aAAa;MACbC,MAAM,GAQNJ,KAAK,CARLI,MAAM;MACNC,OAAO,GAOPL,KAAK,CAPLK,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ui/SegmentGroup/SegmentGroup.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, Children, useEffect } from 'react';\nimport type { SetStateAction, RefObject, MutableRefObject } from 'react';\nimport { safeUseId, useCarousel } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { useSegmentInner } from '../../SegmentProvider/SegmentProvider';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as filledBackgroundCSS } from './variations/_filledBackgound/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport type { SegmentGroupProps } from './SegmentGroup.types';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './SegmentGroup.styles';\n\nexport const segmentGroupRoot = (Root: RootProps<HTMLDivElement, SegmentGroupProps>) =>\n forwardRef<HTMLDivElement, SegmentGroupProps>((props, outerRef) => {\n const {\n id,\n selectionMode,\n pilled,\n stretch,\n filledBackground = false,\n disabled = false,\n size,\n view,\n children,\n defaultSelected,\n ...rest\n } = props;\n\n const { setSelectionMode, setDisabledGroup, setSelectedSegmentItems } = useSegmentInner();\n\n const [index, setIndex] = useState(0);\n const [firstItemVisible, setFirstItemVisible] = useState(false);\n const [lastItemVisible, setLastItemVisible] = useState(false);\n\n const uniqId = safeUseId();\n const segmentGroupId = id || uniqId;\n\n const pilledAttr = view !== 'clear' && pilled;\n const filledBackgroundAttr = view !== 'clear' && filledBackground;\n const pilledClass = pilledAttr ? classes.segmentPilled : undefined;\n const filledClass = filledBackgroundAttr ? classes.segmentGroupFilledBackground : undefined;\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.segmentStretch : undefined;\n\n const items = Children?.map(children, (child) => child) || [];\n\n const onPrev = useCallback(() => {\n !disabled && setIndex((prevIndex) => (prevIndex > 0 ? prevIndex - 1 : 0));\n }, [disabled]);\n\n const onNext = useCallback(() => {\n !disabled && setIndex((prevIndex) => (prevIndex < items.length - 1 ? prevIndex + 1 : prevIndex));\n }, [disabled]);\n\n const onIntersecting = (setVisible: (value: SetStateAction<boolean>) => void) => (\n entries: IntersectionObserverEntry[],\n ) => {\n /*\n * Пробегаемся по элементам на которых есть слушатель события появления.\n * Если элемент находится в зоне видимости или выходит из нее, меняем значение флага видимости\n */\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setVisible(true);\n } else {\n setVisible(false);\n }\n });\n };\n\n const { scrollRef, trackRef } = useCarousel({\n index,\n axis: 'x',\n scrollAlign: 'start',\n detectActive: true,\n debounceMs: 250,\n onIndexChange: setIndex,\n });\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий сегмент\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий сегмент\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext],\n );\n\n useEffect(() => {\n selectionMode && setSelectionMode(selectionMode);\n setDisabledGroup(disabled);\n }, [selectionMode, disabled]);\n\n useEffect(() => {\n if (defaultSelected?.length) {\n setSelectedSegmentItems(defaultSelected);\n }\n }, [defaultSelected]);\n\n useEffect(() => {\n // Intersection observer для первого сегмента\n const observeFirstItem = new IntersectionObserver(onIntersecting(setFirstItemVisible), {\n root: null,\n rootMargin: '0px',\n threshold: 0.5,\n });\n\n // Intersection observer для последнего сегмента\n const observeLastItem = new IntersectionObserver(onIntersecting(setLastItemVisible), {\n root: null,\n rootMargin: '0px',\n threshold: 0.5,\n });\n\n // получаем список сегментов внутри SegmentGroup\n const childrenArray = Array.from(trackRef.current?.children || []) as Array<Element>;\n if (childrenArray.length) {\n // подписываемся на событие появление внутри SegmentGroup\n observeFirstItem.observe(childrenArray[0]);\n observeLastItem.observe(childrenArray[childrenArray.length - 1]);\n }\n\n return () => {\n // отписываемся от события появления внутри SegmentGroup\n observeFirstItem.disconnect();\n observeLastItem.disconnect();\n };\n }, [children]);\n\n return (\n <Root\n view={view}\n size={size}\n id={segmentGroupId}\n ref={outerRef}\n filledBackground={filledBackgroundAttr}\n disabled={disabled}\n pilled={pilledAttr}\n className={cx(pilledClass, filledClass, stretchClass)}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper ref={scrollRef as RefObject<HTMLDivElement>}>\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>{children}</StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n );\n });\n\nexport const segmentGroupConfig = {\n name: 'SegmentGroup',\n tag: 'div',\n layout: segmentGroupRoot,\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 pilled: {\n css: pilledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n filledBackground: {\n css: filledBackgroundCSS,\n attrs: true,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["segmentGroupRoot","Root","forwardRef","props","outerRef","id","selectionMode","pilled","stretch","_props$filledBackgrou","filledBackground","_props$disabled","disabled","size","view","children","defaultSelected","rest","_objectWithoutProperties","_excluded","_useSegmentInner","useSegmentInner","setSelectionMode","setDisabledGroup","setSelectedSegmentItems","_useState","useState","_useState2","_slicedToArray","index","setIndex","_useState3","_useState4","firstItemVisible","setFirstItemVisible","_useState5","_useState6","lastItemVisible","setLastItemVisible","uniqId","safeUseId","segmentGroupId","pilledAttr","filledBackgroundAttr","pilledClass","classes","segmentPilled","undefined","filledClass","segmentGroupFilledBackground","stretchClass","segmentStretch","items","Children","map","child","onPrev","useCallback","prevIndex","onNext","length","onIntersecting","setVisible","entries","forEach","entry","isIntersecting","_useCarousel","useCarousel","axis","scrollAlign","detectActive","debounceMs","onIndexChange","scrollRef","trackRef","PreviousButton","useMemo","React","createElement","StyledArrow","type","onClick","tabIndex","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","useEffect","_trackRef$current","observeFirstItem","IntersectionObserver","root","rootMargin","threshold","observeLastItem","childrenArray","Array","from","current","observe","disconnect","_extends","ref","className","cx","StyledContentWrapper","StyledContent","segmentGroupConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","pilledCSS","stretchCSS","filledBackgroundCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;IAmBaA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,IAAkD,EAAA;AAAA,EAAA,oBAC/EC,UAAU,CAAoC,UAACC,KAAK,EAAEC,QAAQ,EAAK;AAC/D,IAAA,IACIC,EAAE,GAWFF,KAAK,CAXLE,EAAE;MACFC,aAAa,GAUbH,KAAK,CAVLG,aAAa;MACbC,MAAM,GASNJ,KAAK,CATLI,MAAM;MACNC,OAAO,GAQPL,KAAK,CARLK,OAAO;MAAAC,qBAAA,GAQPN,KAAK,CAPLO,gBAAgB;AAAhBA,MAAAA,gBAAgB,GAAAD,qBAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,qBAAA;MAAAE,eAAA,GAOxBR,KAAK,CANLS,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,eAAA;MAChBE,IAAI,GAKJV,KAAK,CALLU,IAAI;MACJC,IAAI,GAIJX,KAAK,CAJLW,IAAI;MACJC,QAAQ,GAGRZ,KAAK,CAHLY,QAAQ;MACRC,eAAe,GAEfb,KAAK,CAFLa,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,EAAA;AAACH,MAAAA,GAAG,EAAEhC,SAAAA;AAAuC,KAAA,eAC9DI,KAAA,CAAAC,aAAA,CAAC+B,aAAa,EAAA;AAACJ,MAAAA,GAAG,EAAE/B,QAAAA;KAAsD5D,EAAAA,QAAwB,CAChF,CAAC,EACtB,CAACsB,eAAe,IAAIoD,UACnB,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMsB,kBAAkB,GAAG;AAC9BC,EAAAA,IAAI,EAAE,cAAc;AACpBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElH,gBAAgB;AACxBmH,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACRvG,IAAAA,IAAI,EAAE;AACFwG,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACDxG,IAAAA,IAAI,EAAE;AACFuG,MAAAA,GAAG,EAAEE,MAAAA;KACR;AACD3G,IAAAA,QAAQ,EAAE;AACNyG,MAAAA,GAAG,EAAEG,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDlH,IAAAA,MAAM,EAAE;AACJ8G,MAAAA,GAAG,EAAEK,MAAS;AACdD,MAAAA,KAAK,EAAE,IAAA;KACV;AACDjH,IAAAA,OAAO,EAAE;AACL6G,MAAAA,GAAG,EAAEM,MAAU;AACfF,MAAAA,KAAK,EAAE,IAAA;KACV;AACD/G,IAAAA,gBAAgB,EAAE;AACd2G,MAAAA,GAAG,EAAEO,MAAmB;AACxBH,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDI,EAAAA,QAAQ,EAAE;AACN/G,IAAAA,IAAI,EAAE,OAAO;AACbD,IAAAA,IAAI,EAAE,IAAA;AACV,GAAA;AACJ;;;;"}
@@ -1,5 +1,5 @@
1
1
  import './TextArea_ob9y3r.css';
2
- import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
3
3
  import React, { forwardRef, useState, useCallback, createRef } from 'react';
4
4
  import { useResizeObserver } from '@salutejs/plasma-core';
5
5
  import { cx } from '../../utils/index.js';
@@ -123,17 +123,15 @@ var textAreaRoot = function textAreaRoot(Root) {
123
123
  }
124
124
  onChange === null || onChange === void 0 || onChange(event);
125
125
  }, [value, onChange]);
126
- var dynamicLabelClasses = getDynamicLabelClasses(_objectSpread2({
126
+ var dynamicLabelClasses = getDynamicLabelClasses({
127
127
  size: size,
128
128
  readOnly: readOnly,
129
129
  label: label,
130
130
  labelPlacement: labelPlacement,
131
+ autoResize: autoResize,
132
+ rows: rows,
131
133
  value: value || uncontrolledValue || defaultValue
132
- }, rows ? {
133
- rows: rows
134
- } : {
135
- autoResize: autoResize
136
- }), focused);
134
+ }, focused);
137
135
  return /*#__PURE__*/React.createElement(Root, {
138
136
  view: overriddenView,
139
137
  size: size,