@thecb/components 9.0.2 → 9.0.3-beta.11

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
@@ -27211,7 +27211,11 @@ var RadioButton$1 = function RadioButton(_ref2) {
27211
27211
  disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
27212
27212
  _ref2$ariaDescribedBy = _ref2.ariaDescribedBy,
27213
27213
  ariaDescribedBy = _ref2$ariaDescribedBy === void 0 ? "" : _ref2$ariaDescribedBy,
27214
- themeValues = _ref2.themeValues;
27214
+ themeValues = _ref2.themeValues,
27215
+ _ref2$ariaLabelledBy = _ref2.ariaLabelledBy,
27216
+ ariaLabelledBy = _ref2$ariaLabelledBy === void 0 ? "" : _ref2$ariaLabelledBy,
27217
+ _ref2$ariaLabel = _ref2.ariaLabel,
27218
+ ariaLabel = _ref2$ariaLabel === void 0 ? null : _ref2$ariaLabel;
27215
27219
  var buttonBorder = {
27216
27220
  onFocused: {
27217
27221
  borderColor: themeValues.activeColor,
@@ -27252,19 +27256,27 @@ var RadioButton$1 = function RadioButton(_ref2) {
27252
27256
  width: "0px"
27253
27257
  }
27254
27258
  };
27259
+ var extraProps = {};
27260
+
27261
+ if (ariaLabelledBy && ariaLabelledBy.length) {
27262
+ extraProps["aria-labelledby"] = ariaLabelledBy;
27263
+ } else if (ariaLabel && ariaLabel !== null) {
27264
+ extraProps["aria-label"] = ariaLabel;
27265
+ }
27266
+
27255
27267
  return /*#__PURE__*/React.createElement(Motion, {
27256
27268
  position: "relative",
27257
27269
  padding: "0",
27258
27270
  initial: "off",
27259
27271
  animate: radioOn ? radioFocused ? "onFocused" : "on" : radioFocused ? "offFocused" : "off"
27260
- }, /*#__PURE__*/React.createElement(HiddenRadioButton, {
27261
- id: "#radio-".concat(name),
27262
- "aria-label": name,
27272
+ }, /*#__PURE__*/React.createElement(HiddenRadioButton, _extends({
27273
+ type: "radio",
27274
+ id: "radio-".concat(name),
27263
27275
  disabled: disabled,
27264
27276
  onClick: toggleRadio,
27265
27277
  "aria-describedby": ariaDescribedBy,
27266
27278
  tabIndex: "-1"
27267
- }), /*#__PURE__*/React.createElement(Motion, {
27279
+ }, extraProps)), /*#__PURE__*/React.createElement(Motion, {
27268
27280
  borderWidth: "1px",
27269
27281
  borderStyle: "solid",
27270
27282
  borderRadius: "12px",
@@ -48466,6 +48478,10 @@ var fallbackValues$Q = {
48466
48478
 
48467
48479
  */
48468
48480
 
48481
+ var computeSectionId = function computeSectionId(section) {
48482
+ return typeof section.title === "string" ? createIdFromString(section.title) : section.id;
48483
+ };
48484
+
48469
48485
  var RadioSection = function RadioSection(_ref) {
48470
48486
  var themeValues = _ref.themeValues,
48471
48487
  isMobile = _ref.isMobile,
@@ -48483,10 +48499,12 @@ var RadioSection = function RadioSection(_ref) {
48483
48499
  openHeight = _ref$openHeight === void 0 ? "auto" : _ref$openHeight,
48484
48500
  _ref$containerStyles = _ref.containerStyles,
48485
48501
  containerStyles = _ref$containerStyles === void 0 ? "" : _ref$containerStyles,
48486
- ariaDescribedBy = _ref.ariaDescribedBy;
48502
+ ariaDescribedBy = _ref.ariaDescribedBy,
48503
+ _ref$rightIconsLabel = _ref.rightIconsLabel,
48504
+ rightIconsLabel = _ref$rightIconsLabel === void 0 ? null : _ref$rightIconsLabel;
48487
48505
 
48488
48506
  var handleKeyDown = function handleKeyDown(id, e) {
48489
- if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13) {
48507
+ if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13 || (e === null || e === void 0 ? void 0 : e.keyCode) === 32) {
48490
48508
  toggleOpenSection(id);
48491
48509
  }
48492
48510
  };
@@ -48538,7 +48556,8 @@ var RadioSection = function RadioSection(_ref) {
48538
48556
  borderRadius: "4px",
48539
48557
  extraStyles: containerStyles
48540
48558
  }, /*#__PURE__*/React.createElement(Stack, {
48541
- childGap: "0"
48559
+ childGap: "0",
48560
+ role: "radiogroup"
48542
48561
  }, sections.filter(function (section) {
48543
48562
  return !section.hidden;
48544
48563
  }).map(function (section) {
@@ -48557,7 +48576,9 @@ var RadioSection = function RadioSection(_ref) {
48557
48576
  animate: openSection === section.id ? "open" : "closed",
48558
48577
  initial: initiallyOpen ? "open" : "closed",
48559
48578
  key: "item-".concat(section.id),
48560
- extraStyles: borderStyles
48579
+ extraStyles: borderStyles,
48580
+ role: "radio",
48581
+ "aria-checked": openSection === section.id
48561
48582
  }, /*#__PURE__*/React.createElement(Stack, {
48562
48583
  childGap: "0"
48563
48584
  }, /*#__PURE__*/React.createElement(Box, {
@@ -48587,8 +48608,10 @@ var RadioSection = function RadioSection(_ref) {
48587
48608
  }, !section.hideRadioButton && /*#__PURE__*/React.createElement(Box, {
48588
48609
  padding: "0"
48589
48610
  }, /*#__PURE__*/React.createElement(RadioButton$2, {
48590
- name: typeof section.title === "string" ? createIdFromString(section.title) : section.id,
48611
+ id: computeSectionId(section),
48612
+ name: computeSectionId(section),
48591
48613
  ariaDescribedBy: ariaDescribedBy,
48614
+ ariaLabelledBy: "radio-input-".concat(computeSectionId(section)),
48592
48615
  radioOn: openSection === section.id,
48593
48616
  radioFocused: focused === section.id,
48594
48617
  toggleRadio: section.disabled ? noop : function () {
@@ -48600,11 +48623,14 @@ var RadioSection = function RadioSection(_ref) {
48600
48623
  }, section.titleIcon), /*#__PURE__*/React.createElement(Box, {
48601
48624
  padding: section.titleIcon ? "0 0 0 8px" : "0"
48602
48625
  }, /*#__PURE__*/React.createElement(Text$1, {
48603
- variant: "p",
48604
- color: CHARADE_GREY
48605
- }, section.title))), section.rightIcons && /*#__PURE__*/React.createElement(Cluster, {
48626
+ as: "label",
48627
+ color: CHARADE_GREY,
48628
+ htmlFor: "radio-input-".concat(computeSectionId(section))
48629
+ }, section.title))), section.rightIcons && /*#__PURE__*/React.createElement(Cluster, _extends({
48606
48630
  childGap: "0.5rem"
48607
- }, section.rightIcons.map(function (icon) {
48631
+ }, rightIconsLabel !== null ? {
48632
+ "aria-label": rightIconsLabel
48633
+ } : {}), section.rightIcons.map(function (icon) {
48608
48634
  return /*#__PURE__*/React.createElement(RightIcon, {
48609
48635
  src: icon.img,
48610
48636
  key: icon.img,