@eztrak/shared 0.16.6 → 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/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-SS3J2WBE.mjs → chunk-KJWCRX6F.mjs} +2 -2
- package/dist/components/index.d.mts +2 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +222 -19
- 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 +224 -19
- 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-WZVYTP6G.mjs.map → chunk-HAW3AKJP.mjs.map} +0 -0
- /package/dist/{chunk-SS3J2WBE.mjs.map → chunk-KJWCRX6F.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
|
}
|
|
@@ -3257,6 +3461,7 @@ var TableErrorBoundary = ({
|
|
|
3257
3461
|
CardSkeleton,
|
|
3258
3462
|
CustomCellEditor,
|
|
3259
3463
|
CustomPagination,
|
|
3464
|
+
DEFAULT_CONFIRM_ICONS,
|
|
3260
3465
|
DropdownFilter,
|
|
3261
3466
|
EztrakTabs,
|
|
3262
3467
|
Header,
|