@sc4rfurryx/proteusjs 1.0.0 → 1.1.0
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/LICENSE +1 -1
- package/README.md +331 -77
- package/dist/.tsbuildinfo +1 -1
- package/dist/adapters/react.d.ts +139 -0
- package/dist/adapters/react.esm.js +848 -0
- package/dist/adapters/react.esm.js.map +1 -0
- package/dist/adapters/svelte.d.ts +181 -0
- package/dist/adapters/svelte.esm.js +908 -0
- package/dist/adapters/svelte.esm.js.map +1 -0
- package/dist/adapters/vue.d.ts +205 -0
- package/dist/adapters/vue.esm.js +872 -0
- package/dist/adapters/vue.esm.js.map +1 -0
- package/dist/modules/a11y-audit.d.ts +39 -0
- package/dist/modules/a11y-audit.esm.js +509 -0
- package/dist/modules/a11y-audit.esm.js.map +1 -0
- package/dist/modules/a11y-primitives.d.ts +69 -0
- package/dist/modules/a11y-primitives.esm.js +445 -0
- package/dist/modules/a11y-primitives.esm.js.map +1 -0
- package/dist/modules/anchor.d.ts +29 -0
- package/dist/modules/anchor.esm.js +218 -0
- package/dist/modules/anchor.esm.js.map +1 -0
- package/dist/modules/container.d.ts +60 -0
- package/dist/modules/container.esm.js +194 -0
- package/dist/modules/container.esm.js.map +1 -0
- package/dist/modules/perf.d.ts +82 -0
- package/dist/modules/perf.esm.js +257 -0
- package/dist/modules/perf.esm.js.map +1 -0
- package/dist/modules/popover.d.ts +33 -0
- package/dist/modules/popover.esm.js +191 -0
- package/dist/modules/popover.esm.js.map +1 -0
- package/dist/modules/scroll.d.ts +43 -0
- package/dist/modules/scroll.esm.js +195 -0
- package/dist/modules/scroll.esm.js.map +1 -0
- package/dist/modules/transitions.d.ts +35 -0
- package/dist/modules/transitions.esm.js +120 -0
- package/dist/modules/transitions.esm.js.map +1 -0
- package/dist/modules/typography.d.ts +72 -0
- package/dist/modules/typography.esm.js +168 -0
- package/dist/modules/typography.esm.js.map +1 -0
- package/dist/proteus.cjs.js +2332 -12
- package/dist/proteus.cjs.js.map +1 -1
- package/dist/proteus.d.ts +561 -12
- package/dist/proteus.esm.js +2323 -12
- package/dist/proteus.esm.js.map +1 -1
- package/dist/proteus.esm.min.js +3 -3
- package/dist/proteus.esm.min.js.map +1 -1
- package/dist/proteus.js +2332 -12
- package/dist/proteus.js.map +1 -1
- package/dist/proteus.min.js +3 -3
- package/dist/proteus.min.js.map +1 -1
- package/package.json +61 -4
- package/src/adapters/react.ts +264 -0
- package/src/adapters/svelte.ts +321 -0
- package/src/adapters/vue.ts +268 -0
- package/src/index.ts +33 -6
- package/src/modules/a11y-audit/index.ts +608 -0
- package/src/modules/a11y-primitives/index.ts +554 -0
- package/src/modules/anchor/index.ts +257 -0
- package/src/modules/container/index.ts +230 -0
- package/src/modules/perf/index.ts +291 -0
- package/src/modules/popover/index.ts +238 -0
- package/src/modules/scroll/index.ts +251 -0
- package/src/modules/transitions/index.ts +145 -0
- package/src/modules/typography/index.ts +239 -0
- package/src/utils/version.ts +1 -1
@@ -0,0 +1,257 @@
|
|
1
|
+
/*!
|
2
|
+
* ProteusJS v1.1.0
|
3
|
+
* Shape-shifting responsive design that adapts like the sea god himself
|
4
|
+
* (c) 2025 sc4rfurry
|
5
|
+
* Released under the MIT License
|
6
|
+
*/
|
7
|
+
/**
|
8
|
+
* @sc4rfurryx/proteusjs/perf
|
9
|
+
* Performance guardrails and CWV-friendly patterns
|
10
|
+
*
|
11
|
+
* @version 1.1.0
|
12
|
+
* @author sc4rfurry
|
13
|
+
* @license MIT
|
14
|
+
*/
|
15
|
+
/**
|
16
|
+
* Apply content-visibility for performance optimization
|
17
|
+
*/
|
18
|
+
function contentVisibility(selector, mode = 'auto', opts = {}) {
|
19
|
+
const elements = typeof selector === 'string'
|
20
|
+
? document.querySelectorAll(selector)
|
21
|
+
: [selector];
|
22
|
+
const { containIntrinsicSize = '1000px 400px' } = opts;
|
23
|
+
elements.forEach(element => {
|
24
|
+
const el = element;
|
25
|
+
el.style.contentVisibility = mode;
|
26
|
+
if (mode === 'auto') {
|
27
|
+
el.style.containIntrinsicSize = containIntrinsicSize;
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Set fetch priority for resources
|
33
|
+
*/
|
34
|
+
function fetchPriority(selector, priority) {
|
35
|
+
const elements = typeof selector === 'string'
|
36
|
+
? document.querySelectorAll(selector)
|
37
|
+
: [selector];
|
38
|
+
elements.forEach(element => {
|
39
|
+
if (element instanceof HTMLImageElement ||
|
40
|
+
element instanceof HTMLLinkElement ||
|
41
|
+
element instanceof HTMLScriptElement) {
|
42
|
+
element.fetchPriority = priority;
|
43
|
+
}
|
44
|
+
});
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* Set up speculation rules for prerendering and prefetching
|
48
|
+
*/
|
49
|
+
function speculate(opts) {
|
50
|
+
const { prerender = [], prefetch = [], sameOriginOnly = true } = opts;
|
51
|
+
// Check for Speculation Rules API support
|
52
|
+
if (!('supports' in HTMLScriptElement && HTMLScriptElement.supports('speculationrules'))) {
|
53
|
+
console.warn('Speculation Rules API not supported');
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
const rules = {};
|
57
|
+
if (prerender.length > 0) {
|
58
|
+
rules.prerender = prerender.map(url => {
|
59
|
+
const rule = { where: { href_matches: url } };
|
60
|
+
if (sameOriginOnly) {
|
61
|
+
rule.where.href_matches = new URL(url, window.location.origin).href;
|
62
|
+
}
|
63
|
+
return rule;
|
64
|
+
});
|
65
|
+
}
|
66
|
+
if (prefetch.length > 0) {
|
67
|
+
rules.prefetch = prefetch.map(url => {
|
68
|
+
const rule = { where: { href_matches: url } };
|
69
|
+
if (sameOriginOnly) {
|
70
|
+
rule.where.href_matches = new URL(url, window.location.origin).href;
|
71
|
+
}
|
72
|
+
return rule;
|
73
|
+
});
|
74
|
+
}
|
75
|
+
if (Object.keys(rules).length === 0)
|
76
|
+
return;
|
77
|
+
// Create and inject speculation rules script
|
78
|
+
const script = document.createElement('script');
|
79
|
+
script.type = 'speculationrules';
|
80
|
+
script.textContent = JSON.stringify(rules);
|
81
|
+
document.head.appendChild(script);
|
82
|
+
}
|
83
|
+
/**
|
84
|
+
* Yield to browser using scheduler.yield or postTask when available
|
85
|
+
*/
|
86
|
+
async function yieldToBrowser() {
|
87
|
+
// Use scheduler.yield if available (Chrome 115+)
|
88
|
+
if ('scheduler' in window && 'yield' in window.scheduler) {
|
89
|
+
return window.scheduler.yield();
|
90
|
+
}
|
91
|
+
// Use scheduler.postTask if available
|
92
|
+
if ('scheduler' in window && 'postTask' in window.scheduler) {
|
93
|
+
return new Promise(resolve => {
|
94
|
+
window.scheduler.postTask(resolve, { priority: 'user-blocking' });
|
95
|
+
});
|
96
|
+
}
|
97
|
+
// Fallback to setTimeout
|
98
|
+
return new Promise(resolve => {
|
99
|
+
setTimeout(resolve, 0);
|
100
|
+
});
|
101
|
+
}
|
102
|
+
/**
|
103
|
+
* Optimize images with loading and decoding hints
|
104
|
+
*/
|
105
|
+
function optimizeImages(selector = 'img') {
|
106
|
+
const images = typeof selector === 'string'
|
107
|
+
? document.querySelectorAll(selector)
|
108
|
+
: [selector];
|
109
|
+
images.forEach(img => {
|
110
|
+
if (!(img instanceof HTMLImageElement))
|
111
|
+
return;
|
112
|
+
// Set loading attribute if not already set
|
113
|
+
if (!img.hasAttribute('loading')) {
|
114
|
+
const rect = img.getBoundingClientRect();
|
115
|
+
const isAboveFold = rect.top < window.innerHeight;
|
116
|
+
img.loading = isAboveFold ? 'eager' : 'lazy';
|
117
|
+
}
|
118
|
+
// Set decoding hint
|
119
|
+
if (!img.hasAttribute('decoding')) {
|
120
|
+
img.decoding = 'async';
|
121
|
+
}
|
122
|
+
// Set fetch priority for above-fold images
|
123
|
+
if (!img.hasAttribute('fetchpriority')) {
|
124
|
+
const rect = img.getBoundingClientRect();
|
125
|
+
const isAboveFold = rect.top < window.innerHeight;
|
126
|
+
if (isAboveFold) {
|
127
|
+
img.fetchPriority = 'high';
|
128
|
+
}
|
129
|
+
}
|
130
|
+
});
|
131
|
+
}
|
132
|
+
/**
|
133
|
+
* Preload critical resources
|
134
|
+
*/
|
135
|
+
function preloadCritical(resources) {
|
136
|
+
resources.forEach(({ href, as, type }) => {
|
137
|
+
// Check if already preloaded
|
138
|
+
const existing = document.querySelector(`link[rel="preload"][href="${href}"]`);
|
139
|
+
if (existing)
|
140
|
+
return;
|
141
|
+
const link = document.createElement('link');
|
142
|
+
link.rel = 'preload';
|
143
|
+
link.href = href;
|
144
|
+
link.as = as;
|
145
|
+
if (type) {
|
146
|
+
link.type = type;
|
147
|
+
}
|
148
|
+
document.head.appendChild(link);
|
149
|
+
});
|
150
|
+
}
|
151
|
+
/**
|
152
|
+
* Measure and report Core Web Vitals
|
153
|
+
*/
|
154
|
+
function measureCWV() {
|
155
|
+
return new Promise(resolve => {
|
156
|
+
const metrics = {};
|
157
|
+
let metricsCount = 0;
|
158
|
+
const totalMetrics = 3;
|
159
|
+
const checkComplete = () => {
|
160
|
+
metricsCount++;
|
161
|
+
if (metricsCount >= totalMetrics) {
|
162
|
+
resolve(metrics);
|
163
|
+
}
|
164
|
+
};
|
165
|
+
// LCP (Largest Contentful Paint)
|
166
|
+
if ('PerformanceObserver' in window) {
|
167
|
+
try {
|
168
|
+
const lcpObserver = new PerformanceObserver(list => {
|
169
|
+
const entries = list.getEntries();
|
170
|
+
const lastEntry = entries[entries.length - 1];
|
171
|
+
metrics.lcp = lastEntry.startTime;
|
172
|
+
});
|
173
|
+
lcpObserver.observe({ entryTypes: ['largest-contentful-paint'] });
|
174
|
+
// Stop observing after 10 seconds
|
175
|
+
setTimeout(() => {
|
176
|
+
lcpObserver.disconnect();
|
177
|
+
checkComplete();
|
178
|
+
}, 10000);
|
179
|
+
}
|
180
|
+
catch {
|
181
|
+
checkComplete();
|
182
|
+
}
|
183
|
+
// FID (First Input Delay)
|
184
|
+
try {
|
185
|
+
const fidObserver = new PerformanceObserver(list => {
|
186
|
+
const entries = list.getEntries();
|
187
|
+
entries.forEach((entry) => {
|
188
|
+
metrics.fid = entry.processingStart - entry.startTime;
|
189
|
+
});
|
190
|
+
fidObserver.disconnect();
|
191
|
+
checkComplete();
|
192
|
+
});
|
193
|
+
fidObserver.observe({ entryTypes: ['first-input'] });
|
194
|
+
// If no input after 10 seconds, consider FID as 0
|
195
|
+
setTimeout(() => {
|
196
|
+
if (metrics.fid === undefined) {
|
197
|
+
metrics.fid = 0;
|
198
|
+
fidObserver.disconnect();
|
199
|
+
checkComplete();
|
200
|
+
}
|
201
|
+
}, 10000);
|
202
|
+
}
|
203
|
+
catch {
|
204
|
+
checkComplete();
|
205
|
+
}
|
206
|
+
// CLS (Cumulative Layout Shift)
|
207
|
+
try {
|
208
|
+
let clsValue = 0;
|
209
|
+
const clsObserver = new PerformanceObserver(list => {
|
210
|
+
list.getEntries().forEach((entry) => {
|
211
|
+
if (!entry.hadRecentInput) {
|
212
|
+
clsValue += entry.value;
|
213
|
+
}
|
214
|
+
});
|
215
|
+
metrics.cls = clsValue;
|
216
|
+
});
|
217
|
+
clsObserver.observe({ entryTypes: ['layout-shift'] });
|
218
|
+
// Stop observing after 10 seconds
|
219
|
+
setTimeout(() => {
|
220
|
+
clsObserver.disconnect();
|
221
|
+
checkComplete();
|
222
|
+
}, 10000);
|
223
|
+
}
|
224
|
+
catch {
|
225
|
+
checkComplete();
|
226
|
+
}
|
227
|
+
}
|
228
|
+
else {
|
229
|
+
// Fallback if PerformanceObserver is not supported
|
230
|
+
setTimeout(() => resolve(metrics), 100);
|
231
|
+
}
|
232
|
+
});
|
233
|
+
}
|
234
|
+
// Export boost object to match usage examples in upgrade spec
|
235
|
+
const boost = {
|
236
|
+
contentVisibility,
|
237
|
+
fetchPriority,
|
238
|
+
speculate,
|
239
|
+
yieldToBrowser,
|
240
|
+
optimizeImages,
|
241
|
+
preloadCritical,
|
242
|
+
measureCWV
|
243
|
+
};
|
244
|
+
// Export all functions as named exports and default object
|
245
|
+
var index = {
|
246
|
+
contentVisibility,
|
247
|
+
fetchPriority,
|
248
|
+
speculate,
|
249
|
+
yieldToBrowser,
|
250
|
+
optimizeImages,
|
251
|
+
preloadCritical,
|
252
|
+
measureCWV,
|
253
|
+
boost
|
254
|
+
};
|
255
|
+
|
256
|
+
export { boost, contentVisibility, index as default, fetchPriority, measureCWV, optimizeImages, preloadCritical, speculate, yieldToBrowser };
|
257
|
+
//# sourceMappingURL=perf.esm.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"perf.esm.js","sources":["../../src/modules/perf/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAAA;;;;;;;AAOG;AAYH;;AAEG;AACG,SAAU,iBAAiB,CAC/B,QAA0B,EAC1B,IAAA,GAA0B,MAAM,EAChC,IAAA,GAAiC,EAAE,EAAA;AAEnC,IAAA,MAAM,QAAQ,GAAG,OAAO,QAAQ,KAAK;AACnC,UAAE,QAAQ,CAAC,gBAAgB,CAAC,QAAQ;AACpC,UAAE,CAAC,QAAQ,CAAC;AAEd,IAAA,MAAM,EAAE,oBAAoB,GAAG,cAAc,EAAE,GAAG,IAAI;AAEtD,IAAA,QAAQ,CAAC,OAAO,CAAC,OAAO,IAAG;QACzB,MAAM,EAAE,GAAG,OAAsB;AACjC,QAAA,EAAE,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI;AAEjC,QAAA,IAAI,IAAI,KAAK,MAAM,EAAE;AACnB,YAAA,EAAE,CAAC,KAAK,CAAC,oBAAoB,GAAG,oBAAoB;QACtD;AACF,IAAA,CAAC,CAAC;AACJ;AAEA;;AAEG;AACG,SAAU,aAAa,CAC3B,QAA0B,EAC1B,QAAiC,EAAA;AAEjC,IAAA,MAAM,QAAQ,GAAG,OAAO,QAAQ,KAAK;AACnC,UAAE,QAAQ,CAAC,gBAAgB,CAAC,QAAQ;AACpC,UAAE,CAAC,QAAQ,CAAC;AAEd,IAAA,QAAQ,CAAC,OAAO,CAAC,OAAO,IAAG;QACzB,IAAI,OAAO,YAAY,gBAAgB;AACnC,YAAA,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AG;IACnB,iBAAiB;IACjB,aAAa;IACb,SAAS;IACT,cAAc;IACd,cAAc;IACd,eAAe;IACf;;AAGF;AACA,YAAe;IACb,iBAAiB;IACjB,aAAa;IACb,SAAS;IACT,cAAc;IACd,cAAc;IACd,eAAe;IACf,UAAU;IACV;CACD;;;;"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/**
|
2
|
+
* @sc4rfurryx/proteusjs/popover
|
3
|
+
* HTML Popover API wrapper with robust focus/inert handling
|
4
|
+
*
|
5
|
+
* @version 1.1.0
|
6
|
+
* @author sc4rfurry
|
7
|
+
* @license MIT
|
8
|
+
*/
|
9
|
+
interface PopoverOptions {
|
10
|
+
type?: 'menu' | 'dialog' | 'tooltip';
|
11
|
+
trapFocus?: boolean;
|
12
|
+
restoreFocus?: boolean;
|
13
|
+
closeOnEscape?: boolean;
|
14
|
+
onOpen?: () => void;
|
15
|
+
onClose?: () => void;
|
16
|
+
}
|
17
|
+
interface PopoverController {
|
18
|
+
open(): void;
|
19
|
+
close(): void;
|
20
|
+
toggle(): void;
|
21
|
+
destroy(): void;
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* Unified API for menus, tooltips, and dialogs using the native Popover API
|
25
|
+
* with robust focus/inert handling
|
26
|
+
*/
|
27
|
+
declare function attach(trigger: Element | string, panel: Element | string, opts?: PopoverOptions): PopoverController;
|
28
|
+
declare const _default: {
|
29
|
+
attach: typeof attach;
|
30
|
+
};
|
31
|
+
|
32
|
+
export { attach, _default as default };
|
33
|
+
export type { PopoverController, PopoverOptions };
|
@@ -0,0 +1,191 @@
|
|
1
|
+
/*!
|
2
|
+
* ProteusJS v1.1.0
|
3
|
+
* Shape-shifting responsive design that adapts like the sea god himself
|
4
|
+
* (c) 2025 sc4rfurry
|
5
|
+
* Released under the MIT License
|
6
|
+
*/
|
7
|
+
/**
|
8
|
+
* @sc4rfurryx/proteusjs/popover
|
9
|
+
* HTML Popover API wrapper with robust focus/inert handling
|
10
|
+
*
|
11
|
+
* @version 1.1.0
|
12
|
+
* @author sc4rfurry
|
13
|
+
* @license MIT
|
14
|
+
*/
|
15
|
+
/**
|
16
|
+
* Unified API for menus, tooltips, and dialogs using the native Popover API
|
17
|
+
* with robust focus/inert handling
|
18
|
+
*/
|
19
|
+
function attach(trigger, panel, opts = {}) {
|
20
|
+
const triggerEl = typeof trigger === 'string' ? document.querySelector(trigger) : trigger;
|
21
|
+
const panelEl = typeof panel === 'string' ? document.querySelector(panel) : panel;
|
22
|
+
if (!triggerEl || !panelEl) {
|
23
|
+
throw new Error('Both trigger and panel elements must exist');
|
24
|
+
}
|
25
|
+
const { type = 'menu', trapFocus = type === 'dialog', restoreFocus = true, closeOnEscape = true, onOpen, onClose } = opts;
|
26
|
+
let isOpen = false;
|
27
|
+
let previousFocus = null;
|
28
|
+
let focusTrap = null;
|
29
|
+
// Check for native Popover API support
|
30
|
+
const hasPopoverAPI = 'popover' in HTMLElement.prototype;
|
31
|
+
// Set up ARIA attributes
|
32
|
+
const setupAria = () => {
|
33
|
+
const panelId = panelEl.id || `popover-${Math.random().toString(36).substr(2, 9)}`;
|
34
|
+
panelEl.id = panelId;
|
35
|
+
triggerEl.setAttribute('aria-expanded', 'false');
|
36
|
+
triggerEl.setAttribute('aria-controls', panelId);
|
37
|
+
if (type === 'menu') {
|
38
|
+
triggerEl.setAttribute('aria-haspopup', 'menu');
|
39
|
+
panelEl.setAttribute('role', 'menu');
|
40
|
+
}
|
41
|
+
else if (type === 'dialog') {
|
42
|
+
triggerEl.setAttribute('aria-haspopup', 'dialog');
|
43
|
+
panelEl.setAttribute('role', 'dialog');
|
44
|
+
panelEl.setAttribute('aria-modal', 'true');
|
45
|
+
}
|
46
|
+
else if (type === 'tooltip') {
|
47
|
+
triggerEl.setAttribute('aria-describedby', panelId);
|
48
|
+
panelEl.setAttribute('role', 'tooltip');
|
49
|
+
}
|
50
|
+
};
|
51
|
+
// Set up native popover if supported
|
52
|
+
const setupNativePopover = () => {
|
53
|
+
if (hasPopoverAPI) {
|
54
|
+
panelEl.popover = type === 'dialog' ? 'manual' : 'auto';
|
55
|
+
triggerEl.setAttribute('popovertarget', panelEl.id);
|
56
|
+
}
|
57
|
+
};
|
58
|
+
// Focus trap implementation
|
59
|
+
class FocusTrap {
|
60
|
+
constructor(container) {
|
61
|
+
this.container = container;
|
62
|
+
this.focusableElements = [];
|
63
|
+
this.handleKeyDown = (e) => {
|
64
|
+
if (e.key !== 'Tab')
|
65
|
+
return;
|
66
|
+
const firstElement = this.focusableElements[0];
|
67
|
+
const lastElement = this.focusableElements[this.focusableElements.length - 1];
|
68
|
+
if (e.shiftKey) {
|
69
|
+
if (document.activeElement === firstElement) {
|
70
|
+
e.preventDefault();
|
71
|
+
lastElement.focus();
|
72
|
+
}
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
if (document.activeElement === lastElement) {
|
76
|
+
e.preventDefault();
|
77
|
+
firstElement.focus();
|
78
|
+
}
|
79
|
+
}
|
80
|
+
};
|
81
|
+
this.updateFocusableElements();
|
82
|
+
}
|
83
|
+
updateFocusableElements() {
|
84
|
+
const selector = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
85
|
+
this.focusableElements = Array.from(this.container.querySelectorAll(selector));
|
86
|
+
}
|
87
|
+
activate() {
|
88
|
+
this.updateFocusableElements();
|
89
|
+
if (this.focusableElements.length > 0) {
|
90
|
+
this.focusableElements[0].focus();
|
91
|
+
}
|
92
|
+
document.addEventListener('keydown', this.handleKeyDown);
|
93
|
+
}
|
94
|
+
deactivate() {
|
95
|
+
document.removeEventListener('keydown', this.handleKeyDown);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
const open = () => {
|
99
|
+
if (isOpen)
|
100
|
+
return;
|
101
|
+
if (restoreFocus) {
|
102
|
+
previousFocus = document.activeElement;
|
103
|
+
}
|
104
|
+
if (hasPopoverAPI) {
|
105
|
+
panelEl.showPopover();
|
106
|
+
}
|
107
|
+
else {
|
108
|
+
panelEl.style.display = 'block';
|
109
|
+
panelEl.setAttribute('data-popover-open', 'true');
|
110
|
+
}
|
111
|
+
triggerEl.setAttribute('aria-expanded', 'true');
|
112
|
+
isOpen = true;
|
113
|
+
if (trapFocus) {
|
114
|
+
focusTrap = new FocusTrap(panelEl);
|
115
|
+
focusTrap.activate();
|
116
|
+
}
|
117
|
+
if (onOpen) {
|
118
|
+
onOpen();
|
119
|
+
}
|
120
|
+
};
|
121
|
+
const close = () => {
|
122
|
+
if (!isOpen)
|
123
|
+
return;
|
124
|
+
if (hasPopoverAPI) {
|
125
|
+
panelEl.hidePopover();
|
126
|
+
}
|
127
|
+
else {
|
128
|
+
panelEl.style.display = 'none';
|
129
|
+
panelEl.removeAttribute('data-popover-open');
|
130
|
+
}
|
131
|
+
triggerEl.setAttribute('aria-expanded', 'false');
|
132
|
+
isOpen = false;
|
133
|
+
if (focusTrap) {
|
134
|
+
focusTrap.deactivate();
|
135
|
+
focusTrap = null;
|
136
|
+
}
|
137
|
+
if (restoreFocus && previousFocus) {
|
138
|
+
previousFocus.focus();
|
139
|
+
previousFocus = null;
|
140
|
+
}
|
141
|
+
if (onClose) {
|
142
|
+
onClose();
|
143
|
+
}
|
144
|
+
};
|
145
|
+
const toggle = () => {
|
146
|
+
if (isOpen) {
|
147
|
+
close();
|
148
|
+
}
|
149
|
+
else {
|
150
|
+
open();
|
151
|
+
}
|
152
|
+
};
|
153
|
+
const handleKeyDown = (e) => {
|
154
|
+
if (closeOnEscape && e.key === 'Escape' && isOpen) {
|
155
|
+
e.preventDefault();
|
156
|
+
close();
|
157
|
+
}
|
158
|
+
};
|
159
|
+
const handleClick = (e) => {
|
160
|
+
e.preventDefault();
|
161
|
+
toggle();
|
162
|
+
};
|
163
|
+
const destroy = () => {
|
164
|
+
triggerEl.removeEventListener('click', handleClick);
|
165
|
+
document.removeEventListener('keydown', handleKeyDown);
|
166
|
+
if (focusTrap) {
|
167
|
+
focusTrap.deactivate();
|
168
|
+
}
|
169
|
+
if (isOpen) {
|
170
|
+
close();
|
171
|
+
}
|
172
|
+
};
|
173
|
+
// Initialize
|
174
|
+
setupAria();
|
175
|
+
setupNativePopover();
|
176
|
+
triggerEl.addEventListener('click', handleClick);
|
177
|
+
document.addEventListener('keydown', handleKeyDown);
|
178
|
+
return {
|
179
|
+
open,
|
180
|
+
close,
|
181
|
+
toggle,
|
182
|
+
destroy
|
183
|
+
};
|
184
|
+
}
|
185
|
+
// Export default object for convenience
|
186
|
+
var index = {
|
187
|
+
attach
|
188
|
+
};
|
189
|
+
|
190
|
+
export { attach, index as default };
|
191
|
+
//# sourceMappingURL=popover.esm.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"popover.esm.js","sources":["../../src/modules/popover/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAAA;;;;;;;AAOG;AAkBH;;;AAGG;AACG,SAAU,MAAM,CACpB,OAAyB,EACzB,KAAuB,EACvB,OAAuB,EAAE,EAAA;AAEzB,IAAA,MAAM,SAAS,GAAG,OAAO,OAAO,KAAK,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO;AACzF,IAAA,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,KAAK;AAEjF,IAAA,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE;AAC1B,QAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC;IAC/D;IAEA,MAAM,EACJ,IAAI,GAAG,MAAM,EACb,SAAS,GAAG,IAAI,KAAK,QAAQ,EAC7B,YAAY,GAAG,IAAI,EACnB,aAAa,GAAG,IAAI,EACpB,MAAM,EACN,OAAO,EACR,GAAG,IAAI;IAER,IAAI,MAAM,GAAG,KAAK;IAClB,IAAI,aAAa,GAAmB,IAAI;IACxC,IAAI,SAAS,GAAqB,IAAI;;AAGtC,IAAA,MAAM,aAAa,GAAG,SAAS,IAAI,WAAW,CAAC,SAAS;;IAGx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AAE;QACX;AACF,IAAA,CAAC;IAED,MAAM,MAAM,GAAG,MAAK;QAClB,IAAI,MAAM,EAAE;AACV,YAAA,KAAK,EAAE;QACT;aAAO;AACL,YAAA,IAAI,EAAE;QACR;AACF,IAAA,CAAC;AAED,IAAA,MAAM,aAAa,GAAG,CAAC,CAAgB,KAAI;QACzC,IAAI,aAAa,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,MAAM,EAAE;YACjD,CAAC,CAAC,cAAc,EAAE;AAClB,YAAA,KAAK,EAAE;QACT;AACF,IAAA,CAAC;AAED,IAAA,MAAM,WAAW,GAAG,CAAC,CAAQ,KAAI;QAC/B,CAAC,CAAC,cAAc,EAAE;AAClB,QAAA,MAAM,EAAE;AACV,IAAA,CAAC;IAED,MAAM,OAAO,GAAG,MAAK;AACnB,QAAA,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC;AACnD,QAAA,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC;QAEtD,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,UAAU,EAAE;QACxB;QAEA,IAAI,MAAM,EAAE;AACV,YAAA,KAAK,EAAE;QACT;AACF,IAAA,CAAC;;AAGD,IAAA,SAAS,EAAE;AACX,IAAA,kBAAkB,EAAE;AAEpB,IAAA,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC;AAChD,IAAA,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC;IAEnD,OAAO;QACL,IAAI;QACJ,KAAK;QACL,MAAM;QACN;KACD;AACH;AAEA;AACA,YAAe;IACb;CACD;;;;"}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/**
|
2
|
+
* @sc4rfurryx/proteusjs/scroll
|
3
|
+
* Scroll-driven animations with CSS Scroll-Linked Animations
|
4
|
+
*
|
5
|
+
* @version 1.1.0
|
6
|
+
* @author sc4rfurry
|
7
|
+
* @license MIT
|
8
|
+
*/
|
9
|
+
interface ScrollAnimateOptions {
|
10
|
+
keyframes: Keyframe[];
|
11
|
+
range?: [string, string];
|
12
|
+
timeline?: {
|
13
|
+
axis?: 'block' | 'inline';
|
14
|
+
start?: string;
|
15
|
+
end?: string;
|
16
|
+
};
|
17
|
+
fallback?: 'io' | false;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Zero-boilerplate setup for CSS Scroll-Linked Animations with fallbacks
|
21
|
+
*/
|
22
|
+
declare function scrollAnimate(target: Element | string, opts: ScrollAnimateOptions): void;
|
23
|
+
/**
|
24
|
+
* Create a scroll-triggered animation that plays once when element enters viewport
|
25
|
+
*/
|
26
|
+
declare function scrollTrigger(target: Element | string, keyframes: Keyframe[], options?: KeyframeAnimationOptions): void;
|
27
|
+
/**
|
28
|
+
* Parallax effect using scroll-driven animations
|
29
|
+
*/
|
30
|
+
declare function parallax(target: Element | string, speed?: number): void;
|
31
|
+
/**
|
32
|
+
* Cleanup function to remove scroll animations
|
33
|
+
*/
|
34
|
+
declare function cleanup(target: Element | string): void;
|
35
|
+
declare const _default: {
|
36
|
+
scrollAnimate: typeof scrollAnimate;
|
37
|
+
scrollTrigger: typeof scrollTrigger;
|
38
|
+
parallax: typeof parallax;
|
39
|
+
cleanup: typeof cleanup;
|
40
|
+
};
|
41
|
+
|
42
|
+
export { cleanup, _default as default, parallax, scrollAnimate, scrollTrigger };
|
43
|
+
export type { ScrollAnimateOptions };
|