solid-ctrl-flow 7.0.2 → 7.0.3
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 +0 -13
- package/dist/index.mjs +26 -61
- package/dist/index.umd.js +24 -59
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Accessor } from 'solid-js';
|
|
2
|
-
import { ComponentProps } from 'solid-js';
|
|
3
2
|
import { Context } from 'solid-js';
|
|
4
3
|
import { JSX } from 'solid-js';
|
|
5
4
|
import { MemoOptions } from 'solid-js';
|
|
@@ -21,9 +20,6 @@ export declare function Case(props: ParentProps<{
|
|
|
21
20
|
*/
|
|
22
21
|
export declare function disposeWithOwner<T>(outer: Owner, f: Accessor<T>): T;
|
|
23
22
|
|
|
24
|
-
/** Handy type alias */
|
|
25
|
-
declare type div = ComponentProps<"div">;
|
|
26
|
-
|
|
27
23
|
/**
|
|
28
24
|
* Eventually wraps its content into a template if a certain condition is met.
|
|
29
25
|
* If you set {@link Standard.recycled} to `true`, the content will be memoized in the beginning and will be recycled even if the wrapper changes.
|
|
@@ -173,15 +169,6 @@ export declare namespace OrderedLinkedList {
|
|
|
173
169
|
}
|
|
174
170
|
}
|
|
175
171
|
|
|
176
|
-
/**
|
|
177
|
-
* Simple {@link HTMLDivElement} that accepts another set of attributes to merge with the base ones.
|
|
178
|
-
* Specifically, {@link div.ref}, {@link div.class}, {@link div.classList}, and {@link div.style} are combined rather than overwritten by the second set of attributes.
|
|
179
|
-
* Used for customizable structural parts of components
|
|
180
|
-
*/
|
|
181
|
-
export declare function Part(props: {
|
|
182
|
-
props: div | undefined;
|
|
183
|
-
} & div): JSX;
|
|
184
|
-
|
|
185
172
|
/**
|
|
186
173
|
* Executes {@link f} with the provided value for the specified {@link Context}.
|
|
187
174
|
* You can pass `undefined` to {@link value} in order to get back the default value for {@link ctx}.
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { untrack, getOwner, createRoot, runWithOwner, onCleanup, createMemo, Show, createContext, useContext, For, createRenderEffect, on, splitProps, createSignal, batch,
|
|
2
|
-
import { createComponent, memo, mergeProps,
|
|
1
|
+
import { untrack, getOwner, createRoot, runWithOwner, onCleanup, createMemo, Show, createContext, useContext, For, createRenderEffect, on, splitProps, createSignal, batch, createSelector, equalFn, Match } from "solid-js";
|
|
2
|
+
import { createComponent, memo, mergeProps, spread } from "solid-js/web";
|
|
3
3
|
function untrackCall(f, ...args) {
|
|
4
4
|
return untrack(() => f.apply(this, args));
|
|
5
5
|
}
|
|
@@ -226,6 +226,30 @@ function SameContextSource(props) {
|
|
|
226
226
|
}
|
|
227
227
|
}));
|
|
228
228
|
}
|
|
229
|
+
const ctx = createContext(void 0, {
|
|
230
|
+
name: "on-case"
|
|
231
|
+
});
|
|
232
|
+
function On(props) {
|
|
233
|
+
const memo2 = memoProps(props);
|
|
234
|
+
const selector = createSelector(() => memo2.value, (a, b) => (memo2.onCompare ?? equalFn)(a, b));
|
|
235
|
+
return createComponent(ctx.Provider, {
|
|
236
|
+
value: selector,
|
|
237
|
+
get children() {
|
|
238
|
+
return props.children;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
function Case(props) {
|
|
243
|
+
const selector = useContext(ctx);
|
|
244
|
+
return createComponent(Match, {
|
|
245
|
+
get when() {
|
|
246
|
+
return selector(props.value);
|
|
247
|
+
},
|
|
248
|
+
get children() {
|
|
249
|
+
return props.children;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
229
253
|
const memoProps = (obj, equals) => new Proxy(obj, new MemoPropsHandler(getOwner(), equals));
|
|
230
254
|
const splitAndMemoProps = (obj, ...keys) => splitAndMemoSomeProps(obj, keys.length, ...keys);
|
|
231
255
|
function splitAndMemoSomeProps(obj, n, ...keys) {
|
|
@@ -261,64 +285,6 @@ class MemoPropsHandler {
|
|
|
261
285
|
return runWithOwner(this.owner, () => createMemo(() => t[k], void 0, opts));
|
|
262
286
|
}
|
|
263
287
|
}
|
|
264
|
-
var _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
265
|
-
function Part(props) {
|
|
266
|
-
const [mine, first, second, other, user] = processProps(props);
|
|
267
|
-
return (() => {
|
|
268
|
-
var _el$ = _tmpl$();
|
|
269
|
-
use((x) => createComponent(Spread, {
|
|
270
|
-
target: x,
|
|
271
|
-
ref(r$) {
|
|
272
|
-
var _ref$ = mine.ref;
|
|
273
|
-
typeof _ref$ === "function" ? _ref$(r$) : mine.ref = r$;
|
|
274
|
-
},
|
|
275
|
-
get style() {
|
|
276
|
-
return mine.style;
|
|
277
|
-
}
|
|
278
|
-
}), _el$);
|
|
279
|
-
spread(_el$, mergeProps(other, user, {
|
|
280
|
-
get classList() {
|
|
281
|
-
return {
|
|
282
|
-
[first.class ?? ""]: true,
|
|
283
|
-
[second.class ?? ""]: true,
|
|
284
|
-
// A key containing only spaces breaks, so the optional classes are kept as separate properties
|
|
285
|
-
...first.classList,
|
|
286
|
-
...second.classList
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
}), false, false);
|
|
290
|
-
return _el$;
|
|
291
|
-
})();
|
|
292
|
-
}
|
|
293
|
-
function processProps(props) {
|
|
294
|
-
const [mine, temp, other] = splitProps(props, ["ref", "style", "props"], ["class", "classList"]), first = memoProps(temp);
|
|
295
|
-
const [second, user] = splitAndMemoProps(mergeProps$1(() => mine.props), ["class", "classList"]);
|
|
296
|
-
return [mine, first, second, other, user];
|
|
297
|
-
}
|
|
298
|
-
const ctx = createContext(void 0, {
|
|
299
|
-
name: "on-case"
|
|
300
|
-
});
|
|
301
|
-
function On(props) {
|
|
302
|
-
const memo2 = memoProps(props);
|
|
303
|
-
const selector = createSelector(() => memo2.value, (a, b) => (memo2.onCompare ?? equalFn)(a, b));
|
|
304
|
-
return createComponent(ctx.Provider, {
|
|
305
|
-
value: selector,
|
|
306
|
-
get children() {
|
|
307
|
-
return props.children;
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
function Case(props) {
|
|
312
|
-
const selector = useContext(ctx);
|
|
313
|
-
return createComponent(Match, {
|
|
314
|
-
get when() {
|
|
315
|
-
return selector(props.value);
|
|
316
|
-
},
|
|
317
|
-
get children() {
|
|
318
|
-
return props.children;
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
288
|
class TransitionMonitor {
|
|
323
289
|
#signal = createSignal(false);
|
|
324
290
|
/** Whether a transition is currently in progress */
|
|
@@ -362,7 +328,6 @@ export {
|
|
|
362
328
|
Extractor,
|
|
363
329
|
On,
|
|
364
330
|
OrderedLinkedList,
|
|
365
|
-
Part,
|
|
366
331
|
SameContext,
|
|
367
332
|
Spread,
|
|
368
333
|
TransitionMonitor,
|
package/dist/index.umd.js
CHANGED
|
@@ -228,6 +228,30 @@
|
|
|
228
228
|
}
|
|
229
229
|
}));
|
|
230
230
|
}
|
|
231
|
+
const ctx = solidJs.createContext(void 0, {
|
|
232
|
+
name: "on-case"
|
|
233
|
+
});
|
|
234
|
+
function On(props) {
|
|
235
|
+
const memo = memoProps(props);
|
|
236
|
+
const selector = solidJs.createSelector(() => memo.value, (a, b) => (memo.onCompare ?? solidJs.equalFn)(a, b));
|
|
237
|
+
return web.createComponent(ctx.Provider, {
|
|
238
|
+
value: selector,
|
|
239
|
+
get children() {
|
|
240
|
+
return props.children;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function Case(props) {
|
|
245
|
+
const selector = solidJs.useContext(ctx);
|
|
246
|
+
return web.createComponent(solidJs.Match, {
|
|
247
|
+
get when() {
|
|
248
|
+
return selector(props.value);
|
|
249
|
+
},
|
|
250
|
+
get children() {
|
|
251
|
+
return props.children;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
231
255
|
const memoProps = (obj, equals) => new Proxy(obj, new MemoPropsHandler(solidJs.getOwner(), equals));
|
|
232
256
|
const splitAndMemoProps = (obj, ...keys) => splitAndMemoSomeProps(obj, keys.length, ...keys);
|
|
233
257
|
function splitAndMemoSomeProps(obj, n, ...keys) {
|
|
@@ -263,64 +287,6 @@
|
|
|
263
287
|
return solidJs.runWithOwner(this.owner, () => solidJs.createMemo(() => t[k], void 0, opts));
|
|
264
288
|
}
|
|
265
289
|
}
|
|
266
|
-
var _tmpl$ = /* @__PURE__ */ web.template(`<div>`);
|
|
267
|
-
function Part(props) {
|
|
268
|
-
const [mine, first, second, other, user] = processProps(props);
|
|
269
|
-
return (() => {
|
|
270
|
-
var _el$ = _tmpl$();
|
|
271
|
-
web.use((x) => web.createComponent(Spread, {
|
|
272
|
-
target: x,
|
|
273
|
-
ref(r$) {
|
|
274
|
-
var _ref$ = mine.ref;
|
|
275
|
-
typeof _ref$ === "function" ? _ref$(r$) : mine.ref = r$;
|
|
276
|
-
},
|
|
277
|
-
get style() {
|
|
278
|
-
return mine.style;
|
|
279
|
-
}
|
|
280
|
-
}), _el$);
|
|
281
|
-
web.spread(_el$, web.mergeProps(other, user, {
|
|
282
|
-
get classList() {
|
|
283
|
-
return {
|
|
284
|
-
[first.class ?? ""]: true,
|
|
285
|
-
[second.class ?? ""]: true,
|
|
286
|
-
// A key containing only spaces breaks, so the optional classes are kept as separate properties
|
|
287
|
-
...first.classList,
|
|
288
|
-
...second.classList
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
}), false, false);
|
|
292
|
-
return _el$;
|
|
293
|
-
})();
|
|
294
|
-
}
|
|
295
|
-
function processProps(props) {
|
|
296
|
-
const [mine, temp, other] = solidJs.splitProps(props, ["ref", "style", "props"], ["class", "classList"]), first = memoProps(temp);
|
|
297
|
-
const [second, user] = splitAndMemoProps(solidJs.mergeProps(() => mine.props), ["class", "classList"]);
|
|
298
|
-
return [mine, first, second, other, user];
|
|
299
|
-
}
|
|
300
|
-
const ctx = solidJs.createContext(void 0, {
|
|
301
|
-
name: "on-case"
|
|
302
|
-
});
|
|
303
|
-
function On(props) {
|
|
304
|
-
const memo = memoProps(props);
|
|
305
|
-
const selector = solidJs.createSelector(() => memo.value, (a, b) => (memo.onCompare ?? solidJs.equalFn)(a, b));
|
|
306
|
-
return web.createComponent(ctx.Provider, {
|
|
307
|
-
value: selector,
|
|
308
|
-
get children() {
|
|
309
|
-
return props.children;
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
function Case(props) {
|
|
314
|
-
const selector = solidJs.useContext(ctx);
|
|
315
|
-
return web.createComponent(solidJs.Match, {
|
|
316
|
-
get when() {
|
|
317
|
-
return selector(props.value);
|
|
318
|
-
},
|
|
319
|
-
get children() {
|
|
320
|
-
return props.children;
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
290
|
class TransitionMonitor {
|
|
325
291
|
#signal = solidJs.createSignal(false);
|
|
326
292
|
/** Whether a transition is currently in progress */
|
|
@@ -363,7 +329,6 @@
|
|
|
363
329
|
exports2.Extractor = Extractor;
|
|
364
330
|
exports2.On = On;
|
|
365
331
|
exports2.OrderedLinkedList = OrderedLinkedList;
|
|
366
|
-
exports2.Part = Part;
|
|
367
332
|
exports2.SameContext = SameContext;
|
|
368
333
|
exports2.Spread = Spread;
|
|
369
334
|
exports2.TransitionMonitor = TransitionMonitor;
|