@api-client/ui 0.3.2 → 0.3.4

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 (85) hide show
  1. package/build/src/elements/environment/EnvironmentEditor.d.ts.map +1 -1
  2. package/build/src/elements/environment/EnvironmentEditor.js +8 -6
  3. package/build/src/elements/environment/EnvironmentEditor.js.map +1 -1
  4. package/build/src/elements/har/HarViewer.d.ts.map +1 -1
  5. package/build/src/elements/har/HarViewer.js +13 -15
  6. package/build/src/elements/har/HarViewer.js.map +1 -1
  7. package/build/src/elements/http/RequestEditor.d.ts +2 -1
  8. package/build/src/elements/http/RequestEditor.d.ts.map +1 -1
  9. package/build/src/elements/http/RequestEditor.js +17 -12
  10. package/build/src/elements/http/RequestEditor.js.map +1 -1
  11. package/build/src/elements/http/RequestLog.d.ts.map +1 -1
  12. package/build/src/elements/http/RequestLog.js +34 -8
  13. package/build/src/elements/http/RequestLog.js.map +1 -1
  14. package/build/src/md/button/internals/base.d.ts.map +1 -1
  15. package/build/src/md/button/internals/base.js +2 -6
  16. package/build/src/md/button/internals/base.js.map +1 -1
  17. package/build/src/md/button/internals/button.styles.js +4 -4
  18. package/build/src/md/button/internals/button.styles.js.map +1 -1
  19. package/build/src/md/chip/internals/Chip.d.ts +11 -15
  20. package/build/src/md/chip/internals/Chip.d.ts.map +1 -1
  21. package/build/src/md/chip/internals/Chip.js +66 -104
  22. package/build/src/md/chip/internals/Chip.js.map +1 -1
  23. package/build/src/md/chip/internals/Chip.styles.d.ts.map +1 -1
  24. package/build/src/md/chip/internals/Chip.styles.js +114 -101
  25. package/build/src/md/chip/internals/Chip.styles.js.map +1 -1
  26. package/build/src/md/chip/internals/ChipSet.d.ts +16 -0
  27. package/build/src/md/chip/internals/ChipSet.d.ts.map +1 -0
  28. package/build/src/md/chip/internals/ChipSet.js +138 -0
  29. package/build/src/md/chip/internals/ChipSet.js.map +1 -0
  30. package/build/src/md/chip/internals/ChipSet.styles.d.ts +3 -0
  31. package/build/src/md/chip/internals/ChipSet.styles.d.ts.map +1 -0
  32. package/build/src/md/chip/internals/ChipSet.styles.js +9 -0
  33. package/build/src/md/chip/internals/ChipSet.styles.js.map +1 -0
  34. package/build/src/md/chip/ui-chip-set.d.ts +11 -0
  35. package/build/src/md/chip/ui-chip-set.d.ts.map +1 -0
  36. package/build/src/md/chip/ui-chip-set.js +27 -0
  37. package/build/src/md/chip/ui-chip-set.js.map +1 -0
  38. package/build/src/md/motion/animation.d.ts +5 -3
  39. package/build/src/md/motion/animation.d.ts.map +1 -1
  40. package/build/src/md/motion/animation.js +4 -2
  41. package/build/src/md/motion/animation.js.map +1 -1
  42. package/build/src/md/ripple/internals/ripple.styles.d.ts.map +1 -1
  43. package/build/src/md/ripple/internals/ripple.styles.js +20 -8
  44. package/build/src/md/ripple/internals/ripple.styles.js.map +1 -1
  45. package/build/src/md/switch/internals/Switch.styles.js +1 -1
  46. package/build/src/md/switch/internals/Switch.styles.js.map +1 -1
  47. package/build/src/md/tabs/internals/Tab.d.ts +25 -9
  48. package/build/src/md/tabs/internals/Tab.d.ts.map +1 -1
  49. package/build/src/md/tabs/internals/Tab.js +122 -53
  50. package/build/src/md/tabs/internals/Tab.js.map +1 -1
  51. package/build/src/md/tabs/internals/Tab.styles.d.ts.map +1 -1
  52. package/build/src/md/tabs/internals/Tab.styles.js +69 -64
  53. package/build/src/md/tabs/internals/Tab.styles.js.map +1 -1
  54. package/build/src/md/tabs/internals/Tabs.d.ts +52 -54
  55. package/build/src/md/tabs/internals/Tabs.d.ts.map +1 -1
  56. package/build/src/md/tabs/internals/Tabs.js +270 -330
  57. package/build/src/md/tabs/internals/Tabs.js.map +1 -1
  58. package/build/src/md/tabs/internals/Tabs.styles.d.ts.map +1 -1
  59. package/build/src/md/tabs/internals/Tabs.styles.js +13 -17
  60. package/build/src/md/tabs/internals/Tabs.styles.js.map +1 -1
  61. package/demo/md/chip/chip.html +33 -6
  62. package/demo/md/chip/chip.ts +111 -56
  63. package/demo/md/tabs/tabs.html +19 -0
  64. package/demo/md/tabs/tabs.ts +133 -83
  65. package/package.json +1 -1
  66. package/src/elements/environment/EnvironmentEditor.ts +8 -6
  67. package/src/elements/har/HarViewer.ts +13 -15
  68. package/src/elements/http/RequestEditor.ts +18 -13
  69. package/src/elements/http/RequestLog.ts +34 -8
  70. package/src/md/button/internals/base.ts +2 -6
  71. package/src/md/button/internals/button.styles.ts +4 -4
  72. package/src/md/chip/internals/Chip.styles.ts +114 -101
  73. package/src/md/chip/internals/Chip.ts +58 -88
  74. package/src/md/chip/internals/ChipSet.styles.ts +9 -0
  75. package/src/md/chip/internals/ChipSet.ts +142 -0
  76. package/src/md/chip/ui-chip-set.ts +15 -0
  77. package/src/md/motion/animation.ts +4 -2
  78. package/src/md/ripple/internals/ripple.styles.ts +20 -8
  79. package/src/md/switch/internals/Switch.styles.ts +1 -1
  80. package/src/md/tabs/internals/Tab.styles.ts +69 -64
  81. package/src/md/tabs/internals/Tab.ts +126 -43
  82. package/src/md/tabs/internals/Tabs.styles.ts +13 -17
  83. package/src/md/tabs/internals/Tabs.ts +259 -305
  84. package/test/elements/har/HarViewerElement.test.ts +1 -55
  85. package/test/ui/chip/UiChip.test.ts +18 -67
@@ -6,166 +6,179 @@ export default css`
6
6
  vertical-align: middle;
7
7
  outline: none;
8
8
  -webkit-tap-highlight-color: transparent;
9
- height: 32px;
9
+ position: relative;
10
+ user-select: none;
10
11
 
11
12
  font-family: var(--md-sys-typescale-label-large-font);
12
13
  font-size: var(--md-sys-typescale-label-large-size);
13
14
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
14
15
  line-height: var(--md-sys-typescale-label-large-height);
15
16
 
16
- border-radius: var(--md-sys-shape-corner-small);
17
- color: var(--md-sys-color-on-surface);
18
- fill: var(--md-sys-color-primary);
19
-
20
- user-select: none;
21
-
22
17
  --md-ripple-hover-state-layer-color: var(--md-sys-color-on-surface);
23
18
  --md-ripple-focus-state-layer-color: var(--md-sys-color-on-surface);
24
19
  --md-ripple-pressed-state-layer-color: var(--md-sys-color-primary);
25
- }
26
20
 
27
- :host([disabled]) {
28
- pointer-events: none;
29
- }
30
-
31
- :host([disabled]) .container {
32
- border-color: var(--md-sys-color-on-surface);
33
- opacity: 0.12;
34
- }
21
+ --_leading-icon-color: currentColor;
22
+ --_trailing-icon-color: currentColor;
23
+ --_background-color: transparent;
24
+ --_color: inherit;
25
+ --_shadow: var(--md-sys-elevation-0);
26
+ --_outline-color: transparent;
27
+ --_outline-size: 0;
28
+ --_inline-padding-start: 16px;
29
+ --_inline-padding-end: 16px;
30
+ --_avatar-size: 24px;
31
+ --_avatar-shape: 24px;
32
+ --_icon-size: 18px;
35
33
 
36
- :host([disabled][elevated]) .container {
37
- background-color: var(--md-sys-color-on-surface);
38
- opacity: 0.12;
39
- box-shadow: none;
40
- }
41
-
42
- :host([disabled]) .content {
43
- color: var(--md-sys-color-on-surface);
44
- opacity: 0.68;
45
- }
46
-
47
- .surface {
48
- position: relative;
49
- height: inherit;
50
- border-radius: inherit;
34
+ height: 32px;
35
+ border-radius: var(--md-sys-shape-corner-small);
36
+ box-shadow: var(--_shadow);
37
+ border: var(--_outline-size) solid var(--_outline-color);
51
38
  }
52
39
 
53
40
  .ripple {
54
- z-index: 0;
55
41
  border-radius: inherit;
42
+ transition: border-radius var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-standard);
56
43
  }
57
44
 
58
- .container {
59
- position: absolute;
60
- inset: 0;
45
+ .ripple.activated {
46
+ z-index: 1;
47
+ }
61
48
 
62
- box-sizing: border-box;
63
- border-radius: inherit;
64
- border: 1px var(--md-sys-color-outline) solid;
65
- z-index: 0;
49
+ :host([disabled]) {
50
+ --_background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
51
+ --_color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
52
+ --_leading-icon-color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
53
+ --_trailing-icon-color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
54
+ --_outline-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
55
+ box-shadow: none;
56
+ cursor: not-allowed;
57
+ pointer-events: none;
66
58
  }
67
59
 
68
- .content {
60
+ .surface {
69
61
  height: inherit;
70
62
  display: flex;
71
63
  align-items: center;
72
64
  justify-content: start;
73
65
  box-sizing: border-box;
74
- padding: 0 16px;
66
+ padding: 0 var(--_inline-padding-end) 0 var(--_inline-padding-start);
75
67
  border-radius: inherit;
76
- border: 1px transparent solid;
77
- position: relative;
78
- z-index: 1;
68
+ background-color: var(--_background-color);
69
+ color: var(--_color);
70
+ gap: 0;
79
71
  }
80
72
 
81
- :host([elevated]) .container {
82
- background-color: var(--md-sys-color-surface);
83
- box-shadow: var(--md-sys-elevation-1);
84
- border-width: 0;
73
+ .leading-icon {
74
+ height: var(--_icon-size);
75
+ width: 0px;
76
+ overflow: hidden;
77
+ transition: width 230ms var(--md-sys-animation-easing-standard);
78
+ color: var(--_leading-icon-color);
79
+ fill: currentColor;
85
80
  }
86
81
 
87
- .withIcon .content,
88
- :host([type='filter'][checked]) .content {
89
- padding-left: 8px;
82
+ .leading-icon::slotted(*) {
83
+ width: var(--_icon-size);
84
+ height: var(--_icon-size);
85
+ margin-right: 8px;
90
86
  }
91
87
 
92
- .withAvatar .content {
93
- padding-left: 4px;
88
+ slot[name='avatar']::slotted(*) {
89
+ width: var(--_avatar-size);
90
+ height: var(--_avatar-size);
91
+ border-radius: var(--_avatar-shape);
92
+ flex-shrink: 0;
93
+ flex-grow: 0;
94
+ margin-right: 8px;
94
95
  }
95
96
 
96
- :host([closable]) .content,
97
- :host([type='filter'][list]) .content {
98
- padding-right: 8px;
97
+ .check-mark.checked {
98
+ width: 18px;
99
+ margin-right: 8px;
99
100
  }
100
101
 
101
- .withIcon slot[name='icon']::slotted(*),
102
- .withAvatar slot[name='avatar']::slotted(*) {
103
- margin-right: 8px;
102
+ .trailing-icon {
103
+ margin-left: 8px;
104
+ width: 18px;
105
+ height: 18px;
106
+ color: var(--_trailing-icon-color);
107
+ fill: currentColor;
104
108
  }
105
109
 
106
- slot[name='icon']::slotted(*) {
107
- width: 16px;
108
- height: 16px;
110
+ :host([elevated]) {
111
+ --_shadow: var(--md-sys-elevation-1);
112
+ border: none;
113
+ --_background-color: var(--md-sys-color-surface-container-low);
109
114
  }
110
115
 
111
- slot[name='avatar']::slotted(*) {
112
- width: 24px;
113
- height: 24px;
114
- border-radius: var(--md-sys-shape-corner-medium);
116
+ :host([elevated]:hover:not([disabled])) {
117
+ --_shadow: var(--md-sys-elevation-2);
115
118
  }
116
119
 
117
- .leading-icon {
118
- height: 18px;
119
- width: 0px;
120
- overflow: hidden;
121
- transition: width 230ms var(--md-sys-animation-easing-standard);
120
+ .surface.has-trailing-icon {
121
+ --_inline-padding-end: 8px;
122
122
  }
123
123
 
124
- .check-mark.checked {
125
- width: 18px;
126
- margin-right: 8px;
124
+ :host([type='assist']:not([disabled])) {
125
+ --_outline-color: var(--md-sys-color-outline-variant);
126
+ --_outline-size: 1px;
127
+ --_color: var(--md-sys-color-on-surface);
128
+ --_leading-icon-color: var(--md-sys-color-primary);
127
129
  }
128
130
 
129
- .trailing-icon {
130
- margin-left: 8px;
131
- width: 18px;
132
- height: 18px;
133
- fill: var(--md-sys-color-on-surface-variant);
131
+ :host .has-icon {
132
+ --_inline-padding-start: 8px;
133
+ }
134
+
135
+ :host .has-avatar {
136
+ --_inline-padding-start: 4px;
137
+ }
138
+
139
+ :host([checked]) {
140
+ --_inline-padding-start: 8px;
141
+ --_background-color: var(--md-sys-color-secondary-container);
134
142
  }
135
143
 
136
- :host([elevated]:hover) .container,
137
- :host([elevated]:focus) .container {
138
- box-shadow: var(--md-sys-elevation-2);
144
+ :host([type='filter']:not([disabled])) {
145
+ --_leading-icon-color: var(--md-sys-color-primary);
146
+ --_trailing-icon-color: var(--md-sys-on-surface-variant);
147
+ --_outline-color: var(--md-sys-color-outline-variant);
148
+ --_outline-size: 1px;
149
+ --_color: var(--md-sys-color-on-surface-variant);
139
150
  }
140
151
 
141
- :host([elevated][dragged]) .container {
142
- box-shadow: var(--md-sys-elevation-4);
152
+ :host([type='filter'][checked]) {
153
+ --_outline-size: 1px;
143
154
  }
144
155
 
145
- :host([checked]) .container {
146
- background-color: var(--md-sys-color-secondary-container);
147
- border-width: 0;
156
+ :host([type='filter'][checked]:not([disabled])) {
157
+ --_leading-icon-color: var(--md-sys-color-on-secondary-container);
158
+ --_trailing-icon-color: var(--md-sys-on-secondary-container);
159
+ --_outline-color: var(--md-sys-color-secondary-container);
160
+ --_color: var(--md-sys-color-on-secondary-container);
148
161
  }
149
162
 
150
- :host([type='filter']),
151
- :host([type='filter']) .leading-icon {
152
- color: var(--md-sys-color-on-surface-variant);
153
- fill: var(--md-sys-color-on-surface-variant);
163
+ :host([type='input']:not([disabled])) {
164
+ --_outline-color: var(--md-sys-color-outline-variant);
165
+ --_outline-size: 1px;
166
+ --_leading-icon-color: var(--md-sys-color-primary);
167
+ --_trailing-icon-color: var(--md-sys-color-on-surface-variant);
168
+ --_color: var(--md-sys-color-on-surface-variant);
154
169
  }
155
170
 
156
- :host([type='filter'][checked]),
157
- :host([type='filter'][checked]) .leading-icon {
158
- color: var(--md-sys-color-on-secondary-container);
171
+ :host([type='input'][checked]) {
172
+ --_outline-size: 0px;
159
173
  }
160
174
 
161
- :host([type='input']) .container {
162
- background-color: var(--md-sys-color-surface);
163
- color: var(--md-sys-color-on-surface-variant);
175
+ :host([type='suggestion']) {
176
+ --_outline-size: 1px;
177
+ --_outline-color: var(--md-sys-color-outline-variant);
178
+ --_color: var(--md-sys-color-on-surface-variant);
164
179
  }
165
180
 
166
- :host([type='input']) .leading-icon,
167
- :host([type='input']) .trailing-icon {
168
- color: var(--md-sys-color-on-surface-variant);
169
- fill: var(--md-sys-color-on-surface-variant);
181
+ :host([type='suggestion']:not([disabled])) {
182
+ --_leading-icon-color: var(--md-sys-color-primary);
170
183
  }
171
184
  `
@@ -1,11 +1,9 @@
1
1
  import { cancelEvent } from '@api-client/core/lib/events/Utils.js'
2
2
  import { html, nothing, PropertyValues, TemplateResult } from 'lit'
3
- import { property, queryAsync, state } from 'lit/decorators.js'
3
+ import { property, query, state } from 'lit/decorators.js'
4
4
  import { classMap } from 'lit/directives/class-map.js'
5
- import { when } from 'lit/directives/when.js'
6
5
  import { UiElement } from '../../UiElement.js'
7
6
  import UiRipple from '../../ripple/internals/ripple.js'
8
- import { ripple } from '../../effects/rippleDirective.js'
9
7
  import { close, arrowDropDown, check } from '../../icons/Icons.js'
10
8
  import { setDisabled } from '../../../lib/disabled.js'
11
9
  import { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'
@@ -22,9 +20,9 @@ export enum ChipType {
22
20
  * @slot The content of the chip.
23
21
  * @slot icon - The leading icon, sized 18x18 px
24
22
  * @slot avatar - The leading image, sized 24x24 px
25
- * @fires list - When the user requested to activate the list associated with the element.
26
23
  * @fires select - When the checked state changed through a user interaction. This only related to
27
24
  * `filter` chips. Note, `select` is dispatched just before the `click` event.
25
+ * @fires remove - When the user clicks the "remove" icon on the chip.
28
26
  */
29
27
  export default class UiChip extends UiElement {
30
28
  /**
@@ -51,7 +49,7 @@ export default class UiChip extends UiElement {
51
49
  * Whether the chip renders the "close" icon at the end.
52
50
  * @attribute
53
51
  */
54
- @property({ type: Boolean, reflect: true }) accessor closable: boolean | undefined
52
+ @property({ type: Boolean, reflect: true }) accessor removable: boolean | undefined
55
53
 
56
54
  /**
57
55
  * Whether the chip is currently checked.
@@ -61,17 +59,14 @@ export default class UiChip extends UiElement {
61
59
  @property({ type: Boolean, reflect: true }) accessor checked: boolean | undefined
62
60
 
63
61
  /**
64
- * The ID attribute of the list element that is rendered after activating the chip.
65
- * When this is set the chip renders the dropdown icon at the end and sets `aria-*`
66
- * attributes informing the assistive technology that this chip controls a list.
62
+ * When set, the chip will render a trailing icon that indicates that the chip is associated
63
+ * with a list. It does not do anything.
67
64
  *
68
65
  * @attribute
69
66
  */
70
- @property({ type: String, reflect: true }) accessor list: string | undefined
67
+ @property({ type: Boolean, reflect: true }) accessor list: boolean | undefined
71
68
 
72
- @queryAsync('ui-ripple') protected accessor ripple!: Promise<UiRipple | null>
73
-
74
- @state() protected accessor showRipple = false
69
+ @query('ui-ripple') protected accessor ripple!: UiRipple | null
75
70
 
76
71
  /**
77
72
  * Determines when the element has an icon in the "icon" slot.
@@ -93,13 +88,14 @@ export default class UiChip extends UiElement {
93
88
 
94
89
  this.actionController.cancelKeyboardEvents = true
95
90
 
96
- this.addEventListener('click', this.handleClick.bind(this))
97
91
  this.addEventListener('keydown', this.handleKeyDown.bind(this))
98
92
  this.addEventListener('keyup', this.handleKeyUp.bind(this))
93
+ this.addEventListener('click', this.handleClick.bind(this))
99
94
  this.addEventListener('pointerdown', this.handlePointerDown.bind(this))
100
95
  this.addEventListener('pointerup', this.handlePointerUp.bind(this))
101
96
  this.addEventListener('pointercancel', this.handlePointerCancel.bind(this))
102
97
  this.addEventListener('pointerleave', this.handlePointerLeave.bind(this))
98
+ this.addEventListener('pointerenter', this.handlePointerEnter.bind(this))
103
99
  this.addEventListener('contextmenu', this.handleContextMenu.bind(this))
104
100
  this.addEventListener('focus', this.handleFocus.bind(this))
105
101
  this.addEventListener('blur', this.handleBlur.bind(this))
@@ -121,52 +117,32 @@ export default class UiChip extends UiElement {
121
117
  }
122
118
  }
123
119
 
124
- protected async pressRipple(): Promise<void> {
125
- const element = await this.getRipple()
126
- if (element && !element.isPressed) {
127
- element.beginPress()
128
- }
129
- }
130
-
131
- protected async endRipple(): Promise<void> {
132
- const element = await this.getRipple()
133
- element?.endPress()
134
- }
135
-
136
120
  override beginPress(options: BeginPressConfig): void {
137
121
  super.beginPress(options)
138
- this.pressRipple()
122
+ this.classList.add('pressed')
123
+ this.ripple?.beginPress(options.positionEvent)
139
124
  }
140
125
 
141
126
  override async handleKeyDown(e: KeyboardEvent): Promise<void> {
142
127
  super.handleKeyDown(e)
143
- if (this.type === ChipType.filter && e.code === 'ArrowDown') {
128
+ if (this.removable && e.code === 'Backspace') {
144
129
  e.preventDefault()
145
- this.listAction()
146
- } else if (this.closable && e.code === 'Backspace') {
147
- e.preventDefault()
148
- this.closeAction()
130
+ this.removeAction()
149
131
  }
150
132
  }
151
133
 
152
134
  protected async handleFocus(): Promise<void> {
153
- const element = await this.getRipple()
154
- element?.beginFocus()
135
+ this.ripple?.beginFocus()
155
136
  }
156
137
 
157
138
  protected async handleBlur(): Promise<void> {
158
- const element = await this.getRipple()
159
- element?.endFocus()
160
- }
161
-
162
- protected readonly getRipple = (): Promise<UiRipple | null> => {
163
- this.showRipple = true
164
- return this.ripple
139
+ this.ripple?.endFocus()
165
140
  }
166
141
 
167
142
  override endPress(info: EndPressConfig): void {
168
143
  super.endPress(info)
169
- this.endRipple()
144
+ this.classList.remove('pressed')
145
+ this.ripple?.endPress()
170
146
  const { cancelled, reason } = info
171
147
  if (cancelled) {
172
148
  return
@@ -183,6 +159,16 @@ export default class UiChip extends UiElement {
183
159
  }
184
160
  }
185
161
 
162
+ override handlePointerEnter(e: PointerEvent): void {
163
+ super.handlePointerEnter(e)
164
+ this.ripple?.beginHover(e)
165
+ }
166
+
167
+ override handlePointerLeave(e: PointerEvent): void {
168
+ super.handlePointerLeave(e)
169
+ this.ripple?.endHover()
170
+ }
171
+
186
172
  /**
187
173
  * Toggles the "filter" type of the chip.
188
174
  */
@@ -207,47 +193,37 @@ export default class UiChip extends UiElement {
207
193
  this.hasAvatar = !!slot.assignedNodes().length
208
194
  }
209
195
 
210
- protected handleListClick(e: Event): void {
211
- e.preventDefault()
212
- e.stopPropagation()
213
- this.listAction()
214
- }
215
-
216
196
  protected handleClose(e: Event): void {
217
197
  e.preventDefault()
218
198
  e.stopPropagation()
219
- this.closeAction()
199
+ this.removeAction()
220
200
  }
221
201
 
222
- protected async closeAction(): Promise<void> {
223
- this.dispatchEvent(new Event('close'))
224
- }
225
-
226
- protected async listAction(): Promise<void> {
227
- this.dispatchEvent(new Event('list'))
202
+ protected async removeAction(): Promise<void> {
203
+ this.dispatchEvent(new Event('remove'))
228
204
  }
229
205
 
230
206
  protected override render(): TemplateResult {
231
- const { pressed = false } = this
232
207
  const containerClasses = classMap({
233
- surface: true,
234
- withIcon: this.hasIcon,
235
- withAvatar: this.hasAvatar,
236
- pressed,
208
+ 'surface': true,
209
+ 'has-icon': this.hasIcon,
210
+ 'has-avatar': this.hasAvatar,
211
+ 'has-trailing-icon': this.hasTrailingIcon,
237
212
  })
238
213
  return html`
239
- <div class="${containerClasses}" ${ripple(this.getRipple)}>
240
- <div class="container"></div>
241
- ${when(this.showRipple, this.renderRipple)}
242
- <div class="content">
243
- ${this.renderLeadingIcon()} ${this.renderAvatar()}
244
- <slot></slot>
245
- ${this.renderTrailingIcon()}
246
- </div>
214
+ ${this.renderRipple()}
215
+ <div class="${containerClasses}">
216
+ ${this.renderLeadingIcon()} ${this.renderAvatar()}
217
+ <slot></slot>
218
+ ${this.renderTrailingIcon()}
247
219
  </div>
248
220
  `
249
221
  }
250
222
 
223
+ protected renderRipple(): TemplateResult {
224
+ return html`<ui-ripple class="ripple" ?disabled="${this.disabled}"></ui-ripple>`
225
+ }
226
+
251
227
  protected renderLeadingIcon(): TemplateResult | typeof nothing {
252
228
  const { type } = this
253
229
  if (type === ChipType.suggestion) {
@@ -261,31 +237,19 @@ export default class UiChip extends UiElement {
261
237
  })
262
238
  return html`<span class="${iconClasses}" role="presentation">${check}</span>`
263
239
  }
264
- return html`<slot name="icon" @slotchange="${this.handleIconSlotChange}"></slot>`
240
+ return html`<slot class="leading-icon" name="icon" @slotchange="${this.handleIconSlotChange}"></slot>`
265
241
  }
266
242
 
267
243
  protected renderAvatar(): TemplateResult | typeof nothing {
268
- const { type } = this
269
- if (type === ChipType.input) {
270
- return html`<slot name="avatar" @slotchange="${this.handleAvatarSlotChange}"></slot>`
271
- }
272
- return nothing
244
+ return html`<slot name="avatar" @slotchange="${this.handleAvatarSlotChange}"></slot>`
273
245
  }
274
246
 
275
247
  protected renderTrailingIcon(): TemplateResult | typeof nothing {
276
- const { closable = false, list, type } = this
277
- if (type === ChipType.filter) {
278
- if (list) {
279
- return html`<span
280
- class="trailing-icon"
281
- role="presentation"
282
- @click="${this.handleListClick}"
283
- @keypress="${cancelEvent}"
284
- >${arrowDropDown}</span
285
- >`
286
- }
248
+ const { removable = false, list, type } = this
249
+ if (type === ChipType.filter && list) {
250
+ return html`<span class="trailing-icon" role="presentation">${arrowDropDown}</span>`
287
251
  }
288
- if (type === ChipType.input && closable) {
252
+ if (type === ChipType.input && removable) {
289
253
  return html`<span
290
254
  class="trailing-icon"
291
255
  @click="${this.handleClose}"
@@ -298,8 +262,14 @@ export default class UiChip extends UiElement {
298
262
  return nothing
299
263
  }
300
264
 
301
- protected renderRipple = (): TemplateResult => {
302
- const { disabled } = this
303
- return html`<ui-ripple class="ripple" ?disabled="${disabled}"></ui-ripple>`
265
+ get hasTrailingIcon(): boolean {
266
+ const { removable = false, list, type } = this
267
+ if (type === ChipType.filter && list) {
268
+ return true
269
+ }
270
+ if (type === ChipType.input && removable) {
271
+ return true
272
+ }
273
+ return false
304
274
  }
305
275
  }
@@ -0,0 +1,9 @@
1
+ import { css } from 'lit'
2
+
3
+ export default css`
4
+ :host {
5
+ display: flex;
6
+ flex-wrap: wrap;
7
+ gap: 8px;
8
+ }
9
+ `