From e060db2929e576aff007ba09d6812cde2f045f4d Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 6 Oct 2022 09:54:43 +0100 Subject: [PATCH] UX/UI updates and rollup config changes to exclude common warnings --- packages/client/manifest.json | 27 ++- packages/client/rollup.config.js | 9 + .../src/components/app/CodeScanner.svelte | 226 +++++++++++++----- .../app/forms/CodeScannerField.svelte | 34 +-- 4 files changed, 202 insertions(+), 94 deletions(-) diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 5ccb31409d..acb05d58bc 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -3168,24 +3168,39 @@ "section" ], "settings": [ - { - "type": "text", - "label": "Label", - "key": "label", - "defaultValue": true - }, { "type": "field/code", "label": "Field", "key": "field", "required": true }, + { + "type": "text", + "label": "Label", + "key": "label" + }, + { + "type": "text", + "label": "Button", + "key": "scanButtonText" + }, + { + "type": "text", + "label": "Default value", + "key": "defaultValue" + }, { "type": "boolean", "label": "Disabled", "key": "disabled", "defaultValue": false }, + { + "type": "boolean", + "label": "Allow manual entry", + "key": "allowManualEntry", + "defaultValue": false + }, { "type": "validation/string", "label": "Validation", diff --git a/packages/client/rollup.config.js b/packages/client/rollup.config.js index 5206b63884..be94ace90c 100644 --- a/packages/client/rollup.config.js +++ b/packages/client/rollup.config.js @@ -27,6 +27,15 @@ export default { file: `./dist/budibase-client.js`, }, ], + onwarn(warning, warn) { + if ( + warning.code === "THIS_IS_UNDEFINED" || + warning.code === "CIRCULAR_DEPENDENCY" + ) { + return + } + warn(warning) + }, plugins: [ alias({ entries: [ diff --git a/packages/client/src/components/app/CodeScanner.svelte b/packages/client/src/components/app/CodeScanner.svelte index 7203b30aef..3215875faa 100644 --- a/packages/client/src/components/app/CodeScanner.svelte +++ b/packages/client/src/components/app/CodeScanner.svelte @@ -1,123 +1,189 @@
- {#if code} -
+ {#if value && !manualMode} +
- {code} + {value}
{/if} - + + {#if allowManualEntry && manualMode} +
+ { + dispatch("change", value) + }} + /> +
+ {/if} + + {#if value} + { + dispatch("change", "") + }} + {disabled} + > + Clear + + {:else} + { + showReaderModal() + }} + {disabled} + > + {scanButtonText} + + {/if}
diff --git a/packages/client/src/components/app/forms/CodeScannerField.svelte b/packages/client/src/components/app/forms/CodeScannerField.svelte index 034e6eacce..e2da89d1b5 100644 --- a/packages/client/src/components/app/forms/CodeScannerField.svelte +++ b/packages/client/src/components/app/forms/CodeScannerField.svelte @@ -9,34 +9,18 @@ export let validation export let defaultValue = "" export let onChange + export let allowManualEntry + export let scanButtonText let fieldState let fieldApi - let scannedCode - let loaded = false - - const handleInput = () => { - const changed = fieldApi.setValue(scannedCode) + const handleUpdate = e => { + const changed = fieldApi.setValue(e.detail) if (onChange && changed) { - onChange({ value: scannedCode }) + onChange({ value: e.detail }) } } - - $: if (!loaded && !scannedCode && fieldState?.value) { - scannedCode = fieldState.value + "" - loaded = true - } - - /* - QR Nimiq has rollup issues? - QR qrcodejs 12b bundle? - https://github.com/davidshimjs/qrcodejs - BOTH html5-qrcode has a 330k bundle - https://github.com/mebjas/html5-qrcode - BOTH zxing 360k bundle size - https://github.com/zxing-js/library - */ {#if fieldState} - + {/if}