@atlaskit/spotlight 0.3.3 → 0.3.4

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,12 @@
1
1
  # @atlaskit/spotlight
2
2
 
3
+ ## 0.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`cc92031710191`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cc92031710191) -
8
+ `SpotlightDismissControl` now applies `autofocus` when it is mounted.
9
+
3
10
  ## 0.3.3
4
11
 
5
12
  ### Patch Changes
@@ -1,10 +1,11 @@
1
1
  ._1bsbo7ao{width:15px}
2
- ._1eint94y{border-end-end-radius:1px}
3
2
  ._1pby1fw0{z-index:700}
4
- ._1s1gt94y{border-start-start-radius:1px}
5
3
  ._1yxnt94y{border-end-start-radius:1px}
6
4
  ._4t3io7ao{height:15px}
7
- ._5fbct94y{border-start-end-radius:1px}
8
5
  ._bfhkcdhy{background-color:var(--ds-background-neutral-bold,#44546f)}
9
6
  ._kqswh2mm{position:relative}
7
+ ._mkrzmhja{clip-path:polygon(0 0,100% 100%,0 100%)}
8
+ ._t9ec1hke{transform:rotate(135deg)}
9
+ ._t9ec71a3{transform:rotate(315deg)}
10
+ ._t9ecebzf{transform:rotate(225deg)}
10
11
  ._t9ecjyd4{transform:rotate(45deg)}
@@ -13,17 +13,17 @@ var _runtime = require("@compiled/react/runtime");
13
13
  var _context = require("../../../controllers/context");
14
14
  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
15
  var styles = {
16
- root: "_kqswh2mm _1pby1fw0 _1bsbo7ao _4t3io7ao _t9ecjyd4 _bfhkcdhy",
17
- 'top-start': "_1eint94y",
18
- 'top-center': "_1eint94y",
19
- 'top-end': "_1eint94y",
20
- 'bottom-start': "_1s1gt94y",
21
- 'bottom-center': "_1s1gt94y",
22
- 'bottom-end': "_1s1gt94y",
23
- 'right-start': "_1yxnt94y",
24
- 'right-end': "_1yxnt94y",
25
- 'left-start': "_5fbct94y",
26
- 'left-end': "_5fbct94y"
16
+ root: "_bfhkcdhy _1yxnt94y _mkrzmhja _4t3io7ao _kqswh2mm _1bsbo7ao _1pby1fw0",
17
+ 'top-start': "_t9ec71a3",
18
+ 'top-center': "_t9ec71a3",
19
+ 'top-end': "_t9ec71a3",
20
+ 'bottom-start': "_t9ec1hke",
21
+ 'bottom-center': "_t9ec1hke",
22
+ 'bottom-end': "_t9ec1hke",
23
+ 'right-start': "_t9ecjyd4",
24
+ 'right-end': "_t9ecjyd4",
25
+ 'left-start': "_t9ecebzf",
26
+ 'left-end': "_t9ecebzf"
27
27
  };
28
28
  /**
29
29
  * __Caret__
@@ -24,14 +24,19 @@ var styles = {
24
24
  *
25
25
  */
26
26
  var SpotlightDismissControl = exports.SpotlightDismissControl = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
27
- var onClick = _ref.onClick,
27
+ var _ref$autoFocus = _ref.autoFocus,
28
+ autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
29
+ onClick = _ref.onClick,
28
30
  testId = _ref.testId;
29
- return /*#__PURE__*/React.createElement(_compiled.Pressable, {
30
- "aria-label": "Dismiss",
31
- xcss: styles.root,
31
+ return /*#__PURE__*/React.createElement(_compiled.Pressable
32
+ // eslint-disable-next-line jsx-a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
33
+ , {
34
+ autoFocus: autoFocus,
32
35
  onClick: onClick,
33
36
  ref: ref,
34
- testId: testId
37
+ testId: testId,
38
+ xcss: styles.root,
39
+ "aria-label": "Dismiss"
35
40
  }, /*#__PURE__*/React.createElement(_cross.default, {
36
41
  label: "Close"
37
42
  }));
@@ -1,5 +1 @@
1
- ._1pby1fw0{z-index:700}
2
- ._3um015vq{visibility:hidden}
3
- ._3um0ewfl{visibility:visible}
4
- ._lcxv1wug{pointer-events:auto}
5
- ._lcxvglyw{pointer-events:none}
1
+ ._1pby1fw0{z-index:700}
@@ -16,10 +16,6 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
16
16
  var styles = {
17
17
  root: "_1pby1fw0"
18
18
  };
19
- var visibilityStyles = {
20
- visible: "_lcxv1wug _3um0ewfl",
21
- hidden: "_lcxvglyw _3um015vq"
22
- };
23
19
 
24
20
  /**
25
21
  * The `transform: rotate(45deg);` styles used to rotate the `Caret` component result in the corners of
@@ -63,7 +59,6 @@ var PopoverContent = exports.PopoverContent = function PopoverContent(_ref) {
63
59
  var _useContext = (0, _react.useContext)(_context.SpotlightContext),
64
60
  setPlacement = _useContext.setPlacement,
65
61
  heading = _useContext.heading;
66
- var visibility = isVisible ? 'visible' : 'hidden';
67
62
  (0, _react.useEffect)(function () {
68
63
  setPlacement(placement);
69
64
  }, [placement, setPlacement]);
@@ -73,6 +68,9 @@ var PopoverContent = exports.PopoverContent = function PopoverContent(_ref) {
73
68
  }, function (_ref2) {
74
69
  var ref = _ref2.ref,
75
70
  style = _ref2.style;
71
+ if (!isVisible) {
72
+ return;
73
+ }
76
74
  return /*#__PURE__*/React.createElement("div", {
77
75
  role: "dialog",
78
76
  "data-testid": testId,
@@ -81,7 +79,7 @@ var PopoverContent = exports.PopoverContent = function PopoverContent(_ref) {
81
79
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
82
80
  ,
83
81
  style: style,
84
- className: (0, _runtime.ax)([styles.root, visibilityStyles[visibility]])
82
+ className: (0, _runtime.ax)([styles.root])
85
83
  }, children);
86
84
  });
87
85
  };
@@ -31,5 +31,5 @@ var SpotlightStepCount = exports.SpotlightStepCount = /*#__PURE__*/(0, _react.fo
31
31
  }, /*#__PURE__*/React.createElement(_compiled.Text, {
32
32
  ref: ref,
33
33
  testId: testId
34
- }, children, ' ', /*#__PURE__*/React.createElement(_visuallyHidden.default, null, "steps")));
34
+ }, children, " ", /*#__PURE__*/React.createElement(_visuallyHidden.default, null, "steps")));
35
35
  });
@@ -1,10 +1,11 @@
1
1
  ._1bsbo7ao{width:15px}
2
- ._1eint94y{border-end-end-radius:1px}
3
2
  ._1pby1fw0{z-index:700}
4
- ._1s1gt94y{border-start-start-radius:1px}
5
3
  ._1yxnt94y{border-end-start-radius:1px}
6
4
  ._4t3io7ao{height:15px}
7
- ._5fbct94y{border-start-end-radius:1px}
8
5
  ._bfhkcdhy{background-color:var(--ds-background-neutral-bold,#44546f)}
9
6
  ._kqswh2mm{position:relative}
7
+ ._mkrzmhja{clip-path:polygon(0 0,100% 100%,0 100%)}
8
+ ._t9ec1hke{transform:rotate(135deg)}
9
+ ._t9ec71a3{transform:rotate(315deg)}
10
+ ._t9ecebzf{transform:rotate(225deg)}
10
11
  ._t9ecjyd4{transform:rotate(45deg)}
@@ -5,17 +5,17 @@ import { ax, ix } from "@compiled/react/runtime";
5
5
  import { forwardRef, useContext } from 'react';
6
6
  import { SpotlightContext } from '../../../controllers/context';
7
7
  const styles = {
8
- root: "_kqswh2mm _1pby1fw0 _1bsbo7ao _4t3io7ao _t9ecjyd4 _bfhkcdhy",
9
- 'top-start': "_1eint94y",
10
- 'top-center': "_1eint94y",
11
- 'top-end': "_1eint94y",
12
- 'bottom-start': "_1s1gt94y",
13
- 'bottom-center': "_1s1gt94y",
14
- 'bottom-end': "_1s1gt94y",
15
- 'right-start': "_1yxnt94y",
16
- 'right-end': "_1yxnt94y",
17
- 'left-start': "_5fbct94y",
18
- 'left-end': "_5fbct94y"
8
+ root: "_bfhkcdhy _1yxnt94y _mkrzmhja _4t3io7ao _kqswh2mm _1bsbo7ao _1pby1fw0",
9
+ 'top-start': "_t9ec71a3",
10
+ 'top-center': "_t9ec71a3",
11
+ 'top-end': "_t9ec71a3",
12
+ 'bottom-start': "_t9ec1hke",
13
+ 'bottom-center': "_t9ec1hke",
14
+ 'bottom-end': "_t9ec1hke",
15
+ 'right-start': "_t9ecjyd4",
16
+ 'right-end': "_t9ecjyd4",
17
+ 'left-start': "_t9ecebzf",
18
+ 'left-end': "_t9ecebzf"
19
19
  };
20
20
  /**
21
21
  * __Caret__
@@ -15,15 +15,19 @@ const styles = {
15
15
  *
16
16
  */
17
17
  export const SpotlightDismissControl = /*#__PURE__*/forwardRef(({
18
+ autoFocus = true,
18
19
  onClick,
19
20
  testId
20
21
  }, ref) => {
21
- return /*#__PURE__*/React.createElement(Pressable, {
22
- "aria-label": "Dismiss",
23
- xcss: styles.root,
22
+ return /*#__PURE__*/React.createElement(Pressable
23
+ // eslint-disable-next-line jsx-a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
24
+ , {
25
+ autoFocus: autoFocus,
24
26
  onClick: onClick,
25
27
  ref: ref,
26
- testId: testId
28
+ testId: testId,
29
+ xcss: styles.root,
30
+ "aria-label": "Dismiss"
27
31
  }, /*#__PURE__*/React.createElement(CrossIcon, {
28
32
  label: "Close"
29
33
  }));
@@ -1,5 +1 @@
1
- ._1pby1fw0{z-index:700}
2
- ._3um015vq{visibility:hidden}
3
- ._3um0ewfl{visibility:visible}
4
- ._lcxv1wug{pointer-events:auto}
5
- ._lcxvglyw{pointer-events:none}
1
+ ._1pby1fw0{z-index:700}
@@ -8,10 +8,6 @@ import { SpotlightContext } from '../../controllers/context';
8
8
  const styles = {
9
9
  root: "_1pby1fw0"
10
10
  };
11
- const visibilityStyles = {
12
- visible: "_lcxv1wug _3um0ewfl",
13
- hidden: "_lcxvglyw _3um015vq"
14
- };
15
11
 
16
12
  /**
17
13
  * The `transform: rotate(45deg);` styles used to rotate the `Caret` component result in the corners of
@@ -56,7 +52,6 @@ export const PopoverContent = ({
56
52
  setPlacement,
57
53
  heading
58
54
  } = useContext(SpotlightContext);
59
- const visibility = isVisible ? 'visible' : 'hidden';
60
55
  useEffect(() => {
61
56
  setPlacement(placement);
62
57
  }, [placement, setPlacement]);
@@ -66,14 +61,19 @@ export const PopoverContent = ({
66
61
  }, ({
67
62
  ref,
68
63
  style
69
- }) => /*#__PURE__*/React.createElement("div", {
70
- role: "dialog",
71
- "data-testid": testId,
72
- "aria-labelledby": heading.id,
73
- ref: ref
74
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
75
- ,
76
- style: style,
77
- className: ax([styles.root, visibilityStyles[visibility]])
78
- }, children));
64
+ }) => {
65
+ if (!isVisible) {
66
+ return;
67
+ }
68
+ return /*#__PURE__*/React.createElement("div", {
69
+ role: "dialog",
70
+ "data-testid": testId,
71
+ "aria-labelledby": heading.id,
72
+ ref: ref
73
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
74
+ ,
75
+ style: style,
76
+ className: ax([styles.root])
77
+ }, children);
78
+ });
79
79
  };
@@ -23,5 +23,5 @@ export const SpotlightStepCount = /*#__PURE__*/forwardRef(({
23
23
  }, /*#__PURE__*/React.createElement(Text, {
24
24
  ref: ref,
25
25
  testId: testId
26
- }, children, ' ', /*#__PURE__*/React.createElement(VisuallyHidden, null, "steps")));
26
+ }, children, " ", /*#__PURE__*/React.createElement(VisuallyHidden, null, "steps")));
27
27
  });
@@ -1,10 +1,11 @@
1
1
  ._1bsbo7ao{width:15px}
2
- ._1eint94y{border-end-end-radius:1px}
3
2
  ._1pby1fw0{z-index:700}
4
- ._1s1gt94y{border-start-start-radius:1px}
5
3
  ._1yxnt94y{border-end-start-radius:1px}
6
4
  ._4t3io7ao{height:15px}
7
- ._5fbct94y{border-start-end-radius:1px}
8
5
  ._bfhkcdhy{background-color:var(--ds-background-neutral-bold,#44546f)}
9
6
  ._kqswh2mm{position:relative}
7
+ ._mkrzmhja{clip-path:polygon(0 0,100% 100%,0 100%)}
8
+ ._t9ec1hke{transform:rotate(135deg)}
9
+ ._t9ec71a3{transform:rotate(315deg)}
10
+ ._t9ecebzf{transform:rotate(225deg)}
10
11
  ._t9ecjyd4{transform:rotate(45deg)}
@@ -5,17 +5,17 @@ import { ax, ix } from "@compiled/react/runtime";
5
5
  import { forwardRef, useContext } from 'react';
6
6
  import { SpotlightContext } from '../../../controllers/context';
7
7
  var styles = {
8
- root: "_kqswh2mm _1pby1fw0 _1bsbo7ao _4t3io7ao _t9ecjyd4 _bfhkcdhy",
9
- 'top-start': "_1eint94y",
10
- 'top-center': "_1eint94y",
11
- 'top-end': "_1eint94y",
12
- 'bottom-start': "_1s1gt94y",
13
- 'bottom-center': "_1s1gt94y",
14
- 'bottom-end': "_1s1gt94y",
15
- 'right-start': "_1yxnt94y",
16
- 'right-end': "_1yxnt94y",
17
- 'left-start': "_5fbct94y",
18
- 'left-end': "_5fbct94y"
8
+ root: "_bfhkcdhy _1yxnt94y _mkrzmhja _4t3io7ao _kqswh2mm _1bsbo7ao _1pby1fw0",
9
+ 'top-start': "_t9ec71a3",
10
+ 'top-center': "_t9ec71a3",
11
+ 'top-end': "_t9ec71a3",
12
+ 'bottom-start': "_t9ec1hke",
13
+ 'bottom-center': "_t9ec1hke",
14
+ 'bottom-end': "_t9ec1hke",
15
+ 'right-start': "_t9ecjyd4",
16
+ 'right-end': "_t9ecjyd4",
17
+ 'left-start': "_t9ecebzf",
18
+ 'left-end': "_t9ecebzf"
19
19
  };
20
20
  /**
21
21
  * __Caret__
@@ -15,14 +15,19 @@ var styles = {
15
15
  *
16
16
  */
17
17
  export var SpotlightDismissControl = /*#__PURE__*/forwardRef(function (_ref, ref) {
18
- var onClick = _ref.onClick,
18
+ var _ref$autoFocus = _ref.autoFocus,
19
+ autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
20
+ onClick = _ref.onClick,
19
21
  testId = _ref.testId;
20
- return /*#__PURE__*/React.createElement(Pressable, {
21
- "aria-label": "Dismiss",
22
- xcss: styles.root,
22
+ return /*#__PURE__*/React.createElement(Pressable
23
+ // eslint-disable-next-line jsx-a11y/no-autofocus -- VERIFIED: autoFocus moving to first focusable element on non-modal modal dialog.
24
+ , {
25
+ autoFocus: autoFocus,
23
26
  onClick: onClick,
24
27
  ref: ref,
25
- testId: testId
28
+ testId: testId,
29
+ xcss: styles.root,
30
+ "aria-label": "Dismiss"
26
31
  }, /*#__PURE__*/React.createElement(CrossIcon, {
27
32
  label: "Close"
28
33
  }));
@@ -1,5 +1 @@
1
- ._1pby1fw0{z-index:700}
2
- ._3um015vq{visibility:hidden}
3
- ._3um0ewfl{visibility:visible}
4
- ._lcxv1wug{pointer-events:auto}
5
- ._lcxvglyw{pointer-events:none}
1
+ ._1pby1fw0{z-index:700}
@@ -8,10 +8,6 @@ import { SpotlightContext } from '../../controllers/context';
8
8
  var styles = {
9
9
  root: "_1pby1fw0"
10
10
  };
11
- var visibilityStyles = {
12
- visible: "_lcxv1wug _3um0ewfl",
13
- hidden: "_lcxvglyw _3um015vq"
14
- };
15
11
 
16
12
  /**
17
13
  * The `transform: rotate(45deg);` styles used to rotate the `Caret` component result in the corners of
@@ -55,7 +51,6 @@ export var PopoverContent = function PopoverContent(_ref) {
55
51
  var _useContext = useContext(SpotlightContext),
56
52
  setPlacement = _useContext.setPlacement,
57
53
  heading = _useContext.heading;
58
- var visibility = isVisible ? 'visible' : 'hidden';
59
54
  useEffect(function () {
60
55
  setPlacement(placement);
61
56
  }, [placement, setPlacement]);
@@ -65,6 +60,9 @@ export var PopoverContent = function PopoverContent(_ref) {
65
60
  }, function (_ref2) {
66
61
  var ref = _ref2.ref,
67
62
  style = _ref2.style;
63
+ if (!isVisible) {
64
+ return;
65
+ }
68
66
  return /*#__PURE__*/React.createElement("div", {
69
67
  role: "dialog",
70
68
  "data-testid": testId,
@@ -73,7 +71,7 @@ export var PopoverContent = function PopoverContent(_ref) {
73
71
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
74
72
  ,
75
73
  style: style,
76
- className: ax([styles.root, visibilityStyles[visibility]])
74
+ className: ax([styles.root])
77
75
  }, children);
78
76
  });
79
77
  };
@@ -22,5 +22,5 @@ export var SpotlightStepCount = /*#__PURE__*/forwardRef(function (_ref, ref) {
22
22
  }, /*#__PURE__*/React.createElement(Text, {
23
23
  ref: ref,
24
24
  testId: testId
25
- }, children, ' ', /*#__PURE__*/React.createElement(VisuallyHidden, null, "steps")));
25
+ }, children, " ", /*#__PURE__*/React.createElement(VisuallyHidden, null, "steps")));
26
26
  });
@@ -10,6 +10,14 @@ export interface SpotlightDismissControlProps {
10
10
  * The action to take when the button is clicked.
11
11
  */
12
12
  onClick?: PressableProps['onClick'];
13
+ /**
14
+ * @default true
15
+ *
16
+ * Specifies whether the dismiss button should be focused when the spotlight is rendered.
17
+ * For spotlights that are triggered by user-action, this should be `true`. In the event that
18
+ * a spotlight is rendered on pageload, without explicit user interaction, this should be `false`.
19
+ */
20
+ autoFocus?: boolean;
13
21
  }
14
22
  /**
15
23
  * __SpotlightDismissControl__
@@ -20,5 +20,5 @@ interface PopoverContentProps {
20
20
  *
21
21
  * A `PopoverContent` is the element that is shown as a popover.
22
22
  */
23
- export declare const PopoverContent: ({ children, placement, isVisible, testId }: PopoverContentProps) => JSX.Element;
23
+ export declare const PopoverContent: ({ children, placement, isVisible, testId, }: PopoverContentProps) => JSX.Element;
24
24
  export {};
@@ -10,6 +10,14 @@ export interface SpotlightDismissControlProps {
10
10
  * The action to take when the button is clicked.
11
11
  */
12
12
  onClick?: PressableProps['onClick'];
13
+ /**
14
+ * @default true
15
+ *
16
+ * Specifies whether the dismiss button should be focused when the spotlight is rendered.
17
+ * For spotlights that are triggered by user-action, this should be `true`. In the event that
18
+ * a spotlight is rendered on pageload, without explicit user interaction, this should be `false`.
19
+ */
20
+ autoFocus?: boolean;
13
21
  }
14
22
  /**
15
23
  * __SpotlightDismissControl__
@@ -20,5 +20,5 @@ interface PopoverContentProps {
20
20
  *
21
21
  * A `PopoverContent` is the element that is shown as a popover.
22
22
  */
23
- export declare const PopoverContent: ({ children, placement, isVisible, testId }: PopoverContentProps) => JSX.Element;
23
+ export declare const PopoverContent: ({ children, placement, isVisible, testId, }: PopoverContentProps) => JSX.Element;
24
24
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/spotlight",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
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",
@@ -29,7 +29,7 @@
29
29
  "@atlaskit/button": "^23.4.0",
30
30
  "@atlaskit/css": "^0.14.0",
31
31
  "@atlaskit/heading": "^5.2.0",
32
- "@atlaskit/icon": "^28.2.0",
32
+ "@atlaskit/icon": "^28.3.0",
33
33
  "@atlaskit/image": "^3.0.0",
34
34
  "@atlaskit/popper": "^7.1.0",
35
35
  "@atlaskit/primitives": "^14.15.0",