lilact 0.23.1 → 0.24.1
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 +17 -1
- package/dist/lilact.development.js +485 -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 +25 -25
- package/docs/assets/hierarchy.js +1 -1
- package/docs/classes/accessories.ErrorBoundary.html +8 -8
- package/docs/classes/accessories.Suspense.html +7 -7
- package/docs/classes/components.Component.html +11 -11
- package/docs/classes/components.HTMLComponent.html +11 -11
- package/docs/classes/components.RootComponent.html +11 -11
- package/docs/functions/components.cloneComponent.html +1 -1
- package/docs/functions/components.createComponent.html +1 -1
- package/docs/functions/components.createPortal.html +1 -1
- package/docs/functions/components.createRoot.html +1 -1
- package/docs/functions/components.memo.html +1 -1
- package/docs/functions/components.render.html +1 -1
- package/docs/functions/timers.timeoutPromise.html +4 -4
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +18 -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 +2 -2
- package/docs/static/lilact.development.js +485 -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 +25 -25
- 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 +2 -2
- package/examples/lilact.development.js +485 -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 +25 -25
- package/package.json +1 -1
- package/src/components.jsx +11 -4
- package/src/lilact.jsx +1 -1
- package/src/proptypes.jsx +38 -0
- package/impexptest.js +0 -51
package/package.json
CHANGED
package/src/components.jsx
CHANGED
|
@@ -35,6 +35,8 @@ import { shallowEqual, toBool, isClass } from "./misc.jsx";
|
|
|
35
35
|
|
|
36
36
|
import { PropTypes } from './proptypes.jsx';
|
|
37
37
|
|
|
38
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
39
|
+
|
|
38
40
|
/*
|
|
39
41
|
ComponentCache is for internal use. It is the heart of the JSX runtime,
|
|
40
42
|
it holds child components and detects which one is being rendered or updated.
|
|
@@ -210,7 +212,12 @@ if(DEBUG) {
|
|
|
210
212
|
|
|
211
213
|
if( typeof(this.entity)==='string' ) {
|
|
212
214
|
if(!(this.element instanceof Element)) {
|
|
213
|
-
this.
|
|
215
|
+
if(this.parent.entity==='svg' || this.entity==='svg') {
|
|
216
|
+
this.element = document.createElementNS(SVG_NS, this.entity);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
this.element = document.createElement(this.entity);
|
|
220
|
+
}
|
|
214
221
|
if(next_props?.defaultValue) this.element.value = String(next_props.defaultValue).slice(0, next_props?.maxLength);
|
|
215
222
|
if(next_props?.defaultChecked) this.element.checked = next_props.defaultChecked;
|
|
216
223
|
}
|
|
@@ -1142,7 +1149,7 @@ export function createComponent(entity, props={}, ...children)
|
|
|
1142
1149
|
props.key = generateComponentKey(entity, props);
|
|
1143
1150
|
props.children = children;
|
|
1144
1151
|
|
|
1145
|
-
return { entity, props };
|
|
1152
|
+
return { entity, props, [CORE]: null };
|
|
1146
1153
|
}
|
|
1147
1154
|
|
|
1148
1155
|
/**
|
|
@@ -1208,7 +1215,7 @@ export function createPortal(children, element)
|
|
|
1208
1215
|
|
|
1209
1216
|
export function cloneComponent(component, propsPatch, ...children)
|
|
1210
1217
|
{
|
|
1211
|
-
return { entity: component.entity, props: {...component.props, ...propsPatch, children} };
|
|
1218
|
+
return { entity: component.entity, props: {...component.props, ...propsPatch, children}, [CORE]: null };
|
|
1212
1219
|
}
|
|
1213
1220
|
|
|
1214
1221
|
export const cloneElement = cloneComponent;
|
|
@@ -1247,7 +1254,7 @@ export function memo(component)
|
|
|
1247
1254
|
component[MEMOIZED] = true;
|
|
1248
1255
|
}
|
|
1249
1256
|
else {
|
|
1250
|
-
component = { component, [MEMOIZED]: true };
|
|
1257
|
+
component = { component, [MEMOIZED]: true, [CORE]: null };
|
|
1251
1258
|
}
|
|
1252
1259
|
return component;
|
|
1253
1260
|
}
|
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) {
|
package/impexptest.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Imports
|
|
2
|
-
import foo from "foo";
|
|
3
|
-
import { a, b } from "foo";
|
|
4
|
-
import {a as alpha, b as beta} from "foo";
|
|
5
|
-
import * as utils from "foo";
|
|
6
|
-
import foo, { a, b as c, d } from "foo";
|
|
7
|
-
import "foo";
|
|
8
|
-
|
|
9
|
-
// Re-exports from other modules
|
|
10
|
-
export * from "foo";
|
|
11
|
-
export { a, b } from "foo";
|
|
12
|
-
export { default as Foo } from "foo";
|
|
13
|
-
|
|
14
|
-
export * from "./some-module.js";
|
|
15
|
-
export { exportedThing } from "./another-module.js";
|
|
16
|
-
export { default as depDefault } from "./yet-another-module.js";
|
|
17
|
-
export { default as depDefault, a, b, c as depC } from "./...";
|
|
18
|
-
|
|
19
|
-
// Default export forms
|
|
20
|
-
const defaultValue = { ok: true };
|
|
21
|
-
export default defaultValue;
|
|
22
|
-
|
|
23
|
-
export default function defaultFn() {
|
|
24
|
-
return "defaultFn";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default class DefaultClass {
|
|
28
|
-
constructor() {}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export {localA as a, localB as b, localC as c};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export { localFn as renamedFn };
|
|
36
|
-
|
|
37
|
-
// Additional named exports (declared bindings)
|
|
38
|
-
export const namedConst = 1;
|
|
39
|
-
export let namedLet = 2;
|
|
40
|
-
export var namedVar = 3;
|
|
41
|
-
|
|
42
|
-
export function namedFn() {
|
|
43
|
-
return "namedFn";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export class NamedClass {}
|
|
48
|
-
|
|
49
|
-
// Re-exporting local bindings is OK (examples)
|
|
50
|
-
export defaultValue;
|
|
51
|
-
export { defaultValue };
|