@sheetxl/utils-react 0.7.3 → 0.7.5
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/README.md +9 -5
- package/browser/cjs/index.cjs +2 -2
- package/browser/esm/index.mjs +383 -352
- package/node/esm/index.mjs +771 -740
- package/package.json +15 -2
- package/types/index.d.ts +136 -89
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.7.
|
|
4
|
+
"version": "0.7.5",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -20,14 +20,27 @@
|
|
|
20
20
|
"*.css",
|
|
21
21
|
"**/*.css"
|
|
22
22
|
],
|
|
23
|
+
"homepage": "https://sheetxl.com",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/sheetxl/sheetxl.git"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/sheetxl/sheetxl/issues"
|
|
30
|
+
},
|
|
23
31
|
"keywords": [
|
|
24
32
|
"sheetxl",
|
|
25
33
|
"spreadsheet",
|
|
34
|
+
"javascript",
|
|
35
|
+
"typescript",
|
|
36
|
+
"data grid",
|
|
37
|
+
"excel",
|
|
38
|
+
"xlsx",
|
|
26
39
|
"utilities",
|
|
27
40
|
"react"
|
|
28
41
|
],
|
|
29
42
|
"dependencies": {
|
|
30
|
-
"@sheetxl/utils": "^0.7.
|
|
43
|
+
"@sheetxl/utils": "^0.7.5",
|
|
31
44
|
"clsx": "^2.1.1",
|
|
32
45
|
"detect-it": "^4.0.1",
|
|
33
46
|
"react-merge-refs": "^3.0.2",
|
package/types/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { CellCoords } from '@sheetxl/utils';
|
|
2
2
|
import { default as default_2 } from 'react';
|
|
3
|
+
import { DefaultNotifier } from '@sheetxl/utils';
|
|
3
4
|
import { DependencyList } from 'react';
|
|
4
5
|
import { Dimensions } from '@sheetxl/utils';
|
|
5
6
|
import { Direction } from '@sheetxl/utils';
|
|
6
7
|
import { EditModeHandler } from '@sheetxl/utils';
|
|
8
|
+
import { INotifier } from '@sheetxl/utils';
|
|
7
9
|
import { JSX } from 'react/jsx-runtime';
|
|
10
|
+
import { NotifierOptions } from '@sheetxl/utils';
|
|
11
|
+
import { ReactNode } from 'react';
|
|
8
12
|
import { ReferenceableClipboard } from '@sheetxl/utils';
|
|
9
13
|
import { RemoveListener } from '@sheetxl/utils';
|
|
10
14
|
import { TopLeft } from '@sheetxl/utils';
|
|
@@ -12,8 +16,8 @@ import { UndoManager } from '@sheetxl/utils';
|
|
|
12
16
|
|
|
13
17
|
declare function boundPixel(pixel: number, _increase?: boolean, _absOffset?: number): number;
|
|
14
18
|
|
|
15
|
-
export declare interface
|
|
16
|
-
icon?:
|
|
19
|
+
export declare interface BusyNotifierOptions {
|
|
20
|
+
icon?: default_2.ReactNode;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
export declare type CellFinder = (activeCoords: CellCoords, isContentfulCell: IsContentfulCell | undefined, hiddenAt: HiddenHeadersAt | undefined, direction: Direction, first: boolean, limit: number) => number;
|
|
@@ -190,10 +194,6 @@ export declare interface CopyPasteProps {
|
|
|
190
194
|
* Called after paste has been called.
|
|
191
195
|
*/
|
|
192
196
|
onPaste?: (reference: ReferenceableClipboard.ReferenceItem, args: ReferenceableClipboard.PasteOptions) => void;
|
|
193
|
-
/**
|
|
194
|
-
* A notifier to provide for warnings and errors.
|
|
195
|
-
*/
|
|
196
|
-
notifier?: Notifier;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
export declare interface CopyPasteResults {
|
|
@@ -231,7 +231,26 @@ export declare const defaultCreateScrollEndButton: (props: ScrollButtonProps) =>
|
|
|
231
231
|
*/
|
|
232
232
|
export declare const defaultCreateScrollStartButton: (props: ScrollButtonProps) => default_2.ReactElement;
|
|
233
233
|
|
|
234
|
-
export declare
|
|
234
|
+
export declare class DefaultReactNotifier extends DefaultNotifier implements IReactNotifier {
|
|
235
|
+
/** @inheritdoc IReactNotifier.setOverrides */
|
|
236
|
+
setOverrides(overrides: Partial<IReactNotifier> | null): void;
|
|
237
|
+
/** @inheritdoc IReactNotifier.getDelegate */
|
|
238
|
+
getDelegate(): Partial<IReactNotifier> | null;
|
|
239
|
+
/** @inheritdoc IReactNotifier.showMessage */
|
|
240
|
+
showMessage(message: string | default_2.ReactNode, options?: EnqueueNotifierOptions): void;
|
|
241
|
+
/** @inheritdoc IReactNotifier.showBusy */
|
|
242
|
+
showBusy(message: string | default_2.ReactNode, options?: BusyNotifierOptions): (Promise<() => void>) | (() => void);
|
|
243
|
+
/** @inheritdoc IReactNotifier.showWindow */
|
|
244
|
+
showWindow(type: string, props?: any, options?: {
|
|
245
|
+
disableAutoDestroy?: boolean;
|
|
246
|
+
}): Promise<HTMLElement>;
|
|
247
|
+
/** @inheritdoc IReactNotifier.showError */
|
|
248
|
+
showError(error: any): void;
|
|
249
|
+
/** @inheritdoc IReactNotifier.showOptions */
|
|
250
|
+
showOptions(options: OptionsNotifierOptions): Promise<string>;
|
|
251
|
+
/** @inheritdoc IReactNotifier.showInputOptions */
|
|
252
|
+
showInputOptions(options: InputOptionsNotifierOptions): Promise<InputResults>;
|
|
253
|
+
}
|
|
235
254
|
|
|
236
255
|
/**
|
|
237
256
|
* Re-export detectIt.
|
|
@@ -274,6 +293,20 @@ declare type DynamicValue<T, CONTEXT> = T | ((context?: DynamicContext<CONTEXT>)
|
|
|
274
293
|
|
|
275
294
|
declare const EmptyCssProperties: React.CSSProperties;
|
|
276
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Configuration for non-blocking notifications.
|
|
298
|
+
*/
|
|
299
|
+
export declare interface EnqueueNotifierOptions extends NotifierOptions {
|
|
300
|
+
/**
|
|
301
|
+
* A hint for decorations of the message.
|
|
302
|
+
*/
|
|
303
|
+
type?: NotifierType;
|
|
304
|
+
/**
|
|
305
|
+
* Passed directly to the Snackbar component.
|
|
306
|
+
*/
|
|
307
|
+
enqueueProps?: Record<string, any>;
|
|
308
|
+
}
|
|
309
|
+
|
|
277
310
|
declare const focusableNodeNames: Set<string>;
|
|
278
311
|
|
|
279
312
|
/**
|
|
@@ -607,19 +640,19 @@ export declare interface IKeyStroke {
|
|
|
607
640
|
readonly modifiers?: KeyModifiers[];
|
|
608
641
|
}
|
|
609
642
|
|
|
610
|
-
export declare interface
|
|
643
|
+
export declare interface InputOptionsNotifierOptions extends OptionsNotifierOptions {
|
|
611
644
|
initialValue?: string;
|
|
612
645
|
/**
|
|
613
646
|
* Css style for input
|
|
614
647
|
*/
|
|
615
|
-
inputProps?:
|
|
648
|
+
inputProps?: default_2.HTMLAttributes<HTMLInputElement | HTMLTextAreaElement>;
|
|
616
649
|
inputLabel?: string;
|
|
617
650
|
inputType?: 'text' | 'password' | 'email' | 'number' | 'search' | 'tel' | 'url';
|
|
618
651
|
inputPlaceHolder?: string;
|
|
619
652
|
onInputOption?: (input?: string, option?: string) => void;
|
|
620
653
|
/**
|
|
621
654
|
* Call when an option is selected. If false is returned, the the
|
|
622
|
-
* dialog will not close.
|
|
655
|
+
* dialog will not close. INotifier is not provided but can
|
|
623
656
|
* be supplied via the textFieldProps helperText property.
|
|
624
657
|
* @remarks
|
|
625
658
|
* Optional the textProps can be updated via the textFieldProps argument
|
|
@@ -637,6 +670,50 @@ export declare interface InputValidationResults {
|
|
|
637
670
|
message?: string;
|
|
638
671
|
}
|
|
639
672
|
|
|
673
|
+
/**
|
|
674
|
+
* Interface that provides popups for the user.
|
|
675
|
+
*/
|
|
676
|
+
export declare interface IReactNotifier extends INotifier {
|
|
677
|
+
/**
|
|
678
|
+
* Useful when informing the user of something but are not expecting a response.
|
|
679
|
+
*/
|
|
680
|
+
showMessage: (message: string | default_2.ReactNode, options?: EnqueueNotifierOptions) => void;
|
|
681
|
+
/**
|
|
682
|
+
* Useful when performing a long running operation and you want to inform the user.
|
|
683
|
+
*
|
|
684
|
+
* A return type of a handler will be returned to allow for hideBusy.
|
|
685
|
+
* If multiple calls are made the consumer should continue to indicated blocked
|
|
686
|
+
* until all calls have been hideBusy.
|
|
687
|
+
*/
|
|
688
|
+
showBusy: (message: string | default_2.ReactNode, options?: BusyNotifierOptions) => (Promise<() => void>) | (() => void);
|
|
689
|
+
/**
|
|
690
|
+
* Show a dialog for a given type.
|
|
691
|
+
*
|
|
692
|
+
* @param type
|
|
693
|
+
* @param props
|
|
694
|
+
* @param options
|
|
695
|
+
*/
|
|
696
|
+
showWindow: (type: string, props?: any, options?: {
|
|
697
|
+
disableAutoDestroy?: boolean;
|
|
698
|
+
}) => Promise<HTMLElement>;
|
|
699
|
+
/**
|
|
700
|
+
* Should return error object exception.
|
|
701
|
+
*
|
|
702
|
+
* @param error
|
|
703
|
+
*/
|
|
704
|
+
showError: (error: Error | string) => void;
|
|
705
|
+
/**
|
|
706
|
+
* Provide a user with a list of options to choose from.
|
|
707
|
+
* @param options
|
|
708
|
+
*/
|
|
709
|
+
showOptions: (options: OptionsNotifierOptions) => Promise<string>;
|
|
710
|
+
/**
|
|
711
|
+
* Provider a user with a way to enter a text input.
|
|
712
|
+
* @param options
|
|
713
|
+
*/
|
|
714
|
+
showInputOptions: (options: InputOptionsNotifierOptions) => Promise<InputResults>;
|
|
715
|
+
}
|
|
716
|
+
|
|
640
717
|
export declare interface IsContentfulCell {
|
|
641
718
|
(coords: CellCoords): boolean;
|
|
642
719
|
}
|
|
@@ -736,42 +813,34 @@ export declare const MouseButtonCodes: {
|
|
|
736
813
|
|
|
737
814
|
export declare type MouseButtonCodes = typeof MouseButtonCodes[keyof typeof MouseButtonCodes];
|
|
738
815
|
|
|
816
|
+
export declare const NotifierProvider: default_2.FC<NotifierProviderProps>;
|
|
817
|
+
|
|
739
818
|
/**
|
|
740
|
-
*
|
|
819
|
+
* Context provider for notifications. Allows custom notification implementations
|
|
820
|
+
* to be provided to components within the provider tree.
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* ```tsx
|
|
824
|
+
* const customNotifier = {
|
|
825
|
+
* showMessage: (message) => toast(message),
|
|
826
|
+
* showError: (error) => toast.error(error),
|
|
827
|
+
* // ... other methods
|
|
828
|
+
* };
|
|
829
|
+
*
|
|
830
|
+
* <NotifierProvider notifier={customNotifier}>
|
|
831
|
+
* <App />
|
|
832
|
+
* </NotifierProvider>
|
|
833
|
+
* ```
|
|
741
834
|
*/
|
|
742
|
-
declare interface
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
*/
|
|
746
|
-
type?: NotificationType;
|
|
747
|
-
/**
|
|
748
|
-
* Setting this to true will leave the notification on the screen unless it is dismissed (programmatically or through user interaction).
|
|
749
|
-
* If `false` will be removed after a period of time.
|
|
750
|
-
*
|
|
751
|
-
* @defaultValue false
|
|
752
|
-
*/
|
|
753
|
-
persist?: boolean;
|
|
754
|
-
/**
|
|
755
|
-
* Ignores displaying multiple snackBars with the same `message`.
|
|
756
|
-
*
|
|
757
|
-
* @defaultValue false
|
|
758
|
-
*/
|
|
759
|
-
preventDuplicate?: boolean;
|
|
760
|
-
/**
|
|
761
|
-
* If provided then then notification provider should not notify if the same id is used again.
|
|
762
|
-
*/
|
|
763
|
-
onceKey?: string;
|
|
764
|
-
/**
|
|
765
|
-
* Passed directly to the Snackbar component.
|
|
766
|
-
*/
|
|
767
|
-
enqueueProps?: Record<string, any>;
|
|
835
|
+
export declare interface NotifierProviderProps {
|
|
836
|
+
children: ReactNode;
|
|
837
|
+
notifier: IReactNotifier;
|
|
768
838
|
}
|
|
769
|
-
export { NotificationOptions_2 as NotificationOptions }
|
|
770
839
|
|
|
771
840
|
/**
|
|
772
841
|
* Indicates the type of notification.
|
|
773
842
|
*/
|
|
774
|
-
export declare const
|
|
843
|
+
export declare const NotifierType: {
|
|
775
844
|
readonly Default: "default";
|
|
776
845
|
readonly Error: "error";
|
|
777
846
|
readonly Success: "success";
|
|
@@ -779,57 +848,14 @@ export declare const NotificationType: {
|
|
|
779
848
|
readonly Info: "info";
|
|
780
849
|
};
|
|
781
850
|
|
|
782
|
-
export declare type
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* Interface that provides popups for the user.
|
|
786
|
-
*/
|
|
787
|
-
export declare interface Notifier {
|
|
788
|
-
/**
|
|
789
|
-
* Useful when informing the user of something but are not expecting a response.
|
|
790
|
-
*/
|
|
791
|
-
showMessage?: (message: string | React.ReactNode, options?: NotificationOptions_2) => void;
|
|
792
|
-
/**
|
|
793
|
-
* Useful when performing a long running operation and you want to inform the user.
|
|
794
|
-
*
|
|
795
|
-
* A return type of a handler will be returned to allow for hideBusy.
|
|
796
|
-
* If multiple calls are made the consumer should continue to indicated blocked
|
|
797
|
-
* until all calls have been hideBusy.
|
|
798
|
-
*/
|
|
799
|
-
showBusy?: (message: string | React.ReactNode, options?: BusyNotificationOptions) => (Promise<() => void>) | (() => void);
|
|
800
|
-
/**
|
|
801
|
-
* Show a dialog for a given type.
|
|
802
|
-
* @param type
|
|
803
|
-
* @param props
|
|
804
|
-
* @param options
|
|
805
|
-
*/
|
|
806
|
-
showWindow?: (type: string, props?: any, options?: {
|
|
807
|
-
disableAutoDestroy?: boolean;
|
|
808
|
-
}) => Promise<HTMLElement>;
|
|
809
|
-
/**
|
|
810
|
-
* Should return error object exception.
|
|
811
|
-
*
|
|
812
|
-
* @param error
|
|
813
|
-
*/
|
|
814
|
-
showError?: (error: Error | string) => void;
|
|
815
|
-
/**
|
|
816
|
-
* Provide a user with a list of options to choose from.
|
|
817
|
-
* @param options
|
|
818
|
-
*/
|
|
819
|
-
showOptions?: (options: OptionsNotificationOptions) => Promise<string>;
|
|
820
|
-
/**
|
|
821
|
-
* Provider a user with a way to enter a text input.
|
|
822
|
-
* @param options
|
|
823
|
-
*/
|
|
824
|
-
showInputOptions?: (options: InputOptionsNotificationOptions) => Promise<InputResults>;
|
|
825
|
-
}
|
|
851
|
+
export declare type NotifierType = typeof NotifierType[keyof typeof NotifierType];
|
|
826
852
|
|
|
827
853
|
export declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
828
854
|
|
|
829
855
|
/**
|
|
830
856
|
* Configuration for an options dialog.
|
|
831
857
|
*/
|
|
832
|
-
export declare interface
|
|
858
|
+
export declare interface OptionsNotifierOptions extends default_2.HTMLAttributes<HTMLDivElement> {
|
|
833
859
|
/**
|
|
834
860
|
* The options as a list of strings
|
|
835
861
|
*/
|
|
@@ -848,7 +874,7 @@ export declare interface OptionsNotificationOptions extends React.HTMLAttributes
|
|
|
848
874
|
* @remarks
|
|
849
875
|
* Not yet implemented
|
|
850
876
|
*/
|
|
851
|
-
icon?:
|
|
877
|
+
icon?: default_2.ReactNode;
|
|
852
878
|
/**
|
|
853
879
|
* Allows for the option will be the default selected option and the enter key trigger.
|
|
854
880
|
* @defaultValue The first option
|
|
@@ -872,10 +898,10 @@ export declare interface OptionsNotificationOptions extends React.HTMLAttributes
|
|
|
872
898
|
* @remarks
|
|
873
899
|
* The option is passed as the `children` prop and as the second argument
|
|
874
900
|
*/
|
|
875
|
-
createOptionsButton?: (option: string, props:
|
|
901
|
+
createOptionsButton?: (option: string, props: default_2.HTMLAttributes<HTMLButtonElement> & default_2.Attributes, isDefaultOption: boolean) => default_2.ReactNode;
|
|
876
902
|
/**
|
|
877
903
|
* Call when an option is selected. If false is returned, the the
|
|
878
|
-
* dialog will not close.
|
|
904
|
+
* dialog will not close. INotifier is not provided but can
|
|
879
905
|
* be supplied via the textFieldProps helperText property.
|
|
880
906
|
*/
|
|
881
907
|
onValidateOption?: (option?: string) => boolean | Promise<boolean>;
|
|
@@ -1205,7 +1231,6 @@ export declare interface UndoManagerProps {
|
|
|
1205
1231
|
* way to disable/protect a sheet. Excel clears the undo stack!
|
|
1206
1232
|
*/
|
|
1207
1233
|
disabled?: boolean;
|
|
1208
|
-
notifier?: Notifier;
|
|
1209
1234
|
commands?: ICommands.IGroup;
|
|
1210
1235
|
}
|
|
1211
1236
|
|
|
@@ -1292,6 +1317,28 @@ export declare function useImperativeElement<R extends T, A = any, T = HTMLEleme
|
|
|
1292
1317
|
*/
|
|
1293
1318
|
export declare function useMouseDownAndHoldListener(onPointerDown: (event: default_2.PointerEvent<Element>) => boolean | void, options?: RepeatClickOptions): (event: default_2.PointerEvent<Element>) => void;
|
|
1294
1319
|
|
|
1320
|
+
/**
|
|
1321
|
+
* Hook to access the notification system. Uses the notifier from the nearest
|
|
1322
|
+
* NotifierProvider, or falls back to the default ReactNotifier singleton if
|
|
1323
|
+
* no provider is found.
|
|
1324
|
+
*
|
|
1325
|
+
* @returns The notification interface
|
|
1326
|
+
*
|
|
1327
|
+
* @example
|
|
1328
|
+
* ```tsx
|
|
1329
|
+
* function MyComponent() {
|
|
1330
|
+
* const notifier = useNotifier();
|
|
1331
|
+
*
|
|
1332
|
+
* const handleClick = () => {
|
|
1333
|
+
* notifier.showMessage('Hello World!', { type: NotifierType.Success });
|
|
1334
|
+
* };
|
|
1335
|
+
*
|
|
1336
|
+
* return <button onClick={handleClick}>Show INotifier</button>;
|
|
1337
|
+
* }
|
|
1338
|
+
* ```
|
|
1339
|
+
*/
|
|
1340
|
+
export declare const useNotifier: () => IReactNotifier;
|
|
1341
|
+
|
|
1295
1342
|
export declare function useOnClickOrFocusAway(ref: default_2.RefObject<any>, listenerArg: ClickOrFocusAwayListener, options?: ClickOrFocusAwayOptions): void;
|
|
1296
1343
|
|
|
1297
1344
|
/**
|
|
@@ -1308,7 +1355,7 @@ export declare function useTraceUpdate(props: any, enabled?: boolean): void;
|
|
|
1308
1355
|
/**
|
|
1309
1356
|
* Undo manager hook
|
|
1310
1357
|
*/
|
|
1311
|
-
export declare const useUndoManager: ({ manager, commands: commandsParent, disabled: propDisabled,
|
|
1358
|
+
export declare const useUndoManager: ({ manager, commands: commandsParent, disabled: propDisabled, }: UndoManagerProps) => UndoManagerResults;
|
|
1312
1359
|
|
|
1313
1360
|
/**
|
|
1314
1361
|
* The virtual scrollbar is for very large scroll area.
|