@ktjs/core 0.24.4 → 0.26.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.
@@ -81,7 +81,7 @@ if (typeof Symbol === 'undefined') {
81
81
  }
82
82
 
83
83
  // Shared utilities and cached native methods for kt.js framework
84
- Object.defineProperty(window, '__ktjs__', { value: '0.22.6' });
84
+ Object.defineProperty(window, '__ktjs__', { value: '0.22.8' });
85
85
 
86
86
  // export const KT_TYPE_REF = 1 as const;
87
87
  // export const KT_TYPE_COMPUTED = 2 as const;
@@ -132,19 +132,41 @@ const handlers = {
132
132
  };
133
133
 
134
134
  const defaultHandler = (element, key, value) => element.setAttribute(key, value);
135
+ const setElementStyle = (element, style) => {
136
+ if (typeof style === 'string') {
137
+ element.style.cssText = style;
138
+ return;
139
+ }
140
+ for (const key in style) {
141
+ element.style[key] = style[key];
142
+ }
143
+ };
135
144
  function attrIsObject(element, attr) {
136
145
  const classValue = attr.class || attr.className;
137
146
  if (classValue !== undefined) {
138
- element.setAttribute('class', classValue);
147
+ if (isKT(classValue)) {
148
+ element.setAttribute('class', classValue.value);
149
+ classValue.addOnChange((v) => element.setAttribute('class', v));
150
+ }
151
+ else {
152
+ // todo 这里要让undefined 排除出reactify类型工具之外
153
+ element.setAttribute('class', classValue);
154
+ }
139
155
  }
156
+ // todo 这里加入reactive支持
157
+ // todo 类型定义也要支持reactive响应式
140
158
  const style = attr.style;
141
159
  if (style) {
142
160
  if (typeof style === 'string') {
143
161
  element.setAttribute('style', style);
144
162
  }
145
163
  else if (typeof style === 'object') {
146
- for (const key in style) {
147
- element.style[key] = style[key];
164
+ if (isKT(style)) {
165
+ setElementStyle(element, style.value);
166
+ style.addOnChange((v) => setElementStyle(element, v));
167
+ }
168
+ else {
169
+ setElementStyle(element, style);
148
170
  }
149
171
  }
150
172
  }
@@ -176,8 +198,14 @@ function attrIsObject(element, attr) {
176
198
  }
177
199
  // normal attributes
178
200
  else {
179
- // todo 这里也可以绑定ref的
180
- (handlers[key] || defaultHandler)(element, key, o);
201
+ const handler = handlers[key] || defaultHandler;
202
+ if (isKT(o)) {
203
+ handler(element, key, o.value);
204
+ o.addOnChange((v) => handler(element, key, v));
205
+ }
206
+ else {
207
+ handler(element, key, o);
208
+ }
181
209
  }
182
210
  }
183
211
  }
@@ -324,7 +352,7 @@ function ref(value, onChange) {
324
352
 
325
353
  function applyKModel(element, valueRef) {
326
354
  if (!isKT(valueRef)) {
327
- console.warn('[kt.js warn] k-model value must be a KTRef.');
355
+ console.warn('[kt.js warn]','k-model value must be a KTRef.');
328
356
  return;
329
357
  }
330
358
  if (element instanceof HTMLInputElement) {
@@ -342,7 +370,7 @@ function applyKModel(element, valueRef) {
342
370
  applyModel(element, valueRef, 'value', 'input');
343
371
  }
344
372
  else {
345
- console.warn('[kt.js warn] not supported element for k-model:');
373
+ console.warn('[kt.js warn]','not supported element for k-model:');
346
374
  }
347
375
  }
348
376
 
@@ -360,7 +388,7 @@ let creator = htmlCreator;
360
388
  * ## About
361
389
  * @package @ktjs/core
362
390
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
363
- * @version 0.24.4 (Last Update: 2026.02.05 13:57:50.861)
391
+ * @version 0.26.1 (Last Update: 2026.02.05 17:35:29.547)
364
392
  * @license MIT
365
393
  * @link https://github.com/baendlorel/kt.js
366
394
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -141,7 +141,7 @@ type KTAttribute = KTBaseAttribute & KTPrefixedEventAttribute;
141
141
  * ## About
142
142
  * @package @ktjs/core
143
143
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
144
- * @version 0.24.4 (Last Update: 2026.02.05 13:57:50.861)
144
+ * @version 0.26.1 (Last Update: 2026.02.05 17:35:29.547)
145
145
  * @license MIT
146
146
  * @link https://github.com/baendlorel/kt.js
147
147
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -81,7 +81,7 @@ if (typeof Symbol === 'undefined') {
81
81
  }
82
82
 
83
83
  // Shared utilities and cached native methods for kt.js framework
84
- Object.defineProperty(window, '__ktjs__', { value: '0.22.6' });
84
+ Object.defineProperty(window, '__ktjs__', { value: '0.22.8' });
85
85
 
86
86
  // export const KT_TYPE_REF = 1 as const;
87
87
  // export const KT_TYPE_COMPUTED = 2 as const;
@@ -132,19 +132,41 @@ const handlers = {
132
132
  };
133
133
 
134
134
  const defaultHandler = (element, key, value) => element.setAttribute(key, value);
135
+ const setElementStyle = (element, style) => {
136
+ if (typeof style === 'string') {
137
+ element.style.cssText = style;
138
+ return;
139
+ }
140
+ for (const key in style) {
141
+ element.style[key] = style[key];
142
+ }
143
+ };
135
144
  function attrIsObject(element, attr) {
136
145
  const classValue = attr.class || attr.className;
137
146
  if (classValue !== undefined) {
138
- element.setAttribute('class', classValue);
147
+ if (isKT(classValue)) {
148
+ element.setAttribute('class', classValue.value);
149
+ classValue.addOnChange((v) => element.setAttribute('class', v));
150
+ }
151
+ else {
152
+ // todo 这里要让undefined 排除出reactify类型工具之外
153
+ element.setAttribute('class', classValue);
154
+ }
139
155
  }
156
+ // todo 这里加入reactive支持
157
+ // todo 类型定义也要支持reactive响应式
140
158
  const style = attr.style;
141
159
  if (style) {
142
160
  if (typeof style === 'string') {
143
161
  element.setAttribute('style', style);
144
162
  }
145
163
  else if (typeof style === 'object') {
146
- for (const key in style) {
147
- element.style[key] = style[key];
164
+ if (isKT(style)) {
165
+ setElementStyle(element, style.value);
166
+ style.addOnChange((v) => setElementStyle(element, v));
167
+ }
168
+ else {
169
+ setElementStyle(element, style);
148
170
  }
149
171
  }
150
172
  }
@@ -176,8 +198,14 @@ function attrIsObject(element, attr) {
176
198
  }
177
199
  // normal attributes
178
200
  else {
179
- // todo 这里也可以绑定ref的
180
- (handlers[key] || defaultHandler)(element, key, o);
201
+ const handler = handlers[key] || defaultHandler;
202
+ if (isKT(o)) {
203
+ handler(element, key, o.value);
204
+ o.addOnChange((v) => handler(element, key, v));
205
+ }
206
+ else {
207
+ handler(element, key, o);
208
+ }
181
209
  }
182
210
  }
183
211
  }
@@ -324,7 +352,7 @@ function ref(value, onChange) {
324
352
 
325
353
  function applyKModel(element, valueRef) {
326
354
  if (!isKT(valueRef)) {
327
- console.warn('[kt.js warn] k-model value must be a KTRef.');
355
+ console.warn('[kt.js warn]','k-model value must be a KTRef.');
328
356
  return;
329
357
  }
330
358
  if (element instanceof HTMLInputElement) {
@@ -342,7 +370,7 @@ function applyKModel(element, valueRef) {
342
370
  applyModel(element, valueRef, 'value', 'input');
343
371
  }
344
372
  else {
345
- console.warn('[kt.js warn] not supported element for k-model:');
373
+ console.warn('[kt.js warn]','not supported element for k-model:');
346
374
  }
347
375
  }
348
376
 
@@ -360,7 +388,7 @@ let creator = htmlCreator;
360
388
  * ## About
361
389
  * @package @ktjs/core
362
390
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
363
- * @version 0.24.4 (Last Update: 2026.02.05 13:57:50.861)
391
+ * @version 0.26.1 (Last Update: 2026.02.05 17:35:29.547)
364
392
  * @license MIT
365
393
  * @link https://github.com/baendlorel/kt.js
366
394
  * @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.24.4",
3
+ "version": "0.26.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",
@@ -44,7 +44,7 @@
44
44
  "directory": "packages/core"
45
45
  },
46
46
  "dependencies": {
47
- "@ktjs/shared": "0.22.6"
47
+ "@ktjs/shared": "0.22.8"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "rollup -c rollup.config.mjs",