@ktjs/core 0.18.8 → 0.19.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.
package/dist/index.d.ts CHANGED
@@ -6,25 +6,32 @@ type otherstring = string & {};
6
6
  type HTMLTag = keyof HTMLElementTagNameMap;
7
7
  type SVGTag = keyof SVGElementTagNameMap;
8
8
 
9
- type ChangeHandler<T> = (newValue: T, oldValue: T) => void;
10
- interface KTRef<T> {
9
+ type RefChangeHandler<T> = (newValue: T, oldValue: T) => void;
10
+ declare class KTRef<T> {
11
+ /**
12
+ * Indicates that this is a KTRef instance
13
+ */
14
+ isKT: boolean;
15
+ private _value;
16
+ private _onChanges;
17
+ constructor(_value: T, _onChanges: Array<RefChangeHandler<T>>);
11
18
  /**
12
19
  * If new value and old value are both nodes, the old one will be replaced in the DOM
13
20
  */
14
- value: T;
15
- isKT: true;
16
- addOnChange: (callback: ChangeHandler<T>) => void;
17
- removeOnChange: (callback: ChangeHandler<T>) => void;
21
+ get value(): T;
22
+ set value(newValue: T);
23
+ addOnChange(callback: RefChangeHandler<T>): void;
24
+ removeOnChange(callback: RefChangeHandler<T>): boolean;
18
25
  }
19
26
  /**
20
27
  * Reference to the created HTML element.
21
28
  * - can alse be used to store normal values, but it is not reactive.
22
29
  * @param value mostly an HTMLElement
23
30
  */
24
- declare function ref<T = HTMLElement>(value?: T, onChange?: ChangeHandler<T>): KTRef<T>;
31
+ declare function ref<T = HTMLElement>(value?: T, onChange?: RefChangeHandler<T>): KTRef<T>;
25
32
 
26
33
  // Base events available to all HTML elements
27
- type BaseAttr = {
34
+ interface BaseAttr {
28
35
  [k: string]: any;
29
36
 
30
37
  // # base attributes
@@ -43,7 +50,7 @@ type BaseAttr = {
43
50
  'on:mouseleave'?: (ev: MouseEvent) => void;
44
51
  'on:mouseover'?: (ev: MouseEvent) => void;
45
52
  'on:mouseout'?: (ev: MouseEvent) => void;
46
- 'on:contextmenu'?: (ev: MouseEvent) => void;
53
+ 'on:contextmenu'?: (ev: PointerEvent) => void;
47
54
 
48
55
  // Keyboard events
49
56
  'on:keydown'?: (ev: KeyboardEvent) => void;
@@ -116,7 +123,7 @@ type BaseAttr = {
116
123
 
117
124
  // Resize event
118
125
  'on:resize'?: (ev: UIEvent) => void;
119
- };
126
+ }
120
127
 
121
128
  // Form-specific events
122
129
  interface FormElementEvents {
@@ -760,7 +767,7 @@ interface AttributesMap {
760
767
 
761
768
  svg: BaseAttr & {
762
769
  class?: string;
763
- style?: string;
770
+ style?: string | Partial<CSSStyleDeclaration>;
764
771
  width?: number | string;
765
772
  height?: number | string;
766
773
  viewBox?: string;
@@ -1215,7 +1222,7 @@ interface KTBaseAttribute {
1215
1222
  [k: string]: any;
1216
1223
 
1217
1224
  // # kt-specific attributes
1218
- ref?: KTRef<HTMLElement>;
1225
+ ref?: KTRef<KTHTMLElement>;
1219
1226
  'k-if'?: any;
1220
1227
 
1221
1228
  // # normal HTML attributes
@@ -1296,7 +1303,7 @@ type HTML<T extends (HTMLTag | SVGTag) & otherstring> = T extends SVGTag ? SVGEl
1296
1303
  * ## About
1297
1304
  * @package @ktjs/core
1298
1305
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
1299
- * @version 0.18.8 (Last Update: 2026.01.31 14:28:10.930)
1306
+ * @version 0.19.0 (Last Update: 2026.01.31 22:50:55.987)
1300
1307
  * @license MIT
1301
1308
  * @link https://github.com/baendlorel/kt.js
1302
1309
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -1342,7 +1349,7 @@ declare const jsxs: typeof jsx;
1342
1349
  * @param creator a simple creator function that returns an element
1343
1350
  * @returns created element
1344
1351
  */
1345
- declare function createRedrawableNoref(creator: () => KTHTMLElement): KTHTMLElement;
1352
+ declare function createRedrawableNoref<T extends KTHTMLElement>(creator: () => T): T;
1346
1353
  /**
1347
1354
  * A helper to create redrawable elements
1348
1355
  * ```tsx
@@ -1357,7 +1364,7 @@ declare function createRedrawableNoref(creator: () => KTHTMLElement): KTHTMLElem
1357
1364
  * @param creator a simple creator function that returns an element
1358
1365
  * @returns created element's ref
1359
1366
  */
1360
- declare function createRedrawable(creator: () => KTHTMLElement): KTRef<KTHTMLElement>;
1367
+ declare function createRedrawable<T extends KTHTMLElement>(creator: () => T): KTRef<T>;
1361
1368
 
1362
1369
  /**
1363
1370
  * Extract component props type (excluding ref and children)
@@ -1385,5 +1392,5 @@ interface KTForProps<T> {
1385
1392
  */
1386
1393
  declare function KTFor<T>(props: KTForProps<T>): KForElement;
1387
1394
 
1388
- export { Fragment, KTAsync, KTFor, h as createElement, createRedrawable, createRedrawableNoref, h, jsx, jsxDEV, jsxs, ref };
1389
- export type { EventHandler, HTMLTag, KTAttribute, KTForProps, KTHTMLElement, KTRawAttr, KTRawContent, KTRawContents, KTRef };
1395
+ export { Fragment, KTAsync, KTFor, KTRef, h as createElement, createRedrawable, createRedrawableNoref, h, jsx, jsxDEV, jsxs, ref };
1396
+ export type { EventHandler, HTMLTag, KTAttribute, KTForProps, KTHTMLElement, KTRawAttr, KTRawContent, KTRawContents };
@@ -1,10 +1,56 @@
1
1
  var __ktjs_core__ = (function (exports) {
2
2
  'use strict';
3
3
 
4
+ // Cached native methods for performance optimization
5
+ const $isArray = Array.isArray;
6
+ const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then === 'function';
7
+
8
+ // Error handling utilities
4
9
  const $throw = (message) => {
5
- throw new Error('kt.js: ' + message);
10
+ throw new Error('@ktjs/shared: ' + message);
6
11
  };
7
12
 
13
+ // DOM manipulation utilities
14
+ /**
15
+ * & Remove `bind` because it is shockingly slower than wrapper
16
+ * & `window.document` is safe because it is not configurable and its setter is undefined
17
+ */
18
+ const $appendChild = HTMLElement.prototype.appendChild;
19
+ const originAppend = HTMLElement.prototype.append;
20
+ const $append = // for ie 9/10/11
21
+ typeof originAppend === 'function'
22
+ ? originAppend
23
+ : function (...nodes) {
24
+ if (nodes.length < 50) {
25
+ for (let i = 0; i < nodes.length; i++) {
26
+ const node = nodes[i];
27
+ if (typeof node === 'string') {
28
+ $appendChild.call(this, document.createTextNode(node));
29
+ }
30
+ else {
31
+ $appendChild.call(this, node);
32
+ }
33
+ }
34
+ }
35
+ else {
36
+ const fragment = document.createDocumentFragment();
37
+ for (let i = 0; i < nodes.length; i++) {
38
+ const node = nodes[i];
39
+ if (typeof node === 'string') {
40
+ $appendChild.call(fragment, document.createTextNode(node));
41
+ }
42
+ else {
43
+ $appendChild.call(fragment, node);
44
+ }
45
+ }
46
+ $appendChild.call(this, fragment);
47
+ }
48
+ };
49
+
50
+ // Shared utilities and cached native methods for kt.js framework
51
+ // Re-export all utilities
52
+ Object.defineProperty(window, '@ktjs/shared', { value: '0.19.0' });
53
+
8
54
  const booleanHandler = (element, key, value) => {
9
55
  if (key in element) {
10
56
  element[key] = !!value;
@@ -75,7 +121,7 @@ var __ktjs_core__ = (function (exports) {
75
121
  const o = attr[key];
76
122
  // normal event handler
77
123
  if (key.startsWith('on:')) {
78
- element.addEventListener(key.slice(3), o); // chop off the `@`
124
+ element.addEventListener(key.slice(3), o); // chop off the `on:`
79
125
  }
80
126
  // normal attributes
81
127
  else {
@@ -95,51 +141,6 @@ var __ktjs_core__ = (function (exports) {
95
141
  }
96
142
  }
97
143
 
98
- /**
99
- * & Remove `bind` because it is shockingly slower than wrapper
100
- * & `window.document` is safe because it is not configurable and its setter is undefined
101
- */
102
- const $appendChild = HTMLElement.prototype.appendChild;
103
- const originAppend = HTMLElement.prototype.append;
104
- const $append = // for ie 9/10/11
105
- typeof originAppend === 'function'
106
- ? function (...args) {
107
- return originAppend.apply(this, args);
108
- }
109
- : function (...nodes) {
110
- if (nodes.length < 50) {
111
- for (let i = 0; i < nodes.length; i++) {
112
- const node = nodes[i];
113
- if (typeof node === 'string') {
114
- $appendChild.call(this, document.createTextNode(node));
115
- }
116
- else {
117
- $appendChild.call(this, node);
118
- }
119
- }
120
- }
121
- else {
122
- const fragment = document.createDocumentFragment();
123
- for (let i = 0; i < nodes.length; i++) {
124
- const node = nodes[i];
125
- if (typeof node === 'string') {
126
- $appendChild.call(fragment, document.createTextNode(node));
127
- }
128
- else {
129
- $appendChild.call(fragment, node);
130
- }
131
- }
132
- $appendChild.call(this, fragment);
133
- }
134
- };
135
-
136
- const $isArray = Array.isArray;
137
- const emptyPromiseHandler = () => ({});
138
- if (typeof Promise === 'undefined') {
139
- window.Promise = { resolve: emptyPromiseHandler, reject: emptyPromiseHandler };
140
- }
141
- const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then === 'function';
142
-
143
144
  function apdSingle(element, c) {
144
145
  // & JSX should ignore false, undefined, and null
145
146
  if (c === false || c === undefined || c === null) {
@@ -202,7 +203,7 @@ var __ktjs_core__ = (function (exports) {
202
203
  * ## About
203
204
  * @package @ktjs/core
204
205
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
205
- * @version 0.18.8 (Last Update: 2026.01.31 14:28:10.930)
206
+ * @version 0.19.0 (Last Update: 2026.01.31 22:50:55.987)
206
207
  * @license MIT
207
208
  * @link https://github.com/baendlorel/kt.js
208
209
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -225,47 +226,60 @@ var __ktjs_core__ = (function (exports) {
225
226
  return element;
226
227
  };
227
228
 
229
+ class KTRef {
230
+ /**
231
+ * Indicates that this is a KTRef instance
232
+ */
233
+ isKT = true;
234
+ _value;
235
+ _onChanges;
236
+ constructor(_value, _onChanges) {
237
+ this._value = _value;
238
+ this._onChanges = _onChanges;
239
+ }
240
+ /**
241
+ * If new value and old value are both nodes, the old one will be replaced in the DOM
242
+ */
243
+ get value() {
244
+ return this._value;
245
+ }
246
+ set value(newValue) {
247
+ if (newValue === this._value) {
248
+ return;
249
+ }
250
+ // replace the old node with the new one in the DOM if both are nodes
251
+ if (this._value instanceof Node && newValue instanceof Node) {
252
+ if (newValue.contains(this._value)) {
253
+ this._value.remove();
254
+ }
255
+ this._value.replaceWith(newValue);
256
+ }
257
+ const oldValue = this._value;
258
+ this._value = newValue;
259
+ for (let i = 0; i < this._onChanges.length; i++) {
260
+ this._onChanges[i](newValue, oldValue);
261
+ }
262
+ }
263
+ addOnChange(callback) {
264
+ this._onChanges.push(callback);
265
+ }
266
+ removeOnChange(callback) {
267
+ for (let i = this._onChanges.length - 1; i >= 0; i--) {
268
+ if (this._onChanges[i] === callback) {
269
+ this._onChanges.splice(i, 1);
270
+ return true;
271
+ }
272
+ }
273
+ return false;
274
+ }
275
+ }
228
276
  /**
229
277
  * Reference to the created HTML element.
230
278
  * - can alse be used to store normal values, but it is not reactive.
231
279
  * @param value mostly an HTMLElement
232
280
  */
233
281
  function ref(value, onChange) {
234
- let _value = value;
235
- let _onChanges = onChange ? [onChange] : [];
236
- return {
237
- isKT: true,
238
- get value() {
239
- return _value;
240
- },
241
- set value(newValue) {
242
- if (newValue === _value) {
243
- return;
244
- }
245
- // replace the old node with the new one in the DOM if both are nodes
246
- if (_value instanceof Node && newValue instanceof Node) {
247
- if (newValue.contains(_value)) {
248
- _value.remove();
249
- }
250
- _value.replaceWith(newValue);
251
- }
252
- const oldValue = _value;
253
- _value = newValue;
254
- for (let i = 0; i < _onChanges.length; i++) {
255
- _onChanges[i](newValue, oldValue);
256
- }
257
- },
258
- addOnChange: (callback) => _onChanges.push(callback),
259
- removeOnChange: (callback) => {
260
- for (let i = _onChanges.length - 1; i >= 0; i--) {
261
- if (_onChanges[i] === callback) {
262
- _onChanges.splice(i, 1);
263
- return true;
264
- }
265
- }
266
- return false;
267
- },
268
- };
282
+ return new KTRef(value, onChange ? [onChange] : []);
269
283
  }
270
284
 
271
285
  const dummyRef = { value: null };
@@ -280,13 +294,13 @@ var __ktjs_core__ = (function (exports) {
280
294
  props = newProps ? { ...props, ...newProps } : props;
281
295
  el = jsx(tag, props);
282
296
  if (ref !== dummyRef) {
283
- ref.value = el; // ref setter automatically replaces old element in DOM
297
+ ref.value = el; // & ref setter automatically replaces old element in DOM
284
298
  }
285
299
  return el;
286
300
  };
287
301
  if ('k-if' in props && !props['k-if']) {
288
302
  el = document.createComment('k-if');
289
- ref.value = el;
303
+ ref.value = el; // & ref setter automatically replaces old element in DOM
290
304
  el.redraw = redraw;
291
305
  return el;
292
306
  }
@@ -432,10 +446,10 @@ var __ktjs_core__ = (function (exports) {
432
446
  // Attach elements array to anchor
433
447
  anchor.__kt_for_list__ = elements;
434
448
  // Redraw function for updates
435
- anchor.redraw = (newProps = props) => {
436
- const newList = (newProps.list ?? currentList);
437
- const newKey = (newProps.key ?? currentKey);
438
- const newMap = (newProps.map ?? currentMap);
449
+ anchor.redraw = (newProps) => {
450
+ const newList = (newProps?.list ?? currentList);
451
+ const newKey = (newProps?.key ?? currentKey);
452
+ const newMap = (newProps?.map ?? currentMap);
439
453
  // Update stored values
440
454
  currentList = newList;
441
455
  currentKey = newKey;
@@ -620,6 +634,7 @@ var __ktjs_core__ = (function (exports) {
620
634
  exports.Fragment = Fragment;
621
635
  exports.KTAsync = KTAsync;
622
636
  exports.KTFor = KTFor;
637
+ exports.KTRef = KTRef;
623
638
  exports.createElement = h;
624
639
  exports.createRedrawable = createRedrawable;
625
640
  exports.createRedrawableNoref = createRedrawableNoref;
@@ -1,10 +1,56 @@
1
1
  var __ktjs_core__ = (function (exports) {
2
2
  'use strict';
3
3
 
4
- var $throw = function (message) {
5
- throw new Error('kt.js: ' + message);
4
+ // Cached native methods for performance optimization
5
+ const $isArray = Array.isArray;
6
+ const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then === 'function';
7
+
8
+ // Error handling utilities
9
+ const $throw = (message) => {
10
+ throw new Error('@ktjs/shared: ' + message);
6
11
  };
7
12
 
13
+ // DOM manipulation utilities
14
+ /**
15
+ * & Remove `bind` because it is shockingly slower than wrapper
16
+ * & `window.document` is safe because it is not configurable and its setter is undefined
17
+ */
18
+ const $appendChild = HTMLElement.prototype.appendChild;
19
+ const originAppend = HTMLElement.prototype.append;
20
+ const $append = // for ie 9/10/11
21
+ typeof originAppend === 'function'
22
+ ? originAppend
23
+ : function (...nodes) {
24
+ if (nodes.length < 50) {
25
+ for (let i = 0; i < nodes.length; i++) {
26
+ const node = nodes[i];
27
+ if (typeof node === 'string') {
28
+ $appendChild.call(this, document.createTextNode(node));
29
+ }
30
+ else {
31
+ $appendChild.call(this, node);
32
+ }
33
+ }
34
+ }
35
+ else {
36
+ const fragment = document.createDocumentFragment();
37
+ for (let i = 0; i < nodes.length; i++) {
38
+ const node = nodes[i];
39
+ if (typeof node === 'string') {
40
+ $appendChild.call(fragment, document.createTextNode(node));
41
+ }
42
+ else {
43
+ $appendChild.call(fragment, node);
44
+ }
45
+ }
46
+ $appendChild.call(this, fragment);
47
+ }
48
+ };
49
+
50
+ // Shared utilities and cached native methods for kt.js framework
51
+ // Re-export all utilities
52
+ Object.defineProperty(window, '@ktjs/shared', { value: '0.19.0' });
53
+
8
54
  var booleanHandler = function (element, key, value) {
9
55
  if (key in element) {
10
56
  element[key] = !!value;
@@ -75,7 +121,7 @@ var __ktjs_core__ = (function (exports) {
75
121
  var o = attr[key];
76
122
  // normal event handler
77
123
  if (key.startsWith('on:')) {
78
- element.addEventListener(key.slice(3), o); // chop off the `@`
124
+ element.addEventListener(key.slice(3), o); // chop off the `on:`
79
125
  }
80
126
  // normal attributes
81
127
  else {
@@ -95,61 +141,6 @@ var __ktjs_core__ = (function (exports) {
95
141
  }
96
142
  }
97
143
 
98
- /**
99
- * & Remove `bind` because it is shockingly slower than wrapper
100
- * & `window.document` is safe because it is not configurable and its setter is undefined
101
- */
102
- var $appendChild = HTMLElement.prototype.appendChild;
103
- var originAppend = HTMLElement.prototype.append;
104
- var $append = // for ie 9/10/11
105
- typeof originAppend === 'function'
106
- ? function () {
107
- var args = [];
108
- for (var _i = 0; _i < arguments.length; _i++) {
109
- args[_i] = arguments[_i];
110
- }
111
- return originAppend.apply(this, args);
112
- }
113
- : function () {
114
- var nodes = [];
115
- for (var _i = 0; _i < arguments.length; _i++) {
116
- nodes[_i] = arguments[_i];
117
- }
118
- if (nodes.length < 50) {
119
- for (var i = 0; i < nodes.length; i++) {
120
- var node = nodes[i];
121
- if (typeof node === 'string') {
122
- $appendChild.call(this, document.createTextNode(node));
123
- }
124
- else {
125
- $appendChild.call(this, node);
126
- }
127
- }
128
- }
129
- else {
130
- var fragment = document.createDocumentFragment();
131
- for (var i = 0; i < nodes.length; i++) {
132
- var node = nodes[i];
133
- if (typeof node === 'string') {
134
- $appendChild.call(fragment, document.createTextNode(node));
135
- }
136
- else {
137
- $appendChild.call(fragment, node);
138
- }
139
- }
140
- $appendChild.call(this, fragment);
141
- }
142
- };
143
-
144
- var $isArray = Array.isArray;
145
- var emptyPromiseHandler = function () { return ({}); };
146
- if (typeof Promise === 'undefined') {
147
- window.Promise = { resolve: emptyPromiseHandler, reject: emptyPromiseHandler };
148
- }
149
- var $isThenable = function (o) {
150
- return typeof o === 'object' && o !== null && typeof o.then === 'function';
151
- };
152
-
153
144
  function apdSingle(element, c) {
154
145
  // & JSX should ignore false, undefined, and null
155
146
  if (c === false || c === undefined || c === null) {
@@ -215,7 +206,7 @@ var __ktjs_core__ = (function (exports) {
215
206
  * ## About
216
207
  * @package @ktjs/core
217
208
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
218
- * @version 0.18.8 (Last Update: 2026.01.31 14:28:10.930)
209
+ * @version 0.19.0 (Last Update: 2026.01.31 22:50:55.987)
219
210
  * @license MIT
220
211
  * @link https://github.com/baendlorel/kt.js
221
212
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -271,47 +262,63 @@ var __ktjs_core__ = (function (exports) {
271
262
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
272
263
  };
273
264
 
274
- /**
275
- * Reference to the created HTML element.
276
- * - can alse be used to store normal values, but it is not reactive.
277
- * @param value mostly an HTMLElement
278
- */
279
- function ref(value, onChange) {
280
- var _value = value;
281
- var _onChanges = onChange ? [onChange] : [];
282
- return {
283
- isKT: true,
284
- get value() {
285
- return _value;
265
+ var KTRef = /** @class */ (function () {
266
+ function KTRef(_value, _onChanges) {
267
+ /**
268
+ * Indicates that this is a KTRef instance
269
+ */
270
+ this.isKT = true;
271
+ this._value = _value;
272
+ this._onChanges = _onChanges;
273
+ }
274
+ Object.defineProperty(KTRef.prototype, "value", {
275
+ /**
276
+ * If new value and old value are both nodes, the old one will be replaced in the DOM
277
+ */
278
+ get: function () {
279
+ return this._value;
286
280
  },
287
- set value(newValue) {
288
- if (newValue === _value) {
281
+ set: function (newValue) {
282
+ if (newValue === this._value) {
289
283
  return;
290
284
  }
291
285
  // replace the old node with the new one in the DOM if both are nodes
292
- if (_value instanceof Node && newValue instanceof Node) {
293
- if (newValue.contains(_value)) {
294
- _value.remove();
286
+ if (this._value instanceof Node && newValue instanceof Node) {
287
+ if (newValue.contains(this._value)) {
288
+ this._value.remove();
295
289
  }
296
- _value.replaceWith(newValue);
290
+ this._value.replaceWith(newValue);
297
291
  }
298
- var oldValue = _value;
299
- _value = newValue;
300
- for (var i = 0; i < _onChanges.length; i++) {
301
- _onChanges[i](newValue, oldValue);
292
+ var oldValue = this._value;
293
+ this._value = newValue;
294
+ for (var i = 0; i < this._onChanges.length; i++) {
295
+ this._onChanges[i](newValue, oldValue);
302
296
  }
303
297
  },
304
- addOnChange: function (callback) { return _onChanges.push(callback); },
305
- removeOnChange: function (callback) {
306
- for (var i = _onChanges.length - 1; i >= 0; i--) {
307
- if (_onChanges[i] === callback) {
308
- _onChanges.splice(i, 1);
309
- return true;
310
- }
298
+ enumerable: false,
299
+ configurable: true
300
+ });
301
+ KTRef.prototype.addOnChange = function (callback) {
302
+ this._onChanges.push(callback);
303
+ };
304
+ KTRef.prototype.removeOnChange = function (callback) {
305
+ for (var i = this._onChanges.length - 1; i >= 0; i--) {
306
+ if (this._onChanges[i] === callback) {
307
+ this._onChanges.splice(i, 1);
308
+ return true;
311
309
  }
312
- return false;
313
- },
310
+ }
311
+ return false;
314
312
  };
313
+ return KTRef;
314
+ }());
315
+ /**
316
+ * Reference to the created HTML element.
317
+ * - can alse be used to store normal values, but it is not reactive.
318
+ * @param value mostly an HTMLElement
319
+ */
320
+ function ref(value, onChange) {
321
+ return new KTRef(value, onChange ? [onChange] : []);
315
322
  }
316
323
 
317
324
  var dummyRef = { value: null };
@@ -328,13 +335,13 @@ var __ktjs_core__ = (function (exports) {
328
335
  props = newProps ? __assign(__assign({}, props), newProps) : props;
329
336
  el = jsx(tag, props);
330
337
  if (ref !== dummyRef) {
331
- ref.value = el; // ref setter automatically replaces old element in DOM
338
+ ref.value = el; // & ref setter automatically replaces old element in DOM
332
339
  }
333
340
  return el;
334
341
  };
335
342
  if ('k-if' in props && !props['k-if']) {
336
343
  el = document.createComment('k-if');
337
- ref.value = el;
344
+ ref.value = el; // & ref setter automatically replaces old element in DOM
338
345
  el.redraw = redraw;
339
346
  return el;
340
347
  }
@@ -488,10 +495,9 @@ var __ktjs_core__ = (function (exports) {
488
495
  // Redraw function for updates
489
496
  anchor.redraw = function (newProps) {
490
497
  var _a, _b, _c;
491
- if (newProps === void 0) { newProps = props; }
492
- var newList = ((_a = newProps.list) !== null && _a !== void 0 ? _a : currentList);
493
- var newKey = ((_b = newProps.key) !== null && _b !== void 0 ? _b : currentKey);
494
- var newMap = ((_c = newProps.map) !== null && _c !== void 0 ? _c : currentMap);
498
+ var newList = ((_a = newProps === null || newProps === void 0 ? void 0 : newProps.list) !== null && _a !== void 0 ? _a : currentList);
499
+ var newKey = ((_b = newProps === null || newProps === void 0 ? void 0 : newProps.key) !== null && _b !== void 0 ? _b : currentKey);
500
+ var newMap = ((_c = newProps === null || newProps === void 0 ? void 0 : newProps.map) !== null && _c !== void 0 ? _c : currentMap);
495
501
  // Update stored values
496
502
  currentList = newList;
497
503
  currentKey = newKey;
@@ -676,6 +682,7 @@ var __ktjs_core__ = (function (exports) {
676
682
  exports.Fragment = Fragment;
677
683
  exports.KTAsync = KTAsync;
678
684
  exports.KTFor = KTFor;
685
+ exports.KTRef = KTRef;
679
686
  exports.createElement = h;
680
687
  exports.createRedrawable = createRedrawable;
681
688
  exports.createRedrawableNoref = createRedrawableNoref;