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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useResizeObserver;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
function useResizeObserver(
|
|
11
|
+
/** Reference to the resizable HTML element */
|
|
12
|
+
ref,
|
|
13
|
+
/** Callback meant to be executed on element resize */
|
|
14
|
+
onResize,
|
|
15
|
+
/** Flag to indicate whether hook should be disabled */
|
|
16
|
+
disabled) {
|
|
17
|
+
const observer = (0, _react.useRef)();
|
|
18
|
+
const onResizeRef = (0, _react.useRef)(onResize);
|
|
19
|
+
onResizeRef.current = onResize;
|
|
20
|
+
(0, _react.useLayoutEffect)(() => {
|
|
21
|
+
const referenceRef = ref.current;
|
|
22
|
+
|
|
23
|
+
if (!disabled && referenceRef) {
|
|
24
|
+
observer.current = new ResizeObserver(() => {
|
|
25
|
+
onResizeRef === null || onResizeRef === void 0 ? void 0 : onResizeRef.current();
|
|
26
|
+
});
|
|
27
|
+
observer.current.observe(referenceRef);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return () => {
|
|
31
|
+
if (!disabled && referenceRef && observer.current) {
|
|
32
|
+
observer.current.unobserve(referenceRef);
|
|
33
|
+
observer.current.disconnect();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, [ref, disabled]);
|
|
37
|
+
}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
__CARBON_INTERNALS_SCROLL_BLOCKERS?: {
|
|
4
|
+
components: {
|
|
5
|
+
[key: string]: boolean;
|
|
6
|
+
};
|
|
7
|
+
originalValues: string[];
|
|
8
|
+
restoreValues?: (() => void) | null;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
2
12
|
declare class ScrollBlockManager {
|
|
3
|
-
components:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
components: {
|
|
14
|
+
[key: string]: boolean;
|
|
15
|
+
};
|
|
16
|
+
originalValues: string[];
|
|
17
|
+
constructor();
|
|
18
|
+
registerComponent(id: string): void;
|
|
19
|
+
unregisterComponent(id: string): void;
|
|
20
|
+
saveRestoreValuesCallback(callback: (() => void) | null): void;
|
|
21
|
+
getRestoreValuesCallback(): (() => void) | null | undefined;
|
|
22
|
+
saveOriginalValues(values: string[]): void;
|
|
23
|
+
getOriginalValues(): string[];
|
|
11
24
|
isBlocked(): boolean;
|
|
12
25
|
}
|
|
26
|
+
export default ScrollBlockManager;
|
|
@@ -11,19 +11,26 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
11
11
|
|
|
12
12
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
|
|
16
|
+
// TODO: This component can be refactored to remove redundant code
|
|
17
|
+
// once we can confirm that all Sage products use version 105.0.0^
|
|
16
18
|
let ScrollBlockManager = /*#__PURE__*/function () {
|
|
17
19
|
function ScrollBlockManager() {
|
|
18
20
|
_classCallCheck(this, ScrollBlockManager);
|
|
19
21
|
|
|
22
|
+
_defineProperty(this, "components", void 0);
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "originalValues", void 0);
|
|
25
|
+
|
|
20
26
|
// Due to possibility of multiple carbon versions using it
|
|
21
27
|
// it is necessary to maintain same structure in this global variable
|
|
22
28
|
if (!window.__CARBON_INTERNALS_SCROLL_BLOCKERS) {
|
|
23
29
|
window.__CARBON_INTERNALS_SCROLL_BLOCKERS = {
|
|
24
30
|
components: {},
|
|
25
31
|
// originalValues can be removed
|
|
26
|
-
originalValues: []
|
|
32
|
+
originalValues: [],
|
|
33
|
+
restoreValues: null
|
|
27
34
|
};
|
|
28
35
|
}
|
|
29
36
|
|
|
@@ -41,23 +48,28 @@ let ScrollBlockManager = /*#__PURE__*/function () {
|
|
|
41
48
|
key: "unregisterComponent",
|
|
42
49
|
value: function unregisterComponent(id) {
|
|
43
50
|
delete this.components[id];
|
|
44
|
-
} // TODO: saveOriginalValues can be removed
|
|
45
|
-
|
|
46
|
-
}, {
|
|
47
|
-
key: "saveOriginalValues",
|
|
48
|
-
value: function saveOriginalValues(values) {
|
|
49
|
-
this.originalValues.length = 0;
|
|
50
|
-
this.originalValues.push(...values);
|
|
51
51
|
}
|
|
52
52
|
}, {
|
|
53
53
|
key: "saveRestoreValuesCallback",
|
|
54
54
|
value: function saveRestoreValuesCallback(callback) {
|
|
55
|
-
|
|
55
|
+
/* istanbul ignore else */
|
|
56
|
+
if (window.__CARBON_INTERNALS_SCROLL_BLOCKERS) {
|
|
57
|
+
window.__CARBON_INTERNALS_SCROLL_BLOCKERS.restoreValues = callback;
|
|
58
|
+
}
|
|
56
59
|
}
|
|
57
60
|
}, {
|
|
58
61
|
key: "getRestoreValuesCallback",
|
|
59
62
|
value: function getRestoreValuesCallback() {
|
|
60
|
-
|
|
63
|
+
var _window$__CARBON_INTE;
|
|
64
|
+
|
|
65
|
+
return (_window$__CARBON_INTE = window.__CARBON_INTERNALS_SCROLL_BLOCKERS) === null || _window$__CARBON_INTE === void 0 ? void 0 : _window$__CARBON_INTE.restoreValues;
|
|
66
|
+
} // TODO: saveOriginalValues can be removed
|
|
67
|
+
|
|
68
|
+
}, {
|
|
69
|
+
key: "saveOriginalValues",
|
|
70
|
+
value: function saveOriginalValues(values) {
|
|
71
|
+
this.originalValues.length = 0;
|
|
72
|
+
this.originalValues.push(...values);
|
|
61
73
|
} // TODO: getOriginalValues can be removed
|
|
62
74
|
|
|
63
75
|
}, {
|
|
@@ -16,20 +16,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
16
|
// TODO: This component can be refactored to remove redundant code after
|
|
17
17
|
// we can confirm that all Sage products use version 105.0.0^
|
|
18
18
|
const scrollBlockManager = new _scrollBlockManager.default();
|
|
19
|
-
/* istanbul ignore next */
|
|
20
|
-
|
|
21
|
-
const safeDocument = typeof document !== "undefined" ? document : {};
|
|
22
19
|
|
|
23
20
|
const useScrollBlock = () => {
|
|
24
21
|
const {
|
|
25
22
|
current: containerGuid
|
|
26
23
|
} = (0, _react.useRef)((0, _guid.default)());
|
|
27
|
-
const originalValuesRef = (0, _react.useRef)();
|
|
24
|
+
const originalValuesRef = (0, _react.useRef)([]);
|
|
28
25
|
const rules = (0, _react.useMemo)(() => {
|
|
26
|
+
/* istanbul ignore next */
|
|
29
27
|
const {
|
|
30
28
|
documentElement,
|
|
31
29
|
body
|
|
32
|
-
} =
|
|
30
|
+
} = document || {};
|
|
33
31
|
const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
|
|
34
32
|
const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
|
|
35
33
|
return [// TODO: First two entries of this array with the documentElement can be removed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default
|
|
1
|
+
export { default } from "./useMediaQuery";
|
|
@@ -3,30 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function useMediaQuery(queryInput) {
|
|
13
|
-
const query = queryInput.replace(/^@media( ?)/m, "");
|
|
14
|
-
|
|
15
|
-
const [match, setMatch] = _react.default.useState(() => false);
|
|
16
|
-
|
|
17
|
-
_react.default.useEffect(() => {
|
|
18
|
-
const queryList = window.matchMedia(query);
|
|
19
|
-
|
|
20
|
-
const updateMatch = () => {
|
|
21
|
-
setMatch(queryList.matches);
|
|
22
|
-
};
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useMediaQuery.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
23
12
|
|
|
24
|
-
|
|
25
|
-
queryList.addListener(updateMatch);
|
|
26
|
-
return () => {
|
|
27
|
-
queryList.removeListener(updateMatch);
|
|
28
|
-
};
|
|
29
|
-
}, [query]);
|
|
13
|
+
var _useMediaQuery = _interopRequireDefault(require("./useMediaQuery"));
|
|
30
14
|
|
|
31
|
-
|
|
32
|
-
}
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useMediaQuery(queryInput: string): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useMediaQuery;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
function useMediaQuery(queryInput) {
|
|
13
|
+
const query = queryInput.replace(/^@media( ?)/m, "");
|
|
14
|
+
|
|
15
|
+
const [match, setMatch] = _react.default.useState(() => false);
|
|
16
|
+
|
|
17
|
+
_react.default.useEffect(() => {
|
|
18
|
+
const queryList = window.matchMedia(query);
|
|
19
|
+
|
|
20
|
+
const updateMatch = () => {
|
|
21
|
+
setMatch(queryList.matches);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
updateMatch();
|
|
25
|
+
queryList.addListener(updateMatch);
|
|
26
|
+
return () => {
|
|
27
|
+
queryList.removeListener(updateMatch);
|
|
28
|
+
};
|
|
29
|
+
}, [query]);
|
|
30
|
+
|
|
31
|
+
return match;
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "105.
|
|
3
|
+
"version": "105.1.2",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -84,6 +84,8 @@
|
|
|
84
84
|
"@storybook/components": "^6.4.18",
|
|
85
85
|
"@storybook/react": "^6.4.18",
|
|
86
86
|
"@storybook/theming": "^6.4.18",
|
|
87
|
+
"@testing-library/jest-dom": "^5.16.2",
|
|
88
|
+
"@testing-library/react": "^12.1.3",
|
|
87
89
|
"@types/enzyme": "^3.10.3",
|
|
88
90
|
"@types/enzyme-adapter-react-16": "^1.0.5",
|
|
89
91
|
"@types/jest": "^26.0.19",
|
|
@@ -172,8 +174,8 @@
|
|
|
172
174
|
"polished": "^4.0.5",
|
|
173
175
|
"prop-types": "^15.7.2",
|
|
174
176
|
"react-day-picker": "~7.4.10",
|
|
175
|
-
"react-dnd": "^
|
|
176
|
-
"react-dnd-html5-backend": "^
|
|
177
|
+
"react-dnd": "^15.1.1",
|
|
178
|
+
"react-dnd-html5-backend": "^15.1.2",
|
|
177
179
|
"react-is": "^17.0.2",
|
|
178
180
|
"react-transition-group": "^4.4.1",
|
|
179
181
|
"styled-system": "^5.1.5",
|