@atlaskit/spotlight 0.0.7 → 0.0.8
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 +10 -0
- package/dist/cjs/controllers/context.js +39 -0
- package/dist/cjs/types.js +1 -5
- package/dist/cjs/ui/headline/index.js +1 -0
- package/dist/cjs/ui/popover-content/index.js +26 -3
- package/dist/cjs/ui/popover-provider/index.js +2 -1
- package/dist/cjs/ui/spotlight/caret/index.compiled.css +4 -0
- package/dist/cjs/ui/spotlight/caret/index.js +30 -0
- package/dist/cjs/ui/spotlight/index.compiled.css +12 -2
- package/dist/cjs/ui/spotlight/index.js +22 -7
- package/dist/es2019/controllers/context.js +26 -0
- package/dist/es2019/types.js +0 -1
- package/dist/es2019/ui/headline/index.js +1 -0
- package/dist/es2019/ui/popover-content/index.js +26 -3
- package/dist/es2019/ui/popover-provider/index.js +4 -3
- package/dist/es2019/ui/popover-target/index.js +2 -2
- package/dist/es2019/ui/spotlight/caret/index.compiled.css +4 -0
- package/dist/es2019/ui/spotlight/caret/index.js +23 -0
- package/dist/es2019/ui/spotlight/index.compiled.css +12 -2
- package/dist/es2019/ui/spotlight/index.js +24 -8
- package/dist/esm/controllers/context.js +31 -0
- package/dist/esm/types.js +0 -1
- package/dist/esm/ui/headline/index.js +1 -0
- package/dist/esm/ui/popover-content/index.js +25 -3
- package/dist/esm/ui/popover-provider/index.js +4 -3
- package/dist/esm/ui/popover-target/index.js +2 -2
- package/dist/esm/ui/spotlight/caret/index.compiled.css +4 -0
- package/dist/esm/ui/spotlight/caret/index.js +22 -0
- package/dist/esm/ui/spotlight/index.compiled.css +12 -2
- package/dist/esm/ui/spotlight/index.js +23 -8
- package/dist/types/controllers/context.d.ts +11 -0
- package/dist/types/types.d.ts +1 -2
- package/dist/types/ui/popover-content/index.d.ts +2 -2
- package/dist/types/ui/popover-provider/index.d.ts +1 -1
- package/dist/types/ui/popover-target/index.d.ts +1 -1
- package/dist/types/ui/spotlight/caret/index.d.ts +20 -0
- package/dist/types-ts4.5/controllers/context.d.ts +11 -0
- package/dist/types-ts4.5/types.d.ts +1 -2
- package/dist/types-ts4.5/ui/popover-content/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/popover-provider/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/popover-target/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/spotlight/caret/index.d.ts +20 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/spotlight
|
|
2
2
|
|
|
3
|
+
## 0.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9d9570259070a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9d9570259070a) -
|
|
8
|
+
Create PopoverProvider, PopoverTarget, PopoverContent components.
|
|
9
|
+
- [`9d9570259070a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9d9570259070a) -
|
|
10
|
+
Create Caret component. Positions the Spotlight UI card in relation to the Caret component, and
|
|
11
|
+
positions the Caret component in relation to the PopoverTarget element.
|
|
12
|
+
|
|
3
13
|
## 0.0.7
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.SpotlightContextProvider = exports.SpotlightContext = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
|
+
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
15
|
+
var SpotlightContext = exports.SpotlightContext = /*#__PURE__*/(0, _react.createContext)({
|
|
16
|
+
placement: 'bottom-end',
|
|
17
|
+
setPlacement: function setPlacement() {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
23
|
+
var SpotlightContextProvider = exports.SpotlightContextProvider = function SpotlightContextProvider(_ref) {
|
|
24
|
+
var children = _ref.children;
|
|
25
|
+
var _useState = (0, _react.useState)('bottom-end'),
|
|
26
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
27
|
+
placement = _useState2[0],
|
|
28
|
+
setPlacement = _useState2[1];
|
|
29
|
+
return (
|
|
30
|
+
/*#__PURE__*/
|
|
31
|
+
// eslint-disable-next-line react/react-in-jsx-scope
|
|
32
|
+
_react.default.createElement(SpotlightContext.Provider, {
|
|
33
|
+
value: {
|
|
34
|
+
placement: placement,
|
|
35
|
+
setPlacement: setPlacement
|
|
36
|
+
}
|
|
37
|
+
}, children)
|
|
38
|
+
);
|
|
39
|
+
};
|
package/dist/cjs/types.js
CHANGED
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.PopoverContent = void 0;
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _popper = require("@atlaskit/popper");
|
|
10
|
+
var _context = require("../../controllers/context");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
|
+
/**
|
|
13
|
+
* The Spotlight card can be positioned in many different configurations, but the caret should always point to
|
|
14
|
+
* the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
|
|
15
|
+
* this center alignment along the respective face. So we translate between the Spotlight position, and the
|
|
16
|
+
* Popper position using this map.
|
|
17
|
+
*/
|
|
18
|
+
var popperPlacementMap = {
|
|
19
|
+
'top-start': 'top',
|
|
20
|
+
'top-end': 'top',
|
|
21
|
+
'bottom-start': 'bottom',
|
|
22
|
+
'bottom-end': 'bottom',
|
|
23
|
+
'right-start': 'right',
|
|
24
|
+
'right-end': 'right',
|
|
25
|
+
'left-start': 'left',
|
|
26
|
+
'left-end': 'left'
|
|
27
|
+
};
|
|
28
|
+
|
|
10
29
|
/**
|
|
11
30
|
* __PopoverContent__
|
|
12
31
|
*
|
|
@@ -15,8 +34,12 @@ var _popper = require("@atlaskit/popper");
|
|
|
15
34
|
var PopoverContent = exports.PopoverContent = function PopoverContent(_ref) {
|
|
16
35
|
var children = _ref.children,
|
|
17
36
|
placement = _ref.placement;
|
|
37
|
+
var _useContext = (0, _react.useContext)(_context.SpotlightContext),
|
|
38
|
+
setPlacement = _useContext.setPlacement;
|
|
39
|
+
setPlacement(placement);
|
|
18
40
|
return /*#__PURE__*/_react.default.createElement(_popper.Popper, {
|
|
19
|
-
|
|
41
|
+
offset: [0, 0],
|
|
42
|
+
placement: popperPlacementMap[placement]
|
|
20
43
|
}, function (_ref2) {
|
|
21
44
|
var ref = _ref2.ref,
|
|
22
45
|
style = _ref2.style;
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.PopoverProvider = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _popper = require("@atlaskit/popper");
|
|
10
|
+
var _context = require("../../controllers/context");
|
|
10
11
|
/**
|
|
11
12
|
* __Popover provider__
|
|
12
13
|
*
|
|
@@ -15,5 +16,5 @@ var _popper = require("@atlaskit/popper");
|
|
|
15
16
|
*/
|
|
16
17
|
var PopoverProvider = exports.PopoverProvider = function PopoverProvider(_ref) {
|
|
17
18
|
var children = _ref.children;
|
|
18
|
-
return /*#__PURE__*/_react.default.createElement(_popper.Manager, null, children);
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement(_context.SpotlightContextProvider, null, /*#__PURE__*/_react.default.createElement(_popper.Manager, null, children));
|
|
19
20
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.Caret = void 0;
|
|
9
|
+
require("./index.compiled.css");
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var React = _react;
|
|
12
|
+
var _runtime = require("@compiled/react/runtime");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
+
var styles = {
|
|
15
|
+
root: "_1bsb7vkz _4t3i7vkz _t9ecjyd4 _bfhkcdhy"
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* __Caret__
|
|
19
|
+
*
|
|
20
|
+
* A `Caret` is a purely visual pointer displayed on the edge of a spotlight, which points to the target element.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
var Caret = exports.Caret = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
24
|
+
var testId = _ref.testId;
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
"data-testid": testId,
|
|
27
|
+
ref: ref,
|
|
28
|
+
className: (0, _runtime.ax)([styles.root])
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
._2rkopd34{border-radius:var(--ds-border-radius-200,8px)}.
|
|
3
|
-
.
|
|
2
|
+
._2rkopd34{border-radius:var(--ds-border-radius-200,8px)}._154imgjw{top:var(--ds-space-negative-200,-1pc)}
|
|
3
|
+
._154iu2gc{top:var(--ds-space-100,8px)}
|
|
4
|
+
._1bsbaq3k{width:295px}
|
|
5
|
+
._1ltvmgjw{left:var(--ds-space-negative-200,-1pc)}
|
|
6
|
+
._1ltvu2gc{left:var(--ds-space-100,8px)}
|
|
7
|
+
._1xi2mgjw{right:var(--ds-space-negative-200,-1pc)}
|
|
8
|
+
._1xi2u2gc{right:var(--ds-space-100,8px)}
|
|
9
|
+
._94n5mgjw{bottom:var(--ds-space-negative-200,-1pc)}
|
|
10
|
+
._94n5u2gc{bottom:var(--ds-space-100,8px)}
|
|
11
|
+
._bfhkcdhy{background-color:var(--ds-background-neutral-bold,#44546f)}
|
|
12
|
+
._kqswh2mm{position:relative}
|
|
13
|
+
._kqswstnw{position:absolute}
|
|
@@ -10,10 +10,22 @@ require("./index.compiled.css");
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var React = _react;
|
|
12
12
|
var _runtime = require("@compiled/react/runtime");
|
|
13
|
-
var
|
|
13
|
+
var _context = require("../../controllers/context");
|
|
14
|
+
var _caret = require("./caret");
|
|
14
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
15
16
|
var styles = {
|
|
16
|
-
root: "
|
|
17
|
+
root: "_kqswh2mm",
|
|
18
|
+
card: "_2rkopd34 _kqswstnw _1bsbaq3k _bfhkcdhy"
|
|
19
|
+
};
|
|
20
|
+
var placementStyles = {
|
|
21
|
+
'top-start': "_94n5u2gc _1xi2mgjw",
|
|
22
|
+
'top-end': "_94n5u2gc _1ltvmgjw",
|
|
23
|
+
'right-start': "_1ltvu2gc _94n5mgjw",
|
|
24
|
+
'right-end': "_1ltvu2gc _154imgjw",
|
|
25
|
+
'bottom-start': "_154iu2gc _1xi2mgjw",
|
|
26
|
+
'bottom-end': "_154iu2gc _1ltvmgjw",
|
|
27
|
+
'left-start': "_1xi2u2gc _94n5mgjw",
|
|
28
|
+
'left-end': "_1xi2u2gc _154imgjw"
|
|
17
29
|
};
|
|
18
30
|
/**
|
|
19
31
|
* __Spotlight__
|
|
@@ -24,10 +36,13 @@ var styles = {
|
|
|
24
36
|
var Spotlight = exports.Spotlight = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
25
37
|
var children = _ref.children,
|
|
26
38
|
testId = _ref.testId;
|
|
27
|
-
|
|
39
|
+
var _useContext = (0, _react.useContext)(_context.SpotlightContext),
|
|
40
|
+
placement = _useContext.placement;
|
|
41
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: (0, _runtime.ax)([styles.root])
|
|
43
|
+
}, /*#__PURE__*/React.createElement(_caret.Caret, null), /*#__PURE__*/React.createElement("div", {
|
|
28
44
|
ref: ref,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, children);
|
|
45
|
+
"data-testid": testId,
|
|
46
|
+
className: (0, _runtime.ax)([styles.card, placementStyles[placement]])
|
|
47
|
+
}, children));
|
|
33
48
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { createContext, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
6
|
+
export const SpotlightContext = /*#__PURE__*/createContext({
|
|
7
|
+
placement: 'bottom-end',
|
|
8
|
+
setPlacement: () => undefined
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
12
|
+
export const SpotlightContextProvider = ({
|
|
13
|
+
children
|
|
14
|
+
}) => {
|
|
15
|
+
const [placement, setPlacement] = useState('bottom-end');
|
|
16
|
+
return (
|
|
17
|
+
/*#__PURE__*/
|
|
18
|
+
// eslint-disable-next-line react/react-in-jsx-scope
|
|
19
|
+
React.createElement(SpotlightContext.Provider, {
|
|
20
|
+
value: {
|
|
21
|
+
placement,
|
|
22
|
+
setPlacement
|
|
23
|
+
}
|
|
24
|
+
}, children)
|
|
25
|
+
);
|
|
26
|
+
};
|
package/dist/es2019/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Popper } from
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { Popper } from '@atlaskit/popper';
|
|
3
|
+
import { SpotlightContext } from '../../controllers/context';
|
|
4
|
+
/**
|
|
5
|
+
* The Spotlight card can be positioned in many different configurations, but the caret should always point to
|
|
6
|
+
* the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
|
|
7
|
+
* this center alignment along the respective face. So we translate between the Spotlight position, and the
|
|
8
|
+
* Popper position using this map.
|
|
9
|
+
*/
|
|
10
|
+
const popperPlacementMap = {
|
|
11
|
+
'top-start': 'top',
|
|
12
|
+
'top-end': 'top',
|
|
13
|
+
'bottom-start': 'bottom',
|
|
14
|
+
'bottom-end': 'bottom',
|
|
15
|
+
'right-start': 'right',
|
|
16
|
+
'right-end': 'right',
|
|
17
|
+
'left-start': 'left',
|
|
18
|
+
'left-end': 'left'
|
|
19
|
+
};
|
|
20
|
+
|
|
3
21
|
/**
|
|
4
22
|
* __PopoverContent__
|
|
5
23
|
*
|
|
@@ -9,8 +27,13 @@ export const PopoverContent = ({
|
|
|
9
27
|
children,
|
|
10
28
|
placement
|
|
11
29
|
}) => {
|
|
30
|
+
const {
|
|
31
|
+
setPlacement
|
|
32
|
+
} = useContext(SpotlightContext);
|
|
33
|
+
setPlacement(placement);
|
|
12
34
|
return /*#__PURE__*/React.createElement(Popper, {
|
|
13
|
-
|
|
35
|
+
offset: [0, 0],
|
|
36
|
+
placement: popperPlacementMap[placement]
|
|
14
37
|
}, ({
|
|
15
38
|
ref,
|
|
16
39
|
style
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Manager } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Manager } from '@atlaskit/popper';
|
|
3
|
+
import { SpotlightContextProvider } from '../../controllers/context';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* __Popover provider__
|
|
@@ -10,5 +11,5 @@ import { Manager } from "@atlaskit/popper";
|
|
|
10
11
|
export const PopoverProvider = ({
|
|
11
12
|
children
|
|
12
13
|
}) => {
|
|
13
|
-
return /*#__PURE__*/React.createElement(Manager, null, children);
|
|
14
|
+
return /*#__PURE__*/React.createElement(SpotlightContextProvider, null, /*#__PURE__*/React.createElement(Manager, null, children));
|
|
14
15
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./index.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { forwardRef } from 'react';
|
|
6
|
+
const styles = {
|
|
7
|
+
root: "_1bsb7vkz _4t3i7vkz _t9ecjyd4 _bfhkcdhy"
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* __Caret__
|
|
11
|
+
*
|
|
12
|
+
* A `Caret` is a purely visual pointer displayed on the edge of a spotlight, which points to the target element.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export const Caret = /*#__PURE__*/forwardRef(({
|
|
16
|
+
testId
|
|
17
|
+
}, ref) => {
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
"data-testid": testId,
|
|
20
|
+
ref: ref,
|
|
21
|
+
className: ax([styles.root])
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
._2rkopd34{border-radius:var(--ds-border-radius-200,8px)}.
|
|
3
|
-
.
|
|
2
|
+
._2rkopd34{border-radius:var(--ds-border-radius-200,8px)}._154imgjw{top:var(--ds-space-negative-200,-1pc)}
|
|
3
|
+
._154iu2gc{top:var(--ds-space-100,8px)}
|
|
4
|
+
._1bsbaq3k{width:295px}
|
|
5
|
+
._1ltvmgjw{left:var(--ds-space-negative-200,-1pc)}
|
|
6
|
+
._1ltvu2gc{left:var(--ds-space-100,8px)}
|
|
7
|
+
._1xi2mgjw{right:var(--ds-space-negative-200,-1pc)}
|
|
8
|
+
._1xi2u2gc{right:var(--ds-space-100,8px)}
|
|
9
|
+
._94n5mgjw{bottom:var(--ds-space-negative-200,-1pc)}
|
|
10
|
+
._94n5u2gc{bottom:var(--ds-space-100,8px)}
|
|
11
|
+
._bfhkcdhy{background-color:var(--ds-background-neutral-bold,#44546f)}
|
|
12
|
+
._kqswh2mm{position:relative}
|
|
13
|
+
._kqswstnw{position:absolute}
|
|
@@ -2,10 +2,22 @@
|
|
|
2
2
|
import "./index.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { forwardRef } from 'react';
|
|
6
|
-
import {
|
|
5
|
+
import { forwardRef, useContext } from 'react';
|
|
6
|
+
import { SpotlightContext } from '../../controllers/context';
|
|
7
|
+
import { Caret } from './caret';
|
|
7
8
|
const styles = {
|
|
8
|
-
root: "
|
|
9
|
+
root: "_kqswh2mm",
|
|
10
|
+
card: "_2rkopd34 _kqswstnw _1bsbaq3k _bfhkcdhy"
|
|
11
|
+
};
|
|
12
|
+
const placementStyles = {
|
|
13
|
+
'top-start': "_94n5u2gc _1xi2mgjw",
|
|
14
|
+
'top-end': "_94n5u2gc _1ltvmgjw",
|
|
15
|
+
'right-start': "_1ltvu2gc _94n5mgjw",
|
|
16
|
+
'right-end': "_1ltvu2gc _154imgjw",
|
|
17
|
+
'bottom-start': "_154iu2gc _1xi2mgjw",
|
|
18
|
+
'bottom-end': "_154iu2gc _1ltvmgjw",
|
|
19
|
+
'left-start': "_1xi2u2gc _94n5mgjw",
|
|
20
|
+
'left-end': "_1xi2u2gc _154imgjw"
|
|
9
21
|
};
|
|
10
22
|
/**
|
|
11
23
|
* __Spotlight__
|
|
@@ -17,10 +29,14 @@ export const Spotlight = /*#__PURE__*/forwardRef(({
|
|
|
17
29
|
children,
|
|
18
30
|
testId
|
|
19
31
|
}, ref) => {
|
|
20
|
-
|
|
32
|
+
const {
|
|
33
|
+
placement
|
|
34
|
+
} = useContext(SpotlightContext);
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: ax([styles.root])
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Caret, null), /*#__PURE__*/React.createElement("div", {
|
|
21
38
|
ref: ref,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, children);
|
|
39
|
+
"data-testid": testId,
|
|
40
|
+
className: ax([styles.card, placementStyles[placement]])
|
|
41
|
+
}, children));
|
|
26
42
|
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { createContext, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
7
|
+
export var SpotlightContext = /*#__PURE__*/createContext({
|
|
8
|
+
placement: 'bottom-end',
|
|
9
|
+
setPlacement: function setPlacement() {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
15
|
+
export var SpotlightContextProvider = function SpotlightContextProvider(_ref) {
|
|
16
|
+
var children = _ref.children;
|
|
17
|
+
var _useState = useState('bottom-end'),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
placement = _useState2[0],
|
|
20
|
+
setPlacement = _useState2[1];
|
|
21
|
+
return (
|
|
22
|
+
/*#__PURE__*/
|
|
23
|
+
// eslint-disable-next-line react/react-in-jsx-scope
|
|
24
|
+
React.createElement(SpotlightContext.Provider, {
|
|
25
|
+
value: {
|
|
26
|
+
placement: placement,
|
|
27
|
+
setPlacement: setPlacement
|
|
28
|
+
}
|
|
29
|
+
}, children)
|
|
30
|
+
);
|
|
31
|
+
};
|
package/dist/esm/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Popper } from
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { Popper } from '@atlaskit/popper';
|
|
3
|
+
import { SpotlightContext } from '../../controllers/context';
|
|
4
|
+
/**
|
|
5
|
+
* The Spotlight card can be positioned in many different configurations, but the caret should always point to
|
|
6
|
+
* the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
|
|
7
|
+
* this center alignment along the respective face. So we translate between the Spotlight position, and the
|
|
8
|
+
* Popper position using this map.
|
|
9
|
+
*/
|
|
10
|
+
var popperPlacementMap = {
|
|
11
|
+
'top-start': 'top',
|
|
12
|
+
'top-end': 'top',
|
|
13
|
+
'bottom-start': 'bottom',
|
|
14
|
+
'bottom-end': 'bottom',
|
|
15
|
+
'right-start': 'right',
|
|
16
|
+
'right-end': 'right',
|
|
17
|
+
'left-start': 'left',
|
|
18
|
+
'left-end': 'left'
|
|
19
|
+
};
|
|
20
|
+
|
|
3
21
|
/**
|
|
4
22
|
* __PopoverContent__
|
|
5
23
|
*
|
|
@@ -8,8 +26,12 @@ import { Popper } from "@atlaskit/popper";
|
|
|
8
26
|
export var PopoverContent = function PopoverContent(_ref) {
|
|
9
27
|
var children = _ref.children,
|
|
10
28
|
placement = _ref.placement;
|
|
29
|
+
var _useContext = useContext(SpotlightContext),
|
|
30
|
+
setPlacement = _useContext.setPlacement;
|
|
31
|
+
setPlacement(placement);
|
|
11
32
|
return /*#__PURE__*/React.createElement(Popper, {
|
|
12
|
-
|
|
33
|
+
offset: [0, 0],
|
|
34
|
+
placement: popperPlacementMap[placement]
|
|
13
35
|
}, function (_ref2) {
|
|
14
36
|
var ref = _ref2.ref,
|
|
15
37
|
style = _ref2.style;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Manager } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Manager } from '@atlaskit/popper';
|
|
3
|
+
import { SpotlightContextProvider } from '../../controllers/context';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* __Popover provider__
|
|
@@ -9,5 +10,5 @@ import { Manager } from "@atlaskit/popper";
|
|
|
9
10
|
*/
|
|
10
11
|
export var PopoverProvider = function PopoverProvider(_ref) {
|
|
11
12
|
var children = _ref.children;
|
|
12
|
-
return /*#__PURE__*/React.createElement(Manager, null, children);
|
|
13
|
+
return /*#__PURE__*/React.createElement(SpotlightContextProvider, null, /*#__PURE__*/React.createElement(Manager, null, children));
|
|
13
14
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./index.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { forwardRef } from 'react';
|
|
6
|
+
var styles = {
|
|
7
|
+
root: "_1bsb7vkz _4t3i7vkz _t9ecjyd4 _bfhkcdhy"
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* __Caret__
|
|
11
|
+
*
|
|
12
|
+
* A `Caret` is a purely visual pointer displayed on the edge of a spotlight, which points to the target element.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export var Caret = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
16
|
+
var testId = _ref.testId;
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
"data-testid": testId,
|
|
19
|
+
ref: ref,
|
|
20
|
+
className: ax([styles.root])
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
._2rkopd34{border-radius:var(--ds-border-radius-200,8px)}.
|
|
3
|
-
.
|
|
2
|
+
._2rkopd34{border-radius:var(--ds-border-radius-200,8px)}._154imgjw{top:var(--ds-space-negative-200,-1pc)}
|
|
3
|
+
._154iu2gc{top:var(--ds-space-100,8px)}
|
|
4
|
+
._1bsbaq3k{width:295px}
|
|
5
|
+
._1ltvmgjw{left:var(--ds-space-negative-200,-1pc)}
|
|
6
|
+
._1ltvu2gc{left:var(--ds-space-100,8px)}
|
|
7
|
+
._1xi2mgjw{right:var(--ds-space-negative-200,-1pc)}
|
|
8
|
+
._1xi2u2gc{right:var(--ds-space-100,8px)}
|
|
9
|
+
._94n5mgjw{bottom:var(--ds-space-negative-200,-1pc)}
|
|
10
|
+
._94n5u2gc{bottom:var(--ds-space-100,8px)}
|
|
11
|
+
._bfhkcdhy{background-color:var(--ds-background-neutral-bold,#44546f)}
|
|
12
|
+
._kqswh2mm{position:relative}
|
|
13
|
+
._kqswstnw{position:absolute}
|
|
@@ -2,10 +2,22 @@
|
|
|
2
2
|
import "./index.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { forwardRef } from 'react';
|
|
6
|
-
import {
|
|
5
|
+
import { forwardRef, useContext } from 'react';
|
|
6
|
+
import { SpotlightContext } from '../../controllers/context';
|
|
7
|
+
import { Caret } from './caret';
|
|
7
8
|
var styles = {
|
|
8
|
-
root: "
|
|
9
|
+
root: "_kqswh2mm",
|
|
10
|
+
card: "_2rkopd34 _kqswstnw _1bsbaq3k _bfhkcdhy"
|
|
11
|
+
};
|
|
12
|
+
var placementStyles = {
|
|
13
|
+
'top-start': "_94n5u2gc _1xi2mgjw",
|
|
14
|
+
'top-end': "_94n5u2gc _1ltvmgjw",
|
|
15
|
+
'right-start': "_1ltvu2gc _94n5mgjw",
|
|
16
|
+
'right-end': "_1ltvu2gc _154imgjw",
|
|
17
|
+
'bottom-start': "_154iu2gc _1xi2mgjw",
|
|
18
|
+
'bottom-end': "_154iu2gc _1ltvmgjw",
|
|
19
|
+
'left-start': "_1xi2u2gc _94n5mgjw",
|
|
20
|
+
'left-end': "_1xi2u2gc _154imgjw"
|
|
9
21
|
};
|
|
10
22
|
/**
|
|
11
23
|
* __Spotlight__
|
|
@@ -16,10 +28,13 @@ var styles = {
|
|
|
16
28
|
export var Spotlight = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
17
29
|
var children = _ref.children,
|
|
18
30
|
testId = _ref.testId;
|
|
19
|
-
|
|
31
|
+
var _useContext = useContext(SpotlightContext),
|
|
32
|
+
placement = _useContext.placement;
|
|
33
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: ax([styles.root])
|
|
35
|
+
}, /*#__PURE__*/React.createElement(Caret, null), /*#__PURE__*/React.createElement("div", {
|
|
20
36
|
ref: ref,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, children);
|
|
37
|
+
"data-testid": testId,
|
|
38
|
+
className: ax([styles.card, placementStyles[placement]])
|
|
39
|
+
}, children));
|
|
25
40
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { type Dispatch, type ReactNode, type SetStateAction } from 'react';
|
|
2
|
+
import type { Placement } from '../types';
|
|
3
|
+
interface SpotlightContextType {
|
|
4
|
+
placement: Placement;
|
|
5
|
+
setPlacement: Dispatch<SetStateAction<Placement>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const SpotlightContext: React.Context<SpotlightContextType>;
|
|
8
|
+
export declare const SpotlightContextProvider: ({ children }: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}) => React.JSX.Element;
|
|
11
|
+
export {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type Placement = Extract<ADSPopperPlacement, "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end">;
|
|
1
|
+
export type Placement = 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'right-start' | 'right-end' | 'left-start' | 'left-end';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React, { type ReactNode } from
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
2
|
import type { Placement } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* __PopoverContent__
|
|
5
5
|
*
|
|
6
6
|
* A `PopoverContent` is the element that is shown as a popover.
|
|
7
7
|
*/
|
|
8
|
-
export declare const PopoverContent: ({ children, placement }: {
|
|
8
|
+
export declare const PopoverContent: ({ children, placement, }: {
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
placement: Placement;
|
|
11
11
|
}) => React.JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
/// <reference types="react" />
|
|
6
|
+
export interface CaretProps {
|
|
7
|
+
/**
|
|
8
|
+
* A `testId` prop is provided for specified elements, which is a unique
|
|
9
|
+
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
10
|
+
* serving as a hook for automated tests
|
|
11
|
+
*/
|
|
12
|
+
testId?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* __Caret__
|
|
16
|
+
*
|
|
17
|
+
* A `Caret` is a purely visual pointer displayed on the edge of a spotlight, which points to the target element.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export declare const Caret: import("react").ForwardRefExoticComponent<CaretProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { type Dispatch, type ReactNode, type SetStateAction } from 'react';
|
|
2
|
+
import type { Placement } from '../types';
|
|
3
|
+
interface SpotlightContextType {
|
|
4
|
+
placement: Placement;
|
|
5
|
+
setPlacement: Dispatch<SetStateAction<Placement>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const SpotlightContext: React.Context<SpotlightContextType>;
|
|
8
|
+
export declare const SpotlightContextProvider: ({ children }: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}) => React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type Placement = Extract<ADSPopperPlacement, "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end">;
|
|
1
|
+
export type Placement = 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'right-start' | 'right-end' | 'left-start' | 'left-end';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React, { type ReactNode } from
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
2
|
import type { Placement } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* __PopoverContent__
|
|
5
5
|
*
|
|
6
6
|
* A `PopoverContent` is the element that is shown as a popover.
|
|
7
7
|
*/
|
|
8
|
-
export declare const PopoverContent: ({ children, placement }: {
|
|
8
|
+
export declare const PopoverContent: ({ children, placement, }: {
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
placement: Placement;
|
|
11
11
|
}) => React.JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
export interface CaretProps {
|
|
7
|
+
/**
|
|
8
|
+
* A `testId` prop is provided for specified elements, which is a unique
|
|
9
|
+
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
10
|
+
* serving as a hook for automated tests
|
|
11
|
+
*/
|
|
12
|
+
testId?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* __Caret__
|
|
16
|
+
*
|
|
17
|
+
* A `Caret` is a purely visual pointer displayed on the edge of a spotlight, which points to the target element.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export declare const Caret: import("react").ForwardRefExoticComponent<CaretProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/spotlight",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "A spotlight introduces users to various points of interest across Atlassian through focused messages or multi-step tours.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|