@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,268 @@
|
|
1
|
+
/**
|
2
|
+
* @sc4rfurryx/proteusjs/adapters/vue
|
3
|
+
* Vue composables and directives for ProteusJS
|
4
|
+
*
|
5
|
+
* @version 1.1.0
|
6
|
+
* @author sc4rfurry
|
7
|
+
* @license MIT
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { ref, onMounted, onUnmounted, Ref } from 'vue';
|
11
|
+
import { transition, TransitionOptions } from '../modules/transitions';
|
12
|
+
import { scrollAnimate, ScrollAnimateOptions } from '../modules/scroll';
|
13
|
+
import { attach as attachPopover, PopoverOptions, PopoverController } from '../modules/popover';
|
14
|
+
import { tether, TetherOptions, TetherController } from '../modules/anchor';
|
15
|
+
import { defineContainer, ContainerOptions } from '../modules/container';
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Composable for view transitions
|
19
|
+
*/
|
20
|
+
export function useTransition() {
|
21
|
+
return {
|
22
|
+
transition: async (run: () => Promise<any> | any, opts?: TransitionOptions) => {
|
23
|
+
return transition(run, opts);
|
24
|
+
}
|
25
|
+
};
|
26
|
+
}
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Composable for scroll animations
|
30
|
+
*/
|
31
|
+
export function useScrollAnimate(
|
32
|
+
elementRef: Ref<HTMLElement | undefined>,
|
33
|
+
opts: ScrollAnimateOptions
|
34
|
+
) {
|
35
|
+
onMounted(() => {
|
36
|
+
if (elementRef.value) {
|
37
|
+
scrollAnimate(elementRef.value, opts);
|
38
|
+
}
|
39
|
+
});
|
40
|
+
|
41
|
+
return {
|
42
|
+
elementRef
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Composable for popover functionality
|
48
|
+
*/
|
49
|
+
export function usePopover(
|
50
|
+
triggerRef: Ref<HTMLElement | undefined>,
|
51
|
+
panelRef: Ref<HTMLElement | undefined>,
|
52
|
+
opts?: PopoverOptions
|
53
|
+
) {
|
54
|
+
const controller = ref<PopoverController | null>(null);
|
55
|
+
const isOpen = ref(false);
|
56
|
+
|
57
|
+
onMounted(() => {
|
58
|
+
if (triggerRef.value && panelRef.value) {
|
59
|
+
controller.value = attachPopover(triggerRef.value, panelRef.value, {
|
60
|
+
...opts,
|
61
|
+
onOpen: () => {
|
62
|
+
isOpen.value = true;
|
63
|
+
opts?.onOpen?.();
|
64
|
+
},
|
65
|
+
onClose: () => {
|
66
|
+
isOpen.value = false;
|
67
|
+
opts?.onClose?.();
|
68
|
+
}
|
69
|
+
});
|
70
|
+
}
|
71
|
+
});
|
72
|
+
|
73
|
+
onUnmounted(() => {
|
74
|
+
if (controller.value) {
|
75
|
+
controller.value.destroy();
|
76
|
+
}
|
77
|
+
});
|
78
|
+
|
79
|
+
const open = () => controller.value?.open();
|
80
|
+
const close = () => controller.value?.close();
|
81
|
+
const toggle = () => controller.value?.toggle();
|
82
|
+
|
83
|
+
return {
|
84
|
+
isOpen,
|
85
|
+
open,
|
86
|
+
close,
|
87
|
+
toggle
|
88
|
+
};
|
89
|
+
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Composable for anchor positioning
|
93
|
+
*/
|
94
|
+
export function useAnchor(
|
95
|
+
floatingRef: Ref<HTMLElement | undefined>,
|
96
|
+
anchorRef: Ref<HTMLElement | undefined>,
|
97
|
+
opts?: Omit<TetherOptions, 'anchor'>
|
98
|
+
) {
|
99
|
+
const controller = ref<TetherController | null>(null);
|
100
|
+
|
101
|
+
onMounted(() => {
|
102
|
+
if (floatingRef.value && anchorRef.value) {
|
103
|
+
controller.value = tether(floatingRef.value, {
|
104
|
+
anchor: anchorRef.value,
|
105
|
+
...opts
|
106
|
+
});
|
107
|
+
}
|
108
|
+
});
|
109
|
+
|
110
|
+
onUnmounted(() => {
|
111
|
+
if (controller.value) {
|
112
|
+
controller.value.destroy();
|
113
|
+
}
|
114
|
+
});
|
115
|
+
|
116
|
+
return {
|
117
|
+
controller
|
118
|
+
};
|
119
|
+
}
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Composable for container queries
|
123
|
+
*/
|
124
|
+
export function useContainer(
|
125
|
+
elementRef: Ref<HTMLElement | undefined>,
|
126
|
+
name?: string,
|
127
|
+
opts?: ContainerOptions
|
128
|
+
) {
|
129
|
+
onMounted(() => {
|
130
|
+
if (elementRef.value) {
|
131
|
+
defineContainer(elementRef.value, name, opts);
|
132
|
+
}
|
133
|
+
});
|
134
|
+
|
135
|
+
return {
|
136
|
+
elementRef
|
137
|
+
};
|
138
|
+
}
|
139
|
+
|
140
|
+
/**
|
141
|
+
* Vue directive for scroll animations
|
142
|
+
*/
|
143
|
+
export const vProteusScroll = {
|
144
|
+
mounted(el: HTMLElement, binding: { value: ScrollAnimateOptions }) {
|
145
|
+
scrollAnimate(el, binding.value);
|
146
|
+
}
|
147
|
+
};
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Vue directive for container queries
|
151
|
+
*/
|
152
|
+
export const vProteusContainer = {
|
153
|
+
mounted(el: HTMLElement, binding: { value?: { name?: string; options?: ContainerOptions } }) {
|
154
|
+
const { name, options } = binding.value || {};
|
155
|
+
defineContainer(el, name, options);
|
156
|
+
}
|
157
|
+
};
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Vue directive for performance optimizations
|
161
|
+
*/
|
162
|
+
export const vProteusPerf = {
|
163
|
+
mounted(el: HTMLElement) {
|
164
|
+
// Apply content visibility optimization
|
165
|
+
const observer = new IntersectionObserver(
|
166
|
+
(entries) => {
|
167
|
+
entries.forEach(entry => {
|
168
|
+
if (entry.isIntersecting) {
|
169
|
+
el.style.contentVisibility = 'visible';
|
170
|
+
} else {
|
171
|
+
el.style.contentVisibility = 'auto';
|
172
|
+
}
|
173
|
+
});
|
174
|
+
},
|
175
|
+
{ rootMargin: '50px' }
|
176
|
+
);
|
177
|
+
|
178
|
+
observer.observe(el);
|
179
|
+
|
180
|
+
// Store cleanup function
|
181
|
+
(el as any)._proteusCleanup = () => {
|
182
|
+
observer.disconnect();
|
183
|
+
};
|
184
|
+
},
|
185
|
+
unmounted(el: HTMLElement) {
|
186
|
+
if ((el as any)._proteusCleanup) {
|
187
|
+
(el as any)._proteusCleanup();
|
188
|
+
}
|
189
|
+
}
|
190
|
+
};
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Vue directive for accessibility enhancements
|
194
|
+
*/
|
195
|
+
export const vProteusA11y = {
|
196
|
+
mounted(el: HTMLElement, binding: { value?: { announceChanges?: boolean } }) {
|
197
|
+
const { announceChanges = false } = binding.value || {};
|
198
|
+
|
199
|
+
// Enhance focus indicators
|
200
|
+
const focusableElements = el.querySelectorAll(
|
201
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
202
|
+
);
|
203
|
+
|
204
|
+
focusableElements.forEach(element => {
|
205
|
+
const htmlEl = element as HTMLElement;
|
206
|
+
htmlEl.addEventListener('focus', () => {
|
207
|
+
htmlEl.style.outline = '2px solid #0066cc';
|
208
|
+
htmlEl.style.outlineOffset = '2px';
|
209
|
+
});
|
210
|
+
|
211
|
+
htmlEl.addEventListener('blur', () => {
|
212
|
+
htmlEl.style.outline = 'none';
|
213
|
+
});
|
214
|
+
});
|
215
|
+
|
216
|
+
if (announceChanges) {
|
217
|
+
const observer = new MutationObserver(() => {
|
218
|
+
const announcement = document.createElement('div');
|
219
|
+
announcement.setAttribute('aria-live', 'polite');
|
220
|
+
announcement.style.position = 'absolute';
|
221
|
+
announcement.style.left = '-10000px';
|
222
|
+
announcement.textContent = 'Content updated';
|
223
|
+
document.body.appendChild(announcement);
|
224
|
+
|
225
|
+
setTimeout(() => {
|
226
|
+
document.body.removeChild(announcement);
|
227
|
+
}, 1000);
|
228
|
+
});
|
229
|
+
|
230
|
+
observer.observe(el, { childList: true, subtree: true });
|
231
|
+
|
232
|
+
(el as any)._proteusA11yCleanup = () => {
|
233
|
+
observer.disconnect();
|
234
|
+
};
|
235
|
+
}
|
236
|
+
},
|
237
|
+
unmounted(el: HTMLElement) {
|
238
|
+
if ((el as any)._proteusA11yCleanup) {
|
239
|
+
(el as any)._proteusA11yCleanup();
|
240
|
+
}
|
241
|
+
}
|
242
|
+
};
|
243
|
+
|
244
|
+
/**
|
245
|
+
* Plugin for Vue 3
|
246
|
+
*/
|
247
|
+
export const ProteusPlugin = {
|
248
|
+
install(app: any) {
|
249
|
+
app.directive('proteus-scroll', vProteusScroll);
|
250
|
+
app.directive('proteus-container', vProteusContainer);
|
251
|
+
app.directive('proteus-perf', vProteusPerf);
|
252
|
+
app.directive('proteus-a11y', vProteusA11y);
|
253
|
+
}
|
254
|
+
};
|
255
|
+
|
256
|
+
// Export all composables and directives
|
257
|
+
export default {
|
258
|
+
useTransition,
|
259
|
+
useScrollAnimate,
|
260
|
+
usePopover,
|
261
|
+
useAnchor,
|
262
|
+
useContainer,
|
263
|
+
vProteusScroll,
|
264
|
+
vProteusContainer,
|
265
|
+
vProteusPerf,
|
266
|
+
vProteusA11y,
|
267
|
+
ProteusPlugin
|
268
|
+
};
|
package/src/index.ts
CHANGED
@@ -1,16 +1,32 @@
|
|
1
1
|
/**
|
2
|
-
* ProteusJS -
|
2
|
+
* ProteusJS - Native-first Web Development Primitives
|
3
3
|
* Shape-shifting responsive design that adapts like the sea god himself
|
4
|
-
*
|
5
|
-
* @version 1.
|
6
|
-
* @author
|
4
|
+
*
|
5
|
+
* @version 1.1.0
|
6
|
+
* @author sc4rfurry
|
7
7
|
* @license MIT
|
8
8
|
*/
|
9
9
|
|
10
|
-
// Core exports
|
10
|
+
// Core exports (legacy compatibility)
|
11
11
|
export { ProteusJS as default } from './core/ProteusJS';
|
12
12
|
export { ProteusJS } from './core/ProteusJS';
|
13
13
|
|
14
|
+
// New modular exports
|
15
|
+
export * as transitions from './modules/transitions';
|
16
|
+
export * as scroll from './modules/scroll';
|
17
|
+
export * as anchor from './modules/anchor';
|
18
|
+
export * as popover from './modules/popover';
|
19
|
+
export * as container from './modules/container';
|
20
|
+
export * as typography from './modules/typography';
|
21
|
+
export * as a11yAudit from './modules/a11y-audit';
|
22
|
+
export * as a11yPrimitives from './modules/a11y-primitives';
|
23
|
+
export * as perf from './modules/perf';
|
24
|
+
|
25
|
+
// Framework adapters are available as separate subpath exports:
|
26
|
+
// import { ... } from '@sc4rfurryx/proteusjs/adapters/react'
|
27
|
+
// import { ... } from '@sc4rfurryx/proteusjs/adapters/vue'
|
28
|
+
// import { ... } from '@sc4rfurryx/proteusjs/adapters/svelte'
|
29
|
+
|
14
30
|
// Type exports
|
15
31
|
export type {
|
16
32
|
ProteusConfig,
|
@@ -23,6 +39,17 @@ export type {
|
|
23
39
|
PerformanceConfig
|
24
40
|
} from './types';
|
25
41
|
|
42
|
+
// Module-specific type exports
|
43
|
+
export type { TransitionOptions, NavigateOptions } from './modules/transitions';
|
44
|
+
export type { ScrollAnimateOptions } from './modules/scroll';
|
45
|
+
export type { TetherOptions, TetherController } from './modules/anchor';
|
46
|
+
export type { PopoverOptions, PopoverController } from './modules/popover';
|
47
|
+
export type { ContainerOptions } from './modules/container';
|
48
|
+
export type { FluidTypeOptions, FluidTypeResult } from './modules/typography';
|
49
|
+
export type { AuditOptions, AuditReport, AuditViolation } from './modules/a11y-audit';
|
50
|
+
export type { Controller, DialogOptions, TooltipOptions, ComboboxOptions, ListboxOptions, FocusTrapController } from './modules/a11y-primitives';
|
51
|
+
export type { SpeculationOptions, ContentVisibilityOptions } from './modules/perf';
|
52
|
+
|
26
53
|
// Utility exports
|
27
54
|
export { version } from './utils/version';
|
28
55
|
export { isSupported } from './utils/support';
|
@@ -31,5 +58,5 @@ export { isSupported } from './utils/support';
|
|
31
58
|
export type { ProteusPlugin } from './core/PluginSystem';
|
32
59
|
|
33
60
|
// Constants
|
34
|
-
export const VERSION = '1.
|
61
|
+
export const VERSION = '1.1.0';
|
35
62
|
export const LIBRARY_NAME = 'ProteusJS';
|