@astronox/core 0.4.5 → 0.4.7
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/package.json +1 -1
- package/src/components/feedback/PreferenceBootstrap/PreferenceBootstrap.astro +13 -2
- package/src/components/forms/PreparedFormBootstrap/PreparedFormBootstrap.astro +7 -1
- package/src/composition/Grid/Grid.css +0 -37
- package/src/composition/Stack/Stack.astro +1 -1
- package/src/composition/Stack/Stack.css +4 -0
- package/src/composition/SurfaceGroup/SurfaceGroup.css +23 -18
- package/src/composition/SurfaceGroup/stickySurfaceGroupController.ts +15 -11
- package/src/pages/.gitkeep +1 -0
- package/src/patterns/Table/Table.css +3 -6
- package/src/patterns/Table/TableFilterPanel.css +20 -10
- package/src/patterns/Table/TablePagination.css +3 -10
- package/src/patterns/Table/tableClientController.ts +7 -2
- package/src/patterns/Table/tableFilterController.ts +6 -0
- package/src/patterns/Table/tableProgressiveController.ts +5 -2
- package/src/patterns/Table/tableSortController.ts +2 -0
- package/src/patterns/Table/tableViewport.ts +46 -0
package/package.json
CHANGED
|
@@ -16,9 +16,20 @@ const payload = definitions.map((definition) => ({
|
|
|
16
16
|
}));
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
<script is:inline
|
|
19
|
+
<script is:inline data-preference-definitions={JSON.stringify(payload)}>
|
|
20
20
|
(() => {
|
|
21
|
-
|
|
21
|
+
const bootstrapScript = document.currentScript;
|
|
22
|
+
if (!(bootstrapScript instanceof HTMLScriptElement)) return;
|
|
23
|
+
|
|
24
|
+
let definitions;
|
|
25
|
+
try {
|
|
26
|
+
definitions = JSON.parse(
|
|
27
|
+
bootstrapScript.dataset.preferenceDefinitions ?? '[]',
|
|
28
|
+
);
|
|
29
|
+
} catch {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!Array.isArray(definitions) || definitions.length === 0) return;
|
|
22
33
|
|
|
23
34
|
const globalKey = '__astronoxPreferenceSnapshot';
|
|
24
35
|
const changeEvent = 'astronox:preference-change';
|
|
@@ -7,8 +7,14 @@ type Props = {
|
|
|
7
7
|
const { formId, stateKey }: Props = Astro.props;
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
<script is:inline
|
|
10
|
+
<script is:inline data-form-id={formId} data-state-key={stateKey}>
|
|
11
11
|
(() => {
|
|
12
|
+
const bootstrapScript = document.currentScript;
|
|
13
|
+
if (!(bootstrapScript instanceof HTMLScriptElement)) return;
|
|
14
|
+
const formId = bootstrapScript.dataset.formId;
|
|
15
|
+
const stateKey = bootstrapScript.dataset.stateKey;
|
|
16
|
+
if (!formId || !stateKey) return;
|
|
17
|
+
|
|
12
18
|
const isRecord = (value) =>
|
|
13
19
|
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
14
20
|
const readState = () => {
|
|
@@ -103,31 +103,6 @@
|
|
|
103
103
|
grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
.grid[data-layout='content-sidebar']:where(
|
|
107
|
-
:has(> [data-composition='grid-item'][data-position='sticky'])
|
|
108
|
-
) {
|
|
109
|
-
--grid-sticky-viewport-block-size: calc(
|
|
110
|
-
100vh - var(--nox-site-header-height) - var(--nox-layout-gap) * 2
|
|
111
|
-
);
|
|
112
|
-
--grid-sticky-viewport-block-size: calc(
|
|
113
|
-
100dvh - var(--nox-site-header-height) - var(--nox-layout-gap) * 2
|
|
114
|
-
);
|
|
115
|
-
--grid-sticky-peer-position: sticky;
|
|
116
|
-
--grid-sticky-peer-inset-block-start: var(--nox-layout-gap);
|
|
117
|
-
--table-progressive-runway-block-size: var(--grid-sticky-viewport-block-size);
|
|
118
|
-
|
|
119
|
-
min-block-size: var(--grid-sticky-viewport-block-size);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.grid[data-layout='content-sidebar']:where(
|
|
123
|
-
:has(> [data-composition='grid-item'][data-position='sticky'])
|
|
124
|
-
)
|
|
125
|
-
> [data-composition='grid-item'][data-position='static']
|
|
126
|
-
> .grid-item__content {
|
|
127
|
-
position: var(--grid-sticky-peer-position);
|
|
128
|
-
inset-block-start: var(--grid-sticky-peer-inset-block-start);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
106
|
.grid[data-rows] {
|
|
132
107
|
grid-template-rows: repeat(var(--grid-rows), minmax(0, 1fr));
|
|
133
108
|
}
|
|
@@ -137,9 +112,6 @@
|
|
|
137
112
|
[data-layout='fixed'],
|
|
138
113
|
[data-layout='content-sidebar']
|
|
139
114
|
)[data-collapse-at='sm'] {
|
|
140
|
-
--grid-sticky-viewport-block-size: 0px;
|
|
141
|
-
--grid-sticky-peer-position: static;
|
|
142
|
-
--grid-sticky-peer-inset-block-start: auto;
|
|
143
115
|
grid-template-columns: 1fr;
|
|
144
116
|
}
|
|
145
117
|
|
|
@@ -192,9 +164,6 @@
|
|
|
192
164
|
[data-layout='fixed'],
|
|
193
165
|
[data-layout='content-sidebar']
|
|
194
166
|
)[data-collapse-at='md'] {
|
|
195
|
-
--grid-sticky-viewport-block-size: 0px;
|
|
196
|
-
--grid-sticky-peer-position: static;
|
|
197
|
-
--grid-sticky-peer-inset-block-start: auto;
|
|
198
167
|
grid-template-columns: 1fr;
|
|
199
168
|
}
|
|
200
169
|
|
|
@@ -247,9 +216,6 @@
|
|
|
247
216
|
[data-layout='fixed'],
|
|
248
217
|
[data-layout='content-sidebar']
|
|
249
218
|
)[data-collapse-at='lg'] {
|
|
250
|
-
--grid-sticky-viewport-block-size: 0px;
|
|
251
|
-
--grid-sticky-peer-position: static;
|
|
252
|
-
--grid-sticky-peer-inset-block-start: auto;
|
|
253
219
|
grid-template-columns: 1fr;
|
|
254
220
|
}
|
|
255
221
|
|
|
@@ -302,9 +268,6 @@
|
|
|
302
268
|
[data-layout='fixed'],
|
|
303
269
|
[data-layout='content-sidebar']
|
|
304
270
|
)[data-collapse-at='xl'] {
|
|
305
|
-
--grid-sticky-viewport-block-size: 0px;
|
|
306
|
-
--grid-sticky-peer-position: static;
|
|
307
|
-
--grid-sticky-peer-inset-block-start: auto;
|
|
308
271
|
grid-template-columns: 1fr;
|
|
309
272
|
}
|
|
310
273
|
|
|
@@ -3,7 +3,7 @@ import type { HTMLAttributes } from 'astro/types';
|
|
|
3
3
|
import type { Tone } from '../../theme/contracts';
|
|
4
4
|
|
|
5
5
|
type StackElement = 'div' | 'form' | 'section' | 'nav';
|
|
6
|
-
type StackGap = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
|
+
type StackGap = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'layout';
|
|
7
7
|
type StackAttributes = HTMLAttributes<'div'> &
|
|
8
8
|
HTMLAttributes<'form'> &
|
|
9
9
|
HTMLAttributes<'section'> &
|
|
@@ -16,29 +16,26 @@
|
|
|
16
16
|
pointer-events: none;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.surface-group:has(> [data-sticky-surface]) {
|
|
20
|
+
--surface-group-sticky-surface-block-size: var(
|
|
21
|
+
--nox-section-responsive-block-size
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
.surface-group:has(> [data-sticky-surface])::before {
|
|
26
|
+
--surface-group-sticky-occlusion-size: calc(
|
|
27
|
+
var(--nox-layout-gap) + var(--surface-group-sticky-surface-block-size)
|
|
28
|
+
);
|
|
29
|
+
|
|
20
30
|
position: sticky;
|
|
21
31
|
z-index: 39;
|
|
22
32
|
top: 0;
|
|
23
33
|
display: block;
|
|
24
34
|
min-width: 0;
|
|
25
|
-
min-height: var(
|
|
26
|
-
--surface-group-sticky-occlusion-size,
|
|
27
|
-
calc(var(--nox-layout-gap) + var(--nox-section-responsive-block-size))
|
|
28
|
-
);
|
|
35
|
+
min-height: var(--surface-group-sticky-occlusion-size);
|
|
29
36
|
visibility: hidden;
|
|
30
|
-
flex: 0 0
|
|
31
|
-
|
|
32
|
-
--surface-group-sticky-occlusion-size,
|
|
33
|
-
calc(var(--nox-layout-gap) + var(--nox-section-responsive-block-size))
|
|
34
|
-
);
|
|
35
|
-
margin-block-end: calc(
|
|
36
|
-
-1 *
|
|
37
|
-
var(
|
|
38
|
-
--surface-group-sticky-occlusion-size,
|
|
39
|
-
calc(var(--nox-layout-gap) + var(--nox-section-responsive-block-size))
|
|
40
|
-
)
|
|
41
|
-
);
|
|
37
|
+
flex: 0 0 var(--surface-group-sticky-occlusion-size);
|
|
38
|
+
margin-block-end: calc(-1 * var(--surface-group-sticky-occlusion-size));
|
|
42
39
|
background: var(--nox-page-background);
|
|
43
40
|
content: '';
|
|
44
41
|
}
|
|
@@ -69,8 +66,8 @@
|
|
|
69
66
|
|
|
70
67
|
.surface-group
|
|
71
68
|
> [data-surface]:not([hidden]):has(~ [data-surface]:not([hidden])) {
|
|
72
|
-
border-end-start-radius:
|
|
73
|
-
border-end-end-radius:
|
|
69
|
+
border-end-start-radius: 0;
|
|
70
|
+
border-end-end-radius: 0;
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
.surface-group > [data-surface]:not([hidden]) ~ [data-surface]:not([hidden]) {
|
|
@@ -78,3 +75,11 @@
|
|
|
78
75
|
border-start-start-radius: 0;
|
|
79
76
|
border-start-end-radius: 0;
|
|
80
77
|
}
|
|
78
|
+
|
|
79
|
+
@container nox-surface-group (width < 32rem) {
|
|
80
|
+
.surface-group:has(> [data-sticky-surface]) {
|
|
81
|
+
--surface-group-sticky-surface-block-size: var(
|
|
82
|
+
--nox-section-compact-block-size
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const noop = () => {};
|
|
2
|
+
const stickySurfaceBlockSizeProperty =
|
|
3
|
+
'--surface-group-sticky-surface-block-size';
|
|
2
4
|
|
|
3
5
|
const getScrollParent = (element: HTMLElement): HTMLElement | Window => {
|
|
4
6
|
let parent = element.parentElement;
|
|
@@ -37,19 +39,23 @@ export const initStickySurfaceGroup = (root: HTMLElement): (() => void) => {
|
|
|
37
39
|
stickySurface.before(sentinel);
|
|
38
40
|
|
|
39
41
|
let observer: IntersectionObserver | null = null;
|
|
42
|
+
let surfaceResizeObserver: ResizeObserver | null = null;
|
|
40
43
|
let resizeFrame = 0;
|
|
41
44
|
|
|
42
45
|
const observe = () => {
|
|
43
46
|
resizeFrame = 0;
|
|
44
47
|
observer?.disconnect();
|
|
45
|
-
|
|
48
|
+
|
|
49
|
+
const stickySurfaceBlockSize = stickySurface.getBoundingClientRect().height;
|
|
50
|
+
if (stickySurfaceBlockSize > 0) {
|
|
51
|
+
root.style.setProperty(
|
|
52
|
+
stickySurfaceBlockSizeProperty,
|
|
53
|
+
`${stickySurfaceBlockSize}px`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
46
56
|
|
|
47
57
|
const stickyOffset =
|
|
48
58
|
Number.parseFloat(window.getComputedStyle(stickySurface).top) || 0;
|
|
49
|
-
root.style.setProperty(
|
|
50
|
-
'--surface-group-sticky-occlusion-size',
|
|
51
|
-
`${stickyOffset + stickySurface.getBoundingClientRect().height}px`,
|
|
52
|
-
);
|
|
53
59
|
observer = new IntersectionObserver(
|
|
54
60
|
([entry]) => {
|
|
55
61
|
if (!entry) return;
|
|
@@ -59,7 +65,6 @@ export const initStickySurfaceGroup = (root: HTMLElement): (() => void) => {
|
|
|
59
65
|
'data-sticky-active',
|
|
60
66
|
entry.boundingClientRect.top <= activationBoundary + 0.5,
|
|
61
67
|
);
|
|
62
|
-
root.setAttribute('data-sticky-measured', 'true');
|
|
63
68
|
},
|
|
64
69
|
{
|
|
65
70
|
root: scrollParent instanceof Window ? null : scrollParent,
|
|
@@ -78,15 +83,15 @@ export const initStickySurfaceGroup = (root: HTMLElement): (() => void) => {
|
|
|
78
83
|
|
|
79
84
|
root.setAttribute('data-sticky-initialized', 'true');
|
|
80
85
|
window.addEventListener('resize', scheduleObserve, { passive: true });
|
|
81
|
-
|
|
86
|
+
surfaceResizeObserver =
|
|
82
87
|
'ResizeObserver' in window ? new ResizeObserver(scheduleObserve) : null;
|
|
83
|
-
|
|
88
|
+
surfaceResizeObserver?.observe(stickySurface);
|
|
84
89
|
observe();
|
|
85
90
|
|
|
86
91
|
return () => {
|
|
87
92
|
window.removeEventListener('resize', scheduleObserve);
|
|
88
|
-
resizeObserver?.disconnect();
|
|
89
93
|
observer?.disconnect();
|
|
94
|
+
surfaceResizeObserver?.disconnect();
|
|
90
95
|
sentinel.remove();
|
|
91
96
|
|
|
92
97
|
if (resizeFrame !== 0) {
|
|
@@ -95,7 +100,6 @@ export const initStickySurfaceGroup = (root: HTMLElement): (() => void) => {
|
|
|
95
100
|
|
|
96
101
|
root.removeAttribute('data-sticky-active');
|
|
97
102
|
root.removeAttribute('data-sticky-initialized');
|
|
98
|
-
root.
|
|
99
|
-
root.style.removeProperty('--surface-group-sticky-occlusion-size');
|
|
103
|
+
root.style.removeProperty(stickySurfaceBlockSizeProperty);
|
|
100
104
|
};
|
|
101
105
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -49,7 +49,9 @@
|
|
|
49
49
|
|
|
50
50
|
.table[data-table-sticky-header]:has([data-sticky-surface])
|
|
51
51
|
[data-table-header] {
|
|
52
|
-
top: calc(
|
|
52
|
+
top: calc(
|
|
53
|
+
var(--nox-layout-gap) + var(--surface-group-sticky-surface-block-size)
|
|
54
|
+
);
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
@container nox-table (width < 32rem) {
|
|
@@ -57,11 +59,6 @@
|
|
|
57
59
|
--table-cell-padding-inline: var(--nox-space-1);
|
|
58
60
|
--table-edge-padding-inline: var(--nox-space-2);
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
.table[data-table-sticky-header]:has([data-sticky-surface])
|
|
62
|
-
[data-table-header] {
|
|
63
|
-
top: calc(var(--nox-layout-gap) + var(--nox-section-compact-block-size));
|
|
64
|
-
}
|
|
65
62
|
}
|
|
66
63
|
|
|
67
64
|
@container nox-table (width < 36rem) {
|
|
@@ -28,8 +28,10 @@
|
|
|
28
28
|
|
|
29
29
|
.table-filter-panel[data-table-filter-panel-compact]:not(
|
|
30
30
|
[data-table-filter-panel-open]
|
|
31
|
-
)
|
|
32
|
-
|
|
31
|
+
)
|
|
32
|
+
> .card-header {
|
|
33
|
+
border-end-start-radius: var(--nox-radius-md);
|
|
34
|
+
border-end-end-radius: var(--nox-radius-md);
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
.table-filter-panel[data-table-filter-panel-compact]:not(
|
|
@@ -47,8 +49,10 @@
|
|
|
47
49
|
@container nox-grid (width < 24rem) {
|
|
48
50
|
.table-filter-panel[data-table-filter-panel-collapse-at='sm']:not(
|
|
49
51
|
[data-table-filter-panel-open]
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
+
)
|
|
53
|
+
> .card-header {
|
|
54
|
+
border-end-start-radius: var(--nox-radius-md);
|
|
55
|
+
border-end-end-radius: var(--nox-radius-md);
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
.table-filter-panel[data-table-filter-panel-collapse-at='sm']
|
|
@@ -69,8 +73,10 @@
|
|
|
69
73
|
@container nox-grid (width < 36rem) {
|
|
70
74
|
.table-filter-panel[data-table-filter-panel-collapse-at='md']:not(
|
|
71
75
|
[data-table-filter-panel-open]
|
|
72
|
-
)
|
|
73
|
-
|
|
76
|
+
)
|
|
77
|
+
> .card-header {
|
|
78
|
+
border-end-start-radius: var(--nox-radius-md);
|
|
79
|
+
border-end-end-radius: var(--nox-radius-md);
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
.table-filter-panel[data-table-filter-panel-collapse-at='md']
|
|
@@ -91,8 +97,10 @@
|
|
|
91
97
|
@container nox-grid (width < 44rem) {
|
|
92
98
|
.table-filter-panel[data-table-filter-panel-collapse-at='lg']:not(
|
|
93
99
|
[data-table-filter-panel-open]
|
|
94
|
-
)
|
|
95
|
-
|
|
100
|
+
)
|
|
101
|
+
> .card-header {
|
|
102
|
+
border-end-start-radius: var(--nox-radius-md);
|
|
103
|
+
border-end-end-radius: var(--nox-radius-md);
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
.table-filter-panel[data-table-filter-panel-collapse-at='lg']
|
|
@@ -113,8 +121,10 @@
|
|
|
113
121
|
@container nox-grid (width < 54rem) {
|
|
114
122
|
.table-filter-panel[data-table-filter-panel-collapse-at='xl']:not(
|
|
115
123
|
[data-table-filter-panel-open]
|
|
116
|
-
)
|
|
117
|
-
|
|
124
|
+
)
|
|
125
|
+
> .card-header {
|
|
126
|
+
border-end-start-radius: var(--nox-radius-md);
|
|
127
|
+
border-end-end-radius: var(--nox-radius-md);
|
|
118
128
|
}
|
|
119
129
|
|
|
120
130
|
.table-filter-panel[data-table-filter-panel-collapse-at='xl']
|
|
@@ -49,19 +49,13 @@
|
|
|
49
49
|
position: relative;
|
|
50
50
|
display: block;
|
|
51
51
|
overflow: visible;
|
|
52
|
-
block-size:
|
|
53
|
-
min-block-size:
|
|
52
|
+
block-size: 0;
|
|
53
|
+
min-block-size: 0;
|
|
54
54
|
border: 0;
|
|
55
55
|
border-radius: 0;
|
|
56
56
|
background: transparent;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
.table-pagination[data-table-progressive-enhanced='true']
|
|
60
|
-
.table-pagination__sentinel {
|
|
61
|
-
inset-block-start: 0;
|
|
62
|
-
inset-block-end: auto;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
59
|
.table-pagination[data-table-progressive-enhanced='true']
|
|
66
60
|
.table-pagination__content {
|
|
67
61
|
block-size: 0;
|
|
@@ -82,8 +76,7 @@
|
|
|
82
76
|
.table-pagination__link:focus-visible {
|
|
83
77
|
z-index: 1;
|
|
84
78
|
inset-inline: 0;
|
|
85
|
-
inset-block-
|
|
86
|
-
inset-block-end: auto;
|
|
79
|
+
inset-block-end: 0;
|
|
87
80
|
display: grid;
|
|
88
81
|
overflow: visible;
|
|
89
82
|
width: auto;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveTableScrollRoot } from './tableViewport';
|
|
2
|
+
|
|
1
3
|
export type ClientTableState = 'ready' | 'empty' | 'error';
|
|
2
4
|
|
|
3
5
|
export type ClientTablePage<TItem> = {
|
|
@@ -90,6 +92,7 @@ export function createClientTablePagination<TItem>({
|
|
|
90
92
|
'[data-table-skeleton-template]',
|
|
91
93
|
);
|
|
92
94
|
const keys = new Set<string>();
|
|
95
|
+
const scrollRoot = resolveTableScrollRoot(root);
|
|
93
96
|
let nextCursor: string | undefined;
|
|
94
97
|
let loading = false;
|
|
95
98
|
let disposed = false;
|
|
@@ -190,7 +193,9 @@ export function createClientTablePagination<TItem>({
|
|
|
190
193
|
shouldContinue = Boolean(
|
|
191
194
|
nextCursor &&
|
|
192
195
|
sentinel &&
|
|
193
|
-
sentinel.getBoundingClientRect().top <=
|
|
196
|
+
sentinel.getBoundingClientRect().top <=
|
|
197
|
+
(scrollRoot?.getBoundingClientRect().bottom ?? window.innerHeight) +
|
|
198
|
+
512,
|
|
194
199
|
);
|
|
195
200
|
} catch (error) {
|
|
196
201
|
if (disposed) return;
|
|
@@ -221,7 +226,7 @@ export function createClientTablePagination<TItem>({
|
|
|
221
226
|
(entries) => {
|
|
222
227
|
if (entries.some((entry) => entry.isIntersecting)) void load(true);
|
|
223
228
|
},
|
|
224
|
-
{ rootMargin: '512px 0px' },
|
|
229
|
+
{ root: scrollRoot, rootMargin: '512px 0px' },
|
|
225
230
|
)
|
|
226
231
|
: null;
|
|
227
232
|
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
hasTableProgressive,
|
|
9
9
|
setTableProgressiveFilters,
|
|
10
10
|
} from './tableProgressiveController';
|
|
11
|
+
import { revealTableStart } from './tableViewport';
|
|
11
12
|
|
|
12
13
|
type FilterValues = Readonly<Record<string, readonly string[]>>;
|
|
13
14
|
|
|
@@ -63,6 +64,8 @@ function setTokenAttribute(
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
export function refreshTableFilters(root: HTMLElement): void {
|
|
67
|
+
const table = root.querySelector<HTMLElement>('[data-table-filter-table]');
|
|
68
|
+
if (table) revealTableStart(table);
|
|
66
69
|
root.dispatchEvent(new Event(refreshEvent));
|
|
67
70
|
}
|
|
68
71
|
|
|
@@ -171,6 +174,7 @@ export function initTableFilters(root: HTMLElement): () => void {
|
|
|
171
174
|
};
|
|
172
175
|
|
|
173
176
|
const handleSearch = (): void => {
|
|
177
|
+
revealTableStart(table);
|
|
174
178
|
scheduleFilters();
|
|
175
179
|
};
|
|
176
180
|
|
|
@@ -187,6 +191,7 @@ export function initTableFilters(root: HTMLElement): () => void {
|
|
|
187
191
|
const field = target.dataset.tableFilterField;
|
|
188
192
|
if (!field) return;
|
|
189
193
|
selections.set(field, customEvent.detail.values[0] ?? '');
|
|
194
|
+
revealTableStart(table);
|
|
190
195
|
scheduleFilters();
|
|
191
196
|
};
|
|
192
197
|
|
|
@@ -198,6 +203,7 @@ export function initTableFilters(root: HTMLElement): () => void {
|
|
|
198
203
|
};
|
|
199
204
|
|
|
200
205
|
const handleReset = (): void => {
|
|
206
|
+
revealTableStart(table);
|
|
201
207
|
if (search) search.value = '';
|
|
202
208
|
for (const field of fields) {
|
|
203
209
|
clearCombobox(field, { emit: false });
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
TableProgressiveModel,
|
|
4
4
|
} from '../../display/contracts';
|
|
5
5
|
import { tableProgressiveBatchSize } from '../../display/tableProgressive';
|
|
6
|
+
import { resolveTableScrollRoot, revealTableStart } from './tableViewport';
|
|
6
7
|
|
|
7
8
|
const initializedAttribute = 'data-table-progressive-initialized';
|
|
8
9
|
|
|
@@ -154,13 +155,15 @@ export function initTableProgressive(root: HTMLElement): () => void {
|
|
|
154
155
|
|
|
155
156
|
registerRows(getRows(activeRowsRoot));
|
|
156
157
|
|
|
158
|
+
const scrollRoot = resolveTableScrollRoot(root);
|
|
159
|
+
|
|
157
160
|
const observer = new IntersectionObserver(
|
|
158
161
|
(observedEntries) => {
|
|
159
162
|
if (observedEntries.some((entry) => entry.isIntersecting)) {
|
|
160
163
|
void renderNextBatch();
|
|
161
164
|
}
|
|
162
165
|
},
|
|
163
|
-
{ rootMargin: '600px 0px' },
|
|
166
|
+
{ root: scrollRoot, rootMargin: '600px 0px' },
|
|
164
167
|
);
|
|
165
168
|
|
|
166
169
|
function registerRows(rows: readonly HTMLElement[]): void {
|
|
@@ -406,7 +409,6 @@ export function initTableProgressive(root: HTMLElement): () => void {
|
|
|
406
409
|
generation += 1;
|
|
407
410
|
request?.abort();
|
|
408
411
|
request = null;
|
|
409
|
-
activePagination.hidden = false;
|
|
410
412
|
updateTableState(state);
|
|
411
413
|
addSkeleton(batchSize);
|
|
412
414
|
detachRenderedRows();
|
|
@@ -518,6 +520,7 @@ export function updateTableProgressiveEntry(
|
|
|
518
520
|
export function refreshTableProgressive(root: HTMLElement): boolean {
|
|
519
521
|
const context = getProgressiveContext(root);
|
|
520
522
|
if (!context) return false;
|
|
523
|
+
revealTableStart(root);
|
|
521
524
|
context.refresh();
|
|
522
525
|
return true;
|
|
523
526
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
setTableProgressiveSort,
|
|
5
5
|
updateTableProgressiveEntry,
|
|
6
6
|
} from './tableProgressiveController';
|
|
7
|
+
import { revealTableStart } from './tableViewport';
|
|
7
8
|
|
|
8
9
|
type SortDirection = 'ascending' | 'descending';
|
|
9
10
|
type SortType = 'number' | 'text';
|
|
@@ -161,6 +162,7 @@ export function initTableSort(root: HTMLElement): () => void {
|
|
|
161
162
|
state = null;
|
|
162
163
|
}
|
|
163
164
|
|
|
165
|
+
revealTableStart(root);
|
|
164
166
|
updateButtons();
|
|
165
167
|
if (!setTableProgressiveSort(root, state)) scheduleSort();
|
|
166
168
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
type TableStartScrollInput = {
|
|
2
|
+
currentScrollTop: number;
|
|
3
|
+
stickyOffset: number;
|
|
4
|
+
tableTop: number;
|
|
5
|
+
viewportTop: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function resolveTableStartScrollTop({
|
|
9
|
+
currentScrollTop,
|
|
10
|
+
stickyOffset,
|
|
11
|
+
tableTop,
|
|
12
|
+
viewportTop,
|
|
13
|
+
}: TableStartScrollInput): number {
|
|
14
|
+
const targetTop = viewportTop + stickyOffset;
|
|
15
|
+
if (tableTop >= targetTop) return currentScrollTop;
|
|
16
|
+
|
|
17
|
+
return Math.max(0, currentScrollTop + tableTop - targetTop);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function resolveTableScrollRoot(root: HTMLElement): HTMLElement | null {
|
|
21
|
+
return root.closest<HTMLElement>('[data-site-viewport]');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function resolveTableStickyOffset(root: HTMLElement): number {
|
|
25
|
+
const stickySurface = root.querySelector<HTMLElement>(
|
|
26
|
+
'[data-sticky-surface]',
|
|
27
|
+
);
|
|
28
|
+
if (!stickySurface) return 0;
|
|
29
|
+
|
|
30
|
+
return Number.parseFloat(window.getComputedStyle(stickySurface).top) || 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function revealTableStart(root: HTMLElement): void {
|
|
34
|
+
const scrollRoot = resolveTableScrollRoot(root);
|
|
35
|
+
if (!scrollRoot) return;
|
|
36
|
+
|
|
37
|
+
const nextScrollTop = resolveTableStartScrollTop({
|
|
38
|
+
currentScrollTop: scrollRoot.scrollTop,
|
|
39
|
+
stickyOffset: resolveTableStickyOffset(root),
|
|
40
|
+
tableTop: root.getBoundingClientRect().top,
|
|
41
|
+
viewportTop: scrollRoot.getBoundingClientRect().top,
|
|
42
|
+
});
|
|
43
|
+
if (nextScrollTop !== scrollRoot.scrollTop) {
|
|
44
|
+
scrollRoot.scrollTop = nextScrollTop;
|
|
45
|
+
}
|
|
46
|
+
}
|