@openmrs/esm-framework 9.0.3-pre.4558 → 9.0.3-pre.4633

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 (89.69ms)
1
+ [0] Successfully compiled: 3 files with swc (135.42ms)
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
@@ -2,35 +2,101 @@
2
2
 
3
3
  # Function: useAppContext()
4
4
 
5
+ ## Call Signature
6
+
5
7
  > **useAppContext**\<`T`\>(`namespace`): `undefined` \| `Readonly`\<`T`\>
6
8
 
7
- Defined in: [packages/framework/esm-react-utils/src/useAppContext.ts:26](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-react-utils/src/useAppContext.ts#L26)
9
+ Defined in: [packages/framework/esm-react-utils/src/useAppContext.ts:30](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-react-utils/src/useAppContext.ts#L30)
8
10
 
9
11
  This hook is used to access a namespace within the overall AppContext, so that a component can
10
12
  use any shared contextual values. A selector may be provided to further restrict the properties
11
13
  returned from the namespace.
12
14
 
13
- ## Type Parameters
15
+ ### Type Parameters
14
16
 
15
- ### T
17
+ #### T
16
18
 
17
19
  `T` *extends* `object` = `object`
18
20
 
19
21
  The type of the value stored in the namespace
20
22
 
21
- ## Parameters
23
+ ### Parameters
22
24
 
23
- ### namespace
25
+ #### namespace
24
26
 
25
27
  `string`
26
28
 
27
29
  The namespace to load properties from
28
30
 
29
- ## Returns
31
+ ### Returns
30
32
 
31
33
  `undefined` \| `Readonly`\<`T`\>
32
34
 
33
- ## Examples
35
+ The current value registered under `namespace`, or `undefined` when the namespace has not
36
+ yet been registered, was unregistered (e.g. the owning component unmounted), or is a blank string.
37
+ Consumers should handle the `undefined` case explicitly rather than defaulting to `{}`, since an
38
+ empty-object default can mask a genuinely missing namespace and hide bugs.
39
+
40
+ ### Examples
41
+
42
+ ```ts
43
+ // load a full namespace
44
+ const patientContext = useAppContext<PatientContext>('patient');
45
+ ```
46
+
47
+ ```ts
48
+ // loads part of a namespace
49
+ const patientName = useAppContext<PatientContext, string | undefined>('patient', (state) => state.display);
50
+ ```
51
+
52
+ ## Call Signature
53
+
54
+ > **useAppContext**\<`T`, `U`\>(`namespace`, `selector`): `undefined` \| `Readonly`\<`U`\>
55
+
56
+ Defined in: [packages/framework/esm-react-utils/src/useAppContext.ts:60](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-react-utils/src/useAppContext.ts#L60)
57
+
58
+ This hook is used to access a namespace within the overall AppContext, so that a component can
59
+ use any shared contextual values. A selector may be provided to further restrict the properties
60
+ returned from the namespace.
61
+
62
+ ### Type Parameters
63
+
64
+ #### T
65
+
66
+ `T` *extends* `object` = `object`
67
+
68
+ The type of the value stored in the namespace
69
+
70
+ #### U
71
+
72
+ `U` = `T`
73
+
74
+ The return type of this hook which is mostly relevant when using a selector
75
+
76
+ ### Parameters
77
+
78
+ #### namespace
79
+
80
+ `string`
81
+
82
+ The namespace to load properties from
83
+
84
+ #### selector
85
+
86
+ (`state`) => `Readonly`\<`U`\>
87
+
88
+ An optional function which extracts the relevant part of the state
89
+
90
+ ### Returns
91
+
92
+ `undefined` \| `Readonly`\<`U`\>
93
+
94
+ The selected value, or `undefined` when the namespace has not yet been registered, was
95
+ unregistered (e.g. the owning component unmounted), or is a blank string. Consumers should handle
96
+ the `undefined` case explicitly rather than defaulting to `{}`, since an empty-object default can
97
+ mask a genuinely missing namespace and hide bugs.
98
+
99
+ ### Examples
34
100
 
35
101
  ```ts
36
102
  // load a full namespace
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-framework",
3
- "version": "9.0.3-pre.4558",
3
+ "version": "9.0.3-pre.4633",
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": "9.0.3-pre.4558",
63
- "@openmrs/esm-config": "9.0.3-pre.4558",
64
- "@openmrs/esm-context": "9.0.3-pre.4558",
65
- "@openmrs/esm-dynamic-loading": "9.0.3-pre.4558",
66
- "@openmrs/esm-emr-api": "9.0.3-pre.4558",
67
- "@openmrs/esm-error-handling": "9.0.3-pre.4558",
68
- "@openmrs/esm-expression-evaluator": "9.0.3-pre.4558",
69
- "@openmrs/esm-extensions": "9.0.3-pre.4558",
70
- "@openmrs/esm-feature-flags": "9.0.3-pre.4558",
71
- "@openmrs/esm-globals": "9.0.3-pre.4558",
72
- "@openmrs/esm-navigation": "9.0.3-pre.4558",
73
- "@openmrs/esm-offline": "9.0.3-pre.4558",
74
- "@openmrs/esm-react-utils": "9.0.3-pre.4558",
75
- "@openmrs/esm-routes": "9.0.3-pre.4558",
76
- "@openmrs/esm-state": "9.0.3-pre.4558",
77
- "@openmrs/esm-styleguide": "9.0.3-pre.4558",
78
- "@openmrs/esm-translations": "9.0.3-pre.4558",
79
- "@openmrs/esm-utils": "9.0.3-pre.4558"
62
+ "@openmrs/esm-api": "9.0.3-pre.4633",
63
+ "@openmrs/esm-config": "9.0.3-pre.4633",
64
+ "@openmrs/esm-context": "9.0.3-pre.4633",
65
+ "@openmrs/esm-dynamic-loading": "9.0.3-pre.4633",
66
+ "@openmrs/esm-emr-api": "9.0.3-pre.4633",
67
+ "@openmrs/esm-error-handling": "9.0.3-pre.4633",
68
+ "@openmrs/esm-expression-evaluator": "9.0.3-pre.4633",
69
+ "@openmrs/esm-extensions": "9.0.3-pre.4633",
70
+ "@openmrs/esm-feature-flags": "9.0.3-pre.4633",
71
+ "@openmrs/esm-globals": "9.0.3-pre.4633",
72
+ "@openmrs/esm-navigation": "9.0.3-pre.4633",
73
+ "@openmrs/esm-offline": "9.0.3-pre.4633",
74
+ "@openmrs/esm-react-utils": "9.0.3-pre.4633",
75
+ "@openmrs/esm-routes": "9.0.3-pre.4633",
76
+ "@openmrs/esm-state": "9.0.3-pre.4633",
77
+ "@openmrs/esm-styleguide": "9.0.3-pre.4633",
78
+ "@openmrs/esm-translations": "9.0.3-pre.4633",
79
+ "@openmrs/esm-utils": "9.0.3-pre.4633"
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": "9.0.3-pre.4558",
92
+ "@openmrs/typedoc-plugin-file-categories": "9.0.3-pre.4633",
93
93
  "@swc/cli": "0.8.1",
94
94
  "@swc/core": "1.15.21",
95
95
  "@vitest/coverage-v8": "^4.1.2",