@sheetxl/utils-react 0.8.0-beta.10 → 0.8.0-beta.11

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.
@@ -14,6 +14,7 @@ export * from './persistence';
14
14
  export * from './scroll';
15
15
  export * from './theme';
16
16
  export * from './utils';
17
+ export * from './virtualKeyboard';
17
18
  export { Resizable, ResizableBox } from './react-resizable';
18
19
  export type { ResizeCallbackData, ResizeHandleAxis } from './react-resizable';
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -3,7 +3,7 @@ export interface ScrollerCallback {
3
3
  }
4
4
  /**
5
5
  * Wheel-to-zoom gain: `level *= exp(-deltaY * K)`. Tuned so one mouse notch (`deltaY` = 100 in
6
- * Chrome on Windows) is ≈ 15 % — the step `ISheetView.zoomIn` takes — and a touchpad pinch's
6
+ * Chrome on Windows) is ≈ 15 % — the step `IWorksheetView.zoomIn` takes — and a touchpad pinch's
7
7
  * fractional deltas ramp smoothly.
8
8
  */
9
9
  export declare const WHEEL_ZOOM_K: number;
@@ -2,4 +2,5 @@ export * as ReactUtils from './ReactUtils';
2
2
  export * from './useFullScreen';
3
3
  export * from './FullScreenPortal';
4
4
  export * from './textSelectionDrag';
5
+ export * from './measureUIText';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The font a piece of UI text is set in, as CSS has it.
3
+ */
4
+ export interface UIFont {
5
+ /** Font size in px. */
6
+ size: number;
7
+ /** The CSS font-family list, as the theme names it. */
8
+ family: string;
9
+ /** CSS font-weight; `normal` when unset. */
10
+ weight?: string | number;
11
+ /** CSS font-style; `normal` when unset. */
12
+ style?: 'normal' | 'italic' | 'oblique';
13
+ }
14
+ /**
15
+ * The width in px the browser paints `text` at in a UI font: for sizing a control to a sample
16
+ * label (a toolbar button to its widest value). Nothing to do with cells: spreadsheet text is
17
+ * measured by the sdk's font collection, with Excel's numbers.
18
+ *
19
+ * @remarks
20
+ * A cached canvas measures with the browser's own advances. Where there is no canvas (jsdom, a
21
+ * server) the width is estimated from the character count, which is enough to size a control.
22
+ */
23
+ export declare function measureUIText(text: string, font: UIFont): number;
24
+ //# sourceMappingURL=measureUIText.d.ts.map
@@ -0,0 +1,122 @@
1
+ import { default as React } from 'react';
2
+ /** The virtual keyboard a text field asks for (its `inputmode`). */
3
+ export type VirtualKeyboardInputMode = 'text' | 'decimal' | 'numeric' | 'tel' | 'email' | 'url' | 'search';
4
+ /**
5
+ * Configuration for a {@link VirtualKeyboardStore}.
6
+ */
7
+ export interface VirtualKeyboardOptions {
8
+ /**
9
+ * Never enter keyboard mode: the grid takes focus itself, and the keyboard comes and goes with
10
+ * each text field as the browser decides. `false` turns keyboard mode on where the device was not
11
+ * detected to have one.
12
+ *
13
+ * @defaultValue `true` on a device with no touch input (no virtual keyboard), else `false`
14
+ */
15
+ disabled?: boolean;
16
+ /** Leave the grid scrolled where it is when the keyboard rises over the active cell. */
17
+ disableScrollIntoView?: boolean;
18
+ /**
19
+ * A tap on the grid keeps keyboard mode, as Excel keeps its keyboard, rather than putting the
20
+ * keyboard away.
21
+ */
22
+ keepOnTap?: boolean;
23
+ }
24
+ /**
25
+ * The keyboard-mode state.
26
+ */
27
+ export interface VirtualKeyboardState {
28
+ /**
29
+ * Whether the sheet is in keyboard mode: a virtual keyboard is up for typing into the sheet, and
30
+ * focusing the sheet lands on its typing input so the keyboard stays.
31
+ */
32
+ readonly active: boolean;
33
+ /** The keyboard every sheet text field asks for. */
34
+ readonly inputMode: VirtualKeyboardInputMode;
35
+ }
36
+ /**
37
+ * The imperative handle {@link useVirtualKeyboard} returns.
38
+ */
39
+ export interface VirtualKeyboardHandler {
40
+ /** The current state. A new object on each change. */
41
+ getState(): VirtualKeyboardState;
42
+ /**
43
+ * Whether keyboard mode is available: the device has a virtual keyboard, and the store is not
44
+ * {@link VirtualKeyboardOptions.disabled}. The counterpart of `document.fullscreenEnabled`; a host
45
+ * leaves keyboard-mode parts (the sheet's keyboard layer) out when it is `false`.
46
+ */
47
+ isEnabled(): boolean;
48
+ /** Shorthand for `getState().active`. */
49
+ isActive(): boolean;
50
+ /** Shorthand for `getState().inputMode`. */
51
+ getInputMode(): VirtualKeyboardInputMode;
52
+ /** Ask for a different keyboard on the sheet's text fields. */
53
+ setInputMode(inputMode: VirtualKeyboardInputMode): void;
54
+ /**
55
+ * Enter keyboard mode. A sheet whose focus is not already in a text field focuses its typing
56
+ * input, which raises the keyboard; browsers raise one only inside a user gesture, so call this
57
+ * from a tap.
58
+ *
59
+ * @returns Whether keyboard mode is on: `false` when it is not {@link isEnabled | enabled}, as
60
+ * `requestFullscreen` refuses where fullscreen is not.
61
+ */
62
+ show(): boolean;
63
+ /**
64
+ * Leave keyboard mode, and go back to the letters keyboard: a field opened later (a double-click
65
+ * into a cell) asks for letters, so the next keyboard does too. A sheet whose typing input has focus
66
+ * hands it to the grid, which lowers the keyboard; an editor that has focus keeps it.
67
+ */
68
+ hide(): void;
69
+ /**
70
+ * Name the editor that typing opens in while in keyboard mode, by the id it parks on the edit
71
+ * session (`EditSession.setActiveEditorId`); a phone's formula bar names itself so a typed key
72
+ * opens the edit there rather than in the cell. The latest registration wins.
73
+ *
74
+ * @returns Removes this registration.
75
+ */
76
+ registerEditor(editorId: string): () => void;
77
+ /** The editor typing opens in while in keyboard mode, or `null` for the cell. */
78
+ getEditorId(): string | null;
79
+ /** The options the store was created with. */
80
+ getOptions(): Readonly<VirtualKeyboardOptions>;
81
+ }
82
+ /**
83
+ * A virtual keyboard **bus instance**: one keyboard mode shared by the sheet, its editors, and any
84
+ * control that shows or hides the keyboard.
85
+ */
86
+ export interface VirtualKeyboardStore extends VirtualKeyboardHandler {
87
+ /** Subscribe to any state change. Returns the remover. */
88
+ subscribe(listener: () => void): () => void;
89
+ }
90
+ /**
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.
93
+ */
94
+ export declare const isVirtualKeyboardUp: () => boolean;
95
+ /**
96
+ * Create an isolated virtual keyboard store.
97
+ */
98
+ export declare const createVirtualKeyboardStore: (options?: VirtualKeyboardOptions) => VirtualKeyboardStore;
99
+ export interface VirtualKeyboardProviderProps extends VirtualKeyboardOptions {
100
+ /** The bus instance to share. Omit to create one for this subtree from the options. */
101
+ store?: VirtualKeyboardStore;
102
+ children?: React.ReactNode;
103
+ }
104
+ /**
105
+ * Share one virtual keyboard bus with a subtree: the sheet, its editors, and any keyboard control an
106
+ * app adds (a "show keyboard" button calls `useVirtualKeyboard().show()`). With no `store` a fresh one
107
+ * is created from the options, stable while they are unchanged.
108
+ */
109
+ export declare const VirtualKeyboardProvider: (props: VirtualKeyboardProviderProps) => React.ReactElement;
110
+ /**
111
+ * Resolve the enclosing bus **instance**: the nearest {@link VirtualKeyboardProvider}'s store, else
112
+ * the app-wide default, enabled on a device with touch input. Never `null`: where there is no
113
+ * virtual keyboard the store reports `isEnabled() === false` and `show()` refuses, as the
114
+ * fullscreen API does where fullscreen is unavailable. Non-reactive; use {@link useVirtualKeyboard}
115
+ * to also re-render.
116
+ */
117
+ export declare const useVirtualKeyboardStore: () => VirtualKeyboardStore;
118
+ /**
119
+ * Access the enclosing virtual keyboard bus. Reading re-renders on change.
120
+ */
121
+ export declare const useVirtualKeyboard: () => VirtualKeyboardHandler;
122
+ //# sourceMappingURL=VirtualKeyboard.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './VirtualKeyboard';
2
+ //# sourceMappingURL=index.d.ts.map