@openmrs/esm-form-builder-app 2.0.2-pre.574 → 2.0.2-pre.586

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 (85) hide show
  1. package/README.md +43 -17
  2. package/dist/127.js +1 -1
  3. package/dist/127.js.map +1 -1
  4. package/dist/150.js +1 -1
  5. package/dist/150.js.map +1 -1
  6. package/dist/153.js +1 -1
  7. package/dist/153.js.map +1 -1
  8. package/dist/164.js +1 -1
  9. package/dist/256.js +1 -1
  10. package/dist/319.js +1 -1
  11. package/dist/447.js +1 -1
  12. package/dist/447.js.map +1 -1
  13. package/dist/515.js +2 -0
  14. package/dist/{773.js.LICENSE.txt → 515.js.LICENSE.txt} +9 -0
  15. package/dist/515.js.map +1 -0
  16. package/dist/527.js +1 -0
  17. package/dist/527.js.map +1 -0
  18. package/dist/574.js +1 -1
  19. package/dist/757.js +1 -1
  20. package/dist/788.js +1 -1
  21. package/dist/800.js +1 -1
  22. package/dist/800.js.map +1 -1
  23. package/dist/807.js +1 -1
  24. package/dist/833.js +1 -1
  25. package/dist/878.js +2 -0
  26. package/dist/{208.js.LICENSE.txt → 878.js.LICENSE.txt} +2 -1
  27. package/dist/878.js.map +1 -0
  28. package/dist/main.js +1 -1
  29. package/dist/main.js.map +1 -1
  30. package/dist/openmrs-esm-form-builder-app.js +1 -1
  31. package/dist/openmrs-esm-form-builder-app.js.buildmanifest.json +154 -175
  32. package/dist/openmrs-esm-form-builder-app.js.map +1 -1
  33. package/dist/routes.json +1 -1
  34. package/package.json +35 -32
  35. package/src/components/action-buttons/action-buttons.component.tsx +65 -101
  36. package/src/components/dashboard/dashboard.component.tsx +98 -174
  37. package/src/components/dashboard/dashboard.test.tsx +51 -81
  38. package/src/components/empty-state/empty-data-illustration.component.tsx +4 -16
  39. package/src/components/empty-state/empty-state.component.tsx +11 -15
  40. package/src/components/error-state/error-state.component.tsx +11 -13
  41. package/src/components/form-editor/form-editor.component.tsx +97 -128
  42. package/src/components/form-renderer/form-renderer.component.tsx +30 -41
  43. package/src/components/interactive-builder/add-question-modal.component.tsx +129 -167
  44. package/src/components/interactive-builder/delete-page-modal.component.tsx +24 -37
  45. package/src/components/interactive-builder/delete-question-modal.component.tsx +25 -47
  46. package/src/components/interactive-builder/delete-section-modal.component.tsx +24 -37
  47. package/src/components/interactive-builder/draggable-question.component.tsx +21 -34
  48. package/src/components/interactive-builder/droppable-container.component.tsx +5 -5
  49. package/src/components/interactive-builder/edit-question-modal.component.tsx +191 -233
  50. package/src/components/interactive-builder/editable-value.component.tsx +12 -17
  51. package/src/components/interactive-builder/interactive-builder.component.tsx +134 -184
  52. package/src/components/interactive-builder/new-form-modal.component.tsx +35 -49
  53. package/src/components/interactive-builder/page-modal.component.tsx +29 -45
  54. package/src/components/interactive-builder/question-modal.scss +7 -0
  55. package/src/components/interactive-builder/section-modal.component.tsx +29 -40
  56. package/src/components/interactive-builder/value-editor.component.tsx +11 -16
  57. package/src/components/modals/save-form-modal.component.tsx +112 -165
  58. package/src/components/pagination/index.ts +2 -2
  59. package/src/components/pagination/pagination.component.tsx +8 -13
  60. package/src/components/pagination/usePaginationInfo.ts +4 -9
  61. package/src/components/schema-editor/schema-editor.component.tsx +11 -17
  62. package/src/config-schema.ts +28 -30
  63. package/src/declarations.d.ts +4 -3
  64. package/src/form-builder-admin-card-link.component.tsx +7 -11
  65. package/src/forms.resource.ts +66 -87
  66. package/src/hooks/useClobdata.ts +10 -12
  67. package/src/hooks/useConceptLookup.ts +5 -8
  68. package/src/hooks/useConceptName.ts +6 -9
  69. package/src/hooks/useEncounterTypes.ts +8 -8
  70. package/src/hooks/useForm.ts +7 -7
  71. package/src/hooks/useForms.ts +5 -8
  72. package/src/index.ts +11 -23
  73. package/src/root.component.tsx +4 -4
  74. package/src/setup-tests.ts +1 -9
  75. package/src/test-helpers.tsx +8 -15
  76. package/src/types.ts +16 -8
  77. package/dist/208.js +0 -2
  78. package/dist/208.js.map +0 -1
  79. package/dist/536.js +0 -1
  80. package/dist/536.js.map +0 -1
  81. package/dist/62.js +0 -1
  82. package/dist/62.js.map +0 -1
  83. package/dist/773.js +0 -2
  84. package/dist/773.js.map +0 -1
  85. package/src/constants.ts +0 -3
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@openmrs/esm-form-builder-app",
3
- "version": "2.0.2-pre.574",
3
+ "version": "2.0.2-pre.586",
4
4
  "license": "MPL-2.0",
5
5
  "description": "OpenMRS ESM Form Builder App",
6
6
  "browser": "dist/openmrs-esm-form-builder-app.js",
7
7
  "main": "src/index.ts",
8
8
  "source": true,
9
+ "lint-staged": {
10
+ "*.{js,jsx,ts,tsx}": "eslint --cache --fix"
11
+ },
9
12
  "scripts": {
10
13
  "start": "openmrs develop",
11
14
  "serve": "webpack serve --mode=development",
12
15
  "build": "webpack --mode production",
13
16
  "analyze": "webpack --mode=production --env.analyze=true",
14
- "lint": "TIMING=1 eslint src --ext js,jsx,ts,tsx",
17
+ "lint": "TIMING=1 eslint src --ext js,jsx,ts,tsx --max-warnings=0",
15
18
  "prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
16
19
  "typescript": "tsc",
17
20
  "test": "jest --config jest.config.js",
@@ -32,7 +35,6 @@
32
35
  "keywords": [
33
36
  "openmrs",
34
37
  "microfrontends",
35
- "formbuilder",
36
38
  "form builder"
37
39
  ],
38
40
  "repository": {
@@ -47,13 +49,13 @@
47
49
  "url": "https://github.com/openmrs/openmrs-esm-form-builder/issues"
48
50
  },
49
51
  "dependencies": {
50
- "@carbon/react": "^1.31.0",
52
+ "@carbon/react": "^1.38.0",
51
53
  "@openmrs/openmrs-form-engine-lib": "next",
52
- "dotenv": "^16.1.4",
54
+ "dotenv": "^16.3.1",
53
55
  "file-loader": "^6.2.0",
54
56
  "lodash-es": "^4.17.21",
55
57
  "react-ace": "^10.1.0",
56
- "sass": "^1.63.3"
58
+ "sass": "^1.67.0"
57
59
  },
58
60
  "peerDependencies": {
59
61
  "@openmrs/esm-framework": "*",
@@ -69,44 +71,45 @@
69
71
  "@dnd-kit/utilities": "^3.2.1",
70
72
  "@openmrs/esm-framework": "next",
71
73
  "@openmrs/esm-styleguide": "next",
72
- "@playwright/test": "^1.35.0",
74
+ "@playwright/test": "^1.38.0",
73
75
  "@swc/cli": "^0.1.62",
74
- "@swc/core": "^1.3.62",
75
- "@swc/jest": "^0.2.26",
76
- "@testing-library/dom": "^8.20.0",
77
- "@testing-library/jest-dom": "^5.16.5",
78
- "@testing-library/react": "^13.4.0",
79
- "@testing-library/user-event": "^14.4.3",
80
- "@types/jest": "^29.5.2",
81
- "@types/react": "^18.2.12",
82
- "@types/react-dom": "^18.2.5",
76
+ "@swc/core": "^1.3.85",
77
+ "@swc/jest": "^0.2.29",
78
+ "@testing-library/dom": "^9.3.1",
79
+ "@testing-library/jest-dom": "^6.1.3",
80
+ "@testing-library/react": "^14.0.0",
81
+ "@testing-library/user-event": "^14.5.1",
82
+ "@types/jest": "^29.5.5",
83
+ "@types/react": "^18.2.21",
84
+ "@types/react-dom": "^18.2.7",
83
85
  "@types/webpack-env": "^1.18.1",
84
- "@typescript-eslint/eslint-plugin": "^5.59.11",
85
- "@typescript-eslint/parser": "^5.59.11",
86
+ "@typescript-eslint/eslint-plugin": "^6.7.0",
87
+ "@typescript-eslint/parser": "^6.7.0",
86
88
  "css-loader": "^6.8.1",
87
- "eslint": "^8.42.0",
88
- "eslint-config-prettier": "^8.8.0",
89
+ "eslint": "^8.49.0",
90
+ "eslint-config-prettier": "^9.0.0",
89
91
  "eslint-config-ts-react-important-stuff": "^3.0.0",
90
- "eslint-plugin-prettier": "^4.2.1",
92
+ "eslint-plugin-playwright": "^0.16.0",
93
+ "eslint-plugin-prettier": "^5.0.0",
91
94
  "husky": "^8.0.3",
92
- "i18next": "^19.9.2",
93
- "i18next-parser": "^5.4.0",
95
+ "i18next": "^23.5.1",
96
+ "i18next-parser": "^8.7.0",
94
97
  "identity-obj-proxy": "^3.0.0",
95
- "jest": "^29.5.0",
96
- "jest-cli": "^29.5.0",
97
- "jest-environment-jsdom": "^29.5.0",
98
+ "jest": "^29.7.0",
99
+ "jest-cli": "^29.7.0",
100
+ "jest-environment-jsdom": "^29.7.0",
101
+ "lint-staged": "^14.0.1",
98
102
  "openmrs": "next",
99
- "prettier": "^2.8.8",
100
- "pretty-quick": "^3.1.3",
103
+ "prettier": "^3.0.3",
101
104
  "react": "^18.2.0",
102
105
  "react-dom": "^18.2.0",
103
- "react-error-boundary": "^4.0.10",
104
- "react-i18next": "^11.18.6",
106
+ "react-error-boundary": "^4.0.11",
107
+ "react-i18next": "^13.2.2",
105
108
  "rxjs": "^7.8.1",
106
109
  "swc-loader": "^0.2.3",
107
- "turbo": "^1.10.3",
110
+ "turbo": "^1.10.14",
108
111
  "typescript": "^4.9.5",
109
- "webpack": "^5.86.0",
112
+ "webpack": "^5.88.2",
110
113
  "webpack-cli": "^5.1.4"
111
114
  },
112
115
  "packageManager": "yarn@3.6.0",
@@ -1,39 +1,26 @@
1
- import React, { useState } from "react";
2
- import {
3
- Button,
4
- ComposedModal,
5
- InlineLoading,
6
- ModalBody,
7
- ModalFooter,
8
- ModalHeader,
9
- } from "@carbon/react";
10
- import { useParams } from "react-router-dom";
11
- import { showToast, showNotification } from "@openmrs/esm-framework";
12
-
13
- import type { TFunction } from "react-i18next";
14
- import type { RouteParams, Schema } from "../../types";
15
- import { publishForm, unpublishForm } from "../../forms.resource";
16
- import { useForm } from "../../hooks/useForm";
17
- import SaveFormModal from "../modals/save-form-modal.component";
18
- import styles from "./action-buttons.scss";
19
-
20
- type ActionButtonsProps = {
1
+ import React, { useState } from 'react';
2
+ import { Button, ComposedModal, InlineLoading, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
3
+ import type { TFunction } from 'i18next';
4
+ import { useParams } from 'react-router-dom';
5
+ import { showToast, showNotification } from '@openmrs/esm-framework';
6
+
7
+ import type { Schema } from '../../types';
8
+ import { publishForm, unpublishForm } from '../../forms.resource';
9
+ import { useForm } from '../../hooks/useForm';
10
+ import SaveFormModal from '../modals/save-form-modal.component';
11
+ import styles from './action-buttons.scss';
12
+
13
+ interface ActionButtonsProps {
21
14
  schema: Schema;
22
15
  t: TFunction;
23
- };
16
+ }
24
17
 
25
- type Status =
26
- | "idle"
27
- | "publishing"
28
- | "published"
29
- | "unpublishing"
30
- | "unpublished"
31
- | "error";
18
+ type Status = 'idle' | 'publishing' | 'published' | 'unpublishing' | 'unpublished' | 'error';
32
19
 
33
20
  function ActionButtons({ schema, t }: ActionButtonsProps) {
34
- const { formUuid } = useParams<RouteParams>();
21
+ const { formUuid } = useParams<{ formUuid?: string }>();
35
22
  const { form, mutate } = useForm(formUuid);
36
- const [status, setStatus] = useState<Status>("idle");
23
+ const [status, setStatus] = useState<Status>('idle');
37
24
  const [showUnpublishModal, setShowUnpublishModal] = useState(false);
38
25
 
39
26
  const launchUnpublishModal = () => {
@@ -41,56 +28,57 @@ function ActionButtons({ schema, t }: ActionButtonsProps) {
41
28
  };
42
29
 
43
30
  async function handlePublish() {
44
- setStatus("publishing");
31
+ setStatus('publishing');
45
32
  try {
46
33
  await publishForm(form.uuid);
47
34
 
48
35
  showToast({
49
- title: t("formPublished", "Form published"),
50
- kind: "success",
36
+ title: t('formPublished', 'Form published'),
37
+ kind: 'success',
51
38
  critical: true,
52
- description:
53
- `${form.name} ` +
54
- t("formPublishedSuccessfully", "form was published successfully"),
39
+ description: `${form.name} ` + t('formPublishedSuccessfully', 'form was published successfully'),
55
40
  });
56
41
 
57
- setStatus("published");
58
- mutate();
42
+ setStatus('published');
43
+ await mutate();
59
44
  } catch (error) {
60
- showNotification({
61
- title: t("errorPublishingForm", "Error publishing form"),
62
- kind: "error",
63
- critical: true,
64
- description: error?.message,
65
- });
66
- setStatus("error");
45
+ if (error instanceof Error) {
46
+ showNotification({
47
+ title: t('errorPublishingForm', 'Error publishing form'),
48
+ kind: 'error',
49
+ critical: true,
50
+ description: error?.message,
51
+ });
52
+ setStatus('error');
53
+ }
67
54
  }
68
55
  }
69
56
 
70
57
  async function handleUnpublish() {
71
- setStatus("unpublishing");
58
+ setStatus('unpublishing');
59
+
72
60
  try {
73
61
  await unpublishForm(form.uuid);
74
62
 
75
63
  showToast({
76
- title: t("formUnpublished", "Form unpublished"),
77
- kind: "success",
64
+ title: t('formUnpublished', 'Form unpublished'),
65
+ kind: 'success',
78
66
  critical: true,
79
- description:
80
- `${form.name} ` +
81
- t("formUnpublishedSuccessfully", "form was unpublished successfully"),
67
+ description: `${form.name} ` + t('formUnpublishedSuccessfully', 'form was unpublished successfully'),
82
68
  });
83
69
 
84
- setStatus("unpublished");
85
- mutate();
70
+ setStatus('unpublished');
71
+ await mutate();
86
72
  } catch (error) {
87
- showNotification({
88
- title: t("errorUnpublishingForm", "Error unpublishing form"),
89
- kind: "error",
90
- critical: true,
91
- description: error?.message,
92
- });
93
- setStatus("error");
73
+ if (error instanceof Error) {
74
+ showNotification({
75
+ title: t('errorUnpublishingForm', 'Error unpublishing form'),
76
+ kind: 'error',
77
+ critical: true,
78
+ description: error?.message,
79
+ });
80
+ setStatus('error');
81
+ }
94
82
  }
95
83
  setShowUnpublishModal(false);
96
84
  }
@@ -101,71 +89,47 @@ function ActionButtons({ schema, t }: ActionButtonsProps) {
101
89
 
102
90
  <>
103
91
  {form && !form.published ? (
104
- <Button
105
- kind="secondary"
106
- onClick={handlePublish}
107
- disabled={status === "publishing"}
108
- >
109
- {status === "publishing" && !form?.published ? (
110
- <InlineLoading
111
- className={styles.spinner}
112
- description={t("publishing", "Publishing") + "..."}
113
- />
92
+ <Button kind="secondary" onClick={handlePublish} disabled={status === 'publishing'}>
93
+ {status === 'publishing' && !form?.published ? (
94
+ <InlineLoading className={styles.spinner} description={t('publishing', 'Publishing') + '...'} />
114
95
  ) : (
115
- <span>{t("publishForm", "Publish form")}</span>
96
+ <span>{t('publishForm', 'Publish form')}</span>
116
97
  )}
117
98
  </Button>
118
99
  ) : null}
119
100
 
120
101
  {form && form.published ? (
121
- <Button
122
- kind="danger"
123
- onClick={launchUnpublishModal}
124
- disabled={status === "unpublishing"}
125
- >
126
- {t("unpublishForm", "Unpublish form")}
102
+ <Button kind="danger" onClick={launchUnpublishModal} disabled={status === 'unpublishing'}>
103
+ {t('unpublishForm', 'Unpublish form')}
127
104
  </Button>
128
105
  ) : null}
129
106
 
130
107
  {showUnpublishModal ? (
131
- <ComposedModal
132
- open={true}
133
- onClose={() => setShowUnpublishModal(false)}
134
- preventCloseOnClickOutside
135
- >
108
+ <ComposedModal open={true} onClose={() => setShowUnpublishModal(false)} preventCloseOnClickOutside>
136
109
  <ModalHeader
137
- title={t(
138
- "unpublishConfirmation",
139
- "Are you sure you want to unpublish this form?"
140
- )}
110
+ title={t('unpublishConfirmation', 'Are you sure you want to unpublish this form?')}
141
111
  ></ModalHeader>
142
112
  <ModalBody>
143
113
  <p>
144
114
  {t(
145
- "unpublishExplainerText",
146
- "Unpublishing a form means you can no longer access it from your frontend. Unpublishing forms does not delete their associated schemas, it only affects whether or not you can access them in your frontend."
115
+ 'unpublishExplainerText',
116
+ 'Unpublishing a form means you can no longer access it from your frontend. Unpublishing forms does not delete their associated schemas, it only affects whether or not you can access them in your frontend.',
147
117
  )}
148
118
  </p>
149
119
  </ModalBody>
150
120
  <ModalFooter>
151
- <Button
152
- kind="secondary"
153
- onClick={() => setShowUnpublishModal(false)}
154
- >
155
- {t("cancel", "Cancel")}
121
+ <Button kind="secondary" onClick={() => setShowUnpublishModal(false)}>
122
+ {t('cancel', 'Cancel')}
156
123
  </Button>
157
124
  <Button
158
- disabled={status === "unpublishing"}
159
- kind={status === "unpublishing" ? "secondary" : "danger"}
125
+ disabled={status === 'unpublishing'}
126
+ kind={status === 'unpublishing' ? 'secondary' : 'danger'}
160
127
  onClick={handleUnpublish}
161
128
  >
162
- {status === "unpublishing" ? (
163
- <InlineLoading
164
- className={styles.spinner}
165
- description={t("unpublishing", "Unpublishing") + "..."}
166
- />
129
+ {status === 'unpublishing' ? (
130
+ <InlineLoading className={styles.spinner} description={t('unpublishing', 'Unpublishing') + '...'} />
167
131
  ) : (
168
- <span>{t("unpublishForm", "Unpublish form")}</span>
132
+ <span>{t('confirm', 'Confirm')}</span>
169
133
  )}
170
134
  </Button>
171
135
  </ModalFooter>