@thecb/components 9.0.2-beta.0 → 9.0.3-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
@@ -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,19 +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),
27270
- "aria-label": name,
27280
+ }, /*#__PURE__*/React__default.createElement(HiddenRadioButton, _extends({
27281
+ type: "radio",
27282
+ id: "radio-".concat(name),
27271
27283
  disabled: disabled,
27272
27284
  onClick: toggleRadio,
27273
27285
  "aria-describedby": ariaDescribedBy,
27274
27286
  tabIndex: "-1"
27275
- }), /*#__PURE__*/React__default.createElement(Motion, {
27287
+ }, extraProps)), /*#__PURE__*/React__default.createElement(Motion, {
27276
27288
  borderWidth: "1px",
27277
27289
  borderStyle: "solid",
27278
27290
  borderRadius: "12px",
@@ -48474,6 +48486,10 @@ var fallbackValues$Q = {
48474
48486
 
48475
48487
  */
48476
48488
 
48489
+ var computeSectionId = function computeSectionId(section) {
48490
+ return typeof section.title === "string" ? createIdFromString(section.title) : section.id;
48491
+ };
48492
+
48477
48493
  var RadioSection = function RadioSection(_ref) {
48478
48494
  var themeValues = _ref.themeValues,
48479
48495
  isMobile = _ref.isMobile,
@@ -48491,10 +48507,12 @@ var RadioSection = function RadioSection(_ref) {
48491
48507
  openHeight = _ref$openHeight === void 0 ? "auto" : _ref$openHeight,
48492
48508
  _ref$containerStyles = _ref.containerStyles,
48493
48509
  containerStyles = _ref$containerStyles === void 0 ? "" : _ref$containerStyles,
48494
- ariaDescribedBy = _ref.ariaDescribedBy;
48510
+ ariaDescribedBy = _ref.ariaDescribedBy,
48511
+ _ref$rightIconsLabel = _ref.rightIconsLabel,
48512
+ rightIconsLabel = _ref$rightIconsLabel === void 0 ? null : _ref$rightIconsLabel;
48495
48513
 
48496
48514
  var handleKeyDown = function handleKeyDown(id, e) {
48497
- if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13) {
48515
+ if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13 || (e === null || e === void 0 ? void 0 : e.keyCode) === 32) {
48498
48516
  toggleOpenSection(id);
48499
48517
  }
48500
48518
  };
@@ -48546,7 +48564,8 @@ var RadioSection = function RadioSection(_ref) {
48546
48564
  borderRadius: "4px",
48547
48565
  extraStyles: containerStyles
48548
48566
  }, /*#__PURE__*/React__default.createElement(Stack, {
48549
- childGap: "0"
48567
+ childGap: "0",
48568
+ role: "radiogroup"
48550
48569
  }, sections.filter(function (section) {
48551
48570
  return !section.hidden;
48552
48571
  }).map(function (section) {
@@ -48565,7 +48584,9 @@ var RadioSection = function RadioSection(_ref) {
48565
48584
  animate: openSection === section.id ? "open" : "closed",
48566
48585
  initial: initiallyOpen ? "open" : "closed",
48567
48586
  key: "item-".concat(section.id),
48568
- extraStyles: borderStyles
48587
+ extraStyles: borderStyles,
48588
+ role: "radio",
48589
+ "aria-checked": openSection === section.id
48569
48590
  }, /*#__PURE__*/React__default.createElement(Stack, {
48570
48591
  childGap: "0"
48571
48592
  }, /*#__PURE__*/React__default.createElement(Box, {
@@ -48595,8 +48616,10 @@ var RadioSection = function RadioSection(_ref) {
48595
48616
  }, !section.hideRadioButton && /*#__PURE__*/React__default.createElement(Box, {
48596
48617
  padding: "0"
48597
48618
  }, /*#__PURE__*/React__default.createElement(RadioButton$2, {
48598
- name: typeof section.title === "string" ? createIdFromString(section.title) : section.id,
48619
+ id: computeSectionId(section),
48620
+ name: computeSectionId(section),
48599
48621
  ariaDescribedBy: ariaDescribedBy,
48622
+ ariaLabelledBy: "radio-input-".concat(computeSectionId(section)),
48600
48623
  radioOn: openSection === section.id,
48601
48624
  radioFocused: focused === section.id,
48602
48625
  toggleRadio: section.disabled ? noop : function () {
@@ -48608,11 +48631,14 @@ var RadioSection = function RadioSection(_ref) {
48608
48631
  }, section.titleIcon), /*#__PURE__*/React__default.createElement(Box, {
48609
48632
  padding: section.titleIcon ? "0 0 0 8px" : "0"
48610
48633
  }, /*#__PURE__*/React__default.createElement(Text$1, {
48611
- variant: "p",
48612
- color: CHARADE_GREY
48613
- }, section.title))), section.rightIcons && /*#__PURE__*/React__default.createElement(Cluster, {
48634
+ as: "label",
48635
+ color: CHARADE_GREY,
48636
+ htmlFor: "radio-input-".concat(computeSectionId(section))
48637
+ }, section.title))), section.rightIcons && /*#__PURE__*/React__default.createElement(Cluster, _extends({
48614
48638
  childGap: "0.5rem"
48615
- }, section.rightIcons.map(function (icon) {
48639
+ }, rightIconsLabel !== null ? {
48640
+ "aria-label": rightIconsLabel
48641
+ } : {}), section.rightIcons.map(function (icon) {
48616
48642
  return /*#__PURE__*/React__default.createElement(RightIcon, {
48617
48643
  src: icon.img,
48618
48644
  key: icon.img,