@dile/utils 3.3.6 → 3.3.7

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.
Files changed (21) hide show
  1. package/package.json +4 -4
  2. package/components/country-select/country-select.spec.js +0 -35
  3. package/components/datepicker/calendar.spec.js +0 -136
  4. package/components/datepicker/datepicker.spec.js +0 -45
  5. package/components/datepicker/datetimepicker.spec.js +0 -55
  6. package/components/graph/graph.spec.js +0 -38
  7. package/components/html-transform/html-transform.spec.js +0 -25
  8. package/components/input-phone/__screenshots__/input-phone.spec.js/dile-input-phone-Rendering-preselects-the-prefix-of-the-country-attribute-1.png +0 -0
  9. package/components/input-phone/__screenshots__/input-phone.spec.js/dile-input-phone-Value-set-from-outside-keeps-the-country-when-it-shares-the-prefix-of-the-value-1.png +0 -0
  10. package/components/input-phone/__screenshots__/input-phone.spec.js/dile-input-phone-Value-with-prefix-does-not-let-the-prefix-selector-events-escape-as-the-field-own-events-1.png +0 -0
  11. package/components/input-phone/__screenshots__/input-phone.spec.js/dile-input-phone-Value-with-prefix-updates-the-value-when-the-user-chooses-a-prefix-1.png +0 -0
  12. package/components/input-phone/input-phone.spec.js +0 -345
  13. package/components/local-time/local-time.spec.js +0 -25
  14. package/components/media-query/media-query.spec.js +0 -34
  15. package/components/network/network.spec.js +0 -33
  16. package/components/phone-prefix-select/__screenshots__/phone-prefix-select.spec.js/dile-phone-prefix-select-Initial-value-and-country-ignores-a-country-that-does-not-match-the-prefix-1.png +0 -0
  17. package/components/phone-prefix-select/__screenshots__/phone-prefix-select.spec.js/dile-phone-prefix-select-Searching-compact-gives-the-selected-field-an-accessible-name-with-the-country-1.png +0 -0
  18. package/components/phone-prefix-select/phone-prefix-select.spec.js +0 -257
  19. package/components/qr-code/qr-code.spec.js +0 -164
  20. package/components/smooth-scroll/smooth-scroll.spec.js +0 -26
  21. package/components/time-duration/time-duration.spec.js +0 -68
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/utils",
3
- "version": "3.3.6",
3
+ "version": "3.3.7",
4
4
  "description": "Utility Components of Diverse Uses Based on the Lit Library and Web Components Standard.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,8 +20,8 @@
20
20
  },
21
21
  "homepage": "https://dile-components.com/",
22
22
  "dependencies": {
23
- "@dile/iconlib": "^2.0.1",
24
- "@dile/ui": "^3.18.0",
23
+ "@dile/iconlib": "^2.0.2",
24
+ "@dile/ui": "^3.18.1",
25
25
  "@lion/ui": "^0.21.0",
26
26
  "linkify-string": "^4.1.3",
27
27
  "linkifyjs": "^4.1.3",
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "1b065736666cc26f8afc1106ec7ffc98feaec60e"
34
+ "gitHead": "6724d25c93731ed35e6710228a6d0b18e5b6ebb1"
35
35
  }
@@ -1,35 +0,0 @@
1
- import { describe, it, expect, afterEach } from 'vitest';
2
- import './country-select.js';
3
-
4
- describe('dile-country-select', () => {
5
- afterEach(() => {
6
- document.body.innerHTML = '';
7
- });
8
-
9
- async function renderCountrySelect(html) {
10
- document.body.innerHTML = html;
11
- const el = document.body.querySelector('dile-country-select');
12
- await el.updateComplete;
13
- return el;
14
- }
15
-
16
- it('renders a dile-select with country options', async () => {
17
- const el = await renderCountrySelect('<dile-country-select name="country"></dile-country-select>');
18
- const select = el.shadowRoot.querySelector('dile-select');
19
- expect(select).toBeTruthy();
20
- expect(el.shadowRoot.querySelectorAll('option').length).toBeGreaterThan(1);
21
- });
22
-
23
- it('updates value and dispatches country-changed on selection change', async () => {
24
- const el = await renderCountrySelect('<dile-country-select name="country"></dile-country-select>');
25
- let detail = null;
26
- el.addEventListener('country-changed', (e) => { detail = e.detail; });
27
-
28
- el.shadowRoot.querySelector('dile-select').dispatchEvent(
29
- new CustomEvent('element-changed', { detail: { value: 'ES' } })
30
- );
31
-
32
- expect(el.value).toBe('ES');
33
- expect(detail).toEqual({ value: 'ES' });
34
- });
35
- });
@@ -1,136 +0,0 @@
1
- import { describe, it, expect, afterEach } from 'vitest';
2
- import './calendar.js';
3
-
4
- describe('dile-calendar', () => {
5
- afterEach(() => {
6
- document.body.innerHTML = '';
7
- });
8
-
9
- async function renderCalendar(html) {
10
- document.body.innerHTML = html;
11
- const el = document.body.querySelector('dile-calendar');
12
- await el.updateComplete;
13
- return el;
14
- }
15
-
16
- it('renders the month navigation and day grid', async () => {
17
- const el = await renderCalendar('<dile-calendar></dile-calendar>');
18
- await el.updateComplete;
19
- expect(el.shadowRoot.querySelector('.calendar__navigation')).toBeTruthy();
20
- expect(el.shadowRoot.querySelectorAll('.calendar__day-button').length).toBeGreaterThan(0);
21
- });
22
-
23
- it('has accessible navigation buttons with aria-label', async () => {
24
- const el = await renderCalendar('<dile-calendar></dile-calendar>');
25
- await el.updateComplete;
26
-
27
- const prevButtons = el.shadowRoot.querySelectorAll('.calendar__previous-button');
28
- const nextButtons = el.shadowRoot.querySelectorAll('.calendar__next-button');
29
-
30
- expect(prevButtons.length).toBe(2); // Year and Month prev
31
- expect(nextButtons.length).toBe(2); // Year and Month next
32
-
33
- prevButtons.forEach(btn => {
34
- expect(btn.getAttribute('aria-label')).toBeTruthy();
35
- });
36
- nextButtons.forEach(btn => {
37
- expect(btn.getAttribute('aria-label')).toBeTruthy();
38
- });
39
- });
40
-
41
- it('has accessible grid semantics and screen-reader day labels', async () => {
42
- const el = await renderCalendar('<dile-calendar></dile-calendar>');
43
- await el.updateComplete;
44
-
45
- const gridcells = el.shadowRoot.querySelectorAll('[role="gridcell"]');
46
- expect(gridcells.length).toBeGreaterThan(0);
47
-
48
- const dayButtons = el.shadowRoot.querySelectorAll('.calendar__day-button[role="button"]');
49
- expect(dayButtons.length).toBeGreaterThan(0);
50
-
51
- const srLabels = el.shadowRoot.querySelectorAll('.calendar__day-button .u-sr-only');
52
- expect(srLabels.length).toBe(dayButtons.length);
53
- expect(srLabels[0].textContent.trim().length).toBeGreaterThan(0);
54
- });
55
-
56
- it('supports roving tabindex where only one active date has tabindex 0', async () => {
57
- const el = await renderCalendar('<dile-calendar></dile-calendar>');
58
- await el.updateComplete;
59
-
60
- const focusableDays = el.shadowRoot.querySelectorAll('.calendar__day-button[tabindex="0"]');
61
- expect(focusableDays.length).toBe(1);
62
-
63
- const unfocusableDays = el.shadowRoot.querySelectorAll('.calendar__day-button[tabindex="-1"]');
64
- expect(unfocusableDays.length).toBeGreaterThan(0);
65
- });
66
-
67
- it('navigates days with keyboard arrow keys', async () => {
68
- const el = await renderCalendar('<dile-calendar></dile-calendar>');
69
- await el.updateComplete;
70
-
71
- const initialDate = new Date(2026, 0, 15);
72
- el.centralDate = initialDate;
73
- await el.updateComplete;
74
-
75
- const contentWrapper = el.shadowRoot.getElementById('js-content-wrapper');
76
-
77
- // ArrowRight: next day
78
- contentWrapper.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowRight', bubbles: true, composed: true }));
79
- await el.updateComplete;
80
- expect(el.centralDate.getDate()).toBe(16);
81
-
82
- // ArrowLeft: previous day
83
- contentWrapper.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowLeft', bubbles: true, composed: true }));
84
- await el.updateComplete;
85
- expect(el.centralDate.getDate()).toBe(15);
86
-
87
- // ArrowDown: next week (+7 days)
88
- contentWrapper.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowDown', bubbles: true, composed: true }));
89
- await el.updateComplete;
90
- expect(el.centralDate.getDate()).toBe(22);
91
-
92
- // ArrowUp: previous week (-7 days)
93
- contentWrapper.dispatchEvent(new KeyboardEvent('keyup', { key: 'ArrowUp', bubbles: true, composed: true }));
94
- await el.updateComplete;
95
- expect(el.centralDate.getDate()).toBe(15);
96
- });
97
-
98
- it('selects date when clicking a day button', async () => {
99
- const el = await renderCalendar('<dile-calendar></dile-calendar>');
100
- await el.updateComplete;
101
-
102
- let selectedDate = null;
103
- el.addEventListener('user-selected-date-changed', (e) => {
104
- selectedDate = e.detail.selectedDate;
105
- });
106
-
107
- const activeDayButton = el.shadowRoot.querySelector('.calendar__day-button[tabindex="0"]');
108
- activeDayButton.click();
109
- await el.updateComplete;
110
-
111
- expect(selectedDate).toBeTruthy();
112
- expect(selectedDate instanceof Date).toBe(true);
113
- });
114
-
115
- it('navigates next and previous months and years', async () => {
116
- const el = await renderCalendar('<dile-calendar></dile-calendar>');
117
- el.centralDate = new Date(2026, 5, 15); // June 2026
118
- await el.updateComplete;
119
-
120
- el.goToNextMonth();
121
- await el.updateComplete;
122
- expect(el.centralDate.getMonth()).toBe(6); // July
123
-
124
- el.goToPreviousMonth();
125
- await el.updateComplete;
126
- expect(el.centralDate.getMonth()).toBe(5); // June
127
-
128
- el.goToNextYear();
129
- await el.updateComplete;
130
- expect(el.centralDate.getFullYear()).toBe(2027);
131
-
132
- el.goToPreviousYear();
133
- await el.updateComplete;
134
- expect(el.centralDate.getFullYear()).toBe(2026);
135
- });
136
- });
@@ -1,45 +0,0 @@
1
- import { describe, it, expect, afterEach } from 'vitest';
2
- import './datepicker.js';
3
-
4
- describe('dile-datepicker', () => {
5
- afterEach(() => {
6
- document.body.innerHTML = '';
7
- });
8
-
9
- async function renderDatepicker(html) {
10
- document.body.innerHTML = html;
11
- const el = document.body.querySelector('dile-datepicker');
12
- await el.updateComplete;
13
- return el;
14
- }
15
-
16
- it('renders the text input and a calendar trigger icon', async () => {
17
- const el = await renderDatepicker('<dile-datepicker name="birthdate" label="Birthdate"></dile-datepicker>');
18
- expect(el.shadowRoot.querySelector('input')).toBeTruthy();
19
- expect(el.shadowRoot.querySelector('dile-menu-overlay')).toBeTruthy();
20
- expect(el.shadowRoot.querySelector('dile-iconlib')).toBeTruthy();
21
- });
22
-
23
- it('updates value when a date is selected from the calendar and closes overlay', async () => {
24
- const el = await renderDatepicker('<dile-datepicker name="birthdate"></dile-datepicker>');
25
- const calendar = el.shadowRoot.querySelector('dile-calendar');
26
- const menu = el.shadowRoot.getElementById('menu');
27
-
28
- calendar.dispatchEvent(new CustomEvent('user-selected-date-changed', {
29
- detail: { selectedDate: new Date(2024, 0, 15) },
30
- bubbles: true,
31
- composed: true,
32
- }));
33
- await el.updateComplete;
34
-
35
- expect(el.value).toBeTruthy();
36
- expect(menu._overlayClass).toBe('');
37
- });
38
-
39
- it('passes firstDayOfWeek to the dile-calendar child', async () => {
40
- const el = await renderDatepicker('<dile-datepicker name="birthdate" firstDayOfWeek="1"></dile-datepicker>');
41
- await el.updateComplete;
42
- const calendar = el.shadowRoot.querySelector('dile-calendar');
43
- expect(calendar.firstDayOfWeek).toBe(1);
44
- });
45
- });
@@ -1,55 +0,0 @@
1
- import { describe, it, expect, afterEach } from 'vitest';
2
- import './datetimepicker.js';
3
-
4
- describe('dile-datetimepicker', () => {
5
- afterEach(() => {
6
- document.body.innerHTML = '';
7
- });
8
-
9
- async function renderDatetimepicker(html) {
10
- document.body.innerHTML = html;
11
- const el = document.body.querySelector('dile-datetimepicker');
12
- await el.updateComplete;
13
- return el;
14
- }
15
-
16
- it('renders the text input, trigger icon, calendar and time picker inside the overlay', async () => {
17
- const el = await renderDatetimepicker('<dile-datetimepicker name="appointment"></dile-datetimepicker>');
18
- expect(el.shadowRoot.querySelector('input')).toBeTruthy();
19
- expect(el.shadowRoot.querySelector('dile-iconlib')).toBeTruthy();
20
- expect(el.icon).toBe('lucide.calendar-clock');
21
- expect(el.shadowRoot.querySelector('dile-calendar')).toBeTruthy();
22
- expect(el.shadowRoot.querySelector('dile-time-picker')).toBeTruthy();
23
- });
24
-
25
- it('renders an accessible accept button with aria-label and type="button"', async () => {
26
- const el = await renderDatetimepicker('<dile-datetimepicker name="appointment" acceptLabel="Confirm selection"></dile-datetimepicker>');
27
- const acceptBtn = el.shadowRoot.querySelector('.accept-button');
28
-
29
- expect(acceptBtn).toBeTruthy();
30
- expect(acceptBtn.tagName.toLowerCase()).toBe('button');
31
- expect(acceptBtn.getAttribute('type')).toBe('button');
32
- expect(acceptBtn.getAttribute('aria-label')).toBe('Confirm selection');
33
- expect(acceptBtn.querySelector('dile-icon')).toBeTruthy();
34
- });
35
-
36
- it('updates value combining date and time when accepted via method', async () => {
37
- const el = await renderDatetimepicker('<dile-datetimepicker name="appointment"></dile-datetimepicker>');
38
- el.acceptTime();
39
- await el.updateComplete;
40
-
41
- expect(el.value).toMatch(/^\d{4}-\d{2}-\d{2} /);
42
- });
43
-
44
- it('updates value and closes overlay when accept button is clicked', async () => {
45
- const el = await renderDatetimepicker('<dile-datetimepicker name="appointment"></dile-datetimepicker>');
46
- const acceptBtn = el.shadowRoot.querySelector('.accept-button');
47
- const menu = el.shadowRoot.getElementById('menu');
48
-
49
- acceptBtn.click();
50
- await el.updateComplete;
51
-
52
- expect(el.value).toMatch(/^\d{4}-\d{2}-\d{2} /);
53
- expect(menu._overlayClass).toBe('');
54
- });
55
- });
@@ -1,38 +0,0 @@
1
- import { describe, it, expect, afterEach, beforeEach } from 'vitest';
2
- import './graph.js';
3
-
4
- // DileGraph relies on a global `Chart` (Chart.js), normally loaded via <script> tag
5
- // in consuming pages, not a module import. Stub it so firstUpdated() doesn't throw.
6
- describe('dile-graph', () => {
7
- beforeEach(() => {
8
- window.Chart = class {
9
- constructor(ctx, config) {
10
- this.ctx = ctx;
11
- this.config = config;
12
- }
13
- };
14
- });
15
-
16
- afterEach(() => {
17
- document.body.innerHTML = '';
18
- delete window.Chart;
19
- });
20
-
21
- async function renderGraph(html) {
22
- document.body.innerHTML = html;
23
- const el = document.body.querySelector('dile-graph');
24
- await el.updateComplete;
25
- return el;
26
- }
27
-
28
- it('renders a canvas and initializes a Chart instance', async () => {
29
- const el = await renderGraph('<dile-graph></dile-graph>');
30
- expect(el.shadowRoot.querySelector('canvas')).toBeTruthy();
31
- expect(el.myChart).toBeInstanceOf(window.Chart);
32
- });
33
-
34
- it('defaults chartType to line', async () => {
35
- const el = await renderGraph('<dile-graph></dile-graph>');
36
- expect(el.chartType).toBe('line');
37
- });
38
- });
@@ -1,25 +0,0 @@
1
- import { describe, it, expect, afterEach } from 'vitest';
2
- import './html-transform.js';
3
-
4
- describe('dile-html-transform', () => {
5
- afterEach(() => {
6
- document.body.innerHTML = '';
7
- });
8
-
9
- async function renderHtmlTransform(html) {
10
- document.body.innerHTML = html;
11
- const el = document.body.querySelector('dile-html-transform');
12
- await el.updateComplete;
13
- return el;
14
- }
15
-
16
- it('renders the plain text when no conversion flags are set', async () => {
17
- const el = await renderHtmlTransform('<dile-html-transform text="hello world"></dile-html-transform>');
18
- expect(el.shadowRoot.textContent.trim()).toBe('hello world');
19
- });
20
-
21
- it('converts a link when convertLinks is set', async () => {
22
- const el = await renderHtmlTransform('<dile-html-transform text="visit example.com" convertLinks></dile-html-transform>');
23
- expect(el.shadowRoot.querySelector('a')).toBeTruthy();
24
- });
25
- });