@mittwald/flow-react-components 0.1.0-alpha.173 → 0.1.0-alpha.175

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.
Files changed (27) hide show
  1. package/dist/List/ListLoaderAsyncResource.js +3 -4
  2. package/dist/List.js +275 -273
  3. package/dist/styles.css +1 -1
  4. package/dist/types/components/List/components/Header/FilterPicker/FilterPicker.d.ts +1 -2
  5. package/dist/types/components/List/components/Header/ListFilter.d.ts +6 -3
  6. package/dist/types/components/List/components/Header/ListSorting.d.ts +4 -4
  7. package/dist/types/components/List/components/Header/SortingPickerItem/SortingPickerItem.d.ts +1 -2
  8. package/dist/types/components/List/components/Items/ListItem/FallbackRenderer.d.ts +1 -2
  9. package/dist/types/components/List/components/Items/ListItemView.d.ts +6 -4
  10. package/dist/types/components/List/components/ListLoaderAsync.d.ts +5 -3
  11. package/dist/types/components/List/components/ListLoaderAsyncResource.d.ts +5 -3
  12. package/dist/types/components/List/components/ListStaticData.d.ts +6 -3
  13. package/dist/types/components/List/hooks/useList.d.ts +1 -1
  14. package/dist/types/components/List/index.d.ts +1 -0
  15. package/dist/types/components/List/listContext.d.ts +1 -2
  16. package/dist/types/components/List/model/List.d.ts +3 -3
  17. package/dist/types/components/List/model/ReactTable.d.ts +1 -1
  18. package/dist/types/components/List/model/filter/Filter.d.ts +4 -4
  19. package/dist/types/components/List/model/filter/types.d.ts +8 -6
  20. package/dist/types/components/List/model/item/Item.d.ts +1 -3
  21. package/dist/types/components/List/model/item/types.d.ts +3 -5
  22. package/dist/types/components/List/model/sorting/Sorting.d.ts +2 -1
  23. package/dist/types/components/List/model/sorting/types.d.ts +1 -1
  24. package/dist/types/components/List/model/types.d.ts +5 -2
  25. package/dist/types/components/List/typedList.d.ts +25 -0
  26. package/dist/types/lib/types/array.d.ts +1 -0
  27. package/package.json +4 -4
@@ -1,9 +1,8 @@
1
1
  import { FC } from 'react';
2
2
  import { Filter } from '../../../model/filter/Filter';
3
- import { AnyData } from '../../../model/item/types';
4
3
 
5
4
  interface Props {
6
- filter: Filter<AnyData>;
5
+ filter: Filter<never, never, never>;
7
6
  }
8
7
  export declare const FilterPicker: FC<Props>;
9
8
  export {};
@@ -1,5 +1,8 @@
1
- import { FilterShape } from '../../model/filter/types';
1
+ import { FilterShape, FilterValue } from '../../model/filter/types';
2
+ import { ReactNode } from 'react';
3
+ import { PropertyName } from '../../model/types';
2
4
 
3
- type Props<T> = Omit<FilterShape<T>, "type">;
4
- export declare function ListFilter<T = never>(ignoredProps: Props<T>): null;
5
+ type Props<T, TProp extends PropertyName<T>, TMatcherValue> = Omit<FilterShape<T, TProp, TMatcherValue>, "type">;
6
+ export declare const ListFilter: <T, const TProp extends PropertyName<T> = PropertyName<T>, TMatcherValue = FilterValue<T, TProp>>(ignoredProps: Props<T, TProp, TMatcherValue>) => null;
7
+ export declare const TypedListFilter: <T>() => <const TProp extends PropertyName<T>, TMatcherValue = FilterValue<T, TProp>>(props: Props<T, TProp, TMatcherValue>) => ReactNode;
5
8
  export {};
@@ -1,7 +1,7 @@
1
1
  import { SortingShape } from '../../model/sorting/types';
2
+ import { ComponentType } from 'react';
2
3
 
3
- interface Props<T> extends SortingShape<T> {
4
- defaultEnabled?: boolean;
5
- }
6
- export declare function ListSorting<T = never>(ignoredProps: Props<T>): null;
4
+ type Props<T> = SortingShape<T>;
5
+ export declare const ListSorting: <T>(ignoredProps: Props<T>) => null;
6
+ export declare const TypedListSorting: <T>() => ComponentType<Props<T>>;
7
7
  export {};
@@ -1,9 +1,8 @@
1
1
  import { FC } from 'react';
2
- import { AnyData } from '../../../model/item/types';
3
2
  import { Sorting } from '../../../model/sorting/Sorting';
4
3
 
5
4
  interface Props {
6
- sorting: Sorting<AnyData>;
5
+ sorting: Sorting<never>;
7
6
  }
8
7
  export declare const SortingPickerItem: FC<Props>;
9
8
  export {};
@@ -1,8 +1,7 @@
1
- import { AnyData } from '../../../model/item/types';
2
1
  import { FC } from 'react';
3
2
 
4
3
  interface Props {
5
- data: AnyData;
4
+ data: unknown;
6
5
  }
7
6
  export declare const FallbackRenderer: FC<Props>;
8
7
  export {};
@@ -1,7 +1,9 @@
1
- import { RenderItemFn } from '../../model/item/Item';
1
+ import { ComponentType } from 'react';
2
+ import { RenderItemFn } from '../../model/item/types';
2
3
 
3
- interface Props<T> {
4
+ type Props<T> = {} & {
4
5
  children: RenderItemFn<T>;
5
- }
6
- export declare function ListItemView<T = never>(ignoredProps: Props<T>): null;
6
+ };
7
+ export declare const ListItemView: <T>(ignoredProps: Props<T>) => null;
8
+ export declare const TypedListItemView: <T>() => ComponentType<Props<T>>;
7
9
  export {};
@@ -1,7 +1,9 @@
1
1
  import { AsyncDataLoaderShape } from '../model/loading/types';
2
+ import { ComponentType } from 'react';
2
3
 
3
- interface Props<T> extends Omit<AsyncDataLoaderShape<T>, "asyncLoader"> {
4
+ type Props<T> = Omit<AsyncDataLoaderShape<T>, "asyncLoader"> & {
4
5
  children: AsyncDataLoaderShape<T>["asyncLoader"];
5
- }
6
- export declare function ListLoaderAsync<T = never>(ignoredProps: Props<T>): null;
6
+ };
7
+ export declare const ListLoaderAsync: <T>(ignoredProps: Props<T>) => null;
8
+ export declare const TypedListLoaderAsync: <T>() => ComponentType<Props<T>>;
7
9
  export {};
@@ -1,7 +1,9 @@
1
1
  import { AsyncResourceFactoryDataLoaderShape } from '../model/loading/types';
2
+ import { ComponentType } from 'react';
2
3
 
3
- interface Props<T> extends Omit<AsyncResourceFactoryDataLoaderShape<T>, "asyncResourceFactory"> {
4
+ type Props<T> = Omit<AsyncResourceFactoryDataLoaderShape<T>, "asyncResourceFactory"> & {
4
5
  children: AsyncResourceFactoryDataLoaderShape<T>["asyncResourceFactory"];
5
- }
6
- export declare function ListLoaderAsyncResource<T = never>(ignoredProps: Props<T>): null;
6
+ };
7
+ export declare const ListLoaderAsyncResource: <T>(ignoredProps: Props<T>) => null;
8
+ export declare const TypedListLoaderAsyncResource: <T>() => ComponentType<Props<T>>;
7
9
  export {};
@@ -1,5 +1,8 @@
1
- interface Props<T> {
1
+ import { ComponentType } from 'react';
2
+
3
+ type Props<T> = {} & {
2
4
  data: T[];
3
- }
4
- export declare function ListStaticData<T = never>(ignoredProps: Props<T>): null;
5
+ };
6
+ export declare const ListStaticData: <T>(ignoredProps: Props<T>) => null;
7
+ export declare const TypedListStaticData: <T>() => ComponentType<Props<T>>;
5
8
  export {};
@@ -1 +1 @@
1
- export declare const useList: () => import('../model/List').List<any>;
1
+ export declare const useList: () => import('../model/List').List<never>;
@@ -1,6 +1,7 @@
1
1
  import { List } from './List';
2
2
 
3
3
  export * from './List';
4
+ export * from './typedList';
4
5
  export * from './components/Header/ListFilter';
5
6
  export * from './components/Header/ListSorting';
6
7
  export * from './components/Items/ListItemView';
@@ -1,8 +1,7 @@
1
1
  import { default as List } from './model/List';
2
- import { AnyData } from './model/item/types';
3
2
 
4
3
  interface ListContext {
5
- list: List<AnyData>;
4
+ list: List<never>;
6
5
  }
7
6
  export declare const listContext: import('react').Context<ListContext>;
8
7
  export {};
@@ -1,14 +1,14 @@
1
1
  import { ItemCollection } from './item/ItemCollection';
2
2
  import { BatchesController } from './pagination/BatchesController';
3
- import { PropertyName, RenderItemFn } from './item/Item';
4
3
  import { Filter } from './filter/Filter';
5
4
  import { Sorting } from './sorting/Sorting';
6
5
  import { default as ReactTable } from './ReactTable';
7
6
  import { ListShape } from './types';
8
7
  import { IncrementalLoader } from './loading/IncrementalLoader';
8
+ import { RenderItemFn } from './item/types';
9
9
 
10
10
  export declare class List<T> {
11
- readonly filters: Filter<T>[];
11
+ readonly filters: Filter<T, never, never>[];
12
12
  readonly sorting: Sorting<T>[];
13
13
  readonly items: ItemCollection<T>;
14
14
  readonly render?: RenderItemFn<T>;
@@ -18,7 +18,7 @@ export declare class List<T> {
18
18
  private constructor();
19
19
  static useNew<T>(shape: ListShape<T>): List<T>;
20
20
  isFiltered(): boolean;
21
- getSorting(property: PropertyName<T>): Sorting<T>;
21
+ getSorting(id: string): Sorting<T>;
22
22
  clearSorting(): void;
23
23
  clearFilters(): void;
24
24
  useIsEmpty(): boolean;
@@ -1,6 +1,6 @@
1
1
  import { Column, Table, TableOptions } from '@tanstack/react-table';
2
2
  import { default as List } from './List';
3
- import { PropertyName } from './item/Item';
3
+ import { PropertyName } from './types';
4
4
 
5
5
  export declare class ReactTable<T> {
6
6
  readonly list: List<T>;
@@ -1,17 +1,17 @@
1
1
  import { Column, ColumnDef, ColumnFilter } from '@tanstack/react-table';
2
2
  import { default as List } from '../List';
3
- import { PropertyName } from '../item/Item';
4
3
  import { FilterMatcher, FilterMode, FilterShape } from './types';
4
+ import { PropertyName } from '../types';
5
5
 
6
- export declare class Filter<T> {
6
+ export declare class Filter<T, TProp extends PropertyName<T>, TMatchValue> {
7
7
  private readonly _values?;
8
8
  readonly list: List<T>;
9
9
  readonly property: PropertyName<T>;
10
10
  readonly mode: FilterMode;
11
- readonly matcher: FilterMatcher;
11
+ readonly matcher: FilterMatcher<T, never, never>;
12
12
  readonly name?: string;
13
13
  private onFilterUpdateCallbacks;
14
- constructor(list: List<T>, shape: FilterShape<T>);
14
+ constructor(list: List<T>, shape: FilterShape<T, TProp, TMatchValue>);
15
15
  updateTableColumnDef(def: ColumnDef<T>): void;
16
16
  private getReactTableFilterFn;
17
17
  private checkFilterMatches;
@@ -1,11 +1,13 @@
1
- import { PropertyName } from '../item/Item';
1
+ import { ItemType } from '../../../../lib/types/array';
2
+ import { PropertyName, PropertyValue } from '../types';
2
3
 
3
4
  export type FilterMode = "all" | "some" | "one";
4
- export type FilterMatcher = (filterValue: unknown, property: unknown) => boolean;
5
- export interface FilterShape<T> {
6
- property: PropertyName<T>;
5
+ export type FilterValue<T, P> = ItemType<NonNullable<PropertyValue<T, P>>>;
6
+ export type FilterMatcher<T, P, TMatcherValue> = (filterBy: FilterValue<T, P>, filterFrom: TMatcherValue[]) => boolean;
7
+ export interface FilterShape<T, TProp extends PropertyName<T>, TMatcherValue> {
8
+ property: TProp;
7
9
  mode?: FilterMode;
8
- matcher?: FilterMatcher;
9
- values?: unknown[];
10
+ matcher?: FilterMatcher<T, TProp, TMatcherValue>;
11
+ values?: TMatcherValue[];
10
12
  name?: string;
11
13
  }
@@ -1,9 +1,7 @@
1
1
  import { ItemCollection } from './ItemCollection';
2
2
  import { ReactNode } from 'react';
3
- import { DeepKeys, Row } from '@tanstack/react-table';
3
+ import { Row } from '@tanstack/react-table';
4
4
 
5
- export type PropertyName<T> = DeepKeys<T>;
6
- export type RenderItemFn<T> = (data: T) => ReactNode;
7
5
  export declare class Item<T> {
8
6
  readonly id: string;
9
7
  readonly data: T;
@@ -1,5 +1,3 @@
1
- export type AnyData = any;
2
- export interface ListDataLoaderResult<T> {
3
- data: T[];
4
- itemTotalCount?: number;
5
- }
1
+ import { ReactNode } from 'react';
2
+
3
+ export type RenderItemFn<T> = (data: T) => ReactNode;
@@ -1,7 +1,7 @@
1
1
  import { Column, ColumnDef, SortDirection } from '@tanstack/react-table';
2
2
  import { default as List } from '../List';
3
- import { PropertyName } from '../item/Item';
4
3
  import { SortingShape } from './types';
4
+ import { PropertyName } from '../types';
5
5
 
6
6
  export declare class Sorting<T> {
7
7
  readonly list: List<T>;
@@ -15,4 +15,5 @@ export declare class Sorting<T> {
15
15
  getTableColumn(): Column<T>;
16
16
  enable(): void;
17
17
  clear(): void;
18
+ get id(): string;
18
19
  }
@@ -1,5 +1,5 @@
1
- import { PropertyName } from '../item/Item';
2
1
  import { SortDirection } from '@tanstack/react-table';
2
+ import { PropertyName } from '../types';
3
3
 
4
4
  export interface SortingShape<T> {
5
5
  property: PropertyName<T>;
@@ -1,13 +1,16 @@
1
- import { PropertyName, RenderItemFn } from './item/Item';
1
+ import { DeepKeys, DeepValue } from '@tanstack/react-table';
2
2
  import { SortingShape } from './sorting/types';
3
3
  import { BatchesControllerShape } from './pagination/types';
4
4
  import { FilterShape } from './filter/types';
5
5
  import { IncrementalLoaderShape } from './loading/types';
6
+ import { RenderItemFn } from './item/types';
6
7
 
8
+ export type PropertyName<T> = never extends T ? string : DeepKeys<T>;
9
+ export type PropertyValue<T, TProp> = DeepValue<T, TProp>;
7
10
  export interface ListShape<T> {
8
11
  loader?: IncrementalLoaderShape<T>;
9
12
  render?: RenderItemFn<T>;
10
- filters?: FilterShape<T>[];
13
+ filters?: FilterShape<T, never, never>[];
11
14
  sorting?: SortingShape<T>[];
12
15
  batchesController?: BatchesControllerShape;
13
16
  }
@@ -0,0 +1,25 @@
1
+ import { default as List } from './List';
2
+
3
+ export declare const typedList: <T>() => {
4
+ List: typeof List;
5
+ Filter: <const TProp extends import('./model/types').PropertyName<T>, TMatcherValue = import('../../lib/types/array').ItemType<NonNullable<import('@tanstack/table-core').DeepValue<T, TProp>>>>(props: {
6
+ name?: string;
7
+ property: TProp;
8
+ mode?: import('./model/filter/types').FilterMode;
9
+ values?: TMatcherValue[] | undefined;
10
+ matcher?: import('./model/filter/types').FilterMatcher<T, TProp, TMatcherValue> | undefined;
11
+ }) => import('react').ReactNode;
12
+ Sorting: import('react').ComponentType<import('./model/sorting/types').SortingShape<T>>;
13
+ ItemView: import('react').ComponentType<{
14
+ children: import('./model/item/types').RenderItemFn<T>;
15
+ }>;
16
+ StaticData: import('react').ComponentType<{
17
+ data: T[];
18
+ }>;
19
+ LoaderAsync: import('react').ComponentType<Omit<import('./model/loading/types').AsyncDataLoaderShape<T>, "asyncLoader"> & {
20
+ children: import('./model/loading/types').AsyncDataLoader<T>;
21
+ }>;
22
+ LoaderAsyncResource: import('react').ComponentType<Omit<import('./model/loading/types').AsyncResourceFactoryDataLoaderShape<T>, "asyncResourceFactory"> & {
23
+ children: (options?: import('./model/loading/types').DataLoaderOptions<T> | undefined) => import('@mittwald/react-use-promise').AsyncResource<import('./model/loading/types').DataLoaderResult<T>>;
24
+ }>;
25
+ };
@@ -0,0 +1 @@
1
+ export type ItemType<T> = T extends (infer TItem)[] ? TItem : T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-react-components",
3
- "version": "0.1.0-alpha.173",
3
+ "version": "0.1.0-alpha.175",
4
4
  "type": "module",
5
5
  "description": "A React implementation of Flow, mittwald’s design system",
6
6
  "homepage": "https://mittwald.github.io/flow",
@@ -280,7 +280,7 @@
280
280
  "dependencies": {
281
281
  "@chakra-ui/live-region": "^2.1.0",
282
282
  "@internationalized/string-compiler": "^3.2.4",
283
- "@mittwald/react-tunnel": "^0.1.0-alpha.173",
283
+ "@mittwald/react-tunnel": "^0.1.0-alpha.175",
284
284
  "@mittwald/react-use-promise": "^2.3.13",
285
285
  "@react-aria/utils": "^3.24.1",
286
286
  "@react-types/shared": "^3.23.1",
@@ -307,7 +307,7 @@
307
307
  },
308
308
  "devDependencies": {
309
309
  "@faker-js/faker": "^8.4.1",
310
- "@mittwald/flow-design-tokens": "^0.1.0-alpha.173",
310
+ "@mittwald/flow-design-tokens": "^0.1.0-alpha.175",
311
311
  "@mittwald/react-use-promise": "^2.3.13",
312
312
  "@nx/storybook": "^19.4.0",
313
313
  "@storybook/addon-a11y": "^8.1.11",
@@ -383,5 +383,5 @@
383
383
  "optional": true
384
384
  }
385
385
  },
386
- "gitHead": "382ff60cf43672d7d822a503da4d7a61b775314c"
386
+ "gitHead": "d574568700b63fa336578f7ac2454fdd3add2720"
387
387
  }