lilact 0.18.0 → 0.19.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 (53) hide show
  1. package/dist/lilact.development.js +34 -9
  2. package/dist/lilact.development.js.map +3 -3
  3. package/dist/lilact.development.min.js +16 -16
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +17 -17
  6. package/docs/assets/hierarchy.js +1 -1
  7. package/docs/assets/navigation.js +1 -1
  8. package/docs/assets/search.js +1 -1
  9. package/docs/classes/accessories.ErrorBoundary.html +8 -8
  10. package/docs/classes/accessories.Suspense.html +7 -7
  11. package/docs/classes/components.Component.html +11 -11
  12. package/docs/classes/components.HTMLComponent.html +11 -11
  13. package/docs/classes/components.RootComponent.html +11 -11
  14. package/docs/functions/components.createComponent.html +1 -1
  15. package/docs/functions/components.createPortal.html +11 -0
  16. package/docs/functions/components.createRoot.html +1 -1
  17. package/docs/functions/components.memo.html +1 -1
  18. package/docs/functions/components.render.html +1 -1
  19. package/docs/functions/misc.Fragment.html +1 -1
  20. package/docs/functions/misc.Portal.html +4 -0
  21. package/docs/functions/misc.deepEqual.html +1 -1
  22. package/docs/functions/misc.forwardRef.html +1 -1
  23. package/docs/functions/misc.getComponentByPointer.html +1 -1
  24. package/docs/functions/misc.isAsync.html +1 -1
  25. package/docs/functions/misc.isClass.html +1 -1
  26. package/docs/functions/misc.isEmpty.html +1 -1
  27. package/docs/functions/misc.isError.html +1 -1
  28. package/docs/functions/misc.isThenable.html +1 -1
  29. package/docs/functions/misc.shallowEqual.html +1 -1
  30. package/docs/functions/misc.toBool.html +1 -1
  31. package/docs/functions/timers.timeoutPromise.html +4 -5
  32. package/docs/hierarchy.html +1 -1
  33. package/docs/modules/components.html +1 -1
  34. package/docs/modules/misc.html +1 -1
  35. package/docs/static/demos/portal.jsx +56 -0
  36. package/docs/static/index.html +6 -2
  37. package/docs/static/lilact.development.js +34 -9
  38. package/docs/static/lilact.development.js.map +3 -3
  39. package/docs/static/lilact.development.min.js +16 -16
  40. package/docs/static/lilact.development.min.js.map +3 -3
  41. package/docs/static/lilact.production.min.js +17 -17
  42. package/docs/variables/misc.Children.html +2 -2
  43. package/examples/demos/portal.jsx +56 -0
  44. package/examples/index.html +6 -2
  45. package/examples/lilact.development.js +34 -9
  46. package/examples/lilact.development.js.map +3 -3
  47. package/examples/lilact.development.min.js +16 -16
  48. package/examples/lilact.development.min.js.map +3 -3
  49. package/examples/lilact.production.min.js +17 -17
  50. package/package.json +1 -1
  51. package/src/components.jsx +46 -9
  52. package/src/lilact.jsx +1 -1
  53. package/src/misc.jsx +18 -1
@@ -1975,6 +1975,7 @@ __export(components_exports, {
1975
1975
  capture_events_set: () => capture_events_set,
1976
1976
  createComponent: () => createComponent2,
1977
1977
  createElement: () => createElement,
1978
+ createPortal: () => createPortal,
1978
1979
  createRoot: () => createRoot,
1979
1980
  current_component: () => current_component,
1980
1981
  effect_timeout: () => effect_timeout,
@@ -2032,6 +2033,7 @@ var misc_exports = {};
2032
2033
  __export(misc_exports, {
2033
2034
  Children: () => Children,
2034
2035
  Fragment: () => Fragment2,
2036
+ Portal: () => Portal,
2035
2037
  deepEqual: () => deepEqual,
2036
2038
  eval_num: () => eval_num,
2037
2039
  findDOMNode: () => findDOMNode,
@@ -2063,10 +2065,15 @@ var findDOMNode = (component) => {
2063
2065
  if (!((_b = (_a = component[CORE]) == null ? void 0 : _a.element) == null ? void 0 : _b.parentNode)) throw new Error("findDOMNode only works on mounted components.");
2064
2066
  return component[CORE].element;
2065
2067
  };
2066
- var Fragment2 = function({ children }) {
2068
+ function Fragment2({ children }) {
2067
2069
  return children;
2068
- };
2070
+ }
2069
2071
  Fragment2.displayName = "Fragment";
2072
+ function Portal({ children, view }) {
2073
+ this[CORE].portal = view;
2074
+ return children;
2075
+ }
2076
+ Portal.displayName = "Portal";
2070
2077
  var Children = {
2071
2078
  /**
2072
2079
  * Returns the only child from a children collection.
@@ -2246,7 +2253,7 @@ var ComponentCache = class {
2246
2253
  arr.slice(arr[IDX]).forEach((ex) => {
2247
2254
  if (ex.cleanup) {
2248
2255
  ex.cleanup();
2249
- } else if (ex.element) {
2256
+ } else if (ex.element && !ex.portal) {
2250
2257
  ex.element.parentElement.removeChild(ex.element);
2251
2258
  }
2252
2259
  });
@@ -2356,6 +2363,9 @@ var ComponentCore = class {
2356
2363
  renderErrorHandler(this, e);
2357
2364
  }
2358
2365
  }
2366
+ if (this == null ? void 0 : this.portal) {
2367
+ this.element = this.portal;
2368
+ }
2359
2369
  if (((_e = (_d = this.outlet) == null ? void 0 : _d.constructor) == null ? void 0 : _e.name) !== "Array") {
2360
2370
  this.outlet = [this.outlet];
2361
2371
  }
@@ -2411,7 +2421,7 @@ var ComponentCore = class {
2411
2421
  if (this.component.componentWillUnmount) {
2412
2422
  this.component.componentWillUnmount();
2413
2423
  }
2414
- if ((_b = this == null ? void 0 : this.element) == null ? void 0 : _b.parentElement) {
2424
+ if (((_b = this == null ? void 0 : this.element) == null ? void 0 : _b.parentElement) && !this.portal) {
2415
2425
  this.element.parentElement.removeChild(this.element);
2416
2426
  }
2417
2427
  if (this.outlet !== void 0) {
@@ -2559,6 +2569,7 @@ var ComponentCore = class {
2559
2569
  }
2560
2570
  appendElement(core) {
2561
2571
  var _a;
2572
+ if (core.portal) return;
2562
2573
  this.scanZombies(core.container, core.element);
2563
2574
  if ((core == null ? void 0 : core.element.parentNode) === null) {
2564
2575
  core.container.element.insertBefore(
@@ -2628,9 +2639,13 @@ function constructFunc(core, parent) {
2628
2639
  } else {
2629
2640
  let entity = core.entity;
2630
2641
  let memoized = false;
2631
- if (typeof entity === "object" && entity[MEMOIZED]) {
2632
- memoized = true;
2633
- entity = entity[MEMOIZED];
2642
+ if (typeof entity === "object") {
2643
+ if (entity[MEMOIZED]) {
2644
+ memoized = entity[MEMOIZED];
2645
+ entity = entity.component;
2646
+ } else {
2647
+ throw new Error("Invalid component.");
2648
+ }
2634
2649
  }
2635
2650
  if (typeof entity === "string") {
2636
2651
  comp = new HTMLComponent(entity, core.props);
@@ -2956,6 +2971,9 @@ function createRoot(element) {
2956
2971
  }
2957
2972
  };
2958
2973
  }
2974
+ function createPortal(children, element) {
2975
+ return createComponent2(lilact_default.Portal, { "view": element }, children);
2976
+ }
2959
2977
  function render(component, element) {
2960
2978
  if (component[CORE] && (component[CORE].container || component[CORE].parent)) {
2961
2979
  throw new Error("Component is already in use");
@@ -2963,7 +2981,12 @@ function render(component, element) {
2963
2981
  return createRoot(element).render(component);
2964
2982
  }
2965
2983
  function memo(component) {
2966
- return { [MEMOIZED]: component };
2984
+ if (typeof component === "object") {
2985
+ component[MEMOIZED] = true;
2986
+ } else {
2987
+ component = { component, [MEMOIZED]: true };
2988
+ }
2989
+ return component;
2967
2990
  }
2968
2991
  var createElement = createComponent2;
2969
2992
  var current_component = [];
@@ -5827,7 +5850,7 @@ function transpileJSX(jsx2, {
5827
5850
 
5828
5851
  // .tmp/src/lilact.jsx
5829
5852
  var Lilact2 = {
5830
- VERSION: "beta.18",
5853
+ VERSION: "beta.19",
5831
5854
  // Configuration
5832
5855
  defaultTransitionTimeout: 300,
5833
5856
  defaultIsEqual: Object.is,
@@ -5879,6 +5902,7 @@ export {
5879
5902
  Lilact2 as Lilact,
5880
5903
  Link,
5881
5904
  NavLink,
5905
+ Portal,
5882
5906
  PropTypes,
5883
5907
  Provider,
5884
5908
  RootComponent,
@@ -5902,6 +5926,7 @@ export {
5902
5926
  createComponent2 as createComponent,
5903
5927
  createContext,
5904
5928
  createElement,
5929
+ createPortal,
5905
5930
  createRoot,
5906
5931
  createSyntheticEvent,
5907
5932
  current_component,