@dile/ui 3.4.5 → 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/button-icon.js +3 -1
- package/components/button/button.js +3 -1
- 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/chip/chip.js +3 -1
- package/components/chip/chip.spec.js +31 -0
- package/components/color-picker/color-picker.js +3 -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/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/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/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/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/range/range.js +3 -1
- package/components/range/range.spec.js +36 -0
- 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/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/textarea.js +3 -1
- package/components/textarea/textarea.spec.js +39 -0
- 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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DileFloatingFeedback } from './src/DileFloatingFeedback.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
if (!customElements.get('dile-floating-feedback')) {
|
|
4
|
+
window.customElements.define('dile-floating-feedback', DileFloatingFeedback);
|
|
5
|
+
}
|
|
4
6
|
|
|
5
7
|
export { DileFloatingFeedback };
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { DileFloatingMenuItem } from './src/DileFloatingMenuItem.js';
|
|
2
|
-
customElements.
|
|
2
|
+
if (!customElements.get('dile-floating-menu-item')) {
|
|
3
|
+
customElements.define('dile-floating-menu-item', DileFloatingMenuItem);
|
|
4
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './floating-menu-item.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-floating-menu-item', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderItem(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-floating-menu-item');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders the slotted content inside a link with the href property', async () => {
|
|
17
|
+
const el = await renderItem('<dile-floating-menu-item href="/home">Home</dile-floating-menu-item>');
|
|
18
|
+
const link = el.shadowRoot.querySelector('a');
|
|
19
|
+
expect(link.getAttribute('href')).toBe('/home');
|
|
20
|
+
expect(el.textContent.trim()).toBe('Home');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('sets role listitem on the host', async () => {
|
|
24
|
+
const el = await renderItem('<dile-floating-menu-item href="/home">Home</dile-floating-menu-item>');
|
|
25
|
+
expect(el.getAttribute('role')).toBe('listitem');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './floating-menu.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-floating-menu', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderFloatingMenu(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-floating-menu');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders closed by default', async () => {
|
|
17
|
+
const el = await renderFloatingMenu('<dile-floating-menu></dile-floating-menu>');
|
|
18
|
+
expect(el.opened).toBe(false);
|
|
19
|
+
expect(el.shadowRoot.querySelector('button')).toBeTruthy();
|
|
20
|
+
expect(el.shadowRoot.querySelector('.closed')).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('toggles opened state when the button is clicked', async () => {
|
|
24
|
+
const el = await renderFloatingMenu('<dile-floating-menu></dile-floating-menu>');
|
|
25
|
+
el.shadowRoot.querySelector('button').click();
|
|
26
|
+
await el.updateComplete;
|
|
27
|
+
|
|
28
|
+
expect(el.opened).toBe(true);
|
|
29
|
+
expect(el.shadowRoot.querySelector('.opened')).toBeTruthy();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './form-separator.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-form-separator', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderFormSeparator(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-form-separator');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders without a heading when label is not set', async () => {
|
|
17
|
+
const el = await renderFormSeparator('<dile-form-separator></dile-form-separator>');
|
|
18
|
+
expect(el.shadowRoot.querySelector('div')).toBeTruthy();
|
|
19
|
+
expect(el.shadowRoot.querySelector('h3')).toBeNull();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('renders the label as a heading when set', async () => {
|
|
23
|
+
const el = await renderFormSeparator('<dile-form-separator label="Section"></dile-form-separator>');
|
|
24
|
+
const heading = el.shadowRoot.querySelector('h3');
|
|
25
|
+
expect(heading).toBeTruthy();
|
|
26
|
+
expect(heading.textContent.trim()).toBe('Section');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './hamburger.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-hamburger', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderHamburger(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-hamburger');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders a button without the is-active class by default', async () => {
|
|
17
|
+
const el = await renderHamburger('<dile-hamburger></dile-hamburger>');
|
|
18
|
+
const button = el.shadowRoot.querySelector('button.hamburger');
|
|
19
|
+
expect(button).toBeTruthy();
|
|
20
|
+
expect(button.classList.contains('is-active')).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('adds the is-active class when active is set', async () => {
|
|
24
|
+
const el = await renderHamburger('<dile-hamburger active></dile-hamburger>');
|
|
25
|
+
const button = el.shadowRoot.querySelector('button.hamburger');
|
|
26
|
+
expect(button.classList.contains('is-active')).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
});
|
package/components/icon/icon.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import { closeIcon } from '@dile/icons/index.js';
|
|
3
|
+
import './icon.js';
|
|
4
|
+
|
|
5
|
+
describe('dile-icon', () => {
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
document.body.innerHTML = '';
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
async function renderIcon(html) {
|
|
11
|
+
document.body.innerHTML = html;
|
|
12
|
+
const el = document.body.querySelector('dile-icon');
|
|
13
|
+
await el.updateComplete;
|
|
14
|
+
return el;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
it('renders the provided icon inside a span', async () => {
|
|
18
|
+
const el = await renderIcon('<dile-icon></dile-icon>');
|
|
19
|
+
el.icon = closeIcon;
|
|
20
|
+
await el.updateComplete;
|
|
21
|
+
|
|
22
|
+
const span = el.shadowRoot.querySelector('span');
|
|
23
|
+
expect(span).toBeTruthy();
|
|
24
|
+
expect(span.querySelector('svg')).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('renders nothing extra when icon is not set', async () => {
|
|
28
|
+
const el = await renderIcon('<dile-icon></dile-icon>');
|
|
29
|
+
expect(el.shadowRoot.querySelector('span').querySelector('svg')).toBeNull();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { DileIconSwitchGroup } from "./src/DileIconSwitchGroup.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
if (!customElements.get("dile-icon-switch-group")) {
|
|
4
|
+
window.customElements.define("dile-icon-switch-group", DileIconSwitchGroup);
|
|
5
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import { closeIcon } from '@dile/icons/index.js';
|
|
3
|
+
import './icon-switch-group.js';
|
|
4
|
+
import './icon-switch.js';
|
|
5
|
+
|
|
6
|
+
describe('dile-icon-switch-group', () => {
|
|
7
|
+
afterEach(() => {
|
|
8
|
+
document.body.innerHTML = '';
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
async function renderGroup(html) {
|
|
12
|
+
document.body.innerHTML = html;
|
|
13
|
+
const el = document.body.querySelector('dile-icon-switch-group');
|
|
14
|
+
const switches = el.querySelectorAll('dile-icon-switch');
|
|
15
|
+
switches.forEach((s) => { s.icon = closeIcon; });
|
|
16
|
+
await el.updateComplete;
|
|
17
|
+
for (const s of switches) await s.updateComplete;
|
|
18
|
+
return el;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
it('renders the slotted dile-icon-switch children', async () => {
|
|
22
|
+
const el = await renderGroup(`
|
|
23
|
+
<dile-icon-switch-group>
|
|
24
|
+
<dile-icon-switch name="one"></dile-icon-switch>
|
|
25
|
+
<dile-icon-switch name="two"></dile-icon-switch>
|
|
26
|
+
</dile-icon-switch-group>
|
|
27
|
+
`);
|
|
28
|
+
expect(el.querySelectorAll('dile-icon-switch').length).toBe(2);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('deactivates the other switches when one becomes active', async () => {
|
|
32
|
+
const el = await renderGroup(`
|
|
33
|
+
<dile-icon-switch-group>
|
|
34
|
+
<dile-icon-switch name="one" active></dile-icon-switch>
|
|
35
|
+
<dile-icon-switch name="two"></dile-icon-switch>
|
|
36
|
+
</dile-icon-switch-group>
|
|
37
|
+
`);
|
|
38
|
+
const [one, two] = el.querySelectorAll('dile-icon-switch');
|
|
39
|
+
|
|
40
|
+
two.shadowRoot.querySelector('dile-icon').click();
|
|
41
|
+
await el.updateComplete;
|
|
42
|
+
|
|
43
|
+
expect(two.active).toBe(true);
|
|
44
|
+
expect(one.active).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import { closeIcon } from '@dile/icons/index.js';
|
|
3
|
+
import './icon-switch.js';
|
|
4
|
+
|
|
5
|
+
describe('dile-icon-switch', () => {
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
document.body.innerHTML = '';
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
async function renderIconSwitch(html) {
|
|
11
|
+
document.body.innerHTML = html;
|
|
12
|
+
const el = document.body.querySelector('dile-icon-switch');
|
|
13
|
+
el.icon = closeIcon;
|
|
14
|
+
await el.updateComplete;
|
|
15
|
+
return el;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
it('starts inactive by default', async () => {
|
|
19
|
+
const el = await renderIconSwitch('<dile-icon-switch name="one"></dile-icon-switch>');
|
|
20
|
+
expect(el.active).toBeFalsy();
|
|
21
|
+
expect(el.shadowRoot.querySelector('dile-icon')).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('toggles active and dispatches dile-icon-switch-changed on click', async () => {
|
|
25
|
+
const el = await renderIconSwitch('<dile-icon-switch name="one"></dile-icon-switch>');
|
|
26
|
+
let detail = null;
|
|
27
|
+
el.addEventListener('dile-icon-switch-changed', (e) => { detail = e.detail; });
|
|
28
|
+
|
|
29
|
+
el.shadowRoot.querySelector('dile-icon').click();
|
|
30
|
+
await el.updateComplete;
|
|
31
|
+
|
|
32
|
+
expect(el.active).toBe(true);
|
|
33
|
+
expect(detail).toEqual({ active: true, name: 'one' });
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './info-box.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-info-box', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderInfoBox(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-info-box');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders the slotted content and a default info icon', async () => {
|
|
17
|
+
const el = await renderInfoBox('<dile-info-box>Some info</dile-info-box>');
|
|
18
|
+
expect(el.textContent.trim()).toBe('Some info');
|
|
19
|
+
expect(el.shadowRoot.querySelector('.info dile-icon, .info svg')).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('renders the title when set', async () => {
|
|
23
|
+
const el = await renderInfoBox('<dile-info-box title="Heads up">Some info</dile-info-box>');
|
|
24
|
+
const title = el.shadowRoot.querySelector('.title');
|
|
25
|
+
expect(title).toBeTruthy();
|
|
26
|
+
expect(title.textContent.trim()).toBe('Heads up');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('shows the close button only when showCloseButton is set', async () => {
|
|
30
|
+
const el = await renderInfoBox('<dile-info-box>Some info</dile-info-box>');
|
|
31
|
+
expect(el.shadowRoot.querySelector('.close')).toBeNull();
|
|
32
|
+
|
|
33
|
+
el.showCloseButton = true;
|
|
34
|
+
await el.updateComplete;
|
|
35
|
+
|
|
36
|
+
expect(el.shadowRoot.querySelector('.close button')).toBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { DileInlineFeedback } from "./src/DileInlineFeedback.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
if (!customElements.get("dile-inline-feedback")) {
|
|
4
|
+
window.customElements.define("dile-inline-feedback", DileInlineFeedback);
|
|
5
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './inline-feedback.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-inline-feedback', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderInlineFeedback(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-inline-feedback');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders an empty message section by default', async () => {
|
|
17
|
+
const el = await renderInlineFeedback('<dile-inline-feedback></dile-inline-feedback>');
|
|
18
|
+
const section = el.shadowRoot.querySelector('#msg');
|
|
19
|
+
expect(section).toBeTruthy();
|
|
20
|
+
expect(section.textContent.trim()).toBe('');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('sets the message and status classes on positiveFeedback', async () => {
|
|
24
|
+
const el = await renderInlineFeedback('<dile-inline-feedback></dile-inline-feedback>');
|
|
25
|
+
el.positiveFeedback('Saved!');
|
|
26
|
+
await el.updateComplete;
|
|
27
|
+
|
|
28
|
+
expect(el.msg).toBe('Saved!');
|
|
29
|
+
expect(el.status).toBe('success');
|
|
30
|
+
expect(el.shadowRoot.querySelector('#msg').textContent.trim()).toBe('Saved!');
|
|
31
|
+
expect(el.shadowRoot.querySelector('#msg').classList.contains('success')).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('clears the message and status on clear()', async () => {
|
|
35
|
+
const el = await renderInlineFeedback('<dile-inline-feedback></dile-inline-feedback>');
|
|
36
|
+
el.negativeFeedback('Oops');
|
|
37
|
+
await el.updateComplete;
|
|
38
|
+
|
|
39
|
+
el.clear();
|
|
40
|
+
await el.updateComplete;
|
|
41
|
+
|
|
42
|
+
expect(el.msg).toBe('');
|
|
43
|
+
expect(el.status).toBe('');
|
|
44
|
+
expect(el.opened).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './input-contact.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-input-contact', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderInputContact(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-input-contact');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders a native text input with the given value', async () => {
|
|
17
|
+
const el = await renderInputContact('<dile-input-contact name="phone" value="123"></dile-input-contact>');
|
|
18
|
+
const input = el.shadowRoot.querySelector('input');
|
|
19
|
+
expect(input).toBeTruthy();
|
|
20
|
+
expect(input.value).toBe('123');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('marks invalid phone values as errored on blur', async () => {
|
|
24
|
+
const el = await renderInputContact('<dile-input-contact name="phone" phone value="abc"></dile-input-contact>');
|
|
25
|
+
const input = el.shadowRoot.querySelector('input');
|
|
26
|
+
input.dispatchEvent(new Event('blur'));
|
|
27
|
+
await el.updateComplete;
|
|
28
|
+
|
|
29
|
+
expect(el.valid).toBe(false);
|
|
30
|
+
expect(el.errored).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './input-integer.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-input-integer', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderInputInteger(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-input-integer');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders a native text input with the given value', async () => {
|
|
17
|
+
const el = await renderInputInteger('<dile-input-integer name="qty" value="5"></dile-input-integer>');
|
|
18
|
+
const input = el.shadowRoot.querySelector('input');
|
|
19
|
+
expect(input).toBeTruthy();
|
|
20
|
+
expect(input.value).toBe('5');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('formats the value to an integer on blur', async () => {
|
|
24
|
+
const el = await renderInputInteger('<dile-input-integer name="qty" value="5.9"></dile-input-integer>');
|
|
25
|
+
const input = el.shadowRoot.querySelector('input');
|
|
26
|
+
input.value = '5.9';
|
|
27
|
+
input.dispatchEvent(new Event('blur'));
|
|
28
|
+
|
|
29
|
+
expect(el.value).toBe(5);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './input-message.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-input-message', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderInputMessage(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-input-message');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders nothing when there is no message', async () => {
|
|
17
|
+
const el = await renderInputMessage('<dile-input-message></dile-input-message>');
|
|
18
|
+
expect(el.shadowRoot.querySelector('.message')).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('renders the message text when set', async () => {
|
|
22
|
+
const el = await renderInputMessage('<dile-input-message message="Required"></dile-input-message>');
|
|
23
|
+
const message = el.shadowRoot.querySelector('.message span');
|
|
24
|
+
expect(message).toBeTruthy();
|
|
25
|
+
expect(message.textContent.trim()).toBe('Required');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './input-money.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-input-money', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderInputMoney(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-input-money');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders a native text input with the given value', async () => {
|
|
17
|
+
const el = await renderInputMoney('<dile-input-money name="price" value="9.5"></dile-input-money>');
|
|
18
|
+
const input = el.shadowRoot.querySelector('input');
|
|
19
|
+
expect(input).toBeTruthy();
|
|
20
|
+
expect(input.value).toBe('9.5');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('formats the value to two decimals via set()', async () => {
|
|
24
|
+
const el = await renderInputMoney('<dile-input-money name="price"></dile-input-money>');
|
|
25
|
+
el.set('9.5');
|
|
26
|
+
await el.updateComplete;
|
|
27
|
+
|
|
28
|
+
expect(el.value).toBe('9.50');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { DileInputNumberMask } from './src/DileInputNumberMask.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
if (!customElements.get('dile-input-number-mask')) {
|
|
4
|
+
window.customElements.define('dile-input-number-mask', DileInputNumberMask);
|
|
5
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './input-number-mask.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-input-number-mask', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderInputNumberMask(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-input-number-mask');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders a native text input', async () => {
|
|
17
|
+
const el = await renderInputNumberMask('<dile-input-number-mask name="code" mask="00-00"></dile-input-number-mask>');
|
|
18
|
+
expect(el.shadowRoot.querySelector('input')).toBeTruthy();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('masks digit keydowns following the given pattern', async () => {
|
|
22
|
+
const el = await renderInputNumberMask('<dile-input-number-mask name="code" mask="00-00"></dile-input-number-mask>');
|
|
23
|
+
const input = el.shadowRoot.querySelector('input');
|
|
24
|
+
|
|
25
|
+
['1', '2', '3'].forEach((key) => {
|
|
26
|
+
input.dispatchEvent(new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true }));
|
|
27
|
+
});
|
|
28
|
+
await el.updateComplete;
|
|
29
|
+
|
|
30
|
+
expect(el.maskedValue).toBe('12-3');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { DileInputPercentage } from './src/DileInputPercentage.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
if (!customElements.get('dile-input-percentage')) {
|
|
4
|
+
window.customElements.define('dile-input-percentage', DileInputPercentage);
|
|
5
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import './input-percentage.js';
|
|
3
|
+
|
|
4
|
+
describe('dile-input-percentage', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = '';
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
async function renderInputPercentage(html) {
|
|
10
|
+
document.body.innerHTML = html;
|
|
11
|
+
const el = document.body.querySelector('dile-input-percentage');
|
|
12
|
+
await el.updateComplete;
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
it('renders a native text input with the given value and a % label', async () => {
|
|
17
|
+
const el = await renderInputPercentage('<dile-input-percentage name="rate" value="10"></dile-input-percentage>');
|
|
18
|
+
const input = el.shadowRoot.querySelector('input');
|
|
19
|
+
expect(input).toBeTruthy();
|
|
20
|
+
expect(input.value).toBe('10');
|
|
21
|
+
expect(el.shadowRoot.querySelector('.labelright').textContent.trim()).toBe('%');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('formats the value as a float via doFormat()', async () => {
|
|
25
|
+
const el = await renderInputPercentage('<dile-input-percentage name="rate" value="10.5"></dile-input-percentage>');
|
|
26
|
+
el.doFormat();
|
|
27
|
+
await el.updateComplete;
|
|
28
|
+
|
|
29
|
+
expect(el.value).toBe(10.5);
|
|
30
|
+
});
|
|
31
|
+
});
|