@etsoo/materialui 1.1.39 → 1.1.42

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.
Files changed (42) hide show
  1. package/lib/AuditDisplay.d.ts +5 -5
  2. package/lib/AuditDisplay.js +17 -19
  3. package/lib/BridgeCloseButton.d.ts +2 -2
  4. package/lib/BridgeCloseButton.js +7 -8
  5. package/lib/DataSteps.d.ts +4 -4
  6. package/lib/DataSteps.js +17 -14
  7. package/lib/DataTable.d.ts +33 -0
  8. package/lib/DataTable.js +56 -0
  9. package/lib/ListMoreDisplay.d.ts +5 -5
  10. package/lib/ListMoreDisplay.js +8 -10
  11. package/lib/OptionBool.js +2 -1
  12. package/lib/SelectBool.js +2 -1
  13. package/lib/ShowDataComparison.d.ts +1 -1
  14. package/lib/ShowDataComparison.js +27 -20
  15. package/lib/SwitchAnt.d.ts +3 -3
  16. package/lib/SwitchAnt.js +11 -8
  17. package/lib/SwitchField.d.ts +45 -0
  18. package/lib/SwitchField.js +33 -0
  19. package/lib/Tiplist.js +4 -4
  20. package/lib/UserAvatar.js +7 -8
  21. package/lib/app/ReactApp.d.ts +7 -7
  22. package/lib/app/ReactApp.js +26 -26
  23. package/lib/index.d.ts +2 -0
  24. package/lib/index.js +2 -0
  25. package/lib/pages/ViewPage.d.ts +7 -7
  26. package/lib/pages/ViewPage.js +30 -29
  27. package/package.json +3 -2
  28. package/src/AuditDisplay.tsx +92 -99
  29. package/src/BridgeCloseButton.tsx +48 -50
  30. package/src/DataSteps.tsx +188 -185
  31. package/src/DataTable.tsx +124 -0
  32. package/src/ListMoreDisplay.tsx +184 -188
  33. package/src/OptionBool.tsx +1 -1
  34. package/src/SelectBool.tsx +1 -1
  35. package/src/ShowDataComparison.tsx +88 -76
  36. package/src/SwitchAnt.tsx +82 -78
  37. package/src/SwitchField.tsx +133 -0
  38. package/src/Tiplist.tsx +5 -4
  39. package/src/UserAvatar.tsx +43 -45
  40. package/src/app/ReactApp.ts +485 -489
  41. package/src/index.ts +2 -0
  42. package/src/pages/ViewPage.tsx +272 -277
@@ -1,11 +1,11 @@
1
- import { AuditLineDto } from '@etsoo/appscript';
2
- import { Theme } from '@mui/material';
3
- import React, { CSSProperties } from 'react';
4
- import { ListMoreDisplayProps } from './ListMoreDisplay';
1
+ import { AuditLineDto } from "@etsoo/appscript";
2
+ import { Theme } from "@mui/material";
3
+ import React, { CSSProperties } from "react";
4
+ import { ListMoreDisplayProps } from "./ListMoreDisplay";
5
5
  /**
6
6
  * Audit display props
7
7
  */
8
- export interface AuditDisplayProps extends Omit<ListMoreDisplayProps<AuditLineDto>, 'children'> {
8
+ export interface AuditDisplayProps extends Omit<ListMoreDisplayProps<AuditLineDto>, "children"> {
9
9
  /**
10
10
  * Get list item style callback
11
11
  */
@@ -1,19 +1,19 @@
1
- import { Utils } from '@etsoo/shared';
2
- import { Button, Divider, Typography, useTheme } from '@mui/material';
3
- import React from 'react';
4
- import { globalApp } from './app/ReactApp';
5
- import { ListMoreDisplay } from './ListMoreDisplay';
6
- import { ShowDataComparison } from './ShowDataComparison';
1
+ import { Utils } from "@etsoo/shared";
2
+ import { Button, Divider, Typography, useTheme } from "@mui/material";
3
+ import React from "react";
4
+ import { globalApp } from "./app/ReactApp";
5
+ import { ListMoreDisplay } from "./ListMoreDisplay";
6
+ import { ShowDataComparison } from "./ShowDataComparison";
7
7
  // Get label
8
8
  const getLabel = (key) => {
9
9
  var _a;
10
- return (_a = globalApp.get(Utils.formatInitial(key))) !== null && _a !== void 0 ? _a : key;
10
+ return (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get(Utils.formatInitial(key))) !== null && _a !== void 0 ? _a : key;
11
11
  };
12
12
  // Format date
13
13
  const formatDate = (date) => {
14
- if (typeof globalApp === 'undefined')
15
- return date.toUTCString();
16
- return globalApp.formatDate(date, 'ds');
14
+ if (globalApp)
15
+ return globalApp.formatDate(date, "ds");
16
+ return date.toUTCString();
17
17
  };
18
18
  /**
19
19
  * Audit display
@@ -24,28 +24,26 @@ export function AuditDisplay(props) {
24
24
  // Theme
25
25
  const theme = useTheme();
26
26
  // Title
27
- var title = getLabel('dataComparison');
27
+ var title = getLabel("dataComparison");
28
28
  // Destruct
29
29
  const { getItemStyle = (index, theme) => ({
30
- padding: [theme.spacing(1.5), theme.spacing(1)].join(' '),
31
- background: index % 2 === 0
32
- ? theme.palette.grey[100]
33
- : theme.palette.grey[50]
30
+ padding: [theme.spacing(1.5), theme.spacing(1)].join(" "),
31
+ background: index % 2 === 0 ? theme.palette.grey[100] : theme.palette.grey[50]
34
32
  }), getColumnLabel, equalCheck, itemRenderer = (data) => {
35
33
  const { newData, oldData, changes = { newData: newData !== null && newData !== void 0 ? newData : {}, oldData: oldData !== null && oldData !== void 0 ? oldData : {} } } = data;
36
34
  return (React.createElement(React.Fragment, null,
37
35
  changes != null && (React.createElement(Button, { variant: "outlined", size: "small", onClick: () => ShowDataComparison(changes, title, getColumnLabel, equalCheck), sx: {
38
36
  marginLeft: theme.spacing(1),
39
37
  marginTop: theme.spacing(-0.5),
40
- float: 'right'
38
+ float: "right"
41
39
  } }, title)),
42
40
  React.createElement(Typography, null, formatDate(data.creation) +
43
- ', [' +
41
+ ", [" +
44
42
  getLabel(data.action) +
45
- '], ' +
43
+ "], " +
46
44
  data.user)));
47
45
  }, headerTitle = (React.createElement(React.Fragment, null,
48
- React.createElement(Typography, null, getLabel('audits')),
46
+ React.createElement(Typography, null, getLabel("audits")),
49
47
  React.createElement(Divider, null))), ...rest } = props;
50
48
  // Layout
51
49
  return (React.createElement(ListMoreDisplay, { headerTitle: headerTitle, ...rest }, (data, index) => (React.createElement("div", { key: data.id, style: getItemStyle(index, theme) }, itemRenderer(data, index)))));
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { IBridgeHost } from '@etsoo/appscript';
3
- import { BoxProps, IconButtonProps } from '@mui/material';
2
+ import { IBridgeHost } from "@etsoo/appscript";
3
+ import { BoxProps, IconButtonProps } from "@mui/material";
4
4
  /**
5
5
  * Bridge close button props
6
6
  */
@@ -1,18 +1,17 @@
1
- import { BridgeUtils } from '@etsoo/appscript';
2
- import CloseIcon from '@mui/icons-material/Close';
3
- import { Box, IconButton } from '@mui/material';
4
- import React from 'react';
5
- import { globalApp } from './app/ReactApp';
1
+ import { BridgeUtils } from "@etsoo/appscript";
2
+ import CloseIcon from "@mui/icons-material/Close";
3
+ import { Box, IconButton } from "@mui/material";
4
+ import React from "react";
5
+ import { globalApp } from "./app/ReactApp";
6
6
  /**
7
7
  * Bridge close button
8
8
  * @param props Props
9
9
  * @returns Component
10
10
  */
11
11
  export function BridgeCloseButton(props) {
12
+ var _a;
12
13
  // Destruct
13
- const { boxProps, onClick, title = typeof globalApp === 'undefined'
14
- ? 'Close'
15
- : globalApp.get('close'), validate, ...rest } = props;
14
+ const { boxProps, onClick, title = (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get("close")) !== null && _a !== void 0 ? _a : "Close", validate, ...rest } = props;
16
15
  // Host
17
16
  const host = BridgeUtils.host;
18
17
  if (host == null ||
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { TextFieldProps } from '@mui/material';
3
- import { InputDialogProps } from '@etsoo/react';
2
+ import { TextFieldProps } from "@mui/material";
3
+ import { InputDialogProps } from "@etsoo/react";
4
4
  /**
5
5
  * Data step
6
6
  */
7
- export type DataStep = Omit<InputDialogProps, 'callback'> & {
7
+ export type DataStep = Omit<InputDialogProps, "callback"> & {
8
8
  /**
9
9
  * Callback
10
10
  */
@@ -13,7 +13,7 @@ export type DataStep = Omit<InputDialogProps, 'callback'> & {
13
13
  /**
14
14
  * Data collecting steps component props
15
15
  */
16
- export type DataStepsProps<T extends object> = Omit<TextFieldProps, 'InputProps' | 'onClick'> & {
16
+ export type DataStepsProps<T extends object> = Omit<TextFieldProps, "InputProps" | "onClick"> & {
17
17
  /**
18
18
  * JSON value
19
19
  */
package/lib/DataSteps.js CHANGED
@@ -1,13 +1,13 @@
1
- import { Button, IconButton, InputAdornment, TextField } from '@mui/material';
2
- import CloseIcon from '@mui/icons-material/Close';
3
- import NavigateNextIcon from '@mui/icons-material/NavigateNext';
4
- import NavigateBeforeIcon from '@mui/icons-material/NavigateBefore';
5
- import CheckIcon from '@mui/icons-material/Check';
6
- import StartIcon from '@mui/icons-material/Start';
7
- import React from 'react';
8
- import { HBox } from './FlexBox';
9
- import { globalApp } from './app/ReactApp';
10
- import { MUGlobal } from './MUGlobal';
1
+ import { Button, IconButton, InputAdornment, TextField } from "@mui/material";
2
+ import CloseIcon from "@mui/icons-material/Close";
3
+ import NavigateNextIcon from "@mui/icons-material/NavigateNext";
4
+ import NavigateBeforeIcon from "@mui/icons-material/NavigateBefore";
5
+ import CheckIcon from "@mui/icons-material/Check";
6
+ import StartIcon from "@mui/icons-material/Start";
7
+ import React from "react";
8
+ import { HBox } from "./FlexBox";
9
+ import { globalApp } from "./app/ReactApp";
10
+ import { MUGlobal } from "./MUGlobal";
11
11
  /**
12
12
  * Data collecting steps component
13
13
  * @param props Props
@@ -17,10 +17,13 @@ export function DataSteps(props) {
17
17
  var _a;
18
18
  // App
19
19
  const app = globalApp;
20
+ if (app == null) {
21
+ throw new Error("No globalApp");
22
+ }
20
23
  // Labels
21
- const labels = app.getLabels('close', 'nextStep', 'previousStep', 'submit');
24
+ const labels = app.getLabels("close", "nextStep", "previousStep", "submit");
22
25
  // Destruct
23
- const { InputLabelProps = {}, jsonValue, valueFormatter = (_data) => '...', onValueChange, steps, value = '', ...rest } = props;
26
+ const { InputLabelProps = {}, jsonValue, valueFormatter = (_data) => "...", onValueChange, steps, value = "", ...rest } = props;
24
27
  // Shrink
25
28
  (_a = InputLabelProps.shrink) !== null && _a !== void 0 ? _a : (InputLabelProps.shrink = MUGlobal.searchFieldShrink);
26
29
  // Current index
@@ -74,9 +77,9 @@ export function DataSteps(props) {
74
77
  React.useEffect(() => {
75
78
  setLocalValue(valueFormatter(jsonRef.current));
76
79
  }, [valueFormatter]);
77
- return (React.createElement(TextField, { autoComplete: "new-password", InputLabelProps: InputLabelProps, inputProps: { style: { cursor: 'pointer' } }, InputProps: {
80
+ return (React.createElement(TextField, { autoComplete: "new-password", InputLabelProps: InputLabelProps, inputProps: { style: { cursor: "pointer" } }, InputProps: {
78
81
  onKeyDown: (event) => {
79
- if (event.key === 'Tab')
82
+ if (event.key === "Tab")
80
83
  return;
81
84
  cancelInput(event);
82
85
  },
@@ -0,0 +1,33 @@
1
+ import { GridCellModesModel, GridRowId, GridValidRowModel } from "@mui/x-data-grid";
2
+ import { DataGridProps } from "@mui/x-data-grid/models/props/DataGridProps";
3
+ import React from "react";
4
+ /**
5
+ * Data table selected cell params
6
+ */
7
+ export interface DataTableSelectedCellParams {
8
+ id: GridRowId;
9
+ field: string;
10
+ index: number;
11
+ }
12
+ /**
13
+ * Data table props
14
+ */
15
+ export type DataTableProps<R extends GridValidRowModel = any> = Omit<DataGridProps<R>, "disableColumnMenu"> & {
16
+ /**
17
+ * Cell selection handler
18
+ * @param params Params
19
+ * @returns Result
20
+ */
21
+ onCellSelection?: (params: DataTableSelectedCellParams) => void | false;
22
+ /**
23
+ * Toolbar creator
24
+ * @returns Toolbar
25
+ */
26
+ toolbarCreator?: (selectedCellParams: DataTableSelectedCellParams | null, setCellModesModel: React.Dispatch<React.SetStateAction<GridCellModesModel>>, cellModesModel: GridCellModesModel) => React.ReactElement;
27
+ };
28
+ /**
29
+ * Data table
30
+ * @param props Props
31
+ * @returns Component
32
+ */
33
+ export declare function DataTable<R extends GridValidRowModel = any>(props: DataTableProps<R>): JSX.Element;
@@ -0,0 +1,56 @@
1
+ import { DataGrid } from "@mui/x-data-grid";
2
+ import React from "react";
3
+ import { globalApp } from "./app/ReactApp";
4
+ /**
5
+ * Data table
6
+ * @param props Props
7
+ * @returns Component
8
+ */
9
+ export function DataTable(props) {
10
+ var _a;
11
+ // Destructor
12
+ const { localeText = {}, onCellSelection, toolbarCreator, ...rest } = props;
13
+ // Labels
14
+ const { noRows } = (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.getLabels("noRows")) !== null && _a !== void 0 ? _a : {};
15
+ if (noRows && !localeText.noRowsLabel)
16
+ localeText.noRowsLabel = noRows;
17
+ const [selectedCellParams, setSelectedCellParams] = React.useState(null);
18
+ const [cellModesModel, setCellModesModel] = React.useState({});
19
+ const handleCellFocus = React.useCallback((event) => {
20
+ // event.target is the element that triggered the event
21
+ // event.currentTarget is the element that the event listener is attached to
22
+ const cell = event.currentTarget;
23
+ const row = cell.parentElement;
24
+ if (row == null)
25
+ return;
26
+ const id = row.dataset.id;
27
+ const index = row.dataset.rowindex;
28
+ const field = cell.dataset.field;
29
+ if (id == null || index == null || field == null)
30
+ return;
31
+ const params = {
32
+ id,
33
+ field,
34
+ index: parseInt(index)
35
+ };
36
+ if (onCellSelection) {
37
+ if (onCellSelection(params) === false)
38
+ return;
39
+ }
40
+ setSelectedCellParams(params);
41
+ }, []);
42
+ return (React.createElement(DataGrid, { disableColumnMenu: true, hideFooter: true, localeText: localeText, cellModesModel: cellModesModel, onCellModesModelChange: (model) => setCellModesModel(model), components: {
43
+ Toolbar: toolbarCreator
44
+ ? ({ selectedCellParams, setCellModesModel, cellModesModel }) => toolbarCreator(selectedCellParams, setCellModesModel, cellModesModel)
45
+ : undefined
46
+ }, componentsProps: {
47
+ toolbar: {
48
+ selectedCellParams,
49
+ setCellModesModel,
50
+ cellModesModel
51
+ },
52
+ cell: {
53
+ onFocus: handleCellFocus
54
+ }
55
+ }, ...rest }));
56
+ }
@@ -1,11 +1,11 @@
1
- import { DataTypes } from '@etsoo/shared';
2
- import { CardProps } from '@mui/material';
3
- import React from 'react';
4
- import { GridData, GridLoader } from '@etsoo/react';
1
+ import { DataTypes } from "@etsoo/shared";
2
+ import { CardProps } from "@mui/material";
3
+ import React from "react";
4
+ import { GridData, GridLoader } from "@etsoo/react";
5
5
  /**
6
6
  * ListMoreDisplay props
7
7
  */
8
- export interface ListMoreDisplayProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> extends Omit<CardProps, 'children'>, GridLoader<T> {
8
+ export interface ListMoreDisplayProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> extends Omit<CardProps, "children">, GridLoader<T> {
9
9
  /**
10
10
  * Batch size to load
11
11
  */
@@ -1,8 +1,8 @@
1
- import { Card, CardActions, CardContent, CardHeader, CircularProgress } from '@mui/material';
2
- import React from 'react';
3
- import { GridDataGet } from '@etsoo/react';
4
- import { LoadingButton } from './LoadingButton';
5
- import { globalApp } from './app/ReactApp';
1
+ import { Card, CardActions, CardContent, CardHeader, CircularProgress } from "@mui/material";
2
+ import React from "react";
3
+ import { GridDataGet } from "@etsoo/react";
4
+ import { LoadingButton } from "./LoadingButton";
5
+ import { globalApp } from "./app/ReactApp";
6
6
  /**
7
7
  * ListMoreDisplay
8
8
  * @param props Props
@@ -10,9 +10,7 @@ import { globalApp } from './app/ReactApp';
10
10
  */
11
11
  export function ListMoreDisplay(props) {
12
12
  // Destruct
13
- const { batchSize = 6, children, defaultOrderBy, headerRenderer, autoLoad = headerRenderer == null, headerTitle, loadBatchSize, loadData, moreLabel = typeof globalApp === 'undefined'
14
- ? undefined
15
- : globalApp.get('more') + '...', fieldTemplate, threshold, ...rest } = props;
13
+ const { batchSize = 6, children, defaultOrderBy, headerRenderer, autoLoad = headerRenderer == null, headerTitle, loadBatchSize, loadData, moreLabel = globalApp ? globalApp.get("more") + "..." : undefined, fieldTemplate, threshold, ...rest } = props;
16
14
  // Refs
17
15
  const refs = React.useRef({
18
16
  autoLoad,
@@ -95,8 +93,8 @@ export function ListMoreDisplay(props) {
95
93
  React.createElement(CardHeader, { title: headerTitle }),
96
94
  React.createElement(CardContent, { sx: {
97
95
  paddingTop: 0,
98
- paddingBottom: states.completed ? 0 : 'inherit'
96
+ paddingBottom: states.completed ? 0 : "inherit"
99
97
  } }, states.items == null ? (React.createElement(CircularProgress, { size: 20 })) : (states.items.map((item, index) => children(item, index)))),
100
- !states.completed && (React.createElement(CardActions, { sx: { justifyContent: 'flex-end' } },
98
+ !states.completed && (React.createElement(CardActions, { sx: { justifyContent: "flex-end" } },
101
99
  React.createElement(LoadingButton, { onClick: async () => await loadDataLocal() }, moreLabel))))));
102
100
  }
package/lib/OptionBool.js CHANGED
@@ -7,8 +7,9 @@ import { OptionGroup } from "./OptionGroup";
7
7
  * @returns Component
8
8
  */
9
9
  export function OptionBool(props) {
10
+ var _a;
10
11
  // Options
11
- const options = globalApp.getBools();
12
+ const options = (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.getBools()) !== null && _a !== void 0 ? _a : [];
12
13
  // Layout
13
14
  return (React.createElement(OptionGroup, { options: options, row: true, multiple: false, ...props }));
14
15
  }
package/lib/SelectBool.js CHANGED
@@ -8,10 +8,11 @@ import { SelectEx } from "./SelectEx";
8
8
  * @returns Component
9
9
  */
10
10
  export function SelectBool(props) {
11
+ var _a;
11
12
  // Destruct
12
13
  const { search = true, autoAddBlankItem = search, ...rest } = props;
13
14
  // Options
14
- const options = globalApp.getBools();
15
+ const options = (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.getBools()) !== null && _a !== void 0 ? _a : [];
15
16
  if (autoAddBlankItem)
16
17
  Utils.addBlankItem(options);
17
18
  // Layout
@@ -1,4 +1,4 @@
1
- import { AuditLineChangesDto } from '@etsoo/appscript';
1
+ import { AuditLineChangesDto } from "@etsoo/appscript";
2
2
  /**
3
3
  * Check obj is instance of AuditLineChangesDto
4
4
  * @param obj Input
@@ -1,26 +1,26 @@
1
- import { NotificationMessageType } from '@etsoo/notificationbase';
2
- import { Utils } from '@etsoo/shared';
3
- import { Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material';
4
- import React from 'react';
5
- import { globalApp } from './app/ReactApp';
1
+ import { NotificationMessageType } from "@etsoo/notificationbase";
2
+ import { Utils } from "@etsoo/shared";
3
+ import { Table, TableBody, TableCell, TableHead, TableRow } from "@mui/material";
4
+ import React from "react";
5
+ import { globalApp } from "./app/ReactApp";
6
6
  /**
7
7
  * Check obj is instance of AuditLineChangesDto
8
8
  * @param obj Input
9
9
  * @returns Result
10
10
  */
11
11
  export function IsAuditLineUpdateData(obj) {
12
- return (typeof obj === 'object' &&
13
- 'oldData' in obj &&
14
- typeof obj.oldData === 'object' &&
15
- 'newData' in obj &&
16
- typeof obj.newData === 'object');
12
+ return (typeof obj === "object" &&
13
+ "oldData" in obj &&
14
+ typeof obj.oldData === "object" &&
15
+ "newData" in obj &&
16
+ typeof obj.newData === "object");
17
17
  }
18
18
  // Format value
19
19
  const formatValue = (value, app) => {
20
20
  if (value == null)
21
- return '';
21
+ return "";
22
22
  if (value instanceof Date)
23
- return app.formatDate(value, 'ds');
23
+ return app.formatDate(value, "ds");
24
24
  return `${value}`;
25
25
  };
26
26
  /**
@@ -31,10 +31,17 @@ const formatValue = (value, app) => {
31
31
  * @param equalCheck Equal check for properties
32
32
  */
33
33
  export const ShowDataComparison = (data, modelTitle, getLabel, equalCheck = true) => {
34
- modelTitle !== null && modelTitle !== void 0 ? modelTitle : (modelTitle = globalApp.get('dataComparison'));
34
+ // Validate app
35
+ const app = globalApp;
36
+ if (app == null) {
37
+ throw new Error("No globalApp");
38
+ }
39
+ // Labels
40
+ const { dataComparison, field, newValue, oldValue } = app.getLabels("dataComparison", "field", "newValue", "oldValue");
41
+ modelTitle !== null && modelTitle !== void 0 ? modelTitle : (modelTitle = dataComparison);
35
42
  getLabel !== null && getLabel !== void 0 ? getLabel : (getLabel = (key) => {
36
43
  var _a;
37
- return (_a = globalApp.get(Utils.formatInitial(key))) !== null && _a !== void 0 ? _a : key;
44
+ return (_a = app.get(Utils.formatInitial(key))) !== null && _a !== void 0 ? _a : key;
38
45
  });
39
46
  const keys = new Set([
40
47
  ...Object.keys(data.oldData),
@@ -50,12 +57,12 @@ export const ShowDataComparison = (data, modelTitle, getLabel, equalCheck = true
50
57
  const inputs = (React.createElement(Table, null,
51
58
  React.createElement(TableHead, null,
52
59
  React.createElement(TableRow, null,
53
- React.createElement(TableCell, { width: "18%" }, globalApp.get('field')),
54
- React.createElement(TableCell, { width: "41%", align: "right" }, globalApp.get('oldValue')),
55
- React.createElement(TableCell, { width: "41%", align: "right" }, globalApp.get('newValue')))),
60
+ React.createElement(TableCell, { width: "18%" }, field),
61
+ React.createElement(TableCell, { width: "41%", align: "right" }, oldValue),
62
+ React.createElement(TableCell, { width: "41%", align: "right" }, newValue))),
56
63
  React.createElement(TableBody, null, rows.map((row) => (React.createElement(TableRow, { key: row.field },
57
64
  React.createElement(TableCell, null, getLabel(row.field)),
58
- React.createElement(TableCell, { align: "right" }, formatValue(row.oldValue, globalApp)),
59
- React.createElement(TableCell, { align: "right" }, formatValue(row.newValue, globalApp))))))));
60
- globalApp.notifier.alert([undefined, modelTitle], undefined, NotificationMessageType.Info, { fullScreen: globalApp.smDown, inputs });
65
+ React.createElement(TableCell, { align: "right" }, formatValue(row.oldValue, app)),
66
+ React.createElement(TableCell, { align: "right" }, formatValue(row.newValue, app))))))));
67
+ app.notifier.alert([undefined, modelTitle], undefined, NotificationMessageType.Info, { fullScreen: app.smDown, inputs });
61
68
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { SwitchProps } from '@mui/material/Switch';
2
+ import { SwitchProps } from "@mui/material/Switch";
3
3
  /**
4
4
  * Ant style switch props
5
5
  */
@@ -11,11 +11,11 @@ export interface SwitchAntProps extends SwitchProps {
11
11
  /**
12
12
  * Start label
13
13
  */
14
- startLabel: string;
14
+ startLabel?: string;
15
15
  /**
16
16
  * End label
17
17
  */
18
- endLabel: string;
18
+ endLabel?: string;
19
19
  }
20
20
  /**
21
21
  * Ant style switch
package/lib/SwitchAnt.js CHANGED
@@ -1,17 +1,20 @@
1
- import { Stack, Typography } from '@mui/material';
2
- import Switch from '@mui/material/Switch';
3
- import React from 'react';
1
+ import { Stack, Typography } from "@mui/material";
2
+ import Switch from "@mui/material/Switch";
3
+ import React from "react";
4
+ import { globalApp } from "./app/ReactApp";
4
5
  /**
5
6
  * Ant style switch
6
7
  * @param props Props
7
8
  * @returns Component
8
9
  */
9
10
  export function SwitchAnt(props) {
10
- var _a;
11
+ var _a, _b;
12
+ // Labels
13
+ const { yes = "Yes", no = "No" } = (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.getLabels("yes", "no")) !== null && _a !== void 0 ? _a : {};
11
14
  // Destruct
12
- const { activeColor, checked, defaultChecked, defaultValue, endLabel, startLabel, onChange, value = 'true', ...rest } = props;
15
+ const { activeColor, checked, defaultChecked, defaultValue, endLabel = yes, startLabel = no, onChange, value = "true", ...rest } = props;
13
16
  // Checked state
14
- const [controlChecked, setControlChecked] = React.useState((_a = checked !== null && checked !== void 0 ? checked : defaultChecked) !== null && _a !== void 0 ? _a : defaultValue == value);
17
+ const [controlChecked, setControlChecked] = React.useState((_b = checked !== null && checked !== void 0 ? checked : defaultChecked) !== null && _b !== void 0 ? _b : defaultValue == value);
15
18
  // Ref
16
19
  const ref = React.useRef(null);
17
20
  React.useEffect(() => {
@@ -27,14 +30,14 @@ export function SwitchAnt(props) {
27
30
  // Layout
28
31
  return (React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
29
32
  React.createElement(Typography, { onClick: () => { var _a; return controlChecked && ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.click()); }, sx: {
30
- cursor: 'pointer',
33
+ cursor: "pointer",
31
34
  color: controlChecked
32
35
  ? undefined
33
36
  : (theme) => activeColor !== null && activeColor !== void 0 ? activeColor : theme.palette.warning.main
34
37
  } }, startLabel),
35
38
  React.createElement(Switch, { checked: controlChecked, inputRef: ref, value: value, onChange: onChangeLocal, ...rest }),
36
39
  React.createElement(Typography, { onClick: () => { var _a; return !controlChecked && ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.click()); }, sx: {
37
- cursor: 'pointer',
40
+ cursor: "pointer",
38
41
  color: controlChecked
39
42
  ? (theme) => activeColor !== null && activeColor !== void 0 ? activeColor : theme.palette.warning.main
40
43
  : undefined
@@ -0,0 +1,45 @@
1
+ import { FormControlProps } from "@mui/material";
2
+ import React from "react";
3
+ /**
4
+ * SwitchField props
5
+ */
6
+ export type SwitchFieldProps = Omit<FormControlProps<"fieldset">, "defaultValue"> & {
7
+ /**
8
+ * Helper text
9
+ */
10
+ helperText?: React.ReactNode;
11
+ /**
12
+ * Label
13
+ */
14
+ label?: string;
15
+ /**
16
+ * Checked
17
+ */
18
+ checked?: boolean;
19
+ /**
20
+ * Active color
21
+ */
22
+ activeColor?: string;
23
+ /**
24
+ * Start label
25
+ */
26
+ startLabel?: string;
27
+ /**
28
+ * End label
29
+ */
30
+ endLabel?: string;
31
+ /**
32
+ * Height in px
33
+ */
34
+ height?: number;
35
+ /**
36
+ * Value, default is true
37
+ */
38
+ value?: unknown;
39
+ };
40
+ /**
41
+ * SwitchField
42
+ * @param props Props
43
+ * @returns Component
44
+ */
45
+ export declare function SwitchField(props: SwitchFieldProps): JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { Box, FormControl, FormHelperText, InputLabel } from "@mui/material";
2
+ import NotchedOutline from "@mui/material/OutlinedInput";
3
+ import React from "react";
4
+ import { SwitchAnt } from "./SwitchAnt";
5
+ /**
6
+ * SwitchField
7
+ * @param props Props
8
+ * @returns Component
9
+ */
10
+ export function SwitchField(props) {
11
+ // Destruct
12
+ const { activeColor, startLabel, endLabel, value = true, fullWidth, height = 56, helperText, label, name, required, sx = {}, checked, variant = "outlined", ...rest } = props;
13
+ // Outlined
14
+ const outlined = variant === "outlined";
15
+ if (sx) {
16
+ Object.assign(sx, { height: outlined ? `${height}px` : undefined });
17
+ }
18
+ // Layout
19
+ return (React.createElement(React.Fragment, null,
20
+ React.createElement(FormControl, { component: "fieldset", fullWidth: fullWidth, sx: sx, ...rest },
21
+ label && (React.createElement(InputLabel, { required: required, variant: variant, shrink: true }, label)),
22
+ outlined && (React.createElement(NotchedOutline, { label: label && required ? label + " *" : label, notched: true, sx: {
23
+ cursor: "default",
24
+ position: "absolute",
25
+ width: fullWidth ? "100%" : "auto",
26
+ "& input": {
27
+ visibility: "hidden"
28
+ }
29
+ } })),
30
+ React.createElement(Box, { paddingLeft: 2, paddingY: "7px", position: outlined ? "absolute" : undefined },
31
+ React.createElement(SwitchAnt, { activeColor: activeColor, name: name, startLabel: startLabel !== null && startLabel !== void 0 ? startLabel : "NO", endLabel: endLabel !== null && endLabel !== void 0 ? endLabel : "YES", value: value, checked: checked }))),
32
+ helperText && React.createElement(FormHelperText, null, helperText)));
33
+ }
package/lib/Tiplist.js CHANGED
@@ -11,10 +11,11 @@ import { SearchField } from "./SearchField";
11
11
  * @returns Component
12
12
  */
13
13
  export function Tiplist(props) {
14
+ var _a;
14
15
  // Labels
15
- const labels = globalApp === null || globalApp === void 0 ? void 0 : globalApp.getLabels("noOptions", "loading", "more");
16
+ const { noOptions, loading, more } = (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.getLabels("noOptions", "loading", "more")) !== null && _a !== void 0 ? _a : {};
16
17
  // Destruct
17
- const { search = false, idField = "id", idValue, inputAutoComplete = "new-password", inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, label, loadData, defaultValue, value, maxItems = 16, name, readOnly, onChange, openOnFocus = true, sx = { minWidth: "180px" }, noOptionsText = labels === null || labels === void 0 ? void 0 : labels.noOptions, loadingText = labels === null || labels === void 0 ? void 0 : labels.loading, getOptionLabel, getOptionDisabled, ...rest } = props;
18
+ const { search = false, idField = "id", idValue, inputAutoComplete = "new-password", inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, label, loadData, defaultValue, value, maxItems = 16, name, readOnly, onChange, openOnFocus = true, sx = { minWidth: "180px" }, noOptionsText = noOptions, loadingText = loading, getOptionLabel, getOptionDisabled, ...rest } = props;
18
19
  // Value input ref
19
20
  const inputRef = React.createRef();
20
21
  // Local value
@@ -160,11 +161,10 @@ export function Tiplist(props) {
160
161
  return true;
161
162
  return getOptionDisabled ? getOptionDisabled(item) : false;
162
163
  }, getOptionLabel: (item) => {
163
- var _a;
164
164
  if (typeof item !== "object")
165
165
  return `${item}`;
166
166
  if (item[idField] === "n/a")
167
- return ((_a = labels.more) !== null && _a !== void 0 ? _a : "More") + "...";
167
+ return (more !== null && more !== void 0 ? more : "More") + "...";
168
168
  return getOptionLabel
169
169
  ? getOptionLabel(item)
170
170
  : "label" in item