From ce1fe5e600bf078981282f97321adbd258cd9575 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 5 Jul 2022 09:21:20 +0100 Subject: [PATCH] add ability to select groups from dropdown --- .../bbui/src/Form/Core/PickerDropdown.svelte | 406 ++++++++++++++++++ packages/bbui/src/Form/PickerDropdown.svelte | 129 ++++++ 2 files changed, 535 insertions(+) create mode 100644 packages/bbui/src/Form/Core/PickerDropdown.svelte create mode 100644 packages/bbui/src/Form/PickerDropdown.svelte diff --git a/packages/bbui/src/Form/Core/PickerDropdown.svelte b/packages/bbui/src/Form/Core/PickerDropdown.svelte new file mode 100644 index 0000000000..9620636742 --- /dev/null +++ b/packages/bbui/src/Form/Core/PickerDropdown.svelte @@ -0,0 +1,406 @@ + + +
+
+ {#if iconData} + + + + {/if} + (primaryOpen = true)} + on:blur + on:focus + on:input + on:keyup + on:blur={onBlur} + on:input={onInput} + on:keyup={updateValueOnEnter} + value={primaryLabel || ""} + placeholder={placeholder || ""} + {disabled} + {readonly} + class="spectrum-Textfield-input spectrum-InputGroup-input" + class:labelPadding={iconData} + /> +
+ {#if primaryOpen} +
(primaryOpen = false)} + transition:fly|local={{ y: -20, duration: 200 }} + class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" + class:auto-width={autoWidth} + style="width: 70%" + > +
    + {#if placeholderOption} +
  • onSelectOption(null)} + > + {placeholderOption} + +
  • + {/if} + {#each groupTitles as title} +
    + {title} +
    + {#if primaryOptions} + {#each primaryOptions[title].data as option, idx} +
  • + onPickPrimary({ + value: primaryOptions[title].getValue(option), + label: primaryOptions[title].getLabel(option), + })} + > + {#if primaryOptions[title].getIcon(option)} +
    +
    + +
    +
    + {:else if getPrimaryOptionColour(option, idx)} + + + + {/if} + + + {primaryOptions[title].getLabel(option)} + + + + {#if getPrimaryOptionIcon(option, idx) && getPrimaryOptionColour(option, idx)} + + + + {/if} + +
  • + {/each} + {/if} + {/each} +
+
+ {/if} +
+ + {#if secondaryOpen} +
(secondaryOpen = false)} + transition:fly|local={{ y: -20, duration: 200 }} + class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" + style="width: 30%" + > +
    + {#each secondaryOptions as option, idx} +
  • + onPickSecondary(getSecondaryOptionValue(option, idx))} + > + {#if getSecondaryOptionColour(option, idx)} + + + + {/if} + + + {getSecondaryOptionLabel(option, idx)} + + +
  • + {/each} +
+
+ {/if} +
+
+ + diff --git a/packages/bbui/src/Form/PickerDropdown.svelte b/packages/bbui/src/Form/PickerDropdown.svelte new file mode 100644 index 0000000000..de284dd379 --- /dev/null +++ b/packages/bbui/src/Form/PickerDropdown.svelte @@ -0,0 +1,129 @@ + + + + +