preline icon indicating copy to clipboard operation
preline copied to clipboard

ComboBox - New methods + bullet proofing

Open mohsinhijazee opened this issue 1 year ago • 0 comments

This PR proposes few additions to the ComboBox.

I have tested this with SvelteKit and wrapped the Combox as a Svelte Component with full events and multiple instances of the component on the same page fetching data from difference sources so many copies/instances work seemlessly.

Few fixes/improvements:

  • Constructor does not rely on window.$hsComboBoxCollection being initialised. Thus users for bundlers (vite etc) don't have to load all of preline.js.
  • Fixed an error about invalid nullish statement
  • Fetching and rendering items is now bit more bullet proof, ensures that the returned response is iterable.

Additions to the CombBox:

  • apiSearchQueryTransformer to allow transforming query before fetch. This is required in case some APIs use more advanced filtering DSL such as Google's AIP-160 for example filter=prefix('name', 'sh') OR contains('lastName', 'sh') etc.
  • selectedItem() returns elemnent that was selected
  • selectedValue() returns the value.
  • selectedAttr(attr) returns the custom attribute.

Few other changes to the package.json (required dependencies added, deprecated type definitions replaced with updated packages), few scripts/watch/commands and generation scripts added.

Don't have full context on design choices so some things might seem absurd and I am here to revise as per your feedback FYI @jahaganiev and @olegpix

mohsinhijazee avatar Oct 10 '24 17:10 mohsinhijazee