@zendeskgarden/react-accordions 8.69.5 → 8.69.7

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/dist/index.esm.js CHANGED
@@ -6,14 +6,12 @@
6
6
  */
7
7
 
8
8
  import * as React from 'react';
9
- import React__default, { cloneElement, Children, createContext, useContext, forwardRef, useRef, useState, useMemo, useEffect, useLayoutEffect } from 'react';
9
+ import React__default, { cloneElement, Children, createContext, useContext, forwardRef, useState, useMemo, isValidElement } from 'react';
10
10
  import { useAccordion } from '@zendeskgarden/container-accordion';
11
- import styled, { css, ThemeContext } from 'styled-components';
12
- import { retrieveComponentStyles, DEFAULT_THEME, getColor, getLineHeight, focusStyles, useDocument } from '@zendeskgarden/react-theming';
11
+ import styled, { css } from 'styled-components';
12
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor, getLineHeight, focusStyles } from '@zendeskgarden/react-theming';
13
13
  import { math } from 'polished';
14
14
  import { composeEventHandlers } from '@zendeskgarden/container-utilities';
15
- import debounce from 'lodash.debounce';
16
- import mergeRefs from 'react-merge-refs';
17
15
  import PropTypes from 'prop-types';
18
16
 
19
17
  function _extends$3() {
@@ -32,7 +30,7 @@ function _extends$3() {
32
30
  }
33
31
 
34
32
  const COMPONENT_ID$k = 'accordions.step_content';
35
- const sizeStyles$1 = props => {
33
+ const sizeStyles$2 = props => {
36
34
  const {
37
35
  rtl,
38
36
  space
@@ -47,11 +45,11 @@ const sizeStyles$1 = props => {
47
45
  };
48
46
  const StyledContent = styled.div.attrs({
49
47
  'data-garden-id': COMPONENT_ID$k,
50
- 'data-garden-version': '8.69.5'
48
+ 'data-garden-version': '8.69.7'
51
49
  }).withConfig({
52
50
  displayName: "StyledContent",
53
51
  componentId: "sc-mazvvo-0"
54
- })(["display:grid;grid-template-rows:", "fr;transition:grid-template-rows 0.25s ease-in-out;word-break:break-word;", " ", ";"], props => props.isActive ? 1 : 0, sizeStyles$1, props => retrieveComponentStyles(COMPONENT_ID$k, props));
52
+ })(["display:grid;grid-template-rows:", "fr;transition:grid-template-rows 0.25s ease-in-out;word-break:break-word;", " ", ";"], props => props.isActive ? 1 : 0, sizeStyles$2, props => retrieveComponentStyles(COMPONENT_ID$k, props));
55
53
  StyledContent.defaultProps = {
56
54
  theme: DEFAULT_THEME
57
55
  };
@@ -59,7 +57,7 @@ StyledContent.defaultProps = {
59
57
  const COMPONENT_ID$j = 'accordions.step_line';
60
58
  const StyledLine = styled.div.attrs({
61
59
  'data-garden-id': COMPONENT_ID$j,
62
- 'data-garden-version': '8.69.5'
60
+ 'data-garden-version': '8.69.7'
63
61
  }).withConfig({
64
62
  displayName: "StyledLine",
65
63
  componentId: "sc-1gkpjbr-0"
@@ -71,7 +69,7 @@ StyledLine.defaultProps = {
71
69
  const COMPONENT_ID$i = 'accordions.step';
72
70
  const StyledStep = styled.li.attrs({
73
71
  'data-garden-id': COMPONENT_ID$i,
74
- 'data-garden-version': '8.69.5'
72
+ 'data-garden-version': '8.69.7'
75
73
  }).withConfig({
76
74
  displayName: "StyledStep",
77
75
  componentId: "sc-12fiwtz-0"
@@ -83,7 +81,7 @@ StyledStep.defaultProps = {
83
81
  const COMPONENT_ID$h = 'accordions.step_inner_content';
84
82
  const StyledInnerContent = styled.div.attrs({
85
83
  'data-garden-id': COMPONENT_ID$h,
86
- 'data-garden-version': '8.69.5'
84
+ 'data-garden-version': '8.69.7'
87
85
  }).withConfig({
88
86
  displayName: "StyledInnerContent",
89
87
  componentId: "sc-1xs9fh7-0"
@@ -95,7 +93,7 @@ StyledInnerContent.defaultProps = {
95
93
  const COMPONENT_ID$g = 'accordions.stepper';
96
94
  const StyledStepper = styled.ol.attrs({
97
95
  'data-garden-id': COMPONENT_ID$g,
98
- 'data-garden-version': '8.69.5'
96
+ 'data-garden-version': '8.69.7'
99
97
  }).withConfig({
100
98
  displayName: "StyledStepper",
101
99
  componentId: "sc-dsxw0f-0"
@@ -109,21 +107,21 @@ const StyledIconFlexContainer = styled.div.withConfig({
109
107
  displayName: "StyledIcon__StyledIconFlexContainer",
110
108
  componentId: "sc-v20nz9-0"
111
109
  })(["display:flex;flex-basis:100%;justify-content:center;width:100%;"]);
112
- const sizeStyles = props => {
110
+ const sizeStyles$1 = props => {
113
111
  const size = `${props.theme.space.base * 6}px`;
114
112
  const fontSize = props.theme.fontSizes.sm;
115
113
  return css(["margin-bottom:", ";margin-", ":", ";width:", ";min-width:", ";height:", ";min-height:", ";line-height:", ";font-size:", ";"], props.isHorizontal && `${props.theme.space.base * 2}px`, props.theme.rtl ? 'left' : 'right', !props.isHorizontal && `${props.theme.space.base * 3}px`, size, size, size, size, getLineHeight(size, fontSize), fontSize);
116
114
  };
117
- const colorStyles$2 = props => {
115
+ const colorStyles$3 = props => {
118
116
  return css(["background:", ";color:", ";"], props.isActive ? getColor('neutralHue', 600, props.theme) : getColor('neutralHue', 200, props.theme), props.isActive ? props.theme.colors.background : props.theme.colors.foreground);
119
117
  };
120
118
  const StyledIcon = styled.div.attrs({
121
119
  'data-garden-id': COMPONENT_ID$f,
122
- 'data-garden-version': '8.69.5'
120
+ 'data-garden-version': '8.69.7'
123
121
  }).withConfig({
124
122
  displayName: "StyledIcon",
125
123
  componentId: "sc-v20nz9-1"
126
- })(["display:flex;align-items:center;justify-content:center;transition:background 0.25s ease-in-out,color 0.25s ease-in-out;border-radius:100%;", " ", " ", ";"], sizeStyles, colorStyles$2, props => retrieveComponentStyles(COMPONENT_ID$f, props));
124
+ })(["display:flex;align-items:center;justify-content:center;transition:background 0.25s ease-in-out,color 0.25s ease-in-out;border-radius:100%;", " ", " ", ";"], sizeStyles$1, colorStyles$3, props => retrieveComponentStyles(COMPONENT_ID$f, props));
127
125
  StyledIconFlexContainer.defaultProps = {
128
126
  theme: DEFAULT_THEME
129
127
  };
@@ -134,7 +132,7 @@ StyledIcon.defaultProps = {
134
132
  const COMPONENT_ID$e = 'accordions.step_label';
135
133
  const StyledLabel = styled.div.attrs({
136
134
  'data-garden-id': COMPONENT_ID$e,
137
- 'data-garden-version': '8.69.5'
135
+ 'data-garden-version': '8.69.7'
138
136
  }).withConfig({
139
137
  displayName: "StyledLabel",
140
138
  componentId: "sc-1o82llj-0"
@@ -146,7 +144,7 @@ StyledLabel.defaultProps = {
146
144
  const COMPONENT_ID$d = 'accordions.step_label_text';
147
145
  const StyledLabelText = styled.div.attrs({
148
146
  'data-garden-id': COMPONENT_ID$d,
149
- 'data-garden-version': '8.69.5'
147
+ 'data-garden-version': '8.69.7'
150
148
  }).withConfig({
151
149
  displayName: "StyledLabelText",
152
150
  componentId: "sc-111m5zo-0"
@@ -158,7 +156,7 @@ StyledLabelText.defaultProps = {
158
156
  const COMPONENT_ID$c = 'accordions.accordion';
159
157
  const StyledAccordion = styled.div.attrs({
160
158
  'data-garden-id': COMPONENT_ID$c,
161
- 'data-garden-version': '8.69.5'
159
+ 'data-garden-version': '8.69.7'
162
160
  }).withConfig({
163
161
  displayName: "StyledAccordion",
164
162
  componentId: "sc-niv9ic-0"
@@ -168,31 +166,43 @@ StyledAccordion.defaultProps = {
168
166
  };
169
167
 
170
168
  const COMPONENT_ID$b = 'accordions.panel';
171
- const paddingStyles = props => {
169
+ const colorStyles$2 = props => {
170
+ const {
171
+ theme,
172
+ isBare
173
+ } = props;
174
+ return css(["border-bottom-color:", ";"], isBare ? 'transparent' : getColor('neutralHue', 300, theme));
175
+ };
176
+ const sizeStyles = props => {
177
+ const {
178
+ theme,
179
+ isCompact,
180
+ isExpanded
181
+ } = props;
172
182
  const {
173
183
  base
174
- } = props.theme.space;
184
+ } = theme.space;
175
185
  let paddingTop = base * 2;
176
186
  let paddingHorizontal = base * 5;
177
187
  let paddingBottom = base * 8;
178
- if (props.isCompact) {
188
+ if (isCompact) {
179
189
  paddingTop = base * 2;
180
190
  paddingHorizontal = base * 3;
181
191
  paddingBottom = base * 4;
182
192
  }
183
- if (props.isExpanded === false) {
193
+ if (isExpanded === false) {
184
194
  paddingTop = 0;
185
195
  paddingBottom = 0;
186
196
  }
187
- return css(["transition:", ";padding:", "px ", "px ", "px;"], props.isAnimated && 'padding 0.25s ease-in-out', paddingTop, paddingHorizontal, paddingBottom);
197
+ return css(["grid-template-rows:", "fr;border-bottom-width:", ";border-bottom-style:solid;padding:", "px ", "px ", "px;line-height:", ";font-size:", ";"], isExpanded ? 1 : 0, theme.borderWidths.sm, paddingTop, paddingHorizontal, paddingBottom, getLineHeight(base * 5, theme.fontSizes.md), theme.fontSizes.md);
188
198
  };
189
199
  const StyledPanel = styled.section.attrs({
190
200
  'data-garden-id': COMPONENT_ID$b,
191
- 'data-garden-version': '8.69.5'
201
+ 'data-garden-version': '8.69.7'
192
202
  }).withConfig({
193
203
  displayName: "StyledPanel",
194
204
  componentId: "sc-1piryze-0"
195
- })(["", ";border-bottom:", ";", ";"], paddingStyles, props => `${props.theme.borders.sm} ${props.isBare ? 'transparent' : getColor('neutralHue', 300, props.theme)}`, props => retrieveComponentStyles(COMPONENT_ID$b, props));
205
+ })(["display:grid;transition:", ";overflow:hidden;", " ", " ", ";"], props => props.isAnimated && 'padding 0.25s ease-in-out, grid-template-rows 0.25s ease-in-out', sizeStyles, colorStyles$2, props => retrieveComponentStyles(COMPONENT_ID$b, props));
196
206
  StyledPanel.defaultProps = {
197
207
  isAnimated: true,
198
208
  theme: DEFAULT_THEME
@@ -201,7 +211,7 @@ StyledPanel.defaultProps = {
201
211
  const COMPONENT_ID$a = 'accordions.section';
202
212
  const StyledSection = styled.div.attrs({
203
213
  'data-garden-id': COMPONENT_ID$a,
204
- 'data-garden-version': '8.69.5'
214
+ 'data-garden-version': '8.69.7'
205
215
  }).withConfig({
206
216
  displayName: "StyledSection",
207
217
  componentId: "sc-v2t9bd-0"
@@ -213,7 +223,7 @@ StyledSection.defaultProps = {
213
223
  const COMPONENT_ID$9 = 'accordions.header';
214
224
  const StyledHeader = styled.div.attrs({
215
225
  'data-garden-id': COMPONENT_ID$9,
216
- 'data-garden-version': '8.69.5'
226
+ 'data-garden-version': '8.69.7'
217
227
  }).withConfig({
218
228
  displayName: "StyledHeader",
219
229
  componentId: "sc-2c6rbr-0"
@@ -238,7 +248,7 @@ const colorStyles$1 = props => {
238
248
  };
239
249
  const StyledButton = styled.button.attrs({
240
250
  'data-garden-id': COMPONENT_ID$8,
241
- 'data-garden-version': '8.69.5'
251
+ 'data-garden-version': '8.69.7'
242
252
  }).withConfig({
243
253
  displayName: "StyledButton",
244
254
  componentId: "sc-xj3hy7-0"
@@ -250,13 +260,12 @@ StyledButton.defaultProps = {
250
260
  const COMPONENT_ID$7 = 'accordions.step_inner_panel';
251
261
  const StyledInnerPanel = styled.div.attrs({
252
262
  'data-garden-id': COMPONENT_ID$7,
253
- 'data-garden-version': '8.69.5'
263
+ 'data-garden-version': '8.69.7'
254
264
  }).withConfig({
255
265
  displayName: "StyledInnerPanel",
256
266
  componentId: "sc-8nbueg-0"
257
- })(["transition:", ";max-height:", ";overflow:hidden;line-height:", ";font-size:", ";", ";"], props => props.isAnimated && 'max-height 0.25s ease-in-out', props => !props.isExpanded && '0 !important', props => getLineHeight(props.theme.space.base * 5, props.theme.fontSizes.md), props => props.theme.fontSizes.md, props => retrieveComponentStyles(COMPONENT_ID$7, props));
267
+ })(["overflow:hidden;line-height:inherit;font-size:inherit;", ";"], props => retrieveComponentStyles(COMPONENT_ID$7, props));
258
268
  StyledInnerPanel.defaultProps = {
259
- isAnimated: true,
260
269
  theme: DEFAULT_THEME
261
270
  };
262
271
 
@@ -282,7 +291,7 @@ _ref => {
282
291
  return cloneElement(Children.only(children), props);
283
292
  }).attrs({
284
293
  'data-garden-id': COMPONENT_ID$6,
285
- 'data-garden-version': '8.69.5'
294
+ 'data-garden-version': '8.69.7'
286
295
  }).withConfig({
287
296
  displayName: "StyledRotateIcon",
288
297
  componentId: "sc-hp435q-0"
@@ -294,7 +303,7 @@ StyledRotateIcon.defaultProps = {
294
303
  const COMPONENT_ID$5 = 'timeline';
295
304
  const StyledTimeline = styled.ol.attrs({
296
305
  'data-garden-id': COMPONENT_ID$5,
297
- 'data-garden-version': '8.69.5'
306
+ 'data-garden-version': '8.69.7'
298
307
  }).withConfig({
299
308
  displayName: "StyledTimeline",
300
309
  componentId: "sc-pig5kv-0"
@@ -306,7 +315,7 @@ StyledTimeline.defaultProps = {
306
315
  const COMPONENT_ID$4 = 'timeline.content.separator';
307
316
  const StyledSeparator = styled.div.attrs({
308
317
  'data-garden-id': COMPONENT_ID$4,
309
- 'data-garden-version': '8.69.5'
318
+ 'data-garden-version': '8.69.7'
310
319
  }).withConfig({
311
320
  displayName: "StyledSeparator",
312
321
  componentId: "sc-fki51e-0"
@@ -318,7 +327,7 @@ StyledSeparator.defaultProps = {
318
327
  const COMPONENT_ID$3 = 'timeline.content';
319
328
  const StyledTimelineContent = styled.div.attrs({
320
329
  'data-garden-id': COMPONENT_ID$3,
321
- 'data-garden-version': '8.69.5'
330
+ 'data-garden-version': '8.69.7'
322
331
  }).withConfig({
323
332
  displayName: "StyledContent__StyledTimelineContent",
324
333
  componentId: "sc-19phgu1-0"
@@ -330,7 +339,7 @@ StyledTimelineContent.defaultProps = {
330
339
  const COMPONENT_ID$2 = 'timeline.opposite.content';
331
340
  const StyledOppositeContent = styled.div.attrs({
332
341
  'data-garden-id': COMPONENT_ID$2,
333
- 'data-garden-version': '8.69.5'
342
+ 'data-garden-version': '8.69.7'
334
343
  }).withConfig({
335
344
  displayName: "StyledOppositeContent",
336
345
  componentId: "sc-jurh2k-0"
@@ -342,7 +351,7 @@ StyledOppositeContent.defaultProps = {
342
351
  const COMPONENT_ID$1 = 'timeline.item';
343
352
  const StyledTimelineItem = styled.li.attrs({
344
353
  'data-garden-id': COMPONENT_ID$1,
345
- 'data-garden-version': '8.69.5'
354
+ 'data-garden-version': '8.69.7'
346
355
  }).withConfig({
347
356
  displayName: "StyledItem__StyledTimelineItem",
348
357
  componentId: "sc-5mcnzm-0"
@@ -361,7 +370,7 @@ const StyledItemIcon = styled(_ref => {
361
370
  return cloneElement(Children.only(children), props);
362
371
  }).attrs({
363
372
  'data-garden-id': COMPONENT_ID,
364
- 'data-garden-version': '8.69.5'
373
+ 'data-garden-version': '8.69.7'
365
374
  }).withConfig({
366
375
  displayName: "StyledItemIcon",
367
376
  componentId: "sc-vz2l6e-0"
@@ -383,7 +392,7 @@ const StepContext = createContext(undefined);
383
392
  const useStepContext = () => {
384
393
  const context = useContext(StepContext);
385
394
  if (context === undefined) {
386
- throw new Error('This component must be rendered within a Stepper.Step component');
395
+ throw new Error('This component must be rendered within a Stepper component');
387
396
  }
388
397
  return context;
389
398
  };
@@ -401,7 +410,7 @@ const SectionContext = createContext(undefined);
401
410
  const useSectionContext = () => {
402
411
  const context = useContext(SectionContext);
403
412
  if (context === undefined) {
404
- throw new Error('This component must be rendered within a Accordion.Section component');
413
+ throw new Error('This component must be rendered within an Accordion component');
405
414
  }
406
415
  return context;
407
416
  };
@@ -433,18 +442,9 @@ const useTimelineItemContext = () => {
433
442
  return context;
434
443
  };
435
444
 
436
- const SectionComponent = forwardRef((props, ref) => {
437
- const {
438
- currentIndexRef
439
- } = useAccordionContext();
440
- const sectionIndexRef = useRef(currentIndexRef.current++);
441
- const sectionIndex = sectionIndexRef.current;
442
- return React__default.createElement(SectionContext.Provider, {
443
- value: sectionIndex
444
- }, React__default.createElement(StyledSection, _extends$3({
445
- ref: ref
446
- }, props)));
447
- });
445
+ const SectionComponent = forwardRef((props, ref) => React__default.createElement(StyledSection, _extends$3({
446
+ ref: ref
447
+ }, props)));
448
448
  SectionComponent.displayName = 'Accordion.Section';
449
449
  const Section = SectionComponent;
450
450
 
@@ -465,34 +465,35 @@ var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
465
465
  };
466
466
 
467
467
  const HeaderComponent = forwardRef((props, ref) => {
468
- const {
469
- level: ariaLevel,
470
- isCompact,
471
- isCollapsible,
472
- getHeaderProps,
473
- getTriggerProps,
474
- expandedSections
475
- } = useAccordionContext();
476
468
  const {
477
469
  onClick,
478
470
  onFocus,
479
471
  onBlur,
480
472
  onMouseOver,
481
473
  onMouseOut,
474
+ role,
482
475
  children,
483
476
  ...other
484
477
  } = props;
485
- const sectionIndex = useSectionContext();
478
+ const {
479
+ level: ariaLevel,
480
+ isCompact,
481
+ isCollapsible,
482
+ getHeaderProps,
483
+ getTriggerProps,
484
+ expandedSections
485
+ } = useAccordionContext();
486
+ const sectionValue = useSectionContext();
486
487
  const [isFocused, setIsFocused] = useState(false);
487
488
  const [isHovered, setIsHovered] = useState(false);
488
- const isExpanded = expandedSections.includes(sectionIndex);
489
+ const isExpanded = expandedSections.includes(sectionValue);
489
490
  const {
490
491
  onClick: onTriggerClick,
491
492
  onKeyDown,
492
493
  ...otherTriggerProps
493
494
  } = getTriggerProps({
494
495
  type: 'button',
495
- index: sectionIndex
496
+ value: sectionValue
496
497
  });
497
498
  const onHeaderFocus = e => {
498
499
  e.persist();
@@ -510,20 +511,21 @@ const HeaderComponent = forwardRef((props, ref) => {
510
511
  }), [isHovered, otherTriggerProps]);
511
512
  return React__default.createElement(HeaderContext.Provider, {
512
513
  value: value
513
- }, React__default.createElement(StyledHeader, getHeaderProps({
514
+ }, React__default.createElement(StyledHeader, _extends$3({
515
+ isCollapsible: isCollapsible,
516
+ isExpanded: isExpanded,
517
+ isFocused: isFocused
518
+ }, getHeaderProps({
514
519
  ref,
515
- ariaLevel,
516
- isCompact,
517
- isFocused,
518
- isExpanded,
519
- isCollapsible,
520
+ 'aria-level': ariaLevel,
521
+ role: role === undefined || role === null ? role : 'heading',
520
522
  onClick: composeEventHandlers(onClick, onTriggerClick),
521
523
  onFocus: composeEventHandlers(onFocus, onHeaderFocus),
522
524
  onBlur: composeEventHandlers(onBlur, () => setIsFocused(false)),
523
525
  onMouseOver: composeEventHandlers(onMouseOver, () => setIsHovered(true)),
524
526
  onMouseOut: composeEventHandlers(onMouseOut, () => setIsHovered(false)),
525
527
  ...other
526
- }), children, React__default.createElement(StyledRotateIcon, {
528
+ })), children, React__default.createElement(StyledRotateIcon, {
527
529
  isCompact: isCompact,
528
530
  isHovered: isHovered,
529
531
  isRotated: isExpanded,
@@ -536,13 +538,13 @@ HeaderComponent.displayName = 'Accordion.Header';
536
538
  const Header = HeaderComponent;
537
539
 
538
540
  const LabelComponent$1 = forwardRef((props, ref) => {
539
- const sectionIndex = useSectionContext();
541
+ const sectionValue = useSectionContext();
540
542
  const {
541
543
  isCompact,
542
544
  isCollapsible,
543
545
  expandedSections
544
546
  } = useAccordionContext();
545
- const isExpanded = expandedSections.includes(sectionIndex);
547
+ const isExpanded = expandedSections.includes(sectionValue);
546
548
  const {
547
549
  isHovered,
548
550
  otherTriggerProps
@@ -558,87 +560,78 @@ const LabelComponent$1 = forwardRef((props, ref) => {
558
560
  LabelComponent$1.displayName = 'Accordion.Label';
559
561
  const Label$1 = LabelComponent$1;
560
562
 
561
- const PanelComponent = forwardRef((props, ref) => {
563
+ const PanelComponent = forwardRef((_ref, ref) => {
564
+ let {
565
+ role,
566
+ children,
567
+ ...props
568
+ } = _ref;
562
569
  const {
563
- isCompact,
564
- isBare,
565
570
  isAnimated,
566
- getPanelProps,
567
- expandedSections
568
- } = useAccordionContext();
569
- const panelRef = useRef();
570
- const index = useSectionContext();
571
- const isExpanded = expandedSections.includes(index);
572
- const theme = useContext(ThemeContext);
573
- const environment = useDocument(theme);
574
- useEffect(() => {
575
- if (!isAnimated) {
576
- return undefined;
577
- }
578
- if (environment) {
579
- const updateMaxHeight = debounce(() => {
580
- if (panelRef.current) {
581
- const child = panelRef.current.children[0];
582
- child.style.maxHeight = `${child.scrollHeight}px`;
583
- }
584
- }, 100);
585
- const win = environment.defaultView || window;
586
- win.addEventListener('resize', updateMaxHeight);
587
- updateMaxHeight();
588
- return () => {
589
- updateMaxHeight.cancel();
590
- win.removeEventListener('resize', updateMaxHeight);
591
- };
592
- }
593
- return undefined;
594
- }, [isAnimated, panelRef, environment, props.children]);
595
- return React__default.createElement(StyledPanel, getPanelProps({
596
- role: null,
597
- ref: mergeRefs([panelRef, ref]),
598
- index,
599
571
  isBare,
600
572
  isCompact,
601
- isExpanded,
602
- isAnimated,
573
+ expandedSections,
574
+ getPanelProps
575
+ } = useAccordionContext();
576
+ const sectionValue = useSectionContext();
577
+ const isExpanded = expandedSections.includes(sectionValue);
578
+ return React__default.createElement(StyledPanel, _extends$3({
579
+ isAnimated: isAnimated,
580
+ isBare: isBare,
581
+ isCompact: isCompact,
582
+ isExpanded: isExpanded
583
+ }, getPanelProps({
584
+ role: role === undefined ? null : 'region',
585
+ ref,
586
+ value: sectionValue,
603
587
  ...props
604
- }), React__default.createElement(StyledInnerPanel, {
605
- isExpanded: isExpanded,
606
- isAnimated: isAnimated
607
- }, props.children));
588
+ })), React__default.createElement(StyledInnerPanel, null, children));
608
589
  });
609
590
  PanelComponent.displayName = 'Accordion.Panel';
610
591
  const Panel = PanelComponent;
611
592
 
612
593
  const AccordionComponent = forwardRef((_ref, ref) => {
613
594
  let {
614
- level,
595
+ children,
615
596
  isBare,
616
- onChange,
617
597
  isCompact,
618
598
  isAnimated,
619
599
  isExpandable,
620
600
  isCollapsible,
601
+ level,
602
+ onChange,
621
603
  defaultExpandedSections,
622
604
  expandedSections: controlledExpandedSections,
623
605
  ...props
624
606
  } = _ref;
607
+ const {
608
+ sections,
609
+ sectionChildren
610
+ } = useMemo(() => Children.toArray(children).filter(isValidElement).map((child, index) => React__default.createElement(SectionContext.Provider, {
611
+ key: index,
612
+ value: index
613
+ }, child)).reduce((acc, child, index) => {
614
+ acc.sectionChildren.push(child);
615
+ acc.sections.push(index);
616
+ return acc;
617
+ }, {
618
+ sectionChildren: [],
619
+ sections: []
620
+ }), [children]);
625
621
  const {
626
622
  expandedSections,
627
623
  getHeaderProps,
628
624
  getTriggerProps,
629
625
  getPanelProps
630
626
  } = useAccordion({
627
+ sections,
628
+ defaultExpandedSections,
629
+ expandedSections: controlledExpandedSections,
631
630
  collapsible: isCollapsible,
632
631
  expandable: isExpandable || false,
633
- onChange,
634
- defaultExpandedSections,
635
- expandedSections: controlledExpandedSections
636
- });
637
- const currentIndexRef = useRef(0);
638
- useEffect(() => {
639
- currentIndexRef.current = 0;
632
+ onChange
640
633
  });
641
- const value = useMemo(() => ({
634
+ const accordionContextValue = useMemo(() => ({
642
635
  level,
643
636
  isBare,
644
637
  isCompact,
@@ -647,14 +640,13 @@ const AccordionComponent = forwardRef((_ref, ref) => {
647
640
  getPanelProps,
648
641
  getHeaderProps,
649
642
  getTriggerProps,
650
- currentIndexRef,
651
643
  expandedSections
652
- }), [level, isBare, isCompact, isAnimated, isCollapsible, getPanelProps, getHeaderProps, getTriggerProps, currentIndexRef, expandedSections]);
644
+ }), [level, isBare, isCompact, isAnimated, isCollapsible, getPanelProps, getHeaderProps, getTriggerProps, expandedSections]);
653
645
  return React__default.createElement(AccordionContext.Provider, {
654
- value: value
646
+ value: accordionContextValue
655
647
  }, React__default.createElement(StyledAccordion, _extends$3({
656
648
  ref: ref
657
- }, props)));
649
+ }, props), sectionChildren));
658
650
  });
659
651
  AccordionComponent.displayName = 'Accordion';
660
652
  AccordionComponent.defaultProps = {
@@ -667,29 +659,18 @@ Accordion.Label = Label$1;
667
659
  Accordion.Panel = Panel;
668
660
  Accordion.Section = Section;
669
661
 
670
- const StepComponent = forwardRef((props, ref) => {
662
+ const StepComponent = forwardRef((_ref, ref) => {
663
+ let {
664
+ children,
665
+ ...props
666
+ } = _ref;
671
667
  const {
672
- currentIndexRef,
673
668
  isHorizontal
674
669
  } = useStepperContext();
675
- const [currentStepIndex, setCurrentStepIndex] = useState(currentIndexRef.current);
676
- useLayoutEffect(() => {
677
- setCurrentStepIndex(currentIndexRef.current);
678
- currentIndexRef.current++;
679
- const currentIndex = currentIndexRef;
680
- return () => {
681
- currentIndex.current--;
682
- };
683
- }, [currentIndexRef]);
684
- const value = useMemo(() => ({
685
- currentStepIndex
686
- }), [currentStepIndex]);
687
- return React__default.createElement(StepContext.Provider, {
688
- value: value
689
- }, React__default.createElement(StyledStep, _extends$3({
670
+ return React__default.createElement(StyledStep, _extends$3({
690
671
  ref: ref,
691
672
  isHorizontal: isHorizontal
692
- }, props), isHorizontal && React__default.createElement(StyledLine, null), props.children));
673
+ }, props), isHorizontal && React__default.createElement(StyledLine, null), children);
693
674
  });
694
675
  StepComponent.displayName = 'Stepper.Step';
695
676
  const Step = StepComponent;
@@ -723,16 +704,13 @@ const LabelComponent = forwardRef((_ref, ref) => {
723
704
  ...other
724
705
  } = _ref;
725
706
  const {
726
- currentStepIndex
727
- } = useStepContext();
728
- const {
729
- activeIndex,
707
+ currentStepIndex,
708
+ isActive,
709
+ isCompleted,
730
710
  isHorizontal
731
- } = useStepperContext();
711
+ } = useStepContext();
732
712
  const numericStep = currentStepIndex + 1;
733
713
  const stepIcon = icon || numericStep;
734
- const isActive = activeIndex === currentStepIndex;
735
- const isCompleted = activeIndex > currentStepIndex;
736
714
  const styledIcon = React__default.createElement(StyledIcon, {
737
715
  isActive: isActive,
738
716
  isHorizontal: isHorizontal
@@ -756,13 +734,9 @@ const Label = LabelComponent;
756
734
 
757
735
  const ContentComponent$1 = forwardRef((props, ref) => {
758
736
  const {
759
- activeIndex,
737
+ isActive,
760
738
  isHorizontal
761
- } = useStepperContext();
762
- const {
763
- currentStepIndex
764
739
  } = useStepContext();
765
- const isActive = currentStepIndex === activeIndex;
766
740
  return isHorizontal === false ? React__default.createElement(StyledContent, _extends$3({
767
741
  ref: ref,
768
742
  isActive: isActive
@@ -773,31 +747,37 @@ const ContentComponent$1 = forwardRef((props, ref) => {
773
747
  ContentComponent$1.displayName = 'Stepper.Content';
774
748
  const Content$1 = ContentComponent$1;
775
749
 
750
+ const DEFAULT_ACTIVE_INDEX = 0;
776
751
  const StepperComponent = forwardRef((_ref, ref) => {
777
752
  let {
753
+ activeIndex = DEFAULT_ACTIVE_INDEX,
778
754
  isHorizontal,
779
- activeIndex,
755
+ children,
780
756
  ...props
781
757
  } = _ref;
782
- const currentIndexRef = useRef(0);
783
758
  const stepperContext = useMemo(() => ({
784
- isHorizontal: isHorizontal || false,
785
- activeIndex: activeIndex,
786
- currentIndexRef
787
- }), [isHorizontal, activeIndex, currentIndexRef]);
788
- useEffect(() => {
789
- currentIndexRef.current = 0;
790
- });
759
+ activeIndex,
760
+ isHorizontal: isHorizontal || false
761
+ }), [activeIndex, isHorizontal]);
791
762
  return React__default.createElement(StepperContext.Provider, {
792
763
  value: stepperContext
793
764
  }, React__default.createElement(StyledStepper, _extends$3({
794
765
  ref: ref,
795
766
  isHorizontal: isHorizontal
796
- }, props)));
767
+ }, props), useMemo(() => Children.toArray(children).filter(isValidElement).map((child, index) => React__default.createElement(StepContext.Provider, {
768
+ key: index
769
+ ,
770
+ value: {
771
+ currentStepIndex: index,
772
+ isActive: stepperContext.activeIndex === index,
773
+ isCompleted: stepperContext.activeIndex > index,
774
+ isHorizontal: stepperContext.isHorizontal
775
+ }
776
+ }, child)), [children, stepperContext])));
797
777
  });
798
778
  StepperComponent.displayName = 'Stepper';
799
779
  StepperComponent.defaultProps = {
800
- activeIndex: 0
780
+ activeIndex: DEFAULT_ACTIVE_INDEX
801
781
  };
802
782
  const Stepper = StepperComponent;
803
783
  Stepper.Content = Content$1;