@sheetxl/utils-react 0.8.0-beta.17 → 0.8.0-beta.18

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sheetxl/utils-react",
3
3
  "description": "Utils React - Utilities for React capabilities needed for all SheetXL components.",
4
- "version": "0.8.0-beta.17",
4
+ "version": "0.8.0-beta.18",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "exports": {
@@ -40,7 +40,7 @@
40
40
  ],
41
41
  "dependencies": {
42
42
  "@floating-ui/react-dom": "^2.1.9",
43
- "@sheetxl/utils": "^0.8.0-beta.17",
43
+ "@sheetxl/utils": "^0.8.0-beta.18",
44
44
  "clsx": "^2.1.1",
45
45
  "detect-it": "^4.0.1",
46
46
  "prop-types": "^15.8.1",
@@ -0,0 +1,17 @@
1
+ import { ThemeAttrs } from '../theme';
2
+ import { FloatThemeScope } from './FloatUtils';
3
+ /**
4
+ * The nearest `data-sxl-theme-mode` / `-surface` above an element. Read as an **external store**, not at
5
+ * render: the attrs live on an ANCESTOR's DOM, stamped in the same commit that re-renders the caller, so a
6
+ * render-time read sees the previous theme and nothing re-renders the caller afterwards. The store is
7
+ * re-checked after commit and on any later attribute change.
8
+ */
9
+ export declare const useElementThemeAttrs: (el: Element | null) => ThemeAttrs;
10
+ /**
11
+ * The theme an element portaled out of its themed subtree opens with (THEMING-DESIGN §7): the nearest
12
+ * `FloatProvider`'s theme scope, with the nearest `TokenThemeProvider` folded in — a React-inherited context
13
+ * that crosses the portal even though the cascade can't. Its scope class makes an `isolate`d provider's
14
+ * `@scope`d rules apply on the portal root, and its pinned mode is the fallback mode.
15
+ */
16
+ export declare const useFloatThemeScope: () => FloatThemeScope | undefined;
17
+ //# sourceMappingURL=_FloatTheme.d.ts.map
@@ -18,7 +18,8 @@ export interface VisualViewportRect {
18
18
  */
19
19
  export declare const getVisualViewportRect: () => VisualViewportRect | null;
20
20
  /**
21
- * Listen for the visual viewport resizing or scrolling.
21
+ * Listen for the visual viewport resizing or scrolling, and for the browser reporting a change in a
22
+ * keyboard that overlays the page (which leaves the visual viewport as it is).
22
23
  *
23
24
  * @returns Stops listening.
24
25
  */
@@ -2019,6 +2019,46 @@ declare const _default: {
2019
2019
  }
2020
2020
  ]
2021
2021
  },
2022
+ "SparklineColumn": {
2023
+ "svg": [
2024
+ {
2025
+ "d": "M3 4h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zm.5 1.5v13h17v-13z",
2026
+ "className": "fill"
2027
+ },
2028
+ {
2029
+ "d": "M5 12h2v5H5zm4-4h2v9H9zm4 5h2v4h-2zm4-6h2v10h-2z",
2030
+ "className": "fill primary"
2031
+ }
2032
+ ]
2033
+ },
2034
+ "SparklineLine": {
2035
+ "svg": [
2036
+ {
2037
+ "d": "M3 4h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zm.5 1.5v13h17v-13z",
2038
+ "className": "fill"
2039
+ },
2040
+ {
2041
+ "d": "M5.2 15.6 9.1 9.4l4 3.9 5-5.6 1.2 1-6.1 6.8-3.9-3.8-2.9 4.7z",
2042
+ "className": "fill primary"
2043
+ }
2044
+ ]
2045
+ },
2046
+ "SparklineWinLoss": {
2047
+ "svg": [
2048
+ {
2049
+ "d": "M3 4h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zm.5 1.5v13h17v-13z",
2050
+ "className": "fill"
2051
+ },
2052
+ {
2053
+ "d": "M5 7h2v4.5H5zm8 0h2v4.5h-2z",
2054
+ "className": "fill primary"
2055
+ },
2056
+ {
2057
+ "d": "M9 12.5h2V17H9zm8 0h2V17h-2z",
2058
+ "className": "fill error"
2059
+ }
2060
+ ]
2061
+ },
2022
2062
  "Ungroup": {
2023
2063
  "svg": [
2024
2064
  {
@@ -0,0 +1,73 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * The top edge of the {@link KeyboardAccessory} showing on the keyboard, in client px (the coordinates
4
+ * `getBoundingClientRect` reads), or `null` while none shows. Content under that line is covered: the
5
+ * keyboard and the accessory both sit below it.
6
+ */
7
+ export declare const getKeyboardAccessoryTop: () => number | null;
8
+ /**
9
+ * Listen for {@link getKeyboardAccessoryTop} changing: an accessory settling on the keyboard, moving
10
+ * with it, or going away.
11
+ *
12
+ * @returns Stops listening.
13
+ */
14
+ export declare const subscribeKeyboardAccessoryTop: (listener: () => void) => (() => void);
15
+ /**
16
+ * Props for {@link KeyboardAccessory}.
17
+ */
18
+ export interface KeyboardAccessoryProps {
19
+ /**
20
+ * Whether the content rides the top of the virtual keyboard. While `false` it stays mounted but
21
+ * hidden, so a field inside keeps its focus and its keyboard across the change.
22
+ */
23
+ floating: boolean;
24
+ /**
25
+ * The element the accessory stands in for, in the page: its theme mode and surface are carried onto
26
+ * the accessory when no float provider supplies a theme.
27
+ */
28
+ anchor?: Element | null;
29
+ /**
30
+ * Called as the accessory shows and hides, after it has settled: an in-page twin fades the other
31
+ * way, so the content looks to have moved.
32
+ */
33
+ onShownChange?: (shown: boolean) => void;
34
+ /**
35
+ * Called when the keyboard goes away while floating (the Android back gesture, the keyboard's own
36
+ * hide key, Safari's Done), so the owner can end what the keyboard was for.
37
+ */
38
+ onKeyboardClose?: () => void;
39
+ className?: string;
40
+ style?: React.CSSProperties;
41
+ children?: React.ReactNode;
42
+ }
43
+ /**
44
+ * Content that rides the top of the virtual keyboard: a bar of a page-level portal, placed from the
45
+ * visual viewport (the part of the page the keyboard leaves visible).
46
+ *
47
+ * @remarks
48
+ * CSS cannot pin anything to the visual viewport (`position: fixed` pins to the layout viewport, which
49
+ * the keyboard does not shrink on iOS, nor on Chrome by default), and script placement runs a frame
50
+ * behind the browser's own scroll, zoom and address-bar animation. So:
51
+ *
52
+ * - **Hidden while anything moves.** A visual viewport resize or scroll, or a page scroll, hides it at
53
+ * once; once nothing has moved for a moment it is placed on the keyboard and fades in.
54
+ * - **Parked at the top of the visible area while hidden.** A focused field the browser sees under the
55
+ * keyboard's edge makes it pan the page to reveal it, and mid-pan the visual viewport's readings do
56
+ * not match the screen. Parked at the top, the field is always in view.
57
+ * - **Undoes pinch zoom**, so it stays the size of the screen.
58
+ * - **Placed by the browser where it can.** Where the browser offers the VirtualKeyboard API (Chromium,
59
+ * in a secure context), the keyboard overlays the page while the accessory floats, and the accessory
60
+ * sits on `env(keyboard-inset-height)`. The visual viewport is wrong in one state there: Chrome
61
+ * bringing its address bar back as the keyboard rises on a scrolled page reports the visible area as
62
+ * if the bar were still hidden, which would put the accessory behind the keyboard. Elsewhere (iOS
63
+ * Safari, Firefox) it is placed from the visual viewport.
64
+ *
65
+ * Its top edge is published through {@link getKeyboardAccessoryTop} while it shows. It never scrolls
66
+ * the page.
67
+ *
68
+ * Inside an iframe the visual viewport is the iframe's, so the accessory rides the iframe's bottom.
69
+ * A floating or split keyboard, or a hardware one, does not shrink the visual viewport: the accessory
70
+ * sits at the bottom of the visible area, and no keyboard close is reported.
71
+ */
72
+ export declare const KeyboardAccessory: React.ForwardRefExoticComponent<KeyboardAccessoryProps & React.RefAttributes<HTMLDivElement>>;
73
+ //# sourceMappingURL=KeyboardAccessory.d.ts.map
@@ -89,9 +89,15 @@ export interface VirtualKeyboardStore extends VirtualKeyboardHandler {
89
89
  }
90
90
  /**
91
91
  * Whether a virtual keyboard is up, read from the visual viewport (the part of the page the keyboard
92
- * leaves visible). Pinch zoom shrinks the visual viewport too, so its scale is undone first.
92
+ * leaves visible). Pinch zoom shrinks the visual viewport too, so its scale is undone first. While a
93
+ * keyboard overlays the page (the browser's VirtualKeyboard API with `overlaysContent`, as a
94
+ * `KeyboardAccessory` sets it), the browser's own report of the keyboard is read instead.
95
+ *
96
+ * @param baseline The layout height to measure against, in px. Defaults to `window.innerHeight`; pass
97
+ * the height read before the keyboard rose where the page may shrink with it (a host whose viewport
98
+ * asks for `interactive-widget=resizes-content`).
93
99
  */
94
- export declare const isVirtualKeyboardUp: () => boolean;
100
+ export declare const isVirtualKeyboardUp: (baseline?: number) => boolean;
95
101
  /**
96
102
  * Create an isolated virtual keyboard store.
97
103
  */
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The browser's VirtualKeyboard API (`navigator.virtualKeyboard`): Chromium only, and only in a secure
3
+ * context (HTTPS, or localhost). With `overlaysContent` on, the keyboard covers the page instead of
4
+ * shrinking the visual viewport, and the browser reports its rectangle (and the CSS
5
+ * `env(keyboard-inset-*)` values) itself.
6
+ */
7
+ export interface VirtualKeyboardApi extends EventTarget {
8
+ overlaysContent: boolean;
9
+ readonly boundingRect: DOMRectReadOnly;
10
+ }
11
+ /** The browser's VirtualKeyboard API, or `null` where it is unavailable. */
12
+ export declare const getVirtualKeyboardApi: () => VirtualKeyboardApi | null;
13
+ //# sourceMappingURL=_keyboardApi.d.ts.map
@@ -1,2 +1,4 @@
1
1
  export * from './VirtualKeyboard';
2
+ export * from './KeyboardAccessory';
3
+ export * from './useKeyboardResize';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * How a host makes room for the virtual keyboard.
3
+ *
4
+ * - `'float'`: the host stays as it is and never scrolls the page; what is being typed into rides
5
+ * the top of the keyboard in a {@link KeyboardAccessory}. For a host that is part of a page.
6
+ * - `'resize'`: the host shrinks to the part of the screen the keyboard leaves
7
+ * ({@link useKeyboardResize}), so everything in it stays in view above the keyboard. For a host that
8
+ * is the page; in a page that scrolls it would fight the page.
9
+ * - `'none'`: nothing; the host or the browser manages the keyboard.
10
+ */
11
+ export type VirtualKeyboardMode = 'float' | 'resize' | 'none';
12
+ /** The room a host that is the page gives up to the virtual keyboard. See {@link useKeyboardResize}. */
13
+ export interface KeyboardResize {
14
+ /** The height the host gives up to the keyboard, in px; `0` while the keyboard is down. */
15
+ inset: number;
16
+ /** How far the host moves down to stay in the visible part of the page, in px. */
17
+ offsetTop: number;
18
+ }
19
+ /**
20
+ * The room a host that is the page makes for the virtual keyboard (the `'resize'`
21
+ * {@link VirtualKeyboardMode}): it shrinks to the part of the screen the keyboard leaves. Apply the
22
+ * result to the host's own box, e.g. `height: calc(100% - ${inset}px)` and
23
+ * `transform: translateY(${offsetTop}px)`.
24
+ *
25
+ * @param enabled Measure only while `true`; a host in another mode pays nothing.
26
+ *
27
+ * @remarks
28
+ * iOS Safari keeps the layout viewport at full height and scrolls the page instead; the visual
29
+ * viewport is the one signal that reflects the keyboard on every platform. While the keyboard is up
30
+ * the host gives up its height (layout minus visual), rides the visual viewport's offset so it stays
31
+ * put while Safari scrolls the layout under it, and the page is scrolled back to the top as the
32
+ * keyboard changes and once as it goes. Only the keyboard counts: the address bar showing or hiding
33
+ * and a pinch zoom leave the host alone.
34
+ *
35
+ * Meant for a host that fills a page that does not scroll. There, Chrome's address bar never hides,
36
+ * so the visual viewport's readings stay right; on a page that scrolls, use the `'float'` mode.
37
+ *
38
+ * Re-renders with the visual viewport while enabled.
39
+ */
40
+ export declare const useKeyboardResize: (enabled: boolean) => KeyboardResize;
41
+ //# sourceMappingURL=useKeyboardResize.d.ts.map