lilact 0.0.0 → 0.2.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 (87) hide show
  1. package/README.md +13 -2
  2. package/dist/{lilact.development.js → lilact.development.min.js} +690 -315
  3. package/dist/lilact.development.min.js.LICENSE.txt +77 -0
  4. package/dist/lilact.development.min.js.map +1 -0
  5. package/dist/lilact.production.min.js +1 -1
  6. package/dist/lilact.production.min.js.map +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 +11 -10
  10. package/docs/classes/accessories.Suspense.html +12 -22
  11. package/docs/classes/components.Component.html +11 -10
  12. package/docs/classes/components.HTMLComponent.html +11 -10
  13. package/docs/classes/components.RootComponent.html +11 -10
  14. package/docs/functions/accessories.Spinner.html +1 -1
  15. package/docs/functions/components.createComponent.html +1 -1
  16. package/docs/functions/components.createRoot.html +1 -1
  17. package/docs/functions/components.render.html +1 -1
  18. package/docs/functions/hooks.createContext.html +1 -1
  19. package/docs/functions/hooks.forwardRef.html +4 -0
  20. package/docs/functions/hooks.useActionState.html +1 -1
  21. package/docs/functions/hooks.useImperativeHandle.html +7 -0
  22. package/docs/functions/hooks.useReducer.html +1 -1
  23. package/docs/functions/hooks.useState.html +2 -2
  24. package/docs/functions/hooks.useTransition.html +1 -1
  25. package/docs/functions/jsx.transpileJSX.html +1 -1
  26. package/docs/functions/run.lazy.html +7 -0
  27. package/docs/functions/run.require.html +11 -11
  28. package/docs/functions/run.run.html +3 -5
  29. package/docs/functions/run.runScripts.html +1 -1
  30. package/docs/functions/run.traceError.html +1 -1
  31. package/docs/functions/transition.CSSTransition.html +1 -1
  32. package/docs/functions/transition.Transition.html +15 -0
  33. package/docs/functions/transition.TransitionGroup.html +1 -1
  34. package/docs/index.html +8 -2
  35. package/docs/modules/hooks.html +1 -1
  36. package/docs/modules/jsx.html +1 -1
  37. package/docs/modules/run.html +1 -1
  38. package/docs/modules/transition.html +1 -1
  39. package/docs/static/demos/actionstate.jsx +5 -7
  40. package/docs/static/demos/context.jsx +2 -4
  41. package/docs/static/demos/css-transition.jsx +1 -1
  42. package/docs/static/demos/lazy.jsx +14 -0
  43. package/docs/static/demos/modal.jsx +14 -16
  44. package/docs/static/demos/proptypes.jsx +6 -9
  45. package/docs/static/demos/reducer.jsx +22 -24
  46. package/docs/static/demos/redux.jsx +1 -1
  47. package/docs/static/demos/router.jsx +1 -8
  48. package/docs/static/demos/stopwatch.jsx +1 -1
  49. package/docs/static/demos/suspense.jsx +5 -7
  50. package/docs/static/demos/transition.jsx +25 -25
  51. package/{root/demos/use-differed.jsx → docs/static/demos/use-deffered.jsx} +1 -1
  52. package/docs/static/demos/usetransition.jsx +2 -4
  53. package/docs/static/index 2.html +95 -0
  54. package/docs/static/index.html +27 -29
  55. package/docs/static/{lilact.development.js → lilact.development.min.js} +690 -315
  56. package/docs/static/lilact.production.min.js +1 -1
  57. package/package.json +2 -2
  58. package/root/demos/actionstate.jsx +5 -7
  59. package/root/demos/context.jsx +2 -4
  60. package/root/demos/css-transition.jsx +1 -1
  61. package/root/demos/lazy.jsx +14 -0
  62. package/root/demos/modal.jsx +14 -16
  63. package/root/demos/proptypes.jsx +6 -9
  64. package/root/demos/reducer.jsx +22 -24
  65. package/root/demos/redux.jsx +1 -1
  66. package/root/demos/router.jsx +1 -8
  67. package/root/demos/stopwatch.jsx +1 -1
  68. package/root/demos/suspense.jsx +5 -7
  69. package/root/demos/transition.jsx +25 -25
  70. package/{docs/static/demos/use-differed.jsx → root/demos/use-deffered.jsx} +1 -1
  71. package/root/demos/usetransition.jsx +2 -4
  72. package/root/index 2.html +95 -0
  73. package/root/index.html +27 -29
  74. package/root/{lilact.development.js → lilact.development.min.js} +690 -315
  75. package/root/lilact.production.min.js +1 -1
  76. package/src/accessories.jsx +12 -11
  77. package/src/components.jsx +11 -5
  78. package/src/hooks.jsx +47 -6
  79. package/src/jsx.js +1 -0
  80. package/src/lilact.jsx +5 -7
  81. package/src/pane.jsx +287 -0
  82. package/src/run.jsx +91 -43
  83. package/src/transition.jsx +32 -21
  84. package/webpack.config.js +2 -12
  85. package/dist/lilact.development.js.map +0 -1
  86. package/docs/classes/transition.Transition.html +0 -31
  87. package/docs/variables/jsx.transpilerConfig.html +0 -1
@@ -1,4 +1,4 @@
1
- const { PropTypes, createRoot } = Lilact;
1
+ const { PropTypes } = Lilact;
2
2
 
3
3
  function UserCard({ name, age, tags, onClick }) {
4
4
  return (
@@ -23,15 +23,12 @@ UserCard.defaultProps = {
23
23
  onClick: () => {},
24
24
  };
25
25
 
26
- /* App render */
27
26
  function Demo() {
28
- return (
29
- <div><p>Check your browser console to see the logs.</p>
30
- <UserCard name="Alex" age={29} tags={['react','js']} />
31
- {/* Missing name -> will warn in dev console */}
32
- <UserCard age={"not-a-number"} />
33
- </div>
34
- );
27
+ return <div><p>Check your browser console to see the logs.</p>
28
+ <UserCard name="Alex" age={29} tags={['react','js']} />
29
+ {/* Missing name -> will warn in dev console */}
30
+ <UserCard age={"not-a-number"} />
31
+ </div>
35
32
  }
36
33
 
37
34
  module.exports = Demo;
@@ -1,4 +1,4 @@
1
- const { useReducer, render } = Lilact;
1
+ const { useReducer } = Lilact;
2
2
 
3
3
  function createInitialState(username) {
4
4
  const initialTodos = [];
@@ -43,29 +43,27 @@ function Demo({ username })
43
43
  username,
44
44
  createInitialState
45
45
  );
46
- return (
47
- <>
48
- <input
49
- value={state.draft}
50
- onChange={e => {
51
- dispatch({
52
- type: 'changed_draft',
53
- nextDraft: e.target.value
54
- })
55
- }}
56
- />
57
- <button onClick={() => {
58
- dispatch({ type: 'added_todo' });
59
- }}>Add</button>
60
- <ul>
61
- {state.todos.map(item => (
62
- <li key={item.id}>
63
- {item.text}
64
- </li>
65
- ))}
66
- </ul>
67
- </>
68
- );
46
+ return <>
47
+ <input
48
+ value={state.draft}
49
+ onChange={e => {
50
+ dispatch({
51
+ type: 'changed_draft',
52
+ nextDraft: e.target.value
53
+ })
54
+ }}
55
+ />
56
+ <button onClick={() => {
57
+ dispatch({ type: 'added_todo' });
58
+ }}>Add</button>
59
+ <ul>
60
+ {state.todos.map(item => (
61
+ <li key={item.id}>
62
+ {item.text}
63
+ </li>
64
+ ))}
65
+ </ul>
66
+ </>
69
67
  }
70
68
 
71
69
  module.exports = Demo;
@@ -1,4 +1,4 @@
1
- const { Provider, useSelector, useDispatch, connect, render } = Lilact;
1
+ const { Provider, useSelector, useDispatch, connect } = Lilact;
2
2
  const { createStore } = Lilact.redux;
3
3
 
4
4
  // Reducer + store
@@ -1,11 +1,4 @@
1
- const { createRoot,HashRouter,
2
- NavLink,
3
- Routes,
4
- Route,
5
- useNavigate,
6
- useLocation,
7
- useState
8
- } = Lilact;
1
+ const { HashRouter, NavLink, Routes, Route, useNavigate, useLocation } = Lilact;
9
2
 
10
3
  /* Simple pages */
11
4
  function Home() {
@@ -1,4 +1,4 @@
1
- const { useState, useRef, render } = Lilact;
1
+ const { useState, useRef } = Lilact;
2
2
 
3
3
  function Demo()
4
4
  {
@@ -1,4 +1,4 @@
1
- const {Suspense, Spinner} = Lilact;
1
+ const { Suspense, Spinner } = Lilact;
2
2
 
3
3
  // resource factory that throws its internal promise until resolved
4
4
  function createResource(delay, value) {
@@ -36,12 +36,10 @@ function Child2() {
36
36
  }
37
37
 
38
38
  function Demo() {
39
- return (
40
- <Suspense minDelay={200} minShowTime={400} fallback={<Spinner/>}>
41
- <Child1 />
42
- <Child2 />
43
- </Suspense>
44
- );
39
+ return <Suspense minDelay={200} minShowTime={400} fallback={<Spinner/>}>
40
+ <Child1 />
41
+ <Child2 />
42
+ </Suspense>
45
43
  }
46
44
 
47
45
 
@@ -8,33 +8,33 @@ function Demo() {
8
8
  };
9
9
 
10
10
  return <>
11
- <p>See the console for logs.</p>
12
- <div>
13
- <button onClick={toggleVisibility}>
14
- {inProp ? 'Hide Component' : 'Show Component'}
15
- </button>
16
- <Transition
17
- in={inProp}
18
- timeout={1000}
19
- mountOnEnter={false}
20
- onEnter={() => console.log('Enter')}
21
- onExit={() => console.log('Exit')}
22
- onEntering={() => console.log('Entering')}
23
- onExiting={() => console.log('Exiting')}
24
- onEntered={() => console.log('Entered')}
25
- onExited={() => console.log('Exited')}
26
- >
27
- {(state) => (
11
+ <p>See the console for logs.</p>
28
12
  <div>
29
- {state === 'entering' && <p>Hello, World! (Entering)</p>}
30
- {state === 'exiting' && <p>Hello, World! (Exiting)</p>}
31
- {state === 'entered' && <p>Hello, World! (Visible)</p>}
32
- {state === 'exited' && <p>Hello, World! (Hidden)</p>}
13
+ <button onClick={toggleVisibility}>
14
+ {inProp ? 'Hide Component' : 'Show Component'}
15
+ </button>
16
+ <Transition
17
+ in={inProp}
18
+ timeout={1000}
19
+ mountOnEnter={false}
20
+ onEnter={() => console.log('Enter')}
21
+ onExit={() => console.log('Exit')}
22
+ onEntering={() => console.log('Entering')}
23
+ onExiting={() => console.log('Exiting')}
24
+ onEntered={() => console.log('Entered')}
25
+ onExited={() => console.log('Exited')}
26
+ >
27
+ {(state) => (
28
+ <div>
29
+ {state === 'entering' && <p>Hello, World! (Entering)</p>}
30
+ {state === 'exiting' && <p>Hello, World! (Exiting)</p>}
31
+ {state === 'entered' && <p>Hello, World! (Visible)</p>}
32
+ {state === 'exited' && <p>Hello, World! (Hidden)</p>}
33
+ </div>
34
+ )}
35
+ </Transition>
33
36
  </div>
34
- )}
35
- </Transition>
36
- </div>
37
- </>;
37
+ </>;
38
38
  };
39
39
 
40
40
  module.exports = Demo;
@@ -1,4 +1,4 @@
1
- const { useState, useDeferredValue, render } = Lilact;
1
+ const { useState, useDeferredValue } = Lilact;
2
2
 
3
3
  function ExpensiveList({ query }) {
4
4
  const items = Array.from({ length: 5000 }, (_, i) => `${query} item ${i}`);
@@ -1,4 +1,4 @@
1
- const { useTransition, useState, useCallback, useId, render } = Lilact;
1
+ const { useTransition, useState, useCallback, useId } = Lilact;
2
2
  const { css, cx } = Lilact.emotion;
3
3
 
4
4
  const Demo = ()=>{
@@ -24,13 +24,11 @@ const Demo = ()=>{
24
24
  } )
25
25
  }, [] );
26
26
  return (
27
-
28
27
  <div className={css({background:bg})}>
29
- <h4>{id}</h4>
28
+ <h4>{id}</h4>
30
29
  {isPending? <b>PENDING...</b> : <i>NOT PENDING</i>}
31
30
  <button onclick={startCB}>START CB</button>
32
31
  </div>
33
-
34
32
  );
35
33
  };
36
34
 
@@ -0,0 +1,95 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>Lilact Demo</title>
6
+ <script src='./lilact.development.min.js' type="module"></script>
7
+
8
+ <script src="prismjs/prism.min.js"></script>
9
+ <script src="prismjs/prism-jsx.min.js"></script>
10
+ <link rel="stylesheet" href="prismjs/prism.min.css">
11
+
12
+ </head>
13
+
14
+ <body></body>
15
+
16
+ <script type='text/jsx'>
17
+
18
+ const { useRef, useEffect, useState, Suspense, Spinner, run, render, lazy, require } = Lilact;
19
+ const { css,cx,injectGlobal } = Lilact.emotion;
20
+
21
+
22
+
23
+ injectGlobal({"*:not(code):not(code *)" : {fontFamily: "Ubuntu, 'Segoe UI', 'Noto Sans', helvetica, sans", fontSize: "14px"}});
24
+
25
+
26
+ injectGlobal({ code: { whiteSpace: "pre !important",
27
+ padding: "10px 0",
28
+ fontSize: "14px !important",
29
+ display: "block",
30
+ overflowWrap: "anywhere" }
31
+ });
32
+
33
+ const outer = css({
34
+ display: "flex",
35
+ flexDirection: "row",
36
+ gap: 2,
37
+ alignItems: "stretch",
38
+ width: "100%",
39
+ });
40
+
41
+ const collapsible = css({
42
+ width: "100%",
43
+ display: "block",
44
+ fontSize: "16px",
45
+ border: "1px solid #888",
46
+ padding: "5px"
47
+ });
48
+
49
+ const responsiveOuter = css({
50
+ "@media (max-width: 600px)": {
51
+ flexDirection: "column",
52
+ },
53
+ });
54
+
55
+ const pane = css({ flex: "1 1 0",
56
+ border: "1px solid",
57
+ height: "400px",
58
+ minHeight: "400px",
59
+ overflowY: "auto",
60
+ padding: "10px"
61
+ });
62
+
63
+ const left = css({ float: "left" });
64
+ const right = css({ float: "right" });
65
+
66
+
67
+
68
+ const Mod = lazy( ()=>require('demos/stopwatch.jsx') );
69
+
70
+ function DemoBlock({file})
71
+ {
72
+ return <>
73
+ <div>
74
+ <Suspense fallback={<Spinner/>}>
75
+ <Mod/>
76
+ </Suspense>
77
+ </div>
78
+ </>
79
+ ;
80
+ }
81
+
82
+
83
+ function App()
84
+ {
85
+
86
+ return <>
87
+ <DemoBlock/>
88
+ </>
89
+ }
90
+
91
+ render(<App/>, document.body);
92
+
93
+ </script>
94
+
95
+ </html>
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8"/>
5
5
  <title>Lilact Demo</title>
6
- <script src='./lilact.development.js' type="module"></script>
6
+ <script src='./lilact.development.min.js' type="module"></script>
7
7
 
8
8
  <script src="prismjs/prism.min.js"></script>
9
9
  <script src="prismjs/prism-jsx.min.js"></script>
@@ -68,15 +68,6 @@ injectGlobal({ code: { whiteSpace: "pre !important",
68
68
  overflowWrap: "anywhere" }
69
69
  });
70
70
 
71
-
72
- injectGlobal({ code: { whiteSpace: "pre !important",
73
- padding: "10px 0",
74
- fontSize: "14px !important",
75
- display: "block",
76
- overflowWrap: "anywhere" }
77
- });
78
-
79
-
80
71
  const outer = css({
81
72
  display: "flex",
82
73
  flexDirection: "row",
@@ -88,7 +79,9 @@ const outer = css({
88
79
  const collapsible = css({
89
80
  width: "100%",
90
81
  display: "block",
91
- fontSize: "16px"
82
+ fontSize: "16px",
83
+ border: "1px solid #888",
84
+ padding: "5px"
92
85
  });
93
86
 
94
87
  const responsiveOuter = css({
@@ -105,6 +98,9 @@ const pane = css({ flex: "1 1 0",
105
98
  padding: "10px"
106
99
  });
107
100
 
101
+ const left = css({ float: "left" });
102
+ const right = css({ float: "right" });
103
+
108
104
 
109
105
 
110
106
  function DemoView({ file })
@@ -114,7 +110,7 @@ function DemoView({ file })
114
110
  const viewRef = useRef();
115
111
  const codeRef = useRef();
116
112
 
117
- const resource = createResource("./demos/"+file);
113
+ const resource = createResource("./demos/"+file[0]);
118
114
  const code = resource.read(); // Suspense will handle the promise
119
115
 
120
116
  if(isOpen) {
@@ -130,13 +126,14 @@ function DemoView({ file })
130
126
 
131
127
  return <>
132
128
  <button onClick={()=>setOpen(!isOpen)} className={collapsible}>
133
- {(isOpen?'- ':'+ ')+file}
129
+ <span className={left}>{ (isOpen?'- ':'+ ') + file[0] + ' '}</span>
130
+ <b className={right}>{file[1]}</b>
134
131
  </button>
135
132
  {isOpen &&
136
133
  <div style={{width:"100%"}}>
137
134
  <div className={cx(responsiveOuter,outer)}>
138
135
  <div className={pane} style={{background:"#f5f2f0"}}>
139
- <code className="language-jsx" ref={codeRef}>{code}</code>
136
+ <code className="language-jsx code_style" ref={codeRef}>{code}</code>
140
137
  </div>
141
138
  <div className={pane} ref={viewRef}></div>
142
139
  </div>
@@ -162,26 +159,27 @@ function DemoBlock({file})
162
159
  function App()
163
160
  {
164
161
  const demos =[
165
- 'stopwatch.jsx',
166
- 'modal.jsx',
167
- 'actionstate.jsx',
168
- 'context.jsx',
169
- 'proptypes.jsx',
170
- 'router.jsx',
171
- 'use-differed.jsx',
172
- 'boundary.jsx',
173
- 'css-transition.jsx',
174
- 'reducer.jsx',
175
- 'usetransition.jsx',
176
- 'redux.jsx',
177
- 'suspense.jsx',
178
- 'transition.jsx'
162
+ ['stopwatch.jsx', '( useState, useRef )'],
163
+ ['modal.jsx', '( useEffect, useRef, useState )'],
164
+ ['actionstate.jsx', '( useActionState, useState )'],
165
+ ['context.jsx', '( createContext, useContext, useState ), emotion:( css, cx )'],
166
+ ['proptypes.jsx', '( PropTypes )'],
167
+ ['router.jsx', '( HashRouter, NavLink, Routes, Route, useNavigate, useLocation )'],
168
+ ['use-deffered.jsx', '( useState, useDeferredValue )'],
169
+ ['boundary.jsx', '( ErrorBoundary, useState )'],
170
+ ['css-transition.jsx', '( CSSTransition, useState, useRef )'],
171
+ ['reducer.jsx', '( useReducer )'],
172
+ ['usetransition.jsx', '( useTransition, useState, useCallback, useId ), emotion:( css, cx )'],
173
+ ['redux.jsx', '( Provider, useSelector, useDispatch, connect ), redux:( createStore )'],
174
+ ['suspense.jsx', '( Suspense, Spinner )'],
175
+ ['transition.jsx', '( useState, Transition )'],
176
+ ['lazy.jsx', '( lazy, require, Suspene, Spinner )']
179
177
  ];
180
178
 
181
179
  return <>
182
180
  <h3>Lilact Demos</h3>
183
181
 
184
- <p>These scripts are transpiled and run directly in your browser. You have already loaded the complete Lilact toolchain!</p>
182
+ <p>These scripts are transpiled and run directly in your browser. You have already loaded Lilact completely!</p>
185
183
 
186
184
  <p>These examples are not meant to be pretty.
187
185