@carbon/react 1.97.0 → 1.98.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +974 -939
- package/es/components/ButtonSet/ButtonSet.d.ts +5 -0
- package/es/components/ButtonSet/ButtonSet.js +68 -4
- package/es/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/es/components/Copy/Copy.d.ts +1 -1
- package/es/components/CopyButton/CopyButton.d.ts +1 -1
- package/es/components/DataTable/DataTable.d.ts +2 -1
- package/es/components/DataTable/TableContainer.d.ts +10 -2
- package/es/components/DataTable/TableContainer.js +15 -3
- package/es/components/DataTable/state/sorting.d.ts +2 -4
- package/es/components/DatePicker/DatePicker.d.ts +3 -2
- package/es/components/DatePicker/DatePicker.js +18 -135
- package/es/components/DatePicker/DatePickerLocales.d.ts +12 -0
- package/es/components/DatePicker/DatePickerLocales.js +135 -0
- package/es/components/DatePickerInput/DatePickerInput.js +50 -28
- package/es/components/Dropdown/Dropdown.js +9 -1
- package/es/components/FileUploader/FileUploader.d.ts +23 -8
- package/es/components/FileUploader/FileUploader.js +53 -33
- package/es/components/FileUploader/FileUploaderButton.js +2 -2
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +13 -2
- package/es/components/FileUploader/FileUploaderDropContainer.js +15 -6
- package/es/components/FileUploader/FileUploaderItem.js +9 -6
- package/es/components/Menu/index.d.ts +4 -3
- package/es/components/Pagination/Pagination.js +5 -5
- package/es/components/Select/Select.js +27 -33
- package/es/components/Toggletip/index.d.ts +1 -0
- package/es/components/Toggletip/index.js +1 -1
- package/es/components/Tooltip/index.d.ts +3 -2
- package/es/internal/FloatingMenu.js +6 -5
- package/es/internal/OptimizedResize.js +4 -5
- package/es/tools/events.d.ts +1 -1
- package/lib/components/ButtonSet/ButtonSet.d.ts +5 -0
- package/lib/components/ButtonSet/ButtonSet.js +67 -3
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/lib/components/Copy/Copy.d.ts +1 -1
- package/lib/components/CopyButton/CopyButton.d.ts +1 -1
- package/lib/components/DataTable/DataTable.d.ts +2 -1
- package/lib/components/DataTable/TableContainer.d.ts +10 -2
- package/lib/components/DataTable/TableContainer.js +15 -3
- package/lib/components/DataTable/state/sorting.d.ts +2 -4
- package/lib/components/DatePicker/DatePicker.d.ts +3 -2
- package/lib/components/DatePicker/DatePicker.js +18 -135
- package/lib/components/DatePicker/DatePickerLocales.d.ts +12 -0
- package/lib/components/DatePicker/DatePickerLocales.js +137 -0
- package/lib/components/DatePickerInput/DatePickerInput.js +49 -27
- package/lib/components/Dropdown/Dropdown.js +9 -1
- package/lib/components/FileUploader/FileUploader.d.ts +23 -8
- package/lib/components/FileUploader/FileUploader.js +53 -33
- package/lib/components/FileUploader/FileUploaderButton.js +2 -2
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +13 -2
- package/lib/components/FileUploader/FileUploaderDropContainer.js +15 -6
- package/lib/components/FileUploader/FileUploaderItem.js +9 -6
- package/lib/components/Menu/index.d.ts +4 -3
- package/lib/components/Pagination/Pagination.js +5 -5
- package/lib/components/Select/Select.js +27 -33
- package/lib/components/Toggletip/index.d.ts +1 -0
- package/lib/components/Toggletip/index.js +3 -0
- package/lib/components/Tooltip/index.d.ts +3 -2
- package/lib/internal/FloatingMenu.js +6 -5
- package/lib/internal/OptimizedResize.js +4 -5
- package/lib/tools/events.d.ts +1 -1
- package/package.json +19 -26
- package/telemetry.yml +2 -0
|
@@ -28,6 +28,7 @@ require('../FluidForm/FluidForm.js');
|
|
|
28
28
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
29
29
|
var iconsReact = require('@carbon/icons-react');
|
|
30
30
|
var utilities = require('@carbon/utilities');
|
|
31
|
+
var DatePickerLocales = require('./DatePickerLocales.js');
|
|
31
32
|
|
|
32
33
|
// Weekdays shorthand for English locale
|
|
33
34
|
// Ensure localization exists before trying to access it
|
|
@@ -366,7 +367,6 @@ const DatePicker = /*#__PURE__*/React.forwardRef(function DatePicker({
|
|
|
366
367
|
const {
|
|
367
368
|
current: end
|
|
368
369
|
} = endInputField;
|
|
369
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
370
370
|
const flatpickerConfig = {
|
|
371
371
|
inline: inline ?? false,
|
|
372
372
|
onClose: onCalendarClose,
|
|
@@ -515,12 +515,11 @@ const DatePicker = /*#__PURE__*/React.forwardRef(function DatePicker({
|
|
|
515
515
|
|
|
516
516
|
// prevent a duplicate date selection when a default value is set
|
|
517
517
|
if (value) {
|
|
518
|
-
if (
|
|
519
|
-
|
|
518
|
+
if (start) {
|
|
519
|
+
start.value = '';
|
|
520
520
|
}
|
|
521
|
-
if (
|
|
522
|
-
|
|
523
|
-
endInputField.current.value = '';
|
|
521
|
+
if (end) {
|
|
522
|
+
end.value = '';
|
|
524
523
|
}
|
|
525
524
|
}
|
|
526
525
|
if (start) {
|
|
@@ -600,8 +599,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef(function DatePicker({
|
|
|
600
599
|
endInputField.current.value = '';
|
|
601
600
|
}
|
|
602
601
|
}
|
|
603
|
-
|
|
604
|
-
}, [value]);
|
|
602
|
+
}, [value, startInputField]);
|
|
605
603
|
React.useEffect(() => {
|
|
606
604
|
const handleMouseDown = event => {
|
|
607
605
|
if (calendarRef.current && calendarRef.current.isOpen && !calendarRef.current.calendarContainer.contains(event.target) && !startInputField.current.contains(event.target) && !endInputField.current?.contains(event.target)) {
|
|
@@ -609,8 +607,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef(function DatePicker({
|
|
|
609
607
|
closeCalendar();
|
|
610
608
|
}
|
|
611
609
|
};
|
|
612
|
-
|
|
613
|
-
const closeCalendar = event => {
|
|
610
|
+
const closeCalendar = () => {
|
|
614
611
|
calendarRef.current?.close();
|
|
615
612
|
// Remove focus from endDate calendar input
|
|
616
613
|
onCalendarClose(calendarRef.current?.selectedDates, '', calendarRef.current, {
|
|
@@ -625,15 +622,22 @@ const DatePicker = /*#__PURE__*/React.forwardRef(function DatePicker({
|
|
|
625
622
|
React.useEffect(() => {
|
|
626
623
|
if (calendarRef.current?.set) {
|
|
627
624
|
if (value !== undefined) {
|
|
628
|
-
calendarRef.current.setDate
|
|
625
|
+
// To make up for calendarRef.current.setDate not making provision for an empty string or array
|
|
626
|
+
if (value === '' || value === null || Array.isArray(value) && (value.length === 0 || value.every(element => !element))) {
|
|
627
|
+
// only clear if there are selected dates to avoid unnecessary operations
|
|
628
|
+
if (calendarRef.current.selectedDates.length > 0) {
|
|
629
|
+
calendarRef.current.clear();
|
|
630
|
+
}
|
|
631
|
+
} else {
|
|
632
|
+
calendarRef.current.setDate(value);
|
|
633
|
+
}
|
|
629
634
|
}
|
|
630
635
|
updateClassNames(calendarRef.current, prefix);
|
|
631
636
|
//for simple date picker w/o calendar; initial mount may not have value
|
|
632
637
|
} else if (!calendarRef.current && value) {
|
|
633
638
|
startInputField.current.value = value;
|
|
634
639
|
}
|
|
635
|
-
}, [value, prefix]);
|
|
636
|
-
|
|
640
|
+
}, [value, prefix, startInputField]);
|
|
637
641
|
let fluidError;
|
|
638
642
|
if (isFluid) {
|
|
639
643
|
if (invalid) {
|
|
@@ -722,128 +726,7 @@ DatePicker.propTypes = {
|
|
|
722
726
|
/**
|
|
723
727
|
* The language locale used to format the days of the week, months, and numbers. The full list of supported locales can be found here https://github.com/flatpickr/flatpickr/tree/master/src/l10n
|
|
724
728
|
*/
|
|
725
|
-
locale: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(
|
|
726
|
-
// Arabic
|
|
727
|
-
'at',
|
|
728
|
-
// Austria
|
|
729
|
-
'az',
|
|
730
|
-
// Azerbaijan
|
|
731
|
-
'be',
|
|
732
|
-
// Belarusian
|
|
733
|
-
'bg',
|
|
734
|
-
// Bulgarian
|
|
735
|
-
'bn',
|
|
736
|
-
// Bangla
|
|
737
|
-
'bs',
|
|
738
|
-
// Bosnia
|
|
739
|
-
'cat',
|
|
740
|
-
// Catalan
|
|
741
|
-
'cs',
|
|
742
|
-
// Czech
|
|
743
|
-
'cy',
|
|
744
|
-
// Welsh
|
|
745
|
-
'da',
|
|
746
|
-
// Danish
|
|
747
|
-
'de',
|
|
748
|
-
// German
|
|
749
|
-
'en',
|
|
750
|
-
// English
|
|
751
|
-
'eo',
|
|
752
|
-
// Esperanto
|
|
753
|
-
'es',
|
|
754
|
-
// Spanish
|
|
755
|
-
'et',
|
|
756
|
-
// Estonian
|
|
757
|
-
'fa',
|
|
758
|
-
// Persian
|
|
759
|
-
'fi',
|
|
760
|
-
// Finnish
|
|
761
|
-
'fo',
|
|
762
|
-
// Faroese
|
|
763
|
-
'fr',
|
|
764
|
-
// French
|
|
765
|
-
'ga',
|
|
766
|
-
// Gaelic
|
|
767
|
-
'gr',
|
|
768
|
-
// Greek
|
|
769
|
-
'he',
|
|
770
|
-
// Hebrew
|
|
771
|
-
'hi',
|
|
772
|
-
// Hindi
|
|
773
|
-
'hr',
|
|
774
|
-
// Croatian
|
|
775
|
-
'hu',
|
|
776
|
-
// Hungarian
|
|
777
|
-
'id',
|
|
778
|
-
// Indonesian
|
|
779
|
-
'is',
|
|
780
|
-
// Icelandic
|
|
781
|
-
'it',
|
|
782
|
-
// Italian
|
|
783
|
-
'ja',
|
|
784
|
-
// Japanese
|
|
785
|
-
'ka',
|
|
786
|
-
// Georgian
|
|
787
|
-
'km',
|
|
788
|
-
// Khmer
|
|
789
|
-
'ko',
|
|
790
|
-
// Korean
|
|
791
|
-
'kz',
|
|
792
|
-
// Kazakh
|
|
793
|
-
'lt',
|
|
794
|
-
// Lithuanian
|
|
795
|
-
'lv',
|
|
796
|
-
// Latvian
|
|
797
|
-
'mk',
|
|
798
|
-
// Macedonian
|
|
799
|
-
'mn',
|
|
800
|
-
// Mongolian
|
|
801
|
-
'ms',
|
|
802
|
-
// Malaysian
|
|
803
|
-
'my',
|
|
804
|
-
// Burmese
|
|
805
|
-
'nl',
|
|
806
|
-
// Dutch
|
|
807
|
-
'no',
|
|
808
|
-
// Norwegian
|
|
809
|
-
'pa',
|
|
810
|
-
// Punjabi
|
|
811
|
-
'pl',
|
|
812
|
-
// Polish
|
|
813
|
-
'pt',
|
|
814
|
-
// Portuguese
|
|
815
|
-
'ro',
|
|
816
|
-
// Romanian
|
|
817
|
-
'ru',
|
|
818
|
-
// Russian
|
|
819
|
-
'si',
|
|
820
|
-
// Sinhala
|
|
821
|
-
'sk',
|
|
822
|
-
// Slovak
|
|
823
|
-
'sl',
|
|
824
|
-
// Slovenian
|
|
825
|
-
'sq',
|
|
826
|
-
// Albanian
|
|
827
|
-
'sr',
|
|
828
|
-
// Serbian
|
|
829
|
-
'sv',
|
|
830
|
-
// Swedish
|
|
831
|
-
'th',
|
|
832
|
-
// Thai
|
|
833
|
-
'tr',
|
|
834
|
-
// Turkish
|
|
835
|
-
'uk',
|
|
836
|
-
// Ukrainian
|
|
837
|
-
'uz',
|
|
838
|
-
// Uzbek
|
|
839
|
-
'uz_latn',
|
|
840
|
-
// Uzbek Latin
|
|
841
|
-
'vn',
|
|
842
|
-
// Vietnamese
|
|
843
|
-
'zh_tw',
|
|
844
|
-
// Mandarin Traditional
|
|
845
|
-
'zh' // Mandarin
|
|
846
|
-
])]),
|
|
729
|
+
locale: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(DatePickerLocales.SUPPORTED_LOCALES)]),
|
|
847
730
|
/**
|
|
848
731
|
* The maximum date that a user can pick to.
|
|
849
732
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The full list of supported locales can be found here:
|
|
9
|
+
* https://github.com/flatpickr/flatpickr/tree/master/src/l10n
|
|
10
|
+
*/
|
|
11
|
+
export declare const SUPPORTED_LOCALES: readonly ["ar", "at", "az", "be", "bg", "bn", "bs", "cat", "cs", "cy", "da", "de", "en", "eo", "es", "et", "fa", "fi", "fo", "fr", "ga", "gr", "he", "hi", "hr", "hu", "id", "is", "it", "ja", "ka", "km", "ko", "kz", "lt", "lv", "mk", "mn", "ms", "my", "nl", "no", "pa", "pl", "pt", "ro", "ru", "si", "sk", "sl", "sq", "sr", "sv", "th", "tr", "uk", "uz", "uz_latn", "vn", "zh_tw", "zh"];
|
|
12
|
+
export type SupportedLocale = (typeof SUPPORTED_LOCALES)[number];
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The full list of supported locales can be found here:
|
|
12
|
+
* https://github.com/flatpickr/flatpickr/tree/master/src/l10n
|
|
13
|
+
*/
|
|
14
|
+
const SUPPORTED_LOCALES = ['ar',
|
|
15
|
+
// Arabic
|
|
16
|
+
'at',
|
|
17
|
+
// Austria
|
|
18
|
+
'az',
|
|
19
|
+
// Azerbaijan
|
|
20
|
+
'be',
|
|
21
|
+
// Belarusian
|
|
22
|
+
'bg',
|
|
23
|
+
// Bulgarian
|
|
24
|
+
'bn',
|
|
25
|
+
// Bangla
|
|
26
|
+
'bs',
|
|
27
|
+
// Bosnia
|
|
28
|
+
'cat',
|
|
29
|
+
// Catalan
|
|
30
|
+
'cs',
|
|
31
|
+
// Czech
|
|
32
|
+
'cy',
|
|
33
|
+
// Welsh
|
|
34
|
+
'da',
|
|
35
|
+
// Danish
|
|
36
|
+
'de',
|
|
37
|
+
// German
|
|
38
|
+
'en',
|
|
39
|
+
// English
|
|
40
|
+
'eo',
|
|
41
|
+
// Esperanto
|
|
42
|
+
'es',
|
|
43
|
+
// Spanish
|
|
44
|
+
'et',
|
|
45
|
+
// Estonian
|
|
46
|
+
'fa',
|
|
47
|
+
// Persian
|
|
48
|
+
'fi',
|
|
49
|
+
// Finnish
|
|
50
|
+
'fo',
|
|
51
|
+
// Faroese
|
|
52
|
+
'fr',
|
|
53
|
+
// French
|
|
54
|
+
'ga',
|
|
55
|
+
// Gaelic
|
|
56
|
+
'gr',
|
|
57
|
+
// Greek
|
|
58
|
+
'he',
|
|
59
|
+
// Hebrew
|
|
60
|
+
'hi',
|
|
61
|
+
// Hindi
|
|
62
|
+
'hr',
|
|
63
|
+
// Croatian
|
|
64
|
+
'hu',
|
|
65
|
+
// Hungarian
|
|
66
|
+
'id',
|
|
67
|
+
// Indonesian
|
|
68
|
+
'is',
|
|
69
|
+
// Icelandic
|
|
70
|
+
'it',
|
|
71
|
+
// Italian
|
|
72
|
+
'ja',
|
|
73
|
+
// Japanese
|
|
74
|
+
'ka',
|
|
75
|
+
// Georgian
|
|
76
|
+
'km',
|
|
77
|
+
// Khmer
|
|
78
|
+
'ko',
|
|
79
|
+
// Korean
|
|
80
|
+
'kz',
|
|
81
|
+
// Kazakh
|
|
82
|
+
'lt',
|
|
83
|
+
// Lithuanian
|
|
84
|
+
'lv',
|
|
85
|
+
// Latvian
|
|
86
|
+
'mk',
|
|
87
|
+
// Macedonian
|
|
88
|
+
'mn',
|
|
89
|
+
// Mongolian
|
|
90
|
+
'ms',
|
|
91
|
+
// Malaysian
|
|
92
|
+
'my',
|
|
93
|
+
// Burmese
|
|
94
|
+
'nl',
|
|
95
|
+
// Dutch
|
|
96
|
+
'no',
|
|
97
|
+
// Norwegian
|
|
98
|
+
'pa',
|
|
99
|
+
// Punjabi
|
|
100
|
+
'pl',
|
|
101
|
+
// Polish
|
|
102
|
+
'pt',
|
|
103
|
+
// Portuguese
|
|
104
|
+
'ro',
|
|
105
|
+
// Romanian
|
|
106
|
+
'ru',
|
|
107
|
+
// Russian
|
|
108
|
+
'si',
|
|
109
|
+
// Sinhala
|
|
110
|
+
'sk',
|
|
111
|
+
// Slovak
|
|
112
|
+
'sl',
|
|
113
|
+
// Slovenian
|
|
114
|
+
'sq',
|
|
115
|
+
// Albanian
|
|
116
|
+
'sr',
|
|
117
|
+
// Serbian
|
|
118
|
+
'sv',
|
|
119
|
+
// Swedish
|
|
120
|
+
'th',
|
|
121
|
+
// Thai
|
|
122
|
+
'tr',
|
|
123
|
+
// Turkish
|
|
124
|
+
'uk',
|
|
125
|
+
// Ukrainian
|
|
126
|
+
'uz',
|
|
127
|
+
// Uzbek
|
|
128
|
+
'uz_latn',
|
|
129
|
+
// Uzbek Latin
|
|
130
|
+
'vn',
|
|
131
|
+
// Vietnamese
|
|
132
|
+
'zh_tw',
|
|
133
|
+
// Mandarin Traditional
|
|
134
|
+
'zh' // Mandarin
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
exports.SUPPORTED_LOCALES = SUPPORTED_LOCALES;
|
|
@@ -23,6 +23,7 @@ require('../Text/TextDirection.js');
|
|
|
23
23
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
24
24
|
var index = require('../AILabel/index.js');
|
|
25
25
|
var utils = require('../../internal/utils.js');
|
|
26
|
+
var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js');
|
|
26
27
|
|
|
27
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
28
29
|
|
|
@@ -45,8 +46,9 @@ const DatePickerInput = /*#__PURE__*/React.forwardRef(function DatePickerInput(p
|
|
|
45
46
|
size = 'md',
|
|
46
47
|
slug,
|
|
47
48
|
type = 'text',
|
|
48
|
-
warn,
|
|
49
|
+
warn = false,
|
|
49
50
|
warnText,
|
|
51
|
+
readOnly,
|
|
50
52
|
...rest
|
|
51
53
|
} = props;
|
|
52
54
|
const prefix = usePrefix.usePrefix();
|
|
@@ -54,6 +56,15 @@ const DatePickerInput = /*#__PURE__*/React.forwardRef(function DatePickerInput(p
|
|
|
54
56
|
isFluid
|
|
55
57
|
} = React.useContext(FormContext.FormContext);
|
|
56
58
|
const datePickerInputInstanceId = useId.useId();
|
|
59
|
+
const normalizedProps = useNormalizedInputProps.useNormalizedInputProps({
|
|
60
|
+
id,
|
|
61
|
+
readOnly,
|
|
62
|
+
disabled,
|
|
63
|
+
invalid,
|
|
64
|
+
invalidText,
|
|
65
|
+
warn,
|
|
66
|
+
warnText
|
|
67
|
+
});
|
|
57
68
|
const datePickerInputProps = {
|
|
58
69
|
id,
|
|
59
70
|
onChange: event => {
|
|
@@ -75,28 +86,28 @@ const DatePickerInput = /*#__PURE__*/React.forwardRef(function DatePickerInput(p
|
|
|
75
86
|
didWarnAboutDatePickerInputValue = true;
|
|
76
87
|
}
|
|
77
88
|
const wrapperClasses = cx(`${prefix}--date-picker-input__wrapper`, {
|
|
78
|
-
[`${prefix}--date-picker-input__wrapper--invalid`]: invalid,
|
|
79
|
-
[`${prefix}--date-picker-input__wrapper--warn`]: warn,
|
|
89
|
+
[`${prefix}--date-picker-input__wrapper--invalid`]: normalizedProps.invalid,
|
|
90
|
+
[`${prefix}--date-picker-input__wrapper--warn`]: normalizedProps.warn,
|
|
80
91
|
[`${prefix}--date-picker-input__wrapper--slug`]: slug,
|
|
81
92
|
[`${prefix}--date-picker-input__wrapper--decorator`]: decorator
|
|
82
93
|
});
|
|
83
94
|
const labelClasses = cx(`${prefix}--label`, {
|
|
84
95
|
[`${prefix}--visually-hidden`]: hideLabel,
|
|
85
|
-
[`${prefix}--label--disabled`]: disabled,
|
|
86
|
-
[`${prefix}--label--readonly`]:
|
|
96
|
+
[`${prefix}--label--disabled`]: normalizedProps.disabled,
|
|
97
|
+
[`${prefix}--label--readonly`]: readOnly
|
|
87
98
|
});
|
|
88
99
|
const helperTextClasses = cx(`${prefix}--form__helper-text`, {
|
|
89
|
-
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
100
|
+
[`${prefix}--form__helper-text--disabled`]: normalizedProps.disabled
|
|
90
101
|
});
|
|
91
102
|
const inputClasses = cx(`${prefix}--date-picker__input`, {
|
|
92
103
|
[`${prefix}--date-picker__input--${size}`]: size,
|
|
93
|
-
[`${prefix}--date-picker__input--invalid`]: invalid,
|
|
94
|
-
[`${prefix}--date-picker__input--warn`]: warn
|
|
104
|
+
[`${prefix}--date-picker__input--invalid`]: normalizedProps.invalid,
|
|
105
|
+
[`${prefix}--date-picker__input--warn`]: normalizedProps.warn
|
|
95
106
|
});
|
|
96
107
|
const containerClasses = cx(`${prefix}--date-picker-container`, {
|
|
97
108
|
[`${prefix}--date-picker--nolabel`]: !labelText,
|
|
98
|
-
[`${prefix}--date-picker--fluid--invalid`]: isFluid && invalid,
|
|
99
|
-
[`${prefix}--date-picker--fluid--warn`]: isFluid && warn
|
|
109
|
+
[`${prefix}--date-picker--fluid--invalid`]: isFluid && normalizedProps.invalid,
|
|
110
|
+
[`${prefix}--date-picker--fluid--warn`]: isFluid && normalizedProps.warn
|
|
100
111
|
});
|
|
101
112
|
const datePickerInputHelperId = !helperText ? undefined : `datepicker-input-helper-text-${datePickerInputInstanceId}`;
|
|
102
113
|
|
|
@@ -105,11 +116,11 @@ const DatePickerInput = /*#__PURE__*/React.forwardRef(function DatePickerInput(p
|
|
|
105
116
|
...rest,
|
|
106
117
|
...datePickerInputProps,
|
|
107
118
|
className: inputClasses,
|
|
108
|
-
disabled,
|
|
119
|
+
disabled: normalizedProps.disabled,
|
|
109
120
|
ref,
|
|
110
121
|
['aria-describedby']: helperText ? datePickerInputHelperId : undefined
|
|
111
122
|
};
|
|
112
|
-
if (invalid) {
|
|
123
|
+
if (normalizedProps.invalid) {
|
|
113
124
|
inputProps['data-invalid'] = true;
|
|
114
125
|
}
|
|
115
126
|
const input = /*#__PURE__*/React.createElement("input", inputProps);
|
|
@@ -134,19 +145,11 @@ const DatePickerInput = /*#__PURE__*/React.forwardRef(function DatePickerInput(p
|
|
|
134
145
|
datePickerType: datePickerType
|
|
135
146
|
}), /*#__PURE__*/React.createElement(DatePickerIcon, {
|
|
136
147
|
datePickerType: datePickerType,
|
|
137
|
-
invalid: invalid,
|
|
138
|
-
warn: warn
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}), /*#__PURE__*/React.createElement(Text.Text, {
|
|
142
|
-
as: "div",
|
|
143
|
-
className: `${prefix}--form-requirement`
|
|
144
|
-
}, invalidText)), warn && !invalid && /*#__PURE__*/React.createElement(React.Fragment, null, isFluid && /*#__PURE__*/React.createElement("hr", {
|
|
145
|
-
className: `${prefix}--date-picker__divider`
|
|
146
|
-
}), /*#__PURE__*/React.createElement(Text.Text, {
|
|
147
|
-
as: "div",
|
|
148
|
-
className: `${prefix}--form-requirement`
|
|
149
|
-
}, warnText)), helperText && !invalid && /*#__PURE__*/React.createElement(Text.Text, {
|
|
148
|
+
invalid: normalizedProps.invalid,
|
|
149
|
+
warn: normalizedProps.warn,
|
|
150
|
+
disabled: normalizedProps.disabled,
|
|
151
|
+
readOnly: readOnly
|
|
152
|
+
}))), normalizedProps.validation, helperText && !normalizedProps.invalid && !normalizedProps.warn && /*#__PURE__*/React.createElement(Text.Text, {
|
|
150
153
|
as: "div",
|
|
151
154
|
id: datePickerInputHelperId,
|
|
152
155
|
className: helperTextClasses
|
|
@@ -247,7 +250,9 @@ DatePickerInput.propTypes = {
|
|
|
247
250
|
function DatePickerIcon({
|
|
248
251
|
datePickerType,
|
|
249
252
|
invalid,
|
|
250
|
-
warn
|
|
253
|
+
warn,
|
|
254
|
+
disabled,
|
|
255
|
+
readOnly
|
|
251
256
|
}) {
|
|
252
257
|
const prefix = usePrefix.usePrefix();
|
|
253
258
|
const {
|
|
@@ -258,6 +263,15 @@ function DatePickerIcon({
|
|
|
258
263
|
return null;
|
|
259
264
|
}
|
|
260
265
|
}
|
|
266
|
+
|
|
267
|
+
// Don't show invalid/warn icons when disabled or readonly
|
|
268
|
+
if (disabled || readOnly) {
|
|
269
|
+
return /*#__PURE__*/React.createElement(iconsReact.Calendar, {
|
|
270
|
+
className: `${prefix}--date-picker__icon`,
|
|
271
|
+
role: "img",
|
|
272
|
+
"aria-hidden": "true"
|
|
273
|
+
});
|
|
274
|
+
}
|
|
261
275
|
if (invalid) {
|
|
262
276
|
return /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
|
|
263
277
|
className: `${prefix}--date-picker__icon ${prefix}--date-picker__icon--invalid`
|
|
@@ -290,7 +304,15 @@ DatePickerIcon.propTypes = {
|
|
|
290
304
|
/**
|
|
291
305
|
* Specify whether the control is currently in warning state
|
|
292
306
|
*/
|
|
293
|
-
warn: PropTypes.bool
|
|
307
|
+
warn: PropTypes.bool,
|
|
308
|
+
/**
|
|
309
|
+
* Specify whether or not the input should be disabled
|
|
310
|
+
*/
|
|
311
|
+
disabled: PropTypes.bool,
|
|
312
|
+
/**
|
|
313
|
+
* Specify whether the input is readonly
|
|
314
|
+
*/
|
|
315
|
+
readOnly: PropTypes.bool
|
|
294
316
|
};
|
|
295
317
|
|
|
296
318
|
exports.default = DatePickerInput;
|
|
@@ -31,7 +31,9 @@ var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
|
31
31
|
|
|
32
32
|
const {
|
|
33
33
|
ItemMouseMove,
|
|
34
|
-
MenuMouseLeave
|
|
34
|
+
MenuMouseLeave,
|
|
35
|
+
ToggleButtonBlur,
|
|
36
|
+
FunctionCloseMenu
|
|
35
37
|
} = Downshift.useSelect.stateChangeTypes;
|
|
36
38
|
/**
|
|
37
39
|
* Custom state reducer for `useSelect` in Downshift, providing control over
|
|
@@ -65,6 +67,12 @@ function stateReducer(state, actionAndChanges) {
|
|
|
65
67
|
return state;
|
|
66
68
|
}
|
|
67
69
|
return changes;
|
|
70
|
+
case ToggleButtonBlur:
|
|
71
|
+
case FunctionCloseMenu:
|
|
72
|
+
return {
|
|
73
|
+
...changes,
|
|
74
|
+
selectedItem: state.selectedItem
|
|
75
|
+
};
|
|
68
76
|
default:
|
|
69
77
|
return changes;
|
|
70
78
|
}
|
|
@@ -8,7 +8,9 @@ import React, { type HTMLAttributes } from 'react';
|
|
|
8
8
|
interface FileItem {
|
|
9
9
|
name: string;
|
|
10
10
|
uuid: string;
|
|
11
|
-
file: File
|
|
11
|
+
file: File & {
|
|
12
|
+
invalidFileType?: boolean;
|
|
13
|
+
};
|
|
12
14
|
}
|
|
13
15
|
export interface FileChangeData {
|
|
14
16
|
addedFiles: FileItem[];
|
|
@@ -58,6 +60,10 @@ export interface FileUploaderProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
58
60
|
* Specify the title text of this `<FileUploader>`
|
|
59
61
|
*/
|
|
60
62
|
labelTitle?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Maximum file size allowed in bytes. Files larger than this will be marked invalid
|
|
65
|
+
*/
|
|
66
|
+
maxFileSize?: number;
|
|
61
67
|
/**
|
|
62
68
|
* Specify if the component should accept multiple files to upload
|
|
63
69
|
*/
|
|
@@ -66,24 +72,32 @@ export interface FileUploaderProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
66
72
|
* Provide a name for the underlying `<input>` node
|
|
67
73
|
*/
|
|
68
74
|
name?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Event handler that is called after files are added to the uploader
|
|
77
|
+
*/
|
|
78
|
+
onAddFiles?: (event: React.SyntheticEvent<HTMLElement>, content: {
|
|
79
|
+
addedFiles: Array<File & {
|
|
80
|
+
invalidFileType?: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
}) => void;
|
|
69
83
|
/**
|
|
70
84
|
* Provide an optional `onChange` hook that is called each time the input is changed.
|
|
71
85
|
* When 'enable-enhanced-file-uploader' feature flag is enabled:
|
|
72
86
|
* - Also fires for file deletions and clearFiles operations
|
|
73
87
|
* - Event includes enhanced file information in event.target
|
|
74
88
|
*/
|
|
75
|
-
onChange?: (event:
|
|
89
|
+
onChange?: (event: React.SyntheticEvent<HTMLElement>, data?: FileChangeData) => void;
|
|
76
90
|
/**
|
|
77
91
|
* Provide an optional `onClick` hook that is called each time the
|
|
78
92
|
* FileUploader is clicked
|
|
79
93
|
*/
|
|
80
|
-
onClick?: (event:
|
|
94
|
+
onClick?: (event: React.SyntheticEvent<HTMLElement>) => void;
|
|
81
95
|
/**
|
|
82
96
|
* Provide an optional `onDelete` hook that is called when an uploaded item is removed.
|
|
83
97
|
* When 'enable-enhanced-file-uploader' feature flag is enabled:
|
|
84
98
|
* - Event includes deleted file information in event.target
|
|
85
99
|
*/
|
|
86
|
-
onDelete?: (event:
|
|
100
|
+
onDelete?: (event: React.SyntheticEvent<HTMLElement>, data?: FileDeleteData) => void;
|
|
87
101
|
/**
|
|
88
102
|
* Specify the size of the FileUploaderButton, from a list of available
|
|
89
103
|
* sizes.
|
|
@@ -101,9 +115,10 @@ export interface FileUploaderHandle {
|
|
|
101
115
|
getCurrentFiles?: () => FileItem[];
|
|
102
116
|
}
|
|
103
117
|
declare const FileUploader: {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
(props: FileUploaderProps): React.ReactElement;
|
|
119
|
+
displayName?: string;
|
|
120
|
+
propTypes?: unknown;
|
|
121
|
+
contextTypes?: unknown;
|
|
122
|
+
defaultProps?: unknown;
|
|
108
123
|
};
|
|
109
124
|
export default FileUploader;
|