@gusarov-studio/rubik-ui 3.10.0 → 3.11.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.
@@ -0,0 +1,9 @@
1
+ import type React from "react";
2
+ import type { ModalProps } from "./types";
3
+ interface ModalDefProps {
4
+ modalId: string;
5
+ component: React.ComponentType<any>;
6
+ defaultProps?: ModalProps;
7
+ }
8
+ declare function ModalDef(props: ModalDefProps): null;
9
+ export { ModalDef };
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ interface ModalManagerProviderProps {
3
+ children: React.ReactNode;
4
+ builtInView?: boolean;
5
+ }
6
+ declare function ModalsManagerProvider(props: ModalManagerProviderProps): React.JSX.Element;
7
+ export { ModalsManagerProvider };
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare function ModalsView(): React.JSX.Element | null;
3
+ export { ModalsView };
@@ -0,0 +1,4 @@
1
+ export declare const actionTypes: {
2
+ readonly OPEN_MODAL: "RUBIK_UI/OPEN_MODAL";
3
+ readonly CLOSE_MODAL: "RUBIK_UI/CLOSE_MODAL";
4
+ };
@@ -0,0 +1,2 @@
1
+ declare const ModalsManagerContext: import("react").Context<import("./types").ModalsManagerState | null>;
2
+ export { ModalsManagerContext };
@@ -0,0 +1,6 @@
1
+ import type React from "react";
2
+ import type { ModalsAction } from "./types";
3
+ type Dispatcher = React.Dispatch<ModalsAction>;
4
+ declare function registerDispatcher(dispatch: Dispatcher): void;
5
+ declare function dispatch(action: ModalsAction): void;
6
+ export { registerDispatcher, dispatch };
@@ -0,0 +1,3 @@
1
+ import type { ModalsManager } from "../types";
2
+ declare function useModals(): ModalsManager;
3
+ export { useModals };
@@ -0,0 +1,2 @@
1
+ declare function useModalsContext(): import("../types").ModalsManagerState;
2
+ export { useModalsContext };
@@ -0,0 +1,5 @@
1
+ import type React from "react";
2
+ import type { ModalsAction, ModalsManagerState } from "../types";
3
+ declare const reducer: (state: ModalsManagerState | undefined, action: ModalsAction) => ModalsManagerState;
4
+ declare function useModalsState(): [ModalsManagerState, React.Dispatch<ModalsAction>];
5
+ export { useModalsState, reducer };
@@ -0,0 +1,6 @@
1
+ export { ModalsManagerProvider } from "./ModalsManagerProvider";
2
+ export { ModalsView } from "./ModalsView";
3
+ export { ModalDef } from "./ModalDef";
4
+ export { useModals } from "./hooks/useModals";
5
+ export { modalsManager } from "./modalsManager";
6
+ export { type ModalsManager } from "./types";
@@ -0,0 +1,8 @@
1
+ import type { ModalProps } from "./types";
2
+ declare const modalsManager: {
3
+ open(modalId: string, props?: ModalProps): void;
4
+ close(): void;
5
+ register: (modalId: string, Component: React.ComponentType<unknown>, defaultProps?: ModalProps) => void;
6
+ unregister: (modalId: string) => boolean;
7
+ };
8
+ export { modalsManager };
@@ -0,0 +1,13 @@
1
+ import type React from "react";
2
+ import type { ModalProps, RegistryItem } from "./types";
3
+ declare function register(modalId: string, Component: React.ComponentType<unknown>, defaultProps?: ModalProps): void;
4
+ declare function unregister(modalId: string): boolean;
5
+ declare function get(modalId: string): RegistryItem | undefined;
6
+ declare function has(modalId: string): boolean;
7
+ declare const modalsRegistry: {
8
+ register: typeof register;
9
+ unregister: typeof unregister;
10
+ has: typeof has;
11
+ get: typeof get;
12
+ };
13
+ export { modalsRegistry };
@@ -0,0 +1,25 @@
1
+ import type React from "react";
2
+ import type { actionTypes } from "./constants/actionTypes";
3
+ export type ModalProps = Record<string, unknown>;
4
+ export interface ModalsManagerState {
5
+ activeDialogId: string | null;
6
+ props: ModalProps;
7
+ }
8
+ export interface ModalsManager {
9
+ open: (dialogId: string, props?: ModalProps) => void;
10
+ close: () => void;
11
+ }
12
+ export type ModalsContextState = ModalsManagerState;
13
+ export interface RegistryItem {
14
+ Component: React.ComponentType<unknown>;
15
+ props?: ModalProps;
16
+ }
17
+ export type ModalsAction = {
18
+ type: typeof actionTypes.OPEN_MODAL;
19
+ payload: {
20
+ modalId: string;
21
+ props?: ModalProps;
22
+ };
23
+ } | {
24
+ type: typeof actionTypes.CLOSE_MODAL;
25
+ };
package/dist/index.d.ts CHANGED
@@ -17,4 +17,5 @@ export * from "./Text";
17
17
  export * from "./Textarea";
18
18
  export * from "./ThemesProvider";
19
19
  export * from "./Tooltip";
20
+ export * from "./ModalsManager";
20
21
  export * from "./utils";