@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.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';
@@ -602,7 +604,7 @@ var OPERATOR_MAP = {
602
604
  dropdown: ["is", "isNot"],
603
605
  lookup: ["containsAny", "containsOnly", "containsAll", "notContains"],
604
606
  uuid: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
605
- json: ["contains", "equals", "beginsWith", "endsWith"]
607
+ json: ["equals", "notEquals", "containsAny"]
606
608
  };
607
609
 
608
610
  // src/components/advanceSearch/hooks/useAdvanceSearch.ts
@@ -2436,6 +2438,7 @@ var LookupSelect = ({
2436
2438
  dropdownPortalId
2437
2439
  }) => {
2438
2440
  const [inputValue, setInputValue] = useState("");
2441
+ const inputRef = useRef(null);
2439
2442
  const [suggestions, setSuggestions] = useState([]);
2440
2443
  const [optionLabels, setOptionLabels] = useState({});
2441
2444
  const [loading, setLoading] = useState(false);
@@ -2514,6 +2517,10 @@ var LookupSelect = ({
2514
2517
  (option) => {
2515
2518
  upsertOptionLabels([option]);
2516
2519
  addTag(option.value);
2520
+ inputRef.current?.focus();
2521
+ setTimeout(() => {
2522
+ inputRef.current?.scrollIntoView({ behavior: "smooth" });
2523
+ }, 100);
2517
2524
  },
2518
2525
  [addTag, upsertOptionLabels]
2519
2526
  );
@@ -2655,9 +2662,10 @@ var LookupSelect = ({
2655
2662
  `${tag}-${i}`
2656
2663
  );
2657
2664
  }),
2658
- /* @__PURE__ */ jsx(
2665
+ !limitReached && /* @__PURE__ */ jsx(
2659
2666
  "input",
2660
2667
  {
2668
+ ref: inputRef,
2661
2669
  type: "text",
2662
2670
  value: inputValue,
2663
2671
  onChange: (e) => setInputValue(e.target.value),
@@ -2673,7 +2681,7 @@ var LookupSelect = ({
2673
2681
  }
2674
2682
  )
2675
2683
  ] }),
2676
- /* @__PURE__ */ jsx("div", { className: "flex justify-end absolute inset-y-1 right-2 items-center gap-2 pointer-events-auto", children: value.length === 0 ? /* @__PURE__ */ jsx("span", { className: "flex h-7 w-7 items-center justify-center text-inherit", children: /* @__PURE__ */ jsx(Search, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsx(
2684
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end items-center gap-2 pointer-events-auto h-fit", children: value.length === 0 ? /* @__PURE__ */ jsx("span", { className: "flex h-7 w-7 items-center justify-center text-inherit", children: /* @__PURE__ */ jsx(Search, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsx(
2677
2685
  ClearButton,
2678
2686
  {
2679
2687
  onClick: handleClear,
@@ -2686,7 +2694,7 @@ var LookupSelect = ({
2686
2694
  ),
2687
2695
  renderDropdown(),
2688
2696
  fetchError && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-red-600", children: fetchError }),
2689
- limitReached && !fetchError && /* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-inherit", children: [
2697
+ limitReached && !fetchError && maxTags !== 1 && /* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-inherit", children: [
2690
2698
  "Maximum ",
2691
2699
  maxTags,
2692
2700
  " tags reached."
@@ -2736,6 +2744,58 @@ var ConditionLookupInput = ({
2736
2744
  }
2737
2745
  }
2738
2746
  );
2747
+ var ConditionJSONInput = ({
2748
+ row,
2749
+ control,
2750
+ onClear,
2751
+ fieldSchema,
2752
+ dropdownPortalId
2753
+ }) => /* @__PURE__ */ jsx(
2754
+ FormField,
2755
+ {
2756
+ control,
2757
+ name: `value_${row.id}`,
2758
+ rules: { required: "This field is required." },
2759
+ render: ({ field, fieldState }) => {
2760
+ const value = Array.isArray(field.value) ? field.value : [];
2761
+ const handleChange = (tags) => {
2762
+ field.onChange(tags);
2763
+ };
2764
+ const handleClear = () => {
2765
+ field.onChange([]);
2766
+ onClear("value");
2767
+ };
2768
+ return /* @__PURE__ */ jsxs(FormItem, { className: "relative w-full overflow-x-hidden", children: [
2769
+ /* @__PURE__ */ jsx(FormControl, { children: fieldSchema?.fetchSuggestions ? /* @__PURE__ */ jsx(
2770
+ LookupSelect,
2771
+ {
2772
+ value,
2773
+ onChange: handleChange,
2774
+ onClear: handleClear,
2775
+ error: Boolean(fieldState.error),
2776
+ placeholder: fieldSchema?.placeholder,
2777
+ maxTags: row.operator === "containsAny" ? fieldSchema?.maxTags : 1,
2778
+ fetchSuggestions: fieldSchema?.fetchSuggestions,
2779
+ suggestionDebounce: fieldSchema?.suggestionDebounce,
2780
+ noOptionsMessage: fieldSchema?.noOptionsMessage,
2781
+ loadingMessage: fieldSchema?.loadingMessage,
2782
+ dropdownPortalId
2783
+ }
2784
+ ) : /* @__PURE__ */ jsx(
2785
+ Input,
2786
+ {
2787
+ ...field,
2788
+ value: field.value ?? "",
2789
+ autoComplete: "off",
2790
+ inputMode: "text",
2791
+ 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"
2792
+ }
2793
+ ) }),
2794
+ /* @__PURE__ */ jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
2795
+ ] });
2796
+ }
2797
+ }
2798
+ );
2739
2799
  var ConditionValue = ({ row, fields, onClearValue, dropdownPortalId }) => {
2740
2800
  const { control } = useFormContext();
2741
2801
  const fieldSchema = fields.find((f) => f.name === row.fieldName);
@@ -2771,6 +2831,18 @@ var ConditionValue = ({ row, fields, onClearValue, dropdownPortalId }) => {
2771
2831
  dropdownPortalId
2772
2832
  }
2773
2833
  );
2834
+ case "json": {
2835
+ return /* @__PURE__ */ jsx(
2836
+ ConditionJSONInput,
2837
+ {
2838
+ row,
2839
+ control,
2840
+ onClear: onClearValue,
2841
+ fieldSchema,
2842
+ dropdownPortalId
2843
+ }
2844
+ );
2845
+ }
2774
2846
  default:
2775
2847
  return /* @__PURE__ */ jsx(ConditionTextInput, { row, control, onClear: onClearValue });
2776
2848
  }
@@ -2986,23 +3058,20 @@ var DropdownBuilder = class {
2986
3058
  // src/components/advanceSearch/builder/json.ts
2987
3059
  var JSONBuilder = class {
2988
3060
  build(row) {
3061
+ const isArray = Array.isArray(row.value);
2989
3062
  switch (row.operator) {
2990
- case "contains":
2991
- return { [row.fieldName]: { path: row.jsonPath, string_contains: row.value } };
2992
3063
  case "equals":
2993
- return { [row.fieldName]: { path: row.jsonPath, equals: row.value } };
2994
- case "beginsWith":
2995
- return { [row.fieldName]: { path: row.jsonPath, string_starts_with: row.value } };
2996
- case "endsWith":
2997
- return { [row.fieldName]: { path: row.jsonPath, string_ends_with: row.value } };
2998
- case "notContains":
2999
- return { [row.fieldName]: { path: row.jsonPath, not: { string_contains: row.value } } };
3064
+ return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
3000
3065
  case "notEquals":
3001
- return { [row.fieldName]: { path: row.jsonPath, not: { equals: row.value } } };
3002
- case "notBeginsWith":
3003
- return { [row.fieldName]: { path: row.jsonPath, not: { string_starts_with: row.value } } };
3004
- case "notEndsWith":
3005
- return { [row.fieldName]: { path: row.jsonPath, not: { string_ends_with: row.value } } };
3066
+ return {
3067
+ NOT: { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } }
3068
+ };
3069
+ case "containsAny":
3070
+ if (!isArray)
3071
+ return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
3072
+ return {
3073
+ OR: row.value.map((v) => ({ [row.fieldName]: { path: row.jsonPath, equals: v } }))
3074
+ };
3006
3075
  default:
3007
3076
  return {};
3008
3077
  }
@@ -4724,9 +4793,11 @@ var buttonVariants2 = cva(
4724
4793
  variant: {
4725
4794
  default: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
4726
4795
  success: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
4727
- error: "border border-[#BB0B0E] bg-[#BB0B0E] shadow-xs hover:bg-accent hover:text-accent-foreground text-white",
4796
+ error: "border border-[#BB0B0E] text-[#BB0B0E] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground",
4728
4797
  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"
4798
+ cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
4799
+ confirm: "border border-[#BB0B0E] text-[#BB0B0E] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground",
4800
+ "confirm-green": "border border-[#379A2A] text-[#379A2A] bg-white shadow-xs hover:bg-accent hover:text-accent-foreground"
4730
4801
  },
4731
4802
  size: {
4732
4803
  default: "h-9 px-4 has-[>svg]:px-3",
@@ -4768,6 +4839,154 @@ function Button2({
4768
4839
  }
4769
4840
  );
4770
4841
  }
4842
+
4843
+ // src/components/dialog-alert/lib/constants.ts
4844
+ var DIALOG_ALERT_I18N_NAMESPACE = "dialog_alert";
4845
+
4846
+ // src/components/dialog-alert/locale/default.ts
4847
+ var defaultResource = {
4848
+ sharedui: {
4849
+ [DIALOG_ALERT_I18N_NAMESPACE]: {
4850
+ cancel: "Cancel",
4851
+ close: "Close",
4852
+ "success.saved": {
4853
+ title: "Successfully",
4854
+ description: "Data has been successfully saved"
4855
+ },
4856
+ "success.deleted": {
4857
+ title: "Successfully",
4858
+ description: "Data has been successfully deleted"
4859
+ },
4860
+ "success.removed": {
4861
+ title: "Successfully",
4862
+ description: "Data has been successfully removed"
4863
+ },
4864
+ "error.api_db_error": {
4865
+ title: "API/Database Error",
4866
+ description: "Failed to connect to the system. Please check API or database connection."
4867
+ },
4868
+ "error.permission_denied": {
4869
+ title: "Permission Denied",
4870
+ description: "You do not have permission to delete this data.",
4871
+ confirm_text: "Discard"
4872
+ },
4873
+ "error.session_expired": {
4874
+ title: "Session Expired",
4875
+ description: "Your session has expired or you have been logged out. Please sign in again.",
4876
+ confirm_text: "Logout"
4877
+ },
4878
+ "error.user_not_found": {
4879
+ title: "User Not Found",
4880
+ description: "The system could not locate the user account.",
4881
+ confirm_text: "Logout"
4882
+ },
4883
+ "error.data_not_found": {
4884
+ title: "Data Not Found",
4885
+ description: "The data has already been deleted or does not exist in the system."
4886
+ },
4887
+ "error.data_restrict_editing": {
4888
+ title: "Data Status Restricts Editing",
4889
+ description: "Data status does not allow editing."
4890
+ },
4891
+ "error.network_timeout_error": {
4892
+ title: "Network Error / Timeout",
4893
+ description: "The system could not connect to the network or the request took too long to process."
4894
+ },
4895
+ "error.queue_full": {
4896
+ title: "Queue Full",
4897
+ description: "The notification queue has reached its limit. Please try again later."
4898
+ },
4899
+ "error.invalid_data_format": {
4900
+ title: "Invalid Data Format",
4901
+ description: "Data creation failed due to invalid or incorrectly formatted data."
4902
+ },
4903
+ "error.data_linked_to_system_data": {
4904
+ title: "Data Linked to System Data",
4905
+ description: "Cannot delete data because they are linked to existing system data."
4906
+ },
4907
+ "error.pending_workflow_conflict": {
4908
+ title: "Pending Workflow Conflict ",
4909
+ description: "The data is currently involved in a pending workflow or approval process and cannot be deactivated."
4910
+ },
4911
+ "error.invalid_incomplete_data": {
4912
+ title: "Invalid or Incomplete Data",
4913
+ description: "Data status cannot be changed due to incomplete or invalid information."
4914
+ },
4915
+ "error.client_side_error": {
4916
+ title: "Client-Side Error",
4917
+ description: "An error occurred on the client side. Please refresh the page or try again."
4918
+ },
4919
+ "error.system_limitation": {
4920
+ title: "System Limitation",
4921
+ description: "The search cannot be completed due to system limitations. Please simplify your query."
4922
+ },
4923
+ "error.timeout": {
4924
+ title: "Timeout",
4925
+ description: "Request failed due to a system error or timeout. Please try again."
4926
+ },
4927
+ "error.duplicate_data": {
4928
+ title: "Duplicate Data",
4929
+ description: "The data you entered already exists in the system."
4930
+ },
4931
+ "error.something_went_wrong": {
4932
+ title: "Something Went Wrong",
4933
+ description: "An unknown error occurred."
4934
+ },
4935
+ "confirm.delete": {
4936
+ title: "Confirmation",
4937
+ description: "Are you sure you want to delete this item?",
4938
+ confirm_text: "Delete"
4939
+ },
4940
+ "confirm.inactive": {
4941
+ title: "Confirmation",
4942
+ description: "Are you sure you want to inactive this item?",
4943
+ confirm_text: "Inactive"
4944
+ },
4945
+ "confirm.active": {
4946
+ variant: "confirm-green",
4947
+ title: "Confirmation",
4948
+ description: "Are you sure you want to active this item?",
4949
+ confirm_text: "Active"
4950
+ },
4951
+ "confirm.leave_page": {
4952
+ title: "Confirmation",
4953
+ description: "Unsaved changes. Do you want to leave this page?",
4954
+ confirm_text: "Leave"
4955
+ },
4956
+ "confirm.remove": {
4957
+ title: "Confirmation",
4958
+ description: "Are you sure you want to remove this item?",
4959
+ confirm_text: "Remove"
4960
+ },
4961
+ "confirm.logout": {
4962
+ title: "Confirmation",
4963
+ description: "Do you want to log out?",
4964
+ confirm_text: "Logout"
4965
+ }
4966
+ }
4967
+ }
4968
+ };
4969
+
4970
+ // src/components/dialog-alert/locale/i18n.ts
4971
+ i18n.use(initReactI18next).init({
4972
+ resources: defaultResource,
4973
+ lng: "sharedui",
4974
+ fallbackLng: "sharedui",
4975
+ defaultNS: DIALOG_ALERT_I18N_NAMESPACE,
4976
+ interpolation: {
4977
+ escapeValue: false
4978
+ // react already safes from xss
4979
+ }
4980
+ });
4981
+ var i18n_default = i18n;
4982
+ var titleColorVariant = {
4983
+ default: "",
4984
+ success: "text-green-600",
4985
+ error: "text-red-600",
4986
+ warning: "text-yellow-600",
4987
+ confirm: "text-red-600",
4988
+ "confirm-green": "text-red-600"
4989
+ };
4771
4990
  function DialogAlert({
4772
4991
  open,
4773
4992
  onOpenChange,
@@ -4775,7 +4994,7 @@ function DialogAlert({
4775
4994
  description,
4776
4995
  variant = "default",
4777
4996
  confirmText,
4778
- cancelText = "Cancel",
4997
+ cancelText = "cancel",
4779
4998
  onConfirm,
4780
4999
  onCancel,
4781
5000
  showCancel = true,
@@ -4784,6 +5003,7 @@ function DialogAlert({
4784
5003
  persistent = false
4785
5004
  }) {
4786
5005
  const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
5006
+ const { t } = useTranslation(DIALOG_ALERT_I18N_NAMESPACE);
4787
5007
  const handleCancel = useCallback(() => {
4788
5008
  onCancel?.();
4789
5009
  onOpenChange(false);
@@ -4794,28 +5014,261 @@ function DialogAlert({
4794
5014
  return /* @__PURE__ */ jsx(Dialog2, { open, onOpenChange: persistent ? () => {
4795
5015
  } : onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
4796
5016
  /* @__PURE__ */ jsxs(DialogHeader2, { children: [
4797
- title && /* @__PURE__ */ jsx(DialogTitle2, { className: variantClass(variant), children: title }),
4798
- description && /* @__PURE__ */ jsx(DialogDescription2, { children: description })
5017
+ title && /* @__PURE__ */ jsx(DialogTitle2, { className: titleColorVariant[variant], children: t(title) }),
5018
+ description && /* @__PURE__ */ jsx(DialogDescription2, { children: t(description) })
4799
5019
  ] }),
4800
5020
  outlet && outlet,
4801
5021
  /* @__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 })
5022
+ showCancel && /* @__PURE__ */ jsx(Button2, { variant: "cancel", onClick: handleCancel, children: t(cancelText) }),
5023
+ confirmText && /* @__PURE__ */ jsx(Button2, { variant, onClick: handleConfirm, children: t(confirmText) })
4804
5024
  ] })
4805
5025
  ] }) });
4806
5026
  }
4807
- function variantClass(variant) {
4808
- switch (variant) {
4809
- case "success":
4810
- return "text-green-600";
4811
- case "error":
4812
- return "text-red-600";
4813
- case "warning":
4814
- return "text-yellow-600";
4815
- default:
4816
- return "";
5027
+
5028
+ // src/components/dialog-alert/templates/index.ts
5029
+ var getDialogTemplates = ({ setOpen = () => {
5030
+ } }) => ({
5031
+ "success.saved": {
5032
+ variant: "success",
5033
+ title: "success.saved.title",
5034
+ description: "success.saved.description",
5035
+ cancelText: "close"
5036
+ },
5037
+ "success.deleted": {
5038
+ variant: "success",
5039
+ title: "success.deleted.title",
5040
+ description: "success.deleted.description",
5041
+ cancelText: "close"
5042
+ },
5043
+ "success.removed": {
5044
+ variant: "success",
5045
+ title: "success.removed.title",
5046
+ description: "success.removed.description",
5047
+ cancelText: "close"
5048
+ },
5049
+ "error.api_db_error": {
5050
+ variant: "error",
5051
+ title: "error.api_db_error.title",
5052
+ description: "error.api_db_error.description",
5053
+ cancelText: "close"
5054
+ },
5055
+ "error.permission_denied": {
5056
+ variant: "error",
5057
+ title: "error.permission_denied.title",
5058
+ description: "error.permission_denied.description",
5059
+ confirmText: "error.permission_denied.confirm_text",
5060
+ showCancel: false,
5061
+ onConfirm: () => setOpen(false)
5062
+ },
5063
+ "error.session_expired": {
5064
+ variant: "error",
5065
+ title: "error.session_expired.title",
5066
+ description: "error.session_expired.description",
5067
+ confirmText: "error.session_expired.confirm_text",
5068
+ showCancel: false
5069
+ },
5070
+ "error.user_not_found": {
5071
+ variant: "error",
5072
+ title: "error.user_not_found.title",
5073
+ description: "error.user_not_found.description",
5074
+ confirmText: "error.user_not_found.confirm_text",
5075
+ showCancel: false
5076
+ },
5077
+ "error.data_not_found": {
5078
+ variant: "error",
5079
+ title: "error.data_not_found.title",
5080
+ description: "error.data_not_found.description",
5081
+ cancelText: "close"
5082
+ },
5083
+ "error.data_restrict_editing": {
5084
+ variant: "error",
5085
+ title: "error.data_restrict_editing.title",
5086
+ description: "error.data_restrict_editing.description",
5087
+ cancelText: "close"
5088
+ },
5089
+ "error.network_timeout_error": {
5090
+ variant: "error",
5091
+ title: "error.network_timeout_error.title",
5092
+ description: "error.network_timeout_error.description",
5093
+ cancelText: "close"
5094
+ },
5095
+ "error.queue_full": {
5096
+ variant: "error",
5097
+ title: "error.queue_full.title",
5098
+ description: "error.queue_full.description",
5099
+ cancelText: "close"
5100
+ },
5101
+ "error.invalid_data_format": {
5102
+ variant: "error",
5103
+ title: "error.invalid_data_format.title",
5104
+ description: "error.invalid_data_format.description",
5105
+ cancelText: "close"
5106
+ },
5107
+ "error.data_linked_to_system_data": {
5108
+ variant: "error",
5109
+ title: "error.data_linked_to_system_data.title",
5110
+ description: "error.data_linked_to_system_data.description",
5111
+ cancelText: "close"
5112
+ },
5113
+ "error.pending_workflow_conflict": {
5114
+ variant: "error",
5115
+ title: "error.pending_workflow_conflict.title",
5116
+ description: "error.pending_workflow_conflict.description",
5117
+ cancelText: "close"
5118
+ },
5119
+ "error.invalid_incomplete_data": {
5120
+ variant: "error",
5121
+ title: "error.invalid_incomplete_data.title",
5122
+ description: "error.invalid_incomplete_data.description",
5123
+ cancelText: "close"
5124
+ },
5125
+ "error.client_side_error": {
5126
+ variant: "error",
5127
+ title: "error.client_side_error.title",
5128
+ description: "error.client_side_error.description",
5129
+ cancelText: "close"
5130
+ },
5131
+ "error.system_limitation": {
5132
+ variant: "error",
5133
+ title: "error.system_limitation.title",
5134
+ description: "error.system_limitation.description",
5135
+ cancelText: "close"
5136
+ },
5137
+ "error.timeout": {
5138
+ variant: "error",
5139
+ title: "error.timeout.title",
5140
+ description: "error.timeout.description",
5141
+ cancelText: "close"
5142
+ },
5143
+ "error.duplicate_data": {
5144
+ variant: "error",
5145
+ title: "error.duplicate_data.title",
5146
+ description: "error.duplicate_data.description",
5147
+ cancelText: "close"
5148
+ },
5149
+ "error.something_went_wrong": {
5150
+ variant: "error",
5151
+ title: "error.something_went_wrong.title",
5152
+ description: "error.something_went_wrong.description",
5153
+ cancelText: "close"
5154
+ },
5155
+ "confirm.delete": {
5156
+ variant: "confirm",
5157
+ title: "confirm.delete.title",
5158
+ description: "confirm.delete.description",
5159
+ confirmText: "confirm.delete.confirm_text"
5160
+ },
5161
+ "confirm.inactive": {
5162
+ variant: "confirm",
5163
+ title: "confirm.inactive.title",
5164
+ description: "confirm.inactive.description",
5165
+ confirmText: "confirm.inactive.confirm_text"
5166
+ },
5167
+ "confirm.active": {
5168
+ variant: "confirm-green",
5169
+ title: "confirm.active.title",
5170
+ description: "confirm.active.description",
5171
+ confirmText: "confirm.active.confirm_text"
5172
+ },
5173
+ "confirm.leave_page": {
5174
+ variant: "confirm",
5175
+ title: "confirm.leave_page.title",
5176
+ description: "confirm.leave_page.description",
5177
+ confirmText: "confirm.leave_page.confirm_text"
5178
+ },
5179
+ "confirm.remove": {
5180
+ variant: "confirm",
5181
+ title: "confirm.remove.title",
5182
+ description: "confirm.remove.description",
5183
+ confirmText: "confirm.remove.confirm_text"
5184
+ },
5185
+ "confirm.logout": {
5186
+ variant: "confirm",
5187
+ title: "confirm.logout.title",
5188
+ description: "confirm.logout.description",
5189
+ confirmText: "confirm.logout.confirm_text"
4817
5190
  }
4818
- }
5191
+ });
5192
+ var useDialogAlertStore = create((set, get) => ({
5193
+ open: false,
5194
+ dialogProps: {},
5195
+ setOpen: (data) => set({ open: data }),
5196
+ setDialogProps: (data) => set({ dialogProps: data }),
5197
+ openDialogAlert: (payload) => {
5198
+ let templateVal;
5199
+ if (payload?.template) {
5200
+ templateVal = getDialogTemplates({ setOpen: get().setOpen })[payload.template];
5201
+ }
5202
+ get().setDialogProps({ ...templateVal, ...payload?.props });
5203
+ get().setOpen(true);
5204
+ },
5205
+ closeDialogAlert: () => {
5206
+ set({ open: false });
5207
+ }
5208
+ }));
5209
+ var DialogAlertProvider = ({ children, i18nResource, i18nLang }) => {
5210
+ const open = useDialogAlertStore((state) => state.open);
5211
+ const setOpen = useDialogAlertStore((state) => state.setOpen);
5212
+ const dialogProps = useDialogAlertStore((state) => state.dialogProps);
5213
+ useEffect(() => {
5214
+ if (!i18nResource) {
5215
+ i18n_default.changeLanguage("sharedui");
5216
+ return;
5217
+ }
5218
+ const langs = Object.keys(i18nResource);
5219
+ for (const lang of langs) {
5220
+ i18n_default.addResourceBundle(
5221
+ lang,
5222
+ DIALOG_ALERT_I18N_NAMESPACE,
5223
+ i18nResource[lang][DIALOG_ALERT_I18N_NAMESPACE],
5224
+ false,
5225
+ true
5226
+ );
5227
+ }
5228
+ i18n_default.changeLanguage(i18nLang);
5229
+ }, [i18nLang, i18nResource]);
5230
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
5231
+ children,
5232
+ /* @__PURE__ */ jsx(DialogAlert, { open, onOpenChange: setOpen, ...dialogProps })
5233
+ ] });
5234
+ };
5235
+ var openDialogAlert = useDialogAlertStore.getState().openDialogAlert;
5236
+ var closeDialogAlert = useDialogAlertStore.getState().closeDialogAlert;
5237
+ var openErrorDialogAlert = (error) => {
5238
+ if (error instanceof Error) {
5239
+ openDialogAlert({ template: "error.something_went_wrong", props: { description: error.message } });
5240
+ } else if (error.isAxiosError) {
5241
+ let template = "error.something_went_wrong";
5242
+ switch (error.response?.status) {
5243
+ case 400:
5244
+ template = "error.invalid_incomplete_data";
5245
+ break;
5246
+ case 401:
5247
+ template = "error.session_expired";
5248
+ break;
5249
+ case 403:
5250
+ template = "error.permission_denied";
5251
+ break;
5252
+ case 404:
5253
+ template = "error.data_not_found";
5254
+ break;
5255
+ case 409:
5256
+ template = "error.duplicate_data";
5257
+ break;
5258
+ case 500:
5259
+ template = "error.api_db_error";
5260
+ break;
5261
+ }
5262
+ openDialogAlert({ template });
5263
+ } else {
5264
+ openDialogAlert({ template: "error.something_went_wrong" });
5265
+ }
5266
+ };
5267
+ var getDialogAlertControls = () => ({
5268
+ openDialogAlert,
5269
+ closeDialogAlert,
5270
+ openErrorDialogAlert
5271
+ });
4819
5272
  function TooltipProvider({
4820
5273
  delayDuration = 0,
4821
5274
  ...props
@@ -5332,9 +5785,9 @@ var InfoIcon = (props) => {
5332
5785
  {
5333
5786
  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",
5334
5787
  stroke: "white",
5335
- "stroke-width": "1.5",
5336
- "stroke-linecap": "round",
5337
- "stroke-linejoin": "round"
5788
+ strokeWidth: "1.5",
5789
+ strokeLinecap: "round",
5790
+ strokeLinejoin: "round"
5338
5791
  }
5339
5792
  ),
5340
5793
  /* @__PURE__ */ jsx(
@@ -5342,9 +5795,9 @@ var InfoIcon = (props) => {
5342
5795
  {
5343
5796
  d: "M10 13.3333V10",
5344
5797
  stroke: "white",
5345
- "stroke-width": "1.5",
5346
- "stroke-linecap": "round",
5347
- "stroke-linejoin": "round"
5798
+ strokeWidth: "1.5",
5799
+ strokeLinecap: "round",
5800
+ strokeLinejoin: "round"
5348
5801
  }
5349
5802
  ),
5350
5803
  /* @__PURE__ */ jsx(
@@ -5352,9 +5805,9 @@ var InfoIcon = (props) => {
5352
5805
  {
5353
5806
  d: "M10 6.66602H10.0083",
5354
5807
  stroke: "white",
5355
- "stroke-width": "1.5",
5356
- "stroke-linecap": "round",
5357
- "stroke-linejoin": "round"
5808
+ strokeWidth: "1.5",
5809
+ strokeLinecap: "round",
5810
+ strokeLinejoin: "round"
5358
5811
  }
5359
5812
  )
5360
5813
  ]
@@ -7726,10 +8179,38 @@ async function getCroppedImg(imageSrc, pixelCrop, desiredDimension) {
7726
8179
  }, "image/png");
7727
8180
  });
7728
8181
  }
8182
+ async function getCroppedSVG(imageSrc, pixelCrop, desiredDimension) {
8183
+ let svgString;
8184
+ const parts = imageSrc.split(",");
8185
+ const meta = parts[0];
8186
+ const data = parts[1];
8187
+ if (meta.includes("base64")) {
8188
+ svgString = atob(data);
8189
+ } else {
8190
+ svgString = decodeURIComponent(data);
8191
+ }
8192
+ const parser = new DOMParser();
8193
+ const svgDoc = parser.parseFromString(svgString, "image/svg+xml");
8194
+ const svgElement = svgDoc.documentElement;
8195
+ if (svgElement.tagName.toLowerCase() !== "svg") {
8196
+ throw new Error("The file is not a valid SVG document root.");
8197
+ }
8198
+ const newViewBox = `${pixelCrop.x} ${pixelCrop.y} ${pixelCrop.width} ${pixelCrop.height}`;
8199
+ svgElement.setAttribute("viewBox", newViewBox);
8200
+ const outputWidth = desiredDimension?.width ?? pixelCrop.width;
8201
+ const outputHeight = desiredDimension?.height ?? pixelCrop.height;
8202
+ svgElement.setAttribute("width", String(outputWidth));
8203
+ svgElement.setAttribute("height", String(outputHeight));
8204
+ const serializer = new XMLSerializer();
8205
+ const croppedSvgString = serializer.serializeToString(svgElement);
8206
+ const blob = new Blob([croppedSvgString], { type: "image/svg+xml" });
8207
+ return URL.createObjectURL(blob);
8208
+ }
7729
8209
  var CropperModal = ({
7730
8210
  open,
7731
8211
  onOpenChange,
7732
8212
  imageSrc,
8213
+ isSVG,
7733
8214
  onConfirm,
7734
8215
  onCancel,
7735
8216
  onError,
@@ -7771,7 +8252,7 @@ var CropperModal = ({
7771
8252
  setIsLoading(true);
7772
8253
  try {
7773
8254
  const desiredDimension = outputExactCropSize ? cropSize : void 0;
7774
- const croppedImage = await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
8255
+ const croppedImage = isSVG ? await getCroppedSVG(imageSrc, croppedAreaPixels, desiredDimension) : await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
7775
8256
  onConfirm({ crop, croppedAreaPixels, croppedImageBlobUrl: croppedImage });
7776
8257
  } catch (e) {
7777
8258
  if (onError) {
@@ -7836,7 +8317,7 @@ var CropperModal = ({
7836
8317
  ...props?.cropper
7837
8318
  }
7838
8319
  ) }),
7839
- /* @__PURE__ */ jsx("div", { className: "w-full py-4 px-8", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full justify-between", children: [
8320
+ /* @__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
8321
  /* @__PURE__ */ jsx(Button, { type: "button", variant: "cancel", onClick: handleCancel, disabled: isLoading, children: "Cancel" }),
7841
8322
  /* @__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
8323
  ] }) })
@@ -7847,6 +8328,6 @@ var CropperModal = ({
7847
8328
  );
7848
8329
  };
7849
8330
 
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 };
8331
+ 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
8332
  //# sourceMappingURL=index.mjs.map
7852
8333
  //# sourceMappingURL=index.mjs.map