@eztrak/shared 0.16.6 → 0.17.1
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-SS3J2WBE.mjs → chunk-4ASJWHN3.mjs} +3 -6
- package/dist/chunk-4ASJWHN3.mjs.map +1 -0
- package/dist/{chunk-WZVYTP6G.mjs → chunk-LS7AI4ER.mjs} +2 -2
- package/dist/{chunk-EIX5CUQF.mjs → chunk-QOYMQFOB.mjs} +238 -20
- package/dist/chunk-QOYMQFOB.mjs.map +1 -0
- package/dist/components/index.d.mts +2 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +237 -23
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -2
- package/dist/{handleApiError-CwVIJOqO.d.mts → handleApiError-BIAaN76q.d.mts} +32 -1
- package/dist/{handleApiError-CwVIJOqO.d.ts → handleApiError-BIAaN76q.d.ts} +32 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +239 -23
- 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 +238 -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-SS3J2WBE.mjs.map +0 -1
- /package/dist/{chunk-WZVYTP6G.mjs.map → chunk-LS7AI4ER.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,26 @@ 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;
|
|
37
|
+
/** Body HTML when `html` is not set. String only (not React nodes). */
|
|
38
|
+
children?: string;
|
|
34
39
|
icon?: "warning" | "info" | "question" | "error" | "success";
|
|
40
|
+
/** Custom icon markup. When set, replaces SweetAlert's default icon content. */
|
|
41
|
+
iconHtml?: string;
|
|
42
|
+
iconColor?: string;
|
|
43
|
+
iconBgColor?: string;
|
|
44
|
+
showIcon?: boolean;
|
|
35
45
|
confirmButtonText?: string;
|
|
36
46
|
cancelButtonText?: string;
|
|
37
47
|
confirmButtonColor?: string;
|
|
38
48
|
cancelButtonColor?: string;
|
|
49
|
+
confirmButtonTextColor?: string;
|
|
50
|
+
cancelButtonTextColor?: string;
|
|
51
|
+
showCancelButton?: boolean;
|
|
39
52
|
showLoaderOnConfirm?: boolean;
|
|
40
53
|
/** Type exactly — trimmed, case-sensitive. */
|
|
41
54
|
inputExpectedValue?: string;
|
|
@@ -43,7 +56,25 @@ interface ConfirmationAlertOptions {
|
|
|
43
56
|
reverseButtons?: boolean;
|
|
44
57
|
focusCancel?: boolean;
|
|
45
58
|
zIndex?: number;
|
|
59
|
+
width?: string | number;
|
|
60
|
+
/** Card corner radius. Default `1rem`. Number = px. */
|
|
61
|
+
borderRadius?: string | number;
|
|
62
|
+
/** Confirm/cancel button corner radius. Default `0.5rem`. Number = px. */
|
|
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;
|
|
69
|
+
/** `danger` = delete look; `brand` = orange confirm. Explicit options win. */
|
|
70
|
+
variant?: ConfirmationAlertVariant;
|
|
71
|
+
customClass?: SweetAlertOptions["customClass"];
|
|
72
|
+
onCancel?: () => void;
|
|
46
73
|
}
|
|
74
|
+
/** Reusable icon markup — override via `iconHtml`. */
|
|
75
|
+
declare const DEFAULT_CONFIRM_ICONS: {
|
|
76
|
+
readonly warning: string;
|
|
77
|
+
};
|
|
47
78
|
declare function confirmationAlert(onConfirm: () => void | Promise<void>, options?: ConfirmationAlertOptions): void;
|
|
48
79
|
|
|
49
|
-
export { type ConfirmationAlertOptions as C, type ErrorClassification as E, type HandleApiErrorOptions as H, type RtkQueryError as R, type
|
|
80
|
+
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,26 @@ 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;
|
|
37
|
+
/** Body HTML when `html` is not set. String only (not React nodes). */
|
|
38
|
+
children?: string;
|
|
34
39
|
icon?: "warning" | "info" | "question" | "error" | "success";
|
|
40
|
+
/** Custom icon markup. When set, replaces SweetAlert's default icon content. */
|
|
41
|
+
iconHtml?: string;
|
|
42
|
+
iconColor?: string;
|
|
43
|
+
iconBgColor?: string;
|
|
44
|
+
showIcon?: boolean;
|
|
35
45
|
confirmButtonText?: string;
|
|
36
46
|
cancelButtonText?: string;
|
|
37
47
|
confirmButtonColor?: string;
|
|
38
48
|
cancelButtonColor?: string;
|
|
49
|
+
confirmButtonTextColor?: string;
|
|
50
|
+
cancelButtonTextColor?: string;
|
|
51
|
+
showCancelButton?: boolean;
|
|
39
52
|
showLoaderOnConfirm?: boolean;
|
|
40
53
|
/** Type exactly — trimmed, case-sensitive. */
|
|
41
54
|
inputExpectedValue?: string;
|
|
@@ -43,7 +56,25 @@ interface ConfirmationAlertOptions {
|
|
|
43
56
|
reverseButtons?: boolean;
|
|
44
57
|
focusCancel?: boolean;
|
|
45
58
|
zIndex?: number;
|
|
59
|
+
width?: string | number;
|
|
60
|
+
/** Card corner radius. Default `1rem`. Number = px. */
|
|
61
|
+
borderRadius?: string | number;
|
|
62
|
+
/** Confirm/cancel button corner radius. Default `0.5rem`. Number = px. */
|
|
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;
|
|
69
|
+
/** `danger` = delete look; `brand` = orange confirm. Explicit options win. */
|
|
70
|
+
variant?: ConfirmationAlertVariant;
|
|
71
|
+
customClass?: SweetAlertOptions["customClass"];
|
|
72
|
+
onCancel?: () => void;
|
|
46
73
|
}
|
|
74
|
+
/** Reusable icon markup — override via `iconHtml`. */
|
|
75
|
+
declare const DEFAULT_CONFIRM_ICONS: {
|
|
76
|
+
readonly warning: string;
|
|
77
|
+
};
|
|
47
78
|
declare function confirmationAlert(onConfirm: () => void | Promise<void>, options?: ConfirmationAlertOptions): void;
|
|
48
79
|
|
|
49
|
-
export { type ConfirmationAlertOptions as C, type ErrorClassification as E, type HandleApiErrorOptions as H, type RtkQueryError as R, type
|
|
80
|
+
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-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';
|
|
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-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';
|
|
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,144 @@ 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
|
+
.ez-confirm-popup .swal2-input {
|
|
591
|
+
margin-top: var(--ez-confirm-input-mt, 0) !important;
|
|
592
|
+
margin-right: var(--ez-confirm-input-mr, 0) !important;
|
|
593
|
+
margin-bottom: var(--ez-confirm-input-mb, 1.25rem) !important;
|
|
594
|
+
margin-left: var(--ez-confirm-input-ml, 0) !important;
|
|
595
|
+
}
|
|
596
|
+
`;
|
|
597
|
+
document.head.appendChild(style);
|
|
598
|
+
}
|
|
599
|
+
function pick(explicit, fromVariant, fallback) {
|
|
600
|
+
if (explicit !== void 0) return explicit;
|
|
601
|
+
if (fromVariant !== void 0) return fromVariant;
|
|
602
|
+
return fallback;
|
|
603
|
+
}
|
|
604
|
+
function mergeCustomClass(base, extra) {
|
|
605
|
+
if (!extra || typeof extra !== "object") return base;
|
|
606
|
+
const merged = { ...base };
|
|
607
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
608
|
+
if (typeof value === "string" && value) {
|
|
609
|
+
merged[key] = merged[key] ? `${merged[key]} ${value}` : value;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return merged;
|
|
613
|
+
}
|
|
476
614
|
function getConfirmErrorMessage(error) {
|
|
477
615
|
if (error && typeof error === "object") {
|
|
478
616
|
const err = error;
|
|
@@ -481,23 +619,63 @@ function getConfirmErrorMessage(error) {
|
|
|
481
619
|
return "Something went wrong. Please try again.";
|
|
482
620
|
}
|
|
483
621
|
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;
|
|
622
|
+
ensureConfirmAlertStyles();
|
|
623
|
+
const variant = options.variant ?? "brand";
|
|
624
|
+
const vd = VARIANT_DEFAULTS[variant];
|
|
625
|
+
const inputExpectedValue = options.inputExpectedValue;
|
|
500
626
|
const hasInput = Boolean(inputExpectedValue);
|
|
627
|
+
const title = pick(
|
|
628
|
+
options.title,
|
|
629
|
+
vd.title,
|
|
630
|
+
hasInput ? "Confirmation Required" : "Delete this item"
|
|
631
|
+
);
|
|
632
|
+
const text = options.text;
|
|
633
|
+
const html = options.html ?? options.children;
|
|
634
|
+
const icon = pick(options.icon, vd.icon, "warning");
|
|
635
|
+
const iconHtml = pick(options.iconHtml, vd.iconHtml, void 0);
|
|
636
|
+
const iconColor = pick(options.iconColor, vd.iconColor, BRAND_ORANGE);
|
|
637
|
+
const iconBgColor = pick(options.iconBgColor, vd.iconBgColor, "#FFEDD5");
|
|
638
|
+
const showIcon = options.showIcon !== false;
|
|
639
|
+
const confirmButtonText = pick(options.confirmButtonText, vd.confirmButtonText, "Yes");
|
|
640
|
+
const cancelButtonText = options.cancelButtonText ?? "Cancel";
|
|
641
|
+
const confirmButtonColor = pick(
|
|
642
|
+
options.confirmButtonColor,
|
|
643
|
+
vd.confirmButtonColor,
|
|
644
|
+
BRAND_ORANGE
|
|
645
|
+
);
|
|
646
|
+
const cancelButtonColor = pick(
|
|
647
|
+
options.cancelButtonColor,
|
|
648
|
+
vd.cancelButtonColor,
|
|
649
|
+
CANCEL_BG
|
|
650
|
+
);
|
|
651
|
+
const confirmButtonTextColor = pick(
|
|
652
|
+
options.confirmButtonTextColor,
|
|
653
|
+
vd.confirmButtonTextColor,
|
|
654
|
+
"#ffffff"
|
|
655
|
+
);
|
|
656
|
+
const cancelButtonTextColor = pick(
|
|
657
|
+
options.cancelButtonTextColor,
|
|
658
|
+
vd.cancelButtonTextColor,
|
|
659
|
+
CANCEL_TEXT
|
|
660
|
+
);
|
|
661
|
+
const showCancelButton = options.showCancelButton !== false;
|
|
662
|
+
const showLoaderOnConfirm = pick(
|
|
663
|
+
options.showLoaderOnConfirm,
|
|
664
|
+
vd.showLoaderOnConfirm,
|
|
665
|
+
false
|
|
666
|
+
);
|
|
667
|
+
const inputPlaceholder = options.inputPlaceholder ?? "Type confirmation text to proceed";
|
|
668
|
+
const reverseButtons = options.reverseButtons ?? false;
|
|
669
|
+
const focusCancel = options.focusCancel;
|
|
670
|
+
const zIndex = options.zIndex;
|
|
671
|
+
const width = options.width;
|
|
672
|
+
const borderRadius = cssSize(options.borderRadius, "1rem");
|
|
673
|
+
const buttonBorderRadius = cssSize(options.buttonBorderRadius, "0.5rem");
|
|
674
|
+
const inputMarginTop = cssSize(options.inputMarginTop, "0");
|
|
675
|
+
const inputMarginRight = cssSize(options.inputMarginRight, "0");
|
|
676
|
+
const inputMarginBottom = cssSize(options.inputMarginBottom, "1.25rem");
|
|
677
|
+
const inputMarginLeft = cssSize(options.inputMarginLeft, "0");
|
|
678
|
+
const onCancel = options.onCancel;
|
|
501
679
|
const useLoader = showLoaderOnConfirm || hasInput;
|
|
502
680
|
const inputHtml = html ?? (hasInput ? `
|
|
503
681
|
${text ? `<p style="margin-bottom: 15px;">${text}</p>` : ""}
|
|
@@ -505,24 +683,60 @@ function confirmationAlert(onConfirm, options = {}) {
|
|
|
505
683
|
Please type "<span style="color: ${BRAND_ORANGE}; font-weight: bold;">${inputExpectedValue}</span>" to confirm:
|
|
506
684
|
</p>
|
|
507
685
|
` : void 0);
|
|
686
|
+
const baseCustomClass = {
|
|
687
|
+
popup: "ez-confirm-popup",
|
|
688
|
+
title: "ez-confirm-title",
|
|
689
|
+
htmlContainer: "ez-confirm-html",
|
|
690
|
+
actions: "ez-confirm-actions",
|
|
691
|
+
confirmButton: "ez-confirm-confirm",
|
|
692
|
+
cancelButton: "ez-confirm-cancel",
|
|
693
|
+
icon: "ez-confirm-icon"
|
|
694
|
+
};
|
|
508
695
|
const swalOptions = {
|
|
509
696
|
title,
|
|
510
|
-
|
|
511
|
-
showCancelButton: true,
|
|
697
|
+
showCancelButton,
|
|
512
698
|
confirmButtonText,
|
|
513
699
|
cancelButtonText,
|
|
514
700
|
confirmButtonColor,
|
|
515
701
|
cancelButtonColor,
|
|
516
702
|
reverseButtons,
|
|
517
703
|
focusCancel,
|
|
704
|
+
customClass: mergeCustomClass(baseCustomClass, options.customClass),
|
|
518
705
|
allowOutsideClick: () => !import_sweetalert2.default.isLoading(),
|
|
519
706
|
allowEscapeKey: () => !import_sweetalert2.default.isLoading(),
|
|
520
707
|
didOpen: () => {
|
|
708
|
+
const popup = import_sweetalert2.default.getPopup();
|
|
709
|
+
if (popup) {
|
|
710
|
+
popup.style.setProperty("--ez-confirm-confirm-bg", confirmButtonColor);
|
|
711
|
+
popup.style.setProperty("--ez-confirm-confirm-fg", confirmButtonTextColor);
|
|
712
|
+
popup.style.setProperty("--ez-confirm-cancel-bg", cancelButtonColor);
|
|
713
|
+
popup.style.setProperty("--ez-confirm-cancel-fg", cancelButtonTextColor);
|
|
714
|
+
popup.style.setProperty("--ez-confirm-icon-color", iconColor);
|
|
715
|
+
popup.style.setProperty("--ez-confirm-icon-bg", iconBgColor);
|
|
716
|
+
popup.style.setProperty("--ez-confirm-radius", borderRadius);
|
|
717
|
+
popup.style.setProperty("--ez-confirm-btn-radius", buttonBorderRadius);
|
|
718
|
+
popup.style.setProperty("--ez-confirm-input-mt", inputMarginTop);
|
|
719
|
+
popup.style.setProperty("--ez-confirm-input-mr", inputMarginRight);
|
|
720
|
+
popup.style.setProperty("--ez-confirm-input-mb", inputMarginBottom);
|
|
721
|
+
popup.style.setProperty("--ez-confirm-input-ml", inputMarginLeft);
|
|
722
|
+
if (width != null) {
|
|
723
|
+
popup.style.setProperty(
|
|
724
|
+
"--ez-confirm-width",
|
|
725
|
+
typeof width === "number" ? `${width}px` : String(width)
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
521
729
|
if (zIndex == null) return;
|
|
522
730
|
const container = import_sweetalert2.default.getContainer();
|
|
523
731
|
if (container) container.style.zIndex = String(zIndex);
|
|
524
732
|
}
|
|
525
733
|
};
|
|
734
|
+
if (showIcon) {
|
|
735
|
+
swalOptions.icon = icon;
|
|
736
|
+
if (iconHtml) {
|
|
737
|
+
swalOptions.iconHtml = iconHtml;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
526
740
|
if (hasInput) {
|
|
527
741
|
swalOptions.html = inputHtml;
|
|
528
742
|
swalOptions.input = "text";
|
|
@@ -557,6 +771,10 @@ function confirmationAlert(onConfirm, options = {}) {
|
|
|
557
771
|
void import_sweetalert2.default.fire(swalOptions).then((result) => {
|
|
558
772
|
if (result.isConfirmed && !useLoader) {
|
|
559
773
|
void Promise.resolve(onConfirm());
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
if (result.isDismissed) {
|
|
777
|
+
onCancel?.();
|
|
560
778
|
}
|
|
561
779
|
});
|
|
562
780
|
}
|
|
@@ -2254,10 +2472,7 @@ function Sidebar({
|
|
|
2254
2472
|
"div",
|
|
2255
2473
|
{
|
|
2256
2474
|
"data-sidebar-item": item.name,
|
|
2257
|
-
className:
|
|
2258
|
-
"has-sub-items max-w-full min-w-0 flex flex-col",
|
|
2259
|
-
collapsed ? "my-1" : "my-2"
|
|
2260
|
-
),
|
|
2475
|
+
className: "has-sub-items max-w-full min-w-0 flex flex-col",
|
|
2261
2476
|
children: [
|
|
2262
2477
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2263
2478
|
ToolTip,
|
|
@@ -3257,6 +3472,7 @@ var TableErrorBoundary = ({
|
|
|
3257
3472
|
CardSkeleton,
|
|
3258
3473
|
CustomCellEditor,
|
|
3259
3474
|
CustomPagination,
|
|
3475
|
+
DEFAULT_CONFIRM_ICONS,
|
|
3260
3476
|
DropdownFilter,
|
|
3261
3477
|
EztrakTabs,
|
|
3262
3478
|
Header,
|