agentcss 0.0.0-stage → 0.11.2
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/01-tokens/README.md +236 -0
- package/01-tokens/behavior/dismissable.js +132 -0
- package/01-tokens/behavior/emit.js +76 -0
- package/01-tokens/behavior/focus-return.js +81 -0
- package/01-tokens/behavior/roving.js +152 -0
- package/01-tokens/behavior/typeahead.js +124 -0
- package/01-tokens/focus-ring-demo.html +133 -0
- package/01-tokens/focus-ring.css +102 -0
- package/01-tokens/page.css +244 -0
- package/01-tokens/polyfill.js +116 -0
- package/01-tokens/responsive-demo.html +171 -0
- package/01-tokens/scrollbar-demo.html +194 -0
- package/01-tokens/scrollbar.css +179 -0
- package/01-tokens/theme-toggle.js +103 -0
- package/01-tokens/tokens.css +972 -0
- package/01-tokens/typography.css +156 -0
- package/02-primitives/badge/README.md +71 -0
- package/02-primitives/badge/badge.css +141 -0
- package/02-primitives/badge/demo.html +101 -0
- package/02-primitives/button/README.md +99 -0
- package/02-primitives/button/button.css +353 -0
- package/02-primitives/button/demo.html +200 -0
- package/02-primitives/card/README.md +145 -0
- package/02-primitives/card/card.css +246 -0
- package/02-primitives/card/demo.html +170 -0
- package/02-primitives/choice/README.md +161 -0
- package/02-primitives/choice/choice.css +395 -0
- package/02-primitives/choice/demo.html +277 -0
- package/02-primitives/combobox/README.md +79 -0
- package/02-primitives/combobox/combobox.css +223 -0
- package/02-primitives/combobox/combobox.js +485 -0
- package/02-primitives/combobox/demo.html +109 -0
- package/02-primitives/date-range/README.md +100 -0
- package/02-primitives/date-range/date-range.css +206 -0
- package/02-primitives/date-range/date-range.js +301 -0
- package/02-primitives/date-range/demo.html +104 -0
- package/02-primitives/input/README.md +170 -0
- package/02-primitives/input/demo.html +246 -0
- package/02-primitives/input/input.css +239 -0
- package/02-primitives/popover/README.md +80 -0
- package/02-primitives/popover/demo.html +150 -0
- package/02-primitives/popover/popover.css +187 -0
- package/02-primitives/popover/popover.js +331 -0
- package/02-primitives/progress/README.md +82 -0
- package/02-primitives/progress/demo.html +154 -0
- package/02-primitives/progress/progress.css +172 -0
- package/02-primitives/select/README.md +95 -0
- package/02-primitives/select/demo.html +121 -0
- package/02-primitives/select/select.css +151 -0
- package/02-primitives/select/select.js +549 -0
- package/02-primitives/separator/README.md +63 -0
- package/02-primitives/separator/demo.html +84 -0
- package/02-primitives/separator/separator.css +73 -0
- package/02-primitives/skeleton/README.md +69 -0
- package/02-primitives/skeleton/demo.html +110 -0
- package/02-primitives/skeleton/skeleton.css +96 -0
- package/02-primitives/switch/README.md +65 -0
- package/02-primitives/switch/demo.html +115 -0
- package/02-primitives/switch/switch.css +370 -0
- package/03-patterns/accordion/README.md +121 -0
- package/03-patterns/accordion/accordion.css +453 -0
- package/03-patterns/accordion/accordion.js +369 -0
- package/03-patterns/accordion/demo.html +223 -0
- package/03-patterns/content/README.md +103 -0
- package/03-patterns/content/content.css +286 -0
- package/03-patterns/content/demo.html +88 -0
- package/03-patterns/drawer/README.md +79 -0
- package/03-patterns/drawer/demo.html +101 -0
- package/03-patterns/drawer/drawer.css +129 -0
- package/03-patterns/drawer/drawer.js +258 -0
- package/03-patterns/dropdown/README.md +78 -0
- package/03-patterns/dropdown/demo.html +101 -0
- package/03-patterns/dropdown/dropdown.css +135 -0
- package/03-patterns/dropdown/dropdown.js +451 -0
- package/03-patterns/form-validation/README.md +147 -0
- package/03-patterns/form-validation/demo.html +280 -0
- package/03-patterns/form-validation/form-validation.css +263 -0
- package/03-patterns/list/README.md +150 -0
- package/03-patterns/list/demo.html +225 -0
- package/03-patterns/list/flip.js +201 -0
- package/03-patterns/list/list.css +162 -0
- package/03-patterns/nav/README.md +225 -0
- package/03-patterns/nav/demo.html +131 -0
- package/03-patterns/nav/nav.css +314 -0
- package/03-patterns/nav/nav.js +430 -0
- package/03-patterns/nav/toc.js +111 -0
- package/03-patterns/overlay/README.md +196 -0
- package/03-patterns/overlay/demo.html +241 -0
- package/03-patterns/overlay/overlay.css +319 -0
- package/03-patterns/overlay/overlay.js +563 -0
- package/03-patterns/pagination/README.md +114 -0
- package/03-patterns/pagination/demo.html +165 -0
- package/03-patterns/pagination/pagination.css +195 -0
- package/03-patterns/pagination/pagination.js +395 -0
- package/03-patterns/reveal/README.md +91 -0
- package/03-patterns/reveal/demo.html +106 -0
- package/03-patterns/reveal/reveal.css +93 -0
- package/03-patterns/reveal/reveal.js +172 -0
- package/03-patterns/states/README.md +141 -0
- package/03-patterns/states/demo.html +240 -0
- package/03-patterns/states/states.css +252 -0
- package/03-patterns/tabs/README.md +84 -0
- package/03-patterns/tabs/demo.html +139 -0
- package/03-patterns/tabs/tabs.css +172 -0
- package/03-patterns/tabs/tabs.js +307 -0
- package/03-patterns/tooltip/README.md +96 -0
- package/03-patterns/tooltip/demo.html +78 -0
- package/03-patterns/tooltip/tooltip.css +89 -0
- package/03-patterns/tooltip/tooltip.js +288 -0
- package/03-patterns/tree/README.md +94 -0
- package/03-patterns/tree/demo.html +138 -0
- package/03-patterns/tree/tree.css +113 -0
- package/03-patterns/tree/tree.js +456 -0
- package/04-recipes/analysis-report/README.md +80 -0
- package/04-recipes/analysis-report/analysis-report.css +187 -0
- package/04-recipes/analysis-report/demo.html +274 -0
- package/04-recipes/data-showcase/README.md +45 -0
- package/04-recipes/data-showcase/demo.html +247 -0
- package/04-recipes/detail-page/README.md +93 -0
- package/04-recipes/detail-page/demo.html +55 -0
- package/04-recipes/detail-page/detail-page.css +190 -0
- package/04-recipes/detail-page/full.html +60 -0
- package/04-recipes/detail-page/null.html +60 -0
- package/04-recipes/detail-page/partial.html +60 -0
- package/04-recipes/detail-page/verify-skeleton.py +19 -0
- package/04-recipes/longform/README.md +93 -0
- package/04-recipes/longform/agc-memory.svg +4 -0
- package/04-recipes/longform/content.html +610 -0
- package/04-recipes/longform/content.md +51 -0
- package/04-recipes/longform/longform.html +627 -0
- package/04-recipes/report/README.md +176 -0
- package/04-recipes/report/demo.html +355 -0
- package/04-recipes/report/report.css +364 -0
- package/04-recipes/table/README.md +103 -0
- package/04-recipes/table/demo.html +455 -0
- package/04-recipes/table/table.css +372 -0
- package/04-recipes/tierA-tokens.css +189 -0
- package/09-assets/README.md +74 -0
- package/09-assets/bar/README.md +94 -0
- package/09-assets/bar/bar.css +166 -0
- package/09-assets/bar/bar.js +320 -0
- package/09-assets/bar/demo.html +176 -0
- package/09-assets/echarts-adapter/demo.html +192 -0
- package/09-assets/echarts-adapter/echarts-adapter.js +277 -0
- package/09-assets/model-viewer/README.md +155 -0
- package/09-assets/model-viewer/demo.html +105 -0
- package/09-assets/model-viewer/model-viewer.css +143 -0
- package/09-assets/model-viewer/model-viewer.js +423 -0
- package/09-assets/scientific-plot/README.md +94 -0
- package/09-assets/scientific-plot/demo.html +252 -0
- package/09-assets/scientific-plot/scientific-plot.css +141 -0
- package/09-assets/scientific-plot/scientific-plot.js +610 -0
- package/09-assets/sparkline/README.md +153 -0
- package/09-assets/sparkline/demo.html +163 -0
- package/09-assets/sparkline/sparkline.css +158 -0
- package/09-assets/sparkline/sparkline.js +508 -0
- package/API.md +332 -0
- package/CHANGELOG.md +3116 -0
- package/CODE_OF_CONDUCT.md +64 -0
- package/CONTRIBUTING.md +89 -0
- package/ERRORS.md +1658 -0
- package/LICENSE +21 -0
- package/README.md +491 -2
- package/SECURITY.md +72 -0
- package/START-HERE.md +164 -0
- package/SUPPORT.md +109 -0
- package/adapters/presentation/README.md +113 -0
- package/adapters/presentation/check.js +101 -0
- package/adapters/presentation/deck.schema.json +74 -0
- package/adapters/presentation/to-doc.js +138 -0
- package/ai/START-HERE.md +104 -0
- package/ai/behaviors.json +380 -0
- package/ai/behaviors.schema.json +61 -0
- package/ai/capabilities.json +56 -0
- package/ai/cli.js +387 -0
- package/ai/components.json +1944 -0
- package/ai/components.meta.json +168 -0
- package/ai/components.schema.json +220 -0
- package/ai/contract.schema.json +147 -0
- package/ai/deprecations.json +55 -0
- package/ai/deprecations.schema.json +85 -0
- package/ai/motion-policy.json +22 -0
- package/ai/patch.js +323 -0
- package/ai/patch.schema.json +63 -0
- package/ai/profiles.json +92 -0
- package/ai/tokens.audience.json +55 -0
- package/ai/tokens.audience.schema.json +73 -0
- package/ai/tokens.json +762 -0
- package/ai/tokens.schema.json +58 -0
- package/ai/tokens.tree.json +752 -0
- package/ai/tokens.tree.schema.json +56 -0
- package/ai/validate.js +383 -0
- package/dist/01-tokens/behavior/dismissable.js +60 -0
- package/dist/01-tokens/behavior/emit.js +21 -0
- package/dist/01-tokens/behavior/focus-return.js +31 -0
- package/dist/01-tokens/behavior/roving.js +77 -0
- package/dist/01-tokens/behavior/typeahead.js +61 -0
- package/dist/01-tokens/focus-ring.css +1 -0
- package/dist/01-tokens/page.css +1 -0
- package/dist/01-tokens/polyfill.js +78 -0
- package/dist/01-tokens/scrollbar.css +1 -0
- package/dist/01-tokens/theme-toggle.js +61 -0
- package/dist/01-tokens/tokens.css +1 -0
- package/dist/01-tokens/typography.css +1 -0
- package/dist/02-primitives/badge/badge.css +1 -0
- package/dist/02-primitives/button/button.css +1 -0
- package/dist/02-primitives/card/card.css +1 -0
- package/dist/02-primitives/choice/choice.css +1 -0
- package/dist/02-primitives/combobox/combobox.css +1 -0
- package/dist/02-primitives/combobox/combobox.js +439 -0
- package/dist/02-primitives/date-range/date-range.css +1 -0
- package/dist/02-primitives/date-range/date-range.js +267 -0
- package/dist/02-primitives/input/input.css +1 -0
- package/dist/02-primitives/popover/popover.css +1 -0
- package/dist/02-primitives/popover/popover.js +257 -0
- package/dist/02-primitives/progress/progress.css +1 -0
- package/dist/02-primitives/select/select.css +1 -0
- package/dist/02-primitives/select/select.js +449 -0
- package/dist/02-primitives/separator/separator.css +1 -0
- package/dist/02-primitives/skeleton/skeleton.css +1 -0
- package/dist/02-primitives/switch/switch.css +1 -0
- package/dist/03-patterns/accordion/accordion.css +1 -0
- package/dist/03-patterns/accordion/accordion.js +219 -0
- package/dist/03-patterns/content/content.css +1 -0
- package/dist/03-patterns/drawer/drawer.css +1 -0
- package/dist/03-patterns/drawer/drawer.js +229 -0
- package/dist/03-patterns/dropdown/dropdown.css +1 -0
- package/dist/03-patterns/dropdown/dropdown.js +365 -0
- package/dist/03-patterns/form-validation/form-validation.css +1 -0
- package/dist/03-patterns/list/flip.js +117 -0
- package/dist/03-patterns/list/list.css +1 -0
- package/dist/03-patterns/nav/nav.css +1 -0
- package/dist/03-patterns/nav/nav.js +322 -0
- package/dist/03-patterns/nav/toc.js +76 -0
- package/dist/03-patterns/overlay/overlay.css +1 -0
- package/dist/03-patterns/overlay/overlay.js +398 -0
- package/dist/03-patterns/pagination/pagination.css +1 -0
- package/dist/03-patterns/pagination/pagination.js +273 -0
- package/dist/03-patterns/reveal/reveal.css +1 -0
- package/dist/03-patterns/reveal/reveal.js +138 -0
- package/dist/03-patterns/states/states.css +1 -0
- package/dist/03-patterns/tabs/tabs.css +1 -0
- package/dist/03-patterns/tabs/tabs.js +242 -0
- package/dist/03-patterns/tooltip/tooltip.css +1 -0
- package/dist/03-patterns/tooltip/tooltip.js +213 -0
- package/dist/03-patterns/tree/tree.css +1 -0
- package/dist/03-patterns/tree/tree.js +383 -0
- package/dist/04-recipes/analysis-report/analysis-report.css +1 -0
- package/dist/04-recipes/detail-page/detail-page.css +1 -0
- package/dist/04-recipes/report/report.css +1 -0
- package/dist/04-recipes/table/table.css +1 -0
- package/dist/04-recipes/tierA-tokens.css +1 -0
- package/dist/09-assets/bar/bar.css +1 -0
- package/dist/09-assets/bar/bar.js +222 -0
- package/dist/09-assets/echarts-adapter/echarts-adapter.js +185 -0
- package/dist/09-assets/model-viewer/model-viewer.css +1 -0
- package/dist/09-assets/model-viewer/model-viewer.js +320 -0
- package/dist/09-assets/scientific-plot/scientific-plot.css +1 -0
- package/dist/09-assets/scientific-plot/scientific-plot.js +568 -0
- package/dist/09-assets/sparkline/sparkline.css +1 -0
- package/dist/09-assets/sparkline/sparkline.js +265 -0
- package/dist/COSTS.md +56 -0
- package/docs/AI-CONTRACT.md +197 -0
- package/docs/BACKLOG.md +127 -0
- package/docs/BENCHMARK.md +252 -0
- package/docs/GUIDANCE.md +154 -0
- package/docs/INVARIANT.md +372 -0
- package/docs/LAYER-BASELINE.md +158 -0
- package/docs/RELEASING.md +275 -0
- package/docs/RFC-THEME-SCOPE.md +141 -0
- package/docs/ROADMAP.md +182 -0
- package/index.html +82 -0
- package/package.json +107 -4
- package/types/index.d.ts +310 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
(function (global) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var FOCUSABLE = [
|
|
5
|
+
'a[href]',
|
|
6
|
+
'button:not([disabled])',
|
|
7
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
8
|
+
'select:not([disabled])',
|
|
9
|
+
'textarea:not([disabled])',
|
|
10
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
11
|
+
].join(',');
|
|
12
|
+
|
|
13
|
+
var lockCount = 0;
|
|
14
|
+
|
|
15
|
+
var scrollLock = { changed: false, saved: '', varSet: false };
|
|
16
|
+
|
|
17
|
+
var inertRefs = [];
|
|
18
|
+
|
|
19
|
+
var ariaRefs = [];
|
|
20
|
+
|
|
21
|
+
function focusableIn(root) {
|
|
22
|
+
var all = Array.prototype.slice.call(root.querySelectorAll(FOCUSABLE));
|
|
23
|
+
|
|
24
|
+
return all.filter(function (el) {
|
|
25
|
+
return el.offsetParent !== null || el === document.activeElement;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function lockScroll() {
|
|
30
|
+
if (lockCount++ > 0) return;
|
|
31
|
+
|
|
32
|
+
var sbw = window.innerWidth - document.documentElement.clientWidth;
|
|
33
|
+
if (sbw > 0) {
|
|
34
|
+
var cur = parseFloat(getComputedStyle(document.body).paddingRight) || 0;
|
|
35
|
+
scrollLock.saved = document.body.style.paddingRight;
|
|
36
|
+
document.body.style.paddingRight = (cur + sbw) + 'px';
|
|
37
|
+
scrollLock.changed = true;
|
|
38
|
+
document.documentElement.style.setProperty(
|
|
39
|
+
'--overlay-scrollbar-width', sbw + 'px');
|
|
40
|
+
scrollLock.varSet = true;
|
|
41
|
+
}
|
|
42
|
+
document.body.setAttribute('data-scroll-locked', 'true');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function unlockScroll() {
|
|
46
|
+
if (--lockCount > 0) return;
|
|
47
|
+
document.body.removeAttribute('data-scroll-locked');
|
|
48
|
+
if (scrollLock.varSet) {
|
|
49
|
+
document.documentElement.style.removeProperty('--overlay-scrollbar-width');
|
|
50
|
+
scrollLock.varSet = false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (scrollLock.changed) {
|
|
54
|
+
document.body.style.paddingRight = scrollLock.saved;
|
|
55
|
+
scrollLock.changed = false;
|
|
56
|
+
scrollLock.saved = '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function inertAcquire(node) {
|
|
61
|
+
for (var i = 0; i < inertRefs.length; i++) {
|
|
62
|
+
if (inertRefs[i].node === node) { inertRefs[i].count++; return; }
|
|
63
|
+
}
|
|
64
|
+
inertRefs.push({ node: node, count: 1 });
|
|
65
|
+
node.inert = true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function inertRelease(node) {
|
|
69
|
+
for (var i = 0; i < inertRefs.length; i++) {
|
|
70
|
+
if (inertRefs[i].node !== node) continue;
|
|
71
|
+
inertRefs[i].count--;
|
|
72
|
+
if (inertRefs[i].count <= 0) {
|
|
73
|
+
node.inert = false;
|
|
74
|
+
inertRefs.splice(i, 1);
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function ariaAcquire(node) {
|
|
81
|
+
for (var i = 0; i < ariaRefs.length; i++) {
|
|
82
|
+
if (ariaRefs[i].node === node) { ariaRefs[i].count++; return; }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
ariaRefs.push({ node: node, count: 1, prev: node.getAttribute('aria-hidden') });
|
|
86
|
+
node.setAttribute('aria-hidden', 'true');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function ariaRelease(node) {
|
|
90
|
+
for (var i = 0; i < ariaRefs.length; i++) {
|
|
91
|
+
if (ariaRefs[i].node !== node) continue;
|
|
92
|
+
ariaRefs[i].count--;
|
|
93
|
+
if (ariaRefs[i].count <= 0) {
|
|
94
|
+
var prev = ariaRefs[i].prev;
|
|
95
|
+
if (prev === null) node.removeAttribute('aria-hidden');
|
|
96
|
+
else node.setAttribute('aria-hidden', prev);
|
|
97
|
+
ariaRefs.splice(i, 1);
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var openStack = [];
|
|
104
|
+
|
|
105
|
+
function installIsolation(entry) {
|
|
106
|
+
var box = entry.box;
|
|
107
|
+
var backdrop = entry.backdrop;
|
|
108
|
+
var lastInside = null;
|
|
109
|
+
|
|
110
|
+
function topmost() { return openStack[openStack.length - 1]; }
|
|
111
|
+
|
|
112
|
+
function pullBack() {
|
|
113
|
+
if (lastInside && document.contains(lastInside) && box.contains(lastInside)) {
|
|
114
|
+
lastInside.focus();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
var f = focusableIn(box);
|
|
118
|
+
if (f.length) { f[0].focus(); return; }
|
|
119
|
+
box.focus();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function onFocusIn(e) {
|
|
123
|
+
if (topmost() !== entry) return;
|
|
124
|
+
var t = e.target;
|
|
125
|
+
if (box.contains(t) || backdrop.contains(t)) { lastInside = t; return; }
|
|
126
|
+
pullBack();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function onPointer(e) {
|
|
130
|
+
if (topmost() !== entry) return;
|
|
131
|
+
if (backdrop.contains(e.target)) return;
|
|
132
|
+
if (e.cancelable) e.preventDefault();
|
|
133
|
+
e.stopPropagation();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
document.addEventListener('focusin', onFocusIn, true);
|
|
137
|
+
document.addEventListener('pointerdown', onPointer, true);
|
|
138
|
+
document.addEventListener('mousedown', onPointer, true);
|
|
139
|
+
document.addEventListener('touchstart', onPointer, true);
|
|
140
|
+
|
|
141
|
+
document.addEventListener('click', onPointer, true);
|
|
142
|
+
|
|
143
|
+
return function uninstall() {
|
|
144
|
+
document.removeEventListener('focusin', onFocusIn, true);
|
|
145
|
+
document.removeEventListener('pointerdown', onPointer, true);
|
|
146
|
+
document.removeEventListener('mousedown', onPointer, true);
|
|
147
|
+
document.removeEventListener('touchstart', onPointer, true);
|
|
148
|
+
document.removeEventListener('click', onPointer, true);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function toast(opts) {
|
|
153
|
+
opts = opts || {};
|
|
154
|
+
|
|
155
|
+
var region = document.querySelector('.toast-region');
|
|
156
|
+
if (!region) {
|
|
157
|
+
region = document.createElement('div');
|
|
158
|
+
region.className = 'toast-region';
|
|
159
|
+
|
|
160
|
+
region.setAttribute('role', 'status');
|
|
161
|
+
region.setAttribute('aria-live', 'polite');
|
|
162
|
+
document.body.appendChild(region);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var el = document.createElement('div');
|
|
166
|
+
el.className = 'toast' + (opts.variant ? ' toast--' + opts.variant : '');
|
|
167
|
+
|
|
168
|
+
var body = document.createElement('div');
|
|
169
|
+
body.className = 'toast__body';
|
|
170
|
+
if (opts.title) {
|
|
171
|
+
var t = document.createElement('p');
|
|
172
|
+
t.className = 'toast__title';
|
|
173
|
+
t.textContent = opts.title;
|
|
174
|
+
body.appendChild(t);
|
|
175
|
+
}
|
|
176
|
+
if (opts.desc) {
|
|
177
|
+
var d = document.createElement('p');
|
|
178
|
+
d.className = 'toast__desc';
|
|
179
|
+
d.textContent = opts.desc;
|
|
180
|
+
body.appendChild(d);
|
|
181
|
+
}
|
|
182
|
+
el.appendChild(body);
|
|
183
|
+
|
|
184
|
+
var auto = opts.duration;
|
|
185
|
+
if (auto === undefined) {
|
|
186
|
+
auto = (opts.variant === 'error') ? 0 : 4000;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (auto > 0) {
|
|
190
|
+
var timer = document.createElement('div');
|
|
191
|
+
timer.className = 'toast__timer';
|
|
192
|
+
timer.style.animationDuration = auto + 'ms';
|
|
193
|
+
el.appendChild(timer);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var closeBtn = document.createElement('button');
|
|
197
|
+
closeBtn.className = 'toast__close';
|
|
198
|
+
closeBtn.type = 'button';
|
|
199
|
+
closeBtn.setAttribute('aria-label', '关闭提示');
|
|
200
|
+
closeBtn.textContent = '×';
|
|
201
|
+
el.appendChild(closeBtn);
|
|
202
|
+
|
|
203
|
+
var closed = false;
|
|
204
|
+
function close() {
|
|
205
|
+
if (closed) return;
|
|
206
|
+
closed = true;
|
|
207
|
+
if (auto) clearTimeout(timerId);
|
|
208
|
+
el.setAttribute('data-state', 'leaving');
|
|
209
|
+
|
|
210
|
+
setTimeout(function () {
|
|
211
|
+
if (el.parentNode) el.parentNode.removeChild(el);
|
|
212
|
+
}, 220);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
closeBtn.addEventListener('click', close);
|
|
216
|
+
region.appendChild(el);
|
|
217
|
+
|
|
218
|
+
var timerId = auto > 0 ? setTimeout(close, auto) : null;
|
|
219
|
+
return { el: el, close: close };
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
var flFocusReturn = function (opts) {
|
|
223
|
+
var opt = opts || {};
|
|
224
|
+
var saved = null;
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
save: function () {
|
|
228
|
+
var a = document.activeElement;
|
|
229
|
+
saved = (a && a !== document.body && a.focus) ? a : null;
|
|
230
|
+
return saved;
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
restore: function () {
|
|
234
|
+
var target = saved;
|
|
235
|
+
|
|
236
|
+
if (!target || !document.contains(target)) target = opt.fallback || null;
|
|
237
|
+
if (!target) { saved = null; return false; }
|
|
238
|
+
try {
|
|
239
|
+
target.focus();
|
|
240
|
+
} catch (e) {
|
|
241
|
+
saved = null;
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
var ok = document.activeElement === target;
|
|
245
|
+
saved = null;
|
|
246
|
+
return ok;
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
target: function () { return saved; },
|
|
250
|
+
clear: function () { saved = null; },
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
function dialog(opts) {
|
|
255
|
+
opts = opts || {};
|
|
256
|
+
|
|
257
|
+
var fr = flFocusReturn();
|
|
258
|
+
fr.save();
|
|
259
|
+
|
|
260
|
+
var backdrop = document.createElement('div');
|
|
261
|
+
backdrop.className = 'dialog-backdrop';
|
|
262
|
+
|
|
263
|
+
var box = document.createElement('div');
|
|
264
|
+
box.className = 'dialog' + (opts.danger ? ' dialog--danger' : '');
|
|
265
|
+
box.setAttribute('role', 'dialog');
|
|
266
|
+
box.setAttribute('aria-modal', 'true');
|
|
267
|
+
|
|
268
|
+
box.setAttribute('tabindex', '-1');
|
|
269
|
+
|
|
270
|
+
if (opts.title) {
|
|
271
|
+
var h = document.createElement('h2');
|
|
272
|
+
h.className = 'dialog__title';
|
|
273
|
+
h.id = 'dlg-title-' + Date.now();
|
|
274
|
+
h.textContent = opts.title;
|
|
275
|
+
box.appendChild(h);
|
|
276
|
+
box.setAttribute('aria-labelledby', h.id);
|
|
277
|
+
}
|
|
278
|
+
if (opts.desc) {
|
|
279
|
+
var p = document.createElement('p');
|
|
280
|
+
p.className = 'dialog__desc';
|
|
281
|
+
p.id = 'dlg-desc-' + Date.now();
|
|
282
|
+
p.textContent = opts.desc;
|
|
283
|
+
box.appendChild(p);
|
|
284
|
+
box.setAttribute('aria-describedby', p.id);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
var act = document.createElement('div');
|
|
288
|
+
act.className = 'dialog__actions';
|
|
289
|
+
(opts.actions || []).forEach(function (a) {
|
|
290
|
+
var b = document.createElement('button');
|
|
291
|
+
b.type = 'button';
|
|
292
|
+
b.className = 'btn ' + (a.variant === 'danger' ? 'btn--danger'
|
|
293
|
+
: a.variant === 'primary' ? 'btn--primary' : 'btn--secondary');
|
|
294
|
+
b.textContent = a.label;
|
|
295
|
+
b.addEventListener('click', function () {
|
|
296
|
+
if (a.onClick) a.onClick(close);
|
|
297
|
+
if (a.keepOpen !== true) close();
|
|
298
|
+
});
|
|
299
|
+
act.appendChild(b);
|
|
300
|
+
});
|
|
301
|
+
box.appendChild(act);
|
|
302
|
+
|
|
303
|
+
backdrop.appendChild(box);
|
|
304
|
+
document.body.appendChild(backdrop);
|
|
305
|
+
lockScroll();
|
|
306
|
+
|
|
307
|
+
var useInert = 'inert' in HTMLElement.prototype;
|
|
308
|
+
var stackEntry = { backdrop: backdrop, box: box };
|
|
309
|
+
var uninstallIsolation = null;
|
|
310
|
+
openStack.push(stackEntry);
|
|
311
|
+
if (!useInert) uninstallIsolation = installIsolation(stackEntry);
|
|
312
|
+
|
|
313
|
+
function focusables() { return focusableIn(box); }
|
|
314
|
+
|
|
315
|
+
box.addEventListener('keydown', function (e) {
|
|
316
|
+
if (e.key === 'Escape') {
|
|
317
|
+
e.preventDefault();
|
|
318
|
+
|
|
319
|
+
e.stopPropagation();
|
|
320
|
+
close();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (e.key !== 'Tab') return;
|
|
324
|
+
|
|
325
|
+
var f = focusables();
|
|
326
|
+
if (!f.length) { e.preventDefault(); box.focus(); return; }
|
|
327
|
+
var first = f[0], last = f[f.length - 1];
|
|
328
|
+
|
|
329
|
+
if (e.shiftKey && (document.activeElement === first || document.activeElement === box)) {
|
|
330
|
+
e.preventDefault(); last.focus();
|
|
331
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
332
|
+
e.preventDefault(); first.focus();
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
if (opts.initialFocus === 'cancel') {
|
|
337
|
+
var cancel = box.querySelector('.btn:not(.btn--danger)');
|
|
338
|
+
if (cancel) cancel.focus();
|
|
339
|
+
else box.focus();
|
|
340
|
+
} else {
|
|
341
|
+
box.focus();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (opts.closeOnBackdrop !== false && !opts.danger) {
|
|
345
|
+
backdrop.addEventListener('mousedown', function (e) {
|
|
346
|
+
if (e.target === backdrop) close();
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
var closed = false;
|
|
351
|
+
var inerted = [];
|
|
352
|
+
var ariaed = [];
|
|
353
|
+
|
|
354
|
+
var nodes = Array.prototype.slice.call(
|
|
355
|
+
document.body.querySelectorAll('body > *')
|
|
356
|
+
);
|
|
357
|
+
nodes.forEach(function (n) {
|
|
358
|
+
|
|
359
|
+
if (n.classList.contains('dialog-backdrop')) return;
|
|
360
|
+
if (useInert) {
|
|
361
|
+
inerted.push(n);
|
|
362
|
+
inertAcquire(n);
|
|
363
|
+
} else {
|
|
364
|
+
ariaed.push(n);
|
|
365
|
+
ariaAcquire(n);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
function close() {
|
|
370
|
+
if (closed) return;
|
|
371
|
+
closed = true;
|
|
372
|
+
|
|
373
|
+
var ae = document.activeElement;
|
|
374
|
+
var focusIsMine = !ae || ae === document.body ||
|
|
375
|
+
box.contains(ae) || backdrop.contains(ae);
|
|
376
|
+
|
|
377
|
+
if (backdrop.parentNode) backdrop.parentNode.removeChild(backdrop);
|
|
378
|
+
|
|
379
|
+
for (var si = openStack.length - 1; si >= 0; si--) {
|
|
380
|
+
if (openStack[si] === stackEntry) { openStack.splice(si, 1); break; }
|
|
381
|
+
}
|
|
382
|
+
if (uninstallIsolation) { uninstallIsolation(); uninstallIsolation = null; }
|
|
383
|
+
|
|
384
|
+
inerted.forEach(inertRelease);
|
|
385
|
+
|
|
386
|
+
ariaed.forEach(ariaRelease);
|
|
387
|
+
unlockScroll();
|
|
388
|
+
|
|
389
|
+
fr.restore();
|
|
390
|
+
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return { el: box, close: close };
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
global.Overlay = { toast: toast, dialog: dialog };
|
|
397
|
+
|
|
398
|
+
})(window);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.pagination {display:flex;align-items:center;gap:var(--sp-2);flex-wrap:wrap;}.pagination__list {display:flex;align-items:center;gap:2px;flex-wrap:wrap;list-style:none;margin:0;padding:0;}.pagination__item {margin:0;}.pagination__link {display:inline-flex;align-items:center;justify-content:center;min-width:var(--sz-touch);min-height:var(--sz-touch);padding:0 var(--sp-2);font-size:var(--fs-sm);font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--text-primary);text-decoration:none;background:var(--surface);border:1px solid var(--border-decor);border-radius:var(--r-sm);cursor:pointer;-webkit-tap-highlight-color:transparent;transition:background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);}.pagination__link:hover:not([aria-disabled="true"]):not([disabled]) {background:var(--surface-sunken);}.pagination__link:focus-visible {outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);}.pagination__link[aria-disabled="true"], .pagination__link:disabled {color:var(--text-tertiary);background:var(--surface-sunken);border-color:transparent;cursor:not-allowed;}.pagination__link[aria-current="page"]:not([disabled]) {color:var(--text-on-accent);background:var(--accent);border-color:var(--accent);font-weight:600;box-shadow:var(--lift-sm);cursor:default;opacity:1;z-index:var(--z-raised);}.pagination__ellipsis {display:inline-flex;align-items:center;justify-content:center;min-width:var(--sz-touch);min-height:var(--sz-touch);color:var(--text-tertiary);font-size:var(--fs-sm);user-select:none;}.pagination__status {margin-inline-start:auto;font-size:var(--fs-xs);color:var(--text-secondary);font-variant-numeric:tabular-nums;}.pagination__status:empty {display:none;}.pagination__sr {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;}.pagination__live {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;}@media (max-width:480px) {.pagination__status {margin-inline-start:0;width:100%;}}@media (prefers-reduced-motion:reduce) {.pagination__link {transition:none;}}@media (hover:hover) and (pointer:fine) {.pagination__link:hover:not([aria-disabled="true"]):not([disabled]) {background:var(--surface-sunken);}}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var flEmit = function (el, name, detail) {
|
|
5
|
+
if (!el || !el.dispatchEvent) return null;
|
|
6
|
+
var type = name.indexOf('fl-') === 0 ? name : 'fl-' + name;
|
|
7
|
+
var ev = null;
|
|
8
|
+
|
|
9
|
+
if (typeof window.CustomEvent === 'function') {
|
|
10
|
+
try {
|
|
11
|
+
ev = new window.CustomEvent(type, {
|
|
12
|
+
detail: detail || null, bubbles: true, cancelable: false
|
|
13
|
+
});
|
|
14
|
+
} catch (e) { ev = null; }
|
|
15
|
+
}
|
|
16
|
+
if (!ev) {
|
|
17
|
+
try {
|
|
18
|
+
ev = document.createEvent('CustomEvent');
|
|
19
|
+
ev.initCustomEvent(type, true, false, detail || null);
|
|
20
|
+
} catch (e2) { return null; }
|
|
21
|
+
}
|
|
22
|
+
el.dispatchEvent(ev);
|
|
23
|
+
return ev;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var SLOTS = 7;
|
|
27
|
+
|
|
28
|
+
function el(tag, cls, text) {
|
|
29
|
+
var n = document.createElement(tag);
|
|
30
|
+
if (cls) n.className = cls;
|
|
31
|
+
if (text !== undefined && text !== null) n.textContent = text;
|
|
32
|
+
return n;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function pageWindow(cur, total, slots) {
|
|
36
|
+
slots = slots || SLOTS;
|
|
37
|
+
if (total <= slots - 2) {
|
|
38
|
+
var all = [];
|
|
39
|
+
for (var i = 1; i <= total; i++) all.push(i);
|
|
40
|
+
return all;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var MAX_MID = slots - 4;
|
|
44
|
+
if (MAX_MID < 1) MAX_MID = 1;
|
|
45
|
+
|
|
46
|
+
var mid = [];
|
|
47
|
+
var start = cur - Math.floor(MAX_MID / 2);
|
|
48
|
+
if (start < 2) start = 2;
|
|
49
|
+
if (start + MAX_MID - 1 > total - 1) start = total - MAX_MID;
|
|
50
|
+
if (start < 2) start = 2;
|
|
51
|
+
for (var j = start; j < start + MAX_MID; j++) {
|
|
52
|
+
if (j > 1 && j < total) mid.push(j);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var out = [1];
|
|
56
|
+
|
|
57
|
+
if (mid.length && mid[0] > 2) out.push('…');
|
|
58
|
+
for (var k = 0; k < mid.length; k++) out.push(mid[k]);
|
|
59
|
+
if (mid.length && mid[mid.length - 1] < total - 1) out.push('…');
|
|
60
|
+
if (total > 1) out.push(total);
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function Pagination(node) {
|
|
65
|
+
this.node = node;
|
|
66
|
+
this.total = Math.max(1, parseInt(node.getAttribute('data-total') || '1', 10));
|
|
67
|
+
this.size = Math.max(1, parseInt(node.getAttribute('data-page-size') || '20', 10));
|
|
68
|
+
this.page = Math.max(1, parseInt(node.getAttribute('data-page') || '1', 10));
|
|
69
|
+
this.label = node.getAttribute('aria-label') || '分页';
|
|
70
|
+
this.pages = Math.max(1, Math.ceil(this.total / this.size));
|
|
71
|
+
this.onChange = null;
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
var u = node.getAttribute('data-pg-param') || 'page';
|
|
75
|
+
var q = parseInt(new URL(location.href).searchParams.get(u) || '0', 10);
|
|
76
|
+
if (q > 0) this.page = Math.min(q, this.pages);
|
|
77
|
+
} catch (e) { }
|
|
78
|
+
|
|
79
|
+
this.listNode = node.querySelector('[data-pg-list]');
|
|
80
|
+
this.statusNode = node.querySelector('[data-pg-status]');
|
|
81
|
+
this.liveNode = node.querySelector('[data-pg-live]');
|
|
82
|
+
|
|
83
|
+
var self = this;
|
|
84
|
+
node.addEventListener('click', function (e) {
|
|
85
|
+
var t = e.target;
|
|
86
|
+
while (t && t !== node && t.tagName !== 'BUTTON' && t.tagName !== 'A') {
|
|
87
|
+
t = t.parentNode;
|
|
88
|
+
}
|
|
89
|
+
if (!t || t === node) return;
|
|
90
|
+
if (t.disabled || t.getAttribute('aria-disabled') === 'true') return;
|
|
91
|
+
var to = t.getAttribute('data-goto');
|
|
92
|
+
if (to === 'prev') { self.go(self.page - 1); }
|
|
93
|
+
else if (to === 'next') { self.go(self.page + 1); }
|
|
94
|
+
else if (to === 'first') { self.go(1); }
|
|
95
|
+
else if (to === 'last') { self.go(self.pages); }
|
|
96
|
+
else if (to) { self.go(parseInt(to, 10)); }
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
this._onKey = function (e) {
|
|
100
|
+
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
|
101
|
+
var act = document.activeElement;
|
|
102
|
+
var inside = act && (act === self.node || self.node.contains(act));
|
|
103
|
+
|
|
104
|
+
if (act && /^(INPUT|TEXTAREA|SELECT)$/.test(act.tagName)) return;
|
|
105
|
+
if (act && act.isContentEditable) return;
|
|
106
|
+
|
|
107
|
+
if (!inside && act && act !== document.body) return;
|
|
108
|
+
|
|
109
|
+
var k = e.key;
|
|
110
|
+
if (k === 'ArrowLeft') { self.go(self.page - 1); }
|
|
111
|
+
else if (k === 'ArrowRight') { self.go(self.page + 1); }
|
|
112
|
+
else if (k === 'Home') { self.go(1); }
|
|
113
|
+
else if (k === 'End') { self.go(self.pages); }
|
|
114
|
+
else return;
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
|
|
117
|
+
self.focusCurrent();
|
|
118
|
+
};
|
|
119
|
+
document.addEventListener('keydown', this._onKey);
|
|
120
|
+
|
|
121
|
+
this.render();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
Pagination.prototype.pages = 1;
|
|
125
|
+
|
|
126
|
+
Pagination.prototype.destroy = function () {
|
|
127
|
+
if (this._destroyed) return;
|
|
128
|
+
this._destroyed = true;
|
|
129
|
+
document.removeEventListener('keydown', this._onKey);
|
|
130
|
+
|
|
131
|
+
if (this.node && document.activeElement &&
|
|
132
|
+
this.node.contains &&
|
|
133
|
+
this.node.contains(document.activeElement)) {
|
|
134
|
+
document.activeElement.blur();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
Pagination.prototype.go = function (n, opts) {
|
|
139
|
+
opts = opts || {};
|
|
140
|
+
n = Math.max(1, Math.min(this.pages, n));
|
|
141
|
+
if (n === this.page && !opts.force) { this.focusCurrent(); return; }
|
|
142
|
+
this.page = n;
|
|
143
|
+
this.render();
|
|
144
|
+
this.announce();
|
|
145
|
+
|
|
146
|
+
if (opts.scroll !== false) this.scrollToTop();
|
|
147
|
+
this.syncURL();
|
|
148
|
+
flEmit(this.node, 'fl-change', { value: n, page: n });
|
|
149
|
+
if (typeof this.onChange === 'function') this.onChange(n);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
Pagination.prototype.scrollToTop = function () {
|
|
153
|
+
var target = this.node.getAttribute('data-pg-scroll-target')
|
|
154
|
+
|| this.node.getAttribute('aria-controls');
|
|
155
|
+
var el = target ? document.getElementById(target) : null;
|
|
156
|
+
if (!el || !el.scrollIntoView) {
|
|
157
|
+
|
|
158
|
+
if (this.node.scrollIntoView) {
|
|
159
|
+
try { this.node.scrollIntoView({ block: 'nearest' }); } catch (e) {}
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
el.scrollIntoView({ block: 'start' });
|
|
165
|
+
} catch (e) {
|
|
166
|
+
el.scrollIntoView(true);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
Pagination.prototype.syncURL = function () {
|
|
171
|
+
if (typeof history === 'undefined' || !history.replaceState) return;
|
|
172
|
+
if (this.node.getAttribute('data-pg-nourl') === 'true') return;
|
|
173
|
+
try {
|
|
174
|
+
var u = this.node.getAttribute('data-pg-param') || 'page';
|
|
175
|
+
var url = new URL(location.href);
|
|
176
|
+
if (this.page <= 1) url.searchParams.delete(u);
|
|
177
|
+
else url.searchParams.set(u, String(this.page));
|
|
178
|
+
history.replaceState(null, '', url.toString());
|
|
179
|
+
} catch (e) { }
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
Pagination.prototype.focusCurrent = function () {
|
|
183
|
+
var cur = this.listNode.querySelector('[aria-current="page"]');
|
|
184
|
+
if (cur && cur.focus) cur.focus();
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
Pagination.prototype.announce = function () {
|
|
188
|
+
if (!this.liveNode) return;
|
|
189
|
+
this.liveNode.textContent = '第 ' + this.page + ' 页,共 ' + this.pages + ' 页';
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
Pagination.prototype.render = function () {
|
|
193
|
+
if (!this.listNode) return;
|
|
194
|
+
var L = this.listNode;
|
|
195
|
+
while (L.firstChild) L.removeChild(L.firstChild);
|
|
196
|
+
var self = this;
|
|
197
|
+
|
|
198
|
+
function addBtn(text, ariaLabel, goto, disabled) {
|
|
199
|
+
var li = el('li', 'pagination__item');
|
|
200
|
+
var b = el('button', 'pagination__link', text);
|
|
201
|
+
b.type = 'button';
|
|
202
|
+
b.setAttribute('data-goto', goto);
|
|
203
|
+
|
|
204
|
+
if (disabled) { b.disabled = true; b.setAttribute('aria-disabled', 'true'); }
|
|
205
|
+
if (ariaLabel) b.setAttribute('aria-label', ariaLabel);
|
|
206
|
+
li.appendChild(b);
|
|
207
|
+
L.appendChild(li);
|
|
208
|
+
return b;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
addBtn('‹', '上一页', 'prev', self.page <= 1);
|
|
212
|
+
|
|
213
|
+
var win = pageWindow(self.page, self.pages, SLOTS);
|
|
214
|
+
for (var i = 0; i < win.length; i++) {
|
|
215
|
+
var p = win[i];
|
|
216
|
+
if (p === '…') {
|
|
217
|
+
var li = el('li', 'pagination__item');
|
|
218
|
+
li.appendChild(el('span', 'pagination__ellipsis', '…'));
|
|
219
|
+
|
|
220
|
+
li.firstChild.setAttribute('aria-hidden', 'true');
|
|
221
|
+
L.appendChild(li);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
var isCur = (p === self.page);
|
|
226
|
+
var li2 = el('li', 'pagination__item');
|
|
227
|
+
var b2 = el('button', 'pagination__link', String(p));
|
|
228
|
+
b2.type = 'button';
|
|
229
|
+
b2.setAttribute('data-goto', String(p));
|
|
230
|
+
b2.setAttribute('aria-label', '第 ' + p + ' 页' + (isCur ? '(当前页)' : ''));
|
|
231
|
+
if (isCur) {
|
|
232
|
+
b2.setAttribute('aria-current', 'page');
|
|
233
|
+
b2.setAttribute('aria-disabled', 'true');
|
|
234
|
+
}
|
|
235
|
+
li2.appendChild(b2);
|
|
236
|
+
L.appendChild(li2);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
addBtn('›', '下一页', 'next', self.page >= self.pages);
|
|
240
|
+
|
|
241
|
+
if (this.statusNode) {
|
|
242
|
+
this.statusNode.textContent =
|
|
243
|
+
'第 '+ self.page + ' 页 / 共 ' + self.pages + ' 页';
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
var API = {
|
|
248
|
+
|
|
249
|
+
create: function (node) {
|
|
250
|
+
if (!node) return null;
|
|
251
|
+
if (node.__pg) return node.__pg;
|
|
252
|
+
node.__pg = new Pagination(node);
|
|
253
|
+
return node.__pg;
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
update: function (root) {
|
|
257
|
+
var list = (root || document).querySelectorAll('[data-pagination]');
|
|
258
|
+
for (var i = 0; i < list.length; i++) API.create(list[i]);
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
pagesOf: function (total, pageSize) {
|
|
262
|
+
return Math.max(1, Math.ceil((total || 1) / (pageSize || 20)));
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
if (typeof window !== 'undefined') window.Pagination = API;
|
|
267
|
+
|
|
268
|
+
if (document.readyState === 'loading') {
|
|
269
|
+
document.addEventListener('DOMContentLoaded', function () { API.update(); });
|
|
270
|
+
} else {
|
|
271
|
+
API.update();
|
|
272
|
+
}
|
|
273
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[data-reveal], .reveal {--reveal-x:0px;--reveal-y:0px;--reveal-scale:1;--reveal-delay:0ms;transform:translate(var(--reveal-x), var(--reveal-y)) scale(var(--reveal-scale));transition-property:transform, opacity;transition-duration:var(--dur-base);transition-timing-function:var(--ease-out);transition-delay:var(--reveal-delay);}[data-reveal="up"] {--reveal-y:8px;}[data-reveal="down"] {--reveal-y:-8px;}[data-reveal="left"] {--reveal-x:8px;}[data-reveal="right"] {--reveal-x:-8px;}[data-reveal="scale"] {--reveal-scale:.97;}[data-reveal="none"] {--reveal-x:0px;--reveal-y:0px;--reveal-scale:1;}[data-reveal-ready] [data-reveal]:not([data-reveal-done]) {opacity:0;}[data-reveal-ready] [data-reveal][data-reveal-done] {opacity:1;--reveal-x:0px;--reveal-y:0px;--reveal-scale:1;}[data-reveal-children] > * {transition-delay:var(--reveal-delay, 0ms);}@media (prefers-reduced-motion:reduce) {[data-reveal] {transform:none;transition-property:opacity;transition-duration:var(--dur-fast);}[data-reveal-ready] [data-reveal]:not([data-reveal-done]) {opacity:1;}}
|