@atlaskit/spotlight 0.0.9 → 0.0.10
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 +8 -0
- package/dist/cjs/controllers/context.js +64 -11
- package/dist/cjs/index.js +14 -1
- package/dist/cjs/ui/dismiss-control/index.js +7 -5
- package/dist/cjs/ui/popover-content/index.compiled.css +4 -0
- package/dist/cjs/ui/popover-content/index.js +18 -10
- package/dist/es2019/controllers/context.js +55 -10
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/ui/dismiss-control/index.js +6 -4
- package/dist/es2019/ui/popover-content/index.compiled.css +4 -0
- package/dist/es2019/ui/popover-content/index.js +15 -7
- package/dist/esm/controllers/context.js +63 -10
- package/dist/esm/index.js +2 -1
- package/dist/esm/ui/dismiss-control/index.js +7 -5
- package/dist/esm/ui/popover-content/index.compiled.css +4 -0
- package/dist/esm/ui/popover-content/index.js +18 -10
- package/dist/types/controllers/context.d.ts +22 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/ui/dismiss-control/index.d.ts +5 -0
- package/dist/types/ui/popover-content/index.d.ts +12 -5
- package/dist/types-ts4.5/controllers/context.d.ts +22 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/dismiss-control/index.d.ts +5 -0
- package/dist/types-ts4.5/ui/popover-content/index.d.ts +12 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/spotlight
|
|
2
2
|
|
|
3
|
+
## 0.0.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#198989](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/198989)
|
|
8
|
+
[`c4a86f623352d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c4a86f623352d) -
|
|
9
|
+
Allow Spotlight to be dismissed. Implement basic Spotlight Tour functionality.
|
|
10
|
+
|
|
3
11
|
## 0.0.9
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.SpotlightContextProvider = exports.SpotlightContext = void 0;
|
|
8
|
+
exports.TourContextProvider = exports.TourContext = exports.SpotlightContextProvider = exports.SpotlightContext = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
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); }
|
|
@@ -26,14 +26,67 @@ var SpotlightContextProvider = exports.SpotlightContextProvider = function Spotl
|
|
|
26
26
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
27
27
|
placement = _useState2[0],
|
|
28
28
|
setPlacement = _useState2[1];
|
|
29
|
-
return (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(SpotlightContext.Provider, {
|
|
30
|
+
value: {
|
|
31
|
+
placement: placement,
|
|
32
|
+
setPlacement: setPlacement
|
|
33
|
+
}
|
|
34
|
+
}, children);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* __Tour context__
|
|
41
|
+
*
|
|
42
|
+
* A tour context is a way of managing multiple spotlights as steps in the same tour.
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
var TourContext = exports.TourContext = /*#__PURE__*/(0, _react.createContext)({
|
|
46
|
+
currentStep: 1,
|
|
47
|
+
setCurrentStep: function setCurrentStep() {
|
|
48
|
+
return undefined;
|
|
49
|
+
},
|
|
50
|
+
next: function next() {
|
|
51
|
+
return undefined;
|
|
52
|
+
},
|
|
53
|
+
prev: function prev() {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* __Tour context provider__
|
|
60
|
+
*
|
|
61
|
+
* A tour context provider is a way of managing multiple spotlights as steps in the same tour.
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
var TourContextProvider = exports.TourContextProvider = function TourContextProvider(_ref2) {
|
|
65
|
+
var children = _ref2.children;
|
|
66
|
+
var _useState3 = (0, _react.useState)(1),
|
|
67
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
68
|
+
currentStep = _useState4[0],
|
|
69
|
+
setCurrentStep = _useState4[1];
|
|
70
|
+
var next = function next() {
|
|
71
|
+
if (!currentStep) {
|
|
72
|
+
setCurrentStep(1);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
setCurrentStep(currentStep + 1);
|
|
76
|
+
};
|
|
77
|
+
var prev = function prev() {
|
|
78
|
+
if (!currentStep) {
|
|
79
|
+
setCurrentStep(1);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setCurrentStep(currentStep - 1);
|
|
83
|
+
};
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement(TourContext.Provider, {
|
|
85
|
+
value: {
|
|
86
|
+
currentStep: currentStep,
|
|
87
|
+
setCurrentStep: setCurrentStep,
|
|
88
|
+
next: next,
|
|
89
|
+
prev: prev
|
|
90
|
+
}
|
|
91
|
+
}, children);
|
|
39
92
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -81,6 +81,18 @@ Object.defineProperty(exports, "SpotlightSecondaryAction", {
|
|
|
81
81
|
return _secondaryAction.SpotlightSecondaryAction;
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
|
+
Object.defineProperty(exports, "TourContext", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function get() {
|
|
87
|
+
return _context.TourContext;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "TourContextProvider", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _context.TourContextProvider;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
84
96
|
var _spotlight = require("./ui/spotlight");
|
|
85
97
|
var _body = require("./ui/body");
|
|
86
98
|
var _header = require("./ui/header");
|
|
@@ -93,4 +105,5 @@ var _controls = require("./ui/controls");
|
|
|
93
105
|
var _dismissControl = require("./ui/dismiss-control");
|
|
94
106
|
var _popoverProvider = require("./ui/popover-provider");
|
|
95
107
|
var _popoverContent = require("./ui/popover-content");
|
|
96
|
-
var _popoverTarget = require("./ui/popover-target");
|
|
108
|
+
var _popoverTarget = require("./ui/popover-target");
|
|
109
|
+
var _context = require("./controllers/context");
|
|
@@ -17,13 +17,15 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
var SpotlightDismissControl = exports.SpotlightDismissControl = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
20
|
-
var
|
|
20
|
+
var onClick = _ref.onClick,
|
|
21
|
+
testId = _ref.testId;
|
|
21
22
|
return /*#__PURE__*/_react.default.createElement(_new.IconButton, {
|
|
22
|
-
testId: testId,
|
|
23
|
-
ref: ref,
|
|
24
23
|
appearance: "default",
|
|
25
|
-
spacing: "compact",
|
|
26
24
|
icon: _cross.default,
|
|
27
|
-
label: "Close"
|
|
25
|
+
label: "Close",
|
|
26
|
+
onClick: onClick,
|
|
27
|
+
ref: ref,
|
|
28
|
+
spacing: "compact",
|
|
29
|
+
testId: testId
|
|
28
30
|
});
|
|
29
31
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
1
2
|
"use strict";
|
|
2
3
|
|
|
3
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
@@ -5,10 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.PopoverContent = void 0;
|
|
9
|
+
require("./index.compiled.css");
|
|
8
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var React = _react;
|
|
12
|
+
var _runtime = require("@compiled/react/runtime");
|
|
9
13
|
var _popper = require("@atlaskit/popper");
|
|
10
14
|
var _context = require("../../controllers/context");
|
|
11
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); }
|
|
16
|
+
var styles = {
|
|
17
|
+
visible: "_lcxv1wug _3um0ewfl",
|
|
18
|
+
hidden: "_lcxvglyw _3um015vq"
|
|
19
|
+
};
|
|
12
20
|
/**
|
|
13
21
|
* The Spotlight card can be positioned in many different configurations, but the caret should always point to
|
|
14
22
|
* the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
|
|
@@ -33,25 +41,25 @@ var popperPlacementMap = {
|
|
|
33
41
|
*/
|
|
34
42
|
var PopoverContent = exports.PopoverContent = function PopoverContent(_ref) {
|
|
35
43
|
var children = _ref.children,
|
|
36
|
-
placement = _ref.placement
|
|
44
|
+
placement = _ref.placement,
|
|
45
|
+
_ref$isVisible = _ref.isVisible,
|
|
46
|
+
isVisible = _ref$isVisible === void 0 ? true : _ref$isVisible;
|
|
37
47
|
var _useContext = (0, _react.useContext)(_context.SpotlightContext),
|
|
38
48
|
setPlacement = _useContext.setPlacement;
|
|
49
|
+
var visibility = isVisible ? 'visible' : 'hidden';
|
|
39
50
|
(0, _react.useEffect)(function () {
|
|
40
51
|
setPlacement(placement);
|
|
41
52
|
}, [placement, setPlacement]);
|
|
42
|
-
return /*#__PURE__*/
|
|
53
|
+
return /*#__PURE__*/React.createElement(_popper.Popper, {
|
|
43
54
|
offset: [0, 0],
|
|
44
55
|
placement: popperPlacementMap[placement]
|
|
45
56
|
}, function (_ref2) {
|
|
46
57
|
var ref = _ref2.ref,
|
|
47
58
|
style = _ref2.style;
|
|
48
|
-
return (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
style: style
|
|
54
|
-
}, children)
|
|
55
|
-
);
|
|
59
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
ref: ref,
|
|
61
|
+
style: style,
|
|
62
|
+
className: (0, _runtime.ax)([styles[visibility]])
|
|
63
|
+
}, children);
|
|
56
64
|
});
|
|
57
65
|
};
|
|
@@ -13,14 +13,59 @@ export const SpotlightContextProvider = ({
|
|
|
13
13
|
children
|
|
14
14
|
}) => {
|
|
15
15
|
const [placement, setPlacement] = useState('bottom-end');
|
|
16
|
-
return (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
return /*#__PURE__*/React.createElement(SpotlightContext.Provider, {
|
|
17
|
+
value: {
|
|
18
|
+
placement,
|
|
19
|
+
setPlacement
|
|
20
|
+
}
|
|
21
|
+
}, children);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* __Tour context__
|
|
28
|
+
*
|
|
29
|
+
* A tour context is a way of managing multiple spotlights as steps in the same tour.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
export const TourContext = /*#__PURE__*/createContext({
|
|
33
|
+
currentStep: 1,
|
|
34
|
+
setCurrentStep: () => undefined,
|
|
35
|
+
next: () => undefined,
|
|
36
|
+
prev: () => undefined
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* __Tour context provider__
|
|
41
|
+
*
|
|
42
|
+
* A tour context provider is a way of managing multiple spotlights as steps in the same tour.
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
export const TourContextProvider = ({
|
|
46
|
+
children
|
|
47
|
+
}) => {
|
|
48
|
+
const [currentStep, setCurrentStep] = useState(1);
|
|
49
|
+
const next = () => {
|
|
50
|
+
if (!currentStep) {
|
|
51
|
+
setCurrentStep(1);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
setCurrentStep(currentStep + 1);
|
|
55
|
+
};
|
|
56
|
+
const prev = () => {
|
|
57
|
+
if (!currentStep) {
|
|
58
|
+
setCurrentStep(1);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setCurrentStep(currentStep - 1);
|
|
62
|
+
};
|
|
63
|
+
return /*#__PURE__*/React.createElement(TourContext.Provider, {
|
|
64
|
+
value: {
|
|
65
|
+
currentStep,
|
|
66
|
+
setCurrentStep,
|
|
67
|
+
next,
|
|
68
|
+
prev
|
|
69
|
+
}
|
|
70
|
+
}, children);
|
|
26
71
|
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -10,4 +10,5 @@ export { SpotlightControls } from './ui/controls';
|
|
|
10
10
|
export { SpotlightDismissControl } from './ui/dismiss-control';
|
|
11
11
|
export { PopoverProvider } from './ui/popover-provider';
|
|
12
12
|
export { PopoverContent } from './ui/popover-content';
|
|
13
|
-
export { PopoverTarget } from './ui/popover-target';
|
|
13
|
+
export { PopoverTarget } from './ui/popover-target';
|
|
14
|
+
export { TourContext, TourContextProvider } from './controllers/context';
|
|
@@ -8,14 +8,16 @@ import CrossIcon from '@atlaskit/icon/core/cross';
|
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
10
|
export const SpotlightDismissControl = /*#__PURE__*/forwardRef(({
|
|
11
|
+
onClick,
|
|
11
12
|
testId
|
|
12
13
|
}, ref) => {
|
|
13
14
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
14
|
-
testId: testId,
|
|
15
|
-
ref: ref,
|
|
16
15
|
appearance: "default",
|
|
17
|
-
spacing: "compact",
|
|
18
16
|
icon: CrossIcon,
|
|
19
|
-
label: "Close"
|
|
17
|
+
label: "Close",
|
|
18
|
+
onClick: onClick,
|
|
19
|
+
ref: ref,
|
|
20
|
+
spacing: "compact",
|
|
21
|
+
testId: testId
|
|
20
22
|
});
|
|
21
23
|
});
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
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 { useContext, useEffect } from "react";
|
|
2
6
|
import { Popper } from '@atlaskit/popper';
|
|
3
7
|
import { SpotlightContext } from '../../controllers/context';
|
|
8
|
+
const styles = {
|
|
9
|
+
visible: "_lcxv1wug _3um0ewfl",
|
|
10
|
+
hidden: "_lcxvglyw _3um015vq"
|
|
11
|
+
};
|
|
4
12
|
/**
|
|
5
13
|
* The Spotlight card can be positioned in many different configurations, but the caret should always point to
|
|
6
14
|
* the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
|
|
@@ -25,11 +33,13 @@ const popperPlacementMap = {
|
|
|
25
33
|
*/
|
|
26
34
|
export const PopoverContent = ({
|
|
27
35
|
children,
|
|
28
|
-
placement
|
|
36
|
+
placement,
|
|
37
|
+
isVisible = true
|
|
29
38
|
}) => {
|
|
30
39
|
const {
|
|
31
40
|
setPlacement
|
|
32
41
|
} = useContext(SpotlightContext);
|
|
42
|
+
const visibility = isVisible ? 'visible' : 'hidden';
|
|
33
43
|
useEffect(() => {
|
|
34
44
|
setPlacement(placement);
|
|
35
45
|
}, [placement, setPlacement]);
|
|
@@ -39,11 +49,9 @@ export const PopoverContent = ({
|
|
|
39
49
|
}, ({
|
|
40
50
|
ref,
|
|
41
51
|
style
|
|
42
|
-
}) =>
|
|
43
|
-
/*#__PURE__*/
|
|
44
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
45
|
-
React.createElement("div", {
|
|
52
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
46
53
|
ref: ref,
|
|
47
|
-
style: style
|
|
54
|
+
style: style,
|
|
55
|
+
className: ax([styles[visibility]])
|
|
48
56
|
}, children));
|
|
49
57
|
};
|
|
@@ -18,14 +18,67 @@ export var SpotlightContextProvider = function SpotlightContextProvider(_ref) {
|
|
|
18
18
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19
19
|
placement = _useState2[0],
|
|
20
20
|
setPlacement = _useState2[1];
|
|
21
|
-
return (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
return /*#__PURE__*/React.createElement(SpotlightContext.Provider, {
|
|
22
|
+
value: {
|
|
23
|
+
placement: placement,
|
|
24
|
+
setPlacement: setPlacement
|
|
25
|
+
}
|
|
26
|
+
}, children);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* __Tour context__
|
|
33
|
+
*
|
|
34
|
+
* A tour context is a way of managing multiple spotlights as steps in the same tour.
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
export var TourContext = /*#__PURE__*/createContext({
|
|
38
|
+
currentStep: 1,
|
|
39
|
+
setCurrentStep: function setCurrentStep() {
|
|
40
|
+
return undefined;
|
|
41
|
+
},
|
|
42
|
+
next: function next() {
|
|
43
|
+
return undefined;
|
|
44
|
+
},
|
|
45
|
+
prev: function prev() {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* __Tour context provider__
|
|
52
|
+
*
|
|
53
|
+
* A tour context provider is a way of managing multiple spotlights as steps in the same tour.
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
export var TourContextProvider = function TourContextProvider(_ref2) {
|
|
57
|
+
var children = _ref2.children;
|
|
58
|
+
var _useState3 = useState(1),
|
|
59
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
60
|
+
currentStep = _useState4[0],
|
|
61
|
+
setCurrentStep = _useState4[1];
|
|
62
|
+
var next = function next() {
|
|
63
|
+
if (!currentStep) {
|
|
64
|
+
setCurrentStep(1);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
setCurrentStep(currentStep + 1);
|
|
68
|
+
};
|
|
69
|
+
var prev = function prev() {
|
|
70
|
+
if (!currentStep) {
|
|
71
|
+
setCurrentStep(1);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
setCurrentStep(currentStep - 1);
|
|
75
|
+
};
|
|
76
|
+
return /*#__PURE__*/React.createElement(TourContext.Provider, {
|
|
77
|
+
value: {
|
|
78
|
+
currentStep: currentStep,
|
|
79
|
+
setCurrentStep: setCurrentStep,
|
|
80
|
+
next: next,
|
|
81
|
+
prev: prev
|
|
82
|
+
}
|
|
83
|
+
}, children);
|
|
31
84
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -10,4 +10,5 @@ export { SpotlightControls } from './ui/controls';
|
|
|
10
10
|
export { SpotlightDismissControl } from './ui/dismiss-control';
|
|
11
11
|
export { PopoverProvider } from './ui/popover-provider';
|
|
12
12
|
export { PopoverContent } from './ui/popover-content';
|
|
13
|
-
export { PopoverTarget } from './ui/popover-target';
|
|
13
|
+
export { PopoverTarget } from './ui/popover-target';
|
|
14
|
+
export { TourContext, TourContextProvider } from './controllers/context';
|
|
@@ -8,13 +8,15 @@ import CrossIcon from '@atlaskit/icon/core/cross';
|
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
10
|
export var SpotlightDismissControl = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
11
|
-
var
|
|
11
|
+
var onClick = _ref.onClick,
|
|
12
|
+
testId = _ref.testId;
|
|
12
13
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
13
|
-
testId: testId,
|
|
14
|
-
ref: ref,
|
|
15
14
|
appearance: "default",
|
|
16
|
-
spacing: "compact",
|
|
17
15
|
icon: CrossIcon,
|
|
18
|
-
label: "Close"
|
|
16
|
+
label: "Close",
|
|
17
|
+
onClick: onClick,
|
|
18
|
+
ref: ref,
|
|
19
|
+
spacing: "compact",
|
|
20
|
+
testId: testId
|
|
19
21
|
});
|
|
20
22
|
});
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
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 { useContext, useEffect } from "react";
|
|
2
6
|
import { Popper } from '@atlaskit/popper';
|
|
3
7
|
import { SpotlightContext } from '../../controllers/context';
|
|
8
|
+
var styles = {
|
|
9
|
+
visible: "_lcxv1wug _3um0ewfl",
|
|
10
|
+
hidden: "_lcxvglyw _3um015vq"
|
|
11
|
+
};
|
|
4
12
|
/**
|
|
5
13
|
* The Spotlight card can be positioned in many different configurations, but the caret should always point to
|
|
6
14
|
* the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
|
|
@@ -25,9 +33,12 @@ var popperPlacementMap = {
|
|
|
25
33
|
*/
|
|
26
34
|
export var PopoverContent = function PopoverContent(_ref) {
|
|
27
35
|
var children = _ref.children,
|
|
28
|
-
placement = _ref.placement
|
|
36
|
+
placement = _ref.placement,
|
|
37
|
+
_ref$isVisible = _ref.isVisible,
|
|
38
|
+
isVisible = _ref$isVisible === void 0 ? true : _ref$isVisible;
|
|
29
39
|
var _useContext = useContext(SpotlightContext),
|
|
30
40
|
setPlacement = _useContext.setPlacement;
|
|
41
|
+
var visibility = isVisible ? 'visible' : 'hidden';
|
|
31
42
|
useEffect(function () {
|
|
32
43
|
setPlacement(placement);
|
|
33
44
|
}, [placement, setPlacement]);
|
|
@@ -37,13 +48,10 @@ export var PopoverContent = function PopoverContent(_ref) {
|
|
|
37
48
|
}, function (_ref2) {
|
|
38
49
|
var ref = _ref2.ref,
|
|
39
50
|
style = _ref2.style;
|
|
40
|
-
return (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
style: style
|
|
46
|
-
}, children)
|
|
47
|
-
);
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
ref: ref,
|
|
53
|
+
style: style,
|
|
54
|
+
className: ax([styles[visibility]])
|
|
55
|
+
}, children);
|
|
48
56
|
});
|
|
49
57
|
};
|
|
@@ -8,4 +8,26 @@ export declare const SpotlightContext: React.Context<SpotlightContextType>;
|
|
|
8
8
|
export declare const SpotlightContextProvider: ({ children }: {
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
}) => React.JSX.Element;
|
|
11
|
+
interface TourContextType {
|
|
12
|
+
currentStep: number | undefined;
|
|
13
|
+
setCurrentStep: Dispatch<SetStateAction<number | undefined>>;
|
|
14
|
+
next: () => void;
|
|
15
|
+
prev: () => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* __Tour context__
|
|
19
|
+
*
|
|
20
|
+
* A tour context is a way of managing multiple spotlights as steps in the same tour.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare const TourContext: React.Context<TourContextType>;
|
|
24
|
+
/**
|
|
25
|
+
* __Tour context provider__
|
|
26
|
+
*
|
|
27
|
+
* A tour context provider is a way of managing multiple spotlights as steps in the same tour.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
export declare const TourContextProvider: ({ children }: {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}) => React.JSX.Element;
|
|
11
33
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export { SpotlightDismissControl, type SpotlightDismissControlProps } from './ui
|
|
|
11
11
|
export { PopoverProvider } from './ui/popover-provider';
|
|
12
12
|
export { PopoverContent } from './ui/popover-content';
|
|
13
13
|
export { PopoverTarget } from './ui/popover-target';
|
|
14
|
+
export { TourContext, TourContextProvider } from './controllers/context';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type IconButtonProps } from '@atlaskit/button/new';
|
|
2
3
|
export interface SpotlightDismissControlProps {
|
|
3
4
|
/**
|
|
4
5
|
* A `testId` prop is provided for specified elements, which is a unique
|
|
@@ -6,6 +7,10 @@ export interface SpotlightDismissControlProps {
|
|
|
6
7
|
* serving as a hook for automated tests
|
|
7
8
|
*/
|
|
8
9
|
testId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The action to take when the button is clicked.
|
|
12
|
+
*/
|
|
13
|
+
onClick?: IconButtonProps['onClick'];
|
|
9
14
|
}
|
|
10
15
|
/**
|
|
11
16
|
* __SpotlightDismissControl__
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode } from "react";
|
|
2
6
|
import type { Placement } from '../../types';
|
|
7
|
+
interface PopoverContentProps {
|
|
8
|
+
placement: Placement;
|
|
9
|
+
isVisible?: boolean;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* __PopoverContent__
|
|
5
14
|
*
|
|
6
15
|
* A `PopoverContent` is the element that is shown as a popover.
|
|
7
16
|
*/
|
|
8
|
-
export declare const PopoverContent: ({ children, placement }:
|
|
9
|
-
|
|
10
|
-
placement: Placement;
|
|
11
|
-
}) => React.JSX.Element;
|
|
17
|
+
export declare const PopoverContent: ({ children, placement, isVisible }: PopoverContentProps) => JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -8,4 +8,26 @@ export declare const SpotlightContext: React.Context<SpotlightContextType>;
|
|
|
8
8
|
export declare const SpotlightContextProvider: ({ children }: {
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
}) => React.JSX.Element;
|
|
11
|
+
interface TourContextType {
|
|
12
|
+
currentStep: number | undefined;
|
|
13
|
+
setCurrentStep: Dispatch<SetStateAction<number | undefined>>;
|
|
14
|
+
next: () => void;
|
|
15
|
+
prev: () => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* __Tour context__
|
|
19
|
+
*
|
|
20
|
+
* A tour context is a way of managing multiple spotlights as steps in the same tour.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare const TourContext: React.Context<TourContextType>;
|
|
24
|
+
/**
|
|
25
|
+
* __Tour context provider__
|
|
26
|
+
*
|
|
27
|
+
* A tour context provider is a way of managing multiple spotlights as steps in the same tour.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
export declare const TourContextProvider: ({ children }: {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}) => React.JSX.Element;
|
|
11
33
|
export {};
|
|
@@ -11,3 +11,4 @@ export { SpotlightDismissControl, type SpotlightDismissControlProps } from './ui
|
|
|
11
11
|
export { PopoverProvider } from './ui/popover-provider';
|
|
12
12
|
export { PopoverContent } from './ui/popover-content';
|
|
13
13
|
export { PopoverTarget } from './ui/popover-target';
|
|
14
|
+
export { TourContext, TourContextProvider } from './controllers/context';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type IconButtonProps } from '@atlaskit/button/new';
|
|
2
3
|
export interface SpotlightDismissControlProps {
|
|
3
4
|
/**
|
|
4
5
|
* A `testId` prop is provided for specified elements, which is a unique
|
|
@@ -6,6 +7,10 @@ export interface SpotlightDismissControlProps {
|
|
|
6
7
|
* serving as a hook for automated tests
|
|
7
8
|
*/
|
|
8
9
|
testId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The action to take when the button is clicked.
|
|
12
|
+
*/
|
|
13
|
+
onClick?: IconButtonProps['onClick'];
|
|
9
14
|
}
|
|
10
15
|
/**
|
|
11
16
|
* __SpotlightDismissControl__
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode } from "react";
|
|
2
6
|
import type { Placement } from '../../types';
|
|
7
|
+
interface PopoverContentProps {
|
|
8
|
+
placement: Placement;
|
|
9
|
+
isVisible?: boolean;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* __PopoverContent__
|
|
5
14
|
*
|
|
6
15
|
* A `PopoverContent` is the element that is shown as a popover.
|
|
7
16
|
*/
|
|
8
|
-
export declare const PopoverContent: ({ children, placement }:
|
|
9
|
-
|
|
10
|
-
placement: Placement;
|
|
11
|
-
}) => React.JSX.Element;
|
|
17
|
+
export declare const PopoverContent: ({ children, placement, isVisible }: PopoverContentProps) => JSX.Element;
|
|
18
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/spotlight",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
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",
|