@dile/ui 3.12.4 → 3.13.0

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.
@@ -13,7 +13,7 @@ describe('dile-input-search', () => {
13
13
  return el;
14
14
  }
15
15
 
16
- it('renders a native text input and a search icon', async () => {
16
+ it('renders a native search input and a search icon', async () => {
17
17
  const el = await renderInputSearch('<dile-input-search placeholder="Search..."></dile-input-search>');
18
18
  const input = el.shadowRoot.querySelector('input');
19
19
  expect(input).toBeTruthy();
@@ -21,6 +21,16 @@ describe('dile-input-search', () => {
21
21
  expect(el.shadowRoot.querySelector('dile-icon')).toBeTruthy();
22
22
  });
23
23
 
24
+ it('renders the input as a search field with browser and password manager autofill disabled', async () => {
25
+ const el = await renderInputSearch('<dile-input-search></dile-input-search>');
26
+ const input = el.shadowRoot.querySelector('input');
27
+ expect(input.type).toBe('search');
28
+ expect(input.getAttribute('autocomplete')).toBe('off');
29
+ expect(input.hasAttribute('data-1p-ignore')).toBe(true);
30
+ expect(input.getAttribute('data-lpignore')).toBe('true');
31
+ expect(input.getAttribute('data-form-type')).toBe('other');
32
+ });
33
+
24
34
  it('updates the value on input and dispatches dile-input-search after the delay', async () => {
25
35
  const el = await renderInputSearch('<dile-input-search delay="10"></dile-input-search>');
26
36
  const input = el.shadowRoot.querySelector('input');
@@ -35,6 +35,12 @@ export class DileInputSearch extends LitElement {
35
35
  input:focus {
36
36
  outline: none;
37
37
  }
38
+ input::-webkit-search-cancel-button,
39
+ input::-webkit-search-decoration {
40
+ -webkit-appearance: none;
41
+ appearance: none;
42
+ display: none;
43
+ }
38
44
  input::placeholder {
39
45
  /* WCAG AA contrast: #666 sobre #fff = 7.5:1 */
40
46
  color: var(--dile-input-placeholder-color, #666);
@@ -116,10 +122,13 @@ export class DileInputSearch extends LitElement {
116
122
  <div class="${this.errored ? "errored" : ""}">
117
123
  <input
118
124
  id="elinput"
119
- type="text"
125
+ type="search"
120
126
  placeholder="${this.placeholder}"
121
127
  @input=${this.inputHandler}
122
128
  autocomplete="off"
129
+ data-1p-ignore
130
+ data-lpignore="true"
131
+ data-form-type="other"
123
132
  .value="${this.value}"
124
133
  ?disabled="${this.disabled}"
125
134
  ?readonly="${this.readOnly}"
@@ -1,8 +1,16 @@
1
1
  import { html, css, LitElement } from "lit";
2
+ import { ifDefined } from "lit/directives/if-defined.js";
2
3
  import { DileSelectableItem } from "../../../mixins/selectable/index.js";
3
4
 
4
5
  export class DileTab extends DileSelectableItem(LitElement) {
5
6
 
7
+ static get properties() {
8
+ return {
9
+ href: { type: String },
10
+ target: { type: String },
11
+ };
12
+ }
13
+
6
14
  static get styles() {
7
15
  return css`
8
16
  :host {
@@ -40,6 +48,11 @@ export class DileTab extends DileSelectableItem(LitElement) {
40
48
  .markselected {
41
49
  width: 100%;
42
50
  }
51
+ a {
52
+ display: block;
53
+ color: inherit;
54
+ text-decoration: none;
55
+ }
43
56
  .line {
44
57
  display: flex;
45
58
  justify-content: center;
@@ -48,6 +61,15 @@ export class DileTab extends DileSelectableItem(LitElement) {
48
61
  }
49
62
 
50
63
  render() {
64
+ if (this.href) {
65
+ return html`
66
+ <a href="${this.href}" target="${ifDefined(this.target)}">${this.tabTemplate}</a>
67
+ `;
68
+ }
69
+ return this.tabTemplate;
70
+ }
71
+
72
+ get tabTemplate() {
51
73
  return html`
52
74
  <article @click='${this.select}' class="${this.selected ? 'selected' : ''}">
53
75
  <div class="label"><slot></slot></div>
@@ -42,4 +42,44 @@ describe('dile-tabs', () => {
42
42
 
43
43
  expect(el.selected).toBe(1);
44
44
  });
45
+
46
+ it('renders a native link when the tab has an href', async () => {
47
+ const el = await renderTabs(`
48
+ <dile-tabs>
49
+ <dile-tab href="/one">One</dile-tab>
50
+ <dile-tab href="https://example.com" target="_blank">Two</dile-tab>
51
+ <dile-tab>Three</dile-tab>
52
+ </dile-tabs>
53
+ `);
54
+
55
+ const tabs = el.querySelectorAll('dile-tab');
56
+ await Promise.all([...tabs].map((tab) => tab.updateComplete));
57
+
58
+ const link1 = tabs[0].shadowRoot.querySelector('a');
59
+ expect(link1.getAttribute('href')).toBe('/one');
60
+ expect(link1.hasAttribute('target')).toBe(false);
61
+ expect(link1.querySelector('article')).not.toBeNull();
62
+
63
+ const link2 = tabs[1].shadowRoot.querySelector('a');
64
+ expect(link2.getAttribute('target')).toBe('_blank');
65
+
66
+ expect(tabs[2].shadowRoot.querySelector('a')).toBeNull();
67
+ });
68
+
69
+ it('keeps selection working for tabs with href', async () => {
70
+ const el = await renderTabs(`
71
+ <dile-tabs attrForSelected="name" selected="two">
72
+ <dile-tab name="one" href="#one">One</dile-tab>
73
+ <dile-tab name="two" href="#two">Two</dile-tab>
74
+ </dile-tabs>
75
+ `);
76
+
77
+ const tabs = el.querySelectorAll('dile-tab');
78
+ await tabs[1].updateComplete;
79
+ expect(tabs[1].selected).toBe(true);
80
+
81
+ tabs[0].shadowRoot.querySelector('article').click();
82
+ await el.updateComplete;
83
+ expect(el.selected).toBe('one');
84
+ });
45
85
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "3.12.4",
3
+ "version": "3.13.0",
4
4
  "description": "UI Core components from dile-components.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "29dbec2b9bc0a8f5613158409950ffd3456af179"
31
+ "gitHead": "e4b428c6b9cee3e0f20520c5baa979e232f90dda"
32
32
  }