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

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,
@@ -48495,12 +48507,9 @@ var RadioSection = function RadioSection(_ref) {
48495
48507
  openHeight = _ref$openHeight === void 0 ? "auto" : _ref$openHeight,
48496
48508
  _ref$containerStyles = _ref.containerStyles,
48497
48509
  containerStyles = _ref$containerStyles === void 0 ? "" : _ref$containerStyles,
48498
- ariaDescribedBy = _ref.ariaDescribedBy,
48499
- _ref$groupLabel = _ref.groupLabel;
48510
+ ariaDescribedBy = _ref.ariaDescribedBy;
48500
48511
 
48501
48512
  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
48513
  if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13 || (e === null || e === void 0 ? void 0 : e.keyCode) === 32) {
48505
48514
  toggleOpenSection(id);
48506
48515
  }
@@ -48547,18 +48556,14 @@ var RadioSection = function RadioSection(_ref) {
48547
48556
  focused = _useState2[0],
48548
48557
  setFocused = _useState2[1];
48549
48558
 
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
48559
  return /*#__PURE__*/React__default.createElement(Box, {
48556
48560
  padding: "1px",
48557
48561
  border: "1px solid ".concat(themeValues.borderColor),
48558
48562
  borderRadius: "4px",
48559
48563
  extraStyles: containerStyles
48560
48564
  }, /*#__PURE__*/React__default.createElement(Stack, {
48561
- childGap: "0"
48565
+ childGap: "0",
48566
+ role: "radiogroup"
48562
48567
  }, sections.filter(function (section) {
48563
48568
  return !section.hidden;
48564
48569
  }).map(function (section) {
@@ -48578,12 +48583,8 @@ var RadioSection = function RadioSection(_ref) {
48578
48583
  initial: initiallyOpen ? "open" : "closed",
48579
48584
  key: "item-".concat(section.id),
48580
48585
  extraStyles: borderStyles,
48581
- disabled: section.disabled,
48582
- "aria-disabled": section.disabled,
48583
48586
  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)
48587
+ "aria-checked": openSection === section.id
48587
48588
  }, /*#__PURE__*/React__default.createElement(Stack, {
48588
48589
  childGap: "0"
48589
48590
  }, /*#__PURE__*/React__default.createElement(Box, {
@@ -48613,22 +48614,24 @@ var RadioSection = function RadioSection(_ref) {
48613
48614
  }, !section.hideRadioButton && /*#__PURE__*/React__default.createElement(Box, {
48614
48615
  padding: "0"
48615
48616
  }, /*#__PURE__*/React__default.createElement(RadioButton$2, {
48616
- id: computeId(section.title, section.id),
48617
- name: computeId(section.title, section.id),
48617
+ id: computeSectionId(section),
48618
+ name: computeSectionId(section),
48618
48619
  ariaDescribedBy: ariaDescribedBy,
48620
+ ariaLabelledBy: "radio-input-".concat(computeSectionId(section)),
48619
48621
  radioOn: openSection === section.id,
48620
48622
  radioFocused: focused === section.id,
48621
48623
  toggleRadio: section.disabled ? noop : function () {
48622
48624
  return toggleOpenSection(section.id);
48623
- }
48625
+ },
48626
+ tabIndex: "-1"
48624
48627
  })), section.titleIcon && /*#__PURE__*/React__default.createElement(Cluster, {
48625
48628
  align: "center"
48626
48629
  }, section.titleIcon), /*#__PURE__*/React__default.createElement(Box, {
48627
48630
  padding: section.titleIcon ? "0 0 0 8px" : "0"
48628
48631
  }, /*#__PURE__*/React__default.createElement(Text$1, {
48629
48632
  as: "label",
48630
- htmlFor: computeId(section.title, section.id),
48631
- color: CHARADE_GREY
48633
+ color: CHARADE_GREY,
48634
+ htmlFor: "radio-input-".concat(computeSectionId(section))
48632
48635
  }, section.title))), section.rightIcons && /*#__PURE__*/React__default.createElement(Cluster, {
48633
48636
  childGap: "0.5rem"
48634
48637
  }, section.rightIcons.map(function (icon) {