Skip to content

Commit

Permalink
Merge pull request #680 from contember/feat/grid-filters
Browse files Browse the repository at this point in the history
headless improvements
  • Loading branch information
matej21 committed Mar 25, 2024
2 parents 1c24943 + af5ff08 commit 879d01e
Show file tree
Hide file tree
Showing 105 changed files with 3,001 additions and 968 deletions.
17 changes: 16 additions & 1 deletion build/api/binding.api.md
Expand Up @@ -4,6 +4,8 @@
```ts

import { ContentEntitySelection } from '@contember/client';
import { ContentQuery } from '@contember/client';
import { ContentQueryBuilder } from '@contember/client';
import type { CrudQueryBuilder } from '@contember/client';
import { EmbeddedActionsParser } from 'chevrotain';
Expand Down Expand Up @@ -319,7 +321,7 @@ export class EntityListAccessor implements Errorable {
[Symbol.iterator](): IterableIterator<EntityAccessor>;
// Warning: (ae-forgotten-export) The symbol "EntityListState" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "ListOperations" needs to be exported by the entry point index.d.ts
constructor(state: EntityListState, operations: ListOperations, _children: ReadonlyMap<EntityId, {
constructor(state: EntityListState, operations: ListOperations, name: EntityName, _children: ReadonlyMap<EntityId, {
getAccessor: EntityAccessor.GetEntityAccessor;
}>, _idsPersistedOnServer: ReadonlySet<EntityId>, hasUnpersistedChanges: boolean, errors: ErrorAccessor | undefined, environment: Environment, getAccessor: EntityListAccessor.GetEntityListAccessor);
// (undocumented)
Expand Down Expand Up @@ -357,6 +359,8 @@ export class EntityListAccessor implements Errorable {
// (undocumented)
getChildEntityById(id: EntityId): EntityAccessor;
// (undocumented)
getMarker(): EntityListSubTreeMarker | HasManyRelationMarker;
// (undocumented)
getParent(): EntityAccessor | undefined;
// (undocumented)
hasEntityId(id: EntityId): boolean;
Expand All @@ -372,6 +376,8 @@ export class EntityListAccessor implements Errorable {
keys(): IterableIterator<EntityRealmKey>;
// (undocumented)
get length(): number;
// (undocumented)
readonly name: EntityName;
}

// @public (undocumented)
Expand Down Expand Up @@ -1339,6 +1345,15 @@ export interface QualifiedSingleEntityParameters {
where: UniqueWhere;
}

// @public (undocumented)
export class QueryGenerator {
constructor(tree: MarkerTreeRoot, qb: ContentQueryBuilder);
// (undocumented)
getReadQuery(): Record<string, ContentQuery<any>>;
// (undocumented)
static registerQueryPart(fields: EntityFieldMarkers, selection: ContentEntitySelection): ContentEntitySelection;
}

// @public (undocumented)
export class QueryLanguage {
// (undocumented)
Expand Down
3 changes: 1 addition & 2 deletions build/api/react-datagrid-ui.api.md
Expand Up @@ -8,7 +8,6 @@ import { BooleanCellRendererProps } from '@contember/react-datagrid';
import { BooleanFilterArtifacts } from '@contember/react-dataview';
import { CoalesceCellRendererProps } from '@contember/react-datagrid';
import { CoalesceFieldViewProps } from '@contember/react-binding-ui';
import { CoalesceTextFilterArtifacts } from '@contember/react-dataview';
import { ComponentType } from 'react';
import { DataGridColumnCommonProps } from '@contember/react-datagrid';
import { DataGridColumnProps } from '@contember/react-datagrid';
Expand Down Expand Up @@ -68,7 +67,7 @@ export const BooleanCellFilter: ({ setFilter, filter }: FilterRendererProps<Bool

// @public
export const CoalesceTextCell: FunctionComponent<DataGridColumnCommonProps & CoalesceCellRendererProps & {
initialFilter?: CoalesceTextFilterArtifacts | undefined;
initialFilter?: TextFilterArtifacts | undefined;
} & DataGridCellPublicProps & DataGridHeaderCellPublicProps & CoalesceFieldViewProps<FieldValue>>;

// @public
Expand Down
9 changes: 4 additions & 5 deletions build/api/react-datagrid.api.md
Expand Up @@ -6,7 +6,6 @@

import { BaseDynamicChoiceField } from '@contember/react-choice-field';
import { BooleanFilterArtifacts } from '@contember/react-dataview';
import { CoalesceTextFilterArtifacts } from '@contember/react-dataview';
import { ComponentType } from 'react';
import { DataViewFilterArtifact } from '@contember/react-dataview';
import { DataViewFilterHandler } from '@contember/react-dataview';
Expand Down Expand Up @@ -48,12 +47,12 @@ export type BooleanCellRendererProps = {
// @public (undocumented)
export type CoalesceCellRendererProps = {
fields: (SugarableRelativeSingleField | string)[];
initialFilter?: CoalesceTextFilterArtifacts;
initialFilter?: TextFilterArtifacts;
};

// @public (undocumented)
export type CoalesceTextCellProps = DataGridColumnCommonProps & CoalesceCellRendererProps & {
initialFilter?: CoalesceTextFilterArtifacts;
initialFilter?: TextFilterArtifacts;
};

// @public (undocumented)
Expand All @@ -76,10 +75,10 @@ export const createBooleanCell: <ColumnProps extends {}, ValueRendererProps exte

// @public (undocumented)
export const createCoalesceTextCell: <ColumnProps extends {}, ValueRendererProps extends {}>({ FilterRenderer, ValueRenderer }: {
FilterRenderer: ComponentType<FilterRendererProps<CoalesceTextFilterArtifacts>>;
FilterRenderer: ComponentType<FilterRendererProps<TextFilterArtifacts>>;
ValueRenderer: ComponentType<CoalesceCellRendererProps & ValueRendererProps>;
}) => FunctionComponent<DataGridColumnCommonProps & CoalesceCellRendererProps & {
initialFilter?: CoalesceTextFilterArtifacts | undefined;
initialFilter?: TextFilterArtifacts | undefined;
} & ColumnProps & ValueRendererProps>;

// @public (undocumented)
Expand Down
128 changes: 116 additions & 12 deletions build/api/react-dataview.api.md
Expand Up @@ -5,16 +5,22 @@
```ts

import { ChangeEvent } from 'react';
import { ChildrenAnalyzer } from '@contember/react-multipass-rendering';
import { EntityAccessor } from '@contember/react-binding';
import { EntityAccessor as EntityAccessor_2 } from '@contember/binding';
import { EntityId } from '@contember/react-binding';
import { EntityId as EntityId_2 } from '@contember/binding';
import { EntityListAccessor } from '@contember/binding';
import { EntityListSubTreeLoaderState } from '@contember/react-binding';
import { EntityListSubTreeMarker } from '@contember/binding';
import { EntityListSubTreeMarker as EntityListSubTreeMarker_2 } from '@contember/react-binding';
import { Environment } from '@contember/react-binding';
import { Environment as Environment_2 } from '@contember/binding';
import { FieldMarker } from '@contember/binding';
import { Filter } from '@contember/binding';
import { ForwardRefExoticComponent } from 'react';
import { HasManyRelationMarker } from '@contember/binding';
import { HasOneRelationMarker } from '@contember/binding';
import { Input } from '@contember/client';
import { JSX as JSX_2 } from 'react/jsx-runtime';
import { JSXElementConstructor } from 'react';
Expand All @@ -28,6 +34,7 @@ import { ReactNode } from 'react';
import { RefAttributes } from 'react';
import { Serializable } from '@contember/react-utils';
import { SetStateAction } from 'react';
import { StateStorageOrName } from '@contember/react-utils';
import { SugaredOrderBy } from '@contember/binding';
import { SugaredQualifiedEntityList } from '@contember/binding';
import { SugaredRelativeEntityList } from '@contember/binding';
Expand All @@ -42,12 +49,6 @@ export type BooleanFilterArtifacts = {
nullCondition?: boolean;
};

// @public (undocumented)
export type CoalesceTextFilterArtifacts = {
mode?: 'matches' | 'matchesExactly' | 'startsWith' | 'endsWith' | 'doesNotMatch';
query?: string;
};

// @public (undocumented)
export const ControlledDataView: NamedExoticComponent< {
children: ReactNode;
Expand All @@ -69,9 +70,6 @@ export type ControlledDataViewProps = {
// @public (undocumented)
export const createBooleanFilter: (field: SugaredRelativeSingleField['field']) => DataViewFilterHandler<BooleanFilterArtifacts>;

// @public (undocumented)
export const createCoalesceFilter: (fields: SugaredRelativeSingleField['field'][]) => DataViewFilterHandler<TextFilterArtifacts>;

// @public (undocumented)
export const createDateFilter: (field: SugaredRelativeSingleField['field']) => DataViewFilterHandler<DateRangeFilterArtifacts>;

Expand All @@ -96,6 +94,27 @@ export const createNumberRangeFilter: (field: SugaredRelativeSingleField['field'
// @public (undocumented)
export const createTextFilter: (field: SugaredRelativeSingleField['field']) => DataViewFilterHandler<TextFilterArtifacts>;

// @public (undocumented)
export const createUnionTextFilter: (fields: SugaredRelativeSingleField['field'][]) => DataViewFilterHandler<TextFilterArtifacts>;

// @public (undocumented)
export class CsvExportFactory implements ExportFactory {
// (undocumented)
create(args: ExportFormatterCreateOutputArgs): ExportResult;
// (undocumented)
protected createData(data: DataViewDataForExport): string[][];
// (undocumented)
protected createHeader(data: DataViewDataForExport): string[];
// (undocumented)
protected filterData(data: DataViewDataForExport): DataViewDataForExport;
// (undocumented)
protected flattenData(data: any[], marker: EntityListSubTreeMarker | HasOneRelationMarker | HasManyRelationMarker): DataViewDataForExport;
// (undocumented)
protected formatOutput(data: DataViewDataForExport): string;
// (undocumented)
protected formatValue(value: any): string;
}

// @public (undocumented)
const DataView_2: NamedExoticComponent<DataViewProps>;
export { DataView_2 as DataView }
Expand Down Expand Up @@ -125,6 +144,12 @@ export interface DataViewChangePageTriggerProps {
// @internal (undocumented)
export const DataViewCurrentKeyContext: React_2.Context<string>;

// @public (undocumented)
export type DataViewDataForExport = {
markerPath: (EntityListSubTreeMarker | HasOneRelationMarker | HasManyRelationMarker | FieldMarker)[];
values: any[];
}[];

// @public (undocumented)
export const DataViewDateFilterInput: ({ name, type, ...props }: {
name: string;
Expand Down Expand Up @@ -191,6 +216,27 @@ export const DataViewEnumFilterTrigger: ({ name, action, value, ...props }: {
action?: DataViewSetEnumFilterAction | undefined;
}) => JSX_2.Element;

// @public (undocumented)
export const DataViewExportTrigger: ({ fields, children, baseName, exportFactory }: DataViewExportTriggerProps) => JSX_2.Element;

// @public (undocumented)
export interface DataViewExportTriggerProps {
// (undocumented)
baseName?: string;
// (undocumented)
children: ReactElement;
// (undocumented)
exportFactory?: ExportFactory;
// (undocumented)
fields: ReactNode;
}

// @public (undocumented)
export const DataViewFilter: ({}: DataViewFilterProps) => never;

// @public (undocumented)
export const dataViewFilterAnalyzer: ChildrenAnalyzer<DataViewFilterProps, never, Environment_2<Environment_2.AnyNode | undefined>>;

// @public (undocumented)
export type DataViewFilterArtifact = Serializable;

Expand Down Expand Up @@ -224,21 +270,39 @@ export const DataViewFilteringMethodsContext: React_2.Context<DataViewFilteringM
export type DataViewFilteringProps = {
filterTypes?: DataViewFilterHandlerRegistry;
initialFilters?: DataViewFilteringArtifacts | ((stored: DataViewFilteringArtifacts) => DataViewFilteringArtifacts);
filteringStateStorage?: StateStorageOrName;
};

// @public (undocumented)
export type DataViewFilteringState = {
artifact: DataViewFilteringArtifacts;
filter: Filter;
filter: Filter<never>;
filterTypes: DataViewFilterHandlerRegistry;
};

// @internal (undocumented)
export const DataViewFilteringStateContext: React_2.Context<DataViewFilteringState>;

// @public (undocumented)
export type DataViewFilterProps = {
name: string;
filterHandler: DataViewFilterHandler<any>;
};

// @internal (undocumented)
export const DataViewGlobalKeyContext: React_2.Context<string>;

// @public (undocumented)
export const DataViewHasFilterType: ({ name, children }: DataViewHasFilterTypeProps) => JSX_2.Element | null;

// @public (undocumented)
export interface DataViewHasFilterTypeProps {
// (undocumented)
children: React.ReactNode;
// (undocumented)
name: string;
}

// @public (undocumented)
export const DataViewHasSelection: NamedExoticComponent<DataViewHasSelectionProps>;

Expand Down Expand Up @@ -358,8 +422,12 @@ export const DataViewPagingMethodsContext: React_2.Context<DataViewPagingMethods

// @public (undocumented)
export interface DataViewPagingProps {
// (undocumented)
currentPageStateStorage?: StateStorageOrName;
// (undocumented)
initialItemsPerPage?: number | null;
// (undocumented)
pagingSettingsStorage?: StateStorageOrName;
}

// @public (undocumented)
Expand Down Expand Up @@ -428,6 +496,7 @@ export const DataViewSelectionMethodsContext: React_2.Context<DataViewSelectionM
export type DataViewSelectionProps = {
initialSelection?: DataViewSelectionValues | ((stored: DataViewSelectionValues) => DataViewSelectionValues);
selectionFallback?: DataViewSelectionValue;
selectionStateStorage?: StateStorageOrName;
};

// @public (undocumented)
Expand Down Expand Up @@ -523,6 +592,7 @@ export const DataViewSortingMethodsContext: React_2.Context<DataViewSortingMetho
// @public (undocumented)
export type DataViewSortingProps = {
initialSorting?: DataViewSortingDirections;
sortingStateStorage?: StateStorageOrName;
};

// @public (undocumented)
Expand Down Expand Up @@ -575,8 +645,9 @@ export type DataViewState = {
};

// @public (undocumented)
export const DataViewTextFilterInput: ({ name, ...props }: {
export const DataViewTextFilterInput: ({ name, debounceMs, ...props }: {
name: string;
debounceMs?: number | undefined;
children: ReactElement;
}) => JSX_2.Element;

Expand Down Expand Up @@ -622,6 +693,28 @@ export type EnumFilterArtifacts = {
nullCondition?: boolean;
};

// @public (undocumented)
export interface ExportFactory {
// (undocumented)
create(args: ExportFormatterCreateOutputArgs): ExportResult;
}

// @public (undocumented)
export interface ExportFormatterCreateOutputArgs {
// (undocumented)
data: any[];
// (undocumented)
marker: EntityListSubTreeMarker | HasOneRelationMarker | HasManyRelationMarker;
}

// @public (undocumented)
export interface ExportResult {
// (undocumented)
blob: Blob;
// (undocumented)
extension: string;
}

// @public (undocumented)
export type GenericTextCellFilterArtifacts = {
mode?: 'matches' | 'matchesExactly' | 'startsWith' | 'endsWith' | 'doesNotMatch';
Expand Down Expand Up @@ -733,6 +826,14 @@ export const useDataViewEnumFilter: (name: string, value: string) => UseDataView
// @public (undocumented)
export const useDataViewEnumFilterFactory: (name: string) => (value: string) => UseDataViewEnumFilter;

// @public (undocumented)
export const useDataViewFetchAllData: ({ children }: {
children: ReactNode;
}) => () => Promise<{
data: any;
marker: EntityListSubTreeMarker_2;
}>;

// @public (undocumented)
export const useDataViewFilter: <T extends Serializable>(key: string) => [T | undefined, (filter: SetStateAction<T | undefined>) => void];

Expand Down Expand Up @@ -835,7 +936,10 @@ export const useDataViewSortingMethods: () => DataViewSortingMethods;
export const useDataViewSortingState: () => DataViewSortingState;

// @public (undocumented)
export const useDataViewTextFilterInput: (name: string) => UseDataViewTextFilterInputResult;
export const useDataViewTextFilterInput: ({ name, debounceMs }: {
name: string;
debounceMs?: number | undefined;
}) => UseDataViewTextFilterInputResult;

// @public (undocumented)
export interface UseDataViewTextFilterInputResult {
Expand Down

0 comments on commit 879d01e

Please sign in to comment.