@dhis2-ui/calendar 10.7.5 → 10.7.7

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.
@@ -13,7 +13,7 @@ var _navigationContainer = require("./navigation-container.js");
13
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
- const backgroundColor = 'none';
16
+ const backgroundColor = _uiConstants.colors.white;
17
17
  const CalendarContainer = exports.CalendarContainer = /*#__PURE__*/_react.default.memo(function CalendarContainer(_ref) {
18
18
  let {
19
19
  date,
@@ -48,6 +48,7 @@ const CalendarInput = function () {
48
48
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
49
49
  const ref = (0, _react.useRef)();
50
50
  const calendarRef = (0, _react.useRef)();
51
+ const popperRef = (0, _react.useRef)();
51
52
  const [open, setOpen] = (0, _react.useState)(false);
52
53
  const [partialDate, setPartialDate] = (0, _react.useState)(date);
53
54
  (0, _react.useEffect)(() => setPartialDate(date), [date]);
@@ -96,7 +97,7 @@ const CalendarInput = function () {
96
97
  };
97
98
  const handleBlur = (_, e) => {
98
99
  var _calendarRef$current;
99
- if (e.relatedTarget && (_calendarRef$current = calendarRef.current) !== null && _calendarRef$current !== void 0 && _calendarRef$current.contains(e.relatedTarget)) {
100
+ if (e.relatedTarget && ((_calendarRef$current = calendarRef.current) !== null && _calendarRef$current !== void 0 && _calendarRef$current.contains(e.relatedTarget) || popperRef.current === e.relatedTarget)) {
100
101
  return;
101
102
  }
102
103
  onChooseDate(partialDate, validationOptions);
@@ -156,7 +157,11 @@ const CalendarInput = function () {
156
157
  }, /*#__PURE__*/_react.default.createElement(_popper.Popper, {
157
158
  reference: ref,
158
159
  placement: "bottom-start",
159
- modifiers: [offsetModifier]
160
+ modifiers: [offsetModifier],
161
+ onFirstUpdate: component => {
162
+ var _component$elements;
163
+ popperRef.current = component === null || component === void 0 ? void 0 : (_component$elements = component.elements) === null || _component$elements === void 0 ? void 0 : _component$elements.popper;
164
+ }
160
165
  }, /*#__PURE__*/_react.default.createElement(_calendarContainer.CalendarContainer, _extends({}, calendarProps, {
161
166
  calendarRef: calendarRef
162
167
  })))), /*#__PURE__*/_react.default.createElement(_style.default, {
@@ -1,10 +1,10 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
- import { elevations } from '@dhis2/ui-constants';
2
+ import { colors, elevations } from '@dhis2/ui-constants';
3
3
  import PropTypes from 'prop-types';
4
4
  import React, { useMemo } from 'react';
5
5
  import { CalendarTable, CalendarTableProps } from './calendar-table.js';
6
6
  import { NavigationContainer, NavigationContainerProps } from './navigation-container.js';
7
- const backgroundColor = 'none';
7
+ const backgroundColor = colors.white;
8
8
  export const CalendarContainer = /*#__PURE__*/React.memo(function CalendarContainer(_ref) {
9
9
  let {
10
10
  date,
@@ -39,6 +39,7 @@ export const CalendarInput = function () {
39
39
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
40
40
  const ref = useRef();
41
41
  const calendarRef = useRef();
42
+ const popperRef = useRef();
42
43
  const [open, setOpen] = useState(false);
43
44
  const [partialDate, setPartialDate] = useState(date);
44
45
  useEffect(() => setPartialDate(date), [date]);
@@ -87,7 +88,7 @@ export const CalendarInput = function () {
87
88
  };
88
89
  const handleBlur = (_, e) => {
89
90
  var _calendarRef$current;
90
- if (e.relatedTarget && (_calendarRef$current = calendarRef.current) !== null && _calendarRef$current !== void 0 && _calendarRef$current.contains(e.relatedTarget)) {
91
+ if (e.relatedTarget && ((_calendarRef$current = calendarRef.current) !== null && _calendarRef$current !== void 0 && _calendarRef$current.contains(e.relatedTarget) || popperRef.current === e.relatedTarget)) {
91
92
  return;
92
93
  }
93
94
  onChooseDate(partialDate, validationOptions);
@@ -147,7 +148,11 @@ export const CalendarInput = function () {
147
148
  }, /*#__PURE__*/React.createElement(Popper, {
148
149
  reference: ref,
149
150
  placement: "bottom-start",
150
- modifiers: [offsetModifier]
151
+ modifiers: [offsetModifier],
152
+ onFirstUpdate: component => {
153
+ var _component$elements;
154
+ popperRef.current = component === null || component === void 0 ? void 0 : (_component$elements = component.elements) === null || _component$elements === void 0 ? void 0 : _component$elements.popper;
155
+ }
151
156
  }, /*#__PURE__*/React.createElement(CalendarContainer, _extends({}, calendarProps, {
152
157
  calendarRef: calendarRef
153
158
  })))), /*#__PURE__*/React.createElement(_JSXStyle, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/calendar",
3
- "version": "10.7.5",
3
+ "version": "10.7.7",
4
4
  "description": "UI Calendar",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,15 +33,15 @@
33
33
  "styled-jsx": "^4"
34
34
  },
35
35
  "dependencies": {
36
- "@dhis2-ui/button": "10.7.5",
37
- "@dhis2-ui/card": "10.7.5",
38
- "@dhis2-ui/input": "10.7.5",
39
- "@dhis2-ui/layer": "10.7.5",
40
- "@dhis2-ui/popper": "10.7.5",
36
+ "@dhis2-ui/button": "10.7.7",
37
+ "@dhis2-ui/card": "10.7.7",
38
+ "@dhis2-ui/input": "10.7.7",
39
+ "@dhis2-ui/layer": "10.7.7",
40
+ "@dhis2-ui/popper": "10.7.7",
41
41
  "@dhis2/multi-calendar-dates": "2.1.2",
42
42
  "@dhis2/prop-types": "^3.1.2",
43
- "@dhis2/ui-constants": "10.7.5",
44
- "@dhis2/ui-icons": "10.7.5",
43
+ "@dhis2/ui-constants": "10.7.7",
44
+ "@dhis2/ui-icons": "10.7.7",
45
45
  "classnames": "^2.3.1",
46
46
  "prop-types": "^15.7.2"
47
47
  },