@solid-primitives/range
Advanced tools
Comparing version 0.1.11 to 0.1.12
import { MaybeAccessor } from '@solid-primitives/utils'; | ||
import { Accessor } from 'solid-js'; | ||
import { Accessor, JSX } from 'solid-js'; | ||
@@ -47,3 +47,3 @@ type RangeProps = { | ||
children: ((index: number) => T) | T; | ||
}): Accessor<T[]>; | ||
}): JSX.Element; | ||
@@ -92,3 +92,3 @@ /** | ||
children: ((number: number) => T) | T; | ||
}): Accessor<T[]>; | ||
}): JSX.Element; | ||
@@ -137,4 +137,4 @@ /** | ||
children: ((number: Accessor<number>) => T) | T; | ||
}): Accessor<T[]>; | ||
}): JSX.Element; | ||
export { IndexRange, Range, RangeProps, Repeat, indexRange, mapRange, repeat }; |
@@ -61,6 +61,9 @@ import { onCleanup, createMemo, untrack, DEV, createRoot, createSignal } from 'solid-js'; | ||
function Repeat(props) { | ||
const fallback = props.fallback ? () => props.fallback : void 0; | ||
const mapFn = typeof props.children === "function" ? props.children : () => props.children; | ||
const length = () => props.times; | ||
return repeat(length, mapFn, { fallback }); | ||
return createMemo( | ||
repeat( | ||
() => props.times, | ||
toFunction(() => props.children), | ||
"fallback" in props ? { fallback: () => props.fallback } : void 0 | ||
) | ||
); | ||
} | ||
@@ -163,5 +166,11 @@ function mapRange(getStart, getTo, getStep, mapFn, options = {}) { | ||
} | ||
const fallback = props.fallback ? () => props.fallback : void 0; | ||
const mapFn = toFunction(() => props.children); | ||
return mapRange(start, to, step, mapFn, { fallback }); | ||
return createMemo( | ||
mapRange( | ||
start, | ||
to, | ||
step, | ||
toFunction(() => props.children), | ||
"fallback" in props ? { fallback: () => props.fallback } : void 0 | ||
) | ||
); | ||
} | ||
@@ -240,7 +249,13 @@ function indexRange(getStart, getTo, getStep, mapFn, options = {}) { | ||
} | ||
const fallback = props.fallback ? () => props.fallback : void 0; | ||
const mapFn = toFunction(() => props.children); | ||
return indexRange(start, to, step, mapFn, { fallback }); | ||
return createMemo( | ||
indexRange( | ||
start, | ||
to, | ||
step, | ||
toFunction(() => props.children), | ||
"fallback" in props ? { fallback: () => props.fallback } : void 0 | ||
) | ||
); | ||
} | ||
export { IndexRange, Range, Repeat, indexRange, mapRange, repeat }; |
{ | ||
"name": "@solid-primitives/range", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "Control Flow Primitives for displaying given number or a number range of elements.", | ||
@@ -57,3 +57,3 @@ "author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>", | ||
"dependencies": { | ||
"@solid-primitives/utils": "^6.0.0" | ||
"@solid-primitives/utils": "^6.1.0" | ||
}, | ||
@@ -60,0 +60,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
650
32480