@thecb/components 6.0.8 → 6.1.0-beta.2
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 +53 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +53 -11
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/atoms/dropdown/Dropdown.js +2 -0
- package/src/components/atoms/form-layouts/FormInput.js +22 -4
- package/src/components/atoms/form-select/FormSelect.js +8 -2
- package/src/components/molecules/periscope-dashboard-iframe/PeriscopeDashboardIframe.js +5 -2
- package/src/util/focusFirstInvalidInputHook.js +17 -0
- package/src/util/general.js +13 -0
- package/src/util/index.js +2 -1
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
|
|
21203
|
+
id: createIdFromString(labelTextWhenNoError)
|
|
21189
21204
|
}, labelTextWhenNoError))), /*#__PURE__*/React__default.createElement(Dropdown$1, {
|
|
21190
|
-
ariaLabelledby: labelTextWhenNoError
|
|
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
|
|
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
|
|
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,9 @@ 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
|
|
22694
|
+
"aria-labelledby": createIdFromString(labelTextWhenNoError),
|
|
22695
|
+
"aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
|
|
22696
|
+
"aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
|
|
22678
22697
|
onChange: function onChange(e) {
|
|
22679
22698
|
return fieldActions.set(e);
|
|
22680
22699
|
},
|
|
@@ -22690,7 +22709,9 @@ var FormInput = function FormInput(_ref15) {
|
|
|
22690
22709
|
$customHeight: customHeight,
|
|
22691
22710
|
$extraStyles: extraStyles
|
|
22692
22711
|
}, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
|
|
22693
|
-
"aria-labelledby": labelTextWhenNoError
|
|
22712
|
+
"aria-labelledby": createIdFromString(labelTextWhenNoError),
|
|
22713
|
+
"aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
|
|
22714
|
+
"aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
|
|
22694
22715
|
onChange: function onChange(e) {
|
|
22695
22716
|
return fieldActions.set(e.target.value);
|
|
22696
22717
|
},
|
|
@@ -22712,7 +22733,8 @@ var FormInput = function FormInput(_ref15) {
|
|
|
22712
22733
|
color: ERROR_COLOR,
|
|
22713
22734
|
variant: "pXS",
|
|
22714
22735
|
weight: themeValues.fontWeight,
|
|
22715
|
-
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }"
|
|
22736
|
+
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
22737
|
+
id: createIdFromString(labelTextWhenNoError, "error message")
|
|
22716
22738
|
}, errorMessages[field.errors[0]]) : /*#__PURE__*/React__default.createElement(Text$1, {
|
|
22717
22739
|
extraStyles: "height: ".concat(themeValues.lineHeight, ";")
|
|
22718
22740
|
}), !isMobile && decorator && /*#__PURE__*/React__default.createElement(Box, {
|
|
@@ -43297,6 +43319,9 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
|
|
|
43297
43319
|
time.timer = setTimeout(function () {
|
|
43298
43320
|
periscopeDataRequestFailure();
|
|
43299
43321
|
}, 10000);
|
|
43322
|
+
return function () {
|
|
43323
|
+
return clearTimeout(time.timer);
|
|
43324
|
+
};
|
|
43300
43325
|
}, []);
|
|
43301
43326
|
|
|
43302
43327
|
var Dashboard = function Dashboard(height) {
|
|
@@ -43317,8 +43342,11 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
|
|
|
43317
43342
|
var validatePeriscope = function validatePeriscope(message) {
|
|
43318
43343
|
if (isValidMessage(message)) {
|
|
43319
43344
|
setHeight(message.data.dashboard_height + 100);
|
|
43320
|
-
|
|
43321
|
-
|
|
43345
|
+
|
|
43346
|
+
if (!periscopeDataSuccess) {
|
|
43347
|
+
clearTimeout(time.timer);
|
|
43348
|
+
periscopeDataRequestSuccess();
|
|
43349
|
+
}
|
|
43322
43350
|
}
|
|
43323
43351
|
};
|
|
43324
43352
|
|
|
@@ -43627,13 +43655,27 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
43627
43655
|
fontWeights: style_constants
|
|
43628
43656
|
});
|
|
43629
43657
|
|
|
43658
|
+
var useFocusInvalidInput = function useFocusInvalidInput() {
|
|
43659
|
+
var showErrors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
43660
|
+
// Only move focus when "showErrors" is true
|
|
43661
|
+
// "showErrors" is managed by container page of form
|
|
43662
|
+
// typically set to "true" on attempted form submission, if errors exist
|
|
43663
|
+
React.useEffect(function () {
|
|
43664
|
+
if (showErrors) {
|
|
43665
|
+
var inputsWithErrors = document.querySelectorAll("input[aria-invalid=true]");
|
|
43666
|
+
console.log("inputs with errors...", inputsWithErrors);
|
|
43667
|
+
}
|
|
43668
|
+
}, [showErrors]);
|
|
43669
|
+
};
|
|
43670
|
+
|
|
43630
43671
|
|
|
43631
43672
|
|
|
43632
43673
|
var index$5 = /*#__PURE__*/Object.freeze({
|
|
43633
43674
|
__proto__: null,
|
|
43634
43675
|
formats: formats,
|
|
43635
43676
|
general: general,
|
|
43636
|
-
theme: themeUtils
|
|
43677
|
+
theme: themeUtils,
|
|
43678
|
+
useFocusInvalidInput: useFocusInvalidInput
|
|
43637
43679
|
});
|
|
43638
43680
|
|
|
43639
43681
|
exports.AccountNumberImage = AccountNumberImage;
|