@agilemotion/oui-react-js 1.8.18 → 1.8.19

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.
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _Observable = _interopRequireDefault(require("../event/Observable"));
9
9
  var _styles = require("@mui/styles");
10
- var _ToggleButtonGroup = _interopRequireDefault(require("@mui/lab/ToggleButtonGroup"));
10
+ var _ToggleButtonGroup = _interopRequireDefault(require("@mui/material/ToggleButtonGroup"));
11
11
  var _MenuButton = _interopRequireDefault(require("./menu/MenuButton"));
12
12
  var _Button = _interopRequireDefault(require("./Button"));
13
13
  var _Utils = _interopRequireDefault(require("../Utils"));
@@ -33,18 +33,18 @@ const BaseField = props => {
33
33
  const ref = _react.default.useRef(null);
34
34
  const valid = _react.default.useRef(false);
35
35
  _react.default.useEffect(() => {
36
- let value = valueObject[valueProperty];
36
+ let boundValue = valueObject[valueProperty];
37
37
  if (props.config.fieldType === 'SELECT' || props.config.fieldType === 'LOOKUP') {
38
- if (!value || _Utils.default.isNull(value.id)) {
38
+ if (!boundValue || _Utils.default.isNull(boundValue.id)) {
39
39
  setValue(null);
40
40
  valueRef.current = null;
41
41
  } else {
42
- setValue(value);
43
- valueRef.current = value;
42
+ setValue(boundValue);
43
+ valueRef.current = boundValue;
44
44
  }
45
45
  } else {
46
- setValue(value);
47
- valueRef.current = value;
46
+ setValue(boundValue);
47
+ valueRef.current = boundValue;
48
48
  }
49
49
  }, [valueObject[valueProperty]]);
50
50
 
@@ -52,7 +52,6 @@ const CurrencyFieldWrapper = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_reac
52
52
  } else {
53
53
  base.handleValueChange(0);
54
54
  }
55
- console.log("TARGET VAL : " + event.target.value);
56
55
  setDisplayValue(event.target.value);
57
56
  }
58
57
  };
@@ -27,12 +27,19 @@ const LookupFieldComponent = exports.LookupFieldComponent = /*#__PURE__*/_react.
27
27
  const height = !_Utils.default.isNull(props.config.attributes?.style?.height) ? props.config.attributes.style.height : '41px';
28
28
  const margin = !_Utils.default.isNull(props.config.attributes?.style?.margin) ? props.config.attributes.style.margin : '4px 0';
29
29
  const defaultValue = _Utils.default.isNull(props.value) ? '' : props.value;
30
+ const [value, setValue] = _react.default.useState(_Utils.default.isNull(props.value) ? null : props.value.id);
30
31
  const base = props.base;
31
32
  const handleClose = () => {
32
33
  setOpen(false);
33
34
  setCurrentSelection(null);
34
35
  _Observable.default.clearComponentEventListeners(props.gridHandle.api.id);
35
36
  };
37
+ _react.default.useEffect(() => {
38
+ // Initial binding
39
+ if (_Utils.default.isNull(value)) {
40
+ setValue(base.value);
41
+ }
42
+ }, [base.value]);
36
43
  _react.default.useEffect(() => {
37
44
  if (props.config && props.config.grid) {
38
45
  if (!props.config.grid.attributes) {
@@ -62,6 +69,7 @@ const LookupFieldComponent = exports.LookupFieldComponent = /*#__PURE__*/_react.
62
69
  const setSelectionAsValue = () => {
63
70
  if (currentSelection.length > 0) {
64
71
  let val = setupVal();
72
+ setValue(val);
65
73
  base.handleValueChange(val);
66
74
  handleClose();
67
75
  }
@@ -100,7 +108,7 @@ const LookupFieldComponent = exports.LookupFieldComponent = /*#__PURE__*/_react.
100
108
  className: 'col-*-* no-margin no-padding',
101
109
  style: {
102
110
  width: 'calc(100% - 72px)',
103
- marginBottom: base.value ? '0' : '8px',
111
+ marginBottom: value ? '0' : '8px',
104
112
  position: 'relative'
105
113
  }
106
114
  }, !base.required && /*#__PURE__*/_react.default.createElement("div", {
@@ -124,10 +132,10 @@ const LookupFieldComponent = exports.LookupFieldComponent = /*#__PURE__*/_react.
124
132
  },
125
133
  id: props.id,
126
134
  required: base.required,
127
- readonly: true,
135
+ readOnly: true,
128
136
  disabled: base.disabled,
129
137
  label: !_Utils.default.isNull(props.config.attributes) && !_Utils.default.isNull(props.config.attributes['label']) ? props.config.attributes['label'] : null,
130
- value: base.value?.__oui_label || base.value?.dataRecordDescription || defaultValue,
138
+ value: value?.__oui_label || value?.dataRecordDescription || defaultValue,
131
139
  className: props.className || 'lookup-field-input',
132
140
  error: base.hasError,
133
141
  helperText: base.errorMessage,
@@ -5,24 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
- var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
9
- var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
10
8
  var _Utils = _interopRequireDefault(require("../../Utils"));
11
9
  var _BaseField = require("./BaseField");
12
10
  var _RestService = require("../../RestService");
13
- var _Event = _interopRequireDefault(require("../../event/Event"));
14
- var _Observable = _interopRequireDefault(require("../../event/Observable"));
15
- var _EventType = _interopRequireDefault(require("../../event/EventType"));
11
+ var _material = require("@mui/material");
16
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
13
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
18
14
  const SelectItemComponent = props => {
19
15
  const base = props.base;
20
16
  const [optionsLoaded, setOptionsLoaded] = _react.default.useState(false);
21
17
  const [loadFullOptionList, setLoadFullOptionList] = _react.default.useState(false);
18
+ const [value, setValue] = _react.default.useState(_Utils.default.isNull(props.value) ? '' : props.value.id);
19
+ const initialValue = _react.default.useRef(null);
22
20
  const width = !_Utils.default.isNull(props.config.attributes?.style?.width) ? props.config.attributes.style.width : "100%";
23
21
  const maxWidth = !_Utils.default.isNull(props.config.attributes?.style?.maxWidth) ? props.config.attributes.style.maxWidth : null;
24
22
  const minWidth = !_Utils.default.isNull(props.config.attributes?.style?.minWidth) ? props.config.attributes.style.minWidth : "240px";
25
- const defaultValue = _Utils.default.isNull(props.value) ? '' : props.value.id;
26
23
  _react.default.useEffect(() => {
27
24
  if (!_Utils.default.isNull(base.value) && !optionsLoaded) {
28
25
  let defaultOptions = [];
@@ -30,7 +27,17 @@ const SelectItemComponent = props => {
30
27
  base.setSelectOptions(defaultOptions);
31
28
  setOptionsLoaded(true);
32
29
  }
30
+ if (_Utils.default.isNull(initialValue.current) && !_Utils.default.isNull(base.value)) {
31
+ initialValue.current = base.value;
32
+ }
33
33
  }, [base.value]);
34
+ _react.default.useEffect(() => {
35
+ if (!_Utils.default.isNull(base.selectOptions) && base.selectOptions.length > 0) {
36
+ if (initialValue.current) {
37
+ setValue(initialValue.current.id);
38
+ }
39
+ }
40
+ }, [base.selectOptions]);
34
41
  _react.default.useEffect(() => {
35
42
  if (loadFullOptionList && !_Utils.default.isNull(props.config.dataService)) {
36
43
  let method = props.config.dataService.type === 'rpc' ? _RestService.invokeRpc : _RestService.invokeRest;
@@ -57,42 +64,45 @@ const SelectItemComponent = props => {
57
64
  setOptionsLoaded(true);
58
65
  }
59
66
  }, [loadFullOptionList, props.refreshData]);
60
- return /*#__PURE__*/_react.default.createElement(_TextField.default, {
61
- select: true,
62
- InputProps: props.InputProps,
63
- id: props.id,
64
- disabled: base.disabled,
67
+ return /*#__PURE__*/_react.default.createElement(_material.FormControl, {
68
+ fullWidth: true,
69
+ margin: "dense",
70
+ size: "small",
65
71
  required: base.required,
66
- label: !_Utils.default.isNull(props.config.attributes) ? props.config.attributes['label'] : null,
72
+ disabled: base.disabled,
73
+ error: base.hasError,
67
74
  style: _Utils.default.mergeStyles({
68
75
  minWidth: minWidth,
69
76
  width: width,
70
77
  maxWidth: maxWidth
71
- }, props.config),
72
- SelectProps: {
73
- onOpen: () => {
74
- if (!loadFullOptionList) {
75
- setLoadFullOptionList(true);
76
- }
78
+ }, props.config)
79
+ }, /*#__PURE__*/_react.default.createElement(_material.InputLabel, {
80
+ id: `${props.id}-label`
81
+ }, !_Utils.default.isNull(props.config.attributes) ? props.config.attributes['label'] : ''), /*#__PURE__*/_react.default.createElement(_material.Select, {
82
+ labelId: `${props.id}-label`,
83
+ id: props.id,
84
+ variant: "outlined",
85
+ value: value,
86
+ input: /*#__PURE__*/_react.default.createElement(_material.OutlinedInput, {
87
+ label: props.config.attributes?.label || ''
88
+ }),
89
+ onOpen: () => {
90
+ if (!loadFullOptionList) {
91
+ setLoadFullOptionList(true);
77
92
  }
78
93
  },
79
- value: !_Utils.default.isNull(base.value) && base.selectOptions && base.selectOptions.length > 0 ? base.value.id : defaultValue,
80
- className: props.className,
81
94
  onChange: e => {
82
95
  base.handleValueChange(e.target.value);
96
+ setValue(e.target.value);
83
97
  },
84
- error: base.hasError,
85
- helperText: base.errorMessage,
86
- margin: "dense",
87
- size: "small",
88
- variant: "outlined"
89
- }, base.selectOptions.map(option => option.id === '_EMPTY_VALUE' ? /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
98
+ className: props.className
99
+ }, base.selectOptions.map(option => option.id === '_EMPTY_VALUE' ? /*#__PURE__*/_react.default.createElement(_material.MenuItem, {
90
100
  value: "",
91
101
  key: option.id
92
- }, /*#__PURE__*/_react.default.createElement("em", null, "\xA0")) : /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
102
+ }, /*#__PURE__*/_react.default.createElement("em", null, "\xA0")) : /*#__PURE__*/_react.default.createElement(_material.MenuItem, {
93
103
  key: option.id,
94
104
  value: option.id
95
- }, _Utils.default.isNull(option.dataRecordDescription) ? '' : option.dataRecordDescription.trim())));
105
+ }, _Utils.default.isNull(option.dataRecordDescription) ? '' : option.dataRecordDescription.trim()))), base.hasError && /*#__PURE__*/_react.default.createElement(_material.FormHelperText, null, base.errorMessage));
96
106
  };
97
107
  const SelectItem = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.default.forwardRef((props, ref) => {
98
108
  const [refreshData, setRefreshData] = _react.default.useState(false);
@@ -9,7 +9,7 @@ var _styles = require("@mui/styles");
9
9
  var _Divider = _interopRequireDefault(require("@mui/material/Divider"));
10
10
  var _Paper = _interopRequireDefault(require("@mui/material/Paper"));
11
11
  var _ToggleButton = _interopRequireDefault(require("@mui/lab/ToggleButton"));
12
- var _ToggleButtonGroup = _interopRequireDefault(require("@mui/lab/ToggleButtonGroup"));
12
+ var _ToggleButtonGroup = _interopRequireDefault(require("@mui/material/ToggleButtonGroup"));
13
13
  var _Add = _interopRequireDefault(require("@mui/icons-material/Add"));
14
14
  var _Edit = _interopRequireDefault(require("@mui/icons-material/Edit"));
15
15
  var _Save = _interopRequireDefault(require("@mui/icons-material/Save"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilemotion/oui-react-js",
3
- "version": "1.8.18",
3
+ "version": "1.8.19",
4
4
  "files": [
5
5
  "dist"
6
6
  ],