@ktjs/mui 0.18.4 → 0.18.8
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 +161 -97
- package/dist/index.iife.js +69 -42
- package/dist/index.mjs +69 -42
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
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 {
|
|
5
5
|
class?: string;
|
|
6
|
-
style?: string
|
|
7
|
-
sx?: Record<string, any>;
|
|
6
|
+
style?: string | Partial<CSSStyleDeclaration>;
|
|
8
7
|
children: string | HTMLElement | KTHTMLElement | Array<string | HTMLElement | KTHTMLElement>;
|
|
9
8
|
severity?: 'error' | 'warning' | 'info' | 'success';
|
|
10
9
|
variant?: 'standard' | 'filled' | 'outlined';
|
|
@@ -18,7 +17,7 @@ declare function Alert(props: AlertProps): KTHTMLElement;
|
|
|
18
17
|
|
|
19
18
|
interface ButtonProps {
|
|
20
19
|
class?: string;
|
|
21
|
-
style?: string
|
|
20
|
+
style?: string | Partial<CSSStyleDeclaration>;
|
|
22
21
|
children: string | HTMLElement | KTHTMLElement;
|
|
23
22
|
variant?: 'contained' | 'outlined' | 'text';
|
|
24
23
|
color?: 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success';
|
|
@@ -36,46 +35,50 @@ interface ButtonProps {
|
|
|
36
35
|
*/
|
|
37
36
|
declare function Button(props: ButtonProps): KTHTMLElement;
|
|
38
37
|
|
|
39
|
-
interface
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
interface KTMuiCheckboxProps {
|
|
39
|
+
value: string;
|
|
40
|
+
label?: string | KTHTMLElement$1 | HTMLElement;
|
|
41
|
+
checked?: boolean;
|
|
42
|
+
size?: 'small' | 'medium';
|
|
43
|
+
'kt:change'?: ((checked: boolean, value: string) => void) | KTRef<boolean>;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
color?: 'primary' | 'secondary' | 'default' | 'success' | 'error' | 'warning';
|
|
46
|
+
indeterminate?: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface KTMuiCheckboxGroupProps {
|
|
50
|
+
class?: string;
|
|
51
|
+
style?: string;
|
|
52
|
+
value?: string[];
|
|
53
|
+
size?: 'small' | 'medium';
|
|
54
|
+
options: KTMuiCheckboxProps[];
|
|
55
|
+
'kt:change'?: ((values: string[]) => void) | KTRef<string[]>;
|
|
56
|
+
row?: boolean;
|
|
48
57
|
}
|
|
58
|
+
|
|
49
59
|
type KTMuiCheckbox = KTHTMLElement$1 & {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
checked: boolean;
|
|
61
|
+
value: string;
|
|
62
|
+
disabled: boolean;
|
|
53
63
|
};
|
|
64
|
+
|
|
54
65
|
type KTMuiCheckboxGroup = KTHTMLElement$1 & {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
value: string[];
|
|
67
|
+
disabled: boolean[];
|
|
68
|
+
disableAll: () => void;
|
|
69
|
+
enableAll: () => void;
|
|
59
70
|
};
|
|
71
|
+
|
|
60
72
|
/**
|
|
61
73
|
* Checkbox component - mimics MUI Checkbox appearance and behavior
|
|
62
74
|
*/
|
|
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
|
-
}
|
|
75
|
+
declare function Checkbox(props: KTMuiCheckboxProps): KTMuiCheckbox;
|
|
73
76
|
/**
|
|
74
77
|
* CheckboxGroup component - groups multiple checkboxes together
|
|
75
78
|
*/
|
|
76
|
-
declare function CheckboxGroup(props:
|
|
79
|
+
declare function CheckboxGroup(props: KTMuiCheckboxGroupProps): KTMuiCheckboxGroup;
|
|
77
80
|
|
|
78
|
-
interface
|
|
81
|
+
interface KTMuiDialogProps {
|
|
79
82
|
open?: boolean;
|
|
80
83
|
'kt:close'?: () => void;
|
|
81
84
|
title?: string;
|
|
@@ -94,7 +97,7 @@ type KTMuiDialog = KTHTMLElement$1 & {
|
|
|
94
97
|
* Dialog component - mimics MUI Dialog appearance and behavior
|
|
95
98
|
* Only handles open/close state, title and content are passed as props
|
|
96
99
|
*/
|
|
97
|
-
declare function Dialog(props:
|
|
100
|
+
declare function Dialog(props: KTMuiDialogProps): KTMuiDialog;
|
|
98
101
|
|
|
99
102
|
interface FormLabelProps {
|
|
100
103
|
children: string | HTMLElement | KTHTMLElement;
|
|
@@ -113,13 +116,15 @@ declare function FormLabel(props: FormLabelProps): KTHTMLElement;
|
|
|
113
116
|
|
|
114
117
|
interface LinearProgressProps {
|
|
115
118
|
class?: string;
|
|
116
|
-
style?: string
|
|
117
|
-
sx?: Record<string, any>;
|
|
119
|
+
style?: string | Partial<CSSStyleDeclaration>;
|
|
118
120
|
variant?: 'determinate' | 'indeterminate';
|
|
119
121
|
progress?: number;
|
|
120
122
|
color?: 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success';
|
|
121
123
|
}
|
|
122
124
|
type KTMuiLinearProgress = KTHTMLElement$1 & {
|
|
125
|
+
/**
|
|
126
|
+
* Reactive property to get or set the current progress value (0-100)
|
|
127
|
+
*/
|
|
123
128
|
progress: number;
|
|
124
129
|
};
|
|
125
130
|
/**
|
|
@@ -130,87 +135,146 @@ declare function LinearProgress(props: LinearProgressProps): KTMuiLinearProgress
|
|
|
130
135
|
type ChangeHandler<T = string> = (value: T, ...args: any[]) => void;
|
|
131
136
|
|
|
132
137
|
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
|
-
|
|
138
|
+
|
|
139
|
+
interface KTMuiTextFieldProps<T extends InputTypes> {
|
|
140
|
+
class?: string;
|
|
141
|
+
style?: string | Partial<CSSStyleDeclaration>;
|
|
142
|
+
label?: string;
|
|
143
|
+
placeholder?: string;
|
|
144
|
+
value?: any;
|
|
145
|
+
type?: T;
|
|
146
|
+
disabled?: boolean;
|
|
147
|
+
readonly?: boolean;
|
|
148
|
+
required?: boolean;
|
|
149
|
+
error?: boolean;
|
|
150
|
+
helperText?: string;
|
|
151
|
+
fullWidth?: boolean;
|
|
152
|
+
multiline?: boolean;
|
|
153
|
+
rows?: number;
|
|
154
|
+
size?: 'small' | 'medium';
|
|
155
|
+
'kt:input'?: T extends 'number' ? ChangeHandler<number> | KTRef$1<number> : ChangeHandler | KTRef$1<string>;
|
|
156
|
+
'kt-trim:input'?: T extends 'number' ? ChangeHandler<number> | KTRef$1<number> : ChangeHandler | KTRef$1<string>;
|
|
157
|
+
'kt:change'?: T extends 'number' ? ChangeHandler<number> | KTRef$1<number> : ChangeHandler | KTRef$1<string>;
|
|
158
|
+
'kt-trim:change'?: T extends 'number' ? ChangeHandler<number> | KTRef$1<number> : ChangeHandler | KTRef$1<string>;
|
|
159
|
+
'kt:blur'?: () => void;
|
|
160
|
+
'kt:focus'?: () => void;
|
|
155
161
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
|
|
163
|
+
type KTMuiTextField = KTHTMLElement & {
|
|
164
|
+
/**
|
|
165
|
+
* Reactive `value` of the input field
|
|
166
|
+
*/
|
|
167
|
+
value: string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Reactive `label` of the input field
|
|
171
|
+
*/
|
|
172
|
+
label: string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Reactive `placeholder` of the input field
|
|
176
|
+
*/
|
|
177
|
+
placeholder: string;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Reactive `type` of the input field
|
|
181
|
+
*/
|
|
182
|
+
type: string;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Reactive `disabled` state of the input field
|
|
186
|
+
*/
|
|
187
|
+
disabled: boolean;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Reactive `readonly` state of the input field
|
|
191
|
+
*/
|
|
192
|
+
readonly: boolean;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* `required` state of the input field
|
|
196
|
+
* @readonly
|
|
197
|
+
*/
|
|
198
|
+
readonly required: boolean;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Reactive `error` state of the input field
|
|
202
|
+
*/
|
|
203
|
+
error: boolean;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Reactive `helperText` of the input field
|
|
207
|
+
*/
|
|
208
|
+
helperText: string;
|
|
166
209
|
};
|
|
210
|
+
|
|
167
211
|
/**
|
|
168
212
|
* TextField component - mimics MUI TextField appearance and behavior
|
|
169
213
|
*/
|
|
170
|
-
declare function TextField<T extends InputTypes>(props:
|
|
214
|
+
declare function TextField<T extends InputTypes>(props: KTMuiTextFieldProps<T>): KTMuiTextField;
|
|
215
|
+
|
|
216
|
+
interface KTMuiRadioProps {
|
|
217
|
+
class?: string;
|
|
218
|
+
style?: string | Partial<CSSStyleDeclaration>;
|
|
219
|
+
value: string;
|
|
220
|
+
label: string | KTHTMLElement$1 | HTMLElement;
|
|
221
|
+
checked?: boolean;
|
|
222
|
+
size?: 'small' | 'medium';
|
|
223
|
+
'kt:change'?: (checked: boolean, value: string) => void;
|
|
224
|
+
disabled?: boolean;
|
|
225
|
+
color?: 'primary' | 'secondary' | 'default';
|
|
226
|
+
}
|
|
171
227
|
|
|
172
|
-
interface
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
228
|
+
interface KTMuiRadioGroupProps {
|
|
229
|
+
class?: string;
|
|
230
|
+
style?: string | Partial<CSSStyleDeclaration>;
|
|
231
|
+
value?: string;
|
|
232
|
+
name?: string;
|
|
233
|
+
size?: 'small' | 'medium';
|
|
234
|
+
options: KTMuiRadioProps[];
|
|
235
|
+
'kt:change'?: ((value: string) => void) | KTRef<string>;
|
|
236
|
+
'kt:click'?: (checked: boolean) => void;
|
|
237
|
+
row?: boolean;
|
|
180
238
|
}
|
|
181
|
-
|
|
182
|
-
|
|
239
|
+
|
|
240
|
+
type KTMuiRadio = KTHTMLElement$1 & {
|
|
241
|
+
/**
|
|
242
|
+
* The value of the radio button
|
|
243
|
+
* @readonly
|
|
244
|
+
*/
|
|
245
|
+
readonly value: string;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Reactive checked state of the radio button
|
|
249
|
+
*/
|
|
250
|
+
checked: boolean;
|
|
251
|
+
};
|
|
252
|
+
type KTMuiRadioGroup = KTHTMLElement$1 & {
|
|
253
|
+
/**
|
|
254
|
+
* Reactive checked state of the radio button
|
|
255
|
+
*/
|
|
256
|
+
value: string;
|
|
183
257
|
};
|
|
258
|
+
|
|
184
259
|
/**
|
|
185
260
|
* Radio component - mimics MUI Radio appearance and behavior
|
|
186
261
|
*/
|
|
187
|
-
declare function Radio(props:
|
|
188
|
-
interface RadioGroupProps {
|
|
189
|
-
class?: string;
|
|
190
|
-
style?: string;
|
|
191
|
-
value?: string;
|
|
192
|
-
name?: string;
|
|
193
|
-
size?: 'small' | 'medium';
|
|
194
|
-
options: RadioProps[];
|
|
195
|
-
'kt:change'?: (value: string) => void;
|
|
196
|
-
'kt:click'?: (checked: boolean) => void;
|
|
197
|
-
row?: boolean;
|
|
198
|
-
}
|
|
262
|
+
declare function Radio(props: KTMuiRadioProps): KTMuiRadio;
|
|
199
263
|
/**
|
|
200
264
|
* RadioGroup component - groups multiple radios together
|
|
201
265
|
*/
|
|
202
|
-
declare function RadioGroup(props:
|
|
266
|
+
declare function RadioGroup(props: KTMuiRadioGroupProps): KTMuiRadioGroup;
|
|
203
267
|
|
|
204
|
-
interface
|
|
268
|
+
interface KTMuiSelectOption {
|
|
205
269
|
value: string;
|
|
206
270
|
label: string;
|
|
207
271
|
}
|
|
208
|
-
interface
|
|
272
|
+
interface KTMuiSelectProps {
|
|
209
273
|
class?: string;
|
|
210
|
-
style?: string
|
|
274
|
+
style?: string | Partial<CSSStyleDeclaration>;
|
|
211
275
|
size?: 'small' | 'medium';
|
|
212
276
|
value?: string;
|
|
213
|
-
options:
|
|
277
|
+
options: KTMuiSelectOption[];
|
|
214
278
|
label?: string;
|
|
215
279
|
placeholder?: string;
|
|
216
280
|
'kt:change'?: (value: string) => void;
|
|
@@ -220,7 +284,7 @@ interface SelectProps {
|
|
|
220
284
|
/**
|
|
221
285
|
* Select component - mimics MUI Select appearance and behavior
|
|
222
286
|
*/
|
|
223
|
-
declare function Select(props:
|
|
287
|
+
declare function Select(props: KTMuiSelectProps): JSX.Element;
|
|
224
288
|
|
|
225
289
|
declare function DownloadIcon(props: KTAttribute): JSX.Element;
|
|
226
290
|
|
|
@@ -267,4 +331,4 @@ declare function ContentCopyIcon(props: KTAttribute): JSX.Element;
|
|
|
267
331
|
declare function SelectAllIcon(props: KTAttribute): JSX.Element;
|
|
268
332
|
|
|
269
333
|
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 };
|
|
334
|
+
export type { KTMuiDialog, KTMuiLinearProgress, KTMuiRadio, KTMuiRadioGroup, KTMuiRadioProps, KTMuiSelectProps, KTMuiTextField, KTMuiTextFieldProps };
|
package/dist/index.iife.js
CHANGED
|
@@ -5,12 +5,12 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
5
5
|
* Alert component - mimics MUI Alert appearance and behavior
|
|
6
6
|
*/
|
|
7
7
|
function Alert(props) {
|
|
8
|
-
const { children, severity = 'info', variant = 'standard', icon, 'kt:close': onClose
|
|
8
|
+
const { children, style = '', severity = 'info', variant = 'standard', icon, 'kt:close': onClose } = props;
|
|
9
9
|
const classes = `mui-alert mui-alert-${severity} mui-alert-${variant} ${props.class ? props.class : ''}`;
|
|
10
10
|
// Convert sx object to style string
|
|
11
|
-
let styleString =
|
|
12
|
-
if (
|
|
13
|
-
const sxStyles = Object.entries(
|
|
11
|
+
let styleString = typeof style === 'string' ? style : '';
|
|
12
|
+
if (style && typeof style === 'object') {
|
|
13
|
+
const sxStyles = Object.entries(style)
|
|
14
14
|
.map(([key, value]) => {
|
|
15
15
|
// Convert camelCase to kebab-case
|
|
16
16
|
const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
@@ -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 = () => { };
|
|
48
48
|
const generateHandler = (props, key) => {
|
|
49
49
|
const handler = props[key];
|
|
50
50
|
if (typeof handler === 'function') {
|
|
@@ -53,14 +53,30 @@ 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;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const parseStyle = (style) => {
|
|
60
|
+
if (typeof style === 'string') {
|
|
61
|
+
return style;
|
|
62
|
+
}
|
|
63
|
+
if (style && typeof style === 'object') {
|
|
64
|
+
return Object.entries(style)
|
|
65
|
+
.map(([key, value]) => {
|
|
66
|
+
// Convert camelCase to kebab-case
|
|
67
|
+
const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
68
|
+
return `${cssKey}: ${value}`;
|
|
69
|
+
})
|
|
70
|
+
.join('; ');
|
|
71
|
+
}
|
|
72
|
+
return '';
|
|
57
73
|
};
|
|
58
74
|
|
|
59
75
|
/**
|
|
60
76
|
* Button component - mimics MUI Button appearance and behavior
|
|
61
77
|
*/
|
|
62
78
|
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
|
|
79
|
+
const { children, variant = 'text', color = 'primary', size = 'medium', disabled = false, fullWidth = false, iconOnly = false, startIcon, endIcon, type = 'button', 'on:click': onClick = emptyFn, } = props;
|
|
64
80
|
const classes = [
|
|
65
81
|
'mui-button',
|
|
66
82
|
`mui-button-${variant}`,
|
|
@@ -99,7 +115,7 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
99
115
|
}
|
|
100
116
|
onClick(e);
|
|
101
117
|
};
|
|
102
|
-
return (jsxRuntime.jsxs("button", { class: classes, style: props.style
|
|
118
|
+
return (jsxRuntime.jsxs("button", { class: classes, style: parseStyle(props.style), type: type, disabled: disabled, "on:click": handleClick, children: [startIcon && jsxRuntime.jsx("span", { class: "mui-button-start-icon", children: startIcon }), jsxRuntime.jsx("span", { class: "mui-button-label", children: children }), endIcon && jsxRuntime.jsx("span", { class: "mui-button-end-icon", children: endIcon }), jsxRuntime.jsx("span", { class: "mui-button-ripple" })] }));
|
|
103
119
|
}
|
|
104
120
|
|
|
105
121
|
/**
|
|
@@ -248,13 +264,12 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
248
264
|
return container;
|
|
249
265
|
}
|
|
250
266
|
|
|
251
|
-
const noop = () => { };
|
|
252
267
|
/**
|
|
253
268
|
* Dialog component - mimics MUI Dialog appearance and behavior
|
|
254
269
|
* Only handles open/close state, title and content are passed as props
|
|
255
270
|
*/
|
|
256
271
|
function Dialog(props) {
|
|
257
|
-
let { open = false, 'kt:close': onClose =
|
|
272
|
+
let { open = false, 'kt:close': onClose = emptyFn, title, children, actions, maxWidth = 'sm', fullWidth = false, } = props;
|
|
258
273
|
// Handle ESC key - store handler for cleanup
|
|
259
274
|
const keyDownHandler = (e) => {
|
|
260
275
|
if (e.key === 'Escape') {
|
|
@@ -406,25 +421,14 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
406
421
|
* LinearProgress component - mimics MUI LinearProgress appearance and behavior
|
|
407
422
|
*/
|
|
408
423
|
function LinearProgress(props) {
|
|
409
|
-
let { variant = 'indeterminate', progress: value = 0, color = 'primary'
|
|
424
|
+
let { variant = 'indeterminate', progress: value = 0, color = 'primary' } = props;
|
|
410
425
|
const classes = [
|
|
411
426
|
'mui-linear-progress',
|
|
412
427
|
`mui-linear-progress-${color}`,
|
|
413
428
|
`mui-linear-progress-${variant}`,
|
|
414
429
|
props.class ? props.class : '',
|
|
415
430
|
].join(' ');
|
|
416
|
-
|
|
417
|
-
let styleString = props.style || '';
|
|
418
|
-
if (sx) {
|
|
419
|
-
const sxStyles = Object.entries(sx)
|
|
420
|
-
.map(([key, value]) => {
|
|
421
|
-
// Convert camelCase to kebab-case
|
|
422
|
-
const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
423
|
-
return `${cssKey}: ${value}`;
|
|
424
|
-
})
|
|
425
|
-
.join('; ');
|
|
426
|
-
styleString = styleString ? `${styleString}; ${sxStyles}` : sxStyles;
|
|
427
|
-
}
|
|
431
|
+
const styleString = parseStyle(props.style);
|
|
428
432
|
// Calculate progress percentage
|
|
429
433
|
let progressValue = Math.min(Math.max(value, 0), 100);
|
|
430
434
|
const barRef = ref();
|
|
@@ -507,7 +511,7 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
507
511
|
: (jsxRuntime.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 }));
|
|
508
512
|
const helperTextEl = jsxRuntime.jsx("p", { class: "mui-textfield-helper-text", children: helperText });
|
|
509
513
|
const wrapperRef = createRedrawable(() => (jsxRuntime.jsxs("div", { class: "mui-textfield-wrapper", children: [jsxRuntime.jsxs("label", { "k-if": label, class: "mui-textfield-label", children: [label, required && jsxRuntime.jsx("span", { class: "mui-textfield-required", children: "*" })] }), jsxRuntime.jsx("div", { class: "mui-textfield-input-wrapper", children: inputEl }), jsxRuntime.jsx("fieldset", { class: "mui-textfield-fieldset", children: jsxRuntime.jsx("legend", { "k-if": label, class: "mui-textfield-legend", children: jsxRuntime.jsxs("span", { children: [label, required && '*'] }) }) })] })));
|
|
510
|
-
const container = (jsxRuntime.jsxs("div", { class: 'mui-textfield-root ' + (props.class ? props.class : ''), style: props.style
|
|
514
|
+
const container = (jsxRuntime.jsxs("div", { class: 'mui-textfield-root ' + (props.class ? props.class : ''), style: parseStyle(props.style), children: [wrapperRef, helperTextEl] }));
|
|
511
515
|
// Initialize classes
|
|
512
516
|
setTimeout(() => updateContainerClass(), 0);
|
|
513
517
|
Object.defineProperties(container, {
|
|
@@ -589,11 +593,11 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
589
593
|
return container;
|
|
590
594
|
}
|
|
591
595
|
|
|
592
|
-
const emptyFn$1 = () => { };
|
|
593
596
|
/**
|
|
594
597
|
* Radio component - mimics MUI Radio appearance and behavior
|
|
595
598
|
*/
|
|
596
599
|
function Radio(props) {
|
|
600
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
597
601
|
const toggleIcon = (checked) => {
|
|
598
602
|
uncheckedIcon.style.display = checked ? 'none' : '';
|
|
599
603
|
checkedIcon.style.display = checked ? '' : 'none';
|
|
@@ -603,36 +607,47 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
603
607
|
if (disabled) {
|
|
604
608
|
return;
|
|
605
609
|
}
|
|
606
|
-
checked =
|
|
610
|
+
checked = input.checked;
|
|
607
611
|
toggleIcon(checked);
|
|
608
612
|
onChange(checked, value);
|
|
609
613
|
};
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
let checked = initChecked;
|
|
613
|
-
let disabled = initDisabled;
|
|
614
|
+
let { checked = false, value = '', label: text = '', size = 'small', disabled = false, color = 'primary' } = props;
|
|
615
|
+
const input = (jsxRuntime.jsx("input", { type: "radio", class: "mui-radio-input", checked: checked, value: value, disabled: disabled, "on:change": handleChange }));
|
|
614
616
|
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
617
|
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
618
|
// initialize icon state
|
|
617
619
|
toggleIcon(checked);
|
|
618
|
-
const container = (jsxRuntime.jsxs("label", { class: `mui-radio-wrapper mui-radio-size-${size} ${disabled ? 'mui-radio-disabled' : ''} mui-radio-color-${color}`,
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
620
|
+
const container = (jsxRuntime.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, jsxRuntime.jsxs("span", { class: "mui-radio-icon", children: [uncheckedIcon, checkedIcon] }), jsxRuntime.jsx("span", { class: "mui-radio-label", children: text })] }));
|
|
621
|
+
Object.defineProperties(container, {
|
|
622
|
+
value: {
|
|
623
|
+
get() {
|
|
624
|
+
return value;
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
checked: {
|
|
628
|
+
get() {
|
|
629
|
+
return checked;
|
|
630
|
+
},
|
|
631
|
+
set(newChecked) {
|
|
632
|
+
checked = newChecked === value;
|
|
633
|
+
input.checked = checked;
|
|
634
|
+
toggleIcon(checked);
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
});
|
|
624
638
|
return container;
|
|
625
639
|
}
|
|
626
640
|
/**
|
|
627
641
|
* RadioGroup component - groups multiple radios together
|
|
628
642
|
*/
|
|
629
643
|
function RadioGroup(props) {
|
|
630
|
-
|
|
644
|
+
let { value = '', size = 'small', row = false } = props;
|
|
645
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
631
646
|
const changeHandler = (checked, value) => {
|
|
632
647
|
if (checked) {
|
|
633
648
|
onChange(value);
|
|
634
649
|
}
|
|
635
|
-
radios.forEach((radio) => radio.
|
|
650
|
+
radios.forEach((radio) => (radio.checked = radio.value === value));
|
|
636
651
|
};
|
|
637
652
|
const radios = props.options.map((o) => {
|
|
638
653
|
o.size = size;
|
|
@@ -649,15 +664,27 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
649
664
|
}
|
|
650
665
|
return Radio(o);
|
|
651
666
|
});
|
|
652
|
-
|
|
667
|
+
const container = (jsxRuntime.jsx("div", { class: `mui-radio-group ${row ? 'mui-radio-group-row' : ''} ${props.class ?? ''}`, style: parseStyle(props.style), role: "radiogroup", children: radios }));
|
|
668
|
+
Object.defineProperties(container, {
|
|
669
|
+
value: {
|
|
670
|
+
get() {
|
|
671
|
+
return value;
|
|
672
|
+
},
|
|
673
|
+
set(newValue) {
|
|
674
|
+
value = newValue;
|
|
675
|
+
radios.forEach((radio) => (radio.checked = radio.value === value));
|
|
676
|
+
},
|
|
677
|
+
},
|
|
678
|
+
});
|
|
679
|
+
return container;
|
|
653
680
|
}
|
|
654
681
|
|
|
655
|
-
const emptyFn = () => { };
|
|
656
682
|
/**
|
|
657
683
|
* Select component - mimics MUI Select appearance and behavior
|
|
658
684
|
*/
|
|
659
685
|
function Select(props) {
|
|
660
|
-
let { value = '', options = [], label = '', placeholder = '', size = 'medium',
|
|
686
|
+
let { value = '', options = [], label = '', placeholder = '', size = 'medium', fullWidth = false, disabled = false, } = props;
|
|
687
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
661
688
|
let isOpen = false;
|
|
662
689
|
let isFocused = false;
|
|
663
690
|
const selectRef = kt_js.ref();
|
|
@@ -744,7 +771,7 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
|
|
|
744
771
|
return (jsxRuntime.jsx("div", { class: "mui-select-menu", style: { display: 'none' }, children: options.map((option) => (jsxRuntime.jsx("div", { class: `mui-select-option ${option.value === value ? 'selected' : ''}`, "on:click": () => handleOptionClick(option.value), children: option.label }))) }));
|
|
745
772
|
});
|
|
746
773
|
// Create container
|
|
747
|
-
const container = (jsxRuntime.jsxs("div", { ref: selectRef, class: `mui-select-wrapper mui-select-size-${size} ${props.class
|
|
774
|
+
const container = (jsxRuntime.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: [label && jsxRuntime.jsx("label", { class: `mui-select-label ${value || isFocused ? 'focused' : ''}`, children: label }), jsxRuntime.jsxs("div", { class: "mui-select-control mui-select-outlined", "on:click": toggleMenu, "on:focus": handleFocus, "on:blur": handleBlur, tabIndex: disabled ? -1 : 0, children: [valueDisplay, jsxRuntime.jsx("input", { type: "hidden", value: value }), jsxRuntime.jsx("fieldset", { class: "mui-select-fieldset", children: jsxRuntime.jsx("legend", { children: jsxRuntime.jsx("span", { children: label }) }) }), jsxRuntime.jsx("svg", { class: "mui-select-icon", focusable: "false", "aria-hidden": "true", viewBox: "0 0 24 24", width: "24", height: "24", children: jsxRuntime.jsx("path", { d: "M7 10l5 5 5-5Z", fill: "currentColor" }) })] }), menu] }));
|
|
748
775
|
// Add global click listener
|
|
749
776
|
setTimeout(() => {
|
|
750
777
|
document.removeEventListener('click', handleClickOutside);
|
package/dist/index.mjs
CHANGED
|
@@ -5,12 +5,12 @@ import { ref as ref$1, createRedrawable as createRedrawable$1 } from 'kt.js';
|
|
|
5
5
|
* Alert component - mimics MUI Alert appearance and behavior
|
|
6
6
|
*/
|
|
7
7
|
function Alert(props) {
|
|
8
|
-
const { children, severity = 'info', variant = 'standard', icon, 'kt:close': onClose
|
|
8
|
+
const { children, style = '', severity = 'info', variant = 'standard', icon, 'kt:close': onClose } = props;
|
|
9
9
|
const classes = `mui-alert mui-alert-${severity} mui-alert-${variant} ${props.class ? props.class : ''}`;
|
|
10
10
|
// Convert sx object to style string
|
|
11
|
-
let styleString =
|
|
12
|
-
if (
|
|
13
|
-
const sxStyles = Object.entries(
|
|
11
|
+
let styleString = typeof style === 'string' ? style : '';
|
|
12
|
+
if (style && typeof style === 'object') {
|
|
13
|
+
const sxStyles = Object.entries(style)
|
|
14
14
|
.map(([key, value]) => {
|
|
15
15
|
// Convert camelCase to kebab-case
|
|
16
16
|
const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
@@ -44,7 +44,7 @@ function Alert(props) {
|
|
|
44
44
|
return alert;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const emptyFn
|
|
47
|
+
const emptyFn = () => { };
|
|
48
48
|
const generateHandler = (props, key) => {
|
|
49
49
|
const handler = props[key];
|
|
50
50
|
if (typeof handler === 'function') {
|
|
@@ -53,14 +53,30 @@ 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;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const parseStyle = (style) => {
|
|
60
|
+
if (typeof style === 'string') {
|
|
61
|
+
return style;
|
|
62
|
+
}
|
|
63
|
+
if (style && typeof style === 'object') {
|
|
64
|
+
return Object.entries(style)
|
|
65
|
+
.map(([key, value]) => {
|
|
66
|
+
// Convert camelCase to kebab-case
|
|
67
|
+
const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
68
|
+
return `${cssKey}: ${value}`;
|
|
69
|
+
})
|
|
70
|
+
.join('; ');
|
|
71
|
+
}
|
|
72
|
+
return '';
|
|
57
73
|
};
|
|
58
74
|
|
|
59
75
|
/**
|
|
60
76
|
* Button component - mimics MUI Button appearance and behavior
|
|
61
77
|
*/
|
|
62
78
|
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
|
|
79
|
+
const { children, variant = 'text', color = 'primary', size = 'medium', disabled = false, fullWidth = false, iconOnly = false, startIcon, endIcon, type = 'button', 'on:click': onClick = emptyFn, } = props;
|
|
64
80
|
const classes = [
|
|
65
81
|
'mui-button',
|
|
66
82
|
`mui-button-${variant}`,
|
|
@@ -99,7 +115,7 @@ function Button(props) {
|
|
|
99
115
|
}
|
|
100
116
|
onClick(e);
|
|
101
117
|
};
|
|
102
|
-
return (jsxs("button", { class: classes, style: props.style
|
|
118
|
+
return (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 }), jsx("span", { class: "mui-button-ripple" })] }));
|
|
103
119
|
}
|
|
104
120
|
|
|
105
121
|
/**
|
|
@@ -248,13 +264,12 @@ function CheckboxGroup(props) {
|
|
|
248
264
|
return container;
|
|
249
265
|
}
|
|
250
266
|
|
|
251
|
-
const noop = () => { };
|
|
252
267
|
/**
|
|
253
268
|
* Dialog component - mimics MUI Dialog appearance and behavior
|
|
254
269
|
* Only handles open/close state, title and content are passed as props
|
|
255
270
|
*/
|
|
256
271
|
function Dialog(props) {
|
|
257
|
-
let { open = false, 'kt:close': onClose =
|
|
272
|
+
let { open = false, 'kt:close': onClose = emptyFn, title, children, actions, maxWidth = 'sm', fullWidth = false, } = props;
|
|
258
273
|
// Handle ESC key - store handler for cleanup
|
|
259
274
|
const keyDownHandler = (e) => {
|
|
260
275
|
if (e.key === 'Escape') {
|
|
@@ -406,25 +421,14 @@ function createRedrawable(creator) {
|
|
|
406
421
|
* LinearProgress component - mimics MUI LinearProgress appearance and behavior
|
|
407
422
|
*/
|
|
408
423
|
function LinearProgress(props) {
|
|
409
|
-
let { variant = 'indeterminate', progress: value = 0, color = 'primary'
|
|
424
|
+
let { variant = 'indeterminate', progress: value = 0, color = 'primary' } = props;
|
|
410
425
|
const classes = [
|
|
411
426
|
'mui-linear-progress',
|
|
412
427
|
`mui-linear-progress-${color}`,
|
|
413
428
|
`mui-linear-progress-${variant}`,
|
|
414
429
|
props.class ? props.class : '',
|
|
415
430
|
].join(' ');
|
|
416
|
-
|
|
417
|
-
let styleString = props.style || '';
|
|
418
|
-
if (sx) {
|
|
419
|
-
const sxStyles = Object.entries(sx)
|
|
420
|
-
.map(([key, value]) => {
|
|
421
|
-
// Convert camelCase to kebab-case
|
|
422
|
-
const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
423
|
-
return `${cssKey}: ${value}`;
|
|
424
|
-
})
|
|
425
|
-
.join('; ');
|
|
426
|
-
styleString = styleString ? `${styleString}; ${sxStyles}` : sxStyles;
|
|
427
|
-
}
|
|
431
|
+
const styleString = parseStyle(props.style);
|
|
428
432
|
// Calculate progress percentage
|
|
429
433
|
let progressValue = Math.min(Math.max(value, 0), 100);
|
|
430
434
|
const barRef = ref();
|
|
@@ -507,7 +511,7 @@ function TextField(props) {
|
|
|
507
511
|
: (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 }));
|
|
508
512
|
const helperTextEl = jsx("p", { class: "mui-textfield-helper-text", children: helperText });
|
|
509
513
|
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 && '*'] }) }) })] })));
|
|
510
|
-
const container = (jsxs("div", { class: 'mui-textfield-root ' + (props.class ? props.class : ''), style: props.style
|
|
514
|
+
const container = (jsxs("div", { class: 'mui-textfield-root ' + (props.class ? props.class : ''), style: parseStyle(props.style), children: [wrapperRef, helperTextEl] }));
|
|
511
515
|
// Initialize classes
|
|
512
516
|
setTimeout(() => updateContainerClass(), 0);
|
|
513
517
|
Object.defineProperties(container, {
|
|
@@ -589,11 +593,11 @@ function TextField(props) {
|
|
|
589
593
|
return container;
|
|
590
594
|
}
|
|
591
595
|
|
|
592
|
-
const emptyFn$1 = () => { };
|
|
593
596
|
/**
|
|
594
597
|
* Radio component - mimics MUI Radio appearance and behavior
|
|
595
598
|
*/
|
|
596
599
|
function Radio(props) {
|
|
600
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
597
601
|
const toggleIcon = (checked) => {
|
|
598
602
|
uncheckedIcon.style.display = checked ? 'none' : '';
|
|
599
603
|
checkedIcon.style.display = checked ? '' : 'none';
|
|
@@ -603,36 +607,47 @@ function Radio(props) {
|
|
|
603
607
|
if (disabled) {
|
|
604
608
|
return;
|
|
605
609
|
}
|
|
606
|
-
checked =
|
|
610
|
+
checked = input.checked;
|
|
607
611
|
toggleIcon(checked);
|
|
608
612
|
onChange(checked, value);
|
|
609
613
|
};
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
let checked = initChecked;
|
|
613
|
-
let disabled = initDisabled;
|
|
614
|
+
let { checked = false, value = '', label: text = '', size = 'small', disabled = false, color = 'primary' } = props;
|
|
615
|
+
const input = (jsx("input", { type: "radio", class: "mui-radio-input", checked: checked, value: value, disabled: disabled, "on:change": handleChange }));
|
|
614
616
|
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
617
|
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
618
|
// initialize icon state
|
|
617
619
|
toggleIcon(checked);
|
|
618
|
-
const container = (jsxs("label", { class: `mui-radio-wrapper mui-radio-size-${size} ${disabled ? 'mui-radio-disabled' : ''} mui-radio-color-${color}`,
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
620
|
+
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 })] }));
|
|
621
|
+
Object.defineProperties(container, {
|
|
622
|
+
value: {
|
|
623
|
+
get() {
|
|
624
|
+
return value;
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
checked: {
|
|
628
|
+
get() {
|
|
629
|
+
return checked;
|
|
630
|
+
},
|
|
631
|
+
set(newChecked) {
|
|
632
|
+
checked = newChecked === value;
|
|
633
|
+
input.checked = checked;
|
|
634
|
+
toggleIcon(checked);
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
});
|
|
624
638
|
return container;
|
|
625
639
|
}
|
|
626
640
|
/**
|
|
627
641
|
* RadioGroup component - groups multiple radios together
|
|
628
642
|
*/
|
|
629
643
|
function RadioGroup(props) {
|
|
630
|
-
|
|
644
|
+
let { value = '', size = 'small', row = false } = props;
|
|
645
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
631
646
|
const changeHandler = (checked, value) => {
|
|
632
647
|
if (checked) {
|
|
633
648
|
onChange(value);
|
|
634
649
|
}
|
|
635
|
-
radios.forEach((radio) => radio.
|
|
650
|
+
radios.forEach((radio) => (radio.checked = radio.value === value));
|
|
636
651
|
};
|
|
637
652
|
const radios = props.options.map((o) => {
|
|
638
653
|
o.size = size;
|
|
@@ -649,15 +664,27 @@ function RadioGroup(props) {
|
|
|
649
664
|
}
|
|
650
665
|
return Radio(o);
|
|
651
666
|
});
|
|
652
|
-
|
|
667
|
+
const container = (jsx("div", { class: `mui-radio-group ${row ? 'mui-radio-group-row' : ''} ${props.class ?? ''}`, style: parseStyle(props.style), role: "radiogroup", children: radios }));
|
|
668
|
+
Object.defineProperties(container, {
|
|
669
|
+
value: {
|
|
670
|
+
get() {
|
|
671
|
+
return value;
|
|
672
|
+
},
|
|
673
|
+
set(newValue) {
|
|
674
|
+
value = newValue;
|
|
675
|
+
radios.forEach((radio) => (radio.checked = radio.value === value));
|
|
676
|
+
},
|
|
677
|
+
},
|
|
678
|
+
});
|
|
679
|
+
return container;
|
|
653
680
|
}
|
|
654
681
|
|
|
655
|
-
const emptyFn = () => { };
|
|
656
682
|
/**
|
|
657
683
|
* Select component - mimics MUI Select appearance and behavior
|
|
658
684
|
*/
|
|
659
685
|
function Select(props) {
|
|
660
|
-
let { value = '', options = [], label = '', placeholder = '', size = 'medium',
|
|
686
|
+
let { value = '', options = [], label = '', placeholder = '', size = 'medium', fullWidth = false, disabled = false, } = props;
|
|
687
|
+
const onChange = generateHandler(props, 'kt:change');
|
|
661
688
|
let isOpen = false;
|
|
662
689
|
let isFocused = false;
|
|
663
690
|
const selectRef = ref$1();
|
|
@@ -744,7 +771,7 @@ function Select(props) {
|
|
|
744
771
|
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 }))) }));
|
|
745
772
|
});
|
|
746
773
|
// Create container
|
|
747
|
-
const container = (jsxs("div", { ref: selectRef, class: `mui-select-wrapper mui-select-size-${size} ${props.class
|
|
774
|
+
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: [label && jsx("label", { 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] }));
|
|
748
775
|
// Add global click listener
|
|
749
776
|
setTimeout(() => {
|
|
750
777
|
document.removeEventListener('click', handleClickOutside);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ktjs/mui",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.8",
|
|
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.18.
|
|
38
|
+
"@ktjs/core": "0.18.10"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "rollup -c rollup.config.mjs",
|