@bahmni/widgets 0.0.1-dev.193 → 0.0.1-dev.194

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.
@@ -1,31 +1,31 @@
1
- import { jsx as o, jsxs as l, Fragment as V } from "react/jsx-runtime";
2
- import { u as $, a as H, b as P, F as z, U as Y, c as j, y as G } from "./index-D3jK_TZZ.js";
1
+ import { jsx as s, jsxs as l, Fragment as k } from "react/jsx-runtime";
2
+ import { u as V, a as H, b as P, F as q, U as z, c as G, y as Y } from "./index-BxI904MH.js";
3
3
  import { useQuery as K } from "@tanstack/react-query";
4
- import { useState as C, useCallback as E, useEffect as M, useMemo as f } from "react";
4
+ import { useState as C, useCallback as E, useEffect as L, useMemo as f } from "react";
5
5
  import { useTranslation as Q } from "react-i18next";
6
- const W = "_documentsTableBody_6qsah_1", J = "_viewAttachmentsLink_6qsah_11", X = "_documentViewerContainer_6qsah_15", Z = "_attachmentItem_6qsah_23", x = "_attachmentCounter_6qsah_27", ee = "_attachmentError_6qsah_36", te = "_documentIframe_6qsah_44", ae = "_documentImage_6qsah_50", c = {
6
+ const W = "_documentsTableBody_1voj8_1", X = "_viewAttachmentsLink_1voj8_11", J = "_documentViewerContainer_1voj8_15", Z = "_attachmentItem_1voj8_23", x = "_attachmentCounter_1voj8_27", ee = "_attachmentError_1voj8_36", te = "_documentIframe_1voj8_44", ne = "_documentImage_1voj8_50", c = {
7
7
  documentsTableBody: W,
8
- viewAttachmentsLink: J,
9
- documentViewerContainer: X,
8
+ viewAttachmentsLink: X,
9
+ documentViewerContainer: J,
10
10
  attachmentItem: Z,
11
11
  attachmentCounter: x,
12
12
  attachmentError: ee,
13
13
  documentIframe: te,
14
- documentImage: ae
15
- }, ne = {
14
+ documentImage: ne
15
+ }, ae = {
16
16
  documentIdentifier: "DOCUMENTS_DOCUMENT_IDENTIFIER",
17
17
  documentType: "DOCUMENTS_TYPE",
18
18
  uploadedOn: "DOCUMENTS_UPLOADED_ON",
19
19
  uploadedBy: "DOCUMENTS_UPLOADED_BY",
20
20
  action: "DOCUMENTS_ACTION"
21
21
  };
22
- function S(t) {
22
+ function M(t) {
23
23
  return !t || t.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${t}`;
24
24
  }
25
- function se(t, u) {
25
+ function oe(t, u) {
26
26
  return t.map((d) => ({
27
27
  key: d,
28
- header: u(ne[d])
28
+ header: u(ae[d])
29
29
  }));
30
30
  }
31
31
  const re = [
@@ -34,35 +34,35 @@ const re = [
34
34
  "uploadedOn",
35
35
  "uploadedBy",
36
36
  "action"
37
- ], w = (t) => t.attachments.length > 0 ? t.attachments : t.documentUrl ? [{ url: t.documentUrl, contentType: t.contentType }] : [], le = ({ config: t, encounterUuids: u }) => {
38
- const [d, O] = C(!1), [n, y] = C(
37
+ ], se = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, v = (t) => t.attachments.length > 0 ? t.attachments : t.documentUrl ? [{ url: t.documentUrl, contentType: t.contentType }] : [], ue = ({ config: t, encounterUuids: u }) => {
38
+ const [d, g] = C(!1), [a, O] = C(
39
39
  null
40
- ), [b, T] = C(
40
+ ), [w, T] = C(
41
41
  /* @__PURE__ */ new Set()
42
- ), p = $(), { t: a } = Q(), { addNotification: g } = H(), U = E((e) => {
43
- y(e), O(!0);
44
- }, []), v = E(() => {
45
- O(!1), y(null), T(/* @__PURE__ */ new Set());
46
- }, []), L = E((e) => {
47
- T((s) => new Set(s).add(e));
48
- }, []), { data: B, isLoading: q, isError: I, error: A } = K({
42
+ ), p = V(), { t: n } = Q(), { addNotification: y } = H(), S = E((e) => {
43
+ O(e), g(!0);
44
+ }, []), b = E(() => {
45
+ g(!1), O(null), T(/* @__PURE__ */ new Set());
46
+ }, []), U = E((e) => {
47
+ T((o) => new Set(o).add(e));
48
+ }, []), { data: B, isLoading: j, isError: I, error: A } = K({
49
49
  queryKey: ["documents", p, u],
50
50
  enabled: !!p,
51
51
  queryFn: () => P(p, u)
52
52
  });
53
- M(() => {
54
- I && g({
55
- title: a("ERROR_DEFAULT_TITLE"),
53
+ L(() => {
54
+ I && y({
55
+ title: n("ERROR_DEFAULT_TITLE"),
56
56
  message: A?.message ?? "",
57
57
  type: "error"
58
58
  });
59
- }, [I, A, g, a]), M(() => {
59
+ }, [I, A, y, n]), L(() => {
60
60
  const e = new AbortController();
61
61
  return (async () => {
62
- if (!d || !n) return;
63
- const r = /* @__PURE__ */ new Set(), _ = w(n);
62
+ if (!d || !a) return;
63
+ const r = /* @__PURE__ */ new Set(), _ = v(a);
64
64
  for (let m = 0; m < _.length; m++) {
65
- const N = S(_[m].url);
65
+ const N = M(_[m].url);
66
66
  try {
67
67
  (await fetch(N, {
68
68
  method: "HEAD",
@@ -74,125 +74,125 @@ const re = [
74
74
  }
75
75
  e.signal.aborted || T(r);
76
76
  })(), () => e.abort();
77
- }, [d, n]);
77
+ }, [d, a]);
78
78
  const h = f(
79
79
  () => t?.fields ?? re,
80
80
  [t?.fields]
81
- ), F = f(() => se(h, a), [h, a]), R = f(
81
+ ), F = f(() => oe(h, n), [h, n]), R = f(
82
82
  () => h.map((e) => ({
83
83
  key: e,
84
84
  sortable: e !== "action"
85
85
  })),
86
86
  [h]
87
87
  ), i = f(
88
- () => n ? w(n) : [],
89
- [n]
90
- ), k = E(
91
- (e, s) => {
92
- switch (s) {
88
+ () => a ? v(a) : [],
89
+ [a]
90
+ ), $ = E(
91
+ (e, o) => {
92
+ switch (o) {
93
93
  case "documentIdentifier":
94
- return /* @__PURE__ */ o("span", { children: e.documentIdentifier });
94
+ return /* @__PURE__ */ s("span", { children: e.documentIdentifier });
95
95
  case "documentType":
96
- return e.documentType ?? a("DOCUMENTS_NOT_AVAILABLE");
96
+ return e.documentType ?? n("DOCUMENTS_NOT_AVAILABLE");
97
97
  case "uploadedOn":
98
- return Y(
98
+ return z(
99
99
  e.uploadedOn,
100
- a,
100
+ n,
101
101
  !0
102
- ).formattedResult || a("DOCUMENTS_NOT_AVAILABLE");
102
+ ).formattedResult || n("DOCUMENTS_NOT_AVAILABLE");
103
103
  case "uploadedBy":
104
- return e.uploadedBy ?? a("DOCUMENTS_NOT_AVAILABLE");
104
+ return e.uploadedBy ?? n("DOCUMENTS_NOT_AVAILABLE");
105
105
  case "action":
106
- return e.attachments.length > 0 || !!e.documentUrl ? /* @__PURE__ */ o(
107
- z,
106
+ return e.attachments.length > 0 || !!e.documentUrl ? /* @__PURE__ */ s(
107
+ q,
108
108
  {
109
- onClick: () => U(e),
109
+ onClick: () => S(e),
110
110
  className: c.viewAttachmentsLink,
111
111
  "data-testid": `view-attachments-${e.id}`,
112
- children: a("DOCUMENTS_VIEW_ATTACHMENTS")
112
+ children: n("DOCUMENTS_VIEW_ATTACHMENTS")
113
113
  }
114
114
  ) : "--";
115
115
  default:
116
116
  return null;
117
117
  }
118
118
  },
119
- [U, a]
119
+ [S, n]
120
120
  );
121
- return /* @__PURE__ */ l(V, { children: [
122
- /* @__PURE__ */ o("div", { "data-testid": "documents-table", children: /* @__PURE__ */ o(
123
- j,
121
+ return /* @__PURE__ */ l(k, { children: [
122
+ /* @__PURE__ */ s("div", { "data-testid": "documents-table", children: /* @__PURE__ */ s(
123
+ G,
124
124
  {
125
125
  headers: F,
126
- ariaLabel: a("DOCUMENTS_TABLE_HEADING"),
126
+ ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
127
127
  rows: B ?? [],
128
- loading: q,
128
+ loading: j,
129
129
  errorStateMessage: I ? A?.message : null,
130
130
  sortable: R,
131
- emptyStateMessage: a("DOCUMENTS_NO_RECORDS"),
132
- renderCell: k,
131
+ emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
132
+ renderCell: $,
133
133
  className: c.documentsTableBody,
134
134
  dataTestId: "documents-table"
135
135
  }
136
136
  ) }),
137
- d && n && /* @__PURE__ */ o(
138
- G,
137
+ d && a && /* @__PURE__ */ s(
138
+ Y,
139
139
  {
140
140
  id: "modalIdForActionAreaLayout",
141
141
  portalId: "main-display-area",
142
142
  open: d,
143
- onRequestClose: v,
144
- modalHeading: n.documentIdentifier,
143
+ onRequestClose: b,
144
+ modalHeading: a.documentIdentifier,
145
145
  passiveModal: !0,
146
146
  size: "lg",
147
147
  testId: "document-view-modal",
148
- children: /* @__PURE__ */ o("div", { className: c.documentViewerContainer, children: i.map((e, s) => {
149
- const r = S(e.url), _ = e.contentType?.toLowerCase().includes("pdf"), m = e.contentType?.toLowerCase().includes("image"), N = b.has(s);
148
+ children: /* @__PURE__ */ s("div", { className: c.documentViewerContainer, children: i.map((e, o) => {
149
+ const r = M(e.url), _ = e.contentType?.toLowerCase().includes("pdf"), m = (e.contentType?.toLowerCase().includes("image") ?? !1) || se.test(e.url ?? ""), N = w.has(o);
150
150
  return r === "#" || N ? /* @__PURE__ */ l(
151
151
  "div",
152
152
  {
153
153
  className: c.attachmentError,
154
- "data-testid": `attachment-error-${s}`,
154
+ "data-testid": `attachment-error-${o}`,
155
155
  children: [
156
156
  i.length > 1 && /* @__PURE__ */ l("p", { className: c.attachmentCounter, children: [
157
- s + 1,
157
+ o + 1,
158
158
  "/",
159
159
  i.length
160
160
  ] }),
161
- /* @__PURE__ */ o("p", { children: a("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
161
+ /* @__PURE__ */ s("p", { children: n("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
162
162
  ]
163
163
  },
164
- `${n.id}-${e.url}`
164
+ `${a.id}-${e.url}`
165
165
  ) : /* @__PURE__ */ l(
166
166
  "div",
167
167
  {
168
168
  className: c.attachmentItem,
169
- "data-testid": `attachment-item-${s}`,
169
+ "data-testid": `attachment-item-${o}`,
170
170
  children: [
171
171
  i.length > 1 && /* @__PURE__ */ l("p", { className: c.attachmentCounter, children: [
172
- s + 1,
172
+ o + 1,
173
173
  "/",
174
174
  i.length
175
175
  ] }),
176
- m ? /* @__PURE__ */ o(
176
+ m ? /* @__PURE__ */ s(
177
177
  "img",
178
178
  {
179
179
  src: r,
180
- alt: n.documentIdentifier,
180
+ alt: a.documentIdentifier,
181
181
  className: c.documentImage,
182
- onError: () => L(s)
182
+ onError: () => U(o)
183
183
  }
184
- ) : /* @__PURE__ */ o(
184
+ ) : /* @__PURE__ */ s(
185
185
  "iframe",
186
186
  {
187
187
  src: _ ? `${r}#toolbar=0` : r,
188
188
  className: c.documentIframe,
189
- title: n.documentIdentifier,
190
- onError: () => L(s)
189
+ title: a.documentIdentifier,
190
+ onError: () => U(o)
191
191
  }
192
192
  )
193
193
  ]
194
194
  },
195
- `${n.id}-${e.url}`
195
+ `${a.id}-${e.url}`
196
196
  );
197
197
  }) })
198
198
  }
@@ -200,5 +200,5 @@ const re = [
200
200
  ] });
201
201
  };
202
202
  export {
203
- le as default
203
+ ue as default
204
204
  };
@@ -1,5 +1,5 @@
1
1
  import { jsxs as b, jsx as o, Fragment as j } from "react/jsx-runtime";
2
- import { f as K, d as R, Q as ae, r as oe, o as se, e as ne, g as de, s as ie, u as le, q as ce, G as me, B as ue, z as pe, h as be, i as fe, U as _e, F as ye, c as P, j as he, W as $e, y as ge, D as Ne, R as H } from "./index-D3jK_TZZ.js";
2
+ import { f as K, d as R, Q as ae, r as oe, o as se, e as ne, g as de, s as ie, u as le, q as ce, G as me, B as ue, z as pe, h as be, i as fe, U as _e, F as ye, c as P, j as he, W as $e, y as ge, D as Ne, R as H } from "./index-BxI904MH.js";
3
3
  import { useQueryClient as ve, useQuery as O } from "@tanstack/react-query";
4
4
  import { useState as k, useMemo as g, useCallback as L } from "react";
5
5
  import { useTranslation as V } from "react-i18next";
@@ -1,5 +1,5 @@
1
1
  import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
- import { k, l as C, t as M, Q as V, J as q, r as K, o as w, e as G, u as P, a as H, Y, L as j, i as J, g as z, m as W, n as X, p as Z, c as x } from "./index-D3jK_TZZ.js";
2
+ import { k, l as C, t as M, Q as V, J as q, r as K, o as w, e as G, u as P, a as H, Y, L as j, i as J, g as z, m as W, n as X, p as Z, c as x } from "./index-BxI904MH.js";
3
3
  import { useQueries as ee, useQuery as te } from "@tanstack/react-query";
4
4
  import { useRef as se, useEffect as $, useMemo as h } from "react";
5
5
  import { useTranslation as D } from "react-i18next";
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentsTable.d.ts","sourceRoot":"","sources":["../../src/documents/DocumentsTable.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAGzE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsBhD,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAmOzC,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"DocumentsTable.d.ts","sourceRoot":"","sources":["../../src/documents/DocumentsTable.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAGzE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAwBhD,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAoOzC,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -80067,7 +80067,7 @@ const j0t = [
80067
80067
  },
80068
80068
  {
80069
80069
  type: "patientDocuments",
80070
- component: kr(() => import("./DocumentsTable-Clxa2r1r.js"))
80070
+ component: kr(() => import("./DocumentsTable-B1EReEvo.js"))
80071
80071
  },
80072
80072
  {
80073
80073
  type: "flowSheet",
@@ -80075,7 +80075,7 @@ const j0t = [
80075
80075
  },
80076
80076
  {
80077
80077
  type: "forms",
80078
- component: kr(() => import("./FormsTable-DL-5D8n9.js"))
80078
+ component: kr(() => import("./FormsTable-BHR8ELR1.js"))
80079
80079
  },
80080
80080
  {
80081
80081
  type: "labOrders",
@@ -80083,7 +80083,7 @@ const j0t = [
80083
80083
  },
80084
80084
  {
80085
80085
  type: "observations",
80086
- component: kr(() => import("./Observations-BTyQ4sIk.js"))
80086
+ component: kr(() => import("./Observations-BsDev8sJ.js"))
80087
80087
  },
80088
80088
  {
80089
80089
  type: "ordersControl",