@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.
- package/CHANGELOG.md +98 -0
- package/README.md +4 -0
- package/dist/Modules/NeoReactModule.d.ts +4 -4
- package/dist/Modules/NeoReactModule.js +28 -26
- package/dist/Modules/ReactSetup.d.ts +2 -2
- package/dist/Modules/ReactSetup.js +17 -17
- package/dist/Modules/Types.d.ts +63 -61
- package/dist/Modules/Types.js +13 -12
- package/dist/React/AutoRunner.d.ts +5 -5
- package/dist/React/AutoRunner.js +94 -92
- package/dist/React/DataView.d.ts +6 -6
- package/dist/React/DataView.js +11 -11
- package/dist/React/ReactModelCreator.d.ts +11 -11
- package/dist/React/ReactModelCreator.js +165 -162
- package/dist/ReactComponents/Button.d.ts +24 -23
- package/dist/ReactComponents/Button.js +131 -123
- package/dist/ReactComponents/Card.d.ts +24 -23
- package/dist/ReactComponents/Card.js +56 -54
- package/dist/ReactComponents/Collapsable.d.ts +23 -23
- package/dist/ReactComponents/Collapsable.js +38 -38
- package/dist/ReactComponents/CollapsableBase.d.ts +13 -13
- package/dist/ReactComponents/CollapsableBase.js +42 -42
- package/dist/ReactComponents/ColorPicker.d.ts +26 -26
- package/dist/ReactComponents/ColorPicker.js +67 -67
- package/dist/ReactComponents/ComponentBase.d.ts +17 -17
- package/dist/ReactComponents/ComponentBase.js +33 -33
- package/dist/ReactComponents/ContextMenu/ContextMenu.d.ts +25 -24
- package/dist/ReactComponents/ContextMenu/ContextMenu.js +91 -88
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.d.ts +14 -14
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.js +48 -48
- package/dist/ReactComponents/ContextMenu/ContextMenuState.d.ts +8 -7
- package/dist/ReactComponents/ContextMenu/ContextMenuState.js +23 -23
- package/dist/ReactComponents/DatePicker.d.ts +19 -19
- package/dist/ReactComponents/DatePicker.js +53 -53
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +93 -83
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +222 -188
- package/dist/ReactComponents/DropDown/DropDown.d.ts +44 -44
- package/dist/ReactComponents/DropDown/DropDown.js +138 -134
- package/dist/ReactComponents/DropDown/DropDownBase.d.ts +16 -15
- package/dist/ReactComponents/DropDown/DropDownBase.js +86 -108
- package/dist/ReactComponents/DropDown/LookupHelper.d.ts +13 -0
- package/dist/ReactComponents/DropDown/LookupHelper.js +45 -0
- package/dist/ReactComponents/ErrorHandler.d.ts +9 -8
- package/dist/ReactComponents/ErrorHandler.js +92 -91
- package/dist/ReactComponents/FileManager/FileBasicInput.d.ts +20 -20
- package/dist/ReactComponents/FileManager/FileBasicInput.js +70 -70
- package/dist/ReactComponents/FileManager/FileContext.d.ts +16 -16
- package/dist/ReactComponents/FileManager/FileContext.js +24 -24
- package/dist/ReactComponents/FileManager/FileDropArea.d.ts +19 -18
- package/dist/ReactComponents/FileManager/FileDropArea.js +66 -64
- package/dist/ReactComponents/FileManager/FileInput.d.ts +44 -42
- package/dist/ReactComponents/FileManager/FileInput.js +191 -189
- package/dist/ReactComponents/FileManager/FileUploadButton.d.ts +17 -17
- package/dist/ReactComponents/FileManager/FileUploadButton.js +49 -49
- package/dist/ReactComponents/FileManager/FileUploadProgress.d.ts +14 -14
- package/dist/ReactComponents/FileManager/FileUploadProgress.js +35 -35
- package/dist/ReactComponents/Form.d.ts +19 -18
- package/dist/ReactComponents/Form.js +90 -90
- package/dist/ReactComponents/FormContext.d.ts +33 -31
- package/dist/ReactComponents/FormContext.js +39 -40
- package/dist/ReactComponents/FormGroup/FormGroup.d.ts +37 -37
- package/dist/ReactComponents/FormGroup/FormGroup.js +83 -84
- package/dist/ReactComponents/FormGroup/FormGroupFloating.d.ts +19 -19
- package/dist/ReactComponents/FormGroup/FormGroupFloating.js +97 -97
- package/dist/ReactComponents/FormGroup/FormGroupInline.d.ts +11 -11
- package/dist/ReactComponents/FormGroup/FormGroupInline.js +43 -43
- package/dist/ReactComponents/Grid/ButtonColumn.d.ts +47 -47
- package/dist/ReactComponents/Grid/ButtonColumn.js +81 -82
- package/dist/ReactComponents/Grid/Column.d.ts +47 -47
- package/dist/ReactComponents/Grid/Column.js +205 -205
- package/dist/ReactComponents/Grid/ColumnHelper.d.ts +12 -12
- package/dist/ReactComponents/Grid/ColumnHelper.js +19 -19
- package/dist/ReactComponents/Grid/Grid.d.ts +87 -90
- package/dist/ReactComponents/Grid/Grid.js +203 -203
- package/dist/ReactComponents/Grid/Row.d.ts +81 -81
- package/dist/ReactComponents/Grid/Row.js +200 -201
- package/dist/ReactComponents/Grid/_Exports.d.ts +5 -5
- package/dist/ReactComponents/Grid/_Exports.js +5 -5
- package/dist/ReactComponents/GridLayout.d.ts +20 -20
- package/dist/ReactComponents/GridLayout.js +38 -38
- package/dist/ReactComponents/Icons/FontAwesomeIconFactory.d.ts +23 -0
- package/dist/ReactComponents/Icons/FontAwesomeIconFactory.js +43 -0
- package/dist/ReactComponents/Icons/IIconFactory.d.ts +21 -0
- package/dist/ReactComponents/Icons/IIconFactory.js +1 -0
- package/dist/ReactComponents/Icons/IconFactory.d.ts +9 -0
- package/dist/ReactComponents/Icons/IconFactory.js +45 -0
- package/dist/ReactComponents/Icons/index.d.ts +3 -0
- package/dist/ReactComponents/Icons/index.js +2 -0
- package/dist/ReactComponents/Input.d.ts +45 -45
- package/dist/ReactComponents/Input.js +153 -152
- package/dist/ReactComponents/InputHelpers.d.ts +6 -5
- package/dist/ReactComponents/InputHelpers.js +29 -33
- package/dist/ReactComponents/Link.d.ts +13 -13
- package/dist/ReactComponents/Link.js +28 -28
- package/dist/ReactComponents/Loader.d.ts +18 -18
- package/dist/ReactComponents/Loader.js +57 -57
- package/dist/ReactComponents/Misc.d.ts +15 -15
- package/dist/ReactComponents/Misc.js +28 -28
- package/dist/ReactComponents/Modal/Modal.d.ts +11 -11
- package/dist/ReactComponents/Modal/Modal.js +129 -129
- package/dist/ReactComponents/Modal/ModalContainer.d.ts +17 -17
- package/dist/ReactComponents/Modal/ModalContainer.js +37 -37
- package/dist/ReactComponents/Modal/ModalPortal.d.ts +16 -15
- package/dist/ReactComponents/Modal/ModalPortal.js +27 -27
- package/dist/ReactComponents/Notifications/Alert.d.ts +7 -6
- package/dist/ReactComponents/Notifications/Alert.js +38 -35
- package/dist/ReactComponents/Notifications/Toast.d.ts +9 -8
- package/dist/ReactComponents/Notifications/Toast.js +47 -45
- package/dist/ReactComponents/Notifications/ToastContainer.d.ts +8 -8
- package/dist/ReactComponents/Notifications/ToastContainer.js +18 -18
- package/dist/ReactComponents/NumberInput.d.ts +57 -50
- package/dist/ReactComponents/NumberInput.js +260 -246
- package/dist/ReactComponents/Paging/BasicPagerControls.d.ts +26 -25
- package/dist/ReactComponents/Paging/BasicPagerControls.js +57 -55
- package/dist/ReactComponents/Paging/PageSizeControl.d.ts +11 -11
- package/dist/ReactComponents/Paging/PageSizeControl.js +21 -21
- package/dist/ReactComponents/Paging/Pager.d.ts +24 -24
- package/dist/ReactComponents/Paging/Pager.js +41 -41
- package/dist/ReactComponents/ProgressBar.d.ts +19 -19
- package/dist/ReactComponents/ProgressBar.js +52 -52
- package/dist/ReactComponents/PropTypes.d.ts +161 -161
- package/dist/ReactComponents/PropTypes.js +253 -236
- package/dist/ReactComponents/RadioList.d.ts +29 -29
- package/dist/ReactComponents/RadioList.js +59 -77
- package/dist/ReactComponents/Slider.d.ts +28 -28
- package/dist/ReactComponents/Slider.js +76 -76
- package/dist/ReactComponents/StateObserver.d.ts +15 -15
- package/dist/ReactComponents/StateObserver.js +35 -35
- package/dist/ReactComponents/Tabs/Tab.d.ts +42 -41
- package/dist/ReactComponents/Tabs/Tab.js +71 -72
- package/dist/ReactComponents/Tabs/TabContainer.d.ts +44 -44
- package/dist/ReactComponents/Tabs/TabContainer.js +98 -98
- package/dist/ReactComponents/Tabs/TabManager.d.ts +62 -62
- package/dist/ReactComponents/Tabs/TabManager.js +154 -154
- package/dist/ReactComponents/Tooltip.d.ts +20 -19
- package/dist/ReactComponents/Tooltip.js +51 -51
- package/dist/ReactComponents/TooltipHelper.d.ts +8 -8
- package/dist/ReactComponents/TooltipHelper.js +84 -84
- package/dist/ReactComponents/TooltipProvider.d.ts +30 -30
- package/dist/ReactComponents/TooltipProvider.js +111 -111
- package/dist/ReactComponents/ValidationSummary.d.ts +23 -22
- package/dist/ReactComponents/ValidationSummary.js +46 -43
- package/dist/ReactComponents/_Exports.d.ts +41 -41
- package/dist/ReactComponents/_Exports.js +41 -41
- package/dist/ReactComponents/_Managers.d.ts +4 -4
- package/dist/ReactComponents/_Managers.js +4 -4
- package/dist/Routing/BreadCrumbItem.d.ts +14 -14
- package/dist/Routing/BreadCrumbItem.js +12 -12
- package/dist/Routing/IRouteChangedProps.d.ts +31 -31
- package/dist/Routing/IRouteChangedProps.js +1 -1
- package/dist/Routing/IRouteParameter.d.ts +22 -22
- package/dist/Routing/IRouteParameter.js +9 -9
- package/dist/Routing/MenuRoute.d.ts +25 -24
- package/dist/Routing/MenuRoute.js +24 -24
- package/dist/Routing/NavigationHelper.d.ts +41 -40
- package/dist/Routing/NavigationHelper.js +61 -61
- package/dist/Routing/PageLeaveHandler.d.ts +13 -13
- package/dist/Routing/PageLeaveHandler.js +74 -74
- package/dist/Routing/RouteProvider.d.ts +31 -31
- package/dist/Routing/RouteProvider.js +92 -92
- package/dist/Routing/RouteView.d.ts +50 -50
- package/dist/Routing/RouteView.js +143 -144
- package/dist/Routing/RoutingState.d.ts +18 -15
- package/dist/Routing/RoutingState.js +45 -40
- package/dist/Routing/ViewParameter.d.ts +80 -58
- package/dist/Routing/ViewParameter.js +116 -95
- package/dist/Routing/ViewParameterList.d.ts +53 -53
- package/dist/Routing/ViewParameterList.js +163 -145
- package/dist/Routing/index.d.ts +9 -9
- package/dist/Routing/index.js +6 -6
- package/dist/Services/DisposeHelper.d.ts +15 -15
- package/dist/Services/DisposeHelper.js +40 -41
- package/dist/Services/IDisposeHelper.d.ts +12 -12
- package/dist/Services/IDisposeHelper.js +1 -1
- package/dist/Views/EmptyViewModel.d.ts +5 -5
- package/dist/Views/EmptyViewModel.js +14 -14
- package/dist/Views/IViewModel.d.ts +16 -16
- package/dist/Views/IViewModel.js +1 -1
- package/dist/Views/PersistentViewBase.d.ts +10 -10
- package/dist/Views/PersistentViewBase.js +21 -21
- package/dist/Views/ViewBase.d.ts +70 -71
- package/dist/Views/ViewBase.js +166 -153
- package/dist/Views/ViewComponentBase.d.ts +19 -13
- package/dist/Views/ViewComponentBase.js +24 -21
- package/dist/Views/ViewModelBase.d.ts +57 -56
- package/dist/Views/ViewModelBase.js +122 -118
- package/dist/Views/ViewState.d.ts +13 -13
- package/dist/Views/ViewState.js +9 -9
- package/dist/Views/index.d.ts +5 -5
- package/dist/Views/index.js +5 -5
- package/dist/index.d.ts +11 -10
- package/dist/index.js +10 -9
- package/package.json +26 -26
- package/styles/DatePicker.scss +2 -2
- package/styles/Forms.scss +5 -0
- package/styles/Validation.scss +0 -9
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
import { Model } from '@singularsystems/neo-core';
|
|
2
|
-
import { CancellableEvent } from '../Misc';
|
|
3
|
-
/**
|
|
4
|
-
* Tab manager used to manage a tab component.
|
|
5
|
-
* @param T string union type of tab names.
|
|
6
|
-
*/
|
|
7
|
-
var TabManager = /** @class */ (function () {
|
|
8
|
-
/**
|
|
9
|
-
* Creates a tab manager used to bind to a tab container.
|
|
10
|
-
* @param selectedTab Initially selected tab.
|
|
11
|
-
* @param autoSelectFirstTab Set to true if the first child tab should become selected.
|
|
12
|
-
*/
|
|
13
|
-
function TabManager(selectedTab, autoSelectFirstTab) {
|
|
14
|
-
if (selectedTab === void 0) { selectedTab = ""; }
|
|
15
|
-
if (autoSelectFirstTab === void 0) { autoSelectFirstTab = false; }
|
|
16
|
-
this.autoSelectFirstTab = autoSelectFirstTab;
|
|
17
|
-
this.observable = new Model.ObservableValue("");
|
|
18
|
-
this.tabs = {};
|
|
19
|
-
this.observable.value = selectedTab;
|
|
20
|
-
this.onTabChanged = this.onTabChanged.bind(this);
|
|
21
|
-
}
|
|
22
|
-
/** Called by tab container. */
|
|
23
|
-
TabManager.prototype.initialise = function () {
|
|
24
|
-
if (this.selectedTab !== "") {
|
|
25
|
-
this.onTabChanged();
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/** Called by tab container. */
|
|
29
|
-
TabManager.prototype.destroy = function () {
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(TabManager.prototype, "selectedTab", {
|
|
32
|
-
get: function () {
|
|
33
|
-
return this.observable.value;
|
|
34
|
-
},
|
|
35
|
-
set: function (value) {
|
|
36
|
-
var _this = this;
|
|
37
|
-
if (!this.tabs[value]) {
|
|
38
|
-
// Probably different case, find the actual tab key.
|
|
39
|
-
var foundValue = Object.keys(this.tabs).find(function (t) { return t.toLowerCase() === value.toLowerCase(); });
|
|
40
|
-
if (foundValue) {
|
|
41
|
-
value = foundValue;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
var currentTabKey = this.observable.peek;
|
|
45
|
-
if (value !== currentTabKey) {
|
|
46
|
-
var cancellableEvent = new CancellableEvent(function () { return currentTabKey === _this.observable.peek; });
|
|
47
|
-
var currentTab = this.tabs[currentTabKey];
|
|
48
|
-
if ((currentTab === null || currentTab === void 0 ? void 0 : currentTab.onLeave) !== undefined) {
|
|
49
|
-
currentTab.onLeave(cancellableEvent);
|
|
50
|
-
}
|
|
51
|
-
cancellableEvent.tryRunAction(function () {
|
|
52
|
-
_this.observable.value = value;
|
|
53
|
-
_this.onTabChanged();
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
enumerable: false,
|
|
58
|
-
configurable: true
|
|
59
|
-
});
|
|
60
|
-
/**
|
|
61
|
-
* Registers a callback to run when the tab is first displayed, or when reset is called with reInitialise=true.
|
|
62
|
-
*/
|
|
63
|
-
TabManager.prototype.onTabInitialise = function (tabKey, callback) {
|
|
64
|
-
var tab = this.getTab(tabKey, true);
|
|
65
|
-
tab.onInitialise = callback;
|
|
66
|
-
return this;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Registers a callback to run whenever the tab with this tab key is displayed.
|
|
70
|
-
*/
|
|
71
|
-
TabManager.prototype.onTabDisplayed = function (tabKey, callback) {
|
|
72
|
-
var tab = this.getTab(tabKey, true);
|
|
73
|
-
tab.onDisplayed = callback;
|
|
74
|
-
return this;
|
|
75
|
-
};
|
|
76
|
-
TabManager.prototype.tabMounted = function (tabKey, onLeave) {
|
|
77
|
-
var tab = this.getTab(tabKey, true);
|
|
78
|
-
tab.onLeave = onLeave;
|
|
79
|
-
if (!this.selectedTab && this.autoSelectFirstTab) {
|
|
80
|
-
this.selectedTab = tabKey;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
TabManager.prototype.getTab = function (tabKey, create) {
|
|
84
|
-
if (create === void 0) { create = false; }
|
|
85
|
-
var tab = this.tabs[tabKey];
|
|
86
|
-
if (!tab && create) {
|
|
87
|
-
tab = new Tab();
|
|
88
|
-
this.tabs[tabKey] = tab;
|
|
89
|
-
}
|
|
90
|
-
return tab;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Marks the tab as 'initial'.
|
|
94
|
-
* @param reInitialise True if the tabs onInitialise() should be invoked.
|
|
95
|
-
*/
|
|
96
|
-
TabManager.prototype.reset = function (tabKey, reInitialise) {
|
|
97
|
-
if (reInitialise === void 0) { reInitialise = false; }
|
|
98
|
-
var tab = this.getTab(tabKey);
|
|
99
|
-
if (tab) {
|
|
100
|
-
if (reInitialise) {
|
|
101
|
-
tab.initialise();
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
tab.hasFetched = false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
/** Calls onInitialise() if the tab has not yet initialised. */
|
|
109
|
-
TabManager.prototype.initialiseTab = function (tabKey) {
|
|
110
|
-
var tab = this.getTab(tabKey);
|
|
111
|
-
if (tab && !tab.hasFetched) {
|
|
112
|
-
tab.initialise();
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Marks all tabs as 'initial', causing onInitialise() to be called the next time each is displayed.
|
|
117
|
-
* @param reInitialise True if the onInitialise() should be called on the currently displayed tab.
|
|
118
|
-
*/
|
|
119
|
-
TabManager.prototype.resetAll = function (reInitialise) {
|
|
120
|
-
if (reInitialise === void 0) { reInitialise = false; }
|
|
121
|
-
var currentTabKey = this.observable.peek;
|
|
122
|
-
for (var tabKey in this.tabs) {
|
|
123
|
-
this.reset(tabKey, reInitialise && currentTabKey === tabKey);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
TabManager.prototype.onTabChanged = function () {
|
|
127
|
-
var tab = this.getTab(this.observable.peek);
|
|
128
|
-
if (tab) {
|
|
129
|
-
if (!tab.hasFetched) {
|
|
130
|
-
tab.initialise();
|
|
131
|
-
}
|
|
132
|
-
if (tab.onDisplayed) {
|
|
133
|
-
tab.onDisplayed();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
return TabManager;
|
|
138
|
-
}());
|
|
139
|
-
export { TabManager };
|
|
140
|
-
var Tab = /** @class */ (function () {
|
|
141
|
-
function Tab() {
|
|
142
|
-
this.hasFetched = false;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Calls initialise without checking hasFetched.
|
|
146
|
-
*/
|
|
147
|
-
Tab.prototype.initialise = function () {
|
|
148
|
-
if (this.onInitialise) {
|
|
149
|
-
this.onInitialise();
|
|
150
|
-
}
|
|
151
|
-
this.hasFetched = true;
|
|
152
|
-
};
|
|
153
|
-
return Tab;
|
|
154
|
-
}());
|
|
1
|
+
import { Model } from '@singularsystems/neo-core';
|
|
2
|
+
import { CancellableEvent } from '../Misc';
|
|
3
|
+
/**
|
|
4
|
+
* Tab manager used to manage a tab component.
|
|
5
|
+
* @param T string union type of tab names.
|
|
6
|
+
*/
|
|
7
|
+
var TabManager = /** @class */ (function () {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a tab manager used to bind to a tab container.
|
|
10
|
+
* @param selectedTab Initially selected tab.
|
|
11
|
+
* @param autoSelectFirstTab Set to true if the first child tab should become selected.
|
|
12
|
+
*/
|
|
13
|
+
function TabManager(selectedTab, autoSelectFirstTab) {
|
|
14
|
+
if (selectedTab === void 0) { selectedTab = ""; }
|
|
15
|
+
if (autoSelectFirstTab === void 0) { autoSelectFirstTab = false; }
|
|
16
|
+
this.autoSelectFirstTab = autoSelectFirstTab;
|
|
17
|
+
this.observable = new Model.ObservableValue("");
|
|
18
|
+
this.tabs = {};
|
|
19
|
+
this.observable.value = selectedTab;
|
|
20
|
+
this.onTabChanged = this.onTabChanged.bind(this);
|
|
21
|
+
}
|
|
22
|
+
/** Called by tab container. */
|
|
23
|
+
TabManager.prototype.initialise = function () {
|
|
24
|
+
if (this.selectedTab !== "") {
|
|
25
|
+
this.onTabChanged();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/** Called by tab container. */
|
|
29
|
+
TabManager.prototype.destroy = function () {
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(TabManager.prototype, "selectedTab", {
|
|
32
|
+
get: function () {
|
|
33
|
+
return this.observable.value;
|
|
34
|
+
},
|
|
35
|
+
set: function (value) {
|
|
36
|
+
var _this = this;
|
|
37
|
+
if (!this.tabs[value]) {
|
|
38
|
+
// Probably different case, find the actual tab key.
|
|
39
|
+
var foundValue = Object.keys(this.tabs).find(function (t) { return t.toLowerCase() === value.toLowerCase(); });
|
|
40
|
+
if (foundValue) {
|
|
41
|
+
value = foundValue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
var currentTabKey = this.observable.peek;
|
|
45
|
+
if (value !== currentTabKey) {
|
|
46
|
+
var cancellableEvent = new CancellableEvent(function () { return currentTabKey === _this.observable.peek; });
|
|
47
|
+
var currentTab = this.tabs[currentTabKey];
|
|
48
|
+
if ((currentTab === null || currentTab === void 0 ? void 0 : currentTab.onLeave) !== undefined) {
|
|
49
|
+
currentTab.onLeave(cancellableEvent);
|
|
50
|
+
}
|
|
51
|
+
cancellableEvent.tryRunAction(function () {
|
|
52
|
+
_this.observable.value = value;
|
|
53
|
+
_this.onTabChanged();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
enumerable: false,
|
|
58
|
+
configurable: true
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Registers a callback to run when the tab is first displayed, or when reset is called with reInitialise=true.
|
|
62
|
+
*/
|
|
63
|
+
TabManager.prototype.onTabInitialise = function (tabKey, callback) {
|
|
64
|
+
var tab = this.getTab(tabKey, true);
|
|
65
|
+
tab.onInitialise = callback;
|
|
66
|
+
return this;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Registers a callback to run whenever the tab with this tab key is displayed.
|
|
70
|
+
*/
|
|
71
|
+
TabManager.prototype.onTabDisplayed = function (tabKey, callback) {
|
|
72
|
+
var tab = this.getTab(tabKey, true);
|
|
73
|
+
tab.onDisplayed = callback;
|
|
74
|
+
return this;
|
|
75
|
+
};
|
|
76
|
+
TabManager.prototype.tabMounted = function (tabKey, onLeave) {
|
|
77
|
+
var tab = this.getTab(tabKey, true);
|
|
78
|
+
tab.onLeave = onLeave;
|
|
79
|
+
if (!this.selectedTab && this.autoSelectFirstTab) {
|
|
80
|
+
this.selectedTab = tabKey;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
TabManager.prototype.getTab = function (tabKey, create) {
|
|
84
|
+
if (create === void 0) { create = false; }
|
|
85
|
+
var tab = this.tabs[tabKey];
|
|
86
|
+
if (!tab && create) {
|
|
87
|
+
tab = new Tab();
|
|
88
|
+
this.tabs[tabKey] = tab;
|
|
89
|
+
}
|
|
90
|
+
return tab;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Marks the tab as 'initial'.
|
|
94
|
+
* @param reInitialise True if the tabs onInitialise() should be invoked.
|
|
95
|
+
*/
|
|
96
|
+
TabManager.prototype.reset = function (tabKey, reInitialise) {
|
|
97
|
+
if (reInitialise === void 0) { reInitialise = false; }
|
|
98
|
+
var tab = this.getTab(tabKey);
|
|
99
|
+
if (tab) {
|
|
100
|
+
if (reInitialise) {
|
|
101
|
+
tab.initialise();
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
tab.hasFetched = false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/** Calls onInitialise() if the tab has not yet initialised. */
|
|
109
|
+
TabManager.prototype.initialiseTab = function (tabKey) {
|
|
110
|
+
var tab = this.getTab(tabKey);
|
|
111
|
+
if (tab && !tab.hasFetched) {
|
|
112
|
+
tab.initialise();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Marks all tabs as 'initial', causing onInitialise() to be called the next time each is displayed.
|
|
117
|
+
* @param reInitialise True if the onInitialise() should be called on the currently displayed tab.
|
|
118
|
+
*/
|
|
119
|
+
TabManager.prototype.resetAll = function (reInitialise) {
|
|
120
|
+
if (reInitialise === void 0) { reInitialise = false; }
|
|
121
|
+
var currentTabKey = this.observable.peek;
|
|
122
|
+
for (var tabKey in this.tabs) {
|
|
123
|
+
this.reset(tabKey, reInitialise && currentTabKey === tabKey);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
TabManager.prototype.onTabChanged = function () {
|
|
127
|
+
var tab = this.getTab(this.observable.peek);
|
|
128
|
+
if (tab) {
|
|
129
|
+
if (!tab.hasFetched) {
|
|
130
|
+
tab.initialise();
|
|
131
|
+
}
|
|
132
|
+
if (tab.onDisplayed) {
|
|
133
|
+
tab.onDisplayed();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
return TabManager;
|
|
138
|
+
}());
|
|
139
|
+
export { TabManager };
|
|
140
|
+
var Tab = /** @class */ (function () {
|
|
141
|
+
function Tab() {
|
|
142
|
+
this.hasFetched = false;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Calls initialise without checking hasFetched.
|
|
146
|
+
*/
|
|
147
|
+
Tab.prototype.initialise = function () {
|
|
148
|
+
if (this.onInitialise) {
|
|
149
|
+
this.onInitialise();
|
|
150
|
+
}
|
|
151
|
+
this.hasFetched = true;
|
|
152
|
+
};
|
|
153
|
+
return Tab;
|
|
154
|
+
}());
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { Components } from '@singularsystems/neo-core';
|
|
2
|
-
import React, { HTMLProps } from 'react';
|
|
3
|
-
export interface ITooltipProps extends Components.Tooltip.ITooltipOptions<string | JSX.Element> {
|
|
4
|
-
/**
|
|
5
|
-
* True if the div wrapping the content must display inline.
|
|
6
|
-
*/
|
|
7
|
-
inline?: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
static
|
|
19
|
-
|
|
1
|
+
import { Components } from '@singularsystems/neo-core';
|
|
2
|
+
import React, { HTMLProps } from 'react';
|
|
3
|
+
export interface ITooltipProps extends Components.Tooltip.ITooltipOptions<string | JSX.Element> {
|
|
4
|
+
/**
|
|
5
|
+
* True if the div wrapping the content must display inline.
|
|
6
|
+
*/
|
|
7
|
+
inline?: boolean;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export default class Tooltip extends React.Component<ITooltipProps> {
|
|
11
|
+
private divRef;
|
|
12
|
+
private contentRef;
|
|
13
|
+
constructor(props: ITooltipProps);
|
|
14
|
+
componentWillUnmount(): void;
|
|
15
|
+
private onMouseEnter;
|
|
16
|
+
private onMouseLeave;
|
|
17
|
+
render(): JSX.Element;
|
|
18
|
+
static fromDataAttributes(element: JSX.Element, attributes: {}): JSX.Element;
|
|
19
|
+
static setDomProperties(dom: HTMLProps<HTMLElement>, tooltipOptions: string | Components.Tooltip.ITooltipOptions): void;
|
|
20
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { TooltipHelper } from './TooltipHelper';
|
|
4
|
-
var Tooltip = /** @class */ (function (_super) {
|
|
5
|
-
__extends(Tooltip, _super);
|
|
6
|
-
function Tooltip(props) {
|
|
7
|
-
var _this = _super.call(this, props) || this;
|
|
8
|
-
_this.divRef = React.createRef();
|
|
9
|
-
_this.contentRef = React.createRef();
|
|
10
|
-
_this.onMouseEnter = _this.onMouseEnter.bind(_this);
|
|
11
|
-
_this.onMouseLeave = _this.onMouseLeave.bind(_this);
|
|
12
|
-
return _this;
|
|
13
|
-
}
|
|
14
|
-
Tooltip.prototype.componentWillUnmount = function () {
|
|
15
|
-
TooltipHelper.hideTooltip();
|
|
16
|
-
};
|
|
17
|
-
Tooltip.prototype.onMouseEnter = function (e) {
|
|
18
|
-
if (this.divRef.current && this.contentRef.current) {
|
|
19
|
-
TooltipHelper.showTooltip(this.divRef.current, this.contentRef.current.innerHTML, true, this.props.alignment, this.props.position, this.props.className);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
Tooltip.prototype.onMouseLeave = function (e) {
|
|
23
|
-
TooltipHelper.hideTooltip();
|
|
24
|
-
};
|
|
25
|
-
Tooltip.prototype.render = function () {
|
|
26
|
-
return React.createElement("div", { ref: this.divRef, onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave, style: { display: this.props.inline ? "inline-block" : "" } },
|
|
27
|
-
React.createElement("div", { style: { display: "none" }, ref: this.contentRef }, this.props.content),
|
|
28
|
-
this.props.children);
|
|
29
|
-
};
|
|
30
|
-
Tooltip.fromDataAttributes = function (element, attributes) {
|
|
31
|
-
if (attributes["data-tip"]) {
|
|
32
|
-
return React.createElement(Tooltip, { content: attributes["data-tip"], className: attributes["data-tip-class"], alignment: attributes["data-tip-align"], position: attributes["data-tip-pos"] }, element);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return element;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Tooltip.setDomProperties = function (dom, tooltipOptions) {
|
|
39
|
-
if (typeof tooltipOptions === "string") {
|
|
40
|
-
dom["data-tip"] = tooltipOptions;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
dom["data-tip"] = tooltipOptions.content;
|
|
44
|
-
dom["data-tip-class"] = tooltipOptions.className;
|
|
45
|
-
dom["data-tip-align"] = tooltipOptions.alignment;
|
|
46
|
-
dom["data-tip-pos"] = tooltipOptions.position;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
return Tooltip;
|
|
50
|
-
}(React.Component));
|
|
51
|
-
export default Tooltip;
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TooltipHelper } from './TooltipHelper';
|
|
4
|
+
var Tooltip = /** @class */ (function (_super) {
|
|
5
|
+
__extends(Tooltip, _super);
|
|
6
|
+
function Tooltip(props) {
|
|
7
|
+
var _this = _super.call(this, props) || this;
|
|
8
|
+
_this.divRef = React.createRef();
|
|
9
|
+
_this.contentRef = React.createRef();
|
|
10
|
+
_this.onMouseEnter = _this.onMouseEnter.bind(_this);
|
|
11
|
+
_this.onMouseLeave = _this.onMouseLeave.bind(_this);
|
|
12
|
+
return _this;
|
|
13
|
+
}
|
|
14
|
+
Tooltip.prototype.componentWillUnmount = function () {
|
|
15
|
+
TooltipHelper.hideTooltip();
|
|
16
|
+
};
|
|
17
|
+
Tooltip.prototype.onMouseEnter = function (e) {
|
|
18
|
+
if (this.divRef.current && this.contentRef.current) {
|
|
19
|
+
TooltipHelper.showTooltip(this.divRef.current, this.contentRef.current.innerHTML, true, this.props.alignment, this.props.position, this.props.className);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
Tooltip.prototype.onMouseLeave = function (e) {
|
|
23
|
+
TooltipHelper.hideTooltip();
|
|
24
|
+
};
|
|
25
|
+
Tooltip.prototype.render = function () {
|
|
26
|
+
return React.createElement("div", { ref: this.divRef, onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave, style: { display: this.props.inline ? "inline-block" : "" } },
|
|
27
|
+
React.createElement("div", { style: { display: "none" }, ref: this.contentRef }, this.props.content),
|
|
28
|
+
this.props.children);
|
|
29
|
+
};
|
|
30
|
+
Tooltip.fromDataAttributes = function (element, attributes) {
|
|
31
|
+
if (attributes["data-tip"]) {
|
|
32
|
+
return React.createElement(Tooltip, { content: attributes["data-tip"], className: attributes["data-tip-class"], alignment: attributes["data-tip-align"], position: attributes["data-tip-pos"] }, element);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return element;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Tooltip.setDomProperties = function (dom, tooltipOptions) {
|
|
39
|
+
if (typeof tooltipOptions === "string") {
|
|
40
|
+
dom["data-tip"] = tooltipOptions;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
dom["data-tip"] = tooltipOptions.content;
|
|
44
|
+
dom["data-tip-class"] = tooltipOptions.className;
|
|
45
|
+
dom["data-tip-align"] = tooltipOptions.alignment;
|
|
46
|
+
dom["data-tip-pos"] = tooltipOptions.position;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return Tooltip;
|
|
50
|
+
}(React.Component));
|
|
51
|
+
export default Tooltip;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Components } from '@singularsystems/neo-core';
|
|
2
|
-
export declare class TooltipHelper {
|
|
3
|
-
private static toolTipContainer;
|
|
4
|
-
static showTooltip(on: HTMLElement, content: string, isHtml: boolean, aligmnent?: Components.Tooltip.Alignment, position?: Components.Tooltip.Position, className?: string): void;
|
|
5
|
-
static hideTooltip(): void;
|
|
6
|
-
private static positionTooltip;
|
|
7
|
-
private static getPrefixedStyleName;
|
|
8
|
-
}
|
|
1
|
+
import { Components } from '@singularsystems/neo-core';
|
|
2
|
+
export declare class TooltipHelper {
|
|
3
|
+
private static toolTipContainer;
|
|
4
|
+
static showTooltip(on: HTMLElement, content: string, isHtml: boolean, aligmnent?: Components.Tooltip.Alignment, position?: Components.Tooltip.Position, className?: string): void;
|
|
5
|
+
static hideTooltip(): void;
|
|
6
|
+
private static positionTooltip;
|
|
7
|
+
private static getPrefixedStyleName;
|
|
8
|
+
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { Misc } from '@singularsystems/neo-core';
|
|
2
|
-
import { containerId } from './TooltipProvider';
|
|
3
|
-
var arrowHeight = 6;
|
|
4
|
-
var TooltipHelper = /** @class */ (function () {
|
|
5
|
-
function TooltipHelper() {
|
|
6
|
-
}
|
|
7
|
-
TooltipHelper.showTooltip = function (on, content, isHtml, aligmnent, position, className) {
|
|
8
|
-
this.toolTipContainer = Misc.Globals.root.getElementById(containerId);
|
|
9
|
-
if (this.toolTipContainer) {
|
|
10
|
-
var ttText = this.toolTipContainer.firstChild;
|
|
11
|
-
if (isHtml) {
|
|
12
|
-
ttText.innerHTML = content;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
ttText.innerText = content;
|
|
16
|
-
}
|
|
17
|
-
TooltipHelper.positionTooltip(this.toolTipContainer, on, aligmnent, position, className);
|
|
18
|
-
this.toolTipContainer.classList.add("show");
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
console.error("Tooltip: TooltipProvider has not been added to the app.");
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
TooltipHelper.hideTooltip = function () {
|
|
25
|
-
if (this.toolTipContainer) {
|
|
26
|
-
this.toolTipContainer.classList.remove("show");
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
TooltipHelper.positionTooltip = function (toolTipContainer, anchor, alignment, position, className) {
|
|
30
|
-
var isHorizontal = position === "left" || position === "right";
|
|
31
|
-
toolTipContainer.className = "neo-tooltip" + (isHorizontal ? " horizontal" : "");
|
|
32
|
-
if (className) {
|
|
33
|
-
toolTipContainer.classList.add(className);
|
|
34
|
-
}
|
|
35
|
-
var ttArrow = toolTipContainer.lastChild;
|
|
36
|
-
var bgColor = window.getComputedStyle(toolTipContainer).backgroundColor;
|
|
37
|
-
var startName = isHorizontal ? "top" : "left", endName = isHorizontal ? "bottom" : "right", dimensionName = isHorizontal ? "height" : "width", alignName = isHorizontal ? "left" : "top", endAlignName = isHorizontal ? "right" : "bottom", alignDimensionName = isHorizontal ? "width" : "height";
|
|
38
|
-
toolTipContainer.style.top = "0";
|
|
39
|
-
toolTipContainer.style.left = "0";
|
|
40
|
-
var ttRect = toolTipContainer.getBoundingClientRect();
|
|
41
|
-
var anchorRect = anchor.getBoundingClientRect();
|
|
42
|
-
if (alignment === "start-edge") {
|
|
43
|
-
alignment = (anchorRect[startName] + ttRect[dimensionName] + 20 > window[this.getPrefixedStyleName("inner", dimensionName)]) ? "end" : "start";
|
|
44
|
-
}
|
|
45
|
-
else if (alignment === "end-edge") {
|
|
46
|
-
alignment = (anchorRect[endName] - ttRect[dimensionName] < 15) ? "start" : "end";
|
|
47
|
-
}
|
|
48
|
-
var start = anchorRect[startName] + (anchorRect[dimensionName] - ttRect[dimensionName]) / 2;
|
|
49
|
-
var arrowPosition = anchorRect[dimensionName] / 2;
|
|
50
|
-
if (alignment === "start") {
|
|
51
|
-
start = anchorRect[startName];
|
|
52
|
-
arrowPosition = 20;
|
|
53
|
-
}
|
|
54
|
-
else if (alignment === "end") {
|
|
55
|
-
start = anchorRect[endName] - ttRect[dimensionName];
|
|
56
|
-
arrowPosition = anchorRect[dimensionName] - 20;
|
|
57
|
-
}
|
|
58
|
-
// Check if the tooltip is going to go off the edge of the screen.
|
|
59
|
-
var clampedStart = Math.max(Math.min(start, window[this.getPrefixedStyleName("inner", dimensionName)] - ttRect[dimensionName] - 20), 15);
|
|
60
|
-
var arrowOffset = anchorRect[startName] - clampedStart;
|
|
61
|
-
ttArrow.removeAttribute("style");
|
|
62
|
-
ttArrow.style[startName] = (arrowOffset + arrowPosition) + "px";
|
|
63
|
-
var align = anchorRect[alignName] - ttRect[alignDimensionName] - arrowHeight;
|
|
64
|
-
if ((align < 20 || position === endAlignName) && anchorRect[endAlignName] + ttRect[alignDimensionName] + arrowHeight + 20 < window[this.getPrefixedStyleName("inner", alignDimensionName)]) {
|
|
65
|
-
align = anchorRect[endAlignName] + arrowHeight;
|
|
66
|
-
ttArrow.style[this.getPrefixedStyleName("border", endAlignName)] = "5px solid " + bgColor;
|
|
67
|
-
ttArrow.style[this.getPrefixedStyleName("border", alignName)] = "none";
|
|
68
|
-
ttArrow.style[alignName] = "-5px";
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// Show above
|
|
72
|
-
ttArrow.style[this.getPrefixedStyleName("border", alignName)] = "5px solid " + bgColor;
|
|
73
|
-
ttArrow.style[this.getPrefixedStyleName("border", endAlignName)] = "none";
|
|
74
|
-
ttArrow.style[endAlignName] = "-5px";
|
|
75
|
-
}
|
|
76
|
-
toolTipContainer.style[alignName] = align + (isHorizontal ? window.scrollX : window.scrollY) + "px";
|
|
77
|
-
toolTipContainer.style[startName] = clampedStart + (isHorizontal ? window.scrollY : window.scrollX) + "px";
|
|
78
|
-
};
|
|
79
|
-
TooltipHelper.getPrefixedStyleName = function (prefix, styleName) {
|
|
80
|
-
return prefix + styleName[0].toUpperCase() + styleName.substring(1);
|
|
81
|
-
};
|
|
82
|
-
return TooltipHelper;
|
|
83
|
-
}());
|
|
84
|
-
export { TooltipHelper };
|
|
1
|
+
import { Misc } from '@singularsystems/neo-core';
|
|
2
|
+
import { containerId } from './TooltipProvider';
|
|
3
|
+
var arrowHeight = 6;
|
|
4
|
+
var TooltipHelper = /** @class */ (function () {
|
|
5
|
+
function TooltipHelper() {
|
|
6
|
+
}
|
|
7
|
+
TooltipHelper.showTooltip = function (on, content, isHtml, aligmnent, position, className) {
|
|
8
|
+
this.toolTipContainer = Misc.Globals.root.getElementById(containerId);
|
|
9
|
+
if (this.toolTipContainer) {
|
|
10
|
+
var ttText = this.toolTipContainer.firstChild;
|
|
11
|
+
if (isHtml) {
|
|
12
|
+
ttText.innerHTML = content;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
ttText.innerText = content;
|
|
16
|
+
}
|
|
17
|
+
TooltipHelper.positionTooltip(this.toolTipContainer, on, aligmnent, position, className);
|
|
18
|
+
this.toolTipContainer.classList.add("show");
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.error("Tooltip: TooltipProvider has not been added to the app.");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
TooltipHelper.hideTooltip = function () {
|
|
25
|
+
if (this.toolTipContainer) {
|
|
26
|
+
this.toolTipContainer.classList.remove("show");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
TooltipHelper.positionTooltip = function (toolTipContainer, anchor, alignment, position, className) {
|
|
30
|
+
var isHorizontal = position === "left" || position === "right";
|
|
31
|
+
toolTipContainer.className = "neo-tooltip" + (isHorizontal ? " horizontal" : "");
|
|
32
|
+
if (className) {
|
|
33
|
+
toolTipContainer.classList.add(className);
|
|
34
|
+
}
|
|
35
|
+
var ttArrow = toolTipContainer.lastChild;
|
|
36
|
+
var bgColor = window.getComputedStyle(toolTipContainer).backgroundColor;
|
|
37
|
+
var startName = isHorizontal ? "top" : "left", endName = isHorizontal ? "bottom" : "right", dimensionName = isHorizontal ? "height" : "width", alignName = isHorizontal ? "left" : "top", endAlignName = isHorizontal ? "right" : "bottom", alignDimensionName = isHorizontal ? "width" : "height";
|
|
38
|
+
toolTipContainer.style.top = "0";
|
|
39
|
+
toolTipContainer.style.left = "0";
|
|
40
|
+
var ttRect = toolTipContainer.getBoundingClientRect();
|
|
41
|
+
var anchorRect = anchor.getBoundingClientRect();
|
|
42
|
+
if (alignment === "start-edge") {
|
|
43
|
+
alignment = (anchorRect[startName] + ttRect[dimensionName] + 20 > window[this.getPrefixedStyleName("inner", dimensionName)]) ? "end" : "start";
|
|
44
|
+
}
|
|
45
|
+
else if (alignment === "end-edge") {
|
|
46
|
+
alignment = (anchorRect[endName] - ttRect[dimensionName] < 15) ? "start" : "end";
|
|
47
|
+
}
|
|
48
|
+
var start = anchorRect[startName] + (anchorRect[dimensionName] - ttRect[dimensionName]) / 2;
|
|
49
|
+
var arrowPosition = anchorRect[dimensionName] / 2;
|
|
50
|
+
if (alignment === "start") {
|
|
51
|
+
start = anchorRect[startName];
|
|
52
|
+
arrowPosition = 20;
|
|
53
|
+
}
|
|
54
|
+
else if (alignment === "end") {
|
|
55
|
+
start = anchorRect[endName] - ttRect[dimensionName];
|
|
56
|
+
arrowPosition = anchorRect[dimensionName] - 20;
|
|
57
|
+
}
|
|
58
|
+
// Check if the tooltip is going to go off the edge of the screen.
|
|
59
|
+
var clampedStart = Math.max(Math.min(start, window[this.getPrefixedStyleName("inner", dimensionName)] - ttRect[dimensionName] - 20), 15);
|
|
60
|
+
var arrowOffset = anchorRect[startName] - clampedStart;
|
|
61
|
+
ttArrow.removeAttribute("style");
|
|
62
|
+
ttArrow.style[startName] = (arrowOffset + arrowPosition) + "px";
|
|
63
|
+
var align = anchorRect[alignName] - ttRect[alignDimensionName] - arrowHeight;
|
|
64
|
+
if ((align < 20 || position === endAlignName) && anchorRect[endAlignName] + ttRect[alignDimensionName] + arrowHeight + 20 < window[this.getPrefixedStyleName("inner", alignDimensionName)]) {
|
|
65
|
+
align = anchorRect[endAlignName] + arrowHeight;
|
|
66
|
+
ttArrow.style[this.getPrefixedStyleName("border", endAlignName)] = "5px solid " + bgColor;
|
|
67
|
+
ttArrow.style[this.getPrefixedStyleName("border", alignName)] = "none";
|
|
68
|
+
ttArrow.style[alignName] = "-5px";
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Show above
|
|
72
|
+
ttArrow.style[this.getPrefixedStyleName("border", alignName)] = "5px solid " + bgColor;
|
|
73
|
+
ttArrow.style[this.getPrefixedStyleName("border", endAlignName)] = "none";
|
|
74
|
+
ttArrow.style[endAlignName] = "-5px";
|
|
75
|
+
}
|
|
76
|
+
toolTipContainer.style[alignName] = align + (isHorizontal ? window.scrollX : window.scrollY) + "px";
|
|
77
|
+
toolTipContainer.style[startName] = clampedStart + (isHorizontal ? window.scrollY : window.scrollX) + "px";
|
|
78
|
+
};
|
|
79
|
+
TooltipHelper.getPrefixedStyleName = function (prefix, styleName) {
|
|
80
|
+
return prefix + styleName[0].toUpperCase() + styleName.substring(1);
|
|
81
|
+
};
|
|
82
|
+
return TooltipHelper;
|
|
83
|
+
}());
|
|
84
|
+
export { TooltipHelper };
|