ish-ui 1.0.26 → 1.0.28

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.
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
- declare const _default: React.JSXElementConstructor<Omit<any, "classes"> & (import("@mui/styles").StyledComponentProps<any> | (import("@mui/styles").StyledComponentProps<any> & object))>;
3
- export default _default;
2
+ import { MessageProps } from '../../model/Message';
3
+ declare const Message: ({ opened, text, clearMessage, success, persist }: MessageProps) => React.JSX.Element;
4
+ export default Message;
@@ -4,12 +4,12 @@
4
4
  */
5
5
  import React from 'react';
6
6
  import clsx from 'clsx';
7
- import { withStyles } from '@mui/styles';
8
7
  import Snackbar from '@mui/material/Snackbar';
9
8
  import IconButton from '@mui/material/IconButton';
10
9
  import Alert from '@mui/material/Alert';
11
10
  import CloseIcon from '@mui/icons-material/Close';
12
- const styles = theme => ({
11
+ import { makeAppStyles } from '../../styles';
12
+ const useStyles = makeAppStyles((theme) => ({
13
13
  close: {
14
14
  color: theme.palette.primary.contrastText,
15
15
  width: theme.spacing(4),
@@ -38,54 +38,34 @@ const styles = theme => ({
38
38
  marginRight: theme.spacing(-2),
39
39
  paddingRight: theme.spacing(2)
40
40
  }
41
- });
42
- class Message extends React.Component {
43
- constructor(props) {
44
- super(props);
45
- this.handleClose = () => {
46
- if (!this.state.persist) {
47
- this.props.clearMessage();
48
- }
49
- };
50
- this.state = {
51
- success: props.isSuccess,
52
- text: props.text,
53
- persist: props.persist
54
- };
55
- }
56
- componentDidUpdate(prevProps) {
57
- if (this.props.opened !== prevProps.opened) {
58
- this.setState({
59
- success: this.props.opened ? this.props.isSuccess : this.state.success,
60
- text: this.props.opened ? this.props.text : this.state.text,
61
- persist: this.props.opened ? this.props.persist : this.state.persist
62
- });
41
+ }));
42
+ const Message = ({ opened, text, clearMessage, success, persist }) => {
43
+ const classes = useStyles();
44
+ const handleClose = () => {
45
+ if (!persist && clearMessage) {
46
+ clearMessage();
63
47
  }
64
- }
65
- render() {
66
- const { classes, opened, clearMessage } = this.props;
67
- const { success, text, persist } = this.state;
68
- return (React.createElement(Snackbar, { open: opened, anchorOrigin: {
69
- vertical: 'bottom',
70
- horizontal: 'left'
71
- }, classes: {
72
- root: classes.autoWidthRoot
73
- }, ContentProps: {
74
- classes: {
75
- root: clsx(classes.autoWidth, {
76
- [classes.success]: success
77
- }),
78
- message: persist ? classes.fullScreenMessage : undefined
79
- }
80
- }, ClickAwayListenerProps: {
81
- onClickAway: this.handleClose
82
- }, autoHideDuration: persist ? null : 6000, onClose: this.handleClose, disableWindowBlurListener: persist },
83
- React.createElement(Alert, { variant: "filled", severity: success ? 'success' : 'error', classes: {
84
- message: 'text-pre-wrap',
85
- standardError: 'errorBackgroundColor',
86
- standardSuccess: 'successBackgroundColor'
87
- }, action: (React.createElement(IconButton, { key: "close", "aria-label": "Close", color: "inherit", className: classes.close, onClick: clearMessage },
88
- React.createElement(CloseIcon, null))) }, text)));
89
- }
90
- }
91
- export default withStyles(styles)(Message);
48
+ };
49
+ return (React.createElement(Snackbar, { open: opened, anchorOrigin: {
50
+ vertical: 'bottom',
51
+ horizontal: 'left'
52
+ }, classes: {
53
+ root: classes.autoWidthRoot
54
+ }, ContentProps: {
55
+ classes: {
56
+ root: clsx(classes.autoWidth, {
57
+ [classes.success]: success
58
+ }),
59
+ message: persist ? classes.fullScreenMessage : undefined
60
+ }
61
+ }, ClickAwayListenerProps: {
62
+ onClickAway: handleClose
63
+ }, autoHideDuration: persist ? null : 6000, onClose: handleClose, disableWindowBlurListener: persist },
64
+ React.createElement(Alert, { variant: "filled", severity: success ? 'success' : 'error', classes: {
65
+ message: 'text-pre-wrap',
66
+ standardError: 'errorBackgroundColor',
67
+ standardSuccess: 'successBackgroundColor'
68
+ }, action: (React.createElement(IconButton, { key: "close", "aria-label": "Close", color: "inherit", className: classes.close, onClick: clearMessage },
69
+ React.createElement(CloseIcon, null))) }, text)));
70
+ };
71
+ export default Message;
@@ -208,7 +208,7 @@ function EditInPlaceSearchSelect({ label, disabled, className, labelAdornment, i
208
208
  const getOptionLabel = option => (selectLabelCondition ? selectLabelCondition(option) : option && option[selectLabelMark]) || '';
209
209
  const getOptionSelected = (option, value) => {
210
210
  if (multiple || returnType === 'object') {
211
- return option[selectValueMark] === value[selectValueMark];
211
+ return value && (option[selectValueMark] === value[selectValueMark]);
212
212
  }
213
213
  return option[selectValueMark] === value;
214
214
  };
@@ -0,0 +1,8 @@
1
+ import { AnyArgFunction } from '../model/CommonFunctions';
2
+ export interface MessageProps {
3
+ opened: boolean;
4
+ text: string;
5
+ clearMessage: AnyArgFunction;
6
+ success?: boolean;
7
+ persist?: boolean;
8
+ }
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright ish group pty ltd 2023.
3
+ *
4
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
5
+ *
6
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
7
+ */
8
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ish-ui",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "UI elements for onCourse and other ish apps",
5
5
  "main": "main.ts",
6
6
  "devDependencies": {