@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.js
CHANGED
|
@@ -18,6 +18,9 @@ var CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
|
18
18
|
var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
|
|
19
19
|
var reactTable = require('@tanstack/react-table');
|
|
20
20
|
var SheetPrimitive = require('@radix-ui/react-dialog');
|
|
21
|
+
var i18n = require('i18next');
|
|
22
|
+
var reactI18next = require('react-i18next');
|
|
23
|
+
var zustand = require('zustand');
|
|
21
24
|
var zod$1 = require('@hookform/resolvers/zod');
|
|
22
25
|
var sortable = require('@dnd-kit/sortable');
|
|
23
26
|
var utilities = require('@dnd-kit/utilities');
|
|
@@ -25,7 +28,6 @@ var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
|
25
28
|
var core = require('@dnd-kit/core');
|
|
26
29
|
var modifiers = require('@dnd-kit/modifiers');
|
|
27
30
|
var zod = require('zod');
|
|
28
|
-
var zustand = require('zustand');
|
|
29
31
|
var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
|
30
32
|
var lexical = require('lexical');
|
|
31
33
|
var LexicalComposer = require('@lexical/react/LexicalComposer');
|
|
@@ -80,6 +82,7 @@ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitiv
|
|
|
80
82
|
var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
|
|
81
83
|
var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(CollapsiblePrimitive);
|
|
82
84
|
var SheetPrimitive__namespace = /*#__PURE__*/_interopNamespace(SheetPrimitive);
|
|
85
|
+
var i18n__default = /*#__PURE__*/_interopDefault(i18n);
|
|
83
86
|
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
|
|
84
87
|
var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
|
|
85
88
|
var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
|
|
@@ -4760,9 +4763,11 @@ var buttonVariants2 = classVarianceAuthority.cva(
|
|
|
4760
4763
|
variant: {
|
|
4761
4764
|
default: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
|
|
4762
4765
|
success: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
|
|
4763
|
-
error: "border border-[#BB0B0E]
|
|
4766
|
+
error: "border border-[#BB0B0E] text-[#BB0B0E] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
4764
4767
|
warning: "bg-yellow-500 text-black shadow-xs hover:bg-yellow-600 dark:hover:bg-yellow-400",
|
|
4765
|
-
cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50"
|
|
4768
|
+
cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
|
|
4769
|
+
confirm: "border border-[#BB0B0E] text-[#BB0B0E] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
4770
|
+
"confirm-green": "border border-[#379A2A] text-[#379A2A] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground"
|
|
4766
4771
|
},
|
|
4767
4772
|
size: {
|
|
4768
4773
|
default: "h-9 px-4 has-[>svg]:px-3",
|
|
@@ -4804,6 +4809,154 @@ function Button2({
|
|
|
4804
4809
|
}
|
|
4805
4810
|
);
|
|
4806
4811
|
}
|
|
4812
|
+
|
|
4813
|
+
// src/components/dialog-alert/lib/constants.ts
|
|
4814
|
+
var DIALOG_ALERT_I18N_NAMESPACE = "dialog_alert";
|
|
4815
|
+
|
|
4816
|
+
// src/components/dialog-alert/locale/default.ts
|
|
4817
|
+
var defaultResource = {
|
|
4818
|
+
sharedui: {
|
|
4819
|
+
[DIALOG_ALERT_I18N_NAMESPACE]: {
|
|
4820
|
+
cancel: "Cancel",
|
|
4821
|
+
close: "Close",
|
|
4822
|
+
"success.saved": {
|
|
4823
|
+
title: "Successfully",
|
|
4824
|
+
description: "Data has been successfully saved"
|
|
4825
|
+
},
|
|
4826
|
+
"success.deleted": {
|
|
4827
|
+
title: "Successfully",
|
|
4828
|
+
description: "Data has been successfully deleted"
|
|
4829
|
+
},
|
|
4830
|
+
"success.removed": {
|
|
4831
|
+
title: "Successfully",
|
|
4832
|
+
description: "Data has been successfully removed"
|
|
4833
|
+
},
|
|
4834
|
+
"error.api_db_error": {
|
|
4835
|
+
title: "API/Database Error",
|
|
4836
|
+
description: "Failed to connect to the system. Please check API or database connection."
|
|
4837
|
+
},
|
|
4838
|
+
"error.permission_denied": {
|
|
4839
|
+
title: "Permission Denied",
|
|
4840
|
+
description: "You do not have permission to delete this data.",
|
|
4841
|
+
confirm_text: "Discard"
|
|
4842
|
+
},
|
|
4843
|
+
"error.session_expired": {
|
|
4844
|
+
title: "Session Expired",
|
|
4845
|
+
description: "Your session has expired or you have been logged out. Please sign in again.",
|
|
4846
|
+
confirm_text: "Logout"
|
|
4847
|
+
},
|
|
4848
|
+
"error.user_not_found": {
|
|
4849
|
+
title: "User Not Found",
|
|
4850
|
+
description: "The system could not locate the user account.",
|
|
4851
|
+
confirm_text: "Logout"
|
|
4852
|
+
},
|
|
4853
|
+
"error.data_not_found": {
|
|
4854
|
+
title: "Data Not Found",
|
|
4855
|
+
description: "The data has already been deleted or does not exist in the system."
|
|
4856
|
+
},
|
|
4857
|
+
"error.data_restrict_editing": {
|
|
4858
|
+
title: "Data Status Restricts Editing",
|
|
4859
|
+
description: "Data status does not allow editing."
|
|
4860
|
+
},
|
|
4861
|
+
"error.network_timeout_error": {
|
|
4862
|
+
title: "Network Error / Timeout",
|
|
4863
|
+
description: "The system could not connect to the network or the request took too long to process."
|
|
4864
|
+
},
|
|
4865
|
+
"error.queue_full": {
|
|
4866
|
+
title: "Queue Full",
|
|
4867
|
+
description: "The notification queue has reached its limit. Please try again later."
|
|
4868
|
+
},
|
|
4869
|
+
"error.invalid_data_format": {
|
|
4870
|
+
title: "Invalid Data Format",
|
|
4871
|
+
description: "Data creation failed due to invalid or incorrectly formatted data."
|
|
4872
|
+
},
|
|
4873
|
+
"error.data_linked_to_system_data": {
|
|
4874
|
+
title: "Data Linked to System Data",
|
|
4875
|
+
description: "Cannot delete data because they are linked to existing system data."
|
|
4876
|
+
},
|
|
4877
|
+
"error.pending_workflow_conflict": {
|
|
4878
|
+
title: "Pending Workflow Conflict ",
|
|
4879
|
+
description: "The data is currently involved in a pending workflow or approval process and cannot be deactivated."
|
|
4880
|
+
},
|
|
4881
|
+
"error.invalid_incomplete_data": {
|
|
4882
|
+
title: "Invalid or Incomplete Data",
|
|
4883
|
+
description: "Data status cannot be changed due to incomplete or invalid information."
|
|
4884
|
+
},
|
|
4885
|
+
"error.client_side_error": {
|
|
4886
|
+
title: "Client-Side Error",
|
|
4887
|
+
description: "An error occurred on the client side. Please refresh the page or try again."
|
|
4888
|
+
},
|
|
4889
|
+
"error.system_limitation": {
|
|
4890
|
+
title: "System Limitation",
|
|
4891
|
+
description: "The search cannot be completed due to system limitations. Please simplify your query."
|
|
4892
|
+
},
|
|
4893
|
+
"error.timeout": {
|
|
4894
|
+
title: "Timeout",
|
|
4895
|
+
description: "Request failed due to a system error or timeout. Please try again."
|
|
4896
|
+
},
|
|
4897
|
+
"error.duplicate_data": {
|
|
4898
|
+
title: "Duplicate Data",
|
|
4899
|
+
description: "The data you entered already exists in the system."
|
|
4900
|
+
},
|
|
4901
|
+
"error.something_went_wrong": {
|
|
4902
|
+
title: "Something Went Wrong",
|
|
4903
|
+
description: "An unknown error occurred."
|
|
4904
|
+
},
|
|
4905
|
+
"confirm.delete": {
|
|
4906
|
+
title: "Confirmation",
|
|
4907
|
+
description: "Are you sure you want to delete this item?",
|
|
4908
|
+
confirm_text: "Delete"
|
|
4909
|
+
},
|
|
4910
|
+
"confirm.inactive": {
|
|
4911
|
+
title: "Confirmation",
|
|
4912
|
+
description: "Are you sure you want to inactive this item?",
|
|
4913
|
+
confirm_text: "Inactive"
|
|
4914
|
+
},
|
|
4915
|
+
"confirm.active": {
|
|
4916
|
+
variant: "confirm-green",
|
|
4917
|
+
title: "Confirmation",
|
|
4918
|
+
description: "Are you sure you want to active this item?",
|
|
4919
|
+
confirm_text: "Active"
|
|
4920
|
+
},
|
|
4921
|
+
"confirm.leave_page": {
|
|
4922
|
+
title: "Confirmation",
|
|
4923
|
+
description: "Unsaved changes. Do you want to leave this page?",
|
|
4924
|
+
confirm_text: "Leave"
|
|
4925
|
+
},
|
|
4926
|
+
"confirm.remove": {
|
|
4927
|
+
title: "Confirmation",
|
|
4928
|
+
description: "Are you sure you want to remove this item?",
|
|
4929
|
+
confirm_text: "Remove"
|
|
4930
|
+
},
|
|
4931
|
+
"confirm.logout": {
|
|
4932
|
+
title: "Confirmation",
|
|
4933
|
+
description: "Do you want to log out?",
|
|
4934
|
+
confirm_text: "Logout"
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4938
|
+
};
|
|
4939
|
+
|
|
4940
|
+
// src/components/dialog-alert/locale/i18n.ts
|
|
4941
|
+
i18n__default.default.use(reactI18next.initReactI18next).init({
|
|
4942
|
+
resources: defaultResource,
|
|
4943
|
+
lng: "sharedui",
|
|
4944
|
+
fallbackLng: "sharedui",
|
|
4945
|
+
defaultNS: DIALOG_ALERT_I18N_NAMESPACE,
|
|
4946
|
+
interpolation: {
|
|
4947
|
+
escapeValue: false
|
|
4948
|
+
// react already safes from xss
|
|
4949
|
+
}
|
|
4950
|
+
});
|
|
4951
|
+
var i18n_default = i18n__default.default;
|
|
4952
|
+
var titleColorVariant = {
|
|
4953
|
+
default: "",
|
|
4954
|
+
success: "text-green-600",
|
|
4955
|
+
error: "text-red-600",
|
|
4956
|
+
warning: "text-yellow-600",
|
|
4957
|
+
confirm: "text-red-600",
|
|
4958
|
+
"confirm-green": "text-red-600"
|
|
4959
|
+
};
|
|
4807
4960
|
function DialogAlert({
|
|
4808
4961
|
open,
|
|
4809
4962
|
onOpenChange,
|
|
@@ -4811,7 +4964,7 @@ function DialogAlert({
|
|
|
4811
4964
|
description,
|
|
4812
4965
|
variant = "default",
|
|
4813
4966
|
confirmText,
|
|
4814
|
-
cancelText = "
|
|
4967
|
+
cancelText = "cancel",
|
|
4815
4968
|
onConfirm,
|
|
4816
4969
|
onCancel,
|
|
4817
4970
|
showCancel = true,
|
|
@@ -4820,6 +4973,7 @@ function DialogAlert({
|
|
|
4820
4973
|
persistent = false
|
|
4821
4974
|
}) {
|
|
4822
4975
|
const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
|
|
4976
|
+
const { t } = reactI18next.useTranslation(DIALOG_ALERT_I18N_NAMESPACE);
|
|
4823
4977
|
const handleCancel = React4.useCallback(() => {
|
|
4824
4978
|
onCancel?.();
|
|
4825
4979
|
onOpenChange(false);
|
|
@@ -4830,28 +4984,261 @@ function DialogAlert({
|
|
|
4830
4984
|
return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange: persistent ? () => {
|
|
4831
4985
|
} : onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
|
|
4832
4986
|
/* @__PURE__ */ jsxRuntime.jsxs(DialogHeader2, { children: [
|
|
4833
|
-
title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className:
|
|
4834
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: description })
|
|
4987
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: titleColorVariant[variant], children: t(title) }),
|
|
4988
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: t(description) })
|
|
4835
4989
|
] }),
|
|
4836
4990
|
outlet && outlet,
|
|
4837
4991
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex gap-3 mt-3 ${alignClass}`, children: [
|
|
4838
|
-
showCancel && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "cancel", onClick: handleCancel, children: cancelText }),
|
|
4839
|
-
confirmText && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant, onClick: handleConfirm, children: confirmText })
|
|
4992
|
+
showCancel && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "cancel", onClick: handleCancel, children: t(cancelText) }),
|
|
4993
|
+
confirmText && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant, onClick: handleConfirm, children: t(confirmText) })
|
|
4840
4994
|
] })
|
|
4841
4995
|
] }) });
|
|
4842
4996
|
}
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4997
|
+
|
|
4998
|
+
// src/components/dialog-alert/templates/index.ts
|
|
4999
|
+
var getDialogTemplates = ({ setOpen = () => {
|
|
5000
|
+
} }) => ({
|
|
5001
|
+
"success.saved": {
|
|
5002
|
+
variant: "success",
|
|
5003
|
+
title: "success.saved.title",
|
|
5004
|
+
description: "success.saved.description",
|
|
5005
|
+
cancelText: "close"
|
|
5006
|
+
},
|
|
5007
|
+
"success.deleted": {
|
|
5008
|
+
variant: "success",
|
|
5009
|
+
title: "success.deleted.title",
|
|
5010
|
+
description: "success.deleted.description",
|
|
5011
|
+
cancelText: "close"
|
|
5012
|
+
},
|
|
5013
|
+
"success.removed": {
|
|
5014
|
+
variant: "success",
|
|
5015
|
+
title: "success.removed.title",
|
|
5016
|
+
description: "success.removed.description",
|
|
5017
|
+
cancelText: "close"
|
|
5018
|
+
},
|
|
5019
|
+
"error.api_db_error": {
|
|
5020
|
+
variant: "error",
|
|
5021
|
+
title: "error.api_db_error.title",
|
|
5022
|
+
description: "error.api_db_error.description",
|
|
5023
|
+
cancelText: "close"
|
|
5024
|
+
},
|
|
5025
|
+
"error.permission_denied": {
|
|
5026
|
+
variant: "error",
|
|
5027
|
+
title: "error.permission_denied.title",
|
|
5028
|
+
description: "error.permission_denied.description",
|
|
5029
|
+
confirmText: "error.permission_denied.confirm_text",
|
|
5030
|
+
showCancel: false,
|
|
5031
|
+
onConfirm: () => setOpen(false)
|
|
5032
|
+
},
|
|
5033
|
+
"error.session_expired": {
|
|
5034
|
+
variant: "error",
|
|
5035
|
+
title: "error.session_expired.title",
|
|
5036
|
+
description: "error.session_expired.description",
|
|
5037
|
+
confirmText: "error.session_expired.confirm_text",
|
|
5038
|
+
showCancel: false
|
|
5039
|
+
},
|
|
5040
|
+
"error.user_not_found": {
|
|
5041
|
+
variant: "error",
|
|
5042
|
+
title: "error.user_not_found.title",
|
|
5043
|
+
description: "error.user_not_found.description",
|
|
5044
|
+
confirmText: "error.user_not_found.confirm_text",
|
|
5045
|
+
showCancel: false
|
|
5046
|
+
},
|
|
5047
|
+
"error.data_not_found": {
|
|
5048
|
+
variant: "error",
|
|
5049
|
+
title: "error.data_not_found.title",
|
|
5050
|
+
description: "error.data_not_found.description",
|
|
5051
|
+
cancelText: "close"
|
|
5052
|
+
},
|
|
5053
|
+
"error.data_restrict_editing": {
|
|
5054
|
+
variant: "error",
|
|
5055
|
+
title: "error.data_restrict_editing.title",
|
|
5056
|
+
description: "error.data_restrict_editing.description",
|
|
5057
|
+
cancelText: "close"
|
|
5058
|
+
},
|
|
5059
|
+
"error.network_timeout_error": {
|
|
5060
|
+
variant: "error",
|
|
5061
|
+
title: "error.network_timeout_error.title",
|
|
5062
|
+
description: "error.network_timeout_error.description",
|
|
5063
|
+
cancelText: "close"
|
|
5064
|
+
},
|
|
5065
|
+
"error.queue_full": {
|
|
5066
|
+
variant: "error",
|
|
5067
|
+
title: "error.queue_full.title",
|
|
5068
|
+
description: "error.queue_full.description",
|
|
5069
|
+
cancelText: "close"
|
|
5070
|
+
},
|
|
5071
|
+
"error.invalid_data_format": {
|
|
5072
|
+
variant: "error",
|
|
5073
|
+
title: "error.invalid_data_format.title",
|
|
5074
|
+
description: "error.invalid_data_format.description",
|
|
5075
|
+
cancelText: "close"
|
|
5076
|
+
},
|
|
5077
|
+
"error.data_linked_to_system_data": {
|
|
5078
|
+
variant: "error",
|
|
5079
|
+
title: "error.data_linked_to_system_data.title",
|
|
5080
|
+
description: "error.data_linked_to_system_data.description",
|
|
5081
|
+
cancelText: "close"
|
|
5082
|
+
},
|
|
5083
|
+
"error.pending_workflow_conflict": {
|
|
5084
|
+
variant: "error",
|
|
5085
|
+
title: "error.pending_workflow_conflict.title",
|
|
5086
|
+
description: "error.pending_workflow_conflict.description",
|
|
5087
|
+
cancelText: "close"
|
|
5088
|
+
},
|
|
5089
|
+
"error.invalid_incomplete_data": {
|
|
5090
|
+
variant: "error",
|
|
5091
|
+
title: "error.invalid_incomplete_data.title",
|
|
5092
|
+
description: "error.invalid_incomplete_data.description",
|
|
5093
|
+
cancelText: "close"
|
|
5094
|
+
},
|
|
5095
|
+
"error.client_side_error": {
|
|
5096
|
+
variant: "error",
|
|
5097
|
+
title: "error.client_side_error.title",
|
|
5098
|
+
description: "error.client_side_error.description",
|
|
5099
|
+
cancelText: "close"
|
|
5100
|
+
},
|
|
5101
|
+
"error.system_limitation": {
|
|
5102
|
+
variant: "error",
|
|
5103
|
+
title: "error.system_limitation.title",
|
|
5104
|
+
description: "error.system_limitation.description",
|
|
5105
|
+
cancelText: "close"
|
|
5106
|
+
},
|
|
5107
|
+
"error.timeout": {
|
|
5108
|
+
variant: "error",
|
|
5109
|
+
title: "error.timeout.title",
|
|
5110
|
+
description: "error.timeout.description",
|
|
5111
|
+
cancelText: "close"
|
|
5112
|
+
},
|
|
5113
|
+
"error.duplicate_data": {
|
|
5114
|
+
variant: "error",
|
|
5115
|
+
title: "error.duplicate_data.title",
|
|
5116
|
+
description: "error.duplicate_data.description",
|
|
5117
|
+
cancelText: "close"
|
|
5118
|
+
},
|
|
5119
|
+
"error.something_went_wrong": {
|
|
5120
|
+
variant: "error",
|
|
5121
|
+
title: "error.something_went_wrong.title",
|
|
5122
|
+
description: "error.something_went_wrong.description",
|
|
5123
|
+
cancelText: "close"
|
|
5124
|
+
},
|
|
5125
|
+
"confirm.delete": {
|
|
5126
|
+
variant: "confirm",
|
|
5127
|
+
title: "confirm.delete.title",
|
|
5128
|
+
description: "confirm.delete.description",
|
|
5129
|
+
confirmText: "confirm.delete.confirm_text"
|
|
5130
|
+
},
|
|
5131
|
+
"confirm.inactive": {
|
|
5132
|
+
variant: "confirm",
|
|
5133
|
+
title: "confirm.inactive.title",
|
|
5134
|
+
description: "confirm.inactive.description",
|
|
5135
|
+
confirmText: "confirm.inactive.confirm_text"
|
|
5136
|
+
},
|
|
5137
|
+
"confirm.active": {
|
|
5138
|
+
variant: "confirm-green",
|
|
5139
|
+
title: "confirm.active.title",
|
|
5140
|
+
description: "confirm.active.description",
|
|
5141
|
+
confirmText: "confirm.active.confirm_text"
|
|
5142
|
+
},
|
|
5143
|
+
"confirm.leave_page": {
|
|
5144
|
+
variant: "confirm",
|
|
5145
|
+
title: "confirm.leave_page.title",
|
|
5146
|
+
description: "confirm.leave_page.description",
|
|
5147
|
+
confirmText: "confirm.leave_page.confirm_text"
|
|
5148
|
+
},
|
|
5149
|
+
"confirm.remove": {
|
|
5150
|
+
variant: "confirm",
|
|
5151
|
+
title: "confirm.remove.title",
|
|
5152
|
+
description: "confirm.remove.description",
|
|
5153
|
+
confirmText: "confirm.remove.confirm_text"
|
|
5154
|
+
},
|
|
5155
|
+
"confirm.logout": {
|
|
5156
|
+
variant: "confirm",
|
|
5157
|
+
title: "confirm.logout.title",
|
|
5158
|
+
description: "confirm.logout.description",
|
|
5159
|
+
confirmText: "confirm.logout.confirm_text"
|
|
4853
5160
|
}
|
|
4854
|
-
}
|
|
5161
|
+
});
|
|
5162
|
+
var useDialogAlertStore = zustand.create((set, get) => ({
|
|
5163
|
+
open: false,
|
|
5164
|
+
dialogProps: {},
|
|
5165
|
+
setOpen: (data) => set({ open: data }),
|
|
5166
|
+
setDialogProps: (data) => set({ dialogProps: data }),
|
|
5167
|
+
openDialogAlert: (payload) => {
|
|
5168
|
+
let templateVal;
|
|
5169
|
+
if (payload?.template) {
|
|
5170
|
+
templateVal = getDialogTemplates({ setOpen: get().setOpen })[payload.template];
|
|
5171
|
+
}
|
|
5172
|
+
get().setDialogProps({ ...templateVal, ...payload?.props });
|
|
5173
|
+
get().setOpen(true);
|
|
5174
|
+
},
|
|
5175
|
+
closeDialogAlert: () => {
|
|
5176
|
+
set({ open: false });
|
|
5177
|
+
}
|
|
5178
|
+
}));
|
|
5179
|
+
var DialogAlertProvider = ({ children, i18nResource, i18nLang }) => {
|
|
5180
|
+
const open = useDialogAlertStore((state) => state.open);
|
|
5181
|
+
const setOpen = useDialogAlertStore((state) => state.setOpen);
|
|
5182
|
+
const dialogProps = useDialogAlertStore((state) => state.dialogProps);
|
|
5183
|
+
React4.useEffect(() => {
|
|
5184
|
+
if (!i18nResource) {
|
|
5185
|
+
i18n_default.changeLanguage("sharedui");
|
|
5186
|
+
return;
|
|
5187
|
+
}
|
|
5188
|
+
const langs = Object.keys(i18nResource);
|
|
5189
|
+
for (const lang of langs) {
|
|
5190
|
+
i18n_default.addResourceBundle(
|
|
5191
|
+
lang,
|
|
5192
|
+
DIALOG_ALERT_I18N_NAMESPACE,
|
|
5193
|
+
i18nResource[lang][DIALOG_ALERT_I18N_NAMESPACE],
|
|
5194
|
+
false,
|
|
5195
|
+
true
|
|
5196
|
+
);
|
|
5197
|
+
}
|
|
5198
|
+
i18n_default.changeLanguage(i18nLang);
|
|
5199
|
+
}, [i18nLang, i18nResource]);
|
|
5200
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5201
|
+
children,
|
|
5202
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogAlert, { open, onOpenChange: setOpen, ...dialogProps })
|
|
5203
|
+
] });
|
|
5204
|
+
};
|
|
5205
|
+
var openDialogAlert = useDialogAlertStore.getState().openDialogAlert;
|
|
5206
|
+
var closeDialogAlert = useDialogAlertStore.getState().closeDialogAlert;
|
|
5207
|
+
var openErrorDialogAlert = (error) => {
|
|
5208
|
+
if (error instanceof Error) {
|
|
5209
|
+
openDialogAlert({ template: "error.something_went_wrong", props: { description: error.message } });
|
|
5210
|
+
} else if (error.isAxiosError) {
|
|
5211
|
+
let template = "error.something_went_wrong";
|
|
5212
|
+
switch (error.response?.status) {
|
|
5213
|
+
case 400:
|
|
5214
|
+
template = "error.invalid_incomplete_data";
|
|
5215
|
+
break;
|
|
5216
|
+
case 401:
|
|
5217
|
+
template = "error.session_expired";
|
|
5218
|
+
break;
|
|
5219
|
+
case 403:
|
|
5220
|
+
template = "error.permission_denied";
|
|
5221
|
+
break;
|
|
5222
|
+
case 404:
|
|
5223
|
+
template = "error.data_not_found";
|
|
5224
|
+
break;
|
|
5225
|
+
case 409:
|
|
5226
|
+
template = "error.duplicate_data";
|
|
5227
|
+
break;
|
|
5228
|
+
case 500:
|
|
5229
|
+
template = "error.api_db_error";
|
|
5230
|
+
break;
|
|
5231
|
+
}
|
|
5232
|
+
openDialogAlert({ template });
|
|
5233
|
+
} else {
|
|
5234
|
+
openDialogAlert({ template: "error.something_went_wrong" });
|
|
5235
|
+
}
|
|
5236
|
+
};
|
|
5237
|
+
var getDialogAlertControls = () => ({
|
|
5238
|
+
openDialogAlert,
|
|
5239
|
+
closeDialogAlert,
|
|
5240
|
+
openErrorDialogAlert
|
|
5241
|
+
});
|
|
4855
5242
|
function TooltipProvider({
|
|
4856
5243
|
delayDuration = 0,
|
|
4857
5244
|
...props
|
|
@@ -7762,10 +8149,38 @@ async function getCroppedImg(imageSrc, pixelCrop, desiredDimension) {
|
|
|
7762
8149
|
}, "image/png");
|
|
7763
8150
|
});
|
|
7764
8151
|
}
|
|
8152
|
+
async function getCroppedSVG(imageSrc, pixelCrop, desiredDimension) {
|
|
8153
|
+
let svgString;
|
|
8154
|
+
const parts = imageSrc.split(",");
|
|
8155
|
+
const meta = parts[0];
|
|
8156
|
+
const data = parts[1];
|
|
8157
|
+
if (meta.includes("base64")) {
|
|
8158
|
+
svgString = atob(data);
|
|
8159
|
+
} else {
|
|
8160
|
+
svgString = decodeURIComponent(data);
|
|
8161
|
+
}
|
|
8162
|
+
const parser = new DOMParser();
|
|
8163
|
+
const svgDoc = parser.parseFromString(svgString, "image/svg+xml");
|
|
8164
|
+
const svgElement = svgDoc.documentElement;
|
|
8165
|
+
if (svgElement.tagName.toLowerCase() !== "svg") {
|
|
8166
|
+
throw new Error("The file is not a valid SVG document root.");
|
|
8167
|
+
}
|
|
8168
|
+
const newViewBox = `${pixelCrop.x} ${pixelCrop.y} ${pixelCrop.width} ${pixelCrop.height}`;
|
|
8169
|
+
svgElement.setAttribute("viewBox", newViewBox);
|
|
8170
|
+
const outputWidth = desiredDimension?.width ?? pixelCrop.width;
|
|
8171
|
+
const outputHeight = desiredDimension?.height ?? pixelCrop.height;
|
|
8172
|
+
svgElement.setAttribute("width", String(outputWidth));
|
|
8173
|
+
svgElement.setAttribute("height", String(outputHeight));
|
|
8174
|
+
const serializer = new XMLSerializer();
|
|
8175
|
+
const croppedSvgString = serializer.serializeToString(svgElement);
|
|
8176
|
+
const blob = new Blob([croppedSvgString], { type: "image/svg+xml" });
|
|
8177
|
+
return URL.createObjectURL(blob);
|
|
8178
|
+
}
|
|
7765
8179
|
var CropperModal = ({
|
|
7766
8180
|
open,
|
|
7767
8181
|
onOpenChange,
|
|
7768
8182
|
imageSrc,
|
|
8183
|
+
isSVG,
|
|
7769
8184
|
onConfirm,
|
|
7770
8185
|
onCancel,
|
|
7771
8186
|
onError,
|
|
@@ -7807,7 +8222,7 @@ var CropperModal = ({
|
|
|
7807
8222
|
setIsLoading(true);
|
|
7808
8223
|
try {
|
|
7809
8224
|
const desiredDimension = outputExactCropSize ? cropSize : void 0;
|
|
7810
|
-
const croppedImage = await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
|
|
8225
|
+
const croppedImage = isSVG ? await getCroppedSVG(imageSrc, croppedAreaPixels, desiredDimension) : await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
|
|
7811
8226
|
onConfirm({ crop, croppedAreaPixels, croppedImageBlobUrl: croppedImage });
|
|
7812
8227
|
} catch (e) {
|
|
7813
8228
|
if (onError) {
|
|
@@ -7872,7 +8287,7 @@ var CropperModal = ({
|
|
|
7872
8287
|
...props?.cropper
|
|
7873
8288
|
}
|
|
7874
8289
|
) }),
|
|
7875
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full py-4 px-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full justify-between", children: [
|
|
8290
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full py-4 px-8 min-h-10", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full justify-between", children: [
|
|
7876
8291
|
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "cancel", onClick: handleCancel, disabled: isLoading, children: "Cancel" }),
|
|
7877
8292
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex gap-x-2", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "default", onClick: handleConfirm, disabled: isLoading, children: "Confirm" }) })
|
|
7878
8293
|
] }) })
|
|
@@ -7895,10 +8310,12 @@ exports.Collapsible = Collapsible;
|
|
|
7895
8310
|
exports.CollapsibleContent = CollapsibleContent2;
|
|
7896
8311
|
exports.CollapsibleTrigger = CollapsibleTrigger2;
|
|
7897
8312
|
exports.CropperModal = CropperModal;
|
|
8313
|
+
exports.DIALOG_ALERT_I18N_NAMESPACE = DIALOG_ALERT_I18N_NAMESPACE;
|
|
7898
8314
|
exports.DataTable = DataTable_default;
|
|
7899
8315
|
exports.DatePicker = DatePicker2;
|
|
7900
8316
|
exports.Dialog = Dialog;
|
|
7901
8317
|
exports.DialogAlert = DialogAlert;
|
|
8318
|
+
exports.DialogAlertProvider = DialogAlertProvider;
|
|
7902
8319
|
exports.DialogContent = DialogContent;
|
|
7903
8320
|
exports.DialogDescription = DialogDescription;
|
|
7904
8321
|
exports.DialogFooter = DialogFooter;
|
|
@@ -7999,6 +8416,8 @@ exports.buttonVariants = buttonVariants;
|
|
|
7999
8416
|
exports.cn = cn;
|
|
8000
8417
|
exports.compareAlphanumeric = compareAlphanumeric;
|
|
8001
8418
|
exports.debounce = debounce;
|
|
8419
|
+
exports.getDialogAlertControls = getDialogAlertControls;
|
|
8420
|
+
exports.getDialogTemplates = getDialogTemplates;
|
|
8002
8421
|
exports.inputVariants = inputVariants;
|
|
8003
8422
|
exports.isDefined = isDefined;
|
|
8004
8423
|
exports.isEmptyObject = isEmptyObject;
|