solid-ctrl-flow 1.0.36 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -5
- package/dist/index.mjs +8 -6
- package/dist/index.umd.js +8 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Accessor } from 'solid-js';
|
|
|
2
2
|
import { Context } from 'solid-js';
|
|
3
3
|
import { EffectFunction } from 'solid-js';
|
|
4
4
|
import { JSX } from 'solid-js';
|
|
5
|
+
import { MemoOptions } from 'solid-js';
|
|
5
6
|
import { Ref } from 'solid-js';
|
|
6
7
|
import { Resource } from 'solid-js';
|
|
7
8
|
import { Setter } from 'solid-js';
|
|
@@ -132,6 +133,9 @@ export declare function createReactiveResource<R>(f: EffectFunction<R | undefine
|
|
|
132
133
|
/** Built-in {@link ReactiveContext} which allows you to display different things in debug mode */
|
|
133
134
|
export declare const debug: ReactiveContext<boolean>;
|
|
134
135
|
|
|
136
|
+
/** Handy type alias */
|
|
137
|
+
declare type Equals = MemoOptions<unknown>["equals"];
|
|
138
|
+
|
|
135
139
|
/** Informations about a {@link Source} component */
|
|
136
140
|
declare type Info = {
|
|
137
141
|
/** Order of the current source if there are many */
|
|
@@ -140,12 +144,16 @@ declare type Info = {
|
|
|
140
144
|
};
|
|
141
145
|
|
|
142
146
|
/**
|
|
143
|
-
* Memoizes some of the properties of {@link obj}
|
|
144
|
-
* If {@link keys} is not provided, memoizes everything that get returned by {@link Object.keys} when provided with {@link obj}
|
|
147
|
+
* Memoizes some of the properties of {@link obj}.
|
|
148
|
+
* If {@link keys} is not provided, memoizes everything that get returned by {@link Object.keys} when provided with {@link obj}.
|
|
149
|
+
* The {@link equals} parameter defaults to `false` to allow the specific reactive value to have control over when its dependant effects are triggered
|
|
145
150
|
* @param obj Object to partially memoize
|
|
146
151
|
* @param keys The keys of the properties to memoize
|
|
152
|
+
* @param equals The comparator function to use on the newly created memos
|
|
147
153
|
*/
|
|
148
|
-
export declare function memoProps<T
|
|
154
|
+
export declare function memoProps<T>(obj: T, keys?: undefined, equals?: Equals): T;
|
|
155
|
+
|
|
156
|
+
export declare function memoProps<T, K extends readonly (keyof T)[]>(obj: T, keys: K, equals?: Equals): Pick<T, K[number]>;
|
|
149
157
|
|
|
150
158
|
/**
|
|
151
159
|
* Like a {@link For}, but instead of putting an element after another it nests them.
|
|
@@ -229,11 +237,12 @@ export declare function runWithContext<T, V extends T, R>(ctx: Context<T>, value
|
|
|
229
237
|
export declare function runWithContext<T, R>(ctx: Context<T>, value: T | undefined, f: (x: T) => R): R;
|
|
230
238
|
|
|
231
239
|
/**
|
|
232
|
-
* Executes {@link splitProps} and memoizes the first of the two returned objects
|
|
240
|
+
* Executes {@link splitProps} and memoizes the first of the two returned objects using {@link memoProps}
|
|
233
241
|
* @param obj Object to split and partially memoize
|
|
234
242
|
* @param keys The keys of the properties to memoize and to include in the first of the two objects
|
|
243
|
+
* @param equals The comparator function to use on the newly created memos
|
|
235
244
|
*/
|
|
236
|
-
export declare function splitAndMemoProps<T extends
|
|
245
|
+
export declare function splitAndMemoProps<T extends Record<any, any>, K extends readonly (keyof T)[]>(obj: T, keys: K, equals?: Equals): [Pick<T, Extract<K, readonly (keyof T)[]>[number]>, Omit<T, K[number]>];
|
|
237
246
|
|
|
238
247
|
/**
|
|
239
248
|
* Creates a full-fledged solid {@link Setter} from a normal one
|
package/dist/index.mjs
CHANGED
|
@@ -105,7 +105,7 @@ function Dest() {
|
|
|
105
105
|
function Source(props) {
|
|
106
106
|
const obj = useContext(this);
|
|
107
107
|
if (!obj)
|
|
108
|
-
return props.children;
|
|
108
|
+
return createMemo(() => props.children);
|
|
109
109
|
const order = createMemo(() => props.order || 0);
|
|
110
110
|
const info = {
|
|
111
111
|
get order() {
|
|
@@ -116,7 +116,7 @@ function Source(props) {
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
obj.source.push(info);
|
|
119
|
-
onCleanup(() => obj.source.splice(obj.source.indexOf(info), 1));
|
|
119
|
+
onCleanup(() => obj.source.splice(obj.source.indexOf(createMutable(info)), 1));
|
|
120
120
|
return createComponent(Show, {
|
|
121
121
|
get when() {
|
|
122
122
|
return !obj.attached;
|
|
@@ -191,18 +191,20 @@ function refCall(ref, value) {
|
|
|
191
191
|
ref(value);
|
|
192
192
|
return value;
|
|
193
193
|
}
|
|
194
|
-
function memoProps(obj, keys = Object.keys(obj)) {
|
|
194
|
+
function memoProps(obj, keys = Object.keys(obj), equals = false) {
|
|
195
195
|
const out = {};
|
|
196
196
|
for (const elm of keys)
|
|
197
197
|
Object.defineProperty(out, elm, {
|
|
198
198
|
enumerable: true,
|
|
199
|
-
get: createMemo(() => obj[elm]
|
|
199
|
+
get: createMemo(() => obj[elm], void 0, {
|
|
200
|
+
equals
|
|
201
|
+
})
|
|
200
202
|
});
|
|
201
203
|
return out;
|
|
202
204
|
}
|
|
203
|
-
function splitAndMemoProps(obj, keys) {
|
|
205
|
+
function splitAndMemoProps(obj, keys, equals) {
|
|
204
206
|
const out = splitProps(obj, keys);
|
|
205
|
-
out[0] = memoProps(out[0], keys);
|
|
207
|
+
out[0] = memoProps(out[0], keys, equals);
|
|
206
208
|
return out;
|
|
207
209
|
}
|
|
208
210
|
function runWithContext(ctx2, value, f) {
|
package/dist/index.umd.js
CHANGED
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
function Source(props) {
|
|
108
108
|
const obj = solidJs.useContext(this);
|
|
109
109
|
if (!obj)
|
|
110
|
-
return props.children;
|
|
110
|
+
return solidJs.createMemo(() => props.children);
|
|
111
111
|
const order = solidJs.createMemo(() => props.order || 0);
|
|
112
112
|
const info = {
|
|
113
113
|
get order() {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
120
|
obj.source.push(info);
|
|
121
|
-
solidJs.onCleanup(() => obj.source.splice(obj.source.indexOf(info), 1));
|
|
121
|
+
solidJs.onCleanup(() => obj.source.splice(obj.source.indexOf(store.createMutable(info)), 1));
|
|
122
122
|
return solidJs.createComponent(solidJs.Show, {
|
|
123
123
|
get when() {
|
|
124
124
|
return !obj.attached;
|
|
@@ -193,18 +193,20 @@
|
|
|
193
193
|
ref(value);
|
|
194
194
|
return value;
|
|
195
195
|
}
|
|
196
|
-
function memoProps(obj, keys = Object.keys(obj)) {
|
|
196
|
+
function memoProps(obj, keys = Object.keys(obj), equals = false) {
|
|
197
197
|
const out = {};
|
|
198
198
|
for (const elm of keys)
|
|
199
199
|
Object.defineProperty(out, elm, {
|
|
200
200
|
enumerable: true,
|
|
201
|
-
get: solidJs.createMemo(() => obj[elm]
|
|
201
|
+
get: solidJs.createMemo(() => obj[elm], void 0, {
|
|
202
|
+
equals
|
|
203
|
+
})
|
|
202
204
|
});
|
|
203
205
|
return out;
|
|
204
206
|
}
|
|
205
|
-
function splitAndMemoProps(obj, keys) {
|
|
207
|
+
function splitAndMemoProps(obj, keys, equals) {
|
|
206
208
|
const out = solidJs.splitProps(obj, keys);
|
|
207
|
-
out[0] = memoProps(out[0], keys);
|
|
209
|
+
out[0] = memoProps(out[0], keys, equals);
|
|
208
210
|
return out;
|
|
209
211
|
}
|
|
210
212
|
function runWithContext(ctx2, value, f) {
|