From 3733b5f5aeb2e11a113a682689d589da0ef23885 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 1 Feb 2021 14:46:44 +0000 Subject: [PATCH] use regex for search --- .../SetupPanel/GenericBindingPopover.svelte | 7 +++---- .../design/PropertiesPanel/BindingPanel.svelte | 13 +++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/builder/src/components/automation/SetupPanel/GenericBindingPopover.svelte b/packages/builder/src/components/automation/SetupPanel/GenericBindingPopover.svelte index 6ef86969ac..24b6042940 100644 --- a/packages/builder/src/components/automation/SetupPanel/GenericBindingPopover.svelte +++ b/packages/builder/src/components/automation/SetupPanel/GenericBindingPopover.svelte @@ -29,6 +29,7 @@ $: categories = Object.entries(groupBy("category", bindings)) $: value && checkValid() + $: searchRgx = new RegExp(search, "ig") function onClickBinding(binding) { const position = getCaretPosition() @@ -61,7 +62,7 @@ {categoryName} {#each bindings.filter(binding => - binding.label.startsWith(search) + binding.label.match(searchRgx) ) as binding}
onClickBinding(binding)}> {binding.label} @@ -75,9 +76,7 @@ {/each} Helpers - {#each helpers.filter(binding => - binding.label.startsWith(search) - ) as helper} + {#each helpers.filter(helper => helper.label.match(searchRgx) || helper.description.match(searchRgx)) as helper}
onClickBinding(helper)}> {helper.label}
diff --git a/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte b/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte index ae428ef763..47334267b6 100644 --- a/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte @@ -29,6 +29,7 @@ ) $: dispatch("update", value) $: ({ instance, context } = groupBy("type", bindableProperties)) + $: searchRgx = new RegExp(search, "ig") function checkValid() { // TODO: need to convert the value to the runtime binding @@ -69,7 +70,7 @@
    {#each context.filter(context => - context.readableBinding.startsWith(search) + context.readableBinding.match(searchRgx) ) as { readableBinding }}
  • addToText(readableBinding)}> {readableBinding} @@ -83,7 +84,7 @@
      {#each instance.filter(instance => - instance.readableBinding.startsWith(search) + instance.readableBinding.match(searchRgx) ) as { readableBinding }}
    • addToText(readableBinding)}> {readableBinding} @@ -95,13 +96,13 @@ Helpers
        - {#each helpers.filter(helper => - helper.label.startsWith(search) - ) as helper} + {#each helpers.filter(helper => helper.label.match(searchRgx) || helper.description.match(searchRgx)) as helper}
      • addToText(helper.text)}>
        -
        {@html helper.description}
        +
        + {@html helper.description} +
      • {/each}