@nolwenture/formik-jsonschema-form 1.0.0-beta.4 → 1.0.0-beta.7

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.
Files changed (49) hide show
  1. package/dist/cjs/Form/components/FieldInput.js +6 -1
  2. package/dist/cjs/Form/fields/ArrayField/ArrayField.js +20 -8
  3. package/dist/cjs/Form/fields/BooleanField/BooleanField.js +1 -1
  4. package/dist/cjs/Form/fields/BooleanField/styledComponents.js +4 -0
  5. package/dist/cjs/Form/fields/DateField/DateField.js +1 -1
  6. package/dist/cjs/Form/fields/MultipleChoiceField/MultipleChoiceField.js +1 -1
  7. package/dist/cjs/Form/fields/MultipleChoiceField/styledComponents.js +2 -0
  8. package/dist/cjs/Form/fields/ObjectField/ObjectField.js +12 -5
  9. package/dist/cjs/Form/fields/RadioField/RadioField.js +1 -1
  10. package/dist/cjs/Form/fields/RadioField/styledComponents.js +4 -0
  11. package/dist/cjs/Form/fields/StringField/StringField.js +4 -2
  12. package/dist/cjs/Form/fields/TextAreaField/TextAreaField.js +1 -1
  13. package/dist/cjs/Form/fields/ToggleField/ToggleField.js +1 -1
  14. package/dist/cjs/Form/fields/ToggleField/styledComponents.js +4 -0
  15. package/dist/cjs/FormView/FormView.js +10 -2
  16. package/dist/cjs/FormView/components/Field.js +101 -9
  17. package/dist/cjs/FormView/components/index.js +0 -2
  18. package/dist/esm/Form/components/FieldInput.js +5 -0
  19. package/dist/esm/Form/fields/ArrayField/ArrayField.js +20 -8
  20. package/dist/esm/Form/fields/BooleanField/BooleanField.js +1 -1
  21. package/dist/esm/Form/fields/BooleanField/styledComponents.js +4 -0
  22. package/dist/esm/Form/fields/DateField/DateField.js +1 -1
  23. package/dist/esm/Form/fields/MultipleChoiceField/MultipleChoiceField.js +1 -1
  24. package/dist/esm/Form/fields/MultipleChoiceField/styledComponents.js +2 -0
  25. package/dist/esm/Form/fields/ObjectField/ObjectField.js +12 -5
  26. package/dist/esm/Form/fields/RadioField/RadioField.js +1 -1
  27. package/dist/esm/Form/fields/RadioField/styledComponents.js +4 -0
  28. package/dist/esm/Form/fields/StringField/StringField.js +4 -2
  29. package/dist/esm/Form/fields/TextAreaField/TextAreaField.js +1 -1
  30. package/dist/esm/Form/fields/ToggleField/ToggleField.js +1 -1
  31. package/dist/esm/Form/fields/ToggleField/styledComponents.js +4 -0
  32. package/dist/esm/FormView/FormView.js +6 -1
  33. package/dist/esm/FormView/components/Field.js +94 -7
  34. package/dist/esm/FormView/components/index.js +0 -2
  35. package/dist/types/Form/components/FieldInput.d.ts +5 -0
  36. package/dist/types/Form/components/index.d.ts +5 -0
  37. package/dist/types/Form/templates/ArrayFieldTemplate/types.d.ts +0 -4
  38. package/dist/types/Form/templates/FieldTemplate/types.d.ts +0 -4
  39. package/dist/types/FormView/FormView.d.ts +2 -0
  40. package/dist/types/FormView/components/Field.d.ts +36 -3
  41. package/dist/types/FormView/components/index.d.ts +15 -14
  42. package/dist/types/FormView/templates/ArrayFieldTemplate/types.d.ts +0 -4
  43. package/dist/types/FormView/templates/FieldTemplate/types.d.ts +0 -4
  44. package/dist/types/common/types/Field.d.ts +0 -3
  45. package/dist/types/common/types/Schemas.d.ts +11 -8
  46. package/package.json +20 -14
  47. package/dist/cjs/FormView/components/old_styledComponents.js +0 -65
  48. package/dist/esm/FormView/components/old_styledComponents.js +0 -57
  49. package/dist/types/FormView/components/old_styledComponents.d.ts +0 -32
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.FieldInput = exports.FieldHelp = exports.FieldDescription = exports.FieldTitle = exports.FieldWrapper = void 0;
26
+ exports.SelectFieldInput = exports.FieldInput = exports.FieldHelp = exports.FieldDescription = exports.FieldTitle = exports.FieldWrapper = void 0;
27
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
28
  const styled_components_1 = require("styled-components");
29
29
  const formik = __importStar(require("formik"));
@@ -57,3 +57,8 @@ exports.FieldHelp = styled_components_1.styled.p `
57
57
  exports.FieldInput = (0, styled_components_1.styled)(({ formikAs, ...props }) => {
58
58
  return (0, jsx_runtime_1.jsx)(formik.Field, { ...props, as: formikAs });
59
59
  }) ``;
60
+ exports.SelectFieldInput = (0, styled_components_1.styled)(exports.FieldInput) `
61
+ &[readonly] {
62
+ pointer-events: none;
63
+ }
64
+ `;
@@ -32,7 +32,7 @@ const moveInArray = (values, index, direction) => {
32
32
  }
33
33
  };
34
34
  const ArrayField = (props) => {
35
- const { fields: { SchemaField }, templates: { ArrayFieldTemplate, FieldTemplate }, components: { FieldInput, ArrayFieldItem, ArrayFieldItemButtons, ArrayFieldList, ArrayFieldAddButton, ArrayFieldRemoveButton, ArrayFieldUpButton, ArrayFieldDownButton, }, useItemsAsAdditionalItems, } = (0, react_1.useContext)(FormRegistry_1.FormRegistry);
35
+ const { fields: { SchemaField }, templates: { ArrayFieldTemplate, FieldTemplate }, components: { SelectFieldInput, ArrayFieldItem, ArrayFieldItemButtons, ArrayFieldList, ArrayFieldAddButton, ArrayFieldRemoveButton, ArrayFieldUpButton, ArrayFieldDownButton, }, useItemsAsAdditionalItems, } = (0, react_1.useContext)(FormRegistry_1.FormRegistry);
36
36
  (0, hooks_1.useSetDefault)(props);
37
37
  const { name, schema, uiSchema } = props;
38
38
  const { type, props: inputProps } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
@@ -98,16 +98,28 @@ const ArrayField = (props) => {
98
98
  // Backwards compatibility ends
99
99
  const { disabled } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
100
100
  const valueArray = Array.isArray(value) ? value : undefined;
101
- return schema.anyOf !== undefined ? ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-array": name, children: (0, jsx_runtime_1.jsx)(FieldInput, { type,
102
- ...inputProps, name: name, formikAs: "select", multiple: enums?.type === utils_1.EnumsTypes.MULTI_SELECT, children: enums?.values.map((option, index) => ((0, jsx_runtime_1.jsx)("option", { value: option.const, children: option.title }, index))) }) })) : ((0, jsx_runtime_1.jsxs)(ArrayFieldTemplate, { ...props, "data-fjsf-array": name, children: [(0, jsx_runtime_1.jsxs)(ArrayFieldList, { children: [(items || []).map((itemSchema, index) => ((0, jsx_runtime_1.jsx)(ArrayFieldItem, { children: (0, jsx_runtime_1.jsx)(SchemaField, { name: `${name}[${index}]`, schema: typeof itemSchema !== "boolean" ? itemSchema : {}, uiSchema: uiSchema?.[index] || uiSchema?.items,
101
+ const preventManipulation = disabled || schema.readOnly;
102
+ return schema.anyOf !== undefined ? ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-array": name, children: (0, jsx_runtime_1.jsx)(SelectFieldInput, { type,
103
+ readOnly: schema.readOnly,
104
+ ...inputProps, name: name, formikAs: "select", multiple: enums?.type === utils_1.EnumsTypes.MULTI_SELECT, children: enums?.values.map((option, index) => ((0, jsx_runtime_1.jsx)("option", { value: option.const, children: option.title }, index))) }) })) : ((0, jsx_runtime_1.jsxs)(ArrayFieldTemplate, { ...props, "data-fjsf-array": name, children: [(0, jsx_runtime_1.jsxs)(ArrayFieldList, { children: [(items || []).map((itemSchema, index) => ((0, jsx_runtime_1.jsx)(ArrayFieldItem, { children: (0, jsx_runtime_1.jsx)(SchemaField, { name: `${name}[${index}]`, schema: prepareChildSchema(itemSchema, schema), uiSchema: {
105
+ disabled,
106
+ ...(uiSchema?.[index] || uiSchema?.items),
107
+ },
103
108
  // "true" will prevent validation for required array fields
104
109
  // since a value always exists in the array
105
- forceDefaultValue: false }) }, index))), (valueArray?.slice(items.length) || []).map((_, index) => ((0, jsx_runtime_1.jsxs)(ArrayFieldItem, { children: [(0, jsx_runtime_1.jsx)(SchemaField, { name: `${name}[${index + items.length}]`, schema: additionalItems && typeof additionalItems !== "boolean"
106
- ? additionalItems
107
- : {}, uiSchema: {
110
+ forceDefaultValue: false }) }, index))), (valueArray?.slice(items.length) || []).map((_, index) => ((0, jsx_runtime_1.jsxs)(ArrayFieldItem, { children: [(0, jsx_runtime_1.jsx)(SchemaField, { name: `${name}[${index + items.length}]`, schema: prepareChildSchema(additionalItems, schema), uiSchema: {
108
111
  disabled,
109
112
  ...(uiSchema?.[index + items.length] || uiSchema?.items),
110
- } }), (0, jsx_runtime_1.jsxs)(ArrayFieldItemButtons, { children: [(0, jsx_runtime_1.jsx)(ArrayFieldRemoveButton, { ...(uiSchema?.["ui:removeButtonOptions"]?.props ?? {}), onClick: () => setValue(removeFromArray(value, index + items.length)), children: uiSchema?.["ui:removeButtonOptions"]?.content ?? "-" }), value.length > 1 && index > 0 && ((0, jsx_runtime_1.jsx)(ArrayFieldUpButton, { ...(uiSchema?.["ui:upButtonOptions"]?.props ?? {}), onClick: () => setValue(moveInArray(value, index + items.length, -1)), children: uiSchema?.["ui:upButtonOptions"]?.content ?? "↑" })), value.length > 1 &&
111
- index < value?.slice(items.length).length - 1 && ((0, jsx_runtime_1.jsx)(ArrayFieldDownButton, { ...(uiSchema?.["ui:downButtonOptions"]?.props ?? {}), onClick: () => setValue(moveInArray(value, index + items.length, 1)), children: uiSchema?.["ui:downButtonOptions"]?.content ?? "↓" }))] })] }, index)))] }), additionalItems && ((0, jsx_runtime_1.jsx)(ArrayFieldAddButton, { ...(uiSchema?.["ui:addButtonOptions"]?.props ?? {}), onClick: () => setValue(appendArray(value)), children: uiSchema?.["ui:addButtonOptions"]?.content ?? "+" }))] }));
113
+ } }), !preventManipulation && ((0, jsx_runtime_1.jsxs)(ArrayFieldItemButtons, { children: [(0, jsx_runtime_1.jsx)(ArrayFieldRemoveButton, { ...(uiSchema?.["ui:removeButtonOptions"]?.props ?? {}), onClick: () => setValue(removeFromArray(value, index + items.length)), children: uiSchema?.["ui:removeButtonOptions"]?.content ?? "-" }), value.length > 1 && index > 0 && ((0, jsx_runtime_1.jsx)(ArrayFieldUpButton, { ...(uiSchema?.["ui:upButtonOptions"]?.props ?? {}), onClick: () => setValue(moveInArray(value, index + items.length, -1)), children: uiSchema?.["ui:upButtonOptions"]?.content ?? "↑" })), value.length > 1 &&
114
+ index < value?.slice(items.length).length - 1 && ((0, jsx_runtime_1.jsx)(ArrayFieldDownButton, { ...(uiSchema?.["ui:downButtonOptions"]?.props ?? {}), onClick: () => setValue(moveInArray(value, index + items.length, 1)), children: uiSchema?.["ui:downButtonOptions"]?.content ?? "↓" }))] }))] }, index)))] }), additionalItems && !preventManipulation && ((0, jsx_runtime_1.jsx)(ArrayFieldAddButton, { ...(uiSchema?.["ui:addButtonOptions"]?.props ?? {}), onClick: () => setValue(appendArray(value)), children: uiSchema?.["ui:addButtonOptions"]?.content ?? "+" }))] }));
112
115
  };
113
116
  exports.ArrayField = ArrayField;
117
+ function prepareChildSchema(childSchema, parentSchema) {
118
+ if (!childSchema || typeof childSchema === "boolean") {
119
+ return {};
120
+ }
121
+ if (parentSchema.readOnly) {
122
+ return { ...childSchema, readOnly: parentSchema.readOnly };
123
+ }
124
+ return childSchema;
125
+ }
@@ -13,7 +13,7 @@ const BooleanField = (props) => {
13
13
  const { name, uiSchema } = props;
14
14
  const { label, props: inputProps } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
15
15
  const { values, setValues } = (0, formik_1.useFormikContext)();
16
- return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: (0, jsx_runtime_1.jsxs)(BooleanFieldWrapper, { children: [(0, jsx_runtime_1.jsx)(FieldInput, { ...inputProps, name: name, type: "checkbox" }), (0, jsx_runtime_1.jsx)("span", { onClick: () => {
16
+ return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: (0, jsx_runtime_1.jsxs)(BooleanFieldWrapper, { children: [(0, jsx_runtime_1.jsx)(FieldInput, { readOnly: props.schema.readOnly, ...inputProps, name: name, type: "checkbox" }), (0, jsx_runtime_1.jsx)("span", { onClick: () => {
17
17
  setValues({
18
18
  ...values,
19
19
  [name]: !values?.[name],
@@ -12,4 +12,8 @@ exports.BooleanFieldWrapper = styled_components_1.styled.div `
12
12
  gap: ${(props) => props.theme.spacing.s};
13
13
 
14
14
  ${common_1.commonCheckboxStyles}
15
+
16
+ & > input[readonly], & > input[readonly] ~ span {
17
+ pointer-events: none;
18
+ }
15
19
  `;
@@ -12,6 +12,6 @@ const DateField = (props) => {
12
12
  (0, hooks_1.useSetDefault)(props);
13
13
  const { name, uiSchema } = props;
14
14
  const { props: inputProps } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
15
- return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-string": name, children: (0, jsx_runtime_1.jsx)(styledComponents_1.DateFieldWrapper, { children: (0, jsx_runtime_1.jsx)(FieldInput, { ...inputProps, name: name, type: "date" }) }) }));
15
+ return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-string": name, children: (0, jsx_runtime_1.jsx)(styledComponents_1.DateFieldWrapper, { children: (0, jsx_runtime_1.jsx)(FieldInput, { readOnly: props.schema.readOnly, ...inputProps, name: name, type: "date" }) }) }));
16
16
  };
17
17
  exports.DateField = DateField;
@@ -27,6 +27,6 @@ const MultipleChoiceField = (props) => {
27
27
  return { "data-fjsf-string": name };
28
28
  }
29
29
  })();
30
- return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, ...fieldDataAttribute, children: (0, jsx_runtime_1.jsx)(MultipleChoiceFieldInput, { inputProps: inputProps, name: name, enums: enums, style: style, value: value, form: form }) }));
30
+ return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, ...fieldDataAttribute, children: (0, jsx_runtime_1.jsx)(MultipleChoiceFieldInput, { inputProps: { readOnly: props.schema.readOnly, ...inputProps }, name: name, enums: enums, style: style, value: value, form: form }) }));
31
31
  };
32
32
  exports.MultipleChoiceField = MultipleChoiceField;
@@ -11,6 +11,8 @@ exports.MultipleChoiceFieldContainer = (0, styled_components_1.default)(styledCo
11
11
  ${common_1.commonCheckboxStyles}
12
12
  ${common_1.commonRadioStyles}
13
13
  font-family: ${(props) => props.theme.typography.fontFamily.base};
14
+ flex-wrap: wrap;
15
+ justify-content: start;
14
16
  `;
15
17
  exports.MultipleChoiceFieldElement = (0, styled_components_1.default)(styledComponents_1.RadioFieldElement) ``;
16
18
  exports.MultipleChoiceFieldInputElement = (0, styled_components_1.default)(styledComponents_1.RadioFieldInputElement) ``;
@@ -59,7 +59,7 @@ const ObjectField = (props) => {
59
59
  const childSchema = properties?.[child];
60
60
  if (!childSchema)
61
61
  return undefined;
62
- return ((0, jsx_runtime_1.jsx)(SchemaField, { required: required?.includes(child), name: name ? [name, child].join(".") : child, schema: typeof childSchema !== "boolean" ? childSchema : {}, uiSchema: uiSchema?.[child] }, child));
62
+ return ((0, jsx_runtime_1.jsx)(SchemaField, { required: required?.includes(child), name: name ? [name, child].join(".") : child, schema: prepareChildSchema(childSchema, schema), uiSchema: uiSchema?.[child] }, child));
63
63
  }
64
64
  else {
65
65
  const { title, fields, collapsible } = child;
@@ -67,14 +67,12 @@ const ObjectField = (props) => {
67
67
  const childSchema = properties?.[child2];
68
68
  if (!childSchema)
69
69
  return undefined;
70
- return ((0, jsx_runtime_1.jsx)(SchemaField, { name: name ? [name, child2].join(".") : child2, schema: typeof childSchema !== "boolean" ? childSchema : {}, uiSchema: uiSchema?.[child2] }, child2));
70
+ return ((0, jsx_runtime_1.jsx)(SchemaField, { name: name ? [name, child2].join(".") : child2, schema: prepareChildSchema(childSchema, schema), uiSchema: uiSchema?.[child2] }, child2));
71
71
  }) }, fields.join("_")));
72
72
  }
73
73
  })
74
74
  .filter((x) => x), (!hideUnmarkedAdditionalProperties || additionalProperties) &&
75
- Object.entries(additionalValues || {}).map(([childName]) => ((0, jsx_runtime_1.jsxs)(ObjectFieldItem, { children: [(0, jsx_runtime_1.jsx)(SchemaField, { required: required?.includes(childName), name: name ? [name, childName].join(".") : childName, schema: typeof schema.additionalProperties !== "boolean"
76
- ? schema.additionalProperties
77
- : {}, uiSchema: uiSchema?.[childName] }, childName), (0, jsx_runtime_1.jsx)(ObjectFieldItemButtons, { children: getObjectFieldButton({
75
+ Object.entries(additionalValues || {}).map(([childName]) => ((0, jsx_runtime_1.jsxs)(ObjectFieldItem, { children: [(0, jsx_runtime_1.jsx)(SchemaField, { required: required?.includes(childName), name: name ? [name, childName].join(".") : childName, schema: prepareChildSchema(schema.additionalProperties, schema), uiSchema: uiSchema?.[childName] }, childName), (0, jsx_runtime_1.jsx)(ObjectFieldItemButtons, { children: getObjectFieldButton({
78
76
  purpose: types_1.ObjectFieldButtonPurpose.REMOVE,
79
77
  onClick: () => {
80
78
  const { [childName]: _removedProperty, ...newValue } = value;
@@ -94,3 +92,12 @@ const ObjectField = (props) => {
94
92
  })] }));
95
93
  };
96
94
  exports.ObjectField = ObjectField;
95
+ function prepareChildSchema(childSchema, parentSchema) {
96
+ if (!childSchema || typeof childSchema === "boolean") {
97
+ return {};
98
+ }
99
+ if (parentSchema.readOnly) {
100
+ return { ...childSchema, readOnly: parentSchema.readOnly };
101
+ }
102
+ return childSchema;
103
+ }
@@ -11,6 +11,6 @@ const RadioField = (props) => {
11
11
  (0, hooks_1.useSetDefault)(props);
12
12
  const { name, uiSchema } = props;
13
13
  const { label, props: inputProps } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
14
- return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: (0, jsx_runtime_1.jsx)(RadioFieldInput, { inputProps: inputProps, label: label, name: name }) }));
14
+ return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: (0, jsx_runtime_1.jsx)(RadioFieldInput, { inputProps: { readOnly: props.schema.readOnly, ...inputProps }, label: label, name: name }) }));
15
15
  };
16
16
  exports.RadioField = RadioField;
@@ -14,6 +14,10 @@ exports.RadioFieldContainer = styled_components_1.styled.div `
14
14
  exports.RadioFieldElement = styled_components_1.styled.label `
15
15
  display: inline-flex;
16
16
  align-items: center;
17
+
18
+ &:has(input[readonly]) {
19
+ pointer-events: none;
20
+ }
17
21
  `;
18
22
  exports.RadioFieldInputElement = (0, styled_components_1.styled)(FieldInput_1.FieldInput) `
19
23
  margin: unset;
@@ -9,7 +9,7 @@ const FormRegistry_1 = require("../../FormRegistry");
9
9
  const hooks_1 = require("../../hooks");
10
10
  const styledComponents_1 = require("./styledComponents");
11
11
  const StringField = (props) => {
12
- const { templates: { FieldTemplate }, components: { FieldInput }, } = (0, react_1.useContext)(FormRegistry_1.FormRegistry);
12
+ const { templates: { FieldTemplate }, components: { FieldInput, SelectFieldInput }, } = (0, react_1.useContext)(FormRegistry_1.FormRegistry);
13
13
  (0, hooks_1.useSetDefault)(props);
14
14
  const { name, uiSchema = {}, schema } = props;
15
15
  const { type, placeholder, props: inputProps, } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
@@ -20,7 +20,8 @@ const StringField = (props) => {
20
20
  : { "data-fjsf-number": name };
21
21
  switch (enums?.type) {
22
22
  case "select":
23
- return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, ...fieldDataAttribute, children: (0, jsx_runtime_1.jsx)(styledComponents_1.StringFieldWrapper, { children: (0, jsx_runtime_1.jsxs)(FieldInput, { type,
23
+ return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, ...fieldDataAttribute, children: (0, jsx_runtime_1.jsx)(styledComponents_1.StringFieldWrapper, { children: (0, jsx_runtime_1.jsxs)(SelectFieldInput, { type,
24
+ readOnly: props.schema.readOnly,
24
25
  ...inputProps, name: name, formikAs: "select", onChange: (e) => {
25
26
  const selectedOption = enums?.values.find((option) => option.const.toString() === e.target.value);
26
27
  const selectedValue = selectedOption
@@ -33,6 +34,7 @@ const StringField = (props) => {
33
34
  default:
34
35
  return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, ...fieldDataAttribute, children: (0, jsx_runtime_1.jsx)(styledComponents_1.StringFieldWrapper, { children: (0, jsx_runtime_1.jsx)(FieldInput, { type,
35
36
  placeholder,
37
+ readOnly: props.schema.readOnly,
36
38
  ...inputProps, name: name }) }) }));
37
39
  }
38
40
  };
@@ -11,6 +11,6 @@ const TextAreaField = (props) => {
11
11
  (0, hooks_1.useSetDefault)(props);
12
12
  const { name, uiSchema } = props;
13
13
  const { props: inputProps } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
14
- return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-string": name, children: (0, jsx_runtime_1.jsx)(TextAreaFieldInput, { ...inputProps, name: name, formikAs: "textarea" }) }));
14
+ return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-string": name, children: (0, jsx_runtime_1.jsx)(TextAreaFieldInput, { readOnly: props.schema.readOnly, ...inputProps, name: name, formikAs: "textarea" }) }));
15
15
  };
16
16
  exports.TextAreaField = TextAreaField;
@@ -11,6 +11,6 @@ const ToggleField = (props) => {
11
11
  (0, hooks_1.useSetDefault)(props);
12
12
  const { name, uiSchema } = props;
13
13
  const { props: inputProps } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
14
- return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: (0, jsx_runtime_1.jsx)(ToggleFieldInput, { inputProps: inputProps, name: name }) }));
14
+ return ((0, jsx_runtime_1.jsx)(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: (0, jsx_runtime_1.jsx)(ToggleFieldInput, { inputProps: { readOnly: props.schema.readOnly, ...inputProps }, name: name }) }));
15
15
  };
16
16
  exports.ToggleField = ToggleField;
@@ -33,6 +33,10 @@ exports.ToggleFieldLabel = styled_components_1.styled.label `
33
33
  position: relative;
34
34
  display: inline-block;
35
35
  width: 2rem;
36
+
37
+ &:has(input[readonly]) {
38
+ pointer-events: none;
39
+ }
36
40
  `;
37
41
  exports.ToggleFieldInputElement = (0, styled_components_1.styled)(FieldInput_1.FieldInput) `
38
42
  opacity: 0;
@@ -1,12 +1,20 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormView = void 0;
6
+ exports.FormView = exports.FormWrapper = void 0;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const styled_components_1 = __importDefault(require("styled-components"));
5
9
  const utils_1 = require("../utils");
6
10
  const fields_1 = require("./fields");
7
11
  const components_1 = require("./components");
8
12
  const templates_1 = require("./templates");
9
13
  const FormViewRegistry_1 = require("./FormViewRegistry");
14
+ exports.FormWrapper = styled_components_1.default.div `
15
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
16
+ padding: ${(props) => props.theme.spacing.xxxxxl};
17
+ `;
10
18
  const FormView = (props) => {
11
19
  (0, utils_1.warnFromUnsupportedKeys)("Form", props, [
12
20
  "schema",
@@ -37,6 +45,6 @@ const FormView = (props) => {
37
45
  };
38
46
  const { Form: FormEl } = registry.components;
39
47
  const SchemaField = registry.fields.SchemaField;
40
- return ((0, jsx_runtime_1.jsx)(FormViewRegistry_1.FormViewRegistry.Provider, { value: registry, children: (0, jsx_runtime_1.jsx)(FormEl, { className: className, children: (0, jsx_runtime_1.jsx)(SchemaField, { name: "", schema: schema, uiSchema: uiSchema, values: values }) }) }));
48
+ return ((0, jsx_runtime_1.jsx)(exports.FormWrapper, { children: (0, jsx_runtime_1.jsx)(FormViewRegistry_1.FormViewRegistry.Provider, { value: registry, children: (0, jsx_runtime_1.jsx)(FormEl, { className: className, children: (0, jsx_runtime_1.jsx)(SchemaField, { name: "", schema: schema, uiSchema: uiSchema, values: values }) }) }) }));
41
49
  };
42
50
  exports.FormView = FormView;
@@ -1,13 +1,105 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FieldDescription = exports.FieldTitle = exports.FieldWrapper = void 0;
4
- const styled_components_1 = require("styled-components");
5
- exports.FieldWrapper = styled_components_1.styled.div ``;
6
- exports.FieldTitle = styled_components_1.styled.label `
7
- font-size: ${(props) => props.theme.typography.size.base};
6
+ exports.MultipleChoiceFieldValue = exports.BooleanFieldValue = exports.MultipleChoiceFieldWrapper = exports.BooleanFieldWrapper = exports.EJSFieldValue = exports.ArrayFieldItem = exports.TextAreaValue = exports.StringFieldValue = exports.FieldDescription = exports.FieldTitle = exports.FieldWrapper = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const styledComponents_1 = require("../../Form/fields/MultipleChoiceField/styledComponents");
10
+ const getStyle_1 = require("../../utils/getStyle");
11
+ exports.FieldWrapper = styled_components_1.default.div `
12
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
13
+ width: clamp(20rem, 100%, 70rem);
14
+ margin: ${(props) => `${props.theme.spacing.l} 0`};
15
+ `;
16
+ exports.FieldTitle = styled_components_1.default.label `
17
+ color: ${(props) => props.theme.color.text.default};
18
+ display: inline-block;
19
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
20
+ font-size: ${(props) => props.theme.typography.size.h3};
21
+ font-weight: ${(props) => props.theme.typography.weight.bold};
22
+ margin: ${(props) => `${props.theme.spacing.xs} 0 0 0`};
23
+ border-top: ${(props) => `${props.theme.strokeWidth.thin} solid ${props.theme.color.text.default}`};
24
+ padding-top: ${(props) => props.theme.spacing.s};
25
+ width: 100%;
26
+ `;
27
+ exports.FieldDescription = styled_components_1.default.div `
28
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
29
+ font-weight: ${(props) => props.theme.typography.weight.normal};
30
+ font-style: italic;
31
+ font-size: ${(props) => props.theme.typography.size.large};
32
+ margin-bottom: ${(props) => props.theme.spacing.xs};
33
+ max-width: 66ch;
34
+ `;
35
+ exports.StringFieldValue = styled_components_1.default.div `
36
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
37
+ margin-bottom: ${(props) => props.theme.spacing.m};
38
+ max-width: 66ch;
39
+ white-space: pre-line;
40
+ `;
41
+ exports.TextAreaValue = styled_components_1.default.div `
42
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
43
+ margin-bottom: ${(props) => props.theme.spacing.m};
44
+ max-width: 66ch;
45
+ white-space: pre-line;
46
+ `;
47
+ exports.ArrayFieldItem = styled_components_1.default.div `
48
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
49
+ `;
50
+ exports.EJSFieldValue = styled_components_1.default.div `
51
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
52
+ width: 100%;
53
+ `;
54
+ const NotSelected = styled_components_1.default.div `
55
+ opacity: 0.3;
56
+ display: flex;
57
+ align-items: start;
58
+ `;
59
+ const Selected = styled_components_1.default.div `
60
+ display: flex;
61
+ align-items: start;
62
+ `;
63
+ const SelectedBox = styled_components_1.default.span `
64
+ color: ${(props) => props.theme.color.background.default};
65
+ background: ${(props) => props.theme.color.text.default};
66
+ padding: ${(props) => `0 ${props.theme.spacing.xs}`};
67
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
68
+ font-size: ${(props) => props.theme.typography.size.small};
69
+ display: inline-flex;
70
+ justify-content: center;
71
+ align-items: start;
72
+ `;
73
+ const NotSelectedCircle = styled_components_1.default.span `
74
+ color: ${(props) => props.theme.color.background.default};
75
+ background: ${(props) => props.theme.color.text.default};
76
+ padding: ${(props) => props.theme.spacing.xxs};
77
+ border-radius: ${(props) => props.theme.borderRadius.circle};
8
78
  font-family: ${(props) => props.theme.typography.fontFamily.base};
9
- font-weight: ${(props) => props.theme.typography.weight.medium};
10
- margin-right: ${(props) => props.theme.spacing.s};
11
- color: ${(props) => props.theme.color.text.default};
79
+ font-size: ${(props) => props.theme.typography.size.small};
80
+ line-height: 1.1;
81
+ display: inline-flex;
82
+ justify-content: center;
83
+ align-items: start;
84
+ flex: 0 0 1rem;
85
+ `;
86
+ exports.BooleanFieldWrapper = styled_components_1.default.div `
87
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
88
+ `;
89
+ exports.MultipleChoiceFieldWrapper = styled_components_1.default.div `
90
+ label {
91
+ align-items: start;
92
+ }
12
93
  `;
13
- exports.FieldDescription = styled_components_1.styled.div ``;
94
+ const BooleanFieldValue = ({ name, className, value, label, }) => {
95
+ return ((0, jsx_runtime_1.jsx)("div", { className: className, children: value === true ? ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { children: "\u2713" }), (0, jsx_runtime_1.jsx)("span", { children: label !== undefined ? label : "Selected" })] })) : ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { children: "\u2716" }), (0, jsx_runtime_1.jsx)("span", { children: label !== undefined ? label : "Not selected" })] })) }));
96
+ };
97
+ exports.BooleanFieldValue = BooleanFieldValue;
98
+ const MultipleChoiceFieldValue = ({ inputProps, name, className, style, selected, notSelected }) => {
99
+ return ((0, jsx_runtime_1.jsx)(exports.MultipleChoiceFieldWrapper, { children: (0, jsx_runtime_1.jsxs)(styledComponents_1.MultipleChoiceFieldContainer, { className: className, style: (0, getStyle_1.getStyle)(style ?? ""), children: [!selected && !notSelected && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: "Nothing was selected" }), selected &&
100
+ selected.length > 0 &&
101
+ selected.map((s) => ((0, jsx_runtime_1.jsx)(styledComponents_1.MultipleChoiceFieldElement, { children: (0, jsx_runtime_1.jsxs)(Selected, { children: [(0, jsx_runtime_1.jsx)(SelectedBox, { children: "\u2713" }), (0, jsx_runtime_1.jsx)(styledComponents_1.MultipleChoiceFieldLabel, { children: s.title ?? "Hello" })] }) }, s.title ?? s))), notSelected &&
102
+ notSelected?.length > 0 &&
103
+ notSelected.map((n) => ((0, jsx_runtime_1.jsx)(styledComponents_1.MultipleChoiceFieldElement, { children: (0, jsx_runtime_1.jsxs)(NotSelected, { children: [(0, jsx_runtime_1.jsx)(NotSelectedCircle, { children: "\u2715" }), (0, jsx_runtime_1.jsx)(styledComponents_1.MultipleChoiceFieldLabel, { children: n.title })] }) }, n.title ?? n)))] }) }));
104
+ };
105
+ exports.MultipleChoiceFieldValue = MultipleChoiceFieldValue;
@@ -36,9 +36,7 @@ const templates_1 = require("../templates");
36
36
  const Field = __importStar(require("./Field"));
37
37
  const Form = __importStar(require("./Form"));
38
38
  const Icon = __importStar(require("./Icon"));
39
- const oldComponents = __importStar(require("./old_styledComponents"));
40
39
  exports.components = {
41
- ...oldComponents,
42
40
  ...fields_1.fieldComponents,
43
41
  ...templates_1.templateComponents,
44
42
  //Please keep this in alphabetical order
@@ -31,3 +31,8 @@ export const FieldHelp = styled.p `
31
31
  export const FieldInput = styled(({ formikAs, ...props }) => {
32
32
  return _jsx(formik.Field, { ...props, as: formikAs });
33
33
  }) ``;
34
+ export const SelectFieldInput = styled(FieldInput) `
35
+ &[readonly] {
36
+ pointer-events: none;
37
+ }
38
+ `;
@@ -29,7 +29,7 @@ const moveInArray = (values, index, direction) => {
29
29
  }
30
30
  };
31
31
  export const ArrayField = (props) => {
32
- const { fields: { SchemaField }, templates: { ArrayFieldTemplate, FieldTemplate }, components: { FieldInput, ArrayFieldItem, ArrayFieldItemButtons, ArrayFieldList, ArrayFieldAddButton, ArrayFieldRemoveButton, ArrayFieldUpButton, ArrayFieldDownButton, }, useItemsAsAdditionalItems, } = useContext(FormRegistry);
32
+ const { fields: { SchemaField }, templates: { ArrayFieldTemplate, FieldTemplate }, components: { SelectFieldInput, ArrayFieldItem, ArrayFieldItemButtons, ArrayFieldList, ArrayFieldAddButton, ArrayFieldRemoveButton, ArrayFieldUpButton, ArrayFieldDownButton, }, useItemsAsAdditionalItems, } = useContext(FormRegistry);
33
33
  useSetDefault(props);
34
34
  const { name, schema, uiSchema } = props;
35
35
  const { type, props: inputProps } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
@@ -95,15 +95,27 @@ export const ArrayField = (props) => {
95
95
  // Backwards compatibility ends
96
96
  const { disabled } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
97
97
  const valueArray = Array.isArray(value) ? value : undefined;
98
- return schema.anyOf !== undefined ? (_jsx(FieldTemplate, { ...props, "data-fjsf-array": name, children: _jsx(FieldInput, { type,
99
- ...inputProps, name: name, formikAs: "select", multiple: enums?.type === EnumsTypes.MULTI_SELECT, children: enums?.values.map((option, index) => (_jsx("option", { value: option.const, children: option.title }, index))) }) })) : (_jsxs(ArrayFieldTemplate, { ...props, "data-fjsf-array": name, children: [_jsxs(ArrayFieldList, { children: [(items || []).map((itemSchema, index) => (_jsx(ArrayFieldItem, { children: _jsx(SchemaField, { name: `${name}[${index}]`, schema: typeof itemSchema !== "boolean" ? itemSchema : {}, uiSchema: uiSchema?.[index] || uiSchema?.items,
98
+ const preventManipulation = disabled || schema.readOnly;
99
+ return schema.anyOf !== undefined ? (_jsx(FieldTemplate, { ...props, "data-fjsf-array": name, children: _jsx(SelectFieldInput, { type,
100
+ readOnly: schema.readOnly,
101
+ ...inputProps, name: name, formikAs: "select", multiple: enums?.type === EnumsTypes.MULTI_SELECT, children: enums?.values.map((option, index) => (_jsx("option", { value: option.const, children: option.title }, index))) }) })) : (_jsxs(ArrayFieldTemplate, { ...props, "data-fjsf-array": name, children: [_jsxs(ArrayFieldList, { children: [(items || []).map((itemSchema, index) => (_jsx(ArrayFieldItem, { children: _jsx(SchemaField, { name: `${name}[${index}]`, schema: prepareChildSchema(itemSchema, schema), uiSchema: {
102
+ disabled,
103
+ ...(uiSchema?.[index] || uiSchema?.items),
104
+ },
100
105
  // "true" will prevent validation for required array fields
101
106
  // since a value always exists in the array
102
- forceDefaultValue: false }) }, index))), (valueArray?.slice(items.length) || []).map((_, index) => (_jsxs(ArrayFieldItem, { children: [_jsx(SchemaField, { name: `${name}[${index + items.length}]`, schema: additionalItems && typeof additionalItems !== "boolean"
103
- ? additionalItems
104
- : {}, uiSchema: {
107
+ forceDefaultValue: false }) }, index))), (valueArray?.slice(items.length) || []).map((_, index) => (_jsxs(ArrayFieldItem, { children: [_jsx(SchemaField, { name: `${name}[${index + items.length}]`, schema: prepareChildSchema(additionalItems, schema), uiSchema: {
105
108
  disabled,
106
109
  ...(uiSchema?.[index + items.length] || uiSchema?.items),
107
- } }), _jsxs(ArrayFieldItemButtons, { children: [_jsx(ArrayFieldRemoveButton, { ...(uiSchema?.["ui:removeButtonOptions"]?.props ?? {}), onClick: () => setValue(removeFromArray(value, index + items.length)), children: uiSchema?.["ui:removeButtonOptions"]?.content ?? "-" }), value.length > 1 && index > 0 && (_jsx(ArrayFieldUpButton, { ...(uiSchema?.["ui:upButtonOptions"]?.props ?? {}), onClick: () => setValue(moveInArray(value, index + items.length, -1)), children: uiSchema?.["ui:upButtonOptions"]?.content ?? "↑" })), value.length > 1 &&
108
- index < value?.slice(items.length).length - 1 && (_jsx(ArrayFieldDownButton, { ...(uiSchema?.["ui:downButtonOptions"]?.props ?? {}), onClick: () => setValue(moveInArray(value, index + items.length, 1)), children: uiSchema?.["ui:downButtonOptions"]?.content ?? "↓" }))] })] }, index)))] }), additionalItems && (_jsx(ArrayFieldAddButton, { ...(uiSchema?.["ui:addButtonOptions"]?.props ?? {}), onClick: () => setValue(appendArray(value)), children: uiSchema?.["ui:addButtonOptions"]?.content ?? "+" }))] }));
110
+ } }), !preventManipulation && (_jsxs(ArrayFieldItemButtons, { children: [_jsx(ArrayFieldRemoveButton, { ...(uiSchema?.["ui:removeButtonOptions"]?.props ?? {}), onClick: () => setValue(removeFromArray(value, index + items.length)), children: uiSchema?.["ui:removeButtonOptions"]?.content ?? "-" }), value.length > 1 && index > 0 && (_jsx(ArrayFieldUpButton, { ...(uiSchema?.["ui:upButtonOptions"]?.props ?? {}), onClick: () => setValue(moveInArray(value, index + items.length, -1)), children: uiSchema?.["ui:upButtonOptions"]?.content ?? "↑" })), value.length > 1 &&
111
+ index < value?.slice(items.length).length - 1 && (_jsx(ArrayFieldDownButton, { ...(uiSchema?.["ui:downButtonOptions"]?.props ?? {}), onClick: () => setValue(moveInArray(value, index + items.length, 1)), children: uiSchema?.["ui:downButtonOptions"]?.content ?? "↓" }))] }))] }, index)))] }), additionalItems && !preventManipulation && (_jsx(ArrayFieldAddButton, { ...(uiSchema?.["ui:addButtonOptions"]?.props ?? {}), onClick: () => setValue(appendArray(value)), children: uiSchema?.["ui:addButtonOptions"]?.content ?? "+" }))] }));
109
112
  };
113
+ function prepareChildSchema(childSchema, parentSchema) {
114
+ if (!childSchema || typeof childSchema === "boolean") {
115
+ return {};
116
+ }
117
+ if (parentSchema.readOnly) {
118
+ return { ...childSchema, readOnly: parentSchema.readOnly };
119
+ }
120
+ return childSchema;
121
+ }
@@ -10,7 +10,7 @@ export const BooleanField = (props) => {
10
10
  const { name, uiSchema } = props;
11
11
  const { label, props: inputProps } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
12
12
  const { values, setValues } = useFormikContext();
13
- return (_jsx(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: _jsxs(BooleanFieldWrapper, { children: [_jsx(FieldInput, { ...inputProps, name: name, type: "checkbox" }), _jsx("span", { onClick: () => {
13
+ return (_jsx(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: _jsxs(BooleanFieldWrapper, { children: [_jsx(FieldInput, { readOnly: props.schema.readOnly, ...inputProps, name: name, type: "checkbox" }), _jsx("span", { onClick: () => {
14
14
  setValues({
15
15
  ...values,
16
16
  [name]: !values?.[name],
@@ -9,4 +9,8 @@ export const BooleanFieldWrapper = styled.div `
9
9
  gap: ${(props) => props.theme.spacing.s};
10
10
 
11
11
  ${commonCheckboxStyles}
12
+
13
+ & > input[readonly], & > input[readonly] ~ span {
14
+ pointer-events: none;
15
+ }
12
16
  `;
@@ -9,5 +9,5 @@ export const DateField = (props) => {
9
9
  useSetDefault(props);
10
10
  const { name, uiSchema } = props;
11
11
  const { props: inputProps } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
12
- return (_jsx(FieldTemplate, { ...props, "data-fjsf-string": name, children: _jsx(DateFieldWrapper, { children: _jsx(FieldInput, { ...inputProps, name: name, type: "date" }) }) }));
12
+ return (_jsx(FieldTemplate, { ...props, "data-fjsf-string": name, children: _jsx(DateFieldWrapper, { children: _jsx(FieldInput, { readOnly: props.schema.readOnly, ...inputProps, name: name, type: "date" }) }) }));
13
13
  };
@@ -24,5 +24,5 @@ export const MultipleChoiceField = (props) => {
24
24
  return { "data-fjsf-string": name };
25
25
  }
26
26
  })();
27
- return (_jsx(FieldTemplate, { ...props, ...fieldDataAttribute, children: _jsx(MultipleChoiceFieldInput, { inputProps: inputProps, name: name, enums: enums, style: style, value: value, form: form }) }));
27
+ return (_jsx(FieldTemplate, { ...props, ...fieldDataAttribute, children: _jsx(MultipleChoiceFieldInput, { inputProps: { readOnly: props.schema.readOnly, ...inputProps }, name: name, enums: enums, style: style, value: value, form: form }) }));
28
28
  };
@@ -5,6 +5,8 @@ export const MultipleChoiceFieldContainer = styled(RadioFieldContainer) `
5
5
  ${commonCheckboxStyles}
6
6
  ${commonRadioStyles}
7
7
  font-family: ${(props) => props.theme.typography.fontFamily.base};
8
+ flex-wrap: wrap;
9
+ justify-content: start;
8
10
  `;
9
11
  export const MultipleChoiceFieldElement = styled(RadioFieldElement) ``;
10
12
  export const MultipleChoiceFieldInputElement = styled(RadioFieldInputElement) ``;
@@ -56,7 +56,7 @@ export const ObjectField = (props) => {
56
56
  const childSchema = properties?.[child];
57
57
  if (!childSchema)
58
58
  return undefined;
59
- return (_jsx(SchemaField, { required: required?.includes(child), name: name ? [name, child].join(".") : child, schema: typeof childSchema !== "boolean" ? childSchema : {}, uiSchema: uiSchema?.[child] }, child));
59
+ return (_jsx(SchemaField, { required: required?.includes(child), name: name ? [name, child].join(".") : child, schema: prepareChildSchema(childSchema, schema), uiSchema: uiSchema?.[child] }, child));
60
60
  }
61
61
  else {
62
62
  const { title, fields, collapsible } = child;
@@ -64,14 +64,12 @@ export const ObjectField = (props) => {
64
64
  const childSchema = properties?.[child2];
65
65
  if (!childSchema)
66
66
  return undefined;
67
- return (_jsx(SchemaField, { name: name ? [name, child2].join(".") : child2, schema: typeof childSchema !== "boolean" ? childSchema : {}, uiSchema: uiSchema?.[child2] }, child2));
67
+ return (_jsx(SchemaField, { name: name ? [name, child2].join(".") : child2, schema: prepareChildSchema(childSchema, schema), uiSchema: uiSchema?.[child2] }, child2));
68
68
  }) }, fields.join("_")));
69
69
  }
70
70
  })
71
71
  .filter((x) => x), (!hideUnmarkedAdditionalProperties || additionalProperties) &&
72
- Object.entries(additionalValues || {}).map(([childName]) => (_jsxs(ObjectFieldItem, { children: [_jsx(SchemaField, { required: required?.includes(childName), name: name ? [name, childName].join(".") : childName, schema: typeof schema.additionalProperties !== "boolean"
73
- ? schema.additionalProperties
74
- : {}, uiSchema: uiSchema?.[childName] }, childName), _jsx(ObjectFieldItemButtons, { children: getObjectFieldButton({
72
+ Object.entries(additionalValues || {}).map(([childName]) => (_jsxs(ObjectFieldItem, { children: [_jsx(SchemaField, { required: required?.includes(childName), name: name ? [name, childName].join(".") : childName, schema: prepareChildSchema(schema.additionalProperties, schema), uiSchema: uiSchema?.[childName] }, childName), _jsx(ObjectFieldItemButtons, { children: getObjectFieldButton({
75
73
  purpose: ObjectFieldButtonPurpose.REMOVE,
76
74
  onClick: () => {
77
75
  const { [childName]: _removedProperty, ...newValue } = value;
@@ -90,3 +88,12 @@ export const ObjectField = (props) => {
90
88
  uiSchema: uiSchema,
91
89
  })] }));
92
90
  };
91
+ function prepareChildSchema(childSchema, parentSchema) {
92
+ if (!childSchema || typeof childSchema === "boolean") {
93
+ return {};
94
+ }
95
+ if (parentSchema.readOnly) {
96
+ return { ...childSchema, readOnly: parentSchema.readOnly };
97
+ }
98
+ return childSchema;
99
+ }
@@ -8,5 +8,5 @@ export const RadioField = (props) => {
8
8
  useSetDefault(props);
9
9
  const { name, uiSchema } = props;
10
10
  const { label, props: inputProps } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
11
- return (_jsx(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: _jsx(RadioFieldInput, { inputProps: inputProps, label: label, name: name }) }));
11
+ return (_jsx(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: _jsx(RadioFieldInput, { inputProps: { readOnly: props.schema.readOnly, ...inputProps }, label: label, name: name }) }));
12
12
  };
@@ -11,6 +11,10 @@ export const RadioFieldContainer = styled.div `
11
11
  export const RadioFieldElement = styled.label `
12
12
  display: inline-flex;
13
13
  align-items: center;
14
+
15
+ &:has(input[readonly]) {
16
+ pointer-events: none;
17
+ }
14
18
  `;
15
19
  export const RadioFieldInputElement = styled(FieldInput) `
16
20
  margin: unset;
@@ -6,7 +6,7 @@ import { FormRegistry } from "../../FormRegistry";
6
6
  import { useSetDefault } from "../../hooks";
7
7
  import { StringFieldWrapper } from "./styledComponents";
8
8
  export const StringField = (props) => {
9
- const { templates: { FieldTemplate }, components: { FieldInput }, } = useContext(FormRegistry);
9
+ const { templates: { FieldTemplate }, components: { FieldInput, SelectFieldInput }, } = useContext(FormRegistry);
10
10
  useSetDefault(props);
11
11
  const { name, uiSchema = {}, schema } = props;
12
12
  const { type, placeholder, props: inputProps, } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
@@ -17,7 +17,8 @@ export const StringField = (props) => {
17
17
  : { "data-fjsf-number": name };
18
18
  switch (enums?.type) {
19
19
  case "select":
20
- return (_jsx(FieldTemplate, { ...props, ...fieldDataAttribute, children: _jsx(StringFieldWrapper, { children: _jsxs(FieldInput, { type,
20
+ return (_jsx(FieldTemplate, { ...props, ...fieldDataAttribute, children: _jsx(StringFieldWrapper, { children: _jsxs(SelectFieldInput, { type,
21
+ readOnly: props.schema.readOnly,
21
22
  ...inputProps, name: name, formikAs: "select", onChange: (e) => {
22
23
  const selectedOption = enums?.values.find((option) => option.const.toString() === e.target.value);
23
24
  const selectedValue = selectedOption
@@ -30,6 +31,7 @@ export const StringField = (props) => {
30
31
  default:
31
32
  return (_jsx(FieldTemplate, { ...props, ...fieldDataAttribute, children: _jsx(StringFieldWrapper, { children: _jsx(FieldInput, { type,
32
33
  placeholder,
34
+ readOnly: props.schema.readOnly,
33
35
  ...inputProps, name: name }) }) }));
34
36
  }
35
37
  };
@@ -8,5 +8,5 @@ export const TextAreaField = (props) => {
8
8
  useSetDefault(props);
9
9
  const { name, uiSchema } = props;
10
10
  const { props: inputProps } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
11
- return (_jsx(FieldTemplate, { ...props, "data-fjsf-string": name, children: _jsx(TextAreaFieldInput, { ...inputProps, name: name, formikAs: "textarea" }) }));
11
+ return (_jsx(FieldTemplate, { ...props, "data-fjsf-string": name, children: _jsx(TextAreaFieldInput, { readOnly: props.schema.readOnly, ...inputProps, name: name, formikAs: "textarea" }) }));
12
12
  };
@@ -8,5 +8,5 @@ export const ToggleField = (props) => {
8
8
  useSetDefault(props);
9
9
  const { name, uiSchema } = props;
10
10
  const { props: inputProps } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
11
- return (_jsx(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: _jsx(ToggleFieldInput, { inputProps: inputProps, name: name }) }));
11
+ return (_jsx(FieldTemplate, { ...props, "data-fjsf-boolean": name, children: _jsx(ToggleFieldInput, { inputProps: { readOnly: props.schema.readOnly, ...inputProps }, name: name }) }));
12
12
  };