@reliability-design/web 1.1.1 → 1.3.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/dist/components/rel-accordion/rel-accordion.ts +289 -150
- package/dist/components/rel-alert/rel-alert.ts +34 -34
- package/dist/components/rel-avatar/README.md +15 -4
- package/dist/components/rel-avatar/rel-avatar.ts +138 -94
- package/dist/components/rel-badge/README.md +7 -0
- package/dist/components/rel-badge/rel-badge.ts +39 -2
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +6 -6
- package/dist/components/rel-button/rel-button.ts +96 -28
- package/dist/components/rel-calendar/rel-calendar.ts +15 -8
- package/dist/components/rel-card/rel-card.ts +9 -17
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +20 -23
- package/dist/components/rel-carousel/rel-carousel.ts +596 -468
- package/dist/components/rel-checkbox/rel-checkbox.ts +68 -16
- package/dist/components/rel-chip/README.md +7 -0
- package/dist/components/rel-chip/rel-chip.ts +411 -244
- package/dist/components/rel-container/rel-container.ts +2 -2
- package/dist/components/rel-date-picker/rel-date-picker.ts +23 -19
- package/dist/components/rel-divider/rel-divider.ts +3 -3
- package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -2
- package/dist/components/rel-drawer/rel-drawer.ts +46 -90
- package/dist/components/rel-kbd/rel-kbd.ts +94 -118
- package/dist/components/rel-layout/rel-layout.ts +49 -58
- package/dist/components/rel-menu/rel-menu.ts +359 -359
- package/dist/components/rel-menubar/rel-menubar-menu.css +3 -0
- package/dist/components/rel-menubar/rel-menubar-menu.ts +2 -1
- package/dist/components/rel-menubar/rel-menubar.ts +603 -605
- package/dist/components/rel-otp/rel-otp.ts +22 -25
- package/dist/components/rel-pagination/rel-pagination.ts +442 -381
- package/dist/components/rel-popover/rel-popover-content.ts +6 -5
- package/dist/components/rel-popover/rel-popover.ts +26 -7
- package/dist/components/rel-progress/rel-progress.ts +10 -9
- package/dist/components/rel-radio/rel-radio.ts +228 -172
- package/dist/components/rel-range-picker/rel-range-picker.css +349 -0
- package/dist/components/rel-range-picker/rel-range-picker.ts +1080 -0
- package/dist/components/rel-resizable/rel-resizable-handle.ts +8 -7
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +41 -20
- package/dist/components/rel-select/README.md +34 -28
- package/dist/components/rel-select/rel-select.ts +1015 -275
- package/dist/components/rel-sheet/rel-sheet.ts +365 -684
- package/dist/components/rel-skeleton/rel-skeleton.ts +139 -0
- package/dist/components/rel-slider/rel-slider.ts +49 -27
- package/dist/components/rel-snackbar/rel-snackbar.ts +28 -28
- package/dist/components/rel-stepper/rel-stepper.ts +11 -10
- package/dist/components/rel-switch/rel-switch.ts +7 -6
- package/dist/components/rel-tab/rel-tab.ts +15 -29
- package/dist/components/rel-textfield/rel-textfield.ts +192 -35
- package/dist/components/rel-toast/rel-toast.ts +21 -13
- package/dist/components/rel-tooltip/rel-tooltip.ts +123 -123
- package/dist/components/rel-topbar/rel-topbar-actions.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar-brand.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +32 -2
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +1 -1
- package/dist/components/rel-topbar/rel-topbar-item.ts +15 -10
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar-profile.ts +30 -56
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar.ts +137 -28
- package/dist/index.d.mts +310 -193
- package/dist/index.d.ts +310 -193
- package/dist/index.js +5562 -3526
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5328 -3284
- package/dist/index.mjs.map +1 -1
- package/dist/rel-menubar-menu-BEEQDAXW.css +3 -0
- package/dist/styles/vars-v2.css +525 -0
- package/dist/styles/vars.css +346 -346
- package/dist/{vars-TBB4BMSD.css → vars-I2PC74XD.css} +346 -346
- package/dist/vars-v2-VMGWTFJZ.css +525 -0
- package/package.json +2 -1
|
@@ -1,244 +1,411 @@
|
|
|
1
|
-
import { LitElement, html, css } from "lit";
|
|
2
|
-
import { customElement, property } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
@
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.chip
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
border-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.chip
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
background:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
:host
|
|
164
|
-
:host
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
:host
|
|
176
|
-
:host
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
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";
|
|
10
|
+
|
|
11
|
+
@customElement("rel-chip")
|
|
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
|
+
|
|
23
|
+
@property({ type: String }) label = "Label";
|
|
24
|
+
|
|
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";
|
|
30
|
+
|
|
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;
|
|
36
|
+
/** Initials text for the avatar (e.g. "JD"). Mutually exclusive with leadingIcon. */
|
|
37
|
+
@property({ type: String }) avatar?: string;
|
|
38
|
+
|
|
39
|
+
@property({ type: Boolean }) removable = false;
|
|
40
|
+
|
|
41
|
+
/** IMPORTANT: reflected so CSS + Angular can see it */
|
|
42
|
+
@property({ type: Boolean, reflect: true }) removed = false;
|
|
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
|
+
|
|
53
|
+
static styles = css`
|
|
54
|
+
:host {
|
|
55
|
+
display: inline-flex;
|
|
56
|
+
width: auto;
|
|
57
|
+
flex: 0 0 auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
:host([removed]) {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.chip {
|
|
65
|
+
display: inline-flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
font-family: var(--rel-fontFamilies-primary);
|
|
69
|
+
font-weight: 500;
|
|
70
|
+
letter-spacing: -0.6px;
|
|
71
|
+
gap: 8px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
user-select: none;
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
outline: none;
|
|
76
|
+
background: transparent;
|
|
77
|
+
transition: background-color 0.15s ease;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* ── Size ── */
|
|
81
|
+
:host([size="lg"]) .chip {
|
|
82
|
+
height: 32px;
|
|
83
|
+
padding: 4px 8px;
|
|
84
|
+
font-size: 16px;
|
|
85
|
+
line-height: 24px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:host([size="md"]) .chip {
|
|
89
|
+
height: 28px;
|
|
90
|
+
padding: 4px 8px;
|
|
91
|
+
font-size: 14px;
|
|
92
|
+
line-height: 22px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:host([size="sm"]) .chip {
|
|
96
|
+
height: 24px;
|
|
97
|
+
padding: 4px 8px;
|
|
98
|
+
font-size: 12px;
|
|
99
|
+
line-height: 20px;
|
|
100
|
+
}
|
|
101
|
+
|
|
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;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
:host([border="rounded"]) .chip {
|
|
109
|
+
border-radius: 1000px;
|
|
110
|
+
padding-left: 12px;
|
|
111
|
+
padding-right: 12px;
|
|
112
|
+
}
|
|
113
|
+
|
|
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;
|
|
154
|
+
}
|
|
155
|
+
|
|
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;
|
|
170
|
+
}
|
|
171
|
+
|
|
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);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
:host([dragging]) .chip {
|
|
181
|
+
cursor: grabbing;
|
|
182
|
+
}
|
|
183
|
+
|
|
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;
|
|
194
|
+
}
|
|
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. */
|
|
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 {
|
|
225
|
+
display: inline-flex;
|
|
226
|
+
flex-shrink: 0;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
:host([variant="fill"]) .chip rel-avatar {
|
|
230
|
+
--rel-avatar-bg-fill: rgba(255, 255, 255, 0.25);
|
|
231
|
+
--rel-avatar-color-fill: #ffffff;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
:host([variant="subtle"]) .chip rel-avatar {
|
|
235
|
+
--rel-avatar-bg-fill: rgba(11, 11, 11, 0.12);
|
|
236
|
+
--rel-avatar-color-fill: currentColor;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* ── Remove (close) button ── */
|
|
240
|
+
.chip-remove {
|
|
241
|
+
display: inline-flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
justify-content: center;
|
|
244
|
+
flex-shrink: 0;
|
|
245
|
+
cursor: pointer;
|
|
246
|
+
opacity: 0.7;
|
|
247
|
+
background: none;
|
|
248
|
+
border: none;
|
|
249
|
+
color: inherit;
|
|
250
|
+
font: inherit;
|
|
251
|
+
padding: 0;
|
|
252
|
+
line-height: 1;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.chip-remove:hover {
|
|
256
|
+
opacity: 1;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.chip-remove:focus-visible {
|
|
260
|
+
outline: 1.5px solid currentColor;
|
|
261
|
+
outline-offset: 1px;
|
|
262
|
+
border-radius: 2px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
:host([size="lg"]) .chip-remove {
|
|
266
|
+
--rel-icon-size: 16px;
|
|
267
|
+
}
|
|
268
|
+
:host([size="md"]) .chip-remove {
|
|
269
|
+
--rel-icon-size: 14px;
|
|
270
|
+
}
|
|
271
|
+
:host([size="sm"]) .chip-remove {
|
|
272
|
+
--rel-icon-size: 12px;
|
|
273
|
+
}
|
|
274
|
+
|
|
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;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
:host-context([data-theme="dark"])[tone="danger"][variant="subtle"] .chip {
|
|
291
|
+
background: #3d1414;
|
|
292
|
+
color: #ff8080;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
:host-context([data-theme="dark"])[tone="warning"][variant="subtle"] .chip {
|
|
296
|
+
background: #3d2e0a;
|
|
297
|
+
color: #ffd980;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
:host-context([data-theme="dark"])[tone="success"][variant="subtle"] .chip {
|
|
301
|
+
background: #0d2e22;
|
|
302
|
+
color: #4ddba3;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
:host-context([data-theme="dark"])[tone="info"][variant="subtle"] .chip {
|
|
306
|
+
background: #0a2e45;
|
|
307
|
+
color: #66c2ff;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
:host-context([data-theme="dark"])[tone="neutral"][variant="fill"] .chip {
|
|
311
|
+
background: #f5f5f5;
|
|
312
|
+
color: #0b0b0b;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
:host-context([data-theme="dark"]) .chip-remove:focus-visible {
|
|
316
|
+
outline-color: currentColor;
|
|
317
|
+
}
|
|
318
|
+
`;
|
|
319
|
+
|
|
320
|
+
private get classes() {
|
|
321
|
+
return "chip";
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
private handleRemove(event: Event) {
|
|
325
|
+
event.stopPropagation();
|
|
326
|
+
this.removed = true;
|
|
327
|
+
|
|
328
|
+
this.dispatchEvent(
|
|
329
|
+
new CustomEvent("removed", {
|
|
330
|
+
bubbles: true,
|
|
331
|
+
composed: true,
|
|
332
|
+
})
|
|
333
|
+
);
|
|
334
|
+
}
|
|
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
|
+
|
|
364
|
+
render() {
|
|
365
|
+
const showAvatar = !!this.avatar;
|
|
366
|
+
const showLeadingIcon = !showAvatar && !!this.leadingIcon;
|
|
367
|
+
|
|
368
|
+
if (this.avatar && this.leadingIcon) {
|
|
369
|
+
console.warn(
|
|
370
|
+
"[rel-chip] leadingIcon and avatar are mutually exclusive. avatar takes precedence."
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return html`
|
|
375
|
+
<span
|
|
376
|
+
class="${this.classes}"
|
|
377
|
+
role="button"
|
|
378
|
+
tabindex="0"
|
|
379
|
+
aria-label="${this.label}"
|
|
380
|
+
>
|
|
381
|
+
${showAvatar
|
|
382
|
+
? html`<rel-avatar type="text" text=${this.avatar} size="xs"></rel-avatar>`
|
|
383
|
+
: null}
|
|
384
|
+
${showLeadingIcon
|
|
385
|
+
? html`<rel-icon class="chip-icon" name="${this.leadingIcon}"></rel-icon>`
|
|
386
|
+
: null}
|
|
387
|
+
|
|
388
|
+
<span class="chip-label">${this.label}</span>
|
|
389
|
+
|
|
390
|
+
${this.trailingIcon
|
|
391
|
+
? html`<rel-icon class="chip-icon" name="${this.trailingIcon}"></rel-icon>`
|
|
392
|
+
: null}
|
|
393
|
+
${this.removable
|
|
394
|
+
? html`<button
|
|
395
|
+
class="chip-remove"
|
|
396
|
+
aria-label="Remove ${this.label}"
|
|
397
|
+
@click=${this.handleRemove}
|
|
398
|
+
>
|
|
399
|
+
<rel-icon name="close"></rel-icon>
|
|
400
|
+
</button>`
|
|
401
|
+
: null}
|
|
402
|
+
</span>
|
|
403
|
+
`;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
declare global {
|
|
408
|
+
interface HTMLElementTagNameMap {
|
|
409
|
+
"rel-chip": RelChip;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
@@ -22,11 +22,11 @@ export class RelContainer extends LitElement {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
.bg-white {
|
|
25
|
-
background-color: var(--rel-
|
|
25
|
+
background-color: var(--rel-color-bg-primary);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
.bg-light {
|
|
29
|
-
background-color: var(--rel-
|
|
29
|
+
background-color: var(--rel-color-bg-secondary);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
.bg-none {
|