@dile/ui 2.0.1
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/LICENSE +7 -0
- package/README.md +3 -0
- package/components/app-drawer/app-drawer.js +3 -0
- package/components/app-drawer/index.js +1 -0
- package/components/app-drawer/src/DileAppDrawer.js +153 -0
- package/components/avatar/avatar.js +3 -0
- package/components/avatar/index.js +1 -0
- package/components/avatar/src/DileAvatar.js +78 -0
- package/components/breadcrumbs/breadcrumbs-item.js +3 -0
- package/components/breadcrumbs/breadcrumbs.js +4 -0
- package/components/breadcrumbs/index.js +2 -0
- package/components/breadcrumbs/src/DileBreadcrumbs.js +76 -0
- package/components/breadcrumbs/src/DileBreadcrumbsItem.js +51 -0
- package/components/button/button-icon.js +3 -0
- package/components/button/button.js +3 -0
- package/components/button/index.js +2 -0
- package/components/button/src/DileButton.js +86 -0
- package/components/button/src/DileButtonIcon.js +38 -0
- package/components/card/card.js +3 -0
- package/components/card/index.js +1 -0
- package/components/card/src/DileCard.js +111 -0
- package/components/checkbox/checkbox.js +3 -0
- package/components/checkbox/index.js +1 -0
- package/components/checkbox/src/DileCheckbox.js +154 -0
- package/components/confirm/confirm.js +3 -0
- package/components/confirm/index.js +1 -0
- package/components/confirm/src/DileConfirm.js +121 -0
- package/components/datepicker/calendar.js +3 -0
- package/components/datepicker/datepicker.js +4 -0
- package/components/datepicker/index.js +2 -0
- package/components/datepicker/src/DileCalendar.js +72 -0
- package/components/datepicker/src/DileDatepicker.js +114 -0
- package/components/hamburger/hamburger.js +3 -0
- package/components/hamburger/index.js +1 -0
- package/components/hamburger/src/DileHamburger.js +129 -0
- package/components/icon/icon.js +3 -0
- package/components/icon/index.js +1 -0
- package/components/icon/src/DileIcon.js +40 -0
- package/components/icon-switch/icon-switch-group.js +3 -0
- package/components/icon-switch/icon-switch.js +3 -0
- package/components/icon-switch/index.js +1 -0
- package/components/icon-switch/src/DileIconSwitch.js +54 -0
- package/components/icon-switch/src/DileIconSwitchGroup.js +38 -0
- package/components/info-box/index.js +1 -0
- package/components/info-box/info-box.js +3 -0
- package/components/info-box/src/DileInfoBox.js +118 -0
- package/components/inline-feedback/index.js +1 -0
- package/components/inline-feedback/inline-feedback.js +3 -0
- package/components/inline-feedback/src/DileInlineFeedback.js +96 -0
- package/components/input/index.js +9 -0
- package/components/input/input-integer.js +3 -0
- package/components/input/input-message.js +3 -0
- package/components/input/input-money.js +3 -0
- package/components/input/input-number-mask.js +3 -0
- package/components/input/input-percentage.js +3 -0
- package/components/input/input-search.js +3 -0
- package/components/input/input.js +3 -0
- package/components/input/src/DileInput.js +245 -0
- package/components/input/src/DileInputInteger.js +45 -0
- package/components/input/src/DileInputMessage.js +12 -0
- package/components/input/src/DileInputMoney.js +72 -0
- package/components/input/src/DileInputNumberMask.js +83 -0
- package/components/input/src/DileInputPercentage.js +57 -0
- package/components/input/src/DileInputSearch.js +145 -0
- package/components/input/src/Mask.js +37 -0
- package/components/input/src/message-styles.js +14 -0
- package/components/menu-hamburger/index.js +1 -0
- package/components/menu-hamburger/menu-hamburger.js +3 -0
- package/components/menu-hamburger/src/DileMenuHamburger.js +89 -0
- package/components/menu-overlay/index.js +1 -0
- package/components/menu-overlay/menu-overlay.js +3 -0
- package/components/menu-overlay/src/DileMenuOverlay.js +71 -0
- package/components/message/index.js +1 -0
- package/components/message/message.js +3 -0
- package/components/message/src/DileMessage.js +166 -0
- package/components/modal/index.js +1 -0
- package/components/modal/modal.js +3 -0
- package/components/modal/src/DileModal.js +194 -0
- package/components/nav/index.js +1 -0
- package/components/nav/nav.js +3 -0
- package/components/nav/src/DileNav.js +68 -0
- package/components/order-switch/index.js +1 -0
- package/components/order-switch/order-switch.js +3 -0
- package/components/order-switch/src/DileOrderSwitch.js +74 -0
- package/components/pages/index.js +1 -0
- package/components/pages/pages.js +3 -0
- package/components/pages/src/DilePages.js +178 -0
- package/components/password/index.js +1 -0
- package/components/password/password.js +3 -0
- package/components/password/src/DilePassword.js +34 -0
- package/components/progress-bar/index.js +1 -0
- package/components/progress-bar/progress-bar.js +3 -0
- package/components/progress-bar/src/DileProgressBar.js +89 -0
- package/components/radio-group/index.js +2 -0
- package/components/radio-group/radio-group.js +3 -0
- package/components/radio-group/radio.js +3 -0
- package/components/radio-group/src/DileRadio.js +79 -0
- package/components/radio-group/src/DileRadioGroup.js +102 -0
- package/components/range/index.js +1 -0
- package/components/range/range.js +3 -0
- package/components/range/src/DileRange.js +119 -0
- package/components/rating/index.js +1 -0
- package/components/rating/rating.js +4 -0
- package/components/rating/src/DileRating.js +119 -0
- package/components/rating/src/DileStar.js +63 -0
- package/components/rating/star.js +3 -0
- package/components/rating-scale-question/index.js +2 -0
- package/components/rating-scale-question/rating-scale-option.js +3 -0
- package/components/rating-scale-question/rating-scale-question.js +3 -0
- package/components/rating-scale-question/src/DileRatingScaleOption.js +184 -0
- package/components/rating-scale-question/src/DileRatingScaleQuestion.js +252 -0
- package/components/select/index.js +1 -0
- package/components/select/select-ajax.js +4 -0
- package/components/select/select.js +3 -0
- package/components/select/src/DileSelect.js +172 -0
- package/components/select/src/DileSelectAjax.js +338 -0
- package/components/selector/index.js +2 -0
- package/components/selector/selector-item.js +3 -0
- package/components/selector/selector.js +3 -0
- package/components/selector/src/DileSelector.js +12 -0
- package/components/selector/src/DileSelectorItem.js +94 -0
- package/components/slide-show/index.js +1 -0
- package/components/slide-show/slide-show.js +3 -0
- package/components/slide-show/src/DileSlideShow.js +111 -0
- package/components/social-icon/index.js +1 -0
- package/components/social-icon/social-icon.js +3 -0
- package/components/social-icon/src/DileSocialIcon.js +63 -0
- package/components/social-icon/src/icons.js +103 -0
- package/components/spinner/index.js +1 -0
- package/components/spinner/spinner-horizontal.js +3 -0
- package/components/spinner/spinner-modal.js +4 -0
- package/components/spinner/spinner.js +3 -0
- package/components/spinner/src/DileSpinner.js +116 -0
- package/components/spinner/src/DileSpinnerHorizontal.js +64 -0
- package/components/spinner/src/DileSpinnerMixin.js +13 -0
- package/components/spinner/src/DileSpinnerModal.js +51 -0
- package/components/tabs/index.js +2 -0
- package/components/tabs/src/DileTab.js +60 -0
- package/components/tabs/src/DileTabs.js +12 -0
- package/components/tabs/tab.js +3 -0
- package/components/tabs/tabs.js +4 -0
- package/components/textarea/index.js +1 -0
- package/components/textarea/src/DileTextarea.js +166 -0
- package/components/textarea/textarea.js +3 -0
- package/components/toast/index.js +3 -0
- package/components/toast/src/DileToast.js +95 -0
- package/components/toast/src/DileToastItem.js +92 -0
- package/components/toast/src/DileToastPersistent.js +100 -0
- package/components/toast/toast-item.js +3 -0
- package/components/toast/toast-persistent.js +3 -0
- package/components/toast/toast.js +4 -0
- package/components/tooltip/chip-tooltip.js +3 -0
- package/components/tooltip/index.js +1 -0
- package/components/tooltip/src/DileChipTooltip.js +86 -0
- package/components/tooltip/src/DileTooltip.js +195 -0
- package/components/tooltip/tooltip.js +3 -0
- package/mixins/close-document-click/index.js +1 -0
- package/mixins/close-document-click/src/DileCloseDocumentClick.js +67 -0
- package/mixins/close-on-esc-pressed/index.js +1 -0
- package/mixins/close-on-esc-pressed/src/DileCloseOnEscPressed.js +31 -0
- package/mixins/form/index.js +3 -0
- package/mixins/form/src/DileEmmitChange.js +22 -0
- package/mixins/form/src/DileForm.js +116 -0
- package/mixins/form/src/DileFormChangeDetect.js +34 -0
- package/mixins/overlay/index.js +1 -0
- package/mixins/overlay/src/DileOverlay.js +171 -0
- package/mixins/selectable/index.js +2 -0
- package/mixins/selectable/src/DileSelectable.js +154 -0
- package/mixins/selectable/src/DileSelectableItem.js +30 -0
- package/mixins/slide-down/index.js +1 -0
- package/mixins/slide-down/src/DileSlideDown.js +40 -0
- package/package.json +29 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { html, css, LitElement } from "lit";
|
|
2
|
+
import '../../icon/icon.js';
|
|
3
|
+
|
|
4
|
+
export class DileIconSwitch extends LitElement {
|
|
5
|
+
static get properties() {
|
|
6
|
+
return {
|
|
7
|
+
icon: { type: Object },
|
|
8
|
+
active: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
reflect: true,
|
|
11
|
+
},
|
|
12
|
+
name: { type: String },
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static get styles() {
|
|
17
|
+
return [
|
|
18
|
+
css`
|
|
19
|
+
:host {
|
|
20
|
+
display: inline-block;
|
|
21
|
+
}
|
|
22
|
+
dile-icon {
|
|
23
|
+
--dile-icon-color: var(--dile-icon-switch-inactive-color, #303030);
|
|
24
|
+
}
|
|
25
|
+
:host([active]) dile-icon{
|
|
26
|
+
--dile-icon-color: var(--dile-icon-switch-active-color, #7BB93D);
|
|
27
|
+
}
|
|
28
|
+
.flex {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
}
|
|
32
|
+
`];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
render() {
|
|
36
|
+
return html`
|
|
37
|
+
<div class="flex">
|
|
38
|
+
<dile-icon .icon="${this.icon}" @click=${this.clickHandler}></dile-icon>
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
clickHandler() {
|
|
44
|
+
this.active = ! this.active;
|
|
45
|
+
this.dispatchEvent(new CustomEvent('dile-icon-switch-changed', {
|
|
46
|
+
bubbles: true,
|
|
47
|
+
composed: true,
|
|
48
|
+
detail: {
|
|
49
|
+
active: this.active,
|
|
50
|
+
name: this.name,
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import '../icon-switch';
|
|
3
|
+
|
|
4
|
+
export class DileIconSwitchGroup extends LitElement {
|
|
5
|
+
static styles = [
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
}
|
|
10
|
+
.flex {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
render() {
|
|
18
|
+
return html`
|
|
19
|
+
<div class="flex" @dile-icon-switch-changed=${this.processChanged}>
|
|
20
|
+
<slot></slot>
|
|
21
|
+
</div>
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
processChanged(e) {
|
|
26
|
+
this.querySelectorAll('dile-icon-switch').forEach( element => {
|
|
27
|
+
if(element.name != e.detail.name) {
|
|
28
|
+
element.active = false;
|
|
29
|
+
} else {
|
|
30
|
+
if(element.active == false) {
|
|
31
|
+
element.active = true;
|
|
32
|
+
e.stopPropagation();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DileInfoBox } from './src/DileInfoBox.js';
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { DileSlideDown } from '../../../mixins/slide-down';
|
|
3
|
+
import { closeIcon, infoIcon, warningIcon, iconStyles } from '@dile/icons/index.js';
|
|
4
|
+
|
|
5
|
+
export class DileInfoBox extends DileSlideDown(LitElement) {
|
|
6
|
+
|
|
7
|
+
static get styles() {
|
|
8
|
+
return [iconStyles, css`
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
#box {
|
|
13
|
+
transition: height 0.3s ease-in;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
}
|
|
16
|
+
section {
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: flex-start;
|
|
20
|
+
border-radius: var(--dile-info-box-border-radius, 0px);
|
|
21
|
+
padding: var(--dile-info-box-padding, 1rem);
|
|
22
|
+
background-color: var(--dile-info-box-background-color, #ddd);
|
|
23
|
+
color: var(--dile-info-box-text-color, #303030);
|
|
24
|
+
}
|
|
25
|
+
.content {
|
|
26
|
+
flex-grow: 1;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: flex-start;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
}
|
|
31
|
+
.info {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
margin-bottom: 0.5rem;
|
|
35
|
+
--dile-icon-size: 36px;
|
|
36
|
+
}
|
|
37
|
+
main {
|
|
38
|
+
flex-grow: 1;
|
|
39
|
+
}
|
|
40
|
+
.close {
|
|
41
|
+
padding-top: 0.5rem;
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: flex-start;
|
|
44
|
+
--dile-icon-color: var(--dile-info-box-close-icon-color, #f33);
|
|
45
|
+
}
|
|
46
|
+
button {
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
border: none;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
}
|
|
51
|
+
.title {
|
|
52
|
+
margin-bottom: var(--dile-info-box-title-margin-bottom, 0.5rem);;
|
|
53
|
+
font-size: var(--dile-info-box-title-font-size, 1.3rem);
|
|
54
|
+
font-weight: var(--dile-info-box-title-font-weight, bold);
|
|
55
|
+
color: var(--dile-info-box-title-text-color, inherit);
|
|
56
|
+
}
|
|
57
|
+
@media(min-width: 400px) {
|
|
58
|
+
.content {
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
align-items: center;
|
|
61
|
+
}
|
|
62
|
+
.info {
|
|
63
|
+
margin: 0 1rem 0 0;
|
|
64
|
+
--dile-icon-size: 28px;
|
|
65
|
+
}
|
|
66
|
+
.close {
|
|
67
|
+
padding-top: 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
@media(min-width: 500px) {
|
|
71
|
+
.info {
|
|
72
|
+
--dile-icon-size: 36px;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static get properties() {
|
|
79
|
+
return {
|
|
80
|
+
showCloseButton: { type: Boolean },
|
|
81
|
+
title: { type: String },
|
|
82
|
+
isError: { type: Boolean}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
render() {
|
|
87
|
+
return html`
|
|
88
|
+
<div id="box">
|
|
89
|
+
<section>
|
|
90
|
+
<div class="content">
|
|
91
|
+
<span class="info">${this.showIcon(this.isError)}</span>
|
|
92
|
+
<main>
|
|
93
|
+
${this.title
|
|
94
|
+
? html`<div class="title">${this.title}</div>`
|
|
95
|
+
: ''
|
|
96
|
+
}
|
|
97
|
+
<slot></slot>
|
|
98
|
+
</main>
|
|
99
|
+
</div>
|
|
100
|
+
${this.showCloseButton
|
|
101
|
+
? html`
|
|
102
|
+
<div class="close">
|
|
103
|
+
<button @click="${this.close}">${closeIcon}</button>
|
|
104
|
+
</div>` : ''}
|
|
105
|
+
</section>
|
|
106
|
+
</div>
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
close() {
|
|
111
|
+
let elem = this.shadowRoot.getElementById('box');
|
|
112
|
+
this.slideHide(elem);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
showIcon(isError) {
|
|
116
|
+
return isError ? html`${warningIcon}` : html`${infoIcon}`
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DileInlineFeedback } from './src/DileInlineFeedback.js';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
import { DileSlideDown } from '../../../mixins/slide-down';
|
|
3
|
+
|
|
4
|
+
export class DileInlineFeedback extends DileSlideDown(LitElement) {
|
|
5
|
+
static get properties() {
|
|
6
|
+
return {
|
|
7
|
+
msg: { type: String },
|
|
8
|
+
status: { type: String },
|
|
9
|
+
opened: { type: Boolean },
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
static get styles() {
|
|
13
|
+
return css`
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
}
|
|
17
|
+
section {
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
font-size: 0.9em;
|
|
20
|
+
border-radius: 5px;
|
|
21
|
+
text-align: center;
|
|
22
|
+
background-color: #ddd;
|
|
23
|
+
height: 0px;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
transition: all 0.3s ease-in;
|
|
26
|
+
-webkit-transition: all 0.3s ease-in;
|
|
27
|
+
}
|
|
28
|
+
section p {
|
|
29
|
+
margin: 0;
|
|
30
|
+
padding: 12px 5px;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
}
|
|
33
|
+
.error {
|
|
34
|
+
background-color: rgba(220, 60, 60, 0.3);
|
|
35
|
+
box-shadow: inset 0 0 0 2px rgba(220, 60, 60, 0.5);
|
|
36
|
+
}
|
|
37
|
+
.success {
|
|
38
|
+
background-color: rgba(30, 220, 99, 0.3);
|
|
39
|
+
box-shadow: inset 0 0 0 2px rgba(30, 220, 99, 0.5);
|
|
40
|
+
}
|
|
41
|
+
.neutral {
|
|
42
|
+
background-color: rgba(30, 100, 250, 0.2);
|
|
43
|
+
box-shadow: inset 0 0 0 2px rgba(30, 100, 220, 0.5);
|
|
44
|
+
}
|
|
45
|
+
@media(min-width: 850px) {
|
|
46
|
+
section {
|
|
47
|
+
font-size: 0.8em;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
render() {
|
|
54
|
+
return html`
|
|
55
|
+
<section id="msg" class="${this.status}">
|
|
56
|
+
<p>
|
|
57
|
+
${this.msg}
|
|
58
|
+
</p>
|
|
59
|
+
</section>
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
firstUpdated() {
|
|
64
|
+
this.msgElement = this.shadowRoot.getElementById('msg');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
doFeeedback(msg, status) {
|
|
68
|
+
if(this.opened) {
|
|
69
|
+
this.clear();
|
|
70
|
+
setTimeout(() => this.doFeeedback(msg, status), 300);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.msg = msg;
|
|
74
|
+
this.status = status;
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
this.slideShow(this.msgElement);
|
|
77
|
+
this.opened = true
|
|
78
|
+
}, 100);
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
positiveFeedback(msg) {
|
|
82
|
+
this.doFeeedback(msg, 'success');
|
|
83
|
+
}
|
|
84
|
+
negativeFeedback(msg) {
|
|
85
|
+
this.doFeeedback(msg, 'error');
|
|
86
|
+
}
|
|
87
|
+
neutralFeedback(msg) {
|
|
88
|
+
this.doFeeedback(msg, 'neutral');
|
|
89
|
+
}
|
|
90
|
+
clear() {
|
|
91
|
+
this.slideHide(this.msgElement);
|
|
92
|
+
this.msg = '';
|
|
93
|
+
this.status = '';
|
|
94
|
+
this.opened = false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { DileInput } from './src/DileInput.js';
|
|
2
|
+
export { DileInputInteger } from './src/DileInputInteger.js';
|
|
3
|
+
export { DileInputMessage } from './src/DileInputMessage.js';
|
|
4
|
+
export { DileInputMoney } from './src/DileInputMoney.js';
|
|
5
|
+
export { DileInputNumberMask } from './src/DileInputNumberMask.js';
|
|
6
|
+
export { DileInputPercentage } from './src/DileInputPercentage.js';
|
|
7
|
+
export { DileInputSearch } from './src/DileInputSearch.js';
|
|
8
|
+
export { messageStyles } from './src/message-styles.js';
|
|
9
|
+
export { Mask } from './src/Mask.js';
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
3
|
+
import { messageStyles } from './message-styles.js';
|
|
4
|
+
|
|
5
|
+
export class DileInput extends DileEmmitChange(LitElement) {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Fired when user press enter key.
|
|
9
|
+
*
|
|
10
|
+
* @event enter-pressed
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Liten to the native input event to recive text input updates
|
|
15
|
+
*
|
|
16
|
+
* @event input
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {
|
|
21
|
+
/** Label to the element */
|
|
22
|
+
label: { type: String },
|
|
23
|
+
|
|
24
|
+
/** Input type */
|
|
25
|
+
type: { type: String },
|
|
26
|
+
|
|
27
|
+
/** Set a placeholder to the input element */
|
|
28
|
+
placeholder: { type: String },
|
|
29
|
+
|
|
30
|
+
/** Disable the input field */
|
|
31
|
+
disabled: { type: Boolean },
|
|
32
|
+
|
|
33
|
+
/** Set initial value to the input. This property syncs to the input field value property */
|
|
34
|
+
value: { type: String },
|
|
35
|
+
|
|
36
|
+
/** Name for this input field */
|
|
37
|
+
name: { type: String },
|
|
38
|
+
|
|
39
|
+
/** Has error on this input field */
|
|
40
|
+
errored: { type: Boolean },
|
|
41
|
+
|
|
42
|
+
/** Disable the autocomplete of the input field */
|
|
43
|
+
disableAutocomplete: { type: Boolean },
|
|
44
|
+
|
|
45
|
+
/** ReadOnly attribute */
|
|
46
|
+
readonly: { type: Boolean },
|
|
47
|
+
|
|
48
|
+
/** Select all content on focus */
|
|
49
|
+
selectOnFocus: { type: Boolean },
|
|
50
|
+
|
|
51
|
+
/** Message Displayed */
|
|
52
|
+
message: { type: String },
|
|
53
|
+
|
|
54
|
+
/** Text placed on the right side of the input */
|
|
55
|
+
labelRight: { type: String },
|
|
56
|
+
|
|
57
|
+
/** Hide errors on input */
|
|
58
|
+
hideErrorOnInput: { type: Boolean },
|
|
59
|
+
|
|
60
|
+
/** Set the application focus to this the input component after the initialization */
|
|
61
|
+
focusOnStart: { type: Boolean },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
firstUpdated() {
|
|
66
|
+
if(this.focusOnStart) {
|
|
67
|
+
this.focus();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
updated(changedProperties) {
|
|
72
|
+
if(changedProperties.has('value')) {
|
|
73
|
+
this.emmitChange();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
constructor() {
|
|
78
|
+
super();
|
|
79
|
+
this.placeholder = '';
|
|
80
|
+
this.label = '';
|
|
81
|
+
this.labelRight = '';
|
|
82
|
+
this.value = '';
|
|
83
|
+
this.disabled = false;
|
|
84
|
+
this.disableAutocomplete = false;
|
|
85
|
+
this.name = '';
|
|
86
|
+
this.type = 'text';
|
|
87
|
+
this.types = ['text', 'password', 'email', 'number', 'tel', 'url', 'search', 'date', 'time', 'datetime', 'datetime-local', 'month', 'week'];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static get styles() {
|
|
91
|
+
return [
|
|
92
|
+
messageStyles,
|
|
93
|
+
css`
|
|
94
|
+
* {
|
|
95
|
+
box-sizing: border-box;
|
|
96
|
+
}
|
|
97
|
+
:host {
|
|
98
|
+
display: block;
|
|
99
|
+
margin-bottom: 10px;
|
|
100
|
+
}
|
|
101
|
+
:host([type="hidden"]) {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
main {
|
|
105
|
+
width: var(--dile-input-section-width, 100%);
|
|
106
|
+
}
|
|
107
|
+
label {
|
|
108
|
+
display: block;
|
|
109
|
+
margin-bottom: var(--dile-input-label-margin-bottom, 4px);
|
|
110
|
+
font-size: var(--dile-input-label-font-size, 1em);
|
|
111
|
+
color: var(--dile-input-label-color, #59e);
|
|
112
|
+
font-weight: var(--dile-input-label-font-weight, normal);
|
|
113
|
+
}
|
|
114
|
+
input {
|
|
115
|
+
box-sizing: border-box;
|
|
116
|
+
border-radius: var(--dile-input-border-radius, 5px);
|
|
117
|
+
border: var(--dile-input-border-width, 1px) solid var(--dile-input-border-color, #888);
|
|
118
|
+
font-size: var(--dile-input-font-size, 1em);
|
|
119
|
+
line-height: var(--dile-input-line-height, 1.5em);
|
|
120
|
+
padding: var(--dile-input-padding, 5px);
|
|
121
|
+
background-color: var(--dile-input-background-color, #fff);
|
|
122
|
+
color: var(--dile-input-color, #303030);
|
|
123
|
+
text-align: var(--dile-input-text-align, left);
|
|
124
|
+
width: 100%;
|
|
125
|
+
flex-grow: 1;
|
|
126
|
+
}
|
|
127
|
+
input:focus {
|
|
128
|
+
outline: none;
|
|
129
|
+
border-color: var(--dile-input-focus-border-color, #6af)
|
|
130
|
+
}
|
|
131
|
+
input::placeholder {
|
|
132
|
+
color: var(--dile-input-placeholder-color, #ccc);
|
|
133
|
+
}
|
|
134
|
+
input:disabled {
|
|
135
|
+
background-color: #f5f5f5;
|
|
136
|
+
border-color: var(--dile-input-disabled-border-color, #eee);
|
|
137
|
+
}
|
|
138
|
+
.errored {
|
|
139
|
+
border-color: var(--dile-input-error-border-color, #c00);
|
|
140
|
+
}
|
|
141
|
+
section.for-input {
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
width: 100%;
|
|
145
|
+
}
|
|
146
|
+
.labelright {
|
|
147
|
+
margin-left: var(--dile-input-label-right-margin-left, 10px);
|
|
148
|
+
color: var(--dile-input-label-color, #59e);
|
|
149
|
+
font-size: var(--dile-input-label-right-font-size, 1.2em);
|
|
150
|
+
}
|
|
151
|
+
`
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
render() {
|
|
156
|
+
return html`
|
|
157
|
+
<main>
|
|
158
|
+
${this.label
|
|
159
|
+
? html`<label for="textField">${this.label}</label>`
|
|
160
|
+
: ""}
|
|
161
|
+
<section class="for-input">
|
|
162
|
+
<input
|
|
163
|
+
type="${this.availableType(this.type)}"
|
|
164
|
+
id="textField"
|
|
165
|
+
name="${this.name}"
|
|
166
|
+
placeholder="${this.placeholder}"
|
|
167
|
+
?disabled="${this.disabled}"
|
|
168
|
+
?readonly="${this.readonly}"
|
|
169
|
+
autocomplete="${this.disableAutocomplete ? "off" : "on"}"
|
|
170
|
+
.value="${this.computeValue(this.value)}"
|
|
171
|
+
class="${this.errored ? 'errored' : ''}"
|
|
172
|
+
@keypress="${this._lookForEnter}"
|
|
173
|
+
@input="${this._input}"
|
|
174
|
+
@blur="${this.doBlur}"
|
|
175
|
+
@focus="${this.doFocus}"
|
|
176
|
+
/>
|
|
177
|
+
${this.labelRight
|
|
178
|
+
? html`<span class="labelright">${this.labelRight}</span>`
|
|
179
|
+
: ''
|
|
180
|
+
}
|
|
181
|
+
</section>
|
|
182
|
+
${this.messageTemplate}
|
|
183
|
+
</main>
|
|
184
|
+
`;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
get messageTemplate() {
|
|
188
|
+
return html`
|
|
189
|
+
${this.message
|
|
190
|
+
? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
191
|
+
: ''
|
|
192
|
+
}
|
|
193
|
+
`
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Private method to dispatch events on enter key pressed
|
|
198
|
+
*/
|
|
199
|
+
_lookForEnter(e) {
|
|
200
|
+
let keycode = (e.keyCode ? e.keyCode : e.which);
|
|
201
|
+
if (keycode == '13') {
|
|
202
|
+
this.dispatchEvent(new CustomEvent('enter-pressed'));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
_input(e) {
|
|
206
|
+
this.value = e.target.value;
|
|
207
|
+
if (this.hideErrorOnInput && this.errored) {
|
|
208
|
+
this.clearError();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
clearError() {
|
|
213
|
+
this.errored = false;
|
|
214
|
+
this.message = '';
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
availableType(type) {
|
|
218
|
+
if(this.types.includes(type)) {
|
|
219
|
+
return type;
|
|
220
|
+
}
|
|
221
|
+
return 'text';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
get el() {
|
|
225
|
+
return this.shadowRoot.querySelector('input');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
doBlur() {
|
|
229
|
+
//
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
doFocus() {
|
|
233
|
+
if(this.selectOnFocus) {
|
|
234
|
+
this.el.select();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
computeValue(value) {
|
|
239
|
+
return value;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
focus() {
|
|
243
|
+
this.el.focus();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { DileInput } from './DileInput';
|
|
3
|
+
|
|
4
|
+
export class DileInputInteger extends DileInput {
|
|
5
|
+
static styles = [
|
|
6
|
+
DileInput.styles,
|
|
7
|
+
css`
|
|
8
|
+
:host {
|
|
9
|
+
display: block;
|
|
10
|
+
}
|
|
11
|
+
input {
|
|
12
|
+
text-align: var(--dile-input-integer-text-align, var(--dile-input-text-align, right));
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.changed = false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
doBlur(e) {
|
|
23
|
+
let num = e.target.value;
|
|
24
|
+
if(num.length > 0) {
|
|
25
|
+
num = this.formatInteger(num);
|
|
26
|
+
}
|
|
27
|
+
if(num != e.target.value || this.changed) {
|
|
28
|
+
this.el.value = num;
|
|
29
|
+
this.value = num;
|
|
30
|
+
this.emmitChange();
|
|
31
|
+
this.changed = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
formatInteger(num) {
|
|
36
|
+
num = parseInt(num);
|
|
37
|
+
return isNaN(num) ? '0' : num;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
updated(changedProperties) {
|
|
41
|
+
if(changedProperties.has('value') && this.value) {
|
|
42
|
+
this.changed = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|