From 244967fb0eca3a3c0027e8ee3900a353f60c1e00 Mon Sep 17 00:00:00 2001 From: Eric Mika Date: Wed, 18 Sep 2024 21:36:03 -0400 Subject: [PATCH] Prevent color-like strings from changing the Text component to a Color component . Addresses #17 . --- .eslintrc.cjs | 1 - .../tests/TestTextStringDetection.svelte | 50 +++++++++++++++++++ src/lib/control/Text.svelte | 6 ++- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/examples/tests/TestTextStringDetection.svelte diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d71cb4f..16ac921 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -101,7 +101,6 @@ module.exports = { '@typescript-eslint/no-duplicate-type-constituents': 'off', '@typescript-eslint/no-redundant-type-constituents': 'off', '@typescript-eslint/no-unnecessary-type-arguments': 'off', - '@typescript-eslint/restrict-plus-operands': 'off', 'no-return-assign': 'off', 'unicorn/no-null': 'off', diff --git a/src/examples/tests/TestTextStringDetection.svelte b/src/examples/tests/TestTextStringDetection.svelte new file mode 100644 index 0000000..0d17f6c --- /dev/null +++ b/src/examples/tests/TestTextStringDetection.svelte @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/lib/control/Text.svelte b/src/lib/control/Text.svelte index d458824..4af72ee 100644 --- a/src/lib/control/Text.svelte +++ b/src/lib/control/Text.svelte @@ -45,6 +45,10 @@ change: TextChangeEvent; }; + // Do not allow for automatic detection of hex / color strings + // See https://github.com/kitschpatrol/svelte-tweakpane-ui/issues/17 + const options = { view: 'text' }; + // Tweakpane's implementation only sends updates on blur we extend it to send continues change // updates if desired let ref: GenericInputRef; @@ -98,4 +102,4 @@ position="inline">`. [Text.svelte](https://github.com/kitschpatrol/svelte-tweakpane-ui/blob/main/src/lib/control/Text.svelte) --> - +