@zendeskgarden/react-accordions 8.49.1 → 8.49.4

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,15 +6,15 @@
6
6
  */
7
7
 
8
8
  import * as React from 'react';
9
- import React__default, { cloneElement, Children, createContext, useContext, forwardRef, useState, useLayoutEffect, useMemo, useRef, useCallback, useEffect } from 'react';
9
+ import React__default, { cloneElement, Children, createContext, useContext, forwardRef, useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect } from 'react';
10
+ import { useAccordion } from '@zendeskgarden/container-accordion';
10
11
  import styled, { css } from 'styled-components';
11
12
  import { retrieveComponentStyles, DEFAULT_THEME, getColor, getLineHeight } from '@zendeskgarden/react-theming';
12
13
  import { math } from 'polished';
13
- import PropTypes from 'prop-types';
14
- import mergeRefs from 'react-merge-refs';
15
- import debounce from 'lodash.debounce';
16
- import { useAccordion } from '@zendeskgarden/container-accordion';
17
14
  import { composeEventHandlers } from '@zendeskgarden/container-utilities';
15
+ import debounce from 'lodash.debounce';
16
+ import mergeRefs from 'react-merge-refs';
17
+ import PropTypes from 'prop-types';
18
18
 
19
19
  function ownKeys(object, enumerableOnly) {
20
20
  var keys = Object.keys(object);
@@ -185,7 +185,7 @@ var sizeStyles$1 = function sizeStyles(props) {
185
185
  };
186
186
  var StyledContent = styled.div.attrs({
187
187
  'data-garden-id': COMPONENT_ID$k,
188
- 'data-garden-version': '8.49.1'
188
+ 'data-garden-version': '8.49.4'
189
189
  }).withConfig({
190
190
  displayName: "StyledContent",
191
191
  componentId: "sc-mazvvo-0"
@@ -201,7 +201,7 @@ StyledContent.defaultProps = {
201
201
  var COMPONENT_ID$j = 'accordions.step_line';
202
202
  var StyledLine = styled.div.attrs({
203
203
  'data-garden-id': COMPONENT_ID$j,
204
- 'data-garden-version': '8.49.1'
204
+ 'data-garden-version': '8.49.4'
205
205
  }).withConfig({
206
206
  displayName: "StyledLine",
207
207
  componentId: "sc-1gkpjbr-0"
@@ -223,7 +223,7 @@ StyledLine.defaultProps = {
223
223
  var COMPONENT_ID$i = 'accordions.step';
224
224
  var StyledStep = styled.li.attrs({
225
225
  'data-garden-id': COMPONENT_ID$i,
226
- 'data-garden-version': '8.49.1'
226
+ 'data-garden-version': '8.49.4'
227
227
  }).withConfig({
228
228
  displayName: "StyledStep",
229
229
  componentId: "sc-12fiwtz-0"
@@ -253,7 +253,7 @@ StyledStep.defaultProps = {
253
253
  var COMPONENT_ID$h = 'accordions.step_inner_content';
254
254
  var StyledInnerContent = styled.div.attrs({
255
255
  'data-garden-id': COMPONENT_ID$h,
256
- 'data-garden-version': '8.49.1'
256
+ 'data-garden-version': '8.49.4'
257
257
  }).withConfig({
258
258
  displayName: "StyledInnerContent",
259
259
  componentId: "sc-1xs9fh7-0"
@@ -275,7 +275,7 @@ StyledInnerContent.defaultProps = {
275
275
  var COMPONENT_ID$g = 'accordions.stepper';
276
276
  var StyledStepper = styled.ol.attrs({
277
277
  'data-garden-id': COMPONENT_ID$g,
278
- 'data-garden-version': '8.49.1'
278
+ 'data-garden-version': '8.49.4'
279
279
  }).withConfig({
280
280
  displayName: "StyledStepper",
281
281
  componentId: "sc-dsxw0f-0"
@@ -303,7 +303,7 @@ var colorStyles$2 = function colorStyles(props) {
303
303
  };
304
304
  var StyledIcon = styled.div.attrs({
305
305
  'data-garden-id': COMPONENT_ID$f,
306
- 'data-garden-version': '8.49.1'
306
+ 'data-garden-version': '8.49.4'
307
307
  }).withConfig({
308
308
  displayName: "StyledIcon",
309
309
  componentId: "sc-v20nz9-1"
@@ -320,7 +320,7 @@ StyledIcon.defaultProps = {
320
320
  var COMPONENT_ID$e = 'accordions.step_label';
321
321
  var StyledLabel = styled.div.attrs({
322
322
  'data-garden-id': COMPONENT_ID$e,
323
- 'data-garden-version': '8.49.1'
323
+ 'data-garden-version': '8.49.4'
324
324
  }).withConfig({
325
325
  displayName: "StyledLabel",
326
326
  componentId: "sc-1o82llj-0"
@@ -348,7 +348,7 @@ StyledLabel.defaultProps = {
348
348
  var COMPONENT_ID$d = 'accordions.step_label_text';
349
349
  var StyledLabelText = styled.div.attrs({
350
350
  'data-garden-id': COMPONENT_ID$d,
351
- 'data-garden-version': '8.49.1'
351
+ 'data-garden-version': '8.49.4'
352
352
  }).withConfig({
353
353
  displayName: "StyledLabelText",
354
354
  componentId: "sc-111m5zo-0"
@@ -366,7 +366,7 @@ StyledLabelText.defaultProps = {
366
366
  var COMPONENT_ID$c = 'accordions.accordion';
367
367
  var StyledAccordion = styled.div.attrs({
368
368
  'data-garden-id': COMPONENT_ID$c,
369
- 'data-garden-version': '8.49.1'
369
+ 'data-garden-version': '8.49.4'
370
370
  }).withConfig({
371
371
  displayName: "StyledAccordion",
372
372
  componentId: "sc-niv9ic-0"
@@ -396,7 +396,7 @@ var paddingStyles = function paddingStyles(props) {
396
396
  };
397
397
  var StyledPanel = styled.section.attrs({
398
398
  'data-garden-id': COMPONENT_ID$b,
399
- 'data-garden-version': '8.49.1'
399
+ 'data-garden-version': '8.49.4'
400
400
  }).withConfig({
401
401
  displayName: "StyledPanel",
402
402
  componentId: "sc-1piryze-0"
@@ -413,7 +413,7 @@ StyledPanel.defaultProps = {
413
413
  var COMPONENT_ID$a = 'accordions.section';
414
414
  var StyledSection = styled.div.attrs({
415
415
  'data-garden-id': COMPONENT_ID$a,
416
- 'data-garden-version': '8.49.1'
416
+ 'data-garden-version': '8.49.4'
417
417
  }).withConfig({
418
418
  displayName: "StyledSection",
419
419
  componentId: "sc-v2t9bd-0"
@@ -427,7 +427,7 @@ StyledSection.defaultProps = {
427
427
  var COMPONENT_ID$9 = 'accordions.header';
428
428
  var StyledHeader = styled.div.attrs({
429
429
  'data-garden-id': COMPONENT_ID$9,
430
- 'data-garden-version': '8.49.1'
430
+ 'data-garden-version': '8.49.4'
431
431
  }).withConfig({
432
432
  displayName: "StyledHeader",
433
433
  componentId: "sc-2c6rbr-0"
@@ -455,7 +455,7 @@ var colorStyles$1 = function colorStyles(props) {
455
455
  };
456
456
  var StyledButton = styled.button.attrs({
457
457
  'data-garden-id': COMPONENT_ID$8,
458
- 'data-garden-version': '8.49.1'
458
+ 'data-garden-version': '8.49.4'
459
459
  }).withConfig({
460
460
  displayName: "StyledButton",
461
461
  componentId: "sc-xj3hy7-0"
@@ -481,7 +481,7 @@ StyledButton.defaultProps = {
481
481
  var COMPONENT_ID$7 = 'accordions.step_inner_panel';
482
482
  var StyledInnerPanel = styled.div.attrs({
483
483
  'data-garden-id': COMPONENT_ID$7,
484
- 'data-garden-version': '8.49.1'
484
+ 'data-garden-version': '8.49.4'
485
485
  }).withConfig({
486
486
  displayName: "StyledInnerPanel",
487
487
  componentId: "sc-8nbueg-0"
@@ -522,7 +522,7 @@ function (_ref) {
522
522
  return cloneElement(Children.only(children), props);
523
523
  }).attrs({
524
524
  'data-garden-id': COMPONENT_ID$6,
525
- 'data-garden-version': '8.49.1'
525
+ 'data-garden-version': '8.49.4'
526
526
  }).withConfig({
527
527
  displayName: "StyledRotateIcon",
528
528
  componentId: "sc-hp435q-0"
@@ -544,7 +544,7 @@ StyledRotateIcon.defaultProps = {
544
544
  var COMPONENT_ID$5 = 'timeline';
545
545
  var StyledTimeline = styled.ol.attrs({
546
546
  'data-garden-id': COMPONENT_ID$5,
547
- 'data-garden-version': '8.49.1'
547
+ 'data-garden-version': '8.49.4'
548
548
  }).withConfig({
549
549
  displayName: "StyledTimeline",
550
550
  componentId: "sc-pig5kv-0"
@@ -558,7 +558,7 @@ StyledTimeline.defaultProps = {
558
558
  var COMPONENT_ID$4 = 'timeline.content.separator';
559
559
  var StyledSeparator = styled.div.attrs({
560
560
  'data-garden-id': COMPONENT_ID$4,
561
- 'data-garden-version': '8.49.1'
561
+ 'data-garden-version': '8.49.4'
562
562
  }).withConfig({
563
563
  displayName: "StyledSeparator",
564
564
  componentId: "sc-fki51e-0"
@@ -576,7 +576,7 @@ StyledSeparator.defaultProps = {
576
576
  var COMPONENT_ID$3 = 'timeline.content';
577
577
  var StyledTimelineContent = styled.div.attrs({
578
578
  'data-garden-id': COMPONENT_ID$3,
579
- 'data-garden-version': '8.49.1'
579
+ 'data-garden-version': '8.49.4'
580
580
  }).withConfig({
581
581
  displayName: "StyledContent__StyledTimelineContent",
582
582
  componentId: "sc-19phgu1-0"
@@ -592,7 +592,7 @@ StyledTimelineContent.defaultProps = {
592
592
  var COMPONENT_ID$2 = 'timeline.opposite.content';
593
593
  var StyledOppositeContent = styled.div.attrs({
594
594
  'data-garden-id': COMPONENT_ID$2,
595
- 'data-garden-version': '8.49.1'
595
+ 'data-garden-version': '8.49.4'
596
596
  }).withConfig({
597
597
  displayName: "StyledOppositeContent",
598
598
  componentId: "sc-jurh2k-0"
@@ -610,7 +610,7 @@ StyledOppositeContent.defaultProps = {
610
610
  var COMPONENT_ID$1 = 'timeline.item';
611
611
  var StyledTimelineItem = styled.li.attrs({
612
612
  'data-garden-id': COMPONENT_ID$1,
613
- 'data-garden-version': '8.49.1'
613
+ 'data-garden-version': '8.49.4'
614
614
  }).withConfig({
615
615
  displayName: "StyledItem__StyledTimelineItem",
616
616
  componentId: "sc-5mcnzm-0"
@@ -634,7 +634,7 @@ var StyledItemIcon = styled(function (_ref) {
634
634
  return cloneElement(Children.only(children), props);
635
635
  }).attrs({
636
636
  'data-garden-id': COMPONENT_ID,
637
- 'data-garden-version': '8.49.1'
637
+ 'data-garden-version': '8.49.4'
638
638
  }).withConfig({
639
639
  displayName: "StyledItemIcon",
640
640
  componentId: "sc-vz2l6e-0"
@@ -718,155 +718,6 @@ var useTimelineItemContext = function useTimelineItemContext() {
718
718
  return context;
719
719
  };
720
720
 
721
- var StepComponent = forwardRef(function (props, ref) {
722
- var _useStepperContext = useStepperContext(),
723
- currentIndexRef = _useStepperContext.currentIndexRef,
724
- isHorizontal = _useStepperContext.isHorizontal;
725
- var _useState = useState(currentIndexRef.current),
726
- _useState2 = _slicedToArray(_useState, 2),
727
- currentStepIndex = _useState2[0],
728
- setIndex = _useState2[1];
729
- useLayoutEffect(function () {
730
- setIndex(currentIndexRef.current);
731
- currentIndexRef.current++;
732
- var currentIndex = currentIndexRef;
733
- return function () {
734
- currentIndex.current--;
735
- };
736
- }, [currentIndexRef]);
737
- var value = useMemo(function () {
738
- return {
739
- currentStepIndex: currentStepIndex
740
- };
741
- }, [currentStepIndex]);
742
- return React__default.createElement(StepContext.Provider, {
743
- value: value
744
- }, React__default.createElement(StyledStep, _extends$3({
745
- ref: ref,
746
- isHorizontal: isHorizontal
747
- }, props), isHorizontal && React__default.createElement(StyledLine, null), props.children));
748
- });
749
- StepComponent.displayName = 'Stepper.Step';
750
- var Step = StepComponent;
751
-
752
- var _path$1;
753
-
754
- function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
755
-
756
- var SvgCheckSmStroke = function SvgCheckSmStroke(props) {
757
- return /*#__PURE__*/React.createElement("svg", _extends$2({
758
- xmlns: "http://www.w3.org/2000/svg",
759
- width: 16,
760
- height: 16,
761
- focusable: "false",
762
- viewBox: "0 0 16 16",
763
- "aria-hidden": "true"
764
- }, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
765
- fill: "none",
766
- stroke: "currentColor",
767
- strokeLinecap: "round",
768
- strokeLinejoin: "round",
769
- strokeWidth: 1.25,
770
- d: "M3 9l3 3 7-7"
771
- })));
772
- };
773
-
774
- var LabelComponent$1 = forwardRef(function (props, ref) {
775
- var _useStepContext = useStepContext(),
776
- currentStepIndex = _useStepContext.currentStepIndex;
777
- var _useStepperContext = useStepperContext(),
778
- activeIndex = _useStepperContext.activeIndex,
779
- isHorizontal = _useStepperContext.isHorizontal;
780
- var numericStep = currentStepIndex + 1;
781
- var stepIcon = props.icon || numericStep;
782
- var isActive = activeIndex === currentStepIndex;
783
- var isCompleted = activeIndex > currentStepIndex;
784
- var styledIcon = React__default.createElement(StyledIcon, {
785
- isActive: isActive,
786
- isHorizontal: isHorizontal
787
- }, isCompleted ? React__default.createElement(SvgCheckSmStroke, null) : stepIcon);
788
- return React__default.createElement(StyledLabel, _extends$3({
789
- ref: ref,
790
- isActive: isActive,
791
- isHorizontal: isHorizontal
792
- }, props), isHorizontal ? React__default.createElement(StyledIconFlexContainer, null, styledIcon) : styledIcon, React__default.createElement(StyledLabelText, {
793
- isHidden: props.isHidden,
794
- isHorizontal: isHorizontal
795
- }, props.children));
796
- });
797
- LabelComponent$1.displayName = 'Stepper.Label';
798
- LabelComponent$1.propTypes = {
799
- icon: PropTypes.node,
800
- isHidden: PropTypes.bool
801
- };
802
- var Label$1 = LabelComponent$1;
803
-
804
- var ContentComponent$1 = forwardRef(function (props, ref) {
805
- var contentRef = useRef();
806
- var _useStepperContext = useStepperContext(),
807
- activeIndex = _useStepperContext.activeIndex,
808
- isHorizontal = _useStepperContext.isHorizontal;
809
- var _useStepContext = useStepContext(),
810
- currentStepIndex = _useStepContext.currentStepIndex;
811
- var isActive = currentStepIndex === activeIndex;
812
- var updateMaxHeight = useCallback(debounce(function () {
813
- if (contentRef.current) {
814
- var child = contentRef.current.children[0];
815
- child.style.maxHeight = "".concat(child.scrollHeight, "px");
816
- }
817
- }, 100), [contentRef]);
818
- useEffect(function () {
819
- if (isActive && isHorizontal === false) {
820
- addEventListener('resize', updateMaxHeight);
821
- updateMaxHeight();
822
- return function () {
823
- removeEventListener('resize', updateMaxHeight);
824
- };
825
- }
826
- return undefined;
827
- }, [isActive, isHorizontal, props.children, updateMaxHeight]);
828
- return isHorizontal === false ? React__default.createElement(StyledContent, _extends$3({
829
- ref: mergeRefs([contentRef, ref]),
830
- isActive: isActive
831
- }, props), React__default.createElement(StyledInnerContent, {
832
- isActive: isActive
833
- }, props.children)) : null;
834
- });
835
- ContentComponent$1.displayName = 'Stepper.Content';
836
- var Content$1 = ContentComponent$1;
837
-
838
- var _excluded$4 = ["isHorizontal", "activeIndex"];
839
- var StepperComponent = forwardRef(function (_ref, ref) {
840
- var isHorizontal = _ref.isHorizontal,
841
- activeIndex = _ref.activeIndex,
842
- props = _objectWithoutProperties(_ref, _excluded$4);
843
- var currentIndexRef = useRef(0);
844
- var stepperContext = useMemo(function () {
845
- return {
846
- isHorizontal: isHorizontal || false,
847
- activeIndex: activeIndex,
848
- currentIndexRef: currentIndexRef
849
- };
850
- }, [isHorizontal, activeIndex, currentIndexRef]);
851
- useEffect(function () {
852
- currentIndexRef.current = 0;
853
- });
854
- return React__default.createElement(StepperContext.Provider, {
855
- value: stepperContext
856
- }, React__default.createElement(StyledStepper, _extends$3({
857
- ref: ref,
858
- isHorizontal: isHorizontal
859
- }, props)));
860
- });
861
- StepperComponent.displayName = 'Stepper';
862
- StepperComponent.defaultProps = {
863
- activeIndex: 0
864
- };
865
- var Stepper = StepperComponent;
866
- Stepper.Content = Content$1;
867
- Stepper.Label = Label$1;
868
- Stepper.Step = Step;
869
-
870
721
  var SectionComponent = forwardRef(function (props, ref) {
871
722
  var _useAccordionContext = useAccordionContext(),
872
723
  currentIndexRef = _useAccordionContext.currentIndexRef;
@@ -881,25 +732,25 @@ var SectionComponent = forwardRef(function (props, ref) {
881
732
  SectionComponent.displayName = 'Accordion.Section';
882
733
  var Section = SectionComponent;
883
734
 
884
- var _path;
735
+ var _path$1;
885
736
 
886
- function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
737
+ function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
887
738
 
888
739
  var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
889
- return /*#__PURE__*/React.createElement("svg", _extends$1({
740
+ return /*#__PURE__*/React.createElement("svg", _extends$2({
890
741
  xmlns: "http://www.w3.org/2000/svg",
891
742
  width: 16,
892
743
  height: 16,
893
744
  focusable: "false",
894
745
  viewBox: "0 0 16 16",
895
746
  "aria-hidden": "true"
896
- }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
747
+ }, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
897
748
  fill: "currentColor",
898
749
  d: "M12.688 5.61a.5.5 0 01.69.718l-.066.062-5 4a.5.5 0 01-.542.054l-.082-.054-5-4a.5.5 0 01.55-.83l.074.05L8 9.359l4.688-3.75z"
899
750
  })));
900
751
  };
901
752
 
902
- var _excluded$3 = ["onClick", "onFocus", "onBlur", "onMouseOver", "onMouseOut", "children"],
753
+ var _excluded$4 = ["onClick", "onFocus", "onBlur", "onMouseOver", "onMouseOut", "children"],
903
754
  _excluded2 = ["onClick", "onKeyDown"];
904
755
  var HeaderComponent = forwardRef(function (props, ref) {
905
756
  var _useAccordionContext = useAccordionContext(),
@@ -915,7 +766,7 @@ var HeaderComponent = forwardRef(function (props, ref) {
915
766
  onMouseOver = props.onMouseOver,
916
767
  onMouseOut = props.onMouseOut,
917
768
  children = props.children,
918
- other = _objectWithoutProperties(props, _excluded$3);
769
+ other = _objectWithoutProperties(props, _excluded$4);
919
770
  var sectionIndex = useSectionContext();
920
771
  var _useState = useState(false),
921
772
  _useState2 = _slicedToArray(_useState, 2),
@@ -985,7 +836,7 @@ var HeaderComponent = forwardRef(function (props, ref) {
985
836
  HeaderComponent.displayName = 'Accordion.Header';
986
837
  var Header = HeaderComponent;
987
838
 
988
- var LabelComponent = forwardRef(function (props, ref) {
839
+ var LabelComponent$1 = forwardRef(function (props, ref) {
989
840
  var sectionIndex = useSectionContext();
990
841
  var _useAccordionContext = useAccordionContext(),
991
842
  isCompact = _useAccordionContext.isCompact,
@@ -1003,8 +854,8 @@ var LabelComponent = forwardRef(function (props, ref) {
1003
854
  isCollapsible: isCollapsible
1004
855
  }, otherTriggerProps, props));
1005
856
  });
1006
- LabelComponent.displayName = 'Accordion.Label';
1007
- var Label = LabelComponent;
857
+ LabelComponent$1.displayName = 'Accordion.Label';
858
+ var Label$1 = LabelComponent$1;
1008
859
 
1009
860
  var PanelComponent = forwardRef(function (props, ref) {
1010
861
  var _useAccordionContext = useAccordionContext(),
@@ -1048,7 +899,7 @@ var PanelComponent = forwardRef(function (props, ref) {
1048
899
  PanelComponent.displayName = 'Accordion.Panel';
1049
900
  var Panel = PanelComponent;
1050
901
 
1051
- var _excluded$2 = ["level", "isBare", "onChange", "isCompact", "isAnimated", "isExpandable", "isCollapsible", "defaultExpandedSections", "expandedSections"];
902
+ var _excluded$3 = ["level", "isBare", "onChange", "isCompact", "isAnimated", "isExpandable", "isCollapsible", "defaultExpandedSections", "expandedSections"];
1052
903
  var AccordionComponent = forwardRef(function (_ref, ref) {
1053
904
  var level = _ref.level,
1054
905
  isBare = _ref.isBare,
@@ -1059,7 +910,7 @@ var AccordionComponent = forwardRef(function (_ref, ref) {
1059
910
  isCollapsible = _ref.isCollapsible,
1060
911
  defaultExpandedSections = _ref.defaultExpandedSections,
1061
912
  controlledExpandedSections = _ref.expandedSections,
1062
- props = _objectWithoutProperties(_ref, _excluded$2);
913
+ props = _objectWithoutProperties(_ref, _excluded$3);
1063
914
  var _useAccordion = useAccordion({
1064
915
  collapsible: isCollapsible,
1065
916
  expandable: isExpandable || false,
@@ -1102,10 +953,160 @@ AccordionComponent.defaultProps = {
1102
953
  };
1103
954
  var Accordion = AccordionComponent;
1104
955
  Accordion.Header = Header;
1105
- Accordion.Label = Label;
956
+ Accordion.Label = Label$1;
1106
957
  Accordion.Panel = Panel;
1107
958
  Accordion.Section = Section;
1108
959
 
960
+ var StepComponent = forwardRef(function (props, ref) {
961
+ var _useStepperContext = useStepperContext(),
962
+ currentIndexRef = _useStepperContext.currentIndexRef,
963
+ isHorizontal = _useStepperContext.isHorizontal;
964
+ var _useState = useState(currentIndexRef.current),
965
+ _useState2 = _slicedToArray(_useState, 2),
966
+ currentStepIndex = _useState2[0],
967
+ setIndex = _useState2[1];
968
+ useLayoutEffect(function () {
969
+ setIndex(currentIndexRef.current);
970
+ currentIndexRef.current++;
971
+ var currentIndex = currentIndexRef;
972
+ return function () {
973
+ currentIndex.current--;
974
+ };
975
+ }, [currentIndexRef]);
976
+ var value = useMemo(function () {
977
+ return {
978
+ currentStepIndex: currentStepIndex
979
+ };
980
+ }, [currentStepIndex]);
981
+ return React__default.createElement(StepContext.Provider, {
982
+ value: value
983
+ }, React__default.createElement(StyledStep, _extends$3({
984
+ ref: ref,
985
+ isHorizontal: isHorizontal
986
+ }, props), isHorizontal && React__default.createElement(StyledLine, null), props.children));
987
+ });
988
+ StepComponent.displayName = 'Stepper.Step';
989
+ var Step = StepComponent;
990
+
991
+ var _path;
992
+
993
+ function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
994
+
995
+ var SvgCheckSmStroke = function SvgCheckSmStroke(props) {
996
+ return /*#__PURE__*/React.createElement("svg", _extends$1({
997
+ xmlns: "http://www.w3.org/2000/svg",
998
+ width: 16,
999
+ height: 16,
1000
+ focusable: "false",
1001
+ viewBox: "0 0 16 16",
1002
+ "aria-hidden": "true"
1003
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
1004
+ fill: "none",
1005
+ stroke: "currentColor",
1006
+ strokeLinecap: "round",
1007
+ strokeLinejoin: "round",
1008
+ strokeWidth: 1.25,
1009
+ d: "M3 9l3 3 7-7"
1010
+ })));
1011
+ };
1012
+
1013
+ var LabelComponent = forwardRef(function (props, ref) {
1014
+ var _useStepContext = useStepContext(),
1015
+ currentStepIndex = _useStepContext.currentStepIndex;
1016
+ var _useStepperContext = useStepperContext(),
1017
+ activeIndex = _useStepperContext.activeIndex,
1018
+ isHorizontal = _useStepperContext.isHorizontal;
1019
+ var numericStep = currentStepIndex + 1;
1020
+ var stepIcon = props.icon || numericStep;
1021
+ var isActive = activeIndex === currentStepIndex;
1022
+ var isCompleted = activeIndex > currentStepIndex;
1023
+ var styledIcon = React__default.createElement(StyledIcon, {
1024
+ isActive: isActive,
1025
+ isHorizontal: isHorizontal
1026
+ }, isCompleted ? React__default.createElement(SvgCheckSmStroke, null) : stepIcon);
1027
+ return React__default.createElement(StyledLabel, _extends$3({
1028
+ ref: ref,
1029
+ isActive: isActive,
1030
+ isHorizontal: isHorizontal
1031
+ }, props), isHorizontal ? React__default.createElement(StyledIconFlexContainer, null, styledIcon) : styledIcon, React__default.createElement(StyledLabelText, {
1032
+ isHidden: props.isHidden,
1033
+ isHorizontal: isHorizontal
1034
+ }, props.children));
1035
+ });
1036
+ LabelComponent.displayName = 'Stepper.Label';
1037
+ LabelComponent.propTypes = {
1038
+ icon: PropTypes.node,
1039
+ isHidden: PropTypes.bool
1040
+ };
1041
+ var Label = LabelComponent;
1042
+
1043
+ var ContentComponent$1 = forwardRef(function (props, ref) {
1044
+ var contentRef = useRef();
1045
+ var _useStepperContext = useStepperContext(),
1046
+ activeIndex = _useStepperContext.activeIndex,
1047
+ isHorizontal = _useStepperContext.isHorizontal;
1048
+ var _useStepContext = useStepContext(),
1049
+ currentStepIndex = _useStepContext.currentStepIndex;
1050
+ var isActive = currentStepIndex === activeIndex;
1051
+ var updateMaxHeight = useCallback(debounce(function () {
1052
+ if (contentRef.current) {
1053
+ var child = contentRef.current.children[0];
1054
+ child.style.maxHeight = "".concat(child.scrollHeight, "px");
1055
+ }
1056
+ }, 100), [contentRef]);
1057
+ useEffect(function () {
1058
+ if (isActive && isHorizontal === false) {
1059
+ addEventListener('resize', updateMaxHeight);
1060
+ updateMaxHeight();
1061
+ return function () {
1062
+ removeEventListener('resize', updateMaxHeight);
1063
+ };
1064
+ }
1065
+ return undefined;
1066
+ }, [isActive, isHorizontal, props.children, updateMaxHeight]);
1067
+ return isHorizontal === false ? React__default.createElement(StyledContent, _extends$3({
1068
+ ref: mergeRefs([contentRef, ref]),
1069
+ isActive: isActive
1070
+ }, props), React__default.createElement(StyledInnerContent, {
1071
+ isActive: isActive,
1072
+ "aria-hidden": !isActive
1073
+ }, props.children)) : null;
1074
+ });
1075
+ ContentComponent$1.displayName = 'Stepper.Content';
1076
+ var Content$1 = ContentComponent$1;
1077
+
1078
+ var _excluded$2 = ["isHorizontal", "activeIndex"];
1079
+ var StepperComponent = forwardRef(function (_ref, ref) {
1080
+ var isHorizontal = _ref.isHorizontal,
1081
+ activeIndex = _ref.activeIndex,
1082
+ props = _objectWithoutProperties(_ref, _excluded$2);
1083
+ var currentIndexRef = useRef(0);
1084
+ var stepperContext = useMemo(function () {
1085
+ return {
1086
+ isHorizontal: isHorizontal || false,
1087
+ activeIndex: activeIndex,
1088
+ currentIndexRef: currentIndexRef
1089
+ };
1090
+ }, [isHorizontal, activeIndex, currentIndexRef]);
1091
+ useEffect(function () {
1092
+ currentIndexRef.current = 0;
1093
+ });
1094
+ return React__default.createElement(StepperContext.Provider, {
1095
+ value: stepperContext
1096
+ }, React__default.createElement(StyledStepper, _extends$3({
1097
+ ref: ref,
1098
+ isHorizontal: isHorizontal
1099
+ }, props)));
1100
+ });
1101
+ StepperComponent.displayName = 'Stepper';
1102
+ StepperComponent.defaultProps = {
1103
+ activeIndex: 0
1104
+ };
1105
+ var Stepper = StepperComponent;
1106
+ Stepper.Content = Content$1;
1107
+ Stepper.Label = Label;
1108
+ Stepper.Step = Step;
1109
+
1109
1110
  var OppositeContentComponent = forwardRef(function (props, ref) {
1110
1111
  return React__default.createElement(StyledOppositeContent, _extends$3({
1111
1112
  ref: ref
@@ -4,35 +4,12 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import React, { HTMLAttributes } from 'react';
7
+ import React from 'react';
8
+ import { IAccordionProps } from '../../types';
8
9
  import { Section } from '../accordion/components/Section';
9
10
  import { Header } from '../accordion/components/Header';
10
11
  import { Label } from '../accordion/components/Label';
11
12
  import { Panel } from '../accordion/components/Panel';
12
- export interface IAccordionProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
13
- /** Sets `aria-level` heading rank in the document structure */
14
- level: number;
15
- /** Sets the expanded sections in a controlled accordion */
16
- expandedSections?: number[];
17
- /** Sets the default expanded sections in an uncontrolled accordion */
18
- defaultExpandedSections?: number[];
19
- /** Hides section borders */
20
- isBare?: boolean;
21
- /** Allows uncontrolled accordion sections to collapse */
22
- isCollapsible?: boolean;
23
- /** Applies compact styling */
24
- isCompact?: boolean;
25
- /** Animates section expansion and collapse */
26
- isAnimated?: boolean;
27
- /** Enables simultaneous expansion of uncontrolled accordion sections */
28
- isExpandable?: boolean;
29
- /**
30
- * Handles accordion expansion changes
31
- *
32
- * @param {number} index A section index
33
- */
34
- onChange?: (index: number) => void;
35
- }
36
13
  /**
37
14
  * @extends HTMLAttributes<HTMLDivElement>
38
15
  */
@@ -4,16 +4,11 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import React, { OlHTMLAttributes } from 'react';
7
+ import React from 'react';
8
+ import { IStepperProps } from '../../types';
8
9
  import { Step } from './components/Step';
9
10
  import { Label } from './components/Label';
10
11
  import { Content } from './components/Content';
11
- export interface IStepperProps extends OlHTMLAttributes<HTMLOListElement> {
12
- /** Defines the currently active step, starting at 0 */
13
- activeIndex?: number;
14
- /** Applies horizontal layout styling */
15
- isHorizontal?: boolean;
16
- }
17
12
  /**
18
13
  * @extends OlHTMLAttributes<HTMLOListElement>
19
14
  */
@@ -4,13 +4,8 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import React, { HTMLAttributes } from 'react';
8
- export interface IStepperLabelProps extends HTMLAttributes<HTMLDivElement> {
9
- /** Replaces the label number with an icon */
10
- icon?: React.ReactNode;
11
- /** Hides the label text */
12
- isHidden?: boolean;
13
- }
7
+ import React from 'react';
8
+ import { IStepperLabelProps } from '../../../types';
14
9
  /**
15
10
  * @extends HTMLAttributes<HTMLDivElement>
16
11
  */
@@ -4,14 +4,11 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import React, { OlHTMLAttributes } from 'react';
7
+ import React from 'react';
8
+ import { ITimelineProps } from '../../types';
8
9
  import { Item } from '../timeline/components/Item';
9
10
  import { Content } from '../timeline/components/Content';
10
11
  import { OppositeContent } from '../timeline/components/OppositeContent';
11
- export interface ITimelineProps extends Omit<OlHTMLAttributes<HTMLOListElement>, 'onChange'> {
12
- /** Applies alternate styling */
13
- isAlternate?: boolean;
14
- }
15
12
  /**
16
13
  * @extends OlHTMLAttributes<HTMLOListElement>
17
14
  */