malinajs 0.7.2-a1 → 0.7.2-a10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "malinajs",
3
- "version": "0.7.2-a1",
3
+ "version": "0.7.2-a10",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "prepare": "npm run build",
package/runtime.js CHANGED
@@ -1,3 +1,7 @@
1
+ let current_destroyList, current_mountList, current_cd, destroyResults;
2
+ const $onDestroy = fn => fn && current_destroyList.push(fn);
3
+ const $onMount = fn => current_mountList.push(fn);
4
+
1
5
  let __app_onerror = console.error;
2
6
 
3
7
  const configure = (option) => {
@@ -24,17 +28,13 @@ const safeGroupCall = list => {
24
28
  }
25
29
  };
26
30
 
27
- const safeCallMount = (mountList, destroyList) => {
28
- mountList.forEach(fn => {
31
+ const safeGroupCall2 = (list, resultList, onlyFunction) => {
32
+ list?.forEach(fn => {
29
33
  let r = safeCall(fn);
30
- r && destroyList.push(r);
34
+ r && (!onlyFunction || isFunction(r)) && resultList.push(r);
31
35
  });
32
36
  };
33
37
 
34
- let current_destroyList, current_mountList, current_cd, destroyResults;
35
- const $onDestroy = fn => fn && current_destroyList.push(fn);
36
- const $onMount = fn => current_mountList.push(fn);
37
-
38
38
  function WatchObject(fn, cb) {
39
39
  this.fn = fn;
40
40
  this.cb = cb;
@@ -75,7 +75,7 @@ const cd_component = cd => {
75
75
  return cd.component;
76
76
  };
77
77
 
78
- const cd_new = () => new $ChangeDetector();
78
+ const cd_new = (parent) => new $ChangeDetector(parent);
79
79
 
80
80
  const cd_attach = (parent, cd) => {
81
81
  if(cd) {
@@ -288,25 +288,6 @@ const iterNodes = (el, last, fn) => {
288
288
  const removeElements = (el, last) => iterNodes(el, last, n => n.remove());
289
289
 
290
290
 
291
- function removeElementsBetween(el, stop) {
292
- let next;
293
- el = el.nextSibling;
294
- while(el) {
295
- next = el.nextSibling;
296
- if(el == stop) break;
297
- el.remove();
298
- el = next;
299
- }
300
- }
301
-
302
- const getFinalLabel = n => {
303
- if(n.nextSibling) return n.nextSibling;
304
- let e = document.createTextNode('');
305
- n.parentNode.appendChild(e);
306
- return e;
307
- };
308
-
309
-
310
291
  const resolvedPromise = Promise.resolve();
311
292
 
312
293
  function $tick(fn) {
@@ -326,7 +307,7 @@ function makeEmitter(option) {
326
307
  }
327
308
 
328
309
 
329
- let current_component;
310
+ let current_component, $context;
330
311
 
331
312
 
332
313
  const makeApply = () => {
@@ -357,6 +338,7 @@ const makeApply = () => {
357
338
 
358
339
  const makeComponent = (init) => {
359
340
  return ($option = {}) => {
341
+ $context = $option.context || {};
360
342
  let prev_component = current_component,
361
343
  prev_cd = current_cd,
362
344
  $component = current_component = { $option };
@@ -367,6 +349,7 @@ const makeComponent = (init) => {
367
349
  } finally {
368
350
  current_component = prev_component;
369
351
  current_cd = prev_cd;
352
+ $context = null;
370
353
  }
371
354
 
372
355
  return $component;
@@ -417,34 +400,33 @@ const callComponentDyn = (component, context, option = {}, propFn, cmp, setter,
417
400
  };
418
401
 
419
402
 
420
- const attachDynComponent = (label, exp, bind) => {
403
+ const attachDynComponent = (label, exp, bind, parentLabel) => {
421
404
  let parentCD = current_cd;
422
- let active, destroyList, $cd, $dom, finalLabel = getFinalLabel(label);
405
+ let destroyList, $cd, first;
423
406
  const destroy = () => safeGroupCall(destroyList);
424
407
  $onDestroy(destroy);
425
408
 
426
409
  $watch(exp, (component) => {
427
410
  destroy();
428
411
  if($cd) cd_detach($cd);
429
- if(active) removeElementsBetween(label, finalLabel);
412
+ if(first) removeElements(first, parentLabel ? null : label.previousSibling);
430
413
 
431
414
  if(component) {
432
415
  destroyList = current_destroyList = [];
433
416
  current_mountList = [];
434
- $cd = current_cd = cd_new();
417
+ $cd = current_cd = cd_new(parentCD);
435
418
  try {
436
- $dom = bind(component).$dom;
419
+ const $dom = bind(component).$dom;
437
420
  cd_attach(parentCD, $cd);
438
- insertAfter(label, $dom);
439
- safeCallMount(current_mountList, destroyList);
421
+ first = $dom.nodeType == 11 ? $dom.firstChild : $dom;
422
+ if(parentLabel) label.appendChild($dom);
423
+ else label.parentNode.insertBefore($dom, label);
424
+ safeGroupCall2(current_mountList, destroyList);
440
425
  } finally {
441
426
  current_destroyList = current_mountList = current_cd = null;
442
427
  }
443
- active = true;
444
428
  } else {
445
- $cd = null;
446
- active = false;
447
- destroyList = null;
429
+ $cd = first = destroyList = null;
448
430
  }
449
431
  });
450
432
  };
@@ -647,7 +629,8 @@ const spreadAttributes = (el, fn) => {
647
629
 
648
630
 
649
631
  const callExportedFragment = (childComponent, name, slot, events, props, cmp) => {
650
- let push, $dom;
632
+ let push, $dom, fn = childComponent.$exported?.[name];
633
+ if(!fn) return;
651
634
  if(cmp) {
652
635
  let result;
653
636
  let w = $watch(props, (value) => {
@@ -657,7 +640,6 @@ const callExportedFragment = (childComponent, name, slot, events, props, cmp) =>
657
640
  fire(w);
658
641
  props = () => result;
659
642
  }
660
- let fn = childComponent.$exported?.[name];
661
643
  ([$dom, push] = fn(props, events, slot));
662
644
  return $dom;
663
645
  };
@@ -731,6 +713,16 @@ const attachBlock = (label, $dom) => {
731
713
  insertAfter(label, $dom.$dom || $dom);
732
714
  };
733
715
 
716
+ const addBlock = (parent, $dom) => {
717
+ if(!$dom) return;
718
+ parent.appendChild($dom.$dom || $dom);
719
+ };
720
+
721
+ const insertBlock = (label, $dom) => {
722
+ if(!$dom) return;
723
+ label.parentNode.insertBefore($dom.$dom || $dom, label);
724
+ };
725
+
734
726
  const mergeEvents = (...callbacks) => {
735
727
  callbacks = callbacks.filter(i => i);
736
728
  return (e) => callbacks.forEach(cb => cb(e));
@@ -791,7 +783,7 @@ const mount = (label, component, option) => {
791
783
  last = $dom.lastChild;
792
784
  } else first = last = $dom;
793
785
  label.appendChild($dom);
794
- safeCallMount(current_mountList, destroyList);
786
+ safeGroupCall2(current_mountList, destroyList);
795
787
  } finally {
796
788
  current_destroyList = current_mountList = null;
797
789
  }
@@ -860,21 +852,21 @@ let create = (tag, html) => {
860
852
  t.innerHTML = html;
861
853
  fr = t.content;
862
854
  }
863
- let lastElement = fr.lastChild;
864
- insertAfter(tag, fr);
865
- return lastElement;
855
+ let firstElement = fr.firstChild;
856
+ tag.parentNode.insertBefore(fr, tag);
857
+ return firstElement;
866
858
  };
867
859
 
868
860
  function htmlBlock(tag, fn) {
869
- let lastElement;
861
+ let firstElement;
870
862
  let destroy = () => {
871
- if(!lastElement) return;
872
- removeElements(tag.nextSibling, lastElement);
873
- lastElement = null;
863
+ if(!firstElement) return;
864
+ removeElements(firstElement, tag.previousSibling);
865
+ firstElement = null;
874
866
  };
875
867
  $watch(fn, (html) => {
876
868
  destroy();
877
- if(html) lastElement = create(tag, html);
869
+ if(html) firstElement = create(tag, html);
878
870
  });
879
871
  }
880
872
 
@@ -884,13 +876,13 @@ function htmlBlockStatic(tag, value) {
884
876
 
885
877
  function ifBlock(label, fn, parts, parentLabel) {
886
878
  let first, last, $cd, destroyList, parentCD = current_cd;
887
- $onDestroy(() => safeGroupCall(destroyList));
879
+ $onDestroy(() => safeGroupCall2(destroyList, destroyResults));
888
880
 
889
881
  function createBlock(builder) {
890
882
  let $dom;
891
883
  destroyList = current_destroyList = [];
892
884
  let mountList = current_mountList = [];
893
- $cd = current_cd = cd_new();
885
+ $cd = current_cd = cd_new(parentCD);
894
886
  try {
895
887
  $dom = builder();
896
888
  } finally {
@@ -902,14 +894,14 @@ function ifBlock(label, fn, parts, parentLabel) {
902
894
  last = $dom.lastChild;
903
895
  } else first = last = $dom;
904
896
  if(parentLabel) label.appendChild($dom);
905
- else insertAfter(label, $dom);
906
- safeCallMount(mountList, destroyList);
897
+ else label.parentNode.insertBefore($dom, label);
898
+ safeGroupCall2(mountList, destroyList, 1);
907
899
  }
908
900
 
909
901
  function destroyBlock() {
910
902
  if(!first) return;
911
903
  destroyResults = [];
912
- safeGroupCall(destroyList);
904
+ safeGroupCall2(destroyList, destroyResults);
913
905
  destroyList.length = 0;
914
906
  if($cd) {
915
907
  cd_detach($cd);
@@ -932,12 +924,16 @@ function ifBlock(label, fn, parts, parentLabel) {
932
924
  }
933
925
 
934
926
 
935
- function ifBlockReadOnly(label, fn, parts) {
927
+ function ifBlockReadOnly(label, fn, parts, parentLabel) {
936
928
  let value = fn();
937
- if(value != null) insertAfter(label, parts[value]());
929
+ if(value != null) {
930
+ const $dom = parts[value]();
931
+ if(parentLabel) label.appendChild($dom);
932
+ else label.parentNode.insertBefore($dom, label);
933
+ }
938
934
  }
939
935
 
940
- function awaitBlock(label, relation, fn, build_main, build_then, build_catch) {
936
+ function awaitBlock(label, parentLabel, relation, fn, build_main, build_then, build_catch) {
941
937
  let parentCD = current_cd, first, last, $cd, promise, destroyList, status = 0;
942
938
  $onDestroy(() => safeGroupCall(destroyList));
943
939
 
@@ -959,7 +955,7 @@ function awaitBlock(label, relation, fn, build_main, build_then, build_catch) {
959
955
 
960
956
  if(!builder) return;
961
957
  destroyList = current_destroyList = [];
962
- $cd = current_cd = cd_new();
958
+ $cd = current_cd = cd_new(parentCD);
963
959
  let $dom, mountList = current_mountList = [];
964
960
  try {
965
961
  $dom = builder(value);
@@ -971,8 +967,9 @@ function awaitBlock(label, relation, fn, build_main, build_then, build_catch) {
971
967
  first = $dom.firstChild;
972
968
  last = $dom.lastChild;
973
969
  } else first = last = $dom;
974
- insertAfter(label, $dom);
975
- safeCallMount(mountList, destroyList);
970
+ if(parentLabel) label.appendChild($dom);
971
+ else label.parentNode.insertBefore($dom, label);
972
+ safeGroupCall2(mountList, destroyList, 1);
976
973
  cd_component(parentCD).$apply();
977
974
  }
978
975
 
@@ -1015,11 +1012,12 @@ const makeEachSingleBlock = (fn) => {
1015
1012
 
1016
1013
 
1017
1014
  const makeEachElseBlock = (fn) => {
1018
- return (label, onlyChild, parentCD) => {
1015
+ return (label, mode, parentCD) => {
1019
1016
  let first, last;
1020
1017
  let destroyList = current_destroyList = [];
1021
- let $cd = current_cd = cd_new();
1018
+ let $cd = current_cd = cd_new(parentCD);
1022
1019
  current_mountList = [];
1020
+ const parentNode = mode ? label : label.parentNode;
1023
1021
  try {
1024
1022
  let $dom = fn();
1025
1023
  if($dom.nodeType == 11) {
@@ -1027,32 +1025,41 @@ const makeEachElseBlock = (fn) => {
1027
1025
  last = $dom.lastChild;
1028
1026
  } else first = last = $dom;
1029
1027
  cd_attach(parentCD, $cd);
1030
- if(onlyChild) label.appendChild($dom);
1031
- else attachBlock(label, $dom);
1032
- safeCallMount(current_mountList, destroyList);
1028
+ parentNode.insertBefore($dom, mode ? null : label);
1029
+ safeGroupCall2(current_mountList, destroyList, 1);
1033
1030
  } finally {
1034
1031
  current_destroyList = current_mountList = current_cd = null;
1035
1032
  }
1036
1033
 
1037
1034
  return () => {
1038
- removeElements(first, last);
1039
1035
  cd_detach($cd);
1040
- safeGroupCall(destroyList);
1036
+ destroyResults = [];
1037
+ safeGroupCall2(destroyList, destroyResults);
1038
+
1039
+ if(destroyResults.length) {
1040
+ const f = first, l = last;
1041
+ iterNodes(f, l, n => n.$$removing = true);
1042
+ Promise.allSettled(destroyResults).then(() => iterNodes(f, l, n => n.remove()));
1043
+ } else {
1044
+ removeElements(first, last);
1045
+ }
1046
+ destroyResults = null;
1041
1047
  };
1042
1048
  };
1043
1049
  };
1044
1050
 
1045
1051
 
1046
- function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
1052
+ function $$eachBlock(label, mode, fn, getKey, bind, buildElseBlock) {
1047
1053
  let parentCD = current_cd;
1048
1054
  let eachCD = cd_new();
1049
1055
  cd_attach(parentCD, eachCD);
1050
1056
 
1051
1057
  let mapping = new Map();
1052
- let lastNode, vi = 0, p_promise = 0, p_destroy = 0, elseBlock;
1058
+ let firstNode, vi = 0, p_promise = 0, p_destroy = 0, elseBlock;
1059
+ const onlyChild = mode == 1;
1053
1060
 
1054
1061
  const destroyAll = () => {
1055
- p_destroy && safeCall(() => mapping.forEach(ctx => ctx.d?.forEach(fn => fn())));
1062
+ p_destroy && mapping.forEach(ctx => safeGroupCall2(ctx.d, destroyResults));
1056
1063
  mapping.clear();
1057
1064
  };
1058
1065
 
@@ -1065,14 +1072,7 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
1065
1072
  else if(!isArray(array)) array = [];
1066
1073
 
1067
1074
  let newMapping = new Map();
1068
- let prevNode, parentNode;
1069
- if(onlyChild) {
1070
- prevNode = null;
1071
- parentNode = label;
1072
- } else {
1073
- prevNode = label;
1074
- parentNode = label.parentNode;
1075
- }
1075
+ let parentNode = mode ? label : label.parentNode;
1076
1076
 
1077
1077
  if(mapping.size) {
1078
1078
  let ctx, count = 0;
@@ -1085,7 +1085,7 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
1085
1085
  }
1086
1086
  }
1087
1087
 
1088
- if(!count && lastNode) {
1088
+ if(!count && firstNode) {
1089
1089
  destroyResults = [];
1090
1090
  eachCD.children.length = 0;
1091
1091
  destroyAll();
@@ -1093,14 +1093,14 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
1093
1093
  if(destroyResults.length) {
1094
1094
  p_promise = 1;
1095
1095
  let removedNodes = [];
1096
- iterNodes(onlyChild ? label.firstChild : label.nextSibling, lastNode, n => {
1096
+ iterNodes(firstNode, onlyChild ? null : label.previousSibling, n => {
1097
1097
  n.$$removing = true;
1098
1098
  removedNodes.push(n);
1099
1099
  });
1100
1100
  Promise.allSettled(destroyResults).then(() => removedNodes.forEach(n => n.remove()));
1101
1101
  } else {
1102
1102
  if(onlyChild) label.textContent = '';
1103
- else removeElements(label.nextSibling, lastNode);
1103
+ else removeElements(firstNode, label.previousSibling);
1104
1104
  }
1105
1105
 
1106
1106
  destroyResults = null;
@@ -1113,7 +1113,7 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
1113
1113
  ctx.$cd && eachCD.children.push(ctx.$cd);
1114
1114
  return;
1115
1115
  }
1116
- safeGroupCall(ctx.d);
1116
+ safeGroupCall2(ctx.d, destroyResults);
1117
1117
  iterNodes(ctx.first, ctx.last, n => removedNodes.push(n));
1118
1118
  });
1119
1119
 
@@ -1134,7 +1134,9 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
1134
1134
  }
1135
1135
 
1136
1136
  let i, item, next_ctx, ctx, nextEl, key;
1137
- for(i = 0; i < array.length; i++) {
1137
+ let nextNode = mode ? null : label;
1138
+ i = array.length;
1139
+ while(i--) {
1138
1140
  item = array[i];
1139
1141
  key = getKey(item, i, array);
1140
1142
  if(next_ctx) {
@@ -1142,36 +1144,36 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
1142
1144
  next_ctx = null;
1143
1145
  } else ctx = mapping.get(key);
1144
1146
  if(ctx) {
1145
- nextEl = i == 0 && onlyChild ? parentNode.firstChild : prevNode.nextSibling;
1146
- if(p_promise) while(nextEl && nextEl.$$removing) nextEl = nextEl.nextSibling;
1147
- if(nextEl != ctx.first) {
1147
+ nextEl = nextNode ? nextNode.previousSibling : parentNode.lastChild;
1148
+ if(p_promise) while(nextEl && nextEl.$$removing) nextEl = nextEl.previousSibling;
1149
+ if(nextEl != ctx.last) {
1148
1150
  let insert = true;
1149
1151
 
1150
- if(ctx.first == ctx.last && (i + 1 < array.length) && prevNode?.nextSibling) {
1151
- next_ctx = mapping.get(getKey(array[i + 1], i + 1, array));
1152
- if(next_ctx && prevNode.nextSibling.nextSibling === next_ctx.first) {
1153
- parentNode.replaceChild(ctx.first, prevNode.nextSibling);
1152
+ if(ctx.first == ctx.last && (i > 0) && nextEl) {
1153
+ next_ctx = mapping.get(getKey(array[i - 1], i - 1, array));
1154
+ if(next_ctx && nextEl.previousSibling === next_ctx.last) {
1155
+ parentNode.replaceChild(ctx.first, nextEl);
1154
1156
  insert = false;
1155
1157
  }
1156
1158
  }
1157
1159
 
1158
1160
  if(insert) {
1159
- let insertBefore = prevNode?.nextSibling;
1160
1161
  let next, el = ctx.first;
1161
1162
  while(el) {
1162
1163
  next = el.nextSibling;
1163
- parentNode.insertBefore(el, insertBefore);
1164
+ parentNode.insertBefore(el, nextNode);
1164
1165
  if(el == ctx.last) break;
1165
1166
  el = next;
1166
1167
  }
1167
1168
  }
1168
1169
  }
1169
1170
  ctx.rebind?.(item, i);
1171
+ nextNode = ctx.first;
1170
1172
  } else {
1171
1173
  let $dom, rebind,
1172
1174
  d = current_destroyList = [],
1173
1175
  m = current_mountList = [],
1174
- $cd = current_cd = cd_new();
1176
+ $cd = current_cd = cd_new(eachCD);
1175
1177
  try {
1176
1178
  ([$dom, rebind] = bind(item, i));
1177
1179
  } finally {
@@ -1183,22 +1185,22 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind, buildElseBlock) {
1183
1185
  ctx.first = $dom.firstChild;
1184
1186
  ctx.last = $dom.lastChild;
1185
1187
  } else ctx.first = ctx.last = $dom;
1186
- parentNode.insertBefore($dom, prevNode?.nextSibling);
1187
- safeCallMount(m, d);
1188
+ parentNode.insertBefore($dom, nextNode);
1189
+ nextNode = ctx.first;
1190
+ safeGroupCall2(m, d, 1);
1188
1191
  if(d.length) {
1189
1192
  ctx.d = d;
1190
1193
  p_destroy = 1;
1191
1194
  }
1192
1195
  }
1193
- prevNode = ctx.last;
1194
1196
  newMapping.set(key, ctx);
1195
1197
  }
1196
- lastNode = prevNode;
1198
+ firstNode = nextNode;
1197
1199
  mapping.clear();
1198
1200
  mapping = newMapping;
1199
1201
 
1200
1202
  if(!array.length && !elseBlock && buildElseBlock) {
1201
- elseBlock = buildElseBlock(label, onlyChild, parentCD);
1203
+ elseBlock = buildElseBlock(label, mode, parentCD);
1202
1204
  }
1203
1205
  }, { cmp: compareArray });
1204
1206
  }
@@ -1245,4 +1247,88 @@ const makeSlot = (fr, fn) => {
1245
1247
  };
1246
1248
  };
1247
1249
 
1248
- export { $$eachBlock, $digest, $onDestroy, $onMount, $tick, $watch, WatchObject, __app_onerror, __bindActionSubscribe, addClass, addEvent, addStyles, attachAnchor, attachBlock, attachDynComponent, autoSubscribe, awaitBlock, bindAction, bindAttribute, bindAttributeBase, bindClass, bindClassExp, bindInput, bindStyle, bindText, callComponent, callComponentDyn, callExportedFragment, cd_attach, cd_component, cd_detach, cd_new, cloneDeep, compareArray, compareDeep, configure, createTextNode, current_cd, current_component, current_destroyList, current_mountList, deepComparator, destroyResults, eachDefaultKey, exportFragment, fire, getFinalLabel, htmlBlock, htmlBlockStatic, htmlToFragment, htmlToFragmentClean, ifBlock, ifBlockReadOnly, insertAfter, invokeSlot, invokeSlotBase, isArray, isFunction, iterNodes, keyComparator, makeAnchor, makeApply, makeBlock, makeBlockBound, makeClassResolver, makeComponent, makeEachBlock, makeEachElseBlock, makeEachSingleBlock, makeEmitter, makeExternalProperty, makeRootEvent, makeSlot, mergeAllEvents, mergeEvents, mount, mountStatic, noop, prefixPush, refer, removeElements, removeElementsBetween, removeItem, setClassToElement, spreadAttributes, svgToFragment, unwrapProps };
1250
+ const keepAlive = (store, keyFn, builder) => {
1251
+ if(!store.$$d) store.$$d = [];
1252
+ const key = keyFn();
1253
+ let block = store.get(key);
1254
+ const parentCD = current_cd;
1255
+
1256
+ $onDestroy(() => {
1257
+ if(!block.fr) block.fr = new DocumentFragment();
1258
+ iterNodes(block.first, block.last, n => block.fr.appendChild(n));
1259
+ cd_detach(block.$cd);
1260
+ });
1261
+
1262
+ if(block) {
1263
+ cd_attach(parentCD, block.$cd);
1264
+ return block.fr;
1265
+ } else {
1266
+ let $dom, first, last, prev_destroyList = current_destroyList;
1267
+ let destroyList = current_destroyList = [];
1268
+ let $cd = current_cd = cd_new(parentCD);
1269
+ try {
1270
+ $dom = builder();
1271
+ } finally {
1272
+ current_destroyList = prev_destroyList;
1273
+ current_cd = parentCD;
1274
+ }
1275
+ cd_attach(parentCD, $cd);
1276
+ if($dom.nodeType == 11) {
1277
+ first = $dom.firstChild;
1278
+ last = $dom.lastChild;
1279
+ } else first = last = $dom;
1280
+
1281
+ store.$$d.push(() => safeGroupCall(destroyList));
1282
+ store.set(key, block = {first, last, $cd});
1283
+
1284
+ return $dom;
1285
+ }
1286
+ };
1287
+
1288
+ const selectElement = (el, getter, setter) => {
1289
+ addEvent(el, 'change', () => {
1290
+ let op = el.querySelector(':checked');
1291
+ if(op?.$$value) {
1292
+ let value = op.$$value();
1293
+ setter(value);
1294
+ w.value = value;
1295
+ }
1296
+ });
1297
+ const update = () => {
1298
+ for(let op of el.options) {
1299
+ if(op.$$value?.() === w.value) {
1300
+ op.selected = true;
1301
+ return;
1302
+ }
1303
+ }
1304
+ el.selectedIndex = -1;
1305
+ };
1306
+ const w = $watch(getter, update);
1307
+
1308
+ let debounce = 0;
1309
+ el.$$update = () => {
1310
+ if(debounce) return;
1311
+ debounce = 1;
1312
+ $tick(() => {
1313
+ debounce = 0;
1314
+ update();
1315
+ });
1316
+ };
1317
+ };
1318
+
1319
+ const selectOption = (op, getter) => {
1320
+ op.$$value = getter;
1321
+ if(op.parentElement?.$$update) op.parentElement.$$update();
1322
+ else $tick(() => op.parentElement?.$$update?.());
1323
+ };
1324
+
1325
+ const radioButton = (el, getValue, getter, setter) => {
1326
+ let w = $watch(getter, (value) => {
1327
+ el.checked = getValue() === value;
1328
+ });
1329
+ addEvent(el, 'change', () => {
1330
+ if(el.checked) setter(w.value = getValue());
1331
+ });
1332
+ };
1333
+
1334
+ export { $$eachBlock, $context, $digest, $onDestroy, $onMount, $tick, $watch, WatchObject, __app_onerror, __bindActionSubscribe, addBlock, addClass, addEvent, addStyles, attachAnchor, attachBlock, attachDynComponent, autoSubscribe, awaitBlock, bindAction, bindAttribute, bindAttributeBase, bindClass, bindClassExp, bindInput, bindStyle, bindText, callComponent, callComponentDyn, callExportedFragment, cd_attach, cd_component, cd_detach, cd_new, cloneDeep, compareArray, compareDeep, configure, createTextNode, current_cd, current_component, current_destroyList, current_mountList, deepComparator, destroyResults, eachDefaultKey, exportFragment, fire, htmlBlock, htmlBlockStatic, htmlToFragment, htmlToFragmentClean, ifBlock, ifBlockReadOnly, insertAfter, insertBlock, invokeSlot, invokeSlotBase, isArray, isFunction, iterNodes, keepAlive, keyComparator, makeAnchor, makeApply, makeBlock, makeBlockBound, makeClassResolver, makeComponent, makeEachBlock, makeEachElseBlock, makeEachSingleBlock, makeEmitter, makeExternalProperty, makeRootEvent, makeSlot, mergeAllEvents, mergeEvents, mount, mountStatic, noop, prefixPush, radioButton, refer, removeElements, removeItem, selectElement, selectOption, setClassToElement, spreadAttributes, svgToFragment, unwrapProps };
package/CHANGELOG.md DELETED
@@ -1,75 +0,0 @@
1
-
2
- ## 0.7.x
3
- * refactoring, optimization, fixes
4
- * export function
5
- * manual event delegation @click|root
6
- * able to delay destroying block (for animations)
7
- * be able to off autosubscribe for import: !no-autosubscribe
8
- * destructuring array/object for each
9
- * functions mount, mountStatic
10
- * each, index variable is not included by default
11
- * reference to element is removed on destroying
12
- * config.useGroupReferencing
13
- * action can return destroy function (not only object)
14
- * each-else
15
- * else-if
16
- * refactoring $onMount
17
- * optional deep checking for passed props: prop={value} prop|deep={value}
18
-
19
- ## 0.6.x
20
-
21
- * style's attribute "global"
22
- * compound classes (handle mix of class and class directives)
23
- * new passing class
24
- * mark a class as external "$className"
25
- * Deprecated: passing class from 0.5
26
- * plugins
27
- * esbuild-plugin (by AlexxNB)
28
- * $context
29
- * onError
30
- * $onMount
31
- * $onDestroy
32
- * alias for import: malinajs -> malinajs/runtime.js
33
- * alias @click -> @click={click}, @@click is forwarding
34
- * local config "malina.config.js"
35
- * plugin sass/scss
36
- * key "auto" for each-block
37
- * anchors for components
38
- * style templates, e.g. style:color={color}, style:border-color="red", style:border="1px solid {color}"
39
- * compile option "css"
40
- * event modifier: stop, prevent
41
- * script option "read-only"
42
- * constant props - "export const prop;"
43
- * compile option: debugLabel
44
- * slot for fragment
45
- * exported fragments (inverted slots)
46
- * <malina:head>, <malina:body>, <malina:window>
47
- * option: passClass
48
- * option: immutable
49
- * event modifiers: prevent, stop, ctrl, alt, shift, meta. key-events: enter, tab, esc, space, up, down, left, right, delete
50
- * inline actions for text-node and elements
51
- * portals: <malina:portal>
52
- * autoimport
53
-
54
- ## 0.5.x
55
-
56
- * input with type "range"/"number" - value as number
57
- * improve reactive expression
58
- * unwrap object in each
59
- * dynamic component
60
- * named slot
61
- * fix for dynamic import
62
- * option.onerror
63
- * autosubscribe for imported objects
64
- * compile time optinoption !no-check
65
- * fragments
66
- * event modifier: stopPropagation
67
- * $props, $attributes, $restProps
68
- * await-then-catch
69
- * :global classes
70
- * spreading props and objects {...obj}
71
- * forwarding events, forward all @@
72
- * onMount, onDestroy, $onDestroy
73
- * shortcuts for bindings and actions
74
- * scoped-css
75
- * conrol directives: each, if