@carbon/react 1.16.0 → 1.17.0-rc.1
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/es/components/Checkbox/Checkbox.Skeleton.d.ts +18 -0
- package/es/components/Checkbox/Checkbox.Skeleton.js +1 -2
- package/es/components/Checkbox/Checkbox.d.ts +47 -0
- package/es/components/Checkbox/Checkbox.js +6 -7
- package/es/components/Checkbox/index.d.ts +10 -0
- package/es/components/Checkbox/index.js +10 -0
- package/es/components/ComposedModal/ComposedModal.js +4 -3
- package/es/components/DataTable/TableToolbarSearch.js +1 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -1
- package/es/components/Grid/Grid.js +0 -5
- package/es/components/Modal/Modal.js +5 -4
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +8 -2
- package/es/components/Search/Search.js +160 -184
- package/es/components/Search/index.js +2 -8
- package/es/components/Tab/index.js +1 -1
- package/es/components/Tabs/Tabs.Skeleton.js +6 -6
- package/es/components/Tabs/Tabs.js +582 -508
- package/es/components/Tabs/index.js +2 -12
- package/es/components/Tabs/{next/usePressable.js → usePressable.js} +1 -1
- package/es/components/Text/Text.d.ts +33 -0
- package/es/components/Text/Text.js +8 -5
- package/es/components/Text/TextDirection.d.ts +35 -0
- package/es/components/Text/TextDirectionContext.js +2 -0
- package/es/components/Text/createTextComponent.d.ts +18 -0
- package/es/components/Text/index.d.ts +18 -0
- package/es/components/Text/index.js +2 -0
- package/es/components/TextArea/TextArea.js +19 -2
- package/es/components/Tile/Tile.js +339 -502
- package/es/index.js +9 -9
- package/es/internal/usePrefix.d.ts +9 -0
- package/lib/components/Checkbox/Checkbox.Skeleton.d.ts +18 -0
- package/lib/components/Checkbox/Checkbox.Skeleton.js +1 -2
- package/lib/components/Checkbox/Checkbox.d.ts +47 -0
- package/lib/components/Checkbox/Checkbox.js +6 -7
- package/lib/components/Checkbox/index.d.ts +10 -0
- package/lib/components/Checkbox/index.js +18 -0
- package/lib/components/ComposedModal/ComposedModal.js +4 -3
- package/lib/components/DataTable/TableToolbarSearch.js +2 -2
- package/lib/components/ExpandableSearch/ExpandableSearch.js +3 -3
- package/lib/components/Grid/Grid.js +0 -5
- package/lib/components/Modal/Modal.js +5 -4
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +8 -2
- package/lib/components/Search/Search.js +159 -183
- package/lib/components/Search/index.js +2 -25
- package/lib/components/Tab/index.js +1 -1
- package/lib/components/Tabs/Tabs.Skeleton.js +6 -6
- package/lib/components/Tabs/Tabs.js +586 -507
- package/lib/components/Tabs/index.js +7 -33
- package/lib/components/Tabs/{next/usePressable.js → usePressable.js} +1 -1
- package/lib/components/Text/Text.d.ts +33 -0
- package/lib/components/Text/Text.js +8 -5
- package/lib/components/Text/TextDirection.d.ts +35 -0
- package/lib/components/Text/TextDirectionContext.js +2 -0
- package/lib/components/Text/createTextComponent.d.ts +18 -0
- package/lib/components/Text/index.d.ts +18 -0
- package/lib/components/Text/index.js +4 -0
- package/lib/components/TextArea/TextArea.js +18 -1
- package/lib/components/Tile/Tile.js +336 -499
- package/lib/index.js +76 -76
- package/lib/internal/usePrefix.d.ts +9 -0
- package/package.json +8 -4
- package/es/components/Search/next/Search.js +0 -265
- package/es/components/Tabs/next/Tabs.Skeleton.js +0 -53
- package/es/components/Tabs/next/Tabs.js +0 -692
- package/es/components/Tile/index.js +0 -19
- package/es/components/Tile/next/Tile.js +0 -604
- package/lib/components/Search/next/Search.js +0 -275
- package/lib/components/Tabs/next/Tabs.Skeleton.js +0 -63
- package/lib/components/Tabs/next/Tabs.js +0 -708
- package/lib/components/Tile/index.js +0 -48
- package/lib/components/Tile/next/Tile.js +0 -619
|
@@ -5,15 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
export { IconTab, Tab, TabList, TabPanel, TabPanels } from './next/Tabs.js';
|
|
11
|
-
import Tabs$3 from './Tabs.js';
|
|
12
|
-
import TabsSkeleton$1 from './Tabs.Skeleton.js';
|
|
13
|
-
import TabsSkeleton from './next/Tabs.Skeleton.js';
|
|
14
|
-
|
|
15
|
-
var Tabs = FeatureFlags.enabled('enable-v11-release') ? Tabs$2 : Tabs$3;
|
|
16
|
-
FeatureFlags.enabled('enable-v11-release') ? TabsSkeleton : TabsSkeleton$1;
|
|
17
|
-
var Tabs$1 = Tabs;
|
|
18
|
-
|
|
19
|
-
export { Tabs$1 as default };
|
|
8
|
+
import { Tabs } from './Tabs.js';
|
|
9
|
+
export { IconTab, Tab, TabList, TabPanel, TabPanels, Tabs as default } from './Tabs.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { slicedToArray as _slicedToArray } from '
|
|
8
|
+
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import { useRef, useState, useEffect } from 'react';
|
|
10
10
|
|
|
11
11
|
function usePressable(ref) {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2018
|
|
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';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { PolymorphicProps } from '../../types/common';
|
|
10
|
+
import { TextDir } from './TextDirection';
|
|
11
|
+
export interface TextBaseProps {
|
|
12
|
+
dir?: TextDir | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare type TextProps<T extends React.ElementType> = PolymorphicProps<T, TextBaseProps>;
|
|
15
|
+
declare function Text<T extends React.ElementType>({ as, children, dir, ...rest }: TextProps<T>): JSX.Element;
|
|
16
|
+
declare namespace Text {
|
|
17
|
+
var propTypes: {
|
|
18
|
+
/**
|
|
19
|
+
* Provide a custom element type used to render the outermost node
|
|
20
|
+
*/
|
|
21
|
+
as: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.ReactComponentLike | null | undefined>>;
|
|
22
|
+
/**
|
|
23
|
+
* Provide child elements or text to be rendered inside of this component
|
|
24
|
+
*/
|
|
25
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
26
|
+
/**
|
|
27
|
+
* Specify the text direction to be used for this component and any of its
|
|
28
|
+
* children
|
|
29
|
+
*/
|
|
30
|
+
dir: PropTypes.Requireable<string>;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export { Text };
|
|
@@ -13,15 +13,16 @@ import { TextDirectionContext } from './TextDirectionContext.js';
|
|
|
13
13
|
var _excluded = ["as", "children", "dir"];
|
|
14
14
|
|
|
15
15
|
function Text(_ref) {
|
|
16
|
-
var
|
|
17
|
-
BaseComponent = _ref$as === void 0 ? 'span' : _ref$as,
|
|
16
|
+
var as = _ref.as,
|
|
18
17
|
children = _ref.children,
|
|
19
18
|
_ref$dir = _ref.dir,
|
|
20
19
|
dir = _ref$dir === void 0 ? 'auto' : _ref$dir,
|
|
21
20
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
22
21
|
|
|
22
|
+
// TODO: Update with context typing once its been converted to TS
|
|
23
23
|
var context = useContext(TextDirectionContext);
|
|
24
24
|
var textProps = {};
|
|
25
|
+
var BaseComponent = as !== null && as !== void 0 ? as : 'span';
|
|
25
26
|
|
|
26
27
|
var value = _objectSpread2({}, context);
|
|
27
28
|
|
|
@@ -74,21 +75,23 @@ Text.propTypes = {
|
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
function getTextFromChildren(children) {
|
|
78
|
+
var _React$Children$map;
|
|
79
|
+
|
|
77
80
|
if (typeof children === 'string') {
|
|
78
81
|
return children;
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
var text = React__default.Children.map(children, function (child) {
|
|
84
|
+
var text = (_React$Children$map = React__default.Children.map(children, function (child) {
|
|
82
85
|
if (typeof child === 'string') {
|
|
83
86
|
return child;
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
return null;
|
|
87
|
-
}).filter(function (text) {
|
|
90
|
+
})) === null || _React$Children$map === void 0 ? void 0 : _React$Children$map.filter(function (text) {
|
|
88
91
|
return text !== null;
|
|
89
92
|
});
|
|
90
93
|
|
|
91
|
-
if (text.length === 1) {
|
|
94
|
+
if ((text === null || text === void 0 ? void 0 : text.length) === 1) {
|
|
92
95
|
return text[0];
|
|
93
96
|
}
|
|
94
97
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2018
|
|
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';
|
|
8
|
+
import { ReactNode } from 'react';
|
|
9
|
+
export declare type TextDir = 'ltr' | 'rtl' | 'auto';
|
|
10
|
+
export declare type GetTextDirection = (text: string | string[] | undefined) => TextDir;
|
|
11
|
+
export interface TextDirectionProps {
|
|
12
|
+
children: ReactNode | undefined;
|
|
13
|
+
dir?: TextDir;
|
|
14
|
+
getTextDirection?: GetTextDirection;
|
|
15
|
+
}
|
|
16
|
+
declare function TextDirection({ children, dir, getTextDirection, }: TextDirectionProps): JSX.Element;
|
|
17
|
+
declare namespace TextDirection {
|
|
18
|
+
var propTypes: {
|
|
19
|
+
/**
|
|
20
|
+
* Provide children to be rendered inside of this component
|
|
21
|
+
*/
|
|
22
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
23
|
+
/**
|
|
24
|
+
* Specify the text direction for rendered children
|
|
25
|
+
*/
|
|
26
|
+
dir: PropTypes.Requireable<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Optionally provide a custom function to get the text direction for a piece
|
|
29
|
+
* of text. Whatever is returned will become the value of the `dir` attribute
|
|
30
|
+
* on a node of text. Should return one of: 'ltr', 'rtl', or 'auto'
|
|
31
|
+
*/
|
|
32
|
+
getTextDirection: PropTypes.Requireable<(...args: any[]) => any>;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export { TextDirection };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2018
|
|
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 React from 'react';
|
|
8
|
+
import { TextProps } from './Text';
|
|
9
|
+
/**
|
|
10
|
+
* Create a text component wrapper for a given text node type. Useful for
|
|
11
|
+
* returning a `Text` component for a text node like a `<label>`.
|
|
12
|
+
* @param {string} element
|
|
13
|
+
* @param {string} displayName
|
|
14
|
+
*/
|
|
15
|
+
export declare function createTextComponent(element: React.ElementType, displayName: string): {
|
|
16
|
+
(props: TextProps<React.ElementType>): JSX.Element;
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2018
|
|
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 { TextDirection, TextDirectionProps, GetTextDirection, TextDir } from './TextDirection';
|
|
8
|
+
import { Text, TextBaseProps, TextProps } from './Text';
|
|
9
|
+
export { TextDirection, Text };
|
|
10
|
+
export type { TextBaseProps, TextProps, TextDirectionProps, GetTextDirection, TextDir, };
|
|
11
|
+
export declare const Label: {
|
|
12
|
+
(props: TextProps<import("react").ElementType<any>>): JSX.Element;
|
|
13
|
+
displayName: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const Legend: {
|
|
16
|
+
(props: TextProps<import("react").ElementType<any>>): JSX.Element;
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
export { TextDirection } from './TextDirection.js';
|
|
9
|
+
export { Text } from './Text.js';
|
|
8
10
|
import { createTextComponent } from './createTextComponent.js';
|
|
9
11
|
|
|
10
12
|
createTextComponent('label', 'Label');
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React__default, { useContext, useState } from 'react';
|
|
10
|
+
import React__default, { useContext, useState, useEffect } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import deprecate from '../../prop-types/deprecate.js';
|
|
13
13
|
import { WarningFilled } from '@carbon/icons-react';
|
|
@@ -49,6 +49,11 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, re
|
|
|
49
49
|
textCount = _useState2[0],
|
|
50
50
|
setTextCount = _useState2[1];
|
|
51
51
|
|
|
52
|
+
var _useState3 = useState(''),
|
|
53
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
54
|
+
ariaAnnouncement = _useState4[0],
|
|
55
|
+
setAriaAnnouncement = _useState4[1];
|
|
56
|
+
|
|
52
57
|
var textareaProps = {
|
|
53
58
|
id: id,
|
|
54
59
|
onChange: function onChange(evt) {
|
|
@@ -72,6 +77,15 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, re
|
|
|
72
77
|
textareaProps.maxLength = maxCount;
|
|
73
78
|
}
|
|
74
79
|
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
var lastTen = maxCount - 10;
|
|
82
|
+
|
|
83
|
+
if (textCount >= lastTen) {
|
|
84
|
+
setAriaAnnouncement("".concat(maxCount - textCount, " characters left."));
|
|
85
|
+
} else {
|
|
86
|
+
setAriaAnnouncement('');
|
|
87
|
+
}
|
|
88
|
+
}, [textCount, maxCount]);
|
|
75
89
|
var labelClasses = cx("".concat(prefix, "--label"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--visually-hidden"), hideLabel && !isFluid), _defineProperty(_classNames, "".concat(prefix, "--label--disabled"), disabled), _classNames));
|
|
76
90
|
var label = labelText ? /*#__PURE__*/React__default.createElement("label", {
|
|
77
91
|
htmlFor: id,
|
|
@@ -110,7 +124,10 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, re
|
|
|
110
124
|
"data-invalid": invalid || null
|
|
111
125
|
}, invalid && !isFluid && /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
112
126
|
className: "".concat(prefix, "--text-area__invalid-icon")
|
|
113
|
-
}), input,
|
|
127
|
+
}), input, /*#__PURE__*/React__default.createElement("span", {
|
|
128
|
+
className: "".concat(prefix, "--text-area__counter-alert"),
|
|
129
|
+
role: "alert"
|
|
130
|
+
}, ariaAnnouncement), isFluid && /*#__PURE__*/React__default.createElement("hr", {
|
|
114
131
|
className: "".concat(prefix, "--text-area__divider")
|
|
115
132
|
}), isFluid && invalid ? error : null), invalid && !isFluid ? error : helper);
|
|
116
133
|
});
|