@singularsystems/neo-react 1.0.0-beta.2 → 1.0.0-beta.3
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.
- package/dist/React/AutoRunner.js +12 -1
- package/dist/ReactComponents/DropDown/DropDown.d.ts +3 -0
- package/dist/ReactComponents/DropDown/DropDown.js +11 -6
- package/dist/ReactComponents/Grid/Grid.d.ts +1 -0
- package/dist/ReactComponents/Grid/Grid.js +3 -3
- package/dist/ReactComponents/Grid/Row.d.ts +4 -0
- package/dist/ReactComponents/Grid/Row.js +2 -1
- package/dist/ReactComponents/PropTypes.d.ts +1 -1
- package/dist/ReactComponents/Tabs/Tab.d.ts +1 -1
- package/package.json +3 -3
- package/CHANGELOG.md +0 -98
package/dist/React/AutoRunner.js
CHANGED
|
@@ -22,8 +22,19 @@ var AutoRunner = /** @class */ (function () {
|
|
|
22
22
|
this.disposerDelayed = reaction(function () { return _this.accessAllValues(model, true, new Map(), ""); }, function () { var _a; return _this.runCallback(model, callback, (_a = _this.options.delayMs) !== null && _a !== void 0 ? _a : 500); });
|
|
23
23
|
this.disposerImmediate = reaction(function () { return _this.accessAllValues(model, false, new Map(), ""); }, function () { return _this.runCallback(model, callback, 0); });
|
|
24
24
|
}
|
|
25
|
+
Object.defineProperty(AutoRunner.prototype, "hasPending", {
|
|
26
|
+
get: function () {
|
|
27
|
+
return DebounceHelper.hasPending(this);
|
|
28
|
+
},
|
|
29
|
+
enumerable: false,
|
|
30
|
+
configurable: true
|
|
31
|
+
});
|
|
25
32
|
AutoRunner.prototype.cancelPending = function () {
|
|
26
|
-
DebounceHelper.
|
|
33
|
+
if (DebounceHelper.hasPending(this)) {
|
|
34
|
+
DebounceHelper.cancelPending(this);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
27
38
|
};
|
|
28
39
|
AutoRunner.prototype.fireImmediate = function () {
|
|
29
40
|
DebounceHelper.executeImmediate(this);
|
|
@@ -26,6 +26,8 @@ export interface IDropDownSpecificProps<T> {
|
|
|
26
26
|
nullText?: string;
|
|
27
27
|
/** Text to display as the first item in the drop down list when the user is allowed to select a blank item. */
|
|
28
28
|
deSelectText?: string;
|
|
29
|
+
/** Set to true if the property should be sorted by value instead of display text. */
|
|
30
|
+
sortByValue?: boolean;
|
|
29
31
|
}
|
|
30
32
|
export interface IDropDownProps<T> extends IBindableEditorProps<HTMLSelectElement> {
|
|
31
33
|
select: IDropDownSpecificProps<T>;
|
|
@@ -34,6 +36,7 @@ export default class DropDown<T> extends DropDownBase<T, IDropDownProps<T>> {
|
|
|
34
36
|
static contextType: React.Context<import("../FormContext").FormContextParams>;
|
|
35
37
|
context: React.ContextType<typeof FormContext>;
|
|
36
38
|
private selectedItem;
|
|
39
|
+
private sortByValue?;
|
|
37
40
|
private listIndexSymbol;
|
|
38
41
|
constructor(props: IDropDownProps<T>);
|
|
39
42
|
private get items();
|
|
@@ -41,7 +41,9 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
41
41
|
list.forEach(function (item) { return index[item[_this.valueMember]] = item; });
|
|
42
42
|
};
|
|
43
43
|
DropDown.prototype.getSelectedOption = function (value) {
|
|
44
|
-
this.
|
|
44
|
+
if (!this.sortByValue) {
|
|
45
|
+
this.props.bind.propertyInfo.hasSortValue = true;
|
|
46
|
+
}
|
|
45
47
|
if (!this.selectedItem || this.selectedItem[this.valueMember] != value) {
|
|
46
48
|
var list = this.items;
|
|
47
49
|
var indexJustCreated = false;
|
|
@@ -61,7 +63,9 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
61
63
|
this.selectedItem[this.displayMember] = "";
|
|
62
64
|
this.selectedItem[this.valueMember] = null;
|
|
63
65
|
}
|
|
64
|
-
|
|
66
|
+
var displayValue = this.selectedItem[this.displayMember];
|
|
67
|
+
this.setFieldInfo(this.props.bind, displayValue);
|
|
68
|
+
this.props.bind.sortValue = this.sortByValue ? value : displayValue;
|
|
65
69
|
}
|
|
66
70
|
return this.selectedItem;
|
|
67
71
|
};
|
|
@@ -81,10 +85,11 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
81
85
|
};
|
|
82
86
|
DropDown.prototype.render = function () {
|
|
83
87
|
var _this = this;
|
|
84
|
-
var _a, _b, _c, _d, _e, _f;
|
|
88
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
85
89
|
var splitProps = BindPropsHelper.normaliseEditorProps(this, this.props);
|
|
86
90
|
var domProps = BindPropsHelper.autoSetDomProperties(splitProps, this.context);
|
|
87
91
|
domProps.className = Utils.joinWithSpaces(domProps.className, splitProps.isBootstrap ? "form-control" : "neo-forms-editor");
|
|
92
|
+
this.sortByValue = (_a = splitProps.select) === null || _a === void 0 ? void 0 : _a.sortByValue;
|
|
88
93
|
if (splitProps.select) {
|
|
89
94
|
if (splitProps.select.valueMember)
|
|
90
95
|
this.valueMember = splitProps.select.valueMember;
|
|
@@ -96,7 +101,7 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
96
101
|
var items = this.items;
|
|
97
102
|
var selectedItem = this.getSelectedOption(this.props.bind.value); // This sets the sort value to allow sorting of drop downs in grids.
|
|
98
103
|
var value = this.props.bind.value;
|
|
99
|
-
var addBlankItem = ((
|
|
104
|
+
var addBlankItem = ((_c = (_b = splitProps.select) === null || _b === void 0 ? void 0 : _b.allowNulls) !== null && _c !== void 0 ? _c : this.props.bind.propertyInfo.allowNulls) || !value;
|
|
100
105
|
if (addBlankItem && items.find(function (item) { return item[_this.valueMember] === null || item[_this.valueMember] === ""; })) {
|
|
101
106
|
// If there is an item with a null value, don't add a blank drop down item.
|
|
102
107
|
addBlankItem = false;
|
|
@@ -106,7 +111,7 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
106
111
|
control = React.createElement("div", { className: "form-control form-control-loading" },
|
|
107
112
|
React.createElement("div", { className: "spinner-border" }));
|
|
108
113
|
}
|
|
109
|
-
else if ((
|
|
114
|
+
else if ((_d = splitProps.select) === null || _d === void 0 ? void 0 : _d.renderAsText) {
|
|
110
115
|
control = React.createElement("span", null, selectedItem ? selectedItem[this.displayMember] : "");
|
|
111
116
|
}
|
|
112
117
|
else if (splitProps.editor.isReadOnly) {
|
|
@@ -117,7 +122,7 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
117
122
|
domProps.disabled = true;
|
|
118
123
|
}
|
|
119
124
|
var valueIsBlank = value === undefined || value === null;
|
|
120
|
-
var nullText = (valueIsBlank || ((
|
|
125
|
+
var nullText = (valueIsBlank || ((_e = splitProps.select) === null || _e === void 0 ? void 0 : _e.deSelectText) === undefined) ? (_f = splitProps.select) === null || _f === void 0 ? void 0 : _f.nullText : (_g = splitProps.select) === null || _g === void 0 ? void 0 : _g.deSelectText;
|
|
121
126
|
if (valueIsBlank) {
|
|
122
127
|
domProps.className = Utils.joinWithSpaces(domProps.className, "select-no-value");
|
|
123
128
|
}
|
|
@@ -11,6 +11,7 @@ export declare class GridContextParams<T> {
|
|
|
11
11
|
inFirstRowInGroup: boolean;
|
|
12
12
|
columnCount: number;
|
|
13
13
|
expandProperty?: Model.IPropertyInstance<boolean | null>;
|
|
14
|
+
hideExpandButton?: boolean;
|
|
14
15
|
expandAll?: boolean;
|
|
15
16
|
hasSummaries: boolean;
|
|
16
17
|
dataView: Data.DataViewBase<T>;
|
|
@@ -101,12 +101,12 @@ var Grid = /** @class */ (function (_super) {
|
|
|
101
101
|
}
|
|
102
102
|
return (React.createElement("table", __assign({}, domProps, { className: className, ref: this.domRef }),
|
|
103
103
|
React.createElement(GridContext.Provider, { value: this.gridContext },
|
|
104
|
-
React.createElement(TableSection, { type: "header" }, this.headerItem && this.props.children(this.headerItem, this.headerItem.meta)),
|
|
104
|
+
React.createElement(TableSection, { type: "header" }, this.headerItem && this.props.children(this.headerItem, this.headerItem.meta, true)),
|
|
105
105
|
React.createElement(TableSection, { type: "body" }, this.gridContext.dataView.getItems().map(function (item) { return (React.createElement(ItemGroup, { item: item, key: keyProperty ? item[keyProperty] : item.entityIdentifier, template: _this.props.children })); })),
|
|
106
106
|
React.createElement(Observer, null, function () {
|
|
107
107
|
return React.createElement(React.Fragment, null, (showAddButton || addButton || footerButtons || _this.gridContext.hasSummaries || footerContent !== undefined) &&
|
|
108
108
|
React.createElement(TableSection, { type: "footer" },
|
|
109
|
-
_this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta),
|
|
109
|
+
_this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta, true),
|
|
110
110
|
footerContent !== undefined && footerContent(_this.gridContext.dataView.getItems()),
|
|
111
111
|
(showAddButton || addButton || footerButtons) &&
|
|
112
112
|
React.createElement(AddButtonRow, { addButton: addButton, showAddButton: showAddButton, additionalContent: footerButtons })));
|
|
@@ -208,7 +208,7 @@ var ItemGroup = /** @class */ (function (_super) {
|
|
|
208
208
|
ItemGroup.prototype.render = function () {
|
|
209
209
|
this.context.currentItem = this.props.item;
|
|
210
210
|
//this.context.inFirstRowInGroup = true;
|
|
211
|
-
return (this.props.template(this.props.item, this.props.item.meta));
|
|
211
|
+
return (this.props.template(this.props.item, this.props.item.meta, false));
|
|
212
212
|
};
|
|
213
213
|
ItemGroup.contextType = GridContext;
|
|
214
214
|
ItemGroup = __decorate([
|
|
@@ -71,6 +71,10 @@ interface INeoRowGroupProps {
|
|
|
71
71
|
* To hide the expand button, return null.
|
|
72
72
|
*/
|
|
73
73
|
expandProperty?: Model.IPropertyInstance<boolean | null>;
|
|
74
|
+
/**
|
|
75
|
+
* Hides the expansion button on this row.
|
|
76
|
+
*/
|
|
77
|
+
hideExpandButton?: boolean;
|
|
74
78
|
children: React.ReactNode;
|
|
75
79
|
}
|
|
76
80
|
export declare class RowGroup extends React.Component<INeoRowGroupProps> {
|
|
@@ -76,7 +76,7 @@ var Row = /** @class */ (function (_super) {
|
|
|
76
76
|
var output = ((this.props.showInHeader || inBody) &&
|
|
77
77
|
React.createElement("tr", __assign({}, domProps),
|
|
78
78
|
this.expandProperty && this.context.expandAll === undefined &&
|
|
79
|
-
React.createElement(Column, { className: "neo-grid-expand-column" }, this.firstRowInGroup && inBody && this.expandProperty.value !== null &&
|
|
79
|
+
React.createElement(Column, { className: "neo-grid-expand-column" }, this.firstRowInGroup && inBody && this.context.hideExpandButton !== true && this.expandProperty.value !== null &&
|
|
80
80
|
React.createElement(NeoButton, __assign({}, expandButtonOptions))),
|
|
81
81
|
this.props.children));
|
|
82
82
|
this.setGridContext();
|
|
@@ -193,6 +193,7 @@ export var RowGroup = /** @class */ (function (_super) {
|
|
|
193
193
|
RowGroup.prototype.render = function () {
|
|
194
194
|
this.context.expandProperty = this.props.expandProperty;
|
|
195
195
|
this.context.inFirstRowInGroup = true;
|
|
196
|
+
this.context.hideExpandButton = this.props.hideExpandButton;
|
|
196
197
|
return this.props.children;
|
|
197
198
|
};
|
|
198
199
|
RowGroup.contextType = GridContext;
|
|
@@ -11,7 +11,7 @@ import PropertyInfo from '@singularsystems/neo-core/dist/Model/PropertyInfo';
|
|
|
11
11
|
import { IComponentBase } from './ComponentBase';
|
|
12
12
|
import FileInput, { IFileEditorProps } from './FileManager/FileInput';
|
|
13
13
|
import { FormContextParams } from './FormContext';
|
|
14
|
-
export type ItemCallback<T> = (item: T, meta: TransformMetaType<T
|
|
14
|
+
export type ItemCallback<T> = (item: T, meta: TransformMetaType<T>, isHeader: boolean) => React.ReactNode;
|
|
15
15
|
export declare enum ControlType {
|
|
16
16
|
Date = 0,
|
|
17
17
|
Number = 1,
|
|
@@ -9,7 +9,7 @@ interface ITabProps {
|
|
|
9
9
|
/** Name used for binding to selected tab. (Same as id property) */
|
|
10
10
|
name?: string;
|
|
11
11
|
/** Icon to display in tab header. */
|
|
12
|
-
icon?:
|
|
12
|
+
icon?: any;
|
|
13
13
|
/** True if the tab is disabled and not allowed to be clicked on. */
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"typescript": "5.0.4"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@singularsystems/neo-core": "1.0.0-beta.
|
|
32
|
+
"@singularsystems/neo-core": "1.0.0-beta.5",
|
|
33
33
|
"@types/rc-slider": "^8.6.5",
|
|
34
34
|
"@types/react-color": "^3.0.1",
|
|
35
35
|
"axios": "1.4.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"tslib": "2.5.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@singularsystems/neo-core": ">=1.0.0-beta.
|
|
51
|
+
"@singularsystems/neo-core": ">=1.0.0-beta.5",
|
|
52
52
|
"axios": "1.4.0",
|
|
53
53
|
"inversify": ">=5.0.1",
|
|
54
54
|
"mobx": ">=6.9.0",
|
package/CHANGELOG.md
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# Version 1.x
|
|
2
|
-
|
|
3
|
-
Version 1 of neo-react upgrades react to version 18, and mobX to version 6. Both of these are major updates and will require you to make code changes to your project.
|
|
4
|
-
|
|
5
|
-
## Testing
|
|
6
|
-
|
|
7
|
-
In addition to requiring code / syntax changes, both React 18, and Mobx 6 behave differently enough to their previous versions that runtime bugs may be introduced into your project. You should only update to this version when you and the client have enough time to test the project thoroughly. If you find any issues, please report them so this document can be updated.
|
|
8
|
-
|
|
9
|
-
The project changes required are detailed below:
|
|
10
|
-
|
|
11
|
-
## Package changes:
|
|
12
|
-
|
|
13
|
-
* Update all neo packages to the latest 1.x version.
|
|
14
|
-
* Update the following packages to the latest version (these were the latest at time of writing):
|
|
15
|
-
* dependencies
|
|
16
|
-
* `"axios": "1.4.0"`,
|
|
17
|
-
* `"mobx": "6.9.0"`,
|
|
18
|
-
* `"mobx-react": "7.6.0"`,
|
|
19
|
-
* `"react": "18.2.0"`,
|
|
20
|
-
* `"react-dom": "18.2.0"`,
|
|
21
|
-
* `"react-router": "5.2.1"`, - Must be version 5.x
|
|
22
|
-
* `"react-router-dom": "5.3.0"`, - Must be version 5.x
|
|
23
|
-
* `"react-select": "5.7.3"`,
|
|
24
|
-
|
|
25
|
-
* devDependencies
|
|
26
|
-
* `"@types/react": "18.2.4"`,
|
|
27
|
-
* `"@types/react-dom": "18.2.3"`,
|
|
28
|
-
* `"@types/react-router": "5.1.17"`, - Must be version 5.x
|
|
29
|
-
* `"@types/react-router-dom": "5.3.3"`, - Must be version 5.x
|
|
30
|
-
* resolutions
|
|
31
|
-
* remove all entries
|
|
32
|
-
* delete yarn.lock, and run `yarn install`
|
|
33
|
-
|
|
34
|
-
## Fix errors
|
|
35
|
-
|
|
36
|
-
If any of your components allow children, React 18 requires to you have an explicit `children` prop. Add this to the props definition of the component:
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
interface MyProps {
|
|
40
|
-
...
|
|
41
|
-
children: React.ReactNode;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// or if the component has no other props:
|
|
45
|
-
|
|
46
|
-
MyComponent extends React.Component<{ children: React.ReactNode }> {
|
|
47
|
-
...
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
The React root api has also changed in version 18. Make the following changes to your `index.tsx` file:
|
|
52
|
-
|
|
53
|
-
Your existing code will look something like this:
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
import ReactDOM from 'react-dom';
|
|
57
|
-
...
|
|
58
|
-
// React init
|
|
59
|
-
ReactDOM.render(
|
|
60
|
-
renderComponent,
|
|
61
|
-
document.getElementById('root') as HTMLElement
|
|
62
|
-
);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Change the `ReactDOM` import, and the react init code:
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
import ReactDOM from 'react-dom/client';
|
|
69
|
-
...
|
|
70
|
-
// React init
|
|
71
|
-
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
|
72
|
-
root.render(renderComponent);
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Mobx
|
|
76
|
-
|
|
77
|
-
Before mobx 6, you could mark a property as being observable by adding an `@observable` decorator to the property. In mobx 6 this no longer works ([read more](https://mobx.js.org/migrating-from-4-or-5.html)).
|
|
78
|
-
|
|
79
|
-
For any class that extends `ModelBase`, `ValueObject`, `ViewModelBase` etc, this change is handled by neo, and you will not need to change any code.
|
|
80
|
-
|
|
81
|
-
For other classes, you will need to add initialisation code to the constructor.
|
|
82
|
-
|
|
83
|
-
* Search for `@observable` in your project. (In most projects this will be in the Sidebar and AppLayout components)
|
|
84
|
-
* In the constructor of the class that contains the property, add:
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
makeObservable(this);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Decorators on neo models
|
|
91
|
-
|
|
92
|
-
If you try use mobx decorators on any models that extend `ModelBase`, `ValueObject` or `ViewModelBase`, you will receive this error:
|
|
93
|
-
|
|
94
|
-
> [MobX] makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.
|
|
95
|
-
|
|
96
|
-
This is most likely because you have used an `@action` decorator on a method. Neo now marks all methods as actions, so you can remove the `@action` decorator.
|
|
97
|
-
|
|
98
|
-
* Search for `@action` in your project. Remove the decorator **only** if the class extends `ModelBase` (and its decendents e.g. `ValueObject`) or `ViewModelBase`.
|