@nolwenture/formik-jsonschema-form 1.0.4 → 1.0.5

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 (36) hide show
  1. package/dist/cjs/Form/components/FieldInput.js +2 -0
  2. package/dist/cjs/Form/fields/BooleanField/styledComponents.js +2 -1
  3. package/dist/cjs/Form/fields/RadioField/styledComponents.js +5 -0
  4. package/dist/cjs/Form/fields/SearchableMultiTagSelectField/SearchableMultiTagSelectField.js +2 -2
  5. package/dist/cjs/Form/fields/SearchableMultiTagSelectField/SearchableMultiTagSelectFieldInput.js +3 -3
  6. package/dist/cjs/Form/fields/SearchableMultiTagSelectField/styledComponents.js +9 -4
  7. package/dist/cjs/Form/fields/SearchableSelectField/SearchableSelectField.js +7 -1
  8. package/dist/cjs/Form/fields/SearchableSelectField/styledComponents.js +1 -1
  9. package/dist/cjs/Form/fields/TextAreaField/TextAreaField.js +4 -2
  10. package/dist/cjs/Form/fields/ToggleField/styledComponents.js +1 -0
  11. package/dist/cjs/Form/styles/common.js +74 -4
  12. package/dist/cjs/Form/templates/FieldTemplate/FieldTemplate.js +3 -2
  13. package/dist/cjs/Form/templates/ObjectFieldTemplate/styledComponents.js +13 -0
  14. package/dist/cjs/FormView/fields/MultipleChoiceField.js +1 -1
  15. package/dist/esm/Form/components/FieldInput.js +2 -0
  16. package/dist/esm/Form/fields/BooleanField/styledComponents.js +2 -1
  17. package/dist/esm/Form/fields/RadioField/styledComponents.js +5 -0
  18. package/dist/esm/Form/fields/SearchableMultiTagSelectField/SearchableMultiTagSelectField.js +2 -2
  19. package/dist/esm/Form/fields/SearchableMultiTagSelectField/SearchableMultiTagSelectFieldInput.js +3 -3
  20. package/dist/esm/Form/fields/SearchableMultiTagSelectField/styledComponents.js +9 -4
  21. package/dist/esm/Form/fields/SearchableSelectField/SearchableSelectField.js +7 -1
  22. package/dist/esm/Form/fields/SearchableSelectField/styledComponents.js +1 -1
  23. package/dist/esm/Form/fields/TextAreaField/TextAreaField.js +4 -2
  24. package/dist/esm/Form/fields/ToggleField/styledComponents.js +1 -0
  25. package/dist/esm/Form/styles/common.js +74 -4
  26. package/dist/esm/Form/templates/FieldTemplate/FieldTemplate.js +3 -2
  27. package/dist/esm/Form/templates/ObjectFieldTemplate/styledComponents.js +13 -0
  28. package/dist/esm/FormView/fields/MultipleChoiceField.js +1 -1
  29. package/dist/types/Form/components/FieldInput.d.ts +3 -1
  30. package/dist/types/Form/components/index.d.ts +7 -5
  31. package/dist/types/Form/fields/SearchableMultiTagSelectField/SearchableMultiTagSelectFieldInput.d.ts +3 -1
  32. package/dist/types/Form/fields/SearchableMultiTagSelectField/index.d.ts +3 -3
  33. package/dist/types/Form/fields/SearchableMultiTagSelectField/styledComponents.d.ts +2 -2
  34. package/dist/types/Form/fields/SearchableSelectField/styledComponents.d.ts +1 -1
  35. package/dist/types/Form/fields/index.d.ts +4 -4
  36. package/package.json +2 -1
@@ -42,6 +42,8 @@ exports.FieldWrapper = styled_components_1.styled.div `
42
42
  flex-direction: column;
43
43
  margin: ${(props) => `${props.theme.spacing.s} 0`};
44
44
  color: ${(props) => props.theme.color.text.default};
45
+ opacity: ${(props) => (props.$isDisabled ? 0.6 : 1)};
46
+ pointer-events: ${(props) => (props.$isDisabled ? 'none' : 'auto')};
45
47
  `;
46
48
  exports.FieldTitle = styled_components_1.styled.label `
47
49
  font-size: ${(props) => props.theme.typography.size.base};
@@ -11,7 +11,8 @@ exports.BooleanFieldWrapper = (0, styled_components_1.styled)(common_1.CommonChe
11
11
  font-family: ${(props) => props.theme.typography.fontFamily.base};
12
12
  gap: ${(props) => props.theme.spacing.s};
13
13
 
14
- & > input[readonly], & > input[readonly] ~ span {
14
+ &:has(input[readonly]) {
15
15
  pointer-events: none;
16
+ cursor: pointer;
16
17
  }
17
18
  `;
@@ -49,6 +49,11 @@ exports.RadioFieldContainer = (0, styled_components_1.styled)(common_1.CommonChe
49
49
  transform: scale(1);
50
50
  }
51
51
  }
52
+
53
+ &[readonly] {
54
+ background-color: transparent;
55
+ border: none;
56
+ }
52
57
  }
53
58
  `;
54
59
  exports.RadioFieldElement = styled_components_1.styled.label `
@@ -9,12 +9,12 @@ const FormRegistry_1 = require("../../FormRegistry");
9
9
  const SearchableMultiTagSelectField = (props) => {
10
10
  const { templates, components: { SearchableMultiTagSelectFieldInput }, } = (0, react_1.useContext)(FormRegistry_1.FormRegistry);
11
11
  (0, hooks_1.useSetDefault)(props);
12
- const { name, uiSchema } = props;
12
+ const { name, uiSchema, schema } = props;
13
13
  const { placeholder, emptySearchMessage, props: inputProps, } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
14
14
  const enums = (0, react_1.useMemo)(() => (0, utils_1.getEnums)(props), [props]);
15
15
  const SelectedFieldTemplate = (props.uiSchema?.["ui:template"] &&
16
16
  templates[props.uiSchema?.["ui:template"]]) ??
17
17
  templates.FieldTemplate;
18
- return ((0, jsx_runtime_1.jsx)(SelectedFieldTemplate, { ...props, "data-fjsf-array": name, children: (0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldInput, { ...inputProps, name: name, placeholder: placeholder, emptySearchMessage: emptySearchMessage, enums: enums }) }));
18
+ return ((0, jsx_runtime_1.jsx)(SelectedFieldTemplate, { ...props, "data-fjsf-array": name, children: (0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldInput, { ...inputProps, name: name, placeholder: placeholder, emptySearchMessage: emptySearchMessage, enums: enums, readOnly: schema.readOnly }) }));
19
19
  };
20
20
  exports.SearchableMultiTagSelectField = SearchableMultiTagSelectField;
@@ -4,7 +4,7 @@ exports.SearchableMultiTagSelectFieldInput = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const FormRegistry_1 = require("../../FormRegistry");
7
- const SearchableMultiTagSelectFieldInput = ({ name, placeholder, enums, emptySearchMessage, closeElement, className, }) => {
7
+ const SearchableMultiTagSelectFieldInput = ({ name, placeholder, enums, emptySearchMessage, closeElement, className, disabled, readOnly, }) => {
8
8
  const { components: { FieldInput, SearchableMultiTagSelectFieldBadge, SearchableMultiTagSelectFieldBadgeCloseElement, SearchableMultiTagSelectFieldBadgeContainer, SearchableMultiTagSelectFieldContainer, SearchableMultiTagSelectFieldInputElement, SearchableMultiTagSelectFieldOptionList, SearchableMultiTagSelectFieldOptionListItem, SearchableMultiTagSelectFieldOptionListWithoutItem, SearchableMultiTagSelectFieldSearchContainer, }, } = (0, react_1.useContext)(FormRegistry_1.FormRegistry);
9
9
  const [search, setSearch] = (0, react_1.useState)("");
10
10
  const searchIncludedInEnum = () => {
@@ -13,7 +13,7 @@ const SearchableMultiTagSelectFieldInput = ({ name, placeholder, enums, emptySea
13
13
  };
14
14
  return ((0, jsx_runtime_1.jsx)(FieldInput, { className: className, name: name, multiple: true, children: ({ field, form: { setFieldValue }, meta, }) => ((0, jsx_runtime_1.jsxs)(SearchableMultiTagSelectFieldContainer, { className: className, children: [(0, jsx_runtime_1.jsx)(FieldInput, { id: className, type: "hidden", ...field }), (0, jsx_runtime_1.jsxs)(SearchableMultiTagSelectFieldSearchContainer, { children: [(0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldInputElement, { id: className + "_id", className: className, type: "text", onChange: (e) => {
15
15
  setSearch(e.currentTarget.value);
16
- }, placeholder: placeholder, value: search }), search.length > 0 && ((0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldOptionList, { children: searchIncludedInEnum() ? (enums?.values
16
+ }, placeholder: placeholder, value: search, readOnly: readOnly, disabled: disabled }), search.length > 0 && !disabled && !readOnly && ((0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldOptionList, { children: searchIncludedInEnum() ? (enums?.values
17
17
  .filter((item) => !(field.value ?? []).includes(item.const))
18
18
  .filter((value) => value.title.toLowerCase().includes(search.toLowerCase()))
19
19
  .map((option, index) => ((0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldOptionListItem, { value: option.const, onClick: () => {
@@ -22,6 +22,6 @@ const SearchableMultiTagSelectFieldInput = ({ name, placeholder, enums, emptySea
22
22
  ]);
23
23
  setSearch("");
24
24
  }, children: option.title }, index)))) : ((0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldOptionListWithoutItem, { children: emptySearchMessage ?? "No match found" })) }))] }), (0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldBadgeContainer, { children: (field.value ?? []).map((value) => ((0, jsx_runtime_1.jsxs)(SearchableMultiTagSelectFieldBadge, { children: [enums?.values.find((option) => option.const === value)
25
- ?.title, (0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldBadgeCloseElement, { onClick: () => setFieldValue(name, field.value.filter((v) => v !== value)), children: closeElement ?? "✕" })] }, value))) }), meta.touched && meta.error && ((0, jsx_runtime_1.jsx)("div", { className: "error", children: meta.error }))] })) }));
25
+ ?.title, (0, jsx_runtime_1.jsx)(SearchableMultiTagSelectFieldBadgeCloseElement, { onClick: () => setFieldValue(name, field.value.filter((v) => v !== value)), disabled: disabled || readOnly, children: closeElement ?? "✕" })] }, value))) }), meta.touched && meta.error && ((0, jsx_runtime_1.jsx)("div", { className: "error", children: meta.error }))] })) }));
26
26
  };
27
27
  exports.SearchableMultiTagSelectFieldInput = SearchableMultiTagSelectFieldInput;
@@ -22,17 +22,22 @@ exports.SearchableMultiTagSelectFieldBadgeContainer = styled_components_1.styled
22
22
  display: inline-flex;
23
23
  gap: ${(props) => props.theme.strokeWidth.thin};
24
24
  `;
25
- exports.SearchableMultiTagSelectFieldBadge = styled_components_1.styled.span `
25
+ exports.SearchableMultiTagSelectFieldBadge = styled_components_1.styled.div `
26
26
  color: ${(props) => props.theme.color.background.input};
27
27
  background: ${(props) => props.theme.color.text.default};
28
- padding: ${(props) => `0 ${props.theme.spacing.xs} 0 ${props.theme.spacing.s}`};
28
+ padding: ${(props) => `0 ${props.theme.spacing.s}`};
29
29
  border-radius: ${(props) => props.theme.borderRadius.none};
30
30
  display: flex;
31
31
  margin-right: ${(props) => props.theme.spacing.xs};
32
+ gap: ${(props) => props.theme.spacing.s};
32
33
  `;
33
- exports.SearchableMultiTagSelectFieldBadgeCloseElement = styled_components_1.styled.span `
34
+ exports.SearchableMultiTagSelectFieldBadgeCloseElement = styled_components_1.styled.button `
35
+ background: transparent;
36
+ color: ${(props) => props.theme.color.background.input};
37
+ border: none;
34
38
  cursor: pointer;
35
- margin-left: ${(props) => props.theme.spacing.s};
39
+ margin: 0;
40
+ padding: 0;
36
41
  font-size: ${(props) => props.theme.typography.size.small};
37
42
  align-self: center;
38
43
  font-family: ${(props) => props.theme.typography.fontFamily.base};
@@ -88,6 +88,8 @@ const SearchableSelectField = (props) => {
88
88
  };
89
89
  }, [handleKeyPress]);
90
90
  const handleSearchChange = (event) => {
91
+ if (schema.readOnly)
92
+ return;
91
93
  setSearchTerm(event.target.value);
92
94
  setItemsToShow(dropdownOptions.perPage);
93
95
  setShowOptions(true);
@@ -101,6 +103,8 @@ const SearchableSelectField = (props) => {
101
103
  onSelect?.(item.const);
102
104
  };
103
105
  const handleFocus = () => {
106
+ if (schema.readOnly)
107
+ return;
104
108
  setShowOptions(true);
105
109
  };
106
110
  const handleBlur = (event) => {
@@ -110,6 +114,8 @@ const SearchableSelectField = (props) => {
110
114
  }
111
115
  };
112
116
  const handleClear = () => {
117
+ if (schema.readOnly)
118
+ return;
113
119
  setSearchTerm("");
114
120
  setValue(undefined);
115
121
  };
@@ -122,7 +128,7 @@ const SearchableSelectField = (props) => {
122
128
  const SelectedFieldTemplate = (props.uiSchema?.["ui:template"] &&
123
129
  templates[props.uiSchema?.["ui:template"]]) ??
124
130
  templates.FieldTemplate;
125
- return ((0, jsx_runtime_1.jsx)(SelectedFieldTemplate, { ...props, ...fieldDataAttribute, children: (0, jsx_runtime_1.jsxs)(SearchableSelectFieldContainer, { ref: containerRef, onBlur: handleBlur, children: [(0, jsx_runtime_1.jsxs)(SearchableSelectFieldInputContainer, { children: [(0, jsx_runtime_1.jsx)(SearchableSelectFieldInputElement, { ...inputProps, name: name, type: "text", placeholder: placeholder, value: searchTerm, onChange: handleSearchChange, onFocus: handleFocus }), searchTerm && !hideClearButton && ((0, jsx_runtime_1.jsx)(SearchableSelectFieldClearButton, { onClick: handleClear, children: clearButtonText ?? "✕" }))] }), showOptions && ((0, jsx_runtime_1.jsxs)(SearchableSelectFieldDropdownContainer, { role: "dropdown-list",
131
+ return ((0, jsx_runtime_1.jsx)(SelectedFieldTemplate, { ...props, ...fieldDataAttribute, children: (0, jsx_runtime_1.jsxs)(SearchableSelectFieldContainer, { ref: containerRef, onBlur: handleBlur, children: [(0, jsx_runtime_1.jsxs)(SearchableSelectFieldInputContainer, { children: [(0, jsx_runtime_1.jsx)(SearchableSelectFieldInputElement, { ...inputProps, name: name, type: "text", placeholder: placeholder, value: searchTerm, onChange: handleSearchChange, onFocus: handleFocus, readOnly: schema.readOnly }), searchTerm && !hideClearButton && ((0, jsx_runtime_1.jsx)(SearchableSelectFieldClearButton, { onClick: handleClear, disabled: schema.readOnly, children: clearButtonText ?? "✕" }))] }), showOptions && !schema.readOnly && ((0, jsx_runtime_1.jsxs)(SearchableSelectFieldDropdownContainer, { role: "dropdown-list",
126
132
  //ref={moreRef} //TODO
127
133
  style: {
128
134
  maxHeight: dropdownOptions.height,
@@ -32,7 +32,7 @@ exports.SearchableSelectFieldInputElement = (0, styled_components_1.styled)(Fiel
32
32
  padding-right: ${(props) => props.theme.spacing.xxl};
33
33
  text-overflow: ellipsis;
34
34
  `;
35
- exports.SearchableSelectFieldClearButton = styled_components_1.styled.span `
35
+ exports.SearchableSelectFieldClearButton = styled_components_1.styled.button `
36
36
  background-color: ${(props) => props.theme.color.palette.neutral[500]};
37
37
  border-radius: ${(props) => props.theme.borderRadius.circle};
38
38
  bottom: 0;
@@ -10,10 +10,12 @@ const TextAreaField = (props) => {
10
10
  const { templates, components: { TextAreaFieldInput }, } = (0, react_1.useContext)(FormRegistry_1.FormRegistry);
11
11
  (0, hooks_1.useSetDefault)(props);
12
12
  const { name, uiSchema } = props;
13
- const { props: inputProps } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
13
+ const { placeholder, props: inputProps } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
14
14
  const SelectedFieldTemplate = (props.uiSchema?.["ui:template"] &&
15
15
  templates[props.uiSchema?.["ui:template"]]) ??
16
16
  templates.FieldTemplate;
17
- return ((0, jsx_runtime_1.jsx)(SelectedFieldTemplate, { ...props, "data-fjsf-string": name, children: (0, jsx_runtime_1.jsx)(TextAreaFieldInput, { readOnly: props.schema.readOnly, ...inputProps, name: name, formikAs: "textarea" }) }));
17
+ return ((0, jsx_runtime_1.jsx)(SelectedFieldTemplate, { ...props, "data-fjsf-string": name, children: (0, jsx_runtime_1.jsx)(TextAreaFieldInput, { placeholder,
18
+ readOnly: props.schema.readOnly,
19
+ ...inputProps, name: name, formikAs: "textarea" }) }));
18
20
  };
19
21
  exports.TextAreaField = TextAreaField;
@@ -10,6 +10,7 @@ exports.ToggleFieldToggle = styled_components_1.styled.span `
10
10
  left: 0;
11
11
  right: 0;
12
12
  bottom: 0;
13
+ height: 1rem;
13
14
  background: ${(props) => props.theme.color.intent.default.none};
14
15
  border: ${(props) => `${props.theme.strokeWidth.thin} solid ${props.theme.color.border.default}`};
15
16
  -webkit-transition: 0.4s;
@@ -23,6 +23,24 @@ exports.CommonFieldWrapper = styled_components_1.styled.div `
23
23
  }
24
24
 
25
25
  &:read-only {
26
+ border: none;
27
+ background-color: transparent;
28
+ padding: 0;
29
+
30
+ &::placeholder {
31
+ color: ${(props) => props.theme.color.text.default};
32
+ }
33
+ }
34
+
35
+ &:disabled {
36
+ background-color: ${(props) => props.theme.color.background.input};
37
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid
38
+ ${props.theme.color.border.default}`};
39
+ padding: ${(props) => props.theme.spacing.s};
40
+
41
+ &::placeholder {
42
+ color: ${(props) => props.theme.color.text.muted};
43
+ }
26
44
  }
27
45
 
28
46
  &:focus {
@@ -59,13 +77,24 @@ exports.CommonFieldWrapper = styled_components_1.styled.div `
59
77
  background-repeat: no-repeat;
60
78
  background-size: ${(props) => props.theme.spacing.l}; auto;
61
79
 
62
- &:read-only {
63
-
80
+ &[readonly] {
81
+ background-image: none;
82
+ border: none;
83
+ background-color: transparent;
84
+ padding: 0;
64
85
  }
65
86
 
66
87
  &:focus {
67
88
  ${(props) => props.theme.focus.default};
68
89
  }
90
+
91
+ &:disabled {
92
+ background-color: ${(props) => props.theme.color.background.input};
93
+ background-image: ${(props) => `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 320 512'%3E%3Cpath fill='${encodeURIComponent(props.theme.color.text.default)}' d='M31 192h258c17 0 26 21 14 33l-129 129c-8 8-21 8-29 0L17 225c-12-12-3-33 14-33z'/%3E%3C/svg%3E")`};
94
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid
95
+ ${props.theme.color.border.default}`};
96
+ padding: ${(props) => `${props.theme.spacing.s} ${props.theme.spacing.xxxxl} ${props.theme.spacing.s} ${props.theme.spacing.m}`};
97
+ }
69
98
  }
70
99
 
71
100
  select[multiple] {
@@ -73,6 +102,40 @@ exports.CommonFieldWrapper = styled_components_1.styled.div `
73
102
  background-image: none;
74
103
  overflow: auto;
75
104
  }
105
+
106
+ textarea {
107
+
108
+ background-color: ${(props) => props.theme.color.background.input};
109
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid
110
+ ${props.theme.color.border.default}`};
111
+ padding: ${(props) => props.theme.spacing.s};
112
+
113
+ &:read-only {
114
+ border: none;
115
+ background-color: transparent;
116
+ padding: 0;
117
+ min-height: unset;
118
+ resize: none;
119
+ field-sizing: content;
120
+
121
+ &::placeholder {
122
+ color: ${(props) => props.theme.color.text.default};
123
+ }
124
+ }
125
+
126
+ &:disabled {
127
+ background-color: ${(props) => props.theme.color.background.input};
128
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid
129
+ ${props.theme.color.border.default}`};
130
+ min-height: 5rem;
131
+ padding: ${(props) => props.theme.spacing.s};
132
+
133
+ &::placeholder {
134
+ color: ${(props) => props.theme.color.text.muted};
135
+ }
136
+ }
137
+
138
+ }
76
139
  `;
77
140
  exports.CommonCheckboxStyles = styled_components_1.styled.div `
78
141
  input[type="checkbox"] {
@@ -178,8 +241,15 @@ exports.CommonCheckboxStyles = styled_components_1.styled.div `
178
241
  }
179
242
  }
180
243
 
181
- &:read-only {
182
-
244
+ &[readonly] {
245
+ background: transparent;
246
+ border: none;
247
+ }
248
+
249
+ &:disabled {
250
+ background-color: ${(props) => props.theme.color.background.input};
251
+ border: ${(props) => props.theme.strokeWidth.thin} solid
252
+ ${(props) => props.theme.color.border.default};
183
253
  }
184
254
  }
185
255
  `;
@@ -10,7 +10,8 @@ const FieldTemplate = (props) => {
10
10
  const { name, uiSchema, children, ...otherProps } = props;
11
11
  const title = (0, utils_1.getTitle)(props);
12
12
  const description = (0, utils_1.getDescription)(props);
13
- const { help, info, props: { wrapper: wrapperProps = {}, title: titleProps, description: descriptionProps, help: helpProps, error: errorProps, } = {}, } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
13
+ const { help, info, disabled, props: { wrapper: wrapperProps = {}, title: titleProps, description: descriptionProps, help: helpProps, error: errorProps, disabled: isDisabled, } = {}, } = (0, react_1.useMemo)(() => (0, utils_1.extractUiSchema)(uiSchema), [uiSchema]);
14
+ const isReadOnly = props.schema?.readOnly;
14
15
  const dataAttributes = Object.keys(otherProps)
15
16
  .filter((key) => key.startsWith("data-"))
16
17
  .reduce((acc, key) => {
@@ -22,6 +23,6 @@ const FieldTemplate = (props) => {
22
23
  ...wrapperProps,
23
24
  ...dataAttributes, // This will only include data-* attributes
24
25
  };
25
- return ((0, jsx_runtime_1.jsxs)(FieldWrapper, { ...mergedWrapperProps, children: [title && ((0, jsx_runtime_1.jsxs)(FieldTitle, { ...titleProps, htmlFor: name, children: [title, props.required && (0, jsx_runtime_1.jsx)(RequiredIndicator, {})] })), info && (0, jsx_runtime_1.jsx)(FieldInfo, { ...info }), description && ((0, jsx_runtime_1.jsx)(FieldDescription, { ...descriptionProps, children: description })), children, help && (0, jsx_runtime_1.jsx)(FieldHelp, { ...helpProps, children: help }), (0, jsx_runtime_1.jsx)(ErrorMessage, { ...errorProps, name: name })] }));
26
+ return ((0, jsx_runtime_1.jsxs)(FieldWrapper, { ...mergedWrapperProps, "$isDisabled": isDisabled, children: [title && ((0, jsx_runtime_1.jsxs)(FieldTitle, { ...titleProps, htmlFor: name, children: [title, props.required && (0, jsx_runtime_1.jsx)(RequiredIndicator, {})] })), info && (0, jsx_runtime_1.jsx)(FieldInfo, { ...info }), description && ((0, jsx_runtime_1.jsx)(FieldDescription, { ...descriptionProps, children: description })), children, help && (0, jsx_runtime_1.jsx)(FieldHelp, { ...helpProps, children: help }), (0, jsx_runtime_1.jsx)(ErrorMessage, { ...errorProps, name: name })] }));
26
27
  };
27
28
  exports.FieldTemplate = FieldTemplate;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectFieldTemplateErrorMessage = exports.ObjectFieldTemplateRequiredIndicator = exports.ObjectFieldTemplateInfo = exports.ObjectFieldTemplateHelp = exports.ObjectFieldTemplateDescription = exports.ObjectFieldTemplateTitle = exports.ObjectFieldTemplateWrapper = void 0;
4
4
  exports.getComponents = getComponents;
5
+ const polished_1 = require("polished");
5
6
  const styled_components_1 = require("styled-components");
6
7
  exports.ObjectFieldTemplateWrapper = styled_components_1.styled.fieldset `
7
8
  color: ${(props) => props.theme.color.text.default};
@@ -9,6 +10,18 @@ exports.ObjectFieldTemplateWrapper = styled_components_1.styled.fieldset `
9
10
  margin-inline: 0;
10
11
  margin-bottom: ${(props) => props.theme.spacing.xs};
11
12
 
13
+ &:has(input[disabled]), &:has(option[disabled]), &:has(select[disabled]), &:has(textarea[disabled]) {
14
+ border-color: ${(props) => (0, polished_1.lighten)(0.4, props.theme.color.border.default)};
15
+
16
+ legend {
17
+ color: ${(props) => (0, polished_1.lighten)(0.4, props.theme.color.text.default)};
18
+
19
+ & + p {
20
+ color: ${(props) => (0, polished_1.lighten)(0.4, props.theme.color.text.default)};
21
+ }
22
+ }
23
+ }
24
+
12
25
  `;
13
26
  exports.ObjectFieldTemplateTitle = styled_components_1.styled.legend `
14
27
  color: ${(props) => props.theme.color.text.default};
@@ -14,7 +14,7 @@ const MultipleChoiceField = (props) => {
14
14
  const { values } = (0, formik_1.useFormikContext)();
15
15
  const value = (0, formik_1.getIn)(values, name);
16
16
  const selected = (0, utils_1.getSelectedEnum)(value, enums);
17
- const notSelected = enums?.values?.filter((v) => Array.isArray(value) && !value.includes(v));
17
+ const notSelected = enums?.values?.filter((v) => Array.isArray(value) && !value.includes(v.const));
18
18
  const hideNotSelected = onlyShowSelected === true || selected === undefined;
19
19
  const SelectedFieldTemplate = (props.uiSchema?.["ui:template"] &&
20
20
  templates[props.uiSchema?.["ui:template"]]) ??
@@ -6,6 +6,8 @@ export const FieldWrapper = styled.div `
6
6
  flex-direction: column;
7
7
  margin: ${(props) => `${props.theme.spacing.s} 0`};
8
8
  color: ${(props) => props.theme.color.text.default};
9
+ opacity: ${(props) => (props.$isDisabled ? 0.6 : 1)};
10
+ pointer-events: ${(props) => (props.$isDisabled ? 'none' : 'auto')};
9
11
  `;
10
12
  export const FieldTitle = styled.label `
11
13
  font-size: ${(props) => props.theme.typography.size.base};
@@ -8,7 +8,8 @@ export const BooleanFieldWrapper = styled(CommonCheckboxStyles) `
8
8
  font-family: ${(props) => props.theme.typography.fontFamily.base};
9
9
  gap: ${(props) => props.theme.spacing.s};
10
10
 
11
- & > input[readonly], & > input[readonly] ~ span {
11
+ &:has(input[readonly]) {
12
12
  pointer-events: none;
13
+ cursor: pointer;
13
14
  }
14
15
  `;
@@ -46,6 +46,11 @@ export const RadioFieldContainer = styled(CommonCheckboxStyles) `
46
46
  transform: scale(1);
47
47
  }
48
48
  }
49
+
50
+ &[readonly] {
51
+ background-color: transparent;
52
+ border: none;
53
+ }
49
54
  }
50
55
  `;
51
56
  export const RadioFieldElement = styled.label `
@@ -6,11 +6,11 @@ import { FormRegistry } from "../../FormRegistry";
6
6
  export const SearchableMultiTagSelectField = (props) => {
7
7
  const { templates, components: { SearchableMultiTagSelectFieldInput }, } = useContext(FormRegistry);
8
8
  useSetDefault(props);
9
- const { name, uiSchema } = props;
9
+ const { name, uiSchema, schema } = props;
10
10
  const { placeholder, emptySearchMessage, props: inputProps, } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
11
11
  const enums = useMemo(() => getEnums(props), [props]);
12
12
  const SelectedFieldTemplate = (props.uiSchema?.["ui:template"] &&
13
13
  templates[props.uiSchema?.["ui:template"]]) ??
14
14
  templates.FieldTemplate;
15
- return (_jsx(SelectedFieldTemplate, { ...props, "data-fjsf-array": name, children: _jsx(SearchableMultiTagSelectFieldInput, { ...inputProps, name: name, placeholder: placeholder, emptySearchMessage: emptySearchMessage, enums: enums }) }));
15
+ return (_jsx(SelectedFieldTemplate, { ...props, "data-fjsf-array": name, children: _jsx(SearchableMultiTagSelectFieldInput, { ...inputProps, name: name, placeholder: placeholder, emptySearchMessage: emptySearchMessage, enums: enums, readOnly: schema.readOnly }) }));
16
16
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useContext, useState } from "react";
3
3
  import { FormRegistry } from "../../FormRegistry";
4
- export const SearchableMultiTagSelectFieldInput = ({ name, placeholder, enums, emptySearchMessage, closeElement, className, }) => {
4
+ export const SearchableMultiTagSelectFieldInput = ({ name, placeholder, enums, emptySearchMessage, closeElement, className, disabled, readOnly, }) => {
5
5
  const { components: { FieldInput, SearchableMultiTagSelectFieldBadge, SearchableMultiTagSelectFieldBadgeCloseElement, SearchableMultiTagSelectFieldBadgeContainer, SearchableMultiTagSelectFieldContainer, SearchableMultiTagSelectFieldInputElement, SearchableMultiTagSelectFieldOptionList, SearchableMultiTagSelectFieldOptionListItem, SearchableMultiTagSelectFieldOptionListWithoutItem, SearchableMultiTagSelectFieldSearchContainer, }, } = useContext(FormRegistry);
6
6
  const [search, setSearch] = useState("");
7
7
  const searchIncludedInEnum = () => {
@@ -10,7 +10,7 @@ export const SearchableMultiTagSelectFieldInput = ({ name, placeholder, enums, e
10
10
  };
11
11
  return (_jsx(FieldInput, { className: className, name: name, multiple: true, children: ({ field, form: { setFieldValue }, meta, }) => (_jsxs(SearchableMultiTagSelectFieldContainer, { className: className, children: [_jsx(FieldInput, { id: className, type: "hidden", ...field }), _jsxs(SearchableMultiTagSelectFieldSearchContainer, { children: [_jsx(SearchableMultiTagSelectFieldInputElement, { id: className + "_id", className: className, type: "text", onChange: (e) => {
12
12
  setSearch(e.currentTarget.value);
13
- }, placeholder: placeholder, value: search }), search.length > 0 && (_jsx(SearchableMultiTagSelectFieldOptionList, { children: searchIncludedInEnum() ? (enums?.values
13
+ }, placeholder: placeholder, value: search, readOnly: readOnly, disabled: disabled }), search.length > 0 && !disabled && !readOnly && (_jsx(SearchableMultiTagSelectFieldOptionList, { children: searchIncludedInEnum() ? (enums?.values
14
14
  .filter((item) => !(field.value ?? []).includes(item.const))
15
15
  .filter((value) => value.title.toLowerCase().includes(search.toLowerCase()))
16
16
  .map((option, index) => (_jsx(SearchableMultiTagSelectFieldOptionListItem, { value: option.const, onClick: () => {
@@ -19,5 +19,5 @@ export const SearchableMultiTagSelectFieldInput = ({ name, placeholder, enums, e
19
19
  ]);
20
20
  setSearch("");
21
21
  }, children: option.title }, index)))) : (_jsx(SearchableMultiTagSelectFieldOptionListWithoutItem, { children: emptySearchMessage ?? "No match found" })) }))] }), _jsx(SearchableMultiTagSelectFieldBadgeContainer, { children: (field.value ?? []).map((value) => (_jsxs(SearchableMultiTagSelectFieldBadge, { children: [enums?.values.find((option) => option.const === value)
22
- ?.title, _jsx(SearchableMultiTagSelectFieldBadgeCloseElement, { onClick: () => setFieldValue(name, field.value.filter((v) => v !== value)), children: closeElement ?? "✕" })] }, value))) }), meta.touched && meta.error && (_jsx("div", { className: "error", children: meta.error }))] })) }));
22
+ ?.title, _jsx(SearchableMultiTagSelectFieldBadgeCloseElement, { onClick: () => setFieldValue(name, field.value.filter((v) => v !== value)), disabled: disabled || readOnly, children: closeElement ?? "✕" })] }, value))) }), meta.touched && meta.error && (_jsx("div", { className: "error", children: meta.error }))] })) }));
23
23
  };
@@ -19,17 +19,22 @@ export const SearchableMultiTagSelectFieldBadgeContainer = styled.div `
19
19
  display: inline-flex;
20
20
  gap: ${(props) => props.theme.strokeWidth.thin};
21
21
  `;
22
- export const SearchableMultiTagSelectFieldBadge = styled.span `
22
+ export const SearchableMultiTagSelectFieldBadge = styled.div `
23
23
  color: ${(props) => props.theme.color.background.input};
24
24
  background: ${(props) => props.theme.color.text.default};
25
- padding: ${(props) => `0 ${props.theme.spacing.xs} 0 ${props.theme.spacing.s}`};
25
+ padding: ${(props) => `0 ${props.theme.spacing.s}`};
26
26
  border-radius: ${(props) => props.theme.borderRadius.none};
27
27
  display: flex;
28
28
  margin-right: ${(props) => props.theme.spacing.xs};
29
+ gap: ${(props) => props.theme.spacing.s};
29
30
  `;
30
- export const SearchableMultiTagSelectFieldBadgeCloseElement = styled.span `
31
+ export const SearchableMultiTagSelectFieldBadgeCloseElement = styled.button `
32
+ background: transparent;
33
+ color: ${(props) => props.theme.color.background.input};
34
+ border: none;
31
35
  cursor: pointer;
32
- margin-left: ${(props) => props.theme.spacing.s};
36
+ margin: 0;
37
+ padding: 0;
33
38
  font-size: ${(props) => props.theme.typography.size.small};
34
39
  align-self: center;
35
40
  font-family: ${(props) => props.theme.typography.fontFamily.base};
@@ -85,6 +85,8 @@ export const SearchableSelectField = (props) => {
85
85
  };
86
86
  }, [handleKeyPress]);
87
87
  const handleSearchChange = (event) => {
88
+ if (schema.readOnly)
89
+ return;
88
90
  setSearchTerm(event.target.value);
89
91
  setItemsToShow(dropdownOptions.perPage);
90
92
  setShowOptions(true);
@@ -98,6 +100,8 @@ export const SearchableSelectField = (props) => {
98
100
  onSelect?.(item.const);
99
101
  };
100
102
  const handleFocus = () => {
103
+ if (schema.readOnly)
104
+ return;
101
105
  setShowOptions(true);
102
106
  };
103
107
  const handleBlur = (event) => {
@@ -107,6 +111,8 @@ export const SearchableSelectField = (props) => {
107
111
  }
108
112
  };
109
113
  const handleClear = () => {
114
+ if (schema.readOnly)
115
+ return;
110
116
  setSearchTerm("");
111
117
  setValue(undefined);
112
118
  };
@@ -119,7 +125,7 @@ export const SearchableSelectField = (props) => {
119
125
  const SelectedFieldTemplate = (props.uiSchema?.["ui:template"] &&
120
126
  templates[props.uiSchema?.["ui:template"]]) ??
121
127
  templates.FieldTemplate;
122
- return (_jsx(SelectedFieldTemplate, { ...props, ...fieldDataAttribute, children: _jsxs(SearchableSelectFieldContainer, { ref: containerRef, onBlur: handleBlur, children: [_jsxs(SearchableSelectFieldInputContainer, { children: [_jsx(SearchableSelectFieldInputElement, { ...inputProps, name: name, type: "text", placeholder: placeholder, value: searchTerm, onChange: handleSearchChange, onFocus: handleFocus }), searchTerm && !hideClearButton && (_jsx(SearchableSelectFieldClearButton, { onClick: handleClear, children: clearButtonText ?? "✕" }))] }), showOptions && (_jsxs(SearchableSelectFieldDropdownContainer, { role: "dropdown-list",
128
+ return (_jsx(SelectedFieldTemplate, { ...props, ...fieldDataAttribute, children: _jsxs(SearchableSelectFieldContainer, { ref: containerRef, onBlur: handleBlur, children: [_jsxs(SearchableSelectFieldInputContainer, { children: [_jsx(SearchableSelectFieldInputElement, { ...inputProps, name: name, type: "text", placeholder: placeholder, value: searchTerm, onChange: handleSearchChange, onFocus: handleFocus, readOnly: schema.readOnly }), searchTerm && !hideClearButton && (_jsx(SearchableSelectFieldClearButton, { onClick: handleClear, disabled: schema.readOnly, children: clearButtonText ?? "✕" }))] }), showOptions && !schema.readOnly && (_jsxs(SearchableSelectFieldDropdownContainer, { role: "dropdown-list",
123
129
  //ref={moreRef} //TODO
124
130
  style: {
125
131
  maxHeight: dropdownOptions.height,
@@ -29,7 +29,7 @@ export const SearchableSelectFieldInputElement = styled(FieldInput) `
29
29
  padding-right: ${(props) => props.theme.spacing.xxl};
30
30
  text-overflow: ellipsis;
31
31
  `;
32
- export const SearchableSelectFieldClearButton = styled.span `
32
+ export const SearchableSelectFieldClearButton = styled.button `
33
33
  background-color: ${(props) => props.theme.color.palette.neutral[500]};
34
34
  border-radius: ${(props) => props.theme.borderRadius.circle};
35
35
  bottom: 0;
@@ -7,9 +7,11 @@ export const TextAreaField = (props) => {
7
7
  const { templates, components: { TextAreaFieldInput }, } = useContext(FormRegistry);
8
8
  useSetDefault(props);
9
9
  const { name, uiSchema } = props;
10
- const { props: inputProps } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
10
+ const { placeholder, props: inputProps } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
11
11
  const SelectedFieldTemplate = (props.uiSchema?.["ui:template"] &&
12
12
  templates[props.uiSchema?.["ui:template"]]) ??
13
13
  templates.FieldTemplate;
14
- return (_jsx(SelectedFieldTemplate, { ...props, "data-fjsf-string": name, children: _jsx(TextAreaFieldInput, { readOnly: props.schema.readOnly, ...inputProps, name: name, formikAs: "textarea" }) }));
14
+ return (_jsx(SelectedFieldTemplate, { ...props, "data-fjsf-string": name, children: _jsx(TextAreaFieldInput, { placeholder,
15
+ readOnly: props.schema.readOnly,
16
+ ...inputProps, name: name, formikAs: "textarea" }) }));
15
17
  };
@@ -7,6 +7,7 @@ export const ToggleFieldToggle = styled.span `
7
7
  left: 0;
8
8
  right: 0;
9
9
  bottom: 0;
10
+ height: 1rem;
10
11
  background: ${(props) => props.theme.color.intent.default.none};
11
12
  border: ${(props) => `${props.theme.strokeWidth.thin} solid ${props.theme.color.border.default}`};
12
13
  -webkit-transition: 0.4s;
@@ -20,6 +20,24 @@ export const CommonFieldWrapper = styled.div `
20
20
  }
21
21
 
22
22
  &:read-only {
23
+ border: none;
24
+ background-color: transparent;
25
+ padding: 0;
26
+
27
+ &::placeholder {
28
+ color: ${(props) => props.theme.color.text.default};
29
+ }
30
+ }
31
+
32
+ &:disabled {
33
+ background-color: ${(props) => props.theme.color.background.input};
34
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid
35
+ ${props.theme.color.border.default}`};
36
+ padding: ${(props) => props.theme.spacing.s};
37
+
38
+ &::placeholder {
39
+ color: ${(props) => props.theme.color.text.muted};
40
+ }
23
41
  }
24
42
 
25
43
  &:focus {
@@ -56,13 +74,24 @@ export const CommonFieldWrapper = styled.div `
56
74
  background-repeat: no-repeat;
57
75
  background-size: ${(props) => props.theme.spacing.l}; auto;
58
76
 
59
- &:read-only {
60
-
77
+ &[readonly] {
78
+ background-image: none;
79
+ border: none;
80
+ background-color: transparent;
81
+ padding: 0;
61
82
  }
62
83
 
63
84
  &:focus {
64
85
  ${(props) => props.theme.focus.default};
65
86
  }
87
+
88
+ &:disabled {
89
+ background-color: ${(props) => props.theme.color.background.input};
90
+ background-image: ${(props) => `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 320 512'%3E%3Cpath fill='${encodeURIComponent(props.theme.color.text.default)}' d='M31 192h258c17 0 26 21 14 33l-129 129c-8 8-21 8-29 0L17 225c-12-12-3-33 14-33z'/%3E%3C/svg%3E")`};
91
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid
92
+ ${props.theme.color.border.default}`};
93
+ padding: ${(props) => `${props.theme.spacing.s} ${props.theme.spacing.xxxxl} ${props.theme.spacing.s} ${props.theme.spacing.m}`};
94
+ }
66
95
  }
67
96
 
68
97
  select[multiple] {
@@ -70,6 +99,40 @@ export const CommonFieldWrapper = styled.div `
70
99
  background-image: none;
71
100
  overflow: auto;
72
101
  }
102
+
103
+ textarea {
104
+
105
+ background-color: ${(props) => props.theme.color.background.input};
106
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid
107
+ ${props.theme.color.border.default}`};
108
+ padding: ${(props) => props.theme.spacing.s};
109
+
110
+ &:read-only {
111
+ border: none;
112
+ background-color: transparent;
113
+ padding: 0;
114
+ min-height: unset;
115
+ resize: none;
116
+ field-sizing: content;
117
+
118
+ &::placeholder {
119
+ color: ${(props) => props.theme.color.text.default};
120
+ }
121
+ }
122
+
123
+ &:disabled {
124
+ background-color: ${(props) => props.theme.color.background.input};
125
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid
126
+ ${props.theme.color.border.default}`};
127
+ min-height: 5rem;
128
+ padding: ${(props) => props.theme.spacing.s};
129
+
130
+ &::placeholder {
131
+ color: ${(props) => props.theme.color.text.muted};
132
+ }
133
+ }
134
+
135
+ }
73
136
  `;
74
137
  export const CommonCheckboxStyles = styled.div `
75
138
  input[type="checkbox"] {
@@ -175,8 +238,15 @@ export const CommonCheckboxStyles = styled.div `
175
238
  }
176
239
  }
177
240
 
178
- &:read-only {
179
-
241
+ &[readonly] {
242
+ background: transparent;
243
+ border: none;
244
+ }
245
+
246
+ &:disabled {
247
+ background-color: ${(props) => props.theme.color.background.input};
248
+ border: ${(props) => props.theme.strokeWidth.thin} solid
249
+ ${(props) => props.theme.color.border.default};
180
250
  }
181
251
  }
182
252
  `;
@@ -7,7 +7,8 @@ export const FieldTemplate = (props) => {
7
7
  const { name, uiSchema, children, ...otherProps } = props;
8
8
  const title = getTitle(props);
9
9
  const description = getDescription(props);
10
- const { help, info, props: { wrapper: wrapperProps = {}, title: titleProps, description: descriptionProps, help: helpProps, error: errorProps, } = {}, } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
10
+ const { help, info, disabled, props: { wrapper: wrapperProps = {}, title: titleProps, description: descriptionProps, help: helpProps, error: errorProps, disabled: isDisabled, } = {}, } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
11
+ const isReadOnly = props.schema?.readOnly;
11
12
  const dataAttributes = Object.keys(otherProps)
12
13
  .filter((key) => key.startsWith("data-"))
13
14
  .reduce((acc, key) => {
@@ -19,5 +20,5 @@ export const FieldTemplate = (props) => {
19
20
  ...wrapperProps,
20
21
  ...dataAttributes, // This will only include data-* attributes
21
22
  };
22
- return (_jsxs(FieldWrapper, { ...mergedWrapperProps, children: [title && (_jsxs(FieldTitle, { ...titleProps, htmlFor: name, children: [title, props.required && _jsx(RequiredIndicator, {})] })), info && _jsx(FieldInfo, { ...info }), description && (_jsx(FieldDescription, { ...descriptionProps, children: description })), children, help && _jsx(FieldHelp, { ...helpProps, children: help }), _jsx(ErrorMessage, { ...errorProps, name: name })] }));
23
+ return (_jsxs(FieldWrapper, { ...mergedWrapperProps, "$isDisabled": isDisabled, children: [title && (_jsxs(FieldTitle, { ...titleProps, htmlFor: name, children: [title, props.required && _jsx(RequiredIndicator, {})] })), info && _jsx(FieldInfo, { ...info }), description && (_jsx(FieldDescription, { ...descriptionProps, children: description })), children, help && _jsx(FieldHelp, { ...helpProps, children: help }), _jsx(ErrorMessage, { ...errorProps, name: name })] }));
23
24
  };
@@ -1,3 +1,4 @@
1
+ import { lighten } from "polished";
1
2
  import { styled } from "styled-components";
2
3
  export const ObjectFieldTemplateWrapper = styled.fieldset `
3
4
  color: ${(props) => props.theme.color.text.default};
@@ -5,6 +6,18 @@ export const ObjectFieldTemplateWrapper = styled.fieldset `
5
6
  margin-inline: 0;
6
7
  margin-bottom: ${(props) => props.theme.spacing.xs};
7
8
 
9
+ &:has(input[disabled]), &:has(option[disabled]), &:has(select[disabled]), &:has(textarea[disabled]) {
10
+ border-color: ${(props) => lighten(0.4, props.theme.color.border.default)};
11
+
12
+ legend {
13
+ color: ${(props) => lighten(0.4, props.theme.color.text.default)};
14
+
15
+ & + p {
16
+ color: ${(props) => lighten(0.4, props.theme.color.text.default)};
17
+ }
18
+ }
19
+ }
20
+
8
21
  `;
9
22
  export const ObjectFieldTemplateTitle = styled.legend `
10
23
  color: ${(props) => props.theme.color.text.default};
@@ -11,7 +11,7 @@ export const MultipleChoiceField = (props) => {
11
11
  const { values } = useFormikContext();
12
12
  const value = getIn(values, name);
13
13
  const selected = getSelectedEnum(value, enums);
14
- const notSelected = enums?.values?.filter((v) => Array.isArray(value) && !value.includes(v));
14
+ const notSelected = enums?.values?.filter((v) => Array.isArray(value) && !value.includes(v.const));
15
15
  const hideNotSelected = onlyShowSelected === true || selected === undefined;
16
16
  const SelectedFieldTemplate = (props.uiSchema?.["ui:template"] &&
17
17
  templates[props.uiSchema?.["ui:template"]]) ??
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
2
  import * as formik from "formik";
3
- export declare const FieldWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
+ export declare const FieldWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
4
+ $isDisabled?: boolean;
5
+ }>> & string;
4
6
  export declare const FieldTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>> & string;
5
7
  export declare const FieldDescription: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, never>> & string;
6
8
  export declare const FieldHelp: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, never>> & string;
@@ -12,7 +12,9 @@ export declare const components: {
12
12
  }, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & import("react").RefAttributes<HTMLFormElement>>, keyof import("react").Component<any, {}, any>>;
13
13
  FormButtonWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
14
14
  FormButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Readonly<import("@nolwenture/component-library").ButtonProps>, never>> & string & Omit<typeof import("@nolwenture/component-library").Button, keyof import("react").Component<any, {}, any>>;
15
- FieldWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
15
+ FieldWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
16
+ $isDisabled?: boolean;
17
+ }>> & string;
16
18
  FieldTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>> & string;
17
19
  FieldDescription: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, never>> & string;
18
20
  FieldHelp: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, never>> & string;
@@ -110,9 +112,9 @@ export declare const components: {
110
112
  }, never>, "ref"> & {
111
113
  ref?: unknown;
112
114
  }, never>> & string;
113
- SearchableSelectFieldClearButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
115
+ SearchableSelectFieldClearButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
114
116
  SearchableSelectFieldInputContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
115
- SearchableMultiTagSelectFieldInput: ({ name, placeholder, enums, emptySearchMessage, closeElement, className, }: import("../fields/SearchableMultiTagSelectField").SearchableMultiTagSelectFieldInputProps) => import("react/jsx-runtime").JSX.Element;
117
+ SearchableMultiTagSelectFieldInput: ({ name, placeholder, enums, emptySearchMessage, closeElement, className, disabled, readOnly, }: import("../fields/SearchableMultiTagSelectField").SearchableMultiTagSelectFieldInputProps) => import("react/jsx-runtime").JSX.Element;
116
118
  SearchableMultiTagSelectFieldContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>, "ref"> & {
117
119
  ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
118
120
  }, never>> & string;
@@ -123,8 +125,8 @@ export declare const components: {
123
125
  ref?: unknown;
124
126
  }, never>> & string;
125
127
  SearchableMultiTagSelectFieldBadgeContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
126
- SearchableMultiTagSelectFieldBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
127
- SearchableMultiTagSelectFieldBadgeCloseElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
128
+ SearchableMultiTagSelectFieldBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
129
+ SearchableMultiTagSelectFieldBadgeCloseElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
128
130
  SearchableMultiTagSelectFieldOptionList: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, never>> & string;
129
131
  SearchableMultiTagSelectFieldOptionListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>> & string;
130
132
  SearchableMultiTagSelectFieldOptionListWithoutItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>> & string;
@@ -5,5 +5,7 @@ export type SearchableMultiTagSelectFieldInputProps = {
5
5
  emptySearchMessage?: string;
6
6
  closeElement?: string;
7
7
  className?: string;
8
+ disabled?: boolean;
9
+ readOnly?: boolean;
8
10
  };
9
- export declare const SearchableMultiTagSelectFieldInput: ({ name, placeholder, enums, emptySearchMessage, closeElement, className, }: SearchableMultiTagSelectFieldInputProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const SearchableMultiTagSelectFieldInput: ({ name, placeholder, enums, emptySearchMessage, closeElement, className, disabled, readOnly, }: SearchableMultiTagSelectFieldInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  export * as fields from "./SearchableMultiTagSelectField";
2
2
  declare const components: {
3
- SearchableMultiTagSelectFieldInput: ({ name, placeholder, enums, emptySearchMessage, closeElement, className, }: import("./SearchableMultiTagSelectFieldInput").SearchableMultiTagSelectFieldInputProps) => import("react/jsx-runtime").JSX.Element;
3
+ SearchableMultiTagSelectFieldInput: ({ name, placeholder, enums, emptySearchMessage, closeElement, className, disabled, readOnly, }: import("./SearchableMultiTagSelectFieldInput").SearchableMultiTagSelectFieldInputProps) => import("react/jsx-runtime").JSX.Element;
4
4
  SearchableMultiTagSelectFieldContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>, "ref"> & {
5
5
  ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
6
6
  }, never>> & string;
@@ -11,8 +11,8 @@ declare const components: {
11
11
  ref?: unknown;
12
12
  }, never>> & string;
13
13
  SearchableMultiTagSelectFieldBadgeContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
14
- SearchableMultiTagSelectFieldBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
15
- SearchableMultiTagSelectFieldBadgeCloseElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
14
+ SearchableMultiTagSelectFieldBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
15
+ SearchableMultiTagSelectFieldBadgeCloseElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
16
16
  SearchableMultiTagSelectFieldOptionList: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, never>> & string;
17
17
  SearchableMultiTagSelectFieldOptionListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>> & string;
18
18
  SearchableMultiTagSelectFieldOptionListWithoutItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>> & string;
@@ -8,8 +8,8 @@ export declare const SearchableMultiTagSelectFieldInputElement: import("styled-c
8
8
  ref?: unknown;
9
9
  }, never>> & string;
10
10
  export declare const SearchableMultiTagSelectFieldBadgeContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
11
- export declare const SearchableMultiTagSelectFieldBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
12
- export declare const SearchableMultiTagSelectFieldBadgeCloseElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
11
+ export declare const SearchableMultiTagSelectFieldBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
12
+ export declare const SearchableMultiTagSelectFieldBadgeCloseElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
13
13
  export declare const SearchableMultiTagSelectFieldOptionList: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, never>> & string;
14
14
  export declare const SearchableMultiTagSelectFieldOptionListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>> & string;
15
15
  export declare const SearchableMultiTagSelectFieldOptionListWithoutItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>> & string;
@@ -18,5 +18,5 @@ export declare const SearchableSelectFieldInputElement: import("styled-component
18
18
  }, never>, "ref"> & {
19
19
  ref?: unknown;
20
20
  }, never>> & string;
21
- export declare const SearchableSelectFieldClearButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
21
+ export declare const SearchableSelectFieldClearButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
22
22
  export declare const SearchableSelectFieldInputContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -40,9 +40,9 @@ export declare const fieldComponents: {
40
40
  }, never>, "ref"> & {
41
41
  ref?: unknown;
42
42
  }, never>> & string;
43
- SearchableSelectFieldClearButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
43
+ SearchableSelectFieldClearButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
44
44
  SearchableSelectFieldInputContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
45
- SearchableMultiTagSelectFieldInput: ({ name, placeholder, enums, emptySearchMessage, closeElement, className, }: SearchableMultiTagSelectField.SearchableMultiTagSelectFieldInputProps) => import("react/jsx-runtime").JSX.Element;
45
+ SearchableMultiTagSelectFieldInput: ({ name, placeholder, enums, emptySearchMessage, closeElement, className, disabled, readOnly, }: SearchableMultiTagSelectField.SearchableMultiTagSelectFieldInputProps) => import("react/jsx-runtime").JSX.Element;
46
46
  SearchableMultiTagSelectFieldContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>, "ref"> & {
47
47
  ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
48
48
  }, never>> & string;
@@ -53,8 +53,8 @@ export declare const fieldComponents: {
53
53
  ref?: unknown;
54
54
  }, never>> & string;
55
55
  SearchableMultiTagSelectFieldBadgeContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
56
- SearchableMultiTagSelectFieldBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
57
- SearchableMultiTagSelectFieldBadgeCloseElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
56
+ SearchableMultiTagSelectFieldBadge: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
57
+ SearchableMultiTagSelectFieldBadgeCloseElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
58
58
  SearchableMultiTagSelectFieldOptionList: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, never>> & string;
59
59
  SearchableMultiTagSelectFieldOptionListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>> & string;
60
60
  SearchableMultiTagSelectFieldOptionListWithoutItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>> & string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolwenture/formik-jsonschema-form",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Formik form generation from json schema",
5
5
  "author": "anttivikman <antti.vikman@nolwenture.com>",
6
6
  "contributors": [
@@ -83,6 +83,7 @@
83
83
  "formik": "^2.4.5",
84
84
  "jest": "^29.7.0",
85
85
  "jest-environment-jsdom": "^29.7.0",
86
+ "polished": "^4.3.1",
86
87
  "react": "^18.2.0",
87
88
  "react-dom": "^18.2.0",
88
89
  "react-redux": "^9.2.0",