@dile/ui 3.20.1 → 3.20.2

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.
@@ -19,22 +19,41 @@ export class DileChip extends LitElement {
19
19
  padding-bottom: var(--dile-chip-padding-y, 0.3rem);
20
20
  border-radius: var(--dile-chip-border-radius, 0);
21
21
  }
22
- span {
22
+ .text {
23
23
  font-size: var(--dile-chip-font-size, 1rem);
24
24
  font-weight: var(--dile-chip-font-weight, bold);
25
25
  color: var(--dile-chip-text-color, #303030);
26
26
  display: inline-block;
27
27
  margin-right: 20px;
28
- transition: color 0.3s ease;
29
28
  }
30
- dile-icon {
29
+ button {
30
+ all: unset;
31
+ box-sizing: border-box;
32
+ display: inline-flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ /* Enlarge the hit area (WCAG 2.5.8) without changing the visual size */
36
+ padding: 4px;
37
+ margin: -4px;
38
+ min-width: 24px;
39
+ min-height: 24px;
40
+ border-radius: 4px;
41
+ cursor: pointer;
31
42
  --dile-icon-color: var(--dile-chip-icon-color, #303030);
32
43
  --dile-icon-size: var(--dile-chip-icon-size, 16px);
33
- cursor: pointer;
44
+ -webkit-tap-highlight-color: transparent;
34
45
  }
35
- dile-icon:hover {
46
+ button:hover,
47
+ button:focus-visible {
36
48
  --dile-icon-color: var(--dile-chip-icon-hover-color, #d06060);
37
49
  }
50
+ button:focus-visible {
51
+ outline: 2px solid var(--dile-chip-focus-outline-color, var(--dile-primary-color, #1a73e8));
52
+ outline-offset: 0;
53
+ }
54
+ .action-label {
55
+ display: none;
56
+ }
38
57
  `;
39
58
  }
40
59
 
@@ -42,23 +61,45 @@ export class DileChip extends LitElement {
42
61
  return {
43
62
  name: { type: String },
44
63
  icon: { type: Object },
64
+ iconLabel: { type: String, attribute: 'icon-label' },
45
65
  };
46
66
  }
47
67
 
48
68
  constructor() {
49
69
  super();
50
70
  this.icon = clearIcon;
71
+ this.iconLabel = 'Remove';
51
72
  }
52
73
 
53
74
  render() {
54
75
  return html`
55
76
  <div>
56
- <span><slot></slot></span>
57
- <dile-icon .icon="${this.icon}" @click="${this.doClick}"></dile-icon>
77
+ <span class="text" id="text"><slot></slot></span>
78
+ <span class="action-label" id="action">${this.iconLabel}</span>
79
+ <button
80
+ type="button"
81
+ part="button"
82
+ aria-labelledby="action text"
83
+ @click="${this.doClick}"
84
+ @keydown="${this.onKeyDown}"
85
+ >
86
+ <dile-icon .icon="${this.icon}" aria-hidden="true"></dile-icon>
87
+ </button>
58
88
  </div>
59
89
  `;
60
90
  }
61
91
 
92
+ onKeyDown(e) {
93
+ if (e.key === 'Delete' || e.key === 'Backspace') {
94
+ e.preventDefault();
95
+ this.doClick();
96
+ }
97
+ }
98
+
99
+ focus(options) {
100
+ this.shadowRoot?.querySelector('button')?.focus(options);
101
+ }
102
+
62
103
  doClick() {
63
104
  this.dispatchEvent(new CustomEvent('dile-chip-icon-click', {
64
105
  bubbles: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "3.20.1",
3
+ "version": "3.20.2",
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": "2312fc5bacc0b5499c99cd25be6ae3509fd026c1"
31
+ "gitHead": "c6bb68030489b454927cbe7f36dd49388d87ff71"
32
32
  }