@teo-garcia/react-shared 1.2.1 → 1.3.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/README.md +138 -136
- package/dist/components/client-only/client-only.d.ts +11 -0
- package/dist/components/client-only/client-only.d.ts.map +1 -0
- package/dist/components/client-only/client-only.js +17 -0
- package/dist/components/client-only/index.d.ts +2 -0
- package/dist/components/client-only/index.d.ts.map +1 -0
- package/dist/components/client-only/index.js +1 -0
- package/dist/components/dev-panel/dev-panel-features.d.ts +10 -0
- package/dist/components/dev-panel/dev-panel-features.d.ts.map +1 -0
- package/dist/components/dev-panel/dev-panel-features.js +29 -0
- package/dist/components/dev-panel/dev-panel.d.ts +15 -17
- package/dist/components/dev-panel/dev-panel.d.ts.map +1 -1
- package/dist/components/dev-panel/dev-panel.js +619 -99
- package/dist/components/dev-panel/index.d.ts +1 -1
- package/dist/components/dev-panel/index.d.ts.map +1 -1
- package/dist/components/dev-panel/index.js +1 -1
- package/dist/components/dev-panel/use-dev-panel-diagnostics.d.ts +39 -0
- package/dist/components/dev-panel/use-dev-panel-diagnostics.d.ts.map +1 -0
- package/dist/components/dev-panel/use-dev-panel-diagnostics.js +384 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/separator/separator.d.ts +4 -4
- package/dist/components/separator/separator.d.ts.map +1 -1
- package/dist/components/separator/separator.js +18 -6
- package/dist/components/skeleton/skeleton.d.ts +1 -1
- package/dist/components/skeleton/skeleton.d.ts.map +1 -1
- package/dist/components/skeleton/skeleton.js +19 -4
- package/dist/components/skip-link/skip-link.d.ts.map +1 -1
- package/dist/components/skip-link/skip-link.js +8 -5
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/use-breakpoint.d.ts +9 -0
- package/dist/hooks/use-breakpoint.d.ts.map +1 -0
- package/dist/hooks/use-breakpoint.js +47 -0
- package/dist/index.d.ts +2 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -7
- package/package.json +11 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DevPanel, type DevPanelProps } from './dev-panel.js';
|
|
1
|
+
export { ALL_DEV_PANEL_FEATURES, DevPanel, type DevPanelFeature, type DevPanelItem, type DevPanelLayout, type DevPanelProps, } from './dev-panel.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dev-panel/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dev-panel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DevPanel } from './dev-panel.js';
|
|
1
|
+
export { ALL_DEV_PANEL_FEATURES, DevPanel, } from './dev-panel.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DevPanelFeature } from './dev-panel-features.js';
|
|
2
|
+
export type ResolvedTheme = 'dark' | 'light';
|
|
3
|
+
export interface DevPanelDiagnostics {
|
|
4
|
+
canHover: boolean;
|
|
5
|
+
connectionSummary: string;
|
|
6
|
+
contrast: 'custom' | 'less' | 'more' | 'no-preference';
|
|
7
|
+
displayStandalone: boolean;
|
|
8
|
+
dpr: number;
|
|
9
|
+
focusPeek: string;
|
|
10
|
+
fps: number;
|
|
11
|
+
fpsSampled: boolean;
|
|
12
|
+
fullscreen: boolean;
|
|
13
|
+
heapUsedMb: number | null;
|
|
14
|
+
invertedColors: boolean;
|
|
15
|
+
locale: string;
|
|
16
|
+
online: boolean;
|
|
17
|
+
orientation: string;
|
|
18
|
+
pointerCoarse: boolean;
|
|
19
|
+
prefersColorScheme: ResolvedTheme;
|
|
20
|
+
reducedMotion: boolean;
|
|
21
|
+
reducedTransparency: boolean;
|
|
22
|
+
resolvedTheme: ResolvedTheme;
|
|
23
|
+
saveDataReduced: boolean;
|
|
24
|
+
safeBottom: number;
|
|
25
|
+
safeLeft: number;
|
|
26
|
+
safeRight: number;
|
|
27
|
+
safeTop: number;
|
|
28
|
+
scrollHeight: number;
|
|
29
|
+
scrollY: number;
|
|
30
|
+
scrollbarWidth: number;
|
|
31
|
+
timeZone: string;
|
|
32
|
+
visibility: DocumentVisibilityState;
|
|
33
|
+
vvHeight: number;
|
|
34
|
+
vvScale: number;
|
|
35
|
+
vvWidth: number;
|
|
36
|
+
}
|
|
37
|
+
export declare function devPanelFeaturesKey(features: DevPanelFeature[] | undefined): string;
|
|
38
|
+
export declare function useDevPanelDiagnostics(features: DevPanelFeature[] | undefined): DevPanelDiagnostics;
|
|
39
|
+
//# sourceMappingURL=use-dev-panel-diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dev-panel-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/components/dev-panel/use-dev-panel-diagnostics.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAE9D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAA;AAE5C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,OAAO,CAAA;IACjB,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,CAAA;IACtD,iBAAiB,EAAE,OAAO,CAAA;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,OAAO,CAAA;IACtB,kBAAkB,EAAE,aAAa,CAAA;IACjC,aAAa,EAAE,OAAO,CAAA;IACtB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,aAAa,EAAE,aAAa,CAAA;IAC5B,eAAe,EAAE,OAAO,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,uBAAuB,CAAA;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAqID,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,GACtC,MAAM,CAGR;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EAAE,GAAG,SAAS,GACtC,mBAAmB,CA0UrB"}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
const INITIAL = {
|
|
3
|
+
canHover: false,
|
|
4
|
+
connectionSummary: '',
|
|
5
|
+
contrast: 'no-preference',
|
|
6
|
+
displayStandalone: false,
|
|
7
|
+
dpr: 1,
|
|
8
|
+
focusPeek: '',
|
|
9
|
+
fps: 0,
|
|
10
|
+
fpsSampled: false,
|
|
11
|
+
fullscreen: false,
|
|
12
|
+
heapUsedMb: null,
|
|
13
|
+
invertedColors: false,
|
|
14
|
+
locale: '',
|
|
15
|
+
online: true,
|
|
16
|
+
orientation: 'unknown',
|
|
17
|
+
pointerCoarse: false,
|
|
18
|
+
prefersColorScheme: 'light',
|
|
19
|
+
reducedMotion: false,
|
|
20
|
+
reducedTransparency: false,
|
|
21
|
+
resolvedTheme: 'light',
|
|
22
|
+
saveDataReduced: false,
|
|
23
|
+
safeBottom: 0,
|
|
24
|
+
safeLeft: 0,
|
|
25
|
+
safeRight: 0,
|
|
26
|
+
safeTop: 0,
|
|
27
|
+
scrollHeight: 0,
|
|
28
|
+
scrollY: 0,
|
|
29
|
+
scrollbarWidth: 0,
|
|
30
|
+
timeZone: '',
|
|
31
|
+
visibility: 'visible',
|
|
32
|
+
vvHeight: 0,
|
|
33
|
+
vvScale: 1,
|
|
34
|
+
vvWidth: 0,
|
|
35
|
+
};
|
|
36
|
+
function resolveTheme(root) {
|
|
37
|
+
const explicitClassTheme = ['dark', 'light'].find((name) => root.classList.contains(name));
|
|
38
|
+
if (explicitClassTheme === 'dark' || explicitClassTheme === 'light') {
|
|
39
|
+
return explicitClassTheme;
|
|
40
|
+
}
|
|
41
|
+
const explicitAttributeTheme = root.getAttribute('data-theme') ??
|
|
42
|
+
root.getAttribute('data-color-scheme') ??
|
|
43
|
+
root.dataset.theme;
|
|
44
|
+
if (explicitAttributeTheme === 'dark' || explicitAttributeTheme === 'light') {
|
|
45
|
+
return explicitAttributeTheme;
|
|
46
|
+
}
|
|
47
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
48
|
+
? 'dark'
|
|
49
|
+
: 'light';
|
|
50
|
+
}
|
|
51
|
+
function readSafeAreaInsets() {
|
|
52
|
+
const probe = document.createElement('div');
|
|
53
|
+
probe.style.cssText =
|
|
54
|
+
'position:fixed;left:0;top:0;visibility:hidden;pointer-events:none;z-index:-1;' +
|
|
55
|
+
'padding-top:env(safe-area-inset-top,0px);padding-right:env(safe-area-inset-right,0px);' +
|
|
56
|
+
'padding-bottom:env(safe-area-inset-bottom,0px);padding-left:env(safe-area-inset-left,0px)';
|
|
57
|
+
document.documentElement.appendChild(probe);
|
|
58
|
+
const cs = getComputedStyle(probe);
|
|
59
|
+
const px = (v) => Math.round(parseFloat(v) || 0);
|
|
60
|
+
const top = px(cs.paddingTop);
|
|
61
|
+
const right = px(cs.paddingRight);
|
|
62
|
+
const bottom = px(cs.paddingBottom);
|
|
63
|
+
const left = px(cs.paddingLeft);
|
|
64
|
+
document.documentElement.removeChild(probe);
|
|
65
|
+
return { bottom, left, right, top };
|
|
66
|
+
}
|
|
67
|
+
function resolveContrast(m) {
|
|
68
|
+
try {
|
|
69
|
+
if (m('(prefers-contrast: more)').matches)
|
|
70
|
+
return 'more';
|
|
71
|
+
if (m('(prefers-contrast: less)').matches)
|
|
72
|
+
return 'less';
|
|
73
|
+
if (m('(prefers-contrast: custom)').matches)
|
|
74
|
+
return 'custom';
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
/* unsupported query */
|
|
78
|
+
}
|
|
79
|
+
return 'no-preference';
|
|
80
|
+
}
|
|
81
|
+
function orientationLabel() {
|
|
82
|
+
const o = screen.orientation;
|
|
83
|
+
if (o && typeof o.type === 'string')
|
|
84
|
+
return o.type;
|
|
85
|
+
return window.innerHeight >= window.innerWidth ? 'portrait' : 'landscape';
|
|
86
|
+
}
|
|
87
|
+
function focusPeekLabel() {
|
|
88
|
+
const el = document.activeElement;
|
|
89
|
+
if (!el || el === document.body)
|
|
90
|
+
return 'body';
|
|
91
|
+
if (el === document.documentElement)
|
|
92
|
+
return 'html';
|
|
93
|
+
const tag = el.tagName.toLowerCase();
|
|
94
|
+
let s = tag;
|
|
95
|
+
if (el.id)
|
|
96
|
+
s += `#${el.id}`;
|
|
97
|
+
if (el.className && typeof el.className === 'string') {
|
|
98
|
+
const cls = el.className.trim().split(/\s+/).filter(Boolean).slice(0, 2);
|
|
99
|
+
if (cls.length)
|
|
100
|
+
s += `.${cls.join('.')}`;
|
|
101
|
+
}
|
|
102
|
+
return s.length > 72 ? `${s.slice(0, 69)}…` : s;
|
|
103
|
+
}
|
|
104
|
+
function readConnectionSummary() {
|
|
105
|
+
const nav = navigator;
|
|
106
|
+
const c = nav.connection;
|
|
107
|
+
if (!c || typeof c.effectiveType !== 'string')
|
|
108
|
+
return 'unavailable';
|
|
109
|
+
const parts = [c.effectiveType];
|
|
110
|
+
if (typeof c.downlink === 'number')
|
|
111
|
+
parts.push(`${c.downlink} Mbps`);
|
|
112
|
+
if (typeof c.rtt === 'number')
|
|
113
|
+
parts.push(`rtt ${c.rtt}ms`);
|
|
114
|
+
return parts.join(' · ');
|
|
115
|
+
}
|
|
116
|
+
export function devPanelFeaturesKey(features) {
|
|
117
|
+
if (features == null || features.length === 0)
|
|
118
|
+
return '';
|
|
119
|
+
return [...features].sort().join('\0');
|
|
120
|
+
}
|
|
121
|
+
export function useDevPanelDiagnostics(features) {
|
|
122
|
+
const featureKey = devPanelFeaturesKey(features);
|
|
123
|
+
const enabled = useMemo(() => new Set(features ?? []), [featureKey]);
|
|
124
|
+
const [state, setState] = useState(INITIAL);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (typeof window === 'undefined')
|
|
127
|
+
return;
|
|
128
|
+
const patch = (partial) => setState((s) => ({ ...s, ...partial }));
|
|
129
|
+
function syncResolvedTheme() {
|
|
130
|
+
patch({ resolvedTheme: resolveTheme(document.documentElement) });
|
|
131
|
+
}
|
|
132
|
+
syncResolvedTheme();
|
|
133
|
+
const cleanups = [];
|
|
134
|
+
const themeObserver = new MutationObserver(syncResolvedTheme);
|
|
135
|
+
themeObserver.observe(document.documentElement, {
|
|
136
|
+
attributes: true,
|
|
137
|
+
attributeFilter: ['class', 'data-theme', 'data-color-scheme'],
|
|
138
|
+
});
|
|
139
|
+
cleanups.push(() => themeObserver.disconnect());
|
|
140
|
+
if (enabled.has('colorScheme')) {
|
|
141
|
+
const mColor = window.matchMedia('(prefers-color-scheme: dark)');
|
|
142
|
+
const onColor = () => patch({
|
|
143
|
+
prefersColorScheme: mColor.matches ? 'dark' : 'light',
|
|
144
|
+
});
|
|
145
|
+
onColor();
|
|
146
|
+
mColor.addEventListener('change', onColor);
|
|
147
|
+
cleanups.push(() => mColor.removeEventListener('change', onColor));
|
|
148
|
+
}
|
|
149
|
+
if (enabled.has('media')) {
|
|
150
|
+
const mReduced = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
151
|
+
const mPointer = window.matchMedia('(pointer: coarse)');
|
|
152
|
+
const mHover = window.matchMedia('(hover: hover)');
|
|
153
|
+
const onReduced = () => patch({ reducedMotion: mReduced.matches });
|
|
154
|
+
const onPointer = () => patch({ pointerCoarse: mPointer.matches });
|
|
155
|
+
const onHover = () => patch({ canHover: mHover.matches });
|
|
156
|
+
onReduced();
|
|
157
|
+
onPointer();
|
|
158
|
+
onHover();
|
|
159
|
+
mReduced.addEventListener('change', onReduced);
|
|
160
|
+
mPointer.addEventListener('change', onPointer);
|
|
161
|
+
mHover.addEventListener('change', onHover);
|
|
162
|
+
cleanups.push(() => mReduced.removeEventListener('change', onReduced), () => mPointer.removeEventListener('change', onPointer), () => mHover.removeEventListener('change', onHover));
|
|
163
|
+
}
|
|
164
|
+
if (enabled.has('dpr')) {
|
|
165
|
+
const update = () => patch({ dpr: Number(window.devicePixelRatio.toFixed(2)) });
|
|
166
|
+
update();
|
|
167
|
+
window.addEventListener('resize', update);
|
|
168
|
+
cleanups.push(() => window.removeEventListener('resize', update));
|
|
169
|
+
}
|
|
170
|
+
if (enabled.has('scroll')) {
|
|
171
|
+
const update = () => patch({
|
|
172
|
+
scrollHeight: document.documentElement.scrollHeight,
|
|
173
|
+
scrollY: Math.round(window.scrollY),
|
|
174
|
+
});
|
|
175
|
+
update();
|
|
176
|
+
window.addEventListener('scroll', update, { passive: true });
|
|
177
|
+
window.addEventListener('resize', update);
|
|
178
|
+
cleanups.push(() => window.removeEventListener('scroll', update), () => window.removeEventListener('resize', update));
|
|
179
|
+
}
|
|
180
|
+
if (enabled.has('safeArea')) {
|
|
181
|
+
const update = () => {
|
|
182
|
+
const { bottom, left, right, top } = readSafeAreaInsets();
|
|
183
|
+
patch({
|
|
184
|
+
safeBottom: bottom,
|
|
185
|
+
safeLeft: left,
|
|
186
|
+
safeRight: right,
|
|
187
|
+
safeTop: top,
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
update();
|
|
191
|
+
window.addEventListener('resize', update);
|
|
192
|
+
window.visualViewport?.addEventListener('resize', update);
|
|
193
|
+
cleanups.push(() => {
|
|
194
|
+
window.removeEventListener('resize', update);
|
|
195
|
+
window.visualViewport?.removeEventListener('resize', update);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (enabled.has('visualViewport') && window.visualViewport) {
|
|
199
|
+
const vv = window.visualViewport;
|
|
200
|
+
const update = () => patch({
|
|
201
|
+
vvHeight: Math.round(vv.height),
|
|
202
|
+
vvScale: Number(vv.scale.toFixed(3)),
|
|
203
|
+
vvWidth: Math.round(vv.width),
|
|
204
|
+
});
|
|
205
|
+
update();
|
|
206
|
+
vv.addEventListener('resize', update);
|
|
207
|
+
vv.addEventListener('scroll', update);
|
|
208
|
+
cleanups.push(() => vv.removeEventListener('resize', update), () => vv.removeEventListener('scroll', update));
|
|
209
|
+
}
|
|
210
|
+
if (enabled.has('scrollbar')) {
|
|
211
|
+
const update = () => patch({
|
|
212
|
+
scrollbarWidth: Math.max(0, window.innerWidth - document.documentElement.clientWidth),
|
|
213
|
+
});
|
|
214
|
+
update();
|
|
215
|
+
window.addEventListener('resize', update);
|
|
216
|
+
cleanups.push(() => window.removeEventListener('resize', update));
|
|
217
|
+
}
|
|
218
|
+
if (enabled.has('orientation')) {
|
|
219
|
+
const update = () => patch({ orientation: orientationLabel() });
|
|
220
|
+
update();
|
|
221
|
+
window.addEventListener('resize', update);
|
|
222
|
+
screen.orientation?.addEventListener('change', update);
|
|
223
|
+
cleanups.push(() => {
|
|
224
|
+
window.removeEventListener('resize', update);
|
|
225
|
+
screen.orientation?.removeEventListener('change', update);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
if (enabled.has('contrast')) {
|
|
229
|
+
const m = window.matchMedia.bind(window);
|
|
230
|
+
const run = () => patch({ contrast: resolveContrast(m) });
|
|
231
|
+
const matchers = [
|
|
232
|
+
m('(prefers-contrast: more)'),
|
|
233
|
+
m('(prefers-contrast: less)'),
|
|
234
|
+
m('(prefers-contrast: custom)'),
|
|
235
|
+
];
|
|
236
|
+
run();
|
|
237
|
+
matchers.forEach((matcher) => matcher.addEventListener('change', run));
|
|
238
|
+
cleanups.push(() => matchers.forEach((matcher) => matcher.removeEventListener('change', run)));
|
|
239
|
+
}
|
|
240
|
+
if (enabled.has('reducedTransparency')) {
|
|
241
|
+
try {
|
|
242
|
+
const mq = window.matchMedia('(prefers-reduced-transparency: reduce)');
|
|
243
|
+
const run = () => patch({ reducedTransparency: mq.matches });
|
|
244
|
+
run();
|
|
245
|
+
mq.addEventListener('change', run);
|
|
246
|
+
cleanups.push(() => mq.removeEventListener('change', run));
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
/* unsupported */
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (enabled.has('inverted')) {
|
|
253
|
+
try {
|
|
254
|
+
const mq = window.matchMedia('(inverted-colors: inverted)');
|
|
255
|
+
const run = () => patch({ invertedColors: mq.matches });
|
|
256
|
+
run();
|
|
257
|
+
mq.addEventListener('change', run);
|
|
258
|
+
cleanups.push(() => mq.removeEventListener('change', run));
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
/* unsupported */
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (enabled.has('online')) {
|
|
265
|
+
const update = () => patch({ online: navigator.onLine });
|
|
266
|
+
update();
|
|
267
|
+
window.addEventListener('online', update);
|
|
268
|
+
window.addEventListener('offline', update);
|
|
269
|
+
cleanups.push(() => window.removeEventListener('online', update), () => window.removeEventListener('offline', update));
|
|
270
|
+
}
|
|
271
|
+
if (enabled.has('visibility')) {
|
|
272
|
+
const update = () => patch({ visibility: document.visibilityState });
|
|
273
|
+
update();
|
|
274
|
+
document.addEventListener('visibilitychange', update);
|
|
275
|
+
cleanups.push(() => document.removeEventListener('visibilitychange', update));
|
|
276
|
+
}
|
|
277
|
+
if (enabled.has('fullscreen')) {
|
|
278
|
+
const update = () => patch({ fullscreen: document.fullscreenElement != null });
|
|
279
|
+
update();
|
|
280
|
+
document.addEventListener('fullscreenchange', update);
|
|
281
|
+
cleanups.push(() => document.removeEventListener('fullscreenchange', update));
|
|
282
|
+
}
|
|
283
|
+
if (enabled.has('displayMode')) {
|
|
284
|
+
const mq = window.matchMedia('(display-mode: standalone)');
|
|
285
|
+
const update = () => patch({
|
|
286
|
+
displayStandalone: mq.matches ||
|
|
287
|
+
navigator.standalone ===
|
|
288
|
+
true,
|
|
289
|
+
});
|
|
290
|
+
update();
|
|
291
|
+
mq.addEventListener('change', update);
|
|
292
|
+
cleanups.push(() => mq.removeEventListener('change', update));
|
|
293
|
+
}
|
|
294
|
+
if (enabled.has('locale')) {
|
|
295
|
+
let timeZone = '';
|
|
296
|
+
try {
|
|
297
|
+
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone ?? '';
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
timeZone = '';
|
|
301
|
+
}
|
|
302
|
+
patch({
|
|
303
|
+
locale: navigator.language ?? '',
|
|
304
|
+
timeZone,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if (enabled.has('connection')) {
|
|
308
|
+
const update = () => patch({ connectionSummary: readConnectionSummary() });
|
|
309
|
+
update();
|
|
310
|
+
const nav = navigator;
|
|
311
|
+
const c = nav.connection;
|
|
312
|
+
if (c?.addEventListener) {
|
|
313
|
+
c.addEventListener('change', update);
|
|
314
|
+
cleanups.push(() => c.removeEventListener?.('change', update));
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (enabled.has('saveData')) {
|
|
318
|
+
try {
|
|
319
|
+
const mq = window.matchMedia('(prefers-reduced-data: reduce)');
|
|
320
|
+
const run = () => patch({ saveDataReduced: mq.matches });
|
|
321
|
+
run();
|
|
322
|
+
mq.addEventListener('change', run);
|
|
323
|
+
cleanups.push(() => mq.removeEventListener('change', run));
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
/* unsupported */
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (enabled.has('focus')) {
|
|
330
|
+
const update = () => patch({ focusPeek: focusPeekLabel() });
|
|
331
|
+
update();
|
|
332
|
+
document.addEventListener('focusin', update, true);
|
|
333
|
+
cleanups.push(() => document.removeEventListener('focusin', update, true));
|
|
334
|
+
}
|
|
335
|
+
return () => {
|
|
336
|
+
cleanups.forEach((fn) => fn());
|
|
337
|
+
};
|
|
338
|
+
}, [enabled, featureKey]);
|
|
339
|
+
useEffect(() => {
|
|
340
|
+
if (typeof window === 'undefined')
|
|
341
|
+
return;
|
|
342
|
+
if (!enabled.has('perf'))
|
|
343
|
+
return;
|
|
344
|
+
let rafId = 0;
|
|
345
|
+
let frames = 0;
|
|
346
|
+
let last = performance.now();
|
|
347
|
+
const loop = (now) => {
|
|
348
|
+
frames += 1;
|
|
349
|
+
const elapsed = now - last;
|
|
350
|
+
if (elapsed >= 1000) {
|
|
351
|
+
setState((s) => ({
|
|
352
|
+
...s,
|
|
353
|
+
fps: Math.round((frames * 1000) / elapsed),
|
|
354
|
+
fpsSampled: true,
|
|
355
|
+
}));
|
|
356
|
+
frames = 0;
|
|
357
|
+
last = now;
|
|
358
|
+
}
|
|
359
|
+
rafId = requestAnimationFrame(loop);
|
|
360
|
+
};
|
|
361
|
+
rafId = requestAnimationFrame(loop);
|
|
362
|
+
return () => cancelAnimationFrame(rafId);
|
|
363
|
+
}, [enabled]);
|
|
364
|
+
useEffect(() => {
|
|
365
|
+
if (typeof window === 'undefined')
|
|
366
|
+
return;
|
|
367
|
+
if (!enabled.has('memory'))
|
|
368
|
+
return;
|
|
369
|
+
const perf = performance;
|
|
370
|
+
const tick = () => {
|
|
371
|
+
const m = perf.memory;
|
|
372
|
+
setState((s) => ({
|
|
373
|
+
...s,
|
|
374
|
+
heapUsedMb: m
|
|
375
|
+
? Math.round((m.usedJSHeapSize / 1024 / 1024) * 10) / 10
|
|
376
|
+
: null,
|
|
377
|
+
}));
|
|
378
|
+
};
|
|
379
|
+
tick();
|
|
380
|
+
const id = window.setInterval(tick, 2000);
|
|
381
|
+
return () => window.clearInterval(id);
|
|
382
|
+
}, [enabled]);
|
|
383
|
+
return state;
|
|
384
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA"}
|
package/dist/components/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
interface SeparatorProps extends HTMLAttributes<HTMLHRElement> {
|
|
2
3
|
orientation?: 'horizontal' | 'vertical';
|
|
3
|
-
className?: string;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
* Semantic separator with
|
|
6
|
+
* Semantic separator with self-contained styling.
|
|
7
7
|
* RSC-safe. Use `orientation="vertical"` in flex rows.
|
|
8
8
|
*/
|
|
9
|
-
export declare function Separator({ orientation,
|
|
9
|
+
export declare function Separator({ orientation, style, ...props }: SeparatorProps): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=separator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"separator.d.ts","sourceRoot":"","sources":["../../../src/components/separator/separator.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"separator.d.ts","sourceRoot":"","sources":["../../../src/components/separator/separator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAA;AAE3C,UAAU,cAAe,SAAQ,cAAc,CAAC,aAAa,CAAC;IAC5D,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;CACxC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACxB,WAA0B,EAC1B,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,2CA0BhB"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from '../../utils/cn.js';
|
|
3
2
|
/**
|
|
4
|
-
* Semantic separator with
|
|
3
|
+
* Semantic separator with self-contained styling.
|
|
5
4
|
* RSC-safe. Use `orientation="vertical"` in flex rows.
|
|
6
5
|
*/
|
|
7
|
-
export function Separator({ orientation = 'horizontal',
|
|
8
|
-
return (_jsx("hr", { role: 'separator', "aria-orientation": orientation,
|
|
9
|
-
|
|
10
|
-
:
|
|
6
|
+
export function Separator({ orientation = 'horizontal', style, ...props }) {
|
|
7
|
+
return (_jsx("hr", { role: 'separator', "aria-orientation": orientation, style: {
|
|
8
|
+
border: 0,
|
|
9
|
+
flexShrink: 0,
|
|
10
|
+
...(orientation === 'horizontal'
|
|
11
|
+
? {
|
|
12
|
+
borderTop: '1px solid var(--react-shared-separator-color, rgba(15, 23, 42, 0.12))',
|
|
13
|
+
margin: '0.5rem 0',
|
|
14
|
+
width: '100%',
|
|
15
|
+
}
|
|
16
|
+
: {
|
|
17
|
+
alignSelf: 'stretch',
|
|
18
|
+
borderLeft: '1px solid var(--react-shared-separator-color, rgba(15, 23, 42, 0.12))',
|
|
19
|
+
margin: '0 0.5rem',
|
|
20
|
+
}),
|
|
21
|
+
...style,
|
|
22
|
+
}, ...props }));
|
|
11
23
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type HTMLAttributes } from 'react';
|
|
2
|
-
export declare function Skeleton({
|
|
2
|
+
export declare function Skeleton({ style, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=skeleton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton/skeleton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton/skeleton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAA;AAc3C,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,cAAc,CAAC,2CAgB3E"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
const PULSE_KEYFRAMES = `
|
|
3
|
+
@keyframes react-shared-skeleton-pulse {
|
|
4
|
+
0%,
|
|
5
|
+
100% {
|
|
6
|
+
opacity: 1;
|
|
7
|
+
}
|
|
8
|
+
50% {
|
|
9
|
+
opacity: 0.58;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
export function Skeleton({ style, ...props }) {
|
|
14
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: PULSE_KEYFRAMES }), _jsx("div", { style: {
|
|
15
|
+
animation: 'react-shared-skeleton-pulse 1.6s ease-in-out infinite',
|
|
16
|
+
background: 'var(--react-shared-skeleton-background, rgba(15, 23, 42, 0.08))',
|
|
17
|
+
borderRadius: '0.5rem',
|
|
18
|
+
...style,
|
|
19
|
+
}, ...props })] }));
|
|
5
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-link.d.ts","sourceRoot":"","sources":["../../../src/components/skip-link/skip-link.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAE3D,UAAU,aAAc,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACrE,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,QAAiC,EACjC,GAAG,KAAK,EACT,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"skip-link.d.ts","sourceRoot":"","sources":["../../../src/components/skip-link/skip-link.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAE3D,UAAU,aAAc,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACrE,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,QAAiC,EACjC,GAAG,KAAK,EACT,EAAE,aAAa,2CAgCf"}
|
|
@@ -9,18 +9,21 @@ import { useState } from 'react';
|
|
|
9
9
|
export function SkipLink({ href, children = 'Skip to main content', ...props }) {
|
|
10
10
|
const [focused, setFocused] = useState(false);
|
|
11
11
|
return (_jsx("a", { href: href, onFocus: () => setFocused(true), onBlur: () => setFocused(false), style: {
|
|
12
|
-
position: '
|
|
12
|
+
position: 'fixed',
|
|
13
13
|
top: focused ? '0.5rem' : '-100%',
|
|
14
14
|
left: '0.5rem',
|
|
15
15
|
zIndex: 9999,
|
|
16
16
|
padding: '0.5rem 1rem',
|
|
17
|
-
background: '
|
|
18
|
-
color: '#fff',
|
|
17
|
+
background: 'var(--react-shared-skip-link-background, rgba(15, 23, 42, 0.96))',
|
|
18
|
+
color: 'var(--react-shared-skip-link-foreground, #fff)',
|
|
19
19
|
textDecoration: 'none',
|
|
20
|
-
borderRadius: '
|
|
20
|
+
borderRadius: '9999px',
|
|
21
21
|
fontSize: '0.875rem',
|
|
22
|
-
fontWeight:
|
|
22
|
+
fontWeight: 600,
|
|
23
23
|
transition: 'top 0.1s',
|
|
24
|
+
boxShadow: focused
|
|
25
|
+
? '0 0 0 3px rgba(59, 130, 246, 0.35)'
|
|
26
|
+
: '0 1px 2px rgba(15, 23, 42, 0.16)',
|
|
24
27
|
outline: '2px solid transparent',
|
|
25
28
|
}, ...props, children: children }));
|
|
26
29
|
}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GACd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const DEFAULT_BREAKPOINTS: Record<string, number>;
|
|
2
|
+
export interface BreakpointState {
|
|
3
|
+
breakpoint: string;
|
|
4
|
+
height: number;
|
|
5
|
+
width: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveBreakpoint(width: number, breakpoints: Record<string, number>): string;
|
|
8
|
+
export declare function useBreakpoint(breakpoints?: Record<string, number>): BreakpointState;
|
|
9
|
+
//# sourceMappingURL=use-breakpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-breakpoint.d.ts","sourceRoot":"","sources":["../../src/hooks/use-breakpoint.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMtD,CAAA;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,MAAM,CAQR;AAED,wBAAgB,aAAa,CAC3B,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAuB,GACxD,eAAe,CAmCjB"}
|