@salutejs/plasma-new-hope 0.93.0-canary.1252.9677594480.0 → 0.93.0-dev.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,11 +57,6 @@ var SegmentProvider = function SegmentProvider(_ref) {
57
57
  disabledGroup: disabledGroup,
58
58
  setDisabledGroup: setDisabledGroup
59
59
  };
60
- React.useEffect(function () {
61
- if (selectionMode === 'single' && (selectedSegmentItems === null || selectedSegmentItems === void 0 ? void 0 : selectedSegmentItems.length) > 0) {
62
- setSelectedSegmentItems([selectedSegmentItems[0]]);
63
- }
64
- }, [selectionMode]);
65
60
  return /*#__PURE__*/React.createElement(SegmentContext.Provider, {
66
61
  value: contextValue
67
62
  }, children);
@@ -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 } from 'react';\n\nimport { SegmentContextType, SegmentProviderProps, 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<SegmentProviderProps> = ({ children, defaultSelected }) => {\n const [selectedSegmentItems, setSelectedSegmentItems] = useState<string[]>(defaultSelected || []);\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","defaultSelected","_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,GAAiCL,eAAe,EAAE;IAA1CM,oBAAoB,GAAAD,gBAAA,CAApBC,oBAAoB,CAAA;EAC5B,OAAO;AAAEA,IAAAA,oBAAoB,EAApBA,oBAAAA;GAAsB,CAAA;AACnC,EAAC;IAEYC,eAAyC,GAAG,SAA5CA,eAAyCA,CAAAC,IAAA,EAAsC;AAAA,EAAA,IAAhCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,eAAe,GAAAF,IAAA,CAAfE,eAAe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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;AACrC3B,IAAAA,oBAAoB,EAApBA,oBAAoB;AACpBS,IAAAA,uBAAuB,EAAvBA,uBAAuB;AACvBS,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;AACZ,IAAA,IAAIhB,aAAa,KAAK,QAAQ,IAAI,CAAAZ,oBAAoB,KAAA,IAAA,IAApBA,oBAAoB,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAApBA,oBAAoB,CAAE6B,MAAM,IAAG,CAAC,EAAE;AAChEpB,MAAAA,uBAAuB,CAAC,CAACT,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACtD,KAAA;AACJ,GAAC,EAAE,CAACY,aAAa,CAAC,CAAC,CAAA;AAEnB,EAAA,oBAAOkB,KAAA,CAAAC,aAAA,CAACxC,cAAc,CAACyC,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEN,YAAAA;AAAa,GAAA,EAAExB,QAAkC,CAAC,CAAA;AAC7F;;;;;;;"}
1
+ {"version":3,"file":"SegmentProvider.js","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useState } from 'react';\nimport type { FC } from 'react';\n\nimport { SegmentContextType, SegmentProviderProps, 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<SegmentProviderProps> = ({ children, defaultSelected }) => {\n const [selectedSegmentItems, setSelectedSegmentItems] = useState<string[]>(defaultSelected || []);\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 return <SegmentContext.Provider value={contextValue}>{children}</SegmentContext.Provider>;\n};\n"],"names":["SegmentContext","createContext","undefined","useSegmentInner","context","useContext","Error","useSegment","_useSegmentInner","selectedSegmentItems","SegmentProvider","_ref","children","defaultSelected","_useState","useState","_useState2","_slicedToArray","setSelectedSegmentItems","_useState3","_useState4","selectionMode","setSelectionMode","_useState5","_useState6","disabledGroup","setDisabledGroup","handleSelect","useCallback","label","prevSelected","includes","filter","item","concat","_toConsumableArray","contextValue","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;AAC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AU,EAAE;MAC9BH,uBAAuB,CAAC,UAACY,YAAY,EAAA;QAAA,OAAMA,YAAY,CAACC,QAAQ,CAACF,KAAK,CAAC,GAAG,EAAE,GAAG,CAACA,KAAK,CAAC,CAAA;AAAA,OAAC,CAAC,CAAA;AACxF,MAAA,OAAA;AACJ,KAAA;IAEAX,uBAAuB,CAAC,UAACY,YAAY,EAAA;AAAA,MAAA,OACjCA,YAAY,CAACC,QAAQ,CAACF,KAAK,CAAC,GAAGC,YAAY,CAACE,MAAM,CAAC,UAACC,IAAI,EAAA;QAAA,OAAKA,IAAI,KAAKJ,KAAK,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;AACrC3B,IAAAA,oBAAoB,EAApBA,oBAAoB;AACpBS,IAAAA,uBAAuB,EAAvBA,uBAAuB;AACvBS,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;AAED,EAAA,oBAAOW,KAAA,CAAAC,aAAA,CAACtC,cAAc,CAACuC,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEJ,YAAAA;AAAa,GAAA,EAAExB,QAAkC,CAAC,CAAA;AAC7F;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
- import React, { useState, useCallback, useEffect, createContext, useContext } from 'react';
2
+ import React, { useState, useCallback, createContext, useContext } from 'react';
3
3
 
4
4
  var SegmentContext = /*#__PURE__*/createContext(undefined);
5
5
  var useSegmentInner = function useSegmentInner() {
@@ -53,11 +53,6 @@ var SegmentProvider = function SegmentProvider(_ref) {
53
53
  disabledGroup: disabledGroup,
54
54
  setDisabledGroup: setDisabledGroup
55
55
  };
56
- useEffect(function () {
57
- if (selectionMode === 'single' && (selectedSegmentItems === null || selectedSegmentItems === void 0 ? void 0 : selectedSegmentItems.length) > 0) {
58
- setSelectedSegmentItems([selectedSegmentItems[0]]);
59
- }
60
- }, [selectionMode]);
61
56
  return /*#__PURE__*/React.createElement(SegmentContext.Provider, {
62
57
  value: contextValue
63
58
  }, children);
@@ -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 } from 'react';\n\nimport { SegmentContextType, SegmentProviderProps, 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<SegmentProviderProps> = ({ children, defaultSelected }) => {\n const [selectedSegmentItems, setSelectedSegmentItems] = useState<string[]>(defaultSelected || []);\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","defaultSelected","_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,eAAyC,GAAG,SAA5CA,eAAyCA,CAAAC,IAAA,EAAsC;AAAA,EAAA,IAAhCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,eAAe,GAAAF,IAAA,CAAfE,eAAe,CAAA;AACjF,EAAA,IAAAC,SAAA,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A,CAAED,KAAK,CAAC,CAAA,CAAA;AAAA,KAC3G,CAAC,CAAA;AACL,GAAC,EACD,CAACR,aAAa,EAAEH,uBAAuB,CAC3C,CAAC,CAAA;AAED,EAAA,IAAMkB,YAAgC,GAAG;AACrC3B,IAAAA,oBAAoB,EAApBA,oBAAoB;AACpBS,IAAAA,uBAAuB,EAAvBA,uBAAuB;AACvBS,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,SAAS,CAAC,YAAM;AACZ,IAAA,IAAIhB,aAAa,KAAK,QAAQ,IAAI,CAAAZ,oBAAoB,KAAA,IAAA,IAApBA,oBAAoB,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAApBA,oBAAoB,CAAE6B,MAAM,IAAG,CAAC,EAAE;AAChEpB,MAAAA,uBAAuB,CAAC,CAACT,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACtD,KAAA;AACJ,GAAC,EAAE,CAACY,aAAa,CAAC,CAAC,CAAA;AAEnB,EAAA,oBAAOkB,KAAA,CAAAC,aAAA,CAACxC,cAAc,CAACyC,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEN,YAAAA;AAAa,GAAA,EAAExB,QAAkC,CAAC,CAAA;AAC7F;;;;"}
1
+ {"version":3,"file":"SegmentProvider.js","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useState } from 'react';\nimport type { FC } from 'react';\n\nimport { SegmentContextType, SegmentProviderProps, 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<SegmentProviderProps> = ({ children, defaultSelected }) => {\n const [selectedSegmentItems, setSelectedSegmentItems] = useState<string[]>(defaultSelected || []);\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 return <SegmentContext.Provider value={contextValue}>{children}</SegmentContext.Provider>;\n};\n"],"names":["SegmentContext","createContext","undefined","useSegmentInner","context","useContext","Error","useSegment","_useSegmentInner","selectedSegmentItems","SegmentProvider","_ref","children","defaultSelected","_useState","useState","_useState2","_slicedToArray","setSelectedSegmentItems","_useState3","_useState4","selectionMode","setSelectionMode","_useState5","_useState6","disabledGroup","setDisabledGroup","handleSelect","useCallback","label","prevSelected","includes","filter","item","concat","_toConsumableArray","contextValue","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,EA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AA,OAAMA,YAAY,CAACC,QAAQ,CAACF,KAAK,CAAC,GAAG,EAAE,GAAG,CAACA,KAAK,CAAC,CAAA;AAAA,OAAC,CAAC,CAAA;AACxF,MAAA,OAAA;AACJ,KAAA;IAEAX,uBAAuB,CAAC,UAACY,YAAY,EAAA;AAAA,MAAA,OACjCA,YAAY,CAACC,QAAQ,CAACF,KAAK,CAAC,GAAGC,YAAY,CAACE,MAAM,CAAC,UAACC,IAAI,EAAA;QAAA,OAAKA,IAAI,KAAKJ,KAAK,CAAA;OAAC,CAAA,GAAA,EAAA,CAAAK,MAAA,CAAAC,kBAAA,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;AACrC3B,IAAAA,oBAAoB,EAApBA,oBAAoB;AACpBS,IAAAA,uBAAuB,EAAvBA,uBAAuB;AACvBS,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;AAED,EAAA,oBAAOW,KAAA,CAAAC,aAAA,CAACtC,cAAc,CAACuC,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEJ,YAAAA;AAAa,GAAA,EAAExB,QAAkC,CAAC,CAAA;AAC7F;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salutejs/plasma-new-hope",
3
- "version": "0.93.0-canary.1252.9677594480.0",
3
+ "version": "0.93.0-dev.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": "d0c8a27b97e09a3bfce2cc314fa95f2a352f2274"
108
+ "gitHead": "8bddae7b4dec6f4395f270228317c1de2ae1e4c9"
109
109
  }
@@ -70,11 +70,6 @@ var SegmentProvider = exports.SegmentProvider = function SegmentProvider(_ref) {
70
70
  disabledGroup: disabledGroup,
71
71
  setDisabledGroup: setDisabledGroup
72
72
  };
73
- (0, _react.useEffect)(function () {
74
- if (selectionMode === 'single' && (selectedSegmentItems === null || selectedSegmentItems === void 0 ? void 0 : selectedSegmentItems.length) > 0) {
75
- setSelectedSegmentItems([selectedSegmentItems[0]]);
76
- }
77
- }, [selectionMode]);
78
73
  return /*#__PURE__*/_react["default"].createElement(SegmentContext.Provider, {
79
74
  value: contextValue
80
75
  }, children);
@@ -8,7 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
- import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';
11
+ import React, { createContext, useCallback, useContext, useState } from 'react';
12
12
  export var SegmentContext = /*#__PURE__*/createContext(undefined);
13
13
  export var useSegmentInner = function useSegmentInner() {
14
14
  var context = useContext(SegmentContext);
@@ -61,11 +61,6 @@ export var SegmentProvider = function SegmentProvider(_ref) {
61
61
  disabledGroup: disabledGroup,
62
62
  setDisabledGroup: setDisabledGroup
63
63
  };
64
- useEffect(function () {
65
- if (selectionMode === 'single' && (selectedSegmentItems === null || selectedSegmentItems === void 0 ? void 0 : selectedSegmentItems.length) > 0) {
66
- setSelectedSegmentItems([selectedSegmentItems[0]]);
67
- }
68
- }, [selectionMode]);
69
64
  return /*#__PURE__*/React.createElement(SegmentContext.Provider, {
70
65
  value: contextValue
71
66
  }, children);
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsE,MAAM,OAAO,CAAC;AAC3F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAwB,MAAM,yBAAyB,CAAC;AAEzG,eAAO,MAAM,cAAc,+CAA2D,CAAC;AAEvF,eAAO,MAAM,eAAe,0BAM3B,CAAC;AAEF,eAAO,MAAM,UAAU;;CAGtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAoCpD,CAAC"}
1
+ {"version":3,"file":"SegmentProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/Segment/SegmentProvider/SegmentProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAwB,MAAM,yBAAyB,CAAC;AAEzG,eAAO,MAAM,cAAc,+CAA2D,CAAC;AAEvF,eAAO,MAAM,eAAe,0BAM3B,CAAC;AAEF,eAAO,MAAM,UAAU;;CAGtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CA8BpD,CAAC"}