carbon-react 103.2.0 → 104.2.0
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/__internal__/tooltip-provider/index.d.ts +1 -0
- package/lib/__internal__/tooltip-provider/index.js +6 -3
- package/lib/components/button/button.component.d.ts +21 -1
- package/lib/components/button/button.component.js +63 -52
- 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/icon/icon.component.js +4 -2
- package/lib/components/icon-button/icon-button.component.js +11 -19
- 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 +7 -7
- package/lib/components/tooltip/tooltip.d.ts +1 -0
- 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
|
@@ -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
|
|
@@ -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
|
|
|
@@ -1,57 +1,29 @@
|
|
|
1
1
|
export default DateInput;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
updateValidEventValues: (value: any) => void;
|
|
30
|
-
reformatVisibleDate: () => void;
|
|
31
|
-
closeDatePicker: () => void;
|
|
32
|
-
handleClick: (event: any) => void;
|
|
33
|
-
handleDateSelect: (selectedDate: any) => void;
|
|
34
|
-
updateVisibleValue: (date: any) => void;
|
|
35
|
-
focusInput: () => void;
|
|
36
|
-
handleVisibleInputChange: (ev: any) => void;
|
|
37
|
-
updateSelectedDate: (newValue: any) => void;
|
|
38
|
-
getDateObject: (newValue: any) => any;
|
|
39
|
-
emitOnChangeCallback: (ev: any, isoFormattedValue: any) => void;
|
|
40
|
-
canBeEmptyValues: (value: any) => any;
|
|
41
|
-
buildCustomEvent: (ev: any, isoFormattedValue: any) => any;
|
|
42
|
-
renderDatePicker: (dateRangeProps: any) => JSX.Element | null;
|
|
43
|
-
markCurrentDatepicker: () => void;
|
|
44
|
-
hiddenValue: () => any;
|
|
45
|
-
renderHiddenInput: () => JSX.Element;
|
|
2
|
+
declare function DateInput({ adaptiveLabelBreakpoint, allowEmptyValue, autoFocus, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, disabled, disablePortal, helpAriaLabel, labelInline, minDate, maxDate, onBlur, onChange, onClick, onFocus, onKeyDown, pickerProps, readOnly, size, tooltipPosition, value, ...rest }: {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
adaptiveLabelBreakpoint: any;
|
|
5
|
+
allowEmptyValue: any;
|
|
6
|
+
autoFocus: any;
|
|
7
|
+
"data-component": any;
|
|
8
|
+
"data-element": any;
|
|
9
|
+
"data-role": any;
|
|
10
|
+
disabled: any;
|
|
11
|
+
disablePortal?: boolean | undefined;
|
|
12
|
+
helpAriaLabel: any;
|
|
13
|
+
labelInline: any;
|
|
14
|
+
minDate: any;
|
|
15
|
+
maxDate: any;
|
|
16
|
+
onBlur: any;
|
|
17
|
+
onChange: any;
|
|
18
|
+
onClick: any;
|
|
19
|
+
onFocus: any;
|
|
20
|
+
onKeyDown: any;
|
|
21
|
+
pickerProps?: {} | undefined;
|
|
22
|
+
readOnly: any;
|
|
23
|
+
size?: string | undefined;
|
|
24
|
+
tooltipPosition: any;
|
|
25
|
+
value: any;
|
|
26
|
+
}): JSX.Element;
|
|
27
|
+
declare namespace DateInput {
|
|
28
|
+
const propTypes: any;
|
|
46
29
|
}
|
|
47
|
-
export namespace BaseDateInput {
|
|
48
|
-
export { LocaleContext as contextType };
|
|
49
|
-
export const propTypes: any;
|
|
50
|
-
export const defaultProps: {
|
|
51
|
-
disablePortal: boolean;
|
|
52
|
-
"data-component": string;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
declare const DateInput: JSX.Element;
|
|
56
|
-
import React from "react";
|
|
57
|
-
import LocaleContext from "../../__internal__/i18n-context";
|