react-solidlike 2.2.0 → 2.2.2
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.js +9 -3
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -80,7 +80,7 @@ function For({ each, children, keyExtractor, fallback = null }) {
|
|
|
80
80
|
if (!each || each.length === 0) return fallback;
|
|
81
81
|
return each.map((item, index) => {
|
|
82
82
|
const key = keyExtractor ? keyExtractor(item, index) : index;
|
|
83
|
-
return
|
|
83
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children(item, index) }, key);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -104,15 +104,21 @@ function QueryBoundary({ query, loading = null, error = null, empty = null, chil
|
|
|
104
104
|
function Repeat({ times, children }) {
|
|
105
105
|
if (times <= 0) return null;
|
|
106
106
|
const elements = [];
|
|
107
|
-
for (let i = 0; i < times; i++) elements.push( jsx(Fragment, { children: children(i) }, i));
|
|
107
|
+
for (let i = 0; i < times; i++) elements.push(/* @__PURE__ */ jsx(Fragment, { children: children(i) }, i));
|
|
108
108
|
return elements;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
function Show({ when, children, fallback = null }) {
|
|
112
|
-
if (!when) return fallback;
|
|
112
|
+
if (!when || isEmpty(when)) return fallback;
|
|
113
113
|
if (typeof children === "function") return children(when);
|
|
114
114
|
return children;
|
|
115
115
|
}
|
|
116
|
+
function isEmpty(value) {
|
|
117
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
118
|
+
if (value instanceof Map || value instanceof Set) return value.size === 0;
|
|
119
|
+
if (typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype) return Object.keys(value).length === 0;
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
116
122
|
|
|
117
123
|
function Match(_props) {
|
|
118
124
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-solidlike",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Declarative React control flow components inspired by Solid.js, replacing ternary expressions and array.map() in JSX",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"
|
|
13
|
-
"require": "./dist/index.cjs"
|
|
12
|
+
"default": "./dist/index.js"
|
|
14
13
|
}
|
|
15
14
|
},
|
|
16
15
|
"files": [
|