carbon-react 103.1.0 → 104.1.1
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/lib/__internal__/popover/popover.component.js +2 -6
- package/lib/components/badge/badge.style.d.ts +1 -1
- package/lib/components/badge/badge.style.js +3 -9
- package/lib/components/date/__internal__/date-formats/index.d.ts +8 -0
- package/lib/components/date/__internal__/date-formats/index.js +47 -0
- package/lib/components/date/__internal__/date-picker/date-picker.component.d.ts +3 -0
- package/lib/components/date/__internal__/date-picker/date-picker.component.js +154 -0
- package/lib/components/date/__internal__/date-picker/date-picker.d.ts +25 -0
- package/lib/components/date/{day-picker.style.d.ts → __internal__/date-picker/day-picker.style.d.ts} +0 -0
- package/lib/components/date/{day-picker.style.js → __internal__/date-picker/day-picker.style.js} +5 -1
- package/lib/components/date/__internal__/date-picker/index.d.ts +1 -0
- package/lib/{__internal__/date → components/date/__internal__/date-picker}/index.js +2 -2
- package/lib/components/date/{navbar → __internal__/navbar}/button.style.d.ts +0 -0
- package/lib/components/date/{navbar → __internal__/navbar}/button.style.js +1 -1
- package/lib/components/date/{navbar → __internal__/navbar}/index.d.ts +0 -0
- package/lib/components/date/{navbar → __internal__/navbar}/index.js +0 -0
- package/lib/components/date/{navbar → __internal__/navbar}/navbar.component.d.ts +0 -0
- package/lib/components/date/{navbar → __internal__/navbar}/navbar.component.js +10 -12
- package/lib/components/date/__internal__/navbar/navbar.d.ts +8 -0
- package/lib/components/date/{navbar → __internal__/navbar}/navbar.style.d.ts +0 -0
- package/lib/components/date/{navbar → __internal__/navbar}/navbar.style.js +1 -1
- package/lib/components/date/__internal__/utils.d.ts +19 -0
- package/lib/components/date/__internal__/utils.js +182 -0
- package/lib/components/date/{weekday → __internal__/weekday}/abbr.style.d.ts +0 -0
- package/lib/components/date/{weekday → __internal__/weekday}/abbr.style.js +0 -0
- package/lib/components/date/{weekday → __internal__/weekday}/index.d.ts +0 -0
- package/lib/components/date/{weekday → __internal__/weekday}/index.js +0 -0
- package/lib/components/date/{weekday → __internal__/weekday}/weekday.component.d.ts +0 -0
- package/lib/components/date/{weekday → __internal__/weekday}/weekday.component.js +0 -0
- package/lib/components/date/__internal__/weekday/weekday.d.ts +13 -0
- package/lib/components/date/{weekday → __internal__/weekday}/weekday.style.d.ts +0 -0
- package/lib/components/date/{weekday → __internal__/weekday}/weekday.style.js +1 -1
- package/lib/components/date/date.component.d.ts +27 -55
- package/lib/components/date/date.component.js +291 -661
- package/lib/components/date/date.d.ts +28 -20
- package/lib/components/date/date.style.js +3 -2
- package/lib/components/date/index.js +2 -10
- package/lib/components/date-range/date-range-context.d.ts +17 -0
- package/lib/components/date-range/date-range.component.d.ts +3 -5
- package/lib/components/date-range/date-range.component.js +123 -119
- package/lib/components/date-range/date-range.context.d.ts +3 -0
- package/lib/components/date-range/date-range.context.js +14 -0
- package/lib/components/date-range/date-range.d.ts +5 -7
- package/lib/components/date-range/date-range.style.js +1 -0
- package/lib/components/date-range/index.d.ts +1 -0
- package/lib/components/i18n-provider/i18n-provider.component.d.ts +1 -4
- package/lib/components/i18n-provider/i18n-provider.component.js +1 -4
- package/lib/components/portal/portal.js +3 -6
- package/lib/components/step-sequence/step-sequence-item/step-sequence-item.style.js +13 -23
- package/lib/components/tooltip/tooltip.component.js +3 -7
- package/lib/locales/date-fns-locales/index.d.ts +1 -0
- package/lib/locales/date-fns-locales/index.js +18 -0
- package/lib/locales/en-gb.js +3 -4
- package/lib/locales/locale.d.ts +3 -4
- package/lib/locales/pl-pl.d.ts +1 -1
- package/lib/locales/pl-pl.js +5 -0
- package/lib/style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component.d.ts +7 -5
- package/lib/style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component.js +11 -36
- package/lib/style/themes/aegean/aegean-theme.config.d.ts +1 -0
- package/lib/style/themes/aegean/aegean-theme.config.js +2 -1
- package/lib/style/themes/base/base-theme.config.d.ts +162 -93
- package/lib/style/themes/mint/mint-theme.config.d.ts +1 -0
- package/lib/style/themes/mint/mint-theme.config.js +2 -1
- package/lib/style/themes/sage/index.d.ts +162 -93
- package/package.json +6 -5
- package/lib/__internal__/date/date.d.ts +0 -34
- package/lib/__internal__/date/date.js +0 -216
- package/lib/__internal__/date/index.d.ts +0 -1
- package/lib/__spec_helper__/mock-date-helper.d.ts +0 -1
- package/lib/__spec_helper__/mock-date-helper.js +0 -37
- package/lib/components/date/date-picker.component.d.ts +0 -22
- package/lib/components/date/date-picker.component.js +0 -218
|
@@ -13,11 +13,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
13
13
|
|
|
14
14
|
var _core = require("@popperjs/core");
|
|
15
15
|
|
|
16
|
-
var _styledComponents = require("styled-components");
|
|
17
|
-
|
|
18
16
|
var _useResizeObserver = _interopRequireDefault(require("../../hooks/__internal__/useResizeObserver"));
|
|
19
17
|
|
|
20
|
-
var _carbonScopedTokensProvider = require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component");
|
|
18
|
+
var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
|
|
21
19
|
|
|
22
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
21
|
|
|
@@ -34,11 +32,9 @@ const Popover = ({
|
|
|
34
32
|
modifiers
|
|
35
33
|
}) => {
|
|
36
34
|
const elementDOM = (0, _react.useRef)();
|
|
37
|
-
const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
|
|
38
35
|
|
|
39
36
|
if (!elementDOM.current && !disablePortal) {
|
|
40
37
|
elementDOM.current = document.createElement("div");
|
|
41
|
-
elementDOM.current.classList.add((0, _carbonScopedTokensProvider.tokensClassName)(theme === null || theme === void 0 ? void 0 : theme.name));
|
|
42
38
|
document.body.appendChild(elementDOM.current);
|
|
43
39
|
}
|
|
44
40
|
|
|
@@ -98,7 +94,7 @@ const Popover = ({
|
|
|
98
94
|
return content;
|
|
99
95
|
}
|
|
100
96
|
|
|
101
|
-
return /*#__PURE__*/_reactDom.default.createPortal(content, elementDOM.current);
|
|
97
|
+
return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_carbonScopedTokensProvider.default, null, content), elementDOM.current);
|
|
102
98
|
};
|
|
103
99
|
|
|
104
100
|
Popover.propTypes = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export const StyledButton: import("styled-components").StyledComponent<typeof Button, any,
|
|
2
|
+
export const StyledButton: import("styled-components").StyledComponent<typeof Button, any, {}, never>;
|
|
3
3
|
export const StyledCrossIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
|
|
4
4
|
export const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
5
|
import Button from "../button";
|
|
@@ -37,9 +37,7 @@ const StyledButton = (0, _styledComponents.default)(_button.default)`
|
|
|
37
37
|
top: -11px;
|
|
38
38
|
right: -11px;
|
|
39
39
|
margin-right: 0;
|
|
40
|
-
background:
|
|
41
|
-
theme
|
|
42
|
-
}) => theme.colors.white};
|
|
40
|
+
background: var(--colorsActionMajorYang100);
|
|
43
41
|
|
|
44
42
|
::-moz-focus-inner {
|
|
45
43
|
border: none;
|
|
@@ -47,9 +45,7 @@ const StyledButton = (0, _styledComponents.default)(_button.default)`
|
|
|
47
45
|
|
|
48
46
|
&:hover,
|
|
49
47
|
&:focus {
|
|
50
|
-
background:
|
|
51
|
-
theme
|
|
52
|
-
}) => theme.colors.primary};
|
|
48
|
+
background: var(--colorsActionMajor500);
|
|
53
49
|
border: none;
|
|
54
50
|
${StyledCounter} {
|
|
55
51
|
display: none;
|
|
@@ -63,9 +59,7 @@ const StyledButton = (0, _styledComponents.default)(_button.default)`
|
|
|
63
59
|
|
|
64
60
|
:before {
|
|
65
61
|
font-size: 16px;
|
|
66
|
-
color:
|
|
67
|
-
theme
|
|
68
|
-
}) => theme.colors.white};
|
|
62
|
+
color: var(--colorsActionMajorYang100);
|
|
69
63
|
}
|
|
70
64
|
}
|
|
71
65
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
// The order of this array is important
|
|
8
|
+
const EU_FORMATS = ["d M yyyy", "dd M yyyy", "d MM yyyy", "dd MM yyyy", "d M yy", "dd M yy", "d MM yy", "dd MM yy", "d", "d M", "dd", "d MM", "dd M", "dd MM"]; // The order of this array is important
|
|
9
|
+
|
|
10
|
+
const NA_FORMATS = ["M", "M d", "MM", "M dd", "MM d", "MM dd", "M d yy", "MM d yy", "M dd yy", "MM dd yy", "M d yyyy", "MM d yyyy", "M dd yyyy", "MM dd yyyy"];
|
|
11
|
+
const SEPARATORS = ["", ".", ",", "-", "/", ":"];
|
|
12
|
+
|
|
13
|
+
const generateFormats = formatArray => formatArray.reduce((arr, formatString) => {
|
|
14
|
+
const array = [...arr, formatString];
|
|
15
|
+
|
|
16
|
+
if (formatString.includes(" ")) {
|
|
17
|
+
SEPARATORS.forEach(char => array.push(formatString.replace(/ /g, char)));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return array;
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
const getFormatData = ({
|
|
24
|
+
code
|
|
25
|
+
}) => {
|
|
26
|
+
if (["en-CA", "en-US"].includes(code)) {
|
|
27
|
+
return {
|
|
28
|
+
format: "MM/dd/yyyy",
|
|
29
|
+
formats: generateFormats(NA_FORMATS)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (code === "de") {
|
|
34
|
+
return {
|
|
35
|
+
format: "dd.MM.yyyy",
|
|
36
|
+
formats: generateFormats(EU_FORMATS)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
format: "dd/MM/yyyy",
|
|
42
|
+
formats: generateFormats(EU_FORMATS)
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var _default = getFormatData;
|
|
47
|
+
exports.default = _default;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _reactDayPicker = _interopRequireDefault(require("react-day-picker"));
|
|
13
|
+
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
|
|
16
|
+
var _popover = _interopRequireDefault(require("../../../../__internal__/popover"));
|
|
17
|
+
|
|
18
|
+
var _useLocale = _interopRequireDefault(require("../../../../hooks/__internal__/useLocale"));
|
|
19
|
+
|
|
20
|
+
var _navbar = _interopRequireDefault(require("../navbar"));
|
|
21
|
+
|
|
22
|
+
var _weekday = _interopRequireDefault(require("../weekday"));
|
|
23
|
+
|
|
24
|
+
var _dayPicker = _interopRequireDefault(require("./day-picker.style"));
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
31
|
+
|
|
32
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
33
|
+
|
|
34
|
+
const DatePicker = /*#__PURE__*/_react.default.forwardRef(({
|
|
35
|
+
inputElement,
|
|
36
|
+
minDate,
|
|
37
|
+
maxDate,
|
|
38
|
+
selectedDays,
|
|
39
|
+
disablePortal,
|
|
40
|
+
onDayClick,
|
|
41
|
+
pickerMouseDown,
|
|
42
|
+
pickerProps
|
|
43
|
+
}, ref) => {
|
|
44
|
+
const l = (0, _useLocale.default)();
|
|
45
|
+
const {
|
|
46
|
+
localize,
|
|
47
|
+
options
|
|
48
|
+
} = l.date.dateFnsLocale();
|
|
49
|
+
const {
|
|
50
|
+
weekStartsOn
|
|
51
|
+
} = options;
|
|
52
|
+
const monthsLong = Array.from({
|
|
53
|
+
length: 12
|
|
54
|
+
}).map((_, i) => localize.month(i));
|
|
55
|
+
const monthsShort = Array.from({
|
|
56
|
+
length: 12
|
|
57
|
+
}).map((_, i) => localize.month(i, {
|
|
58
|
+
width: "abbreviated"
|
|
59
|
+
}).substring(0, 3));
|
|
60
|
+
const weekdaysLong = Array.from({
|
|
61
|
+
length: 7
|
|
62
|
+
}).map((_, i) => localize.day(i));
|
|
63
|
+
const weekdaysShort = Array.from({
|
|
64
|
+
length: 7
|
|
65
|
+
}).map((_, i) => localize.day(i, l.locale() === "de" ? {} : {
|
|
66
|
+
width: "abbreviated"
|
|
67
|
+
}).substring(0, 3));
|
|
68
|
+
const popoverModifiers = (0, _react.useMemo)(() => [{
|
|
69
|
+
name: "offset",
|
|
70
|
+
options: {
|
|
71
|
+
offset: [0, 3]
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
name: "preventOverflow",
|
|
75
|
+
options: {
|
|
76
|
+
mainAxis: false
|
|
77
|
+
}
|
|
78
|
+
}], []);
|
|
79
|
+
|
|
80
|
+
const handleDayClick = (date, {
|
|
81
|
+
disabled
|
|
82
|
+
}, ev) => {
|
|
83
|
+
if (!disabled) {
|
|
84
|
+
onDayClick(date, ev);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const formatDay = date => `${weekdaysShort[date.getDay()]} ${date.getDate()} ${monthsShort[date.getMonth()]} ${date.getFullYear()}`;
|
|
89
|
+
|
|
90
|
+
return /*#__PURE__*/_react.default.createElement(_popover.default, {
|
|
91
|
+
placement: "bottom-start",
|
|
92
|
+
reference: inputElement,
|
|
93
|
+
modifiers: popoverModifiers,
|
|
94
|
+
disablePortal: disablePortal
|
|
95
|
+
}, /*#__PURE__*/_react.default.createElement(_dayPicker.default, {
|
|
96
|
+
ref: ref,
|
|
97
|
+
onMouseDown: pickerMouseDown
|
|
98
|
+
}, /*#__PURE__*/_react.default.createElement(_reactDayPicker.default, _extends({
|
|
99
|
+
month: selectedDays,
|
|
100
|
+
months: monthsLong,
|
|
101
|
+
firstDayOfWeek: weekStartsOn,
|
|
102
|
+
onDayClick: handleDayClick,
|
|
103
|
+
selectedDays: selectedDays,
|
|
104
|
+
date: selectedDays,
|
|
105
|
+
weekdayElement: weekdayElementProps => {
|
|
106
|
+
const {
|
|
107
|
+
className,
|
|
108
|
+
weekday
|
|
109
|
+
} = weekdayElementProps;
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement(_weekday.default, {
|
|
111
|
+
className: className,
|
|
112
|
+
title: weekdaysLong[weekday]
|
|
113
|
+
}, weekdaysShort[weekday]);
|
|
114
|
+
},
|
|
115
|
+
navbarElement: /*#__PURE__*/_react.default.createElement(_navbar.default, null),
|
|
116
|
+
enableOutsideDays: true,
|
|
117
|
+
fixedWeeks: true,
|
|
118
|
+
initialMonth: selectedDays || undefined,
|
|
119
|
+
disabledDays: (0, _utils.getDisabledDays)(minDate, maxDate),
|
|
120
|
+
inline: true,
|
|
121
|
+
locale: l.locale(),
|
|
122
|
+
localeUtils: {
|
|
123
|
+
formatDay
|
|
124
|
+
}
|
|
125
|
+
}, pickerProps))));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
DatePicker.propTypes = {
|
|
129
|
+
/** Minimum possible date */
|
|
130
|
+
minDate: _propTypes.default.string,
|
|
131
|
+
|
|
132
|
+
/** Maximum possible date */
|
|
133
|
+
maxDate: _propTypes.default.string,
|
|
134
|
+
|
|
135
|
+
/** Boolean to toggle where DatePicker is rendered in relation to the Date Input */
|
|
136
|
+
disablePortal: _propTypes.default.bool,
|
|
137
|
+
|
|
138
|
+
/** Element that the DatePicker will be displayed under */
|
|
139
|
+
inputElement: _propTypes.default.object.isRequired,
|
|
140
|
+
|
|
141
|
+
/** Currently selected date */
|
|
142
|
+
selectedDays: _propTypes.default.instanceOf(Date),
|
|
143
|
+
|
|
144
|
+
/** Callback to set selected date */
|
|
145
|
+
onDayClick: _propTypes.default.func,
|
|
146
|
+
|
|
147
|
+
/** Pass any props that match the DayPickerProps interface to override default behaviors */
|
|
148
|
+
pickerProps: _propTypes.default.object,
|
|
149
|
+
|
|
150
|
+
/** Callback to handle mousedown event on picker */
|
|
151
|
+
pickerMouseDown: _propTypes.default.func
|
|
152
|
+
};
|
|
153
|
+
var _default = DatePicker;
|
|
154
|
+
exports.default = _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DayPickerProps } from "react-day-picker";
|
|
3
|
+
|
|
4
|
+
export interface DatePickerProps extends Pick<DayPickerProps, "onDayClick"> {
|
|
5
|
+
/** Boolean to toggle where DatePicker is rendered in relation to the Date Input */
|
|
6
|
+
disablePortal?: boolean;
|
|
7
|
+
/** Minimum possible date YYYY-MM-DD */
|
|
8
|
+
minDate?: string;
|
|
9
|
+
/** Maximum possible date YYYY-MM-DD */
|
|
10
|
+
maxDate?: string;
|
|
11
|
+
/** Pass any props that match the DayPickerProps interface to override default behaviors */
|
|
12
|
+
pickerProps?: DayPickerProps;
|
|
13
|
+
/** Element that the DatePicker will be displayed under */
|
|
14
|
+
inputElement: React.RefObject<HTMLElement>;
|
|
15
|
+
/** Currently selected date */
|
|
16
|
+
selectedDays?: Date;
|
|
17
|
+
/** Callback to handle mousedown event on picker container */
|
|
18
|
+
pickerMouseDown?: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare function DatePicker(
|
|
22
|
+
props: DatePickerProps & React.RefAttributes<HTMLElement>
|
|
23
|
+
): JSX.Element;
|
|
24
|
+
|
|
25
|
+
export default DatePicker;
|
package/lib/components/date/{day-picker.style.d.ts → __internal__/date-picker/day-picker.style.d.ts}
RENAMED
|
File without changes
|
package/lib/components/date/{day-picker.style.js → __internal__/date-picker/day-picker.style.js}
RENAMED
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _base = _interopRequireDefault(require("
|
|
10
|
+
var _base = _interopRequireDefault(require("../../../../style/themes/base"));
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
@@ -81,6 +81,10 @@ const addReactDayPickerStyles = () => `
|
|
|
81
81
|
|
|
82
82
|
.DayPicker-Weekday {
|
|
83
83
|
display: table-cell;
|
|
84
|
+
|
|
85
|
+
abbr {
|
|
86
|
+
text-decoration: none;
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
.DayPicker-Body {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./date-picker.component";
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "default", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _datePicker.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _datePicker = _interopRequireDefault(require("./date-picker.component"));
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
File without changes
|
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _base = _interopRequireDefault(require("
|
|
10
|
+
var _base = _interopRequireDefault(require("../../../../style/themes/base"));
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -13,7 +13,7 @@ var _button = _interopRequireDefault(require("./button.style"));
|
|
|
13
13
|
|
|
14
14
|
var _navbar = _interopRequireDefault(require("./navbar.style"));
|
|
15
15
|
|
|
16
|
-
var _icon = _interopRequireDefault(require("
|
|
16
|
+
var _icon = _interopRequireDefault(require("../../../icon"));
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
@@ -21,17 +21,15 @@ const Navbar = ({
|
|
|
21
21
|
onPreviousClick,
|
|
22
22
|
onNextClick,
|
|
23
23
|
...props
|
|
24
|
-
}) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})));
|
|
34
|
-
};
|
|
24
|
+
}) => /*#__PURE__*/_react.default.createElement(_navbar.default, props, /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
25
|
+
onClick: () => onPreviousClick()
|
|
26
|
+
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
27
|
+
type: "chevron_left"
|
|
28
|
+
})), /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
29
|
+
onClick: () => onNextClick()
|
|
30
|
+
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
31
|
+
type: "chevron_right"
|
|
32
|
+
})));
|
|
35
33
|
|
|
36
34
|
Navbar.propTypes = {
|
|
37
35
|
onPreviousClick: _propTypes.default.func,
|
|
File without changes
|
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _base = _interopRequireDefault(require("
|
|
10
|
+
var _base = _interopRequireDefault(require("../../../../style/themes/base"));
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function parseDate(formatString: any, valueString: any): "" | Date;
|
|
2
|
+
export function formatToISO(formatString: any, valueString: any): string | null;
|
|
3
|
+
export function formattedValue(formatString: any, value: any): string;
|
|
4
|
+
export function isDateValid(date: any): any;
|
|
5
|
+
export function additionalYears(formatString: any, value: any): any[];
|
|
6
|
+
export function findMatchedFormatAndValue(valueString: any, formats: any): any;
|
|
7
|
+
export function parseISODate(value: any): Date;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the disabled array of days specified by props maxDate and minDate
|
|
10
|
+
*/
|
|
11
|
+
export function getDisabledDays(minDate: any, maxDate: any): ({
|
|
12
|
+
before: Date;
|
|
13
|
+
after?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
after: Date;
|
|
16
|
+
before?: undefined;
|
|
17
|
+
})[] | null;
|
|
18
|
+
export function checkISOFormatAndLength(value: any): boolean;
|
|
19
|
+
export function getSeparator(value: any): string;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseDate = parseDate;
|
|
7
|
+
exports.formatToISO = formatToISO;
|
|
8
|
+
exports.formattedValue = formattedValue;
|
|
9
|
+
exports.isDateValid = isDateValid;
|
|
10
|
+
exports.additionalYears = additionalYears;
|
|
11
|
+
exports.findMatchedFormatAndValue = findMatchedFormatAndValue;
|
|
12
|
+
exports.parseISODate = parseISODate;
|
|
13
|
+
exports.getDisabledDays = getDisabledDays;
|
|
14
|
+
exports.checkISOFormatAndLength = checkISOFormatAndLength;
|
|
15
|
+
exports.getSeparator = void 0;
|
|
16
|
+
|
|
17
|
+
var _fp = require("date-fns/fp");
|
|
18
|
+
|
|
19
|
+
function parseDate(formatString, valueString) {
|
|
20
|
+
if (!valueString || !formatString) return "";
|
|
21
|
+
return (0, _fp.parse)(new Date(), formatString, valueString);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function formatToISO(formatString, valueString) {
|
|
25
|
+
const dateValue = parseDate(formatString, valueString);
|
|
26
|
+
|
|
27
|
+
if (!isDateValid(dateValue)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (0, _fp.formatISO)(dateValue).split("T")[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function formattedValue(formatString, value) {
|
|
35
|
+
return (0, _fp.format)(formatString, value);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function isDateValid(date) {
|
|
39
|
+
return date && date.toString() !== "Invalid Date";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function hasMatchedFormat(formatString, valueString) {
|
|
43
|
+
return formatString.length === valueString.length && (0, _fp.isMatch)(formatString, valueString);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function additionalYears(formatString, value) {
|
|
47
|
+
if (formatString.split("y").length - 1 !== 2) {
|
|
48
|
+
return [formatString, value];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let year = value.substring(value.length - 2);
|
|
52
|
+
const dayAndMonth = value.substring(0, value.length - 2);
|
|
53
|
+
const yearAsNumber = Number(year);
|
|
54
|
+
|
|
55
|
+
if (yearAsNumber < 69) {
|
|
56
|
+
year = String(2000 + yearAsNumber);
|
|
57
|
+
} else {
|
|
58
|
+
year = String(1900 + yearAsNumber);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return [`${formatString.substring(0, formatString.length - 2)}yyyy`, `${dayAndMonth}${year}`];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function makeSeparatedValues(arr, str) {
|
|
65
|
+
return arr.map((_, i) => str.substring(arr[i], arr[i + 1]));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function checkForCompleteMatch(formatArray, valueArray) {
|
|
69
|
+
return formatArray.every((formatString, i) => hasMatchedFormat(formatString, valueArray[i]));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function findMatchWithNoSeparators(valueString, formatString) {
|
|
73
|
+
const indexArray = formatString.split("").reduce((arr, char, index) => {
|
|
74
|
+
if (index === 0 || char !== formatString[index - 1]) {
|
|
75
|
+
return [...arr, index];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return arr;
|
|
79
|
+
}, []);
|
|
80
|
+
const formatArray = makeSeparatedValues(indexArray, formatString);
|
|
81
|
+
const valueArray = makeSeparatedValues(indexArray, valueString);
|
|
82
|
+
|
|
83
|
+
if (checkForCompleteMatch(formatArray, valueArray)) {
|
|
84
|
+
return [formatArray.join("."), valueArray.join(".")];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function findMatchWithSeparators(valueString, formatString, separator) {
|
|
91
|
+
const formatArray = formatString.split(separator);
|
|
92
|
+
const valueArray = valueString.split(separator);
|
|
93
|
+
|
|
94
|
+
if (checkForCompleteMatch(formatArray, valueArray)) {
|
|
95
|
+
return [formatString, valueString];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const getSeparator = value => {
|
|
102
|
+
const separator = ["", ".", ",", "-", "/", " ", ":"].slice(1).find(char => value.includes(char));
|
|
103
|
+
return separator || "";
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
exports.getSeparator = getSeparator;
|
|
107
|
+
|
|
108
|
+
function findMatchedFormatAndValue(valueString, formats) {
|
|
109
|
+
if (!valueString) {
|
|
110
|
+
return ["", ""];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const valueSeparator = getSeparator(valueString);
|
|
114
|
+
const filteredFormats = formats.filter(formatString => formatString.length === valueString.length && getSeparator(formatString) === valueSeparator);
|
|
115
|
+
const matchedFormatAndValue = filteredFormats.reduce((acc, formatString) => {
|
|
116
|
+
const formatSeparator = getSeparator(formatString);
|
|
117
|
+
|
|
118
|
+
if (valueSeparator === "" && formatSeparator === "") {
|
|
119
|
+
// This check is added as there is a bug in date-fns https://github.com/date-fns/date-fns/issues/2785
|
|
120
|
+
// it incorrectly matches or fails to parse valid dates with no separators
|
|
121
|
+
const match = findMatchWithNoSeparators(valueString, formatString);
|
|
122
|
+
|
|
123
|
+
if (match) {
|
|
124
|
+
return match;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (valueSeparator && formatSeparator && valueSeparator === formatSeparator) {
|
|
129
|
+
const match = findMatchWithSeparators(valueString, formatString, valueSeparator);
|
|
130
|
+
|
|
131
|
+
if (match) {
|
|
132
|
+
return match;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return acc;
|
|
137
|
+
}, []);
|
|
138
|
+
return matchedFormatAndValue;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function parseISODate(value) {
|
|
142
|
+
return (0, _fp.parseISO)(value);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Returns the disabled array of days specified by props maxDate and minDate
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
function getDisabledDays(minDate, maxDate) {
|
|
150
|
+
const days = [];
|
|
151
|
+
|
|
152
|
+
if (!minDate && !maxDate) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (checkISOFormatAndLength(minDate)) {
|
|
157
|
+
days.push({
|
|
158
|
+
before: parseISODate(minDate)
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (checkISOFormatAndLength(maxDate)) {
|
|
163
|
+
days.push({
|
|
164
|
+
after: parseISODate(maxDate)
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return days;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function checkISOFormatAndLength(value) {
|
|
172
|
+
if (!value || value.length !== 10 || !isValidISODate(value)) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const array = value.split("-");
|
|
177
|
+
return array.length === 3 && array[0].length === 4 && array[1].length === 2 && array[2].length === 2;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function isValidISODate(dateString) {
|
|
181
|
+
return parseISODate(dateString).toString() !== "Invalid Date";
|
|
182
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
export interface WeekdayProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare function Weekday(
|
|
10
|
+
props: WeekdayProps & React.RefAttributes<HTMLElement>
|
|
11
|
+
): JSX.Element;
|
|
12
|
+
|
|
13
|
+
export default Weekday;
|
|
File without changes
|