@payloadcms/ui 3.34.0-canary.3 → 3.34.0-canary.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE/F,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAA;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,aAAa,EAAE,YAAY,EAAE,CAAA;IACtC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,SAAS,CAAA;IACxC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,OAAO,KAAK,EAAE,QAAQ,EAA2B,qBAAqB,EAAE,MAAM,SAAS,CAAA;AASvF,OAAO,cAAc,CAAA;AAKrB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA+JrC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE/F,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAA;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,aAAa,EAAE,YAAY,EAAE,CAAA;IACtC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,SAAS,CAAA;IACxC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,OAAO,KAAK,EAAE,QAAQ,EAA2B,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAWvF,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA4KrC,CAAA"}
@@ -7,8 +7,9 @@ import { useEffectEvent } from '../../../hooks/useEffectEvent.js';
7
7
  import { useTranslation } from '../../../providers/Translation/index.js';
8
8
  import { Button } from '../../Button/index.js';
9
9
  import { ReactSelect } from '../../ReactSelect/index.js';
10
- import './index.scss';
11
10
  import { DefaultFilter } from './DefaultFilter/index.js';
11
+ import { getOperatorValueTypes } from './validOperators.js';
12
+ import './index.scss';
12
13
  const baseClass = 'condition';
13
14
  export const Condition = props => {
14
15
  const {
@@ -69,12 +70,20 @@ export const Condition = props => {
69
70
  });
70
71
  }, [andIndex, operator, orIndex, reducedFields, updateCondition]);
71
72
  const handleOperatorChange = useCallback(async operator_0 => {
73
+ const operatorValueTypes = getOperatorValueTypes(reducedField.field.type);
74
+ const validOperatorValue = operatorValueTypes[operator_0.value] || 'any';
75
+ const isValidValue = validOperatorValue === 'any' || typeof value === validOperatorValue || validOperatorValue === 'boolean' && (value === 'true' || value === 'false');
76
+ if (!isValidValue) {
77
+ // if the current value is not valid for the new operator
78
+ // reset the value before passing it to updateCondition
79
+ setInternalValue(undefined);
80
+ }
72
81
  await updateCondition({
73
82
  andIndex,
74
83
  field: reducedField,
75
84
  operator: operator_0.value,
76
85
  orIndex,
77
- value
86
+ value: isValidValue ? value : undefined
78
87
  });
79
88
  }, [andIndex, reducedField, orIndex, updateCondition, value]);
80
89
  return /*#__PURE__*/_jsx("div", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","useDebounce","useEffectEvent","useTranslation","Button","ReactSelect","DefaultFilter","baseClass","Condition","props","addCondition","andIndex","fieldName","filterOptions","operator","orIndex","reducedFields","removeCondition","RenderedFilter","updateCondition","value","t","reducedField","find","field","internalValue","setInternalValue","debouncedValue","booleanSelect","includes","type","valueOptions","label","options","updateValue","disabled","admin","disableListFilter","handleFieldChange","undefined","option","handleOperatorChange","_jsx","className","_jsxs","isClearable","onChange","filter","operators","o","internalField","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { AddCondition, ReducedField, RemoveCondition, UpdateCondition } from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldName: string\n readonly filterOptions: ResolvedFilterOptions\n readonly operator: Operator\n readonly orIndex: number\n readonly reducedFields: ReducedField[]\n readonly removeCondition: RemoveCondition\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: UpdateCondition\n readonly value: string\n}\n\nimport type { Operator, Option as PayloadOption, ResolvedFilterOptions } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../../hooks/useEffectEvent.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport './index.scss'\nimport { DefaultFilter } from './DefaultFilter/index.js'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldName,\n filterOptions,\n operator,\n orIndex,\n reducedFields,\n removeCondition,\n RenderedFilter,\n updateCondition,\n value,\n } = props\n\n const { t } = useTranslation()\n\n const reducedField = reducedFields.find((field) => field.value === fieldName)\n\n const [internalValue, setInternalValue] = useState<string>(value)\n\n const debouncedValue = useDebounce(internalValue, 300)\n\n const booleanSelect = ['exists'].includes(operator) || reducedField?.field?.type === 'checkbox'\n\n let valueOptions: PayloadOption[] = []\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (reducedField?.field && 'options' in reducedField.field) {\n valueOptions = reducedField.field.options\n }\n\n const updateValue = useEffectEvent(async (debouncedValue) => {\n if (operator) {\n await updateCondition({\n andIndex,\n field: reducedField,\n operator,\n orIndex,\n value: debouncedValue === null ? '' : debouncedValue,\n })\n }\n })\n\n useEffect(() => {\n void updateValue(debouncedValue)\n }, [debouncedValue])\n\n const disabled =\n (!reducedField?.value && typeof reducedField?.value !== 'number') ||\n reducedField?.field?.admin?.disableListFilter\n\n const handleFieldChange = useCallback(\n async (field: Option<string>) => {\n setInternalValue(undefined)\n await updateCondition({\n andIndex,\n field: reducedFields.find((option) => option.value === field.value),\n operator,\n orIndex,\n value: undefined,\n })\n },\n [andIndex, operator, orIndex, reducedFields, updateCondition],\n )\n\n const handleOperatorChange = useCallback(\n async (operator: Option<Operator>) => {\n await updateCondition({\n andIndex,\n field: reducedField,\n operator: operator.value,\n orIndex,\n value,\n })\n },\n [andIndex, reducedField, orIndex, updateCondition, value],\n )\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleFieldChange}\n options={reducedFields.filter((field) => !field.field.admin.disableListFilter)}\n value={\n reducedField || {\n value: reducedField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleOperatorChange}\n options={reducedField?.operators}\n value={reducedField?.operators.find((o) => operator === o.value) || null}\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={\n !operator || !reducedField || reducedField?.field?.admin?.disableListFilter\n }\n filterOptions={filterOptions}\n internalField={reducedField}\n onChange={setInternalValue}\n operator={operator}\n options={valueOptions}\n value={internalValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAsBxD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,OAAO;AACP,SAASC,aAAa,QAAQ;AAE9B,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,S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,OAAA,EAASA,CAAA,KACP5C,YAAA,CAAa;YACXC,QAAA,EAAUA,QAAA,GAAW;YACrBa,KAAA,EAAOR,aAAA,CAAcO,IAAI,CAAEC,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAACY,KAAK,EAAEC,iBAAA;YACzDtB,OAAA;YACAyC,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","useDebounce","useEffectEvent","useTranslation","Button","ReactSelect","DefaultFilter","getOperatorValueTypes","baseClass","Condition","props","addCondition","andIndex","fieldName","filterOptions","operator","orIndex","reducedFields","removeCondition","RenderedFilter","updateCondition","value","t","reducedField","find","field","internalValue","setInternalValue","debouncedValue","booleanSelect","includes","type","valueOptions","label","options","updateValue","disabled","admin","disableListFilter","handleFieldChange","undefined","option","handleOperatorChange","operatorValueTypes","validOperatorValue","isValidValue","_jsx","className","_jsxs","isClearable","onChange","filter","operators","o","internalField","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { AddCondition, ReducedField, RemoveCondition, UpdateCondition } from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldName: string\n readonly filterOptions: ResolvedFilterOptions\n readonly operator: Operator\n readonly orIndex: number\n readonly reducedFields: ReducedField[]\n readonly removeCondition: RemoveCondition\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: UpdateCondition\n readonly value: string\n}\n\nimport type { Operator, Option as PayloadOption, ResolvedFilterOptions } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../../hooks/useEffectEvent.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DefaultFilter } from './DefaultFilter/index.js'\nimport { getOperatorValueTypes } from './validOperators.js'\nimport './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldName,\n filterOptions,\n operator,\n orIndex,\n reducedFields,\n removeCondition,\n RenderedFilter,\n updateCondition,\n value,\n } = props\n\n const { t } = useTranslation()\n\n const reducedField = reducedFields.find((field) => field.value === fieldName)\n\n const [internalValue, setInternalValue] = useState<string>(value)\n\n const debouncedValue = useDebounce(internalValue, 300)\n\n const booleanSelect = ['exists'].includes(operator) || reducedField?.field?.type === 'checkbox'\n\n let valueOptions: PayloadOption[] = []\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (reducedField?.field && 'options' in reducedField.field) {\n valueOptions = reducedField.field.options\n }\n\n const updateValue = useEffectEvent(async (debouncedValue) => {\n if (operator) {\n await updateCondition({\n andIndex,\n field: reducedField,\n operator,\n orIndex,\n value: debouncedValue === null ? '' : debouncedValue,\n })\n }\n })\n\n useEffect(() => {\n void updateValue(debouncedValue)\n }, [debouncedValue])\n\n const disabled =\n (!reducedField?.value && typeof reducedField?.value !== 'number') ||\n reducedField?.field?.admin?.disableListFilter\n\n const handleFieldChange = useCallback(\n async (field: Option<string>) => {\n setInternalValue(undefined)\n await updateCondition({\n andIndex,\n field: reducedFields.find((option) => option.value === field.value),\n operator,\n orIndex,\n value: undefined,\n })\n },\n [andIndex, operator, orIndex, reducedFields, updateCondition],\n )\n\n const handleOperatorChange = useCallback(\n async (operator: Option<Operator>) => {\n const operatorValueTypes = getOperatorValueTypes(reducedField.field.type)\n const validOperatorValue = operatorValueTypes[operator.value] || 'any'\n const isValidValue =\n validOperatorValue === 'any' ||\n typeof value === validOperatorValue ||\n (validOperatorValue === 'boolean' && (value === 'true' || value === 'false'))\n\n if (!isValidValue) {\n // if the current value is not valid for the new operator\n // reset the value before passing it to updateCondition\n setInternalValue(undefined)\n }\n\n await updateCondition({\n andIndex,\n field: reducedField,\n operator: operator.value,\n orIndex,\n value: isValidValue ? value : undefined,\n })\n },\n [andIndex, reducedField, orIndex, updateCondition, value],\n )\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleFieldChange}\n options={reducedFields.filter((field) => !field.field.admin.disableListFilter)}\n value={\n reducedField || {\n value: reducedField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleOperatorChange}\n options={reducedField?.operators}\n value={reducedField?.operators.find((o) => operator === o.value) || null}\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={\n !operator || !reducedField || reducedField?.field?.admin?.disableListFilter\n }\n filterOptions={filterOptions}\n internalField={reducedField}\n onChange={setInternalValue}\n operator={operator}\n options={valueOptions}\n value={internalValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAsBxD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cA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AgBA,YAAA,EAAcE,KAAA,EAAOY,KAAA,EAAOC,iBAAA;YAE5DxB,aAAA,EAAeA,aAAA;YACfwC,aAAA,EAAe/B,YAAA;YACf2B,QAAA,EAAUvB,gBAAA;YACVZ,QAAA,EAAUA,QAAA;YACVmB,OAAA,EAASF,YAAA;YACTX,KAAA,EAAOK,aAAA,IAAiB;;;uBAKhCsB,KAAA,CAAC;QAAID,SAAA,EAAW,GAAGvC,SAAA,WAAoB;gCACrCsC,IAAA,CAAC1C,MAAA;UACCmD,WAAA,EAAY;UACZR,SAAA,EAAW,GAAGvC,SAAA,kBAA2B;UACzCgD,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACPxC,eAAA,CAAgB;YACdN,QAAA;YACAI;UACF;UAEF2C,KAAK;yBAEPb,IAAA,CAAC1C,MAAA;UACCmD,WAAA,EAAY;UACZR,SAAA,EAAW,GAAGvC,SAAA,eAAwB;UACtCgD,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACP/C,YAAA,CAAa;YACXC,QAAA,EAAUA,QAAA,GAAW;YACrBa,KAAA,EAAOR,aAAA,CAAcO,IAAI,CAAEC,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAACY,KAAK,EAAEC,iBAAA;YACzDtB,OAAA;YACA4C,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ export declare const getOperatorValueTypes: (fieldType: any) => {
2
+ all: string;
3
+ contains: string;
4
+ equals: string;
5
+ exists: string;
6
+ greater_than: string;
7
+ greater_than_equal: string;
8
+ in: string;
9
+ intersects: string;
10
+ less_than: string;
11
+ less_than_equal: string;
12
+ like: string;
13
+ near: string;
14
+ not_equals: string;
15
+ not_in: string;
16
+ not_like: string;
17
+ within: string;
18
+ };
19
+ //# sourceMappingURL=validOperators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validOperators.d.ts","sourceRoot":"","sources":["../../../../src/elements/WhereBuilder/Condition/validOperators.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;CAiCjC,CAAA"}
@@ -0,0 +1,35 @@
1
+ export const getOperatorValueTypes = fieldType => {
2
+ return {
3
+ all: 'any',
4
+ contains: 'string',
5
+ equals: 'any',
6
+ /*
7
+ * exists:
8
+ * The expected value is boolean, but it's passed as a string ('true' or 'false').
9
+ * Need to additionally check if the value is strictly 'true' or 'false' as a string,
10
+ * rather than using a direct typeof comparison.
11
+ * This is handled as:
12
+ * validOperatorValue === 'boolean' && (value === 'true' || value === 'false')
13
+ */
14
+ exists: 'boolean',
15
+ /*
16
+ * greater_than, greater_than_equal, less_than, less_than_equal:
17
+ * Used for number and date fields:
18
+ * - For date fields, the value is an object (e.g., Mon Feb 17 2025 12:00:00 GMT+0000).
19
+ * - For number fields, the value is a string representing the number.
20
+ */
21
+ greater_than: fieldType === 'date' ? 'object' : 'string',
22
+ greater_than_equal: fieldType === 'date' ? 'object' : 'string',
23
+ in: 'any',
24
+ intersects: 'any',
25
+ less_than: fieldType === 'date' ? 'object' : 'string',
26
+ less_than_equal: fieldType === 'date' ? 'object' : 'string',
27
+ like: 'string',
28
+ near: 'any',
29
+ not_equals: 'any',
30
+ not_in: 'any',
31
+ not_like: 'string',
32
+ within: 'any'
33
+ };
34
+ };
35
+ //# sourceMappingURL=validOperators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validOperators.js","names":["getOperatorValueTypes","fieldType","all","contains","equals","exists","greater_than","greater_than_equal","in","intersects","less_than","less_than_equal","like","near","not_equals","not_in","not_like","within"],"sources":["../../../../src/elements/WhereBuilder/Condition/validOperators.ts"],"sourcesContent":["export const getOperatorValueTypes = (fieldType) => {\n return {\n all: 'any',\n contains: 'string',\n equals: 'any',\n /*\n * exists:\n * The expected value is boolean, but it's passed as a string ('true' or 'false').\n * Need to additionally check if the value is strictly 'true' or 'false' as a string,\n * rather than using a direct typeof comparison.\n * This is handled as:\n * validOperatorValue === 'boolean' && (value === 'true' || value === 'false')\n */\n exists: 'boolean',\n /*\n * greater_than, greater_than_equal, less_than, less_than_equal:\n * Used for number and date fields:\n * - For date fields, the value is an object (e.g., Mon Feb 17 2025 12:00:00 GMT+0000).\n * - For number fields, the value is a string representing the number.\n */\n greater_than: fieldType === 'date' ? 'object' : 'string',\n greater_than_equal: fieldType === 'date' ? 'object' : 'string',\n in: 'any',\n intersects: 'any',\n less_than: fieldType === 'date' ? 'object' : 'string',\n less_than_equal: fieldType === 'date' ? 'object' : 'string',\n like: 'string',\n near: 'any',\n not_equals: 'any',\n not_in: 'any',\n not_like: 'string',\n within: 'any',\n }\n}\n"],"mappings":"AAAA,OAAO,MAAMA,qBAAA,GAAyBC,SAAA;EACpC,OAAO;IACLC,GAAA,EAAK;IACLC,QAAA,EAAU;IACVC,MAAA,EAAQ;IACR;;;;;;;;IAQAC,MAAA,EAAQ;IACR;;;;;;IAMAC,YAAA,EAAcL,SAAA,KAAc,SAAS,WAAW;IAChDM,kBAAA,EAAoBN,SAAA,KAAc,SAAS,WAAW;IACtDO,EAAA,EAAI;IACJC,UAAA,EAAY;IACZC,SAAA,EAAWT,SAAA,KAAc,SAAS,WAAW;IAC7CU,eAAA,EAAiBV,SAAA,KAAc,SAAS,WAAW;IACnDW,IAAA,EAAM;IACNC,IAAA,EAAM;IACNC,UAAA,EAAY;IACZC,MAAA,EAAQ;IACRC,QAAA,EAAU;IACVC,MAAA,EAAQ;EACV;AACF","ignoreList":[]}