@semcore/accordion 5.48.2 → 5.49.0-prerelease.0

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.
@@ -2,52 +2,44 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
+ import _callSuper from "@babel/runtime/helpers/esm/callSuper";
6
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
7
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
8
7
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
- import { sstyled } from "@semcore/utils/lib/core/index";
10
- import createComponent, { Component, sstyled as sstyled$1, assignProps } from "@semcore/core";
11
- import React from "react";
12
- import { Flex } from "@semcore/flex-box";
13
- import { Collapse as Collapse$1 } from "@semcore/animation";
14
- import { Text } from "@semcore/typography";
15
- import ChevronRightM from "@semcore/icon/ChevronRight/m";
8
+ import { sstyled, Component, assignProps, createComponent } from "@semcore/core";
9
+ import { Flex, Collapse as Collapse$1 } from "@semcore/base-components";
10
+ import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
11
+ import { cssVariableEnhance } from "@semcore/core/lib/utils/useCssVariable";
16
12
  import ChevronRightL from "@semcore/icon/ChevronRight/l";
17
- import keyboardFocusEnhance from "@semcore/utils/lib/enhances/keyboardFocusEnhance";
18
- import uniqueIDEnhancement from "@semcore/utils/lib/uniqueID";
19
- import { cssVariableEnhance } from "@semcore/utils/lib/useCssVariable";
13
+ import ChevronRightM from "@semcore/icon/ChevronRight/m";
14
+ import { Text } from "@semcore/typography";
15
+ import React from "react";
20
16
  /*!__reshadow-styles__:"./style/accordion.shadow.css"*/
21
17
  var style = (
22
18
  /*__reshadow_css_start__*/
23
19
  (sstyled.insert(
24
20
  /*__inner_css_start__*/
25
- '.___SItemToggle_amcdq_gg_{display:flex;align-items:center;position:relative;cursor:pointer;outline:0}.___SItemToggle_amcdq_gg_.__keyboardFocused_amcdq_gg_:not(._tabIndex_-1_amcdq_gg_)::after{position:absolute;display:block;content:"";top:3px;right:3px;bottom:3px;left:3px;box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5));pointer-events:none;z-index:3}.___SItemToggle_amcdq_gg_.__use_amcdq_gg_.__use_amcdq_gg_{color:var(--intergalactic-text-primary, #191b23);font-weight:var(--intergalactic-regular, 400)}.___SItemToggle_amcdq_gg_.__use_amcdq_gg_._use_primary_amcdq_gg_{background-color:var(--intergalactic-bg-secondary-neutral, #f4f5f9);padding:var(--intergalactic-spacing-2x, 8px) var(--intergalactic-spacing-3x, 12px);margin-bottom:var(--intergalactic-spacing-05x, 2px)}@media (hover:hover){.___SItemToggle_amcdq_gg_.__use_amcdq_gg_._use_primary_amcdq_gg_:hover{background-color:var(--intergalactic-bg-secondary-neutral-hover, #e0e1e9)}}.___SItemToggle_amcdq_gg_.__disabled_amcdq_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default}.___SItemChevron_amcdq_gg_{transform:rotate(0deg);transition:transform calc(var(--intergalactic-duration-accordion, 200)*1ms) ease-out;fill:var(--intergalactic-icon-primary-neutral, #6c6e79)}.___SItemChevron_amcdq_gg_.__selected_amcdq_gg_{transform:rotate(90deg)}@media (prefers-reduced-motion){.___SItemChevron_amcdq_gg_{transition:none}}',
21
+ ".___SItemToggle_hkpt8_gg_{display:flex;align-items:center;position:relative;cursor:pointer;outline:0}.___SItemToggle_hkpt8_gg_.__use_hkpt8_gg_.__use_hkpt8_gg_{color:var(--intergalactic-text-primary, rgba(1, 5, 0, 0.899));font-weight:var(--intergalactic-regular, 400)}.___SItemToggle_hkpt8_gg_.__use_hkpt8_gg_._use_primary_hkpt8_gg_{background-color:var(--intergalactic-bg-secondary-neutral, rgb(248, 249, 248));padding:var(--intergalactic-spacing-2x, 8px) var(--intergalactic-spacing-3x, 12px);margin-bottom:var(--intergalactic-spacing-05x, 2px)}@media (hover:hover){.___SItemToggle_hkpt8_gg_.__use_hkpt8_gg_._use_primary_hkpt8_gg_:hover{background-color:var(--intergalactic-bg-secondary-neutral-hover, rgb(241, 242, 242))}}.___SItemToggle_hkpt8_gg_.__disabled_hkpt8_gg_{opacity:var(--intergalactic-disabled-opacity, 0.4);cursor:default}.___SItemChevron_hkpt8_gg_{margin-right:var(--intergalactic-spacing-2x, 8px);transform:rotate(0deg);transition:transform calc(var(--intergalactic-duration-accordion, 200)*1ms) ease-out;fill:var(--intergalactic-icon-primary-neutral, rgba(0, 4, 1, 0.526))}.___SItemChevron_hkpt8_gg_.__selected_hkpt8_gg_{transform:rotate(90deg)}@media (prefers-reduced-motion){.___SItemChevron_hkpt8_gg_{transition:none}}",
26
22
  /*__inner_css_end__*/
27
- "amcdq_gg_"
23
+ "hkpt8_gg_"
28
24
  ), /*__reshadow_css_end__*/
29
25
  {
30
- "__SItemToggle": "___SItemToggle_amcdq_gg_",
31
- "_keyboardFocused": "__keyboardFocused_amcdq_gg_",
32
- "_tabIndex_-1": "_tabIndex_-1_amcdq_gg_",
33
- "_use": "__use_amcdq_gg_",
34
- "_use_primary": "_use_primary_amcdq_gg_",
35
- "_disabled": "__disabled_amcdq_gg_",
36
- "__SItemChevron": "___SItemChevron_amcdq_gg_",
37
- "_selected": "__selected_amcdq_gg_"
26
+ "__SItemToggle": "___SItemToggle_hkpt8_gg_",
27
+ "_use": "__use_hkpt8_gg_",
28
+ "_use_primary": "_use_primary_hkpt8_gg_",
29
+ "_disabled": "__disabled_hkpt8_gg_",
30
+ "__SItemChevron": "___SItemChevron_hkpt8_gg_",
31
+ "_selected": "__selected_hkpt8_gg_"
38
32
  })
39
33
  );
40
- var RootAccordion = /* @__PURE__ */ function(_Component) {
41
- _inherits(RootAccordion2, _Component);
42
- var _super = _createSuper(RootAccordion2);
34
+ var RootAccordion = /* @__PURE__ */ (function(_Component) {
43
35
  function RootAccordion2() {
44
36
  var _this;
45
37
  _classCallCheck(this, RootAccordion2);
46
38
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
47
39
  args[_key] = arguments[_key];
48
40
  }
49
- _this = _super.call.apply(_super, [this].concat(args));
50
- _defineProperty(_assertThisInitialized(_this), "handleToggleInteraction", function(newValue) {
41
+ _this = _callSuper(this, RootAccordion2, [].concat(args));
42
+ _defineProperty(_this, "handleToggleInteraction", function(newValue) {
51
43
  var value = _this.asProps.value;
52
44
  if (Array.isArray(value)) {
53
45
  var indexOfNewValue = value.indexOf(newValue);
@@ -60,7 +52,8 @@ var RootAccordion = /* @__PURE__ */ function(_Component) {
60
52
  });
61
53
  return _this;
62
54
  }
63
- _createClass(RootAccordion2, [{
55
+ _inherits(RootAccordion2, _Component);
56
+ return _createClass(RootAccordion2, [{
64
57
  key: "uncontrolledProps",
65
58
  value: function uncontrolledProps() {
66
59
  return {
@@ -87,8 +80,7 @@ var RootAccordion = /* @__PURE__ */ function(_Component) {
87
80
  return /* @__PURE__ */ React.createElement(Children, null);
88
81
  }
89
82
  }]);
90
- return RootAccordion2;
91
- }(Component);
83
+ })(Component);
92
84
  _defineProperty(RootAccordion, "displayName", "Accordion");
93
85
  _defineProperty(RootAccordion, "style", style);
94
86
  _defineProperty(RootAccordion, "defaultProps", {
@@ -98,38 +90,38 @@ _defineProperty(RootAccordion, "defaultProps", {
98
90
  _defineProperty(RootAccordion, "enhance", [cssVariableEnhance({
99
91
  variable: "--intergalactic-duration-accordion",
100
92
  fallback: "200",
101
- map: Number.parseInt,
93
+ map: function map(value) {
94
+ return "".concat(Number.parseInt(value));
95
+ },
102
96
  prop: "duration"
103
97
  })]);
104
- var RootItem = /* @__PURE__ */ function(_Component2) {
105
- _inherits(RootItem2, _Component2);
106
- var _super2 = _createSuper(RootItem2);
98
+ var RootItem = /* @__PURE__ */ (function(_Component2) {
107
99
  function RootItem2() {
108
100
  var _this2;
109
101
  _classCallCheck(this, RootItem2);
110
102
  for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
111
103
  args[_key2] = arguments[_key2];
112
104
  }
113
- _this2 = _super2.call.apply(_super2, [this].concat(args));
114
- _defineProperty(_assertThisInitialized(_this2), "handleClick", function() {
105
+ _this2 = _callSuper(this, RootItem2, [].concat(args));
106
+ _defineProperty(_this2, "handleClick", function() {
115
107
  var _this2$asProps = _this2.asProps, value = _this2$asProps.value, $handleInteraction = _this2$asProps.$handleInteraction;
116
108
  $handleInteraction(value);
117
109
  });
118
110
  return _this2;
119
111
  }
120
- _createClass(RootItem2, [{
112
+ _inherits(RootItem2, _Component2);
113
+ return _createClass(RootItem2, [{
121
114
  key: "getToggleProps",
122
115
  value: function getToggleProps() {
123
- var _this$asProps2 = this.asProps, value = _this$asProps2.value, uid = _this$asProps2.uid;
124
- _this$asProps2.selected;
125
- var disabled = _this$asProps2.disabled, use = _this$asProps2.use;
116
+ var _this$asProps2 = this.asProps, value = _this$asProps2.value, uid = _this$asProps2.uid, disabled = _this$asProps2.disabled, use = _this$asProps2.use;
126
117
  return {
127
118
  use,
128
119
  disabled,
129
120
  onClick: disabled ? void 0 : this.handleClick,
130
121
  id: "igc-".concat(uid, "-").concat(value, "-toggle"),
131
122
  tag: "h3",
132
- size: 300
123
+ size: 300,
124
+ tabIndex: disabled ? -1 : 0
133
125
  };
134
126
  }
135
127
  }, {
@@ -138,7 +130,7 @@ var RootItem = /* @__PURE__ */ function(_Component2) {
138
130
  var _this$asProps3 = this.asProps, value = _this$asProps3.value, uid = _this$asProps3.uid, selected = _this$asProps3.selected, disabled = _this$asProps3.disabled;
139
131
  return {
140
132
  disabled,
141
- id: "igc-".concat(uid, "-").concat(value, "-toggle-button"),
133
+ "id": "igc-".concat(uid, "-").concat(value, "-toggle-button"),
142
134
  "aria-expanded": selected ? "true" : "false",
143
135
  "aria-controls": selected ? "igc-".concat(uid, "-").concat(value, "-collapse") : void 0
144
136
  };
@@ -150,8 +142,8 @@ var RootItem = /* @__PURE__ */ function(_Component2) {
150
142
  return {
151
143
  selected,
152
144
  duration,
153
- id: "igc-".concat(uid, "-").concat(value, "-collapse"),
154
- role: "region",
145
+ "id": "igc-".concat(uid, "-").concat(value, "-collapse"),
146
+ "role": "region",
155
147
  "aria-labelledby": "igc-".concat(uid, "-").concat(value, "-toggle-button")
156
148
  };
157
149
  }
@@ -171,23 +163,20 @@ var RootItem = /* @__PURE__ */ function(_Component2) {
171
163
  return /* @__PURE__ */ React.createElement(Children, null);
172
164
  }
173
165
  }]);
174
- return RootItem2;
175
- }(Component);
166
+ })(Component);
176
167
  _defineProperty(RootItem, "displayName", "Item");
177
168
  _defineProperty(RootItem, "style", style);
178
169
  _defineProperty(RootItem, "enhance", [uniqueIDEnhancement()]);
179
- var Toggle = /* @__PURE__ */ function(_Component3) {
180
- _inherits(Toggle2, _Component3);
181
- var _super3 = _createSuper(Toggle2);
170
+ var Toggle = /* @__PURE__ */ (function(_Component3) {
182
171
  function Toggle2() {
183
172
  var _this3;
184
173
  _classCallCheck(this, Toggle2);
185
174
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
186
175
  args[_key3] = arguments[_key3];
187
176
  }
188
- _this3 = _super3.call.apply(_super3, [this].concat(args));
189
- _defineProperty(_assertThisInitialized(_this3), "toggleRef", /* @__PURE__ */ React.createRef());
190
- _defineProperty(_assertThisInitialized(_this3), "handleKeyDown", function(event) {
177
+ _this3 = _callSuper(this, Toggle2, [].concat(args));
178
+ _defineProperty(_this3, "toggleRef", /* @__PURE__ */ React.createRef());
179
+ _defineProperty(_this3, "handleKeyDown", function(event) {
191
180
  if (event.key === "Enter") {
192
181
  if (_this3.toggleRef.current === event.target) {
193
182
  event.currentTarget.click();
@@ -201,38 +190,35 @@ var Toggle = /* @__PURE__ */ function(_Component3) {
201
190
  });
202
191
  return _this3;
203
192
  }
204
- _createClass(Toggle2, [{
193
+ _inherits(Toggle2, _Component3);
194
+ return _createClass(Toggle2, [{
205
195
  key: "render",
206
196
  value: function render() {
207
197
  var _ref = this.asProps, _ref5;
208
- var _this$asProps6 = this.asProps, styles = _this$asProps6.styles;
209
- _this$asProps6.disabled;
210
- var use = _this$asProps6.use;
198
+ var _this$asProps6 = this.asProps, styles = _this$asProps6.styles, use = _this$asProps6.use;
211
199
  var SItemToggle = Text;
212
- return _ref5 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SItemToggle, _ref5.cn("SItemToggle", _objectSpread({}, assignProps({
200
+ return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SItemToggle, _ref5.cn("SItemToggle", _objectSpread({}, assignProps({
213
201
  "use": use,
214
202
  "ref": this.toggleRef,
203
+ "innerOutline": true,
215
204
  "onKeyDown": this.handleKeyDown
216
205
  }, _ref))));
217
206
  }
218
207
  }]);
219
- return Toggle2;
220
- }(Component);
221
- _defineProperty(Toggle, "enhance", [keyboardFocusEnhance()]);
208
+ })(Component);
222
209
  function Chevron(props) {
223
210
  var _ref2 = arguments[0], _ref6;
224
211
  var styles = props.styles, size = props.size;
225
212
  var SItemChevron = size === "l" ? ChevronRightL : ChevronRightM;
226
- return _ref6 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SItemChevron, _ref6.cn("SItemChevron", _objectSpread({}, assignProps({}, _ref2))));
213
+ return _ref6 = sstyled(styles), /* @__PURE__ */ React.createElement(SItemChevron, _ref6.cn("SItemChevron", _objectSpread({}, assignProps({}, _ref2))));
227
214
  }
228
215
  function ToggleButton(props) {
229
216
  var _ref3 = arguments[0], _ref7;
230
217
  var styles = props.styles;
231
- var SToggleButton = Flex;
232
- return _ref7 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SToggleButton, _ref7.cn("SToggleButton", _objectSpread({}, assignProps(_objectSpread({
218
+ return _ref7 = sstyled(styles), /* @__PURE__ */ React.createElement(Flex, assignProps({
233
219
  "alignItems": "center",
234
220
  "role": "button"
235
- }, props), _ref3))));
221
+ }, _ref3));
236
222
  }
237
223
  function Collapse(props) {
238
224
  var _ref4 = arguments[0];
@@ -0,0 +1 @@
1
+
package/lib/esm/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { RootItem, default as default2, wrapAccordion } from "./Accordion.mjs";
1
+ import { default as default2, wrapAccordion } from "./Accordion.mjs";
2
+ import "./Accordion.type.mjs";
2
3
  export {
3
- RootItem,
4
4
  default2 as default,
5
5
  wrapAccordion
6
6
  };
@@ -6,37 +6,29 @@ SItemToggle {
6
6
  outline: 0;
7
7
  }
8
8
 
9
- SItemToggle[keyboardFocused]:not([tabIndex='-1'])::after {
10
- position: absolute;
11
- display: block;
12
- content: '';
13
- inset: 3px;
14
- box-shadow: var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5));
15
- pointer-events: none;
16
- z-index: 3;
17
- }
18
9
  SItemToggle[use][use] {
19
- color: var(--intergalactic-text-primary, #191b23);
10
+ color: var(--intergalactic-text-primary, oklch(0.1 0.03 137 / 0.899));
20
11
  font-weight: var(--intergalactic-regular, 400);
21
12
  }
22
13
  SItemToggle[use][use='primary'] {
23
- background-color: var(--intergalactic-bg-secondary-neutral, #f4f5f9);
14
+ background-color: var(--intergalactic-bg-secondary-neutral, oklch(0.98 0.001 180));
24
15
  padding: var(--intergalactic-spacing-2x, 8px) var(--intergalactic-spacing-3x, 12px);
25
16
  margin-bottom: var(--intergalactic-spacing-05x, 2px);
26
17
  }
27
18
  SItemToggle[use][use='primary']:hover {
28
- background-color: var(--intergalactic-bg-secondary-neutral-hover, #e0e1e9);
19
+ background-color: var(--intergalactic-bg-secondary-neutral-hover, oklch(0.96 0.001 180));
29
20
  }
30
21
 
31
22
  SItemToggle[disabled] {
32
- opacity: var(--intergalactic-disabled-opacity, 0.3);
23
+ opacity: var(--intergalactic-disabled-opacity, 0.4);
33
24
  cursor: default;
34
25
  }
35
26
 
36
27
  SItemChevron {
28
+ margin-right: var(--intergalactic-spacing-2x, 8px);
37
29
  transform: rotate(0deg);
38
30
  transition: transform calc(var(--intergalactic-duration-accordion, 200) * 1ms) ease-out;
39
- fill: var(--intergalactic-icon-primary-neutral, #6c6e79);
31
+ fill: var(--intergalactic-icon-primary-neutral, oklch(0.092 0.024 152.2 / 0.526));
40
32
 
41
33
  &[selected] {
42
34
  transform: rotate(90deg);
@@ -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 { NSAccordion } from './Accordion.type';
5
+ declare class RootAccordion extends Component<Intergalactic.InternalTypings.InferComponentProps<NSAccordion.Component>, typeof RootAccordion.enhance, NSAccordion.Handlers> {
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: NSAccordion.Item.Props["value"]) => void;
21
+ getItemProps({ value }: NSAccordion.Item.Props): {
22
+ selected: boolean;
23
+ duration: never;
24
+ use: "primary" | "secondary" | undefined;
25
+ $handleInteraction: (newValue: NSAccordion.Item.Props["value"]) => void;
26
+ };
27
+ render(): React.JSX.Element;
28
+ }
29
+ export declare class RootItem extends Component<Intergalactic.InternalTypings.InferChildComponentProps<NSAccordion.Item.Component, 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: NSAccordion.Component;
67
+ export declare const wrapAccordion: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.UntypeRefAndTag<Intergalactic.InternalTypings.ComponentPropsNesting<NSAccordion.WrapComponent>> & PropsExtending) => React.ReactNode) => NSAccordion.WrapComponent<PropsExtending>;
68
+ export default Accordion;
@@ -0,0 +1,142 @@
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
+ declare namespace NSAccordion {
6
+ type Value = null | number | string | Array<number | string | null>;
7
+ type Props<V extends NSAccordion.Value = NSAccordion.Value> = FlexProps & {
8
+ /** Value for the active tab. Can be set as stroke, number, null or as array.
9
+ * @type AccordionValue
10
+ * */
11
+ value?: V;
12
+ /**
13
+ * Value of the active tabs selected by default
14
+ * @type AccordionValue
15
+ * @default []
16
+ */
17
+ defaultValue?: V;
18
+ /** Called when the selection is changed
19
+ * @type (value: AccordionValue, event?: React.SyntheticEvent) => void
20
+ * */
21
+ onChange?: ((value: V, event?: React.SyntheticEvent) => void) | React.Dispatch<React.SetStateAction<V>>;
22
+ /** Animation duration of each Accordion.Item inside
23
+ * @default 350 */
24
+ duration?: number;
25
+ /**
26
+ * Changes the visual appearance of the component
27
+ * @default secondary
28
+ */
29
+ use?: 'primary' | 'secondary';
30
+ };
31
+ type Ctx = {
32
+ getItemProps: PropGetterFn;
33
+ };
34
+ type Handlers = {
35
+ value: Props['value'];
36
+ };
37
+ namespace Item {
38
+ type Props = {
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
+ type Ctx = {
48
+ getToggleProps?: PropGetterFn;
49
+ getCollapseProps?: PropGetterFn;
50
+ getChevronProps?: PropGetterFn;
51
+ selected?: boolean;
52
+ };
53
+ namespace Toggle {
54
+ type Props = BoxProps & {
55
+ tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
56
+ };
57
+ type Component = Intergalactic.Component<typeof Text, Props>;
58
+ }
59
+ namespace ToggleButton {
60
+ type Props = {};
61
+ type Component = Intergalactic.Component<typeof Flex, Props>;
62
+ }
63
+ namespace Chevron {
64
+ type Props = BoxProps & {
65
+ /**
66
+ * Chevron size
67
+ * @default m
68
+ */
69
+ size?: 'm' | 'l';
70
+ };
71
+ type Component = Intergalactic.Component<'div', Props>;
72
+ }
73
+ namespace Collapse {
74
+ type Props = BoxProps & {
75
+ /** Animation titles */
76
+ keyframes?: [string, string];
77
+ /** Enables animation on first rendering
78
+ * @default false
79
+ */
80
+ initialAnimation?: boolean;
81
+ /**
82
+ * @default ease-out
83
+ */
84
+ timingFunction?: Property.AnimationTimingFunction;
85
+ /**
86
+ * @default false
87
+ */
88
+ animationsDisabled?: boolean;
89
+ /** Animation duration in ms
90
+ * @default 0
91
+ */
92
+ duration?: number | [number, number];
93
+ /** If it set to `true`, animated node is persisted in dom even if `visible=false` */
94
+ preserveNode?: boolean;
95
+ /**
96
+ * Add overflow=clip when passing animation
97
+ * @default true
98
+ * */
99
+ overflowHidden?: boolean;
100
+ /**
101
+ * Value for height after animation
102
+ * @default auto
103
+ */
104
+ defaultHeight?: 'auto' | '100%';
105
+ };
106
+ type Component = Intergalactic.Component<'div', Props>;
107
+ }
108
+ type Component = Intergalactic.Component<'div', Props, Ctx> & {
109
+ Toggle: Toggle.Component;
110
+ ToggleButton: ToggleButton.Component;
111
+ Chevron: Chevron.Component;
112
+ Collapse: Collapse.Component;
113
+ };
114
+ }
115
+ type WrapComponent<PropsExtending = {}> = (<V extends Value, Tag extends Intergalactic.Tag = 'div'>(props: Intergalactic.InternalTypings.ComponentProps<Tag, 'div', Props<V>, Ctx & {
116
+ value: V;
117
+ }, [
118
+ handlers: Handlers
119
+ ]> & PropsExtending) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;
120
+ type Component = WrapComponent & {
121
+ Item: Item.Component;
122
+ };
123
+ }
124
+ /** @deprecated It will be removed in v18. */
125
+ export type AccordionValue = NSAccordion.Value;
126
+ /** @deprecated It will be removed in v18. */
127
+ export type AccordionProps<V extends AccordionValue = AccordionValue> = NSAccordion.Props<V>;
128
+ /** @deprecated It will be removed in v18. */
129
+ export type AccordionContext = NSAccordion.Ctx;
130
+ /** @deprecated It will be removed in v18. */
131
+ export type AccordionHandlers = NSAccordion.Handlers;
132
+ /** @deprecated It will be removed in v18. */
133
+ export type AccordionItemProps = NSAccordion.Item.Props;
134
+ /** @deprecated It will be removed in v18. */
135
+ export type AccordionItemContext = NSAccordion.Item.Ctx;
136
+ /** @deprecated It will be removed in v18. */
137
+ export type AccordionItemToggleProps = NSAccordion.Item.Toggle.Props;
138
+ /** @deprecated It will be removed in v18. */
139
+ export type ChevronItemProps = NSAccordion.Item.Chevron.Props;
140
+ /** @deprecated It will be removed in v18. */
141
+ export type AccordionCollapseProps = NSAccordion.Item.Collapse.Props;
142
+ export type { NSAccordion };
@@ -1,124 +1,2 @@
1
- import { BoxProps, FlexProps, Flex } from '@semcore/flex-box';
2
- import { PropGetterFn, Intergalactic, UnknownProperties } from '@semcore/core';
3
- import { CollapseProps } from '@semcore/animation';
4
- import { KeyboardFocusProps } from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
5
- import { Text } from '@semcore/typography';
6
-
7
- export type AccordionValue = null | number | string | Array<number | string | null>;
8
-
9
- export type AccordionProps<T extends AccordionValue = AccordionValue> = FlexProps & {
10
- /** Value for the active tab. Can be set as stroke, number, null or as array.
11
- * @type AccordionValue
12
- * */
13
- value?: T;
14
- /**
15
- * Value of the active tabs selected by default
16
- * @type AccordionValue
17
- * @default []
18
- */
19
- defaultValue?: T;
20
- /** Called when the selection is changed
21
- * @type (value: AccordionValue, event?: React.SyntheticEvent) => void
22
- * */
23
- onChange?:
24
- | ((value: T, event?: React.SyntheticEvent) => void)
25
- | React.Dispatch<React.SetStateAction<T>>;
26
- /** Animation duration of each Accordion.Item inside
27
- * @default 350 */
28
- duration?: number;
29
-
30
- /**
31
- * Changes the visual appearance of the component
32
- * @default secondary
33
- */
34
- use?: 'primary' | 'secondary';
35
- };
36
-
37
- export interface IAccordionProps<T extends AccordionValue = AccordionValue>
38
- extends AccordionProps<T> {}
39
-
40
- /** @deprecated */
41
- export interface IAccordionContext extends AccordionContext, UnknownProperties {}
42
- export type AccordionContext = {
43
- getItemProps: PropGetterFn;
44
- };
45
-
46
- /** @deprecated */
47
- export interface IAccordionHandlers extends AccordionHandlers, UnknownProperties {}
48
- export type AccordionHandlers = {
49
- value: (value: AccordionValue) => void;
50
- };
51
-
52
- /** @deprecated */
53
- export interface IAccordionItemProps extends AccordionItemProps, UnknownProperties {}
54
- export type AccordionItemProps = {
55
- /** Tab value */
56
- value: string | number;
57
- /** Disabling selection changes */
58
- disabled?: boolean;
59
- /** Animation duration
60
- * @default 350 */
61
- duration?: number;
62
- };
63
-
64
- /** @deprecated */
65
- export interface IAccordionItemContext extends AccordionItemContext, UnknownProperties {}
66
- export type AccordionItemContext = {
67
- getToggleProps?: PropGetterFn;
68
- getCollapseProps?: PropGetterFn;
69
- getChevronProps?: PropGetterFn;
70
- selected?: boolean;
71
- };
72
-
73
- export type AccordionItemToggleProps = BoxProps &
74
- KeyboardFocusProps & {
75
- tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
76
- };
77
- export type ChevronItemProps = BoxProps & {
78
- /**
79
- * Chevron size
80
- * @default m
81
- */
82
- size?: 'm' | 'l';
83
- };
84
-
85
- type IntergalacticAccordionComponent<PropsExtending = {}> = (<
86
- Value extends AccordionValue,
87
- Tag extends Intergalactic.Tag = 'div',
88
- >(
89
- props: Intergalactic.InternalTypings.ComponentProps<
90
- Tag,
91
- 'div',
92
- AccordionProps<Value>,
93
- AccordionContext & { value: Value },
94
- [handlers: AccordionHandlers]
95
- > &
96
- PropsExtending,
97
- ) => Intergalactic.InternalTypings.ComponentRenderingResults) &
98
- Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', AccordionProps>;
99
-
100
- declare const Accordion: IntergalacticAccordionComponent & {
101
- Item: Intergalactic.Component<
102
- 'div',
103
- AccordionItemProps,
104
- AccordionItemContext,
105
- [handlers: AccordionHandlers]
106
- > & {
107
- Toggle: Intergalactic.Component<typeof Text, AccordionItemToggleProps>;
108
- ToggleButton: Intergalactic.Component<typeof Flex, {}>;
109
- Chevron: Intergalactic.Component<'div', ChevronItemProps>;
110
- Collapse: Intergalactic.Component<'div', CollapseProps>;
111
- };
112
- };
113
-
114
- declare const wrapAccordion: <PropsExtending extends {}>(
115
- wrapper: (
116
- props: Intergalactic.InternalTypings.UntypeRefAndTag<
117
- Intergalactic.InternalTypings.ComponentPropsNesting<IntergalacticAccordionComponent>
118
- > &
119
- PropsExtending,
120
- ) => React.ReactNode,
121
- ) => IntergalacticAccordionComponent<PropsExtending>;
122
- export { wrapAccordion };
123
-
124
- 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": "5.48.2",
4
+ "version": "5.49.0-prerelease.0",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,15 +14,15 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/animation": "2.41.4",
18
- "@semcore/flex-box": "5.41.4",
19
- "@semcore/icon": "4.62.1",
20
- "@semcore/utils": "4.48.5",
21
- "@semcore/button": "5.43.3",
22
- "@semcore/typography": "5.53.2"
17
+ "@semcore/animation": "2.42.0-prerelease.0",
18
+ "@semcore/flex-box": "5.42.0-prerelease.0",
19
+ "@semcore/icon": "4.63.0-prerelease.0",
20
+ "@semcore/utils": "4.49.0-prerelease.0",
21
+ "@semcore/button": "5.44.0-prerelease.0",
22
+ "@semcore/typography": "5.54.0-prerelease.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "@semcore/core": "^2.17.5",
25
+ "@semcore/core": "^2.40.0-prerelease.0",
26
26
  "react": "16.8 - 18",
27
27
  "react-dom": "16.8 - 18"
28
28
  },