@reliability-design/web 1.2.0 → 1.3.1
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/dist/components/rel-accordion/rel-accordion.ts +289 -135
- package/dist/components/rel-alert/rel-alert.ts +8 -1
- package/dist/components/rel-avatar/README.md +15 -4
- package/dist/components/rel-avatar/rel-avatar.ts +138 -96
- package/dist/components/rel-badge/README.md +7 -0
- package/dist/components/rel-badge/rel-badge.ts +61 -8
- package/dist/components/rel-button/rel-button.ts +64 -7
- package/dist/components/rel-chip/README.md +7 -0
- package/dist/components/rel-chip/rel-chip.ts +250 -130
- package/dist/components/rel-date-picker/rel-date-picker.ts +116 -14
- package/dist/components/rel-drawer/rel-drawer.ts +5 -2
- package/dist/components/rel-menubar/rel-menubar.ts +1 -0
- package/dist/components/rel-pagination/rel-pagination.ts +442 -425
- package/dist/components/rel-radio/rel-radio.ts +16 -16
- package/dist/components/rel-range-picker/rel-range-picker.css +349 -349
- package/dist/components/rel-range-picker/rel-range-picker.ts +1080 -1079
- package/dist/components/rel-select/README.md +34 -28
- package/dist/components/rel-select/rel-select.ts +1015 -346
- package/dist/components/rel-sheet/rel-sheet.ts +6 -3
- package/dist/components/rel-skeleton/rel-skeleton.ts +139 -0
- package/dist/components/rel-tab/rel-tab.ts +10 -4
- package/dist/components/rel-textfield/rel-textfield.ts +637 -349
- package/dist/components/rel-toast/rel-toast.ts +1 -6
- package/dist/components/rel-topbar/rel-topbar-actions.ts +4 -0
- package/dist/components/rel-topbar/rel-topbar-brand.ts +4 -0
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +4 -0
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +4 -0
- package/dist/components/rel-topbar/rel-topbar-item.ts +4 -0
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +4 -0
- package/dist/components/rel-topbar/rel-topbar-profile.ts +3 -0
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +4 -0
- package/dist/components/rel-topbar/rel-topbar.ts +6 -0
- package/dist/index.d.mts +239 -22
- package/dist/index.d.ts +239 -22
- package/dist/index.js +2609 -981
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2621 -994
- package/dist/index.mjs.map +1 -1
- package/dist/styles/vars.css +17 -0
- package/dist/{vars-I2PC74XD.css → vars-F54UGCHM.css} +17 -0
- package/package.json +1 -1
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
import { LitElement, html, css } from "lit";
|
|
2
|
-
import { customElement, property } from "lit/decorators.js";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
3
|
import "../rel-avatar/rel-avatar.js";
|
|
4
|
+
import "@reliability-design/icons/rel-icon";
|
|
5
|
+
|
|
6
|
+
export type ChipTone = "neutral" | "danger" | "warning" | "success" | "info";
|
|
7
|
+
export type ChipVariant = "fill" | "subtle";
|
|
8
|
+
export type ChipSize = "sm" | "md" | "lg";
|
|
9
|
+
export type ChipBorder = "default" | "rounded";
|
|
4
10
|
|
|
5
11
|
@customElement("rel-chip")
|
|
6
12
|
export class RelChip extends LitElement {
|
|
13
|
+
// The actually-focusable element is the inner <span tabindex="0">, not the
|
|
14
|
+
// host. Without delegatesFocus, calling host.focus() (e.g. from a parent
|
|
15
|
+
// component, or a "focus this" demo button) is a no-op since the host
|
|
16
|
+
// itself carries no tabindex — only real Tab-key traversal would still
|
|
17
|
+
// reach the inner span, because that walks the flattened DOM regardless.
|
|
18
|
+
static override shadowRootOptions: ShadowRootInit = {
|
|
19
|
+
...LitElement.shadowRootOptions,
|
|
20
|
+
delegatesFocus: true,
|
|
21
|
+
};
|
|
22
|
+
|
|
7
23
|
@property({ type: String }) label = "Label";
|
|
8
24
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
25
|
+
@property({ type: String, reflect: true }) tone: ChipTone = "neutral";
|
|
26
|
+
|
|
27
|
+
@property({ type: String, reflect: true }) variant: ChipVariant = "fill";
|
|
28
|
+
|
|
29
|
+
@property({ type: String, reflect: true }) size: ChipSize = "md";
|
|
12
30
|
|
|
13
|
-
@property({ type: String })
|
|
14
|
-
|
|
31
|
+
@property({ type: String, reflect: true }) border: ChipBorder = "default";
|
|
32
|
+
|
|
33
|
+
/** Icon name from the generated icon dictionary (e.g. "settings") — rendered via <rel-icon>. */
|
|
34
|
+
@property({ type: String, attribute: "leading-icon" }) leadingIcon?: string;
|
|
35
|
+
@property({ type: String, attribute: "trailing-icon" }) trailingIcon?: string;
|
|
15
36
|
/** Initials text for the avatar (e.g. "JD"). Mutually exclusive with leadingIcon. */
|
|
16
37
|
@property({ type: String }) avatar?: string;
|
|
17
38
|
|
|
@@ -20,6 +41,15 @@ export class RelChip extends LitElement {
|
|
|
20
41
|
/** IMPORTANT: reflected so CSS + Angular can see it */
|
|
21
42
|
@property({ type: Boolean, reflect: true }) removed = false;
|
|
22
43
|
|
|
44
|
+
/** Opt-in native drag-and-drop — reflects the Figma "Dragged" state automatically during a real drag gesture. */
|
|
45
|
+
// Explicit attribute mapping — Lit's default attribute name for a camelCase
|
|
46
|
+
// property is the name fully lowercased (no hyphens), so without this it'd
|
|
47
|
+
// only respond to draggablechip="", not draggable-chip.
|
|
48
|
+
@property({ type: Boolean, attribute: "draggable-chip" }) draggableChip = false;
|
|
49
|
+
|
|
50
|
+
/** Reflected so CSS can target the Figma "Dragged" visual state. Driven automatically by dragstart/dragend when draggableChip is set. */
|
|
51
|
+
@state() private dragging = false;
|
|
52
|
+
|
|
23
53
|
static styles = css`
|
|
24
54
|
:host {
|
|
25
55
|
display: inline-flex;
|
|
@@ -34,108 +64,184 @@ export class RelChip extends LitElement {
|
|
|
34
64
|
.chip {
|
|
35
65
|
display: inline-flex;
|
|
36
66
|
align-items: center;
|
|
67
|
+
box-sizing: border-box;
|
|
37
68
|
font-family: var(--rel-fontFamilies-primary);
|
|
38
|
-
font-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
padding: var(--rel-spacing-space-2xs) var(--rel-spacing-space-xs);
|
|
42
|
-
gap: var(--rel-spacing-space-2xs);
|
|
69
|
+
font-weight: 500;
|
|
70
|
+
letter-spacing: -0.6px;
|
|
71
|
+
gap: 8px;
|
|
43
72
|
cursor: pointer;
|
|
44
|
-
border: var(--rel-borders-width-stroke-100) solid transparent;
|
|
45
73
|
user-select: none;
|
|
46
74
|
white-space: nowrap;
|
|
75
|
+
outline: none;
|
|
47
76
|
background: transparent;
|
|
77
|
+
transition: background-color 0.15s ease;
|
|
48
78
|
}
|
|
49
79
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
/* ── Size ── */
|
|
81
|
+
:host([size="lg"]) .chip {
|
|
82
|
+
height: 32px;
|
|
83
|
+
padding: 4px 8px;
|
|
84
|
+
font-size: 16px;
|
|
85
|
+
line-height: 24px;
|
|
53
86
|
}
|
|
54
87
|
|
|
55
|
-
.chip
|
|
56
|
-
|
|
57
|
-
|
|
88
|
+
:host([size="md"]) .chip {
|
|
89
|
+
height: 28px;
|
|
90
|
+
padding: 4px 8px;
|
|
91
|
+
font-size: 14px;
|
|
92
|
+
line-height: 22px;
|
|
58
93
|
}
|
|
59
94
|
|
|
60
|
-
.chip
|
|
61
|
-
|
|
62
|
-
|
|
95
|
+
:host([size="sm"]) .chip {
|
|
96
|
+
height: 24px;
|
|
97
|
+
padding: 4px 8px;
|
|
98
|
+
font-size: 12px;
|
|
99
|
+
line-height: 20px;
|
|
63
100
|
}
|
|
64
101
|
|
|
65
|
-
/*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
background: #717171;
|
|
70
|
-
color: var(--rel-colors-white);
|
|
102
|
+
/* ── Border / shape — "Rounded" also widens horizontal padding to 12px,
|
|
103
|
+
consistent across all three sizes per the Figma spec. ── */
|
|
104
|
+
:host([border="default"]) .chip {
|
|
105
|
+
border-radius: 4px;
|
|
71
106
|
}
|
|
72
107
|
|
|
73
|
-
.chip
|
|
74
|
-
|
|
75
|
-
|
|
108
|
+
:host([border="rounded"]) .chip {
|
|
109
|
+
border-radius: 1000px;
|
|
110
|
+
padding-left: 12px;
|
|
111
|
+
padding-right: 12px;
|
|
76
112
|
}
|
|
77
113
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
114
|
+
/* ── Tone x Variant — Default/Default state colors ── */
|
|
115
|
+
:host([tone="neutral"][variant="fill"]) .chip {
|
|
116
|
+
background: #0b0b0b;
|
|
117
|
+
color: #ffffff;
|
|
118
|
+
}
|
|
119
|
+
:host([tone="neutral"][variant="subtle"]) .chip {
|
|
120
|
+
background: #f5f5f5;
|
|
121
|
+
color: #0b0b0b;
|
|
122
|
+
}
|
|
123
|
+
:host([tone="danger"][variant="fill"]) .chip {
|
|
124
|
+
background: #f83b3b;
|
|
125
|
+
color: #ffffff;
|
|
126
|
+
}
|
|
127
|
+
:host([tone="danger"][variant="subtle"]) .chip {
|
|
128
|
+
background: #fff1f1;
|
|
129
|
+
color: #ce3131;
|
|
130
|
+
}
|
|
131
|
+
:host([tone="warning"][variant="fill"]) .chip {
|
|
132
|
+
background: #ffcb66;
|
|
133
|
+
color: #0b0b0b;
|
|
134
|
+
}
|
|
135
|
+
:host([tone="warning"][variant="subtle"]) .chip {
|
|
136
|
+
background: #ffefd1;
|
|
137
|
+
color: #713f12;
|
|
138
|
+
}
|
|
139
|
+
:host([tone="success"][variant="fill"]) .chip {
|
|
140
|
+
background: #00a86b;
|
|
141
|
+
color: #ffffff;
|
|
142
|
+
}
|
|
143
|
+
:host([tone="success"][variant="subtle"]) .chip {
|
|
144
|
+
background: #edf8f4;
|
|
145
|
+
color: #008655;
|
|
146
|
+
}
|
|
147
|
+
:host([tone="info"][variant="fill"]) .chip {
|
|
148
|
+
background: #0091ea;
|
|
149
|
+
color: #ffffff;
|
|
150
|
+
}
|
|
151
|
+
:host([tone="info"][variant="subtle"]) .chip {
|
|
152
|
+
background: #eff7ff;
|
|
153
|
+
color: #00528d;
|
|
81
154
|
}
|
|
82
155
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
156
|
+
/* ── Hover / Dragged — Figma only specs explicit color shifts for the
|
|
157
|
+
"neutral" tone; the other four tones have no hover/dragged sample to
|
|
158
|
+
match, so a generic brightness dim covers them instead of leaving
|
|
159
|
+
hover completely inert. Flagged in the handoff notes. ── */
|
|
160
|
+
:host([tone="neutral"][variant="fill"]) .chip:hover {
|
|
161
|
+
background: #363636;
|
|
162
|
+
}
|
|
163
|
+
:host([tone="neutral"][variant="fill"]) .chip:active,
|
|
164
|
+
:host([tone="neutral"][variant="fill"][dragging]) .chip {
|
|
165
|
+
background: #404040;
|
|
166
|
+
}
|
|
167
|
+
:host([tone="neutral"][variant="subtle"]) .chip:active,
|
|
168
|
+
:host([tone="neutral"][variant="subtle"][dragging]) .chip {
|
|
169
|
+
background: #e5e5e5;
|
|
86
170
|
}
|
|
87
171
|
|
|
88
|
-
.chip
|
|
89
|
-
|
|
90
|
-
|
|
172
|
+
:host(:not([tone="neutral"])) .chip:hover {
|
|
173
|
+
filter: brightness(0.96);
|
|
174
|
+
}
|
|
175
|
+
:host(:not([tone="neutral"])) .chip:active,
|
|
176
|
+
:host(:not([tone="neutral"])[dragging]) .chip {
|
|
177
|
+
filter: brightness(0.92);
|
|
91
178
|
}
|
|
92
179
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
Overriding that custom property here pins avatar bg to white across all tones.
|
|
96
|
-
NOTE: rel-avatar hardcodes color: #ffffff — text color (#000000) cannot be
|
|
97
|
-
overridden from outside the shadow DOM without ::part() or a custom property
|
|
98
|
-
in rel-avatar itself. */
|
|
99
|
-
.chip rel-avatar {
|
|
100
|
-
display: inline-flex;
|
|
101
|
-
width: 20px !important;
|
|
102
|
-
height: 20px !important;
|
|
103
|
-
flex-shrink: 0;
|
|
104
|
-
font-size: 10px;
|
|
180
|
+
:host([dragging]) .chip {
|
|
181
|
+
cursor: grabbing;
|
|
105
182
|
}
|
|
106
183
|
|
|
107
|
-
.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
184
|
+
/* ── Focused — 1.5px outline, drawn outside (matches Figma's
|
|
185
|
+
strokeAlign:OUTSIDE) so it never affects layout. Same color
|
|
186
|
+
regardless of tone, per spec. OUTSIDE alignment means the stroke
|
|
187
|
+
sits flush against the shape's edge with zero gap, extending
|
|
188
|
+
outward by strokeWeight — outline-offset must be 0, not a positive
|
|
189
|
+
gap (a positive offset was the bug: it drew a visible gap that
|
|
190
|
+
doesn't exist in Figma). ── */
|
|
191
|
+
.chip:focus-visible {
|
|
192
|
+
outline: 1.5px solid var(--rel-chip-focus-ring, #0b0b0b);
|
|
193
|
+
outline-offset: 0;
|
|
114
194
|
}
|
|
115
195
|
|
|
196
|
+
/* ── Icons ── */
|
|
197
|
+
/* rel-icon renders its SVG inside its own shadow root, so sizing has to
|
|
198
|
+
go through --rel-icon-size (a custom property — pierces shadow
|
|
199
|
+
boundaries) rather than a ".chip-icon svg" selector, which can never
|
|
200
|
+
reach across shadow DOM. */
|
|
116
201
|
.chip-icon {
|
|
202
|
+
flex-shrink: 0;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
:host([size="lg"]) .chip-icon {
|
|
206
|
+
--rel-icon-size: 16px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
:host([size="md"]) .chip-icon {
|
|
210
|
+
--rel-icon-size: 14px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
:host([size="sm"]) .chip-icon {
|
|
214
|
+
--rel-icon-size: 12px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* ── Avatar — not shown in the Figma sample. rel-avatar sizes its inner
|
|
218
|
+
.avatar div directly from its own "size" prop (fixed presets only —
|
|
219
|
+
no --rel-avatar-size custom property escape hatch like rel-icon has),
|
|
220
|
+
so a host-level width/height override here would only resize the
|
|
221
|
+
empty outer wrapper, not the actual painted circle. "xs" (20px) is
|
|
222
|
+
rel-avatar's smallest preset; used uniformly across all three chip
|
|
223
|
+
sizes since there's nothing smaller to ask for. ── */
|
|
224
|
+
.chip rel-avatar {
|
|
117
225
|
display: inline-flex;
|
|
118
|
-
align-items: center;
|
|
119
|
-
justify-content: center;
|
|
120
|
-
width: 16px;
|
|
121
|
-
height: 16px;
|
|
122
226
|
flex-shrink: 0;
|
|
123
227
|
}
|
|
124
228
|
|
|
125
|
-
.chip-
|
|
126
|
-
|
|
127
|
-
|
|
229
|
+
:host([variant="fill"]) .chip rel-avatar {
|
|
230
|
+
--rel-avatar-bg-fill: rgba(255, 255, 255, 0.25);
|
|
231
|
+
--rel-avatar-color-fill: #ffffff;
|
|
128
232
|
}
|
|
129
233
|
|
|
130
|
-
.chip-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
height: 16px;
|
|
134
|
-
fill: currentColor;
|
|
234
|
+
:host([variant="subtle"]) .chip rel-avatar {
|
|
235
|
+
--rel-avatar-bg-fill: rgba(11, 11, 11, 0.12);
|
|
236
|
+
--rel-avatar-color-fill: currentColor;
|
|
135
237
|
}
|
|
136
238
|
|
|
239
|
+
/* ── Remove (close) button ── */
|
|
137
240
|
.chip-remove {
|
|
138
|
-
|
|
241
|
+
display: inline-flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
justify-content: center;
|
|
244
|
+
flex-shrink: 0;
|
|
139
245
|
cursor: pointer;
|
|
140
246
|
opacity: 0.7;
|
|
141
247
|
background: none;
|
|
@@ -151,78 +257,68 @@ export class RelChip extends LitElement {
|
|
|
151
257
|
}
|
|
152
258
|
|
|
153
259
|
.chip-remove:focus-visible {
|
|
154
|
-
outline:
|
|
260
|
+
outline: 1.5px solid currentColor;
|
|
155
261
|
outline-offset: 1px;
|
|
156
262
|
border-radius: 2px;
|
|
157
263
|
}
|
|
158
264
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
/* NOTE: #FFFBF5 (chip-orange dark bg) has no exact vars-v2 token;
|
|
162
|
-
nearest is --rel-colors-gray-light (#FAFAFA) */
|
|
163
|
-
|
|
164
|
-
/* Reinforce layout — external dark-mode stylesheets can override display/width on the host */
|
|
165
|
-
:host-context([data-theme="dark"]) .chip {
|
|
166
|
-
display: inline-flex;
|
|
167
|
-
width: auto;
|
|
265
|
+
:host([size="lg"]) .chip-remove {
|
|
266
|
+
--rel-icon-size: 16px;
|
|
168
267
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
/* --rel-colors-gray-screen-bg flips to #262626 in dark — hardcoded to preserve #EEEEEE */
|
|
172
|
-
background: #EEEEEE;
|
|
173
|
-
color: #717171;
|
|
268
|
+
:host([size="md"]) .chip-remove {
|
|
269
|
+
--rel-icon-size: 14px;
|
|
174
270
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
/* --rel-colors-blue-bg flips to #0f1e2c in dark mode — hardcoded to preserve #E1F2FF */
|
|
178
|
-
background: #E1F2FF;
|
|
179
|
-
color: var(--rel-colors-blue-tertiary);
|
|
271
|
+
:host([size="sm"]) .chip-remove {
|
|
272
|
+
--rel-icon-size: 12px;
|
|
180
273
|
}
|
|
181
274
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
275
|
+
/* ── Dark mode — Figma had no dark-mode sample for this new component
|
|
276
|
+
set. Fill stays unchanged (the saturated tones already read fine on
|
|
277
|
+
dark surfaces); Subtle gets a dark-tinted background, following the
|
|
278
|
+
same invert pattern used elsewhere in this design system. Flagged in
|
|
279
|
+
the handoff notes — adjust if exact values exist.
|
|
280
|
+
No [data-theme="dark"] :host(...) fallback here — :host() can never
|
|
281
|
+
be preceded by a combinator, so that form is invalid and silently
|
|
282
|
+
matches nothing (the exact bug hit and fixed multiple times in
|
|
283
|
+
rel-avatar/rel-select earlier this session). :host-context() alone
|
|
284
|
+
has universal modern browser support, so no fallback is needed. ── */
|
|
285
|
+
:host-context([data-theme="dark"])[tone="neutral"][variant="subtle"] .chip {
|
|
286
|
+
background: #333333;
|
|
287
|
+
color: #f5f5f5;
|
|
185
288
|
}
|
|
186
289
|
|
|
187
|
-
:host-context([data-theme="dark"]) .chip
|
|
188
|
-
background:
|
|
189
|
-
color:
|
|
290
|
+
:host-context([data-theme="dark"])[tone="danger"][variant="subtle"] .chip {
|
|
291
|
+
background: #3d1414;
|
|
292
|
+
color: #ff8080;
|
|
190
293
|
}
|
|
191
294
|
|
|
192
|
-
:host-context([data-theme="dark"]) .chip
|
|
193
|
-
background:
|
|
194
|
-
color:
|
|
295
|
+
:host-context([data-theme="dark"])[tone="warning"][variant="subtle"] .chip {
|
|
296
|
+
background: #3d2e0a;
|
|
297
|
+
color: #ffd980;
|
|
195
298
|
}
|
|
196
299
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
--rel-avatar-color: #ffffff;
|
|
300
|
+
:host-context([data-theme="dark"])[tone="success"][variant="subtle"] .chip {
|
|
301
|
+
background: #0d2e22;
|
|
302
|
+
color: #4ddba3;
|
|
201
303
|
}
|
|
202
304
|
|
|
203
|
-
:host-context([data-theme="dark"]) .chip
|
|
204
|
-
|
|
205
|
-
|
|
305
|
+
:host-context([data-theme="dark"])[tone="info"][variant="subtle"] .chip {
|
|
306
|
+
background: #0a2e45;
|
|
307
|
+
color: #66c2ff;
|
|
206
308
|
}
|
|
207
309
|
|
|
208
|
-
:host-context([data-theme="dark"]) .chip
|
|
209
|
-
|
|
210
|
-
|
|
310
|
+
:host-context([data-theme="dark"])[tone="neutral"][variant="fill"] .chip {
|
|
311
|
+
background: #f5f5f5;
|
|
312
|
+
color: #0b0b0b;
|
|
211
313
|
}
|
|
212
314
|
|
|
213
|
-
:host-context([data-theme="dark"]) .chip-
|
|
214
|
-
|
|
215
|
-
--rel-avatar-color: #ffffff;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
:host-context([data-theme="dark"]) .chip-green rel-avatar {
|
|
219
|
-
--rel-colors-gray-disabled-text: #00A86B;
|
|
220
|
-
--rel-avatar-color: #ffffff;
|
|
315
|
+
:host-context([data-theme="dark"]) .chip-remove:focus-visible {
|
|
316
|
+
outline-color: currentColor;
|
|
221
317
|
}
|
|
222
318
|
`;
|
|
223
319
|
|
|
224
320
|
private get classes() {
|
|
225
|
-
return
|
|
321
|
+
return "chip";
|
|
226
322
|
}
|
|
227
323
|
|
|
228
324
|
private handleRemove(event: Event) {
|
|
@@ -237,6 +333,34 @@ export class RelChip extends LitElement {
|
|
|
237
333
|
);
|
|
238
334
|
}
|
|
239
335
|
|
|
336
|
+
private onDragStart = (e: DragEvent) => {
|
|
337
|
+
if (!this.draggableChip) return;
|
|
338
|
+
this.dragging = true;
|
|
339
|
+
e.dataTransfer?.setData("text/plain", this.label);
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
private onDragEnd = () => {
|
|
343
|
+
this.dragging = false;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
protected updated(changed: Map<string, unknown>) {
|
|
347
|
+
if (changed.has("draggableChip")) {
|
|
348
|
+
if (this.draggableChip) {
|
|
349
|
+
this.setAttribute("draggable", "true");
|
|
350
|
+
this.addEventListener("dragstart", this.onDragStart);
|
|
351
|
+
this.addEventListener("dragend", this.onDragEnd);
|
|
352
|
+
} else {
|
|
353
|
+
this.removeAttribute("draggable");
|
|
354
|
+
this.removeEventListener("dragstart", this.onDragStart);
|
|
355
|
+
this.removeEventListener("dragend", this.onDragEnd);
|
|
356
|
+
this.dragging = false;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (changed.has("dragging")) {
|
|
360
|
+
this.toggleAttribute("dragging", this.dragging);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
240
364
|
render() {
|
|
241
365
|
const showAvatar = !!this.avatar;
|
|
242
366
|
const showLeadingIcon = !showAvatar && !!this.leadingIcon;
|
|
@@ -258,17 +382,13 @@ export class RelChip extends LitElement {
|
|
|
258
382
|
? html`<rel-avatar type="text" text=${this.avatar} size="xs"></rel-avatar>`
|
|
259
383
|
: null}
|
|
260
384
|
${showLeadingIcon
|
|
261
|
-
? html`<
|
|
262
|
-
${this.renderIcon(this.leadingIcon!)}
|
|
263
|
-
</span>`
|
|
385
|
+
? html`<rel-icon class="chip-icon" name="${this.leadingIcon}"></rel-icon>`
|
|
264
386
|
: null}
|
|
265
387
|
|
|
266
388
|
<span class="chip-label">${this.label}</span>
|
|
267
389
|
|
|
268
390
|
${this.trailingIcon
|
|
269
|
-
? html`<
|
|
270
|
-
${this.renderIcon(this.trailingIcon)}
|
|
271
|
-
</span>`
|
|
391
|
+
? html`<rel-icon class="chip-icon" name="${this.trailingIcon}"></rel-icon>`
|
|
272
392
|
: null}
|
|
273
393
|
${this.removable
|
|
274
394
|
? html`<button
|
|
@@ -276,16 +396,16 @@ export class RelChip extends LitElement {
|
|
|
276
396
|
aria-label="Remove ${this.label}"
|
|
277
397
|
@click=${this.handleRemove}
|
|
278
398
|
>
|
|
279
|
-
|
|
399
|
+
<rel-icon name="close"></rel-icon>
|
|
280
400
|
</button>`
|
|
281
401
|
: null}
|
|
282
402
|
</span>
|
|
283
403
|
`;
|
|
284
404
|
}
|
|
405
|
+
}
|
|
285
406
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
return template.content.cloneNode(true);
|
|
407
|
+
declare global {
|
|
408
|
+
interface HTMLElementTagNameMap {
|
|
409
|
+
"rel-chip": RelChip;
|
|
290
410
|
}
|
|
291
411
|
}
|