lilact 0.16.3 → 0.18.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 (70) hide show
  1. package/dist/lilact.development.js +227 -151
  2. package/dist/lilact.development.js.map +3 -3
  3. package/dist/lilact.development.min.js +20 -20
  4. package/dist/lilact.development.min.js.map +3 -3
  5. package/dist/lilact.production.min.js +20 -20
  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.createRoot.html +1 -1
  16. package/docs/functions/components.memo.html +7 -0
  17. package/docs/functions/components.render.html +1 -1
  18. package/docs/functions/hooks.startTransition.html +6 -0
  19. package/docs/functions/hooks.useActionState.html +1 -1
  20. package/docs/functions/hooks.useDebugValue.html +5 -0
  21. package/docs/functions/hooks.useDeferredValue.html +1 -1
  22. package/docs/functions/hooks.useEffect.html +5 -4
  23. package/docs/functions/hooks.useImperativeHandle.html +1 -1
  24. package/docs/functions/hooks.useInsertionEffect.html +6 -0
  25. package/docs/functions/hooks.useLayoutEffect.html +3 -2
  26. package/docs/functions/hooks.useMemo.html +3 -2
  27. package/docs/functions/hooks.useReducer.html +1 -1
  28. package/docs/functions/misc.Fragment.html +2 -2
  29. package/docs/functions/misc.deepEqual.html +1 -1
  30. package/docs/functions/misc.findDOMNode.html +1 -1
  31. package/docs/functions/misc.forwardRef.html +1 -1
  32. package/docs/functions/misc.getComponentByPointer.html +1 -1
  33. package/docs/functions/misc.isAsync.html +1 -1
  34. package/docs/functions/misc.isClass.html +1 -1
  35. package/docs/functions/misc.isEmpty.html +1 -1
  36. package/docs/functions/misc.isError.html +1 -1
  37. package/docs/functions/misc.isThenable.html +1 -1
  38. package/docs/functions/{misc.isValidElement.html → misc.isValidComponent.html} +1 -1
  39. package/docs/functions/misc.shallowEqual.html +3 -2
  40. package/docs/functions/misc.toBool.html +1 -1
  41. package/docs/functions/timers.timeoutPromise.html +10 -7
  42. package/docs/hierarchy.html +1 -1
  43. package/docs/modules/components.html +1 -1
  44. package/docs/modules/hooks.html +1 -1
  45. package/docs/modules/misc.html +1 -1
  46. package/docs/static/demos/actionstate.jsx +2 -2
  47. package/docs/static/demos/memo.jsx +26 -0
  48. package/docs/static/demos/priorities.jsx +68 -0
  49. package/docs/static/index.html +3 -1
  50. package/docs/static/lilact.development.js +227 -151
  51. package/docs/static/lilact.development.js.map +3 -3
  52. package/docs/static/lilact.development.min.js +20 -20
  53. package/docs/static/lilact.development.min.js.map +3 -3
  54. package/docs/static/lilact.production.min.js +20 -20
  55. package/docs/variables/misc.Children.html +2 -2
  56. package/docs/variables/misc.isValidElement.html +7 -0
  57. package/examples/demos/actionstate.jsx +2 -2
  58. package/examples/demos/memo.jsx +26 -0
  59. package/examples/demos/priorities.jsx +68 -0
  60. package/examples/index.html +3 -1
  61. package/examples/lilact.development.js +227 -151
  62. package/examples/lilact.development.js.map +3 -3
  63. package/examples/lilact.development.min.js +20 -20
  64. package/examples/lilact.development.min.js.map +3 -3
  65. package/examples/lilact.production.min.js +20 -20
  66. package/package.json +1 -1
  67. package/src/components.jsx +126 -40
  68. package/src/hooks.jsx +84 -11
  69. package/src/lilact.jsx +1 -1
  70. package/src/misc.jsx +13 -8
@@ -0,0 +1,7 @@
1
+ <!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>isValidElement | Lilact</title><meta name="description" content="Documentation for Lilact"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Lilact</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/misc.html">misc</a></li><li><a href="" aria-current="page">isValidElement</a></li></ul><h1>Variable isValidElement<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">isValidElement</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">value</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> = isValidComponent</span></div><div class="tsd-comment tsd-typography"><p>Checks whether a value is a Lilact component. It is the same as <code>isValidComponent</code>.</p>
2
+ </div><div class="tsd-type-declaration"><h4>Type Declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures"><li class="tsd-signature" id="__type"><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">value</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Checks whether a value is a Lilact component.</p>
3
+ </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">value</span>: <span class="tsd-signature-type">any</span></span><div class="tsd-comment tsd-typography"><p>Value to inspect.</p>
4
+ </div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><p>True if the value is a class component; otherwise false.</p>
5
+ </li></ul></li></ul></div><div class="tsd-comment tsd-typography"><div class="tsd-tag-param"><h4 class="tsd-anchor-link" id="param-value">Param: value<a href="#param-value" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>Value to inspect.</p>
6
+ </div><div class="tsd-tag-returns"><h4 class="tsd-anchor-link" id="returns">Returns<a href="#returns" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>True if the value is a class component; otherwise false.</p>
7
+ </div></div><aside class="tsd-sources"><ul><li>Defined in misc.jsx:67</li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">Lilact</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
@@ -1,4 +1,4 @@
1
- const { useActionState } = Lilact;
1
+ const { useActionState, Spinner } = Lilact;
2
2
 
3
3
  async function addToCart(prevState, queryData) {
4
4
 
@@ -23,7 +23,7 @@ function AddToCartForm({itemID, itemTitle}) {
23
23
  <h2>{itemTitle}</h2>
24
24
  <input type="hidden" name="itemID" value={itemID} />
25
25
  <button type="submit">Add to Cart </button>
26
- {isPending ? "Loading..." : message}
26
+ {isPending ? <Spinner size={24} style={ {display:"inline-block", transform: "translateY(7px)", width:24}}/> : message}
27
27
  </form>
28
28
  );
29
29
  }
@@ -0,0 +1,26 @@
1
+ const { useState, memo } = Lilact;
2
+
3
+ const Child = memo(function Child({ count }) {
4
+ console.log("Child render. count =", count);
5
+ return <div>Child count: {count}</div>;
6
+ });
7
+
8
+ module.exports = function Demo() {
9
+ const [tick, setTick] = useState(0);
10
+ const [count] = useState(5); // never changes
11
+
12
+ return (
13
+ <div>
14
+ <p>This is a demonstration of `memo`. When the button is pressed the parent div is updated but as the count
15
+ is not changed the Child does not update, so its render is only logged once.
16
+ </p>
17
+ <center>
18
+ <button onClick={() => setTick(tick + 1)}>Parent re-render</button>
19
+ <div>Tick: {tick}</div>
20
+
21
+ {/* Parent updates, but count prop stays 5 */}
22
+ <Child count={count} />
23
+ </center>
24
+ </div>
25
+ );
26
+ }
@@ -0,0 +1,68 @@
1
+ const {useEffect, useLayoutEffect, useInsertionEffect, useState, startTransition} = Lilact;
2
+
3
+ function Demo() {
4
+ const [n, setN] = useState(0);
5
+
6
+ // Runs during render-triggered commit, before layout effects, before paint
7
+ useInsertionEffect(() => {
8
+ console.log("insertionEffect", n);
9
+ }, [n]);
10
+
11
+ // Runs after insertion effects, before paint
12
+ useLayoutEffect(() => {
13
+ console.log("layoutEffect", n);
14
+ }, [n]);
15
+
16
+ // Runs after paint (passive)
17
+ useEffect(() => {
18
+ console.log("passiveEffect", n);
19
+ }, [n]);
20
+
21
+ console.log("render", n);
22
+
23
+ return (<>
24
+ <button
25
+ onClick={() => {
26
+ console.log("click handler: start");
27
+ startTransition(() => {
28
+ console.log("startTransition callback: before setN");
29
+ setN(x => x + 1);
30
+ console.log("startTransition callback: after setN");
31
+ });
32
+ console.log("click handler: end");
33
+ }}
34
+ >
35
+ Trigger
36
+ </button>
37
+ <p>
38
+ Expected console output (typical behavior)<br/>
39
+ <br/>
40
+ When you click the button once, you should see this pattern (note the “render”/commit/effects ordering):<br/>
41
+ <br/>
42
+ Initial mount (before any click)<br/>
43
+ <br/>
44
+ render 0<br/>
45
+ insertionEffect 0<br/>
46
+ layoutEffect 0<br/>
47
+ (after paint) passiveEffect 0<br/>
48
+ <br/>
49
+ After the click (startTransition schedules the update)<br/>
50
+ <br/>
51
+ click handler: start<br/>
52
+ startTransition callback: before setN<br/>
53
+ startTransition callback: after setN<br/>
54
+ click handler: end<br/>
55
+ <br/>
56
+ Commit for the transition update (n becomes 1)<br/>
57
+ <br/>
58
+ render 1<br/>
59
+ insertionEffect 1<br/>
60
+ layoutEffect 1<br/>
61
+ (after paint) passiveEffect 1<br/>
62
+ <br/>
63
+ </p>
64
+
65
+ </>);
66
+ }
67
+
68
+ module.exports = Demo;
@@ -214,7 +214,7 @@ function App()
214
214
  const demos =[
215
215
  "Hooks",
216
216
  ['stopwatch.jsx', '( useState, useRef )'],
217
- ['actionstate.jsx', '( useActionState, useState )'],
217
+ ['actionstate.jsx', '( useActionState, Spinner )'],
218
218
  ['usedefered.jsx', '( useState, useDeferredValue )'],
219
219
  ['usetransition.jsx', '( useTransition, useState, useCallback, useId ), emotion:( css, cx )'],
220
220
  ['reducer.jsx', '( useReducer )'],
@@ -222,7 +222,9 @@ function App()
222
222
 
223
223
  "API",
224
224
  ['capture.jsx', '-- Event Capture and Bubble --'],
225
+ ['priorities.jsx', '-- Effect Priorities --'],
225
226
  ['forwardref.jsx', '( forwardRef, useImperativeHandle, useRef )'],
227
+ ['memo.jsx', '( memo, useState )'],
226
228
  ['lazy.jsx', '( lazy, require, Suspene, Spinner )'],
227
229
  ['proptypes.jsx', '( PropTypes )'],
228
230
  ['redux.jsx', '( Provider, useSelector, useDispatch, connect ), redux:( createStore )'],