@mittwald/flow-react-components 0.1.0-alpha.42 → 0.1.0-alpha.44
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/dist/Avatar.js +14 -13
- package/dist/Heading.js +21 -15
- package/dist/IconChevronUp-_2GHUOdG.js +10 -0
- package/dist/IconPlus-D0cizRQb.js +10 -0
- package/dist/Icons.js +27 -26
- package/dist/InlineCode-CVs3jCiw.js +13 -0
- package/dist/InlineCode.js +3 -10
- package/dist/List/ListLoaderAsyncResource.js +8 -0
- package/dist/List.js +546 -0
- package/dist/NumberField.js +12 -11
- package/dist/styles.css +1 -1
- package/dist/types/components/Heading/stories/Default.stories.d.ts +1 -0
- package/dist/types/components/Heading/stories/EdgeCases.stories.d.ts +6 -0
- package/dist/types/components/List/List.d.ts +7 -0
- package/dist/types/components/List/List.test.d.ts +1 -0
- package/dist/types/components/List/components/DataLoader/DataLoader.d.ts +3 -0
- package/dist/types/components/List/components/DataLoader/components/SuspenseFallback/SuspenseFallback.d.ts +6 -0
- package/dist/types/components/List/components/DataLoader/components/SuspenseFallback/index.d.ts +3 -0
- package/dist/types/components/List/components/DataLoader/index.d.ts +3 -0
- package/dist/types/components/List/components/FilterBar/FilterBar.d.ts +6 -0
- package/dist/types/components/List/components/FilterBar/components/FilterPicker/FilterPicker.d.ts +2 -0
- package/dist/types/components/List/components/FilterBar/components/FilterPicker/index.d.ts +3 -0
- package/dist/types/components/List/components/FilterBar/components/FilterPickerItem/FilterPickerItem.d.ts +8 -0
- package/dist/types/components/List/components/FilterBar/components/FilterPickerItem/index.d.ts +3 -0
- package/dist/types/components/List/components/FilterBar/components/SortingPicker/SortingPicker.d.ts +2 -0
- package/dist/types/components/List/components/FilterBar/components/SortingPicker/index.d.ts +3 -0
- package/dist/types/components/List/components/FilterBar/components/SortingPickerItem/SortingPickerItem.d.ts +8 -0
- package/dist/types/components/List/components/FilterBar/components/SortingPickerItem/index.d.ts +3 -0
- package/dist/types/components/List/components/FilterBar/index.d.ts +3 -0
- package/dist/types/components/List/components/Item/FallbackRenderer.d.ts +7 -0
- package/dist/types/components/List/components/Item/Item.d.ts +5 -0
- package/dist/types/components/List/components/Item/index.d.ts +3 -0
- package/dist/types/components/List/components/Items/Items.d.ts +6 -0
- package/dist/types/components/List/components/Items/index.d.ts +3 -0
- package/dist/types/components/List/components/ListFilter.d.ts +5 -0
- package/dist/types/components/List/components/ListItemView.d.ts +6 -0
- package/dist/types/components/List/components/ListLoaderAsync.d.ts +6 -0
- package/dist/types/components/List/components/ListLoaderAsyncResource.d.ts +6 -0
- package/dist/types/components/List/components/ListSorting.d.ts +5 -0
- package/dist/types/components/List/components/ListStaticData.d.ts +5 -0
- package/dist/types/components/List/components/PaginationInfos/PaginationInfos.d.ts +4 -0
- package/dist/types/components/List/components/PaginationInfos/index.d.ts +3 -0
- package/dist/types/components/List/components/ShowMoreItemsButton/ShowMoreItemsButton.d.ts +4 -0
- package/dist/types/components/List/components/ShowMoreItemsButton/index.d.ts +3 -0
- package/dist/types/components/List/hooks/useList.d.ts +1 -0
- package/dist/types/components/List/index.d.ts +8 -0
- package/dist/types/components/List/listContext.d.ts +8 -0
- package/dist/types/components/List/model/List.d.ts +21 -0
- package/dist/types/components/List/model/ReactTable.d.ts +17 -0
- package/dist/types/components/List/model/filter/Filter.d.ts +26 -0
- package/dist/types/components/List/model/filter/types.d.ts +9 -0
- package/dist/types/components/List/model/item/Item.d.ts +14 -0
- package/dist/types/components/List/model/item/ItemCollection.d.ts +8 -0
- package/dist/types/components/List/model/item/types.d.ts +5 -0
- package/dist/types/components/List/model/loading/IncrementalLoader.d.ts +23 -0
- package/dist/types/components/List/model/loading/types.d.ts +43 -0
- package/dist/types/components/List/model/pagination/Pagination.d.ts +16 -0
- package/dist/types/components/List/model/pagination/types.d.ts +3 -0
- package/dist/types/components/List/model/sorting/Sorting.d.ts +12 -0
- package/dist/types/components/List/model/sorting/types.d.ts +4 -0
- package/dist/types/components/List/model/types.d.ts +14 -0
- package/dist/types/components/List/stories/Default.stories.d.ts +6 -0
- package/dist/types/components/List/testData/userApi.d.ts +57 -0
- package/dist/types/lib/react/components/Empty/Empty.d.ts +3 -0
- package/dist/types/lib/react/components/Empty/index.d.ts +3 -0
- package/dist/types/lib/react/components/Render/Render.d.ts +4 -0
- package/dist/types/lib/react/components/Render/Render.test.d.ts +1 -0
- package/dist/types/lib/react/components/Render/index.d.ts +1 -0
- package/dist/types/lib/react/deepFindOfType.d.ts +3 -0
- package/dist/types/lib/react/deepFindOfType.test.d.ts +1 -0
- package/dist/types/lib/react/deepHas.d.ts +2 -0
- package/package.json +24 -3
- package/dist/IconPlus-C2E1lBEu.js +0 -12
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { AnyData } from './model/item/types';
|
|
3
|
+
import { ListShape } from './model/types';
|
|
4
|
+
interface Props extends PropsWithChildren, Pick<ListShape<AnyData>, "enableMultiSort"> {
|
|
5
|
+
}
|
|
6
|
+
export declare function List(props: Props): React.JSX.Element;
|
|
7
|
+
export default List;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { AnyData } from '../../../../model/item/types';
|
|
3
|
+
import { Sorting } from '../../../../model/sorting/Sorting';
|
|
4
|
+
interface Props {
|
|
5
|
+
sorting: Sorting<AnyData>;
|
|
6
|
+
}
|
|
7
|
+
export declare const SortingPickerItem: FC<Props>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AsyncDataLoaderShape } from '../model/loading/types';
|
|
2
|
+
interface Props<T> extends Omit<AsyncDataLoaderShape<T>, "asyncLoader"> {
|
|
3
|
+
children: AsyncDataLoaderShape<T>["asyncLoader"];
|
|
4
|
+
}
|
|
5
|
+
export declare function ListLoaderAsync<T = never>(ignoredProps: Props<T>): null;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AsyncResourceFactoryDataLoaderShape } from '../model/loading/types';
|
|
2
|
+
interface Props<T> extends Omit<AsyncResourceFactoryDataLoaderShape<T>, "asyncResourceFactory"> {
|
|
3
|
+
children: AsyncResourceFactoryDataLoaderShape<T>["asyncResourceFactory"];
|
|
4
|
+
}
|
|
5
|
+
export declare function ListLoaderAsyncResource<T = never>(ignoredProps: Props<T>): null;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useList: () => import("../model/List").List<any>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { List } from "./List";
|
|
2
|
+
export * from "./List";
|
|
3
|
+
export * from "./components/ListFilter";
|
|
4
|
+
export * from "./components/ListSorting";
|
|
5
|
+
export * from "./components/ListItemView";
|
|
6
|
+
export * from "./components/ListLoaderAsync";
|
|
7
|
+
export * from "./components/ListStaticData";
|
|
8
|
+
export default List;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ItemCollection } from './item/ItemCollection';
|
|
2
|
+
import { Pagination } from './pagination/Pagination';
|
|
3
|
+
import { RenderItemFn } from './item/Item';
|
|
4
|
+
import { Filter } from "./filter/Filter";
|
|
5
|
+
import { Sorting } from './sorting/Sorting';
|
|
6
|
+
import ReactTable from './ReactTable';
|
|
7
|
+
import { ListShape } from './types';
|
|
8
|
+
import { IncrementalLoader } from './loading/IncrementalLoader';
|
|
9
|
+
export declare class List<T> {
|
|
10
|
+
readonly filters: Array<Filter<T>>;
|
|
11
|
+
readonly sorting: Array<Sorting<T>>;
|
|
12
|
+
readonly items: ItemCollection<T>;
|
|
13
|
+
readonly render?: RenderItemFn<T>;
|
|
14
|
+
readonly reactTable: ReactTable<T>;
|
|
15
|
+
readonly pagination: Pagination<T>;
|
|
16
|
+
readonly loader: IncrementalLoader<T>;
|
|
17
|
+
private constructor();
|
|
18
|
+
static useNew<T>(shape: ListShape<T>): List<T>;
|
|
19
|
+
isFiltered(): boolean;
|
|
20
|
+
}
|
|
21
|
+
export default List;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Column, Table, TableOptions } from "@tanstack/react-table";
|
|
2
|
+
import List from './List';
|
|
3
|
+
import { PropertyName } from './item/Item';
|
|
4
|
+
export declare class ReactTable<T> {
|
|
5
|
+
readonly list: List<T>;
|
|
6
|
+
readonly table: Table<T>;
|
|
7
|
+
private readonly tableState;
|
|
8
|
+
private constructor();
|
|
9
|
+
static useNew<T>(list: List<T>, tableOptions?: Partial<TableOptions<T>>): ReactTable<T>;
|
|
10
|
+
private useReactTable;
|
|
11
|
+
private useUpdateTableState;
|
|
12
|
+
private onTableStateChange;
|
|
13
|
+
private getUpdatedTableState;
|
|
14
|
+
getTableColumn(property: PropertyName<T>): Column<T>;
|
|
15
|
+
private getTableColumnDefs;
|
|
16
|
+
}
|
|
17
|
+
export default ReactTable;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Column, ColumnDef, ColumnFilter } from "@tanstack/react-table";
|
|
2
|
+
import List from '../List';
|
|
3
|
+
import { PropertyName } from '../item/Item';
|
|
4
|
+
import { FilterMatcher, FilterMode, FilterShape } from './types';
|
|
5
|
+
export declare class Filter<T> {
|
|
6
|
+
private readonly _values?;
|
|
7
|
+
readonly list: List<T>;
|
|
8
|
+
readonly property: PropertyName<T>;
|
|
9
|
+
readonly mode: FilterMode;
|
|
10
|
+
readonly matcher: FilterMatcher;
|
|
11
|
+
private onFilterUpdateCallbacks;
|
|
12
|
+
constructor(list: List<T>, shape: FilterShape<T>);
|
|
13
|
+
updateTableColumnDef(def: ColumnDef<T>): void;
|
|
14
|
+
private getReactTableFilterFn;
|
|
15
|
+
private checkFilterMatches;
|
|
16
|
+
protected getTableColumnFilter(): ColumnFilter | undefined;
|
|
17
|
+
protected getTableColumn(): Column<T>;
|
|
18
|
+
getValue(): unknown;
|
|
19
|
+
getValueId(value: unknown): string;
|
|
20
|
+
get values(): unknown[];
|
|
21
|
+
getArrayValue(): Array<unknown>;
|
|
22
|
+
isValueActive(value: unknown): boolean;
|
|
23
|
+
isActive(): boolean;
|
|
24
|
+
toggleValue(newValue: unknown): void;
|
|
25
|
+
onFilterUpdated(cb: () => unknown): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PropertyName } from '../item/Item';
|
|
2
|
+
export type FilterMode = "all" | "some" | "one";
|
|
3
|
+
export type FilterMatcher = (filterValue: unknown, property: unknown) => boolean;
|
|
4
|
+
export interface FilterShape<T> {
|
|
5
|
+
property: PropertyName<T>;
|
|
6
|
+
mode?: FilterMode;
|
|
7
|
+
matcher?: FilterMatcher;
|
|
8
|
+
values?: unknown[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ItemCollection } from './ItemCollection';
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { DeepKeys, Row } from "@tanstack/react-table";
|
|
4
|
+
export type PropertyName<T> = DeepKeys<T>;
|
|
5
|
+
export type RenderItemFn<T> = (data: T) => ReactNode;
|
|
6
|
+
export declare class Item<T> {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly data: T;
|
|
9
|
+
readonly collection: ItemCollection<T>;
|
|
10
|
+
constructor(collection: ItemCollection<T>, id: string, data: T);
|
|
11
|
+
render(): ReactNode;
|
|
12
|
+
static fromRow<T>(collection: ItemCollection<T>, row: Row<T>): Item<T>;
|
|
13
|
+
private static fallbackRenderItemFn;
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import List from '../List';
|
|
2
|
+
import { IncrementalLoaderShape } from './types';
|
|
3
|
+
export declare class IncrementalLoader<T> {
|
|
4
|
+
private readonly list;
|
|
5
|
+
private readonly dataSource;
|
|
6
|
+
private readonly pagesDataSignal;
|
|
7
|
+
private readonly pagesLoadingStateSignal;
|
|
8
|
+
readonly manualSorting: boolean;
|
|
9
|
+
readonly manualFiltering: boolean;
|
|
10
|
+
readonly manualPagination: boolean;
|
|
11
|
+
constructor(list: List<T>, shape?: IncrementalLoaderShape<T>);
|
|
12
|
+
private reset;
|
|
13
|
+
useIsLoading(): boolean;
|
|
14
|
+
useData(): T[];
|
|
15
|
+
useSuspenseHook(pageIndex: number): void;
|
|
16
|
+
getLoaderInvocationHooks(): Array<() => void>;
|
|
17
|
+
private useLoadPage;
|
|
18
|
+
private getDataLoaderOptions;
|
|
19
|
+
private getPageDataAsyncResource;
|
|
20
|
+
private updatePageData;
|
|
21
|
+
private updatePageLoadingState;
|
|
22
|
+
loadMore(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PropertyRecord } from '../types';
|
|
2
|
+
import { FilterMode } from '../filter/types';
|
|
3
|
+
import { AsyncResource } from "@mittwald/react-use-promise";
|
|
4
|
+
type DataLoaderSortOptions<T> = PropertyRecord<T, "asc" | "desc">;
|
|
5
|
+
type DataLoaderFilterOptions<T> = PropertyRecord<T, {
|
|
6
|
+
mode: FilterMode;
|
|
7
|
+
values: unknown[];
|
|
8
|
+
}>;
|
|
9
|
+
interface DataLoaderPaginationOptions {
|
|
10
|
+
offset: number;
|
|
11
|
+
limit: number;
|
|
12
|
+
}
|
|
13
|
+
export interface DataLoaderOptions<T> {
|
|
14
|
+
sorting?: DataLoaderSortOptions<T>;
|
|
15
|
+
filtering?: DataLoaderFilterOptions<T>;
|
|
16
|
+
pagination?: DataLoaderPaginationOptions;
|
|
17
|
+
}
|
|
18
|
+
export type DataLoaderResult<T> = {
|
|
19
|
+
data: T[];
|
|
20
|
+
itemTotalCount?: number;
|
|
21
|
+
};
|
|
22
|
+
export type AsyncDataLoader<T> = (options?: DataLoaderOptions<T>) => Promise<DataLoaderResult<T>>;
|
|
23
|
+
type AsyncResourceFactory<T> = (options?: DataLoaderOptions<T>) => AsyncResource<DataLoaderResult<T>>;
|
|
24
|
+
type StaticData<T> = T[];
|
|
25
|
+
interface DynamicLoaderShape {
|
|
26
|
+
manualSorting?: boolean;
|
|
27
|
+
manualFiltering?: boolean;
|
|
28
|
+
manualPagination?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface StaticDataLoaderShape<T> {
|
|
31
|
+
staticData: StaticData<T>;
|
|
32
|
+
}
|
|
33
|
+
export type AsyncResourceFactoryDataLoaderShape<T> = {
|
|
34
|
+
asyncResourceFactory: AsyncResourceFactory<T>;
|
|
35
|
+
} & DynamicLoaderShape;
|
|
36
|
+
export type AsyncDataLoaderShape<T> = {
|
|
37
|
+
asyncLoader: AsyncDataLoader<T>;
|
|
38
|
+
} & DynamicLoaderShape;
|
|
39
|
+
export type DataSource<T> = StaticDataLoaderShape<T> | AsyncResourceFactoryDataLoaderShape<T> | AsyncDataLoaderShape<T>;
|
|
40
|
+
export interface IncrementalLoaderShape<T> {
|
|
41
|
+
source?: DataSource<T>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import List from '../List';
|
|
2
|
+
import { PaginationShape } from './types';
|
|
3
|
+
export declare class Pagination<T> {
|
|
4
|
+
private readonly list;
|
|
5
|
+
readonly initialPageSize: number;
|
|
6
|
+
constructor(list: List<T>, shape?: PaginationShape);
|
|
7
|
+
getPageIndex(): number;
|
|
8
|
+
hasNextPage(): boolean;
|
|
9
|
+
nextPage(): void;
|
|
10
|
+
updatePageSize(size: number): void;
|
|
11
|
+
getPageSize(): number;
|
|
12
|
+
getTotalItemsCount(): number | undefined;
|
|
13
|
+
getFilteredItemsCount(): number;
|
|
14
|
+
getVisibleItemsCount(): number | undefined;
|
|
15
|
+
updateItemTotalCount(value: number): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Column, ColumnDef, SortDirection } from "@tanstack/react-table";
|
|
2
|
+
import List from '../List';
|
|
3
|
+
import { PropertyName } from '../item/Item';
|
|
4
|
+
import { SortingShape } from './types';
|
|
5
|
+
export declare class Sorting<T> {
|
|
6
|
+
readonly list: List<T>;
|
|
7
|
+
readonly property: PropertyName<T>;
|
|
8
|
+
constructor(list: List<T>, shape: SortingShape<T>);
|
|
9
|
+
updateTableColumnDef(def: ColumnDef<T>): void;
|
|
10
|
+
get direction(): SortDirection | false;
|
|
11
|
+
getTableColumn(): Column<T>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PropertyName, RenderItemFn } from './item/Item';
|
|
2
|
+
import { SortingShape } from './sorting/types';
|
|
3
|
+
import { PaginationShape } from './pagination/types';
|
|
4
|
+
import { FilterShape } from './filter/types';
|
|
5
|
+
import { IncrementalLoaderShape } from './loading/types';
|
|
6
|
+
export interface ListShape<T> {
|
|
7
|
+
loader?: IncrementalLoaderShape<T>;
|
|
8
|
+
render?: RenderItemFn<T>;
|
|
9
|
+
filters?: FilterShape<T>[];
|
|
10
|
+
sorting?: SortingShape<T>[];
|
|
11
|
+
pagination?: PaginationShape;
|
|
12
|
+
enableMultiSort?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type PropertyRecord<T, TValue> = Partial<Record<PropertyName<T>, TValue>>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type User = (typeof users)[number];
|
|
2
|
+
export declare const getStates: () => Promise<string[]>;
|
|
3
|
+
interface Request {
|
|
4
|
+
pagination?: {
|
|
5
|
+
limit: number;
|
|
6
|
+
skip: number;
|
|
7
|
+
};
|
|
8
|
+
filter?: {
|
|
9
|
+
states?: string[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface Response {
|
|
13
|
+
data: User[];
|
|
14
|
+
totalCount: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const getUsers: (req: Request) => Promise<Response>;
|
|
17
|
+
export declare const users: {
|
|
18
|
+
status: string;
|
|
19
|
+
name: {
|
|
20
|
+
first: string;
|
|
21
|
+
middle: string;
|
|
22
|
+
last: string;
|
|
23
|
+
};
|
|
24
|
+
username: string;
|
|
25
|
+
password: string;
|
|
26
|
+
emails: string[];
|
|
27
|
+
phoneNumber: string;
|
|
28
|
+
location: {
|
|
29
|
+
street: string;
|
|
30
|
+
city: string;
|
|
31
|
+
state: string;
|
|
32
|
+
country: string;
|
|
33
|
+
zip: string;
|
|
34
|
+
coordinates: {
|
|
35
|
+
latitude: number;
|
|
36
|
+
longitude: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
website: string;
|
|
40
|
+
domain: string;
|
|
41
|
+
job: {
|
|
42
|
+
title: string;
|
|
43
|
+
descriptor: string;
|
|
44
|
+
area: string;
|
|
45
|
+
type: string;
|
|
46
|
+
company: string;
|
|
47
|
+
};
|
|
48
|
+
creditCard: {
|
|
49
|
+
number: string;
|
|
50
|
+
cvv: string;
|
|
51
|
+
issuer: string;
|
|
52
|
+
};
|
|
53
|
+
uuid: string;
|
|
54
|
+
objectId: string;
|
|
55
|
+
}[];
|
|
56
|
+
export declare const states: string[];
|
|
57
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Render";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ComponentProps, ElementType, FunctionComponentElement, ReactNode } from "react";
|
|
2
|
+
export declare const deepFindOfType: <T extends ElementType>(children: ReactNode, searchType: T) => FunctionComponentElement<ComponentProps<T>> | undefined;
|
|
3
|
+
export declare const deepFilterByType: <T extends ElementType>(children: ReactNode, searchType: T) => Array<FunctionComponentElement<ComponentProps<T>>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|