@uxland/primary-shell 5.7.0 → 6.0.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/dist/index.js +2499 -2489
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +40 -40
- package/dist/index.umd.cjs.map +1 -1
- package/dist/primary/shell/src/api/interaction-service/interaction-service-impl.d.ts +2 -3
- package/dist/primary/shell/src/api/interaction-service/interaction-service.d.ts +5 -1
- package/package.json +1 -1
- package/src/api/interaction-service/interaction-service-impl.tsx +18 -12
- package/src/api/interaction-service/interaction-service.ts +7 -3
- package/src/features/exit/handler.test.ts +2 -2
- package/src/features/exit/handler.ts +2 -2
- package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/handler.ts +1 -1
- package/src/internal-plugins/activity-history/activity-history-item/filter/UI/activity-history-filters/template.ts +15 -10
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfirmationOptions, ConfirmationResult, ConfirmComponentUI, PrimariaInteractionService } from './interaction-service';
|
|
2
2
|
|
|
3
|
-
import * as React from "react";
|
|
4
3
|
export declare class ParimariaInteractionServiceImpl extends PrimariaInteractionService {
|
|
5
|
-
confirm<TData = undefined, TResult = undefined>(data: TData | undefined,
|
|
4
|
+
confirm<TData = undefined, TResult = undefined>(data: TData | undefined, componentUI: ConfirmComponentUI<TData, TResult>, options?: ConfirmationOptions | undefined): Promise<ConfirmationResult<TResult | undefined>>;
|
|
6
5
|
confirmMessage(message: string, options?: ConfirmationOptions | undefined): Promise<ConfirmationResult>;
|
|
7
6
|
}
|
|
@@ -26,7 +26,11 @@ export interface ConfirmationOptions {
|
|
|
26
26
|
closeOnOutsideClick?: boolean | undefined;
|
|
27
27
|
state?: "success" | "info" | "alert" | "error";
|
|
28
28
|
}
|
|
29
|
+
export interface ConfirmComponentUI<TData = undefined, TResult = undefined> {
|
|
30
|
+
component: React.ComponentType<ConfirmationContentProps<TData, TResult> | ConfirmationWithResultContentProps<TData, TResult>> | (new () => HTMLElement);
|
|
31
|
+
styles?: string;
|
|
32
|
+
}
|
|
29
33
|
export declare abstract class PrimariaInteractionService {
|
|
30
|
-
abstract confirm<TData = undefined, TResult = undefined>(data: TData | undefined,
|
|
34
|
+
abstract confirm<TData = undefined, TResult = undefined>(data: TData | undefined, componentUI: ConfirmComponentUI<TData, TResult>, options?: ConfirmationOptions | undefined): Promise<ConfirmationResult<TResult | undefined>>;
|
|
31
35
|
abstract confirmMessage(message: string, options?: ConfirmationOptions | undefined): Promise<ConfirmationResult>;
|
|
32
36
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ConfirmationContentProps,
|
|
3
2
|
ConfirmationOptions,
|
|
4
3
|
ConfirmationResult,
|
|
5
|
-
|
|
4
|
+
ConfirmComponentUI,
|
|
6
5
|
PrimariaInteractionService,
|
|
7
6
|
} from "./interaction-service";
|
|
8
7
|
import * as React from "react";
|
|
@@ -25,19 +24,24 @@ const defaultOptions: ConfirmationOptions = {
|
|
|
25
24
|
export class ParimariaInteractionServiceImpl extends PrimariaInteractionService {
|
|
26
25
|
confirm<TData = undefined, TResult = undefined>(
|
|
27
26
|
data: TData | undefined,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| (new () => HTMLElement),
|
|
31
|
-
options?: ConfirmationOptions | undefined,
|
|
27
|
+
componentUI: ConfirmComponentUI<TData, TResult>,
|
|
28
|
+
options?: ConfirmationOptions | undefined
|
|
32
29
|
): Promise<ConfirmationResult<TResult | undefined>> {
|
|
33
30
|
const finalOptions: ConfirmationOptions = { ...defaultOptions, ...(options || {}) };
|
|
34
31
|
return new Promise((resolve) => {
|
|
35
32
|
const div = document.createElement("div");
|
|
36
33
|
document.body.appendChild(div);
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const wrapperHeadStyles = document.createElement("style");
|
|
35
|
+
wrapperHeadStyles.textContent = modalStyles;
|
|
36
|
+
document.head.appendChild(wrapperHeadStyles);
|
|
37
|
+
const DialogComponent = componentUI.component;
|
|
38
|
+
const DialogComponentStyles = componentUI.styles;
|
|
39
|
+
let componentHeadStyles;
|
|
40
|
+
if(DialogComponentStyles) {
|
|
41
|
+
componentHeadStyles = document.createElement("style");
|
|
42
|
+
componentHeadStyles.textContent = componentUI?.styles;
|
|
43
|
+
document.head.appendChild(componentHeadStyles);
|
|
44
|
+
}
|
|
41
45
|
|
|
42
46
|
const DialogWrapper = () => {
|
|
43
47
|
const [result, setResult] = useState<ConfirmationResult<TResult | undefined>>();
|
|
@@ -106,7 +110,9 @@ export class ParimariaInteractionServiceImpl extends PrimariaInteractionService
|
|
|
106
110
|
};
|
|
107
111
|
resolve(confirmationResult);
|
|
108
112
|
document.body.removeChild(div);
|
|
109
|
-
document.head.removeChild(
|
|
113
|
+
document.head.removeChild(wrapperHeadStyles);
|
|
114
|
+
if (DialogComponentStyles)
|
|
115
|
+
document.head.removeChild(componentHeadStyles);
|
|
110
116
|
window.removeEventListener('keydown', handleKeydown);
|
|
111
117
|
}, 300);
|
|
112
118
|
};
|
|
@@ -198,6 +204,6 @@ export class ParimariaInteractionServiceImpl extends PrimariaInteractionService
|
|
|
198
204
|
message: string,
|
|
199
205
|
options?: ConfirmationOptions | undefined,
|
|
200
206
|
): Promise<ConfirmationResult> {
|
|
201
|
-
return this.confirm(message, ConfirmationMessage, options);
|
|
207
|
+
return this.confirm(message, {component: ConfirmationMessage}, options);
|
|
202
208
|
}
|
|
203
209
|
}
|
|
@@ -31,12 +31,16 @@ export interface ConfirmationOptions {
|
|
|
31
31
|
state?: "success" | "info" | "alert" | "error";
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
export interface ConfirmComponentUI<TData = undefined, TResult = undefined> {
|
|
35
|
+
component: | React.ComponentType<ConfirmationContentProps<TData, TResult> | ConfirmationWithResultContentProps<TData, TResult>>
|
|
36
|
+
| (new () => HTMLElement);
|
|
37
|
+
styles?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
export abstract class PrimariaInteractionService {
|
|
35
41
|
abstract confirm<TData = undefined, TResult = undefined>(
|
|
36
42
|
data: TData | undefined,
|
|
37
|
-
|
|
38
|
-
| React.ComponentType<ConfirmationContentProps<TData, TResult> | ConfirmationWithResultContentProps<TData, TResult>>
|
|
39
|
-
| (new () => HTMLElement),
|
|
43
|
+
componentUI: ConfirmComponentUI<TData, TResult>,
|
|
40
44
|
options?: ConfirmationOptions | undefined,
|
|
41
45
|
): Promise<ConfirmationResult<TResult | undefined>>;
|
|
42
46
|
abstract confirmMessage(
|
|
@@ -74,8 +74,8 @@ describe("ExitShellHandler", () => {
|
|
|
74
74
|
|
|
75
75
|
await handler.handle(message);
|
|
76
76
|
|
|
77
|
-
expect(mockApi.interactionService.confirm).toHaveBeenCalledWith({ busyTasks }, PluginBusyList, {
|
|
78
|
-
title:
|
|
77
|
+
expect(mockApi.interactionService.confirm).toHaveBeenCalledWith({ busyTasks }, {component: PluginBusyList}, {
|
|
78
|
+
title: "actions.askExit",
|
|
79
79
|
state: "error",
|
|
80
80
|
confirmButtonText: "Sí",
|
|
81
81
|
cancelButtonText: "No",
|
|
@@ -23,7 +23,7 @@ export class ExitShellHandler {
|
|
|
23
23
|
// Per si un plugin tarda molt en fer dispose, màxim deixarem 5 segons, per no interrompre el tancar infinitament
|
|
24
24
|
await Promise.race([
|
|
25
25
|
disposePlugins(), // S'intenta executar un dispose normal
|
|
26
|
-
this.timeout(
|
|
26
|
+
this.timeout(10000), // Si passen 5s, es segueix amb l'execució
|
|
27
27
|
]);
|
|
28
28
|
disposeShell();
|
|
29
29
|
this.emitClose(evt);
|
|
@@ -34,7 +34,7 @@ export class ExitShellHandler {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
private askForClose(busyTasks: PluginBusyTask[]) {
|
|
37
|
-
return this.api.interactionService.confirm({ busyTasks }, PluginBusyList, {
|
|
37
|
+
return this.api.interactionService.confirm({ busyTasks }, {component: PluginBusyList}, {
|
|
38
38
|
title: translate("actions.askExit"),
|
|
39
39
|
state: "error",
|
|
40
40
|
confirmButtonText: "Sí",
|
package/src/internal-plugins/activity-history/activity-history-item/export-to-pdf/handler.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ExportPdfModal } from "./export-pdf-modal/export-pdf-modal";
|
|
|
5
5
|
export class ExportToPdfHandler extends ApiBaseHandler {
|
|
6
6
|
async handle() {
|
|
7
7
|
try {
|
|
8
|
-
this.api.interactionService.confirm(undefined, ExportPdfModal, {
|
|
8
|
+
this.api.interactionService.confirm(undefined, {component: ExportPdfModal}, {
|
|
9
9
|
title: translate("modal.selectExportOption"),
|
|
10
10
|
confirmButtonText: "Exportar",
|
|
11
11
|
cancelButtonText: "Cancelar",
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
IActivityHistoryFilter,
|
|
10
10
|
} from "../../model";
|
|
11
11
|
import { translate } from "../../../../localization";
|
|
12
|
+
import { when } from "lit/directives/when.js";
|
|
12
13
|
|
|
13
14
|
const filterTemplates = {
|
|
14
15
|
[ActivityHistoryFilterType.Switch]: (id, title, handleChange, isSelected, isEnabled) => html`
|
|
@@ -108,8 +109,10 @@ const customFilterTemplate = (
|
|
|
108
109
|
group: IActivityHistoryCustomFilterGroup,
|
|
109
110
|
) => {
|
|
110
111
|
if (filter.type === ActivityHistoryFilterType.Dropdown) {
|
|
111
|
-
const elements = filter?.options.map(option => ({ value: option.id, label: option.title || option.id }));
|
|
112
|
-
return
|
|
112
|
+
const elements = filter?.options.map((option) => ({ value: option.id, label: option.title || option.id }));
|
|
113
|
+
return when(
|
|
114
|
+
elements.length > 0,
|
|
115
|
+
() => html`
|
|
113
116
|
<dss-input-dropdown
|
|
114
117
|
inputsize="md"
|
|
115
118
|
icon=""
|
|
@@ -117,28 +120,30 @@ const customFilterTemplate = (
|
|
|
117
120
|
dropdownFixed
|
|
118
121
|
type="default"
|
|
119
122
|
.elements=${elements}
|
|
120
|
-
@onInputDropdownChange=${(e) =>
|
|
121
|
-
props._onChangeCustomFilterAllValues(group.id, filter.id, e.detail.selectedValue)
|
|
122
|
-
}
|
|
123
|
+
@onInputDropdownChange=${(e) => props._onChangeCustomFilterAllValues(group.id, filter.id, e.detail.selectedValue)}
|
|
123
124
|
.selectedValue=${filter.enabledValues}
|
|
124
125
|
selectorStyle="max-height: 450px"
|
|
125
126
|
>
|
|
126
127
|
<label slot="label">${filter.title}</label>
|
|
127
128
|
<input slot="input" type="text" class="dss-input" autocomplete="off" />
|
|
128
129
|
</dss-input-dropdown>
|
|
129
|
-
|
|
130
|
+
`,
|
|
131
|
+
);
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
return filter.singleOption
|
|
133
135
|
? getFilterTemplate(filter, props._onChangeCustomFilterValue.bind(props), group)
|
|
134
|
-
:
|
|
136
|
+
: when(
|
|
137
|
+
!!filter.options?.length,
|
|
138
|
+
() => html`
|
|
135
139
|
<primaria-accordion isOpen>
|
|
136
140
|
<div class="custom-filter-title" slot="title">${filter.title}</div>
|
|
137
141
|
<div class="custom-filter-content" slot="content">
|
|
138
|
-
${filter.options.map(option =>
|
|
139
|
-
getFilterTemplate(filter, props._onChangeCustomFilterValue.bind(props), group, option)
|
|
142
|
+
${filter.options.map((option) =>
|
|
143
|
+
getFilterTemplate(filter, props._onChangeCustomFilterValue.bind(props), group, option),
|
|
140
144
|
)}
|
|
141
145
|
</div>
|
|
142
146
|
</primaria-accordion>
|
|
143
|
-
|
|
147
|
+
`,
|
|
148
|
+
);
|
|
144
149
|
};
|