@thecb/components 9.3.1-beta.1 → 9.3.1-beta.10

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.cjs.js CHANGED
@@ -48670,6 +48670,8 @@ var idString = function idString(section) {
48670
48670
  };
48671
48671
 
48672
48672
  var RadioSection = function RadioSection(_ref) {
48673
+ var _sections$;
48674
+
48673
48675
  var themeValues = _ref.themeValues,
48674
48676
  isMobile = _ref.isMobile,
48675
48677
  supportsTouch = _ref.supportsTouch,
@@ -48688,8 +48690,8 @@ var RadioSection = function RadioSection(_ref) {
48688
48690
  containerStyles = _ref$containerStyles === void 0 ? "" : _ref$containerStyles,
48689
48691
  ariaDescribedBy = _ref.ariaDescribedBy,
48690
48692
  _ref$isSectionRequire = _ref.isSectionRequired,
48691
- isSectionRequired = _ref$isSectionRequire === void 0 ? false : _ref$isSectionRequire,
48692
- _ref$legendText = _ref.legendText;
48693
+ isSectionRequired = _ref$isSectionRequire === void 0 ? false : _ref$isSectionRequire;
48694
+ var areSectionsGrouped = typeof (sections === null || sections === void 0 ? void 0 : (_sections$ = sections[0]) === null || _sections$ === void 0 ? void 0 : _sections$[0]) !== "undefined";
48693
48695
 
48694
48696
  var handleKeyDown = function handleKeyDown(id, e) {
48695
48697
  if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13 || (e === null || e === void 0 ? void 0 : e.keyCode) === 32) {
@@ -48744,18 +48746,10 @@ var RadioSection = function RadioSection(_ref) {
48744
48746
  borderRadius: "4px",
48745
48747
  extraStyles: containerStyles
48746
48748
  }, /*#__PURE__*/React__default.createElement(Stack, {
48747
- childGap: "0"
48748
- }, /*#__PURE__*/React__default.createElement("fieldset", {
48749
+ childGap: "0",
48749
48750
  role: "radiogroup",
48750
- tabIndex: "0",
48751
- required: isSectionRequired
48752
- }, /*#__PURE__*/React__default.createElement("legend", null, /*#__PURE__*/React__default.createElement(Box, {
48753
- width: "0",
48754
- srOnly: true,
48755
- border: "0",
48756
- padding: "0",
48757
- margin: "0"
48758
- })), sections.filter(function (section) {
48751
+ "aria-required": isSectionRequired
48752
+ }, !areSectionsGrouped && sections.filter(function (section) {
48759
48753
  return !section.hidden;
48760
48754
  }).map(function (section) {
48761
48755
  return /*#__PURE__*/React__default.createElement(Motion, {
@@ -48772,7 +48766,7 @@ var RadioSection = function RadioSection(_ref) {
48772
48766
  hoverStyles: themeValues.focusStyles,
48773
48767
  animate: openSection === section.id ? "open" : "closed",
48774
48768
  initial: initiallyOpen ? "open" : "closed",
48775
- key: "item-".concat(section.id),
48769
+ key: "item-".concat(sections.indexOf(section)),
48776
48770
  extraStyles: borderStyles,
48777
48771
  role: "radio",
48778
48772
  "aria-checked": openSection === section.id,
@@ -48815,6 +48809,7 @@ var RadioSection = function RadioSection(_ref) {
48815
48809
  toggleRadio: section.disabled ? noop : function () {
48816
48810
  return toggleOpenSection(section.id);
48817
48811
  },
48812
+ tabIndex: "-1",
48818
48813
  isRequired: section === null || section === void 0 ? void 0 : section.required
48819
48814
  })), section.titleIcon && /*#__PURE__*/React__default.createElement(Cluster, {
48820
48815
  align: "center"
@@ -48850,7 +48845,108 @@ var RadioSection = function RadioSection(_ref) {
48850
48845
  variants: wrapper,
48851
48846
  extraStyles: "transform-origin: 100% 0;"
48852
48847
  }, section.content))));
48853
- }))));
48848
+ }), areSectionsGrouped && sections.map(function (sectionGroup) {
48849
+ return sectionGroup.filter(function (section) {
48850
+ return !section.hidden;
48851
+ }).map(function (section) {
48852
+ return /*#__PURE__*/React__default.createElement(Motion, {
48853
+ tabIndex: section.hideRadioButton || section.disabled ? "-1" : "0",
48854
+ onKeyDown: function onKeyDown(e) {
48855
+ return !section.disabled && handleKeyDown(section.id, e);
48856
+ },
48857
+ onFocus: function onFocus() {
48858
+ return !section.disabled && setFocused(section.id);
48859
+ },
48860
+ onBlur: function onBlur() {
48861
+ return !section.disabled && setFocused(null);
48862
+ },
48863
+ hoverStyles: themeValues.focusStyles,
48864
+ animate: openSection === section.id ? "open" : "closed",
48865
+ initial: initiallyOpen ? "open" : "closed",
48866
+ key: "item-".concat(sections.indexOf(sectionGroup), "-").concat(sectionGroup.indexOf(section)),
48867
+ extraStyles: borderStyles,
48868
+ role: "radio",
48869
+ "aria-checked": openSection === section.id,
48870
+ "aria-disabled": section.disabled,
48871
+ "aria-required": section === null || section === void 0 ? void 0 : section.required
48872
+ }, /*#__PURE__*/React__default.createElement(Stack, {
48873
+ childGap: "0"
48874
+ }, /*#__PURE__*/React__default.createElement(Box, {
48875
+ padding: section.hideRadioButton ? "1.5rem" : "1.25rem 1.5rem",
48876
+ background: section.disabled ? themeValues.headingDisabledColor : themeValues.headingBackgroundColor,
48877
+ onClick: isMobile && supportsTouch || section.disabled ? noop : function () {
48878
+ return toggleOpenSection(section.id);
48879
+ },
48880
+ onTouchEnd: isMobile && supportsTouch && !section.disabled ? function () {
48881
+ return toggleOpenSection(section.id);
48882
+ } : noop,
48883
+ key: "header-".concat(section.id),
48884
+ borderSize: "0px",
48885
+ borderColor: themeValues.borderColor,
48886
+ borderWidthOverride: openSection === section.id && !!section.content ? "0px 0px 1px 0px" : "",
48887
+ extraStyles: !section.disabled ? "cursor: pointer;" : "",
48888
+ dataQa: section.dataQa ? section.dataQa : section.id
48889
+ }, /*#__PURE__*/React__default.createElement(Cluster, {
48890
+ justify: "space-between",
48891
+ align: "center",
48892
+ childGap: "1px",
48893
+ nowrap: true
48894
+ }, /*#__PURE__*/React__default.createElement(Cluster, {
48895
+ justify: "flex-start",
48896
+ align: "center",
48897
+ nowrap: true
48898
+ }, !section.hideRadioButton && /*#__PURE__*/React__default.createElement(Box, {
48899
+ padding: "0"
48900
+ }, /*#__PURE__*/React__default.createElement(RadioButton$2, {
48901
+ id: "radio-input-".concat(idString(section)),
48902
+ name: idString(section),
48903
+ ariaDescribedBy: ariaDescribedBy,
48904
+ radioOn: openSection === section.id,
48905
+ radioFocused: focused === section.id,
48906
+ toggleRadio: section.disabled ? noop : function () {
48907
+ return toggleOpenSection(section.id);
48908
+ },
48909
+ tabIndex: "-1",
48910
+ isRequired: section === null || section === void 0 ? void 0 : section.required
48911
+ })), section.titleIcon && /*#__PURE__*/React__default.createElement(Cluster, {
48912
+ align: "center"
48913
+ }, section.titleIcon), /*#__PURE__*/React__default.createElement(Box, {
48914
+ padding: section.titleIcon ? "0 0 0 8px" : "0"
48915
+ }, /*#__PURE__*/React__default.createElement(Text$1, {
48916
+ as: "label",
48917
+ htmlFor: "radio-input-".concat(idString(section)),
48918
+ color: CHARADE_GREY
48919
+ }, section.title))), section.rightIcons && /*#__PURE__*/React__default.createElement(Cluster, {
48920
+ childGap: "0.5rem",
48921
+ "aria-label": (section === null || section === void 0 ? void 0 : section.rightIconsLabel) || null,
48922
+ role: (section === null || section === void 0 ? void 0 : section.rightIconsRole) || null
48923
+ }, section.rightIcons.map(function (icon) {
48924
+ return /*#__PURE__*/React__default.createElement(RightIcon, {
48925
+ src: icon.img,
48926
+ key: icon.img,
48927
+ fade: !icon.enabled,
48928
+ isMobile: isMobile,
48929
+ alt: icon.altText,
48930
+ "aria-disabled": !icon.enabled
48931
+ });
48932
+ })), section.rightTitleContent && /*#__PURE__*/React__default.createElement(React.Fragment, null, section.rightTitleContent))), /*#__PURE__*/React__default.createElement(AnimatePresence, {
48933
+ initial: false
48934
+ }, openSection === section.id && /*#__PURE__*/React__default.createElement(Motion, {
48935
+ key: "content-".concat(section.id),
48936
+ padding: "0",
48937
+ background: themeValues.bodyBackgroundColor,
48938
+ layoutTransition: true,
48939
+ initial: "closed",
48940
+ animate: "open",
48941
+ exit: "closed",
48942
+ variants: wrapper,
48943
+ extraStyles: "transform-origin: 100% 0;"
48944
+ }, section.content))), sections.indexOf(sectionGroup) !== sections.length - 1 && sectionGroup.indexOf(section) === sectionGroup.length - 1 && /*#__PURE__*/React__default.createElement(SolidDivider$1, {
48945
+ borderSize: "2px",
48946
+ borderColor: themeValues.borderColor
48947
+ }));
48948
+ });
48949
+ })));
48854
48950
  };
48855
48951
 
48856
48952
  var RadioSection$1 = themeComponent(RadioSection, "RadioSection", fallbackValues$Q);