@ktjs/mui 0.20.0 → 0.20.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 CHANGED
@@ -37,8 +37,6 @@ declare class KTRef<T> {
37
37
  * Indicates that this is a KTRef instance
38
38
  */
39
39
  isKT: boolean;
40
- private _value;
41
- private _onChanges;
42
40
  constructor(_value: T, _onChanges: Array<RefChangeHandler<T>>);
43
41
  /**
44
42
  * If new value and old value are both nodes, the old one will be replaced in the DOM
@@ -1106,6 +1104,8 @@ declare global {
1106
1104
  type Element = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
1107
1105
 
1108
1106
  interface IntrinsicElements {
1107
+ [k: string]: AttributesMap['div']; // Allow any element with div attributes as fallback
1108
+
1109
1109
  // Document-level & metadata
1110
1110
  html: AttributesMap['html'];
1111
1111
  head: AttributesMap['head'];
@@ -1274,6 +1274,67 @@ declare global {
1274
1274
  tspan: SVGAttributesMap['tspan'];
1275
1275
  use: SVGAttributesMap['use'];
1276
1276
  view: SVGAttributesMap['view'];
1277
+
1278
+ // 'svg:svg': AttributesMap['svg'];
1279
+ // 'svg:a': SVGAttributesMap['a'];
1280
+ // 'svg:animate': SVGAttributesMap['animate'];
1281
+ // 'svg:animateMotion': SVGAttributesMap['animateMotion'];
1282
+ // 'svg:animateTransform': SVGAttributesMap['animateTransform'];
1283
+ // 'svg:circle': SVGAttributesMap['circle'];
1284
+ // 'svg:clipPath': SVGAttributesMap['clipPath'];
1285
+ // 'svg:defs': SVGAttributesMap['defs'];
1286
+ // 'svg:desc': SVGAttributesMap['desc'];
1287
+ // 'svg:ellipse': SVGAttributesMap['ellipse'];
1288
+ // 'svg:feBlend': SVGAttributesMap['feBlend'];
1289
+ // 'svg:feColorMatrix': SVGAttributesMap['feColorMatrix'];
1290
+ // 'svg:feComponentTransfer': SVGAttributesMap['feComponentTransfer'];
1291
+ // 'svg:feComposite': SVGAttributesMap['feComposite'];
1292
+ // 'svg:feConvolveMatrix': SVGAttributesMap['feConvolveMatrix'];
1293
+ // 'svg:feDiffuseLighting': SVGAttributesMap['feDiffuseLighting'];
1294
+ // 'svg:feDisplacementMap': SVGAttributesMap['feDisplacementMap'];
1295
+ // 'svg:feDistantLight': SVGAttributesMap['feDistantLight'];
1296
+ // 'svg:feDropShadow': SVGAttributesMap['feDropShadow'];
1297
+ // 'svg:feFlood': SVGAttributesMap['feFlood'];
1298
+ // 'svg:feFuncA': SVGAttributesMap['feFuncA'];
1299
+ // 'svg:feFuncB': SVGAttributesMap['feFuncB'];
1300
+ // 'svg:feFuncG': SVGAttributesMap['feFuncG'];
1301
+ // 'svg:feFuncR': SVGAttributesMap['feFuncR'];
1302
+ // 'svg:feGaussianBlur': SVGAttributesMap['feGaussianBlur'];
1303
+ // 'svg:feImage': SVGAttributesMap['feImage'];
1304
+ // 'svg:feMerge': SVGAttributesMap['feMerge'];
1305
+ // 'svg:feMergeNode': SVGAttributesMap['feMergeNode'];
1306
+ // 'svg:feMorphology': SVGAttributesMap['feMorphology'];
1307
+ // 'svg:feOffset': SVGAttributesMap['feOffset'];
1308
+ // 'svg:fePointLight': SVGAttributesMap['fePointLight'];
1309
+ // 'svg:feSpecularLighting': SVGAttributesMap['feSpecularLighting'];
1310
+ // 'svg:feSpotLight': SVGAttributesMap['feSpotLight'];
1311
+ // 'svg:feTile': SVGAttributesMap['feTile'];
1312
+ // 'svg:feTurbulence': SVGAttributesMap['feTurbulence'];
1313
+ // 'svg:filter': SVGAttributesMap['filter'];
1314
+ // 'svg:foreignObject': SVGAttributesMap['foreignObject'];
1315
+ // 'svg:g': SVGAttributesMap['g'];
1316
+ // 'svg:image': SVGAttributesMap['image'];
1317
+ // 'svg:line': SVGAttributesMap['line'];
1318
+ // 'svg:linearGradient': SVGAttributesMap['linearGradient'];
1319
+ // 'svg:marker': SVGAttributesMap['marker'];
1320
+ // 'svg:mask': SVGAttributesMap['mask'];
1321
+ // 'svg:metadata': SVGAttributesMap['metadata'];
1322
+ // 'svg:mpath': SVGAttributesMap['mpath'];
1323
+ // 'svg:path': SVGAttributesMap['path'];
1324
+ // 'svg:pattern': SVGAttributesMap['pattern'];
1325
+ // 'svg:polygon': SVGAttributesMap['polygon'];
1326
+ // 'svg:polyline': SVGAttributesMap['polyline'];
1327
+ // 'svg:radialGradient': SVGAttributesMap['radialGradient'];
1328
+ // 'svg:rect': SVGAttributesMap['rect'];
1329
+ // 'svg:set': SVGAttributesMap['set'];
1330
+ // 'svg:stop': SVGAttributesMap['stop'];
1331
+ // 'svg:switch': SVGAttributesMap['switch'];
1332
+ // 'svg:symbol': SVGAttributesMap['symbol'];
1333
+ // 'svg:text': SVGAttributesMap['text'];
1334
+ // 'svg:textPath': SVGAttributesMap['textPath'];
1335
+ // 'svg:tspan': SVGAttributesMap['tspan'];
1336
+ // 'svg:use': SVGAttributesMap['use'];
1337
+ // 'svg:view': SVGAttributesMap['view'];
1277
1338
  }
1278
1339
 
1279
1340
  interface IntrinsicAttributes {
@@ -1389,7 +1450,7 @@ type ChangeHandler<T = string> = (value: T, ...args: any[]) => void;
1389
1450
 
1390
1451
  type InputTypes = 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';
1391
1452
 
1392
- interface KTMuiTextFieldProps<T extends InputTypes> {
1453
+ interface KTMuiTextFieldProps<T extends InputTypes = 'text'> {
1393
1454
  class?: string;
1394
1455
  style?: string | Partial<CSSStyleDeclaration>;
1395
1456
  label?: string;
@@ -194,7 +194,14 @@ var __ktjs_mui__ = (function (exports) {
194
194
  }
195
195
  }
196
196
 
197
- const svgTempWrapper = document.createElement('div');
197
+ document.createElement('div');
198
+ const htmlCreator = (tag) => document.createElement(tag);
199
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/2000/svg', tag);
200
+ const mathMLCreator = (tag) => document.createElementNS('http://www.w3.org/1998/Math/MathML', tag);
201
+ let creator = htmlCreator;
202
+ // # consts
203
+ const SVG_ATTR_FLAG = '__kt_svg__';
204
+ const MATHML_ATTR_FLAG = '__kt_mathml__';
198
205
  /**
199
206
  * Create an enhanced HTMLElement.
200
207
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -205,7 +212,7 @@ var __ktjs_mui__ = (function (exports) {
205
212
  * ## About
206
213
  * @package @ktjs/core
207
214
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
208
- * @version 0.20.0 (Last Update: 2026.02.01 00:47:09.995)
215
+ * @version 0.20.3 (Last Update: 2026.02.01 18:38:02.198)
209
216
  * @license MIT
210
217
  * @link https://github.com/baendlorel/kt.js
211
218
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -216,15 +223,32 @@ var __ktjs_mui__ = (function (exports) {
216
223
  if (typeof tag !== 'string') {
217
224
  $throw('tagName must be a string.');
218
225
  }
226
+ if (attr) {
227
+ if (SVG_ATTR_FLAG in attr) {
228
+ delete attr[SVG_ATTR_FLAG];
229
+ creator = svgCreator;
230
+ }
231
+ else if (MATHML_ATTR_FLAG in attr) {
232
+ delete attr[MATHML_ATTR_FLAG];
233
+ creator = mathMLCreator;
234
+ }
235
+ else {
236
+ creator = htmlCreator;
237
+ }
238
+ }
219
239
  // * start creating the element
220
- const element = document.createElement(tag);
240
+ const element = creator(tag);
221
241
  // * Handle content
222
242
  applyAttr(element, attr);
223
243
  applyContent(element, content);
224
- if (tag === 'svg') {
225
- svgTempWrapper.innerHTML = element.outerHTML;
226
- return svgTempWrapper.firstChild;
227
- }
244
+ // if (tag === 'svg') {
245
+ // tempWrapper.innerHTML = element.outerHTML;
246
+ // return tempWrapper.firstChild as HTML<T>;
247
+ // }
248
+ // if (tag === 'math') {
249
+ // tempWrapper.innerHTML = element.outerHTML;
250
+ // return tempWrapper.firstChild as HTML<T>;
251
+ // }
228
252
  return element;
229
253
  };
230
254
 
@@ -233,7 +257,7 @@ var __ktjs_mui__ = (function (exports) {
233
257
  * @param tag html tag or function component
234
258
  * @param props properties/attributes
235
259
  */
236
- function jsx(tag, props = {}) {
260
+ function jsx(tag, props) {
237
261
  const ref = props.ref?.isKT ? props.ref : dummyRef;
238
262
  let el;
239
263
  if ('k-if' in props && !props['k-if']) {
@@ -324,7 +348,7 @@ var __ktjs_mui__ = (function (exports) {
324
348
  }
325
349
  };
326
350
  const alertIcon = getIcon();
327
- const alert = (jsxs("div", { class: classes, style: parseStyle(props.style), role: "alert", children: [alertIcon && jsx("div", { class: "mui-alert-icon-wrapper", children: alertIcon }), jsx("div", { class: "mui-alert-message", children: children }), onClose && (jsx("button", { class: "mui-alert-close", "on:click": onClose, "aria-label": "Close", children: jsx("svg", { viewBox: "0 0 24 24", width: "18px", height: "18px", children: jsx("path", { fill: "currentColor", d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) }))] }));
351
+ const alert = (jsxs("div", { class: classes, style: parseStyle(props.style), role: "alert", children: [alertIcon && jsx("div", { class: "mui-alert-icon-wrapper", children: alertIcon }), jsx("div", { class: "mui-alert-message", children: children }), jsx("button", { "k-if": onClose, class: "mui-alert-close", "on:click": onClose, "aria-label": "Close", children: jsx("svg", { viewBox: "0 0 24 24", width: "18px", height: "18px", children: jsx("path", { fill: "currentColor", d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) })] }));
328
352
  return alert;
329
353
  }
330
354
 
@@ -620,7 +644,13 @@ var __ktjs_mui__ = (function (exports) {
620
644
  * Indicates that this is a KTRef instance
621
645
  */
622
646
  isKT = true;
647
+ /**
648
+ * @internal
649
+ */
623
650
  _value;
651
+ /**
652
+ * @internal
653
+ */
624
654
  _onChanges;
625
655
  constructor(_value, _onChanges) {
626
656
  this._value = _value;
@@ -784,13 +814,23 @@ var __ktjs_mui__ = (function (exports) {
784
814
  updateContainerClass();
785
815
  onBlur(inputEl.value);
786
816
  };
817
+ const handleWrapperMouseDown = (e) => {
818
+ if (disabled) {
819
+ return;
820
+ }
821
+ const target = e.target;
822
+ if (!target || target === inputEl) {
823
+ return;
824
+ }
825
+ setTimeout(() => inputEl.focus(), 0);
826
+ };
787
827
  const getPlaceholder = () => (label && !isFocused && !value ? '' : placeholder);
788
828
  let isFocused = false;
789
829
  const inputEl = multiline
790
830
  ? (jsx("textarea", { class: "mui-textfield-input", placeholder: getPlaceholder(), value: value, disabled: disabled, readOnly: readonly, required: required, rows: rows, "on:input": handleInput, "on:change": handleChange, "on:focus": handleFocus, "on:blur": handleBlur }))
791
831
  : (jsx("input", { type: type, class: "mui-textfield-input", placeholder: getPlaceholder(), value: value, disabled: disabled, readOnly: readonly, required: required, "on:input": handleInput, "on:change": handleChange, "on:focus": handleFocus, "on:blur": handleBlur }));
792
832
  const helperTextEl = jsx("p", { class: "mui-textfield-helper-text", children: helperText });
793
- const wrapperRef = createRedrawable(() => (jsxs("div", { class: "mui-textfield-wrapper", children: [jsxs("label", { "k-if": label, class: "mui-textfield-label", children: [label, required && jsx("span", { class: "mui-textfield-required", children: "*" })] }), jsx("div", { class: "mui-textfield-input-wrapper", children: inputEl }), jsx("fieldset", { class: "mui-textfield-fieldset", children: jsx("legend", { "k-if": label, class: "mui-textfield-legend", children: jsxs("span", { children: [label, required && '*'] }) }) })] })));
833
+ const wrapperRef = createRedrawable(() => (jsxs("div", { class: "mui-textfield-wrapper", "on:mousedown": handleWrapperMouseDown, children: [jsxs("label", { "k-if": label, class: "mui-textfield-label", children: [label, required && jsx("span", { class: "mui-textfield-required", children: "*" })] }), jsx("div", { class: "mui-textfield-input-wrapper", children: inputEl }), jsx("fieldset", { class: "mui-textfield-fieldset", children: jsx("legend", { "k-if": label, class: "mui-textfield-legend", children: jsxs("span", { children: [label, required && '*'] }) }) })] })));
794
834
  const container = (jsxs("div", { class: 'mui-textfield-root ' + (props.class ? props.class : ''), style: parseStyle(props.style), children: [wrapperRef, helperTextEl] }));
795
835
  // Initialize classes
796
836
  setTimeout(() => updateContainerClass(), 0);
package/dist/index.mjs CHANGED
@@ -191,7 +191,14 @@ function applyContent(element, content) {
191
191
  }
192
192
  }
193
193
 
194
- const svgTempWrapper = document.createElement('div');
194
+ document.createElement('div');
195
+ const htmlCreator = (tag) => document.createElement(tag);
196
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/2000/svg', tag);
197
+ const mathMLCreator = (tag) => document.createElementNS('http://www.w3.org/1998/Math/MathML', tag);
198
+ let creator = htmlCreator;
199
+ // # consts
200
+ const SVG_ATTR_FLAG = '__kt_svg__';
201
+ const MATHML_ATTR_FLAG = '__kt_mathml__';
195
202
  /**
196
203
  * Create an enhanced HTMLElement.
197
204
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -202,7 +209,7 @@ const svgTempWrapper = document.createElement('div');
202
209
  * ## About
203
210
  * @package @ktjs/core
204
211
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
205
- * @version 0.20.0 (Last Update: 2026.02.01 00:47:09.995)
212
+ * @version 0.20.3 (Last Update: 2026.02.01 18:38:02.198)
206
213
  * @license MIT
207
214
  * @link https://github.com/baendlorel/kt.js
208
215
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -213,15 +220,32 @@ const h = (tag, attr, content) => {
213
220
  if (typeof tag !== 'string') {
214
221
  $throw('tagName must be a string.');
215
222
  }
223
+ if (attr) {
224
+ if (SVG_ATTR_FLAG in attr) {
225
+ delete attr[SVG_ATTR_FLAG];
226
+ creator = svgCreator;
227
+ }
228
+ else if (MATHML_ATTR_FLAG in attr) {
229
+ delete attr[MATHML_ATTR_FLAG];
230
+ creator = mathMLCreator;
231
+ }
232
+ else {
233
+ creator = htmlCreator;
234
+ }
235
+ }
216
236
  // * start creating the element
217
- const element = document.createElement(tag);
237
+ const element = creator(tag);
218
238
  // * Handle content
219
239
  applyAttr(element, attr);
220
240
  applyContent(element, content);
221
- if (tag === 'svg') {
222
- svgTempWrapper.innerHTML = element.outerHTML;
223
- return svgTempWrapper.firstChild;
224
- }
241
+ // if (tag === 'svg') {
242
+ // tempWrapper.innerHTML = element.outerHTML;
243
+ // return tempWrapper.firstChild as HTML<T>;
244
+ // }
245
+ // if (tag === 'math') {
246
+ // tempWrapper.innerHTML = element.outerHTML;
247
+ // return tempWrapper.firstChild as HTML<T>;
248
+ // }
225
249
  return element;
226
250
  };
227
251
 
@@ -230,7 +254,7 @@ const dummyRef = { value: null };
230
254
  * @param tag html tag or function component
231
255
  * @param props properties/attributes
232
256
  */
233
- function jsx(tag, props = {}) {
257
+ function jsx(tag, props) {
234
258
  const ref = props.ref?.isKT ? props.ref : dummyRef;
235
259
  let el;
236
260
  if ('k-if' in props && !props['k-if']) {
@@ -321,7 +345,7 @@ function Alert(props) {
321
345
  }
322
346
  };
323
347
  const alertIcon = getIcon();
324
- const alert = (jsxs("div", { class: classes, style: parseStyle(props.style), role: "alert", children: [alertIcon && jsx("div", { class: "mui-alert-icon-wrapper", children: alertIcon }), jsx("div", { class: "mui-alert-message", children: children }), onClose && (jsx("button", { class: "mui-alert-close", "on:click": onClose, "aria-label": "Close", children: jsx("svg", { viewBox: "0 0 24 24", width: "18px", height: "18px", children: jsx("path", { fill: "currentColor", d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) }))] }));
348
+ const alert = (jsxs("div", { class: classes, style: parseStyle(props.style), role: "alert", children: [alertIcon && jsx("div", { class: "mui-alert-icon-wrapper", children: alertIcon }), jsx("div", { class: "mui-alert-message", children: children }), jsx("button", { "k-if": onClose, class: "mui-alert-close", "on:click": onClose, "aria-label": "Close", children: jsx("svg", { viewBox: "0 0 24 24", width: "18px", height: "18px", children: jsx("path", { fill: "currentColor", d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) })] }));
325
349
  return alert;
326
350
  }
327
351
 
@@ -617,7 +641,13 @@ class KTRef {
617
641
  * Indicates that this is a KTRef instance
618
642
  */
619
643
  isKT = true;
644
+ /**
645
+ * @internal
646
+ */
620
647
  _value;
648
+ /**
649
+ * @internal
650
+ */
621
651
  _onChanges;
622
652
  constructor(_value, _onChanges) {
623
653
  this._value = _value;
@@ -781,13 +811,23 @@ function TextField(props) {
781
811
  updateContainerClass();
782
812
  onBlur(inputEl.value);
783
813
  };
814
+ const handleWrapperMouseDown = (e) => {
815
+ if (disabled) {
816
+ return;
817
+ }
818
+ const target = e.target;
819
+ if (!target || target === inputEl) {
820
+ return;
821
+ }
822
+ setTimeout(() => inputEl.focus(), 0);
823
+ };
784
824
  const getPlaceholder = () => (label && !isFocused && !value ? '' : placeholder);
785
825
  let isFocused = false;
786
826
  const inputEl = multiline
787
827
  ? (jsx("textarea", { class: "mui-textfield-input", placeholder: getPlaceholder(), value: value, disabled: disabled, readOnly: readonly, required: required, rows: rows, "on:input": handleInput, "on:change": handleChange, "on:focus": handleFocus, "on:blur": handleBlur }))
788
828
  : (jsx("input", { type: type, class: "mui-textfield-input", placeholder: getPlaceholder(), value: value, disabled: disabled, readOnly: readonly, required: required, "on:input": handleInput, "on:change": handleChange, "on:focus": handleFocus, "on:blur": handleBlur }));
789
829
  const helperTextEl = jsx("p", { class: "mui-textfield-helper-text", children: helperText });
790
- const wrapperRef = createRedrawable(() => (jsxs("div", { class: "mui-textfield-wrapper", children: [jsxs("label", { "k-if": label, class: "mui-textfield-label", children: [label, required && jsx("span", { class: "mui-textfield-required", children: "*" })] }), jsx("div", { class: "mui-textfield-input-wrapper", children: inputEl }), jsx("fieldset", { class: "mui-textfield-fieldset", children: jsx("legend", { "k-if": label, class: "mui-textfield-legend", children: jsxs("span", { children: [label, required && '*'] }) }) })] })));
830
+ const wrapperRef = createRedrawable(() => (jsxs("div", { class: "mui-textfield-wrapper", "on:mousedown": handleWrapperMouseDown, children: [jsxs("label", { "k-if": label, class: "mui-textfield-label", children: [label, required && jsx("span", { class: "mui-textfield-required", children: "*" })] }), jsx("div", { class: "mui-textfield-input-wrapper", children: inputEl }), jsx("fieldset", { class: "mui-textfield-fieldset", children: jsx("legend", { "k-if": label, class: "mui-textfield-legend", children: jsxs("span", { children: [label, required && '*'] }) }) })] })));
791
831
  const container = (jsxs("div", { class: 'mui-textfield-root ' + (props.class ? props.class : ''), style: parseStyle(props.style), children: [wrapperRef, helperTextEl] }));
792
832
  // Initialize classes
793
833
  setTimeout(() => updateContainerClass(), 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/mui",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
4
4
  "description": "Material-UI inspired components for kt.js - pre-styled UI components",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
@@ -35,7 +35,7 @@
35
35
  "directory": "packages/mui"
36
36
  },
37
37
  "dependencies": {
38
- "@ktjs/core": "0.20.0",
38
+ "@ktjs/core": "0.20.3",
39
39
  "@ktjs/shared": "0.20.0"
40
40
  },
41
41
  "scripts": {