@carbon/react 1.57.0-rc.0 → 1.57.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.
Files changed (52) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +971 -936
  2. package/es/components/ComboBox/ComboBox.js +1 -0
  3. package/es/components/ContainedList/ContainedList.d.ts +7 -3
  4. package/es/components/ContainedList/ContainedList.js +3 -2
  5. package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -2
  6. package/es/components/ContainedList/ContainedListItem/index.d.ts +9 -0
  7. package/es/components/ContainedList/index.d.ts +11 -0
  8. package/es/components/ContainedList/index.js +13 -0
  9. package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +51 -0
  10. package/es/components/DatePicker/DatePicker.d.ts +5 -4
  11. package/es/components/DatePicker/plugins/rangePlugin.js +5 -6
  12. package/es/components/Dialog/index.d.ts +31 -0
  13. package/es/components/ListBox/next/ListBoxTrigger.js +4 -3
  14. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +177 -0
  15. package/es/components/MultiSelect/FilterableMultiSelect.js +388 -313
  16. package/es/components/MultiSelect/MultiSelect.js +1 -2
  17. package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +62 -0
  18. package/es/components/MultiSelect/index.d.ts +10 -0
  19. package/es/components/MultiSelect/index.js +2 -0
  20. package/es/components/Pagination/Pagination.js +9 -9
  21. package/es/components/RadioButton/RadioButton.d.ts +4 -0
  22. package/es/components/RadioButton/RadioButton.js +7 -1
  23. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +4 -0
  24. package/es/components/RadioButtonGroup/RadioButtonGroup.js +7 -1
  25. package/es/components/TimePicker/TimePicker.js +1 -1
  26. package/es/index.js +3 -1
  27. package/lib/components/ComboBox/ComboBox.js +1 -0
  28. package/lib/components/ContainedList/ContainedList.d.ts +7 -3
  29. package/lib/components/ContainedList/ContainedList.js +3 -2
  30. package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -2
  31. package/lib/components/ContainedList/ContainedListItem/index.d.ts +9 -0
  32. package/lib/components/ContainedList/index.d.ts +11 -0
  33. package/lib/components/ContainedList/index.js +19 -0
  34. package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +51 -0
  35. package/lib/components/DatePicker/DatePicker.d.ts +5 -4
  36. package/lib/components/DatePicker/plugins/rangePlugin.js +5 -6
  37. package/lib/components/Dialog/index.d.ts +31 -0
  38. package/lib/components/ListBox/next/ListBoxTrigger.js +4 -3
  39. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +177 -0
  40. package/lib/components/MultiSelect/FilterableMultiSelect.js +387 -312
  41. package/lib/components/MultiSelect/MultiSelect.js +1 -2
  42. package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +62 -0
  43. package/lib/components/MultiSelect/index.d.ts +10 -0
  44. package/lib/components/MultiSelect/index.js +2 -0
  45. package/lib/components/Pagination/Pagination.js +9 -9
  46. package/lib/components/RadioButton/RadioButton.d.ts +4 -0
  47. package/lib/components/RadioButton/RadioButton.js +7 -1
  48. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +4 -0
  49. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +7 -1
  50. package/lib/components/TimePicker/TimePicker.js +1 -1
  51. package/lib/index.js +4 -2
  52. package/package.json +7 -7
@@ -439,6 +439,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
439
439
  onClearSelection: handleSelectionClear,
440
440
  selectionCount: 0
441
441
  }), /*#__PURE__*/React__default.createElement(ListBoxTrigger, _extends({}, buttonProps, {
442
+ // @ts-expect-error
442
443
  isOpen: isOpen,
443
444
  translateWithId: translateWithId
444
445
  }))), normalizedSlug, /*#__PURE__*/React__default.createElement(ListBox.Menu, getMenuProps({
@@ -5,9 +5,13 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import React, { ReactNode } from 'react';
8
+ import ContainedListItem from './ContainedListItem';
8
9
  declare const variants: readonly ["on-page", "disclosed"];
9
- type Variants = (typeof variants)[number];
10
- interface ContainedListProps {
10
+ interface ContainedListType extends React.FC<ContainedListProps> {
11
+ ContainedListItem: typeof ContainedListItem;
12
+ }
13
+ export type Variants = (typeof variants)[number];
14
+ export interface ContainedListProps {
11
15
  /**
12
16
  * A slot for a possible interactive element to render.
13
17
  */
@@ -37,5 +41,5 @@ interface ContainedListProps {
37
41
  */
38
42
  size?: 'sm' | 'md' | 'lg' | 'xl';
39
43
  }
40
- declare const ContainedList: React.FC<ContainedListProps>;
44
+ declare const ContainedList: ContainedListType;
41
45
  export default ContainedList;
@@ -12,6 +12,7 @@ import cx from 'classnames';
12
12
  import { LayoutConstraint } from '../Layout/index.js';
13
13
  import { useId } from '../../internal/useId.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
+ import ContainedListItem from './ContainedListItem/ContainedListItem.js';
15
16
 
16
17
  const variants = ['on-page', 'disclosed'];
17
18
  function filterChildren(children) {
@@ -130,6 +131,6 @@ ContainedList.propTypes = {
130
131
  */
131
132
  size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl'])
132
133
  };
133
- var ContainedList$1 = ContainedList;
134
+ ContainedList.ContainedListItem = ContainedListItem;
134
135
 
135
- export { ContainedList$1 as default };
136
+ export { ContainedList as default };
@@ -76,6 +76,5 @@ ContainedListItem.propTypes = {
76
76
  // @ts-expect-error: PropTypes are not expressive enough to cover this case
77
77
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
78
78
  };
79
- var ContainedListItem$1 = ContainedListItem;
80
79
 
81
- export { ContainedListItem$1 as default };
80
+ export { ContainedListItem as default };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022
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 ContainedListItem from './ContainedListItem';
8
+ export default ContainedListItem;
9
+ export { ContainedListItem };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022
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 ContainedList from './ContainedList';
8
+ import ContainedListItem from './ContainedListItem';
9
+ export { ContainedListItem };
10
+ export default ContainedList;
11
+ export { ContainedList };
@@ -0,0 +1,13 @@
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
+ import ContainedList from './ContainedList.js';
9
+ export { default as ContainedList, default } from './ContainedList.js';
10
+ import ContainedListItem from './ContainedListItem/ContainedListItem.js';
11
+ export { default as ContainedListItem } from './ContainedListItem/ContainedListItem.js';
12
+
13
+ ContainedList.ContainedListItem = ContainedListItem;
@@ -0,0 +1,51 @@
1
+ import { ChangeEvent } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ export type PopoverAlignment = 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start';
4
+ interface TableToolbarFilterProps {
5
+ /**
6
+ * Specify how the popover should align with the trigger element
7
+ */
8
+ align?: PopoverAlignment;
9
+ /**
10
+ * Provide an optional class name for the toolbar filter
11
+ */
12
+ className?: string;
13
+ /**
14
+ * Provide an optional hook that is called each time the input is updated
15
+ */
16
+ onChange?: (event: '' | ChangeEvent<HTMLInputElement>, value?: string) => void;
17
+ /**
18
+ * Provide an function that is called when the apply button is clicked
19
+ */
20
+ onApplyFilter?: (selectedCheckboxes: Array<string>) => void;
21
+ /**
22
+ * Provide an function that is called when the reset button is clicked
23
+ */
24
+ onResetFilter?: () => void;
25
+ }
26
+ declare const TableToolbarFilter: {
27
+ ({ align, onApplyFilter, onResetFilter, className, ...rest }: TableToolbarFilterProps): import("react/jsx-runtime").JSX.Element;
28
+ propTypes: {
29
+ /**
30
+ * Specify how the popover should align with the trigger element
31
+ */
32
+ align: PropTypes.Requireable<string>;
33
+ /**
34
+ * Provide an optional class name for the search container
35
+ */
36
+ className: PropTypes.Requireable<string>;
37
+ /**
38
+ * Provide an function that is called when the apply button is clicked
39
+ */
40
+ onApplyFilter: PropTypes.Requireable<(...args: any[]) => any>;
41
+ /**
42
+ * Provide an optional hook that is called each time the input is updated
43
+ */
44
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
45
+ /**
46
+ * Provide an function that is called when the reset button is clicked
47
+ */
48
+ onResetFilter: PropTypes.Requireable<(...args: any[]) => any>;
49
+ };
50
+ };
51
+ export default TableToolbarFilter;
@@ -7,6 +7,7 @@
7
7
  import { ReactNodeLike } from 'prop-types';
8
8
  import React from 'react';
9
9
  import flatpickr from 'flatpickr';
10
+ import { DateLimit, DateOption } from 'flatpickr/dist/types/options';
10
11
  export type DatePickerTypes = 'simple' | 'single' | 'range';
11
12
  export type CalRef = {
12
13
  inline: boolean;
@@ -57,11 +58,11 @@ interface DatePickerProps {
57
58
  /**
58
59
  * The flatpickr `disable` option that allows a user to disable certain dates.
59
60
  */
60
- disable?: string[];
61
+ disable?: DateLimit<DateOption>[];
61
62
  /**
62
63
  * The flatpickr `enable` option that allows a user to enable certain dates.
63
64
  */
64
- enable?: string[];
65
+ enable?: DateLimit<DateOption>[];
65
66
  /**
66
67
  * The flatpickr `inline` option.
67
68
  */
@@ -85,11 +86,11 @@ interface DatePickerProps {
85
86
  /**
86
87
  * The maximum date that a user can pick to.
87
88
  */
88
- maxDate?: string | number;
89
+ maxDate?: DateOption;
89
90
  /**
90
91
  * The minimum date that a user can start picking from.
91
92
  */
92
- minDate?: string | number;
93
+ minDate?: DateOption;
93
94
  /**
94
95
  * The `change` event handler.
95
96
  */
@@ -27,14 +27,13 @@ var carbonFlatpickrRangePlugin = (config => {
27
27
  // where Flatpickr's range plugin takes care of fixing the first `<input>`
28
28
  if (!triggerChange) {
29
29
  const {
30
- _input: inputFrom
30
+ _input: inputDates
31
31
  } = fp;
32
- const {
33
- input: inputTo
34
- } = config;
35
- [inputFrom, inputTo].forEach((input, i) => {
32
+ const inputDatesArray = inputDates.value.split(' ');
33
+ fp.close();
34
+ [inputDatesArray[0], inputDatesArray[2]].forEach((input, i) => {
36
35
  if (input) {
37
- input.value = !dates[i] ? '' : fp.formatDate(new Date(dates[i]), fp.config.dateFormat);
36
+ input = !dates[i] ? '' : fp.formatDate(new Date(dates[i]), fp.config.dateFormat);
38
37
  }
39
38
  });
40
39
  }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright IBM Corp. 2014, 2024
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 'wicg-inert';
8
+ import React from 'react';
9
+ import { ReactAttr } from '../../types/common';
10
+ export interface DialogProps extends ReactAttr<HTMLDialogElement> {
11
+ /**
12
+ * Provide the contents of the Dialog
13
+ */
14
+ children?: React.ReactNode;
15
+ /**
16
+ * Specifies whether the dialog is modal or non-modal
17
+ */
18
+ modal?: boolean;
19
+ /**
20
+ * Specify a handler for closing Dialog.
21
+ * The handler should care of closing Dialog, e.g. changing `open` prop.
22
+ */
23
+ onRequestClose?: React.ReactEventHandler<HTMLElement>;
24
+ /**
25
+ * Specify whether the Dialog is currently open
26
+ */
27
+ open?: boolean;
28
+ }
29
+ declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<unknown>>;
30
+ export { Dialog };
31
+ export default Dialog;
@@ -27,7 +27,7 @@ const defaultTranslateWithId = id => defaultTranslations[id];
27
27
  * `ListBoxTrigger` is used to orient the icon up or down depending on the
28
28
  * state of the menu for a given `ListBox`
29
29
  */
30
- const ListBoxTrigger = _ref => {
30
+ const ListBoxTrigger = /*#__PURE__*/React__default.forwardRef(function ListBoxTrigger(_ref, ref) {
31
31
  let {
32
32
  isOpen,
33
33
  translateWithId: t = defaultTranslateWithId,
@@ -44,9 +44,10 @@ const ListBoxTrigger = _ref => {
44
44
  title: description,
45
45
  className: className,
46
46
  type: "button",
47
- tabIndex: "-1"
47
+ tabIndex: "-1",
48
+ ref: ref
48
49
  }), _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default.createElement(ChevronDown, null)));
49
- };
50
+ });
50
51
  ListBoxTrigger.propTypes = {
51
52
  /**
52
53
  * Specify whether the menu is currently open, which will influence the
@@ -0,0 +1,177 @@
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
+ import { type UseComboboxProps, type UseMultipleSelectionProps } from 'downshift';
8
+ import { ReactNodeLike } from 'prop-types';
9
+ import { ReactNode, FunctionComponent, ReactElement } from 'react';
10
+ import { type ItemBase, type SortingPropTypes } from './MultiSelectPropTypes';
11
+ export interface FilterableMultiSelectProps<Item extends ItemBase> extends SortingPropTypes<Item> {
12
+ /**
13
+ * Specify a label to be read by screen readers on the container node
14
+ * @deprecated
15
+ */
16
+ 'aria-label'?: string;
17
+ /** @deprecated */
18
+ ariaLabel?: string;
19
+ className?: string;
20
+ /**
21
+ * Specify the text that should be read for screen readers that describes total items selected
22
+ */
23
+ clearSelectionDescription?: string;
24
+ /**
25
+ * Specify the text that should be read for screen readers to clear selection.
26
+ */
27
+ clearSelectionText?: string;
28
+ /**
29
+ * Specify the direction of the multiselect dropdown.
30
+ */
31
+ direction?: 'top' | 'bottom';
32
+ /**
33
+ * Disable the control
34
+ */
35
+ disabled?: boolean;
36
+ /**
37
+ * Additional props passed to Downshift
38
+ */
39
+ downshiftProps?: UseMultipleSelectionProps<Item>;
40
+ /**
41
+ * Default sorter is assigned if not provided.
42
+ */
43
+ filterItems(items: readonly Item[], extra: {
44
+ inputValue: string | null;
45
+ itemToString: NonNullable<UseMultipleSelectionProps<Item>['itemToString']>;
46
+ }): Item[];
47
+ /**
48
+ * Specify whether the title text should be hidden or not
49
+ */
50
+ hideLabel?: boolean;
51
+ /**
52
+ * Provide helper text that is used alongside
53
+ * the control label for additional help
54
+ */
55
+ helperText?: ReactNode;
56
+ /**
57
+ * Specify a custom `id`
58
+ */
59
+ id: string;
60
+ /**
61
+ * Allow users to pass in arbitrary items from their collection that are
62
+ * pre-selected
63
+ */
64
+ initialSelectedItems?: Item[];
65
+ /**
66
+ * Is the current selection invalid?
67
+ */
68
+ invalid?: boolean;
69
+ /**
70
+ * If invalid, what is the error?
71
+ */
72
+ invalidText?: ReactNode;
73
+ /**
74
+ * Function to render items as custom components instead of strings.
75
+ * Defaults to null and is overridden by a getter
76
+ */
77
+ itemToElement?: FunctionComponent<Item>;
78
+ /**
79
+ * Helper function passed to downshift that allows the library to render
80
+ * a given item to a string label.
81
+ *
82
+ * By default, it extracts the `label` field from a given item
83
+ * to serve as the item label in the list.
84
+ */
85
+ itemToString?(item: Item | null): string;
86
+ /**
87
+ * We try to stay as generic as possible here to allow individuals to pass
88
+ * in a collection of whatever kind of data structure they prefer
89
+ */
90
+ items: Item[];
91
+ /**
92
+ * @deprecated `true` to use the light version.
93
+ */
94
+ light?: boolean;
95
+ /**
96
+ * Specify the locale of the control.
97
+ * Used for the default `compareItems`,
98
+ * which is used for sorting the list of items in the control.
99
+ */
100
+ locale?: string;
101
+ /**
102
+ * `onChange` is a utility for this controlled component to communicate to a
103
+ * consuming component what kind of internal state changes are occurring.
104
+ */
105
+ onChange?(changes: {
106
+ selectedItems: Item[];
107
+ }): void;
108
+ /**
109
+ * A utility for this controlled component
110
+ * to communicate to the currently typed input.
111
+ */
112
+ onInputValueChange?: UseComboboxProps<Item>['onInputValueChange'];
113
+ /**
114
+ * `onMenuChange` is a utility for this controlled component to communicate to a
115
+ * consuming component that the menu was opened(`true`)/closed(`false`).
116
+ */
117
+ onMenuChange?(open: boolean): void;
118
+ /**
119
+ * Initialize the component with an open(`true`)/closed(`false`) menu.
120
+ */
121
+ open?: boolean;
122
+ /**
123
+ * Generic `placeholder` that will be used as the textual representation of
124
+ * what this field is for
125
+ */
126
+ placeholder?: string;
127
+ /**
128
+ * Specify feedback (mode) of the selection.
129
+ * `top`: selected item jumps to top
130
+ * `fixed`: selected item stays at its position
131
+ * `top-after-reopen`: selected item jump to top after reopen dropdown
132
+ */
133
+ selectionFeedback?: 'top' | 'fixed' | 'top-after-reopen';
134
+ /**
135
+ * For full control of the selected items
136
+ */
137
+ selectedItems?: Item[];
138
+ /**
139
+ * Specify the size of the ListBox.
140
+ * Currently, supports either `sm`, `md` or `lg` as an option.
141
+ */
142
+ size?: 'sm' | 'md' | 'lg';
143
+ /**
144
+ * **Experimental**: Provide a `Slug` component to be rendered inside the `Checkbox` component
145
+ */
146
+ slug?: ReactNodeLike;
147
+ /**
148
+ * Provide text to be used in a `<label>` element that is tied to the
149
+ * combobox via ARIA attributes.
150
+ */
151
+ titleText?: ReactNode;
152
+ /**
153
+ * Callback function for translating ListBoxMenuIcon SVG title
154
+ */
155
+ translateWithId?(messageId: string, args?: Record<string, unknown>): string;
156
+ type?: 'default' | 'inline';
157
+ /**
158
+ * Specify title to show title on hover
159
+ */
160
+ useTitleInItem?: boolean;
161
+ /**
162
+ * Specify whether the control is currently in warning state
163
+ */
164
+ warn?: boolean;
165
+ /**
166
+ * Provide the text that is displayed when the control is in warning state
167
+ */
168
+ warnText?: ReactNode;
169
+ }
170
+ declare const FilterableMultiSelect: {
171
+ <Item extends ItemBase>(props: FilterableMultiSelectProps<Item>): ReactElement;
172
+ propTypes?: any;
173
+ contextTypes?: any;
174
+ defaultProps?: any;
175
+ displayName?: any;
176
+ };
177
+ export default FilterableMultiSelect;