@eztrak/shared 0.17.1 → 0.18.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.
- package/README.md +48 -0
- package/dist/{chunk-4ASJWHN3.mjs → chunk-2KXV5C3X.mjs} +2 -2
- package/dist/{chunk-QOYMQFOB.mjs → chunk-A5Y5QGVL.mjs} +138 -32
- package/dist/chunk-A5Y5QGVL.mjs.map +1 -0
- package/dist/{chunk-LS7AI4ER.mjs → chunk-IQGTSEHC.mjs} +2 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +135 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/utils/index.d.mts +20 -4
- package/dist/utils/index.d.ts +20 -4
- package/dist/utils/index.js +135 -29
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +2 -2
- package/package.json +2 -1
- package/dist/chunk-QOYMQFOB.mjs.map +0 -1
- /package/dist/{chunk-4ASJWHN3.mjs.map → chunk-2KXV5C3X.mjs.map} +0 -0
- /package/dist/{chunk-LS7AI4ER.mjs.map → chunk-IQGTSEHC.mjs.map} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CreateBaseQueryWithRetryOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, resetPageParam, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.mjs';
|
|
1
|
+
export { CreateBaseQueryWithRetryOptions, CurrencyFormatterOptions, DateUtcMode, FormatDateOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, resetPageParam, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.mjs';
|
|
2
2
|
export { C as ConfirmationAlertOptions, a as ConfirmationAlertVariant, D as DEFAULT_CONFIRM_ICONS, E as ErrorClassification, b as ErrorSuggestedAction, H as HandleApiErrorOptions, R as RtkQueryError, c as classifyError, d as confirmationAlert, f as formatValidationErrorsHtml, h as handleApiError, i as isRetryableError } from './handleApiError-BIAaN76q.mjs';
|
|
3
3
|
export { UseGridHeightOptions, useGridHeight, usePaginationUrlSync } from './hooks/index.mjs';
|
|
4
4
|
export { ActionMenuItem, ActionMenuItemProps, BreadcrumbRoute, Breadcrumbs, BreadcrumbsProps, Button, ButtonProps, Card, CardProps, CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, Header, HeaderProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ROW_ACTION_DEFAULT_ICON_SIZE, ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE, ROW_ACTION_ITEM_HOVER_CLASS, ROW_ACTION_ITEM_TEXT_CLASS, ROW_ACTION_PRESETS, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, ResolvedRowAction, RowAction, RowActionConfirmFn, RowActionFlag, RowActionItemRenderContext, RowActionItemType, RowActionPreset, RowActionPresetName, RowActions, RowActionsList, RowActionsMode, RowActionsProps, RowActionsRenderContext, SearchInput, SearchInputProps, Sidebar, SidebarItem, SidebarProps, TableErrorBoundary, TableErrorBoundaryProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles, resolveActions } from './components/index.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CreateBaseQueryWithRetryOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, resetPageParam, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.js';
|
|
1
|
+
export { CreateBaseQueryWithRetryOptions, CurrencyFormatterOptions, DateUtcMode, FormatDateOptions, PermissionRecord, TransformedPermissions, USER_STATE_STORAGE_KEY, capitalizeText, checkIfExistsInArray, cn, convertCommaDataToArray, createBaseQueryWithRetry, currencyFormatter, deserializeJson, flattenTableData, formatDate, formatDateTime, formatNumber, get, getApiError, getErrorMessages, getFieldsByCategory, getFieldsByInputType, getFieldsByName, getItem, getItemFromLocalStorage, isEmpty, loadUserState, normalizeApiListItems, parseCurrencyValueToNumber, removeByPropertyValues, removeItem, resetPageParam, saveItemLocalStorage, saveUserState, set, setItem, storeItemInLocalStorage, toDateInputValue, toLowerCaseText, transformPermissions, truncateFileName, truncateText } from './utils/index.js';
|
|
2
2
|
export { C as ConfirmationAlertOptions, a as ConfirmationAlertVariant, D as DEFAULT_CONFIRM_ICONS, E as ErrorClassification, b as ErrorSuggestedAction, H as HandleApiErrorOptions, R as RtkQueryError, c as classifyError, d as confirmationAlert, f as formatValidationErrorsHtml, h as handleApiError, i as isRetryableError } from './handleApiError-BIAaN76q.js';
|
|
3
3
|
export { UseGridHeightOptions, useGridHeight, usePaginationUrlSync } from './hooks/index.js';
|
|
4
4
|
export { ActionMenuItem, ActionMenuItemProps, BreadcrumbRoute, Breadcrumbs, BreadcrumbsProps, Button, ButtonProps, Card, CardProps, CardSkeleton, CardSkeletonProps, CardSkeletonVariant, CellEditPayload, CellEditorInputType, CustomCellEditor, CustomCellEditorProps, CustomCellEditorRef, CustomPagination, CustomPaginationClassNames, CustomPaginationProps, DropdownFilter, DropdownFilterProps, DropdownOption, EztrakTab, EztrakTabs, EztrakTabsClassNames, EztrakTabsProps, Header, HeaderProps, LayoutStatus, Loader, LoaderProps, Modal, ModalProps, PaginationData, PopupActionHandler, PopupCellRenderer, PopupCellRendererParams, PopupCellRendererProps, PopupDropDownContent, ROW_ACTION_DEFAULT_ICON_SIZE, ROW_ACTION_DEFAULT_MENU_TOOLTIP_STYLE, ROW_ACTION_ITEM_HOVER_CLASS, ROW_ACTION_ITEM_TEXT_CLASS, ROW_ACTION_PRESETS, ResetColumnsButton, ResetColumnsButtonProps, ResetFiltersButton, ResetFiltersButtonProps, ResetFiltersButtonVariant, ResolvedRowAction, RowAction, RowActionConfirmFn, RowActionFlag, RowActionItemRenderContext, RowActionItemType, RowActionPreset, RowActionPresetName, RowActions, RowActionsList, RowActionsMode, RowActionsProps, RowActionsRenderContext, SearchInput, SearchInputProps, Sidebar, SidebarItem, SidebarProps, TableErrorBoundary, TableErrorBoundaryProps, TableLayoutToolbarControls, TableLayoutToolbarControlsProps, ToolTip, ToolTipProps, TooltipText, TooltipTextProps, dropdownStyles, resolveActions } from './components/index.js';
|
package/dist/index.js
CHANGED
|
@@ -122,6 +122,118 @@ function resetPageParam(params, pageKey = "page", defaultPage = "1") {
|
|
|
122
122
|
return params;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
// src/utils/format-date.ts
|
|
126
|
+
var DEFAULT_DATE_FALLBACK = "-";
|
|
127
|
+
var DEFAULT_DATETIME_FALLBACK = "Invalid Date";
|
|
128
|
+
var pad2 = (n) => n.toString().padStart(2, "0");
|
|
129
|
+
var getParts = (date, utc) => {
|
|
130
|
+
if (utc === "preserve") {
|
|
131
|
+
return {
|
|
132
|
+
year: date.getUTCFullYear(),
|
|
133
|
+
month: date.getUTCMonth() + 1,
|
|
134
|
+
day: date.getUTCDate(),
|
|
135
|
+
hours: date.getUTCHours(),
|
|
136
|
+
minutes: date.getUTCMinutes(),
|
|
137
|
+
seconds: date.getUTCSeconds()
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
year: date.getFullYear(),
|
|
142
|
+
month: date.getMonth() + 1,
|
|
143
|
+
day: date.getDate(),
|
|
144
|
+
hours: date.getHours(),
|
|
145
|
+
minutes: date.getMinutes(),
|
|
146
|
+
seconds: date.getSeconds()
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
var formatAmPmTime = (parts) => {
|
|
150
|
+
const hour12 = parts.hours % 12 || 12;
|
|
151
|
+
const ampm = parts.hours >= 12 ? "PM" : "AM";
|
|
152
|
+
return `${hour12}:${pad2(parts.minutes)} ${ampm}`;
|
|
153
|
+
};
|
|
154
|
+
var formatMmDdYy = (parts) => `${pad2(parts.month)}/${pad2(parts.day)}/${String(parts.year).slice(-2)}`;
|
|
155
|
+
var applyPattern = (pattern, parts) => {
|
|
156
|
+
const hour12 = parts.hours % 12 || 12;
|
|
157
|
+
const ampm = parts.hours >= 12 ? "PM" : "AM";
|
|
158
|
+
const replacements = [
|
|
159
|
+
["yyyy", String(parts.year)],
|
|
160
|
+
["yy", String(parts.year).slice(-2)],
|
|
161
|
+
["MM", pad2(parts.month)],
|
|
162
|
+
["dd", pad2(parts.day)],
|
|
163
|
+
["HH", pad2(parts.hours)],
|
|
164
|
+
["hh", pad2(hour12)],
|
|
165
|
+
["mm", pad2(parts.minutes)],
|
|
166
|
+
["ss", pad2(parts.seconds)],
|
|
167
|
+
["a", ampm]
|
|
168
|
+
];
|
|
169
|
+
let result = "";
|
|
170
|
+
let i = 0;
|
|
171
|
+
while (i < pattern.length) {
|
|
172
|
+
let matched = false;
|
|
173
|
+
for (const [token, value] of replacements) {
|
|
174
|
+
if (pattern.startsWith(token, i)) {
|
|
175
|
+
result += value;
|
|
176
|
+
i += token.length;
|
|
177
|
+
matched = true;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (!matched) {
|
|
182
|
+
result += pattern[i];
|
|
183
|
+
i += 1;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
};
|
|
188
|
+
var parseDate = (dateString) => {
|
|
189
|
+
if (dateString === null || dateString === void 0) return null;
|
|
190
|
+
const date = new Date(dateString);
|
|
191
|
+
if (isNaN(date.getTime())) return null;
|
|
192
|
+
return date;
|
|
193
|
+
};
|
|
194
|
+
var formatDate = (dateString, options = {}) => {
|
|
195
|
+
const {
|
|
196
|
+
pattern,
|
|
197
|
+
utc = "local",
|
|
198
|
+
includeTime = false,
|
|
199
|
+
fallback = DEFAULT_DATE_FALLBACK
|
|
200
|
+
} = options;
|
|
201
|
+
const date = parseDate(dateString);
|
|
202
|
+
if (!date) return fallback;
|
|
203
|
+
const parts = getParts(date, utc);
|
|
204
|
+
if (pattern) {
|
|
205
|
+
return applyPattern(pattern, parts);
|
|
206
|
+
}
|
|
207
|
+
const datePart = formatMmDdYy(parts);
|
|
208
|
+
if (!includeTime) return datePart;
|
|
209
|
+
return `${datePart}, ${formatAmPmTime(parts)}`;
|
|
210
|
+
};
|
|
211
|
+
var formatDateTime = (dateString, options = {}) => {
|
|
212
|
+
const {
|
|
213
|
+
pattern,
|
|
214
|
+
utc = "local",
|
|
215
|
+
includeTime = true,
|
|
216
|
+
fallback = DEFAULT_DATETIME_FALLBACK
|
|
217
|
+
} = options;
|
|
218
|
+
const date = parseDate(dateString);
|
|
219
|
+
if (!date) return fallback;
|
|
220
|
+
if (pattern) {
|
|
221
|
+
return applyPattern(pattern, getParts(date, utc));
|
|
222
|
+
}
|
|
223
|
+
const localeOptions = {
|
|
224
|
+
year: "numeric",
|
|
225
|
+
month: "numeric",
|
|
226
|
+
day: "numeric",
|
|
227
|
+
...includeTime ? {
|
|
228
|
+
hour: "numeric",
|
|
229
|
+
minute: "numeric",
|
|
230
|
+
hour12: true
|
|
231
|
+
} : {},
|
|
232
|
+
...utc === "preserve" ? { timeZone: "UTC" } : {}
|
|
233
|
+
};
|
|
234
|
+
return date.toLocaleString("en-US", localeOptions);
|
|
235
|
+
};
|
|
236
|
+
|
|
125
237
|
// src/utils/helpers.ts
|
|
126
238
|
var truncateText = (text, maxLength = 20) => {
|
|
127
239
|
if (text === null || text === void 0) return "";
|
|
@@ -196,17 +308,6 @@ function toLowerCaseText(text) {
|
|
|
196
308
|
if (!text) return "";
|
|
197
309
|
return text.toLowerCase();
|
|
198
310
|
}
|
|
199
|
-
var formatDate = (dateString) => {
|
|
200
|
-
if (dateString === null || dateString === void 0) return "-";
|
|
201
|
-
const date = new Date(dateString);
|
|
202
|
-
if (isNaN(date.getTime())) {
|
|
203
|
-
return dateString;
|
|
204
|
-
}
|
|
205
|
-
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
206
|
-
const day = date.getDate().toString().padStart(2, "0");
|
|
207
|
-
const year = date.getFullYear().toString().slice(-2);
|
|
208
|
-
return `${month}/${day}/${year}`;
|
|
209
|
-
};
|
|
210
311
|
var isEmpty = (obj) => {
|
|
211
312
|
return Object.keys(obj).length === 0;
|
|
212
313
|
};
|
|
@@ -237,11 +338,30 @@ function convertCommaDataToArray(data) {
|
|
|
237
338
|
function checkIfExistsInArray(array, searchValue) {
|
|
238
339
|
return array.includes(searchValue);
|
|
239
340
|
}
|
|
240
|
-
var currencyFormatter = (value) => {
|
|
241
|
-
return
|
|
341
|
+
var currencyFormatter = (value, options) => {
|
|
342
|
+
if (value == null) return "";
|
|
343
|
+
const {
|
|
344
|
+
currency = "USD",
|
|
345
|
+
locale = "en-US",
|
|
346
|
+
hideSymbol = false,
|
|
347
|
+
minimumFractionDigits,
|
|
348
|
+
maximumFractionDigits
|
|
349
|
+
} = options ?? {};
|
|
350
|
+
const fractionDigits = {
|
|
351
|
+
...minimumFractionDigits != null && { minimumFractionDigits },
|
|
352
|
+
...maximumFractionDigits != null && { maximumFractionDigits }
|
|
353
|
+
};
|
|
354
|
+
if (hideSymbol) {
|
|
355
|
+
return value.toLocaleString(locale, {
|
|
356
|
+
minimumFractionDigits: minimumFractionDigits ?? 2,
|
|
357
|
+
maximumFractionDigits: maximumFractionDigits ?? 2
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
return value.toLocaleString(locale, {
|
|
242
361
|
style: "currency",
|
|
243
|
-
currency
|
|
244
|
-
|
|
362
|
+
currency,
|
|
363
|
+
...fractionDigits
|
|
364
|
+
});
|
|
245
365
|
};
|
|
246
366
|
var formatNumber = (number) => {
|
|
247
367
|
if (isNaN(Number(number)) || number === null || number === void 0) {
|
|
@@ -295,20 +415,6 @@ var deserializeJson = (jsonString) => {
|
|
|
295
415
|
return null;
|
|
296
416
|
}
|
|
297
417
|
};
|
|
298
|
-
var formatDateTime = (dateString) => {
|
|
299
|
-
if (!dateString) return "Invalid Date";
|
|
300
|
-
const date = new Date(dateString);
|
|
301
|
-
if (isNaN(date.getTime())) return "Invalid Date";
|
|
302
|
-
const options = {
|
|
303
|
-
year: "numeric",
|
|
304
|
-
month: "numeric",
|
|
305
|
-
day: "numeric",
|
|
306
|
-
hour: "numeric",
|
|
307
|
-
minute: "numeric",
|
|
308
|
-
hour12: true
|
|
309
|
-
};
|
|
310
|
-
return date.toLocaleString("en-US", options);
|
|
311
|
-
};
|
|
312
418
|
var removeByPropertyValues = (items = [], property, values = [], { caseInsensitive = false } = {}) => {
|
|
313
419
|
if (!Array.isArray(items) || !property) return Array.isArray(items) ? items : [];
|
|
314
420
|
const normalize = (v) => caseInsensitive && typeof v === "string" ? v.toLowerCase() : v;
|