@onewelcome/react-lib-components 12.1.0-alpha.4 → 13.0.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 (203) hide show
  1. package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.cjs.js +2 -2
  2. package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.es.js +5 -5
  3. package/dist/components/Button/BaseButton.module.scss.cjs.js +2 -2
  4. package/dist/components/Button/BaseButton.module.scss.es.js +4 -4
  5. package/dist/components/Button/Button.module.scss.cjs.js +2 -2
  6. package/dist/components/Button/Button.module.scss.es.js +17 -17
  7. package/dist/components/Button/IconButton.module.scss.cjs.js +2 -2
  8. package/dist/components/Button/IconButton.module.scss.es.js +18 -18
  9. package/dist/components/ContextMenu/ContextMenu.module.scss.cjs.js +2 -2
  10. package/dist/components/ContextMenu/ContextMenu.module.scss.es.js +6 -6
  11. package/dist/components/ContextMenu/ContextMenuDivider.module.scss.cjs.js +2 -2
  12. package/dist/components/ContextMenu/ContextMenuDivider.module.scss.es.js +2 -2
  13. package/dist/components/ContextMenu/ContextMenuItem.module.scss.cjs.js +2 -2
  14. package/dist/components/ContextMenu/ContextMenuItem.module.scss.es.js +3 -3
  15. package/dist/components/DataGrid/DataGrid.module.scss.cjs.js +2 -2
  16. package/dist/components/DataGrid/DataGrid.module.scss.es.js +6 -6
  17. package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.cjs.js +2 -2
  18. package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.es.js +6 -6
  19. package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.cjs.js +2 -2
  20. package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.es.js +7 -7
  21. package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.cjs.js +2 -2
  22. package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.es.js +2 -2
  23. package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.cjs.js +2 -2
  24. package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.es.js +5 -5
  25. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.cjs.js +2 -2
  26. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.es.js +4 -4
  27. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.cjs.js +2 -2
  28. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.es.js +5 -5
  29. package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.cjs.js +2 -2
  30. package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.es.js +24 -24
  31. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.cjs.js +2 -2
  32. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.es.js +9 -9
  33. package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.cjs.js +2 -2
  34. package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.es.js +8 -8
  35. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js +2 -2
  36. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.es.js +17 -17
  37. package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.cjs.js +2 -2
  38. package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.es.js +3 -3
  39. package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.cjs.js +2 -2
  40. package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.es.js +7 -7
  41. package/dist/components/DatePicker/DatePicker.module.scss.cjs.js +2 -2
  42. package/dist/components/DatePicker/DatePicker.module.scss.es.js +31 -31
  43. package/dist/components/Form/Checkbox/Checkbox.module.scss.cjs.js +2 -2
  44. package/dist/components/Form/Checkbox/Checkbox.module.scss.es.js +13 -13
  45. package/dist/components/Form/Fieldset/Fieldset.module.scss.cjs.js +2 -2
  46. package/dist/components/Form/Fieldset/Fieldset.module.scss.es.js +5 -5
  47. package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.cjs.js +2 -2
  48. package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.es.js +18 -18
  49. package/dist/components/Form/FileUpload/FileUpload.module.scss.cjs.js +2 -2
  50. package/dist/components/Form/FileUpload/FileUpload.module.scss.es.js +16 -16
  51. package/dist/components/Form/Form.module.scss.cjs.js +2 -2
  52. package/dist/components/Form/Form.module.scss.es.js +2 -2
  53. package/dist/components/Form/FormControl/FormControl.module.scss.cjs.js +2 -2
  54. package/dist/components/Form/FormControl/FormControl.module.scss.es.js +13 -13
  55. package/dist/components/Form/FormErrorText/FormErrorText.module.scss.cjs.js +2 -2
  56. package/dist/components/Form/FormErrorText/FormErrorText.module.scss.es.js +5 -5
  57. package/dist/components/Form/FormGroup/FormGroup.module.scss.cjs.js +2 -2
  58. package/dist/components/Form/FormGroup/FormGroup.module.scss.es.js +3 -3
  59. package/dist/components/Form/FormHelperText/FormHelperText.module.scss.cjs.js +2 -2
  60. package/dist/components/Form/FormHelperText/FormHelperText.module.scss.es.js +4 -4
  61. package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.cjs.js +2 -2
  62. package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.es.js +6 -6
  63. package/dist/components/Form/Input/Input.module.scss.cjs.js +2 -2
  64. package/dist/components/Form/Input/Input.module.scss.es.js +9 -9
  65. package/dist/components/Form/Label/Label.module.scss.cjs.js +2 -2
  66. package/dist/components/Form/Label/Label.module.scss.es.js +2 -2
  67. package/dist/components/Form/Radio/Radio.module.scss.cjs.js +2 -2
  68. package/dist/components/Form/Radio/Radio.module.scss.es.js +11 -11
  69. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.cjs.js +2 -2
  70. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.es.js +15 -15
  71. package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.cjs.js +2 -2
  72. package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.es.js +2 -2
  73. package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.cjs.js +2 -2
  74. package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.es.js +4 -4
  75. package/dist/components/Form/Select/SingleSelect/Select.module.scss.cjs.js +2 -2
  76. package/dist/components/Form/Select/SingleSelect/Select.module.scss.es.js +17 -17
  77. package/dist/components/Form/Select/useAddNewBtn.module.scss.cjs.js +2 -2
  78. package/dist/components/Form/Select/useAddNewBtn.module.scss.es.js +4 -4
  79. package/dist/components/Form/Textarea/Textarea.module.scss.cjs.js +2 -2
  80. package/dist/components/Form/Textarea/Textarea.module.scss.es.js +6 -6
  81. package/dist/components/Form/Toggle/Toggle.module.scss.cjs.js +2 -2
  82. package/dist/components/Form/Toggle/Toggle.module.scss.es.js +18 -18
  83. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.cjs.js +2 -2
  84. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.es.js +3 -3
  85. package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.cjs.js +2 -2
  86. package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.es.js +4 -4
  87. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.cjs.js +2 -2
  88. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.es.js +3 -3
  89. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.cjs.js +2 -2
  90. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.es.js +3 -3
  91. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.cjs.js +2 -2
  92. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.es.js +3 -3
  93. package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.cjs.js +2 -2
  94. package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.es.js +8 -8
  95. package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.cjs.js +2 -2
  96. package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.es.js +6 -6
  97. package/dist/components/Icon/Icon.module.scss.cjs.js +2 -2
  98. package/dist/components/Icon/Icon.module.scss.es.js +107 -107
  99. package/dist/components/Layout/Card/Card.module.scss.cjs.js +2 -2
  100. package/dist/components/Layout/Card/Card.module.scss.es.js +12 -12
  101. package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.cjs.js +2 -2
  102. package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.es.js +12 -12
  103. package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.cjs.js +2 -2
  104. package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.es.js +4 -4
  105. package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.cjs.js +2 -2
  106. package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.es.js +2 -2
  107. package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.cjs.js +2 -2
  108. package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.es.js +3 -3
  109. package/dist/components/Link/Link.module.scss.cjs.js +2 -2
  110. package/dist/components/Link/Link.module.scss.es.js +17 -17
  111. package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.cjs.js +2 -2
  112. package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.es.js +11 -11
  113. package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.cjs.js +2 -2
  114. package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.es.js +22 -22
  115. package/dist/components/Notifications/Banner/Banner.module.scss.cjs.js +2 -2
  116. package/dist/components/Notifications/Banner/Banner.module.scss.es.js +9 -9
  117. package/dist/components/Notifications/BaseModal/BaseModal.module.scss.cjs.js +2 -2
  118. package/dist/components/Notifications/BaseModal/BaseModal.module.scss.es.js +5 -5
  119. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.cjs.js +2 -2
  120. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.es.js +4 -4
  121. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.cjs.js +2 -2
  122. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.es.js +2 -2
  123. package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.cjs.js +2 -2
  124. package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.es.js +6 -6
  125. package/dist/components/Notifications/Dialog/Dialog.module.scss.cjs.js +2 -2
  126. package/dist/components/Notifications/Dialog/Dialog.module.scss.es.js +4 -4
  127. package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.cjs.js +2 -2
  128. package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.es.js +3 -3
  129. package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.cjs.js +2 -2
  130. package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.es.js +10 -10
  131. package/dist/components/Notifications/SideSheet/SideSheet.module.scss.cjs.js +2 -2
  132. package/dist/components/Notifications/SideSheet/SideSheet.module.scss.es.js +13 -13
  133. package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js +2 -2
  134. package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.es.js +2 -2
  135. package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js +2 -2
  136. package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.es.js +2 -2
  137. package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.cjs.js +2 -2
  138. package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.es.js +10 -10
  139. package/dist/components/Pagination/Pagination.module.scss.cjs.js +2 -2
  140. package/dist/components/Pagination/Pagination.module.scss.es.js +14 -14
  141. package/dist/components/Popover/Popover.module.scss.cjs.js +2 -2
  142. package/dist/components/Popover/Popover.module.scss.es.js +3 -3
  143. package/dist/components/ProgressBar/ProgressBar.module.scss.cjs.js +2 -2
  144. package/dist/components/ProgressBar/ProgressBar.module.scss.es.js +9 -9
  145. package/dist/components/Skeleton/Skeleton.module.scss.cjs.js +2 -2
  146. package/dist/components/Skeleton/Skeleton.module.scss.es.js +5 -5
  147. package/dist/components/Spinner/Spinner.module.scss.cjs.js +2 -2
  148. package/dist/components/Spinner/Spinner.module.scss.es.js +3 -3
  149. package/dist/components/Stepper/Step.module.scss.cjs.js +2 -2
  150. package/dist/components/Stepper/Step.module.scss.es.js +22 -22
  151. package/dist/components/Stepper/Stepper.module.scss.cjs.js +2 -2
  152. package/dist/components/Stepper/Stepper.module.scss.es.js +4 -4
  153. package/dist/components/Tabs/Tab.module.scss.cjs.js +2 -2
  154. package/dist/components/Tabs/Tab.module.scss.es.js +3 -3
  155. package/dist/components/Tabs/TabButton.module.scss.cjs.js +2 -2
  156. package/dist/components/Tabs/TabButton.module.scss.es.js +12 -12
  157. package/dist/components/Tabs/Tabs.module.scss.cjs.js +2 -2
  158. package/dist/components/Tabs/Tabs.module.scss.es.js +10 -10
  159. package/dist/components/Tag/RemoveButton.module.scss.cjs.js +2 -2
  160. package/dist/components/Tag/RemoveButton.module.scss.es.js +3 -3
  161. package/dist/components/Tag/Tag.module.scss.cjs.js +2 -2
  162. package/dist/components/Tag/Tag.module.scss.es.js +6 -6
  163. package/dist/components/TextEllipsis/TextEllipsis.module.scss.cjs.js +2 -2
  164. package/dist/components/TextEllipsis/TextEllipsis.module.scss.es.js +3 -3
  165. package/dist/components/Tiles/Tile.module.scss.cjs.js +2 -2
  166. package/dist/components/Tiles/Tile.module.scss.es.js +8 -8
  167. package/dist/components/Tiles/Tiles.module.scss.cjs.js +2 -2
  168. package/dist/components/Tiles/Tiles.module.scss.es.js +2 -2
  169. package/dist/components/Tooltip/Tooltip.module.scss.cjs.js +2 -2
  170. package/dist/components/Tooltip/Tooltip.module.scss.es.js +27 -27
  171. package/dist/components/Typography/Typography.module.scss.cjs.js +2 -2
  172. package/dist/components/Typography/Typography.module.scss.es.js +13 -13
  173. package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.cjs.js +2 -2
  174. package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.es.js +5 -5
  175. package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.cjs.js +2 -2
  176. package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.es.js +14 -14
  177. package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.cjs.js +2 -2
  178. package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.es.js +3 -3
  179. package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.cjs.js +2 -2
  180. package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.es.js +7 -7
  181. package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.cjs.js +2 -2
  182. package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.es.js +13 -13
  183. package/dist/components/miscellaneous/IdentityProviderButton.module.scss.cjs.js +2 -2
  184. package/dist/components/miscellaneous/IdentityProviderButton.module.scss.es.js +3 -3
  185. package/dist/index.cjs.js +1 -1
  186. package/dist/index.d.ts +0 -75
  187. package/dist/index.es.js +0 -3
  188. package/dist/index.es.js.map +1 -1
  189. package/dist/readyclasses.module.scss.cjs.js +2 -2
  190. package/dist/readyclasses.module.scss.es.js +5 -5
  191. package/dist/util/helper.cjs.js +1 -1
  192. package/dist/util/helper.cjs.js.map +1 -1
  193. package/dist/util/helper.es.js +0 -17
  194. package/dist/util/helper.es.js.map +1 -1
  195. package/package.json +1 -1
  196. package/dist/components/Notifications/NotificationProvider/NotificationContext.cjs.js +0 -2
  197. package/dist/components/Notifications/NotificationProvider/NotificationContext.cjs.js.map +0 -1
  198. package/dist/components/Notifications/NotificationProvider/NotificationContext.es.js +0 -146
  199. package/dist/components/Notifications/NotificationProvider/NotificationContext.es.js.map +0 -1
  200. package/dist/components/Notifications/NotificationProvider/NotificationService.cjs.js +0 -2
  201. package/dist/components/Notifications/NotificationProvider/NotificationService.cjs.js.map +0 -1
  202. package/dist/components/Notifications/NotificationProvider/NotificationService.es.js +0 -19
  203. package/dist/components/Notifications/NotificationProvider/NotificationService.es.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -42,13 +42,6 @@ declare interface AddNewProps {
42
42
  alwaysEnabled?: boolean;
43
43
  }
44
44
 
45
- export declare interface AddNotification {
46
- type: "error" | "success";
47
- status: HttpStatuses;
48
- title?: string;
49
- message?: string;
50
- }
51
-
52
45
  declare type AlertEntry = AlertItemProps & {
53
46
  height?: number;
54
47
  };
@@ -614,10 +607,6 @@ declare const dateTypes: readonly ["date", "time", "datetime-local"];
614
607
 
615
608
  export declare const debounce: (fn: (...args: unknown[]) => unknown, delay: number) => (...args: unknown[]) => void;
616
609
 
617
- declare type DeepPartial<T> = {
618
- [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
619
- };
620
-
621
610
  export declare const Dialog: default_2.ForwardRefExoticComponent<Omit<DialogProps, "ref"> & default_2.RefAttributes<HTMLDivElement>>;
622
611
 
623
612
  export declare interface DialogAction extends Omit<ButtonProps, "variant" | "ref"> {
@@ -663,11 +652,6 @@ declare const EMPHASES: readonly ["low", "medium", "high"];
663
652
 
664
653
  declare type Emphasis = (typeof EMPHASES)[keyof typeof EMPHASES];
665
654
 
666
- declare interface ErrorNotification extends NotificationType {
667
- response?: string;
668
- type: "error";
669
- }
670
-
671
655
  export declare const Fieldset: default_2.ForwardRefExoticComponent<Omit<default_2.PropsWithChildren<Omit<FieldsetProps, "ref"> & default_2.RefAttributes<HTMLFieldSetElement> & WithReadOnlyProps>, "ref"> & default_2.RefAttributes<unknown>>;
672
656
 
673
657
  export declare interface FieldsetProps extends ComponentPropsWithRef<"fieldset"> {
@@ -862,8 +846,6 @@ declare enum horizontal {
862
846
 
863
847
  declare type HorizontalPlacement = `${horizontal}`;
864
848
 
865
- declare type HttpStatuses = 200 | 500 | 400 | 401 | 403 | 404 | 501 | 502 | 503 | 504;
866
-
867
849
  export declare const Icon: default_2.ForwardRefExoticComponent<Omit<IconProps, "ref"> & default_2.RefAttributes<HTMLDivElement>>;
868
850
 
869
851
  export declare const IconButton: default_2.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & default_2.RefAttributes<HTMLButtonElement>>;
@@ -1145,31 +1127,6 @@ export declare interface MultiSelectWrapperProps extends Omit<ComponentPropsWith
1145
1127
 
1146
1128
  declare type MultiValueSpacingMultiplier = `${SpacingMultiplier} ${SpacingMultiplier} ${SpacingMultiplier} ${SpacingMultiplier}` | `${SpacingMultiplier} ${SpacingMultiplier} ${SpacingMultiplier}` | `${SpacingMultiplier} ${SpacingMultiplier}` | SpacingMultiplierStringOrNumber;
1147
1129
 
1148
- declare interface Notification_2<T extends NotificationType> {
1149
- id?: string;
1150
- type?: T["type"];
1151
- status?: HttpStatuses;
1152
- title?: string;
1153
- message?: string;
1154
- handled?: boolean;
1155
- }
1156
-
1157
- export declare const NotificationProvider: ({ children, translations }: NotificationProviderProps) => default_2.JSX.Element;
1158
-
1159
- export declare interface NotificationProviderProps {
1160
- children?: ReactNode;
1161
- translations?: DeepPartial<Translations>;
1162
- }
1163
-
1164
- declare interface NotificationState {
1165
- notifications: Notification_2<ErrorNotification | SuccessNotification>[];
1166
- }
1167
-
1168
- declare interface NotificationType {
1169
- type: "error" | "success";
1170
- status: HttpStatuses;
1171
- }
1172
-
1173
1130
  declare interface Offset {
1174
1131
  top: number;
1175
1132
  right: number;
@@ -1412,10 +1369,6 @@ export declare interface RadioWrapperProps extends ComponentPropsWithRef<"div">,
1412
1369
 
1413
1370
  declare type RefElement = default_2.RefObject<HTMLOrSVGElement> | undefined;
1414
1371
 
1415
- export declare interface RemoveNotification {
1416
- id: string;
1417
- }
1418
-
1419
1372
  export declare enum ScreenSize {
1420
1373
  SMALL = 0,
1421
1374
  MEDIUM = 1,
@@ -1542,11 +1495,6 @@ export declare interface StepProps extends Omit<ComponentPropsWithRef<"div">, "o
1542
1495
 
1543
1496
  export declare type StepStatus = "waiting" | "current" | "done" | "error";
1544
1497
 
1545
- declare interface SuccessNotification extends NotificationType {
1546
- response?: string;
1547
- type: "success";
1548
- }
1549
-
1550
1498
  declare interface SupportedCustomizationKeys {
1551
1499
  backgroundColor: string;
1552
1500
  focusBorderColor: string;
@@ -1699,22 +1647,6 @@ export declare interface TopNavBarProps {
1699
1647
  "data-testid"?: string;
1700
1648
  }
1701
1649
 
1702
- export declare interface Translations {
1703
- general: {
1704
- error: string;
1705
- success: string;
1706
- };
1707
- messages: {
1708
- general: string;
1709
- badRequest: string;
1710
- unauthorized: string;
1711
- forbidden: string;
1712
- notFound: string;
1713
- timeout: string;
1714
- unavailable: string;
1715
- };
1716
- }
1717
-
1718
1650
  export declare const Typography: default_2.ForwardRefExoticComponent<Omit<TypographyProps, "ref"> & default_2.RefAttributes<unknown>>;
1719
1651
 
1720
1652
  export declare interface TypographyProps extends ComponentPropsWithRef<any> {
@@ -1788,13 +1720,6 @@ declare interface UseMultiSelectResult {
1788
1720
  optionElements: default_2.JSX.Element[];
1789
1721
  }
1790
1722
 
1791
- export declare const useNotificationContext: () => {
1792
- state: NotificationState;
1793
- addNotification: (notification: AddNotification) => void;
1794
- removeNotification: (id: string) => void;
1795
- resetNotifications: () => void;
1796
- };
1797
-
1798
1723
  export declare const usePosition: (providedConfigObject?: ConfigObject) => {
1799
1724
  top: PositionType;
1800
1725
  bottom: PositionType;
package/dist/index.es.js CHANGED
@@ -34,7 +34,6 @@ import { AlertProvider } from "./components/Notifications/Alert/AlertProvider/Al
34
34
  import { AlertItem } from "./components/Notifications/Alert/AlertItem/AlertItem.es.js";
35
35
  import { Dialog } from "./components/Notifications/Dialog/Dialog.es.js";
36
36
  import { DiscardChangesModal } from "./components/Notifications/DiscardChangesModal/DiscardChangesModal.es.js";
37
- import { NotificationProvider, useNotificationContext } from "./components/Notifications/NotificationProvider/NotificationContext.es.js";
38
37
  import { SlideInModal } from "./components/Notifications/SlideInModal/SlideInModal.es.js";
39
38
  import { SideSheet } from "./components/Notifications/SideSheet/SideSheet.es.js";
40
39
  import { SideSheetContent } from "./components/Notifications/SideSheet/SideSheetContent/SideSheetContent.es.js";
@@ -140,7 +139,6 @@ export {
140
139
  MultiOption,
141
140
  MultiSelect,
142
141
  MultiSelectWrapper,
143
- NotificationProvider,
144
142
  Option,
145
143
  Pagination,
146
144
  ProfileMenu,
@@ -180,7 +178,6 @@ export {
180
178
  useFiltersReducer,
181
179
  useFullHeightCollapse,
182
180
  useMultiSelect,
183
- useNotificationContext,
184
181
  usePosition,
185
182
  useRepeater,
186
183
  useScreenSize,
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,3 +1,3 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.readyclasses_sr-only_SI2V3{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.readyclasses_hidden_SI2V3{display:none}.readyclasses_slide-in_SI2V3{animation:readyclasses_slide-in_SI2V3 .5s forwards}@media(prefers-reduced-motion:reduce){.readyclasses_slide-in_SI2V3{animation-duration:.1ms}}.readyclasses_slide-out_SI2V3{animation:readyclasses_slide-out_SI2V3 .5s forwards}@media(prefers-reduced-motion:reduce){.readyclasses_slide-out_SI2V3{animation-duration:.1ms}}@keyframes readyclasses_slide-in_SI2V3{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes readyclasses_slide-out_SI2V3{0%{transform:translateY(0)}to{transform:translateY(100vh)}}')),document.head.appendChild(e)}}catch(s){console.error("vite-plugin-css-injected-by-js",s)}}();
2
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="readyclasses_hidden_SI2V3",s={"sr-only":"readyclasses_sr-only_SI2V3",hidden:e,"slide-in":"readyclasses_slide-in_SI2V3","slide-out":"readyclasses_slide-out_SI2V3"};exports.default=s,exports.hidden=e;
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.readyclasses_sr-only_adu78{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.readyclasses_hidden_adu78{display:none}.readyclasses_slide-in_adu78{animation:readyclasses_slide-in_adu78 .5s forwards}@media(prefers-reduced-motion:reduce){.readyclasses_slide-in_adu78{animation-duration:.1ms}}.readyclasses_slide-out_adu78{animation:readyclasses_slide-out_adu78 .5s forwards}@media(prefers-reduced-motion:reduce){.readyclasses_slide-out_adu78{animation-duration:.1ms}}@keyframes readyclasses_slide-in_adu78{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes readyclasses_slide-out_adu78{0%{transform:translateY(0)}to{transform:translateY(100vh)}}')),document.head.appendChild(e)}}catch(s){console.error("vite-plugin-css-injected-by-js",s)}}();
2
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="readyclasses_hidden_adu78",s={"sr-only":"readyclasses_sr-only_adu78",hidden:e,"slide-in":"readyclasses_slide-in_adu78","slide-out":"readyclasses_slide-out_adu78"};exports.default=s,exports.hidden=e;
3
3
  //# sourceMappingURL=readyclasses.module.scss.cjs.js.map
@@ -1,10 +1,10 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.readyclasses_sr-only_SI2V3{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.readyclasses_hidden_SI2V3{display:none}.readyclasses_slide-in_SI2V3{animation:readyclasses_slide-in_SI2V3 .5s forwards}@media(prefers-reduced-motion:reduce){.readyclasses_slide-in_SI2V3{animation-duration:.1ms}}.readyclasses_slide-out_SI2V3{animation:readyclasses_slide-out_SI2V3 .5s forwards}@media(prefers-reduced-motion:reduce){.readyclasses_slide-out_SI2V3{animation-duration:.1ms}}@keyframes readyclasses_slide-in_SI2V3{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes readyclasses_slide-out_SI2V3{0%{transform:translateY(0)}to{transform:translateY(100vh)}}')),document.head.appendChild(e)}}catch(s){console.error("vite-plugin-css-injected-by-js",s)}}();
2
- const hidden = "readyclasses_hidden_SI2V3";
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.readyclasses_sr-only_adu78{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.readyclasses_hidden_adu78{display:none}.readyclasses_slide-in_adu78{animation:readyclasses_slide-in_adu78 .5s forwards}@media(prefers-reduced-motion:reduce){.readyclasses_slide-in_adu78{animation-duration:.1ms}}.readyclasses_slide-out_adu78{animation:readyclasses_slide-out_adu78 .5s forwards}@media(prefers-reduced-motion:reduce){.readyclasses_slide-out_adu78{animation-duration:.1ms}}@keyframes readyclasses_slide-in_adu78{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes readyclasses_slide-out_adu78{0%{transform:translateY(0)}to{transform:translateY(100vh)}}')),document.head.appendChild(e)}}catch(s){console.error("vite-plugin-css-injected-by-js",s)}}();
2
+ const hidden = "readyclasses_hidden_adu78";
3
3
  const readyclasses = {
4
- "sr-only": "readyclasses_sr-only_SI2V3",
4
+ "sr-only": "readyclasses_sr-only_adu78",
5
5
  hidden,
6
- "slide-in": "readyclasses_slide-in_SI2V3",
7
- "slide-out": "readyclasses_slide-out_SI2V3"
6
+ "slide-in": "readyclasses_slide-in_adu78",
7
+ "slide-out": "readyclasses_slide-out_adu78"
8
8
  };
9
9
  export {
10
10
  readyclasses as default,
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=(t,r)=>{if(!r)return t;const o={...t};for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&("object"==typeof r[n]&&null!==r[n]&&Object.prototype.hasOwnProperty.call(t,n)&&!Array.isArray(r[n])?o[n]=e(t[n],r[n]):o[n]=r[n]);return o};exports.debounce=(e,t)=>{let r;return function(...o){clearTimeout(r),r=setTimeout(()=>{clearTimeout(r),e(...o)},t)}},exports.deepMerge=e,exports.filterProps=(e,t,r=!0)=>r?Object.keys(e).reduce((r,o)=>(t.test(o)&&(r[o]=e[o]),r),{}):Object.entries(e).filter(([e])=>!t.test(e)).reduce((e,t)=>({...e,[t[0]]:t[1]}),{}),exports.generateID=(e=15,t)=>{const r=["1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];let o="";for(let n=0;n<e&&o.length<e;n++)o=o+("string"!=typeof t||void 0===(null==t?void 0:t[n])||/\s/.test(t[n])?"":t[n])+r[Math.floor(Math.random()*r.length)];return o.slice(0,e)},exports.isJsonString=e=>{try{JSON.parse(e)}catch{return!1}return!0},exports.remToPx=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),exports.throttle=(e,t)=>{let r=0;return function(){const o=Date.now();o-r>=t&&(e(),r=o)}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.debounce=(e,t)=>{let r;return function(...o){clearTimeout(r),r=setTimeout(()=>{clearTimeout(r),e(...o)},t)}},exports.filterProps=(e,t,r=!0)=>r?Object.keys(e).reduce((r,o)=>(t.test(o)&&(r[o]=e[o]),r),{}):Object.entries(e).filter(([e])=>!t.test(e)).reduce((e,t)=>({...e,[t[0]]:t[1]}),{}),exports.generateID=(e=15,t)=>{const r=["1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];let o="";for(let n=0;n<e&&o.length<e;n++)o=o+("string"!=typeof t||void 0===(null==t?void 0:t[n])||/\s/.test(t[n])?"":t[n])+r[Math.floor(Math.random()*r.length)];return o.slice(0,e)},exports.isJsonString=e=>{try{JSON.parse(e)}catch{return!1}return!0},exports.remToPx=e=>e*parseFloat(getComputedStyle(document.documentElement).fontSize),exports.throttle=(e,t)=>{let r=0;return function(){const o=Date.now();o-r>=t&&(e(),r=o)}};
2
2
  //# sourceMappingURL=helper.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.cjs.js","sources":["../../src/util/helper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype KeyValuePair = { [key: string]: unknown };\n\nexport const generateID = (length = 15, stringToWeaveIn?: string) => {\n /** We will make sure to mesh the generate id and name property together to basically create a unique ID */\n const hashCharacters = [\n \"1\",\n \"2\",\n \"3\",\n \"4\",\n \"5\",\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"0\",\n \"A\",\n \"B\",\n \"C\",\n \"D\",\n \"E\",\n \"F\",\n \"G\",\n \"H\",\n \"I\",\n \"J\",\n \"K\",\n \"L\",\n \"M\",\n \"N\",\n \"O\",\n \"P\",\n \"Q\",\n \"R\",\n \"S\",\n \"T\",\n \"U\",\n \"V\",\n \"W\",\n \"X\",\n \"Y\",\n \"Z\",\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\",\n \"f\",\n \"g\",\n \"h\",\n \"i\",\n \"j\",\n \"k\",\n \"l\",\n \"m\",\n \"n\",\n \"o\",\n \"p\",\n \"q\",\n \"r\",\n \"s\",\n \"t\",\n \"u\",\n \"v\",\n \"w\",\n \"x\",\n \"y\",\n \"z\"\n ];\n\n let id = \"\";\n\n /** Generate an id of x characters in length */\n for (let i = 0; i < length && id.length < length; i++) {\n const stringCharacter =\n typeof stringToWeaveIn === \"string\" &&\n stringToWeaveIn?.[i] !== undefined &&\n !/\\s/.test(stringToWeaveIn[i])\n ? stringToWeaveIn[i]\n : \"\";\n id = id + stringCharacter + hashCharacters[Math.floor(Math.random() * hashCharacters.length)];\n }\n\n return id.slice(0, length);\n};\n\nexport const filterProps = (props: any, regexPattern: RegExp, returnFiltered: boolean = true) => {\n if (returnFiltered) {\n return Object.keys(props).reduce((acc: KeyValuePair, key) => {\n if (regexPattern.test(key)) {\n acc[key] = props[key];\n }\n\n return acc;\n }, {});\n } else {\n return Object.entries(props)\n .filter(([key]) => !regexPattern.test(key))\n .reduce(\n (prevObj, currKeyValPair) => ({ ...prevObj, [currKeyValPair[0]]: currKeyValPair[1] }),\n {}\n );\n }\n};\n\nexport const debounce = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let timeout: undefined | ReturnType<typeof setTimeout>;\n\n return function executedFunction(...args: unknown[]) {\n const later = () => {\n clearTimeout(timeout);\n fn(...args);\n };\n\n clearTimeout(timeout);\n\n timeout = setTimeout(later, delay);\n };\n};\n\nexport const throttle = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let lastTime = 0;\n\n return function () {\n const now = Date.now();\n\n if (now - lastTime >= delay) {\n fn();\n lastTime = now;\n }\n };\n};\n\nconst isEqual = (x: any, y: any): boolean => {\n const typesCoincide = x && y && typeof x === \"object\" && typeof y === \"object\";\n return typesCoincide\n ? Object.keys(x).length === Object.keys(y).length &&\n Object.keys(x).every(key => isEqual(x[key], y[key]))\n : x === y;\n};\n\nexport const areArraysDifferent = (\n arr1: Record<string, any>[],\n arr2: Record<string, any>[],\n key: string\n) => {\n if (arr1.length !== arr2.length) {\n return true;\n } else {\n const firstFilteredArray = arr1.filter(arr1Item =>\n arr2.some((arr2Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n const secondFilteredArray = arr2.filter(arr2Item =>\n arr1.some((arr1Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n\n return !!firstFilteredArray.length || !!secondFilteredArray.length;\n }\n};\n\n/** Source: https://stackoverflow.com/a/42769683/5084110 */\nexport const remToPx = (rem: number): number => {\n return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);\n};\n\nexport const isJsonString = (str: any) => {\n try {\n JSON.parse(str);\n } catch {\n return false;\n }\n return true;\n};\n\ntype ObjectType = { [key: string]: any };\n\nexport const deepMerge = <T extends object>(obj1: ObjectType, obj2: ObjectType | false): T => {\n if (!obj2) {\n return obj1 as T;\n }\n\n const result: ObjectType = { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n if (\n typeof obj2[key] === \"object\" &&\n obj2[key] !== null &&\n Object.prototype.hasOwnProperty.call(obj1, key) &&\n !Array.isArray(obj2[key])\n ) {\n result[key] = deepMerge(obj1[key], obj2[key]);\n } else {\n result[key] = obj2[key];\n }\n }\n }\n\n return result as T;\n};\n\nexport const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n"],"names":["deepMerge","obj1","obj2","result","key","Object","prototype","hasOwnProperty","call","Array","isArray","fn","delay","timeout","args","clearTimeout","setTimeout","props","regexPattern","returnFiltered","keys","reduce","acc","test","entries","filter","prevObj","currKeyValPair","length","stringToWeaveIn","hashCharacters","id","i","Math","floor","random","slice","str","JSON","parse","rem","parseFloat","getComputedStyle","document","documentElement","fontSize","lastTime","now","Date"],"mappings":"gFAoBO,MA6KMA,EAAY,CAAmBC,EAAkBC,KAC5D,IAAKA,EACH,OAAOD,EAGT,MAAME,EAAqB,IAAKF,GAEhC,IAAA,MAAWG,KAAOF,EACZG,OAAOC,UAAUC,eAAeC,KAAKN,EAAME,KAEtB,iBAAdF,EAAKE,IACE,OAAdF,EAAKE,IACLC,OAAOC,UAAUC,eAAeC,KAAKP,EAAMG,KAC1CK,MAAMC,QAAQR,EAAKE,IAEpBD,EAAOC,GAAOJ,EAAUC,EAAKG,GAAMF,EAAKE,IAExCD,EAAOC,GAAOF,EAAKE,IAKzB,OAAOD,oBA7Fe,CAACQ,EAAqCC,KAC5D,IAAIC,EAEJ,OAAO,YAA6BC,GAMlCC,aAAaF,GAEbA,EAAUG,WAPI,KACZD,aAAaF,GACbF,KAAMG,IAKoBF,EAC9B,2CA/ByB,CAACK,EAAYC,EAAsBC,GAA0B,IAClFA,EACKd,OAAOe,KAAKH,GAAOI,OAAO,CAACC,EAAmBlB,KAC/Cc,EAAaK,KAAKnB,KACpBkB,EAAIlB,GAAOa,EAAMb,IAGZkB,GACN,CAAA,GAEIjB,OAAOmB,QAAQP,GACnBQ,OAAO,EAAErB,MAAUc,EAAaK,KAAKnB,IACrCiB,OACC,CAACK,EAASC,KAAA,IAAyBD,EAAS,CAACC,EAAe,IAAKA,EAAe,KAChF,CAAA,sBAjGkB,CAACC,EAAS,GAAIC,KAEtC,MAAMC,EAAiB,CACrB,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGF,IAAIC,EAAK,GAGT,IAAA,IAASC,EAAI,EAAGA,EAAIJ,GAAUG,EAAGH,OAASA,EAAQI,IAOhDD,EAAKA,GALwB,iBAApBF,QACkB,KAAzB,MAAAA,OAAA,EAAAA,EAAkBG,KACjB,KAAKT,KAAKM,EAAgBG,IAEvB,GADAH,EAAgBG,IAEMF,EAAeG,KAAKC,MAAMD,KAAKE,SAAWL,EAAeF,SAGvF,OAAOG,EAAGK,MAAM,EAAGR,yBAkFQS,IAC3B,IACEC,KAAKC,MAAMF,EACb,CAAA,MACE,OAAO,CACT,CACA,OAAO,mBAVeG,GACfA,EAAMC,WAAWC,iBAAiBC,SAASC,iBAAiBC,2BA1C7C,CAAClC,EAAqCC,KAC5D,IAAIkC,EAAW,EAEf,OAAO,WACL,MAAMC,EAAMC,KAAKD,MAEbA,EAAMD,GAAYlC,IACpBD,IACAmC,EAAWC,EAEf"}
1
+ {"version":3,"file":"helper.cjs.js","sources":["../../src/util/helper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype KeyValuePair = { [key: string]: unknown };\n\nexport const generateID = (length = 15, stringToWeaveIn?: string) => {\n /** We will make sure to mesh the generate id and name property together to basically create a unique ID */\n const hashCharacters = [\n \"1\",\n \"2\",\n \"3\",\n \"4\",\n \"5\",\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"0\",\n \"A\",\n \"B\",\n \"C\",\n \"D\",\n \"E\",\n \"F\",\n \"G\",\n \"H\",\n \"I\",\n \"J\",\n \"K\",\n \"L\",\n \"M\",\n \"N\",\n \"O\",\n \"P\",\n \"Q\",\n \"R\",\n \"S\",\n \"T\",\n \"U\",\n \"V\",\n \"W\",\n \"X\",\n \"Y\",\n \"Z\",\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\",\n \"f\",\n \"g\",\n \"h\",\n \"i\",\n \"j\",\n \"k\",\n \"l\",\n \"m\",\n \"n\",\n \"o\",\n \"p\",\n \"q\",\n \"r\",\n \"s\",\n \"t\",\n \"u\",\n \"v\",\n \"w\",\n \"x\",\n \"y\",\n \"z\"\n ];\n\n let id = \"\";\n\n /** Generate an id of x characters in length */\n for (let i = 0; i < length && id.length < length; i++) {\n const stringCharacter =\n typeof stringToWeaveIn === \"string\" &&\n stringToWeaveIn?.[i] !== undefined &&\n !/\\s/.test(stringToWeaveIn[i])\n ? stringToWeaveIn[i]\n : \"\";\n id = id + stringCharacter + hashCharacters[Math.floor(Math.random() * hashCharacters.length)];\n }\n\n return id.slice(0, length);\n};\n\nexport const filterProps = (props: any, regexPattern: RegExp, returnFiltered: boolean = true) => {\n if (returnFiltered) {\n return Object.keys(props).reduce((acc: KeyValuePair, key) => {\n if (regexPattern.test(key)) {\n acc[key] = props[key];\n }\n\n return acc;\n }, {});\n } else {\n return Object.entries(props)\n .filter(([key]) => !regexPattern.test(key))\n .reduce(\n (prevObj, currKeyValPair) => ({ ...prevObj, [currKeyValPair[0]]: currKeyValPair[1] }),\n {}\n );\n }\n};\n\nexport const debounce = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let timeout: undefined | ReturnType<typeof setTimeout>;\n\n return function executedFunction(...args: unknown[]) {\n const later = () => {\n clearTimeout(timeout);\n fn(...args);\n };\n\n clearTimeout(timeout);\n\n timeout = setTimeout(later, delay);\n };\n};\n\nexport const throttle = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let lastTime = 0;\n\n return function () {\n const now = Date.now();\n\n if (now - lastTime >= delay) {\n fn();\n lastTime = now;\n }\n };\n};\n\nconst isEqual = (x: any, y: any): boolean => {\n const typesCoincide = x && y && typeof x === \"object\" && typeof y === \"object\";\n return typesCoincide\n ? Object.keys(x).length === Object.keys(y).length &&\n Object.keys(x).every(key => isEqual(x[key], y[key]))\n : x === y;\n};\n\nexport const areArraysDifferent = (\n arr1: Record<string, any>[],\n arr2: Record<string, any>[],\n key: string\n) => {\n if (arr1.length !== arr2.length) {\n return true;\n } else {\n const firstFilteredArray = arr1.filter(arr1Item =>\n arr2.some((arr2Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n const secondFilteredArray = arr2.filter(arr2Item =>\n arr1.some((arr1Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n\n return !!firstFilteredArray.length || !!secondFilteredArray.length;\n }\n};\n\n/** Source: https://stackoverflow.com/a/42769683/5084110 */\nexport const remToPx = (rem: number): number => {\n return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);\n};\n\nexport const isJsonString = (str: any) => {\n try {\n JSON.parse(str);\n } catch {\n return false;\n }\n return true;\n};\n\ntype ObjectType = { [key: string]: any };\n\nexport const deepMerge = <T extends object>(obj1: ObjectType, obj2: ObjectType | false): T => {\n if (!obj2) {\n return obj1 as T;\n }\n\n const result: ObjectType = { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n if (\n typeof obj2[key] === \"object\" &&\n obj2[key] !== null &&\n Object.prototype.hasOwnProperty.call(obj1, key) &&\n !Array.isArray(obj2[key])\n ) {\n result[key] = deepMerge(obj1[key], obj2[key]);\n } else {\n result[key] = obj2[key];\n }\n }\n }\n\n return result as T;\n};\n\nexport const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n"],"names":["fn","delay","timeout","args","clearTimeout","setTimeout","props","regexPattern","returnFiltered","Object","keys","reduce","acc","key","test","entries","filter","prevObj","currKeyValPair","length","stringToWeaveIn","hashCharacters","id","i","Math","floor","random","slice","str","JSON","parse","rem","parseFloat","getComputedStyle","document","documentElement","fontSize","lastTime","now","Date"],"mappings":"iGA0HwB,CAACA,EAAqCC,KAC5D,IAAIC,EAEJ,OAAO,YAA6BC,GAMlCC,aAAaF,GAEbA,EAAUG,WAPI,KACZD,aAAaF,GACbF,KAAMG,IAKoBF,EAC9B,uBA/ByB,CAACK,EAAYC,EAAsBC,GAA0B,IAClFA,EACKC,OAAOC,KAAKJ,GAAOK,OAAO,CAACC,EAAmBC,KAC/CN,EAAaO,KAAKD,KACpBD,EAAIC,GAAOP,EAAMO,IAGZD,GACN,CAAA,GAEIH,OAAOM,QAAQT,GACnBU,OAAO,EAAEH,MAAUN,EAAaO,KAAKD,IACrCF,OACC,CAACM,EAASC,KAAA,IAAyBD,EAAS,CAACC,EAAe,IAAKA,EAAe,KAChF,CAAA,sBAjGkB,CAACC,EAAS,GAAIC,KAEtC,MAAMC,EAAiB,CACrB,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGF,IAAIC,EAAK,GAGT,IAAA,IAASC,EAAI,EAAGA,EAAIJ,GAAUG,EAAGH,OAASA,EAAQI,IAOhDD,EAAKA,GALwB,iBAApBF,QACkB,KAAzB,MAAAA,OAAA,EAAAA,EAAkBG,KACjB,KAAKT,KAAKM,EAAgBG,IAEvB,GADAH,EAAgBG,IAEMF,EAAeG,KAAKC,MAAMD,KAAKE,SAAWL,EAAeF,SAGvF,OAAOG,EAAGK,MAAM,EAAGR,yBAkFQS,IAC3B,IACEC,KAAKC,MAAMF,EACb,CAAA,MACE,OAAO,CACT,CACA,OAAO,mBAVeG,GACfA,EAAMC,WAAWC,iBAAiBC,SAASC,iBAAiBC,2BA1C7C,CAACpC,EAAqCC,KAC5D,IAAIoC,EAAW,EAEf,OAAO,WACL,MAAMC,EAAMC,KAAKD,MAEbA,EAAMD,GAAYpC,IACpBD,IACAqC,EAAWC,EAEf"}
@@ -117,25 +117,8 @@ const isJsonString = (str) => {
117
117
  }
118
118
  return true;
119
119
  };
120
- const deepMerge = (obj1, obj2) => {
121
- if (!obj2) {
122
- return obj1;
123
- }
124
- const result = { ...obj1 };
125
- for (const key in obj2) {
126
- if (Object.prototype.hasOwnProperty.call(obj2, key)) {
127
- if (typeof obj2[key] === "object" && obj2[key] !== null && Object.prototype.hasOwnProperty.call(obj1, key) && !Array.isArray(obj2[key])) {
128
- result[key] = deepMerge(obj1[key], obj2[key]);
129
- } else {
130
- result[key] = obj2[key];
131
- }
132
- }
133
- }
134
- return result;
135
- };
136
120
  export {
137
121
  debounce,
138
- deepMerge,
139
122
  filterProps,
140
123
  generateID,
141
124
  isJsonString,
@@ -1 +1 @@
1
- {"version":3,"file":"helper.es.js","sources":["../../src/util/helper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype KeyValuePair = { [key: string]: unknown };\n\nexport const generateID = (length = 15, stringToWeaveIn?: string) => {\n /** We will make sure to mesh the generate id and name property together to basically create a unique ID */\n const hashCharacters = [\n \"1\",\n \"2\",\n \"3\",\n \"4\",\n \"5\",\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"0\",\n \"A\",\n \"B\",\n \"C\",\n \"D\",\n \"E\",\n \"F\",\n \"G\",\n \"H\",\n \"I\",\n \"J\",\n \"K\",\n \"L\",\n \"M\",\n \"N\",\n \"O\",\n \"P\",\n \"Q\",\n \"R\",\n \"S\",\n \"T\",\n \"U\",\n \"V\",\n \"W\",\n \"X\",\n \"Y\",\n \"Z\",\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\",\n \"f\",\n \"g\",\n \"h\",\n \"i\",\n \"j\",\n \"k\",\n \"l\",\n \"m\",\n \"n\",\n \"o\",\n \"p\",\n \"q\",\n \"r\",\n \"s\",\n \"t\",\n \"u\",\n \"v\",\n \"w\",\n \"x\",\n \"y\",\n \"z\"\n ];\n\n let id = \"\";\n\n /** Generate an id of x characters in length */\n for (let i = 0; i < length && id.length < length; i++) {\n const stringCharacter =\n typeof stringToWeaveIn === \"string\" &&\n stringToWeaveIn?.[i] !== undefined &&\n !/\\s/.test(stringToWeaveIn[i])\n ? stringToWeaveIn[i]\n : \"\";\n id = id + stringCharacter + hashCharacters[Math.floor(Math.random() * hashCharacters.length)];\n }\n\n return id.slice(0, length);\n};\n\nexport const filterProps = (props: any, regexPattern: RegExp, returnFiltered: boolean = true) => {\n if (returnFiltered) {\n return Object.keys(props).reduce((acc: KeyValuePair, key) => {\n if (regexPattern.test(key)) {\n acc[key] = props[key];\n }\n\n return acc;\n }, {});\n } else {\n return Object.entries(props)\n .filter(([key]) => !regexPattern.test(key))\n .reduce(\n (prevObj, currKeyValPair) => ({ ...prevObj, [currKeyValPair[0]]: currKeyValPair[1] }),\n {}\n );\n }\n};\n\nexport const debounce = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let timeout: undefined | ReturnType<typeof setTimeout>;\n\n return function executedFunction(...args: unknown[]) {\n const later = () => {\n clearTimeout(timeout);\n fn(...args);\n };\n\n clearTimeout(timeout);\n\n timeout = setTimeout(later, delay);\n };\n};\n\nexport const throttle = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let lastTime = 0;\n\n return function () {\n const now = Date.now();\n\n if (now - lastTime >= delay) {\n fn();\n lastTime = now;\n }\n };\n};\n\nconst isEqual = (x: any, y: any): boolean => {\n const typesCoincide = x && y && typeof x === \"object\" && typeof y === \"object\";\n return typesCoincide\n ? Object.keys(x).length === Object.keys(y).length &&\n Object.keys(x).every(key => isEqual(x[key], y[key]))\n : x === y;\n};\n\nexport const areArraysDifferent = (\n arr1: Record<string, any>[],\n arr2: Record<string, any>[],\n key: string\n) => {\n if (arr1.length !== arr2.length) {\n return true;\n } else {\n const firstFilteredArray = arr1.filter(arr1Item =>\n arr2.some((arr2Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n const secondFilteredArray = arr2.filter(arr2Item =>\n arr1.some((arr1Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n\n return !!firstFilteredArray.length || !!secondFilteredArray.length;\n }\n};\n\n/** Source: https://stackoverflow.com/a/42769683/5084110 */\nexport const remToPx = (rem: number): number => {\n return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);\n};\n\nexport const isJsonString = (str: any) => {\n try {\n JSON.parse(str);\n } catch {\n return false;\n }\n return true;\n};\n\ntype ObjectType = { [key: string]: any };\n\nexport const deepMerge = <T extends object>(obj1: ObjectType, obj2: ObjectType | false): T => {\n if (!obj2) {\n return obj1 as T;\n }\n\n const result: ObjectType = { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n if (\n typeof obj2[key] === \"object\" &&\n obj2[key] !== null &&\n Object.prototype.hasOwnProperty.call(obj1, key) &&\n !Array.isArray(obj2[key])\n ) {\n result[key] = deepMerge(obj1[key], obj2[key]);\n } else {\n result[key] = obj2[key];\n }\n }\n }\n\n return result as T;\n};\n\nexport const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n"],"names":[],"mappings":"AAoBO,MAAM,aAAa,CAAC,SAAS,IAAI,oBAA6B;AAEnE,QAAM,iBAAiB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,MAAI,KAAK;AAGT,WAAS,IAAI,GAAG,IAAI,UAAU,GAAG,SAAS,QAAQ,KAAK;AACrD,UAAM,kBACJ,OAAO,oBAAoB,aAC3B,mDAAkB,QAAO,UACzB,CAAC,KAAK,K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AAM,eAAe,CAAC,QAAa;AACxC,MAAI;AACF,SAAK,MAAM,GAAG;AAAA,EAChB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAIO,MAAM,YAAY,CAAmB,MAAkB,SAAgC;AAC5F,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AAEA,QAAM,SAAqB,EAAE,GAAG,KAAA;AAEhC,aAAW,OAAO,MAAM;AACtB,QAAI,OAAO,UAAU,eAAe,KAAK,MAAM,GAAG,GAAG;AACnD,UACE,OAAO,KAAK,GAAG,MAAM,YACrB,KAAK,GAAG,MAAM,QACd,OAAO,UAAU,eAAe,KAAK,MAAM,GAAG,KAC9C,CAAC,MAAM,QAAQ,KAAK,GAAG,CAAC,GACxB;AACA,eAAO,GAAG,IAAI,UAAU,KAAK,GAAG,GAAG,KAAK,GAAG,CAAC;AAAA,MAC9C,OAAO;AACL,eAAO,GAAG,IAAI,KAAK,GAAG;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;"}
1
+ {"version":3,"file":"helper.es.js","sources":["../../src/util/helper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype KeyValuePair = { [key: string]: unknown };\n\nexport const generateID = (length = 15, stringToWeaveIn?: string) => {\n /** We will make sure to mesh the generate id and name property together to basically create a unique ID */\n const hashCharacters = [\n \"1\",\n \"2\",\n \"3\",\n \"4\",\n \"5\",\n \"6\",\n \"7\",\n \"8\",\n \"9\",\n \"0\",\n \"A\",\n \"B\",\n \"C\",\n \"D\",\n \"E\",\n \"F\",\n \"G\",\n \"H\",\n \"I\",\n \"J\",\n \"K\",\n \"L\",\n \"M\",\n \"N\",\n \"O\",\n \"P\",\n \"Q\",\n \"R\",\n \"S\",\n \"T\",\n \"U\",\n \"V\",\n \"W\",\n \"X\",\n \"Y\",\n \"Z\",\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\",\n \"f\",\n \"g\",\n \"h\",\n \"i\",\n \"j\",\n \"k\",\n \"l\",\n \"m\",\n \"n\",\n \"o\",\n \"p\",\n \"q\",\n \"r\",\n \"s\",\n \"t\",\n \"u\",\n \"v\",\n \"w\",\n \"x\",\n \"y\",\n \"z\"\n ];\n\n let id = \"\";\n\n /** Generate an id of x characters in length */\n for (let i = 0; i < length && id.length < length; i++) {\n const stringCharacter =\n typeof stringToWeaveIn === \"string\" &&\n stringToWeaveIn?.[i] !== undefined &&\n !/\\s/.test(stringToWeaveIn[i])\n ? stringToWeaveIn[i]\n : \"\";\n id = id + stringCharacter + hashCharacters[Math.floor(Math.random() * hashCharacters.length)];\n }\n\n return id.slice(0, length);\n};\n\nexport const filterProps = (props: any, regexPattern: RegExp, returnFiltered: boolean = true) => {\n if (returnFiltered) {\n return Object.keys(props).reduce((acc: KeyValuePair, key) => {\n if (regexPattern.test(key)) {\n acc[key] = props[key];\n }\n\n return acc;\n }, {});\n } else {\n return Object.entries(props)\n .filter(([key]) => !regexPattern.test(key))\n .reduce(\n (prevObj, currKeyValPair) => ({ ...prevObj, [currKeyValPair[0]]: currKeyValPair[1] }),\n {}\n );\n }\n};\n\nexport const debounce = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let timeout: undefined | ReturnType<typeof setTimeout>;\n\n return function executedFunction(...args: unknown[]) {\n const later = () => {\n clearTimeout(timeout);\n fn(...args);\n };\n\n clearTimeout(timeout);\n\n timeout = setTimeout(later, delay);\n };\n};\n\nexport const throttle = (fn: (...args: unknown[]) => unknown, delay: number) => {\n let lastTime = 0;\n\n return function () {\n const now = Date.now();\n\n if (now - lastTime >= delay) {\n fn();\n lastTime = now;\n }\n };\n};\n\nconst isEqual = (x: any, y: any): boolean => {\n const typesCoincide = x && y && typeof x === \"object\" && typeof y === \"object\";\n return typesCoincide\n ? Object.keys(x).length === Object.keys(y).length &&\n Object.keys(x).every(key => isEqual(x[key], y[key]))\n : x === y;\n};\n\nexport const areArraysDifferent = (\n arr1: Record<string, any>[],\n arr2: Record<string, any>[],\n key: string\n) => {\n if (arr1.length !== arr2.length) {\n return true;\n } else {\n const firstFilteredArray = arr1.filter(arr1Item =>\n arr2.some((arr2Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n const secondFilteredArray = arr2.filter(arr2Item =>\n arr1.some((arr1Item: { [x: string]: any }) => !isEqual(arr1Item[key], arr2Item[key]))\n );\n\n return !!firstFilteredArray.length || !!secondFilteredArray.length;\n }\n};\n\n/** Source: https://stackoverflow.com/a/42769683/5084110 */\nexport const remToPx = (rem: number): number => {\n return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);\n};\n\nexport const isJsonString = (str: any) => {\n try {\n JSON.parse(str);\n } catch {\n return false;\n }\n return true;\n};\n\ntype ObjectType = { [key: string]: any };\n\nexport const deepMerge = <T extends object>(obj1: ObjectType, obj2: ObjectType | false): T => {\n if (!obj2) {\n return obj1 as T;\n }\n\n const result: ObjectType = { ...obj1 };\n\n for (const key in obj2) {\n if (Object.prototype.hasOwnProperty.call(obj2, key)) {\n if (\n typeof obj2[key] === \"object\" &&\n obj2[key] !== null &&\n Object.prototype.hasOwnProperty.call(obj1, key) &&\n !Array.isArray(obj2[key])\n ) {\n result[key] = deepMerge(obj1[key], obj2[key]);\n } else {\n result[key] = obj2[key];\n }\n }\n }\n\n return result as T;\n};\n\nexport const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n"],"names":[],"mappings":"AAoBO,MAAM,aAAa,CAAC,SAAS,IAAI,oBAA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YAAI,GAAG,IAAI,MAAM,GAAG;AAAA,MACtB;AAEA,aAAO;AAAA,IACT,GAAG,CAAA,CAAE;AAAA,EACP,OAAO;AACL,WAAO,OAAO,QAAQ,KAAK,EACxB,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,aAAa,KAAK,GAAG,CAAC,EACzC;AAAA,MACC,CAAC,SAAS,oBAAoB,EAAE,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC,GAAG,eAAe,CAAC;MACjF,CAAA;AAAA,IAAC;AAAA,EAEP;AACF;AAEO,MAAM,WAAW,CAAC,IAAqC,UAAkB;AAC9E,MAAI;AAEJ,SAAO,SAAS,oBAAoB,MAAiB;AACnD,UAAM,QAAQ,MAAM;AAClB,mBAAa,OAAO;AACpB,SAAG,GAAG,IAAI;AAAA,IACZ;AAEA,iBAAa,OAAO;AAEpB,cAAU,WAAW,OAAO,KAAK;AAAA,EACnC;AACF;AAEO,MAAM,WAAW,CAAC,IAAqC,UAAkB;AAC9E,MAAI,WAAW;AAEf,SAAO,WAAY;AACjB,UAAM,MAAM,KAAK,IAAA;AAEjB,QAAI,MAAM,YAAY,OAAO;AAC3B,SAAA;AACA,iBAAW;AAAA,IACb;AAAA,EACF;AACF;AA8BO,MAAM,UAAU,CAAC,QAAwB;AAC9C,SAAO,MAAM,WAAW,iBAAiB,SAAS,eAAe,EAAE,QAAQ;AAC7E;AAEO,MAAM,eAAe,CAAC,QAAa;AACxC,MAAI;AACF,SAAK,MAAM,GAAG;AAAA,EAChB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,SAAO;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onewelcome/react-lib-components",
3
- "version": "12.1.0-alpha.4",
3
+ "version": "13.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "author": "OneWelcome B.V.",
6
6
  "main": "dist/index.cjs.js",
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./NotificationService.cjs.js"),a=require("../../../util/helper.cjs.js"),s=require("../Alert/useAlert.cjs.js"),i={notifications:[]},r=({translations:i={},dispatchFn:r})=>{const{enqueueErrorAlert:n,enqueueSuccessAlert:d}=s.useAlert(),{state:{notifications:c}}=o(),l=a.deepMerge(t.defaultTranslations,i),u=e=>{if(e.message)return e.message;switch(e.status){case 500:default:return l.messages.general;case 400:return l.messages.badRequest;case 401:return l.messages.unauthorized;case 403:return l.messages.forbidden;case 404:return l.messages.notFound;case 502:case 503:return l.messages.unavailable;case 504:return l.messages.timeout}};return e.useEffect(()=>{c.forEach(e=>{e.status&&e.handled&&(401===e.status||403===e.status)?r({type:"remove",payload:{id:e.id}}):e.status&&!e.handled&&"error"===e.type?(n({title:e.title??l.general.error,content:u(e),onClose:()=>r({type:"remove",payload:{id:e.id}})}),r({type:"handled",payload:{id:e.id,handled:!0}})):e.title&&!e.handled&&"success"===e.type&&(d({title:e.title??l.general.success,content:e.message,onClose:()=>r({type:"remove",payload:{id:e.id}})}),r({type:"handled",payload:{id:e.id,handled:!0}}))})},[c.length]),null},n=e.createContext({state:i,dispatch:()=>{}}),o=()=>{const t=e.useContext(n),a=e.useCallback(e=>{t.dispatch({type:"add",payload:e})},[t]),s=e.useCallback(e=>{t.dispatch({type:"remove",payload:{id:e}})},[t]),i=e.useCallback(()=>{t.dispatch({type:"reset"})},[t]);return{state:t.state,addNotification:a,removeNotification:s,resetNotifications:i}},d=(e,t)=>{switch(t.type){case"add":return{...e,notifications:[...e.notifications,{...t.payload,id:a.generateID(),handled:!1}]};case"remove":return{...e,notifications:e.notifications.filter(e=>{var a;return e.id!==(null==(a=t.payload)?void 0:a.id)})};case"handled":return{...e,notifications:e.notifications.map(e=>{var a;return e.id===(null==(a=t.payload)?void 0:a.id)?{...e,handled:!0}:e})};case"reset":return{...e,notifications:[]};default:return e}};exports.NotificationContext=n,exports.NotificationHandler=r,exports.NotificationProvider=({children:t,translations:a})=>{const[s,o]=e.useReducer(d,i);return e.createElement(n.Provider,{value:{state:s,dispatch:o}},t,e.createElement(r,{translations:a,dispatchFn:o}))},exports.notificationReducer=d,exports.useNotificationContext=o;
2
- //# sourceMappingURL=NotificationContext.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NotificationContext.cjs.js","sources":["../../../../src/components/Notifications/NotificationProvider/NotificationContext.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n ReactNode,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useReducer\n} from \"react\";\nimport {\n Notification,\n ErrorNotification,\n SuccessNotification,\n Translations,\n AddNotification\n} from \"./notification.interfaces\";\nimport { defaultTranslations } from \"./NotificationService\";\nimport { deepMerge, generateID } from \"../../../util/helper\";\nimport { DeepPartial } from \"../../../interfaces\";\nimport { useAlert } from \"../Alert/useAlert\";\n\ninterface NotificationState {\n notifications: Notification<ErrorNotification | SuccessNotification>[];\n}\n\nexport interface NotificationAction {\n type: \"add\" | \"remove\" | \"handled\" | \"reset\";\n payload?: Notification<ErrorNotification | SuccessNotification> & {\n id?: string;\n handled?: boolean;\n };\n}\n\nconst initialState: NotificationState = {\n notifications: []\n};\n\nexport interface NotificationHandlerProps {\n translations?: DeepPartial<Translations>;\n dispatchFn: React.Dispatch<NotificationAction>;\n}\n\nexport const NotificationHandler = ({\n translations = {},\n dispatchFn\n}: NotificationHandlerProps) => {\n const { enqueueErrorAlert, enqueueSuccessAlert } = useAlert();\n const {\n state: { notifications }\n } = useNotificationContext();\n\n const mergedTranslations = deepMerge<Translations>(defaultTranslations, translations);\n\n const determineNotificationMessage = (notification: Notification<ErrorNotification>) => {\n if (notification.message) {\n return notification.message;\n }\n\n switch (notification.status) {\n case 500:\n return mergedTranslations.messages.general;\n case 400:\n return mergedTranslations.messages.badRequest;\n case 401:\n return mergedTranslations.messages.unauthorized;\n case 403:\n return mergedTranslations.messages.forbidden;\n case 404:\n return mergedTranslations.messages.notFound;\n case 502:\n case 503:\n return mergedTranslations.messages.unavailable;\n case 504:\n return mergedTranslations.messages.timeout;\n default:\n return mergedTranslations.messages.general;\n }\n };\n\n useEffect(() => {\n notifications.forEach(notification => {\n if (\n notification.status &&\n notification.handled &&\n (notification.status === 401 || notification.status === 403)\n ) {\n dispatchFn({ type: \"remove\", payload: { id: notification.id } });\n } else if (notification.status && !notification.handled && notification.type === \"error\") {\n enqueueErrorAlert({\n title: notification.title ?? mergedTranslations.general.error,\n content: determineNotificationMessage(notification as Notification<ErrorNotification>),\n onClose: () => dispatchFn({ type: \"remove\", payload: { id: notification.id } })\n });\n dispatchFn({ type: \"handled\", payload: { id: notification.id, handled: true } });\n } else if (notification.title && !notification.handled && notification.type === \"success\") {\n enqueueSuccessAlert({\n title: notification.title ?? mergedTranslations.general.success,\n content: notification.message,\n onClose: () => dispatchFn({ type: \"remove\", payload: { id: notification.id } })\n });\n\n dispatchFn({ type: \"handled\", payload: { id: notification.id, handled: true } });\n }\n });\n }, [notifications.length]);\n\n return null;\n};\n\nexport const NotificationContext = createContext<{\n state: NotificationState;\n dispatch: React.Dispatch<NotificationAction>;\n}>({\n state: initialState,\n dispatch: () => undefined\n});\n\nexport interface Props {\n children?: ReactNode;\n translations?: DeepPartial<Translations>;\n}\n\nexport const NotificationProvider = ({ children, translations }: Props) => {\n const [state, dispatch] = useReducer(notificationReducer, initialState);\n\n return (\n <NotificationContext.Provider value={{ state, dispatch }}>\n {children}\n <NotificationHandler translations={translations} dispatchFn={dispatch} />\n </NotificationContext.Provider>\n );\n};\n\nexport const useNotificationContext = () => {\n const ctx = useContext(NotificationContext);\n\n const addNotification = useCallback(\n (notification: AddNotification) => {\n ctx.dispatch({ type: \"add\", payload: notification });\n },\n [ctx]\n );\n\n const removeNotification = useCallback(\n (id: string) => {\n ctx.dispatch({ type: \"remove\", payload: { id } });\n },\n [ctx]\n );\n\n const resetNotifications = useCallback(() => {\n ctx.dispatch({ type: \"reset\" });\n }, [ctx]);\n\n return {\n state: ctx.state,\n addNotification,\n removeNotification,\n resetNotifications\n };\n};\n\nexport const notificationReducer = (\n state: NotificationState,\n action: NotificationAction\n): NotificationState => {\n switch (action.type) {\n case \"add\":\n return {\n ...state,\n notifications: [\n ...state.notifications,\n {\n ...action.payload,\n id: generateID(),\n handled: false\n }\n ]\n };\n case \"remove\":\n return {\n ...state,\n notifications: state.notifications.filter(\n notification => notification.id !== action.payload?.id\n )\n };\n case \"handled\":\n return {\n ...state,\n notifications: state.notifications.map(notification =>\n notification.id === action.payload?.id ? { ...notification, handled: true } : notification\n )\n };\n case \"reset\":\n return {\n ...state,\n notifications: []\n };\n default:\n return state;\n }\n};\n"],"names":["initialState","notifications","NotificationHandler","translations","dispatchFn","enqueueErrorAlert","enqueueSuccessAlert","useAlert","state","useNotificationContext","mergedTranslations","deepMerge","defaultTranslations","determineNotificationMessage","notification","message","status","messages","general","badRequest","unauthorized","forbidden","notFound","unavailable","timeout","useEffect","forEach","handled","type","payload","id","title","error","content","onClose","success","length","NotificationContext","createContext","dispatch","ctx","useContext","addNotification","useCallback","removeNotification","resetNotifications","notificationReducer","action","generateID","filter","_a","map","children","useReducer","React","createElement","Provider","value"],"mappings":"kOAgDMA,EAAkC,CACtCC,cAAe,IAQJC,EAAsB,EACjCC,eAAe,CAAA,EACfC,iBAEA,MAAMC,kBAAEA,EAAAC,oBAAmBA,GAAwBC,cAEjDC,OAAOP,cAAEA,IACPQ,IAEEC,EAAqBC,EAAAA,UAAwBC,EAAAA,oBAAqBT,GAElEU,EAAgCC,IACpC,GAAIA,EAAaC,QACf,OAAOD,EAAaC,QAGtB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,GAEjBK,EAAkBC,EAAAA,YACrB7B,IACC0B,EAAID,SAAS,CAAEX,KAAM,MAAOC,QAASf,KAEvC,CAAC0B,IAGGI,EAAqBD,EAAAA,YACxBb,IACCU,EAAID,SAAS,CAAEX,KAAM,SAAUC,QAAS,CAAEC,SAE5C,CAACU,IAGGK,EAAqBF,EAAAA,YAAY,KACrCH,EAAID,SAAS,CAAEX,KAAM,WACpB,CAACY,IAEJ,MAAO,CACLhC,MAAOgC,EAAIhC,MACXkC,kBACAE,qBACAC,uBAISC,EAAsB,CACjCtC,EACAuC,KAEA,OAAQA,EAAOnB,MACb,IAAK,MACH,MAAO,IACFpB,EACHP,cAAe,IACVO,EAAMP,cACT,IACK8C,EAAOlB,QACVC,GAAIkB,EAAAA,aACJrB,SAAS,KAIjB,IAAK,SACH,MAAO,IACFnB,EACHP,cAAeO,EAAMP,cAAcgD,OACjCnC,UAAgB,OAAAA,EAAagB,MAAO,OAAAoB,EAAAH,EAAOlB,cAAP,EAAAqB,EAAgBpB,OAG1D,IAAK,UACH,MAAO,IACFtB,EACHP,cAAeO,EAAMP,cAAckD,IAAIrC,UACrC,OAAAA,EAAagB,MAAO,OAAAoB,EAAAH,EAAOlB,cAAP,EAAAqB,EAAgBpB,IAAK,IAAKhB,EAAca,SAAS,GAASb,KAGpF,IAAK,QACH,MAAO,IACFN,EACHP,cAAe,IAEnB,QACE,OAAOO,6FA7EuB,EAAG4C,WAAUjD,mBAC/C,MAAOK,EAAO+B,GAAYc,EAAAA,WAAWP,EAAqB9C,GAE1D,OACEsD,EAAAC,cAAClB,EAAoBmB,SAApB,CAA6BC,MAAO,CAAEjD,QAAO+B,aAC3Ca,EACDE,EAAAC,cAACrD,EAAA,CAAoBC,eAA4BC,WAAYmC"}
@@ -1,146 +0,0 @@
1
- import React, { useReducer, useContext, useCallback, createContext, useEffect } from "react";
2
- import { defaultTranslations } from "./NotificationService.es.js";
3
- import { generateID, deepMerge } from "../../../util/helper.es.js";
4
- import { useAlert } from "../Alert/useAlert.es.js";
5
- const initialState = {
6
- notifications: []
7
- };
8
- const NotificationHandler = ({
9
- translations = {},
10
- dispatchFn
11
- }) => {
12
- const { enqueueErrorAlert, enqueueSuccessAlert } = useAlert();
13
- const {
14
- state: { notifications }
15
- } = useNotificationContext();
16
- const mergedTranslations = deepMerge(defaultTranslations, translations);
17
- const determineNotificationMessage = (notification) => {
18
- if (notification.message) {
19
- return notification.message;
20
- }
21
- switch (notification.status) {
22
- case 500:
23
- return mergedTranslations.messages.general;
24
- case 400:
25
- return mergedTranslations.messages.badRequest;
26
- case 401:
27
- return mergedTranslations.messages.unauthorized;
28
- case 403:
29
- return mergedTranslations.messages.forbidden;
30
- case 404:
31
- return mergedTranslations.messages.notFound;
32
- case 502:
33
- case 503:
34
- return mergedTranslations.messages.unavailable;
35
- case 504:
36
- return mergedTranslations.messages.timeout;
37
- default:
38
- return mergedTranslations.messages.general;
39
- }
40
- };
41
- useEffect(() => {
42
- notifications.forEach((notification) => {
43
- if (notification.status && notification.handled && (notification.status === 401 || notification.status === 403)) {
44
- dispatchFn({ type: "remove", payload: { id: notification.id } });
45
- } else if (notification.status && !notification.handled && notification.type === "error") {
46
- enqueueErrorAlert({
47
- title: notification.title ?? mergedTranslations.general.error,
48
- content: determineNotificationMessage(notification),
49
- onClose: () => dispatchFn({ type: "remove", payload: { id: notification.id } })
50
- });
51
- dispatchFn({ type: "handled", payload: { id: notification.id, handled: true } });
52
- } else if (notification.title && !notification.handled && notification.type === "success") {
53
- enqueueSuccessAlert({
54
- title: notification.title ?? mergedTranslations.general.success,
55
- content: notification.message,
56
- onClose: () => dispatchFn({ type: "remove", payload: { id: notification.id } })
57
- });
58
- dispatchFn({ type: "handled", payload: { id: notification.id, handled: true } });
59
- }
60
- });
61
- }, [notifications.length]);
62
- return null;
63
- };
64
- const NotificationContext = createContext({
65
- state: initialState,
66
- dispatch: () => void 0
67
- });
68
- const NotificationProvider = ({ children, translations }) => {
69
- const [state, dispatch] = useReducer(notificationReducer, initialState);
70
- return /* @__PURE__ */ React.createElement(NotificationContext.Provider, { value: { state, dispatch } }, children, /* @__PURE__ */ React.createElement(NotificationHandler, { translations, dispatchFn: dispatch }));
71
- };
72
- const useNotificationContext = () => {
73
- const ctx = useContext(NotificationContext);
74
- const addNotification = useCallback(
75
- (notification) => {
76
- ctx.dispatch({ type: "add", payload: notification });
77
- },
78
- [ctx]
79
- );
80
- const removeNotification = useCallback(
81
- (id) => {
82
- ctx.dispatch({ type: "remove", payload: { id } });
83
- },
84
- [ctx]
85
- );
86
- const resetNotifications = useCallback(() => {
87
- ctx.dispatch({ type: "reset" });
88
- }, [ctx]);
89
- return {
90
- state: ctx.state,
91
- addNotification,
92
- removeNotification,
93
- resetNotifications
94
- };
95
- };
96
- const notificationReducer = (state, action) => {
97
- switch (action.type) {
98
- case "add":
99
- return {
100
- ...state,
101
- notifications: [
102
- ...state.notifications,
103
- {
104
- ...action.payload,
105
- id: generateID(),
106
- handled: false
107
- }
108
- ]
109
- };
110
- case "remove":
111
- return {
112
- ...state,
113
- notifications: state.notifications.filter(
114
- (notification) => {
115
- var _a;
116
- return notification.id !== ((_a = action.payload) == null ? void 0 : _a.id);
117
- }
118
- )
119
- };
120
- case "handled":
121
- return {
122
- ...state,
123
- notifications: state.notifications.map(
124
- (notification) => {
125
- var _a;
126
- return notification.id === ((_a = action.payload) == null ? void 0 : _a.id) ? { ...notification, handled: true } : notification;
127
- }
128
- )
129
- };
130
- case "reset":
131
- return {
132
- ...state,
133
- notifications: []
134
- };
135
- default:
136
- return state;
137
- }
138
- };
139
- export {
140
- NotificationContext,
141
- NotificationHandler,
142
- NotificationProvider,
143
- notificationReducer,
144
- useNotificationContext
145
- };
146
- //# sourceMappingURL=NotificationContext.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NotificationContext.es.js","sources":["../../../../src/components/Notifications/NotificationProvider/NotificationContext.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n ReactNode,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useReducer\n} from \"react\";\nimport {\n Notification,\n ErrorNotification,\n SuccessNotification,\n Translations,\n AddNotification\n} from \"./notification.interfaces\";\nimport { defaultTranslations } from \"./NotificationService\";\nimport { deepMerge, generateID } from \"../../../util/helper\";\nimport { DeepPartial } from \"../../../interfaces\";\nimport { useAlert } from \"../Alert/useAlert\";\n\ninterface NotificationState {\n notifications: Notification<ErrorNotification | SuccessNotification>[];\n}\n\nexport interface NotificationAction {\n type: \"add\" | \"remove\" | \"handled\" | \"reset\";\n payload?: Notification<ErrorNotification | SuccessNotification> & {\n id?: string;\n handled?: boolean;\n };\n}\n\nconst initialState: NotificationState = {\n notifications: []\n};\n\nexport interface NotificationHandlerProps {\n translations?: DeepPartial<Translations>;\n dispatchFn: React.Dispatch<NotificationAction>;\n}\n\nexport const NotificationHandler = ({\n translations = {},\n dispatchFn\n}: NotificationHandlerProps) => {\n const { enqueueErrorAlert, enqueueSuccessAlert } = useAlert();\n const {\n state: { notifications }\n } = useNotificationContext();\n\n const mergedTranslations = deepMerge<Translations>(defaultTranslations, translations);\n\n const determineNotificationMessage = (notification: Notification<ErrorNotification>) => {\n if (notification.message) {\n return notification.message;\n }\n\n switch (notification.status) {\n case 500:\n return mergedTranslations.messages.general;\n case 400:\n return mergedTranslations.messages.badRequest;\n case 401:\n return mergedTranslations.messages.unauthorized;\n case 403:\n return mergedTranslations.messages.forbidden;\n case 404:\n return mergedTranslations.messages.notFound;\n case 502:\n case 503:\n return mergedTranslations.messages.unavailable;\n case 504:\n return mergedTranslations.messages.timeout;\n default:\n return mergedTranslations.messages.general;\n }\n };\n\n useEffect(() => {\n notifications.forEach(notification => {\n if (\n notification.status &&\n notification.handled &&\n (notification.status === 401 || notification.status === 403)\n ) {\n dispatchFn({ type: \"remove\", payload: { id: notification.id } });\n } else if (notification.status && !notification.handled && notification.type === \"error\") {\n enqueueErrorAlert({\n title: notification.title ?? mergedTranslations.general.error,\n content: determineNotificationMessage(notification as Notification<ErrorNotification>),\n onClose: () => dispatchFn({ type: \"remove\", payload: { id: notification.id } })\n });\n dispatchFn({ type: \"handled\", payload: { id: notification.id, handled: true } });\n } else if (notification.title && !notification.handled && notification.type === \"success\") {\n enqueueSuccessAlert({\n title: notification.title ?? mergedTranslations.general.success,\n content: notification.message,\n onClose: () => dispatchFn({ type: \"remove\", payload: { id: notification.id } })\n });\n\n dispatchFn({ type: \"handled\", payload: { id: notification.id, handled: true } });\n }\n });\n }, [notifications.length]);\n\n return null;\n};\n\nexport const NotificationContext = createContext<{\n state: NotificationState;\n dispatch: React.Dispatch<NotificationAction>;\n}>({\n state: initialState,\n dispatch: () => undefined\n});\n\nexport interface Props {\n children?: ReactNode;\n translations?: DeepPartial<Translations>;\n}\n\nexport const NotificationProvider = ({ children, translations }: Props) => {\n const [state, dispatch] = useReducer(notificationReducer, initialState);\n\n return (\n <NotificationContext.Provider value={{ state, dispatch }}>\n {children}\n <NotificationHandler translations={translations} dispatchFn={dispatch} />\n </NotificationContext.Provider>\n );\n};\n\nexport const useNotificationContext = () => {\n const ctx = useContext(NotificationContext);\n\n const addNotification = useCallback(\n (notification: AddNotification) => {\n ctx.dispatch({ type: \"add\", payload: notification });\n },\n [ctx]\n );\n\n const removeNotification = useCallback(\n (id: string) => {\n ctx.dispatch({ type: \"remove\", payload: { id } });\n },\n [ctx]\n );\n\n const resetNotifications = useCallback(() => {\n ctx.dispatch({ type: \"reset\" });\n }, [ctx]);\n\n return {\n state: ctx.state,\n addNotification,\n removeNotification,\n resetNotifications\n };\n};\n\nexport const notificationReducer = (\n state: NotificationState,\n action: NotificationAction\n): NotificationState => {\n switch (action.type) {\n case \"add\":\n return {\n ...state,\n notifications: [\n ...state.notifications,\n {\n ...action.payload,\n id: generateID(),\n handled: false\n }\n ]\n };\n case \"remove\":\n return {\n ...state,\n notifications: state.notifications.filter(\n notification => notification.id !== action.payload?.id\n )\n };\n case \"handled\":\n return {\n ...state,\n notifications: state.notifications.map(notification =>\n notification.id === action.payload?.id ? { ...notification, handled: true } : notification\n )\n };\n case \"reset\":\n return {\n ...state,\n notifications: []\n };\n default:\n return state;\n }\n};\n"],"names":[],"mappings":";;;;AAgDA,MAAM,eAAkC;AAAA,EACtC,eAAe,CAAA;AACjB;AAOO,MAAM,sBAAsB,CAAC;AAAA,EAClC,eAAe,CAAA;AAAA,EACf;AACF,MAAgC;AAC9B,QAAM,EAAE,mBAAmB,oBAAA,IAAwB,SAAA;AACnD,QAAM;AAAA,IACJ,OAAO,EAAE,cAAA;AAAA,EAAc,IACrB,uBAAA;AAEJ,QAAM,qBAAqB,UAAwB,qBAAqB,YAAY;AAEpF,QAAM,+BAA+B,CAAC,iBAAkD;AACtF,QAAI,aAAa,SAAS;AACxB,aAAO,aAAa;AAAA,IACtB;AAEA,YAAQ,aAAa,QAAA;AAAA,MACnB,KAAK;AACH,eAAO,mBAAmB,SAAS;AAAA,MACrC,KAAK;AACH,eAAO,mBAAmB,SAAS;AAAA,MACrC,KAAK;AACH,eAAO,mBAAmB,SAAS;AAAA,MACrC,KAAK;AACH,eAAO,mBAAmB,SAAS;AAAA,MACrC,KAAK;AACH,eAAO,mBAAmB,SAAS;AAAA,MACrC,KAAK;AAAA,MACL,KAAK;AACH,eAAO,mBAAmB,SAAS;AAAA,MACrC,KAAK;AACH,eAAO,mBAAmB,SAAS;AAAA,MACrC;AACE,eAAO,mBAAmB,SAAS;AAAA,IAAA;AAAA,EAEzC;AAEA,YAAU,MAAM;AACd,kBAAc,QAAQ,CAAA,iBAAgB;AACpC,UACE,aAAa,UACb,aAAa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H,eAAe,CAAA;AAAA,MAAC;AAAA,IAEpB;AACE,aAAO;AAAA,EAAA;AAEb;"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.defaultTranslations={general:{error:"Error",success:"Success"},messages:{general:"Something went wrong. Please try again later.",badRequest:"Bad request",unauthorized:"You are not authorized to perform this action.",forbidden:"You are not allowed to perform this action.",notFound:"The requested resource could not be found.",timeout:"The request timed out.",unavailable:"The server is currently unavailable. Please try again later."}};
2
- //# sourceMappingURL=NotificationService.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NotificationService.cjs.js","sources":["../../../../src/components/Notifications/NotificationProvider/NotificationService.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Translations } from \"./notification.interfaces\";\n\nexport const defaultTranslations: Translations = {\n general: {\n error: \"Error\",\n success: \"Success\"\n },\n messages: {\n general: \"Something went wrong. Please try again later.\",\n badRequest: \"Bad request\",\n unauthorized: \"You are not authorized to perform this action.\",\n forbidden: \"You are not allowed to perform this action.\",\n notFound: \"The requested resource could not be found.\",\n timeout: \"The request timed out.\",\n unavailable: \"The server is currently unavailable. Please try again later.\"\n }\n};\n"],"names":["general","error","success","messages","badRequest","unauthorized","forbidden","notFound","timeout","unavailable"],"mappings":"4GAkBiD,CAC/CA,QAAS,CACPC,MAAO,QACPC,QAAS,WAEXC,SAAU,CACRH,QAAS,gDACTI,WAAY,cACZC,aAAc,iDACdC,UAAW,8CACXC,SAAU,6CACVC,QAAS,yBACTC,YAAa"}
@@ -1,19 +0,0 @@
1
- const defaultTranslations = {
2
- general: {
3
- error: "Error",
4
- success: "Success"
5
- },
6
- messages: {
7
- general: "Something went wrong. Please try again later.",
8
- badRequest: "Bad request",
9
- unauthorized: "You are not authorized to perform this action.",
10
- forbidden: "You are not allowed to perform this action.",
11
- notFound: "The requested resource could not be found.",
12
- timeout: "The request timed out.",
13
- unavailable: "The server is currently unavailable. Please try again later."
14
- }
15
- };
16
- export {
17
- defaultTranslations
18
- };
19
- //# sourceMappingURL=NotificationService.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NotificationService.es.js","sources":["../../../../src/components/Notifications/NotificationProvider/NotificationService.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Translations } from \"./notification.interfaces\";\n\nexport const defaultTranslations: Translations = {\n general: {\n error: \"Error\",\n success: \"Success\"\n },\n messages: {\n general: \"Something went wrong. Please try again later.\",\n badRequest: \"Bad request\",\n unauthorized: \"You are not authorized to perform this action.\",\n forbidden: \"You are not allowed to perform this action.\",\n notFound: \"The requested resource could not be found.\",\n timeout: \"The request timed out.\",\n unavailable: \"The server is currently unavailable. Please try again later.\"\n }\n};\n"],"names":[],"mappings":"AAkBO,MAAM,sBAAoC;AAAA,EAC/C,SAAS;AAAA,IACP,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,UAAU;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,WAAW;AAAA,IACX,UAAU;AAAA,IACV,SAAS;AAAA,IACT,aAAa;AAAA,EAAA;AAEjB;"}