@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,172 @@
|
|
|
1
|
+
import { html, css, LitElement } from "lit";
|
|
2
|
+
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
3
|
+
import { messageStyles } from '../../input/index.js';
|
|
4
|
+
|
|
5
|
+
export class DileSelect extends DileEmmitChange(LitElement) {
|
|
6
|
+
static get styles() {
|
|
7
|
+
return [
|
|
8
|
+
messageStyles,
|
|
9
|
+
css`
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
margin-bottom: 10px;
|
|
13
|
+
}
|
|
14
|
+
* {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
label {
|
|
18
|
+
display: block;
|
|
19
|
+
margin-bottom: var(--dile-input-label-margin-bottom, 4px);
|
|
20
|
+
font-size: var(--dile-input-label-font-size, 1em);
|
|
21
|
+
color: var(--dile-input-label-color, #59e);
|
|
22
|
+
font-weight: var(--dile-input-label-font-weight, normal);
|
|
23
|
+
}
|
|
24
|
+
::slotted(select) {
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
width: var(--dile-input-width, 100%);
|
|
27
|
+
padding: var(--dile-input-padding, 7px 5px);
|
|
28
|
+
line-height: var(--dile-input-line-height, 1.5em);
|
|
29
|
+
font-size: var(--dile-select-font-size, 0.875em);
|
|
30
|
+
border-radius: var(--dile-input-border-radius, 5px);
|
|
31
|
+
border: var(--dile-input-border-width, 1px) solid var(--dile-input-border-color, #888);
|
|
32
|
+
background-color: var(--dile-input-background-color, #fff);
|
|
33
|
+
color: var(--dile-input-color, #303030);
|
|
34
|
+
background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20256%20448%22%20enable-background%3D%22new%200%200%20256%20448%22%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E.arrow%7Bfill%3A%23303030%3B%7D%3C%2Fstyle%3E%3Cpath%20class%3D%22arrow%22%20d%3D%22M255.9%20168c0-4.2-1.6-7.9-4.8-11.2-3.2-3.2-6.9-4.8-11.2-4.8H16c-4.2%200-7.9%201.6-11.2%204.8S0%20163.8%200%20168c0%204.4%201.6%208.2%204.8%2011.4l112%20112c3.1%203.1%206.8%204.6%2011.2%204.6%204.4%200%208.2-1.5%2011.4-4.6l112-112c3-3.2%204.5-7%204.5-11.4z%22%2F%3E%3C%2Fsvg%3E%0A");
|
|
35
|
+
background-position: right 10px center;
|
|
36
|
+
background-repeat: no-repeat;
|
|
37
|
+
background-size: auto 50%;
|
|
38
|
+
-moz-appearance: none;
|
|
39
|
+
-webkit-appearance: none;
|
|
40
|
+
appearance: none;
|
|
41
|
+
}
|
|
42
|
+
::slotted(select.dark) {
|
|
43
|
+
background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20256%20448%22%20enable-background%3D%22new%200%200%20256%20448%22%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E.arrow%7Bfill%3A%23ffffff%3B%7D%3C%2Fstyle%3E%3Cpath%20class%3D%22arrow%22%20d%3D%22M255.9%20168c0-4.2-1.6-7.9-4.8-11.2-3.2-3.2-6.9-4.8-11.2-4.8H16c-4.2%200-7.9%201.6-11.2%204.8S0%20163.8%200%20168c0%204.4%201.6%208.2%204.8%2011.4l112%20112c3.1%203.1%206.8%204.6%2011.2%204.6%204.4%200%208.2-1.5%2011.4-4.6l112-112c3-3.2%204.5-7%204.5-11.4z%22%2F%3E%3C%2Fsvg%3E%0A");
|
|
44
|
+
}
|
|
45
|
+
::slotted(select):focus {
|
|
46
|
+
outline: none;
|
|
47
|
+
border-color: var(--dile-input-focus-border-color, #6af);
|
|
48
|
+
}
|
|
49
|
+
::slotted(select.errored) {
|
|
50
|
+
border-color: var(--dile-input-error-border-color, #c00);
|
|
51
|
+
}
|
|
52
|
+
::slotted(select.disabled) {
|
|
53
|
+
background-color: #f5f5f5;
|
|
54
|
+
border-color: var(--dile-input-disabled-border-color, #eee);
|
|
55
|
+
}
|
|
56
|
+
`];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static get properties() {
|
|
60
|
+
return {
|
|
61
|
+
label: { type: String },
|
|
62
|
+
value: { type: String },
|
|
63
|
+
name: { type: String },
|
|
64
|
+
disabled: { type: Boolean },
|
|
65
|
+
errored: { type: Boolean },
|
|
66
|
+
message: { type: String },
|
|
67
|
+
hideErrorOnInput: { type: Boolean },
|
|
68
|
+
quietOnStart: { type: Boolean },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
render() {
|
|
73
|
+
return html`
|
|
74
|
+
<div>
|
|
75
|
+
${this.label
|
|
76
|
+
? html`<label for="textField">${this.label}</label>`
|
|
77
|
+
: ""
|
|
78
|
+
}
|
|
79
|
+
<slot name="select"></slot>
|
|
80
|
+
</div>
|
|
81
|
+
${this.message
|
|
82
|
+
? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
83
|
+
: ''
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get elselect() {
|
|
89
|
+
return this.querySelector("select");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
constructor() {
|
|
93
|
+
super();
|
|
94
|
+
this.errored = false;
|
|
95
|
+
this.hideErrorOnInput = false;
|
|
96
|
+
this.changeHandler = this.onChange.bind(this);
|
|
97
|
+
this.quiet = false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
connectedCallback() {
|
|
101
|
+
super.connectedCallback();
|
|
102
|
+
if (!this.elselect) {
|
|
103
|
+
throw new Error('Use dile-select with a select element in the slot "select"');
|
|
104
|
+
} else {
|
|
105
|
+
this.elselect.addEventListener("change", this.changeHandler);
|
|
106
|
+
this.value = this.elselect.value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
disconnectedCallback() {
|
|
111
|
+
super.disconnectedCallback();
|
|
112
|
+
if (this.elselect) {
|
|
113
|
+
this.elselect.removeEventListener("change", this.changeHandler);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
onChange(e) {
|
|
118
|
+
this.value = e.target.value;
|
|
119
|
+
if (this.hideErrorOnInput && this.errored) {
|
|
120
|
+
this.errored = false;
|
|
121
|
+
this.message = '';
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
updated(changedProperties) {
|
|
126
|
+
if(changedProperties.has("value")) {
|
|
127
|
+
this.elselect.value = this.value;
|
|
128
|
+
if (this.quiet) {
|
|
129
|
+
this.quiet = false;
|
|
130
|
+
} else {
|
|
131
|
+
this.emmitChange();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if(changedProperties.has("disabled")) {
|
|
135
|
+
this.elselect.disabled = this.disabled;
|
|
136
|
+
this.elselect.classList.toggle("disabled", this.disabled);
|
|
137
|
+
}
|
|
138
|
+
if(changedProperties.has("errored")) {
|
|
139
|
+
this.elselect.classList.toggle("errored", this.errored);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
firstUpdated() {
|
|
144
|
+
super.firstUpdated();
|
|
145
|
+
this.quiet = this.quietOnStart;
|
|
146
|
+
if(this.value) {
|
|
147
|
+
this.elselect.value = this.value;
|
|
148
|
+
} else {
|
|
149
|
+
this.value = this.elselect.value;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
clear() {
|
|
154
|
+
this.value = undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
getOptionByValue(id) {
|
|
158
|
+
let options = this.elselect.options;
|
|
159
|
+
for(let i = 0; i < options.length; i++) {
|
|
160
|
+
if(options[i].value === id) {
|
|
161
|
+
return options[i];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
quietChange(value) {
|
|
167
|
+
if (value != this.value) {
|
|
168
|
+
this.quiet = true;
|
|
169
|
+
this.value = value;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import '../../input/input-search.js';
|
|
3
|
+
import '../../spinner/spinner-horizontal.js';
|
|
4
|
+
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
5
|
+
import '../select.js';
|
|
6
|
+
|
|
7
|
+
export class DileSelectAjax extends DileEmmitChange(LitElement) {
|
|
8
|
+
|
|
9
|
+
static get styles() {
|
|
10
|
+
return css`
|
|
11
|
+
* {
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
}
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
position: relative;
|
|
17
|
+
margin-bottom: 10px;
|
|
18
|
+
}
|
|
19
|
+
label {
|
|
20
|
+
display: block;
|
|
21
|
+
margin-bottom: var(--dile-input-label-margin-bottom, 4px);
|
|
22
|
+
font-size: var(--dile-input-label-font-size, 1em);
|
|
23
|
+
color: var(--dile-input-label-color, #59e);
|
|
24
|
+
font-weight: var(--dile-input-label-font-weight, normal);
|
|
25
|
+
}
|
|
26
|
+
.anchor {
|
|
27
|
+
margin-top: 0.5rem;
|
|
28
|
+
position: relative;
|
|
29
|
+
}
|
|
30
|
+
section {
|
|
31
|
+
min-height: 2.5rem;
|
|
32
|
+
width: var(--dile-input-width, 100%);
|
|
33
|
+
border-radius: var(--dile-input-border-radius, 5px);
|
|
34
|
+
padding: var(--dile-input-padding, 7px 5px);
|
|
35
|
+
display: none;
|
|
36
|
+
position: absolute;
|
|
37
|
+
background-color: #fff;
|
|
38
|
+
border: 1px solid #ccc;
|
|
39
|
+
border: var(--dile-input-border-width, 1px) solid var(--dile-input-border-color, #888);
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
}
|
|
43
|
+
p {
|
|
44
|
+
margin: 0;
|
|
45
|
+
}
|
|
46
|
+
.opened {
|
|
47
|
+
display: flex;
|
|
48
|
+
}
|
|
49
|
+
dile-select {
|
|
50
|
+
margin-bottom: 0;
|
|
51
|
+
--dile-input-width: 100%;
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static get properties() {
|
|
57
|
+
return {
|
|
58
|
+
/* Allows to set a text for the default option, that is a empty option and do not selects nothing in the interface. */
|
|
59
|
+
selectDefaultPlaceholder: { type: String },
|
|
60
|
+
endpoint: { type: String },
|
|
61
|
+
label: { type: String },
|
|
62
|
+
value: { type: String },
|
|
63
|
+
name: { type: String },
|
|
64
|
+
disabled: { type: Boolean },
|
|
65
|
+
errored: { type: Boolean },
|
|
66
|
+
data: { type: Array },
|
|
67
|
+
placeholder: { type: String },
|
|
68
|
+
emptyMessage: { type: String },
|
|
69
|
+
selectedText: { type: String },
|
|
70
|
+
ajaxErrorMessage: { type: String },
|
|
71
|
+
ajaxError: { type: Boolean },
|
|
72
|
+
queryStringVariable: { type: String },
|
|
73
|
+
/** Use resultDataProperty to declare witch property in the JSON object returned by the endpoint has the data to assign to the select options. Left it blank if the result JSON has directly the array with the data */
|
|
74
|
+
resultDataProperty: { type: String },
|
|
75
|
+
displayProperty: { type: String },
|
|
76
|
+
idProperty: { type: String },
|
|
77
|
+
delay: { type: Number },
|
|
78
|
+
opened: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
state: true,
|
|
81
|
+
},
|
|
82
|
+
keyword: {
|
|
83
|
+
type: String,
|
|
84
|
+
state: true,
|
|
85
|
+
},
|
|
86
|
+
loading: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
state: true,
|
|
89
|
+
},
|
|
90
|
+
isSelected: {
|
|
91
|
+
type: Object,
|
|
92
|
+
state: true,
|
|
93
|
+
},
|
|
94
|
+
/* When static is true there is no posibility to search, then all the options are displayed on the select on initialization */
|
|
95
|
+
static: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
updated(changedProperties) {
|
|
102
|
+
if(changedProperties.has("value")) {
|
|
103
|
+
this.emmitChange();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
constructor() {
|
|
108
|
+
super();
|
|
109
|
+
this.placeholder = "Search to choose...";
|
|
110
|
+
this.selectDefaultPlaceholder = "Select an option...";
|
|
111
|
+
this.emptyMessage = "No results found";
|
|
112
|
+
this.ajaxErrorMessage = "Error loading data";
|
|
113
|
+
this.data = [];
|
|
114
|
+
this.keyword = '';
|
|
115
|
+
this.loading = false;
|
|
116
|
+
this.errored = false;
|
|
117
|
+
this.ajaxError = false;
|
|
118
|
+
this.isSelected = false;
|
|
119
|
+
this.static = false;
|
|
120
|
+
this.blurHandler = this.close.bind(this);
|
|
121
|
+
this.queryStringVariable = 'q';
|
|
122
|
+
this.delay = 300;
|
|
123
|
+
this.idProperty = 'id';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
connectedCallback() {
|
|
127
|
+
super.connectedCallback();
|
|
128
|
+
this.addEventListener('blur', this.blurHandler);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
disconnectedCallback() {
|
|
132
|
+
super.disconnectedCallback();
|
|
133
|
+
this.removeEventListener('blur', this.blurHandler);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
firstUpdated() {
|
|
137
|
+
if(this.value) {
|
|
138
|
+
this.isSelected = true;
|
|
139
|
+
this.searchValueInitial();
|
|
140
|
+
}
|
|
141
|
+
if(this.static) {
|
|
142
|
+
this.loadData();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
searchValueInitial() {
|
|
147
|
+
fetch(`${this.endpoint}/${this.value}`)
|
|
148
|
+
.then(response => response.json())
|
|
149
|
+
.then(json => this.registerText(json))
|
|
150
|
+
.catch(error => this.registerError(error));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
registerText(json) {
|
|
154
|
+
this.selectedText = json[this.displayProperty];
|
|
155
|
+
this.loading = false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
get search() {
|
|
160
|
+
return this.shadowRoot.getElementById('search');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
get select() {
|
|
164
|
+
return this.shadowRoot.getElementById('elselect');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
render() {
|
|
168
|
+
return html`
|
|
169
|
+
<div>
|
|
170
|
+
${this.label
|
|
171
|
+
? html`<label for="textField">${this.label}</label>`
|
|
172
|
+
: ""}
|
|
173
|
+
${this.isSelected
|
|
174
|
+
? this.selectedTemplate
|
|
175
|
+
: this.static ? this.loadingOrLoadedTemplate : this.searchTemplate
|
|
176
|
+
}
|
|
177
|
+
</div>
|
|
178
|
+
`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
get selectedTemplate() {
|
|
182
|
+
return html`
|
|
183
|
+
<dile-input-search
|
|
184
|
+
id="result"
|
|
185
|
+
?errored=${this.errored}
|
|
186
|
+
?disabled=${this.disabled}
|
|
187
|
+
value="${this.selectedText}"
|
|
188
|
+
readOnly
|
|
189
|
+
@dile-input-search-cleared=${this.onClearSelected}
|
|
190
|
+
></dile-input-search>
|
|
191
|
+
`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
get searchTemplate() {
|
|
195
|
+
return html`
|
|
196
|
+
<dile-input-search
|
|
197
|
+
id="search"
|
|
198
|
+
placeholder="${this.placeholder}"
|
|
199
|
+
label="${this.label}"
|
|
200
|
+
?errored=${this.errored}
|
|
201
|
+
?disabled=${this.disabled}
|
|
202
|
+
@focus=${this.onFocus}
|
|
203
|
+
@dile-input-search=${this.onTextInput}
|
|
204
|
+
delay="${this.delay}"
|
|
205
|
+
></dile-input-search>
|
|
206
|
+
<div class="anchor">
|
|
207
|
+
<section class="${this.opened && this.keyword.length > 0 ? 'opened' : ''}">
|
|
208
|
+
${this.loadingOrLoadedTemplate}
|
|
209
|
+
</section>
|
|
210
|
+
</div>
|
|
211
|
+
`;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
get loadingOrLoadedTemplate() {
|
|
215
|
+
return html`
|
|
216
|
+
${this.loading
|
|
217
|
+
? this.loadingTemplate
|
|
218
|
+
: this.loadedTemplate
|
|
219
|
+
}
|
|
220
|
+
`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
get loadingTemplate() {
|
|
224
|
+
return html`<dile-spinner-horizontal active></dile-spinner-horizontal>`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
get loadedTemplate() {
|
|
228
|
+
return html`
|
|
229
|
+
${this.ajaxError
|
|
230
|
+
? html`<p>${this.ajaxErrorMessage}</p>`
|
|
231
|
+
: html`
|
|
232
|
+
${this.data.length == 0
|
|
233
|
+
? this.emptyTemplate
|
|
234
|
+
: this.dataTemplate
|
|
235
|
+
}
|
|
236
|
+
`
|
|
237
|
+
}
|
|
238
|
+
`;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
get emptyTemplate() {
|
|
242
|
+
return html`
|
|
243
|
+
<p>
|
|
244
|
+
${this.emptyMessage}
|
|
245
|
+
</p>
|
|
246
|
+
`;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
get dataTemplate() {
|
|
250
|
+
return html`
|
|
251
|
+
<dile-select
|
|
252
|
+
id="elselect"
|
|
253
|
+
@element-changed=${this.doSelected}
|
|
254
|
+
name="generated-select-field"
|
|
255
|
+
>
|
|
256
|
+
<select slot="select">
|
|
257
|
+
<option value="">${this.selectDefaultPlaceholder}</option>
|
|
258
|
+
${this.data.map(item => html`
|
|
259
|
+
<option value="${item[this.idProperty]}">${item[this.displayProperty]}</option>
|
|
260
|
+
`)}
|
|
261
|
+
</select>
|
|
262
|
+
</dile-select>
|
|
263
|
+
`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
onFocus() {
|
|
267
|
+
this.opened = true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
onTextInput(e) {
|
|
271
|
+
this.keyword = e.detail.keyword;
|
|
272
|
+
this.loadData();
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
loadData() {
|
|
276
|
+
this.loading = true;
|
|
277
|
+
this.ajaxError = false;
|
|
278
|
+
fetch(`${this.endpoint}?${this.queryStringVariable}=${this.keyword}`)
|
|
279
|
+
.then(response => response.json())
|
|
280
|
+
.then(json => this.registerData(json))
|
|
281
|
+
.catch(error => this.registerError(error));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
registerError(err) {
|
|
285
|
+
this.ajaxError = true;
|
|
286
|
+
this.loading = false;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
registerData(json) {
|
|
290
|
+
if(this.resultDataProperty === undefined || this.resultDataProperty === '') {
|
|
291
|
+
this.data = json;
|
|
292
|
+
} else {
|
|
293
|
+
this.data = json[this.resultDataProperty];
|
|
294
|
+
}
|
|
295
|
+
this.updateComplete.then( () => this.loading = false )
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
doSelected(e) {
|
|
299
|
+
let value = e.detail.value;
|
|
300
|
+
if(e.detail.name === 'generated-select-field' && value !== '') {
|
|
301
|
+
this.selectedText = this.select.getOptionByValue(value).innerText;
|
|
302
|
+
this.value = value;
|
|
303
|
+
this.isSelected = true;
|
|
304
|
+
}
|
|
305
|
+
e.stopPropagation();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
onClearSelected() {
|
|
309
|
+
this.value = undefined;
|
|
310
|
+
this.isSelected = false;
|
|
311
|
+
if(! this.static) {
|
|
312
|
+
this.keyword = '';
|
|
313
|
+
this.selectedText = '';
|
|
314
|
+
this.data = [];
|
|
315
|
+
this.updateComplete.then(() => {
|
|
316
|
+
this.search.focus();
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
close() {
|
|
322
|
+
this.opened = false;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
clear() {
|
|
326
|
+
this.isSelected = false;
|
|
327
|
+
this.value = undefined;
|
|
328
|
+
this.selectedText = '';
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
set(value) {
|
|
332
|
+
this.value = value;
|
|
333
|
+
if(value) {
|
|
334
|
+
this.isSelected = true;
|
|
335
|
+
this.searchValueInitial();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { html, css, LitElement } from "lit";
|
|
2
|
+
import { DileSelectable } from "../../../mixins/selectable/index.js";
|
|
3
|
+
|
|
4
|
+
export class DileSelector extends DileSelectable(LitElement) {
|
|
5
|
+
static get styles() {
|
|
6
|
+
return css`
|
|
7
|
+
:host {
|
|
8
|
+
display: block;
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { html, css, LitElement } from "lit";
|
|
2
|
+
import { DileSelectableItem } from "../../../mixins/selectable/index.js";
|
|
3
|
+
|
|
4
|
+
const icons = {
|
|
5
|
+
"navigate_next": html`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/></svg>`,
|
|
6
|
+
"arrow_forward": html`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"/></svg>`,
|
|
7
|
+
"star": html`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#f26"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>`,
|
|
8
|
+
"label_important": html`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M3.5 18.99l11 .01c.67 0 1.27-.33 1.63-.84L20.5 12l-4.37-6.16c-.36-.51-.96-.84-1.63-.84l-11 .01L8.34 12 3.5 18.99z"/></svg>`,
|
|
9
|
+
"add": html`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>`,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class DileSelectorItem extends DileSelectableItem(LitElement) {
|
|
13
|
+
|
|
14
|
+
static get styles() {
|
|
15
|
+
return css`
|
|
16
|
+
:host {
|
|
17
|
+
display: block;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
}
|
|
20
|
+
article {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
padding-top: var(--dile-selector-padding-y, 0.2rem);
|
|
24
|
+
padding-bottom: var(--dile-selector-padding-y, 0.2rem);
|
|
25
|
+
padding-left: var(--dile-selector-padding-x, 0.5rem);
|
|
26
|
+
padding-right: var(--dile-selector-padding-x, 0.5rem);
|
|
27
|
+
background-color: var(--dile-selector-background-color, transparent);
|
|
28
|
+
color: var(--dile-selector-text-color, #000);
|
|
29
|
+
transition: all 0.3s ease-in;
|
|
30
|
+
}
|
|
31
|
+
.selected {
|
|
32
|
+
background-color: var(--dile-selector-selected-background-color, #039be5);
|
|
33
|
+
color: var(--dile-selector-selected-text-color, #fff);
|
|
34
|
+
font-weight: var(--dile-selector-selected-font-weight, normal);
|
|
35
|
+
border-radius: var(--dile-selector-selected-border-radius, 0);
|
|
36
|
+
}
|
|
37
|
+
.icon {
|
|
38
|
+
margin-right: 0.3rem;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
}
|
|
42
|
+
.icon svg {
|
|
43
|
+
color: red;
|
|
44
|
+
fill: var(--dile-selector-icon-color, #039be5);
|
|
45
|
+
width: var(--dile-selector-icon-size, 20px);
|
|
46
|
+
height: var(--dile-selector-icon-size, 20px);
|
|
47
|
+
}
|
|
48
|
+
.selected .icon svg {
|
|
49
|
+
fill: var(--dile-selector-selected-icon-color, #fff);
|
|
50
|
+
}
|
|
51
|
+
a {
|
|
52
|
+
display: block;
|
|
53
|
+
text-decoration: var(--dile-selector-text-decoration, none);
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static get properties() {
|
|
59
|
+
return {
|
|
60
|
+
icon: { type: String },
|
|
61
|
+
href: { type: String },
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
constructor() {
|
|
66
|
+
super();
|
|
67
|
+
this.href = '';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
render() {
|
|
71
|
+
return html`
|
|
72
|
+
${this.href == ''
|
|
73
|
+
? this.itemTemplate
|
|
74
|
+
: html`<a href="${this.href}">${this.itemTemplate}</a>`
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get itemTemplate() {
|
|
80
|
+
return html`
|
|
81
|
+
<article @click='${this.select}' class="${this.selected ? 'selected' : ''}">
|
|
82
|
+
${this.icon
|
|
83
|
+
? html`<div class="icon">${this.iconElement(this.icon)}</div>`
|
|
84
|
+
: ''
|
|
85
|
+
}
|
|
86
|
+
<div class="line"><slot></slot></div>
|
|
87
|
+
</article>
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
iconElement(icon) {
|
|
91
|
+
return icons[icon];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DileSlideShow } from './src/DileSlideShow.js';
|