@semcore/accordion 17.0.0-prerelease.30 → 17.0.0-prerelease.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,12 +2,16 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
- ## [17.0.0] - 2026-03-09
5
+ ## [17.0.0] - 2026-04-08
6
6
 
7
7
  ### BREAK
8
8
 
9
9
  - New major version.
10
10
 
11
+ ### Fixed
12
+
13
+ - Rewrite component to TS.
14
+
11
15
  ## [16.7.2] - 2025-11-17
12
16
 
13
17
  ### Changed
@@ -80,7 +80,7 @@ class RootAccordion extends _core.Component {
80
80
  (0, _defineProperty2.default)(RootAccordion, "enhance", [(0, _useCssVariable.cssVariableEnhance)({
81
81
  variable: '--intergalactic-duration-accordion',
82
82
  fallback: '200',
83
- map: Number.parseInt,
83
+ map: value => `${Number.parseInt(value)}`,
84
84
  prop: 'duration'
85
85
  })]);
86
86
  class RootItem extends _core.Component {
@@ -214,14 +214,10 @@ function ToggleButton(props) {
214
214
  const {
215
215
  styles
216
216
  } = props;
217
- const SToggleButton = _baseComponents.Flex;
218
- return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SToggleButton, _ref7.cn("SToggleButton", {
219
- ...(0, _core.assignProps)({
220
- "alignItems": 'center',
221
- "role": 'button',
222
- ...props
223
- }, _ref3)
224
- }));
217
+ return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(_baseComponents.Flex, (0, _core.assignProps)({
218
+ "alignItems": 'center',
219
+ "role": 'button'
220
+ }, _ref3));
225
221
  }
226
222
  function Collapse(props) {
227
223
  var _ref4 = arguments[0];
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.js","names":["_core","require","_baseComponents","_uniqueID","_interopRequireDefault","_useCssVariable","_l","_m","_typography","_react","style","sstyled","insert","RootAccordion","Component","constructor","args","_defineProperty2","default","newValue","value","asProps","Array","isArray","indexOfNewValue","indexOf","result","push","splice","handlers","uncontrolledProps","getItemProps","selectedValue","duration","use","selected","includes","$handleInteraction","handleToggleInteraction","render","Children","createElement","defaultValue","cssVariableEnhance","variable","fallback","map","Number","parseInt","prop","RootItem","getToggleProps","uid","disabled","onClick","undefined","handleClick","id","tag","size","tabIndex","getToggleButtonProps","getCollapseProps","getChevronProps","exports","uniqueIDEnhancement","Toggle","React","createRef","event","key","toggleRef","current","target","currentTarget","click","preventDefault","_ref","_ref5","styles","SItemToggle","Text","cn","assignProps","handleKeyDown","Chevron","props","_ref2","arguments[0]","_ref6","SItemChevron","ChevronRightL","ChevronRightM","ToggleButton","_ref3","_ref7","SToggleButton","Flex","Collapse","_ref4","visible","CollapseAnimate","Item","createComponent","Accordion","wrapAccordion","wrapper","_default"],"sources":["../../src/Accordion.jsx"],"sourcesContent":["import { Collapse as CollapseAnimate, Flex } from '@semcore/base-components';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport ChevronRightL from '@semcore/icon/ChevronRight/l';\nimport ChevronRightM from '@semcore/icon/ChevronRight/m';\nimport { Text } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/accordion.shadow.css';\n\nclass RootAccordion extends Component {\n static displayName = 'Accordion';\n static style = style;\n static defaultProps = {\n defaultValue: [],\n use: 'secondary',\n };\n\n static enhance = [\n cssVariableEnhance({\n variable: '--intergalactic-duration-accordion',\n fallback: '200',\n map: Number.parseInt,\n prop: 'duration',\n }),\n ];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n handleToggleInteraction = (newValue) => {\n const { value } = this.asProps;\n\n if (Array.isArray(value)) {\n const indexOfNewValue = value.indexOf(newValue);\n const result = [...value];\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n indexOfNewValue === -1 ? result.push(newValue) : result.splice(indexOfNewValue, 1);\n this.handlers.value(result);\n } else {\n this.handlers.value(value === newValue ? null : newValue);\n }\n };\n\n getItemProps({ value }) {\n const { value: selectedValue, duration, use } = this.asProps;\n const selected = Array.isArray(selectedValue)\n ? selectedValue.includes(value)\n : selectedValue === value;\n return {\n selected,\n duration,\n use,\n $handleInteraction: this.handleToggleInteraction,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\n\nexport class RootItem extends Component {\n static displayName = 'Item';\n static style = style;\n static enhance = [uniqueIDEnhancement()];\n\n handleClick = () => {\n const { value, $handleInteraction } = this.asProps;\n\n $handleInteraction(value);\n };\n\n getToggleProps() {\n const { value, uid, disabled, use } = this.asProps;\n return {\n use,\n disabled,\n onClick: disabled ? undefined : this.handleClick,\n id: `igc-${uid}-${value}-toggle`,\n tag: 'h3',\n size: 300,\n tabIndex: disabled ? -1 : 0,\n };\n }\n\n getToggleButtonProps() {\n const { value, uid, selected, disabled } = this.asProps;\n return {\n disabled,\n 'id': `igc-${uid}-${value}-toggle-button`,\n 'aria-expanded': selected ? 'true' : 'false',\n 'aria-controls': selected ? `igc-${uid}-${value}-collapse` : undefined,\n };\n }\n\n getCollapseProps() {\n const { selected, uid, duration, value } = this.asProps;\n return {\n selected,\n duration,\n 'id': `igc-${uid}-${value}-collapse`,\n 'role': 'region',\n 'aria-labelledby': `igc-${uid}-${value}-toggle-button`,\n };\n }\n\n getChevronProps() {\n const { selected, size } = this.asProps;\n return {\n selected,\n size,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\n\nclass Toggle extends Component {\n toggleRef = React.createRef();\n\n handleKeyDown = (event) => {\n if (event.key === 'Enter') {\n if (this.toggleRef.current === event.target) {\n event.currentTarget.click();\n }\n } else if (event.key === ' ') {\n event.preventDefault();\n if (this.toggleRef.current === event.target) {\n event.currentTarget.click();\n }\n }\n };\n\n render() {\n const { styles, use } = this.asProps;\n const SItemToggle = Root;\n\n return sstyled(styles)(\n <SItemToggle\n use={use}\n ref={this.toggleRef}\n render={Text}\n innerOutline\n onKeyDown={this.handleKeyDown}\n />,\n );\n }\n}\n\nfunction Chevron(props) {\n const { styles, size } = props;\n\n const SItemChevron = Root;\n return sstyled(styles)(<SItemChevron render={size === 'l' ? ChevronRightL : ChevronRightM} />);\n}\n\nfunction ToggleButton(props) {\n const { styles } = props;\n\n const SToggleButton = Root;\n return sstyled(styles)(\n <SToggleButton alignItems='center' render={Flex} role='button' {...props} />,\n );\n}\n\nfunction Collapse(props) {\n const { selected } = props;\n const visible = selected;\n\n return (\n <Root\n render={CollapseAnimate}\n visible={visible}\n interactive\n inert={!visible ? '' : undefined}\n aria-hidden={!visible}\n />\n );\n}\n\nconst Item = createComponent(RootItem, {\n Toggle,\n Chevron,\n ToggleButton,\n Collapse,\n});\n\nconst Accordion = createComponent(RootAccordion, {\n Item,\n});\n\nexport const wrapAccordion = (wrapper) => wrapper;\n\nexport default Accordion;\n"],"mappings":";;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,EAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,EAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAL,sBAAA,CAAAH,OAAA;AAA0B;AAAA,MAAAS,KAAA,8BAAAV,KAAA,CAAAW,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI1B,MAAMC,aAAa,SAASC,eAAS,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,mCAuBTC,QAAQ,IAAK;MACtC,MAAM;QAAEC;MAAM,CA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AAO;AAAC1C,OAAA,CAAAyC,aAAA,GAAAA,aAAA;AAAA,IAAAE,QAAA,GAAA3C,OAAA,CAAA9C,OAAA,GAEnCsF,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"Accordion.js","names":["_core","require","_baseComponents","_uniqueID","_interopRequireDefault","_useCssVariable","_l","_m","_typography","_react","style","sstyled","insert","RootAccordion","Component","constructor","args","_defineProperty2","default","newValue","value","asProps","Array","isArray","indexOfNewValue","indexOf","result","push","splice","handlers","uncontrolledProps","getItemProps","selectedValue","duration","use","selected","includes","$handleInteraction","handleToggleInteraction","render","Children","createElement","defaultValue","cssVariableEnhance","variable","fallback","map","Number","parseInt","prop","RootItem","getToggleProps","uid","disabled","onClick","undefined","handleClick","id","tag","size","tabIndex","getToggleButtonProps","getCollapseProps","getChevronProps","exports","uniqueIDEnhancement","Toggle","React","createRef","event","key","toggleRef","current","target","currentTarget","click","preventDefault","_ref","_ref5","styles","SItemToggle","Text","cn","assignProps","handleKeyDown","Chevron","props","_ref2","arguments[0]","_ref6","SItemChevron","ChevronRightL","ChevronRightM","ToggleButton","_ref3","_ref7","Flex","Collapse","_ref4","visible","CollapseAnimate","Item","createComponent","Accordion","wrapAccordion","wrapper","_default"],"sources":["../../src/Accordion.tsx"],"sourcesContent":["import { Collapse as CollapseAnimate, Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport ChevronRightL from '@semcore/icon/ChevronRight/l';\nimport ChevronRightM from '@semcore/icon/ChevronRight/m';\nimport { Text } from '@semcore/typography';\nimport React from 'react';\n\nimport type {\n AccordionComponent,\n AccordionHandlers,\n AccordionItemChevronComponent,\n AccordionItemCollapseComponent,\n AccordionItemComponent,\n AccordionItemProps,\n AccordionItemToggleButtonComponent,\n AccordionItemToggleComponent,\n IntergalacticAccordionComponent,\n} from './Accordion.type';\nimport style from './style/accordion.shadow.css';\n\nclass RootAccordion extends Component<\n Intergalactic.InternalTypings.InferComponentProps<IntergalacticAccordionComponent>,\n typeof RootAccordion.enhance,\n AccordionHandlers\n> {\n static displayName = 'Accordion';\n static style = style;\n static defaultProps = {\n defaultValue: [],\n use: 'secondary',\n };\n\n static enhance = [\n cssVariableEnhance({\n variable: '--intergalactic-duration-accordion',\n fallback: '200',\n map: (value: string) => `${Number.parseInt(value)}`,\n prop: 'duration',\n }),\n ] as const;\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n handleToggleInteraction = (newValue: AccordionItemProps['value']) => {\n const { value } = this.asProps;\n\n if (Array.isArray(value)) {\n const indexOfNewValue = value.indexOf(newValue);\n const result = [...value];\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n indexOfNewValue === -1 ? result.push(newValue) : result.splice(indexOfNewValue, 1);\n this.handlers.value(result);\n } else {\n this.handlers.value(value === newValue ? null : newValue);\n }\n };\n\n getItemProps({ value }: AccordionItemProps) {\n const { value: selectedValue, duration, use } = this.asProps;\n const selected = Array.isArray(selectedValue)\n ? selectedValue.includes(value)\n : selectedValue === value;\n\n return {\n selected,\n duration,\n use,\n $handleInteraction: this.handleToggleInteraction,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\nexport class RootItem extends Component<\n Intergalactic.InternalTypings.InferChildComponentProps<AccordionItemComponent, typeof RootAccordion, 'Item'>,\n typeof RootItem.enhance\n> {\n static displayName = 'Item';\n static style = style;\n static enhance = [uniqueIDEnhancement()] as const;\n\n handleClick = () => {\n const { value, $handleInteraction } = this.asProps;\n\n $handleInteraction(value);\n };\n\n getToggleProps() {\n const { value, uid, disabled, use } = this.asProps;\n return {\n use,\n disabled,\n onClick: disabled ? undefined : this.handleClick,\n id: `igc-${uid}-${value}-toggle`,\n tag: 'h3',\n size: 300,\n tabIndex: disabled ? -1 : 0,\n };\n }\n\n getToggleButtonProps() {\n const { value, uid, selected, disabled } = this.asProps;\n return {\n disabled,\n 'id': `igc-${uid}-${value}-toggle-button`,\n 'aria-expanded': selected ? 'true' : 'false',\n 'aria-controls': selected ? `igc-${uid}-${value}-collapse` : undefined,\n };\n }\n\n getCollapseProps() {\n const { selected, uid, duration, value } = this.asProps;\n return {\n selected,\n duration,\n 'id': `igc-${uid}-${value}-collapse`,\n 'role': 'region',\n 'aria-labelledby': `igc-${uid}-${value}-toggle-button`,\n };\n }\n\n getChevronProps() {\n const { selected, size } = this.asProps;\n return {\n selected,\n size,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\n\nclass Toggle extends Component<\n Intergalactic.InternalTypings.InferChildComponentProps<AccordionItemToggleComponent, typeof RootItem, 'Toggle'>\n> {\n toggleRef = React.createRef();\n\n handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n if (event.key === 'Enter') {\n if (this.toggleRef.current === event.target) {\n event.currentTarget.click();\n }\n } else if (event.key === ' ') {\n event.preventDefault();\n if (this.toggleRef.current === event.target) {\n event.currentTarget.click();\n }\n }\n };\n\n render() {\n const { styles, use } = this.asProps;\n const SItemToggle = Root;\n\n return sstyled(styles)(\n <SItemToggle use={use} ref={this.toggleRef} render={Text} innerOutline onKeyDown={this.handleKeyDown} />,\n );\n }\n}\n\nfunction Chevron(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n AccordionItemChevronComponent,\n typeof RootItem,\n 'Chevron'\n >,\n) {\n const { styles, size } = props;\n\n const SItemChevron = Root;\n return sstyled(styles)(<SItemChevron render={size === 'l' ? ChevronRightL : ChevronRightM} />);\n}\n\nfunction ToggleButton(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n AccordionItemToggleButtonComponent,\n typeof RootItem,\n 'ToggleButton'\n >,\n) {\n const { styles } = props;\n\n return sstyled(styles)(\n <Root render={Flex} alignItems='center' role='button' />,\n );\n}\n\nfunction Collapse(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n AccordionItemCollapseComponent,\n typeof RootItem,\n 'Collapse'\n >,\n) {\n const { selected } = props;\n const visible = selected;\n\n return (\n <Root\n render={CollapseAnimate}\n visible={visible}\n interactive\n inert={!visible ? '' : undefined}\n aria-hidden={!visible}\n />\n );\n}\n\nconst Item = createComponent(RootItem, {\n Toggle,\n Chevron,\n ToggleButton,\n Collapse,\n}) as AccordionItemComponent;\n\nconst Accordion = createComponent(RootAccordion, {\n Item,\n}) as unknown as AccordionComponent;\n\nexport const wrapAccordion = <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticAccordionComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => wrapper as IntergalacticAccordionComponent<PropsExtending>;\n\nexport default Accordion;\n"],"mappings":";;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,EAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,EAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAL,sBAAA,CAAAH,OAAA;AAA0B;AAAA,MAAAS,KAAA,8BAAAV,KAAA,CAAAW,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAe1B,MAAMC,aAAa,SAASC,eAAS,CAInC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,mCAuB2BC,QAAqC,IAAK;MACnE,MAAM;QAAEC;MAAM,CAAC,GAAG,IAAI,CAACC,OAAO;MAE9B,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;QACxB,MAAMI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 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=Accordion.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accordion.type.js","names":[],"sources":["../../src/Accordion.type.ts"],"sourcesContent":["import type { BoxProps, FlexProps, Flex } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { Text } from '@semcore/typography';\nimport type { Property } from 'csstype';\n\nexport type AccordionValue = null | number | string | Array<number | string | null>;\n\nexport type AccordionProps<T extends AccordionValue = AccordionValue> = FlexProps & {\n /** Value for the active tab. Can be set as stroke, number, null or as array.\n * @type AccordionValue\n * */\n value?: T;\n /**\n * Value of the active tabs selected by default\n * @type AccordionValue\n * @default []\n */\n defaultValue?: T;\n /** Called when the selection is changed\n * @type (value: AccordionValue, event?: React.SyntheticEvent) => void\n * */\n onChange?:\n | ((value: T, event?: React.SyntheticEvent) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Animation duration of each Accordion.Item inside\n * @default 350 */\n duration?: number;\n\n /**\n * Changes the visual appearance of the component\n * @default secondary\n */\n use?: 'primary' | 'secondary';\n};\n\nexport interface IAccordionProps<T extends AccordionValue = AccordionValue>\n extends AccordionProps<T> {}\n\nexport type AccordionContext = {\n getItemProps: PropGetterFn;\n};\n\nexport type AccordionHandlers = {\n value: AccordionProps['value'];\n};\n\nexport type AccordionItemProps = {\n /** Tab value */\n value: string | number;\n /** Disabling selection changes */\n disabled?: boolean;\n /** Animation duration\n * @default 350 */\n duration?: number;\n};\n\nexport type AccordionItemContext = {\n getToggleProps?: PropGetterFn;\n getCollapseProps?: PropGetterFn;\n getChevronProps?: PropGetterFn;\n selected?: boolean;\n};\n\nexport type AccordionItemToggleProps = BoxProps & {\n tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n};\nexport type ChevronItemProps = BoxProps & {\n /**\n * Chevron size\n * @default m\n */\n size?: 'm' | 'l';\n};\n\nexport type CollapseAnimationProps = {\n /** Animation titles */\n keyframes?: [string, string];\n /** Enables animation on first rendering\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * @default ease-out\n */\n timingFunction?: Property.AnimationTimingFunction;\n /**\n * @default false\n */\n animationsDisabled?: boolean;\n};\n\nexport type AccordionCollapseProps = BoxProps & CollapseAnimationProps & {\n /** Animation duration in ms\n * @default 0\n */\n duration?: number | [number, number];\n /** If it set to `true`, animated node is persisted in dom even if `visible=false` */\n preserveNode?: boolean;\n /**\n * Add overflow=clip when passing animation\n * @default true\n * */\n overflowHidden?: boolean;\n /**\n * Value for height after animation\n * @default auto\n */\n defaultHeight?: 'auto' | '100%';\n};\n\nexport type IntergalacticAccordionComponent<PropsExtending = {}> = (<\n Value extends AccordionValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n AccordionProps<Value>,\n AccordionContext & { value: Value },\n [handlers: AccordionHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', AccordionProps>;\n\nexport type AccordionItemComponent = Intergalactic.Component<\n 'div',\n AccordionItemProps,\n AccordionItemContext\n>;\nexport type AccordionItemToggleComponent = Intergalactic.Component<typeof Text, AccordionItemToggleProps>;\nexport type AccordionItemToggleButtonComponent = Intergalactic.Component<typeof Flex, {}>;\nexport type AccordionItemChevronComponent = Intergalactic.Component<'div', ChevronItemProps>;\nexport type AccordionItemCollapseComponent = Intergalactic.Component<'div', AccordionCollapseProps>;\n\nexport type AccordionComponent = IntergalacticAccordionComponent & {\n Item: AccordionItemComponent & {\n Toggle: AccordionItemToggleComponent;\n ToggleButton: AccordionItemToggleButtonComponent;\n Chevron: AccordionItemChevronComponent;\n Collapse: AccordionItemCollapseComponent;\n };\n};\n"],"mappings":"","ignoreList":[]}
package/lib/cjs/index.js CHANGED
@@ -4,22 +4,31 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- var _exportNames = {};
7
+ var _exportNames = {
8
+ wrapAccordion: true
9
+ };
8
10
  Object.defineProperty(exports, "default", {
9
11
  enumerable: true,
10
12
  get: function () {
11
13
  return _Accordion.default;
12
14
  }
13
15
  });
16
+ Object.defineProperty(exports, "wrapAccordion", {
17
+ enumerable: true,
18
+ get: function () {
19
+ return _Accordion.wrapAccordion;
20
+ }
21
+ });
14
22
  var _Accordion = _interopRequireWildcard(require("./Accordion"));
15
- Object.keys(_Accordion).forEach(function (key) {
23
+ var _Accordion2 = require("./Accordion.type");
24
+ Object.keys(_Accordion2).forEach(function (key) {
16
25
  if (key === "default" || key === "__esModule") return;
17
26
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
18
- if (key in exports && exports[key] === _Accordion[key]) return;
27
+ if (key in exports && exports[key] === _Accordion2[key]) return;
19
28
  Object.defineProperty(exports, key, {
20
29
  enumerable: true,
21
30
  get: function () {
22
- return _Accordion[key];
31
+ return _Accordion2[key];
23
32
  }
24
33
  });
25
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_Accordion","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.js"],"sourcesContent":["export { default } from './Accordion';\nexport * from './Accordion';\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,uBAAA,CAAAC,OAAA;AACAC,MAAA,CAAAC,IAAA,CAAAJ,UAAA,EAAAK,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAN,UAAA,CAAAM,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAd,UAAA,CAAAM,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_Accordion","_interopRequireWildcard","require","_Accordion2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../src/index.ts"],"sourcesContent":["export { default, wrapAccordion } from './Accordion';\nexport * from './Accordion.type';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -78,7 +78,7 @@ _defineProperty(RootAccordion, "defaultProps", {
78
78
  _defineProperty(RootAccordion, "enhance", [cssVariableEnhance({
79
79
  variable: '--intergalactic-duration-accordion',
80
80
  fallback: '200',
81
- map: Number.parseInt,
81
+ map: value => `${Number.parseInt(value)}`,
82
82
  prop: 'duration'
83
83
  })]);
84
84
  export class RootItem extends Component {
@@ -211,14 +211,10 @@ function ToggleButton(props) {
211
211
  const {
212
212
  styles
213
213
  } = props;
214
- const SToggleButton = Flex;
215
- return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SToggleButton, _ref7.cn("SToggleButton", {
216
- ..._assignProps3({
217
- "alignItems": 'center',
218
- "role": 'button',
219
- ...props
220
- }, _ref3)
221
- }));
214
+ return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(Flex, _assignProps3({
215
+ "alignItems": 'center',
216
+ "role": 'button'
217
+ }, _ref3));
222
218
  }
223
219
  function Collapse(props) {
224
220
  var _ref4 = arguments[0];
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.js","names":["Collapse","CollapseAnimate","Flex","createComponent","Component","sstyled","Root","uniqueIDEnhancement","cssVariableEnhance","ChevronRightL","ChevronRightM","Text","React","style","_sstyled","insert","RootAccordion","constructor","args","_defineProperty","newValue","value","asProps","Array","isArray","indexOfNewValue","indexOf","result","push","splice","handlers","uncontrolledProps","getItemProps","selectedValue","duration","use","selected","includes","$handleInteraction","handleToggleInteraction","render","Children","createElement","defaultValue","variable","fallback","map","Number","parseInt","prop","RootItem","getToggleProps","uid","disabled","onClick","undefined","handleClick","id","tag","size","tabIndex","getToggleButtonProps","getCollapseProps","getChevronProps","Toggle","createRef","event","key","toggleRef","current","target","currentTarget","click","preventDefault","_ref","_ref5","styles","SItemToggle","cn","_assignProps","handleKeyDown","Chevron","props","_ref2","arguments[0]","_ref6","SItemChevron","_assignProps2","ToggleButton","_ref3","_ref7","SToggleButton","_assignProps3","_ref4","visible","_assignProps4","Item","Accordion","wrapAccordion","wrapper"],"sources":["../../src/Accordion.jsx"],"sourcesContent":["import { Collapse as CollapseAnimate, Flex } from '@semcore/base-components';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport ChevronRightL from '@semcore/icon/ChevronRight/l';\nimport ChevronRightM from '@semcore/icon/ChevronRight/m';\nimport { Text } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './style/accordion.shadow.css';\n\nclass RootAccordion extends Component {\n static displayName = 'Accordion';\n static style = style;\n static defaultProps = {\n defaultValue: [],\n use: 'secondary',\n };\n\n static enhance = [\n cssVariableEnhance({\n variable: '--intergalactic-duration-accordion',\n fallback: '200',\n map: Number.parseInt,\n prop: 'duration',\n }),\n ];\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n handleToggleInteraction = (newValue) => {\n const { value } = this.asProps;\n\n if (Array.isArray(value)) {\n const indexOfNewValue = value.indexOf(newValue);\n const result = [...value];\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n indexOfNewValue === -1 ? result.push(newValue) : result.splice(indexOfNewValue, 1);\n this.handlers.value(result);\n } else {\n this.handlers.value(value === newValue ? null : newValue);\n }\n };\n\n getItemProps({ value }) {\n const { value: selectedValue, duration, use } = this.asProps;\n const selected = Array.isArray(selectedValue)\n ? selectedValue.includes(value)\n : selectedValue === value;\n return {\n selected,\n duration,\n use,\n $handleInteraction: this.handleToggleInteraction,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\n\nexport class RootItem extends Component {\n static displayName = 'Item';\n static style = style;\n static enhance = [uniqueIDEnhancement()];\n\n handleClick = () => {\n const { value, $handleInteraction } = this.asProps;\n\n $handleInteraction(value);\n };\n\n getToggleProps() {\n const { value, uid, disabled, use } = this.asProps;\n return {\n use,\n disabled,\n onClick: disabled ? undefined : this.handleClick,\n id: `igc-${uid}-${value}-toggle`,\n tag: 'h3',\n size: 300,\n tabIndex: disabled ? -1 : 0,\n };\n }\n\n getToggleButtonProps() {\n const { value, uid, selected, disabled } = this.asProps;\n return {\n disabled,\n 'id': `igc-${uid}-${value}-toggle-button`,\n 'aria-expanded': selected ? 'true' : 'false',\n 'aria-controls': selected ? `igc-${uid}-${value}-collapse` : undefined,\n };\n }\n\n getCollapseProps() {\n const { selected, uid, duration, value } = this.asProps;\n return {\n selected,\n duration,\n 'id': `igc-${uid}-${value}-collapse`,\n 'role': 'region',\n 'aria-labelledby': `igc-${uid}-${value}-toggle-button`,\n };\n }\n\n getChevronProps() {\n const { selected, size } = this.asProps;\n return {\n selected,\n size,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\n\nclass Toggle extends Component {\n toggleRef = React.createRef();\n\n handleKeyDown = (event) => {\n if (event.key === 'Enter') {\n if (this.toggleRef.current === event.target) {\n event.currentTarget.click();\n }\n } else if (event.key === ' ') {\n event.preventDefault();\n if (this.toggleRef.current === event.target) {\n event.currentTarget.click();\n }\n }\n };\n\n render() {\n const { styles, use } = this.asProps;\n const SItemToggle = Root;\n\n return sstyled(styles)(\n <SItemToggle\n use={use}\n ref={this.toggleRef}\n render={Text}\n innerOutline\n onKeyDown={this.handleKeyDown}\n />,\n );\n }\n}\n\nfunction Chevron(props) {\n const { styles, size } = props;\n\n const SItemChevron = Root;\n return sstyled(styles)(<SItemChevron render={size === 'l' ? ChevronRightL : ChevronRightM} />);\n}\n\nfunction ToggleButton(props) {\n const { styles } = props;\n\n const SToggleButton = Root;\n return sstyled(styles)(\n <SToggleButton alignItems='center' render={Flex} role='button' {...props} />,\n );\n}\n\nfunction Collapse(props) {\n const { selected } = props;\n const visible = selected;\n\n return (\n <Root\n render={CollapseAnimate}\n visible={visible}\n interactive\n inert={!visible ? '' : undefined}\n aria-hidden={!visible}\n />\n );\n}\n\nconst Item = createComponent(RootItem, {\n Toggle,\n Chevron,\n ToggleButton,\n Collapse,\n});\n\nconst Accordion = createComponent(RootAccordion, {\n Item,\n});\n\nexport const wrapAccordion = (wrapper) => wrapper;\n\nexport default Accordion;\n"],"mappings":";;;;;;AAAA,SAASA,QAAQ,IAAIC,eAAe,EAAEC,IAAI,QAAQ,0BAA0B;AAC5E,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,mBAAmB,MAAM,kCAAkC;AAClE,SAASC,kBAAkB,QAAQ,wCAAwC;AAC3E,OAAOC,aAAa,MAAM,8BAA8B;AACxD,OAAOC,aAAa,MAAM,8BAA8B;AACxD,SAASC,IAAI,QAAQ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AAA,CAAA8B,aAAA,CAAC4C,YAAY,EAAAD,KAAA,CAAAP,EAAA;IAAA,GAAAS,aAAA,KAAAJ,KAAA;EAAA,EAAwD,CAAC;AAC/F;AAEA,SAASK,YAAYA,CAACN,KAAK,EAAE;EAAA,IAAAO,KAAA,GAAAL,YAAA;IAAAM,KAAA;EAC3B,MAAM;IAAEd;EAAO,CAAC,GAAGM,KAAK;EAExB,MAAMS,aAAa,GAE0BzF,IAAI;EADjD,OAAAwF,KAAA,GAAOrF,OAAO,CAACuE,MAAM,CAAC,eACpBhE,KAAA,CAAA8B,aAAA,CAACiD,aAAa,EAAAD,KAAA,CAAAZ,EAAA;IAAA,GAAAc,aAAA;MAAA,cAAY,QAAQ;MAAA,QAAoB,QAAQ;MAAA,GAAKV;IAAK,GAAAO,KAAA;EAAA,EAAG,CAAC;AAEhF;AAEA,SAASzF,QAAQA,CAACkF,KAAK,EAAE;EAAA,IAAAW,KAAA,GAAAT,YAAA;EACvB,MAAM;IAAEhD;EAAS,CAAC,GAAG8C,KAAK;EAC1B,MAAMY,OAAO,GAAG1D,QAAQ;EAExB,oBACExB,KAAA,CAAA8B,aAAA,CACUzC,eAAe,EAAA8F,aAAA;IAAA,WACdD,OAAO;IAAA;IAAA,SAET,CAACA,OAAO,GAAG,EAAE,GAAGvC,SAAS;IAAA,eACnB,CAACuC;EAAO,GAAAD,KAAA,CACtB,CAAC;AAEN;AAEA,MAAMG,IAAI,GAAG7F,eAAe,CAAC+C,QAAQ,EAAE;EACrCc,MAAM;EACNiB,OAAO;EACPO,YAAY;EACZxF;AACF,CAAC,CAAC;AAEF,MAAMiG,SAAS,GAAG9F,eAAe,CAACa,aAAa,EAAE;EAC/CgF;AACF,CAAC,CAAC;AAEF,OAAO,MAAME,aAAa,GAAIC,OAAO,IAAKA,OAAO;AAEjD,eAAeF,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"Accordion.js","names":["Collapse","CollapseAnimate","Flex","createComponent","Component","sstyled","Root","uniqueIDEnhancement","cssVariableEnhance","ChevronRightL","ChevronRightM","Text","React","style","_sstyled","insert","RootAccordion","constructor","args","_defineProperty","newValue","value","asProps","Array","isArray","indexOfNewValue","indexOf","result","push","splice","handlers","uncontrolledProps","getItemProps","selectedValue","duration","use","selected","includes","$handleInteraction","handleToggleInteraction","render","Children","createElement","defaultValue","variable","fallback","map","Number","parseInt","prop","RootItem","getToggleProps","uid","disabled","onClick","undefined","handleClick","id","tag","size","tabIndex","getToggleButtonProps","getCollapseProps","getChevronProps","Toggle","createRef","event","key","toggleRef","current","target","currentTarget","click","preventDefault","_ref","_ref5","styles","SItemToggle","cn","_assignProps","handleKeyDown","Chevron","props","_ref2","arguments[0]","_ref6","SItemChevron","_assignProps2","ToggleButton","_ref3","_ref7","_assignProps3","_ref4","visible","_assignProps4","Item","Accordion","wrapAccordion","wrapper"],"sources":["../../src/Accordion.tsx"],"sourcesContent":["import { Collapse as CollapseAnimate, Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport ChevronRightL from '@semcore/icon/ChevronRight/l';\nimport ChevronRightM from '@semcore/icon/ChevronRight/m';\nimport { Text } from '@semcore/typography';\nimport React from 'react';\n\nimport type {\n AccordionComponent,\n AccordionHandlers,\n AccordionItemChevronComponent,\n AccordionItemCollapseComponent,\n AccordionItemComponent,\n AccordionItemProps,\n AccordionItemToggleButtonComponent,\n AccordionItemToggleComponent,\n IntergalacticAccordionComponent,\n} from './Accordion.type';\nimport style from './style/accordion.shadow.css';\n\nclass RootAccordion extends Component<\n Intergalactic.InternalTypings.InferComponentProps<IntergalacticAccordionComponent>,\n typeof RootAccordion.enhance,\n AccordionHandlers\n> {\n static displayName = 'Accordion';\n static style = style;\n static defaultProps = {\n defaultValue: [],\n use: 'secondary',\n };\n\n static enhance = [\n cssVariableEnhance({\n variable: '--intergalactic-duration-accordion',\n fallback: '200',\n map: (value: string) => `${Number.parseInt(value)}`,\n prop: 'duration',\n }),\n ] as const;\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n handleToggleInteraction = (newValue: AccordionItemProps['value']) => {\n const { value } = this.asProps;\n\n if (Array.isArray(value)) {\n const indexOfNewValue = value.indexOf(newValue);\n const result = [...value];\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n indexOfNewValue === -1 ? result.push(newValue) : result.splice(indexOfNewValue, 1);\n this.handlers.value(result);\n } else {\n this.handlers.value(value === newValue ? null : newValue);\n }\n };\n\n getItemProps({ value }: AccordionItemProps) {\n const { value: selectedValue, duration, use } = this.asProps;\n const selected = Array.isArray(selectedValue)\n ? selectedValue.includes(value)\n : selectedValue === value;\n\n return {\n selected,\n duration,\n use,\n $handleInteraction: this.handleToggleInteraction,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\nexport class RootItem extends Component<\n Intergalactic.InternalTypings.InferChildComponentProps<AccordionItemComponent, typeof RootAccordion, 'Item'>,\n typeof RootItem.enhance\n> {\n static displayName = 'Item';\n static style = style;\n static enhance = [uniqueIDEnhancement()] as const;\n\n handleClick = () => {\n const { value, $handleInteraction } = this.asProps;\n\n $handleInteraction(value);\n };\n\n getToggleProps() {\n const { value, uid, disabled, use } = this.asProps;\n return {\n use,\n disabled,\n onClick: disabled ? undefined : this.handleClick,\n id: `igc-${uid}-${value}-toggle`,\n tag: 'h3',\n size: 300,\n tabIndex: disabled ? -1 : 0,\n };\n }\n\n getToggleButtonProps() {\n const { value, uid, selected, disabled } = this.asProps;\n return {\n disabled,\n 'id': `igc-${uid}-${value}-toggle-button`,\n 'aria-expanded': selected ? 'true' : 'false',\n 'aria-controls': selected ? `igc-${uid}-${value}-collapse` : undefined,\n };\n }\n\n getCollapseProps() {\n const { selected, uid, duration, value } = this.asProps;\n return {\n selected,\n duration,\n 'id': `igc-${uid}-${value}-collapse`,\n 'role': 'region',\n 'aria-labelledby': `igc-${uid}-${value}-toggle-button`,\n };\n }\n\n getChevronProps() {\n const { selected, size } = this.asProps;\n return {\n selected,\n size,\n };\n }\n\n render() {\n const { Children } = this.asProps;\n return <Children />;\n }\n}\n\nclass Toggle extends Component<\n Intergalactic.InternalTypings.InferChildComponentProps<AccordionItemToggleComponent, typeof RootItem, 'Toggle'>\n> {\n toggleRef = React.createRef();\n\n handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n if (event.key === 'Enter') {\n if (this.toggleRef.current === event.target) {\n event.currentTarget.click();\n }\n } else if (event.key === ' ') {\n event.preventDefault();\n if (this.toggleRef.current === event.target) {\n event.currentTarget.click();\n }\n }\n };\n\n render() {\n const { styles, use } = this.asProps;\n const SItemToggle = Root;\n\n return sstyled(styles)(\n <SItemToggle use={use} ref={this.toggleRef} render={Text} innerOutline onKeyDown={this.handleKeyDown} />,\n );\n }\n}\n\nfunction Chevron(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n AccordionItemChevronComponent,\n typeof RootItem,\n 'Chevron'\n >,\n) {\n const { styles, size } = props;\n\n const SItemChevron = Root;\n return sstyled(styles)(<SItemChevron render={size === 'l' ? ChevronRightL : ChevronRightM} />);\n}\n\nfunction ToggleButton(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n AccordionItemToggleButtonComponent,\n typeof RootItem,\n 'ToggleButton'\n >,\n) {\n const { styles } = props;\n\n return sstyled(styles)(\n <Root render={Flex} alignItems='center' role='button' />,\n );\n}\n\nfunction Collapse(\n props: Intergalactic.InternalTypings.InferChildComponentProps<\n AccordionItemCollapseComponent,\n typeof RootItem,\n 'Collapse'\n >,\n) {\n const { selected } = props;\n const visible = selected;\n\n return (\n <Root\n render={CollapseAnimate}\n visible={visible}\n interactive\n inert={!visible ? '' : undefined}\n aria-hidden={!visible}\n />\n );\n}\n\nconst Item = createComponent(RootItem, {\n Toggle,\n Chevron,\n ToggleButton,\n Collapse,\n}) as AccordionItemComponent;\n\nconst Accordion = createComponent(RootAccordion, {\n Item,\n}) as unknown as AccordionComponent;\n\nexport const wrapAccordion = <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticAccordionComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => wrapper as IntergalacticAccordionComponent<PropsExtending>;\n\nexport default Accordion;\n"],"mappings":";;;;;;AAAA,SAASA,QAAQ,IAAIC,eAAe,EAAEC,IAAI,QAAQ,0BAA0B;AAE5E,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,mBAAmB,MAAM,kCAAkC;AAClE,SAASC,kBAAkB,QAAQ,wCAAwC;AAC3E,OAAOC,aAAa,MAAM,8BAA8B;AACxD,OAAOC,aAAa,MAAM,8BAA8B;AACxD,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAe1B,MAAMC,aAAa,SAASZ,SAAS,CAInC;EAAAa,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,kCAuB2BC,QAAqC,IAAK;MACnE,MAAM;QAAEC;MAAM,CAAC,GAAG,IAAI,CAACC,OAAO;MAE9B,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;QACxB,MAAMI,eAAe,GAAGJ,KAAK,CAACK,OAAO,CAACN,QAAQ,CAAC;QAC/C,MAAMO,MAAM,GAAG,CAAC,GAAGN,KAAK,CAAC;QACzB;QACAI,eAAe,KAAK,CAAC,CAAC,GAAGE,MAAM,CAACC,IAAI,CAACR,QAAQ,CAAC,GAAGO,MAAM,CAACE,MAAM,CAACJ,eAAe,EAAE,CAAC,CAAC;QAClF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ExB,oBACExB,KAAA,CAAA8B,aAAA,CACUzC,eAAe,EAAA6F,aAAA;IAAA,WACdD,OAAO;IAAA;IAAA,SAET,CAACA,OAAO,GAAG,EAAE,GAAGtC,SAAS;IAAA,eACnB,CAACsC;EAAO,GAAAD,KAAA,CACtB,CAAC;AAEN;AAEA,MAAMG,IAAI,GAAG5F,eAAe,CAAC+C,QAAQ,EAAE;EACrCc,MAAM;EACNiB,OAAO;EACPO,YAAY;EACZxF;AACF,CAAC,CAA2B;AAE5B,MAAMgG,SAAS,GAAG7F,eAAe,CAACa,aAAa,EAAE;EAC/C+E;AACF,CAAC,CAAkC;AAEnC,OAAO,MAAME,aAAa,GACxBC,OAKoB,IACjBA,OAA0D;AAE/D,eAAeF,SAAS","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Accordion.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accordion.type.js","names":[],"sources":["../../src/Accordion.type.ts"],"sourcesContent":["import type { BoxProps, FlexProps, Flex } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { Text } from '@semcore/typography';\nimport type { Property } from 'csstype';\n\nexport type AccordionValue = null | number | string | Array<number | string | null>;\n\nexport type AccordionProps<T extends AccordionValue = AccordionValue> = FlexProps & {\n /** Value for the active tab. Can be set as stroke, number, null or as array.\n * @type AccordionValue\n * */\n value?: T;\n /**\n * Value of the active tabs selected by default\n * @type AccordionValue\n * @default []\n */\n defaultValue?: T;\n /** Called when the selection is changed\n * @type (value: AccordionValue, event?: React.SyntheticEvent) => void\n * */\n onChange?:\n | ((value: T, event?: React.SyntheticEvent) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Animation duration of each Accordion.Item inside\n * @default 350 */\n duration?: number;\n\n /**\n * Changes the visual appearance of the component\n * @default secondary\n */\n use?: 'primary' | 'secondary';\n};\n\nexport interface IAccordionProps<T extends AccordionValue = AccordionValue>\n extends AccordionProps<T> {}\n\nexport type AccordionContext = {\n getItemProps: PropGetterFn;\n};\n\nexport type AccordionHandlers = {\n value: AccordionProps['value'];\n};\n\nexport type AccordionItemProps = {\n /** Tab value */\n value: string | number;\n /** Disabling selection changes */\n disabled?: boolean;\n /** Animation duration\n * @default 350 */\n duration?: number;\n};\n\nexport type AccordionItemContext = {\n getToggleProps?: PropGetterFn;\n getCollapseProps?: PropGetterFn;\n getChevronProps?: PropGetterFn;\n selected?: boolean;\n};\n\nexport type AccordionItemToggleProps = BoxProps & {\n tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n};\nexport type ChevronItemProps = BoxProps & {\n /**\n * Chevron size\n * @default m\n */\n size?: 'm' | 'l';\n};\n\nexport type CollapseAnimationProps = {\n /** Animation titles */\n keyframes?: [string, string];\n /** Enables animation on first rendering\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * @default ease-out\n */\n timingFunction?: Property.AnimationTimingFunction;\n /**\n * @default false\n */\n animationsDisabled?: boolean;\n};\n\nexport type AccordionCollapseProps = BoxProps & CollapseAnimationProps & {\n /** Animation duration in ms\n * @default 0\n */\n duration?: number | [number, number];\n /** If it set to `true`, animated node is persisted in dom even if `visible=false` */\n preserveNode?: boolean;\n /**\n * Add overflow=clip when passing animation\n * @default true\n * */\n overflowHidden?: boolean;\n /**\n * Value for height after animation\n * @default auto\n */\n defaultHeight?: 'auto' | '100%';\n};\n\nexport type IntergalacticAccordionComponent<PropsExtending = {}> = (<\n Value extends AccordionValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n AccordionProps<Value>,\n AccordionContext & { value: Value },\n [handlers: AccordionHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', AccordionProps>;\n\nexport type AccordionItemComponent = Intergalactic.Component<\n 'div',\n AccordionItemProps,\n AccordionItemContext\n>;\nexport type AccordionItemToggleComponent = Intergalactic.Component<typeof Text, AccordionItemToggleProps>;\nexport type AccordionItemToggleButtonComponent = Intergalactic.Component<typeof Flex, {}>;\nexport type AccordionItemChevronComponent = Intergalactic.Component<'div', ChevronItemProps>;\nexport type AccordionItemCollapseComponent = Intergalactic.Component<'div', AccordionCollapseProps>;\n\nexport type AccordionComponent = IntergalacticAccordionComponent & {\n Item: AccordionItemComponent & {\n Toggle: AccordionItemToggleComponent;\n ToggleButton: AccordionItemToggleButtonComponent;\n Chevron: AccordionItemChevronComponent;\n Collapse: AccordionItemCollapseComponent;\n };\n};\n"],"mappings":"","ignoreList":[]}
package/lib/es6/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { default } from './Accordion';
2
- export * from './Accordion';
1
+ export { default, wrapAccordion } from './Accordion';
2
+ export * from './Accordion.type';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default"],"sources":["../../src/index.js"],"sourcesContent":["export { default } from './Accordion';\nexport * from './Accordion';\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,aAAa;AACrC,cAAc,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default","wrapAccordion"],"sources":["../../src/index.ts"],"sourcesContent":["export { default, wrapAccordion } from './Accordion';\nexport * from './Accordion.type';\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,aAAa,QAAQ,aAAa;AACpD,cAAc,kBAAkB","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { createComponent, sstyled, Component, assignProps } from "@semcore/core";
2
+ import { sstyled, createComponent, Component, assignProps } from "@semcore/core";
3
3
  import { Collapse as Collapse$1, Flex } from "@semcore/base-components";
4
4
  import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
5
5
  import { cssVariableEnhance } from "@semcore/core/lib/utils/useCssVariable";
@@ -79,7 +79,7 @@ _defineProperty(RootAccordion, "defaultProps", {
79
79
  _defineProperty(RootAccordion, "enhance", [cssVariableEnhance({
80
80
  variable: "--intergalactic-duration-accordion",
81
81
  fallback: "200",
82
- map: Number.parseInt,
82
+ map: (value) => `${Number.parseInt(value)}`,
83
83
  prop: "duration"
84
84
  })]);
85
85
  class RootItem extends Component {
@@ -205,18 +205,14 @@ function Chevron(props) {
205
205
  }));
206
206
  }
207
207
  function ToggleButton(props) {
208
- var _ref3 = arguments[0], _ref7;
208
+ var _ref3 = arguments[0];
209
209
  const {
210
210
  styles
211
211
  } = props;
212
- const SToggleButton = Flex;
213
- return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(SToggleButton, _ref7.cn("SToggleButton", {
214
- ...assignProps({
215
- "alignItems": "center",
216
- "role": "button",
217
- ...props
218
- }, _ref3)
219
- }));
212
+ return sstyled(styles), /* @__PURE__ */ React.createElement(Flex, assignProps({
213
+ "alignItems": "center",
214
+ "role": "button"
215
+ }, _ref3));
220
216
  }
221
217
  function Collapse(props) {
222
218
  var _ref4 = arguments[0];
package/lib/esm/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import { RootItem, default as default2, wrapAccordion } from "./Accordion.mjs";
1
+ import { default as default2, wrapAccordion } from "./Accordion.mjs";
2
2
  export {
3
- RootItem,
4
3
  default2 as default,
5
4
  wrapAccordion
6
5
  };
@@ -0,0 +1,68 @@
1
+ import type { Intergalactic } from '@semcore/core';
2
+ import { Component } from '@semcore/core';
3
+ import React from 'react';
4
+ import type { AccordionComponent, AccordionHandlers, AccordionItemComponent, AccordionItemProps, IntergalacticAccordionComponent } from './Accordion.type';
5
+ declare class RootAccordion extends Component<Intergalactic.InternalTypings.InferComponentProps<IntergalacticAccordionComponent>, typeof RootAccordion.enhance, AccordionHandlers> {
6
+ static displayName: string;
7
+ static style: {
8
+ [key: string]: string;
9
+ };
10
+ static defaultProps: {
11
+ defaultValue: never[];
12
+ use: string;
13
+ };
14
+ static enhance: readonly [<T extends {}>(props: T) => T & {
15
+ duration: string;
16
+ }];
17
+ uncontrolledProps(): {
18
+ value: null;
19
+ };
20
+ handleToggleInteraction: (newValue: AccordionItemProps["value"]) => void;
21
+ getItemProps({ value }: AccordionItemProps): {
22
+ selected: boolean;
23
+ duration: never;
24
+ use: "primary" | "secondary" | undefined;
25
+ $handleInteraction: (newValue: AccordionItemProps["value"]) => void;
26
+ };
27
+ render(): React.JSX.Element;
28
+ }
29
+ export declare class RootItem extends Component<Intergalactic.InternalTypings.InferChildComponentProps<AccordionItemComponent, typeof RootAccordion, 'Item'>, typeof RootItem.enhance> {
30
+ static displayName: string;
31
+ static style: {
32
+ [key: string]: string;
33
+ };
34
+ static enhance: readonly [(props: any) => {
35
+ uid: ReturnType<typeof import("@semcore/core/lib/utils/uniqueID").useUID>;
36
+ }];
37
+ handleClick: () => void;
38
+ getToggleProps(): {
39
+ use: "primary" | "secondary" | undefined;
40
+ disabled: boolean | undefined;
41
+ onClick: (() => void) | undefined;
42
+ id: string;
43
+ tag: string;
44
+ size: number;
45
+ tabIndex: number;
46
+ };
47
+ getToggleButtonProps(): {
48
+ disabled: boolean | undefined;
49
+ id: string;
50
+ 'aria-expanded': string;
51
+ 'aria-controls': string | undefined;
52
+ };
53
+ getCollapseProps(): {
54
+ selected: boolean;
55
+ duration: number | undefined;
56
+ id: string;
57
+ role: string;
58
+ 'aria-labelledby': string;
59
+ };
60
+ getChevronProps(): {
61
+ selected: boolean;
62
+ size: number | undefined;
63
+ };
64
+ render(): React.JSX.Element;
65
+ }
66
+ declare const Accordion: AccordionComponent;
67
+ export declare const wrapAccordion: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.UntypeRefAndTag<Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticAccordionComponent>> & PropsExtending) => React.ReactNode) => IntergalacticAccordionComponent<PropsExtending>;
68
+ export default Accordion;
@@ -0,0 +1,114 @@
1
+ import type { BoxProps, FlexProps, Flex } from '@semcore/base-components';
2
+ import type { PropGetterFn, Intergalactic } from '@semcore/core';
3
+ import type { Text } from '@semcore/typography';
4
+ import type { Property } from 'csstype';
5
+ export type AccordionValue = null | number | string | Array<number | string | null>;
6
+ export type AccordionProps<T extends AccordionValue = AccordionValue> = FlexProps & {
7
+ /** Value for the active tab. Can be set as stroke, number, null or as array.
8
+ * @type AccordionValue
9
+ * */
10
+ value?: T;
11
+ /**
12
+ * Value of the active tabs selected by default
13
+ * @type AccordionValue
14
+ * @default []
15
+ */
16
+ defaultValue?: T;
17
+ /** Called when the selection is changed
18
+ * @type (value: AccordionValue, event?: React.SyntheticEvent) => void
19
+ * */
20
+ onChange?: ((value: T, event?: React.SyntheticEvent) => void) | React.Dispatch<React.SetStateAction<T>>;
21
+ /** Animation duration of each Accordion.Item inside
22
+ * @default 350 */
23
+ duration?: number;
24
+ /**
25
+ * Changes the visual appearance of the component
26
+ * @default secondary
27
+ */
28
+ use?: 'primary' | 'secondary';
29
+ };
30
+ export interface IAccordionProps<T extends AccordionValue = AccordionValue> extends AccordionProps<T> {
31
+ }
32
+ export type AccordionContext = {
33
+ getItemProps: PropGetterFn;
34
+ };
35
+ export type AccordionHandlers = {
36
+ value: AccordionProps['value'];
37
+ };
38
+ export type AccordionItemProps = {
39
+ /** Tab value */
40
+ value: string | number;
41
+ /** Disabling selection changes */
42
+ disabled?: boolean;
43
+ /** Animation duration
44
+ * @default 350 */
45
+ duration?: number;
46
+ };
47
+ export type AccordionItemContext = {
48
+ getToggleProps?: PropGetterFn;
49
+ getCollapseProps?: PropGetterFn;
50
+ getChevronProps?: PropGetterFn;
51
+ selected?: boolean;
52
+ };
53
+ export type AccordionItemToggleProps = BoxProps & {
54
+ tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
55
+ };
56
+ export type ChevronItemProps = BoxProps & {
57
+ /**
58
+ * Chevron size
59
+ * @default m
60
+ */
61
+ size?: 'm' | 'l';
62
+ };
63
+ export type CollapseAnimationProps = {
64
+ /** Animation titles */
65
+ keyframes?: [string, string];
66
+ /** Enables animation on first rendering
67
+ * @default false
68
+ */
69
+ initialAnimation?: boolean;
70
+ /**
71
+ * @default ease-out
72
+ */
73
+ timingFunction?: Property.AnimationTimingFunction;
74
+ /**
75
+ * @default false
76
+ */
77
+ animationsDisabled?: boolean;
78
+ };
79
+ export type AccordionCollapseProps = BoxProps & CollapseAnimationProps & {
80
+ /** Animation duration in ms
81
+ * @default 0
82
+ */
83
+ duration?: number | [number, number];
84
+ /** If it set to `true`, animated node is persisted in dom even if `visible=false` */
85
+ preserveNode?: boolean;
86
+ /**
87
+ * Add overflow=clip when passing animation
88
+ * @default true
89
+ * */
90
+ overflowHidden?: boolean;
91
+ /**
92
+ * Value for height after animation
93
+ * @default auto
94
+ */
95
+ defaultHeight?: 'auto' | '100%';
96
+ };
97
+ export type IntergalacticAccordionComponent<PropsExtending = {}> = (<Value extends AccordionValue, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', AccordionProps<Value>, AccordionContext & {
98
+ value: Value;
99
+ }, [
100
+ handlers: AccordionHandlers
101
+ ]> & PropsExtending) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', AccordionProps>;
102
+ export type AccordionItemComponent = Intergalactic.Component<'div', AccordionItemProps, AccordionItemContext>;
103
+ export type AccordionItemToggleComponent = Intergalactic.Component<typeof Text, AccordionItemToggleProps>;
104
+ export type AccordionItemToggleButtonComponent = Intergalactic.Component<typeof Flex, {}>;
105
+ export type AccordionItemChevronComponent = Intergalactic.Component<'div', ChevronItemProps>;
106
+ export type AccordionItemCollapseComponent = Intergalactic.Component<'div', AccordionCollapseProps>;
107
+ export type AccordionComponent = IntergalacticAccordionComponent & {
108
+ Item: AccordionItemComponent & {
109
+ Toggle: AccordionItemToggleComponent;
110
+ ToggleButton: AccordionItemToggleButtonComponent;
111
+ Chevron: AccordionItemChevronComponent;
112
+ Collapse: AccordionItemCollapseComponent;
113
+ };
114
+ };
@@ -1,150 +1,2 @@
1
- import type { BoxProps, FlexProps, Flex } from '@semcore/base-components';
2
- import type { PropGetterFn, Intergalactic } from '@semcore/core';
3
- import type { Text } from '@semcore/typography';
4
- import type { Property } from 'csstype';
5
-
6
- export type AccordionValue = null | number | string | Array<number | string | null>;
7
-
8
- export type AccordionProps<T extends AccordionValue = AccordionValue> = FlexProps & {
9
- /** Value for the active tab. Can be set as stroke, number, null or as array.
10
- * @type AccordionValue
11
- * */
12
- value?: T;
13
- /**
14
- * Value of the active tabs selected by default
15
- * @type AccordionValue
16
- * @default []
17
- */
18
- defaultValue?: T;
19
- /** Called when the selection is changed
20
- * @type (value: AccordionValue, event?: React.SyntheticEvent) => void
21
- * */
22
- onChange?:
23
- | ((value: T, event?: React.SyntheticEvent) => void)
24
- | React.Dispatch<React.SetStateAction<T>>;
25
- /** Animation duration of each Accordion.Item inside
26
- * @default 350 */
27
- duration?: number;
28
-
29
- /**
30
- * Changes the visual appearance of the component
31
- * @default secondary
32
- */
33
- use?: 'primary' | 'secondary';
34
- };
35
-
36
- export interface IAccordionProps<T extends AccordionValue = AccordionValue>
37
- extends AccordionProps<T> {}
38
-
39
- export type AccordionContext = {
40
- getItemProps: PropGetterFn;
41
- };
42
-
43
- export type AccordionHandlers = {
44
- value: (value: AccordionValue) => void;
45
- };
46
-
47
- export type AccordionItemProps = {
48
- /** Tab value */
49
- value: string | number;
50
- /** Disabling selection changes */
51
- disabled?: boolean;
52
- /** Animation duration
53
- * @default 350 */
54
- duration?: number;
55
- };
56
-
57
- export type AccordionItemContext = {
58
- getToggleProps?: PropGetterFn;
59
- getCollapseProps?: PropGetterFn;
60
- getChevronProps?: PropGetterFn;
61
- selected?: boolean;
62
- };
63
-
64
- export type AccordionItemToggleProps = BoxProps & {
65
- tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
66
- };
67
- export type ChevronItemProps = BoxProps & {
68
- /**
69
- * Chevron size
70
- * @default m
71
- */
72
- size?: 'm' | 'l';
73
- };
74
-
75
- export type CollapseAnimationProps = {
76
- /** Animation titles */
77
- keyframes?: [string, string];
78
- /** Enables animation on first rendering
79
- * @default false
80
- */
81
- initialAnimation?: boolean;
82
- /**
83
- * @default ease-out
84
- */
85
- timingFunction?: Property.AnimationTimingFunction;
86
- /**
87
- * @default false
88
- */
89
- animationsDisabled?: boolean;
90
- };
91
-
92
- export type AccordionCollapseProps = BoxProps & CollapseAnimationProps & {
93
- /** Animation duration in ms
94
- * @default 0
95
- */
96
- duration?: number | [number, number];
97
- /** If it set to `true`, animated node is persisted in dom even if `visible=false` */
98
- preserveNode?: boolean;
99
- /**
100
- * Add overflow=clip when passing animation
101
- * @default true
102
- * */
103
- overflowHidden?: boolean;
104
- /**
105
- * Value for height after animation
106
- * @default auto
107
- */
108
- defaultHeight?: 'auto' | '100%';
109
- };
110
-
111
- type IntergalacticAccordionComponent<PropsExtending = {}> = (<
112
- Value extends AccordionValue,
113
- Tag extends Intergalactic.Tag = 'div',
114
- >(
115
- props: Intergalactic.InternalTypings.ComponentProps<
116
- Tag,
117
- 'div',
118
- AccordionProps<Value>,
119
- AccordionContext & { value: Value },
120
- [handlers: AccordionHandlers]
121
- > &
122
- PropsExtending,
123
- ) => Intergalactic.InternalTypings.ComponentRenderingResults) &
124
- Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', AccordionProps>;
125
-
126
- declare const Accordion: IntergalacticAccordionComponent & {
127
- Item: Intergalactic.Component<
128
- 'div',
129
- AccordionItemProps,
130
- AccordionItemContext,
131
- [handlers: AccordionHandlers]
132
- > & {
133
- Toggle: Intergalactic.Component<typeof Text, AccordionItemToggleProps>;
134
- ToggleButton: Intergalactic.Component<typeof Flex, {}>;
135
- Chevron: Intergalactic.Component<'div', ChevronItemProps>;
136
- Collapse: Intergalactic.Component<'div', AccordionCollapseProps>;
137
- };
138
- };
139
-
140
- declare const wrapAccordion: <PropsExtending extends {}>(
141
- wrapper: (
142
- props: Intergalactic.InternalTypings.UntypeRefAndTag<
143
- Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticAccordionComponent>
144
- > &
145
- PropsExtending,
146
- ) => React.ReactNode,
147
- ) => IntergalacticAccordionComponent<PropsExtending>;
148
- export { wrapAccordion };
149
-
150
- export default Accordion;
1
+ export { default, wrapAccordion } from './Accordion';
2
+ export * from './Accordion.type';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/accordion",
3
3
  "description": "Semrush Accordion Component",
4
- "version": "17.0.0-prerelease.30",
4
+ "version": "17.0.0-prerelease.34",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,8 +14,8 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/button": "^17.0.0-prerelease.30",
18
- "@semcore/typography": "^17.0.0-prerelease.30",
17
+ "@semcore/button": "^17.0.0-prerelease.34",
18
+ "@semcore/typography": "^17.0.0-prerelease.34",
19
19
  "csstype": "3.1.3"
20
20
  },
21
21
  "peerDependencies": {
@@ -28,12 +28,12 @@
28
28
  "directory": "semcore/accordion"
29
29
  },
30
30
  "devDependencies": {
31
- "@semcore/core": "17.0.0-prerelease.30",
32
- "@semcore/base-components": "17.0.0-prerelease.30",
31
+ "@semcore/base-components": "17.0.0-prerelease.34",
32
+ "@semcore/core": "17.0.0-prerelease.34",
33
33
  "@semcore/testing-utils": "1.0.0",
34
- "@semcore/icon": "16.7.2-prerelease.30"
34
+ "@semcore/icon": "16.7.2-prerelease.34"
35
35
  },
36
36
  "scripts": {
37
- "build": "pnpm semcore-builder --source=js && pnpm vite build"
37
+ "build": "pnpm semcore-builder && pnpm vite build"
38
38
  }
39
39
  }
package/vite.config.ts CHANGED
@@ -7,7 +7,7 @@ export default mergeConfig(
7
7
  defineConfig({
8
8
  build: {
9
9
  lib: {
10
- entry: './src/index.js',
10
+ entry: './src/index.ts',
11
11
  },
12
12
  rollupOptions: {
13
13
  external: ['react', 'react-dom', 'react/jsx-runtime', /@babel\/runtime\/*/, /@semcore\/*/],
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=index.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { BoxProps, FlexProps, Flex } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { Text } from '@semcore/typography';\nimport type { Property } from 'csstype';\n\nexport type AccordionValue = null | number | string | Array<number | string | null>;\n\nexport type AccordionProps<T extends AccordionValue = AccordionValue> = FlexProps & {\n /** Value for the active tab. Can be set as stroke, number, null or as array.\n * @type AccordionValue\n * */\n value?: T;\n /**\n * Value of the active tabs selected by default\n * @type AccordionValue\n * @default []\n */\n defaultValue?: T;\n /** Called when the selection is changed\n * @type (value: AccordionValue, event?: React.SyntheticEvent) => void\n * */\n onChange?:\n | ((value: T, event?: React.SyntheticEvent) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Animation duration of each Accordion.Item inside\n * @default 350 */\n duration?: number;\n\n /**\n * Changes the visual appearance of the component\n * @default secondary\n */\n use?: 'primary' | 'secondary';\n};\n\nexport interface IAccordionProps<T extends AccordionValue = AccordionValue>\n extends AccordionProps<T> {}\n\nexport type AccordionContext = {\n getItemProps: PropGetterFn;\n};\n\nexport type AccordionHandlers = {\n value: (value: AccordionValue) => void;\n};\n\nexport type AccordionItemProps = {\n /** Tab value */\n value: string | number;\n /** Disabling selection changes */\n disabled?: boolean;\n /** Animation duration\n * @default 350 */\n duration?: number;\n};\n\nexport type AccordionItemContext = {\n getToggleProps?: PropGetterFn;\n getCollapseProps?: PropGetterFn;\n getChevronProps?: PropGetterFn;\n selected?: boolean;\n};\n\nexport type AccordionItemToggleProps = BoxProps & {\n tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n};\nexport type ChevronItemProps = BoxProps & {\n /**\n * Chevron size\n * @default m\n */\n size?: 'm' | 'l';\n};\n\nexport type CollapseAnimationProps = {\n /** Animation titles */\n keyframes?: [string, string];\n /** Enables animation on first rendering\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * @default ease-out\n */\n timingFunction?: Property.AnimationTimingFunction;\n /**\n * @default false\n */\n animationsDisabled?: boolean;\n};\n\nexport type AccordionCollapseProps = BoxProps & CollapseAnimationProps & {\n /** Animation duration in ms\n * @default 0\n */\n duration?: number | [number, number];\n /** If it set to `true`, animated node is persisted in dom even if `visible=false` */\n preserveNode?: boolean;\n /**\n * Add overflow=clip when passing animation\n * @default true\n * */\n overflowHidden?: boolean;\n /**\n * Value for height after animation\n * @default auto\n */\n defaultHeight?: 'auto' | '100%';\n};\n\ntype IntergalacticAccordionComponent<PropsExtending = {}> = (<\n Value extends AccordionValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n AccordionProps<Value>,\n AccordionContext & { value: Value },\n [handlers: AccordionHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', AccordionProps>;\n\ndeclare const Accordion: IntergalacticAccordionComponent & {\n Item: Intergalactic.Component<\n 'div',\n AccordionItemProps,\n AccordionItemContext,\n [handlers: AccordionHandlers]\n > & {\n Toggle: Intergalactic.Component<typeof Text, AccordionItemToggleProps>;\n ToggleButton: Intergalactic.Component<typeof Flex, {}>;\n Chevron: Intergalactic.Component<'div', ChevronItemProps>;\n Collapse: Intergalactic.Component<'div', AccordionCollapseProps>;\n };\n};\n\ndeclare const wrapAccordion: <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticAccordionComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => IntergalacticAccordionComponent<PropsExtending>;\nexport { wrapAccordion };\n\nexport default Accordion;\n"],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { BoxProps, FlexProps, Flex } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type { Text } from '@semcore/typography';\nimport type { Property } from 'csstype';\n\nexport type AccordionValue = null | number | string | Array<number | string | null>;\n\nexport type AccordionProps<T extends AccordionValue = AccordionValue> = FlexProps & {\n /** Value for the active tab. Can be set as stroke, number, null or as array.\n * @type AccordionValue\n * */\n value?: T;\n /**\n * Value of the active tabs selected by default\n * @type AccordionValue\n * @default []\n */\n defaultValue?: T;\n /** Called when the selection is changed\n * @type (value: AccordionValue, event?: React.SyntheticEvent) => void\n * */\n onChange?:\n | ((value: T, event?: React.SyntheticEvent) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Animation duration of each Accordion.Item inside\n * @default 350 */\n duration?: number;\n\n /**\n * Changes the visual appearance of the component\n * @default secondary\n */\n use?: 'primary' | 'secondary';\n};\n\nexport interface IAccordionProps<T extends AccordionValue = AccordionValue>\n extends AccordionProps<T> {}\n\nexport type AccordionContext = {\n getItemProps: PropGetterFn;\n};\n\nexport type AccordionHandlers = {\n value: (value: AccordionValue) => void;\n};\n\nexport type AccordionItemProps = {\n /** Tab value */\n value: string | number;\n /** Disabling selection changes */\n disabled?: boolean;\n /** Animation duration\n * @default 350 */\n duration?: number;\n};\n\nexport type AccordionItemContext = {\n getToggleProps?: PropGetterFn;\n getCollapseProps?: PropGetterFn;\n getChevronProps?: PropGetterFn;\n selected?: boolean;\n};\n\nexport type AccordionItemToggleProps = BoxProps & {\n tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n};\nexport type ChevronItemProps = BoxProps & {\n /**\n * Chevron size\n * @default m\n */\n size?: 'm' | 'l';\n};\n\nexport type CollapseAnimationProps = {\n /** Animation titles */\n keyframes?: [string, string];\n /** Enables animation on first rendering\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * @default ease-out\n */\n timingFunction?: Property.AnimationTimingFunction;\n /**\n * @default false\n */\n animationsDisabled?: boolean;\n};\n\nexport type AccordionCollapseProps = BoxProps & CollapseAnimationProps & {\n /** Animation duration in ms\n * @default 0\n */\n duration?: number | [number, number];\n /** If it set to `true`, animated node is persisted in dom even if `visible=false` */\n preserveNode?: boolean;\n /**\n * Add overflow=clip when passing animation\n * @default true\n * */\n overflowHidden?: boolean;\n /**\n * Value for height after animation\n * @default auto\n */\n defaultHeight?: 'auto' | '100%';\n};\n\ntype IntergalacticAccordionComponent<PropsExtending = {}> = (<\n Value extends AccordionValue,\n Tag extends Intergalactic.Tag = 'div',\n>(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n AccordionProps<Value>,\n AccordionContext & { value: Value },\n [handlers: AccordionHandlers]\n > &\n PropsExtending,\n) => Intergalactic.InternalTypings.ComponentRenderingResults) &\nIntergalactic.InternalTypings.ComponentAdditive<'div', 'div', AccordionProps>;\n\ndeclare const Accordion: IntergalacticAccordionComponent & {\n Item: Intergalactic.Component<\n 'div',\n AccordionItemProps,\n AccordionItemContext,\n [handlers: AccordionHandlers]\n > & {\n Toggle: Intergalactic.Component<typeof Text, AccordionItemToggleProps>;\n ToggleButton: Intergalactic.Component<typeof Flex, {}>;\n Chevron: Intergalactic.Component<'div', ChevronItemProps>;\n Collapse: Intergalactic.Component<'div', AccordionCollapseProps>;\n };\n};\n\ndeclare const wrapAccordion: <PropsExtending extends {}>(\n wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticAccordionComponent>\n > &\n PropsExtending,\n ) => React.ReactNode,\n) => IntergalacticAccordionComponent<PropsExtending>;\nexport { wrapAccordion };\n\nexport default Accordion;\n"],"mappings":"","ignoreList":[]}