@gravitee/ui-components 3.25.3-typescript-50960c3 → 3.25.3-typescript-9d19b68
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
|
@@ -1 +1,323 @@
|
|
|
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 { classMap } from 'lit/directives/class-map';
|
|
18
|
+
/**
|
|
19
|
+
* Popover component
|
|
20
|
+
*
|
|
21
|
+
* ## Details
|
|
22
|
+
* * has @theme facet
|
|
23
|
+
*
|
|
24
|
+
* @attr {String} event - the event that triggers the opening.
|
|
25
|
+
* @attr {String} delay - the time before closing, useful for a click event
|
|
26
|
+
* @attr {String} arrow - if need arrow
|
|
27
|
+
* @attr {String} small - Small popover
|
|
28
|
+
* @attr {String} medium - Medium popover
|
|
29
|
+
* @attr {String} large - Large popover
|
|
30
|
+
* @attr {String} width - The width of popover
|
|
31
|
+
* @attr {String} position - The position top, right, bottom or left
|
|
32
|
+
* @attr {Boolean} auto - to let the component choose the position
|
|
33
|
+
*
|
|
34
|
+
* @cssprop {Color} [--gv-popover--bgc=var(--gv-theme-neutral-color-lighter, #fafafa)] - Background color
|
|
35
|
+
* @cssprop {Color} [--gv-popover--c=var(--gv-theme-font-color-dark, #262626)] - Color
|
|
36
|
+
* @cssprop {Color} [--gv-popover--bdc=var(--gv-theme-neutral-color, #f5f5f5)] - Border color
|
|
37
|
+
* @cssprop {Length} [--gv-popover--p=0.5rem] - Padding
|
|
38
|
+
*/
|
|
39
|
+
export class GvPopover extends LitElement {
|
|
40
|
+
static get properties() {
|
|
41
|
+
return {
|
|
42
|
+
event: { type: String },
|
|
43
|
+
delay: { type: Number },
|
|
44
|
+
arrow: { type: Boolean, reflect: true },
|
|
45
|
+
small: { type: Boolean, reflect: true },
|
|
46
|
+
medium: { type: Boolean, reflect: true },
|
|
47
|
+
large: { type: Boolean, reflect: true },
|
|
48
|
+
width: { type: String },
|
|
49
|
+
position: { type: String, reflect: true },
|
|
50
|
+
auto: { type: Boolean },
|
|
51
|
+
_opened: { type: Boolean, attribute: false },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
static get styles() {
|
|
55
|
+
return [
|
|
56
|
+
// language=CSS
|
|
57
|
+
css `
|
|
58
|
+
:host {
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
display: inline-block;
|
|
62
|
+
position: relative;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.popover {
|
|
66
|
+
--bgc: var(--gv-popover--bgc, var(--gv-theme-neutral-color-lighter, #fafafa));
|
|
67
|
+
color: var(--gv-popover--c, var(--gv-theme-font-color-dark, #262626));
|
|
68
|
+
position: absolute;
|
|
69
|
+
background-color: var(--bgc);
|
|
70
|
+
padding: var(--gv-popover--p, 0.5rem);
|
|
71
|
+
border-radius: 4px;
|
|
72
|
+
z-index: 1000;
|
|
73
|
+
margin: 0 auto;
|
|
74
|
+
text-align: center;
|
|
75
|
+
width: auto;
|
|
76
|
+
box-sizing: content-box;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
:host([position='bottom']) .popover {
|
|
80
|
+
top: calc(100% + 0.4rem);
|
|
81
|
+
transform: translateX(-50%);
|
|
82
|
+
left: 50%;
|
|
83
|
+
box-shadow: 1px 0 0 0 var(--gv-theme-neutral-color, #f5f5f5), 0 2px 3px var(--gv-theme-neutral-color-dark, #bfbfbf);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host([position='bottom'][arrow]) .popover {
|
|
87
|
+
top: calc(100% + 0.4rem + 10px);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
:host([position='bottom'][arrow]) .arrow {
|
|
91
|
+
top: calc(100% - 8px);
|
|
92
|
+
transform: translateX(-50%);
|
|
93
|
+
left: 50%;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:host([position='top']) .popover {
|
|
97
|
+
bottom: calc(100% + 0.4rem);
|
|
98
|
+
transform: translateX(-50%);
|
|
99
|
+
left: 50%;
|
|
100
|
+
box-shadow: 1px 0 0 0 var(--gv-theme-neutral-color, #f5f5f5), 0 -2px 3px var(--gv-theme-neutral-color-dark, #bfbfbf);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:host([position='top'][arrow]) .popover {
|
|
104
|
+
bottom: calc(100% + 0.4rem + 10px);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([position='top'][arrow]) .arrow {
|
|
108
|
+
bottom: calc(100% - 8px);
|
|
109
|
+
transform: translateX(-50%) rotate(180deg);
|
|
110
|
+
left: 50%;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:host([position='left']) .popover {
|
|
114
|
+
top: 50%;
|
|
115
|
+
transform: translateY(-50%);
|
|
116
|
+
right: calc(100% + 0.4rem);
|
|
117
|
+
box-shadow: -1px 0 0 0 var(--gv-theme-neutral-color, #f5f5f5), -1px 2px 3px var(--gv-theme-neutral-color-dark, #bfbfbf);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
:host([position='left'][arrow]) .popover {
|
|
121
|
+
right: calc(100% + 0.4rem + 10px);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
:host([position='left'][arrow]) .arrow {
|
|
125
|
+
top: 50%;
|
|
126
|
+
transform: translateY(-50%) rotate(90deg);
|
|
127
|
+
right: calc(100% - 8px);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
:host([position='right']) .popover {
|
|
131
|
+
top: 50%;
|
|
132
|
+
transform: translateY(-50%);
|
|
133
|
+
left: calc(100% + 0.4rem);
|
|
134
|
+
box-shadow: 1px 0 0 1px var(--gv-theme-neutral-color, #f5f5f5), 1px 1px 1px var(--gv-theme-neutral-color-dark, #bfbfbf);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
:host([position='right'][arrow]) .popover {
|
|
138
|
+
left: calc(100% + 0.4rem + 10px);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
:host([position='right'][arrow]) .arrow {
|
|
142
|
+
left: calc(100% - 8px);
|
|
143
|
+
top: 50%;
|
|
144
|
+
transform: translateY(-50%) rotate(-90deg);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.inline .popover {
|
|
148
|
+
white-space: nowrap;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
:host([small]) .popover {
|
|
152
|
+
width: 200px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:host([medium]) .popover {
|
|
156
|
+
width: 350px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
:host([large]) .popover {
|
|
160
|
+
width: 500px;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.content {
|
|
164
|
+
width: 100%;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.popover,
|
|
168
|
+
.arrow {
|
|
169
|
+
opacity: 0;
|
|
170
|
+
visibility: hidden;
|
|
171
|
+
transition: opacity 0.3s ease-in-out;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.open .popover,
|
|
175
|
+
.open .arrow {
|
|
176
|
+
display: block;
|
|
177
|
+
opacity: 1;
|
|
178
|
+
visibility: visible;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.close .popover,
|
|
182
|
+
.close .arrow {
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.arrow {
|
|
186
|
+
width: 25px;
|
|
187
|
+
height: 25px;
|
|
188
|
+
z-index: 101;
|
|
189
|
+
position: absolute;
|
|
190
|
+
overflow: hidden;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.arrow:after {
|
|
194
|
+
content: '';
|
|
195
|
+
position: absolute;
|
|
196
|
+
width: 12px;
|
|
197
|
+
height: 12px;
|
|
198
|
+
background: var(--gv-popover--bgc, var(--gv-theme-neutral-color-lighter, #fafafa));
|
|
199
|
+
transform: rotate(45deg);
|
|
200
|
+
top: 19px;
|
|
201
|
+
left: 6px;
|
|
202
|
+
border: 1px solid var(--gv-popover--bdc, var(--gv-theme-neutral-color, #f5f5f5));
|
|
203
|
+
}
|
|
204
|
+
`,
|
|
205
|
+
];
|
|
206
|
+
}
|
|
207
|
+
constructor() {
|
|
208
|
+
super();
|
|
209
|
+
this.event = 'mouseover';
|
|
210
|
+
this._closeHandler = this._close.bind(this);
|
|
211
|
+
this.delay = 0;
|
|
212
|
+
this.arrow = false;
|
|
213
|
+
this.position = 'bottom';
|
|
214
|
+
this.auto = false;
|
|
215
|
+
}
|
|
216
|
+
_open(e) {
|
|
217
|
+
if (this.event === 'click') {
|
|
218
|
+
window.removeEventListener(this.event, this._closeHandler);
|
|
219
|
+
}
|
|
220
|
+
this._opened = true;
|
|
221
|
+
if (this.event === 'click') {
|
|
222
|
+
setTimeout(() => window.addEventListener(this.event, this._closeHandler));
|
|
223
|
+
}
|
|
224
|
+
if (this.delay > 0) {
|
|
225
|
+
setTimeout(() => this._close({}), this.delay);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
close() {
|
|
229
|
+
this._close({});
|
|
230
|
+
}
|
|
231
|
+
_close(e) {
|
|
232
|
+
if (this._opened && (e.target !== this.firstElementChild || this.event !== 'click')) {
|
|
233
|
+
const openElement = this.shadowRoot.querySelector('.open');
|
|
234
|
+
openElement.classList.add('close');
|
|
235
|
+
setTimeout(() => {
|
|
236
|
+
openElement.classList.remove('close');
|
|
237
|
+
this._opened = false;
|
|
238
|
+
}, 200);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
render() {
|
|
242
|
+
const inline = this.width == null && !this.small && !this.medium && !this.large;
|
|
243
|
+
const classes = { open: this._opened, content: true, inline };
|
|
244
|
+
return html ` <div class="${classMap(classes)}">
|
|
245
|
+
<slot></slot>
|
|
246
|
+
${this.arrow ? html `<div class="arrow"></div>` : ''}
|
|
247
|
+
<div class="popover">${this.renderContent()}</div>
|
|
248
|
+
</div>`;
|
|
249
|
+
}
|
|
250
|
+
renderContent() {
|
|
251
|
+
return html `<slot name="popover"></slot>`;
|
|
252
|
+
}
|
|
253
|
+
firstUpdated(_changedProperties) {
|
|
254
|
+
setTimeout(() => {
|
|
255
|
+
this.addEventListener(this.event, this._open.bind(this));
|
|
256
|
+
if (this.event.startsWith('mouse') && this.delay === 0) {
|
|
257
|
+
this.addEventListener('mouseleave', this._close.bind(this));
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
_getContentSize() {
|
|
262
|
+
const popover = this.shadowRoot.querySelector('.popover');
|
|
263
|
+
return {
|
|
264
|
+
width: popover.offsetWidth,
|
|
265
|
+
height: popover.offsetHeight,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
_getPositionPadding() {
|
|
269
|
+
return 10;
|
|
270
|
+
}
|
|
271
|
+
_getCenterPosition() {
|
|
272
|
+
return {
|
|
273
|
+
x: this.target.x + this.target.width / 2 + window.scrollX,
|
|
274
|
+
y: this.target.y + this.target.height / 2 + window.scrollY,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
_updatePosition() {
|
|
278
|
+
if (this.position != null && this.auto) {
|
|
279
|
+
const popover = this.shadowRoot.querySelector('.popover');
|
|
280
|
+
if (popover) {
|
|
281
|
+
this.target = this.firstElementChild.getBoundingClientRect();
|
|
282
|
+
if ((this.position === 'top' && !this._hasTopSpace()) ||
|
|
283
|
+
(this.position === 'bottom' && !this._hasBottomSpace()) ||
|
|
284
|
+
(this.position === 'left' && !this._hasLeftSpace()) ||
|
|
285
|
+
(this.position === 'right' && !this._hasRightSpace())) {
|
|
286
|
+
const index = [this._hasTopSpace(), this._hasRightSpace(), this._hasBottomSpace(), this._hasLeftSpace()].indexOf(true);
|
|
287
|
+
if (index > -1) {
|
|
288
|
+
this.position = ['top', 'right', 'bottom', 'left'][index];
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
_getMaxX() {
|
|
295
|
+
return window.innerWidth - this._getPositionPadding();
|
|
296
|
+
}
|
|
297
|
+
_getMaxY() {
|
|
298
|
+
return window.innerHeight - this._getPositionPadding();
|
|
299
|
+
}
|
|
300
|
+
_hasBottomSpace() {
|
|
301
|
+
const y = this.target.y + this.target.height + this._getContentSize().height + this._getPositionPadding();
|
|
302
|
+
return y <= this._getMaxY();
|
|
303
|
+
}
|
|
304
|
+
_hasRightSpace() {
|
|
305
|
+
const y = this.target.x + this.target.width + this._getContentSize().width + this._getPositionPadding();
|
|
306
|
+
return y <= this._getMaxX();
|
|
307
|
+
}
|
|
308
|
+
_hasTopSpace() {
|
|
309
|
+
const y = this.target.y - this._getContentSize().height - this._getPositionPadding();
|
|
310
|
+
return y >= this._getPositionPadding();
|
|
311
|
+
}
|
|
312
|
+
_hasLeftSpace() {
|
|
313
|
+
const y = this.target.x - this._getContentSize().width - this._getPositionPadding();
|
|
314
|
+
return y >= this._getPositionPadding();
|
|
315
|
+
}
|
|
316
|
+
updated(props) {
|
|
317
|
+
if (props.has('width')) {
|
|
318
|
+
this.shadowRoot.querySelector('.popover').style.setProperty('width', this.width);
|
|
319
|
+
}
|
|
320
|
+
this._updatePosition();
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
window.customElements.define('gv-popover', GvPopover);
|
|
@@ -1 +1,203 @@
|
|
|
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 { classMap } from 'lit/directives/class-map';
|
|
18
|
+
import { dispatchCustomEvent } from '../lib/events';
|
|
19
|
+
import { i18n } from '../lib/i18n';
|
|
20
|
+
import { ItemResource } from '../mixins/item-resource';
|
|
21
|
+
import { getTitle, getDescription, getVersion, getOwner } from '../lib/item';
|
|
22
|
+
import { truncate } from '../lib/utils';
|
|
23
|
+
import '../atoms/gv-image';
|
|
24
|
+
import '../atoms/gv-button';
|
|
25
|
+
import '../molecules/gv-rating';
|
|
26
|
+
import '../molecules/gv-metrics';
|
|
27
|
+
/**
|
|
28
|
+
* Promote component
|
|
29
|
+
*
|
|
30
|
+
* ## Details
|
|
31
|
+
* * has @theme facet
|
|
32
|
+
*
|
|
33
|
+
* @fires gv-promote:click - When click on button for view item
|
|
34
|
+
* @fires gv-tag:click - When one of the label is clicked
|
|
35
|
+
*
|
|
36
|
+
* @attr {Promise<any>} item - an item.
|
|
37
|
+
*
|
|
38
|
+
* @cssprop {Color} [--gv-promote-image--bgc=var(--gv-theme-color-light, #86c3d0)] - Image background color
|
|
39
|
+
* @cssprop {Color} [--gv-promote--bgc=var(--gv-theme-neutral-color-lightest, #ffffff)] - Background color
|
|
40
|
+
* @cssprop {Length} [--gv-promote-image--h=300px] - Image height
|
|
41
|
+
* @cssprop {Length} [--gv-promote-image--w=300px] - Image width
|
|
42
|
+
* @cssprop {Length} [--gv-promote-button--p=19px 80px] - Button padding
|
|
43
|
+
* @cssprop {Length} [--gv-promote-button--fz=var(--gv-theme-font-size-l, 16px)] - Button font size
|
|
44
|
+
*/
|
|
45
|
+
export class GvPromote extends ItemResource(LitElement) {
|
|
46
|
+
static get properties() {
|
|
47
|
+
return {
|
|
48
|
+
...super.properties,
|
|
49
|
+
limit: { type: Number },
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static get styles() {
|
|
53
|
+
return [
|
|
54
|
+
...super.styles,
|
|
55
|
+
// language=CSS
|
|
56
|
+
css `
|
|
57
|
+
:host {
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
display: inline-block;
|
|
60
|
+
margin: 0.2rem;
|
|
61
|
+
vertical-align: middle;
|
|
62
|
+
--gv-button--p: var(--gv-promote-button--p, 19px 80px);
|
|
63
|
+
--gv-button--fz: var(--gv-promote-button--fz, var(--gv-theme-font-size-l, 16px));
|
|
64
|
+
--gv-preview-button: 'none';
|
|
65
|
+
width: 100%;
|
|
66
|
+
--gv-icon--s: 20px;
|
|
67
|
+
--gv-rating--s: 20px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
gv-identity-picture {
|
|
71
|
+
height: var(--gv-promote-image--h, 300px);
|
|
72
|
+
width: var(--gv-promote-image--w, 300px);
|
|
73
|
+
--gv-image--of: contain;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.container {
|
|
77
|
+
display: flex;
|
|
78
|
+
min-height: 420px;
|
|
79
|
+
max-height: 420px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.image {
|
|
83
|
+
background-color: var(--gv-promote-image--bgc, var(--gv-theme-color-light, #86c3d0));
|
|
84
|
+
min-height: 0;
|
|
85
|
+
min-width: 0;
|
|
86
|
+
width: 480px;
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
border-radius: 4px 0 0 4px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.title {
|
|
94
|
+
text-transform: capitalize;
|
|
95
|
+
min-height: 32px;
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.title h2 {
|
|
101
|
+
font-size: var(--gv-theme-font-size-xl, 26px);
|
|
102
|
+
flex: 1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.title .version {
|
|
106
|
+
font-size: var(--gv-theme-font-size-s, 12px);
|
|
107
|
+
color: var(--gv-theme-neutral-color-dark, #d9d9d9);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.owner {
|
|
111
|
+
--gv-icon--c: var(--gv-theme-neutral-color-dark, #bfbfbf);
|
|
112
|
+
--gv-icon--s: 16px;
|
|
113
|
+
color: var(--gv-theme-neutral-color-dark, #bfbfbf);
|
|
114
|
+
display: flex;
|
|
115
|
+
padding-bottom: 2px;
|
|
116
|
+
margin-top: -8px;
|
|
117
|
+
line-height: initial;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.content {
|
|
121
|
+
flex: 1;
|
|
122
|
+
padding: 1.5rem;
|
|
123
|
+
background-color: var(--gv-promote--bgc, var(--gv-theme-neutral-color-lightest, #ffffff));
|
|
124
|
+
color: var(--gv-theme-font-color-dark, #262626);
|
|
125
|
+
font-size: var(--gv-theme-font-size-l, 16px);
|
|
126
|
+
line-height: 24px;
|
|
127
|
+
border-radius: 0 4px 4px 0;
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.description {
|
|
133
|
+
margin: 24px 0px;
|
|
134
|
+
flex-grow: 1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.description-large {
|
|
138
|
+
text-align: justify;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.infos {
|
|
142
|
+
display: flex;
|
|
143
|
+
justify-content: flex-end;
|
|
144
|
+
margin: 0.5rem 0.2rem;
|
|
145
|
+
align-items: center;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
gv-metrics {
|
|
149
|
+
display: flex;
|
|
150
|
+
height: 100%;
|
|
151
|
+
justify-content: flex-end;
|
|
152
|
+
align-items: stretch;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.labels {
|
|
156
|
+
text-align: right;
|
|
157
|
+
}
|
|
158
|
+
`,
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
_onClick() {
|
|
162
|
+
dispatchCustomEvent(this, 'click', { data: this._item, href: this.href });
|
|
163
|
+
}
|
|
164
|
+
render() {
|
|
165
|
+
if (this._invisible) {
|
|
166
|
+
return '';
|
|
167
|
+
}
|
|
168
|
+
const owner = getOwner(this._item);
|
|
169
|
+
return html `<div class="container">
|
|
170
|
+
<div class="${classMap({ skeleton: this._skeleton, image: true })}">${this._renderImage()}</div>
|
|
171
|
+
<div class="content">
|
|
172
|
+
${this._error && !this._skeleton
|
|
173
|
+
? html `<p class="description error">${i18n('gv-promote.error')}</p>`
|
|
174
|
+
: html `
|
|
175
|
+
${this._empty && !this._skeleton
|
|
176
|
+
? html `<p class="description empty">${i18n('gv-promote.empty')}</p>`
|
|
177
|
+
: html ` <div class=${classMap({ skeleton: this._skeleton, title: true })}>
|
|
178
|
+
<h2>${getTitle(this._item)}</h2>
|
|
179
|
+
<span class="version">${getVersion(this._item)}</span>
|
|
180
|
+
</div>
|
|
181
|
+
${owner != null && owner.trim().length > 0
|
|
182
|
+
? html `<div class="owner"><gv-icon shape="general:user" size="8px"></gv-icon>${owner}</div>`
|
|
183
|
+
: ''}
|
|
184
|
+
<p
|
|
185
|
+
class=${classMap({
|
|
186
|
+
skeleton: this._skeleton,
|
|
187
|
+
description: true,
|
|
188
|
+
'description-large': getDescription(this._item).split(' ').length > 10,
|
|
189
|
+
})}
|
|
190
|
+
>
|
|
191
|
+
${truncate(getDescription(this._item), this.limit)}
|
|
192
|
+
</p>
|
|
193
|
+
<div class=${classMap({ skeleton: this._skeleton, infos: true })}>${this._renderMetricsWithRating()}</div>
|
|
194
|
+
<div class="labels">${this._renderLabels(true)}</div>
|
|
195
|
+
<gv-button ?skeleton=${this._skeleton} .href="${this.href}" @click="${this._onClick}"
|
|
196
|
+
>${i18n('gv-promote.view')}</gv-button
|
|
197
|
+
>`}
|
|
198
|
+
`}
|
|
199
|
+
</div>
|
|
200
|
+
</div>`;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
window.customElements.define('gv-promote', GvPromote);
|