@tesouro/embedded-components-react 0.5.149 → 0.5.152

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.
@@ -7,55 +7,55 @@ import { useTagsQuery as n } from "../../data-access/dist/index2.js";
7
7
  import "../../data-access/dist/index.js";
8
8
  import { useCallback as r, useMemo as i, useState as a } from "react";
9
9
  //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index10.js
10
- function o({ keywordsByTagId: o, userNamesById: s }) {
11
- let [c, l] = a([{
10
+ function o({ keywordsByTagId: o, userNamesById: s, pageSizeOptions: c }) {
11
+ let [l, u] = a([{
12
12
  id: "createdAtLabel",
13
13
  desc: !0
14
- }]), [u, d] = a(10), [f, p] = a(), m = t(c[0]?.id), h = c[0]?.desc ? "desc" : "asc", g = n({
15
- sort: m,
16
- order: h,
17
- limit: u,
18
- pagination_token: f
19
- }), _ = i(() => e({
20
- tags: g.data?.data ?? [],
14
+ }]), [d, f] = a(() => c[0] ?? 10), [p, m] = a(), h = t(l[0]?.id), g = l[0]?.desc ? "desc" : "asc", _ = n({
15
+ sort: h,
16
+ order: g,
17
+ limit: d,
18
+ pagination_token: p
19
+ }), v = i(() => e({
20
+ tags: _.data?.data ?? [],
21
21
  keywordsByTagId: o,
22
22
  userNamesById: s
23
23
  }), [
24
- g.data,
24
+ _.data,
25
25
  o,
26
26
  s
27
- ]), v = r((e) => (g.data?.data ?? []).find((t) => t.id === e), [g.data]), y = r((e) => {
28
- let n = typeof e == "function" ? e(c) : e;
29
- l(n);
27
+ ]), y = r((e) => (_.data?.data ?? []).find((t) => t.id === e), [_.data]), b = r((e) => {
28
+ let n = typeof e == "function" ? e(l) : e;
29
+ u(n);
30
30
  let r = t(n[0]?.id), i = n[0]?.desc ? "desc" : "asc";
31
- (r !== m || i !== h) && p(void 0);
31
+ (r !== h || i !== g) && m(void 0);
32
32
  }, [
33
- c,
34
- m,
35
- h
36
- ]), b = r((e) => {
37
- d(e), p(void 0);
38
- }, []), x = r(() => {
39
- p(g.data?.next_pagination_token ?? void 0);
40
- }, [g.data?.next_pagination_token]), S = r(() => {
41
- p(g.data?.prev_pagination_token ?? void 0);
42
- }, [g.data?.prev_pagination_token]), C = r(() => {
43
- g.refetch();
44
- }, [g]);
33
+ l,
34
+ h,
35
+ g
36
+ ]), x = r((e) => {
37
+ f(e), m(void 0);
38
+ }, []), S = r(() => {
39
+ m(_.data?.next_pagination_token ?? void 0);
40
+ }, [_.data?.next_pagination_token]), C = r(() => {
41
+ m(_.data?.prev_pagination_token ?? void 0);
42
+ }, [_.data?.prev_pagination_token]), w = r(() => {
43
+ _.refetch();
44
+ }, [_]);
45
45
  return {
46
- rows: _,
47
- isLoading: g.isLoading,
48
- isError: g.isError,
49
- sorting: c,
50
- onSortingChange: y,
51
- pageSize: u,
52
- onPageSizeChange: b,
53
- hasNextPage: !!g.data?.next_pagination_token,
54
- hasPrevPage: !!g.data?.prev_pagination_token,
55
- onNextPage: x,
56
- onPrevPage: S,
57
- onRetry: C,
58
- findTag: v
46
+ rows: v,
47
+ isLoading: _.isLoading,
48
+ isError: _.isError,
49
+ sorting: l,
50
+ onSortingChange: b,
51
+ pageSize: d,
52
+ onPageSizeChange: x,
53
+ hasNextPage: !!_.data?.next_pagination_token,
54
+ hasPrevPage: !!_.data?.prev_pagination_token,
55
+ onNextPage: S,
56
+ onPrevPage: C,
57
+ onRetry: w,
58
+ findTag: y
59
59
  };
60
60
  }
61
61
  //#endregion
@@ -2,7 +2,7 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { TAG_MESSAGE_LABELS_EN as e } from "./index5.js";
5
+ import { TAGS_MESSAGE_LABELS_EN as e } from "./index5.js";
6
6
  import { hasSelectedText as t } from "./index6.js";
7
7
  import { useEntitySettings as n } from "./index7.js";
8
8
  import { useTagDelete as r } from "./index8.js";
@@ -10,47 +10,49 @@ import { useTagForm as i } from "./index9.js";
10
10
  import { useTagsTable as a } from "./index10.js";
11
11
  import { useCallback as o, useMemo as s, useState as c } from "react";
12
12
  //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index11.js
13
- function l({ messageLabels: l, canWrite: u, canMutate: d }) {
14
- let f = s(() => ({
13
+ function l({ messageLabels: l, canWrite: u, canMutate: d, pageSizeOptions: f }) {
14
+ let p = s(() => ({
15
15
  ...e,
16
16
  ...l
17
- }), [l]), [p, m] = c(), h = n({ messages: f }), g = a({
18
- keywordsByTagId: h.keywordsByTagId,
19
- userNamesById: h.userNamesById
20
- }), _ = i({
21
- selectedTag: p,
22
- setSelectedTag: m,
23
- settings: h,
24
- messages: f,
17
+ }), [l]), [m, h] = c(), g = n({ messages: p }), _ = a({
18
+ keywordsByTagId: g.keywordsByTagId,
19
+ userNamesById: g.userNamesById,
20
+ pageSizeOptions: f
21
+ }), v = i({
22
+ selectedTag: m,
23
+ setSelectedTag: h,
24
+ settings: g,
25
+ messages: p,
25
26
  canWrite: u,
26
27
  canMutate: d
27
- }), v = r({
28
- selectedTag: p,
29
- setSelectedTag: m,
30
- settings: h,
28
+ }), y = r({
29
+ selectedTag: m,
30
+ setSelectedTag: h,
31
+ settings: g,
31
32
  canWrite: u,
32
- canMutate: d
33
+ canMutate: d,
34
+ messages: p
33
35
  });
34
36
  return {
35
- selectedTag: p,
36
- table: g,
37
- form: _,
38
- del: v,
37
+ selectedTag: m,
38
+ table: _,
39
+ form: v,
40
+ del: y,
39
41
  handleRowClick: o((e) => {
40
42
  if (t()) return;
41
- let n = g.findTag(e.id);
42
- n && _.openEdit(n);
43
- }, [g, _]),
43
+ let n = _.findTag(e.id);
44
+ n && v.openEdit(n);
45
+ }, [_, v]),
44
46
  handleDeleteClick: o((e) => {
45
- let t = g.findTag(e.id);
46
- t && v.requestDelete(t);
47
- }, [g, v]),
47
+ let t = _.findTag(e.id);
48
+ t && y.requestDelete(t);
49
+ }, [_, y]),
48
50
  handleFormDelete: o(() => {
49
- _.close(), p && v.requestDelete(p);
51
+ v.close(), m && y.requestDelete(m);
50
52
  }, [
51
- _,
52
- p,
53
- v
53
+ v,
54
+ m,
55
+ y
54
56
  ])
55
57
  };
56
58
  }
@@ -2,91 +2,96 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { useAnalyticsTrack as e } from "../../../../shared/feature/dist/lib/analytics/hooks.js";
6
- import { WidgetProvider as t } from "../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
7
- import { useWidgetConfig as n, useWidgetInitStaleForToken as r } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
5
+ import { EmbeddedToaster as e } from "../../../../shared/ui/dist/lib/EmbeddedToaster.js";
6
+ import "../../../../shared/ui/dist/index.js";
7
+ import { useAnalyticsTrack as t } from "../../../../shared/feature/dist/lib/analytics/hooks.js";
8
+ import { WidgetProvider as n } from "../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
9
+ import { useWidgetConfig as r, useWidgetInitStaleForToken as i } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
8
10
  import "../../../../shared/feature/dist/index.js";
9
- import { TagsWidgetAnalyticsEvent as i, WIDGET_NAME as a } from "./index2.js";
10
- import { getTagsPermissions as o } from "./index3.js";
11
- import { PAGE_SIZE_OPTIONS as s } from "./index4.js";
12
- import { useTagsWidget as c } from "./index11.js";
13
- import { TagsScreen as l } from "../../ui/dist/index3.js";
14
- import { TagDeleteDialog as u } from "../../ui/dist/index4.js";
15
- import { TagFormSheet as d } from "../../ui/dist/index5.js";
11
+ import { TagsWidgetAnalyticsEvent as a, WIDGET_NAME as o } from "./index2.js";
12
+ import { getTagsPermissions as s } from "./index3.js";
13
+ import { PAGE_SIZE_OPTIONS as c } from "./index4.js";
14
+ import { useTagsWidget as l } from "./index11.js";
15
+ import { TagsScreen as u } from "../../ui/dist/index3.js";
16
+ import { TagDeleteDialog as d } from "../../ui/dist/index4.js";
17
+ import { TagFormSheet as f } from "../../ui/dist/index5.js";
16
18
  import "../../ui/dist/index.js";
17
- import { useEffect as f, useMemo as p } from "react";
18
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
19
+ import { useEffect as p, useMemo as m } from "react";
20
+ import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
19
21
  //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index12.js
20
- function _({ pageSizeOptions: t = s, screenLabels: a, formLabels: _, deleteLabels: v, messageLabels: y }) {
21
- let b = e();
22
- f(() => {
23
- b(i.Mounted);
24
- }, [b]);
25
- let { initResponse: x } = n(), S = r(), { canWrite: C } = p(() => o(x?.scopes), [x?.scopes]), { selectedTag: w, table: T, form: E, del: D, handleRowClick: O, handleDeleteClick: k, handleFormDelete: A } = c({
26
- messageLabels: y,
27
- canWrite: C,
28
- canMutate: C && !S
22
+ function v({ pageSizeOptions: n = c, screenLabels: o, formLabels: v, deleteLabels: y, messageLabels: b }) {
23
+ let x = t();
24
+ p(() => {
25
+ x(a.Mounted);
26
+ }, [x]);
27
+ let { initResponse: S } = r(), C = i(), { canWrite: w } = m(() => s(S?.scopes), [S?.scopes]), { selectedTag: T, table: E, form: D, del: O, handleRowClick: k, handleDeleteClick: A, handleFormDelete: j } = l({
28
+ messageLabels: b,
29
+ canWrite: w,
30
+ canMutate: w && !C,
31
+ pageSizeOptions: n
29
32
  });
30
- return /* @__PURE__ */ g(m, { children: [
31
- /* @__PURE__ */ h(l, {
32
- tags: T.rows,
33
- isLoading: T.isLoading,
34
- isError: T.isError,
35
- sorting: T.sorting,
36
- onSortingChange: T.onSortingChange,
37
- pageSize: T.pageSize,
38
- onPageSizeChange: T.onPageSizeChange,
39
- pageSizeOptions: t,
40
- hasNextPage: T.hasNextPage,
41
- hasPrevPage: T.hasPrevPage,
42
- onNextPage: T.onNextPage,
43
- onPrevPage: T.onPrevPage,
44
- onCreateClick: C ? E.openCreate : void 0,
45
- onRowClick: C ? O : void 0,
46
- onDeleteClick: C ? k : void 0,
47
- onRetry: T.onRetry,
48
- labels: a,
33
+ return /* @__PURE__ */ _(h, { children: [
34
+ /* @__PURE__ */ g(e, {}),
35
+ /* @__PURE__ */ g(u, {
36
+ tags: E.rows,
37
+ isLoading: E.isLoading,
38
+ isError: E.isError,
39
+ sorting: E.sorting,
40
+ onSortingChange: E.onSortingChange,
41
+ pageSize: E.pageSize,
42
+ onPageSizeChange: E.onPageSizeChange,
43
+ pageSizeOptions: n,
44
+ hasNextPage: E.hasNextPage,
45
+ hasPrevPage: E.hasPrevPage,
46
+ onNextPage: E.onNextPage,
47
+ onPrevPage: E.onPrevPage,
48
+ onCreateClick: w ? D.openCreate : void 0,
49
+ onRowClick: w ? k : void 0,
50
+ onDeleteClick: w ? A : void 0,
51
+ onRetry: E.onRetry,
52
+ labels: o,
49
53
  emptyStateTestId: "tags-widget-empty-state"
50
54
  }),
51
- /* @__PURE__ */ h(d, {
52
- open: E.open,
53
- onOpenChange: E.onOpenChange,
54
- mode: E.mode,
55
- values: E.values,
56
- errors: E.errors,
57
- categoryOptions: E.categoryOptions,
58
- tagName: w?.name,
59
- inProgress: E.isSubmitting || S,
60
- showDelete: C,
61
- onNameChange: E.onNameChange,
62
- onCategoryChange: E.onCategoryChange,
63
- onKeywordsChange: E.onKeywordsChange,
64
- onKeywordsInputChange: E.onKeywordsInputChange,
65
- onSubmit: E.submit,
66
- onCancel: E.close,
67
- onDelete: A,
68
- labels: _
69
- }),
70
- /* @__PURE__ */ h(u, {
55
+ /* @__PURE__ */ g(f, {
71
56
  open: D.open,
72
57
  onOpenChange: D.onOpenChange,
73
- tagName: w?.name ?? "",
74
- isDeleting: D.isDeleting,
75
- confirmDisabled: S,
76
- onConfirm: D.confirm,
77
- onCancel: D.cancel,
58
+ mode: D.mode,
59
+ values: D.values,
60
+ errors: D.errors,
61
+ categoryOptions: D.categoryOptions,
62
+ tagName: T?.name,
63
+ inProgress: D.isSubmitting || C,
64
+ showDelete: w,
65
+ onNameChange: D.onNameChange,
66
+ onCategoryChange: D.onCategoryChange,
67
+ onKeywordsChange: D.onKeywordsChange,
68
+ onKeywordsInputChange: D.onKeywordsInputChange,
69
+ onSubmit: D.submit,
70
+ onCancel: D.close,
71
+ onDelete: j,
78
72
  labels: v
73
+ }),
74
+ /* @__PURE__ */ g(d, {
75
+ open: O.open,
76
+ onOpenChange: O.onOpenChange,
77
+ tagName: T?.name ?? "",
78
+ isDeleting: O.isDeleting,
79
+ error: O.error,
80
+ confirmDisabled: O.confirmDisabled || C,
81
+ onConfirm: O.confirm,
82
+ onCancel: O.cancel,
83
+ labels: y
79
84
  })
80
85
  ] });
81
86
  }
82
- function v({ baseUrl: e, widgetToken: n, organizationId: r, configClient: i, gatewayRouting: o, linkComponent: s, implementation: c, uiFramework: l, errorFallback: u, onError: d, analytics: f, disclosuresAcceptance: p, providerLabels: m, ...g }) {
83
- return /* @__PURE__ */ h(t, {
84
- widgetName: a,
87
+ function y({ baseUrl: e, widgetToken: t, organizationId: r, configClient: i, gatewayRouting: a, linkComponent: s, implementation: c, uiFramework: l, errorFallback: u, onError: d, analytics: f, disclosuresAcceptance: p, providerLabels: m, ...h }) {
88
+ return /* @__PURE__ */ g(n, {
89
+ widgetName: o,
85
90
  baseUrl: e,
86
- widgetToken: n,
91
+ widgetToken: t,
87
92
  organizationId: r,
88
93
  configClient: i,
89
- gatewayRouting: o,
94
+ gatewayRouting: a,
90
95
  linkComponent: s,
91
96
  implementation: c,
92
97
  uiFramework: l,
@@ -95,8 +100,8 @@ function v({ baseUrl: e, widgetToken: n, organizationId: r, configClient: i, gat
95
100
  analytics: f,
96
101
  disclosuresAcceptance: p,
97
102
  providerLabels: m,
98
- children: /* @__PURE__ */ h(_, { ...g })
103
+ children: /* @__PURE__ */ g(v, { ...h })
99
104
  });
100
105
  }
101
106
  //#endregion
102
- export { v as TagsWidget, v as default };
107
+ export { y as TagsWidget, y as default };
@@ -8,6 +8,14 @@ var e = {
8
8
  duplicateName: "A tag with this name already exists.",
9
9
  keywordsNotSaved: "The tag was saved, but its keywords were not. Save again to finish."
10
10
  }, t = {
11
+ ...e,
12
+ tagCreated: "Tag “{name}” created",
13
+ tagUpdated: "Tag “{name}” updated",
14
+ tagDeleted: "Tag “{name}” deleted",
15
+ deleteError: "Could not delete this tag. Please try again.",
16
+ keywordCleanupError: "Tag “{name}” was deleted, but its OCR keywords could not be removed.",
17
+ keywordSyncError: "Tag “{name}” was saved, but its OCR keywords were not."
18
+ }, n = {
11
19
  document_type: "Document Type",
12
20
  department: "Department",
13
21
  project: "Project",
@@ -17,4 +25,4 @@ var e = {
17
25
  approval_status: "Approval Status"
18
26
  };
19
27
  //#endregion
20
- export { t as TAG_CATEGORY_LABELS_EN, e as TAG_MESSAGE_LABELS_EN };
28
+ export { t as TAGS_MESSAGE_LABELS_EN, n as TAG_CATEGORY_LABELS_EN, e as TAG_MESSAGE_LABELS_EN };
@@ -8,42 +8,46 @@ var r = {
8
8
  function i(e) {
9
9
  return e && r[e] || "created_at";
10
10
  }
11
- var a = new Intl.DateTimeFormat(void 0, {
11
+ var a = {
12
12
  year: "numeric",
13
13
  month: "short",
14
14
  day: "numeric"
15
- });
16
- function o(e) {
15
+ };
16
+ function o(e, t) {
17
+ return e.replace("{name}", () => t);
18
+ }
19
+ var s;
20
+ function c(e) {
17
21
  if (!e) return "";
18
22
  let t = new Date(e);
19
- return Number.isNaN(t.getTime()) ? "" : a.format(t);
23
+ return Number.isNaN(t.getTime()) ? "" : (s ??= new Intl.DateTimeFormat(void 0, a), s.format(t));
20
24
  }
21
- function s() {
25
+ function l() {
22
26
  let e = globalThis.getSelection?.();
23
27
  return !!(e && e.toString().length > 0);
24
28
  }
25
- function c(e) {
29
+ function u(e) {
26
30
  let t = {};
27
31
  for (let n of e ?? []) t[n.tag_id] = n.keywords;
28
32
  return t;
29
33
  }
30
- function l(e) {
34
+ function d(e) {
31
35
  let t = {};
32
36
  for (let n of e ?? []) t[n.id] = `${n.first_name ?? ""} ${n.last_name ?? ""}`.trim();
33
37
  return t;
34
38
  }
35
- function u({ tags: e, keywordsByTagId: t, userNamesById: n }) {
39
+ function f({ tags: e, keywordsByTagId: t, userNamesById: n }) {
36
40
  return e.map((e) => ({
37
41
  id: e.id,
38
42
  name: e.name,
39
- categoryLabel: p(e.category),
43
+ categoryLabel: h(e.category),
40
44
  keywords: (t[e.id] ?? []).join(", "),
41
- createdAtLabel: o(e.created_at),
42
- updatedAtLabel: o(e.updated_at),
45
+ createdAtLabel: c(e.created_at),
46
+ updatedAtLabel: c(e.updated_at),
43
47
  createdByLabel: e.created_by_entity_user_id ? n[e.created_by_entity_user_id] ?? "" : ""
44
48
  }));
45
49
  }
46
- function d(e, t, n) {
50
+ function p(e, t, n) {
47
51
  let r = e ?? [], i = r.filter((e) => e.tag_id !== t), a = Array.from(new Set(n));
48
52
  return i.length === r.length && a.length === 0 ? {
49
53
  changed: !1,
@@ -57,7 +61,7 @@ function d(e, t, n) {
57
61
  }] : i
58
62
  };
59
63
  }
60
- var f = [
64
+ var m = [
61
65
  "document_type",
62
66
  "department",
63
67
  "project",
@@ -66,30 +70,30 @@ var f = [
66
70
  "payment_method",
67
71
  "approval_status"
68
72
  ];
69
- function p(e, n) {
73
+ function h(e, n) {
70
74
  return e ? n?.[e] ?? t[e] ?? "" : "";
71
75
  }
72
- function m(e) {
73
- return f.map((t) => ({
76
+ function g(e) {
77
+ return m.map((t) => ({
74
78
  value: t,
75
- label: p(t, e)
79
+ label: h(t, e)
76
80
  }));
77
81
  }
78
- function h(e, t = n) {
82
+ function _(e, t = n) {
79
83
  let r = {}, i = e.name.trim();
80
84
  i.length === 0 ? r.name = t.nameRequired : i.length > 255 && (r.name = t.nameTooLong);
81
85
  let a = e.keywords.some((e) => e.length < 2), o = e.keywords.some((e) => e.length > 25);
82
86
  return a ? r.keywords = t.keywordTooShort : o && (r.keywords = t.keywordTooLong), r;
83
87
  }
84
- function g(e) {
88
+ function v(e) {
85
89
  return !!(e.name || e.keywords);
86
90
  }
87
- function _(e) {
91
+ function y(e) {
88
92
  return e === "This tag already exists.";
89
93
  }
90
- function v(t, r = n, { preferApiMessage: i = !1 } = {}) {
94
+ function b(t, r = n, { preferApiMessage: i = !1 } = {}) {
91
95
  let a = e(t);
92
- return _(a) ? { name: r.duplicateName } : { form: (i ? a : void 0) ?? r.genericError };
96
+ return y(a) ? { name: r.duplicateName } : { form: (i ? a : void 0) ?? r.genericError };
93
97
  }
94
98
  //#endregion
95
- export { f as TAG_CATEGORIES, c as buildKeywordsByTagId, u as buildTagRows, l as buildUserNamesById, d as computeNextOcrAutoTagging, o as formatTagDate, m as getCategoryOptions, p as getTagCategoryLabel, g as hasFormErrors, s as hasSelectedText, _ as isDuplicateTagNameError, v as resolveTagSubmitError, i as sortFieldForColumn, h as validateTagForm };
99
+ export { m as TAG_CATEGORIES, u as buildKeywordsByTagId, f as buildTagRows, d as buildUserNamesById, p as computeNextOcrAutoTagging, c as formatTagDate, g as getCategoryOptions, h as getTagCategoryLabel, v as hasFormErrors, l as hasSelectedText, y as isDuplicateTagNameError, b as resolveTagSubmitError, i as sortFieldForColumn, _ as validateTagForm, o as withTagName };
@@ -7,22 +7,30 @@ import { useMyEntityQuery as n } from "../../data-access/dist/index7.js";
7
7
  import { useEntitySettingsQuery as r } from "../../data-access/dist/index8.js";
8
8
  import { useEntityUsersQuery as i } from "../../data-access/dist/index10.js";
9
9
  import "../../data-access/dist/index.js";
10
- import { useCallback as a, useMemo as o } from "react";
10
+ import { useCallback as a, useMemo as o, useRef as s, useState as c } from "react";
11
11
  //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index7.js
12
- function s({ messages: s }) {
13
- let c = n().data?.id, l = r(c), u = i(), d = o(() => e(l.data?.payables_ocr_auto_tagging), [l.data]), f = o(() => t(u.data?.data), [u.data]), p = a(async () => (await l.refetch()).data ?? l.data, [l]), m = a(async () => {
14
- let e = await p();
15
- if (!e) throw Error(s.genericError);
12
+ function l({ messages: l }) {
13
+ let u = n().data?.id, d = r(u), f = i(), p = o(() => e(d.data?.payables_ocr_auto_tagging), [d.data]), m = o(() => t(f.data?.data), [f.data]), h = a(async () => (await d.refetch()).data ?? d.data, [d]), g = s(Promise.resolve()), _ = s(0), [v, y] = c(!1), b = a((e) => {
14
+ _.current += 1, y(!0);
15
+ let t = g.current.then(e, e), n = () => {
16
+ --_.current, _.current === 0 && y(!1);
17
+ };
18
+ return g.current = t.then(n, n), t;
19
+ }, []), x = a(async () => {
20
+ let e = await h();
21
+ if (!e) throw Error(l.genericError);
16
22
  return e;
17
- }, [s.genericError, p]);
23
+ }, [l.genericError, h]);
18
24
  return {
19
- entityId: c,
20
- keywordsByTagId: d,
21
- userNamesById: f,
22
- settingsData: l.data,
23
- refetchSettings: p,
24
- requireFreshSettings: m
25
+ entityId: u,
26
+ keywordsByTagId: p,
27
+ userNamesById: m,
28
+ settingsData: d.data,
29
+ refetchSettings: h,
30
+ requireFreshSettings: x,
31
+ withSettingsLock: b,
32
+ settingsBusy: v
25
33
  };
26
34
  }
27
35
  //#endregion
28
- export { s as useEntitySettings };
36
+ export { l as useEntitySettings };
@@ -2,63 +2,79 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { computeNextOcrAutoTagging as e } from "./index6.js";
6
- import { useDeleteTagMutation as t } from "../../data-access/dist/index6.js";
7
- import { useUpdateEntitySettingsMutation as n } from "../../data-access/dist/index9.js";
5
+ import { toast as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import "../../../../shared/ui/dist/index.js";
7
+ import { extractApiErrorMessage as t } from "../../../../shared/util/dist/lib/apiErrors.js";
8
+ import { computeNextOcrAutoTagging as n, withTagName as r } from "./index6.js";
9
+ import { useDeleteTagMutation as i } from "../../data-access/dist/index6.js";
10
+ import { useUpdateEntitySettingsMutation as a } from "../../data-access/dist/index9.js";
8
11
  import "../../data-access/dist/index.js";
9
- import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
12
+ import { useCallback as o, useEffect as s, useRef as c, useState as l } from "react";
10
13
  //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index8.js
11
- function s({ selectedTag: s, setSelectedTag: c, settings: l, canWrite: u, canMutate: d }) {
12
- let { entityId: f, requireFreshSettings: p } = l, m = t(), h = n(), [g, _] = o(!1), v = a(0), y = r(() => {
13
- v.current += 1;
14
- }, []);
15
- i(() => {
16
- u || (y(), _(!1));
17
- }, [u, y]);
18
- let b = a(d);
19
- b.current = d;
20
- let x = r((e) => {
21
- u && (y(), c(e), _(!0));
14
+ function u({ selectedTag: u, setSelectedTag: d, settings: f, messages: p, canWrite: m, canMutate: h }) {
15
+ let { entityId: g, requireFreshSettings: _, withSettingsLock: v, settingsBusy: y } = f, b = i(), x = a(), [S, C] = l(!1), [w, T] = l(), E = c(0), D = o(() => {
16
+ E.current += 1;
17
+ }, []), O = c(h);
18
+ O.current = h, s(() => {
19
+ m || (D(), C(!1));
20
+ }, [m, D]);
21
+ let k = o((e) => {
22
+ m && (D(), d(e), T(void 0), C(!0));
22
23
  }, [
23
- u,
24
- y,
25
- c
26
- ]), S = r((e) => {
27
- e || (y(), _(!1));
28
- }, [y]), C = r(() => {
29
- y(), _(!1);
30
- }, [y]);
24
+ m,
25
+ D,
26
+ d
27
+ ]), A = o((e) => {
28
+ e || (D(), T(void 0), C(!1));
29
+ }, [D]), j = o(() => {
30
+ D(), T(void 0), C(!1);
31
+ }, [D]);
31
32
  return {
32
- open: g,
33
- requestDelete: x,
34
- onOpenChange: S,
35
- confirm: r(async () => {
36
- if (!d || !s) return;
37
- let t = v.current, n = () => v.current === t;
38
- try {
39
- let t = f ? await p() : void 0;
40
- if (!b.current) return;
41
- if (await m.mutateAsync({ path: { tag_id: s.id } }), f && t) {
42
- let { changed: n, next: r } = e(t.payables_ocr_auto_tagging, s.id, []);
43
- n && b.current && await h.mutateAsync({
44
- path: { entity_id: f },
45
- body: { payables_ocr_auto_tagging: r }
33
+ open: S,
34
+ error: w,
35
+ requestDelete: k,
36
+ onOpenChange: A,
37
+ confirm: o(async () => {
38
+ if (!h || !u) return;
39
+ let i = u;
40
+ T(void 0);
41
+ let a = E.current, o = () => E.current === a;
42
+ await v(async () => {
43
+ let a;
44
+ try {
45
+ if (a = g ? await _() : void 0, !O.current) return;
46
+ await b.mutateAsync({ path: { tag_id: i.id } });
47
+ } catch (n) {
48
+ let r = t(n) ?? p.deleteError;
49
+ o() ? T(r) : e.error(r);
50
+ return;
51
+ }
52
+ if (e.success(r(p.tagDeleted, i.name)), o() && (C(!1), d(void 0)), !g || !a) return;
53
+ let { changed: s, next: c } = n(a.payables_ocr_auto_tagging, i.id, []);
54
+ if (s && O.current) try {
55
+ await x.mutateAsync({
56
+ path: { entity_id: g },
57
+ body: { payables_ocr_auto_tagging: c }
46
58
  });
59
+ } catch {
60
+ e.error(r(p.keywordCleanupError, i.name));
47
61
  }
48
- n() && (_(!1), c(void 0));
49
- } catch {}
62
+ });
50
63
  }, [
51
- d,
52
- s,
53
- f,
54
- p,
55
- m,
56
64
  h,
57
- c
65
+ u,
66
+ g,
67
+ _,
68
+ v,
69
+ b,
70
+ x,
71
+ d,
72
+ p
58
73
  ]),
59
- cancel: C,
60
- isDeleting: m.isPending
74
+ cancel: j,
75
+ isDeleting: b.isPending,
76
+ confirmDisabled: y
61
77
  };
62
78
  }
63
79
  //#endregion
64
- export { s as useTagDelete };
80
+ export { u as useTagDelete };
@@ -2,130 +2,145 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { EMPTY_FORM_VALUES as e } from "./index4.js";
6
- import { buildKeywordsByTagId as t, computeNextOcrAutoTagging as n, getCategoryOptions as r, hasFormErrors as i, resolveTagSubmitError as a, validateTagForm as o } from "./index6.js";
7
- import { useCreateTagMutation as s } from "../../data-access/dist/index4.js";
8
- import { useUpdateTagMutation as c } from "../../data-access/dist/index5.js";
9
- import { useUpdateEntitySettingsMutation as l } from "../../data-access/dist/index9.js";
5
+ import { toast as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import "../../../../shared/ui/dist/index.js";
7
+ import { EMPTY_FORM_VALUES as t } from "./index4.js";
8
+ import { buildKeywordsByTagId as n, computeNextOcrAutoTagging as r, getCategoryOptions as i, hasFormErrors as a, resolveTagSubmitError as o, validateTagForm as s, withTagName as c } from "./index6.js";
9
+ import { useCreateTagMutation as l } from "../../data-access/dist/index4.js";
10
+ import { useUpdateTagMutation as u } from "../../data-access/dist/index5.js";
11
+ import { useUpdateEntitySettingsMutation as d } from "../../data-access/dist/index9.js";
10
12
  import "../../data-access/dist/index.js";
11
- import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
13
+ import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
12
14
  //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index9.js
13
- function h({ selectedTag: h, setSelectedTag: g, settings: _, messages: v, canWrite: y, canMutate: b }) {
14
- let { entityId: x, settingsData: S, refetchSettings: C, requireFreshSettings: w } = _, T = s(), E = c(), D = l(), [O, k] = m(!1), [A, j] = m("create"), [M, N] = m(e), [P, F] = m({}), I = f(() => r(), []), L = p(0), R = T.isPending || E.isPending || D.isPending, z = u(() => {
15
- L.current += 1;
15
+ function _({ selectedTag: _, setSelectedTag: v, settings: y, messages: b, canWrite: x, canMutate: S }) {
16
+ let { entityId: C, settingsData: w, refetchSettings: T, requireFreshSettings: E, withSettingsLock: D, settingsBusy: O } = y, k = l(), A = u(), j = d(), [M, N] = g(!1), [P, F] = g("create"), [I, L] = g(t), [R, z] = g({}), B = m(() => i(), []), V = h(0), H = O || k.isPending || A.isPending || j.isPending, U = f(() => {
17
+ V.current += 1;
16
18
  }, []);
17
- d(() => {
18
- y || k(!1);
19
- }, [y]);
20
- let B = p(y);
21
- B.current = y;
22
- let V = p(b);
23
- return V.current = b, {
24
- open: O,
25
- mode: A,
26
- values: M,
27
- errors: P,
28
- categoryOptions: I,
29
- isSubmitting: R,
30
- openCreate: u(() => {
31
- y && (z(), j("create"), g(void 0), N(e), F({}), k(!0));
19
+ p(() => {
20
+ x || (U(), N(!1));
21
+ }, [x, U]);
22
+ let W = h(x);
23
+ W.current = x;
24
+ let G = h(S);
25
+ return G.current = S, {
26
+ open: M,
27
+ mode: P,
28
+ values: I,
29
+ errors: R,
30
+ categoryOptions: B,
31
+ isSubmitting: H,
32
+ openCreate: f(() => {
33
+ x && (U(), F("create"), v(void 0), L(t), z({}), N(!0));
32
34
  }, [
33
- y,
34
- z,
35
- g
35
+ x,
36
+ U,
37
+ v
36
38
  ]),
37
- openEdit: u((e) => {
38
- y && (z(), (async () => {
39
- let n = S ?? await C();
40
- if (!B.current) return;
41
- let r = t(n?.payables_ocr_auto_tagging);
42
- g(e), j("edit"), N({
39
+ openEdit: f((e) => {
40
+ if (!x) return;
41
+ U();
42
+ let t = V.current;
43
+ (async () => {
44
+ let r = w ?? await T();
45
+ if (!W.current || V.current !== t) return;
46
+ let i = n(r?.payables_ocr_auto_tagging);
47
+ v(e), F("edit"), L({
43
48
  name: e.name,
44
49
  category: e.category ?? "",
45
- keywords: r[e.id] ?? [],
50
+ keywords: i[e.id] ?? [],
46
51
  keywordsInput: ""
47
- }), F({}), k(!0);
48
- })());
52
+ }), z({}), N(!0);
53
+ })();
49
54
  }, [
50
- y,
51
- z,
52
- S,
53
- C,
54
- g
55
+ x,
56
+ U,
57
+ w,
58
+ T,
59
+ v
55
60
  ]),
56
- onOpenChange: u((e) => {
57
- e || (z(), k(!1));
58
- }, [z]),
59
- close: u(() => {
60
- z(), k(!1);
61
- }, [z]),
62
- onNameChange: u((e) => N((t) => ({
61
+ onOpenChange: f((e) => {
62
+ e || (U(), N(!1));
63
+ }, [U]),
64
+ close: f(() => {
65
+ U(), N(!1);
66
+ }, [U]),
67
+ onNameChange: f((e) => L((t) => ({
63
68
  ...t,
64
69
  name: e
65
70
  })), []),
66
- onCategoryChange: u((e) => N((t) => ({
71
+ onCategoryChange: f((e) => L((t) => ({
67
72
  ...t,
68
73
  category: e
69
74
  })), []),
70
- onKeywordsChange: u((e) => N((t) => ({
75
+ onKeywordsChange: f((e) => L((t) => ({
71
76
  ...t,
72
77
  keywords: e
73
78
  })), []),
74
- onKeywordsInputChange: u((e) => N((t) => ({
79
+ onKeywordsInputChange: f((e) => L((t) => ({
75
80
  ...t,
76
81
  keywordsInput: e
77
82
  })), []),
78
- submit: u(async () => {
79
- if (!b) return;
80
- let e = o(M, v);
81
- if (i(e)) {
82
- F(e);
83
+ submit: f(async () => {
84
+ if (!S) return;
85
+ let t = s(I, b);
86
+ if (a(t)) {
87
+ z(t);
83
88
  return;
84
89
  }
85
- F({});
86
- let t = M.name.trim(), r = M.category === "" ? void 0 : M.category, s = {
87
- name: t,
88
- ...r ? { category: r } : {}
89
- }, c = L.current, l = () => L.current === c;
90
- try {
91
- let e = M.keywords.length > 0 || A === "edit", t = x && e ? await w() : void 0;
92
- if (!V.current) return;
93
- let r = A === "edit" && h ? await E.mutateAsync({
94
- path: { tag_id: h.id },
95
- body: s
96
- }) : await T.mutateAsync({ body: s });
97
- if (x && t) {
98
- let { changed: e, next: i } = n(t.payables_ocr_auto_tagging, r.id, M.keywords);
99
- if (e) {
100
- if (!V.current) {
101
- l() && (g(r), j("edit"), F({ form: v.keywordsNotSaved }));
102
- return;
90
+ z({});
91
+ let n = I.name.trim(), i = I.category === "" ? void 0 : I.category, l = {
92
+ name: n,
93
+ ...i ? { category: i } : {}
94
+ }, u = V.current, d = () => V.current === u, f = (t) => {
95
+ d() ? (v(t), F("edit"), z({ form: b.keywordsNotSaved })) : e.error(c(b.keywordSyncError, n));
96
+ }, p;
97
+ await D(async () => {
98
+ try {
99
+ let t = I.keywords.length > 0 || P === "edit", i = C && t ? await E() : void 0;
100
+ if (!G.current) return;
101
+ let a = P === "edit" && _ ? await A.mutateAsync({
102
+ path: { tag_id: _.id },
103
+ body: l
104
+ }) : await k.mutateAsync({ body: l });
105
+ if (p = a, C && i) {
106
+ let { changed: e, next: t } = r(i.payables_ocr_auto_tagging, a.id, I.keywords);
107
+ if (e) {
108
+ if (!G.current) {
109
+ f(a);
110
+ return;
111
+ }
112
+ await j.mutateAsync({
113
+ path: { entity_id: C },
114
+ body: { payables_ocr_auto_tagging: t }
115
+ });
103
116
  }
104
- await D.mutateAsync({
105
- path: { entity_id: x },
106
- body: { payables_ocr_auto_tagging: i }
107
- });
108
117
  }
118
+ e.success(c(P === "edit" ? b.tagUpdated : b.tagCreated, n)), d() && N(!1);
119
+ } catch (t) {
120
+ if (p) {
121
+ f(p);
122
+ return;
123
+ }
124
+ let n = o(t, b, { preferApiMessage: !0 });
125
+ d() ? z(n) : e.error(n.form ?? n.name ?? b.genericError);
109
126
  }
110
- l() && k(!1);
111
- } catch (e) {
112
- l() && F(a(e, v, { preferApiMessage: !0 }));
113
- }
127
+ });
114
128
  }, [
115
- b,
116
- M,
129
+ S,
130
+ I,
131
+ P,
132
+ F,
133
+ v,
134
+ _,
135
+ C,
136
+ k,
117
137
  A,
118
138
  j,
119
- g,
120
- h,
121
- x,
122
- T,
139
+ b,
123
140
  E,
124
- D,
125
- v,
126
- w
141
+ D
127
142
  ])
128
143
  };
129
144
  }
130
145
  //#endregion
131
- export { h as useTagForm };
146
+ export { _ as useTagForm };
@@ -2,26 +2,34 @@ import { AlertDialog as e, AlertDialogContent as t, AlertDialogDescription as n,
2
2
  import { TAG_DELETE_DIALOG_LABELS_EN as s } from "./index2.js";
3
3
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
4
4
  //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/ui/dist/index4.js
5
- function u({ open: u, onOpenChange: d, tagName: f, isDeleting: p, confirmDisabled: m, onConfirm: h, onCancel: g, labels: _ }) {
6
- let v = {
5
+ function u({ open: u, onOpenChange: d, tagName: f, isDeleting: p, error: m, confirmDisabled: h, onConfirm: g, onCancel: _, labels: v }) {
6
+ let y = {
7
7
  ...s,
8
- ..._
8
+ ...v
9
9
  };
10
10
  return /* @__PURE__ */ c(e, {
11
11
  open: u,
12
12
  onOpenChange: d,
13
- children: /* @__PURE__ */ l(t, { children: [/* @__PURE__ */ l(i, { children: [/* @__PURE__ */ c(a, { children: v.title.replace("{name}", f) }), /* @__PURE__ */ c(n, { children: v.message })] }), /* @__PURE__ */ l(r, { children: [/* @__PURE__ */ c(o, {
14
- variant: "ghost",
15
- onClick: g,
16
- disabled: p,
17
- children: v.cancelButton
18
- }), /* @__PURE__ */ c(o, {
19
- variant: "destructive",
20
- onClick: h,
21
- disabled: p || m,
22
- loading: p,
23
- children: v.confirmButton
24
- })] })] })
13
+ children: /* @__PURE__ */ l(t, { children: [
14
+ /* @__PURE__ */ l(i, { children: [/* @__PURE__ */ c(a, { children: y.title.replace("{name}", f) }), /* @__PURE__ */ c(n, { children: y.message })] }),
15
+ m ? /* @__PURE__ */ c("p", {
16
+ role: "alert",
17
+ className: "ttw:text-sm ttw:text-destructive",
18
+ children: m
19
+ }) : null,
20
+ /* @__PURE__ */ l(r, { children: [/* @__PURE__ */ c(o, {
21
+ variant: "ghost",
22
+ onClick: _,
23
+ disabled: p,
24
+ children: y.cancelButton
25
+ }), /* @__PURE__ */ c(o, {
26
+ variant: "destructive",
27
+ onClick: g,
28
+ disabled: p || h,
29
+ loading: p,
30
+ children: y.confirmButton
31
+ })] })
32
+ ] })
25
33
  });
26
34
  }
27
35
  //#endregion
@@ -363,7 +363,10 @@ var Fe = e.object({
363
363
  "CANCELED",
364
364
  "DENIED"
365
365
  ]), ze = e.object({
366
+ canceled: e.union([e.int().min(-2147483648, { error: "Invalid value: Expected int32 to be >= -2147483648" }).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }), e.string().regex(/^-?(?:0|[1-9]\d*)$/)]).optional(),
366
367
  complete: e.union([e.int().min(-2147483648, { error: "Invalid value: Expected int32 to be >= -2147483648" }).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }), e.string().regex(/^-?(?:0|[1-9]\d*)$/)]).optional(),
368
+ deleted: e.union([e.int().min(-2147483648, { error: "Invalid value: Expected int32 to be >= -2147483648" }).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }), e.string().regex(/^-?(?:0|[1-9]\d*)$/)]).optional(),
369
+ denied: e.union([e.int().min(-2147483648, { error: "Invalid value: Expected int32 to be >= -2147483648" }).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }), e.string().regex(/^-?(?:0|[1-9]\d*)$/)]).optional(),
367
370
  draft: e.union([e.int().min(-2147483648, { error: "Invalid value: Expected int32 to be >= -2147483648" }).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }), e.string().regex(/^-?(?:0|[1-9]\d*)$/)]).optional(),
368
371
  submitted: e.union([e.int().min(-2147483648, { error: "Invalid value: Expected int32 to be >= -2147483648" }).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }), e.string().regex(/^-?(?:0|[1-9]\d*)$/)]).optional(),
369
372
  total: e.union([e.int().min(-2147483648, { error: "Invalid value: Expected int32 to be >= -2147483648" }).max(2147483647, { error: "Invalid value: Expected int32 to be <= 2147483647" }), e.string().regex(/^-?(?:0|[1-9]\d*)$/)]).optional()
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.5.149", n = "b55b5c0119256ab01eeabd18be4881238052ca1d", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.5.152", n = "7687365879f9ac21a36e43eb14f11441ec7386dc", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.5.149",
3
+ "version": "0.5.152",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {