@atlaskit/blanket 12.2.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/CHANGELOG.md +774 -0
- package/LICENSE +13 -0
- package/README.md +11 -0
- package/__perf__/default.tsx +5 -0
- package/__perf__/hideBlanket.tsx +58 -0
- package/__perf__/showBlanket.tsx +56 -0
- package/__perf__/withClickThroughDisabled.tsx +14 -0
- package/__perf__/withClickThroughEnabled.tsx +14 -0
- package/codemods/12.0.0-lite-mode.tsx +18 -0
- package/codemods/__tests__/rename-canclickthrough-to-shouldallowclickthrough.tsx +167 -0
- package/codemods/internal/constants.tsx +3 -0
- package/codemods/migrations/rename-canclickthrough-to-shouldallowclickthrough.tsx +13 -0
- package/dist/cjs/blanket.js +112 -0
- package/dist/cjs/entry-points/types.js +5 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/blanket.js +79 -0
- package/dist/es2019/entry-points/types.js +1 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/blanket.js +89 -0
- package/dist/esm/entry-points/types.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/blanket.d.ts +12 -0
- package/dist/types/entry-points/types.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types.d.ts +30 -0
- package/package.json +80 -0
- package/types/package.json +7 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "default", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _blanket.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var _blanket = _interopRequireDefault(require("./blanket"));
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React, { forwardRef, memo, useCallback } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
5
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
6
|
+
import { DN90A, N100A } from '@atlaskit/theme/colors';
|
|
7
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
8
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
9
|
+
import { token } from '@atlaskit/tokens';
|
|
10
|
+
const packageName = "@atlaskit/blanket";
|
|
11
|
+
const packageVersion = "12.2.2";
|
|
12
|
+
const analyticsAttributes = {
|
|
13
|
+
componentName: 'blanket',
|
|
14
|
+
packageName,
|
|
15
|
+
packageVersion
|
|
16
|
+
};
|
|
17
|
+
const baseStyles = css({
|
|
18
|
+
position: 'fixed',
|
|
19
|
+
zIndex: layers.blanket(),
|
|
20
|
+
top: 0,
|
|
21
|
+
right: 0,
|
|
22
|
+
bottom: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
overflowY: 'auto',
|
|
25
|
+
pointerEvents: 'initial'
|
|
26
|
+
});
|
|
27
|
+
const shouldAllowClickThroughStyles = css({
|
|
28
|
+
pointerEvents: 'none'
|
|
29
|
+
});
|
|
30
|
+
const invisibleStyles = css({
|
|
31
|
+
backgroundColor: 'transparent'
|
|
32
|
+
});
|
|
33
|
+
const lightBgStyles = css({
|
|
34
|
+
backgroundColor: token('color.background.blanket', N100A)
|
|
35
|
+
});
|
|
36
|
+
const darkBgStyles = css({
|
|
37
|
+
backgroundColor: token('color.background.blanket', DN90A)
|
|
38
|
+
});
|
|
39
|
+
const backgroundStyle = {
|
|
40
|
+
light: lightBgStyles,
|
|
41
|
+
dark: darkBgStyles
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* __Blanket__
|
|
45
|
+
*
|
|
46
|
+
* A Blanket provides the overlay layer for components such as a modal dialog or a tooltip
|
|
47
|
+
*
|
|
48
|
+
* - [Examples](https://atlaskit.atlassian.com/examples/design-system/blanket/basic-usage)
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
const Blanket = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Blanket({
|
|
52
|
+
shouldAllowClickThrough = false,
|
|
53
|
+
isTinted = false,
|
|
54
|
+
onBlanketClicked = noop,
|
|
55
|
+
testId,
|
|
56
|
+
children,
|
|
57
|
+
analyticsContext
|
|
58
|
+
}, ref) {
|
|
59
|
+
const {
|
|
60
|
+
mode
|
|
61
|
+
} = useGlobalTheme();
|
|
62
|
+
const onBlanketClickedWithAnalytics = usePlatformLeafEventHandler({
|
|
63
|
+
fn: onBlanketClicked,
|
|
64
|
+
action: 'clicked',
|
|
65
|
+
analyticsData: analyticsContext,
|
|
66
|
+
...analyticsAttributes
|
|
67
|
+
});
|
|
68
|
+
const blanketClickOutsideChildren = useCallback(e => e.currentTarget === e.target ? onBlanketClickedWithAnalytics(e) : undefined, [onBlanketClickedWithAnalytics]);
|
|
69
|
+
const onClick = shouldAllowClickThrough ? undefined : blanketClickOutsideChildren;
|
|
70
|
+
return jsx("div", {
|
|
71
|
+
role: "presentation",
|
|
72
|
+
css: [baseStyles, shouldAllowClickThrough && shouldAllowClickThroughStyles, backgroundStyle[mode], !isTinted && invisibleStyles],
|
|
73
|
+
onClick: onClick,
|
|
74
|
+
"data-testid": testId,
|
|
75
|
+
ref: ref
|
|
76
|
+
}, children);
|
|
77
|
+
}));
|
|
78
|
+
Blanket.displayName = 'Blanket';
|
|
79
|
+
export default Blanket;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './blanket';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
|
|
7
|
+
/** @jsx jsx */
|
|
8
|
+
import React, { forwardRef, memo, useCallback } from 'react';
|
|
9
|
+
import { css, jsx } from '@emotion/core';
|
|
10
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
11
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
12
|
+
import { DN90A, N100A } from '@atlaskit/theme/colors';
|
|
13
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
14
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
15
|
+
import { token } from '@atlaskit/tokens';
|
|
16
|
+
var packageName = "@atlaskit/blanket";
|
|
17
|
+
var packageVersion = "12.2.2";
|
|
18
|
+
var analyticsAttributes = {
|
|
19
|
+
componentName: 'blanket',
|
|
20
|
+
packageName: packageName,
|
|
21
|
+
packageVersion: packageVersion
|
|
22
|
+
};
|
|
23
|
+
var baseStyles = css({
|
|
24
|
+
position: 'fixed',
|
|
25
|
+
zIndex: layers.blanket(),
|
|
26
|
+
top: 0,
|
|
27
|
+
right: 0,
|
|
28
|
+
bottom: 0,
|
|
29
|
+
left: 0,
|
|
30
|
+
overflowY: 'auto',
|
|
31
|
+
pointerEvents: 'initial'
|
|
32
|
+
});
|
|
33
|
+
var shouldAllowClickThroughStyles = css({
|
|
34
|
+
pointerEvents: 'none'
|
|
35
|
+
});
|
|
36
|
+
var invisibleStyles = css({
|
|
37
|
+
backgroundColor: 'transparent'
|
|
38
|
+
});
|
|
39
|
+
var lightBgStyles = css({
|
|
40
|
+
backgroundColor: token('color.background.blanket', N100A)
|
|
41
|
+
});
|
|
42
|
+
var darkBgStyles = css({
|
|
43
|
+
backgroundColor: token('color.background.blanket', DN90A)
|
|
44
|
+
});
|
|
45
|
+
var backgroundStyle = {
|
|
46
|
+
light: lightBgStyles,
|
|
47
|
+
dark: darkBgStyles
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* __Blanket__
|
|
51
|
+
*
|
|
52
|
+
* A Blanket provides the overlay layer for components such as a modal dialog or a tooltip
|
|
53
|
+
*
|
|
54
|
+
* - [Examples](https://atlaskit.atlassian.com/examples/design-system/blanket/basic-usage)
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
var Blanket = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Blanket(_ref, ref) {
|
|
58
|
+
var _ref$shouldAllowClick = _ref.shouldAllowClickThrough,
|
|
59
|
+
shouldAllowClickThrough = _ref$shouldAllowClick === void 0 ? false : _ref$shouldAllowClick,
|
|
60
|
+
_ref$isTinted = _ref.isTinted,
|
|
61
|
+
isTinted = _ref$isTinted === void 0 ? false : _ref$isTinted,
|
|
62
|
+
_ref$onBlanketClicked = _ref.onBlanketClicked,
|
|
63
|
+
onBlanketClicked = _ref$onBlanketClicked === void 0 ? noop : _ref$onBlanketClicked,
|
|
64
|
+
testId = _ref.testId,
|
|
65
|
+
children = _ref.children,
|
|
66
|
+
analyticsContext = _ref.analyticsContext;
|
|
67
|
+
|
|
68
|
+
var _useGlobalTheme = useGlobalTheme(),
|
|
69
|
+
mode = _useGlobalTheme.mode;
|
|
70
|
+
|
|
71
|
+
var onBlanketClickedWithAnalytics = usePlatformLeafEventHandler(_objectSpread({
|
|
72
|
+
fn: onBlanketClicked,
|
|
73
|
+
action: 'clicked',
|
|
74
|
+
analyticsData: analyticsContext
|
|
75
|
+
}, analyticsAttributes));
|
|
76
|
+
var blanketClickOutsideChildren = useCallback(function (e) {
|
|
77
|
+
return e.currentTarget === e.target ? onBlanketClickedWithAnalytics(e) : undefined;
|
|
78
|
+
}, [onBlanketClickedWithAnalytics]);
|
|
79
|
+
var onClick = shouldAllowClickThrough ? undefined : blanketClickOutsideChildren;
|
|
80
|
+
return jsx("div", {
|
|
81
|
+
role: "presentation",
|
|
82
|
+
css: [baseStyles, shouldAllowClickThrough && shouldAllowClickThroughStyles, backgroundStyle[mode], !isTinted && invisibleStyles],
|
|
83
|
+
onClick: onClick,
|
|
84
|
+
"data-testid": testId,
|
|
85
|
+
ref: ref
|
|
86
|
+
}, children);
|
|
87
|
+
}));
|
|
88
|
+
Blanket.displayName = 'Blanket';
|
|
89
|
+
export default Blanket;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './blanket';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { BlanketProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* __Blanket__
|
|
6
|
+
*
|
|
7
|
+
* A Blanket provides the overlay layer for components such as a modal dialog or a tooltip
|
|
8
|
+
*
|
|
9
|
+
* - [Examples](https://atlaskit.atlassian.com/examples/design-system/blanket/basic-usage)
|
|
10
|
+
*/
|
|
11
|
+
declare const Blanket: React.MemoExoticComponent<React.ForwardRefExoticComponent<BlanketProps & React.RefAttributes<HTMLDivElement>>>;
|
|
12
|
+
export default Blanket;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { BlanketProps } from '../types';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import UIAnalyticsEvent from '@atlaskit/analytics-next/UIAnalyticsEvent';
|
|
3
|
+
export interface BlanketProps {
|
|
4
|
+
/**
|
|
5
|
+
* Whether mouse events can pierce the blanket. If true, onBlanketClicked will not be fired.
|
|
6
|
+
*/
|
|
7
|
+
shouldAllowClickThrough?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the blanket has a tinted background color.
|
|
10
|
+
*/
|
|
11
|
+
isTinted?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Handler function to be called when the blanket is clicked.
|
|
14
|
+
*/
|
|
15
|
+
onBlanketClicked?: (event: React.MouseEvent<HTMLDivElement>, analyticsEvent: UIAnalyticsEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Additional information to be included in the `context` of analytics events.
|
|
18
|
+
*/
|
|
19
|
+
analyticsContext?: Record<string, any>;
|
|
20
|
+
/**
|
|
21
|
+
* A `testId` prop is provided for specified elements,
|
|
22
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
23
|
+
* serving as a hook for automated tests.
|
|
24
|
+
*/
|
|
25
|
+
testId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The children to be rendered within Blanket.
|
|
28
|
+
*/
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/blanket",
|
|
3
|
+
"version": "12.2.2",
|
|
4
|
+
"description": "A React component that covers the underlying UI for a layered component.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"registry": "https://registry.npmjs.org/"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
9
|
+
"author": "Atlassian Pty Ltd",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"main": "dist/cjs/index.js",
|
|
12
|
+
"module": "dist/esm/index.js",
|
|
13
|
+
"module:es2019": "dist/es2019/index.js",
|
|
14
|
+
"types": "dist/types/index.d.ts",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"atlaskit:src": "src/index.tsx",
|
|
17
|
+
"atlaskit:designLink": "https://atlassian.design/guidelines/product/components/modal-dialog",
|
|
18
|
+
"atlassian": {
|
|
19
|
+
"team": "Design System Team",
|
|
20
|
+
"inPublicMirror": true,
|
|
21
|
+
"releaseModel": "scheduled",
|
|
22
|
+
"website": {
|
|
23
|
+
"name": "Blanket"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"af:exports": {
|
|
27
|
+
".": "./src/index.tsx",
|
|
28
|
+
"./types": "./src/entry-points/types.tsx"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@atlaskit/analytics-next": "^8.2.0",
|
|
32
|
+
"@atlaskit/codemod-utils": "^3.4.0",
|
|
33
|
+
"@atlaskit/ds-lib": "^1.3.0",
|
|
34
|
+
"@atlaskit/theme": "^12.0.0",
|
|
35
|
+
"@atlaskit/tokens": "^0.2.0",
|
|
36
|
+
"@babel/runtime": "^7.0.0",
|
|
37
|
+
"@emotion/core": "^10.0.9"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react": "^16.8.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@atlaskit/badge": "^15.0.0",
|
|
44
|
+
"@atlaskit/build-utils": "*",
|
|
45
|
+
"@atlaskit/button": "^16.1.0",
|
|
46
|
+
"@atlaskit/docs": "*",
|
|
47
|
+
"@atlaskit/ssr": "*",
|
|
48
|
+
"@atlaskit/toggle": "^12.3.0",
|
|
49
|
+
"@atlaskit/visual-regression": "*",
|
|
50
|
+
"@atlaskit/webdriver-runner": "*",
|
|
51
|
+
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
52
|
+
"@testing-library/dom": "^7.7.3",
|
|
53
|
+
"@testing-library/react": "^8.0.1",
|
|
54
|
+
"jscodeshift": "^0.13.0",
|
|
55
|
+
"react-dom": "^16.8.0",
|
|
56
|
+
"react-lorem-component": "^0.13.0",
|
|
57
|
+
"storybook-addon-performance": "^0.16.0",
|
|
58
|
+
"typescript": "3.9.6",
|
|
59
|
+
"wait-for-expect": "^1.2.0"
|
|
60
|
+
},
|
|
61
|
+
"keywords": [
|
|
62
|
+
"atlaskit",
|
|
63
|
+
"react",
|
|
64
|
+
"ui"
|
|
65
|
+
],
|
|
66
|
+
"techstack": {
|
|
67
|
+
"@atlassian/frontend": {
|
|
68
|
+
"import-structure": "atlassian-conventions"
|
|
69
|
+
},
|
|
70
|
+
"@repo/internal": {
|
|
71
|
+
"design-system": "v1",
|
|
72
|
+
"styling": "emotion",
|
|
73
|
+
"ui-components": "lite-mode",
|
|
74
|
+
"analytics": "analytics-next",
|
|
75
|
+
"theming": "tokens",
|
|
76
|
+
"deprecation": "no-deprecated-imports"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
80
|
+
}
|