diff --git a/.changeset/pre.json b/.changeset/pre.json index 20feecfdd..1a57b3b37 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -101,7 +101,8 @@ "@solid-primitives/video": "0.0.100", "@solid-primitives/async": "0.0.100", "@solid-primitives/url": "0.1.0", - "@solid-primitives/favicon": "0.0.100" + "@solid-primitives/favicon": "0.0.100", + "@solid-primitives/sortable": "0.0.100" }, "changesets": [ "a11y-dataset-hydration-safety", @@ -208,6 +209,7 @@ "signal-builders-solid2-migration", "signal-builders-toggle", "solid-2-beta-20-upgrade", + "sortable-initial", "spring-solid2-migration", "sse-solid2-async-reactivity", "state-machine-solid2-migration", diff --git a/packages/sortable/CHANGELOG.md b/packages/sortable/CHANGELOG.md new file mode 100644 index 000000000..3162f4a96 --- /dev/null +++ b/packages/sortable/CHANGELOG.md @@ -0,0 +1,43 @@ +# @solid-primitives/sortable + +## 1.0.0-next.0 + +### Major Changes + +- a402fce: Initial release of `@solid-primitives/sortable` + + Reactive sorting primitives, combining ideas from VueUse's `useSorted` and d3-array's comparator + utilities, built directly on Solid 2.0's `mapArray` and `createProjection` rather than a bespoke + diffing engine. + + ### `ascending` / `descending` / `by` / `combine` / `reverse` + + Comparator building blocks. `ascending`/`descending` always sort `null`/`undefined`/`NaN` to the + end, regardless of direction — unlike a naive `a < b ? -1 : a > b ? 1 : 0`, which silently treats + them as equal to everything. `by` derives a comparator from a key accessor; `combine` composes + comparators for multi-key tie-breaking; `reverse` flips any comparator. + + ### `makeSorted` / `createSorted` + + Non-reactive and reactive sort. `createSorted`'s default path (a static comparator, non-`dirty`) + delegates directly to `@solid-primitives/signal-builders`'s existing `sort()`. It adds a reactive + comparator (an accessor, so toggling sort direction/column doesn't rebuild the primitive) and a + `dirty: true` option that sorts the source array in place and reuses its reference — mirroring + VueUse's `useSorted`'s `dirty` option under Solid's signal model. + + ### `sortedIndex` / `sortedIndexBy` / `insertSorted` + + Binary search over an already-sorted array, and an O(log n) immutable insert — versus an + O(n log n) full re-sort for a single insertion. + + ### `createSortedIndex` + + Per-item reactive rank tracking: an item's index accessor only updates when _that item's_ position + actually changes, never for unrelated moves elsewhere in the list. Built on `mapArray` — the same + core primitive that powers `` — rather than a hand-rolled diffing engine. + + ### `createSortedProjection` + + A store-shaped sorted view, reconciled by key via `createProjection`, so unrelated rows don't + notify when one row's data changes. Pairs naturally with `` for + move-not-recreate DOM behavior with no bespoke tracking code. diff --git a/packages/sortable/deno.jsonc b/packages/sortable/deno.jsonc index 93e87fe6e..29e46d582 100644 --- a/packages/sortable/deno.jsonc +++ b/packages/sortable/deno.jsonc @@ -1,6 +1,6 @@ { "name": "@solid-primitives/sortable", - "version": "0.0.100", + "version": "1.0.0-next.0", "description": "Reactive sorting primitives — comparators, reactive sort, sorted search/insert, and granular per-item rank tracking.", "license": "MIT", "exports": "./src/index.ts", diff --git a/packages/sortable/package.json b/packages/sortable/package.json index 776c722d1..8f4997f95 100644 --- a/packages/sortable/package.json +++ b/packages/sortable/package.json @@ -1,6 +1,6 @@ { "name": "@solid-primitives/sortable", - "version": "0.0.100", + "version": "1.0.0-next.0", "description": "Reactive sorting primitives — comparators, reactive sort, sorted search/insert, and granular per-item rank tracking.", "author": "David Di Biase ", "contributors": [],