@singularsystems/neo-react 0.10.56 → 0.10.58

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.
@@ -2,9 +2,9 @@ import { Model } from '@singularsystems/neo-core';
2
2
  import { ModelCreatorBase } from '@singularsystems/neo-core/dist/Model/ModelCreatorBase';
3
3
  import { NeoTypeInfo } from '@singularsystems/neo-core/dist/Model/NeoTypeInfo';
4
4
  export declare class ReactModelCreator extends ModelCreatorBase {
5
- convertInstance(instance: {}): {};
6
- setupModel(typeInfo: NeoTypeInfo, model: Model.IModelBase): void;
7
- setupObject(typeInfo: NeoTypeInfo, object: any): void;
5
+ convertInstance(instance: {}, options: Model.IMakeBindableOptions): {};
6
+ setupModel(typeInfo: NeoTypeInfo, model: Model.IModelBase, options: Model.IMakeBindableOptions): void;
7
+ setupObject(typeInfo: NeoTypeInfo, object: any, options: Model.IMakeBindableOptions): void;
8
8
  private convertToObservable;
9
9
  private addChangeTracking;
10
10
  }
@@ -4,38 +4,34 @@ import { createObservableList } from './Utils';
4
4
  import { Misc, Validation, Utils } from '@singularsystems/neo-core';
5
5
  import { ModelCreatorBase } from '@singularsystems/neo-core/dist/Model/ModelCreatorBase';
6
6
  import PropertyInstance from '@singularsystems/neo-core/dist/Model/PropertyInstance';
7
- var hasConvertedSymbol = Symbol("hasConvertedModel");
8
7
  var ReactModelCreator = /** @class */ (function (_super) {
9
8
  __extends(ReactModelCreator, _super);
10
9
  function ReactModelCreator() {
11
10
  return _super !== null && _super.apply(this, arguments) || this;
12
11
  }
13
- ReactModelCreator.prototype.convertInstance = function (instance) {
14
- if (!instance[hasConvertedSymbol]) {
15
- if (this.typeInfo.inheritsBindableBase) {
16
- this.setupModel(this.typeInfo, instance);
17
- }
18
- else {
19
- this.setupObject(this.typeInfo, instance);
20
- }
21
- instance[hasConvertedSymbol] = true;
12
+ ReactModelCreator.prototype.convertInstance = function (instance, options) {
13
+ if (this.typeInfo.inheritsBindableBase) {
14
+ this.setupModel(this.typeInfo, instance, options);
15
+ }
16
+ else {
17
+ this.setupObject(this.typeInfo, instance, options);
22
18
  }
23
19
  return instance;
24
20
  };
25
- ReactModelCreator.prototype.setupModel = function (typeInfo, model) {
21
+ ReactModelCreator.prototype.setupModel = function (typeInfo, model, options) {
26
22
  if (this.typeInfo.inheritsModelBase) {
27
23
  model.validator = new Validation.ModelValidator(model, typeInfo.objectRules);
28
24
  }
29
25
  model.meta = {};
30
26
  model.isSuspended = true;
31
- this.setupObject(typeInfo, model);
27
+ this.setupObject(typeInfo, model, options);
32
28
  model.isSuspended = false;
33
29
  };
34
- ReactModelCreator.prototype.setupObject = function (typeInfo, object) {
30
+ ReactModelCreator.prototype.setupObject = function (typeInfo, object, options) {
35
31
  for (var _i = 0, _a = typeInfo.properties; _i < _a.length; _i++) {
36
32
  var propertyInfo = _a[_i];
37
33
  if (propertyInfo.isObservable !== false) {
38
- var propertyName = propertyInfo.propertyName, makeObservable = this.typeInfo.inheritsModelBase || propertyInfo.isObservable === true;
34
+ var propertyName = propertyInfo.propertyName, makeObservable = options.makeObservable || propertyInfo.isObservable === true;
39
35
  var propertyInstance = void 0;
40
36
  if (this.typeInfo.inheritsBindableBase) {
41
37
  var model = object;
@@ -67,7 +67,12 @@ export interface IAutoCompleteMultiSelectProps<T> extends IAutoCompleteCommonPro
67
67
  /**
68
68
  * Optional list of ids. This will be kept in sync with the bindItems prop.
69
69
  */
70
- bindIds?: (string | number)[];
70
+ bindIds?: (string | number)[] | Model.IPropertyInstance<number[]>;
71
+ /**
72
+ * The max no of items to record in the field info if bound to a field info class. (Defaults to 5)
73
+ * If the selected items exceeds this limit, the field info will be recorded as "x items selected".
74
+ */
75
+ fieldInfoLimit?: number;
71
76
  }
72
77
  export default class AutoCompleteDropDown<T> extends DropDownBase<T, IAutoCompleteProps<T> | IAutoCompleteMultiSelectProps<T>> {
73
78
  static contextType: React.Context<import("../FormContext").FormContextParams>;
@@ -75,6 +80,9 @@ export default class AutoCompleteDropDown<T> extends DropDownBase<T, IAutoComple
75
80
  private asyncSelectImplementation;
76
81
  private selectImplementation;
77
82
  constructor(props: IAutoCompleteProps<T> | IAutoCompleteMultiSelectProps<T>);
83
+ private bindProperty;
84
+ private bindIdsList?;
85
+ private bindIdsProperty?;
78
86
  static getBindProp<T>(props: IAutoCompleteProps<T> | IAutoCompleteMultiSelectProps<T>): any;
79
87
  private onKeyPress;
80
88
  private mapTArrayToOptions;
@@ -1,6 +1,6 @@
1
1
  import { __assign, __decorate, __extends, __metadata, __rest } from "tslib";
2
2
  import React from 'react';
3
- import { EnumHelper, Misc, Utils } from '@singularsystems/neo-core';
3
+ import { EnumHelper, Misc, Model, Utils } from '@singularsystems/neo-core';
4
4
  import { observer } from 'mobx-react';
5
5
  import { DropDownBase } from './DropDownBase';
6
6
  import { BindPropsHelper } from '../PropTypes';
@@ -11,11 +11,27 @@ import { NeoReactTypes } from '../../Modules/Types';
11
11
  var AutoCompleteDropDown = /** @class */ (function (_super) {
12
12
  __extends(AutoCompleteDropDown, _super);
13
13
  function AutoCompleteDropDown(props) {
14
+ var _a;
14
15
  var _this = _super.call(this, props) || this;
15
16
  _this.asyncSelectImplementation = Misc.Globals.appService.get(NeoReactTypes.Components.AsyncSelect);
16
17
  _this.selectImplementation = Misc.Globals.appService.get(NeoReactTypes.Components.ReactSelect);
17
18
  _this.onKeyPress = _this.onKeyPress.bind(_this);
18
19
  _this.onItemSelected = _this.onItemSelected.bind(_this);
20
+ _this.bindProperty = (_a = _this.props.bind, (_a !== null && _a !== void 0 ? _a : _this.props.bindItems));
21
+ _this.fieldInfoContainer = Model.ModelFieldInfo.asModelFieldInfoContainer(_this.bindProperty.attachedTo);
22
+ if (_this.props.bindIds) {
23
+ if (_this.props.bindIds.propertyInfo) {
24
+ _this.bindIdsProperty = _this.props.bindIds;
25
+ _this.bindIdsList = _this.props.bindIds.value;
26
+ }
27
+ else {
28
+ _this.bindIdsList = _this.props.bindIds;
29
+ if (_this.fieldInfoContainer) {
30
+ console.error("Warning: Pass a property instance as 'bindIds', otherwise the display values will not be captured.");
31
+ _this.fieldInfoContainer = null;
32
+ }
33
+ }
34
+ }
19
35
  return _this;
20
36
  }
21
37
  AutoCompleteDropDown.getBindProp = function (props) {
@@ -58,11 +74,10 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
58
74
  var itemsProperty = this.props.bindItems;
59
75
  // Multi select
60
76
  var itemList = itemsProperty.value;
61
- var bindIdsList = this.props.bindIds;
62
77
  if (action.action === "select-option") {
63
78
  itemList.push({ id: action.option.value, display: action.option.label });
64
- if (bindIdsList) {
65
- bindIdsList.push(action.option.value);
79
+ if (this.bindIdsList) {
80
+ this.bindIdsList.push(action.option.value);
66
81
  }
67
82
  if (onItemSelected) {
68
83
  onItemSelected((_a = action.option) === null || _a === void 0 ? void 0 : _a.item);
@@ -72,8 +87,8 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
72
87
  var removeItem = itemList.find(function (c) { return c.id === action.removedValue.value; });
73
88
  if (removeItem) {
74
89
  itemList.remove(removeItem);
75
- if (bindIdsList) {
76
- bindIdsList.remove(removeItem.id);
90
+ if (this.bindIdsList) {
91
+ this.bindIdsList.remove(removeItem.id);
77
92
  }
78
93
  }
79
94
  if (onItemSelected) {
@@ -82,8 +97,8 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
82
97
  }
83
98
  else if (action.action === "clear") {
84
99
  itemList.length = 0;
85
- if (bindIdsList) {
86
- bindIdsList.length = 0;
100
+ if (this.bindIdsList) {
101
+ this.bindIdsList.length = 0;
87
102
  }
88
103
  if (onItemSelected) {
89
104
  onItemSelected(undefined);
@@ -105,15 +120,14 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
105
120
  AutoCompleteDropDown.prototype.render = function () {
106
121
  var _this = this;
107
122
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
108
- var _m = this.props, bind = _m.bind, bindDisplay = _m.bindDisplay, bindItems = _m.bindItems, bindIds = _m.bindIds, itemSource = _m.itemSource, items = _m.items, displayMember = _m.displayMember, valueMember = _m.valueMember, descriptionMember = _m.descriptionMember, option = _m.option, noRecordsPrompt = _m.noRecordsPrompt, typeToSearchPrompt = _m.typeToSearchPrompt, delayMs = _m.delayMs, minCharacters = _m.minCharacters, onItemSelected = _m.onItemSelected, otherProps = __rest(_m, ["bind", "bindDisplay", "bindItems", "bindIds", "itemSource", "items", "displayMember", "valueMember", "descriptionMember", "option", "noRecordsPrompt", "typeToSearchPrompt", "delayMs", "minCharacters", "onItemSelected"]);
123
+ var _m = this.props, bind = _m.bind, bindDisplay = _m.bindDisplay, bindItems = _m.bindItems, bindIds = _m.bindIds, itemSource = _m.itemSource, items = _m.items, displayMember = _m.displayMember, valueMember = _m.valueMember, descriptionMember = _m.descriptionMember, option = _m.option, noRecordsPrompt = _m.noRecordsPrompt, typeToSearchPrompt = _m.typeToSearchPrompt, delayMs = _m.delayMs, minCharacters = _m.minCharacters, onItemSelected = _m.onItemSelected, fieldInfoLimit = _m.fieldInfoLimit, otherProps = __rest(_m, ["bind", "bindDisplay", "bindItems", "bindIds", "itemSource", "items", "displayMember", "valueMember", "descriptionMember", "option", "noRecordsPrompt", "typeToSearchPrompt", "delayMs", "minCharacters", "onItemSelected", "fieldInfoLimit"]);
109
124
  var splitProps = BindPropsHelper.splitCommonEditorProps(otherProps);
110
125
  var nativeProps = splitProps.rest;
111
126
  var bindItemsProperty = bindItems;
112
127
  var itemList = (_a = bindItemsProperty) === null || _a === void 0 ? void 0 : _a.value;
113
128
  var bindValue = bind;
114
129
  var bindDisplayProperty = bindDisplay;
115
- var bindProperty = (bindItemsProperty !== null && bindItemsProperty !== void 0 ? bindItemsProperty : bindValue);
116
- var displayInfo = bindProperty.validator.getDisplayState(this.context.validationDisplayMode);
130
+ var displayInfo = this.bindProperty.validator.getDisplayState(this.context.validationDisplayMode);
117
131
  displayInfo.applyToDom(nativeProps, this.context.parentType !== EditorParentType.FormGroup);
118
132
  this.displayMember = (_b = this.props.displayMember, (_b !== null && _b !== void 0 ? _b : ""));
119
133
  this.valueMember = (_c = this.props.valueMember, (_c !== null && _c !== void 0 ? _c : ""));
@@ -130,6 +144,16 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
130
144
  var value = null;
131
145
  if (bindItems) {
132
146
  value = itemList.map(function (c) { return ({ value: c.id, label: c.display }); });
147
+ if (this.fieldInfoContainer && this.bindIdsProperty) {
148
+ var itemListString = "";
149
+ if (value.length > ((fieldInfoLimit !== null && fieldInfoLimit !== void 0 ? fieldInfoLimit : 5))) {
150
+ itemListString = value.length + " items selected";
151
+ }
152
+ else if (value.length > 0) {
153
+ itemListString = value.map(function (c) { return c.label; }).join(", ");
154
+ }
155
+ this.setFieldInfo(this.bindIdsProperty, itemListString, bindItemsProperty.propertyInfo.readableName);
156
+ }
133
157
  }
134
158
  else {
135
159
  if (bindValue.value !== null) {
@@ -170,7 +194,7 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
170
194
  }
171
195
  var userOnBlur = nativeProps.onBlur;
172
196
  nativeProps.onBlur = function (e) {
173
- bindProperty.validator.hasBlurred = true;
197
+ _this.bindProperty.validator.hasBlurred = true;
174
198
  if (userOnBlur !== undefined) {
175
199
  userOnBlur(e);
176
200
  }
@@ -1,7 +1,7 @@
1
1
  import { __assign, __decorate, __extends, __metadata } from "tslib";
2
2
  import * as React from 'react';
3
3
  import { BindPropsHelper } from '../PropTypes';
4
- import { Utils } from '@singularsystems/neo-core';
4
+ import { Model, Utils } from '@singularsystems/neo-core';
5
5
  import { observer } from 'mobx-react';
6
6
  import { InputHelpers } from '../InputHelpers';
7
7
  import { DropDownBase } from './DropDownBase';
@@ -12,6 +12,7 @@ var DropDown = /** @class */ (function (_super) {
12
12
  var _this = _super.call(this, props) || this;
13
13
  _this.listIndexSymbol = Symbol("ValueIndex");
14
14
  _this.onItemSelected = _this.onItemSelected.bind(_this);
15
+ _this.fieldInfoContainer = Model.ModelFieldInfo.asModelFieldInfoContainer(_this.props.bind.attachedTo);
15
16
  return _this;
16
17
  }
17
18
  Object.defineProperty(DropDown.prototype, "items", {
@@ -8,8 +8,9 @@ export declare abstract class DropDownBase<T, TProps> extends ComponentBase<TPro
8
8
  protected isLoading: boolean;
9
9
  protected dataSource: Data.IAsyncDataSource<T[]> | null;
10
10
  protected cachedDataSource: Data.IDataCacheEntry | null;
11
+ protected fieldInfoContainer: Model.IModelFieldInfoContainer | null;
11
12
  protected getItems(itemSource: ItemSource<T>): T[];
12
13
  afterRender(): Promise<void>;
13
14
  private fieldDisplayInfo;
14
- protected setFieldInfo(bindProperty: Model.IPropertyInstance, displayValue: string): void;
15
+ protected setFieldInfo(bindProperty: Model.IPropertyInstance, displayValue: string, readableName?: string): void;
15
16
  }
@@ -1,5 +1,5 @@
1
1
  import { __awaiter, __extends, __generator } from "tslib";
2
- import { Data, Model } from '@singularsystems/neo-core';
2
+ import { Data } from '@singularsystems/neo-core';
3
3
  import ComponentBase from '../ComponentBase';
4
4
  import LookupHelper from './LookupHelper';
5
5
  var DropDownBase = /** @class */ (function (_super) {
@@ -9,6 +9,7 @@ var DropDownBase = /** @class */ (function (_super) {
9
9
  _this.isLoading = false;
10
10
  _this.dataSource = null;
11
11
  _this.cachedDataSource = null;
12
+ _this.fieldInfoContainer = null;
12
13
  _this.fieldDisplayInfo = null;
13
14
  return _this;
14
15
  }
@@ -53,7 +54,7 @@ var DropDownBase = /** @class */ (function (_super) {
53
54
  };
54
55
  DropDownBase.prototype.afterRender = function () {
55
56
  return __awaiter(this, void 0, void 0, function () {
56
- var _a, bindProperty, displayValue, fieldInfo;
57
+ var _a, bindProperty, displayValue, readableName, fieldInfo;
57
58
  return __generator(this, function (_b) {
58
59
  if (this.cachedDataSource) {
59
60
  this.dataSource = this.cachedDataSource.get();
@@ -62,16 +63,12 @@ var DropDownBase = /** @class */ (function (_super) {
62
63
  this.dataSource.fetchInitial();
63
64
  }
64
65
  if (this.fieldDisplayInfo) {
65
- _a = this.fieldDisplayInfo, bindProperty = _a.bindProperty, displayValue = _a.displayValue;
66
+ _a = this.fieldDisplayInfo, bindProperty = _a.bindProperty, displayValue = _a.displayValue, readableName = _a.readableName;
66
67
  this.fieldDisplayInfo = null;
67
- if (bindProperty.attachedTo instanceof Model.CriteriaBase) {
68
- fieldInfo = bindProperty.attachedTo.fieldInfo[bindProperty.propertyInfo.propertyName];
69
- if (!fieldInfo) {
70
- fieldInfo = new Model.ModelFieldInfo(bindProperty.propertyInfo.readableName, displayValue);
71
- bindProperty.attachedTo.fieldInfo[bindProperty.propertyInfo.propertyName] = fieldInfo;
72
- }
73
- else {
74
- fieldInfo.valueString = displayValue;
68
+ if (this.fieldInfoContainer) {
69
+ fieldInfo = this.fieldInfoContainer.setModelFieldInfo(bindProperty.propertyInfo, displayValue);
70
+ if (readableName) {
71
+ fieldInfo.displayName = readableName;
75
72
  }
76
73
  }
77
74
  }
@@ -79,8 +76,10 @@ var DropDownBase = /** @class */ (function (_super) {
79
76
  });
80
77
  });
81
78
  };
82
- DropDownBase.prototype.setFieldInfo = function (bindProperty, displayValue) {
83
- this.fieldDisplayInfo = { bindProperty: bindProperty, displayValue: displayValue };
79
+ DropDownBase.prototype.setFieldInfo = function (bindProperty, displayValue, readableName) {
80
+ if (this.fieldInfoContainer) {
81
+ this.fieldDisplayInfo = { bindProperty: bindProperty, displayValue: displayValue, readableName: readableName };
82
+ }
84
83
  };
85
84
  return DropDownBase;
86
85
  }(ComponentBase));
@@ -143,7 +143,7 @@ var Column = /** @class */ (function (_super) {
143
143
  if (sortProperty && !this.suppressSort) {
144
144
  var sortInfo = this.context.dataView.sortInfo.find(function (c) { return c.column === sortProperty.propertyInfo; });
145
145
  if (sortInfo) {
146
- sortIcon = sortInfo.sortAscending ? "sort-alpha-down" : "sort-alpha-up";
146
+ sortIcon = sortInfo.sortAscending ? Misc.Settings.icons.sortAsc : Misc.Settings.icons.sortDesc;
147
147
  domProps.className = Utils.joinWithSpaces(domProps.className, "column-is-sorted");
148
148
  }
149
149
  domProps.className = Utils.joinWithSpaces(domProps.className, "column-sortable");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-react",
3
- "version": "0.10.56",
3
+ "version": "0.10.58",
4
4
  "description": "React application logic and components for the Neo client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "@types/rc-slider": "^8.6.5",
34
34
  "@types/react-color": "^3.0.1",
35
35
  "@types/react-select": "3.1.0",
36
- "@singularsystems/neo-core": "^0.10.58",
36
+ "@singularsystems/neo-core": "^0.10.63",
37
37
  "axios": "^0.21.1",
38
38
  "decimal.js-light": "2.5.1",
39
39
  "history": "4.10.1",
@@ -47,7 +47,7 @@
47
47
  "react-router-dom": "5.1.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "@singularsystems/neo-core": ">=0.10.58",
50
+ "@singularsystems/neo-core": ">=0.10.63",
51
51
  "axios": ">=0.21.1",
52
52
  "inversify": ">=5.0.1",
53
53
  "react": ">=16.13.1",
@@ -124,7 +124,7 @@
124
124
  margin: 8px 5px;
125
125
 
126
126
  td {
127
- padding: 13px 12px;
127
+ padding: 13px 0px;
128
128
  }
129
129
  }
130
130
 
@@ -132,7 +132,7 @@
132
132
  margin: 5px 8px;
133
133
 
134
134
  td {
135
- padding: 8px 10px;
135
+ padding: 8px 0px;
136
136
  }
137
137
  }
138
138
  }
package/styles/Forms.scss CHANGED
@@ -131,6 +131,11 @@ div.neo-form-group-floating {
131
131
  }
132
132
  }
133
133
 
134
+ .react-select-bs {
135
+ .react-select-bs__menu {
136
+ z-index: 2; /* Without this, checkboxes appear in front of the drop down menu. */
137
+ }
138
+ }
134
139
  .react-select-row {
135
140
  padding: 0.15rem 1rem 0.25rem 1rem;
136
141
  display: flex;