P17
P17 is a simple Svelte library for crafting forms. Crafted to demonstrate my understanding and ability in accessible HTML form design and development.
I haven't really tested the accessibility aspect yet.
I used the GDS Design System as a loose guide because it helps to have a starting point; empirically backed double so.
My library's unique selling point is that the field unvalidates when a user focuses on an input after validation has accepted or reject the current content (JavaScript only). It's not perfect. The unvalidation simply removes the error message which means users won't have it as reference as they're typing a new answer.
Maybe I'll improve that in a future version. No garuntees.
Made to be Plundered
This library is made to be forked or plundered by anyone for whatever you want as long as you adhere to the permissive MIT license. Break rules and innovate!
Components
<ButtonPopulate>
On click, populates specified form fields with specified values.
<script>
export let label = "Populate"
export let values = {}
</script>
<ButtonReset>
On click, resets the form fields to their initial values.
<script>
export let label = "Reset"
export let clear = false
</script>
<ButtonSubmit>
On click, validates and submits the form.
<script>
export let label = "Submit"
</script>
<ButtonUnvalidate>
On click, sets all fields to the unvalidated state.
<script>
export let label = "Unvalidate"
</script>
<DebugFieldPrinter>
Upon change, prints a field's value and error values.
<slot />
<DebugFormPrinter>
Upon change, prints the fields, values, and errors stores.
<script>
export let fields = false
export let values = false
export let errors = false
</script>
<slot />
<DebugFormTable>
Renders a reactively updating table of field values.
<Field>
<script>
export let type
export let id =
export let name
export let label = ""
export let hint = ""
export let options = null
export let value = ""
export let format = undefined
export let validate = undefined
setContext('p17-field', ...)
</script>
<slot name="before" />
<slot name="after" />
<Form>
Primary component in which fields are slotted into.
$restProps are passed to the form element (outer component element).
<script>
export const fields = writable({})
export const values = writable({})
export const errors = writable({})
export const form = writable({})
export let id =
export let validate = null
export let submit = null
setContext('p17-fields', ...)
setContext('p17-values', ...)
setContext('p17-errors', ...)
setContext('p17-form', ...)
</script>
<slot />