Comparing version 0.1.13 to 0.1.14
{ | ||
"name": "sveltik", | ||
"version": "0.1.13", | ||
"repository": "git@github.com:nathancahill/sveltik.git", | ||
"version": "0.1.14", | ||
"repository": "github:nathancahill/sveltik", | ||
"author": "Nathan Cahill <nathan@nathancahill>", | ||
@@ -11,14 +11,14 @@ "svelte": "src/index.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.10.2", | ||
"@babel/preset-env": "^7.10.2", | ||
"@rollup/plugin-node-resolve": "^8.0.1", | ||
"@testing-library/jest-dom": "^5.9.0", | ||
"babel-jest": "^26.0.1", | ||
"@babel/core": "^7.12.9", | ||
"@babel/preset-env": "^7.12.7", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"@testing-library/jest-dom": "^5.11.6", | ||
"babel-jest": "^26.6.3", | ||
"dainte": "^0.1.4", | ||
"jest": "^26.0.1", | ||
"jsdom": "^16.2.2", | ||
"prettier": "^2.0.5", | ||
"prettier-plugin-svelte": "^1.1.0", | ||
"rollup": "^2.11.2", | ||
"rollup-plugin-svelte": "^5.2.2" | ||
"jest": "^26.6.3", | ||
"jsdom": "^16.4.0", | ||
"prettier": "^2.2.1", | ||
"prettier-plugin-svelte": "^1.4.1", | ||
"rollup": "^2.34.0", | ||
"rollup-plugin-svelte": "^5.2.3" | ||
}, | ||
@@ -25,0 +25,0 @@ "dependencies": { |
174
README.md
@@ -7,27 +7,25 @@ # Sveltik ![CI](https://github.com/nathancahill/sveltik/workflows/CI/badge.svg) | ||
<script> | ||
import { Sveltik, Form, Field, ErrorMessage } from 'sveltik' | ||
import { Sveltik, Form, Field, ErrorMessage } from 'sveltik' | ||
let initialValues = { | ||
email: '', | ||
password: '', | ||
} | ||
let initialValues = { | ||
email: '', | ||
password: '', | ||
} | ||
let validate = values => { | ||
const errors = {} | ||
if (!values.email) { | ||
errors.email = 'Required' | ||
} else if ( | ||
!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(values.email) | ||
) { | ||
errors.email = 'Invalid email address' | ||
let validate = values => { | ||
const errors = {} | ||
if (!values.email) { | ||
errors.email = 'Required' | ||
} else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(values.email)) { | ||
errors.email = 'Invalid email address' | ||
} | ||
return errors | ||
} | ||
return errors | ||
} | ||
let onSubmit = (values, { setSubmitting }) => { | ||
setTimeout(() => { | ||
alert(JSON.stringify(values, null, 2)) | ||
setSubmitting(false) | ||
}, 400) | ||
} | ||
let onSubmit = (values, { setSubmitting }) => { | ||
setTimeout(() => { | ||
alert(JSON.stringify(values, null, 2)) | ||
setSubmitting(false) | ||
}, 400) | ||
} | ||
</script> | ||
@@ -41,5 +39,3 @@ | ||
<ErrorMessage name="password" as="div" /> | ||
<button type="submit" disabled={isSubmitting}> | ||
Submit | ||
</button> | ||
<button type="submit" disabled={isSubmitting}>Submit</button> | ||
</Form> | ||
@@ -62,31 +58,31 @@ </Sveltik> | ||
<script> | ||
import { Sveltik } from 'sveltik' | ||
import { Sveltik } from 'sveltik' | ||
</script> | ||
<div> | ||
<h1>My Form</h1> | ||
<Sveltik | ||
initialValues={{ name: 'jared' }} | ||
onSubmit={(values, actions) => { | ||
setTimeout(() => { | ||
alert(JSON.stringify(values, null, 2)); | ||
actions.setSubmitting(false); | ||
}, 1000); | ||
}} | ||
let:props | ||
> | ||
<form on:submit|preventDefault={props.handleSubmit}> | ||
<input | ||
type="text" | ||
on:change={props.handleChange} | ||
on:blur={props.handleBlur} | ||
value={props.values.name} | ||
name="name" | ||
/> | ||
{#if props.errors.name} | ||
<div id="feedback">{props.errors.name}</div> | ||
{/if} | ||
<button type="submit">Submit</button> | ||
</form> | ||
</Sveltik> | ||
<h1>My Form</h1> | ||
<Sveltik | ||
initialValues={{ name: 'jared' }} | ||
onSubmit={(values, actions) => { | ||
setTimeout(() => { | ||
alert(JSON.stringify(values, null, 2)) | ||
actions.setSubmitting(false) | ||
}, 1000) | ||
}} | ||
let:props | ||
> | ||
<form on:submit|preventDefault={props.handleSubmit}> | ||
<input | ||
type="text" | ||
on:change={props.handleChange} | ||
on:blur={props.handleBlur} | ||
value={props.values.name} | ||
name="name" | ||
/> | ||
{#if props.errors.name} | ||
<div id="feedback">{props.errors.name}</div> | ||
{/if} | ||
<button type="submit">Submit</button> | ||
</form> | ||
</Sveltik> | ||
</div> | ||
@@ -353,4 +349,4 @@ ``` | ||
<script> | ||
export let field | ||
export let props | ||
export let field | ||
export let props | ||
</script> | ||
@@ -365,44 +361,44 @@ | ||
<script> | ||
import { Sveltik, Form, Field } from 'sveltik' | ||
import MyInput from './MyInput.svelte' | ||
import { Sveltik, Form, Field } from 'sveltik' | ||
import MyInput from './MyInput.svelte' | ||
</script> | ||
<div> | ||
<h1>My Form</h1> | ||
<Sveltik | ||
initialValues={{ email: '', color: 'red', firstName: '', lastName: '' }} | ||
onSubmit={(values, actions) => { | ||
setTimeout(() => { | ||
alert(JSON.stringify(values, null, 2)); | ||
actions.setSubmitting(false); | ||
}, 1000); | ||
}} | ||
> | ||
<Form> | ||
<Field type="email" name="email" placeholder="Email" /> | ||
<Field as="select" name="color"> | ||
<option value="red">Red</option> | ||
<option value="green">Green</option> | ||
<option value="blue">Blue</option> | ||
</Field> | ||
<h1>My Form</h1> | ||
<Sveltik | ||
initialValues={{ email: '', color: 'red', firstName: '', lastName: '' }} | ||
onSubmit={(values, actions) => { | ||
setTimeout(() => { | ||
alert(JSON.stringify(values, null, 2)) | ||
actions.setSubmitting(false) | ||
}, 1000) | ||
}} | ||
> | ||
<Form> | ||
<Field type="email" name="email" placeholder="Email" /> | ||
<Field as="select" name="color"> | ||
<option value="red">Red</option> | ||
<option value="green">Green</option> | ||
<option value="blue">Blue</option> | ||
</Field> | ||
<Field name="firstName" let:field let:meta> | ||
<div> | ||
<input | ||
type="text" | ||
placeholder="Jon" | ||
{...field} | ||
on:input={field.handleInput} | ||
on:blur={field.handleBlur} | ||
/> | ||
{#if meta.touched && meta.error} | ||
<div className="error">{meta.error}</div> | ||
{/if} | ||
</div> | ||
</Field> | ||
<Field name="firstName" let:field let:meta> | ||
<div> | ||
<input | ||
type="text" | ||
placeholder="Jon" | ||
{...field} | ||
on:input={field.handleInput} | ||
on:blur={field.handleBlur} | ||
/> | ||
{#if meta.touched && meta.error} | ||
<div className="error">{meta.error}</div> | ||
{/if} | ||
</div> | ||
</Field> | ||
<Field name="lastName" placeholder="Doe" as={MyInput} /> | ||
<button type="submit">Submit</button> | ||
</Form> | ||
</Sveltik> | ||
<Field name="lastName" placeholder="Doe" as={MyInput} /> | ||
<button type="submit">Submit</button> | ||
</Form> | ||
</Sveltik> | ||
</div> | ||
@@ -409,0 +405,0 @@ ``` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
435144
12
12220
528
1