Skip to content

Commit

Permalink
Release 1.0.0-alpha.1
Browse files Browse the repository at this point in the history
  • Loading branch information
webblocksapp committed Oct 4, 2022
1 parent 330d3e4 commit fd735ac
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 11 deletions.
11 changes: 9 additions & 2 deletions packages/lib/examples/components/Checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FormHandler } from '@interfaces';
import { Component, createEffect, JSX, onMount, splitProps } from 'solid-js';
import { Component, createEffect, JSX, onCleanup, onMount, splitProps } from 'solid-js';
import { createStore } from 'solid-js/store';

export interface CheckboxProps extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, 'type'> {
Expand Down Expand Up @@ -123,7 +123,14 @@ export const Checkbox: Component<CheckboxProps> = (props) => {
* Initializes the form field default value
*/
onMount(() => {
local.checked !== undefined && local.formHandler?.setFieldDefaultValue(rest.name, getValue(local.checked));
local.formHandler?.setFieldDefaultValue(rest.name, getValue(local.checked));
});

/**
* Refresh the form field when unmounted.
*/
onCleanup(() => {
local.formHandler?.refreshFormField(rest.name);
});

return (
Expand Down
11 changes: 9 additions & 2 deletions packages/lib/examples/components/Checkboxes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, createEffect, createSelector, For, JSX, onMount, splitProps } from 'solid-js';
import { Component, createEffect, createSelector, For, JSX, onCleanup, onMount, splitProps } from 'solid-js';
import { Checkbox } from '@components';
import { FormHandler } from '@interfaces';
import { createStore } from 'solid-js/store';
Expand Down Expand Up @@ -111,7 +111,14 @@ export const Checkboxes: Component<CheckboxesProps> = (props) => {
* Initializes the form field default value
*/
onMount(() => {
store.defaultValue && rest.formHandler?.setFieldDefaultValue(rest.name, store.defaultValue);
rest.formHandler?.setFieldDefaultValue(rest.name, store.defaultValue);
});

/**
* Refresh the form field when unmounted.
*/
onCleanup(() => {
rest.formHandler?.refreshFormField(rest.name);
});

return (
Expand Down
11 changes: 9 additions & 2 deletions packages/lib/examples/components/Radio/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FormHandler } from '@interfaces';
import { Component, createEffect, JSX, onMount, splitProps } from 'solid-js';
import { Component, createEffect, JSX, onCleanup, onMount, splitProps } from 'solid-js';
import { createStore } from 'solid-js/store';

export interface RadioProps extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, 'type' | 'value'> {
Expand Down Expand Up @@ -95,7 +95,14 @@ export const Radio: Component<RadioProps> = (props) => {
* Initializes the form field default value
*/
onMount(() => {
local.checked !== undefined && local.formHandler?.setFieldDefaultValue(rest.name, getValue(local.checked));
local.formHandler?.setFieldDefaultValue(rest.name, getValue(local.checked));
});

/**
* Refresh the form field when unmounted.
*/
onCleanup(() => {
local.formHandler?.refreshFormField(rest.name);
});

return (
Expand Down
11 changes: 9 additions & 2 deletions packages/lib/examples/components/Radios/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, createEffect, createSelector, For, JSX, onMount, splitProps } from 'solid-js';
import { Component, createEffect, createSelector, For, JSX, onCleanup, onMount, splitProps } from 'solid-js';
import { Radio } from '@components';
import { FormHandler } from '@interfaces';
import { createStore } from 'solid-js/store';
Expand Down Expand Up @@ -99,7 +99,14 @@ export const Radios: Component<RadiosProps> = (props) => {
* Initializes the form field default value
*/
onMount(() => {
store.defaultValue && rest.formHandler?.setFieldDefaultValue(rest.name, store.defaultValue);
rest.formHandler?.setFieldDefaultValue(rest.name, store.defaultValue);
});

/**
* Refresh the form field when unmounted.
*/
onCleanup(() => {
rest.formHandler?.refreshFormField(rest.name);
});

return (
Expand Down
11 changes: 9 additions & 2 deletions packages/lib/examples/components/Select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FormHandler } from '@interfaces';
import { Component, createEffect, createSignal, For, JSX, onMount, splitProps } from 'solid-js';
import { Component, createEffect, createSignal, For, JSX, onCleanup, onMount, splitProps } from 'solid-js';
import { createStore } from 'solid-js/store';

type SelectableOption = { value: string | number; label: string };
Expand Down Expand Up @@ -126,7 +126,14 @@ export const Select: Component<SelectProps> = (props) => {
* Initializes the form field default value
*/
onMount(() => {
store.defaultValue && local.formHandler?.setFieldDefaultValue(rest.name, store.defaultValue);
local.formHandler?.setFieldDefaultValue(rest.name, store.defaultValue);
});

/**
* Refresh the form field when unmounted.
*/
onCleanup(() => {
local.formHandler?.refreshFormField(rest.name);
});

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "solid-form-handler",
"description": "A SolidJS library for simplifying form validations.",
"version": "1.0.0-alpha",
"version": "1.0.0-alpha.1",
"license": "MIT",
"keywords": [
"SolidJS forms",
Expand Down

0 comments on commit fd735ac

Please sign in to comment.