From c94bbf9571c123691d3bb7b8e05f24d927c3f80e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 15 Apr 2021 11:51:18 +0100 Subject: [PATCH] Update StringField and OptionsField to use BBUI components --- .../standard-components/src/forms/Form.svelte | 5 +- .../src/forms/OptionsField.svelte | 31 +++------- .../src/forms/StringField.svelte | 58 +++---------------- packages/standard-components/src/index.js | 1 - 4 files changed, 19 insertions(+), 76 deletions(-) diff --git a/packages/standard-components/src/forms/Form.svelte b/packages/standard-components/src/forms/Form.svelte index 5e810d5086..1052abcbe5 100644 --- a/packages/standard-components/src/forms/Form.svelte +++ b/packages/standard-components/src/forms/Form.svelte @@ -98,13 +98,11 @@ const newValue = value == null ? defaultValue : value const newError = validate ? validate(newValue) : null - const newValid = !newError // Update field state fieldState.update(state => { state.value = newValue state.error = newError - state.valid = newValid return state }) @@ -120,7 +118,7 @@ return state }) - return newValid + return !newError } return { setValue, @@ -138,7 +136,6 @@ fieldId: `id-${generateID()}`, value: initialValues[field] ?? defaultValue, error: null, - valid: true, disabled: fieldDisabled, }) } diff --git a/packages/standard-components/src/forms/OptionsField.svelte b/packages/standard-components/src/forms/OptionsField.svelte index 82f213686b..6117f6f35a 100644 --- a/packages/standard-components/src/forms/OptionsField.svelte +++ b/packages/standard-components/src/forms/OptionsField.svelte @@ -1,6 +1,6 @@ {#if fieldState} - option === $fieldState.value} - onSelectOption={selectOption} /> + - + fieldApi.setValue(e.detail)} + disabled={$fieldState.disabled} + error={$fieldState.error} + id={$fieldState.fieldId} + {placeholder} + {type} /> {/if} - - diff --git a/packages/standard-components/src/index.js b/packages/standard-components/src/index.js index edc54a1114..c7c536f2ca 100644 --- a/packages/standard-components/src/index.js +++ b/packages/standard-components/src/index.js @@ -1,4 +1,3 @@ -import "@budibase/bbui/dist/style.css" import "@spectrum-css/vars/dist/spectrum-global.css" import "@spectrum-css/vars/dist/spectrum-medium.css" import "@spectrum-css/vars/dist/spectrum-large.css"