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.
Files changed (37) hide show
  1. package/README.md +15 -1
  2. package/dist/lilact.development.js +480 -461
  3. package/dist/lilact.development.js.map +4 -4
  4. package/dist/lilact.development.min.js +24 -24
  5. package/dist/lilact.development.min.js.map +4 -4
  6. package/dist/lilact.production.min.js +24 -24
  7. package/docs/assets/hierarchy.js +1 -1
  8. package/docs/classes/components.Component.html +1 -1
  9. package/docs/classes/components.HTMLComponent.html +1 -1
  10. package/docs/classes/components.RootComponent.html +1 -1
  11. package/docs/functions/components.cloneComponent.html +1 -1
  12. package/docs/functions/timers.timeoutPromise.html +4 -4
  13. package/docs/hierarchy.html +1 -1
  14. package/docs/index.html +17 -1
  15. package/docs/static/demos/cloneelement.jsx +6 -0
  16. package/docs/static/demos/lazy.jsx +1 -1
  17. package/docs/static/demos/legacy-context.jsx +0 -7
  18. package/docs/static/index.html +1 -1
  19. package/docs/static/lilact.development.js +480 -461
  20. package/docs/static/lilact.development.js.map +4 -4
  21. package/docs/static/lilact.development.min.js +24 -24
  22. package/docs/static/lilact.development.min.js.map +4 -4
  23. package/docs/static/lilact.production.min.js +24 -24
  24. package/docs/variables/components.cloneElement.html +1 -1
  25. package/examples/demos/cloneelement.jsx +6 -0
  26. package/examples/demos/lazy.jsx +1 -1
  27. package/examples/demos/legacy-context.jsx +0 -7
  28. package/examples/index.html +1 -1
  29. package/examples/lilact.development.js +480 -461
  30. package/examples/lilact.development.js.map +4 -4
  31. package/examples/lilact.development.min.js +24 -24
  32. package/examples/lilact.development.min.js.map +4 -4
  33. package/examples/lilact.production.min.js +24 -24
  34. package/package.json +1 -1
  35. package/src/components.jsx +3 -3
  36. package/src/lilact.jsx +1 -1
  37. package/src/proptypes.jsx +38 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lilact",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "description": "A Little React/JSX Runtime Implementation for Browser",
5
5
  "repository": "github:arashkazemi/lilact",
6
6
  "homepage": "https://arashkazemi.github.io/lilact/",
@@ -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
@@ -92,7 +92,7 @@ export {transpileJSX, transpilerConfig} from "./jsx";
92
92
  export const Lilact =
93
93
  {
94
94
 
95
- VERSION: "beta.23",
95
+ VERSION: "RC.1",
96
96
 
97
97
  // Configuration
98
98
 
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) {