@bahmni/command-palette-app 0.0.1-dev.321 → 0.0.1-dev.326
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandPaletteProvider.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPaletteProvider/CommandPaletteProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CommandPaletteProvider.d.ts","sourceRoot":"","sources":["../../../src/components/CommandPaletteProvider/CommandPaletteProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAI9C,UAAU,2BAA2B;IACnC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAcD,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAaxE,CAAC"}
|
package/dist/constants/app.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PatientFieldsConfig, TriggerConfig } from '@bahmni/widgets';
|
|
2
2
|
export declare const BAHMNI_COMMAND_PALETTE_NAMESPACE = "command-palette";
|
|
3
|
+
export declare const COMMAND_PALETTE_ENABLED_STORAGE_KEY = "enableCommandPalette";
|
|
3
4
|
export declare const COMMAND_PALETTE_APP_CONFIG_URL = "/bahmni_config/openmrs/apps/command-palette/app.json";
|
|
4
5
|
export declare const EXTENSION_BASE_URL = "/bahmni_config/openmrs/apps";
|
|
5
6
|
export declare const DEFAULT_TRIGGER: TriggerConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/constants/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1E,eAAO,MAAM,gCAAgC,oBAAoB,CAAC;AAElE,eAAO,MAAM,8BAA8B,yDACa,CAAC;AACzD,eAAO,MAAM,kBAAkB,gCAAgC,CAAC;AAEhE,eAAO,MAAM,eAAe,EAAE,aAG7B,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,mBAGpC,CAAC"}
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/constants/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1E,eAAO,MAAM,gCAAgC,oBAAoB,CAAC;AAElE,eAAO,MAAM,mCAAmC,yBAAyB,CAAC;AAE1E,eAAO,MAAM,8BAA8B,yDACa,CAAC;AACzD,eAAO,MAAM,kBAAkB,gCAAgC,CAAC;AAEhE,eAAO,MAAM,eAAe,EAAE,aAG7B,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,mBAGpC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,88 +1,90 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { CommandPaletteProvider as
|
|
3
|
-
import { formatUrl as
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { CommandPaletteProvider as _ } from "@bahmni/widgets";
|
|
3
|
+
import { formatUrl as I, initAppI18n as F, getConfig as N, getCurrentUserPrivileges as M, fetchModuleExtensions as O, hasPrivilege as q } from "@bahmni/services";
|
|
4
4
|
import { useState as a, useEffect as f } from "react";
|
|
5
|
-
import { useLocation as
|
|
6
|
-
const L = "command-palette", D = "/bahmni_config/openmrs/apps/command-palette/app.json",
|
|
5
|
+
import { useLocation as x } from "react-router-dom";
|
|
6
|
+
const L = "command-palette", D = "enableCommandPalette", S = "/bahmni_config/openmrs/apps/command-palette/app.json", j = {
|
|
7
7
|
type: "combination",
|
|
8
8
|
keys: ["cmd+k", "ctrl+k"]
|
|
9
|
-
},
|
|
9
|
+
}, U = {
|
|
10
10
|
primaryFields: ["name", "identifier"],
|
|
11
11
|
additionalFields: ["age", "gender"]
|
|
12
|
-
},
|
|
12
|
+
}, R = "org.bahmni.commandpalette.navItem", k = "org.bahmni.commandpalette.patientAction", G = (e) => e.split("{{")[0].replace(/\/$/, ""), V = (e) => ({ patientUuid: r, patientIdentifier: o = "" }) => I(e, { patientUuid: r, patientIdentifier: o }), g = (e) => e.translationKey ?? e.label ?? "", w = "http://json-schema.org/draft-07/schema#", B = "Command Palette App Configuration", $ = "object", K = ["id"], H = { id: { type: "string" }, commandPalette: { type: "object", additionalProperties: !1, properties: { trigger: { type: "object", additionalProperties: !1, required: ["type"], properties: { type: { type: "string", enum: ["combination", "double"] }, keys: { type: "array", items: { type: "string" }, minItems: 1 }, interval: { type: "number" } }, allOf: [{ if: { properties: { type: { const: "combination" } }, required: ["type"] }, then: { required: ["keys"] } }, { if: { properties: { type: { const: "double" } }, required: ["type"] }, then: { required: ["keys"] } }] }, patientFields: { type: "object", additionalProperties: !1, required: ["primaryFields", "additionalFields"], properties: { primaryFields: { type: "array", items: { type: "string", enum: ["name", "identifier", "age", "gender", "birthDate", "addressFieldValue", "extraIdentifiers", "customAttribute", "activeVisitUuid"] } }, additionalFields: { type: "array", items: { type: "string", enum: ["name", "identifier", "age", "gender", "birthDate", "addressFieldValue", "extraIdentifiers", "customAttribute", "activeVisitUuid"] } } } }, searchAnnotations: { type: "array", items: { type: "object", additionalProperties: !1, required: ["prefix", "label"], properties: { prefix: { type: "string" }, label: { type: "string" }, searchType: { type: "string", enum: ["patientAttribute", "patientNameOrId"] }, fieldType: { type: "string", enum: ["person", "address"] }, fieldsToSearch: { type: "array", items: { type: "string" } } }, if: { not: { properties: { searchType: { const: "patientNameOrId" } }, required: ["searchType"] } }, then: { required: ["fieldType", "fieldsToSearch"] } } } } } }, J = {
|
|
13
13
|
$schema: w,
|
|
14
|
-
title:
|
|
14
|
+
title: B,
|
|
15
15
|
type: $,
|
|
16
|
-
required:
|
|
16
|
+
required: K,
|
|
17
17
|
properties: H
|
|
18
18
|
};
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function W(e, r) {
|
|
20
|
+
return e.appContext ? (Array.isArray(e.appContext) ? e.appContext : [e.appContext]).some((p) => r.startsWith(p)) : !0;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const [
|
|
22
|
+
function Y() {
|
|
23
|
+
const [e, r] = a([]), [o, p] = a([]), [P, A] = a(U), [h, T] = a(j), [b, C] = a([]), [d, E] = a(
|
|
24
24
|
[]
|
|
25
|
-
), [m, v] = a(null), { pathname: c } =
|
|
25
|
+
), [m, v] = a(null), { pathname: c } = x();
|
|
26
26
|
return f(() => {
|
|
27
27
|
const s = new AbortController();
|
|
28
28
|
return (async () => {
|
|
29
|
-
const [,
|
|
30
|
-
|
|
29
|
+
const [, t, i, l] = await Promise.allSettled([
|
|
30
|
+
F(L),
|
|
31
31
|
N(
|
|
32
|
-
|
|
32
|
+
S,
|
|
33
33
|
J
|
|
34
34
|
),
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
M(),
|
|
36
|
+
O("command-palette")
|
|
37
37
|
]);
|
|
38
38
|
if (s.signal.aborted) return;
|
|
39
|
-
const u =
|
|
39
|
+
const u = t.status === "fulfilled" ? t.value : null;
|
|
40
40
|
if (u) {
|
|
41
41
|
const n = u.commandPalette;
|
|
42
|
-
n?.trigger &&
|
|
42
|
+
n?.trigger && T(n.trigger), n?.patientFields && A(n.patientFields), n?.searchAnnotations && C(n.searchAnnotations);
|
|
43
43
|
}
|
|
44
44
|
v(
|
|
45
45
|
i.status === "fulfilled" ? i.value : null
|
|
46
|
-
),
|
|
47
|
-
|
|
46
|
+
), E(
|
|
47
|
+
l.status === "fulfilled" ? l.value : []
|
|
48
48
|
);
|
|
49
49
|
})(), () => s.abort();
|
|
50
50
|
}, []), f(() => {
|
|
51
|
-
const s = (
|
|
52
|
-
(i) => !i.requiredPrivilege ||
|
|
53
|
-
).sort((i,
|
|
51
|
+
const s = (t) => d.filter((i) => i.extensionPointId === t).filter((i) => W(i, c)).filter(
|
|
52
|
+
(i) => !i.requiredPrivilege || q(m, i.requiredPrivilege)
|
|
53
|
+
).sort((i, l) => (i.order ?? 0) - (l.order ?? 0));
|
|
54
54
|
r(
|
|
55
|
-
s(
|
|
56
|
-
id:
|
|
57
|
-
label:
|
|
58
|
-
path:
|
|
59
|
-
icon:
|
|
60
|
-
newTab:
|
|
55
|
+
s(R).map((t) => ({
|
|
56
|
+
id: t.id,
|
|
57
|
+
label: g(t),
|
|
58
|
+
path: t.url ?? "",
|
|
59
|
+
icon: t.icon,
|
|
60
|
+
newTab: t.newTab
|
|
61
61
|
}))
|
|
62
|
-
),
|
|
63
|
-
s(k).map((
|
|
64
|
-
id:
|
|
65
|
-
label:
|
|
66
|
-
icon:
|
|
67
|
-
getPath: V(
|
|
68
|
-
basePath:
|
|
62
|
+
), p(
|
|
63
|
+
s(k).map((t) => ({
|
|
64
|
+
id: t.id,
|
|
65
|
+
label: g(t),
|
|
66
|
+
icon: t.icon,
|
|
67
|
+
getPath: V(t.pathTemplate ?? ""),
|
|
68
|
+
basePath: G(t.pathTemplate ?? "")
|
|
69
69
|
}))
|
|
70
70
|
);
|
|
71
71
|
}, [d, m, c]), {
|
|
72
|
-
navItems:
|
|
72
|
+
navItems: e,
|
|
73
73
|
patientActions: o,
|
|
74
|
-
patientFieldsConfig:
|
|
74
|
+
patientFieldsConfig: P,
|
|
75
75
|
trigger: h,
|
|
76
|
-
searchAnnotations:
|
|
76
|
+
searchAnnotations: b
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
const z = ({
|
|
80
|
-
children:
|
|
80
|
+
children: e
|
|
81
81
|
}) => {
|
|
82
|
-
const r =
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
}
|
|
85
|
-
|
|
82
|
+
const r = Y();
|
|
83
|
+
return /* @__PURE__ */ y(_, { ...r, children: e });
|
|
84
|
+
}, Q = ({
|
|
85
|
+
children: e
|
|
86
|
+
}) => localStorage.getItem(D) === "true" ? /* @__PURE__ */ y(z, { children: e }) : e;
|
|
87
|
+
Q.displayName = "BahmniCommandPaletteProvider";
|
|
86
88
|
export {
|
|
87
|
-
|
|
89
|
+
Q as CommandPaletteProvider
|
|
88
90
|
};
|