@dile/ui 3.4.4 → 3.4.6
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/components/accordion/accordion-item.js +3 -1
- package/components/accordion/accordion.js +3 -1
- package/components/app-drawer/app-drawer.js +3 -1
- package/components/avatar/avatar.js +3 -1
- package/components/avatar/avatar.spec.js +25 -0
- package/components/box-selector/box-selector-item.js +3 -1
- package/components/box-selector/box-selector-item.spec.js +27 -0
- package/components/box-selector/box-selector.js +3 -1
- package/components/box-selector/box-selector.spec.js +27 -0
- package/components/breadcrumbs/breadcrumbs-item.js +3 -1
- package/components/breadcrumbs/breadcrumbs-item.spec.js +28 -0
- package/components/breadcrumbs/breadcrumbs.js +3 -1
- package/components/breadcrumbs/breadcrumbs.spec.js +33 -0
- package/components/button/__screenshots__/button.spec.js/dile-button-Native-form-submission--DEBUG---timing-probe--does-not-leak-a-stale-value-when-the-form-is-submitted-again-without-a-button-click-1.png +0 -0
- package/components/button/__screenshots__/button.spec.js/dile-button-Native-form-submission--DEBUG---timing-probe--includes-name-value-in-the-formdata-event-entry-list-when-clicked-1.png +0 -0
- package/components/button/__screenshots__/button.spec.js/dile-button-Native-form-submission--DEBUG---timing-probe--includes-name-value-when-read-synchronously-inside-the-submit-listener-1.png +0 -0
- package/components/button/__screenshots__/button.spec.js/dile-button-Native-form-submission--DEBUG---timing-probe--only-includes-the-clicked-button-among-two-submit-buttons-with-different-values-1.png +0 -0
- package/components/button/button-icon.js +3 -1
- package/components/button/button.js +3 -1
- package/components/button/button.spec.js +134 -0
- package/components/button/src/DileButton.js +8 -2
- package/components/card/card-slide.js +3 -1
- package/components/card/card-slide.spec.js +30 -0
- package/components/card/card.js +3 -1
- package/components/card/card.spec.js +26 -0
- package/components/checkbox/checkbox.js +3 -1
- package/components/checkbox/checkbox.spec.js +235 -0
- package/components/checkbox/src/DileCheckbox.js +27 -15
- package/components/chip/chip.js +3 -1
- package/components/chip/chip.spec.js +31 -0
- package/components/color-picker/color-picker.js +3 -1
- package/components/color-picker/color-picker.spec.js +16 -0
- package/components/color-picker/src/DileColorPicker.js +1 -1
- package/components/confirm/confirm.js +3 -1
- package/components/confirm/confirm.spec.js +32 -0
- package/components/confirm-text/confirm-text.js +3 -1
- package/components/confirm-text/confirm-text.spec.js +29 -0
- package/components/copy-markdown-url/copy-markdown-url.spec.js +27 -0
- package/components/copy-markdown-url/index.js +3 -1
- package/components/copy-text/__screenshots__/copy-text.spec.js/dile-copy-text-dispatches-dile-text-copied-with-the-content-on-copy---1.png +0 -0
- package/components/copy-text/copy-text.spec.js +38 -0
- package/components/copy-text/index.js +3 -1
- package/components/drop-file/drop-file.js +3 -1
- package/components/drop-file/drop-file.spec.js +33 -0
- package/components/drop-file/file-preview.js +3 -1
- package/components/drop-file/file-preview.spec.js +35 -0
- package/components/drop-file/src/DileDropFile.js +1 -1
- package/components/floating-feedback/floating-feedback.spec.js +30 -0
- package/components/floating-feedback/index.js +3 -1
- package/components/floating-menu/floating-menu-item.js +3 -1
- package/components/floating-menu/floating-menu-item.spec.js +27 -0
- package/components/floating-menu/floating-menu.js +3 -1
- package/components/floating-menu/floating-menu.spec.js +31 -0
- package/components/form-separator/form-separator.js +3 -1
- package/components/form-separator/form-separator.spec.js +28 -0
- package/components/hamburger/hamburger.js +3 -1
- package/components/hamburger/hamburger.spec.js +28 -0
- package/components/icon/icon.js +3 -1
- package/components/icon/icon.spec.js +31 -0
- package/components/icon-switch/icon-switch-group.js +3 -1
- package/components/icon-switch/icon-switch-group.spec.js +46 -0
- package/components/icon-switch/icon-switch.js +3 -1
- package/components/icon-switch/icon-switch.spec.js +35 -0
- package/components/info-box/info-box.js +3 -1
- package/components/info-box/info-box.spec.js +38 -0
- package/components/inline-feedback/inline-feedback.js +3 -1
- package/components/inline-feedback/inline-feedback.spec.js +46 -0
- package/components/input/__screenshots__/input-number-mask.spec.js/dile-input-number-mask-masks-digit-keydowns-following-the-given-pattern-1.png +0 -0
- package/components/input/input-contact.js +3 -1
- package/components/input/input-contact.spec.js +32 -0
- package/components/input/input-integer.js +3 -1
- package/components/input/input-integer.spec.js +31 -0
- package/components/input/input-message.js +3 -1
- package/components/input/input-message.spec.js +27 -0
- package/components/input/input-money.js +3 -1
- package/components/input/input-money.spec.js +30 -0
- package/components/input/input-number-mask.js +3 -1
- package/components/input/input-number-mask.spec.js +32 -0
- package/components/input/input-percentage.js +3 -1
- package/components/input/input-percentage.spec.js +31 -0
- package/components/input/input-search.js +3 -1
- package/components/input/input-search.spec.js +39 -0
- package/components/input/input.js +3 -1
- package/components/input/input.spec.js +47 -0
- package/components/input/src/DileInput.js +1 -1
- package/components/light-mode-switch/light-mode-switch.js +3 -1
- package/components/light-mode-switch/light-mode-switch.spec.js +34 -0
- package/components/menu-hamburger/menu-hamburger.js +3 -1
- package/components/menu-hamburger/menu-hamburger.spec.js +34 -0
- package/components/menu-overlay/menu-overlay.js +3 -1
- package/components/menu-overlay/menu-overlay.spec.js +44 -0
- package/components/message/message.js +3 -1
- package/components/message/message.spec.js +42 -0
- package/components/modal/__screenshots__/modal-help.spec.js/dile-modal-help-opens-the-inner-modal-on-open---1.png +0 -0
- package/components/modal/modal-help.js +3 -1
- package/components/modal/modal-help.spec.js +32 -0
- package/components/modal/modal.js +3 -1
- package/components/modal/modal.spec.js +46 -0
- package/components/nav/nav.js +3 -1
- package/components/nav/nav.spec.js +33 -0
- package/components/number-picker/number-picker-element.js +3 -1
- package/components/number-picker/number-picker-element.spec.js +30 -0
- package/components/number-picker/number-picker.js +3 -1
- package/components/number-picker/number-picker.spec.js +30 -0
- package/components/number-picker/src/DileNumberPicker.js +1 -1
- package/components/order-switch/order-switch.js +3 -1
- package/components/order-switch/order-switch.spec.js +31 -0
- package/components/otp-input/otp-input.js +3 -1
- package/components/otp-input/otp-input.spec.js +41 -0
- package/components/otp-input/src/DileOtpInput.js +1 -1
- package/components/pages/pages.js +3 -1
- package/components/pages/pages.spec.js +44 -0
- package/components/password/password.js +3 -1
- package/components/password/password.spec.js +35 -0
- package/components/progress-bar/progress-bar.js +3 -1
- package/components/progress-bar/progress-bar.spec.js +28 -0
- package/components/radio-group/radio-group.js +3 -1
- package/components/radio-group/radio-group.spec.js +44 -0
- package/components/radio-group/radio.js +3 -1
- package/components/radio-group/radio.spec.js +32 -0
- package/components/radio-group/src/DileRadioGroup.js +1 -1
- package/components/range/range.js +3 -1
- package/components/range/range.spec.js +36 -0
- package/components/range/src/DileRange.js +1 -1
- package/components/rating/rating.js +3 -1
- package/components/rating/rating.spec.js +34 -0
- package/components/rating/star.js +3 -1
- package/components/rating/star.spec.js +30 -0
- package/components/rating-scale-question/rating-scale-option.js +3 -1
- package/components/rating-scale-question/rating-scale-option.spec.js +32 -0
- package/components/rating-scale-question/rating-scale-question.js +3 -1
- package/components/rating-scale-question/rating-scale-question.spec.js +35 -0
- package/components/select/select-ajax.js +3 -1
- package/components/select/select-boolean.js +3 -1
- package/components/select/select.js +3 -1
- package/components/select/select.spec.js +39 -0
- package/components/select/src/DileSelect.js +1 -1
- package/components/select/src/DileSelectAjax.js +1 -1
- package/components/select/src/DileSelectBoolean.js +1 -1
- package/components/selector/selector-item.js +3 -1
- package/components/selector/selector-item.spec.js +40 -0
- package/components/selector/selector-overlay.js +3 -1
- package/components/selector/selector.js +3 -1
- package/components/selector/selector.spec.js +45 -0
- package/components/slide-menu/slide-menu.js +3 -1
- package/components/slide-menu/slide-menu.spec.js +38 -0
- package/components/slide-show/slide-show.js +3 -1
- package/components/slide-show/slide-show.spec.js +34 -0
- package/components/social-icon/social-icon.js +3 -1
- package/components/social-icon/social-icon.spec.js +26 -0
- package/components/spinner/spinner-bar.js +3 -1
- package/components/spinner/spinner-bar.spec.js +26 -0
- package/components/spinner/spinner-block.js +3 -1
- package/components/spinner/spinner-block.spec.js +21 -0
- package/components/spinner/spinner-horizontal.js +3 -1
- package/components/spinner/spinner-horizontal.spec.js +25 -0
- package/components/spinner/spinner-icon.js +3 -1
- package/components/spinner/spinner-icon.spec.js +25 -0
- package/components/spinner/spinner-modal.js +3 -1
- package/components/spinner/spinner-modal.spec.js +26 -0
- package/components/spinner/spinner.js +3 -1
- package/components/spinner/spinner.spec.js +26 -0
- package/components/switch/switch.js +3 -1
- package/components/switch/switch.spec.js +33 -0
- package/components/tabs/tab.js +3 -1
- package/components/tabs/tabs.js +3 -1
- package/components/tabs/tabs.spec.js +45 -0
- package/components/textarea/src/DileTextarea.js +1 -1
- package/components/textarea/textarea.js +3 -1
- package/components/textarea/textarea.spec.js +39 -0
- package/components/time-picker/src/DileTimePicker.js +1 -1
- package/components/time-picker/time-picker.js +3 -1
- package/components/time-picker/time-picker.spec.js +26 -0
- package/components/timer/timer.js +3 -1
- package/components/timer/timer.spec.js +31 -0
- package/components/toast/toast-item.js +3 -1
- package/components/toast/toast-persistent.js +3 -1
- package/components/toast/toast.js +3 -1
- package/components/tooltip/chip-tooltip.js +3 -1
- package/components/tooltip/chip-tooltip.spec.js +29 -0
- package/components/tooltip/tooltip.js +3 -1
- package/components/tooltip/tooltip.spec.js +32 -0
- package/components/web-visor/web-visor.js +3 -1
- package/components/web-visor/web-visor.spec.js +32 -0
- package/package.json +3 -3
|
@@ -35,7 +35,7 @@ export class DileOtpInput extends DileEmmitChange(LitElement) {
|
|
|
35
35
|
value: { type: String },
|
|
36
36
|
|
|
37
37
|
/** Name for this input field */
|
|
38
|
-
name: { type: String },
|
|
38
|
+
name: { type: String, reflect: true },
|
|
39
39
|
|
|
40
40
|
/** Disable the input field */
|
|
41
41
|
disabled: { type: Boolean },
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './pages.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-pages', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderPages(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-pages');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('shows only the selected page', async () => {
|
|
17
|
+
const el = await renderPages(`
|
|
18
|
+
<dile-pages selected="1">
|
|
19
|
+
<div>Page 0</div>
|
|
20
|
+
<div>Page 1</div>
|
|
21
|
+
</dile-pages>
|
|
22
|
+
`);
|
|
23
|
+
|
|
24
|
+
const [page0, page1] = el.children;
|
|
25
|
+
expect(page0.style.display).toBe('none');
|
|
26
|
+
expect(page1.style.display).toBe('block');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('hides the previous page and shows the new one when selected changes', async () => {
|
|
30
|
+
const el = await renderPages(`
|
|
31
|
+
<dile-pages selected="0">
|
|
32
|
+
<div>Page 0</div>
|
|
33
|
+
<div>Page 1</div>
|
|
34
|
+
</dile-pages>
|
|
35
|
+
`);
|
|
36
|
+
|
|
37
|
+
el.selected = 1;
|
|
38
|
+
await el.updateComplete;
|
|
39
|
+
|
|
40
|
+
const [page0, page1] = el.children;
|
|
41
|
+
expect(page0.style.display).toBe('none');
|
|
42
|
+
expect(page1.style.display).toBe('block');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './password.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-password', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderPassword(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-password');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders a password type input by default', async () => {
|
|
17
|
+
const el = await renderPassword('<dile-password name="pwd"></dile-password>');
|
|
18
|
+
const input = el.shadowRoot.querySelector('input');
|
|
19
|
+
|
|
20
|
+
expect(input).toBeTruthy();
|
|
21
|
+
expect(input.type).toBe('password');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('toggles input type to text when the visibility toggle is shown and clicked', async () => {
|
|
25
|
+
const el = await renderPassword('<dile-password name="pwd" showPasswordToggle></dile-password>');
|
|
26
|
+
const toggle = el.shadowRoot.querySelector('.password-toggle-btn');
|
|
27
|
+
expect(toggle).toBeTruthy();
|
|
28
|
+
|
|
29
|
+
toggle.click();
|
|
30
|
+
await el.updateComplete;
|
|
31
|
+
|
|
32
|
+
expect(el.passwordVisible).toBe(true);
|
|
33
|
+
expect(el.shadowRoot.querySelector('input').type).toBe('text');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './progress-bar.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-progress-bar', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderProgressBar(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-progress-bar');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders the progress bar width and percentage from the value property', async () => {
|
|
17
|
+
const el = await renderProgressBar('<dile-progress-bar value="42"></dile-progress-bar>');
|
|
18
|
+
const bar = el.shadowRoot.querySelector('.progress-bar');
|
|
19
|
+
|
|
20
|
+
expect(bar.getAttribute('style')).toContain('width: 42%');
|
|
21
|
+
expect(bar.querySelector('span').textContent.trim()).toBe('42%');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('renders the title when set', async () => {
|
|
25
|
+
const el = await renderProgressBar('<dile-progress-bar title="Loading"></dile-progress-bar>');
|
|
26
|
+
expect(el.shadowRoot.querySelector('.progress-bar-title').textContent.trim()).toBe('Loading');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './radio.js';
|
|
2
2
|
import { DileRadioGroup } from "./src/DileRadioGroup.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
if (!customElements.get("dile-radio-group")) {
|
|
5
|
+
window.customElements.define("dile-radio-group", DileRadioGroup);
|
|
6
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './radio-group.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-radio-group', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderRadioGroup(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-radio-group');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders the slotted radios and label', async () => {
|
|
17
|
+
const el = await renderRadioGroup(`
|
|
18
|
+
<dile-radio-group name="opt" label="Choose one">
|
|
19
|
+
<dile-radio value="a" label="A"></dile-radio>
|
|
20
|
+
<dile-radio value="b" label="B"></dile-radio>
|
|
21
|
+
</dile-radio-group>
|
|
22
|
+
`);
|
|
23
|
+
|
|
24
|
+
expect(el.shadowRoot.querySelector('.label').textContent.trim()).toBe('Choose one');
|
|
25
|
+
expect(el.querySelectorAll('dile-radio').length).toBe(2);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('updates value and selection when a radio is clicked', async () => {
|
|
29
|
+
const el = await renderRadioGroup(`
|
|
30
|
+
<dile-radio-group name="opt">
|
|
31
|
+
<dile-radio value="a" label="A"></dile-radio>
|
|
32
|
+
<dile-radio value="b" label="B"></dile-radio>
|
|
33
|
+
</dile-radio-group>
|
|
34
|
+
`);
|
|
35
|
+
|
|
36
|
+
const radios = el.querySelectorAll('dile-radio');
|
|
37
|
+
radios[1].shadowRoot.querySelector('article').click();
|
|
38
|
+
await el.updateComplete;
|
|
39
|
+
|
|
40
|
+
expect(el.value).toBe('b');
|
|
41
|
+
expect(radios[1].selected).toBe(true);
|
|
42
|
+
expect(radios[0].selected).toBe(false);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './radio.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-radio', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderRadio(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-radio');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders the label and starts unselected', async () => {
|
|
17
|
+
const el = await renderRadio('<dile-radio value="a" label="Option A"></dile-radio>');
|
|
18
|
+
|
|
19
|
+
expect(el.selected).toBe(false);
|
|
20
|
+
expect(el.shadowRoot.querySelector('.label').textContent.trim()).toBe('Option A');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('dispatches dile-radio-selected with value and label on click', async () => {
|
|
24
|
+
const el = await renderRadio('<dile-radio value="a" label="Option A"></dile-radio>');
|
|
25
|
+
let detail = null;
|
|
26
|
+
el.addEventListener('dile-radio-selected', (e) => { detail = e.detail; });
|
|
27
|
+
|
|
28
|
+
el.shadowRoot.querySelector('article').click();
|
|
29
|
+
|
|
30
|
+
expect(detail).toEqual({ value: 'a', label: 'Option A' });
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -26,7 +26,7 @@ export class DileRadioGroup extends DileEmmitChange(LitElement) {
|
|
|
26
26
|
return {
|
|
27
27
|
label: { type: String },
|
|
28
28
|
value: { type: String },
|
|
29
|
-
name: { type: String },
|
|
29
|
+
name: { type: String, reflect: true },
|
|
30
30
|
message: { type: String },
|
|
31
31
|
errored: { type: Boolean },
|
|
32
32
|
hideErrorOnInput: { type: Boolean },
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './range.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-range', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderRange(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-range');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders a native range input with min/max/value', async () => {
|
|
17
|
+
const el = await renderRange('<dile-range name="vol" min="0" max="20" value="5"></dile-range>');
|
|
18
|
+
const input = el.shadowRoot.querySelector('input[type="range"]');
|
|
19
|
+
|
|
20
|
+
expect(input).toBeTruthy();
|
|
21
|
+
expect(input.min).toBe('0');
|
|
22
|
+
expect(input.max).toBe('20');
|
|
23
|
+
expect(input.value).toBe('5');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('updates the value property when the input changes', async () => {
|
|
27
|
+
const el = await renderRange('<dile-range name="vol"></dile-range>');
|
|
28
|
+
const input = el.shadowRoot.querySelector('input[type="range"]');
|
|
29
|
+
|
|
30
|
+
input.value = '7';
|
|
31
|
+
input.dispatchEvent(new Event('input'));
|
|
32
|
+
await el.updateComplete;
|
|
33
|
+
|
|
34
|
+
expect(el.value).toBe('7');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -96,7 +96,7 @@ export class DileRange extends DileEmmitChange(LitElement) {
|
|
|
96
96
|
min: { type: Number },
|
|
97
97
|
step: { type: Number },
|
|
98
98
|
value: { type: Number },
|
|
99
|
-
name: { type: String },
|
|
99
|
+
name: { type: String, reflect: true },
|
|
100
100
|
label: { type: String },
|
|
101
101
|
message: { type: String },
|
|
102
102
|
errored: { type: Boolean, reflect: true },
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './rating.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-rating', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderRating(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-rating');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders five dile-star elements', async () => {
|
|
17
|
+
const el = await renderRating('<dile-rating value="3"></dile-rating>');
|
|
18
|
+
expect(el.shadowRoot.querySelectorAll('dile-star').length).toBe(5);
|
|
19
|
+
expect(el.value).toBe(3);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('updates value and dispatches dile-rating-selected when a star is selected', async () => {
|
|
23
|
+
const el = await renderRating('<dile-rating value="0"></dile-rating>');
|
|
24
|
+
let detail = null;
|
|
25
|
+
el.addEventListener('dile-rating-selected', (e) => { detail = e.detail; });
|
|
26
|
+
|
|
27
|
+
el.shadowRoot.querySelectorAll('dile-star')[2].dispatchEvent(new CustomEvent('dile-star-selected', {
|
|
28
|
+
detail: { index: 2 },
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
expect(el.value).toBe(3);
|
|
32
|
+
expect(detail).toEqual({ value: 3 });
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './star.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-star', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderStar(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-star');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders an inner dile-icon', async () => {
|
|
17
|
+
const el = await renderStar('<dile-star value="1" index="0"></dile-star>');
|
|
18
|
+
expect(el.shadowRoot.querySelector('dile-icon')).toBeTruthy();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('dispatches dile-star-selected with the index on click', async () => {
|
|
22
|
+
const el = await renderStar('<dile-star value="1" index="2"></dile-star>');
|
|
23
|
+
let detail = null;
|
|
24
|
+
el.addEventListener('dile-star-selected', (e) => { detail = e.detail; });
|
|
25
|
+
|
|
26
|
+
el.shadowRoot.querySelector('dile-icon').dispatchEvent(new Event('click'));
|
|
27
|
+
|
|
28
|
+
expect(detail).toEqual({ index: 2 });
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { DileRatingScaleOption } from "./src/DileRatingScaleOption.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
if (!customElements.get("dile-rating-scale-option")) {
|
|
4
|
+
window.customElements.define("dile-rating-scale-option", DileRatingScaleOption);
|
|
5
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './rating-scale-option.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-rating-scale-option', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderOption(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-rating-scale-option');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders the label and starts unselected', async () => {
|
|
17
|
+
const el = await renderOption('<dile-rating-scale-option value="3" label="Agree"></dile-rating-scale-option>');
|
|
18
|
+
|
|
19
|
+
expect(el.selected).toBe(false);
|
|
20
|
+
expect(el.shadowRoot.querySelector('.radio_label').textContent.trim()).toBe('Agree');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('dispatches dile-rating-scale-option-selected with the value on click', async () => {
|
|
24
|
+
const el = await renderOption('<dile-rating-scale-option value="3"></dile-rating-scale-option>');
|
|
25
|
+
let detail = null;
|
|
26
|
+
el.addEventListener('dile-rating-scale-option-selected', (e) => { detail = e.detail; });
|
|
27
|
+
|
|
28
|
+
el.shadowRoot.querySelector('span').click();
|
|
29
|
+
|
|
30
|
+
expect(detail).toEqual({ value: '3' });
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './rating-scale-option.js';
|
|
2
2
|
import { DileRatingScaleQuestion } from "./src/DileRatingScaleQuestion.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
if (!customElements.get("dile-rating-scale-question")) {
|
|
5
|
+
window.customElements.define("dile-rating-scale-question", DileRatingScaleQuestion);
|
|
6
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './rating-scale-question.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-rating-scale-question', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderQuestion(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-rating-scale-question');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders the label and default 7-point options', async () => {
|
|
17
|
+
const el = await renderQuestion('<dile-rating-scale-question name="q1" label="How satisfied are you?"></dile-rating-scale-question>');
|
|
18
|
+
|
|
19
|
+
expect(el.shadowRoot.querySelector('legend').textContent.trim()).toBe('How satisfied are you?');
|
|
20
|
+
expect(el.shadowRoot.querySelectorAll('dile-rating-scale-option').length).toBe(7);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('updates value when an option is selected', async () => {
|
|
24
|
+
const el = await renderQuestion('<dile-rating-scale-question name="q1"></dile-rating-scale-question>');
|
|
25
|
+
const option = el.shadowRoot.querySelector('dile-rating-scale-option');
|
|
26
|
+
option.dispatchEvent(new CustomEvent('dile-rating-scale-option-selected', {
|
|
27
|
+
bubbles: true,
|
|
28
|
+
composed: true,
|
|
29
|
+
detail: { value: option.value },
|
|
30
|
+
}));
|
|
31
|
+
await el.updateComplete;
|
|
32
|
+
|
|
33
|
+
expect(el.value).toBe(option.value);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './select.js'
|
|
2
2
|
import { DileSelectAjax } from "./src/DileSelectAjax.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
if (!customElements.get("dile-select-ajax")) {
|
|
5
|
+
window.customElements.define("dile-select-ajax", DileSelectAjax);
|
|
6
|
+
}
|
|
@@ -531,5 +531,44 @@ describe('dile-select', () => {
|
|
|
531
531
|
|
|
532
532
|
expect(el.internals.form).toBeDefined();
|
|
533
533
|
});
|
|
534
|
+
|
|
535
|
+
it('participates in FormData when name is set as an attribute', async () => {
|
|
536
|
+
document.body.innerHTML = `
|
|
537
|
+
<form id="testForm">
|
|
538
|
+
<dile-select name="fruit" value="1">
|
|
539
|
+
<select slot="select">
|
|
540
|
+
<option value="1">Option 1</option>
|
|
541
|
+
<option value="2">Option 2</option>
|
|
542
|
+
</select>
|
|
543
|
+
</dile-select>
|
|
544
|
+
</form>
|
|
545
|
+
`;
|
|
546
|
+
const el = document.body.querySelector('dile-select');
|
|
547
|
+
await el.updateComplete;
|
|
548
|
+
|
|
549
|
+
const data = new FormData(document.getElementById('testForm'));
|
|
550
|
+
expect(data.get('fruit')).toBe('1');
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
it('participates in FormData when name is set as a JS property', async () => {
|
|
554
|
+
document.body.innerHTML = `
|
|
555
|
+
<form id="testForm">
|
|
556
|
+
<dile-select value="1">
|
|
557
|
+
<select slot="select">
|
|
558
|
+
<option value="1">Option 1</option>
|
|
559
|
+
<option value="2">Option 2</option>
|
|
560
|
+
</select>
|
|
561
|
+
</dile-select>
|
|
562
|
+
</form>
|
|
563
|
+
`;
|
|
564
|
+
const el = document.body.querySelector('dile-select');
|
|
565
|
+
el.name = 'fruit';
|
|
566
|
+
await el.updateComplete;
|
|
567
|
+
|
|
568
|
+
expect(el.getAttribute('name')).toBe('fruit');
|
|
569
|
+
|
|
570
|
+
const data = new FormData(document.getElementById('testForm'));
|
|
571
|
+
expect(data.get('fruit')).toBe('1');
|
|
572
|
+
});
|
|
534
573
|
});
|
|
535
574
|
});
|
|
@@ -98,7 +98,7 @@ export class DileSelect extends DileEmmitChange(LitElement) {
|
|
|
98
98
|
return {
|
|
99
99
|
label: { type: String },
|
|
100
100
|
value: { type: String },
|
|
101
|
-
name: { type: String },
|
|
101
|
+
name: { type: String, reflect: true },
|
|
102
102
|
disabled: { type: Boolean },
|
|
103
103
|
errored: { type: Boolean },
|
|
104
104
|
message: { type: String },
|
|
@@ -66,7 +66,7 @@ export class DileSelectAjax extends DileEmmitChange(LitElement) {
|
|
|
66
66
|
endpoint: { type: String },
|
|
67
67
|
label: { type: String },
|
|
68
68
|
value: { type: String },
|
|
69
|
-
name: { type: String },
|
|
69
|
+
name: { type: String, reflect: true },
|
|
70
70
|
disabled: { type: Boolean },
|
|
71
71
|
errored: { type: Boolean },
|
|
72
72
|
data: { type: Array },
|
|
@@ -19,7 +19,7 @@ export class DileSelectBoolean extends DileEmmitChange(LitElement) {
|
|
|
19
19
|
return {
|
|
20
20
|
label: { type: String },
|
|
21
21
|
value: {},
|
|
22
|
-
name: { type: String },
|
|
22
|
+
name: { type: String, reflect: true },
|
|
23
23
|
disabled: { type: Boolean },
|
|
24
24
|
errored: { type: Boolean },
|
|
25
25
|
message: { type: String },
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './selector-item.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-selector-item', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderSelectorItem(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-selector-item');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders the slotted content and starts unselected', async () => {
|
|
17
|
+
const el = await renderSelectorItem('<dile-selector-item>Option A</dile-selector-item>');
|
|
18
|
+
|
|
19
|
+
expect(el.selected).toBe(false);
|
|
20
|
+
expect(el.textContent.trim()).toBe('Option A');
|
|
21
|
+
expect(el.shadowRoot.querySelector('article')).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('dispatches dile-item-selected with itself when clicked', async () => {
|
|
25
|
+
const el = await renderSelectorItem('<dile-selector-item>Option A</dile-selector-item>');
|
|
26
|
+
let detail = null;
|
|
27
|
+
el.addEventListener('dile-item-selected', (e) => { detail = e.detail; });
|
|
28
|
+
|
|
29
|
+
el.shadowRoot.querySelector('article').click();
|
|
30
|
+
|
|
31
|
+
expect(detail).toBe(el);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('wraps content in a link when href is set', async () => {
|
|
35
|
+
const el = await renderSelectorItem('<dile-selector-item href="/foo">Go</dile-selector-item>');
|
|
36
|
+
const link = el.shadowRoot.querySelector('a');
|
|
37
|
+
expect(link).toBeTruthy();
|
|
38
|
+
expect(link.getAttribute('href')).toBe('/foo');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { DileSelectorOverlay } from "./src/DileSelectorOverlay.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
if (!customElements.get("dile-selector-overlay")) {
|
|
4
|
+
window.customElements.define("dile-selector-overlay", DileSelectorOverlay);
|
|
5
|
+
}
|