carbon-react 105.0.2 → 105.1.2
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/esm/__spec_helper__/mock-match-media.d.ts +3 -1
- package/esm/components/button/button.component.js +1 -1
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +9 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
- package/esm/components/multi-action-button/multi-action-button.component.js +1 -1
- package/esm/components/select/option/index.d.ts +1 -1
- package/esm/components/split-button/split-button.component.js +1 -1
- package/esm/components/tile/tile.component.d.ts +3 -2
- package/esm/components/tile/tile.component.js +14 -2
- package/esm/components/tile/tile.d.ts +2 -0
- package/esm/components/toast/toast.component.d.ts +1 -1
- package/esm/components/toast/toast.component.js +10 -2
- package/esm/hooks/__internal__/useCharacterCount/index.d.ts +1 -2
- package/esm/hooks/__internal__/useCharacterCount/index.js +1 -18
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +3 -0
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +24 -0
- package/esm/hooks/__internal__/useInputAccessibility/index.d.ts +1 -24
- package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +11 -11
- package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.js +1 -3
- package/esm/hooks/__internal__/useIsAboveBreakpoint/index.d.ts +1 -1
- package/esm/hooks/__internal__/useIsAboveBreakpoint/index.js +1 -6
- package/esm/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.d.ts +1 -0
- package/esm/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js +6 -0
- package/esm/hooks/__internal__/useLocale/index.d.ts +1 -1
- package/esm/hooks/__internal__/useLocale/index.js +1 -5
- package/esm/hooks/__internal__/useLocale/useLocale.d.ts +1 -0
- package/esm/hooks/__internal__/useLocale/useLocale.js +5 -0
- package/esm/hooks/__internal__/useResizeObserver/index.d.ts +1 -10
- package/esm/hooks/__internal__/useResizeObserver/index.js +1 -23
- package/esm/hooks/__internal__/useResizeObserver/useResizeObserver.d.ts +8 -0
- package/esm/hooks/__internal__/useResizeObserver/useResizeObserver.js +29 -0
- package/esm/hooks/__internal__/useScrollBlock/index.d.ts +1 -4
- package/esm/hooks/__internal__/useScrollBlock/scroll-block-manager.d.ts +23 -9
- package/esm/hooks/__internal__/useScrollBlock/scroll-block-manager.js +24 -12
- package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.d.ts +2 -2
- package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.js +3 -5
- package/esm/hooks/useMediaQuery/index.d.ts +1 -1
- package/esm/hooks/useMediaQuery/index.js +1 -19
- package/esm/hooks/useMediaQuery/useMediaQuery.d.ts +1 -0
- package/esm/hooks/useMediaQuery/useMediaQuery.js +19 -0
- package/lib/__spec_helper__/mock-match-media.d.ts +3 -1
- package/lib/components/button/button.component.js +1 -1
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +10 -3
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +2 -0
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js +22 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +0 -1
- package/lib/components/multi-action-button/multi-action-button.component.js +1 -1
- package/lib/components/select/option/index.d.ts +1 -1
- package/lib/components/split-button/split-button.component.js +1 -1
- package/lib/components/tile/tile.component.d.ts +3 -2
- package/lib/components/tile/tile.component.js +17 -2
- package/lib/components/tile/tile.d.ts +2 -0
- package/lib/components/toast/toast.component.d.ts +1 -1
- package/lib/components/toast/toast.component.js +13 -2
- package/lib/components/vertical-divider/vertical-divider.component.js +3 -0
- package/lib/hooks/__internal__/useCharacterCount/index.d.ts +1 -2
- package/lib/hooks/__internal__/useCharacterCount/index.js +8 -27
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +3 -0
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +40 -0
- package/lib/hooks/__internal__/useInputAccessibility/index.d.ts +1 -24
- package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +11 -11
- package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.js +1 -3
- package/lib/hooks/__internal__/useIsAboveBreakpoint/index.d.ts +1 -1
- package/lib/hooks/__internal__/useIsAboveBreakpoint/index.js +8 -9
- package/lib/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.d.ts +1 -0
- package/lib/hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js +16 -0
- package/lib/hooks/__internal__/useLocale/index.d.ts +1 -1
- package/lib/hooks/__internal__/useLocale/index.js +8 -9
- package/lib/hooks/__internal__/useLocale/useLocale.d.ts +1 -0
- package/lib/hooks/__internal__/useLocale/useLocale.js +16 -0
- package/lib/hooks/__internal__/useResizeObserver/index.d.ts +1 -10
- package/lib/hooks/__internal__/useResizeObserver/index.js +8 -24
- package/lib/hooks/__internal__/useResizeObserver/useResizeObserver.d.ts +8 -0
- package/lib/hooks/__internal__/useResizeObserver/useResizeObserver.js +37 -0
- package/lib/hooks/__internal__/useScrollBlock/index.d.ts +1 -4
- package/lib/hooks/__internal__/useScrollBlock/scroll-block-manager.d.ts +23 -9
- package/lib/hooks/__internal__/useScrollBlock/scroll-block-manager.js +24 -12
- package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.d.ts +2 -2
- package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.js +3 -5
- package/lib/hooks/useMediaQuery/index.d.ts +1 -1
- package/lib/hooks/useMediaQuery/index.js +8 -25
- package/lib/hooks/useMediaQuery/useMediaQuery.d.ts +1 -0
- package/lib/hooks/useMediaQuery/useMediaQuery.js +32 -0
- package/package.json +5 -3
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export default function useMediaQuery(queryInput) {
|
|
3
|
-
const query = queryInput.replace(/^@media( ?)/m, "");
|
|
4
|
-
const [match, setMatch] = React.useState(() => false);
|
|
5
|
-
React.useEffect(() => {
|
|
6
|
-
const queryList = window.matchMedia(query);
|
|
7
|
-
|
|
8
|
-
const updateMatch = () => {
|
|
9
|
-
setMatch(queryList.matches);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
updateMatch();
|
|
13
|
-
queryList.addListener(updateMatch);
|
|
14
|
-
return () => {
|
|
15
|
-
queryList.removeListener(updateMatch);
|
|
16
|
-
};
|
|
17
|
-
}, [query]);
|
|
18
|
-
return match;
|
|
19
|
-
}
|
|
1
|
+
export { default } from "./useMediaQuery";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useMediaQuery(queryInput: string): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export default function useMediaQuery(queryInput) {
|
|
3
|
+
const query = queryInput.replace(/^@media( ?)/m, "");
|
|
4
|
+
const [match, setMatch] = React.useState(() => false);
|
|
5
|
+
React.useEffect(() => {
|
|
6
|
+
const queryList = window.matchMedia(query);
|
|
7
|
+
|
|
8
|
+
const updateMatch = () => {
|
|
9
|
+
setMatch(queryList.matches);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
updateMatch();
|
|
13
|
+
queryList.addListener(updateMatch);
|
|
14
|
+
return () => {
|
|
15
|
+
queryList.removeListener(updateMatch);
|
|
16
|
+
};
|
|
17
|
+
}, [query]);
|
|
18
|
+
return match;
|
|
19
|
+
}
|
|
@@ -99,7 +99,7 @@ const Button = ({
|
|
|
99
99
|
deprecatedWarnTriggered = true;
|
|
100
100
|
|
|
101
101
|
_logger.default.deprecate( // eslint-disable-next-line max-len
|
|
102
|
-
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
102
|
+
"The `as` prop is deprecated and will soon be removed from the `Button` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const [internalRef, setInternalRef] = (0, _react.useState)(null);
|
package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js
CHANGED
|
@@ -15,7 +15,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _icon = _interopRequireDefault(require("../../icon/icon.style"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _flatTableBodyDraggable = _interopRequireDefault(require("./flat-table-body-draggable.style"));
|
|
19
19
|
|
|
20
20
|
var _flatTableCell = _interopRequireDefault(require("../flat-table-cell/flat-table-cell.component"));
|
|
21
21
|
|
|
@@ -32,16 +32,23 @@ const DropTarget = ({
|
|
|
32
32
|
getOrder,
|
|
33
33
|
...rest
|
|
34
34
|
}) => {
|
|
35
|
+
const [isDragging, setIsDragging] = (0, _react.useState)(false);
|
|
35
36
|
const [, drop] = (0, _reactDnd.useDrop)({
|
|
36
37
|
accept: "flatTableRow",
|
|
38
|
+
hover: (_, monitor) => {
|
|
39
|
+
if (!isDragging && monitor.isOver()) setIsDragging(true);
|
|
40
|
+
},
|
|
37
41
|
|
|
38
42
|
drop() {
|
|
43
|
+
setIsDragging(false);
|
|
39
44
|
getOrder();
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
});
|
|
43
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
44
|
-
|
|
48
|
+
return /*#__PURE__*/_react.default.createElement(_flatTableBodyDraggable.default, _extends({
|
|
49
|
+
"data-testid": "flat-table-body-draggable",
|
|
50
|
+
ref: drop,
|
|
51
|
+
isDragging: isDragging
|
|
45
52
|
}, rest), children);
|
|
46
53
|
};
|
|
47
54
|
|
package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
11
|
+
|
|
12
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
|
|
14
|
+
const StyledFlatTableBodyDraggable = _styledComponents.default.tbody`
|
|
15
|
+
${({
|
|
16
|
+
isDragging
|
|
17
|
+
}) => isDragging && (0, _styledComponents.css)`
|
|
18
|
+
cursor: grabbing;
|
|
19
|
+
`}
|
|
20
|
+
`;
|
|
21
|
+
var _default = StyledFlatTableBodyDraggable;
|
|
22
|
+
exports.default = _default;
|
|
@@ -269,7 +269,6 @@ const StyledFlatTableRow = _styledComponents.default.tr`
|
|
|
269
269
|
${isDragging && (0, _styledComponents.css)`
|
|
270
270
|
border: ${isInSidebar ? "var(--colorsUtilityMajor300)" : "var(--colorsUtilityMajor200)"}
|
|
271
271
|
2px solid;
|
|
272
|
-
cursor: grabbing;
|
|
273
272
|
${allCellTypes} {
|
|
274
273
|
background-color: ${isInSidebar ? "var(--colorsUtilityMajor200)" : "var(--colorsUtilityMajor150)"};
|
|
275
274
|
}
|
|
@@ -51,7 +51,7 @@ const MultiActionButton = ({
|
|
|
51
51
|
deprecatedWarnTriggered = true;
|
|
52
52
|
|
|
53
53
|
_logger.default.deprecate( // eslint-disable-next-line max-len
|
|
54
|
-
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
54
|
+
"The `as` prop is deprecated and will soon be removed from the `MultiActionButton` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
const ref = (0, _react.useRef)();
|
|
@@ -4,7 +4,7 @@ export interface OptionProps {
|
|
|
4
4
|
/** The option's visible text, displayed within <Textbox> of <Select>, and used for filtering */
|
|
5
5
|
text: string;
|
|
6
6
|
/** Optional: alternative rendered content, displayed within <SelectList> of <Select> (eg: an icon, an image, etc) */
|
|
7
|
-
children?: React.
|
|
7
|
+
children?: React.ReactNode;
|
|
8
8
|
/** The option's invisible internal value */
|
|
9
9
|
value: string | Record<string, unknown>;
|
|
10
10
|
/** MultiSelect only - custom Pill border color - provide any color from palette or any valid css color value. */
|
|
@@ -67,7 +67,7 @@ const SplitButton = ({
|
|
|
67
67
|
deprecatedWarnTriggered = true;
|
|
68
68
|
|
|
69
69
|
_logger.default.deprecate( // eslint-disable-next-line max-len
|
|
70
|
-
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
70
|
+
"The `as` prop is deprecated and will soon be removed from the `SplitButton` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _themes.baseTheme;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default Tile;
|
|
2
|
-
declare function Tile({ as, p, children, orientation, width, ...props }: {
|
|
2
|
+
declare function Tile({ as, variant, p, children, orientation, width, ...props }: {
|
|
3
3
|
[x: string]: any;
|
|
4
|
-
as
|
|
4
|
+
as: any;
|
|
5
|
+
variant?: string | undefined;
|
|
5
6
|
p?: number | undefined;
|
|
6
7
|
children: any;
|
|
7
8
|
orientation?: string | undefined;
|
|
@@ -13,18 +13,30 @@ var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
|
|
|
13
13
|
|
|
14
14
|
var _tileStyle = require("./tile.style.js");
|
|
15
15
|
|
|
16
|
+
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
17
|
+
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
20
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
19
21
|
|
|
22
|
+
let deprecatedWarnTriggered = false;
|
|
23
|
+
|
|
20
24
|
const Tile = ({
|
|
21
|
-
as
|
|
25
|
+
as,
|
|
26
|
+
variant = "tile",
|
|
22
27
|
p = 3,
|
|
23
28
|
children,
|
|
24
29
|
orientation = "horizontal",
|
|
25
30
|
width,
|
|
26
31
|
...props
|
|
27
32
|
}) => {
|
|
33
|
+
if (!deprecatedWarnTriggered && as) {
|
|
34
|
+
deprecatedWarnTriggered = true;
|
|
35
|
+
|
|
36
|
+
_logger.default.deprecate( // eslint-disable-next-line max-len
|
|
37
|
+
"The `as` prop is deprecated and will soon be removed from the `Tile` component interface. You should use the `variant` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
const isHorizontal = () => orientation === "horizontal";
|
|
29
41
|
|
|
30
42
|
const isVertical = () => orientation === "vertical";
|
|
@@ -54,7 +66,7 @@ const Tile = ({
|
|
|
54
66
|
});
|
|
55
67
|
|
|
56
68
|
return /*#__PURE__*/_react.default.createElement(_tileStyle.StyledTile, _extends({
|
|
57
|
-
tileTheme: as,
|
|
69
|
+
tileTheme: as || variant,
|
|
58
70
|
width: width,
|
|
59
71
|
"data-component": "tile",
|
|
60
72
|
isHorizontal: isHorizontal(orientation),
|
|
@@ -69,6 +81,9 @@ Tile.propTypes = {
|
|
|
69
81
|
/** Sets the theme of the tile - either 'tile' or 'transparent' */
|
|
70
82
|
as: _propTypes.default.oneOf(["tile", "transparent"]),
|
|
71
83
|
|
|
84
|
+
/** Sets the theme of the tile - either 'tile' or 'transparent' */
|
|
85
|
+
variant: _propTypes.default.oneOf(["tile", "transparent"]),
|
|
86
|
+
|
|
72
87
|
/**
|
|
73
88
|
* The content to render within the tile. Each child will be wrapped with
|
|
74
89
|
* a TileContent wrapper, which allows any individual child component to take a
|
|
@@ -4,6 +4,8 @@ import { SpaceProps } from "styled-system";
|
|
|
4
4
|
export interface TileProps extends SpaceProps {
|
|
5
5
|
/** Sets the theme of the tile - either 'tile' or 'transparent' */
|
|
6
6
|
as?: "tile" | "transparent";
|
|
7
|
+
/** Sets the theme of the tile - either 'tile' or 'transparent' */
|
|
8
|
+
variant?: "tile" | "transparent";
|
|
7
9
|
/**
|
|
8
10
|
* The content to render within the tile. Each child will be wrapped with
|
|
9
11
|
* a TileContent wrapper, which allows any individual child component to take a
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default Toast;
|
|
2
2
|
declare function Toast({ as, children, className, id, isCenter, maxWidth, onDismiss, open, targetPortalId, timeout, variant, ...restProps }: {
|
|
3
3
|
[x: string]: any;
|
|
4
|
-
as
|
|
4
|
+
as: any;
|
|
5
5
|
children: any;
|
|
6
6
|
className: any;
|
|
7
7
|
id: any;
|
|
@@ -27,6 +27,8 @@ var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/e
|
|
|
27
27
|
|
|
28
28
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
29
29
|
|
|
30
|
+
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
31
|
+
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
|
|
32
34
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -35,8 +37,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
35
37
|
|
|
36
38
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
37
39
|
|
|
40
|
+
let deprecatedWarnTriggered = false;
|
|
41
|
+
|
|
38
42
|
const Toast = ({
|
|
39
|
-
as
|
|
43
|
+
as,
|
|
40
44
|
children,
|
|
41
45
|
className,
|
|
42
46
|
id,
|
|
@@ -49,6 +53,13 @@ const Toast = ({
|
|
|
49
53
|
variant,
|
|
50
54
|
...restProps
|
|
51
55
|
}) => {
|
|
56
|
+
if (!deprecatedWarnTriggered && as) {
|
|
57
|
+
deprecatedWarnTriggered = true;
|
|
58
|
+
|
|
59
|
+
_logger.default.deprecate( // eslint-disable-next-line max-len
|
|
60
|
+
"The `as` prop is deprecated and will soon be removed from the `Toast` component interface. You should use the `variant` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
61
|
+
}
|
|
62
|
+
|
|
52
63
|
const locale = (0, _useLocale.default)();
|
|
53
64
|
const toastRef = (0, _react.useRef)();
|
|
54
65
|
const timer = (0, _react.useRef)();
|
|
@@ -100,7 +111,7 @@ const Toast = ({
|
|
|
100
111
|
if (!open) return null;
|
|
101
112
|
const toastProps = {
|
|
102
113
|
isCenter,
|
|
103
|
-
variant: variant || as,
|
|
114
|
+
variant: variant || as || "success",
|
|
104
115
|
id,
|
|
105
116
|
maxWidth
|
|
106
117
|
};
|
|
@@ -12,6 +12,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
12
12
|
var _menu = require("../menu/menu.component");
|
|
13
13
|
|
|
14
14
|
var _verticalDivider = require("./vertical-divider.style");
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
function _getRequireWildcardCache() {
|
|
17
20
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export default useCharacterCount;
|
|
2
|
-
declare function useCharacterCount(value: any, characterLimit: any, warnOverLimit?: boolean, enforceCharacterLimit?: boolean): any[];
|
|
1
|
+
export { default } from "./useCharacterCount";
|
|
@@ -3,32 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _useLocale = _interopRequireDefault(require("../useLocale"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useCharacterCount.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
const l = (0, _useLocale.default)();
|
|
24
|
-
const isOverLimit = (0, _react.useMemo)(() => value && value.length > parseInt(characterLimit, 10), [value, characterLimit]);
|
|
25
|
-
return [enforceCharacterLimit && characterLimit ? characterLimit : undefined, characterLimit ? /*#__PURE__*/_react.default.createElement(_characterCount.default, {
|
|
26
|
-
isOverLimit: isOverLimit && warnOverLimit,
|
|
27
|
-
value: getFormatNumber(value.length, l.locale()),
|
|
28
|
-
limit: getFormatNumber(characterLimit, l.locale()),
|
|
29
|
-
"data-element": "character-limit"
|
|
30
|
-
}) : null];
|
|
31
|
-
};
|
|
13
|
+
var _useCharacterCount = _interopRequireDefault(require("./useCharacterCount"));
|
|
32
14
|
|
|
33
|
-
|
|
34
|
-
exports.default = _default;
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _characterCount = _interopRequireDefault(require("../../../__internal__/character-count"));
|
|
11
|
+
|
|
12
|
+
var _useLocale = _interopRequireDefault(require("../useLocale"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
|
|
21
|
+
|
|
22
|
+
const useCharacterCount = (value, characterLimit, warnOverLimit = false, enforceCharacterLimit = true) => {
|
|
23
|
+
const l = (0, _useLocale.default)();
|
|
24
|
+
const isOverLimit = (0, _react.useMemo)(() => {
|
|
25
|
+
if (value && characterLimit) {
|
|
26
|
+
return value.length > parseInt(characterLimit, 10);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return false;
|
|
30
|
+
}, [value, characterLimit]);
|
|
31
|
+
return [enforceCharacterLimit && characterLimit ? characterLimit : undefined, characterLimit ? /*#__PURE__*/_react.default.createElement(_characterCount.default, {
|
|
32
|
+
isOverLimit: isOverLimit && warnOverLimit,
|
|
33
|
+
value: getFormatNumber(value.length, l.locale()),
|
|
34
|
+
limit: getFormatNumber(+characterLimit, l.locale()),
|
|
35
|
+
"data-element": "character-limit"
|
|
36
|
+
}) : null];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var _default = useCharacterCount;
|
|
40
|
+
exports.default = _default;
|
|
@@ -1,24 +1 @@
|
|
|
1
|
-
|
|
2
|
-
labelId?: string;
|
|
3
|
-
tooltipId?: string;
|
|
4
|
-
fieldHelpId?: string;
|
|
5
|
-
ariaDescribedBy?: string;
|
|
6
|
-
ariaLabelledBy?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default function useInputAccessibility(
|
|
10
|
-
/** Input id - */
|
|
11
|
-
id: string,
|
|
12
|
-
/** Error validation message */
|
|
13
|
-
error?: string,
|
|
14
|
-
/** Warning validation message */
|
|
15
|
-
warning?: string,
|
|
16
|
-
/** Info validation message */
|
|
17
|
-
info?: string,
|
|
18
|
-
/** Label */
|
|
19
|
-
label?: string,
|
|
20
|
-
/** labelHelp message */
|
|
21
|
-
labelHelp?: string,
|
|
22
|
-
/** fieldHelp message */
|
|
23
|
-
fieldHelp?: string
|
|
24
|
-
): void;
|
|
1
|
+
export { default } from "./useInputAccessibility";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export default function useInputAccessibility({ id, error, warning, info, label, fieldHelp, }: {
|
|
2
|
-
id:
|
|
3
|
-
error
|
|
4
|
-
warning
|
|
5
|
-
info
|
|
6
|
-
label
|
|
7
|
-
fieldHelp
|
|
2
|
+
id: string;
|
|
3
|
+
error?: string;
|
|
4
|
+
warning?: string;
|
|
5
|
+
info?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
fieldHelp?: string;
|
|
8
8
|
}): {
|
|
9
|
-
labelId
|
|
10
|
-
validationIconId
|
|
11
|
-
fieldHelpId
|
|
12
|
-
ariaDescribedBy
|
|
13
|
-
ariaLabelledBy
|
|
9
|
+
labelId?: string;
|
|
10
|
+
validationIconId?: string;
|
|
11
|
+
fieldHelpId?: string;
|
|
12
|
+
ariaDescribedBy?: string;
|
|
13
|
+
ariaLabelledBy?: string;
|
|
14
14
|
};
|
|
@@ -14,9 +14,7 @@ function useInputAccessibility({
|
|
|
14
14
|
fieldHelp
|
|
15
15
|
}) {
|
|
16
16
|
const labelId = label ? `${id}-label` : undefined;
|
|
17
|
-
const validationIconId = [error, warning, info].filter(validation => {
|
|
18
|
-
return validation && typeof validation === "string";
|
|
19
|
-
}).length ? `${id}-validation-icon` : undefined;
|
|
17
|
+
const validationIconId = [error, warning, info].filter(validation => validation && typeof validation === "string").length ? `${id}-validation-icon` : undefined;
|
|
20
18
|
const fieldHelpId = fieldHelp ? `${id}-field-help` : undefined;
|
|
21
19
|
const ariaDescribedBy = [fieldHelpId, validationIconId].filter(Boolean).join(" ");
|
|
22
20
|
const ariaLabelledBy = labelId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default
|
|
1
|
+
export { default } from "./useIsAboveBreakpoint";
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useIsAboveBreakpoint.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
var _useIsAboveBreakpoint = _interopRequireDefault(require("./useIsAboveBreakpoint"));
|
|
11
14
|
|
|
12
|
-
function
|
|
13
|
-
const matchesQuery = (0, _useMediaQuery.default)(`(min-width:${breakpoint}px)`);
|
|
14
|
-
if (!breakpoint) return undefined;
|
|
15
|
-
return matchesQuery;
|
|
16
|
-
}
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useIsAboveBreakpoint(breakpoint?: number): boolean | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useIsAboveBreakpoint;
|
|
7
|
+
|
|
8
|
+
var _useMediaQuery = _interopRequireDefault(require("../../useMediaQuery"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
function useIsAboveBreakpoint(breakpoint) {
|
|
13
|
+
const matchesQuery = (0, _useMediaQuery.default)(`(min-width:${breakpoint}px)`);
|
|
14
|
+
if (!breakpoint) return undefined;
|
|
15
|
+
return matchesQuery;
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default
|
|
1
|
+
export { default } from "./useLocale";
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useLocale.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
var _useLocale = _interopRequireDefault(require("./useLocale"));
|
|
13
14
|
|
|
14
|
-
function
|
|
15
|
-
return (0, _react.useContext)(_i18nContext.default);
|
|
16
|
-
}
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useLocale(): import("../../../locales/locale").default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useLocale;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _i18nContext = _interopRequireDefault(require("../../../__internal__/i18n-context"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function useLocale() {
|
|
15
|
+
return (0, _react.useContext)(_i18nContext.default);
|
|
16
|
+
}
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default function useResizeObserver(
|
|
4
|
-
/** Reference to the resizable HTML element - */
|
|
5
|
-
ref: React.RefObject<HTMLElement>,
|
|
6
|
-
/** Callback meant to be executed on element resize */
|
|
7
|
-
onResize: () => void,
|
|
8
|
-
/** Flag to indicate whether hook should be disabled */
|
|
9
|
-
disabled?: boolean
|
|
10
|
-
): void;
|
|
1
|
+
export { default } from "./useResizeObserver";
|
|
@@ -3,29 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const onResizeRef = (0, _react.useRef)(null);
|
|
13
|
-
onResizeRef.current = onResize;
|
|
14
|
-
(0, _react.useLayoutEffect)(() => {
|
|
15
|
-
const referenceRef = ref.current;
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useResizeObserver.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
observer.current = new ResizeObserver(() => {
|
|
19
|
-
onResizeRef === null || onResizeRef === void 0 ? void 0 : onResizeRef.current();
|
|
20
|
-
});
|
|
21
|
-
observer.current.observe(referenceRef);
|
|
22
|
-
}
|
|
13
|
+
var _useResizeObserver = _interopRequireDefault(require("./useResizeObserver"));
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
if (!disabled) {
|
|
26
|
-
observer.current.unobserve(referenceRef);
|
|
27
|
-
observer.current.disconnect();
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}, [ref, disabled]);
|
|
31
|
-
}
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
export default function useResizeObserver(
|
|
3
|
+
/** Reference to the resizable HTML element */
|
|
4
|
+
ref: RefObject<Element>,
|
|
5
|
+
/** Callback meant to be executed on element resize */
|
|
6
|
+
onResize: () => void,
|
|
7
|
+
/** Flag to indicate whether hook should be disabled */
|
|
8
|
+
disabled?: boolean): void;
|