From 869cb47df9f9facca046c40efd8e984e1c95fec4 Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 20 Jul 2020 12:53:43 +0500 Subject: [PATCH] feat(wrap): replace wrapper boilerplate code #27 --- .../src/components/fields/ArrayField.svelte | 22 +++++++-------- .../src/components/fields/BooleanField.svelte | 27 +++++++++---------- .../src/components/fields/NullField.svelte | 25 ++++++++--------- .../src/components/fields/NumberField.svelte | 10 ++----- .../src/components/fields/ObjectField.svelte | 21 +++++---------- .../src/components/fields/StringField.svelte | 11 +++----- .../fields/extra/TextareaField.svelte | 27 +++++++++---------- 7 files changed, 57 insertions(+), 86 deletions(-) diff --git a/packages/lib/src/components/fields/ArrayField.svelte b/packages/lib/src/components/fields/ArrayField.svelte index 022e50a..f565569 100644 --- a/packages/lib/src/components/fields/ArrayField.svelte +++ b/packages/lib/src/components/fields/ArrayField.svelte @@ -2,12 +2,13 @@ import type { ErrorRecord } from "@pyoner/svelte-form-common"; import { createProps, - getSchemaComponent, - getSchemaComponentProps, defaultValue, getComponent, - getComponentProps, + getProps, + getComponentFromContainer, + getPropsFromContainer, } from "../../helpers"; + import Wrap from "../helpers/Wrap.svelte"; type T = Array; const p = createProps([]); @@ -59,16 +60,13 @@ {#if components && schema && schema.items && schema.items.type} - + {#if value} {#each value as v, i (i)}
{/if} - + {/if} diff --git a/packages/lib/src/components/fields/BooleanField.svelte b/packages/lib/src/components/fields/BooleanField.svelte index 7f5b55a..aaefd48 100644 --- a/packages/lib/src/components/fields/BooleanField.svelte +++ b/packages/lib/src/components/fields/BooleanField.svelte @@ -1,26 +1,23 @@ {#if schema && components} - + - + {/if} diff --git a/packages/lib/src/components/fields/NullField.svelte b/packages/lib/src/components/fields/NullField.svelte index b34fa64..1144a32 100644 --- a/packages/lib/src/components/fields/NullField.svelte +++ b/packages/lib/src/components/fields/NullField.svelte @@ -1,22 +1,19 @@ {#if schema && components} - + - + {/if} diff --git a/packages/lib/src/components/fields/NumberField.svelte b/packages/lib/src/components/fields/NumberField.svelte index 8ca79a7..2f7d094 100644 --- a/packages/lib/src/components/fields/NumberField.svelte +++ b/packages/lib/src/components/fields/NumberField.svelte @@ -1,5 +1,5 @@ {#if schema && components} - + {#each Object.entries(schema.properties) as [key, propSchema] (key)} {/each} - + {/if} diff --git a/packages/lib/src/components/fields/StringField.svelte b/packages/lib/src/components/fields/StringField.svelte index e6dac56..032aedf 100644 --- a/packages/lib/src/components/fields/StringField.svelte +++ b/packages/lib/src/components/fields/StringField.svelte @@ -1,5 +1,6 @@ {#if schema && components} - + {#if format == 'date-time'} {:else if format == 'date'} @@ -33,5 +30,5 @@ {:else} {/if} - + {/if} diff --git a/packages/lib/src/components/fields/extra/TextareaField.svelte b/packages/lib/src/components/fields/extra/TextareaField.svelte index 4e8d299..cbbbedb 100644 --- a/packages/lib/src/components/fields/extra/TextareaField.svelte +++ b/packages/lib/src/components/fields/extra/TextareaField.svelte @@ -1,26 +1,23 @@ {#if schema && components} - +