@zeedhi/zd-user-info-common 1.3.5 → 3.0.1
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 +92 -142
- package/{types → dist/types}/UserInfoController.d.ts +8 -7
- package/{types → dist/types}/index.d.ts +2 -2
- package/{types → dist/types}/interfaces.d.ts +27 -27
- package/{types → dist/types}/user-info.d.ts +130 -134
- package/dist/user-info-common.es.js +230 -0
- package/package.json +31 -17
- package/dist/user-info-common.esm.js +0 -226
- package/dist/user-info-common.umd.js +0 -233
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
var Z = Object.create;
|
|
2
|
+
var P = Object.defineProperty;
|
|
3
|
+
var T = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var U = (e, i) => (i = Symbol[e]) ? i : Symbol.for("Symbol." + e), C = (e) => {
|
|
5
|
+
throw TypeError(e);
|
|
6
|
+
};
|
|
7
|
+
var R = (e, i, t) => i in e ? P(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
|
|
8
|
+
var L = (e, i) => P(e, "name", { value: i, configurable: !0 });
|
|
9
|
+
var N = (e) => [, , , Z((e == null ? void 0 : e[U("metadata")]) ?? null)], F = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], I = (e) => e !== void 0 && typeof e != "function" ? C("Function expected") : e, X = (e, i, t, n, h) => ({ kind: F[e], name: i, metadata: n, addInitializer: (a) => t._ ? C("Already initialized") : h.push(I(a || null)) }), Y = (e, i) => R(i, U("metadata"), e[3]), W = (e, i, t, n) => {
|
|
10
|
+
for (var h = 0, a = e[i >> 1], g = a && a.length; h < g; h++) i & 1 ? a[h].call(t) : n = a[h].call(t, n);
|
|
11
|
+
return n;
|
|
12
|
+
}, A = (e, i, t, n, h, a) => {
|
|
13
|
+
var g, r, x, u, f, o = i & 7, O = !!(i & 8), c = !!(i & 16), v = o > 3 ? e.length + 1 : o ? O ? 1 : 2 : 0, H = F[o + 5], E = o > 3 && (e[v - 1] = []), G = e[v] || (e[v] = []), m = o && (!c && !O && (h = h.prototype), o < 5 && (o > 3 || !c) && T(o < 4 ? h : { get [t]() {
|
|
14
|
+
return V(this, a);
|
|
15
|
+
}, set [t](l) {
|
|
16
|
+
return b(this, a, l);
|
|
17
|
+
} }, t));
|
|
18
|
+
o ? c && o < 4 && L(a, (o > 2 ? "set " : o > 1 ? "get " : "") + t) : L(h, t);
|
|
19
|
+
for (var S = n.length - 1; S >= 0; S--)
|
|
20
|
+
u = X(o, t, x = {}, e[3], G), o && (u.static = O, u.private = c, f = u.access = { has: c ? (l) => w(h, l) : (l) => t in l }, o ^ 3 && (f.get = c ? (l) => (o ^ 1 ? V : z)(l, h, o ^ 4 ? a : m.get) : (l) => l[t]), o > 2 && (f.set = c ? (l, _) => b(l, h, _, o ^ 4 ? a : m.set) : (l, _) => l[t] = _)), r = (0, n[S])(o ? o < 4 ? c ? a : m[H] : o > 4 ? void 0 : { get: m.get, set: m.set } : h, u), x._ = 1, o ^ 4 || r === void 0 ? I(r) && (o > 4 ? E.unshift(r) : o ? c ? a = r : m[H] = r : h = r) : typeof r != "object" || r === null ? C("Object expected") : (I(g = r.get) && (m.get = g), I(g = r.set) && (m.set = g), I(g = r.init) && E.unshift(g));
|
|
21
|
+
return o || Y(e, h), m && P(h, t, m), c ? o ^ 4 ? a : m : h;
|
|
22
|
+
}, s = (e, i, t) => R(e, typeof i != "symbol" ? i + "" : i, t), k = (e, i, t) => i.has(e) || C("Cannot " + t), w = (e, i) => Object(i) !== i ? C('Cannot use the "in" operator on this value') : e.has(i), V = (e, i, t) => (k(e, i, "read from private field"), t ? t.call(e) : i.get(e));
|
|
23
|
+
var b = (e, i, t, n) => (k(e, i, "write to private field"), n ? n.call(e, t) : i.set(e, t), t), z = (e, i, t) => (k(e, i, "access private method"), t);
|
|
24
|
+
import { ComponentRender as B } from "@zeedhi/common";
|
|
25
|
+
import { Singleton as M, Messages as j, Loader as q } from "@zeedhi/core";
|
|
26
|
+
var $, p;
|
|
27
|
+
$ = [M];
|
|
28
|
+
class d {
|
|
29
|
+
constructor(i) {
|
|
30
|
+
s(this, "component");
|
|
31
|
+
this.component = i;
|
|
32
|
+
}
|
|
33
|
+
get showChangeProfile() {
|
|
34
|
+
const { changeProfile: i } = this.component.visibleItems;
|
|
35
|
+
return i || i === void 0;
|
|
36
|
+
}
|
|
37
|
+
get showLogout() {
|
|
38
|
+
const { logout: i } = this.component.visibleItems;
|
|
39
|
+
return i || i === void 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
p = N(null), d = A(p, 0, "UserInfoController", $, d), W(p, 1, d);
|
|
43
|
+
class K extends B {
|
|
44
|
+
constructor(t) {
|
|
45
|
+
super(t);
|
|
46
|
+
/**
|
|
47
|
+
* Dropdown activator
|
|
48
|
+
*/
|
|
49
|
+
s(this, "activator");
|
|
50
|
+
/**
|
|
51
|
+
* Props to be passed to the ZdAvatar component
|
|
52
|
+
*/
|
|
53
|
+
s(this, "avatarProps", {});
|
|
54
|
+
/**
|
|
55
|
+
* Components to be rendered on the bottom slot
|
|
56
|
+
*/
|
|
57
|
+
s(this, "bottomSlot", []);
|
|
58
|
+
/**
|
|
59
|
+
* Components to be rendered on the center slot
|
|
60
|
+
*/
|
|
61
|
+
s(this, "centerSlot", []);
|
|
62
|
+
/**
|
|
63
|
+
* Components to be rendered on the top slot
|
|
64
|
+
*/
|
|
65
|
+
s(this, "topSlot", []);
|
|
66
|
+
/**
|
|
67
|
+
* User name
|
|
68
|
+
*/
|
|
69
|
+
s(this, "user", "");
|
|
70
|
+
/**
|
|
71
|
+
* User image
|
|
72
|
+
*/
|
|
73
|
+
s(this, "userImage", "");
|
|
74
|
+
/**
|
|
75
|
+
* Designates if menu should close on outside-activator click.
|
|
76
|
+
*/
|
|
77
|
+
s(this, "closeOnClick", !0);
|
|
78
|
+
/**
|
|
79
|
+
* Designates if menu should close when its content is clicked.
|
|
80
|
+
*/
|
|
81
|
+
s(this, "closeOnContentClick", !0);
|
|
82
|
+
/**
|
|
83
|
+
* Applies position fixed to the dropdown.
|
|
84
|
+
*/
|
|
85
|
+
s(this, "fixed", !1);
|
|
86
|
+
/**
|
|
87
|
+
* Components to be rendered on the menu header
|
|
88
|
+
*/
|
|
89
|
+
s(this, "headerSlot", []);
|
|
90
|
+
/**
|
|
91
|
+
* Props to be passed to the ZdImage component (rendered inside the avatar)
|
|
92
|
+
*/
|
|
93
|
+
s(this, "imageProps", {});
|
|
94
|
+
/**
|
|
95
|
+
* Offset the menu on the x-axis.
|
|
96
|
+
*/
|
|
97
|
+
s(this, "offsetX", !1);
|
|
98
|
+
/**
|
|
99
|
+
* Offset the menu on the x-axis.
|
|
100
|
+
*/
|
|
101
|
+
s(this, "offsetY", !0);
|
|
102
|
+
/**
|
|
103
|
+
* Designates whether menu should open on activator click.
|
|
104
|
+
*/
|
|
105
|
+
s(this, "openOnClick", !0);
|
|
106
|
+
/**
|
|
107
|
+
* Designates whether menu should open on activator hover.
|
|
108
|
+
*/
|
|
109
|
+
s(this, "openOnHover", !1);
|
|
110
|
+
/**
|
|
111
|
+
* Controls whether the component is visible or hidden.
|
|
112
|
+
*/
|
|
113
|
+
s(this, "value", !1);
|
|
114
|
+
s(this, "visibleItems", {
|
|
115
|
+
userName: !0,
|
|
116
|
+
changeProfile: !0,
|
|
117
|
+
logout: !0
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* Sets the height for the dropdown.
|
|
121
|
+
*/
|
|
122
|
+
s(this, "height", "auto");
|
|
123
|
+
/**
|
|
124
|
+
* Sets the maximum height for the dropdown.
|
|
125
|
+
*/
|
|
126
|
+
s(this, "maxHeight");
|
|
127
|
+
/**
|
|
128
|
+
* Sets the maximum width for the dropdown.
|
|
129
|
+
*/
|
|
130
|
+
s(this, "maxWidth");
|
|
131
|
+
/**
|
|
132
|
+
* Sets the minimum height for the dropdown.
|
|
133
|
+
*/
|
|
134
|
+
s(this, "minHeight");
|
|
135
|
+
/**
|
|
136
|
+
* Sets the minimum width for the dropdown.
|
|
137
|
+
*/
|
|
138
|
+
s(this, "minWidth");
|
|
139
|
+
s(this, "propCenterSlot");
|
|
140
|
+
this.user = this.getInitValue("user", t.user, this.user), this.userImage = this.getInitValue("userImage", t.userImage, this.userImage), this.closeOnClick = this.getInitValue("closeOnClick", t.closeOnClick, this.closeOnClick), this.closeOnContentClick = this.getInitValue("closeOnContentClick", t.closeOnContentClick, this.closeOnContentClick), this.fixed = this.getInitValue("fixed", t.fixed, this.fixed), this.offsetX = this.getInitValue("offsetX", t.offsetX, this.offsetX), this.offsetY = this.getInitValue("offsetY", t.offsetY, this.offsetY), this.openOnClick = this.getInitValue("openOnClick", t.openOnClick, this.openOnClick), this.openOnHover = this.getInitValue("openOnHover", t.openOnHover, this.openOnHover), this.value = this.getInitValue("value", t.value, this.value), this.visibleItems = this.getInitValue("visibleItems", t.visibleItems, this.visibleItems), this.height = this.getInitValue("height", t.height, this.height), this.maxHeight = this.getInitValue("maxHeight", t.maxHeight, this.maxHeight), this.minHeight = this.getInitValue("minHeight", t.minHeight, this.minHeight), this.maxWidth = this.getInitValue("maxWidth", t.maxWidth, this.maxWidth), this.minWidth = this.getInitValue("minWidth", t.minWidth, this.minWidth), this.avatarProps = t.avatarProps || this.avatarProps, this.imageProps = t.imageProps || this.imageProps, this.activator = t.activator || this.getActivator(), this.bottomSlot = t.bottomSlot || this.bottomSlot, this.propCenterSlot = t.centerSlot, this.topSlot = t.topSlot || this.topSlot, this.headerSlot = t.headerSlot || this.headerSlot, this.createAccessors();
|
|
141
|
+
}
|
|
142
|
+
getActivator() {
|
|
143
|
+
return {
|
|
144
|
+
name: `${this.name}_activator_tooltip`,
|
|
145
|
+
component: "ZdTooltip",
|
|
146
|
+
bottom: !0,
|
|
147
|
+
label: this.user,
|
|
148
|
+
children: [
|
|
149
|
+
{
|
|
150
|
+
name: `${this.name}_activator`,
|
|
151
|
+
component: "ZdAvatar",
|
|
152
|
+
avatarSlot: [
|
|
153
|
+
{
|
|
154
|
+
name: `${this.name}_image`,
|
|
155
|
+
component: "ZdImage",
|
|
156
|
+
src: this.userImage,
|
|
157
|
+
...this.imageProps
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
...this.avatarProps
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
getCenterSlot() {
|
|
166
|
+
return [
|
|
167
|
+
{
|
|
168
|
+
name: `${this.name}_center_list`,
|
|
169
|
+
component: "ZdList",
|
|
170
|
+
dense: !0,
|
|
171
|
+
items: [
|
|
172
|
+
{
|
|
173
|
+
name: `${this.name}_change_profile`,
|
|
174
|
+
component: "ZdListItem",
|
|
175
|
+
title: "USERINFO_CHANGE_PROFILE",
|
|
176
|
+
prependIcon: "mdi-account",
|
|
177
|
+
cssClass: "zd-px-2",
|
|
178
|
+
isVisible: `{{UserInfoController_${this.componentId}.showChangeProfile}}`,
|
|
179
|
+
events: {
|
|
180
|
+
click: ({ event: t, element: n }) => this.onProfileChange(t, n)
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: `${this.name}_logout`,
|
|
185
|
+
component: "ZdListItem",
|
|
186
|
+
title: "USERINFO_LOGOUT",
|
|
187
|
+
prependIcon: "mdi-logout-variant",
|
|
188
|
+
cssClass: "zd-px-2",
|
|
189
|
+
isVisible: `{{UserInfoController_${this.componentId}.showLogout}}`,
|
|
190
|
+
events: {
|
|
191
|
+
click: ({ event: t, element: n }) => this.onLogoutClick(t, n)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
];
|
|
197
|
+
}
|
|
198
|
+
onLogoutClick(t, n) {
|
|
199
|
+
this.callEvent("onLogoutClick", { event: t, element: n, component: this });
|
|
200
|
+
}
|
|
201
|
+
onProfileChange(t, n) {
|
|
202
|
+
this.callEvent("onProfileChange", { event: t, element: n, component: this });
|
|
203
|
+
}
|
|
204
|
+
onCreated() {
|
|
205
|
+
super.onCreated(), q.addController(`UserInfoController_${this.componentId}`, d, [this]), this.centerSlot = this.propCenterSlot ? this.propCenterSlot : this.getCenterSlot();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
j.add({
|
|
209
|
+
"pt-BR": {
|
|
210
|
+
translation: {
|
|
211
|
+
USERINFO_CHANGE_PROFILE: "Alterar perfil",
|
|
212
|
+
USERINFO_LOGOUT: "Sair"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"en-US": {
|
|
216
|
+
translation: {
|
|
217
|
+
USERINFO_CHANGE_PROFILE: "Change profile",
|
|
218
|
+
USERINFO_LOGOUT: "Sign out"
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
"es-CL": {
|
|
222
|
+
translation: {
|
|
223
|
+
USERINFO_CHANGE_PROFILE: "Cambiar el perfil",
|
|
224
|
+
USERINFO_LOGOUT: "Salir"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
export {
|
|
229
|
+
K as UserInfo
|
|
230
|
+
};
|
package/package.json
CHANGED
|
@@ -1,27 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/zd-user-info-common",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
11
|
+
"module": "./dist/user-info-common.es.js",
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/user-info-common.es.js",
|
|
16
|
+
"types": "./dist/types/index.d.ts"
|
|
17
|
+
}
|
|
16
18
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "vite",
|
|
21
|
+
"build": "tsc && vite build",
|
|
22
|
+
"test": "vitest run --coverage",
|
|
23
|
+
"test:watch": "vitest"
|
|
21
24
|
},
|
|
22
25
|
"peerDependencies": {
|
|
23
|
-
"@zeedhi/common": "^
|
|
24
|
-
"@zeedhi/core": "^
|
|
26
|
+
"@zeedhi/common": "^3.0.0",
|
|
27
|
+
"@zeedhi/core": "^3.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^22.10.2",
|
|
31
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
32
|
+
"@zeedhi/common": "^3.0.0",
|
|
33
|
+
"@zeedhi/core": "^3.0.0",
|
|
34
|
+
"jsdom": "^25.0.1",
|
|
35
|
+
"typescript": "~5.6.2",
|
|
36
|
+
"vite": "^5.4.0",
|
|
37
|
+
"vite-plugin-dts": "^4.3.0",
|
|
38
|
+
"vitest": "^2.1.8"
|
|
25
39
|
},
|
|
26
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "2c2a25056f4faa91cf3d7a3227050ccde64d4fee"
|
|
27
41
|
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { Singleton, Messages, Loader, VersionService } from '@zeedhi/core';
|
|
2
|
-
import { ComponentRender } from '@zeedhi/common';
|
|
3
|
-
|
|
4
|
-
/*! *****************************************************************************
|
|
5
|
-
Copyright (c) Microsoft Corporation.
|
|
6
|
-
|
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
8
|
-
purpose with or without fee is hereby granted.
|
|
9
|
-
|
|
10
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
12
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
13
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
15
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
-
***************************************************************************** */
|
|
18
|
-
|
|
19
|
-
function __decorate(decorators, target, key, desc) {
|
|
20
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
21
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
22
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
23
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let UserInfoController = class UserInfoController {
|
|
27
|
-
constructor(component) {
|
|
28
|
-
this.component = component;
|
|
29
|
-
}
|
|
30
|
-
get showChangeProfile() {
|
|
31
|
-
const { changeProfile } = this.component.visibleItems;
|
|
32
|
-
return changeProfile || changeProfile === undefined;
|
|
33
|
-
}
|
|
34
|
-
get showLogout() {
|
|
35
|
-
const { logout } = this.component.visibleItems;
|
|
36
|
-
return logout || logout === undefined;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
UserInfoController = __decorate([
|
|
40
|
-
Singleton
|
|
41
|
-
], UserInfoController);
|
|
42
|
-
|
|
43
|
-
class UserInfo extends ComponentRender {
|
|
44
|
-
constructor(props) {
|
|
45
|
-
super(props);
|
|
46
|
-
/**
|
|
47
|
-
* Props to be passed to the ZdAvatar component
|
|
48
|
-
*/
|
|
49
|
-
this.avatarProps = {};
|
|
50
|
-
/**
|
|
51
|
-
* Components to be rendered on the bottom slot
|
|
52
|
-
*/
|
|
53
|
-
this.bottomSlot = [];
|
|
54
|
-
/**
|
|
55
|
-
* Components to be rendered on the center slot
|
|
56
|
-
*/
|
|
57
|
-
this.centerSlot = [];
|
|
58
|
-
/**
|
|
59
|
-
* Components to be rendered on the top slot
|
|
60
|
-
*/
|
|
61
|
-
this.topSlot = [];
|
|
62
|
-
/**
|
|
63
|
-
* User name
|
|
64
|
-
*/
|
|
65
|
-
this.user = '';
|
|
66
|
-
/**
|
|
67
|
-
* User image
|
|
68
|
-
*/
|
|
69
|
-
this.userImage = '';
|
|
70
|
-
/**
|
|
71
|
-
* Designates if menu should close on outside-activator click.
|
|
72
|
-
*/
|
|
73
|
-
this.closeOnClick = true;
|
|
74
|
-
/**
|
|
75
|
-
* Designates if menu should close when its content is clicked.
|
|
76
|
-
*/
|
|
77
|
-
this.closeOnContentClick = true;
|
|
78
|
-
/**
|
|
79
|
-
* Applies position fixed to the dropdown.
|
|
80
|
-
*/
|
|
81
|
-
this.fixed = false;
|
|
82
|
-
/**
|
|
83
|
-
* Components to be rendered on the menu header
|
|
84
|
-
*/
|
|
85
|
-
this.headerSlot = [];
|
|
86
|
-
/**
|
|
87
|
-
* Props to be passed to the ZdImage component (rendered inside the avatar)
|
|
88
|
-
*/
|
|
89
|
-
this.imageProps = {};
|
|
90
|
-
/**
|
|
91
|
-
* Offset the menu on the x-axis.
|
|
92
|
-
*/
|
|
93
|
-
this.offsetX = false;
|
|
94
|
-
/**
|
|
95
|
-
* Offset the menu on the x-axis.
|
|
96
|
-
*/
|
|
97
|
-
this.offsetY = true;
|
|
98
|
-
/**
|
|
99
|
-
* Designates whether menu should open on activator click.
|
|
100
|
-
*/
|
|
101
|
-
this.openOnClick = true;
|
|
102
|
-
/**
|
|
103
|
-
* Designates whether menu should open on activator hover.
|
|
104
|
-
*/
|
|
105
|
-
this.openOnHover = false;
|
|
106
|
-
/**
|
|
107
|
-
* Controls whether the component is visible or hidden.
|
|
108
|
-
*/
|
|
109
|
-
this.value = false;
|
|
110
|
-
this.visibleItems = {
|
|
111
|
-
userName: true,
|
|
112
|
-
changeProfile: true,
|
|
113
|
-
logout: true,
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Sets the height for the dropdown.
|
|
117
|
-
*/
|
|
118
|
-
this.height = 'auto';
|
|
119
|
-
this.user = this.getInitValue('user', props.user, this.user);
|
|
120
|
-
this.userImage = this.getInitValue('userImage', props.userImage, this.userImage);
|
|
121
|
-
this.closeOnClick = this.getInitValue('closeOnClick', props.closeOnClick, this.closeOnClick);
|
|
122
|
-
this.closeOnContentClick = this.getInitValue('closeOnContentClick', props.closeOnContentClick, this.closeOnContentClick);
|
|
123
|
-
this.fixed = this.getInitValue('fixed', props.fixed, this.fixed);
|
|
124
|
-
this.offsetX = this.getInitValue('offsetX', props.offsetX, this.offsetX);
|
|
125
|
-
this.offsetY = this.getInitValue('offsetY', props.offsetY, this.offsetY);
|
|
126
|
-
this.openOnClick = this.getInitValue('openOnClick', props.openOnClick, this.openOnClick);
|
|
127
|
-
this.openOnHover = this.getInitValue('openOnHover', props.openOnHover, this.openOnHover);
|
|
128
|
-
this.value = this.getInitValue('value', props.value, this.value);
|
|
129
|
-
this.visibleItems = this.getInitValue('visibleItems', props.visibleItems, this.visibleItems);
|
|
130
|
-
this.height = this.getInitValue('height', props.height, this.height);
|
|
131
|
-
this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
|
|
132
|
-
this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
|
|
133
|
-
this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
|
|
134
|
-
this.minWidth = this.getInitValue('minWidth', props.minWidth, this.minWidth);
|
|
135
|
-
this.avatarProps = props.avatarProps || this.avatarProps;
|
|
136
|
-
this.imageProps = props.imageProps || this.imageProps;
|
|
137
|
-
this.activator = props.activator || this.getActivator();
|
|
138
|
-
this.bottomSlot = props.bottomSlot || this.bottomSlot;
|
|
139
|
-
this.propCenterSlot = props.centerSlot;
|
|
140
|
-
this.topSlot = props.topSlot || this.topSlot;
|
|
141
|
-
this.headerSlot = props.headerSlot || this.headerSlot;
|
|
142
|
-
this.createAccessors();
|
|
143
|
-
}
|
|
144
|
-
getActivator() {
|
|
145
|
-
return {
|
|
146
|
-
name: `${this.name}_activator_tooltip`,
|
|
147
|
-
component: 'ZdTooltip',
|
|
148
|
-
bottom: true,
|
|
149
|
-
label: this.user,
|
|
150
|
-
children: [
|
|
151
|
-
Object.assign({ name: `${this.name}_activator`, component: 'ZdAvatar', avatarSlot: [
|
|
152
|
-
Object.assign({ name: `${this.name}_image`, component: 'ZdImage', src: this.userImage }, this.imageProps),
|
|
153
|
-
] }, this.avatarProps),
|
|
154
|
-
],
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
getCenterSlot() {
|
|
158
|
-
return [
|
|
159
|
-
{
|
|
160
|
-
name: `${this.name}_center_list`,
|
|
161
|
-
component: 'ZdList',
|
|
162
|
-
dense: true,
|
|
163
|
-
items: [
|
|
164
|
-
{
|
|
165
|
-
name: `${this.name}_change_profile`,
|
|
166
|
-
component: 'ZdListItem',
|
|
167
|
-
title: 'USERINFO_CHANGE_PROFILE',
|
|
168
|
-
prependIcon: 'mdi-account',
|
|
169
|
-
cssClass: 'zd-px-2',
|
|
170
|
-
isVisible: `{{UserInfoController_${this.componentId}.showChangeProfile}}`,
|
|
171
|
-
events: {
|
|
172
|
-
click: ({ event, element }) => this.onProfileChange(event, element),
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
name: `${this.name}_logout`,
|
|
177
|
-
component: 'ZdListItem',
|
|
178
|
-
title: 'USERINFO_LOGOUT',
|
|
179
|
-
prependIcon: 'mdi-logout-variant',
|
|
180
|
-
cssClass: 'zd-px-2',
|
|
181
|
-
isVisible: `{{UserInfoController_${this.componentId}.showLogout}}`,
|
|
182
|
-
events: {
|
|
183
|
-
click: ({ event, element }) => this.onLogoutClick(event, element),
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
],
|
|
187
|
-
},
|
|
188
|
-
];
|
|
189
|
-
}
|
|
190
|
-
onLogoutClick(event, element) {
|
|
191
|
-
this.callEvent('onLogoutClick', { event, element, component: this });
|
|
192
|
-
}
|
|
193
|
-
onProfileChange(event, element) {
|
|
194
|
-
this.callEvent('onProfileChange', { event, element, component: this });
|
|
195
|
-
}
|
|
196
|
-
onCreated() {
|
|
197
|
-
super.onCreated();
|
|
198
|
-
Loader.addController(`UserInfoController_${this.componentId}`, new UserInfoController(this));
|
|
199
|
-
this.centerSlot = this.propCenterSlot ? this.propCenterSlot : this.getCenterSlot();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
Messages.add({
|
|
203
|
-
'pt-BR': {
|
|
204
|
-
translation: {
|
|
205
|
-
USERINFO_CHANGE_PROFILE: 'Alterar perfil',
|
|
206
|
-
USERINFO_LOGOUT: 'Sair',
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
'en-US': {
|
|
210
|
-
translation: {
|
|
211
|
-
USERINFO_CHANGE_PROFILE: 'Change profile',
|
|
212
|
-
USERINFO_LOGOUT: 'Sign out',
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
'es-CL': {
|
|
216
|
-
translation: {
|
|
217
|
-
USERINFO_CHANGE_PROFILE: 'Cambiar el perfil',
|
|
218
|
-
USERINFO_LOGOUT: 'Salir',
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
const packageContent = require('../package.json');
|
|
224
|
-
VersionService.addPackageVersion(packageContent.name, packageContent.version);
|
|
225
|
-
|
|
226
|
-
export { UserInfo };
|