@gravitee/ui-components 3.25.3-typescript-fdacf14 → 3.25.3-typescript-493e1dd
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/package.json +5 -13
- package/src/atoms/gv-autocomplete.js +422 -1
- package/src/atoms/gv-button.js +397 -1
- package/src/atoms/gv-checkbox.js +178 -1
- package/src/atoms/gv-date-picker-calendar.js +812 -1
- package/src/atoms/gv-date-picker-cell.js +174 -1
- package/src/atoms/gv-date-picker.js +638 -1
- package/src/atoms/gv-file-upload.js +348 -1
- package/src/atoms/gv-icon.js +93 -1
- package/src/atoms/gv-image.js +135 -1
- package/src/atoms/gv-input-message.js +78 -1
- package/src/atoms/gv-input.js +508 -1
- package/src/atoms/gv-link.js +204 -1
- package/src/atoms/gv-message.js +133 -1
- package/src/atoms/gv-metric.js +112 -1
- package/src/atoms/gv-relative-time.js +143 -1
- package/src/atoms/gv-select-native.js +363 -1
- package/src/atoms/gv-select.js +413 -1
- package/src/atoms/gv-spinner.js +54 -1
- package/src/atoms/gv-state.js +125 -1
- package/src/atoms/gv-switch.js +235 -1
- package/src/atoms/gv-tag.js +162 -1
- package/src/atoms/gv-text.js +160 -1
- package/src/charts/gv-chart-bar.js +101 -1
- package/src/charts/gv-chart-gauge.js +92 -1
- package/src/charts/gv-chart-histogram.js +78 -1
- package/src/charts/gv-chart-line.js +218 -1
- package/src/charts/gv-chart-map.js +111 -1
- package/src/charts/gv-chart-pie.js +89 -1
- package/src/index.js +77 -1
- package/src/lib/cron-expression.js +176 -1
- package/src/lib/date.js +43 -1
- package/src/lib/events.js +26 -1
- package/src/lib/http-client-schema-form.js +67 -1
- package/src/lib/http.js +237 -1
- package/src/lib/i18n.js +93 -1
- package/src/lib/item.js +110 -1
- package/src/lib/properties.js +171 -1
- package/src/lib/schema-form.js +39 -1
- package/src/lib/studio.js +144 -1
- package/src/lib/style.js +39 -1
- package/src/lib/text-format.js +65 -1
- package/src/lib/theme.js +60 -1
- package/src/lib/utils.js +106 -1
- package/src/mixins/chart-element.js +153 -1
- package/src/mixins/input-element.js +136 -1
- package/src/mixins/item-resource.js +102 -1
- package/src/mixins/keyboard-element.js +62 -1
- package/src/mixins/update-after-browser.js +30 -1
- package/src/mixins/with-resize-observer.js +62 -1
- package/src/mixins/with-skeleton-attribute.js +109 -1
- package/src/molecules/gv-card-full.js +209 -1
- package/src/molecules/gv-card-list.js +101 -1
- package/src/molecules/gv-card.js +130 -1
- package/src/molecules/gv-category-list.js +56 -1
- package/src/molecules/gv-category.js +163 -1
- package/src/molecules/gv-code.js +334 -1
- package/src/molecules/gv-confirm.js +175 -1
- package/src/molecules/gv-cron-editor.js +685 -1
- package/src/molecules/gv-dropdown-menu.js +108 -1
- package/src/molecules/gv-expandable.js +116 -1
- package/src/molecules/gv-expression-language.js +263 -1
- package/src/molecules/gv-identity-picture.js +139 -1
- package/src/molecules/gv-list.js +214 -1
- package/src/molecules/gv-metrics.js +147 -1
- package/src/molecules/gv-modal.js +203 -1
- package/src/molecules/gv-nav.js +180 -1
- package/src/molecules/gv-option.js +230 -1
- package/src/molecules/gv-plans.js +400 -1
- package/src/molecules/gv-popover.js +323 -1
- package/src/molecules/gv-promote.js +203 -1
- package/src/molecules/gv-rating-list.js +341 -1
- package/src/molecules/gv-rating.js +234 -1
- package/src/molecules/gv-row-expandable.js +42 -1
- package/src/molecules/gv-row.js +205 -1
- package/src/molecules/gv-stats.js +110 -1
- package/src/molecules/gv-stepper.js +274 -1
- package/src/molecules/gv-table.js +644 -1
- package/src/molecules/gv-tree.js +238 -1
- package/src/organisms/gv-documentation.js +205 -1
- package/src/organisms/gv-header.js +276 -1
- package/src/organisms/gv-http-client.js +258 -1
- package/src/organisms/gv-menu.js +258 -1
- package/src/organisms/gv-newsletter-subscription.js +258 -1
- package/src/organisms/gv-pagination.js +179 -1
- package/src/organisms/gv-properties.js +860 -1
- package/src/organisms/gv-resizable-views.js +371 -1
- package/src/organisms/gv-resources.js +496 -1
- package/src/organisms/gv-schema-form-array.js +237 -1
- package/src/organisms/gv-schema-form-control-object.js +141 -1
- package/src/organisms/gv-schema-form-control.js +419 -1
- package/src/organisms/gv-schema-form.js +700 -1
- package/src/organisms/gv-tabs.js +201 -1
- package/src/organisms/gv-user-menu.js +298 -1
- package/src/organisms/gv-vertical-menu.js +119 -1
- package/src/policy-studio/gv-flow-step.js +443 -1
- package/src/policy-studio/gv-flow.js +595 -1
- package/src/policy-studio/gv-policy-studio-menu.js +689 -1
- package/src/policy-studio/gv-policy-studio.js +1712 -1
- package/src/styles/empty.js +35 -1
- package/src/styles/input.js +262 -1
- package/src/styles/link.js +31 -1
- package/src/styles/shapes.js +17 -1
- package/src/styles/skeleton.js +52 -1
- package/src/styles/zoom.js +39 -1
- package/src/theme/gv-theme.js +197 -1
- package/wc/gv-autocomplete.js +1 -1
- package/wc/gv-button.js +1 -1
- package/wc/gv-card-full.js +1 -1
- package/wc/gv-card-list.js +1 -1
- package/wc/gv-card.js +1 -1
- package/wc/gv-category-list.js +1 -1
- package/wc/gv-category.js +1 -1
- package/wc/gv-chart-bar.js +1 -1
- package/wc/gv-chart-gauge.js +1 -1
- package/wc/gv-chart-histogram.js +1 -1
- package/wc/gv-chart-line.js +1 -1
- package/wc/gv-chart-map.js +1 -1
- package/wc/gv-chart-pie.js +1 -1
- package/wc/gv-checkbox.js +1 -1
- package/wc/gv-code.js +1 -1
- package/wc/gv-confirm.js +1 -1
- package/wc/gv-cron-editor.js +1 -1
- package/wc/gv-date-picker-calendar.js +1 -1
- package/wc/gv-date-picker-cell.js +1 -1
- package/wc/gv-date-picker.js +1 -1
- package/wc/gv-documentation.js +1 -1
- package/wc/gv-dropdown-menu.js +1 -1
- package/wc/gv-expandable.js +1 -1
- package/wc/gv-expression-language.js +1 -1
- package/wc/gv-file-upload.js +1 -1
- package/wc/gv-flow-step.js +1 -1
- package/wc/gv-flow.js +1 -1
- package/wc/gv-header.js +1 -1
- package/wc/gv-http-client.js +1 -1
- package/wc/gv-icon.js +1 -1
- package/wc/gv-identity-picture.js +1 -1
- package/wc/gv-image.js +1 -1
- package/wc/gv-input-message.js +1 -1
- package/wc/gv-input.js +1 -1
- package/wc/gv-link.js +1 -1
- package/wc/gv-list.js +1 -1
- package/wc/gv-menu.js +1 -1
- package/wc/gv-message.js +1 -1
- package/wc/gv-metric.js +1 -1
- package/wc/gv-metrics.js +1 -1
- package/wc/gv-modal.js +1 -1
- package/wc/gv-nav.js +1 -1
- package/wc/gv-newsletter-subscription.js +1 -1
- package/wc/gv-option.js +1 -1
- package/wc/gv-pagination.js +1 -1
- package/wc/gv-plans.js +1 -1
- package/wc/gv-policy-studio-menu.js +1 -1
- package/wc/gv-policy-studio.js +1 -1
- package/wc/gv-popover.js +1 -1
- package/wc/gv-promote.js +1 -1
- package/wc/gv-properties.js +1 -1
- package/wc/gv-rating-list.js +1 -1
- package/wc/gv-rating.js +1 -1
- package/wc/gv-relative-time.js +1 -1
- package/wc/gv-resizable-views.js +1 -1
- package/wc/gv-resources.js +1 -1
- package/wc/gv-row-expandable.js +1 -1
- package/wc/gv-row.js +1 -1
- package/wc/gv-schema-form-array.js +1 -1
- package/wc/gv-schema-form-control-object.js +1 -1
- package/wc/gv-schema-form-control.js +1 -1
- package/wc/gv-schema-form.js +1 -1
- package/wc/gv-select-native.js +1 -1
- package/wc/gv-select.js +1 -1
- package/wc/gv-spinner.js +1 -1
- package/wc/gv-state.js +1 -1
- package/wc/gv-stats.js +1 -1
- package/wc/gv-stepper.js +1 -1
- package/wc/gv-switch.js +1 -1
- package/wc/gv-table.js +1 -1
- package/wc/gv-tabs.js +1 -1
- package/wc/gv-tag.js +1 -1
- package/wc/gv-text.js +1 -1
- package/wc/gv-theme.js +1 -1
- package/wc/gv-tree.js +1 -1
- package/wc/gv-user-menu.js +1 -1
- package/wc/gv-vertical-menu.js +1 -1
package/src/organisms/gv-tabs.js
CHANGED
|
@@ -1 +1,201 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { css, LitElement, html } from 'lit';
|
|
17
|
+
import '../molecules/gv-option';
|
|
18
|
+
import { dispatchCustomEvent } from '../lib/events';
|
|
19
|
+
/**
|
|
20
|
+
* Tabs component
|
|
21
|
+
*
|
|
22
|
+
* * ## Details
|
|
23
|
+
* * This component use gv-option component to generate tabs.
|
|
24
|
+
*
|
|
25
|
+
* @attr {Array<id: string | {id, title?, icon?, active?, description?, label?}>} options - An array of options for gv-option sub component
|
|
26
|
+
* @slot content - List of elements for tabs content. Should have an id related to options.
|
|
27
|
+
*
|
|
28
|
+
* @attr {String} value - the opened tab id
|
|
29
|
+
* @attr {Boolean} disabled - true if disabled
|
|
30
|
+
* @attr {Boolean} small - true if you want display tabs below of title
|
|
31
|
+
* @attr {Boolean} truncate - true if you want truncate tabs title
|
|
32
|
+
* @attr {Function} validator - a function that's calls when user change tab, this is useful to validate tab change.
|
|
33
|
+
*
|
|
34
|
+
* @cssprop {Length} [--gv-tabs-options--m=0] - Tabs options margin
|
|
35
|
+
*/
|
|
36
|
+
export class GvTabs extends LitElement {
|
|
37
|
+
static get properties() {
|
|
38
|
+
return {
|
|
39
|
+
options: { type: Array },
|
|
40
|
+
_options: { type: Array, attribute: false },
|
|
41
|
+
value: { type: String, reflect: true },
|
|
42
|
+
validator: { type: Function },
|
|
43
|
+
disabled: { type: Boolean },
|
|
44
|
+
small: { type: Boolean },
|
|
45
|
+
truncate: { type: Boolean },
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
static get styles() {
|
|
49
|
+
return [
|
|
50
|
+
// language=css
|
|
51
|
+
css `
|
|
52
|
+
:host {
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
::slotted([slot='content']) {
|
|
57
|
+
opacity: 0;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
transition: opacity 350ms ease-in-out;
|
|
60
|
+
visibility: hidden;
|
|
61
|
+
position: absolute;
|
|
62
|
+
left: -9999px;
|
|
63
|
+
top: -9999px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
::slotted([slot='content'].current) {
|
|
67
|
+
opacity: 1;
|
|
68
|
+
visibility: visible;
|
|
69
|
+
position: relative;
|
|
70
|
+
left: auto;
|
|
71
|
+
top: auto;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.header {
|
|
75
|
+
display: flex;
|
|
76
|
+
border-bottom: 1px solid #d9d9d9;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.title {
|
|
81
|
+
flex: 1;
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.actions {
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.tabs {
|
|
92
|
+
flex: 1;
|
|
93
|
+
display: flex;
|
|
94
|
+
justify-content: flex-end;
|
|
95
|
+
--gv-option--bdrs: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:host([small]) .tabs {
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:host([small]) gv-option {
|
|
103
|
+
align-self: flex-end;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
gv-option {
|
|
107
|
+
margin: var(--gv-tabs-options--m, 0);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
::slotted(gv-button) {
|
|
111
|
+
padding-bottom: 2px;
|
|
112
|
+
}
|
|
113
|
+
`,
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
_getContent() {
|
|
117
|
+
const content = this.shadowRoot.querySelector('slot[name="content"]');
|
|
118
|
+
return content.assignedNodes();
|
|
119
|
+
}
|
|
120
|
+
firstUpdated() {
|
|
121
|
+
if (this.value == null && this.options != null && this.options.length > 0) {
|
|
122
|
+
this.value = this.options[0].id;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
set options(options) {
|
|
126
|
+
if (options && Array.isArray(options)) {
|
|
127
|
+
this._options = options.map((option) => {
|
|
128
|
+
if (typeof option === 'string') {
|
|
129
|
+
return { id: option, title: option };
|
|
130
|
+
}
|
|
131
|
+
else if (typeof option === 'object' && option.title == null) {
|
|
132
|
+
return { id: option.id, title: option.id };
|
|
133
|
+
}
|
|
134
|
+
return option;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
get options() {
|
|
139
|
+
return this._options;
|
|
140
|
+
}
|
|
141
|
+
updated() {
|
|
142
|
+
const content = this._getContent();
|
|
143
|
+
content.forEach((c) => c.classList.remove('current'));
|
|
144
|
+
if (this.value) {
|
|
145
|
+
const target = this.querySelector(`#${this.value}`);
|
|
146
|
+
if (target) {
|
|
147
|
+
target.classList.add('current');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
content[0].classList.add('current');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
_changeTab(from, content, value) {
|
|
155
|
+
from.classList.remove('current');
|
|
156
|
+
content.classList.add('current');
|
|
157
|
+
this.value = value;
|
|
158
|
+
dispatchCustomEvent(this, 'change', { value, from: from.id, to: content.id });
|
|
159
|
+
}
|
|
160
|
+
_onClick({ detail }) {
|
|
161
|
+
if (!this.disabled) {
|
|
162
|
+
const from = this._getContent().find((e) => e.classList.contains('current'));
|
|
163
|
+
const content = this.querySelector(`#${detail.id}`);
|
|
164
|
+
this.shadowRoot.querySelector('gv-option').value = from.id;
|
|
165
|
+
if (this.validator) {
|
|
166
|
+
this.validator({ from: from.id, to: content.id })
|
|
167
|
+
.then(() => {
|
|
168
|
+
this._changeTab(from, content, detail.id);
|
|
169
|
+
})
|
|
170
|
+
.catch(() => { });
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
this._changeTab(from, content, detail.id);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
get _contextualOptions() {
|
|
178
|
+
if (this.truncate) {
|
|
179
|
+
return this.options.map((option) => {
|
|
180
|
+
if (this.value !== option.id) {
|
|
181
|
+
const label = option.label || option.title;
|
|
182
|
+
return { ...option, label: label.substring(0, 1) };
|
|
183
|
+
}
|
|
184
|
+
return option;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return this.options;
|
|
188
|
+
}
|
|
189
|
+
render() {
|
|
190
|
+
return html `<div>
|
|
191
|
+
<div class="header">
|
|
192
|
+
<div class="tabs">
|
|
193
|
+
<slot name="title" class="title"></slot>
|
|
194
|
+
<gv-option small .options="${this._contextualOptions}" @gv-option:select="${this._onClick}" .value="${this.value}"></gv-option>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
<slot name="content"></slot>
|
|
198
|
+
</div>`;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
window.customElements.define('gv-tabs', GvTabs);
|
|
@@ -1 +1,298 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { LitElement, html, css } from 'lit';
|
|
17
|
+
import '../molecules/gv-nav';
|
|
18
|
+
import { repeat } from 'lit/directives/repeat';
|
|
19
|
+
import { classMap } from 'lit/directives/class-map';
|
|
20
|
+
import { isSameRoutes } from '../lib/utils';
|
|
21
|
+
/**
|
|
22
|
+
* User menu
|
|
23
|
+
*
|
|
24
|
+
* ## Details
|
|
25
|
+
* * has @theme facet
|
|
26
|
+
*
|
|
27
|
+
* @fires gv-link:click - Custom event when nav link click
|
|
28
|
+
*
|
|
29
|
+
* @attr {Array} routes - definition of user routes [{icon: String, path: String, title: Promise<String>, active: Boolean, routes: Array<any>]
|
|
30
|
+
* @attr {String} username - name of the user
|
|
31
|
+
* @attr {String} avatar - url of the user avatar
|
|
32
|
+
*
|
|
33
|
+
* @cssprop {Color} [--gv-user-menu--c=var(--gv-theme-font-color-dark, #262626)] - Color
|
|
34
|
+
* @cssprop {Color} [--gv-user-menu-hover--c=var(--gv-theme-color-dark, #28444f)] - Hover color
|
|
35
|
+
* @cssprop {Color} [--gv-user-menu--bgc=transparent] - Background color
|
|
36
|
+
* @cssprop {Color} [--gv-user-menu-list--bgc=var(--gv-theme-neutral-color-lightest, #ffffff)] - List background color
|
|
37
|
+
* @cssprop {Color} [--gv-user-menu-hover--bgc=var(--gv-theme-color-light, #86c3d0)] - Hover background color
|
|
38
|
+
* @cssprop {Color} [--gv-user-menu--bdc=lightgrey] - Border color
|
|
39
|
+
* @cssprop {String} [--gv-user-menu--tsh=none] - Text shadow
|
|
40
|
+
* @cssprop {Color} [--gv-user-menu-icon--c=var(--gv-theme-neutral-color-darkest, #000000)] - Icon color
|
|
41
|
+
* @cssprop {Length} [--gv-user-menu-icon--s=16px] - Height and icon width
|
|
42
|
+
* @cssprop {Length} [--gv-user-menu-link-a--ph=0px] - Link horizontal padding
|
|
43
|
+
* @cssprop {String} [--gv-user-menu-link--ta=right] - Text align
|
|
44
|
+
*/
|
|
45
|
+
export class GvUserMenu extends LitElement {
|
|
46
|
+
static get properties() {
|
|
47
|
+
return {
|
|
48
|
+
avatar: { type: String },
|
|
49
|
+
routes: { type: Array },
|
|
50
|
+
_routes: { type: Array, attribute: false },
|
|
51
|
+
_isClosed: { type: Boolean, attribute: false },
|
|
52
|
+
username: { type: String },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
static get styles() {
|
|
56
|
+
return [
|
|
57
|
+
// language=css
|
|
58
|
+
css `
|
|
59
|
+
:host {
|
|
60
|
+
--bdc: var(--gv-user-menu--bdc, lightgrey);
|
|
61
|
+
--c: var(--gv-user-menu--c, var(--gv-theme-font-color-dark, #262626));
|
|
62
|
+
--bgc: var(--gv-user-menu--bgc, transparent);
|
|
63
|
+
--list-bgc: var(--gv-user-menu-list--bgc, var(--gv-theme-neutral-color-lightest, #ffffff));
|
|
64
|
+
--hover-bgc: var(--gv-user-menu-hover--bgc, var(--gv-theme-color-light, #86c3d0));
|
|
65
|
+
--gv-link-active--c: var(--gv-user-menu-hover--c, var(--gv-theme-color-dark, #28444f));
|
|
66
|
+
--gv-icon--c: var(--gv-user-menu-icon--c, var(--gv-theme-neutral-color-darkest, #000000));
|
|
67
|
+
--gv-icon--s: var(--gv-user-menu-icon--s, 16px);
|
|
68
|
+
--gv-link-a--ph: var(--gv-user-menu-link-a--ph, 0px);
|
|
69
|
+
--gv-link--ta: var(--gv-user-menu-link--ta, right);
|
|
70
|
+
user-select: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.user-menu {
|
|
74
|
+
list-style: none;
|
|
75
|
+
margin: 0;
|
|
76
|
+
padding: 0;
|
|
77
|
+
display: inline-block;
|
|
78
|
+
position: relative;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.user-menu__title {
|
|
82
|
+
background-color: var(--bgc);
|
|
83
|
+
border-left: 1px solid var(--bdc);
|
|
84
|
+
color: var(--c);
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
line-height: 40px;
|
|
87
|
+
padding: 8px 24px;
|
|
88
|
+
display: inline-flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
justify-content: space-between;
|
|
91
|
+
min-width: 175px;
|
|
92
|
+
text-shadow: var(--gv-user-menu--tsh, none);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
::slotted(*) {
|
|
96
|
+
height: 40px;
|
|
97
|
+
width: 40px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.user-menu__title.no-user {
|
|
101
|
+
padding: 5px 24px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.user-menu__title gv-link {
|
|
105
|
+
--gv-link-a--ph: 0;
|
|
106
|
+
--gv-link-a--pv: 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.user-menu__title span {
|
|
110
|
+
flex: 1;
|
|
111
|
+
text-align: center;
|
|
112
|
+
margin: 0 0.4rem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.user-menu__title > gv-icon {
|
|
116
|
+
transition: all 0.3s ease 0s;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.user-menu__list {
|
|
120
|
+
position: absolute;
|
|
121
|
+
background-color: var(--list-bgc);
|
|
122
|
+
list-style: none;
|
|
123
|
+
padding: 0;
|
|
124
|
+
transition: all 0.3s ease 0s;
|
|
125
|
+
width: 100%;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.user-menu__list__item {
|
|
129
|
+
border-left: 1px solid var(--bdc);
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
transition: all 0.5s ease;
|
|
133
|
+
padding: 2px 30px;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.user-menu__list__item:last-child {
|
|
137
|
+
border-bottom: 1px solid var(--bdc);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.user-menu__list__item:hover {
|
|
141
|
+
background-color: var(--hover-bgc);
|
|
142
|
+
border-left: 1px dotted var(--bdc);
|
|
143
|
+
font-weight: 500;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
gv-link {
|
|
147
|
+
margin: 0px;
|
|
148
|
+
display: flex;
|
|
149
|
+
width: 100%;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.separator {
|
|
153
|
+
border-top: 1px solid var(--bdc);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.active {
|
|
157
|
+
background-color: var(--gv-theme-neutral-color-dark, #d9d9d9);
|
|
158
|
+
font-weight: bold;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** for animations */
|
|
162
|
+
.user-menu__list {
|
|
163
|
+
visibility: visible;
|
|
164
|
+
opacity: 1;
|
|
165
|
+
transform: translateY(0%);
|
|
166
|
+
z-index: 100;
|
|
167
|
+
transition-delay: 0s, 0s, 0.2s;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.user-menu__list__group {
|
|
171
|
+
border-top: 1px solid var(--bdc);
|
|
172
|
+
background-color: var(--gv-theme-neutral-color-light, #efefef);
|
|
173
|
+
padding-left: 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.user-menu__list__group__title {
|
|
177
|
+
font-size: small;
|
|
178
|
+
color: var(--gv-theme-color-darker, #383e3f);
|
|
179
|
+
border-left: 1px solid var(--bdc);
|
|
180
|
+
padding-left: 10px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.closed .user-menu__list {
|
|
184
|
+
visibility: hidden;
|
|
185
|
+
opacity: 0;
|
|
186
|
+
transform: translateY(-2em);
|
|
187
|
+
z-index: -1;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
gv-icon {
|
|
191
|
+
transform: rotate(0deg);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.closed gv-icon {
|
|
195
|
+
transform: rotate(-180deg);
|
|
196
|
+
}
|
|
197
|
+
`,
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
constructor() {
|
|
201
|
+
super();
|
|
202
|
+
this._isClosed = true;
|
|
203
|
+
}
|
|
204
|
+
_onClick(e) {
|
|
205
|
+
e.preventDefault();
|
|
206
|
+
this._isClosed = !this._isClosed;
|
|
207
|
+
}
|
|
208
|
+
_onMouseLeave() {
|
|
209
|
+
this._isClosed = true;
|
|
210
|
+
}
|
|
211
|
+
_onSelect() {
|
|
212
|
+
this._isClosed = true;
|
|
213
|
+
}
|
|
214
|
+
_hasOneItem() {
|
|
215
|
+
return this.username == null && this._routes && this._routes.length === 1;
|
|
216
|
+
}
|
|
217
|
+
set routes(candidate) {
|
|
218
|
+
if (candidate) {
|
|
219
|
+
Promise.resolve(candidate).then((candidates) => {
|
|
220
|
+
if (candidates) {
|
|
221
|
+
Promise.all(candidates).then((futureRoutes) => {
|
|
222
|
+
if (!isSameRoutes(this._routes, futureRoutes)) {
|
|
223
|
+
this._routes = futureRoutes.filter((r) => r != null);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
this._routes = null;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
this._routes = null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
_renderFirstItem() {
|
|
237
|
+
if (this._routes) {
|
|
238
|
+
if (this.username) {
|
|
239
|
+
return html `<li class="user-menu__title" @click=${this._onClick}>
|
|
240
|
+
<div>
|
|
241
|
+
<slot></slot>
|
|
242
|
+
</div>
|
|
243
|
+
<span>${this.username}</span>
|
|
244
|
+
<gv-icon shape="design:triangle"></gv-icon>
|
|
245
|
+
</li>`;
|
|
246
|
+
}
|
|
247
|
+
else if (this._hasOneItem()) {
|
|
248
|
+
const firstItem = this._routes[0];
|
|
249
|
+
return html `<li class="user-menu__title no-user" @click=${this._onClick}>
|
|
250
|
+
<gv-link .icon="${firstItem.icon}" .path="${firstItem.path}" .title="${firstItem.title}" @click=${this._onSelect}></gv-link>
|
|
251
|
+
</li>`;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return html ``;
|
|
255
|
+
}
|
|
256
|
+
render() {
|
|
257
|
+
const classes = { closed: this._isClosed };
|
|
258
|
+
if (this._routes) {
|
|
259
|
+
return html `
|
|
260
|
+
<nav class="${classMap(classes)}">
|
|
261
|
+
<ul class="user-menu" @mouseleave=${this._onMouseLeave}>
|
|
262
|
+
${this._renderFirstItem()}
|
|
263
|
+
|
|
264
|
+
<li class="user-menu__content">
|
|
265
|
+
<ul class="user-menu__list">
|
|
266
|
+
${repeat(this._routes, (route) => route, (route, index) => html ` ${this._hasOneItem() ? html `` : this._renderItem(route)} `)}
|
|
267
|
+
</ul>
|
|
268
|
+
</li>
|
|
269
|
+
</ul>
|
|
270
|
+
</nav>
|
|
271
|
+
`;
|
|
272
|
+
}
|
|
273
|
+
return html ``;
|
|
274
|
+
}
|
|
275
|
+
_renderItem(route) {
|
|
276
|
+
if (route.routes) {
|
|
277
|
+
return html `<ul class="user-menu__list__group">
|
|
278
|
+
<span class="user-menu__list__group__title">${route.title}</span>
|
|
279
|
+
${repeat(route.routes, (childRoute) => childRoute, (childRoute, index) => html ` ${this._renderItem(childRoute)} `)}
|
|
280
|
+
</ul>`;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
return html `<li
|
|
284
|
+
class="user-menu__list__item ${route.separator ? 'separator' : ''} ${route.active ? 'active' : ''}"
|
|
285
|
+
style="${route.style}"
|
|
286
|
+
>
|
|
287
|
+
<gv-link
|
|
288
|
+
.icon="${route.icon}"
|
|
289
|
+
.path="${route.path}"
|
|
290
|
+
.title="${route.title}"
|
|
291
|
+
.target="${route.target}"
|
|
292
|
+
@click=${this._onSelect}
|
|
293
|
+
></gv-link>
|
|
294
|
+
</li>`;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
window.customElements.define('gv-user-menu', GvUserMenu);
|
|
@@ -1 +1,119 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { css, html, LitElement } from 'lit';
|
|
17
|
+
import '../molecules/gv-nav';
|
|
18
|
+
import '../atoms/gv-image';
|
|
19
|
+
import { isSameRoutes } from '../lib/utils';
|
|
20
|
+
/**
|
|
21
|
+
* A vertical menu
|
|
22
|
+
*
|
|
23
|
+
* @fires gv-link:click - Custom event when link click
|
|
24
|
+
*
|
|
25
|
+
* @attr {Array} routes - definition of routes [{active: Boolean, icon: String, path: String, title: Promise<String>]
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
export class GvVerticalMenu extends LitElement {
|
|
29
|
+
static get properties() {
|
|
30
|
+
return {
|
|
31
|
+
/** @required **/
|
|
32
|
+
routes: { type: Array },
|
|
33
|
+
_routes: { type: Array, attribute: false },
|
|
34
|
+
logo: { type: String },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
static get styles() {
|
|
38
|
+
return [
|
|
39
|
+
// language=css
|
|
40
|
+
css `
|
|
41
|
+
:host {
|
|
42
|
+
--gv-link--c: var(--gv-menu--c, var(--gv-theme-font-color-light, #ffffff));
|
|
43
|
+
--gv-link-active--c: var(--gv-menu--c, var(--gv-theme-font-color-light, #ffffff));
|
|
44
|
+
--gv-link--bgc: var(--gv-menu-link--bgc, transparent);
|
|
45
|
+
--gv-link-active--bgc: var(--gv-menu-link-active--bgc, transparent);
|
|
46
|
+
--gv-link-active--bdw: var(--gv-menu-link-active--bdw, 0 0 0 4px);
|
|
47
|
+
--gv-link-active--bdc: var(--gv-menu-link-active--bdc, var(--gv-theme-color-light, #86c3d0));
|
|
48
|
+
--gv-link-active--bds: var(--gv-menu-link-active--bds, solid);
|
|
49
|
+
--pr: var(--gv-theme-layout--pr, 4rem);
|
|
50
|
+
--pl: var(--gv-theme-layout--pl, 4rem);
|
|
51
|
+
box-sizing: border-box;
|
|
52
|
+
display: block;
|
|
53
|
+
font-size: var(--gv-theme-font-size-s, 16px);
|
|
54
|
+
width: var(--gv-theme-layout-menu-w, 200px);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.menu-container {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
justify-content: space-between;
|
|
61
|
+
|
|
62
|
+
background-color: var(--gv-menu--bgc, var(--gv-theme-color-dark, #28444f));
|
|
63
|
+
color: var(--gv-menu--c, var(--gv-theme-font-color-light, #ffffff));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
gv-image {
|
|
67
|
+
height: 200px;
|
|
68
|
+
width: 200px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
gv-nav {
|
|
72
|
+
transition: width 250ms ease-in-out;
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
justify-content: space-between;
|
|
76
|
+
line-height: 20px;
|
|
77
|
+
vertical-align: middle;
|
|
78
|
+
width: 100%;
|
|
79
|
+
font-size: 16px;
|
|
80
|
+
}
|
|
81
|
+
`,
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
constructor() {
|
|
85
|
+
super();
|
|
86
|
+
/** @protected */
|
|
87
|
+
this._routes = [];
|
|
88
|
+
}
|
|
89
|
+
set routes(candidate) {
|
|
90
|
+
if (candidate) {
|
|
91
|
+
Promise.resolve(candidate).then((candidates) => {
|
|
92
|
+
if (candidates) {
|
|
93
|
+
Promise.all(candidates).then((futureRoutes) => {
|
|
94
|
+
if (!isSameRoutes(this._routes, futureRoutes)) {
|
|
95
|
+
this._routes = futureRoutes.filter((r) => r != null);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this._routes = null;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this._routes = null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
render() {
|
|
109
|
+
return html `
|
|
110
|
+
<div class="menu-container">
|
|
111
|
+
${this.logo ? html `<gv-image .src="${this.logo}"></gv-image>` : ''}
|
|
112
|
+
<div class="nav-container">
|
|
113
|
+
<gv-nav .routes="${this._routes}" vertical></gv-nav>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
window.customElements.define('gv-vertical-menu', GvVerticalMenu);
|