@etsoo/materialui 1.0.33 → 1.0.35

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.
@@ -5,7 +5,6 @@ import { INotificationBaseReact, INotificationReact, NotificationReact, Notifier
5
5
  * MU notification
6
6
  */
7
7
  export declare class NotificationMU extends NotificationReact {
8
- private returnValue;
9
8
  private createAlert;
10
9
  private createConfirm;
11
10
  private createMessageColor;
package/lib/NotifierMU.js CHANGED
@@ -23,16 +23,6 @@ const IconDialogTitle = styled(DialogTitle) `
23
23
  * MU notification
24
24
  */
25
25
  export class NotificationMU extends NotificationReact {
26
- // On return
27
- // Dismiss first, then run callback
28
- async returnValue(value) {
29
- if (this.onReturn) {
30
- const result = await this.onReturn(value);
31
- if (result === false)
32
- return;
33
- }
34
- this.dismiss();
35
- }
36
26
  // Create alert
37
27
  createAlert(_props, className) {
38
28
  var _a;
@@ -73,7 +63,7 @@ export class NotificationMU extends NotificationReact {
73
63
  React.createElement(DialogContent, null,
74
64
  React.createElement(DialogContentText, null, this.content),
75
65
  inputs),
76
- React.createElement(DialogActions, null, buttons ? (buttons(callback)) : (React.createElement(LoadingButton, { ...setupProps, onClick: callback, autoFocus: true, ...primaryButton }, okLabel)))));
66
+ React.createElement(DialogActions, null, buttons ? (buttons(this, callback)) : (React.createElement(LoadingButton, { ...setupProps, onClick: callback, autoFocus: true, ...primaryButton }, okLabel)))));
77
67
  }
78
68
  // Create confirm
79
69
  createConfirm(_props, className) {
@@ -89,7 +79,7 @@ export class NotificationMU extends NotificationReact {
89
79
  React.createElement(DialogContent, null,
90
80
  React.createElement(DialogContentText, null, this.content),
91
81
  inputs),
92
- React.createElement(DialogActions, null, buttons ? (buttons(callback)) : (React.createElement(React.Fragment, null,
82
+ React.createElement(DialogActions, null, buttons ? (buttons(this, callback)) : (React.createElement(React.Fragment, null,
93
83
  cancelButton && (React.createElement(LoadingButton, { color: "secondary", onClick: async (event) => await callback(event, false) }, cancelLabel)),
94
84
  React.createElement(LoadingButton, { color: "primary", onClick: async (event) => await callback(event, true), autoFocus: true, ...primaryButton }, okLabel))))));
95
85
  }
@@ -217,7 +207,7 @@ export class NotificationMU extends NotificationReact {
217
207
  React.createElement(DialogContentText, null, this.content),
218
208
  localInputs,
219
209
  React.createElement(Typography, { variant: "caption", display: "block", ref: errorRef, color: (theme) => theme.palette.error.main })),
220
- React.createElement(DialogActions, null, buttons ? (buttons(handleSubmit)) : (React.createElement(React.Fragment, null,
210
+ React.createElement(DialogActions, null, buttons ? (buttons(this, handleSubmit)) : (React.createElement(React.Fragment, null,
221
211
  cancelButton && (React.createElement(Button, { color: "secondary", onClick: () => {
222
212
  if (this.onReturn)
223
213
  this.onReturn(undefined);
@@ -5,7 +5,7 @@ import { SwitchProps } from '@mui/material/Switch';
5
5
  */
6
6
  export interface SwitchAntProps extends SwitchProps {
7
7
  /**
8
- *
8
+ * Active color
9
9
  */
10
10
  activeColor?: string;
11
11
  /**
package/lib/SwitchAnt.js CHANGED
@@ -12,6 +12,8 @@ export function SwitchAnt(props) {
12
12
  const { activeColor, checked, defaultChecked, defaultValue, endLabel, startLabel, onChange, value = 'true', ...rest } = props;
13
13
  // Checked state
14
14
  const [controlChecked, setControlChecked] = React.useState((_a = checked !== null && checked !== void 0 ? checked : defaultChecked) !== null && _a !== void 0 ? _a : defaultValue == value);
15
+ // Ref
16
+ const ref = React.useRef(null);
15
17
  React.useEffect(() => {
16
18
  if (checked)
17
19
  setControlChecked(checked);
@@ -24,14 +26,14 @@ export function SwitchAnt(props) {
24
26
  };
25
27
  // Layout
26
28
  return (React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
27
- React.createElement(Typography, { onClick: () => setControlChecked(false), sx: {
29
+ React.createElement(Typography, { onClick: () => { var _a; return controlChecked && ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.click()); }, sx: {
28
30
  cursor: 'pointer',
29
31
  color: controlChecked
30
32
  ? undefined
31
33
  : (theme) => activeColor !== null && activeColor !== void 0 ? activeColor : theme.palette.warning.main
32
34
  } }, startLabel),
33
- React.createElement(Switch, { checked: controlChecked, value: value, onChange: onChangeLocal, ...rest }),
34
- React.createElement(Typography, { onClick: () => setControlChecked(true), sx: {
35
+ React.createElement(Switch, { checked: controlChecked, ref: ref, value: value, onChange: onChangeLocal, ...rest }),
36
+ React.createElement(Typography, { onClick: () => { var _a; return !controlChecked && ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.click()); }, sx: {
35
37
  cursor: 'pointer',
36
38
  color: controlChecked
37
39
  ? (theme) => activeColor !== null && activeColor !== void 0 ? activeColor : theme.palette.warning.main
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -51,9 +51,9 @@
51
51
  "@emotion/css": "^11.10.0",
52
52
  "@emotion/react": "^11.10.4",
53
53
  "@emotion/styled": "^11.10.4",
54
- "@etsoo/appscript": "^1.2.99",
55
- "@etsoo/notificationbase": "^1.1.10",
56
- "@etsoo/react": "^1.6.9",
54
+ "@etsoo/appscript": "^1.3.0",
55
+ "@etsoo/notificationbase": "^1.1.11",
56
+ "@etsoo/react": "^1.6.10",
57
57
  "@etsoo/shared": "^1.1.58",
58
58
  "@mui/icons-material": "^5.10.6",
59
59
  "@mui/material": "^5.10.7",
@@ -58,16 +58,6 @@ const IconDialogTitle = styled(DialogTitle)`
58
58
  * MU notification
59
59
  */
60
60
  export class NotificationMU extends NotificationReact {
61
- // On return
62
- // Dismiss first, then run callback
63
- private async returnValue(value: any) {
64
- if (this.onReturn) {
65
- const result = await this.onReturn(value);
66
- if (result === false) return;
67
- }
68
- this.dismiss();
69
- }
70
-
71
61
  // Create alert
72
62
  private createAlert(_props: NotificationRenderProps, className: string) {
73
63
  const labels = Labels.NotificationMU;
@@ -132,7 +122,7 @@ export class NotificationMU extends NotificationReact {
132
122
  </DialogContent>
133
123
  <DialogActions>
134
124
  {buttons ? (
135
- buttons(callback)
125
+ buttons(this, callback)
136
126
  ) : (
137
127
  <LoadingButton
138
128
  {...setupProps}
@@ -190,7 +180,7 @@ export class NotificationMU extends NotificationReact {
190
180
  </DialogContent>
191
181
  <DialogActions>
192
182
  {buttons ? (
193
- buttons(callback)
183
+ buttons(this, callback)
194
184
  ) : (
195
185
  <React.Fragment>
196
186
  {cancelButton && (
@@ -414,7 +404,7 @@ export class NotificationMU extends NotificationReact {
414
404
  </DialogContent>
415
405
  <DialogActions>
416
406
  {buttons ? (
417
- buttons(handleSubmit)
407
+ buttons(this, handleSubmit)
418
408
  ) : (
419
409
  <React.Fragment>
420
410
  {cancelButton && (
package/src/SwitchAnt.tsx CHANGED
@@ -7,7 +7,7 @@ import React from 'react';
7
7
  */
8
8
  export interface SwitchAntProps extends SwitchProps {
9
9
  /**
10
- *
10
+ * Active color
11
11
  */
12
12
  activeColor?: string;
13
13
 
@@ -46,6 +46,9 @@ export function SwitchAnt(props: SwitchAntProps) {
46
46
  checked ?? defaultChecked ?? defaultValue == value
47
47
  );
48
48
 
49
+ // Ref
50
+ const ref = React.useRef<HTMLButtonElement>(null);
51
+
49
52
  React.useEffect(() => {
50
53
  if (checked) setControlChecked(checked);
51
54
  }, [checked]);
@@ -63,7 +66,7 @@ export function SwitchAnt(props: SwitchAntProps) {
63
66
  return (
64
67
  <Stack direction="row" spacing={1} alignItems="center">
65
68
  <Typography
66
- onClick={() => setControlChecked(false)}
69
+ onClick={() => controlChecked && ref.current?.click()}
67
70
  sx={{
68
71
  cursor: 'pointer',
69
72
  color: controlChecked
@@ -75,12 +78,13 @@ export function SwitchAnt(props: SwitchAntProps) {
75
78
  </Typography>
76
79
  <Switch
77
80
  checked={controlChecked}
81
+ ref={ref}
78
82
  value={value}
79
83
  onChange={onChangeLocal}
80
84
  {...rest}
81
85
  />
82
86
  <Typography
83
- onClick={() => setControlChecked(true)}
87
+ onClick={() => !controlChecked && ref.current?.click()}
84
88
  sx={{
85
89
  cursor: 'pointer',
86
90
  color: controlChecked