@ktjs/mui 0.19.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
@@ -1,3 +1,34 @@
1
+ interface KTMuiAlertProps {
2
+ class?: string;
3
+ style?: string | Partial<CSSStyleDeclaration>;
4
+ children: string | HTMLElement | JSX.Element | Array<string | HTMLElement | JSX.Element>;
5
+ severity?: 'error' | 'warning' | 'info' | 'success';
6
+ variant?: 'standard' | 'filled' | 'outlined';
7
+ icon?: HTMLElement | false;
8
+ 'kt:close'?: () => void;
9
+ }
10
+ declare function Alert(props: KTMuiAlertProps): JSX.Element;
11
+
12
+ interface KTMuiButtonProps {
13
+ class?: string;
14
+ style?: string | Partial<CSSStyleDeclaration>;
15
+ children?: string | HTMLElement | JSX.Element;
16
+ variant?: 'contained' | 'outlined' | 'text';
17
+ color?: 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success';
18
+ size?: 'small' | 'medium' | 'large';
19
+ disabled?: boolean;
20
+ fullWidth?: boolean;
21
+ iconOnly?: boolean;
22
+ startIcon?: HTMLElement | JSX.Element;
23
+ endIcon?: HTMLElement | JSX.Element;
24
+ type?: 'button' | 'submit' | 'reset';
25
+ 'on:click'?: (event: Event) => void;
26
+ }
27
+ /**
28
+ * Button component - mimics MUI Button appearance and behavior
29
+ */
30
+ declare function Button(props: KTMuiButtonProps): JSX.Element;
31
+
1
32
  type otherstring = string & {};
2
33
 
3
34
  type RefChangeHandler<T> = (newValue: T, oldValue: T) => void;
@@ -6,8 +37,6 @@ declare class KTRef<T> {
6
37
  * Indicates that this is a KTRef instance
7
38
  */
8
39
  isKT: boolean;
9
- private _value;
10
- private _onChanges;
11
40
  constructor(_value: T, _onChanges: Array<RefChangeHandler<T>>);
12
41
  /**
13
42
  * If new value and old value are both nodes, the old one will be replaced in the DOM
@@ -18,6 +47,79 @@ declare class KTRef<T> {
18
47
  removeOnChange(callback: RefChangeHandler<T>): boolean;
19
48
  }
20
49
 
50
+ type SingleContent = KTRef<any> | HTMLElement | Element | Node | string | number | boolean | null | undefined;
51
+ type KTAvailableContent = SingleContent | KTAvailableContent[];
52
+ type KTRawContent = KTAvailableContent | Promise<KTAvailableContent>;
53
+
54
+ /**
55
+ * Used to create enhanced HTML elements
56
+ */
57
+ interface KTBaseAttribute {
58
+ [k: string]: any;
59
+
60
+ // # kt-specific attributes
61
+ ref?: KTRef<JSX.Element>;
62
+ 'k-if'?: any;
63
+
64
+ // # normal HTML attributes
65
+ id?: string;
66
+ class?: string;
67
+ className?: string;
68
+ style?: string | Partial<CSSStyleDeclaration>;
69
+
70
+ type?:
71
+ | 'text'
72
+ | 'password'
73
+ | 'email'
74
+ | 'number'
75
+ | 'tel'
76
+ | 'url'
77
+ | 'search'
78
+ | 'date'
79
+ | 'datetime-local'
80
+ | 'time'
81
+ | 'month'
82
+ | 'week'
83
+ | 'color'
84
+ | 'range'
85
+ | 'file'
86
+ | 'checkbox'
87
+ | 'radio'
88
+ | 'hidden'
89
+ | 'submit'
90
+ | 'reset'
91
+ | 'button'
92
+ | 'image'
93
+ | otherstring;
94
+ for?: string;
95
+
96
+ name?: string;
97
+ title?: string;
98
+ placeholder?: string;
99
+ contenteditable?: boolean;
100
+ value?: any;
101
+ valueAsDate?: Date;
102
+ valueAsNumber?: number;
103
+ label?: string;
104
+ disabled?: boolean;
105
+
106
+ min?: string | number;
107
+ max?: string | number;
108
+ step?: string | number;
109
+
110
+ selected?: boolean;
111
+ checked?: boolean;
112
+
113
+ action?: string;
114
+ method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
115
+ }
116
+
117
+ type KTPrefixedEventHandlers = {
118
+ [EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
119
+ };
120
+
121
+ type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
122
+
21
123
  // Base events available to all HTML elements
22
124
  interface BaseAttr {
23
125
  [k: string]: any;
@@ -997,19 +1099,13 @@ interface SVGAttributesMap {
997
1099
  view: AttributesMap['svg'] & { viewBox?: string; preserveAspectRatio?: string };
998
1100
  }
999
1101
 
1000
- type KTHTMLElement<El extends HTMLElement = HTMLElement> = El & {
1001
- /**
1002
- * Automically generate a redraw function if it is not provided
1003
- * @param props
1004
- */
1005
- redraw: (props?: KTAttribute, ...args: any[]) => KTHTMLElement;
1006
- };
1007
-
1008
1102
  declare global {
1009
1103
  namespace JSX {
1010
- type Element = KTHTMLElement;
1104
+ type Element = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
1011
1105
 
1012
1106
  interface IntrinsicElements {
1107
+ [k: string]: AttributesMap['div']; // Allow any element with div attributes as fallback
1108
+
1013
1109
  // Document-level & metadata
1014
1110
  html: AttributesMap['html'];
1015
1111
  head: AttributesMap['head'];
@@ -1178,10 +1274,71 @@ declare global {
1178
1274
  tspan: SVGAttributesMap['tspan'];
1179
1275
  use: SVGAttributesMap['use'];
1180
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'];
1181
1338
  }
1182
1339
 
1183
1340
  interface IntrinsicAttributes {
1184
- ref?: KTRef<HTMLElement>;
1341
+ ref?: KTRef<any>;
1185
1342
  'k-if'?: any;
1186
1343
  children?: KTRawContent;
1187
1344
  }
@@ -1192,116 +1349,9 @@ declare global {
1192
1349
  }
1193
1350
  }
1194
1351
 
1195
- type SingleContent = KTRef<any> | HTMLElement | Element | Node | string | number | boolean | null | undefined;
1196
- type KTAvailableContent = SingleContent | KTAvailableContent[];
1197
- type KTRawContent = KTAvailableContent | Promise<KTAvailableContent>;
1198
-
1199
- /**
1200
- * Used to create enhanced HTML elements
1201
- */
1202
- interface KTBaseAttribute {
1203
- [k: string]: any;
1204
-
1205
- // # kt-specific attributes
1206
- ref?: KTRef<KTHTMLElement>;
1207
- 'k-if'?: any;
1208
-
1209
- // # normal HTML attributes
1210
- id?: string;
1211
- class?: string;
1212
- className?: string;
1213
- style?: string | Partial<CSSStyleDeclaration>;
1214
-
1215
- type?:
1216
- | 'text'
1217
- | 'password'
1218
- | 'email'
1219
- | 'number'
1220
- | 'tel'
1221
- | 'url'
1222
- | 'search'
1223
- | 'date'
1224
- | 'datetime-local'
1225
- | 'time'
1226
- | 'month'
1227
- | 'week'
1228
- | 'color'
1229
- | 'range'
1230
- | 'file'
1231
- | 'checkbox'
1232
- | 'radio'
1233
- | 'hidden'
1234
- | 'submit'
1235
- | 'reset'
1236
- | 'button'
1237
- | 'image'
1238
- | otherstring;
1239
- for?: string;
1240
-
1241
- name?: string;
1242
- title?: string;
1243
- placeholder?: string;
1244
- contenteditable?: boolean;
1245
- value?: any;
1246
- valueAsDate?: Date;
1247
- valueAsNumber?: number;
1248
- label?: string;
1249
- disabled?: boolean;
1250
-
1251
- min?: string | number;
1252
- max?: string | number;
1253
- step?: string | number;
1254
-
1255
- selected?: boolean;
1256
- checked?: boolean;
1257
-
1258
- action?: string;
1259
- method?: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'CONNECT' | 'TRACE' | otherstring;
1260
- }
1261
-
1262
- type KTPrefixedEventHandlers = {
1263
- [EventName in keyof HTMLElementEventMap as `on:${EventName}`]?: (ev: HTMLElementEventMap[EventName]) => void;
1264
- };
1265
-
1266
- type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
1267
-
1268
- interface AlertProps {
1269
- class?: string;
1270
- style?: string | Partial<CSSStyleDeclaration>;
1271
- children: string | HTMLElement | KTHTMLElement | Array<string | HTMLElement | KTHTMLElement>;
1272
- severity?: 'error' | 'warning' | 'info' | 'success';
1273
- variant?: 'standard' | 'filled' | 'outlined';
1274
- icon?: HTMLElement | KTHTMLElement | false;
1275
- 'kt:close'?: () => void;
1276
- }
1277
- /**s
1278
- * Alert component - mimics MUI Alert appearance and behavior
1279
- */
1280
- declare function Alert(props: AlertProps): KTHTMLElement;
1281
-
1282
- interface ButtonProps {
1283
- class?: string;
1284
- style?: string | Partial<CSSStyleDeclaration>;
1285
- children: string | HTMLElement | KTHTMLElement;
1286
- variant?: 'contained' | 'outlined' | 'text';
1287
- color?: 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success';
1288
- size?: 'small' | 'medium' | 'large';
1289
- disabled?: boolean;
1290
- fullWidth?: boolean;
1291
- iconOnly?: boolean;
1292
- startIcon?: HTMLElement | KTHTMLElement;
1293
- endIcon?: HTMLElement | KTHTMLElement;
1294
- type?: 'button' | 'submit' | 'reset';
1295
- 'on:click'?: (event: Event) => void;
1296
- }
1297
- /**
1298
- * Button component - mimics MUI Button appearance and behavior
1299
- */
1300
- declare function Button(props: ButtonProps): KTHTMLElement;
1301
-
1302
1352
  interface KTMuiCheckboxProps {
1303
1353
  value: string;
1304
- label?: string | KTHTMLElement | HTMLElement;
1354
+ label?: string | JSX.Element | HTMLElement;
1305
1355
  checked?: boolean;
1306
1356
  size?: 'small' | 'medium';
1307
1357
  'kt:change'?: ((checked: boolean, value: string) => void) | KTRef<boolean>;
@@ -1320,13 +1370,13 @@ interface KTMuiCheckboxGroupProps {
1320
1370
  row?: boolean;
1321
1371
  }
1322
1372
 
1323
- type KTMuiCheckbox = KTHTMLElement & {
1373
+ type KTMuiCheckbox = JSX.Element & {
1324
1374
  checked: boolean;
1325
1375
  value: string;
1326
1376
  disabled: boolean;
1327
1377
  };
1328
1378
 
1329
- type KTMuiCheckboxGroup = KTHTMLElement & {
1379
+ type KTMuiCheckboxGroup = JSX.Element & {
1330
1380
  value: string[];
1331
1381
  disabled: boolean[];
1332
1382
  disableAll: () => void;
@@ -1346,12 +1396,12 @@ interface KTMuiDialogProps {
1346
1396
  open?: boolean;
1347
1397
  'kt:close'?: () => void;
1348
1398
  title?: string;
1349
- children?: HTMLElement | HTMLElement[] | string;
1399
+ children?: HTMLElement | HTMLElement[] | JSX.Element | JSX.Element[] | string;
1350
1400
  actions?: HTMLElement | HTMLElement[];
1351
1401
  maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false;
1352
1402
  fullWidth?: boolean;
1353
1403
  }
1354
- type KTMuiDialog = KTHTMLElement & {
1404
+ type KTMuiDialog = JSX.Element & {
1355
1405
  /**
1356
1406
  * Controls whether the dialog is open or closed
1357
1407
  */
@@ -1364,7 +1414,7 @@ type KTMuiDialog = KTHTMLElement & {
1364
1414
  declare function Dialog(props: KTMuiDialogProps): KTMuiDialog;
1365
1415
 
1366
1416
  interface FormLabelProps {
1367
- children: string | HTMLElement | KTHTMLElement;
1417
+ children: string | HTMLElement | JSX.Element;
1368
1418
  required?: boolean;
1369
1419
  error?: boolean;
1370
1420
  disabled?: boolean;
@@ -1376,7 +1426,7 @@ interface FormLabelProps {
1376
1426
  /**
1377
1427
  * FormLabel component - mimics MUI FormLabel appearance and behavior
1378
1428
  */
1379
- declare function FormLabel(props: FormLabelProps): KTHTMLElement;
1429
+ declare function FormLabel(props: FormLabelProps): JSX.Element;
1380
1430
 
1381
1431
  interface LinearProgressProps {
1382
1432
  class?: string;
@@ -1385,7 +1435,7 @@ interface LinearProgressProps {
1385
1435
  progress?: number;
1386
1436
  color?: 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success';
1387
1437
  }
1388
- type KTMuiLinearProgress = KTHTMLElement & {
1438
+ type KTMuiLinearProgress = JSX.Element & {
1389
1439
  /**
1390
1440
  * Reactive property to get or set the current progress value (0-100)
1391
1441
  */
@@ -1400,7 +1450,7 @@ type ChangeHandler<T = string> = (value: T, ...args: any[]) => void;
1400
1450
 
1401
1451
  type InputTypes = 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';
1402
1452
 
1403
- interface KTMuiTextFieldProps<T extends InputTypes> {
1453
+ interface KTMuiTextFieldProps<T extends InputTypes = 'text'> {
1404
1454
  class?: string;
1405
1455
  style?: string | Partial<CSSStyleDeclaration>;
1406
1456
  label?: string;
@@ -1424,7 +1474,7 @@ interface KTMuiTextFieldProps<T extends InputTypes> {
1424
1474
  'kt:focus'?: () => void;
1425
1475
  }
1426
1476
 
1427
- type KTMuiTextField = KTHTMLElement & {
1477
+ type KTMuiTextField = JSX.Element & {
1428
1478
  /**
1429
1479
  * Reactive `value` of the input field
1430
1480
  */
@@ -1481,7 +1531,7 @@ interface KTMuiRadioProps {
1481
1531
  class?: string;
1482
1532
  style?: string | Partial<CSSStyleDeclaration>;
1483
1533
  value: string;
1484
- label: string | KTHTMLElement | HTMLElement;
1534
+ label: string | JSX.Element | HTMLElement;
1485
1535
  checked?: boolean;
1486
1536
  size?: 'small' | 'medium';
1487
1537
  'kt:change'?: (checked: boolean, value: string) => void;
@@ -1501,7 +1551,7 @@ interface KTMuiRadioGroupProps {
1501
1551
  row?: boolean;
1502
1552
  }
1503
1553
 
1504
- type KTMuiRadio = KTHTMLElement & {
1554
+ type KTMuiRadio = JSX.Element & {
1505
1555
  /**
1506
1556
  * The value of the radio button
1507
1557
  * @readonly
@@ -1513,7 +1563,7 @@ type KTMuiRadio = KTHTMLElement & {
1513
1563
  */
1514
1564
  checked: boolean;
1515
1565
  };
1516
- type KTMuiRadioGroup = KTHTMLElement & {
1566
+ type KTMuiRadioGroup = JSX.Element & {
1517
1567
  /**
1518
1568
  * Reactive checked state of the radio button
1519
1569
  */
@@ -1545,10 +1595,20 @@ interface KTMuiSelectProps {
1545
1595
  fullWidth?: boolean;
1546
1596
  disabled?: boolean;
1547
1597
  }
1598
+ type KTMuiSelect = JSX.Element & {
1599
+ /**
1600
+ * Reactive `value` of the select component
1601
+ */
1602
+ value: string;
1603
+ /**
1604
+ * Reactive `disabled` state of the select component
1605
+ */
1606
+ disabled: boolean;
1607
+ };
1548
1608
  /**
1549
1609
  * Select component - mimics MUI Select appearance and behavior
1550
1610
  */
1551
- declare function Select(props: KTMuiSelectProps): JSX.Element;
1611
+ declare function Select(props: KTMuiSelectProps): KTMuiSelect;
1552
1612
 
1553
1613
  declare function DownloadIcon(props: KTAttribute): JSX.Element;
1554
1614
 
@@ -1594,5 +1654,5 @@ declare function ContentCopyIcon(props: KTAttribute): JSX.Element;
1594
1654
 
1595
1655
  declare function SelectAllIcon(props: KTAttribute): JSX.Element;
1596
1656
 
1597
- 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 };
1657
+ 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 };
1598
1658
  export type { KTMuiDialog, KTMuiLinearProgress, KTMuiRadio, KTMuiRadioGroup, KTMuiRadioProps, KTMuiSelectProps, KTMuiTextField, KTMuiTextFieldProps };