@thecb/components 9.0.3-beta.4 → 9.0.3-beta.6

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
@@ -27219,7 +27219,11 @@ var RadioButton$1 = function RadioButton(_ref2) {
27219
27219
  disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
27220
27220
  _ref2$ariaDescribedBy = _ref2.ariaDescribedBy,
27221
27221
  ariaDescribedBy = _ref2$ariaDescribedBy === void 0 ? "" : _ref2$ariaDescribedBy,
27222
- themeValues = _ref2.themeValues;
27222
+ themeValues = _ref2.themeValues,
27223
+ _ref2$ariaLabelledBy = _ref2.ariaLabelledBy,
27224
+ ariaLabelledBy = _ref2$ariaLabelledBy === void 0 ? "" : _ref2$ariaLabelledBy,
27225
+ _ref2$ariaLabel = _ref2.ariaLabel,
27226
+ ariaLabel = _ref2$ariaLabel === void 0 ? null : _ref2$ariaLabel;
27223
27227
  var buttonBorder = {
27224
27228
  onFocused: {
27225
27229
  borderColor: themeValues.activeColor,
@@ -27260,20 +27264,27 @@ var RadioButton$1 = function RadioButton(_ref2) {
27260
27264
  width: "0px"
27261
27265
  }
27262
27266
  };
27267
+ var extraProps = {};
27268
+
27269
+ if (ariaLabelledBy && ariaLabelledBy.length) {
27270
+ extraProps["aria-labelledby"] = ariaLabelledBy;
27271
+ } else if (ariaLabel && ariaLabel !== null) {
27272
+ extraProps["aria-label"] = ariaLabel;
27273
+ }
27274
+
27263
27275
  return /*#__PURE__*/React__default.createElement(Motion, {
27264
27276
  position: "relative",
27265
27277
  padding: "0",
27266
27278
  initial: "off",
27267
27279
  animate: radioOn ? radioFocused ? "onFocused" : "on" : radioFocused ? "offFocused" : "off"
27268
- }, /*#__PURE__*/React__default.createElement(HiddenRadioButton, {
27269
- id: "radio-".concat(name),
27280
+ }, /*#__PURE__*/React__default.createElement(HiddenRadioButton, _extends({
27270
27281
  type: "radio",
27271
- "aria-disabled": disabled,
27282
+ id: "radio-".concat(name),
27272
27283
  disabled: disabled,
27273
27284
  onClick: toggleRadio,
27274
27285
  "aria-describedby": ariaDescribedBy,
27275
27286
  tabIndex: "-1"
27276
- }), /*#__PURE__*/React__default.createElement(Motion, {
27287
+ }, extraProps)), /*#__PURE__*/React__default.createElement(Motion, {
27277
27288
  borderWidth: "1px",
27278
27289
  borderStyle: "solid",
27279
27290
  borderRadius: "12px",
@@ -45784,8 +45795,6 @@ var Module = function Module(_ref) {
45784
45795
  spacingBottom = _ref$spacingBottom === void 0 ? "2.5rem" : _ref$spacingBottom,
45785
45796
  fontSize = _ref.fontSize,
45786
45797
  themeValues = _ref.themeValues,
45787
- _ref$ariaRole = _ref.ariaRole,
45788
- ariaRole = _ref$ariaRole === void 0 ? null : _ref$ariaRole,
45789
45798
  children = _ref.children;
45790
45799
  var themedFontSize = variant === "small" ? "1.25rem" : variant === "default" ? "1.375rem" : "2rem";
45791
45800
  var computedFontSize = fontSize || themedFontSize;
@@ -45801,13 +45810,12 @@ var Module = function Module(_ref) {
45801
45810
  extraStyles: "font-size: ".concat(computedFontSize, ";"),
45802
45811
  id: titleID
45803
45812
  }, heading);
45804
- return /*#__PURE__*/React__default.createElement(Box, _extends({
45813
+ return /*#__PURE__*/React__default.createElement(Box, {
45805
45814
  "aria-disabled": disabled,
45806
45815
  extraStyles: disabled && disabledStyles,
45807
- padding: "0"
45808
- }, ariaRole ? {
45809
- role: ariaRole
45810
- } : {}), heading && !rightTitleContent && headingText, heading && rightTitleContent && /*#__PURE__*/React__default.createElement(Cluster, {
45816
+ padding: "0",
45817
+ role: "group"
45818
+ }, heading && !rightTitleContent && headingText, heading && rightTitleContent && /*#__PURE__*/React__default.createElement(Cluster, {
45811
45819
  justify: "space-between",
45812
45820
  align: "center",
45813
45821
  nowrap: true
@@ -48478,6 +48486,10 @@ var fallbackValues$Q = {
48478
48486
 
48479
48487
  */
48480
48488
 
48489
+ var computeSectionId = function computeSectionId(section) {
48490
+ return typeof section.title === "string" ? createIdFromString(section.title) : section.id;
48491
+ };
48492
+
48481
48493
  var RadioSection = function RadioSection(_ref) {
48482
48494
  var themeValues = _ref.themeValues,
48483
48495
  isMobile = _ref.isMobile,
@@ -48496,11 +48508,10 @@ var RadioSection = function RadioSection(_ref) {
48496
48508
  _ref$containerStyles = _ref.containerStyles,
48497
48509
  containerStyles = _ref$containerStyles === void 0 ? "" : _ref$containerStyles,
48498
48510
  ariaDescribedBy = _ref.ariaDescribedBy,
48499
- _ref$groupLabel = _ref.groupLabel;
48511
+ _ref$rightContentRole = _ref.rightContentRole,
48512
+ rightContentRole = _ref$rightContentRole === void 0 ? null : _ref$rightContentRole;
48500
48513
 
48501
48514
  var handleKeyDown = function handleKeyDown(id, e) {
48502
- // The expected keyboard shortcut for activating a radio is the Space key
48503
- // Below covers both Enter or Space key presses
48504
48515
  if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13 || (e === null || e === void 0 ? void 0 : e.keyCode) === 32) {
48505
48516
  toggleOpenSection(id);
48506
48517
  }
@@ -48547,18 +48558,14 @@ var RadioSection = function RadioSection(_ref) {
48547
48558
  focused = _useState2[0],
48548
48559
  setFocused = _useState2[1];
48549
48560
 
48550
- var computeId = function computeId(string) {
48551
- var fallbackString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
48552
- return typeof string === "string" ? createIdFromString(string) : fallbackString;
48553
- };
48554
-
48555
48561
  return /*#__PURE__*/React__default.createElement(Box, {
48556
48562
  padding: "1px",
48557
48563
  border: "1px solid ".concat(themeValues.borderColor),
48558
48564
  borderRadius: "4px",
48559
48565
  extraStyles: containerStyles
48560
48566
  }, /*#__PURE__*/React__default.createElement(Stack, {
48561
- childGap: "0"
48567
+ childGap: "0",
48568
+ role: "radiogroup"
48562
48569
  }, sections.filter(function (section) {
48563
48570
  return !section.hidden;
48564
48571
  }).map(function (section) {
@@ -48578,12 +48585,8 @@ var RadioSection = function RadioSection(_ref) {
48578
48585
  initial: initiallyOpen ? "open" : "closed",
48579
48586
  key: "item-".concat(section.id),
48580
48587
  extraStyles: borderStyles,
48581
- disabled: section.disabled,
48582
- "aria-disabled": section.disabled,
48583
48588
  role: "radio",
48584
- "aria-checked": !section.disabled && openSection === section.id,
48585
- "aria-labelledby": computeId(section.title, section.id),
48586
- id: createIdFromString(typeof section.title === "string" ? section.title : section.id)
48589
+ "aria-checked": openSection === section.id
48587
48590
  }, /*#__PURE__*/React__default.createElement(Stack, {
48588
48591
  childGap: "0"
48589
48592
  }, /*#__PURE__*/React__default.createElement(Box, {
@@ -48613,32 +48616,36 @@ var RadioSection = function RadioSection(_ref) {
48613
48616
  }, !section.hideRadioButton && /*#__PURE__*/React__default.createElement(Box, {
48614
48617
  padding: "0"
48615
48618
  }, /*#__PURE__*/React__default.createElement(RadioButton$2, {
48616
- id: computeId(section.title, section.id),
48617
- name: computeId(section.title, section.id),
48619
+ id: computeSectionId(section),
48620
+ name: computeSectionId(section),
48618
48621
  ariaDescribedBy: ariaDescribedBy,
48622
+ ariaLabelledBy: "radio-input-".concat(computeSectionId(section)),
48619
48623
  radioOn: openSection === section.id,
48620
48624
  radioFocused: focused === section.id,
48621
48625
  toggleRadio: section.disabled ? noop : function () {
48622
48626
  return toggleOpenSection(section.id);
48623
- }
48627
+ },
48628
+ tabIndex: "-1"
48624
48629
  })), section.titleIcon && /*#__PURE__*/React__default.createElement(Cluster, {
48625
48630
  align: "center"
48626
48631
  }, section.titleIcon), /*#__PURE__*/React__default.createElement(Box, {
48627
48632
  padding: section.titleIcon ? "0 0 0 8px" : "0"
48628
48633
  }, /*#__PURE__*/React__default.createElement(Text$1, {
48629
48634
  as: "label",
48630
- htmlFor: computeId(section.title, section.id),
48631
- color: CHARADE_GREY
48635
+ color: CHARADE_GREY,
48636
+ htmlFor: "radio-input-".concat(computeSectionId(section))
48632
48637
  }, section.title))), section.rightIcons && /*#__PURE__*/React__default.createElement(Cluster, {
48633
48638
  childGap: "0.5rem"
48634
48639
  }, section.rightIcons.map(function (icon) {
48635
- return /*#__PURE__*/React__default.createElement(RightIcon, {
48640
+ return /*#__PURE__*/React__default.createElement(RightIcon, _extends({
48636
48641
  src: icon.img,
48637
48642
  key: icon.img,
48638
48643
  fade: !icon.enabled,
48639
48644
  isMobile: isMobile,
48640
48645
  alt: icon.altText
48641
- });
48646
+ }, rightContentRole !== null ? {
48647
+ role: rightContentRole || "presentation"
48648
+ } : {}));
48642
48649
  })), section.rightTitleContent && /*#__PURE__*/React__default.createElement(React.Fragment, null, section.rightTitleContent))), /*#__PURE__*/React__default.createElement(AnimatePresence, {
48643
48650
  initial: false
48644
48651
  }, openSection === section.id && /*#__PURE__*/React__default.createElement(Motion, {