@singularsystems/neo-react 1.0.0-alpha.2 → 1.0.0-beta.0

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.
Files changed (196) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +4 -0
  3. package/dist/Modules/NeoReactModule.d.ts +4 -4
  4. package/dist/Modules/NeoReactModule.js +28 -26
  5. package/dist/Modules/ReactSetup.d.ts +2 -2
  6. package/dist/Modules/ReactSetup.js +17 -17
  7. package/dist/Modules/Types.d.ts +63 -61
  8. package/dist/Modules/Types.js +13 -12
  9. package/dist/React/AutoRunner.d.ts +5 -5
  10. package/dist/React/AutoRunner.js +94 -92
  11. package/dist/React/DataView.d.ts +6 -6
  12. package/dist/React/DataView.js +11 -11
  13. package/dist/React/ReactModelCreator.d.ts +11 -11
  14. package/dist/React/ReactModelCreator.js +165 -162
  15. package/dist/ReactComponents/Button.d.ts +24 -23
  16. package/dist/ReactComponents/Button.js +131 -123
  17. package/dist/ReactComponents/Card.d.ts +24 -23
  18. package/dist/ReactComponents/Card.js +56 -54
  19. package/dist/ReactComponents/Collapsable.d.ts +23 -23
  20. package/dist/ReactComponents/Collapsable.js +38 -38
  21. package/dist/ReactComponents/CollapsableBase.d.ts +13 -13
  22. package/dist/ReactComponents/CollapsableBase.js +42 -42
  23. package/dist/ReactComponents/ColorPicker.d.ts +26 -26
  24. package/dist/ReactComponents/ColorPicker.js +67 -67
  25. package/dist/ReactComponents/ComponentBase.d.ts +17 -17
  26. package/dist/ReactComponents/ComponentBase.js +33 -33
  27. package/dist/ReactComponents/ContextMenu/ContextMenu.d.ts +25 -24
  28. package/dist/ReactComponents/ContextMenu/ContextMenu.js +91 -88
  29. package/dist/ReactComponents/ContextMenu/ContextMenuContainer.d.ts +14 -14
  30. package/dist/ReactComponents/ContextMenu/ContextMenuContainer.js +48 -48
  31. package/dist/ReactComponents/ContextMenu/ContextMenuState.d.ts +8 -7
  32. package/dist/ReactComponents/ContextMenu/ContextMenuState.js +23 -23
  33. package/dist/ReactComponents/DatePicker.d.ts +19 -19
  34. package/dist/ReactComponents/DatePicker.js +53 -53
  35. package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +93 -83
  36. package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +222 -188
  37. package/dist/ReactComponents/DropDown/DropDown.d.ts +44 -44
  38. package/dist/ReactComponents/DropDown/DropDown.js +138 -134
  39. package/dist/ReactComponents/DropDown/DropDownBase.d.ts +16 -15
  40. package/dist/ReactComponents/DropDown/DropDownBase.js +86 -108
  41. package/dist/ReactComponents/DropDown/LookupHelper.d.ts +13 -0
  42. package/dist/ReactComponents/DropDown/LookupHelper.js +45 -0
  43. package/dist/ReactComponents/ErrorHandler.d.ts +9 -8
  44. package/dist/ReactComponents/ErrorHandler.js +92 -91
  45. package/dist/ReactComponents/FileManager/FileBasicInput.d.ts +20 -20
  46. package/dist/ReactComponents/FileManager/FileBasicInput.js +70 -70
  47. package/dist/ReactComponents/FileManager/FileContext.d.ts +16 -16
  48. package/dist/ReactComponents/FileManager/FileContext.js +24 -24
  49. package/dist/ReactComponents/FileManager/FileDropArea.d.ts +19 -18
  50. package/dist/ReactComponents/FileManager/FileDropArea.js +66 -64
  51. package/dist/ReactComponents/FileManager/FileInput.d.ts +44 -42
  52. package/dist/ReactComponents/FileManager/FileInput.js +191 -189
  53. package/dist/ReactComponents/FileManager/FileUploadButton.d.ts +17 -17
  54. package/dist/ReactComponents/FileManager/FileUploadButton.js +49 -49
  55. package/dist/ReactComponents/FileManager/FileUploadProgress.d.ts +14 -14
  56. package/dist/ReactComponents/FileManager/FileUploadProgress.js +35 -35
  57. package/dist/ReactComponents/Form.d.ts +19 -18
  58. package/dist/ReactComponents/Form.js +90 -90
  59. package/dist/ReactComponents/FormContext.d.ts +33 -31
  60. package/dist/ReactComponents/FormContext.js +39 -40
  61. package/dist/ReactComponents/FormGroup/FormGroup.d.ts +37 -37
  62. package/dist/ReactComponents/FormGroup/FormGroup.js +83 -84
  63. package/dist/ReactComponents/FormGroup/FormGroupFloating.d.ts +19 -19
  64. package/dist/ReactComponents/FormGroup/FormGroupFloating.js +97 -97
  65. package/dist/ReactComponents/FormGroup/FormGroupInline.d.ts +11 -11
  66. package/dist/ReactComponents/FormGroup/FormGroupInline.js +43 -43
  67. package/dist/ReactComponents/Grid/ButtonColumn.d.ts +47 -47
  68. package/dist/ReactComponents/Grid/ButtonColumn.js +81 -82
  69. package/dist/ReactComponents/Grid/Column.d.ts +47 -47
  70. package/dist/ReactComponents/Grid/Column.js +205 -205
  71. package/dist/ReactComponents/Grid/ColumnHelper.d.ts +12 -12
  72. package/dist/ReactComponents/Grid/ColumnHelper.js +19 -19
  73. package/dist/ReactComponents/Grid/Grid.d.ts +87 -90
  74. package/dist/ReactComponents/Grid/Grid.js +203 -203
  75. package/dist/ReactComponents/Grid/Row.d.ts +81 -81
  76. package/dist/ReactComponents/Grid/Row.js +200 -201
  77. package/dist/ReactComponents/Grid/_Exports.d.ts +5 -5
  78. package/dist/ReactComponents/Grid/_Exports.js +5 -5
  79. package/dist/ReactComponents/GridLayout.d.ts +20 -20
  80. package/dist/ReactComponents/GridLayout.js +38 -38
  81. package/dist/ReactComponents/Icons/FontAwesomeIconFactory.d.ts +23 -0
  82. package/dist/ReactComponents/Icons/FontAwesomeIconFactory.js +43 -0
  83. package/dist/ReactComponents/Icons/IIconFactory.d.ts +21 -0
  84. package/dist/ReactComponents/Icons/IIconFactory.js +1 -0
  85. package/dist/ReactComponents/Icons/IconFactory.d.ts +9 -0
  86. package/dist/ReactComponents/Icons/IconFactory.js +45 -0
  87. package/dist/ReactComponents/Icons/index.d.ts +3 -0
  88. package/dist/ReactComponents/Icons/index.js +2 -0
  89. package/dist/ReactComponents/Input.d.ts +45 -45
  90. package/dist/ReactComponents/Input.js +153 -152
  91. package/dist/ReactComponents/InputHelpers.d.ts +6 -5
  92. package/dist/ReactComponents/InputHelpers.js +29 -33
  93. package/dist/ReactComponents/Link.d.ts +13 -13
  94. package/dist/ReactComponents/Link.js +28 -28
  95. package/dist/ReactComponents/Loader.d.ts +18 -18
  96. package/dist/ReactComponents/Loader.js +57 -57
  97. package/dist/ReactComponents/Misc.d.ts +15 -15
  98. package/dist/ReactComponents/Misc.js +28 -28
  99. package/dist/ReactComponents/Modal/Modal.d.ts +11 -11
  100. package/dist/ReactComponents/Modal/Modal.js +129 -129
  101. package/dist/ReactComponents/Modal/ModalContainer.d.ts +17 -17
  102. package/dist/ReactComponents/Modal/ModalContainer.js +37 -37
  103. package/dist/ReactComponents/Modal/ModalPortal.d.ts +16 -15
  104. package/dist/ReactComponents/Modal/ModalPortal.js +27 -27
  105. package/dist/ReactComponents/Notifications/Alert.d.ts +7 -6
  106. package/dist/ReactComponents/Notifications/Alert.js +38 -35
  107. package/dist/ReactComponents/Notifications/Toast.d.ts +9 -8
  108. package/dist/ReactComponents/Notifications/Toast.js +47 -45
  109. package/dist/ReactComponents/Notifications/ToastContainer.d.ts +8 -8
  110. package/dist/ReactComponents/Notifications/ToastContainer.js +18 -18
  111. package/dist/ReactComponents/NumberInput.d.ts +57 -50
  112. package/dist/ReactComponents/NumberInput.js +260 -246
  113. package/dist/ReactComponents/Paging/BasicPagerControls.d.ts +26 -25
  114. package/dist/ReactComponents/Paging/BasicPagerControls.js +57 -55
  115. package/dist/ReactComponents/Paging/PageSizeControl.d.ts +11 -11
  116. package/dist/ReactComponents/Paging/PageSizeControl.js +21 -21
  117. package/dist/ReactComponents/Paging/Pager.d.ts +24 -24
  118. package/dist/ReactComponents/Paging/Pager.js +41 -41
  119. package/dist/ReactComponents/ProgressBar.d.ts +19 -19
  120. package/dist/ReactComponents/ProgressBar.js +52 -52
  121. package/dist/ReactComponents/PropTypes.d.ts +161 -161
  122. package/dist/ReactComponents/PropTypes.js +253 -236
  123. package/dist/ReactComponents/RadioList.d.ts +29 -29
  124. package/dist/ReactComponents/RadioList.js +59 -77
  125. package/dist/ReactComponents/Slider.d.ts +28 -28
  126. package/dist/ReactComponents/Slider.js +76 -76
  127. package/dist/ReactComponents/StateObserver.d.ts +15 -15
  128. package/dist/ReactComponents/StateObserver.js +35 -35
  129. package/dist/ReactComponents/Tabs/Tab.d.ts +42 -41
  130. package/dist/ReactComponents/Tabs/Tab.js +71 -72
  131. package/dist/ReactComponents/Tabs/TabContainer.d.ts +44 -44
  132. package/dist/ReactComponents/Tabs/TabContainer.js +98 -98
  133. package/dist/ReactComponents/Tabs/TabManager.d.ts +62 -62
  134. package/dist/ReactComponents/Tabs/TabManager.js +154 -154
  135. package/dist/ReactComponents/Tooltip.d.ts +20 -19
  136. package/dist/ReactComponents/Tooltip.js +51 -51
  137. package/dist/ReactComponents/TooltipHelper.d.ts +8 -8
  138. package/dist/ReactComponents/TooltipHelper.js +84 -84
  139. package/dist/ReactComponents/TooltipProvider.d.ts +30 -30
  140. package/dist/ReactComponents/TooltipProvider.js +111 -111
  141. package/dist/ReactComponents/ValidationSummary.d.ts +23 -22
  142. package/dist/ReactComponents/ValidationSummary.js +46 -43
  143. package/dist/ReactComponents/_Exports.d.ts +41 -41
  144. package/dist/ReactComponents/_Exports.js +41 -41
  145. package/dist/ReactComponents/_Managers.d.ts +4 -4
  146. package/dist/ReactComponents/_Managers.js +4 -4
  147. package/dist/Routing/BreadCrumbItem.d.ts +14 -14
  148. package/dist/Routing/BreadCrumbItem.js +12 -12
  149. package/dist/Routing/IRouteChangedProps.d.ts +31 -31
  150. package/dist/Routing/IRouteChangedProps.js +1 -1
  151. package/dist/Routing/IRouteParameter.d.ts +22 -22
  152. package/dist/Routing/IRouteParameter.js +9 -9
  153. package/dist/Routing/MenuRoute.d.ts +25 -24
  154. package/dist/Routing/MenuRoute.js +24 -24
  155. package/dist/Routing/NavigationHelper.d.ts +41 -40
  156. package/dist/Routing/NavigationHelper.js +61 -61
  157. package/dist/Routing/PageLeaveHandler.d.ts +13 -13
  158. package/dist/Routing/PageLeaveHandler.js +74 -74
  159. package/dist/Routing/RouteProvider.d.ts +31 -31
  160. package/dist/Routing/RouteProvider.js +92 -92
  161. package/dist/Routing/RouteView.d.ts +50 -50
  162. package/dist/Routing/RouteView.js +143 -144
  163. package/dist/Routing/RoutingState.d.ts +18 -15
  164. package/dist/Routing/RoutingState.js +45 -40
  165. package/dist/Routing/ViewParameter.d.ts +80 -58
  166. package/dist/Routing/ViewParameter.js +116 -95
  167. package/dist/Routing/ViewParameterList.d.ts +53 -53
  168. package/dist/Routing/ViewParameterList.js +163 -145
  169. package/dist/Routing/index.d.ts +9 -9
  170. package/dist/Routing/index.js +6 -6
  171. package/dist/Services/DisposeHelper.d.ts +15 -15
  172. package/dist/Services/DisposeHelper.js +40 -41
  173. package/dist/Services/IDisposeHelper.d.ts +12 -12
  174. package/dist/Services/IDisposeHelper.js +1 -1
  175. package/dist/Views/EmptyViewModel.d.ts +5 -5
  176. package/dist/Views/EmptyViewModel.js +14 -14
  177. package/dist/Views/IViewModel.d.ts +16 -16
  178. package/dist/Views/IViewModel.js +1 -1
  179. package/dist/Views/PersistentViewBase.d.ts +10 -10
  180. package/dist/Views/PersistentViewBase.js +21 -21
  181. package/dist/Views/ViewBase.d.ts +70 -71
  182. package/dist/Views/ViewBase.js +166 -153
  183. package/dist/Views/ViewComponentBase.d.ts +19 -13
  184. package/dist/Views/ViewComponentBase.js +24 -21
  185. package/dist/Views/ViewModelBase.d.ts +57 -56
  186. package/dist/Views/ViewModelBase.js +122 -118
  187. package/dist/Views/ViewState.d.ts +13 -13
  188. package/dist/Views/ViewState.js +9 -9
  189. package/dist/Views/index.d.ts +5 -5
  190. package/dist/Views/index.js +5 -5
  191. package/dist/index.d.ts +11 -10
  192. package/dist/index.js +10 -9
  193. package/package.json +26 -26
  194. package/styles/DatePicker.scss +2 -2
  195. package/styles/Forms.scss +5 -0
  196. package/styles/Validation.scss +0 -9
@@ -1,90 +1,87 @@
1
- import * as React from 'react';
2
- import { Data, Model } from '@singularsystems/neo-core';
3
- import { DataViewContext } from '../../React/DataView';
4
- import { IButtonOptions } from '@singularsystems/neo-core/dist/Components/ButtonOptions';
5
- import { ItemCallback } from '../PropTypes';
6
- export declare type GridSection = "header" | "body" | "footer";
7
- export declare class GridContextParams<T> {
8
- currentItem: T;
9
- section: GridSection;
10
- doneStaticSetup: boolean;
11
- inFirstRowInGroup: boolean;
12
- columnCount: number;
13
- expandProperty?: Model.IPropertyInstance<boolean | null>;
14
- expandAll?: boolean;
15
- hasSummaries: boolean;
16
- dataView: Data.DataViewBase<T>;
17
- get inBody(): boolean;
18
- }
19
- export declare const GridContext: React.Context<GridContextParams<unknown>>;
20
- interface IGridProps<T> extends React.HTMLProps<HTMLTableElement> {
21
- /**
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
- * a DataViewProvider like a Pager or DataScroller
24
- */
25
- items?: T[] | Data.DataViewBase<T>;
26
- /** True if the add new button should be shown in the footer. Requires the datasource to be a neo List. */
27
- showAddButton?: boolean;
28
- /** Add new button options. Will cause add new button to be shown. */
29
- addButton?: IButtonOptions;
30
- /** Function used to filter items out of the datasource. */
31
- filterPredicate?: (item: T, index: number) => boolean;
32
- /**
33
- * The unique key of the items being displayed. This is only necessary if the items dont have an entityIdentifier
34
- * property (non ModelBase items).
35
- */
36
- keyProperty?: string;
37
- /**
38
- * Set to false if you don't want to allow sorting.
39
- */
40
- allowSort?: boolean;
41
- /**
42
- * Set to true expand all child rows. All expand buttons will be hidden.
43
- */
44
- expandAll?: boolean;
45
- /**
46
- * Set to true collapse all child rows. All expand buttons will be hidden.
47
- */
48
- collapseAll?: boolean;
49
- /**
50
- * Initial sort column.
51
- */
52
- initialSort?: keyof T | (keyof T)[];
53
- initialSortAscending?: boolean | boolean[];
54
- /**
55
- * When specified, the default bootstrap table borders (sides and cells) will be added.
56
- * This is the default unless overridden in Misc.Settings.grid
57
- */
58
- isBordered?: boolean;
59
- /** When specified, every alternating row will receive a slightly darker background color. */
60
- isStriped?: boolean;
61
- /** When specified, the table will have no cell borders, and the table will have no main border. */
62
- isBorderless?: boolean;
63
- /** When specified, a background color will be applied on a row if it is being hovered over. */
64
- showHover?: boolean;
65
- /** When specified, the table size will be reduced (by reducing the padding sizes in each cell by half). */
66
- isSmallTable?: boolean;
67
- /** Additional footer row(s) to display below the main footer row. */
68
- footerContent?: (data: T[]) => React.ReactNode;
69
- /**
70
- * Additional content to show next to the add new button.
71
- *
72
- * Set `showAddButton = false` if you don't want the default button.
73
- */
74
- footerButtons?: () => React.ReactNode;
75
- children: any;
76
- }
77
- interface GridPropsWithChildren<T> extends IGridProps<T> {
78
- children: ItemCallback<T>;
79
- }
80
- export default class Grid<T> extends React.Component<GridPropsWithChildren<T>> {
81
- static contextType: React.Context<import("../../React/DataView").DataViewContextParams<unknown>>;
82
- context: React.ContextType<typeof DataViewContext>;
83
- private gridContext;
84
- private prevItems?;
85
- private headerItem;
86
- constructor(props: GridPropsWithChildren<T>);
87
- render(): JSX.Element;
88
- private setInitialSort;
89
- }
90
- export {};
1
+ import * as React from 'react';
2
+ import { Data, Model } from '@singularsystems/neo-core';
3
+ import { DataViewContext } from '../../React/DataView';
4
+ import { IButtonOptions } from '@singularsystems/neo-core/dist/Components/ButtonOptions';
5
+ import { ItemCallback } from '../PropTypes';
6
+ export type GridSection = "header" | "body" | "footer";
7
+ export declare class GridContextParams<T> {
8
+ currentItem: T;
9
+ section: GridSection;
10
+ doneStaticSetup: boolean;
11
+ inFirstRowInGroup: boolean;
12
+ columnCount: number;
13
+ expandProperty?: Model.IPropertyInstance<boolean | null>;
14
+ expandAll?: boolean;
15
+ hasSummaries: boolean;
16
+ dataView: Data.DataViewBase<T>;
17
+ get inBody(): boolean;
18
+ }
19
+ export declare const GridContext: React.Context<GridContextParams<unknown>>;
20
+ interface IGridProps<T> extends Omit<React.HTMLProps<HTMLTableElement>, "children"> {
21
+ /**
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
+ * a DataViewProvider like a Pager or DataScroller
24
+ */
25
+ items?: T[] | Data.DataViewBase<T>;
26
+ /** True if the add new button should be shown in the footer. Requires the datasource to be a neo List. */
27
+ showAddButton?: boolean;
28
+ /** Add new button options. Will cause add new button to be shown. */
29
+ addButton?: IButtonOptions;
30
+ /** Function used to filter items out of the datasource. */
31
+ filterPredicate?: (item: T, index: number) => boolean;
32
+ /**
33
+ * The unique key of the items being displayed. This is only necessary if the items dont have an entityIdentifier
34
+ * property (non ModelBase items).
35
+ */
36
+ keyProperty?: string;
37
+ /**
38
+ * Set to false if you don't want to allow sorting.
39
+ */
40
+ allowSort?: boolean;
41
+ /**
42
+ * Set to true expand all child rows. All expand buttons will be hidden.
43
+ */
44
+ expandAll?: boolean;
45
+ /**
46
+ * Set to true collapse all child rows. All expand buttons will be hidden.
47
+ */
48
+ collapseAll?: boolean;
49
+ /**
50
+ * Initial sort column.
51
+ */
52
+ initialSort?: keyof T | (keyof T)[];
53
+ initialSortAscending?: boolean | boolean[];
54
+ /**
55
+ * When specified, the default bootstrap table borders (sides and cells) will be added.
56
+ * This is the default unless overridden in Misc.Settings.grid
57
+ */
58
+ isBordered?: boolean;
59
+ /** When specified, every alternating row will receive a slightly darker background color. */
60
+ isStriped?: boolean;
61
+ /** When specified, the table will have no cell borders, and the table will have no main border. */
62
+ isBorderless?: boolean;
63
+ /** When specified, a background color will be applied on a row if it is being hovered over. */
64
+ showHover?: boolean;
65
+ /** When specified, the table size will be reduced (by reducing the padding sizes in each cell by half). */
66
+ isSmallTable?: boolean;
67
+ /** Additional footer row(s) to display below the main footer row. */
68
+ footerContent?: (data: T[]) => React.ReactNode;
69
+ /**
70
+ * Additional content to show next to the add new button.
71
+ *
72
+ * Set `showAddButton = false` if you don't want the default button.
73
+ */
74
+ footerButtons?: () => React.ReactNode;
75
+ children: ItemCallback<T>;
76
+ }
77
+ export default class Grid<T> extends React.Component<IGridProps<T>> {
78
+ static contextType: React.Context<import("../../React/DataView").DataViewContextParams<unknown>>;
79
+ context: React.ContextType<typeof DataViewContext>;
80
+ private gridContext;
81
+ private prevItems?;
82
+ private headerItem;
83
+ constructor(props: IGridProps<T>);
84
+ render(): JSX.Element;
85
+ private setInitialSort;
86
+ }
87
+ export {};
@@ -1,203 +1,203 @@
1
- import { __assign, __decorate, __extends, __metadata, __rest } from "tslib";
2
- import * as React from 'react';
3
- import { Data, Utils, Misc } from '@singularsystems/neo-core';
4
- import { observer, Observer } from 'mobx-react';
5
- import NeoButton from '../Button';
6
- import { DataViewContext } from '../../React/DataView';
7
- // Grid context
8
- var GridContextParams = /** @class */ (function () {
9
- function GridContextParams() {
10
- this.doneStaticSetup = false;
11
- this.columnCount = 0;
12
- this.hasSummaries = false;
13
- }
14
- Object.defineProperty(GridContextParams.prototype, "inBody", {
15
- get: function () {
16
- return this.section === "body";
17
- },
18
- enumerable: false,
19
- configurable: true
20
- });
21
- return GridContextParams;
22
- }());
23
- export { GridContextParams };
24
- export var GridContext = React.createContext(new GridContextParams());
25
- var Grid = /** @class */ (function (_super) {
26
- __extends(Grid, _super);
27
- function Grid(props) {
28
- var _this = _super.call(this, props) || this;
29
- _this.gridContext = new GridContextParams();
30
- _this.gridContext.section = "header";
31
- return _this;
32
- }
33
- Grid.prototype.render = function () {
34
- 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"]);
36
- if (expandAll === true) {
37
- this.gridContext.expandAll = true;
38
- }
39
- else if (collapseAll === true) {
40
- this.gridContext.expandAll = false;
41
- }
42
- else {
43
- this.gridContext.expandAll = undefined;
44
- }
45
- var className = Utils.joinWithSpaces(domProps.className, "table neo-grid");
46
- // apply bordered styling
47
- if (isBordered !== null && isBordered !== void 0 ? isBordered : Misc.Settings.grid.isBordered) {
48
- className += " table-bordered";
49
- }
50
- // apply striped styling
51
- if (isStriped !== null && isStriped !== void 0 ? isStriped : Misc.Settings.grid.isStriped) {
52
- className += " table-striped";
53
- }
54
- // apply borderless styling
55
- if (isBorderless !== null && isBorderless !== void 0 ? isBorderless : Misc.Settings.grid.isBorderless) {
56
- className += " table-borderless";
57
- }
58
- // apply hover styling
59
- if (showHover !== null && showHover !== void 0 ? showHover : Misc.Settings.grid.showHover) {
60
- className += " table-hover";
61
- }
62
- // use small table sizing
63
- if (isSmallTable !== null && isSmallTable !== void 0 ? isSmallTable : Misc.Settings.grid.isSmallTable) {
64
- className += " table-sm";
65
- }
66
- if (!this.gridContext.dataView || items !== this.prevItems) {
67
- this.prevItems = items;
68
- if (items) {
69
- if (items instanceof Data.DataViewBase) {
70
- this.gridContext.dataView = items;
71
- }
72
- else {
73
- this.gridContext.dataView = new Data.DataView(items);
74
- this.setInitialSort(initialSort, initialSortAscending);
75
- }
76
- this.gridContext.dataView.itemFilter = filterPredicate;
77
- }
78
- else if (this.context) {
79
- this.gridContext.dataView = this.context.dataView;
80
- }
81
- else {
82
- throw "NeoGrid requires it's items prop to be set, or must be in a containing datasource.";
83
- }
84
- if (allowSort !== undefined) {
85
- this.gridContext.dataView.allowSort = allowSort;
86
- }
87
- this.headerItem = this.gridContext.dataView.getMetaItem();
88
- }
89
- return (React.createElement("table", __assign({}, domProps, { className: className }),
90
- React.createElement(GridContext.Provider, { value: this.gridContext },
91
- React.createElement(TableSection, { type: "header" }, this.headerItem && this.props.children(this.headerItem, this.headerItem.meta)),
92
- 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 () { return (showAddButton || addButton || footerButtons || _this.gridContext.hasSummaries || footerContent !== undefined) ?
94
- React.createElement(TableSection, { type: "footer" },
95
- _this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta),
96
- footerContent !== undefined && footerContent(_this.gridContext.dataView.getItems()),
97
- (showAddButton || addButton || footerButtons) &&
98
- React.createElement(AddButtonRow, { addButton: addButton, showAddButton: showAddButton, additionalContent: footerButtons })) : null; }))));
99
- };
100
- Grid.prototype.setInitialSort = function (initialSort, initialSortAscending) {
101
- var _a;
102
- var meta = (_a = this.gridContext.dataView.getMetaItem()) === null || _a === void 0 ? void 0 : _a.meta;
103
- if (initialSort && meta) {
104
- var sortColumns = void 0;
105
- var sortAsc_1;
106
- if (initialSort instanceof Array) {
107
- sortColumns = initialSort;
108
- sortAsc_1 = (initialSortAscending !== null && initialSortAscending !== void 0 ? initialSortAscending : []);
109
- }
110
- else {
111
- sortColumns = [initialSort];
112
- sortAsc_1 = [initialSortAscending];
113
- }
114
- this.gridContext.dataView.sortInfo = sortColumns.map(function (c, i) { return new Data.SortOperation(meta[c].propertyInfo, sortAsc_1[i] !== false); });
115
- }
116
- };
117
- Grid.contextType = DataViewContext;
118
- Grid = __decorate([
119
- observer,
120
- __metadata("design:paramtypes", [Object])
121
- ], Grid);
122
- return Grid;
123
- }(React.Component));
124
- export default Grid;
125
- var TableSection = /** @class */ (function (_super) {
126
- __extends(TableSection, _super);
127
- function TableSection() {
128
- return _super !== null && _super.apply(this, arguments) || this;
129
- }
130
- TableSection.prototype.render = function () {
131
- this.context.section = this.props.type;
132
- return (this.props.type == "header" ?
133
- React.createElement("thead", null, this.props.children) :
134
- this.props.type == "body" ?
135
- React.createElement("tbody", null, this.props.children) :
136
- React.createElement("tfoot", null, this.props.children));
137
- };
138
- TableSection.contextType = GridContext;
139
- return TableSection;
140
- }(React.PureComponent));
141
- var AddButtonRow = /** @class */ (function (_super) {
142
- __extends(AddButtonRow, _super);
143
- function AddButtonRow(props) {
144
- var _this = _super.call(this, props) || this;
145
- _this.domRef = React.createRef();
146
- _this.onAddNew = _this.onAddNew.bind(_this);
147
- return _this;
148
- }
149
- AddButtonRow.prototype.onAddNew = function () {
150
- var newItem = this.context.dataView.addNonSortedItem();
151
- this.focusFirstElement(newItem.entityIdentifier);
152
- if (this.context.dataView instanceof Data.WindowedDataView) {
153
- var view = this.context.dataView;
154
- view.position = (view.filteredItems.length - view.maxItems);
155
- }
156
- };
157
- /**
158
- * Focus the first element that is bound to the item identifier provided.
159
- */
160
- AddButtonRow.prototype.focusFirstElement = function (entityIdentifier) {
161
- var _this = this;
162
- if (entityIdentifier) {
163
- setTimeout(function () {
164
- if (_this.domRef.current) {
165
- var tableParent = _this.domRef.current.parentElement.parentElement;
166
- var firstElement = tableParent.querySelector("[id^=\"".concat(entityIdentifier, "\"]"));
167
- if (firstElement && firstElement.focus) {
168
- firstElement.focus();
169
- }
170
- }
171
- }, 0);
172
- }
173
- };
174
- AddButtonRow.prototype.render = function () {
175
- var _a = this.props, addButton = _a.addButton, showAddButton = _a.showAddButton, additionalContent = _a.additionalContent;
176
- var addButtonOptions = Utils.populatePartialWithDefaults(addButton, __assign({}, Misc.Settings.grid.addButton));
177
- if (!addButtonOptions.onClick)
178
- addButtonOptions.onClick = this.onAddNew;
179
- return (React.createElement("tr", { ref: this.domRef },
180
- React.createElement("td", { colSpan: this.context.columnCount + (this.context.expandProperty ? 1 : 0) },
181
- React.createElement("div", { className: "neo-grid-button-row" },
182
- showAddButton !== false && React.createElement(NeoButton, __assign({}, addButtonOptions)),
183
- additionalContent !== undefined && additionalContent()))));
184
- };
185
- AddButtonRow.contextType = GridContext;
186
- return AddButtonRow;
187
- }(React.Component));
188
- var ItemGroup = /** @class */ (function (_super) {
189
- __extends(ItemGroup, _super);
190
- function ItemGroup() {
191
- return _super !== null && _super.apply(this, arguments) || this;
192
- }
193
- ItemGroup.prototype.render = function () {
194
- this.context.currentItem = this.props.item;
195
- //this.context.inFirstRowInGroup = true;
196
- return (this.props.template(this.props.item, this.props.item.meta));
197
- };
198
- ItemGroup.contextType = GridContext;
199
- ItemGroup = __decorate([
200
- observer
201
- ], ItemGroup);
202
- return ItemGroup;
203
- }(React.Component));
1
+ import { __assign, __decorate, __extends, __metadata, __rest } from "tslib";
2
+ import * as React from 'react';
3
+ import { Data, Utils, Misc } from '@singularsystems/neo-core';
4
+ import { observer, Observer } from 'mobx-react';
5
+ import NeoButton from '../Button';
6
+ import { DataViewContext } from '../../React/DataView';
7
+ // Grid context
8
+ var GridContextParams = /** @class */ (function () {
9
+ function GridContextParams() {
10
+ this.doneStaticSetup = false;
11
+ this.columnCount = 0;
12
+ this.hasSummaries = false;
13
+ }
14
+ Object.defineProperty(GridContextParams.prototype, "inBody", {
15
+ get: function () {
16
+ return this.section === "body";
17
+ },
18
+ enumerable: false,
19
+ configurable: true
20
+ });
21
+ return GridContextParams;
22
+ }());
23
+ export { GridContextParams };
24
+ export var GridContext = React.createContext(new GridContextParams());
25
+ var Grid = /** @class */ (function (_super) {
26
+ __extends(Grid, _super);
27
+ function Grid(props) {
28
+ var _this = _super.call(this, props) || this;
29
+ _this.gridContext = new GridContextParams();
30
+ _this.gridContext.section = "header";
31
+ return _this;
32
+ }
33
+ Grid.prototype.render = function () {
34
+ 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"]);
36
+ if (expandAll === true) {
37
+ this.gridContext.expandAll = true;
38
+ }
39
+ else if (collapseAll === true) {
40
+ this.gridContext.expandAll = false;
41
+ }
42
+ else {
43
+ this.gridContext.expandAll = undefined;
44
+ }
45
+ var className = Utils.joinWithSpaces(domProps.className, "table neo-grid");
46
+ // apply bordered styling
47
+ if (isBordered !== null && isBordered !== void 0 ? isBordered : Misc.Settings.grid.isBordered) {
48
+ className += " table-bordered";
49
+ }
50
+ // apply striped styling
51
+ if (isStriped !== null && isStriped !== void 0 ? isStriped : Misc.Settings.grid.isStriped) {
52
+ className += " table-striped";
53
+ }
54
+ // apply borderless styling
55
+ if (isBorderless !== null && isBorderless !== void 0 ? isBorderless : Misc.Settings.grid.isBorderless) {
56
+ className += " table-borderless";
57
+ }
58
+ // apply hover styling
59
+ if (showHover !== null && showHover !== void 0 ? showHover : Misc.Settings.grid.showHover) {
60
+ className += " table-hover";
61
+ }
62
+ // use small table sizing
63
+ if (isSmallTable !== null && isSmallTable !== void 0 ? isSmallTable : Misc.Settings.grid.isSmallTable) {
64
+ className += " table-sm";
65
+ }
66
+ if (!this.gridContext.dataView || items !== this.prevItems) {
67
+ this.prevItems = items;
68
+ if (items) {
69
+ if (items instanceof Data.DataViewBase) {
70
+ this.gridContext.dataView = items;
71
+ }
72
+ else {
73
+ this.gridContext.dataView = new Data.DataView(items);
74
+ this.setInitialSort(initialSort, initialSortAscending);
75
+ }
76
+ this.gridContext.dataView.itemFilter = filterPredicate;
77
+ }
78
+ else if (this.context) {
79
+ this.gridContext.dataView = this.context.dataView;
80
+ }
81
+ else {
82
+ throw "NeoGrid requires it's items prop to be set, or must be in a containing datasource.";
83
+ }
84
+ if (allowSort !== undefined) {
85
+ this.gridContext.dataView.allowSort = allowSort;
86
+ }
87
+ this.headerItem = this.gridContext.dataView.getMetaItem();
88
+ }
89
+ return (React.createElement("table", __assign({}, domProps, { className: className }),
90
+ React.createElement(GridContext.Provider, { value: this.gridContext },
91
+ React.createElement(TableSection, { type: "header" }, this.headerItem && this.props.children(this.headerItem, this.headerItem.meta)),
92
+ 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 () { return (showAddButton || addButton || footerButtons || _this.gridContext.hasSummaries || footerContent !== undefined) ?
94
+ React.createElement(TableSection, { type: "footer" },
95
+ _this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta),
96
+ footerContent !== undefined && footerContent(_this.gridContext.dataView.getItems()),
97
+ (showAddButton || addButton || footerButtons) &&
98
+ React.createElement(AddButtonRow, { addButton: addButton, showAddButton: showAddButton, additionalContent: footerButtons })) : null; }))));
99
+ };
100
+ Grid.prototype.setInitialSort = function (initialSort, initialSortAscending) {
101
+ var _a;
102
+ var meta = (_a = this.gridContext.dataView.getMetaItem()) === null || _a === void 0 ? void 0 : _a.meta;
103
+ if (initialSort && meta) {
104
+ var sortColumns = void 0;
105
+ var sortAsc_1;
106
+ if (initialSort instanceof Array) {
107
+ sortColumns = initialSort;
108
+ sortAsc_1 = (initialSortAscending !== null && initialSortAscending !== void 0 ? initialSortAscending : []);
109
+ }
110
+ else {
111
+ sortColumns = [initialSort];
112
+ sortAsc_1 = [initialSortAscending];
113
+ }
114
+ this.gridContext.dataView.sortInfo = sortColumns.map(function (c, i) { return new Data.SortOperation(meta[c].propertyInfo, sortAsc_1[i] !== false); });
115
+ }
116
+ };
117
+ Grid.contextType = DataViewContext;
118
+ Grid = __decorate([
119
+ observer,
120
+ __metadata("design:paramtypes", [Object])
121
+ ], Grid);
122
+ return Grid;
123
+ }(React.Component));
124
+ export default Grid;
125
+ var TableSection = /** @class */ (function (_super) {
126
+ __extends(TableSection, _super);
127
+ function TableSection() {
128
+ return _super !== null && _super.apply(this, arguments) || this;
129
+ }
130
+ TableSection.prototype.render = function () {
131
+ this.context.section = this.props.type;
132
+ return (this.props.type == "header" ?
133
+ React.createElement("thead", null, this.props.children) :
134
+ this.props.type == "body" ?
135
+ React.createElement("tbody", null, this.props.children) :
136
+ React.createElement("tfoot", null, this.props.children));
137
+ };
138
+ TableSection.contextType = GridContext;
139
+ return TableSection;
140
+ }(React.PureComponent));
141
+ var AddButtonRow = /** @class */ (function (_super) {
142
+ __extends(AddButtonRow, _super);
143
+ function AddButtonRow(props) {
144
+ var _this = _super.call(this, props) || this;
145
+ _this.domRef = React.createRef();
146
+ _this.onAddNew = _this.onAddNew.bind(_this);
147
+ return _this;
148
+ }
149
+ AddButtonRow.prototype.onAddNew = function () {
150
+ var newItem = this.context.dataView.addNonSortedItem();
151
+ this.focusFirstElement(newItem.entityIdentifier);
152
+ if (this.context.dataView instanceof Data.WindowedDataView) {
153
+ var view = this.context.dataView;
154
+ view.position = (view.filteredItems.length - view.maxItems);
155
+ }
156
+ };
157
+ /**
158
+ * Focus the first element that is bound to the item identifier provided.
159
+ */
160
+ AddButtonRow.prototype.focusFirstElement = function (entityIdentifier) {
161
+ var _this = this;
162
+ if (entityIdentifier) {
163
+ setTimeout(function () {
164
+ if (_this.domRef.current) {
165
+ var tableParent = _this.domRef.current.parentElement.parentElement;
166
+ var firstElement = tableParent.querySelector("[id^=\"".concat(entityIdentifier, "\"]"));
167
+ if (firstElement && firstElement.focus) {
168
+ firstElement.focus();
169
+ }
170
+ }
171
+ }, 0);
172
+ }
173
+ };
174
+ AddButtonRow.prototype.render = function () {
175
+ var _a = this.props, addButton = _a.addButton, showAddButton = _a.showAddButton, additionalContent = _a.additionalContent;
176
+ var addButtonOptions = Utils.populatePartialWithDefaults(addButton, __assign({}, Misc.Settings.grid.addButton));
177
+ if (!addButtonOptions.onClick)
178
+ addButtonOptions.onClick = this.onAddNew;
179
+ return (React.createElement("tr", { ref: this.domRef },
180
+ React.createElement("td", { colSpan: this.context.columnCount + (this.context.expandProperty ? 1 : 0) },
181
+ React.createElement("div", { className: "neo-grid-button-row" },
182
+ showAddButton !== false && React.createElement(NeoButton, __assign({}, addButtonOptions)),
183
+ additionalContent !== undefined && additionalContent()))));
184
+ };
185
+ AddButtonRow.contextType = GridContext;
186
+ return AddButtonRow;
187
+ }(React.Component));
188
+ var ItemGroup = /** @class */ (function (_super) {
189
+ __extends(ItemGroup, _super);
190
+ function ItemGroup() {
191
+ return _super !== null && _super.apply(this, arguments) || this;
192
+ }
193
+ ItemGroup.prototype.render = function () {
194
+ this.context.currentItem = this.props.item;
195
+ //this.context.inFirstRowInGroup = true;
196
+ return (this.props.template(this.props.item, this.props.item.meta));
197
+ };
198
+ ItemGroup.contextType = GridContext;
199
+ ItemGroup = __decorate([
200
+ observer
201
+ ], ItemGroup);
202
+ return ItemGroup;
203
+ }(React.Component));