@sc4rfurryx/proteusjs 1.1.1 → 2.0.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.
Files changed (60) hide show
  1. package/README.md +684 -899
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/modules/a11y-audit.d.ts +1 -1
  4. package/dist/modules/a11y-audit.esm.js +3 -3
  5. package/dist/modules/a11y-primitives.d.ts +2 -2
  6. package/dist/modules/a11y-primitives.esm.js +2 -2
  7. package/dist/modules/a11y-primitives.esm.js.map +1 -1
  8. package/dist/modules/anchor.d.ts +1 -1
  9. package/dist/modules/anchor.esm.js +2 -2
  10. package/dist/modules/container.d.ts +1 -1
  11. package/dist/modules/container.esm.js +34 -34
  12. package/dist/modules/container.esm.js.map +1 -1
  13. package/dist/modules/perf.d.ts +1 -1
  14. package/dist/modules/perf.esm.js +2 -2
  15. package/dist/modules/popover.d.ts +1 -1
  16. package/dist/modules/popover.esm.js +2 -2
  17. package/dist/modules/scroll.d.ts +1 -1
  18. package/dist/modules/scroll.esm.js +14 -14
  19. package/dist/modules/scroll.esm.js.map +1 -1
  20. package/dist/modules/transitions.d.ts +1 -1
  21. package/dist/modules/transitions.esm.js +12 -12
  22. package/dist/modules/transitions.esm.js.map +1 -1
  23. package/dist/modules/typography.d.ts +1 -1
  24. package/dist/modules/typography.esm.js +2 -2
  25. package/dist/proteus.cjs.js +68 -68
  26. package/dist/proteus.cjs.js.map +1 -1
  27. package/dist/proteus.d.ts +13 -13
  28. package/dist/proteus.esm.js +68 -68
  29. package/dist/proteus.esm.js.map +1 -1
  30. package/dist/proteus.esm.min.js +2 -2
  31. package/dist/proteus.esm.min.js.map +1 -1
  32. package/dist/proteus.js +68 -68
  33. package/dist/proteus.js.map +1 -1
  34. package/dist/proteus.min.js +2 -2
  35. package/dist/proteus.min.js.map +1 -1
  36. package/package.json +40 -8
  37. package/src/adapters/react.ts +607 -264
  38. package/src/adapters/svelte.ts +321 -321
  39. package/src/adapters/vue.ts +268 -268
  40. package/src/core/ProteusJS.ts +6 -6
  41. package/src/index.ts +2 -2
  42. package/src/modules/a11y-audit/index.ts +84 -84
  43. package/src/modules/a11y-primitives/index.ts +151 -151
  44. package/src/modules/anchor/index.ts +259 -259
  45. package/src/modules/container/index.ts +230 -230
  46. package/src/modules/perf/index.ts +291 -291
  47. package/src/modules/popover/index.ts +238 -238
  48. package/src/modules/scroll/index.ts +251 -251
  49. package/src/modules/transitions/index.ts +145 -145
  50. package/src/modules/typography/index.ts +239 -239
  51. package/src/utils/version.ts +1 -1
  52. package/dist/adapters/react.d.ts +0 -140
  53. package/dist/adapters/react.esm.js +0 -849
  54. package/dist/adapters/react.esm.js.map +0 -1
  55. package/dist/adapters/svelte.d.ts +0 -181
  56. package/dist/adapters/svelte.esm.js +0 -909
  57. package/dist/adapters/svelte.esm.js.map +0 -1
  58. package/dist/adapters/vue.d.ts +0 -205
  59. package/dist/adapters/vue.esm.js +0 -873
  60. package/dist/adapters/vue.esm.js.map +0 -1
@@ -1,230 +1,230 @@
1
- /**
2
- * @sc4rfurryx/proteusjs/container
3
- * Container/Style Query helpers with visualization devtools
4
- *
5
- * @version 1.1.0
6
- * @author sc4rfurry
7
- * @license MIT
8
- */
9
-
10
- export interface ContainerOptions {
11
- type?: 'size' | 'style';
12
- inlineSize?: boolean;
13
- }
14
-
15
- /**
16
- * Sugar on native container queries with dev visualization
17
- */
18
- export function defineContainer(
19
- target: Element | string,
20
- name?: string,
21
- opts: ContainerOptions = {}
22
- ): void {
23
- const targetEl = typeof target === 'string' ? document.querySelector(target) : target;
24
- if (!targetEl) {
25
- throw new Error('Target element not found');
26
- }
27
-
28
- const {
29
- type = 'size',
30
- inlineSize: _inlineSize = true
31
- } = opts;
32
-
33
- const containerName = name || `container-${Math.random().toString(36).substring(2, 11)}`;
34
-
35
- // Apply container properties
36
- const element = targetEl as HTMLElement;
37
- element.style.containerName = containerName;
38
- element.style.containerType = type;
39
-
40
- // Warn if containment settings are missing
41
- const computedStyle = getComputedStyle(element);
42
- if (!computedStyle.contain || computedStyle.contain === 'none') {
43
- console.warn(`Container "${containerName}" may need explicit containment settings for optimal performance`);
44
- }
45
-
46
- // Dev overlay (only in development)
47
- if (process.env['NODE_ENV'] === 'development' || (window as unknown as { __PROTEUS_DEV__?: boolean }).__PROTEUS_DEV__) {
48
- createDevOverlay(element, containerName);
49
- }
50
- }
51
-
52
- /**
53
- * Create development overlay showing container bounds and breakpoints
54
- */
55
- function createDevOverlay(element: HTMLElement, name: string): void {
56
- const overlay = document.createElement('div');
57
- overlay.className = 'proteus-container-overlay';
58
- overlay.style.cssText = `
59
- position: absolute;
60
- top: 0;
61
- left: 0;
62
- right: 0;
63
- bottom: 0;
64
- pointer-events: none;
65
- border: 2px dashed rgba(255, 0, 255, 0.5);
66
- background: rgba(255, 0, 255, 0.05);
67
- z-index: 9999;
68
- font-family: monospace;
69
- font-size: 12px;
70
- color: #ff00ff;
71
- `;
72
-
73
- const label = document.createElement('div');
74
- label.style.cssText = `
75
- position: absolute;
76
- top: -20px;
77
- left: 0;
78
- background: rgba(255, 0, 255, 0.9);
79
- color: white;
80
- padding: 2px 6px;
81
- border-radius: 3px;
82
- font-size: 10px;
83
- white-space: nowrap;
84
- `;
85
- label.textContent = `Container: ${name}`;
86
-
87
- const sizeInfo = document.createElement('div');
88
- sizeInfo.style.cssText = `
89
- position: absolute;
90
- bottom: 2px;
91
- right: 2px;
92
- background: rgba(0, 0, 0, 0.7);
93
- color: white;
94
- padding: 2px 4px;
95
- border-radius: 2px;
96
- font-size: 10px;
97
- `;
98
-
99
- overlay.appendChild(label);
100
- overlay.appendChild(sizeInfo);
101
-
102
- // Position overlay relative to container
103
- if (getComputedStyle(element).position === 'static') {
104
- element.style.position = 'relative';
105
- }
106
- element.appendChild(overlay);
107
-
108
- // Update size info
109
- const updateSizeInfo = () => {
110
- const rect = element.getBoundingClientRect();
111
- sizeInfo.textContent = `${Math.round(rect.width)}×${Math.round(rect.height)}`;
112
- };
113
-
114
- updateSizeInfo();
115
-
116
- // Update on resize
117
- if ('ResizeObserver' in window) {
118
- const resizeObserver = new ResizeObserver(updateSizeInfo);
119
- resizeObserver.observe(element);
120
- }
121
-
122
- // Store cleanup function
123
- (element as HTMLElement & { _proteusContainerCleanup?: () => void })._proteusContainerCleanup = () => {
124
- overlay.remove();
125
- };
126
- }
127
-
128
- /**
129
- * Helper to create container query CSS rules
130
- */
131
- export function createContainerQuery(
132
- containerName: string,
133
- condition: string,
134
- styles: Record<string, string>
135
- ): string {
136
- const cssRules = Object.entries(styles)
137
- .map(([property, value]) => ` ${property}: ${value};`)
138
- .join('\n');
139
-
140
- return `@container ${containerName} (${condition}) {\n${cssRules}\n}`;
141
- }
142
-
143
- /**
144
- * Apply container query styles dynamically
145
- */
146
- export function applyContainerQuery(
147
- containerName: string,
148
- condition: string,
149
- styles: Record<string, string>
150
- ): void {
151
- const css = createContainerQuery(containerName, condition, styles);
152
-
153
- const styleElement = document.createElement('style');
154
- styleElement.textContent = css;
155
- styleElement.setAttribute('data-proteus-container', containerName);
156
- document.head.appendChild(styleElement);
157
- }
158
-
159
- /**
160
- * Remove container query styles
161
- */
162
- export function removeContainerQuery(containerName: string): void {
163
- const styleElements = document.querySelectorAll(`style[data-proteus-container="${containerName}"]`);
164
- styleElements.forEach(element => element.remove());
165
- }
166
-
167
- /**
168
- * Get container size information
169
- */
170
- export function getContainerSize(target: Element | string): { width: number; height: number } {
171
- const targetEl = typeof target === 'string' ? document.querySelector(target) : target;
172
- if (!targetEl) {
173
- throw new Error('Target element not found');
174
- }
175
-
176
- const rect = targetEl.getBoundingClientRect();
177
- return {
178
- width: rect.width,
179
- height: rect.height
180
- };
181
- }
182
-
183
- /**
184
- * Check if container queries are supported
185
- */
186
- export function isSupported(): boolean {
187
- return CSS.supports('container-type', 'size');
188
- }
189
-
190
- /**
191
- * Cleanup container overlays and observers
192
- */
193
- export function cleanup(target: Element | string): void {
194
- const targetEl = typeof target === 'string' ? document.querySelector(target) : target;
195
- if (!targetEl) return;
196
-
197
- // Call stored cleanup function if it exists
198
- const elementWithCleanup = targetEl as HTMLElement & { _proteusContainerCleanup?: () => void };
199
- if (elementWithCleanup._proteusContainerCleanup) {
200
- elementWithCleanup._proteusContainerCleanup();
201
- delete elementWithCleanup._proteusContainerCleanup;
202
- }
203
- }
204
-
205
- /**
206
- * Toggle dev overlay visibility
207
- */
208
- export function toggleDevOverlay(visible?: boolean): void {
209
- const overlays = document.querySelectorAll('.proteus-container-overlay');
210
- overlays.forEach(overlay => {
211
- const element = overlay as HTMLElement;
212
- if (visible !== undefined) {
213
- element.style.display = visible ? 'block' : 'none';
214
- } else {
215
- element.style.display = element.style.display === 'none' ? 'block' : 'none';
216
- }
217
- });
218
- }
219
-
220
- // Export default object for convenience
221
- export default {
222
- defineContainer,
223
- createContainerQuery,
224
- applyContainerQuery,
225
- removeContainerQuery,
226
- getContainerSize,
227
- isSupported,
228
- cleanup,
229
- toggleDevOverlay
230
- };
1
+ /**
2
+ * @sc4rfurryx/proteusjs/container
3
+ * Container/Style Query helpers with visualization devtools
4
+ *
5
+ * @version 2.0.0
6
+ * @author sc4rfurry
7
+ * @license MIT
8
+ */
9
+
10
+ export interface ContainerOptions {
11
+ type?: 'size' | 'style';
12
+ inlineSize?: boolean;
13
+ }
14
+
15
+ /**
16
+ * Sugar on native container queries with dev visualization
17
+ */
18
+ export function defineContainer(
19
+ target: Element | string,
20
+ name?: string,
21
+ opts: ContainerOptions = {}
22
+ ): void {
23
+ const targetEl = typeof target === 'string' ? document.querySelector(target) : target;
24
+ if (!targetEl) {
25
+ throw new Error('Target element not found');
26
+ }
27
+
28
+ const {
29
+ type = 'size',
30
+ inlineSize: _inlineSize = true
31
+ } = opts;
32
+
33
+ const containerName = name || `container-${Math.random().toString(36).substring(2, 11)}`;
34
+
35
+ // Apply container properties
36
+ const element = targetEl as HTMLElement;
37
+ element.style.containerName = containerName;
38
+ element.style.containerType = type;
39
+
40
+ // Warn if containment settings are missing
41
+ const computedStyle = getComputedStyle(element);
42
+ if (!computedStyle.contain || computedStyle.contain === 'none') {
43
+ console.warn(`Container "${containerName}" may need explicit containment settings for optimal performance`);
44
+ }
45
+
46
+ // Dev overlay (only in development)
47
+ if (process.env['NODE_ENV'] === 'development' || (window as unknown as { __PROTEUS_DEV__?: boolean }).__PROTEUS_DEV__) {
48
+ createDevOverlay(element, containerName);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Create development overlay showing container bounds and breakpoints
54
+ */
55
+ function createDevOverlay(element: HTMLElement, name: string): void {
56
+ const overlay = document.createElement('div');
57
+ overlay.className = 'proteus-container-overlay';
58
+ overlay.style.cssText = `
59
+ position: absolute;
60
+ top: 0;
61
+ left: 0;
62
+ right: 0;
63
+ bottom: 0;
64
+ pointer-events: none;
65
+ border: 2px dashed rgba(255, 0, 255, 0.5);
66
+ background: rgba(255, 0, 255, 0.05);
67
+ z-index: 9999;
68
+ font-family: monospace;
69
+ font-size: 12px;
70
+ color: #ff00ff;
71
+ `;
72
+
73
+ const label = document.createElement('div');
74
+ label.style.cssText = `
75
+ position: absolute;
76
+ top: -20px;
77
+ left: 0;
78
+ background: rgba(255, 0, 255, 0.9);
79
+ color: white;
80
+ padding: 2px 6px;
81
+ border-radius: 3px;
82
+ font-size: 10px;
83
+ white-space: nowrap;
84
+ `;
85
+ label.textContent = `Container: ${name}`;
86
+
87
+ const sizeInfo = document.createElement('div');
88
+ sizeInfo.style.cssText = `
89
+ position: absolute;
90
+ bottom: 2px;
91
+ right: 2px;
92
+ background: rgba(0, 0, 0, 0.7);
93
+ color: white;
94
+ padding: 2px 4px;
95
+ border-radius: 2px;
96
+ font-size: 10px;
97
+ `;
98
+
99
+ overlay.appendChild(label);
100
+ overlay.appendChild(sizeInfo);
101
+
102
+ // Position overlay relative to container
103
+ if (getComputedStyle(element).position === 'static') {
104
+ element.style.position = 'relative';
105
+ }
106
+ element.appendChild(overlay);
107
+
108
+ // Update size info
109
+ const updateSizeInfo = () => {
110
+ const rect = element.getBoundingClientRect();
111
+ sizeInfo.textContent = `${Math.round(rect.width)}×${Math.round(rect.height)}`;
112
+ };
113
+
114
+ updateSizeInfo();
115
+
116
+ // Update on resize
117
+ if ('ResizeObserver' in window) {
118
+ const resizeObserver = new ResizeObserver(updateSizeInfo);
119
+ resizeObserver.observe(element);
120
+ }
121
+
122
+ // Store cleanup function
123
+ (element as HTMLElement & { _proteusContainerCleanup?: () => void })._proteusContainerCleanup = () => {
124
+ overlay.remove();
125
+ };
126
+ }
127
+
128
+ /**
129
+ * Helper to create container query CSS rules
130
+ */
131
+ export function createContainerQuery(
132
+ containerName: string,
133
+ condition: string,
134
+ styles: Record<string, string>
135
+ ): string {
136
+ const cssRules = Object.entries(styles)
137
+ .map(([property, value]) => ` ${property}: ${value};`)
138
+ .join('\n');
139
+
140
+ return `@container ${containerName} (${condition}) {\n${cssRules}\n}`;
141
+ }
142
+
143
+ /**
144
+ * Apply container query styles dynamically
145
+ */
146
+ export function applyContainerQuery(
147
+ containerName: string,
148
+ condition: string,
149
+ styles: Record<string, string>
150
+ ): void {
151
+ const css = createContainerQuery(containerName, condition, styles);
152
+
153
+ const styleElement = document.createElement('style');
154
+ styleElement.textContent = css;
155
+ styleElement.setAttribute('data-proteus-container', containerName);
156
+ document.head.appendChild(styleElement);
157
+ }
158
+
159
+ /**
160
+ * Remove container query styles
161
+ */
162
+ export function removeContainerQuery(containerName: string): void {
163
+ const styleElements = document.querySelectorAll(`style[data-proteus-container="${containerName}"]`);
164
+ styleElements.forEach(element => element.remove());
165
+ }
166
+
167
+ /**
168
+ * Get container size information
169
+ */
170
+ export function getContainerSize(target: Element | string): { width: number; height: number } {
171
+ const targetEl = typeof target === 'string' ? document.querySelector(target) : target;
172
+ if (!targetEl) {
173
+ throw new Error('Target element not found');
174
+ }
175
+
176
+ const rect = targetEl.getBoundingClientRect();
177
+ return {
178
+ width: rect.width,
179
+ height: rect.height
180
+ };
181
+ }
182
+
183
+ /**
184
+ * Check if container queries are supported
185
+ */
186
+ export function isSupported(): boolean {
187
+ return CSS.supports('container-type', 'size');
188
+ }
189
+
190
+ /**
191
+ * Cleanup container overlays and observers
192
+ */
193
+ export function cleanup(target: Element | string): void {
194
+ const targetEl = typeof target === 'string' ? document.querySelector(target) : target;
195
+ if (!targetEl) return;
196
+
197
+ // Call stored cleanup function if it exists
198
+ const elementWithCleanup = targetEl as HTMLElement & { _proteusContainerCleanup?: () => void };
199
+ if (elementWithCleanup._proteusContainerCleanup) {
200
+ elementWithCleanup._proteusContainerCleanup();
201
+ delete elementWithCleanup._proteusContainerCleanup;
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Toggle dev overlay visibility
207
+ */
208
+ export function toggleDevOverlay(visible?: boolean): void {
209
+ const overlays = document.querySelectorAll('.proteus-container-overlay');
210
+ overlays.forEach(overlay => {
211
+ const element = overlay as HTMLElement;
212
+ if (visible !== undefined) {
213
+ element.style.display = visible ? 'block' : 'none';
214
+ } else {
215
+ element.style.display = element.style.display === 'none' ? 'block' : 'none';
216
+ }
217
+ });
218
+ }
219
+
220
+ // Export default object for convenience
221
+ export default {
222
+ defineContainer,
223
+ createContainerQuery,
224
+ applyContainerQuery,
225
+ removeContainerQuery,
226
+ getContainerSize,
227
+ isSupported,
228
+ cleanup,
229
+ toggleDevOverlay
230
+ };