@threadlabs/looma 0.52.10 → 0.52.12
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/components/ui-column/ui-column.html +63 -0
- package/components/ui-column/ui-column.js +16 -0
- package/components/ui-data-table/ui-data-table.html +137 -0
- package/components/ui-data-table/ui-data-table.js +69 -0
- package/dist/index.js +69 -67
- package/docs/catalog.json +417 -1
- package/editor/components.css +19 -19
- package/package.json +3 -3
- package/styles/ui-action-bar.css +1 -1
- package/styles/ui-affordance-scope.css +1 -1
- package/styles/ui-avatar-group.css +1 -1
- package/styles/ui-avatar.css +1 -1
- package/styles/ui-badge.css +1 -1
- package/styles/ui-breadcrumb-item.css +1 -1
- package/styles/ui-breadcrumbs.css +1 -1
- package/styles/ui-button.css +1 -1
- package/styles/ui-calendar.css +1 -1
- package/styles/ui-callout.css +1 -1
- package/styles/ui-card-group.css +1 -1
- package/styles/ui-card.css +1 -1
- package/styles/ui-checkbox.css +1 -1
- package/styles/ui-cluster.css +1 -1
- package/styles/ui-color-picker.css +1 -1
- package/styles/ui-column.css +65 -0
- package/styles/ui-combobox.css +1 -1
- package/styles/ui-compact-content.css +1 -1
- package/styles/ui-compact-editor.css +1 -1
- package/styles/ui-compact-mark.css +1 -1
- package/styles/ui-compact-node.css +1 -1
- package/styles/ui-container.css +1 -1
- package/styles/ui-context-menu.css +1 -1
- package/styles/ui-cover.css +1 -1
- package/styles/ui-curve-editor.css +1 -1
- package/styles/ui-cycle-button.css +1 -1
- package/styles/ui-data-table.css +125 -0
- package/styles/ui-date-field.css +1 -1
- package/styles/ui-date-picker.css +1 -1
- package/styles/ui-date-range-picker.css +1 -1
- package/styles/ui-description-item.css +1 -1
- package/styles/ui-description-list.css +1 -1
- package/styles/ui-dialog.css +1 -1
- package/styles/ui-disclosure.css +1 -1
- package/styles/ui-editable.css +1 -1
- package/styles/ui-editor-block-actions.css +1 -1
- package/styles/ui-editor-chip-editor.css +1 -1
- package/styles/ui-editor-code-language.css +1 -1
- package/styles/ui-editor-footnote-editor.css +1 -1
- package/styles/ui-editor-formatting-tools.css +1 -1
- package/styles/ui-editor-image-toolbar.css +1 -1
- package/styles/ui-editor-insert-table-grid.css +1 -1
- package/styles/ui-editor-link-card.css +1 -1
- package/styles/ui-editor-link-form.css +1 -1
- package/styles/ui-editor-mention-menu-item.css +1 -1
- package/styles/ui-editor-mention-menu.css +1 -1
- package/styles/ui-editor-slash-menu-group.css +1 -1
- package/styles/ui-editor-slash-menu-item.css +1 -1
- package/styles/ui-editor-slash-menu.css +1 -1
- package/styles/ui-editor-surface.css +1 -1
- package/styles/ui-editor-table-context-menu.css +1 -1
- package/styles/ui-editor-table-overlay.css +1 -1
- package/styles/ui-editor-table-toolbar.css +1 -1
- package/styles/ui-editor-toolbar.css +1 -1
- package/styles/ui-editor.css +1 -1
- package/styles/ui-file-input.css +1 -1
- package/styles/ui-floating-action-button.css +1 -1
- package/styles/ui-form-field.css +1 -1
- package/styles/ui-grid.css +1 -1
- package/styles/ui-icon-button.css +1 -1
- package/styles/ui-icon.css +1 -1
- package/styles/ui-image.css +1 -1
- package/styles/ui-input-group.css +1 -1
- package/styles/ui-input.css +1 -1
- package/styles/ui-light-editor.css +1 -1
- package/styles/ui-list-item.css +1 -1
- package/styles/ui-list.css +1 -1
- package/styles/ui-listbox.css +1 -1
- package/styles/ui-menu-group.css +1 -1
- package/styles/ui-menu-item.css +1 -1
- package/styles/ui-menu.css +1 -1
- package/styles/ui-meter.css +1 -1
- package/styles/ui-nav-item.css +1 -1
- package/styles/ui-notice-stripe.css +1 -1
- package/styles/ui-number-input.css +1 -1
- package/styles/ui-page-header.css +1 -1
- package/styles/ui-pagination.css +1 -1
- package/styles/ui-popover.css +1 -1
- package/styles/ui-radio-group.css +1 -1
- package/styles/ui-radio.css +1 -1
- package/styles/ui-reel.css +1 -1
- package/styles/ui-scroll-area.css +1 -1
- package/styles/ui-search-result-row.css +1 -1
- package/styles/ui-search-shell.css +1 -1
- package/styles/ui-section.css +1 -1
- package/styles/ui-segmented-control.css +1 -1
- package/styles/ui-select.css +1 -1
- package/styles/ui-separator.css +1 -1
- package/styles/ui-sidebar.css +1 -1
- package/styles/ui-site-header.css +1 -1
- package/styles/ui-skeleton.css +1 -1
- package/styles/ui-slider.css +1 -1
- package/styles/ui-spinner.css +1 -1
- package/styles/ui-stack.css +1 -1
- package/styles/ui-status-message.css +1 -1
- package/styles/ui-swatch.css +1 -1
- package/styles/ui-switch.css +1 -1
- package/styles/ui-switcher.css +1 -1
- package/styles/ui-table.css +1 -1
- package/styles/ui-tabs.css +1 -1
- package/styles/ui-text.css +1 -1
- package/styles/ui-textarea.css +1 -1
- package/styles/ui-time-field.css +1 -1
- package/styles/ui-time-picker.css +1 -1
- package/styles/ui-toast-region.css +1 -1
- package/styles/ui-toast.css +1 -1
- package/styles/ui-tooltip.css +1 -1
- package/styles/ui-top-bar.css +1 -1
- package/styles/ui-tree-item.css +1 -1
- package/styles/ui-tree.css +1 -1
- package/styles/ui-wizard.css +1 -1
- package/vanilla/UiActionBar.d.ts +1 -1
- package/vanilla/UiActionBar.js +1 -1
- package/vanilla/UiAffordanceScope.d.ts +1 -1
- package/vanilla/UiAffordanceScope.js +1 -1
- package/vanilla/UiAvatar.d.ts +1 -1
- package/vanilla/UiAvatar.js +1 -1
- package/vanilla/UiAvatarGroup.d.ts +1 -1
- package/vanilla/UiAvatarGroup.js +1 -1
- package/vanilla/UiBadge.d.ts +1 -1
- package/vanilla/UiBadge.js +1 -1
- package/vanilla/UiBreadcrumbItem.d.ts +1 -1
- package/vanilla/UiBreadcrumbItem.js +1 -1
- package/vanilla/UiBreadcrumbs.d.ts +1 -1
- package/vanilla/UiBreadcrumbs.js +1 -1
- package/vanilla/UiButton.d.ts +1 -1
- package/vanilla/UiButton.js +1 -1
- package/vanilla/UiCalendar.d.ts +1 -1
- package/vanilla/UiCalendar.js +1 -1
- package/vanilla/UiCallout.d.ts +1 -1
- package/vanilla/UiCallout.js +1 -1
- package/vanilla/UiCard.d.ts +1 -1
- package/vanilla/UiCard.js +1 -1
- package/vanilla/UiCardGroup.d.ts +1 -1
- package/vanilla/UiCardGroup.js +1 -1
- package/vanilla/UiCheckbox.d.ts +1 -1
- package/vanilla/UiCheckbox.js +1 -1
- package/vanilla/UiCluster.d.ts +1 -1
- package/vanilla/UiCluster.js +1 -1
- package/vanilla/UiColorPicker.d.ts +1 -1
- package/vanilla/UiColorPicker.js +1 -1
- package/vanilla/UiColumn.d.ts +31 -0
- package/vanilla/UiColumn.js +62 -0
- package/vanilla/UiCombobox.d.ts +1 -1
- package/vanilla/UiCombobox.js +1 -1
- package/vanilla/UiCompactContent.d.ts +1 -1
- package/vanilla/UiCompactContent.js +1 -1
- package/vanilla/UiCompactEditor.d.ts +1 -1
- package/vanilla/UiCompactEditor.js +1 -1
- package/vanilla/UiCompactMark.d.ts +1 -1
- package/vanilla/UiCompactMark.js +1 -1
- package/vanilla/UiCompactNode.d.ts +1 -1
- package/vanilla/UiCompactNode.js +1 -1
- package/vanilla/UiContainer.d.ts +1 -1
- package/vanilla/UiContainer.js +1 -1
- package/vanilla/UiContextMenu.d.ts +1 -1
- package/vanilla/UiContextMenu.js +1 -1
- package/vanilla/UiCover.d.ts +1 -1
- package/vanilla/UiCover.js +1 -1
- package/vanilla/UiCurveEditor.d.ts +1 -1
- package/vanilla/UiCurveEditor.js +1 -1
- package/vanilla/UiCycleButton.d.ts +1 -1
- package/vanilla/UiCycleButton.js +1 -1
- package/vanilla/UiDataTable.d.ts +30 -0
- package/vanilla/UiDataTable.js +155 -0
- package/vanilla/UiDateField.d.ts +1 -1
- package/vanilla/UiDateField.js +1 -1
- package/vanilla/UiDatePicker.d.ts +1 -1
- package/vanilla/UiDatePicker.js +1 -1
- package/vanilla/UiDateRangePicker.d.ts +1 -1
- package/vanilla/UiDateRangePicker.js +1 -1
- package/vanilla/UiDescriptionItem.d.ts +1 -1
- package/vanilla/UiDescriptionItem.js +1 -1
- package/vanilla/UiDescriptionList.d.ts +1 -1
- package/vanilla/UiDescriptionList.js +1 -1
- package/vanilla/UiDialog.d.ts +1 -1
- package/vanilla/UiDialog.js +1 -1
- package/vanilla/UiDisclosure.d.ts +1 -1
- package/vanilla/UiDisclosure.js +1 -1
- package/vanilla/UiEditable.d.ts +1 -1
- package/vanilla/UiEditable.js +1 -1
- package/vanilla/UiEditor.d.ts +1 -1
- package/vanilla/UiEditor.js +1 -1
- package/vanilla/UiEditorBlockActions.d.ts +1 -1
- package/vanilla/UiEditorBlockActions.js +1 -1
- package/vanilla/UiEditorChipEditor.d.ts +1 -1
- package/vanilla/UiEditorChipEditor.js +1 -1
- package/vanilla/UiEditorCodeLanguage.d.ts +1 -1
- package/vanilla/UiEditorCodeLanguage.js +1 -1
- package/vanilla/UiEditorFootnoteEditor.d.ts +1 -1
- package/vanilla/UiEditorFootnoteEditor.js +1 -1
- package/vanilla/UiEditorFormattingTools.d.ts +1 -1
- package/vanilla/UiEditorFormattingTools.js +1 -1
- package/vanilla/UiEditorImageToolbar.d.ts +1 -1
- package/vanilla/UiEditorImageToolbar.js +1 -1
- package/vanilla/UiEditorInsertTableGrid.d.ts +1 -1
- package/vanilla/UiEditorInsertTableGrid.js +1 -1
- package/vanilla/UiEditorLinkCard.d.ts +1 -1
- package/vanilla/UiEditorLinkCard.js +1 -1
- package/vanilla/UiEditorLinkForm.d.ts +1 -1
- package/vanilla/UiEditorLinkForm.js +1 -1
- package/vanilla/UiEditorMentionMenu.d.ts +1 -1
- package/vanilla/UiEditorMentionMenu.js +1 -1
- package/vanilla/UiEditorMentionMenuItem.d.ts +1 -1
- package/vanilla/UiEditorMentionMenuItem.js +1 -1
- package/vanilla/UiEditorSlashMenu.d.ts +1 -1
- package/vanilla/UiEditorSlashMenu.js +1 -1
- package/vanilla/UiEditorSlashMenuGroup.d.ts +1 -1
- package/vanilla/UiEditorSlashMenuGroup.js +1 -1
- package/vanilla/UiEditorSlashMenuItem.d.ts +1 -1
- package/vanilla/UiEditorSlashMenuItem.js +1 -1
- package/vanilla/UiEditorSurface.d.ts +1 -1
- package/vanilla/UiEditorSurface.js +1 -1
- package/vanilla/UiEditorTableContextMenu.d.ts +1 -1
- package/vanilla/UiEditorTableContextMenu.js +1 -1
- package/vanilla/UiEditorTableOverlay.d.ts +1 -1
- package/vanilla/UiEditorTableOverlay.js +1 -1
- package/vanilla/UiEditorTableToolbar.d.ts +1 -1
- package/vanilla/UiEditorTableToolbar.js +1 -1
- package/vanilla/UiEditorToolbar.d.ts +1 -1
- package/vanilla/UiEditorToolbar.js +1 -1
- package/vanilla/UiFileInput.d.ts +1 -1
- package/vanilla/UiFileInput.js +1 -1
- package/vanilla/UiFloatingActionButton.d.ts +1 -1
- package/vanilla/UiFloatingActionButton.js +1 -1
- package/vanilla/UiFormField.d.ts +1 -1
- package/vanilla/UiFormField.js +1 -1
- package/vanilla/UiGrid.d.ts +1 -1
- package/vanilla/UiGrid.js +1 -1
- package/vanilla/UiIcon.d.ts +1 -1
- package/vanilla/UiIcon.js +1 -1
- package/vanilla/UiIconButton.d.ts +1 -1
- package/vanilla/UiIconButton.js +1 -1
- package/vanilla/UiImage.d.ts +1 -1
- package/vanilla/UiImage.js +1 -1
- package/vanilla/UiInput.d.ts +1 -1
- package/vanilla/UiInput.js +1 -1
- package/vanilla/UiInputGroup.d.ts +1 -1
- package/vanilla/UiInputGroup.js +1 -1
- package/vanilla/UiLightEditor.d.ts +1 -1
- package/vanilla/UiLightEditor.js +1 -1
- package/vanilla/UiList.d.ts +1 -1
- package/vanilla/UiList.js +1 -1
- package/vanilla/UiListItem.d.ts +1 -1
- package/vanilla/UiListItem.js +1 -1
- package/vanilla/UiListbox.d.ts +1 -1
- package/vanilla/UiListbox.js +1 -1
- package/vanilla/UiMenu.d.ts +1 -1
- package/vanilla/UiMenu.js +1 -1
- package/vanilla/UiMenuGroup.d.ts +1 -1
- package/vanilla/UiMenuGroup.js +1 -1
- package/vanilla/UiMenuItem.d.ts +1 -1
- package/vanilla/UiMenuItem.js +1 -1
- package/vanilla/UiMeter.d.ts +1 -1
- package/vanilla/UiMeter.js +1 -1
- package/vanilla/UiNavItem.d.ts +1 -1
- package/vanilla/UiNavItem.js +1 -1
- package/vanilla/UiNoticeStripe.d.ts +1 -1
- package/vanilla/UiNoticeStripe.js +1 -1
- package/vanilla/UiNumberInput.d.ts +1 -1
- package/vanilla/UiNumberInput.js +1 -1
- package/vanilla/UiPageHeader.d.ts +1 -1
- package/vanilla/UiPageHeader.js +1 -1
- package/vanilla/UiPagination.d.ts +1 -1
- package/vanilla/UiPagination.js +1 -1
- package/vanilla/UiPopover.d.ts +1 -1
- package/vanilla/UiPopover.js +1 -1
- package/vanilla/UiRadio.d.ts +1 -1
- package/vanilla/UiRadio.js +1 -1
- package/vanilla/UiRadioGroup.d.ts +1 -1
- package/vanilla/UiRadioGroup.js +1 -1
- package/vanilla/UiReel.d.ts +1 -1
- package/vanilla/UiReel.js +1 -1
- package/vanilla/UiScrollArea.d.ts +1 -1
- package/vanilla/UiScrollArea.js +1 -1
- package/vanilla/UiSearchResultRow.d.ts +1 -1
- package/vanilla/UiSearchResultRow.js +1 -1
- package/vanilla/UiSearchShell.d.ts +1 -1
- package/vanilla/UiSearchShell.js +1 -1
- package/vanilla/UiSection.d.ts +1 -1
- package/vanilla/UiSection.js +1 -1
- package/vanilla/UiSegmentedControl.d.ts +1 -1
- package/vanilla/UiSegmentedControl.js +1 -1
- package/vanilla/UiSelect.d.ts +1 -1
- package/vanilla/UiSelect.js +1 -1
- package/vanilla/UiSeparator.d.ts +1 -1
- package/vanilla/UiSeparator.js +1 -1
- package/vanilla/UiSidebar.d.ts +1 -1
- package/vanilla/UiSidebar.js +1 -1
- package/vanilla/UiSiteHeader.d.ts +1 -1
- package/vanilla/UiSiteHeader.js +1 -1
- package/vanilla/UiSkeleton.d.ts +1 -1
- package/vanilla/UiSkeleton.js +1 -1
- package/vanilla/UiSlider.d.ts +1 -1
- package/vanilla/UiSlider.js +1 -1
- package/vanilla/UiSpinner.d.ts +1 -1
- package/vanilla/UiSpinner.js +1 -1
- package/vanilla/UiStack.d.ts +1 -1
- package/vanilla/UiStack.js +1 -1
- package/vanilla/UiStatusMessage.d.ts +1 -1
- package/vanilla/UiStatusMessage.js +1 -1
- package/vanilla/UiSwatch.d.ts +1 -1
- package/vanilla/UiSwatch.js +1 -1
- package/vanilla/UiSwitch.d.ts +1 -1
- package/vanilla/UiSwitch.js +1 -1
- package/vanilla/UiSwitcher.d.ts +1 -1
- package/vanilla/UiSwitcher.js +1 -1
- package/vanilla/UiTable.d.ts +1 -1
- package/vanilla/UiTable.js +1 -1
- package/vanilla/UiTabs.d.ts +1 -1
- package/vanilla/UiTabs.js +1 -1
- package/vanilla/UiText.d.ts +1 -1
- package/vanilla/UiText.js +1 -1
- package/vanilla/UiTextarea.d.ts +1 -1
- package/vanilla/UiTextarea.js +1 -1
- package/vanilla/UiTimeField.d.ts +1 -1
- package/vanilla/UiTimeField.js +1 -1
- package/vanilla/UiTimePicker.d.ts +1 -1
- package/vanilla/UiTimePicker.js +1 -1
- package/vanilla/UiToast.d.ts +1 -1
- package/vanilla/UiToast.js +1 -1
- package/vanilla/UiToastRegion.d.ts +1 -1
- package/vanilla/UiToastRegion.js +1 -1
- package/vanilla/UiTooltip.d.ts +1 -1
- package/vanilla/UiTooltip.js +1 -1
- package/vanilla/UiTopBar.d.ts +1 -1
- package/vanilla/UiTopBar.js +1 -1
- package/vanilla/UiTree.d.ts +1 -1
- package/vanilla/UiTree.js +1 -1
- package/vanilla/UiTreeItem.d.ts +1 -1
- package/vanilla/UiTreeItem.js +1 -1
- package/vanilla/UiWizard.d.ts +1 -1
- package/vanilla/UiWizard.js +1 -1
- package/vanilla/index.js +2 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<template component="ui-column" module="./ui-column.js">
|
|
2
|
+
<th scope="col" style:--_width="$width"><slot name="header">{$header}</slot></th>
|
|
3
|
+
<defs>
|
|
4
|
+
<prop name="field" type="string">The row field each cell shows when the column gives no cell content.</prop>
|
|
5
|
+
<prop name="header" type="string">The header text. Content in the header slot replaces it, for markup such as an abbreviation.</prop>
|
|
6
|
+
<prop name="align" type="keyword" values="start, center, end" default="start"
|
|
7
|
+
>Where the header and every cell set their content along the row, such as end for a column of figures.</prop>
|
|
8
|
+
<prop name="frozen" type="keyword" values="none, start, end" default="none"
|
|
9
|
+
>Keeps the column in view while the table scrolls sideways. start holds it at the inline start edge, beside any frozen columns before it; end holds it at
|
|
10
|
+
the inline end edge, beside any frozen columns after it.</prop>
|
|
11
|
+
<prop name="width" type="string">The column's width as a CSS length, such as 12rem. The column sizes to its content when it is not set.</prop>
|
|
12
|
+
<slot name="header"></slot>
|
|
13
|
+
<slot name="cell"><prop name="row" type="object({ ... })" required>The row this cell shows.</prop></slot>
|
|
14
|
+
</defs>
|
|
15
|
+
<style>
|
|
16
|
+
/* One column of a Data Table: its root is the header cell, and the table places its cell content in
|
|
17
|
+
every row. The header stays at the top of the table's scroll box, so it stays in view whenever the
|
|
18
|
+
table has a bounded height. The table sets the padding for its density through the
|
|
19
|
+
--_ui-column-pad-inline custom property. */
|
|
20
|
+
:host {
|
|
21
|
+
position: sticky;
|
|
22
|
+
inset-block-start: 0;
|
|
23
|
+
z-index: 2;
|
|
24
|
+
box-sizing: border-box !important;
|
|
25
|
+
inline-size: var(--_width, auto);
|
|
26
|
+
min-inline-size: var(--_width, 0);
|
|
27
|
+
padding: var(--ui-space-2) var(--_ui-column-pad-inline, var(--ui-space-3)) !important;
|
|
28
|
+
border-block-end: var(--ui-border-width) solid var(--ui-border-divider);
|
|
29
|
+
background: var(--ui-surface);
|
|
30
|
+
color: var(--ui-text-muted);
|
|
31
|
+
font-weight: var(--ui-font-medium);
|
|
32
|
+
text-align: start;
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
vertical-align: bottom;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:host([align="center"]) {
|
|
38
|
+
text-align: center;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:host([align="end"]) {
|
|
42
|
+
text-align: end;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* The table measures the frozen columns and publishes each one's offset; the controller points this
|
|
46
|
+
column at its own. */
|
|
47
|
+
:host([frozen="start"]) {
|
|
48
|
+
inset-inline-start: var(--_ui-frozen-offset, 0);
|
|
49
|
+
z-index: 3;
|
|
50
|
+
border-inline-end: var(--ui-border-width) solid var(--ui-border-divider);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:host([frozen="end"]) {
|
|
54
|
+
inset-inline-end: var(--_ui-frozen-offset, 0);
|
|
55
|
+
z-index: 3;
|
|
56
|
+
border-inline-start: var(--ui-border-width) solid var(--ui-border-divider);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:host[hidden] {
|
|
60
|
+
display: none !important;
|
|
61
|
+
}
|
|
62
|
+
</style>
|
|
63
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// A frozen column reads its offset from the Data Table around it, which measures every frozen column
|
|
2
|
+
// and publishes --_ui-col-<index> on its table. The column points its own offset at its index and
|
|
3
|
+
// follows it when columns are added, removed, or reordered.
|
|
4
|
+
export function connect(host) {
|
|
5
|
+
const element = host.element;
|
|
6
|
+
const row = element.parentElement;
|
|
7
|
+
if (!row) return undefined;
|
|
8
|
+
const update = () => element.style.setProperty("--_ui-frozen-offset", `var(--_ui-col-${element.cellIndex}, 0)`);
|
|
9
|
+
const observer = new MutationObserver(update);
|
|
10
|
+
observer.observe(row, { childList: true });
|
|
11
|
+
update();
|
|
12
|
+
return () => {
|
|
13
|
+
observer.disconnect();
|
|
14
|
+
element.style.removeProperty("--_ui-frozen-offset");
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<template component="ui-data-table" module="./ui-data-table.js">
|
|
2
|
+
<div>
|
|
3
|
+
<table>
|
|
4
|
+
<caption $if="$caption">{$caption}</caption>
|
|
5
|
+
<thead><tr><template $slot></template></tr></thead>
|
|
6
|
+
<tbody>
|
|
7
|
+
<tr $each="row, r of $rows" $key="$row[$rowKey]" class:frozen="$r < $frozenRows" style:--_ui-top="concat('var(--_ui-row-', $r, ', 0)')">
|
|
8
|
+
<td
|
|
9
|
+
$each="column, c of $columns"
|
|
10
|
+
$key="$column"
|
|
11
|
+
from:data-ui-align="$column.align"
|
|
12
|
+
from:data-ui-frozen="$column.frozen"
|
|
13
|
+
style:--_ui-side="concat('var(--_ui-col-', $c, ', 0)')"
|
|
14
|
+
>
|
|
15
|
+
<slot of="$column" name="cell" from:row="$row">{$row[$column.field]}</slot>
|
|
16
|
+
</td>
|
|
17
|
+
</tr>
|
|
18
|
+
</tbody>
|
|
19
|
+
</table>
|
|
20
|
+
</div>
|
|
21
|
+
<defs>
|
|
22
|
+
<prop name="rows" type="list(object({ ... }))" default="[]">One entry per table row. Each column shows its field of the row, or its own cell content.</prop>
|
|
23
|
+
<prop name="rowKey" type="string" default="id"
|
|
24
|
+
>The row field that identifies each row, so a row keeps its cells, and the state of any control in them, when the rows change order.</prop>
|
|
25
|
+
<prop name="caption" type="string">Names the table. A screen reader announces it with the table, and it names the scrolling region.</prop>
|
|
26
|
+
<prop name="density" type="keyword" values="comfortable, compact" default="comfortable"
|
|
27
|
+
>How tall each row is. comfortable fits a control of the standard height; compact fits a small one, for long tables to scan.</prop>
|
|
28
|
+
<prop name="frozenRows" type="integer" default="0"
|
|
29
|
+
>How many leading rows stay in view beneath the header while the rows scroll. Frozen rows suit totals or a pinned item.</prop>
|
|
30
|
+
<slot accepts="ui-column" as="columns"></slot>
|
|
31
|
+
</defs>
|
|
32
|
+
<style>
|
|
33
|
+
/* The root scrolls the table: sideways when it is wider than the root, and down when the root has a
|
|
34
|
+
bounded height. The header, the frozen rows, and the frozen columns stay in view with
|
|
35
|
+
position: sticky; the controller measures them and publishes each offset as --_ui-col-<index> and
|
|
36
|
+
--_ui-row-<index>. */
|
|
37
|
+
:host {
|
|
38
|
+
--_pad-block: var(--ui-space-1);
|
|
39
|
+
--_pad-inline: var(--ui-space-3);
|
|
40
|
+
--_row-size: var(--ui-control-size);
|
|
41
|
+
--_ui-column-pad-inline: var(--_pad-inline);
|
|
42
|
+
display: block !important;
|
|
43
|
+
box-sizing: border-box !important;
|
|
44
|
+
max-inline-size: 100%;
|
|
45
|
+
min-inline-size: 0;
|
|
46
|
+
min-block-size: 0;
|
|
47
|
+
overflow: auto;
|
|
48
|
+
overscroll-behavior-inline: contain;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host:focus-visible {
|
|
52
|
+
outline: var(--ui-focus-width) solid var(--ui-focus-ring);
|
|
53
|
+
outline-offset: calc(-1 * var(--ui-focus-width));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
:host([density="compact"]) {
|
|
57
|
+
--_pad-block: var(--ui-space-0-5);
|
|
58
|
+
--_pad-inline: var(--ui-space-2);
|
|
59
|
+
--_row-size: var(--ui-control-size-sm);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Separate borders stay on their cells when sticky cells scroll; collapsed ones stay behind. */
|
|
63
|
+
/* The table fills the root, and grows past it when its columns need more room, so the root scrolls. */
|
|
64
|
+
table {
|
|
65
|
+
min-inline-size: 100%;
|
|
66
|
+
border-collapse: separate;
|
|
67
|
+
border-spacing: 0;
|
|
68
|
+
color: var(--ui-text-primary);
|
|
69
|
+
font-size: var(--ui-font-size-sm);
|
|
70
|
+
line-height: var(--ui-line-height);
|
|
71
|
+
font-variant-numeric: tabular-nums;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
caption {
|
|
75
|
+
padding-block-end: var(--ui-space-2) !important;
|
|
76
|
+
color: var(--ui-text-secondary);
|
|
77
|
+
font-weight: var(--ui-font-medium);
|
|
78
|
+
text-align: start;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
td {
|
|
82
|
+
block-size: var(--_row-size);
|
|
83
|
+
padding: var(--_pad-block) var(--_pad-inline) !important;
|
|
84
|
+
border-block-end: var(--ui-border-width) solid var(--ui-border-subtle);
|
|
85
|
+
background: var(--ui-surface);
|
|
86
|
+
text-align: start;
|
|
87
|
+
vertical-align: middle;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
tbody tr:last-child > td {
|
|
91
|
+
border-block-end-width: 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
td[data-ui-align="center"] {
|
|
95
|
+
text-align: center;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
td[data-ui-align="end"] {
|
|
99
|
+
text-align: end;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Frozen cells sit above the cells that scroll beneath them; a cell frozen both ways sits above both. */
|
|
103
|
+
/* A divider on a frozen column's inner edge marks where the scrolling cells pass beneath it. */
|
|
104
|
+
td[data-ui-frozen="start"] {
|
|
105
|
+
position: sticky;
|
|
106
|
+
inset-inline-start: var(--_ui-side);
|
|
107
|
+
z-index: 1;
|
|
108
|
+
border-inline-end: var(--ui-border-width) solid var(--ui-border-divider);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
td[data-ui-frozen="end"] {
|
|
112
|
+
position: sticky;
|
|
113
|
+
inset-inline-end: var(--_ui-side);
|
|
114
|
+
z-index: 1;
|
|
115
|
+
border-inline-start: var(--ui-border-width) solid var(--ui-border-divider);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
tr.frozen > td {
|
|
119
|
+
position: sticky;
|
|
120
|
+
inset-block-start: var(--_ui-top);
|
|
121
|
+
z-index: 1;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
tr.frozen > td[data-ui-frozen="start"],
|
|
125
|
+
tr.frozen > td[data-ui-frozen="end"] {
|
|
126
|
+
z-index: 2;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
tr.frozen:nth-last-child(1 of .frozen) > td {
|
|
130
|
+
border-block-end-color: var(--ui-border-divider);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
:host[hidden] {
|
|
134
|
+
display: none !important;
|
|
135
|
+
}
|
|
136
|
+
</style>
|
|
137
|
+
</template>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { connect as connectScrollRegion } from "../ui-table/ui-table.js";
|
|
2
|
+
|
|
3
|
+
// The root is a keyboard-scrollable region while the table scrolls, as Table's is. Frozen columns and
|
|
4
|
+
// rows stay in view with position: sticky, which needs each one's offset: the sum of the frozen
|
|
5
|
+
// columns before it (or after it, for end), and the header plus the frozen rows above it. The
|
|
6
|
+
// controller measures them and publishes --_ui-col-<index> and --_ui-row-<index> on the table, and
|
|
7
|
+
// measures again when a cell resizes or the rows or columns change.
|
|
8
|
+
export function connect(host) {
|
|
9
|
+
const element = host.element;
|
|
10
|
+
const stopRegion = connectScrollRegion(host);
|
|
11
|
+
const table = element.querySelector(":scope > table");
|
|
12
|
+
if (!table) return stopRegion;
|
|
13
|
+
|
|
14
|
+
let published = [];
|
|
15
|
+
let frame = 0;
|
|
16
|
+
const publish = (name, value) => {
|
|
17
|
+
table.style.setProperty(name, `${value}px`);
|
|
18
|
+
published.push(name);
|
|
19
|
+
};
|
|
20
|
+
const measure = () => {
|
|
21
|
+
frame = 0;
|
|
22
|
+
for (const name of published) table.style.removeProperty(name);
|
|
23
|
+
published = [];
|
|
24
|
+
const columns = host.state.columns ?? [];
|
|
25
|
+
const headers = Array.from(table.tHead?.rows[0]?.cells ?? []);
|
|
26
|
+
let start = 0;
|
|
27
|
+
headers.forEach((cell, index) => {
|
|
28
|
+
if (columns[index]?.frozen !== "start") return;
|
|
29
|
+
publish(`--_ui-col-${index}`, start);
|
|
30
|
+
start += cell.getBoundingClientRect().width;
|
|
31
|
+
});
|
|
32
|
+
let end = 0;
|
|
33
|
+
for (let index = headers.length - 1; index >= 0; index -= 1) {
|
|
34
|
+
if (columns[index]?.frozen !== "end") continue;
|
|
35
|
+
publish(`--_ui-col-${index}`, end);
|
|
36
|
+
end += headers[index].getBoundingClientRect().width;
|
|
37
|
+
}
|
|
38
|
+
let top = table.tHead?.getBoundingClientRect().height ?? 0;
|
|
39
|
+
for (const [index, row] of Array.from(table.tBodies[0]?.rows ?? []).entries()) {
|
|
40
|
+
if (!row.classList.contains("frozen")) break;
|
|
41
|
+
publish(`--_ui-row-${index}`, top);
|
|
42
|
+
top += row.getBoundingClientRect().height;
|
|
43
|
+
}
|
|
44
|
+
observe();
|
|
45
|
+
};
|
|
46
|
+
const schedule = () => {
|
|
47
|
+
frame ||= requestAnimationFrame(measure);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const resize = new ResizeObserver(schedule);
|
|
51
|
+
const observe = () => {
|
|
52
|
+
resize.disconnect();
|
|
53
|
+
for (const cell of table.tHead?.rows[0]?.cells ?? []) resize.observe(cell);
|
|
54
|
+
for (const row of table.tBodies[0]?.rows ?? []) {
|
|
55
|
+
if (!row.classList.contains("frozen")) break;
|
|
56
|
+
resize.observe(row);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const changes = new MutationObserver(schedule);
|
|
60
|
+
changes.observe(table, { childList: true, subtree: true, attributes: true, attributeFilter: ["class", "data-ui-frozen"] });
|
|
61
|
+
measure();
|
|
62
|
+
return () => {
|
|
63
|
+
cancelAnimationFrame(frame);
|
|
64
|
+
resize.disconnect();
|
|
65
|
+
changes.disconnect();
|
|
66
|
+
for (const name of published) table.style.removeProperty(name);
|
|
67
|
+
stopRegion?.();
|
|
68
|
+
};
|
|
69
|
+
}
|