@singularsystems/neo-react 0.10.65 → 0.10.66

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.
@@ -23,8 +23,19 @@ var AutoRunner = /** @class */ (function () {
23
23
  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); });
24
24
  this.disposerImmediate = reaction(function () { return _this.accessAllValues(model, false, new Map(), ""); }, function () { return _this.runCallback(model, callback, 0); });
25
25
  }
26
+ Object.defineProperty(AutoRunner.prototype, "hasPending", {
27
+ get: function () {
28
+ return DebounceHelper.hasPending(this);
29
+ },
30
+ enumerable: false,
31
+ configurable: true
32
+ });
26
33
  AutoRunner.prototype.cancelPending = function () {
27
- DebounceHelper.cancelPending(this);
34
+ if (DebounceHelper.hasPending(this)) {
35
+ DebounceHelper.cancelPending(this);
36
+ return true;
37
+ }
38
+ return false;
28
39
  };
29
40
  AutoRunner.prototype.fireImmediate = function () {
30
41
  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.props.bind.propertyInfo.hasSortValue = true;
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
- this.setFieldInfo(this.props.bind, this.selectedItem[this.displayMember]);
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 = ((_b = (_a = splitProps.select) === null || _a === void 0 ? void 0 : _a.allowNulls) !== null && _b !== void 0 ? _b : this.props.bind.propertyInfo.allowNulls) || !value;
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 ((_c = splitProps.select) === null || _c === void 0 ? void 0 : _c.renderAsText) {
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 || ((_d = splitProps.select) === null || _d === void 0 ? void 0 : _d.deSelectText) === undefined) ? (_e = splitProps.select) === null || _e === void 0 ? void 0 : _e.nullText : (_f = splitProps.select) === null || _f === void 0 ? void 0 : _f.deSelectText;
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
  }
@@ -1,13 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { Components, Model } from '@singularsystems/neo-core';
3
- import { ItemCallback } from './PropTypes';
4
3
  export interface IFormProps<T extends Model.IModelBase> extends React.FormHTMLAttributes<HTMLElement>, Components.IFormOptions<T> {
5
4
  /**
6
5
  * Called when the form is submitted, but the model is not valid.
7
6
  * The justValidated parameter will be true if the validationDisplayMode is 'AfterSubmit', and this is the first submit attempt.
8
7
  */
9
8
  onInvalid?: (e: React.FormEvent, justValidated?: boolean) => void;
10
- children: React.ReactNode | React.ReactNode[] | ItemCallback<T>;
9
+ children: React.ReactNode | React.ReactNode[] | ((item: T, meta: Model.TransformMetaType<T>) => React.ReactNode);
11
10
  }
12
11
  export default class Form<T extends Model.IModelBase> extends React.Component<IFormProps<T>> {
13
12
  private reactionDisposer?;
@@ -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,11 +101,11 @@ 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 () { return (showAddButton || addButton || footerButtons || _this.gridContext.hasSummaries || footerContent !== undefined) &&
107
107
  React.createElement(TableSection, { type: "footer" },
108
- _this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta),
108
+ _this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta, true),
109
109
  footerContent !== undefined && footerContent(_this.gridContext.dataView.getItems()),
110
110
  (showAddButton || addButton || footerButtons) &&
111
111
  React.createElement(AddButtonRow, { addButton: addButton, showAddButton: showAddButton, additionalContent: footerButtons })); }))));
@@ -206,7 +206,7 @@ var ItemGroup = /** @class */ (function (_super) {
206
206
  ItemGroup.prototype.render = function () {
207
207
  this.context.currentItem = this.props.item;
208
208
  //this.context.inFirstRowInGroup = true;
209
- return (this.props.template(this.props.item, this.props.item.meta));
209
+ return (this.props.template(this.props.item, this.props.item.meta, false));
210
210
  };
211
211
  ItemGroup.contextType = GridContext;
212
212
  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
  }
75
79
  export declare class RowGroup extends React.Component<INeoRowGroupProps> {
76
80
  static contextType: React.Context<import("./Grid").GridContextParams<unknown>>;
@@ -75,7 +75,7 @@ var Row = /** @class */ (function (_super) {
75
75
  var output = ((this.props.showInHeader || inBody) &&
76
76
  React.createElement("tr", __assign({}, domProps),
77
77
  this.expandProperty && this.context.expandAll === undefined &&
78
- React.createElement(Column, { className: "neo-grid-expand-column" }, this.firstRowInGroup && inBody && this.expandProperty.value !== null &&
78
+ React.createElement(Column, { className: "neo-grid-expand-column" }, this.firstRowInGroup && inBody && this.context.hideExpandButton !== true && this.expandProperty.value !== null &&
79
79
  React.createElement(NeoButton, __assign({}, expandButtonOptions))),
80
80
  this.props.children));
81
81
  this.setGridContext();
@@ -193,6 +193,7 @@ 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 declare type ItemCallback<T> = (item: T, meta: TransformMetaType<T>) => React.ReactNode;
14
+ export declare 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?: string;
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": "0.10.65",
3
+ "version": "0.10.66",
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",
@@ -32,7 +32,7 @@
32
32
  "typescript": "4.5.5"
33
33
  },
34
34
  "dependencies": {
35
- "@singularsystems/neo-core": "0.10.77",
35
+ "@singularsystems/neo-core": "0.10.80",
36
36
  "@types/rc-slider": "^8.6.5",
37
37
  "@types/react-color": "^3.0.1",
38
38
  "@types/react-select": "3.1.0",
@@ -50,7 +50,7 @@
50
50
  "react-router-dom": "5.1.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@singularsystems/neo-core": ">=0.10.77",
53
+ "@singularsystems/neo-core": ">=0.10.80",
54
54
  "axios": ">=0.21.1",
55
55
  "inversify": ">=5.0.1",
56
56
  "react": ">=16.13.1",