@uxland/primary-shell 2.0.0 → 2.0.1-rc.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/README.md +1 -231
- package/dist/index.js +11193 -10854
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +560 -548
- package/dist/index.umd.cjs.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/region-manager.d.ts +2 -1
- package/package.json +11 -13
- package/src/UI/components/primaria-shell/template.ts +1 -59
- package/src/initializer.ts +0 -2
- package/dist/UI/styles/theme/apply-theme.d.ts +0 -1
- package/dist/style.css +0 -3
- package/src/UI/styles/theme/apply-theme.ts +0 -11
package/README.md
CHANGED
|
@@ -1,231 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Primaria Shell is the `main container` of the Primaria application. Within it, we can find the different regions where plugins can inject their views.
|
|
3
|
-
|
|
4
|
-
Each plugin is provided with an "API" of type `PrimariaApi`. The plugin must use this object to interact with the shell (register views, open modals, send events, share data, query data, etc.).
|
|
5
|
-
|
|
6
|
-
```
|
|
7
|
-
export interface PrimariaApi extends HarmonixApi {
|
|
8
|
-
httpClient: PrimariaHttpClient;
|
|
9
|
-
interactionManager: PrimariaInteractionManager;
|
|
10
|
-
broker: PrimariaBroker;
|
|
11
|
-
regionManager: PrimariaRegionManager;
|
|
12
|
-
globalStateManager: PrimariaGlobalStateManager;
|
|
13
|
-
pluginInfo: PluginInfo;
|
|
14
|
-
createLocaleManager(messages: LocalizationMessages): Promise<HarmonixLocaleApi>;
|
|
15
|
-
}
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## 🔹 pluginInfo
|
|
19
|
-
|
|
20
|
-
This property is an object containing information about the plugin (identifier).
|
|
21
|
-
```
|
|
22
|
-
export interface PluginInfo {
|
|
23
|
-
pluginId: string;
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
## 🔹 httpClient
|
|
27
|
-
|
|
28
|
-
TODO
|
|
29
|
-
## 🔹 interactionManager
|
|
30
|
-
|
|
31
|
-
This object is used to open modals and notification toasts.
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
export interface PrimariaInteractionManager {
|
|
35
|
-
notify(options: NotifyOptions): Promise<any>;
|
|
36
|
-
doConfirm(options: ConfirmOptions): Promise<boolean>;
|
|
37
|
-
doCustomConfirm(options: CustomConfirmOptions): Promise<boolean>;
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### ▪notify
|
|
42
|
-
|
|
43
|
-
Function to display a notification toast. You need to pass options as an argument.
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
export interface NotifyOptions {
|
|
47
|
-
message?: string;
|
|
48
|
-
type?: NotifyType;
|
|
49
|
-
position?: NotifyPosition;
|
|
50
|
-
order?: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type NotifyOrder = "first" | "second" | "third" | "fourth" | "fifth";
|
|
54
|
-
export type NotifyPosition = "bottom" | "center" | "top";
|
|
55
|
-
export type NotifyType = "danger" | "warning" | "info" | "success";
|
|
56
|
-
```
|
|
57
|
-
Example:
|
|
58
|
-
```
|
|
59
|
-
api.interactionManager.notify({
|
|
60
|
-
message: "Esta es un Toast de notificación!!",
|
|
61
|
-
type: "danger",
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### ▪doConfirm
|
|
66
|
-
|
|
67
|
-
Function to display a basic confirmation modal. You need to pass options as an argument.
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
export interface ConfirmOptions {
|
|
71
|
-
title: string;
|
|
72
|
-
message: string;
|
|
73
|
-
type: ConfirmType;
|
|
74
|
-
acceptLabel: string;
|
|
75
|
-
cancelLabel: string;
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
Example:
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
api.interactionManager
|
|
82
|
-
.doConfirm({
|
|
83
|
-
title: "Confirmation title",
|
|
84
|
-
type: "info",
|
|
85
|
-
message: "Això és missatge de confirmacio",
|
|
86
|
-
acceptLabel: "Acceptar",
|
|
87
|
-
cancelLabel: "Cancelar",
|
|
88
|
-
})
|
|
89
|
-
.then((r) => console.log(r));
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### ▪doCustomConfirm
|
|
93
|
-
|
|
94
|
-
Function to display a customized confirmation modal. You need to pass options as an argument, including a component constructor to be rendered inside the modal.
|
|
95
|
-
|
|
96
|
-
```
|
|
97
|
-
export interface CustomConfirmOptions<T = any> {
|
|
98
|
-
title: string;
|
|
99
|
-
componentConstructor: Constructor<LitElement | any>;
|
|
100
|
-
type: ConfirmType;
|
|
101
|
-
acceptLabel?: string;
|
|
102
|
-
cancelLabel?: string;
|
|
103
|
-
model?: T;
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Example:
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
api.interactionManager
|
|
111
|
-
.doCustomConfirm({
|
|
112
|
-
title: "Confirmation title",
|
|
113
|
-
type: "danger",
|
|
114
|
-
componentConstructor: TitleView,
|
|
115
|
-
acceptLabel: "Acceptar",
|
|
116
|
-
cancelLabel: "Cancelar",
|
|
117
|
-
properties: { title: "HOLAAA" },
|
|
118
|
-
})
|
|
119
|
-
.then((r) => console.log(r));
|
|
120
|
-
```
|
|
121
|
-
## 🔹 regionManager
|
|
122
|
-
|
|
123
|
-
This object is used to manage views within regions (injection, activation, deactivation, etc.).
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
export interface PrimariaRegionManager extends HarmonixRegionManager {
|
|
127
|
-
registerMenu(view: HarmonixViewDefinition): Promise<void>;
|
|
128
|
-
registerQuickAction(view: HarmonixViewDefinition): Promise<void>;
|
|
129
|
-
registerMainView(view: HarmonixViewDefinition, title: string): Promise<void>;
|
|
130
|
-
activateMainView(viewId: string): Promise<void>;
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
The Primaria API defines these functions to help easily register views in the main shell regions, although you can also use the original Harmonix framework API with all its facilities.
|
|
135
|
-
|
|
136
|
-
```
|
|
137
|
-
export interface HarmonixRegionManager {
|
|
138
|
-
registerView(regionName: string, view: HarmonixViewDefinition): Promise<void>;
|
|
139
|
-
removeView(regionName: string, viewId: string): Promise<void>;
|
|
140
|
-
activateView(regionName: string, viewId: string): Promise<void>;
|
|
141
|
-
deactivateView(regionName: string, viewId: string): Promise<void>;
|
|
142
|
-
getRegion(regionName: string): Promise<IRegion>;
|
|
143
|
-
isViewActive(regionName: string, viewId: string): Promise<boolean>;
|
|
144
|
-
containsView(regionName: string, viewId: string): Promise<boolean>;
|
|
145
|
-
}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Example:
|
|
149
|
-
|
|
150
|
-
```
|
|
151
|
-
api.regionManager.registerMainView(
|
|
152
|
-
{
|
|
153
|
-
id: "my-plugin",
|
|
154
|
-
factory: () => new MainComponent(),
|
|
155
|
-
},
|
|
156
|
-
"My Plugin title",
|
|
157
|
-
);
|
|
158
|
-
```
|
|
159
|
-
## 🔹 createLocaleManager
|
|
160
|
-
|
|
161
|
-
This function receives a collection of translations and returns an object capable of translating and obtaining the current language.
|
|
162
|
-
|
|
163
|
-
```
|
|
164
|
-
export interface HarmonixLocaleApi {
|
|
165
|
-
getCurrentLanguage(): string;
|
|
166
|
-
translate<T = Record<string, string>>(path: string, variables?: T): string;
|
|
167
|
-
getTranslations(): LocalizationMessages;
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
Example:
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
const pluginLocaleManager = api.createLocaleManager(locales);
|
|
175
|
-
console.log(pluginLocaleManager.getTranslations());
|
|
176
|
-
console.log(pluginLocaleManager.translate("title"));
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## 🔹 globalStateManager
|
|
180
|
-
|
|
181
|
-
This object provides the capability to set or get global data. It is used to share data between plugins or to obtain important data that the core of the application may provide.
|
|
182
|
-
|
|
183
|
-
```
|
|
184
|
-
export abstract class PrimariaGlobalStateManager {
|
|
185
|
-
abstract setData(key: string, value: any): void;
|
|
186
|
-
abstract getData(key: string): any;
|
|
187
|
-
abstract clearData(): void;
|
|
188
|
-
}
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Example:
|
|
192
|
-
|
|
193
|
-
```
|
|
194
|
-
api.globalStateManager.setData("key1", "value1");
|
|
195
|
-
const result = globalStateManager.getData("key1");
|
|
196
|
-
console.log("key1"); // "value1"
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## 🔹 broker
|
|
200
|
-
|
|
201
|
-
This object provides a way to handle messaging through an internal broker or bus. Plugins can use this bus to communicate with other plugins, but also to manage internal plugin messaging, delegating all responsibility to the broker by registering handlers for each use case, adhering to architectural patterns and clean code practices.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
```
|
|
205
|
-
export interface PrimariaBroker {
|
|
206
|
-
send<TRequest extends IRequest<TResponse>, TResponse>(message: TRequest): Promise<TResponse>;
|
|
207
|
-
send<TPayload, TResponse>(requestName: string, payload: TPayload): Promise<TResponse>;
|
|
208
|
-
publish<TEvent extends IEvent>(event: TEvent): Promise<void>;
|
|
209
|
-
publish<TPayload>(eventName: string, payload: TPayload): Promise<void>;
|
|
210
|
-
subscribe<TEvent extends IEvent>(event: IEventClass, handler: EventHandler<TEvent>): void;
|
|
211
|
-
subscribe<TPayload>(eventName: string, handler: EventHandler<TPayload>): void;
|
|
212
|
-
registerRequest<TRequest extends IRequest<TResponse>, TResponse>(request: IRequestClass<TRequest>, handler: RequestHandler<TRequest, TResponse>): void;
|
|
213
|
-
registerRequest<TPayload, TResponse>(requestName: string, handler: RequestHandler<TPayload, TResponse>): void;
|
|
214
|
-
}
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
All methods can be used by message name (request) or by class. It is recommended that plugins register messages and use the broker with a prefix to avoid collisions between plugins, such as registering the same message.
|
|
218
|
-
|
|
219
|
-
Example:
|
|
220
|
-
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
class Greet implements IRequest<string> {
|
|
224
|
-
constructor(public message: string) {}
|
|
225
|
-
}
|
|
226
|
-
api.broker.registerRequest(command: Greet, (cmd: IRequest<any>) => {
|
|
227
|
-
alert(command.message)
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
api.broker.send(new Greet("Jaaaa")); //This will alert "Jaaaa"
|
|
231
|
-
```
|
|
1
|
+
Full Harmonix and Primaria Shell Documentation here: https://doc.clickup.com/9012015559/d/h/8cjgwe7-2192/bc9e680ac3c7b52
|