@openmrs/esm-framework 5.1.1-pre.999 → 5.2.0

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.
package/docs/API.md CHANGED
@@ -26,6 +26,7 @@
26
26
  - [toLocationObject](API.md#tolocationobject)
27
27
  - [toVisitTypeObject](API.md#tovisittypeobject)
28
28
  - [updateVisit](API.md#updatevisit)
29
+ - [useDebounce](API.md#usedebounce)
29
30
  - [useLocations](API.md#uselocations)
30
31
  - [usePatient](API.md#usepatient)
31
32
  - [useSession](API.md#usesession)
@@ -62,6 +63,7 @@
62
63
  - [formatDate](API.md#formatdate)
63
64
  - [formatDatetime](API.md#formatdatetime)
64
65
  - [formatTime](API.md#formattime)
66
+ - [getLocale](API.md#getlocale)
65
67
  - [isOmrsDateStrict](API.md#isomrsdatestrict)
66
68
  - [isOmrsDateToday](API.md#isomrsdatetoday)
67
69
  - [parseDate](API.md#parsedate)
@@ -818,6 +820,16 @@ and *must* only be used once within that `<ExtensionSlot>`.
818
820
 
819
821
  ___
820
822
 
823
+ ### OpenmrsDatePicker
824
+
825
+ • `Const` **OpenmrsDatePicker**: `React.FC`<`OpenmrsDatePickerProps`\>
826
+
827
+ #### Defined in
828
+
829
+ [packages/framework/esm-styleguide/src/datepicker/openmrs/openmrs-date-picker.component.tsx:41](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/datepicker/openmrs/openmrs-date-picker.component.tsx#L41)
830
+
831
+ ___
832
+
821
833
  ### backendDependencies
822
834
 
823
835
  • `Const` **backendDependencies**: `Object`
@@ -839,7 +851,7 @@ ___
839
851
 
840
852
  ### LeftNavMenu
841
853
 
842
- • `Const` **LeftNavMenu**: `ForwardRefExoticComponent`<`Pick`<`SideNavProps`, `string` \| `number` \| `symbol`\> & `RefAttributes`<`HTMLElement`\>\>
854
+ • `Const` **LeftNavMenu**: `ForwardRefExoticComponent`<`RefAttributes`<`HTMLElement`\>\>
843
855
 
844
856
  #### Defined in
845
857
 
@@ -1366,6 +1378,58 @@ ___
1366
1378
 
1367
1379
  ___
1368
1380
 
1381
+ ### useDebounce
1382
+
1383
+ ▸ **useDebounce**<`T`\>(`value`, `delay?`): `T`
1384
+
1385
+ This hook debounces a state variable. That state variable can then be used as the
1386
+ value of a controlled input, while the return value of this hook is used for making
1387
+ a request.
1388
+
1389
+ **`example`**
1390
+ ```tsx
1391
+ import { useDebounce } from "@openmrs/esm-react-utils";
1392
+
1393
+ function MyComponent() {
1394
+ const [searchTerm, setSearchTerm] = useState('');
1395
+ const debouncedSearchTerm = useDebounce(searchTerm);
1396
+ const swrResult = useSWR(`/api/search?q=${debouncedSearchTerm}`)
1397
+
1398
+ return (
1399
+ <Search
1400
+ labelText={t('search', 'Search')}
1401
+ onChange={(e) => setSearchTerm(e.target.value)}
1402
+ value={searchTerm}
1403
+ />
1404
+ )
1405
+ }
1406
+ ```
1407
+
1408
+ #### Type parameters
1409
+
1410
+ | Name |
1411
+ | :------ |
1412
+ | `T` |
1413
+
1414
+ #### Parameters
1415
+
1416
+ | Name | Type | Default value | Description |
1417
+ | :------ | :------ | :------ | :------ |
1418
+ | `value` | `T` | `undefined` | The value that will be used to set `debounceValue` |
1419
+ | `delay` | `number` | `300` | The number of milliseconds to wait before updating `debounceValue` |
1420
+
1421
+ #### Returns
1422
+
1423
+ `T`
1424
+
1425
+ The debounced value
1426
+
1427
+ #### Defined in
1428
+
1429
+ [packages/framework/esm-react-utils/src/useDebounce.ts:32](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-react-utils/src/useDebounce.ts#L32)
1430
+
1431
+ ___
1432
+
1369
1433
  ### useLocations
1370
1434
 
1371
1435
  ▸ **useLocations**(): [`Location`](interfaces/Location.md)[]
@@ -1969,6 +2033,24 @@ Formats the input as a time, according to the current locale.
1969
2033
 
1970
2034
  ___
1971
2035
 
2036
+ ### getLocale
2037
+
2038
+ ▸ **getLocale**(): `string`
2039
+
2040
+ Returns the current locale of the application.
2041
+
2042
+ #### Returns
2043
+
2044
+ `string`
2045
+
2046
+ string
2047
+
2048
+ #### Defined in
2049
+
2050
+ [packages/framework/esm-utils/src/omrs-dates.ts:273](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/omrs-dates.ts#L273)
2051
+
2052
+ ___
2053
+
1972
2054
  ### isOmrsDateStrict
1973
2055
 
1974
2056
  ▸ **isOmrsDateStrict**(`omrsPayloadString`): `boolean`
@@ -2383,7 +2465,7 @@ An array of extensions assigned to the named slot
2383
2465
 
2384
2466
  #### Defined in
2385
2467
 
2386
- [packages/framework/esm-extensions/src/extensions.ts:373](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/extensions.ts#L373)
2468
+ [packages/framework/esm-extensions/src/extensions.ts:375](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-extensions/src/extensions.ts#L375)
2387
2469
 
2388
2470
  ___
2389
2471
 
@@ -3098,11 +3180,17 @@ ___
3098
3180
 
3099
3181
  ### getDynamicOfflineDataEntries
3100
3182
 
3101
- ▸ **getDynamicOfflineDataEntries**(`type?`): `Promise`<[`DynamicOfflineData`](interfaces/DynamicOfflineData.md)[]\>
3183
+ ▸ **getDynamicOfflineDataEntries**<`T`\>(`type?`): `Promise`<`T`[]\>
3102
3184
 
3103
3185
  Returns all [DynamicOfflineData](interfaces/DynamicOfflineData.md) entries which registered for the currently logged in user.
3104
3186
  Optionally returns only entries of a given type.
3105
3187
 
3188
+ #### Type parameters
3189
+
3190
+ | Name | Type |
3191
+ | :------ | :------ |
3192
+ | `T` | extends [`DynamicOfflineData`](interfaces/DynamicOfflineData.md) |
3193
+
3106
3194
  #### Parameters
3107
3195
 
3108
3196
  | Name | Type | Description |
@@ -3111,7 +3199,7 @@ Optionally returns only entries of a given type.
3111
3199
 
3112
3200
  #### Returns
3113
3201
 
3114
- `Promise`<[`DynamicOfflineData`](interfaces/DynamicOfflineData.md)[]\>
3202
+ `Promise`<`T`[]\>
3115
3203
 
3116
3204
  #### Defined in
3117
3205
 
@@ -3121,11 +3209,17 @@ ___
3121
3209
 
3122
3210
  ### getDynamicOfflineDataEntriesFor
3123
3211
 
3124
- ▸ **getDynamicOfflineDataEntriesFor**(`userId`, `type?`): `Promise`<[`DynamicOfflineData`](interfaces/DynamicOfflineData.md)[]\>
3212
+ ▸ **getDynamicOfflineDataEntriesFor**<`T`\>(`userId`, `type?`): `Promise`<`T`[]\>
3125
3213
 
3126
3214
  Returns all [DynamicOfflineData](interfaces/DynamicOfflineData.md) entries which registered for the given user.
3127
3215
  Optionally returns only entries of a given type.
3128
3216
 
3217
+ #### Type parameters
3218
+
3219
+ | Name | Type |
3220
+ | :------ | :------ |
3221
+ | `T` | extends [`DynamicOfflineData`](interfaces/DynamicOfflineData.md) |
3222
+
3129
3223
  #### Parameters
3130
3224
 
3131
3225
  | Name | Type | Description |
@@ -3135,7 +3229,7 @@ Optionally returns only entries of a given type.
3135
3229
 
3136
3230
  #### Returns
3137
3231
 
3138
- `Promise`<[`DynamicOfflineData`](interfaces/DynamicOfflineData.md)[]\>
3232
+ `Promise`<`T`[]\>
3139
3233
 
3140
3234
  #### Defined in
3141
3235
 
@@ -3354,7 +3448,7 @@ should be made available offline for the currently logged in user.
3354
3448
 
3355
3449
  #### Defined in
3356
3450
 
3357
- [packages/framework/esm-offline/src/dynamic-offline-data.ts:162](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L162)
3451
+ [packages/framework/esm-offline/src/dynamic-offline-data.ts:161](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L161)
3358
3452
 
3359
3453
  ___
3360
3454
 
@@ -3379,7 +3473,7 @@ should be made available offline for the user with the given ID.
3379
3473
 
3380
3474
  #### Defined in
3381
3475
 
3382
- [packages/framework/esm-offline/src/dynamic-offline-data.ts:177](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L177)
3476
+ [packages/framework/esm-offline/src/dynamic-offline-data.ts:176](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L176)
3383
3477
 
3384
3478
  ___
3385
3479
 
@@ -3456,7 +3550,7 @@ no longer needs to be available offline for the currently logged in user.
3456
3550
 
3457
3551
  #### Defined in
3458
3552
 
3459
- [packages/framework/esm-offline/src/dynamic-offline-data.ts:213](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L213)
3553
+ [packages/framework/esm-offline/src/dynamic-offline-data.ts:212](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L212)
3460
3554
 
3461
3555
  ___
3462
3556
 
@@ -3481,7 +3575,7 @@ no longer needs to be available offline for the user with the given ID.
3481
3575
 
3482
3576
  #### Defined in
3483
3577
 
3484
- [packages/framework/esm-offline/src/dynamic-offline-data.ts:228](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L228)
3578
+ [packages/framework/esm-offline/src/dynamic-offline-data.ts:227](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L227)
3485
3579
 
3486
3580
  ___
3487
3581
 
@@ -3636,7 +3730,7 @@ Synchronizes all offline data entries of the given [type](interfaces/FetchRespon
3636
3730
 
3637
3731
  #### Defined in
3638
3732
 
3639
- [packages/framework/esm-offline/src/dynamic-offline-data.ts:262](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L262)
3733
+ [packages/framework/esm-offline/src/dynamic-offline-data.ts:261](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L261)
3640
3734
 
3641
3735
  ___
3642
3736
 
@@ -3660,7 +3754,7 @@ Synchronizes a single offline data entry of the given [type](interfaces/FetchRes
3660
3754
 
3661
3755
  #### Defined in
3662
3756
 
3663
- [packages/framework/esm-offline/src/dynamic-offline-data.ts:280](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L280)
3757
+ [packages/framework/esm-offline/src/dynamic-offline-data.ts:279](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-offline/src/dynamic-offline-data.ts#L279)
3664
3758
 
3665
3759
  ___
3666
3760
 
@@ -4382,7 +4476,7 @@ ___
4382
4476
 
4383
4477
  ▸ **age**(`dateString`): `string`
4384
4478
 
4385
- Gets a human readable age represention of the provided date string.
4479
+ Gets a human readable and locale supported age represention of the provided date string.
4386
4480
 
4387
4481
  #### Parameters
4388
4482
 
@@ -4398,7 +4492,7 @@ A human-readable string version of the age.
4398
4492
 
4399
4493
  #### Defined in
4400
4494
 
4401
- [packages/framework/esm-utils/src/age-helpers.tsx:39](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/age-helpers.tsx#L39)
4495
+ [packages/framework/esm-utils/src/age-helpers.tsx:41](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/age-helpers.tsx#L41)
4402
4496
 
4403
4497
  ___
4404
4498
 
@@ -4422,7 +4516,7 @@ The number of days.
4422
4516
 
4423
4517
  #### Defined in
4424
4518
 
4425
- [packages/framework/esm-utils/src/age-helpers.tsx:8](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/age-helpers.tsx#L8)
4519
+ [packages/framework/esm-utils/src/age-helpers.tsx:10](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/age-helpers.tsx#L10)
4426
4520
 
4427
4521
  ___
4428
4522
 
@@ -4447,7 +4541,7 @@ True if both are located on the same day.
4447
4541
 
4448
4542
  #### Defined in
4449
4543
 
4450
- [packages/framework/esm-utils/src/age-helpers.tsx:25](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/age-helpers.tsx#L25)
4544
+ [packages/framework/esm-utils/src/age-helpers.tsx:27](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/age-helpers.tsx#L27)
4451
4545
 
4452
4546
  ___
4453
4547
 
package/mock.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import type {} from "@openmrs/esm-globals";
3
3
  import { createStore, StoreApi } from "zustand";
4
- import { never, of } from "rxjs";
4
+ import { NEVER, of } from "rxjs";
5
5
  import { interpolateUrl } from "@openmrs/esm-config";
6
6
  import { SessionStore } from "@openmrs/esm-api";
7
7
  export {
@@ -193,7 +193,7 @@ export const ConfigurableLink = jest
193
193
  export const importDynamic = jest.fn();
194
194
 
195
195
  /* esm-error-handling */
196
- export const createErrorHandler = () => jest.fn().mockReturnValue(never());
196
+ export const createErrorHandler = () => jest.fn().mockReturnValue(NEVER);
197
197
 
198
198
  export const reportError = jest.fn().mockImplementation((error) => {
199
199
  throw error;
@@ -294,6 +294,8 @@ export const useVisit = jest.fn().mockReturnValue({
294
294
 
295
295
  export const useVisitTypes = jest.fn(() => []);
296
296
 
297
+ export const useDebounce = jest.fn().mockImplementation((value) => value);
298
+
297
299
  /* esm-styleguide */
298
300
 
299
301
  export const showNotification = jest.fn();
@@ -305,4 +307,4 @@ export const LeftNavMenu = jest.fn();
305
307
  export const setLeftNav = jest.fn();
306
308
  export const unsetLeftNav = jest.fn();
307
309
 
308
- export { OpenmrsDatePicker } from "@openmrs/esm-styleguide";
310
+ export const OpenmrsDatePicker = jest.fn();
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@openmrs/esm-framework",
3
- "version": "5.1.1-pre.999",
3
+ "version": "5.2.0",
4
4
  "license": "MPL-2.0",
5
5
  "browser": "dist/openmrs-esm-framework.js",
6
6
  "main": "src/index.ts",
7
7
  "source": true,
8
8
  "scripts": {
9
9
  "document": "../../../document.sh esm-framework",
10
- "test": "jest --config jest.config.js --passWithNoTests",
10
+ "test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color",
11
+ "test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
11
12
  "build": "webpack --mode=production",
12
13
  "build:development": "webpack --mode development",
13
14
  "analyze": "webpack --mode=production --env analyze=true",
@@ -36,19 +37,19 @@
36
37
  "access": "public"
37
38
  },
38
39
  "dependencies": {
39
- "@openmrs/esm-api": "^5.1.1-pre.999",
40
- "@openmrs/esm-breadcrumbs": "^5.1.1-pre.999",
41
- "@openmrs/esm-config": "^5.1.1-pre.999",
42
- "@openmrs/esm-dynamic-loading": "^5.1.1-pre.999",
43
- "@openmrs/esm-error-handling": "^5.1.1-pre.999",
44
- "@openmrs/esm-extensions": "^5.1.1-pre.999",
45
- "@openmrs/esm-feature-flags": "^5.1.1-pre.999",
46
- "@openmrs/esm-globals": "^5.1.1-pre.999",
47
- "@openmrs/esm-offline": "^5.1.1-pre.999",
48
- "@openmrs/esm-react-utils": "^5.1.1-pre.999",
49
- "@openmrs/esm-state": "^5.1.1-pre.999",
50
- "@openmrs/esm-styleguide": "^5.1.1-pre.999",
51
- "@openmrs/esm-utils": "^5.1.1-pre.999",
40
+ "@openmrs/esm-api": "^5.2.0",
41
+ "@openmrs/esm-breadcrumbs": "^5.2.0",
42
+ "@openmrs/esm-config": "^5.2.0",
43
+ "@openmrs/esm-dynamic-loading": "^5.2.0",
44
+ "@openmrs/esm-error-handling": "^5.2.0",
45
+ "@openmrs/esm-extensions": "^5.2.0",
46
+ "@openmrs/esm-feature-flags": "^5.2.0",
47
+ "@openmrs/esm-globals": "^5.2.0",
48
+ "@openmrs/esm-offline": "^5.2.0",
49
+ "@openmrs/esm-react-utils": "^5.2.0",
50
+ "@openmrs/esm-state": "^5.2.0",
51
+ "@openmrs/esm-styleguide": "^5.2.0",
52
+ "@openmrs/esm-utils": "^5.2.0",
52
53
  "dayjs": "^1.10.7"
53
54
  },
54
55
  "peerDependencies": {
@@ -58,7 +59,8 @@
58
59
  "react-dom": "18.x",
59
60
  "react-i18next": "11.x",
60
61
  "rxjs": "6.x",
61
- "single-spa": "5.x"
62
+ "single-spa": "5.x",
63
+ "swr": "2.x"
62
64
  },
63
65
  "devDependencies": {
64
66
  "jest": "28.1.0",
@@ -66,5 +68,5 @@
66
68
  "jest-environment-jsdom": "28.1.0",
67
69
  "webpack": "^5.88.0"
68
70
  },
69
- "gitHead": "a216f155e09508cf5bdc3d244fb7a154d1e74325"
71
+ "gitHead": "f46cd16443cae13069a55067ca317ac995eef570"
70
72
  }
package/webpack.config.js CHANGED
@@ -26,7 +26,14 @@ module.exports = (env) => ({
26
26
  use: "swc-loader",
27
27
  },
28
28
  {
29
- test: /\.s?css$/,
29
+ test: /\.css$/,
30
+ use: [
31
+ { loader: require.resolve("style-loader") },
32
+ { loader: require.resolve("css-loader") },
33
+ ],
34
+ },
35
+ {
36
+ test: /\.scss$/,
30
37
  use: [
31
38
  { loader: require.resolve("style-loader") },
32
39
  { loader: require.resolve("css-loader") },