-
Notifications
You must be signed in to change notification settings - Fork 151
upgrade: range package upgrade for Solid 2.0 #912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
davedbase
wants to merge
4
commits into
solidjs-community:next
Choose a base branch
from
davedbase:update/v2/range
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| "@solid-primitives/range": major | ||
| --- | ||
|
|
||
| Migrate to Solid.js v2.0 (beta.13) | ||
|
|
||
| ## Breaking Changes | ||
|
|
||
| **Peer dependencies**: `solid-js@^2.0.0-beta.13` and `@solidjs/web@^2.0.0-beta.13` are now required. | ||
|
|
||
| - `isServer` is now imported from `@solidjs/web` (was `solid-js/web`) | ||
| - `JSX` types are now imported from `@solidjs/web` (was `solid-js`) | ||
| - `indexRange` internal signals now use `ownedWrite: true` so they can be updated from inside reactive scopes (e.g. when `IndexRange` wraps in `createMemo`) | ||
| - `createEffect` usage in user code must use the split compute/apply form required by Solid 2.0 — see updated README examples | ||
| - Signal writes are now batched by default; call `flush()` after writing signals before reading the resulting mapped array | ||
| - `<Repeat>` is **deprecated** — Solid 2.0 ships an equivalent built-in `<Repeat count={n}>` in `@solidjs/web`. See the README for migration guidance. The `repeat` primitive continues to be supported for cases that require incremental child creation/disposal. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type { Accessor } from "solid-js"; | ||
| import type { MaybeAccessor } from "@solid-primitives/utils"; | ||
| import { access } from "@solid-primitives/utils"; | ||
| import { mapRange } from "./mapRange.js"; | ||
|
|
||
| /** | ||
| * Reactively generates an array of numbers for the given range. | ||
| * | ||
| * When called with one argument, generates `[0, 1, ..., to - 1]`. | ||
| * When called with two or three arguments, generates `[start, start + step, ..., to - 1]`. | ||
| * | ||
| * Step direction is inferred from the relationship between `start` and `to` — a negative | ||
| * `to` relative to `start` produces a descending range regardless of the sign of `step`. | ||
| * | ||
| * @param startOrTo start of the range, or — when `to` is omitted — the end (start defaults to 0) | ||
| * @param to end of the range (not included) | ||
| * @param step difference between consecutive values (defaults to 1) | ||
| * @returns accessor returning the current number array | ||
| * @see https://github.com/solidjs-community/solid-primitives/tree/main/packages/range#createnumericrange | ||
| * @example | ||
| * ```ts | ||
| * const nums = createNumericRange(5); // [0, 1, 2, 3, 4] | ||
| * const nums = createNumericRange(2, 7); // [2, 3, 4, 5, 6] | ||
| * const nums = createNumericRange(0, 10, 2); // [0, 2, 4, 6, 8] | ||
| * | ||
| * // reactive | ||
| * const [to, setTo] = createSignal(5); | ||
| * const nums = createNumericRange(to); // updates when `to` changes | ||
| * | ||
| * // use with <For> | ||
| * const nums = createNumericRange(count); | ||
| * <For each={nums()}>{n => <div>{n}</div>}</For> | ||
| * ``` | ||
| */ | ||
| export function createNumericRange( | ||
| startOrTo: MaybeAccessor<number>, | ||
| to?: MaybeAccessor<number>, | ||
| step: MaybeAccessor<number> = 1, | ||
| ): Accessor<number[]> { | ||
| const getStart = to !== undefined ? () => access(startOrTo) : () => 0; | ||
| const getTo = to !== undefined ? () => access(to) : () => access(startOrTo); | ||
| const getStep = () => access(step); | ||
| return mapRange(getStart, getTo, getStep, n => n); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.