@payloadcms/plugin-form-builder 3.0.0-canary.c696728 → 3.0.0-canary.c96fa61
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.
|
@@ -3,15 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { TextField, useLocale, useWatchForm } from '@payloadcms/ui';
|
|
4
4
|
import React, { useEffect, useState } from 'react';
|
|
5
5
|
export const DynamicPriceSelector = (props)=>{
|
|
6
|
-
const { field } = props;
|
|
6
|
+
const { field, path } = props;
|
|
7
7
|
const { fields, getData, getDataByPath } = useWatchForm();
|
|
8
8
|
const locale = useLocale();
|
|
9
9
|
const [isNumberField, setIsNumberField] = useState();
|
|
10
10
|
const [valueType, setValueType] = useState();
|
|
11
11
|
// only number fields can use 'valueOfField`
|
|
12
12
|
useEffect(()=>{
|
|
13
|
-
if (
|
|
14
|
-
const parentPath =
|
|
13
|
+
if (path) {
|
|
14
|
+
const parentPath = path.split('.').slice(0, -1).join('.');
|
|
15
15
|
const paymentFieldData = getDataByPath(parentPath);
|
|
16
16
|
if (paymentFieldData) {
|
|
17
17
|
const { fieldToUse, valueType } = paymentFieldData;
|
|
@@ -26,9 +26,9 @@ export const DynamicPriceSelector = (props)=>{
|
|
|
26
26
|
}
|
|
27
27
|
}, [
|
|
28
28
|
fields,
|
|
29
|
-
field._path,
|
|
30
29
|
getDataByPath,
|
|
31
|
-
getData
|
|
30
|
+
getData,
|
|
31
|
+
path
|
|
32
32
|
]);
|
|
33
33
|
// TODO: make this a number field, block by Payload
|
|
34
34
|
if (valueType === 'static') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { Data, TextFieldClientComponent } from 'payload'\n\nimport { TextField, useLocale, useWatchForm } from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\ntype FieldWithID = {\n id: string\n name: string\n}\n\nexport const DynamicPriceSelector: TextFieldClientComponent = (props) => {\n const { field } = props\n\n const { fields, getData, getDataByPath } = useWatchForm()\n\n const locale = useLocale()\n\n const [isNumberField, setIsNumberField] = useState<boolean>()\n const [valueType, setValueType] = useState<'static' | 'valueOfField'>()\n\n // only number fields can use 'valueOfField`\n useEffect(() => {\n if (
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { Data, TextFieldClientComponent } from 'payload'\n\nimport { TextField, useLocale, useWatchForm } from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\ntype FieldWithID = {\n id: string\n name: string\n}\n\nexport const DynamicPriceSelector: TextFieldClientComponent = (props) => {\n const { field, path } = props\n\n const { fields, getData, getDataByPath } = useWatchForm()\n\n const locale = useLocale()\n\n const [isNumberField, setIsNumberField] = useState<boolean>()\n const [valueType, setValueType] = useState<'static' | 'valueOfField'>()\n\n // only number fields can use 'valueOfField`\n useEffect(() => {\n if (path) {\n const parentPath = path.split('.').slice(0, -1).join('.')\n const paymentFieldData: any = getDataByPath(parentPath)\n\n if (paymentFieldData) {\n const { fieldToUse, valueType } = paymentFieldData\n\n setValueType(valueType)\n\n const { fields: allFields }: Data = getData()\n const field = allFields.find((field: FieldWithID) => field.name === fieldToUse)\n\n if (field) {\n const { blockType } = field\n setIsNumberField(blockType === 'number')\n }\n }\n }\n }, [fields, getDataByPath, getData, path])\n\n // TODO: make this a number field, block by Payload\n if (valueType === 'static') {\n return <TextField {...props} />\n }\n\n const localeCode = typeof locale === 'object' && 'code' in locale ? locale.code : locale\n\n const localLabels = typeof field.label === 'object' ? field.label : { [localeCode]: field.label }\n\n const labelValue = localLabels[localeCode] || localLabels['en'] || ''\n\n if (valueType === 'valueOfField' && !isNumberField) {\n return (\n <div>\n <div>{String(labelValue)}</div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n The selected field must be a number field.\n </div>\n </div>\n )\n }\n\n return null\n}\n"],"names":["TextField","useLocale","useWatchForm","React","useEffect","useState","DynamicPriceSelector","props","field","path","fields","getData","getDataByPath","locale","isNumberField","setIsNumberField","valueType","setValueType","parentPath","split","slice","join","paymentFieldData","fieldToUse","allFields","find","name","blockType","localeCode","code","localLabels","label","labelValue","div","String","style","color"],"mappings":"AAAA;;AAIA,SAASA,SAAS,EAAEC,SAAS,EAAEC,YAAY,QAAQ,iBAAgB;AACnE,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAOlD,OAAO,MAAMC,uBAAiD,CAACC;IAC7D,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGF;IAExB,MAAM,EAAEG,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAE,GAAGV;IAE3C,MAAMW,SAASZ;IAEf,MAAM,CAACa,eAAeC,iBAAiB,GAAGV;IAC1C,MAAM,CAACW,WAAWC,aAAa,GAAGZ;IAElC,4CAA4C;IAC5CD,UAAU;QACR,IAAIK,MAAM;YACR,MAAMS,aAAaT,KAAKU,KAAK,CAAC,KAAKC,KAAK,CAAC,GAAG,CAAC,GAAGC,IAAI,CAAC;YACrD,MAAMC,mBAAwBV,cAAcM;YAE5C,IAAII,kBAAkB;gBACpB,MAAM,EAAEC,UAAU,EAAEP,SAAS,EAAE,GAAGM;gBAElCL,aAAaD;gBAEb,MAAM,EAAEN,QAAQc,SAAS,EAAE,GAASb;gBACpC,MAAMH,QAAQgB,UAAUC,IAAI,CAAC,CAACjB,QAAuBA,MAAMkB,IAAI,KAAKH;gBAEpE,IAAIf,OAAO;oBACT,MAAM,EAAEmB,SAAS,EAAE,GAAGnB;oBACtBO,iBAAiBY,cAAc;gBACjC;YACF;QACF;IACF,GAAG;QAACjB;QAAQE;QAAeD;QAASF;KAAK;IAEzC,mDAAmD;IACnD,IAAIO,cAAc,UAAU;QAC1B,qBAAO,KAAChB;YAAW,GAAGO,KAAK;;IAC7B;IAEA,MAAMqB,aAAa,OAAOf,WAAW,YAAY,UAAUA,SAASA,OAAOgB,IAAI,GAAGhB;IAElF,MAAMiB,cAAc,OAAOtB,MAAMuB,KAAK,KAAK,WAAWvB,MAAMuB,KAAK,GAAG;QAAE,CAACH,WAAW,EAAEpB,MAAMuB,KAAK;IAAC;IAEhG,MAAMC,aAAaF,WAAW,CAACF,WAAW,IAAIE,WAAW,CAAC,KAAK,IAAI;IAEnE,IAAId,cAAc,kBAAkB,CAACF,eAAe;QAClD,qBACE,MAACmB;;8BACC,KAACA;8BAAKC,OAAOF;;8BACb,KAACC;oBACCE,OAAO;wBACLC,OAAO;oBACT;8BACD;;;;IAKP;IAEA,OAAO;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-form-builder",
|
|
3
|
-
"version": "3.0.0-canary.
|
|
3
|
+
"version": "3.0.0-canary.c96fa61",
|
|
4
4
|
"description": "Form builder plugin for Payload CMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -45,22 +45,21 @@
|
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"escape-html": "^1.0.3",
|
|
48
|
-
"@payloadcms/ui": "3.0.0-canary.
|
|
48
|
+
"@payloadcms/ui": "3.0.0-canary.c96fa61"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/escape-html": "^1.0.4",
|
|
52
|
-
"@types/express": "^4.17.21",
|
|
53
52
|
"@types/react": "npm:types-react@19.0.0-rc.1",
|
|
54
53
|
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
|
|
55
54
|
"copyfiles": "^2.4.1",
|
|
56
55
|
"cross-env": "^7.0.3",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
56
|
+
"payload": "3.0.0-canary.c96fa61",
|
|
57
|
+
"@payloadcms/eslint-config": "3.0.0-beta.112"
|
|
59
58
|
},
|
|
60
59
|
"peerDependencies": {
|
|
61
|
-
"react": "^19.0.0 || ^19.0.0-rc-
|
|
62
|
-
"react-dom": "^19.0.0 || ^19.0.0-rc-
|
|
63
|
-
"payload": "3.0.0-canary.
|
|
60
|
+
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
61
|
+
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
62
|
+
"payload": "3.0.0-canary.c96fa61"
|
|
64
63
|
},
|
|
65
64
|
"publishConfig": {
|
|
66
65
|
"registry": "https://registry.npmjs.org/"
|