@fluixi/dom 1.0.0-alpha.83 → 1.0.0-alpha.85
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/cdn/dom-client.cjs +1427 -1
- package/dist/cdn/dom-client.d.ts +2 -2
- package/dist/cdn/dom-client.global.js +2 -1
- package/dist/cdn/dom-client.js +3 -3
- package/dist/cdn/dom-client.mjs +1430 -1
- package/dist/cdn/dom.cjs +3127 -1
- package/dist/cdn/dom.d.ts +2 -2
- package/dist/cdn/dom.global.js +2 -1
- package/dist/cdn/dom.js +4 -4
- package/dist/cdn/dom.mjs +3133 -1
- package/dist/index.cjs +3155 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +3149 -1
- package/dist/lib/component/index.cjs +128 -1
- package/dist/lib/component/index.mjs +105 -1
- package/dist/lib/component/modifiers.cjs +126 -1
- package/dist/lib/component/modifiers.d.ts +12 -0
- package/dist/lib/component/modifiers.d.ts.map +1 -1
- package/dist/lib/component/modifiers.js +12 -84
- package/dist/lib/component/modifiers.mjs +105 -1
- package/dist/lib/dom/delegate.cjs +60 -1
- package/dist/lib/dom/delegate.js +1 -1
- package/dist/lib/dom/delegate.mjs +39 -1
- package/dist/lib/dom/dynamic-element.cjs +949 -1
- package/dist/lib/dom/dynamic-element.d.ts +3 -3
- package/dist/lib/dom/dynamic-element.js +2 -2
- package/dist/lib/dom/dynamic-element.mjs +928 -1
- package/dist/lib/dom/hydration-state.cjs +93 -1
- package/dist/lib/dom/hydration-state.d.ts +1 -1
- package/dist/lib/dom/hydration-state.js +1 -1
- package/dist/lib/dom/hydration-state.mjs +72 -1
- package/dist/lib/dom/hydration.cjs +685 -1
- package/dist/lib/dom/hydration.js +8 -8
- package/dist/lib/dom/hydration.mjs +664 -1
- package/dist/lib/dom/index.cjs +2040 -1
- package/dist/lib/dom/index.js +1 -1
- package/dist/lib/dom/index.mjs +2020 -1
- package/dist/lib/dom/integration.cjs +71 -1
- package/dist/lib/dom/integration.js +3 -3
- package/dist/lib/dom/integration.mjs +51 -1
- package/dist/lib/dom/island.cjs +790 -1
- package/dist/lib/dom/island.d.ts +1 -1
- package/dist/lib/dom/island.js +11 -11
- package/dist/lib/dom/island.mjs +769 -1
- package/dist/lib/dom/runtime.cjs +1432 -1
- package/dist/lib/dom/runtime.d.ts +60 -17
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +122 -79
- package/dist/lib/dom/runtime.mjs +1414 -1
- package/dist/lib/dom/server/fx-data.cjs +53 -1
- package/dist/lib/dom/server/fx-data.d.ts +5 -5
- package/dist/lib/dom/server/fx-data.js +6 -6
- package/dist/lib/dom/server/fx-data.mjs +32 -1
- package/dist/lib/dom/server/host.cjs +66 -1
- package/dist/lib/dom/server/host.d.ts +6 -0
- package/dist/lib/dom/server/host.d.ts.map +1 -1
- package/dist/lib/dom/server/host.js +7 -1
- package/dist/lib/dom/server/host.mjs +45 -1
- package/dist/lib/dom/server/index.cjs +759 -1
- package/dist/lib/dom/server/index.d.ts +1 -1
- package/dist/lib/dom/server/index.js +1 -1
- package/dist/lib/dom/server/index.mjs +743 -1
- package/dist/lib/dom/server/nodes.cjs +302 -1
- package/dist/lib/dom/server/nodes.d.ts +2 -2
- package/dist/lib/dom/server/nodes.d.ts.map +1 -1
- package/dist/lib/dom/server/nodes.js +4 -4
- package/dist/lib/dom/server/nodes.mjs +279 -1
- package/dist/lib/dom/server/parse-template.cjs +395 -1
- package/dist/lib/dom/server/parse-template.d.ts +1 -1
- package/dist/lib/dom/server/parse-template.js +4 -4
- package/dist/lib/dom/server/parse-template.mjs +372 -1
- package/dist/lib/dom/server/render.cjs +691 -1
- package/dist/lib/dom/server/render.d.ts +9 -1
- package/dist/lib/dom/server/render.d.ts.map +1 -1
- package/dist/lib/dom/server/render.js +23 -15
- package/dist/lib/dom/server/render.mjs +677 -1
- package/dist/lib/dom/server/request-context.cjs +110 -1
- package/dist/lib/dom/server/request-context.d.ts +29 -9
- package/dist/lib/dom/server/request-context.d.ts.map +1 -1
- package/dist/lib/dom/server/request-context.js +28 -8
- package/dist/lib/dom/server/request-context.mjs +89 -1
- package/dist/lib/dom/server/serialize.cjs +187 -1
- package/dist/lib/dom/server/serialize.js +3 -3
- package/dist/lib/dom/server/serialize.mjs +164 -1
- package/dist/lib/dom/server-renderer.cjs +760 -1
- package/dist/lib/dom/server-renderer.js +1 -1
- package/dist/lib/dom/server-renderer.mjs +745 -1
- package/dist/lib/dom/types.cjs +18 -1
- package/dist/lib/dom/utils.cjs +381 -1
- package/dist/lib/dom/utils.d.ts +1 -88
- package/dist/lib/dom/utils.d.ts.map +1 -1
- package/dist/lib/dom/utils.js +2 -99
- package/dist/lib/dom/utils.mjs +361 -1
- package/dist/lib/dom/versions.cjs +60 -1
- package/dist/lib/dom/versions.d.ts +3 -3
- package/dist/lib/dom/versions.d.ts.map +1 -1
- package/dist/lib/dom/versions.js +17 -5
- package/dist/lib/dom/versions.mjs +37 -1
- package/dist/lib/element/attributes.cjs +19 -1
- package/dist/lib/element/attributes.d.ts +7 -7
- package/dist/lib/element/attributes.js +1 -1
- package/dist/lib/element/attributes.mjs +1 -0
- package/dist/lib/element/index.cjs +19 -1
- package/dist/lib/element/index.mjs +1 -0
- package/dist/lib/element/types.cjs +18 -1
- package/dist/lib/element/types.d.ts +4 -5
- package/dist/lib/element/types.d.ts.map +1 -1
- package/dist/lib/element/types.js +0 -1
- package/dist/lib/flow/class-map.cjs +38 -1
- package/dist/lib/flow/class-map.d.ts +3 -3
- package/dist/lib/flow/class-map.js +2 -2
- package/dist/lib/flow/class-map.mjs +17 -1
- package/dist/lib/flow/client-only.cjs +57 -1
- package/dist/lib/flow/client-only.d.ts +4 -4
- package/dist/lib/flow/client-only.js +3 -3
- package/dist/lib/flow/client-only.mjs +36 -1
- package/dist/lib/flow/dynamic.cjs +53 -1
- package/dist/lib/flow/dynamic.d.ts +2 -2
- package/dist/lib/flow/dynamic.js +3 -3
- package/dist/lib/flow/dynamic.mjs +32 -1
- package/dist/lib/flow/error-boundary.cjs +43 -1
- package/dist/lib/flow/error-boundary.d.ts +2 -2
- package/dist/lib/flow/error-boundary.js +3 -3
- package/dist/lib/flow/error-boundary.mjs +22 -1
- package/dist/lib/flow/for.cjs +66 -1
- package/dist/lib/flow/for.d.ts +9 -9
- package/dist/lib/flow/for.d.ts.map +1 -1
- package/dist/lib/flow/for.js +2 -2
- package/dist/lib/flow/for.mjs +45 -1
- package/dist/lib/flow/index-flow.cjs +67 -1
- package/dist/lib/flow/index-flow.d.ts +5 -5
- package/dist/lib/flow/index-flow.js +4 -4
- package/dist/lib/flow/index-flow.mjs +46 -1
- package/dist/lib/flow/index.cjs +805 -1
- package/dist/lib/flow/index.mjs +792 -1
- package/dist/lib/flow/portal.cjs +538 -1
- package/dist/lib/flow/portal.mjs +519 -1
- package/dist/lib/flow/show.cjs +81 -1
- package/dist/lib/flow/show.d.ts +1 -1
- package/dist/lib/flow/show.d.ts.map +1 -1
- package/dist/lib/flow/show.js +4 -115
- package/dist/lib/flow/show.mjs +67 -1
- package/dist/lib/flow/style-map.cjs +43 -1
- package/dist/lib/flow/style-map.d.ts +3 -3
- package/dist/lib/flow/style-map.js +3 -3
- package/dist/lib/flow/style-map.mjs +22 -1
- package/dist/lib/flow/switch.cjs +91 -1
- package/dist/lib/flow/switch.d.ts +3 -3
- package/dist/lib/flow/switch.d.ts.map +1 -1
- package/dist/lib/flow/switch.js +6 -6
- package/dist/lib/flow/switch.mjs +70 -1
- package/dist/lib/flow/utils.cjs +44 -1
- package/dist/lib/flow/utils.d.ts +1 -1
- package/dist/lib/flow/utils.js +1 -1
- package/dist/lib/flow/utils.mjs +23 -1
- package/dist/lib/html.cjs +32 -1
- package/dist/lib/html.d.ts +6 -6
- package/dist/lib/html.js +5 -5
- package/dist/lib/html.mjs +11 -1
- package/dist/lib/index.cjs +3104 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -3
- package/dist/lib/index.mjs +3097 -1
- package/dist/lib/shared/types.cjs +18 -1
- package/dist/lib/shared/types.d.ts +8 -8
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +26 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +2 -2
- package/dist/version.generated.mjs +5 -1
- package/package.json +7 -6
- package/dist/lib/jsx/control-flow/flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/flow.js +0 -627
- package/dist/lib/jsx/control-flow/flow.mjs +0 -0
- package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/for-flow.js +0 -1
- package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
package/dist/lib/flow/show.js
CHANGED
|
@@ -3,7 +3,7 @@ import { resolveReactiveProp, isLitResult } from './utils.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Conditionally renders content based on a reactive condition.
|
|
5
5
|
*
|
|
6
|
-
* Returns a memo
|
|
6
|
+
* Returns a memo: works in both JSX and `html` templates.
|
|
7
7
|
*
|
|
8
8
|
* @example JSX
|
|
9
9
|
* <Show when={isLoggedIn()} fallback={<Login />}>
|
|
@@ -13,34 +13,22 @@ import { resolveReactiveProp, isLitResult } from './utils.js';
|
|
|
13
13
|
* @example html template
|
|
14
14
|
* Show({ when: isLoggedIn, fallback: html`<p>Login</p>`, children: html`<p>Dashboard</p>` })
|
|
15
15
|
*/
|
|
16
|
-
// export function Show<T>(props: ShowProps<T>): Accessor<any> {
|
|
17
|
-
// const when = normalizeAccessor(props.when);
|
|
18
16
|
// return createMemo(() => {
|
|
19
|
-
// const value = when();
|
|
20
|
-
// if (isTruthy(value)) {
|
|
21
|
-
// return typeof props.children === 'function'
|
|
22
|
-
// ? props.children(value)
|
|
23
|
-
// : props.children;
|
|
24
|
-
// }
|
|
25
|
-
// return props.fallback ?? null;
|
|
26
|
-
// });
|
|
27
|
-
// }
|
|
28
17
|
export function Show(props) {
|
|
29
18
|
// Read `when` lazily through the prop getter so `when={cond()}` re-runs the caller's
|
|
30
19
|
// expression inside these memos (reactive), while `when={cond}` / `when={() => cond}`
|
|
31
|
-
// still work
|
|
20
|
+
// still work: resolveReactiveProp unwraps the accessor form once.
|
|
32
21
|
const when = resolveReactiveProp(() => props.when);
|
|
33
|
-
// const {when} = props
|
|
34
22
|
// Named for a watcher: three memos at one line, two of them anonymous, is what a graph of
|
|
35
23
|
// a page with a few conditions turns into.
|
|
36
24
|
const value = createMemo(when, undefined, { name: 'Show.when' });
|
|
37
25
|
const cond = createMemo(value, undefined, { name: 'Show.cond' });
|
|
38
26
|
// Each branch renders in its own scope so that leaving it tears down whatever
|
|
39
|
-
// it registered
|
|
27
|
+
// it registered, an event listener, an observer, a timer. Without this the
|
|
40
28
|
// branch's `onCleanup`s land on the enclosing owner and only run when the
|
|
41
29
|
// whole tree dies, so a closed <Show> kept listening and reacting.
|
|
42
30
|
//
|
|
43
|
-
// Keyed on which branch is showing,
|
|
31
|
+
// Keyed on which branch is showing, not on every re-run: the memo also re-runs
|
|
44
32
|
// when the value changes within the same branch, and disposing then would
|
|
45
33
|
// throw away DOM the runtime deliberately reuses.
|
|
46
34
|
const parentOwner = getOwner();
|
|
@@ -60,7 +48,6 @@ export function Show(props) {
|
|
|
60
48
|
// return props.fallback ?? null;
|
|
61
49
|
// }
|
|
62
50
|
// }
|
|
63
|
-
// const value = when();
|
|
64
51
|
const evaluate = cond();
|
|
65
52
|
enterBranch(evaluate ? 'when' : 'fallback');
|
|
66
53
|
return runWithOwner(branchScope, () => {
|
|
@@ -82,108 +69,10 @@ export function Show(props) {
|
|
|
82
69
|
return props.fallback;
|
|
83
70
|
});
|
|
84
71
|
// if (isTruthy(value)) {
|
|
85
|
-
// let children = props.children;
|
|
86
|
-
// // handle children on jsx
|
|
87
|
-
// // if(Array.isArray(children)) {
|
|
88
|
-
// // children = makeArrayFlat(children);
|
|
89
|
-
// // // console.log('is truthy', children);
|
|
90
|
-
// // // if(children)
|
|
91
|
-
// // // children = (children as any[]).map((c: any) => typeof c === 'function' ? c(value) : c) as any;
|
|
92
|
-
// // // return children;
|
|
93
|
-
// // }
|
|
94
|
-
// if (typeof children === 'function' && !isLitResult(children)) {
|
|
95
|
-
// if (isSignal<any>(value)) {
|
|
96
|
-
// // value = (value as any)() as any;
|
|
97
|
-
// return (children as (item: T) => any)((value as any)());
|
|
98
|
-
// }
|
|
99
|
-
// return (children as (item: T) => any)(value as T);
|
|
100
|
-
// }
|
|
101
|
-
// return children;
|
|
102
|
-
// // return typeof props.children === 'function'
|
|
103
|
-
// // ? props.children(value)
|
|
104
|
-
// // : props.children;
|
|
105
|
-
// }
|
|
106
|
-
// let value =
|
|
107
|
-
// typeof condition === 'function' ? (condition as () => T)() : condition;
|
|
108
|
-
// if (value != null && value !== false) {
|
|
109
|
-
// // console.log('value', value);
|
|
110
|
-
// const children = props.children;
|
|
111
|
-
// if (typeof children === 'function' && !isLitResult(children)) {
|
|
112
|
-
// if (isSignal<any>(value)) {
|
|
113
|
-
// value = (value as any)() as any;
|
|
114
|
-
// }
|
|
115
|
-
// return (children as (item: T) => any)(value as T);
|
|
116
|
-
// }
|
|
117
|
-
// return children;
|
|
118
|
-
// }
|
|
119
72
|
return props.fallback ?? null;
|
|
120
73
|
}, undefined,
|
|
121
74
|
// Not `Show`: the compiler already marks the memo it wraps the component in with that,
|
|
122
75
|
// and two cards of the same name in one graph is worse than a longer one.
|
|
123
76
|
{ name: 'Show.result' });
|
|
124
77
|
}
|
|
125
|
-
// export function Show1<T>(props: ShowProps<T>): any {
|
|
126
|
-
// const when = normalizeAccessor(props.when);
|
|
127
|
-
// return createMemo(
|
|
128
|
-
// () => {
|
|
129
|
-
// if (isResource(when)) {
|
|
130
|
-
// if (when.loading) {
|
|
131
|
-
// return props.fallback ?? null;
|
|
132
|
-
// }
|
|
133
|
-
// }
|
|
134
|
-
// const value = when();
|
|
135
|
-
// if (isTruthy(value)) {
|
|
136
|
-
// let children = props.children;
|
|
137
|
-
// // handle children on jsx
|
|
138
|
-
// // if(Array.isArray(children)) {
|
|
139
|
-
// // children = makeArrayFlat(children);
|
|
140
|
-
// // // console.log('is truthy', children);
|
|
141
|
-
// // // if(children)
|
|
142
|
-
// // // children = (children as any[]).map((c: any) => typeof c === 'function' ? c(value) : c) as any;
|
|
143
|
-
// // // return children;
|
|
144
|
-
// // }
|
|
145
|
-
// if (typeof children === 'function' && !isLitResult(children)) {
|
|
146
|
-
// if (isSignal<any>(value)) {
|
|
147
|
-
// // value = (value as any)() as any;
|
|
148
|
-
// return (children as (item: T) => any)((value as any)());
|
|
149
|
-
// }
|
|
150
|
-
// return (children as (item: T) => any)(value as T);
|
|
151
|
-
// }
|
|
152
|
-
// return children;
|
|
153
|
-
// // return typeof props.children === 'function'
|
|
154
|
-
// // ? props.children(value)
|
|
155
|
-
// // : props.children;
|
|
156
|
-
// }
|
|
157
|
-
// // let value =
|
|
158
|
-
// // typeof condition === 'function' ? (condition as () => T)() : condition;
|
|
159
|
-
// // if (value != null && value !== false) {
|
|
160
|
-
// // // console.log('value', value);
|
|
161
|
-
// // const children = props.children;
|
|
162
|
-
// // if (typeof children === 'function' && !isLitResult(children)) {
|
|
163
|
-
// // if (isSignal<any>(value)) {
|
|
164
|
-
// // value = (value as any)() as any;
|
|
165
|
-
// // }
|
|
166
|
-
// // return (children as (item: T) => any)(value as T);
|
|
167
|
-
// // }
|
|
168
|
-
// // return children;
|
|
169
|
-
// // }
|
|
170
|
-
// return props.fallback ?? null;
|
|
171
|
-
// },
|
|
172
|
-
// undefined,
|
|
173
|
-
// { name: 'show' }
|
|
174
|
-
// );
|
|
175
|
-
// }
|
|
176
78
|
// if (isTruthy(value)) {
|
|
177
|
-
// const children = props.children;
|
|
178
|
-
// if (typeof children === 'function' && !isLitResult(children)) {
|
|
179
|
-
// if (isSignal<any>(value)) {
|
|
180
|
-
// // value = (value as any)() as any;
|
|
181
|
-
// return (children as (item: T) => any)((value as any)());
|
|
182
|
-
// }
|
|
183
|
-
// return (children as (item: T) => any)(value as T);
|
|
184
|
-
// }
|
|
185
|
-
// return children;
|
|
186
|
-
// // return typeof props.children === 'function'
|
|
187
|
-
// // ? props.children(value)
|
|
188
|
-
// // : props.children;
|
|
189
|
-
// }
|
package/dist/lib/flow/show.mjs
CHANGED
|
@@ -1 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
// src/lib/flow/show.ts
|
|
2
|
+
import {
|
|
3
|
+
createChildOwner,
|
|
4
|
+
createMemo,
|
|
5
|
+
disposeScope,
|
|
6
|
+
getOwner,
|
|
7
|
+
runWithOwner,
|
|
8
|
+
untrack
|
|
9
|
+
} from "@fluixi/reactive/signal";
|
|
10
|
+
|
|
11
|
+
// src/lib/flow/utils.ts
|
|
12
|
+
function resolveReactiveProp(read) {
|
|
13
|
+
return () => {
|
|
14
|
+
const value = read();
|
|
15
|
+
return typeof value === "function" ? value() : value;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function isLitResult(value) {
|
|
19
|
+
if (!value || typeof value !== "object") return false;
|
|
20
|
+
return !!(typeof value["_$litType$"] !== "undefined" || typeof value["_$litDirective$"] !== "undefined" || Array.isArray(value.strings) && Array.isArray(value.values));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/lib/flow/show.ts
|
|
24
|
+
function Show(props) {
|
|
25
|
+
const when = resolveReactiveProp(() => props.when);
|
|
26
|
+
const value = createMemo(when, void 0, { name: "Show.when" });
|
|
27
|
+
const cond = createMemo(value, void 0, { name: "Show.cond" });
|
|
28
|
+
const parentOwner = getOwner();
|
|
29
|
+
let branchScope = null;
|
|
30
|
+
let shown = null;
|
|
31
|
+
const enterBranch = (next) => {
|
|
32
|
+
if (next === shown) return;
|
|
33
|
+
if (branchScope) disposeScope(branchScope);
|
|
34
|
+
branchScope = createChildOwner(parentOwner);
|
|
35
|
+
shown = next;
|
|
36
|
+
};
|
|
37
|
+
return createMemo(
|
|
38
|
+
() => {
|
|
39
|
+
const evaluate = cond();
|
|
40
|
+
enterBranch(evaluate ? "when" : "fallback");
|
|
41
|
+
return runWithOwner(branchScope, () => {
|
|
42
|
+
if (evaluate) {
|
|
43
|
+
let children = props.children;
|
|
44
|
+
if (typeof children === "function" && !isLitResult(children)) {
|
|
45
|
+
if (typeof value === "function") {
|
|
46
|
+
return untrack(() => {
|
|
47
|
+
if (!untrack(value)) return props.fallback;
|
|
48
|
+
return children(value());
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return children(value);
|
|
52
|
+
}
|
|
53
|
+
return children;
|
|
54
|
+
}
|
|
55
|
+
return props.fallback;
|
|
56
|
+
});
|
|
57
|
+
return props.fallback ?? null;
|
|
58
|
+
},
|
|
59
|
+
void 0,
|
|
60
|
+
// Not `Show`: the compiler already marks the memo it wraps the component in with that,
|
|
61
|
+
// and two cards of the same name in one graph is worse than a longer one.
|
|
62
|
+
{ name: "Show.result" }
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
Show
|
|
67
|
+
};
|
|
@@ -1 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/flow/style-map.ts
|
|
21
|
+
var style_map_exports = {};
|
|
22
|
+
__export(style_map_exports, {
|
|
23
|
+
styleMap: () => styleMap
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(style_map_exports);
|
|
26
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
27
|
+
function toKebab(prop) {
|
|
28
|
+
return prop.startsWith("--") ? prop : prop.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
29
|
+
}
|
|
30
|
+
function styleMap(input) {
|
|
31
|
+
return (0, import_signal.createMemo)(() => {
|
|
32
|
+
const map = typeof input === "function" ? input() : input;
|
|
33
|
+
const parts = [];
|
|
34
|
+
for (const [prop, val] of Object.entries(map)) {
|
|
35
|
+
if (!prop) continue;
|
|
36
|
+
const resolved = typeof val === "function" ? val() : val;
|
|
37
|
+
if (resolved != null) {
|
|
38
|
+
parts.push(`${toKebab(prop)}: ${resolved}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return parts.join("; ");
|
|
42
|
+
}, void 0, { name: "StyleMap" });
|
|
43
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Accessor } from '@fluixi/reactive/signal';
|
|
2
2
|
/**
|
|
3
|
-
* A single style property value
|
|
3
|
+
* A single style property value: static or reactive.
|
|
4
4
|
* Numbers are converted to strings as-is (no `px` appended automatically).
|
|
5
5
|
*/
|
|
6
6
|
export type StyleValue = string | number | null | undefined | Accessor<string | number | null | undefined> | (() => string | number | null | undefined);
|
|
@@ -36,11 +36,11 @@ export type StyleMapInput = Record<string, StyleValue> | Accessor<Record<string,
|
|
|
36
36
|
*
|
|
37
37
|
* // camelCase is converted automatically
|
|
38
38
|
* styleMap({ backgroundColor: '#fff', fontSize: '1rem' })
|
|
39
|
-
* //
|
|
39
|
+
* // -> "background-color: #fff; font-size: 1rem"
|
|
40
40
|
*
|
|
41
41
|
* // CSS custom properties pass through unchanged
|
|
42
42
|
* styleMap({ '--radius': radius })
|
|
43
|
-
* //
|
|
43
|
+
* // -> "--radius: 8px"
|
|
44
44
|
*/
|
|
45
45
|
export declare function styleMap(input: StyleMapInput): Accessor<string>;
|
|
46
46
|
//# sourceMappingURL=style-map.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createMemo } from '@fluixi/reactive/signal';
|
|
2
|
-
/** camelCase
|
|
2
|
+
/** camelCase -> kebab-case; CSS custom properties (--) pass through unchanged. */
|
|
3
3
|
function toKebab(prop) {
|
|
4
4
|
return prop.startsWith('--')
|
|
5
5
|
? prop
|
|
@@ -28,11 +28,11 @@ function toKebab(prop) {
|
|
|
28
28
|
*
|
|
29
29
|
* // camelCase is converted automatically
|
|
30
30
|
* styleMap({ backgroundColor: '#fff', fontSize: '1rem' })
|
|
31
|
-
* //
|
|
31
|
+
* // -> "background-color: #fff; font-size: 1rem"
|
|
32
32
|
*
|
|
33
33
|
* // CSS custom properties pass through unchanged
|
|
34
34
|
* styleMap({ '--radius': radius })
|
|
35
|
-
* //
|
|
35
|
+
* // -> "--radius: 8px"
|
|
36
36
|
*/
|
|
37
37
|
export function styleMap(input) {
|
|
38
38
|
return createMemo(() => {
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
// src/lib/flow/style-map.ts
|
|
2
|
+
import { createMemo } from "@fluixi/reactive/signal";
|
|
3
|
+
function toKebab(prop) {
|
|
4
|
+
return prop.startsWith("--") ? prop : prop.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
5
|
+
}
|
|
6
|
+
function styleMap(input) {
|
|
7
|
+
return createMemo(() => {
|
|
8
|
+
const map = typeof input === "function" ? input() : input;
|
|
9
|
+
const parts = [];
|
|
10
|
+
for (const [prop, val] of Object.entries(map)) {
|
|
11
|
+
if (!prop) continue;
|
|
12
|
+
const resolved = typeof val === "function" ? val() : val;
|
|
13
|
+
if (resolved != null) {
|
|
14
|
+
parts.push(`${toKebab(prop)}: ${resolved}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return parts.join("; ");
|
|
18
|
+
}, void 0, { name: "StyleMap" });
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
styleMap
|
|
22
|
+
};
|
package/dist/lib/flow/switch.cjs
CHANGED
|
@@ -1 +1,91 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/flow/switch.ts
|
|
21
|
+
var switch_exports = {};
|
|
22
|
+
__export(switch_exports, {
|
|
23
|
+
Match: () => Match,
|
|
24
|
+
Switch: () => Switch
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(switch_exports);
|
|
27
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
28
|
+
|
|
29
|
+
// src/lib/flow/utils.ts
|
|
30
|
+
function resolveReactiveProp(read) {
|
|
31
|
+
return () => {
|
|
32
|
+
const value = read();
|
|
33
|
+
return typeof value === "function" ? value() : value;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function isTruthy(value) {
|
|
37
|
+
return value !== null && value !== void 0 && value !== false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/lib/flow/switch.ts
|
|
41
|
+
var MATCH_MARKER = /* @__PURE__ */ Symbol("match");
|
|
42
|
+
function Match(props) {
|
|
43
|
+
return {
|
|
44
|
+
[MATCH_MARKER]: true,
|
|
45
|
+
// Lazy read through the prop getter. Switch calls `branch.when()` inside its memo,
|
|
46
|
+
// so `when={cond()}` reacts; `when={cond}` unwraps via resolveReactiveProp.
|
|
47
|
+
when: resolveReactiveProp(() => props.when),
|
|
48
|
+
// Lazy, like `when`. Read eagerly, every branch's children were built the
|
|
49
|
+
// moment the Match node was, before Switch had chosen one, so they were
|
|
50
|
+
// created outside the branch's scope (and non-matching branches were built
|
|
51
|
+
// for nothing). Switch reads this inside the selected branch's scope.
|
|
52
|
+
get children() {
|
|
53
|
+
return props.children;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function Switch(props) {
|
|
58
|
+
const branches = Array.isArray(props.children) ? props.children : [props.children];
|
|
59
|
+
const parentOwner = (0, import_signal.getOwner)();
|
|
60
|
+
let branchScope = null;
|
|
61
|
+
let shown = -1;
|
|
62
|
+
const enterBranch = (index) => {
|
|
63
|
+
if (index === shown) return;
|
|
64
|
+
if (branchScope) (0, import_signal.disposeScope)(branchScope);
|
|
65
|
+
branchScope = (0, import_signal.createChildOwner)(parentOwner);
|
|
66
|
+
shown = index;
|
|
67
|
+
};
|
|
68
|
+
return (0, import_signal.createMemo)(() => {
|
|
69
|
+
for (let i = 0; i < branches.length; i += 1) {
|
|
70
|
+
const raw = branches[i];
|
|
71
|
+
let branch = raw;
|
|
72
|
+
let guard = 0;
|
|
73
|
+
while (typeof branch === "function" && !branch[MATCH_MARKER] && guard++ < 10) {
|
|
74
|
+
branch = branch();
|
|
75
|
+
}
|
|
76
|
+
if (!branch || typeof branch !== "object" || branch[MATCH_MARKER] !== true) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const value = branch.when();
|
|
80
|
+
if (isTruthy(value)) {
|
|
81
|
+
enterBranch(i);
|
|
82
|
+
return (0, import_signal.runWithOwner)(
|
|
83
|
+
branchScope,
|
|
84
|
+
() => typeof branch.children === "function" ? branch.children(value) : branch.children
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
enterBranch(-2);
|
|
89
|
+
return (0, import_signal.runWithOwner)(branchScope, () => props.fallback ?? null);
|
|
90
|
+
}, void 0, { name: "Switch" });
|
|
91
|
+
}
|
|
@@ -9,7 +9,7 @@ export interface MatchProps<T> {
|
|
|
9
9
|
*/
|
|
10
10
|
children: any | ((val: NonNullable<T>) => any);
|
|
11
11
|
}
|
|
12
|
-
/** @internal Opaque shape returned by Match
|
|
12
|
+
/** @internal Opaque shape returned by Match: consumed by Switch. */
|
|
13
13
|
export interface MatchNode<T = any> {
|
|
14
14
|
[MATCH_MARKER]: true;
|
|
15
15
|
when: Accessor<T | null | undefined | false>;
|
|
@@ -38,10 +38,10 @@ export interface SwitchProps {
|
|
|
38
38
|
children: MatchNode | MatchNode[];
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Multi-branch conditional rendering
|
|
41
|
+
* Multi-branch conditional rendering: mirrors SolidJS `<Switch>/<Match>`.
|
|
42
42
|
*
|
|
43
43
|
* Evaluates `Match` branches in order and renders the first truthy one.
|
|
44
|
-
* Returns a memo
|
|
44
|
+
* Returns a memo: works in both JSX and `html` templates.
|
|
45
45
|
*
|
|
46
46
|
* @example JSX
|
|
47
47
|
* <Switch fallback={<p>Nothing</p>}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkF,MAAM,yBAAyB,CAAC;AAInI,QAAA,MAAM,YAAY,eAAkB,CAAC;AAErC,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,4CAA4C;IAC5C,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC;IACjD;;;OAGG;IACH,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;CAChD;AAED,
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkF,MAAM,yBAAyB,CAAC;AAInI,QAAA,MAAM,YAAY,eAAkB,CAAC;AAErC,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,4CAA4C;IAC5C,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC;IACjD;;;OAGG;IACH,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;CAChD;AAED,oEAAoE;AACpE,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,GAAG;IAChC,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,CAAC;IAC7C,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;CAChD;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAc3D;AAED,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf;;;;;OAKG;IACH,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CA6CxD"}
|
package/dist/lib/flow/switch.js
CHANGED
|
@@ -15,11 +15,11 @@ const MATCH_MARKER = Symbol('match');
|
|
|
15
15
|
export function Match(props) {
|
|
16
16
|
return {
|
|
17
17
|
[MATCH_MARKER]: true,
|
|
18
|
-
// Lazy read through the prop getter
|
|
18
|
+
// Lazy read through the prop getter. Switch calls `branch.when()` inside its memo,
|
|
19
19
|
// so `when={cond()}` reacts; `when={cond}` unwraps via resolveReactiveProp.
|
|
20
20
|
when: resolveReactiveProp(() => props.when),
|
|
21
21
|
// Lazy, like `when`. Read eagerly, every branch's children were built the
|
|
22
|
-
// moment the Match node was
|
|
22
|
+
// moment the Match node was, before Switch had chosen one, so they were
|
|
23
23
|
// created outside the branch's scope (and non-matching branches were built
|
|
24
24
|
// for nothing). Switch reads this inside the selected branch's scope.
|
|
25
25
|
get children() {
|
|
@@ -28,10 +28,10 @@ export function Match(props) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Multi-branch conditional rendering
|
|
31
|
+
* Multi-branch conditional rendering: mirrors SolidJS `<Switch>/<Match>`.
|
|
32
32
|
*
|
|
33
33
|
* Evaluates `Match` branches in order and renders the first truthy one.
|
|
34
|
-
* Returns a memo
|
|
34
|
+
* Returns a memo: works in both JSX and `html` templates.
|
|
35
35
|
*
|
|
36
36
|
* @example JSX
|
|
37
37
|
* <Switch fallback={<p>Nothing</p>}>
|
|
@@ -51,8 +51,8 @@ export function Match(props) {
|
|
|
51
51
|
export function Switch(props) {
|
|
52
52
|
const branches = Array.isArray(props.children) ? props.children : [props.children];
|
|
53
53
|
// Each branch renders in its own scope, disposed when a different branch takes
|
|
54
|
-
// over, so whatever it registered with `onCleanup
|
|
55
|
-
// timer
|
|
54
|
+
// over, so whatever it registered with `onCleanup`, a listener, an observer, a
|
|
55
|
+
// timer: goes with it. Keyed on which branch is showing, not on every re-run:
|
|
56
56
|
// the memo also re-runs when a `when` value changes within the same branch, and
|
|
57
57
|
// disposing then would throw away DOM the runtime deliberately reuses.
|
|
58
58
|
const parentOwner = getOwner();
|
package/dist/lib/flow/switch.mjs
CHANGED
|
@@ -1 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
// src/lib/flow/switch.ts
|
|
2
|
+
import { createMemo, createChildOwner, disposeScope, getOwner, runWithOwner } from "@fluixi/reactive/signal";
|
|
3
|
+
|
|
4
|
+
// src/lib/flow/utils.ts
|
|
5
|
+
function resolveReactiveProp(read) {
|
|
6
|
+
return () => {
|
|
7
|
+
const value = read();
|
|
8
|
+
return typeof value === "function" ? value() : value;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function isTruthy(value) {
|
|
12
|
+
return value !== null && value !== void 0 && value !== false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/lib/flow/switch.ts
|
|
16
|
+
var MATCH_MARKER = /* @__PURE__ */ Symbol("match");
|
|
17
|
+
function Match(props) {
|
|
18
|
+
return {
|
|
19
|
+
[MATCH_MARKER]: true,
|
|
20
|
+
// Lazy read through the prop getter. Switch calls `branch.when()` inside its memo,
|
|
21
|
+
// so `when={cond()}` reacts; `when={cond}` unwraps via resolveReactiveProp.
|
|
22
|
+
when: resolveReactiveProp(() => props.when),
|
|
23
|
+
// Lazy, like `when`. Read eagerly, every branch's children were built the
|
|
24
|
+
// moment the Match node was, before Switch had chosen one, so they were
|
|
25
|
+
// created outside the branch's scope (and non-matching branches were built
|
|
26
|
+
// for nothing). Switch reads this inside the selected branch's scope.
|
|
27
|
+
get children() {
|
|
28
|
+
return props.children;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function Switch(props) {
|
|
33
|
+
const branches = Array.isArray(props.children) ? props.children : [props.children];
|
|
34
|
+
const parentOwner = getOwner();
|
|
35
|
+
let branchScope = null;
|
|
36
|
+
let shown = -1;
|
|
37
|
+
const enterBranch = (index) => {
|
|
38
|
+
if (index === shown) return;
|
|
39
|
+
if (branchScope) disposeScope(branchScope);
|
|
40
|
+
branchScope = createChildOwner(parentOwner);
|
|
41
|
+
shown = index;
|
|
42
|
+
};
|
|
43
|
+
return createMemo(() => {
|
|
44
|
+
for (let i = 0; i < branches.length; i += 1) {
|
|
45
|
+
const raw = branches[i];
|
|
46
|
+
let branch = raw;
|
|
47
|
+
let guard = 0;
|
|
48
|
+
while (typeof branch === "function" && !branch[MATCH_MARKER] && guard++ < 10) {
|
|
49
|
+
branch = branch();
|
|
50
|
+
}
|
|
51
|
+
if (!branch || typeof branch !== "object" || branch[MATCH_MARKER] !== true) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const value = branch.when();
|
|
55
|
+
if (isTruthy(value)) {
|
|
56
|
+
enterBranch(i);
|
|
57
|
+
return runWithOwner(
|
|
58
|
+
branchScope,
|
|
59
|
+
() => typeof branch.children === "function" ? branch.children(value) : branch.children
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
enterBranch(-2);
|
|
64
|
+
return runWithOwner(branchScope, () => props.fallback ?? null);
|
|
65
|
+
}, void 0, { name: "Switch" });
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
Match,
|
|
69
|
+
Switch
|
|
70
|
+
};
|
package/dist/lib/flow/utils.cjs
CHANGED
|
@@ -1 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/flow/utils.ts
|
|
21
|
+
var utils_exports = {};
|
|
22
|
+
__export(utils_exports, {
|
|
23
|
+
isLitResult: () => isLitResult,
|
|
24
|
+
isTruthy: () => isTruthy,
|
|
25
|
+
normalizeAccessor: () => normalizeAccessor,
|
|
26
|
+
resolveReactiveProp: () => resolveReactiveProp
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(utils_exports);
|
|
29
|
+
function normalizeAccessor(value) {
|
|
30
|
+
return typeof value === "function" ? value : (() => value);
|
|
31
|
+
}
|
|
32
|
+
function resolveReactiveProp(read) {
|
|
33
|
+
return () => {
|
|
34
|
+
const value = read();
|
|
35
|
+
return typeof value === "function" ? value() : value;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function isTruthy(value) {
|
|
39
|
+
return value !== null && value !== void 0 && value !== false;
|
|
40
|
+
}
|
|
41
|
+
function isLitResult(value) {
|
|
42
|
+
if (!value || typeof value !== "object") return false;
|
|
43
|
+
return !!(typeof value["_$litType$"] !== "undefined" || typeof value["_$litDirective$"] !== "undefined" || Array.isArray(value.strings) && Array.isArray(value.values));
|
|
44
|
+
}
|
package/dist/lib/flow/utils.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function normalizeAccessor<T>(value: T | Accessor<T>): Accessor<T
|
|
|
8
8
|
*
|
|
9
9
|
* The compiler emits control-flow value props (each/when/component/mount) as getters, so
|
|
10
10
|
* `read()` re-runs the caller's expression INSIDE the tracking scope where the returned
|
|
11
|
-
* accessor is invoked
|
|
11
|
+
* accessor is invoked, this is what makes `each={items()}` reactive. If the read value is
|
|
12
12
|
* itself a function (the `each={items}` accessor form), it is called once. This unwraps at
|
|
13
13
|
* most one level, so `each={() => items()}` doesn't double-call.
|
|
14
14
|
*/
|
package/dist/lib/flow/utils.js
CHANGED
|
@@ -11,7 +11,7 @@ export function normalizeAccessor(value) {
|
|
|
11
11
|
*
|
|
12
12
|
* The compiler emits control-flow value props (each/when/component/mount) as getters, so
|
|
13
13
|
* `read()` re-runs the caller's expression INSIDE the tracking scope where the returned
|
|
14
|
-
* accessor is invoked
|
|
14
|
+
* accessor is invoked, this is what makes `each={items()}` reactive. If the read value is
|
|
15
15
|
* itself a function (the `each={items}` accessor form), it is called once. This unwraps at
|
|
16
16
|
* most one level, so `each={() => items()}` doesn't double-call.
|
|
17
17
|
*/
|