@threadlabs/looma 0.47.1 → 0.47.3
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-card/ui-card.html +39 -5
- package/components/ui-card-group/ui-card-group.html +29 -0
- package/components/ui-combobox/ui-combobox.html +24 -4
- package/components/ui-combobox/ui-combobox.js +6 -0
- package/components/ui-site-header/ui-site-header.html +7 -5
- package/components/ui-top-bar/ui-top-bar.html +32 -2
- package/components/ui-top-bar/ui-top-bar.js +60 -0
- package/dist/index.js +4 -3
- package/docs/catalog.json +190 -4
- package/package.json +1 -1
- package/styles/ui-card-group.css +41 -0
- package/styles/ui-card.css +19 -1
- package/styles/ui-combobox.css +42 -6
- package/styles/ui-site-header.css +14 -10
- package/styles/ui-top-bar.css +24 -1
- package/vanilla/UiCard.js +148 -36
- package/vanilla/UiCardGroup.d.ts +25 -0
- package/vanilla/UiCardGroup.js +59 -0
- package/vanilla/UiCombobox.d.ts +1 -0
- package/vanilla/UiCombobox.js +88 -82
- package/vanilla/UiTopBar.d.ts +1 -0
- package/vanilla/UiTopBar.js +50 -13
- package/vanilla/index.js +1 -0
- package/vue/UiCard.d.ts +20 -4
- package/vue/UiCard.vue +31 -5
- package/vue/UiCardGroup.d.ts +41 -0
- package/vue/UiCardGroup.js +2 -0
- package/vue/UiCardGroup.vue +168 -0
- package/vue/UiCombobox.d.ts +6 -0
- package/vue/UiCombobox.vue +78 -9
- package/vue/UiSiteHeader.vue +12 -8
- package/vue/UiTopBar.d.ts +17 -1
- package/vue/UiTopBar.vue +171 -3
- package/vue/chunks/UiAffordanceScope.js +1 -1
- package/vue/chunks/UiAvatar.js +1 -1
- package/vue/chunks/UiAvatarGroup.js +1 -1
- package/vue/chunks/UiBadge.js +1 -1
- package/vue/chunks/UiBreadcrumbItem.js +1 -1
- package/vue/chunks/UiBreadcrumbs.js +1 -1
- package/vue/chunks/UiButton.js +1 -1
- package/vue/chunks/UiCallout.js +1 -1
- package/vue/chunks/UiCard.js +74 -10
- package/vue/chunks/UiCardGroup.js +153 -0
- package/vue/chunks/UiCheckbox.js +1 -1
- package/vue/chunks/UiCluster.js +1 -1
- package/vue/chunks/UiColorPicker.js +1 -1
- package/vue/chunks/UiCombobox.js +74 -53
- package/vue/chunks/UiContainer.js +1 -1
- package/vue/chunks/UiContextMenu.js +1 -1
- package/vue/chunks/UiCover.js +1 -1
- package/vue/chunks/UiCurveEditor.js +1 -1
- package/vue/chunks/UiCycleButton.js +1 -1
- package/vue/chunks/UiDescriptionItem.js +1 -1
- package/vue/chunks/UiDescriptionList.js +1 -1
- package/vue/chunks/UiDialog.js +1 -1
- package/vue/chunks/UiDisclosure.js +1 -1
- package/vue/chunks/UiEditable.js +1 -1
- package/vue/chunks/UiEditorBlockActions.js +1 -1
- package/vue/chunks/UiEditorChipEditor.js +1 -1
- package/vue/chunks/UiEditorCodeLanguage.js +1 -1
- package/vue/chunks/UiEditorFootnoteEditor.js +1 -1
- package/vue/chunks/UiEditorImageToolbar.js +1 -1
- package/vue/chunks/UiEditorInsertTableGrid.js +1 -1
- package/vue/chunks/UiEditorLinkCard.js +1 -1
- package/vue/chunks/UiEditorLinkForm.js +1 -1
- package/vue/chunks/UiEditorMentionMenu.js +1 -1
- package/vue/chunks/UiEditorMentionMenuItem.js +1 -1
- package/vue/chunks/UiEditorSlashMenu.js +1 -1
- package/vue/chunks/UiEditorSlashMenuGroup.js +1 -1
- package/vue/chunks/UiEditorSlashMenuItem.js +1 -1
- package/vue/chunks/UiEditorSurface.js +1 -1
- package/vue/chunks/UiEditorTableContextMenu.js +1 -1
- package/vue/chunks/UiEditorTableOverlay.js +1 -1
- package/vue/chunks/UiEditorTableToolbar.js +1 -1
- package/vue/chunks/UiEditorToolbar.js +1 -1
- package/vue/chunks/UiFloatingActionButton.js +1 -1
- package/vue/chunks/UiFormField.js +1 -1
- package/vue/chunks/UiGrid.js +1 -1
- package/vue/chunks/UiIcon.js +1 -1
- package/vue/chunks/UiIconButton.js +1 -1
- package/vue/chunks/UiImage.js +1 -1
- package/vue/chunks/UiInput.js +1 -1
- package/vue/chunks/UiInputGroup.js +1 -1
- package/vue/chunks/UiLightEditor.js +1 -1
- package/vue/chunks/UiList.js +1 -1
- package/vue/chunks/UiListItem.js +1 -1
- package/vue/chunks/UiListbox.js +1 -1
- package/vue/chunks/UiMenu.js +1 -1
- package/vue/chunks/UiMenuGroup.js +1 -1
- package/vue/chunks/UiMenuItem.js +1 -1
- package/vue/chunks/UiMeter.js +1 -1
- package/vue/chunks/UiNavItem.js +1 -1
- package/vue/chunks/UiNumberInput.js +1 -1
- package/vue/chunks/UiPageHeader.js +1 -1
- package/vue/chunks/UiPagination.js +1 -1
- package/vue/chunks/UiPopover.js +1 -1
- package/vue/chunks/UiRadio.js +1 -1
- package/vue/chunks/UiRadioGroup.js +1 -1
- package/vue/chunks/UiReel.js +1 -1
- package/vue/chunks/UiScrollArea.js +1 -1
- package/vue/chunks/UiSearchResultRow.js +1 -1
- package/vue/chunks/UiSearchShell.js +1 -1
- package/vue/chunks/UiSection.js +1 -1
- package/vue/chunks/UiSelect.js +1 -1
- package/vue/chunks/UiSeparator.js +1 -1
- package/vue/chunks/UiSidebar.js +1 -1
- package/vue/chunks/UiSiteHeader.js +2 -2
- package/vue/chunks/UiSkeleton.js +1 -1
- package/vue/chunks/UiSlider.js +1 -1
- package/vue/chunks/UiSpinner.js +1 -1
- package/vue/chunks/UiStack.js +1 -1
- package/vue/chunks/UiStatusMessage.js +1 -1
- package/vue/chunks/UiSwatch.js +1 -1
- package/vue/chunks/UiSwitch.js +1 -1
- package/vue/chunks/UiSwitcher.js +1 -1
- package/vue/chunks/UiTable.js +1 -1
- package/vue/chunks/UiTabs.js +1 -1
- package/vue/chunks/UiText.js +1 -1
- package/vue/chunks/UiTextarea.js +1 -1
- package/vue/chunks/UiToast.js +1 -1
- package/vue/chunks/UiToastRegion.js +1 -1
- package/vue/chunks/UiTooltip.js +1 -1
- package/vue/chunks/UiTopBar.js +105 -17
- package/vue/chunks/UiTree.js +1 -1
- package/vue/chunks/UiTreeItem.js +1 -1
- package/vue/chunks/props.js +1 -1
- package/vue/components.css +185 -77
- package/vue/index.d.ts +1 -0
- package/vue/index.js +3 -2
|
@@ -19,10 +19,26 @@
|
|
|
19
19
|
>The native element the card renders. Choose the one that names the content: a section of a page, a self-contained article, or an aside.</prop>
|
|
20
20
|
</defs>
|
|
21
21
|
<template $match>
|
|
22
|
-
<section $when="$as = 'section'"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
<section $when="$as = 'section'">
|
|
23
|
+
<div class="header"><slot name="header"></slot></div>
|
|
24
|
+
<div class="content"><slot></slot></div>
|
|
25
|
+
<div class="actions"><slot name="actions"></slot></div>
|
|
26
|
+
</section>
|
|
27
|
+
<article $when="$as = 'article'">
|
|
28
|
+
<div class="header"><slot name="header"></slot></div>
|
|
29
|
+
<div class="content"><slot></slot></div>
|
|
30
|
+
<div class="actions"><slot name="actions"></slot></div>
|
|
31
|
+
</article>
|
|
32
|
+
<aside $when="$as = 'aside'">
|
|
33
|
+
<div class="header"><slot name="header"></slot></div>
|
|
34
|
+
<div class="content"><slot></slot></div>
|
|
35
|
+
<div class="actions"><slot name="actions"></slot></div>
|
|
36
|
+
</aside>
|
|
37
|
+
<div $else>
|
|
38
|
+
<div class="header"><slot name="header"></slot></div>
|
|
39
|
+
<div class="content"><slot></slot></div>
|
|
40
|
+
<div class="actions"><slot name="actions"></slot></div>
|
|
41
|
+
</div>
|
|
26
42
|
</template>
|
|
27
43
|
<style>
|
|
28
44
|
/* A surface that groups content. Its children stack with even space between them, so a card
|
|
@@ -34,7 +50,11 @@
|
|
|
34
50
|
--_ui-selection-context-surface: initial;
|
|
35
51
|
--_ui-selection-context-border: initial;
|
|
36
52
|
--_ui-selection-context-text: initial;
|
|
37
|
-
|
|
53
|
+
--_ui-card-layout: var(--_ui-card-group-layout, flex);
|
|
54
|
+
--_ui-card-region-layout: var(--_ui-card-group-region-layout, contents);
|
|
55
|
+
display: var(--_ui-card-layout) !important;
|
|
56
|
+
grid-template-rows: var(--_ui-card-group-rows, none) !important;
|
|
57
|
+
grid-row: var(--_ui-card-group-span, auto) !important;
|
|
38
58
|
flex-direction: column !important;
|
|
39
59
|
gap: var(--ui-space-4) !important;
|
|
40
60
|
box-sizing: border-box !important;
|
|
@@ -46,6 +66,20 @@
|
|
|
46
66
|
color: var(--_ui-surface-text, var(--ui-text-primary));
|
|
47
67
|
}
|
|
48
68
|
|
|
69
|
+
.header,
|
|
70
|
+
.content,
|
|
71
|
+
.actions {
|
|
72
|
+
display: var(--_ui-card-region-layout) !important;
|
|
73
|
+
flex-direction: column !important;
|
|
74
|
+
gap: inherit !important;
|
|
75
|
+
min-inline-size: 0;
|
|
76
|
+
/* Group context stops at this card; nested cards start a fresh layout. */
|
|
77
|
+
--_ui-card-group-layout: initial;
|
|
78
|
+
--_ui-card-group-rows: initial;
|
|
79
|
+
--_ui-card-group-span: initial;
|
|
80
|
+
--_ui-card-group-region-layout: initial;
|
|
81
|
+
}
|
|
82
|
+
|
|
49
83
|
:host([padding="xs"]) {
|
|
50
84
|
gap: var(--ui-space-1) !important;
|
|
51
85
|
padding: var(--ui-space-2) !important;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<link rel="component" href="../ui-grid/ui-grid.html">
|
|
2
|
+
<link rel="component" href="../ui-card/ui-card.html">
|
|
3
|
+
<template component="ui-card-group">
|
|
4
|
+
<defs>
|
|
5
|
+
<prop name="gap" type="keyword" values="xs, s, m, l, xl" default="l"
|
|
6
|
+
>Space between cards, using Grid’s spacing scale. Grid’s public --ui-grid-gap custom property also applies.</prop>
|
|
7
|
+
<prop name="min" type="keyword" values="sm, md, lg" default="lg"
|
|
8
|
+
>Minimum card column width: sm is 12rem, md 16rem and lg 20rem. A narrower container still fits one column.</prop>
|
|
9
|
+
<prop name="columns" type="integer">Maximum columns when there is room. Omit for no cap; cards wrap as the container narrows.</prop>
|
|
10
|
+
</defs>
|
|
11
|
+
<div>
|
|
12
|
+
<ui-grid from:gap="$gap" from:min="$min" from:columns="$columns"><slot></slot></ui-grid>
|
|
13
|
+
</div>
|
|
14
|
+
<style>
|
|
15
|
+
/* Grid owns columns and spacing; Card owns its surface and three aligned regions. */
|
|
16
|
+
:host {
|
|
17
|
+
display: block !important;
|
|
18
|
+
min-inline-size: 0;
|
|
19
|
+
max-inline-size: 100%;
|
|
20
|
+
--_ui-card-group-layout: grid;
|
|
21
|
+
--_ui-card-group-rows: subgrid;
|
|
22
|
+
--_ui-card-group-span: span 3;
|
|
23
|
+
--_ui-card-group-region-layout: flex;
|
|
24
|
+
}
|
|
25
|
+
:host[hidden] {
|
|
26
|
+
display: none !important;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
</template>
|
|
@@ -47,6 +47,9 @@
|
|
|
47
47
|
>Lets the user choose several options. Each choice becomes a removable badge before the input, the list stays open between picks, and choosing a checked
|
|
48
48
|
option removes it. items-change then reports the whole list of items, and selected-values-change the list of their values; use selectedValues or items,
|
|
49
49
|
not value, in this mode.</prop>
|
|
50
|
+
<prop name="maxRows" type="integer" default="1"
|
|
51
|
+
>Visible rows of selected items and typing space in multiple mode. More than one lets the field grow and wrap before extra rows scroll vertically inside it.
|
|
52
|
+
One or less keeps the single horizontally scrolling row; single-selection fields are unchanged.</prop>
|
|
50
53
|
<prop name="tokenSeparators" type="list(string)"
|
|
51
54
|
>Keys that commit the typed text in multiple mode, as KeyboardEvent key values such as "," or ";". The text is added as the option whose label matches it,
|
|
52
55
|
ignoring case, or with allowCreate is reported as create-item; otherwise it stays in the input.</prop>
|
|
@@ -427,7 +430,7 @@
|
|
|
427
430
|
*</template></label>
|
|
428
431
|
<div class="control">
|
|
429
432
|
<div class="field" $ref="field">
|
|
430
|
-
<div class="entry">
|
|
433
|
+
<div class="entry" class:multiline="$multiple and $maxRows > 1" style:--_max-rows="$maxRows">
|
|
431
434
|
<span class="start"><slot name="start"></slot></span>
|
|
432
435
|
<template $if="$multiple">
|
|
433
436
|
<button
|
|
@@ -850,6 +853,7 @@
|
|
|
850
853
|
/* Multiple mode keeps one control height. Chips and the input scroll within the entry,
|
|
851
854
|
while the clear and disclosure controls remain fixed at the end of the field. */
|
|
852
855
|
:host([multiple]) .field {
|
|
856
|
+
--_item-row: 1.75rem;
|
|
853
857
|
align-items: center !important;
|
|
854
858
|
min-block-size: var(--_ui-combobox-item-min-block-size, var(--_row));
|
|
855
859
|
padding: var(--ui-space-1) !important;
|
|
@@ -867,24 +871,40 @@
|
|
|
867
871
|
max-block-size: none;
|
|
868
872
|
flex: 1 0 var(--_ui-combobox-item-input-min-inline-size, 5rem);
|
|
869
873
|
width: auto;
|
|
870
|
-
min-block-size:
|
|
874
|
+
min-block-size: var(--_item-row);
|
|
871
875
|
padding: var(--ui-space-0-5) var(--ui-space-1) !important;
|
|
872
876
|
}
|
|
873
877
|
/* Size variants keep their control height as selections are added. */
|
|
874
878
|
:host([multiple]):host([size="sm"]) .field {
|
|
879
|
+
--_item-row: calc(var(--_row) - 2 * var(--ui-border-width) - 2 * var(--ui-space-0-5));
|
|
875
880
|
min-block-size: 0;
|
|
876
881
|
padding: var(--ui-space-0-5) !important;
|
|
877
882
|
}
|
|
878
883
|
:host([multiple]):host([size="sm"]) input {
|
|
879
|
-
min-block-size:
|
|
884
|
+
min-block-size: var(--_item-row);
|
|
880
885
|
padding: 0 var(--ui-space-1) !important;
|
|
881
886
|
}
|
|
882
887
|
/* A large multiple field starts at the large control height, as sm starts at the small one. */
|
|
883
888
|
:host([multiple]):host([size="lg"]) .field {
|
|
889
|
+
--_item-row: calc(var(--ui-control-size-lg) - 2 * var(--ui-border-width) - 2 * var(--ui-space-1));
|
|
884
890
|
min-block-size: 0;
|
|
885
891
|
}
|
|
886
892
|
:host([multiple]):host([size="lg"]) input {
|
|
887
|
-
min-block-size:
|
|
893
|
+
min-block-size: var(--_item-row);
|
|
894
|
+
}
|
|
895
|
+
/* Grow through the requested rows, then keep the typing row in a bounded field.
|
|
896
|
+
The entry owns its scroll; clear/disclosure actions remain outside it. */
|
|
897
|
+
:host([multiple]) .entry.multiline {
|
|
898
|
+
/* The field owns its nominal row size; nested badges keep their own sizing hooks. */
|
|
899
|
+
--_entry-row: max(1.5rem, var(--_item-row));
|
|
900
|
+
flex-wrap: wrap !important;
|
|
901
|
+
align-content: flex-start !important;
|
|
902
|
+
max-block-size: calc(var(--_max-rows) * var(--_entry-row) + (var(--_max-rows) - 1) * var(--ui-space-1));
|
|
903
|
+
overflow-x: hidden;
|
|
904
|
+
overflow-y: auto;
|
|
905
|
+
}
|
|
906
|
+
.entry.multiline .item {
|
|
907
|
+
min-block-size: var(--_entry-row);
|
|
888
908
|
}
|
|
889
909
|
.item {
|
|
890
910
|
appearance: none;
|
|
@@ -497,6 +497,9 @@ export function connect(host) {
|
|
|
497
497
|
void validateCurrent();
|
|
498
498
|
};
|
|
499
499
|
const onFocusin = (event) => {
|
|
500
|
+
if (host.props.multiple.value && host.props.maxRows.value > 1 && field.contains(event.target)) {
|
|
501
|
+
revealActiveItem(field, () => document.activeElement);
|
|
502
|
+
}
|
|
500
503
|
if (event.target === input && host.props.openOnFocus.value && !host.state.expanded && !suppressFocusOpening) openFromField();
|
|
501
504
|
};
|
|
502
505
|
const onCompositionstart = (event) => { if (event.target === input) composing = true; };
|
|
@@ -585,10 +588,13 @@ export function connect(host) {
|
|
|
585
588
|
if (host.props.query.value !== lastQuery) { lastQuery = host.props.query.value; syncQuery(); }
|
|
586
589
|
if (host.props.disabled.value || host.props.readonly.value) close();
|
|
587
590
|
updateView();
|
|
591
|
+
if (host.props.multiple.value && host.props.maxRows.value > 1
|
|
592
|
+
&& document.activeElement && field.contains(document.activeElement)) revealActiveItem(field, () => document.activeElement);
|
|
588
593
|
});
|
|
589
594
|
|
|
590
595
|
return () => {
|
|
591
596
|
alive = false;
|
|
597
|
+
cancelActiveItemReveal(field);
|
|
592
598
|
stop();
|
|
593
599
|
stopReset();
|
|
594
600
|
observer.disconnect();
|
|
@@ -71,23 +71,25 @@
|
|
|
71
71
|
justify-items: center !important;
|
|
72
72
|
margin-inline-start: auto !important;
|
|
73
73
|
}
|
|
74
|
-
/*
|
|
74
|
+
/* Brand, navigation and actions centre their own containers, including mixed font sizes. */
|
|
75
75
|
.identity {
|
|
76
76
|
display: flex !important;
|
|
77
77
|
flex: 1 1 0;
|
|
78
78
|
flex-wrap: wrap !important;
|
|
79
|
-
align-items:
|
|
79
|
+
align-items: center !important;
|
|
80
80
|
gap: var(--ui-space-2) var(--ui-space-6) !important;
|
|
81
81
|
min-inline-size: 0;
|
|
82
82
|
}
|
|
83
83
|
.brand {
|
|
84
|
+
display: flex !important;
|
|
85
|
+
align-items: center !important;
|
|
84
86
|
min-inline-size: 0;
|
|
85
87
|
font-size: var(--ui-font-size-lg);
|
|
86
88
|
font-weight: var(--ui-font-bold);
|
|
87
89
|
}
|
|
88
90
|
.brand > :slotted(a) {
|
|
89
91
|
display: inline-flex !important;
|
|
90
|
-
align-items:
|
|
92
|
+
align-items: center !important;
|
|
91
93
|
gap: var(--ui-space-3) !important;
|
|
92
94
|
min-inline-size: 0;
|
|
93
95
|
max-inline-size: 100%;
|
|
@@ -97,7 +99,7 @@
|
|
|
97
99
|
.navigation {
|
|
98
100
|
display: flex !important;
|
|
99
101
|
flex-wrap: wrap !important;
|
|
100
|
-
align-items:
|
|
102
|
+
align-items: center !important;
|
|
101
103
|
gap: var(--ui-space-2) var(--ui-space-5) !important;
|
|
102
104
|
min-inline-size: 0;
|
|
103
105
|
font-size: var(--ui-font-size-sm);
|
|
@@ -139,7 +141,7 @@
|
|
|
139
141
|
.inline-navigation {
|
|
140
142
|
position: static;
|
|
141
143
|
display: flex !important;
|
|
142
|
-
align-items:
|
|
144
|
+
align-items: center !important;
|
|
143
145
|
min-inline-size: 0;
|
|
144
146
|
max-inline-size: none;
|
|
145
147
|
margin: 0 !important;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
<template component="ui-top-bar">
|
|
1
|
+
<template component="ui-top-bar" module="./ui-top-bar.js">
|
|
2
|
+
<defs>
|
|
3
|
+
<prop name="titleFor" type="string" default=""
|
|
4
|
+
>The ID of the page heading represented by the default title slot. While that heading is visible below the sticky bar, its duplicate title is concealed.
|
|
5
|
+
After the heading scrolls above the bar, the single-line title slides up and fades in. Leading and action slots stay available, and the bar keeps its
|
|
6
|
+
size. Omit it for an always-visible title. Reduced motion removes the transition.</prop>
|
|
7
|
+
<state name="titleOutOfView" type="boolean" value="false"></state>
|
|
8
|
+
<computed name="titleHidden" from="not ($titleFor = '') and not $titleOutOfView"></computed>
|
|
9
|
+
</defs>
|
|
2
10
|
<header>
|
|
3
11
|
<div class="leading"><slot name="leading"></slot></div>
|
|
4
|
-
<div class="title"
|
|
12
|
+
<div class="title" class:scroll-title="not ($titleFor = '')" class:concealed="$titleHidden" from:aria-hidden="$titleHidden" from:inert="$titleHidden">
|
|
13
|
+
<slot></slot>
|
|
14
|
+
</div>
|
|
5
15
|
<div class="search"><slot name="search"></slot></div>
|
|
6
16
|
<div class="actions"><slot name="actions"></slot></div>
|
|
7
17
|
</header>
|
|
@@ -40,6 +50,26 @@
|
|
|
40
50
|
min-inline-size: 0;
|
|
41
51
|
flex: 1;
|
|
42
52
|
}
|
|
53
|
+
.title.scroll-title {
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
text-overflow: ellipsis;
|
|
57
|
+
opacity: 1;
|
|
58
|
+
transform: translateY(0);
|
|
59
|
+
transition: opacity var(--ui-motion-fast) var(--ui-motion-ease), transform var(--ui-motion-fast) var(--ui-motion-ease);
|
|
60
|
+
}
|
|
61
|
+
.title.scroll-title.concealed {
|
|
62
|
+
opacity: 0;
|
|
63
|
+
transform: translateY(var(--ui-space-2));
|
|
64
|
+
pointer-events: none;
|
|
65
|
+
}
|
|
66
|
+
@media (prefers-reduced-motion: reduce) {
|
|
67
|
+
.title.scroll-title,
|
|
68
|
+
.title.scroll-title.concealed {
|
|
69
|
+
transition: none;
|
|
70
|
+
transform: none;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
43
73
|
|
|
44
74
|
/* An unused region takes no space, so it adds no gap. */
|
|
45
75
|
.leading:empty,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createIdResolver } from "../shared/overlay.js";
|
|
2
|
+
|
|
3
|
+
/** Reveal the duplicate title at the sticky edge; scroll never drives animation progress. */
|
|
4
|
+
export function connect(host) {
|
|
5
|
+
const element = host.element;
|
|
6
|
+
const document = element.ownerDocument;
|
|
7
|
+
const view = document.defaultView;
|
|
8
|
+
let observer = null;
|
|
9
|
+
let heading = null;
|
|
10
|
+
let bottom = -1;
|
|
11
|
+
let frame = 0;
|
|
12
|
+
let alive = true;
|
|
13
|
+
const resolver = createIdResolver(document, () => sync());
|
|
14
|
+
|
|
15
|
+
function sync() {
|
|
16
|
+
if (!alive) return;
|
|
17
|
+
const id = host.props.titleFor.value;
|
|
18
|
+
const next = resolver.get(id);
|
|
19
|
+
const edge = Math.max(0, element.getBoundingClientRect().bottom);
|
|
20
|
+
if (next === heading && Math.abs(edge - bottom) < 0.5 && observer) return;
|
|
21
|
+
observer?.disconnect();
|
|
22
|
+
observer = null;
|
|
23
|
+
heading = next;
|
|
24
|
+
bottom = edge;
|
|
25
|
+
if (!id || !heading || !view.IntersectionObserver) {
|
|
26
|
+
host.state.titleOutOfView = Boolean(id);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
observer = new view.IntersectionObserver(entries => {
|
|
30
|
+
if (!alive) return;
|
|
31
|
+
const entry = entries.at(-1);
|
|
32
|
+
if (entry?.target !== heading) return;
|
|
33
|
+
if (!heading?.isConnected) { sync(); return; }
|
|
34
|
+
host.state.titleOutOfView = !entry.isIntersecting && entry.boundingClientRect.top < bottom;
|
|
35
|
+
}, { rootMargin: `-${bottom}px 0px 0px 0px` });
|
|
36
|
+
observer.observe(heading);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Nested scrollports may move the bar before it becomes sticky. Rebuild its
|
|
40
|
+
// observation boundary only when that edge changes, not for every scroll tick.
|
|
41
|
+
const schedule = () => {
|
|
42
|
+
if (frame || !host.props.titleFor.value) return;
|
|
43
|
+
frame = view.requestAnimationFrame(() => { frame = 0; sync(); });
|
|
44
|
+
};
|
|
45
|
+
const resize = new view.ResizeObserver(schedule);
|
|
46
|
+
resize.observe(element);
|
|
47
|
+
document.addEventListener("scroll", schedule, { capture: true, passive: true });
|
|
48
|
+
view.addEventListener("resize", schedule);
|
|
49
|
+
const stop = host.effect(sync);
|
|
50
|
+
return () => {
|
|
51
|
+
alive = false;
|
|
52
|
+
stop();
|
|
53
|
+
resolver.stop();
|
|
54
|
+
observer?.disconnect();
|
|
55
|
+
resize.disconnect();
|
|
56
|
+
if (frame) view.cancelAnimationFrame(frame);
|
|
57
|
+
document.removeEventListener("scroll", schedule, true);
|
|
58
|
+
view.removeEventListener("resize", schedule);
|
|
59
|
+
};
|
|
60
|
+
}
|