@ktjs/mui 0.18.1 → 0.18.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
@@ -38,20 +38,20 @@ declare function Button(props: ButtonProps): KTHTMLElement;
38
38
 
39
39
  interface CheckboxProps {
40
40
  value: string;
41
- label?: string | KTHTMLElement | HTMLElement;
41
+ label?: string | KTHTMLElement$1 | HTMLElement;
42
42
  checked?: boolean;
43
43
  size?: 'small' | 'medium';
44
- 'kt:change'?: (checked: boolean, value: string) => void;
44
+ 'kt:change'?: ((checked: boolean, value: string) => void) | KTRef<boolean>;
45
45
  disabled?: boolean;
46
46
  color?: 'primary' | 'secondary' | 'default' | 'success' | 'error' | 'warning';
47
47
  indeterminate?: boolean;
48
48
  }
49
- type KTMuiCheckbox = KTHTMLElement & {
49
+ type KTMuiCheckbox = KTHTMLElement$1 & {
50
50
  checked: boolean;
51
51
  value: string;
52
52
  disabled: boolean;
53
53
  };
54
- type KTMuiCheckboxGroup = KTHTMLElement & {
54
+ type KTMuiCheckboxGroup = KTHTMLElement$1 & {
55
55
  value: string[];
56
56
  disabled: boolean[];
57
57
  disableAll: () => void;
@@ -67,7 +67,7 @@ interface CheckboxGroupProps {
67
67
  value?: string[];
68
68
  size?: 'small' | 'medium';
69
69
  options: CheckboxProps[];
70
- 'kt:change'?: (values: string[]) => void;
70
+ 'kt:change'?: ((values: string[]) => void) | KTRef<string[]>;
71
71
  row?: boolean;
72
72
  }
73
73
  /**
@@ -127,7 +127,7 @@ type KTMuiLinearProgress = KTHTMLElement$1 & {
127
127
  */
128
128
  declare function LinearProgress(props: LinearProgressProps): KTMuiLinearProgress;
129
129
 
130
- type ChangeHandler<T = string> = (value: T) => void;
130
+ type ChangeHandler<T = string> = (value: T, ...args: any[]) => void;
131
131
 
132
132
  interface TextFieldProps {
133
133
  class?: string;
@@ -44,7 +44,7 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
44
44
  return alert;
45
45
  }
46
46
 
47
- const emptyFn$3 = () => { };
47
+ const emptyFn$2 = () => { };
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$3;
56
+ return emptyFn$2;
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$3, } = props;
63
+ const { children, variant = 'text', color = 'primary', size = 'medium', disabled = false, fullWidth = false, iconOnly = false, startIcon, endIcon, type = 'button', 'on:click': onClick = emptyFn$2, } = props;
64
64
  const classes = [
65
65
  'mui-button',
66
66
  `mui-button-${variant}`,
@@ -102,7 +102,6 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
102
102
  return (jsxRuntime.jsxs("button", { class: classes, style: props.style ? 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
103
  }
104
104
 
105
- const emptyFn$2 = () => { };
106
105
  /**
107
106
  * Checkbox component - mimics MUI Checkbox appearance and behavior
108
107
  */
@@ -129,7 +128,8 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
129
128
  toggleIcon(checked, indeterminate);
130
129
  onChange(checked, value);
131
130
  };
132
- let { checked = false, value = '', label = '', size = 'medium', 'kt:change': onChange = emptyFn$2, disabled = false, color = 'primary', indeterminate = false, } = props;
131
+ let { checked = false, value = '', label = '', size = 'medium', disabled = false, color = 'primary', indeterminate = false, } = props;
132
+ const onChange = generateHandler(props, 'kt:change');
133
133
  const inputEl = (jsxRuntime.jsx("input", { type: "checkbox", class: "mui-checkbox-input", checked: checked, value: value, disabled: disabled, "on:change": handleChange }));
134
134
  // Unchecked icon
135
135
  const uncheckedIcon = (jsxRuntime.jsx("span", { class: "mui-checkbox-icon-unchecked", children: jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", children: jsxRuntime.jsx("path", { d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" }) }) }));
@@ -193,7 +193,7 @@ var __ktjs_mui__ = (function (exports, jsxRuntime, kt_js) {
193
193
  const checkboxes = props.options.map((o) => {
194
194
  o.size = size;
195
195
  o.checked = selectedValues.has(o.value);
196
- const originalChange = o['kt:change'];
196
+ const originalChange = generateHandler(o, 'kt:change');
197
197
  if (originalChange) {
198
198
  o['kt:change'] = (checked, value) => {
199
199
  originalChange(checked, value);
package/dist/index.mjs CHANGED
@@ -44,7 +44,7 @@ function Alert(props) {
44
44
  return alert;
45
45
  }
46
46
 
47
- const emptyFn$3 = () => { };
47
+ const emptyFn$2 = () => { };
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$3;
56
+ return emptyFn$2;
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$3, } = props;
63
+ const { children, variant = 'text', color = 'primary', size = 'medium', disabled = false, fullWidth = false, iconOnly = false, startIcon, endIcon, type = 'button', 'on:click': onClick = emptyFn$2, } = props;
64
64
  const classes = [
65
65
  'mui-button',
66
66
  `mui-button-${variant}`,
@@ -102,7 +102,6 @@ function Button(props) {
102
102
  return (jsxs("button", { class: classes, style: props.style ? 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
103
  }
104
104
 
105
- const emptyFn$2 = () => { };
106
105
  /**
107
106
  * Checkbox component - mimics MUI Checkbox appearance and behavior
108
107
  */
@@ -129,7 +128,8 @@ function Checkbox(props) {
129
128
  toggleIcon(checked, indeterminate);
130
129
  onChange(checked, value);
131
130
  };
132
- let { checked = false, value = '', label = '', size = 'medium', 'kt:change': onChange = emptyFn$2, disabled = false, color = 'primary', indeterminate = false, } = props;
131
+ let { checked = false, value = '', label = '', size = 'medium', disabled = false, color = 'primary', indeterminate = false, } = props;
132
+ const onChange = generateHandler(props, 'kt:change');
133
133
  const inputEl = (jsx("input", { type: "checkbox", class: "mui-checkbox-input", checked: checked, value: value, disabled: disabled, "on:change": handleChange }));
134
134
  // Unchecked icon
135
135
  const uncheckedIcon = (jsx("span", { class: "mui-checkbox-icon-unchecked", children: jsx("svg", { viewBox: "0 0 24 24", children: jsx("path", { d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" }) }) }));
@@ -193,7 +193,7 @@ function CheckboxGroup(props) {
193
193
  const checkboxes = props.options.map((o) => {
194
194
  o.size = size;
195
195
  o.checked = selectedValues.has(o.value);
196
- const originalChange = o['kt:change'];
196
+ const originalChange = generateHandler(o, 'kt:change');
197
197
  if (originalChange) {
198
198
  o['kt:change'] = (checked, value) => {
199
199
  originalChange(checked, value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/mui",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
4
4
  "description": "Material-UI inspired components for kt.js - pre-styled UI components",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",