@atlaskit/spotlight 0.6.1 → 0.6.3
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 +14 -0
- package/dist/cjs/controllers/context.js +12 -12
- package/dist/cjs/ui/dismiss-control/index.js +8 -2
- package/dist/cjs/ui/popover-content/index.js +10 -2
- package/dist/cjs/utils/use-on-click-outside/index.js +3 -3
- package/dist/es2019/controllers/context.js +10 -5
- package/dist/es2019/ui/dismiss-control/index.js +10 -3
- package/dist/es2019/ui/popover-content/index.js +9 -2
- package/dist/es2019/utils/use-on-click-outside/index.js +3 -3
- package/dist/esm/controllers/context.js +13 -13
- package/dist/esm/ui/dismiss-control/index.js +9 -3
- package/dist/esm/ui/popover-content/index.js +10 -2
- package/dist/esm/utils/use-on-click-outside/index.js +3 -3
- package/dist/types/controllers/context.d.ts +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +9 -0
- package/dist/types/ui/popover-content/index.d.ts +4 -3
- package/dist/types-ts4.5/controllers/context.d.ts +3 -3
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +9 -0
- package/dist/types-ts4.5/ui/popover-content/index.d.ts +4 -3
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/spotlight
|
|
2
2
|
|
|
3
|
+
## 0.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1b4bf57dec49e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1b4bf57dec49e) -
|
|
8
|
+
Make 'click-outside-to-dismiss' functionality optional.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 0.6.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 0.6.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -53,13 +53,13 @@ var SpotlightContext = exports.SpotlightContext = /*#__PURE__*/(0, _react.create
|
|
|
53
53
|
});
|
|
54
54
|
};
|
|
55
55
|
},
|
|
56
|
-
dismiss:
|
|
57
|
-
|
|
56
|
+
dismiss: {
|
|
57
|
+
current: function current() {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
58
60
|
},
|
|
59
61
|
setDismiss: function setDismiss() {
|
|
60
|
-
return
|
|
61
|
-
return undefined;
|
|
62
|
-
};
|
|
62
|
+
return undefined;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
});
|
|
@@ -100,12 +100,12 @@ var SpotlightContextProvider = exports.SpotlightContextProvider = function Spotl
|
|
|
100
100
|
_useState0 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
101
101
|
cardRef = _useState0[0],
|
|
102
102
|
setCardRef = _useState0[1];
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
var dismissRef = (0, _react.useRef)(function () {
|
|
104
|
+
return undefined;
|
|
105
|
+
});
|
|
106
|
+
var setDismiss = function setDismiss(dismissFn) {
|
|
107
|
+
dismissRef.current = dismissFn;
|
|
108
|
+
};
|
|
109
109
|
return /*#__PURE__*/React.createElement(SpotlightContext.Provider, {
|
|
110
110
|
value: {
|
|
111
111
|
card: {
|
|
@@ -123,7 +123,7 @@ var SpotlightContextProvider = exports.SpotlightContextProvider = function Spotl
|
|
|
123
123
|
setRef: setPopoverRef,
|
|
124
124
|
update: update,
|
|
125
125
|
setUpdate: setUpdate,
|
|
126
|
-
dismiss:
|
|
126
|
+
dismiss: dismissRef,
|
|
127
127
|
setDismiss: setDismiss
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -13,6 +13,7 @@ var React = _react;
|
|
|
13
13
|
var _runtime = require("@compiled/react/runtime");
|
|
14
14
|
var _cross = _interopRequireDefault(require("@atlaskit/icon/core/cross"));
|
|
15
15
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
16
|
+
var _context = require("../../controllers/context");
|
|
16
17
|
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); }
|
|
17
18
|
var styles = {
|
|
18
19
|
root: "_2rko12b0 _1rjc12x7 _syaz15cr _bfhkcdhy _irr31bsc _1di61b6k"
|
|
@@ -28,11 +29,16 @@ var SpotlightDismissControl = exports.SpotlightDismissControl = /*#__PURE__*/(0,
|
|
|
28
29
|
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
29
30
|
onClick = _ref.onClick,
|
|
30
31
|
testId = _ref.testId;
|
|
32
|
+
var _useContext = (0, _react.useContext)(_context.SpotlightContext),
|
|
33
|
+
popoverContent = _useContext.popoverContent;
|
|
34
|
+
var dismiss = function dismiss(event) {
|
|
35
|
+
popoverContent.dismiss.current(event);
|
|
36
|
+
};
|
|
31
37
|
return /*#__PURE__*/React.createElement(_compiled.Pressable
|
|
32
|
-
// eslint-disable-next-line
|
|
38
|
+
// eslint-disable-next-line @atlassian/a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
|
|
33
39
|
, {
|
|
34
40
|
autoFocus: autoFocus,
|
|
35
|
-
onClick: onClick,
|
|
41
|
+
onClick: onClick || dismiss,
|
|
36
42
|
ref: ref,
|
|
37
43
|
testId: testId,
|
|
38
44
|
xcss: styles.root,
|
|
@@ -60,6 +60,8 @@ var PopoverContent = exports.PopoverContent = function PopoverContent(_ref) {
|
|
|
60
60
|
placement = _ref.placement,
|
|
61
61
|
_ref$isVisible = _ref.isVisible,
|
|
62
62
|
isVisible = _ref$isVisible === void 0 ? true : _ref$isVisible,
|
|
63
|
+
_ref$shouldDismissOnC = _ref.shouldDismissOnClickOutside,
|
|
64
|
+
shouldDismissOnClickOutside = _ref$shouldDismissOnC === void 0 ? true : _ref$shouldDismissOnC,
|
|
63
65
|
dismiss = _ref.dismiss,
|
|
64
66
|
testId = _ref.testId;
|
|
65
67
|
var updateRef = (0, _react.useRef)(function () {
|
|
@@ -76,6 +78,9 @@ var PopoverContent = exports.PopoverContent = function PopoverContent(_ref) {
|
|
|
76
78
|
(0, _react.useEffect)(function () {
|
|
77
79
|
popoverContent.setRef(ref);
|
|
78
80
|
}, [ref, popoverContent]);
|
|
81
|
+
(0, _react.useEffect)(function () {
|
|
82
|
+
popoverContent.setDismiss(dismiss);
|
|
83
|
+
}, [dismiss, popoverContent]);
|
|
79
84
|
(0, _react.useEffect)(function () {
|
|
80
85
|
card.setPlacement(placement);
|
|
81
86
|
}, [placement, card]);
|
|
@@ -90,10 +95,13 @@ var PopoverContent = exports.PopoverContent = function PopoverContent(_ref) {
|
|
|
90
95
|
if (!focusWithin) {
|
|
91
96
|
return;
|
|
92
97
|
}
|
|
93
|
-
dismiss(event);
|
|
98
|
+
popoverContent.dismiss.current(event);
|
|
94
99
|
});
|
|
95
100
|
(0, _useOnClickOutside.useOnClickOutside)(function (event) {
|
|
96
|
-
|
|
101
|
+
if (!shouldDismissOnClickOutside) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
popoverContent.dismiss.current(event);
|
|
97
105
|
});
|
|
98
106
|
return /*#__PURE__*/React.createElement(_popper.Popper, {
|
|
99
107
|
offset: offset,
|
|
@@ -17,8 +17,8 @@ var useOnClickOutside = exports.useOnClickOutside = function useOnClickOutside(o
|
|
|
17
17
|
if (!doc) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
var
|
|
21
|
-
type: '
|
|
20
|
+
var unbindMouseUp = (0, _bindEventListener.bind)(doc, {
|
|
21
|
+
type: 'mouseup',
|
|
22
22
|
listener: function listener(event) {
|
|
23
23
|
if (!ref || !ref.current) {
|
|
24
24
|
return;
|
|
@@ -31,7 +31,7 @@ var useOnClickOutside = exports.useOnClickOutside = function useOnClickOutside(o
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
return function () {
|
|
34
|
-
|
|
34
|
+
unbindMouseUp();
|
|
35
35
|
};
|
|
36
36
|
}, [onClickOutside, ref]);
|
|
37
37
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* context.tsx generated by @compiled/babel-plugin v0.38.1 */
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
-
import { createContext, useId, useState } from 'react';
|
|
4
|
+
import { createContext, useId, useRef, useState } from 'react';
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
7
7
|
|
|
@@ -22,8 +22,10 @@ export const SpotlightContext = /*#__PURE__*/createContext({
|
|
|
22
22
|
setRef: () => undefined,
|
|
23
23
|
update: () => () => new Promise(() => null),
|
|
24
24
|
setUpdate: () => () => new Promise(() => null),
|
|
25
|
-
dismiss:
|
|
26
|
-
|
|
25
|
+
dismiss: {
|
|
26
|
+
current: () => undefined
|
|
27
|
+
},
|
|
28
|
+
setDismiss: () => undefined
|
|
27
29
|
}
|
|
28
30
|
});
|
|
29
31
|
|
|
@@ -37,7 +39,10 @@ export const SpotlightContextProvider = ({
|
|
|
37
39
|
const [update, setUpdate] = useState(() => async () => undefined);
|
|
38
40
|
const [popoverRef, setPopoverRef] = useState();
|
|
39
41
|
const [cardRef, setCardRef] = useState(null);
|
|
40
|
-
const
|
|
42
|
+
const dismissRef = useRef(() => undefined);
|
|
43
|
+
const setDismiss = dismissFn => {
|
|
44
|
+
dismissRef.current = dismissFn;
|
|
45
|
+
};
|
|
41
46
|
return /*#__PURE__*/React.createElement(SpotlightContext.Provider, {
|
|
42
47
|
value: {
|
|
43
48
|
card: {
|
|
@@ -55,7 +60,7 @@ export const SpotlightContextProvider = ({
|
|
|
55
60
|
setRef: setPopoverRef,
|
|
56
61
|
update,
|
|
57
62
|
setUpdate,
|
|
58
|
-
dismiss,
|
|
63
|
+
dismiss: dismissRef,
|
|
59
64
|
setDismiss
|
|
60
65
|
}
|
|
61
66
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
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';
|
|
5
|
+
import { forwardRef, useContext } from 'react';
|
|
6
6
|
import CrossIcon from '@atlaskit/icon/core/cross';
|
|
7
7
|
import { Pressable } from '@atlaskit/primitives/compiled';
|
|
8
|
+
import { SpotlightContext } from '../../controllers/context';
|
|
8
9
|
const styles = {
|
|
9
10
|
root: "_2rko12b0 _1rjc12x7 _syaz15cr _bfhkcdhy _irr31bsc _1di61b6k"
|
|
10
11
|
};
|
|
@@ -19,11 +20,17 @@ export const SpotlightDismissControl = /*#__PURE__*/forwardRef(({
|
|
|
19
20
|
onClick,
|
|
20
21
|
testId
|
|
21
22
|
}, ref) => {
|
|
23
|
+
const {
|
|
24
|
+
popoverContent
|
|
25
|
+
} = useContext(SpotlightContext);
|
|
26
|
+
const dismiss = event => {
|
|
27
|
+
popoverContent.dismiss.current(event);
|
|
28
|
+
};
|
|
22
29
|
return /*#__PURE__*/React.createElement(Pressable
|
|
23
|
-
// eslint-disable-next-line
|
|
30
|
+
// eslint-disable-next-line @atlassian/a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
|
|
24
31
|
, {
|
|
25
32
|
autoFocus: autoFocus,
|
|
26
|
-
onClick: onClick,
|
|
33
|
+
onClick: onClick || dismiss,
|
|
27
34
|
ref: ref,
|
|
28
35
|
testId: testId,
|
|
29
36
|
xcss: styles.root,
|
|
@@ -50,6 +50,7 @@ export const PopoverContent = ({
|
|
|
50
50
|
children,
|
|
51
51
|
placement,
|
|
52
52
|
isVisible = true,
|
|
53
|
+
shouldDismissOnClickOutside = true,
|
|
53
54
|
dismiss,
|
|
54
55
|
testId
|
|
55
56
|
}) => {
|
|
@@ -64,6 +65,9 @@ export const PopoverContent = ({
|
|
|
64
65
|
useEffect(() => {
|
|
65
66
|
popoverContent.setRef(ref);
|
|
66
67
|
}, [ref, popoverContent]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
popoverContent.setDismiss(dismiss);
|
|
70
|
+
}, [dismiss, popoverContent]);
|
|
67
71
|
useEffect(() => {
|
|
68
72
|
card.setPlacement(placement);
|
|
69
73
|
}, [placement, card]);
|
|
@@ -76,10 +80,13 @@ export const PopoverContent = ({
|
|
|
76
80
|
if (!focusWithin) {
|
|
77
81
|
return;
|
|
78
82
|
}
|
|
79
|
-
dismiss(event);
|
|
83
|
+
popoverContent.dismiss.current(event);
|
|
80
84
|
});
|
|
81
85
|
useOnClickOutside(event => {
|
|
82
|
-
|
|
86
|
+
if (!shouldDismissOnClickOutside) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
popoverContent.dismiss.current(event);
|
|
83
90
|
});
|
|
84
91
|
return /*#__PURE__*/React.createElement(Popper, {
|
|
85
92
|
offset: offset,
|
|
@@ -12,8 +12,8 @@ export const useOnClickOutside = onClickOutside => {
|
|
|
12
12
|
if (!doc) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
type: '
|
|
15
|
+
const unbindMouseUp = bind(doc, {
|
|
16
|
+
type: 'mouseup',
|
|
17
17
|
listener: event => {
|
|
18
18
|
if (!ref || !ref.current) {
|
|
19
19
|
return;
|
|
@@ -26,7 +26,7 @@ export const useOnClickOutside = onClickOutside => {
|
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
return () => {
|
|
29
|
-
|
|
29
|
+
unbindMouseUp();
|
|
30
30
|
};
|
|
31
31
|
}, [onClickOutside, ref]);
|
|
32
32
|
};
|
|
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
6
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
-
import { createContext, useId, useState } from 'react';
|
|
7
|
+
import { createContext, useId, useRef, useState } from 'react';
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line @repo/internal/react/consistent-types-definitions
|
|
10
10
|
|
|
@@ -45,13 +45,13 @@ export var SpotlightContext = /*#__PURE__*/createContext({
|
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
47
|
},
|
|
48
|
-
dismiss:
|
|
49
|
-
|
|
48
|
+
dismiss: {
|
|
49
|
+
current: function current() {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
50
52
|
},
|
|
51
53
|
setDismiss: function setDismiss() {
|
|
52
|
-
return
|
|
53
|
-
return undefined;
|
|
54
|
-
};
|
|
54
|
+
return undefined;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
});
|
|
@@ -92,12 +92,12 @@ export var SpotlightContextProvider = function SpotlightContextProvider(_ref) {
|
|
|
92
92
|
_useState0 = _slicedToArray(_useState9, 2),
|
|
93
93
|
cardRef = _useState0[0],
|
|
94
94
|
setCardRef = _useState0[1];
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
var dismissRef = useRef(function () {
|
|
96
|
+
return undefined;
|
|
97
|
+
});
|
|
98
|
+
var setDismiss = function setDismiss(dismissFn) {
|
|
99
|
+
dismissRef.current = dismissFn;
|
|
100
|
+
};
|
|
101
101
|
return /*#__PURE__*/React.createElement(SpotlightContext.Provider, {
|
|
102
102
|
value: {
|
|
103
103
|
card: {
|
|
@@ -115,7 +115,7 @@ export var SpotlightContextProvider = function SpotlightContextProvider(_ref) {
|
|
|
115
115
|
setRef: setPopoverRef,
|
|
116
116
|
update: update,
|
|
117
117
|
setUpdate: setUpdate,
|
|
118
|
-
dismiss:
|
|
118
|
+
dismiss: dismissRef,
|
|
119
119
|
setDismiss: setDismiss
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
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';
|
|
5
|
+
import { forwardRef, useContext } from 'react';
|
|
6
6
|
import CrossIcon from '@atlaskit/icon/core/cross';
|
|
7
7
|
import { Pressable } from '@atlaskit/primitives/compiled';
|
|
8
|
+
import { SpotlightContext } from '../../controllers/context';
|
|
8
9
|
var styles = {
|
|
9
10
|
root: "_2rko12b0 _1rjc12x7 _syaz15cr _bfhkcdhy _irr31bsc _1di61b6k"
|
|
10
11
|
};
|
|
@@ -19,11 +20,16 @@ export var SpotlightDismissControl = /*#__PURE__*/forwardRef(function (_ref, ref
|
|
|
19
20
|
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
20
21
|
onClick = _ref.onClick,
|
|
21
22
|
testId = _ref.testId;
|
|
23
|
+
var _useContext = useContext(SpotlightContext),
|
|
24
|
+
popoverContent = _useContext.popoverContent;
|
|
25
|
+
var dismiss = function dismiss(event) {
|
|
26
|
+
popoverContent.dismiss.current(event);
|
|
27
|
+
};
|
|
22
28
|
return /*#__PURE__*/React.createElement(Pressable
|
|
23
|
-
// eslint-disable-next-line
|
|
29
|
+
// eslint-disable-next-line @atlassian/a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
|
|
24
30
|
, {
|
|
25
31
|
autoFocus: autoFocus,
|
|
26
|
-
onClick: onClick,
|
|
32
|
+
onClick: onClick || dismiss,
|
|
27
33
|
ref: ref,
|
|
28
34
|
testId: testId,
|
|
29
35
|
xcss: styles.root,
|
|
@@ -51,6 +51,8 @@ export var PopoverContent = function PopoverContent(_ref) {
|
|
|
51
51
|
placement = _ref.placement,
|
|
52
52
|
_ref$isVisible = _ref.isVisible,
|
|
53
53
|
isVisible = _ref$isVisible === void 0 ? true : _ref$isVisible,
|
|
54
|
+
_ref$shouldDismissOnC = _ref.shouldDismissOnClickOutside,
|
|
55
|
+
shouldDismissOnClickOutside = _ref$shouldDismissOnC === void 0 ? true : _ref$shouldDismissOnC,
|
|
54
56
|
dismiss = _ref.dismiss,
|
|
55
57
|
testId = _ref.testId;
|
|
56
58
|
var updateRef = useRef(function () {
|
|
@@ -67,6 +69,9 @@ export var PopoverContent = function PopoverContent(_ref) {
|
|
|
67
69
|
useEffect(function () {
|
|
68
70
|
popoverContent.setRef(ref);
|
|
69
71
|
}, [ref, popoverContent]);
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
popoverContent.setDismiss(dismiss);
|
|
74
|
+
}, [dismiss, popoverContent]);
|
|
70
75
|
useEffect(function () {
|
|
71
76
|
card.setPlacement(placement);
|
|
72
77
|
}, [placement, card]);
|
|
@@ -81,10 +86,13 @@ export var PopoverContent = function PopoverContent(_ref) {
|
|
|
81
86
|
if (!focusWithin) {
|
|
82
87
|
return;
|
|
83
88
|
}
|
|
84
|
-
dismiss(event);
|
|
89
|
+
popoverContent.dismiss.current(event);
|
|
85
90
|
});
|
|
86
91
|
useOnClickOutside(function (event) {
|
|
87
|
-
|
|
92
|
+
if (!shouldDismissOnClickOutside) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
popoverContent.dismiss.current(event);
|
|
88
96
|
});
|
|
89
97
|
return /*#__PURE__*/React.createElement(Popper, {
|
|
90
98
|
offset: offset,
|
|
@@ -11,8 +11,8 @@ export var useOnClickOutside = function useOnClickOutside(onClickOutside) {
|
|
|
11
11
|
if (!doc) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
var
|
|
15
|
-
type: '
|
|
14
|
+
var unbindMouseUp = bind(doc, {
|
|
15
|
+
type: 'mouseup',
|
|
16
16
|
listener: function listener(event) {
|
|
17
17
|
if (!ref || !ref.current) {
|
|
18
18
|
return;
|
|
@@ -25,7 +25,7 @@ export var useOnClickOutside = function useOnClickOutside(onClickOutside) {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
return function () {
|
|
28
|
-
|
|
28
|
+
unbindMouseUp();
|
|
29
29
|
};
|
|
30
30
|
}, [onClickOutside, ref]);
|
|
31
31
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import { type Dispatch, type MutableRefObject, type ReactNode, type SetStateAction } from 'react';
|
|
6
|
-
import type { Placement } from '../types';
|
|
6
|
+
import type { DismissEvent, Placement } from '../types';
|
|
7
7
|
export interface SpotlightContextType {
|
|
8
8
|
card: {
|
|
9
9
|
ref: MutableRefObject<HTMLDivElement | null> | null;
|
|
@@ -20,8 +20,8 @@ export interface SpotlightContextType {
|
|
|
20
20
|
setRef: Dispatch<SetStateAction<MutableRefObject<HTMLDivElement | undefined> | undefined>>;
|
|
21
21
|
update: () => () => Promise<any>;
|
|
22
22
|
setUpdate: Dispatch<SetStateAction<() => () => Promise<any>>>;
|
|
23
|
-
dismiss: () => void
|
|
24
|
-
setDismiss:
|
|
23
|
+
dismiss: MutableRefObject<(_event: DismissEvent) => void>;
|
|
24
|
+
setDismiss: (dismissFn: (_event: DismissEvent) => void) => void;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
export declare const SpotlightContext: import("react").Context<SpotlightContextType>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -14,5 +14,5 @@ export { SpotlightMedia, type SpotlightMediaProps } from './ui/media';
|
|
|
14
14
|
export { PopoverProvider } from './ui/popover-provider';
|
|
15
15
|
export { PopoverContent, type PopoverContentProps } from './ui/popover-content';
|
|
16
16
|
export { PopoverTarget } from './ui/popover-target';
|
|
17
|
-
export { type Placement } from './types';
|
|
17
|
+
export { type Placement, type DismissEvent } from './types';
|
|
18
18
|
export { UNSAFE_UpdateOnChange } from './ui/UNSAFE_update-on-change';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
1
|
export type Placement = 'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end' | 'right-start' | 'right-end' | 'left-start' | 'left-end';
|
|
2
|
+
/**
|
|
3
|
+
* Spotlights can be dismissed by:
|
|
4
|
+
* 1. Clicking the `SpotlightDismissControl`
|
|
5
|
+
* 2. Clicking any DOM element outside the spotlight
|
|
6
|
+
* 3. Pressing the Escape key
|
|
7
|
+
*
|
|
8
|
+
* These events align to the `React.MouseEvent<HTMLButtonElement, MouseEvent>`, `MouseEvent`, and `KeyboardEvent` events respectively.
|
|
9
|
+
*/
|
|
10
|
+
export type DismissEvent = React.MouseEvent<HTMLButtonElement, MouseEvent> | MouseEvent | KeyboardEvent;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import { type ReactNode } from 'react';
|
|
6
|
-
import type { Placement } from '../../types';
|
|
6
|
+
import type { DismissEvent, Placement } from '../../types';
|
|
7
7
|
export interface PopoverContentProps {
|
|
8
8
|
/**
|
|
9
9
|
* A `testId` prop is provided for specified elements, which is a unique
|
|
@@ -13,7 +13,8 @@ export interface PopoverContentProps {
|
|
|
13
13
|
testId?: string;
|
|
14
14
|
placement: Placement;
|
|
15
15
|
isVisible?: boolean;
|
|
16
|
-
|
|
16
|
+
shouldDismissOnClickOutside?: boolean;
|
|
17
|
+
dismiss: (event: DismissEvent) => void;
|
|
17
18
|
children: ReactNode;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
@@ -21,4 +22,4 @@ export interface PopoverContentProps {
|
|
|
21
22
|
*
|
|
22
23
|
* A `PopoverContent` is the element that is shown as a popover.
|
|
23
24
|
*/
|
|
24
|
-
export declare const PopoverContent: ({ children, placement, isVisible, dismiss, testId, }: PopoverContentProps) => JSX.Element;
|
|
25
|
+
export declare const PopoverContent: ({ children, placement, isVisible, shouldDismissOnClickOutside, dismiss, testId, }: PopoverContentProps) => JSX.Element;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import { type Dispatch, type MutableRefObject, type ReactNode, type SetStateAction } from 'react';
|
|
6
|
-
import type { Placement } from '../types';
|
|
6
|
+
import type { DismissEvent, Placement } from '../types';
|
|
7
7
|
export interface SpotlightContextType {
|
|
8
8
|
card: {
|
|
9
9
|
ref: MutableRefObject<HTMLDivElement | null> | null;
|
|
@@ -20,8 +20,8 @@ export interface SpotlightContextType {
|
|
|
20
20
|
setRef: Dispatch<SetStateAction<MutableRefObject<HTMLDivElement | undefined> | undefined>>;
|
|
21
21
|
update: () => () => Promise<any>;
|
|
22
22
|
setUpdate: Dispatch<SetStateAction<() => () => Promise<any>>>;
|
|
23
|
-
dismiss: () => void
|
|
24
|
-
setDismiss:
|
|
23
|
+
dismiss: MutableRefObject<(_event: DismissEvent) => void>;
|
|
24
|
+
setDismiss: (dismissFn: (_event: DismissEvent) => void) => void;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
export declare const SpotlightContext: import("react").Context<SpotlightContextType>;
|
|
@@ -14,5 +14,5 @@ export { SpotlightMedia, type SpotlightMediaProps } from './ui/media';
|
|
|
14
14
|
export { PopoverProvider } from './ui/popover-provider';
|
|
15
15
|
export { PopoverContent, type PopoverContentProps } from './ui/popover-content';
|
|
16
16
|
export { PopoverTarget } from './ui/popover-target';
|
|
17
|
-
export { type Placement } from './types';
|
|
17
|
+
export { type Placement, type DismissEvent } from './types';
|
|
18
18
|
export { UNSAFE_UpdateOnChange } from './ui/UNSAFE_update-on-change';
|
|
@@ -1 +1,10 @@
|
|
|
1
1
|
export type Placement = 'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end' | 'right-start' | 'right-end' | 'left-start' | 'left-end';
|
|
2
|
+
/**
|
|
3
|
+
* Spotlights can be dismissed by:
|
|
4
|
+
* 1. Clicking the `SpotlightDismissControl`
|
|
5
|
+
* 2. Clicking any DOM element outside the spotlight
|
|
6
|
+
* 3. Pressing the Escape key
|
|
7
|
+
*
|
|
8
|
+
* These events align to the `React.MouseEvent<HTMLButtonElement, MouseEvent>`, `MouseEvent`, and `KeyboardEvent` events respectively.
|
|
9
|
+
*/
|
|
10
|
+
export type DismissEvent = React.MouseEvent<HTMLButtonElement, MouseEvent> | MouseEvent | KeyboardEvent;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import { type ReactNode } from 'react';
|
|
6
|
-
import type { Placement } from '../../types';
|
|
6
|
+
import type { DismissEvent, Placement } from '../../types';
|
|
7
7
|
export interface PopoverContentProps {
|
|
8
8
|
/**
|
|
9
9
|
* A `testId` prop is provided for specified elements, which is a unique
|
|
@@ -13,7 +13,8 @@ export interface PopoverContentProps {
|
|
|
13
13
|
testId?: string;
|
|
14
14
|
placement: Placement;
|
|
15
15
|
isVisible?: boolean;
|
|
16
|
-
|
|
16
|
+
shouldDismissOnClickOutside?: boolean;
|
|
17
|
+
dismiss: (event: DismissEvent) => void;
|
|
17
18
|
children: ReactNode;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
@@ -21,4 +22,4 @@ export interface PopoverContentProps {
|
|
|
21
22
|
*
|
|
22
23
|
* A `PopoverContent` is the element that is shown as a popover.
|
|
23
24
|
*/
|
|
24
|
-
export declare const PopoverContent: ({ children, placement, isVisible, dismiss, testId, }: PopoverContentProps) => JSX.Element;
|
|
25
|
+
export declare const PopoverContent: ({ children, placement, isVisible, shouldDismissOnClickOutside, dismiss, testId, }: PopoverContentProps) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/spotlight",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
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",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@atlaskit/browser-apis": "^0.0.1",
|
|
30
30
|
"@atlaskit/button": "^23.5.0",
|
|
31
|
-
"@atlaskit/css": "^0.
|
|
31
|
+
"@atlaskit/css": "^0.15.0",
|
|
32
32
|
"@atlaskit/ds-lib": "^5.1.0",
|
|
33
33
|
"@atlaskit/heading": "^5.2.0",
|
|
34
34
|
"@atlaskit/icon": "^28.5.0",
|
|
35
35
|
"@atlaskit/image": "^3.0.0",
|
|
36
36
|
"@atlaskit/popper": "^7.1.0",
|
|
37
|
-
"@atlaskit/primitives": "^
|
|
38
|
-
"@atlaskit/tokens": "^
|
|
37
|
+
"@atlaskit/primitives": "^15.0.0",
|
|
38
|
+
"@atlaskit/tokens": "^7.0.0",
|
|
39
39
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
|
-
"@compiled/react": "^0.18.
|
|
41
|
+
"@compiled/react": "^0.18.6",
|
|
42
42
|
"bind-event-listener": "^3.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|