Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ containers and keys or use the ones that come with the module.
| | as | String | HTML tag to use for the inner-text field |
| | htmlClass | String | HTML class for the tag used |
| | defaultValue | String | Either used as a static value for the HTML element or as a placeholder when is not defined |
| inner-html | renderer | String | inner-html |
| | as | String | HTML tag to use for the inner-html field |
| | htmlClass | String | HTML class for the tag used |
| | defaultValue | String | Either used as a static value for the HTML element |
| button | renderer | String | button |
| | content | String | button inner html |

Expand Down
28 changes: 27 additions & 1 deletion demo/src/schema/all-available-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ export default {
htmlClass: 'text-muted d-block mb-3 mt-1',
defaultValue: 'This is some raw html text content: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum'
},
innerHtml: {
type: "field",
renderer: "inner-html",
name: "innerText",
as: "p",
htmlClass: "text-muted d-block mb-3 mt-1",
defaultValue:
"<h2>This is some raw html content</h2>Lorem Ipsum is simply dummy text of the <b>printing and typesetting industry</b>. Lorem Ipsum has been the industry's standard dummy text ever <u>since the 1500s</u>, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum",
},
autocomplete: {
name: "autocomplete",
label: "Autocomplete",
Expand Down Expand Up @@ -151,6 +160,23 @@ export default {
formGroupClass: "form-group mb-4",
validation: [['array'], ['of', [['string']]]]
},
reactSelectCreatableMultiDelimited: {
type: "field",
renderer: "react-select",
name: "react-select-creatable-multi-delimited",
label: "React Select Creatable Multi Delimited with ','",
delimiter: ',',
isMulti: true,
isCreatable: true,
options: [],
menuIsOpen: false,
defaultValue: [],
components: {
DropdownIndicator: null
},
formGroupClass: "form-group mb-4",
validation: [['array'], ['of', [['string']]]]
},
textarea: {
name: "description",
label: "Description",
Expand Down Expand Up @@ -271,4 +297,4 @@ export default {
}
}
}
}
}
19 changes: 19 additions & 0 deletions src/Field/InnerHtml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";

const InnerHtml = ({ config, formik, value, error }) => {
const {
name,
as: Component = "div",
htmlClass,
defaultValue = "",
...attributes
} = config;

return (
<Component className={htmlClass} {...attributes}>
<div dangerouslySetInnerHTML={{ __html: value || defaultValue }}></div>
</Component>
);
};

export default React.memo(InnerHtml);
21 changes: 16 additions & 5 deletions src/Field/ReactSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const ReactSelect = ({ config, formik, value, error }) => {
isDisabled = false,
isClearable = false,
isCreatable = false,
delimiter= '',
options: initialOptions,
...attributes
} = config;
Expand Down Expand Up @@ -103,15 +104,25 @@ const ReactSelect = ({ config, formik, value, error }) => {
switch (event.key) {
case 'Enter':
case 'Tab':
changeHandler(
if (delimiter && inputValue.indexOf(delimiter) >= 1) {
changeHandler(
setFieldValueWrapper(setFieldValue, name),
formik,
config,
[ ...selectedValue, inputValue ],
[...selectedValue, ...inputValue.split(delimiter)],
'onChange'
);
setInputValue('');
event.preventDefault();
);
} else {
changeHandler(
setFieldValueWrapper(setFieldValue, name),
formik,
config,
[...selectedValue, inputValue],
'onChange'
);
}
setInputValue('');
event.preventDefault();
}
},
...attributes
Expand Down
2 changes: 2 additions & 0 deletions src/Field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Wysiwyg from './Wysiwyg';
import Textarea from './Textarea';
import Checkbox from './Checkbox';
import InnerText from './InnerText';
import InnerHtml from './InnerHtml';
import CodeEditor from './CodeEditor';
import ReactSelect from './ReactSelect';
import FileUploader from './FileUploader';
Expand All @@ -29,6 +30,7 @@ registerField('wysiwyg', Wysiwyg);
registerField('textarea', Textarea);
registerField('checkbox', Checkbox);
registerField('inner-text', InnerText);
registerField('inner-html', InnerHtml);
registerField('code-editor', CodeEditor);
registerField('react-select', ReactSelect);
registerField('autocomplete', Autocomplete);
Expand Down