@openmrs/esm-framework 10.0.1-pre.4947 → 10.0.1-pre.4968

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,3 +1,3 @@
1
- [0] Successfully compiled: 3 files with swc (144.49ms)
1
+ [0] Successfully compiled: 3 files with swc (136.32ms)
2
2
  [0] swc --strip-leading-paths src -d dist exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
package/mock-jest.tsx CHANGED
@@ -111,7 +111,7 @@ export const navigateAndLaunchWorkspace = jest.fn();
111
111
  export const useWorkspaces = jest.fn();
112
112
  export const useWorkspace2Context = jest.fn();
113
113
 
114
- export const OpenmrsDatePicker = jest.fn(({ id, labelText, value, onChange, isInvalid, invalidText }) => (
114
+ export const OpenmrsDatePicker = jest.fn(({ id, labelText, value, onChange, invalid, isInvalid, invalidText }) => (
115
115
  <>
116
116
  <label htmlFor={id}>{labelText}</label>
117
117
  <input
@@ -120,39 +120,41 @@ export const OpenmrsDatePicker = jest.fn(({ id, labelText, value, onChange, isIn
120
120
  value={value ? dayjs(value).format('DD/MM/YYYY') : ''}
121
121
  onChange={(evt) => onChange?.(dayjs(evt.target.value).toDate())}
122
122
  />
123
- {isInvalid && <span>{invalidText}</span>}
123
+ {(invalid || isInvalid) && <span>{invalidText}</span>}
124
124
  </>
125
125
  ));
126
126
 
127
- export const OpenmrsDateRangePicker = jest.fn(({ id, labelText, value = [], onChange, isInvalid, invalidText }) => {
128
- const [inputValue, setInputValue] = useState(() => {
129
- const [start, end] = value;
130
- const formattedStart = start ? dayjs(start).format('DD/MM/YYYY') : 'dd/mm/yyyy';
131
- const formattedEnd = end ? dayjs(end).format('DD/MM/YYYY') : 'dd/mm/yyyy';
132
- return `${formattedStart}–${formattedEnd}`;
133
- });
134
-
135
- const handleChange = (e) => {
136
- const raw = e.target.value;
137
- setInputValue(raw);
138
-
139
- const [startStr, endStr] = raw.split('–');
140
- const start = dayjs(startStr, 'DD/MM/YYYY', true);
141
- const end = dayjs(endStr, 'DD/MM/YYYY', true);
142
-
143
- if (start.isValid() && end.isValid()) {
144
- onChange?.([start.toDate(), end.toDate()]);
145
- }
146
- };
147
-
148
- return (
149
- <div>
150
- <label htmlFor={id}>{labelText}</label>
151
- <input id={id} type="text" value={inputValue} onChange={handleChange} />
152
- {isInvalid && <span>{invalidText}</span>}
153
- </div>
154
- );
155
- });
127
+ export const OpenmrsDateRangePicker = jest.fn(
128
+ ({ id, labelText, value = [], onChange, invalid, isInvalid, invalidText }) => {
129
+ const [inputValue, setInputValue] = useState(() => {
130
+ const [start, end] = value;
131
+ const formattedStart = start ? dayjs(start).format('DD/MM/YYYY') : 'dd/mm/yyyy';
132
+ const formattedEnd = end ? dayjs(end).format('DD/MM/YYYY') : 'dd/mm/yyyy';
133
+ return `${formattedStart}–${formattedEnd}`;
134
+ });
135
+
136
+ const handleChange = (e) => {
137
+ const raw = e.target.value;
138
+ setInputValue(raw);
139
+
140
+ const [startStr, endStr] = raw.split('');
141
+ const start = dayjs(startStr, 'DD/MM/YYYY', true);
142
+ const end = dayjs(endStr, 'DD/MM/YYYY', true);
143
+
144
+ if (start.isValid() && end.isValid()) {
145
+ onChange?.([start.toDate(), end.toDate()]);
146
+ }
147
+ };
148
+
149
+ return (
150
+ <div>
151
+ <label htmlFor={id}>{labelText}</label>
152
+ <input id={id} type="text" value={inputValue} onChange={handleChange} />
153
+ {(invalid || isInvalid) && <span>{invalidText}</span>}
154
+ </div>
155
+ );
156
+ },
157
+ );
156
158
 
157
159
  /* esm-utils */
158
160
  export {
package/mock.tsx CHANGED
@@ -112,7 +112,7 @@ export const navigateAndLaunchWorkspace = vi.fn();
112
112
  export const useWorkspaces = vi.fn();
113
113
  export const useWorkspace2Context = vi.fn();
114
114
 
115
- export const OpenmrsDatePicker = vi.fn(({ id, labelText, value, onChange, isInvalid, invalidText }) => (
115
+ export const OpenmrsDatePicker = vi.fn(({ id, labelText, value, onChange, invalid, isInvalid, invalidText }) => (
116
116
  <>
117
117
  <label htmlFor={id}>{labelText}</label>
118
118
  <input
@@ -121,39 +121,41 @@ export const OpenmrsDatePicker = vi.fn(({ id, labelText, value, onChange, isInva
121
121
  value={value ? dayjs(value).format('DD/MM/YYYY') : ''}
122
122
  onChange={(evt) => onChange?.(dayjs(evt.target.value).toDate())}
123
123
  />
124
- {isInvalid && <span>{invalidText}</span>}
124
+ {(invalid || isInvalid) && <span>{invalidText}</span>}
125
125
  </>
126
126
  ));
127
127
 
128
- export const OpenmrsDateRangePicker = vi.fn(({ id, labelText, value = [], onChange, isInvalid, invalidText }) => {
129
- const [inputValue, setInputValue] = useState(() => {
130
- const [start, end] = value;
131
- const formattedStart = start ? dayjs(start).format('DD/MM/YYYY') : 'dd/mm/yyyy';
132
- const formattedEnd = end ? dayjs(end).format('DD/MM/YYYY') : 'dd/mm/yyyy';
133
- return `${formattedStart}–${formattedEnd}`;
134
- });
135
-
136
- const handleChange = (e) => {
137
- const raw = e.target.value;
138
- setInputValue(raw);
139
-
140
- const [startStr, endStr] = raw.split('–');
141
- const start = dayjs(startStr, 'DD/MM/YYYY', true);
142
- const end = dayjs(endStr, 'DD/MM/YYYY', true);
143
-
144
- if (start.isValid() && end.isValid()) {
145
- onChange?.([start.toDate(), end.toDate()]);
146
- }
147
- };
148
-
149
- return (
150
- <div>
151
- <label htmlFor={id}>{labelText}</label>
152
- <input id={id} type="text" value={inputValue} onChange={handleChange} />
153
- {isInvalid && <span>{invalidText}</span>}
154
- </div>
155
- );
156
- });
128
+ export const OpenmrsDateRangePicker = vi.fn(
129
+ ({ id, labelText, value = [], onChange, invalid, isInvalid, invalidText }) => {
130
+ const [inputValue, setInputValue] = useState(() => {
131
+ const [start, end] = value;
132
+ const formattedStart = start ? dayjs(start).format('DD/MM/YYYY') : 'dd/mm/yyyy';
133
+ const formattedEnd = end ? dayjs(end).format('DD/MM/YYYY') : 'dd/mm/yyyy';
134
+ return `${formattedStart}–${formattedEnd}`;
135
+ });
136
+
137
+ const handleChange = (e) => {
138
+ const raw = e.target.value;
139
+ setInputValue(raw);
140
+
141
+ const [startStr, endStr] = raw.split('');
142
+ const start = dayjs(startStr, 'DD/MM/YYYY', true);
143
+ const end = dayjs(endStr, 'DD/MM/YYYY', true);
144
+
145
+ if (start.isValid() && end.isValid()) {
146
+ onChange?.([start.toDate(), end.toDate()]);
147
+ }
148
+ };
149
+
150
+ return (
151
+ <div>
152
+ <label htmlFor={id}>{labelText}</label>
153
+ <input id={id} type="text" value={inputValue} onChange={handleChange} />
154
+ {(invalid || isInvalid) && <span>{invalidText}</span>}
155
+ </div>
156
+ );
157
+ },
158
+ );
157
159
 
158
160
  /* esm-utils */
159
161
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-framework",
3
- "version": "10.0.1-pre.4947",
3
+ "version": "10.0.1-pre.4968",
4
4
  "license": "MPL-2.0",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
@@ -59,24 +59,24 @@
59
59
  "access": "public"
60
60
  },
61
61
  "dependencies": {
62
- "@openmrs/esm-api": "10.0.1-pre.4947",
63
- "@openmrs/esm-config": "10.0.1-pre.4947",
64
- "@openmrs/esm-context": "10.0.1-pre.4947",
65
- "@openmrs/esm-dynamic-loading": "10.0.1-pre.4947",
66
- "@openmrs/esm-emr-api": "10.0.1-pre.4947",
67
- "@openmrs/esm-error-handling": "10.0.1-pre.4947",
68
- "@openmrs/esm-expression-evaluator": "10.0.1-pre.4947",
69
- "@openmrs/esm-extensions": "10.0.1-pre.4947",
70
- "@openmrs/esm-feature-flags": "10.0.1-pre.4947",
71
- "@openmrs/esm-globals": "10.0.1-pre.4947",
72
- "@openmrs/esm-navigation": "10.0.1-pre.4947",
73
- "@openmrs/esm-offline": "10.0.1-pre.4947",
74
- "@openmrs/esm-react-utils": "10.0.1-pre.4947",
75
- "@openmrs/esm-routes": "10.0.1-pre.4947",
76
- "@openmrs/esm-state": "10.0.1-pre.4947",
77
- "@openmrs/esm-styleguide": "10.0.1-pre.4947",
78
- "@openmrs/esm-translations": "10.0.1-pre.4947",
79
- "@openmrs/esm-utils": "10.0.1-pre.4947"
62
+ "@openmrs/esm-api": "10.0.1-pre.4968",
63
+ "@openmrs/esm-config": "10.0.1-pre.4968",
64
+ "@openmrs/esm-context": "10.0.1-pre.4968",
65
+ "@openmrs/esm-dynamic-loading": "10.0.1-pre.4968",
66
+ "@openmrs/esm-emr-api": "10.0.1-pre.4968",
67
+ "@openmrs/esm-error-handling": "10.0.1-pre.4968",
68
+ "@openmrs/esm-expression-evaluator": "10.0.1-pre.4968",
69
+ "@openmrs/esm-extensions": "10.0.1-pre.4968",
70
+ "@openmrs/esm-feature-flags": "10.0.1-pre.4968",
71
+ "@openmrs/esm-globals": "10.0.1-pre.4968",
72
+ "@openmrs/esm-navigation": "10.0.1-pre.4968",
73
+ "@openmrs/esm-offline": "10.0.1-pre.4968",
74
+ "@openmrs/esm-react-utils": "10.0.1-pre.4968",
75
+ "@openmrs/esm-routes": "10.0.1-pre.4968",
76
+ "@openmrs/esm-state": "10.0.1-pre.4968",
77
+ "@openmrs/esm-styleguide": "10.0.1-pre.4968",
78
+ "@openmrs/esm-translations": "10.0.1-pre.4968",
79
+ "@openmrs/esm-utils": "10.0.1-pre.4968"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "dayjs": "1.x",
@@ -89,7 +89,7 @@
89
89
  "swr": "2.x"
90
90
  },
91
91
  "devDependencies": {
92
- "@openmrs/typedoc-plugin-file-categories": "10.0.1-pre.4947",
92
+ "@openmrs/typedoc-plugin-file-categories": "10.0.1-pre.4968",
93
93
  "@swc/cli": "0.8.1",
94
94
  "@swc/core": "1.15.21",
95
95
  "@vitest/coverage-v8": "^4.1.2",