@sustaina/shared-ui 1.12.0 → 1.13.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/index.d.mts +60 -4
- package/dist/index.d.ts +60 -4
- package/dist/index.js +440 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +436 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -4
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,9 @@ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
|
17
17
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
18
18
|
import { reSplitAlphaNumeric, useReactTable, getCoreRowModel, getGroupedRowModel, getExpandedRowModel, getSortedRowModel, getFilteredRowModel, flexRender } from '@tanstack/react-table';
|
|
19
19
|
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
20
|
+
import i18n from 'i18next';
|
|
21
|
+
import { initReactI18next, useTranslation } from 'react-i18next';
|
|
22
|
+
import { create } from 'zustand';
|
|
20
23
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
21
24
|
import { SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
|
|
22
25
|
import { CSS } from '@dnd-kit/utilities';
|
|
@@ -24,7 +27,6 @@ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
|
24
27
|
import { useSensors, useSensor, PointerSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
25
28
|
import { restrictToParentElement, restrictToVerticalAxis } from '@dnd-kit/modifiers';
|
|
26
29
|
import { z } from 'zod';
|
|
27
|
-
import { create } from 'zustand';
|
|
28
30
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
29
31
|
import { createCommand, DecoratorNode, $getSelection, $isRangeSelection, $getNodeByKey, $createTextNode, $insertNodes, CAN_UNDO_COMMAND, COMMAND_PRIORITY_NORMAL, CAN_REDO_COMMAND, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, $createParagraphNode, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, UNDO_COMMAND, REDO_COMMAND, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
30
32
|
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
@@ -4724,9 +4726,11 @@ var buttonVariants2 = cva(
|
|
|
4724
4726
|
variant: {
|
|
4725
4727
|
default: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
|
|
4726
4728
|
success: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
|
|
4727
|
-
error: "border border-[#BB0B0E]
|
|
4729
|
+
error: "border border-[#BB0B0E] text-[#BB0B0E] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
4728
4730
|
warning: "bg-yellow-500 text-black shadow-xs hover:bg-yellow-600 dark:hover:bg-yellow-400",
|
|
4729
|
-
cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50"
|
|
4731
|
+
cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
|
|
4732
|
+
confirm: "border border-[#BB0B0E] text-[#BB0B0E] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
4733
|
+
"confirm-green": "border border-[#379A2A] text-[#379A2A] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground"
|
|
4730
4734
|
},
|
|
4731
4735
|
size: {
|
|
4732
4736
|
default: "h-9 px-4 has-[>svg]:px-3",
|
|
@@ -4768,6 +4772,154 @@ function Button2({
|
|
|
4768
4772
|
}
|
|
4769
4773
|
);
|
|
4770
4774
|
}
|
|
4775
|
+
|
|
4776
|
+
// src/components/dialog-alert/lib/constants.ts
|
|
4777
|
+
var DIALOG_ALERT_I18N_NAMESPACE = "dialog_alert";
|
|
4778
|
+
|
|
4779
|
+
// src/components/dialog-alert/locale/default.ts
|
|
4780
|
+
var defaultResource = {
|
|
4781
|
+
sharedui: {
|
|
4782
|
+
[DIALOG_ALERT_I18N_NAMESPACE]: {
|
|
4783
|
+
cancel: "Cancel",
|
|
4784
|
+
close: "Close",
|
|
4785
|
+
"success.saved": {
|
|
4786
|
+
title: "Successfully",
|
|
4787
|
+
description: "Data has been successfully saved"
|
|
4788
|
+
},
|
|
4789
|
+
"success.deleted": {
|
|
4790
|
+
title: "Successfully",
|
|
4791
|
+
description: "Data has been successfully deleted"
|
|
4792
|
+
},
|
|
4793
|
+
"success.removed": {
|
|
4794
|
+
title: "Successfully",
|
|
4795
|
+
description: "Data has been successfully removed"
|
|
4796
|
+
},
|
|
4797
|
+
"error.api_db_error": {
|
|
4798
|
+
title: "API/Database Error",
|
|
4799
|
+
description: "Failed to connect to the system. Please check API or database connection."
|
|
4800
|
+
},
|
|
4801
|
+
"error.permission_denied": {
|
|
4802
|
+
title: "Permission Denied",
|
|
4803
|
+
description: "You do not have permission to delete this data.",
|
|
4804
|
+
confirm_text: "Discard"
|
|
4805
|
+
},
|
|
4806
|
+
"error.session_expired": {
|
|
4807
|
+
title: "Session Expired",
|
|
4808
|
+
description: "Your session has expired or you have been logged out. Please sign in again.",
|
|
4809
|
+
confirm_text: "Logout"
|
|
4810
|
+
},
|
|
4811
|
+
"error.user_not_found": {
|
|
4812
|
+
title: "User Not Found",
|
|
4813
|
+
description: "The system could not locate the user account.",
|
|
4814
|
+
confirm_text: "Logout"
|
|
4815
|
+
},
|
|
4816
|
+
"error.data_not_found": {
|
|
4817
|
+
title: "Data Not Found",
|
|
4818
|
+
description: "The data has already been deleted or does not exist in the system."
|
|
4819
|
+
},
|
|
4820
|
+
"error.data_restrict_editing": {
|
|
4821
|
+
title: "Data Status Restricts Editing",
|
|
4822
|
+
description: "Data status does not allow editing."
|
|
4823
|
+
},
|
|
4824
|
+
"error.network_timeout_error": {
|
|
4825
|
+
title: "Network Error / Timeout",
|
|
4826
|
+
description: "The system could not connect to the network or the request took too long to process."
|
|
4827
|
+
},
|
|
4828
|
+
"error.queue_full": {
|
|
4829
|
+
title: "Queue Full",
|
|
4830
|
+
description: "The notification queue has reached its limit. Please try again later."
|
|
4831
|
+
},
|
|
4832
|
+
"error.invalid_data_format": {
|
|
4833
|
+
title: "Invalid Data Format",
|
|
4834
|
+
description: "Data creation failed due to invalid or incorrectly formatted data."
|
|
4835
|
+
},
|
|
4836
|
+
"error.data_linked_to_system_data": {
|
|
4837
|
+
title: "Data Linked to System Data",
|
|
4838
|
+
description: "Cannot delete data because they are linked to existing system data."
|
|
4839
|
+
},
|
|
4840
|
+
"error.pending_workflow_conflict": {
|
|
4841
|
+
title: "Pending Workflow Conflict ",
|
|
4842
|
+
description: "The data is currently involved in a pending workflow or approval process and cannot be deactivated."
|
|
4843
|
+
},
|
|
4844
|
+
"error.invalid_incomplete_data": {
|
|
4845
|
+
title: "Invalid or Incomplete Data",
|
|
4846
|
+
description: "Data status cannot be changed due to incomplete or invalid information."
|
|
4847
|
+
},
|
|
4848
|
+
"error.client_side_error": {
|
|
4849
|
+
title: "Client-Side Error",
|
|
4850
|
+
description: "An error occurred on the client side. Please refresh the page or try again."
|
|
4851
|
+
},
|
|
4852
|
+
"error.system_limitation": {
|
|
4853
|
+
title: "System Limitation",
|
|
4854
|
+
description: "The search cannot be completed due to system limitations. Please simplify your query."
|
|
4855
|
+
},
|
|
4856
|
+
"error.timeout": {
|
|
4857
|
+
title: "Timeout",
|
|
4858
|
+
description: "Request failed due to a system error or timeout. Please try again."
|
|
4859
|
+
},
|
|
4860
|
+
"error.duplicate_data": {
|
|
4861
|
+
title: "Duplicate Data",
|
|
4862
|
+
description: "The data you entered already exists in the system."
|
|
4863
|
+
},
|
|
4864
|
+
"error.something_went_wrong": {
|
|
4865
|
+
title: "Something Went Wrong",
|
|
4866
|
+
description: "An unknown error occurred."
|
|
4867
|
+
},
|
|
4868
|
+
"confirm.delete": {
|
|
4869
|
+
title: "Confirmation",
|
|
4870
|
+
description: "Are you sure you want to delete this item?",
|
|
4871
|
+
confirm_text: "Delete"
|
|
4872
|
+
},
|
|
4873
|
+
"confirm.inactive": {
|
|
4874
|
+
title: "Confirmation",
|
|
4875
|
+
description: "Are you sure you want to inactive this item?",
|
|
4876
|
+
confirm_text: "Inactive"
|
|
4877
|
+
},
|
|
4878
|
+
"confirm.active": {
|
|
4879
|
+
variant: "confirm-green",
|
|
4880
|
+
title: "Confirmation",
|
|
4881
|
+
description: "Are you sure you want to active this item?",
|
|
4882
|
+
confirm_text: "Active"
|
|
4883
|
+
},
|
|
4884
|
+
"confirm.leave_page": {
|
|
4885
|
+
title: "Confirmation",
|
|
4886
|
+
description: "Unsaved changes. Do you want to leave this page?",
|
|
4887
|
+
confirm_text: "Leave"
|
|
4888
|
+
},
|
|
4889
|
+
"confirm.remove": {
|
|
4890
|
+
title: "Confirmation",
|
|
4891
|
+
description: "Are you sure you want to remove this item?",
|
|
4892
|
+
confirm_text: "Remove"
|
|
4893
|
+
},
|
|
4894
|
+
"confirm.logout": {
|
|
4895
|
+
title: "Confirmation",
|
|
4896
|
+
description: "Do you want to log out?",
|
|
4897
|
+
confirm_text: "Logout"
|
|
4898
|
+
}
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
};
|
|
4902
|
+
|
|
4903
|
+
// src/components/dialog-alert/locale/i18n.ts
|
|
4904
|
+
i18n.use(initReactI18next).init({
|
|
4905
|
+
resources: defaultResource,
|
|
4906
|
+
lng: "sharedui",
|
|
4907
|
+
fallbackLng: "sharedui",
|
|
4908
|
+
defaultNS: DIALOG_ALERT_I18N_NAMESPACE,
|
|
4909
|
+
interpolation: {
|
|
4910
|
+
escapeValue: false
|
|
4911
|
+
// react already safes from xss
|
|
4912
|
+
}
|
|
4913
|
+
});
|
|
4914
|
+
var i18n_default = i18n;
|
|
4915
|
+
var titleColorVariant = {
|
|
4916
|
+
default: "",
|
|
4917
|
+
success: "text-green-600",
|
|
4918
|
+
error: "text-red-600",
|
|
4919
|
+
warning: "text-yellow-600",
|
|
4920
|
+
confirm: "text-red-600",
|
|
4921
|
+
"confirm-green": "text-red-600"
|
|
4922
|
+
};
|
|
4771
4923
|
function DialogAlert({
|
|
4772
4924
|
open,
|
|
4773
4925
|
onOpenChange,
|
|
@@ -4775,7 +4927,7 @@ function DialogAlert({
|
|
|
4775
4927
|
description,
|
|
4776
4928
|
variant = "default",
|
|
4777
4929
|
confirmText,
|
|
4778
|
-
cancelText = "
|
|
4930
|
+
cancelText = "cancel",
|
|
4779
4931
|
onConfirm,
|
|
4780
4932
|
onCancel,
|
|
4781
4933
|
showCancel = true,
|
|
@@ -4784,6 +4936,7 @@ function DialogAlert({
|
|
|
4784
4936
|
persistent = false
|
|
4785
4937
|
}) {
|
|
4786
4938
|
const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
|
|
4939
|
+
const { t } = useTranslation(DIALOG_ALERT_I18N_NAMESPACE);
|
|
4787
4940
|
const handleCancel = useCallback(() => {
|
|
4788
4941
|
onCancel?.();
|
|
4789
4942
|
onOpenChange(false);
|
|
@@ -4794,28 +4947,261 @@ function DialogAlert({
|
|
|
4794
4947
|
return /* @__PURE__ */ jsx(Dialog2, { open, onOpenChange: persistent ? () => {
|
|
4795
4948
|
} : onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
|
|
4796
4949
|
/* @__PURE__ */ jsxs(DialogHeader2, { children: [
|
|
4797
|
-
title && /* @__PURE__ */ jsx(DialogTitle2, { className:
|
|
4798
|
-
description && /* @__PURE__ */ jsx(DialogDescription2, { children: description })
|
|
4950
|
+
title && /* @__PURE__ */ jsx(DialogTitle2, { className: titleColorVariant[variant], children: t(title) }),
|
|
4951
|
+
description && /* @__PURE__ */ jsx(DialogDescription2, { children: t(description) })
|
|
4799
4952
|
] }),
|
|
4800
4953
|
outlet && outlet,
|
|
4801
4954
|
/* @__PURE__ */ jsxs("div", { className: `flex gap-3 mt-3 ${alignClass}`, children: [
|
|
4802
|
-
showCancel && /* @__PURE__ */ jsx(Button2, { variant: "cancel", onClick: handleCancel, children: cancelText }),
|
|
4803
|
-
confirmText && /* @__PURE__ */ jsx(Button2, { variant, onClick: handleConfirm, children: confirmText })
|
|
4955
|
+
showCancel && /* @__PURE__ */ jsx(Button2, { variant: "cancel", onClick: handleCancel, children: t(cancelText) }),
|
|
4956
|
+
confirmText && /* @__PURE__ */ jsx(Button2, { variant, onClick: handleConfirm, children: t(confirmText) })
|
|
4804
4957
|
] })
|
|
4805
4958
|
] }) });
|
|
4806
4959
|
}
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4960
|
+
|
|
4961
|
+
// src/components/dialog-alert/templates/index.ts
|
|
4962
|
+
var getDialogTemplates = ({ setOpen = () => {
|
|
4963
|
+
} }) => ({
|
|
4964
|
+
"success.saved": {
|
|
4965
|
+
variant: "success",
|
|
4966
|
+
title: "success.saved.title",
|
|
4967
|
+
description: "success.saved.description",
|
|
4968
|
+
cancelText: "close"
|
|
4969
|
+
},
|
|
4970
|
+
"success.deleted": {
|
|
4971
|
+
variant: "success",
|
|
4972
|
+
title: "success.deleted.title",
|
|
4973
|
+
description: "success.deleted.description",
|
|
4974
|
+
cancelText: "close"
|
|
4975
|
+
},
|
|
4976
|
+
"success.removed": {
|
|
4977
|
+
variant: "success",
|
|
4978
|
+
title: "success.removed.title",
|
|
4979
|
+
description: "success.removed.description",
|
|
4980
|
+
cancelText: "close"
|
|
4981
|
+
},
|
|
4982
|
+
"error.api_db_error": {
|
|
4983
|
+
variant: "error",
|
|
4984
|
+
title: "error.api_db_error.title",
|
|
4985
|
+
description: "error.api_db_error.description",
|
|
4986
|
+
cancelText: "close"
|
|
4987
|
+
},
|
|
4988
|
+
"error.permission_denied": {
|
|
4989
|
+
variant: "error",
|
|
4990
|
+
title: "error.permission_denied.title",
|
|
4991
|
+
description: "error.permission_denied.description",
|
|
4992
|
+
confirmText: "error.permission_denied.confirm_text",
|
|
4993
|
+
showCancel: false,
|
|
4994
|
+
onConfirm: () => setOpen(false)
|
|
4995
|
+
},
|
|
4996
|
+
"error.session_expired": {
|
|
4997
|
+
variant: "error",
|
|
4998
|
+
title: "error.session_expired.title",
|
|
4999
|
+
description: "error.session_expired.description",
|
|
5000
|
+
confirmText: "error.session_expired.confirm_text",
|
|
5001
|
+
showCancel: false
|
|
5002
|
+
},
|
|
5003
|
+
"error.user_not_found": {
|
|
5004
|
+
variant: "error",
|
|
5005
|
+
title: "error.user_not_found.title",
|
|
5006
|
+
description: "error.user_not_found.description",
|
|
5007
|
+
confirmText: "error.user_not_found.confirm_text",
|
|
5008
|
+
showCancel: false
|
|
5009
|
+
},
|
|
5010
|
+
"error.data_not_found": {
|
|
5011
|
+
variant: "error",
|
|
5012
|
+
title: "error.data_not_found.title",
|
|
5013
|
+
description: "error.data_not_found.description",
|
|
5014
|
+
cancelText: "close"
|
|
5015
|
+
},
|
|
5016
|
+
"error.data_restrict_editing": {
|
|
5017
|
+
variant: "error",
|
|
5018
|
+
title: "error.data_restrict_editing.title",
|
|
5019
|
+
description: "error.data_restrict_editing.description",
|
|
5020
|
+
cancelText: "close"
|
|
5021
|
+
},
|
|
5022
|
+
"error.network_timeout_error": {
|
|
5023
|
+
variant: "error",
|
|
5024
|
+
title: "error.network_timeout_error.title",
|
|
5025
|
+
description: "error.network_timeout_error.description",
|
|
5026
|
+
cancelText: "close"
|
|
5027
|
+
},
|
|
5028
|
+
"error.queue_full": {
|
|
5029
|
+
variant: "error",
|
|
5030
|
+
title: "error.queue_full.title",
|
|
5031
|
+
description: "error.queue_full.description",
|
|
5032
|
+
cancelText: "close"
|
|
5033
|
+
},
|
|
5034
|
+
"error.invalid_data_format": {
|
|
5035
|
+
variant: "error",
|
|
5036
|
+
title: "error.invalid_data_format.title",
|
|
5037
|
+
description: "error.invalid_data_format.description",
|
|
5038
|
+
cancelText: "close"
|
|
5039
|
+
},
|
|
5040
|
+
"error.data_linked_to_system_data": {
|
|
5041
|
+
variant: "error",
|
|
5042
|
+
title: "error.data_linked_to_system_data.title",
|
|
5043
|
+
description: "error.data_linked_to_system_data.description",
|
|
5044
|
+
cancelText: "close"
|
|
5045
|
+
},
|
|
5046
|
+
"error.pending_workflow_conflict": {
|
|
5047
|
+
variant: "error",
|
|
5048
|
+
title: "error.pending_workflow_conflict.title",
|
|
5049
|
+
description: "error.pending_workflow_conflict.description",
|
|
5050
|
+
cancelText: "close"
|
|
5051
|
+
},
|
|
5052
|
+
"error.invalid_incomplete_data": {
|
|
5053
|
+
variant: "error",
|
|
5054
|
+
title: "error.invalid_incomplete_data.title",
|
|
5055
|
+
description: "error.invalid_incomplete_data.description",
|
|
5056
|
+
cancelText: "close"
|
|
5057
|
+
},
|
|
5058
|
+
"error.client_side_error": {
|
|
5059
|
+
variant: "error",
|
|
5060
|
+
title: "error.client_side_error.title",
|
|
5061
|
+
description: "error.client_side_error.description",
|
|
5062
|
+
cancelText: "close"
|
|
5063
|
+
},
|
|
5064
|
+
"error.system_limitation": {
|
|
5065
|
+
variant: "error",
|
|
5066
|
+
title: "error.system_limitation.title",
|
|
5067
|
+
description: "error.system_limitation.description",
|
|
5068
|
+
cancelText: "close"
|
|
5069
|
+
},
|
|
5070
|
+
"error.timeout": {
|
|
5071
|
+
variant: "error",
|
|
5072
|
+
title: "error.timeout.title",
|
|
5073
|
+
description: "error.timeout.description",
|
|
5074
|
+
cancelText: "close"
|
|
5075
|
+
},
|
|
5076
|
+
"error.duplicate_data": {
|
|
5077
|
+
variant: "error",
|
|
5078
|
+
title: "error.duplicate_data.title",
|
|
5079
|
+
description: "error.duplicate_data.description",
|
|
5080
|
+
cancelText: "close"
|
|
5081
|
+
},
|
|
5082
|
+
"error.something_went_wrong": {
|
|
5083
|
+
variant: "error",
|
|
5084
|
+
title: "error.something_went_wrong.title",
|
|
5085
|
+
description: "error.something_went_wrong.description",
|
|
5086
|
+
cancelText: "close"
|
|
5087
|
+
},
|
|
5088
|
+
"confirm.delete": {
|
|
5089
|
+
variant: "confirm",
|
|
5090
|
+
title: "confirm.delete.title",
|
|
5091
|
+
description: "confirm.delete.description",
|
|
5092
|
+
confirmText: "confirm.delete.confirm_text"
|
|
5093
|
+
},
|
|
5094
|
+
"confirm.inactive": {
|
|
5095
|
+
variant: "confirm",
|
|
5096
|
+
title: "confirm.inactive.title",
|
|
5097
|
+
description: "confirm.inactive.description",
|
|
5098
|
+
confirmText: "confirm.inactive.confirm_text"
|
|
5099
|
+
},
|
|
5100
|
+
"confirm.active": {
|
|
5101
|
+
variant: "confirm-green",
|
|
5102
|
+
title: "confirm.active.title",
|
|
5103
|
+
description: "confirm.active.description",
|
|
5104
|
+
confirmText: "confirm.active.confirm_text"
|
|
5105
|
+
},
|
|
5106
|
+
"confirm.leave_page": {
|
|
5107
|
+
variant: "confirm",
|
|
5108
|
+
title: "confirm.leave_page.title",
|
|
5109
|
+
description: "confirm.leave_page.description",
|
|
5110
|
+
confirmText: "confirm.leave_page.confirm_text"
|
|
5111
|
+
},
|
|
5112
|
+
"confirm.remove": {
|
|
5113
|
+
variant: "confirm",
|
|
5114
|
+
title: "confirm.remove.title",
|
|
5115
|
+
description: "confirm.remove.description",
|
|
5116
|
+
confirmText: "confirm.remove.confirm_text"
|
|
5117
|
+
},
|
|
5118
|
+
"confirm.logout": {
|
|
5119
|
+
variant: "confirm",
|
|
5120
|
+
title: "confirm.logout.title",
|
|
5121
|
+
description: "confirm.logout.description",
|
|
5122
|
+
confirmText: "confirm.logout.confirm_text"
|
|
4817
5123
|
}
|
|
4818
|
-
}
|
|
5124
|
+
});
|
|
5125
|
+
var useDialogAlertStore = create((set, get) => ({
|
|
5126
|
+
open: false,
|
|
5127
|
+
dialogProps: {},
|
|
5128
|
+
setOpen: (data) => set({ open: data }),
|
|
5129
|
+
setDialogProps: (data) => set({ dialogProps: data }),
|
|
5130
|
+
openDialogAlert: (payload) => {
|
|
5131
|
+
let templateVal;
|
|
5132
|
+
if (payload?.template) {
|
|
5133
|
+
templateVal = getDialogTemplates({ setOpen: get().setOpen })[payload.template];
|
|
5134
|
+
}
|
|
5135
|
+
get().setDialogProps({ ...templateVal, ...payload?.props });
|
|
5136
|
+
get().setOpen(true);
|
|
5137
|
+
},
|
|
5138
|
+
closeDialogAlert: () => {
|
|
5139
|
+
set({ open: false });
|
|
5140
|
+
}
|
|
5141
|
+
}));
|
|
5142
|
+
var DialogAlertProvider = ({ children, i18nResource, i18nLang }) => {
|
|
5143
|
+
const open = useDialogAlertStore((state) => state.open);
|
|
5144
|
+
const setOpen = useDialogAlertStore((state) => state.setOpen);
|
|
5145
|
+
const dialogProps = useDialogAlertStore((state) => state.dialogProps);
|
|
5146
|
+
useEffect(() => {
|
|
5147
|
+
if (!i18nResource) {
|
|
5148
|
+
i18n_default.changeLanguage("sharedui");
|
|
5149
|
+
return;
|
|
5150
|
+
}
|
|
5151
|
+
const langs = Object.keys(i18nResource);
|
|
5152
|
+
for (const lang of langs) {
|
|
5153
|
+
i18n_default.addResourceBundle(
|
|
5154
|
+
lang,
|
|
5155
|
+
DIALOG_ALERT_I18N_NAMESPACE,
|
|
5156
|
+
i18nResource[lang][DIALOG_ALERT_I18N_NAMESPACE],
|
|
5157
|
+
false,
|
|
5158
|
+
true
|
|
5159
|
+
);
|
|
5160
|
+
}
|
|
5161
|
+
i18n_default.changeLanguage(i18nLang);
|
|
5162
|
+
}, [i18nLang, i18nResource]);
|
|
5163
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5164
|
+
children,
|
|
5165
|
+
/* @__PURE__ */ jsx(DialogAlert, { open, onOpenChange: setOpen, ...dialogProps })
|
|
5166
|
+
] });
|
|
5167
|
+
};
|
|
5168
|
+
var openDialogAlert = useDialogAlertStore.getState().openDialogAlert;
|
|
5169
|
+
var closeDialogAlert = useDialogAlertStore.getState().closeDialogAlert;
|
|
5170
|
+
var openErrorDialogAlert = (error) => {
|
|
5171
|
+
if (error instanceof Error) {
|
|
5172
|
+
openDialogAlert({ template: "error.something_went_wrong", props: { description: error.message } });
|
|
5173
|
+
} else if (error.isAxiosError) {
|
|
5174
|
+
let template = "error.something_went_wrong";
|
|
5175
|
+
switch (error.response?.status) {
|
|
5176
|
+
case 400:
|
|
5177
|
+
template = "error.invalid_incomplete_data";
|
|
5178
|
+
break;
|
|
5179
|
+
case 401:
|
|
5180
|
+
template = "error.session_expired";
|
|
5181
|
+
break;
|
|
5182
|
+
case 403:
|
|
5183
|
+
template = "error.permission_denied";
|
|
5184
|
+
break;
|
|
5185
|
+
case 404:
|
|
5186
|
+
template = "error.data_not_found";
|
|
5187
|
+
break;
|
|
5188
|
+
case 409:
|
|
5189
|
+
template = "error.duplicate_data";
|
|
5190
|
+
break;
|
|
5191
|
+
case 500:
|
|
5192
|
+
template = "error.api_db_error";
|
|
5193
|
+
break;
|
|
5194
|
+
}
|
|
5195
|
+
openDialogAlert({ template });
|
|
5196
|
+
} else {
|
|
5197
|
+
openDialogAlert({ template: "error.something_went_wrong" });
|
|
5198
|
+
}
|
|
5199
|
+
};
|
|
5200
|
+
var getDialogAlertControls = () => ({
|
|
5201
|
+
openDialogAlert,
|
|
5202
|
+
closeDialogAlert,
|
|
5203
|
+
openErrorDialogAlert
|
|
5204
|
+
});
|
|
4819
5205
|
function TooltipProvider({
|
|
4820
5206
|
delayDuration = 0,
|
|
4821
5207
|
...props
|
|
@@ -7726,10 +8112,38 @@ async function getCroppedImg(imageSrc, pixelCrop, desiredDimension) {
|
|
|
7726
8112
|
}, "image/png");
|
|
7727
8113
|
});
|
|
7728
8114
|
}
|
|
8115
|
+
async function getCroppedSVG(imageSrc, pixelCrop, desiredDimension) {
|
|
8116
|
+
let svgString;
|
|
8117
|
+
const parts = imageSrc.split(",");
|
|
8118
|
+
const meta = parts[0];
|
|
8119
|
+
const data = parts[1];
|
|
8120
|
+
if (meta.includes("base64")) {
|
|
8121
|
+
svgString = atob(data);
|
|
8122
|
+
} else {
|
|
8123
|
+
svgString = decodeURIComponent(data);
|
|
8124
|
+
}
|
|
8125
|
+
const parser = new DOMParser();
|
|
8126
|
+
const svgDoc = parser.parseFromString(svgString, "image/svg+xml");
|
|
8127
|
+
const svgElement = svgDoc.documentElement;
|
|
8128
|
+
if (svgElement.tagName.toLowerCase() !== "svg") {
|
|
8129
|
+
throw new Error("The file is not a valid SVG document root.");
|
|
8130
|
+
}
|
|
8131
|
+
const newViewBox = `${pixelCrop.x} ${pixelCrop.y} ${pixelCrop.width} ${pixelCrop.height}`;
|
|
8132
|
+
svgElement.setAttribute("viewBox", newViewBox);
|
|
8133
|
+
const outputWidth = desiredDimension?.width ?? pixelCrop.width;
|
|
8134
|
+
const outputHeight = desiredDimension?.height ?? pixelCrop.height;
|
|
8135
|
+
svgElement.setAttribute("width", String(outputWidth));
|
|
8136
|
+
svgElement.setAttribute("height", String(outputHeight));
|
|
8137
|
+
const serializer = new XMLSerializer();
|
|
8138
|
+
const croppedSvgString = serializer.serializeToString(svgElement);
|
|
8139
|
+
const blob = new Blob([croppedSvgString], { type: "image/svg+xml" });
|
|
8140
|
+
return URL.createObjectURL(blob);
|
|
8141
|
+
}
|
|
7729
8142
|
var CropperModal = ({
|
|
7730
8143
|
open,
|
|
7731
8144
|
onOpenChange,
|
|
7732
8145
|
imageSrc,
|
|
8146
|
+
isSVG,
|
|
7733
8147
|
onConfirm,
|
|
7734
8148
|
onCancel,
|
|
7735
8149
|
onError,
|
|
@@ -7771,7 +8185,7 @@ var CropperModal = ({
|
|
|
7771
8185
|
setIsLoading(true);
|
|
7772
8186
|
try {
|
|
7773
8187
|
const desiredDimension = outputExactCropSize ? cropSize : void 0;
|
|
7774
|
-
const croppedImage = await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
|
|
8188
|
+
const croppedImage = isSVG ? await getCroppedSVG(imageSrc, croppedAreaPixels, desiredDimension) : await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
|
|
7775
8189
|
onConfirm({ crop, croppedAreaPixels, croppedImageBlobUrl: croppedImage });
|
|
7776
8190
|
} catch (e) {
|
|
7777
8191
|
if (onError) {
|
|
@@ -7836,7 +8250,7 @@ var CropperModal = ({
|
|
|
7836
8250
|
...props?.cropper
|
|
7837
8251
|
}
|
|
7838
8252
|
) }),
|
|
7839
|
-
/* @__PURE__ */ jsx("div", { className: "w-full py-4 px-8", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between", children: [
|
|
8253
|
+
/* @__PURE__ */ jsx("div", { className: "w-full py-4 px-8 min-h-10", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between", children: [
|
|
7840
8254
|
/* @__PURE__ */ jsx(Button, { type: "button", variant: "cancel", onClick: handleCancel, disabled: isLoading, children: "Cancel" }),
|
|
7841
8255
|
/* @__PURE__ */ jsx("div", { className: "ml-auto flex gap-x-2", children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "default", onClick: handleConfirm, disabled: isLoading, children: "Confirm" }) })
|
|
7842
8256
|
] }) })
|
|
@@ -7847,6 +8261,6 @@ var CropperModal = ({
|
|
|
7847
8261
|
);
|
|
7848
8262
|
};
|
|
7849
8263
|
|
|
7850
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch_default as AdvanceSearch, arrow_default as ArrowIcon, Button, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CropperModal, DataTable_default as DataTable, DatePicker2 as DatePicker, Dialog, DialogAlert, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, Input, Label2 as Label, List_default as List, container_default as ListContainer, header_default as ListHeader, table_default as ListTable, LookupSelect, MonthPicker2 as MonthPicker, navbar_default as Navbar, not_found_default as NotFoundIcon, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave_default as PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, calendar_default as SuiCalendarIcon, check_default as SuiCheckIcon, dots_vertical_default as SuiDotsVerticalIcon, empty_data_default as SuiEmptyDataIcon, expand_default as SuiExpandIcon, filter_default as SuiFilterIcon, setting_default as SuiSettingIcon, triangle_down_default as SuiTriangleDownIcon, warning_default as SuiWarningIcon, Switch, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, ui_exports as UI, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, stripNullishObject, throttle, useFormField, useGridSettingsStore_default as useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useMediaQuery_default as useMediaQuery, usePreventPageLeave_default as usePreventPageLeave, usePreventPageLeaveStore_default as usePreventPageLeaveStore, useScreenSize_default as useScreenSize, useSidebar, useTruncated_default as useTruncated };
|
|
8264
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch_default as AdvanceSearch, arrow_default as ArrowIcon, Button, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CropperModal, DIALOG_ALERT_I18N_NAMESPACE, DataTable_default as DataTable, DatePicker2 as DatePicker, Dialog, DialogAlert, DialogAlertProvider, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, Input, Label2 as Label, List_default as List, container_default as ListContainer, header_default as ListHeader, table_default as ListTable, LookupSelect, MonthPicker2 as MonthPicker, navbar_default as Navbar, not_found_default as NotFoundIcon, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave_default as PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, calendar_default as SuiCalendarIcon, check_default as SuiCheckIcon, dots_vertical_default as SuiDotsVerticalIcon, empty_data_default as SuiEmptyDataIcon, expand_default as SuiExpandIcon, filter_default as SuiFilterIcon, setting_default as SuiSettingIcon, triangle_down_default as SuiTriangleDownIcon, warning_default as SuiWarningIcon, Switch, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, ui_exports as UI, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, getDialogAlertControls, getDialogTemplates, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, stripNullishObject, throttle, useFormField, useGridSettingsStore_default as useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useMediaQuery_default as useMediaQuery, usePreventPageLeave_default as usePreventPageLeave, usePreventPageLeaveStore_default as usePreventPageLeaveStore, useScreenSize_default as useScreenSize, useSidebar, useTruncated_default as useTruncated };
|
|
7851
8265
|
//# sourceMappingURL=index.mjs.map
|
|
7852
8266
|
//# sourceMappingURL=index.mjs.map
|