@eztrak/shared 0.17.0 → 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.
@@ -28,8 +28,8 @@ import {
28
28
  TooltipText,
29
29
  dropdownStyles,
30
30
  resolveActions
31
- } from "../chunk-KJWCRX6F.mjs";
32
- import "../chunk-A5BBQ7X5.mjs";
31
+ } from "../chunk-2KXV5C3X.mjs";
32
+ import "../chunk-A5Y5QGVL.mjs";
33
33
  export {
34
34
  ActionMenuItem,
35
35
  Breadcrumbs,
@@ -34,6 +34,8 @@ interface ConfirmationAlertOptions {
34
34
  title?: string;
35
35
  text?: string;
36
36
  html?: string;
37
+ /** Body HTML when `html` is not set. String only (not React nodes). */
38
+ children?: string;
37
39
  icon?: "warning" | "info" | "question" | "error" | "success";
38
40
  /** Custom icon markup. When set, replaces SweetAlert's default icon content. */
39
41
  iconHtml?: string;
@@ -59,6 +61,11 @@ interface ConfirmationAlertOptions {
59
61
  borderRadius?: string | number;
60
62
  /** Confirm/cancel button corner radius. Default `0.5rem`. Number = px. */
61
63
  buttonBorderRadius?: string | number;
64
+ /** Typed-input margin. Number = px. Bottom default `1.25rem`; other sides default `0`. */
65
+ inputMarginTop?: string | number;
66
+ inputMarginRight?: string | number;
67
+ inputMarginBottom?: string | number;
68
+ inputMarginLeft?: string | number;
62
69
  /** `danger` = delete look; `brand` = orange confirm. Explicit options win. */
63
70
  variant?: ConfirmationAlertVariant;
64
71
  customClass?: SweetAlertOptions["customClass"];
@@ -34,6 +34,8 @@ interface ConfirmationAlertOptions {
34
34
  title?: string;
35
35
  text?: string;
36
36
  html?: string;
37
+ /** Body HTML when `html` is not set. String only (not React nodes). */
38
+ children?: string;
37
39
  icon?: "warning" | "info" | "question" | "error" | "success";
38
40
  /** Custom icon markup. When set, replaces SweetAlert's default icon content. */
39
41
  iconHtml?: string;
@@ -59,6 +61,11 @@ interface ConfirmationAlertOptions {
59
61
  borderRadius?: string | number;
60
62
  /** Confirm/cancel button corner radius. Default `0.5rem`. Number = px. */
61
63
  buttonBorderRadius?: string | number;
64
+ /** Typed-input margin. Number = px. Bottom default `1.25rem`; other sides default `0`. */
65
+ inputMarginTop?: string | number;
66
+ inputMarginRight?: string | number;
67
+ inputMarginBottom?: string | number;
68
+ inputMarginLeft?: string | number;
62
69
  /** `danger` = delete look; `brand` = orange confirm. Explicit options win. */
63
70
  variant?: ConfirmationAlertVariant;
64
71
  customClass?: SweetAlertOptions["customClass"];
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
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';
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-SHMjCJHj.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
+ 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';
5
5
  import 'clsx';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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';
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-SHMjCJHj.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
+ 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';
5
5
  import 'clsx';
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 value?.toLocaleString("en-US", {
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: "USD"
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;
@@ -587,6 +693,12 @@ function ensureConfirmAlertStyles() {
587
693
  .ez-confirm-cancel:hover {
588
694
  background: #f9fafb !important;
589
695
  }
696
+ .ez-confirm-popup .swal2-input {
697
+ margin-top: var(--ez-confirm-input-mt, 0) !important;
698
+ margin-right: var(--ez-confirm-input-mr, 0) !important;
699
+ margin-bottom: var(--ez-confirm-input-mb, 1.25rem) !important;
700
+ margin-left: var(--ez-confirm-input-ml, 0) !important;
701
+ }
590
702
  `;
591
703
  document.head.appendChild(style);
592
704
  }
@@ -624,7 +736,7 @@ function confirmationAlert(onConfirm, options = {}) {
624
736
  hasInput ? "Confirmation Required" : "Delete this item"
625
737
  );
626
738
  const text = options.text;
627
- const html = options.html;
739
+ const html = options.html ?? options.children;
628
740
  const icon = pick(options.icon, vd.icon, "warning");
629
741
  const iconHtml = pick(options.iconHtml, vd.iconHtml, void 0);
630
742
  const iconColor = pick(options.iconColor, vd.iconColor, BRAND_ORANGE);
@@ -665,6 +777,10 @@ function confirmationAlert(onConfirm, options = {}) {
665
777
  const width = options.width;
666
778
  const borderRadius = cssSize(options.borderRadius, "1rem");
667
779
  const buttonBorderRadius = cssSize(options.buttonBorderRadius, "0.5rem");
780
+ const inputMarginTop = cssSize(options.inputMarginTop, "0");
781
+ const inputMarginRight = cssSize(options.inputMarginRight, "0");
782
+ const inputMarginBottom = cssSize(options.inputMarginBottom, "1.25rem");
783
+ const inputMarginLeft = cssSize(options.inputMarginLeft, "0");
668
784
  const onCancel = options.onCancel;
669
785
  const useLoader = showLoaderOnConfirm || hasInput;
670
786
  const inputHtml = html ?? (hasInput ? `
@@ -705,6 +821,10 @@ function confirmationAlert(onConfirm, options = {}) {
705
821
  popup.style.setProperty("--ez-confirm-icon-bg", iconBgColor);
706
822
  popup.style.setProperty("--ez-confirm-radius", borderRadius);
707
823
  popup.style.setProperty("--ez-confirm-btn-radius", buttonBorderRadius);
824
+ popup.style.setProperty("--ez-confirm-input-mt", inputMarginTop);
825
+ popup.style.setProperty("--ez-confirm-input-mr", inputMarginRight);
826
+ popup.style.setProperty("--ez-confirm-input-mb", inputMarginBottom);
827
+ popup.style.setProperty("--ez-confirm-input-ml", inputMarginLeft);
708
828
  if (width != null) {
709
829
  popup.style.setProperty(
710
830
  "--ez-confirm-width",
@@ -2458,10 +2578,7 @@ function Sidebar({
2458
2578
  "div",
2459
2579
  {
2460
2580
  "data-sidebar-item": item.name,
2461
- className: cn(
2462
- "has-sub-items max-w-full min-w-0 flex flex-col",
2463
- collapsed ? "my-1" : "my-2"
2464
- ),
2581
+ className: "has-sub-items max-w-full min-w-0 flex flex-col",
2465
2582
  children: [
2466
2583
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2467
2584
  ToolTip,