svelte-ux
svelte-ux copied to clipboard
Add queryParamsStore
- [x] Support simple types (numbers, strings, booleans)
- [x] Support objects
- [x] Support arrays
- Return array even if single item
- Arrays of simple types
- Arrays of objects
- [x] Handle datatype changing when only a single vs multiple selected (ex. select with a single vs multiple values)
- [ ] Provide better errors when config not found (at least include param name)
- [ ] Support updating single param with
queryParamsStore- Either support property and only update those with keys passed (require null / undefined to remove) or expose function from store to set
- [ ] Support specifying
pushState(browser back) vsreplaceState - [ ] Attempt to guess paramType based on default value and/or current params set?
- Might be confusing when breaks in certain conditions
- [ ] Consider supporting
Numberand[Number]along with'number'and'number[]'(etc)?- Support both formats?
- What about
json(JSON),object(Object)? - What about
datevsdatetime?- Maybe
Dateis bound todatetimeanddateis handled by passing in an implementation object with encode/decode (see below)
- Maybe
- Support a custom format in the future (UTC date vs local date, etc)
- Maybe passing in an implementation object with encode/decode (see below)
- [ ] Consider supporting explicit object with
{encode: ..., decode: ....}? - [ ] Differentiate between null and undefined
- Should only undefined delete the value (null is persisted)? Example: active/inactive/all toggles
Useful links
- https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
- Svelte
- https://stackoverflow.com/questions/57181704/svelte-components-store-load-state-into-from-url-hash-parameters
- React
- https://github.com/pbeshai/use-query-params
- https://github.com/pbeshai/serialize-query-params
- https://github.com/rudyhuynh/use-url-search-params
- Using React Hooks to sync your component state and the URL Query string
- The Easiest Way to Use Query Parameters in React
- https://github.com/pbeshai/use-query-params
- Libraries
- https://github.com/sindresorhus/query-string (6.3k)
- https://github.com/ljharb/qs (10.2k - 27.9k)
- https://github.com/lukeed/qss (757b)