lilact 0.23.1 → 0.24.0
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/README.md +15 -1
- package/dist/lilact.development.js +480 -461
- package/dist/lilact.development.js.map +4 -4
- package/dist/lilact.development.min.js +24 -24
- package/dist/lilact.development.min.js.map +4 -4
- package/dist/lilact.production.min.js +24 -24
- package/docs/assets/hierarchy.js +1 -1
- package/docs/classes/components.Component.html +1 -1
- package/docs/classes/components.HTMLComponent.html +1 -1
- package/docs/classes/components.RootComponent.html +1 -1
- package/docs/functions/components.cloneComponent.html +1 -1
- package/docs/functions/timers.timeoutPromise.html +4 -4
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +17 -1
- package/docs/static/demos/cloneelement.jsx +6 -0
- package/docs/static/demos/lazy.jsx +1 -1
- package/docs/static/demos/legacy-context.jsx +0 -7
- package/docs/static/index.html +1 -1
- package/docs/static/lilact.development.js +480 -461
- package/docs/static/lilact.development.js.map +4 -4
- package/docs/static/lilact.development.min.js +24 -24
- package/docs/static/lilact.development.min.js.map +4 -4
- package/docs/static/lilact.production.min.js +24 -24
- package/docs/variables/components.cloneElement.html +1 -1
- package/examples/demos/cloneelement.jsx +6 -0
- package/examples/demos/lazy.jsx +1 -1
- package/examples/demos/legacy-context.jsx +0 -7
- package/examples/index.html +1 -1
- package/examples/lilact.development.js +480 -461
- package/examples/lilact.development.js.map +4 -4
- package/examples/lilact.development.min.js +24 -24
- package/examples/lilact.development.min.js.map +4 -4
- package/examples/lilact.production.min.js +24 -24
- package/package.json +1 -1
- package/src/components.jsx +3 -3
- package/src/lilact.jsx +1 -1
- package/src/proptypes.jsx +38 -0
package/package.json
CHANGED
package/src/components.jsx
CHANGED
|
@@ -1142,7 +1142,7 @@ export function createComponent(entity, props={}, ...children)
|
|
|
1142
1142
|
props.key = generateComponentKey(entity, props);
|
|
1143
1143
|
props.children = children;
|
|
1144
1144
|
|
|
1145
|
-
return { entity, props };
|
|
1145
|
+
return { entity, props, [CORE]: null };
|
|
1146
1146
|
}
|
|
1147
1147
|
|
|
1148
1148
|
/**
|
|
@@ -1208,7 +1208,7 @@ export function createPortal(children, element)
|
|
|
1208
1208
|
|
|
1209
1209
|
export function cloneComponent(component, propsPatch, ...children)
|
|
1210
1210
|
{
|
|
1211
|
-
return { entity: component.entity, props: {...component.props, ...propsPatch, children} };
|
|
1211
|
+
return { entity: component.entity, props: {...component.props, ...propsPatch, children}, [CORE]: null };
|
|
1212
1212
|
}
|
|
1213
1213
|
|
|
1214
1214
|
export const cloneElement = cloneComponent;
|
|
@@ -1247,7 +1247,7 @@ export function memo(component)
|
|
|
1247
1247
|
component[MEMOIZED] = true;
|
|
1248
1248
|
}
|
|
1249
1249
|
else {
|
|
1250
|
-
component = { component, [MEMOIZED]: true };
|
|
1250
|
+
component = { component, [MEMOIZED]: true, [CORE]: null };
|
|
1251
1251
|
}
|
|
1252
1252
|
return component;
|
|
1253
1253
|
}
|
package/src/lilact.jsx
CHANGED
package/src/proptypes.jsx
CHANGED
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
+
import { isValidComponent } from "./misc.jsx";
|
|
32
|
+
|
|
33
|
+
|
|
31
34
|
function isNullOrUndefined(v) {
|
|
32
35
|
return v === null || v === undefined;
|
|
33
36
|
}
|
|
@@ -45,6 +48,28 @@ function defaultGetDisplayName(x) {
|
|
|
45
48
|
return x.displayName || x.name || "Unknown";
|
|
46
49
|
}
|
|
47
50
|
|
|
51
|
+
|
|
52
|
+
// ---- node validator ----
|
|
53
|
+
function isNode(x) {
|
|
54
|
+
// ignored-by-render children should be accepted by node
|
|
55
|
+
if (x === null || x === undefined) return true;
|
|
56
|
+
if (x === false || x === true) return true;
|
|
57
|
+
|
|
58
|
+
// primitives render
|
|
59
|
+
if (typeof x === "string" || typeof x === "number") return true;
|
|
60
|
+
|
|
61
|
+
if (isValidComponent(x)) return true;
|
|
62
|
+
|
|
63
|
+
// arrays are accepted as children; renderer will flatten later
|
|
64
|
+
if (Array.isArray(x)) return x.every(isNode);
|
|
65
|
+
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function isValidElementType(x) {
|
|
70
|
+
return typeof x === "function" || typeof x === "string";
|
|
71
|
+
}
|
|
72
|
+
|
|
48
73
|
/**
|
|
49
74
|
* Build a prop validator with a consistent contract:
|
|
50
75
|
* validator(props, propName, componentName, location, propFullName)
|
|
@@ -117,6 +142,19 @@ function createPropTypes() {
|
|
|
117
142
|
PropTypes.symbol = createPrimitiveValidator((v) => typeof v === "symbol");
|
|
118
143
|
PropTypes.symbol.expectedType = "symbol";
|
|
119
144
|
|
|
145
|
+
PropTypes.component = createPrimitiveValidator((v) => isValidComponent(v));
|
|
146
|
+
PropTypes.component.expectedType = "component";
|
|
147
|
+
|
|
148
|
+
PropTypes.element = createPrimitiveValidator((v) => isValidComponent(v));
|
|
149
|
+
PropTypes.element.expectedType = "element";
|
|
150
|
+
|
|
151
|
+
PropTypes.node = createPrimitiveValidator((v) => isNode(v));
|
|
152
|
+
PropTypes.node.expectedType = "node";
|
|
153
|
+
|
|
154
|
+
PropTypes.elementType = createPrimitiveValidator((v) => isValidElementType(v));
|
|
155
|
+
PropTypes.elementType.expectedType = "elementType";
|
|
156
|
+
|
|
157
|
+
|
|
120
158
|
// ----- combinators -----
|
|
121
159
|
|
|
122
160
|
PropTypes.oneOf = function oneOf(values) {
|