@sustaina/shared-ui 1.16.0 → 1.17.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.mjs CHANGED
@@ -4911,127 +4911,130 @@ function Button2({
4911
4911
  }
4912
4912
 
4913
4913
  // src/components/dialog-alert/lib/constants.ts
4914
- var DIALOG_ALERT_I18N_NAMESPACE = "dialog_alert";
4914
+ var DIALOG_ALERT_I18N_SUBNAMESPACE = "dialog_alert";
4915
+ var i18nPrefix = `translation:${DIALOG_ALERT_I18N_SUBNAMESPACE}.`;
4915
4916
 
4916
4917
  // src/components/dialog-alert/locale/default.ts
4917
4918
  var defaultResource = {
4918
4919
  sharedui: {
4919
- [DIALOG_ALERT_I18N_NAMESPACE]: {
4920
- cancel: "Cancel",
4921
- close: "Close",
4922
- "success.saved": {
4923
- title: "Successfully",
4924
- description: "Data has been successfully saved"
4925
- },
4926
- "success.deleted": {
4927
- title: "Successfully",
4928
- description: "Data has been successfully deleted"
4929
- },
4930
- "success.removed": {
4931
- title: "Successfully",
4932
- description: "Data has been successfully removed"
4933
- },
4934
- "error.api_db_error": {
4935
- title: "API/Database Error",
4936
- description: "Failed to connect to the system. Please check API or database connection."
4937
- },
4938
- "error.permission_denied": {
4939
- title: "Permission Denied",
4940
- description: "You do not have permission to delete this data.",
4941
- confirm_text: "Discard"
4942
- },
4943
- "error.session_expired": {
4944
- title: "Session Expired",
4945
- description: "Your session has expired or you have been logged out. Please sign in again.",
4946
- confirm_text: "Logout"
4947
- },
4948
- "error.user_not_found": {
4949
- title: "User Not Found",
4950
- description: "The system could not locate the user account.",
4951
- confirm_text: "Logout"
4952
- },
4953
- "error.data_not_found": {
4954
- title: "Data Not Found",
4955
- description: "The data has already been deleted or does not exist in the system."
4956
- },
4957
- "error.data_restrict_editing": {
4958
- title: "Data Status Restricts Editing",
4959
- description: "Data status does not allow editing."
4960
- },
4961
- "error.network_timeout_error": {
4962
- title: "Network Error / Timeout",
4963
- description: "The system could not connect to the network or the request took too long to process."
4964
- },
4965
- "error.queue_full": {
4966
- title: "Queue Full",
4967
- description: "The notification queue has reached its limit. Please try again later."
4968
- },
4969
- "error.invalid_data_format": {
4970
- title: "Invalid Data Format",
4971
- description: "Data creation failed due to invalid or incorrectly formatted data."
4972
- },
4973
- "error.data_linked_to_system_data": {
4974
- title: "Data Linked to System Data",
4975
- description: "Cannot delete data because they are linked to existing system data."
4976
- },
4977
- "error.pending_workflow_conflict": {
4978
- title: "Pending Workflow Conflict ",
4979
- description: "The data is currently involved in a pending workflow or approval process and cannot be deactivated."
4980
- },
4981
- "error.invalid_incomplete_data": {
4982
- title: "Invalid or Incomplete Data",
4983
- description: "Data status cannot be changed due to incomplete or invalid information."
4984
- },
4985
- "error.client_side_error": {
4986
- title: "Client-Side Error",
4987
- description: "An error occurred on the client side. Please refresh the page or try again."
4988
- },
4989
- "error.system_limitation": {
4990
- title: "System Limitation",
4991
- description: "The search cannot be completed due to system limitations. Please simplify your query."
4992
- },
4993
- "error.timeout": {
4994
- title: "Timeout",
4995
- description: "Request failed due to a system error or timeout. Please try again."
4996
- },
4997
- "error.duplicate_data": {
4998
- title: "Duplicate Data",
4999
- description: "The data you entered already exists in the system."
5000
- },
5001
- "error.something_went_wrong": {
5002
- title: "Something Went Wrong",
5003
- description: "An unknown error occurred."
5004
- },
5005
- "confirm.delete": {
5006
- title: "Confirmation",
5007
- description: "Are you sure you want to delete this item?",
5008
- confirm_text: "Delete"
5009
- },
5010
- "confirm.inactive": {
5011
- title: "Confirmation",
5012
- description: "Are you sure you want to inactive this item?",
5013
- confirm_text: "Inactive"
5014
- },
5015
- "confirm.active": {
5016
- variant: "confirm-green",
5017
- title: "Confirmation",
5018
- description: "Are you sure you want to active this item?",
5019
- confirm_text: "Active"
5020
- },
5021
- "confirm.leave_page": {
5022
- title: "Confirmation",
5023
- description: "Unsaved changes. Do you want to leave this page?",
5024
- confirm_text: "Leave"
5025
- },
5026
- "confirm.remove": {
5027
- title: "Confirmation",
5028
- description: "Are you sure you want to remove this item?",
5029
- confirm_text: "Remove"
5030
- },
5031
- "confirm.logout": {
5032
- title: "Confirmation",
5033
- description: "Do you want to log out?",
5034
- confirm_text: "Logout"
4920
+ translation: {
4921
+ [DIALOG_ALERT_I18N_SUBNAMESPACE]: {
4922
+ cancel: "Cancel",
4923
+ close: "Close",
4924
+ "success.saved": {
4925
+ title: "Successfully",
4926
+ description: "Data has been successfully saved"
4927
+ },
4928
+ "success.deleted": {
4929
+ title: "Successfully",
4930
+ description: "Data has been successfully deleted"
4931
+ },
4932
+ "success.removed": {
4933
+ title: "Successfully",
4934
+ description: "Data has been successfully removed"
4935
+ },
4936
+ "error.api_db_error": {
4937
+ title: "API/Database Error",
4938
+ description: "Failed to connect to the system. Please check API or database connection."
4939
+ },
4940
+ "error.permission_denied": {
4941
+ title: "Permission Denied",
4942
+ description: "You do not have permission to delete this data.",
4943
+ confirm_text: "Discard"
4944
+ },
4945
+ "error.session_expired": {
4946
+ title: "Session Expired",
4947
+ description: "Your session has expired or you have been logged out. Please sign in again.",
4948
+ confirm_text: "Logout"
4949
+ },
4950
+ "error.user_not_found": {
4951
+ title: "User Not Found",
4952
+ description: "The system could not locate the user account.",
4953
+ confirm_text: "Logout"
4954
+ },
4955
+ "error.data_not_found": {
4956
+ title: "Data Not Found",
4957
+ description: "The data has already been deleted or does not exist in the system."
4958
+ },
4959
+ "error.data_restrict_editing": {
4960
+ title: "Data Status Restricts Editing",
4961
+ description: "Data status does not allow editing."
4962
+ },
4963
+ "error.network_timeout_error": {
4964
+ title: "Network Error / Timeout",
4965
+ description: "The system could not connect to the network or the request took too long to process."
4966
+ },
4967
+ "error.queue_full": {
4968
+ title: "Queue Full",
4969
+ description: "The notification queue has reached its limit. Please try again later."
4970
+ },
4971
+ "error.invalid_data_format": {
4972
+ title: "Invalid Data Format",
4973
+ description: "Data creation failed due to invalid or incorrectly formatted data."
4974
+ },
4975
+ "error.data_linked_to_system_data": {
4976
+ title: "Data Linked to System Data",
4977
+ description: "Cannot delete data because they are linked to existing system data."
4978
+ },
4979
+ "error.pending_workflow_conflict": {
4980
+ title: "Pending Workflow Conflict ",
4981
+ description: "The data is currently involved in a pending workflow or approval process and cannot be deactivated."
4982
+ },
4983
+ "error.invalid_incomplete_data": {
4984
+ title: "Invalid or Incomplete Data",
4985
+ description: "Data status cannot be changed due to incomplete or invalid information."
4986
+ },
4987
+ "error.client_side_error": {
4988
+ title: "Client-Side Error",
4989
+ description: "An error occurred on the client side. Please refresh the page or try again."
4990
+ },
4991
+ "error.system_limitation": {
4992
+ title: "System Limitation",
4993
+ description: "The search cannot be completed due to system limitations. Please simplify your query."
4994
+ },
4995
+ "error.timeout": {
4996
+ title: "Timeout",
4997
+ description: "Request failed due to a system error or timeout. Please try again."
4998
+ },
4999
+ "error.duplicate_data": {
5000
+ title: "Duplicate Data",
5001
+ description: "The data you entered already exists in the system."
5002
+ },
5003
+ "error.something_went_wrong": {
5004
+ title: "Something Went Wrong",
5005
+ description: "An unknown error occurred."
5006
+ },
5007
+ "confirm.delete": {
5008
+ title: "Confirmation",
5009
+ description: "Are you sure you want to delete this item?",
5010
+ confirm_text: "Delete"
5011
+ },
5012
+ "confirm.inactive": {
5013
+ title: "Confirmation",
5014
+ description: "Are you sure you want to inactive this item?",
5015
+ confirm_text: "Inactive"
5016
+ },
5017
+ "confirm.active": {
5018
+ variant: "confirm-green",
5019
+ title: "Confirmation",
5020
+ description: "Are you sure you want to active this item?",
5021
+ confirm_text: "Active"
5022
+ },
5023
+ "confirm.leave_page": {
5024
+ title: "Confirmation",
5025
+ description: "Unsaved changes. Do you want to leave this page?",
5026
+ confirm_text: "Leave"
5027
+ },
5028
+ "confirm.remove": {
5029
+ title: "Confirmation",
5030
+ description: "Are you sure you want to remove this item?",
5031
+ confirm_text: "Remove"
5032
+ },
5033
+ "confirm.logout": {
5034
+ title: "Confirmation",
5035
+ description: "Do you want to log out?",
5036
+ confirm_text: "Logout"
5037
+ }
5035
5038
  }
5036
5039
  }
5037
5040
  }
@@ -5042,7 +5045,7 @@ i18n.use(initReactI18next).init({
5042
5045
  resources: defaultResource,
5043
5046
  lng: "sharedui",
5044
5047
  fallbackLng: "sharedui",
5045
- defaultNS: DIALOG_ALERT_I18N_NAMESPACE,
5048
+ defaultNS: "translation",
5046
5049
  interpolation: {
5047
5050
  escapeValue: false
5048
5051
  // react already safes from xss
@@ -5073,7 +5076,7 @@ function DialogAlert({
5073
5076
  persistent = false
5074
5077
  }) {
5075
5078
  const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
5076
- const { t } = useTranslation(DIALOG_ALERT_I18N_NAMESPACE);
5079
+ const { t } = useTranslation();
5077
5080
  const handleCancel = useCallback(() => {
5078
5081
  onCancel?.();
5079
5082
  onOpenChange(false);
@@ -5268,6 +5271,10 @@ var useDialogAlertStore = create((set, get) => ({
5268
5271
  let templateVal;
5269
5272
  if (payload?.template) {
5270
5273
  templateVal = getDialogTemplates({ setOpen: get().setOpen })[payload.template];
5274
+ templateVal.title = templateVal.title ? i18nPrefix + templateVal.title : void 0;
5275
+ templateVal.description = templateVal.description ? i18nPrefix + templateVal.description : void 0;
5276
+ templateVal.confirmText = templateVal.confirmText ? i18nPrefix + templateVal.confirmText : void 0;
5277
+ templateVal.cancelText = templateVal.cancelText ? i18nPrefix + templateVal.cancelText : void 0;
5271
5278
  }
5272
5279
  get().setDialogProps({ ...templateVal, ...payload?.props });
5273
5280
  get().setOpen(true);
@@ -5285,17 +5292,16 @@ var DialogAlertProvider = ({ children, i18nResource, i18nLang }) => {
5285
5292
  i18n_default.changeLanguage("sharedui");
5286
5293
  return;
5287
5294
  }
5288
- const langs = Object.keys(i18nResource);
5289
- for (const lang of langs) {
5290
- i18n_default.addResourceBundle(
5291
- lang,
5292
- DIALOG_ALERT_I18N_NAMESPACE,
5293
- i18nResource[lang][DIALOG_ALERT_I18N_NAMESPACE],
5294
- false,
5295
- true
5296
- );
5295
+ try {
5296
+ const langs = Object.keys(i18nResource);
5297
+ for (const lang of langs) {
5298
+ i18n_default.addResourceBundle(lang, "translation", i18nResource[lang]["translation"], false, true);
5299
+ }
5300
+ i18n_default.changeLanguage(i18nLang);
5301
+ } catch {
5302
+ i18n_default.changeLanguage("sharedui");
5303
+ return;
5297
5304
  }
5298
- i18n_default.changeLanguage(i18nLang);
5299
5305
  }, [i18nLang, i18nResource]);
5300
5306
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5301
5307
  children,
@@ -8673,6 +8679,6 @@ var CropperModal = ({
8673
8679
  );
8674
8680
  };
8675
8681
 
8676
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch_default as AdvanceSearch, arrow_default as ArrowIcon, Button, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CropperModal, CropperModalError, DIALOG_ALERT_I18N_NAMESPACE, DataTable_default as DataTable, DatePicker2 as DatePicker, Dialog, DialogAlert, DialogAlertProvider, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, Image2 as Image, 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, Spinner, 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, formatISODate, getDialogAlertControls, getDialogTemplates, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, spinnerVariants, 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 };
8682
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch_default as AdvanceSearch, arrow_default as ArrowIcon, Button, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CropperModal, CropperModalError, DIALOG_ALERT_I18N_SUBNAMESPACE, DataTable_default as DataTable, DatePicker2 as DatePicker, Dialog, DialogAlert, DialogAlertProvider, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, Image2 as Image, 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, Spinner, 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, formatISODate, getDialogAlertControls, getDialogTemplates, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, spinnerVariants, 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 };
8677
8683
  //# sourceMappingURL=index.mjs.map
8678
8684
  //# sourceMappingURL=index.mjs.map