react-ui-basics 0.0.192 → 0.0.193

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-ui-basics",
3
- "version": "0.0.192",
3
+ "version": "0.0.193",
4
4
  "description": "",
5
5
  "module": "index.js",
6
6
  "_main": "index.cjs.js",
@@ -27,8 +27,12 @@ const clearSelection = () => {
27
27
  } else if (getSelection().removeAllRanges) { // Firefox
28
28
  getSelection().removeAllRanges();
29
29
  }
30
- } else if (DOCUMENT.selection) { // IE?
31
- DOCUMENT.selection.empty();
30
+ } else {
31
+ // @ts-ignore
32
+ if (DOCUMENT.selection) { // IE?
33
+ // @ts-ignore
34
+ DOCUMENT.selection.empty();
35
+ }
32
36
  }
33
37
  };
34
38
 
@@ -3,7 +3,7 @@ import ReactDOM from "react-dom";
3
3
  import './DatePicker.css'
4
4
  import TextField from "./TextField";
5
5
  import * as DateTools from "./DateTools";
6
- import {orNoop, classNames, preventDefault, ref} from "./Tools";
6
+ import {orNoop, classNames, preventDefault, ref, WINDOW} from "./Tools";
7
7
  import Button from './Button'
8
8
  import CalendarMonthView from "./CalendarMonthView";
9
9
  import MaterialIcon from "./MaterialIcon";
@@ -92,10 +92,20 @@ class DatePicker extends React.Component<DatePickerProps, DatePickerState> {
92
92
  };
93
93
 
94
94
  private getPopupStyles = () => {
95
- const boundingClientRect = this.el.getBoundingClientRect();
95
+ const textInputBoundingRect = this.el.getBoundingClientRect();
96
+ const popupBoundingRect = this.popup.getBoundingClientRect();
97
+ let left = textInputBoundingRect.left;
98
+ let top = textInputBoundingRect.bottom;
99
+ if (left + popupBoundingRect.width > WINDOW.innerWidth) {
100
+ left = textInputBoundingRect.right - popupBoundingRect.width;
101
+ }
102
+ if (top + popupBoundingRect.height > WINDOW.innerHeight) {
103
+ top = textInputBoundingRect.top - popupBoundingRect.height;
104
+ }
105
+
96
106
  return {
97
- left: boundingClientRect.left + 'px',
98
- top: boundingClientRect.bottom + 'px',
107
+ left: left + 'px',
108
+ top: top + 'px',
99
109
  }
100
110
  };
101
111
 
@@ -47,4 +47,5 @@ class ResizeObserver {
47
47
  }
48
48
  }
49
49
 
50
+ // @ts-ignore
50
51
  WINDOW.ResizeObserver = WINDOW.ResizeObserver || ResizeObserver;
package/src/Tools.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  var global = global || window;
2
- export const WINDOW = global;
2
+ export const WINDOW: Window = global as Window;
3
3
  export const DOCUMENT = WINDOW.document;
4
4
 
5
5
  export function classNames(...classes: Array<string | number | boolean | null | void>) {