@ttt-productions/mobile-core 0.2.12 → 0.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/dist/react/components/IOSSetup.d.ts +7 -0
- package/dist/react/components/IOSSetup.d.ts.map +1 -0
- package/dist/react/components/IOSSetup.js +11 -0
- package/dist/react/components/IOSSetup.js.map +1 -0
- package/dist/react/components/ViewportHeightSetter.d.ts +13 -0
- package/dist/react/components/ViewportHeightSetter.d.ts.map +1 -0
- package/dist/react/components/ViewportHeightSetter.js +19 -0
- package/dist/react/components/ViewportHeightSetter.js.map +1 -0
- package/dist/react/css-prefix.d.ts +12 -0
- package/dist/react/css-prefix.d.ts.map +1 -0
- package/dist/react/css-prefix.js +11 -0
- package/dist/react/css-prefix.js.map +1 -0
- package/dist/react/index.d.ts +18 -13
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +16 -13
- package/dist/react/index.js.map +1 -1
- package/dist/react/ios/useIosSafariFixes.d.ts +4 -1
- package/dist/react/ios/useIosSafariFixes.d.ts.map +1 -1
- package/dist/react/ios/useIosSafariFixes.js +8 -4
- package/dist/react/ios/useIosSafariFixes.js.map +1 -1
- package/dist/react/keyboard/focusOrder.d.ts +1 -1
- package/dist/react/keyboard/focusOrder.d.ts.map +1 -1
- package/dist/react/keyboard/focusOrder.js +4 -2
- package/dist/react/keyboard/focusOrder.js.map +1 -1
- package/dist/react/keyboard/useKeepFocusedInputVisible.d.ts +2 -1
- package/dist/react/keyboard/useKeepFocusedInputVisible.d.ts.map +1 -1
- package/dist/react/keyboard/useKeepFocusedInputVisible.js +4 -2
- package/dist/react/keyboard/useKeepFocusedInputVisible.js.map +1 -1
- package/dist/react/pull-to-refresh/PullToRefreshContainer.d.ts +2 -1
- package/dist/react/pull-to-refresh/PullToRefreshContainer.d.ts.map +1 -1
- package/dist/react/pull-to-refresh/PullToRefreshContainer.js +7 -5
- package/dist/react/pull-to-refresh/PullToRefreshContainer.js.map +1 -1
- package/dist/react/safe-area/useSafeAreaInsets.d.ts +3 -1
- package/dist/react/safe-area/useSafeAreaInsets.d.ts.map +1 -1
- package/dist/react/safe-area/useSafeAreaInsets.js +13 -10
- package/dist/react/safe-area/useSafeAreaInsets.js.map +1 -1
- package/dist/react/viewport/useViewportHeightVars.d.ts +7 -4
- package/dist/react/viewport/useViewportHeightVars.d.ts.map +1 -1
- package/dist/react/viewport/useViewportHeightVars.js +11 -7
- package/dist/react/viewport/useViewportHeightVars.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CssPrefixOptions } from "../css-prefix.js";
|
|
2
|
+
/**
|
|
3
|
+
* Applies iOS-specific Safari fixes on mount. Renders nothing.
|
|
4
|
+
* Pass `cssPrefix` to override the default `app-` class prefix.
|
|
5
|
+
*/
|
|
6
|
+
export declare function IOSSetup(props?: CssPrefixOptions): null;
|
|
7
|
+
//# sourceMappingURL=IOSSetup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IOSSetup.d.ts","sourceRoot":"","sources":["../../../src/react/components/IOSSetup.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,GAAE,gBAAqB,QAGpD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useIosSafariFixes } from "../ios/useIosSafariFixes.js";
|
|
3
|
+
/**
|
|
4
|
+
* Applies iOS-specific Safari fixes on mount. Renders nothing.
|
|
5
|
+
* Pass `cssPrefix` to override the default `app-` class prefix.
|
|
6
|
+
*/
|
|
7
|
+
export function IOSSetup(props = {}) {
|
|
8
|
+
useIosSafariFixes(props);
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=IOSSetup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IOSSetup.js","sourceRoot":"","sources":["../../../src/react/components/IOSSetup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA0B,EAAE;IACnD,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CssPrefixOptions } from "../css-prefix.js";
|
|
2
|
+
export interface ViewportHeightSetterProps extends CssPrefixOptions {
|
|
3
|
+
/**
|
|
4
|
+
* When true (default), also enables global keyboard-aware input scrolling on mobile.
|
|
5
|
+
*/
|
|
6
|
+
enableKeyboardAvoidance?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Sets the `--<prefix>-vh` and `--<prefix>-dvh` CSS custom properties.
|
|
10
|
+
* Defaults to `--app-vh` / `--app-dvh`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ViewportHeightSetter({ cssPrefix, enableKeyboardAvoidance, }?: ViewportHeightSetterProps): import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
//# sourceMappingURL=ViewportHeightSetter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewportHeightSetter.d.ts","sourceRoot":"","sources":["../../../src/react/components/ViewportHeightSetter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IACjE;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAOD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,uBAA8B,GAC/B,GAAE,yBAA8B,kDAIhC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useViewportHeightVars } from "../viewport/useViewportHeightVars.js";
|
|
4
|
+
import { useKeepFocusedInputVisible } from "../keyboard/useKeepFocusedInputVisible.js";
|
|
5
|
+
function KeyboardAvoidance({ cssPrefix }) {
|
|
6
|
+
useKeepFocusedInputVisible({ cssPrefix });
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Sets the `--<prefix>-vh` and `--<prefix>-dvh` CSS custom properties.
|
|
11
|
+
* Defaults to `--app-vh` / `--app-dvh`.
|
|
12
|
+
*/
|
|
13
|
+
export function ViewportHeightSetter({ cssPrefix, enableKeyboardAvoidance = true, } = {}) {
|
|
14
|
+
useViewportHeightVars({ cssPrefix });
|
|
15
|
+
if (enableKeyboardAvoidance)
|
|
16
|
+
return _jsx(KeyboardAvoidance, { cssPrefix: cssPrefix });
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ViewportHeightSetter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewportHeightSetter.js","sourceRoot":"","sources":["../../../src/react/components/ViewportHeightSetter.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAUvF,SAAS,iBAAiB,CAAC,EAAE,SAAS,EAAoB;IACxD,0BAA0B,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,EACnC,SAAS,EACT,uBAAuB,GAAG,IAAI,MACD,EAAE;IAC/B,qBAAqB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IACrC,IAAI,uBAAuB;QAAE,OAAO,KAAC,iBAAiB,IAAC,SAAS,EAAE,SAAS,GAAI,CAAC;IAChF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default neutral CSS prefix for mobile-core. Consumers may override.
|
|
3
|
+
* The prefix is used for CSS variables (e.g. `--<prefix>-vh`) and
|
|
4
|
+
* class/attribute names (e.g. `<prefix>-ios-safari`, `data-<prefix>-input`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_MOBILE_CORE_PREFIX = "app";
|
|
7
|
+
export interface CssPrefixOptions {
|
|
8
|
+
/** Override the default CSS prefix. Defaults to "app". */
|
|
9
|
+
cssPrefix?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function resolvePrefix(opts?: CssPrefixOptions): string;
|
|
12
|
+
//# sourceMappingURL=css-prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-prefix.d.ts","sourceRoot":"","sources":["../../src/react/css-prefix.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,QAAQ,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAE7D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/**
|
|
3
|
+
* Default neutral CSS prefix for mobile-core. Consumers may override.
|
|
4
|
+
* The prefix is used for CSS variables (e.g. `--<prefix>-vh`) and
|
|
5
|
+
* class/attribute names (e.g. `<prefix>-ios-safari`, `data-<prefix>-input`).
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_MOBILE_CORE_PREFIX = "app";
|
|
8
|
+
export function resolvePrefix(opts) {
|
|
9
|
+
return opts?.cssPrefix ?? DEFAULT_MOBILE_CORE_PREFIX;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=css-prefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-prefix.js","sourceRoot":"","sources":["../../src/react/css-prefix.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAOhD,MAAM,UAAU,aAAa,CAAC,IAAuB;IACnD,OAAO,IAAI,EAAE,SAAS,IAAI,0BAA0B,CAAC;AACvD,CAAC"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
1
|
+
export { useVisualViewport } from "./viewport/useVisualViewport.js";
|
|
2
|
+
export { useViewportHeightVars } from "./viewport/useViewportHeightVars.js";
|
|
3
|
+
export { useKeyboard } from "./keyboard/useKeyboard.js";
|
|
4
|
+
export { useKeepFocusedInputVisible } from "./keyboard/useKeepFocusedInputVisible.js";
|
|
5
|
+
export { useInputNavigation } from "./keyboard/useInputNavigation.js";
|
|
6
|
+
export { KeyboardAvoidingView } from "./keyboard/KeyboardAvoidingView.js";
|
|
7
|
+
export { useSafeAreaInsets } from "./safe-area/useSafeAreaInsets.js";
|
|
8
|
+
export { SafeArea } from "./safe-area/SafeArea.js";
|
|
9
|
+
export { useScrollLock } from "./scroll/useScrollLock.js";
|
|
10
|
+
export { useIosSafariFixes } from "./ios/useIosSafariFixes.js";
|
|
11
|
+
export { useNoRubberBand } from "./ios/useNoRubberBand.js";
|
|
12
|
+
export { usePullToRefresh } from "./pull-to-refresh/usePullToRefresh.js";
|
|
13
|
+
export { PullToRefreshContainer } from "./pull-to-refresh/PullToRefreshContainer.js";
|
|
14
|
+
export { IOSSetup } from "./components/IOSSetup.js";
|
|
15
|
+
export { ViewportHeightSetter } from "./components/ViewportHeightSetter.js";
|
|
16
|
+
export type { ViewportHeightSetterProps } from "./components/ViewportHeightSetter.js";
|
|
17
|
+
export { DEFAULT_MOBILE_CORE_PREFIX, resolvePrefix, } from "./css-prefix.js";
|
|
18
|
+
export type { CssPrefixOptions } from "./css-prefix.js";
|
|
14
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,YAAY,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EACL,0BAA0B,EAC1B,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
2
|
+
export { useVisualViewport } from "./viewport/useVisualViewport.js";
|
|
3
|
+
export { useViewportHeightVars } from "./viewport/useViewportHeightVars.js";
|
|
4
|
+
export { useKeyboard } from "./keyboard/useKeyboard.js";
|
|
5
|
+
export { useKeepFocusedInputVisible } from "./keyboard/useKeepFocusedInputVisible.js";
|
|
6
|
+
export { useInputNavigation } from "./keyboard/useInputNavigation.js";
|
|
7
|
+
export { KeyboardAvoidingView } from "./keyboard/KeyboardAvoidingView.js";
|
|
8
|
+
export { useSafeAreaInsets } from "./safe-area/useSafeAreaInsets.js";
|
|
9
|
+
export { SafeArea } from "./safe-area/SafeArea.js";
|
|
10
|
+
export { useScrollLock } from "./scroll/useScrollLock.js";
|
|
11
|
+
export { useIosSafariFixes } from "./ios/useIosSafariFixes.js";
|
|
12
|
+
export { useNoRubberBand } from "./ios/useNoRubberBand.js";
|
|
13
|
+
export { usePullToRefresh } from "./pull-to-refresh/usePullToRefresh.js";
|
|
14
|
+
export { PullToRefreshContainer } from "./pull-to-refresh/PullToRefreshContainer.js";
|
|
15
|
+
export { IOSSetup } from "./components/IOSSetup.js";
|
|
16
|
+
export { ViewportHeightSetter } from "./components/ViewportHeightSetter.js";
|
|
17
|
+
export { DEFAULT_MOBILE_CORE_PREFIX, resolvePrefix, } from "./css-prefix.js";
|
|
15
18
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,EACL,0BAA0B,EAC1B,aAAa,GACd,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { type CssPrefixOptions } from "../css-prefix.js";
|
|
1
2
|
/**
|
|
2
3
|
* Small, safe iOS Safari fixes:
|
|
3
4
|
* - disables double-tap-to-zoom delays for buttons (via touch-action)
|
|
4
5
|
* - ensures inputs don't auto-zoom by recommending 16px font (cannot enforce here)
|
|
5
6
|
* - adds -webkit-overflow-scrolling: touch helper class hook (optional)
|
|
7
|
+
*
|
|
8
|
+
* Default class: `app-ios-safari`. Override via `cssPrefix`.
|
|
6
9
|
*/
|
|
7
|
-
export declare function useIosSafariFixes(): void;
|
|
10
|
+
export declare function useIosSafariFixes(options?: CssPrefixOptions): void;
|
|
8
11
|
//# sourceMappingURL=useIosSafariFixes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIosSafariFixes.d.ts","sourceRoot":"","sources":["../../../src/react/ios/useIosSafariFixes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIosSafariFixes.d.ts","sourceRoot":"","sources":["../../../src/react/ios/useIosSafariFixes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,gBAAgB,QAQ3D"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
import { isBrowser, isIOS, isSafari } from "../../env.js";
|
|
3
|
+
import { resolvePrefix } from "../css-prefix.js";
|
|
3
4
|
/**
|
|
4
5
|
* Small, safe iOS Safari fixes:
|
|
5
6
|
* - disables double-tap-to-zoom delays for buttons (via touch-action)
|
|
6
7
|
* - ensures inputs don't auto-zoom by recommending 16px font (cannot enforce here)
|
|
7
8
|
* - adds -webkit-overflow-scrolling: touch helper class hook (optional)
|
|
9
|
+
*
|
|
10
|
+
* Default class: `app-ios-safari`. Override via `cssPrefix`.
|
|
8
11
|
*/
|
|
9
|
-
export function useIosSafariFixes() {
|
|
12
|
+
export function useIosSafariFixes(options) {
|
|
13
|
+
const prefix = resolvePrefix(options);
|
|
10
14
|
useEffect(() => {
|
|
11
15
|
if (!isBrowser || !isIOS || !isSafari)
|
|
12
16
|
return;
|
|
13
|
-
document.documentElement.classList.add(
|
|
14
|
-
return () => document.documentElement.classList.remove(
|
|
15
|
-
}, []);
|
|
17
|
+
document.documentElement.classList.add(`${prefix}-ios-safari`);
|
|
18
|
+
return () => document.documentElement.classList.remove(`${prefix}-ios-safari`);
|
|
19
|
+
}, [prefix]);
|
|
16
20
|
}
|
|
17
21
|
//# sourceMappingURL=useIosSafariFixes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIosSafariFixes.js","sourceRoot":"","sources":["../../../src/react/ios/useIosSafariFixes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"useIosSafariFixes.js","sourceRoot":"","sources":["../../../src/react/ios/useIosSafariFixes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAyB,MAAM,kBAAkB,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA0B;IAC1D,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACtC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC,QAAQ;YAAE,OAAO;QAE9C,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,aAAa,CAAC,CAAC;QAC/D,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,aAAa,CAAC,CAAC;IACjF,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getFocusableInputs(root?: HTMLElement | Document): HTMLElement[];
|
|
1
|
+
export declare function getFocusableInputs(root?: HTMLElement | Document, prefix?: string): HTMLElement[];
|
|
2
2
|
//# sourceMappingURL=focusOrder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusOrder.d.ts","sourceRoot":"","sources":["../../../src/react/keyboard/focusOrder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"focusOrder.d.ts","sourceRoot":"","sources":["../../../src/react/keyboard/focusOrder.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,WAAW,GAAG,QAAmB,EAAE,MAAM,CAAC,EAAE,MAAM,iBAoB1F"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { DEFAULT_MOBILE_CORE_PREFIX } from "../css-prefix.js";
|
|
2
|
+
export function getFocusableInputs(root = document, prefix) {
|
|
3
|
+
const p = prefix ?? DEFAULT_MOBILE_CORE_PREFIX;
|
|
2
4
|
const el = root instanceof Document ? root : root;
|
|
3
|
-
const list = Array.from(el.querySelectorAll(
|
|
5
|
+
const list = Array.from(el.querySelectorAll(`input, textarea, select, [contenteditable="true"], [data-${p}-input]`)).filter((n) => !n.hasAttribute("disabled") && n.tabIndex !== -1);
|
|
4
6
|
// DOM order is usually correct; allow explicit override
|
|
5
7
|
list.sort((a, b) => {
|
|
6
8
|
const ao = Number(a.getAttribute("data-input-order") ?? "0");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusOrder.js","sourceRoot":"","sources":["../../../src/react/keyboard/focusOrder.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,OAA+B,QAAQ;
|
|
1
|
+
{"version":3,"file":"focusOrder.js","sourceRoot":"","sources":["../../../src/react/keyboard/focusOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,UAAU,kBAAkB,CAAC,OAA+B,QAAQ,EAAE,MAAe;IACzF,MAAM,CAAC,GAAG,MAAM,IAAI,0BAA0B,CAAC;IAC/C,MAAM,EAAE,GAAG,IAAI,YAAY,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CACrB,EAAE,CAAC,gBAAgB,CACjB,4DAA4D,CAAC,SAAS,CACvE,CACF,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC;IAElE,wDAAwD;IACxD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACjB,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7D,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7D,IAAI,EAAE,IAAI,EAAE;YAAE,OAAO,EAAE,GAAG,EAAE,CAAC;QAC7B,IAAI,EAAE;YAAE,OAAO,CAAC,CAAC,CAAC;QAClB,IAAI,EAAE;YAAE,OAAO,CAAC,CAAC;QACjB,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { type CssPrefixOptions } from "../css-prefix.js";
|
|
1
2
|
/**
|
|
2
3
|
* When keyboard opens, ensure focused element is visible within visual viewport.
|
|
3
4
|
* - iOS Safari often hides the caret behind the keyboard.
|
|
4
5
|
*/
|
|
5
|
-
export declare function useKeepFocusedInputVisible(opts?: {
|
|
6
|
+
export declare function useKeepFocusedInputVisible(opts?: CssPrefixOptions & {
|
|
6
7
|
extraOffset?: number;
|
|
7
8
|
scrollBehavior?: ScrollBehavior;
|
|
8
9
|
}): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeepFocusedInputVisible.d.ts","sourceRoot":"","sources":["../../../src/react/keyboard/useKeepFocusedInputVisible.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useKeepFocusedInputVisible.d.ts","sourceRoot":"","sources":["../../../src/react/keyboard/useKeepFocusedInputVisible.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,QA8BA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
import { isBrowser } from "../../env.js";
|
|
3
3
|
import { useKeyboard } from "./useKeyboard.js";
|
|
4
|
+
import { resolvePrefix } from "../css-prefix.js";
|
|
4
5
|
/**
|
|
5
6
|
* When keyboard opens, ensure focused element is visible within visual viewport.
|
|
6
7
|
* - iOS Safari often hides the caret behind the keyboard.
|
|
@@ -9,6 +10,7 @@ export function useKeepFocusedInputVisible(opts) {
|
|
|
9
10
|
const { isOpen } = useKeyboard();
|
|
10
11
|
const extraOffset = opts?.extraOffset ?? 12;
|
|
11
12
|
const behavior = opts?.scrollBehavior ?? "smooth";
|
|
13
|
+
const prefix = resolvePrefix(opts);
|
|
12
14
|
useEffect(() => {
|
|
13
15
|
if (!isBrowser)
|
|
14
16
|
return;
|
|
@@ -19,7 +21,7 @@ export function useKeepFocusedInputVisible(opts) {
|
|
|
19
21
|
return;
|
|
20
22
|
// only inputs-ish
|
|
21
23
|
const tag = el.tagName.toLowerCase();
|
|
22
|
-
const isInput = tag === "input" || tag === "textarea" || tag === "select" || el.isContentEditable || el.hasAttribute(
|
|
24
|
+
const isInput = tag === "input" || tag === "textarea" || tag === "select" || el.isContentEditable || el.hasAttribute(`data-${prefix}-input`);
|
|
23
25
|
if (!isInput)
|
|
24
26
|
return;
|
|
25
27
|
const vv = window.visualViewport;
|
|
@@ -31,6 +33,6 @@ export function useKeepFocusedInputVisible(opts) {
|
|
|
31
33
|
const delta = bottom - limit;
|
|
32
34
|
window.scrollBy({ top: delta, behavior });
|
|
33
35
|
}
|
|
34
|
-
}, [isOpen, extraOffset, behavior]);
|
|
36
|
+
}, [isOpen, extraOffset, behavior, prefix]);
|
|
35
37
|
}
|
|
36
38
|
//# sourceMappingURL=useKeepFocusedInputVisible.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeepFocusedInputVisible.js","sourceRoot":"","sources":["../../../src/react/keyboard/useKeepFocusedInputVisible.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useKeepFocusedInputVisible.js","sourceRoot":"","sources":["../../../src/react/keyboard/useKeepFocusedInputVisible.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAyB,MAAM,kBAAkB,CAAC;AAExE;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAG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EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -4,6 +4,7 @@ type Props = {
|
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
className?: string;
|
|
6
6
|
children: React.ReactNode;
|
|
7
|
+
cssPrefix?: string;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* Drop-in wrapper that adds pull-to-refresh to its children.
|
|
@@ -16,6 +17,6 @@ type Props = {
|
|
|
16
17
|
* </PullToRefreshContainer>
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
|
-
export declare function PullToRefreshContainer({ onRefresh, disabled, className, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function PullToRefreshContainer({ onRefresh, disabled, className, children, cssPrefix }: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
export {};
|
|
21
22
|
//# sourceMappingURL=PullToRefreshContainer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PullToRefreshContainer.d.ts","sourceRoot":"","sources":["../../../src/react/pull-to-refresh/PullToRefreshContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PullToRefreshContainer.d.ts","sourceRoot":"","sources":["../../../src/react/pull-to-refresh/PullToRefreshContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AA6CF;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,KAAK,2CAgDpG"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { usePullToRefresh } from "./usePullToRefresh.js";
|
|
3
|
+
import { resolvePrefix } from "../css-prefix.js";
|
|
3
4
|
const INDICATOR_SIZE = 32;
|
|
4
|
-
function SpinnerIndicator({ progress, isRefreshing }) {
|
|
5
|
+
function SpinnerIndicator({ progress, isRefreshing, prefix }) {
|
|
5
6
|
const radius = 10;
|
|
6
7
|
const circumference = 2 * Math.PI * radius;
|
|
7
8
|
const dashOffset = circumference * (1 - progress);
|
|
8
9
|
return (_jsxs("svg", { width: INDICATOR_SIZE, height: INDICATOR_SIZE, viewBox: "0 0 24 24", style: {
|
|
9
10
|
display: "block",
|
|
10
|
-
animation: isRefreshing ?
|
|
11
|
+
animation: isRefreshing ? `${prefix}-ptr-spin 0.8s linear infinite` : "none",
|
|
11
12
|
}, children: [_jsx("circle", { cx: "12", cy: "12", r: radius, fill: "none", stroke: "currentColor", strokeWidth: "2", opacity: 0.15 }), _jsx("circle", { cx: "12", cy: "12", r: radius, fill: "none", stroke: "currentColor", strokeWidth: "2", strokeDasharray: circumference, strokeDashoffset: isRefreshing ? circumference * 0.25 : dashOffset, strokeLinecap: "round", style: { transition: isRefreshing ? "none" : "stroke-dashoffset 0.1s ease-out" }, transform: "rotate(-90 12 12)" })] }));
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
@@ -21,14 +22,15 @@ function SpinnerIndicator({ progress, isRefreshing }) {
|
|
|
21
22
|
* </PullToRefreshContainer>
|
|
22
23
|
* ```
|
|
23
24
|
*/
|
|
24
|
-
export function PullToRefreshContainer({ onRefresh, disabled, className, children }) {
|
|
25
|
+
export function PullToRefreshContainer({ onRefresh, disabled, className, children, cssPrefix }) {
|
|
26
|
+
const prefix = resolvePrefix({ cssPrefix });
|
|
25
27
|
const { isRefreshing, pullProgress, pullDistance, handlers, style } = usePullToRefresh({
|
|
26
28
|
onRefresh,
|
|
27
29
|
disabled,
|
|
28
30
|
});
|
|
29
31
|
const showIndicator = pullDistance > 0 || isRefreshing;
|
|
30
32
|
const indicatorOpacity = isRefreshing ? 1 : Math.min(1, pullProgress * 1.5);
|
|
31
|
-
return (_jsxs(_Fragment, { children: [_jsx("style", { children: `@keyframes
|
|
33
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { children: `@keyframes ${prefix}-ptr-spin { to { transform: rotate(360deg); } }` }), _jsxs("div", { className: className, ...handlers, style: { position: "relative", overscrollBehaviorY: "contain" }, children: [_jsx("div", { "aria-hidden": true, style: {
|
|
32
34
|
position: "absolute",
|
|
33
35
|
top: 0,
|
|
34
36
|
left: 0,
|
|
@@ -41,6 +43,6 @@ export function PullToRefreshContainer({ onRefresh, disabled, className, childre
|
|
|
41
43
|
pointerEvents: "none",
|
|
42
44
|
zIndex: 10,
|
|
43
45
|
color: "var(--foreground, currentColor)",
|
|
44
|
-
}, children: _jsx(SpinnerIndicator, { progress: pullProgress, isRefreshing: isRefreshing }) }), _jsx("div", { style: style, children: children })] })] }));
|
|
46
|
+
}, children: _jsx(SpinnerIndicator, { progress: pullProgress, isRefreshing: isRefreshing, prefix: prefix }) }), _jsx("div", { style: style, children: children })] })] }));
|
|
45
47
|
}
|
|
46
48
|
//# sourceMappingURL=PullToRefreshContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PullToRefreshContainer.js","sourceRoot":"","sources":["../../../src/react/pull-to-refresh/PullToRefreshContainer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"PullToRefreshContainer.js","sourceRoot":"","sources":["../../../src/react/pull-to-refresh/PullToRefreshContainer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;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AAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAI,GACpF,EAGN,cAAK,KAAK,EAAE,KAAK,YACd,QAAQ,GACL,IACF,IACL,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Insets } from "../../types.js";
|
|
2
|
+
import { type CssPrefixOptions } from "../css-prefix.js";
|
|
2
3
|
/**
|
|
3
4
|
* Uses CSS env(safe-area-inset-*) by writing them to CSS vars and reading computed values.
|
|
4
5
|
* Works on iOS Safari; harmless elsewhere.
|
|
6
|
+
* Default CSS vars: --app-sai-top/right/bottom/left.
|
|
5
7
|
*/
|
|
6
|
-
export declare function useSafeAreaInsets(): Insets;
|
|
8
|
+
export declare function useSafeAreaInsets(options?: CssPrefixOptions): Insets;
|
|
7
9
|
//# sourceMappingURL=useSafeAreaInsets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSafeAreaInsets.d.ts","sourceRoot":"","sources":["../../../src/react/safe-area/useSafeAreaInsets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"useSafeAreaInsets.d.ts","sourceRoot":"","sources":["../../../src/react/safe-area/useSafeAreaInsets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAoCpE"}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import { isBrowser } from "../../env.js";
|
|
3
|
+
import { resolvePrefix } from "../css-prefix.js";
|
|
3
4
|
/**
|
|
4
5
|
* Uses CSS env(safe-area-inset-*) by writing them to CSS vars and reading computed values.
|
|
5
6
|
* Works on iOS Safari; harmless elsewhere.
|
|
7
|
+
* Default CSS vars: --app-sai-top/right/bottom/left.
|
|
6
8
|
*/
|
|
7
|
-
export function useSafeAreaInsets() {
|
|
9
|
+
export function useSafeAreaInsets(options) {
|
|
10
|
+
const prefix = resolvePrefix(options);
|
|
8
11
|
const [insets, setInsets] = useState({ top: 0, right: 0, bottom: 0, left: 0 });
|
|
9
12
|
useEffect(() => {
|
|
10
13
|
if (!isBrowser)
|
|
11
14
|
return;
|
|
12
15
|
const el = document.documentElement;
|
|
13
16
|
// set vars once
|
|
14
|
-
el.style.setProperty(
|
|
15
|
-
el.style.setProperty(
|
|
16
|
-
el.style.setProperty(
|
|
17
|
-
el.style.setProperty(
|
|
17
|
+
el.style.setProperty(`--${prefix}-sai-top`, "env(safe-area-inset-top)");
|
|
18
|
+
el.style.setProperty(`--${prefix}-sai-right`, "env(safe-area-inset-right)");
|
|
19
|
+
el.style.setProperty(`--${prefix}-sai-bottom`, "env(safe-area-inset-bottom)");
|
|
20
|
+
el.style.setProperty(`--${prefix}-sai-left`, "env(safe-area-inset-left)");
|
|
18
21
|
const read = () => {
|
|
19
22
|
const cs = getComputedStyle(el);
|
|
20
23
|
const px = (v) => Math.max(0, Math.round(parseFloat(v || "0")));
|
|
21
24
|
setInsets({
|
|
22
|
-
top: px(cs.getPropertyValue(
|
|
23
|
-
right: px(cs.getPropertyValue(
|
|
24
|
-
bottom: px(cs.getPropertyValue(
|
|
25
|
-
left: px(cs.getPropertyValue(
|
|
25
|
+
top: px(cs.getPropertyValue(`--${prefix}-sai-top`)),
|
|
26
|
+
right: px(cs.getPropertyValue(`--${prefix}-sai-right`)),
|
|
27
|
+
bottom: px(cs.getPropertyValue(`--${prefix}-sai-bottom`)),
|
|
28
|
+
left: px(cs.getPropertyValue(`--${prefix}-sai-left`)),
|
|
26
29
|
});
|
|
27
30
|
};
|
|
28
31
|
read();
|
|
@@ -32,7 +35,7 @@ export function useSafeAreaInsets() {
|
|
|
32
35
|
window.removeEventListener("resize", read);
|
|
33
36
|
window.removeEventListener("orientationchange", read);
|
|
34
37
|
};
|
|
35
|
-
}, []);
|
|
38
|
+
}, [prefix]);
|
|
36
39
|
return insets;
|
|
37
40
|
}
|
|
38
41
|
//# sourceMappingURL=useSafeAreaInsets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSafeAreaInsets.js","sourceRoot":"","sources":["../../../src/react/safe-area/useSafeAreaInsets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"useSafeAreaInsets.js","sourceRoot":"","sources":["../../../src/react/safe-area/useSafeAreaInsets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAyB,MAAM,kBAAkB,CAAC;AAExE;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA0B;IAC1D,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAS,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;IAEvF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAEpC,gBAAgB;QAChB,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,MAAM,UAAU,EAAE,0BAA0B,CAAC,CAAC;QACxE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC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mBAAmB,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { type CssPrefixOptions } from "../css-prefix.js";
|
|
1
2
|
/**
|
|
2
3
|
* Sets:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* --<prefix>-vh: 1% of *layout* viewport height (window.innerHeight)
|
|
5
|
+
* --<prefix>-dvh: 1% of *visual* viewport height (visualViewport.height when available)
|
|
6
|
+
*
|
|
7
|
+
* Default prefix is "app": --app-vh / --app-dvh.
|
|
5
8
|
*
|
|
6
9
|
* Use in CSS:
|
|
7
|
-
* height: calc(var(--
|
|
10
|
+
* height: calc(var(--app-dvh, var(--app-vh, 1vh)) * 100);
|
|
8
11
|
*/
|
|
9
|
-
export declare function useViewportHeightVars(): void;
|
|
12
|
+
export declare function useViewportHeightVars(options?: CssPrefixOptions): void;
|
|
10
13
|
//# sourceMappingURL=useViewportHeightVars.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewportHeightVars.d.ts","sourceRoot":"","sources":["../../../src/react/viewport/useViewportHeightVars.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useViewportHeightVars.d.ts","sourceRoot":"","sources":["../../../src/react/viewport/useViewportHeightVars.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,gBAAgB,QAqB/D"}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
import { isBrowser } from "../../env.js";
|
|
3
|
+
import { resolvePrefix } from "../css-prefix.js";
|
|
3
4
|
/**
|
|
4
5
|
* Sets:
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* --<prefix>-vh: 1% of *layout* viewport height (window.innerHeight)
|
|
7
|
+
* --<prefix>-dvh: 1% of *visual* viewport height (visualViewport.height when available)
|
|
8
|
+
*
|
|
9
|
+
* Default prefix is "app": --app-vh / --app-dvh.
|
|
7
10
|
*
|
|
8
11
|
* Use in CSS:
|
|
9
|
-
* height: calc(var(--
|
|
12
|
+
* height: calc(var(--app-dvh, var(--app-vh, 1vh)) * 100);
|
|
10
13
|
*/
|
|
11
|
-
export function useViewportHeightVars() {
|
|
14
|
+
export function useViewportHeightVars(options) {
|
|
15
|
+
const prefix = resolvePrefix(options);
|
|
12
16
|
useEffect(() => {
|
|
13
17
|
if (!isBrowser)
|
|
14
18
|
return;
|
|
15
19
|
const apply = () => {
|
|
16
20
|
const vh = window.innerHeight * 0.01;
|
|
17
|
-
document.documentElement.style.setProperty(
|
|
21
|
+
document.documentElement.style.setProperty(`--${prefix}-vh`, `${vh}px`);
|
|
18
22
|
const dvh = (window.visualViewport?.height ?? window.innerHeight) * 0.01;
|
|
19
|
-
document.documentElement.style.setProperty(
|
|
23
|
+
document.documentElement.style.setProperty(`--${prefix}-dvh`, `${dvh}px`);
|
|
20
24
|
};
|
|
21
25
|
apply();
|
|
22
26
|
window.addEventListener("resize", apply, { passive: true });
|
|
@@ -25,6 +29,6 @@ export function useViewportHeightVars() {
|
|
|
25
29
|
window.removeEventListener("resize", apply);
|
|
26
30
|
window.visualViewport?.removeEventListener("resize", apply);
|
|
27
31
|
};
|
|
28
|
-
}, []);
|
|
32
|
+
}, [prefix]);
|
|
29
33
|
}
|
|
30
34
|
//# sourceMappingURL=useViewportHeightVars.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewportHeightVars.js","sourceRoot":"","sources":["../../../src/react/viewport/useViewportHeightVars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE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