@payloadcms/ui 3.65.0-internal.098b771 → 3.65.0-internal.5b33fe0
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/elements/ReactSelect/MultiValueLabel/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/MultiValueLabel/index.js +18 -9
- package/dist/elements/ReactSelect/MultiValueLabel/index.js.map +1 -1
- package/dist/elements/ReactSelect/ValueContainer/index.d.ts.map +1 -1
- package/dist/elements/ReactSelect/ValueContainer/index.js +19 -7
- package/dist/elements/ReactSelect/ValueContainer/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/withMergedProps/index.d.ts +1 -1
- package/dist/elements/withMergedProps/index.js +1 -1
- package/dist/elements/withMergedProps/index.js.map +1 -1
- package/dist/exports/client/{CodeEditor-IVFMKS4Z.js → CodeEditor-ORMD3ID3.js} +2 -2
- package/dist/exports/client/{chunk-XUCNM5EK.js → chunk-PXD7OIXB.js} +1 -1
- package/dist/exports/client/{chunk-XUCNM5EK.js.map → chunk-PXD7OIXB.js.map} +2 -2
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.js.map +1 -1
- package/dist/fields/Blocks/BlockSelector/BlockSearch/index.d.ts.map +1 -0
- package/dist/fields/Blocks/BlockSelector/BlockSearch/index.js.map +1 -0
- package/dist/fields/Blocks/BlockSelector/index.d.ts +14 -0
- package/dist/fields/Blocks/BlockSelector/index.d.ts.map +1 -0
- package/dist/fields/Blocks/BlockSelector/index.js +116 -0
- package/dist/fields/Blocks/BlockSelector/index.js.map +1 -0
- package/dist/fields/Blocks/BlocksDrawer/index.d.ts +0 -1
- package/dist/fields/Blocks/BlocksDrawer/index.d.ts.map +1 -1
- package/dist/fields/Blocks/BlocksDrawer/index.js +63 -105
- package/dist/fields/Blocks/BlocksDrawer/index.js.map +1 -1
- package/dist/fields/Relationship/select-components/MultiValueLabel/index.js +1 -0
- package/dist/fields/Relationship/select-components/MultiValueLabel/index.js.map +1 -1
- package/dist/fields/Relationship/select-components/SingleValue/index.js +11 -8
- package/dist/fields/Relationship/select-components/SingleValue/index.js.map +1 -1
- package/dist/hooks/useControllableState.d.ts.map +1 -1
- package/dist/hooks/useControllableState.js.map +1 -1
- package/dist/providers/Auth/index.d.ts.map +1 -1
- package/dist/providers/Auth/index.js +10 -8
- package/dist/providers/Auth/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -4
- package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.d.ts.map +0 -1
- package/dist/fields/Blocks/BlocksDrawer/BlockSearch/index.js.map +0 -1
- /package/dist/exports/client/{CodeEditor-IVFMKS4Z.js.map → CodeEditor-ORMD3ID3.js.map} +0 -0
- /package/dist/fields/Blocks/{BlocksDrawer → BlockSelector}/BlockSearch/index.d.ts +0 -0
- /package/dist/fields/Blocks/{BlocksDrawer → BlockSelector}/BlockSearch/index.js +0 -0
- /package/dist/fields/Blocks/{BlocksDrawer → BlockSelector}/BlockSearch/index.scss +0 -0
- /package/dist/fields/Blocks/{BlocksDrawer → BlockSelector}/index.scss +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/ReactSelect/MultiValueLabel/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/ReactSelect/MultiValueLabel/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAqB7D,CAAA"}
|
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { components as SelectComponents } from 'react-select';
|
|
7
|
+
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
6
8
|
import './index.scss';
|
|
7
9
|
const baseClass = 'multi-value-label';
|
|
8
10
|
export const MultiValueLabel = props => {
|
|
9
|
-
// @ts-expect-error-next-line// TODO Fix this - moduleResolution 16 breaks our declare module
|
|
10
11
|
const {
|
|
11
12
|
data,
|
|
12
|
-
selectProps:
|
|
13
|
-
customProps: {
|
|
14
|
-
draggableProps,
|
|
15
|
-
editableProps
|
|
16
|
-
} = {}
|
|
17
|
-
} = {}
|
|
13
|
+
selectProps: t0
|
|
18
14
|
} = props;
|
|
15
|
+
const {
|
|
16
|
+
customProps: t1
|
|
17
|
+
} = t0 === undefined ? {} : t0;
|
|
18
|
+
const {
|
|
19
|
+
draggableProps,
|
|
20
|
+
editableProps
|
|
21
|
+
} = t1 === undefined ? {} : t1;
|
|
22
|
+
const {
|
|
23
|
+
i18n
|
|
24
|
+
} = useTranslation();
|
|
19
25
|
const className = `${baseClass}__text`;
|
|
20
|
-
|
|
26
|
+
const labelText = data.label ? getTranslation(data.label, i18n) : "";
|
|
27
|
+
const titleText = typeof labelText === "string" ? labelText : "";
|
|
28
|
+
return _jsx("div", {
|
|
21
29
|
className: baseClass,
|
|
22
|
-
|
|
30
|
+
title: titleText,
|
|
31
|
+
children: _jsx(SelectComponents.MultiValueLabel, {
|
|
23
32
|
...props,
|
|
24
33
|
innerProps: {
|
|
25
34
|
className,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","components","SelectComponents","baseClass","MultiValueLabel","props","data","selectProps","customProps","draggableProps","editableProps","className","_jsx","innerProps"],"sources":["../../../../src/elements/ReactSelect/MultiValueLabel/index.tsx"],"sourcesContent":["'use client'\nimport type { MultiValueProps } from 'react-select'\n\nimport React from 'react'\nimport { components as SelectComponents } from 'react-select'\n\nimport type { Option } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'multi-value-label'\n\nexport const MultiValueLabel: React.FC<MultiValueProps<Option>> = (props) => {\n // @ts-expect-error-next-line// TODO Fix this - moduleResolution 16 breaks our declare module\n const { data, selectProps: { customProps: { draggableProps, editableProps } = {} } = {} } = props\n\n const className = `${baseClass}__text`\n\n return (\n <div className={baseClass}>\n <SelectComponents.MultiValueLabel\n {...props}\n innerProps={{\n className,\n ...((editableProps && editableProps(data, className, props.selectProps)) || {}),\n ...(draggableProps || {}),\n }}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","React","components","SelectComponents","useTranslation","baseClass","MultiValueLabel","props","data","selectProps","t0","customProps","t1","undefined","draggableProps","editableProps","i18n","className","labelText","label","titleText","_jsx","title","children","innerProps"],"sources":["../../../../src/elements/ReactSelect/MultiValueLabel/index.tsx"],"sourcesContent":["'use client'\nimport type { OptionLabel } from 'payload'\nimport type { MultiValueProps } from 'react-select'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\nimport { components as SelectComponents } from 'react-select'\n\nimport type { Option } from '../types.js'\n\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport './index.scss'\n\nconst baseClass = 'multi-value-label'\n\nexport const MultiValueLabel: React.FC<MultiValueProps<Option>> = (props) => {\n // @ts-expect-error-next-line// TODO Fix this - moduleResolution 16 breaks our declare module\n const { data, selectProps: { customProps: { draggableProps, editableProps } = {} } = {} } = props\n const { i18n } = useTranslation()\n\n const className = `${baseClass}__text`\n const labelText = data.label ? getTranslation(data.label as OptionLabel, i18n) : ''\n const titleText = typeof labelText === 'string' ? labelText : ''\n\n return (\n <div className={baseClass} title={titleText}>\n <SelectComponents.MultiValueLabel\n {...props}\n innerProps={{\n className,\n ...((editableProps && editableProps(data, className, props.selectProps)) || {}),\n ...(draggableProps || {}),\n }}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAClB,SAASC,UAAA,IAAcC,gBAAgB,QAAQ;AAI/C,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,eAAA,GAAqDC,KAAA;EAEhE;IAAAC,IAAA;IAAAC,WAAA,EAAAC;EAAA,IAA4FH,KAAA;EAAjE;IAAAI,WAAA,EAAAC;EAAA,IAAAF,EAA4D,KAAAG,SAAA,QAA5DH,EAA4D;EAA7C;IAAAI,cAAA;IAAAC;EAAA,IAAAH,EAAsC,KAAAC,SAAA,QAAtCD,EAAsC;EAChF;IAAAI;EAAA,IAAiBZ,cAAA;EAEjB,MAAAa,SAAA,GAAkB,GAAAZ,SAAA,QAAoB;EACtC,MAAAa,SAAA,GAAkBV,IAAA,CAAAW,KAAA,GAAanB,cAAA,CAAeQ,IAAA,CAAAW,KAAA,EAA2BH,IAAA,IAAQ;EACjF,MAAAI,SAAA,GAAkB,OAAOF,SAAA,KAAc,WAAWA,SAAA,GAAY;EAAA,OAG5DG,IAAA,CAAC;IAAAJ,SAAA,EAAAZ,SAAA;IAAAiB,KAAA,EAAiCF,SAAA;IAAAG,QAAA,EAChCF,IAAA,CAAAlB,gBAAA,CAAAG,eAAA;MAAA,GACMC,KAAK;MAAAiB,UAAA;QAAAP,SAAA;QAAA,IAGHF,aAAC,IAAiBA,aAAA,CAAcP,IAAA,EAAMS,SAAA,EAAWV,KAAA,CAAAE,WAAiB,OAAQ;QAAA,IAC1EK,cAAA,MAAoB;MAAA;IAAA,C;;CAKlC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/ReactSelect/ValueContainer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/ReactSelect/ValueContainer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAGvD,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAoBrE,CAAA"}
|
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { components as SelectComponents } from 'react-select';
|
|
7
|
+
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
6
8
|
import './index.scss';
|
|
7
9
|
const baseClass = 'value-container';
|
|
8
10
|
export const ValueContainer = props => {
|
|
9
|
-
// @ts-expect-error-next-line // TODO Fix this - moduleResolution 16 breaks our declare module
|
|
10
11
|
const {
|
|
11
|
-
selectProps:
|
|
12
|
-
customProps
|
|
13
|
-
} = {}
|
|
12
|
+
selectProps: t0
|
|
14
13
|
} = props;
|
|
15
|
-
|
|
14
|
+
const {
|
|
15
|
+
customProps,
|
|
16
|
+
value
|
|
17
|
+
} = t0 === undefined ? {} : t0;
|
|
18
|
+
const {
|
|
19
|
+
i18n
|
|
20
|
+
} = useTranslation();
|
|
21
|
+
let titleText = "";
|
|
22
|
+
if (value && !Array.isArray(value) && typeof value === "object" && "label" in value) {
|
|
23
|
+
const labelText = value.label ? getTranslation(value.label, i18n) : "";
|
|
24
|
+
titleText = typeof labelText === "string" ? labelText : "";
|
|
25
|
+
}
|
|
26
|
+
return _jsxs("div", {
|
|
16
27
|
className: baseClass,
|
|
17
28
|
ref: customProps?.droppableRef,
|
|
18
|
-
|
|
29
|
+
title: titleText,
|
|
30
|
+
children: [customProps?.valueContainerLabel && _jsx("span", {
|
|
19
31
|
className: `${baseClass}__label`,
|
|
20
32
|
children: customProps?.valueContainerLabel
|
|
21
|
-
}),
|
|
33
|
+
}), _jsx(SelectComponents.ValueContainer, {
|
|
22
34
|
...props
|
|
23
35
|
})]
|
|
24
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","components","SelectComponents","baseClass","ValueContainer","props","selectProps","customProps","_jsxs","className","ref","droppableRef","valueContainerLabel","_jsx"],"sources":["../../../../src/elements/ReactSelect/ValueContainer/index.tsx"],"sourcesContent":["'use client'\nimport type { ValueContainerProps } from 'react-select'\n\nimport React from 'react'\nimport { components as SelectComponents } from 'react-select'\n\nimport type { Option } from '../types.js'\n\nimport './index.scss'\n\nconst baseClass = 'value-container'\n\nexport const ValueContainer: React.FC<ValueContainerProps<Option, any>> = (props) => {\n // @ts-expect-error-next-line // TODO Fix this - moduleResolution 16 breaks our declare module\n const { selectProps: { customProps } = {} } = props\n\n return (\n <div className={baseClass} ref={customProps?.droppableRef}>\n {customProps?.valueContainerLabel && (\n <span className={`${baseClass}__label`}>{customProps?.valueContainerLabel}</span>\n )}\n <SelectComponents.ValueContainer {...props} />\n </div>\n )\n}\n"],"mappings":"AAAA;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","React","components","SelectComponents","useTranslation","baseClass","ValueContainer","props","selectProps","t0","customProps","value","undefined","i18n","titleText","Array","isArray","labelText","label","_jsxs","className","ref","droppableRef","title","children","valueContainerLabel","_jsx"],"sources":["../../../../src/elements/ReactSelect/ValueContainer/index.tsx"],"sourcesContent":["'use client'\nimport type { OptionLabel } from 'payload'\nimport type { ValueContainerProps } from 'react-select'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\nimport { components as SelectComponents } from 'react-select'\n\nimport type { Option } from '../types.js'\n\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport './index.scss'\n\nconst baseClass = 'value-container'\n\nexport const ValueContainer: React.FC<ValueContainerProps<Option, any>> = (props) => {\n // @ts-expect-error-next-line // TODO Fix this - moduleResolution 16 breaks our declare module\n const { selectProps: { customProps, value } = {} } = props\n const { i18n } = useTranslation()\n\n // Get the title for single-value selects\n let titleText = ''\n if (value && !Array.isArray(value) && typeof value === 'object' && 'label' in value) {\n const labelText = value.label ? getTranslation(value.label as OptionLabel, i18n) : ''\n titleText = typeof labelText === 'string' ? labelText : ''\n }\n\n return (\n <div className={baseClass} ref={customProps?.droppableRef} title={titleText}>\n {customProps?.valueContainerLabel && (\n <span className={`${baseClass}__label`}>{customProps?.valueContainerLabel}</span>\n )}\n <SelectComponents.ValueContainer {...props} />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAClB,SAASC,UAAA,IAAcC,gBAAgB,QAAQ;AAI/C,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,cAAA,GAA6DC,KAAA;EAExE;IAAAC,WAAA,EAAAC;EAAA,IAAqDF,KAAA;EAAhC;IAAAG,WAAA;IAAAC;EAAA,IAAAF,EAA2B,KAAAG,SAAA,QAA3BH,EAA2B;EAChD;IAAAI;EAAA,IAAiBT,cAAA;EAGjB,IAAAU,SAAA,GAAgB;EAAA,IACZH,KAAA,KAAUI,KAAA,CAAAC,OAAA,CAAcL,KAAA,KAAU,OAAOA,KAAA,KAAU,YAAY,WAAWA,KAAA;IAC5E,MAAAM,SAAA,GAAkBN,KAAA,CAAAO,KAAA,GAAclB,cAAA,CAAeW,KAAA,CAAAO,KAAA,EAA4BL,IAAA,IAAQ;IACnFC,SAAA,CAAAA,CAAA,CAAYA,MAAA,CAAOG,SAAA,KAAc,WAAWA,SAAA,GAAY;EAAxD;EAAA,OAIAE,KAAA,CAAC;IAAAC,SAAA,EAAAf,SAAA;IAAAgB,GAAA,EAA+BX,WAAA,EAAAY,YAAA;IAAAC,KAAA,EAAkCT,SAAA;IAAAU,QAAA,GAC/Dd,WAAA,EAAAe,mBAAA,IACCC,IAAA,CAAC;MAAAN,SAAA,EAAgB,GAAAf,SAAA,SAAqB;MAAAmB,QAAA,EAAGd,WAAA,EAAAe;IAAA,C,GAE3CC,IAAA,CAAAvB,gBAAA,CAAAG,cAAA;MAAA,GAAqCC;IAAK,C;;CAGhD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","useDebounce","useEffectEvent","useTranslation","Button","ReactSelect","DefaultFilter","getOperatorValueTypes","baseClass","Condition","props","addCondition","andIndex","fieldPath","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","filterOption","inputValue","data","plainTextLabel","toLowerCase","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 {\n AddCondition,\n ReducedField,\n RemoveCondition,\n UpdateCondition,\n Value,\n} from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldPath: 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: Value\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 fieldPath,\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 === fieldPath)\n\n const [internalValue, setInternalValue] = useState<Value>(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 type: 'value',\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 type: 'field',\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 type: 'operator',\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 filterOption={(option, inputValue) =>\n ((option?.data?.plainTextLabel as string) || option.label)\n .toLowerCase()\n .includes(inputValue.toLowerCase())\n }\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;AA4BxD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,SAASC,qBAAqB,QAAQ;AACtC,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,SAAA,GAA8BC,KAAA;EACzC,MAAM;IACJC,YAAY;IACZC,QAAQ;IACRC,SAAS;IACTC,aAAa;IACbC,QAAQ;IACRC,OAAO;IACPC,aAAa;IACbC,eAAe;IACfC,cAAc;IACdC,eAAe;IACfC;EAAK,CACN,GAAGX,KAAA;EAEJ,MAAM;IAAEY;EAAC,CAAE,GAAGnB,cAAA;EAEd,MAAMoB,YAAA,GAAeN,aAAA,CAAcO,IAAI,CAAEC,KAAA,IAAUA,KAAA,CAAMJ,KAAK,KAAKR,SAAA;EAEnE,MAAM,CAACa,aAAA,EAAeC,gBAAA,CAAiB,GAAG3B,QAAA,CAAgBqB,KAAA;EAE1D,MAAMO,cAAA,GAAiB3B,WAAA,CAAYyB,aAAA,EAAe;EAElD,MAAMG,aAAA,GAAgB,CAAC,SAAS,CAACC,QAAQ,CAACf,QAAA,KAAaQ,YAAA,EAAcE,KAAA,EAAOM,IAAA,KAAS;EAErF,IAAIC,YAAA,GAAgC,EAAE;EAEtC,IAAIH,aAAA,EAAe;IACjBG,YAAA,GAA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AU;UACVC,OAAA,EAASA,CAAA,KACPpD,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;YACAiD,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","fieldPath","filterOptions","operator","orIndex","reducedFields","removeCondition","RenderedFilter","updateCondition","value","t","reducedField","find","field","internalValue","setInternalValue","debouncedValue","booleanSelect","includes","type","valueOptions","label","options","updateValue","undefined","disabled","admin","disableListFilter","handleFieldChange","option","handleOperatorChange","operatorValueTypes","validOperatorValue","isValidValue","_jsx","className","_jsxs","filterOption","inputValue","data","plainTextLabel","toLowerCase","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 {\n AddCondition,\n ReducedField,\n RemoveCondition,\n UpdateCondition,\n Value,\n} from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldPath: 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: Value\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 fieldPath,\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 === fieldPath)\n\n const [internalValue, setInternalValue] = useState<Value>(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: Value) => {\n if (operator) {\n await updateCondition({\n type: 'value',\n andIndex,\n field: reducedField,\n operator,\n orIndex,\n value: debouncedValue === null || debouncedValue === '' ? undefined : 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 type: 'field',\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 type: 'operator',\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 filterOption={(option, inputValue) =>\n ((option?.data?.plainTextLabel as string) || option.label)\n .toLowerCase()\n .includes(inputValue.toLowerCase())\n }\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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AA,CAAMA,KAAK,CAACa,KAAK,EAAEC,iBAAA;YACzDvB,OAAA;YACAiD,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
|
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
* rendering the original component.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
-
* const PredefinedComponent =
|
|
11
|
+
* const PredefinedComponent = withMergedProps({
|
|
12
12
|
* Component: OriginalComponent,
|
|
13
13
|
* toMergeIntoProps: { someExtraValue: 5 }
|
|
14
14
|
* });
|
|
@@ -10,7 +10,7 @@ import React from 'react';
|
|
|
10
10
|
* rendering the original component.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
* const PredefinedComponent =
|
|
13
|
+
* const PredefinedComponent = withMergedProps({
|
|
14
14
|
* Component: OriginalComponent,
|
|
15
15
|
* toMergeIntoProps: { someExtraValue: 5 }
|
|
16
16
|
* });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isReactServerComponentOrFunction","serverProps","React","withMergedProps","Component","sanitizeServerOnlyProps","toMergeIntoProps","undefined","MergedPropsComponent","passedProps","mergedProps","simpleMergeProps","forEach","prop","_jsx","props","toMerge"],"sources":["../../../src/elements/withMergedProps/index.tsx"],"sourcesContent":["import { isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent =
|
|
1
|
+
{"version":3,"file":"index.js","names":["isReactServerComponentOrFunction","serverProps","React","withMergedProps","Component","sanitizeServerOnlyProps","toMergeIntoProps","undefined","MergedPropsComponent","passedProps","mergedProps","simpleMergeProps","forEach","prop","_jsx","props","toMerge"],"sources":["../../../src/elements/withMergedProps/index.tsx"],"sourcesContent":["import { isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent = withMergedProps({\n * Component: OriginalComponent,\n * toMergeIntoProps: { someExtraValue: 5 }\n * });\n * // Using <PredefinedComponent customProp=\"value\" /> will result in\n * // <OriginalComponent customProp=\"value\" someExtraValue={5} />\n *\n * @returns A higher-order component with combined properties.\n *\n * @param Component - The original component to wrap.\n * @param sanitizeServerOnlyProps - If true, server-only props will be removed from the merged props. @default true if the component is not a server component, false otherwise.\n * @param toMergeIntoProps - The properties to merge into the passed props.\n */\nexport function withMergedProps<ToMergeIntoProps, CompleteReturnProps>({\n Component,\n sanitizeServerOnlyProps,\n toMergeIntoProps,\n}: {\n Component: React.FC<CompleteReturnProps>\n sanitizeServerOnlyProps?: boolean\n toMergeIntoProps: ToMergeIntoProps\n}): React.FC<CompleteReturnProps> {\n if (sanitizeServerOnlyProps === undefined) {\n sanitizeServerOnlyProps = !isReactServerComponentOrFunction(Component)\n }\n // A wrapper around the args.Component to inject the args.toMergeArgs as props, which are merged with the passed props\n const MergedPropsComponent: React.FC<CompleteReturnProps> = (passedProps) => {\n const mergedProps = simpleMergeProps(passedProps, toMergeIntoProps) as CompleteReturnProps\n\n if (sanitizeServerOnlyProps) {\n serverProps.forEach((prop) => {\n delete mergedProps[prop]\n })\n }\n\n return <Component {...mergedProps} />\n }\n\n return MergedPropsComponent\n}\n\nfunction simpleMergeProps(props, toMerge) {\n return { ...props, ...toMerge }\n}\n"],"mappings":";AAAA,SAASA,gCAAgC,EAAEC,WAAW,QAAQ;AAC9D,OAAOC,KAAA,MAAW;AAElB;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,SAASC,gBAAuD;EACrEC,SAAS;EACTC,uBAAuB;EACvBC;AAAgB,CAKjB;EACC,IAAID,uBAAA,KAA4BE,SAAA,EAAW;IACzCF,uBAAA,GAA0B,CAACL,gCAAA,CAAiCI,SAAA;EAC9D;EACA;EACA,MAAMI,oBAAA,GAAuDC,WAAA;IAC3D,MAAMC,WAAA,GAAcC,gBAAA,CAAiBF,WAAA,EAAaH,gBAAA;IAElD,IAAID,uBAAA,EAAyB;MAC3BJ,WAAA,CAAYW,OAAO,CAAEC,IAAA;QACnB,OAAOH,WAAW,CAACG,IAAA,CAAK;MAC1B;IACF;IAEA,oBAAOC,IAAA,CAACV,SAAA;MAAW,GAAGM;;EACxB;EAEA,OAAOF,oBAAA;AACT;AAEA,SAASG,iBAAiBI,KAAK,EAAEC,OAAO;EACtC,OAAO;IAAE,GAAGD,KAAK;IAAE,GAAGC;EAAQ;AAChC","ignoreList":[]}
|
|
@@ -10,5 +10,5 @@ function require(m) {
|
|
|
10
10
|
}
|
|
11
11
|
// Workaround end
|
|
12
12
|
|
|
13
|
-
import{l as a}from"./chunk-
|
|
14
|
-
//# sourceMappingURL=CodeEditor-
|
|
13
|
+
import{l as a}from"./chunk-PXD7OIXB.js";import"./chunk-5LKBKI4T.js";export{a as default};
|
|
14
|
+
//# sourceMappingURL=CodeEditor-ORMD3ID3.js.map
|
|
@@ -24,4 +24,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
24
24
|
`).length*18+2+p):l),d.current=u)},b=[c,l,p,u],e[4]=l,e[5]=p,e[6]=u,e[7]=c,e[8]=P,e[9]=b):(P=e[8],b=e[9]),Ke.useEffect(P,b),Ge(_r,{className:v,height:n?Math.min(C,n):C,loading:Ge(se,{height:C}),options:{...qe,...E,readOnly:!!a,detectIndentation:!1,insertSpaces:void 0,tabSize:void 0,trimAutoWhitespace:void 0},theme:L==="dark"?"vs-dark":"vs",value:c,...s,onChange:(f,T)=>{s.onChange?.(f,T),y(f?Math.max(l,f.split(`
|
|
25
25
|
`).length*18+2+p):l)},onMount:(f,T)=>{s.onMount?.(f,T);let _=f.getModel();_&&_.updateOptions({insertSpaces:x??ee.insertSpaces,tabSize:w??ee.tabSize,trimAutoWhitespace:M??ee.trimAutoWhitespace}),y(Math.max(l,f.getValue().split(`
|
|
26
26
|
`).length*18+2+p))}})},co=kr;export{ke as a,jr as b,ue as c,_n as d,Ue as e,se as f,Qn as g,Ar as h,Vn as i,Fe as j,ee as k,co as l};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-PXD7OIXB.js.map
|