rockin 0.0.31 → 0.0.32
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/dist/hooks/index.d.ts +8 -1
- package/dist/hooks/index.js +49 -1
- package/dist/styles.css +4 -0
- package/package.json +1 -1
package/dist/hooks/index.d.ts
CHANGED
|
@@ -57,6 +57,13 @@ declare function useSearchParams(): {
|
|
|
57
57
|
transactionPage: number;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
type SideRail = "left" | "right" | null;
|
|
61
|
+
/**
|
|
62
|
+
* Which screen edge has a wide, empty safe-area strip that can hold a vertical
|
|
63
|
+
* nav rail, such as the sensor column on the iPhone Duo. `null` everywhere else.
|
|
64
|
+
*/
|
|
65
|
+
declare function useSideRail(): SideRail;
|
|
66
|
+
|
|
60
67
|
declare function useDataTablePagination(): {
|
|
61
68
|
pageIndex: number;
|
|
62
69
|
pageSize: number;
|
|
@@ -115,4 +122,4 @@ declare function useGridChanges<TData extends Record<string, unknown>>(grid: Dat
|
|
|
115
122
|
reconcile: (succeededIds: string[], failedIds?: string[]) => void;
|
|
116
123
|
};
|
|
117
124
|
|
|
118
|
-
export { searchFocus, useDataGridClipboard, useDataGridFillHandle, useDataGridMove, useDataTablePagination, useDataTableRows, useDataTableSearch, useFullscreen, useGridChanges, useMediaQuery, useMounted, useNative, useSearchParams };
|
|
125
|
+
export { type SideRail, searchFocus, useDataGridClipboard, useDataGridFillHandle, useDataGridMove, useDataTablePagination, useDataTableRows, useDataTableSearch, useFullscreen, useGridChanges, useMediaQuery, useMounted, useNative, useSearchParams, useSideRail };
|
package/dist/hooks/index.js
CHANGED
|
@@ -260,6 +260,53 @@ function useSearchParams() {
|
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
// src/hooks/useSideRail.ts
|
|
264
|
+
import { useSyncExternalStore } from "react";
|
|
265
|
+
var RAIL_MIN_INSET = 64;
|
|
266
|
+
var RAIL_MAX_OPPOSITE = 16;
|
|
267
|
+
var probe = null;
|
|
268
|
+
function readInsets() {
|
|
269
|
+
if (!probe) {
|
|
270
|
+
probe = document.createElement("div");
|
|
271
|
+
probe.setAttribute("aria-hidden", "true");
|
|
272
|
+
probe.style.cssText = "position:fixed;top:0;left:0;width:0;height:0;visibility:hidden;pointer-events:none;padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)";
|
|
273
|
+
document.body.appendChild(probe);
|
|
274
|
+
}
|
|
275
|
+
const style = getComputedStyle(probe);
|
|
276
|
+
return {
|
|
277
|
+
left: Number.parseFloat(style.paddingLeft) || 0,
|
|
278
|
+
right: Number.parseFloat(style.paddingRight) || 0
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function getSnapshot() {
|
|
282
|
+
const { left, right } = readInsets();
|
|
283
|
+
if (right >= RAIL_MIN_INSET && left <= RAIL_MAX_OPPOSITE) return "right";
|
|
284
|
+
if (left >= RAIL_MIN_INSET && right <= RAIL_MAX_OPPOSITE) return "left";
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
function subscribe(onChange) {
|
|
288
|
+
readInsets();
|
|
289
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(onChange);
|
|
290
|
+
if (probe) observer?.observe(probe, { box: "border-box" });
|
|
291
|
+
let frame = 0;
|
|
292
|
+
const onViewportChange = () => {
|
|
293
|
+
onChange();
|
|
294
|
+
cancelAnimationFrame(frame);
|
|
295
|
+
frame = requestAnimationFrame(onChange);
|
|
296
|
+
};
|
|
297
|
+
window.addEventListener("resize", onViewportChange);
|
|
298
|
+
window.addEventListener("orientationchange", onViewportChange);
|
|
299
|
+
return () => {
|
|
300
|
+
observer?.disconnect();
|
|
301
|
+
cancelAnimationFrame(frame);
|
|
302
|
+
window.removeEventListener("resize", onViewportChange);
|
|
303
|
+
window.removeEventListener("orientationchange", onViewportChange);
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function useSideRail() {
|
|
307
|
+
return useSyncExternalStore(subscribe, getSnapshot, () => null);
|
|
308
|
+
}
|
|
309
|
+
|
|
263
310
|
// src/ui/data-table/hooks/use-data-grid-clipboard.ts
|
|
264
311
|
function useDataGridClipboard() {
|
|
265
312
|
return {
|
|
@@ -382,5 +429,6 @@ export {
|
|
|
382
429
|
useMediaQuery,
|
|
383
430
|
useMounted,
|
|
384
431
|
useNative,
|
|
385
|
-
useSearchParams
|
|
432
|
+
useSearchParams,
|
|
433
|
+
useSideRail
|
|
386
434
|
};
|
package/dist/styles.css
CHANGED
|
@@ -372,6 +372,10 @@ html[data-native-app="true"][data-native-device="mac"] {
|
|
|
372
372
|
font-synthesis-weight: none;
|
|
373
373
|
text-rendering: optimizeLegibility;
|
|
374
374
|
-webkit-tap-highlight-color: transparent;
|
|
375
|
+
/* Keep content clear of side safe areas: landscape notches and the
|
|
376
|
+
* iPhone Duo sensor strip, which iOS reports as a side inset. */
|
|
377
|
+
padding-left: env(safe-area-inset-left, 0px);
|
|
378
|
+
padding-right: env(safe-area-inset-right, 0px);
|
|
375
379
|
@apply bg-background text-foreground;
|
|
376
380
|
}
|
|
377
381
|
[data-slot="layout"] {
|