This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function (global, factory) { | |
| typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('prop-types')) : | |
| typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom', 'prop-types'], factory) : | |
| (factory((global['react-sandbox-editor'] = {}),global.React,global.require$$10,global.PropTypes)); | |
| }(this, (function (exports,React,require$$10,PropTypes) { 'use strict'; | |
| React = React && React.hasOwnProperty('default') ? React['default'] : React; | |
| require$$10 = require$$10 && require$$10.hasOwnProperty('default') ? require$$10['default'] : require$$10; | |
| PropTypes = PropTypes && PropTypes.hasOwnProperty('default') ? PropTypes['default'] : PropTypes; |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function (global, factory) { | |
| typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('prop-types')) : | |
| typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom', 'prop-types'], factory) : | |
| (factory((global['react-sandbox-editor'] = {}),global.React,global.ReactDOM,global.PropTypes)); | |
| }(this, (function (exports,React,require$$10,PropTypes) { 'use strict'; | |
| React = React && React.hasOwnProperty('default') ? React['default'] : React; | |
| require$$10 = require$$10 && require$$10.hasOwnProperty('default') ? require$$10['default'] : require$$10; | |
| PropTypes = PropTypes && PropTypes.hasOwnProperty('default') ? PropTypes['default'] : PropTypes; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const form = useForm({ | |
| onSubmit, | |
| }); | |
| const usernameField = useField("username", form, { | |
| defaultValue: "", | |
| validations: [ | |
| async formData => { | |
| await timeout(2000); | |
| return formData.username.length < 6 && "Username already exists"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Skipping some boilerplate: imports, ReactDOM, etc. | |
| export const useField = (name, form, { defaultValue } = {}) => { | |
| let [value, setValue] = useState(defaultValue); | |
| let field = { | |
| name, | |
| value, | |
| onChange: e => { | |
| setValue(e.target.value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const useField = ( | |
| name, | |
| form, | |
| { defaultValue, validations = [] } = {} | |
| ) => { | |
| let [value, setValue] = useState(defaultValue); | |
| let [errors, setErrors] = useState([]); | |
| const validate = async () => { | |
| let formData = form.getFormData(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const useField = ( | |
| name, | |
| form, | |
| { defaultValue, validations = [], fieldsToValidateOnChange = [name] } = {} | |
| ) => { | |
| let [value, setValue] = useState(defaultValue); | |
| let [errors, setErrors] = useState([]); | |
| let [pristine, setPristine] = useState(true); | |
| let [validating, setValidating] = useState(false); | |
| let validateCounter = useRef(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // default implementation of customizer when calling db.mergeEntities(entitiesPatch) | |
| ((objValue, srcValue) => { | |
| if (isArray(objValue) || isArray(srcValue) || isSet(objValue) || isSet(srcValue)) { | |
| return srcValue | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { schema } from "normalizr"; | |
| import createDB from "react-use-database"; | |
| let TodoSchema = new schema.Entity("Todo"); | |
| let models = [TodoSchema]; | |
| let [ DatabaseProvider, useDB ] = createDB( | |
| models, | |
| { |