@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;AAG9C,UAAU,2BAA2B;IACnC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CASxE,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"}
@@ -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 E } from "react/jsx-runtime";
2
- import { CommandPaletteProvider as I } from "@bahmni/widgets";
3
- import { formatUrl as F, initAppI18n as _, getConfig as N, getCurrentUserPrivileges as q, fetchModuleExtensions as x, hasPrivilege as M } from "@bahmni/services";
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 O } from "react-router-dom";
6
- const L = "command-palette", D = "/bahmni_config/openmrs/apps/command-palette/app.json", S = {
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
- }, j = {
9
+ }, U = {
10
10
  primaryFields: ["name", "identifier"],
11
11
  additionalFields: ["age", "gender"]
12
- }, U = "org.bahmni.commandpalette.navItem", k = "org.bahmni.commandpalette.patientAction", R = (t) => t.split("{{")[0].replace(/\/$/, ""), V = (t) => ({ patientUuid: r, patientIdentifier: o = "" }) => F(t, { patientUuid: r, patientIdentifier: o }), y = (t) => t.translationKey ?? t.label ?? "", w = "http://json-schema.org/draft-07/schema#", G = "Command Palette App Configuration", $ = "object", B = ["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 = {
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: G,
14
+ title: B,
15
15
  type: $,
16
- required: B,
16
+ required: K,
17
17
  properties: H
18
18
  };
19
- function K(t, r) {
20
- return t.appContext ? (Array.isArray(t.appContext) ? t.appContext : [t.appContext]).some((l) => r.startsWith(l)) : !0;
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 W() {
23
- const [t, r] = a([]), [o, l] = a([]), [g, P] = a(j), [h, A] = a(S), [T, b] = a([]), [d, C] = a(
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 } = O();
25
+ ), [m, v] = a(null), { pathname: c } = x();
26
26
  return f(() => {
27
27
  const s = new AbortController();
28
28
  return (async () => {
29
- const [, e, i, p] = await Promise.allSettled([
30
- _(L),
29
+ const [, t, i, l] = await Promise.allSettled([
30
+ F(L),
31
31
  N(
32
- D,
32
+ S,
33
33
  J
34
34
  ),
35
- q(),
36
- x("command-palette")
35
+ M(),
36
+ O("command-palette")
37
37
  ]);
38
38
  if (s.signal.aborted) return;
39
- const u = e.status === "fulfilled" ? e.value : null;
39
+ const u = t.status === "fulfilled" ? t.value : null;
40
40
  if (u) {
41
41
  const n = u.commandPalette;
42
- n?.trigger && A(n.trigger), n?.patientFields && P(n.patientFields), n?.searchAnnotations && b(n.searchAnnotations);
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
- ), C(
47
- p.status === "fulfilled" ? p.value : []
46
+ ), E(
47
+ l.status === "fulfilled" ? l.value : []
48
48
  );
49
49
  })(), () => s.abort();
50
50
  }, []), f(() => {
51
- const s = (e) => d.filter((i) => i.extensionPointId === e).filter((i) => K(i, c)).filter(
52
- (i) => !i.requiredPrivilege || M(m, i.requiredPrivilege)
53
- ).sort((i, p) => (i.order ?? 0) - (p.order ?? 0));
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(U).map((e) => ({
56
- id: e.id,
57
- label: y(e),
58
- path: e.url ?? "",
59
- icon: e.icon,
60
- newTab: e.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
- ), l(
63
- s(k).map((e) => ({
64
- id: e.id,
65
- label: y(e),
66
- icon: e.icon,
67
- getPath: V(e.pathTemplate ?? ""),
68
- basePath: R(e.pathTemplate ?? "")
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: t,
72
+ navItems: e,
73
73
  patientActions: o,
74
- patientFieldsConfig: g,
74
+ patientFieldsConfig: P,
75
75
  trigger: h,
76
- searchAnnotations: T
76
+ searchAnnotations: b
77
77
  };
78
78
  }
79
79
  const z = ({
80
- children: t
80
+ children: e
81
81
  }) => {
82
- const r = W();
83
- return /* @__PURE__ */ E(I, { ...r, children: t });
84
- };
85
- z.displayName = "BahmniCommandPaletteProvider";
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
- z as CommandPaletteProvider
89
+ Q as CommandPaletteProvider
88
90
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bahmni/command-palette-app",
3
- "version": "0.0.1-dev.321",
3
+ "version": "0.0.1-dev.326",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",