@thisbeyond/solid-select
Advanced tools
Changelog
[0.15.0] - 2024-07-06
A focus on improving the ergonomics of createOptions
to cover more use cases
whilst maintaining a good level of opinionated sensible defaults. Check out the
updated https://solid-select.com for examples of the new behaviour in action.
Support passing a ref
to Select
. Useful for explicitly controlling focus
on the control. Passed down to input
rather than control/container as the
input is the focusable element.
Add ability to customise filtering logic by passing a function as filterable
parameter for createOptions
.
Support custom formatting in createOptions
by passing a format
function as
a new parameter. This can be used to control the created option labels as well
as how the value is displayed when selected.
As part of this, metadata is also passed to the format
function to allow
customising aspects that were previously hardcoded (such as the "Create"
string when creatable
is used or the highlighted elements from
filterable
).
It is now possible to fully localise all text using this approach as well as mix highlighted text with other option elements (such as icons) for a richer filtering experience.
A defaultFormat
function is also exported for reuse / blending into custom
logic.
Add control over how text is extracted from an option's value in
createOptions
. Pass a custom extractText
function to handle the
extraction. It's result will be stored on the option under the text
parameter and then used for existence comparison as well as filtering
comparison.
Support returning an array of options from createable
in createOptions
for
cases where multiple options might be candidates for creation from a single
input string.
Move to custom createable
function in createOptions
the decision on when
to show a "create" option based on existing options.
As a convenience, the createable
function will be passed an exists
boolean
parameter (computed by checking the extracted text of each option against the
current input string), but it will be up to the createable
function what to
do with this. In other words, the createable
function will now always be
called on input value change, whereas previously it was only called if the
exist check passed internally. The function is also passed the current options
to be displayed if custom checks are desired.
The creatable
function can then return undefined
(or an empty list) to
prevent a "create" option being added.
To avoid this being a backwards incompatible change that could cause
unintended issues (duplicate values being created), solid-select will attempt
to detect if the createable
function passed has been updated to accept the
new exists
parameter. If it hasn't, then a warning is issued and the exist
check internally will prevent calling the function.
Pass disable
function on createOptions
the keyed value rather than full
object when a key
parameter is also supplied.
Improve out-of-the-box styling so that Select
renders nicer without
customisation. For example, background colour of select and option list now
defaults to white and children of select have sensible border and sizing
defaults.
Support extracting fuzzySort
target ("key") via function. Useful when a
consumer wants to sort on a nested key directly rather than use the extracted
text of an option.
Attempt to improve typings and make more explicit the differntiation between
different similarly named types (e.g. the Select
option and createOptions
option). Some of these typing are not also exported for direct reuse.
Modernise tooling for library build and packaging. Notably use pnpm as default
packagae manager, switch from rollup to tsup for builds, drop commonjs support
and use plain CSS rather than unnecessarily generate style.css
through the
now sunsetted windicss tool.
Fix some styling issues such as focus outlines not being properly applied and border radius being clipped by container.
Update typings to correctly represent the supported functionality of returning
elements from a custom format
function. Thanks to
LouisLuBrain for the fix.
Avoid Apple devices stealing focus through autocorrect suggestions by setting
autoCorrect
to off
on Input
component. Thanks to
MaAlkhalaf for the fix.
Changelog
[0.14.0] - 2023-04-09
A major refactor to more clearly separate out the core and the builtin
components. The builtin Select
and accompanying component interfaces remains
unchanged, but there are backwards incompatible changes to the createSelect
interface.
Breaking Change Streamline the core and allow greater control in
components. No longer pass or use element refs in the core, including not
automatically settign up event handlers. Instead, return commonly useful
handlers (such as onKeyDown
) from createSelect
for use in components.
Breaking Change Expose signals directly as accessors rather than hiding
behind property getters in return of createSelect
. For example,
select.options
should now be select.options()
. This more closely matches
SolidJS and avoids inconsistency around not being able to set properties
directly.
Breaking Change Remove helpers (such as open
and close
) in favour of
exposing setters (e.g. setIsOpen
) consistently from createSelect
. This
provides a more intuitive interface rather than some aspects having helpers
and others not.
Breaking Change Refactor Select
components to make use of a shared
Context
providing the created select. Avoid unnecessary prop drilling and
make it easier to others to compose their own selects (with useSelect
).
Breaking Change Make createAsyncOptions
throttle by default. The fetcher
will be called every 250ms by default to prevent excessive calls to resources.
The threshold can be configured or removed by passing a second argument - e.g.
createAsyncOptions(fetcher, 0)
for original behaviour.
Hide the input caret with CSS rather than hide the entire input component to make some logic easier (such as focus handling).
Changelog
[0.13.0] - 2022-09-12
Changelog
[0.12.0] - 2022-07-29
initialValue
even if initially undefined
on Select
component.onFocus
prop being ignored by Select
component. It now passes it
through to the core and is called correctly when the select is focused. Thanks
to kapilpipaliya for the fix.Changelog
[0.11.0] - 2022-05-26
Change initialValue
behaviour on the Select
component to react to signals
in a more intuitive way. Rather than pass the raw signal in, use the resolved
signal in a tracking context to gain reactivity for the initialValue
. This
is the recommended approach to passing Signals in Solid (and is also more
similar to plain values).
<Select initialValue={initialValue}/>
becomes
<Select initialValue={initialValue()}/>
Thanks to rturnq for the tip!
Changelog
[0.10.0] - 2022-05-26
Accept emptyPlaceholder
property on Select
to control the message
displayed when there are no options available. Defaults to No options
.
Thanks to @raskyer for this contribution.
The initialValue
prop of the Select
component can now be a Signal in order
to support reactively re-setting the initial value of the component. This is
useful for providing 'reset form' functionality for example.
const [initialValue, setInitialValue] = createSignal(null, { equals: false });
<Select
initialValue={initialValue}
options={["apple", "banana", "pear", "pineapple", "kiwi"]}
/>
<button onClick={() => setInitialValue(null)}>Reset</button>
Changelog
[0.9.0] - 2022-04-09
solid-select-list
.Changelog
[0.8.0] - 2022-04-02
Provide a helper, createAsyncOptions
for loading options asynchronously
based on input value. Uses Solid's createResource
under the hood.
const fetchData = async (inputValue) => { return await ... }
const props = createAsyncOptions(fetchData);
return <Select {...props} />;
Support displaying a loading indicator in the options lists - useful when
fetching options asynchronously. Pass the loading
prop to the Select
component to control whether to display the loading indicator or the list of
options. Customise the loading message with the loadingPlaceholder
prop.
Changelog
[0.7.1] - 2022-03-23
Failed to resolve import "virtual:windi.css"
) when using
'solid' export source in another SolidJS project that does not use WindiCSS.
Strip the relevant import line post build as it is not needed in the
distributed package (the styles are already compiled and available via import "@thisbeyond/solid-select/style.css";
).Changelog
[0.7.0] - 2022-03-17
Support disabling select by passing boolean value for disabled
prop (both in
createSelect
or the Select
component). When disabled no interaction is
permitted. The component is visually styled based on the data-disabled
attribute.
<Select disabled options={["one", "two", "three"]} />