@tap-payments/os-micro-frontend-shared 0.1.367-test.1 → 0.1.367-test.1-test.2-test.3

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 (50) hide show
  1. package/build/components/Notifications/Notifications.d.ts +1 -0
  2. package/build/components/Notifications/Notifications.js +12 -0
  3. package/build/components/Notifications/index.d.ts +2 -0
  4. package/build/components/Notifications/index.js +2 -0
  5. package/build/components/TableHeader/FiltersRow.d.ts +1 -1
  6. package/build/components/TableHeader/FiltersRow.js +4 -2
  7. package/build/components/TableHeader/TableHeader.d.ts +1 -1
  8. package/build/components/TableHeader/TableHeader.js +2 -2
  9. package/build/components/TableHeader/TableView/CreateViewDialog.d.ts +3 -0
  10. package/build/components/TableHeader/TableView/CreateViewDialog.js +98 -0
  11. package/build/components/TableHeader/TableView/CustomViews.js +1 -1
  12. package/build/components/TableHeader/TableView/ViewsDropdown.d.ts +22 -0
  13. package/build/components/TableHeader/TableView/ViewsDropdown.js +137 -0
  14. package/build/components/TableHeader/TableView/ViewsManager.d.ts +29 -0
  15. package/build/components/TableHeader/TableView/ViewsManager.js +108 -0
  16. package/build/components/TableHeader/TableView/constants.d.ts +10 -0
  17. package/build/components/TableHeader/TableView/constants.js +10 -0
  18. package/build/components/TableHeader/TableView/data.d.ts +5 -0
  19. package/build/components/TableHeader/TableView/data.js +54 -0
  20. package/build/components/TableHeader/TableView/hooks.d.ts +25 -0
  21. package/build/components/TableHeader/TableView/hooks.js +79 -0
  22. package/build/components/TableHeader/TableView/index.d.ts +12 -3
  23. package/build/components/TableHeader/TableView/index.js +11 -3
  24. package/build/components/TableHeader/TableView/styles.d.ts +114 -0
  25. package/build/components/TableHeader/TableView/styles.js +399 -0
  26. package/build/components/TableHeader/TableView/types.d.ts +52 -0
  27. package/build/components/TableHeader/TableView/utils.d.ts +74 -0
  28. package/build/components/TableHeader/TableView/utils.js +234 -0
  29. package/build/components/TableHeader/type.d.ts +16 -0
  30. package/build/components/index.d.ts +1 -1
  31. package/build/components/index.js +1 -1
  32. package/build/constants/assets.d.ts +1 -0
  33. package/build/constants/assets.js +1 -0
  34. package/build/hooks/index.d.ts +0 -1
  35. package/build/hooks/index.js +0 -1
  36. package/build/types/appEvents.d.ts +1 -3
  37. package/build/types/appEvents.js +0 -1
  38. package/build/types/index.d.ts +0 -1
  39. package/build/types/index.js +0 -1
  40. package/package.json +2 -2
  41. package/build/components/Toaster/Toaster.d.ts +0 -1
  42. package/build/components/Toaster/Toaster.js +0 -12
  43. package/build/components/Toaster/index.d.ts +0 -2
  44. package/build/components/Toaster/index.js +0 -2
  45. package/build/hooks/useToast.d.ts +0 -12
  46. package/build/hooks/useToast.js +0 -43
  47. package/build/types/toast.d.ts +0 -16
  48. /package/build/components/{Toaster → Notifications}/style.d.ts +0 -0
  49. /package/build/components/{Toaster → Notifications}/style.js +0 -0
  50. /package/build/{types/toast.js → components/TableHeader/TableView/types.js} +0 -0
@@ -0,0 +1,52 @@
1
+ import type { ColumnViewProps } from '../../../types/index.js';
2
+ export type ViewMode = 'advanced' | 'sheet';
3
+ export interface ViewMenuItem {
4
+ label: string;
5
+ id: string;
6
+ columns?: string[];
7
+ submenu?: ColumnViewProps[];
8
+ isCustom?: boolean;
9
+ }
10
+ export interface FieldItem {
11
+ code: string;
12
+ name: {
13
+ text: string;
14
+ lang: string;
15
+ }[];
16
+ default?: boolean;
17
+ }
18
+ export interface ColumnItem {
19
+ code: string;
20
+ name: {
21
+ text: string;
22
+ lang: string;
23
+ }[];
24
+ order?: number;
25
+ default?: boolean;
26
+ fields?: FieldItem[];
27
+ }
28
+ export interface LayoutSection {
29
+ code: string;
30
+ columns: ColumnItem[];
31
+ }
32
+ export interface CreateCustomViewDialogProps {
33
+ open: boolean;
34
+ onClose: () => void;
35
+ onCreate?: (data: {
36
+ name: string;
37
+ selectedColumns: ColumnViewProps[];
38
+ }) => Promise<void>;
39
+ availableColumns?: ColumnViewProps[];
40
+ isLoading?: boolean;
41
+ defaultColumns?: ColumnViewProps[];
42
+ editingView?: {
43
+ id: string;
44
+ label: string;
45
+ submenu?: ColumnViewProps[];
46
+ } | null;
47
+ onDelete?: (viewId: string) => Promise<void>;
48
+ }
49
+ export interface ColumnCheckState {
50
+ checked: boolean;
51
+ indeterminate: boolean;
52
+ }
@@ -0,0 +1,74 @@
1
+ import type { ColumnViewProps } from '../../../types/index.js';
2
+ import type { LayoutSection, ViewMenuItem, ColumnCheckState, ViewMode } from './types';
3
+ /**
4
+ * Transform API layout response to internal ColumnViewProps format
5
+ */
6
+ export declare const transformLayoutToColumns: (layout: LayoutSection[], lang?: string) => ColumnViewProps[];
7
+ export declare const getColumnsByMode: (mode: ViewMode) => ColumnViewProps[];
8
+ export declare const isDateColumn: (name: string) => boolean;
9
+ export declare const getColumnCheckState: (column: ColumnViewProps) => ColumnCheckState;
10
+ export declare const createCustomViewMenuItem: (name: string, selectedColumns: ColumnViewProps[]) => ViewMenuItem;
11
+ /**
12
+ * Initialize columns for editing mode
13
+ */
14
+ export declare const initializeEditingColumns: (editingColumns: ColumnViewProps[], availableColumns: ColumnViewProps[]) => ColumnViewProps[];
15
+ /**
16
+ * Initialize columns for create mode (all unchecked except date)
17
+ */
18
+ export declare const initializeCreateColumns: (availableColumns: ColumnViewProps[]) => ColumnViewProps[];
19
+ /**
20
+ * Reset columns to their default selection state
21
+ */
22
+ export declare const resetColumnsToDefault: (columns: ColumnViewProps[]) => ColumnViewProps[];
23
+ /**
24
+ * Toggle a column's selection (including all children if present)
25
+ */
26
+ export declare const toggleColumn: (columns: ColumnViewProps[], columnName: string) => ColumnViewProps[];
27
+ /**
28
+ * Toggle a sub-item's selection and update parent state
29
+ */
30
+ export declare const toggleSubItem: (columns: ColumnViewProps[], columnName: string, subItemName: string) => ColumnViewProps[];
31
+ /**
32
+ * Select or deselect all columns (except date)
33
+ */
34
+ export declare const toggleAllColumns: (columns: ColumnViewProps[], selectAll: boolean) => ColumnViewProps[];
35
+ /**
36
+ * Check if all non-date columns are selected
37
+ */
38
+ export declare const areAllColumnsSelected: (columns: ColumnViewProps[]) => boolean;
39
+ /**
40
+ * Check if some (but not all) non-date columns are selected
41
+ */
42
+ export declare const areSomeColumnsSelected: (columns: ColumnViewProps[], allSelected: boolean) => boolean;
43
+ /**
44
+ * Validate template name
45
+ */
46
+ export declare const isValidTemplateName: (name: string, maxLength: number) => boolean;
47
+ /**
48
+ * Deep clone columns array with all nested properties
49
+ */
50
+ export declare const deepCloneColumns: (columns: ColumnViewProps[]) => ColumnViewProps[];
51
+ /**
52
+ * Toggle a single column's selection state
53
+ */
54
+ export declare const toggleSingleColumn: (columns: ColumnViewProps[], columnName: string) => ColumnViewProps[];
55
+ /**
56
+ * Get submenu items for a view menu item
57
+ */
58
+ export declare const getSubmenuItems: (item: ViewMenuItem, defaultColumns: ColumnViewProps[]) => ColumnViewProps[];
59
+ /**
60
+ * Check if a view menu item has submenu
61
+ */
62
+ export declare const hasSubmenu: (item: ViewMenuItem, defaultColumns: ColumnViewProps[]) => boolean;
63
+ /**
64
+ * Check if all columns in current state are selected
65
+ */
66
+ export declare const areAllCurrentColumnsSelected: (columns: ColumnViewProps[]) => boolean;
67
+ /**
68
+ * Check if some (but not all) columns in current state are selected
69
+ */
70
+ export declare const areSomeCurrentColumnsSelected: (columns: ColumnViewProps[], allSelected: boolean) => boolean;
71
+ /**
72
+ * Toggle all columns selection (select all or unselect all)
73
+ */
74
+ export declare const toggleAllCurrentColumns: (columns: ColumnViewProps[], shouldSelect: boolean) => ColumnViewProps[];
@@ -0,0 +1,234 @@
1
+ import { advancedColumns, sheetColumns } from './data';
2
+ /**
3
+ * Transform API layout response to internal ColumnViewProps format
4
+ */
5
+ export const transformLayoutToColumns = (layout, lang = 'en') => {
6
+ const columns = [];
7
+ layout.forEach((section) => {
8
+ section.columns.forEach((col) => {
9
+ var _a, _b, _c, _d;
10
+ const label = ((_a = col.name.find((n) => n.lang === lang)) === null || _a === void 0 ? void 0 : _a.text) || ((_b = col.name[0]) === null || _b === void 0 ? void 0 : _b.text) || col.code;
11
+ const menuItems = (_c = col.fields) === null || _c === void 0 ? void 0 : _c.map((field) => {
12
+ var _a, _b;
13
+ return ({
14
+ name: field.code,
15
+ label: ((_a = field.name.find((n) => n.lang === lang || n.lang === '')) === null || _a === void 0 ? void 0 : _a.text) || field.code,
16
+ selected: (_b = field.default) !== null && _b !== void 0 ? _b : false,
17
+ });
18
+ });
19
+ columns.push({
20
+ name: col.code,
21
+ label,
22
+ selected: (_d = col.default) !== null && _d !== void 0 ? _d : false,
23
+ menuItems: (menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) ? menuItems : undefined,
24
+ });
25
+ });
26
+ });
27
+ return columns;
28
+ };
29
+ export const getColumnsByMode = (mode) => {
30
+ return mode === 'advanced' ? [...advancedColumns] : [...sheetColumns];
31
+ };
32
+ export const isDateColumn = (name) => {
33
+ return name.toLowerCase() === 'date';
34
+ };
35
+ export const getColumnCheckState = (column) => {
36
+ var _a, _b;
37
+ if (!((_a = column.menuItems) === null || _a === void 0 ? void 0 : _a.length)) {
38
+ return { checked: (_b = column.selected) !== null && _b !== void 0 ? _b : false, indeterminate: false };
39
+ }
40
+ const selectedCount = column.menuItems.filter((item) => item.selected).length;
41
+ return {
42
+ checked: selectedCount > 0,
43
+ indeterminate: selectedCount > 0 && selectedCount < column.menuItems.length,
44
+ };
45
+ };
46
+ export const createCustomViewMenuItem = (name, selectedColumns) => ({
47
+ label: name,
48
+ id: `custom_${Date.now()}`,
49
+ columns: selectedColumns.map((col) => col.name),
50
+ submenu: selectedColumns,
51
+ isCustom: true,
52
+ });
53
+ /**
54
+ * Initialize columns for editing mode
55
+ */
56
+ export const initializeEditingColumns = (editingColumns, availableColumns) => {
57
+ return availableColumns
58
+ .filter((col) => !isDateColumn(col.name))
59
+ .map((col) => {
60
+ var _a;
61
+ const savedCol = editingColumns.find((ec) => ec.name === col.name);
62
+ return (savedCol || Object.assign(Object.assign({}, col), { selected: false, menuItems: (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: false }))) }));
63
+ });
64
+ };
65
+ /**
66
+ * Initialize columns for create mode (all unchecked except date)
67
+ */
68
+ export const initializeCreateColumns = (availableColumns) => {
69
+ return availableColumns
70
+ .filter((col) => !isDateColumn(col.name))
71
+ .map((col) => {
72
+ var _a;
73
+ return (Object.assign(Object.assign({}, col), { selected: false, menuItems: (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: false }))) }));
74
+ });
75
+ };
76
+ /**
77
+ * Reset columns to their default selection state
78
+ */
79
+ export const resetColumnsToDefault = (columns) => {
80
+ return columns
81
+ .filter((col) => !isDateColumn(col.name))
82
+ .map((col) => {
83
+ var _a, _b;
84
+ return (Object.assign(Object.assign({}, col), { selected: (_a = col.selected) !== null && _a !== void 0 ? _a : false, menuItems: (_b = col.menuItems) === null || _b === void 0 ? void 0 : _b.map((item) => { var _a; return (Object.assign(Object.assign({}, item), { selected: (_a = item.selected) !== null && _a !== void 0 ? _a : false })); }) }));
85
+ });
86
+ };
87
+ /**
88
+ * Toggle a column's selection (including all children if present)
89
+ */
90
+ export const toggleColumn = (columns, columnName) => {
91
+ return columns.map((col) => {
92
+ var _a;
93
+ if (col.name !== columnName)
94
+ return col;
95
+ const newSelected = !col.selected;
96
+ const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: newSelected })));
97
+ return Object.assign(Object.assign({}, col), { selected: newSelected, menuItems: updatedMenuItems });
98
+ });
99
+ };
100
+ /**
101
+ * Toggle a sub-item's selection and update parent state
102
+ */
103
+ export const toggleSubItem = (columns, columnName, subItemName) => {
104
+ return columns.map((col) => {
105
+ var _a, _b;
106
+ if (col.name !== columnName)
107
+ return col;
108
+ const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (item.name === subItemName ? Object.assign(Object.assign({}, item), { selected: !item.selected }) : item));
109
+ const hasSelectedChildren = (_b = updatedMenuItems === null || updatedMenuItems === void 0 ? void 0 : updatedMenuItems.some((item) => item.selected)) !== null && _b !== void 0 ? _b : false;
110
+ return Object.assign(Object.assign({}, col), { menuItems: updatedMenuItems, selected: hasSelectedChildren });
111
+ });
112
+ };
113
+ /**
114
+ * Select or deselect all columns (except date)
115
+ */
116
+ export const toggleAllColumns = (columns, selectAll) => {
117
+ return columns.map((col) => {
118
+ var _a;
119
+ if (isDateColumn(col.name))
120
+ return col;
121
+ const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: selectAll })));
122
+ return Object.assign(Object.assign({}, col), { selected: selectAll, menuItems: updatedMenuItems });
123
+ });
124
+ };
125
+ /**
126
+ * Check if all non-date columns are selected
127
+ */
128
+ export const areAllColumnsSelected = (columns) => {
129
+ const nonDateColumns = columns.filter((col) => !isDateColumn(col.name));
130
+ return (nonDateColumns.length > 0 &&
131
+ nonDateColumns.every((col) => {
132
+ var _a;
133
+ if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
134
+ return col.menuItems.some((item) => item.selected);
135
+ }
136
+ return col.selected;
137
+ }));
138
+ };
139
+ /**
140
+ * Check if some (but not all) non-date columns are selected
141
+ */
142
+ export const areSomeColumnsSelected = (columns, allSelected) => {
143
+ const nonDateColumns = columns.filter((col) => !isDateColumn(col.name));
144
+ const hasAnySelected = nonDateColumns.some((col) => {
145
+ var _a;
146
+ if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
147
+ return col.menuItems.some((item) => item.selected);
148
+ }
149
+ return col.selected;
150
+ });
151
+ return hasAnySelected && !allSelected;
152
+ };
153
+ /**
154
+ * Validate template name
155
+ */
156
+ export const isValidTemplateName = (name, maxLength) => {
157
+ return name.trim().length > 0 && name.length <= maxLength;
158
+ };
159
+ /**
160
+ * Deep clone columns array with all nested properties
161
+ */
162
+ export const deepCloneColumns = (columns) => {
163
+ return columns.map((col) => {
164
+ var _a, _b;
165
+ return (Object.assign(Object.assign({}, col), { selected: (_a = col.selected) !== null && _a !== void 0 ? _a : false, menuItems: (_b = col.menuItems) === null || _b === void 0 ? void 0 : _b.map((item) => {
166
+ var _a;
167
+ return (Object.assign(Object.assign({}, item), { selected: (_a = item.selected) !== null && _a !== void 0 ? _a : false }));
168
+ }) }));
169
+ });
170
+ };
171
+ /**
172
+ * Toggle a single column's selection state
173
+ */
174
+ export const toggleSingleColumn = (columns, columnName) => {
175
+ return columns.map((col) => (col.name === columnName ? Object.assign(Object.assign({}, col), { selected: !col.selected }) : col));
176
+ };
177
+ /**
178
+ * Get submenu items for a view menu item
179
+ */
180
+ export const getSubmenuItems = (item, defaultColumns) => {
181
+ var _a;
182
+ if (item.isCustom && ((_a = item.submenu) === null || _a === void 0 ? void 0 : _a.length)) {
183
+ return item.submenu;
184
+ }
185
+ if (item.id === 'default') {
186
+ return defaultColumns;
187
+ }
188
+ return item.submenu || [];
189
+ };
190
+ /**
191
+ * Check if a view menu item has submenu
192
+ */
193
+ export const hasSubmenu = (item, defaultColumns) => {
194
+ return getSubmenuItems(item, defaultColumns).length > 0;
195
+ };
196
+ /**
197
+ * Check if all columns in current state are selected
198
+ */
199
+ export const areAllCurrentColumnsSelected = (columns) => {
200
+ if (columns.length === 0)
201
+ return false;
202
+ return columns.every((col) => {
203
+ var _a;
204
+ if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
205
+ return col.menuItems.some((item) => item.selected);
206
+ }
207
+ return col.selected;
208
+ });
209
+ };
210
+ /**
211
+ * Check if some (but not all) columns in current state are selected
212
+ */
213
+ export const areSomeCurrentColumnsSelected = (columns, allSelected) => {
214
+ if (columns.length === 0)
215
+ return false;
216
+ const hasAny = columns.some((col) => {
217
+ var _a;
218
+ if ((_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.length) {
219
+ return col.menuItems.some((item) => item.selected);
220
+ }
221
+ return col.selected;
222
+ });
223
+ return hasAny && !allSelected;
224
+ };
225
+ /**
226
+ * Toggle all columns selection (select all or unselect all)
227
+ */
228
+ export const toggleAllCurrentColumns = (columns, shouldSelect) => {
229
+ return columns.map((col) => {
230
+ var _a;
231
+ const updatedMenuItems = (_a = col.menuItems) === null || _a === void 0 ? void 0 : _a.map((item) => (Object.assign(Object.assign({}, item), { selected: shouldSelect })));
232
+ return Object.assign(Object.assign({}, col), { selected: shouldSelect, menuItems: updatedMenuItems });
233
+ });
234
+ };
@@ -2,6 +2,7 @@ import React, { ReactNode } from 'react';
2
2
  import type { CalenderMode, TableHeaderStatus, ColumnViewProps, TableMode, Timezone, SegmentCountry } from '../../types/index.js';
3
3
  import { AvailableStatus } from '../StatusBar/type';
4
4
  import { PartialExcept } from '../../types/index.js';
5
+ import type { ViewMenuItem } from './TableView/types';
5
6
  type ViewsOptions = {
6
7
  default: {};
7
8
  developer: {};
@@ -44,6 +45,21 @@ export interface TableHeaderProps<IStatus extends TableHeaderStatus | TableHeade
44
45
  id: string;
45
46
  label: string;
46
47
  }) => void;
48
+ customViews?: ViewMenuItem[];
49
+ onCreateCustomView?: (data: {
50
+ name: string;
51
+ selectedColumns: ColumnViewProps[];
52
+ }) => Promise<void>;
53
+ onEditCustomView?: (viewId: string, data: {
54
+ name: string;
55
+ selectedColumns: ColumnViewProps[];
56
+ }) => Promise<void>;
57
+ onDeleteCustomView?: (viewId: string) => Promise<void>;
58
+ viewMode?: 'advanced' | 'sheet';
59
+ onTableViewsChange?: (tableViews: ColumnViewProps[]) => void;
60
+ initialTableViews?: ColumnViewProps[];
61
+ onCustomViewsChange?: (customViews: ViewMenuItem[]) => void;
62
+ initialCustomViews?: ViewMenuItem[];
47
63
  onToggleTextButtonClick?: () => void;
48
64
  children?: ReactNode;
49
65
  calendarGroupBy?: string;
@@ -50,7 +50,7 @@ export { default as MultiSelectDropdownButton, type ButtonWithDropdownProps } fr
50
50
  export { default as MultiSelectWithSearch, type MultiSelectWithSearchProps, ChildMenuItem, ParentMenuItem } from './MultiSelectWithSearch';
51
51
  export { default as NestedDropdown, type DropdownProps, type Selected, type Placement, Dropdown, NestedMenuItem } from './NestedDropdown';
52
52
  export { default as NoInternet } from './NoInternet';
53
- export { default as Toaster } from './Toaster';
53
+ export { default as Notifications } from './Notifications';
54
54
  export { default as ProgressBar } from './ProgressBar';
55
55
  export { default as ProgressRing } from './ProgressRing';
56
56
  export * from './InputBase';
@@ -50,7 +50,7 @@ export { default as MultiSelectDropdownButton } from './MultiSelectDropdownButto
50
50
  export { default as MultiSelectWithSearch, ChildMenuItem, ParentMenuItem } from './MultiSelectWithSearch';
51
51
  export { default as NestedDropdown, Dropdown, NestedMenuItem } from './NestedDropdown';
52
52
  export { default as NoInternet } from './NoInternet';
53
- export { default as Toaster } from './Toaster';
53
+ export { default as Notifications } from './Notifications';
54
54
  export { default as ProgressBar } from './ProgressBar';
55
55
  export { default as ProgressRing } from './ProgressRing';
56
56
  export * from './InputBase';
@@ -338,6 +338,7 @@ export declare const TAP3DSPROVIDERIcon: string;
338
338
  export declare const greyPlusIcon: string;
339
339
  export declare const greyMinusIcon: string;
340
340
  export declare const noPreviewIcon: string;
341
+ export declare const editIcon: string;
341
342
  export declare const viewInvoiceIcon: string;
342
343
  export declare const checkoutStatusIcon: string;
343
344
  export declare const checkoutStatusBlueIcon: string;
@@ -344,6 +344,7 @@ export const TAP3DSPROVIDERIcon = `${lightUrl}/provider/TAP3DS.svg`;
344
344
  export const greyPlusIcon = `${lightUrl}/greyPlusIcon.svg`;
345
345
  export const greyMinusIcon = `${lightUrl}/greyMinusIcon.svg`;
346
346
  export const noPreviewIcon = `${lightUrl}/noPreviewIcon.svg`;
347
+ export const editIcon = `${lightUrl}/other/editIcon.svg`;
347
348
  export const viewInvoiceIcon = `${appBaseUrl}/viewInvoice.svg`;
348
349
  export const checkoutStatusIcon = `${appBaseUrl}/checkoutStatus.svg`;
349
350
  export const checkoutStatusBlueIcon = `${appBaseUrl}/checkStatusOutBlue.svg`;
@@ -13,4 +13,3 @@ export * from './useAppsInfo';
13
13
  export * from './useAppEventPublisher';
14
14
  export * from './useAppEventListener';
15
15
  export * from './useSelectedMerchantDetails';
16
- export * from './useToast';
@@ -13,4 +13,3 @@ export * from './useAppsInfo';
13
13
  export * from './useAppEventPublisher';
14
14
  export * from './useAppEventListener';
15
15
  export * from './useSelectedMerchantDetails';
16
- export * from './useToast';
@@ -1,4 +1,4 @@
1
- import { CalenderMode, NavigateFunction, TableMode, Timezone, ToastEventPayload } from './index.js';
1
+ import { CalenderMode, NavigateFunction, TableMode, Timezone } from './index.js';
2
2
  import { DragControls } from 'framer-motion';
3
3
  export declare enum AppEvent {
4
4
  OnClickTableAction = "on-click-table-action",
@@ -10,7 +10,6 @@ export declare enum AppEvent {
10
10
  OnNavigate = "on-navigate",
11
11
  OnStartDrag = "on-start-drag",
12
12
  OnChangeAppToolbar = "on-change-app-toolbar",
13
- OnToast = "on-toast",
14
13
  OnModifyRemotePayload = "on-modify-remote-payload"
15
14
  }
16
15
  /**
@@ -47,5 +46,4 @@ export type AppEventMap = {
47
46
  windowId: string;
48
47
  payload: object;
49
48
  }) => void;
50
- [AppEvent.OnToast]: (params: ToastEventPayload) => void;
51
49
  };
@@ -10,7 +10,6 @@ export var AppEvent;
10
10
  AppEvent["OnNavigate"] = "on-navigate";
11
11
  AppEvent["OnStartDrag"] = "on-start-drag";
12
12
  AppEvent["OnChangeAppToolbar"] = "on-change-app-toolbar";
13
- AppEvent["OnToast"] = "on-toast";
14
13
  // Remote Events
15
14
  AppEvent["OnModifyRemotePayload"] = "on-modify-remote-payload";
16
15
  })(AppEvent || (AppEvent = {}));
@@ -32,4 +32,3 @@ export * from './filter';
32
32
  export * from './utilities';
33
33
  export * from './reports';
34
34
  export * from './document';
35
- export * from './toast';
@@ -32,4 +32,3 @@ export * from './filter';
32
32
  export * from './utilities';
33
33
  export * from './reports';
34
34
  export * from './document';
35
- export * from './toast';
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.367-test.1",
5
- "testVersion": 1,
4
+ "version": "0.1.367-test.1-test.2-test.3",
5
+ "testVersion": 3,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",
@@ -1 +0,0 @@
1
- export default function Toaster(): import("react/jsx-runtime").JSX.Element;
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import Box from '@mui/material/Box';
3
- import { Toaster as HotToaster, resolveValue } from 'react-hot-toast';
4
- import { actionSuccessIcon, warningInfoIcon } from '../../constants/index.js';
5
- import { Content } from './style';
6
- const icons = {
7
- success: actionSuccessIcon,
8
- error: warningInfoIcon,
9
- };
10
- export default function Toaster() {
11
- return (_jsx(HotToaster, { children: (t) => (_jsxs(Content, { children: [icons[t.type] && _jsx(Box, { component: "img", src: icons[t.type], alt: t.type }), _jsx(Box, { children: resolveValue(t.message, t) })] })) }));
12
- }
@@ -1,2 +0,0 @@
1
- import Toaster from './Toaster';
2
- export default Toaster;
@@ -1,2 +0,0 @@
1
- import Toaster from './Toaster';
2
- export default Toaster;
@@ -1,12 +0,0 @@
1
- import { ToastMessage } from '../types/index.js';
2
- import type { ToastOptions } from 'react-hot-toast';
3
- export interface ToastFunction {
4
- (message: ToastMessage, options?: ToastOptions): string;
5
- success: (message: ToastMessage, options?: ToastOptions) => string;
6
- error: (message: ToastMessage, options?: ToastOptions) => string;
7
- loading: (message: ToastMessage, options?: ToastOptions) => string;
8
- custom: (message: ToastMessage, options?: ToastOptions) => string;
9
- dismiss: (toastId?: string) => void;
10
- remove: (toastId?: string) => void;
11
- }
12
- export declare function useToast(): ToastFunction;
@@ -1,43 +0,0 @@
1
- import { useAppEventPublisher } from './index.js';
2
- import { AppEvent } from '../types/index.js';
3
- export function useToast() {
4
- const publish = useAppEventPublisher(AppEvent.OnToast);
5
- const generateToastId = () => crypto.randomUUID();
6
- const base = ((message, options) => {
7
- var _a;
8
- const id = (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : generateToastId();
9
- publish({ action: 'show', variant: 'default', message, options: Object.assign(Object.assign({}, options), { id }) });
10
- return id;
11
- });
12
- base.success = (message, options) => {
13
- var _a;
14
- const id = (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : generateToastId();
15
- publish({ action: 'show', variant: 'success', message, options: Object.assign(Object.assign({}, options), { id }) });
16
- return id;
17
- };
18
- base.error = (message, options) => {
19
- var _a;
20
- const id = (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : generateToastId();
21
- publish({ action: 'show', variant: 'error', message, options: Object.assign(Object.assign({}, options), { id }) });
22
- return id;
23
- };
24
- base.loading = (message, options) => {
25
- var _a;
26
- const id = (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : generateToastId();
27
- publish({ action: 'show', variant: 'loading', message, options: Object.assign(Object.assign({}, options), { id }) });
28
- return id;
29
- };
30
- base.custom = (message, options) => {
31
- var _a;
32
- const id = (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : generateToastId();
33
- publish({ action: 'show', variant: 'custom', message, options: Object.assign(Object.assign({}, options), { id }) });
34
- return id;
35
- };
36
- base.dismiss = (toastId) => {
37
- publish({ action: 'dismiss', variant: 'dismiss', toastId });
38
- };
39
- base.remove = (toastId) => {
40
- publish({ action: 'remove', variant: 'remove', toastId });
41
- };
42
- return base;
43
- }
@@ -1,16 +0,0 @@
1
- import type { ToastOptions, ValueOrFunction, Renderable, Toast } from 'react-hot-toast';
2
- export type ToastMessage = ValueOrFunction<Renderable, Toast>;
3
- export type ToastEventPayload = {
4
- action: 'show';
5
- variant: 'default' | 'success' | 'error' | 'loading' | 'custom';
6
- message: ToastMessage;
7
- options?: ToastOptions;
8
- } | {
9
- variant: 'dismiss';
10
- action: 'dismiss';
11
- toastId?: string;
12
- } | {
13
- variant: 'remove';
14
- action: 'remove';
15
- toastId?: string;
16
- };