@ktjs/mui 0.19.0 → 0.20.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 +130 -131
- package/dist/index.iife.js +131 -130
- package/dist/index.mjs +132 -130
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,7 @@ const $throw = (message) => {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// DOM manipulation utilities
|
|
11
|
+
// # dom natives
|
|
11
12
|
/**
|
|
12
13
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
13
14
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -43,10 +44,11 @@ const $append = // for ie 9/10/11
|
|
|
43
44
|
$appendChild.call(this, fragment);
|
|
44
45
|
}
|
|
45
46
|
};
|
|
47
|
+
const { get: $buttonDisabledGetter$2, set: $buttonDisabledSetter$2 } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
46
48
|
|
|
47
49
|
// Shared utilities and cached native methods for kt.js framework
|
|
48
50
|
// Re-export all utilities
|
|
49
|
-
Object.defineProperty(window, '@ktjs/shared', { value: '0.
|
|
51
|
+
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.0' });
|
|
50
52
|
|
|
51
53
|
const booleanHandler = (element, key, value) => {
|
|
52
54
|
if (key in element) {
|
|
@@ -200,7 +202,7 @@ const svgTempWrapper = document.createElement('div');
|
|
|
200
202
|
* ## About
|
|
201
203
|
* @package @ktjs/core
|
|
202
204
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
203
|
-
* @version 0.
|
|
205
|
+
* @version 0.20.0 (Last Update: 2026.02.01 00:47:09.995)
|
|
204
206
|
* @license MIT
|
|
205
207
|
* @link https://github.com/baendlorel/kt.js
|
|
206
208
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -231,18 +233,10 @@ const dummyRef = { value: null };
|
|
|
231
233
|
function jsx(tag, props = {}) {
|
|
232
234
|
const ref = props.ref?.isKT ? props.ref : dummyRef;
|
|
233
235
|
let el;
|
|
234
|
-
const redraw = (newProps) => {
|
|
235
|
-
props = newProps ? { ...props, ...newProps } : props;
|
|
236
|
-
el = jsx(tag, props);
|
|
237
|
-
if (ref !== dummyRef) {
|
|
238
|
-
ref.value = el; // & ref setter automatically replaces old element in DOM
|
|
239
|
-
}
|
|
240
|
-
return el;
|
|
241
|
-
};
|
|
242
236
|
if ('k-if' in props && !props['k-if']) {
|
|
237
|
+
// & make comment placeholder in case that ref might be redrawn later
|
|
243
238
|
el = document.createComment('k-if');
|
|
244
|
-
ref.value = el;
|
|
245
|
-
el.redraw = redraw;
|
|
239
|
+
ref.value = el;
|
|
246
240
|
return el;
|
|
247
241
|
}
|
|
248
242
|
// Handle function components
|
|
@@ -252,7 +246,6 @@ function jsx(tag, props = {}) {
|
|
|
252
246
|
else {
|
|
253
247
|
el = h(tag, props, props.children);
|
|
254
248
|
}
|
|
255
|
-
el.redraw ??= redraw;
|
|
256
249
|
ref.value = el;
|
|
257
250
|
return el;
|
|
258
251
|
}
|
|
@@ -262,57 +255,16 @@ function jsx(tag, props = {}) {
|
|
|
262
255
|
*/
|
|
263
256
|
const jsxs = jsx;
|
|
264
257
|
|
|
265
|
-
/**s
|
|
266
|
-
* Alert component - mimics MUI Alert appearance and behavior
|
|
267
|
-
*/
|
|
268
|
-
function Alert(props) {
|
|
269
|
-
const { children, style = '', severity = 'info', variant = 'standard', icon, 'kt:close': onClose } = props;
|
|
270
|
-
const classes = `mui-alert mui-alert-${severity} mui-alert-${variant} ${props.class ? props.class : ''}`;
|
|
271
|
-
// Convert sx object to style string
|
|
272
|
-
let styleString = typeof style === 'string' ? style : '';
|
|
273
|
-
if (style && typeof style === 'object') {
|
|
274
|
-
const sxStyles = Object.entries(style)
|
|
275
|
-
.map(([key, value]) => {
|
|
276
|
-
// Convert camelCase to kebab-case
|
|
277
|
-
const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
278
|
-
return `${cssKey}: ${value}`;
|
|
279
|
-
})
|
|
280
|
-
.join('; ');
|
|
281
|
-
styleString = styleString ? `${styleString}; ${sxStyles}` : sxStyles;
|
|
282
|
-
}
|
|
283
|
-
// Icon SVG paths for different severities
|
|
284
|
-
const getIcon = () => {
|
|
285
|
-
if (icon === false)
|
|
286
|
-
return null;
|
|
287
|
-
if (icon)
|
|
288
|
-
return icon;
|
|
289
|
-
const iconSize = '22px';
|
|
290
|
-
const iconClass = 'mui-alert-icon';
|
|
291
|
-
switch (severity) {
|
|
292
|
-
case 'success':
|
|
293
|
-
return (jsx("svg", { class: iconClass, viewBox: "0 0 24 24", width: iconSize, height: iconSize, children: jsx("path", { fill: "currentColor", d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" }) }));
|
|
294
|
-
case 'error':
|
|
295
|
-
return (jsx("svg", { class: iconClass, viewBox: "0 0 24 24", width: iconSize, height: iconSize, children: jsx("path", { fill: "currentColor", d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" }) }));
|
|
296
|
-
case 'warning':
|
|
297
|
-
return (jsx("svg", { class: iconClass, viewBox: "0 0 24 24", width: iconSize, height: iconSize, children: jsx("path", { fill: "currentColor", d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }) }));
|
|
298
|
-
case 'info':
|
|
299
|
-
default:
|
|
300
|
-
return (jsx("svg", { class: iconClass, viewBox: "0 0 24 24", width: iconSize, height: iconSize, children: jsx("path", { fill: "currentColor", d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z" }) }));
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
const alertIcon = getIcon();
|
|
304
|
-
const alert = (jsxs("div", { class: classes, style: styleString, 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" }) }) }))] }));
|
|
305
|
-
return alert;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
258
|
// Cached native methods for performance optimization
|
|
259
|
+
const $defines = Object.defineProperties;
|
|
309
260
|
|
|
310
261
|
// String manipulation utilities
|
|
311
262
|
/**
|
|
312
263
|
* Default empty function
|
|
313
264
|
*/
|
|
314
265
|
const $emptyFn = (() => true);
|
|
315
|
-
|
|
266
|
+
const { get: $buttonDisabledGetter$1, set: $buttonDisabledSetter$1 } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
267
|
+
// # DOM utilities
|
|
316
268
|
const parseStyle = (style) => {
|
|
317
269
|
if (typeof style === 'string') {
|
|
318
270
|
return style;
|
|
@@ -341,25 +293,54 @@ const generateHandler = (props, key) => {
|
|
|
341
293
|
|
|
342
294
|
// Shared utilities and cached native methods for kt.js framework
|
|
343
295
|
// Re-export all utilities
|
|
344
|
-
Object.defineProperty(window, '@ktjs/shared', { value: '0.
|
|
296
|
+
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.0' });
|
|
297
|
+
|
|
298
|
+
function Alert(props) {
|
|
299
|
+
const { children, severity = 'info', variant = 'standard', icon, 'kt:close': onClose } = props;
|
|
300
|
+
const classes = `mui-alert mui-alert-${severity} mui-alert-${variant} ${props.class ? props.class : ''}`;
|
|
301
|
+
// Icon SVG paths for different severities
|
|
302
|
+
const getIcon = () => {
|
|
303
|
+
if (icon === false) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
if (icon) {
|
|
307
|
+
return icon;
|
|
308
|
+
}
|
|
309
|
+
const iconSize = '22px';
|
|
310
|
+
const iconClass = 'mui-alert-icon';
|
|
311
|
+
switch (severity) {
|
|
312
|
+
case 'success':
|
|
313
|
+
return (jsx("svg", { class: iconClass, viewBox: "0 0 24 24", width: iconSize, height: iconSize, children: jsx("path", { fill: "currentColor", d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" }) }));
|
|
314
|
+
case 'error':
|
|
315
|
+
return (jsx("svg", { class: iconClass, viewBox: "0 0 24 24", width: iconSize, height: iconSize, children: jsx("path", { fill: "currentColor", d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" }) }));
|
|
316
|
+
case 'warning':
|
|
317
|
+
return (jsx("svg", { class: iconClass, viewBox: "0 0 24 24", width: iconSize, height: iconSize, children: jsx("path", { fill: "currentColor", d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }) }));
|
|
318
|
+
case 'info':
|
|
319
|
+
default:
|
|
320
|
+
return (jsx("svg", { class: iconClass, viewBox: "0 0 24 24", width: iconSize, height: iconSize, children: jsx("path", { fill: "currentColor", d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z" }) }));
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
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" }) }) }))] }));
|
|
325
|
+
return alert;
|
|
326
|
+
}
|
|
345
327
|
|
|
346
328
|
/**
|
|
347
329
|
* Button component - mimics MUI Button appearance and behavior
|
|
348
330
|
*/
|
|
349
331
|
function Button(props) {
|
|
350
|
-
|
|
332
|
+
let { children, variant = 'text', color = 'primary', size = 'medium', disabled = false, fullWidth = false, iconOnly = false, startIcon, endIcon, type = 'button', 'on:click': onClick = $emptyFn, } = props;
|
|
351
333
|
const classes = [
|
|
352
334
|
'mui-button',
|
|
353
335
|
`mui-button-${variant}`,
|
|
354
336
|
`mui-button-${variant}-${color}`,
|
|
355
337
|
`mui-button-size-${size}`,
|
|
356
|
-
fullWidth
|
|
357
|
-
iconOnly
|
|
358
|
-
disabled
|
|
338
|
+
fullWidth ? 'mui-button-fullwidth' : '',
|
|
339
|
+
iconOnly ? 'mui-button-icon-only' : '',
|
|
340
|
+
disabled ? 'mui-button-disabled' : '',
|
|
359
341
|
props.class ? props.class : '',
|
|
360
|
-
]
|
|
361
|
-
|
|
362
|
-
.join(' ');
|
|
342
|
+
].join(' ');
|
|
343
|
+
const rippleContainer = jsx("span", { class: "mui-button-ripple" });
|
|
363
344
|
const handleClick = (e) => {
|
|
364
345
|
if (disabled) {
|
|
365
346
|
e.preventDefault();
|
|
@@ -367,7 +348,6 @@ function Button(props) {
|
|
|
367
348
|
}
|
|
368
349
|
// Create ripple effect
|
|
369
350
|
const button = e.currentTarget;
|
|
370
|
-
const rippleContainer = button.querySelector('.mui-button-ripple');
|
|
371
351
|
if (rippleContainer) {
|
|
372
352
|
const rect = button.getBoundingClientRect();
|
|
373
353
|
const size = Math.max(rect.width, rect.height);
|
|
@@ -380,13 +360,21 @@ function Button(props) {
|
|
|
380
360
|
ripple.classList.add('mui-button-ripple-effect');
|
|
381
361
|
rippleContainer.appendChild(ripple);
|
|
382
362
|
// Remove ripple after animation
|
|
383
|
-
setTimeout(() =>
|
|
384
|
-
ripple.remove();
|
|
385
|
-
}, 600);
|
|
363
|
+
setTimeout(() => ripple.remove(), 600);
|
|
386
364
|
}
|
|
387
365
|
onClick(e);
|
|
388
366
|
};
|
|
389
|
-
|
|
367
|
+
const container = (jsxs("button", { class: classes, style: parseStyle(props.style), type: type, disabled: disabled, "on:click": handleClick, children: [startIcon && jsx("span", { class: "mui-button-start-icon", children: startIcon }), jsx("span", { class: "mui-button-label", children: children }), endIcon && jsx("span", { class: "mui-button-end-icon", children: endIcon }), rippleContainer] }));
|
|
368
|
+
$defines(container, {
|
|
369
|
+
disabled: {
|
|
370
|
+
get: $buttonDisabledGetter$1,
|
|
371
|
+
set: function (value) {
|
|
372
|
+
$buttonDisabledSetter$1.call(this, value);
|
|
373
|
+
this.classList.toggle('mui-button-disabled', value);
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
return container;
|
|
390
378
|
}
|
|
391
379
|
|
|
392
380
|
/**
|
|
@@ -427,7 +415,7 @@ function Checkbox(props) {
|
|
|
427
415
|
// Initialize icon state
|
|
428
416
|
toggleIcon(checked, indeterminate);
|
|
429
417
|
const container = (jsxs("label", { class: `mui-checkbox-wrapper mui-checkbox-size-${size} ${disabled ? 'mui-checkbox-disabled' : ''} mui-checkbox-color-${color}`, children: [inputEl, jsxs("span", { class: "mui-checkbox-icon", children: [uncheckedIcon, checkedIcon, indeterminateIcon] }), jsx("span", { "k-if": label, class: "mui-checkbox-label", children: label })] }));
|
|
430
|
-
|
|
418
|
+
$defines(container, {
|
|
431
419
|
checked: {
|
|
432
420
|
get() {
|
|
433
421
|
return checked;
|
|
@@ -493,7 +481,7 @@ function CheckboxGroup(props) {
|
|
|
493
481
|
return Checkbox(o);
|
|
494
482
|
});
|
|
495
483
|
const container = (jsx("div", { class: `mui-checkbox-group ${row ? 'mui-checkbox-group-row' : ''} ${props.class ? props.class : ''}`, style: props.style ? props.style : '', role: "group", children: checkboxes }));
|
|
496
|
-
|
|
484
|
+
$defines(container, {
|
|
497
485
|
value: {
|
|
498
486
|
get() {
|
|
499
487
|
return Array.from(selectedValues);
|
|
@@ -564,26 +552,28 @@ function Dialog(props) {
|
|
|
564
552
|
}
|
|
565
553
|
return originalRemove.call(container);
|
|
566
554
|
};
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
555
|
+
$defines(container, {
|
|
556
|
+
open: {
|
|
557
|
+
get: () => open,
|
|
558
|
+
set: (isOpen) => {
|
|
559
|
+
if (isOpen === open) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
open = isOpen;
|
|
563
|
+
if (isOpen) {
|
|
564
|
+
// Opening: set display first, then add class with double RAF for animation
|
|
565
|
+
container.style.display = 'flex';
|
|
566
|
+
setTimeout(() => container.classList.add('kt-dialog-backdrop-open'), 50);
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
container.classList.remove('kt-dialog-backdrop-open');
|
|
570
|
+
setTimeout(() => {
|
|
571
|
+
if (!open) {
|
|
572
|
+
container.style.display = 'none';
|
|
573
|
+
}
|
|
574
|
+
}, 225);
|
|
575
|
+
}
|
|
576
|
+
},
|
|
587
577
|
},
|
|
588
578
|
});
|
|
589
579
|
return container;
|
|
@@ -614,10 +604,11 @@ function FormLabel(props) {
|
|
|
614
604
|
}
|
|
615
605
|
|
|
616
606
|
// Cached native methods for performance optimization
|
|
607
|
+
const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
|
|
617
608
|
|
|
618
609
|
// Shared utilities and cached native methods for kt.js framework
|
|
619
610
|
// Re-export all utilities
|
|
620
|
-
Object.defineProperty(window, '@ktjs/shared', { value: '0.
|
|
611
|
+
Object.defineProperty(window, '@ktjs/shared', { value: '0.20.0' });
|
|
621
612
|
|
|
622
613
|
document.createElement('div');
|
|
623
614
|
|
|
@@ -692,13 +683,12 @@ function ref(value, onChange) {
|
|
|
692
683
|
*/
|
|
693
684
|
function createRedrawable(creator) {
|
|
694
685
|
const elRef = ref();
|
|
695
|
-
elRef.value = creator();
|
|
696
686
|
const redraw = () => {
|
|
697
687
|
elRef.value = creator(); // ref setter automatically calls replaceWith
|
|
698
|
-
elRef.
|
|
688
|
+
elRef.redraw = redraw;
|
|
699
689
|
return elRef.value;
|
|
700
690
|
};
|
|
701
|
-
|
|
691
|
+
redraw();
|
|
702
692
|
return elRef;
|
|
703
693
|
}
|
|
704
694
|
|
|
@@ -718,15 +708,17 @@ function LinearProgress(props) {
|
|
|
718
708
|
let progressValue = Math.min(Math.max(value, 0), 100);
|
|
719
709
|
const barRef = ref();
|
|
720
710
|
const container = (jsx("div", { class: classes, style: styleString, role: "progressbar", "aria-valuenow": progressValue, children: jsx("div", { ref: barRef, class: "mui-linear-progress-bar", style: variant === 'determinate' ? `width: ${progressValue}%` : '' }) }));
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
711
|
+
$defines(container, {
|
|
712
|
+
progress: {
|
|
713
|
+
get() {
|
|
714
|
+
return progressValue;
|
|
715
|
+
},
|
|
716
|
+
set(newValue) {
|
|
717
|
+
progressValue = Math.min(Math.max(newValue, 0), 100);
|
|
718
|
+
if (variant === 'determinate') {
|
|
719
|
+
barRef.value.style.width = `${progressValue}%`;
|
|
720
|
+
}
|
|
721
|
+
},
|
|
730
722
|
},
|
|
731
723
|
});
|
|
732
724
|
return container;
|
|
@@ -799,7 +791,7 @@ function TextField(props) {
|
|
|
799
791
|
const container = (jsxs("div", { class: 'mui-textfield-root ' + (props.class ? props.class : ''), style: parseStyle(props.style), children: [wrapperRef, helperTextEl] }));
|
|
800
792
|
// Initialize classes
|
|
801
793
|
setTimeout(() => updateContainerClass(), 0);
|
|
802
|
-
|
|
794
|
+
$defines(container, {
|
|
803
795
|
value: {
|
|
804
796
|
get() {
|
|
805
797
|
return inputEl.value;
|
|
@@ -815,7 +807,7 @@ function TextField(props) {
|
|
|
815
807
|
},
|
|
816
808
|
set(newLabel) {
|
|
817
809
|
label = newLabel;
|
|
818
|
-
wrapperRef.
|
|
810
|
+
wrapperRef.redraw(); // label takes too much and should be redrawn
|
|
819
811
|
updateContainerClass();
|
|
820
812
|
},
|
|
821
813
|
},
|
|
@@ -903,7 +895,7 @@ function Radio(props) {
|
|
|
903
895
|
// initialize icon state
|
|
904
896
|
toggleIcon(checked);
|
|
905
897
|
const container = (jsxs("label", { class: `mui-radio-wrapper ${props.class ?? ''} mui-radio-size-${size} ${disabled ? 'mui-radio-disabled' : ''} mui-radio-color-${color}`, style: parseStyle(props.style), children: [input, jsxs("span", { class: "mui-radio-icon", children: [uncheckedIcon, checkedIcon] }), jsx("span", { class: "mui-radio-label", children: text })] }));
|
|
906
|
-
|
|
898
|
+
$defines(container, {
|
|
907
899
|
value: {
|
|
908
900
|
get() {
|
|
909
901
|
return value;
|
|
@@ -950,7 +942,7 @@ function RadioGroup(props) {
|
|
|
950
942
|
return Radio(o);
|
|
951
943
|
});
|
|
952
944
|
const container = (jsx("div", { class: `mui-radio-group ${row ? 'mui-radio-group-row' : ''} ${props.class ?? ''}`, style: parseStyle(props.style), role: "radiogroup", children: radios }));
|
|
953
|
-
|
|
945
|
+
$defines(container, {
|
|
954
946
|
value: {
|
|
955
947
|
get() {
|
|
956
948
|
return value;
|
|
@@ -973,6 +965,7 @@ function Select(props) {
|
|
|
973
965
|
let isOpen = false;
|
|
974
966
|
let isFocused = false;
|
|
975
967
|
const selectRef = ref();
|
|
968
|
+
const selectLabelRef = ref();
|
|
976
969
|
// Toggle dropdown
|
|
977
970
|
const toggleMenu = () => {
|
|
978
971
|
if (disabled) {
|
|
@@ -985,12 +978,9 @@ function Select(props) {
|
|
|
985
978
|
const updateMenu = () => {
|
|
986
979
|
if (isOpen) {
|
|
987
980
|
menu.value.style.display = 'block';
|
|
988
|
-
// Trigger reflow to enable animation
|
|
989
|
-
void menu.value.offsetHeight;
|
|
990
|
-
menu.value.classList.add('mui-select-menu-open');
|
|
981
|
+
void menu.value.offsetHeight; // & Trigger reflow to enable animation
|
|
991
982
|
}
|
|
992
983
|
else {
|
|
993
|
-
menu.value.classList.remove('mui-select-menu-open');
|
|
994
984
|
// Hide after animation completes
|
|
995
985
|
setTimeout(() => {
|
|
996
986
|
if (!isOpen) {
|
|
@@ -998,6 +988,7 @@ function Select(props) {
|
|
|
998
988
|
}
|
|
999
989
|
}, 200);
|
|
1000
990
|
}
|
|
991
|
+
menu.value.classList.toggle('mui-select-menu-open', isOpen);
|
|
1001
992
|
selectRef.value.classList.toggle('mui-select-open', isOpen);
|
|
1002
993
|
};
|
|
1003
994
|
// Handle option click
|
|
@@ -1007,11 +998,8 @@ function Select(props) {
|
|
|
1007
998
|
onChange(value);
|
|
1008
999
|
updateMenu();
|
|
1009
1000
|
updateLabelState();
|
|
1010
|
-
valueDisplay.
|
|
1011
|
-
setTimeout(() =>
|
|
1012
|
-
// Trigger redraw of parent if needed
|
|
1013
|
-
menu.value.redraw();
|
|
1014
|
-
}, 200);
|
|
1001
|
+
valueDisplay.redraw();
|
|
1002
|
+
setTimeout(() => menu.redraw(), 200);
|
|
1015
1003
|
};
|
|
1016
1004
|
// Close menu when clicking outside
|
|
1017
1005
|
const handleClickOutside = (e) => {
|
|
@@ -1031,15 +1019,7 @@ function Select(props) {
|
|
|
1031
1019
|
};
|
|
1032
1020
|
// Update label focused state
|
|
1033
1021
|
const updateLabelState = () => {
|
|
1034
|
-
|
|
1035
|
-
if (labelElement) {
|
|
1036
|
-
if (isFocused || value) {
|
|
1037
|
-
labelElement.classList.add('focused');
|
|
1038
|
-
}
|
|
1039
|
-
else {
|
|
1040
|
-
labelElement.classList.remove('focused');
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1022
|
+
selectLabelRef.value.classList?.toggle('focused', isFocused || !!value);
|
|
1043
1023
|
};
|
|
1044
1024
|
const valueDisplay = createRedrawable(() => {
|
|
1045
1025
|
const o = options.find((opt) => opt.value === value);
|
|
@@ -1053,10 +1033,32 @@ function Select(props) {
|
|
|
1053
1033
|
return jsx("div", { class: "mui-select-display", children: inner });
|
|
1054
1034
|
});
|
|
1055
1035
|
const menu = createRedrawable(() => {
|
|
1056
|
-
return (jsx("div", { class: "mui-select-menu", style:
|
|
1036
|
+
return (jsx("div", { class: "mui-select-menu", style: "display: none;", children: options.map((option) => (jsx("div", { class: `mui-select-option ${option.value === value ? 'selected' : ''}`, "on:click": () => handleOptionClick(option.value), children: option.label }))) }));
|
|
1057
1037
|
});
|
|
1058
1038
|
// Create container
|
|
1059
|
-
const container = (jsxs("div", { ref: selectRef, class: `mui-select-wrapper mui-select-size-${size} ${props.class ?? ''} ${fullWidth ? 'mui-select-fullWidth' : ''} ${disabled ? 'mui-select-disabled' : ''}`, style: parseStyle(props.style), children: [
|
|
1039
|
+
const container = (jsxs("div", { ref: selectRef, class: `mui-select-wrapper mui-select-size-${size} ${props.class ?? ''} ${fullWidth ? 'mui-select-fullWidth' : ''} ${disabled ? 'mui-select-disabled' : ''}`, style: parseStyle(props.style), children: [jsx("label", { "k-if": label, ref: selectLabelRef, class: `mui-select-label ${value || isFocused ? 'focused' : ''}`, children: label }), jsxs("div", { class: "mui-select-control mui-select-outlined", "on:click": toggleMenu, "on:focus": handleFocus, "on:blur": handleBlur, tabIndex: disabled ? -1 : 0, children: [valueDisplay, jsx("input", { type: "hidden", value: value }), jsx("fieldset", { class: "mui-select-fieldset", children: jsx("legend", { children: jsx("span", { children: label }) }) }), jsx("svg", { class: "mui-select-icon", focusable: "false", "aria-hidden": "true", viewBox: "0 0 24 24", width: "24", height: "24", children: jsx("path", { d: "M7 10l5 5 5-5Z", fill: "currentColor" }) })] }), menu] }));
|
|
1040
|
+
$defines(container, {
|
|
1041
|
+
value: {
|
|
1042
|
+
get: () => value,
|
|
1043
|
+
set: (newValue) => {
|
|
1044
|
+
value = newValue;
|
|
1045
|
+
updateLabelState();
|
|
1046
|
+
valueDisplay.redraw();
|
|
1047
|
+
menu.redraw();
|
|
1048
|
+
},
|
|
1049
|
+
},
|
|
1050
|
+
disabled: {
|
|
1051
|
+
get: () => disabled,
|
|
1052
|
+
set: (newDisabled) => {
|
|
1053
|
+
disabled = newDisabled;
|
|
1054
|
+
if (disabled) {
|
|
1055
|
+
isOpen = false;
|
|
1056
|
+
updateMenu();
|
|
1057
|
+
}
|
|
1058
|
+
container.classList.toggle('mui-select-disabled', disabled);
|
|
1059
|
+
},
|
|
1060
|
+
},
|
|
1061
|
+
});
|
|
1060
1062
|
// Add global click listener
|
|
1061
1063
|
setTimeout(() => {
|
|
1062
1064
|
document.removeEventListener('click', handleClickOutside);
|
|
@@ -1154,4 +1156,4 @@ function SelectAllIcon(props) {
|
|
|
1154
1156
|
return (jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "1em", height: "1em", ...props, children: jsx("path", { d: "M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2zM7 17h10V7H7v10zm2-8h6v6H9V9z" }) }));
|
|
1155
1157
|
}
|
|
1156
1158
|
|
|
1157
|
-
export { Alert, Button, Checkbox, CheckboxGroup, ColorLensIcon, CompressIcon, ContentCopyIcon, ContentPasteIcon, DeleteIcon, Dialog, DownloadIcon, ExpandMoreIcon, FileOpenIcon
|
|
1159
|
+
export { Alert, Button, Checkbox, CheckboxGroup, ColorLensIcon, CompressIcon, ContentCopyIcon, ContentPasteIcon, DeleteIcon, Dialog, DownloadIcon, ExpandMoreIcon, FileOpenIcon, FolderOpenIcon, FormLabel, HomeIcon, LinearProgress, MenuIcon, NewReleasesIcon, PlayArrowIcon, QueuePlayNextIcon, Radio, RadioGroup, SaveIcon, Select, SelectAllIcon, SettingsIcon, StopIcon, SubtitlesIcon, TextField, UploadFileIcon, VideoFileIcon, WallpaperIcon };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ktjs/mui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
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,8 +35,8 @@
|
|
|
35
35
|
"directory": "packages/mui"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ktjs/
|
|
39
|
-
"@ktjs/
|
|
38
|
+
"@ktjs/core": "0.20.0",
|
|
39
|
+
"@ktjs/shared": "0.20.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "rollup -c rollup.config.mjs",
|