solid-ctrl-flow 1.0.5 → 1.0.6
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 +6 -0
- package/dist/index.mjs +258 -1
- package/dist/index.umd.js +257 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -125,4 +125,10 @@ export declare function When<T>(props: {
|
|
|
125
125
|
children: (x: NonNullable<T>) => JSX.Element;
|
|
126
126
|
}): JSX.Element;
|
|
127
127
|
|
|
128
|
+
/** Wraps an element with a div with the specified {@link JSX.CustomAttributes.classList} if at least one of them is `true` */
|
|
129
|
+
export declare function Wrapper(props: {
|
|
130
|
+
classList: Record<string, boolean | undefined>;
|
|
131
|
+
children: JSX.Element;
|
|
132
|
+
}): JSX.Element;
|
|
133
|
+
|
|
128
134
|
export { }
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,242 @@
|
|
|
1
|
-
import { createContext, createMemo, createComponent, useContext, Match, mergeProps, onCleanup, Show, splitProps } from "solid-js";
|
|
1
|
+
import { sharedConfig, createRenderEffect, untrack, createContext, createMemo, createComponent, useContext, Match, mergeProps, onCleanup, Show, splitProps } from "solid-js";
|
|
2
2
|
import { createMutable } from "solid-js/store";
|
|
3
|
+
function reconcileArrays(parentNode, a, b) {
|
|
4
|
+
let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = a[aEnd - 1].nextSibling, map = null;
|
|
5
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
6
|
+
if (a[aStart] === b[bStart]) {
|
|
7
|
+
aStart++;
|
|
8
|
+
bStart++;
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
while (a[aEnd - 1] === b[bEnd - 1]) {
|
|
12
|
+
aEnd--;
|
|
13
|
+
bEnd--;
|
|
14
|
+
}
|
|
15
|
+
if (aEnd === aStart) {
|
|
16
|
+
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
|
|
17
|
+
while (bStart < bEnd)
|
|
18
|
+
parentNode.insertBefore(b[bStart++], node);
|
|
19
|
+
} else if (bEnd === bStart) {
|
|
20
|
+
while (aStart < aEnd) {
|
|
21
|
+
if (!map || !map.has(a[aStart]))
|
|
22
|
+
a[aStart].remove();
|
|
23
|
+
aStart++;
|
|
24
|
+
}
|
|
25
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
26
|
+
const node = a[--aEnd].nextSibling;
|
|
27
|
+
parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
|
|
28
|
+
parentNode.insertBefore(b[--bEnd], node);
|
|
29
|
+
a[aEnd] = b[bEnd];
|
|
30
|
+
} else {
|
|
31
|
+
if (!map) {
|
|
32
|
+
map = /* @__PURE__ */ new Map();
|
|
33
|
+
let i = bStart;
|
|
34
|
+
while (i < bEnd)
|
|
35
|
+
map.set(b[i], i++);
|
|
36
|
+
}
|
|
37
|
+
const index = map.get(a[aStart]);
|
|
38
|
+
if (index != null) {
|
|
39
|
+
if (bStart < index && index < bEnd) {
|
|
40
|
+
let i = aStart, sequence = 1, t;
|
|
41
|
+
while (++i < aEnd && i < bEnd) {
|
|
42
|
+
if ((t = map.get(a[i])) == null || t !== index + sequence)
|
|
43
|
+
break;
|
|
44
|
+
sequence++;
|
|
45
|
+
}
|
|
46
|
+
if (sequence > index - bStart) {
|
|
47
|
+
const node = a[aStart];
|
|
48
|
+
while (bStart < index)
|
|
49
|
+
parentNode.insertBefore(b[bStart++], node);
|
|
50
|
+
} else
|
|
51
|
+
parentNode.replaceChild(b[bStart++], a[aStart++]);
|
|
52
|
+
} else
|
|
53
|
+
aStart++;
|
|
54
|
+
} else
|
|
55
|
+
a[aStart++].remove();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function template(html, isCE, isSVG) {
|
|
60
|
+
let node;
|
|
61
|
+
const create = () => {
|
|
62
|
+
const t = document.createElement("template");
|
|
63
|
+
t.innerHTML = html;
|
|
64
|
+
return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
65
|
+
};
|
|
66
|
+
const fn = isCE ? () => untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
|
|
67
|
+
fn.cloneNode = fn;
|
|
68
|
+
return fn;
|
|
69
|
+
}
|
|
70
|
+
function className(node, value) {
|
|
71
|
+
if (sharedConfig.context)
|
|
72
|
+
return;
|
|
73
|
+
if (value == null)
|
|
74
|
+
node.removeAttribute("class");
|
|
75
|
+
else
|
|
76
|
+
node.className = value;
|
|
77
|
+
}
|
|
78
|
+
function insert(parent, accessor, marker, initial) {
|
|
79
|
+
if (marker !== void 0 && !initial)
|
|
80
|
+
initial = [];
|
|
81
|
+
if (typeof accessor !== "function")
|
|
82
|
+
return insertExpression(parent, accessor, initial, marker);
|
|
83
|
+
createRenderEffect((current) => insertExpression(parent, accessor(), current, marker), initial);
|
|
84
|
+
}
|
|
85
|
+
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
86
|
+
if (sharedConfig.context) {
|
|
87
|
+
!current && (current = [...parent.childNodes]);
|
|
88
|
+
let cleaned = [];
|
|
89
|
+
for (let i = 0; i < current.length; i++) {
|
|
90
|
+
const node = current[i];
|
|
91
|
+
if (node.nodeType === 8 && node.data.slice(0, 2) === "!$")
|
|
92
|
+
node.remove();
|
|
93
|
+
else
|
|
94
|
+
cleaned.push(node);
|
|
95
|
+
}
|
|
96
|
+
current = cleaned;
|
|
97
|
+
}
|
|
98
|
+
while (typeof current === "function")
|
|
99
|
+
current = current();
|
|
100
|
+
if (value === current)
|
|
101
|
+
return current;
|
|
102
|
+
const t = typeof value, multi = marker !== void 0;
|
|
103
|
+
parent = multi && current[0] && current[0].parentNode || parent;
|
|
104
|
+
if (t === "string" || t === "number") {
|
|
105
|
+
if (sharedConfig.context)
|
|
106
|
+
return current;
|
|
107
|
+
if (t === "number")
|
|
108
|
+
value = value.toString();
|
|
109
|
+
if (multi) {
|
|
110
|
+
let node = current[0];
|
|
111
|
+
if (node && node.nodeType === 3) {
|
|
112
|
+
node.data = value;
|
|
113
|
+
} else
|
|
114
|
+
node = document.createTextNode(value);
|
|
115
|
+
current = cleanChildren(parent, current, marker, node);
|
|
116
|
+
} else {
|
|
117
|
+
if (current !== "" && typeof current === "string") {
|
|
118
|
+
current = parent.firstChild.data = value;
|
|
119
|
+
} else
|
|
120
|
+
current = parent.textContent = value;
|
|
121
|
+
}
|
|
122
|
+
} else if (value == null || t === "boolean") {
|
|
123
|
+
if (sharedConfig.context)
|
|
124
|
+
return current;
|
|
125
|
+
current = cleanChildren(parent, current, marker);
|
|
126
|
+
} else if (t === "function") {
|
|
127
|
+
createRenderEffect(() => {
|
|
128
|
+
let v = value();
|
|
129
|
+
while (typeof v === "function")
|
|
130
|
+
v = v();
|
|
131
|
+
current = insertExpression(parent, v, current, marker);
|
|
132
|
+
});
|
|
133
|
+
return () => current;
|
|
134
|
+
} else if (Array.isArray(value)) {
|
|
135
|
+
const array = [];
|
|
136
|
+
const currentArray = current && Array.isArray(current);
|
|
137
|
+
if (normalizeIncomingArray(array, value, current, unwrapArray)) {
|
|
138
|
+
createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
139
|
+
return () => current;
|
|
140
|
+
}
|
|
141
|
+
if (sharedConfig.context) {
|
|
142
|
+
if (!array.length)
|
|
143
|
+
return current;
|
|
144
|
+
if (marker === void 0)
|
|
145
|
+
return [...parent.childNodes];
|
|
146
|
+
let node = array[0];
|
|
147
|
+
let nodes = [node];
|
|
148
|
+
while ((node = node.nextSibling) !== marker)
|
|
149
|
+
nodes.push(node);
|
|
150
|
+
return current = nodes;
|
|
151
|
+
}
|
|
152
|
+
if (array.length === 0) {
|
|
153
|
+
current = cleanChildren(parent, current, marker);
|
|
154
|
+
if (multi)
|
|
155
|
+
return current;
|
|
156
|
+
} else if (currentArray) {
|
|
157
|
+
if (current.length === 0) {
|
|
158
|
+
appendNodes(parent, array, marker);
|
|
159
|
+
} else
|
|
160
|
+
reconcileArrays(parent, current, array);
|
|
161
|
+
} else {
|
|
162
|
+
current && cleanChildren(parent);
|
|
163
|
+
appendNodes(parent, array);
|
|
164
|
+
}
|
|
165
|
+
current = array;
|
|
166
|
+
} else if (value.nodeType) {
|
|
167
|
+
if (sharedConfig.context && value.parentNode)
|
|
168
|
+
return current = multi ? [value] : value;
|
|
169
|
+
if (Array.isArray(current)) {
|
|
170
|
+
if (multi)
|
|
171
|
+
return current = cleanChildren(parent, current, marker, value);
|
|
172
|
+
cleanChildren(parent, current, null, value);
|
|
173
|
+
} else if (current == null || current === "" || !parent.firstChild) {
|
|
174
|
+
parent.appendChild(value);
|
|
175
|
+
} else
|
|
176
|
+
parent.replaceChild(value, parent.firstChild);
|
|
177
|
+
current = value;
|
|
178
|
+
} else
|
|
179
|
+
;
|
|
180
|
+
return current;
|
|
181
|
+
}
|
|
182
|
+
function normalizeIncomingArray(normalized, array, current, unwrap) {
|
|
183
|
+
let dynamic = false;
|
|
184
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
185
|
+
let item = array[i], prev = current && current[i], t;
|
|
186
|
+
if (item == null || item === true || item === false)
|
|
187
|
+
;
|
|
188
|
+
else if ((t = typeof item) === "object" && item.nodeType) {
|
|
189
|
+
normalized.push(item);
|
|
190
|
+
} else if (Array.isArray(item)) {
|
|
191
|
+
dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
|
|
192
|
+
} else if (t === "function") {
|
|
193
|
+
if (unwrap) {
|
|
194
|
+
while (typeof item === "function")
|
|
195
|
+
item = item();
|
|
196
|
+
dynamic = normalizeIncomingArray(
|
|
197
|
+
normalized,
|
|
198
|
+
Array.isArray(item) ? item : [item],
|
|
199
|
+
Array.isArray(prev) ? prev : [prev]
|
|
200
|
+
) || dynamic;
|
|
201
|
+
} else {
|
|
202
|
+
normalized.push(item);
|
|
203
|
+
dynamic = true;
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
const value = String(item);
|
|
207
|
+
if (prev && prev.nodeType === 3 && prev.data === value)
|
|
208
|
+
normalized.push(prev);
|
|
209
|
+
else
|
|
210
|
+
normalized.push(document.createTextNode(value));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return dynamic;
|
|
214
|
+
}
|
|
215
|
+
function appendNodes(parent, array, marker = null) {
|
|
216
|
+
for (let i = 0, len = array.length; i < len; i++)
|
|
217
|
+
parent.insertBefore(array[i], marker);
|
|
218
|
+
}
|
|
219
|
+
function cleanChildren(parent, current, marker, replacement) {
|
|
220
|
+
if (marker === void 0)
|
|
221
|
+
return parent.textContent = "";
|
|
222
|
+
const node = replacement || document.createTextNode("");
|
|
223
|
+
if (current.length) {
|
|
224
|
+
let inserted = false;
|
|
225
|
+
for (let i = current.length - 1; i >= 0; i--) {
|
|
226
|
+
const el = current[i];
|
|
227
|
+
if (node !== el) {
|
|
228
|
+
const isParent = el.parentNode === parent;
|
|
229
|
+
if (!inserted && !i)
|
|
230
|
+
isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);
|
|
231
|
+
else
|
|
232
|
+
isParent && el.remove();
|
|
233
|
+
} else
|
|
234
|
+
inserted = true;
|
|
235
|
+
}
|
|
236
|
+
} else
|
|
237
|
+
parent.insertBefore(node, marker);
|
|
238
|
+
return [node];
|
|
239
|
+
}
|
|
3
240
|
const ctx$1 = createContext(() => void 0, {
|
|
4
241
|
name: "case-when"
|
|
5
242
|
});
|
|
@@ -98,6 +335,25 @@ function Joint(props) {
|
|
|
98
335
|
}
|
|
99
336
|
});
|
|
100
337
|
}
|
|
338
|
+
const _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
339
|
+
function Wrapper(props) {
|
|
340
|
+
const classList = createMemo(() => Object.entries(props.classList).filter((x) => x[1]).map((x) => x[0]));
|
|
341
|
+
const children = createMemo(() => props.children);
|
|
342
|
+
return createComponent(Show, {
|
|
343
|
+
get when() {
|
|
344
|
+
return classList().length;
|
|
345
|
+
},
|
|
346
|
+
get fallback() {
|
|
347
|
+
return children();
|
|
348
|
+
},
|
|
349
|
+
get children() {
|
|
350
|
+
const _el$ = _tmpl$();
|
|
351
|
+
insert(_el$, children);
|
|
352
|
+
createRenderEffect(() => className(_el$, classList().join(" ")));
|
|
353
|
+
return _el$;
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
101
357
|
function memoProps(obj, keys = Object.keys(obj)) {
|
|
102
358
|
const out = {};
|
|
103
359
|
for (const elm of keys)
|
|
@@ -114,6 +370,7 @@ export {
|
|
|
114
370
|
Case,
|
|
115
371
|
Debug,
|
|
116
372
|
When,
|
|
373
|
+
Wrapper,
|
|
117
374
|
createExtractor,
|
|
118
375
|
memoProps,
|
|
119
376
|
splitAndMemoProps
|
package/dist/index.umd.js
CHANGED
|
@@ -2,6 +2,243 @@
|
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("solid-js"), require("solid-js/store")) : typeof define === "function" && define.amd ? define(["exports", "solid-js", "solid-js/store"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.solidCtrlFlow = {}, global.solidJs, global.solidJsStore));
|
|
3
3
|
})(this, function(exports2, solidJs, store) {
|
|
4
4
|
"use strict";
|
|
5
|
+
function reconcileArrays(parentNode, a, b) {
|
|
6
|
+
let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = a[aEnd - 1].nextSibling, map = null;
|
|
7
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
8
|
+
if (a[aStart] === b[bStart]) {
|
|
9
|
+
aStart++;
|
|
10
|
+
bStart++;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
while (a[aEnd - 1] === b[bEnd - 1]) {
|
|
14
|
+
aEnd--;
|
|
15
|
+
bEnd--;
|
|
16
|
+
}
|
|
17
|
+
if (aEnd === aStart) {
|
|
18
|
+
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
|
|
19
|
+
while (bStart < bEnd)
|
|
20
|
+
parentNode.insertBefore(b[bStart++], node);
|
|
21
|
+
} else if (bEnd === bStart) {
|
|
22
|
+
while (aStart < aEnd) {
|
|
23
|
+
if (!map || !map.has(a[aStart]))
|
|
24
|
+
a[aStart].remove();
|
|
25
|
+
aStart++;
|
|
26
|
+
}
|
|
27
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
28
|
+
const node = a[--aEnd].nextSibling;
|
|
29
|
+
parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
|
|
30
|
+
parentNode.insertBefore(b[--bEnd], node);
|
|
31
|
+
a[aEnd] = b[bEnd];
|
|
32
|
+
} else {
|
|
33
|
+
if (!map) {
|
|
34
|
+
map = /* @__PURE__ */ new Map();
|
|
35
|
+
let i = bStart;
|
|
36
|
+
while (i < bEnd)
|
|
37
|
+
map.set(b[i], i++);
|
|
38
|
+
}
|
|
39
|
+
const index = map.get(a[aStart]);
|
|
40
|
+
if (index != null) {
|
|
41
|
+
if (bStart < index && index < bEnd) {
|
|
42
|
+
let i = aStart, sequence = 1, t;
|
|
43
|
+
while (++i < aEnd && i < bEnd) {
|
|
44
|
+
if ((t = map.get(a[i])) == null || t !== index + sequence)
|
|
45
|
+
break;
|
|
46
|
+
sequence++;
|
|
47
|
+
}
|
|
48
|
+
if (sequence > index - bStart) {
|
|
49
|
+
const node = a[aStart];
|
|
50
|
+
while (bStart < index)
|
|
51
|
+
parentNode.insertBefore(b[bStart++], node);
|
|
52
|
+
} else
|
|
53
|
+
parentNode.replaceChild(b[bStart++], a[aStart++]);
|
|
54
|
+
} else
|
|
55
|
+
aStart++;
|
|
56
|
+
} else
|
|
57
|
+
a[aStart++].remove();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function template(html, isCE, isSVG) {
|
|
62
|
+
let node;
|
|
63
|
+
const create = () => {
|
|
64
|
+
const t = document.createElement("template");
|
|
65
|
+
t.innerHTML = html;
|
|
66
|
+
return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
67
|
+
};
|
|
68
|
+
const fn = isCE ? () => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
|
|
69
|
+
fn.cloneNode = fn;
|
|
70
|
+
return fn;
|
|
71
|
+
}
|
|
72
|
+
function className(node, value) {
|
|
73
|
+
if (solidJs.sharedConfig.context)
|
|
74
|
+
return;
|
|
75
|
+
if (value == null)
|
|
76
|
+
node.removeAttribute("class");
|
|
77
|
+
else
|
|
78
|
+
node.className = value;
|
|
79
|
+
}
|
|
80
|
+
function insert(parent, accessor, marker, initial) {
|
|
81
|
+
if (marker !== void 0 && !initial)
|
|
82
|
+
initial = [];
|
|
83
|
+
if (typeof accessor !== "function")
|
|
84
|
+
return insertExpression(parent, accessor, initial, marker);
|
|
85
|
+
solidJs.createRenderEffect((current) => insertExpression(parent, accessor(), current, marker), initial);
|
|
86
|
+
}
|
|
87
|
+
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
88
|
+
if (solidJs.sharedConfig.context) {
|
|
89
|
+
!current && (current = [...parent.childNodes]);
|
|
90
|
+
let cleaned = [];
|
|
91
|
+
for (let i = 0; i < current.length; i++) {
|
|
92
|
+
const node = current[i];
|
|
93
|
+
if (node.nodeType === 8 && node.data.slice(0, 2) === "!$")
|
|
94
|
+
node.remove();
|
|
95
|
+
else
|
|
96
|
+
cleaned.push(node);
|
|
97
|
+
}
|
|
98
|
+
current = cleaned;
|
|
99
|
+
}
|
|
100
|
+
while (typeof current === "function")
|
|
101
|
+
current = current();
|
|
102
|
+
if (value === current)
|
|
103
|
+
return current;
|
|
104
|
+
const t = typeof value, multi = marker !== void 0;
|
|
105
|
+
parent = multi && current[0] && current[0].parentNode || parent;
|
|
106
|
+
if (t === "string" || t === "number") {
|
|
107
|
+
if (solidJs.sharedConfig.context)
|
|
108
|
+
return current;
|
|
109
|
+
if (t === "number")
|
|
110
|
+
value = value.toString();
|
|
111
|
+
if (multi) {
|
|
112
|
+
let node = current[0];
|
|
113
|
+
if (node && node.nodeType === 3) {
|
|
114
|
+
node.data = value;
|
|
115
|
+
} else
|
|
116
|
+
node = document.createTextNode(value);
|
|
117
|
+
current = cleanChildren(parent, current, marker, node);
|
|
118
|
+
} else {
|
|
119
|
+
if (current !== "" && typeof current === "string") {
|
|
120
|
+
current = parent.firstChild.data = value;
|
|
121
|
+
} else
|
|
122
|
+
current = parent.textContent = value;
|
|
123
|
+
}
|
|
124
|
+
} else if (value == null || t === "boolean") {
|
|
125
|
+
if (solidJs.sharedConfig.context)
|
|
126
|
+
return current;
|
|
127
|
+
current = cleanChildren(parent, current, marker);
|
|
128
|
+
} else if (t === "function") {
|
|
129
|
+
solidJs.createRenderEffect(() => {
|
|
130
|
+
let v = value();
|
|
131
|
+
while (typeof v === "function")
|
|
132
|
+
v = v();
|
|
133
|
+
current = insertExpression(parent, v, current, marker);
|
|
134
|
+
});
|
|
135
|
+
return () => current;
|
|
136
|
+
} else if (Array.isArray(value)) {
|
|
137
|
+
const array = [];
|
|
138
|
+
const currentArray = current && Array.isArray(current);
|
|
139
|
+
if (normalizeIncomingArray(array, value, current, unwrapArray)) {
|
|
140
|
+
solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
141
|
+
return () => current;
|
|
142
|
+
}
|
|
143
|
+
if (solidJs.sharedConfig.context) {
|
|
144
|
+
if (!array.length)
|
|
145
|
+
return current;
|
|
146
|
+
if (marker === void 0)
|
|
147
|
+
return [...parent.childNodes];
|
|
148
|
+
let node = array[0];
|
|
149
|
+
let nodes = [node];
|
|
150
|
+
while ((node = node.nextSibling) !== marker)
|
|
151
|
+
nodes.push(node);
|
|
152
|
+
return current = nodes;
|
|
153
|
+
}
|
|
154
|
+
if (array.length === 0) {
|
|
155
|
+
current = cleanChildren(parent, current, marker);
|
|
156
|
+
if (multi)
|
|
157
|
+
return current;
|
|
158
|
+
} else if (currentArray) {
|
|
159
|
+
if (current.length === 0) {
|
|
160
|
+
appendNodes(parent, array, marker);
|
|
161
|
+
} else
|
|
162
|
+
reconcileArrays(parent, current, array);
|
|
163
|
+
} else {
|
|
164
|
+
current && cleanChildren(parent);
|
|
165
|
+
appendNodes(parent, array);
|
|
166
|
+
}
|
|
167
|
+
current = array;
|
|
168
|
+
} else if (value.nodeType) {
|
|
169
|
+
if (solidJs.sharedConfig.context && value.parentNode)
|
|
170
|
+
return current = multi ? [value] : value;
|
|
171
|
+
if (Array.isArray(current)) {
|
|
172
|
+
if (multi)
|
|
173
|
+
return current = cleanChildren(parent, current, marker, value);
|
|
174
|
+
cleanChildren(parent, current, null, value);
|
|
175
|
+
} else if (current == null || current === "" || !parent.firstChild) {
|
|
176
|
+
parent.appendChild(value);
|
|
177
|
+
} else
|
|
178
|
+
parent.replaceChild(value, parent.firstChild);
|
|
179
|
+
current = value;
|
|
180
|
+
} else
|
|
181
|
+
;
|
|
182
|
+
return current;
|
|
183
|
+
}
|
|
184
|
+
function normalizeIncomingArray(normalized, array, current, unwrap) {
|
|
185
|
+
let dynamic = false;
|
|
186
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
187
|
+
let item = array[i], prev = current && current[i], t;
|
|
188
|
+
if (item == null || item === true || item === false)
|
|
189
|
+
;
|
|
190
|
+
else if ((t = typeof item) === "object" && item.nodeType) {
|
|
191
|
+
normalized.push(item);
|
|
192
|
+
} else if (Array.isArray(item)) {
|
|
193
|
+
dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
|
|
194
|
+
} else if (t === "function") {
|
|
195
|
+
if (unwrap) {
|
|
196
|
+
while (typeof item === "function")
|
|
197
|
+
item = item();
|
|
198
|
+
dynamic = normalizeIncomingArray(
|
|
199
|
+
normalized,
|
|
200
|
+
Array.isArray(item) ? item : [item],
|
|
201
|
+
Array.isArray(prev) ? prev : [prev]
|
|
202
|
+
) || dynamic;
|
|
203
|
+
} else {
|
|
204
|
+
normalized.push(item);
|
|
205
|
+
dynamic = true;
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
const value = String(item);
|
|
209
|
+
if (prev && prev.nodeType === 3 && prev.data === value)
|
|
210
|
+
normalized.push(prev);
|
|
211
|
+
else
|
|
212
|
+
normalized.push(document.createTextNode(value));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return dynamic;
|
|
216
|
+
}
|
|
217
|
+
function appendNodes(parent, array, marker = null) {
|
|
218
|
+
for (let i = 0, len = array.length; i < len; i++)
|
|
219
|
+
parent.insertBefore(array[i], marker);
|
|
220
|
+
}
|
|
221
|
+
function cleanChildren(parent, current, marker, replacement) {
|
|
222
|
+
if (marker === void 0)
|
|
223
|
+
return parent.textContent = "";
|
|
224
|
+
const node = replacement || document.createTextNode("");
|
|
225
|
+
if (current.length) {
|
|
226
|
+
let inserted = false;
|
|
227
|
+
for (let i = current.length - 1; i >= 0; i--) {
|
|
228
|
+
const el = current[i];
|
|
229
|
+
if (node !== el) {
|
|
230
|
+
const isParent = el.parentNode === parent;
|
|
231
|
+
if (!inserted && !i)
|
|
232
|
+
isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);
|
|
233
|
+
else
|
|
234
|
+
isParent && el.remove();
|
|
235
|
+
} else
|
|
236
|
+
inserted = true;
|
|
237
|
+
}
|
|
238
|
+
} else
|
|
239
|
+
parent.insertBefore(node, marker);
|
|
240
|
+
return [node];
|
|
241
|
+
}
|
|
5
242
|
const ctx$1 = solidJs.createContext(() => void 0, {
|
|
6
243
|
name: "case-when"
|
|
7
244
|
});
|
|
@@ -100,6 +337,25 @@
|
|
|
100
337
|
}
|
|
101
338
|
});
|
|
102
339
|
}
|
|
340
|
+
const _tmpl$ = /* @__PURE__ */ template(`<div>`);
|
|
341
|
+
function Wrapper(props) {
|
|
342
|
+
const classList = solidJs.createMemo(() => Object.entries(props.classList).filter((x) => x[1]).map((x) => x[0]));
|
|
343
|
+
const children = solidJs.createMemo(() => props.children);
|
|
344
|
+
return solidJs.createComponent(solidJs.Show, {
|
|
345
|
+
get when() {
|
|
346
|
+
return classList().length;
|
|
347
|
+
},
|
|
348
|
+
get fallback() {
|
|
349
|
+
return children();
|
|
350
|
+
},
|
|
351
|
+
get children() {
|
|
352
|
+
const _el$ = _tmpl$();
|
|
353
|
+
insert(_el$, children);
|
|
354
|
+
solidJs.createRenderEffect(() => className(_el$, classList().join(" ")));
|
|
355
|
+
return _el$;
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
103
359
|
function memoProps(obj, keys = Object.keys(obj)) {
|
|
104
360
|
const out = {};
|
|
105
361
|
for (const elm of keys)
|
|
@@ -115,6 +371,7 @@
|
|
|
115
371
|
exports2.Case = Case;
|
|
116
372
|
exports2.Debug = Debug;
|
|
117
373
|
exports2.When = When;
|
|
374
|
+
exports2.Wrapper = Wrapper;
|
|
118
375
|
exports2.createExtractor = createExtractor;
|
|
119
376
|
exports2.memoProps = memoProps;
|
|
120
377
|
exports2.splitAndMemoProps = splitAndMemoProps;
|