@astronox/core 0.4.4 → 0.4.6
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/SurfaceGroup/SurfaceGroup.css +17 -18
- package/src/composition/SurfaceGroup/stickySurfaceGroupController.ts +0 -12
- package/src/pages/.gitkeep +1 -0
- package/src/patterns/Table/TableFilterPanel.css +20 -10
- package/src/patterns/Table/tableClientController.ts +7 -2
- package/src/patterns/Table/tableFilterController.ts +6 -0
- package/src/patterns/Table/tableProgressiveController.ts +5 -1
- package/src/patterns/Table/tableSortController.ts +2 -0
- package/src/patterns/Table/tableViewport.ts +42 -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 = () => {
|
|
@@ -17,28 +17,19 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.surface-group:has(> [data-sticky-surface])::before {
|
|
20
|
+
--surface-group-sticky-occlusion-size: calc(
|
|
21
|
+
var(--nox-layout-gap) + var(--nox-section-responsive-block-size)
|
|
22
|
+
);
|
|
23
|
+
|
|
20
24
|
position: sticky;
|
|
21
25
|
z-index: 39;
|
|
22
26
|
top: 0;
|
|
23
27
|
display: block;
|
|
24
28
|
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
|
-
);
|
|
29
|
+
min-height: var(--surface-group-sticky-occlusion-size);
|
|
29
30
|
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
|
-
);
|
|
31
|
+
flex: 0 0 var(--surface-group-sticky-occlusion-size);
|
|
32
|
+
margin-block-end: calc(-1 * var(--surface-group-sticky-occlusion-size));
|
|
42
33
|
background: var(--nox-page-background);
|
|
43
34
|
content: '';
|
|
44
35
|
}
|
|
@@ -69,8 +60,8 @@
|
|
|
69
60
|
|
|
70
61
|
.surface-group
|
|
71
62
|
> [data-surface]:not([hidden]):has(~ [data-surface]:not([hidden])) {
|
|
72
|
-
border-end-start-radius:
|
|
73
|
-
border-end-end-radius:
|
|
63
|
+
border-end-start-radius: 0;
|
|
64
|
+
border-end-end-radius: 0;
|
|
74
65
|
}
|
|
75
66
|
|
|
76
67
|
.surface-group > [data-surface]:not([hidden]) ~ [data-surface]:not([hidden]) {
|
|
@@ -78,3 +69,11 @@
|
|
|
78
69
|
border-start-start-radius: 0;
|
|
79
70
|
border-start-end-radius: 0;
|
|
80
71
|
}
|
|
72
|
+
|
|
73
|
+
@container nox-surface-group (width < 32rem) {
|
|
74
|
+
.surface-group:has(> [data-sticky-surface])::before {
|
|
75
|
+
--surface-group-sticky-occlusion-size: calc(
|
|
76
|
+
var(--nox-layout-gap) + var(--nox-section-compact-block-size)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -42,14 +42,9 @@ export const initStickySurfaceGroup = (root: HTMLElement): (() => void) => {
|
|
|
42
42
|
const observe = () => {
|
|
43
43
|
resizeFrame = 0;
|
|
44
44
|
observer?.disconnect();
|
|
45
|
-
root.removeAttribute('data-sticky-measured');
|
|
46
45
|
|
|
47
46
|
const stickyOffset =
|
|
48
47
|
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
48
|
observer = new IntersectionObserver(
|
|
54
49
|
([entry]) => {
|
|
55
50
|
if (!entry) return;
|
|
@@ -59,7 +54,6 @@ export const initStickySurfaceGroup = (root: HTMLElement): (() => void) => {
|
|
|
59
54
|
'data-sticky-active',
|
|
60
55
|
entry.boundingClientRect.top <= activationBoundary + 0.5,
|
|
61
56
|
);
|
|
62
|
-
root.setAttribute('data-sticky-measured', 'true');
|
|
63
57
|
},
|
|
64
58
|
{
|
|
65
59
|
root: scrollParent instanceof Window ? null : scrollParent,
|
|
@@ -78,14 +72,10 @@ export const initStickySurfaceGroup = (root: HTMLElement): (() => void) => {
|
|
|
78
72
|
|
|
79
73
|
root.setAttribute('data-sticky-initialized', 'true');
|
|
80
74
|
window.addEventListener('resize', scheduleObserve, { passive: true });
|
|
81
|
-
const resizeObserver =
|
|
82
|
-
'ResizeObserver' in window ? new ResizeObserver(scheduleObserve) : null;
|
|
83
|
-
resizeObserver?.observe(stickySurface);
|
|
84
75
|
observe();
|
|
85
76
|
|
|
86
77
|
return () => {
|
|
87
78
|
window.removeEventListener('resize', scheduleObserve);
|
|
88
|
-
resizeObserver?.disconnect();
|
|
89
79
|
observer?.disconnect();
|
|
90
80
|
sentinel.remove();
|
|
91
81
|
|
|
@@ -95,7 +85,5 @@ export const initStickySurfaceGroup = (root: HTMLElement): (() => void) => {
|
|
|
95
85
|
|
|
96
86
|
root.removeAttribute('data-sticky-active');
|
|
97
87
|
root.removeAttribute('data-sticky-initialized');
|
|
98
|
-
root.removeAttribute('data-sticky-measured');
|
|
99
|
-
root.style.removeProperty('--surface-group-sticky-occlusion-size');
|
|
100
88
|
};
|
|
101
89
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -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']
|
|
@@ -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 {
|
|
@@ -517,6 +520,7 @@ export function updateTableProgressiveEntry(
|
|
|
517
520
|
export function refreshTableProgressive(root: HTMLElement): boolean {
|
|
518
521
|
const context = getProgressiveContext(root);
|
|
519
522
|
if (!context) return false;
|
|
523
|
+
revealTableStart(root);
|
|
520
524
|
context.refresh();
|
|
521
525
|
return true;
|
|
522
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,42 @@
|
|
|
1
|
+
type TableStartScrollInput = {
|
|
2
|
+
currentScrollTop: number;
|
|
3
|
+
layoutGap: number;
|
|
4
|
+
tableTop: number;
|
|
5
|
+
viewportTop: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function resolveTableStartScrollTop({
|
|
9
|
+
currentScrollTop,
|
|
10
|
+
layoutGap,
|
|
11
|
+
tableTop,
|
|
12
|
+
viewportTop,
|
|
13
|
+
}: TableStartScrollInput): number {
|
|
14
|
+
const targetTop = viewportTop + layoutGap;
|
|
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
|
+
export function revealTableStart(root: HTMLElement): void {
|
|
25
|
+
const scrollRoot = resolveTableScrollRoot(root);
|
|
26
|
+
if (!scrollRoot) return;
|
|
27
|
+
|
|
28
|
+
const nextScrollTop = resolveTableStartScrollTop({
|
|
29
|
+
currentScrollTop: scrollRoot.scrollTop,
|
|
30
|
+
layoutGap:
|
|
31
|
+
Number.parseFloat(
|
|
32
|
+
window
|
|
33
|
+
.getComputedStyle(document.documentElement)
|
|
34
|
+
.getPropertyValue('--nox-layout-gap'),
|
|
35
|
+
) || 0,
|
|
36
|
+
tableTop: root.getBoundingClientRect().top,
|
|
37
|
+
viewportTop: scrollRoot.getBoundingClientRect().top,
|
|
38
|
+
});
|
|
39
|
+
if (nextScrollTop !== scrollRoot.scrollTop) {
|
|
40
|
+
scrollRoot.scrollTop = nextScrollTop;
|
|
41
|
+
}
|
|
42
|
+
}
|