@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.esm.js
CHANGED
|
@@ -6066,6 +6066,18 @@ var createUniqueId = function createUniqueId() {
|
|
|
6066
6066
|
return "_" + Math.random().toString(36).substr(2, 9);
|
|
6067
6067
|
};
|
|
6068
6068
|
|
|
6069
|
+
var createIdFromString = function createIdFromString(text, postscript) {
|
|
6070
|
+
var unique = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
6071
|
+
|
|
6072
|
+
if (text === undefined) {
|
|
6073
|
+
return createUniqueId();
|
|
6074
|
+
} else {
|
|
6075
|
+
// "first name", undefined, false -> "first-name"
|
|
6076
|
+
// "email address", "error message", false -> "email-address-error-message"
|
|
6077
|
+
// "shopping cart", "order item", true -> "shopping-cart-order-item_2ahtlz608"
|
|
6078
|
+
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() : "");
|
|
6079
|
+
}
|
|
6080
|
+
};
|
|
6069
6081
|
var safeChildren = function safeChildren(children) {
|
|
6070
6082
|
var replacement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
6071
6083
|
var unsafeValues = [false, undefined, NaN, null];
|
|
@@ -6148,6 +6160,7 @@ var general = /*#__PURE__*/Object.freeze({
|
|
|
6148
6160
|
displayCurrency: displayCurrency,
|
|
6149
6161
|
convertCentsToMoneyInt: convertCentsToMoneyInt,
|
|
6150
6162
|
formatPercent: formatPercent,
|
|
6163
|
+
createIdFromString: createIdFromString,
|
|
6151
6164
|
safeChildren: safeChildren,
|
|
6152
6165
|
generateClickHandler: generateClickHandler,
|
|
6153
6166
|
checkCardBrand: checkCardBrand,
|
|
@@ -20712,6 +20725,7 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
20712
20725
|
_ref8$autoEraseTypeAh = _ref8.autoEraseTypeAhead,
|
|
20713
20726
|
autoEraseTypeAhead = _ref8$autoEraseTypeAh === void 0 ? true : _ref8$autoEraseTypeAh,
|
|
20714
20727
|
ariaLabelledby = _ref8.ariaLabelledby,
|
|
20728
|
+
ariaDescribedby = _ref8.ariaDescribedby,
|
|
20715
20729
|
_ref8$autocompleteVal = _ref8.autocompleteValue,
|
|
20716
20730
|
autocompleteValue = _ref8$autocompleteVal === void 0 ? "" : _ref8$autocompleteVal,
|
|
20717
20731
|
_ref8$smoothScroll = _ref8.smoothScroll,
|
|
@@ -20961,6 +20975,7 @@ var Dropdown = function Dropdown(_ref8) {
|
|
|
20961
20975
|
"aria-owns": "".concat(ariaLabelledby, "_listbox"),
|
|
20962
20976
|
"aria-haspopup": "listbox",
|
|
20963
20977
|
"aria-labelledby": ariaLabelledby,
|
|
20978
|
+
"aria-describedby": ariaDescribedby,
|
|
20964
20979
|
"aria-expanded": isOpen,
|
|
20965
20980
|
autocomplete: autocompleteValue,
|
|
20966
20981
|
background: isOpen ? themeValues.hoverColor : WHITE,
|
|
@@ -21177,9 +21192,10 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
21177
21192
|
color: themeValues.labelColor,
|
|
21178
21193
|
weight: themeValues.fontWeight,
|
|
21179
21194
|
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
21180
|
-
id: labelTextWhenNoError
|
|
21195
|
+
id: createIdFromString(labelTextWhenNoError)
|
|
21181
21196
|
}, labelTextWhenNoError))), /*#__PURE__*/React.createElement(Dropdown$1, {
|
|
21182
|
-
ariaLabelledby: labelTextWhenNoError
|
|
21197
|
+
ariaLabelledby: createIdFromString(labelTextWhenNoError),
|
|
21198
|
+
ariaDescribedby: createIdFromString(labelTextWhenNoError, "error message"),
|
|
21183
21199
|
maxHeight: dropdownMaxHeight,
|
|
21184
21200
|
hasTitles: hasTitles,
|
|
21185
21201
|
placeholder: options[0] ? options[0].text : "",
|
|
@@ -21206,7 +21222,8 @@ var FormSelect = function FormSelect(_ref) {
|
|
|
21206
21222
|
color: ERROR_COLOR,
|
|
21207
21223
|
variant: "pXS",
|
|
21208
21224
|
weight: themeValues.fontWeight,
|
|
21209
|
-
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }"
|
|
21225
|
+
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
21226
|
+
id: createIdFromString(labelTextWhenNoError, "error message")
|
|
21210
21227
|
}, errorMessages[field.errors[0]]) : /*#__PURE__*/React.createElement(Text$1, {
|
|
21211
21228
|
extraStyles: "height: ".concat(themeValues.lineHeight, ";")
|
|
21212
21229
|
})));
|
|
@@ -22629,7 +22646,7 @@ var FormInput = function FormInput(_ref15) {
|
|
|
22629
22646
|
variant: "pS",
|
|
22630
22647
|
weight: themeValues.fontWeight,
|
|
22631
22648
|
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
22632
|
-
id: labelTextWhenNoError
|
|
22649
|
+
id: createIdFromString(labelTextWhenNoError)
|
|
22633
22650
|
}, labelTextWhenNoError), /*#__PURE__*/React.createElement(Text$1, {
|
|
22634
22651
|
color: themeValues.linkColor,
|
|
22635
22652
|
variant: "pS",
|
|
@@ -22646,7 +22663,7 @@ var FormInput = function FormInput(_ref15) {
|
|
|
22646
22663
|
variant: "pS",
|
|
22647
22664
|
fontWeight: themeValues.fontWeight,
|
|
22648
22665
|
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
22649
|
-
id: labelTextWhenNoError
|
|
22666
|
+
id: createIdFromString(labelTextWhenNoError)
|
|
22650
22667
|
}, labelTextWhenNoError), type === "password" && /*#__PURE__*/React.createElement(Text$1, {
|
|
22651
22668
|
variant: "pS",
|
|
22652
22669
|
color: themeValues.linkColor,
|
|
@@ -22666,7 +22683,9 @@ var FormInput = function FormInput(_ref15) {
|
|
|
22666
22683
|
}, decorator)))), /*#__PURE__*/React.createElement(Box, {
|
|
22667
22684
|
padding: "0"
|
|
22668
22685
|
}, formatter ? /*#__PURE__*/React.createElement(FormattedInputField, _extends({
|
|
22669
|
-
"aria-labelledby": labelTextWhenNoError
|
|
22686
|
+
"aria-labelledby": createIdFromString(labelTextWhenNoError),
|
|
22687
|
+
"aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
|
|
22688
|
+
"aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
|
|
22670
22689
|
onChange: function onChange(e) {
|
|
22671
22690
|
return fieldActions.set(e);
|
|
22672
22691
|
},
|
|
@@ -22682,7 +22701,9 @@ var FormInput = function FormInput(_ref15) {
|
|
|
22682
22701
|
$customHeight: customHeight,
|
|
22683
22702
|
$extraStyles: extraStyles
|
|
22684
22703
|
}, props)) : /*#__PURE__*/React.createElement(InputField, _extends({
|
|
22685
|
-
"aria-labelledby": labelTextWhenNoError
|
|
22704
|
+
"aria-labelledby": createIdFromString(labelTextWhenNoError),
|
|
22705
|
+
"aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
|
|
22706
|
+
"aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
|
|
22686
22707
|
onChange: function onChange(e) {
|
|
22687
22708
|
return fieldActions.set(e.target.value);
|
|
22688
22709
|
},
|
|
@@ -22704,7 +22725,8 @@ var FormInput = function FormInput(_ref15) {
|
|
|
22704
22725
|
color: ERROR_COLOR,
|
|
22705
22726
|
variant: "pXS",
|
|
22706
22727
|
weight: themeValues.fontWeight,
|
|
22707
|
-
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }"
|
|
22728
|
+
extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
|
|
22729
|
+
id: createIdFromString(labelTextWhenNoError, "error message")
|
|
22708
22730
|
}, errorMessages[field.errors[0]]) : /*#__PURE__*/React.createElement(Text$1, {
|
|
22709
22731
|
extraStyles: "height: ".concat(themeValues.lineHeight, ";")
|
|
22710
22732
|
}), !isMobile && decorator && /*#__PURE__*/React.createElement(Box, {
|
|
@@ -43289,6 +43311,9 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
|
|
|
43289
43311
|
time.timer = setTimeout(function () {
|
|
43290
43312
|
periscopeDataRequestFailure();
|
|
43291
43313
|
}, 10000);
|
|
43314
|
+
return function () {
|
|
43315
|
+
return clearTimeout(time.timer);
|
|
43316
|
+
};
|
|
43292
43317
|
}, []);
|
|
43293
43318
|
|
|
43294
43319
|
var Dashboard = function Dashboard(height) {
|
|
@@ -43309,8 +43334,11 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
|
|
|
43309
43334
|
var validatePeriscope = function validatePeriscope(message) {
|
|
43310
43335
|
if (isValidMessage(message)) {
|
|
43311
43336
|
setHeight(message.data.dashboard_height + 100);
|
|
43312
|
-
|
|
43313
|
-
|
|
43337
|
+
|
|
43338
|
+
if (!periscopeDataSuccess) {
|
|
43339
|
+
clearTimeout(time.timer);
|
|
43340
|
+
periscopeDataRequestSuccess();
|
|
43341
|
+
}
|
|
43314
43342
|
}
|
|
43315
43343
|
};
|
|
43316
43344
|
|
|
@@ -43619,13 +43647,27 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
43619
43647
|
fontWeights: style_constants
|
|
43620
43648
|
});
|
|
43621
43649
|
|
|
43650
|
+
var useFocusInvalidInput = function useFocusInvalidInput() {
|
|
43651
|
+
var showErrors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
43652
|
+
// Only move focus when "showErrors" is true
|
|
43653
|
+
// "showErrors" is managed by container page of form
|
|
43654
|
+
// typically set to "true" on attempted form submission, if errors exist
|
|
43655
|
+
useEffect$1(function () {
|
|
43656
|
+
if (showErrors) {
|
|
43657
|
+
var inputsWithErrors = document.querySelectorAll("input[aria-invalid=true]");
|
|
43658
|
+
console.log("inputs with errors...", inputsWithErrors);
|
|
43659
|
+
}
|
|
43660
|
+
}, [showErrors]);
|
|
43661
|
+
};
|
|
43662
|
+
|
|
43622
43663
|
|
|
43623
43664
|
|
|
43624
43665
|
var index$5 = /*#__PURE__*/Object.freeze({
|
|
43625
43666
|
__proto__: null,
|
|
43626
43667
|
formats: formats,
|
|
43627
43668
|
general: general,
|
|
43628
|
-
theme: themeUtils
|
|
43669
|
+
theme: themeUtils,
|
|
43670
|
+
useFocusInvalidInput: useFocusInvalidInput
|
|
43629
43671
|
});
|
|
43630
43672
|
|
|
43631
43673
|
export { AccountNumberImage, AccountsAddIcon$1 as AccountsAddIcon, AccountsIcon$1 as AccountsIcon, AccountsIconSmall$1 as AccountsIconSmall, AchReturnIcon, AddObligation$1 as AddObligation, AddressForm, Alert$1 as Alert, AllocatedIcon, AmountCallout$1 as AmountCallout, AutopayOnIcon, BankIcon, Box, BoxWithShadow$1 as BoxWithShadow, Breadcrumbs as Breadcrumb, ButtonWithAction, ButtonWithLink, CalendarIcon, CarrotIcon$1 as CarrotIcon, CashIcon, Center, CenterSingle$1 as CenterSingle, CenterStack$1 as CenterStack, ChangePasswordForm, ChargebackIcon, ChargebackReversalIcon, CheckIcon, Checkbox$1 as Checkbox, CheckboxList$1 as CheckboxList, CheckmarkIcon, ChevronIcon$1 as ChevronIcon, Cluster, CollapsibleSection$1 as CollapsibleSection, CountryDropdown, Cover, CustomerSearchIcon, DefaultPageTemplate, Detail$1 as Detail, DisplayBox$1 as DisplayBox, DisplayCard, Dropdown$1 as Dropdown, DuplicateIcon, EditNameForm, EditableList, EditableTable, EmailForm, EmptyCartIcon$1 as EmptyCartIcon, ErroredIcon, ExternalLink, FailedIcon, ForgotPasswordForm, ForgotPasswordIcon$1 as ForgotPasswordIcon, FormContainer$1 as FormContainer, FormFooterPanel$1 as FormFooterPanel, FormInput$1 as FormInput, FormInputColumn, FormInputRow, FormSelect$1 as FormSelect, FormattedAddress$1 as FormattedAddress, FormattedCreditCard$1 as FormattedCreditCard, Frame, GenericCard, GenericCardLarge, GoToEmailIcon$1 as GoToEmailIcon, Grid, HamburgerButton, Heading$1 as Heading, HighlightTabRow$1 as HighlightTabRow, IconAdd, IconQuitLarge, Imposter, InternalLink, InternalUserInfoForm, Jumbo$1 as Jumbo, LabeledAmount$1 as LabeledAmount, LineItem$1 as LineItem, Loading, LoginForm, Modal$1 as Modal, Module$1 as Module, Motion, NavFooter, NavHeader, NavMenuDesktop$1 as NavMenuDesktop, NavMenuMobile$1 as NavMenuMobile, NoCustomerResultsIcon, NoPaymentResultsIcon, NotFoundIcon, Obligation, iconsMap as ObligationIcons, Pagination, Paragraph$1 as Paragraph, PartialAmountForm, PasswordRequirements, PaymentButtonBar, PaymentDetails$1 as PaymentDetails, PaymentFormACH, PaymentFormCard$1 as PaymentFormCard, PaymentIcon, PaymentMethodAddIcon$1 as PaymentMethodAddIcon, PaymentMethodIcon$1 as PaymentMethodIcon, PaymentSearchIcon, PaymentsIconSmall$1 as PaymentsIconSmall, PendingIcon, PeriscopeDashboardIframe, PeriscopeFailedIcon, PhoneForm, Placeholder$1 as Placeholder, ProcessingFee$1 as ProcessingFee, ProfileIcon$1 as ProfileIcon, ProfileIconSmall$1 as ProfileIconSmall, PropertiesAddIcon$1 as PropertiesAddIcon, PropertiesIconSmall$1 as PropertiesIconSmall, RadioButton$2 as RadioButton, RadioSection$1 as RadioSection, Reel, RefundIcon, RegistrationForm, RejectedIcon, RejectedVelocityIcon, ResetConfirmationForm$1 as ResetConfirmationForm, ResetPasswordForm, ResetPasswordIcon, ResetPasswordSuccess, RoutingNumberImage, SearchIcon, SearchableSelect$1 as SearchableSelect, SettingsIconSmall$1 as SettingsIconSmall, ShoppingCartIcon, Sidebar, SidebarSingleContent$1 as SidebarSingleContent, SidebarStackContent$1 as SidebarStackContent, SolidDivider$1 as SolidDivider, Spinner$2 as Spinner, Stack, FormStateDropdown as StateProvinceDropdown, StatusUnknownIcon, SuccessfulIcon, Switcher, TabSidebar$1 as TabSidebar, TableListItem, Tabs$1 as Tabs, TermsAndConditions, TermsAndConditionsModal$1 as TermsAndConditionsModal, Text$1 as Text, Timeout$1 as Timeout, TimeoutImage, Title$1 as Title, ToggleSwitch$1 as ToggleSwitch, TrashIcon$1 as TrashIcon, TypeaheadInput, VerifiedEmailIcon$1 as VerifiedEmailIcon, VoidedIcon, WalletIcon$1 as WalletIcon, WarningIconXS, WelcomeModule$1 as WelcomeModule, WorkflowTile, cardRegistry, index$4 as constants, createPartialAmountFormState, index$5 as util, withWindowSize };
|