@gravitee/ui-components 3.25.3-typescript-ad6021f → 3.25.3-typescript-bfd8f67
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 -8
- package/src/atoms/gv-autocomplete.js +1 -461
- package/src/atoms/gv-button.js +1 -410
- package/src/atoms/gv-checkbox.js +1 -187
- package/src/atoms/gv-date-picker-calendar.js +1 -894
- package/src/atoms/gv-date-picker-cell.js +1 -190
- package/src/atoms/gv-date-picker.js +1 -671
- package/src/atoms/gv-file-upload.js +1 -367
- package/src/atoms/gv-icon.js +1 -103
- package/src/atoms/gv-image.js +1 -144
- package/src/atoms/gv-input-message.js +1 -84
- package/src/atoms/gv-input.js +1 -561
- package/src/atoms/gv-link.js +1 -210
- package/src/atoms/gv-message.js +1 -128
- package/src/atoms/gv-metric.js +1 -117
- package/src/atoms/gv-relative-time.js +1 -156
- package/src/atoms/gv-select-native.js +1 -388
- package/src/atoms/gv-select.js +1 -437
- package/src/atoms/gv-spinner.js +1 -57
- package/src/atoms/gv-state.js +1 -130
- package/src/atoms/gv-switch.js +1 -243
- package/src/atoms/gv-tag.js +1 -168
- package/src/atoms/gv-text.js +1 -168
- package/src/charts/gv-chart-bar.js +1 -103
- package/src/charts/gv-chart-gauge.js +1 -100
- package/src/charts/gv-chart-histogram.js +1 -83
- package/src/charts/gv-chart-line.js +1 -224
- package/src/charts/gv-chart-map.js +1 -112
- package/src/charts/gv-chart-pie.js +1 -91
- package/src/index.js +1 -77
- package/src/lib/cron-expression.js +1 -205
- package/src/lib/date.js +1 -44
- package/src/lib/events.js +1 -26
- package/src/lib/http-client-schema-form.js +1 -67
- package/src/lib/http.js +1 -237
- package/src/lib/i18n.js +1 -103
- package/src/lib/item.js +1 -118
- package/src/lib/properties.js +1 -189
- package/src/lib/schema-form.js +1 -44
- package/src/lib/studio.js +1 -141
- package/src/lib/style.js +1 -41
- package/src/lib/text-format.js +1 -69
- package/src/lib/theme.js +1 -63
- package/src/lib/utils.js +1 -111
- package/src/mixins/chart-element.js +1 -165
- package/src/mixins/input-element.js +1 -144
- package/src/mixins/item-resource.js +1 -120
- package/src/mixins/keyboard-element.js +1 -69
- package/src/mixins/update-after-browser.js +1 -30
- package/src/mixins/with-resize-observer.js +1 -68
- package/src/mixins/with-skeleton-attribute.js +1 -112
- package/src/molecules/gv-card-full.js +1 -218
- package/src/molecules/gv-card-list.js +1 -113
- package/src/molecules/gv-card.js +1 -133
- package/src/molecules/gv-category-list.js +1 -60
- package/src/molecules/gv-category.js +1 -170
- package/src/molecules/gv-code.js +1 -359
- package/src/molecules/gv-confirm.js +1 -188
- package/src/molecules/gv-cron-editor.js +1 -710
- package/src/molecules/gv-dropdown-menu.js +1 -116
- package/src/molecules/gv-expandable.js +1 -122
- package/src/molecules/gv-expression-language.js +1 -270
- package/src/molecules/gv-identity-picture.js +1 -148
- package/src/molecules/gv-list.js +1 -227
- package/src/molecules/gv-metrics.js +1 -162
- package/src/molecules/gv-modal.js +1 -213
- package/src/molecules/gv-nav.js +1 -196
- package/src/molecules/gv-option.js +1 -242
- package/src/molecules/gv-plans.js +1 -429
- package/src/molecules/gv-popover.js +1 -351
- package/src/molecules/gv-promote.js +1 -209
- package/src/molecules/gv-rating-list.js +1 -365
- package/src/molecules/gv-rating.js +1 -253
- package/src/molecules/gv-row-expandable.js +1 -45
- package/src/molecules/gv-row.js +1 -210
- package/src/molecules/gv-stats.js +1 -121
- package/src/molecules/gv-stepper.js +1 -288
- package/src/molecules/gv-table.js +1 -685
- package/src/molecules/gv-tree.js +1 -250
- package/src/organisms/gv-documentation.js +1 -215
- package/src/organisms/gv-header.js +1 -288
- package/src/organisms/gv-http-client.js +1 -275
- package/src/organisms/gv-menu.js +1 -263
- package/src/organisms/gv-newsletter-subscription.js +1 -271
- package/src/organisms/gv-pagination.js +1 -198
- package/src/organisms/gv-properties.js +1 -920
- package/src/organisms/gv-resizable-views.js +1 -396
- package/src/organisms/gv-resources.js +1 -535
- package/src/organisms/gv-schema-form-array.js +1 -250
- package/src/organisms/gv-schema-form-control-object.js +1 -154
- package/src/organisms/gv-schema-form-control.js +1 -443
- package/src/organisms/gv-schema-form.js +1 -751
- package/src/organisms/gv-tabs.js +1 -210
- package/src/organisms/gv-user-menu.js +1 -314
- package/src/organisms/gv-vertical-menu.js +1 -123
- package/src/policy-studio/gv-flow-step.js +1 -464
- package/src/policy-studio/gv-flow.js +1 -621
- package/src/policy-studio/gv-policy-studio-menu.js +1 -750
- package/src/policy-studio/gv-policy-studio.js +1 -1842
- package/src/styles/empty.js +1 -36
- package/src/styles/input.js +1 -263
- package/src/styles/link.js +1 -32
- package/src/styles/shapes.js +1 -17
- package/src/styles/skeleton.js +1 -53
- package/src/styles/zoom.js +1 -40
- package/src/theme/gv-theme.js +1 -203
- 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/CHANGELOG.md +0 -1292
- package/LICENSE.txt +0 -202
- package/README.md +0 -195
- package/src/.eslintrc.js +0 -19
- package/src/theme/definition.json +0 -1762
|
@@ -1,84 +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 '../atoms/gv-icon';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Input message component
|
|
21
|
-
*
|
|
22
|
-
* @attr {String} level - level of message ['info', 'error', 'warning']
|
|
23
|
-
*/
|
|
24
|
-
export class GvInputMessage extends LitElement {
|
|
25
|
-
static get properties() {
|
|
26
|
-
return {
|
|
27
|
-
level: { type: String },
|
|
28
|
-
_level: { type: String, attribute: false },
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
constructor() {
|
|
33
|
-
super();
|
|
34
|
-
this._level = 'warning';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
set level(level) {
|
|
38
|
-
if (['error', 'info', 'warning'].includes(level)) {
|
|
39
|
-
this._level = level;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
render() {
|
|
44
|
-
return html`<div class="box"><gv-icon class="${this._level}" shape="code:${this._level}"></gv-icon><slot></slot></div>`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static get styles() {
|
|
48
|
-
return [
|
|
49
|
-
// language=CSS
|
|
50
|
-
css`
|
|
51
|
-
:host {
|
|
52
|
-
box-sizing: border-box;
|
|
53
|
-
display: block;
|
|
54
|
-
margin: 0.2rem;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.box {
|
|
58
|
-
display: flex;
|
|
59
|
-
align-items: center;
|
|
60
|
-
white-space: normal;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
gv-icon {
|
|
64
|
-
margin: 0 0.2rem;
|
|
65
|
-
--gv-icon--s: 24px;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
gv-icon.warning {
|
|
69
|
-
--gv-icon-opacity--c: var(--gv-theme-color-warning, #ff9800);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
gv-icon.error {
|
|
73
|
-
--gv-icon-opacity--c: var(--gv-theme-color-error, #f44336);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
gv-icon.info {
|
|
77
|
-
--gv-icon-opacity--c: var(--gv-theme-color-info, #2196f3);
|
|
78
|
-
}
|
|
79
|
-
`,
|
|
80
|
-
];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
window.customElements.define('gv-input-message', GvInputMessage);
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvInputMessage=void 0;const e=require("lit");require("../atoms/gv-icon");class t extends e.LitElement{static get properties(){return{level:{type:String},_level:{type:String,attribute:!1}}}constructor(){super(),this._level="warning"}set level(e){["error","info","warning"].includes(e)&&(this._level=e)}render(){return e.html`<div class="box"><gv-icon class="${this._level}" shape="code:${this._level}"></gv-icon><slot></slot></div>`}static get styles(){return[e.css`:host{box-sizing:border-box;display:block;margin:.2rem}.box{display:flex;align-items:center;white-space:normal}gv-icon{margin:0 .2rem;--gv-icon--s:24px}gv-icon.warning{--gv-icon-opacity--c:var(--gv-theme-color-warning, #ff9800)}gv-icon.error{--gv-icon-opacity--c:var(--gv-theme-color-error, #f44336)}gv-icon.info{--gv-icon-opacity--c:var(--gv-theme-color-info, #2196f3)}`]}}exports.GvInputMessage=t,window.customElements.define("gv-input-message",t);
|
package/src/atoms/gv-input.js
CHANGED
|
@@ -1,561 +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
|
-
|
|
18
|
-
import { LitElement, html, css } from 'lit';
|
|
19
|
-
import { skeleton } from '../styles/skeleton';
|
|
20
|
-
import { input } from '../styles/input';
|
|
21
|
-
import { link } from '../styles/link';
|
|
22
|
-
import { dispatchCustomEvent } from '../lib/events';
|
|
23
|
-
import './gv-icon';
|
|
24
|
-
import '../molecules/gv-popover';
|
|
25
|
-
import { i18n } from '../lib/i18n';
|
|
26
|
-
import { InputElement } from '../mixins/input-element';
|
|
27
|
-
import { shapeClipboard, shapeCopied } from '../styles/shapes';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* ## Details
|
|
32
|
-
* * has @theme facet
|
|
33
|
-
*
|
|
34
|
-
* @fires gv-input:input - mirrors native input events with the `value` on `detail`
|
|
35
|
-
* @fires gv-input:clear - event when user clear a clearable input
|
|
36
|
-
*
|
|
37
|
-
* @attr {Boolean} disabled - same as native input element `disabled` attribute
|
|
38
|
-
* @attr {Boolean} required - same as native input element `required` attribute
|
|
39
|
-
* @attr {Boolean} skeleton - enable skeleton screen UI pattern (loading hint)
|
|
40
|
-
* @attr {String} value - the value of the input
|
|
41
|
-
* @attr {String} label - label of the input
|
|
42
|
-
* @attr {String} title - title of the input
|
|
43
|
-
* @attr {String} name - name of the input
|
|
44
|
-
* @attr {String} placeholder - an example value to display in the input when empty
|
|
45
|
-
* @attr {String} description - a description
|
|
46
|
-
* @attr {String} type - type of the input, can be text (Default), password, email, search, number, url.
|
|
47
|
-
* @attr {Boolean} clipboard - for readonly input with clipboard
|
|
48
|
-
* @attr {Boolean} large - for a large input
|
|
49
|
-
* @attr {Boolean} medium - for a medium input (Default)
|
|
50
|
-
* @attr {Boolean} small - for a small input
|
|
51
|
-
* @attr {String} icon - icon of the input
|
|
52
|
-
* @attr {String} icon-left - icon of the input to display at left
|
|
53
|
-
* @attr {Boolean} valid - if value is valid
|
|
54
|
-
* @attr {Boolean} invalid - if value is invalid
|
|
55
|
-
* @attr {Boolean} [loading=false] - true to display a loading icon
|
|
56
|
-
* @attr {Boolean} [autofocus=false] - true to put the focus on the input
|
|
57
|
-
* @attr {Boolean} [readonly=false] - true if field is readonly mode
|
|
58
|
-
* @attr {String} [autocomplete='off'] - standard autocomplete attribute
|
|
59
|
-
* @attr {Boolean} [clickable=false] - If true, icon has link style
|
|
60
|
-
* @attr {Boolean} [clearable=false] - If true, input can be clear with button
|
|
61
|
-
* @attr {Boolean} [no-submit=false] - If true, input cannot dispatch native submit event on enter key press to closest form
|
|
62
|
-
* @attr {String} [pattern=null] - Pattern for input validation. If type is url, default pattern is ^(http|https)://
|
|
63
|
-
*
|
|
64
|
-
* @cssprop {String} [--gv-input--bdc=var(--gv-theme-neutral-color, #F5F5F5)] - Border color
|
|
65
|
-
* @cssprop {Color} [--gv-input--bds=solid] - Border style
|
|
66
|
-
* @cssprop {Color} [--gv-input-icon--bgc=var(--gv-theme-neutral-color, #F5F5F5)] - Icon background color
|
|
67
|
-
*/
|
|
68
|
-
export class GvInput extends InputElement(LitElement) {
|
|
69
|
-
static get properties() {
|
|
70
|
-
return {
|
|
71
|
-
...super.properties,
|
|
72
|
-
type: { type: String, reflect: true },
|
|
73
|
-
large: { type: Boolean },
|
|
74
|
-
medium: { type: Boolean },
|
|
75
|
-
small: { type: Boolean },
|
|
76
|
-
icon: { type: String },
|
|
77
|
-
iconLeft: { type: String, attribute: 'icon-left' },
|
|
78
|
-
loading: { type: Boolean },
|
|
79
|
-
min: { type: Number },
|
|
80
|
-
max: { type: Number },
|
|
81
|
-
autocomplete: { type: String },
|
|
82
|
-
clipboard: { type: Boolean },
|
|
83
|
-
clickable: { type: Boolean },
|
|
84
|
-
clearable: { type: Boolean },
|
|
85
|
-
noSubmit: { type: Boolean, attribute: 'no-submit' },
|
|
86
|
-
pattern: { type: String, reflect: true },
|
|
87
|
-
description: { type: String },
|
|
88
|
-
_type: { type: String, attribute: false },
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
static get styles() {
|
|
93
|
-
return [
|
|
94
|
-
...super.styles,
|
|
95
|
-
skeleton,
|
|
96
|
-
input,
|
|
97
|
-
link,
|
|
98
|
-
// language=CSS
|
|
99
|
-
css`
|
|
100
|
-
.clickable input,
|
|
101
|
-
.clickable ::slotted(input) {
|
|
102
|
-
cursor: pointer;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.clickable input:hover,
|
|
106
|
-
.clickable ::slotted(input:hover) {
|
|
107
|
-
box-shadow: 0 1px 3px var(--gv-theme-neutral-color-dark, #bfbfbf);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
gv-icon {
|
|
111
|
-
--gv-icon--s: 22px;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.copied {
|
|
115
|
-
--gv-input--bdc: var(--gv-theme-color-success-light, #81c784);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.copied .box-icon gv-icon {
|
|
119
|
-
--gv-icon--c: var(--gv-theme-color-success-dark, #388e3c);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
div.box-icon gv-icon.loading,
|
|
123
|
-
.loading ::slotted(input) {
|
|
124
|
-
animation: spinner 1.6s linear infinite;
|
|
125
|
-
--gv-icon--s: 20px;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.loading.small gv-icon {
|
|
129
|
-
--gv-icon--s: 18px;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
@keyframes spinner {
|
|
133
|
-
to {
|
|
134
|
-
transform: rotate(360deg);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.clipboard input,
|
|
139
|
-
.clipboard ::slotted(input) {
|
|
140
|
-
cursor: copy;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.clipboard input:read-only:hover,
|
|
144
|
-
.clipboard ::slotted(input:read-only:hover) {
|
|
145
|
-
cursor: not-allowed;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.clipboard__popover {
|
|
149
|
-
--gv-popover--bgc: var(--gv-theme-color-darker, #383e3f);
|
|
150
|
-
--gv-popover--c: var(--gv-theme-font-color-light, #ffffff);
|
|
151
|
-
--gv-popover--p: 0rem 0.4rem 0rem 0.2rem;
|
|
152
|
-
font-size: 11px;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.clipboard__popover-content {
|
|
156
|
-
display: flex;
|
|
157
|
-
justify-content: center;
|
|
158
|
-
align-items: center;
|
|
159
|
-
--gv-icon--c: var(--gv-theme-font-color-light, #ffffff);
|
|
160
|
-
}
|
|
161
|
-
`,
|
|
162
|
-
];
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
static get shapeSearch() {
|
|
166
|
-
return 'general:search';
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
static get shapeClear() {
|
|
170
|
-
return 'code:error';
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
static get shapeInvisible() {
|
|
174
|
-
return 'general:invisible';
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
static get shapeVisible() {
|
|
178
|
-
return 'general:visible';
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
constructor() {
|
|
182
|
-
super();
|
|
183
|
-
this._type = 'text';
|
|
184
|
-
this._showPassword = false;
|
|
185
|
-
this.value = '';
|
|
186
|
-
this.autocomplete = 'off';
|
|
187
|
-
this.noSubmit = false;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
reset() {
|
|
191
|
-
this.value = '';
|
|
192
|
-
this.getInputElement().blur();
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
focus() {
|
|
196
|
-
this.getInputElement().focus();
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
getInputElement() {
|
|
200
|
-
return this._input || super.getInputElement();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
updated(changedProperties) {
|
|
204
|
-
if (changedProperties.has('_type')) {
|
|
205
|
-
this.getInputElement().type = this._type;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (changedProperties.has('autocomplete')) {
|
|
209
|
-
this.getInputElement().autocomplete = this.autocomplete;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (changedProperties.has('name') && this.name != null) {
|
|
213
|
-
this.getInputElement().name = this.name;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (changedProperties.has('required')) {
|
|
217
|
-
this.getInputElement().required = this.required;
|
|
218
|
-
this.getInputElement()['aria-required'] = !!this.required;
|
|
219
|
-
if (this.value == null || this.value.trim() === '') {
|
|
220
|
-
this.invalid = true;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (this.readonly) {
|
|
225
|
-
this.getInputElement().setAttribute('readonly', true);
|
|
226
|
-
} else {
|
|
227
|
-
this.getInputElement().removeAttribute('readonly');
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (changedProperties.has('label') || changedProperties.has('title')) {
|
|
231
|
-
const title = this.title || this.label;
|
|
232
|
-
if (title != null) {
|
|
233
|
-
this.getInputElement().title = title;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (changedProperties.has('label') && this.label) {
|
|
238
|
-
this.getInputElement()['aria-label'] = this.label;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (changedProperties.has('pattern')) {
|
|
242
|
-
this.getInputElement().pattern = this.pattern;
|
|
243
|
-
this._regexPattern = new RegExp(this.pattern);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (changedProperties.has('disabled') || changedProperties.has('skeleton')) {
|
|
247
|
-
this.getInputElement().disabled = this.disabled || this.skeleton;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (changedProperties.has('placeholder') && this.placeholder != null) {
|
|
251
|
-
this.getInputElement().placeholder = this.placeholder;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (changedProperties.has('value')) {
|
|
255
|
-
this.getInputElement().value = this.value;
|
|
256
|
-
this.updateState(this.value);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (changedProperties.has('min') && this.min != null) {
|
|
260
|
-
this.getInputElement().min = this.min;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (changedProperties.has('max') && this.max != null) {
|
|
264
|
-
this.getInputElement().max = this.max;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
_setClipboardIcon(shape) {
|
|
269
|
-
if (this.icon != null && this.icon !== shapeCopied && this.icon !== shapeClipboard) {
|
|
270
|
-
this.iconLeft = shape;
|
|
271
|
-
} else {
|
|
272
|
-
this.icon = shape;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
firstUpdated(changedProperties) {
|
|
277
|
-
super.firstUpdated(changedProperties);
|
|
278
|
-
|
|
279
|
-
this.catchSlot();
|
|
280
|
-
|
|
281
|
-
if (this.clipboard) {
|
|
282
|
-
import('clipboard-copy').then(
|
|
283
|
-
(mod) =>
|
|
284
|
-
(this.copy = () => {
|
|
285
|
-
const copy = mod.default;
|
|
286
|
-
copy(this.value);
|
|
287
|
-
this._copied = true;
|
|
288
|
-
this._setClipboardIcon(shapeCopied);
|
|
289
|
-
setTimeout(() => {
|
|
290
|
-
this._copied = false;
|
|
291
|
-
this._setClipboardIcon(shapeClipboard);
|
|
292
|
-
}, 1000);
|
|
293
|
-
}),
|
|
294
|
-
);
|
|
295
|
-
this._setClipboardIcon(shapeClipboard);
|
|
296
|
-
|
|
297
|
-
setTimeout(() => {
|
|
298
|
-
const clipboardPopover = this.shadowRoot.querySelector('.clipboard__popover');
|
|
299
|
-
clipboardPopover.addEventListener('click', (e) => {
|
|
300
|
-
e.preventDefault();
|
|
301
|
-
e.stopPropagation();
|
|
302
|
-
this.copy(this.value);
|
|
303
|
-
});
|
|
304
|
-
}, 0);
|
|
305
|
-
} else {
|
|
306
|
-
const clickableIcon = this.shadowRoot.querySelector('gv-icon.link');
|
|
307
|
-
if (clickableIcon) {
|
|
308
|
-
clickableIcon.addEventListener('click', this._onIconClick.bind(this));
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
this.getInputElement().id = this._id;
|
|
313
|
-
|
|
314
|
-
this.bindInputEvents();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
bindInputEvents() {
|
|
318
|
-
this.getInputElement().addEventListener('input', this._onInput.bind(this));
|
|
319
|
-
this.getInputElement().addEventListener('keyup', this._onKeyUp.bind(this));
|
|
320
|
-
this.getInputElement().addEventListener('keypress', this._onKeyPress.bind(this));
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
catchSlot() {
|
|
324
|
-
const defaultInputElement = this.getInputElement();
|
|
325
|
-
for (const node of this.childNodes) {
|
|
326
|
-
if (node.nodeType === 1) {
|
|
327
|
-
const child = node.nodeName.toLowerCase() === 'input' ? node : node.querySelector('input');
|
|
328
|
-
if (child) {
|
|
329
|
-
this._input = child;
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (this._input) {
|
|
335
|
-
defaultInputElement.remove();
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
updateState(value) {
|
|
340
|
-
super.updateState(value);
|
|
341
|
-
if (this.valid === true && !this.readonly) {
|
|
342
|
-
if (this._regexPattern) {
|
|
343
|
-
if (value != null && value.trim() !== '') {
|
|
344
|
-
const valid = value.match(this._regexPattern);
|
|
345
|
-
this.setValidity(valid == null, `field not respect the pattern ${this._regexPattern}`);
|
|
346
|
-
}
|
|
347
|
-
} else if (this._type === 'number' && value != null && (typeof value === 'number' || value.trim() !== '')) {
|
|
348
|
-
const _value = Number(value).valueOf();
|
|
349
|
-
if (isNaN(_value)) {
|
|
350
|
-
this.setValidity(true, `field is not number`);
|
|
351
|
-
} else if (this.min != null && this.min > _value) {
|
|
352
|
-
this.setValidity(true, `field is < ${this.min}`);
|
|
353
|
-
} else if (this.max != null && this.max < _value) {
|
|
354
|
-
this.setValidity(true, `field is > ${this.max}`);
|
|
355
|
-
} else {
|
|
356
|
-
this.setValidity(false);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
_onInput(e) {
|
|
363
|
-
this.updateState(e.target.value);
|
|
364
|
-
this.value = e.target.value;
|
|
365
|
-
dispatchCustomEvent(this, 'input', this.value);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
_onKeyPress(e) {
|
|
369
|
-
if (this._type === 'number') {
|
|
370
|
-
let key;
|
|
371
|
-
if (e.type === 'paste') {
|
|
372
|
-
key = e.clipboardData.getData('text/plain');
|
|
373
|
-
} else {
|
|
374
|
-
key = String.fromCharCode(e.keyCode);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
let regex = /[0-9]/;
|
|
378
|
-
if (this.min == null || this.min < 0) {
|
|
379
|
-
regex = /[0-9-]/;
|
|
380
|
-
}
|
|
381
|
-
if (!regex.test(key)) {
|
|
382
|
-
e.preventDefault();
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
_onKeyUp(e) {
|
|
388
|
-
if (e.keyCode === 13) {
|
|
389
|
-
if (!this.noSubmit) {
|
|
390
|
-
const form = this.closest('form');
|
|
391
|
-
if (form) {
|
|
392
|
-
form.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }));
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
dispatchCustomEvent(this, 'submit', this.value);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
get isClearable() {
|
|
400
|
-
return this.clearable && !this.disabled && !this.readonly && !this.loading && this.value != null && this.value !== '';
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
set type(value) {
|
|
404
|
-
if (['text', 'password', 'email', 'search', 'number', 'url'].includes(value)) {
|
|
405
|
-
this._type = value;
|
|
406
|
-
}
|
|
407
|
-
if (this._type === 'url') {
|
|
408
|
-
this.pattern = '(https?://.w*)(:\\d*)?\\/?(.*)';
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (this._type === 'email') {
|
|
412
|
-
this.pattern =
|
|
413
|
-
/^(([^<>()\\[\]\\.,;:\s@"]+(\.[^<>()\\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
if (this._type === 'search' && this.icon == null && this.iconLeft == null) {
|
|
417
|
-
this.icon = GvInput.shapeSearch;
|
|
418
|
-
this.clearable = true;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
if (this._type === 'password') {
|
|
422
|
-
this.icon = GvInput.shapeSearch;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
get type() {
|
|
427
|
-
return this._type;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
_onIconClick() {
|
|
431
|
-
dispatchCustomEvent(this, 'icon-click', this.value);
|
|
432
|
-
dispatchCustomEvent(this, 'submit', this.value);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
_onIconVisibleClick(e) {
|
|
436
|
-
if (this.isPassword) {
|
|
437
|
-
e.preventDefault();
|
|
438
|
-
e.stopPropagation();
|
|
439
|
-
this._showPassword = !this._showPassword;
|
|
440
|
-
this._type = this._showPassword ? 'text' : 'password';
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
get isPassword() {
|
|
445
|
-
return !this.disabled && (this._type === 'password' || (this._type === 'text' && this._showPassword));
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
get hasClickableIcon() {
|
|
449
|
-
return !this.disabled && !this.readonly && (this.clickable || this._type === 'search' || this.clipboard);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
get hasClipboard() {
|
|
453
|
-
return !this.disabled && this.clipboard;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
clear() {
|
|
457
|
-
this.focus();
|
|
458
|
-
this.value = '';
|
|
459
|
-
dispatchCustomEvent(this, 'clear', this.value);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
_renderClearIcon() {
|
|
463
|
-
if (this.isClearable) {
|
|
464
|
-
return html`<div class="box-icon box-icon-clear">
|
|
465
|
-
<gv-icon class="link" shape="code:error" title="${i18n('gv-input.clear')}" @click="${this.clear}"></gv-icon>
|
|
466
|
-
</div>`;
|
|
467
|
-
}
|
|
468
|
-
return '';
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
_shapePassword() {
|
|
472
|
-
return this._showPassword ? 'general:visible' : 'general:hidden';
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
_renderPasswordIcon() {
|
|
476
|
-
if (this.isPassword) {
|
|
477
|
-
const shape = this._shapePassword();
|
|
478
|
-
const title = this._showPassword ? 'Show' : 'Hide';
|
|
479
|
-
return html`<div class="box-icon">
|
|
480
|
-
<gv-icon class="link" shape="${shape}" title="${title}" @click="${this._onIconVisibleClick}"></gv-icon>
|
|
481
|
-
</div>`;
|
|
482
|
-
}
|
|
483
|
-
return '';
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
get hasBackground() {
|
|
487
|
-
return !this.loading;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
renderIcon() {
|
|
491
|
-
let shape = null;
|
|
492
|
-
if ((!this.isPassword && this.icon) || this.iconLeft) {
|
|
493
|
-
shape = (!this.isPassword && this.icon) || this.iconLeft;
|
|
494
|
-
}
|
|
495
|
-
if (this.loading) {
|
|
496
|
-
shape = 'navigation:waiting';
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
if (shape) {
|
|
500
|
-
const classes = {
|
|
501
|
-
'box-icon': true,
|
|
502
|
-
'box-icon-left': this.iconLeft != null || this.clearable,
|
|
503
|
-
'box-icon-bgc': this.hasBackground,
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
const iconClasses = {
|
|
507
|
-
link: this.hasClickableIcon,
|
|
508
|
-
loading: this.loading,
|
|
509
|
-
};
|
|
510
|
-
let title = '';
|
|
511
|
-
if (this._type === 'search') {
|
|
512
|
-
title = i18n('gv-input.search');
|
|
513
|
-
} else if (this.hasClipboard) {
|
|
514
|
-
title = i18n('gv-input.copy');
|
|
515
|
-
return html`<div class="${classMap(classes)}">
|
|
516
|
-
<gv-popover class="clipboard__popover" event="click" delay="750" .arrow="${false}">
|
|
517
|
-
<gv-icon class="${classMap(iconClasses)}" shape="${shape}" title="${title}"></gv-icon>
|
|
518
|
-
<div slot="popover" class="clipboard__popover-content">
|
|
519
|
-
<gv-icon shape="code:check"></gv-icon>
|
|
520
|
-
<div>Copied</div>
|
|
521
|
-
</div>
|
|
522
|
-
</gv-popover>
|
|
523
|
-
</div>`;
|
|
524
|
-
} else if (this.placeholder) {
|
|
525
|
-
title = this.placeholder;
|
|
526
|
-
}
|
|
527
|
-
return html`<div class="${classMap(classes)}">
|
|
528
|
-
<gv-icon class="${classMap(iconClasses)}" shape="${shape}" title="${title}"></gv-icon>
|
|
529
|
-
</div>`;
|
|
530
|
-
}
|
|
531
|
-
return '';
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
render() {
|
|
535
|
-
const classes = {
|
|
536
|
-
'box-input': true,
|
|
537
|
-
skeleton: this.skeleton,
|
|
538
|
-
large: this.large,
|
|
539
|
-
medium: this.medium || (!this.large && !this.small),
|
|
540
|
-
small: this.small,
|
|
541
|
-
icon: !!this.icon && !this.clearable,
|
|
542
|
-
clearable: this.clearable,
|
|
543
|
-
'icon-left': !!this.iconLeft || (!!this.icon && this.clearable),
|
|
544
|
-
clipboard: this.hasClipboard,
|
|
545
|
-
required: this.required,
|
|
546
|
-
copied: this.hasClipboard && this._copied,
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
return html`
|
|
550
|
-
<div class="${classMap(classes)}">
|
|
551
|
-
${this.renderLabel()}
|
|
552
|
-
<input />
|
|
553
|
-
<slot></slot>
|
|
554
|
-
${this._renderClearIcon()} ${this.renderIcon()} ${this._renderPasswordIcon()}
|
|
555
|
-
</div>
|
|
556
|
-
${this.description != null ? html`<div class="description" .innerHTML="${this.description}"></div>` : ''}
|
|
557
|
-
`;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
window.customElements.define('gv-input', GvInput);
|
|
1
|
+
var t=Object.create?function(t,e,i,s){void 0===s&&(s=i),Object.defineProperty(t,s,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,s){void 0===s&&(s=i),t[s]=e[i]},e=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e},i=function(i){if(i&&i.__esModule)return i;var s={};if(null!=i)for(var n in i)"default"!==n&&Object.prototype.hasOwnProperty.call(i,n)&&t(s,i,n);return e(s,i),s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvInput=void 0;const s=require("lit/directives/class-map"),n=require("lit"),l=require("../styles/skeleton"),a=require("../styles/input"),o=require("../styles/link"),r=require("../lib/events");require("./gv-icon"),require("../molecules/gv-popover");const h=require("../lib/i18n"),c=require("../mixins/input-element"),p=require("../styles/shapes");class u extends((0,c.InputElement)(n.LitElement)){static get properties(){return{...super.properties,type:{type:String,reflect:!0},large:{type:Boolean},medium:{type:Boolean},small:{type:Boolean},icon:{type:String},iconLeft:{type:String,attribute:"icon-left"},loading:{type:Boolean},min:{type:Number},max:{type:Number},autocomplete:{type:String},clipboard:{type:Boolean},clickable:{type:Boolean},clearable:{type:Boolean},noSubmit:{type:Boolean,attribute:"no-submit"},pattern:{type:String,reflect:!0},description:{type:String},_type:{type:String,attribute:!1}}}static get styles(){return[...super.styles,l.skeleton,a.input,o.link,n.css`.clickable ::slotted(input),.clickable input{cursor:pointer}.clickable ::slotted(input:hover),.clickable input:hover{box-shadow:0 1px 3px var(--gv-theme-neutral-color-dark,#bfbfbf)}gv-icon{--gv-icon--s:22px}.copied{--gv-input--bdc:var(--gv-theme-color-success-light, #81c784)}.copied .box-icon gv-icon{--gv-icon--c:var(--gv-theme-color-success-dark, #388e3c)}.loading ::slotted(input),div.box-icon gv-icon.loading{animation:spinner 1.6s linear infinite;--gv-icon--s:20px}.loading.small gv-icon{--gv-icon--s:18px}@keyframes spinner{to{transform:rotate(360deg)}}.clipboard ::slotted(input),.clipboard input{cursor:copy}.clipboard ::slotted(input:read-only:hover),.clipboard input:read-only:hover{cursor:not-allowed}.clipboard__popover{--gv-popover--bgc:var(--gv-theme-color-darker, #383e3f);--gv-popover--c:var(--gv-theme-font-color-light, #ffffff);--gv-popover--p:0rem 0.4rem 0rem 0.2rem;font-size:11px}.clipboard__popover-content{display:flex;justify-content:center;align-items:center;--gv-icon--c:var(--gv-theme-font-color-light, #ffffff)}`]}static get shapeSearch(){return"general:search"}static get shapeClear(){return"code:error"}static get shapeInvisible(){return"general:invisible"}static get shapeVisible(){return"general:visible"}constructor(){super(),this._type="text",this._showPassword=!1,this.value="",this.autocomplete="off",this.noSubmit=!1}reset(){this.value="",this.getInputElement().blur()}focus(){this.getInputElement().focus()}getInputElement(){return this._input||super.getInputElement()}updated(t){if(t.has("_type")&&(this.getInputElement().type=this._type),t.has("autocomplete")&&(this.getInputElement().autocomplete=this.autocomplete),t.has("name")&&null!=this.name&&(this.getInputElement().name=this.name),t.has("required")&&(this.getInputElement().required=this.required,this.getInputElement()["aria-required"]=!!this.required,null!=this.value&&""!==this.value.trim()||(this.invalid=!0)),this.readonly?this.getInputElement().setAttribute("readonly",!0):this.getInputElement().removeAttribute("readonly"),t.has("label")||t.has("title")){const t=this.title||this.label;null!=t&&(this.getInputElement().title=t)}t.has("label")&&this.label&&(this.getInputElement()["aria-label"]=this.label),t.has("pattern")&&(this.getInputElement().pattern=this.pattern,this._regexPattern=new RegExp(this.pattern)),(t.has("disabled")||t.has("skeleton"))&&(this.getInputElement().disabled=this.disabled||this.skeleton),t.has("placeholder")&&null!=this.placeholder&&(this.getInputElement().placeholder=this.placeholder),t.has("value")&&(this.getInputElement().value=this.value,this.updateState(this.value)),t.has("min")&&null!=this.min&&(this.getInputElement().min=this.min),t.has("max")&&null!=this.max&&(this.getInputElement().max=this.max)}_setClipboardIcon(t){null!=this.icon&&this.icon!==p.shapeCopied&&this.icon!==p.shapeClipboard?this.iconLeft=t:this.icon=t}firstUpdated(t){if(super.firstUpdated(t),this.catchSlot(),this.clipboard)Promise.resolve().then((()=>i(require("clipboard-copy")))).then((t=>this.copy=()=>{(0,t.default)(this.value),this._copied=!0,this._setClipboardIcon(p.shapeCopied),setTimeout((()=>{this._copied=!1,this._setClipboardIcon(p.shapeClipboard)}),1e3)})),this._setClipboardIcon(p.shapeClipboard),setTimeout((()=>{this.shadowRoot.querySelector(".clipboard__popover").addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),this.copy(this.value)}))}),0);else{const t=this.shadowRoot.querySelector("gv-icon.link");t&&t.addEventListener("click",this._onIconClick.bind(this))}this.getInputElement().id=this._id,this.bindInputEvents()}bindInputEvents(){this.getInputElement().addEventListener("input",this._onInput.bind(this)),this.getInputElement().addEventListener("keyup",this._onKeyUp.bind(this)),this.getInputElement().addEventListener("keypress",this._onKeyPress.bind(this))}catchSlot(){const t=this.getInputElement();for(const t of this.childNodes)if(1===t.nodeType){const e="input"===t.nodeName.toLowerCase()?t:t.querySelector("input");if(e){this._input=e;break}}this._input&&t.remove()}updateState(t){if(super.updateState(t),!0===this.valid&&!this.readonly)if(this._regexPattern){if(null!=t&&""!==t.trim()){const e=t.match(this._regexPattern);this.setValidity(null==e,`field not respect the pattern ${this._regexPattern}`)}}else if("number"===this._type&&null!=t&&("number"==typeof t||""!==t.trim())){const e=Number(t).valueOf();isNaN(e)?this.setValidity(!0,"field is not number"):null!=this.min&&this.min>e?this.setValidity(!0,`field is < ${this.min}`):null!=this.max&&this.max<e?this.setValidity(!0,`field is > ${this.max}`):this.setValidity(!1)}}_onInput(t){this.updateState(t.target.value),this.value=t.target.value,(0,r.dispatchCustomEvent)(this,"input",this.value)}_onKeyPress(t){if("number"===this._type){let e;e="paste"===t.type?t.clipboardData.getData("text/plain"):String.fromCharCode(t.keyCode);let i=/[0-9]/;(null==this.min||this.min<0)&&(i=/[0-9-]/),i.test(e)||t.preventDefault()}}_onKeyUp(t){if(13===t.keyCode){if(!this.noSubmit){const t=this.closest("form");t&&t.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))}(0,r.dispatchCustomEvent)(this,"submit",this.value)}}get isClearable(){return this.clearable&&!this.disabled&&!this.readonly&&!this.loading&&null!=this.value&&""!==this.value}set type(t){["text","password","email","search","number","url"].includes(t)&&(this._type=t),"url"===this._type&&(this.pattern="(https?://.w*)(:\\d*)?\\/?(.*)"),"email"===this._type&&(this.pattern=/^(([^<>()\\[\]\\.,;:\s@"]+(\.[^<>()\\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),"search"===this._type&&null==this.icon&&null==this.iconLeft&&(this.icon=u.shapeSearch,this.clearable=!0),"password"===this._type&&(this.icon=u.shapeSearch)}get type(){return this._type}_onIconClick(){(0,r.dispatchCustomEvent)(this,"icon-click",this.value),(0,r.dispatchCustomEvent)(this,"submit",this.value)}_onIconVisibleClick(t){this.isPassword&&(t.preventDefault(),t.stopPropagation(),this._showPassword=!this._showPassword,this._type=this._showPassword?"text":"password")}get isPassword(){return!this.disabled&&("password"===this._type||"text"===this._type&&this._showPassword)}get hasClickableIcon(){return!this.disabled&&!this.readonly&&(this.clickable||"search"===this._type||this.clipboard)}get hasClipboard(){return!this.disabled&&this.clipboard}clear(){this.focus(),this.value="",(0,r.dispatchCustomEvent)(this,"clear",this.value)}_renderClearIcon(){return this.isClearable?n.html`<div class="box-icon box-icon-clear"><gv-icon class="link" shape="code:error" title="${(0,h.i18n)("gv-input.clear")}" @click="${this.clear}"></gv-icon></div>`:""}_shapePassword(){return this._showPassword?"general:visible":"general:hidden"}_renderPasswordIcon(){if(this.isPassword){const t=this._shapePassword(),e=this._showPassword?"Show":"Hide";return n.html`<div class="box-icon"><gv-icon class="link" shape="${t}" title="${e}" @click="${this._onIconVisibleClick}"></gv-icon></div>`}return""}get hasBackground(){return!this.loading}renderIcon(){let t=null;if((!this.isPassword&&this.icon||this.iconLeft)&&(t=!this.isPassword&&this.icon||this.iconLeft),this.loading&&(t="navigation:waiting"),t){const e={"box-icon":!0,"box-icon-left":null!=this.iconLeft||this.clearable,"box-icon-bgc":this.hasBackground},i={link:this.hasClickableIcon,loading:this.loading};let l="";if("search"===this._type)l=(0,h.i18n)("gv-input.search");else{if(this.hasClipboard)return l=(0,h.i18n)("gv-input.copy"),n.html`<div class="${(0,s.classMap)(e)}"><gv-popover class="clipboard__popover" event="click" delay="750" .arrow="${!1}"><gv-icon class="${(0,s.classMap)(i)}" shape="${t}" title="${l}"></gv-icon><div slot="popover" class="clipboard__popover-content"><gv-icon shape="code:check"></gv-icon><div>Copied</div></div></gv-popover></div>`;this.placeholder&&(l=this.placeholder)}return n.html`<div class="${(0,s.classMap)(e)}"><gv-icon class="${(0,s.classMap)(i)}" shape="${t}" title="${l}"></gv-icon></div>`}return""}render(){const t={"box-input":!0,skeleton:this.skeleton,large:this.large,medium:this.medium||!this.large&&!this.small,small:this.small,icon:!!this.icon&&!this.clearable,clearable:this.clearable,"icon-left":!!this.iconLeft||!!this.icon&&this.clearable,clipboard:this.hasClipboard,required:this.required,copied:this.hasClipboard&&this._copied};return n.html`<div class="${(0,s.classMap)(t)}">${this.renderLabel()} <input><slot></slot>${this._renderClearIcon()} ${this.renderIcon()} ${this._renderPasswordIcon()}</div>${null!=this.description?n.html`<div class="description" .innerHTML="${this.description}"></div>`:""}`}}exports.GvInput=u,window.customElements.define("gv-input",u);
|