@lit-material/chip 0.0.2 → 0.1.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.
- package/README.md +35 -0
- package/custom-elements.json +730 -0
- package/dist/chip-input.d.ts +59 -0
- package/dist/chip-input.d.ts.map +1 -0
- package/dist/chip-input.js +263 -0
- package/dist/chip-input.js.map +1 -0
- package/dist/chip-styles.js +1 -1
- package/dist/chip.d.ts +2 -0
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +6 -1
- package/dist/chip.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -59,6 +59,41 @@ action triggers, removable tags), not a value a `<form>` submits, matching how M
|
|
|
59
59
|
itself treats chips. Track a `filter` chip set's selection or an `input` chip list by listening for
|
|
60
60
|
`change`/`remove` rather than reading `FormData`.
|
|
61
61
|
|
|
62
|
+
## `lit-material-chip-input`
|
|
63
|
+
|
|
64
|
+
A field that turns what you type into chips: tags, labels, email addresses, allowed hosts.
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<lit-material-chip-input id="hosts" label="Allowed hosts" placeholder="api.example.com"></lit-material-chip-input>
|
|
68
|
+
<script type="module">
|
|
69
|
+
import "@lit-material/chip";
|
|
70
|
+
const hosts = document.querySelector("#hosts");
|
|
71
|
+
hosts.validator = (v) => (/^[a-z0-9.-]+$/.test(v) ? "" : "Not a host name");
|
|
72
|
+
hosts.addEventListener("change", (e) => console.log(e.detail.values));
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
| Property | Attribute | Type | Default |
|
|
77
|
+
| ----------------- | ------------------ | --------------------- | ------- |
|
|
78
|
+
| `values` | — | `string[]` | `[]` |
|
|
79
|
+
| `label` | `label` | `string` | `""` |
|
|
80
|
+
| `placeholder` | `placeholder` | `string` | `""` |
|
|
81
|
+
| `supportingText` | `supporting-text` | `string` | `""` |
|
|
82
|
+
| `validator` | — | `(value) => string` | — |
|
|
83
|
+
| `allowDuplicates` | `allow-duplicates` | `boolean` | `false` |
|
|
84
|
+
| `max` | `max` | `number` (0: no limit)| `0` |
|
|
85
|
+
| `disabled` | `disabled` (reflected) | `boolean` | `false` |
|
|
86
|
+
| `invalid` | `invalid` (reflected, read it) | `boolean` | `false` |
|
|
87
|
+
|
|
88
|
+
Enter or a comma adds the typed value; a paste of several values (commas, spaces, new lines) adds
|
|
89
|
+
them all and leaves any refused ones in the field. Backspace in the empty field removes the last
|
|
90
|
+
chip; each chip's remove button is named "Remove <value>". A refused value keeps its text and shows
|
|
91
|
+
why under the field (duplicates, `max`, `validator`). Methods `add(value)` (returns the refusal,
|
|
92
|
+
`""` when added) and `removeAt(index)`; event `change` with `detail: { values }`. Additions and
|
|
93
|
+
removals are announced.
|
|
94
|
+
|
|
95
|
+
`lit-material-chip` also gained `remove-label` (default `"Remove"`), the remove button's name.
|
|
96
|
+
|
|
62
97
|
## License
|
|
63
98
|
|
|
64
99
|
MIT
|
|
@@ -0,0 +1,730 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/chip-input.ts",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "class",
|
|
11
|
+
"description": "A field that turns what you type into chips: tags, labels, email\naddresses, allowed hosts. Enter or a comma adds the typed value; pasting\nseveral values separated by commas, spaces or new lines adds them all.\nEach chip has a remove button, and Backspace in the empty field removes\nthe last one.\n\n`validator` refuses a value with a message (shown under the field, the\ntext stays for fixing); duplicates are refused unless `allow-duplicates`.",
|
|
12
|
+
"name": "LitMaterialChipInput",
|
|
13
|
+
"cssParts": [
|
|
14
|
+
{
|
|
15
|
+
"description": "The box holding the chips and the input.",
|
|
16
|
+
"name": "field"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"description": "The text input.",
|
|
20
|
+
"name": "input"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"members": [
|
|
24
|
+
{
|
|
25
|
+
"kind": "field",
|
|
26
|
+
"name": "values",
|
|
27
|
+
"type": {
|
|
28
|
+
"text": "string[]"
|
|
29
|
+
},
|
|
30
|
+
"default": "[]",
|
|
31
|
+
"description": "The chips' values."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"kind": "field",
|
|
35
|
+
"name": "label",
|
|
36
|
+
"type": {
|
|
37
|
+
"text": "string"
|
|
38
|
+
},
|
|
39
|
+
"default": "\"\"",
|
|
40
|
+
"description": "Visible label above the field; also names the input.",
|
|
41
|
+
"attribute": "label"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"kind": "field",
|
|
45
|
+
"name": "placeholder",
|
|
46
|
+
"type": {
|
|
47
|
+
"text": "string"
|
|
48
|
+
},
|
|
49
|
+
"default": "\"\"",
|
|
50
|
+
"attribute": "placeholder"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"kind": "field",
|
|
54
|
+
"name": "supportingText",
|
|
55
|
+
"type": {
|
|
56
|
+
"text": "string"
|
|
57
|
+
},
|
|
58
|
+
"default": "\"\"",
|
|
59
|
+
"description": "Help under the field, replaced by an error while there is one.",
|
|
60
|
+
"attribute": "supporting-text"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"kind": "field",
|
|
64
|
+
"name": "validator",
|
|
65
|
+
"type": {
|
|
66
|
+
"text": "(value: string) => string | undefined"
|
|
67
|
+
},
|
|
68
|
+
"description": "Refuses a value: return a message, or `\"\"` to accept."
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"kind": "field",
|
|
72
|
+
"name": "allowDuplicates",
|
|
73
|
+
"type": {
|
|
74
|
+
"text": "boolean"
|
|
75
|
+
},
|
|
76
|
+
"default": "false",
|
|
77
|
+
"attribute": "allow-duplicates"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"kind": "field",
|
|
81
|
+
"name": "max",
|
|
82
|
+
"type": {
|
|
83
|
+
"text": "number"
|
|
84
|
+
},
|
|
85
|
+
"default": "0",
|
|
86
|
+
"description": "Most chips allowed; `0` for no limit.",
|
|
87
|
+
"attribute": "max"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"kind": "field",
|
|
91
|
+
"name": "disabled",
|
|
92
|
+
"type": {
|
|
93
|
+
"text": "boolean"
|
|
94
|
+
},
|
|
95
|
+
"default": "false",
|
|
96
|
+
"attribute": "disabled",
|
|
97
|
+
"reflects": true
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"kind": "field",
|
|
101
|
+
"name": "invalid",
|
|
102
|
+
"type": {
|
|
103
|
+
"text": "boolean"
|
|
104
|
+
},
|
|
105
|
+
"default": "false",
|
|
106
|
+
"description": "Set while the typed value was refused; reflected.",
|
|
107
|
+
"attribute": "invalid",
|
|
108
|
+
"reflects": true
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"kind": "field",
|
|
112
|
+
"name": "error",
|
|
113
|
+
"type": {
|
|
114
|
+
"text": "string"
|
|
115
|
+
},
|
|
116
|
+
"privacy": "private",
|
|
117
|
+
"default": "\"\""
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"kind": "field",
|
|
121
|
+
"name": "announcement",
|
|
122
|
+
"type": {
|
|
123
|
+
"text": "string"
|
|
124
|
+
},
|
|
125
|
+
"privacy": "private",
|
|
126
|
+
"default": "\"\""
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"kind": "field",
|
|
130
|
+
"name": "input",
|
|
131
|
+
"type": {
|
|
132
|
+
"text": "HTMLInputElement"
|
|
133
|
+
},
|
|
134
|
+
"privacy": "private",
|
|
135
|
+
"readonly": true
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"kind": "field",
|
|
139
|
+
"name": "uid",
|
|
140
|
+
"privacy": "private",
|
|
141
|
+
"readonly": true,
|
|
142
|
+
"default": "`chip-input-${++nextId}`"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"kind": "method",
|
|
146
|
+
"name": "focus",
|
|
147
|
+
"return": {
|
|
148
|
+
"type": {
|
|
149
|
+
"text": "void"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"parameters": [
|
|
153
|
+
{
|
|
154
|
+
"name": "options",
|
|
155
|
+
"optional": true,
|
|
156
|
+
"type": {
|
|
157
|
+
"text": "FocusOptions"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"kind": "method",
|
|
164
|
+
"name": "add",
|
|
165
|
+
"return": {
|
|
166
|
+
"type": {
|
|
167
|
+
"text": "string"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"parameters": [
|
|
171
|
+
{
|
|
172
|
+
"name": "raw",
|
|
173
|
+
"type": {
|
|
174
|
+
"text": "string"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"description": "Adds `raw` (trimmed); returns the refusal message, `\"\"` on success."
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"kind": "method",
|
|
182
|
+
"name": "removeAt",
|
|
183
|
+
"return": {
|
|
184
|
+
"type": {
|
|
185
|
+
"text": "void"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"parameters": [
|
|
189
|
+
{
|
|
190
|
+
"name": "index",
|
|
191
|
+
"type": {
|
|
192
|
+
"text": "number"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"description": "Removes the chip at `index`."
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"kind": "method",
|
|
200
|
+
"name": "setError",
|
|
201
|
+
"privacy": "private",
|
|
202
|
+
"return": {
|
|
203
|
+
"type": {
|
|
204
|
+
"text": "void"
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"parameters": [
|
|
208
|
+
{
|
|
209
|
+
"name": "message",
|
|
210
|
+
"type": {
|
|
211
|
+
"text": "string"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"kind": "method",
|
|
218
|
+
"name": "emit",
|
|
219
|
+
"privacy": "private",
|
|
220
|
+
"return": {
|
|
221
|
+
"type": {
|
|
222
|
+
"text": "void"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"kind": "method",
|
|
228
|
+
"name": "commitTyped",
|
|
229
|
+
"privacy": "private",
|
|
230
|
+
"return": {
|
|
231
|
+
"type": {
|
|
232
|
+
"text": "void"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"kind": "method",
|
|
238
|
+
"name": "onKeyDown",
|
|
239
|
+
"privacy": "private",
|
|
240
|
+
"return": {
|
|
241
|
+
"type": {
|
|
242
|
+
"text": "void"
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
"parameters": [
|
|
246
|
+
{
|
|
247
|
+
"name": "event",
|
|
248
|
+
"type": {
|
|
249
|
+
"text": "KeyboardEvent"
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"kind": "method",
|
|
256
|
+
"name": "onPaste",
|
|
257
|
+
"privacy": "private",
|
|
258
|
+
"return": {
|
|
259
|
+
"type": {
|
|
260
|
+
"text": "void"
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"parameters": [
|
|
264
|
+
{
|
|
265
|
+
"name": "event",
|
|
266
|
+
"type": {
|
|
267
|
+
"text": "ClipboardEvent"
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"kind": "method",
|
|
274
|
+
"name": "onInput",
|
|
275
|
+
"privacy": "private",
|
|
276
|
+
"return": {
|
|
277
|
+
"type": {
|
|
278
|
+
"text": "void"
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
"events": [
|
|
284
|
+
{
|
|
285
|
+
"name": "change",
|
|
286
|
+
"type": {
|
|
287
|
+
"text": "CustomEvent"
|
|
288
|
+
},
|
|
289
|
+
"description": "After a value is added or removed; `detail: { values }`."
|
|
290
|
+
}
|
|
291
|
+
],
|
|
292
|
+
"attributes": [
|
|
293
|
+
{
|
|
294
|
+
"name": "label",
|
|
295
|
+
"type": {
|
|
296
|
+
"text": "string"
|
|
297
|
+
},
|
|
298
|
+
"default": "\"\"",
|
|
299
|
+
"description": "Visible label above the field; also names the input.",
|
|
300
|
+
"fieldName": "label"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"name": "placeholder",
|
|
304
|
+
"type": {
|
|
305
|
+
"text": "string"
|
|
306
|
+
},
|
|
307
|
+
"default": "\"\"",
|
|
308
|
+
"fieldName": "placeholder"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"name": "supporting-text",
|
|
312
|
+
"type": {
|
|
313
|
+
"text": "string"
|
|
314
|
+
},
|
|
315
|
+
"default": "\"\"",
|
|
316
|
+
"description": "Help under the field, replaced by an error while there is one.",
|
|
317
|
+
"fieldName": "supportingText"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"name": "allow-duplicates",
|
|
321
|
+
"type": {
|
|
322
|
+
"text": "boolean"
|
|
323
|
+
},
|
|
324
|
+
"default": "false",
|
|
325
|
+
"fieldName": "allowDuplicates"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"name": "max",
|
|
329
|
+
"type": {
|
|
330
|
+
"text": "number"
|
|
331
|
+
},
|
|
332
|
+
"default": "0",
|
|
333
|
+
"description": "Most chips allowed; `0` for no limit.",
|
|
334
|
+
"fieldName": "max"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "disabled",
|
|
338
|
+
"type": {
|
|
339
|
+
"text": "boolean"
|
|
340
|
+
},
|
|
341
|
+
"default": "false",
|
|
342
|
+
"fieldName": "disabled"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"name": "invalid",
|
|
346
|
+
"type": {
|
|
347
|
+
"text": "boolean"
|
|
348
|
+
},
|
|
349
|
+
"default": "false",
|
|
350
|
+
"description": "Set while the typed value was refused; reflected.",
|
|
351
|
+
"fieldName": "invalid"
|
|
352
|
+
}
|
|
353
|
+
],
|
|
354
|
+
"superclass": {
|
|
355
|
+
"name": "LitElement",
|
|
356
|
+
"package": "lit"
|
|
357
|
+
},
|
|
358
|
+
"tagName": "lit-material-chip-input",
|
|
359
|
+
"customElement": true
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
"exports": [
|
|
363
|
+
{
|
|
364
|
+
"kind": "js",
|
|
365
|
+
"name": "LitMaterialChipInput",
|
|
366
|
+
"declaration": {
|
|
367
|
+
"name": "LitMaterialChipInput",
|
|
368
|
+
"module": "src/chip-input.ts"
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"kind": "custom-element-definition",
|
|
373
|
+
"name": "lit-material-chip-input",
|
|
374
|
+
"declaration": {
|
|
375
|
+
"name": "LitMaterialChipInput",
|
|
376
|
+
"module": "src/chip-input.ts"
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"kind": "javascript-module",
|
|
383
|
+
"path": "src/chip-styles.ts",
|
|
384
|
+
"declarations": [
|
|
385
|
+
{
|
|
386
|
+
"kind": "variable",
|
|
387
|
+
"name": "styles",
|
|
388
|
+
"default": "css` :host { display: inline-flex; vertical-align: top; -webkit-tap-highlight-color: transparent; } :host([disabled]) { pointer-events: none; } .chip { position: relative; display: inline-flex; align-items: stretch; box-sizing: border-box; height: 32px; border-radius: var(--md-sys-shape-corner-small, 8px); background-color: transparent; border: 1px solid var(--md-sys-color-outline, #79747e); color: var(--md-sys-color-on-surface-variant, #49454f); transition: background-color 150ms var(--md-sys-motion-easing-standard, cubic-bezier(0.2, 0, 0, 1)), border-color 150ms var(--md-sys-motion-easing-standard, cubic-bezier(0.2, 0, 0, 1)); } .chip.elevated { border-color: transparent; background-color: var(--md-sys-color-surface-container-low, #f7f2fa); box-shadow: var(--md-sys-elevation-1, 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15)); } .chip.filter.selected { border-color: transparent; background-color: var(--md-sys-color-secondary-container, #e8def8); color: var(--md-sys-color-on-secondary-container, #1d192b); } :host([disabled]) .chip { opacity: 0.38; box-shadow: none; } .action { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 100%; padding-inline: 16px; margin: 0; border: none; background: transparent; text-decoration: none; cursor: pointer; color: inherit; font-family: var(--md-sys-typescale-label-large-font, Roboto, system-ui, sans-serif); font-size: var(--md-sys-typescale-label-large-size, 0.875rem); line-height: var(--md-sys-typescale-label-large-line-height, 1.25rem); border-radius: inherit; -webkit-appearance: none; appearance: none; } .action:disabled, .action[aria-disabled=\"true\"] { cursor: default; } .action:focus-visible { outline: 2px solid var(--md-sys-color-secondary, #625b71); outline-offset: -2px; } .state-layer { position: absolute; inset: 0; border-radius: inherit; background-color: currentColor; opacity: 0; pointer-events: none; transition: opacity 100ms linear; } .action:hover .state-layer { opacity: var(--md-sys-state-hover-state-layer-opacity, 0.08); } .state-layer[data-pressed] { opacity: var(--md-sys-state-pressed-state-layer-opacity, 0.1); } slot.leading-icon::slotted(*) { width: 18px; height: 18px; display: block; pointer-events: none; } .checkmark { width: 18px; height: 18px; flex: none; pointer-events: none; } .checkmark path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; } .label { display: inline-flex; align-items: center; white-space: nowrap; } .remove { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; margin-inline: -8px 8px; padding: 0; border: none; background: transparent; border-radius: 50%; color: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; } .remove:disabled { cursor: default; } .remove:hover { background-color: color-mix(in srgb, currentColor 8%, transparent); } .remove:focus-visible { outline: 2px solid var(--md-sys-color-secondary, #625b71); outline-offset: -1px; } .remove-icon { width: 14px; height: 14px; pointer-events: none; } .remove-icon path { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; } @media (prefers-reduced-motion: reduce) { .chip, .state-layer { transition: none; } } `"
|
|
389
|
+
}
|
|
390
|
+
],
|
|
391
|
+
"exports": [
|
|
392
|
+
{
|
|
393
|
+
"kind": "js",
|
|
394
|
+
"name": "styles",
|
|
395
|
+
"declaration": {
|
|
396
|
+
"name": "styles",
|
|
397
|
+
"module": "src/chip-styles.ts"
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"kind": "javascript-module",
|
|
404
|
+
"path": "src/chip.ts",
|
|
405
|
+
"declarations": [
|
|
406
|
+
{
|
|
407
|
+
"kind": "class",
|
|
408
|
+
"description": "Material Design 3 chip.\n\nUnlike checkbox/radio/switch, chips are not form-associated: they're\nauxiliary UI (filters, action triggers, removable tags) rather than a\nvalue a `<form>` submits, matching how Material Design itself treats\nchips. A `filter` chip's `selected` state and an `input` chip's removal\nare communicated via `change`/`remove` events instead.",
|
|
409
|
+
"name": "LitMaterialChip",
|
|
410
|
+
"cssParts": [
|
|
411
|
+
{
|
|
412
|
+
"description": "The outer container (background/border/elevation).",
|
|
413
|
+
"name": "chip"
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
"description": "The main clickable `<button>` or `<a>` (icon + label).",
|
|
417
|
+
"name": "action"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"description": "The trailing remove `<button>`, when `removable`.",
|
|
421
|
+
"name": "remove-button"
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
"description": "The state-layer element the hover/press feedback is drawn on.",
|
|
425
|
+
"name": "ripple"
|
|
426
|
+
}
|
|
427
|
+
],
|
|
428
|
+
"slots": [
|
|
429
|
+
{
|
|
430
|
+
"description": "The chip's label.",
|
|
431
|
+
"name": ""
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"description": "An optional icon before the label. Ignored on a selected `filter` chip, which shows a checkmark in its place.",
|
|
435
|
+
"name": "leading-icon"
|
|
436
|
+
}
|
|
437
|
+
],
|
|
438
|
+
"members": [
|
|
439
|
+
{
|
|
440
|
+
"kind": "field",
|
|
441
|
+
"name": "variant",
|
|
442
|
+
"type": {
|
|
443
|
+
"text": "ChipVariant"
|
|
444
|
+
},
|
|
445
|
+
"default": "\"assist\"",
|
|
446
|
+
"attribute": "variant"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"kind": "field",
|
|
450
|
+
"name": "selected",
|
|
451
|
+
"type": {
|
|
452
|
+
"text": "boolean"
|
|
453
|
+
},
|
|
454
|
+
"default": "false",
|
|
455
|
+
"attribute": "selected",
|
|
456
|
+
"reflects": true
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"kind": "field",
|
|
460
|
+
"name": "disabled",
|
|
461
|
+
"type": {
|
|
462
|
+
"text": "boolean"
|
|
463
|
+
},
|
|
464
|
+
"default": "false",
|
|
465
|
+
"attribute": "disabled",
|
|
466
|
+
"reflects": true
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
"kind": "field",
|
|
470
|
+
"name": "elevated",
|
|
471
|
+
"type": {
|
|
472
|
+
"text": "boolean"
|
|
473
|
+
},
|
|
474
|
+
"default": "false",
|
|
475
|
+
"attribute": "elevated",
|
|
476
|
+
"reflects": true
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"kind": "field",
|
|
480
|
+
"name": "removable",
|
|
481
|
+
"type": {
|
|
482
|
+
"text": "boolean"
|
|
483
|
+
},
|
|
484
|
+
"default": "false",
|
|
485
|
+
"attribute": "removable"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"kind": "field",
|
|
489
|
+
"name": "removeLabel",
|
|
490
|
+
"type": {
|
|
491
|
+
"text": "string"
|
|
492
|
+
},
|
|
493
|
+
"default": "\"Remove\"",
|
|
494
|
+
"description": "Accessible name of the remove button, e.g. \"Remove app=web\".",
|
|
495
|
+
"attribute": "remove-label"
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
"kind": "field",
|
|
499
|
+
"name": "href",
|
|
500
|
+
"type": {
|
|
501
|
+
"text": "string"
|
|
502
|
+
},
|
|
503
|
+
"default": "\"\"",
|
|
504
|
+
"description": "If set, renders the main action as a link (`<a>`) instead of a `<button>`.",
|
|
505
|
+
"attribute": "href"
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
"kind": "field",
|
|
509
|
+
"name": "target",
|
|
510
|
+
"type": {
|
|
511
|
+
"text": "string"
|
|
512
|
+
},
|
|
513
|
+
"default": "\"\"",
|
|
514
|
+
"attribute": "target"
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
"kind": "field",
|
|
518
|
+
"name": "stateLayerElement",
|
|
519
|
+
"type": {
|
|
520
|
+
"text": "HTMLElement | undefined"
|
|
521
|
+
},
|
|
522
|
+
"privacy": "private",
|
|
523
|
+
"readonly": true
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
"kind": "field",
|
|
527
|
+
"name": "ripple",
|
|
528
|
+
"privacy": "private",
|
|
529
|
+
"readonly": true,
|
|
530
|
+
"default": "new RippleController(this)"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
"kind": "method",
|
|
534
|
+
"name": "handleActionClick",
|
|
535
|
+
"privacy": "private",
|
|
536
|
+
"return": {
|
|
537
|
+
"type": {
|
|
538
|
+
"text": "void"
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
"parameters": [
|
|
542
|
+
{
|
|
543
|
+
"name": "event",
|
|
544
|
+
"type": {
|
|
545
|
+
"text": "MouseEvent"
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
]
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
"kind": "method",
|
|
552
|
+
"name": "handleLinkClick",
|
|
553
|
+
"privacy": "private",
|
|
554
|
+
"return": {
|
|
555
|
+
"type": {
|
|
556
|
+
"text": "void"
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
"parameters": [
|
|
560
|
+
{
|
|
561
|
+
"name": "event",
|
|
562
|
+
"type": {
|
|
563
|
+
"text": "MouseEvent"
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
]
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
"kind": "method",
|
|
570
|
+
"name": "handleRemoveClick",
|
|
571
|
+
"privacy": "private",
|
|
572
|
+
"return": {
|
|
573
|
+
"type": {
|
|
574
|
+
"text": "void"
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
"parameters": [
|
|
578
|
+
{
|
|
579
|
+
"name": "event",
|
|
580
|
+
"type": {
|
|
581
|
+
"text": "MouseEvent"
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
]
|
|
585
|
+
}
|
|
586
|
+
],
|
|
587
|
+
"events": [
|
|
588
|
+
{
|
|
589
|
+
"name": "change",
|
|
590
|
+
"type": {
|
|
591
|
+
"text": "Event"
|
|
592
|
+
},
|
|
593
|
+
"description": "Bubbles when a `filter` chip's `selected` state toggles via user interaction."
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
"name": "remove",
|
|
597
|
+
"type": {
|
|
598
|
+
"text": "Event"
|
|
599
|
+
},
|
|
600
|
+
"description": "Cancelable; fires when the remove button is activated. Unless `event.preventDefault()` is called, the chip removes itself from the DOM afterward."
|
|
601
|
+
}
|
|
602
|
+
],
|
|
603
|
+
"attributes": [
|
|
604
|
+
{
|
|
605
|
+
"name": "variant",
|
|
606
|
+
"type": {
|
|
607
|
+
"text": "ChipVariant"
|
|
608
|
+
},
|
|
609
|
+
"default": "\"assist\"",
|
|
610
|
+
"fieldName": "variant"
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
"name": "selected",
|
|
614
|
+
"type": {
|
|
615
|
+
"text": "boolean"
|
|
616
|
+
},
|
|
617
|
+
"default": "false",
|
|
618
|
+
"fieldName": "selected"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
"name": "disabled",
|
|
622
|
+
"type": {
|
|
623
|
+
"text": "boolean"
|
|
624
|
+
},
|
|
625
|
+
"default": "false",
|
|
626
|
+
"fieldName": "disabled"
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
"name": "elevated",
|
|
630
|
+
"type": {
|
|
631
|
+
"text": "boolean"
|
|
632
|
+
},
|
|
633
|
+
"default": "false",
|
|
634
|
+
"fieldName": "elevated"
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"name": "removable",
|
|
638
|
+
"type": {
|
|
639
|
+
"text": "boolean"
|
|
640
|
+
},
|
|
641
|
+
"default": "false",
|
|
642
|
+
"fieldName": "removable"
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
"name": "remove-label",
|
|
646
|
+
"type": {
|
|
647
|
+
"text": "string"
|
|
648
|
+
},
|
|
649
|
+
"default": "\"Remove\"",
|
|
650
|
+
"description": "Accessible name of the remove button, e.g. \"Remove app=web\".",
|
|
651
|
+
"fieldName": "removeLabel"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"name": "href",
|
|
655
|
+
"type": {
|
|
656
|
+
"text": "string"
|
|
657
|
+
},
|
|
658
|
+
"default": "\"\"",
|
|
659
|
+
"description": "If set, renders the main action as a link (`<a>`) instead of a `<button>`.",
|
|
660
|
+
"fieldName": "href"
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"name": "target",
|
|
664
|
+
"type": {
|
|
665
|
+
"text": "string"
|
|
666
|
+
},
|
|
667
|
+
"default": "\"\"",
|
|
668
|
+
"fieldName": "target"
|
|
669
|
+
}
|
|
670
|
+
],
|
|
671
|
+
"superclass": {
|
|
672
|
+
"name": "LitElement",
|
|
673
|
+
"package": "lit"
|
|
674
|
+
},
|
|
675
|
+
"tagName": "lit-material-chip",
|
|
676
|
+
"customElement": true
|
|
677
|
+
}
|
|
678
|
+
],
|
|
679
|
+
"exports": [
|
|
680
|
+
{
|
|
681
|
+
"kind": "js",
|
|
682
|
+
"name": "LitMaterialChip",
|
|
683
|
+
"declaration": {
|
|
684
|
+
"name": "LitMaterialChip",
|
|
685
|
+
"module": "src/chip.ts"
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"kind": "custom-element-definition",
|
|
690
|
+
"name": "lit-material-chip",
|
|
691
|
+
"declaration": {
|
|
692
|
+
"name": "LitMaterialChip",
|
|
693
|
+
"module": "src/chip.ts"
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
]
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
"kind": "javascript-module",
|
|
700
|
+
"path": "src/index.ts",
|
|
701
|
+
"declarations": [],
|
|
702
|
+
"exports": [
|
|
703
|
+
{
|
|
704
|
+
"kind": "js",
|
|
705
|
+
"name": "LitMaterialChip",
|
|
706
|
+
"declaration": {
|
|
707
|
+
"name": "LitMaterialChip",
|
|
708
|
+
"module": "./chip.js"
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"kind": "js",
|
|
713
|
+
"name": "ChipVariant",
|
|
714
|
+
"declaration": {
|
|
715
|
+
"name": "ChipVariant",
|
|
716
|
+
"module": "./chip.js"
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"kind": "js",
|
|
721
|
+
"name": "LitMaterialChipInput",
|
|
722
|
+
"declaration": {
|
|
723
|
+
"name": "LitMaterialChipInput",
|
|
724
|
+
"module": "./chip-input.js"
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
]
|
|
728
|
+
}
|
|
729
|
+
]
|
|
730
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import "./chip.js";
|
|
3
|
+
/**
|
|
4
|
+
* A field that turns what you type into chips: tags, labels, email
|
|
5
|
+
* addresses, allowed hosts. Enter or a comma adds the typed value; pasting
|
|
6
|
+
* several values separated by commas, spaces or new lines adds them all.
|
|
7
|
+
* Each chip has a remove button, and Backspace in the empty field removes
|
|
8
|
+
* the last one.
|
|
9
|
+
*
|
|
10
|
+
* `validator` refuses a value with a message (shown under the field, the
|
|
11
|
+
* text stays for fixing); duplicates are refused unless `allow-duplicates`.
|
|
12
|
+
*
|
|
13
|
+
* @element lit-material-chip-input
|
|
14
|
+
*
|
|
15
|
+
* @fires change - After a value is added or removed; `detail: { values }`.
|
|
16
|
+
*
|
|
17
|
+
* @csspart field - The box holding the chips and the input.
|
|
18
|
+
* @csspart input - The text input.
|
|
19
|
+
*/
|
|
20
|
+
export declare class LitMaterialChipInput extends LitElement {
|
|
21
|
+
static styles: import("lit").CSSResult;
|
|
22
|
+
/** The chips' values. */
|
|
23
|
+
values: string[];
|
|
24
|
+
/** Visible label above the field; also names the input. */
|
|
25
|
+
label: string;
|
|
26
|
+
placeholder: string;
|
|
27
|
+
/** Help under the field, replaced by an error while there is one. */
|
|
28
|
+
supportingText: string;
|
|
29
|
+
/** Refuses a value: return a message, or `""` to accept. */
|
|
30
|
+
validator?: (value: string) => string;
|
|
31
|
+
allowDuplicates: boolean;
|
|
32
|
+
/** Most chips allowed; `0` for no limit. */
|
|
33
|
+
max: number;
|
|
34
|
+
disabled: boolean;
|
|
35
|
+
/** Set while the typed value was refused; reflected. */
|
|
36
|
+
invalid: boolean;
|
|
37
|
+
private error;
|
|
38
|
+
private announcement;
|
|
39
|
+
private readonly input;
|
|
40
|
+
private readonly uid;
|
|
41
|
+
focus(options?: FocusOptions): void;
|
|
42
|
+
/** Adds `raw` (trimmed); returns the refusal message, `""` on success. */
|
|
43
|
+
add(raw: string): string;
|
|
44
|
+
/** Removes the chip at `index`. */
|
|
45
|
+
removeAt(index: number): void;
|
|
46
|
+
private setError;
|
|
47
|
+
private emit;
|
|
48
|
+
private commitTyped;
|
|
49
|
+
private onKeyDown;
|
|
50
|
+
private onPaste;
|
|
51
|
+
private onInput;
|
|
52
|
+
render(): import("lit").TemplateResult<1>;
|
|
53
|
+
}
|
|
54
|
+
declare global {
|
|
55
|
+
interface HTMLElementTagNameMap {
|
|
56
|
+
"lit-material-chip-input": LitMaterialChipInput;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=chip-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chip-input.d.ts","sourceRoot":"","sources":["../src/chip-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAW,MAAM,KAAK,CAAC;AAGrD,OAAO,WAAW,CAAC;AAInB;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,oBAAqB,SAAQ,UAAU;IAClD,OAAgB,MAAM,0BAgEpB;IAEF,yBAAyB;IACO,MAAM,EAAE,MAAM,EAAE,CAAM;IAEtD,2DAA2D;IAC/C,KAAK,SAAM;IAEX,WAAW,SAAM;IAE7B,qEAAqE;IACzB,cAAc,SAAM;IAEhE,4DAA4D;IAC5B,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAEV,eAAe,UAAS;IAEpF,4CAA4C;IAChB,GAAG,SAAK;IAEQ,QAAQ,UAAS;IAE7D,wDAAwD;IACZ,OAAO,UAAS;IAEnD,OAAO,CAAC,KAAK,CAAM;IAEnB,OAAO,CAAC,YAAY,CAAM;IAEnB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAE1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA4B;IAEvC,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI;IAI5C,0EAA0E;IAC1E,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAexB,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ7B,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,OAAO;IAIN,MAAM;CAyChB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,yBAAyB,EAAE,oBAAoB,CAAC;KACjD;CACF"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { css, html, LitElement, nothing } from "lit";
|
|
8
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
|
9
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
10
|
+
import "./chip.js";
|
|
11
|
+
let nextId = 0;
|
|
12
|
+
/**
|
|
13
|
+
* A field that turns what you type into chips: tags, labels, email
|
|
14
|
+
* addresses, allowed hosts. Enter or a comma adds the typed value; pasting
|
|
15
|
+
* several values separated by commas, spaces or new lines adds them all.
|
|
16
|
+
* Each chip has a remove button, and Backspace in the empty field removes
|
|
17
|
+
* the last one.
|
|
18
|
+
*
|
|
19
|
+
* `validator` refuses a value with a message (shown under the field, the
|
|
20
|
+
* text stays for fixing); duplicates are refused unless `allow-duplicates`.
|
|
21
|
+
*
|
|
22
|
+
* @element lit-material-chip-input
|
|
23
|
+
*
|
|
24
|
+
* @fires change - After a value is added or removed; `detail: { values }`.
|
|
25
|
+
*
|
|
26
|
+
* @csspart field - The box holding the chips and the input.
|
|
27
|
+
* @csspart input - The text input.
|
|
28
|
+
*/
|
|
29
|
+
let LitMaterialChipInput = class LitMaterialChipInput extends LitElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
/** The chips' values. */
|
|
33
|
+
this.values = [];
|
|
34
|
+
/** Visible label above the field; also names the input. */
|
|
35
|
+
this.label = "";
|
|
36
|
+
this.placeholder = "";
|
|
37
|
+
/** Help under the field, replaced by an error while there is one. */
|
|
38
|
+
this.supportingText = "";
|
|
39
|
+
this.allowDuplicates = false;
|
|
40
|
+
/** Most chips allowed; `0` for no limit. */
|
|
41
|
+
this.max = 0;
|
|
42
|
+
this.disabled = false;
|
|
43
|
+
/** Set while the typed value was refused; reflected. */
|
|
44
|
+
this.invalid = false;
|
|
45
|
+
this.error = "";
|
|
46
|
+
this.announcement = "";
|
|
47
|
+
this.uid = `chip-input-${++nextId}`;
|
|
48
|
+
}
|
|
49
|
+
static { this.styles = css `
|
|
50
|
+
:host {
|
|
51
|
+
display: block;
|
|
52
|
+
font-family: var(--md-sys-typescale-body-large-font, Roboto, system-ui, sans-serif);
|
|
53
|
+
}
|
|
54
|
+
:host([hidden]) {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
label {
|
|
58
|
+
display: block;
|
|
59
|
+
margin-block-end: 4px;
|
|
60
|
+
color: var(--md-sys-color-on-surface-variant, light-dark(#49454f, #cac4d0));
|
|
61
|
+
font-size: var(--md-sys-typescale-body-small-size, 0.75rem);
|
|
62
|
+
}
|
|
63
|
+
.field {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-wrap: wrap;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: 6px;
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
min-height: 56px;
|
|
70
|
+
padding: 8px 12px;
|
|
71
|
+
border: 1px solid var(--md-sys-color-outline, light-dark(#79747e, #938f99));
|
|
72
|
+
border-radius: var(--md-sys-shape-corner-extra-small, 4px);
|
|
73
|
+
cursor: text;
|
|
74
|
+
}
|
|
75
|
+
.field:focus-within {
|
|
76
|
+
border-color: var(--md-sys-color-primary, light-dark(#6750a4, #d0bcff));
|
|
77
|
+
box-shadow: inset 0 0 0 1px var(--md-sys-color-primary, light-dark(#6750a4, #d0bcff));
|
|
78
|
+
}
|
|
79
|
+
:host([invalid]) .field {
|
|
80
|
+
border-color: var(--md-sys-color-error, light-dark(#b3261e, #f2b8b5));
|
|
81
|
+
}
|
|
82
|
+
:host([disabled]) .field {
|
|
83
|
+
opacity: 0.38;
|
|
84
|
+
cursor: default;
|
|
85
|
+
}
|
|
86
|
+
input {
|
|
87
|
+
flex: 1;
|
|
88
|
+
min-width: 8ch;
|
|
89
|
+
padding: 4px 0;
|
|
90
|
+
border: 0;
|
|
91
|
+
outline: none;
|
|
92
|
+
background: transparent;
|
|
93
|
+
color: var(--md-sys-color-on-surface, light-dark(#1d1b20, #e6e0e9));
|
|
94
|
+
font: inherit;
|
|
95
|
+
font-size: var(--md-sys-typescale-body-large-size, 1rem);
|
|
96
|
+
}
|
|
97
|
+
.supporting {
|
|
98
|
+
margin: 4px 16px 0;
|
|
99
|
+
color: var(--md-sys-color-on-surface-variant, light-dark(#49454f, #cac4d0));
|
|
100
|
+
font-size: var(--md-sys-typescale-body-small-size, 0.75rem);
|
|
101
|
+
}
|
|
102
|
+
:host([invalid]) .supporting {
|
|
103
|
+
color: var(--md-sys-color-error, light-dark(#b3261e, #f2b8b5));
|
|
104
|
+
}
|
|
105
|
+
.sr {
|
|
106
|
+
position: absolute;
|
|
107
|
+
width: 1px;
|
|
108
|
+
height: 1px;
|
|
109
|
+
overflow: hidden;
|
|
110
|
+
clip-path: inset(50%);
|
|
111
|
+
white-space: nowrap;
|
|
112
|
+
}
|
|
113
|
+
`; }
|
|
114
|
+
focus(options) {
|
|
115
|
+
this.input?.focus(options);
|
|
116
|
+
}
|
|
117
|
+
/** Adds `raw` (trimmed); returns the refusal message, `""` on success. */
|
|
118
|
+
add(raw) {
|
|
119
|
+
const value = raw.trim();
|
|
120
|
+
if (!value)
|
|
121
|
+
return "";
|
|
122
|
+
let message = "";
|
|
123
|
+
if (this.max && this.values.length >= this.max)
|
|
124
|
+
message = `At most ${this.max}`;
|
|
125
|
+
else if (!this.allowDuplicates && this.values.includes(value))
|
|
126
|
+
message = `${value} is already added`;
|
|
127
|
+
else
|
|
128
|
+
message = this.validator?.(value) ?? "";
|
|
129
|
+
this.setError(message);
|
|
130
|
+
if (message)
|
|
131
|
+
return message;
|
|
132
|
+
this.values = [...this.values, value];
|
|
133
|
+
this.announcement = `${value} added`;
|
|
134
|
+
this.emit();
|
|
135
|
+
return "";
|
|
136
|
+
}
|
|
137
|
+
/** Removes the chip at `index`. */
|
|
138
|
+
removeAt(index) {
|
|
139
|
+
const value = this.values[index];
|
|
140
|
+
if (value === undefined)
|
|
141
|
+
return;
|
|
142
|
+
this.values = this.values.filter((_, i) => i !== index);
|
|
143
|
+
this.announcement = `${value} removed`;
|
|
144
|
+
this.emit();
|
|
145
|
+
}
|
|
146
|
+
setError(message) {
|
|
147
|
+
this.error = message;
|
|
148
|
+
this.invalid = Boolean(message);
|
|
149
|
+
}
|
|
150
|
+
emit() {
|
|
151
|
+
this.dispatchEvent(new CustomEvent("change", { bubbles: true, composed: true, detail: { values: this.values } }));
|
|
152
|
+
}
|
|
153
|
+
commitTyped() {
|
|
154
|
+
if (!this.add(this.input.value))
|
|
155
|
+
this.input.value = "";
|
|
156
|
+
}
|
|
157
|
+
onKeyDown(event) {
|
|
158
|
+
if (event.key === "Enter" || event.key === ",") {
|
|
159
|
+
if (!this.input.value.trim())
|
|
160
|
+
return;
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
this.commitTyped();
|
|
163
|
+
}
|
|
164
|
+
else if (event.key === "Backspace" && this.input.value === "" && this.values.length) {
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
this.removeAt(this.values.length - 1);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
onPaste(event) {
|
|
170
|
+
const text = event.clipboardData?.getData("text/plain") ?? "";
|
|
171
|
+
const parts = text.split(/[\s,;]+/).filter(Boolean);
|
|
172
|
+
if (parts.length < 2)
|
|
173
|
+
return;
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
const refused = parts.filter((part) => this.add(part));
|
|
176
|
+
// Leave what was refused in the field, to fix.
|
|
177
|
+
this.input.value = refused.join(", ");
|
|
178
|
+
if (refused.length)
|
|
179
|
+
this.setError(`${refused.length} not added: ${refused.join(", ")}`);
|
|
180
|
+
}
|
|
181
|
+
onInput() {
|
|
182
|
+
if (this.error)
|
|
183
|
+
this.setError("");
|
|
184
|
+
}
|
|
185
|
+
render() {
|
|
186
|
+
const message = this.error || this.supportingText;
|
|
187
|
+
return html `
|
|
188
|
+
${this.label ? html `<label for=${this.uid}>${this.label}</label>` : nothing}
|
|
189
|
+
<div part="field" class="field" @click=${(e) => e.target === e.currentTarget && this.focus()}>
|
|
190
|
+
${repeat(this.values, (value, i) => `${i}:${value}`, (value, i) => html `<lit-material-chip
|
|
191
|
+
variant="input"
|
|
192
|
+
removable
|
|
193
|
+
remove-label=${`Remove ${value}`}
|
|
194
|
+
?disabled=${this.disabled}
|
|
195
|
+
@remove=${(e) => {
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
this.removeAt(i);
|
|
198
|
+
this.focus();
|
|
199
|
+
}}
|
|
200
|
+
>${value}</lit-material-chip
|
|
201
|
+
>`)}
|
|
202
|
+
<input
|
|
203
|
+
part="input"
|
|
204
|
+
id=${this.uid}
|
|
205
|
+
type="text"
|
|
206
|
+
autocomplete="off"
|
|
207
|
+
spellcheck="false"
|
|
208
|
+
placeholder=${this.values.length ? "" : this.placeholder}
|
|
209
|
+
?disabled=${this.disabled}
|
|
210
|
+
aria-invalid=${this.invalid ? "true" : "false"}
|
|
211
|
+
aria-describedby=${message ? `${this.uid}-msg` : nothing}
|
|
212
|
+
@keydown=${this.onKeyDown}
|
|
213
|
+
@paste=${this.onPaste}
|
|
214
|
+
@input=${this.onInput}
|
|
215
|
+
@blur=${() => this.input.value.trim() && this.commitTyped()}
|
|
216
|
+
/>
|
|
217
|
+
</div>
|
|
218
|
+
${message ? html `<div class="supporting" id="${this.uid}-msg">${message}</div>` : nothing}
|
|
219
|
+
<div class="sr" role="status">${this.announcement}</div>
|
|
220
|
+
`;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
__decorate([
|
|
224
|
+
property({ attribute: false })
|
|
225
|
+
], LitMaterialChipInput.prototype, "values", void 0);
|
|
226
|
+
__decorate([
|
|
227
|
+
property()
|
|
228
|
+
], LitMaterialChipInput.prototype, "label", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
property()
|
|
231
|
+
], LitMaterialChipInput.prototype, "placeholder", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
property({ attribute: "supporting-text" })
|
|
234
|
+
], LitMaterialChipInput.prototype, "supportingText", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
property({ attribute: false })
|
|
237
|
+
], LitMaterialChipInput.prototype, "validator", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
property({ type: Boolean, attribute: "allow-duplicates" })
|
|
240
|
+
], LitMaterialChipInput.prototype, "allowDuplicates", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
property({ type: Number })
|
|
243
|
+
], LitMaterialChipInput.prototype, "max", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
property({ type: Boolean, reflect: true })
|
|
246
|
+
], LitMaterialChipInput.prototype, "disabled", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
property({ type: Boolean, reflect: true })
|
|
249
|
+
], LitMaterialChipInput.prototype, "invalid", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
state()
|
|
252
|
+
], LitMaterialChipInput.prototype, "error", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
state()
|
|
255
|
+
], LitMaterialChipInput.prototype, "announcement", void 0);
|
|
256
|
+
__decorate([
|
|
257
|
+
query("input")
|
|
258
|
+
], LitMaterialChipInput.prototype, "input", void 0);
|
|
259
|
+
LitMaterialChipInput = __decorate([
|
|
260
|
+
customElement("lit-material-chip-input")
|
|
261
|
+
], LitMaterialChipInput);
|
|
262
|
+
export { LitMaterialChipInput };
|
|
263
|
+
//# sourceMappingURL=chip-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chip-input.js","sourceRoot":"","sources":["../src/chip-input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,WAAW,CAAC;AAEnB,IAAI,MAAM,GAAG,CAAC,CAAC;AAEf;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,UAAU;IAA7C;;QAmEL,yBAAyB;QACO,WAAM,GAAa,EAAE,CAAC;QAEtD,2DAA2D;QAC/C,UAAK,GAAG,EAAE,CAAC;QAEX,gBAAW,GAAG,EAAE,CAAC;QAE7B,qEAAqE;QACzB,mBAAc,GAAG,EAAE,CAAC;QAKJ,oBAAe,GAAG,KAAK,CAAC;QAEpF,4CAA4C;QAChB,QAAG,GAAG,CAAC,CAAC;QAEQ,aAAQ,GAAG,KAAK,CAAC;QAE7D,wDAAwD;QACZ,YAAO,GAAG,KAAK,CAAC;QAE3C,UAA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CAAC;oDAAuB;AAG1C;IAAX,QAAQ,EAAE;mDAAY;AAEX;IAAX,QAAQ,EAAE;yDAAkB;AAGe;IAA3C,QAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;4DAAqB;AAGhC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDAAuC;AAEV;IAA3D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;6DAAyB;AAGxD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAS;AAEQ;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sDAAkB;AAGjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qDAAiB;AAE3C;IAAhB,KAAK,EAAE;mDAAoB;AAEX;IAAhB,KAAK,EAAE;0DAA2B;AAEF;IAAhC,KAAK,CAAC,OAAO,CAAC;mDAA2C;AA/F/C,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAgNhC"}
|
package/dist/chip-styles.js
CHANGED
package/dist/chip.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export declare class LitMaterialChip extends LitElement {
|
|
|
31
31
|
disabled: boolean;
|
|
32
32
|
elevated: boolean;
|
|
33
33
|
removable: boolean;
|
|
34
|
+
/** Accessible name of the remove button, e.g. "Remove app=web". */
|
|
35
|
+
removeLabel: string;
|
|
34
36
|
/** If set, renders the main action as a link (`<a>`) instead of a `<button>`. */
|
|
35
37
|
href: string;
|
|
36
38
|
target: string;
|
package/dist/chip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../src/chip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAKhD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBACa,eAAgB,SAAQ,UAAU;IAC7C,OAAgB,MAAM,0BAAU;IAEpB,OAAO,EAAE,WAAW,CAAY;IACA,QAAQ,UAAS;IACjB,QAAQ,UAAS;IACjB,QAAQ,UAAS;IAChC,SAAS,UAAS;
|
|
1
|
+
{"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../src/chip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAKhD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBACa,eAAgB,SAAQ,UAAU;IAC7C,OAAgB,MAAM,0BAAU;IAEpB,OAAO,EAAE,WAAW,CAAY;IACA,QAAQ,UAAS;IACjB,QAAQ,UAAS;IACjB,QAAQ,UAAS;IAChC,SAAS,UAAS;IAC/C,mEAAmE;IAC1B,WAAW,SAAY;IAEhE,iFAAiF;IACrE,IAAI,SAAM;IACV,MAAM,SAAM;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAc;IAExE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;cAElC,YAAY,IAAI,IAAI;IAM9B,MAAM;IA8Ef,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,iBAAiB;CAQ1B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,eAAe,CAAC;KACtC;CACF"}
|
package/dist/chip.js
CHANGED
|
@@ -40,6 +40,8 @@ let LitMaterialChip = class LitMaterialChip extends LitElement {
|
|
|
40
40
|
this.disabled = false;
|
|
41
41
|
this.elevated = false;
|
|
42
42
|
this.removable = false;
|
|
43
|
+
/** Accessible name of the remove button, e.g. "Remove app=web". */
|
|
44
|
+
this.removeLabel = "Remove";
|
|
43
45
|
/** If set, renders the main action as a link (`<a>`) instead of a `<button>`. */
|
|
44
46
|
this.href = "";
|
|
45
47
|
this.target = "";
|
|
@@ -111,7 +113,7 @@ let LitMaterialChip = class LitMaterialChip extends LitElement {
|
|
|
111
113
|
part="remove-button"
|
|
112
114
|
type="button"
|
|
113
115
|
?disabled=${this.disabled}
|
|
114
|
-
aria-label
|
|
116
|
+
aria-label=${this.removeLabel}
|
|
115
117
|
@click=${this.handleRemoveClick}
|
|
116
118
|
>
|
|
117
119
|
<svg class="remove-icon" viewBox="0 0 18 18" aria-hidden="true">
|
|
@@ -164,6 +166,9 @@ __decorate([
|
|
|
164
166
|
__decorate([
|
|
165
167
|
property({ type: Boolean })
|
|
166
168
|
], LitMaterialChip.prototype, "removable", void 0);
|
|
169
|
+
__decorate([
|
|
170
|
+
property({ attribute: "remove-label" })
|
|
171
|
+
], LitMaterialChip.prototype, "removeLabel", void 0);
|
|
167
172
|
__decorate([
|
|
168
173
|
property()
|
|
169
174
|
], LitMaterialChip.prototype, "href", void 0);
|
package/dist/chip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../src/chip.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,U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,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAkB;AACjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAkB;AACjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAkB;AAChC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAmB;AAEN;IAAxC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;oDAAwB;AAGpD;IAAX,QAAQ,EAAE;6CAAW;AACV;IAAX,QAAQ,EAAE;+CAAa;AAEgB;IAAvC,KAAK,CAAC,cAAc,CAAC;0DAAkD;AAf7D,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAkI3B"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAoB,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAoB,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-material/chip",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Material Design 3 chip web component (assist, filter, input, suggestion variants).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -33,15 +33,16 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
|
-
"dist"
|
|
36
|
+
"dist",
|
|
37
|
+
"custom-elements.json"
|
|
37
38
|
],
|
|
38
39
|
"publishConfig": {
|
|
39
40
|
"access": "public"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"lit": "^3.2.0",
|
|
43
|
-
"@lit-material/
|
|
44
|
-
"@lit-material/
|
|
44
|
+
"@lit-material/core": "0.0.3",
|
|
45
|
+
"@lit-material/tokens": "0.0.2"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@lit-labs/ssr": "^3.3.1",
|
|
@@ -53,9 +54,11 @@
|
|
|
53
54
|
"tsx": "^4.19.0",
|
|
54
55
|
"typescript": "^5.7.0"
|
|
55
56
|
},
|
|
57
|
+
"customElements": "custom-elements.json",
|
|
56
58
|
"scripts": {
|
|
57
59
|
"build": "tsc -p tsconfig.json",
|
|
58
60
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
59
|
-
"test": "web-test-runner && node --import tsx --test src/chip.ssr.test.ts"
|
|
61
|
+
"test": "web-test-runner && node --import tsx --test src/chip.ssr.test.ts",
|
|
62
|
+
"analyze": "custom-elements-manifest analyze --litelement --globs \"src/**/*.ts\" --exclude \"src/**/*.test.ts\" --exclude \"src/**/*.ssr.test.ts\""
|
|
60
63
|
}
|
|
61
64
|
}
|