dinocollab-core 2.2.48 → 2.2.49
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/filter-bar/index.js +1 -1
- package/dist/src/filter-bar/components/filter-input.js +1 -1
- package/dist/src/filter-bar/components/filter-input.js.map +1 -1
- package/dist/src/filter-bar/components/filter-input.units.js +1 -1
- package/dist/src/filter-bar/components/filter-input.units.js.map +1 -1
- package/dist/src/filter-bar/components/popper-custom.js +1 -1
- package/dist/src/filter-bar/components/popper-custom.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/helpers.js +1 -1
- package/dist/src/filter-bar/helpers.js.map +1 -1
- package/dist/src/filter-bar/hooks.js +1 -1
- package/dist/src/filter-bar/hooks.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/menu/create-form-field-datetime.js +1 -1
- package/dist/src/filter-bar/menu/create-form-field-datetime.js.map +1 -1
- package/dist/src/filter-bar/menu/create-form-field-select-with-api.js +2 -0
- package/dist/src/filter-bar/menu/create-form-field-select-with-api.js.map +1 -0
- package/dist/src/filter-bar/menu/create-form-field-select.fallback.js +1 -1
- package/dist/src/filter-bar/menu/create-form-field-select.fallback.js.map +1 -1
- package/dist/src/filter-bar/menu/create-form-field-select.js +1 -1
- package/dist/src/filter-bar/menu/create-form-field-select.js.map +1 -1
- package/dist/src/form/create.form-base.js +1 -1
- package/dist/src/form/helpers.js +1 -1
- package/dist/src/table/create.table.js +1 -1
- package/dist/src/utils/helpers.js +1 -1
- package/dist/types/filter-bar/components/filter-input.types.d.ts +1 -0
- package/dist/types/filter-bar/components/filter-input.units.d.ts +1 -0
- package/dist/types/filter-bar/components/popper-custom.d.ts +3 -0
- package/dist/types/filter-bar/convert-to-graphql.d.ts +28 -2
- package/dist/types/filter-bar/index.d.ts +2 -0
- package/dist/types/filter-bar/index.dino.d.ts +4 -4
- package/dist/types/filter-bar/menu/create-form-field-select-with-api.d.ts +51 -0
- package/dist/types/filter-bar/menu/create-form-field-select.d.ts +4 -2
- package/dist/types/filter-bar/menu/create-form-field-select.fallback.d.ts +0 -2
- package/package.json +1 -1
- package/dist/src/filter-bar/menu/create-form-field-select-multiple.js +0 -2
- package/dist/src/filter-bar/menu/create-form-field-select-multiple.js.map +0 -1
- package/dist/types/filter-bar/menu/create-form-field-select-multiple.d.ts +0 -45
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import type { IFieldSelectOption } from './create-form-field-select';
|
|
3
|
+
import type { TFieldValid, TLogic } from '../types';
|
|
4
|
+
import type { IFieldMenuConfig, IFilterMenuFormProps } from './types';
|
|
5
|
+
/** Props for the `FormFieldSelectWithApi` component returned by `createFormFieldSelectWithApi`. Extends the base filter-menu form props. */
|
|
6
|
+
export interface IFormFieldSelectWithApiProps<T> extends IFilterMenuFormProps<T> {
|
|
7
|
+
/** Callback function to handle errors */
|
|
8
|
+
onError?: () => void;
|
|
9
|
+
/** Optional content to render at the top of the form */
|
|
10
|
+
top?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/** Parameters passed to `createFormFieldSelectWithApi` to configure the generated component. */
|
|
13
|
+
export interface IFormFieldSelectWithApiParam<T> {
|
|
14
|
+
/** Optional configuration for the form field */
|
|
15
|
+
config?: IFieldMenuConfig<T>;
|
|
16
|
+
/** Function to fetch options asynchronously based on user input query */
|
|
17
|
+
fetchOptions: (query: string, signal?: AbortSignal) => Promise<IFieldSelectOption[]> | IFieldSelectOption[];
|
|
18
|
+
/** Debounce delay for typing in milliseconds @default 300 */
|
|
19
|
+
debounceMs?: number;
|
|
20
|
+
/** Force a specific logic (and/or) for this field, overriding the default or user-selected logic */
|
|
21
|
+
forceLogic?: TLogic;
|
|
22
|
+
/** Maximum number of values that can be selected for this field */
|
|
23
|
+
maxValueCount?: number;
|
|
24
|
+
/** Optional content to render at the top of the form */
|
|
25
|
+
top?: ReactNode;
|
|
26
|
+
/** Placeholder for the search text field @default 'Search...' */
|
|
27
|
+
searchPlaceholder?: string;
|
|
28
|
+
/** Optional function to map selected value back to its label representation */
|
|
29
|
+
mapValueToLabel?: (value: TFieldValid) => string;
|
|
30
|
+
/** Custom storage key for saving option labels to localStorage. Defaults to 'dino-filter-api-labels' */
|
|
31
|
+
storageKey?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Factory function that creates a `FormFieldSelectWithApi` filter-menu component.
|
|
35
|
+
*
|
|
36
|
+
* The generated component renders a search field and a list of options fetched from an API
|
|
37
|
+
* based on user typing. Supports both single-select (RadioGroup) and multi-select (FormGroup/Checkboxes)
|
|
38
|
+
* based on the `config.singleValue` setting.
|
|
39
|
+
*
|
|
40
|
+
* @param params - Static configuration (fetchOptions, debounce settings, etc.)
|
|
41
|
+
* @returns A React FC ready to be used as a filter-menu field component
|
|
42
|
+
*/
|
|
43
|
+
declare function createFormFieldSelectWithApi<T>(params: IFormFieldSelectWithApiParam<T>): FC<IFormFieldSelectWithApiProps<T>>;
|
|
44
|
+
export default createFormFieldSelectWithApi;
|
|
45
|
+
export declare function saveOptionLabelsToLocal(field: string, options: {
|
|
46
|
+
value: string;
|
|
47
|
+
label: string;
|
|
48
|
+
}[], storageKey?: string): void;
|
|
49
|
+
export declare function saveOptionLabelToLocal(field: string, value: string, label: string, storageKey?: string): void;
|
|
50
|
+
export declare function getOptionLabelFromLocal(field: string, value: string, storageKey?: string): string | undefined;
|
|
51
|
+
export declare function formatterSelectWithApi<T = any>(field: keyof T | string, storageKey?: string): (value: TFieldValid) => string;
|
|
@@ -8,7 +8,7 @@ export interface IFormFieldSelectProps<T> extends IFilterMenuFormProps<T> {
|
|
|
8
8
|
/** Optional content to render at the top of the form */
|
|
9
9
|
top?: ReactNode;
|
|
10
10
|
}
|
|
11
|
-
/** A single option item rendered as a radio button inside the select filter menu. */
|
|
11
|
+
/** A single option item rendered as a radio button or checkbox inside the select filter menu. */
|
|
12
12
|
export interface IFieldSelectOption {
|
|
13
13
|
value: TFieldValid;
|
|
14
14
|
label?: string;
|
|
@@ -27,11 +27,13 @@ export interface IFormFieldSelectParam<T> {
|
|
|
27
27
|
maxValueCount?: number;
|
|
28
28
|
/** Optional content to render at the top of the form */
|
|
29
29
|
top?: ReactNode;
|
|
30
|
+
/** If true, disables the field after submission (only for multi-select). @default false */
|
|
31
|
+
disabledAfterSubmit?: boolean;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* Factory function that creates a `FormFieldSelect` filter-menu component.
|
|
33
35
|
*
|
|
34
|
-
* The generated component renders a
|
|
36
|
+
* The generated component renders a list of options (radios or checkboxes) inside a
|
|
35
37
|
* popper/menu panel. It supports:
|
|
36
38
|
* - Single or multi-value selection (controlled by `config.singleValue`)
|
|
37
39
|
* - OR / AND logic toggle when more than one value is selected
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dispatch, FC, ReactNode, SetStateAction } from 'react';
|
|
2
2
|
import { TFetchStatus } from './types';
|
|
3
3
|
import { IFormFieldSelectParam, IFormFieldSelectProps } from './create-form-field-select';
|
|
4
|
-
import { IFormFieldSelectMultipleParam, IFormFieldSelectMultipleProps } from './create-form-field-select-multiple';
|
|
5
4
|
type IFallbackPropsBase = {
|
|
6
5
|
renderTop?: (param?: {
|
|
7
6
|
setStatus: Dispatch<SetStateAction<TFetchStatus>>;
|
|
@@ -9,5 +8,4 @@ type IFallbackPropsBase = {
|
|
|
9
8
|
}) => ReactNode;
|
|
10
9
|
};
|
|
11
10
|
export declare function createFormFieldSelectWithFallback<T>(params: IFormFieldSelectParam<T> & IFallbackPropsBase): FC<IFormFieldSelectProps<T>>;
|
|
12
|
-
export declare function createFormFieldSelectMultipleWithFallback<T>(params: IFormFieldSelectMultipleParam<T> & IFallbackPropsBase): FC<IFormFieldSelectMultipleProps<T>>;
|
|
13
11
|
export {};
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{slicedToArray as e,toConsumableArray as l,asyncToGenerator as n,defineProperty as o,regenerator as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as r,jsxs as t}from"react/jsx-runtime";import{useMemo as a,useState as u,useRef as c,useEffect as s}from"react";import{styled as d,Box as v,Typography as m,CircularProgress as f,Button as p,FormGroup as b,FormControlLabel as h,Checkbox as g}from"@mui/material";import x from"@mui/icons-material/Info";import{DEFAULT_LOGIC as y}from"../helpers.js";import{createChipViewers as C}from"../components/chip-viewer.js";import{PopperContent as k,PopperBody as A,PopperFooter as V}from"../components/popper-custom.js";import{ButtonBack as j,ChipDark as z,FilterLogicToggle as S}from"../components/ui.units.js";import{getErrorMessage as w}from"../../form/helpers.js";function O(d){var O=C(),I=(d||{}).options,R=void 0===I?[]:I;return function(C){var I,T,B,E,F,N=a(function(){return Object.assign({},C.currentConfig,null==d?void 0:d.config)},[null==d?void 0:d.config,C.currentConfig]),D=null!==(I=null==N?void 0:N.defaultLogic)&&void 0!==I?I:y,M=C.value,P=void 0===M?{values:[]}:M,_=u(null!==(T=P.logic)&&void 0!==T?T:D),G=e(_,2),H=G[0],U=G[1],q=null!==(B=null==d?void 0:d.forceLogic)&&void 0!==B?B:H,J=null!==(E=null==N?void 0:N.label)&&void 0!==E?E:N.field.toString(),K=u([]),Q=e(K,2),W=Q[0],X=Q[1],Y=u(null!=d&&d.fetchOptions?"loading":"loaded"),Z=e(Y,2),$=Z[0],ee=Z[1],le=c(null),ne=function(){var e=n(i().m(function e(){var l,n,o,r,t;return i().w(function(e){for(;;)switch(e.p=e.n){case 0:if(null!=d&&d.fetchOptions){e.n=1;break}return e.a(2);case 1:return null===(l=le.current)||void 0===l||l.abort(),n=new AbortController,le.current=n,ee("loading"),e.p=2,e.n=3,d.fetchOptions(n.signal);case 3:o=e.v,X(o),ee("loaded"),e.n=5;break;case 4:e.p=4,t=e.v,null===(r=C.onError)||void 0===r||r.call(C),"AbortError"!==(null==t?void 0:t.name)&&ee("error");case 5:return e.a(2)}},e,null,[[2,4]])}));return function(){return e.apply(this,arguments)}}();s(function(){return ne(),function(){var e;return null===(e=le.current)||void 0===e?void 0:e.abort()}},[]);var oe=null!=d&&d.fetchOptions?W:R,ie=u(function(){return Array.isArray(P.values)?l(P.values):[]}),re=e(ie,2),te=re[0],ae=re[1],ue=Array.isArray(P.values)?P.values:[],ce=H!==(null!==(F=P.logic)&&void 0!==F?F:D),se=te.length!==ue.length||te.some(function(e){return!ue.includes(e)}),de=!se&&!ce,ve=u({}),me=e(ve,2),fe=me[0],pe=me[1],be=function(e){C.onSubmit(N.field,e,N)},he=w(fe,N.field),ge=a(function(){var e=Array.isArray(P.values)?P.values:[P.values];return{field:N.field,items:e.map(function(e){var l;return{value:e,label:null===(l=oe.find(function(l){return l.value===e}))||void 0===l?void 0:l.label}})}},[N.field,P]),xe=null!=(null==d?void 0:d.maxValueCount)&&te.length>d.maxValueCount,ye=null!=(null==d?void 0:d.maxValueCount)&&te.length>=d.maxValueCount,Ce=a(function(){var e=(null==d?void 0:d.top)||C.top;return e?r(v,{sx:{mb:1},children:e}):null},[null==d?void 0:d.top,C.top]),ke=[];return(C.isLoading||"loading"===$)&&ke.push("disabled"),r(L,{className:ke.join(" "),noValidate:!0,onSubmit:function(e){var l;if(e.preventDefault(),se){if(!xe){var n=o({},N.field,te),i=null===(l=C.validator)||void 0===l?void 0:l.run(n);if(pe(i||{}),!i||0===Object.keys(i).length)be({values:te,logic:q})}}else ce&&be({values:P.values,logic:q})},children:t(k,{title:"Filter by ".concat(J),onClose:C.onClose,slots:{beforeTitle:r(j,{size:"small",onClick:C.onBack}),afterTitle:null!=d&&d.forceLogic?null:N.singleValue?r(z,{sx:{ml:1.5},size:"small",label:"Last value only"}):r(S,{sx:{ml:1},value:q,onChange:function(e,l){U(l)}})},children:[t(A,{children:[Ce,N.description&&r(m,{variant:"caption",color:"text.secondary",sx:{mb:1,display:"block"},children:N.description}),null!=(null==d?void 0:d.maxValueCount)&&r(m,{variant:"caption",color:xe?"warning.main":"text.secondary",sx:{mb:.5,display:"block"},children:null!=d&&d.maxValueCount?xe?"Maximum ".concat(d.maxValueCount," value").concat(d.maxValueCount>1?"s":""," selected (limit reached)"):"Up to ".concat(d.maxValueCount," value").concat(d.maxValueCount>1?"s":""," can be selected"):""}),r(O,{sx:{mb:1,borderBottom:"none!important"},label:"Applied",placement:"horizontal",enableMinimalesticView:!0,value:ge,onRemove:C.onRemove}),"loading"===$&&r(v,{sx:{display:"flex",justifyContent:"center",mt:2},children:r(f,{size:20})}),"error"===$&&t(v,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:2,mb:3,gap:1},children:[r(x,{color:"error",fontSize:"large"}),r(m,{variant:"body2",color:"error",children:"Failed to load options"}),r(p,{size:"small",variant:"outlined",color:"error",onClick:ne,children:"Retry"})]}),0===oe.length&&"loaded"===$&&r(m,{variant:"body2",color:"text.secondary",sx:{mt:2},children:"No options available"}),r(b,{className:he.error?"error":"",children:oe.map(function(e,n){var o,i=te.includes(e.value),t=ge.items.some(function(l){return l.value===e.value})&&!0===(null==d?void 0:d.disabledAfterSubmit),a=!i&&ye;return r(h,{value:e.value,disabled:t||a,label:null!==(o=e.label)&&void 0!==o?o:e.value,control:r(g,{name:N.field.toString(),checked:i,onChange:function(n){return o=e.value,i=n.target.checked,void ae(function(e){return i?[].concat(l(e),[o]):e.filter(function(e){return e!==o})});var o,i}})},e.value.toString()+n)})})]}),t(V,{children:[r(p,{size:"small",color:"error",variant:"text",disabled:!P.values||0===P.values.length,onClick:function(){var e;null===(e=C.onRemoveField)||void 0===e||e.call(C,N.field,N)},children:"Clear All"}),r(v,{sx:{flex:1}}),r(p,{size:"small",color:"inherit",variant:"text",onClick:C.onClose,children:"Cancel"}),r(p,{size:"small",type:"submit",color:"primary",variant:"contained",disabled:de,children:"Apply"})]})]})})}}var L=d("form")({position:"relative","&::after":{content:'""',display:"block",position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.12)",filter:"blur(2px)",zIndex:-1,opacity:0,transition:"opacity 0.3s",visibility:"hidden"},"&.disabled":{pointerEvents:"none","&::after":{zIndex:1,opacity:1,visibility:"visible"}}});export{O as default};
|
|
2
|
-
//# sourceMappingURL=create-form-field-select-multiple.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-form-field-select-multiple.js","sources":["../../../../src/filter-bar/menu/create-form-field-select-multiple.tsx"],"sourcesContent":["// Copyright (c) 2024-present, Dinocollab Technologies, Inc. and its affiliates. All rights reserved.\r\n\r\n// imports\r\nimport { useEffect, useMemo, useRef, useState } from 'react'\r\nimport { Box, Button, Checkbox, CircularProgress, FormControlLabel, FormGroup, formGroupClasses, styled, Typography } from '@mui/material'\r\nimport InfoIcon from '@mui/icons-material/Info'\r\nimport { getErrorMessage } from '../../form'\r\nimport { DEFAULT_LOGIC } from '../helpers'\r\nimport { createChipViewers, TChipViewerGroup } from '../components/chip-viewer'\r\nimport { PopperBody, PopperContent, PopperFooter } from '../components/popper-custom'\r\nimport { ButtonBack, ChipDark, FilterLogicToggle } from '../components/ui.units'\r\n// types\r\nimport type { FC, ReactNode } from 'react'\r\nimport type { IPartialError } from '../../form/validator'\r\nimport type { IFieldSelectOption } from './create-form-field-select'\r\nimport type { TFieldModelValid, TFieldValid, TFieldValue, TLogic } from '../types'\r\nimport type { IFieldMenuConfig, IFilterMenuFormProps, TFetchStatus } from './types'\r\n\r\n/** Props for the `FormFieldSelectMultiple` component returned by `createFormFieldSelectMultiple`. Extends the base filter-menu form props. */\r\nexport interface IFormFieldSelectMultipleProps<T> extends IFilterMenuFormProps<T> {\r\n /** Callback function to handle errors */\r\n onError?: () => void\r\n /** Optional content to render at the top of the form */\r\n top?: ReactNode\r\n}\r\n\r\n/** Parameters passed to `createFormFieldSelectMultiple` to configure the generated component. */\r\nexport interface IFormFieldSelectMultipleParam<T> {\r\n /** Optional configuration for the form field */\r\n config?: IFieldMenuConfig<T>\r\n /** List of options for the select field */\r\n options?: IFieldSelectOption[]\r\n /** Function to fetch options asynchronously */\r\n fetchOptions?: (signal?: AbortSignal) => Promise<IFieldSelectOption[]> | IFieldSelectOption[]\r\n /** If true, disables the field after submission. @default false */\r\n disabledAfterSubmit?: boolean\r\n /** Force a fixed logic value, hiding the logic toggle */\r\n forceLogic?: TLogic\r\n /** Maximum number of values that can be selected */\r\n maxValueCount?: number\r\n /** Optional content to render at the top of the form */\r\n top?: ReactNode\r\n}\r\n\r\n/**\r\n * Factory function that creates a `FormFieldSelectMultiple` filter-menu component.\r\n *\r\n * The generated component renders a checkbox list of options inside a\r\n * popper/menu panel, allowing the user to select **multiple values** at once.\r\n * It supports:\r\n * - Controlled checkbox state to prevent uncontrolled→controlled React warnings\r\n * - OR / AND logic toggle when more than one value is applied\r\n * - Chip viewers showing the currently applied values\r\n * - Built-in validation via an optional `validator` prop\r\n * - A loading overlay that disables interaction while `isLoading` is true\r\n *\r\n * @param params - Static configuration (option list, optional field config override)\r\n * @returns A React FC ready to be used as a multi-select filter-menu field component\r\n */\r\nfunction createFormFieldSelectMultiple<T>(params?: IFormFieldSelectMultipleParam<T>) {\r\n const ChipViewers = createChipViewers<T>()\r\n const { options: staticOptions = [] } = params || {}\r\n\r\n const FormFieldSelectMultiple: FC<IFormFieldSelectMultipleProps<T>> = (props) => {\r\n /** Merge `props.currentConfig` with `params.config` (if provided).\r\n * Fields from `params.config` override the corresponding keys in `props.currentConfig`.\r\n * Any keys not present in `params.config` are preserved from `props.currentConfig`.\r\n */\r\n const mergedConfig = useMemo(() => Object.assign({}, props.currentConfig, params?.config), [params?.config, props.currentConfig])\r\n\r\n const defaultLogic: TLogic = mergedConfig?.defaultLogic ?? DEFAULT_LOGIC\r\n const { value = { values: [] } } = props\r\n const [filterLogic, setFilterLogic] = useState<TLogic>(value.logic ?? defaultLogic)\r\n const effectiveLogic = params?.forceLogic ?? filterLogic\r\n\r\n const label = mergedConfig?.label ?? mergedConfig.field.toString()\r\n\r\n const [fetchedOptions, setFetchedOptions] = useState<IFieldSelectOption[]>([])\r\n const [fetchStatus, setFetchStatus] = useState<TFetchStatus>(params?.fetchOptions ? 'loading' : 'loaded')\r\n const abortRef = useRef<AbortController | null>(null)\r\n\r\n const runFetch = async () => {\r\n if (!params?.fetchOptions) return\r\n abortRef.current?.abort()\r\n const controller = new AbortController()\r\n abortRef.current = controller\r\n setFetchStatus('loading')\r\n try {\r\n const res = await params.fetchOptions(controller.signal)\r\n setFetchedOptions(res)\r\n setFetchStatus('loaded')\r\n } catch (error: any) {\r\n props.onError?.()\r\n if (error?.name !== 'AbortError') setFetchStatus('error')\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n runFetch()\r\n return () => abortRef.current?.abort()\r\n }, [])\r\n\r\n const options = params?.fetchOptions ? fetchedOptions : staticOptions\r\n\r\n // Track checked values as controlled state to avoid the uncontrolled→controlled MUI warning\r\n // Initialize directly from value.values so pre-selected values are visible even before fetchOptions resolves\r\n const [checkedValues, setCheckedValues] = useState<TFieldValid[]>(() => {\r\n return Array.isArray(value.values) ? [...value.values] : []\r\n })\r\n\r\n const appliedValues = Array.isArray(value.values) ? value.values : []\r\n const hasLogicChange = filterLogic !== (value.logic ?? defaultLogic)\r\n const hasDataChange = checkedValues.length !== appliedValues.length || checkedValues.some((v) => !appliedValues.includes(v))\r\n const isApplyDisabled = !hasDataChange && !hasLogicChange\r\n\r\n const [errorData, setErrorData] = useState<IPartialError<TFieldModelValid<T>>>({})\r\n\r\n const handleCheckboxChange = (optionValue: TFieldValid, checked: boolean) => {\r\n setCheckedValues((prev) => (checked ? [...prev, optionValue] : prev.filter((v) => v !== optionValue)))\r\n }\r\n\r\n const handleSubmit = (newValue: TFieldValue) => {\r\n props.onSubmit(mergedConfig.field, newValue, mergedConfig)\r\n }\r\n\r\n const handleSubmitForm = (event: React.FormEvent<HTMLFormElement>) => {\r\n event.preventDefault()\r\n\r\n if (!hasDataChange) {\r\n if (hasLogicChange) handleSubmit({ values: value.values, logic: effectiveLogic })\r\n return\r\n }\r\n\r\n if (isMaxReached) return\r\n\r\n const obj = { [mergedConfig.field]: checkedValues } as Partial<TFieldModelValid<T>>\r\n let errorData = props.validator?.run(obj) as IPartialError<TFieldModelValid<T>>\r\n\r\n setErrorData(errorData || {})\r\n\r\n if (!errorData || Object.keys(errorData).length === 0) {\r\n const newValue: TFieldValue = { values: checkedValues, logic: effectiveLogic }\r\n handleSubmit(newValue)\r\n }\r\n }\r\n\r\n const errorResult = getErrorMessage(errorData, mergedConfig.field)\r\n const filterViewerValue = useMemo<TChipViewerGroup<T>>(() => {\r\n const items = Array.isArray(value.values) ? value.values : [value.values]\r\n return {\r\n field: mergedConfig.field,\r\n items: items.map((v) => ({ value: v, label: options.find((o) => o.value === v)?.label }))\r\n }\r\n }, [mergedConfig.field, value])\r\n\r\n const isMaxReached = params?.maxValueCount != null && checkedValues.length > params.maxValueCount\r\n const isMaxReachedValid = params?.maxValueCount != null && checkedValues.length >= params.maxValueCount\r\n\r\n const handleChangeLogic = (newLogic: TLogic) => {\r\n setFilterLogic(newLogic)\r\n }\r\n\r\n const handleClearAll = () => {\r\n props.onRemoveField?.(mergedConfig.field, mergedConfig)\r\n }\r\n\r\n const getMaxReachedText = () => {\r\n if (!params?.maxValueCount) return ''\r\n if (isMaxReached) {\r\n return `Maximum ${params.maxValueCount} value${params.maxValueCount > 1 ? 's' : ''} selected (limit reached)`\r\n } else {\r\n return `Up to ${params.maxValueCount} value${params.maxValueCount > 1 ? 's' : ''} can be selected`\r\n }\r\n }\r\n\r\n const renderAfterTitle = () => {\r\n if (params?.forceLogic) return null\r\n if (mergedConfig.singleValue) return <ChipDark sx={{ ml: 1.5 }} size='small' label='Last value only' />\r\n return <FilterLogicToggle sx={{ ml: 1 }} value={effectiveLogic} onChange={(_, nVal) => handleChangeLogic(nVal)} />\r\n }\r\n\r\n const renderTop = useMemo(() => {\r\n const topContent = params?.top || props.top\r\n if (topContent) return <Box sx={{ mb: 1 }}>{topContent}</Box>\r\n return null\r\n }, [params?.top, props.top])\r\n\r\n const rootClasses: string[] = []\r\n if (props.isLoading || fetchStatus === 'loading') rootClasses.push('disabled')\r\n\r\n return (\r\n <RootStyled className={rootClasses.join(' ')} noValidate onSubmit={handleSubmitForm}>\r\n <PopperContent\r\n title={`Filter by ${label}`}\r\n onClose={props.onClose}\r\n slots={{\r\n beforeTitle: <ButtonBack size='small' onClick={props.onBack} />,\r\n afterTitle: renderAfterTitle()\r\n }}\r\n >\r\n <PopperBody>\r\n {renderTop}\r\n {mergedConfig.description && (\r\n <Typography variant='caption' color='text.secondary' sx={{ mb: 1, display: 'block' }}>\r\n {mergedConfig.description}\r\n </Typography>\r\n )}\r\n {params?.maxValueCount != null && (\r\n <Typography variant='caption' color={isMaxReached ? 'warning.main' : 'text.secondary'} sx={{ mb: 0.5, display: 'block' }}>\r\n {getMaxReachedText()}\r\n </Typography>\r\n )}\r\n <ChipViewers\r\n sx={{ mb: 1, borderBottom: 'none!important' }}\r\n label='Applied'\r\n placement='horizontal'\r\n enableMinimalesticView\r\n value={filterViewerValue}\r\n onRemove={props.onRemove}\r\n />\r\n {fetchStatus === 'loading' && (\r\n <Box sx={{ display: 'flex', justifyContent: 'center', mt: 2 }}>\r\n <CircularProgress size={20} />\r\n </Box>\r\n )}\r\n {fetchStatus === 'error' && (\r\n <Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center', mt: 2, mb: 3, gap: 1 }}>\r\n <InfoIcon color='error' fontSize='large' />\r\n <Typography variant='body2' color='error'>\r\n Failed to load options\r\n </Typography>\r\n <Button size='small' variant='outlined' color='error' onClick={runFetch}>\r\n Retry\r\n </Button>\r\n </Box>\r\n )}\r\n {options.length === 0 && fetchStatus === 'loaded' && (\r\n <Typography variant='body2' color='text.secondary' sx={{ mt: 2 }}>\r\n No options available\r\n </Typography>\r\n )}\r\n <FormGroup className={errorResult.error ? 'error' : ''}>\r\n {options.map((x, i) => {\r\n const isChecked = checkedValues.includes(x.value as TFieldValid)\r\n const isSelected = filterViewerValue.items.some((item) => item.value === x.value)\r\n const disabled = isSelected && params?.disabledAfterSubmit === true\r\n const disableDueToMax = !isChecked && isMaxReachedValid\r\n return (\r\n <FormControlLabel\r\n key={x.value.toString() + i}\r\n value={x.value}\r\n disabled={disabled || disableDueToMax}\r\n label={x.label ?? x.value}\r\n control={\r\n <Checkbox\r\n name={mergedConfig.field.toString()}\r\n checked={isChecked}\r\n onChange={(e) => handleCheckboxChange(x.value as TFieldValid, e.target.checked)}\r\n />\r\n }\r\n />\r\n )\r\n })}\r\n </FormGroup>\r\n </PopperBody>\r\n <PopperFooter>\r\n <Button size='small' color='error' variant='text' disabled={!value.values || value.values.length === 0} onClick={handleClearAll}>\r\n Clear All\r\n </Button>\r\n <Box sx={{ flex: 1 }} />\r\n <Button size='small' color='inherit' variant='text' onClick={props.onClose}>\r\n Cancel\r\n </Button>\r\n <Button size='small' type='submit' color='primary' variant='contained' disabled={isApplyDisabled}>\r\n Apply\r\n </Button>\r\n </PopperFooter>\r\n </PopperContent>\r\n </RootStyled>\r\n )\r\n }\r\n\r\n return FormFieldSelectMultiple\r\n}\r\n\r\nexport default createFormFieldSelectMultiple\r\n\r\nconst RootStyled = styled('form')({\r\n position: 'relative',\r\n '&::after': {\r\n content: '\"\"',\r\n display: 'block',\r\n position: 'absolute',\r\n inset: 0, // top: 0, left: 0, right: 0, bottom: 0\r\n backgroundColor: 'rgba(0, 0, 0, 0.12)',\r\n filter: 'blur(2px)',\r\n zIndex: -1,\r\n opacity: 0,\r\n transition: 'opacity 0.3s',\r\n visibility: 'hidden'\r\n },\r\n '&.disabled': {\r\n pointerEvents: 'none',\r\n '&::after': {\r\n zIndex: 1,\r\n opacity: 1,\r\n visibility: 'visible'\r\n }\r\n }\r\n // [`.${formGroupClasses.root}`]: {}\r\n})\r\n"],"names":["createFormFieldSelectMultiple","params","ChipViewers","createChipViewers","_ref$options","options","staticOptions","props","_mergedConfig$default","_value$logic","_params$forceLogic","_mergedConfig$label","_value$logic2","mergedConfig","useMemo","Object","assign","currentConfig","config","defaultLogic","DEFAULT_LOGIC","_props$value","value","values","_useState","useState","logic","_useState2","_slicedToArray","filterLogic","setFilterLogic","effectiveLogic","forceLogic","label","field","toString","_useState3","_useState4","fetchedOptions","setFetchedOptions","_useState5","fetchOptions","_useState6","fetchStatus","setFetchStatus","abortRef","useRef","runFetch","_ref2","_asyncToGenerator","_regenerator","m","_callee","_abortRef$current","controller","res","_props$onError","_t","w","_context","p","n","a","current","abort","AbortController","signal","v","onError","call","name","apply","this","arguments","useEffect","_abortRef$current2","_useState7","Array","isArray","_toConsumableArray","_useState8","checkedValues","setCheckedValues","appliedValues","hasLogicChange","hasDataChange","length","some","includes","isApplyDisabled","_useState9","_useState0","errorData","setErrorData","handleSubmit","newValue","onSubmit","errorResult","getErrorMessage","filterViewerValue","items","map","_options$find","find","o","isMaxReached","maxValueCount","isMaxReachedValid","renderTop","topContent","top","_jsx","Box","sx","mb","children","rootClasses","isLoading","push","RootStyled","className","join","noValidate","event","_props$validator","preventDefault","obj","_defineProperty","validator","run","keys","_jsxs","PopperContent","title","concat","onClose","slots","beforeTitle","ButtonBack","size","onClick","onBack","afterTitle","singleValue","ChipDark","ml","FilterLogicToggle","onChange","_","nVal","PopperBody","description","Typography","variant","color","display","borderBottom","placement","enableMinimalesticView","onRemove","justifyContent","mt","CircularProgress","flexDirection","alignItems","gap","InfoIcon","fontSize","Button","FormGroup","error","x","i","_x$label","isChecked","disabled","item","disabledAfterSubmit","disableDueToMax","FormControlLabel","control","Checkbox","checked","e","optionValue","target","prev","filter","PopperFooter","_props$onRemoveField","onRemoveField","flex","type","styled","position","content","inset","backgroundColor","zIndex","opacity","transition","visibility","pointerEvents"],"mappings":"6zBA2DA,SAASA,EAAiCC,GACxC,IAAMC,EAAcC,IACgCC,GAAZH,GAAU,CA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C,QAAS,EACTE,WAAY"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { FC, ReactNode } from 'react';
|
|
2
|
-
import type { IFieldSelectOption } from './create-form-field-select';
|
|
3
|
-
import type { TLogic } from '../types';
|
|
4
|
-
import type { IFieldMenuConfig, IFilterMenuFormProps } from './types';
|
|
5
|
-
/** Props for the `FormFieldSelectMultiple` component returned by `createFormFieldSelectMultiple`. Extends the base filter-menu form props. */
|
|
6
|
-
export interface IFormFieldSelectMultipleProps<T> extends IFilterMenuFormProps<T> {
|
|
7
|
-
/** Callback function to handle errors */
|
|
8
|
-
onError?: () => void;
|
|
9
|
-
/** Optional content to render at the top of the form */
|
|
10
|
-
top?: ReactNode;
|
|
11
|
-
}
|
|
12
|
-
/** Parameters passed to `createFormFieldSelectMultiple` to configure the generated component. */
|
|
13
|
-
export interface IFormFieldSelectMultipleParam<T> {
|
|
14
|
-
/** Optional configuration for the form field */
|
|
15
|
-
config?: IFieldMenuConfig<T>;
|
|
16
|
-
/** List of options for the select field */
|
|
17
|
-
options?: IFieldSelectOption[];
|
|
18
|
-
/** Function to fetch options asynchronously */
|
|
19
|
-
fetchOptions?: (signal?: AbortSignal) => Promise<IFieldSelectOption[]> | IFieldSelectOption[];
|
|
20
|
-
/** If true, disables the field after submission. @default false */
|
|
21
|
-
disabledAfterSubmit?: boolean;
|
|
22
|
-
/** Force a fixed logic value, hiding the logic toggle */
|
|
23
|
-
forceLogic?: TLogic;
|
|
24
|
-
/** Maximum number of values that can be selected */
|
|
25
|
-
maxValueCount?: number;
|
|
26
|
-
/** Optional content to render at the top of the form */
|
|
27
|
-
top?: ReactNode;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Factory function that creates a `FormFieldSelectMultiple` filter-menu component.
|
|
31
|
-
*
|
|
32
|
-
* The generated component renders a checkbox list of options inside a
|
|
33
|
-
* popper/menu panel, allowing the user to select **multiple values** at once.
|
|
34
|
-
* It supports:
|
|
35
|
-
* - Controlled checkbox state to prevent uncontrolled→controlled React warnings
|
|
36
|
-
* - OR / AND logic toggle when more than one value is applied
|
|
37
|
-
* - Chip viewers showing the currently applied values
|
|
38
|
-
* - Built-in validation via an optional `validator` prop
|
|
39
|
-
* - A loading overlay that disables interaction while `isLoading` is true
|
|
40
|
-
*
|
|
41
|
-
* @param params - Static configuration (option list, optional field config override)
|
|
42
|
-
* @returns A React FC ready to be used as a multi-select filter-menu field component
|
|
43
|
-
*/
|
|
44
|
-
declare function createFormFieldSelectMultiple<T>(params?: IFormFieldSelectMultipleParam<T>): FC<IFormFieldSelectMultipleProps<T>>;
|
|
45
|
-
export default createFormFieldSelectMultiple;
|