@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,178 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export class DilePages extends LitElement {
|
|
4
|
+
static get properties() {
|
|
5
|
+
return {
|
|
6
|
+
/** Attribute in the page element, to match the selected property value */
|
|
7
|
+
attrForSelected: { type: String },
|
|
8
|
+
/** Set the selected page */
|
|
9
|
+
selected: { type: String },
|
|
10
|
+
/** A selector interface to change the tabs */
|
|
11
|
+
selectorId: { type: String },
|
|
12
|
+
/** Display to the element that is shown */
|
|
13
|
+
showDisplay: { type: String },
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
render() {
|
|
17
|
+
return html`
|
|
18
|
+
<slot></slot>
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.transitionTime = 1000;
|
|
25
|
+
this.selected = 0;
|
|
26
|
+
this._pageInitialization();
|
|
27
|
+
this._onSelectorIdChangedHandler = this._onSelectorIdChanged.bind(this);
|
|
28
|
+
this.showDisplay = 'block';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static get styles() {
|
|
32
|
+
return css`
|
|
33
|
+
:host {
|
|
34
|
+
display: block;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Private method to process the light DOM and it's elements, creating and updating necesary styles
|
|
40
|
+
*
|
|
41
|
+
* @return {void}
|
|
42
|
+
*/
|
|
43
|
+
_pageInitialization() {
|
|
44
|
+
this.pages = [];
|
|
45
|
+
|
|
46
|
+
let pages = this.children;
|
|
47
|
+
for (let ele of pages) {
|
|
48
|
+
ele.style.display = 'none';
|
|
49
|
+
ele.style.transition = `opacity ${this.transitionTime}ms`;
|
|
50
|
+
ele.style.opacity = '0';
|
|
51
|
+
this.pages.push(ele);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Call this method to attach other HTML in the component, to use it as pages, instead of the light DOM
|
|
57
|
+
*
|
|
58
|
+
* @return {void}
|
|
59
|
+
*/
|
|
60
|
+
initializeExternalPages(htmlElements) {
|
|
61
|
+
this.innerHTML = htmlElements;
|
|
62
|
+
this._pageInitialization();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Livecycle method to ensure the view of the correct page in start
|
|
67
|
+
*
|
|
68
|
+
* @return {void}
|
|
69
|
+
*/
|
|
70
|
+
firstUpdated() {
|
|
71
|
+
let page = this._selectPage(this.selected, this.attrForSelected);
|
|
72
|
+
if (page) {
|
|
73
|
+
page.style.display = this.showDisplay;
|
|
74
|
+
}
|
|
75
|
+
if(this.selectorId) {
|
|
76
|
+
document.addEventListener('dile-selected-changed', this._onSelectorIdChangedHandler);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
disconnectedCallback() {
|
|
81
|
+
super.disconnectedCallback();
|
|
82
|
+
if(this.selectorId) {
|
|
83
|
+
document.removeEventListener('dile-selected-changed', this._onSelectorIdChangedHandler);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Livecycle method. Listening changes in selected and attrForSelected properties
|
|
89
|
+
*
|
|
90
|
+
* @return {void}
|
|
91
|
+
*/
|
|
92
|
+
updated(changedProperties) {
|
|
93
|
+
if (this._updatedAndNotUndefined(changedProperties, 'selected') || this._updatedAndNotUndefined(changedProperties, 'attrForSelected')) {
|
|
94
|
+
let lastSelected = this._getLastValueProperty(changedProperties, 'selected');
|
|
95
|
+
let lastAttrForSelected = this._getLastValueProperty(changedProperties, 'attrForSelected');
|
|
96
|
+
this.hidePage(lastSelected, lastAttrForSelected);
|
|
97
|
+
}
|
|
98
|
+
this._showCurrentPage();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Private method to get the current active page
|
|
103
|
+
*
|
|
104
|
+
* @return {page}
|
|
105
|
+
*/
|
|
106
|
+
_selectPage(selected, attrForSelected) {
|
|
107
|
+
let page;
|
|
108
|
+
if (!attrForSelected) {
|
|
109
|
+
page = this.pages[selected];
|
|
110
|
+
} else {
|
|
111
|
+
for (let ele of this.pages) {
|
|
112
|
+
if (ele.getAttribute(attrForSelected) == selected) {
|
|
113
|
+
page = ele;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return page;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Private method to show the current active page
|
|
123
|
+
*
|
|
124
|
+
* @return {page}
|
|
125
|
+
*/
|
|
126
|
+
_showCurrentPage() {
|
|
127
|
+
let page = this._selectPage(this.selected, this.attrForSelected)
|
|
128
|
+
if (page) {
|
|
129
|
+
page.style.display = this.showDisplay;
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
page.style.opacity = '1';
|
|
132
|
+
}, 50);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Hide a page, sending arbitrary data as parameters.
|
|
138
|
+
*
|
|
139
|
+
* @param {selected} the page to hide
|
|
140
|
+
* @param {attrForSelected} the attribute to match the selected value
|
|
141
|
+
* @return {void}
|
|
142
|
+
*/
|
|
143
|
+
hidePage(selected, attrForSelected) {
|
|
144
|
+
let page = this._selectPage(selected, attrForSelected)
|
|
145
|
+
if (page) {
|
|
146
|
+
page.style.display = 'none';
|
|
147
|
+
page.style.opacity = '0';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Private method to know when a property is changed, and its value is not undefined
|
|
153
|
+
*
|
|
154
|
+
* @param {changedProperties} map of the properties changed (same as you get in updated livecycle method)
|
|
155
|
+
* @param {field} the name of the property you need to know is updated
|
|
156
|
+
* @return {boolean}
|
|
157
|
+
*/
|
|
158
|
+
_updatedAndNotUndefined(changedProperties, field) {
|
|
159
|
+
return (changedProperties.has(field) && changedProperties.get(field) != undefined)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Private method to get the last value of a property
|
|
164
|
+
*
|
|
165
|
+
* @param {changedProperties} map of the properties changed (same as you get in updated livecycle method)
|
|
166
|
+
* @param {field} the name of the property you need to know it's last value
|
|
167
|
+
* @return {boolean}
|
|
168
|
+
*/
|
|
169
|
+
_getLastValueProperty(changedProperties, field) {
|
|
170
|
+
return (changedProperties.has(field)) ? changedProperties.get(field) : this[field];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_onSelectorIdChanged(e) {
|
|
174
|
+
if(e.detail.selectorId == this.selectorId) {
|
|
175
|
+
this.selected = e.detail.selected;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DilePassword } from './src/DilePassword.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LitElement, html } from 'lit';
|
|
2
|
+
import { DileInput } from '../../input/index.js';
|
|
3
|
+
|
|
4
|
+
export class DilePassword extends DileInput {
|
|
5
|
+
|
|
6
|
+
render() {
|
|
7
|
+
return html`
|
|
8
|
+
<div>
|
|
9
|
+
${this.label
|
|
10
|
+
? html`<label for="textField">${this.label}</label>`
|
|
11
|
+
: ''
|
|
12
|
+
}
|
|
13
|
+
<section class="for-input">
|
|
14
|
+
<input
|
|
15
|
+
type="password"
|
|
16
|
+
id="textField"
|
|
17
|
+
name="${this.name}"
|
|
18
|
+
placeholder="${this.placeholder}"
|
|
19
|
+
?disabled="${this.disabled}"
|
|
20
|
+
@keypress="${this._lookForEnter}"
|
|
21
|
+
@input="${this._input}"
|
|
22
|
+
.value="${this.value}"
|
|
23
|
+
class="${ this.errored ? 'errored' : '' }"
|
|
24
|
+
>
|
|
25
|
+
</section>
|
|
26
|
+
${this.message
|
|
27
|
+
? html`<div class="message ${this.errored ? 'errored-msg' : ''}"><span>${this.message}</span></div>`
|
|
28
|
+
: ''
|
|
29
|
+
}
|
|
30
|
+
</div>
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DileProgressBar } from './src/DileProgressBar.js';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
|
|
3
|
+
export class DileProgressBar extends LitElement {
|
|
4
|
+
static get styles() {
|
|
5
|
+
return css`
|
|
6
|
+
.progress-bar-title {
|
|
7
|
+
margin-top: var(--dile-progress-bar-title-margin-top, 0px);
|
|
8
|
+
margin-right: var(--dile-progress-bar-title-margin-right, 0px);
|
|
9
|
+
margin-bottom: var(--dile-progress-bar-title-margin-bottom, 10px);
|
|
10
|
+
margin-left: var(--dile-progress-bar-title-margin-left, 0px);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.progress {
|
|
14
|
+
background: var(--dile-progress-background, #e9ecef);
|
|
15
|
+
border-radius: var(--dile-progress-border-radius, 20px);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.progress-bar {
|
|
19
|
+
min-height: var(--dile-progress-bar-min-height, 20px);
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: var(--dile-progress-bar-align, flex-start);
|
|
22
|
+
background: var(--dile-progress-bar-background, #b8b9b9);
|
|
23
|
+
border-radius: var(--dile-progress-bar-border-radius, 20px);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.progress-bar span {
|
|
27
|
+
font-size: var(--dile-progress-bar-percentage-font-size, 14px);
|
|
28
|
+
font-weight: var(--dile-progress-bar-percentage-font-weight, 500);
|
|
29
|
+
color: var(--dile-progress-bar-percentage-color, #eaeaea);
|
|
30
|
+
padding-top: var(--dile-progres-bar-percentage-padding-top, 6px);
|
|
31
|
+
padding-right: var(--dile-progres-bar-percentage-padding-right, 6px);
|
|
32
|
+
padding-bottom: var(--dile-progres-bar-percentage-padding-bottom, 6px);
|
|
33
|
+
padding-left: var(--dile-progres-bar-percentage-padding-left, 10px);
|
|
34
|
+
transition: 5s width;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.progress-bar.animated {
|
|
38
|
+
animation: progress 1500ms ease-in 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@keyframes progress {
|
|
42
|
+
from {
|
|
43
|
+
width: 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static properties = {
|
|
50
|
+
title: { type: String },
|
|
51
|
+
value: { type: Number },
|
|
52
|
+
animated: { type: Boolean },
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
constructor() {
|
|
56
|
+
super();
|
|
57
|
+
this.title = "";
|
|
58
|
+
this.value = "80";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
render() {
|
|
62
|
+
return html` ${this.titleTemplate} ${this.progressTemplate} `;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get titleTemplate() {
|
|
66
|
+
return this.title
|
|
67
|
+
? html`<p class="progress-bar-title">${this.title}</p>`
|
|
68
|
+
: "";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get valueTemplate() {
|
|
72
|
+
return this.value
|
|
73
|
+
? html`<span>${this.value}%</span>`
|
|
74
|
+
: "";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get progressTemplate() {
|
|
78
|
+
return html`
|
|
79
|
+
<div class="progress">
|
|
80
|
+
<div
|
|
81
|
+
class="progress-bar ${this.animated ? "animated" : ""}"
|
|
82
|
+
style="width: ${this.value}%;"
|
|
83
|
+
>
|
|
84
|
+
${this.valueTemplate}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { radioCheckedIcon, circleBorderIcon } from '@dile/icons/index.js';
|
|
3
|
+
import '../../icon/icon.js';
|
|
4
|
+
|
|
5
|
+
export class DileRadio extends LitElement {
|
|
6
|
+
static styles = [
|
|
7
|
+
css`
|
|
8
|
+
:host {
|
|
9
|
+
display: block;
|
|
10
|
+
}
|
|
11
|
+
article {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
}
|
|
15
|
+
.radio {
|
|
16
|
+
margin-right: var(--dile-radio-space-between-label-and-icon, 0.4rem);
|
|
17
|
+
display: flex;
|
|
18
|
+
--dile-icon-size: var(--dile-radio-icon-size, 1.2rem);
|
|
19
|
+
--dile-icon-color: var(--dile-radio-icon-color, #303030);
|
|
20
|
+
}
|
|
21
|
+
.label {
|
|
22
|
+
font-size: var(--dile-radio-label-font-size, 1rem);
|
|
23
|
+
color: var(--dile-radio-label-color, #303030);
|
|
24
|
+
}
|
|
25
|
+
:host([selected]) .radio {
|
|
26
|
+
--dile-icon-color: var(--dile-radio-selected-icon-color, var(--dile-radio-icon-color, #303030));
|
|
27
|
+
}
|
|
28
|
+
:host([selected]) .label {
|
|
29
|
+
color: var(--dile-radio-selected-label-color, var(--dile-radio-label-color, #303030));
|
|
30
|
+
}
|
|
31
|
+
`
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
static get properties() {
|
|
35
|
+
return {
|
|
36
|
+
label: { type: String },
|
|
37
|
+
value: { type: String },
|
|
38
|
+
selected: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
reflect: true
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
constructor() {
|
|
46
|
+
super();
|
|
47
|
+
this.label = '';
|
|
48
|
+
this.value = '';
|
|
49
|
+
this.selected = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
return html`
|
|
54
|
+
<article @click=${this.select}>
|
|
55
|
+
<span class="radio">
|
|
56
|
+
<dile-icon .icon="${this.computeIcon(this.selected)}"></dile-icon>
|
|
57
|
+
</span>
|
|
58
|
+
<span class="label">
|
|
59
|
+
${this.label}
|
|
60
|
+
</span>
|
|
61
|
+
</article>
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
select() {
|
|
66
|
+
this.dispatchEvent(new CustomEvent('dile-radio-selected', {
|
|
67
|
+
bubbles: true,
|
|
68
|
+
composed: true,
|
|
69
|
+
detail: {
|
|
70
|
+
value: this.value,
|
|
71
|
+
label: this.label
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
computeIcon(selected) {
|
|
77
|
+
return selected ? radioCheckedIcon : circleBorderIcon;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
3
|
+
|
|
4
|
+
export class DileRadioGroup extends DileEmmitChange(LitElement) {
|
|
5
|
+
static styles = [
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
display: block;
|
|
9
|
+
margin-bottom: 10px;
|
|
10
|
+
}
|
|
11
|
+
.label {
|
|
12
|
+
display: block;
|
|
13
|
+
margin-bottom: var(--dile-input-label-margin-bottom, 4px);
|
|
14
|
+
font-size: var(--dile-input-label-font-size, 1em);
|
|
15
|
+
color: var(--dile-input-label-color, #59e);
|
|
16
|
+
font-weight: var(--dile-input-label-font-weight, normal);
|
|
17
|
+
}
|
|
18
|
+
:host([disabled]) {
|
|
19
|
+
--dile-radio-icon-color: var(--dile-radio-disabled-icon-color, #ccc);
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
static get properties() {
|
|
25
|
+
return {
|
|
26
|
+
label: { type: String },
|
|
27
|
+
value: { type: String },
|
|
28
|
+
name: { type: String },
|
|
29
|
+
disabled: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
reflect: true
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
this.init = false;
|
|
39
|
+
this.disabled = false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
updated(changedProperties) {
|
|
43
|
+
if(changedProperties.has('value') && this.init) {
|
|
44
|
+
this.doSelection(this.value);
|
|
45
|
+
this.emmitChange();
|
|
46
|
+
this.dispatchChangeEvent();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
firstUpdated() {
|
|
51
|
+
this.init = true;
|
|
52
|
+
if(this.value !== undefined) {
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
this.doSelection(this.value);
|
|
55
|
+
}, 200);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
render() {
|
|
60
|
+
return html`
|
|
61
|
+
<div @dile-radio-selected=${this.changeValue}>
|
|
62
|
+
${this.label
|
|
63
|
+
? html`<span class="label">${this.label}</span>`
|
|
64
|
+
: ""
|
|
65
|
+
}
|
|
66
|
+
<slot></slot>
|
|
67
|
+
</div>
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
changeValue(e) {
|
|
72
|
+
if(!this.disabled) {
|
|
73
|
+
this.value = e.detail.value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
doSelection(newValue) {
|
|
78
|
+
let numSelected = 0;
|
|
79
|
+
this.querySelectorAll('dile-radio').forEach(radio => {
|
|
80
|
+
if (radio.value === newValue) {
|
|
81
|
+
radio.selected = true;
|
|
82
|
+
numSelected++;
|
|
83
|
+
} else {
|
|
84
|
+
radio.selected = false;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
if (numSelected > 1) {
|
|
88
|
+
throw new Error('More than one radio selected because have same value')
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
dispatchChangeEvent() {
|
|
93
|
+
this.dispatchEvent(new CustomEvent('dile-radio-group-changed', {
|
|
94
|
+
bubbles: true,
|
|
95
|
+
composed: true,
|
|
96
|
+
detail: {
|
|
97
|
+
name: this.name,
|
|
98
|
+
value: this.value
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DileRange } from './src/DileRange.js';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { DileEmmitChange } from '../../../mixins/form/index.js';
|
|
3
|
+
|
|
4
|
+
export class DileRange extends DileEmmitChange(LitElement) {
|
|
5
|
+
|
|
6
|
+
static get styles() {
|
|
7
|
+
return css`
|
|
8
|
+
:host {
|
|
9
|
+
display: block;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/*********** Baseline, reset styles ***********/
|
|
13
|
+
input[type="range"] {
|
|
14
|
+
-webkit-appearance: none;
|
|
15
|
+
-moz-appearance: none;
|
|
16
|
+
appearance: none;
|
|
17
|
+
background: transparent;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Removes default focus */
|
|
23
|
+
input[type="range"]:focus {
|
|
24
|
+
outline: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/******** Chrome, Safari, Opera and Edge Chromium styles ********/
|
|
28
|
+
/* slider track */
|
|
29
|
+
input[type="range"]::-webkit-slider-runnable-track {
|
|
30
|
+
background-color: var(--dile-range-line-color, #7BB93D);
|
|
31
|
+
border-radius: 0.5rem;
|
|
32
|
+
height: var(--dile-range-line-height, 0.5rem);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* slider thumb */
|
|
36
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
37
|
+
-webkit-appearance: none; /* Override default look */
|
|
38
|
+
appearance: none;
|
|
39
|
+
margin-top: var(--dile-range-thumb-margin-top, -8px); /* Centers thumb on the track */
|
|
40
|
+
background-color: var(--dile-range-thumb-color, #303030);
|
|
41
|
+
border-radius: var(--dile-range-thumb-border-radius, 2rem);
|
|
42
|
+
height: var(--dile-range-thumb-height, 1.5rem);
|
|
43
|
+
width: var(--dile-range-thumb-width, 1.5rem);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
input[type="range"]:focus::-webkit-slider-thumb {
|
|
47
|
+
outline: 3px solid var(--dile-range-thumb-color, #303030);
|
|
48
|
+
outline-offset: 0.125rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/*********** Firefox styles ***********/
|
|
52
|
+
/* slider track */
|
|
53
|
+
input[type="range"]::-moz-range-track {
|
|
54
|
+
background-color: var(--dile-range-line-color, #7BB93D);
|
|
55
|
+
border-radius: 0.5rem;
|
|
56
|
+
height: var(--dile-range-line-height, 0.5rem);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* slider thumb */
|
|
60
|
+
input[type="range"]::-moz-range-thumb {
|
|
61
|
+
background-color: var(--dile-range-thumb-color, #303030);
|
|
62
|
+
border: none; /*Removes extra border that FF applies*/
|
|
63
|
+
border-radius: var(--dile-range-thumb-border-radius, 2rem);
|
|
64
|
+
height: var(--dile-range-thumb-height, 1.5rem);
|
|
65
|
+
width: var(--dile-range-thumb-width, 1.5rem);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
input[type="range"]:focus::-moz-range-thumb{
|
|
69
|
+
outline: 3px solid var(--dile-range-thumb-color, #303030);
|
|
70
|
+
outline-offset: 0.125rem;
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static get properties() {
|
|
76
|
+
return {
|
|
77
|
+
max: { type: Number },
|
|
78
|
+
min: { type: Number },
|
|
79
|
+
step: { type: Number },
|
|
80
|
+
value: { type: Number },
|
|
81
|
+
name: { type: String },
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
constructor() {
|
|
86
|
+
super();
|
|
87
|
+
this.name = "";
|
|
88
|
+
this.max = 10;
|
|
89
|
+
this.min = 0;
|
|
90
|
+
this.step = 1;
|
|
91
|
+
this.value = 1;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
render() {
|
|
95
|
+
return html`
|
|
96
|
+
<input
|
|
97
|
+
type="range"
|
|
98
|
+
id="${this.name}"
|
|
99
|
+
name="${this.name}"
|
|
100
|
+
min="${this.min}"
|
|
101
|
+
max="${this.max}"
|
|
102
|
+
step="${this.step}"
|
|
103
|
+
value="${this.value}"
|
|
104
|
+
@input="${this.rangeChanged}"
|
|
105
|
+
>
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
rangeChanged(e) {
|
|
110
|
+
this.value = e.target.value;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
updated(changedProperties) {
|
|
114
|
+
if (changedProperties.has('value')) {
|
|
115
|
+
this.emmitChange();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DileRating } from './src/DileRating.js';
|