@ktjs/core 0.16.0 → 0.16.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.
package/dist/index.d.ts CHANGED
@@ -168,7 +168,7 @@ type HTML<T extends (HTMLTag | SVGTag) & otherstring> = T extends SVGTag ? SVGEl
168
168
  * ## About
169
169
  * @package @ktjs/core
170
170
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
171
- * @version 0.16.0 (Last Update: 2026.01.27 17:30:39.673)
171
+ * @version 0.16.1 (Last Update: 2026.01.28 08:51:19.714)
172
172
  * @license MIT
173
173
  * @link https://github.com/baendlorel/kt.js
174
174
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -248,11 +248,11 @@ interface KTForProps<T> {
248
248
  * Key function to uniquely identify each item
249
249
  * Using stable keys enables efficient DOM reuse and updates
250
250
  */
251
- key: (item: T, index: number) => string | number;
251
+ key: (item: T, index: number, array: T[]) => string | number;
252
252
  /**
253
253
  * Mapper function to render each item
254
254
  */
255
- mapper: (item: T, index: number) => HTMLElement;
255
+ mapper: (item: T, index: number, array: T[]) => HTMLElement;
256
256
  }
257
257
  /**
258
258
  * Extended Comment node with redraw capability for KTFor
@@ -260,7 +260,7 @@ interface KTForProps<T> {
260
260
  interface KTForAnchor extends Comment {
261
261
  redraw: (newProps?: {
262
262
  list?: any[];
263
- mapper?: (item: any, index: number) => HTMLElement;
263
+ mapper?: (item: any, index: number, array: any[]) => HTMLElement;
264
264
  }) => void;
265
265
  }
266
266
  /**
@@ -292,13 +292,13 @@ declare function KTFor<T>(props: KTForProps<T>): KTForAnchor;
292
292
  *
293
293
  * @example
294
294
  * ```tsx
295
- * const listAnchor = <KTForStatic
295
+ * const listAnchor = <KTForConst
296
296
  * list={items}
297
297
  * mapper={(item) => <div>{item}</div>}
298
298
  * /> as KTForAnchor;
299
299
  * ```
300
300
  */
301
- declare function KTForStatic<T>(props: Omit<KTForProps<T>, 'key'>): KTForAnchor;
301
+ declare function KTForConst<T>(props: Omit<KTForProps<T>, 'key'>): KTForAnchor;
302
302
 
303
- export { Fragment, KTAsync, KTFor, KTForStatic, h as createElement, createRedrawable, createRedrawableNoref, h, jsx, jsxDEV, jsxs, ref };
303
+ export { Fragment, KTAsync, KTFor, KTForConst, h as createElement, createRedrawable, createRedrawableNoref, h, jsx, jsxDEV, jsxs, ref };
304
304
  export type { EventHandler, HTMLTag, KTAttribute, KTForAnchor, KTForProps, KTHTMLElement, KTRawAttr, KTRawContent, KTRawContents, KTRef };
@@ -206,7 +206,7 @@ var __ktjs_core__ = (function (exports) {
206
206
  * ## About
207
207
  * @package @ktjs/core
208
208
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
209
- * @version 0.16.0 (Last Update: 2026.01.27 17:30:39.673)
209
+ * @version 0.16.1 (Last Update: 2026.01.28 08:51:19.714)
210
210
  * @license MIT
211
211
  * @link https://github.com/baendlorel/kt.js
212
212
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -432,8 +432,8 @@ var __ktjs_core__ = (function (exports) {
432
432
  const initialize = () => {
433
433
  for (let i = 0; i < initList.length; i++) {
434
434
  const item = initList[i];
435
- const key = getKey(item, i);
436
- const node = mapper(item, i);
435
+ const key = getKey(item, i, initList);
436
+ const node = mapper(item, i, initList);
437
437
  nodeCache.set(key, { node, item });
438
438
  currentKeys.push(key);
439
439
  // Append to parent if anchor is already in DOM
@@ -454,7 +454,7 @@ var __ktjs_core__ = (function (exports) {
454
454
  */
455
455
  const smartUpdate = (newList, newMapper) => {
456
456
  const mapperFn = newMapper ?? mapper;
457
- const newKeys = newList.map((item, index) => getKey(item, index));
457
+ const newKeys = newList.map((item, index) => getKey(item, index, newList));
458
458
  if (!anchor.parentNode) {
459
459
  // If anchor is not in DOM yet, just update cache
460
460
  nodeCache.clear();
@@ -462,7 +462,7 @@ var __ktjs_core__ = (function (exports) {
462
462
  for (let i = 0; i < newList.length; i++) {
463
463
  const item = newList[i];
464
464
  const key = newKeys[i];
465
- const node = mapperFn(item, i);
465
+ const node = mapperFn(item, i, newList);
466
466
  nodeCache.set(key, { node, item });
467
467
  currentKeys.push(key);
468
468
  }
@@ -486,7 +486,7 @@ var __ktjs_core__ = (function (exports) {
486
486
  let cached = nodeCache.get(key);
487
487
  // New item: create and cache
488
488
  if (!cached) {
489
- const node = mapperFn(item, i);
489
+ const node = mapperFn(item, i, newList);
490
490
  cached = { node, item };
491
491
  nodeCache.set(key, cached);
492
492
  }
@@ -525,16 +525,16 @@ var __ktjs_core__ = (function (exports) {
525
525
  *
526
526
  * @example
527
527
  * ```tsx
528
- * const listAnchor = <KTForStatic
528
+ * const listAnchor = <KTForConst
529
529
  * list={items}
530
530
  * mapper={(item) => <div>{item}</div>}
531
531
  * /> as KTForAnchor;
532
532
  * ```
533
533
  */
534
- function KTForStatic(props) {
534
+ function KTForConst(props) {
535
535
  const { list: initList, mapper } = props;
536
536
  // Create anchor comment node
537
- const anchor = document.createComment('kt-for-static');
537
+ const anchor = document.createComment('kt-for-const');
538
538
  let nodes = [];
539
539
  // Simple rebuild on redraw
540
540
  const rebuild = (newList) => {
@@ -550,7 +550,7 @@ var __ktjs_core__ = (function (exports) {
550
550
  let previousNode = anchor;
551
551
  for (let i = 0; i < newList.length; i++) {
552
552
  const item = newList[i];
553
- const node = mapper(item, i);
553
+ const node = mapper(item, i, newList);
554
554
  nodes.push(node);
555
555
  if (anchor.parentNode) {
556
556
  if (previousNode.nextSibling) {
@@ -577,7 +577,7 @@ var __ktjs_core__ = (function (exports) {
577
577
  exports.Fragment = Fragment;
578
578
  exports.KTAsync = KTAsync;
579
579
  exports.KTFor = KTFor;
580
- exports.KTForStatic = KTForStatic;
580
+ exports.KTForConst = KTForConst;
581
581
  exports.createElement = h;
582
582
  exports.createRedrawable = createRedrawable;
583
583
  exports.createRedrawableNoref = createRedrawableNoref;
@@ -231,7 +231,7 @@ var __ktjs_core__ = (function (exports) {
231
231
  * ## About
232
232
  * @package @ktjs/core
233
233
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
234
- * @version 0.16.0 (Last Update: 2026.01.27 17:30:39.673)
234
+ * @version 0.16.1 (Last Update: 2026.01.28 08:51:19.714)
235
235
  * @license MIT
236
236
  * @link https://github.com/baendlorel/kt.js
237
237
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -497,8 +497,8 @@ var __ktjs_core__ = (function (exports) {
497
497
  var initialize = function () {
498
498
  for (var i = 0; i < initList.length; i++) {
499
499
  var item = initList[i];
500
- var key = getKey(item, i);
501
- var node = mapper(item, i);
500
+ var key = getKey(item, i, initList);
501
+ var node = mapper(item, i, initList);
502
502
  nodeCache.set(key, { node: node, item: item });
503
503
  currentKeys.push(key);
504
504
  // Append to parent if anchor is already in DOM
@@ -519,7 +519,7 @@ var __ktjs_core__ = (function (exports) {
519
519
  */
520
520
  var smartUpdate = function (newList, newMapper) {
521
521
  var mapperFn = newMapper !== null && newMapper !== void 0 ? newMapper : mapper;
522
- var newKeys = newList.map(function (item, index) { return getKey(item, index); });
522
+ var newKeys = newList.map(function (item, index) { return getKey(item, index, newList); });
523
523
  if (!anchor.parentNode) {
524
524
  // If anchor is not in DOM yet, just update cache
525
525
  nodeCache.clear();
@@ -527,7 +527,7 @@ var __ktjs_core__ = (function (exports) {
527
527
  for (var i = 0; i < newList.length; i++) {
528
528
  var item = newList[i];
529
529
  var key = newKeys[i];
530
- var node = mapperFn(item, i);
530
+ var node = mapperFn(item, i, newList);
531
531
  nodeCache.set(key, { node: node, item: item });
532
532
  currentKeys.push(key);
533
533
  }
@@ -551,7 +551,7 @@ var __ktjs_core__ = (function (exports) {
551
551
  var cached = nodeCache.get(key);
552
552
  // New item: create and cache
553
553
  if (!cached) {
554
- var node = mapperFn(item, i);
554
+ var node = mapperFn(item, i, newList);
555
555
  cached = { node: node, item: item };
556
556
  nodeCache.set(key, cached);
557
557
  }
@@ -590,16 +590,16 @@ var __ktjs_core__ = (function (exports) {
590
590
  *
591
591
  * @example
592
592
  * ```tsx
593
- * const listAnchor = <KTForStatic
593
+ * const listAnchor = <KTForConst
594
594
  * list={items}
595
595
  * mapper={(item) => <div>{item}</div>}
596
596
  * /> as KTForAnchor;
597
597
  * ```
598
598
  */
599
- function KTForStatic(props) {
599
+ function KTForConst(props) {
600
600
  var initList = props.list, mapper = props.mapper;
601
601
  // Create anchor comment node
602
- var anchor = document.createComment('kt-for-static');
602
+ var anchor = document.createComment('kt-for-const');
603
603
  var nodes = [];
604
604
  // Simple rebuild on redraw
605
605
  var rebuild = function (newList) {
@@ -615,7 +615,7 @@ var __ktjs_core__ = (function (exports) {
615
615
  var previousNode = anchor;
616
616
  for (var i = 0; i < newList.length; i++) {
617
617
  var item = newList[i];
618
- var node = mapper(item, i);
618
+ var node = mapper(item, i, newList);
619
619
  nodes.push(node);
620
620
  if (anchor.parentNode) {
621
621
  if (previousNode.nextSibling) {
@@ -642,7 +642,7 @@ var __ktjs_core__ = (function (exports) {
642
642
  exports.Fragment = Fragment;
643
643
  exports.KTAsync = KTAsync;
644
644
  exports.KTFor = KTFor;
645
- exports.KTForStatic = KTForStatic;
645
+ exports.KTForConst = KTForConst;
646
646
  exports.createElement = h;
647
647
  exports.createRedrawable = createRedrawable;
648
648
  exports.createRedrawableNoref = createRedrawableNoref;
package/dist/index.mjs CHANGED
@@ -203,7 +203,7 @@ let creator = defaultCreator;
203
203
  * ## About
204
204
  * @package @ktjs/core
205
205
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
206
- * @version 0.16.0 (Last Update: 2026.01.27 17:30:39.673)
206
+ * @version 0.16.1 (Last Update: 2026.01.28 08:51:19.714)
207
207
  * @license MIT
208
208
  * @link https://github.com/baendlorel/kt.js
209
209
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -429,8 +429,8 @@ function KTFor(props) {
429
429
  const initialize = () => {
430
430
  for (let i = 0; i < initList.length; i++) {
431
431
  const item = initList[i];
432
- const key = getKey(item, i);
433
- const node = mapper(item, i);
432
+ const key = getKey(item, i, initList);
433
+ const node = mapper(item, i, initList);
434
434
  nodeCache.set(key, { node, item });
435
435
  currentKeys.push(key);
436
436
  // Append to parent if anchor is already in DOM
@@ -451,7 +451,7 @@ function KTFor(props) {
451
451
  */
452
452
  const smartUpdate = (newList, newMapper) => {
453
453
  const mapperFn = newMapper ?? mapper;
454
- const newKeys = newList.map((item, index) => getKey(item, index));
454
+ const newKeys = newList.map((item, index) => getKey(item, index, newList));
455
455
  if (!anchor.parentNode) {
456
456
  // If anchor is not in DOM yet, just update cache
457
457
  nodeCache.clear();
@@ -459,7 +459,7 @@ function KTFor(props) {
459
459
  for (let i = 0; i < newList.length; i++) {
460
460
  const item = newList[i];
461
461
  const key = newKeys[i];
462
- const node = mapperFn(item, i);
462
+ const node = mapperFn(item, i, newList);
463
463
  nodeCache.set(key, { node, item });
464
464
  currentKeys.push(key);
465
465
  }
@@ -483,7 +483,7 @@ function KTFor(props) {
483
483
  let cached = nodeCache.get(key);
484
484
  // New item: create and cache
485
485
  if (!cached) {
486
- const node = mapperFn(item, i);
486
+ const node = mapperFn(item, i, newList);
487
487
  cached = { node, item };
488
488
  nodeCache.set(key, cached);
489
489
  }
@@ -522,16 +522,16 @@ function KTFor(props) {
522
522
  *
523
523
  * @example
524
524
  * ```tsx
525
- * const listAnchor = <KTForStatic
525
+ * const listAnchor = <KTForConst
526
526
  * list={items}
527
527
  * mapper={(item) => <div>{item}</div>}
528
528
  * /> as KTForAnchor;
529
529
  * ```
530
530
  */
531
- function KTForStatic(props) {
531
+ function KTForConst(props) {
532
532
  const { list: initList, mapper } = props;
533
533
  // Create anchor comment node
534
- const anchor = document.createComment('kt-for-static');
534
+ const anchor = document.createComment('kt-for-const');
535
535
  let nodes = [];
536
536
  // Simple rebuild on redraw
537
537
  const rebuild = (newList) => {
@@ -547,7 +547,7 @@ function KTForStatic(props) {
547
547
  let previousNode = anchor;
548
548
  for (let i = 0; i < newList.length; i++) {
549
549
  const item = newList[i];
550
- const node = mapper(item, i);
550
+ const node = mapper(item, i, newList);
551
551
  nodes.push(node);
552
552
  if (anchor.parentNode) {
553
553
  if (previousNode.nextSibling) {
@@ -571,4 +571,4 @@ function KTForStatic(props) {
571
571
  return anchor;
572
572
  }
573
573
 
574
- export { Fragment, KTAsync, KTFor, KTForStatic, h as createElement, createRedrawable, createRedrawableNoref, h, jsx, jsxDEV, jsxs, ref };
574
+ export { Fragment, KTAsync, KTFor, KTForConst, h as createElement, createRedrawable, createRedrawableNoref, h, jsx, jsxDEV, jsxs, ref };
@@ -154,7 +154,7 @@ type HTML<T extends (HTMLTag | SVGTag) & otherstring> = T extends SVGTag ? SVGEl
154
154
  * ## About
155
155
  * @package @ktjs/core
156
156
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
157
- * @version 0.16.0 (Last Update: 2026.01.27 17:30:39.673)
157
+ * @version 0.16.1 (Last Update: 2026.01.28 08:51:19.714)
158
158
  * @license MIT
159
159
  * @link https://github.com/baendlorel/kt.js
160
160
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -203,7 +203,7 @@ let creator = defaultCreator;
203
203
  * ## About
204
204
  * @package @ktjs/core
205
205
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
206
- * @version 0.16.0 (Last Update: 2026.01.27 17:30:39.673)
206
+ * @version 0.16.1 (Last Update: 2026.01.28 08:51:19.714)
207
207
  * @license MIT
208
208
  * @link https://github.com/baendlorel/kt.js
209
209
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -148,7 +148,7 @@ type HTML<T extends (HTMLTag | SVGTag) & otherstring> = T extends SVGTag ? SVGEl
148
148
  * ## About
149
149
  * @package @ktjs/core
150
150
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
151
- * @version 0.16.0 (Last Update: 2026.01.27 17:30:39.673)
151
+ * @version 0.16.1 (Last Update: 2026.01.28 08:51:19.714)
152
152
  * @license MIT
153
153
  * @link https://github.com/baendlorel/kt.js
154
154
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -203,7 +203,7 @@ let creator = defaultCreator;
203
203
  * ## About
204
204
  * @package @ktjs/core
205
205
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
206
- * @version 0.16.0 (Last Update: 2026.01.27 17:30:39.673)
206
+ * @version 0.16.1 (Last Update: 2026.01.28 08:51:19.714)
207
207
  * @license MIT
208
208
  * @link https://github.com/baendlorel/kt.js
209
209
  * @link https://baendlorel.github.io/ Welcome to my site!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/core",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",