dinocollab-core 2.2.54 → 2.2.56
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 +1 -23
- package/dist/data-surface/index.js +1 -1
- package/dist/filter-bar/index.js +1 -1
- package/dist/src/data-surface/button-switch.js +1 -1
- package/dist/src/data-surface/button-switch.js.map +1 -1
- package/dist/src/data-surface/index.create.js +1 -1
- package/dist/src/data-surface/index.create.js.map +1 -1
- package/dist/src/data-surface/index.dino.js +1 -1
- package/dist/src/data-surface/index.dino.js.map +1 -1
- package/dist/src/data-surface/ui.units.js +1 -1
- package/dist/src/data-surface/ui.units.js.map +1 -1
- package/dist/src/data-surface/view-grid/index.js +1 -1
- package/dist/src/data-surface/view-grid/index.js.map +1 -1
- package/dist/src/data-surface/view-list/column-selector.js +2 -0
- package/dist/src/data-surface/view-list/column-selector.js.map +1 -0
- package/dist/src/data-surface/view-list/helpers.js +1 -1
- package/dist/src/data-surface/view-list/helpers.js.map +1 -1
- package/dist/src/data-surface/view-list/hooks.js +1 -1
- package/dist/src/data-surface/view-list/hooks.js.map +1 -1
- package/dist/src/data-surface/view-list/index.js +1 -1
- package/dist/src/data-surface/view-list/index.js.map +1 -1
- package/dist/src/data-surface/view-list/types.js.map +1 -1
- package/dist/src/filter-bar/components/ui.units.js +1 -1
- package/dist/src/filter-bar/components/ui.units.js.map +1 -1
- package/dist/src/filter-bar/convert-to-graphql.js +1 -1
- package/dist/src/filter-bar/convert-to-graphql.js.map +1 -1
- package/dist/src/filter-bar/filter-input.js +2 -0
- package/dist/src/filter-bar/filter-input.js.map +1 -0
- package/dist/src/filter-bar/filter-input.types.js +2 -0
- package/dist/src/filter-bar/filter-input.types.js.map +1 -0
- package/dist/src/filter-bar/filter-input.units.js +2 -0
- package/dist/src/filter-bar/filter-input.units.js.map +1 -0
- package/dist/src/filter-bar/filter-menu.helpers.js +2 -0
- package/dist/src/filter-bar/filter-menu.helpers.js.map +1 -0
- package/dist/src/filter-bar/filter-menu.js +2 -0
- package/dist/src/filter-bar/filter-menu.js.map +1 -0
- package/dist/src/filter-bar/filter-menu.styled.js +2 -0
- package/dist/src/filter-bar/filter-menu.styled.js.map +1 -0
- package/dist/src/filter-bar/filter-menu.units.js +2 -0
- package/dist/src/filter-bar/filter-menu.units.js.map +1 -0
- package/dist/src/filter-bar/filter-sort.js +2 -0
- package/dist/src/filter-bar/filter-sort.js.map +1 -0
- package/dist/src/filter-bar/filter-sort.types.js +2 -0
- package/dist/src/filter-bar/filter-sort.types.js.map +1 -0
- package/dist/src/filter-bar/filter-summary.js +2 -0
- package/dist/src/filter-bar/filter-summary.js.map +1 -0
- package/dist/src/filter-bar/form-field/create-form-field-boolean.js +2 -0
- package/dist/src/filter-bar/form-field/create-form-field-boolean.js.map +1 -0
- package/dist/src/filter-bar/form-field/create-form-field-datetime.js +2 -0
- package/dist/src/filter-bar/form-field/create-form-field-datetime.js.map +1 -0
- package/dist/src/filter-bar/form-field/create-form-field-number.js +2 -0
- package/dist/src/filter-bar/form-field/create-form-field-number.js.map +1 -0
- package/dist/src/filter-bar/form-field/create-form-field-select-with-api.js +2 -0
- package/dist/src/filter-bar/form-field/create-form-field-select-with-api.js.map +1 -0
- package/dist/src/filter-bar/form-field/create-form-field-select.fallback.js +2 -0
- package/dist/src/filter-bar/form-field/create-form-field-select.fallback.js.map +1 -0
- package/dist/src/filter-bar/form-field/create-form-field-select.js +2 -0
- package/dist/src/filter-bar/form-field/create-form-field-select.js.map +1 -0
- package/dist/src/filter-bar/form-field/create-form-field-string.js +2 -0
- package/dist/src/filter-bar/form-field/create-form-field-string.js.map +1 -0
- package/dist/src/filter-bar/helpers.js +1 -1
- package/dist/src/filter-bar/helpers.js.map +1 -1
- package/dist/src/filter-bar/index.create.js +1 -1
- package/dist/src/filter-bar/index.create.js.map +1 -1
- package/dist/src/filter-bar/index.dino.js +1 -1
- package/dist/src/filter-bar/index.dino.js.map +1 -1
- package/dist/src/filter-bar/local-filter-builder.js +1 -1
- package/dist/src/filter-bar/local-filter-builder.js.map +1 -1
- package/dist/src/filter-bar/popper-custom.js +2 -0
- package/dist/src/filter-bar/popper-custom.js.map +1 -0
- package/dist/src/filter-bar/types.js.map +1 -1
- package/dist/src/form/create.checkbox.js +1 -1
- package/dist/src/form/create.checkbox.js.map +1 -1
- package/dist/src/form/helpers.js +1 -1
- package/dist/src/form/helpers.js.map +1 -1
- package/dist/src/form/v2/create.autocomplete.chips.js +1 -1
- package/dist/src/form/v2/create.autocomplete.chips.js.map +1 -1
- package/dist/src/form/v2/create.select-with-api.js +1 -1
- package/dist/src/form/v2/create.select-with-api.js.map +1 -1
- package/dist/types/data-surface/button-switch.d.ts +4 -0
- package/dist/types/data-surface/index.create.d.ts +13 -5
- package/dist/types/data-surface/index.dino.d.ts +6 -7
- package/dist/types/data-surface/ui.units.d.ts +1 -0
- package/dist/types/data-surface/view-grid/index.d.ts +0 -1
- package/dist/types/data-surface/view-list/column-selector.d.ts +6 -0
- package/dist/types/data-surface/view-list/helpers.d.ts +3 -2
- package/dist/types/data-surface/view-list/index.d.ts +1 -1
- package/dist/types/data-surface/view-list/types.d.ts +30 -2
- package/dist/types/filter-bar/components/filter-input.mobile.d.ts +1 -7
- package/dist/types/filter-bar/components/ui.units.d.ts +7 -0
- package/dist/types/filter-bar/convert-to-graphql.d.ts +56 -28
- package/dist/types/filter-bar/{components/filter-input.d.ts → filter-input.d.ts} +5 -1
- package/dist/types/filter-bar/{components/filter-input.types.d.ts → filter-input.types.d.ts} +1 -16
- package/dist/types/filter-bar/{components/filter-input.units.d.ts → filter-input.units.d.ts} +7 -2
- package/dist/types/filter-bar/{menu/create.d.ts → filter-menu.d.ts} +4 -13
- package/dist/types/filter-bar/filter-menu.helpers.d.ts +31 -0
- package/dist/types/filter-bar/filter-menu.styled.d.ts +20 -0
- package/dist/types/filter-bar/filter-menu.types.d.ts +63 -0
- package/dist/types/filter-bar/filter-menu.units.d.ts +20 -0
- package/dist/types/filter-bar/{components/filter-sort.d.ts → filter-sort.d.ts} +21 -2
- package/dist/types/filter-bar/filter-sort.types.d.ts +30 -0
- package/dist/types/filter-bar/filter-summary.types.d.ts +14 -0
- package/dist/types/filter-bar/{menu → form-field}/create-form-field-boolean.d.ts +2 -2
- package/dist/types/filter-bar/{menu → form-field}/create-form-field-datetime.d.ts +2 -2
- package/dist/types/filter-bar/{menu → form-field}/create-form-field-number.d.ts +2 -2
- package/dist/types/filter-bar/{menu → form-field}/create-form-field-select-with-api.d.ts +2 -2
- package/dist/types/filter-bar/{menu → form-field}/create-form-field-select.d.ts +2 -2
- package/dist/types/filter-bar/form-field/create-form-field-select.fallback.d.ts +24 -0
- package/dist/types/filter-bar/{menu → form-field}/create-form-field-string.d.ts +2 -2
- package/dist/types/filter-bar/helpers.d.ts +11 -0
- package/dist/types/filter-bar/index.create.d.ts +10 -28
- package/dist/types/filter-bar/index.d.ts +9 -8
- package/dist/types/filter-bar/index.dino.d.ts +7 -7
- package/dist/types/filter-bar/local-filter-builder.d.ts +12 -3
- package/dist/types/filter-bar/types.d.ts +123 -49
- package/dist/types/form/create.checkbox.d.ts +40 -3
- package/dist/types/form/v2/create.autocomplete.chips.d.ts +14 -1
- package/dist/types/form/v2/create.select-with-api.d.ts +41 -3
- package/package.json +1 -1
- package/dist/src/filter-bar/components/filter-input.js +0 -2
- package/dist/src/filter-bar/components/filter-input.js.map +0 -1
- package/dist/src/filter-bar/components/filter-input.units.js +0 -2
- package/dist/src/filter-bar/components/filter-input.units.js.map +0 -1
- package/dist/src/filter-bar/components/filter-sort.js +0 -2
- package/dist/src/filter-bar/components/filter-sort.js.map +0 -1
- package/dist/src/filter-bar/components/filter-summary.js +0 -2
- package/dist/src/filter-bar/components/filter-summary.js.map +0 -1
- package/dist/src/filter-bar/components/popper-custom.js +0 -2
- package/dist/src/filter-bar/components/popper-custom.js.map +0 -1
- package/dist/src/filter-bar/menu/create-form-field-boolean.js +0 -2
- package/dist/src/filter-bar/menu/create-form-field-boolean.js.map +0 -1
- package/dist/src/filter-bar/menu/create-form-field-datetime.js +0 -2
- package/dist/src/filter-bar/menu/create-form-field-datetime.js.map +0 -1
- package/dist/src/filter-bar/menu/create-form-field-number.js +0 -2
- package/dist/src/filter-bar/menu/create-form-field-number.js.map +0 -1
- package/dist/src/filter-bar/menu/create-form-field-select-with-api.js +0 -2
- package/dist/src/filter-bar/menu/create-form-field-select-with-api.js.map +0 -1
- package/dist/src/filter-bar/menu/create-form-field-select.fallback.js +0 -2
- package/dist/src/filter-bar/menu/create-form-field-select.fallback.js.map +0 -1
- package/dist/src/filter-bar/menu/create-form-field-select.js +0 -2
- package/dist/src/filter-bar/menu/create-form-field-select.js.map +0 -1
- package/dist/src/filter-bar/menu/create-form-field-string.js +0 -2
- package/dist/src/filter-bar/menu/create-form-field-string.js.map +0 -1
- package/dist/src/filter-bar/menu/create.js +0 -2
- package/dist/src/filter-bar/menu/create.js.map +0 -1
- package/dist/src/filter-bar/menu/ui.units.js +0 -2
- package/dist/src/filter-bar/menu/ui.units.js.map +0 -1
- package/dist/types/filter-bar/components/filter-sort.types.d.ts +0 -49
- package/dist/types/filter-bar/components/filter-summary.types.d.ts +0 -21
- package/dist/types/filter-bar/menu/create-form-field-select.fallback.d.ts +0 -11
- package/dist/types/filter-bar/menu/types.d.ts +0 -70
- package/dist/types/filter-bar/menu/ui.units.d.ts +0 -6
- /package/dist/types/filter-bar/{components/filter-summary.d.ts → filter-summary.d.ts} +0 -0
- /package/dist/types/filter-bar/{components/popper-custom.d.ts → popper-custom.d.ts} +0 -0
|
@@ -2,7 +2,7 @@ import { FC, ReactNode } from 'react';
|
|
|
2
2
|
export { DEFAULT_STORAGE_KEY, getOptionLabelFromLocal, saveOptionLabelToLocal, saveOptionLabelsToLocal } from '../helpers';
|
|
3
3
|
import type { IFieldSelectOption } from './create-form-field-select';
|
|
4
4
|
import type { TFieldType, TFieldValid, TLogic, TValueFormatterParam } from '../types';
|
|
5
|
-
import type {
|
|
5
|
+
import type { IFilterMenuConfig, IFilterMenuFormProps } from '../filter-menu.types';
|
|
6
6
|
/** Props for the `FormFieldSelectWithApi` component returned by `createFormFieldSelectWithApi`. Extends the base filter-menu form props. */
|
|
7
7
|
export interface IFormFieldSelectWithApiProps<T> extends IFilterMenuFormProps<T> {
|
|
8
8
|
/** Callback function to handle errors */
|
|
@@ -13,7 +13,7 @@ export interface IFormFieldSelectWithApiProps<T> extends IFilterMenuFormProps<T>
|
|
|
13
13
|
/** Parameters passed to `createFormFieldSelectWithApi` to configure the generated component. */
|
|
14
14
|
export interface IFormFieldSelectWithApiParam<T> {
|
|
15
15
|
/** Optional configuration for the form field */
|
|
16
|
-
config?:
|
|
16
|
+
config?: IFilterMenuConfig<T>;
|
|
17
17
|
/** Function to fetch options asynchronously based on user input query */
|
|
18
18
|
fetchOptions: (query: string, signal?: AbortSignal) => Promise<IFieldSelectOption[]> | IFieldSelectOption[];
|
|
19
19
|
/** Debounce delay for typing in milliseconds @default 300 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import type { TFieldType, TFieldValid, TLogic, TValueFormatterParam } from '../types';
|
|
3
|
-
import type {
|
|
3
|
+
import type { IFilterMenuConfig, IFilterMenuFormProps } from '../filter-menu.types';
|
|
4
4
|
/** Props for the `FormFieldSelect` component returned by `createFormFieldSelect`. Extends the base filter-menu form props. */
|
|
5
5
|
export interface IFormFieldSelectProps<T> extends IFilterMenuFormProps<T> {
|
|
6
6
|
/** Callback function to handle errors */
|
|
@@ -16,7 +16,7 @@ export interface IFieldSelectOption {
|
|
|
16
16
|
/** Parameters passed to `createFormFieldSelect` to configure the generated component. */
|
|
17
17
|
export interface IFormFieldSelectParam<T> {
|
|
18
18
|
/** Optional configuration for the form field */
|
|
19
|
-
config?:
|
|
19
|
+
config?: IFilterMenuConfig<T>;
|
|
20
20
|
/** List of options for the select field */
|
|
21
21
|
options?: IFieldSelectOption[];
|
|
22
22
|
/** Function to fetch options asynchronously based on user input */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Dispatch, FC, ReactNode, SetStateAction } from 'react';
|
|
2
|
+
import { TFetchStatus } from '../filter-menu.types';
|
|
3
|
+
import { IFormFieldSelectParam, IFormFieldSelectProps } from './create-form-field-select';
|
|
4
|
+
/**
|
|
5
|
+
* Base parameters for fallback rendering behavior when select option fetching fails.
|
|
6
|
+
*/
|
|
7
|
+
export type IFallbackPropsBase = {
|
|
8
|
+
/** Custom renderer function for rendering error/status feedback content at the top of the form */
|
|
9
|
+
renderTop?: (param?: {
|
|
10
|
+
setStatus: Dispatch<SetStateAction<TFetchStatus>>;
|
|
11
|
+
status: TFetchStatus;
|
|
12
|
+
}) => ReactNode;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Factory function that creates a resilient `FormFieldSelect` component with automatic string fallback.
|
|
16
|
+
*
|
|
17
|
+
* If option loading fails or encounters an error status, the generated component automatically switches
|
|
18
|
+
* from option list selection (`createFormFieldSelect`) to a free-text input (`createFormFieldString`)
|
|
19
|
+
* with a retry option panel, ensuring users can always filter even during API outages.
|
|
20
|
+
*
|
|
21
|
+
* @param params - Configuration options including option fetchers and fallback renderers
|
|
22
|
+
* @returns A React FC ready to be used as a fallback-enabled select field component
|
|
23
|
+
*/
|
|
24
|
+
export declare function createFormFieldSelectWithFallback<T>(params: IFormFieldSelectParam<T> & IFallbackPropsBase): FC<IFormFieldSelectProps<T>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FC, ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IFilterMenuConfig, IFilterMenuFormProps } from '../filter-menu.types';
|
|
3
3
|
/** Props for the `FormFieldString` component returned by `createFormFieldString`. Extends the base filter-menu form props. */
|
|
4
4
|
export interface IFormFieldStringProps<T> extends IFilterMenuFormProps<T> {
|
|
5
5
|
top?: ReactNode;
|
|
@@ -7,7 +7,7 @@ export interface IFormFieldStringProps<T> extends IFilterMenuFormProps<T> {
|
|
|
7
7
|
/** Parameters passed to `createFormFieldString` to configure the generated component. */
|
|
8
8
|
export interface IFormFieldStringParam<T> {
|
|
9
9
|
/** Optional configuration for the form field */
|
|
10
|
-
config?:
|
|
10
|
+
config?: IFilterMenuConfig<T>;
|
|
11
11
|
top?: ReactNode;
|
|
12
12
|
multiline?: boolean;
|
|
13
13
|
}
|
|
@@ -48,3 +48,14 @@ export declare function saveOptionLabelsToLocal(field: string, options: {
|
|
|
48
48
|
}[], storageKey?: string): void;
|
|
49
49
|
export declare function saveOptionLabelToLocal(field: string, value: string, label: string, storageKey?: string): void;
|
|
50
50
|
export declare function getOptionLabelFromLocal(field: string, value: string, storageKey?: string): string | undefined;
|
|
51
|
+
export interface IFieldGroup<TItem> {
|
|
52
|
+
name?: string;
|
|
53
|
+
items: TItem[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Groups visible filter field configs by their `group` property.
|
|
57
|
+
* Items without a `group` property (including quickSearch) are placed first in an unnamed group (`name: undefined`).
|
|
58
|
+
*/
|
|
59
|
+
export declare function groupFields<TItem extends {
|
|
60
|
+
group?: string;
|
|
61
|
+
}>(fields: TItem[]): IFieldGroup<TItem>[];
|
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
import { BoxProps } from '@mui/material';
|
|
2
|
-
import type {
|
|
3
|
-
import type { TFilterState } from './types';
|
|
4
|
-
|
|
5
|
-
import type { IFilterSortConfig, IFilterSortProps } from './components/filter-sort.types';
|
|
6
|
-
import type { IFilterInputConfig, IFilterInputProps } from './components/filter-input.types';
|
|
7
|
-
import type { IFilterSummaryConfig, IFilterSummaryProps } from './components/filter-summary.types';
|
|
8
|
-
export interface IFilterBarConfigs<T> {
|
|
9
|
-
/** Debounce delay for filter input changes in milliseconds @default 300 */
|
|
10
|
-
debounceDelay?: number;
|
|
11
|
-
defaultFilterState?: TFilterState<T>;
|
|
12
|
-
/** Default filter logic, can be overridden by individual filters @default "and" */
|
|
13
|
-
defaultFilterLogic?: 'and' | 'or';
|
|
14
|
-
InputComponent?: ComponentType<IFilterInputProps<T>>;
|
|
15
|
-
inputConfig?: IFilterInputConfig<T>;
|
|
16
|
-
MenuComponent?: ComponentType<IFilterMenuProps<T>>;
|
|
17
|
-
menuConfig?: IFilterMenuConfig<T>;
|
|
18
|
-
sortConfig?: IFilterSortConfig<T>;
|
|
19
|
-
SortComponent?: ComponentType<IFilterSortProps<T>>;
|
|
20
|
-
/** Enable or disable the summary component. Default is true. */
|
|
21
|
-
enableSummary?: boolean;
|
|
22
|
-
SummaryComponent?: ComponentType<IFilterSummaryProps<T>>;
|
|
23
|
-
summaryConfig?: IFilterSummaryConfig<T>;
|
|
24
|
-
}
|
|
2
|
+
import type { FC, ReactNode } from 'react';
|
|
3
|
+
import type { TFilterState, TFilterBarConfigs } from './types';
|
|
4
|
+
export type IFilterBarConfigs<T> = TFilterBarConfigs<T>;
|
|
25
5
|
export interface IFilterBarSlots {
|
|
26
6
|
summaryWrapProps?: BoxProps;
|
|
27
|
-
summaryBefore?:
|
|
28
|
-
summaryAfter?:
|
|
29
|
-
before?:
|
|
30
|
-
after?:
|
|
7
|
+
summaryBefore?: ReactNode | ReactNode[];
|
|
8
|
+
summaryAfter?: ReactNode | ReactNode[];
|
|
9
|
+
before?: ReactNode | ReactNode[];
|
|
10
|
+
after?: ReactNode | ReactNode[];
|
|
11
|
+
actionsBefore?: ReactNode | ReactNode[];
|
|
12
|
+
actionsAfter?: ReactNode | ReactNode[];
|
|
31
13
|
}
|
|
32
14
|
export interface IFilterBarProps<T> {
|
|
33
15
|
sx?: BoxProps['sx'];
|
|
@@ -37,4 +19,4 @@ export interface IFilterBarProps<T> {
|
|
|
37
19
|
slots?: IFilterBarSlots;
|
|
38
20
|
loading?: boolean;
|
|
39
21
|
}
|
|
40
|
-
export declare function createFilterBar<T>(configs:
|
|
22
|
+
export declare function createFilterBar<T>(configs: TFilterBarConfigs<T>): FC<IFilterBarProps<T>>;
|
|
@@ -4,12 +4,13 @@ export * from './components/hint-icon';
|
|
|
4
4
|
export * from './convert-to-graphql';
|
|
5
5
|
export * from './local-filter-builder';
|
|
6
6
|
export * from './index.dino';
|
|
7
|
-
export type { IFieldSelectOption } from './
|
|
8
|
-
export { formatterSelect } from './
|
|
9
|
-
export type { IFormFieldDateTimeParam, TDateTimePickerType } from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export
|
|
7
|
+
export type { IFieldSelectOption } from './form-field/create-form-field-select';
|
|
8
|
+
export { formatterSelect } from './form-field/create-form-field-select';
|
|
9
|
+
export type { IFormFieldDateTimeParam, TDateTimePickerType } from './form-field/create-form-field-datetime';
|
|
10
|
+
export * from './form-field/create-form-field-datetime';
|
|
11
|
+
export * from './form-field/create-form-field-number';
|
|
12
|
+
export * from './form-field/create-form-field-select-with-api';
|
|
13
|
+
export * from './filter-input.types';
|
|
14
|
+
export * from './filter-menu.types';
|
|
15
|
+
export * from './filter-sort.types';
|
|
15
16
|
export { mergeValueToStoreFilter, mergeSingleValueToStoreFilter } from './hooks';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createFilterBar } from './index.create';
|
|
2
2
|
import { getFilterFromURL, isEmptyFilterState, isFilterStateEqual, removeNullValues, setFilterToURL } from './helpers';
|
|
3
|
-
import { createFormFieldSelectWithFallback } from './
|
|
4
|
-
import createFormFieldNumber, { formatterNumber } from './
|
|
5
|
-
import createFormFieldDateTime, { formatterDateTime } from './
|
|
6
|
-
import createFormFieldSelect, { formatterSelect } from './
|
|
7
|
-
import createFormFieldBoolean, { formatterBoolean } from './
|
|
8
|
-
import createFormFieldSelectWithApi, { formatterSelectWithApi } from './
|
|
9
|
-
import createFormFieldString from './
|
|
3
|
+
import { createFormFieldSelectWithFallback } from './form-field/create-form-field-select.fallback';
|
|
4
|
+
import createFormFieldNumber, { formatterNumber } from './form-field/create-form-field-number';
|
|
5
|
+
import createFormFieldDateTime, { formatterDateTime } from './form-field/create-form-field-datetime';
|
|
6
|
+
import createFormFieldSelect, { formatterSelect } from './form-field/create-form-field-select';
|
|
7
|
+
import createFormFieldBoolean, { formatterBoolean } from './form-field/create-form-field-boolean';
|
|
8
|
+
import createFormFieldSelectWithApi, { formatterSelectWithApi } from './form-field/create-form-field-select-with-api';
|
|
9
|
+
import createFormFieldString from './form-field/create-form-field-string';
|
|
10
10
|
export declare class DinoFilterBar {
|
|
11
11
|
createFilterBar: typeof createFilterBar;
|
|
12
12
|
createConvertToGraphQL: <TSource extends Record<string, any>, TTarget extends object, U extends object = {}>(state: import("./types").TFilterState<TSource>) => import("./convert-to-graphql").TableFileterConverter<TSource, TTarget, U>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TFilterState } from './types';
|
|
2
|
-
type TOperation = 'equal' | 'contains';
|
|
2
|
+
type TOperation = 'equal' | 'contains' | 'number' | 'datetime' | 'boolean' | 'enum';
|
|
3
3
|
type TAutoMapField = {
|
|
4
|
-
/** The operation to use for filtering.
|
|
4
|
+
/** The operation to use for filtering. @default 'contains' */
|
|
5
5
|
operation?: TOperation;
|
|
6
6
|
};
|
|
7
7
|
type TAutoMapFields<T> = Partial<Record<keyof T, TAutoMapField>>;
|
|
@@ -10,13 +10,16 @@ type TAutoMapConfigs<T> = {
|
|
|
10
10
|
sortFields?: (keyof T)[];
|
|
11
11
|
quickSearchFields?: (keyof T)[];
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Utility builder class for applying `TFilterState` filtering, quick-searching, and sorting in-memory on client-side array data.
|
|
15
|
+
*/
|
|
13
16
|
export declare class LocalFilterBuilder<T> {
|
|
14
|
-
private operation;
|
|
15
17
|
private data;
|
|
16
18
|
private dataFiltered;
|
|
17
19
|
private filterState;
|
|
18
20
|
constructor(data: T[], filterState: TFilterState<T>);
|
|
19
21
|
private autoMapConfigs;
|
|
22
|
+
/** Register auto-mapping configuration for in-memory field filtering, sorting, and quick search. */
|
|
20
23
|
autoMap(configs?: TAutoMapConfigs<T>): this;
|
|
21
24
|
/** Register field filter config. Merged with autoMap.fields. */
|
|
22
25
|
filter(config?: {
|
|
@@ -33,7 +36,13 @@ export declare class LocalFilterBuilder<T> {
|
|
|
33
36
|
sortFields?: (keyof T)[];
|
|
34
37
|
}): this;
|
|
35
38
|
private handleSort;
|
|
39
|
+
/**
|
|
40
|
+
* Executes filtering, quick search, and sorting logic on the raw data array, returning the processed subset.
|
|
41
|
+
*/
|
|
36
42
|
build(): T[];
|
|
37
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Factory function to instantiate a `LocalFilterBuilder` for client-side array filtering.
|
|
46
|
+
*/
|
|
38
47
|
export declare const createLocalFilterBuilder: <T>(data: T[], filterState: TFilterState<T>) => LocalFilterBuilder<T>;
|
|
39
48
|
export {};
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { IFilterInputConfig, TFieldMatch } from './filter-input.types';
|
|
3
|
+
import type { IFilterMenuConfig, IFilterMenuParam } from './filter-menu.types';
|
|
4
|
+
import type { IFieldValidateConfig } from '../form/validator';
|
|
1
5
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* - Use ISO date strings or a discriminated union if date/serialization handling is needed.
|
|
6
|
-
* @vi
|
|
7
|
-
* - Gia tri nguyen thuy hop le cho cac field filter.
|
|
8
|
-
* - Kieu runtime: string, number, boolean.
|
|
9
|
-
* - Neu can xu ly Date qua mang/serialize thi dung chuoi ISO hoac discriminated union.
|
|
6
|
+
* Allowed primitive values for filter fields.
|
|
7
|
+
* Runtime types: string, number, boolean.
|
|
8
|
+
* Use ISO date strings or a discriminated union if date/serialization handling is needed.
|
|
10
9
|
*/
|
|
11
10
|
export type TFieldValid = string | number | boolean;
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - Kept as const so `TypeScript` preserves literal types.
|
|
16
|
-
* @vi
|
|
17
|
-
* - Khoa filter dac biet cho UI (vi dụ: quickSearch).
|
|
18
|
-
* - Giu const de `TypeScript` giu literal types.
|
|
12
|
+
* Special UI-only filter keys (e.g. quickSearch, sortShuffle).
|
|
13
|
+
* Kept as const so `TypeScript` preserves literal types.
|
|
19
14
|
*/
|
|
20
15
|
export declare const KeySpecial: {
|
|
21
16
|
readonly quickSearch: "quickSearch";
|
|
@@ -23,80 +18,159 @@ export declare const KeySpecial: {
|
|
|
23
18
|
};
|
|
24
19
|
export type KeySpecial = keyof typeof KeySpecial;
|
|
25
20
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* - Purpose: allow filters to reference either a model property or a special UI key.
|
|
29
|
-
* @vi
|
|
30
|
-
* - Tap hop cac khoa cua model va cac khoa filter dac biet cho he thong filter.
|
|
31
|
-
* - Muc dich: cho phep filter tham chieu truong model hoac key UI dac biet.
|
|
21
|
+
* Union of model field keys and special filter keys used by the filter system.
|
|
22
|
+
* Purpose: allow filters to reference either a model property or a special UI key.
|
|
32
23
|
*/
|
|
33
24
|
export type TFieldType<T> = keyof T | keyof typeof KeySpecial;
|
|
25
|
+
/**
|
|
26
|
+
* Merge external model with special filter keys so filters can reference both for safe typing.
|
|
27
|
+
*/
|
|
28
|
+
export type TFieldModelValid<T> = T & Record<keyof typeof KeySpecial, any>;
|
|
29
|
+
/**
|
|
30
|
+
* Parameters passed to `TValueFormatter` callback for custom value display formatting.
|
|
31
|
+
*/
|
|
34
32
|
export type TValueFormatterParam<T> = {
|
|
33
|
+
/** Field key being formatted */
|
|
35
34
|
key: TFieldType<T>;
|
|
35
|
+
/** Current primitive value item */
|
|
36
36
|
value: TFieldValid;
|
|
37
|
+
/** Index of the value within the field's values array */
|
|
37
38
|
index: number;
|
|
39
|
+
/** Complete field value state */
|
|
38
40
|
fieldValue: TFieldValue;
|
|
39
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Custom formatter callback function for converting raw field values to user-facing display strings.
|
|
44
|
+
*/
|
|
40
45
|
export type TValueFormatter<T> = (param: TValueFormatterParam<T>) => string | undefined;
|
|
41
46
|
/**
|
|
42
|
-
*
|
|
43
|
-
* - Merge external model with special filter keys so filters can reference both.
|
|
44
|
-
* - Purpose: extend a model type with UI special keys (e.g. quickSearch) for safe typing.
|
|
45
|
-
* @vi
|
|
46
|
-
* - Gop model ngoai voi cac key filter dac biet de filter co the tham chieu ca hai.
|
|
47
|
-
* - Muc dich: mo rong kieu model de chua cac key UI (vd quickSearch) de type an toan.
|
|
47
|
+
* Configuration options for rendering active filter summary chips.
|
|
48
48
|
*/
|
|
49
|
-
export
|
|
49
|
+
export interface ISummaryChipConfig {
|
|
50
|
+
/** Mode for rendering chips: 'single' collapses all values into 1 chip, 'multiple' renders separate chips per value. @default 'multiple' */
|
|
51
|
+
mode?: 'single' | 'multiple';
|
|
52
|
+
/** Separator string used when mode is 'single'. @default ', ' */
|
|
53
|
+
separator?: string;
|
|
54
|
+
/** Minimum CSS width for the summary chip */
|
|
55
|
+
minWidth?: number | string;
|
|
56
|
+
}
|
|
57
|
+
export type { IFilterMenuConfig } from './filter-menu.types';
|
|
58
|
+
/**
|
|
59
|
+
* Field-level sorting configuration options.
|
|
60
|
+
*/
|
|
61
|
+
export interface ISortFieldConfig {
|
|
62
|
+
/** Default direction for field sorting ('asc' | 'desc') @default 'desc' */
|
|
63
|
+
defaultDirection?: TDirection;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Unified field configuration schema for FilterBar.
|
|
67
|
+
* Each field is declared once with feature activation flags and sub-component specifics.
|
|
68
|
+
*/
|
|
69
|
+
export type TFilterFieldConfig<T> = {
|
|
70
|
+
/** Display label for the field across all components */
|
|
71
|
+
label?: string;
|
|
72
|
+
/** Category group name for visual section grouping in dropdowns */
|
|
73
|
+
group?: string;
|
|
74
|
+
/** Global visibility toggle. If false, field is hidden from all menus. @default true */
|
|
75
|
+
visible?: boolean;
|
|
76
|
+
/** If true, only 1 value is allowed at a time; submitting a new value replaces the previous one. @default false */
|
|
77
|
+
singleValue?: boolean;
|
|
78
|
+
/** Default logical operator ('and' | 'or') within this field's values. @default 'or' */
|
|
79
|
+
defaultLogic?: TLogic;
|
|
80
|
+
/** Custom formatter function for converting raw field values into display strings */
|
|
81
|
+
valueFormatter?: TValueFormatter<T>;
|
|
82
|
+
/** Enables field suggestion in Quick Input bar @default false */
|
|
83
|
+
inputable?: boolean;
|
|
84
|
+
/** Matching rules or keyword patterns for Quick Input parsing */
|
|
85
|
+
inputMatch?: TFieldMatch | TFieldMatch[];
|
|
86
|
+
/** Enables field entry in Sort dropdown @default false */
|
|
87
|
+
sortable?: boolean;
|
|
88
|
+
/** Enables field menu item in Filter Menu popover @default false */
|
|
89
|
+
menuable?: boolean;
|
|
90
|
+
/** Custom React component for editing this field inside the filter menu form view */
|
|
91
|
+
MenuForm?: ComponentType<any>;
|
|
92
|
+
/** Specific options for Filter Menu item and subMenu form behavior */
|
|
93
|
+
menuConfig?: IFilterMenuConfig<T>;
|
|
94
|
+
/** Field-level validation configuration for default menu form */
|
|
95
|
+
menuValidation?: IFieldValidateConfig<Partial<TFieldModelValid<T>>>;
|
|
96
|
+
/** Specific options for active summary chips representation */
|
|
97
|
+
summaryConfig?: ISummaryChipConfig;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Dictionary map of field configurations indexed by field key.
|
|
101
|
+
*/
|
|
102
|
+
export type TFilterFieldConfigs<T> = Partial<Record<TFieldType<T>, TFilterFieldConfig<T>>>;
|
|
50
103
|
/**
|
|
51
|
-
*
|
|
52
|
-
|
|
104
|
+
* Root configuration for FilterBar instance creation.
|
|
105
|
+
*/
|
|
106
|
+
export type TFilterBarConfigs<T> = {
|
|
107
|
+
/** Map of unified field configurations indexed by field key */
|
|
108
|
+
fields?: TFilterFieldConfigs<T>;
|
|
109
|
+
/** Initial default filter state containing active filters and sort directions */
|
|
110
|
+
defaultFilterState?: TFilterState<T>;
|
|
111
|
+
/** Default logical operator ('and' | 'or') for combining active field filters @default 'or' */
|
|
112
|
+
defaultFilterLogic?: TLogic;
|
|
113
|
+
/** Debounce delay in milliseconds for filter input state updates @default 300 */
|
|
114
|
+
debounceDelay?: number;
|
|
115
|
+
/** Configuration options for the Filter Input component */
|
|
116
|
+
inputConfig?: IFilterInputConfig<T>;
|
|
117
|
+
/** Configuration options for the Filter Menu component */
|
|
118
|
+
menuConfig?: Omit<IFilterMenuParam<T>, 'fields'>;
|
|
119
|
+
/** Toggle active summary chips bar below the filter bar @default true */
|
|
120
|
+
enableSummary?: boolean;
|
|
121
|
+
/** Toggle quick search pseudo-field in filter menu @default false */
|
|
122
|
+
enableQuickSearch?: boolean;
|
|
123
|
+
/** Specific options for Field Sorting behavior */
|
|
124
|
+
sortConfig?: ISortFieldConfig;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Sorting direction for fields ('asc' | 'desc').
|
|
53
128
|
*/
|
|
54
129
|
export type TDirection = 'asc' | 'desc';
|
|
55
130
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @vi Giao dien de dinh nghia cach sap xep tren mot truong.
|
|
131
|
+
* Interface for defining active sorting state on a field.
|
|
58
132
|
*/
|
|
59
133
|
export type TFieldSort<T> = {
|
|
134
|
+
/** Field key being sorted */
|
|
60
135
|
field: TFieldType<T>;
|
|
61
|
-
/** Sorting direction
|
|
136
|
+
/** Sorting direction ('asc' | 'desc') @default 'desc' */
|
|
62
137
|
direction?: TDirection;
|
|
63
138
|
};
|
|
64
139
|
/**
|
|
65
|
-
*
|
|
66
|
-
* @vi Dinh nghia cac kieu co ban cho he thong filter bar, bao gom gia tri filter, kieu field va cau truc tong the cua filter state.
|
|
140
|
+
* Logical operator for combining filters or values ('and' | 'or').
|
|
67
141
|
*/
|
|
68
142
|
export type TLogic = 'and' | 'or';
|
|
143
|
+
/**
|
|
144
|
+
* Specific date filter logical condition ('before' | 'after' | 'range').
|
|
145
|
+
*/
|
|
69
146
|
export type TDateLogic = 'before' | 'after' | 'range';
|
|
147
|
+
/**
|
|
148
|
+
* Numeric comparison operator ('eq' | 'lt' | 'lte' | 'gt' | 'gte').
|
|
149
|
+
*/
|
|
70
150
|
export type TNumberOperator = 'eq' | 'lt' | 'lte' | 'gt' | 'gte';
|
|
71
151
|
/**
|
|
72
|
-
*
|
|
73
|
-
* - Structure for storing filter values and their logical relationship (AND/OR) for each field.
|
|
74
|
-
* @vi
|
|
75
|
-
* - Cau truc de luu tru cac gia tri filter va moi quan he logic (AND/OR) cho moi field.
|
|
152
|
+
* Structure for storing active filter values and logical relationship for a single field.
|
|
76
153
|
*/
|
|
77
154
|
export type TFieldValue = {
|
|
78
|
-
/** Logical operator for combining values within this field
|
|
155
|
+
/** Logical operator for combining values within this field ('and' | 'or') @default 'or' */
|
|
79
156
|
logic?: TLogic;
|
|
80
|
-
/** Logical operator for date-specific filtering
|
|
157
|
+
/** Logical operator for date-specific filtering ('before' | 'after' | 'range') */
|
|
81
158
|
dateLogic?: TDateLogic;
|
|
159
|
+
/** Array of active filter values */
|
|
82
160
|
values: TFieldValid[];
|
|
83
161
|
};
|
|
84
162
|
/**
|
|
85
|
-
*
|
|
86
|
-
* - Type for storing active filters in the filter state, mapping field keys to their filter values.
|
|
87
|
-
* @vi
|
|
88
|
-
* - Kieu de luu tru cac filter dang hoat dong trong filter state, map cac khoa field voi gia tri filter cua chung.
|
|
163
|
+
* Dictionary storing active field filter states mapped by field key.
|
|
89
164
|
*/
|
|
90
165
|
export type TFieldStore<T> = Partial<Record<TFieldType<T>, TFieldValue>>;
|
|
91
166
|
/**
|
|
92
|
-
*
|
|
93
|
-
* - Overall filter state structure, including the logical operator for combining filters and optional storage for active filters and sorting.
|
|
94
|
-
* @vi
|
|
95
|
-
* - Cau truc tong the cho filter state, bao gom toan tu logic de ket hop cac filter va luu tru tuy chon cho cac filter dang hoat dong va sap xep.
|
|
167
|
+
* Complete filter state structure including global logic, stored filters, and active sort.
|
|
96
168
|
*/
|
|
97
169
|
export type TFilterState<T> = {
|
|
98
|
-
/** Logical operator for combining filters
|
|
170
|
+
/** Logical operator for combining active field filters ('and' | 'or') @default 'or' */
|
|
99
171
|
filterLogic?: TLogic;
|
|
172
|
+
/** Active filter values stored by field key */
|
|
100
173
|
storeFilter?: TFieldStore<T>;
|
|
174
|
+
/** Active sort configuration */
|
|
101
175
|
storeSort?: TFieldSort<T>;
|
|
102
176
|
};
|
|
@@ -1,18 +1,50 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { BoxProps, CheckboxProps, TypographyProps } from '@mui/material';
|
|
3
3
|
import { IFormInputBase } from './types';
|
|
4
|
+
/** Position of the checkbox button relative to its label/description text. */
|
|
5
|
+
export type TCheckboxPosition = 'left' | 'right';
|
|
6
|
+
/** Common configuration options for DinoCheckbox layout and behavior. */
|
|
7
|
+
export interface ICheckboxOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Position of the checkbox button relative to the label/description text.
|
|
10
|
+
* @default 'left'
|
|
11
|
+
*/
|
|
12
|
+
checkboxPosition?: TCheckboxPosition;
|
|
13
|
+
/**
|
|
14
|
+
* Stretch the checkbox container to take up 100% of the parent container's width.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
fullWidth?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Secondary description text rendered directly below the main label.
|
|
20
|
+
* When provided, renders a modern thin border card container around the field.
|
|
21
|
+
*/
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Slots configuration interface for DinoCheckbox sub-components. */
|
|
4
25
|
export interface ICheckboxSlots {
|
|
26
|
+
/** Props forwarded to the root wrapper container Box. */
|
|
5
27
|
wrapProps?: BoxProps;
|
|
28
|
+
/** Props forwarded to the underlying checkbox element. */
|
|
6
29
|
checkboxProps?: CheckboxProps;
|
|
30
|
+
/** Props forwarded to the primary label Typography component. */
|
|
7
31
|
labelProps?: TypographyProps;
|
|
8
32
|
}
|
|
9
|
-
|
|
33
|
+
/** Props for the DinoCheckbox component instance. */
|
|
34
|
+
export interface ICheckboxProps<T = any> extends IFormInputBase<T, ICheckboxSlots>, ICheckboxOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Callback function triggered when the checkbox state changes.
|
|
37
|
+
* @param checked Current boolean state of the checkbox
|
|
38
|
+
*/
|
|
10
39
|
onChange?: (checked: boolean) => void;
|
|
11
40
|
}
|
|
41
|
+
/** Internal state interface for DinoCheckbox. */
|
|
12
42
|
export interface ICheckboxState {
|
|
43
|
+
/** Indicates whether the checkbox is currently checked. */
|
|
13
44
|
checked: boolean;
|
|
14
45
|
}
|
|
15
|
-
|
|
46
|
+
/** Factory configuration parameters passed into `createCheckbox()`. */
|
|
47
|
+
export interface ICheckboxParams<T = any> extends ICheckboxSlots, ICheckboxOptions {
|
|
16
48
|
}
|
|
17
49
|
/** Standard class names for styling DinoCheckbox sub-components. */
|
|
18
50
|
export declare const checkboxClasses: {
|
|
@@ -20,9 +52,14 @@ export declare const checkboxClasses: {
|
|
|
20
52
|
row: string;
|
|
21
53
|
box: string;
|
|
22
54
|
label: string;
|
|
55
|
+
description: string;
|
|
56
|
+
labelWrap: string;
|
|
23
57
|
error: string;
|
|
24
58
|
checked: string;
|
|
25
59
|
disabled: string;
|
|
60
|
+
fullWidth: string;
|
|
61
|
+
hasDescription: string;
|
|
62
|
+
posRight: string;
|
|
26
63
|
};
|
|
27
64
|
/**
|
|
28
65
|
* Modern Custom Styled Checkbox Component Creator for Boolean fields in DinoForm V2.
|
|
@@ -33,7 +70,7 @@ export declare const checkboxClasses: {
|
|
|
33
70
|
* @formField({
|
|
34
71
|
* type: Boolean,
|
|
35
72
|
* label: 'Same as billing address',
|
|
36
|
-
* renderInput: DinoForm.createCheckbox()
|
|
73
|
+
* renderInput: DinoForm.createCheckbox({ description: 'Use shipping address for billing', checkboxPosition: 'right' })
|
|
37
74
|
* })
|
|
38
75
|
* isSameBilling?: boolean
|
|
39
76
|
*/
|
|
@@ -2,11 +2,23 @@ import { ComponentType } from 'react';
|
|
|
2
2
|
import { BoxProps, TextFieldProps } from '@mui/material';
|
|
3
3
|
import { IFormInputBase } from '../types';
|
|
4
4
|
export interface IAutocompleteChipSlots {
|
|
5
|
+
/** Predefined option items available in the suggestions dropdown. @default [] */
|
|
5
6
|
optionItems?: string[];
|
|
7
|
+
/** Maximum number of tag chips displayed before collapsing into "+N". @default 3 */
|
|
6
8
|
limitTags?: number;
|
|
9
|
+
/** Delimiter string used to serialize tags in the hidden form input. @default '|' */
|
|
7
10
|
separator?: string;
|
|
11
|
+
/** Key used to persist user-created options in browser localStorage. @default undefined */
|
|
8
12
|
saveLocalStorageByKey?: string;
|
|
13
|
+
/**
|
|
14
|
+
* If true, enables free-form text input and tag creation on Enter key press.
|
|
15
|
+
* If false, restricts selection strictly to options in optionItems.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
freeSolo?: boolean;
|
|
19
|
+
/** Props passed to the root Box wrapper container. @default undefined */
|
|
9
20
|
wrapProps?: BoxProps;
|
|
21
|
+
/** Props passed to the internal MUI TextField input component. @default undefined */
|
|
10
22
|
textFieldProps?: TextFieldProps;
|
|
11
23
|
}
|
|
12
24
|
export interface IAutocompleteChipProps<T> extends IFormInputBase<T, IAutocompleteChipSlots> {
|
|
@@ -36,7 +48,8 @@ export declare const autocompleteChipClasses: {
|
|
|
36
48
|
* label: 'Skills (Tags)',
|
|
37
49
|
* renderInput: DinoForm.createAutocompleteChipV2({
|
|
38
50
|
* optionItems: ['React', 'TypeScript', 'Material-UI', 'Node.js'],
|
|
39
|
-
* limitTags: 3
|
|
51
|
+
* limitTags: 3,
|
|
52
|
+
* freeSolo: false // Restrict input to optionItems only
|
|
40
53
|
* })
|
|
41
54
|
* })
|
|
42
55
|
* skills?: string
|
|
@@ -1,24 +1,46 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentType, HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { BoxProps, TextFieldProps } from '@mui/material';
|
|
3
3
|
import { IFormInputBase } from '../types';
|
|
4
4
|
import type { AutocompleteRenderOptionState } from '@mui/material';
|
|
5
5
|
import type { IRichTooltipPanelConfig } from '../../components/rich-tooltip';
|
|
6
6
|
export interface ISelectWithApiOption<TOther = any> {
|
|
7
|
+
/** Unique identifier or value of the option item. */
|
|
7
8
|
value: string;
|
|
9
|
+
/** Human-readable display label for the option item. @default undefined */
|
|
8
10
|
label?: string;
|
|
11
|
+
/** Additional custom metadata payload associated with the option item. @default undefined */
|
|
9
12
|
other?: TOther;
|
|
10
13
|
}
|
|
11
14
|
export interface ISelectWithApiPropsSlots<O extends ISelectWithApiOption = ISelectWithApiOption> {
|
|
15
|
+
/** Custom props passed to the internal MUI TextField component. @default undefined */
|
|
12
16
|
textFieldProps?: TextFieldProps;
|
|
17
|
+
/** Custom props passed to the root Box wrapper container. @default undefined */
|
|
13
18
|
wrapProps?: BoxProps;
|
|
14
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Custom renderer for the entire option row.
|
|
21
|
+
* Note: Providing `renderOption` will override the entire row layout, including `renderEndOption`.
|
|
22
|
+
* @default undefined
|
|
23
|
+
*/
|
|
24
|
+
renderOption?: (props: HTMLAttributes<HTMLElement>, option: O, state: AutocompleteRenderOptionState) => ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Render custom content at the end (right side) of each option row.
|
|
27
|
+
* If a string is returned, it is automatically wrapped in a Typography element.
|
|
28
|
+
* Note: `renderOption` takes precedence and will override this function if both are defined.
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
renderEndOption?: (option: O, state: AutocompleteRenderOptionState) => ReactNode;
|
|
15
32
|
}
|
|
16
33
|
export type ISelectWithApiFetchData<O extends ISelectWithApiOption> = (value?: string, signal?: AbortSignal) => Promise<O[]>;
|
|
17
34
|
export interface ISelectWithApiProps<T, O extends ISelectWithApiOption = ISelectWithApiOption> extends IFormInputBase<T, ISelectWithApiPropsSlots<O>>, ISelectWithApiParams<O> {
|
|
35
|
+
/** Placeholder text displayed inside the search input when empty. @default 'Select [label]' */
|
|
18
36
|
placeholder?: string;
|
|
37
|
+
/** Configuration for rendering an interactive help tooltip panel beside the label. @default undefined */
|
|
19
38
|
tooltip?: IRichTooltipPanelConfig;
|
|
39
|
+
/** Callback fired when an option is selected or cleared. @default undefined */
|
|
20
40
|
onChange?: (value: O | null) => void;
|
|
41
|
+
/** List of option values/IDs to filter out or exclude from dropdown options. @default [] */
|
|
21
42
|
existedIds?: string[];
|
|
43
|
+
/** Custom component slots overrides. @default undefined */
|
|
22
44
|
slots?: ISelectWithApiPropsSlots<O>;
|
|
23
45
|
}
|
|
24
46
|
export interface ISelectWithApiState<O extends ISelectWithApiOption> {
|
|
@@ -29,10 +51,26 @@ export interface ISelectWithApiState<O extends ISelectWithApiOption> {
|
|
|
29
51
|
loading?: boolean;
|
|
30
52
|
}
|
|
31
53
|
export interface ISelectWithApiParams<O extends ISelectWithApiOption = ISelectWithApiOption> {
|
|
54
|
+
/** Placeholder text displayed inside the search input when empty. @default 'Select [label]' */
|
|
32
55
|
placeholder?: string;
|
|
56
|
+
/** Async function to fetch options dynamically based on search keyword. @default () => Promise.resolve([]) */
|
|
33
57
|
fetchData?: ISelectWithApiFetchData<O>;
|
|
58
|
+
/** Configuration for rendering an interactive help tooltip panel beside the label. @default undefined */
|
|
34
59
|
tooltip?: IRichTooltipPanelConfig;
|
|
35
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Custom renderer for the entire option row.
|
|
62
|
+
* Note: Providing `renderOption` will override the entire row layout, including `renderEndOption`.
|
|
63
|
+
* @default undefined
|
|
64
|
+
*/
|
|
65
|
+
renderOption?: (props: HTMLAttributes<HTMLElement>, option: O, state: AutocompleteRenderOptionState) => ReactNode;
|
|
66
|
+
/**
|
|
67
|
+
* Render custom content at the end (right side) of each option row.
|
|
68
|
+
* If a string is returned, it is automatically wrapped in a Typography element.
|
|
69
|
+
* Note: `renderOption` takes precedence and will override this function if both are defined.
|
|
70
|
+
* @default undefined
|
|
71
|
+
*/
|
|
72
|
+
renderEndOption?: (option: O, state: AutocompleteRenderOptionState) => ReactNode;
|
|
73
|
+
/** Custom component slots overrides. @default undefined */
|
|
36
74
|
slots?: ISelectWithApiPropsSlots<O>;
|
|
37
75
|
}
|
|
38
76
|
export interface ISelectWithApiHandle {
|