@thecb/components 9.2.13-beta.0 → 9.2.13-beta.1

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.
Files changed (33) hide show
  1. package/dist/index.cjs.js +80 -22
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.esm.js +80 -23
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/components/atoms/button-with-action/ButtonWithAction.js +76 -70
  8. package/src/components/atoms/checkbox/Checkbox.js +10 -2
  9. package/src/components/atoms/checkbox/Checkbox.stories.js +1 -0
  10. package/src/components/atoms/dropdown/Dropdown.js +2 -1
  11. package/src/components/atoms/icons/KebabMenuIcon.d.ts +1 -0
  12. package/src/components/atoms/icons/KebabMenuIcon.js +38 -0
  13. package/src/components/atoms/icons/TrashIcon.js +42 -40
  14. package/src/components/atoms/icons/icons.stories.js +3 -1
  15. package/src/components/atoms/icons/index.d.ts +1 -0
  16. package/src/components/atoms/icons/index.js +3 -1
  17. package/src/components/atoms/toggle-switch/ToggleSwitch.js +2 -1
  18. package/src/components/molecules/collapsible-section/CollapsibleSection.js +2 -1
  19. package/src/components/molecules/popover/Popover.js +2 -1
  20. package/src/components/molecules/popup-menu/PopupMenu.js +152 -0
  21. package/src/components/molecules/popup-menu/PopupMenu.stories.js +40 -0
  22. package/src/components/molecules/popup-menu/PopupMenu.styled.js +20 -0
  23. package/src/components/molecules/popup-menu/PopupMenu.theme.js +11 -0
  24. package/src/components/molecules/popup-menu/index.d.ts +25 -0
  25. package/src/components/molecules/popup-menu/index.js +3 -0
  26. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.js +79 -0
  27. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.styled.js +27 -0
  28. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.theme.js +23 -0
  29. package/src/components/molecules/radio-section/RadioSection.js +20 -8
  30. package/src/components/molecules/terms-and-conditions/TermsAndConditions.stories.js +3 -1
  31. package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV2.js +4 -0
  32. package/src/constants/keyboard.js +7 -0
  33. package/src/util/general.js +10 -0
package/dist/index.cjs.js CHANGED
@@ -6371,6 +6371,15 @@ var titleCaseString = function titleCaseString(string) {
6371
6371
  var kebabCaseString = function kebabCaseString(string) {
6372
6372
  return string === null || string === void 0 ? void 0 : string.replaceAll(" ", "-").toLowerCase();
6373
6373
  };
6374
+ var wrapIndex$1 = function wrapIndex(index, length) {
6375
+ if (index == -1) {
6376
+ return length - 1;
6377
+ } else if (index == length) {
6378
+ return 0;
6379
+ } else {
6380
+ return index;
6381
+ }
6382
+ };
6374
6383
 
6375
6384
  var general = /*#__PURE__*/Object.freeze({
6376
6385
  __proto__: null,
@@ -6391,7 +6400,8 @@ var general = /*#__PURE__*/Object.freeze({
6391
6400
  throttle: throttle,
6392
6401
  titleCaseWord: titleCaseWord,
6393
6402
  titleCaseString: titleCaseString,
6394
- kebabCaseString: kebabCaseString
6403
+ kebabCaseString: kebabCaseString,
6404
+ wrapIndex: wrapIndex$1
6395
6405
  });
6396
6406
 
6397
6407
  var _excluded$1 = ["themeValues", "weight", "color", "textWrap", "extraStyles", "hoverStyles", "onClick", "onKeyPress", "as", "dataQa", "children", "variant"];
@@ -12927,7 +12937,7 @@ var Spinner = function Spinner(_ref) {
12927
12937
  */
12928
12938
 
12929
12939
 
12930
- var ButtonWithAction = function ButtonWithAction(_ref2) {
12940
+ var ButtonWithAction = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
12931
12941
  var _ref2$action = _ref2.action,
12932
12942
  action = _ref2$action === void 0 ? noop : _ref2$action,
12933
12943
  _ref2$variant = _ref2.variant,
@@ -12958,6 +12968,7 @@ var ButtonWithAction = function ButtonWithAction(_ref2) {
12958
12968
  var activeStyles = "\n outline: none;\n background-color: ".concat(themeValues.activeBackgroundColor, ";\n border-color: ").concat(themeValues.activeBorderColor, ";\n color: ").concat(themeValues.activeColor, ";\n text-decoration: ").concat(variant === "ghost" || variant === "smallGhost" ? "underline" : "none", ";\n ");
12959
12969
  var disabledStyles = "\n background-color: #6D717E;\n border-color: #6D717E;\n color: #FFFFFF;\n cursor: default;\n &:focus {\n box-shadow: 0 0 10px #6D717E;\n outline: none;\n }\n ".concat(extraDisabledStyles, "\n ");
12960
12970
  return /*#__PURE__*/React__default.createElement(Box, _extends({
12971
+ ref: ref,
12961
12972
  variant: variant,
12962
12973
  padding: themeValues.padding,
12963
12974
  minHeight: themeValues.height,
@@ -12986,7 +12997,7 @@ var ButtonWithAction = function ButtonWithAction(_ref2) {
12986
12997
  textWrap: textWrap,
12987
12998
  extraStyles: textExtraStyles
12988
12999
  }, text)));
12989
- };
13000
+ });
12990
13001
 
12991
13002
  var primaryColor = {
12992
13003
  info: "".concat(WHITE),
@@ -15300,7 +15311,8 @@ var ShoppingCartIcon = function ShoppingCartIcon() {
15300
15311
  };
15301
15312
 
15302
15313
  var TrashIcon = function TrashIcon(_ref) {
15303
- var themeValues = _ref.themeValues;
15314
+ var themeValues = _ref.themeValues,
15315
+ iconFill = _ref.iconFill;
15304
15316
  return /*#__PURE__*/React__default.createElement("svg", {
15305
15317
  width: "20px",
15306
15318
  height: "20px",
@@ -15324,12 +15336,12 @@ var TrashIcon = function TrashIcon(_ref) {
15324
15336
  xlinkHref: "#trash-path-1"
15325
15337
  })), /*#__PURE__*/React__default.createElement("use", {
15326
15338
  id: "trash-Mask",
15327
- fill: themeValues.singleIconColor,
15339
+ fill: iconFill !== null && iconFill !== void 0 ? iconFill : themeValues.singleIconColor,
15328
15340
  fillRule: "nonzero",
15329
15341
  xlinkHref: "#trash-path-1"
15330
15342
  }), /*#__PURE__*/React__default.createElement("polygon", {
15331
15343
  id: "trash-Path",
15332
- fill: themeValues.singleIconColor,
15344
+ fill: iconFill !== null && iconFill !== void 0 ? iconFill : themeValues.singleIconColor,
15333
15345
  fillRule: "nonzero",
15334
15346
  mask: "url(#trash-mask-2)",
15335
15347
  points: "0 0 20 0 20 20 0 20"
@@ -18260,6 +18272,34 @@ var PlusCircleIcon = function PlusCircleIcon(_ref) {
18260
18272
  }));
18261
18273
  };
18262
18274
 
18275
+ var KebabMenuIcon = function KebabMenuIcon() {
18276
+ return /*#__PURE__*/React__default.createElement("svg", {
18277
+ xmlns: "http://www.w3.org/2000/svg",
18278
+ width: "21",
18279
+ height: "32",
18280
+ viewBox: "0 0 21 32",
18281
+ fill: "none"
18282
+ }, /*#__PURE__*/React__default.createElement("path", {
18283
+ d: "M0 4C0 1.79086 1.79086 0 4 0L17 0C19.2091 0 21 1.79086 21 4V28C21 30.2091 19.2091 32 17 32H4C1.79086 32 0 30.2091 0 28L0 4Z",
18284
+ fill: "none"
18285
+ }), /*#__PURE__*/React__default.createElement("path", {
18286
+ fillRule: "evenodd",
18287
+ clipRule: "evenodd",
18288
+ d: "M10.5 6C9.39333 6 8.5 6.89333 8.5 8C8.5 9.10667 9.39333 10 10.5 10C11.6067 10 12.5 9.10667 12.5 8C12.5 6.89333 11.6067 6 10.5 6Z",
18289
+ fill: "#3B5BDB"
18290
+ }), /*#__PURE__*/React__default.createElement("path", {
18291
+ fillRule: "evenodd",
18292
+ clipRule: "evenodd",
18293
+ d: "M10.5 14C9.39333 14 8.5 14.8933 8.5 16C8.5 17.1067 9.39333 18 10.5 18C11.6067 18 12.5 17.1067 12.5 16C12.5 14.8933 11.6067 14 10.5 14Z",
18294
+ fill: "#3B5BDB"
18295
+ }), /*#__PURE__*/React__default.createElement("path", {
18296
+ fillRule: "evenodd",
18297
+ clipRule: "evenodd",
18298
+ d: "M10.5 22C9.39333 22 8.5 22.9067 8.5 24C8.5 25.0933 9.40667 26 10.5 26C11.5933 26 12.5 25.0933 12.5 24C12.5 22.9067 11.6067 22 10.5 22Z",
18299
+ fill: "#3B5BDB"
18300
+ }));
18301
+ };
18302
+
18263
18303
  var color$2 = "#15749D";
18264
18304
  var hoverColor$1 = "#116285";
18265
18305
  var activeColor$1 = "#0E506D";
@@ -22086,6 +22126,13 @@ var fallbackValues$d = {
22086
22126
  disabledCheckedStyles: disabledCheckedStyles
22087
22127
  };
22088
22128
 
22129
+ var ARROW_UP = 38;
22130
+ var ARROW_RIGHT = 39;
22131
+ var ARROW_DOWN = 40;
22132
+ var ENTER = 13;
22133
+ var ESCAPE = 27;
22134
+ var SPACEBAR = 32;
22135
+
22089
22136
  var CheckboxContainer = styled__default.div.withConfig({
22090
22137
  displayName: "Checkbox__CheckboxContainer",
22091
22138
  componentId: "sc-36kqbv-0"
@@ -22146,6 +22193,7 @@ var Checkbox = function Checkbox(_ref4) {
22146
22193
  checkboxMargin = _ref4$checkboxMargin === void 0 ? "0 16px 0 0" : _ref4$checkboxMargin,
22147
22194
  extraStyles = _ref4.extraStyles,
22148
22195
  textExtraStyles = _ref4.textExtraStyles,
22196
+ labelledById = _ref4.labelledById,
22149
22197
  _ref4$dataQa = _ref4.dataQa,
22150
22198
  dataQa = _ref4$dataQa === void 0 ? null : _ref4$dataQa;
22151
22199
 
@@ -22155,11 +22203,14 @@ var Checkbox = function Checkbox(_ref4) {
22155
22203
  setFocused = _useState2[1];
22156
22204
 
22157
22205
  var handleClick = function handleClick(e, func) {
22158
- if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13) {
22206
+ if (e.keyCode === ENTER) {
22159
22207
  func();
22160
22208
  }
22161
22209
  };
22162
22210
 
22211
+ var titleId = title ? "checkboxlabel-".concat(name) : undefined;
22212
+ var ariaLabelledById = labelledById !== null && labelledById !== void 0 ? labelledById : titleId;
22213
+ var ariaLabel = ariaLabelledById ? undefined : name;
22163
22214
  return /*#__PURE__*/React__default.createElement(Box, {
22164
22215
  padding: "0",
22165
22216
  tabIndex: "0",
@@ -22183,7 +22234,8 @@ var Checkbox = function Checkbox(_ref4) {
22183
22234
  id: "checkbox-".concat(name),
22184
22235
  disabled: disabled,
22185
22236
  name: name,
22186
- "aria-label": name,
22237
+ "aria-label": ariaLabel,
22238
+ "aria-labelledby": ariaLabelledById,
22187
22239
  checked: checked,
22188
22240
  onChange: onChange,
22189
22241
  tabIndex: "-1",
@@ -22210,6 +22262,7 @@ var Checkbox = function Checkbox(_ref4) {
22210
22262
  }, /*#__PURE__*/React__default.createElement("polyline", {
22211
22263
  points: "20 6 9 17 4 12"
22212
22264
  })))), title && /*#__PURE__*/React__default.createElement(Text$1, {
22265
+ id: titleId,
22213
22266
  variant: "p",
22214
22267
  weight: themeValues.textFontWeight,
22215
22268
  color: themeValues.textColor,
@@ -24122,7 +24175,7 @@ var Dropdown = function Dropdown(_ref13) {
24122
24175
  return handleItemSelection(e, choice, i);
24123
24176
  },
24124
24177
  onKeyDown: function onKeyDown(e) {
24125
- if (e.keyCode === 13) {
24178
+ if (e.keyCode === ENTER) {
24126
24179
  handleItemSelection(e, choice, i);
24127
24180
  }
24128
24181
  },
@@ -25488,7 +25541,7 @@ var Popover = function Popover(_ref) {
25488
25541
  handleTogglePopover(false);
25489
25542
  },
25490
25543
  onKeyDown: function onKeyDown(e) {
25491
- if (e.keyCode === 27) {
25544
+ if (e.keyCode === ESCAPE) {
25492
25545
  handleTogglePopover(false);
25493
25546
  }
25494
25547
  },
@@ -38299,7 +38352,7 @@ var ToggleSwitch = function ToggleSwitch(_ref6) {
38299
38352
  });
38300
38353
 
38301
38354
  var handleKeyDown = function handleKeyDown(e) {
38302
- if (e.keyCode === 13) {
38355
+ if (e.keyCode === ENTER) {
38303
38356
  onToggle();
38304
38357
  }
38305
38358
  };
@@ -39828,7 +39881,7 @@ var CollapsibleSection = function CollapsibleSection(_ref) {
39828
39881
  extraStyles = _ref$extraStyles === void 0 ? "" : _ref$extraStyles;
39829
39882
 
39830
39883
  var handleKeyDown = function handleKeyDown(e) {
39831
- if (e.keyCode === 13) {
39884
+ if (e.keyCode === ENTER) {
39832
39885
  toggleSection();
39833
39886
  }
39834
39887
  };
@@ -47859,6 +47912,8 @@ var TermsAndConditionsControlV1 = function TermsAndConditionsControlV1(_ref) {
47859
47912
  })))));
47860
47913
  };
47861
47914
 
47915
+ var TermsAndConditionsTitleDivId = "terms-and-conditions-title";
47916
+
47862
47917
  var TermsAndConditionsControlV2 = function TermsAndConditionsControlV2(_ref) {
47863
47918
  var _ref$showCheckbox = _ref.showCheckbox,
47864
47919
  showCheckbox = _ref$showCheckbox === void 0 ? true : _ref$showCheckbox,
@@ -47921,7 +47976,8 @@ var TermsAndConditionsControlV2 = function TermsAndConditionsControlV2(_ref) {
47921
47976
  checked: isChecked,
47922
47977
  onChange: onCheck,
47923
47978
  checkboxMargin: checkboxMargin,
47924
- extraStyles: "align-self: flex-start;"
47979
+ extraStyles: "align-self: flex-start;",
47980
+ labelledById: TermsAndConditionsTitleDivId
47925
47981
  }), /*#__PURE__*/React__default.createElement(Stack, {
47926
47982
  childGap: "0.25rem",
47927
47983
  fullHeight: true
@@ -47929,7 +47985,8 @@ var TermsAndConditionsControlV2 = function TermsAndConditionsControlV2(_ref) {
47929
47985
  justify: "flex-start",
47930
47986
  align: "center",
47931
47987
  nowrap: true,
47932
- extraStyles: "padding-right: 2px; > div > * { margin: 4px 2px; };"
47988
+ extraStyles: "padding-right: 2px; > div > * { margin: 4px 2px; };",
47989
+ id: TermsAndConditionsTitleDivId
47933
47990
  }, description && /*#__PURE__*/React__default.createElement(Text$1, {
47934
47991
  color: CHARADE_GREY
47935
47992
  }, description), terms && /*#__PURE__*/React__default.createElement(TermsAndConditionsModal$1, {
@@ -48696,21 +48753,21 @@ var RadioSection = function RadioSection(_ref) {
48696
48753
  } // Allow Enter and Space to select a section
48697
48754
 
48698
48755
 
48699
- if ((e === null || e === void 0 ? void 0 : e.keyCode) === 13 || (e === null || e === void 0 ? void 0 : e.keyCode) === 32) {
48756
+ if (e.keyCode === ENTER || e.keyCode === SPACEBAR) {
48700
48757
  e.preventDefault();
48701
48758
  toggleOpenSection(id);
48702
48759
  } // Allow Up and Down arrow navigation between sections
48703
48760
 
48704
48761
 
48705
- if ((e === null || e === void 0 ? void 0 : e.keyCode) >= 37 && (e === null || e === void 0 ? void 0 : e.keyCode) <= 40) {
48706
- var _sections$target, _sections$target2;
48762
+ if (e.keyCode == ARROW_UP || e.keyCode == ARROW_DOWN || e.keyCode == ARROW_LEFT || e.keyCode == ARROW_RIGHT) {
48763
+ var _sectionRefs$current$, _sectionRefs$current$2, _sections$nextIndex, _sections$nextIndex2;
48707
48764
 
48708
48765
  e.preventDefault();
48709
- var next = i + ((e === null || e === void 0 ? void 0 : e.keyCode) > 38 ? 1 : -1);
48710
- var target = next == -1 ? sections.length - 1 : next == sections.length ? 0 : next;
48711
- sectionRefs.current[target].current.focus();
48712
- setFocused((_sections$target = sections[target]) === null || _sections$target === void 0 ? void 0 : _sections$target.id);
48713
- toggleOpenSection((_sections$target2 = sections[target]) === null || _sections$target2 === void 0 ? void 0 : _sections$target2.id);
48766
+ var indexIncrement = e.keyCode == ARROW_RIGHT || e.keyCode == ARROW_DOWN ? 1 : -1;
48767
+ var nextIndex = wrapIndex(i + indexIncrement);
48768
+ sectionRefs === null || sectionRefs === void 0 ? void 0 : (_sectionRefs$current$ = sectionRefs.current[nextIndex]) === null || _sectionRefs$current$ === void 0 ? void 0 : (_sectionRefs$current$2 = _sectionRefs$current$.current) === null || _sectionRefs$current$2 === void 0 ? void 0 : _sectionRefs$current$2.focus();
48769
+ setFocused((_sections$nextIndex = sections[nextIndex]) === null || _sections$nextIndex === void 0 ? void 0 : _sections$nextIndex.id);
48770
+ toggleOpenSection((_sections$nextIndex2 = sections[nextIndex]) === null || _sections$nextIndex2 === void 0 ? void 0 : _sections$nextIndex2.id);
48714
48771
  }
48715
48772
  };
48716
48773
 
@@ -49888,6 +49945,7 @@ exports.ImageBox = ImageBox;
49888
49945
  exports.Imposter = Imposter;
49889
49946
  exports.InternalLink = InternalLink;
49890
49947
  exports.Jumbo = Jumbo$1;
49948
+ exports.KebabMenuIcon = KebabMenuIcon;
49891
49949
  exports.KioskImage = KioskImage;
49892
49950
  exports.LabeledAmount = LabeledAmount$1;
49893
49951
  exports.LineItem = LineItem$1;