@uxland/primary-shell 3.4.1 → 3.5.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 +11579 -13387
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +795 -1064
- package/dist/index.umd.cjs.map +1 -1
- package/dist/primary/shell/src/UI/components/primaria-error-view/component.d.ts +9 -0
- package/dist/primary/shell/src/UI/components/primaria-error-view/template.d.ts +3 -0
- package/dist/primary/shell/src/UI/components/primaria-shell/constants.d.ts +4 -0
- package/dist/primary/shell/src/UI/components/primaria-shell/primaria-shell.d.ts +10 -0
- package/dist/primary/shell/src/UI/{shared-components/primaria-menu/primaria-menu.d.ts → components/quick-actions-menu/quick-actions-menu.d.ts} +1 -1
- package/dist/primary/shell/src/UI/components/quick-actions-menu/template.d.ts +3 -0
- package/dist/primary/shell/src/UI/shared-components/primaria-nav-item/template.d.ts +3 -0
- package/dist/primary/shell/src/UI/shared-components/primaria-nav-tree-menu/primaria-nav-tree-menu.d.ts +13 -0
- package/dist/primary/shell/src/UI/shared-components/primaria-nav-tree-menu/template.d.ts +3 -0
- package/dist/primary/shell/src/UI/shared-components/typings.d.ts +16 -0
- package/dist/primary/shell/src/api/broker/primaria-broker.d.ts +1 -0
- package/dist/primary/shell/src/api/region-manager/region-manager.d.ts +3 -2
- package/dist/primary/shell/src/bootstrapper.d.ts +2 -0
- package/dist/primary/shell/src/constants.d.ts +1 -0
- package/dist/primary/shell/src/disposer.d.ts +2 -0
- package/dist/primary/shell/src/events.d.ts +2 -0
- package/dist/primary/shell/src/features/bootstrapper.d.ts +1 -1
- package/dist/primary/shell/src/features/utils.d.ts +3 -2
- package/dist/primary/shell/src/{plugin.d.ts → handle-plugins.d.ts} +2 -1
- package/dist/primary/shell/src/handle-views.d.ts +2 -0
- package/dist/primary/shell/src/index.d.ts +5 -3
- package/dist/primary/shell/src/{UI/shared-components/dss-container/dss-container.d.ts → internal-plugins/activity-history/components/activity-history/activity-history-search-header/activity-history-search-header.d.ts} +2 -2
- package/dist/primary/shell/src/internal-plugins/activity-history/components/activity-history/activity-history-search-header/template.d.ts +3 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/components/activity-history/activity-history-timeline/activity-history-timeline.d.ts +6 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/components/activity-history/activity-history.d.ts +4 -3
- package/dist/primary/shell/src/internal-plugins/activity-history/constants.d.ts +3 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/domain/is-valid-history-item/is-valid-history-item.d.ts +1 -0
- package/dist/primary/shell/src/internal-plugins/activity-history/features/search-items/handler.d.ts +3 -1
- package/dist/primary/shell/src/internal-plugins/activity-history/localization.d.ts +2 -0
- package/dist/primary/shell/src/locales.d.ts +14 -3
- package/dist/style.css +1 -1
- package/package.json +2 -3
- package/src/UI/components/index.ts +1 -0
- package/src/UI/components/primaria-error-view/component.ts +18 -0
- package/src/UI/components/primaria-error-view/styles.css +27 -0
- package/src/UI/components/primaria-error-view/template.ts +12 -0
- package/src/UI/components/primaria-shell/constants.ts +4 -0
- package/src/UI/components/primaria-shell/primaria-shell.ts +38 -1
- package/src/UI/components/primaria-shell/styles.css +24 -54
- package/src/UI/components/primaria-shell/template.ts +43 -50
- package/src/UI/{shared-components/primaria-menu/primaria-menu.ts → components/quick-actions-menu/quick-actions-menu.ts} +3 -3
- package/src/UI/components/quick-actions-menu/template.ts +10 -0
- package/src/UI/images/not-found.svg +9 -0
- package/src/UI/shared-components/index.ts +1 -3
- package/src/UI/shared-components/primaria-nav-item/primaria-nav-item.ts +54 -0
- package/src/UI/shared-components/{primaria-menu-item → primaria-nav-item}/styles.css +4 -0
- package/src/UI/shared-components/primaria-nav-item/template.ts +27 -0
- package/src/UI/shared-components/primaria-nav-tree-menu/primaria-nav-tree-menu.ts +41 -0
- package/src/UI/shared-components/primaria-nav-tree-menu/styles.css +11 -0
- package/src/UI/shared-components/primaria-nav-tree-menu/template.ts +30 -0
- package/src/UI/shared-components/typings.ts +17 -0
- package/src/api/api.ts +1 -1
- package/src/api/broker/factory.ts +29 -12
- package/src/api/broker/primaria-broker.ts +2 -0
- package/src/api/ecap-event-manager/ecap-event-manager.ts +1 -1
- package/src/api/region-manager/region-manager.ts +12 -2
- package/src/api/token-manager/token-manager.test.ts +1 -1
- package/src/bootstrapper.ts +16 -0
- package/src/constants.ts +1 -0
- package/src/disposer.ts +10 -0
- package/src/events.ts +2 -0
- package/src/features/bootstrapper.ts +4 -1
- package/src/features/get-user-info/bootstrapper.ts +6 -3
- package/src/features/utils.ts +7 -5
- package/src/{plugin.ts → handle-plugins.ts} +8 -3
- package/src/handle-views.ts +284 -0
- package/src/index.ts +5 -3
- package/src/internal-plugins/activity-history/components/activity-history/activity-history-search-header/activity-history-search-header.ts +20 -0
- package/src/internal-plugins/activity-history/components/activity-history/activity-history-search-header/styles.css +14 -0
- package/src/internal-plugins/activity-history/components/activity-history/activity-history-search-header/template.ts +8 -0
- package/src/internal-plugins/activity-history/components/activity-history/activity-history-timeline/activity-history-timeline.ts +27 -1
- package/src/internal-plugins/activity-history/components/activity-history/activity-history-timeline/styles.css +21 -2
- package/src/internal-plugins/activity-history/components/activity-history/activity-history-timeline/template.ts +38 -19
- package/src/internal-plugins/activity-history/components/activity-history/activity-history.ts +17 -26
- package/src/internal-plugins/activity-history/components/activity-history/styles.css +2 -24
- package/src/internal-plugins/activity-history/components/activity-history/template.ts +37 -69
- package/src/internal-plugins/activity-history/constants.ts +3 -0
- package/src/internal-plugins/activity-history/domain/filter-by-search-string/filter-by-search-string.ts +6 -1
- package/src/internal-plugins/activity-history/domain/is-valid-history-item/is-valid-history-item.ts +19 -5
- package/src/internal-plugins/activity-history/features/add-history-item/bootstrapper.ts +5 -2
- package/src/internal-plugins/activity-history/features/add-history-items/bootstrapper.ts +5 -2
- package/src/internal-plugins/activity-history/features/export-to-pdf/bootstrapper.ts +5 -2
- package/src/internal-plugins/activity-history/features/inject-async-history-items/bootstrapper.ts +5 -2
- package/src/internal-plugins/activity-history/features/inject-async-history-items/handler.ts +3 -3
- package/src/internal-plugins/activity-history/features/search-items/bootstrapper.ts +5 -2
- package/src/internal-plugins/activity-history/features/search-items/handler.ts +9 -1
- package/src/internal-plugins/activity-history/features/update-history-item/bootstrapper.ts +5 -2
- package/src/internal-plugins/activity-history/localization.ts +2 -0
- package/src/locales.ts +25 -5
- package/dist/primary/shell/src/UI/shared-components/primaria-menu/template.d.ts +0 -3
- package/dist/primary/shell/src/UI/shared-components/primaria-menu-item/primaria-menu-item.d.ts +0 -15
- package/dist/primary/shell/src/UI/shared-components/primaria-menu-item/template.d.ts +0 -3
- package/dist/primary/shell/src/UI/shared-components/primaria-nav-menu/primaria-nav-menu.d.ts +0 -26
- package/dist/primary/shell/src/UI/shared-components/primaria-nav-menu/template.d.ts +0 -3
- package/dist/primary/shell/src/UI/shared-components/primaria-wrapper-menu/primaria-wrapper-menu.d.ts +0 -19
- package/dist/primary/shell/src/UI/shared-components/primaria-wrapper-menu/template.d.ts +0 -3
- package/dist/primary/shell/src/initializer.d.ts +0 -1
- package/src/UI/shared-components/dss-container/dss-container.ts +0 -32
- package/src/UI/shared-components/dss-container/styles.css +0 -23
- package/src/UI/shared-components/primaria-menu/template.ts +0 -9
- package/src/UI/shared-components/primaria-menu-item/primaria-menu-item.ts +0 -51
- package/src/UI/shared-components/primaria-menu-item/template.ts +0 -11
- package/src/UI/shared-components/primaria-nav-menu/primaria-nav-menu.ts +0 -66
- package/src/UI/shared-components/primaria-nav-menu/styles.css +0 -26
- package/src/UI/shared-components/primaria-nav-menu/template.ts +0 -30
- package/src/UI/shared-components/primaria-wrapper-menu/primaria-wrapper-menu.ts +0 -41
- package/src/UI/shared-components/primaria-wrapper-menu/styles.css +0 -5
- package/src/UI/shared-components/primaria-wrapper-menu/template.ts +0 -28
- package/src/initializer.ts +0 -327
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { BrokerExtensions } from "@primaria/plugins-core";
|
|
2
2
|
import { UpdateHistoryItemHandler } from "./handler";
|
|
3
3
|
import { updateHistoryItemRequest } from "./request";
|
|
4
|
+
import { BrokerDisposableHandler } from "../../../../api/broker/primaria-broker";
|
|
5
|
+
|
|
6
|
+
let request: BrokerDisposableHandler;
|
|
4
7
|
|
|
5
8
|
export const bootstrapUpdateHistoryItem = (broker: BrokerExtensions) => {
|
|
6
|
-
broker.registerRequest(updateHistoryItemRequest, UpdateHistoryItemHandler);
|
|
9
|
+
request = broker.registerRequest(updateHistoryItemRequest, UpdateHistoryItemHandler);
|
|
7
10
|
};
|
|
8
11
|
|
|
9
12
|
export const teardownUpdateHistoryItem = (broker: BrokerExtensions) => {
|
|
10
|
-
|
|
13
|
+
request?.dispose();
|
|
11
14
|
};
|
|
@@ -38,6 +38,8 @@ export const locales = {
|
|
|
38
38
|
deleted: "Eliminat",
|
|
39
39
|
goToDate: "Anar a data",
|
|
40
40
|
busyEntriesLoading: "Carregant totes les entrades",
|
|
41
|
+
noResults: "Sense resultats. Modifica la cerca",
|
|
42
|
+
searchBarResults: "Resultats per",
|
|
41
43
|
actions: {
|
|
42
44
|
cronogram: "Cronograma",
|
|
43
45
|
exportPdf: "Exportar PDF",
|
package/src/locales.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setLanguage } from "@uxland/localization";
|
|
2
2
|
import { PrimariaApi } from "./api/api";
|
|
3
|
-
import {
|
|
3
|
+
import { primariaShellId } from "./constants";
|
|
4
4
|
|
|
5
5
|
let shellLocaleManager;
|
|
6
6
|
|
|
@@ -10,15 +10,35 @@ export const initializeLocalization = async (api: PrimariaApi) => {
|
|
|
10
10
|
shellLocaleManager = localeManager;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
type LocaleKeys<T> = T extends object
|
|
14
|
+
? {
|
|
15
|
+
[K in keyof T]:
|
|
16
|
+
| `${K & string}`
|
|
17
|
+
| (T[K] extends object ? `${K & string}.${LocaleKeys<T[K]>}` : never);
|
|
18
|
+
}[keyof T]
|
|
19
|
+
: never;
|
|
20
|
+
|
|
21
|
+
export type ShellLocales = LocaleKeys<(typeof locales)[typeof defaultLang][typeof primariaShellId]>;
|
|
22
|
+
|
|
23
|
+
export const translate = (path: ShellLocales) => {
|
|
24
|
+
if (shellLocaleManager) return shellLocaleManager.translate(path);
|
|
25
|
+
return path;
|
|
26
|
+
};
|
|
27
|
+
|
|
13
28
|
export { shellLocaleManager };
|
|
14
29
|
|
|
15
30
|
export const locales = {
|
|
16
31
|
ca: {
|
|
17
32
|
[primariaShellId]: {
|
|
18
33
|
title: "Estació de Treball Clínica",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
actions:{
|
|
35
|
+
create: "Crear",
|
|
36
|
+
toggleMenuClose: "Tancar menú",
|
|
37
|
+
toggleMenuOpen: "Expandir menú",
|
|
38
|
+
},
|
|
39
|
+
clinicalMonitoring:{
|
|
40
|
+
title: "Seguiment clínic",
|
|
41
|
+
},
|
|
42
|
+
}
|
|
23
43
|
},
|
|
24
44
|
};
|
package/dist/primary/shell/src/UI/shared-components/primaria-menu-item/primaria-menu-item.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
|
|
3
|
-
export declare class PrimariaMenuItem extends LitElement {
|
|
4
|
-
constructor(icon: string, label: string, showArrow: boolean, callbackFn: () => void);
|
|
5
|
-
render(): import('lit').TemplateResult<1>;
|
|
6
|
-
static styles: import('lit').CSSResult;
|
|
7
|
-
firstUpdated(p: any): void;
|
|
8
|
-
observeHostResize(): void;
|
|
9
|
-
containerWidth: number;
|
|
10
|
-
showText: boolean;
|
|
11
|
-
icon: string;
|
|
12
|
-
label: string;
|
|
13
|
-
showArrow: boolean;
|
|
14
|
-
callbackFn: () => void;
|
|
15
|
-
}
|
package/dist/primary/shell/src/UI/shared-components/primaria-nav-menu/primaria-nav-menu.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
|
|
3
|
-
export declare class PrimariaNavMenu extends LitElement {
|
|
4
|
-
constructor(icon: string, label: string, subItems: {
|
|
5
|
-
icon?: string;
|
|
6
|
-
label: string;
|
|
7
|
-
callbackFn: () => void;
|
|
8
|
-
}[]);
|
|
9
|
-
firstUpdated(p: any): void;
|
|
10
|
-
observeHostResize(): void;
|
|
11
|
-
icon: string;
|
|
12
|
-
label: string;
|
|
13
|
-
subItems: {
|
|
14
|
-
icon?: string;
|
|
15
|
-
label: string;
|
|
16
|
-
callbackFn: () => void;
|
|
17
|
-
}[];
|
|
18
|
-
showText: boolean;
|
|
19
|
-
isExpanded: boolean;
|
|
20
|
-
parentWidth: any;
|
|
21
|
-
private resizeObserver?;
|
|
22
|
-
render(): import('lit').TemplateResult<1>;
|
|
23
|
-
static styles: import('lit').CSSResult;
|
|
24
|
-
toggleMenu(): void;
|
|
25
|
-
disconnectedCallback(): void;
|
|
26
|
-
}
|
package/dist/primary/shell/src/UI/shared-components/primaria-wrapper-menu/primaria-wrapper-menu.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
|
|
3
|
-
interface MenuItem {
|
|
4
|
-
icon: string;
|
|
5
|
-
label: string;
|
|
6
|
-
callbackFn: () => void;
|
|
7
|
-
}
|
|
8
|
-
export declare class PrimariaWrapperMenu extends LitElement {
|
|
9
|
-
static styles: import('lit').CSSResult;
|
|
10
|
-
icon: string;
|
|
11
|
-
label: string;
|
|
12
|
-
showArrow: boolean;
|
|
13
|
-
actionMenuItems: MenuItem[];
|
|
14
|
-
showActionMenu: boolean;
|
|
15
|
-
constructor(icon: string, label: string, showArrow: boolean, actionMenuItems: MenuItem[]);
|
|
16
|
-
handleItemClick: () => void;
|
|
17
|
-
render(): import('lit').TemplateResult<1>;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const initializeShell: (element: HTMLElement) => Promise<void>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { css, html, LitElement, render, unsafeCSS } from "lit";
|
|
2
|
-
import { customElement } from "lit/decorators.js";
|
|
3
|
-
import styles from "./styles.css?inline";
|
|
4
|
-
|
|
5
|
-
@customElement("dss-container")
|
|
6
|
-
export class DssContainer extends LitElement {
|
|
7
|
-
render() {
|
|
8
|
-
return html`
|
|
9
|
-
<slot></slot>
|
|
10
|
-
<div id="container"></div>
|
|
11
|
-
`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
firstUpdated() {
|
|
15
|
-
const slot = this.shadowRoot?.querySelector("slot");
|
|
16
|
-
const assignedNodes = slot?.assignedNodes({ flatten: false });
|
|
17
|
-
|
|
18
|
-
// assignedNodes.forEach((node) => {
|
|
19
|
-
// if (node.nodeType === Node.ELEMENT_NODE) {
|
|
20
|
-
// console.log((node as HTMLElement).outerHTML);
|
|
21
|
-
// } else if (node.nodeType === Node.TEXT_NODE) {
|
|
22
|
-
// console.log(node.textContent);
|
|
23
|
-
// }
|
|
24
|
-
// });
|
|
25
|
-
|
|
26
|
-
render(assignedNodes[0], this.shadowRoot.querySelector("#container"));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static styles = css`
|
|
30
|
-
${unsafeCSS(styles)}
|
|
31
|
-
`;
|
|
32
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
@import url("@salut/design-system-salut/css/main.css");
|
|
2
|
-
|
|
3
|
-
#container {
|
|
4
|
-
display: flex;
|
|
5
|
-
align-items: center;
|
|
6
|
-
}
|
|
7
|
-
.white {
|
|
8
|
-
color: white;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.neutral {
|
|
12
|
-
color: var(--color-neutral-500);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.action-menu {
|
|
16
|
-
position: relative;
|
|
17
|
-
right: 230px;
|
|
18
|
-
padding: unset;
|
|
19
|
-
box-shadow:
|
|
20
|
-
0px 1px 3px 0px rgba(0, 0, 0, 0.1),
|
|
21
|
-
0px 4px 8px 3px rgba(0, 0, 0, 0.05);
|
|
22
|
-
z-index: 100;
|
|
23
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css, unsafeCSS } from "lit";
|
|
2
|
-
import { template } from "./template";
|
|
3
|
-
import styles from "./styles.css?inline";
|
|
4
|
-
import { customElement, property, state } from "lit/decorators.js";
|
|
5
|
-
|
|
6
|
-
@customElement("primaria-menu-item")
|
|
7
|
-
export class PrimariaMenuItem extends LitElement {
|
|
8
|
-
constructor(icon: string, label: string, showArrow: boolean, callbackFn: () => void) {
|
|
9
|
-
super();
|
|
10
|
-
this.icon = icon;
|
|
11
|
-
this.label = label;
|
|
12
|
-
this.showArrow = showArrow;
|
|
13
|
-
this.callbackFn = callbackFn;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
render() {
|
|
17
|
-
return html`${template(this)}`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static styles = css`
|
|
21
|
-
${unsafeCSS(styles)}
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
firstUpdated(p) {
|
|
25
|
-
super.firstUpdated(p);
|
|
26
|
-
this.observeHostResize();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
observeHostResize() {
|
|
30
|
-
const parentElement = this.parentElement;
|
|
31
|
-
const observer = new ResizeObserver((entries) => {
|
|
32
|
-
for (const entry of entries) {
|
|
33
|
-
const width = entry.target.clientWidth; // Obtenemos el ancho del host
|
|
34
|
-
this.showText = width > 100; // Mostrar texto si el ancho del host es mayor que 150px
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Observamos el tamaño del padre host del componente
|
|
39
|
-
observer.observe(parentElement as HTMLElement);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@property({ type: Number }) containerWidth = 0;
|
|
43
|
-
@state() showText = false;
|
|
44
|
-
// @state() showArrow = false;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@property({ type: String }) icon = "";
|
|
48
|
-
@property({ type: String }) label = "";
|
|
49
|
-
@property({ type: Boolean }) showArrow = false;
|
|
50
|
-
@property({ type: Function }) callbackFn = () => {};
|
|
51
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { PrimariaMenuItem } from "./primaria-menu-item";
|
|
3
|
-
|
|
4
|
-
export const template = (props: PrimariaMenuItem) => html`
|
|
5
|
-
<div class="item" @click=${props.callbackFn} ?expanded=${props.showText}>
|
|
6
|
-
<div class="icon-label">
|
|
7
|
-
<dss-icon icon=${props.icon} size="md"></dss-icon>
|
|
8
|
-
${props.showText ? html`<span>${props.label}</span>` : ""}
|
|
9
|
-
</div>
|
|
10
|
-
${props.showText && props.showArrow ? html`<dss-icon icon="chevron_right" size="md"></dss-icon>` : ""}
|
|
11
|
-
</div>`;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css, unsafeCSS } from "lit";
|
|
2
|
-
import { template } from "./template";
|
|
3
|
-
import styles from "./styles.css?inline";
|
|
4
|
-
import { customElement, property, state } from "lit/decorators.js";
|
|
5
|
-
|
|
6
|
-
@customElement("primaria-nav-menu")
|
|
7
|
-
export class PrimariaNavMenu extends LitElement {
|
|
8
|
-
constructor(
|
|
9
|
-
icon: string,
|
|
10
|
-
label: string,
|
|
11
|
-
subItems: { icon?: string; label: string; callbackFn: () => void }[],
|
|
12
|
-
) {
|
|
13
|
-
super();
|
|
14
|
-
this.icon = icon;
|
|
15
|
-
this.label = label;
|
|
16
|
-
this.subItems = subItems;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
firstUpdated(p) {
|
|
20
|
-
super.firstUpdated(p);
|
|
21
|
-
this.observeHostResize();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
observeHostResize() {
|
|
25
|
-
const parentElement = this.parentElement;
|
|
26
|
-
const observer = new ResizeObserver((entries) => {
|
|
27
|
-
for (const entry of entries) {
|
|
28
|
-
const width = entry.target.clientWidth; // Obtenemos el ancho del host
|
|
29
|
-
this.parentWidth = width;
|
|
30
|
-
this.showText = width > 100; // Mostrar texto si el ancho del host es mayor que 150px
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// Observamos el tamaño del padre host del componente
|
|
35
|
-
observer.observe(parentElement as HTMLElement);
|
|
36
|
-
this.resizeObserver = observer;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@property({ type: String }) icon = "";
|
|
40
|
-
@property({ type: String }) label = "";
|
|
41
|
-
@property({ type: Array }) subItems: { icon?: string; label: string; callbackFn: () => void }[] =
|
|
42
|
-
[];
|
|
43
|
-
|
|
44
|
-
@state() showText = false;
|
|
45
|
-
@state() isExpanded = false;
|
|
46
|
-
@state() parentWidth;
|
|
47
|
-
|
|
48
|
-
private resizeObserver?: ResizeObserver;
|
|
49
|
-
|
|
50
|
-
render() {
|
|
51
|
-
return html`${template(this)}`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static styles = css`
|
|
55
|
-
${unsafeCSS(styles)}
|
|
56
|
-
`;
|
|
57
|
-
|
|
58
|
-
toggleMenu() {
|
|
59
|
-
this.isExpanded = !this.isExpanded;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
disconnectedCallback() {
|
|
63
|
-
super.disconnectedCallback();
|
|
64
|
-
this.resizeObserver?.disconnect();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
.nav-menu {
|
|
2
|
-
position: relative;
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: row;
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
border-radius: 8px;
|
|
7
|
-
border: 1px;
|
|
8
|
-
border-color: white;
|
|
9
|
-
padding: 8px;
|
|
10
|
-
gap: 8px;
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
transition: background-color 0.3s ease;
|
|
14
|
-
|
|
15
|
-
&[expanded] {
|
|
16
|
-
justify-content: flex-start;
|
|
17
|
-
}
|
|
18
|
-
&:hover {
|
|
19
|
-
background-color: var(--color-primary-900);
|
|
20
|
-
color: white;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
dss-action-menu {
|
|
25
|
-
position: absolute;
|
|
26
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { PrimariaNavMenu } from "./primaria-nav-menu";
|
|
3
|
-
|
|
4
|
-
export const template = (props: PrimariaNavMenu) => {
|
|
5
|
-
const actionMenuStyle = `left: ${props.parentWidth}px`;
|
|
6
|
-
|
|
7
|
-
return html`
|
|
8
|
-
<div class="nav-menu" @click="${props.toggleMenu}" ?expanded=${props.showText}>
|
|
9
|
-
<dss-icon icon=${props.icon} size="md"></dss-icon>
|
|
10
|
-
${props.showText ? html`<span>${props.label}</span>` : ""}
|
|
11
|
-
${
|
|
12
|
-
props.isExpanded
|
|
13
|
-
? html`
|
|
14
|
-
<dss-action-menu style=${actionMenuStyle}>
|
|
15
|
-
${props.subItems.map(
|
|
16
|
-
(subItem) => html`
|
|
17
|
-
<dss-action-menu-item
|
|
18
|
-
label=${subItem.label}
|
|
19
|
-
righticon=${subItem.icon || ""}
|
|
20
|
-
@click=${subItem.callbackFn}
|
|
21
|
-
></dss-action-menu-item>
|
|
22
|
-
`,
|
|
23
|
-
)}
|
|
24
|
-
</dss-action-menu>
|
|
25
|
-
`
|
|
26
|
-
: ""
|
|
27
|
-
}
|
|
28
|
-
</div>
|
|
29
|
-
`;
|
|
30
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { LitElement, html, css, unsafeCSS, nothing } from "lit";
|
|
2
|
-
import styles from "./styles.css?inline";
|
|
3
|
-
import { customElement, property, state } from "lit/decorators.js";
|
|
4
|
-
import { template } from "./template";
|
|
5
|
-
|
|
6
|
-
interface MenuItem {
|
|
7
|
-
icon: string;
|
|
8
|
-
label: string;
|
|
9
|
-
callbackFn: () => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@customElement("primaria-wrapper-menu")
|
|
13
|
-
export class PrimariaWrapperMenu extends LitElement {
|
|
14
|
-
static styles = css`
|
|
15
|
-
${unsafeCSS(styles)}
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
@property({ type: String }) icon = "";
|
|
19
|
-
@property({ type: String }) label = "";
|
|
20
|
-
@property({ type: Boolean }) showArrow = true;
|
|
21
|
-
@property({ type: Array }) actionMenuItems: MenuItem[] = [];
|
|
22
|
-
|
|
23
|
-
@state() showActionMenu = false;
|
|
24
|
-
|
|
25
|
-
constructor(icon: string, label: string, showArrow: boolean, actionMenuItems: MenuItem[]) {
|
|
26
|
-
super();
|
|
27
|
-
this.icon = icon;
|
|
28
|
-
this.label = label;
|
|
29
|
-
this.showArrow = showArrow;
|
|
30
|
-
this.actionMenuItems = actionMenuItems;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
handleItemClick = () => {
|
|
34
|
-
this.showActionMenu = true;
|
|
35
|
-
this.requestUpdate();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
render() {
|
|
39
|
-
return html`${template(this)}`;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { html, nothing } from "lit";
|
|
2
|
-
import { PrimariaWrapperMenu } from "./primaria-wrapper-menu";
|
|
3
|
-
|
|
4
|
-
export const template = (props: PrimariaWrapperMenu) => html`
|
|
5
|
-
<div class="wrapper">
|
|
6
|
-
<primaria-menu-item
|
|
7
|
-
.icon=${props.icon}
|
|
8
|
-
.label=${props.label}
|
|
9
|
-
.showArrow=${props.showArrow}
|
|
10
|
-
@click=${props.handleItemClick}
|
|
11
|
-
></primaria-menu-item>
|
|
12
|
-
${props.showActionMenu
|
|
13
|
-
? html`
|
|
14
|
-
<dss-action-menu>
|
|
15
|
-
${props.actionMenuItems?.map(
|
|
16
|
-
(item) => html`
|
|
17
|
-
<dss-action-menu-item
|
|
18
|
-
righticon=${item.icon}
|
|
19
|
-
.label=${item.label}
|
|
20
|
-
@click=${item.callbackFn}
|
|
21
|
-
></dss-action-menu-item>
|
|
22
|
-
`
|
|
23
|
-
)}
|
|
24
|
-
</dss-action-menu>
|
|
25
|
-
`
|
|
26
|
-
: nothing}
|
|
27
|
-
</div>
|
|
28
|
-
`
|