lilact 0.22.0 → 0.23.1

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 (57) hide show
  1. package/README.md +4 -4
  2. package/dist/lilact.development.js +32 -12
  3. package/dist/lilact.development.js.map +2 -2
  4. package/dist/lilact.development.min.js +26 -25
  5. package/dist/lilact.development.min.js.map +3 -3
  6. package/dist/lilact.production.min.js +26 -25
  7. package/docs/assets/hierarchy.js +1 -1
  8. package/docs/assets/navigation.js +1 -1
  9. package/docs/assets/search.js +1 -1
  10. package/docs/classes/components.Component.html +1 -1
  11. package/docs/classes/components.HTMLComponent.html +1 -1
  12. package/docs/classes/components.RootComponent.html +1 -1
  13. package/docs/functions/accessories.DragHandle.html +2 -2
  14. package/docs/functions/accessories.Spinner.html +2 -2
  15. package/docs/functions/components.cloneComponent.html +1 -0
  16. package/docs/functions/components.memo.html +1 -1
  17. package/docs/functions/components.render.html +1 -1
  18. package/docs/functions/redux.Provider.html +2 -2
  19. package/docs/functions/redux.connect.html +2 -2
  20. package/docs/functions/router.HashRouter.html +2 -2
  21. package/docs/functions/router.Link.html +2 -2
  22. package/docs/functions/router.NavLink.html +2 -2
  23. package/docs/functions/router.Routes.html +2 -2
  24. package/docs/functions/run.lazy.html +3 -3
  25. package/docs/functions/run.require.html +4 -9
  26. package/docs/functions/run.runScripts.html +1 -1
  27. package/docs/functions/timers.timeoutPromise.html +144 -2
  28. package/docs/functions/transition.CSSTransition.html +4 -4
  29. package/docs/functions/transition.SwitchTransition.html +2 -2
  30. package/docs/functions/transition.Transition.html +3 -3
  31. package/docs/hierarchy.html +1 -1
  32. package/docs/index.html +4 -4
  33. package/docs/modules/components.html +1 -1
  34. package/docs/static/demos/cloneelement.jsx +66 -0
  35. package/docs/static/demos/reducer.jsx +2 -0
  36. package/docs/static/demos/router.jsx +1 -1
  37. package/docs/static/index.html +33 -32
  38. package/docs/static/lilact.development.js +32 -12
  39. package/docs/static/lilact.development.js.map +2 -2
  40. package/docs/static/lilact.development.min.js +26 -25
  41. package/docs/static/lilact.development.min.js.map +3 -3
  42. package/docs/static/lilact.production.min.js +26 -25
  43. package/docs/variables/components.cloneElement.html +1 -0
  44. package/examples/demos/cloneelement.jsx +66 -0
  45. package/examples/demos/reducer.jsx +2 -0
  46. package/examples/demos/router.jsx +1 -1
  47. package/examples/index.html +33 -32
  48. package/examples/lilact.development.js +32 -12
  49. package/examples/lilact.development.js.map +2 -2
  50. package/examples/lilact.development.min.js +26 -25
  51. package/examples/lilact.development.min.js.map +3 -3
  52. package/examples/lilact.production.min.js +26 -25
  53. package/package.json +1 -1
  54. package/src/components.jsx +7 -0
  55. package/src/expscan.js +7 -3
  56. package/src/lilact.jsx +5 -5
  57. package/src/run.jsx +13 -16
@@ -37,6 +37,8 @@ function reducer(state, action) {
37
37
 
38
38
  function Demo({ username })
39
39
  {
40
+ username ??= "Tester";
41
+
40
42
  const [state, dispatch] = useReducer(
41
43
  reducer,
42
44
  username,
@@ -79,7 +79,7 @@ function NavControls() {
79
79
  }
80
80
  style={{ marginLeft: 8 }}
81
81
  >
82
- Go Profile (replace + state)
82
+ Go Profile (replace + state) (Clears History)
83
83
  </button>
84
84
  <button onClick={() => navigate(-1)} style={{ marginLeft: 8 }}>
85
85
  Back
@@ -142,8 +142,8 @@ const pane = css({ flex: "1 1 0",
142
142
  }
143
143
  });
144
144
 
145
- const left = css({ float: "left" });
146
- const right = css({ float: "right" });
145
+ const left = css({ float: "left", textAlign: "left" });
146
+ const right = css({ float: "right", textAlign: "right" });
147
147
  const demobox = css({ background: "#fff3", borderRadius: "15px", padding: "4px 2px", margin: "4px"});
148
148
 
149
149
 
@@ -172,8 +172,8 @@ function DemoView({ entry })
172
172
 
173
173
  return <>
174
174
  <button onClick={()=>setOpen(!isOpen)} className={collapsible} type="button">
175
- <span className={left}>{ (isOpen?'- ':'+ ') + entry[0] + ' '}</span>
176
- <b className={right}>{entry[1]}</b>
175
+ <b className={left}>{ (isOpen?'- ':'+ ') + entry[1] + ' '}</b>
176
+ <span className={right}>{entry[0]}</span>
177
177
  </button>
178
178
  {isOpen &&
179
179
  <div style={{width:"100%"}}>
@@ -216,40 +216,41 @@ function App()
216
216
  {
217
217
  const demos =[
218
218
  "Hooks",
219
- ['stopwatch.jsx', '( useState, useRef )'],
220
- ['actionstate.jsx', '( useActionState, Spinner )'],
221
- ['usedefered.jsx', '( useState, useDeferredValue )'],
222
- ['usetransition.jsx', '( useTransition, useState, useCallback, useId ), emotion:( css, cx )'],
223
- ['reducer.jsx', '( useReducer )'],
224
- ['context.jsx', '( createContext, useContext, useState ), emotion:( css, cx )'],
219
+ ['stopwatch.jsx', 'Stop Watch ( useState, useRef )'],
220
+ ['actionstate.jsx', 'Action State ( useActionState, Spinner )'],
221
+ ['usedefered.jsx', 'Deferred List Update ( useState, useDeferredValue )'],
222
+ ['usetransition.jsx', 'Transition ( useTransition, useState, useCallback, useId ), emotion:( css, cx )'],
223
+ ['reducer.jsx', 'Todo List: ( useReducer )'],
224
+ ['context.jsx', 'Modern Context API ( createContext, useContext, useState ), emotion:( css, cx )'],
225
225
 
226
226
  "API",
227
- ['capture.jsx', '-- Event Capture and Bubble --'],
228
- ['priorities.jsx', '-- Effect Priorities --'],
229
- ['forwardref.jsx', '( forwardRef, useImperativeHandle, useRef )'],
230
- ['memo.jsx', '( memo, useState )'],
231
- ['lazy.jsx', '( lazy, require, Suspene, Spinner )'],
232
- ['proptypes.jsx', '( PropTypes )'],
233
- ['legacy-context.jsx', '-- Legacy Context API --'],
234
- ['redux.jsx', '( Provider, useSelector, useDispatch, connect ), redux:( createStore )'],
235
- ['transition.jsx', '( useState, Transition )'],
227
+ ['capture.jsx', 'Event Capture and Bubble'],
228
+ ['priorities.jsx', 'Effect Priorities'],
229
+ ['forwardref.jsx', 'ForwardRef with Function Refs ( forwardRef, useImperativeHandle, useRef )'],
230
+ ['memo.jsx', 'Component Memoization ( memo, useState )'],
231
+ ['lazy.jsx', 'Lazy Loading ( lazy, require, Suspene, Spinner )'],
232
+ ['proptypes.jsx', 'PropTypes Validation'],
233
+ ['legacy-context.jsx', 'Legacy Context API'],
234
+ ['redux.jsx', 'Redux and Despatch ( Provider, useSelector, useDispatch, connect ), redux:( createStore )'],
235
+ ['transition.jsx', 'Transition States ( useState, Transition )'],
236
+ ['cloneelement.jsx', 'Cloning Components ( cloneElement, import as React )'],
236
237
 
237
238
  "Components",
238
- ['router.jsx', '( HashRouter, NavLink, Routes, Route, useNavigate, useLocation )'],
239
- ['modal.jsx', '( useEffect, useRef, useState )'],
240
- ['portal.jsx', '(createPortal, useState )'],
241
- ['pane.jsx', '( useRef, useState, SplitPane )'],
242
- ['css-transition.jsx', '( CSSTransition, useState, useRef )'],
243
- ['switch-transition.jsx', '( SwitchTransition )'],
244
- ['suspense.jsx', '( Suspense, Spinner )'],
245
- ['form-elements.jsx', '()'],
239
+ ['router.jsx', 'Hash Router ( HashRouter, NavLink, Routes, Route, useNavigate, useLocation )'],
240
+ ['modal.jsx', 'Simple Modal ( useEffect, useRef, useState )'],
241
+ ['portal.jsx', 'Portal (createPortal, useState )'],
242
+ ['pane.jsx', 'SplitPane ( useRef, useState, SplitPane )'],
243
+ ['css-transition.jsx', 'CSSTransition ( CSSTransition, useState, useRef )'],
244
+ ['switch-transition.jsx', 'SwitchTransition'],
245
+ ['suspense.jsx', 'Suspense and Spinner'],
246
+ ['form-elements.jsx', 'Form Elements'],
246
247
 
247
248
  "Error Report and Handling",
248
- ['error-boundary.jsx', '( ErrorBoundary, useState )'],
249
- ['error-parser.jsx', '-- JSX Parser Error --'],
250
- ['error-init.jsx', '-- Error in Component initialization --'],
251
- ['error-component-stack.jsx', '-- Error Component Stack --'],
252
- ['error-callback.jsx', '-- Error in Callback --'],
249
+ ['error-boundary.jsx', 'Error Boundary'],
250
+ ['error-parser.jsx', 'JSX Parser Error'],
251
+ ['error-init.jsx', 'Error in Component initialization'],
252
+ ['error-component-stack.jsx', 'Error Component Stack'],
253
+ ['error-callback.jsx', 'Error in Callback'],
253
254
  ];
254
255
 
255
256
  return<>
@@ -1973,6 +1973,8 @@ __export(components_exports, {
1973
1973
  RootComponent: () => RootComponent,
1974
1974
  boolean_html_attributes_set: () => boolean_html_attributes_set,
1975
1975
  capture_events_set: () => capture_events_set,
1976
+ cloneComponent: () => cloneComponent,
1977
+ cloneElement: () => cloneElement,
1976
1978
  createComponent: () => createComponent2,
1977
1979
  createElement: () => createElement,
1978
1980
  createPortal: () => createPortal,
@@ -3071,6 +3073,10 @@ function createRoot(element) {
3071
3073
  function createPortal(children, element) {
3072
3074
  return createComponent2(lilact_default.Portal, { "view": element }, children);
3073
3075
  }
3076
+ function cloneComponent(component, propsPatch, ...children) {
3077
+ return { entity: component.entity, props: { ...component.props, ...propsPatch, children } };
3078
+ }
3079
+ var cloneElement = cloneComponent;
3074
3080
  function render(component, element) {
3075
3081
  if (component[CORE] && (component[CORE].container || component[CORE].parent)) {
3076
3082
  throw new Error("Component is already in use");
@@ -3606,9 +3612,16 @@ function run(jsx, path = `InlineJSX-${++lilact_default.eval_num}`, is_inline = t
3606
3612
  throw e;
3607
3613
  }
3608
3614
  }
3609
- function require2(path2, { forceUpdate, checkExport, requirer, isLazy }) {
3610
- var _a, _b;
3611
- if ((_a = lilact_default.importObjectPaths) == null ? void 0 : _a[path2]) return lilact_default.importObjectPaths[path2];
3615
+ function require2(path2) {
3616
+ var _a, _b, _c, _d, _e, _f;
3617
+ let forceUpdate, checkExport, requirer, isLazy;
3618
+ if (arguments.length === 2 && typeof (arguments[1] === "object")) {
3619
+ forceUpdate = (_a = arguments[1]) == null ? void 0 : _a.forceUpdate;
3620
+ checkExport = (_b = arguments[1]) == null ? void 0 : _b.checkExport;
3621
+ requirer = (_c = arguments[1]) == null ? void 0 : _c.requirer;
3622
+ isLazy = (_d = arguments[1]) == null ? void 0 : _d.isLazy;
3623
+ }
3624
+ if ((_e = lilact_default.importObjectPaths) == null ? void 0 : _e[path2]) return lilact_default.importObjectPaths[path2];
3612
3625
  if (required_scripts[path2] && !forceUpdate) return required_scripts[path2].exports;
3613
3626
  if (path2[0] === "#") {
3614
3627
  const el = document.getElementById(path2);
@@ -3619,7 +3632,7 @@ function require2(path2, { forceUpdate, checkExport, requirer, isLazy }) {
3619
3632
  if (requirer && requirer.path) {
3620
3633
  path2 = joinPaths(requirer.path, path2);
3621
3634
  }
3622
- if (((_b = lilact_default) == null ? void 0 : _b[LAZY]) || isLazy) {
3635
+ if (((_f = lilact_default) == null ? void 0 : _f[LAZY]) || isLazy) {
3623
3636
  lilact_default[LAZY] = false;
3624
3637
  return fetch(path2).then((res2) => {
3625
3638
  if (!res2.ok) throw new Error(`HTTP ${res2.status}`);
@@ -5316,19 +5329,20 @@ function processImportExports(node3, jsx2) {
5316
5329
  const src = jsx2.substring(node3.out[m.index + imp.length - 1].begin, node3.out[m.index + imp.length - 1].end);
5317
5330
  const imports = {};
5318
5331
  let star_imports = [];
5332
+ let import_alls = [];
5319
5333
  for (i2 = m.index + 1; i2 < m.index + imp.length - 1; i2++) {
5320
5334
  node3.out.splice(m.index, 1, {
5321
5335
  type: "import",
5322
5336
  begin: begins[m.index],
5323
- end: begins[m.index + imp.length]
5337
+ end: begins[m.index + imp.length],
5338
+ cjs: ""
5324
5339
  });
5325
5340
  skip_spaces();
5326
5341
  switch (s[i2]) {
5327
5342
  case ",":
5328
5343
  break;
5329
5344
  case "I": {
5330
- const prop = node3.out[i2];
5331
- imports[prop] = "default";
5345
+ import_alls.push(node3.out[i2]);
5332
5346
  continue;
5333
5347
  }
5334
5348
  case "J": {
@@ -5371,8 +5385,12 @@ function processImportExports(node3, jsx2) {
5371
5385
  node3.out[i2] = null;
5372
5386
  }
5373
5387
  let cjs = "";
5374
- for (const s2 of star_imports) {
5388
+ for (const s2 of import_alls) {
5375
5389
  cjs += `const ${s2} = require(${src},{requirer:module});
5390
+ `;
5391
+ }
5392
+ for (const s2 of star_imports) {
5393
+ cjs += `const ${s2} = require(${src},{requirer:module, checkExport: ['default']}).default;
5376
5394
  `;
5377
5395
  }
5378
5396
  if (Object.keys(imports).length) {
@@ -6387,7 +6405,7 @@ function transpileJSX(jsx2, {
6387
6405
 
6388
6406
  // .tmp/src/lilact.jsx
6389
6407
  var Lilact2 = {
6390
- VERSION: "beta.22",
6408
+ VERSION: "beta.23",
6391
6409
  // Configuration
6392
6410
  defaultTransitionTimeout: 300,
6393
6411
  defaultIsEqual: Object.is,
@@ -6409,9 +6427,10 @@ var Lilact2 = {
6409
6427
  // Dependencies
6410
6428
  PropTypes,
6411
6429
  redux: redux_exports,
6412
- emotion: emotion_css_esm_exports,
6413
- default: Lilact2
6430
+ emotion: emotion_css_esm_exports
6414
6431
  };
6432
+ Lilact2.default = Lilact2;
6433
+ var lilact_default = Lilact2;
6415
6434
  Lilact2.importObjectPaths = {
6416
6435
  "lilact": Lilact2,
6417
6436
  "@emotion/css": Lilact2.emotion,
@@ -6433,7 +6452,6 @@ if (true) {
6433
6452
  console.log(`Lilact (Version: ${Lilact2.VERSION}) - Debug Mode`);
6434
6453
  console.log(`Copyright(C) 2024-2026 Arash Kazemi <contact.arash.kazemi@gmail.com>`);
6435
6454
  }
6436
- var lilact_default = Lilact2;
6437
6455
  export {
6438
6456
  CSSTransition,
6439
6457
  Children,
@@ -6465,6 +6483,8 @@ export {
6465
6483
  capture_events_set,
6466
6484
  clearInterval,
6467
6485
  clearTimeout2 as clearTimeout,
6486
+ cloneComponent,
6487
+ cloneElement,
6468
6488
  combineReducers2 as combineReducers,
6469
6489
  connect,
6470
6490
  createComponent2 as createComponent,