@thecb/components 9.3.0-beta.2 → 9.3.0

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 (75) hide show
  1. package/dist/index.cjs.js +840 -617
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +171 -60
  4. package/dist/index.esm.js +837 -617
  5. package/dist/index.esm.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/.DS_Store +0 -0
  8. package/src/components/atoms/button-with-action/ButtonWithAction.js +76 -70
  9. package/src/components/atoms/checkbox/Checkbox.js +9 -4
  10. package/src/components/atoms/checkbox/Checkbox.stories.js +3 -3
  11. package/src/components/atoms/country-dropdown/CountryDropdown.js +2 -2
  12. package/src/components/atoms/country-dropdown/CountryDropdown.stories.js +0 -1
  13. package/src/components/atoms/dropdown/Dropdown.js +77 -44
  14. package/src/components/atoms/dropdown/Dropdown.theme.js +8 -2
  15. package/src/components/atoms/form-layouts/FormInput.js +2 -3
  16. package/src/components/atoms/form-select/FormSelect.js +25 -34
  17. package/src/components/atoms/form-select/FormSelect.stories.js +2 -2
  18. package/src/components/atoms/icons/AccountNumberImage.js +2 -0
  19. package/src/components/atoms/icons/BankIcon.js +2 -0
  20. package/src/components/atoms/icons/CheckmarkIcon.js +2 -0
  21. package/src/components/atoms/icons/GenericCard.js +2 -0
  22. package/src/components/atoms/icons/GenericCardLarge.js +2 -0
  23. package/src/components/atoms/icons/KebabMenuIcon.d.ts +1 -0
  24. package/src/components/atoms/icons/KebabMenuIcon.js +38 -0
  25. package/src/components/atoms/icons/RoutingNumberImage.js +2 -0
  26. package/src/components/atoms/icons/TrashIcon.js +42 -40
  27. package/src/components/atoms/icons/icons.stories.js +3 -1
  28. package/src/components/atoms/icons/index.d.ts +1 -0
  29. package/src/components/atoms/icons/index.js +3 -1
  30. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +0 -1
  31. package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.stories.js +0 -1
  32. package/src/components/molecules/address-form/AddressForm.js +1 -2
  33. package/src/components/molecules/email-form/EmailForm.js +3 -1
  34. package/src/components/molecules/index.d.ts +1 -0
  35. package/src/components/molecules/index.js +1 -0
  36. package/src/components/molecules/modal/Modal.js +2 -1
  37. package/src/components/molecules/payment-form-ach/PaymentFormACH.js +4 -5
  38. package/src/components/molecules/payment-form-card/PaymentFormCard.js +0 -2
  39. package/src/components/molecules/phone-form/PhoneForm.js +3 -1
  40. package/src/components/molecules/popover/Popover.js +1 -1
  41. package/src/components/molecules/popup-menu/PopupMenu.js +152 -0
  42. package/src/components/molecules/popup-menu/PopupMenu.stories.js +40 -0
  43. package/src/components/molecules/popup-menu/PopupMenu.styled.js +20 -0
  44. package/src/components/molecules/popup-menu/PopupMenu.theme.js +11 -0
  45. package/src/components/molecules/popup-menu/index.d.ts +25 -0
  46. package/src/components/molecules/popup-menu/index.js +3 -0
  47. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.js +79 -0
  48. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.styled.js +27 -0
  49. package/src/components/molecules/popup-menu/popup-menu-item/PopupMenuItem.theme.js +23 -0
  50. package/src/components/molecules/radio-section/RadioSection.js +10 -4
  51. package/src/components/molecules/radio-section/RadioSection.stories.js +1 -0
  52. package/src/components/molecules/radio-section/radio-button/RadioButton.js +2 -3
  53. package/src/components/molecules/terms-and-conditions/TermsAndConditions.stories.js +3 -1
  54. package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV1.js +0 -1
  55. package/src/components/molecules/terms-and-conditions/TermsAndConditionsControlV2.js +5 -2
  56. package/src/components/molecules/toast-notification/ToastNotification.js +75 -0
  57. package/src/components/molecules/toast-notification/ToastNotification.stories.js +67 -0
  58. package/src/components/molecules/toast-notification/index.d.ts +18 -0
  59. package/src/components/molecules/toast-notification/index.js +3 -0
  60. package/src/constants/colors.d.ts +1 -0
  61. package/src/constants/colors.js +5 -1
  62. package/src/hooks/index.js +3 -0
  63. package/src/hooks/use-toast-notification/index.d.ts +23 -0
  64. package/src/hooks/use-toast-notification/index.js +38 -0
  65. package/src/index.d.ts +2 -1
  66. package/src/index.js +2 -1
  67. package/src/types/common/ToastVariants.ts +6 -0
  68. package/src/types/common/index.ts +1 -0
  69. package/src/util/index.js +10 -2
  70. package/dist/src/apps/checkout/pages/payment/sub-pages/payment-amount/PaymentAmount_old.js +0 -49322
  71. package/src/components/.DS_Store +0 -0
  72. package/src/components/atoms/.DS_Store +0 -0
  73. package/src/components/atoms/icons/.DS_Store +0 -0
  74. /package/src/{util/useOutsideClick.js → hooks/use-outside-click/index.js} +0 -0
  75. /package/src/{util/useScrollTo.js → hooks/use-scroll-to/index.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -99,6 +99,7 @@ declare const COSMOS_RED: Color;
99
99
  declare const BLUSH_RED: Color;
100
100
 
101
101
  declare const ERROR_COLOR: Color;
102
+ declare const ERROR_BACKGROUND_COLOR: Color;
102
103
 
103
104
  declare const ALERT_COLORS: {
104
105
  warn: ColorSet;
@@ -203,6 +204,7 @@ declare const colors_d_FANTASY_RED: typeof FANTASY_RED;
203
204
  declare const colors_d_COSMOS_RED: typeof COSMOS_RED;
204
205
  declare const colors_d_BLUSH_RED: typeof BLUSH_RED;
205
206
  declare const colors_d_ERROR_COLOR: typeof ERROR_COLOR;
207
+ declare const colors_d_ERROR_BACKGROUND_COLOR: typeof ERROR_BACKGROUND_COLOR;
206
208
  declare const colors_d_ALERT_COLORS: typeof ALERT_COLORS;
207
209
  declare const colors_d_PILL_COLORS: typeof PILL_COLORS;
208
210
  declare namespace colors_d {
@@ -282,6 +284,7 @@ declare namespace colors_d {
282
284
  colors_d_COSMOS_RED as COSMOS_RED,
283
285
  colors_d_BLUSH_RED as BLUSH_RED,
284
286
  colors_d_ERROR_COLOR as ERROR_COLOR,
287
+ colors_d_ERROR_BACKGROUND_COLOR as ERROR_BACKGROUND_COLOR,
285
288
  colors_d_ALERT_COLORS as ALERT_COLORS,
286
289
  colors_d_PILL_COLORS as PILL_COLORS,
287
290
  };
@@ -295,6 +298,155 @@ declare namespace index_d {
295
298
  };
296
299
  }
297
300
 
301
+ /*
302
+ Hook that assigns a click event listener to the main document element
303
+ Returns a ref to attach to another element (like an icon/button that triggers a popover)
304
+ If a click event gets captured by the document and the assigned element isn't the target
305
+ hook will run whatever handler is passed (eg a function that closes a popover)
306
+
307
+ See popover component for implementation
308
+
309
+ */
310
+
311
+ declare const useOutsideClickHook = handler => {
312
+ const ref = useRef();
313
+
314
+ useEffect(() => {
315
+ const handleOutsideClick = e => {
316
+ if (ref.current && !ref.current.contains(e.target)) {
317
+ handler();
318
+ }
319
+
320
+ document.addEventListener("click", handleOutsideClick, true);
321
+
322
+ return () => {
323
+ document.removeEventListener("click", handleOutsideClick, true);
324
+ };
325
+ };
326
+ }, [ref]);
327
+
328
+ return ref;
329
+ };
330
+
331
+ /*
332
+ Hook that takes an ID selector for an element on the screen
333
+ And optionally values for top position, left position, smooth behavior
334
+ Finds element on screen and scrolls it to the provided coordinates
335
+
336
+ (string, number, number, string, number) => undefined;
337
+ */
338
+
339
+ declare const useScrollTo = (id, top = 0, left = 0, behavior = "auto", delay) => {
340
+ let scrollItem;
341
+ if (delay) {
342
+ setTimeout(() => {
343
+ scrollItem = document.getElementById(id);
344
+ scrollItem?.scrollTo({ top, left, behavior });
345
+ }, delay);
346
+ } else {
347
+ scrollItem = document.getElementById(id);
348
+ scrollItem?.scrollTo({ top, left, behavior });
349
+ }
350
+ };
351
+
352
+ interface Field {
353
+ hasErrors: boolean;
354
+ dirty: boolean;
355
+ rawValue: string;
356
+ }
357
+
358
+ interface ReduxAction<T = string, P = {}> {
359
+ type: T;
360
+ payload?: P;
361
+ }
362
+
363
+ /**
364
+ * These types should be moved to and referenced from redux-freeform if it implements TypeScript
365
+ */
366
+
367
+ type ValidatorFn = (value: string) => boolean;
368
+
369
+ interface FieldActionPayload {
370
+ fieldName: string;
371
+ value?: string;
372
+ validator?: ValidatorFn;
373
+ }
374
+
375
+ type SetAction = ReduxAction<"field/SET", FieldActionPayload>;
376
+ type AddValidatorAction = ReduxAction<
377
+ "field/ADD_VALIDATOR",
378
+ FieldActionPayload
379
+ >;
380
+ type RemoveValidatorAction = ReduxAction<
381
+ "field/REMOVE_VALIDATOR",
382
+ FieldActionPayload
383
+ >;
384
+ type ClearAction = ReduxAction<"field/CLEAR">;
385
+
386
+ interface FieldActions {
387
+ set?: (fieldName: string) => (value: string) => SetAction;
388
+ addValidator?: (
389
+ fieldName: string
390
+ ) => (validator: ValidatorFn) => AddValidatorAction;
391
+ removeValidator?: (
392
+ fieldName: string
393
+ ) => (validator: ValidatorFn) => RemoveValidatorAction;
394
+ clear?: () => ClearAction;
395
+ }
396
+
397
+ interface FormSelectOption {
398
+ text?: string;
399
+ value?: string;
400
+ }
401
+
402
+ interface SearchableSelectOption {
403
+ name?: string;
404
+ value?: string;
405
+ }
406
+
407
+ interface ErrorMessageDictionary {
408
+ [fieldName: string]: string;
409
+ }
410
+
411
+ enum ToastVariants {
412
+ ERROR = "error",
413
+ SUCCESS = "success"
414
+ }
415
+
416
+ interface UseToastOptions {
417
+ timeout?: number;
418
+ }
419
+
420
+ interface UseToastResult {
421
+ isToastOpen: boolean;
422
+ toastVariant: string | ToastVariants;
423
+ toastMessage: string;
424
+ showToast: ({
425
+ message,
426
+ variant
427
+ }: {
428
+ message: string;
429
+ variant: string | ToastVariants;
430
+ }) => void;
431
+ hideToast: () => void;
432
+ }
433
+
434
+ declare function useToastNotification(
435
+ options?: UseToastOptions
436
+ ): UseToastResult;
437
+
438
+
439
+
440
+ declare const index_useScrollTo: typeof useScrollTo;
441
+ declare const index_useToastNotification: typeof useToastNotification;
442
+ declare namespace index {
443
+ export {
444
+ useOutsideClickHook as useOutsideClick,
445
+ index_useScrollTo as useScrollTo,
446
+ index_useToastNotification as useToastNotification,
447
+ };
448
+ }
449
+
298
450
  type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
299
451
 
300
452
  interface AlertProps {
@@ -379,65 +531,6 @@ interface CardProps {
379
531
  declare const Card: React.FC<Expand<CardProps> &
380
532
  React.HTMLAttributes<HTMLElement>>;
381
533
 
382
- interface Field {
383
- hasErrors: boolean;
384
- dirty: boolean;
385
- rawValue: string;
386
- }
387
-
388
- interface ReduxAction<T = string, P = {}> {
389
- type: T;
390
- payload?: P;
391
- }
392
-
393
- /**
394
- * These types should be moved to and referenced from redux-freeform if it implements TypeScript
395
- */
396
-
397
- type ValidatorFn = (value: string) => boolean;
398
-
399
- interface FieldActionPayload {
400
- fieldName: string;
401
- value?: string;
402
- validator?: ValidatorFn;
403
- }
404
-
405
- type SetAction = ReduxAction<"field/SET", FieldActionPayload>;
406
- type AddValidatorAction = ReduxAction<
407
- "field/ADD_VALIDATOR",
408
- FieldActionPayload
409
- >;
410
- type RemoveValidatorAction = ReduxAction<
411
- "field/REMOVE_VALIDATOR",
412
- FieldActionPayload
413
- >;
414
- type ClearAction = ReduxAction<"field/CLEAR">;
415
-
416
- interface FieldActions {
417
- set?: (fieldName: string) => (value: string) => SetAction;
418
- addValidator?: (
419
- fieldName: string
420
- ) => (validator: ValidatorFn) => AddValidatorAction;
421
- removeValidator?: (
422
- fieldName: string
423
- ) => (validator: ValidatorFn) => RemoveValidatorAction;
424
- clear?: () => ClearAction;
425
- }
426
-
427
- interface FormSelectOption {
428
- text?: string;
429
- value?: string;
430
- }
431
-
432
- interface SearchableSelectOption {
433
- name?: string;
434
- value?: string;
435
- }
436
-
437
- interface ErrorMessageDictionary {
438
- [fieldName: string]: string;
439
- }
440
-
441
534
  interface FormInputProps {
442
535
  extraStyles?: string;
443
536
  field?: Field;
@@ -638,6 +731,8 @@ interface XCircleIconSmallProps {
638
731
  declare const XCircleIconSmall: React.FC<Expand<XCircleIconSmallProps> &
639
732
  React.HTMLAttributes<HTMLElement>>;
640
733
 
734
+ declare const KebabMenuIcon: JSX.Element;
735
+
641
736
  interface BoxProps {
642
737
  autocompleteValue?: string;
643
738
  padding?: string;
@@ -1062,6 +1157,22 @@ interface RadioGroupProps {
1062
1157
  declare const RadioGroup: React.FC<Expand<RadioGroupProps> &
1063
1158
  React.HTMLAttributes<HTMLElement>>;
1064
1159
 
1160
+ interface ToastNotificationProps {
1161
+ variant?: string;
1162
+ message: string;
1163
+ toastOpen: boolean;
1164
+ closeToastNotification: (event?: React.MouseEvent<HTMLElement>) => void;
1165
+ extraStyles?: string;
1166
+ minWidth?: string;
1167
+ maxWidth?: string;
1168
+ height?: string;
1169
+ childGap?: string;
1170
+ backgroundColor?: string;
1171
+ }
1172
+
1173
+ declare const ToastNotification: React.FC<Expand<ToastNotificationProps> &
1174
+ React.HTMLAttributes<HTMLElement>>;
1175
+
1065
1176
  interface DefaultPageTemplateProps {
1066
1177
  content: JSX.Element;
1067
1178
  header?: JSX.Element;
@@ -1076,5 +1187,5 @@ interface DefaultPageTemplateProps {
1076
1187
  declare const DefaultPageTemplate: React.FC<Expand<DefaultPageTemplateProps> &
1077
1188
  React.HTMLAttributes<HTMLElement>>;
1078
1189
 
1079
- export { AddValidatorAction, Alert, AlertProps, ArrowDownCircleIconSmall, ArrowDownCircleIconSmallProps, ArrowLeftCircleIconMedium, ArrowLeftCircleIconMediumProps, ArrowLeftCircleIconSmall, ArrowLeftCircleIconSmallProps, ArrowRightCircleIconSmall, ArrowRightCircleIconSmallProps, ArrowUpCircleIconSmall, ArrowUpCircleIconSmallProps, BankIconLarge, BankIconLargeProps, Box, BoxProps, ButtonWithAction, ButtonWithActionProps, ButtonWithLink, ButtonWithLinkProps, Card, CardProps, Center, CenterProps, ChargebackIconMedium, ChargebackIconMediumProps, ChargebackIconSmall, ChargebackIconSmallProps, ChargebackReversalIconMedium, ChargebackReversalIconMediumProps, ChargebackReversalIconSmall, ChargebackReversalIconSmallProps, ClearAction, Cluster, ClusterProps, CollapsibleSection, CollapsibleSectionProps, Copyable, CopyableProps, Cover, CoverProps, DefaultPageTemplate, DefaultPageTemplateProps, EditableTable, EditableTableProps, ErrorMessageDictionary, ExternalLink, ExternalLinkProps, Field, FieldActionPayload, FieldActions, FooterWithSubfooter, FooterWithSubfooterProps, FormInput, FormInputProps, FormSelect, FormSelectOption, FormSelectProps, GuidedCheckoutImage, HistoryIconSmall, InternalLink, InternalLinkProps, KioskImage, Loading, LoadingProps, NavFooter, NavFooterProps, NavHeader, NavHeaderProps, NavTabs, NavTabsProps, Paragraph, ParagraphProps, PointOfSaleImage, Popover, PopoverProps, ProfileImage, RadioGroup, RadioGroupProps, ReduxAction, RefundIconMedium, RefundIconMediumProps, RefundIconSmall, RefundIconSmallProps, RemoveValidatorAction, RevenueManagementImage, SearchableSelect, SearchableSelectOption, SearchableSelectProps, SetAction, Spinner, SpinnerProps, Stack, StackProps, StandardCheckoutImage, SuccessfulIconMedium, SuccessfulIconMediumProps, SuccessfulIconSmall, SuccessfulIconSmallProps, Switcher, SwitcherProps, Table, TableBody, TableBodyProps, TableCell, TableCellProps, TableHead, TableHeadProps, TableHeading, TableHeadingProps, TableListItem, TableListItemProps, TableProps, TableRow, TableRowProps, Text, TextProps, Title, TitleProps, ValidatorFn, XCircleIconMedium, XCircleIconMediumProps, XCircleIconSmall, XCircleIconSmallProps, index_d as constants };
1190
+ export { AddValidatorAction, Alert, AlertProps, ArrowDownCircleIconSmall, ArrowDownCircleIconSmallProps, ArrowLeftCircleIconMedium, ArrowLeftCircleIconMediumProps, ArrowLeftCircleIconSmall, ArrowLeftCircleIconSmallProps, ArrowRightCircleIconSmall, ArrowRightCircleIconSmallProps, ArrowUpCircleIconSmall, ArrowUpCircleIconSmallProps, BankIconLarge, BankIconLargeProps, Box, BoxProps, ButtonWithAction, ButtonWithActionProps, ButtonWithLink, ButtonWithLinkProps, Card, CardProps, Center, CenterProps, ChargebackIconMedium, ChargebackIconMediumProps, ChargebackIconSmall, ChargebackIconSmallProps, ChargebackReversalIconMedium, ChargebackReversalIconMediumProps, ChargebackReversalIconSmall, ChargebackReversalIconSmallProps, ClearAction, Cluster, ClusterProps, CollapsibleSection, CollapsibleSectionProps, Copyable, CopyableProps, Cover, CoverProps, DefaultPageTemplate, DefaultPageTemplateProps, EditableTable, EditableTableProps, ErrorMessageDictionary, ExternalLink, ExternalLinkProps, Field, FieldActionPayload, FieldActions, FooterWithSubfooter, FooterWithSubfooterProps, FormInput, FormInputProps, FormSelect, FormSelectOption, FormSelectProps, GuidedCheckoutImage, HistoryIconSmall, InternalLink, InternalLinkProps, KebabMenuIcon, KioskImage, Loading, LoadingProps, NavFooter, NavFooterProps, NavHeader, NavHeaderProps, NavTabs, NavTabsProps, Paragraph, ParagraphProps, PointOfSaleImage, Popover, PopoverProps, ProfileImage, RadioGroup, RadioGroupProps, ReduxAction, RefundIconMedium, RefundIconMediumProps, RefundIconSmall, RefundIconSmallProps, RemoveValidatorAction, RevenueManagementImage, SearchableSelect, SearchableSelectOption, SearchableSelectProps, SetAction, Spinner, SpinnerProps, Stack, StackProps, StandardCheckoutImage, SuccessfulIconMedium, SuccessfulIconMediumProps, SuccessfulIconSmall, SuccessfulIconSmallProps, Switcher, SwitcherProps, Table, TableBody, TableBodyProps, TableCell, TableCellProps, TableHead, TableHeadProps, TableHeading, TableHeadingProps, TableListItem, TableListItemProps, TableProps, TableRow, TableRowProps, Text, TextProps, Title, TitleProps, ToastNotification, ToastNotificationProps, ToastVariants, ValidatorFn, XCircleIconMedium, XCircleIconMediumProps, XCircleIconSmall, XCircleIconSmallProps, index_d as constants, index as hooks };
1080
1191
  //# sourceMappingURL=index.d.ts.map