@zeedhi/zd-user-info-common 1.3.5 → 3.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.
@@ -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 };
@@ -1,233 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@zeedhi/core'), require('@zeedhi/common')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@zeedhi/core', '@zeedhi/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@zeedhi/zd-user-info-common"] = {}, global["@zeedhi/core"], global["@zeedhi/common"]));
5
- })(this, (function (exports, core, common) { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
-
22
- function __decorate(decorators, target, key, desc) {
23
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
- 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;
26
- return c > 3 && r && Object.defineProperty(target, key, r), r;
27
- }
28
-
29
- let UserInfoController = class UserInfoController {
30
- constructor(component) {
31
- this.component = component;
32
- }
33
- get showChangeProfile() {
34
- const { changeProfile } = this.component.visibleItems;
35
- return changeProfile || changeProfile === undefined;
36
- }
37
- get showLogout() {
38
- const { logout } = this.component.visibleItems;
39
- return logout || logout === undefined;
40
- }
41
- };
42
- UserInfoController = __decorate([
43
- core.Singleton
44
- ], UserInfoController);
45
-
46
- class UserInfo extends common.ComponentRender {
47
- constructor(props) {
48
- super(props);
49
- /**
50
- * Props to be passed to the ZdAvatar component
51
- */
52
- this.avatarProps = {};
53
- /**
54
- * Components to be rendered on the bottom slot
55
- */
56
- this.bottomSlot = [];
57
- /**
58
- * Components to be rendered on the center slot
59
- */
60
- this.centerSlot = [];
61
- /**
62
- * Components to be rendered on the top slot
63
- */
64
- this.topSlot = [];
65
- /**
66
- * User name
67
- */
68
- this.user = '';
69
- /**
70
- * User image
71
- */
72
- this.userImage = '';
73
- /**
74
- * Designates if menu should close on outside-activator click.
75
- */
76
- this.closeOnClick = true;
77
- /**
78
- * Designates if menu should close when its content is clicked.
79
- */
80
- this.closeOnContentClick = true;
81
- /**
82
- * Applies position fixed to the dropdown.
83
- */
84
- this.fixed = false;
85
- /**
86
- * Components to be rendered on the menu header
87
- */
88
- this.headerSlot = [];
89
- /**
90
- * Props to be passed to the ZdImage component (rendered inside the avatar)
91
- */
92
- this.imageProps = {};
93
- /**
94
- * Offset the menu on the x-axis.
95
- */
96
- this.offsetX = false;
97
- /**
98
- * Offset the menu on the x-axis.
99
- */
100
- this.offsetY = true;
101
- /**
102
- * Designates whether menu should open on activator click.
103
- */
104
- this.openOnClick = true;
105
- /**
106
- * Designates whether menu should open on activator hover.
107
- */
108
- this.openOnHover = false;
109
- /**
110
- * Controls whether the component is visible or hidden.
111
- */
112
- this.value = false;
113
- this.visibleItems = {
114
- userName: true,
115
- changeProfile: true,
116
- logout: true,
117
- };
118
- /**
119
- * Sets the height for the dropdown.
120
- */
121
- this.height = 'auto';
122
- this.user = this.getInitValue('user', props.user, this.user);
123
- this.userImage = this.getInitValue('userImage', props.userImage, this.userImage);
124
- this.closeOnClick = this.getInitValue('closeOnClick', props.closeOnClick, this.closeOnClick);
125
- this.closeOnContentClick = this.getInitValue('closeOnContentClick', props.closeOnContentClick, this.closeOnContentClick);
126
- this.fixed = this.getInitValue('fixed', props.fixed, this.fixed);
127
- this.offsetX = this.getInitValue('offsetX', props.offsetX, this.offsetX);
128
- this.offsetY = this.getInitValue('offsetY', props.offsetY, this.offsetY);
129
- this.openOnClick = this.getInitValue('openOnClick', props.openOnClick, this.openOnClick);
130
- this.openOnHover = this.getInitValue('openOnHover', props.openOnHover, this.openOnHover);
131
- this.value = this.getInitValue('value', props.value, this.value);
132
- this.visibleItems = this.getInitValue('visibleItems', props.visibleItems, this.visibleItems);
133
- this.height = this.getInitValue('height', props.height, this.height);
134
- this.maxHeight = this.getInitValue('maxHeight', props.maxHeight, this.maxHeight);
135
- this.minHeight = this.getInitValue('minHeight', props.minHeight, this.minHeight);
136
- this.maxWidth = this.getInitValue('maxWidth', props.maxWidth, this.maxWidth);
137
- this.minWidth = this.getInitValue('minWidth', props.minWidth, this.minWidth);
138
- this.avatarProps = props.avatarProps || this.avatarProps;
139
- this.imageProps = props.imageProps || this.imageProps;
140
- this.activator = props.activator || this.getActivator();
141
- this.bottomSlot = props.bottomSlot || this.bottomSlot;
142
- this.propCenterSlot = props.centerSlot;
143
- this.topSlot = props.topSlot || this.topSlot;
144
- this.headerSlot = props.headerSlot || this.headerSlot;
145
- this.createAccessors();
146
- }
147
- getActivator() {
148
- return {
149
- name: `${this.name}_activator_tooltip`,
150
- component: 'ZdTooltip',
151
- bottom: true,
152
- label: this.user,
153
- children: [
154
- Object.assign({ name: `${this.name}_activator`, component: 'ZdAvatar', avatarSlot: [
155
- Object.assign({ name: `${this.name}_image`, component: 'ZdImage', src: this.userImage }, this.imageProps),
156
- ] }, this.avatarProps),
157
- ],
158
- };
159
- }
160
- getCenterSlot() {
161
- return [
162
- {
163
- name: `${this.name}_center_list`,
164
- component: 'ZdList',
165
- dense: true,
166
- items: [
167
- {
168
- name: `${this.name}_change_profile`,
169
- component: 'ZdListItem',
170
- title: 'USERINFO_CHANGE_PROFILE',
171
- prependIcon: 'mdi-account',
172
- cssClass: 'zd-px-2',
173
- isVisible: `{{UserInfoController_${this.componentId}.showChangeProfile}}`,
174
- events: {
175
- click: ({ event, element }) => this.onProfileChange(event, element),
176
- },
177
- },
178
- {
179
- name: `${this.name}_logout`,
180
- component: 'ZdListItem',
181
- title: 'USERINFO_LOGOUT',
182
- prependIcon: 'mdi-logout-variant',
183
- cssClass: 'zd-px-2',
184
- isVisible: `{{UserInfoController_${this.componentId}.showLogout}}`,
185
- events: {
186
- click: ({ event, element }) => this.onLogoutClick(event, element),
187
- },
188
- },
189
- ],
190
- },
191
- ];
192
- }
193
- onLogoutClick(event, element) {
194
- this.callEvent('onLogoutClick', { event, element, component: this });
195
- }
196
- onProfileChange(event, element) {
197
- this.callEvent('onProfileChange', { event, element, component: this });
198
- }
199
- onCreated() {
200
- super.onCreated();
201
- core.Loader.addController(`UserInfoController_${this.componentId}`, new UserInfoController(this));
202
- this.centerSlot = this.propCenterSlot ? this.propCenterSlot : this.getCenterSlot();
203
- }
204
- }
205
- core.Messages.add({
206
- 'pt-BR': {
207
- translation: {
208
- USERINFO_CHANGE_PROFILE: 'Alterar perfil',
209
- USERINFO_LOGOUT: 'Sair',
210
- },
211
- },
212
- 'en-US': {
213
- translation: {
214
- USERINFO_CHANGE_PROFILE: 'Change profile',
215
- USERINFO_LOGOUT: 'Sign out',
216
- },
217
- },
218
- 'es-CL': {
219
- translation: {
220
- USERINFO_CHANGE_PROFILE: 'Cambiar el perfil',
221
- USERINFO_LOGOUT: 'Salir',
222
- },
223
- },
224
- });
225
-
226
- const packageContent = require('../package.json');
227
- core.VersionService.addPackageVersion(packageContent.name, packageContent.version);
228
-
229
- exports.UserInfo = UserInfo;
230
-
231
- Object.defineProperty(exports, '__esModule', { value: true });
232
-
233
- }));
package/types/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './user-info';
2
- export * from './interfaces';