@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.
Files changed (183) hide show
  1. package/package.json +5 -13
  2. package/src/atoms/gv-autocomplete.js +422 -1
  3. package/src/atoms/gv-button.js +397 -1
  4. package/src/atoms/gv-checkbox.js +178 -1
  5. package/src/atoms/gv-date-picker-calendar.js +812 -1
  6. package/src/atoms/gv-date-picker-cell.js +174 -1
  7. package/src/atoms/gv-date-picker.js +638 -1
  8. package/src/atoms/gv-file-upload.js +348 -1
  9. package/src/atoms/gv-icon.js +93 -1
  10. package/src/atoms/gv-image.js +135 -1
  11. package/src/atoms/gv-input-message.js +78 -1
  12. package/src/atoms/gv-input.js +508 -1
  13. package/src/atoms/gv-link.js +204 -1
  14. package/src/atoms/gv-message.js +133 -1
  15. package/src/atoms/gv-metric.js +112 -1
  16. package/src/atoms/gv-relative-time.js +143 -1
  17. package/src/atoms/gv-select-native.js +363 -1
  18. package/src/atoms/gv-select.js +413 -1
  19. package/src/atoms/gv-spinner.js +54 -1
  20. package/src/atoms/gv-state.js +125 -1
  21. package/src/atoms/gv-switch.js +235 -1
  22. package/src/atoms/gv-tag.js +162 -1
  23. package/src/atoms/gv-text.js +160 -1
  24. package/src/charts/gv-chart-bar.js +101 -1
  25. package/src/charts/gv-chart-gauge.js +92 -1
  26. package/src/charts/gv-chart-histogram.js +78 -1
  27. package/src/charts/gv-chart-line.js +218 -1
  28. package/src/charts/gv-chart-map.js +111 -1
  29. package/src/charts/gv-chart-pie.js +89 -1
  30. package/src/index.js +77 -1
  31. package/src/lib/cron-expression.js +176 -1
  32. package/src/lib/date.js +43 -1
  33. package/src/lib/events.js +26 -1
  34. package/src/lib/http-client-schema-form.js +67 -1
  35. package/src/lib/http.js +237 -1
  36. package/src/lib/i18n.js +93 -1
  37. package/src/lib/item.js +110 -1
  38. package/src/lib/properties.js +171 -1
  39. package/src/lib/schema-form.js +39 -1
  40. package/src/lib/studio.js +144 -1
  41. package/src/lib/style.js +39 -1
  42. package/src/lib/text-format.js +65 -1
  43. package/src/lib/theme.js +60 -1
  44. package/src/lib/utils.js +106 -1
  45. package/src/mixins/chart-element.js +153 -1
  46. package/src/mixins/input-element.js +136 -1
  47. package/src/mixins/item-resource.js +102 -1
  48. package/src/mixins/keyboard-element.js +62 -1
  49. package/src/mixins/update-after-browser.js +30 -1
  50. package/src/mixins/with-resize-observer.js +62 -1
  51. package/src/mixins/with-skeleton-attribute.js +109 -1
  52. package/src/molecules/gv-card-full.js +209 -1
  53. package/src/molecules/gv-card-list.js +101 -1
  54. package/src/molecules/gv-card.js +130 -1
  55. package/src/molecules/gv-category-list.js +56 -1
  56. package/src/molecules/gv-category.js +163 -1
  57. package/src/molecules/gv-code.js +334 -1
  58. package/src/molecules/gv-confirm.js +175 -1
  59. package/src/molecules/gv-cron-editor.js +685 -1
  60. package/src/molecules/gv-dropdown-menu.js +108 -1
  61. package/src/molecules/gv-expandable.js +116 -1
  62. package/src/molecules/gv-expression-language.js +263 -1
  63. package/src/molecules/gv-identity-picture.js +139 -1
  64. package/src/molecules/gv-list.js +214 -1
  65. package/src/molecules/gv-metrics.js +147 -1
  66. package/src/molecules/gv-modal.js +203 -1
  67. package/src/molecules/gv-nav.js +180 -1
  68. package/src/molecules/gv-option.js +230 -1
  69. package/src/molecules/gv-plans.js +400 -1
  70. package/src/molecules/gv-popover.js +323 -1
  71. package/src/molecules/gv-promote.js +203 -1
  72. package/src/molecules/gv-rating-list.js +341 -1
  73. package/src/molecules/gv-rating.js +234 -1
  74. package/src/molecules/gv-row-expandable.js +42 -1
  75. package/src/molecules/gv-row.js +205 -1
  76. package/src/molecules/gv-stats.js +110 -1
  77. package/src/molecules/gv-stepper.js +274 -1
  78. package/src/molecules/gv-table.js +644 -1
  79. package/src/molecules/gv-tree.js +238 -1
  80. package/src/organisms/gv-documentation.js +205 -1
  81. package/src/organisms/gv-header.js +276 -1
  82. package/src/organisms/gv-http-client.js +258 -1
  83. package/src/organisms/gv-menu.js +258 -1
  84. package/src/organisms/gv-newsletter-subscription.js +258 -1
  85. package/src/organisms/gv-pagination.js +179 -1
  86. package/src/organisms/gv-properties.js +860 -1
  87. package/src/organisms/gv-resizable-views.js +371 -1
  88. package/src/organisms/gv-resources.js +496 -1
  89. package/src/organisms/gv-schema-form-array.js +237 -1
  90. package/src/organisms/gv-schema-form-control-object.js +141 -1
  91. package/src/organisms/gv-schema-form-control.js +419 -1
  92. package/src/organisms/gv-schema-form.js +700 -1
  93. package/src/organisms/gv-tabs.js +201 -1
  94. package/src/organisms/gv-user-menu.js +298 -1
  95. package/src/organisms/gv-vertical-menu.js +119 -1
  96. package/src/policy-studio/gv-flow-step.js +443 -1
  97. package/src/policy-studio/gv-flow.js +595 -1
  98. package/src/policy-studio/gv-policy-studio-menu.js +689 -1
  99. package/src/policy-studio/gv-policy-studio.js +1712 -1
  100. package/src/styles/empty.js +35 -1
  101. package/src/styles/input.js +262 -1
  102. package/src/styles/link.js +31 -1
  103. package/src/styles/shapes.js +17 -1
  104. package/src/styles/skeleton.js +52 -1
  105. package/src/styles/zoom.js +39 -1
  106. package/src/theme/gv-theme.js +197 -1
  107. package/wc/gv-autocomplete.js +1 -1
  108. package/wc/gv-button.js +1 -1
  109. package/wc/gv-card-full.js +1 -1
  110. package/wc/gv-card-list.js +1 -1
  111. package/wc/gv-card.js +1 -1
  112. package/wc/gv-category-list.js +1 -1
  113. package/wc/gv-category.js +1 -1
  114. package/wc/gv-chart-bar.js +1 -1
  115. package/wc/gv-chart-gauge.js +1 -1
  116. package/wc/gv-chart-histogram.js +1 -1
  117. package/wc/gv-chart-line.js +1 -1
  118. package/wc/gv-chart-map.js +1 -1
  119. package/wc/gv-chart-pie.js +1 -1
  120. package/wc/gv-checkbox.js +1 -1
  121. package/wc/gv-code.js +1 -1
  122. package/wc/gv-confirm.js +1 -1
  123. package/wc/gv-cron-editor.js +1 -1
  124. package/wc/gv-date-picker-calendar.js +1 -1
  125. package/wc/gv-date-picker-cell.js +1 -1
  126. package/wc/gv-date-picker.js +1 -1
  127. package/wc/gv-documentation.js +1 -1
  128. package/wc/gv-dropdown-menu.js +1 -1
  129. package/wc/gv-expandable.js +1 -1
  130. package/wc/gv-expression-language.js +1 -1
  131. package/wc/gv-file-upload.js +1 -1
  132. package/wc/gv-flow-step.js +1 -1
  133. package/wc/gv-flow.js +1 -1
  134. package/wc/gv-header.js +1 -1
  135. package/wc/gv-http-client.js +1 -1
  136. package/wc/gv-icon.js +1 -1
  137. package/wc/gv-identity-picture.js +1 -1
  138. package/wc/gv-image.js +1 -1
  139. package/wc/gv-input-message.js +1 -1
  140. package/wc/gv-input.js +1 -1
  141. package/wc/gv-link.js +1 -1
  142. package/wc/gv-list.js +1 -1
  143. package/wc/gv-menu.js +1 -1
  144. package/wc/gv-message.js +1 -1
  145. package/wc/gv-metric.js +1 -1
  146. package/wc/gv-metrics.js +1 -1
  147. package/wc/gv-modal.js +1 -1
  148. package/wc/gv-nav.js +1 -1
  149. package/wc/gv-newsletter-subscription.js +1 -1
  150. package/wc/gv-option.js +1 -1
  151. package/wc/gv-pagination.js +1 -1
  152. package/wc/gv-plans.js +1 -1
  153. package/wc/gv-policy-studio-menu.js +1 -1
  154. package/wc/gv-policy-studio.js +1 -1
  155. package/wc/gv-popover.js +1 -1
  156. package/wc/gv-promote.js +1 -1
  157. package/wc/gv-properties.js +1 -1
  158. package/wc/gv-rating-list.js +1 -1
  159. package/wc/gv-rating.js +1 -1
  160. package/wc/gv-relative-time.js +1 -1
  161. package/wc/gv-resizable-views.js +1 -1
  162. package/wc/gv-resources.js +1 -1
  163. package/wc/gv-row-expandable.js +1 -1
  164. package/wc/gv-row.js +1 -1
  165. package/wc/gv-schema-form-array.js +1 -1
  166. package/wc/gv-schema-form-control-object.js +1 -1
  167. package/wc/gv-schema-form-control.js +1 -1
  168. package/wc/gv-schema-form.js +1 -1
  169. package/wc/gv-select-native.js +1 -1
  170. package/wc/gv-select.js +1 -1
  171. package/wc/gv-spinner.js +1 -1
  172. package/wc/gv-state.js +1 -1
  173. package/wc/gv-stats.js +1 -1
  174. package/wc/gv-stepper.js +1 -1
  175. package/wc/gv-switch.js +1 -1
  176. package/wc/gv-table.js +1 -1
  177. package/wc/gv-tabs.js +1 -1
  178. package/wc/gv-tag.js +1 -1
  179. package/wc/gv-text.js +1 -1
  180. package/wc/gv-theme.js +1 -1
  181. package/wc/gv-tree.js +1 -1
  182. package/wc/gv-user-menu.js +1 -1
  183. package/wc/gv-vertical-menu.js +1 -1
@@ -1 +1,201 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvTabs=void 0;const t=require("lit");require("../molecules/gv-option");const e=require("../lib/events");class i extends t.LitElement{static get properties(){return{options:{type:Array},_options:{type:Array,attribute:!1},value:{type:String,reflect:!0},validator:{type:Function},disabled:{type:Boolean},small:{type:Boolean},truncate:{type:Boolean}}}static get styles(){return[t.css`:host{box-sizing:border-box}::slotted([slot=content]){opacity:0;box-sizing:border-box;transition:opacity 350ms ease-in-out;visibility:hidden;position:absolute;left:-9999px;top:-9999px}::slotted([slot=content].current){opacity:1;visibility:visible;position:relative;left:auto;top:auto}.header{display:flex;border-bottom:1px solid #d9d9d9;box-sizing:border-box}.title{flex:1;display:flex;align-items:center}.actions{display:flex;align-items:center}.tabs{flex:1;display:flex;justify-content:flex-end;--gv-option--bdrs:0}:host([small]) .tabs{flex-direction:column}:host([small]) gv-option{align-self:flex-end}gv-option{margin:var(--gv-tabs-options--m,0)}::slotted(gv-button){padding-bottom:2px}`]}_getContent(){return this.shadowRoot.querySelector('slot[name="content"]').assignedNodes()}firstUpdated(){null==this.value&&null!=this.options&&this.options.length>0&&(this.value=this.options[0].id)}set options(t){t&&Array.isArray(t)&&(this._options=t.map((t=>"string"==typeof t?{id:t,title:t}:"object"==typeof t&&null==t.title?{id:t.id,title:t.id}:t)))}get options(){return this._options}updated(){const t=this._getContent();if(t.forEach((t=>t.classList.remove("current"))),this.value){const t=this.querySelector(`#${this.value}`);t&&t.classList.add("current")}else t[0].classList.add("current")}_changeTab(t,i,s){t.classList.remove("current"),i.classList.add("current"),this.value=s,(0,e.dispatchCustomEvent)(this,"change",{value:s,from:t.id,to:i.id})}_onClick({detail:t}){if(!this.disabled){const e=this._getContent().find((t=>t.classList.contains("current"))),i=this.querySelector(`#${t.id}`);this.shadowRoot.querySelector("gv-option").value=e.id,this.validator?this.validator({from:e.id,to:i.id}).then((()=>{this._changeTab(e,i,t.id)})).catch((()=>{})):this._changeTab(e,i,t.id)}}get _contextualOptions(){return this.truncate?this.options.map((t=>{if(this.value!==t.id){const e=t.label||t.title;return{...t,label:e.substring(0,1)}}return t})):this.options}render(){return t.html`<div><div class="header"><div class="tabs"><slot name="title" class="title"></slot><gv-option small .options="${this._contextualOptions}" @gv-option:select="${this._onClick}" .value="${this.value}"></gv-option></div></div><slot name="content"></slot></div>`}}exports.GvTabs=i,window.customElements.define("gv-tabs",i);
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
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvUserMenu=void 0;const e=require("lit");require("../molecules/gv-nav");const t=require("lit/directives/repeat"),s=require("lit/directives/class-map"),r=require("../lib/utils");class i extends e.LitElement{static get properties(){return{avatar:{type:String},routes:{type:Array},_routes:{type:Array,attribute:!1},_isClosed:{type:Boolean,attribute:!1},username:{type:String}}}static get styles(){return[e.css`:host{--bdc:var(--gv-user-menu--bdc, lightgrey);--c:var(--gv-user-menu--c, var(--gv-theme-font-color-dark, #262626));--bgc:var(--gv-user-menu--bgc, transparent);--list-bgc:var(--gv-user-menu-list--bgc, var(--gv-theme-neutral-color-lightest, #ffffff));--hover-bgc:var(--gv-user-menu-hover--bgc, var(--gv-theme-color-light, #86c3d0));--gv-link-active--c:var(--gv-user-menu-hover--c, var(--gv-theme-color-dark, #28444f));--gv-icon--c:var(--gv-user-menu-icon--c, var(--gv-theme-neutral-color-darkest, #000000));--gv-icon--s:var(--gv-user-menu-icon--s, 16px);--gv-link-a--ph:var(--gv-user-menu-link-a--ph, 0px);--gv-link--ta:var(--gv-user-menu-link--ta, right);user-select:none}.user-menu{list-style:none;margin:0;padding:0;display:inline-block;position:relative}.user-menu__title{background-color:var(--bgc);border-left:1px solid var(--bdc);color:var(--c);cursor:pointer;line-height:40px;padding:8px 24px;display:inline-flex;align-items:center;justify-content:space-between;min-width:175px;text-shadow:var(--gv-user-menu--tsh,none)}::slotted(*){height:40px;width:40px}.user-menu__title.no-user{padding:5px 24px}.user-menu__title gv-link{--gv-link-a--ph:0;--gv-link-a--pv:0}.user-menu__title span{flex:1;text-align:center;margin:0 .4rem}.user-menu__title>gv-icon{transition:all .3s ease 0s}.user-menu__list{position:absolute;background-color:var(--list-bgc);list-style:none;padding:0;transition:all .3s ease 0s;width:100%}.user-menu__list__item{border-left:1px solid var(--bdc);display:flex;align-items:center;transition:all .5s ease;padding:2px 30px}.user-menu__list__item:last-child{border-bottom:1px solid var(--bdc)}.user-menu__list__item:hover{background-color:var(--hover-bgc);border-left:1px dotted var(--bdc);font-weight:500}gv-link{margin:0;display:flex;width:100%}.separator{border-top:1px solid var(--bdc)}.active{background-color:var(--gv-theme-neutral-color-dark,#d9d9d9);font-weight:700}.user-menu__list{visibility:visible;opacity:1;transform:translateY(0);z-index:100;transition-delay:0s,0s,.2s}.user-menu__list__group{border-top:1px solid var(--bdc);background-color:var(--gv-theme-neutral-color-light,#efefef);padding-left:0}.user-menu__list__group__title{font-size:small;color:var(--gv-theme-color-darker,#383e3f);border-left:1px solid var(--bdc);padding-left:10px}.closed .user-menu__list{visibility:hidden;opacity:0;transform:translateY(-2em);z-index:-1}gv-icon{transform:rotate(0)}.closed gv-icon{transform:rotate(-180deg)}`]}constructor(){super(),this._isClosed=!0}_onClick(e){e.preventDefault(),this._isClosed=!this._isClosed}_onMouseLeave(){this._isClosed=!0}_onSelect(){this._isClosed=!0}_hasOneItem(){return null==this.username&&this._routes&&1===this._routes.length}set routes(e){e?Promise.resolve(e).then((e=>{e?Promise.all(e).then((e=>{(0,r.isSameRoutes)(this._routes,e)||(this._routes=e.filter((e=>null!=e)))})):this._routes=null})):this._routes=null}_renderFirstItem(){if(this._routes){if(this.username)return e.html`<li class="user-menu__title" @click="${this._onClick}"><div><slot></slot></div><span>${this.username}</span><gv-icon shape="design:triangle"></gv-icon></li>`;if(this._hasOneItem()){const t=this._routes[0];return e.html`<li class="user-menu__title no-user" @click="${this._onClick}"><gv-link .icon="${t.icon}" .path="${t.path}" .title="${t.title}" @click="${this._onSelect}"></gv-link></li>`}}return e.html``}render(){const r={closed:this._isClosed};return this._routes?e.html`<nav class="${(0,s.classMap)(r)}"><ul class="user-menu" @mouseleave="${this._onMouseLeave}">${this._renderFirstItem()}<li class="user-menu__content"><ul class="user-menu__list">${(0,t.repeat)(this._routes,(e=>e),((t,s)=>e.html`${this._hasOneItem()?e.html``:this._renderItem(t)}`))}</ul></li></ul></nav>`:e.html``}_renderItem(s){return s.routes?e.html`<ul class="user-menu__list__group"><span class="user-menu__list__group__title">${s.title}</span> ${(0,t.repeat)(s.routes,(e=>e),((t,s)=>e.html`${this._renderItem(t)}`))}</ul>`:e.html`<li class="user-menu__list__item ${s.separator?"separator":""} ${s.active?"active":""}" style="${s.style}"><gv-link .icon="${s.icon}" .path="${s.path}" .title="${s.title}" .target="${s.target}" @click="${this._onSelect}"></gv-link></li>`}}exports.GvUserMenu=i,window.customElements.define("gv-user-menu",i);
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
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvVerticalMenu=void 0;const e=require("lit");require("../molecules/gv-nav"),require("../atoms/gv-image");const t=require("../lib/utils");class i extends e.LitElement{static get properties(){return{routes:{type:Array},_routes:{type:Array,attribute:!1},logo:{type:String}}}static get styles(){return[e.css`:host{--gv-link--c:var(--gv-menu--c, var(--gv-theme-font-color-light, #ffffff));--gv-link-active--c:var(--gv-menu--c, var(--gv-theme-font-color-light, #ffffff));--gv-link--bgc:var(--gv-menu-link--bgc, transparent);--gv-link-active--bgc:var(--gv-menu-link-active--bgc, transparent);--gv-link-active--bdw:var(--gv-menu-link-active--bdw, 0 0 0 4px);--gv-link-active--bdc:var(--gv-menu-link-active--bdc, var(--gv-theme-color-light, #86c3d0));--gv-link-active--bds:var(--gv-menu-link-active--bds, solid);--pr:var(--gv-theme-layout--pr, 4rem);--pl:var(--gv-theme-layout--pl, 4rem);box-sizing:border-box;display:block;font-size:var(--gv-theme-font-size-s,16px);width:var(--gv-theme-layout-menu-w,200px)}.menu-container{display:flex;flex-direction:column;justify-content:space-between;background-color:var(--gv-menu--bgc,var(--gv-theme-color-dark,#28444f));color:var(--gv-menu--c,var(--gv-theme-font-color-light,#fff))}gv-image{height:200px;width:200px}gv-nav{transition:width 250ms ease-in-out;display:flex;flex-direction:column;justify-content:space-between;line-height:20px;vertical-align:middle;width:100%;font-size:16px}`]}constructor(){super(),this._routes=[]}set routes(e){e?Promise.resolve(e).then((e=>{e?Promise.all(e).then((e=>{(0,t.isSameRoutes)(this._routes,e)||(this._routes=e.filter((e=>null!=e)))})):this._routes=null})):this._routes=null}render(){return e.html`<div class="menu-container">${this.logo?e.html`<gv-image .src="${this.logo}"></gv-image>`:""}<div class="nav-container"><gv-nav .routes="${this._routes}" vertical></gv-nav></div></div>`}}exports.GvVerticalMenu=i,window.customElements.define("gv-vertical-menu",i);
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);