@webiny/app-headless-cms 5.40.1-beta.2 → 5.40.2-beta.0
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/admin/components/ContentEntryForm/useBind.js +2 -2
- package/admin/components/ContentEntryForm/useBind.js.map +1 -1
- package/admin/plugins/fieldRenderers/checkboxes.js +35 -19
- package/admin/plugins/fieldRenderers/checkboxes.js.map +1 -1
- package/admin/plugins/fieldRenderers/radioButtons.js +6 -1
- package/admin/plugins/fieldRenderers/radioButtons.js.map +1 -1
- package/admin/plugins/fieldRenderers/select.js +12 -21
- package/admin/plugins/fieldRenderers/select.js.map +1 -1
- package/package.json +28 -28
|
@@ -36,13 +36,13 @@ function useBind(_ref) {
|
|
|
36
36
|
}
|
|
37
37
|
var validators = (0, _createValidators.createValidators)(field, field.validation || emptyValidators);
|
|
38
38
|
var listValidators = (0, _createValidators.createValidators)(field, field.listValidation || emptyValidators);
|
|
39
|
-
var defaultValue = undefined;
|
|
40
39
|
var isMultipleValues = index === -1 && field.multipleValues;
|
|
41
40
|
var inputValidators = isMultipleValues ? listValidators : validators;
|
|
42
41
|
memoizedBindComponents.current[componentId] = function UseBind(params) {
|
|
43
42
|
var childName = params.name,
|
|
44
43
|
childValidators = params.validators,
|
|
45
|
-
children = params.children
|
|
44
|
+
children = params.children,
|
|
45
|
+
defaultValue = params.defaultValue;
|
|
46
46
|
return /*#__PURE__*/_react.default.createElement(Bind, {
|
|
47
47
|
name: childName || name,
|
|
48
48
|
validators: childValidators || inputValidators,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_form","_createValidators","createFieldCacheKey","field","id","fieldId","JSON","stringify","validation","listValidation","join","emptyValidators","useBind","_ref","Bind","memoizedBindComponents","useRef","cacheKey","form","useForm","useCallback","index","arguments","length","undefined","parentName","name","filter","v","componentId","concat","current","validators","createValidators","listValidators","defaultValue","isMultipleValues","multipleValues","inputValidators","UseBind","params","childName","childValidators","children","default","createElement","bind","props","_objectSpread2","appendValue","newValue","currentValue","value","newIndex","onChange","_toConsumableArray2","slice","prependValue","appendValues","newValues","removeValue","validateInput","moveValueUp","splice","moveValueDown","element","cloneElement","displayName"],"sources":["useBind.tsx"],"sourcesContent":["import React, { useRef, useCallback, cloneElement } from \"react\";\nimport { Validator } from \"@webiny/validation/types\";\nimport { useForm } from \"@webiny/form\";\nimport { createValidators } from \"~/utils/createValidators\";\nimport { BindComponent, CmsModelField } from \"~/types\";\n\ninterface UseBindProps {\n field: CmsModelField;\n Bind: BindComponent;\n}\n\ninterface UseBindParams {\n name?: string;\n validators?: Validator | Validator[];\n children?: any;\n}\n\nconst createFieldCacheKey = (field: CmsModelField) => {\n return [\n field.id,\n field.fieldId,\n JSON.stringify(field.validation),\n JSON.stringify(field.listValidation)\n ].join(\";\");\n};\n\nexport interface GetBindCallable {\n (index?: number): BindComponent;\n}\n\nconst emptyValidators: Validator[] = [];\n\nexport function useBind({ Bind, field }: UseBindProps) {\n const memoizedBindComponents = useRef<Record<string, BindComponent>>({});\n const cacheKey = createFieldCacheKey(field);\n const form = useForm();\n\n return useCallback(\n (index = -1) => {\n const { parentName } = Bind;\n\n // If there's a parent name assigned to the given Bind component, we need to include it in the new field \"name\".\n // This allows us to have nested fields (like \"object\" field with nested properties)\n const name = [parentName, field.fieldId, index >= 0 ? index : undefined]\n .filter(v => v !== undefined)\n .join(\".\");\n\n const componentId = `${name};${cacheKey}`;\n\n if (memoizedBindComponents.current[componentId]) {\n return memoizedBindComponents.current[componentId];\n }\n\n const validators = createValidators(field, field.validation || emptyValidators);\n const listValidators = createValidators(field, field.listValidation || emptyValidators);\n const defaultValue: string[] | undefined = undefined;\n const isMultipleValues = index === -1 && field.multipleValues;\n const inputValidators = isMultipleValues ? listValidators : validators;\n\n memoizedBindComponents.current[componentId] = function UseBind(params: UseBindParams) {\n const { name: childName, validators: childValidators, children } = params;\n\n return (\n <Bind\n name={childName || name}\n validators={childValidators || inputValidators}\n defaultValue={index === -1 ? defaultValue : null}\n >\n {bind => {\n // Multiple-values functions below.\n const props = { ...bind };\n if (field.multipleValues && index === -1) {\n props.appendValue = (newValue: any, index?: number) => {\n const currentValue = bind.value || [];\n const newIndex = index ?? currentValue.length;\n\n bind.onChange([\n ...currentValue.slice(0, newIndex),\n newValue,\n ...currentValue.slice(newIndex)\n ]);\n };\n props.prependValue = (newValue: any) => {\n bind.onChange([newValue, ...(bind.value || [])]);\n };\n props.appendValues = (newValues: any[]) => {\n bind.onChange([...(bind.value || []), ...newValues]);\n };\n\n props.removeValue = (index: number) => {\n if (index < 0) {\n return;\n }\n let value = bind.value;\n value = [...value.slice(0, index), ...value.slice(index + 1)];\n\n bind.onChange(value);\n\n // To make sure the field is still valid, we must trigger validation.\n form.validateInput(field.fieldId);\n };\n\n props.moveValueUp = (index: number) => {\n if (index <= 0) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index - 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n\n props.moveValueDown = (index: number) => {\n if (index >= bind.value.length) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index + 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n }\n\n const element =\n typeof children === \"function\"\n ? children(props)\n : cloneElement(children, props);\n\n return element;\n }}\n </Bind>\n );\n } as BindComponent;\n\n // We need to keep track of current field name, to support nested fields.\n memoizedBindComponents.current[componentId].parentName = name;\n memoizedBindComponents.current[componentId].displayName = `Bind<${name}>`;\n\n return memoizedBindComponents.current[componentId];\n },\n [field.fieldId, cacheKey]\n );\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAcA,IAAMG,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,KAAoB,EAAK;EAClD,OAAO,CACHA,KAAK,CAACC,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C,CAAC;YACtB+B,KAAK,CAACW,MAAM,CAAC1C,KAAK,GAAG,CAAC,EAAE,CAAC,EAAEyB,IAAI,CAACM,KAAK,CAAC/B,KAAK,CAAC,CAAC;YAE7CyB,IAAI,CAACQ,QAAQ,CAACF,KAAK,CAAC;UACxB,CAAC;UAEDL,KAAK,CAACiB,aAAa,GAAG,UAAC3C,KAAa,EAAK;YACrC,IAAIA,KAAK,IAAIyB,IAAI,CAACM,KAAK,CAAC7B,MAAM,EAAE;cAC5B;YACJ;YAEA,IAAM6B,KAAK,OAAAG,mBAAA,CAAAX,OAAA,EAAOE,IAAI,CAACM,KAAK,CAAC;YAC7BA,KAAK,CAACW,MAAM,CAAC1C,KAAK,EAAE,CAAC,CAAC;YACtB+B,KAAK,CAACW,MAAM,CAAC1C,KAAK,GAAG,CAAC,EAAE,CAAC,EAAEyB,IAAI,CAACM,KAAK,CAAC/B,KAAK,CAAC,CAAC;YAE7CyB,IAAI,CAACQ,QAAQ,CAACF,KAAK,CAAC;UACxB,CAAC;QACL;QAEA,IAAMa,OAAO,GACT,OAAOtB,QAAQ,KAAK,UAAU,GACxBA,QAAQ,CAACI,KAAK,CAAC,gBACf,IAAAmB,mBAAY,EAACvB,QAAQ,EAAEI,KAAK,CAAC;QAEvC,OAAOkB,OAAO;MAClB,CACE,CAAC;IAEf,CAAkB;;IAElB;IACAlD,sBAAsB,CAACgB,OAAO,CAACF,WAAW,CAAC,CAACJ,UAAU,GAAGC,IAAI;IAC7DX,sBAAsB,CAACgB,OAAO,CAACF,WAAW,CAAC,CAACsC,WAAW,WAAArC,MAAA,CAAWJ,IAAI,MAAG;IAEzE,OAAOX,sBAAsB,CAACgB,OAAO,CAACF,WAAW,CAAC;EACtD,CAAC,EACD,CAAC1B,KAAK,CAACE,OAAO,EAAEY,QAAQ,CAC5B,CAAC;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_form","_createValidators","createFieldCacheKey","field","id","fieldId","JSON","stringify","validation","listValidation","join","emptyValidators","useBind","_ref","Bind","memoizedBindComponents","useRef","cacheKey","form","useForm","useCallback","index","arguments","length","undefined","parentName","name","filter","v","componentId","concat","current","validators","createValidators","listValidators","isMultipleValues","multipleValues","inputValidators","UseBind","params","childName","childValidators","children","defaultValue","default","createElement","bind","props","_objectSpread2","appendValue","newValue","currentValue","value","newIndex","onChange","_toConsumableArray2","slice","prependValue","appendValues","newValues","removeValue","validateInput","moveValueUp","splice","moveValueDown","element","cloneElement","displayName"],"sources":["useBind.tsx"],"sourcesContent":["import React, { useRef, useCallback, cloneElement } from \"react\";\nimport { Validator } from \"@webiny/validation/types\";\nimport { useForm } from \"@webiny/form\";\nimport { createValidators } from \"~/utils/createValidators\";\nimport { BindComponent, CmsModelField } from \"~/types\";\n\ninterface UseBindProps {\n field: CmsModelField;\n Bind: BindComponent;\n}\n\ninterface UseBindParams {\n name?: string;\n validators?: Validator | Validator[];\n children?: any;\n defaultValue?: any;\n}\n\nconst createFieldCacheKey = (field: CmsModelField) => {\n return [\n field.id,\n field.fieldId,\n JSON.stringify(field.validation),\n JSON.stringify(field.listValidation)\n ].join(\";\");\n};\n\nexport interface GetBindCallable {\n (index?: number): BindComponent;\n}\n\nconst emptyValidators: Validator[] = [];\n\nexport function useBind({ Bind, field }: UseBindProps) {\n const memoizedBindComponents = useRef<Record<string, BindComponent>>({});\n const cacheKey = createFieldCacheKey(field);\n const form = useForm();\n\n return useCallback(\n (index = -1) => {\n const { parentName } = Bind;\n\n // If there's a parent name assigned to the given Bind component, we need to include it in the new field \"name\".\n // This allows us to have nested fields (like \"object\" field with nested properties)\n const name = [parentName, field.fieldId, index >= 0 ? index : undefined]\n .filter(v => v !== undefined)\n .join(\".\");\n\n const componentId = `${name};${cacheKey}`;\n\n if (memoizedBindComponents.current[componentId]) {\n return memoizedBindComponents.current[componentId];\n }\n\n const validators = createValidators(field, field.validation || emptyValidators);\n const listValidators = createValidators(field, field.listValidation || emptyValidators);\n const isMultipleValues = index === -1 && field.multipleValues;\n const inputValidators = isMultipleValues ? listValidators : validators;\n\n memoizedBindComponents.current[componentId] = function UseBind(params: UseBindParams) {\n const {\n name: childName,\n validators: childValidators,\n children,\n defaultValue\n } = params;\n\n return (\n <Bind\n name={childName || name}\n validators={childValidators || inputValidators}\n defaultValue={index === -1 ? defaultValue : null}\n >\n {bind => {\n // Multiple-values functions below.\n const props = { ...bind };\n if (field.multipleValues && index === -1) {\n props.appendValue = (newValue: any, index?: number) => {\n const currentValue = bind.value || [];\n const newIndex = index ?? currentValue.length;\n\n bind.onChange([\n ...currentValue.slice(0, newIndex),\n newValue,\n ...currentValue.slice(newIndex)\n ]);\n };\n props.prependValue = (newValue: any) => {\n bind.onChange([newValue, ...(bind.value || [])]);\n };\n props.appendValues = (newValues: any[]) => {\n bind.onChange([...(bind.value || []), ...newValues]);\n };\n\n props.removeValue = (index: number) => {\n if (index < 0) {\n return;\n }\n let value = bind.value;\n value = [...value.slice(0, index), ...value.slice(index + 1)];\n\n bind.onChange(value);\n\n // To make sure the field is still valid, we must trigger validation.\n form.validateInput(field.fieldId);\n };\n\n props.moveValueUp = (index: number) => {\n if (index <= 0) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index - 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n\n props.moveValueDown = (index: number) => {\n if (index >= bind.value.length) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index + 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n }\n\n const element =\n typeof children === \"function\"\n ? children(props)\n : cloneElement(children, props);\n\n return element;\n }}\n </Bind>\n );\n } as BindComponent;\n\n // We need to keep track of current field name, to support nested fields.\n memoizedBindComponents.current[componentId].parentName = name;\n memoizedBindComponents.current[componentId].displayName = `Bind<${name}>`;\n\n return memoizedBindComponents.current[componentId];\n },\n [field.fieldId, cacheKey]\n );\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CA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AC,EACD,CAAC1B,KAAK,CAACE,OAAO,EAAEY,QAAQ,CAC5B,CAAC;AACL","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
8
9
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
10
|
var _react = _interopRequireDefault(require("react"));
|
|
10
11
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
@@ -12,6 +13,9 @@ var _i18n = require("@webiny/app/i18n");
|
|
|
12
13
|
var _Checkbox = require("@webiny/ui/Checkbox");
|
|
13
14
|
var _templateObject, _templateObject2;
|
|
14
15
|
var t = _i18n.i18n.ns("app-headless-cms/admin/fields/text");
|
|
16
|
+
var adaptToField = function adaptToField(field, value) {
|
|
17
|
+
return field.type === "number" ? Number(value) : value;
|
|
18
|
+
};
|
|
15
19
|
var plugin = {
|
|
16
20
|
type: "cms-editor-field-renderer",
|
|
17
21
|
name: "cms-editor-field-renderer-checkboxes-buttons",
|
|
@@ -31,27 +35,39 @@ var plugin = {
|
|
|
31
35
|
values: []
|
|
32
36
|
},
|
|
33
37
|
_ref3$values = _ref3.values,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var onChange = _ref4.onChange,
|
|
41
|
-
getValue = _ref4.getValue;
|
|
42
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, options.map(function (option, index) {
|
|
43
|
-
var value = field.type === "number" ? Number(option.value) : option.value;
|
|
44
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
45
|
-
key: String(option.value) + index
|
|
46
|
-
}, /*#__PURE__*/_react.default.createElement(_Checkbox.Checkbox, {
|
|
47
|
-
label: option.label,
|
|
48
|
-
value: getValue(value),
|
|
49
|
-
onChange: onChange(value),
|
|
50
|
-
"data-testid": "fr.input.".concat(field.label)
|
|
51
|
-
}));
|
|
52
|
-
}));
|
|
38
|
+
predefinedOptions = _ref3$values === void 0 ? [] : _ref3$values;
|
|
39
|
+
|
|
40
|
+
// For `number` field, we want to convert the value to actual Number.
|
|
41
|
+
var options = predefinedOptions.map(function (opt) {
|
|
42
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, opt), {}, {
|
|
43
|
+
value: adaptToField(field, opt.value)
|
|
53
44
|
});
|
|
54
45
|
});
|
|
46
|
+
var defaults = options.filter(function (option) {
|
|
47
|
+
return option.selected;
|
|
48
|
+
});
|
|
49
|
+
var defaultValue = defaults.length > 0 ? defaults.map(function (opt) {
|
|
50
|
+
return opt.value;
|
|
51
|
+
}) : undefined;
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement(Bind, {
|
|
53
|
+
defaultValue: defaultValue
|
|
54
|
+
}, /*#__PURE__*/_react.default.createElement(_Checkbox.CheckboxGroup, {
|
|
55
|
+
label: field.label,
|
|
56
|
+
description: field.helpText
|
|
57
|
+
}, function (_ref4) {
|
|
58
|
+
var onChange = _ref4.onChange,
|
|
59
|
+
getValue = _ref4.getValue;
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, options.map(function (option, index) {
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
62
|
+
key: String(option.value) + index
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement(_Checkbox.Checkbox, {
|
|
64
|
+
label: option.label,
|
|
65
|
+
value: getValue(option.value),
|
|
66
|
+
onChange: onChange(option.value),
|
|
67
|
+
"data-testid": "fr.input.".concat(field.label)
|
|
68
|
+
}));
|
|
69
|
+
}));
|
|
70
|
+
}));
|
|
55
71
|
}
|
|
56
72
|
}
|
|
57
73
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_get","_i18n","_Checkbox","_templateObject","_templateObject2","t","i18n","ns","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_get","_i18n","_Checkbox","_templateObject","_templateObject2","t","i18n","ns","adaptToField","field","value","type","Number","plugin","name","renderer","rendererName","_taggedTemplateLiteral2","default","description","canUse","_ref","multipleValues","get","render","_ref2","getBind","Bind","_ref3","predefinedValues","values","_ref3$values","predefinedOptions","options","map","opt","_objectSpread2","defaults","filter","option","selected","defaultValue","length","undefined","createElement","CheckboxGroup","label","helpText","_ref4","onChange","getValue","Fragment","index","key","String","Checkbox","concat","_default","exports"],"sources":["checkboxes.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get\";\nimport { CmsModelField, CmsModelFieldRendererPlugin } from \"~/types\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { Checkbox, CheckboxGroup } from \"@webiny/ui/Checkbox\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/fields/text\");\n\nconst adaptToField = (field: CmsModelField, value: string) => {\n return field.type === \"number\" ? Number(value) : value;\n};\n\nconst plugin: CmsModelFieldRendererPlugin = {\n type: \"cms-editor-field-renderer\",\n name: \"cms-editor-field-renderer-checkboxes-buttons\",\n renderer: {\n rendererName: \"checkboxes\",\n name: t`Checkboxes`,\n description: t`Renders checkboxes, allowing selection of multiple values.`,\n canUse({ field }) {\n return !!field.multipleValues && !!get(field, \"predefinedValues.enabled\");\n },\n render({ field, getBind }) {\n const Bind = getBind();\n\n const { values: predefinedOptions = [] } = field.predefinedValues || {\n values: []\n };\n\n // For `number` field, we want to convert the value to actual Number.\n const options = predefinedOptions.map(opt => ({\n ...opt,\n value: adaptToField(field, opt.value)\n }));\n\n const defaults = options.filter(option => option.selected);\n const defaultValue = defaults.length > 0 ? defaults.map(opt => opt.value) : undefined;\n\n return (\n <Bind defaultValue={defaultValue}>\n <CheckboxGroup label={field.label} description={field.helpText}>\n {({ onChange, getValue }) => (\n <React.Fragment>\n {options.map((option, index) => {\n return (\n <div key={String(option.value) + index}>\n <Checkbox\n label={option.label}\n value={getValue(option.value)}\n onChange={onChange(option.value)}\n data-testid={`fr.input.${field.label}`}\n />\n </div>\n );\n })}\n </React.Fragment>\n )}\n </CheckboxGroup>\n </Bind>\n );\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAA8D,IAAAI,eAAA,EAAAC,gBAAA;AAE9D,IAAMC,CAAC,GAAGC,UAAI,CAACC,EAAE,CAAC,oCAAoC,CAAC;AAEvD,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,KAAoB,EAAEC,KAAa,EAAK;EAC1D,OAAOD,KAAK,CAACE,IAAI,KAAK,QAAQ,GAAGC,MAAM,CAACF,KAAK,CAAC,GAAGA,KAAK;AAC1D,CAAC;AAED,IAAMG,MAAmC,GAAG;EACxCF,IAAI,EAAE,2BAA2B;EACjCG,IAAI,EAAE,8CAA8C;EACpDC,QAAQ,EAAE;IACNC,YAAY,EAAE,YAAY;IAC1BF,IAAI,EAAET,CAAC,CAAAF,eAAA,KAAAA,eAAA,OAAAc,uBAAA,CAAAC,OAAA,mBAAY;IACnBC,WAAW,EAAEd,CAAC,CAAAD,gBAAA,KAAAA,gBAAA,OAAAa,uBAAA,CAAAC,OAAA,mEAA4D;IAC1EE,MAAM,WAAAA,OAAAC,IAAA,EAAY;MAAA,IAATZ,KAAK,GAAAY,IAAA,CAALZ,KAAK;MACV,OAAO,CAAC,CAACA,KAAK,CAACa,cAAc,IAAI,CAAC,CAAC,IAAAC,YAAG,EAACd,KAAK,EAAE,0BAA0B,CAAC;IAC7E,CAAC;IACDe,MAAM,WAAAA,OAAAC,KAAA,EAAqB;MAAA,IAAlBhB,KAAK,GAAAgB,KAAA,CAALh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Q,QACVlB,OAAO,CAACC,GAAG,CAAC,UAACK,MAAM,EAAEa,KAAK,EAAK;UAC5B,oBACIvD,MAAA,CAAAqB,OAAA,CAAA0B,aAAA;YAAKS,GAAG,EAAEC,MAAM,CAACf,MAAM,CAAC7B,KAAK,CAAC,GAAG0C;UAAM,gBACnCvD,MAAA,CAAAqB,OAAA,CAAA0B,aAAA,CAAC1C,SAAA,CAAAqD,QAAQ;YACLT,KAAK,EAAEP,MAAM,CAACO,KAAM;YACpBpC,KAAK,EAAEwC,QAAQ,CAACX,MAAM,CAAC7B,KAAK,CAAE;YAC9BuC,QAAQ,EAAEA,QAAQ,CAACV,MAAM,CAAC7B,KAAK,CAAE;YACjC,2BAAA8C,MAAA,CAAyB/C,KAAK,CAACqC,KAAK;UAAG,CAC1C,CACA,CAAC;QAEd,CAAC,CACW,CAAC;MAAA,CAEV,CACb,CAAC;IAEf;EACJ;AACJ,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAxC,OAAA,GAEaL,MAAM","ignoreList":[]}
|
|
@@ -32,7 +32,12 @@ var plugin = {
|
|
|
32
32
|
},
|
|
33
33
|
_ref3$values = _ref3.values,
|
|
34
34
|
options = _ref3$values === void 0 ? [] : _ref3$values;
|
|
35
|
-
|
|
35
|
+
var defaultOption = options.find(function (opt) {
|
|
36
|
+
return opt.selected === true;
|
|
37
|
+
});
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(Bind, {
|
|
39
|
+
defaultValue: defaultOption ? defaultOption.value : undefined
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(_Radio.RadioGroup, {
|
|
36
41
|
label: field.label,
|
|
37
42
|
description: field.helpText
|
|
38
43
|
}, function (_ref4) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_get","_i18n","_Radio","_templateObject","_templateObject2","t","i18n","ns","plugin","type","name","renderer","rendererName","_taggedTemplateLiteral2","default","description","canUse","_ref","field","multipleValues","get","render","_ref2","getBind","Bind","_ref3","predefinedValues","options","_ref3$values","values","createElement","RadioGroup","label","helpText","_ref4","onChange","getValue","Fragment","map","option","index","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_get","_i18n","_Radio","_templateObject","_templateObject2","t","i18n","ns","plugin","type","name","renderer","rendererName","_taggedTemplateLiteral2","default","description","canUse","_ref","field","multipleValues","get","render","_ref2","getBind","Bind","_ref3","predefinedValues","options","_ref3$values","values","defaultOption","find","opt","selected","createElement","defaultValue","value","undefined","RadioGroup","label","helpText","_ref4","onChange","getValue","Fragment","map","option","index","Number","key","String","Radio","concat","_default","exports"],"sources":["radioButtons.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get\";\nimport { CmsModelFieldRendererPlugin } from \"~/types\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { Radio, RadioGroup } from \"@webiny/ui/Radio\";\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.multipleValues && !!get(field, \"predefinedValues.enabled\");\n },\n render({ field, getBind }) {\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 <RadioGroup label={field.label} description={field.helpText}>\n {({ onChange, getValue }) => (\n <React.Fragment>\n {options.map((option, index) => {\n const value =\n field.type === \"number\"\n ? Number(option.value)\n : option.value;\n return (\n <div key={String(option.value) + index}>\n <Radio\n label={option.label}\n value={getValue(value)}\n onChange={onChange(value)}\n data-testid={`fr.input.${field.label}.${option.label}`}\n />\n </div>\n );\n })}\n </React.Fragment>\n )}\n </RadioGroup>\n </Bind>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AAc,QAAA,GAAAC,OAAA,CAAAxC,OAAA,GAEaN,MAAM","ignoreList":[]}
|
|
@@ -12,17 +12,6 @@ var _i18n = require("@webiny/app/i18n");
|
|
|
12
12
|
var _Select = require("@webiny/ui/Select");
|
|
13
13
|
var _templateObject, _templateObject2;
|
|
14
14
|
var t = _i18n.i18n.ns("app-headless-cms/admin/fields/text");
|
|
15
|
-
var getDefaultValue = function getDefaultValue(initialValue, options) {
|
|
16
|
-
if (initialValue) {
|
|
17
|
-
return initialValue || undefined;
|
|
18
|
-
} else if (!options) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
var selected = options.find(function (option) {
|
|
22
|
-
return !!option.selected;
|
|
23
|
-
});
|
|
24
|
-
return selected ? selected.value : undefined;
|
|
25
|
-
};
|
|
26
15
|
var plugin = {
|
|
27
16
|
type: "cms-editor-field-renderer",
|
|
28
17
|
name: "cms-editor-field-renderer-select-box",
|
|
@@ -39,17 +28,19 @@ var plugin = {
|
|
|
39
28
|
getBind = _ref2.getBind;
|
|
40
29
|
var Bind = getBind();
|
|
41
30
|
var _ref3 = field.predefinedValues || {},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return
|
|
46
|
-
value: value,
|
|
47
|
-
label: field.label,
|
|
48
|
-
description: field.helpText,
|
|
49
|
-
options: options,
|
|
50
|
-
"data-testid": "fr.input.select.".concat(field.label)
|
|
51
|
-
}));
|
|
31
|
+
_ref3$values = _ref3.values,
|
|
32
|
+
options = _ref3$values === void 0 ? [] : _ref3$values;
|
|
33
|
+
var defaultOption = options.find(function (option) {
|
|
34
|
+
return !!option.selected;
|
|
52
35
|
});
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(Bind, {
|
|
37
|
+
defaultValue: defaultOption ? defaultOption.value : undefined
|
|
38
|
+
}, /*#__PURE__*/_react.default.createElement(_Select.Select, {
|
|
39
|
+
label: field.label,
|
|
40
|
+
description: field.helpText,
|
|
41
|
+
options: options,
|
|
42
|
+
"data-testid": "fr.input.select.".concat(field.label)
|
|
43
|
+
}));
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_get","_i18n","_Select","_templateObject","_templateObject2","t","i18n","ns","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_get","_i18n","_Select","_templateObject","_templateObject2","t","i18n","ns","plugin","type","name","renderer","rendererName","_taggedTemplateLiteral2","default","description","canUse","_ref","field","multipleValues","get","render","_ref2","getBind","Bind","_ref3","predefinedValues","_ref3$values","values","options","defaultOption","find","option","selected","createElement","defaultValue","value","undefined","Select","label","helpText","concat","_default","exports"],"sources":["select.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport { CmsModelFieldRendererPlugin } from \"~/types\";\nimport { Select } from \"@webiny/ui/Select\";\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.multipleValues && !!get(field, \"predefinedValues.enabled\");\n },\n render({ field, getBind }) {\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 <Select\n label={field.label}\n description={field.helpText}\n options={options}\n data-testid={`fr.input.select.${field.label}`}\n />\n </Bind>\n );\n }\n }\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,IAAAG,OA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AAAoB,aAAA,CAAChC,OAAA,CAAAoC,MAAM;QACHC,KAAK,EAAErB,KAAK,CAACqB,KAAM;QACnBxB,WAAW,EAAEG,KAAK,CAACsB,QAAS;QAC5BX,OAAO,EAAEA,OAAQ;QACjB,kCAAAY,MAAA,CAAgCvB,KAAK,CAACqB,KAAK;MAAG,CACjD,CACC,CAAC;IAEf;EACJ;AACJ,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAA7B,OAAA,GAEaN,MAAM","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-headless-cms",
|
|
3
|
-
"version": "5.40.
|
|
3
|
+
"version": "5.40.2-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,30 +28,30 @@
|
|
|
28
28
|
"@material-design-icons/svg": "0.14.13",
|
|
29
29
|
"@svgr/webpack": "6.5.1",
|
|
30
30
|
"@types/react": "18.2.79",
|
|
31
|
-
"@webiny/app": "5.40.
|
|
32
|
-
"@webiny/app-aco": "5.40.
|
|
33
|
-
"@webiny/app-admin": "5.40.
|
|
34
|
-
"@webiny/app-graphql-playground": "5.40.
|
|
35
|
-
"@webiny/app-headless-cms-common": "5.40.
|
|
36
|
-
"@webiny/app-i18n": "5.40.
|
|
37
|
-
"@webiny/app-plugin-admin-welcome-screen": "5.40.
|
|
38
|
-
"@webiny/app-security": "5.40.
|
|
39
|
-
"@webiny/app-tenancy": "5.40.
|
|
40
|
-
"@webiny/app-trash-bin": "5.40.
|
|
41
|
-
"@webiny/error": "5.40.
|
|
42
|
-
"@webiny/feature-flags": "5.40.
|
|
43
|
-
"@webiny/form": "5.40.
|
|
44
|
-
"@webiny/lexical-editor": "5.40.
|
|
45
|
-
"@webiny/lexical-nodes": "5.40.
|
|
46
|
-
"@webiny/lexical-theme": "5.40.
|
|
47
|
-
"@webiny/plugins": "5.40.
|
|
48
|
-
"@webiny/react-composition": "5.40.
|
|
49
|
-
"@webiny/react-properties": "5.40.
|
|
50
|
-
"@webiny/react-router": "5.40.
|
|
51
|
-
"@webiny/theme": "5.40.
|
|
52
|
-
"@webiny/ui": "5.40.
|
|
53
|
-
"@webiny/utils": "5.40.
|
|
54
|
-
"@webiny/validation": "5.40.
|
|
31
|
+
"@webiny/app": "5.40.2-beta.0",
|
|
32
|
+
"@webiny/app-aco": "5.40.2-beta.0",
|
|
33
|
+
"@webiny/app-admin": "5.40.2-beta.0",
|
|
34
|
+
"@webiny/app-graphql-playground": "5.40.2-beta.0",
|
|
35
|
+
"@webiny/app-headless-cms-common": "5.40.2-beta.0",
|
|
36
|
+
"@webiny/app-i18n": "5.40.2-beta.0",
|
|
37
|
+
"@webiny/app-plugin-admin-welcome-screen": "5.40.2-beta.0",
|
|
38
|
+
"@webiny/app-security": "5.40.2-beta.0",
|
|
39
|
+
"@webiny/app-tenancy": "5.40.2-beta.0",
|
|
40
|
+
"@webiny/app-trash-bin": "5.40.2-beta.0",
|
|
41
|
+
"@webiny/error": "5.40.2-beta.0",
|
|
42
|
+
"@webiny/feature-flags": "5.40.2-beta.0",
|
|
43
|
+
"@webiny/form": "5.40.2-beta.0",
|
|
44
|
+
"@webiny/lexical-editor": "5.40.2-beta.0",
|
|
45
|
+
"@webiny/lexical-nodes": "5.40.2-beta.0",
|
|
46
|
+
"@webiny/lexical-theme": "5.40.2-beta.0",
|
|
47
|
+
"@webiny/plugins": "5.40.2-beta.0",
|
|
48
|
+
"@webiny/react-composition": "5.40.2-beta.0",
|
|
49
|
+
"@webiny/react-properties": "5.40.2-beta.0",
|
|
50
|
+
"@webiny/react-router": "5.40.2-beta.0",
|
|
51
|
+
"@webiny/theme": "5.40.2-beta.0",
|
|
52
|
+
"@webiny/ui": "5.40.2-beta.0",
|
|
53
|
+
"@webiny/utils": "5.40.2-beta.0",
|
|
54
|
+
"@webiny/validation": "5.40.2-beta.0",
|
|
55
55
|
"apollo-cache": "1.3.5",
|
|
56
56
|
"apollo-client": "2.6.10",
|
|
57
57
|
"apollo-link": "1.2.14",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"@babel/preset-react": "7.24.1",
|
|
86
86
|
"@babel/preset-typescript": "7.24.1",
|
|
87
87
|
"@emotion/babel-plugin": "11.11.0",
|
|
88
|
-
"@webiny/cli": "5.40.
|
|
89
|
-
"@webiny/project-utils": "5.40.
|
|
88
|
+
"@webiny/cli": "5.40.2-beta.0",
|
|
89
|
+
"@webiny/project-utils": "5.40.2-beta.0",
|
|
90
90
|
"babel-plugin-module-resolver": "5.0.0",
|
|
91
91
|
"rimraf": "5.0.5",
|
|
92
92
|
"ttypescript": "1.5.15",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
]
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "cf2c1929dbb2f75bc25ed37ea9b411acd2409f6f"
|
|
119
119
|
}
|