@singularsystems/neo-core 1.0.6 → 1.0.8

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.
@@ -62,6 +62,10 @@ export interface IButtonDropDownItem {
62
62
  isDivider?: boolean;
63
63
  /** Data to be passed to the click event. */
64
64
  data?: any;
65
+ /** Disables the menu item. */
66
+ disabled?: boolean;
67
+ /** Classname for the dropdown item */
68
+ className?: string;
65
69
  /** Function to invoke when the item is clicked. If this is not specified, then the buttons click event will be called. */
66
70
  onClick?: (event: any, data?: any) => void;
67
71
  }
@@ -174,7 +174,8 @@ var DatePicker = /** @class */ (function () {
174
174
  };
175
175
  DatePicker.prototype.positionPopup = function (fromBottom) {
176
176
  if (this.popup) {
177
- PositionHelper.checkScreenBounds(this.container, this.popup, fromBottom, this.options.popupAlignRight);
177
+ var textAlign = this.options.popupAlignRight ? undefined : window.getComputedStyle(this.input).textAlign;
178
+ PositionHelper.checkScreenBounds(this.container, this.popup, fromBottom, this.options.popupAlignRight, textAlign);
178
179
  }
179
180
  };
180
181
  /**
@@ -5,6 +5,7 @@ export default class PositionHelper {
5
5
  * @param popup The element which pops up from the anchor.
6
6
  * @param fromBottom True if the popups bottom style property must be set. Set to false if there are buttons at the top of the popup and the popups height may change.
7
7
  * @param alignRight True if the popup must be aligned to the anchors right position.
8
+ * @param hAlign Horizontal alignment of the popup edge relative to the anchor edge. Overrides alignRight
8
9
  */
9
- static checkScreenBounds(anchor: HTMLElement, popup: HTMLElement, fromBottom?: boolean, alignRight?: boolean): void;
10
+ static checkScreenBounds(anchor: HTMLElement, popup: HTMLElement, fromBottom?: boolean, alignRight?: boolean, hAlign?: "left" | "center" | "right"): void;
10
11
  }
@@ -7,12 +7,14 @@ var PositionHelper = /** @class */ (function () {
7
7
  * @param popup The element which pops up from the anchor.
8
8
  * @param fromBottom True if the popups bottom style property must be set. Set to false if there are buttons at the top of the popup and the popups height may change.
9
9
  * @param alignRight True if the popup must be aligned to the anchors right position.
10
+ * @param hAlign Horizontal alignment of the popup edge relative to the anchor edge. Overrides alignRight
10
11
  */
11
- PositionHelper.checkScreenBounds = function (anchor, popup, fromBottom, alignRight) {
12
+ PositionHelper.checkScreenBounds = function (anchor, popup, fromBottom, alignRight, hAlign) {
12
13
  if (fromBottom === void 0) { fromBottom = true; }
13
14
  if (alignRight === void 0) { alignRight = false; }
14
15
  var popupHeight = popup.offsetHeight;
15
16
  var containerScreenRect = anchor.getBoundingClientRect();
17
+ // Vertical
16
18
  if (containerScreenRect.bottom + anchor.offsetHeight + popupHeight > window.innerHeight - 20 && containerScreenRect.top > popupHeight) {
17
19
  if (fromBottom) {
18
20
  popup.style.top = "auto";
@@ -27,15 +29,30 @@ var PositionHelper = /** @class */ (function () {
27
29
  popup.style.top = "100%";
28
30
  popup.style.bottom = "auto";
29
31
  }
32
+ // Horizontal
30
33
  var popupWidth = popup.offsetWidth;
31
- if ((!alignRight && containerScreenRect.left + popupWidth > window.innerWidth - 20) ||
32
- (alignRight && containerScreenRect.right - popupWidth >= 0)) {
34
+ if (!hAlign) {
35
+ hAlign = alignRight ? "right" : "left";
36
+ }
37
+ var isRightAligned = hAlign === "right" && (containerScreenRect.right - popupWidth >= 0);
38
+ if (isRightAligned) {
33
39
  popup.style.left = "auto";
34
40
  popup.style.right = "0";
35
41
  }
36
42
  else {
37
- popup.style.left = "0";
38
- popup.style.right = "auto";
43
+ var left = 0;
44
+ if (hAlign === "center") {
45
+ left = (containerScreenRect.width - popup.offsetWidth) / 2;
46
+ }
47
+ var leftCheck = containerScreenRect.left + left;
48
+ if (leftCheck < 0) {
49
+ left -= leftCheck;
50
+ }
51
+ else if (leftCheck + popup.offsetWidth > window.innerWidth - 20) {
52
+ left -= (leftCheck + popup.offsetWidth) - (window.innerWidth - 20);
53
+ }
54
+ popup.style.left = left + "px";
55
+ popup.style.right = "";
39
56
  }
40
57
  };
41
58
  return PositionHelper;
@@ -39,7 +39,7 @@ var OidcAuthService = /** @class */ (function () {
39
39
  case 0: return [4 /*yield*/, this.userManager.getUser()];
40
40
  case 1:
41
41
  user = _a.sent();
42
- if (!user) return [3 /*break*/, 3];
42
+ if (!(user && !user.expired)) return [3 /*break*/, 3];
43
43
  // Get user does not raise the onUserLoaded event, so we call it manually.
44
44
  this.onUserLoaded(user);
45
45
  return [4 /*yield*/, this.completeAfterUserLoaded()];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-core",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Core functionality for the Neo client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",