@sheetxl/utils-react 0.8.0-beta.7 → 1.0.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/LICENSE.md +17 -7
- package/browser/esm/{Bw28AK_GmLacWQL9.mjs → B40op1SaLNqvFHlg.mjs} +2 -2
- package/browser/esm/{i81p_jZjY1WbfES8.mjs → BIiHroifM2tesCns.mjs} +22 -21
- package/browser/esm/DKfTbMgV21FBnNOl.mjs +100 -0
- package/browser/esm/index.mjs +2668 -2134
- package/licenses/dependencies.txt +1 -39
- package/node/esm/DGnB_ajTnvY63CO9.mjs +100 -0
- package/node/esm/{DTFDut0Eizkfjl77.mjs → DmRJGz37SB1KXyjc.mjs} +2 -2
- package/node/esm/index.mjs +2352 -1826
- package/package.json +9 -12
- package/types/src/animation/useAnimatedMeasure.d.ts +2 -3
- package/types/src/command/CommandButtonRegistry.d.ts +3 -1
- package/types/src/command/CommandScope.d.ts +23 -2
- package/types/src/components/RenderSlot.d.ts +32 -0
- package/types/src/components/index.d.ts +1 -1
- package/types/src/float/FloatPanel.d.ts +7 -6
- package/types/src/float/FloatPopper.d.ts +84 -10
- package/types/src/float/FloatPopup.d.ts +1 -1
- package/types/src/float/FloatProvider.d.ts +3 -2
- package/types/src/float/FloatStackContext.d.ts +8 -0
- package/types/src/float/FloatUtils.d.ts +3 -2
- package/types/src/float/_FloatTheme.d.ts +16 -0
- package/types/src/float/_FloatUtils.d.ts +6 -0
- package/types/src/float/index.d.ts +0 -1
- package/types/src/float/useFloatStack.d.ts +6 -5
- package/types/src/hooks/index.d.ts +4 -0
- package/types/src/hooks/useCallbackRef.d.ts +19 -6
- package/types/src/hooks/useEditMode.d.ts +26 -6
- package/types/src/hooks/useInputModality.d.ts +26 -0
- package/types/src/hooks/useLocationSearch.d.ts +9 -0
- package/types/src/hooks/useMeasure.d.ts +32 -0
- package/types/src/hooks/useNotifier.d.ts +35 -34
- package/types/src/hooks/useSynchronizedPointerHandler.d.ts +3 -7
- package/types/src/hooks/useVisualViewportRect.d.ts +40 -0
- package/types/src/icons/packs/Base.json.d.ts +3624 -0
- package/types/src/index.d.ts +2 -0
- package/types/src/lazy/lazyComponent.d.ts +9 -2
- package/types/src/persistence/Types.d.ts +4 -2
- package/types/src/persistence/usePersistentState.d.ts +3 -0
- package/types/src/render/PendingRender.d.ts +43 -0
- package/types/src/render/index.d.ts +2 -0
- package/types/src/scroll/AxisViewport.d.ts +6 -2
- package/types/src/scroll/IScrollPane.d.ts +17 -4
- package/types/src/scroll/IScrollbar.d.ts +5 -2
- package/types/src/scroll/ScrollButton.d.ts +3 -3
- package/types/src/scroll/Utils.d.ts +1 -0
- package/types/src/scroll/Viewport.d.ts +50 -2
- package/types/src/scroll/VirtualScrollbar.d.ts +2 -1
- package/types/src/scroll/scrollbarTheming.d.ts +2 -23
- package/types/src/scroll/touchOwner.d.ts +19 -0
- package/types/src/scroll/useWheelScroll.d.ts +15 -2
- package/types/src/scroll/wheelOwner.d.ts +18 -0
- package/types/src/scroller/Scroller.d.ts +44 -5
- package/types/src/splitPane/SplitPane.d.ts +3 -1
- package/types/src/theme/ThemeStyle.d.ts +22 -0
- package/types/src/theme/TokenTheme.d.ts +10 -1
- package/types/src/theme/buildThemeCSS.d.ts +9 -0
- package/types/src/theme/defaultTheme.d.ts +6 -0
- package/types/src/theme/index.d.ts +3 -1
- package/types/src/theme/themeAttrs.d.ts +5 -4
- package/types/src/theme/tokenVar.d.ts +20 -0
- package/types/src/theme/useResolvedThemeMode.d.ts +27 -5
- package/types/src/theme/zIndex.d.ts +24 -0
- package/types/src/utils/index.d.ts +1 -0
- package/types/src/utils/measureUIText.d.ts +24 -0
- package/types/src/virtualKeyboard/KeyboardAccessory.d.ts +73 -0
- package/types/src/virtualKeyboard/VirtualKeyboard.d.ts +128 -0
- package/types/src/virtualKeyboard/_keyboardApi.d.ts +13 -0
- package/types/src/virtualKeyboard/index.d.ts +4 -0
- package/types/src/virtualKeyboard/useKeyboardResize.d.ts +41 -0
- package/browser/cjs/DZSvmqU8nRas1uz6.cjs +0 -1
- package/browser/cjs/YFvC9nIpxy3b5ZTk.cjs +0 -1
- package/browser/cjs/index.cjs +0 -5
- package/browser/cjs/wW5CllvkH2ZVrahP.cjs +0 -1
- package/browser/esm/B5GygXf0YyM0P3w6.mjs +0 -2231
- package/node/esm/Cwt7wlb1TEVLnVZr.mjs +0 -2231
- package/types/src/components/ITooltip.d.ts +0 -38
- package/types/src/float/FloatTooltip.d.ts +0 -22
- package/types/src/theme/TokenThemeProvider.d.ts +0 -97
- package/types/src/utils/PinchZoom.d.ts +0 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `useLayoutEffect` in the browser, `useEffect` where there is no DOM (so server rendering doesn't warn).
|
|
4
|
+
*/
|
|
5
|
+
export declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
6
|
+
/**
|
|
7
|
+
* The content box of a measured element, in CSS px. Same fields as a ResizeObserver `contentRect`:
|
|
8
|
+
* `x`/`y` (and `left`/`top`) are the padding offsets, not a page position.
|
|
9
|
+
*/
|
|
10
|
+
export type MeasureRect = Pick<DOMRectReadOnly, 'x' | 'y' | 'top' | 'left' | 'right' | 'bottom' | 'height' | 'width'>;
|
|
11
|
+
/**
|
|
12
|
+
* A callback ref; attach it to the element to measure.
|
|
13
|
+
*/
|
|
14
|
+
export type MeasureRef<E extends Element> = (element: E | null) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Tracks the content-box size of an element.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Returns all zeros until the ref is attached; the element is measured as soon as it is attached
|
|
20
|
+
* (before paint) and again whenever a ResizeObserver reports a change. The returned rect keeps its
|
|
21
|
+
* identity while the size is unchanged. Where `ResizeObserver` is unavailable the rect stays zero.
|
|
22
|
+
*
|
|
23
|
+
* Changes from CSS transforms are not observed; see `useAnimatedMeasure`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const [refMeasure, { width }] = useMeasure<HTMLDivElement>();
|
|
28
|
+
* return <div ref={refMeasure}>{width}px wide</div>;
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function useMeasure<E extends Element = Element>(): [MeasureRef<E>, MeasureRect];
|
|
32
|
+
//# sourceMappingURL=useMeasure.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { RenderSlotFn } from '../components';
|
|
3
|
+
import { NotifierOptions, INotifier } from '@sheetxl/utils';
|
|
3
4
|
/**
|
|
4
5
|
* Indicates the type of notification.
|
|
5
6
|
*/
|
|
@@ -53,8 +54,15 @@ export interface InputOption {
|
|
|
53
54
|
* close; use that when the reason only emerges from the attempt (a rejected password).
|
|
54
55
|
*/
|
|
55
56
|
disabled?: boolean | (() => boolean);
|
|
56
|
-
/**
|
|
57
|
-
renderButton?:
|
|
57
|
+
/** Render this option's button. Spread `buttonProps` on it. */
|
|
58
|
+
renderButton?: RenderSlotFn<OptionButtonRenderProps>;
|
|
59
|
+
}
|
|
60
|
+
/** What {@link InputOption.renderButton} is handed. */
|
|
61
|
+
export interface OptionButtonRenderProps {
|
|
62
|
+
/** The dialog's wiring for the button: its click, `type` and class. */
|
|
63
|
+
buttonProps: React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
64
|
+
/** The option is the dialog's default (its submit). */
|
|
65
|
+
isDefaultOption: boolean;
|
|
58
66
|
}
|
|
59
67
|
/** A dialog option: a plain label/identity `string`, or a rich {@link InputOption}. */
|
|
60
68
|
export type OptionInput = string | InputOption;
|
|
@@ -269,52 +277,45 @@ export interface IReactNotifier extends INotifier {
|
|
|
269
277
|
*/
|
|
270
278
|
showInput: (options: ShowInputOptions) => Promise<InputResults>;
|
|
271
279
|
}
|
|
272
|
-
export
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
/** @inheritdoc IReactNotifier.showBusy */
|
|
280
|
-
showBusy(message: string | React.ReactNode, options?: ShowBusyOptions): (Promise<BusyHandle>) | BusyHandle;
|
|
281
|
-
/** @inheritdoc IReactNotifier.showWindow */
|
|
282
|
-
showWindow(type: string, options?: ShowWindowOptions): Promise<HTMLElement>;
|
|
283
|
-
/** @inheritdoc IReactNotifier.showError */
|
|
284
|
-
showError(error: any): void;
|
|
285
|
-
/** @inheritdoc IReactNotifier.showOptions */
|
|
286
|
-
showOptions(options: ShowOptionsOptions): Promise<OptionInput>;
|
|
287
|
-
/** @inheritdoc IReactNotifier.showInput */
|
|
288
|
-
showInput(options: ShowInputOptions): Promise<InputResults>;
|
|
280
|
+
export interface ReactNotifierProviderProps {
|
|
281
|
+
children: React.ReactNode;
|
|
282
|
+
/**
|
|
283
|
+
* The methods this provider implements. The ones it leaves out come from a provider further out,
|
|
284
|
+
* or do what {@link useNotifier} does with no provider.
|
|
285
|
+
*/
|
|
286
|
+
notifier: Partial<IReactNotifier>;
|
|
289
287
|
}
|
|
290
288
|
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
289
|
+
* Shows the messages, dialogs and busy indicators that components below it ask for through
|
|
290
|
+
* {@link useNotifier}.
|
|
291
|
+
*
|
|
292
|
+
* @remarks
|
|
293
|
+
* Providers stack **per method, and the outermost wins**. An app that wraps a studio in a provider
|
|
294
|
+
* with only `showMessage` replaces the studio's toasts and keeps its dialogs.
|
|
295
|
+
*
|
|
296
|
+
* The provider affects React components only. To redirect the SDK's own messages, override the
|
|
297
|
+
* global {@link Notifier}.
|
|
293
298
|
*
|
|
294
299
|
* @example
|
|
295
300
|
* ```tsx
|
|
296
|
-
* const
|
|
301
|
+
* const notifier = {
|
|
297
302
|
* showMessage: (message) => toast(message),
|
|
298
|
-
* showError: (error) => toast.error(error)
|
|
299
|
-
* // ... other methods
|
|
303
|
+
* showError: (error) => toast.error(String(error))
|
|
300
304
|
* };
|
|
301
305
|
*
|
|
302
|
-
* <ReactNotifierProvider notifier={
|
|
306
|
+
* <ReactNotifierProvider notifier={notifier}>
|
|
303
307
|
* <App />
|
|
304
308
|
* </ReactNotifierProvider>
|
|
305
309
|
* ```
|
|
306
310
|
*/
|
|
307
|
-
export interface ReactNotifierProviderProps {
|
|
308
|
-
children: React.ReactNode;
|
|
309
|
-
notifier: IReactNotifier;
|
|
310
|
-
}
|
|
311
311
|
export declare const ReactNotifierProvider: React.FC<ReactNotifierProviderProps>;
|
|
312
312
|
/**
|
|
313
|
-
*
|
|
314
|
-
* NotifierProvider, or falls back to the default ReactNotifier singleton if
|
|
315
|
-
* no provider is found.
|
|
313
|
+
* Returns the notifier for showing the user messages, dialogs and busy indicators.
|
|
316
314
|
*
|
|
317
|
-
* @
|
|
315
|
+
* @remarks
|
|
316
|
+
* Every method is always present. With no {@link ReactNotifierProvider} above, messages, dialogs and
|
|
317
|
+
* busy indicators show nothing (a dialog resolves as if cancelled), and `log`, `warn`, `error` and
|
|
318
|
+
* `showError` go to the global {@link Notifier}.
|
|
318
319
|
*
|
|
319
320
|
* @example
|
|
320
321
|
* ```tsx
|
|
@@ -28,16 +28,12 @@ export interface PointerHandlerOptions<T extends Element = Element> {
|
|
|
28
28
|
timerInitial?: number;
|
|
29
29
|
timerContinuous?: number;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* Track the gesture through pointer events rather than mouse events, so a finger or a pen drives
|
|
32
|
+
* it too. The element pressed declares `touch-action: none` to keep the browser's pan, and the
|
|
33
|
+
* scroll pane's touch scroller, off the gesture.
|
|
33
34
|
* @default false
|
|
34
35
|
*/
|
|
35
36
|
processTouch?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* If true the touch events will be consumed and not propagated.
|
|
38
|
-
* @default true
|
|
39
|
-
*/
|
|
40
|
-
consumeTouch?: boolean;
|
|
41
37
|
}
|
|
42
38
|
/**
|
|
43
39
|
* If returns false don't setup the other listeners
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part of the layout viewport that is actually visible, in CSS px.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* On a phone the visual viewport is what shrinks when the virtual keyboard rises (iOS Safari never
|
|
6
|
+
* resizes the layout viewport for it) and what moves when the page is pinch-zoomed or scrolled
|
|
7
|
+
* under a pinned chrome. `offsetTop` / `offsetLeft` are its position within the layout viewport.
|
|
8
|
+
*/
|
|
9
|
+
export interface VisualViewportRect {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
offsetTop: number;
|
|
13
|
+
offsetLeft: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The current {@link VisualViewportRect}, or `null` where `window.visualViewport` is unavailable.
|
|
17
|
+
* Returns the same object until a value changes.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getVisualViewportRect: () => VisualViewportRect | null;
|
|
20
|
+
/**
|
|
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).
|
|
23
|
+
*
|
|
24
|
+
* @returns Stops listening.
|
|
25
|
+
*/
|
|
26
|
+
export declare const subscribeVisualViewport: (listener: () => void) => (() => void);
|
|
27
|
+
/**
|
|
28
|
+
* The visual viewport's size and offset, re-rendering as it changes. `null` on the server, in a
|
|
29
|
+
* browser without `window.visualViewport`, or while `enabled` is `false`.
|
|
30
|
+
*
|
|
31
|
+
* @param enabled Subscribe only while `true`; a component that needs the rect in one configuration
|
|
32
|
+
* (the studio with its formula bar at the bottom) pays nothing in the others.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* The signal behind a chrome that must stay above the virtual keyboard: the rect's `height` is the
|
|
36
|
+
* room left once the keyboard is up, and `offsetTop` is how far the browser has moved the visible
|
|
37
|
+
* part under a layout that did not shrink.
|
|
38
|
+
*/
|
|
39
|
+
export declare const useVisualViewportRect: (enabled?: boolean) => VisualViewportRect | null;
|
|
40
|
+
//# sourceMappingURL=useVisualViewportRect.d.ts.map
|