kt.js 0.14.0 → 0.14.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.
@@ -220,7 +220,7 @@ function applyContent(element, content) {
220
220
  * ## About
221
221
  * @package @ktjs/core
222
222
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
223
- * @version 0.14.0 (Last Update: 2026.01.16 20:08:50.505)
223
+ * @version 0.14.1 (Last Update: 2026.01.16 22:18:41.846)
224
224
  * @license MIT
225
225
  * @link https://github.com/baendlorel/kt.js
226
226
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -335,5 +335,30 @@ const jsxDEV = (...args) => {
335
335
  * This is called when using jsx: "react-jsx" or "react-jsxdev"
336
336
  */
337
337
  const jsxs = jsx;
338
+ /**
339
+ * A helper to create redrawable elements
340
+ * ```tsx
341
+ * export function MyComponent() {
342
+ * let aa = 10;
343
+ * // ...
344
+ * // aa might be changed
345
+ * return createRedrawable(() => <div>{aa}</div>);
346
+ * }
347
+ * ```
348
+ * Then the returned element has a `redraw` method to redraw itself with new values.
349
+ * @param creator
350
+ * @returns created element
351
+ */
352
+ function createRedrawable(creator) {
353
+ let element = creator();
354
+ const redraw = () => {
355
+ const old = element;
356
+ element = creator();
357
+ old.replaceWith(element);
358
+ element.redraw = redraw;
359
+ };
360
+ element.redraw = redraw;
361
+ return element;
362
+ }
338
363
 
339
- export { Fragment, h as createElement, h, jsx, jsxDEV, jsxs };
364
+ export { Fragment, h as createElement, createRedrawable, h, jsx, jsxDEV, jsxs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kt.js",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "author": {
5
5
  "name": "Kasukabe Tsumugi",
6
6
  "email": "futami16237@gmail.com"
@@ -41,8 +41,8 @@
41
41
  ],
42
42
  "license": "MIT",
43
43
  "dependencies": {
44
- "@ktjs/shortcuts": "0.7.3",
45
- "@ktjs/core": "0.14.0"
44
+ "@ktjs/core": "0.14.1",
45
+ "@ktjs/shortcuts": "0.7.3"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "rollup -c rollup.config.mjs",