@sheetxl/utils-react 0.8.0-beta.2 → 0.8.0-beta.21

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.
Files changed (78) hide show
  1. package/LICENSE.md +17 -7
  2. package/browser/esm/{C0YaChjA6T3amxUK.mjs → B6U1YOdlMBIiMwIo.mjs} +2 -2
  3. package/browser/esm/B8oCr4YRlNEgrVTE.mjs +100 -0
  4. package/browser/esm/{DaDIU3EpB96qbvar.mjs → C74v7_u2uwgwlCTV.mjs} +20 -19
  5. package/browser/esm/index.mjs +2381 -1782
  6. package/licenses/dependencies.txt +1 -39
  7. package/node/esm/{ab6S2ZLIze6opqOt.mjs → BRFcIf1L6jIUdzP7.mjs} +2 -2
  8. package/node/esm/CZoJwu33P3QdiHsu.mjs +100 -0
  9. package/node/esm/index.mjs +2274 -1684
  10. package/package.json +9 -12
  11. package/types/src/animation/useAnimatedMeasure.d.ts +2 -3
  12. package/types/src/command/CommandButtonRegistry.d.ts +3 -1
  13. package/types/src/command/CommandScope.d.ts +23 -2
  14. package/types/src/components/RenderSlot.d.ts +32 -0
  15. package/types/src/components/index.d.ts +1 -1
  16. package/types/src/float/FloatPanel.d.ts +7 -6
  17. package/types/src/float/FloatPopper.d.ts +84 -10
  18. package/types/src/float/FloatPopup.d.ts +1 -1
  19. package/types/src/float/FloatProvider.d.ts +3 -2
  20. package/types/src/float/FloatStackContext.d.ts +8 -0
  21. package/types/src/float/FloatUtils.d.ts +3 -2
  22. package/types/src/float/_FloatTheme.d.ts +17 -0
  23. package/types/src/float/_FloatUtils.d.ts +6 -0
  24. package/types/src/float/index.d.ts +0 -1
  25. package/types/src/float/useFloatStack.d.ts +6 -5
  26. package/types/src/hooks/LanguageState.d.ts +1 -1
  27. package/types/src/hooks/index.d.ts +4 -0
  28. package/types/src/hooks/useCallbackRef.d.ts +19 -6
  29. package/types/src/hooks/useEditMode.d.ts +24 -4
  30. package/types/src/hooks/useInputModality.d.ts +26 -0
  31. package/types/src/hooks/useLocationSearch.d.ts +9 -0
  32. package/types/src/hooks/useMeasure.d.ts +32 -0
  33. package/types/src/hooks/useNotifier.d.ts +35 -34
  34. package/types/src/hooks/useSynchronizedPointerHandler.d.ts +3 -7
  35. package/types/src/hooks/useVisualViewportRect.d.ts +40 -0
  36. package/types/src/icons/packs/Base.json.d.ts +3624 -0
  37. package/types/src/index.d.ts +2 -0
  38. package/types/src/lazy/lazyComponent.d.ts +9 -2
  39. package/types/src/persistence/PersistentStateProvider.d.ts +3 -0
  40. package/types/src/persistence/Types.d.ts +22 -6
  41. package/types/src/persistence/_Context.d.ts +3 -2
  42. package/types/src/persistence/index.d.ts +2 -2
  43. package/types/src/persistence/{usePersistenceState.d.ts → usePersistentState.d.ts} +13 -8
  44. package/types/src/render/PendingRender.d.ts +43 -0
  45. package/types/src/render/index.d.ts +2 -0
  46. package/types/src/scroll/AxisViewport.d.ts +6 -2
  47. package/types/src/scroll/IScrollPane.d.ts +17 -4
  48. package/types/src/scroll/IScrollbar.d.ts +5 -2
  49. package/types/src/scroll/ScrollButton.d.ts +3 -3
  50. package/types/src/scroll/Utils.d.ts +1 -0
  51. package/types/src/scroll/Viewport.d.ts +50 -2
  52. package/types/src/scroll/VirtualScrollbar.d.ts +2 -1
  53. package/types/src/scroll/touchOwner.d.ts +19 -0
  54. package/types/src/scroll/useWheelScroll.d.ts +15 -2
  55. package/types/src/scroll/wheelOwner.d.ts +18 -0
  56. package/types/src/scroller/Scroller.d.ts +44 -5
  57. package/types/src/splitPane/SplitPane.d.ts +3 -1
  58. package/types/src/theme/TokenTheme.d.ts +8 -0
  59. package/types/src/theme/index.d.ts +1 -0
  60. package/types/src/theme/useResolvedThemeMode.d.ts +22 -4
  61. package/types/src/theme/zIndex.d.ts +24 -0
  62. package/types/src/utils/index.d.ts +1 -0
  63. package/types/src/utils/measureUIText.d.ts +24 -0
  64. package/types/src/virtualKeyboard/KeyboardAccessory.d.ts +73 -0
  65. package/types/src/virtualKeyboard/VirtualKeyboard.d.ts +128 -0
  66. package/types/src/virtualKeyboard/_keyboardApi.d.ts +13 -0
  67. package/types/src/virtualKeyboard/index.d.ts +4 -0
  68. package/types/src/virtualKeyboard/useKeyboardResize.d.ts +41 -0
  69. package/browser/cjs/DO0nIGKXa_DxYcn6.cjs +0 -1
  70. package/browser/cjs/DZSvmqU8nRas1uz6.cjs +0 -1
  71. package/browser/cjs/fw5WNnhzqSBOfVql.cjs +0 -1
  72. package/browser/cjs/index.cjs +0 -5
  73. package/browser/esm/DKup4mMzT8WdXz0e.mjs +0 -2217
  74. package/node/esm/ErznqJafEjYJ3e0H.mjs +0 -2217
  75. package/types/src/components/ITooltip.d.ts +0 -38
  76. package/types/src/float/FloatTooltip.d.ts +0 -22
  77. package/types/src/persistence/PersistenceStateProvider.d.ts +0 -3
  78. 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 { DefaultNotifier, NotifierOptions, INotifier } from '@sheetxl/utils';
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
- /** Per-option custom button render (replaces the former dialog-level `createOptionsButton`). */
57
- renderButton?: (props: React.HTMLAttributes<HTMLButtonElement> & React.Attributes, isDefaultOption: boolean) => React.ReactNode;
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 declare class DefaultReactNotifier extends DefaultNotifier implements IReactNotifier {
273
- /** @inheritdoc IReactNotifier.setOverrides */
274
- setOverrides(overrides: Partial<IReactNotifier> | null): void;
275
- /** @inheritdoc IReactNotifier.getDelegate */
276
- getDelegate(): Partial<IReactNotifier> | null;
277
- /** @inheritdoc IReactNotifier.showMessage */
278
- showMessage(message: string | React.ReactNode, options?: EnqueueNotifierOptions): void;
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
- * Context provider for notifications. Allows custom notification implementations
292
- * to be provided to components within the provider tree.
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 customNotifier = {
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={customNotifier}>
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
- * Hook to access the notification system. Uses the notifier from the nearest
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
- * @returns The notification interface
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
- * If this is being used for a touch device then this should be true. This will
32
- * prevent the default touch events from being fired (by calling defaultPrevent during the capture phase).
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