@ktjs/mui 0.18.4 → 0.18.5
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 +142 -79
- package/dist/index.iife.js +42 -20
- package/dist/index.mjs +42 -20
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KTHTMLElement, KTAttribute } from 'kt.js';
|
|
1
|
+
import { KTHTMLElement, KTRef as KTRef$1, KTAttribute } from 'kt.js';
|
|
2
2
|
import { KTHTMLElement as KTHTMLElement$1, KTRef } from '@ktjs/core';
|
|
3
3
|
|
|
4
4
|
interface AlertProps {
|
|
@@ -36,46 +36,50 @@ interface ButtonProps {
|
|
|
36
36
|
*/
|
|
37
37
|
declare function Button(props: ButtonProps): KTHTMLElement;
|
|
38
38
|
|
|
39
|
-
interface
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
interface KTMuiCheckboxProps {
|
|
40
|
+
value: string;
|
|
41
|
+
label?: string | KTHTMLElement$1 | HTMLElement;
|
|
42
|
+
checked?: boolean;
|
|
43
|
+
size?: 'small' | 'medium';
|
|
44
|
+
'kt:change'?: ((checked: boolean, value: string) => void) | KTRef<boolean>;
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
color?: 'primary' | 'secondary' | 'default' | 'success' | 'error' | 'warning';
|
|
47
|
+
indeterminate?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface KTMuiCheckboxGroupProps {
|
|
51
|
+
class?: string;
|
|
52
|
+
style?: string;
|
|
53
|
+
value?: string[];
|
|
54
|
+
size?: 'small' | 'medium';
|
|
55
|
+
options: KTMuiCheckboxProps[];
|
|
56
|
+
'kt:change'?: ((values: string[]) => void) | KTRef<string[]>;
|
|
57
|
+
row?: boolean;
|
|
48
58
|
}
|
|
59
|
+
|
|
49
60
|
type KTMuiCheckbox = KTHTMLElement$1 & {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
checked: boolean;
|
|
62
|
+
value: string;
|
|
63
|
+
disabled: boolean;
|
|
53
64
|
};
|
|
65
|
+
|
|
54
66
|
type KTMuiCheckboxGroup = KTHTMLElement$1 & {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
value: string[];
|
|
68
|
+
disabled: boolean[];
|
|
69
|
+
disableAll: () => void;
|
|
70
|
+
enableAll: () => void;
|
|
59
71
|
};
|
|
72
|
+
|
|
60
73
|
/**
|
|
61
74
|
* Checkbox component - mimics MUI Checkbox appearance and behavior
|
|
62
75
|
*/
|
|
63
|
-
declare function Checkbox(props:
|
|
64
|
-
interface CheckboxGroupProps {
|
|
65
|
-
class?: string;
|
|
66
|
-
style?: string;
|
|
67
|
-
value?: string[];
|
|
68
|
-
size?: 'small' | 'medium';
|
|
69
|
-
options: CheckboxProps[];
|
|
70
|
-
'kt:change'?: ((values: string[]) => void) | KTRef<string[]>;
|
|
71
|
-
row?: boolean;
|
|
72
|
-
}
|
|
76
|
+
declare function Checkbox(props: KTMuiCheckboxProps): KTMuiCheckbox;
|
|
73
77
|
/**
|
|
74
78
|
* CheckboxGroup component - groups multiple checkboxes together
|
|
75
79
|
*/
|
|
76
|
-
declare function CheckboxGroup(props:
|
|
80
|
+
declare function CheckboxGroup(props: KTMuiCheckboxGroupProps): KTMuiCheckboxGroup;
|
|
77
81
|
|
|
78
|
-
interface
|
|
82
|
+
interface KTMuiDialogProps {
|
|
79
83
|
open?: boolean;
|
|
80
84
|
'kt:close'?: () => void;
|
|
81
85
|
title?: string;
|
|
@@ -94,7 +98,7 @@ type KTMuiDialog = KTHTMLElement$1 & {
|
|
|
94
98
|
* Dialog component - mimics MUI Dialog appearance and behavior
|
|
95
99
|
* Only handles open/close state, title and content are passed as props
|
|
96
100
|
*/
|
|
97
|
-
declare function Dialog(props:
|
|
101
|
+
declare function Dialog(props: KTMuiDialogProps): KTMuiDialog;
|
|
98
102
|
|
|
99
103
|
interface FormLabelProps {
|
|
100
104
|
children: string | HTMLElement | KTHTMLElement;
|
|
@@ -120,6 +124,9 @@ interface LinearProgressProps {
|
|
|
120
124
|
color?: 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success';
|
|
121
125
|
}
|
|
122
126
|
type KTMuiLinearProgress = KTHTMLElement$1 & {
|
|
127
|
+
/**
|
|
128
|
+
* Reactive property to get or set the current progress value (0-100)
|
|
129
|
+
*/
|
|
123
130
|
progress: number;
|
|
124
131
|
};
|
|
125
132
|
/**
|
|
@@ -130,76 +137,132 @@ declare function LinearProgress(props: LinearProgressProps): KTMuiLinearProgress
|
|
|
130
137
|
type ChangeHandler<T = string> = (value: T, ...args: any[]) => void;
|
|
131
138
|
|
|
132
139
|
type InputTypes = 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
140
|
+
|
|
141
|
+
interface KTMuiTextFieldProps<T extends InputTypes> {
|
|
142
|
+
class?: string;
|
|
143
|
+
style?: string;
|
|
144
|
+
label?: string;
|
|
145
|
+
placeholder?: string;
|
|
146
|
+
value?: any;
|
|
147
|
+
type?: T;
|
|
148
|
+
disabled?: boolean;
|
|
149
|
+
readonly?: boolean;
|
|
150
|
+
required?: boolean;
|
|
151
|
+
error?: boolean;
|
|
152
|
+
helperText?: string;
|
|
153
|
+
fullWidth?: boolean;
|
|
154
|
+
multiline?: boolean;
|
|
155
|
+
rows?: number;
|
|
156
|
+
size?: 'small' | 'medium';
|
|
157
|
+
'kt:input'?: T extends 'number' ? ChangeHandler<number> | KTRef$1<number> : ChangeHandler | KTRef$1<string>;
|
|
158
|
+
'kt-trim:input'?: T extends 'number' ? ChangeHandler<number> | KTRef$1<number> : ChangeHandler | KTRef$1<string>;
|
|
159
|
+
'kt:change'?: T extends 'number' ? ChangeHandler<number> | KTRef$1<number> : ChangeHandler | KTRef$1<string>;
|
|
160
|
+
'kt-trim:change'?: T extends 'number' ? ChangeHandler<number> | KTRef$1<number> : ChangeHandler | KTRef$1<string>;
|
|
161
|
+
'kt:blur'?: () => void;
|
|
162
|
+
'kt:focus'?: () => void;
|
|
155
163
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
|
|
165
|
+
type KTMuiTextField = KTHTMLElement & {
|
|
166
|
+
/**
|
|
167
|
+
* Reactive `value` of the input field
|
|
168
|
+
*/
|
|
169
|
+
value: string;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Reactive `label` of the input field
|
|
173
|
+
*/
|
|
174
|
+
label: string;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Reactive `placeholder` of the input field
|
|
178
|
+
*/
|
|
179
|
+
placeholder: string;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Reactive `type` of the input field
|
|
183
|
+
*/
|
|
184
|
+
type: string;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Reactive `disabled` state of the input field
|
|
188
|
+
*/
|
|
189
|
+
disabled: boolean;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Reactive `readonly` state of the input field
|
|
193
|
+
*/
|
|
194
|
+
readonly: boolean;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* `required` state of the input field
|
|
198
|
+
* @readonly
|
|
199
|
+
*/
|
|
200
|
+
readonly required: boolean;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Reactive `error` state of the input field
|
|
204
|
+
*/
|
|
205
|
+
error: boolean;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Reactive `helperText` of the input field
|
|
209
|
+
*/
|
|
210
|
+
helperText: string;
|
|
166
211
|
};
|
|
212
|
+
|
|
167
213
|
/**
|
|
168
214
|
* TextField component - mimics MUI TextField appearance and behavior
|
|
169
215
|
*/
|
|
170
|
-
declare function TextField<T extends InputTypes>(props:
|
|
171
|
-
|
|
172
|
-
interface
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
216
|
+
declare function TextField<T extends InputTypes>(props: KTMuiTextFieldProps<T>): KTMuiTextField;
|
|
217
|
+
|
|
218
|
+
interface KTMuiRadioProps {
|
|
219
|
+
value: string;
|
|
220
|
+
text: string | KTHTMLElement | HTMLElement;
|
|
221
|
+
checked?: boolean;
|
|
222
|
+
size?: 'small' | 'medium';
|
|
223
|
+
'kt:change'?: (checked: boolean, value: string) => void;
|
|
224
|
+
disabled?: boolean;
|
|
225
|
+
color?: 'primary' | 'secondary' | 'default';
|
|
180
226
|
}
|
|
181
|
-
|
|
182
|
-
|
|
227
|
+
|
|
228
|
+
type KTMuiRadio = KTHTMLElement & {
|
|
229
|
+
/**
|
|
230
|
+
* The value of the radio button
|
|
231
|
+
* @readonly
|
|
232
|
+
*/
|
|
233
|
+
readonly value: string;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Reactive checked state of the radio button
|
|
237
|
+
*/
|
|
238
|
+
checked: boolean;
|
|
239
|
+
};
|
|
240
|
+
type KTMuiRadioGroup = KTHTMLElement & {
|
|
241
|
+
/**
|
|
242
|
+
* Reactive checked state of the radio button
|
|
243
|
+
*/
|
|
244
|
+
value: string;
|
|
183
245
|
};
|
|
246
|
+
|
|
184
247
|
/**
|
|
185
248
|
* Radio component - mimics MUI Radio appearance and behavior
|
|
186
249
|
*/
|
|
187
|
-
declare function Radio(props:
|
|
250
|
+
declare function Radio(props: KTMuiRadioProps): KTMuiRadio;
|
|
188
251
|
interface RadioGroupProps {
|
|
189
252
|
class?: string;
|
|
190
253
|
style?: string;
|
|
191
254
|
value?: string;
|
|
192
255
|
name?: string;
|
|
193
256
|
size?: 'small' | 'medium';
|
|
194
|
-
options:
|
|
195
|
-
'kt:change'?: (value: string) => void
|
|
257
|
+
options: KTMuiRadioProps[];
|
|
258
|
+
'kt:change'?: ((value: string) => void) | KTRef<string>;
|
|
196
259
|
'kt:click'?: (checked: boolean) => void;
|
|
197
260
|
row?: boolean;
|
|
198
261
|
}
|
|
199
262
|
/**
|
|
200
263
|
* RadioGroup component - groups multiple radios together
|
|
201
264
|
*/
|
|
202
|
-
declare function RadioGroup(props: RadioGroupProps):
|
|
265
|
+
declare function RadioGroup(props: RadioGroupProps): KTMuiRadioGroup;
|
|
203
266
|
|
|
204
267
|
interface SelectOption {
|
|
205
268
|
value: string;
|
|
@@ -267,4 +330,4 @@ declare function ContentCopyIcon(props: KTAttribute): JSX.Element;
|
|
|
267
330
|
declare function SelectAllIcon(props: KTAttribute): JSX.Element;
|
|
268
331
|
|
|
269
332
|
export { Alert, Button, Checkbox, CheckboxGroup, ColorLensIcon, CompressIcon, ContentCopyIcon, ContentPasteIcon, DeleteIcon, Dialog, DownloadIcon, ExpandMoreIcon, FileOpenIcon as FileOpen, FileOpenIcon, FolderOpenIcon, FormLabel, HomeIcon, LinearProgress, MenuIcon, NewReleasesIcon, PlayArrowIcon, QueuePlayNextIcon, Radio, RadioGroup, SaveIcon, Select, SelectAllIcon, SettingsIcon, StopIcon, SubtitlesIcon, TextField, UploadFileIcon, VideoFileIcon, WallpaperIcon };
|
|
270
|
-
export type { KTMuiDialog, KTMuiLinearProgress, KTMuiTextField };
|
|
333
|
+
export type { KTMuiDialog, KTMuiLinearProgress, KTMuiRadio, KTMuiRadioGroup, KTMuiRadioProps, KTMuiTextField, KTMuiTextFieldProps };
|
package/dist/index.iife.js
CHANGED
|
@@ -44,7 +44,7 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
44
44
|
return alert;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const emptyFn$
|
|
47
|
+
const emptyFn$1 = () => { };
|
|
48
48
|
const generateHandler = (props, key) => {
|
|
49
49
|
const handler = props[key];
|
|
50
50
|
if (typeof handler === 'function') {
|
|
@@ -53,14 +53,14 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
53
53
|
else if (handler && typeof handler === 'object' && handler.isKT) {
|
|
54
54
|
return (value) => (handler.value = value);
|
|
55
55
|
}
|
|
56
|
-
return emptyFn$
|
|
56
|
+
return emptyFn$1;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Button component - mimics MUI Button appearance and behavior
|
|
61
61
|
*/
|
|
62
62
|
function Button(props) {
|
|
63
|
-
const { children, variant = 'text', color = 'primary', size = 'medium', disabled = false, fullWidth = false, iconOnly = false, startIcon, endIcon, type = 'button', 'on:click': onClick = emptyFn$
|
|
63
|
+
const { children, variant = 'text', color = 'primary', size = 'medium', disabled = false, fullWidth = false, iconOnly = false, startIcon, endIcon, type = 'button', 'on:click': onClick = emptyFn$1, } = props;
|
|
64
64
|
const classes = [
|
|
65
65
|
'mui-button',
|
|
66
66
|
`mui-button-${variant}`,
|
|
@@ -248,13 +248,12 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
248
248
|
return container;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
const noop = () => { };
|
|
252
251
|
/**
|
|
253
252
|
* Dialog component - mimics MUI Dialog appearance and behavior
|
|
254
253
|
* Only handles open/close state, title and content are passed as props
|
|
255
254
|
*/
|
|
256
255
|
function Dialog(props) {
|
|
257
|
-
let { open = false, 'kt:close': onClose =
|
|
256
|
+
let { open = false, 'kt:close': onClose = emptyFn$1, title, children, actions, maxWidth = 'sm', fullWidth = false, } = props;
|
|
258
257
|
// Handle ESC key - store handler for cleanup
|
|
259
258
|
const keyDownHandler = (e) => {
|
|
260
259
|
if (e.key === 'Escape') {
|
|
@@ -589,11 +588,11 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
589
588
|
return container;
|
|
590
589
|
}
|
|
591
590
|
|
|
592
|
-
const emptyFn$1 = () => { };
|
|
593
591
|
/**
|
|
594
592
|
* Radio component - mimics MUI Radio appearance and behavior
|
|
595
593
|
*/
|
|
596
594
|
function Radio(props) {
|
|
595
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
597
596
|
const toggleIcon = (checked) => {
|
|
598
597
|
uncheckedIcon.style.display = checked ? 'none' : '';
|
|
599
598
|
checkedIcon.style.display = checked ? '' : 'none';
|
|
@@ -603,36 +602,47 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
603
602
|
if (disabled) {
|
|
604
603
|
return;
|
|
605
604
|
}
|
|
606
|
-
checked =
|
|
605
|
+
checked = input.checked;
|
|
607
606
|
toggleIcon(checked);
|
|
608
607
|
onChange(checked, value);
|
|
609
608
|
};
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
let checked = initChecked;
|
|
613
|
-
let disabled = initDisabled;
|
|
609
|
+
let { checked = false, value = '', text = '', size = 'small', disabled = false, color = 'primary' } = props;
|
|
610
|
+
const input = (jsxRuntime.jsx("input", { type: "radio", class: "mui-radio-input", checked: checked, value: value, disabled: disabled, "on:change": handleChange }));
|
|
614
611
|
const uncheckedIcon = (jsxRuntime.jsx("span", { class: "mui-radio-icon-unchecked", children: jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" }) }) }));
|
|
615
612
|
const checkedIcon = (jsxRuntime.jsx("span", { class: "mui-radio-icon-checked", children: jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { d: "M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" }) }) }));
|
|
616
613
|
// initialize icon state
|
|
617
614
|
toggleIcon(checked);
|
|
618
|
-
const container = (jsxRuntime.jsxs("label", { class: `mui-radio-wrapper mui-radio-size-${size} ${disabled ? 'mui-radio-disabled' : ''} mui-radio-color-${color}`, children: [
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
615
|
+
const container = (jsxRuntime.jsxs("label", { class: `mui-radio-wrapper mui-radio-size-${size} ${disabled ? 'mui-radio-disabled' : ''} mui-radio-color-${color}`, children: [input, jsxRuntime.jsxs("span", { class: "mui-radio-icon", children: [uncheckedIcon, checkedIcon] }), jsxRuntime.jsx("span", { class: "mui-radio-label", children: text })] }));
|
|
616
|
+
Object.defineProperties(container, {
|
|
617
|
+
value: {
|
|
618
|
+
get() {
|
|
619
|
+
return value;
|
|
620
|
+
},
|
|
621
|
+
},
|
|
622
|
+
checked: {
|
|
623
|
+
get() {
|
|
624
|
+
return checked;
|
|
625
|
+
},
|
|
626
|
+
set(newChecked) {
|
|
627
|
+
checked = newChecked === value;
|
|
628
|
+
input.checked = checked;
|
|
629
|
+
toggleIcon(checked);
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
});
|
|
624
633
|
return container;
|
|
625
634
|
}
|
|
626
635
|
/**
|
|
627
636
|
* RadioGroup component - groups multiple radios together
|
|
628
637
|
*/
|
|
629
638
|
function RadioGroup(props) {
|
|
630
|
-
|
|
639
|
+
let { value = '', size = 'small', row = false } = props;
|
|
640
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
631
641
|
const changeHandler = (checked, value) => {
|
|
632
642
|
if (checked) {
|
|
633
643
|
onChange(value);
|
|
634
644
|
}
|
|
635
|
-
radios.forEach((radio) => radio.
|
|
645
|
+
radios.forEach((radio) => (radio.checked = radio.value === value));
|
|
636
646
|
};
|
|
637
647
|
const radios = props.options.map((o) => {
|
|
638
648
|
o.size = size;
|
|
@@ -649,7 +659,19 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
649
659
|
}
|
|
650
660
|
return Radio(o);
|
|
651
661
|
});
|
|
652
|
-
|
|
662
|
+
const container = (jsxRuntime.jsx("div", { class: `mui-radio-group ${row ? 'mui-radio-group-row' : ''} ${props.class ?? ''}`, style: props.style ?? '', role: "radiogroup", children: radios }));
|
|
663
|
+
Object.defineProperties(container, {
|
|
664
|
+
value: {
|
|
665
|
+
get() {
|
|
666
|
+
return value;
|
|
667
|
+
},
|
|
668
|
+
set(newValue) {
|
|
669
|
+
value = newValue;
|
|
670
|
+
radios.forEach((radio) => (radio.checked = radio.value === value));
|
|
671
|
+
},
|
|
672
|
+
},
|
|
673
|
+
});
|
|
674
|
+
return container;
|
|
653
675
|
}
|
|
654
676
|
|
|
655
677
|
const emptyFn = () => { };
|
package/dist/index.mjs
CHANGED
|
@@ -44,7 +44,7 @@ function Alert(props) {
|
|
|
44
44
|
return alert;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const emptyFn$
|
|
47
|
+
const emptyFn$1 = () => { };
|
|
48
48
|
const generateHandler = (props, key) => {
|
|
49
49
|
const handler = props[key];
|
|
50
50
|
if (typeof handler === 'function') {
|
|
@@ -53,14 +53,14 @@ const generateHandler = (props, key) => {
|
|
|
53
53
|
else if (handler && typeof handler === 'object' && handler.isKT) {
|
|
54
54
|
return (value) => (handler.value = value);
|
|
55
55
|
}
|
|
56
|
-
return emptyFn$
|
|
56
|
+
return emptyFn$1;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Button component - mimics MUI Button appearance and behavior
|
|
61
61
|
*/
|
|
62
62
|
function Button(props) {
|
|
63
|
-
const { children, variant = 'text', color = 'primary', size = 'medium', disabled = false, fullWidth = false, iconOnly = false, startIcon, endIcon, type = 'button', 'on:click': onClick = emptyFn$
|
|
63
|
+
const { children, variant = 'text', color = 'primary', size = 'medium', disabled = false, fullWidth = false, iconOnly = false, startIcon, endIcon, type = 'button', 'on:click': onClick = emptyFn$1, } = props;
|
|
64
64
|
const classes = [
|
|
65
65
|
'mui-button',
|
|
66
66
|
`mui-button-${variant}`,
|
|
@@ -248,13 +248,12 @@ function CheckboxGroup(props) {
|
|
|
248
248
|
return container;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
const noop = () => { };
|
|
252
251
|
/**
|
|
253
252
|
* Dialog component - mimics MUI Dialog appearance and behavior
|
|
254
253
|
* Only handles open/close state, title and content are passed as props
|
|
255
254
|
*/
|
|
256
255
|
function Dialog(props) {
|
|
257
|
-
let { open = false, 'kt:close': onClose =
|
|
256
|
+
let { open = false, 'kt:close': onClose = emptyFn$1, title, children, actions, maxWidth = 'sm', fullWidth = false, } = props;
|
|
258
257
|
// Handle ESC key - store handler for cleanup
|
|
259
258
|
const keyDownHandler = (e) => {
|
|
260
259
|
if (e.key === 'Escape') {
|
|
@@ -589,11 +588,11 @@ function TextField(props) {
|
|
|
589
588
|
return container;
|
|
590
589
|
}
|
|
591
590
|
|
|
592
|
-
const emptyFn$1 = () => { };
|
|
593
591
|
/**
|
|
594
592
|
* Radio component - mimics MUI Radio appearance and behavior
|
|
595
593
|
*/
|
|
596
594
|
function Radio(props) {
|
|
595
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
597
596
|
const toggleIcon = (checked) => {
|
|
598
597
|
uncheckedIcon.style.display = checked ? 'none' : '';
|
|
599
598
|
checkedIcon.style.display = checked ? '' : 'none';
|
|
@@ -603,36 +602,47 @@ function Radio(props) {
|
|
|
603
602
|
if (disabled) {
|
|
604
603
|
return;
|
|
605
604
|
}
|
|
606
|
-
checked =
|
|
605
|
+
checked = input.checked;
|
|
607
606
|
toggleIcon(checked);
|
|
608
607
|
onChange(checked, value);
|
|
609
608
|
};
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
let checked = initChecked;
|
|
613
|
-
let disabled = initDisabled;
|
|
609
|
+
let { checked = false, value = '', text = '', size = 'small', disabled = false, color = 'primary' } = props;
|
|
610
|
+
const input = (jsx("input", { type: "radio", class: "mui-radio-input", checked: checked, value: value, disabled: disabled, "on:change": handleChange }));
|
|
614
611
|
const uncheckedIcon = (jsx("span", { class: "mui-radio-icon-unchecked", children: jsx("svg", { viewBox: "0 0 24 24", children: jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" }) }) }));
|
|
615
612
|
const checkedIcon = (jsx("span", { class: "mui-radio-icon-checked", children: jsx("svg", { viewBox: "0 0 24 24", children: jsx("path", { d: "M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" }) }) }));
|
|
616
613
|
// initialize icon state
|
|
617
614
|
toggleIcon(checked);
|
|
618
|
-
const container = (jsxs("label", { class: `mui-radio-wrapper mui-radio-size-${size} ${disabled ? 'mui-radio-disabled' : ''} mui-radio-color-${color}`, children: [
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
615
|
+
const container = (jsxs("label", { class: `mui-radio-wrapper mui-radio-size-${size} ${disabled ? 'mui-radio-disabled' : ''} mui-radio-color-${color}`, children: [input, jsxs("span", { class: "mui-radio-icon", children: [uncheckedIcon, checkedIcon] }), jsx("span", { class: "mui-radio-label", children: text })] }));
|
|
616
|
+
Object.defineProperties(container, {
|
|
617
|
+
value: {
|
|
618
|
+
get() {
|
|
619
|
+
return value;
|
|
620
|
+
},
|
|
621
|
+
},
|
|
622
|
+
checked: {
|
|
623
|
+
get() {
|
|
624
|
+
return checked;
|
|
625
|
+
},
|
|
626
|
+
set(newChecked) {
|
|
627
|
+
checked = newChecked === value;
|
|
628
|
+
input.checked = checked;
|
|
629
|
+
toggleIcon(checked);
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
});
|
|
624
633
|
return container;
|
|
625
634
|
}
|
|
626
635
|
/**
|
|
627
636
|
* RadioGroup component - groups multiple radios together
|
|
628
637
|
*/
|
|
629
638
|
function RadioGroup(props) {
|
|
630
|
-
|
|
639
|
+
let { value = '', size = 'small', row = false } = props;
|
|
640
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
631
641
|
const changeHandler = (checked, value) => {
|
|
632
642
|
if (checked) {
|
|
633
643
|
onChange(value);
|
|
634
644
|
}
|
|
635
|
-
radios.forEach((radio) => radio.
|
|
645
|
+
radios.forEach((radio) => (radio.checked = radio.value === value));
|
|
636
646
|
};
|
|
637
647
|
const radios = props.options.map((o) => {
|
|
638
648
|
o.size = size;
|
|
@@ -649,7 +659,19 @@ function RadioGroup(props) {
|
|
|
649
659
|
}
|
|
650
660
|
return Radio(o);
|
|
651
661
|
});
|
|
652
|
-
|
|
662
|
+
const container = (jsx("div", { class: `mui-radio-group ${row ? 'mui-radio-group-row' : ''} ${props.class ?? ''}`, style: props.style ?? '', role: "radiogroup", children: radios }));
|
|
663
|
+
Object.defineProperties(container, {
|
|
664
|
+
value: {
|
|
665
|
+
get() {
|
|
666
|
+
return value;
|
|
667
|
+
},
|
|
668
|
+
set(newValue) {
|
|
669
|
+
value = newValue;
|
|
670
|
+
radios.forEach((radio) => (radio.checked = radio.value === value));
|
|
671
|
+
},
|
|
672
|
+
},
|
|
673
|
+
});
|
|
674
|
+
return container;
|
|
653
675
|
}
|
|
654
676
|
|
|
655
677
|
const emptyFn = () => { };
|