@bahmni/registration-app 0.0.1-dev.204 → 0.0.1-dev.206

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ax as s, av as E, aw as i } from "./index-C3dYT9FK.js";
1
+ import { ax as s, av as E, aw as i } from "./index-uOTKH4lb.js";
2
2
  export {
3
3
  s as IDENTIFIER_TYPES_QUERY_KEY,
4
4
  E as RegistrationApp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/registration-app",
3
- "version": "0.0.1-dev.204",
3
+ "version": "0.0.1-dev.206",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,203 +0,0 @@
1
- import { jsx as o, jsxs as l, Fragment as k } from "react/jsx-runtime";
2
- import { l as V, u as x, Q as F, s as H, y as q, C as Q, x as P, T as G } from "./index-C3dYT9FK.js";
3
- import { useQuery as Y } from "@tanstack/react-query";
4
- import { useState as I, useCallback as T, useEffect as U, useMemo as p } from "react";
5
- const z = "_documentsTableBody_1voj8_1", J = "_viewAttachmentsLink_1voj8_11", K = "_documentViewerContainer_1voj8_15", W = "_attachmentItem_1voj8_23", X = "_attachmentCounter_1voj8_27", Z = "_attachmentError_1voj8_36", ee = "_documentIframe_1voj8_44", te = "_documentImage_1voj8_50", d = {
6
- documentsTableBody: z,
7
- viewAttachmentsLink: J,
8
- documentViewerContainer: K,
9
- attachmentItem: W,
10
- attachmentCounter: X,
11
- attachmentError: Z,
12
- documentIframe: ee,
13
- documentImage: te
14
- }, ae = {
15
- documentIdentifier: "DOCUMENTS_DOCUMENT_IDENTIFIER",
16
- documentType: "DOCUMENTS_TYPE",
17
- uploadedOn: "DOCUMENTS_UPLOADED_ON",
18
- uploadedBy: "DOCUMENTS_UPLOADED_BY",
19
- action: "DOCUMENTS_ACTION"
20
- };
21
- function v(a) {
22
- return !a || a.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${a}`;
23
- }
24
- function ne(a, u) {
25
- return a.map((s) => ({
26
- key: s,
27
- header: u(ae[s])
28
- }));
29
- }
30
- const re = [
31
- "documentIdentifier",
32
- "documentType",
33
- "uploadedOn",
34
- "uploadedBy",
35
- "action"
36
- ], oe = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, w = (a) => a.attachments.length > 0 ? a.attachments : a.documentUrl ? [{ url: a.documentUrl, contentType: a.contentType }] : [], ie = ({ config: a, encounterUuids: u }) => {
37
- const [s, y] = I(!1), [r, O] = I(
38
- null
39
- ), [L, E] = I(
40
- /* @__PURE__ */ new Set()
41
- ), N = V(), { t: n } = x(), { addNotification: A } = F(), D = T((e) => {
42
- O(e), y(!0);
43
- }, []), M = T(() => {
44
- y(!1), O(null), E(/* @__PURE__ */ new Set());
45
- }, []), S = T((e) => {
46
- E((t) => new Set(t).add(e));
47
- }, []), { data: b, isLoading: j, isError: f, error: g } = Y({
48
- queryKey: ["documents", N, u],
49
- enabled: !!N,
50
- queryFn: () => H(N, u)
51
- });
52
- U(() => {
53
- f && A({
54
- title: n("ERROR_DEFAULT_TITLE"),
55
- message: g?.message ?? "",
56
- type: "error"
57
- });
58
- }, [f, g, A, n]), U(() => {
59
- const e = new AbortController();
60
- return (async () => {
61
- if (!s || !r) return;
62
- const t = /* @__PURE__ */ new Set(), c = w(r);
63
- for (let m = 0; m < c.length; m++) {
64
- const C = v(c[m].url);
65
- try {
66
- (await fetch(C, {
67
- method: "HEAD",
68
- signal: e.signal
69
- })).ok || t.add(m);
70
- } catch (h) {
71
- h instanceof Error && h.name !== "AbortError" && t.add(m);
72
- }
73
- }
74
- e.signal.aborted || E(t);
75
- })(), () => e.abort();
76
- }, [s, r]);
77
- const _ = p(
78
- () => a?.fields ?? re,
79
- [a?.fields]
80
- ), B = p(() => ne(_, n), [_, n]), R = p(
81
- () => _.map((e) => ({
82
- key: e,
83
- sortable: e !== "action"
84
- })),
85
- [_]
86
- ), i = p(
87
- () => r ? w(r) : [],
88
- [r]
89
- ), $ = T(
90
- (e, t) => {
91
- switch (t) {
92
- case "documentIdentifier":
93
- return /* @__PURE__ */ o("span", { children: e.documentIdentifier });
94
- case "documentType":
95
- return e.documentType ?? n("DOCUMENTS_NOT_AVAILABLE");
96
- case "uploadedOn":
97
- return Q(
98
- e.uploadedOn,
99
- n,
100
- !0
101
- ).formattedResult || n("DOCUMENTS_NOT_AVAILABLE");
102
- case "uploadedBy":
103
- return e.uploadedBy ?? n("DOCUMENTS_NOT_AVAILABLE");
104
- case "action":
105
- return e.attachments.length > 0 || e.documentUrl ? /* @__PURE__ */ o(
106
- q,
107
- {
108
- onClick: () => D(e),
109
- className: d.viewAttachmentsLink,
110
- "data-testid": `view-attachments-${e.id}`,
111
- children: n("DOCUMENTS_VIEW_ATTACHMENTS")
112
- }
113
- ) : "--";
114
- default:
115
- return null;
116
- }
117
- },
118
- [D, n]
119
- );
120
- return /* @__PURE__ */ l(k, { children: [
121
- /* @__PURE__ */ o("div", { "data-testid": "documents-table", children: /* @__PURE__ */ o(
122
- P,
123
- {
124
- headers: B,
125
- ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
126
- rows: b ?? [],
127
- loading: j,
128
- errorStateMessage: f ? g?.message : null,
129
- sortable: R,
130
- emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
131
- renderCell: $,
132
- className: d.documentsTableBody,
133
- dataTestId: "documents-table"
134
- }
135
- ) }),
136
- s && r && /* @__PURE__ */ o(
137
- G,
138
- {
139
- id: "modalIdForActionAreaLayout",
140
- portalId: "main-display-area",
141
- open: s,
142
- onRequestClose: M,
143
- modalHeading: r.documentIdentifier,
144
- passiveModal: !0,
145
- size: "lg",
146
- testId: "document-view-modal",
147
- children: /* @__PURE__ */ o("div", { className: d.documentViewerContainer, children: i.map((e, t) => {
148
- const c = v(e.url), m = e.contentType?.toLowerCase().includes("pdf"), C = (e.contentType?.toLowerCase().includes("image") ?? !1) || oe.test(e.url ?? ""), h = L.has(t);
149
- return c === "#" || h ? /* @__PURE__ */ l(
150
- "div",
151
- {
152
- className: d.attachmentError,
153
- "data-testid": `attachment-error-${t}`,
154
- children: [
155
- i.length > 1 && /* @__PURE__ */ l("p", { className: d.attachmentCounter, children: [
156
- t + 1,
157
- "/",
158
- i.length
159
- ] }),
160
- /* @__PURE__ */ o("p", { children: n("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
161
- ]
162
- },
163
- `${r.id}-${e.url}`
164
- ) : /* @__PURE__ */ l(
165
- "div",
166
- {
167
- className: d.attachmentItem,
168
- "data-testid": `attachment-item-${t}`,
169
- children: [
170
- i.length > 1 && /* @__PURE__ */ l("p", { className: d.attachmentCounter, children: [
171
- t + 1,
172
- "/",
173
- i.length
174
- ] }),
175
- C ? /* @__PURE__ */ o(
176
- "img",
177
- {
178
- src: c,
179
- alt: r.documentIdentifier,
180
- className: d.documentImage,
181
- onError: () => S(t)
182
- }
183
- ) : /* @__PURE__ */ o(
184
- "iframe",
185
- {
186
- src: m ? `${c}#toolbar=0` : c,
187
- className: d.documentIframe,
188
- title: r.documentIdentifier,
189
- onError: () => S(t)
190
- }
191
- )
192
- ]
193
- },
194
- `${r.id}-${e.url}`
195
- );
196
- }) })
197
- }
198
- )
199
- ] });
200
- };
201
- export {
202
- ie as default
203
- };