@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,363 @@
|
|
|
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 { classMap } from 'lit/directives/class-map';
|
|
17
|
+
import { ifDefined } from 'lit/directives/if-defined';
|
|
18
|
+
import { repeat } from 'lit/directives/repeat';
|
|
19
|
+
import { css, html, LitElement } from 'lit';
|
|
20
|
+
import { skeleton } from '../styles/skeleton';
|
|
21
|
+
import { link } from '../styles/link';
|
|
22
|
+
import { input } from '../styles/input';
|
|
23
|
+
import { dispatchCustomEvent } from '../lib/events';
|
|
24
|
+
import { InputElement } from '../mixins/input-element';
|
|
25
|
+
import { i18n } from '../lib/i18n';
|
|
26
|
+
/**
|
|
27
|
+
* A select native component.
|
|
28
|
+
*
|
|
29
|
+
* @fires gv-select:select - Event when user select a value (deprecated, use gv-select:input)
|
|
30
|
+
* @fires gv-select:input - Event when user select a value
|
|
31
|
+
*
|
|
32
|
+
* @attr {Boolean} disabled - same as native select element `disabled` attribute
|
|
33
|
+
* @attr {Boolean} required - same as native select element `required` attribute
|
|
34
|
+
* @attr {Boolean} skeleton - enable skeleton screen UI pattern (loading hint)
|
|
35
|
+
* @attr {Array} options - the options of the select
|
|
36
|
+
* @attr {String | Array} value - the value of the select
|
|
37
|
+
* @attr {String} label - label of the select
|
|
38
|
+
* @attr {String} title - title of the select
|
|
39
|
+
* @attr {String} name - name of the select
|
|
40
|
+
* @attr {String} placeholder - an example value to display in the select when empty
|
|
41
|
+
* @attr {String} description - a description
|
|
42
|
+
* @attr {Boolean} multiple - enable multiple selection
|
|
43
|
+
*
|
|
44
|
+
* @cssprop {Color} [--gv-select--bgc=var(--gv-theme-neutral-color-lightest, #ffffff)] - Background color
|
|
45
|
+
* @cssprop {Color} [--gv-select--bdc=var(--gv-theme-neutral-color-dark, #d9d9d9)] - Border color
|
|
46
|
+
* @cssprop {Color} [--gv-select--c=var(--gv-theme-font-color-dark, #262626)] - Color
|
|
47
|
+
* @cssprop {Color} [--gv-select-hover--bgc=var(--gv-theme-color-light, #86c3d0)] - Hover background color
|
|
48
|
+
* @cssprop {Color} [--gv-select-selected--bgc=var(--gv-theme-neutral-color-light, #efefef)] - Selected background color
|
|
49
|
+
*/
|
|
50
|
+
export class GvSelectNative extends InputElement(LitElement) {
|
|
51
|
+
static get properties() {
|
|
52
|
+
return {
|
|
53
|
+
...super.properties,
|
|
54
|
+
options: { type: Array },
|
|
55
|
+
_options: { type: Array, attribute: false },
|
|
56
|
+
large: { type: Boolean },
|
|
57
|
+
medium: { type: Boolean },
|
|
58
|
+
small: { type: Boolean },
|
|
59
|
+
value: { type: String | Array },
|
|
60
|
+
label: { type: String },
|
|
61
|
+
title: { type: String },
|
|
62
|
+
name: { type: String },
|
|
63
|
+
placeholder: { type: String },
|
|
64
|
+
description: { type: String },
|
|
65
|
+
multiple: { type: Boolean, reflect: true },
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
static get styles() {
|
|
69
|
+
return [
|
|
70
|
+
...super.styles,
|
|
71
|
+
skeleton,
|
|
72
|
+
input,
|
|
73
|
+
link,
|
|
74
|
+
// language=CSS
|
|
75
|
+
css `
|
|
76
|
+
.box {
|
|
77
|
+
--bdc: var(--gv-select--bdc, var(--gv-theme-neutral-color-dark, #d9d9d9));
|
|
78
|
+
--c: var(--gv-select--c, var(--gv-theme-font-color-dark, #262626));
|
|
79
|
+
--bgc: var(--gv-select--bgc, var(--gv-theme-neutral-color-lightest, #ffffff));
|
|
80
|
+
--bgc-list: var(--gv-select--list-bgc, var(--gv-select--bgc, var(--gv-theme-neutral-color-lightest, #ffffff)));
|
|
81
|
+
--hover-bgc: var(--gv-select-hover--bgc, var(--gv-theme-color-light, #86c3d0));
|
|
82
|
+
--selected-bgc: var(--gv-select-selected--bgc, var(--gv-theme-neutral-color-light, #efefef));
|
|
83
|
+
position: relative;
|
|
84
|
+
color: var(--c);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:host([readonly]) div,
|
|
88
|
+
:host([readonly]) input,
|
|
89
|
+
:host([readonly]) input:read-only:hover {
|
|
90
|
+
user-select: auto;
|
|
91
|
+
cursor: text;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
input:read-only:hover {
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
label {
|
|
99
|
+
color: var(--c);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
select,
|
|
103
|
+
.multiple .input {
|
|
104
|
+
background-image: linear-gradient(45deg, transparent 50%, var(--c) 50%), linear-gradient(135deg, var(--c) 50%, transparent 50%),
|
|
105
|
+
linear-gradient(to right, #ccc, #ccc);
|
|
106
|
+
background-position: calc(100% - 17px) calc(1em + 2px), calc(100% - 12px) calc(1em + 2px), calc(100% - 2.5em) 0.5em;
|
|
107
|
+
background-size: 5px 5px, 5px 5px, 1px 1.5em;
|
|
108
|
+
background-repeat: no-repeat;
|
|
109
|
+
-webkit-appearance: none;
|
|
110
|
+
appearance: none;
|
|
111
|
+
background-color: var(--bgc);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.multiple .input {
|
|
115
|
+
padding-right: 35px;
|
|
116
|
+
text-overflow: ellipsis;
|
|
117
|
+
white-space: nowrap;
|
|
118
|
+
overflow: hidden;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.multiple gv-icon {
|
|
122
|
+
display: none;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.multiple.not-empty :not(.show) .input {
|
|
126
|
+
background-image: none, linear-gradient(155deg, var(--c) 0%, transparent 0%), linear-gradient(to right, #ccc, #ccc);
|
|
127
|
+
}
|
|
128
|
+
.multiple.not-empty gv-icon {
|
|
129
|
+
display: block;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.small .multiple .input {
|
|
133
|
+
padding-right: 30px;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.small select,
|
|
137
|
+
.small.multiple .input {
|
|
138
|
+
background-position: calc(100% - 16px) calc(0.8em), calc(100% - 11px) calc(0.8em), calc(100% - 2.5em) 0.5em;
|
|
139
|
+
background-size: 5px 5px, 5px 5px, 1px 1em;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.multiple select {
|
|
143
|
+
opacity: 0;
|
|
144
|
+
position: absolute;
|
|
145
|
+
left: 0;
|
|
146
|
+
top: 0;
|
|
147
|
+
max-height: var(--input-medium--h);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.multiple .show {
|
|
151
|
+
min-height: 75px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.multiple .show select {
|
|
155
|
+
opacity: 1;
|
|
156
|
+
z-index: 1000;
|
|
157
|
+
max-height: 300px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
gv-icon {
|
|
161
|
+
--gv-icon--s: 19px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.medium gv-icon {
|
|
165
|
+
--gv-icon--s: 14px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.small gv-icon {
|
|
169
|
+
--gv-icon--s: 11px;
|
|
170
|
+
}
|
|
171
|
+
`,
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
constructor() {
|
|
175
|
+
super();
|
|
176
|
+
this._options = [{ label: '', value: '', disabled: false, title: null }];
|
|
177
|
+
}
|
|
178
|
+
getInputElement() {
|
|
179
|
+
return this.shadowRoot.querySelector('select');
|
|
180
|
+
}
|
|
181
|
+
async firstUpdated(changedProperties) {
|
|
182
|
+
super.firstUpdated(changedProperties);
|
|
183
|
+
// Give the browser a chance to paint
|
|
184
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
185
|
+
const input = this.getInputElement();
|
|
186
|
+
if (input) {
|
|
187
|
+
input.addEventListener('input', this._onInput.bind(this));
|
|
188
|
+
if (this.multiple) {
|
|
189
|
+
input.addEventListener('mousedown', this._onEnter.bind(this));
|
|
190
|
+
input.addEventListener('focus', this._onEnter.bind(this));
|
|
191
|
+
input.addEventListener('mouseleave', this._onLeave.bind(this));
|
|
192
|
+
input.addEventListener('blur', this._onLeave.bind(this));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
willUpdate(changedProperties) {
|
|
197
|
+
if (changedProperties.has('value')) {
|
|
198
|
+
this.updateState(this.value);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
updateState(value) {
|
|
202
|
+
super.updateState(value);
|
|
203
|
+
if (value && this._options && this.valid) {
|
|
204
|
+
if (this.multiple) {
|
|
205
|
+
if (this.required) {
|
|
206
|
+
this.setValidity(value.length === 0, 'field is required');
|
|
207
|
+
}
|
|
208
|
+
if (value.length > 0 && this.valid) {
|
|
209
|
+
const possibleValues = this._options.map((o) => o.value);
|
|
210
|
+
this.setValidity(!value.some((v) => possibleValues.includes(v)), 'value is not included in the possible values');
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
this.setValidity(this.required && this._options.find((option) => option.value === value) == null, 'value is not included in the possible values');
|
|
215
|
+
}
|
|
216
|
+
this.invalid = !this.valid;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
_onEnter(e) {
|
|
220
|
+
const input = this.getInputElement();
|
|
221
|
+
if (!input.parentNode.classList.contains('show')) {
|
|
222
|
+
e.stopPropagation();
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
input.parentNode.classList.add('show');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
_onLeave() {
|
|
228
|
+
this.getInputElement().parentNode.classList.remove('show');
|
|
229
|
+
}
|
|
230
|
+
_onInput(e) {
|
|
231
|
+
e.stopPropagation();
|
|
232
|
+
if (this.multiple) {
|
|
233
|
+
const options = this.getInputElement().querySelectorAll('option:checked');
|
|
234
|
+
this.value = Array.from(options).map((o) => o.value);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
this.value = e.target.value;
|
|
238
|
+
}
|
|
239
|
+
this.updateState(this.value);
|
|
240
|
+
dispatchCustomEvent(this, 'select', this.value);
|
|
241
|
+
dispatchCustomEvent(this, 'input', this.value);
|
|
242
|
+
this.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
|
|
243
|
+
}
|
|
244
|
+
_onClear() {
|
|
245
|
+
Array.from(this.getInputElement().querySelectorAll('option:checked')).forEach((option) => option.removeAttribute('checked'));
|
|
246
|
+
this.value = [];
|
|
247
|
+
dispatchCustomEvent(this, 'select', this.value);
|
|
248
|
+
dispatchCustomEvent(this, 'input', this.value);
|
|
249
|
+
this.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
|
|
250
|
+
}
|
|
251
|
+
set options(options) {
|
|
252
|
+
if (options) {
|
|
253
|
+
this._options = options.map((option) => {
|
|
254
|
+
if (typeof option !== 'object') {
|
|
255
|
+
return { value: option, label: option };
|
|
256
|
+
}
|
|
257
|
+
else if (!option.label) {
|
|
258
|
+
return { value: option.value, label: option.value };
|
|
259
|
+
}
|
|
260
|
+
return option;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
selectedLabel() {
|
|
265
|
+
if (this.value != null) {
|
|
266
|
+
const elements = this._options.filter((o) => this.isSelected(o));
|
|
267
|
+
if (elements) {
|
|
268
|
+
return elements.map((e) => e.label).join(', ');
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return '';
|
|
272
|
+
}
|
|
273
|
+
renderSelect() {
|
|
274
|
+
const selectedLabel = this.selectedLabel();
|
|
275
|
+
if (this.readonly) {
|
|
276
|
+
return html `
|
|
277
|
+
<input
|
|
278
|
+
id=${this._id}
|
|
279
|
+
type="text"
|
|
280
|
+
.name=${ifDefined(this.name)}
|
|
281
|
+
.title=${ifDefined(selectedLabel || this.title || this.label)}
|
|
282
|
+
.required=${this.required}
|
|
283
|
+
aria-required=${!!this.required}
|
|
284
|
+
.placeholder=${ifDefined(this.placeholder)}
|
|
285
|
+
.value=${selectedLabel}
|
|
286
|
+
readonly="readonly"
|
|
287
|
+
/>
|
|
288
|
+
`;
|
|
289
|
+
}
|
|
290
|
+
else if (this.multiple) {
|
|
291
|
+
const height = this._options ? this._options.length * (this.small ? 20 : 25) : 50;
|
|
292
|
+
return html `
|
|
293
|
+
<input
|
|
294
|
+
class="input"
|
|
295
|
+
type="text"
|
|
296
|
+
.name=${ifDefined(this.name)}
|
|
297
|
+
.title=${ifDefined(selectedLabel || this.title || this.label)}
|
|
298
|
+
.required=${this.required}
|
|
299
|
+
aria-required=${!!this.required}
|
|
300
|
+
.placeholder=${ifDefined(this.placeholder)}
|
|
301
|
+
.value=${selectedLabel}
|
|
302
|
+
readonly="readonly"
|
|
303
|
+
/>
|
|
304
|
+
<select
|
|
305
|
+
class="input"
|
|
306
|
+
id=${this._id}
|
|
307
|
+
.name=${ifDefined(this.name)}
|
|
308
|
+
.title=${ifDefined(selectedLabel || this.title || this.label)}
|
|
309
|
+
.required=${this.required}
|
|
310
|
+
aria-required=${!!this.required}
|
|
311
|
+
?disabled=${this.disabled || this.skeleton}
|
|
312
|
+
.placeholder=${ifDefined(this.placeholder)}
|
|
313
|
+
multiple
|
|
314
|
+
.size="${this._options.length}"
|
|
315
|
+
style="height: ${height}px"
|
|
316
|
+
>
|
|
317
|
+
${this._options &&
|
|
318
|
+
repeat(this._options, (option) => option, (option) => html ` <option value="${option.value || ''}" ?selected="${this.isSelected(option)}">${option.label}</option> `)}
|
|
319
|
+
</select>
|
|
320
|
+
<div class="box-icon box-icon-clear">
|
|
321
|
+
<gv-icon class="link" shape="code:error" title="${i18n('gv-input.clear')}" @click="${this._onClear}"></gv-icon>
|
|
322
|
+
</div>
|
|
323
|
+
`;
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
return html `<select
|
|
327
|
+
class="input"
|
|
328
|
+
id=${this._id}
|
|
329
|
+
.name=${ifDefined(this.name)}
|
|
330
|
+
.title=${ifDefined(selectedLabel || this.title || this.label)}
|
|
331
|
+
.required=${this.required}
|
|
332
|
+
aria-required=${!!this.required}
|
|
333
|
+
?disabled=${this.disabled || this.skeleton}
|
|
334
|
+
.placeholder=${ifDefined(this.placeholder)}
|
|
335
|
+
>
|
|
336
|
+
${this._options &&
|
|
337
|
+
repeat(this._options, (option) => option, (option) => html ` <option value="${option.value || ''}" ?selected="${this.isSelected(option)}">${option.label}</option>`)}
|
|
338
|
+
</select>`;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
render() {
|
|
342
|
+
const classes = {
|
|
343
|
+
box: true,
|
|
344
|
+
large: this.large,
|
|
345
|
+
medium: this.medium || (!this.large && !this.small),
|
|
346
|
+
small: this.small,
|
|
347
|
+
skeleton: this.skeleton,
|
|
348
|
+
required: this.required,
|
|
349
|
+
multiple: this.multiple,
|
|
350
|
+
'not-empty': this._options && this.multiple && this.value && this.value.length > 0,
|
|
351
|
+
};
|
|
352
|
+
return html `
|
|
353
|
+
<div class="${classMap(classes)}">
|
|
354
|
+
<div class="box-input">${this.renderLabel()} ${this.renderSelect()}</div>
|
|
355
|
+
</div>
|
|
356
|
+
${this.description != null ? html `<div class="description" .innerHTML="${this.description}"></div>` : ''}
|
|
357
|
+
`;
|
|
358
|
+
}
|
|
359
|
+
isSelected(option) {
|
|
360
|
+
return this.multiple ? this.value && this.value.includes(option.value) : '' + this.value === '' + option.value;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
window.customElements.define('gv-select-native', GvSelectNative);
|