@declarion/react 0.106.0 → 0.109.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.
Files changed (34) hide show
  1. package/dist-lib/api/agents.js +8 -7
  2. package/dist-lib/api/client.js +48 -49
  3. package/dist-lib/components/agents/AgentChatPanel.impl.js +362 -301
  4. package/dist-lib/components/agents/ChatAttachments.js +144 -0
  5. package/dist-lib/components/agents/transcript-runs.js +1 -1
  6. package/dist-lib/components/chrome/AssociationTabs.js +89 -75
  7. package/dist-lib/components/detail-layout/AssociatedBlock.js +243 -235
  8. package/dist-lib/components/detail-layout/ChildrenCards.js +57 -55
  9. package/dist-lib/components/detail-layout/ChildrenList.js +45 -43
  10. package/dist-lib/components/detail-layout/ChildrenTable.js +93 -91
  11. package/dist-lib/components/detail-layout/ChildrenTimeline.js +160 -155
  12. package/dist-lib/components/detail-layout/widgets/EntityScorecardWidget.js +127 -121
  13. package/dist-lib/components/fields/RefCombobox.js +53 -48
  14. package/dist-lib/components/fields/index.js +1 -0
  15. package/dist-lib/components/file-widgets/useFileSelection.js +152 -0
  16. package/dist-lib/components/pages/SmartDetailPage.impl.js +506 -482
  17. package/dist-lib/components/pages/SmartRecordListPage.impl.js +335 -300
  18. package/dist-lib/components/pages/tenant-params/TenantParamsPage.impl.js +112 -109
  19. package/dist-lib/components/params/ParamsBlock.js +18 -15
  20. package/dist-lib/components/params/param-editors.js +60 -54
  21. package/dist-lib/components/primitives/RetryButton.js +14 -0
  22. package/dist-lib/components/primitives/StatTile.js +42 -34
  23. package/dist-lib/hooks/useAgentConversation.js +18 -13
  24. package/dist-lib/hooks/useParams.js +54 -52
  25. package/dist-lib/hooks/useSchema.js +5 -2
  26. package/dist-lib/hooks/useTimelineData.js +26 -24
  27. package/dist-lib/index.d.ts +89 -5
  28. package/dist-lib/index.js +95 -93
  29. package/dist-lib/lib/read-display-state.js +19 -0
  30. package/dist-lib/stores/auth.js +1 -0
  31. package/dist-lib/testing.d.ts +1 -1
  32. package/dist-lib/types/fieldType.js +1 -1
  33. package/dist-lib/{useResponsiveMode-ECv1AEhv.d.ts → useResponsiveMode-DODbtSrY.d.ts} +3 -0
  34. package/package.json +1 -1
@@ -0,0 +1,152 @@
1
+ import { useText as e } from "../../hooks/useText.js";
2
+ import { UploadError as t, discardFile as n, uploadCheckFailure as r, uploadFailure as i, uploadFile as a, validateClientSide as o } from "./upload.js";
3
+ import { useCallback as s, useEffect as c, useReducer as l, useRef as u } from "react";
4
+ //#region src/components/file-widgets/useFileSelection.ts
5
+ function d(e, t) {
6
+ let n = (t, n) => e.map((e) => e.localId === t && e.state === "uploading" ? {
7
+ ...e,
8
+ ...n
9
+ } : e);
10
+ switch (t.type) {
11
+ case "added": return [...e, {
12
+ localId: t.localId,
13
+ filename: t.filename,
14
+ sizeBytes: t.sizeBytes,
15
+ state: "uploading",
16
+ progress: {
17
+ loaded: 0,
18
+ total: t.sizeBytes,
19
+ pct: 0
20
+ },
21
+ failure: null,
22
+ uploaded: null
23
+ }];
24
+ case "refused": return [...e, {
25
+ localId: t.localId,
26
+ filename: t.filename,
27
+ sizeBytes: t.sizeBytes,
28
+ state: "failed",
29
+ progress: null,
30
+ failure: t.failure,
31
+ uploaded: null
32
+ }];
33
+ case "progressed": return n(t.localId, { progress: t.progress });
34
+ case "uploaded": return n(t.localId, {
35
+ state: "ready",
36
+ progress: null,
37
+ uploaded: t.uploaded
38
+ });
39
+ case "failed": return n(t.localId, {
40
+ state: "failed",
41
+ progress: null,
42
+ failure: t.failure
43
+ });
44
+ case "cancelled": return n(t.localId, {
45
+ state: "cancelled",
46
+ progress: null
47
+ });
48
+ case "removed": return e.filter((e) => e.localId !== t.localId);
49
+ case "released": return e.filter((e) => !t.localIds.includes(e.localId));
50
+ }
51
+ }
52
+ function f(e) {
53
+ let t = e.some((e) => e.state === "uploading"), n = e.some((e) => e.state === "failed");
54
+ return {
55
+ readyFiles: e.flatMap((e) => e.state === "ready" && e.uploaded ? [e.uploaded] : []),
56
+ uploading: t,
57
+ failed: n,
58
+ settled: !t && !n
59
+ };
60
+ }
61
+ function p({ entityCode: p, fieldCode: m, accepts: h, maxSizeBytes: g }) {
62
+ let _ = e(), v = e("errors"), [y, b] = l(d, []), x = u(/* @__PURE__ */ new Map()), S = u(y);
63
+ S.current = y, c(() => {
64
+ let e = x.current;
65
+ return () => e.forEach((e) => e.abort());
66
+ }, []);
67
+ let C = s(async (e) => {
68
+ let s = `selection-${crypto.randomUUID()}`, c = o(e, h, g);
69
+ if (c) {
70
+ b({
71
+ type: "refused",
72
+ localId: s,
73
+ filename: e.name,
74
+ sizeBytes: e.size,
75
+ failure: r(_, v, c)
76
+ });
77
+ return;
78
+ }
79
+ let l = new AbortController();
80
+ x.current.set(s, l), b({
81
+ type: "added",
82
+ localId: s,
83
+ filename: e.name,
84
+ sizeBytes: e.size
85
+ });
86
+ try {
87
+ let t = await a({
88
+ file: e,
89
+ entityCode: p,
90
+ fieldCode: m,
91
+ signal: l.signal,
92
+ onProgress: (e) => b({
93
+ type: "progressed",
94
+ localId: s,
95
+ progress: e
96
+ })
97
+ });
98
+ if (l.signal.aborted) {
99
+ n(t.id).catch(() => {});
100
+ return;
101
+ }
102
+ b({
103
+ type: "uploaded",
104
+ localId: s,
105
+ uploaded: t
106
+ });
107
+ } catch (e) {
108
+ if (e instanceof t && e.code === "ABORTED") return;
109
+ b({
110
+ type: "failed",
111
+ localId: s,
112
+ failure: i(_, v, e)
113
+ });
114
+ } finally {
115
+ x.current.delete(s);
116
+ }
117
+ }, [
118
+ h,
119
+ p,
120
+ v,
121
+ m,
122
+ g,
123
+ _
124
+ ]);
125
+ return {
126
+ selections: y,
127
+ add: s((e) => {
128
+ Array.from(e).forEach((e) => void C(e));
129
+ }, [C]),
130
+ cancel: s((e) => {
131
+ x.current.get(e)?.abort(), b({
132
+ type: "cancelled",
133
+ localId: e
134
+ });
135
+ }, []),
136
+ remove: s((e) => {
137
+ x.current.get(e)?.abort();
138
+ let t = S.current.find((t) => t.localId === e)?.uploaded, r = t && S.current.some((n) => n.localId !== e && n.uploaded?.id === t.id);
139
+ t && !r && n(t.id).catch(() => {}), b({
140
+ type: "removed",
141
+ localId: e
142
+ });
143
+ }, []),
144
+ release: s((e) => b({
145
+ type: "released",
146
+ localIds: e
147
+ }), []),
148
+ ...f(y)
149
+ };
150
+ }
151
+ //#endregion
152
+ export { d as fileSelectionReducer, f as summarizeFileSelections, p as useFileSelection };