@redvars/peacock 3.3.0 → 3.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.
Files changed (105) hide show
  1. package/dist/assets/components.css +1 -1
  2. package/dist/assets/components.css.map +1 -1
  3. package/dist/assets/styles.css +1 -1
  4. package/dist/assets/styles.css.map +1 -1
  5. package/dist/button-group-DA7xoziD.js +292 -0
  6. package/dist/button-group-DA7xoziD.js.map +1 -0
  7. package/dist/button-group.js +6 -107
  8. package/dist/button-group.js.map +1 -1
  9. package/dist/{button-BGFJfbT2.js → button-trIfcqC7.js} +2 -3
  10. package/dist/{button-BGFJfbT2.js.map → button-trIfcqC7.js.map} +1 -1
  11. package/dist/button.js +2 -3
  12. package/dist/button.js.map +1 -1
  13. package/dist/{class-map-DpeNtqCn.js → class-map-hJdvjl-W.js} +9 -3
  14. package/dist/class-map-hJdvjl-W.js.map +1 -0
  15. package/dist/code-editor.js +5 -5
  16. package/dist/code-editor.js.map +1 -1
  17. package/dist/code-highlighter.js +5 -23
  18. package/dist/code-highlighter.js.map +1 -1
  19. package/dist/custom-elements-jsdocs.json +4706 -2471
  20. package/dist/custom-elements.json +3444 -1007
  21. package/dist/index.js +4 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/peacock-loader.js +26 -496
  24. package/dist/peacock-loader.js.map +1 -1
  25. package/dist/src/accordion/accordion-item.d.ts +1 -0
  26. package/dist/src/breadcrumb/breadcrumb/breadcrumb.d.ts +2 -0
  27. package/dist/src/breadcrumb/breadcrumb-item/breadcrumb-item.d.ts +1 -0
  28. package/dist/src/button/button-group/button-group.d.ts +4 -0
  29. package/dist/src/code-editor/code-editor.d.ts +4 -3
  30. package/dist/src/code-highlighter/code-highlighter.d.ts +4 -7
  31. package/dist/src/index.d.ts +4 -0
  32. package/dist/src/menu/index.d.ts +3 -0
  33. package/dist/src/menu/menu/MenuSurfaceController.d.ts +18 -0
  34. package/dist/src/menu/menu/menu.d.ts +54 -12
  35. package/dist/src/menu/menu-item/menu-item.d.ts +12 -5
  36. package/dist/src/menu/sub-menu/sub-menu.d.ts +36 -0
  37. package/dist/src/pagination/index.d.ts +1 -0
  38. package/dist/src/pagination/pagination.d.ts +38 -0
  39. package/dist/src/popover/PopoverController.d.ts +4 -1
  40. package/dist/src/table/index.d.ts +1 -0
  41. package/dist/src/table/table.d.ts +110 -0
  42. package/dist/src/tabs/tab-group.d.ts +4 -0
  43. package/dist/src/tabs/tab-panel.d.ts +1 -0
  44. package/dist/src/tabs/tab.d.ts +1 -0
  45. package/dist/src/tabs/tabs.d.ts +2 -0
  46. package/dist/src/tooltip/tooltip.d.ts +1 -3
  47. package/dist/src/tree-view/index.d.ts +2 -0
  48. package/dist/src/tree-view/tree-node.d.ts +69 -0
  49. package/dist/src/tree-view/tree-view.d.ts +40 -0
  50. package/dist/src/tree-view/wc-tree-view.d.ts +6 -0
  51. package/dist/test/icon.test.d.ts +1 -1
  52. package/dist/test/menu.test.d.ts +1 -0
  53. package/dist/test/sub-menu.test.d.ts +1 -0
  54. package/dist/test/tree-view.test.d.ts +1 -0
  55. package/dist/{slider-Dk9CFWTG.js → tree-view-CLolVlU0.js} +3317 -1180
  56. package/dist/tree-view-CLolVlU0.js.map +1 -0
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +1 -1
  59. package/readme.md +40 -40
  60. package/src/accordion/accordion-item.ts +2 -1
  61. package/src/breadcrumb/breadcrumb/breadcrumb.ts +3 -0
  62. package/src/breadcrumb/breadcrumb-item/breadcrumb-item.ts +1 -0
  63. package/src/button/button-group/button-group.ts +6 -0
  64. package/src/code-editor/code-editor.ts +4 -3
  65. package/src/code-highlighter/code-highlighter.ts +4 -22
  66. package/src/divider/divider.scss +2 -2
  67. package/src/empty-state/empty-state.scss +1 -1
  68. package/src/empty-state/empty-state.ts +1 -1
  69. package/src/index.ts +6 -2
  70. package/src/menu/index.ts +3 -0
  71. package/src/menu/menu/MenuSurfaceController.ts +61 -0
  72. package/src/menu/{menu-list/menu-list.scss → menu/menu.scss} +19 -4
  73. package/src/menu/menu/menu.ts +389 -81
  74. package/src/menu/menu-item/menu-item.ts +115 -36
  75. package/src/menu/sub-menu/sub-menu.scss +7 -0
  76. package/src/menu/sub-menu/sub-menu.ts +243 -0
  77. package/src/pagination/index.ts +1 -0
  78. package/src/pagination/pagination.scss +59 -0
  79. package/src/pagination/pagination.ts +135 -0
  80. package/src/peacock-loader.ts +25 -11
  81. package/src/popover/PopoverController.ts +13 -7
  82. package/src/table/index.ts +1 -0
  83. package/src/table/table.scss +174 -0
  84. package/src/table/table.ts +475 -0
  85. package/src/tabs/tab-group.ts +12 -6
  86. package/src/tabs/tab-panel.ts +1 -0
  87. package/src/tabs/tab.ts +1 -0
  88. package/src/tabs/tabs.scss +6 -5
  89. package/src/tabs/tabs.ts +5 -3
  90. package/src/text/text.css-component.scss +6 -3
  91. package/src/tooltip/tooltip.scss +16 -13
  92. package/src/tooltip/tooltip.ts +7 -9
  93. package/src/tree-view/demo/index.html +57 -0
  94. package/src/tree-view/index.ts +2 -0
  95. package/src/tree-view/tree-node.scss +101 -0
  96. package/src/tree-view/tree-node.ts +268 -0
  97. package/src/tree-view/tree-view.scss +12 -0
  98. package/src/tree-view/tree-view.ts +182 -0
  99. package/src/tree-view/wc-tree-view.ts +9 -0
  100. package/dist/class-map-DpeNtqCn.js.map +0 -1
  101. package/dist/slider-Dk9CFWTG.js.map +0 -1
  102. package/dist/src/menu/menu-list/menu-list.d.ts +0 -22
  103. package/dist/state-8v48Exzh.js +0 -10
  104. package/dist/state-8v48Exzh.js.map +0 -1
  105. package/src/menu/menu-list/menu-list.ts +0 -48
@@ -0,0 +1,475 @@
1
+ import { html, LitElement, nothing } from 'lit';
2
+ import { property, state } from 'lit/decorators.js';
3
+ import { classMap } from 'lit/directives/class-map.js';
4
+ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
5
+ import { throttle } from '../utils.js';
6
+ import styles from './table.scss';
7
+
8
+ const DEFAULT_CELL_WIDTH = 16; // in rem
9
+
10
+ export interface TableColumn {
11
+ name: string;
12
+ label: string;
13
+ width?: number;
14
+ fixed?: boolean;
15
+ template?: (row: any, column: TableColumn) => string;
16
+ }
17
+
18
+ /**
19
+ * @label Table
20
+ * @tag wc-table
21
+ * @rawTag table
22
+ * @summary A configurable component for displaying tabular data.
23
+ * @overview
24
+ * <p>The table component displays rows of data with support for sorting, pagination, row selection, and fixed columns.</p>
25
+ *
26
+ * @fires {CustomEvent} cell-click - Dispatched when a table cell is clicked.
27
+ * @fires {CustomEvent} selection-change - Dispatched when the row selection changes.
28
+ * @fires {CustomEvent} sort - Dispatched when the table is sorted.
29
+ * @fires {CustomEvent} page - Dispatched when the page or page size changes.
30
+ *
31
+ * @example
32
+ * ```html
33
+ * <wc-table columns="[{'name': 'name','label': 'Name','width': 16},{'name': 'age','label': 'Age','width': 7}]" data="[{'name': 'John','age': 30},{'name': 'Jane','age': 25}]"></wc-table>
34
+ * ```
35
+ * @tags display, data
36
+ */
37
+ export class Table extends LitElement {
38
+ static styles = [styles];
39
+
40
+ /**
41
+ * Grid columns configuration.
42
+ * Each column can have: name, label, width (px), fixed (boolean), template (function).
43
+ */
44
+ @property({ type: Array })
45
+ columns: TableColumn[] = [];
46
+
47
+ /**
48
+ * Grid data to display on table.
49
+ */
50
+ @property({ type: Array })
51
+ data: any[] = [];
52
+
53
+ /**
54
+ * Row selection type. Set to `"checkbox"` to enable checkbox selection.
55
+ */
56
+ @property({ type: String, attribute: 'selection-type' })
57
+ selectionType: 'checkbox' | undefined;
58
+
59
+ /**
60
+ * Array of selected row key values.
61
+ */
62
+ @property({ type: Array, attribute: 'selected-row-keys' })
63
+ selectedRowKeys: string[] = [];
64
+
65
+ /**
66
+ * The field name used as the unique key for each row. Defaults to `"id"`.
67
+ */
68
+ @property({ type: String, attribute: 'key-field' })
69
+ keyField: string = 'id';
70
+
71
+ /**
72
+ * If true, sorting and pagination are managed externally (controlled mode).
73
+ */
74
+ @property({ type: Boolean })
75
+ managed: boolean = false;
76
+
77
+ /**
78
+ * If true, columns are sortable. Defaults to `true`.
79
+ */
80
+ @property({ type: Boolean })
81
+ sortable: boolean = true;
82
+
83
+ /**
84
+ * The field name currently used for sorting.
85
+ */
86
+ @property({ type: String, attribute: 'sort-by' })
87
+ sortBy: string = '';
88
+
89
+ /**
90
+ * The current sort order. Possible values are `"asc"` and `"desc"`. Defaults to `"asc"`.
91
+ */
92
+ @property({ type: String, attribute: 'sort-order' })
93
+ sortOrder: 'asc' | 'desc' = 'asc';
94
+
95
+ /**
96
+ * If true, pagination is enabled. Defaults to `true`.
97
+ */
98
+ @property({ type: Boolean })
99
+ paginate: boolean = false;
100
+
101
+ /**
102
+ * The current page number (1-based). Defaults to `1`.
103
+ */
104
+ @property({ type: Number })
105
+ page: number = 1;
106
+
107
+ /**
108
+ * The number of rows per page. Defaults to `10`.
109
+ */
110
+ @property({ type: Number, attribute: 'page-size' })
111
+ pageSize: number = 10;
112
+
113
+ /**
114
+ * Total number of items (used in managed/controlled mode).
115
+ */
116
+ @property({ type: Number, attribute: 'total-items' })
117
+ totalItems: number | undefined;
118
+
119
+ /**
120
+ * Headline text shown when the table has no data.
121
+ */
122
+ @property({ type: String, attribute: 'empty-state-headline' })
123
+ emptyStateHeadline: string = 'No items';
124
+
125
+ /**
126
+ * Description text shown when the table has no data.
127
+ */
128
+ @property({ type: String, attribute: 'empty-state-description' })
129
+ emptyStateDescription: string = 'There are no items to display';
130
+
131
+ @state()
132
+ private hoveredCell: { row?: any; column?: any } = {};
133
+
134
+ @state()
135
+ private isSelectAll: boolean = false;
136
+
137
+ @state()
138
+ private isSelectAllIntermediate: boolean = false;
139
+
140
+ @state()
141
+ private isHorizontallyScrolled: boolean = false;
142
+
143
+ private onCellMouseOverThrottled = throttle((row: any, column: any) => {
144
+ this.hoveredCell = { row, column };
145
+ }, 30);
146
+
147
+ private onSelectAllClick = () => {
148
+ this.isSelectAll = !this.isSelectAll;
149
+ let selectedRowKeys: string[] = [];
150
+ if (this.isSelectAll) {
151
+ selectedRowKeys = this.data
152
+ .slice((this.page - 1) * this.pageSize, this.page * this.pageSize)
153
+ .map(row => row[this.keyField]);
154
+ }
155
+ this.onSelectChange(selectedRowKeys);
156
+ };
157
+
158
+ private onRowSelectClick = (row: any) => {
159
+ let selectedRowKeys = [...this.selectedRowKeys];
160
+ if (selectedRowKeys.includes(row[this.keyField])) {
161
+ this.isSelectAll = false;
162
+ selectedRowKeys = selectedRowKeys.filter(
163
+ rowId => rowId !== row[this.keyField],
164
+ );
165
+ } else {
166
+ selectedRowKeys.push(row[this.keyField]);
167
+ }
168
+ this.onSelectChange(selectedRowKeys);
169
+ };
170
+
171
+ private onSelectChange(selectedRowKeys: string[]) {
172
+ this.selectedRowKeys = selectedRowKeys;
173
+ this.dispatchEvent(
174
+ new CustomEvent('selection-change', {
175
+ detail: {
176
+ value: this.selectedRowKeys,
177
+ isSelectAll: this.isSelectAll,
178
+ },
179
+ bubbles: true,
180
+ composed: true,
181
+ }),
182
+ );
183
+ }
184
+
185
+ private onCellClick(row: any, col: TableColumn, evt: MouseEvent) {
186
+ this.dispatchEvent(
187
+ new CustomEvent('cell-click', {
188
+ detail: {
189
+ record: row,
190
+ column: col,
191
+ altKey: evt.altKey,
192
+ ctrlKey: evt.ctrlKey,
193
+ metaKey: evt.metaKey,
194
+ shiftKey: evt.shiftKey,
195
+ },
196
+ bubbles: true,
197
+ composed: true,
198
+ }),
199
+ );
200
+ }
201
+
202
+ private onScrollContainer = (event: Event) => {
203
+ const target = event.target as HTMLElement;
204
+ this.isHorizontallyScrolled = !!target.scrollLeft;
205
+ };
206
+
207
+ private get totalColumnsWidth(): number {
208
+ let total = 0;
209
+ if (this.selectionType === 'checkbox') {
210
+ total += 3; // approximate checkbox column width in rem
211
+ }
212
+ this.columns.forEach(col => {
213
+ total += col.width ?? DEFAULT_CELL_WIDTH;
214
+ });
215
+ return total;
216
+ }
217
+
218
+ private getTotalItems(): number {
219
+ if (this.paginate && !this.managed) return this.data.length;
220
+ return this.totalItems ?? 0;
221
+ }
222
+
223
+ private getSortIcon(col: TableColumn): string {
224
+ if (this.sortBy === col.name) {
225
+ return this.sortOrder === 'asc' ? 'keyboard_arrow_up' : 'keyboard_arrow_down';
226
+ }
227
+ return '';
228
+ }
229
+
230
+ private onSortClick(col: TableColumn) {
231
+ if (this.sortBy === col.name) {
232
+ if (this.sortOrder === 'asc') {
233
+ this.sortOrder = 'desc';
234
+ } else {
235
+ this.sortBy = '';
236
+ }
237
+ } else {
238
+ this.sortBy = col.name;
239
+ this.sortOrder = 'asc';
240
+ }
241
+ this.dispatchEvent(
242
+ new CustomEvent('sort', {
243
+ detail: { sortBy: this.sortBy, sortOrder: this.sortOrder },
244
+ bubbles: true,
245
+ composed: true,
246
+ }),
247
+ );
248
+ }
249
+
250
+ private renderHeader() {
251
+ const fixedCols: any[] = [];
252
+ const scrollCols: any[] = [];
253
+
254
+ if (this.selectionType === 'checkbox') {
255
+ fixedCols.push(html`
256
+ <div class="col col-checkbox center">
257
+ <div class="col-content">
258
+ <wc-checkbox
259
+ class="checkbox"
260
+ .value=${this.isSelectAll}
261
+ .indeterminate=${this.isSelectAllIntermediate}
262
+ @change=${this.onSelectAllClick}
263
+ ></wc-checkbox>
264
+ </div>
265
+ </div>
266
+ `);
267
+ }
268
+
269
+ this.columns.forEach(col => {
270
+ const colWidth = col.width
271
+ ? parseInt(String(col.width), 10)
272
+ : DEFAULT_CELL_WIDTH;
273
+ const colEl = html`
274
+ <div
275
+ class=${classMap({ col: true, sort: this.sortBy === col.name })}
276
+ style="width: ${colWidth}rem"
277
+ >
278
+ <div class="col-content">
279
+ <div class="col-text">${col.label}</div>
280
+ <div class="col-actions">
281
+ ${this.sortable
282
+ ? html`
283
+ <wc-button
284
+ class="col-action"
285
+ color="secondary"
286
+ variant="text"
287
+ @click=${() => this.onSortClick(col)}
288
+ >
289
+ <wc-icon
290
+ slot="icon"
291
+ name=${this.getSortIcon(col)}
292
+ ></wc-icon>
293
+ </wc-button>
294
+ `
295
+ : nothing}
296
+ </div>
297
+ </div>
298
+ </div>
299
+ `;
300
+ if (col.fixed) {
301
+ fixedCols.push(colEl);
302
+ } else {
303
+ scrollCols.push(colEl);
304
+ }
305
+ });
306
+
307
+ return html`
308
+ <div class="header">
309
+ <div class="row" style="min-width: ${this.totalColumnsWidth}rem">
310
+ <div class="fixed-columns columns-container">${fixedCols}</div>
311
+ <div class="scrollable-columns columns-container">${scrollCols}</div>
312
+ </div>
313
+ </div>
314
+ `;
315
+ }
316
+
317
+ private renderBody() {
318
+ let data = [...this.data];
319
+
320
+ if (!this.managed) {
321
+ if (this.sortable && this.sortBy) {
322
+ data = data.sort((a, b) => {
323
+ if (a[this.sortBy] < b[this.sortBy])
324
+ return this.sortOrder === 'asc' ? -1 : 1;
325
+ if (a[this.sortBy] > b[this.sortBy])
326
+ return this.sortOrder === 'asc' ? 1 : -1;
327
+ return 0;
328
+ });
329
+ }
330
+ if (this.paginate) {
331
+ data = data.slice(
332
+ (this.page - 1) * this.pageSize,
333
+ this.page * this.pageSize,
334
+ );
335
+ }
336
+ }
337
+
338
+ const rows = data.map(row => {
339
+ const fixedCols: any[] = [];
340
+ const scrollCols: any[] = [];
341
+
342
+ if (this.selectionType === 'checkbox') {
343
+ fixedCols.push(html`
344
+ <div class="col center col-checkbox">
345
+ <div class="col-content">
346
+ <wc-checkbox
347
+ class="checkbox"
348
+ .value=${this.selectedRowKeys.includes(row[this.keyField])}
349
+ @change=${() => this.onRowSelectClick(row)}
350
+ ></wc-checkbox>
351
+ </div>
352
+ </div>
353
+ `);
354
+ }
355
+
356
+ this.columns.forEach(column => {
357
+ const colWidth = column.width
358
+ ? parseInt(String(column.width), 10)
359
+ : DEFAULT_CELL_WIDTH;
360
+ const colEl = html`
361
+ <div
362
+ tabindex="0"
363
+ class=${classMap({
364
+ col: true,
365
+ 'col-hover':
366
+ this.hoveredCell.row === row &&
367
+ this.hoveredCell.column === column,
368
+ })}
369
+ style="width: ${colWidth}rem"
370
+ @mouseover=${() => this.onCellMouseOverThrottled(row, column)}
371
+ @focus=${() => this.onCellMouseOverThrottled(row, column)}
372
+ @keydown=${(event: KeyboardEvent) => {
373
+ if ((event.ctrlKey || event.metaKey) && event.key === 'c') {
374
+ const elem = event.target as HTMLElement;
375
+ window.navigator.clipboard
376
+ .writeText(elem.innerText)
377
+ .catch(() => {});
378
+ }
379
+ }}
380
+ @click=${(evt: MouseEvent) => {
381
+ const selection = window.getSelection();
382
+ if (selection?.type !== 'Range') {
383
+ this.onCellClick(row, column, evt);
384
+ }
385
+ }}
386
+ >
387
+ <div class="col-content">
388
+ ${column.template
389
+ ? html`<div class="col-template">
390
+ ${unsafeHTML(column.template(row, column))}
391
+ </div>`
392
+ : html`<div class="col-text" title=${row?.[column.name] ?? ''}>
393
+ ${row?.[column.name]}
394
+ </div>`}
395
+ </div>
396
+ </div>
397
+ `;
398
+ if (column.fixed) {
399
+ fixedCols.push(colEl);
400
+ } else {
401
+ scrollCols.push(colEl);
402
+ }
403
+ });
404
+
405
+ return html`
406
+ <div
407
+ class=${classMap({
408
+ row: true,
409
+ 'row-hover': this.hoveredCell.row === row,
410
+ })}
411
+ style="min-width: ${this.totalColumnsWidth}rem"
412
+ >
413
+ <div class="fixed-columns columns-container">${fixedCols}</div>
414
+ <div class="scrollable-columns columns-container">${scrollCols}</div>
415
+ </div>
416
+ `;
417
+ });
418
+
419
+ return html`<div class="body">${rows}</div>`;
420
+ }
421
+
422
+ private renderEmptyState() {
423
+ return html`
424
+ <div class="empty-table">
425
+ <wc-empty-state
426
+ class="empty-state content-center"
427
+ headline=${this.emptyStateHeadline}
428
+ description=${this.emptyStateDescription}
429
+ ></wc-empty-state>
430
+ </div>
431
+ `;
432
+ }
433
+
434
+ private renderPagination() {
435
+ if (!this.paginate) return nothing;
436
+
437
+ return html`
438
+ <wc-pagination
439
+ .page=${this.page}
440
+ .pageSize=${this.pageSize}
441
+ .totalItems=${this.getTotalItems()}
442
+ @page=${(e: CustomEvent) => {
443
+ this.page = e.detail.page;
444
+ this.pageSize = e.detail.pageSize;
445
+ this.dispatchEvent(
446
+ new CustomEvent('page', {
447
+ detail: { page: this.page, pageSize: this.pageSize },
448
+ bubbles: true,
449
+ composed: true,
450
+ }),
451
+ );
452
+ }}
453
+ ></wc-pagination>
454
+ `;
455
+ }
456
+
457
+ render() {
458
+ const tableClasses = {
459
+ table: true,
460
+ sortable: this.sortable,
461
+ paginate: this.paginate,
462
+ 'horizontal-scrolled': this.isHorizontallyScrolled,
463
+ };
464
+
465
+ return html`
466
+ <div class=${classMap(tableClasses)}>
467
+ <div class="table-scroll-container" @scroll=${this.onScrollContainer}>
468
+ ${this.renderHeader()}
469
+ ${this.data.length ? this.renderBody() : this.renderEmptyState()}
470
+ </div>
471
+ <div class="table-footer">${this.renderPagination()}</div>
472
+ </div>
473
+ `;
474
+ }
475
+ }
@@ -1,6 +1,8 @@
1
1
  import { html, LitElement } from 'lit';
2
2
  import { property } from 'lit/decorators.js';
3
3
  import styles from './tab-group.scss';
4
+ import { Tabs } from './tabs.js';
5
+ import { TabPanel } from './tab-panel.js';
4
6
 
5
7
  /**
6
8
  * @label Tab Group
@@ -29,6 +31,10 @@ import styles from './tab-group.scss';
29
31
  export class TabGroup extends LitElement {
30
32
  static styles = [styles];
31
33
 
34
+ static Tabs = Tabs;
35
+
36
+ static TabPanel = TabPanel;
37
+
32
38
  @property({ reflect: true })
33
39
  variant: 'line' | 'line-secondary' | 'contained' | 'pill' = 'line';
34
40
 
@@ -36,11 +42,11 @@ export class TabGroup extends LitElement {
36
42
 
37
43
  connectedCallback() {
38
44
  super.connectedCallback();
39
- this.addEventListener('base-tab-click', this.onTabClick as EventListener);
45
+ this.addEventListener('tab-click', this.onTabClick as EventListener);
40
46
  }
41
47
 
42
48
  disconnectedCallback() {
43
- this.removeEventListener('base-tab-click', this.onTabClick as EventListener);
49
+ this.removeEventListener('tab-click', this.onTabClick as EventListener);
44
50
  super.disconnectedCallback();
45
51
  }
46
52
 
@@ -91,11 +97,11 @@ export class TabGroup extends LitElement {
91
97
  }
92
98
 
93
99
  private getTabs(): NodeListOf<HTMLElement> {
94
- return this.querySelectorAll(':scope > tabs-list base-tab');
100
+ return this.querySelectorAll(':scope > tabs-list wc-tab');
95
101
  }
96
102
 
97
103
  private getTabPanels(): NodeListOf<HTMLElement> {
98
- return this.querySelectorAll(':scope > base-tab-panel');
104
+ return this.querySelectorAll(':scope > wc-tab-panel');
99
105
  }
100
106
 
101
107
  private getTabList(): HTMLElement | null {
@@ -103,7 +109,7 @@ export class TabGroup extends LitElement {
103
109
  }
104
110
 
105
111
  private tabsHaveTarget(): boolean {
106
- return !!this.querySelector(':scope > tabs-list base-tab[target]');
112
+ return !!this.querySelector(':scope > tabs-list wc-tab[target]');
107
113
  }
108
114
 
109
115
  private initializeTabs() {
@@ -123,7 +129,7 @@ export class TabGroup extends LitElement {
123
129
  }
124
130
  }
125
131
  } else {
126
- const selectedTab = this.querySelector(':scope > tabs-list base-tab[selected]') as HTMLElement;
132
+ const selectedTab = this.querySelector(':scope > tabs-list wc-tab[selected]') as HTMLElement;
127
133
  if (selectedTab) {
128
134
  const selectedTarget = selectedTab.getAttribute('target');
129
135
  if (selectedTarget) this.selectTab(selectedTarget);
@@ -6,6 +6,7 @@ import styles from './tab-panel.scss';
6
6
  * @label Tab Panel
7
7
  * @tag wc-tab-panel
8
8
  * @rawTag tab-panel
9
+ * @parentRawTag tab-group
9
10
  *
10
11
  * @summary Content panel for tabs.
11
12
  * @overview
package/src/tabs/tab.ts CHANGED
@@ -10,6 +10,7 @@ import styles from './tab.scss';
10
10
  * @label Tab
11
11
  * @tag wc-tab
12
12
  * @rawTag tab
13
+ * @parentRawTag tabs
13
14
  *
14
15
  * @summary A tab component for use within tabs.
15
16
  * @overview
@@ -2,17 +2,18 @@
2
2
 
3
3
  @include mixin.base-styles;
4
4
 
5
- .tabs-list {
5
+
6
+ .tabs {
6
7
  display: flex;
7
8
  position: relative;
8
9
  width: 100%;
9
10
  }
10
11
 
11
- :host-context([variant='line']) {
12
- --tabs-list-height: 3rem;
12
+ :host-context([variant='line']), :host([variant='line']) {
13
+ --tabs-height: 3rem;
13
14
 
14
- .tabs-list {
15
- height: var(--tabs-list-height);
15
+ .tabs {
16
+ height: var(--tabs-height);
16
17
  border-bottom: 1px solid var(--color-surface-variant);
17
18
  }
18
19
  }
package/src/tabs/tabs.ts CHANGED
@@ -24,6 +24,8 @@ import { Tab } from './tab.js';
24
24
  export class Tabs extends LitElement {
25
25
  static styles = [styles];
26
26
 
27
+ static Tab = Tab;
28
+
27
29
  @property({ type: Boolean }) managed = false;
28
30
 
29
31
  connectedCallback() {
@@ -42,12 +44,12 @@ export class Tabs extends LitElement {
42
44
  const detailEvent = event as CustomEvent;
43
45
  const path = detailEvent.composedPath();
44
46
  const clickedTab: Tab | undefined = path.find(
45
- node => node instanceof Element && (node as Element).tagName.toLowerCase() === 'base-tab',
47
+ node => node instanceof Element && (node as Element).tagName.toLowerCase() === 'wc-tab',
46
48
  ) as Tab | undefined;
47
49
 
48
50
  if (!clickedTab) return;
49
51
 
50
- const tabs: NodeListOf<Tab> = this.querySelectorAll('base-tab');
52
+ const tabs: NodeListOf<Tab> = this.querySelectorAll('wc-tab');
51
53
  tabs.forEach(tab => {
52
54
  tab.active = false;
53
55
  });
@@ -56,7 +58,7 @@ export class Tabs extends LitElement {
56
58
 
57
59
  render() {
58
60
  return html`
59
- <div class="tabs-list">
61
+ <div class="tabs">
60
62
  <slot></slot>
61
63
  </div>
62
64
  `;
@@ -49,8 +49,11 @@ $sizes: "large", "medium", 'small';
49
49
  }
50
50
 
51
51
  .text-code-block {
52
- font-family: var(--font-family-monospace);
53
- background: var(--color-primary-container);
52
+ display: inline-flex;
53
+ background-color: var(--color-surface-variant);
54
+ text-shadow: 0 1px 1px var(--color-surface-variant);
55
+ color: var(--color-on-surface);
54
56
  border-radius: var(--shape-corner-extra-small);
55
- padding-inline: var(--spacing-050);
57
+ padding: var(--spacing-050);
58
+ font-family: var(--font-family-monospace);
56
59
  }
@@ -3,20 +3,23 @@
3
3
 
4
4
  @include mixin.base-styles;
5
5
 
6
- .tooltip {
7
- pointer-events: none;
8
- transition: transform var(--duration-short2) ease-in-out, opacity var(--duration-short2) ease-in-out;
9
- transform: scale(0);
10
- position: absolute;
11
- top: 0;
12
- left: 0;
13
- opacity: 0;
14
- }
15
6
 
16
- .tooltip.open {
17
- pointer-events: auto;
18
- transform: scale(1);
19
- opacity: 1;
7
+ :host(:not([preview])) {
8
+ .tooltip {
9
+ pointer-events: none;
10
+ transition: transform var(--duration-short2) ease-in-out, opacity var(--duration-short2) ease-in-out;
11
+ transform: scale(0);
12
+ position: absolute;
13
+ top: 0;
14
+ left: 0;
15
+ opacity: 0;
16
+ }
17
+
18
+ .tooltip.open {
19
+ pointer-events: auto;
20
+ transform: scale(1);
21
+ opacity: 1;
22
+ }
20
23
  }
21
24
 
22
25
  .variant-plain .tooltip-content {