@openmrs/esm-framework 3.1.15-pre.707 → 3.1.15-pre.718
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/dist/openmrs-esm-framework.js +1 -1
- package/dist/openmrs-esm-framework.js.map +1 -1
- package/docs/API.md +23 -34
- package/docs/interfaces/ComponentDefinition.md +1 -1
- package/docs/interfaces/ConnectedExtension.md +144 -0
- package/docs/interfaces/{ExtensionComponentDefinition.md → ExtensionDefinition.md} +67 -19
- package/docs/interfaces/ExtensionDetails.md +6 -6
- package/docs/interfaces/ExtensionRegistration.md +2 -0
- package/docs/interfaces/ExtensionSlotBaseProps.md +6 -6
- package/docs/interfaces/PageDefinition.md +2 -2
- package/package.json +13 -13
- package/src/integration-tests/extension-config.test.tsx +49 -0
- package/docs/interfaces/LegacyAppExtensionDefinition.md +0 -170
- package/docs/interfaces/ModernAppExtensionDefinition.md +0 -196
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
attach,
|
|
4
4
|
registerExtension,
|
|
5
5
|
registerExtensionSlot,
|
|
6
|
+
updateExtensionStore,
|
|
7
|
+
ExtensionStore,
|
|
6
8
|
} from "../../../esm-extensions";
|
|
7
9
|
import {
|
|
8
10
|
Extension,
|
|
@@ -15,6 +17,10 @@ import { defineConfigSchema, provide, Type } from "../../../esm-config/src";
|
|
|
15
17
|
import { render, screen, waitFor } from "@testing-library/react";
|
|
16
18
|
|
|
17
19
|
describe("Interaction between configuration and extension systems", () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
updateExtensionStore(() => ({ slots: {}, extensions: {} }));
|
|
22
|
+
});
|
|
23
|
+
|
|
18
24
|
test("Config should add, order, and remove extensions within slots", async () => {
|
|
19
25
|
registerSimpleExtension("Fred", "esm-flintstone");
|
|
20
26
|
registerSimpleExtension("Wilma", "esm-flintstone");
|
|
@@ -96,6 +102,49 @@ describe("Interaction between configuration and extension systems", () => {
|
|
|
96
102
|
const futureWilma = screen.getByTestId("future-slot");
|
|
97
103
|
expect(futureWilma).toHaveTextContent(/Wilma:.*New New York/);
|
|
98
104
|
});
|
|
105
|
+
|
|
106
|
+
test("Should be possible to attach the same extension twice with different configurations", async () => {
|
|
107
|
+
registerSimpleExtension("pet", "esm-characters", true);
|
|
108
|
+
registerExtensionSlot("esm-flintstone", "Flintstone slot");
|
|
109
|
+
defineConfigSchema("esm-characters", {
|
|
110
|
+
name: { _type: Type.String, _default: "(no-name)" },
|
|
111
|
+
});
|
|
112
|
+
attach("Flintstone slot", "pet#Dino");
|
|
113
|
+
attach("Flintstone slot", "pet#BabyPuss");
|
|
114
|
+
provide({
|
|
115
|
+
"esm-flintstone": {
|
|
116
|
+
extensions: {
|
|
117
|
+
"Flintstone slot": {
|
|
118
|
+
configure: {
|
|
119
|
+
"pet#Dino": {
|
|
120
|
+
name: "Dino",
|
|
121
|
+
},
|
|
122
|
+
"pet#BabyPuss": {
|
|
123
|
+
name: "Baby Puss",
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
const App = openmrsComponentDecorator({
|
|
131
|
+
moduleName: "esm-flintstone",
|
|
132
|
+
featureName: "The Flintstones",
|
|
133
|
+
disableTranslations: true,
|
|
134
|
+
})(() => (
|
|
135
|
+
<>
|
|
136
|
+
<ExtensionSlot
|
|
137
|
+
data-testid="flintstone-slot"
|
|
138
|
+
extensionSlotName="Flintstone slot"
|
|
139
|
+
/>
|
|
140
|
+
</>
|
|
141
|
+
));
|
|
142
|
+
render(<App />);
|
|
143
|
+
await screen.findAllByText(/.*Dino.*/);
|
|
144
|
+
const slot = screen.getByTestId("flintstone-slot");
|
|
145
|
+
expect(slot.firstChild).toHaveTextContent(/Dino/);
|
|
146
|
+
expect(slot.lastChild).toHaveTextContent(/Baby Puss/);
|
|
147
|
+
});
|
|
99
148
|
});
|
|
100
149
|
|
|
101
150
|
function registerSimpleExtension(
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
[@openmrs/esm-framework](../API.md) / LegacyAppExtensionDefinition
|
|
2
|
-
|
|
3
|
-
# Interface: LegacyAppExtensionDefinition
|
|
4
|
-
|
|
5
|
-
## Hierarchy
|
|
6
|
-
|
|
7
|
-
- [`ExtensionComponentDefinition`](ExtensionComponentDefinition.md)
|
|
8
|
-
|
|
9
|
-
↳ **`LegacyAppExtensionDefinition`**
|
|
10
|
-
|
|
11
|
-
## Table of contents
|
|
12
|
-
|
|
13
|
-
### Properties
|
|
14
|
-
|
|
15
|
-
- [appName](LegacyAppExtensionDefinition.md#appname)
|
|
16
|
-
- [meta](LegacyAppExtensionDefinition.md#meta)
|
|
17
|
-
- [name](LegacyAppExtensionDefinition.md#name)
|
|
18
|
-
- [offline](LegacyAppExtensionDefinition.md#offline)
|
|
19
|
-
- [online](LegacyAppExtensionDefinition.md#online)
|
|
20
|
-
- [order](LegacyAppExtensionDefinition.md#order)
|
|
21
|
-
- [privilege](LegacyAppExtensionDefinition.md#privilege)
|
|
22
|
-
- [resources](LegacyAppExtensionDefinition.md#resources)
|
|
23
|
-
|
|
24
|
-
### Methods
|
|
25
|
-
|
|
26
|
-
- [load](LegacyAppExtensionDefinition.md#load)
|
|
27
|
-
|
|
28
|
-
## Properties
|
|
29
|
-
|
|
30
|
-
### appName
|
|
31
|
-
|
|
32
|
-
• **appName**: `string`
|
|
33
|
-
|
|
34
|
-
The module/app that defines the component
|
|
35
|
-
|
|
36
|
-
#### Inherited from
|
|
37
|
-
|
|
38
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[appName](ExtensionComponentDefinition.md#appname)
|
|
39
|
-
|
|
40
|
-
#### Defined in
|
|
41
|
-
|
|
42
|
-
[packages/framework/esm-globals/src/types.ts:92](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L92)
|
|
43
|
-
|
|
44
|
-
___
|
|
45
|
-
|
|
46
|
-
### meta
|
|
47
|
-
|
|
48
|
-
• `Optional` **meta**: `Record`<`string`, `any`\>
|
|
49
|
-
|
|
50
|
-
The meta data used for reflection by other components.
|
|
51
|
-
|
|
52
|
-
#### Inherited from
|
|
53
|
-
|
|
54
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[meta](ExtensionComponentDefinition.md#meta)
|
|
55
|
-
|
|
56
|
-
#### Defined in
|
|
57
|
-
|
|
58
|
-
[packages/framework/esm-globals/src/types.ts:119](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L119)
|
|
59
|
-
|
|
60
|
-
___
|
|
61
|
-
|
|
62
|
-
### name
|
|
63
|
-
|
|
64
|
-
• **name**: `string`
|
|
65
|
-
|
|
66
|
-
The ID of the extension to register.
|
|
67
|
-
|
|
68
|
-
#### Defined in
|
|
69
|
-
|
|
70
|
-
[packages/framework/esm-globals/src/types.ts:147](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L147)
|
|
71
|
-
|
|
72
|
-
___
|
|
73
|
-
|
|
74
|
-
### offline
|
|
75
|
-
|
|
76
|
-
• `Optional` **offline**: `boolean` \| `object`
|
|
77
|
-
|
|
78
|
-
Defines the offline support / properties of the component.
|
|
79
|
-
|
|
80
|
-
#### Inherited from
|
|
81
|
-
|
|
82
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[offline](ExtensionComponentDefinition.md#offline)
|
|
83
|
-
|
|
84
|
-
#### Defined in
|
|
85
|
-
|
|
86
|
-
[packages/framework/esm-globals/src/types.ts:104](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L104)
|
|
87
|
-
|
|
88
|
-
___
|
|
89
|
-
|
|
90
|
-
### online
|
|
91
|
-
|
|
92
|
-
• `Optional` **online**: `boolean` \| `object`
|
|
93
|
-
|
|
94
|
-
Defines the online support / properties of the component.
|
|
95
|
-
|
|
96
|
-
#### Inherited from
|
|
97
|
-
|
|
98
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[online](ExtensionComponentDefinition.md#online)
|
|
99
|
-
|
|
100
|
-
#### Defined in
|
|
101
|
-
|
|
102
|
-
[packages/framework/esm-globals/src/types.ts:100](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L100)
|
|
103
|
-
|
|
104
|
-
___
|
|
105
|
-
|
|
106
|
-
### order
|
|
107
|
-
|
|
108
|
-
• `Optional` **order**: `number`
|
|
109
|
-
|
|
110
|
-
Specifies a preferred order number, if any.
|
|
111
|
-
|
|
112
|
-
#### Inherited from
|
|
113
|
-
|
|
114
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[order](ExtensionComponentDefinition.md#order)
|
|
115
|
-
|
|
116
|
-
#### Defined in
|
|
117
|
-
|
|
118
|
-
[packages/framework/esm-globals/src/types.ts:123](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L123)
|
|
119
|
-
|
|
120
|
-
___
|
|
121
|
-
|
|
122
|
-
### privilege
|
|
123
|
-
|
|
124
|
-
• `Optional` **privilege**: `string`
|
|
125
|
-
|
|
126
|
-
Defines the access privilege required for this component, if any.
|
|
127
|
-
|
|
128
|
-
#### Inherited from
|
|
129
|
-
|
|
130
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[privilege](ExtensionComponentDefinition.md#privilege)
|
|
131
|
-
|
|
132
|
-
#### Defined in
|
|
133
|
-
|
|
134
|
-
[packages/framework/esm-globals/src/types.ts:108](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L108)
|
|
135
|
-
|
|
136
|
-
___
|
|
137
|
-
|
|
138
|
-
### resources
|
|
139
|
-
|
|
140
|
-
• `Optional` **resources**: `Record`<`string`, [`ResourceLoader`](ResourceLoader.md)<`any`\>\>
|
|
141
|
-
|
|
142
|
-
Defines resources that are loaded when the component should mount.
|
|
143
|
-
|
|
144
|
-
#### Inherited from
|
|
145
|
-
|
|
146
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[resources](ExtensionComponentDefinition.md#resources)
|
|
147
|
-
|
|
148
|
-
#### Defined in
|
|
149
|
-
|
|
150
|
-
[packages/framework/esm-globals/src/types.ts:112](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L112)
|
|
151
|
-
|
|
152
|
-
## Methods
|
|
153
|
-
|
|
154
|
-
### load
|
|
155
|
-
|
|
156
|
-
▸ **load**(): `Promise`<`any`\>
|
|
157
|
-
|
|
158
|
-
Defines a function to use for actually loading the component's lifecycle.
|
|
159
|
-
|
|
160
|
-
#### Returns
|
|
161
|
-
|
|
162
|
-
`Promise`<`any`\>
|
|
163
|
-
|
|
164
|
-
#### Inherited from
|
|
165
|
-
|
|
166
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[load](ExtensionComponentDefinition.md#load)
|
|
167
|
-
|
|
168
|
-
#### Defined in
|
|
169
|
-
|
|
170
|
-
[packages/framework/esm-globals/src/types.ts:96](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L96)
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
[@openmrs/esm-framework](../API.md) / ModernAppExtensionDefinition
|
|
2
|
-
|
|
3
|
-
# Interface: ModernAppExtensionDefinition
|
|
4
|
-
|
|
5
|
-
## Hierarchy
|
|
6
|
-
|
|
7
|
-
- [`ExtensionComponentDefinition`](ExtensionComponentDefinition.md)
|
|
8
|
-
|
|
9
|
-
↳ **`ModernAppExtensionDefinition`**
|
|
10
|
-
|
|
11
|
-
## Table of contents
|
|
12
|
-
|
|
13
|
-
### Properties
|
|
14
|
-
|
|
15
|
-
- [appName](ModernAppExtensionDefinition.md#appname)
|
|
16
|
-
- [id](ModernAppExtensionDefinition.md#id)
|
|
17
|
-
- [meta](ModernAppExtensionDefinition.md#meta)
|
|
18
|
-
- [offline](ModernAppExtensionDefinition.md#offline)
|
|
19
|
-
- [online](ModernAppExtensionDefinition.md#online)
|
|
20
|
-
- [order](ModernAppExtensionDefinition.md#order)
|
|
21
|
-
- [privilege](ModernAppExtensionDefinition.md#privilege)
|
|
22
|
-
- [resources](ModernAppExtensionDefinition.md#resources)
|
|
23
|
-
- [slot](ModernAppExtensionDefinition.md#slot)
|
|
24
|
-
- [slots](ModernAppExtensionDefinition.md#slots)
|
|
25
|
-
|
|
26
|
-
### Methods
|
|
27
|
-
|
|
28
|
-
- [load](ModernAppExtensionDefinition.md#load)
|
|
29
|
-
|
|
30
|
-
## Properties
|
|
31
|
-
|
|
32
|
-
### appName
|
|
33
|
-
|
|
34
|
-
• **appName**: `string`
|
|
35
|
-
|
|
36
|
-
The module/app that defines the component
|
|
37
|
-
|
|
38
|
-
#### Inherited from
|
|
39
|
-
|
|
40
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[appName](ExtensionComponentDefinition.md#appname)
|
|
41
|
-
|
|
42
|
-
#### Defined in
|
|
43
|
-
|
|
44
|
-
[packages/framework/esm-globals/src/types.ts:92](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L92)
|
|
45
|
-
|
|
46
|
-
___
|
|
47
|
-
|
|
48
|
-
### id
|
|
49
|
-
|
|
50
|
-
• **id**: `string`
|
|
51
|
-
|
|
52
|
-
The ID of the extension to register.
|
|
53
|
-
|
|
54
|
-
#### Defined in
|
|
55
|
-
|
|
56
|
-
[packages/framework/esm-globals/src/types.ts:131](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L131)
|
|
57
|
-
|
|
58
|
-
___
|
|
59
|
-
|
|
60
|
-
### meta
|
|
61
|
-
|
|
62
|
-
• `Optional` **meta**: `Record`<`string`, `any`\>
|
|
63
|
-
|
|
64
|
-
The meta data used for reflection by other components.
|
|
65
|
-
|
|
66
|
-
#### Inherited from
|
|
67
|
-
|
|
68
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[meta](ExtensionComponentDefinition.md#meta)
|
|
69
|
-
|
|
70
|
-
#### Defined in
|
|
71
|
-
|
|
72
|
-
[packages/framework/esm-globals/src/types.ts:119](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L119)
|
|
73
|
-
|
|
74
|
-
___
|
|
75
|
-
|
|
76
|
-
### offline
|
|
77
|
-
|
|
78
|
-
• `Optional` **offline**: `boolean` \| `object`
|
|
79
|
-
|
|
80
|
-
Defines the offline support / properties of the component.
|
|
81
|
-
|
|
82
|
-
#### Inherited from
|
|
83
|
-
|
|
84
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[offline](ExtensionComponentDefinition.md#offline)
|
|
85
|
-
|
|
86
|
-
#### Defined in
|
|
87
|
-
|
|
88
|
-
[packages/framework/esm-globals/src/types.ts:104](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L104)
|
|
89
|
-
|
|
90
|
-
___
|
|
91
|
-
|
|
92
|
-
### online
|
|
93
|
-
|
|
94
|
-
• `Optional` **online**: `boolean` \| `object`
|
|
95
|
-
|
|
96
|
-
Defines the online support / properties of the component.
|
|
97
|
-
|
|
98
|
-
#### Inherited from
|
|
99
|
-
|
|
100
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[online](ExtensionComponentDefinition.md#online)
|
|
101
|
-
|
|
102
|
-
#### Defined in
|
|
103
|
-
|
|
104
|
-
[packages/framework/esm-globals/src/types.ts:100](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L100)
|
|
105
|
-
|
|
106
|
-
___
|
|
107
|
-
|
|
108
|
-
### order
|
|
109
|
-
|
|
110
|
-
• `Optional` **order**: `number`
|
|
111
|
-
|
|
112
|
-
Specifies a preferred order number, if any.
|
|
113
|
-
|
|
114
|
-
#### Inherited from
|
|
115
|
-
|
|
116
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[order](ExtensionComponentDefinition.md#order)
|
|
117
|
-
|
|
118
|
-
#### Defined in
|
|
119
|
-
|
|
120
|
-
[packages/framework/esm-globals/src/types.ts:123](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L123)
|
|
121
|
-
|
|
122
|
-
___
|
|
123
|
-
|
|
124
|
-
### privilege
|
|
125
|
-
|
|
126
|
-
• `Optional` **privilege**: `string`
|
|
127
|
-
|
|
128
|
-
Defines the access privilege required for this component, if any.
|
|
129
|
-
|
|
130
|
-
#### Inherited from
|
|
131
|
-
|
|
132
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[privilege](ExtensionComponentDefinition.md#privilege)
|
|
133
|
-
|
|
134
|
-
#### Defined in
|
|
135
|
-
|
|
136
|
-
[packages/framework/esm-globals/src/types.ts:108](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L108)
|
|
137
|
-
|
|
138
|
-
___
|
|
139
|
-
|
|
140
|
-
### resources
|
|
141
|
-
|
|
142
|
-
• `Optional` **resources**: `Record`<`string`, [`ResourceLoader`](ResourceLoader.md)<`any`\>\>
|
|
143
|
-
|
|
144
|
-
Defines resources that are loaded when the component should mount.
|
|
145
|
-
|
|
146
|
-
#### Inherited from
|
|
147
|
-
|
|
148
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[resources](ExtensionComponentDefinition.md#resources)
|
|
149
|
-
|
|
150
|
-
#### Defined in
|
|
151
|
-
|
|
152
|
-
[packages/framework/esm-globals/src/types.ts:112](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L112)
|
|
153
|
-
|
|
154
|
-
___
|
|
155
|
-
|
|
156
|
-
### slot
|
|
157
|
-
|
|
158
|
-
• `Optional` **slot**: `string`
|
|
159
|
-
|
|
160
|
-
The slot of the extension to optionally attach to.
|
|
161
|
-
|
|
162
|
-
#### Defined in
|
|
163
|
-
|
|
164
|
-
[packages/framework/esm-globals/src/types.ts:135](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L135)
|
|
165
|
-
|
|
166
|
-
___
|
|
167
|
-
|
|
168
|
-
### slots
|
|
169
|
-
|
|
170
|
-
• `Optional` **slots**: `string`[]
|
|
171
|
-
|
|
172
|
-
The slots of the extension to optionally attach to.
|
|
173
|
-
|
|
174
|
-
#### Defined in
|
|
175
|
-
|
|
176
|
-
[packages/framework/esm-globals/src/types.ts:139](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L139)
|
|
177
|
-
|
|
178
|
-
## Methods
|
|
179
|
-
|
|
180
|
-
### load
|
|
181
|
-
|
|
182
|
-
▸ **load**(): `Promise`<`any`\>
|
|
183
|
-
|
|
184
|
-
Defines a function to use for actually loading the component's lifecycle.
|
|
185
|
-
|
|
186
|
-
#### Returns
|
|
187
|
-
|
|
188
|
-
`Promise`<`any`\>
|
|
189
|
-
|
|
190
|
-
#### Inherited from
|
|
191
|
-
|
|
192
|
-
[ExtensionComponentDefinition](ExtensionComponentDefinition.md).[load](ExtensionComponentDefinition.md#load)
|
|
193
|
-
|
|
194
|
-
#### Defined in
|
|
195
|
-
|
|
196
|
-
[packages/framework/esm-globals/src/types.ts:96](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-globals/src/types.ts#L96)
|