@sustaina/shared-ui 1.12.0 → 1.13.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/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);
@@ -638,7 +641,7 @@ var OPERATOR_MAP = {
638
641
  dropdown: ["is", "isNot"],
639
642
  lookup: ["containsAny", "containsOnly", "containsAll", "notContains"],
640
643
  uuid: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
641
- json: ["contains", "equals", "beginsWith", "endsWith"]
644
+ json: ["equals", "notEquals", "containsAny"]
642
645
  };
643
646
 
644
647
  // src/components/advanceSearch/hooks/useAdvanceSearch.ts
@@ -2472,6 +2475,7 @@ var LookupSelect = ({
2472
2475
  dropdownPortalId
2473
2476
  }) => {
2474
2477
  const [inputValue, setInputValue] = React4.useState("");
2478
+ const inputRef = React4.useRef(null);
2475
2479
  const [suggestions, setSuggestions] = React4.useState([]);
2476
2480
  const [optionLabels, setOptionLabels] = React4.useState({});
2477
2481
  const [loading, setLoading] = React4.useState(false);
@@ -2550,6 +2554,10 @@ var LookupSelect = ({
2550
2554
  (option) => {
2551
2555
  upsertOptionLabels([option]);
2552
2556
  addTag(option.value);
2557
+ inputRef.current?.focus();
2558
+ setTimeout(() => {
2559
+ inputRef.current?.scrollIntoView({ behavior: "smooth" });
2560
+ }, 100);
2553
2561
  },
2554
2562
  [addTag, upsertOptionLabels]
2555
2563
  );
@@ -2691,9 +2699,10 @@ var LookupSelect = ({
2691
2699
  `${tag}-${i}`
2692
2700
  );
2693
2701
  }),
2694
- /* @__PURE__ */ jsxRuntime.jsx(
2702
+ !limitReached && /* @__PURE__ */ jsxRuntime.jsx(
2695
2703
  "input",
2696
2704
  {
2705
+ ref: inputRef,
2697
2706
  type: "text",
2698
2707
  value: inputValue,
2699
2708
  onChange: (e) => setInputValue(e.target.value),
@@ -2709,7 +2718,7 @@ var LookupSelect = ({
2709
2718
  }
2710
2719
  )
2711
2720
  ] }),
2712
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end absolute inset-y-1 right-2 items-center gap-2 pointer-events-auto", children: value.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-7 w-7 items-center justify-center text-inherit", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsxRuntime.jsx(
2721
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end items-center gap-2 pointer-events-auto h-fit", children: value.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-7 w-7 items-center justify-center text-inherit", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsxRuntime.jsx(
2713
2722
  ClearButton,
2714
2723
  {
2715
2724
  onClick: handleClear,
@@ -2722,7 +2731,7 @@ var LookupSelect = ({
2722
2731
  ),
2723
2732
  renderDropdown(),
2724
2733
  fetchError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-red-600", children: fetchError }),
2725
- limitReached && !fetchError && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs text-inherit", children: [
2734
+ limitReached && !fetchError && maxTags !== 1 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs text-inherit", children: [
2726
2735
  "Maximum ",
2727
2736
  maxTags,
2728
2737
  " tags reached."
@@ -2772,6 +2781,58 @@ var ConditionLookupInput = ({
2772
2781
  }
2773
2782
  }
2774
2783
  );
2784
+ var ConditionJSONInput = ({
2785
+ row,
2786
+ control,
2787
+ onClear,
2788
+ fieldSchema,
2789
+ dropdownPortalId
2790
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
2791
+ FormField,
2792
+ {
2793
+ control,
2794
+ name: `value_${row.id}`,
2795
+ rules: { required: "This field is required." },
2796
+ render: ({ field, fieldState }) => {
2797
+ const value = Array.isArray(field.value) ? field.value : [];
2798
+ const handleChange = (tags) => {
2799
+ field.onChange(tags);
2800
+ };
2801
+ const handleClear = () => {
2802
+ field.onChange([]);
2803
+ onClear("value");
2804
+ };
2805
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "relative w-full overflow-x-hidden", children: [
2806
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: fieldSchema?.fetchSuggestions ? /* @__PURE__ */ jsxRuntime.jsx(
2807
+ LookupSelect,
2808
+ {
2809
+ value,
2810
+ onChange: handleChange,
2811
+ onClear: handleClear,
2812
+ error: Boolean(fieldState.error),
2813
+ placeholder: fieldSchema?.placeholder,
2814
+ maxTags: row.operator === "containsAny" ? fieldSchema?.maxTags : 1,
2815
+ fetchSuggestions: fieldSchema?.fetchSuggestions,
2816
+ suggestionDebounce: fieldSchema?.suggestionDebounce,
2817
+ noOptionsMessage: fieldSchema?.noOptionsMessage,
2818
+ loadingMessage: fieldSchema?.loadingMessage,
2819
+ dropdownPortalId
2820
+ }
2821
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
2822
+ Input,
2823
+ {
2824
+ ...field,
2825
+ value: field.value ?? "",
2826
+ autoComplete: "off",
2827
+ inputMode: "text",
2828
+ className: "w-full h-9 rounded-md bg-white pr-8 text-sm text-gray-700 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"
2829
+ }
2830
+ ) }),
2831
+ /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
2832
+ ] });
2833
+ }
2834
+ }
2835
+ );
2775
2836
  var ConditionValue = ({ row, fields, onClearValue, dropdownPortalId }) => {
2776
2837
  const { control } = reactHookForm.useFormContext();
2777
2838
  const fieldSchema = fields.find((f) => f.name === row.fieldName);
@@ -2807,6 +2868,18 @@ var ConditionValue = ({ row, fields, onClearValue, dropdownPortalId }) => {
2807
2868
  dropdownPortalId
2808
2869
  }
2809
2870
  );
2871
+ case "json": {
2872
+ return /* @__PURE__ */ jsxRuntime.jsx(
2873
+ ConditionJSONInput,
2874
+ {
2875
+ row,
2876
+ control,
2877
+ onClear: onClearValue,
2878
+ fieldSchema,
2879
+ dropdownPortalId
2880
+ }
2881
+ );
2882
+ }
2810
2883
  default:
2811
2884
  return /* @__PURE__ */ jsxRuntime.jsx(ConditionTextInput, { row, control, onClear: onClearValue });
2812
2885
  }
@@ -3022,23 +3095,20 @@ var DropdownBuilder = class {
3022
3095
  // src/components/advanceSearch/builder/json.ts
3023
3096
  var JSONBuilder = class {
3024
3097
  build(row) {
3098
+ const isArray = Array.isArray(row.value);
3025
3099
  switch (row.operator) {
3026
- case "contains":
3027
- return { [row.fieldName]: { path: row.jsonPath, string_contains: row.value } };
3028
3100
  case "equals":
3029
- return { [row.fieldName]: { path: row.jsonPath, equals: row.value } };
3030
- case "beginsWith":
3031
- return { [row.fieldName]: { path: row.jsonPath, string_starts_with: row.value } };
3032
- case "endsWith":
3033
- return { [row.fieldName]: { path: row.jsonPath, string_ends_with: row.value } };
3034
- case "notContains":
3035
- return { [row.fieldName]: { path: row.jsonPath, not: { string_contains: row.value } } };
3101
+ return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
3036
3102
  case "notEquals":
3037
- return { [row.fieldName]: { path: row.jsonPath, not: { equals: row.value } } };
3038
- case "notBeginsWith":
3039
- return { [row.fieldName]: { path: row.jsonPath, not: { string_starts_with: row.value } } };
3040
- case "notEndsWith":
3041
- return { [row.fieldName]: { path: row.jsonPath, not: { string_ends_with: row.value } } };
3103
+ return {
3104
+ NOT: { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } }
3105
+ };
3106
+ case "containsAny":
3107
+ if (!isArray)
3108
+ return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
3109
+ return {
3110
+ OR: row.value.map((v) => ({ [row.fieldName]: { path: row.jsonPath, equals: v } }))
3111
+ };
3042
3112
  default:
3043
3113
  return {};
3044
3114
  }
@@ -4760,9 +4830,11 @@ var buttonVariants2 = classVarianceAuthority.cva(
4760
4830
  variant: {
4761
4831
  default: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
4762
4832
  success: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
4763
- error: "border border-[#BB0B0E] bg-[#BB0B0E] shadow-xs hover:bg-accent hover:text-accent-foreground text-white",
4833
+ error: "border border-[#BB0B0E] text-[#BB0B0E] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground",
4764
4834
  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"
4835
+ cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
4836
+ confirm: "border border-[#BB0B0E] text-[#BB0B0E] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground",
4837
+ "confirm-green": "border border-[#379A2A] text-[#379A2A] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground"
4766
4838
  },
4767
4839
  size: {
4768
4840
  default: "h-9 px-4 has-[>svg]:px-3",
@@ -4804,6 +4876,154 @@ function Button2({
4804
4876
  }
4805
4877
  );
4806
4878
  }
4879
+
4880
+ // src/components/dialog-alert/lib/constants.ts
4881
+ var DIALOG_ALERT_I18N_NAMESPACE = "dialog_alert";
4882
+
4883
+ // src/components/dialog-alert/locale/default.ts
4884
+ var defaultResource = {
4885
+ sharedui: {
4886
+ [DIALOG_ALERT_I18N_NAMESPACE]: {
4887
+ cancel: "Cancel",
4888
+ close: "Close",
4889
+ "success.saved": {
4890
+ title: "Successfully",
4891
+ description: "Data has been successfully saved"
4892
+ },
4893
+ "success.deleted": {
4894
+ title: "Successfully",
4895
+ description: "Data has been successfully deleted"
4896
+ },
4897
+ "success.removed": {
4898
+ title: "Successfully",
4899
+ description: "Data has been successfully removed"
4900
+ },
4901
+ "error.api_db_error": {
4902
+ title: "API/Database Error",
4903
+ description: "Failed to connect to the system. Please check API or database connection."
4904
+ },
4905
+ "error.permission_denied": {
4906
+ title: "Permission Denied",
4907
+ description: "You do not have permission to delete this data.",
4908
+ confirm_text: "Discard"
4909
+ },
4910
+ "error.session_expired": {
4911
+ title: "Session Expired",
4912
+ description: "Your session has expired or you have been logged out. Please sign in again.",
4913
+ confirm_text: "Logout"
4914
+ },
4915
+ "error.user_not_found": {
4916
+ title: "User Not Found",
4917
+ description: "The system could not locate the user account.",
4918
+ confirm_text: "Logout"
4919
+ },
4920
+ "error.data_not_found": {
4921
+ title: "Data Not Found",
4922
+ description: "The data has already been deleted or does not exist in the system."
4923
+ },
4924
+ "error.data_restrict_editing": {
4925
+ title: "Data Status Restricts Editing",
4926
+ description: "Data status does not allow editing."
4927
+ },
4928
+ "error.network_timeout_error": {
4929
+ title: "Network Error / Timeout",
4930
+ description: "The system could not connect to the network or the request took too long to process."
4931
+ },
4932
+ "error.queue_full": {
4933
+ title: "Queue Full",
4934
+ description: "The notification queue has reached its limit. Please try again later."
4935
+ },
4936
+ "error.invalid_data_format": {
4937
+ title: "Invalid Data Format",
4938
+ description: "Data creation failed due to invalid or incorrectly formatted data."
4939
+ },
4940
+ "error.data_linked_to_system_data": {
4941
+ title: "Data Linked to System Data",
4942
+ description: "Cannot delete data because they are linked to existing system data."
4943
+ },
4944
+ "error.pending_workflow_conflict": {
4945
+ title: "Pending Workflow Conflict ",
4946
+ description: "The data is currently involved in a pending workflow or approval process and cannot be deactivated."
4947
+ },
4948
+ "error.invalid_incomplete_data": {
4949
+ title: "Invalid or Incomplete Data",
4950
+ description: "Data status cannot be changed due to incomplete or invalid information."
4951
+ },
4952
+ "error.client_side_error": {
4953
+ title: "Client-Side Error",
4954
+ description: "An error occurred on the client side. Please refresh the page or try again."
4955
+ },
4956
+ "error.system_limitation": {
4957
+ title: "System Limitation",
4958
+ description: "The search cannot be completed due to system limitations. Please simplify your query."
4959
+ },
4960
+ "error.timeout": {
4961
+ title: "Timeout",
4962
+ description: "Request failed due to a system error or timeout. Please try again."
4963
+ },
4964
+ "error.duplicate_data": {
4965
+ title: "Duplicate Data",
4966
+ description: "The data you entered already exists in the system."
4967
+ },
4968
+ "error.something_went_wrong": {
4969
+ title: "Something Went Wrong",
4970
+ description: "An unknown error occurred."
4971
+ },
4972
+ "confirm.delete": {
4973
+ title: "Confirmation",
4974
+ description: "Are you sure you want to delete this item?",
4975
+ confirm_text: "Delete"
4976
+ },
4977
+ "confirm.inactive": {
4978
+ title: "Confirmation",
4979
+ description: "Are you sure you want to inactive this item?",
4980
+ confirm_text: "Inactive"
4981
+ },
4982
+ "confirm.active": {
4983
+ variant: "confirm-green",
4984
+ title: "Confirmation",
4985
+ description: "Are you sure you want to active this item?",
4986
+ confirm_text: "Active"
4987
+ },
4988
+ "confirm.leave_page": {
4989
+ title: "Confirmation",
4990
+ description: "Unsaved changes. Do you want to leave this page?",
4991
+ confirm_text: "Leave"
4992
+ },
4993
+ "confirm.remove": {
4994
+ title: "Confirmation",
4995
+ description: "Are you sure you want to remove this item?",
4996
+ confirm_text: "Remove"
4997
+ },
4998
+ "confirm.logout": {
4999
+ title: "Confirmation",
5000
+ description: "Do you want to log out?",
5001
+ confirm_text: "Logout"
5002
+ }
5003
+ }
5004
+ }
5005
+ };
5006
+
5007
+ // src/components/dialog-alert/locale/i18n.ts
5008
+ i18n__default.default.use(reactI18next.initReactI18next).init({
5009
+ resources: defaultResource,
5010
+ lng: "sharedui",
5011
+ fallbackLng: "sharedui",
5012
+ defaultNS: DIALOG_ALERT_I18N_NAMESPACE,
5013
+ interpolation: {
5014
+ escapeValue: false
5015
+ // react already safes from xss
5016
+ }
5017
+ });
5018
+ var i18n_default = i18n__default.default;
5019
+ var titleColorVariant = {
5020
+ default: "",
5021
+ success: "text-green-600",
5022
+ error: "text-red-600",
5023
+ warning: "text-yellow-600",
5024
+ confirm: "text-red-600",
5025
+ "confirm-green": "text-red-600"
5026
+ };
4807
5027
  function DialogAlert({
4808
5028
  open,
4809
5029
  onOpenChange,
@@ -4811,7 +5031,7 @@ function DialogAlert({
4811
5031
  description,
4812
5032
  variant = "default",
4813
5033
  confirmText,
4814
- cancelText = "Cancel",
5034
+ cancelText = "cancel",
4815
5035
  onConfirm,
4816
5036
  onCancel,
4817
5037
  showCancel = true,
@@ -4820,6 +5040,7 @@ function DialogAlert({
4820
5040
  persistent = false
4821
5041
  }) {
4822
5042
  const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
5043
+ const { t } = reactI18next.useTranslation(DIALOG_ALERT_I18N_NAMESPACE);
4823
5044
  const handleCancel = React4.useCallback(() => {
4824
5045
  onCancel?.();
4825
5046
  onOpenChange(false);
@@ -4830,28 +5051,261 @@ function DialogAlert({
4830
5051
  return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange: persistent ? () => {
4831
5052
  } : onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
4832
5053
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader2, { children: [
4833
- title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: variantClass(variant), children: title }),
4834
- description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: description })
5054
+ title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: titleColorVariant[variant], children: t(title) }),
5055
+ description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: t(description) })
4835
5056
  ] }),
4836
5057
  outlet && outlet,
4837
5058
  /* @__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 })
5059
+ showCancel && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "cancel", onClick: handleCancel, children: t(cancelText) }),
5060
+ confirmText && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant, onClick: handleConfirm, children: t(confirmText) })
4840
5061
  ] })
4841
5062
  ] }) });
4842
5063
  }
4843
- function variantClass(variant) {
4844
- switch (variant) {
4845
- case "success":
4846
- return "text-green-600";
4847
- case "error":
4848
- return "text-red-600";
4849
- case "warning":
4850
- return "text-yellow-600";
4851
- default:
4852
- return "";
5064
+
5065
+ // src/components/dialog-alert/templates/index.ts
5066
+ var getDialogTemplates = ({ setOpen = () => {
5067
+ } }) => ({
5068
+ "success.saved": {
5069
+ variant: "success",
5070
+ title: "success.saved.title",
5071
+ description: "success.saved.description",
5072
+ cancelText: "close"
5073
+ },
5074
+ "success.deleted": {
5075
+ variant: "success",
5076
+ title: "success.deleted.title",
5077
+ description: "success.deleted.description",
5078
+ cancelText: "close"
5079
+ },
5080
+ "success.removed": {
5081
+ variant: "success",
5082
+ title: "success.removed.title",
5083
+ description: "success.removed.description",
5084
+ cancelText: "close"
5085
+ },
5086
+ "error.api_db_error": {
5087
+ variant: "error",
5088
+ title: "error.api_db_error.title",
5089
+ description: "error.api_db_error.description",
5090
+ cancelText: "close"
5091
+ },
5092
+ "error.permission_denied": {
5093
+ variant: "error",
5094
+ title: "error.permission_denied.title",
5095
+ description: "error.permission_denied.description",
5096
+ confirmText: "error.permission_denied.confirm_text",
5097
+ showCancel: false,
5098
+ onConfirm: () => setOpen(false)
5099
+ },
5100
+ "error.session_expired": {
5101
+ variant: "error",
5102
+ title: "error.session_expired.title",
5103
+ description: "error.session_expired.description",
5104
+ confirmText: "error.session_expired.confirm_text",
5105
+ showCancel: false
5106
+ },
5107
+ "error.user_not_found": {
5108
+ variant: "error",
5109
+ title: "error.user_not_found.title",
5110
+ description: "error.user_not_found.description",
5111
+ confirmText: "error.user_not_found.confirm_text",
5112
+ showCancel: false
5113
+ },
5114
+ "error.data_not_found": {
5115
+ variant: "error",
5116
+ title: "error.data_not_found.title",
5117
+ description: "error.data_not_found.description",
5118
+ cancelText: "close"
5119
+ },
5120
+ "error.data_restrict_editing": {
5121
+ variant: "error",
5122
+ title: "error.data_restrict_editing.title",
5123
+ description: "error.data_restrict_editing.description",
5124
+ cancelText: "close"
5125
+ },
5126
+ "error.network_timeout_error": {
5127
+ variant: "error",
5128
+ title: "error.network_timeout_error.title",
5129
+ description: "error.network_timeout_error.description",
5130
+ cancelText: "close"
5131
+ },
5132
+ "error.queue_full": {
5133
+ variant: "error",
5134
+ title: "error.queue_full.title",
5135
+ description: "error.queue_full.description",
5136
+ cancelText: "close"
5137
+ },
5138
+ "error.invalid_data_format": {
5139
+ variant: "error",
5140
+ title: "error.invalid_data_format.title",
5141
+ description: "error.invalid_data_format.description",
5142
+ cancelText: "close"
5143
+ },
5144
+ "error.data_linked_to_system_data": {
5145
+ variant: "error",
5146
+ title: "error.data_linked_to_system_data.title",
5147
+ description: "error.data_linked_to_system_data.description",
5148
+ cancelText: "close"
5149
+ },
5150
+ "error.pending_workflow_conflict": {
5151
+ variant: "error",
5152
+ title: "error.pending_workflow_conflict.title",
5153
+ description: "error.pending_workflow_conflict.description",
5154
+ cancelText: "close"
5155
+ },
5156
+ "error.invalid_incomplete_data": {
5157
+ variant: "error",
5158
+ title: "error.invalid_incomplete_data.title",
5159
+ description: "error.invalid_incomplete_data.description",
5160
+ cancelText: "close"
5161
+ },
5162
+ "error.client_side_error": {
5163
+ variant: "error",
5164
+ title: "error.client_side_error.title",
5165
+ description: "error.client_side_error.description",
5166
+ cancelText: "close"
5167
+ },
5168
+ "error.system_limitation": {
5169
+ variant: "error",
5170
+ title: "error.system_limitation.title",
5171
+ description: "error.system_limitation.description",
5172
+ cancelText: "close"
5173
+ },
5174
+ "error.timeout": {
5175
+ variant: "error",
5176
+ title: "error.timeout.title",
5177
+ description: "error.timeout.description",
5178
+ cancelText: "close"
5179
+ },
5180
+ "error.duplicate_data": {
5181
+ variant: "error",
5182
+ title: "error.duplicate_data.title",
5183
+ description: "error.duplicate_data.description",
5184
+ cancelText: "close"
5185
+ },
5186
+ "error.something_went_wrong": {
5187
+ variant: "error",
5188
+ title: "error.something_went_wrong.title",
5189
+ description: "error.something_went_wrong.description",
5190
+ cancelText: "close"
5191
+ },
5192
+ "confirm.delete": {
5193
+ variant: "confirm",
5194
+ title: "confirm.delete.title",
5195
+ description: "confirm.delete.description",
5196
+ confirmText: "confirm.delete.confirm_text"
5197
+ },
5198
+ "confirm.inactive": {
5199
+ variant: "confirm",
5200
+ title: "confirm.inactive.title",
5201
+ description: "confirm.inactive.description",
5202
+ confirmText: "confirm.inactive.confirm_text"
5203
+ },
5204
+ "confirm.active": {
5205
+ variant: "confirm-green",
5206
+ title: "confirm.active.title",
5207
+ description: "confirm.active.description",
5208
+ confirmText: "confirm.active.confirm_text"
5209
+ },
5210
+ "confirm.leave_page": {
5211
+ variant: "confirm",
5212
+ title: "confirm.leave_page.title",
5213
+ description: "confirm.leave_page.description",
5214
+ confirmText: "confirm.leave_page.confirm_text"
5215
+ },
5216
+ "confirm.remove": {
5217
+ variant: "confirm",
5218
+ title: "confirm.remove.title",
5219
+ description: "confirm.remove.description",
5220
+ confirmText: "confirm.remove.confirm_text"
5221
+ },
5222
+ "confirm.logout": {
5223
+ variant: "confirm",
5224
+ title: "confirm.logout.title",
5225
+ description: "confirm.logout.description",
5226
+ confirmText: "confirm.logout.confirm_text"
4853
5227
  }
4854
- }
5228
+ });
5229
+ var useDialogAlertStore = zustand.create((set, get) => ({
5230
+ open: false,
5231
+ dialogProps: {},
5232
+ setOpen: (data) => set({ open: data }),
5233
+ setDialogProps: (data) => set({ dialogProps: data }),
5234
+ openDialogAlert: (payload) => {
5235
+ let templateVal;
5236
+ if (payload?.template) {
5237
+ templateVal = getDialogTemplates({ setOpen: get().setOpen })[payload.template];
5238
+ }
5239
+ get().setDialogProps({ ...templateVal, ...payload?.props });
5240
+ get().setOpen(true);
5241
+ },
5242
+ closeDialogAlert: () => {
5243
+ set({ open: false });
5244
+ }
5245
+ }));
5246
+ var DialogAlertProvider = ({ children, i18nResource, i18nLang }) => {
5247
+ const open = useDialogAlertStore((state) => state.open);
5248
+ const setOpen = useDialogAlertStore((state) => state.setOpen);
5249
+ const dialogProps = useDialogAlertStore((state) => state.dialogProps);
5250
+ React4.useEffect(() => {
5251
+ if (!i18nResource) {
5252
+ i18n_default.changeLanguage("sharedui");
5253
+ return;
5254
+ }
5255
+ const langs = Object.keys(i18nResource);
5256
+ for (const lang of langs) {
5257
+ i18n_default.addResourceBundle(
5258
+ lang,
5259
+ DIALOG_ALERT_I18N_NAMESPACE,
5260
+ i18nResource[lang][DIALOG_ALERT_I18N_NAMESPACE],
5261
+ false,
5262
+ true
5263
+ );
5264
+ }
5265
+ i18n_default.changeLanguage(i18nLang);
5266
+ }, [i18nLang, i18nResource]);
5267
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5268
+ children,
5269
+ /* @__PURE__ */ jsxRuntime.jsx(DialogAlert, { open, onOpenChange: setOpen, ...dialogProps })
5270
+ ] });
5271
+ };
5272
+ var openDialogAlert = useDialogAlertStore.getState().openDialogAlert;
5273
+ var closeDialogAlert = useDialogAlertStore.getState().closeDialogAlert;
5274
+ var openErrorDialogAlert = (error) => {
5275
+ if (error instanceof Error) {
5276
+ openDialogAlert({ template: "error.something_went_wrong", props: { description: error.message } });
5277
+ } else if (error.isAxiosError) {
5278
+ let template = "error.something_went_wrong";
5279
+ switch (error.response?.status) {
5280
+ case 400:
5281
+ template = "error.invalid_incomplete_data";
5282
+ break;
5283
+ case 401:
5284
+ template = "error.session_expired";
5285
+ break;
5286
+ case 403:
5287
+ template = "error.permission_denied";
5288
+ break;
5289
+ case 404:
5290
+ template = "error.data_not_found";
5291
+ break;
5292
+ case 409:
5293
+ template = "error.duplicate_data";
5294
+ break;
5295
+ case 500:
5296
+ template = "error.api_db_error";
5297
+ break;
5298
+ }
5299
+ openDialogAlert({ template });
5300
+ } else {
5301
+ openDialogAlert({ template: "error.something_went_wrong" });
5302
+ }
5303
+ };
5304
+ var getDialogAlertControls = () => ({
5305
+ openDialogAlert,
5306
+ closeDialogAlert,
5307
+ openErrorDialogAlert
5308
+ });
4855
5309
  function TooltipProvider({
4856
5310
  delayDuration = 0,
4857
5311
  ...props
@@ -5368,9 +5822,9 @@ var InfoIcon = (props) => {
5368
5822
  {
5369
5823
  d: "M10.0013 18.3327C14.6037 18.3327 18.3346 14.6017 18.3346 9.99935C18.3346 5.39698 14.6037 1.66602 10.0013 1.66602C5.39893 1.66602 1.66797 5.39698 1.66797 9.99935C1.66797 14.6017 5.39893 18.3327 10.0013 18.3327Z",
5370
5824
  stroke: "white",
5371
- "stroke-width": "1.5",
5372
- "stroke-linecap": "round",
5373
- "stroke-linejoin": "round"
5825
+ strokeWidth: "1.5",
5826
+ strokeLinecap: "round",
5827
+ strokeLinejoin: "round"
5374
5828
  }
5375
5829
  ),
5376
5830
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5378,9 +5832,9 @@ var InfoIcon = (props) => {
5378
5832
  {
5379
5833
  d: "M10 13.3333V10",
5380
5834
  stroke: "white",
5381
- "stroke-width": "1.5",
5382
- "stroke-linecap": "round",
5383
- "stroke-linejoin": "round"
5835
+ strokeWidth: "1.5",
5836
+ strokeLinecap: "round",
5837
+ strokeLinejoin: "round"
5384
5838
  }
5385
5839
  ),
5386
5840
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5388,9 +5842,9 @@ var InfoIcon = (props) => {
5388
5842
  {
5389
5843
  d: "M10 6.66602H10.0083",
5390
5844
  stroke: "white",
5391
- "stroke-width": "1.5",
5392
- "stroke-linecap": "round",
5393
- "stroke-linejoin": "round"
5845
+ strokeWidth: "1.5",
5846
+ strokeLinecap: "round",
5847
+ strokeLinejoin: "round"
5394
5848
  }
5395
5849
  )
5396
5850
  ]
@@ -7762,10 +8216,38 @@ async function getCroppedImg(imageSrc, pixelCrop, desiredDimension) {
7762
8216
  }, "image/png");
7763
8217
  });
7764
8218
  }
8219
+ async function getCroppedSVG(imageSrc, pixelCrop, desiredDimension) {
8220
+ let svgString;
8221
+ const parts = imageSrc.split(",");
8222
+ const meta = parts[0];
8223
+ const data = parts[1];
8224
+ if (meta.includes("base64")) {
8225
+ svgString = atob(data);
8226
+ } else {
8227
+ svgString = decodeURIComponent(data);
8228
+ }
8229
+ const parser = new DOMParser();
8230
+ const svgDoc = parser.parseFromString(svgString, "image/svg+xml");
8231
+ const svgElement = svgDoc.documentElement;
8232
+ if (svgElement.tagName.toLowerCase() !== "svg") {
8233
+ throw new Error("The file is not a valid SVG document root.");
8234
+ }
8235
+ const newViewBox = `${pixelCrop.x} ${pixelCrop.y} ${pixelCrop.width} ${pixelCrop.height}`;
8236
+ svgElement.setAttribute("viewBox", newViewBox);
8237
+ const outputWidth = desiredDimension?.width ?? pixelCrop.width;
8238
+ const outputHeight = desiredDimension?.height ?? pixelCrop.height;
8239
+ svgElement.setAttribute("width", String(outputWidth));
8240
+ svgElement.setAttribute("height", String(outputHeight));
8241
+ const serializer = new XMLSerializer();
8242
+ const croppedSvgString = serializer.serializeToString(svgElement);
8243
+ const blob = new Blob([croppedSvgString], { type: "image/svg+xml" });
8244
+ return URL.createObjectURL(blob);
8245
+ }
7765
8246
  var CropperModal = ({
7766
8247
  open,
7767
8248
  onOpenChange,
7768
8249
  imageSrc,
8250
+ isSVG,
7769
8251
  onConfirm,
7770
8252
  onCancel,
7771
8253
  onError,
@@ -7807,7 +8289,7 @@ var CropperModal = ({
7807
8289
  setIsLoading(true);
7808
8290
  try {
7809
8291
  const desiredDimension = outputExactCropSize ? cropSize : void 0;
7810
- const croppedImage = await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
8292
+ const croppedImage = isSVG ? await getCroppedSVG(imageSrc, croppedAreaPixels, desiredDimension) : await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
7811
8293
  onConfirm({ crop, croppedAreaPixels, croppedImageBlobUrl: croppedImage });
7812
8294
  } catch (e) {
7813
8295
  if (onError) {
@@ -7872,7 +8354,7 @@ var CropperModal = ({
7872
8354
  ...props?.cropper
7873
8355
  }
7874
8356
  ) }),
7875
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full py-4 px-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full justify-between", children: [
8357
+ /* @__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
8358
  /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "cancel", onClick: handleCancel, disabled: isLoading, children: "Cancel" }),
7877
8359
  /* @__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
8360
  ] }) })
@@ -7895,10 +8377,12 @@ exports.Collapsible = Collapsible;
7895
8377
  exports.CollapsibleContent = CollapsibleContent2;
7896
8378
  exports.CollapsibleTrigger = CollapsibleTrigger2;
7897
8379
  exports.CropperModal = CropperModal;
8380
+ exports.DIALOG_ALERT_I18N_NAMESPACE = DIALOG_ALERT_I18N_NAMESPACE;
7898
8381
  exports.DataTable = DataTable_default;
7899
8382
  exports.DatePicker = DatePicker2;
7900
8383
  exports.Dialog = Dialog;
7901
8384
  exports.DialogAlert = DialogAlert;
8385
+ exports.DialogAlertProvider = DialogAlertProvider;
7902
8386
  exports.DialogContent = DialogContent;
7903
8387
  exports.DialogDescription = DialogDescription;
7904
8388
  exports.DialogFooter = DialogFooter;
@@ -7999,6 +8483,8 @@ exports.buttonVariants = buttonVariants;
7999
8483
  exports.cn = cn;
8000
8484
  exports.compareAlphanumeric = compareAlphanumeric;
8001
8485
  exports.debounce = debounce;
8486
+ exports.getDialogAlertControls = getDialogAlertControls;
8487
+ exports.getDialogTemplates = getDialogTemplates;
8002
8488
  exports.inputVariants = inputVariants;
8003
8489
  exports.isDefined = isDefined;
8004
8490
  exports.isEmptyObject = isEmptyObject;