@singularsystems/neo-react 1.0.0-beta.0 → 1.0.0-beta.2
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/CHANGELOG.md +7 -7
- package/dist/React/Decorators.js +0 -1
- package/dist/ReactComponents/Button.js +5 -4
- package/dist/ReactComponents/Card.js +4 -3
- package/dist/ReactComponents/DatePicker.d.ts +1 -0
- package/dist/ReactComponents/DatePicker.js +6 -2
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +4 -0
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +4 -1
- package/dist/ReactComponents/Grid/ButtonColumn.d.ts +2 -1
- package/dist/ReactComponents/Grid/ButtonColumn.js +1 -1
- package/dist/ReactComponents/Grid/Grid.d.ts +11 -3
- package/dist/ReactComponents/Grid/Grid.js +23 -8
- package/dist/ReactComponents/Grid/StickyTableHeader.d.ts +27 -0
- package/dist/ReactComponents/Grid/StickyTableHeader.js +107 -0
- package/dist/ReactComponents/Icons/IIconFactory.d.ts +6 -0
- package/dist/ReactComponents/Icons/Icon.d.ts +13 -0
- package/dist/ReactComponents/Icons/Icon.js +27 -0
- package/dist/ReactComponents/Icons/IconFactory.js +7 -1
- package/dist/ReactComponents/Icons/MaterialSymbolsFontFactory.d.ts +21 -0
- package/dist/ReactComponents/Icons/MaterialSymbolsFontFactory.js +114 -0
- package/dist/ReactComponents/Icons/index.d.ts +2 -1
- package/dist/ReactComponents/Icons/index.js +1 -0
- package/dist/ReactComponents/Input.js +1 -1
- package/dist/ReactComponents/InputHelpers.d.ts +1 -1
- package/dist/ReactComponents/InputHelpers.js +3 -3
- package/dist/ReactComponents/Modal/Modal.js +4 -0
- package/dist/ReactComponents/NumberInput.js +14 -7
- package/dist/ReactComponents/Paging/Pager.d.ts +1 -0
- package/dist/ReactComponents/Paging/Pager.js +3 -0
- package/dist/ReactComponents/PropTypes.d.ts +3 -10
- package/dist/ReactComponents/PropTypes.js +12 -2
- package/dist/ReactComponents/TooltipProvider.js +2 -1
- package/dist/ReactComponents/_Exports.d.ts +2 -1
- package/dist/ReactComponents/_Exports.js +2 -1
- package/dist/Routing/RoutingState.d.ts +2 -0
- package/dist/Routing/RoutingState.js +27 -1
- package/dist/Routing/ViewParameterList.d.ts +9 -3
- package/dist/Routing/ViewParameterList.js +7 -4
- package/dist/Views/ViewBase.d.ts +3 -0
- package/dist/Views/ViewBase.js +8 -1
- package/dist/Views/ViewModelBase.d.ts +1 -1
- package/package.json +3 -3
- package/styles/Card.scss +8 -1
- package/styles/DatePicker.scss +11 -0
- package/styles/Grid.scss +5 -0
- package/dist/Declarations.d.ts +0 -3
- package/dist/Declarations.js +0 -0
- package/dist/Modules/NeoReactModule.js.map +0 -1
- package/dist/Modules/ReactSetup.js.map +0 -1
- package/dist/Modules/Types.js.map +0 -1
- package/dist/React/AutoRunner.js.map +0 -1
- package/dist/React/DataView.js.map +0 -1
- package/dist/React/Decorators.js.map +0 -1
- package/dist/React/ReactModelCreator.js.map +0 -1
- package/dist/React/Utils.js.map +0 -1
- package/dist/ReactComponents/Button.js.map +0 -1
- package/dist/ReactComponents/Card.js.map +0 -1
- package/dist/ReactComponents/Collapsable.js.map +0 -1
- package/dist/ReactComponents/CollapsableBase.js.map +0 -1
- package/dist/ReactComponents/ColorPicker.js.map +0 -1
- package/dist/ReactComponents/ComponentBase.js.map +0 -1
- package/dist/ReactComponents/ContextMenu/ContextMenu.js.map +0 -1
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.js.map +0 -1
- package/dist/ReactComponents/ContextMenu/ContextMenuState.js.map +0 -1
- package/dist/ReactComponents/DatePicker.js.map +0 -1
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js.map +0 -1
- package/dist/ReactComponents/DropDown/DropDown.js.map +0 -1
- package/dist/ReactComponents/DropDown/DropDownBase.js.map +0 -1
- package/dist/ReactComponents/ErrorHandler.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileBasicInput.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileContext.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileDropArea.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileInput.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileUploadButton.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileUploadProgress.js.map +0 -1
- package/dist/ReactComponents/Form.js.map +0 -1
- package/dist/ReactComponents/FormContext.js.map +0 -1
- package/dist/ReactComponents/FormGroup/FormGroup.js.map +0 -1
- package/dist/ReactComponents/FormGroup/FormGroupFloating.js.map +0 -1
- package/dist/ReactComponents/FormGroup/FormGroupInline.js.map +0 -1
- package/dist/ReactComponents/Grid/ButtonColumn.js.map +0 -1
- package/dist/ReactComponents/Grid/Column.js.map +0 -1
- package/dist/ReactComponents/Grid/ColumnHelper.js.map +0 -1
- package/dist/ReactComponents/Grid/Grid.js.map +0 -1
- package/dist/ReactComponents/Grid/Row.js.map +0 -1
- package/dist/ReactComponents/Grid/_Exports.js.map +0 -1
- package/dist/ReactComponents/GridLayout.js.map +0 -1
- package/dist/ReactComponents/Input.js.map +0 -1
- package/dist/ReactComponents/InputHelpers.js.map +0 -1
- package/dist/ReactComponents/Loader.js.map +0 -1
- package/dist/ReactComponents/Modal/Modal.js.map +0 -1
- package/dist/ReactComponents/Modal/ModalContainer.js.map +0 -1
- package/dist/ReactComponents/Modal/ModalPortal.js.map +0 -1
- package/dist/ReactComponents/Notifications/Alert.js.map +0 -1
- package/dist/ReactComponents/Notifications/Toast.js.map +0 -1
- package/dist/ReactComponents/Notifications/ToastContainer.js.map +0 -1
- package/dist/ReactComponents/NumberInput.js.map +0 -1
- package/dist/ReactComponents/Paging/BasicPagerControls.js.map +0 -1
- package/dist/ReactComponents/Paging/PageSizeControl.js.map +0 -1
- package/dist/ReactComponents/Paging/Pager.js.map +0 -1
- package/dist/ReactComponents/ProgressBar.js.map +0 -1
- package/dist/ReactComponents/PropTypes.js.map +0 -1
- package/dist/ReactComponents/RadioList.js.map +0 -1
- package/dist/ReactComponents/ReactHelpers.d.ts +0 -5
- package/dist/ReactComponents/ReactHelpers.js +0 -17
- package/dist/ReactComponents/ReactHelpers.js.map +0 -1
- package/dist/ReactComponents/Slider.js.map +0 -1
- package/dist/ReactComponents/StateObserver.js.map +0 -1
- package/dist/ReactComponents/Tabs/Tab.js.map +0 -1
- package/dist/ReactComponents/Tabs/TabContainer.js.map +0 -1
- package/dist/ReactComponents/Tabs/TabManager.js.map +0 -1
- package/dist/ReactComponents/Tooltip.js.map +0 -1
- package/dist/ReactComponents/TooltipHelper.js.map +0 -1
- package/dist/ReactComponents/TooltipProvider.js.map +0 -1
- package/dist/ReactComponents/ValidationSummary.js.map +0 -1
- package/dist/ReactComponents/_Exports.js.map +0 -1
- package/dist/ReactComponents/_Managers.js.map +0 -1
- package/dist/Routing/BreadCrumbItem.js.map +0 -1
- package/dist/Routing/IRouteChangedProps.js.map +0 -1
- package/dist/Routing/IRouteParameter.js.map +0 -1
- package/dist/Routing/MenuRoute.js.map +0 -1
- package/dist/Routing/NavigationHelper.js.map +0 -1
- package/dist/Routing/PageLeaveHandler.js.map +0 -1
- package/dist/Routing/RouteProvider.js.map +0 -1
- package/dist/Routing/RouteView.js.map +0 -1
- package/dist/Routing/RoutingState.js.map +0 -1
- package/dist/Routing/ViewParameter.js.map +0 -1
- package/dist/Routing/ViewParameterList.js.map +0 -1
- package/dist/Routing/index.js.map +0 -1
- package/dist/Services/DisposeHelper.js.map +0 -1
- package/dist/Services/IDisposeHelper.js.map +0 -1
- package/dist/Views/EmptyViewModel.js.map +0 -1
- package/dist/Views/IViewModel.js.map +0 -1
- package/dist/Views/PersistentViewBase.js.map +0 -1
- package/dist/Views/ViewBase.js.map +0 -1
- package/dist/Views/ViewComponentBase.js.map +0 -1
- package/dist/Views/ViewModelBase.js.map +0 -1
- package/dist/Views/ViewState.js.map +0 -1
- package/dist/Views/index.js.map +0 -1
- package/dist/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
-
|
|
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:
|
|
6
10
|
|
|
7
11
|
## Package changes:
|
|
8
12
|
|
|
@@ -85,14 +89,10 @@ makeObservable(this);
|
|
|
85
89
|
|
|
86
90
|
### Decorators on neo models
|
|
87
91
|
|
|
88
|
-
If you try use mobx decorators on any models that extend `ModelBase` or `ViewModelBase`, you will receive this error:
|
|
92
|
+
If you try use mobx decorators on any models that extend `ModelBase`, `ValueObject` or `ViewModelBase`, you will receive this error:
|
|
89
93
|
|
|
90
94
|
> [MobX] makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.
|
|
91
95
|
|
|
92
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.
|
|
93
97
|
|
|
94
|
-
* Search for `@action` in your project. Remove the decorator **only** if the class extends `ModelBase` or `ViewModelBase`.
|
|
95
|
-
|
|
96
|
-
## Testing
|
|
97
|
-
|
|
98
|
-
Both React 18, and Mobx 6 behave differently enough to their previous versions that new bugs are almost guaranteed. 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.
|
|
98
|
+
* Search for `@action` in your project. Remove the decorator **only** if the class extends `ModelBase` (and its decendents e.g. `ValueObject`) or `ViewModelBase`.
|
package/dist/React/Decorators.js
CHANGED
|
@@ -50,11 +50,12 @@ var Button = /** @class */ (function (_super) {
|
|
|
50
50
|
};
|
|
51
51
|
Button.prototype.render = function () {
|
|
52
52
|
var _this = this;
|
|
53
|
-
var _a
|
|
53
|
+
var _a;
|
|
54
|
+
var _b = this.props, isSubmit = _b.isSubmit, variant = _b.variant, size = _b.size, isOutline = _b.isOutline, icon = _b.icon, iconAlignment = _b.iconAlignment, text = _b.text, menuItems = _b.menuItems, splitMenu = _b.splitMenu, menuAlignment = _b.menuAlignment, buttonGroupClassName = _b.buttonGroupClassName, tooltip = _b.tooltip, task = _b.task, isBusy = _b.isBusy, pulse = _b.pulse, customVariant = _b.customVariant, native = __rest(_b, ["isSubmit", "variant", "size", "isOutline", "icon", "iconAlignment", "text", "menuItems", "splitMenu", "menuAlignment", "buttonGroupClassName", "tooltip", "task", "isBusy", "pulse", "customVariant"]);
|
|
54
55
|
native.type = isSubmit ? "submit" : "button";
|
|
55
|
-
|
|
56
|
+
var variantClassName = ((_a = customVariant !== null && customVariant !== void 0 ? customVariant : variant) !== null && _a !== void 0 ? _a : "primary");
|
|
56
57
|
var isDropDown = menuItems && menuItems.length;
|
|
57
|
-
var buttonClasses = "btn btn-" + (isOutline ? "outline-" : "") +
|
|
58
|
+
var buttonClasses = "btn btn-" + (isOutline ? "outline-" : "") + variantClassName;
|
|
58
59
|
if (size)
|
|
59
60
|
buttonClasses += " btn-" + size;
|
|
60
61
|
if (isDropDown && !splitMenu) {
|
|
@@ -72,7 +73,7 @@ var Button = /** @class */ (function (_super) {
|
|
|
72
73
|
native.disabled = true;
|
|
73
74
|
}
|
|
74
75
|
if (pulse) {
|
|
75
|
-
buttonClasses += " ".concat(
|
|
76
|
+
buttonClasses += " ".concat(variantClassName, "-color-pulse");
|
|
76
77
|
}
|
|
77
78
|
native.className = (native.className || "") + " " + buttonClasses;
|
|
78
79
|
// Button text
|
|
@@ -19,7 +19,7 @@ var Card = /** @class */ (function (_super) {
|
|
|
19
19
|
var isCollapsible = collapsible || isExpanded !== undefined || initiallyCollapsed !== undefined;
|
|
20
20
|
var expandState = isExpanded !== null && isExpanded !== void 0 ? isExpanded : this.expandState;
|
|
21
21
|
if (isCollapsible) {
|
|
22
|
-
var expandIndicator = React.createElement("i", { onClick: function () { return expandState.value = !expandState.value; }, className: "card-expand-indicator fa fa-fw fa-angle-".concat(expandState.value ? "up" : "down") });
|
|
22
|
+
var expandIndicator = React.createElement("i", { onClick: function (e) { return expandState.value = !expandState.value; }, className: "card-expand-indicator fa fa-fw fa-angle-".concat(expandState.value ? "up" : "down") });
|
|
23
23
|
if (headerElements) {
|
|
24
24
|
headerElements = React.createElement(React.Fragment, null,
|
|
25
25
|
headerElements,
|
|
@@ -31,6 +31,7 @@ var Card = /** @class */ (function (_super) {
|
|
|
31
31
|
if (!expandState.value) {
|
|
32
32
|
className += " collapsed";
|
|
33
33
|
}
|
|
34
|
+
className += " card-collapsible";
|
|
34
35
|
}
|
|
35
36
|
var body = React.createElement("div", { className: "card-body" },
|
|
36
37
|
useCustomScrollbar && React.createElement(Scrollbar, null, children),
|
|
@@ -41,11 +42,11 @@ var Card = /** @class */ (function (_super) {
|
|
|
41
42
|
}
|
|
42
43
|
return (React.createElement("div", __assign({}, domProps, { className: className }),
|
|
43
44
|
(icon || title) &&
|
|
44
|
-
React.createElement("div", { className: "card-header" },
|
|
45
|
+
React.createElement("div", { className: "card-header", onClick: function (e) { return expandState.value = !expandState.value; } },
|
|
45
46
|
React.createElement("div", { className: "card-header-title" },
|
|
46
47
|
this.iconFactory.getIconComponent(icon),
|
|
47
48
|
React.createElement("span", null, title)),
|
|
48
|
-
headerElements && React.createElement("div", { className: "card-header-right-section" }, headerElements)),
|
|
49
|
+
headerElements && React.createElement("div", { className: "card-header-right-section", onClick: function (e) { return e.stopPropagation(); } }, headerElements)),
|
|
49
50
|
body));
|
|
50
51
|
};
|
|
51
52
|
Card = __decorate([
|
|
@@ -12,6 +12,7 @@ export default class DatePicker extends ComponentBase<INeoDatePickerProps> {
|
|
|
12
12
|
private container;
|
|
13
13
|
private datePicker?;
|
|
14
14
|
private isReadOnly;
|
|
15
|
+
private inputRef;
|
|
15
16
|
constructor(props: INeoDatePickerProps);
|
|
16
17
|
componentDidMount(): void;
|
|
17
18
|
componentWillUnmount(): void;
|
|
@@ -11,6 +11,7 @@ var DatePicker = /** @class */ (function (_super) {
|
|
|
11
11
|
function DatePicker(props) {
|
|
12
12
|
var _this = _super.call(this, props) || this;
|
|
13
13
|
_this.isReadOnly = false;
|
|
14
|
+
_this.inputRef = React.createRef();
|
|
14
15
|
_this.container = React.createRef();
|
|
15
16
|
return _this;
|
|
16
17
|
}
|
|
@@ -33,6 +34,9 @@ var DatePicker = /** @class */ (function (_super) {
|
|
|
33
34
|
this.isReadOnly = !!domProps.readOnly;
|
|
34
35
|
var displayInfo = this.props.bind.validator.getDisplayState(this.context.validationDisplayMode);
|
|
35
36
|
displayInfo.applyToDom(domProps, !splitProps.inGroup);
|
|
37
|
+
if (splitProps.editor.inputElement) {
|
|
38
|
+
this.inputRef = splitProps.editor.inputElement;
|
|
39
|
+
}
|
|
36
40
|
if (this.datePicker) {
|
|
37
41
|
this.datePicker.update(splitProps.dateProps, this.props.bind, this.isReadOnly);
|
|
38
42
|
}
|
|
@@ -40,8 +44,8 @@ var DatePicker = /** @class */ (function (_super) {
|
|
|
40
44
|
// Create dependency on bound value on initial render.
|
|
41
45
|
void this.props.bind.value;
|
|
42
46
|
}
|
|
43
|
-
return (React.createElement("div", { className: "neo-datepicker-container", ref: this.container },
|
|
44
|
-
InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({ type: "text" }, domProps, { ref:
|
|
47
|
+
return (React.createElement("div", { className: "neo-datepicker-container", ref: this.container }, Components.DatePicker.mustShowInput(splitProps.dateProps) &&
|
|
48
|
+
InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({ type: "text" }, domProps, { ref: this.inputRef })), splitProps.editor, this.inputRef)));
|
|
45
49
|
};
|
|
46
50
|
DatePicker.contextType = FormContext;
|
|
47
51
|
DatePicker = __decorate([
|
|
@@ -21,6 +21,10 @@ interface IAutoCompleteCommonProps<T> extends ICommonEditorProps, Props<IOption,
|
|
|
21
21
|
items?: ItemSource<T>;
|
|
22
22
|
valueMember?: keyof T;
|
|
23
23
|
displayMember?: keyof T;
|
|
24
|
+
/**
|
|
25
|
+
* Function used to filter items out of the datasource.
|
|
26
|
+
* **Note:** this will only apply to the `items` prop. */
|
|
27
|
+
filterPredicate?: (item: T) => boolean;
|
|
24
28
|
/**
|
|
25
29
|
* Property of an item to use as the description.
|
|
26
30
|
*
|
|
@@ -137,6 +137,9 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
137
137
|
var defaultItems = undefined;
|
|
138
138
|
if (this.props.items) {
|
|
139
139
|
var items_1 = this.getItems(this.props.items);
|
|
140
|
+
if (this.props.filterPredicate !== undefined) {
|
|
141
|
+
items_1 = items_1.filter(this.props.filterPredicate);
|
|
142
|
+
}
|
|
140
143
|
defaultItems = this.mapTArrayToOptions(items_1);
|
|
141
144
|
if (descriptionMember === undefined && items_1.length > 0) {
|
|
142
145
|
if (EnumHelper.isEnumItem(items_1[0])) {
|
|
@@ -188,7 +191,7 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
188
191
|
if (nativeProps.isClearable === undefined) {
|
|
189
192
|
nativeProps.isClearable = true;
|
|
190
193
|
}
|
|
191
|
-
if (splitProps.editor.
|
|
194
|
+
if (BindPropsHelper.isReadOnly(splitProps.editor, this.context) || BindPropsHelper.isDisabled(splitProps.editor, this.context)) {
|
|
192
195
|
nativeProps.isDisabled = true;
|
|
193
196
|
}
|
|
194
197
|
nativeProps.className = Utils.joinWithSpaces("react-select-bs", nativeProps.className);
|
|
@@ -13,7 +13,7 @@ interface IDeleteButtonOptions extends IButtonOptions {
|
|
|
13
13
|
*/
|
|
14
14
|
onDeleteExisting?: (item: any) => Promise<boolean>;
|
|
15
15
|
}
|
|
16
|
-
export interface IButtonColumnProps extends INeoCommonColumnProps, React.HTMLProps<HTMLTableCellElement> {
|
|
16
|
+
export interface IButtonColumnProps extends INeoCommonColumnProps, Omit<React.HTMLProps<HTMLTableCellElement>, "children"> {
|
|
17
17
|
/** Item to pass to edit and delete callbacks. Defaults to the current rows item */
|
|
18
18
|
item?: any;
|
|
19
19
|
/** Text to show in the header. */
|
|
@@ -32,6 +32,7 @@ export interface IButtonColumnProps extends INeoCommonColumnProps, React.HTMLPro
|
|
|
32
32
|
viewButton?: IButtonOptions;
|
|
33
33
|
/** Where should extra content be placed relative to the pre-defined buttons? */
|
|
34
34
|
childAlignment?: "left" | "right";
|
|
35
|
+
children?: React.ReactNode | (() => React.ReactNode);
|
|
35
36
|
}
|
|
36
37
|
export declare class ButtonColumn extends ComponentBase<IButtonColumnProps> {
|
|
37
38
|
static isColumnComponent: boolean;
|
|
@@ -72,7 +72,7 @@ export var ButtonColumn = /** @class */ (function (_super) {
|
|
|
72
72
|
React.createElement("th", __assign({}, domProps), this.section === "header" && label) :
|
|
73
73
|
React.createElement("td", __assign({}, domProps),
|
|
74
74
|
childAlignment === "right" ? buttons : undefined,
|
|
75
|
-
this.props.children,
|
|
75
|
+
this.props.children instanceof Function ? this.props.children() : this.props.children,
|
|
76
76
|
childAlignment !== "right" ? buttons : undefined));
|
|
77
77
|
};
|
|
78
78
|
ButtonColumn.isColumnComponent = true;
|
|
@@ -17,7 +17,7 @@ export declare class GridContextParams<T> {
|
|
|
17
17
|
get inBody(): boolean;
|
|
18
18
|
}
|
|
19
19
|
export declare const GridContext: React.Context<GridContextParams<unknown>>;
|
|
20
|
-
interface IGridProps<T> extends Omit<React.HTMLProps<HTMLTableElement>, "children"> {
|
|
20
|
+
export interface IGridProps<T> extends Omit<React.HTMLProps<HTMLTableElement>, "children"> {
|
|
21
21
|
/**
|
|
22
22
|
* Datasource of the Grid. Usually a neo List, but can be a js array. This is not required if the grid is nested in
|
|
23
23
|
* a DataViewProvider like a Pager or DataScroller
|
|
@@ -51,6 +51,7 @@ interface IGridProps<T> extends Omit<React.HTMLProps<HTMLTableElement>, "childre
|
|
|
51
51
|
*/
|
|
52
52
|
initialSort?: keyof T | (keyof T)[];
|
|
53
53
|
initialSortAscending?: boolean | boolean[];
|
|
54
|
+
children: ItemCallback<T>;
|
|
54
55
|
/**
|
|
55
56
|
* When specified, the default bootstrap table borders (sides and cells) will be added.
|
|
56
57
|
* This is the default unless overridden in Misc.Settings.grid
|
|
@@ -72,7 +73,11 @@ interface IGridProps<T> extends Omit<React.HTMLProps<HTMLTableElement>, "childre
|
|
|
72
73
|
* Set `showAddButton = false` if you don't want the default button.
|
|
73
74
|
*/
|
|
74
75
|
footerButtons?: () => React.ReactNode;
|
|
75
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Will cause the header to stick to the top of the screen / scroll element when scrolling.
|
|
78
|
+
* Note: if your app has a fixed header, you need to specify this in the global neo settings.
|
|
79
|
+
*/
|
|
80
|
+
stickyHeader?: boolean;
|
|
76
81
|
}
|
|
77
82
|
export default class Grid<T> extends React.Component<IGridProps<T>> {
|
|
78
83
|
static contextType: React.Context<import("../../React/DataView").DataViewContextParams<unknown>>;
|
|
@@ -80,8 +85,11 @@ export default class Grid<T> extends React.Component<IGridProps<T>> {
|
|
|
80
85
|
private gridContext;
|
|
81
86
|
private prevItems?;
|
|
82
87
|
private headerItem;
|
|
88
|
+
private domRef;
|
|
89
|
+
private stickyHeaderHelper?;
|
|
83
90
|
constructor(props: IGridProps<T>);
|
|
91
|
+
componentDidMount(): void;
|
|
92
|
+
componentWillUnmount(): void;
|
|
84
93
|
render(): JSX.Element;
|
|
85
94
|
private setInitialSort;
|
|
86
95
|
}
|
|
87
|
-
export {};
|
|
@@ -4,6 +4,7 @@ import { Data, Utils, Misc } from '@singularsystems/neo-core';
|
|
|
4
4
|
import { observer, Observer } from 'mobx-react';
|
|
5
5
|
import NeoButton from '../Button';
|
|
6
6
|
import { DataViewContext } from '../../React/DataView';
|
|
7
|
+
import { StickyTableHeader } from './StickyTableHeader';
|
|
7
8
|
// Grid context
|
|
8
9
|
var GridContextParams = /** @class */ (function () {
|
|
9
10
|
function GridContextParams() {
|
|
@@ -27,12 +28,24 @@ var Grid = /** @class */ (function (_super) {
|
|
|
27
28
|
function Grid(props) {
|
|
28
29
|
var _this = _super.call(this, props) || this;
|
|
29
30
|
_this.gridContext = new GridContextParams();
|
|
31
|
+
_this.domRef = React.createRef();
|
|
30
32
|
_this.gridContext.section = "header";
|
|
31
33
|
return _this;
|
|
32
34
|
}
|
|
35
|
+
Grid.prototype.componentDidMount = function () {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
if (this.domRef.current && ((_a = this.props.stickyHeader) !== null && _a !== void 0 ? _a : Misc.Settings.grid.useStickyHeaders)) {
|
|
38
|
+
this.stickyHeaderHelper = new StickyTableHeader(this.domRef.current, (_b = Misc.Settings.fixedAppHeaderElement) === null || _b === void 0 ? void 0 : _b.call(undefined));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
Grid.prototype.componentWillUnmount = function () {
|
|
42
|
+
if (this.stickyHeaderHelper) {
|
|
43
|
+
this.stickyHeaderHelper.dispose();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
33
46
|
Grid.prototype.render = function () {
|
|
34
47
|
var _this = this;
|
|
35
|
-
var _a = this.props, items = _a.items, showAddButton = _a.showAddButton, addButton = _a.addButton, filterPredicate = _a.filterPredicate, keyProperty = _a.keyProperty, allowSort = _a.allowSort, expandAll = _a.expandAll, collapseAll = _a.collapseAll, initialSort = _a.initialSort, initialSortAscending = _a.initialSortAscending, isBordered = _a.isBordered, isStriped = _a.isStriped, isBorderless = _a.isBorderless, showHover = _a.showHover, isSmallTable = _a.isSmallTable, footerContent = _a.footerContent, footerButtons = _a.footerButtons, domProps = __rest(_a, ["items", "showAddButton", "addButton", "filterPredicate", "keyProperty", "allowSort", "expandAll", "collapseAll", "initialSort", "initialSortAscending", "isBordered", "isStriped", "isBorderless", "showHover", "isSmallTable", "footerContent", "footerButtons"]);
|
|
48
|
+
var _a = this.props, items = _a.items, showAddButton = _a.showAddButton, addButton = _a.addButton, filterPredicate = _a.filterPredicate, keyProperty = _a.keyProperty, allowSort = _a.allowSort, expandAll = _a.expandAll, collapseAll = _a.collapseAll, initialSort = _a.initialSort, initialSortAscending = _a.initialSortAscending, isBordered = _a.isBordered, isStriped = _a.isStriped, isBorderless = _a.isBorderless, showHover = _a.showHover, isSmallTable = _a.isSmallTable, footerContent = _a.footerContent, footerButtons = _a.footerButtons, stickyHeader = _a.stickyHeader, domProps = __rest(_a, ["items", "showAddButton", "addButton", "filterPredicate", "keyProperty", "allowSort", "expandAll", "collapseAll", "initialSort", "initialSortAscending", "isBordered", "isStriped", "isBorderless", "showHover", "isSmallTable", "footerContent", "footerButtons", "stickyHeader"]);
|
|
36
49
|
if (expandAll === true) {
|
|
37
50
|
this.gridContext.expandAll = true;
|
|
38
51
|
}
|
|
@@ -86,16 +99,18 @@ var Grid = /** @class */ (function (_super) {
|
|
|
86
99
|
}
|
|
87
100
|
this.headerItem = this.gridContext.dataView.getMetaItem();
|
|
88
101
|
}
|
|
89
|
-
return (React.createElement("table", __assign({}, domProps, { className: className }),
|
|
102
|
+
return (React.createElement("table", __assign({}, domProps, { className: className, ref: this.domRef }),
|
|
90
103
|
React.createElement(GridContext.Provider, { value: this.gridContext },
|
|
91
104
|
React.createElement(TableSection, { type: "header" }, this.headerItem && this.props.children(this.headerItem, this.headerItem.meta)),
|
|
92
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 })); })),
|
|
93
|
-
React.createElement(Observer, null, function () {
|
|
94
|
-
React.createElement(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
React.createElement(Observer, null, function () {
|
|
107
|
+
return React.createElement(React.Fragment, null, (showAddButton || addButton || footerButtons || _this.gridContext.hasSummaries || footerContent !== undefined) &&
|
|
108
|
+
React.createElement(TableSection, { type: "footer" },
|
|
109
|
+
_this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta),
|
|
110
|
+
footerContent !== undefined && footerContent(_this.gridContext.dataView.getItems()),
|
|
111
|
+
(showAddButton || addButton || footerButtons) &&
|
|
112
|
+
React.createElement(AddButtonRow, { addButton: addButton, showAddButton: showAddButton, additionalContent: footerButtons })));
|
|
113
|
+
}))));
|
|
99
114
|
};
|
|
100
115
|
Grid.prototype.setInitialSort = function (initialSort, initialSortAscending) {
|
|
101
116
|
var _a;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watches for when a table header scrolls out of view.
|
|
3
|
+
* When it does, adds a cloned header that is fixed at the top of the scrolling element.
|
|
4
|
+
*/
|
|
5
|
+
export declare class StickyTableHeader {
|
|
6
|
+
private table;
|
|
7
|
+
private fixedElement?;
|
|
8
|
+
/**
|
|
9
|
+
* Creates the instance, and begins listening for scroll events.
|
|
10
|
+
* @param table The table to add sticky headers to.
|
|
11
|
+
* @param fixedElement A fixed element at the top of the screen to use as an anchor, rather than the top of the screen itself.
|
|
12
|
+
*/
|
|
13
|
+
constructor(table: HTMLTableElement, fixedElement?: HTMLElement | undefined);
|
|
14
|
+
private scrollParent?;
|
|
15
|
+
private header;
|
|
16
|
+
private headerCopy?;
|
|
17
|
+
private headerHeight;
|
|
18
|
+
private handleScroll;
|
|
19
|
+
private removeCopy;
|
|
20
|
+
private onPossibleContentChange;
|
|
21
|
+
private setColumnWidths;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the first parent element that has a scrollbar.
|
|
25
|
+
*/
|
|
26
|
+
private static getParentScrollElement;
|
|
27
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watches for when a table header scrolls out of view.
|
|
3
|
+
* When it does, adds a cloned header that is fixed at the top of the scrolling element.
|
|
4
|
+
*/
|
|
5
|
+
var StickyTableHeader = /** @class */ (function () {
|
|
6
|
+
/**
|
|
7
|
+
* Creates the instance, and begins listening for scroll events.
|
|
8
|
+
* @param table The table to add sticky headers to.
|
|
9
|
+
* @param fixedElement A fixed element at the top of the screen to use as an anchor, rather than the top of the screen itself.
|
|
10
|
+
*/
|
|
11
|
+
function StickyTableHeader(table, fixedElement) {
|
|
12
|
+
this.table = table;
|
|
13
|
+
this.fixedElement = fixedElement;
|
|
14
|
+
this.headerHeight = 0;
|
|
15
|
+
if (!table.tHead) {
|
|
16
|
+
throw Error("Table must have a header section.");
|
|
17
|
+
}
|
|
18
|
+
this.header = table.tHead;
|
|
19
|
+
this.scrollParent = StickyTableHeader.getParentScrollElement(table);
|
|
20
|
+
this.handleScroll = this.handleScroll.bind(this);
|
|
21
|
+
this.onPossibleContentChange = this.onPossibleContentChange.bind(this);
|
|
22
|
+
document.addEventListener("scroll", this.handleScroll);
|
|
23
|
+
if (this.scrollParent) {
|
|
24
|
+
this.scrollParent.addEventListener("scroll", this.handleScroll);
|
|
25
|
+
}
|
|
26
|
+
table.addEventListener("keydown", this.onPossibleContentChange);
|
|
27
|
+
table.addEventListener("mouseup", this.onPossibleContentChange);
|
|
28
|
+
}
|
|
29
|
+
StickyTableHeader.prototype.handleScroll = function () {
|
|
30
|
+
// If the grid is in an element with a scrollbar, then the header should stick to the top of that element,
|
|
31
|
+
// otherwise if there is a fixed (non scrolling) element at the top of the page, then the headers must appear below that.
|
|
32
|
+
// otherwise the headers will stick to the top of the screen.
|
|
33
|
+
var fixedElement = null;
|
|
34
|
+
if (!this.scrollParent && this.fixedElement && getComputedStyle(this.fixedElement).position === "fixed") {
|
|
35
|
+
fixedElement = this.fixedElement;
|
|
36
|
+
}
|
|
37
|
+
var topBoundary = this.scrollParent ? this.scrollParent.getBoundingClientRect().top : (fixedElement ? fixedElement.getBoundingClientRect().bottom : 0);
|
|
38
|
+
var tableBounds = this.table.getBoundingClientRect();
|
|
39
|
+
var tbodyBounds = this.table.tBodies[this.table.tBodies.length - 1].getBoundingClientRect();
|
|
40
|
+
if (tableBounds.top < topBoundary && tbodyBounds.bottom - this.headerHeight > topBoundary) {
|
|
41
|
+
if (!this.headerCopy) {
|
|
42
|
+
// Clone the header, and re-insert it into the table. The table will then have 2 headers.
|
|
43
|
+
// The original headers position is set to "fixed" which makes it float.
|
|
44
|
+
// The column widths of the floating header then need to be synchronised with the header that is still inside the table layout.
|
|
45
|
+
this.headerHeight = this.header.getBoundingClientRect().height;
|
|
46
|
+
this.headerCopy = this.header.cloneNode(true);
|
|
47
|
+
this.table.insertBefore(this.headerCopy, this.header);
|
|
48
|
+
this.header.classList.add("neo-grid-fixed-header");
|
|
49
|
+
this.setColumnWidths();
|
|
50
|
+
}
|
|
51
|
+
this.header.style.left = tableBounds.left + "px";
|
|
52
|
+
this.header.style.top = topBoundary + "px";
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.setColumnWidths(true);
|
|
56
|
+
this.removeCopy();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
StickyTableHeader.prototype.removeCopy = function () {
|
|
60
|
+
if (this.headerCopy) {
|
|
61
|
+
this.header.classList.remove("neo-grid-fixed-header");
|
|
62
|
+
this.table.removeChild(this.headerCopy);
|
|
63
|
+
this.headerCopy = undefined;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
StickyTableHeader.prototype.onPossibleContentChange = function () {
|
|
67
|
+
var _this = this;
|
|
68
|
+
setTimeout(function () { return _this.setColumnWidths(); }, 0);
|
|
69
|
+
};
|
|
70
|
+
StickyTableHeader.prototype.setColumnWidths = function (isRemoving) {
|
|
71
|
+
if (isRemoving === void 0) { isRemoving = false; }
|
|
72
|
+
if (this.headerCopy) {
|
|
73
|
+
for (var i = 0; i < this.header.rows.length; i++) {
|
|
74
|
+
var originalRow = this.header.rows[i], copyRow = this.headerCopy.rows[i];
|
|
75
|
+
for (var j = 0; j < originalRow.cells.length; j++) {
|
|
76
|
+
var originalCell = originalRow.cells[j], copyCell = copyRow.cells[j];
|
|
77
|
+
originalCell.style.width = isRemoving ? copyCell.style.width : window.getComputedStyle(copyCell).width;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
StickyTableHeader.prototype.dispose = function () {
|
|
83
|
+
document.removeEventListener("scroll", this.handleScroll);
|
|
84
|
+
if (this.scrollParent) {
|
|
85
|
+
this.scrollParent.removeEventListener("scroll", this.handleScroll);
|
|
86
|
+
}
|
|
87
|
+
this.table.removeEventListener("keydown", this.onPossibleContentChange);
|
|
88
|
+
this.table.removeEventListener("mouseup", this.onPossibleContentChange);
|
|
89
|
+
this.removeCopy();
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Returns the first parent element that has a scrollbar.
|
|
93
|
+
*/
|
|
94
|
+
StickyTableHeader.getParentScrollElement = function (element) {
|
|
95
|
+
var current = element;
|
|
96
|
+
while (current) {
|
|
97
|
+
if ((current.style.height || current.style.maxHeight) &&
|
|
98
|
+
(current.style.overflow === "scroll" || current.style.overflow === "auto" || current.style.overflowY === "scroll" || current.style.overflowY === "auto")) {
|
|
99
|
+
return current;
|
|
100
|
+
}
|
|
101
|
+
current = current.parentElement;
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
};
|
|
105
|
+
return StickyTableHeader;
|
|
106
|
+
}());
|
|
107
|
+
export { StickyTableHeader };
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export interface IconStyle {
|
|
3
|
+
/** True if the icon should be fixed width */
|
|
3
4
|
fixedWidth?: boolean;
|
|
5
|
+
/** True if the icon should have a spin animation applied. E.g. loading spinner. */
|
|
4
6
|
spin?: boolean;
|
|
7
|
+
/** True if the icon should have a solid or filled in style. Set to false for font-awesome regular style. */
|
|
8
|
+
solid?: boolean;
|
|
9
|
+
/** How thin / thick the icon lines are. Only supported by material symbols. */
|
|
10
|
+
weight?: number;
|
|
5
11
|
}
|
|
6
12
|
export interface IIconFactory {
|
|
7
13
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IconStyle, IIconFactory } from ".";
|
|
3
|
+
export interface IIconProps extends IconStyle {
|
|
4
|
+
name: string;
|
|
5
|
+
/** Optional icon factory if this icon uses a different icon set to the project default. */
|
|
6
|
+
factory?: IIconFactory;
|
|
7
|
+
}
|
|
8
|
+
/** Renders an icon using the icon factory specified at startup. */
|
|
9
|
+
export default class Icon extends React.Component<IIconProps> {
|
|
10
|
+
private static _iconFactory;
|
|
11
|
+
private get iconFactory();
|
|
12
|
+
render(): React.ReactNode;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __extends, __rest } from "tslib";
|
|
2
|
+
import { Misc } from "@singularsystems/neo-core";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { NeoReactTypes } from "../..";
|
|
5
|
+
/** Renders an icon using the icon factory specified at startup. */
|
|
6
|
+
var Icon = /** @class */ (function (_super) {
|
|
7
|
+
__extends(Icon, _super);
|
|
8
|
+
function Icon() {
|
|
9
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(Icon.prototype, "iconFactory", {
|
|
12
|
+
get: function () {
|
|
13
|
+
if (!Icon._iconFactory) {
|
|
14
|
+
Icon._iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
|
|
15
|
+
}
|
|
16
|
+
return Icon._iconFactory;
|
|
17
|
+
},
|
|
18
|
+
enumerable: false,
|
|
19
|
+
configurable: true
|
|
20
|
+
});
|
|
21
|
+
Icon.prototype.render = function () {
|
|
22
|
+
var _a = this.props, name = _a.name, factory = _a.factory, iconStyle = __rest(_a, ["name", "factory"]);
|
|
23
|
+
return (factory !== null && factory !== void 0 ? factory : this.iconFactory).getIconComponent(name, iconStyle);
|
|
24
|
+
};
|
|
25
|
+
return Icon;
|
|
26
|
+
}(React.Component));
|
|
27
|
+
export default Icon;
|
|
@@ -18,7 +18,7 @@ export var IconFactory = /** @class */ (function () {
|
|
|
18
18
|
return undefined;
|
|
19
19
|
};
|
|
20
20
|
IconFactory.prototype.textOrIcon = function (textOrIcon, style) {
|
|
21
|
-
if (textOrIcon.indexOf("fa-") === 0 || textOrIcon.indexOf("far-") === 0) {
|
|
21
|
+
if (textOrIcon.indexOf("fa-") === 0 || textOrIcon.indexOf("far-") === 0 || textOrIcon.indexOf("fas-") === 0) {
|
|
22
22
|
return this.getIconComponent(textOrIcon, style);
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
@@ -27,6 +27,12 @@ export var IconFactory = /** @class */ (function () {
|
|
|
27
27
|
};
|
|
28
28
|
IconFactory.prototype.mapStringToIcon = function (iconName, style) {
|
|
29
29
|
var className = Utils.getFontAwesomeClass(iconName);
|
|
30
|
+
if ((style === null || style === void 0 ? void 0 : style.solid) === false) {
|
|
31
|
+
className = className.replace("fa ", "far ");
|
|
32
|
+
}
|
|
33
|
+
if ((style === null || style === void 0 ? void 0 : style.solid) === true) {
|
|
34
|
+
className = className.replace("fa ", "fas ");
|
|
35
|
+
}
|
|
30
36
|
if (style === null || style === void 0 ? void 0 : style.fixedWidth) {
|
|
31
37
|
className += " fa-fw";
|
|
32
38
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IconFactory, IconStyle } from ".";
|
|
3
|
+
interface IMaterialSymbolsOptions {
|
|
4
|
+
/** Set to true if icon names with unspecified fill should be made solid/filled. */
|
|
5
|
+
fillDefault?: boolean;
|
|
6
|
+
/** Additional mappings between font-awesome, and material symbols. */
|
|
7
|
+
fontAwesomeMappings?: [string, string][];
|
|
8
|
+
/** Set to true if the provided mappings should completely replace the built in neo mappings. */
|
|
9
|
+
replaceNeoMappings?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Font factory that renders google material symbols icons.
|
|
13
|
+
*/
|
|
14
|
+
export declare class MaterialSymbolsFontFactory extends IconFactory {
|
|
15
|
+
constructor(options?: IMaterialSymbolsOptions);
|
|
16
|
+
private filledByDefault;
|
|
17
|
+
private fontAwesomeMap;
|
|
18
|
+
protected mapStringToIcon(iconName: string, style?: IconStyle | undefined): React.ReactNode;
|
|
19
|
+
protected mapFontAwesomeToMaterial(faName: string): string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export {};
|