@krollins/blueprint 0.1.12 → 0.1.14
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 +9 -3
- package/README.npm.md +9 -3
- package/dist/components/accordion.js +393 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.js +213 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/avatar.js +237 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge.js +144 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.js +481 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button.js +192 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/card.js +223 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/checkbox.js +336 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/code-block/code-block.d.ts +143 -0
- package/dist/components/code-block/code-block.d.ts.map +1 -0
- package/dist/components/code-block/code-block.style.d.ts +2 -0
- package/dist/components/code-block/code-block.style.d.ts.map +1 -0
- package/dist/components/code-block.js +587 -0
- package/dist/components/code-block.js.map +1 -0
- package/dist/components/color-picker/color-picker.d.ts.map +1 -1
- package/dist/components/color-picker.js +1660 -0
- package/dist/components/color-picker.js.map +1 -0
- package/dist/components/combobox.js +595 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/date-picker.js +726 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/divider.js +214 -0
- package/dist/components/divider.js.map +1 -0
- package/dist/components/drawer.js +568 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown.js +377 -0
- package/dist/components/dropdown.js.map +1 -0
- package/dist/components/file-upload.js +669 -0
- package/dist/components/file-upload.js.map +1 -0
- package/dist/components/heading.js +161 -0
- package/dist/components/heading.js.map +1 -0
- package/dist/components/icon.js +599 -0
- package/dist/components/icon.js.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/input.js +363 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/link.js +178 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/menu.js +331 -0
- package/dist/components/menu.js.map +1 -0
- package/dist/components/modal.js +317 -0
- package/dist/components/modal.js.map +1 -0
- package/dist/components/multi-select.js +642 -0
- package/dist/components/multi-select.js.map +1 -0
- package/dist/components/notification.js +429 -0
- package/dist/components/notification.js.map +1 -0
- package/dist/components/number-input.js +556 -0
- package/dist/components/number-input.js.map +1 -0
- package/dist/components/pagination.js +320 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.js +597 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.js +219 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio.js +321 -0
- package/dist/components/radio.js.map +1 -0
- package/dist/components/select.js +498 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/skeleton.js +240 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.js +9 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/spinner.js +133 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/stepper.js +812 -0
- package/dist/components/stepper.js.map +1 -0
- package/dist/components/switch.js +379 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.js +642 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.js +547 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/tag/tag.d.ts.map +1 -1
- package/dist/components/tag.js +291 -0
- package/dist/components/tag.js.map +1 -0
- package/dist/components/text.js +278 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/textarea.js +380 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/time-picker.js +457 -0
- package/dist/components/time-picker.js.map +1 -0
- package/dist/components/tooltip.js +239 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/tree.js +582 -0
- package/dist/components/tree.js.map +1 -0
- package/dist/index.js +96 -17799
- package/dist/index.js.map +1 -1
- package/dist/shared/boolean-converter-XDGfS9LC.js +12 -0
- package/dist/shared/boolean-converter-XDGfS9LC.js.map +1 -0
- package/dist/shared/debounce-BckY30Sf.js +23 -0
- package/dist/shared/debounce-BckY30Sf.js.map +1 -0
- package/dist/shared/memoize-DlOFy-92.js +16 -0
- package/dist/shared/memoize-DlOFy-92.js.map +1 -0
- package/dist/shared/slider-BNt5TITl.js +484 -0
- package/dist/shared/slider-BNt5TITl.js.map +1 -0
- package/dist/utilities/memoize.d.ts.map +1 -1
- package/package.json +44 -2
|
@@ -0,0 +1,642 @@
|
|
|
1
|
+
import { css as v, LitElement as y, nothing as h, html as c } from "lit";
|
|
2
|
+
import { property as n, state as g, customElement as m } from "lit/decorators.js";
|
|
3
|
+
import { classMap as u } from "lit/directives/class-map.js";
|
|
4
|
+
import { ifDefined as w } from "lit/directives/if-defined.js";
|
|
5
|
+
import { repeat as f } from "lit/directives/repeat.js";
|
|
6
|
+
import { m as k } from "../shared/memoize-DlOFy-92.js";
|
|
7
|
+
import { b as S } from "../shared/boolean-converter-XDGfS9LC.js";
|
|
8
|
+
const x = v`
|
|
9
|
+
/* Base styles */
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.table-wrapper {
|
|
15
|
+
overflow-x: auto;
|
|
16
|
+
border-radius: var(--bp-border-radius);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.table {
|
|
20
|
+
width: 100%;
|
|
21
|
+
border-collapse: collapse;
|
|
22
|
+
font-family: var(--bp-font-family);
|
|
23
|
+
font-size: var(--bp-font-size-sm);
|
|
24
|
+
color: var(--bp-color-text);
|
|
25
|
+
background: var(--bp-color-surface);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Header styles */
|
|
29
|
+
.header-row {
|
|
30
|
+
background: var(--bp-color-surface-subdued);
|
|
31
|
+
border-bottom: var(--bp-border-width) solid var(--bp-color-border);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.header-cell {
|
|
35
|
+
font-weight: var(--bp-font-weight-semibold);
|
|
36
|
+
text-align: left;
|
|
37
|
+
color: var(--bp-color-text);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.header-cell--sortable {
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
user-select: none;
|
|
43
|
+
transition: background-color var(--bp-transition-fast);
|
|
44
|
+
position: relative;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.header-cell--sortable::after {
|
|
48
|
+
content: '';
|
|
49
|
+
position: absolute;
|
|
50
|
+
bottom: 0;
|
|
51
|
+
left: 0;
|
|
52
|
+
right: 0;
|
|
53
|
+
height: 2px;
|
|
54
|
+
background: transparent;
|
|
55
|
+
transition: background var(--bp-transition-fast);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.header-cell--sortable:hover::after {
|
|
59
|
+
background: var(--bp-color-primary);
|
|
60
|
+
opacity: 0.3;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.header-cell--sortable:hover {
|
|
64
|
+
background: var(--bp-color-surface);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.header-cell--sortable:active {
|
|
68
|
+
background: var(--bp-color-surface-subdued);
|
|
69
|
+
transform: translateY(1px);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.header-cell__content {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
gap: var(--bp-spacing-1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.header-cell__label {
|
|
79
|
+
flex: 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Sort icon */
|
|
83
|
+
.sort-icon {
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
color: var(--bp-color-text-muted);
|
|
87
|
+
transition: color var(--bp-transition-fast);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.sort-icon--active {
|
|
91
|
+
color: var(--bp-color-primary);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Cell styles */
|
|
95
|
+
.cell {
|
|
96
|
+
padding: var(--bp-spacing-3) var(--bp-spacing-4);
|
|
97
|
+
border-bottom: var(--bp-border-width) solid var(--bp-color-border);
|
|
98
|
+
vertical-align: middle;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.cell--checkbox {
|
|
102
|
+
width: var(--bp-spacing-10);
|
|
103
|
+
text-align: center;
|
|
104
|
+
padding-left: var(--bp-spacing-3);
|
|
105
|
+
padding-right: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.cell--checkbox input[type='checkbox'] {
|
|
109
|
+
width: var(--bp-spacing-6);
|
|
110
|
+
height: var(--bp-spacing-6);
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* Row styles */
|
|
115
|
+
.row {
|
|
116
|
+
transition: background-color var(--bp-transition-fast);
|
|
117
|
+
content-visibility: auto;
|
|
118
|
+
contain-intrinsic-size: auto 48px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.row--hoverable:hover {
|
|
122
|
+
background: var(--bp-color-surface-subdued);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.row--selected {
|
|
126
|
+
background: oklch(from var(--bp-color-primary) l c h / 0.15);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.row--selected:hover {
|
|
130
|
+
background: oklch(from var(--bp-color-primary) l c h / 0.2);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Remove border from last row */
|
|
134
|
+
tbody tr:last-child .cell {
|
|
135
|
+
border-bottom: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* Variants */
|
|
139
|
+
.table--striped tbody tr:nth-child(even) {
|
|
140
|
+
background: var(--bp-color-surface-subdued);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.table--striped tbody tr:nth-child(even):hover {
|
|
144
|
+
background: var(--bp-color-surface);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.table--striped .row--selected {
|
|
148
|
+
background: oklch(from var(--bp-color-primary) l c h / 0.15) !important;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.table--striped .row--selected:hover {
|
|
152
|
+
background: oklch(from var(--bp-color-primary) l c h / 0.2) !important;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.table--bordered {
|
|
156
|
+
border: var(--bp-border-width) solid var(--bp-color-border);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.table--bordered .cell {
|
|
160
|
+
border: var(--bp-border-width) solid var(--bp-color-border);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Sizes */
|
|
164
|
+
.table--sm .cell {
|
|
165
|
+
padding: var(--bp-spacing-1) var(--bp-spacing-3);
|
|
166
|
+
font-size: var(--bp-font-size-xs);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.table--sm .row {
|
|
170
|
+
contain-intrinsic-size: auto 36px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.table--md .cell {
|
|
174
|
+
padding: var(--bp-spacing-3) var(--bp-spacing-4);
|
|
175
|
+
font-size: var(--bp-font-size-sm);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.table--md .row {
|
|
179
|
+
contain-intrinsic-size: auto 48px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.table--lg .cell {
|
|
183
|
+
padding: var(--bp-spacing-4) var(--bp-spacing-5);
|
|
184
|
+
font-size: var(--bp-font-size-base);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.table--lg .row {
|
|
188
|
+
contain-intrinsic-size: auto 56px;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* Sticky header */
|
|
192
|
+
.table--sticky-header thead {
|
|
193
|
+
position: sticky;
|
|
194
|
+
top: 0;
|
|
195
|
+
z-index: 1;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.table--sticky-header .header-row {
|
|
199
|
+
box-shadow: var(--bp-shadow-sm);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* Selectable - add pointer cursor */
|
|
203
|
+
.table--selectable .row {
|
|
204
|
+
cursor: pointer;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* Loading state */
|
|
208
|
+
.table--loading {
|
|
209
|
+
opacity: var(--bp-opacity-disabled);
|
|
210
|
+
pointer-events: none;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* Empty state */
|
|
214
|
+
.empty-state {
|
|
215
|
+
text-align: center;
|
|
216
|
+
padding: var(--bp-spacing-10);
|
|
217
|
+
color: var(--bp-color-text-muted);
|
|
218
|
+
background: var(--bp-color-surface-subdued);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.state-content {
|
|
222
|
+
display: flex;
|
|
223
|
+
flex-direction: column;
|
|
224
|
+
align-items: center;
|
|
225
|
+
justify-content: center;
|
|
226
|
+
gap: var(--bp-spacing-3);
|
|
227
|
+
padding: var(--bp-spacing-5);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.sort-icon--inactive {
|
|
231
|
+
opacity: 0.4;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* Focus styles for keyboard navigation */
|
|
235
|
+
.header-cell--sortable:focus-visible {
|
|
236
|
+
outline: var(--bp-focus-width) var(--bp-focus-style) var(--bp-color-focus);
|
|
237
|
+
outline-offset: var(--bp-focus-offset);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.row:focus-visible {
|
|
241
|
+
outline: var(--bp-focus-width) var(--bp-focus-style) var(--bp-color-focus);
|
|
242
|
+
outline-offset: calc(-1 * var(--bp-focus-offset));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.cell--checkbox input[type='checkbox']:focus-visible {
|
|
246
|
+
outline: var(--bp-focus-width) var(--bp-focus-style) var(--bp-color-focus);
|
|
247
|
+
outline-offset: var(--bp-focus-offset);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Reduced motion */
|
|
251
|
+
@media (prefers-reduced-motion: reduce) {
|
|
252
|
+
.row,
|
|
253
|
+
.header-cell--sortable,
|
|
254
|
+
.sort-icon {
|
|
255
|
+
transition: none;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.header-cell--sortable:active {
|
|
259
|
+
transform: none;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.header-cell--sortable::after {
|
|
263
|
+
transition: none;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
`;
|
|
267
|
+
var R = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, i = (e, t, o, l) => {
|
|
268
|
+
for (var r = l > 1 ? void 0 : l ? $(t, o) : t, d = e.length - 1, a; d >= 0; d--)
|
|
269
|
+
(a = e[d]) && (r = (l ? a(t, o, r) : a(r)) || r);
|
|
270
|
+
return l && r && R(t, o, r), r;
|
|
271
|
+
};
|
|
272
|
+
let s = class extends y {
|
|
273
|
+
constructor() {
|
|
274
|
+
super(), this.allSelected = !1, this.computeSortedRows = k(
|
|
275
|
+
(e, t) => {
|
|
276
|
+
if (!t || t.direction === "none")
|
|
277
|
+
return e;
|
|
278
|
+
const { column: o, direction: l } = t;
|
|
279
|
+
return [...e].sort((r, d) => {
|
|
280
|
+
const a = r[o], p = d[o];
|
|
281
|
+
if (a === p) return 0;
|
|
282
|
+
if (a == null) return 1;
|
|
283
|
+
if (p == null) return -1;
|
|
284
|
+
let b = 0;
|
|
285
|
+
return typeof a == "string" && typeof p == "string" ? b = a.localeCompare(p) : typeof a == "number" && typeof p == "number" ? b = a - p : b = String(a).localeCompare(String(p)), l === "desc" ? -b : b;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
), this.columns = [], this.rows = [], this.variant = "default", this.size = "md", this.selectable = !1, this.multiSelect = !1, this.selectedRows = [], this.sortState = null, this.stickyHeader = !1, this.hoverable = !0, this.loading = !1;
|
|
289
|
+
}
|
|
290
|
+
shouldUpdate(e) {
|
|
291
|
+
for (const t of e.keys())
|
|
292
|
+
if (!s.VISUAL_ONLY_PROPS.has(t))
|
|
293
|
+
return !0;
|
|
294
|
+
return !0;
|
|
295
|
+
}
|
|
296
|
+
updated(e) {
|
|
297
|
+
(e.has("selectedRows") || e.has("rows")) && (this.allSelected = this.rows.length > 0 && this.selectedRows.length === this.rows.length);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Get sorted rows based on current sort state (memoized).
|
|
301
|
+
*/
|
|
302
|
+
get sortedRows() {
|
|
303
|
+
return this.computeSortedRows(this.rows, this.sortState);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Handles click on sortable column header.
|
|
307
|
+
* Cycles through sort directions: asc → desc → none.
|
|
308
|
+
* Manages focus on header after sort completes.
|
|
309
|
+
*/
|
|
310
|
+
handleHeaderClick(e, t) {
|
|
311
|
+
if (!e.sortable) return;
|
|
312
|
+
let o = "asc";
|
|
313
|
+
this.sortState?.column === e.key && (this.sortState.direction === "asc" ? o = "desc" : this.sortState.direction === "desc" && (o = "none")), this.sortState = { column: e.key, direction: o }, this.dispatchEvent(
|
|
314
|
+
new CustomEvent("bp-sort", {
|
|
315
|
+
detail: { column: e.key, direction: o },
|
|
316
|
+
bubbles: !0,
|
|
317
|
+
composed: !0
|
|
318
|
+
})
|
|
319
|
+
), this.updateComplete.then(() => {
|
|
320
|
+
t.target?.focus();
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Handles click events on table rows.
|
|
325
|
+
* Dispatches bp-row-click event and toggles selection if selectable.
|
|
326
|
+
*/
|
|
327
|
+
handleRowClick(e, t) {
|
|
328
|
+
this.dispatchEvent(
|
|
329
|
+
new CustomEvent("bp-row-click", {
|
|
330
|
+
detail: { row: e, originalEvent: t },
|
|
331
|
+
bubbles: !0,
|
|
332
|
+
composed: !0
|
|
333
|
+
})
|
|
334
|
+
), this.selectable && this.toggleRowSelection(e);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Handles keyboard events on table rows.
|
|
338
|
+
* Triggers selection on Enter or Space key press when selectable.
|
|
339
|
+
*/
|
|
340
|
+
handleRowKeyDown(e, t) {
|
|
341
|
+
this.selectable && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.toggleRowSelection(e));
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Toggles selection state for a row.
|
|
345
|
+
* Respects multiSelect setting for single vs multiple selection.
|
|
346
|
+
*/
|
|
347
|
+
toggleRowSelection(e) {
|
|
348
|
+
const t = e.id, o = this.selectedRows.includes(t);
|
|
349
|
+
let l;
|
|
350
|
+
this.multiSelect ? l = o ? this.selectedRows.filter((r) => r !== t) : [...this.selectedRows, t] : l = o ? [] : [t], this.selectedRows = l, this.dispatchEvent(
|
|
351
|
+
new CustomEvent("bp-select", {
|
|
352
|
+
detail: { selectedRows: l, row: e, selected: !o },
|
|
353
|
+
bubbles: !0,
|
|
354
|
+
composed: !0
|
|
355
|
+
})
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Handles select all checkbox toggle.
|
|
360
|
+
* Selects or deselects all rows based on current state.
|
|
361
|
+
*/
|
|
362
|
+
handleSelectAll() {
|
|
363
|
+
this.allSelected ? this.selectedRows = [] : this.selectedRows = this.rows.map((e) => e.id), this.dispatchEvent(
|
|
364
|
+
new CustomEvent("bp-select", {
|
|
365
|
+
detail: {
|
|
366
|
+
selectedRows: this.selectedRows,
|
|
367
|
+
selectAll: !this.allSelected
|
|
368
|
+
},
|
|
369
|
+
bubbles: !0,
|
|
370
|
+
composed: !0
|
|
371
|
+
})
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Handles checkbox click events.
|
|
376
|
+
* Stops propagation only on the checkbox itself to prevent row click.
|
|
377
|
+
*/
|
|
378
|
+
handleCheckboxClick(e, t) {
|
|
379
|
+
e.target instanceof HTMLInputElement && e.stopPropagation(), t ? this.toggleRowSelection(t) : this.handleSelectAll();
|
|
380
|
+
}
|
|
381
|
+
/** Select all rows */
|
|
382
|
+
selectAll() {
|
|
383
|
+
this.selectedRows = this.rows.map((e) => e.id), this.dispatchEvent(
|
|
384
|
+
new CustomEvent("bp-select", {
|
|
385
|
+
detail: { selectedRows: this.selectedRows, selectAll: !0 },
|
|
386
|
+
bubbles: !0,
|
|
387
|
+
composed: !0
|
|
388
|
+
})
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
/** Deselect all rows */
|
|
392
|
+
deselectAll() {
|
|
393
|
+
this.selectedRows = [], this.dispatchEvent(
|
|
394
|
+
new CustomEvent("bp-select", {
|
|
395
|
+
detail: { selectedRows: [], selectAll: !1 },
|
|
396
|
+
bubbles: !0,
|
|
397
|
+
composed: !0
|
|
398
|
+
})
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
/** Clear sort state */
|
|
402
|
+
clearSort() {
|
|
403
|
+
this.sortState = null;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Renders the sort icon for sortable columns.
|
|
407
|
+
* Shows chevron-up for ascending, chevron-down for descending, unsorted icon otherwise.
|
|
408
|
+
*/
|
|
409
|
+
renderSortIcon(e) {
|
|
410
|
+
if (!e.sortable) return h;
|
|
411
|
+
const t = this.sortState?.column === e.key, o = t ? this.sortState?.direction : "none", l = o === "asc" ? "chevron-up" : o === "desc" ? "chevron-down" : "chevron-up";
|
|
412
|
+
return c`
|
|
413
|
+
<span class=${u({
|
|
414
|
+
"sort-icon": !0,
|
|
415
|
+
"sort-icon--active": t && o !== "none",
|
|
416
|
+
"sort-icon--inactive": o === "none"
|
|
417
|
+
})} part="sort-icon" aria-hidden="true">
|
|
418
|
+
<bp-icon name=${l} size="sm"></bp-icon>
|
|
419
|
+
</span>
|
|
420
|
+
`;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Renders the table header with column labels and sort icons.
|
|
424
|
+
*/
|
|
425
|
+
renderHeader() {
|
|
426
|
+
return c`
|
|
427
|
+
<thead part="thead">
|
|
428
|
+
<tr class="header-row" part="header-row">
|
|
429
|
+
${this.selectable && this.multiSelect ? c`
|
|
430
|
+
<th class="cell cell--checkbox" part="header-cell">
|
|
431
|
+
<input
|
|
432
|
+
type="checkbox"
|
|
433
|
+
part="checkbox"
|
|
434
|
+
.checked=${this.allSelected}
|
|
435
|
+
.indeterminate=${this.selectedRows.length > 0 && !this.allSelected}
|
|
436
|
+
@click=${(e) => this.handleCheckboxClick(e)}
|
|
437
|
+
aria-label="Select all rows"
|
|
438
|
+
/>
|
|
439
|
+
</th>
|
|
440
|
+
` : this.selectable ? c`<th class="cell cell--checkbox" part="header-cell"></th>` : h}
|
|
441
|
+
${f(
|
|
442
|
+
this.columns,
|
|
443
|
+
(e) => e.key,
|
|
444
|
+
(e) => c`
|
|
445
|
+
<th
|
|
446
|
+
class="cell header-cell ${e.sortable ? "header-cell--sortable" : ""}"
|
|
447
|
+
part="header-cell"
|
|
448
|
+
style=${e.width ? `width: ${e.width}` : ""}
|
|
449
|
+
@click=${(t) => this.handleHeaderClick(e, t)}
|
|
450
|
+
tabindex=${e.sortable ? 0 : -1}
|
|
451
|
+
@keydown=${(t) => {
|
|
452
|
+
e.sortable && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.handleHeaderClick(e, t));
|
|
453
|
+
}}
|
|
454
|
+
aria-sort=${this.sortState?.column === e.key ? this.sortState.direction === "asc" ? "ascending" : this.sortState.direction === "desc" ? "descending" : "none" : "none"}
|
|
455
|
+
>
|
|
456
|
+
<span
|
|
457
|
+
class="header-cell__content"
|
|
458
|
+
style="justify-content: ${e.align === "center" ? "center" : e.align === "right" ? "flex-end" : "flex-start"}"
|
|
459
|
+
>
|
|
460
|
+
<span class="header-cell__label">${e.label}</span>
|
|
461
|
+
${this.renderSortIcon(e)}
|
|
462
|
+
</span>
|
|
463
|
+
</th>
|
|
464
|
+
`
|
|
465
|
+
)}
|
|
466
|
+
</tr>
|
|
467
|
+
</thead>
|
|
468
|
+
`;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Renders the table body with rows and cells.
|
|
472
|
+
* Handles loading and empty states.
|
|
473
|
+
*/
|
|
474
|
+
renderBody() {
|
|
475
|
+
const e = this.sortedRows;
|
|
476
|
+
return this.loading ? c`
|
|
477
|
+
<tbody part="tbody">
|
|
478
|
+
<tr>
|
|
479
|
+
<td
|
|
480
|
+
colspan=${this.columns.length + (this.selectable ? 1 : 0)}
|
|
481
|
+
class="empty-state"
|
|
482
|
+
part="empty-state"
|
|
483
|
+
>
|
|
484
|
+
<slot name="loading">
|
|
485
|
+
<div class="state-content">Loading...</div>
|
|
486
|
+
</slot>
|
|
487
|
+
</td>
|
|
488
|
+
</tr>
|
|
489
|
+
</tbody>
|
|
490
|
+
` : e.length === 0 ? c`
|
|
491
|
+
<tbody part="tbody">
|
|
492
|
+
<tr>
|
|
493
|
+
<td
|
|
494
|
+
colspan=${this.columns.length + (this.selectable ? 1 : 0)}
|
|
495
|
+
class="empty-state"
|
|
496
|
+
part="empty-state"
|
|
497
|
+
>
|
|
498
|
+
<slot name="empty">
|
|
499
|
+
<div class="state-content">No data available</div>
|
|
500
|
+
</slot>
|
|
501
|
+
</td>
|
|
502
|
+
</tr>
|
|
503
|
+
</tbody>
|
|
504
|
+
` : c`
|
|
505
|
+
<tbody part="tbody">
|
|
506
|
+
${f(
|
|
507
|
+
e,
|
|
508
|
+
(t) => t.id,
|
|
509
|
+
(t) => {
|
|
510
|
+
const o = this.selectedRows.includes(t.id), l = {
|
|
511
|
+
row: !0,
|
|
512
|
+
"row--selected": o,
|
|
513
|
+
"row--hoverable": this.hoverable
|
|
514
|
+
};
|
|
515
|
+
return c`
|
|
516
|
+
<tr
|
|
517
|
+
class=${u(l)}
|
|
518
|
+
part="row"
|
|
519
|
+
@click=${(r) => this.handleRowClick(t, r)}
|
|
520
|
+
@keydown=${(r) => this.handleRowKeyDown(t, r)}
|
|
521
|
+
tabindex=${this.selectable ? 0 : -1}
|
|
522
|
+
aria-selected=${w(
|
|
523
|
+
this.selectable ? o ? "true" : "false" : void 0
|
|
524
|
+
)}
|
|
525
|
+
>
|
|
526
|
+
${this.selectable ? c`
|
|
527
|
+
<td class="cell cell--checkbox" part="cell">
|
|
528
|
+
<input
|
|
529
|
+
type="checkbox"
|
|
530
|
+
part="checkbox"
|
|
531
|
+
.checked=${o}
|
|
532
|
+
@click=${(r) => this.handleCheckboxClick(r, t)}
|
|
533
|
+
aria-label="Select row"
|
|
534
|
+
/>
|
|
535
|
+
</td>
|
|
536
|
+
` : h}
|
|
537
|
+
${f(
|
|
538
|
+
this.columns,
|
|
539
|
+
(r) => r.key,
|
|
540
|
+
(r) => {
|
|
541
|
+
const d = t[r.key], a = r.render ? r.render(d, t) : d;
|
|
542
|
+
return c`
|
|
543
|
+
<td
|
|
544
|
+
class="cell"
|
|
545
|
+
part="cell"
|
|
546
|
+
style="text-align: ${r.align || "left"}"
|
|
547
|
+
>
|
|
548
|
+
${a}
|
|
549
|
+
</td>
|
|
550
|
+
`;
|
|
551
|
+
}
|
|
552
|
+
)}
|
|
553
|
+
</tr>
|
|
554
|
+
`;
|
|
555
|
+
}
|
|
556
|
+
)}
|
|
557
|
+
</tbody>
|
|
558
|
+
`;
|
|
559
|
+
}
|
|
560
|
+
render() {
|
|
561
|
+
const e = {
|
|
562
|
+
table: !0,
|
|
563
|
+
[`table--${this.variant}`]: !0,
|
|
564
|
+
[`table--${this.size}`]: !0,
|
|
565
|
+
"table--sticky-header": this.stickyHeader,
|
|
566
|
+
"table--selectable": this.selectable,
|
|
567
|
+
"table--loading": this.loading
|
|
568
|
+
};
|
|
569
|
+
return c`
|
|
570
|
+
<div class="table-wrapper">
|
|
571
|
+
<table
|
|
572
|
+
class=${u(e)}
|
|
573
|
+
part="table"
|
|
574
|
+
role="grid"
|
|
575
|
+
aria-busy=${this.loading}
|
|
576
|
+
>
|
|
577
|
+
${this.renderHeader()} ${this.renderBody()}
|
|
578
|
+
</table>
|
|
579
|
+
</div>
|
|
580
|
+
`;
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
s.VISUAL_ONLY_PROPS = /* @__PURE__ */ new Set([
|
|
584
|
+
"hoverable",
|
|
585
|
+
"stickyHeader"
|
|
586
|
+
]);
|
|
587
|
+
s.styles = [x];
|
|
588
|
+
i([
|
|
589
|
+
n({ type: Array })
|
|
590
|
+
], s.prototype, "columns", 2);
|
|
591
|
+
i([
|
|
592
|
+
n({ type: Array })
|
|
593
|
+
], s.prototype, "rows", 2);
|
|
594
|
+
i([
|
|
595
|
+
n({
|
|
596
|
+
type: String,
|
|
597
|
+
reflect: !0,
|
|
598
|
+
converter: {
|
|
599
|
+
fromAttribute: (e) => e && ["default", "striped", "bordered"].includes(e) ? e : "default"
|
|
600
|
+
}
|
|
601
|
+
})
|
|
602
|
+
], s.prototype, "variant", 2);
|
|
603
|
+
i([
|
|
604
|
+
n({
|
|
605
|
+
type: String,
|
|
606
|
+
reflect: !0,
|
|
607
|
+
converter: {
|
|
608
|
+
fromAttribute: (e) => e && ["sm", "md", "lg"].includes(e) ? e : "md"
|
|
609
|
+
}
|
|
610
|
+
})
|
|
611
|
+
], s.prototype, "size", 2);
|
|
612
|
+
i([
|
|
613
|
+
n({ type: Boolean, reflect: !0 })
|
|
614
|
+
], s.prototype, "selectable", 2);
|
|
615
|
+
i([
|
|
616
|
+
n({ type: Boolean, reflect: !0 })
|
|
617
|
+
], s.prototype, "multiSelect", 2);
|
|
618
|
+
i([
|
|
619
|
+
n({ type: Array })
|
|
620
|
+
], s.prototype, "selectedRows", 2);
|
|
621
|
+
i([
|
|
622
|
+
n({ type: Object })
|
|
623
|
+
], s.prototype, "sortState", 2);
|
|
624
|
+
i([
|
|
625
|
+
n({ type: Boolean, reflect: !0, attribute: "sticky-header" })
|
|
626
|
+
], s.prototype, "stickyHeader", 2);
|
|
627
|
+
i([
|
|
628
|
+
n({ converter: S, reflect: !0 })
|
|
629
|
+
], s.prototype, "hoverable", 2);
|
|
630
|
+
i([
|
|
631
|
+
n({ type: Boolean, reflect: !0 })
|
|
632
|
+
], s.prototype, "loading", 2);
|
|
633
|
+
i([
|
|
634
|
+
g()
|
|
635
|
+
], s.prototype, "allSelected", 2);
|
|
636
|
+
s = i([
|
|
637
|
+
m("bp-table")
|
|
638
|
+
], s);
|
|
639
|
+
export {
|
|
640
|
+
s as BpTable
|
|
641
|
+
};
|
|
642
|
+
//# sourceMappingURL=table.js.map
|