@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
|
@@ -14,12 +14,12 @@ import { deprecate } from '../../prop-types/deprecate.js';
|
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import '../FluidForm/FluidForm.js';
|
|
16
16
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
17
|
-
import { useId } from '../../internal/useId.js';
|
|
18
17
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
19
18
|
import { Text } from '../Text/Text.js';
|
|
20
19
|
import '../Text/TextDirection.js';
|
|
21
20
|
import { AILabel } from '../AILabel/index.js';
|
|
22
21
|
import { isComponentElement } from '../../internal/utils.js';
|
|
22
|
+
import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
|
|
23
23
|
|
|
24
24
|
const Select = /*#__PURE__*/React.forwardRef(({
|
|
25
25
|
className,
|
|
@@ -49,7 +49,6 @@ const Select = /*#__PURE__*/React.forwardRef(({
|
|
|
49
49
|
isFluid
|
|
50
50
|
} = useContext(FormContext);
|
|
51
51
|
const [isFocused, setIsFocused] = useState(false);
|
|
52
|
-
const selectInstanceId = useId();
|
|
53
52
|
// Convert children to an array of valid elements once using type narrowing
|
|
54
53
|
const validChildren = React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child));
|
|
55
54
|
|
|
@@ -61,55 +60,50 @@ const Select = /*#__PURE__*/React.forwardRef(({
|
|
|
61
60
|
// otherwise, fallback to the first option's text
|
|
62
61
|
const initialTitle = other?.title || selectedOption?.props?.text || validChildren[0]?.props?.text || '';
|
|
63
62
|
const [title, setTitle] = useState(initialTitle);
|
|
63
|
+
const normalizedProps = useNormalizedInputProps({
|
|
64
|
+
id,
|
|
65
|
+
disabled,
|
|
66
|
+
readOnly,
|
|
67
|
+
invalid,
|
|
68
|
+
invalidText,
|
|
69
|
+
warn,
|
|
70
|
+
warnText
|
|
71
|
+
});
|
|
64
72
|
const selectClasses = cx({
|
|
65
73
|
[`${prefix}--select`]: true,
|
|
66
74
|
[`${prefix}--select--inline`]: inline,
|
|
67
75
|
[`${prefix}--select--light`]: light,
|
|
68
|
-
[`${prefix}--select--invalid`]: invalid,
|
|
69
|
-
[`${prefix}--select--disabled`]: disabled,
|
|
76
|
+
[`${prefix}--select--invalid`]: normalizedProps.invalid,
|
|
77
|
+
[`${prefix}--select--disabled`]: normalizedProps.disabled,
|
|
70
78
|
[`${prefix}--select--readonly`]: readOnly,
|
|
71
|
-
[`${prefix}--select--warning`]: warn,
|
|
72
|
-
[`${prefix}--select--fluid--invalid`]: isFluid && invalid,
|
|
79
|
+
[`${prefix}--select--warning`]: normalizedProps.warn,
|
|
80
|
+
[`${prefix}--select--fluid--invalid`]: isFluid && normalizedProps.invalid,
|
|
73
81
|
[`${prefix}--select--fluid--focus`]: isFluid && isFocused,
|
|
74
82
|
[`${prefix}--select--slug`]: slug,
|
|
75
83
|
[`${prefix}--select--decorator`]: decorator
|
|
76
84
|
});
|
|
77
85
|
const labelClasses = cx(`${prefix}--label`, {
|
|
78
86
|
[`${prefix}--visually-hidden`]: hideLabel,
|
|
79
|
-
[`${prefix}--label--disabled`]: disabled
|
|
87
|
+
[`${prefix}--label--disabled`]: normalizedProps.disabled
|
|
80
88
|
});
|
|
81
89
|
const inputClasses = cx({
|
|
82
90
|
[`${prefix}--select-input`]: true,
|
|
83
91
|
[`${prefix}--select-input--${size}`]: size
|
|
84
92
|
});
|
|
85
|
-
const
|
|
86
|
-
const errorText = (() => {
|
|
87
|
-
if (invalid) {
|
|
88
|
-
return invalidText;
|
|
89
|
-
}
|
|
90
|
-
if (warn) {
|
|
91
|
-
return warnText;
|
|
92
|
-
}
|
|
93
|
-
})();
|
|
94
|
-
const error = invalid || warn ? /*#__PURE__*/React.createElement(Text, {
|
|
95
|
-
as: "div",
|
|
96
|
-
className: `${prefix}--form-requirement`,
|
|
97
|
-
id: errorId
|
|
98
|
-
}, errorText) : null;
|
|
93
|
+
const error = normalizedProps.validation;
|
|
99
94
|
const helperTextClasses = cx(`${prefix}--form__helper-text`, {
|
|
100
|
-
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
95
|
+
[`${prefix}--form__helper-text--disabled`]: normalizedProps.disabled
|
|
101
96
|
});
|
|
102
|
-
const helperId = !helperText ? undefined : `select-helper-text-${selectInstanceId}`;
|
|
103
97
|
const helper = helperText ? /*#__PURE__*/React.createElement(Text, {
|
|
104
98
|
as: "div",
|
|
105
|
-
id: helperId,
|
|
99
|
+
id: normalizedProps.helperId,
|
|
106
100
|
className: helperTextClasses
|
|
107
101
|
}, helperText) : null;
|
|
108
102
|
const ariaProps = {};
|
|
109
|
-
if (invalid) {
|
|
110
|
-
ariaProps['aria-describedby'] =
|
|
103
|
+
if (normalizedProps.invalid) {
|
|
104
|
+
ariaProps['aria-describedby'] = normalizedProps.invalidId;
|
|
111
105
|
} else if (!inline && !isFluid) {
|
|
112
|
-
ariaProps['aria-describedby'] = helper ? helperId : undefined;
|
|
106
|
+
ariaProps['aria-describedby'] = helper ? normalizedProps.helperId : undefined;
|
|
113
107
|
}
|
|
114
108
|
const handleFocus = evt => {
|
|
115
109
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
@@ -146,8 +140,8 @@ const Select = /*#__PURE__*/React.forwardRef(({
|
|
|
146
140
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", _extends({}, other, ariaProps, {
|
|
147
141
|
id: id,
|
|
148
142
|
className: inputClasses,
|
|
149
|
-
disabled: disabled || undefined,
|
|
150
|
-
"aria-invalid": invalid || undefined,
|
|
143
|
+
disabled: normalizedProps.disabled || undefined,
|
|
144
|
+
"aria-invalid": normalizedProps.invalid || undefined,
|
|
151
145
|
"aria-readonly": readOnly || undefined,
|
|
152
146
|
title: title,
|
|
153
147
|
onChange: composeEventHandlers([onChange, handleChange])
|
|
@@ -155,9 +149,9 @@ const Select = /*#__PURE__*/React.forwardRef(({
|
|
|
155
149
|
ref: ref
|
|
156
150
|
}), children), /*#__PURE__*/React.createElement(ChevronDown, {
|
|
157
151
|
className: `${prefix}--select__arrow`
|
|
158
|
-
}), invalid && /*#__PURE__*/React.createElement(WarningFilled, {
|
|
152
|
+
}), normalizedProps.invalid && /*#__PURE__*/React.createElement(WarningFilled, {
|
|
159
153
|
className: `${prefix}--select__invalid-icon`
|
|
160
|
-
}), !invalid && warn && /*#__PURE__*/React.createElement(WarningAltFilled, {
|
|
154
|
+
}), !normalizedProps.invalid && normalizedProps.warn && /*#__PURE__*/React.createElement(WarningAltFilled, {
|
|
161
155
|
className: `${prefix}--select__invalid-icon ${prefix}--select__invalid-icon--warning`
|
|
162
156
|
}));
|
|
163
157
|
})();
|
|
@@ -173,10 +167,10 @@ const Select = /*#__PURE__*/React.forwardRef(({
|
|
|
173
167
|
className: `${prefix}--select-input--inline__wrapper`
|
|
174
168
|
}, /*#__PURE__*/React.createElement("div", {
|
|
175
169
|
className: `${prefix}--select-input__wrapper`,
|
|
176
|
-
"data-invalid": invalid || null
|
|
170
|
+
"data-invalid": normalizedProps.invalid || null
|
|
177
171
|
}, input), error), !inline && /*#__PURE__*/React.createElement("div", {
|
|
178
172
|
className: `${prefix}--select-input__wrapper`,
|
|
179
|
-
"data-invalid": invalid || null,
|
|
173
|
+
"data-invalid": normalizedProps.invalid || null,
|
|
180
174
|
onFocus: handleFocus,
|
|
181
175
|
onBlur: handleFocus
|
|
182
176
|
}, input, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -282,4 +282,4 @@ ToggletipActions.propTypes = {
|
|
|
282
282
|
className: PropTypes.string
|
|
283
283
|
};
|
|
284
284
|
|
|
285
|
-
export { Toggletip, ToggletipActions, ToggletipButton, ToggletipContent, ToggletipLabel };
|
|
285
|
+
export { Toggletip, ToggletipActions, ToggletipButton, ToggletipContent, ToggletipLabel, Toggletip as default };
|
|
@@ -4,6 +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 { DefinitionTooltip } from './DefinitionTooltip';
|
|
7
|
+
import { DefinitionTooltip, type DefinitionTooltipProps } from './DefinitionTooltip';
|
|
8
8
|
import { Tooltip, type TooltipProps } from './Tooltip';
|
|
9
|
-
export { DefinitionTooltip, Tooltip, type TooltipProps };
|
|
9
|
+
export { DefinitionTooltip, Tooltip, type DefinitionTooltipProps, type TooltipProps, };
|
|
10
|
+
export default Tooltip;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import React, { useContext, useState, useRef, useCallback, useEffect, cloneElement } from 'react';
|
|
9
9
|
import * as FeatureFlags from '@carbon/feature-flags';
|
|
10
10
|
import ReactDOM from 'react-dom';
|
|
11
|
-
import window from 'window-or-global';
|
|
12
11
|
import { Tab } from './keyboard/keys.js';
|
|
13
12
|
import { match } from './keyboard/match.js';
|
|
14
13
|
import { selectorTabbable, selectorFocusable } from './keyboard/navigation.js';
|
|
@@ -109,14 +108,16 @@ const FloatingMenu = ({
|
|
|
109
108
|
const menuSize = menuBody.getBoundingClientRect();
|
|
110
109
|
const refPosition = triggerEl ? triggerEl.getBoundingClientRect() : undefined;
|
|
111
110
|
const offsetValue = typeof menuOffset === 'function' ? menuOffset(menuBody, menuDirection, triggerEl, flipped) : menuOffset;
|
|
111
|
+
const scrollX = globalThis.scrollX ?? 0;
|
|
112
|
+
const scrollY = globalThis.scrollY ?? 0;
|
|
112
113
|
if (updateOrientation) {
|
|
113
114
|
updateOrientation({
|
|
114
115
|
menuSize,
|
|
115
116
|
refPosition,
|
|
116
117
|
direction: menuDirection,
|
|
117
118
|
offset: offsetValue,
|
|
118
|
-
scrollX
|
|
119
|
-
scrollY
|
|
119
|
+
scrollX,
|
|
120
|
+
scrollY,
|
|
120
121
|
container: {
|
|
121
122
|
rect: target().getBoundingClientRect(),
|
|
122
123
|
position: getComputedStyle(target()).position
|
|
@@ -136,8 +137,8 @@ const FloatingMenu = ({
|
|
|
136
137
|
},
|
|
137
138
|
offset: offsetValue,
|
|
138
139
|
direction: menuDirection,
|
|
139
|
-
scrollX
|
|
140
|
-
scrollY
|
|
140
|
+
scrollX,
|
|
141
|
+
scrollY,
|
|
141
142
|
container: {
|
|
142
143
|
rect: target().getBoundingClientRect(),
|
|
143
144
|
position: getComputedStyle(target()).position
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// mdn resize function
|
|
8
|
+
// Use `globalThis` for universal access to global object (browser, workers, Node).
|
|
9
|
+
const win = globalThis;
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* A callback function to be executed on `resize`.
|
|
@@ -25,7 +24,7 @@ const OptimizedResize = (() => {
|
|
|
25
24
|
const handleResize = () => {
|
|
26
25
|
if (!running) {
|
|
27
26
|
running = true;
|
|
28
|
-
|
|
27
|
+
win.requestAnimationFrame(runCallbacks);
|
|
29
28
|
}
|
|
30
29
|
};
|
|
31
30
|
const addCallback = callback => {
|
|
@@ -38,7 +37,7 @@ const OptimizedResize = (() => {
|
|
|
38
37
|
/** Adds a callback function to be executed on window `resize`. */
|
|
39
38
|
add: callback => {
|
|
40
39
|
if (!callbacks.length) {
|
|
41
|
-
|
|
40
|
+
win.addEventListener('resize', handleResize);
|
|
42
41
|
}
|
|
43
42
|
addCallback(callback);
|
|
44
43
|
return {
|
package/es/tools/events.d.ts
CHANGED
|
@@ -14,4 +14,4 @@ import type { SyntheticEvent } from 'react';
|
|
|
14
14
|
* @param handlers - An array of event handler functions.
|
|
15
15
|
* @returns A composite event handler.
|
|
16
16
|
*/
|
|
17
|
-
export declare const composeEventHandlers: <E extends SyntheticEvent = SyntheticEvent
|
|
17
|
+
export declare const composeEventHandlers: <E extends SyntheticEvent = SyntheticEvent<Element, Event>>(handlers: (((event: E, ...args: any[]) => void) | undefined)[]) => (event: E, ...args: any[]) => void;
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
export interface ButtonSetProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
/**
|
|
10
|
+
* fluid: button set resize to the size of the container up to a maximum dependant on the
|
|
11
|
+
* number of buttons. Overrides `stacked` property.
|
|
12
|
+
*/
|
|
13
|
+
fluid?: boolean;
|
|
9
14
|
/**
|
|
10
15
|
* Specify the button arrangement of the set (vertically stacked or
|
|
11
16
|
* horizontal)
|
|
@@ -14,22 +14,81 @@ var React = require('react');
|
|
|
14
14
|
var PropTypes = require('prop-types');
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
|
+
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
17
18
|
|
|
19
|
+
const buttonOrder = kind => ({
|
|
20
|
+
ghost: 1,
|
|
21
|
+
'danger--ghost': 2,
|
|
22
|
+
tertiary: 3,
|
|
23
|
+
danger: 5,
|
|
24
|
+
primary: 6
|
|
25
|
+
})[kind] ?? 4;
|
|
26
|
+
const getButtonKind = element => {
|
|
27
|
+
if (/*#__PURE__*/React.isValidElement(element) && element.props && typeof element.props === 'object') {
|
|
28
|
+
const props = element.props;
|
|
29
|
+
return props.kind ?? 'primary';
|
|
30
|
+
}
|
|
31
|
+
return 'primary';
|
|
32
|
+
};
|
|
18
33
|
const ButtonSet = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
19
34
|
const {
|
|
20
35
|
children,
|
|
21
36
|
className,
|
|
37
|
+
fluid,
|
|
22
38
|
stacked,
|
|
23
39
|
...rest
|
|
24
40
|
} = props;
|
|
25
41
|
const prefix = usePrefix.usePrefix();
|
|
42
|
+
const fluidInnerRef = React.useRef(null);
|
|
43
|
+
const [isStacked, setIsStacked] = React.useState(false);
|
|
44
|
+
const [sortedChildren, setSortedChildren] = React.useState(React.Children.toArray(children));
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Used to determine if the buttons are currently stacked
|
|
48
|
+
*/
|
|
49
|
+
useIsomorphicEffect.default(() => {
|
|
50
|
+
const checkStacking = () => {
|
|
51
|
+
let newIsStacked = stacked || false;
|
|
52
|
+
if (fluidInnerRef && fluidInnerRef.current) {
|
|
53
|
+
const computedStyle = window.getComputedStyle(fluidInnerRef.current);
|
|
54
|
+
newIsStacked = computedStyle?.getPropertyValue?.('--flex-direction') === 'column';
|
|
55
|
+
}
|
|
56
|
+
return newIsStacked;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/* initial value not dependant on observer */
|
|
60
|
+
setIsStacked(checkStacking());
|
|
61
|
+
if (!fluidInnerRef.current) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
65
|
+
setIsStacked(checkStacking());
|
|
66
|
+
});
|
|
67
|
+
resizeObserver.observe(fluidInnerRef.current);
|
|
68
|
+
return () => resizeObserver.disconnect();
|
|
69
|
+
}, [isStacked, stacked]);
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
const newSortedChildren = React.Children.toArray(children);
|
|
72
|
+
newSortedChildren.sort((a, b) => {
|
|
73
|
+
return (buttonOrder(getButtonKind(a)) - buttonOrder(getButtonKind(b))) * (isStacked ? -1 : 1);
|
|
74
|
+
});
|
|
75
|
+
setSortedChildren(newSortedChildren);
|
|
76
|
+
|
|
77
|
+
// adding sortedChildren to deps causes an infinite loop
|
|
78
|
+
}, [children, isStacked]);
|
|
26
79
|
const buttonSetClasses = cx(className, `${prefix}--btn-set`, {
|
|
27
|
-
[`${prefix}--btn-set--stacked`]:
|
|
80
|
+
[`${prefix}--btn-set--stacked`]: isStacked,
|
|
81
|
+
[`${prefix}--btn-set--fluid`]: fluid
|
|
28
82
|
});
|
|
29
83
|
return /*#__PURE__*/React.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
30
84
|
className: buttonSetClasses,
|
|
31
85
|
ref: ref
|
|
32
|
-
}),
|
|
86
|
+
}), fluid ? /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
ref: fluidInnerRef,
|
|
88
|
+
className: cx(`${prefix}--btn-set__fluid-inner`, {
|
|
89
|
+
[`${prefix}--btn-set__fluid-inner--auto-stack`]: true
|
|
90
|
+
})
|
|
91
|
+
}, sortedChildren) : children);
|
|
33
92
|
});
|
|
34
93
|
ButtonSet.displayName = 'ButtonSet';
|
|
35
94
|
ButtonSet.propTypes = {
|
|
@@ -41,9 +100,14 @@ ButtonSet.propTypes = {
|
|
|
41
100
|
* Specify an optional className to be added to your ButtonSet
|
|
42
101
|
*/
|
|
43
102
|
className: PropTypes.string,
|
|
103
|
+
/**
|
|
104
|
+
* fluid: button set resize to the size of the container up to a maximum dependant on the
|
|
105
|
+
* number of buttons.
|
|
106
|
+
*/
|
|
107
|
+
fluid: PropTypes.bool,
|
|
44
108
|
/**
|
|
45
109
|
* Specify the button arrangement of the set (vertically stacked or
|
|
46
|
-
* horizontal)
|
|
110
|
+
* horizontal) - ignored when fluid is true
|
|
47
111
|
*/
|
|
48
112
|
stacked: PropTypes.bool
|
|
49
113
|
};
|
|
@@ -111,7 +111,7 @@ declare namespace CodeSnippet {
|
|
|
111
111
|
/**
|
|
112
112
|
* Specify how the trigger should align with the tooltip
|
|
113
113
|
*/
|
|
114
|
-
align: PropTypes.Requireable<
|
|
114
|
+
align: PropTypes.Requireable<string> | PropTypes.Validator<string>;
|
|
115
115
|
/**
|
|
116
116
|
* Specify a label to be read by screen readers on the containing textbox
|
|
117
117
|
* node
|
|
@@ -50,7 +50,7 @@ declare namespace Copy {
|
|
|
50
50
|
/**
|
|
51
51
|
* Specify how the trigger should align with the tooltip
|
|
52
52
|
*/
|
|
53
|
-
align: PropTypes.Requireable<
|
|
53
|
+
align: PropTypes.Requireable<string> | PropTypes.Validator<string>;
|
|
54
54
|
/**
|
|
55
55
|
* **Experimental**: Will attempt to automatically align the tooltip. Requires
|
|
56
56
|
* React v17+
|
|
@@ -51,7 +51,7 @@ declare namespace CopyButton {
|
|
|
51
51
|
/**
|
|
52
52
|
* Specify how the trigger should align with the tooltip
|
|
53
53
|
*/
|
|
54
|
-
align: PropTypes.Requireable<
|
|
54
|
+
align: PropTypes.Requireable<string> | PropTypes.Validator<string>;
|
|
55
55
|
/**
|
|
56
56
|
* **Experimental**: Will attempt to automatically align the tooltip. Requires
|
|
57
57
|
* React v17+
|
|
@@ -282,11 +282,12 @@ export declare const DataTable: {
|
|
|
282
282
|
};
|
|
283
283
|
TableCell: React.ForwardRefExoticComponent<import("./TableCell").TableCellProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
284
284
|
TableContainer: {
|
|
285
|
-
({ aiEnabled, className, children, title, description, stickyHeader, useStaticWidth, ...rest }: import("./TableContainer").TableContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
285
|
+
({ aiEnabled, className, children, decorator, title, description, stickyHeader, useStaticWidth, ...rest }: import("./TableContainer").TableContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
286
286
|
propTypes: {
|
|
287
287
|
aiEnabled: PropTypes.Requireable<boolean>;
|
|
288
288
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
289
289
|
className: PropTypes.Requireable<string>;
|
|
290
|
+
decorator: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
290
291
|
description: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
291
292
|
stickyHeader: PropTypes.Requireable<boolean>;
|
|
292
293
|
title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React, { type HTMLAttributes } from 'react';
|
|
8
|
+
import React, { ReactNode, type HTMLAttributes } from 'react';
|
|
9
9
|
export interface TableContainerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
10
10
|
/**
|
|
11
11
|
* Specify if the entire table has AI generated contents
|
|
12
12
|
*/
|
|
13
13
|
aiEnabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `TableContainer` component
|
|
16
|
+
*/
|
|
17
|
+
decorator?: ReactNode;
|
|
14
18
|
/**
|
|
15
19
|
* Optional description text for the Table
|
|
16
20
|
*/
|
|
@@ -29,7 +33,7 @@ export interface TableContainerProps extends Omit<HTMLAttributes<HTMLDivElement>
|
|
|
29
33
|
title?: React.ReactNode;
|
|
30
34
|
}
|
|
31
35
|
declare const TableContainer: {
|
|
32
|
-
({ aiEnabled, className, children, title, description, stickyHeader, useStaticWidth, ...rest }: TableContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
({ aiEnabled, className, children, decorator, title, description, stickyHeader, useStaticWidth, ...rest }: TableContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
33
37
|
propTypes: {
|
|
34
38
|
/**
|
|
35
39
|
* Specify if the entire table has AI generated contents
|
|
@@ -37,6 +41,10 @@ declare const TableContainer: {
|
|
|
37
41
|
aiEnabled: PropTypes.Requireable<boolean>;
|
|
38
42
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
39
43
|
className: PropTypes.Requireable<string>;
|
|
44
|
+
/**
|
|
45
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `TableContainer` component
|
|
46
|
+
*/
|
|
47
|
+
decorator: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
40
48
|
/**
|
|
41
49
|
* Optional description text for the Table
|
|
42
50
|
*/
|
|
@@ -22,6 +22,7 @@ const TableContainer = ({
|
|
|
22
22
|
aiEnabled,
|
|
23
23
|
className,
|
|
24
24
|
children,
|
|
25
|
+
decorator,
|
|
25
26
|
title,
|
|
26
27
|
description,
|
|
27
28
|
stickyHeader,
|
|
@@ -47,15 +48,22 @@ const TableContainer = ({
|
|
|
47
48
|
value: value
|
|
48
49
|
}, /*#__PURE__*/React.createElement(index.Section, _rollupPluginBabelHelpers.extends({}, rest, {
|
|
49
50
|
className: tableContainerClasses
|
|
50
|
-
}), (title || description) && /*#__PURE__*/React.createElement("div", {
|
|
51
|
-
className: `${prefix}--data-table-header
|
|
51
|
+
}), (title || description || decorator) && /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: cx(`${prefix}--data-table-header`, {
|
|
53
|
+
[`${prefix}--data-table-header__with-decorator`]: decorator,
|
|
54
|
+
[`${prefix}--data-table-header__with-decorator--standalone`]: decorator && !title && !description
|
|
55
|
+
})
|
|
56
|
+
}, (title || description) && /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: `${prefix}--data-table-header__content`
|
|
52
58
|
}, title && /*#__PURE__*/React.createElement(index.Heading, {
|
|
53
59
|
className: `${prefix}--data-table-header__title`,
|
|
54
60
|
id: titleId
|
|
55
61
|
}, title), description && /*#__PURE__*/React.createElement("p", {
|
|
56
62
|
className: `${prefix}--data-table-header__description`,
|
|
57
63
|
id: descriptionId
|
|
58
|
-
}, description)),
|
|
64
|
+
}, description)), decorator && /*#__PURE__*/React.createElement("div", {
|
|
65
|
+
className: `${prefix}--data-table-header__decorator`
|
|
66
|
+
}, decorator)), children));
|
|
59
67
|
};
|
|
60
68
|
TableContainer.propTypes = {
|
|
61
69
|
/**
|
|
@@ -64,6 +72,10 @@ TableContainer.propTypes = {
|
|
|
64
72
|
aiEnabled: PropTypes.bool,
|
|
65
73
|
children: PropTypes.node,
|
|
66
74
|
className: PropTypes.string,
|
|
75
|
+
/**
|
|
76
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `TableContainer` component
|
|
77
|
+
*/
|
|
78
|
+
decorator: PropTypes.node,
|
|
67
79
|
/**
|
|
68
80
|
* Optional description text for the Table
|
|
69
81
|
*/
|
|
@@ -43,8 +43,7 @@ export declare const getNextSortDirection: (prevHeader: string, currentHeader: s
|
|
|
43
43
|
* @param state - Current table state.
|
|
44
44
|
* @param key - Header key to sort by.
|
|
45
45
|
*/
|
|
46
|
-
export declare const getNextSortState: <ColTypes extends any[]>(
|
|
47
|
-
props: Props, state: State<ColTypes>, { key }: {
|
|
46
|
+
export declare const getNextSortState: <ColTypes extends any[]>(props: Props, state: State<ColTypes>, { key }: {
|
|
48
47
|
key: string;
|
|
49
48
|
}) => Pick<State<ColTypes>, "sortHeaderKey" | "sortDirection" | "rowIds">;
|
|
50
49
|
/**
|
|
@@ -55,6 +54,5 @@ props: Props, state: State<ColTypes>, { key }: {
|
|
|
55
54
|
* @param key - Header key to sort by.
|
|
56
55
|
* @param sortDirection - Sort direction to apply.
|
|
57
56
|
*/
|
|
58
|
-
export declare const getSortedState: <ColTypes extends any[]>(
|
|
59
|
-
{ locale, sortRow }: Props, { rowIds, cellsById, initialRowOrder }: State<ColTypes>, key: string, sortDirection: DataTableSortState) => Pick<State<ColTypes>, "rowIds" | "sortDirection" | "sortHeaderKey">;
|
|
57
|
+
export declare const getSortedState: <ColTypes extends any[]>({ locale, sortRow }: Props, { rowIds, cellsById, initialRowOrder }: State<ColTypes>, key: string, sortDirection: DataTableSortState) => Pick<State<ColTypes>, "rowIds" | "sortDirection" | "sortHeaderKey">;
|
|
60
58
|
export {};
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
8
|
import flatpickr from 'flatpickr';
|
|
9
9
|
import { DateLimit, DateOption } from 'flatpickr/dist/types/options';
|
|
10
|
+
import { type SupportedLocale } from './DatePickerLocales';
|
|
10
11
|
export type DatePickerTypes = 'simple' | 'single' | 'range';
|
|
11
12
|
export interface DatePickerProps {
|
|
12
13
|
/**
|
|
@@ -69,7 +70,7 @@ export interface DatePickerProps {
|
|
|
69
70
|
/**
|
|
70
71
|
* 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
|
|
71
72
|
*/
|
|
72
|
-
locale?: string | any |
|
|
73
|
+
locale?: string | any | SupportedLocale | undefined;
|
|
73
74
|
/**
|
|
74
75
|
* The maximum date that a user can pick to.
|
|
75
76
|
*/
|
|
@@ -99,7 +100,7 @@ export interface DatePickerProps {
|
|
|
99
100
|
* if boolean applies to all inputs
|
|
100
101
|
* if array applies to each input in order
|
|
101
102
|
*/
|
|
102
|
-
readOnly?: boolean |
|
|
103
|
+
readOnly?: boolean | undefined;
|
|
103
104
|
/**
|
|
104
105
|
* `true` to use the short version.
|
|
105
106
|
*/
|