@thecb/components 6.0.8 → 6.0.9

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
@@ -6074,6 +6074,18 @@ var createUniqueId = function createUniqueId() {
6074
6074
  return "_" + Math.random().toString(36).substr(2, 9);
6075
6075
  };
6076
6076
 
6077
+ var createIdFromString = function createIdFromString(text, postscript) {
6078
+ var unique = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
6079
+
6080
+ if (text === undefined) {
6081
+ return createUniqueId();
6082
+ } else {
6083
+ // "first name", undefined, false -> "first-name"
6084
+ // "email address", "error message", false -> "email-address-error-message"
6085
+ // "shopping cart", "order item", true -> "shopping-cart-order-item_2ahtlz608"
6086
+ return "".concat(text === null || text === void 0 ? void 0 : text.replace(/\s+/g, "-")).concat(postscript ? "-".concat(postscript === null || postscript === void 0 ? void 0 : postscript.replace(/\s+/g, "-")) : "").concat(unique ? createUniqueId() : "");
6087
+ }
6088
+ };
6077
6089
  var safeChildren = function safeChildren(children) {
6078
6090
  var replacement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
6079
6091
  var unsafeValues = [false, undefined, NaN, null];
@@ -6156,6 +6168,7 @@ var general = /*#__PURE__*/Object.freeze({
6156
6168
  displayCurrency: displayCurrency,
6157
6169
  convertCentsToMoneyInt: convertCentsToMoneyInt,
6158
6170
  formatPercent: formatPercent,
6171
+ createIdFromString: createIdFromString,
6159
6172
  safeChildren: safeChildren,
6160
6173
  generateClickHandler: generateClickHandler,
6161
6174
  checkCardBrand: checkCardBrand,
@@ -20720,6 +20733,7 @@ var Dropdown = function Dropdown(_ref8) {
20720
20733
  _ref8$autoEraseTypeAh = _ref8.autoEraseTypeAhead,
20721
20734
  autoEraseTypeAhead = _ref8$autoEraseTypeAh === void 0 ? true : _ref8$autoEraseTypeAh,
20722
20735
  ariaLabelledby = _ref8.ariaLabelledby,
20736
+ ariaDescribedby = _ref8.ariaDescribedby,
20723
20737
  _ref8$autocompleteVal = _ref8.autocompleteValue,
20724
20738
  autocompleteValue = _ref8$autocompleteVal === void 0 ? "" : _ref8$autocompleteVal,
20725
20739
  _ref8$smoothScroll = _ref8.smoothScroll,
@@ -20969,6 +20983,7 @@ var Dropdown = function Dropdown(_ref8) {
20969
20983
  "aria-owns": "".concat(ariaLabelledby, "_listbox"),
20970
20984
  "aria-haspopup": "listbox",
20971
20985
  "aria-labelledby": ariaLabelledby,
20986
+ "aria-describedby": ariaDescribedby,
20972
20987
  "aria-expanded": isOpen,
20973
20988
  autocomplete: autocompleteValue,
20974
20989
  background: isOpen ? themeValues.hoverColor : WHITE,
@@ -21185,9 +21200,10 @@ var FormSelect = function FormSelect(_ref) {
21185
21200
  color: themeValues.labelColor,
21186
21201
  weight: themeValues.fontWeight,
21187
21202
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
21188
- id: labelTextWhenNoError.replace(/\s+/g, "-")
21203
+ id: createIdFromString(labelTextWhenNoError)
21189
21204
  }, labelTextWhenNoError))), /*#__PURE__*/React__default.createElement(Dropdown$1, {
21190
- ariaLabelledby: labelTextWhenNoError.replace(/\s+/g, "-"),
21205
+ ariaLabelledby: createIdFromString(labelTextWhenNoError),
21206
+ ariaDescribedby: createIdFromString(labelTextWhenNoError, "error message"),
21191
21207
  maxHeight: dropdownMaxHeight,
21192
21208
  hasTitles: hasTitles,
21193
21209
  placeholder: options[0] ? options[0].text : "",
@@ -21214,7 +21230,8 @@ var FormSelect = function FormSelect(_ref) {
21214
21230
  color: ERROR_COLOR,
21215
21231
  variant: "pXS",
21216
21232
  weight: themeValues.fontWeight,
21217
- extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }"
21233
+ extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
21234
+ id: createIdFromString(labelTextWhenNoError, "error message")
21218
21235
  }, errorMessages[field.errors[0]]) : /*#__PURE__*/React__default.createElement(Text$1, {
21219
21236
  extraStyles: "height: ".concat(themeValues.lineHeight, ";")
21220
21237
  })));
@@ -22637,7 +22654,7 @@ var FormInput = function FormInput(_ref15) {
22637
22654
  variant: "pS",
22638
22655
  weight: themeValues.fontWeight,
22639
22656
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
22640
- id: labelTextWhenNoError.replace(/\s+/g, "-")
22657
+ id: createIdFromString(labelTextWhenNoError)
22641
22658
  }, labelTextWhenNoError), /*#__PURE__*/React__default.createElement(Text$1, {
22642
22659
  color: themeValues.linkColor,
22643
22660
  variant: "pS",
@@ -22654,7 +22671,7 @@ var FormInput = function FormInput(_ref15) {
22654
22671
  variant: "pS",
22655
22672
  fontWeight: themeValues.fontWeight,
22656
22673
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
22657
- id: labelTextWhenNoError.replace(/\s+/g, "-")
22674
+ id: createIdFromString(labelTextWhenNoError)
22658
22675
  }, labelTextWhenNoError), type === "password" && /*#__PURE__*/React__default.createElement(Text$1, {
22659
22676
  variant: "pS",
22660
22677
  color: themeValues.linkColor,
@@ -22674,7 +22691,8 @@ var FormInput = function FormInput(_ref15) {
22674
22691
  }, decorator)))), /*#__PURE__*/React__default.createElement(Box, {
22675
22692
  padding: "0"
22676
22693
  }, formatter ? /*#__PURE__*/React__default.createElement(FormattedInputField, _extends({
22677
- "aria-labelledby": labelTextWhenNoError.replace(/\s+/g, "-"),
22694
+ "aria-labelledby": createIdFromString(labelTextWhenNoError),
22695
+ "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
22678
22696
  onChange: function onChange(e) {
22679
22697
  return fieldActions.set(e);
22680
22698
  },
@@ -22690,7 +22708,8 @@ var FormInput = function FormInput(_ref15) {
22690
22708
  $customHeight: customHeight,
22691
22709
  $extraStyles: extraStyles
22692
22710
  }, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
22693
- "aria-labelledby": labelTextWhenNoError.replace(/\s+/g, "-"),
22711
+ "aria-labelledby": createIdFromString(labelTextWhenNoError),
22712
+ "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
22694
22713
  onChange: function onChange(e) {
22695
22714
  return fieldActions.set(e.target.value);
22696
22715
  },
@@ -22712,7 +22731,8 @@ var FormInput = function FormInput(_ref15) {
22712
22731
  color: ERROR_COLOR,
22713
22732
  variant: "pXS",
22714
22733
  weight: themeValues.fontWeight,
22715
- extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }"
22734
+ extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
22735
+ id: createIdFromString(labelTextWhenNoError, "error message")
22716
22736
  }, errorMessages[field.errors[0]]) : /*#__PURE__*/React__default.createElement(Text$1, {
22717
22737
  extraStyles: "height: ".concat(themeValues.lineHeight, ";")
22718
22738
  }), !isMobile && decorator && /*#__PURE__*/React__default.createElement(Box, {
@@ -43297,6 +43317,9 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
43297
43317
  time.timer = setTimeout(function () {
43298
43318
  periscopeDataRequestFailure();
43299
43319
  }, 10000);
43320
+ return function () {
43321
+ return clearTimeout(time.timer);
43322
+ };
43300
43323
  }, []);
43301
43324
 
43302
43325
  var Dashboard = function Dashboard(height) {
@@ -43317,8 +43340,11 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
43317
43340
  var validatePeriscope = function validatePeriscope(message) {
43318
43341
  if (isValidMessage(message)) {
43319
43342
  setHeight(message.data.dashboard_height + 100);
43320
- clearTimeout(time.timer);
43321
- periscopeDataRequestSuccess();
43343
+
43344
+ if (!periscopeDataSuccess) {
43345
+ clearTimeout(time.timer);
43346
+ periscopeDataRequestSuccess();
43347
+ }
43322
43348
  }
43323
43349
  };
43324
43350