@webiny/app-headless-cms 6.4.8 → 6.4.9
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.
|
@@ -4,6 +4,7 @@ import { i18n } from "@webiny/app/i18n/index.js";
|
|
|
4
4
|
import { RadioGroup } from "@webiny/admin-ui";
|
|
5
5
|
import { useFieldEffectiveRules, useModelField } from "@webiny/app-headless-cms-common";
|
|
6
6
|
const t = i18n.ns("app-headless-cms/admin/fields/text");
|
|
7
|
+
const isValidValue = (value)=>"string" == typeof value || "number" == typeof value;
|
|
7
8
|
const radioButtons_plugin = {
|
|
8
9
|
type: "cms-editor-field-renderer",
|
|
9
10
|
name: "cms-editor-field-renderer-radio-buttons",
|
|
@@ -34,11 +35,12 @@ const radioButtons_plugin = {
|
|
|
34
35
|
hint: field.help,
|
|
35
36
|
items: options.map((option)=>({
|
|
36
37
|
label: option.label,
|
|
37
|
-
value: String(option.value),
|
|
38
|
+
value: isValidValue(option.value) ? String(option.value) : option.value,
|
|
38
39
|
selected: option.selected
|
|
39
40
|
})),
|
|
40
|
-
value:
|
|
41
|
+
value: isValidValue(value) ? String(value) : void 0,
|
|
41
42
|
onChange: (value)=>{
|
|
43
|
+
if (!isValidValue(value)) return onChange(value);
|
|
42
44
|
"number" === field.type ? onChange(Number(value)) : onChange(String(value));
|
|
43
45
|
}
|
|
44
46
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/fieldRenderers/radioButtons.js","sources":["../../../../src/admin/plugins/fieldRenderers/radioButtons.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get.js\";\nimport type { CmsModelFieldRendererPlugin } from \"~/types.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { RadioGroup } from \"@webiny/admin-ui\";\nimport { useFieldEffectiveRules, useModelField } from \"@webiny/app-headless-cms-common\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields/text\");\n\nconst plugin: CmsModelFieldRendererPlugin = {\n type: \"cms-editor-field-renderer\",\n name: \"cms-editor-field-renderer-radio-buttons\",\n renderer: {\n rendererName: \"radio-buttons\",\n name: t`Radio Buttons`,\n description: t`Renders radio buttons, allowing selection of a single value.`,\n canUse({ field }) {\n return !field.list && !!get(field, \"predefinedValues.enabled\");\n },\n render({ getBind }) {\n const { field } = useModelField();\n const rules = useFieldEffectiveRules(field);\n const disabled = !rules.canEdit || rules.disabled;\n const Bind = getBind();\n\n const { values: options = [] } = field.predefinedValues || {\n options: []\n };\n\n const defaultOption = options.find(opt => opt.selected === true);\n\n return (\n <Bind defaultValue={defaultOption ? defaultOption.value : undefined}>\n {({ onChange, value, ...bind }) => (\n <Bind.ValidationContainer>\n <RadioGroup\n {...bind}\n disabled={disabled}\n label={field.label}\n description={field.description}\n note={field.note}\n hint={field.help}\n items={options.map(option => ({\n label: option.label,\n value: String(option.value),\n selected: option.selected\n }))}\n value={
|
|
1
|
+
{"version":3,"file":"admin/plugins/fieldRenderers/radioButtons.js","sources":["../../../../src/admin/plugins/fieldRenderers/radioButtons.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get.js\";\nimport type { CmsModelFieldRendererPlugin } from \"~/types.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { RadioGroup } from \"@webiny/admin-ui\";\nimport { useFieldEffectiveRules, useModelField } from \"@webiny/app-headless-cms-common\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields/text\");\n\nconst isValidValue = (value: unknown): value is string | number =>\n typeof value === \"string\" || typeof value === \"number\";\n\nconst plugin: CmsModelFieldRendererPlugin = {\n type: \"cms-editor-field-renderer\",\n name: \"cms-editor-field-renderer-radio-buttons\",\n renderer: {\n rendererName: \"radio-buttons\",\n name: t`Radio Buttons`,\n description: t`Renders radio buttons, allowing selection of a single value.`,\n canUse({ field }) {\n return !field.list && !!get(field, \"predefinedValues.enabled\");\n },\n render({ getBind }) {\n const { field } = useModelField();\n const rules = useFieldEffectiveRules(field);\n const disabled = !rules.canEdit || rules.disabled;\n const Bind = getBind();\n\n const { values: options = [] } = field.predefinedValues || {\n options: []\n };\n\n const defaultOption = options.find(opt => opt.selected === true);\n\n return (\n <Bind defaultValue={defaultOption ? defaultOption.value : undefined}>\n {({ onChange, value, ...bind }) => (\n <Bind.ValidationContainer>\n <RadioGroup\n {...bind}\n disabled={disabled}\n label={field.label}\n description={field.description}\n note={field.note}\n hint={field.help}\n items={options.map(option => ({\n label: option.label,\n value: isValidValue(option.value)\n ? String(option.value)\n : option.value,\n selected: option.selected\n }))}\n value={isValidValue(value) ? String(value) : undefined}\n onChange={value => {\n if (!isValidValue(value)) {\n return onChange(value);\n }\n if (field.type === \"number\") {\n onChange(Number(value));\n } else {\n onChange(String(value));\n }\n }}\n />\n </Bind.ValidationContainer>\n )}\n </Bind>\n );\n }\n }\n};\n\nexport default plugin;\n"],"names":["t","i18n","isValidValue","value","plugin","field","get","getBind","useModelField","rules","useFieldEffectiveRules","disabled","Bind","options","defaultOption","opt","undefined","onChange","bind","RadioGroup","option","String","Number"],"mappings":";;;;;AAOA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAElB,MAAMC,eAAe,CAACC,QAClB,AAAiB,YAAjB,OAAOA,SAAsB,AAAiB,YAAjB,OAAOA;AAExC,MAAMC,sBAAsC;IACxC,MAAM;IACN,MAAM;IACN,UAAU;QACN,cAAc;QACd,MAAMJ,CAAC,CAAC,aAAa,CAAC;QACtB,aAAaA,CAAC,CAAC,4DAA4D,CAAC;QAC5E,QAAO,EAAEK,KAAK,EAAE;YACZ,OAAO,CAACA,MAAM,IAAI,IAAI,CAAC,CAACC,IAAID,OAAO;QACvC;QACA,QAAO,EAAEE,OAAO,EAAE;YACd,MAAM,EAAEF,KAAK,EAAE,GAAGG;YAClB,MAAMC,QAAQC,uBAAuBL;YACrC,MAAMM,WAAW,CAACF,MAAM,OAAO,IAAIA,MAAM,QAAQ;YACjD,MAAMG,OAAOL;YAEb,MAAM,EAAE,QAAQM,UAAU,EAAE,EAAE,GAAGR,MAAM,gBAAgB,IAAI;gBACvD,SAAS,EAAE;YACf;YAEA,MAAMS,gBAAgBD,QAAQ,IAAI,CAACE,CAAAA,MAAOA,AAAiB,SAAjBA,IAAI,QAAQ;YAEtD,OAAO,WAAP,GACI,oBAACH,MAAAA;gBAAK,cAAcE,gBAAgBA,cAAc,KAAK,GAAGE;eACrD,CAAC,EAAEC,QAAQ,EAAEd,KAAK,EAAE,GAAGe,MAAM,iBAC1B,oBAACN,KAAK,mBAAmB,sBACrB,oBAACO,YAAUA;oBACN,GAAGD,IAAI;oBACR,UAAUP;oBACV,OAAON,MAAM,KAAK;oBAClB,aAAaA,MAAM,WAAW;oBAC9B,MAAMA,MAAM,IAAI;oBAChB,MAAMA,MAAM,IAAI;oBAChB,OAAOQ,QAAQ,GAAG,CAACO,CAAAA,SAAW;4BAC1B,OAAOA,OAAO,KAAK;4BACnB,OAAOlB,aAAakB,OAAO,KAAK,IAC1BC,OAAOD,OAAO,KAAK,IACnBA,OAAO,KAAK;4BAClB,UAAUA,OAAO,QAAQ;wBAC7B;oBACA,OAAOlB,aAAaC,SAASkB,OAAOlB,SAASa;oBAC7C,UAAUb,CAAAA;wBACN,IAAI,CAACD,aAAaC,QACd,OAAOc,SAASd;wBAED,aAAfE,MAAM,IAAI,GACVY,SAASK,OAAOnB,UAEhBc,SAASI,OAAOlB;oBAExB;;QAMxB;IACJ;AACJ;AAEA,qBAAeC"}
|
|
@@ -4,6 +4,7 @@ import { i18n } from "@webiny/app/i18n/index.js";
|
|
|
4
4
|
import { Select } from "@webiny/admin-ui";
|
|
5
5
|
import { useFieldEffectiveRules, useModelField } from "@webiny/app-headless-cms-common";
|
|
6
6
|
const t = i18n.ns("app-headless-cms/admin/fields/text");
|
|
7
|
+
const isValidValue = (value)=>"string" == typeof value || "number" == typeof value;
|
|
7
8
|
const select_plugin = {
|
|
8
9
|
type: "cms-editor-field-renderer",
|
|
9
10
|
name: "cms-editor-field-renderer-select-box",
|
|
@@ -33,8 +34,9 @@ const select_plugin = {
|
|
|
33
34
|
options: options,
|
|
34
35
|
placeholder: field.placeholder,
|
|
35
36
|
"data-testid": `fr.input.select.${field.label}`,
|
|
36
|
-
value:
|
|
37
|
+
value: isValidValue(value) ? String(value) : void 0,
|
|
37
38
|
onChange: (value)=>{
|
|
39
|
+
if (!isValidValue(value)) return onChange(value);
|
|
38
40
|
"number" === field.type ? onChange(Number(value)) : onChange(String(value));
|
|
39
41
|
}
|
|
40
42
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/fieldRenderers/select.js","sources":["../../../../src/admin/plugins/fieldRenderers/select.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport type { CmsModelFieldRendererPlugin } from \"~/types.js\";\nimport { Select } from \"@webiny/admin-ui\";\nimport { useFieldEffectiveRules, useModelField } from \"@webiny/app-headless-cms-common\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields/text\");\n\nconst plugin: CmsModelFieldRendererPlugin = {\n type: \"cms-editor-field-renderer\",\n name: \"cms-editor-field-renderer-select-box\",\n renderer: {\n rendererName: \"select-box\",\n name: t`Select Box`,\n description: t`Renders a select box, allowing selection of a single value.`,\n canUse({ field }) {\n return !field.list && !!get(field, \"predefinedValues.enabled\");\n },\n render({ getBind }) {\n const { field } = useModelField();\n const rules = useFieldEffectiveRules(field);\n const disabled = !rules.canEdit || rules.disabled;\n const Bind = getBind();\n\n const { values: options = [] } = field.predefinedValues || {};\n const defaultOption = options.find(option => !!option.selected);\n\n return (\n <Bind defaultValue={defaultOption ? defaultOption.value : undefined}>\n {({ value, onChange, ...bind }) => (\n <Bind.ValidationContainer>\n <Select\n {...bind}\n disabled={disabled}\n label={field.label}\n description={field.description}\n note={field.note}\n hint={field.help}\n options={options}\n placeholder={field.placeholder}\n data-testid={`fr.input.select.${field.label}`}\n value={
|
|
1
|
+
{"version":3,"file":"admin/plugins/fieldRenderers/select.js","sources":["../../../../src/admin/plugins/fieldRenderers/select.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get.js\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport type { CmsModelFieldRendererPlugin } from \"~/types.js\";\nimport { Select } from \"@webiny/admin-ui\";\nimport { useFieldEffectiveRules, useModelField } from \"@webiny/app-headless-cms-common\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields/text\");\n\nconst isValidValue = (value: unknown): value is string | number =>\n typeof value === \"string\" || typeof value === \"number\";\n\nconst plugin: CmsModelFieldRendererPlugin = {\n type: \"cms-editor-field-renderer\",\n name: \"cms-editor-field-renderer-select-box\",\n renderer: {\n rendererName: \"select-box\",\n name: t`Select Box`,\n description: t`Renders a select box, allowing selection of a single value.`,\n canUse({ field }) {\n return !field.list && !!get(field, \"predefinedValues.enabled\");\n },\n render({ getBind }) {\n const { field } = useModelField();\n const rules = useFieldEffectiveRules(field);\n const disabled = !rules.canEdit || rules.disabled;\n const Bind = getBind();\n\n const { values: options = [] } = field.predefinedValues || {};\n const defaultOption = options.find(option => !!option.selected);\n\n return (\n <Bind defaultValue={defaultOption ? defaultOption.value : undefined}>\n {({ value, onChange, ...bind }) => (\n <Bind.ValidationContainer>\n <Select\n {...bind}\n disabled={disabled}\n label={field.label}\n description={field.description}\n note={field.note}\n hint={field.help}\n options={options}\n placeholder={field.placeholder}\n data-testid={`fr.input.select.${field.label}`}\n value={isValidValue(value) ? String(value) : undefined}\n onChange={value => {\n if (!isValidValue(value)) {\n return onChange(value);\n }\n if (field.type === \"number\") {\n onChange(Number(value));\n } else {\n onChange(String(value));\n }\n }}\n />\n </Bind.ValidationContainer>\n )}\n </Bind>\n );\n }\n }\n};\n\nexport default plugin;\n"],"names":["t","i18n","isValidValue","value","plugin","field","get","getBind","useModelField","rules","useFieldEffectiveRules","disabled","Bind","options","defaultOption","option","undefined","onChange","bind","Select","String","Number"],"mappings":";;;;;A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AED,aAAfE,MAAM,IAAI,GACVY,SAASI,OAAOlB,UAEhBc,SAASG,OAAOjB;oBAExB;;QAMxB;IACJ;AACJ;AAEA,8BAAeC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-headless-cms",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -31,25 +31,25 @@
|
|
|
31
31
|
"@lexical/utils": "0.46.0",
|
|
32
32
|
"@svgr/webpack": "8.1.0",
|
|
33
33
|
"@types/react": "18.3.31",
|
|
34
|
-
"@webiny/admin-ui": "6.4.
|
|
35
|
-
"@webiny/app": "6.4.
|
|
36
|
-
"@webiny/app-aco": "6.4.
|
|
37
|
-
"@webiny/app-admin": "6.4.
|
|
38
|
-
"@webiny/app-graphql-playground": "6.4.
|
|
39
|
-
"@webiny/app-headless-cms-common": "6.4.
|
|
40
|
-
"@webiny/app-trash-bin": "6.4.
|
|
41
|
-
"@webiny/error": "6.4.
|
|
42
|
-
"@webiny/feature": "6.4.
|
|
43
|
-
"@webiny/form": "6.4.
|
|
44
|
-
"@webiny/icons": "6.4.
|
|
45
|
-
"@webiny/lexical-converter": "6.4.
|
|
46
|
-
"@webiny/lexical-editor": "6.4.
|
|
47
|
-
"@webiny/lexical-nodes": "6.4.
|
|
48
|
-
"@webiny/plugins": "6.4.
|
|
49
|
-
"@webiny/react-composition": "6.4.
|
|
50
|
-
"@webiny/react-properties": "6.4.
|
|
51
|
-
"@webiny/utils": "6.4.
|
|
52
|
-
"@webiny/validation": "6.4.
|
|
34
|
+
"@webiny/admin-ui": "6.4.9",
|
|
35
|
+
"@webiny/app": "6.4.9",
|
|
36
|
+
"@webiny/app-aco": "6.4.9",
|
|
37
|
+
"@webiny/app-admin": "6.4.9",
|
|
38
|
+
"@webiny/app-graphql-playground": "6.4.9",
|
|
39
|
+
"@webiny/app-headless-cms-common": "6.4.9",
|
|
40
|
+
"@webiny/app-trash-bin": "6.4.9",
|
|
41
|
+
"@webiny/error": "6.4.9",
|
|
42
|
+
"@webiny/feature": "6.4.9",
|
|
43
|
+
"@webiny/form": "6.4.9",
|
|
44
|
+
"@webiny/icons": "6.4.9",
|
|
45
|
+
"@webiny/lexical-converter": "6.4.9",
|
|
46
|
+
"@webiny/lexical-editor": "6.4.9",
|
|
47
|
+
"@webiny/lexical-nodes": "6.4.9",
|
|
48
|
+
"@webiny/plugins": "6.4.9",
|
|
49
|
+
"@webiny/react-composition": "6.4.9",
|
|
50
|
+
"@webiny/react-properties": "6.4.9",
|
|
51
|
+
"@webiny/utils": "6.4.9",
|
|
52
|
+
"@webiny/validation": "6.4.9",
|
|
53
53
|
"apollo-cache": "1.3.5",
|
|
54
54
|
"apollo-client": "2.6.10",
|
|
55
55
|
"apollo-link": "1.2.14",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"zod": "4.4.3"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@webiny/build-tools": "6.4.
|
|
74
|
+
"@webiny/build-tools": "6.4.9",
|
|
75
75
|
"rimraf": "6.1.3",
|
|
76
76
|
"typescript": "6.0.3",
|
|
77
77
|
"vitest": "4.1.10"
|