@dexteel/mesf-core 4.18.1 → 4.19.0

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,3 @@
1
1
  {
2
- ".": "4.18.1"
2
+ ".": "4.19.0"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # Changelog
2
+
3
+ ## [4.19.0](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v4.18.1...@dexteel/mesf-core-v4.19.0) (2024-08-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * **TreePickerControlV2:** Implement TreePickerControl with value-OnSelect paradigm. ([8f488a3](https://github.com/dexteel/mesf-core-frontend/commit/8f488a3be4ec8e7edcc8f6b0e8fd11610fd57513))
9
+
10
+ ## [4.18.1] - 2024-08-01
11
+
12
+
13
+
1
14
  # Changelog
2
15
 
3
16
  ## [4.18.1](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v4.18.0...@dexteel/mesf-core-v4.18.1) (2024-08-01)
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ type TreePickerControlProps = {
3
+ onSelect: (value: number, description: string, findNode: any, showPath?: boolean, listAssetDrawings?: number[], multipleSelectNodes?: boolean, onHide?: (showAssetTree?: boolean) => void, showAssetTree?: boolean) => void;
4
+ isLoading?: boolean;
5
+ setListAssetDrawings?: Function;
6
+ onSuccess?: (success: boolean) => void;
7
+ showClearButton?: boolean;
8
+ [key: string]: any;
9
+ };
10
+ export declare const TreePickerControl: (props: TreePickerControlProps) => React.JSX.Element;
11
+ export {};
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { TreeNode } from "./dialogFilter";
3
+ type TreePickerControlProps = {
4
+ onSelect: (value: number, description: string, findNode: any, showPath?: boolean, listAssetDrawings?: number[], multipleSelectNodes?: boolean, onHide?: (showAssetTree?: boolean) => void, showAssetTree?: boolean) => void;
5
+ isLoading?: boolean;
6
+ setListAssetDrawings?: Function;
7
+ onSuccess?: (success: boolean) => void;
8
+ showClearButton?: boolean;
9
+ dataSource: TreeNode;
10
+ [key: string]: any;
11
+ };
12
+ export declare const TreePickerControlV2: (props: TreePickerControlProps) => React.JSX.Element;
13
+ export {};
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- interface TreeNode {
2
+ export interface TreeNode {
3
3
  id: number;
4
4
  name: string;
5
5
  isCode: boolean;
@@ -1,12 +1,4 @@
1
1
  import React, { Component } from "react";
2
- type TreePickerControlProps = {
3
- onSelect: (value: string, description: string, findNode: any, showPath?: boolean, listAssetDrawings?: number[], multipleSelectNodes?: boolean, onHide?: (showAssetTree?: boolean) => void, showAssetTree?: boolean) => void;
4
- isLoading?: boolean;
5
- setListAssetDrawings?: Function;
6
- onSuccess?: (success: boolean) => void;
7
- [key: string]: any;
8
- };
9
- export declare const TreePickerControl: (props: TreePickerControlProps) => React.JSX.Element;
10
2
  export declare class SimpleTextControl extends Component<any> {
11
3
  render(): React.JSX.Element;
12
4
  }
@@ -45,4 +37,5 @@ export declare function SimpleSelectorControl({ title, dataSource, selectedValue
45
37
  export declare const MultipleSelectorControl: (props: any) => React.JSX.Element;
46
38
  export declare const CheckBoxControl: (props: any) => React.JSX.Element;
47
39
  export declare const UploadFileControl: (props: any) => React.JSX.Element;
48
- export {};
40
+ export * from "./TreePickerControl";
41
+ export * from "./TreePickerControlV2";
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { LicenseManager } from 'ag-grid-enterprise';
2
- import { DialogTitle as DialogTitle$1, DialogContent as DialogContent$1, DialogActions as DialogActions$1, Grid, Button, withStyles as withStyles$1, alpha, makeStyles, Dialog as Dialog$1, SvgIcon, Collapse, Typography as Typography$1, Checkbox, TextField, MenuItem, Select, Card, CardContent, CardActions, Snackbar, CircularProgress, Paper, InputLabel, FormHelperText, DialogContentText, FormControlLabel, Badge, useTheme, FormControl, Input, Chip, Tooltip, IconButton as IconButton$1, ListItemIcon, MenuList, Divider, Box, debounce, createStyles as createStyles$1, List, ListItem, ListItemText } from '@material-ui/core';
2
+ import { DialogTitle as DialogTitle$1, DialogContent as DialogContent$1, DialogActions as DialogActions$1, Grid, Button, withStyles as withStyles$1, alpha, makeStyles, Dialog as Dialog$1, SvgIcon, Collapse, Typography as Typography$1, Checkbox, TextField, InputAdornment, IconButton as IconButton$1, MenuItem, Select, Card, CardContent, CardActions, Snackbar, CircularProgress, Paper, InputLabel, FormHelperText, DialogContentText, FormControlLabel, Badge, useTheme, FormControl, Input, Chip, Tooltip, ListItemIcon, MenuList, Divider, Box, debounce, createStyles as createStyles$1, List, ListItem, ListItemText } from '@material-ui/core';
3
3
  import { get, isNil as isNil$1, isEmpty, values, round, isNaN, isNumber } from 'lodash-es';
4
4
  import * as React from 'react';
5
5
  import React__default, { useState, useRef, useEffect, useMemo, Component, createContext, useContext, useCallback, lazy, Suspense } from 'react';
@@ -32,7 +32,7 @@ import InsertChartIcon from '@material-ui/icons/InsertChart';
32
32
  import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
33
33
  import SkipNextIcon from '@material-ui/icons/SkipNext';
34
34
  import { Line } from 'react-chartjs-2';
35
- import { LocalizationProvider } from '@mui/x-date-pickers';
35
+ import { ClearIcon, LocalizationProvider } from '@mui/x-date-pickers';
36
36
  import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
37
37
  import moment$3 from 'moment-timezone';
38
38
  import PersonPinCircleIcon from '@material-ui/icons/PersonPinCircle';
@@ -446,11 +446,6 @@ var ModalTreeFilterControl = function (props) {
446
446
  }
447
447
  return branches;
448
448
  };
449
- var handleEntering = function () {
450
- if (treeRef.current != null) {
451
- treeRef.current.focus();
452
- }
453
- };
454
449
  var handleCancel = function () {
455
450
  onClose();
456
451
  if (onHide)
@@ -562,7 +557,7 @@ var ModalTreeFilterControl = function (props) {
562
557
  }, onClick: handleCheckboxClick }))), className: "delay-item-node", id: nodes.id.toString(), "data-isbranch": !nodes.isCode }, Array.isArray(nodes.children)
563
558
  ? nodes.children.map(function (node) { return renderTree(node); })
564
559
  : null)); };
565
- return (React__default.createElement(Dialog$1, __assign({ onClose: onHide ? function () { return onHide(false); } : function () { return null; }, "aria-label": title, maxWidth: "sm", TransitionProps: { onEntering: handleEntering }, "aria-labelledby": "confirmation-dialog-title", open: open }, other, { onKeyDown: handleKeyDown }),
560
+ return (React__default.createElement(Dialog$1, __assign({ onClose: onHide ? function () { return onHide(false); } : function () { return null; }, "aria-label": title, maxWidth: "sm", disableAutoFocus: true, disableEnforceFocus: true, disableRestoreFocus: true, "aria-labelledby": "confirmation-dialog-title", open: open }, other, { onKeyDown: handleKeyDown }),
566
561
  React__default.createElement(DialogTitle$1, { id: "confirmation-dialog-title" }, title),
567
562
  isLoading ? (React__default.createElement("div", { style: {
568
563
  width: 600,
@@ -572,13 +567,13 @@ var ModalTreeFilterControl = function (props) {
572
567
  alignItems: "center"
573
568
  } },
574
569
  React__default.createElement(LazyLoading, null))) : (React__default.createElement(DialogContent$1, { dividers: true },
575
- React__default.createElement(TreeView, { className: classes.root, defaultCollapseIcon: React__default.createElement(MinusSquare, null), defaultExpandIcon: React__default.createElement(PlusSquare, null), ref: treeRef, selected: value === undefined ? "" : value.toString(), expanded: expanded, onNodeSelect: handleChange, onNodeToggle: handleToogle }, data && data.id !== undefined && renderTree(data)))),
570
+ React__default.createElement(TreeView, { autoFocus: false, className: classes.root, defaultCollapseIcon: React__default.createElement(MinusSquare, null), defaultExpandIcon: React__default.createElement(PlusSquare, null), ref: treeRef, selected: value === undefined ? "" : value.toString(), expanded: expanded, onNodeSelect: handleChange, onNodeToggle: handleToogle }, data && data.id !== undefined && renderTree(data)))),
576
571
  React__default.createElement(DialogActions$1, null,
577
- React__default.createElement(Button, { autoFocus: true, onClick: handleCancel, color: "primary" }, "Cancel"),
572
+ React__default.createElement(Button, { onClick: handleCancel, color: "primary" }, "Cancel"),
578
573
  React__default.createElement(Button, { onClick: handleOk, color: "primary" }, "OK"))));
579
574
  };
580
575
 
581
- var useStyles$u = makeStyles(function (theme) { return ({
576
+ var useStyles$v = makeStyles(function (theme) { return ({
582
577
  root: {
583
578
  width: "100%",
584
579
  backgroundColor: theme.palette.background.paper,
@@ -594,9 +589,9 @@ var useStyles$u = makeStyles(function (theme) { return ({
594
589
  }
595
590
  }); });
596
591
  var TreePickerControl = function (props) {
597
- var classes = useStyles$u();
598
- var onSelect = props.onSelect, value = props.value; props.styleLabel; var dataSource = props.dataSource, _a = props.inputTitle, inputTitle = _a === void 0 ? "Asset" : _a; props.showPath; var _c = props.multipleSelectNodes, multipleSelectNodes = _c === void 0 ? false : _c, showAssetTree = props.showAssetTree, onHide = props.onHide, _d = props.listAssetDrawings, listAssetDrawings = _d === void 0 ? [] : _d, onSuccess = props.onSuccess, isLoading = props.isLoading, other = __rest(props, ["onSelect", "value", "styleLabel", "dataSource", "inputTitle", "showPath", "multipleSelectNodes", "showAssetTree", "onHide", "listAssetDrawings", "onSuccess", "isLoading"]);
599
- var _e = useState(false), open = _e[0], setOpen = _e[1];
592
+ var classes = useStyles$v();
593
+ var onSelect = props.onSelect, value = props.value; props.styleLabel; var dataSource = props.dataSource, _a = props.inputTitle, inputTitle = _a === void 0 ? "Asset" : _a; props.showPath; var _c = props.multipleSelectNodes, multipleSelectNodes = _c === void 0 ? false : _c, _d = props.showClearButton, showClearButton = _d === void 0 ? false : _d, showAssetTree = props.showAssetTree, onHide = props.onHide, _e = props.listAssetDrawings, listAssetDrawings = _e === void 0 ? [] : _e, onSuccess = props.onSuccess, isLoading = props.isLoading, other = __rest(props, ["onSelect", "value", "styleLabel", "dataSource", "inputTitle", "showPath", "multipleSelectNodes", "showClearButton", "showAssetTree", "onHide", "listAssetDrawings", "onSuccess", "isLoading"]);
594
+ var _f = useState(false), open = _f[0], setOpen = _f[1];
600
595
  var handleClickListItem = function (e) {
601
596
  e.stopPropagation();
602
597
  setOpen(true);
@@ -641,20 +636,106 @@ var TreePickerControl = function (props) {
641
636
  }
642
637
  };
643
638
  var description = useMemo(function () { return formatDescription(props.description); }, [props.description]);
644
- useEffect(function () {
645
- if (showAssetTree) {
646
- setOpen(showAssetTree);
639
+ return (React__default.createElement(Grid, { container: true, className: classes.root },
640
+ !showAssetTree ? (React__default.createElement(Grid, { container: true, item: true, md: 12, xs: 12, style: { position: "relative" }, title: props.description },
641
+ React__default.createElement(Grid, { item: true, style: { position: "relative", width: "100%" } },
642
+ React__default.createElement(TextField, { id: "treePickerTextField", label: inputTitle, variant: "outlined", value: description, margin: "dense", autoComplete: "off", fullWidth: true, disabled: true, InputProps: {
643
+ endAdornment: (React__default.createElement(InputAdornment, { position: "end", style: {
644
+ cursor: "pointer"
645
+ } },
646
+ showClearButton && value ? (React__default.createElement(IconButton$1, { "aria-label": "clear input", onClick: function (e) {
647
+ console.log("onClear -> onSelect");
648
+ e.stopPropagation();
649
+ onSelect(0, "", "");
650
+ }, style: {
651
+ cursor: "pointer",
652
+ zIndex: 100
653
+ }, edge: "end" },
654
+ React__default.createElement(ClearIcon, null))) : null,
655
+ React__default.createElement(AccountTreeIcon, { style: {
656
+ cursor: "pointer"
657
+ } })))
658
+ } })),
659
+ React__default.createElement("div", { style: {
660
+ position: "absolute",
661
+ top: 0,
662
+ bottom: 0,
663
+ left: 0,
664
+ right: 0,
665
+ zIndex: 999,
666
+ cursor: "pointer"
667
+ }, onClick: handleClickListItem }))) : (React__default.createElement("div", null)),
668
+ React__default.createElement(Grid, { item: true, xs: 12, md: 12 },
669
+ React__default.createElement(ModalTreeFilterControl, __assign({ classes: {
670
+ paper: classes.paper
671
+ }, onHide: onHide, id: "modal-treeview-filter", title: props.title, keepMounted: true, open: open, onClose: handleClose, isLoading: isLoading, value: value, data: dataSource, onBackdropClick: function () { return setOpen(false); }, multipleSelectNodes: multipleSelectNodes, listAssetDrawings: listAssetDrawings, setListAssetDrawings: listAssetDrawings, onSuccess: onSuccess }, other)))));
672
+ };
673
+
674
+ var useStyles$u = makeStyles(function (theme) { return ({
675
+ root: {
676
+ width: "100%",
677
+ backgroundColor: theme.palette.background.paper,
678
+ "& .MuiInputBase-input": {
679
+ color: "black",
680
+ cursor: "pointer",
681
+ paddingRight: 45
647
682
  }
648
- }, []);
683
+ },
684
+ paper: {
685
+ width: "100%",
686
+ maxHeight: 600
687
+ }
688
+ }); });
689
+ function findNameById(node, id) {
690
+ if (node.id === id) {
691
+ return node.name;
692
+ }
693
+ if (node.children) {
694
+ for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
695
+ var child = _a[_i];
696
+ var result = findNameById(child, id);
697
+ if (result !== null) {
698
+ return result;
699
+ }
700
+ }
701
+ }
702
+ return null;
703
+ }
704
+ var TreePickerControlV2 = function (props) {
705
+ var classes = useStyles$u();
706
+ var value = props.value, onSelect = props.onSelect; props.styleLabel; var dataSource = props.dataSource; props.getOptionName; var _a = props.inputTitle, inputTitle = _a === void 0 ? "Asset" : _a; props.showPath; var _c = props.multipleSelectNodes, multipleSelectNodes = _c === void 0 ? false : _c, _d = props.showClearButton, showClearButton = _d === void 0 ? false : _d, showAssetTree = props.showAssetTree, onHide = props.onHide, _e = props.listAssetDrawings, listAssetDrawings = _e === void 0 ? [] : _e, onSuccess = props.onSuccess, isLoading = props.isLoading, other = __rest(props, ["value", "onSelect", "styleLabel", "dataSource", "getOptionName", "inputTitle", "showPath", "multipleSelectNodes", "showClearButton", "showAssetTree", "onHide", "listAssetDrawings", "onSuccess", "isLoading"]);
707
+ var _f = useState(false), open = _f[0], setOpen = _f[1];
708
+ var handleClickListItem = function (event) {
709
+ event.stopPropagation();
710
+ setOpen(true);
711
+ };
712
+ var handleClose = function (newValue, newDescription, findNode) {
713
+ setOpen(false);
714
+ if (newValue) {
715
+ if (onSelect !== undefined) {
716
+ onSelect(newValue, newDescription, findNode);
717
+ }
718
+ }
719
+ };
720
+ var description = useMemo(function () { return findNameById(dataSource, value) || ""; }, [dataSource, value]);
649
721
  return (React__default.createElement(Grid, { container: true, className: classes.root },
650
722
  !showAssetTree ? (React__default.createElement(Grid, { container: true, item: true, md: 12, xs: 12, style: { position: "relative" }, title: props.description },
651
723
  React__default.createElement(Grid, { item: true, style: { position: "relative", width: "100%" } },
652
- React__default.createElement(TextField, { id: "treePickerTextField", label: inputTitle, variant: "outlined", value: description, margin: "dense", autoComplete: "off", fullWidth: true, disabled: true }),
653
- React__default.createElement(AccountTreeIcon, { style: {
654
- position: "absolute",
655
- right: 15,
656
- top: 16,
657
- cursor: "pointer"
724
+ React__default.createElement(TextField, { id: "treePickerTextField", label: inputTitle || "", variant: "outlined", value: description, margin: "dense", autoComplete: "off", fullWidth: true, disabled: true, InputProps: {
725
+ endAdornment: (React__default.createElement(InputAdornment, { position: "end", style: {
726
+ cursor: "pointer"
727
+ } },
728
+ showClearButton && value ? (React__default.createElement(IconButton$1, { "aria-label": "clear input", onClick: function (e) {
729
+ e.stopPropagation();
730
+ onSelect(0, "", "");
731
+ }, style: {
732
+ cursor: "pointer",
733
+ zIndex: 100
734
+ }, edge: "end" },
735
+ React__default.createElement(ClearIcon, null))) : null,
736
+ React__default.createElement(AccountTreeIcon, { style: {
737
+ cursor: "pointer"
738
+ } })))
658
739
  } })),
659
740
  React__default.createElement("div", { style: {
660
741
  position: "absolute",
@@ -668,7 +749,8 @@ var TreePickerControl = function (props) {
668
749
  React__default.createElement(ModalTreeFilterControl, __assign({ classes: {
669
750
  paper: classes.paper
670
751
  }, onHide: onHide, id: "modal-treeview-filter", title: props.title, keepMounted: true, open: open, onClose: handleClose, isLoading: isLoading, value: value, data: dataSource, onBackdropClick: function () { return setOpen(false); }, multipleSelectNodes: multipleSelectNodes, listAssetDrawings: listAssetDrawings, setListAssetDrawings: listAssetDrawings, onSuccess: onSuccess }, other)))));
671
- };
752
+ };
753
+
672
754
  var SimpleTextControl = /** @class */ (function (_super) {
673
755
  __extends(SimpleTextControl, _super);
674
756
  function SimpleTextControl() {
@@ -12296,5 +12378,5 @@ var areaSelector = /*#__PURE__*/Object.freeze({
12296
12378
  AreaSelector: AreaSelector
12297
12379
  });
12298
12380
 
12299
- export { Account, AssetProvider, AuthContext, AuthProvider, BarChartControl, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ErrorModal, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HorizontalTextControl, IntegerFormatter, Login, Logout, LongFilterPanel, MESApiService, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, NumericTextControl, ShiftDayNavigatorControl, ShiftNavigatorProvider, SimplePasswordControl, SimpleSelectorControl, SimpleTextAreaControl, SimpleTextControl, TimeFormatter, TimeService, TreePickerControl, TrendingsPage, USER_LABELS, UTLSettingsProvider, UploadFileControl, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getError, getMomentTz, getProfiles, getShiftByParameters, getShiftStyle, getTokenFromLS, getUsers, renewToken, setPassword, setProfilesToUser, upsertUser, useAssetContext, useContextMenuMESF, useShiftNavigator, useShiftNavigatorManager, useStyles$1 as useStyles, useToken, useUTLSettingsContext, useUserContext };
12381
+ export { Account, AssetProvider, AuthContext, AuthProvider, BarChartControl, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ErrorModal, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HorizontalTextControl, IntegerFormatter, Login, Logout, LongFilterPanel, MESApiService, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, NumericTextControl, ShiftDayNavigatorControl, ShiftNavigatorProvider, SimplePasswordControl, SimpleSelectorControl, SimpleTextAreaControl, SimpleTextControl, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, TrendingsPage, USER_LABELS, UTLSettingsProvider, UploadFileControl, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getError, getMomentTz, getProfiles, getShiftByParameters, getShiftStyle, getTokenFromLS, getUsers, renewToken, setPassword, setProfilesToUser, upsertUser, useAssetContext, useContextMenuMESF, useShiftNavigator, useShiftNavigatorManager, useStyles$1 as useStyles, useToken, useUTLSettingsContext, useUserContext };
12300
12382
  //# sourceMappingURL=index.esm.js.map