@ktjs/core 0.25.0 → 0.26.2
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 +516 -464
- package/dist/index.iife.js +32 -9
- package/dist/index.legacy.js +37 -11
- package/dist/index.mjs +32 -9
- package/dist/jsx/index.d.ts +539 -463
- package/dist/jsx/index.mjs +32 -9
- package/dist/jsx/jsx-runtime.d.ts +1 -1
- package/dist/jsx/jsx-runtime.mjs +32 -9
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -93,9 +93,6 @@ var __ktjs_core__ = (function (exports) {
|
|
|
93
93
|
// Shared utilities and cached native methods for kt.js framework
|
|
94
94
|
Object.defineProperty(window, '__ktjs__', { value: '0.22.8' });
|
|
95
95
|
|
|
96
|
-
// export const KT_TYPE_REF = 1 as const;
|
|
97
|
-
// export const KT_TYPE_COMPUTED = 2 as const;
|
|
98
|
-
// export type KTReactiveTypeEnum = typeof KT_TYPE_REF | typeof KT_TYPE_COMPUTED;
|
|
99
96
|
const isKT = (obj) => obj?.isKT;
|
|
100
97
|
const isRef = (obj) => obj?.ktType === 1 /* KTReactiveType.REF */;
|
|
101
98
|
const isComputed = (obj) => obj?.ktType === 2 /* KTReactiveType.COMPUTED */;
|
|
@@ -142,19 +139,39 @@ var __ktjs_core__ = (function (exports) {
|
|
|
142
139
|
};
|
|
143
140
|
|
|
144
141
|
const defaultHandler = (element, key, value) => element.setAttribute(key, value);
|
|
142
|
+
const setElementStyle = (element, style) => {
|
|
143
|
+
if (typeof style === 'string') {
|
|
144
|
+
element.style.cssText = style;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
for (const key in style) {
|
|
148
|
+
element.style[key] = style[key];
|
|
149
|
+
}
|
|
150
|
+
};
|
|
145
151
|
function attrIsObject(element, attr) {
|
|
146
152
|
const classValue = attr.class || attr.className;
|
|
147
153
|
if (classValue !== undefined) {
|
|
148
|
-
|
|
154
|
+
if (isKT(classValue)) {
|
|
155
|
+
element.setAttribute('class', classValue.value);
|
|
156
|
+
classValue.addOnChange((v) => element.setAttribute('class', v));
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
element.setAttribute('class', classValue);
|
|
160
|
+
}
|
|
149
161
|
}
|
|
162
|
+
// todo 这里加入reactive支持
|
|
150
163
|
const style = attr.style;
|
|
151
164
|
if (style) {
|
|
152
165
|
if (typeof style === 'string') {
|
|
153
166
|
element.setAttribute('style', style);
|
|
154
167
|
}
|
|
155
168
|
else if (typeof style === 'object') {
|
|
156
|
-
|
|
157
|
-
element
|
|
169
|
+
if (isKT(style)) {
|
|
170
|
+
setElementStyle(element, style.value);
|
|
171
|
+
style.addOnChange((v) => setElementStyle(element, v));
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
setElementStyle(element, style);
|
|
158
175
|
}
|
|
159
176
|
}
|
|
160
177
|
}
|
|
@@ -186,8 +203,14 @@ var __ktjs_core__ = (function (exports) {
|
|
|
186
203
|
}
|
|
187
204
|
// normal attributes
|
|
188
205
|
else {
|
|
189
|
-
|
|
190
|
-
|
|
206
|
+
const handler = handlers[key] || defaultHandler;
|
|
207
|
+
if (isKT(o)) {
|
|
208
|
+
handler(element, key, o.value);
|
|
209
|
+
o.addOnChange((v) => handler(element, key, v));
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
handler(element, key, o);
|
|
213
|
+
}
|
|
191
214
|
}
|
|
192
215
|
}
|
|
193
216
|
}
|
|
@@ -571,7 +594,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
571
594
|
* ## About
|
|
572
595
|
* @package @ktjs/core
|
|
573
596
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
574
|
-
* @version 0.
|
|
597
|
+
* @version 0.26.2 (Last Update: 2026.02.05 20:44:45.309)
|
|
575
598
|
* @license MIT
|
|
576
599
|
* @link https://github.com/baendlorel/kt.js
|
|
577
600
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/index.legacy.js
CHANGED
|
@@ -93,9 +93,6 @@ var __ktjs_core__ = (function (exports) {
|
|
|
93
93
|
// Shared utilities and cached native methods for kt.js framework
|
|
94
94
|
Object.defineProperty(window, '__ktjs__', { value: '0.22.8' });
|
|
95
95
|
|
|
96
|
-
// export const KT_TYPE_REF = 1 as const;
|
|
97
|
-
// export const KT_TYPE_COMPUTED = 2 as const;
|
|
98
|
-
// export type KTReactiveTypeEnum = typeof KT_TYPE_REF | typeof KT_TYPE_COMPUTED;
|
|
99
96
|
var isKT = function (obj) { return obj === null || obj === void 0 ? void 0 : obj.isKT; };
|
|
100
97
|
var isRef = function (obj) { return (obj === null || obj === void 0 ? void 0 : obj.ktType) === 1 /* KTReactiveType.REF */; };
|
|
101
98
|
var isComputed = function (obj) { return (obj === null || obj === void 0 ? void 0 : obj.ktType) === 2 /* KTReactiveType.COMPUTED */; };
|
|
@@ -144,19 +141,39 @@ var __ktjs_core__ = (function (exports) {
|
|
|
144
141
|
var defaultHandler = function (element, key, value) {
|
|
145
142
|
return element.setAttribute(key, value);
|
|
146
143
|
};
|
|
144
|
+
var setElementStyle = function (element, style) {
|
|
145
|
+
if (typeof style === 'string') {
|
|
146
|
+
element.style.cssText = style;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
for (var key in style) {
|
|
150
|
+
element.style[key] = style[key];
|
|
151
|
+
}
|
|
152
|
+
};
|
|
147
153
|
function attrIsObject(element, attr) {
|
|
148
154
|
var classValue = attr.class || attr.className;
|
|
149
155
|
if (classValue !== undefined) {
|
|
150
|
-
|
|
156
|
+
if (isKT(classValue)) {
|
|
157
|
+
element.setAttribute('class', classValue.value);
|
|
158
|
+
classValue.addOnChange(function (v) { return element.setAttribute('class', v); });
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
element.setAttribute('class', classValue);
|
|
162
|
+
}
|
|
151
163
|
}
|
|
164
|
+
// todo 这里加入reactive支持
|
|
152
165
|
var style = attr.style;
|
|
153
166
|
if (style) {
|
|
154
167
|
if (typeof style === 'string') {
|
|
155
168
|
element.setAttribute('style', style);
|
|
156
169
|
}
|
|
157
170
|
else if (typeof style === 'object') {
|
|
158
|
-
|
|
159
|
-
element
|
|
171
|
+
if (isKT(style)) {
|
|
172
|
+
setElementStyle(element, style.value);
|
|
173
|
+
style.addOnChange(function (v) { return setElementStyle(element, v); });
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
setElementStyle(element, style);
|
|
160
177
|
}
|
|
161
178
|
}
|
|
162
179
|
}
|
|
@@ -170,7 +187,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
170
187
|
element.innerHTML = html;
|
|
171
188
|
}
|
|
172
189
|
}
|
|
173
|
-
|
|
190
|
+
var _loop_1 = function (key) {
|
|
174
191
|
if (key === 'k-if' ||
|
|
175
192
|
key === 'k-model' ||
|
|
176
193
|
key === 'ref' ||
|
|
@@ -179,7 +196,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
179
196
|
key === 'style' ||
|
|
180
197
|
key === 'children' ||
|
|
181
198
|
key === 'k-html') {
|
|
182
|
-
continue;
|
|
199
|
+
return "continue";
|
|
183
200
|
}
|
|
184
201
|
var o = attr[key];
|
|
185
202
|
// normal event handler
|
|
@@ -188,9 +205,18 @@ var __ktjs_core__ = (function (exports) {
|
|
|
188
205
|
}
|
|
189
206
|
// normal attributes
|
|
190
207
|
else {
|
|
191
|
-
|
|
192
|
-
|
|
208
|
+
var handler_1 = handlers[key] || defaultHandler;
|
|
209
|
+
if (isKT(o)) {
|
|
210
|
+
handler_1(element, key, o.value);
|
|
211
|
+
o.addOnChange(function (v) { return handler_1(element, key, v); });
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
handler_1(element, key, o);
|
|
215
|
+
}
|
|
193
216
|
}
|
|
217
|
+
};
|
|
218
|
+
for (var key in attr) {
|
|
219
|
+
_loop_1(key);
|
|
194
220
|
}
|
|
195
221
|
}
|
|
196
222
|
function applyAttr(element, attr) {
|
|
@@ -571,7 +597,7 @@ var __ktjs_core__ = (function (exports) {
|
|
|
571
597
|
* ## About
|
|
572
598
|
* @package @ktjs/core
|
|
573
599
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
574
|
-
* @version 0.
|
|
600
|
+
* @version 0.26.2 (Last Update: 2026.02.05 20:44:45.309)
|
|
575
601
|
* @license MIT
|
|
576
602
|
* @link https://github.com/baendlorel/kt.js
|
|
577
603
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
package/dist/index.mjs
CHANGED
|
@@ -90,9 +90,6 @@ if (typeof Symbol === 'undefined') {
|
|
|
90
90
|
// Shared utilities and cached native methods for kt.js framework
|
|
91
91
|
Object.defineProperty(window, '__ktjs__', { value: '0.22.8' });
|
|
92
92
|
|
|
93
|
-
// export const KT_TYPE_REF = 1 as const;
|
|
94
|
-
// export const KT_TYPE_COMPUTED = 2 as const;
|
|
95
|
-
// export type KTReactiveTypeEnum = typeof KT_TYPE_REF | typeof KT_TYPE_COMPUTED;
|
|
96
93
|
const isKT = (obj) => obj?.isKT;
|
|
97
94
|
const isRef = (obj) => obj?.ktType === 1 /* KTReactiveType.REF */;
|
|
98
95
|
const isComputed = (obj) => obj?.ktType === 2 /* KTReactiveType.COMPUTED */;
|
|
@@ -139,19 +136,39 @@ const handlers = {
|
|
|
139
136
|
};
|
|
140
137
|
|
|
141
138
|
const defaultHandler = (element, key, value) => element.setAttribute(key, value);
|
|
139
|
+
const setElementStyle = (element, style) => {
|
|
140
|
+
if (typeof style === 'string') {
|
|
141
|
+
element.style.cssText = style;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
for (const key in style) {
|
|
145
|
+
element.style[key] = style[key];
|
|
146
|
+
}
|
|
147
|
+
};
|
|
142
148
|
function attrIsObject(element, attr) {
|
|
143
149
|
const classValue = attr.class || attr.className;
|
|
144
150
|
if (classValue !== undefined) {
|
|
145
|
-
|
|
151
|
+
if (isKT(classValue)) {
|
|
152
|
+
element.setAttribute('class', classValue.value);
|
|
153
|
+
classValue.addOnChange((v) => element.setAttribute('class', v));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
element.setAttribute('class', classValue);
|
|
157
|
+
}
|
|
146
158
|
}
|
|
159
|
+
// todo 这里加入reactive支持
|
|
147
160
|
const style = attr.style;
|
|
148
161
|
if (style) {
|
|
149
162
|
if (typeof style === 'string') {
|
|
150
163
|
element.setAttribute('style', style);
|
|
151
164
|
}
|
|
152
165
|
else if (typeof style === 'object') {
|
|
153
|
-
|
|
154
|
-
element
|
|
166
|
+
if (isKT(style)) {
|
|
167
|
+
setElementStyle(element, style.value);
|
|
168
|
+
style.addOnChange((v) => setElementStyle(element, v));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
setElementStyle(element, style);
|
|
155
172
|
}
|
|
156
173
|
}
|
|
157
174
|
}
|
|
@@ -183,8 +200,14 @@ function attrIsObject(element, attr) {
|
|
|
183
200
|
}
|
|
184
201
|
// normal attributes
|
|
185
202
|
else {
|
|
186
|
-
|
|
187
|
-
|
|
203
|
+
const handler = handlers[key] || defaultHandler;
|
|
204
|
+
if (isKT(o)) {
|
|
205
|
+
handler(element, key, o.value);
|
|
206
|
+
o.addOnChange((v) => handler(element, key, v));
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
handler(element, key, o);
|
|
210
|
+
}
|
|
188
211
|
}
|
|
189
212
|
}
|
|
190
213
|
}
|
|
@@ -568,7 +591,7 @@ let creator = htmlCreator;
|
|
|
568
591
|
* ## About
|
|
569
592
|
* @package @ktjs/core
|
|
570
593
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
571
|
-
* @version 0.
|
|
594
|
+
* @version 0.26.2 (Last Update: 2026.02.05 20:44:45.309)
|
|
572
595
|
* @license MIT
|
|
573
596
|
* @link https://github.com/baendlorel/kt.js
|
|
574
597
|
* @link https://baendlorel.github.io/ Welcome to my site!
|