@laerdal/life-react-components 1.9.8-dev.24 → 1.9.8-dev.25
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/dist/Card/HorizontalCard/HorizontalCardActions.cjs +8 -2
- package/dist/Card/HorizontalCard/HorizontalCardActions.cjs.map +1 -1
- package/dist/Card/HorizontalCard/HorizontalCardActions.js +2 -2
- package/dist/Card/HorizontalCard/HorizontalCardActions.js.map +1 -1
- package/dist/Dropdown/BasicDropdown.cjs +57 -67
- package/dist/Dropdown/BasicDropdown.cjs.map +1 -1
- package/dist/Dropdown/BasicDropdown.d.ts +7 -14
- package/dist/Dropdown/BasicDropdown.js +58 -67
- package/dist/Dropdown/BasicDropdown.js.map +1 -1
- package/dist/Dropdown/CommonStyling.cjs +1 -1
- package/dist/Dropdown/CommonStyling.cjs.map +1 -1
- package/dist/Dropdown/CommonStyling.js +1 -1
- package/dist/Dropdown/CommonStyling.js.map +1 -1
- package/dist/GlobalNavigationBar/desktop/DesktopActions.cjs +8 -2
- package/dist/GlobalNavigationBar/desktop/DesktopActions.cjs.map +1 -1
- package/dist/GlobalNavigationBar/desktop/DesktopActions.js +2 -2
- package/dist/GlobalNavigationBar/desktop/DesktopActions.js.map +1 -1
- package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.cjs.map +1 -1
- package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.js.map +1 -1
- package/dist/InputFields/DatepickerField.cjs +38 -44
- package/dist/InputFields/DatepickerField.cjs.map +1 -1
- package/dist/InputFields/DatepickerField.d.ts +20 -17
- package/dist/InputFields/DatepickerField.js +20 -33
- package/dist/InputFields/DatepickerField.js.map +1 -1
- package/dist/InputFields/NumberField.cjs +52 -63
- package/dist/InputFields/NumberField.cjs.map +1 -1
- package/dist/InputFields/NumberField.d.ts +19 -14
- package/dist/InputFields/NumberField.js +53 -60
- package/dist/InputFields/NumberField.js.map +1 -1
- package/dist/InputFields/RadioButton.cjs +1 -1
- package/dist/InputFields/RadioButton.cjs.map +1 -1
- package/dist/InputFields/RadioButton.d.ts +1 -1
- package/dist/InputFields/RadioButton.js +1 -1
- package/dist/InputFields/RadioButton.js.map +1 -1
- package/dist/InputFields/TextField.cjs +3 -5
- package/dist/InputFields/TextField.cjs.map +1 -1
- package/dist/InputFields/TextField.d.ts +1 -2
- package/dist/InputFields/TextField.js +4 -5
- package/dist/InputFields/TextField.js.map +1 -1
- package/dist/InputFields/index.cjs +0 -26
- package/dist/InputFields/index.cjs.map +1 -1
- package/dist/InputFields/index.d.ts +0 -1
- package/dist/InputFields/index.js +0 -1
- package/dist/InputFields/index.js.map +1 -1
- package/dist/Toggles/ToggleSwitch.cjs +17 -24
- package/dist/Toggles/ToggleSwitch.cjs.map +1 -1
- package/dist/Toggles/ToggleSwitch.d.ts +1 -5
- package/dist/Toggles/ToggleSwitch.js +12 -21
- package/dist/Toggles/ToggleSwitch.js.map +1 -1
- package/dist/Toggles/TogglerTypes.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
3
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
5
4
|
import _pt from "prop-types";
|
|
6
|
-
var _excluded = ["disabled", "readOnly", "onChange", "invalid", "value", "validationMessage", "dateFormat", "autoComplete", "placeholder", "required", "yearPicker", "yearsBeforeCurrentDate", "yearsAfterCurrentDate", "margin", "onBlur"];
|
|
7
5
|
|
|
8
6
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
9
7
|
|
|
@@ -14,7 +12,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
14
12
|
/**
|
|
15
13
|
* Import react libraries.
|
|
16
14
|
*/
|
|
17
|
-
import React from 'react';
|
|
15
|
+
import * as React from 'react';
|
|
18
16
|
/**
|
|
19
17
|
* Import third-party libraries.
|
|
20
18
|
*/
|
|
@@ -37,14 +35,10 @@ import { ComponentTextStyle, focusStyles, scrollBarStyling } from '../styles';
|
|
|
37
35
|
|
|
38
36
|
import { ErrorMessage, InputFieldStyling, InputWrapper } from './styling';
|
|
39
37
|
import 'react-datepicker/dist/react-datepicker.css';
|
|
40
|
-
import { ComponentMStyling, ComponentSStyling } from '../styles';
|
|
41
|
-
import { Z_INDEXES } from '../styles';
|
|
42
|
-
import { useFocusVisibleRef } from '../common';
|
|
38
|
+
import { ComponentMStyling, ComponentSStyling } from '../styles/typography';
|
|
39
|
+
import { Z_INDEXES } from '../styles/z-indexes';
|
|
40
|
+
import { useFocusVisibleRef } from '../common/FocusVisible';
|
|
43
41
|
import { Size } from '../types';
|
|
44
|
-
/**
|
|
45
|
-
* Add custom types.
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
42
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
43
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
50
44
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -52,7 +46,7 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
52
46
|
/**
|
|
53
47
|
* Add custom styles.
|
|
54
48
|
*/
|
|
55
|
-
var DatePickerContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .react-datepicker-popper {\n z-index: ", ";\n }\n\n > div {\n display: block;\n\n ", "\n .react-datepicker {\n box-sizing: border-box;\n box-shadow: 0px 2px 4px rgb(0 0 0 / 15%);\n border: 1px solid #e5e5e5;\n }\n\n .react-datepicker__navigation {\n line-height: normal;\n text-indent: inherit;\n border: none;\n border-radius: 4px;\n height: 32px;\n width: 32px;\n outline: none;\n margin: 0px;\n color: transparent;\n\n &:hover {\n background: ", ";\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23215369' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23215369' /%3E%3C/svg%3E\");\n }\n }\n\n &:focus {\n ", "\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23163746' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23163746' /%3E%3C/svg%3E\");\n }\n }\n\n &::before {\n text-align: center;\n display: inline-block;\n content: '';\n height: 32px;\n width: 32px;\n vertical-align: middle;\n }\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23666666' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23666666' /%3E%3C/svg%3E\");\n }\n }\n\n .react-datepicker__month-container,\n .react-datepicker__year--container {\n width: 336px;\n }\n\n .react-datepicker__month {\n margin: 0px;\n }\n\n .react-datepicker__triangle {\n left: 50% !important;\n display: none;\n }\n\n .react-datepicker-popper[data-placement^='bottom'] {\n margin-top: 0;\n }\n\n .react-datepicker-popper[data-placement^='bottom'] .react-datepicker__triangle {\n border-bottom-color: ", ";\n }\n\n .react-datepicker__header {\n border-bottom: 1px solid ", ";\n background: ", ";\n height: ", ";\n padding-top: 0px;\n }\n\n .react-datepicker__current-month {\n height: 48px;\n display: inline-flex;\n align-items: center;\n margin-right: 5px;\n\n ", "\n }\n\n .react-datepicker__year {\n max-height: 300px;\n overflow-y: scroll;\n\n ", "\n }\n\n .react-datepicker__year-wrapper {\n max-width: 100%;\n justify-content: space-around;\n }\n\n .react-datepicker__day-name {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n height: 48px;\n margin: 0px;\n width: 48px;\n\n ", "\n }\n\n .react-datepicker__year-text {\n background: ", ";\n border: none;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n margin-top: 20px;\n padding-top: 10px;\n padding-bottom: 10px;\n\n ", "\n &.react-datepicker__year-text--disabled {\n display: none;\n }\n\n &.react-datepicker__day--keyboard-selected {\n color: ", ";\n background: ", ";\n font-weight: 400;\n border: none;\n }\n\n &:hover {\n color: ", ";\n background: ", ";\n }\n\n &:focus {\n ", "\n }\n\n &.react-datepicker__year-text--selected {\n color: ", " !important;\n background: ", " !important;\n }\n }\n\n .react-datepicker__day {\n background: ", ";\n border: none;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n height: 40px;\n width: 40px;\n margin: 4px;\n\n ", "\n &.react-datepicker__day--keyboard-selected {\n color: ", ";\n background: ", ";\n font-weight: 400;\n border: none;\n }\n\n &:hover {\n color: ", ";\n background: ", ";\n }\n\n &:focus {\n ", "\n }\n\n &.react-datepicker__day--selected {\n color: ", " !important;\n background: ", " !important;\n }\n\n &.react-datepicker__day--today {\n border-radius: 0.3rem;\n color: ", ";\n background: ", ";\n\n &:hover {\n color: ", ";\n background: ", ";\n }\n\n &:focus {\n ", "\n }\n }\n }\n }\n"])), Z_INDEXES.dropdown, function (props) {
|
|
49
|
+
var DatePickerContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .react-datepicker-popper {\n z-index: ", ";\n }\n\n > div {\n display: block;\n\n ", "\n .react-datepicker {\n box-sizing: border-box;\n box-shadow: 0px 2px 4px rgb(0 0 0 / 15%);\n border: 1px solid #e5e5e5;\n }\n\n .react-datepicker__navigation {\n line-height: normal;\n text-indent: inherit;\n border: none;\n border-radius: 4px;\n height: 32px;\n width: 32px;\n outline: none;\n margin: 0px;\n color: transparent;\n\n &:hover {\n background: ", ";\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23215369' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23215369' /%3E%3C/svg%3E\");\n }\n }\n\n &:focus {\n ", "\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23163746' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23163746' /%3E%3C/svg%3E\");\n }\n }\n\n &::before {\n text-align: center;\n display: inline-block;\n content: '';\n height: 32px;\n width: 32px;\n vertical-align: middle;\n }\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23666666' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23666666' /%3E%3C/svg%3E\");\n }\n }\n\n .react-datepicker__month-container,\n .react-datepicker__year--container {\n width: 336px;\n }\n\n .react-datepicker__month {\n margin: 0px;\n }\n\n .react-datepicker__triangle {\n left: 50% !important;\n display: none;\n }\n\n .react-datepicker-popper[data-placement^='bottom'] {\n margin-top: 0;\n }\n\n .react-datepicker-popper[data-placement^='bottom'] .react-datepicker__triangle {\n border-bottom-color: ", ";\n }\n\n .react-datepicker__header {\n border-bottom: 1px solid ", ";\n background: ", ";\n height: ", ";\n padding-top: 0px;\n }\n\n .react-datepicker__current-month {\n height: 48px;\n display: inline-flex;\n align-items: center;\n margin-right: 5px;\n\n ", "\n }\n\n .react-datepicker__year {\n max-height: 300px;\n overflow-y: scroll;\n\n ", "\n }\n\n .react-datepicker__year-wrapper {\n max-width: 100%;\n justify-content: space-around;\n }\n\n .react-datepicker__day-name {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n height: 48px;\n margin: 0px;\n width: 48px;\n\n ", "\n }\n\n .react-datepicker__year-text {\n background: ", ";\n border: none;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n margin-top: 20px;\n padding-top: 10px;\n padding-bottom: 10px;\n\n ", "\n &.react-datepicker__year-text--disabled {\n display: none;\n }\n\n &.react-datepicker__day--keyboard-selected {\n color: ", ";\n background: ", ";\n font-weight: 400;\n border: none;\n }\n\n &:hover {\n color: ", ";\n background: ", ";\n }\n\n &:focus {\n ", "\n }\n\n &.react-datepicker__year-text--selected {\n color: ", " !important;\n background: ", " !important;\n }\n }\n\n .react-datepicker__day {\n background: ", ";\n border: none;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n height: 40px;\n width: 40px;\n margin: 4px;\n\n ", "\n &.react-datepicker__day--keyboard-selected {\n color: ", ";\n background: ", ";\n font-weight: 400;\n border: none;\n }\n\n &:hover {\n color: ", ";\n background: ", ";\n }\n\n &:focus {\n ", "\n }\n\n &.react-datepicker__day--selected {\n color: ", " !important;\n background: ", " !important;\n }\n\n &.react-datepicker__day--today {\n border-radius: 0.3rem;\n color: ", ";\n background: ", ";\n\n &:hover {\n color: ", ";\n background: ", ";\n }\n\n &:focus {\n ", "\n }\n }\n }\n }\n"])), Z_INDEXES.dropdown, function (props) {
|
|
56
50
|
return props.margin ? "margin: ".concat(props.margin, ";") : '';
|
|
57
51
|
}, COLORS.primary_20, focusStyles, COLORS.neutral_20, COLORS.neutral_200, COLORS.neutral_20, function (props) {
|
|
58
52
|
return !props.yearPicker ? '96px' : '54px';
|
|
@@ -60,8 +54,10 @@ var DatePickerContainer = styled.div(_templateObject || (_templateObject = _tagg
|
|
|
60
54
|
var IconWrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n pointer-events: none;\n position: absolute;\n right: 16px;\n width: 24px;\n height: 24px;\n z-index: ", ";\n color: ", ";\n"])), Z_INDEXES.focus + 1, COLORS.neutral_600);
|
|
61
55
|
var DatepickerRow = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: center;\n"])));
|
|
62
56
|
var StyledInputFieldStyling = styled(InputFieldStyling)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n &::placeholder {\n color: ", ";\n }\n\n &:focus:not(.focus-visible) {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n\n &:hover {\n box-shadow: inset 0px 0px 0px 2px ", ";\n\n ::placeholder {\n color: ", ";\n }\n\n cursor: pointer;\n background-color: ", ";\n color: ", ";\n }\n\n &:active,\n &.open {\n box-shadow: inset 0px 0px 0px 2px ", ";\n background-color: ", ";\n color: ", ";\n\n ::placeholder {\n color: ", ";\n }\n }\n\n &:disabled {\n background-color: ", ";\n }\n\n &:hover ~ ", " {\n color: ", ";\n }\n\n &:active ~ ", ", &.open ~ ", " {\n color: ", ";\n }\n\n &:disabled ~ ", ", &:read-only ~ ", " {\n color: ", ";\n }\n"])), COLORS.neutral_500, COLORS.primary_300, COLORS.primary_200, COLORS.primary_700, COLORS.primary_20, COLORS.primary_700, COLORS.primary_300, COLORS.primary_100, COLORS.primary_800, COLORS.primary_800, COLORS.white, IconWrapper, COLORS.primary_700, IconWrapper, IconWrapper, COLORS.primary_800, IconWrapper, IconWrapper, COLORS.neutral_300);
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
|
|
58
|
+
var DatepickerField = function DatepickerField(_ref) {
|
|
59
|
+
var id = _ref.id,
|
|
60
|
+
disabled = _ref.disabled,
|
|
65
61
|
readOnly = _ref.readOnly,
|
|
66
62
|
_onChange = _ref.onChange,
|
|
67
63
|
invalid = _ref.invalid,
|
|
@@ -74,10 +70,7 @@ var DatepickerField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
74
70
|
yearPicker = _ref.yearPicker,
|
|
75
71
|
yearsBeforeCurrentDate = _ref.yearsBeforeCurrentDate,
|
|
76
72
|
yearsAfterCurrentDate = _ref.yearsAfterCurrentDate,
|
|
77
|
-
margin = _ref.margin
|
|
78
|
-
onBlur = _ref.onBlur,
|
|
79
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
80
|
-
|
|
73
|
+
margin = _ref.margin;
|
|
81
74
|
// Globally used variables within the component
|
|
82
75
|
var inputRef = useFocusVisibleRef();
|
|
83
76
|
var datepickerRef = React.useRef(null);
|
|
@@ -129,9 +122,6 @@ var DatepickerField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
129
122
|
datepickerRef.current.setOpen(true); //setOpenAt(null);
|
|
130
123
|
}
|
|
131
124
|
}, [openAt]);
|
|
132
|
-
React.useImperativeHandle(ref, function () {
|
|
133
|
-
return inputRef.current;
|
|
134
|
-
}, [inputRef]);
|
|
135
125
|
|
|
136
126
|
var handleCalendarClose = function handleCalendarClose() {
|
|
137
127
|
var _inputRef$current;
|
|
@@ -156,18 +146,10 @@ var DatepickerField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
156
146
|
if (e.key === 'Escape' || e.key === 'Esc') datepickerRef.current.setOpen(false);
|
|
157
147
|
};
|
|
158
148
|
|
|
159
|
-
var handleBlur = function handleBlur(e) {
|
|
160
|
-
// @ts-ignore
|
|
161
|
-
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
162
|
-
onBlur && onBlur(e);
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
149
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
167
150
|
children: [/*#__PURE__*/_jsx(DatePickerContainer, {
|
|
168
151
|
yearPicker: yearPickerMode,
|
|
169
152
|
margin: margin || '',
|
|
170
|
-
onBlur: handleBlur,
|
|
171
153
|
children: /*#__PURE__*/_jsx(DatePicker, {
|
|
172
154
|
ref: datepickerRef,
|
|
173
155
|
onCalendarOpen: handleCalendarOpen,
|
|
@@ -215,7 +197,8 @@ var DatepickerField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
215
197
|
margin: '4px 0px'
|
|
216
198
|
},
|
|
217
199
|
children: /*#__PURE__*/_jsxs(DatepickerRow, {
|
|
218
|
-
children: [/*#__PURE__*/_jsx(StyledInputFieldStyling,
|
|
200
|
+
children: [/*#__PURE__*/_jsx(StyledInputFieldStyling, {
|
|
201
|
+
id: id,
|
|
219
202
|
ref: inputRef,
|
|
220
203
|
type: "text",
|
|
221
204
|
name: "datepicker",
|
|
@@ -235,7 +218,7 @@ var DatepickerField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
235
218
|
readOnly: true,
|
|
236
219
|
suppressReadOnlyStyles: !readOnly,
|
|
237
220
|
required: required
|
|
238
|
-
}
|
|
221
|
+
}), /*#__PURE__*/_jsx(IconWrapper, {
|
|
239
222
|
children: /*#__PURE__*/_jsx(Calendar, {
|
|
240
223
|
size: "24"
|
|
241
224
|
})
|
|
@@ -252,16 +235,20 @@ var DatepickerField = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
252
235
|
})]
|
|
253
236
|
})]
|
|
254
237
|
});
|
|
255
|
-
}
|
|
238
|
+
};
|
|
239
|
+
|
|
256
240
|
DatepickerField.propTypes = {
|
|
257
|
-
|
|
241
|
+
id: _pt.string.isRequired,
|
|
242
|
+
disabled: _pt.bool,
|
|
243
|
+
readOnly: _pt.bool,
|
|
258
244
|
onChange: _pt.func,
|
|
259
|
-
onBlur: _pt.func,
|
|
260
245
|
invalid: _pt.bool,
|
|
246
|
+
value: _pt.instanceOf(Date),
|
|
261
247
|
dateFormat: _pt.string,
|
|
262
248
|
validationMessage: _pt.string,
|
|
263
249
|
autoComplete: _pt.string,
|
|
264
250
|
placeholder: _pt.string,
|
|
251
|
+
required: _pt.bool,
|
|
265
252
|
yearPicker: _pt.bool,
|
|
266
253
|
yearsBeforeCurrentDate: _pt.number,
|
|
267
254
|
yearsAfterCurrentDate: _pt.number,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/InputFields/DatepickerField.tsx"],"names":["React","styled","DatePicker","en","moment","COLORS","Calendar","TechnicalWarning","DatepickerFieldHeader","ComponentTextStyle","focusStyles","scrollBarStyling","ErrorMessage","InputFieldStyling","InputWrapper","ComponentMStyling","ComponentSStyling","Z_INDEXES","useFocusVisibleRef","Size","DatePickerContainer","div","dropdown","props","margin","primary_20","neutral_20","neutral_200","yearPicker","Bold","neutral_600","Small","Regular","white","primary_700","primary_500","neutral_700","neutral_100","IconWrapper","focus","DatepickerRow","StyledInputFieldStyling","neutral_500","primary_300","primary_200","primary_100","primary_800","neutral_300","DatepickerField","forwardRef","ref","disabled","readOnly","onChange","invalid","value","validationMessage","dateFormat","autoComplete","placeholder","required","yearsBeforeCurrentDate","yearsAfterCurrentDate","onBlur","rest","inputRef","datepickerRef","useRef","useState","activeMonthPage","setActiveMonthPage","yearPickerMode","setYearPickerMode","openAt","setOpenAt","open","setOpen","useEffect","current","format","selectedDate","document","getElementsByClassName","dropdownParent","parentElement","scrollTop","offsetTop","offsetHeight","useImperativeHandle","handleCalendarClose","blur","handleCalendarOpen","maxDate","Date","setFullYear","getFullYear","minDate","itemsNumber","Math","round","handleKeyDown","e","key","handleBlur","currentTarget","contains","relatedTarget","newDate","setMonth","undefined","params","createElement","customHeaderCount","display","setSelectionRange","critical_400"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA,OAAOA,KAAP,MAAkB,OAAlB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,OAAOC,UAAP,MAAuB,kBAAvB;AACA,OAAOC,EAAP,MAAe,uBAAf;AACA,OAAOC,MAAP,MAAmB,QAAnB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,kBAAnB;AACA,SAAQC,QAAR,EAAkBC,gBAA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E,gBAAA,OAAO,EAAE,iBAACiD,CAAD;AAAA;;AAAA,+CAAOpC,QAAQ,CAACa,OAAhB,uDAAO,mBAAkBoC,iBAAlB,CAAoC,CAApC,EAAuC,CAAvC,CAAP;AAAA,iBAPX;AAQE,gBAAA,YAAY,EAAExD,YARhB;AASE,gBAAA,WAAW,EAAEC,WATf;AAUE,gBAAA,QAAQ,EAAER,QAVZ;AAWE,gBAAA,QAAQ,EAAE,IAXZ;AAYE,gBAAA,sBAAsB,EAAE,CAACC,QAZ3B;AAaE,gBAAA,QAAQ,EAAEQ;AAbZ,iBAcMI,IAdN,EADF,eAiBE,KAAC,WAAD;AAAA,uCACE,KAAC,QAAD;AAAU,kBAAA,IAAI,EAAC;AAAf;AADF,gBAjBF;AAAA;AADF;AADF;AA9CJ;AADF,MAFF,EA+EGR,iBAAiB,iBAChB,MAAC,YAAD;AAAA,8BACE,KAAC,gBAAD;AAAkB,QAAA,KAAK,EAAEnD,MAAM,CAAC8G;AAAhC,QADF,eAEE;AAAA,kBAAO3D;AAAP,QAFF;AAAA,MAhFJ;AAAA,IADF;AAwFD,CA9KuB,CAAxB;;AA1SED,EAAAA,K;AACAF,EAAAA,Q;AACAU,EAAAA,M;AAEAT,EAAAA,O;AACAG,EAAAA,U;AACAD,EAAAA,iB;AACAE,EAAAA,Y;AACAC,EAAAA,W;AACA/B,EAAAA,U;AACAiC,EAAAA,sB;AACAC,EAAAA,qB;AACAtC,EAAAA,M;;AA8cF,eAAewB,eAAf","sourcesContent":["/**\n * Import react libraries.\n */\nimport React from 'react';\n\n/**\n * Import third-party libraries.\n */\nimport styled from 'styled-components';\nimport DatePicker from 'react-datepicker';\nimport en from 'date-fns/locale/en-GB';\nimport moment from 'moment';\n\n/**\n * Import custom components.\n */\nimport COLORS from '../styles/colors';\nimport {Calendar, TechnicalWarning} from '../icons/systemicons/SystemIcons';\nimport {DatepickerFieldHeader, DatepickerFieldHeaderParams} from './DatepickerFieldHeader';\nimport {ComponentTextStyle, focusStyles, scrollBarStyling} from '../styles';\n\n/**\n * Import custom styles.\n */\nimport {ErrorMessage, InputFieldStyling, InputWrapper} from './styling';\nimport 'react-datepicker/dist/react-datepicker.css';\nimport {ComponentMStyling, ComponentSStyling} from '../styles';\nimport {Z_INDEXES} from '../styles';\nimport {useFocusVisibleRef} from '../common';\nimport {Size} from '../types';\n\n/**\n * Add custom types.\n */\ntype DatepickerFieldProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'value' | 'size' | 'onBlur'> & {\n value?: Date;\n onChange?: (date: Date) => void;\n onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void;\n\n invalid?: boolean;\n dateFormat?: string;\n validationMessage?: string;\n autoComplete?: string;\n placeholder?: string;\n yearPicker?: boolean;\n yearsBeforeCurrentDate?: number;\n yearsAfterCurrentDate?: number;\n margin?: string;\n};\n\n/**\n * Add custom styles.\n */\nconst DatePickerContainer = styled.div<{ yearPicker: boolean; margin: string }>`\n .react-datepicker-popper {\n z-index: ${Z_INDEXES.dropdown};\n }\n\n > div {\n display: block;\n\n ${(props) => (props.margin ? `margin: ${props.margin};` : '')}\n .react-datepicker {\n box-sizing: border-box;\n box-shadow: 0px 2px 4px rgb(0 0 0 / 15%);\n border: 1px solid #e5e5e5;\n }\n\n .react-datepicker__navigation {\n line-height: normal;\n text-indent: inherit;\n border: none;\n border-radius: 4px;\n height: 32px;\n width: 32px;\n outline: none;\n margin: 0px;\n color: transparent;\n\n &:hover {\n background: ${COLORS.primary_20};\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23215369' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23215369' /%3E%3C/svg%3E\");\n }\n }\n\n &:focus {\n ${focusStyles}\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23163746' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23163746' /%3E%3C/svg%3E\");\n }\n }\n\n &::before {\n text-align: center;\n display: inline-block;\n content: '';\n height: 32px;\n width: 32px;\n vertical-align: middle;\n }\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23666666' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23666666' /%3E%3C/svg%3E\");\n }\n }\n\n .react-datepicker__month-container,\n .react-datepicker__year--container {\n width: 336px;\n }\n\n .react-datepicker__month {\n margin: 0px;\n }\n\n .react-datepicker__triangle {\n left: 50% !important;\n display: none;\n }\n\n .react-datepicker-popper[data-placement^='bottom'] {\n margin-top: 0;\n }\n\n .react-datepicker-popper[data-placement^='bottom'] .react-datepicker__triangle {\n border-bottom-color: ${COLORS.neutral_20};\n }\n\n .react-datepicker__header {\n border-bottom: 1px solid ${COLORS.neutral_200};\n background: ${COLORS.neutral_20};\n height: ${(props) => (!props.yearPicker ? '96px' : '54px')};\n padding-top: 0px;\n }\n\n .react-datepicker__current-month {\n height: 48px;\n display: inline-flex;\n align-items: center;\n margin-right: 5px;\n\n ${ComponentSStyling(ComponentTextStyle.Bold, COLORS.neutral_600)}\n }\n\n .react-datepicker__year {\n max-height: 300px;\n overflow-y: scroll;\n\n ${scrollBarStyling(Size.Small)}\n }\n\n .react-datepicker__year-wrapper {\n max-width: 100%;\n justify-content: space-around;\n }\n\n .react-datepicker__day-name {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n height: 48px;\n margin: 0px;\n width: 48px;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}\n }\n\n .react-datepicker__year-text {\n background: ${COLORS.white};\n border: none;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n margin-top: 20px;\n padding-top: 10px;\n padding-bottom: 10px;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}\n &.react-datepicker__year-text--disabled {\n display: none;\n }\n\n &.react-datepicker__day--keyboard-selected {\n color: ${COLORS.neutral_600};\n background: ${COLORS.white};\n font-weight: 400;\n border: none;\n }\n\n &:hover {\n color: ${COLORS.primary_700};\n background: ${COLORS.primary_20};\n }\n\n &:focus {\n ${focusStyles}\n }\n\n &.react-datepicker__year-text--selected {\n color: ${COLORS.white} !important;\n background: ${COLORS.primary_500} !important;\n }\n }\n\n .react-datepicker__day {\n background: ${COLORS.white};\n border: none;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n height: 40px;\n width: 40px;\n margin: 4px;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}\n &.react-datepicker__day--keyboard-selected {\n color: ${COLORS.neutral_600};\n background: ${COLORS.white};\n font-weight: 400;\n border: none;\n }\n\n &:hover {\n color: ${COLORS.primary_700};\n background: ${COLORS.primary_20};\n }\n\n &:focus {\n ${focusStyles}\n }\n\n &.react-datepicker__day--selected {\n color: ${COLORS.white} !important;\n background: ${COLORS.primary_500} !important;\n }\n\n &.react-datepicker__day--today {\n border-radius: 0.3rem;\n color: ${COLORS.neutral_700};\n background: ${COLORS.neutral_100};\n\n &:hover {\n color: ${COLORS.primary_700};\n background: ${COLORS.primary_20};\n }\n\n &:focus {\n ${focusStyles}\n }\n }\n }\n }\n`;\n\nconst IconWrapper = styled.div`\n pointer-events: none;\n position: absolute;\n right: 16px;\n width: 24px;\n height: 24px;\n z-index: ${Z_INDEXES.focus + 1};\n color: ${COLORS.neutral_600};\n`;\n\nconst DatepickerRow = styled.div`\n display: flex;\n flex-direction: row;\n align-items: center;\n`;\n\nconst StyledInputFieldStyling = styled(InputFieldStyling)`\n &::placeholder {\n color: ${COLORS.neutral_500};\n }\n\n &:focus:not(.focus-visible) {\n box-shadow: inset 0px 0px 0px 2px ${COLORS.primary_300};\n }\n\n &:hover {\n box-shadow: inset 0px 0px 0px 2px ${COLORS.primary_200};\n\n ::placeholder {\n color: ${COLORS.primary_700};\n }\n\n cursor: pointer;\n background-color: ${COLORS.primary_20};\n color: ${COLORS.primary_700};\n }\n\n &:active,\n &.open {\n box-shadow: inset 0px 0px 0px 2px ${COLORS.primary_300};\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_800};\n\n ::placeholder {\n color: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n background-color: ${COLORS.white};\n }\n\n &:hover ~ ${IconWrapper} {\n color: ${COLORS.primary_700};\n }\n\n &:active ~ ${IconWrapper}, &.open ~ ${IconWrapper} {\n color: ${COLORS.primary_800};\n }\n\n &:disabled ~ ${IconWrapper}, &:read-only ~ ${IconWrapper} {\n color: ${COLORS.neutral_300};\n }\n`;\n\nconst DatepickerField = React.forwardRef(({\n disabled,\n readOnly,\n onChange,\n invalid,\n value,\n validationMessage,\n dateFormat,\n autoComplete,\n placeholder,\n required,\n yearPicker,\n yearsBeforeCurrentDate,\n yearsAfterCurrentDate,\n margin,\n onBlur,\n ...rest\n }: DatepickerFieldProps, ref) => {\n // Globally used variables within the component\n const inputRef = useFocusVisibleRef();\n const datepickerRef = React.useRef<any>(null);\n const [activeMonthPage, setActiveMonthPage] = React.useState<number>(-1);\n const [yearPickerMode, setYearPickerMode] = React.useState<boolean>(false);\n const [openAt, setOpenAt] = React.useState<Date | null>(null);\n // 'open' flag is used only for tracking current state of the dropdown,\n // for explicitly opening/closing the picker we are using 'datepickerRef.current.setOpen'\n const [open, setOpen] = React.useState<boolean>(false);\n\n /**\n * Format the date in a specific way.\n */\n React.useEffect(() => {\n if (value) inputRef.current.value = moment(value).format(dateFormat ? dateFormat : 'MMMM Do, YYYY');\n }, [value]);\n\n React.useEffect(() => {\n if (yearPickerMode) {\n //unfortunately, since there are no refs, and year pickers is rendered not by our code, but by 'react-datepicker'\n //we have to touch DOM directly\n const selectedDate = document.getElementsByClassName('react-datepicker__year-text--selected')[0] as HTMLElement;\n const dropdownParent = selectedDate?.parentElement?.parentElement;\n if (selectedDate && dropdownParent) dropdownParent.scrollTop = selectedDate.offsetTop - 2 * selectedDate.offsetHeight;\n }\n }, [yearPickerMode]);\n\n //we have to manually reopen the calendar when needed, to guarantee that datepicker will show selected date after year selection\n //otherwise after year selection datepicker will show January month of the selected year\n React.useEffect(() => {\n if (openAt) {\n datepickerRef.current.setOpen(true);\n //setOpenAt(null);\n }\n }, [openAt]);\n\n React.useImperativeHandle(ref, () => inputRef.current, [inputRef]);\n\n const handleCalendarClose = () => {\n inputRef.current?.blur();\n setOpen(false);\n };\n\n const handleCalendarOpen = () => {\n if (openAt) setOpenAt(null);\n setOpen(true);\n };\n\n let maxDate = new Date(value && new Date(value) > new Date() ? new Date(value) : new Date());\n maxDate.setFullYear(maxDate.getFullYear() + (yearsAfterCurrentDate ?? 50));\n\n //itemsNumber - controls number of year select options generated in the dropdown\n //items related to dates higher than 'maxDate' will be hidden, thus to avoid creating hundreds of invisible divs, we divide by 5\n let minDate = new Date(value && new Date(value) < new Date() ? new Date(value) : new Date());\n const itemsNumber = Math.round((minDate.getFullYear() - (yearsBeforeCurrentDate ?? 15)) / 5);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === 'Escape' || e.key === 'Esc')\n datepickerRef.current.setOpen(false);\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLDivElement>) => {\n // @ts-ignore\n if (!e.currentTarget.contains(e.relatedTarget)) {\n onBlur && onBlur(e);\n }\n };\n\n return (\n <>\n {/* Let's render the input itself */}\n <DatePickerContainer yearPicker={yearPickerMode} margin={margin || ''} onBlur={handleBlur}>\n <DatePicker\n ref={datepickerRef}\n onCalendarOpen={handleCalendarOpen}\n onCalendarClose={handleCalendarClose}\n onKeyDown={handleKeyDown}\n\n onClickOutside={() => datepickerRef.current.setOpen(false)}\n\n onChange={(e: any) => {\n if (onChange) {\n if (yearPickerMode) {\n const newDate = new Date();\n newDate.setFullYear(e.getFullYear());\n newDate.setMonth(activeMonthPage);\n setOpenAt(newDate);\n } else onChange(e);\n }\n if (yearPickerMode) setYearPickerMode(false);\n }}\n disabled={disabled || readOnly}\n locale={en}\n showYearPicker={yearPickerMode}\n //we manipulate 'yearItemNumber' and 'maxDate' to guarantee number of year select options shown before and after selected year\n yearItemNumber={yearPickerMode ? itemsNumber : undefined}\n maxDate={yearPickerMode ? maxDate : undefined}\n selected={value}\n openToDate={openAt ?? undefined}\n preventOpenOnFocus={true}\n shouldCloseOnSelect={true}\n renderCustomHeader={\n yearPicker\n ? (params: DatepickerFieldHeaderParams) =>\n React.createElement(\n DatepickerFieldHeader,\n {\n ...params,\n setActiveMonthPage,\n customHeaderCount: 0,\n yearPickerMode: yearPickerMode,\n setYearPickerMode: setYearPickerMode,\n },\n null,\n )\n : undefined\n }\n customInput={\n <InputWrapper disabled={disabled} readOnly={readOnly}>\n <div style={{display: 'block', margin: '4px 0px'}}>\n <DatepickerRow>\n <StyledInputFieldStyling\n ref={inputRef}\n type=\"text\"\n name=\"datepicker\"\n onKeyDown={(e) => e.key === 'Enter' && datepickerRef.current.setOpen(true)}\n className={(invalid ? 'invalid' : '' + (open ? ' open' : ''))}\n tabIndex={disabled || readOnly ? -1 : 0}\n onFocus={(e) => inputRef.current?.setSelectionRange(0, 0)}\n autoComplete={autoComplete}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={true}\n suppressReadOnlyStyles={!readOnly}\n required={required}\n {...rest}\n />\n <IconWrapper>\n <Calendar size=\"24\"/>\n </IconWrapper>\n </DatepickerRow>\n </div>\n </InputWrapper>\n }\n />\n </DatePickerContainer>\n\n {/* If there is an error, let's render the error */}\n {validationMessage && (\n <ErrorMessage>\n <TechnicalWarning color={COLORS.critical_400}/>\n <span>{validationMessage}</span>\n </ErrorMessage>\n )}\n </>\n );\n});\n\nexport default DatepickerField;\n"],"file":"DatepickerField.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/InputFields/DatepickerField.tsx"],"names":["React","styled","DatePicker","en","moment","COLORS","Calendar","TechnicalWarning","DatepickerFieldHeader","ComponentTextStyle","focusStyles","scrollBarStyling","ErrorMessage","InputFieldStyling","InputWrapper","ComponentMStyling","ComponentSStyling","Z_INDEXES","useFocusVisibleRef","Size","DatePickerContainer","div","dropdown","props","margin","primary_20","neutral_20","neutral_200","yearPicker","Bold","neutral_600","Small","Regular","white","primary_700","primary_500","neutral_700","neutral_100","IconWrapper","focus","DatepickerRow","StyledInputFieldStyling","neutral_500","primary_300","primary_200","primary_100","primary_800","neutral_300","DatepickerField","id","disabled","readOnly","onChange","invalid","value","validationMessage","dateFormat","autoComplete","placeholder","required","yearsBeforeCurrentDate","yearsAfterCurrentDate","inputRef","datepickerRef","useRef","useState","activeMonthPage","setActiveMonthPage","yearPickerMode","setYearPickerMode","openAt","setOpenAt","open","setOpen","useEffect","current","format","selectedDate","document","getElementsByClassName","dropdownParent","parentElement","scrollTop","offsetTop","offsetHeight","handleCalendarClose","blur","handleCalendarOpen","maxDate","Date","setFullYear","getFullYear","minDate","itemsNumber","Math","round","handleKeyDown","e","key","newDate","setMonth","undefined","params","createElement","customHeaderCount","display","setSelectionRange","critical_400"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAA4B,mBAA5B;AACA,OAAOC,UAAP,MAAuB,kBAAvB;AACA,OAAOC,EAAP,MAAe,uBAAf;AACA,OAAOC,MAAP,MAAmB,QAAnB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,kBAAnB;AACA,SAASC,QAAT,EAAmBC,gBAAnB,QAA2C,kCAA3C;AACA,SAASC,qBAAT,QAAmE,yBAAnE;AACA,SAASC,kBAAT,EAA6BC,WAA7B,EAA0CC,gBAA1C,QAAkE,WAAlE;AAEA;AACA;AACA;;AACA,SAASC,YAAT,EAAuBC,iBAAvB,EAA0CC,YAA1C,QAA8D,WAA9D;AACA,OAAO,4CAAP;AACA,SAASC,iBAAT,EAA4BC,iBAA5B,QAAqD,sBAArD;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,kBAAT,QAAmC,wBAAnC;AACA,SAASC,IAAT,QAAqB,UAArB;;;;;AAwBA;AACA;AACA;AACA,IAAMC,mBAAmB,GAAGnB,MAAM,CAACoB,GAAV,k7OAEVJ,SAAS,CAACK,QAFA,EAQnB,UAACC,KAAD;AAAA,SAAYA,KAAK,CAACC,MAAN,qBAA0BD,KAAK,CAACC,MAAhC,SAA4C,EAAxD;AAAA,CARmB,EA2BHnB,MAAM,CAACoB,UA3BJ,EAuCff,WAvCe,EAuFIL,MAAM,CAACqB,UAvFX,EA2FQrB,MAAM,CAACsB,WA3Ff,EA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AAa,EAAxB,CANpC;AAOE,gBAAA,QAAQ,EAAEtB,QAAQ,IAAIC,QAAZ,GAAuB,CAAC,CAAxB,GAA4B,CAPxC;AAQE,gBAAA,OAAO,EAAE,iBAAC8C,CAAD;AAAA;;AAAA,+CAAOnC,QAAQ,CAACa,OAAhB,uDAAO,mBAAkB+B,iBAAlB,CAAoC,CAApC,EAAuC,CAAvC,CAAP;AAAA,iBARX;AASE,gBAAA,YAAY,EAAEjD,YAThB;AAUE,gBAAA,WAAW,EAAEC,WAVf;AAWE,gBAAA,QAAQ,EAAER,QAXZ;AAYE,gBAAA,QAAQ,EAAE,IAZZ;AAaE,gBAAA,sBAAsB,EAAE,CAACC,QAb3B;AAcE,gBAAA,QAAQ,EAAEQ;AAdZ,gBADF,eAiBE,KAAC,WAAD;AAAA,uCACE,KAAC,QAAD;AAAU,kBAAA,IAAI,EAAC;AAAf;AADF,gBAjBF;AAAA;AADF;AADF;AA9CJ;AADF,MAFF,EA+EGJ,iBAAiB,iBAChB,MAAC,YAAD;AAAA,8BACE,KAAC,gBAAD;AAAkB,QAAA,KAAK,EAAElD,MAAM,CAACsG;AAAhC,QADF,eAEE;AAAA,kBAAOpD;AAAP,QAFF;AAAA,MAhFJ;AAAA,IADF;AAwFD,CApKD;;;AA7SEN,EAAAA,E;AACAC,EAAAA,Q;AACAC,EAAAA,Q;AACAC,EAAAA,Q;AACAC,EAAAA,O;AACAC,EAAAA,K;AACAE,EAAAA,U;AACAD,EAAAA,iB;AACAE,EAAAA,Y;AACAC,EAAAA,W;AACAC,EAAAA,Q;AACA/B,EAAAA,U;AACAgC,EAAAA,sB;AACAC,EAAAA,qB;AACArC,EAAAA,M;;AAqcF,eAAewB,eAAf","sourcesContent":["/**\n * Import react libraries.\n */\nimport * as React from 'react';\n\n/**\n * Import third-party libraries.\n */\nimport styled, { css } from 'styled-components';\nimport DatePicker from 'react-datepicker';\nimport en from 'date-fns/locale/en-GB';\nimport moment from 'moment';\n\n/**\n * Import custom components.\n */\nimport COLORS from '../styles/colors';\nimport { Calendar, TechnicalWarning } from '../icons/systemicons/SystemIcons';\nimport { DatepickerFieldHeader, DatepickerFieldHeaderParams } from './DatepickerFieldHeader';\nimport { ComponentTextStyle, focusStyles, scrollBarStyling } from '../styles';\n\n/**\n * Import custom styles.\n */\nimport { ErrorMessage, InputFieldStyling, InputWrapper } from './styling';\nimport 'react-datepicker/dist/react-datepicker.css';\nimport { ComponentMStyling, ComponentSStyling } from '../styles/typography';\nimport { Z_INDEXES } from '../styles/z-indexes';\nimport { useFocusVisibleRef } from '../common/FocusVisible';\nimport { Size } from '../types';\nimport { defaultOnMouseDownHandler } from '../common';\n\n/**\n * Add custom types.\n */\ntype DatepickerFieldProps = {\n id: string;\n disabled?: boolean;\n readOnly?: boolean;\n onChange?: (date: Date) => void;\n invalid?: boolean;\n value?: Date;\n dateFormat?: string;\n validationMessage?: string;\n autoComplete?: string;\n placeholder?: string;\n required?: boolean;\n yearPicker?: boolean;\n yearsBeforeCurrentDate?: number;\n yearsAfterCurrentDate?: number;\n margin?: string;\n};\n\n/**\n * Add custom styles.\n */\nconst DatePickerContainer = styled.div<{ yearPicker: boolean; margin: string }>`\n .react-datepicker-popper {\n z-index: ${Z_INDEXES.dropdown};\n }\n\n > div {\n display: block;\n\n ${(props) => (props.margin ? `margin: ${props.margin};` : '')}\n .react-datepicker {\n box-sizing: border-box;\n box-shadow: 0px 2px 4px rgb(0 0 0 / 15%);\n border: 1px solid #e5e5e5;\n }\n\n .react-datepicker__navigation {\n line-height: normal;\n text-indent: inherit;\n border: none;\n border-radius: 4px;\n height: 32px;\n width: 32px;\n outline: none;\n margin: 0px;\n color: transparent;\n\n &:hover {\n background: ${COLORS.primary_20};\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23215369' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23215369' /%3E%3C/svg%3E\");\n }\n }\n\n &:focus {\n ${focusStyles}\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23163746' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23163746' /%3E%3C/svg%3E\");\n }\n }\n\n &::before {\n text-align: center;\n display: inline-block;\n content: '';\n height: 32px;\n width: 32px;\n vertical-align: middle;\n }\n\n &.react-datepicker__navigation--next::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M9.24214 19.8807C8.85113 19.4907 8.85034 18.8575 9.24038 18.4665L15.5184 12.1727L9.24037 5.87895C8.85034 5.48794 8.85113 4.85478 9.24214 4.46474C9.63315 4.0747 10.2663 4.07549 10.6564 4.46651L17.6389 11.4665C18.0282 11.8568 18.0282 12.4886 17.6389 12.879L10.6564 19.879C10.2663 20.27 9.63316 20.2708 9.24214 19.8807Z' fill='%23666666' /%3E%3C/svg%3E\");\n }\n\n &.react-datepicker__navigation--previous::before {\n background-image: url(\"data:image/svg+xml,%3Csvg style='width: 32px; height: 32px;' viewBox='0 0 25 25' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fillRule='evenodd' clipRule='evenodd' d='M15.1975 4.46474C15.5885 4.85478 15.5893 5.48794 15.1993 5.87895L8.92124 12.1727L15.1993 18.4665C15.5893 18.8575 15.5885 19.4907 15.1975 19.8807C14.8065 20.2708 14.1734 20.27 13.7833 19.879L6.8008 12.879C6.41145 12.4886 6.41145 11.8568 6.8008 11.4665L13.7833 4.46651C14.1734 4.0755 14.8065 4.0747 15.1975 4.46474Z' fill='%23666666' /%3E%3C/svg%3E\");\n }\n }\n\n .react-datepicker__month-container,\n .react-datepicker__year--container {\n width: 336px;\n }\n\n .react-datepicker__month {\n margin: 0px;\n }\n\n .react-datepicker__triangle {\n left: 50% !important;\n display: none;\n }\n\n .react-datepicker-popper[data-placement^='bottom'] {\n margin-top: 0;\n }\n\n .react-datepicker-popper[data-placement^='bottom'] .react-datepicker__triangle {\n border-bottom-color: ${COLORS.neutral_20};\n }\n\n .react-datepicker__header {\n border-bottom: 1px solid ${COLORS.neutral_200};\n background: ${COLORS.neutral_20};\n height: ${(props) => (!props.yearPicker ? '96px' : '54px')};\n padding-top: 0px;\n }\n\n .react-datepicker__current-month {\n height: 48px;\n display: inline-flex;\n align-items: center;\n margin-right: 5px;\n\n ${ComponentSStyling(ComponentTextStyle.Bold, COLORS.neutral_600)}\n }\n\n .react-datepicker__year {\n max-height: 300px;\n overflow-y: scroll;\n\n ${scrollBarStyling(Size.Small)}\n }\n\n .react-datepicker__year-wrapper {\n max-width: 100%;\n justify-content: space-around;\n }\n\n .react-datepicker__day-name {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n height: 48px;\n margin: 0px;\n width: 48px;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}\n }\n\n .react-datepicker__year-text {\n background: ${COLORS.white};\n border: none;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n margin-top: 20px;\n padding-top: 10px;\n padding-bottom: 10px;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}\n &.react-datepicker__year-text--disabled {\n display: none;\n }\n\n &.react-datepicker__day--keyboard-selected {\n color: ${COLORS.neutral_600};\n background: ${COLORS.white};\n font-weight: 400;\n border: none;\n }\n\n &:hover {\n color: ${COLORS.primary_700};\n background: ${COLORS.primary_20};\n }\n\n &:focus {\n ${focusStyles}\n }\n\n &.react-datepicker__year-text--selected {\n color: ${COLORS.white} !important;\n background: ${COLORS.primary_500} !important;\n }\n }\n\n .react-datepicker__day {\n background: ${COLORS.white};\n border: none;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n height: 40px;\n width: 40px;\n margin: 4px;\n\n ${ComponentMStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}\n &.react-datepicker__day--keyboard-selected {\n color: ${COLORS.neutral_600};\n background: ${COLORS.white};\n font-weight: 400;\n border: none;\n }\n\n &:hover {\n color: ${COLORS.primary_700};\n background: ${COLORS.primary_20};\n }\n\n &:focus {\n ${focusStyles}\n }\n\n &.react-datepicker__day--selected {\n color: ${COLORS.white} !important;\n background: ${COLORS.primary_500} !important;\n }\n\n &.react-datepicker__day--today {\n border-radius: 0.3rem;\n color: ${COLORS.neutral_700};\n background: ${COLORS.neutral_100};\n\n &:hover {\n color: ${COLORS.primary_700};\n background: ${COLORS.primary_20};\n }\n\n &:focus {\n ${focusStyles}\n }\n }\n }\n }\n`;\n\nconst IconWrapper = styled.div`\n pointer-events: none;\n position: absolute;\n right: 16px;\n width: 24px;\n height: 24px;\n z-index: ${Z_INDEXES.focus + 1};\n color: ${COLORS.neutral_600};\n`;\n\nconst DatepickerRow = styled.div`\n display: flex;\n flex-direction: row;\n align-items: center;\n`;\n\nconst StyledInputFieldStyling = styled(InputFieldStyling)`\n &::placeholder {\n color: ${COLORS.neutral_500};\n }\n\n &:focus:not(.focus-visible) {\n box-shadow: inset 0px 0px 0px 2px ${COLORS.primary_300};\n }\n\n &:hover {\n box-shadow: inset 0px 0px 0px 2px ${COLORS.primary_200};\n\n ::placeholder {\n color: ${COLORS.primary_700};\n }\n\n cursor: pointer;\n background-color: ${COLORS.primary_20};\n color: ${COLORS.primary_700};\n }\n\n &:active,\n &.open {\n box-shadow: inset 0px 0px 0px 2px ${COLORS.primary_300};\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_800};\n\n ::placeholder {\n color: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n background-color: ${COLORS.white};\n }\n\n &:hover ~ ${IconWrapper} {\n color: ${COLORS.primary_700};\n }\n\n &:active ~ ${IconWrapper}, &.open ~ ${IconWrapper} {\n color: ${COLORS.primary_800};\n }\n\n &:disabled ~ ${IconWrapper}, &:read-only ~ ${IconWrapper} {\n color: ${COLORS.neutral_300};\n }\n`;\n\nconst DatepickerField = ({\n id,\n disabled,\n readOnly,\n onChange,\n invalid,\n value,\n validationMessage,\n dateFormat,\n autoComplete,\n placeholder,\n required,\n yearPicker,\n yearsBeforeCurrentDate,\n yearsAfterCurrentDate,\n margin,\n}: DatepickerFieldProps) => {\n // Globally used variables within the component\n const inputRef = useFocusVisibleRef();\n const datepickerRef = React.useRef<any>(null);\n const [activeMonthPage, setActiveMonthPage] = React.useState<number>(-1);\n const [yearPickerMode, setYearPickerMode] = React.useState<boolean>(false);\n const [openAt, setOpenAt] = React.useState<Date | null>(null);\n // 'open' flag is used only for tracking current state of the dropdown,\n // for explicitly opening/closing the picker we are using 'datepickerRef.current.setOpen'\n const [open, setOpen] = React.useState<boolean>(false);\n\n /**\n * Format the date in a specific way.\n */\n React.useEffect(() => {\n if (value) inputRef.current.value = moment(value).format(dateFormat ? dateFormat : 'MMMM Do, YYYY');\n }, [value]);\n\n React.useEffect(() => {\n if (yearPickerMode) {\n //unfortunately, since there are no refs, and year pickers is rendered not by our code, but by 'react-datepicker'\n //we have to touch DOM directly\n const selectedDate = document.getElementsByClassName('react-datepicker__year-text--selected')[0] as HTMLElement;\n const dropdownParent = selectedDate?.parentElement?.parentElement;\n if (selectedDate && dropdownParent) dropdownParent.scrollTop = selectedDate.offsetTop - 2 * selectedDate.offsetHeight;\n }\n }, [yearPickerMode]);\n\n //we have to manually reopen the calendar when needed, to guarantee that datepicker will show selected date after year selection\n //otherwise after year selection datepicker will show January month of the selected year\n React.useEffect(() => {\n if (openAt) { \n datepickerRef.current.setOpen(true);\n //setOpenAt(null);\n }\n }, [openAt]);\n\n const handleCalendarClose = () => {\n inputRef.current?.blur();\n setOpen(false);\n };\n\n const handleCalendarOpen = () => {\n if (openAt) setOpenAt(null);\n setOpen(true);\n };\n\n let maxDate = new Date(value && new Date(value) > new Date() ? new Date(value) : new Date());\n maxDate.setFullYear(maxDate.getFullYear() + (yearsAfterCurrentDate ?? 50));\n\n //itemsNumber - controls number of year select options generated in the dropdown\n //items related to dates higher than 'maxDate' will be hidden, thus to avoid creating hundreds of invisible divs, we divide by 5\n let minDate = new Date(value && new Date(value) < new Date() ? new Date(value) : new Date());\n const itemsNumber = Math.round((minDate.getFullYear() - (yearsBeforeCurrentDate ?? 15)) / 5);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === 'Escape' || e.key === 'Esc')\n datepickerRef.current.setOpen(false);\n };\n\n return (\n <>\n {/* Let's render the input itself */}\n <DatePickerContainer yearPicker={yearPickerMode} margin={margin || ''}>\n <DatePicker\n ref={datepickerRef}\n onCalendarOpen={handleCalendarOpen}\n onCalendarClose={handleCalendarClose}\n onKeyDown={handleKeyDown}\n \n onClickOutside={() => datepickerRef.current.setOpen(false)}\n\n onChange={(e: any) => {\n if (onChange) {\n if (yearPickerMode) {\n const newDate = new Date();\n newDate.setFullYear(e.getFullYear());\n newDate.setMonth(activeMonthPage);\n setOpenAt(newDate);\n } else onChange(e);\n }\n if (yearPickerMode) setYearPickerMode(false);\n }}\n disabled={disabled || readOnly}\n locale={en}\n showYearPicker={yearPickerMode}\n //we manipulate 'yearItemNumber' and 'maxDate' to guarantee number of year select options shown before and after selected year\n yearItemNumber={yearPickerMode ? itemsNumber : undefined}\n maxDate={yearPickerMode ? maxDate : undefined}\n selected={value}\n openToDate={openAt ?? undefined}\n preventOpenOnFocus={true}\n shouldCloseOnSelect={true}\n renderCustomHeader={\n yearPicker\n ? (params: DatepickerFieldHeaderParams) =>\n React.createElement(\n DatepickerFieldHeader,\n {\n ...params,\n setActiveMonthPage,\n customHeaderCount: 0,\n yearPickerMode: yearPickerMode,\n setYearPickerMode: setYearPickerMode,\n },\n null,\n )\n : undefined\n }\n customInput={\n <InputWrapper disabled={disabled} readOnly={readOnly}>\n <div style={{ display: 'block', margin: '4px 0px' }}>\n <DatepickerRow>\n <StyledInputFieldStyling\n id={id}\n ref={inputRef}\n type=\"text\"\n name=\"datepicker\"\n onKeyDown={(e) => e.key === 'Enter' && datepickerRef.current.setOpen(true)}\n className={(invalid ? 'invalid' : '' + (open ? ' open' : ''))}\n tabIndex={disabled || readOnly ? -1 : 0}\n onFocus={(e) => inputRef.current?.setSelectionRange(0, 0)}\n autoComplete={autoComplete}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={true}\n suppressReadOnlyStyles={!readOnly}\n required={required}\n />\n <IconWrapper>\n <Calendar size=\"24\" />\n </IconWrapper>\n </DatepickerRow>\n </div>\n </InputWrapper>\n }\n />\n </DatePickerContainer>\n\n {/* If there is an error, let's render the error */}\n {validationMessage && (\n <ErrorMessage>\n <TechnicalWarning color={COLORS.critical_400} />\n <span>{validationMessage}</span>\n </ErrorMessage>\n )}\n </>\n );\n};\n\nexport default DatepickerField;\n"],"file":"DatepickerField.js"}
|
|
@@ -9,12 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.default = void 0;
|
|
11
11
|
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
13
|
|
|
16
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
17
|
-
|
|
18
14
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
19
15
|
|
|
20
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -37,31 +33,25 @@ var _types = require("../types");
|
|
|
37
33
|
|
|
38
34
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
39
35
|
|
|
40
|
-
var _excluded = ["size", "label", "note", "noteIcon", "required", "prefix", "interval", "minValue", "maxValue", "allowNegative", "decimalPrecision", "disabled", "readOnly", "state", "value", "placeholder", "type", "onChange", "className"];
|
|
41
|
-
|
|
42
36
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13;
|
|
43
37
|
|
|
44
38
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
39
|
|
|
46
40
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
47
41
|
|
|
48
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
49
|
-
|
|
50
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
51
|
-
|
|
52
42
|
var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)([""])));
|
|
53
43
|
|
|
54
|
-
var LabelContainer = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
44
|
+
var LabelContainer = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n margin-bottom: 4px;\n color: ", ";\n display: flex;\n ", "\n"])), _styles.COLORS.neutral_500, function (props) {
|
|
55
45
|
return props.size === _types.Size.Small ? (0, _typography.ComponentXXSStyling)(_typography.ComponentTextStyle.Regular, null) : (0, _typography.ComponentXSStyling)(_typography.ComponentTextStyle.Regular, null);
|
|
56
46
|
});
|
|
57
47
|
|
|
58
48
|
var LabelText = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)([""])));
|
|
59
49
|
|
|
60
|
-
var LabelIcon = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
50
|
+
var LabelIcon = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n margin-right: ", ";\n svg {\n height: 9px;\n width: 9px;\n }\n"])), function (props) {
|
|
61
51
|
return props.size === _types.Size.Small ? '6px' : '8px';
|
|
62
52
|
});
|
|
63
53
|
|
|
64
|
-
var PrefixContainer = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
54
|
+
var PrefixContainer = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n width: ", ";\n height: ", ";\n color: ", ";\n ", "\n position: absolute;\n padding: ", ";\n"])), function (props) {
|
|
65
55
|
return props.size === _types.Size.Small ? '10px' : '11px';
|
|
66
56
|
}, function (props) {
|
|
67
57
|
return props.size === _types.Size.Small ? '20px' : '24px';
|
|
@@ -73,11 +63,11 @@ var PrefixContainer = _styledComponents.default.div(_templateObject5 || (_templa
|
|
|
73
63
|
return props.size === _types.Size.Small ? '14px 0 14px 16px' : '16px 0 16px 16px';
|
|
74
64
|
});
|
|
75
65
|
|
|
76
|
-
var OperatorWrapper = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
66
|
+
var OperatorWrapper = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n top: 0;\n right:0;\n display: flex;\n margin:", ";\n svg {\n height: 14px;\n width: 14px;\n }\n .divider {\n margin: 16px 0;\n background: ", ";\n width: 1px;\n }\n"])), function (props) {
|
|
77
67
|
return props.size === _types.Size.Medium ? '4px 0' : '';
|
|
78
68
|
}, _styles.COLORS.neutral_200);
|
|
79
69
|
|
|
80
|
-
var NumberInput = _styledComponents.default.input(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
70
|
+
var NumberInput = _styledComponents.default.input(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%; \n border: none;\n border-radius: 4px;\n box-shadow: inset 0px 0px 0px 1px ", ";\n outline: none;\n color: ", ";\n ", "\n\n ", "\n\n ", "\n\n &::placeholder {\n ", "\n }\n\n &:focus:not(.focus-visible):not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n \n &.focus-visible {\n ", "\n }\n\n &:hover:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n\n &.disabled {\n box-shadow: inset 0px 0px 0px 1px ", ";\n cursor: not-allowed;\n color: ", ";\n cursor: not-allowed;\n pointer-events: none;\n\n &::placeholder {\n color: ", ";\n }\n }\n\n &.readOnly {\n background: ", ";\n box-shadow: inset 0px 0px 0px 1px ", ";\n cursor: not-allowed;\n background: ", ";\n cursor: not-allowed;\n pointer-events: none;\n color: ", ";\n }\n\n &.valid {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n\n &.invalid {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n"])), _styles.COLORS.neutral_400, _styles.COLORS.neutral_500, function (props) {
|
|
81
71
|
return props.fieldSize === _types.Size.Small ? (0, _typography.ComponentSStyling)(_typography.ComponentTextStyle.Regular, _styles.COLORS.black) : (0, _typography.ComponentMStyling)(_typography.ComponentTextStyle.Regular, _styles.COLORS.black);
|
|
82
72
|
}, function (props) {
|
|
83
73
|
return props.type === 'NumberField' ? "\n padding: ".concat(props.fieldSize === _types.Size.Small ? '14px 97px 14px 16px' : '16px 97px 16px 16px', ";\n padding-left: ").concat(props.hasPrefix ? '30px' : '', ";\n ") : '';
|
|
@@ -87,61 +77,59 @@ var NumberInput = _styledComponents.default.input(_templateObject7 || (_template
|
|
|
87
77
|
return props.fieldSize === _types.Size.Small ? (0, _typography.ComponentSStyling)(_typography.ComponentTextStyle.Italic, null) : (0, _typography.ComponentMStyling)(_typography.ComponentTextStyle.Italic, null);
|
|
88
78
|
}, _styles.COLORS.primary_800, _styles.focusStyles, _styles.COLORS.primary_700, _styles.COLORS.neutral_100, _styles.COLORS.neutral_300, _styles.COLORS.neutral_300, _styles.COLORS.neutral_100, _styles.COLORS.neutral_300, _styles.COLORS.neutral_100, _styles.COLORS.neutral_500, _styles.COLORS.correct_400, _styles.COLORS.critical_400);
|
|
89
79
|
|
|
90
|
-
var NoteLabel = _styledComponents.default.div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
80
|
+
var NoteLabel = _styledComponents.default.div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n ", " \n"])), _styles.COLORS.neutral_500, function (props) {
|
|
91
81
|
return props.size === _types.Size.Small ? (0, _typography.ComponentXXSStyling)(_typography.ComponentTextStyle.Regular, null) : (0, _typography.ComponentXSStyling)(_typography.ComponentTextStyle.Regular, null);
|
|
92
82
|
});
|
|
93
83
|
|
|
94
|
-
var NoteIcon = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
84
|
+
var NoteIcon = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n svg {\n height: 16px;\n }\n"])));
|
|
95
85
|
|
|
96
|
-
var NoteContainer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
86
|
+
var NoteContainer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n margin-top: 5px;\n\n &.valid {\n ", " {\n color: ", ";\n }\n\n ", " {\n svg path {\n fill: ", ";\n }\n }\n }\n\n &.invalid {\n ", " {\n color: ", ";\n }\n\n ", " {\n svg path {\n fill: ", ";\n }\n }\n }\n"])), NoteLabel, _styles.COLORS.correct_500, NoteIcon, _styles.COLORS.correct_500, NoteLabel, _styles.COLORS.critical_500, NoteIcon, _styles.COLORS.critical_500);
|
|
97
87
|
|
|
98
|
-
var InputContainer = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
88
|
+
var InputContainer = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n min-width: ", ";\n height: ", ";\n display: flex;\n position: relative;\n\n input.focus-visible ~ div.operator {\n z-index: ", ";\n }\n"])), function (props) {
|
|
99
89
|
return props.type === 'NumberField' ? '160px' : '144px';
|
|
100
90
|
}, function (props) {
|
|
101
91
|
return props.size === _types.Size.Small ? '48px' : '56px';
|
|
102
92
|
}, _styles.Z_INDEXES.focus);
|
|
103
93
|
|
|
104
|
-
var LeftOperator = _styledComponents.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
94
|
+
var LeftOperator = _styledComponents.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n top: ", ";\n left: 0;\n"])), function (props) {
|
|
105
95
|
return props.size === _types.Size.Small ? '0' : '4px';
|
|
106
96
|
});
|
|
107
97
|
|
|
108
|
-
var RightOperator = _styledComponents.default.div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
98
|
+
var RightOperator = _styledComponents.default.div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n top: ", ";\n right: 0;\n"])), function (props) {
|
|
109
99
|
return props.size === _types.Size.Small ? '0' : '4px';
|
|
110
100
|
});
|
|
111
101
|
|
|
112
|
-
var NumberField =
|
|
113
|
-
var
|
|
114
|
-
size =
|
|
115
|
-
label =
|
|
116
|
-
note =
|
|
117
|
-
noteIcon =
|
|
118
|
-
required =
|
|
119
|
-
prefix =
|
|
120
|
-
|
|
121
|
-
interval =
|
|
122
|
-
minValue =
|
|
123
|
-
maxValue =
|
|
124
|
-
allowNegative =
|
|
125
|
-
decimalPrecision =
|
|
126
|
-
disabled =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
102
|
+
var NumberField = function NumberField(_ref) {
|
|
103
|
+
var _ref$size = _ref.size,
|
|
104
|
+
size = _ref$size === void 0 ? _types.Size.Small : _ref$size,
|
|
105
|
+
label = _ref.label,
|
|
106
|
+
note = _ref.note,
|
|
107
|
+
noteIcon = _ref.noteIcon,
|
|
108
|
+
required = _ref.required,
|
|
109
|
+
prefix = _ref.prefix,
|
|
110
|
+
_ref$interval = _ref.interval,
|
|
111
|
+
interval = _ref$interval === void 0 ? 1 : _ref$interval,
|
|
112
|
+
minValue = _ref.minValue,
|
|
113
|
+
maxValue = _ref.maxValue,
|
|
114
|
+
allowNegative = _ref.allowNegative,
|
|
115
|
+
decimalPrecision = _ref.decimalPrecision,
|
|
116
|
+
_ref$disabled = _ref.disabled,
|
|
117
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
118
|
+
_ref$readOnly = _ref.readOnly,
|
|
119
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
120
|
+
valid = _ref.valid,
|
|
121
|
+
value = _ref.value,
|
|
122
|
+
placeholder = _ref.placeholder,
|
|
123
|
+
type = _ref.type,
|
|
124
|
+
onChange = _ref.onChange;
|
|
135
125
|
|
|
136
126
|
var _React$useState = React.useState(value ? value.toString() : ''),
|
|
137
127
|
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
|
138
128
|
userInput = _React$useState2[0],
|
|
139
129
|
setUserInput = _React$useState2[1];
|
|
140
130
|
|
|
131
|
+
var fieldState = valid !== undefined ? valid ? 'valid' : 'invalid' : undefined;
|
|
141
132
|
var elementRef = (0, _common.useFocusVisibleRef)();
|
|
142
|
-
React.useImperativeHandle(ref, function () {
|
|
143
|
-
return elementRef.current;
|
|
144
|
-
}, [elementRef]);
|
|
145
133
|
|
|
146
134
|
var setVal = function setVal(e) {
|
|
147
135
|
setUserInput(e);
|
|
@@ -211,12 +199,7 @@ var NumberField = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
211
199
|
|
|
212
200
|
if (!isNaN(val)) {
|
|
213
201
|
if (decimalPrecision) val = Math.round((val - interval) * Math.pow(10, decimalPrecision)) / Math.pow(10, decimalPrecision);else val -= 1;
|
|
214
|
-
|
|
215
|
-
if (minValue && minValue <= val || !minValue) {
|
|
216
|
-
if (allowNegative || val >= 0) {
|
|
217
|
-
setVal(val.toString());
|
|
218
|
-
}
|
|
219
|
-
}
|
|
202
|
+
if (minValue && minValue <= val) allowNegative ? setVal(val.toString()) : val >= 0 ? setVal(val.toString()) : undefined;else if (!minValue) allowNegative ? setVal(val.toString()) : val >= 0 ? setVal(val.toString()) : undefined;
|
|
220
203
|
}
|
|
221
204
|
};
|
|
222
205
|
|
|
@@ -224,9 +207,9 @@ var NumberField = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
224
207
|
var val = decimalPrecision ? parseFloat(input) : parseInt(input);
|
|
225
208
|
val = isNaN(val) && userInput === '' ? 0 : val;
|
|
226
209
|
var operatorState = false;
|
|
227
|
-
if (operator === 'add' && maxValue) operatorState = val
|
|
228
|
-
if (operator === 'subtract' && minValue) operatorState = val
|
|
229
|
-
if (operator === 'subtract' && !minValue && !allowNegative) operatorState = val
|
|
210
|
+
if (operator === 'add' && maxValue) operatorState = val < maxValue ? false : true;
|
|
211
|
+
if (operator === 'subtract' && minValue) operatorState = val > minValue ? false : true;
|
|
212
|
+
if (operator === 'subtract' && !minValue && !allowNegative) operatorState = val > 0 ? false : true;
|
|
230
213
|
return operatorState;
|
|
231
214
|
};
|
|
232
215
|
|
|
@@ -234,7 +217,7 @@ var NumberField = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
234
217
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
235
218
|
children: [prefix && /*#__PURE__*/(0, _jsxRuntime.jsx)(PrefixContainer, {
|
|
236
219
|
size: size,
|
|
237
|
-
disabled:
|
|
220
|
+
disabled: disabled,
|
|
238
221
|
className: "operator",
|
|
239
222
|
children: prefix
|
|
240
223
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(OperatorWrapper, {
|
|
@@ -328,7 +311,7 @@ var NumberField = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
328
311
|
type: type,
|
|
329
312
|
size: size,
|
|
330
313
|
tabIndex: -1,
|
|
331
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(NumberInput,
|
|
314
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(NumberInput, {
|
|
332
315
|
type: type,
|
|
333
316
|
"data-testid": 'numberInput',
|
|
334
317
|
fieldSize: size,
|
|
@@ -343,10 +326,10 @@ var NumberField = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
343
326
|
onKeyDown: function onKeyDown(e) {
|
|
344
327
|
return handleKeyPress(e);
|
|
345
328
|
},
|
|
346
|
-
className: 'numberField'.concat(disabled ? ' disabled' : '').concat(readOnly ? ' readOnly' : '').concat(
|
|
347
|
-
}
|
|
329
|
+
className: 'numberField'.concat(disabled ? ' disabled' : '').concat(readOnly ? ' readOnly' : '').concat(fieldState ? " ".concat(fieldState) : '')
|
|
330
|
+
}), type === 'NumberField' && renderNumberFieldElements(), type === 'NumberInput' && renderNumberInputElements()]
|
|
348
331
|
}), note && /*#__PURE__*/(0, _jsxRuntime.jsxs)(NoteContainer, {
|
|
349
|
-
className: 'noteField'.concat(
|
|
332
|
+
className: 'noteField'.concat(fieldState ? " ".concat(fieldState) : ''),
|
|
350
333
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(NoteIcon, {
|
|
351
334
|
children: noteIcon
|
|
352
335
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(NoteLabel, {
|
|
@@ -355,19 +338,25 @@ var NumberField = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
355
338
|
})]
|
|
356
339
|
})]
|
|
357
340
|
});
|
|
358
|
-
}
|
|
341
|
+
};
|
|
342
|
+
|
|
359
343
|
NumberField.propTypes = {
|
|
360
344
|
prefix: _propTypes.default.string,
|
|
361
345
|
interval: _propTypes.default.number,
|
|
362
346
|
label: _propTypes.default.string.isRequired,
|
|
363
347
|
note: _propTypes.default.string,
|
|
364
348
|
noteIcon: _propTypes.default.node,
|
|
349
|
+
required: _propTypes.default.bool,
|
|
365
350
|
minValue: _propTypes.default.number,
|
|
366
351
|
maxValue: _propTypes.default.number,
|
|
367
352
|
allowNegative: _propTypes.default.bool,
|
|
368
353
|
decimalPrecision: _propTypes.default.number,
|
|
369
|
-
|
|
354
|
+
disabled: _propTypes.default.bool,
|
|
355
|
+
readOnly: _propTypes.default.bool,
|
|
356
|
+
valid: _propTypes.default.bool,
|
|
370
357
|
value: _propTypes.default.number,
|
|
358
|
+
placeholder: _propTypes.default.string,
|
|
359
|
+
type: _propTypes.default.oneOf(['NumberField', 'NumberInput']).isRequired,
|
|
371
360
|
onChange: _propTypes.default.func
|
|
372
361
|
};
|
|
373
362
|
var _default = NumberField;
|