@atlaskit/spotlight 0.7.2 → 0.8.0

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/spotlight
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`2a1e06ea7c3d7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a1e06ea7c3d7) -
8
+ Expose `offset` prop on `PopoverContent`. `PopoverContent` can now be manually positioned anywhere
9
+ within the viewport.
10
+
3
11
  ## 0.7.2
4
12
 
5
13
  ### Patch Changes
@@ -34,9 +34,7 @@ var SpotlightDismissControl = exports.SpotlightDismissControl = /*#__PURE__*/(0,
34
34
  var dismiss = function dismiss(event) {
35
35
  popoverContent.dismiss.current(event);
36
36
  };
37
- return /*#__PURE__*/React.createElement(_compiled.Pressable
38
- // eslint-disable-next-line @atlassian/a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
39
- , {
37
+ return /*#__PURE__*/React.createElement(_compiled.Pressable, {
40
38
  autoFocus: autoFocus,
41
39
  onClick: onClick || dismiss,
42
40
  ref: ref,
@@ -22,6 +22,10 @@ var styles = {
22
22
  root: "_1pby1fw0"
23
23
  };
24
24
 
25
+ /**
26
+ * Taken from `@atlaskit/popper`
27
+ */
28
+
25
29
  /**
26
30
  * The `transform: rotate(45deg);` styles used to rotate the `Caret` component result in the corners of
27
31
  * the caret extending beyond the bounding box (by roughly 2px). So, apply an offset to ensure
@@ -30,7 +34,7 @@ var styles = {
30
34
  * Note: `@atlaskit/popper` maps the offset to the placement, so we only need to define `[0, 2]` and
31
35
  * the offset will get correctly rotated depending on the placement.
32
36
  */
33
- var offset = [0, 2];
37
+ var defaultOffset = [0, 2];
34
38
  /**
35
39
  * The Spotlight card can be positioned in many different configurations, but the caret should always point to
36
40
  * the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
@@ -64,7 +68,9 @@ var PopoverContent = exports.PopoverContent = function PopoverContent(props) {
64
68
  shouldDismissOnClickOutside = _props$shouldDismissO === void 0 ? true : _props$shouldDismissO,
65
69
  dismiss = props.dismiss,
66
70
  back = props.back,
67
- testId = props.testId;
71
+ testId = props.testId,
72
+ _props$offset = props.offset,
73
+ offset = _props$offset === void 0 ? defaultOffset : _props$offset;
68
74
 
69
75
  /**
70
76
  * A user should only be able to pass a `done` or a `next`. Not both.
@@ -26,9 +26,7 @@ export const SpotlightDismissControl = /*#__PURE__*/forwardRef(({
26
26
  const dismiss = event => {
27
27
  popoverContent.dismiss.current(event);
28
28
  };
29
- return /*#__PURE__*/React.createElement(Pressable
30
- // eslint-disable-next-line @atlassian/a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
31
- , {
29
+ return /*#__PURE__*/React.createElement(Pressable, {
32
30
  autoFocus: autoFocus,
33
31
  onClick: onClick || dismiss,
34
32
  ref: ref,
@@ -13,6 +13,10 @@ const styles = {
13
13
  root: "_1pby1fw0"
14
14
  };
15
15
 
16
+ /**
17
+ * Taken from `@atlaskit/popper`
18
+ */
19
+
16
20
  /**
17
21
  * The `transform: rotate(45deg);` styles used to rotate the `Caret` component result in the corners of
18
22
  * the caret extending beyond the bounding box (by roughly 2px). So, apply an offset to ensure
@@ -21,7 +25,7 @@ const styles = {
21
25
  * Note: `@atlaskit/popper` maps the offset to the placement, so we only need to define `[0, 2]` and
22
26
  * the offset will get correctly rotated depending on the placement.
23
27
  */
24
- const offset = [0, 2];
28
+ const defaultOffset = [0, 2];
25
29
  /**
26
30
  * The Spotlight card can be positioned in many different configurations, but the caret should always point to
27
31
  * the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
@@ -54,7 +58,8 @@ export const PopoverContent = props => {
54
58
  shouldDismissOnClickOutside = true,
55
59
  dismiss,
56
60
  back,
57
- testId
61
+ testId,
62
+ offset = defaultOffset
58
63
  } = props;
59
64
 
60
65
  /**
@@ -25,9 +25,7 @@ export var SpotlightDismissControl = /*#__PURE__*/forwardRef(function (_ref, ref
25
25
  var dismiss = function dismiss(event) {
26
26
  popoverContent.dismiss.current(event);
27
27
  };
28
- return /*#__PURE__*/React.createElement(Pressable
29
- // eslint-disable-next-line @atlassian/a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
30
- , {
28
+ return /*#__PURE__*/React.createElement(Pressable, {
31
29
  autoFocus: autoFocus,
32
30
  onClick: onClick || dismiss,
33
31
  ref: ref,
@@ -13,6 +13,10 @@ var styles = {
13
13
  root: "_1pby1fw0"
14
14
  };
15
15
 
16
+ /**
17
+ * Taken from `@atlaskit/popper`
18
+ */
19
+
16
20
  /**
17
21
  * The `transform: rotate(45deg);` styles used to rotate the `Caret` component result in the corners of
18
22
  * the caret extending beyond the bounding box (by roughly 2px). So, apply an offset to ensure
@@ -21,7 +25,7 @@ var styles = {
21
25
  * Note: `@atlaskit/popper` maps the offset to the placement, so we only need to define `[0, 2]` and
22
26
  * the offset will get correctly rotated depending on the placement.
23
27
  */
24
- var offset = [0, 2];
28
+ var defaultOffset = [0, 2];
25
29
  /**
26
30
  * The Spotlight card can be positioned in many different configurations, but the caret should always point to
27
31
  * the center of the target element. `@atlaskit/popper` uses `'top' | 'right' | 'bottom' | 'left'` values for
@@ -55,7 +59,9 @@ export var PopoverContent = function PopoverContent(props) {
55
59
  shouldDismissOnClickOutside = _props$shouldDismissO === void 0 ? true : _props$shouldDismissO,
56
60
  dismiss = props.dismiss,
57
61
  back = props.back,
58
- testId = props.testId;
62
+ testId = props.testId,
63
+ _props$offset = props.offset,
64
+ offset = _props$offset === void 0 ? defaultOffset : _props$offset;
59
65
 
60
66
  /**
61
67
  * A user should only be able to pass a `done` or a `next`. Not both.
@@ -4,6 +4,10 @@
4
4
  */
5
5
  import { type ReactNode } from 'react';
6
6
  import type { BackEvent, DismissEvent, DoneEvent, NextEvent, Placement } from '../../types';
7
+ /**
8
+ * Taken from `@atlaskit/popper`
9
+ */
10
+ type Offset = [number | null | undefined, number | null | undefined];
7
11
  interface BasePopoverContentProps {
8
12
  /**
9
13
  * A `testId` prop is provided for specified elements, which is a unique
@@ -38,6 +42,12 @@ interface BasePopoverContentProps {
38
42
  * then that takes precedence, and `back` will be ignored.
39
43
  */
40
44
  back?: (event: BackEvent) => void;
45
+ /**
46
+ * Distance the spotlight should be offset from the target in the format of [along, away] (units in px).
47
+ * Defaults to [0, 2] - which means the spotlight will be 2px away from the edge of the target specified
48
+ * by the `placement` prop.
49
+ */
50
+ offset?: Offset;
41
51
  /**
42
52
  * The content to be rendered in `PopoverContent`. This is intended to be a `SpotlightCard`.
43
53
  */
@@ -4,6 +4,13 @@
4
4
  */
5
5
  import { type ReactNode } from 'react';
6
6
  import type { BackEvent, DismissEvent, DoneEvent, NextEvent, Placement } from '../../types';
7
+ /**
8
+ * Taken from `@atlaskit/popper`
9
+ */
10
+ type Offset = [
11
+ number | null | undefined,
12
+ number | null | undefined
13
+ ];
7
14
  interface BasePopoverContentProps {
8
15
  /**
9
16
  * A `testId` prop is provided for specified elements, which is a unique
@@ -38,6 +45,12 @@ interface BasePopoverContentProps {
38
45
  * then that takes precedence, and `back` will be ignored.
39
46
  */
40
47
  back?: (event: BackEvent) => void;
48
+ /**
49
+ * Distance the spotlight should be offset from the target in the format of [along, away] (units in px).
50
+ * Defaults to [0, 2] - which means the spotlight will be 2px away from the edge of the target specified
51
+ * by the `placement` prop.
52
+ */
53
+ offset?: Offset;
41
54
  /**
42
55
  * The content to be rendered in `PopoverContent`. This is intended to be a `SpotlightCard`.
43
56
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/spotlight",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "A spotlight introduces users to points of interest, from focused messages to multi-step tours.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,13 +35,13 @@
35
35
  "@atlaskit/browser-apis": "^0.0.1",
36
36
  "@atlaskit/button": "^23.5.0",
37
37
  "@atlaskit/css": "^0.15.0",
38
- "@atlaskit/ds-lib": "^5.1.0",
38
+ "@atlaskit/ds-lib": "^5.2.0",
39
39
  "@atlaskit/heading": "^5.2.0",
40
40
  "@atlaskit/icon": "^28.5.0",
41
41
  "@atlaskit/image": "^3.0.0",
42
42
  "@atlaskit/popper": "^7.1.0",
43
43
  "@atlaskit/primitives": "^16.1.0",
44
- "@atlaskit/tokens": "^7.0.0",
44
+ "@atlaskit/tokens": "^7.1.0",
45
45
  "@atlaskit/visually-hidden": "^3.0.0",
46
46
  "@babel/runtime": "^7.0.0",
47
47
  "@compiled/react": "^0.18.6",