@sustaina/shared-ui 1.27.1 → 1.29.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
@@ -5273,7 +5273,8 @@ var getDialogTemplates = ({ setOpen = () => {
5273
5273
  title: "error.session_expired.title",
5274
5274
  description: "error.session_expired.description",
5275
5275
  confirmText: "error.session_expired.confirm_text",
5276
- showCancel: false
5276
+ showCancel: false,
5277
+ persistent: true
5277
5278
  },
5278
5279
  "error.user_not_found": {
5279
5280
  variant: "error",
@@ -5400,9 +5401,17 @@ var getDialogTemplates = ({ setOpen = () => {
5400
5401
  var useDialogAlertStore = create((set, get) => ({
5401
5402
  open: false,
5402
5403
  dialogProps: {},
5403
- setOpen: (data) => set({ open: data }),
5404
+ setOpen: (open) => {
5405
+ if (!open && get().isExclusive) {
5406
+ get().setIsExclusive(false);
5407
+ }
5408
+ set({ open });
5409
+ },
5404
5410
  setDialogProps: (data) => set({ dialogProps: data }),
5405
5411
  openDialogAlert: (payload) => {
5412
+ if (get().isExclusive) {
5413
+ return;
5414
+ }
5406
5415
  let templateVal;
5407
5416
  if (payload?.template) {
5408
5417
  templateVal = getDialogTemplates({ setOpen: get().setOpen })[payload.template];
@@ -5413,10 +5422,13 @@ var useDialogAlertStore = create((set, get) => ({
5413
5422
  }
5414
5423
  get().setDialogProps({ ...templateVal, ...payload?.props });
5415
5424
  get().setOpen(true);
5425
+ get().setIsExclusive(payload?.isExclusive ?? false);
5416
5426
  },
5417
5427
  closeDialogAlert: () => {
5418
5428
  set({ open: false });
5419
- }
5429
+ },
5430
+ isExclusive: false,
5431
+ setIsExclusive: (isExclusive) => set({ isExclusive })
5420
5432
  }));
5421
5433
  var DialogAlertProvider = ({ children, i18nResource, i18nLang }) => {
5422
5434
  const open = useDialogAlertStore((state) => state.open);
@@ -5446,16 +5458,16 @@ var DialogAlertProvider = ({ children, i18nResource, i18nLang }) => {
5446
5458
  var openDialogAlert = useDialogAlertStore.getState().openDialogAlert;
5447
5459
  var closeDialogAlert = useDialogAlertStore.getState().closeDialogAlert;
5448
5460
  var openErrorDialogAlert = (error) => {
5449
- if (error instanceof Error) {
5450
- openDialogAlert({ template: "error.something_went_wrong", props: { description: error.message } });
5451
- } else if (error.isAxiosError) {
5461
+ if (error.isAxiosError) {
5452
5462
  let template = "error.something_went_wrong";
5463
+ let props = void 0;
5453
5464
  switch (error.response?.status) {
5454
5465
  case 400:
5455
5466
  template = "error.invalid_incomplete_data";
5456
5467
  break;
5457
5468
  case 401:
5458
5469
  template = "error.session_expired";
5470
+ props = { confirmText: void 0 };
5459
5471
  break;
5460
5472
  case 403:
5461
5473
  template = "error.permission_denied";
@@ -5470,7 +5482,9 @@ var openErrorDialogAlert = (error) => {
5470
5482
  template = "error.api_db_error";
5471
5483
  break;
5472
5484
  }
5473
- openDialogAlert({ template });
5485
+ openDialogAlert({ template, props });
5486
+ } else if (error instanceof Error) {
5487
+ openDialogAlert({ template: "error.something_went_wrong", props: { description: error.message } });
5474
5488
  } else {
5475
5489
  openDialogAlert({ template: "error.something_went_wrong" });
5476
5490
  }
@@ -6021,7 +6035,7 @@ var pushVariableAndInner = (tokens, value, prefixMap, prefixes) => {
6021
6035
  }
6022
6036
  cursor += prefix.length;
6023
6037
  const rest = value.slice(cursor);
6024
- const codeMatch = rest.match(/^\w+/);
6038
+ const codeMatch = rest.match(/^[\w-]+/);
6025
6039
  if (codeMatch) {
6026
6040
  tokens.push({ type: prefixMap[prefix], code: codeMatch[0] });
6027
6041
  cursor += codeMatch[0].length;
@@ -6050,7 +6064,7 @@ var tokenizeFormulaString = (raw, prefixMap) => {
6050
6064
  const prefix = findPrefixAt(raw, i, prefixes);
6051
6065
  if (prefix) {
6052
6066
  const rest = raw.slice(i + prefix.length);
6053
- const codeMatch = rest.match(/^\w+/);
6067
+ const codeMatch = rest.match(/^[\w-]+/);
6054
6068
  if (codeMatch) {
6055
6069
  flushBuffer();
6056
6070
  segments.push({ kind: "token", prefix, code: codeMatch[0] });
@@ -6074,7 +6088,7 @@ var parseFormulaToToken = (text, prefixMap) => {
6074
6088
  return tokens;
6075
6089
  }
6076
6090
  const afterPrefix = text.slice(leadingPrefix.length);
6077
- const codeMatch = afterPrefix.match(/^\w+/);
6091
+ const codeMatch = afterPrefix.match(/^[\w-]+/);
6078
6092
  if (!codeMatch) {
6079
6093
  pushVariableAndInner(tokens, text, prefixMap, prefixes);
6080
6094
  return tokens;