lilact 0.7.2 → 0.7.4

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/root/index.html CHANGED
@@ -22,38 +22,38 @@ const { css,cx,injectGlobal } = Lilact.emotion;
22
22
  const cache = new Map();
23
23
 
24
24
  function createResource(url) {
25
- let record = cache.get(url);
26
- if (!record) {
27
- record = {
28
- status: "pending",
29
- promise: null,
30
- data: null,
31
- error: null,
32
- };
33
-
34
- record.promise = fetch(url)
35
- .then(r => {
36
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
37
- return r.text();
38
- })
39
- .then(data => {
40
- record.status = "success";
41
- record.data = data;
42
- })
43
- .catch(err => {
44
- record.status = "error";
45
- record.error = err;
46
- });
47
-
48
- cache.set(url, record);
49
- }
50
- return {
51
- read() {
52
- if (record.status === "pending") throw record.promise;
53
- if (record.status === "error") throw record.error;
54
- return record.data;
55
- }
56
- };
25
+ let record = cache.get(url);
26
+ if (!record) {
27
+ record = {
28
+ status: "pending",
29
+ promise: null,
30
+ data: null,
31
+ error: null,
32
+ };
33
+
34
+ record.promise = fetch(url)
35
+ .then(r => {
36
+ if (!r.ok) throw new Error(`HTTP ${r.status}`);
37
+ return r.text();
38
+ })
39
+ .then(data => {
40
+ record.status = "success";
41
+ record.data = data;
42
+ })
43
+ .catch(err => {
44
+ record.status = "error";
45
+ record.error = err;
46
+ });
47
+
48
+ cache.set(url, record);
49
+ }
50
+ return {
51
+ read() {
52
+ if (record.status === "pending") throw record.promise;
53
+ if (record.status === "error") throw record.error;
54
+ return record.data;
55
+ }
56
+ };
57
57
  }
58
58
 
59
59
 
@@ -61,14 +61,17 @@ function createResource(url) {
61
61
  injectGlobal({"*:not(code):not(code *)" : {fontFamily: "Ubuntu, 'Segoe UI', 'Noto Sans', helvetica, sans", fontSize: "14px"}});
62
62
 
63
63
 
64
- injectGlobal({ code: { whiteSpace: "pre !important",
65
- padding: "10px 0",
66
- fontSize: "14px !important",
67
- display: "block",
68
- overflowWrap: "anywhere" },
69
- p: {padding: "10px"},
70
- body: {padding: "20px"}
71
- });
64
+ injectGlobal({
65
+ code: {
66
+ whiteSpace: "pre !important",
67
+ padding: "10px 0",
68
+ fontSize: "14px !important",
69
+ display: "block",
70
+ overflowWrap: "anywhere"
71
+ },
72
+ p: {padding: "10px"},
73
+ body: {padding: "20px"}
74
+ });
72
75
 
73
76
  const outer = css({
74
77
  display: "flex",
@@ -112,10 +115,10 @@ function DemoView({ file })
112
115
  const viewRef = useRef();
113
116
  const codeRef = useRef();
114
117
 
115
- const resource = createResource("demos/"+file[0]);
116
- const code = resource.read(); // Suspense will handle the promise
118
+ const resource = createResource("demos/"+file[0]);
119
+ const code = resource.read(); // Suspense will handle the promise
117
120
 
118
- if(isOpen) {
121
+ if(isOpen) {
119
122
  useEffect(() => {
120
123
  const Comp = run(code, "demos/"+file[0]);
121
124
  Lilact.render(<Comp/>, viewRef.current);
@@ -149,7 +152,7 @@ function DemoBlock({file})
149
152
  {
150
153
  return <div key={file[0]}>
151
154
  <Suspense fallback={<Spinner/>}>
152
- <DemoView file={file} />
155
+ <DemoView file={file} />
153
156
  </Suspense>
154
157
  </div>
155
158
  }
@@ -166,12 +169,13 @@ function App()
166
169
  ['proptypes.jsx', '( PropTypes )'],
167
170
  ['router.jsx', '( HashRouter, NavLink, Routes, Route, useNavigate, useLocation )'],
168
171
  ['use-deffered.jsx', '( useState, useDeferredValue )'],
169
- ['css-transition.jsx', '( CSSTransition, useState, useRef )'],
170
- ['reducer.jsx', '( useReducer )'],
172
+ ['css-transition.jsx', '( CSSTransition, useState, useRef )'],
173
+ <!-- ['switch-transition.jsx', '( SwitchTransition, useState )'], -->
171
174
  ['usetransition.jsx', '( useTransition, useState, useCallback, useId ), emotion:( css, cx )'],
175
+ ['transition.jsx', '( useState, Transition )'],
176
+ ['reducer.jsx', '( useReducer )'],
172
177
  ['redux.jsx', '( Provider, useSelector, useDispatch, connect ), redux:( createStore )'],
173
178
  ['suspense.jsx', '( Suspense, Spinner )'],
174
- ['transition.jsx', '( useState, Transition )'],
175
179
  ['lazy.jsx', '( lazy, require, Suspene, Spinner )'],
176
180
  ['form-elements.jsx', '()'],
177
181
  ['error-boundary.jsx', '( ErrorBoundary, useState )'],