@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.
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.10",
4
+ "version": "0.8.0-beta.11",
5
5
  "license": "SEE LICENSE IN <LICENSE>",
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.10",
43
+ "@sheetxl/utils": "^0.8.0-beta.11",
44
44
  "clsx": "^2.1.1",
45
45
  "detect-it": "^4.0.1",
46
46
  "prop-types": "^15.8.1",
@@ -1,4 +1,4 @@
1
- import { EditModeHandler, SetEditMode } from '@sheetxl/utils';
1
+ import { EditMode, EditModeHandler, SetEditMode } from '@sheetxl/utils';
2
2
  /**
3
3
  * Publish (or clear) the active {@link EditMode} on the app-wide bus **without a hook** — the same
4
4
  * write {@link useEditMode}'s `setMode` performs (fires the superseded mode's
@@ -11,6 +11,25 @@ import { EditModeHandler, SetEditMode } from '@sheetxl/utils';
11
11
  * to be mounted (a `SingletonHooksContainer` in the tree), exactly like the hook.
12
12
  */
13
13
  export declare const setEditMode: SetEditMode;
14
+ /** A way out of a mode: {@link EditMode.done} or {@link EditMode.cancel}. */
15
+ export type EditModeExit = 'done' | 'cancel';
16
+ /**
17
+ * Take a way out of a mode from chrome (the status bar's ✓ / ✕): tells the
18
+ * {@link subscribeEditModeExit} listeners, then runs the mode's own `done` or `cancel`.
19
+ *
20
+ * @remarks
21
+ * A way out is the user finishing the interaction, which is more than the mode ending: an edit also
22
+ * ends when Enter moves on to the next cell. A feature that follows the user rather than the mode (the
23
+ * virtual keyboard going down) listens here, so the chrome needs no knowledge of it.
24
+ */
25
+ export declare const exitEditMode: (mode: EditMode, exit: EditModeExit) => void;
26
+ /**
27
+ * Listen for a way out of a mode taken from chrome (see {@link exitEditMode}). Called before the
28
+ * mode's own `done` or `cancel` runs.
29
+ *
30
+ * @returns Stops listening.
31
+ */
32
+ export declare const subscribeEditModeExit: (listener: (mode: EditMode, exit: EditModeExit) => void) => (() => void);
14
33
  /**
15
34
  * Access the application's **edit-mode bus** — the single, app-wide signal describing the
16
35
  * interaction currently in effect.
@@ -37,8 +56,7 @@ export declare const setEditMode: SetEditMode;
37
56
  *
38
57
  * Typical **consumers** (read the active mode):
39
58
  * - the status bar, which shows {@link EditMode.description} (and its idle label when there is none),
40
- * with a ✕ that runs {@link EditMode.cancel} and a ✓ that runs {@link EditMode.done} when the
41
- * mode carries them;
59
+ * with a ✕ and a ✓ that take the mode's ways out ({@link exitEditMode}) when the mode carries them;
42
60
  * - the grid, which applies {@link EditMode.cursor};
43
61
  * - features that must defer to another interaction — e.g. fill is suppressed while a cell is being
44
62
  * edited — by inspecting the active {@link EditMode.key}.
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { DefaultNotifier, NotifierOptions, INotifier } from '@sheetxl/utils';
2
+ import { NotifierOptions, INotifier } from '@sheetxl/utils';
3
3
  /**
4
4
  * Indicates the type of notification.
5
5
  */
@@ -269,52 +269,45 @@ export interface IReactNotifier extends INotifier {
269
269
  */
270
270
  showInput: (options: ShowInputOptions) => Promise<InputResults>;
271
271
  }
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>;
272
+ export interface ReactNotifierProviderProps {
273
+ children: React.ReactNode;
274
+ /**
275
+ * The methods this provider implements. The ones it leaves out come from a provider further out,
276
+ * or do what {@link useNotifier} does with no provider.
277
+ */
278
+ notifier: Partial<IReactNotifier>;
289
279
  }
290
280
  /**
291
- * Context provider for notifications. Allows custom notification implementations
292
- * to be provided to components within the provider tree.
281
+ * Shows the messages, dialogs and busy indicators that components below it ask for through
282
+ * {@link useNotifier}.
283
+ *
284
+ * @remarks
285
+ * Providers stack **per method, and the outermost wins**. An app that wraps a studio in a provider
286
+ * with only `showMessage` replaces the studio's toasts and keeps its dialogs.
287
+ *
288
+ * The provider affects React components only. To redirect the SDK's own messages, override the
289
+ * global {@link Notifier}.
293
290
  *
294
291
  * @example
295
292
  * ```tsx
296
- * const customNotifier = {
293
+ * const notifier = {
297
294
  * showMessage: (message) => toast(message),
298
- * showError: (error) => toast.error(error),
299
- * // ... other methods
295
+ * showError: (error) => toast.error(String(error))
300
296
  * };
301
297
  *
302
- * <ReactNotifierProvider notifier={customNotifier}>
298
+ * <ReactNotifierProvider notifier={notifier}>
303
299
  * <App />
304
300
  * </ReactNotifierProvider>
305
301
  * ```
306
302
  */
307
- export interface ReactNotifierProviderProps {
308
- children: React.ReactNode;
309
- notifier: IReactNotifier;
310
- }
311
303
  export declare const ReactNotifierProvider: React.FC<ReactNotifierProviderProps>;
312
304
  /**
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.
305
+ * Returns the notifier for showing the user messages, dialogs and busy indicators.
316
306
  *
317
- * @returns The notification interface
307
+ * @remarks
308
+ * Every method is always present. With no {@link ReactNotifierProvider} above, messages, dialogs and
309
+ * busy indicators show nothing (a dialog resolves as if cancelled), and `log`, `warn`, `error` and
310
+ * `showError` go to the global {@link Notifier}.
318
311
  *
319
312
  * @example
320
313
  * ```tsx