@tesouro/embedded-components-react 0.5.153 → 0.5.155

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.
Files changed (49) hide show
  1. package/README.md +21 -19
  2. package/dist/index.css +0 -3
  3. package/dist/index.d.ts +106 -94
  4. package/dist/index.js +15 -15
  5. package/dist/lib/CreditCardsWidget.d.ts +6 -0
  6. package/dist/lib/DebitCardsWidget.d.ts +6 -0
  7. package/dist/lib/SettingsWidget.d.ts +0 -3
  8. package/dist/lib/WidgetSuite.d.ts +102 -9
  9. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +4 -3
  10. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsList.js +45 -44
  11. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index3.js +0 -1
  12. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index4.js +0 -1
  13. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js +56 -64
  14. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +34 -34
  15. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +191 -231
  16. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +91 -147
  17. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  18. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index14.js +16 -10
  19. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index16.js +19 -18
  20. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index6.js +16 -15
  21. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index9.js +15 -2
  22. package/package.json +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index.js +0 -10
  24. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index10.js +0 -28
  25. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index2.js +0 -27
  26. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index3.js +0 -13
  27. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index4.js +0 -34
  28. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index5.js +0 -35
  29. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index6.js +0 -33
  30. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index7.js +0 -22
  31. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index8.js +0 -25
  32. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/data-access/dist/index9.js +0 -26
  33. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index.js +0 -2
  34. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index10.js +0 -62
  35. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index11.js +0 -60
  36. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index12.js +0 -107
  37. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index2.js +0 -5
  38. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index3.js +0 -10
  39. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index4.js +0 -14
  40. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index5.js +0 -28
  41. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index6.js +0 -99
  42. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index7.js +0 -36
  43. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index8.js +0 -80
  44. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index9.js +0 -146
  45. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/ui/dist/index.js +0 -5
  46. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/ui/dist/index2.js +0 -41
  47. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/ui/dist/index3.js +0 -143
  48. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/ui/dist/index4.js +0 -36
  49. package/dist/libs/tesouro-embedded-components-react/settings-widget/tags/ui/dist/index5.js +0 -127
@@ -1,107 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
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";
10
- import "../../../../shared/feature/dist/index.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";
18
- import "../../ui/dist/index.js";
19
- import { useEffect as p, useMemo as m } from "react";
20
- import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
21
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index12.js
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
32
- });
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,
53
- emptyStateTestId: "tags-widget-empty-state"
54
- }),
55
- /* @__PURE__ */ g(f, {
56
- open: D.open,
57
- onOpenChange: D.onOpenChange,
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,
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
84
- })
85
- ] });
86
- }
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,
90
- baseUrl: e,
91
- widgetToken: t,
92
- organizationId: r,
93
- configClient: i,
94
- gatewayRouting: a,
95
- linkComponent: s,
96
- implementation: c,
97
- uiFramework: l,
98
- errorFallback: u,
99
- onError: d,
100
- analytics: f,
101
- disclosuresAcceptance: p,
102
- providerLabels: m,
103
- children: /* @__PURE__ */ g(v, { ...h })
104
- });
105
- }
106
- //#endregion
107
- export { y as TagsWidget, y as default };
@@ -1,5 +0,0 @@
1
- import { SETTINGS_WIDGET_NAME as e } from "../../../shared/util/dist/lib/widgetName.js";
2
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index2.js
3
- var t = `${e}.tags`, n = { Mounted: `${t}.mounted` };
4
- //#endregion
5
- export { n as TagsWidgetAnalyticsEvent, t as WIDGET_NAME };
@@ -1,10 +0,0 @@
1
- import { hasAnyScope as e } from "../../../../shared/data-access/dist/lib/hasAnyScope.js";
2
- import { Scope as t } from "../../../../shared/data-access/dist/lib/scopes.js";
3
- import "../../../../shared/data-access/dist/index.js";
4
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index3.js
5
- var n = [t.AccountingConfigWriteOrg];
6
- function r(t) {
7
- return { canWrite: e(new Set(t ?? []), n) };
8
- }
9
- //#endregion
10
- export { r as getTagsPermissions };
@@ -1,14 +0,0 @@
1
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index4.js
2
- var e = [
3
- 10,
4
- 25,
5
- 50,
6
- 100
7
- ], t = {
8
- name: "",
9
- category: "",
10
- keywords: [],
11
- keywordsInput: ""
12
- };
13
- //#endregion
14
- export { t as EMPTY_FORM_VALUES, e as PAGE_SIZE_OPTIONS };
@@ -1,28 +0,0 @@
1
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index5.js
2
- var e = {
3
- nameRequired: "Required",
4
- nameTooLong: "Value must be at most '255' characters",
5
- keywordTooShort: "Keyword should be at least 2 characters long",
6
- keywordTooLong: "Keyword should be at most 25 characters long",
7
- genericError: "Something went wrong. Please try again.",
8
- duplicateName: "A tag with this name already exists.",
9
- keywordsNotSaved: "The tag was saved, but its keywords were not. Save again to finish."
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 = {
19
- document_type: "Document Type",
20
- department: "Department",
21
- project: "Project",
22
- cost_center: "Cost Center",
23
- vendor_type: "Vendor Type",
24
- payment_method: "Payment Method",
25
- approval_status: "Approval Status"
26
- };
27
- //#endregion
28
- export { t as TAGS_MESSAGE_LABELS_EN, n as TAG_CATEGORY_LABELS_EN, e as TAG_MESSAGE_LABELS_EN };
@@ -1,99 +0,0 @@
1
- import { extractApiErrorMessage as e } from "../../../../shared/util/dist/lib/apiErrors.js";
2
- import { TAG_CATEGORY_LABELS_EN as t, TAG_MESSAGE_LABELS_EN as n } from "./index5.js";
3
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index6.js
4
- var r = {
5
- createdAtLabel: "created_at",
6
- updatedAtLabel: "updated_at"
7
- };
8
- function i(e) {
9
- return e && r[e] || "created_at";
10
- }
11
- var a = {
12
- year: "numeric",
13
- month: "short",
14
- day: "numeric"
15
- };
16
- function o(e, t) {
17
- return e.replace("{name}", () => t);
18
- }
19
- var s;
20
- function c(e) {
21
- if (!e) return "";
22
- let t = new Date(e);
23
- return Number.isNaN(t.getTime()) ? "" : (s ??= new Intl.DateTimeFormat(void 0, a), s.format(t));
24
- }
25
- function l() {
26
- let e = globalThis.getSelection?.();
27
- return !!(e && e.toString().length > 0);
28
- }
29
- function u(e) {
30
- let t = {};
31
- for (let n of e ?? []) t[n.tag_id] = n.keywords;
32
- return t;
33
- }
34
- function d(e) {
35
- let t = {};
36
- for (let n of e ?? []) t[n.id] = `${n.first_name ?? ""} ${n.last_name ?? ""}`.trim();
37
- return t;
38
- }
39
- function f({ tags: e, keywordsByTagId: t, userNamesById: n }) {
40
- return e.map((e) => ({
41
- id: e.id,
42
- name: e.name,
43
- categoryLabel: h(e.category),
44
- keywords: (t[e.id] ?? []).join(", "),
45
- createdAtLabel: c(e.created_at),
46
- updatedAtLabel: c(e.updated_at),
47
- createdByLabel: e.created_by_entity_user_id ? n[e.created_by_entity_user_id] ?? "" : ""
48
- }));
49
- }
50
- function p(e, t, n) {
51
- let r = e ?? [], i = r.filter((e) => e.tag_id !== t), a = Array.from(new Set(n));
52
- return i.length === r.length && a.length === 0 ? {
53
- changed: !1,
54
- next: r
55
- } : {
56
- changed: !0,
57
- next: a.length ? [...i, {
58
- tag_id: t,
59
- keywords: a,
60
- enabled: !0
61
- }] : i
62
- };
63
- }
64
- var m = [
65
- "document_type",
66
- "department",
67
- "project",
68
- "cost_center",
69
- "vendor_type",
70
- "payment_method",
71
- "approval_status"
72
- ];
73
- function h(e, n) {
74
- return e ? n?.[e] ?? t[e] ?? "" : "";
75
- }
76
- function g(e) {
77
- return m.map((t) => ({
78
- value: t,
79
- label: h(t, e)
80
- }));
81
- }
82
- function _(e, t = n) {
83
- let r = {}, i = e.name.trim();
84
- i.length === 0 ? r.name = t.nameRequired : i.length > 255 && (r.name = t.nameTooLong);
85
- let a = e.keywords.some((e) => e.length < 2), o = e.keywords.some((e) => e.length > 25);
86
- return a ? r.keywords = t.keywordTooShort : o && (r.keywords = t.keywordTooLong), r;
87
- }
88
- function v(e) {
89
- return !!(e.name || e.keywords);
90
- }
91
- function y(e) {
92
- return e === "This tag already exists.";
93
- }
94
- function b(t, r = n, { preferApiMessage: i = !1 } = {}) {
95
- let a = e(t);
96
- return y(a) ? { name: r.duplicateName } : { form: (i ? a : void 0) ?? r.genericError };
97
- }
98
- //#endregion
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 };
@@ -1,36 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { buildKeywordsByTagId as e, buildUserNamesById as t } from "./index6.js";
6
- import { useMyEntityQuery as n } from "../../data-access/dist/index7.js";
7
- import { useEntitySettingsQuery as r } from "../../data-access/dist/index8.js";
8
- import { useEntityUsersQuery as i } from "../../data-access/dist/index10.js";
9
- import "../../data-access/dist/index.js";
10
- import { useCallback as a, useMemo as o, useRef as s, useState as c } from "react";
11
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index7.js
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);
22
- return e;
23
- }, [l.genericError, h]);
24
- return {
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
33
- };
34
- }
35
- //#endregion
36
- export { l as useEntitySettings };
@@ -1,80 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
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";
11
- import "../../data-access/dist/index.js";
12
- import { useCallback as o, useEffect as s, useRef as c, useState as l } from "react";
13
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index8.js
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));
23
- }, [
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]);
32
- return {
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 }
58
- });
59
- } catch {
60
- e.error(r(p.keywordCleanupError, i.name));
61
- }
62
- });
63
- }, [
64
- h,
65
- u,
66
- g,
67
- _,
68
- v,
69
- b,
70
- x,
71
- d,
72
- p
73
- ]),
74
- cancel: j,
75
- isDeleting: b.isPending,
76
- confirmDisabled: y
77
- };
78
- }
79
- //#endregion
80
- export { u as useTagDelete };
@@ -1,146 +0,0 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
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";
12
- import "../../data-access/dist/index.js";
13
- import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
14
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/feature/dist/index9.js
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;
18
- }, []);
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));
34
- }, [
35
- x,
36
- U,
37
- v
38
- ]),
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({
48
- name: e.name,
49
- category: e.category ?? "",
50
- keywords: i[e.id] ?? [],
51
- keywordsInput: ""
52
- }), z({}), N(!0);
53
- })();
54
- }, [
55
- x,
56
- U,
57
- w,
58
- T,
59
- v
60
- ]),
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) => ({
68
- ...t,
69
- name: e
70
- })), []),
71
- onCategoryChange: f((e) => L((t) => ({
72
- ...t,
73
- category: e
74
- })), []),
75
- onKeywordsChange: f((e) => L((t) => ({
76
- ...t,
77
- keywords: e
78
- })), []),
79
- onKeywordsInputChange: f((e) => L((t) => ({
80
- ...t,
81
- keywordsInput: e
82
- })), []),
83
- submit: f(async () => {
84
- if (!S) return;
85
- let t = s(I, b);
86
- if (a(t)) {
87
- z(t);
88
- return;
89
- }
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
- });
116
- }
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);
126
- }
127
- });
128
- }, [
129
- S,
130
- I,
131
- P,
132
- F,
133
- v,
134
- _,
135
- C,
136
- k,
137
- A,
138
- j,
139
- b,
140
- E,
141
- D
142
- ])
143
- };
144
- }
145
- //#endregion
146
- export { _ as useTagForm };
@@ -1,5 +0,0 @@
1
- import "./index2.js";
2
- import { TagsScreen as e } from "./index3.js";
3
- import { TagDeleteDialog as t } from "./index4.js";
4
- import { TagFormSheet as n } from "./index5.js";
5
- export { t as TagDeleteDialog, n as TagFormSheet, e as TagsScreen };
@@ -1,41 +0,0 @@
1
- //#region ../../libs/tesouro-embedded-components-react/settings-widget/tags/ui/dist/index2.js
2
- var e = {
3
- createButton: "Create",
4
- columnName: "Name",
5
- columnCategory: "Category",
6
- columnKeywords: "Keywords",
7
- columnCreatedAt: "Created at",
8
- columnUpdatedAt: "Updated at",
9
- columnCreatedBy: "Created by",
10
- columnActions: "Actions",
11
- openRow: (e) => `Edit tag — ${e}`,
12
- actionDelete: "Delete",
13
- openActionsMenu: "Open actions menu",
14
- emptyTitle: "No tags",
15
- emptyDescription: "You don't have any tags yet. You can create your first tag.",
16
- emptyDescriptionNoAction: "You don't have any tags yet.",
17
- emptyAction: "Create new tag",
18
- errorTitle: "Failed to load tags",
19
- errorDescription: "Something went wrong while fetching your tags. Please try again.",
20
- errorRetry: "Try again"
21
- }, t = {
22
- title: "Delete “{name}” tag?",
23
- message: "This action can't be undone.",
24
- confirmButton: "Delete",
25
- cancelButton: "Cancel"
26
- }, n = {
27
- createTitle: "Create new tag",
28
- editTitle: "Edit tag “{name}”",
29
- nameLabel: "Name",
30
- categoryLabel: "Category",
31
- categoryPlaceholder: "Not set",
32
- keywordsLabel: "Keywords",
33
- keywordsPlaceholder: "Add a keyword…",
34
- removeKeyword: "Remove {keyword}",
35
- cancelButton: "Cancel",
36
- createButton: "Create",
37
- saveButton: "Save",
38
- deleteButton: "Delete"
39
- };
40
- //#endregion
41
- export { e as TAGS_SCREEN_LABELS_EN, t as TAG_DELETE_DIALOG_LABELS_EN, n as TAG_FORM_SHEET_LABELS_EN };