@carbon/react 1.99.0-rc.0 → 1.100.0-rc.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 +942 -942
- package/es/components/BadgeIndicator/index.d.ts +1 -1
- package/es/components/BadgeIndicator/index.js +8 -6
- package/es/components/Breadcrumb/BreadcrumbItem.d.ts +1 -1
- package/es/components/Breadcrumb/BreadcrumbItem.js +6 -7
- package/es/components/Button/Button.Skeleton.d.ts +28 -2
- package/es/components/Button/Button.js +3 -2
- package/es/components/ChatButton/ChatButton.d.ts +3 -2
- package/es/components/CheckboxGroup/CheckboxGroup.d.ts +60 -2
- package/es/components/ComboBox/ComboBox.d.ts +4 -4
- package/es/components/ComboBox/ComboBox.js +21 -3
- package/es/components/ComposedModal/ComposedModal.d.ts +2 -2
- package/es/components/ContainedList/ContainedList.d.ts +35 -6
- package/es/components/ContainedList/ContainedList.js +3 -1
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +32 -3
- package/es/components/ContainedList/index.d.ts +1 -1
- package/es/components/ContainedList/index.js +4 -1
- package/es/components/DangerButton/DangerButton.d.ts +1 -1
- package/es/components/DataTable/DataTable.d.ts +22 -5
- package/es/components/DataTable/DataTable.js +1 -1
- package/es/components/DataTable/TableExpandRow.d.ts +1 -1
- package/es/components/DataTable/TableExpandRow.js +2 -2
- package/es/components/DataTable/TableHeader.d.ts +1 -1
- package/es/components/DataTable/TableHeader.js +18 -16
- package/es/components/DataTable/TableToolbar.d.ts +25 -1
- package/es/components/DataTable/TableToolbarMenu.d.ts +25 -5
- package/es/components/DataTable/TableToolbarMenu.js +0 -3
- package/es/components/DataTableSkeleton/DataTableSkeleton.d.ts +51 -2
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +6 -0
- package/es/components/DatePicker/DatePicker.d.ts +2 -2
- package/es/components/DatePicker/DatePicker.js +38 -53
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +28 -2
- package/es/components/DatePickerInput/DatePickerInput.d.ts +1 -1
- package/es/components/DatePickerInput/DatePickerInput.js +3 -2
- package/es/components/Dialog/Dialog.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.Skeleton.d.ts +19 -2
- package/es/components/ExpandableSearch/ExpandableSearch.d.ts +1 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +14 -12
- package/es/components/FileUploader/FileUploader.d.ts +1 -1
- package/es/components/FileUploader/FileUploader.js +2 -2
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +28 -10
- package/es/components/FluidComboBox/FluidComboBox.Skeleton.d.ts +11 -3
- package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.d.ts +15 -3
- package/es/components/FluidDatePicker/FluidDatePicker.d.ts +2 -2
- package/es/components/FluidDropdown/FluidDropdown.Skeleton.d.ts +11 -3
- package/es/components/FluidForm/FluidForm.d.ts +15 -2
- package/es/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +2 -2
- package/es/components/FluidMultiSelect/FluidMultiSelect.Skeleton.d.ts +11 -3
- package/es/components/FluidNumberInput/FluidNumberInput.Skeleton.d.ts +11 -3
- package/es/components/FluidNumberInput/FluidNumberInput.d.ts +1 -1
- package/es/components/FluidSearch/FluidSearch.Skeleton.d.ts +11 -3
- package/es/components/FluidSearch/FluidSearch.d.ts +1 -1
- package/es/components/FluidSearch/FluidSearch.js +3 -3
- package/es/components/FluidSelect/FluidSelect.Skeleton.d.ts +11 -3
- package/es/components/FluidTextArea/FluidTextArea.Skeleton.d.ts +11 -3
- package/es/components/FluidTextArea/FluidTextArea.d.ts +95 -1
- package/es/components/FluidTextInput/FluidPasswordInput.d.ts +83 -2
- package/es/components/FluidTextInput/FluidTextInput.Skeleton.d.ts +11 -3
- package/es/components/Grid/GridContext.d.ts +19 -1
- package/es/components/IconButton/index.d.ts +1 -1
- package/es/components/IconButton/index.js +2 -2
- package/es/components/Link/Link.js +3 -0
- package/es/components/ListBox/ListBoxField.d.ts +35 -2
- package/es/components/ListBox/ListBoxMenuIcon.d.ts +16 -3
- package/es/components/ListBox/ListBoxMenuItem.d.ts +1 -1
- package/es/components/ListBox/ListBoxSelection.d.ts +34 -3
- package/es/components/Menu/MenuItem.d.ts +2 -2
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +2 -2
- package/es/components/MultiSelect/FilterableMultiSelect.js +22 -13
- package/es/components/MultiSelect/MultiSelect.js +22 -13
- package/es/components/Notification/Notification.d.ts +8 -7
- package/es/components/Notification/Notification.js +0 -1
- package/es/components/NumberInput/NumberInput.d.ts +9 -0
- package/es/components/NumberInput/NumberInput.js +206 -38
- package/es/components/OverflowMenu/OverflowMenu.d.ts +1 -1
- package/es/components/OverflowMenu/OverflowMenu.js +0 -1
- package/es/components/OverflowMenu/index.d.ts +1 -1
- package/es/components/PageHeader/PageHeader.d.ts +3 -3
- package/es/components/Popover/index.js +21 -12
- package/es/components/Search/Search.d.ts +2 -2
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/Select/Select.js +2 -2
- package/es/components/SkeletonIcon/SkeletonIcon.d.ts +16 -2
- package/es/components/SkeletonText/SkeletonText.d.ts +1 -1
- package/es/components/Tag/Tag.d.ts +1 -1
- package/es/components/Tag/Tag.js +2 -0
- package/es/components/Text/Text.d.ts +1 -1
- package/es/components/Text/Text.js +4 -3
- package/es/components/Text/TextDirection.d.ts +1 -1
- package/es/components/Text/TextDirection.js +1 -3
- package/es/components/Text/TextDirectionContext.d.ts +3 -3
- package/es/components/TextInput/ControlledPasswordInput.d.ts +1 -1
- package/es/components/TextInput/ControlledPasswordInput.js +2 -2
- package/es/components/TextInput/PasswordInput.d.ts +1 -1
- package/es/components/TextInput/PasswordInput.js +2 -2
- package/es/components/TextInput/TextInput.d.ts +1 -1
- package/es/components/TextInput/TextInput.js +2 -2
- package/es/components/Toggle/Toggle.Skeleton.d.ts +9 -3
- package/es/components/Toggletip/index.d.ts +1 -1
- package/es/components/Toggletip/index.js +9 -7
- package/es/components/Tooltip/DefinitionTooltip.d.ts +52 -1
- package/es/components/Tooltip/Tooltip.js +2 -0
- package/es/components/TreeView/TreeNode.d.ts +4 -4
- package/es/components/UIShell/Header.d.ts +20 -3
- package/es/components/UIShell/HeaderGlobalAction.d.ts +2 -2
- package/es/components/UIShell/HeaderName.js +1 -1
- package/es/components/UIShell/Link.d.ts +1 -1
- package/es/components/UIShell/Link.js +14 -14
- package/es/components/UIShell/SideNav.d.ts +3 -3
- package/es/components/UIShell/SideNav.js +26 -25
- package/es/components/UIShell/SideNavDivider.d.ts +11 -3
- package/es/components/UIShell/SideNavHeader.d.ts +24 -1
- package/es/components/UIShell/SideNavIcon.d.ts +20 -2
- package/es/components/UIShell/SideNavItem.d.ts +20 -2
- package/es/components/UIShell/SideNavItems.d.ts +22 -2
- package/es/components/UIShell/SideNavLink.d.ts +1 -1
- package/es/components/UIShell/SideNavLink.js +14 -14
- package/es/components/UIShell/SideNavMenu.d.ts +1 -1
- package/es/components/UIShell/SideNavMenu.js +2 -2
- package/es/components/UIShell/SideNavMenuItem.d.ts +2 -2
- package/es/components/UIShell/SideNavMenuItem.js +2 -2
- package/es/components/UIShell/SwitcherDivider.d.ts +10 -2
- package/es/internal/FloatingMenu.d.ts +1 -1
- package/es/internal/FloatingMenu.js +0 -2
- package/es/internal/PolymorphicProps.d.ts +3 -3
- package/es/internal/useNoInteractiveChildren.d.ts +1 -1
- package/es/internal/useNoInteractiveChildren.js +8 -10
- package/es/internal/useOutsideClick.d.ts +1 -1
- package/es/internal/useOutsideClick.js +0 -4
- package/lib/components/BadgeIndicator/index.d.ts +1 -1
- package/lib/components/BadgeIndicator/index.js +7 -5
- package/lib/components/Breadcrumb/BreadcrumbItem.d.ts +1 -1
- package/lib/components/Breadcrumb/BreadcrumbItem.js +5 -6
- package/lib/components/Button/Button.Skeleton.d.ts +28 -2
- package/lib/components/Button/Button.js +3 -2
- package/lib/components/ChatButton/ChatButton.d.ts +3 -2
- package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +60 -2
- package/lib/components/ComboBox/ComboBox.d.ts +4 -4
- package/lib/components/ComboBox/ComboBox.js +21 -3
- package/lib/components/ComposedModal/ComposedModal.d.ts +2 -2
- package/lib/components/ContainedList/ContainedList.d.ts +35 -6
- package/lib/components/ContainedList/ContainedList.js +3 -1
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +32 -3
- package/lib/components/ContainedList/index.d.ts +1 -1
- package/lib/components/ContainedList/index.js +4 -1
- package/lib/components/DangerButton/DangerButton.d.ts +1 -1
- package/lib/components/DataTable/DataTable.d.ts +22 -5
- package/lib/components/DataTable/DataTable.js +1 -1
- package/lib/components/DataTable/TableExpandRow.d.ts +1 -1
- package/lib/components/DataTable/TableHeader.d.ts +1 -1
- package/lib/components/DataTable/TableHeader.js +17 -15
- package/lib/components/DataTable/TableToolbar.d.ts +25 -1
- package/lib/components/DataTable/TableToolbarMenu.d.ts +25 -5
- package/lib/components/DataTable/TableToolbarMenu.js +0 -3
- package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +51 -2
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +6 -0
- package/lib/components/DatePicker/DatePicker.d.ts +2 -2
- package/lib/components/DatePicker/DatePicker.js +37 -52
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +28 -2
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +1 -1
- package/lib/components/DatePickerInput/DatePickerInput.js +2 -1
- package/lib/components/Dialog/Dialog.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +19 -2
- package/lib/components/ExpandableSearch/ExpandableSearch.d.ts +1 -1
- package/lib/components/ExpandableSearch/ExpandableSearch.js +13 -11
- package/lib/components/FileUploader/FileUploader.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +28 -10
- package/lib/components/FluidComboBox/FluidComboBox.Skeleton.d.ts +11 -3
- package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.d.ts +15 -3
- package/lib/components/FluidDatePicker/FluidDatePicker.d.ts +2 -2
- package/lib/components/FluidDropdown/FluidDropdown.Skeleton.d.ts +11 -3
- package/lib/components/FluidForm/FluidForm.d.ts +15 -2
- package/lib/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +2 -2
- package/lib/components/FluidMultiSelect/FluidMultiSelect.Skeleton.d.ts +11 -3
- package/lib/components/FluidNumberInput/FluidNumberInput.Skeleton.d.ts +11 -3
- package/lib/components/FluidNumberInput/FluidNumberInput.d.ts +1 -1
- package/lib/components/FluidSearch/FluidSearch.Skeleton.d.ts +11 -3
- package/lib/components/FluidSearch/FluidSearch.d.ts +1 -1
- package/lib/components/FluidSearch/FluidSearch.js +2 -2
- package/lib/components/FluidSelect/FluidSelect.Skeleton.d.ts +11 -3
- package/lib/components/FluidTextArea/FluidTextArea.Skeleton.d.ts +11 -3
- package/lib/components/FluidTextArea/FluidTextArea.d.ts +95 -1
- package/lib/components/FluidTextInput/FluidPasswordInput.d.ts +83 -2
- package/lib/components/FluidTextInput/FluidTextInput.Skeleton.d.ts +11 -3
- package/lib/components/Grid/GridContext.d.ts +19 -1
- package/lib/components/IconButton/index.d.ts +1 -1
- package/lib/components/Link/Link.js +3 -0
- package/lib/components/ListBox/ListBoxField.d.ts +35 -2
- package/lib/components/ListBox/ListBoxMenuIcon.d.ts +16 -3
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +1 -1
- package/lib/components/ListBox/ListBoxSelection.d.ts +34 -3
- package/lib/components/Menu/MenuItem.d.ts +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +22 -13
- package/lib/components/MultiSelect/MultiSelect.js +22 -13
- package/lib/components/Notification/Notification.d.ts +8 -7
- package/lib/components/Notification/Notification.js +0 -1
- package/lib/components/NumberInput/NumberInput.d.ts +9 -0
- package/lib/components/NumberInput/NumberInput.js +206 -37
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +0 -1
- package/lib/components/OverflowMenu/index.d.ts +1 -1
- package/lib/components/PageHeader/PageHeader.d.ts +3 -3
- package/lib/components/Popover/index.js +19 -10
- package/lib/components/Search/Search.d.ts +2 -2
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/SkeletonIcon/SkeletonIcon.d.ts +16 -2
- package/lib/components/SkeletonText/SkeletonText.d.ts +1 -1
- package/lib/components/Tag/Tag.d.ts +1 -1
- package/lib/components/Tag/Tag.js +2 -0
- package/lib/components/Text/Text.d.ts +1 -1
- package/lib/components/Text/Text.js +3 -2
- package/lib/components/Text/TextDirection.d.ts +1 -1
- package/lib/components/Text/TextDirection.js +1 -3
- package/lib/components/Text/TextDirectionContext.d.ts +3 -3
- package/lib/components/TextInput/ControlledPasswordInput.d.ts +1 -1
- package/lib/components/TextInput/PasswordInput.d.ts +1 -1
- package/lib/components/TextInput/TextInput.d.ts +1 -1
- package/lib/components/Toggle/Toggle.Skeleton.d.ts +9 -3
- package/lib/components/Toggletip/index.d.ts +1 -1
- package/lib/components/Toggletip/index.js +7 -5
- package/lib/components/Tooltip/DefinitionTooltip.d.ts +52 -1
- package/lib/components/Tooltip/Tooltip.js +2 -0
- package/lib/components/TreeView/TreeNode.d.ts +4 -4
- package/lib/components/UIShell/Header.d.ts +20 -3
- package/lib/components/UIShell/HeaderGlobalAction.d.ts +2 -2
- package/lib/components/UIShell/HeaderName.js +1 -1
- package/lib/components/UIShell/Link.d.ts +1 -1
- package/lib/components/UIShell/Link.js +13 -13
- package/lib/components/UIShell/SideNav.d.ts +3 -3
- package/lib/components/UIShell/SideNav.js +25 -24
- package/lib/components/UIShell/SideNavDivider.d.ts +11 -3
- package/lib/components/UIShell/SideNavHeader.d.ts +24 -1
- package/lib/components/UIShell/SideNavIcon.d.ts +20 -2
- package/lib/components/UIShell/SideNavItem.d.ts +20 -2
- package/lib/components/UIShell/SideNavItems.d.ts +22 -2
- package/lib/components/UIShell/SideNavLink.d.ts +1 -1
- package/lib/components/UIShell/SideNavLink.js +14 -14
- package/lib/components/UIShell/SideNavMenu.d.ts +1 -1
- package/lib/components/UIShell/SideNavMenuItem.d.ts +2 -2
- package/lib/components/UIShell/SwitcherDivider.d.ts +10 -2
- package/lib/internal/FloatingMenu.d.ts +1 -1
- package/lib/internal/FloatingMenu.js +0 -2
- package/lib/internal/PolymorphicProps.d.ts +3 -3
- package/lib/internal/useNoInteractiveChildren.d.ts +1 -1
- package/lib/internal/useNoInteractiveChildren.js +8 -10
- package/lib/internal/useOutsideClick.d.ts +1 -1
- package/lib/internal/useOutsideClick.js +0 -4
- package/package.json +8 -8
- package/scss/_carbon-utilities.scss +9 -0
- package/telemetry.yml +0 -1
- package/es/internal/createClassWrapper.d.ts +0 -12
- package/lib/internal/createClassWrapper.d.ts +0 -12
|
@@ -45,8 +45,41 @@ const getSeparators = locale => {
|
|
|
45
45
|
const numberWithGroupAndDecimal = 1234567.89;
|
|
46
46
|
const formatted = new Intl.NumberFormat(locale).format(numberWithGroupAndDecimal);
|
|
47
47
|
|
|
48
|
-
//
|
|
49
|
-
|
|
48
|
+
// Comprehensive Unicode digit pattern that includes all common numeral systems
|
|
49
|
+
// supported by Intl.NumberFormat across different locales
|
|
50
|
+
const digitPattern = '[' + '\\u0030-\\u0039' +
|
|
51
|
+
// Western
|
|
52
|
+
'\\u0660-\\u0669' +
|
|
53
|
+
// Eastern Arabic
|
|
54
|
+
'\\u0966-\\u096F' +
|
|
55
|
+
// Devanagari
|
|
56
|
+
'\\u09E6-\\u09EF' +
|
|
57
|
+
// Bengali
|
|
58
|
+
'\\uFF10-\\uFF19' +
|
|
59
|
+
// Fullwidth Japanese 0-9
|
|
60
|
+
'一二三四五六七八九〇零' +
|
|
61
|
+
// Kanji digits
|
|
62
|
+
']';
|
|
63
|
+
|
|
64
|
+
// Non-digit pattern that excludes ALL digit types (not just ASCII 0-9)
|
|
65
|
+
const nonDigitPattern = '[^' + '\\u0030-\\u0039' +
|
|
66
|
+
// Western
|
|
67
|
+
'\\u0660-\\u0669' +
|
|
68
|
+
// Eastern Arabic
|
|
69
|
+
'\\u0966-\\u096F' +
|
|
70
|
+
// Devanagari
|
|
71
|
+
'\\u09E6-\\u09EF' +
|
|
72
|
+
// Bengali
|
|
73
|
+
'\\uFF10-\\uFF19' +
|
|
74
|
+
// Fullwidth Japanese 0-9
|
|
75
|
+
'一二三四五六七八九〇零' +
|
|
76
|
+
// Kanji digits
|
|
77
|
+
']+';
|
|
78
|
+
|
|
79
|
+
// Extract separators using regex that handles all numeral systems
|
|
80
|
+
// Use nonDigitPattern instead of \D+ to correctly identify separators
|
|
81
|
+
const regex = new RegExp(`(${nonDigitPattern})${digitPattern}{3}(${nonDigitPattern})${digitPattern}{2}$`);
|
|
82
|
+
const match = formatted.match(regex);
|
|
50
83
|
if (match) {
|
|
51
84
|
const groupSeparator = match[1];
|
|
52
85
|
const decimalSeparator = match[2];
|
|
@@ -61,11 +94,116 @@ const getSeparators = locale => {
|
|
|
61
94
|
};
|
|
62
95
|
}
|
|
63
96
|
};
|
|
97
|
+
|
|
98
|
+
// Normalizes all Unicode minus variants to ASCII hyphen-minus (-)
|
|
99
|
+
const normalizeMinus = value => value.replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, '-');
|
|
100
|
+
const normalizeNumericInput = value => value
|
|
101
|
+
// Remove bidi / direction control characters (Arabic keyboards)
|
|
102
|
+
.replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, '')
|
|
103
|
+
// Normalize Unicode minus variants to ASCII "-"
|
|
104
|
+
.replace(/[\u2212\u2012\u2013\u2014\uFE63\uFF0D]/g, '-');
|
|
105
|
+
/**
|
|
106
|
+
* Converts a string with any Unicode numeral system to a JavaScript number.
|
|
107
|
+
* Handles all numeral systems supported by Intl.NumberFormat.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} input - The input string with numerals in any Unicode system
|
|
110
|
+
* @param {string} locale - The locale for parsing separators
|
|
111
|
+
* @returns {number} The parsed number, or NaN if invalid
|
|
112
|
+
*/
|
|
113
|
+
const parseNumberWithLocale = (input, locale) => {
|
|
114
|
+
// Handle empty, null, or undefined inputs
|
|
115
|
+
if (input === '' || input === undefined || input === null) {
|
|
116
|
+
return NaN;
|
|
117
|
+
}
|
|
118
|
+
input = normalizeNumericInput(input);
|
|
119
|
+
const {
|
|
120
|
+
groupSeparator,
|
|
121
|
+
decimalSeparator
|
|
122
|
+
} = getSeparators(locale);
|
|
123
|
+
|
|
124
|
+
// Kanji digit map
|
|
125
|
+
const kanjiMap = {
|
|
126
|
+
零: '0',
|
|
127
|
+
〇: '0',
|
|
128
|
+
一: '1',
|
|
129
|
+
二: '2',
|
|
130
|
+
三: '3',
|
|
131
|
+
四: '4',
|
|
132
|
+
五: '5',
|
|
133
|
+
六: '6',
|
|
134
|
+
七: '7',
|
|
135
|
+
八: '8',
|
|
136
|
+
九: '9'
|
|
137
|
+
};
|
|
138
|
+
const digitRanges = [{
|
|
139
|
+
start: 0x0030,
|
|
140
|
+
end: 0x0039,
|
|
141
|
+
base: 0x0030
|
|
142
|
+
}, {
|
|
143
|
+
start: 0x0660,
|
|
144
|
+
end: 0x0669,
|
|
145
|
+
base: 0x0660
|
|
146
|
+
}, {
|
|
147
|
+
start: 0x0966,
|
|
148
|
+
end: 0x096f,
|
|
149
|
+
base: 0x0966
|
|
150
|
+
}, {
|
|
151
|
+
start: 0x09e6,
|
|
152
|
+
end: 0x09ef,
|
|
153
|
+
base: 0x09e6
|
|
154
|
+
}, {
|
|
155
|
+
start: 0xff10,
|
|
156
|
+
end: 0xff19,
|
|
157
|
+
base: 0xff10
|
|
158
|
+
}];
|
|
159
|
+
let normalized = Array.from(input).map(char => {
|
|
160
|
+
// Preserve scientific notation characters
|
|
161
|
+
if (char === 'e' || char === 'E' || char === '+' || char === '-') {
|
|
162
|
+
return char;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Check Kanji first
|
|
166
|
+
if (kanjiMap[char] !== undefined) {
|
|
167
|
+
return kanjiMap[char];
|
|
168
|
+
}
|
|
169
|
+
const code = char.charCodeAt(0);
|
|
170
|
+
for (const range of digitRanges) {
|
|
171
|
+
if (code >= range.start && code <= range.end) {
|
|
172
|
+
return String(code - range.start);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return char;
|
|
176
|
+
}).join('');
|
|
177
|
+
|
|
178
|
+
// Remove grouping separators
|
|
179
|
+
if (groupSeparator) {
|
|
180
|
+
if (groupSeparator?.trim() === '') {
|
|
181
|
+
normalized = normalized?.replace(/[\u00A0\u202F\s]/g, '');
|
|
182
|
+
} else {
|
|
183
|
+
if (decimalSeparator !== ',' && decimalSeparator !== '٬') {
|
|
184
|
+
normalized = normalized?.replace(/[,٬]/g, '');
|
|
185
|
+
}
|
|
186
|
+
if (groupSeparator !== ',' && groupSeparator !== '٬') {
|
|
187
|
+
const escaped = groupSeparator?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
188
|
+
normalized = normalized?.replace(new RegExp(escaped, 'g'), '');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
normalized = normalized.replace(/٫/g, '.');
|
|
193
|
+
if (decimalSeparator && decimalSeparator !== '.' && decimalSeparator !== '٫') {
|
|
194
|
+
const escaped = decimalSeparator.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
195
|
+
normalized = normalized.replace(new RegExp(escaped, 'g'), '.');
|
|
196
|
+
}
|
|
197
|
+
normalized = normalizeMinus(normalized);
|
|
198
|
+
return Number(normalized);
|
|
199
|
+
};
|
|
64
200
|
const validateNumberSeparators = (input, locale) => {
|
|
65
|
-
|
|
66
|
-
if (input === '' || Number.isNaN(input)) {
|
|
201
|
+
if (input === '') {
|
|
67
202
|
return true;
|
|
68
203
|
}
|
|
204
|
+
|
|
205
|
+
// Normalize bidi marks + minus signs FIRST
|
|
206
|
+
input = normalizeNumericInput(input);
|
|
69
207
|
const {
|
|
70
208
|
groupSeparator,
|
|
71
209
|
decimalSeparator
|
|
@@ -74,35 +212,54 @@ const validateNumberSeparators = (input, locale) => {
|
|
|
74
212
|
return !isNaN(Number(input));
|
|
75
213
|
}
|
|
76
214
|
const esc = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
215
|
+
const digit = '[' + '\\u0030-\\u0039' + '\\u0660-\\u0669' + '\\u0966-\\u096F' + '\\u09E6-\\u09EF' + '\\uFF10-\\uFF19' + '一二三四五六七八九〇零' + ']';
|
|
216
|
+
|
|
217
|
+
// Group separator regex
|
|
77
218
|
let group = '';
|
|
78
219
|
if (groupSeparator) {
|
|
79
|
-
if (groupSeparator
|
|
80
|
-
group = '[\\u00A0\\u202F\\s]';
|
|
220
|
+
if (groupSeparator?.trim() === '') {
|
|
221
|
+
group = '[\\u00A0\\u202F\\s]';
|
|
222
|
+
} else if (groupSeparator === ',' || groupSeparator === '٬') {
|
|
223
|
+
group = '[,٬]';
|
|
81
224
|
} else {
|
|
82
225
|
group = esc(groupSeparator);
|
|
83
226
|
}
|
|
84
227
|
}
|
|
85
|
-
const decimal = esc(decimalSeparator);
|
|
86
228
|
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (!regex.test(input)) {
|
|
92
|
-
return false;
|
|
229
|
+
// Decimal separator regex
|
|
230
|
+
let decimal = esc(decimalSeparator);
|
|
231
|
+
if (decimalSeparator === '.' || decimalSeparator === '٫') {
|
|
232
|
+
decimal = '[.٫]';
|
|
93
233
|
}
|
|
234
|
+
const sign = '[\\-\\u2212]?';
|
|
235
|
+
const scientific = `([eE][+-]?${digit}+)?`;
|
|
94
236
|
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
237
|
+
// Detect if grouping is used AT ALL
|
|
238
|
+
const usesGrouping = group && (groupSeparator?.trim() === '' ? /[\u00A0\u202F\s]/.test(input) : groupSeparator === ',' || groupSeparator === '٬' ? /[,٬]/.test(input) : groupSeparator ? input.includes(groupSeparator) : false);
|
|
239
|
+
const scientificMatch = input?.match(/^([^eE]+)([eE][+-]?.*)?$/);
|
|
240
|
+
const baseNumber = scientificMatch ? scientificMatch[1] : input;
|
|
241
|
+
|
|
242
|
+
// Split integer part from the base number - handle both decimal separator variants
|
|
243
|
+
let integerPart;
|
|
244
|
+
if (decimalSeparator === '.' || decimalSeparator === '٫') {
|
|
245
|
+
// Split by either . or ٫
|
|
246
|
+
integerPart = baseNumber?.split(/[.,]/)[0];
|
|
247
|
+
} else {
|
|
248
|
+
integerPart = baseNumber?.split(decimalSeparator)[0];
|
|
103
249
|
}
|
|
104
|
-
|
|
105
|
-
|
|
250
|
+
|
|
251
|
+
// STEP 1: strict integer validation
|
|
252
|
+
// When grouping is used, we need to handle two cases:
|
|
253
|
+
// 1. Numbers with 1-3 digits (no separator required): 1, 12, 123
|
|
254
|
+
// 2. Numbers with 4+ digits (separator required): 1,234 or 12,345 or 123,456
|
|
255
|
+
const integerRegex = usesGrouping ? new RegExp(`^${sign}(${digit}{1,3}|${digit}{1,3}(${group}${digit}{3})+)$`) : new RegExp(`^${sign}${digit}+$`);
|
|
256
|
+
if (!integerRegex.test(integerPart)) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// STEP 2: full number validation
|
|
261
|
+
const fullRegex = new RegExp(`^${sign}${digit}+` + (usesGrouping ? `(${group}${digit}{3})*` : '') + `(${decimal}${digit}+)?${scientific}$`);
|
|
262
|
+
return fullRegex.test(input);
|
|
106
263
|
};
|
|
107
264
|
|
|
108
265
|
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
@@ -294,8 +451,9 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
294
451
|
}
|
|
295
452
|
};
|
|
296
453
|
const outerElementClasses = cx(`${prefix}--form-item`, {
|
|
297
|
-
|
|
298
|
-
|
|
454
|
+
...(customClassName ? {
|
|
455
|
+
[customClassName]: true
|
|
456
|
+
} : {}),
|
|
299
457
|
[`${prefix}--number-input--fluid--invalid`]: isFluid && normalizedProps.invalid,
|
|
300
458
|
[`${prefix}--number-input--fluid--focus`]: isFluid && isFocused,
|
|
301
459
|
[`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
|
|
@@ -766,23 +924,33 @@ function getInputValidity({
|
|
|
766
924
|
validate,
|
|
767
925
|
locale
|
|
768
926
|
}) {
|
|
769
|
-
if (typeof validate === 'function') {
|
|
770
|
-
const result = validate(value, locale);
|
|
771
|
-
if (result === false) {
|
|
772
|
-
return false; // immediate invalid
|
|
773
|
-
}
|
|
774
|
-
// If true or undefined, continue to further validations
|
|
775
|
-
}
|
|
776
927
|
if (invalid) {
|
|
777
928
|
return false;
|
|
778
929
|
}
|
|
779
|
-
|
|
780
|
-
|
|
930
|
+
|
|
931
|
+
// Skip validation if value is empty and allowEmpty
|
|
932
|
+
if (value === '') return allowEmpty;
|
|
933
|
+
|
|
934
|
+
// Normalize the value
|
|
935
|
+
let numericValue;
|
|
936
|
+
if (typeof value === 'string') {
|
|
937
|
+
numericValue = parseNumberWithLocale(value, locale); // safe: handles Arabic, Kanji, etc.
|
|
938
|
+
} else {
|
|
939
|
+
numericValue = value;
|
|
781
940
|
}
|
|
782
|
-
|
|
783
|
-
|
|
941
|
+
|
|
942
|
+
// Use custom validate ONLY for formatting, not numeric comparison
|
|
943
|
+
if (validate && typeof value === 'string') {
|
|
944
|
+
const isFormatValid = validate(value, locale);
|
|
945
|
+
if (isFormatValid === false) {
|
|
946
|
+
return false; // invalid format
|
|
947
|
+
}
|
|
784
948
|
}
|
|
785
|
-
|
|
949
|
+
|
|
950
|
+
// Check min/max bounds
|
|
951
|
+
if (max !== undefined && numericValue > max) return false;
|
|
952
|
+
if (min !== undefined && numericValue < min) return false;
|
|
953
|
+
return true; // valid
|
|
786
954
|
}
|
|
787
955
|
|
|
788
956
|
/**
|
|
@@ -804,4 +972,5 @@ function disableWheel(e) {
|
|
|
804
972
|
}
|
|
805
973
|
|
|
806
974
|
exports.NumberInput = NumberInput;
|
|
975
|
+
exports.parseNumberWithLocale = parseNumberWithLocale;
|
|
807
976
|
exports.validateNumberSeparators = validateNumberSeparators;
|
|
@@ -79,7 +79,6 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
79
79
|
case 'top':
|
|
80
80
|
case 'bottom':
|
|
81
81
|
{
|
|
82
|
-
// TODO: Ensure `trigger` is there for `<OverflowMenu open>`
|
|
83
82
|
const triggerWidth = !trigger ? 0 : trigger.offsetWidth;
|
|
84
83
|
return {
|
|
85
84
|
left: (!flip ? 1 : -1) * (menuWidth / 2 - triggerWidth / 2),
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { type
|
|
7
|
+
import React, { type ElementType } from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import { TYPES } from '../Tag/Tag';
|
|
10
10
|
/**
|
|
@@ -32,7 +32,7 @@ interface PageHeaderBreadcrumbBarProps {
|
|
|
32
32
|
/**
|
|
33
33
|
* Provide an optional icon to render in front of the PageHeaderContent's title.
|
|
34
34
|
*/
|
|
35
|
-
renderIcon?:
|
|
35
|
+
renderIcon?: ElementType;
|
|
36
36
|
/**
|
|
37
37
|
* The PageHeaderBreadcrumbBar's content actions
|
|
38
38
|
*/
|
|
@@ -68,7 +68,7 @@ interface PageHeaderContentProps {
|
|
|
68
68
|
/**
|
|
69
69
|
* Provide an optional icon to render in front of the PageHeaderContent's title.
|
|
70
70
|
*/
|
|
71
|
-
renderIcon?:
|
|
71
|
+
renderIcon?: ElementType;
|
|
72
72
|
/**
|
|
73
73
|
* The PageHeaderContent's title
|
|
74
74
|
*/
|
|
@@ -149,7 +149,9 @@ forwardRef) {
|
|
|
149
149
|
refs,
|
|
150
150
|
floatingStyles,
|
|
151
151
|
placement,
|
|
152
|
-
middlewareData
|
|
152
|
+
middlewareData,
|
|
153
|
+
elements,
|
|
154
|
+
update
|
|
153
155
|
} = react.useFloating(enableFloatingStyles ? {
|
|
154
156
|
placement: align,
|
|
155
157
|
// The floating element is positioned relative to its nearest
|
|
@@ -169,12 +171,18 @@ forwardRef) {
|
|
|
169
171
|
}), react.arrow({
|
|
170
172
|
element: caretRef,
|
|
171
173
|
padding: 16
|
|
172
|
-
}), autoAlign && react.hide()]
|
|
173
|
-
whileElementsMounted: react.autoUpdate
|
|
174
|
+
}), autoAlign && react.hide()]
|
|
174
175
|
} : {}
|
|
175
176
|
// When autoAlign is turned off & the `enable-v12-dynamic-floating-styles` feature flag is not
|
|
176
177
|
// enabled, floating-ui will not be used
|
|
177
178
|
);
|
|
179
|
+
React.useEffect(() => {
|
|
180
|
+
if (!enableFloatingStyles) return;
|
|
181
|
+
if (open && elements.reference && elements.floating) {
|
|
182
|
+
const cleanup = react.autoUpdate(elements.reference, elements.floating, update);
|
|
183
|
+
return cleanup;
|
|
184
|
+
}
|
|
185
|
+
}, [enableFloatingStyles, open, elements, update]);
|
|
178
186
|
const value = React.useMemo(() => {
|
|
179
187
|
return {
|
|
180
188
|
floating,
|
|
@@ -399,11 +407,13 @@ Popover.propTypes = {
|
|
|
399
407
|
*/
|
|
400
408
|
open: PropTypes.bool.isRequired
|
|
401
409
|
};
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
410
|
+
const frFn = React.forwardRef;
|
|
411
|
+
const PopoverContent = frFn((props, forwardRef) => {
|
|
412
|
+
const {
|
|
413
|
+
className,
|
|
414
|
+
children,
|
|
415
|
+
...rest
|
|
416
|
+
} = props;
|
|
407
417
|
const prefix = usePrefix.usePrefix();
|
|
408
418
|
const {
|
|
409
419
|
setFloating,
|
|
@@ -429,8 +439,7 @@ function PopoverContentRenderFunction({
|
|
|
429
439
|
}),
|
|
430
440
|
ref: caretRef
|
|
431
441
|
}));
|
|
432
|
-
}
|
|
433
|
-
const PopoverContent = /*#__PURE__*/React.forwardRef(PopoverContentRenderFunction);
|
|
442
|
+
});
|
|
434
443
|
PopoverContent.displayName = 'PopoverContent';
|
|
435
444
|
PopoverContent.propTypes = {
|
|
436
445
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { type ChangeEvent, type
|
|
7
|
+
import React, { type ChangeEvent, type ElementType, type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react';
|
|
8
8
|
type InputPropsBase = Omit<HTMLAttributes<HTMLInputElement>, 'onChange'>;
|
|
9
9
|
export interface SearchProps extends InputPropsBase {
|
|
10
10
|
/**
|
|
@@ -61,7 +61,7 @@ export interface SearchProps extends InputPropsBase {
|
|
|
61
61
|
/**
|
|
62
62
|
* A component used to render an icon.
|
|
63
63
|
*/
|
|
64
|
-
renderIcon?:
|
|
64
|
+
renderIcon?: ElementType;
|
|
65
65
|
/**
|
|
66
66
|
* @deprecated Specify the role for the underlying `<input>`.
|
|
67
67
|
* No longer needed since `<input type="search">` already provides the correct semantics.
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
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
|
+
import PropTypes from 'prop-types';
|
|
2
8
|
export interface SkeletonIconProps {
|
|
3
9
|
/**
|
|
4
10
|
* Specify an optional className to add.
|
|
5
11
|
*/
|
|
6
12
|
className?: string;
|
|
7
13
|
}
|
|
8
|
-
declare const SkeletonIcon:
|
|
14
|
+
declare const SkeletonIcon: {
|
|
15
|
+
({ className, ...other }: SkeletonIconProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
propTypes: {
|
|
17
|
+
/**
|
|
18
|
+
* Specify an optional className to add.
|
|
19
|
+
*/
|
|
20
|
+
className: PropTypes.Requireable<string>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
9
23
|
export default SkeletonIcon;
|
|
@@ -72,7 +72,7 @@ export interface TagBaseProps {
|
|
|
72
72
|
*/
|
|
73
73
|
slug?: ReactNode;
|
|
74
74
|
/**
|
|
75
|
-
* @deprecated The `title` prop has been deprecated and will be removed in the next major version. Use
|
|
75
|
+
* @deprecated The `title` prop has been deprecated and will be removed in the next major version. Use `children` instead.
|
|
76
76
|
*/
|
|
77
77
|
title?: string;
|
|
78
78
|
/**
|
|
@@ -156,6 +156,8 @@ const TagBase = /*#__PURE__*/React.forwardRef(({
|
|
|
156
156
|
}, normalizedDecorator) : '');
|
|
157
157
|
});
|
|
158
158
|
const Tag = TagBase;
|
|
159
|
+
|
|
160
|
+
// @ts-expect-error - `propTypes` isn't typed.
|
|
159
161
|
Tag.propTypes = {
|
|
160
162
|
/**
|
|
161
163
|
* Provide an alternative tag or component to use instead of the default
|
|
@@ -13,7 +13,7 @@ var React = require('react');
|
|
|
13
13
|
var TextDirectionContext = require('./TextDirectionContext.js');
|
|
14
14
|
|
|
15
15
|
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
16
|
-
const
|
|
16
|
+
const Text = /*#__PURE__*/React.forwardRef(({
|
|
17
17
|
as,
|
|
18
18
|
children,
|
|
19
19
|
dir = 'auto',
|
|
@@ -55,7 +55,8 @@ const TextBase = /*#__PURE__*/React.forwardRef(({
|
|
|
55
55
|
ref: ref
|
|
56
56
|
}, rest, textProps), children));
|
|
57
57
|
});
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
// @ts-expect-error - `propTypes` isn't typed.
|
|
59
60
|
Text.propTypes = {
|
|
60
61
|
/**
|
|
61
62
|
* Provide a custom element type used to render the outermost node
|
|
@@ -25,9 +25,7 @@ const TextDirection = ({
|
|
|
25
25
|
}, [dir]);
|
|
26
26
|
React.useEffect(() => {
|
|
27
27
|
savedCallback.current = getTextDirection;
|
|
28
|
-
|
|
29
|
-
// `getTextDirection`?
|
|
30
|
-
});
|
|
28
|
+
}, [getTextDirection]);
|
|
31
29
|
return /*#__PURE__*/React.createElement(TextDirectionContext.TextDirectionContext.Provider, {
|
|
32
30
|
value: value
|
|
33
31
|
}, children);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import { type
|
|
7
|
+
import { type RefObject } from 'react';
|
|
8
8
|
export type TextDir = 'ltr' | 'rtl' | 'auto' | string;
|
|
9
9
|
export type GetTextDirection = (text: string | string[] | undefined) => TextDir;
|
|
10
10
|
export interface TextDirectionContextType {
|
|
11
11
|
direction: TextDir;
|
|
12
|
-
getTextDirection:
|
|
12
|
+
getTextDirection: RefObject<GetTextDirection | undefined>;
|
|
13
13
|
}
|
|
14
14
|
export declare const TextDirectionContext: import("react").Context<TextDirectionContextType>;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
8
|
export interface ToggleSkeletonProps {
|
|
9
9
|
'aria-label'?: string;
|
|
10
10
|
className?: string;
|
|
11
11
|
}
|
|
12
|
-
declare const ToggleSkeleton:
|
|
12
|
+
declare const ToggleSkeleton: {
|
|
13
|
+
({ className, ...rest }: ToggleSkeletonProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
propTypes: {
|
|
15
|
+
'aria-label': PropTypes.Requireable<string>;
|
|
16
|
+
className: PropTypes.Requireable<string>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
13
19
|
export default ToggleSkeleton;
|
|
14
20
|
export { ToggleSkeleton };
|
|
@@ -188,7 +188,6 @@ Toggletip.propTypes = {
|
|
|
188
188
|
* `ToggletipButton` controls the visibility of the Toggletip through mouse
|
|
189
189
|
* clicks and keyboard interactions.
|
|
190
190
|
*/
|
|
191
|
-
|
|
192
191
|
const ToggletipButton = /*#__PURE__*/React.forwardRef(function ToggletipButton({
|
|
193
192
|
children,
|
|
194
193
|
className: customClassName,
|
|
@@ -229,15 +228,18 @@ ToggletipButton.propTypes = {
|
|
|
229
228
|
label: PropTypes.string
|
|
230
229
|
};
|
|
231
230
|
ToggletipButton.displayName = 'ToggletipButton';
|
|
231
|
+
const frFn = React.forwardRef;
|
|
232
|
+
|
|
232
233
|
/**
|
|
233
234
|
* `ToggletipContent` is a wrapper around `PopoverContent`. It places the
|
|
234
235
|
* `children` passed in as a prop inside of `PopoverContent` so that they will
|
|
235
236
|
* be rendered inside of the popover for this component.
|
|
236
237
|
*/
|
|
237
|
-
const ToggletipContent =
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
const ToggletipContent = frFn((props, ref) => {
|
|
239
|
+
const {
|
|
240
|
+
children,
|
|
241
|
+
className: customClassName
|
|
242
|
+
} = props;
|
|
241
243
|
const toggletip = useToggletip();
|
|
242
244
|
const prefix = usePrefix.usePrefix();
|
|
243
245
|
return /*#__PURE__*/React.createElement(index.PopoverContent, _rollupPluginBabelHelpers.extends({
|