eze-factory 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/README.md +59 -0
- package/dist/Bees/ArrayBee.d.ts +2 -0
- package/dist/Bees/Bee.d.ts +3 -0
- package/dist/Bees/Bees.d.ts +3 -0
- package/dist/Bees/FormBee.d.ts +3 -0
- package/dist/Bees/FormBees.d.ts +3 -0
- package/dist/Bees/ObserverBee.d.ts +3 -0
- package/dist/Bees/ObserverBees.d.ts +3 -0
- package/dist/Bees/ObserverFormBee.d.ts +3 -0
- package/dist/Bees/ProxyBee.d.ts +13 -0
- package/dist/Bees/Types.d.ts +74 -0
- package/dist/Bees/index.d.ts +10 -0
- package/dist/Factory/factory.d.ts +9 -0
- package/dist/Factory/index.d.ts +2 -0
- package/dist/Factory/types.d.ts +2 -0
- package/dist/Hives/AsyncHive.d.ts +2 -0
- package/dist/Hives/FormHive.d.ts +16 -0
- package/dist/Hives/Hive.d.ts +2 -0
- package/dist/Hives/HiveArray.d.ts +2 -0
- package/dist/Hives/HiveBase.d.ts +2 -0
- package/dist/Hives/HiveObserver.d.ts +3 -0
- package/dist/Hives/HiveUtils.d.ts +3 -0
- package/dist/Hives/ProxyHive.d.ts +2 -0
- package/dist/Hives/Types.d.ts +98 -0
- package/dist/Hives/index.d.ts +6 -0
- package/dist/Hooks/index.d.ts +4 -0
- package/dist/Hooks/useFormHive.d.ts +5 -0
- package/dist/Hooks/useFormHoney.d.ts +5 -0
- package/dist/Hooks/useHive.d.ts +2 -0
- package/dist/Hooks/useHoney.d.ts +2 -0
- package/dist/System/Constants/Kit/Error.d.ts +3 -0
- package/dist/System/Constants/Kit/IosLoader.d.ts +3 -0
- package/dist/System/Constants/Kit/ItemsLoading.d.ts +3 -0
- package/dist/System/Constants/Kit/Loader.d.ts +6 -0
- package/dist/System/Constants/Kit/LoaderTwo.d.ts +7 -0
- package/dist/System/Constants/Kit/Loading.d.ts +3 -0
- package/dist/System/Constants/Kit/NoContent.d.ts +6 -0
- package/dist/System/Constants/Kit/Progressing.d.ts +7 -0
- package/dist/System/Constants/Kit/Searching.d.ts +3 -0
- package/dist/System/Constants/Kit/StateKit.d.ts +21 -0
- package/dist/System/Constants/Kit/index.d.ts +4 -0
- package/dist/System/Constants/QueryDefaults.d.ts +17 -0
- package/dist/System/Constants/StatusDefaults.d.ts +8 -0
- package/dist/System/Factories/DetailFactory.d.ts +25 -0
- package/dist/System/Factories/FactoryPackage.d.ts +6 -0
- package/dist/System/Factories/ListFactory.d.ts +34 -0
- package/dist/System/Factories/StaticTableFactory.d.ts +33 -0
- package/dist/System/Factories/TableFactory.d.ts +40 -0
- package/dist/System/Factories/Types.d.ts +25 -0
- package/dist/System/Factories/index.d.ts +4 -0
- package/dist/System/Slices/Exporter/ExporterMechanics.d.ts +17 -0
- package/dist/System/Slices/Exporter/ExporterSlice.d.ts +4 -0
- package/dist/System/Slices/Exporter/Types.d.ts +35 -0
- package/dist/System/Slices/Loader/LoaderMechanics.d.ts +5 -0
- package/dist/System/Slices/Loader/LoaderSlice.d.ts +15 -0
- package/dist/System/Slices/Loader/Types.d.ts +25 -0
- package/dist/System/Slices/Paginator/PaginatorMechanics.d.ts +17 -0
- package/dist/System/Slices/Paginator/PaginatorSlice.d.ts +22 -0
- package/dist/System/Slices/Paginator/Types.d.ts +30 -0
- package/dist/System/Slices/Query/Components/Filters.d.ts +8 -0
- package/dist/System/Slices/Query/Components/QueryContainer.d.ts +9 -0
- package/dist/System/Slices/Query/Components/QueryElements.d.ts +18 -0
- package/dist/System/Slices/Query/Components/Sorts.d.ts +0 -0
- package/dist/System/Slices/Query/QueryMechanics.d.ts +13 -0
- package/dist/System/Slices/Query/QuerySlice.d.ts +4 -0
- package/dist/System/Slices/Query/Types.d.ts +46 -0
- package/dist/System/Slices/Status/Components/StatusIndicator.d.ts +91 -0
- package/dist/System/Slices/Status/Components/StatutsComopnent.d.ts +12 -0
- package/dist/System/Slices/Status/StatusSlice.d.ts +22 -0
- package/dist/System/Slices/Status/Types.d.ts +76 -0
- package/dist/System/Slices/Table/Components.d.ts +2 -0
- package/dist/System/Slices/Table/TableMechanics.d.ts +20 -0
- package/dist/System/Slices/Table/TableSlice.d.ts +4 -0
- package/dist/System/Slices/Table/Types.d.ts +71 -0
- package/dist/System/Slices/Types.d.ts +39 -0
- package/dist/System/StatusKit.d.ts +76 -0
- package/dist/Types.d.ts +15 -0
- package/dist/Ui/Containers/ControllerContainers.d.ts +17 -0
- package/dist/Ui/Containers/index.d.ts +1 -0
- package/dist/Ui/StatusKit/StateBuilder.d.ts +8 -0
- package/dist/Ui/StatusKit/StatusBee.d.ts +15 -0
- package/dist/Ui/StatusKit/StatusKit.d.ts +16 -0
- package/dist/Ui/StatusKit/empty.d.ts +6 -0
- package/dist/Ui/StatusKit/error.d.ts +7 -0
- package/dist/Ui/StatusKit/index.d.ts +4 -0
- package/dist/Ui/StatusKit/loading.d.ts +6 -0
- package/dist/Ui/StatusKit/loadingMore.d.ts +6 -0
- package/dist/Ui/StatusKit/processing.d.ts +6 -0
- package/dist/Ui/Wrappers/Wrapper.d.ts +17 -0
- package/dist/Ui/Wrappers/index.d.ts +2 -0
- package/dist/Ui/Wrappers/types.d.ts +38 -0
- package/dist/Ui/index.d.ts +2 -0
- package/dist/Utils/Storable.d.ts +20 -0
- package/dist/Utils/Utils.d.ts +3 -0
- package/dist/Utils/index.d.ts +5 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FilterDefinition, QueryComponentMap } from "../Slices/Query/Types";
|
|
2
|
+
import { StatusSliceConfig } from "../Slices/Status/Types";
|
|
3
|
+
import { PaginatorProps } from "../Slices/Paginator/Types";
|
|
4
|
+
import { TableSliceConfig } from "../Slices/Table/Types";
|
|
5
|
+
import { ExporterSliceConfig } from "../Slices/Exporter/Types";
|
|
6
|
+
import { ArrayElement } from "../Slices/Paginator/PaginatorMechanics";
|
|
7
|
+
import { DefaultComponentMap } from "../Constants/QueryDefaults";
|
|
8
|
+
type DefaultMap = typeof DefaultComponentMap;
|
|
9
|
+
type MergedMap<M extends QueryComponentMap> = DefaultMap & M;
|
|
10
|
+
type FactoryQueryConfig<M extends QueryComponentMap> = {
|
|
11
|
+
componentMap?: M;
|
|
12
|
+
filters: Record<string, FilterDefinition<MergedMap<M>>>;
|
|
13
|
+
validators?: any[];
|
|
14
|
+
onQueryChange?: (query: any) => void;
|
|
15
|
+
syncWithRouter?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function createTableFactory<P extends {
|
|
18
|
+
load: (...args: any[]) => Promise<any>;
|
|
19
|
+
reload: (...args: any[]) => Promise<any>;
|
|
20
|
+
loadMore: () => Promise<any>;
|
|
21
|
+
hasMore: boolean;
|
|
22
|
+
limit: number;
|
|
23
|
+
}, R = Awaited<ReturnType<P["load"]>>, Fmt = undefined, M extends QueryComponentMap = {}>(config: {
|
|
24
|
+
query?: FactoryQueryConfig<M>;
|
|
25
|
+
paginator: PaginatorProps<P, R, Fmt, any>;
|
|
26
|
+
status?: Partial<StatusSliceConfig>;
|
|
27
|
+
table: TableSliceConfig<ArrayElement<Fmt extends undefined ? R : Fmt>>;
|
|
28
|
+
exporter?: ExporterSliceConfig<ArrayElement<Fmt extends undefined ? R : Fmt>>;
|
|
29
|
+
}): import("./FactoryPackage").Factory<{
|
|
30
|
+
status: import("../Slices/Status/Types").StatusAPI<import("../Slices/Status/Types").StatusKit>;
|
|
31
|
+
} & {
|
|
32
|
+
query: import("../Slices/Query/Types").QueryAPI<MergedMap<M>, Record<string, FilterDefinition<MergedMap<M>>>>;
|
|
33
|
+
} & {
|
|
34
|
+
paginator: import("../Slices/Paginator/Types").PaginatorAPI<ArrayElement<Fmt extends undefined ? R : Fmt>, any>;
|
|
35
|
+
} & {
|
|
36
|
+
table: import("../Slices/Table/Types").TableAPI<ArrayElement<Fmt extends undefined ? R : Fmt>>;
|
|
37
|
+
} & {
|
|
38
|
+
exporter: import("../Slices/Exporter/Types").ExporterAPI;
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PaginatorAPI } from "../Slices/Paginator/Types";
|
|
2
|
+
import { StatusAPI } from "../Slices/Status/Types";
|
|
3
|
+
import { IQueryFilterBuilder } from "../Slices/Types";
|
|
4
|
+
import { TableAPI } from "../Slices/Table/Types";
|
|
5
|
+
import { ExporterAPI } from "../Slices/Exporter/Types";
|
|
6
|
+
import { LoaderAPI } from "../Slices/Loader/Types";
|
|
7
|
+
import { QueryAPI } from "../Slices/Query/Types";
|
|
8
|
+
export interface IPaginatorFactory<T> {
|
|
9
|
+
paginator: PaginatorAPI<T>;
|
|
10
|
+
}
|
|
11
|
+
export interface ILoaderFactory<Response> {
|
|
12
|
+
loader: LoaderAPI<Response>;
|
|
13
|
+
}
|
|
14
|
+
export interface IStatusFactory {
|
|
15
|
+
status: StatusAPI;
|
|
16
|
+
}
|
|
17
|
+
export interface IQueryFactory<F extends readonly IQueryFilterBuilder[]> {
|
|
18
|
+
query: QueryAPI<F>;
|
|
19
|
+
}
|
|
20
|
+
export interface ITableFactory<T> {
|
|
21
|
+
table: TableAPI<T>;
|
|
22
|
+
}
|
|
23
|
+
export interface IExporterFactory {
|
|
24
|
+
exporter: ExporterAPI;
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TableColumnDef } from "../Table/Types";
|
|
2
|
+
import { ExporterDependencies, ExporterSliceConfig } from "./Types";
|
|
3
|
+
export declare const ExporterMechanics: {
|
|
4
|
+
rowsToCsv: (headers: string[], rows: Record<string, any>[]) => string;
|
|
5
|
+
rowsToXlsx: (headers: string[], rows: Record<string, any>[]) => Promise<Blob>;
|
|
6
|
+
saveFileBrowser: (filename: string, blob: Blob) => Promise<void>;
|
|
7
|
+
saveFileNative: (filename: string, blob: Blob | string) => Promise<void>;
|
|
8
|
+
resolveData: <TItem>(config: ExporterSliceConfig<TItem>, ctx: ExporterDependencies<TItem>) => Promise<TItem[]>;
|
|
9
|
+
resolveColumns: <TItem>(config: ExporterSliceConfig<TItem>, ctx: ExporterDependencies<TItem>) => TableColumnDef<TItem>[];
|
|
10
|
+
applyPrepare: <TItem>(config: ExporterSliceConfig<TItem>, items: TItem[], cols: TableColumnDef<TItem>[]) => Promise<{
|
|
11
|
+
items: TItem[];
|
|
12
|
+
cols: TableColumnDef<TItem>[];
|
|
13
|
+
}>;
|
|
14
|
+
download: <TItem>(config: ExporterSliceConfig<TItem>, ctx: ExporterDependencies<TItem>, opts: {
|
|
15
|
+
type: "csv" | "excel";
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PaginatorAPI } from "../Paginator/Types";
|
|
2
|
+
import { StatusAPI } from "../Status/Types";
|
|
3
|
+
import { TableAPI, TableColumnDef } from "../Table/Types";
|
|
4
|
+
import { LoaderAPI } from "../Loader/Types";
|
|
5
|
+
export type ExporterSliceConfig<TItem> = {
|
|
6
|
+
columns?: TableColumnDef<TItem>[];
|
|
7
|
+
/**
|
|
8
|
+
* prepare receives the resolved items and resolved columns.
|
|
9
|
+
* It may:
|
|
10
|
+
* - return a new items array,
|
|
11
|
+
* - return { items?, cols? } to modify either,
|
|
12
|
+
* - or return void/undefined to not change anything.
|
|
13
|
+
*/
|
|
14
|
+
prepare?: (items: TItem[], cols: TableColumnDef<TItem>[]) => Promise<TItem[] | {
|
|
15
|
+
items?: TItem[];
|
|
16
|
+
cols?: TableColumnDef<TItem>[];
|
|
17
|
+
} | void> | TItem[] | {
|
|
18
|
+
items?: TItem[];
|
|
19
|
+
cols?: TableColumnDef<TItem>[];
|
|
20
|
+
} | void;
|
|
21
|
+
filename?: (type: "csv" | "excel") => string;
|
|
22
|
+
dataProvider?: (ctx: any) => TItem[] | Promise<TItem[]>;
|
|
23
|
+
useStatus?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export interface ExporterAPI {
|
|
26
|
+
download: (opts: {
|
|
27
|
+
type: "csv" | "excel";
|
|
28
|
+
}) => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export interface ExporterDependencies<TItem> {
|
|
31
|
+
paginator?: PaginatorAPI<TItem>;
|
|
32
|
+
loader?: LoaderAPI<TItem[]>;
|
|
33
|
+
table: TableAPI<TItem>;
|
|
34
|
+
status?: StatusAPI;
|
|
35
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LoaderFunction, LoaderProps } from "./Types";
|
|
2
|
+
export declare const LoaderMechanics: {
|
|
3
|
+
load: <L extends LoaderFunction, R = Awaited<ReturnType<L>>, Fmt = undefined>(config: LoaderProps<L, R, Fmt>, params?: any, clearCache?: boolean) => Promise<Fmt extends undefined ? R : Fmt>;
|
|
4
|
+
reload: <L extends LoaderFunction, R = Awaited<ReturnType<L>>, Fmt = undefined>(config: LoaderProps<L, R, Fmt>, params?: any) => Promise<Fmt extends undefined ? R : Fmt>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LoaderAPI, LoaderDependencies, LoaderFunction, LoaderProps } from "./Types";
|
|
2
|
+
/**
|
|
3
|
+
* LoaderSlice - Handles data loading with loading states
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ **Requires:** StatusSlice must be added before this slice
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // ✅ Correct
|
|
9
|
+
* createFactory()
|
|
10
|
+
* .use(StatusSlice())
|
|
11
|
+
* .use(LoaderSlice({ loader: myLoader }))
|
|
12
|
+
*/
|
|
13
|
+
export declare function LoaderSlice<L extends LoaderFunction, R = Awaited<ReturnType<L>>, Fmt = undefined>(props: LoaderProps<L, R, Fmt>): (ctx: LoaderDependencies) => {
|
|
14
|
+
loader: LoaderAPI<Fmt extends undefined ? R : Fmt>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IHive } from "../../../Hives";
|
|
2
|
+
import { StatusAPI } from "../Status/Types";
|
|
3
|
+
import { QueryAPI } from "../Query/Types";
|
|
4
|
+
export type LoaderFunction<Params = any, Response = any> = (params?: Params, clearCache?: boolean) => Promise<Response>;
|
|
5
|
+
export interface LoaderProps<L extends LoaderFunction, R = Awaited<ReturnType<L>>, Fmt = undefined, Q = any> {
|
|
6
|
+
loader: L;
|
|
7
|
+
format?: (raw: R) => Fmt;
|
|
8
|
+
onError?: (e: unknown) => void;
|
|
9
|
+
shouldLoadOnQueryChange?: (query: Q, controls: {
|
|
10
|
+
clear: () => void;
|
|
11
|
+
}) => boolean;
|
|
12
|
+
statusProps?: {
|
|
13
|
+
useStatus?: boolean;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface LoaderAPI<Response> {
|
|
17
|
+
loaderHive: IHive<Response>;
|
|
18
|
+
load: (params?: any, clearCache?: boolean) => Promise<void>;
|
|
19
|
+
reload: (params?: any) => Promise<void>;
|
|
20
|
+
isLoading: () => boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface LoaderDependencies {
|
|
23
|
+
status: StatusAPI;
|
|
24
|
+
query?: QueryAPI<any, any>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IHive, IHiveArray } from "../../../Hives";
|
|
2
|
+
import { PaginatorDependencies, PaginatorProps } from "./Types";
|
|
3
|
+
export type ArrayElement<R> = R extends Array<infer U> ? U : R extends {
|
|
4
|
+
batch: Array<infer V>;
|
|
5
|
+
} ? V : R extends {
|
|
6
|
+
data: Array<infer W>;
|
|
7
|
+
} ? W : never;
|
|
8
|
+
export declare const PaginatorMechanics: {
|
|
9
|
+
getArrayFromResponse: <R>(response: R) => ArrayElement<R>[];
|
|
10
|
+
exec: <P extends {
|
|
11
|
+
load: (...args: any[]) => Promise<any>;
|
|
12
|
+
reload: (...args: any[]) => Promise<any>;
|
|
13
|
+
loadMore: () => Promise<any>;
|
|
14
|
+
hasMore: boolean;
|
|
15
|
+
limit: number;
|
|
16
|
+
}, R, F, Item>(ctx: PaginatorDependencies, props: PaginatorProps<P, R, F>, hive: IHiveArray<Item>, canLoadHive: IHive<boolean>, fn: () => Promise<R>, append: boolean) => Promise<void>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ArrayElement } from "./PaginatorMechanics";
|
|
2
|
+
import { PaginatorAPI, PaginatorDependencies, PaginatorProps } from "./Types";
|
|
3
|
+
/**
|
|
4
|
+
* PaginatorSlice - Handles pagination with loading states
|
|
5
|
+
*
|
|
6
|
+
* ⚠️ **Requires:** StatusSlice must be added before this slice
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // ✅ Correct
|
|
10
|
+
* createFactory()
|
|
11
|
+
* .use(StatusSlice())
|
|
12
|
+
* .use(PaginatorSlice({ paginator: myPaginator }))
|
|
13
|
+
*/
|
|
14
|
+
export declare function PaginatorSlice<P extends {
|
|
15
|
+
load: (...args: any[]) => Promise<any>;
|
|
16
|
+
reload: (...args: any[]) => Promise<any>;
|
|
17
|
+
loadMore: () => Promise<any>;
|
|
18
|
+
hasMore: boolean;
|
|
19
|
+
limit: number;
|
|
20
|
+
}, R = Awaited<ReturnType<P["load"]>>, F = undefined>(props: PaginatorProps<P, R, F>): (ctx: PaginatorDependencies) => {
|
|
21
|
+
paginator: PaginatorAPI<ArrayElement<F extends undefined ? R : F>>;
|
|
22
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IHive, IHiveArray } from "../../../Hives";
|
|
2
|
+
import { StatusAPI } from "../Status/Types";
|
|
3
|
+
import { QueryAPI } from "../Query/Types";
|
|
4
|
+
export interface PaginatorProps<P extends {
|
|
5
|
+
load: (...args: any[]) => Promise<any>;
|
|
6
|
+
reload: (...args: any[]) => Promise<any>;
|
|
7
|
+
loadMore: () => Promise<any>;
|
|
8
|
+
hasMore: boolean;
|
|
9
|
+
limit: number;
|
|
10
|
+
}, R = Awaited<ReturnType<P["load"]>>, F = undefined, Q = any> {
|
|
11
|
+
paginator: P;
|
|
12
|
+
format?: (raw: R) => F;
|
|
13
|
+
onError?: (e: unknown) => void;
|
|
14
|
+
shouldLoadOnQueryChange?: (query: Q, controls: {
|
|
15
|
+
clear: () => void;
|
|
16
|
+
}) => boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface PaginatorAPI<Item, Query = any> {
|
|
19
|
+
paginatorHive: IHiveArray<Item>;
|
|
20
|
+
load: (q?: Query) => Promise<void>;
|
|
21
|
+
reload: (q?: Query) => Promise<void>;
|
|
22
|
+
loadMore: () => Promise<void>;
|
|
23
|
+
hasMore: boolean;
|
|
24
|
+
limit: number;
|
|
25
|
+
canLoadHive: IHive<boolean>;
|
|
26
|
+
}
|
|
27
|
+
export interface PaginatorDependencies {
|
|
28
|
+
status: StatusAPI;
|
|
29
|
+
query?: QueryAPI<any>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IQueryFactory } from "../../../Factories/Types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
type Props = {
|
|
4
|
+
factory: IQueryFactory<any>;
|
|
5
|
+
children?: any;
|
|
6
|
+
filterClass?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const QueryContainer: ({ children, factory }: Props) => React.JSX.Element;
|
|
9
|
+
export default QueryContainer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { QueryAPI } from "../Types";
|
|
3
|
+
export interface IQueryProps {
|
|
4
|
+
id: string;
|
|
5
|
+
query: QueryAPI<any>;
|
|
6
|
+
debounce?: number;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
interface IQueryElementProps extends IQueryProps {
|
|
10
|
+
Element: any;
|
|
11
|
+
}
|
|
12
|
+
interface IQueryElementLabeledProps extends IQueryElementProps {
|
|
13
|
+
label?: any;
|
|
14
|
+
customLabel?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const QueryElementLabeled: ({ id, no_label, query, label, customLabel, Element, debounce, ...props }: IQueryElementLabeledProps) => React.JSX.Element;
|
|
17
|
+
export declare const QueryElement: ({ id, query, Element, debounce, ...props }: IQueryElementProps) => React.JSX.Element;
|
|
18
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IHive } from "../../../Hives";
|
|
2
|
+
import { FilterDefinition, IdOf, QueryRecord, QuerySliceConfig } from "./Types";
|
|
3
|
+
export declare const QueryMechanics: {
|
|
4
|
+
createHive: <F extends Record<string, FilterDefinition>>(config: QuerySliceConfig<any, F>) => IHive<QueryRecord<F>>;
|
|
5
|
+
syncInitialQuery: <F extends Record<string, FilterDefinition>>(hive: IHive<QueryRecord<F>>, config: QuerySliceConfig<any, F>) => Promise<void>;
|
|
6
|
+
validate: <F extends Record<string, FilterDefinition>>(config: QuerySliceConfig<any, F>, key: IdOf<F>, value: any) => boolean | string;
|
|
7
|
+
setQuery: <F extends Record<string, FilterDefinition>>(hive: IHive<QueryRecord<F>>, q: QueryRecord<F>, config: QuerySliceConfig<any, F>) => void;
|
|
8
|
+
updateQuery: <F extends Record<string, FilterDefinition>, K extends IdOf<F>>(hive: IHive<QueryRecord<F>>, patch: {
|
|
9
|
+
id: K;
|
|
10
|
+
value: any;
|
|
11
|
+
}, config: QuerySliceConfig<any, F>) => boolean;
|
|
12
|
+
removeParam: <F extends Record<string, FilterDefinition>>(hive: IHive<QueryRecord<F>>, key: IdOf<F>, config: QuerySliceConfig<any, F>) => Promise<void>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FilterDefinition, QueryAPI, QueryComponentMap, QuerySliceConfig } from "./Types";
|
|
2
|
+
export declare function QuerySlice<M extends QueryComponentMap, F extends Record<string, FilterDefinition<M>>>(config: QuerySliceConfig<M, F>): (_: any) => {
|
|
3
|
+
query: QueryAPI<M, F>;
|
|
4
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { IHive } from "../../../Hives";
|
|
3
|
+
export type ParrotKey = string;
|
|
4
|
+
export type QueryComponentMap = Record<string, React.FC<any>>;
|
|
5
|
+
type CommonFilterProps = {
|
|
6
|
+
label?: ParrotKey;
|
|
7
|
+
placement?: "InLine" | "InPopup" | "Auto";
|
|
8
|
+
isMain?: boolean;
|
|
9
|
+
value?: any;
|
|
10
|
+
};
|
|
11
|
+
export type FilterDefinition<M extends QueryComponentMap = any> = {
|
|
12
|
+
[K in keyof M]: {
|
|
13
|
+
type: K;
|
|
14
|
+
} & Omit<ComponentProps<M[K]>, keyof CommonFilterProps | "queryBuilder" | "id"> & CommonFilterProps;
|
|
15
|
+
}[keyof M];
|
|
16
|
+
export type IdOf<F extends Record<string, any>> = Extract<keyof F, string>;
|
|
17
|
+
export type QueryRecord<F extends Record<string, any>> = {
|
|
18
|
+
[K in keyof F]?: any;
|
|
19
|
+
};
|
|
20
|
+
export interface QueryValidator<F extends Record<string, any>> {
|
|
21
|
+
<K extends keyof F>(key: K, value: any): boolean | string;
|
|
22
|
+
}
|
|
23
|
+
export interface QuerySliceConfig<M extends QueryComponentMap = any, F extends Record<string, FilterDefinition<M>> = any> {
|
|
24
|
+
componentMap: M;
|
|
25
|
+
filters: F;
|
|
26
|
+
validators?: Array<QueryValidator<F>>;
|
|
27
|
+
onQueryChange?: (query: QueryRecord<F>) => void;
|
|
28
|
+
syncWithRouter?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface QueryAPI<M extends QueryComponentMap = any, F extends Record<string, FilterDefinition<M>> = any> {
|
|
31
|
+
filters: F;
|
|
32
|
+
queryHive: IHive<QueryRecord<F>>;
|
|
33
|
+
getParam: <K extends IdOf<F>>(key: K) => any;
|
|
34
|
+
getQuery: () => QueryRecord<F>;
|
|
35
|
+
setQuery: (q: QueryRecord<F>) => void;
|
|
36
|
+
updateQuery: <K extends IdOf<F>>(patch: {
|
|
37
|
+
id: K;
|
|
38
|
+
value: any;
|
|
39
|
+
}) => boolean;
|
|
40
|
+
removeParam: (key: IdOf<F>) => void;
|
|
41
|
+
clearQuery: () => void;
|
|
42
|
+
listenToQuery: (cb: (q: QueryRecord<F>) => void) => () => void;
|
|
43
|
+
componentMap: M;
|
|
44
|
+
getFilterComponent: (type: keyof M) => React.FC<any>;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { StatusAPI, StatusKit, StatusTypeNames, OperationState } from "../Types";
|
|
3
|
+
interface StatusIndicatorProps<K extends StatusKit> {
|
|
4
|
+
/** The status API from the factory */
|
|
5
|
+
status: StatusAPI<K>;
|
|
6
|
+
/** Optional: Only listen to these operations */
|
|
7
|
+
operations?: string[];
|
|
8
|
+
/** Optional: Only show these status types */
|
|
9
|
+
statusTypes?: StatusTypeNames<K>[];
|
|
10
|
+
/** Optional: Custom render function */
|
|
11
|
+
children?: (state: OperationState<K> | null) => ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* StatusIndicator - Displays status based on active operations
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Show status for all operations
|
|
18
|
+
* <StatusIndicator status={status} />
|
|
19
|
+
*
|
|
20
|
+
* // Scoped to specific operations
|
|
21
|
+
* <StatusIndicator
|
|
22
|
+
* status={status}
|
|
23
|
+
* operations={['table', 'table-sort']}
|
|
24
|
+
* />
|
|
25
|
+
*
|
|
26
|
+
* // Custom render
|
|
27
|
+
* <StatusIndicator status={status}>
|
|
28
|
+
* {(state) => state ? <CustomLoader /> : null}
|
|
29
|
+
* </StatusIndicator>
|
|
30
|
+
*/
|
|
31
|
+
export declare function StatusIndicator<K extends StatusKit>({ status, operations, statusTypes, children }: StatusIndicatorProps<K>): ReactNode;
|
|
32
|
+
interface TypedIndicatorProps<K extends StatusKit> {
|
|
33
|
+
status: StatusAPI<K>;
|
|
34
|
+
operations?: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* LoadingIndicator - Only shows loading status
|
|
38
|
+
*/
|
|
39
|
+
export declare function LoadingIndicator<K extends StatusKit>({ status, operations }: TypedIndicatorProps<K>): ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* ErrorDisplay - Only shows error status
|
|
42
|
+
*/
|
|
43
|
+
export declare function ErrorDisplay<K extends StatusKit>({ status, operations }: TypedIndicatorProps<K>): ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* SuccessToast - Only shows success status
|
|
46
|
+
*/
|
|
47
|
+
export declare function SuccessToast<K extends StatusKit>({ status, operations }: TypedIndicatorProps<K>): ReactNode;
|
|
48
|
+
interface StatusGuardProps<K extends StatusKit> {
|
|
49
|
+
status: StatusAPI<K>;
|
|
50
|
+
operations?: string[];
|
|
51
|
+
statusTypes?: StatusTypeNames<K>[];
|
|
52
|
+
fallback: ReactNode;
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* StatusGuard - Show fallback while status is active, otherwise show children
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* <StatusGuard
|
|
60
|
+
* status={status}
|
|
61
|
+
* operations={['table']}
|
|
62
|
+
* fallback={<Skeleton />}
|
|
63
|
+
* >
|
|
64
|
+
* <TableContent />
|
|
65
|
+
* </StatusGuard>
|
|
66
|
+
*/
|
|
67
|
+
export declare function StatusGuard<K extends StatusKit>({ status, operations, statusTypes, fallback, children }: StatusGuardProps<K>): ReactNode;
|
|
68
|
+
interface ProgressBarProps<K extends StatusKit> {
|
|
69
|
+
status: StatusAPI<K>;
|
|
70
|
+
operations: string[];
|
|
71
|
+
className?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* ProgressBar - Shows progress from status props
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* <ProgressBar
|
|
78
|
+
* status={status}
|
|
79
|
+
* operations={['upload']}
|
|
80
|
+
* />
|
|
81
|
+
*/
|
|
82
|
+
export declare function ProgressBar<K extends StatusKit>({ status, operations, className }: ProgressBarProps<K>): ReactNode;
|
|
83
|
+
export declare const StatusComponents: {
|
|
84
|
+
StatusIndicator: typeof StatusIndicator;
|
|
85
|
+
LoadingIndicator: typeof LoadingIndicator;
|
|
86
|
+
ErrorDisplay: typeof ErrorDisplay;
|
|
87
|
+
SuccessToast: typeof SuccessToast;
|
|
88
|
+
StatusGuard: typeof StatusGuard;
|
|
89
|
+
ProgressBar: typeof ProgressBar;
|
|
90
|
+
};
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StatusAPI, StatusKit } from "../Types";
|
|
3
|
+
interface StatusComponentProps<K extends StatusKit> {
|
|
4
|
+
status: StatusAPI<K>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* StatusComponent - Renders the primary status using getComponent
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Use StatusIndicator instead for more control
|
|
10
|
+
*/
|
|
11
|
+
declare function StatusComponent<K extends StatusKit>({ status }: StatusComponentProps<K>): React.JSX.Element | null;
|
|
12
|
+
export default StatusComponent;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StatusAPI, StatusKit, StatusSliceConfig } from "./Types";
|
|
2
|
+
/**
|
|
3
|
+
* StatusSlice V3 - Operations-based status management
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Multiple concurrent operations
|
|
7
|
+
* - String-based operation names
|
|
8
|
+
* - Dynamic status type methods from StatusKit
|
|
9
|
+
* - Priority-based status resolution
|
|
10
|
+
* - Scoped component listeners
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Basic usage
|
|
14
|
+
* ctx.status.operation('table').loading({ variant: 'skeleton' });
|
|
15
|
+
* ctx.status.operation('table').success({ message: 'Done!' });
|
|
16
|
+
*
|
|
17
|
+
* // Default operation
|
|
18
|
+
* ctx.status.ready().loading({ message: 'Loading...' });
|
|
19
|
+
*/
|
|
20
|
+
export declare function StatusSlice<K extends StatusKit>(config: StatusSliceConfig<K>): (_ctx: any) => {
|
|
21
|
+
status: StatusAPI<K>;
|
|
22
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IHive } from "../../../Hives";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Defines a single status type configuration
|
|
5
|
+
*/
|
|
6
|
+
export interface StatusTypeConfig<P = any> {
|
|
7
|
+
priority: number;
|
|
8
|
+
props: P;
|
|
9
|
+
component: (props: P) => ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A StatusKit is a record of status type names to their configurations
|
|
13
|
+
*/
|
|
14
|
+
export type StatusKit = Record<string, StatusTypeConfig<any>>;
|
|
15
|
+
/**
|
|
16
|
+
* Extract status type names from a StatusKit
|
|
17
|
+
*/
|
|
18
|
+
export type StatusTypeNames<K extends StatusKit> = keyof K & string;
|
|
19
|
+
/**
|
|
20
|
+
* Extract props type for a specific status type from a StatusKit
|
|
21
|
+
*/
|
|
22
|
+
export type StatusPropsFor<K extends StatusKit, T extends StatusTypeNames<K>> = K[T]["props"];
|
|
23
|
+
/**
|
|
24
|
+
* State for a single operation stored in the hive
|
|
25
|
+
*/
|
|
26
|
+
export interface OperationState<K extends StatusKit = StatusKit> {
|
|
27
|
+
operation: string;
|
|
28
|
+
statusType: StatusTypeNames<K>;
|
|
29
|
+
props: any;
|
|
30
|
+
priority: number;
|
|
31
|
+
startedAt: number;
|
|
32
|
+
timeout?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Options for setting a status
|
|
36
|
+
*/
|
|
37
|
+
export interface StatusOptions {
|
|
38
|
+
timeout?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The chain returned by operation(name) or ready()
|
|
42
|
+
* Dynamically typed based on the StatusKit
|
|
43
|
+
*/
|
|
44
|
+
export type OperationChain<K extends StatusKit = StatusKit> = {
|
|
45
|
+
[T in StatusTypeNames<K>]: (props: StatusPropsFor<K, T>, options?: StatusOptions) => void;
|
|
46
|
+
} & {
|
|
47
|
+
idle: () => void;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The main StatusSlice API exposed to slices and components
|
|
51
|
+
*/
|
|
52
|
+
export interface StatusAPI<K extends StatusKit = StatusKit> {
|
|
53
|
+
operation: (name: string) => OperationChain<K>;
|
|
54
|
+
ready: () => OperationChain<K>;
|
|
55
|
+
isActive: (operation: string) => boolean;
|
|
56
|
+
isAnyActive: (operations: string[]) => boolean;
|
|
57
|
+
getState: (operation: string) => OperationState<K> | null;
|
|
58
|
+
getPrimary: (operations?: string[], statusTypes?: StatusTypeNames<K>[]) => OperationState<K> | null;
|
|
59
|
+
getActiveOperations: () => string[];
|
|
60
|
+
getComponent: (statusType: StatusTypeNames<K>) => (props: any) => ReactNode;
|
|
61
|
+
hive: IHive<Map<string, OperationState<K>>>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Configuration for the StatusSlice
|
|
65
|
+
*/
|
|
66
|
+
export interface StatusSliceConfig<K extends StatusKit = StatusKit> {
|
|
67
|
+
statusKit: K;
|
|
68
|
+
staleTimeout?: number;
|
|
69
|
+
onStaleOperation?: (operation: OperationState<K>) => void;
|
|
70
|
+
}
|
|
71
|
+
export declare const DefaultStatusTypes: {
|
|
72
|
+
readonly idle: "idle";
|
|
73
|
+
readonly loading: "loading";
|
|
74
|
+
readonly success: "success";
|
|
75
|
+
readonly error: "error";
|
|
76
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TableColumnDef, TableSliceConfig, TableSort } from "./Types";
|
|
2
|
+
export declare const TableMechanics: {
|
|
3
|
+
Storage: {
|
|
4
|
+
saveColumns: (key: string, columns: TableColumnDef<any>[]) => void;
|
|
5
|
+
getColumns: <T>(key: string) => Partial<TableColumnDef<T>>[];
|
|
6
|
+
clearColumns: (key: string) => void;
|
|
7
|
+
};
|
|
8
|
+
Sorting: {
|
|
9
|
+
sortRows: <T>(rows: T[], sorts: TableSort<T>[]) => T[];
|
|
10
|
+
};
|
|
11
|
+
Columns: {
|
|
12
|
+
initialize: <TItem>(config: TableSliceConfig<TItem>, ctx: any, storeKey: string) => TableColumnDef<TItem>[];
|
|
13
|
+
setVisible: <TItem>(config: TableSliceConfig<TItem>, ctx: any, cols: TableColumnDef<TItem>[], storeKey: string) => TableColumnDef<TItem>[];
|
|
14
|
+
};
|
|
15
|
+
Selection: {
|
|
16
|
+
toggle: <TItem>(prev: Record<string, TItem>, item: any, idKey: string) => Record<string, TItem>;
|
|
17
|
+
isAllSelected: <TItem>(rows: TItem[], selected: Record<string, TItem>, idKey: string) => boolean;
|
|
18
|
+
selectAll: <TItem>(rows: TItem[], idKey: string) => Record<string, TItem>;
|
|
19
|
+
};
|
|
20
|
+
};
|