@eztrak/shared 0.16.5 → 0.17.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 +119 -3
- package/dist/{chunk-EIX5CUQF.mjs → chunk-A5BBQ7X5.mjs} +224 -20
- package/dist/chunk-A5BBQ7X5.mjs.map +1 -0
- package/dist/{chunk-WZVYTP6G.mjs → chunk-HAW3AKJP.mjs} +2 -2
- package/dist/{chunk-S7ZLXOPF.mjs → chunk-KJWCRX6F.mjs} +150 -51
- package/dist/chunk-KJWCRX6F.mjs.map +1 -0
- package/dist/components/index.d.mts +10 -2
- package/dist/components/index.d.ts +10 -2
- package/dist/components/index.js +357 -58
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/{handleApiError-CwVIJOqO.d.mts → handleApiError-SHMjCJHj.d.mts} +25 -1
- package/dist/{handleApiError-CwVIJOqO.d.ts → handleApiError-SHMjCJHj.d.ts} +25 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +359 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +224 -19
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +4 -2
- package/package.json +1 -1
- package/dist/chunk-EIX5CUQF.mjs.map +0 -1
- package/dist/chunk-S7ZLXOPF.mjs.map +0 -1
- /package/dist/{chunk-WZVYTP6G.mjs.map → chunk-HAW3AKJP.mjs.map} +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SweetAlertOptions } from 'sweetalert2';
|
|
2
|
+
|
|
1
3
|
type RtkQueryError = {
|
|
2
4
|
status?: number | string;
|
|
3
5
|
originalStatus?: number;
|
|
@@ -27,15 +29,24 @@ declare function classifyError(error: RtkQueryError | null | undefined): ErrorCl
|
|
|
27
29
|
declare function formatValidationErrorsHtml(errors: Record<string, string[]>): string;
|
|
28
30
|
/** Handles RTK Query errors with built-in toast.error or SweetAlert (when showAlert is true). */
|
|
29
31
|
declare function handleApiError(error: RtkQueryError | null | undefined, { showAlert, fallbackMessage }?: HandleApiErrorOptions): void;
|
|
32
|
+
type ConfirmationAlertVariant = "brand" | "danger";
|
|
30
33
|
interface ConfirmationAlertOptions {
|
|
31
34
|
title?: string;
|
|
32
35
|
text?: string;
|
|
33
36
|
html?: string;
|
|
34
37
|
icon?: "warning" | "info" | "question" | "error" | "success";
|
|
38
|
+
/** Custom icon markup. When set, replaces SweetAlert's default icon content. */
|
|
39
|
+
iconHtml?: string;
|
|
40
|
+
iconColor?: string;
|
|
41
|
+
iconBgColor?: string;
|
|
42
|
+
showIcon?: boolean;
|
|
35
43
|
confirmButtonText?: string;
|
|
36
44
|
cancelButtonText?: string;
|
|
37
45
|
confirmButtonColor?: string;
|
|
38
46
|
cancelButtonColor?: string;
|
|
47
|
+
confirmButtonTextColor?: string;
|
|
48
|
+
cancelButtonTextColor?: string;
|
|
49
|
+
showCancelButton?: boolean;
|
|
39
50
|
showLoaderOnConfirm?: boolean;
|
|
40
51
|
/** Type exactly — trimmed, case-sensitive. */
|
|
41
52
|
inputExpectedValue?: string;
|
|
@@ -43,7 +54,20 @@ interface ConfirmationAlertOptions {
|
|
|
43
54
|
reverseButtons?: boolean;
|
|
44
55
|
focusCancel?: boolean;
|
|
45
56
|
zIndex?: number;
|
|
57
|
+
width?: string | number;
|
|
58
|
+
/** Card corner radius. Default `1rem`. Number = px. */
|
|
59
|
+
borderRadius?: string | number;
|
|
60
|
+
/** Confirm/cancel button corner radius. Default `0.5rem`. Number = px. */
|
|
61
|
+
buttonBorderRadius?: string | number;
|
|
62
|
+
/** `danger` = delete look; `brand` = orange confirm. Explicit options win. */
|
|
63
|
+
variant?: ConfirmationAlertVariant;
|
|
64
|
+
customClass?: SweetAlertOptions["customClass"];
|
|
65
|
+
onCancel?: () => void;
|
|
46
66
|
}
|
|
67
|
+
/** Reusable icon markup — override via `iconHtml`. */
|
|
68
|
+
declare const DEFAULT_CONFIRM_ICONS: {
|
|
69
|
+
readonly warning: string;
|
|
70
|
+
};
|
|
47
71
|
declare function confirmationAlert(onConfirm: () => void | Promise<void>, options?: ConfirmationAlertOptions): void;
|
|
48
72
|
|
|
49
|
-
export { type ConfirmationAlertOptions as C, type ErrorClassification as E, type HandleApiErrorOptions as H, type RtkQueryError as R, type
|
|
73
|
+
export { type ConfirmationAlertOptions as C, DEFAULT_CONFIRM_ICONS as D, type ErrorClassification as E, type HandleApiErrorOptions as H, type RtkQueryError as R, type ConfirmationAlertVariant as a, type ErrorSuggestedAction as b, classifyError as c, confirmationAlert as d, formatValidationErrorsHtml as f, handleApiError as h, isRetryableError as i };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SweetAlertOptions } from 'sweetalert2';
|
|
2
|
+
|
|
1
3
|
type RtkQueryError = {
|
|
2
4
|
status?: number | string;
|
|
3
5
|
originalStatus?: number;
|
|
@@ -27,15 +29,24 @@ declare function classifyError(error: RtkQueryError | null | undefined): ErrorCl
|
|
|
27
29
|
declare function formatValidationErrorsHtml(errors: Record<string, string[]>): string;
|
|
28
30
|
/** Handles RTK Query errors with built-in toast.error or SweetAlert (when showAlert is true). */
|
|
29
31
|
declare function handleApiError(error: RtkQueryError | null | undefined, { showAlert, fallbackMessage }?: HandleApiErrorOptions): void;
|
|
32
|
+
type ConfirmationAlertVariant = "brand" | "danger";
|
|
30
33
|
interface ConfirmationAlertOptions {
|
|
31
34
|
title?: string;
|
|
32
35
|
text?: string;
|
|
33
36
|
html?: string;
|
|
34
37
|
icon?: "warning" | "info" | "question" | "error" | "success";
|
|
38
|
+
/** Custom icon markup. When set, replaces SweetAlert's default icon content. */
|
|
39
|
+
iconHtml?: string;
|
|
40
|
+
iconColor?: string;
|
|
41
|
+
iconBgColor?: string;
|
|
42
|
+
showIcon?: boolean;
|
|
35
43
|
confirmButtonText?: string;
|
|
36
44
|
cancelButtonText?: string;
|
|
37
45
|
confirmButtonColor?: string;
|
|
38
46
|
cancelButtonColor?: string;
|
|
47
|
+
confirmButtonTextColor?: string;
|
|
48
|
+
cancelButtonTextColor?: string;
|
|
49
|
+
showCancelButton?: boolean;
|
|
39
50
|
showLoaderOnConfirm?: boolean;
|
|
40
51
|
/** Type exactly — trimmed, case-sensitive. */
|
|
41
52
|
inputExpectedValue?: string;
|
|
@@ -43,7 +54,20 @@ interface ConfirmationAlertOptions {
|
|
|
43
54
|
reverseButtons?: boolean;
|
|
44
55
|
focusCancel?: boolean;
|
|
45
56
|
zIndex?: number;
|
|
57
|
+
width?: string | number;
|
|
58
|
+
/** Card corner radius. Default `1rem`. Number = px. */
|
|
59
|
+
borderRadius?: string | number;
|
|
60
|
+
/** Confirm/cancel button corner radius. Default `0.5rem`. Number = px. */
|
|
61
|
+
buttonBorderRadius?: string | number;
|
|
62
|
+
/** `danger` = delete look; `brand` = orange confirm. Explicit options win. */
|
|
63
|
+
variant?: ConfirmationAlertVariant;
|
|
64
|
+
customClass?: SweetAlertOptions["customClass"];
|
|
65
|
+
onCancel?: () => void;
|
|
46
66
|
}
|
|
67
|
+
/** Reusable icon markup — override via `iconHtml`. */
|
|
68
|
+
declare const DEFAULT_CONFIRM_ICONS: {
|
|
69
|
+
readonly warning: string;
|
|
70
|
+
};
|
|
47
71
|
declare function confirmationAlert(onConfirm: () => void | Promise<void>, options?: ConfirmationAlertOptions): void;
|
|
48
72
|
|
|
49
|
-
export { type ConfirmationAlertOptions as C, type ErrorClassification as E, type HandleApiErrorOptions as H, type RtkQueryError as R, type
|
|
73
|
+
export { type ConfirmationAlertOptions as C, DEFAULT_CONFIRM_ICONS as D, type ErrorClassification as E, type HandleApiErrorOptions as H, type RtkQueryError as R, type ConfirmationAlertVariant as a, type ErrorSuggestedAction as b, classifyError as c, confirmationAlert as d, formatValidationErrorsHtml as f, handleApiError as h, isRetryableError as i };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
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, E as ErrorClassification,
|
|
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';
|
|
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';
|
|
6
6
|
import '@reduxjs/toolkit/query';
|
|
7
|
+
import 'sweetalert2';
|
|
7
8
|
import 'react-router-dom';
|
|
8
9
|
import 'react';
|
|
9
10
|
import 'react-select';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
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, E as ErrorClassification,
|
|
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';
|
|
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';
|
|
6
6
|
import '@reduxjs/toolkit/query';
|
|
7
|
+
import 'sweetalert2';
|
|
7
8
|
import 'react-router-dom';
|
|
8
9
|
import 'react';
|
|
9
10
|
import 'react-select';
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(src_exports, {
|
|
|
37
37
|
CardSkeleton: () => CardSkeleton,
|
|
38
38
|
CustomCellEditor: () => CustomCellEditor,
|
|
39
39
|
CustomPagination: () => CustomPagination,
|
|
40
|
+
DEFAULT_CONFIRM_ICONS: () => DEFAULT_CONFIRM_ICONS,
|
|
40
41
|
DropdownFilter: () => DropdownFilter,
|
|
41
42
|
EztrakTabs: () => EztrakTabs,
|
|
42
43
|
Header: () => Header,
|
|
@@ -472,7 +473,138 @@ function handleApiError(error, { showAlert = false, fallbackMessage } = {}) {
|
|
|
472
473
|
import_react_hot_toast.default.error(message);
|
|
473
474
|
}
|
|
474
475
|
var BRAND_ORANGE = "#FF7335";
|
|
475
|
-
var
|
|
476
|
+
var DANGER_RED = "#DC2626";
|
|
477
|
+
var DANGER_ICON_BG = "#FEE2E2";
|
|
478
|
+
var CANCEL_BG = "#ffffff";
|
|
479
|
+
var CANCEL_TEXT = "#374151";
|
|
480
|
+
var CONFIRM_STYLE_ID = "eztrak-confirm-alert-styles";
|
|
481
|
+
function cssSize(value, fallback) {
|
|
482
|
+
if (value === void 0) return fallback;
|
|
483
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
484
|
+
}
|
|
485
|
+
var DEFAULT_CONFIRM_ICONS = {
|
|
486
|
+
warning: `
|
|
487
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
488
|
+
<path d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z" />
|
|
489
|
+
</svg>
|
|
490
|
+
`.trim()
|
|
491
|
+
};
|
|
492
|
+
var VARIANT_DEFAULTS = {
|
|
493
|
+
brand: {
|
|
494
|
+
confirmButtonText: "Yes",
|
|
495
|
+
confirmButtonColor: BRAND_ORANGE,
|
|
496
|
+
confirmButtonTextColor: "#ffffff",
|
|
497
|
+
cancelButtonColor: CANCEL_BG,
|
|
498
|
+
cancelButtonTextColor: CANCEL_TEXT,
|
|
499
|
+
iconColor: BRAND_ORANGE,
|
|
500
|
+
iconBgColor: "#FFEDD5",
|
|
501
|
+
iconHtml: DEFAULT_CONFIRM_ICONS.warning,
|
|
502
|
+
icon: "warning"
|
|
503
|
+
},
|
|
504
|
+
danger: {
|
|
505
|
+
title: "Delete this item",
|
|
506
|
+
confirmButtonText: "Yes, delete it!",
|
|
507
|
+
confirmButtonColor: DANGER_RED,
|
|
508
|
+
confirmButtonTextColor: "#ffffff",
|
|
509
|
+
cancelButtonColor: CANCEL_BG,
|
|
510
|
+
cancelButtonTextColor: CANCEL_TEXT,
|
|
511
|
+
iconColor: DANGER_RED,
|
|
512
|
+
iconBgColor: DANGER_ICON_BG,
|
|
513
|
+
iconHtml: DEFAULT_CONFIRM_ICONS.warning,
|
|
514
|
+
icon: "warning",
|
|
515
|
+
showLoaderOnConfirm: true
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
function ensureConfirmAlertStyles() {
|
|
519
|
+
if (typeof document === "undefined") return;
|
|
520
|
+
if (document.getElementById(CONFIRM_STYLE_ID)) return;
|
|
521
|
+
const style = document.createElement("style");
|
|
522
|
+
style.id = CONFIRM_STYLE_ID;
|
|
523
|
+
style.textContent = `
|
|
524
|
+
.ez-confirm-popup {
|
|
525
|
+
border-radius: var(--ez-confirm-radius, 1rem) !important;
|
|
526
|
+
padding: 1.5rem !important;
|
|
527
|
+
max-width: 24rem !important;
|
|
528
|
+
width: var(--ez-confirm-width, 100%) !important;
|
|
529
|
+
box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25) !important;
|
|
530
|
+
}
|
|
531
|
+
.ez-confirm-title {
|
|
532
|
+
font-size: 1.125rem !important;
|
|
533
|
+
font-weight: 600 !important;
|
|
534
|
+
color: #111827 !important;
|
|
535
|
+
margin: 0 0 0.25rem !important;
|
|
536
|
+
padding: 0 !important;
|
|
537
|
+
}
|
|
538
|
+
.ez-confirm-html {
|
|
539
|
+
font-size: 0.875rem !important;
|
|
540
|
+
color: #6b7280 !important;
|
|
541
|
+
margin: 0 0 1.5rem !important;
|
|
542
|
+
}
|
|
543
|
+
.ez-confirm-icon {
|
|
544
|
+
border: none !important;
|
|
545
|
+
background: var(--ez-confirm-icon-bg, #fee2e2) !important;
|
|
546
|
+
color: var(--ez-confirm-icon-color, #dc2626) !important;
|
|
547
|
+
width: 3rem !important;
|
|
548
|
+
height: 3rem !important;
|
|
549
|
+
margin: 0 auto 1rem !important;
|
|
550
|
+
border-radius: 9999px !important;
|
|
551
|
+
}
|
|
552
|
+
.ez-confirm-icon .swal2-icon-content {
|
|
553
|
+
font-size: inherit !important;
|
|
554
|
+
display: flex !important;
|
|
555
|
+
align-items: center !important;
|
|
556
|
+
justify-content: center !important;
|
|
557
|
+
color: inherit !important;
|
|
558
|
+
}
|
|
559
|
+
.ez-confirm-actions {
|
|
560
|
+
width: 100% !important;
|
|
561
|
+
margin: 0 !important;
|
|
562
|
+
gap: 0.75rem !important;
|
|
563
|
+
}
|
|
564
|
+
.ez-confirm-confirm,
|
|
565
|
+
.ez-confirm-cancel {
|
|
566
|
+
flex: 1 1 0 !important;
|
|
567
|
+
margin: 0 !important;
|
|
568
|
+
border-radius: var(--ez-confirm-btn-radius, 0.5rem) !important;
|
|
569
|
+
font-size: 0.875rem !important;
|
|
570
|
+
font-weight: 500 !important;
|
|
571
|
+
padding: 0.625rem 1rem !important;
|
|
572
|
+
box-shadow: none !important;
|
|
573
|
+
}
|
|
574
|
+
.ez-confirm-confirm {
|
|
575
|
+
background: var(--ez-confirm-confirm-bg, #ff7335) !important;
|
|
576
|
+
color: var(--ez-confirm-confirm-fg, #fff) !important;
|
|
577
|
+
border: none !important;
|
|
578
|
+
}
|
|
579
|
+
.ez-confirm-confirm:hover {
|
|
580
|
+
filter: brightness(0.95);
|
|
581
|
+
}
|
|
582
|
+
.ez-confirm-cancel {
|
|
583
|
+
background: var(--ez-confirm-cancel-bg, #fff) !important;
|
|
584
|
+
color: var(--ez-confirm-cancel-fg, #374151) !important;
|
|
585
|
+
border: 1px solid #d1d5db !important;
|
|
586
|
+
}
|
|
587
|
+
.ez-confirm-cancel:hover {
|
|
588
|
+
background: #f9fafb !important;
|
|
589
|
+
}
|
|
590
|
+
`;
|
|
591
|
+
document.head.appendChild(style);
|
|
592
|
+
}
|
|
593
|
+
function pick(explicit, fromVariant, fallback) {
|
|
594
|
+
if (explicit !== void 0) return explicit;
|
|
595
|
+
if (fromVariant !== void 0) return fromVariant;
|
|
596
|
+
return fallback;
|
|
597
|
+
}
|
|
598
|
+
function mergeCustomClass(base, extra) {
|
|
599
|
+
if (!extra || typeof extra !== "object") return base;
|
|
600
|
+
const merged = { ...base };
|
|
601
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
602
|
+
if (typeof value === "string" && value) {
|
|
603
|
+
merged[key] = merged[key] ? `${merged[key]} ${value}` : value;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return merged;
|
|
607
|
+
}
|
|
476
608
|
function getConfirmErrorMessage(error) {
|
|
477
609
|
if (error && typeof error === "object") {
|
|
478
610
|
const err = error;
|
|
@@ -481,23 +613,59 @@ function getConfirmErrorMessage(error) {
|
|
|
481
613
|
return "Something went wrong. Please try again.";
|
|
482
614
|
}
|
|
483
615
|
function confirmationAlert(onConfirm, options = {}) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
icon = "warning",
|
|
489
|
-
confirmButtonText = "Yes",
|
|
490
|
-
cancelButtonText = "Cancel",
|
|
491
|
-
confirmButtonColor = BRAND_ORANGE,
|
|
492
|
-
cancelButtonColor = CANCEL_RED,
|
|
493
|
-
showLoaderOnConfirm = false,
|
|
494
|
-
inputExpectedValue,
|
|
495
|
-
inputPlaceholder = "Type confirmation text to proceed",
|
|
496
|
-
reverseButtons,
|
|
497
|
-
focusCancel,
|
|
498
|
-
zIndex
|
|
499
|
-
} = options;
|
|
616
|
+
ensureConfirmAlertStyles();
|
|
617
|
+
const variant = options.variant ?? "brand";
|
|
618
|
+
const vd = VARIANT_DEFAULTS[variant];
|
|
619
|
+
const inputExpectedValue = options.inputExpectedValue;
|
|
500
620
|
const hasInput = Boolean(inputExpectedValue);
|
|
621
|
+
const title = pick(
|
|
622
|
+
options.title,
|
|
623
|
+
vd.title,
|
|
624
|
+
hasInput ? "Confirmation Required" : "Delete this item"
|
|
625
|
+
);
|
|
626
|
+
const text = options.text;
|
|
627
|
+
const html = options.html;
|
|
628
|
+
const icon = pick(options.icon, vd.icon, "warning");
|
|
629
|
+
const iconHtml = pick(options.iconHtml, vd.iconHtml, void 0);
|
|
630
|
+
const iconColor = pick(options.iconColor, vd.iconColor, BRAND_ORANGE);
|
|
631
|
+
const iconBgColor = pick(options.iconBgColor, vd.iconBgColor, "#FFEDD5");
|
|
632
|
+
const showIcon = options.showIcon !== false;
|
|
633
|
+
const confirmButtonText = pick(options.confirmButtonText, vd.confirmButtonText, "Yes");
|
|
634
|
+
const cancelButtonText = options.cancelButtonText ?? "Cancel";
|
|
635
|
+
const confirmButtonColor = pick(
|
|
636
|
+
options.confirmButtonColor,
|
|
637
|
+
vd.confirmButtonColor,
|
|
638
|
+
BRAND_ORANGE
|
|
639
|
+
);
|
|
640
|
+
const cancelButtonColor = pick(
|
|
641
|
+
options.cancelButtonColor,
|
|
642
|
+
vd.cancelButtonColor,
|
|
643
|
+
CANCEL_BG
|
|
644
|
+
);
|
|
645
|
+
const confirmButtonTextColor = pick(
|
|
646
|
+
options.confirmButtonTextColor,
|
|
647
|
+
vd.confirmButtonTextColor,
|
|
648
|
+
"#ffffff"
|
|
649
|
+
);
|
|
650
|
+
const cancelButtonTextColor = pick(
|
|
651
|
+
options.cancelButtonTextColor,
|
|
652
|
+
vd.cancelButtonTextColor,
|
|
653
|
+
CANCEL_TEXT
|
|
654
|
+
);
|
|
655
|
+
const showCancelButton = options.showCancelButton !== false;
|
|
656
|
+
const showLoaderOnConfirm = pick(
|
|
657
|
+
options.showLoaderOnConfirm,
|
|
658
|
+
vd.showLoaderOnConfirm,
|
|
659
|
+
false
|
|
660
|
+
);
|
|
661
|
+
const inputPlaceholder = options.inputPlaceholder ?? "Type confirmation text to proceed";
|
|
662
|
+
const reverseButtons = options.reverseButtons ?? false;
|
|
663
|
+
const focusCancel = options.focusCancel;
|
|
664
|
+
const zIndex = options.zIndex;
|
|
665
|
+
const width = options.width;
|
|
666
|
+
const borderRadius = cssSize(options.borderRadius, "1rem");
|
|
667
|
+
const buttonBorderRadius = cssSize(options.buttonBorderRadius, "0.5rem");
|
|
668
|
+
const onCancel = options.onCancel;
|
|
501
669
|
const useLoader = showLoaderOnConfirm || hasInput;
|
|
502
670
|
const inputHtml = html ?? (hasInput ? `
|
|
503
671
|
${text ? `<p style="margin-bottom: 15px;">${text}</p>` : ""}
|
|
@@ -505,24 +673,56 @@ function confirmationAlert(onConfirm, options = {}) {
|
|
|
505
673
|
Please type "<span style="color: ${BRAND_ORANGE}; font-weight: bold;">${inputExpectedValue}</span>" to confirm:
|
|
506
674
|
</p>
|
|
507
675
|
` : void 0);
|
|
676
|
+
const baseCustomClass = {
|
|
677
|
+
popup: "ez-confirm-popup",
|
|
678
|
+
title: "ez-confirm-title",
|
|
679
|
+
htmlContainer: "ez-confirm-html",
|
|
680
|
+
actions: "ez-confirm-actions",
|
|
681
|
+
confirmButton: "ez-confirm-confirm",
|
|
682
|
+
cancelButton: "ez-confirm-cancel",
|
|
683
|
+
icon: "ez-confirm-icon"
|
|
684
|
+
};
|
|
508
685
|
const swalOptions = {
|
|
509
686
|
title,
|
|
510
|
-
|
|
511
|
-
showCancelButton: true,
|
|
687
|
+
showCancelButton,
|
|
512
688
|
confirmButtonText,
|
|
513
689
|
cancelButtonText,
|
|
514
690
|
confirmButtonColor,
|
|
515
691
|
cancelButtonColor,
|
|
516
692
|
reverseButtons,
|
|
517
693
|
focusCancel,
|
|
694
|
+
customClass: mergeCustomClass(baseCustomClass, options.customClass),
|
|
518
695
|
allowOutsideClick: () => !import_sweetalert2.default.isLoading(),
|
|
519
696
|
allowEscapeKey: () => !import_sweetalert2.default.isLoading(),
|
|
520
697
|
didOpen: () => {
|
|
698
|
+
const popup = import_sweetalert2.default.getPopup();
|
|
699
|
+
if (popup) {
|
|
700
|
+
popup.style.setProperty("--ez-confirm-confirm-bg", confirmButtonColor);
|
|
701
|
+
popup.style.setProperty("--ez-confirm-confirm-fg", confirmButtonTextColor);
|
|
702
|
+
popup.style.setProperty("--ez-confirm-cancel-bg", cancelButtonColor);
|
|
703
|
+
popup.style.setProperty("--ez-confirm-cancel-fg", cancelButtonTextColor);
|
|
704
|
+
popup.style.setProperty("--ez-confirm-icon-color", iconColor);
|
|
705
|
+
popup.style.setProperty("--ez-confirm-icon-bg", iconBgColor);
|
|
706
|
+
popup.style.setProperty("--ez-confirm-radius", borderRadius);
|
|
707
|
+
popup.style.setProperty("--ez-confirm-btn-radius", buttonBorderRadius);
|
|
708
|
+
if (width != null) {
|
|
709
|
+
popup.style.setProperty(
|
|
710
|
+
"--ez-confirm-width",
|
|
711
|
+
typeof width === "number" ? `${width}px` : String(width)
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
521
715
|
if (zIndex == null) return;
|
|
522
716
|
const container = import_sweetalert2.default.getContainer();
|
|
523
717
|
if (container) container.style.zIndex = String(zIndex);
|
|
524
718
|
}
|
|
525
719
|
};
|
|
720
|
+
if (showIcon) {
|
|
721
|
+
swalOptions.icon = icon;
|
|
722
|
+
if (iconHtml) {
|
|
723
|
+
swalOptions.iconHtml = iconHtml;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
526
726
|
if (hasInput) {
|
|
527
727
|
swalOptions.html = inputHtml;
|
|
528
728
|
swalOptions.input = "text";
|
|
@@ -557,6 +757,10 @@ function confirmationAlert(onConfirm, options = {}) {
|
|
|
557
757
|
void import_sweetalert2.default.fire(swalOptions).then((result) => {
|
|
558
758
|
if (result.isConfirmed && !useLoader) {
|
|
559
759
|
void Promise.resolve(onConfirm());
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
if (result.isDismissed) {
|
|
763
|
+
onCancel?.();
|
|
560
764
|
}
|
|
561
765
|
});
|
|
562
766
|
}
|
|
@@ -1839,7 +2043,35 @@ function Header({
|
|
|
1839
2043
|
var import_react8 = require("react");
|
|
1840
2044
|
var import_react_router_dom5 = require("react-router-dom");
|
|
1841
2045
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1842
|
-
var
|
|
2046
|
+
var DEFAULT_BACKGROUND = "#F7F7F5";
|
|
2047
|
+
var DEFAULT_INACTIVE = "#6B7280";
|
|
2048
|
+
var DEFAULT_ACTIVE = "#111111";
|
|
2049
|
+
var DEFAULT_SEPARATOR = "#9CA3AF";
|
|
2050
|
+
var CRUMB_LAYOUT = "inline-flex items-center gap-1.5 whitespace-nowrap leading-5 rounded-sm";
|
|
2051
|
+
var LINK_INTERACTION = "font-normal transition-colors duration-200 motion-reduce:transition-none hover:!text-[color-mix(in_srgb,var(--bc-inactive)_65%,#111111)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#111111]";
|
|
2052
|
+
function BreadcrumbChevron() {
|
|
2053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2054
|
+
"svg",
|
|
2055
|
+
{
|
|
2056
|
+
width: "12",
|
|
2057
|
+
height: "12",
|
|
2058
|
+
viewBox: "0 0 12 12",
|
|
2059
|
+
fill: "none",
|
|
2060
|
+
"aria-hidden": "true",
|
|
2061
|
+
className: "shrink-0",
|
|
2062
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2063
|
+
"path",
|
|
2064
|
+
{
|
|
2065
|
+
d: "M4.5 2.5L8 6L4.5 9.5",
|
|
2066
|
+
stroke: "currentColor",
|
|
2067
|
+
strokeWidth: "1.5",
|
|
2068
|
+
strokeLinecap: "round",
|
|
2069
|
+
strokeLinejoin: "round"
|
|
2070
|
+
}
|
|
2071
|
+
)
|
|
2072
|
+
}
|
|
2073
|
+
);
|
|
2074
|
+
}
|
|
1843
2075
|
function asTitleMap(customTitles) {
|
|
1844
2076
|
if (Object.prototype.toString.call(customTitles) !== "[object Object]") {
|
|
1845
2077
|
return {};
|
|
@@ -1869,73 +2101,141 @@ function Breadcrumbs({
|
|
|
1869
2101
|
containerClassName,
|
|
1870
2102
|
linkClassName = "",
|
|
1871
2103
|
separatorClassName = "",
|
|
1872
|
-
separator
|
|
1873
|
-
activeClassName = "font-
|
|
2104
|
+
separator,
|
|
2105
|
+
activeClassName = "font-semibold",
|
|
1874
2106
|
customTitles = {},
|
|
1875
2107
|
customIcons = {},
|
|
1876
2108
|
prefix,
|
|
1877
2109
|
suffix,
|
|
1878
|
-
nonClickablePaths = []
|
|
2110
|
+
nonClickablePaths = [],
|
|
2111
|
+
backgroundColor = DEFAULT_BACKGROUND,
|
|
2112
|
+
inactiveColor = DEFAULT_INACTIVE,
|
|
2113
|
+
activeColor = DEFAULT_ACTIVE,
|
|
2114
|
+
separatorColor = DEFAULT_SEPARATOR,
|
|
2115
|
+
iconColor,
|
|
2116
|
+
iconClassName,
|
|
2117
|
+
showHome = false
|
|
1879
2118
|
}) {
|
|
1880
2119
|
const location = (0, import_react_router_dom5.useLocation)();
|
|
1881
2120
|
const pathnames = location.pathname.split("/").filter((segment) => segment);
|
|
1882
2121
|
const titles = asTitleMap(customTitles);
|
|
1883
|
-
const inactiveLinkClassName = cn(INACTIVE_LINK_CLASS, linkClassName);
|
|
1884
2122
|
const getTitle = (pathname) => {
|
|
1885
2123
|
const match = findRoute(pathname, routes);
|
|
1886
2124
|
if (match && match.title) {
|
|
1887
2125
|
return match.title;
|
|
1888
2126
|
}
|
|
1889
|
-
const titleKeys = Object.keys(titles);
|
|
1890
|
-
const paramMatch = pathname.split("/").find((segment) => titleKeys.includes(segment)) || "";
|
|
1891
|
-
if (paramMatch && titles[paramMatch]) {
|
|
1892
|
-
return titles[paramMatch];
|
|
1893
|
-
}
|
|
1894
2127
|
const lastParamPath = getLastParam(pathname);
|
|
2128
|
+
if (lastParamPath && titles[lastParamPath]) {
|
|
2129
|
+
return titles[lastParamPath];
|
|
2130
|
+
}
|
|
1895
2131
|
if (lastParamPath) {
|
|
1896
2132
|
return lastParamPath;
|
|
1897
2133
|
}
|
|
1898
2134
|
return pathname;
|
|
1899
2135
|
};
|
|
1900
2136
|
const getIcon = (pathname) => {
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
return customIcons[matchedSegment];
|
|
2137
|
+
const segment = getLastParam(pathname);
|
|
2138
|
+
if (segment && customIcons[segment]) {
|
|
2139
|
+
return customIcons[segment];
|
|
1905
2140
|
}
|
|
1906
2141
|
return null;
|
|
1907
2142
|
};
|
|
2143
|
+
const crumbs = [];
|
|
2144
|
+
if (showHome) {
|
|
2145
|
+
crumbs.push({
|
|
2146
|
+
key: "home",
|
|
2147
|
+
to: "/",
|
|
2148
|
+
title: titles.home || "Home",
|
|
2149
|
+
icon: customIcons.home ?? null,
|
|
2150
|
+
isCurrent: pathnames.length === 0,
|
|
2151
|
+
isLink: pathnames.length > 0
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
pathnames.forEach((segment, index) => {
|
|
2155
|
+
const to = `/${pathnames.slice(0, index + 1).join("/")}`;
|
|
2156
|
+
const isCurrent = index === pathnames.length - 1;
|
|
2157
|
+
const isNonClickable = nonClickablePaths.some(
|
|
2158
|
+
(token) => to.includes(token) || segment === token
|
|
2159
|
+
);
|
|
2160
|
+
crumbs.push({
|
|
2161
|
+
key: to,
|
|
2162
|
+
to,
|
|
2163
|
+
title: getTitle(to),
|
|
2164
|
+
icon: getIcon(to),
|
|
2165
|
+
isCurrent,
|
|
2166
|
+
isLink: !isCurrent && !isNonClickable
|
|
2167
|
+
});
|
|
2168
|
+
});
|
|
2169
|
+
const navStyle = {
|
|
2170
|
+
backgroundColor,
|
|
2171
|
+
"--bc-inactive": inactiveColor
|
|
2172
|
+
};
|
|
2173
|
+
const inactiveClassName = cn(CRUMB_LAYOUT, LINK_INTERACTION, linkClassName);
|
|
2174
|
+
const staticInactiveClassName = cn(CRUMB_LAYOUT, "font-normal", linkClassName);
|
|
2175
|
+
const currentClassName = cn(CRUMB_LAYOUT, activeClassName);
|
|
2176
|
+
const renderCrumb = (crumb) => {
|
|
2177
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
2178
|
+
crumb.icon ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2179
|
+
"span",
|
|
2180
|
+
{
|
|
2181
|
+
className: cn("inline-flex shrink-0 items-center", iconClassName),
|
|
2182
|
+
style: iconColor ? { color: iconColor } : void 0,
|
|
2183
|
+
children: crumb.icon
|
|
2184
|
+
}
|
|
2185
|
+
) : null,
|
|
2186
|
+
crumb.title
|
|
2187
|
+
] });
|
|
2188
|
+
if (crumb.isCurrent) {
|
|
2189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2190
|
+
"span",
|
|
2191
|
+
{
|
|
2192
|
+
className: currentClassName,
|
|
2193
|
+
style: { color: activeColor },
|
|
2194
|
+
"aria-current": "page",
|
|
2195
|
+
children: content
|
|
2196
|
+
}
|
|
2197
|
+
);
|
|
2198
|
+
}
|
|
2199
|
+
if (crumb.isLink) {
|
|
2200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2201
|
+
import_react_router_dom5.Link,
|
|
2202
|
+
{
|
|
2203
|
+
to: crumb.to,
|
|
2204
|
+
className: inactiveClassName,
|
|
2205
|
+
style: { color: inactiveColor },
|
|
2206
|
+
children: content
|
|
2207
|
+
}
|
|
2208
|
+
);
|
|
2209
|
+
}
|
|
2210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: staticInactiveClassName, style: { color: inactiveColor }, children: content });
|
|
2211
|
+
};
|
|
1908
2212
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1909
|
-
"
|
|
2213
|
+
"nav",
|
|
1910
2214
|
{
|
|
2215
|
+
"aria-label": "Breadcrumb",
|
|
1911
2216
|
className: cn(
|
|
1912
|
-
"flex flex-row gap-2
|
|
2217
|
+
"flex w-full flex-row items-center gap-2 overflow-x-auto px-4 py-3 text-sm leading-5",
|
|
1913
2218
|
containerClassName
|
|
1914
2219
|
),
|
|
2220
|
+
style: navStyle,
|
|
1915
2221
|
children: [
|
|
1916
|
-
prefix
|
|
1917
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react8.Fragment, { children: [
|
|
1934
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: separatorClassName, children: separator }),
|
|
1935
|
-
isLast || isNonClickable ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: isLast ? activeClassName : linkClassName, children: crumb }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_router_dom5.Link, { to, className: inactiveLinkClassName, children: crumb })
|
|
1936
|
-
] }, to);
|
|
1937
|
-
}),
|
|
1938
|
-
suffix && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "breadcrumb-suffix", children: suffix })
|
|
2222
|
+
prefix ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "breadcrumb-prefix", children: prefix }) : null,
|
|
2223
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ol", { className: "flex min-w-0 flex-row flex-nowrap items-center gap-2", children: crumbs.map((crumb, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { className: "inline-flex items-center gap-2", children: [
|
|
2224
|
+
index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2225
|
+
"span",
|
|
2226
|
+
{
|
|
2227
|
+
"aria-hidden": "true",
|
|
2228
|
+
className: cn(
|
|
2229
|
+
"inline-flex shrink-0 items-center",
|
|
2230
|
+
separatorClassName
|
|
2231
|
+
),
|
|
2232
|
+
style: { color: separatorColor },
|
|
2233
|
+
children: separator === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(BreadcrumbChevron, {}) : (0, import_react8.isValidElement)(separator) ? (0, import_react8.cloneElement)(separator) : separator
|
|
2234
|
+
}
|
|
2235
|
+
) : null,
|
|
2236
|
+
renderCrumb(crumb)
|
|
2237
|
+
] }, crumb.key)) }),
|
|
2238
|
+
suffix ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "breadcrumb-suffix", children: suffix }) : null
|
|
1939
2239
|
]
|
|
1940
2240
|
}
|
|
1941
2241
|
);
|
|
@@ -3161,6 +3461,7 @@ var TableErrorBoundary = ({
|
|
|
3161
3461
|
CardSkeleton,
|
|
3162
3462
|
CustomCellEditor,
|
|
3163
3463
|
CustomPagination,
|
|
3464
|
+
DEFAULT_CONFIRM_ICONS,
|
|
3164
3465
|
DropdownFilter,
|
|
3165
3466
|
EztrakTabs,
|
|
3166
3467
|
Header,
|