@tap-payments/os-micro-frontend-shared 0.1.135 → 0.1.136
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/BackgroundAnimation/BackgroundAnimation.js +28 -0
- package/build/components/BackgroundAnimation/Blob/Blob.js +2 -0
- package/build/components/Chip/style.js +1 -0
- package/build/components/ColorPicker/HexaFields.js +4 -0
- package/build/components/ColorPicker/style.js +1 -1
- package/build/components/Dialog/style.js +1 -0
- package/build/components/Dropdown2/style.js +2 -0
- package/build/components/HeatMap/constant.js +1 -1
- package/build/components/InputBase/AmountInputBase/CurrencyList/style.js +3 -0
- package/build/components/InputBase/PhoneInputBase/CountriesList/CountriesList.js +1 -1
- package/build/components/InputBase/PhoneInputBase/CountriesList/style.js +3 -0
- package/build/components/InputBase/SelectBase/SelectBase.js +1 -0
- package/build/components/InputBase/SelectBase/SelectBaseMultiple.js +3 -0
- package/build/components/InputBase/SelectBase/style.js +3 -2
- package/build/components/InputNumber/InputNumber.js +2 -0
- package/build/components/Inputs/Input/style.js +6 -2
- package/build/components/Inputs/Select/Select.js +1 -0
- package/build/components/Inputs/Select/style.js +3 -2
- package/build/components/JSONViewer/JSONViewer.js +10 -2
- package/build/components/JSONViewer/context/Provider.js +2 -0
- package/build/components/LeftPeekRightExpandingChip/LeftPeekRightExpandingChip.d.ts +10 -0
- package/build/components/LeftPeekRightExpandingChip/LeftPeekRightExpandingChip.js +14 -1
- package/build/components/LeftPeekRightExpandingChip/style.js +1 -0
- package/build/components/LeftPeekRightExpandingChip/useLeftPeekRightExpandingChip.js +30 -2
- package/build/components/MultiSelectStatusButton/MultiSelectStatusButton.js +3 -0
- package/build/components/NestedDropdown/Dropdown.js +3 -0
- package/build/components/RFH/Inputs/FormInput/FormInput.js +1 -0
- package/build/components/RFH/Inputs/MultiSelect/MultiSelect.js +1 -0
- package/build/components/RangeCalender/RangeCalender.js +1 -0
- package/build/components/RangeCalender/components/RangeDatepicker/RangeDatepicker.js +3 -1
- package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.d.ts +32 -0
- package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.js +36 -2
- package/build/components/RightLeftExpandingCenterChip/style.js +25 -4
- package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.d.ts +5 -0
- package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.js +53 -1
- package/build/components/ScrollLoader/ScrollLoader.js +2 -1
- package/build/components/StatusButton/StatusButton.js +11 -3
- package/build/components/StatusButton/constant.js +3 -1
- package/build/components/StatusButton/style.d.ts +2 -1
- package/build/components/StatusButton/type.d.ts +13 -1
- package/build/components/StatusIcons/AuthIcons/constants.js +5 -0
- package/build/components/StatusIcons/AuthorizationAutoIcons/CaptureAutoIcon.js +11 -0
- package/build/components/StatusIcons/AuthorizationAutoIcons/VoidAutoIcon.js +11 -0
- package/build/components/TableCells/CustomCells/ApplicationStatusCell/ApplicationStatusCell.js +3 -1
- package/build/components/TableCells/CustomCells/BrandCell/BrandCell.js +1 -0
- package/build/components/TableCells/CustomCells/ReferenceCell/ReferenceCell.js +3 -1
- package/build/components/TableCells/CustomCells/RefundStatusCell/components/RefundStateIcon.js +1 -0
- package/build/components/TableCells/CustomCells/SegmentsCell/SegmentsCell.js +3 -1
- package/build/components/TableCells/CustomCells/SourceMergedCell/SourceMergedCell.js +7 -1
- package/build/components/TableCells/CustomCells/StatusCell/StatusCell.js +1 -0
- package/build/components/TableView/CustomViews.js +2 -0
- package/build/components/TableView/TableView.js +1 -0
- package/build/components/Timepicker/Timepicker.js +1 -0
- package/build/components/Timepicker/utils.js +9 -5
- package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +11 -1
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableLoading.js +5 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/components/VirtualTable.js +6 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePinnedColumns.js +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableData.js +1 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.js +2 -0
- package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js +3 -2
- package/build/components/VirtualTables/SheetViewVirtualTable/style.js +1 -1
- package/build/components/VirtualTables/VirtualTable/VirtualTable.js +12 -2
- package/build/components/VirtualTables/VirtualTableWithCard/VirtualTableWithCard.js +6 -1
- package/build/components/VirtualTables/components/ColumnFilter/Inputs/Inputs.js +1 -0
- package/build/components/VirtualTables/components/TableFooter/TableFooter.js +9 -0
- package/build/components/VirtualTables/components/TableRow.js +5 -0
- package/build/components/VirtualTables/components/virtualScroll/ListItemWrapper.js +2 -0
- package/build/components/VirtualTables/components/virtualScroll/ListItemWrapperWithCard.js +2 -0
- package/build/components/VirtualTables/components/virtualScroll/VirtualScrollList.js +16 -1
- package/build/components/Widget/style.js +1 -0
- package/build/components/Window/style.js +1 -0
- package/build/components/index.d.ts +2 -1
- package/build/components/index.js +2 -1
- package/build/constants/assets.js +4 -0
- package/build/constants/server.js +1 -0
- package/build/hooks/useCountdown.js +4 -0
- package/build/hooks/useStickyHeaderShadow.js +6 -0
- package/build/utils/api.js +3 -0
- package/build/utils/array.js +5 -1
- package/build/utils/billing.js +1 -0
- package/build/utils/country.js +1 -0
- package/build/utils/currency.js +6 -0
- package/build/utils/date.d.ts +5 -0
- package/build/utils/date.js +31 -3
- package/build/utils/encrypt.js +3 -1
- package/build/utils/error.js +2 -0
- package/build/utils/freshdesk.js +2 -0
- package/build/utils/geography.js +1 -1
- package/build/utils/localStorage.js +7 -0
- package/build/utils/merchant.js +3 -0
- package/build/utils/number.js +1 -0
- package/build/utils/segment.js +1 -0
- package/build/utils/string.d.ts +7 -0
- package/build/utils/string.js +10 -0
- package/build/utils/style.d.ts +11 -0
- package/build/utils/style.js +28 -0
- package/build/utils/table.js +1 -1
- package/build/utils/url.js +2 -0
- package/package.json +2 -2
package/build/utils/api.js
CHANGED
|
@@ -61,6 +61,7 @@ api.interceptors.request.use((config) => {
|
|
|
61
61
|
}, 0);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
|
+
// create interceptor to add token to all requests
|
|
64
65
|
api.interceptors.request.use((config) => {
|
|
65
66
|
config.headers.Authorization = getLoggedInUserJwtToken();
|
|
66
67
|
const secretKey = getSecretKey();
|
|
@@ -81,7 +82,9 @@ export function setApiToken(token) {
|
|
|
81
82
|
api.defaults.headers.common.Authorization = token;
|
|
82
83
|
});
|
|
83
84
|
}
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
86
|
export function getHeaders(attrs) {
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
85
88
|
const _a = attrs !== null && attrs !== void 0 ? attrs : {}, { sandboxMode, fixedSecretKey, applicationId, serviceId, functionId, userFunctionId, segmentId } = _a, rest = __rest(_a, ["sandboxMode", "fixedSecretKey", "applicationId", "serviceId", "functionId", "userFunctionId", "segmentId"]);
|
|
86
89
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { live_mode: sandboxMode ? 'false' : 'true' }), (!!fixedSecretKey && { 'x-test-secret': fixedSecretKey })), (!!applicationId && { application_id: applicationId })), (!!serviceId && { service_id: serviceId })), (!!functionId && { function_id: functionId })), (!!userFunctionId && { user_function_id: userFunctionId }));
|
|
87
90
|
}
|
package/build/utils/array.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import orderBy from 'lodash/orderBy';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
export const generateArray = (length) => Array.from({ length }, (_, i) => i);
|
|
4
|
-
|
|
4
|
+
// eslint-disable-next-line
|
|
5
|
+
export const groupBy = (arr, groupFn) => arr.reduce(
|
|
6
|
+
// eslint-disable-next-line
|
|
7
|
+
(grouped, obj) => (Object.assign(Object.assign({}, grouped), { [groupFn(obj)]: [...(grouped[groupFn(obj)] || []), obj] })), {});
|
|
5
8
|
export function sortList({ list, sortBy, orders }) {
|
|
6
9
|
return (sortBy === null || sortBy === void 0 ? void 0 : sortBy.length) && (orders === null || orders === void 0 ? void 0 : orders.length) ? orderBy(list, sortBy, orders) : list;
|
|
7
10
|
}
|
|
11
|
+
// eslint-disable-next-line
|
|
8
12
|
export const sortByString = (list = [], key) => {
|
|
9
13
|
if (!list.length)
|
|
10
14
|
return [];
|
package/build/utils/billing.js
CHANGED
package/build/utils/country.js
CHANGED
|
@@ -4,6 +4,7 @@ export function getCountryNameByISO(countryCode) {
|
|
|
4
4
|
try {
|
|
5
5
|
const regionNames = new Intl.DisplayNames(['en'], { type: 'region' });
|
|
6
6
|
return regionNames.of(countryCode);
|
|
7
|
+
// eslint-disable-next-line
|
|
7
8
|
}
|
|
8
9
|
catch (error) {
|
|
9
10
|
toast.error((_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message);
|
package/build/utils/currency.js
CHANGED
|
@@ -22,6 +22,7 @@ export const intlCurrency = (charge, currencyType) => {
|
|
|
22
22
|
minimumFractionDigits: currencyConfig[currencyType] ? 3 : 2,
|
|
23
23
|
}).format(charge);
|
|
24
24
|
return currency;
|
|
25
|
+
// eslint-disable-next-line
|
|
25
26
|
}
|
|
26
27
|
catch (error) {
|
|
27
28
|
toast.error((_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message);
|
|
@@ -56,7 +57,9 @@ export const formatCurrencyWithInput = (charge, selectedCurrency) => {
|
|
|
56
57
|
return chargeString;
|
|
57
58
|
};
|
|
58
59
|
export function formatAmount(amount, decimal = 2) {
|
|
60
|
+
// Ensure the input is a number
|
|
59
61
|
const num = parseFloat(amount.toString());
|
|
62
|
+
// Check if it's a valid number
|
|
60
63
|
if (isNaN(num)) {
|
|
61
64
|
const [integerAmount, decimalAmount] = (0).toFixed(decimal).split('.');
|
|
62
65
|
const fullAmount = `${integerAmount}.${decimalAmount}`;
|
|
@@ -66,8 +69,11 @@ export function formatAmount(amount, decimal = 2) {
|
|
|
66
69
|
fullAmount,
|
|
67
70
|
};
|
|
68
71
|
}
|
|
72
|
+
// Use toFixed(limit) to limit to 2 decimal places
|
|
69
73
|
const fixedNumber = num.toFixed(decimal);
|
|
74
|
+
// Split integer and decimal parts
|
|
70
75
|
const [integerPart, decimalPart] = fixedNumber.split('.');
|
|
76
|
+
// Add commas to the integer part
|
|
71
77
|
const formattedInteger = parseInt(integerPart).toLocaleString();
|
|
72
78
|
return {
|
|
73
79
|
integerAmount: formattedInteger,
|
package/build/utils/date.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ export declare function getGreetingMessageId(userTimeHours: number): string;
|
|
|
2
2
|
export declare function getDatePickerFormat(date: Date | [Date, Date], locale: string): string;
|
|
3
3
|
export declare const getUTCOffset: (offsetStr?: string | number) => number;
|
|
4
4
|
export declare const formatUTCOffset: (offset?: number) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Get the default date range for the calendar
|
|
7
|
+
* @param startDay - Number of days to subtract from today, default value is 6 days to get the date range of the last 7 days including today
|
|
8
|
+
* @returns - Array of two dates [startDate, endDate]
|
|
9
|
+
*/
|
|
5
10
|
export declare const getDefaultDateRange: (startDay?: number) => [Date, Date];
|
|
6
11
|
export declare const getUTCTimestamp: (date: Date | string | number) => number;
|
|
7
12
|
export declare const getTimestampByTimezone: (date: Date | string | number, selectedTimezone?: string) => number;
|
package/build/utils/date.js
CHANGED
|
@@ -34,6 +34,7 @@ export function getDatePickerFormat(date, locale) {
|
|
|
34
34
|
month: locale === 'hijri' ? 'short' : 'short',
|
|
35
35
|
day: 'numeric',
|
|
36
36
|
});
|
|
37
|
+
// @ts-expect-error formatRange is not defined in the type
|
|
37
38
|
return formatter.formatRange(startDate, endDate).replace('AH', '').trim().replace('–', ' – ');
|
|
38
39
|
}
|
|
39
40
|
const formatter = new Intl.DateTimeFormat(calendarMode, {
|
|
@@ -58,25 +59,41 @@ export const formatUTCOffset = (offset = 0) => {
|
|
|
58
59
|
const paddedOffset = Math.abs(offset).toString().padStart(2, '0');
|
|
59
60
|
return `UTC${sign}${paddedOffset}:00`;
|
|
60
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Get the default date range for the calendar
|
|
64
|
+
* @param startDay - Number of days to subtract from today, default value is 6 days to get the date range of the last 7 days including today
|
|
65
|
+
* @returns - Array of two dates [startDate, endDate]
|
|
66
|
+
*/
|
|
61
67
|
export const getDefaultDateRange = (startDay = 6) => {
|
|
62
68
|
const monthDaysMinus = dayjs().subtract(startDay, 'day').hour(0).minute(0).second(0).toDate();
|
|
63
69
|
const today = dayjs(new Date()).hour(23).minute(59).second(59).toDate();
|
|
64
70
|
return [monthDaysMinus, today];
|
|
65
71
|
};
|
|
66
72
|
export const getUTCTimestamp = (date) => {
|
|
73
|
+
// Create a Date object with the local date string
|
|
67
74
|
const localDate = new Date(date);
|
|
75
|
+
// Get the local timezone offset in minutes
|
|
68
76
|
const localTimezoneOffset = localDate.getTimezoneOffset();
|
|
69
|
-
|
|
77
|
+
// Calculate the UTC timestamp by subtracting the local timezone offset
|
|
78
|
+
const utcTimestamp = localDate.getTime() - localTimezoneOffset * 60000; // Convert minutes to milliseconds
|
|
79
|
+
// Create a new Date object with the UTC timestamp
|
|
70
80
|
const utcDate = new Date(utcTimestamp);
|
|
81
|
+
// Convert the UTC date to a string
|
|
71
82
|
const utcDateString = utcDate.toISOString();
|
|
72
83
|
return dayjs(utcDateString).valueOf();
|
|
73
84
|
};
|
|
85
|
+
/*
|
|
86
|
+
* Convert local date to the selected timezone
|
|
87
|
+
* @param date - Date object, date string or timestamp
|
|
88
|
+
* @param selectedTimezone - Timezone string
|
|
89
|
+
* @returns - Milliseconds
|
|
90
|
+
*/
|
|
74
91
|
export const getTimestampByTimezone = (date, selectedTimezone = TIMEZONES.KW) => {
|
|
75
92
|
const localDate = new Date(date);
|
|
76
93
|
const localTimezoneOffset = localDate.getTimezoneOffset();
|
|
77
|
-
const selectedTimezoneOffset = getUTCOffset(selectedTimezone) * 60;
|
|
94
|
+
const selectedTimezoneOffset = getUTCOffset(selectedTimezone) * 60; // Convert hours to minutes
|
|
78
95
|
const timezoneDiff = selectedTimezoneOffset - localTimezoneOffset;
|
|
79
|
-
const timezoneTimestamp = localDate.getTime() + timezoneDiff * 60000;
|
|
96
|
+
const timezoneTimestamp = localDate.getTime() + timezoneDiff * 60000; // Convert minutes to milliseconds
|
|
80
97
|
const timezoneDate = new Date(timezoneTimestamp);
|
|
81
98
|
const timezoneDateString = timezoneDate.toISOString();
|
|
82
99
|
return dayjs(timezoneDateString).valueOf();
|
|
@@ -86,12 +103,23 @@ export const convertCalendarDateToUTC = (date, hoursOffset = 0) => {
|
|
|
86
103
|
const adjustedDate = utcDate.subtract(hoursOffset, 'hour');
|
|
87
104
|
return adjustedDate.valueOf();
|
|
88
105
|
};
|
|
106
|
+
/*
|
|
107
|
+
* Convert UTC date to local date
|
|
108
|
+
* @param date - Date object, date string or timestamp
|
|
109
|
+
* @returns - Date object
|
|
110
|
+
*/
|
|
89
111
|
export const convertUTCtoLocalDate = (date) => {
|
|
90
112
|
const localDate = new Date(date);
|
|
91
113
|
const localTimezoneOffset = localDate.getTimezoneOffset();
|
|
92
114
|
const localTimestamp = localDate.getTime() + localTimezoneOffset * 60000;
|
|
93
115
|
return new Date(localTimestamp);
|
|
94
116
|
};
|
|
117
|
+
/*
|
|
118
|
+
* Convert Local date to the selected timezone
|
|
119
|
+
* @param date - Date object, date string or timestamp
|
|
120
|
+
* @param selectedTimezone - Timezone string
|
|
121
|
+
* @returns - Date object
|
|
122
|
+
*/
|
|
95
123
|
export const changeDateTimezone = (date, { currentTimezone, targetTimezone }) => {
|
|
96
124
|
if (!date) {
|
|
97
125
|
return '';
|
package/build/utils/encrypt.js
CHANGED
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
function encryptWithPublicKey(publicKeyPem, text) {
|
|
11
11
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
// Convert PEM to CryptoKey
|
|
12
13
|
function importPublicKey(pem) {
|
|
13
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
15
|
const pemHeader = '-----BEGIN PUBLIC KEY-----';
|
|
@@ -18,7 +19,7 @@ function encryptWithPublicKey(publicKeyPem, text) {
|
|
|
18
19
|
const binaryDer = Uint8Array.from(binaryDerString, (c) => c.charCodeAt(0));
|
|
19
20
|
return yield window.crypto.subtle.importKey('spki', binaryDer.buffer, {
|
|
20
21
|
name: 'RSA-OAEP',
|
|
21
|
-
hash: 'SHA-1',
|
|
22
|
+
hash: 'SHA-1', // <-- Important: match Java's default OAEP hash
|
|
22
23
|
}, true, ['encrypt']);
|
|
23
24
|
});
|
|
24
25
|
}
|
|
@@ -27,6 +28,7 @@ function encryptWithPublicKey(publicKeyPem, text) {
|
|
|
27
28
|
const encryptedBuffer = yield window.crypto.subtle.encrypt({
|
|
28
29
|
name: 'RSA-OAEP',
|
|
29
30
|
}, key, encoder.encode(text));
|
|
31
|
+
// Convert to Base64 for safe transport
|
|
30
32
|
const bytes = new Uint8Array(encryptedBuffer);
|
|
31
33
|
let binary = '';
|
|
32
34
|
for (let i = 0; i < bytes.byteLength; i++) {
|
package/build/utils/error.js
CHANGED
|
@@ -4,10 +4,12 @@ export const isNetworkError = (error) => {
|
|
|
4
4
|
export const hasError = (error) => {
|
|
5
5
|
return Boolean(error);
|
|
6
6
|
};
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
8
|
export const isTimeoutError = (error) => {
|
|
8
9
|
var _a, _b;
|
|
9
10
|
return (_b = ((error === null || error === void 0 ? void 0 : error.code) === 'ECONNABORTED' || ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('timeout')))) !== null && _b !== void 0 ? _b : false;
|
|
10
11
|
};
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
13
|
export const isNotFoundError = (error) => {
|
|
12
14
|
var _a, _b, _c, _d, _e, _f;
|
|
13
15
|
if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 404)
|
package/build/utils/freshdesk.js
CHANGED
|
@@ -17,6 +17,7 @@ const prepareFreshDeskData = ({ individualDetails, activeSegment, language, }) =
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
export const setFreshDeskProperties = ({ individualDetails, activeSegment, language, }) => {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
21
|
const fcWidgetObj = window.fcWidget;
|
|
21
22
|
if (!fcWidgetObj) {
|
|
22
23
|
return;
|
|
@@ -46,6 +47,7 @@ export const setFreshDeskProperties = ({ individualDetails, activeSegment, langu
|
|
|
46
47
|
});
|
|
47
48
|
};
|
|
48
49
|
export const openFreshDeskChat = () => {
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
51
|
const fcWidgetObj = window.fcWidget;
|
|
50
52
|
if (!fcWidgetObj) {
|
|
51
53
|
return;
|
package/build/utils/geography.js
CHANGED
|
@@ -23,6 +23,7 @@ export function removeSecretKey() {
|
|
|
23
23
|
export function removeConnectMetaData() {
|
|
24
24
|
localStorage.removeItem(CONNECT_META_DATA);
|
|
25
25
|
}
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
27
|
export function setNavigationData(data) {
|
|
27
28
|
localStorage.setItem(NAVIGATION_DATA, JSON.stringify(data));
|
|
28
29
|
}
|
|
@@ -39,6 +40,7 @@ export function getNavigationData() {
|
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
42
|
});
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
42
44
|
}
|
|
43
45
|
catch (error) {
|
|
44
46
|
return null;
|
|
@@ -59,15 +61,18 @@ export const removeLoggedInUserJwtToken = () => {
|
|
|
59
61
|
export const removeLoggedInUserData = () => {
|
|
60
62
|
localStorage.removeItem(USER_DATA_KEY);
|
|
61
63
|
};
|
|
64
|
+
// eslint-disable-next-line
|
|
62
65
|
export const setLoggedInUserData = (data) => {
|
|
63
66
|
localStorage.setItem(USER_DATA_KEY, JSON.stringify(data));
|
|
64
67
|
};
|
|
68
|
+
// eslint-disable-next-line
|
|
65
69
|
export const getLoggedInUserData = () => {
|
|
66
70
|
const data = localStorage.getItem(USER_DATA_KEY);
|
|
67
71
|
if (!data)
|
|
68
72
|
return null;
|
|
69
73
|
try {
|
|
70
74
|
return JSON.parse(data);
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
76
|
}
|
|
72
77
|
catch (error) {
|
|
73
78
|
return null;
|
|
@@ -128,6 +133,7 @@ export const getCalenderTimezone = () => {
|
|
|
128
133
|
if (!data)
|
|
129
134
|
return null;
|
|
130
135
|
return JSON.parse(data);
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
131
137
|
}
|
|
132
138
|
catch (error) {
|
|
133
139
|
return null;
|
|
@@ -139,6 +145,7 @@ export const getCalenderTimezoneHistory = () => {
|
|
|
139
145
|
if (!data)
|
|
140
146
|
return null;
|
|
141
147
|
return JSON.parse(data);
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
142
149
|
}
|
|
143
150
|
catch (error) {
|
|
144
151
|
return null;
|
package/build/utils/merchant.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export const getMerchantIds = (activeSegment) => {
|
|
2
2
|
var _a;
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
4
|
return (_a = activeSegment === null || activeSegment === void 0 ? void 0 : activeSegment.countries) === null || _a === void 0 ? void 0 : _a.reduce((acc, country) => {
|
|
4
5
|
const { entities } = country;
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
7
|
const ids = entities.reduce((entitiesAcc, entity) => {
|
|
6
8
|
const { merchants } = entity;
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
10
|
const entitiesAccIds = (merchants || []).map((merchant) => merchant.legacy_id);
|
|
8
11
|
return [...entitiesAcc, ...entitiesAccIds];
|
|
9
12
|
}, []);
|
package/build/utils/number.js
CHANGED
package/build/utils/segment.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getDefaultEntityCountry } from './entity';
|
|
2
2
|
export const getSegmentData = (segments, activeSegmentId, activeSegments) => {
|
|
3
3
|
var _a, _b, _c;
|
|
4
|
+
// debugger
|
|
4
5
|
const newSegment = (_a = segments.find((segment) => segment.id === activeSegmentId)) !== null && _a !== void 0 ? _a : {};
|
|
5
6
|
const activeSegment = (_b = activeSegments.find((segment) => segment.id === activeSegmentId)) !== null && _b !== void 0 ? _b : {};
|
|
6
7
|
const defaultCountry = activeSegment.countries.length === 1
|
package/build/utils/string.d.ts
CHANGED
|
@@ -7,4 +7,11 @@ export declare const copyText: (text: string) => void;
|
|
|
7
7
|
export declare const capitalizeFirstLetter: (text: string) => string;
|
|
8
8
|
export declare const percentageToNumber: (percentageStr: string) => number;
|
|
9
9
|
export declare const maskValue: (value: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Transforms a string by replacing a separator with a replacement character and applying proper case formatting
|
|
12
|
+
* @param text - The string to transform
|
|
13
|
+
* @param separator - The separator to replace (defaults to underscore)
|
|
14
|
+
* @param replacement - The replacement character (defaults to space)
|
|
15
|
+
* @returns The transformed string with proper case formatting
|
|
16
|
+
*/
|
|
10
17
|
export declare const transformStringToProperCase: (text: string, separator?: string | RegExp, replacement?: string) => string;
|
package/build/utils/string.js
CHANGED
|
@@ -34,6 +34,7 @@ export const copyText = (text) => {
|
|
|
34
34
|
else {
|
|
35
35
|
const textArea = document.createElement('textarea');
|
|
36
36
|
textArea.value = text;
|
|
37
|
+
// Avoid scrolling to bottom
|
|
37
38
|
textArea.style.top = '0';
|
|
38
39
|
textArea.style.left = '0';
|
|
39
40
|
textArea.style.position = 'fixed';
|
|
@@ -53,7 +54,16 @@ export const percentageToNumber = (percentageStr) => {
|
|
|
53
54
|
return parseFloat(number) || 0;
|
|
54
55
|
};
|
|
55
56
|
export const maskValue = (value) => `••• ${value.slice(-4)}`;
|
|
57
|
+
/**
|
|
58
|
+
* Transforms a string by replacing a separator with a replacement character and applying proper case formatting
|
|
59
|
+
* @param text - The string to transform
|
|
60
|
+
* @param separator - The separator to replace (defaults to underscore)
|
|
61
|
+
* @param replacement - The replacement character (defaults to space)
|
|
62
|
+
* @returns The transformed string with proper case formatting
|
|
63
|
+
*/
|
|
56
64
|
export const transformStringToProperCase = (text, separator = /_/g, replacement = ' ') => {
|
|
65
|
+
// Replace separator with replacement character
|
|
57
66
|
const updatedText = text.replace(separator, replacement);
|
|
67
|
+
// Apply proper case formatting
|
|
58
68
|
return startCase(updatedText);
|
|
59
69
|
};
|
package/build/utils/style.d.ts
CHANGED
|
@@ -5,13 +5,24 @@ export declare const SELECTION_COLORS: {
|
|
|
5
5
|
readonly transparent: "transparent";
|
|
6
6
|
};
|
|
7
7
|
interface GetSelectionStylesParams {
|
|
8
|
+
/** Whether the current cell/row is selected */
|
|
8
9
|
isSelected: boolean;
|
|
10
|
+
/** Whether this is a single cell selection */
|
|
9
11
|
isCellSelected: boolean;
|
|
12
|
+
/** Whether this is part of a column selection */
|
|
10
13
|
isColumnSelected: boolean;
|
|
14
|
+
/** Whether this is part of a row selection */
|
|
11
15
|
isRowSelected?: boolean;
|
|
16
|
+
/** Whether this is the last row in the selection */
|
|
12
17
|
isLastRow: boolean;
|
|
13
18
|
}
|
|
14
19
|
type SelectionStyles = Record<string, string | Record<string, string>>;
|
|
20
|
+
/**
|
|
21
|
+
* Generates CSS styles for table cell selection states
|
|
22
|
+
*
|
|
23
|
+
* @param params - Selection state parameters
|
|
24
|
+
* @returns CSS-in-JS style object for the selected cell/column
|
|
25
|
+
*/
|
|
15
26
|
export declare const getSelectionStyles: ({ isSelected, isCellSelected, isColumnSelected, isRowSelected, isLastRow, }: GetSelectionStylesParams) => SelectionStyles;
|
|
16
27
|
interface GetRowSelectionBorderStylesParams {
|
|
17
28
|
effectiveFirst: boolean;
|
package/build/utils/style.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Selection style constants
|
|
1
2
|
export const SELECTION_COLORS = {
|
|
2
3
|
primary: '#1F88D0',
|
|
3
4
|
background: 'white',
|
|
@@ -13,31 +14,52 @@ const CELL_DIMENSIONS = {
|
|
|
13
14
|
minHeight: '28px',
|
|
14
15
|
fullHeight: '100%',
|
|
15
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Generates CSS styles for table cell selection states
|
|
19
|
+
*
|
|
20
|
+
* @param params - Selection state parameters
|
|
21
|
+
* @returns CSS-in-JS style object for the selected cell/column
|
|
22
|
+
*/
|
|
16
23
|
export const getSelectionStyles = ({ isSelected, isCellSelected, isColumnSelected, isRowSelected, isLastRow, }) => {
|
|
24
|
+
// Early return for non-selected cells
|
|
17
25
|
if (!isSelected) {
|
|
18
26
|
return {};
|
|
19
27
|
}
|
|
28
|
+
// Row selection styles
|
|
20
29
|
if (isRowSelected) {
|
|
21
30
|
return getRowSelectionStyles();
|
|
22
31
|
}
|
|
32
|
+
// Single cell selection styles
|
|
23
33
|
if (isCellSelected && !isColumnSelected) {
|
|
24
34
|
return getSingleCellSelectionStyles();
|
|
25
35
|
}
|
|
36
|
+
// Column selection styles
|
|
26
37
|
if (isColumnSelected) {
|
|
27
38
|
return getColumnSelectionStyles(isLastRow);
|
|
28
39
|
}
|
|
29
40
|
return {};
|
|
30
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Returns styles for row selection
|
|
44
|
+
*/
|
|
31
45
|
const getRowSelectionStyles = () => ({
|
|
32
46
|
backgroundColor: SELECTION_COLORS.background,
|
|
33
47
|
color: SELECTION_COLORS.primary,
|
|
34
48
|
});
|
|
49
|
+
/**
|
|
50
|
+
* Returns styles for a single selected cell
|
|
51
|
+
*/
|
|
35
52
|
const getSingleCellSelectionStyles = () => ({
|
|
36
53
|
border: `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.primary}`,
|
|
37
54
|
backgroundColor: SELECTION_COLORS.background,
|
|
38
55
|
color: SELECTION_COLORS.primary,
|
|
39
56
|
borderRadius: '2px',
|
|
40
57
|
});
|
|
58
|
+
/**
|
|
59
|
+
* Returns styles for column selection
|
|
60
|
+
*
|
|
61
|
+
* @param isLastRow - Whether this is the last row in the selection
|
|
62
|
+
*/
|
|
41
63
|
const getColumnSelectionStyles = (isLastRow) => {
|
|
42
64
|
const borderWidth = getBorderWidthForColumn();
|
|
43
65
|
const borderBottom = getBorderBottomForColumn(isLastRow);
|
|
@@ -52,10 +74,16 @@ const getColumnSelectionStyles = (isLastRow) => {
|
|
|
52
74
|
alignItems: 'center',
|
|
53
75
|
};
|
|
54
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Calculates border width for column selection
|
|
79
|
+
*/
|
|
55
80
|
const getBorderWidthForColumn = () => {
|
|
56
81
|
const { none, thin } = BORDER_STYLES;
|
|
57
82
|
return `${none} ${thin} ${thin} ${thin}`;
|
|
58
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* Calculates border bottom for column selection
|
|
86
|
+
*/
|
|
59
87
|
const getBorderBottomForColumn = (isLastRow) => {
|
|
60
88
|
return isLastRow ? `${BORDER_STYLES.thick} solid ${SELECTION_COLORS.primary}` : `${BORDER_STYLES.thin} solid ${SELECTION_COLORS.border}`;
|
|
61
89
|
};
|
package/build/utils/table.js
CHANGED
|
@@ -2,7 +2,7 @@ import { walletDetailsTableCellWidth, authenticationsTableCellWidth, authorizati
|
|
|
2
2
|
export const getColumnWidthPercentage = (widthInPx, options) => {
|
|
3
3
|
const { isFirst, isLast } = options || {};
|
|
4
4
|
const paddingInPx = isFirst || isLast ? 0 : 0;
|
|
5
|
-
const widthInPercentage = ((widthInPx + paddingInPx) / 898) * 100;
|
|
5
|
+
const widthInPercentage = ((widthInPx + paddingInPx) / 898) * 100; // 1128 is the total width of the table
|
|
6
6
|
return `${widthInPercentage}%`;
|
|
7
7
|
};
|
|
8
8
|
export const getCellWidth = ({ table, cellID, tableMode }) => {
|
package/build/utils/url.js
CHANGED
|
@@ -9,9 +9,11 @@ export const openNewTab = (url, target = '_blank') => {
|
|
|
9
9
|
export const openUrl = (url) => {
|
|
10
10
|
const isUrl = /^https?:\/\//i.test(url);
|
|
11
11
|
if (isUrl) {
|
|
12
|
+
// Open normal URLs directly
|
|
12
13
|
window.open(url, '_blank', 'noopener,noreferrer');
|
|
13
14
|
}
|
|
14
15
|
else {
|
|
16
|
+
// Show the string in the url bar as a query param
|
|
15
17
|
const newUrl = 'about:blank?' + encodeURIComponent(url);
|
|
16
18
|
window.open(newUrl, '_blank', 'noopener,noreferrer');
|
|
17
19
|
}
|
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.
|
|
5
|
-
"testVersion":
|
|
4
|
+
"version": "0.1.136",
|
|
5
|
+
"testVersion": 0,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"module": "build/index.js",
|