@atlaskit/onboarding 10.2.2 → 10.2.6

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.
Files changed (120) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/components/{Animation.js → animation.js} +8 -1
  3. package/dist/cjs/components/card.js +159 -0
  4. package/dist/cjs/components/{Clone.js → clone.js} +12 -3
  5. package/dist/cjs/components/index.js +13 -13
  6. package/dist/cjs/components/{Modal.js → modal.js} +26 -17
  7. package/dist/cjs/components/{SpotlightCard.js → spotlight-card.js} +10 -3
  8. package/dist/cjs/components/{SpotlightDialog.js → spotlight-dialog.js} +9 -8
  9. package/dist/cjs/components/{SpotlightInner.js → spotlight-inner.js} +16 -9
  10. package/dist/cjs/components/{SpotlightManager.js → spotlight-manager.js} +13 -5
  11. package/dist/cjs/components/spotlight-target.js +34 -0
  12. package/dist/cjs/components/{SpotlightTransition.js → spotlight-transition.js} +27 -11
  13. package/dist/cjs/components/spotlight.js +58 -0
  14. package/dist/cjs/components/{useSpotlight.js → use-spotlight.js} +11 -2
  15. package/dist/cjs/components/{ValueChanged.js → value-changed.js} +0 -0
  16. package/dist/cjs/index.js +2 -2
  17. package/dist/cjs/styled/blanket.js +64 -0
  18. package/dist/cjs/styled/dialog.js +86 -0
  19. package/dist/cjs/styled/modal.js +144 -0
  20. package/dist/cjs/styled/target.js +123 -0
  21. package/dist/cjs/utils/use-element-box.js +8 -0
  22. package/dist/cjs/version.json +1 -1
  23. package/dist/es2019/components/{Animation.js → animation.js} +9 -1
  24. package/dist/es2019/components/card.js +131 -0
  25. package/dist/es2019/components/{Clone.js → clone.js} +10 -1
  26. package/dist/es2019/components/index.js +7 -7
  27. package/dist/es2019/components/{Modal.js → modal.js} +28 -18
  28. package/dist/es2019/components/{SpotlightCard.js → spotlight-card.js} +9 -2
  29. package/dist/es2019/components/{SpotlightDialog.js → spotlight-dialog.js} +7 -6
  30. package/dist/es2019/components/{SpotlightInner.js → spotlight-inner.js} +12 -5
  31. package/dist/es2019/components/{SpotlightManager.js → spotlight-manager.js} +11 -3
  32. package/dist/es2019/components/spotlight-target.js +19 -0
  33. package/dist/es2019/components/{SpotlightTransition.js → spotlight-transition.js} +21 -5
  34. package/dist/es2019/components/spotlight.js +40 -0
  35. package/dist/es2019/components/{useSpotlight.js → use-spotlight.js} +11 -1
  36. package/dist/es2019/components/{ValueChanged.js → value-changed.js} +0 -0
  37. package/dist/es2019/index.js +1 -1
  38. package/dist/es2019/styled/blanket.js +45 -0
  39. package/dist/es2019/styled/dialog.js +62 -0
  40. package/dist/es2019/styled/modal.js +115 -0
  41. package/dist/es2019/styled/target.js +92 -0
  42. package/dist/es2019/utils/use-element-box.js +8 -0
  43. package/dist/es2019/version.json +1 -1
  44. package/dist/esm/components/{Animation.js → animation.js} +9 -1
  45. package/dist/esm/components/card.js +140 -0
  46. package/dist/esm/components/{Clone.js → clone.js} +10 -1
  47. package/dist/esm/components/index.js +7 -7
  48. package/dist/esm/components/{Modal.js → modal.js} +27 -18
  49. package/dist/esm/components/{SpotlightCard.js → spotlight-card.js} +9 -2
  50. package/dist/esm/components/{SpotlightDialog.js → spotlight-dialog.js} +7 -6
  51. package/dist/esm/components/{SpotlightInner.js → spotlight-inner.js} +13 -6
  52. package/dist/esm/components/{SpotlightManager.js → spotlight-manager.js} +11 -3
  53. package/dist/esm/components/spotlight-target.js +22 -0
  54. package/dist/esm/components/{SpotlightTransition.js → spotlight-transition.js} +27 -11
  55. package/dist/esm/components/spotlight.js +45 -0
  56. package/dist/esm/components/{useSpotlight.js → use-spotlight.js} +11 -1
  57. package/dist/esm/components/{ValueChanged.js → value-changed.js} +0 -0
  58. package/dist/esm/index.js +1 -1
  59. package/dist/esm/styled/blanket.js +51 -0
  60. package/dist/esm/styled/dialog.js +67 -0
  61. package/dist/esm/styled/modal.js +119 -0
  62. package/dist/esm/styled/target.js +106 -0
  63. package/dist/esm/utils/use-element-box.js +8 -0
  64. package/dist/esm/version.json +1 -1
  65. package/dist/types/components/animation.d.ts +15 -0
  66. package/dist/types/components/{Card.d.ts → card.d.ts} +35 -12
  67. package/dist/types/components/clone.d.ts +50 -0
  68. package/dist/types/components/index.d.ts +7 -7
  69. package/dist/types/components/modal.d.ts +48 -0
  70. package/dist/types/components/spotlight-card.d.ts +63 -0
  71. package/dist/types/components/{SpotlightDialog.d.ts → spotlight-dialog.d.ts} +37 -13
  72. package/dist/types/components/spotlight-inner.d.ts +54 -0
  73. package/dist/types/components/{SpotlightManager.d.ts → spotlight-manager.d.ts} +21 -5
  74. package/dist/types/components/spotlight-target.d.ts +20 -0
  75. package/dist/types/components/spotlight-transition.d.ts +41 -0
  76. package/dist/types/components/spotlight.d.ts +96 -0
  77. package/dist/types/components/use-spotlight.d.ts +12 -0
  78. package/dist/types/components/value-changed.d.ts +11 -0
  79. package/dist/types/index.d.ts +1 -1
  80. package/dist/types/styled/blanket.d.ts +18 -0
  81. package/dist/types/styled/dialog.d.ts +25 -0
  82. package/dist/types/styled/modal.d.ts +36 -0
  83. package/dist/types/styled/target.d.ts +35 -0
  84. package/dist/types/utils/use-element-box.d.ts +7 -0
  85. package/package.json +21 -11
  86. package/dist/cjs/components/Card.js +0 -103
  87. package/dist/cjs/components/Spotlight.js +0 -79
  88. package/dist/cjs/components/SpotlightTarget.js +0 -62
  89. package/dist/cjs/styled/Blanket.js +0 -35
  90. package/dist/cjs/styled/Dialog.js +0 -50
  91. package/dist/cjs/styled/Modal.js +0 -42
  92. package/dist/cjs/styled/Target.js +0 -54
  93. package/dist/es2019/components/Card.js +0 -87
  94. package/dist/es2019/components/Spotlight.js +0 -39
  95. package/dist/es2019/components/SpotlightTarget.js +0 -14
  96. package/dist/es2019/styled/Blanket.js +0 -23
  97. package/dist/es2019/styled/Dialog.js +0 -51
  98. package/dist/es2019/styled/Modal.js +0 -40
  99. package/dist/es2019/styled/Target.js +0 -40
  100. package/dist/esm/components/Card.js +0 -78
  101. package/dist/esm/components/Spotlight.js +0 -64
  102. package/dist/esm/components/SpotlightTarget.js +0 -42
  103. package/dist/esm/styled/Blanket.js +0 -20
  104. package/dist/esm/styled/Dialog.js +0 -18
  105. package/dist/esm/styled/Modal.js +0 -16
  106. package/dist/esm/styled/Target.js +0 -29
  107. package/dist/types/components/Animation.d.ts +0 -8
  108. package/dist/types/components/Clone.d.ts +0 -27
  109. package/dist/types/components/Modal.d.ts +0 -25
  110. package/dist/types/components/Spotlight.d.ts +0 -59
  111. package/dist/types/components/SpotlightCard.d.ts +0 -38
  112. package/dist/types/components/SpotlightInner.d.ts +0 -30
  113. package/dist/types/components/SpotlightTarget.d.ts +0 -11
  114. package/dist/types/components/SpotlightTransition.d.ts +0 -27
  115. package/dist/types/components/ValueChanged.d.ts +0 -11
  116. package/dist/types/components/useSpotlight.d.ts +0 -3
  117. package/dist/types/styled/Blanket.d.ts +0 -7
  118. package/dist/types/styled/Dialog.d.ts +0 -12
  119. package/dist/types/styled/Modal.d.ts +0 -10
  120. package/dist/types/styled/Target.d.ts +0 -16
@@ -0,0 +1,131 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
3
+ /** @jsx jsx */
4
+ import React from 'react';
5
+ import { css, jsx } from '@emotion/core';
6
+ import Button from '@atlaskit/button/custom-theme-button';
7
+ import { createTheme, useGlobalTheme } from '@atlaskit/theme/components';
8
+ import { borderRadius, gridSize as getGridSize, layers } from '@atlaskit/theme/constants';
9
+ import { h600 } from '@atlaskit/theme/typography';
10
+ import { DialogActionItem, DialogActionItemContainer } from '../styled/dialog';
11
+ const gridSize = getGridSize(); // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
12
+
13
+ const lightH600Styles = css(h600({
14
+ theme: {
15
+ mode: 'light'
16
+ }
17
+ })); // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
18
+
19
+ const darkH600Styles = css(h600({
20
+ theme: {
21
+ mode: 'dark'
22
+ }
23
+ }));
24
+ const Container = /*#__PURE__*/React.forwardRef(({
25
+ children,
26
+ theme,
27
+ ...props
28
+ }, ref) => // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
29
+ jsx("div", _extends({
30
+ css: theme,
31
+ ref: ref
32
+ }, props), children));
33
+ const bodyStyles = css({
34
+ display: 'flex',
35
+ padding: `${gridSize * 2}px ${gridSize * 2.5}px`,
36
+ flexDirection: 'column'
37
+ }); // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
38
+
39
+ const headingStyles = css({
40
+ color: 'inherit'
41
+ });
42
+ const defaultHeaderStyles = css({
43
+ display: 'flex',
44
+ paddingBottom: `${gridSize}px`,
45
+ alignItems: 'baseline',
46
+ justifyContent: 'space-between'
47
+ });
48
+
49
+ const DefaultHeader = ({
50
+ children
51
+ }) => jsx("div", {
52
+ css: defaultHeaderStyles
53
+ }, children);
54
+
55
+ const defaultFooterStyles = css({
56
+ display: 'flex',
57
+ paddingTop: `${gridSize}px`,
58
+ alignItems: 'center',
59
+ justifyContent: 'space-between'
60
+ });
61
+
62
+ const DefaultFooter = ({
63
+ children
64
+ }) => jsx("div", {
65
+ css: defaultFooterStyles
66
+ }, children);
67
+
68
+ const Theme = createTheme(() => ({
69
+ container: {
70
+ overflow: 'auto',
71
+ borderRadius: `${borderRadius()}px`,
72
+ height: 'fit-content',
73
+ zIndex: `${layers.spotlight() + 1}`
74
+ }
75
+ }));
76
+ /**
77
+ * __Card__
78
+ *
79
+ * A card base for the spotlight card. The external `SpotlightCard` wraps this component.
80
+ *
81
+ * @internal
82
+ */
83
+
84
+ const Card = /*#__PURE__*/React.forwardRef(({
85
+ actions = [],
86
+ actionsBeforeElement,
87
+ children,
88
+ components = {},
89
+ image,
90
+ heading,
91
+ headingAfterElement,
92
+ theme,
93
+ testId
94
+ }, ref) => {
95
+ const {
96
+ Header = DefaultHeader,
97
+ Footer = DefaultFooter
98
+ } = components;
99
+ const {
100
+ mode
101
+ } = useGlobalTheme();
102
+ return jsx(Theme.Provider, {
103
+ value: theme
104
+ }, jsx(Theme.Consumer, null, ({
105
+ container
106
+ }) => {
107
+ return (// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
108
+ jsx(Container, {
109
+ theme: container,
110
+ ref: ref,
111
+ "data-testid": testId
112
+ }, typeof image === 'string' ? jsx("img", {
113
+ src: image,
114
+ alt: ""
115
+ }) : image, jsx("div", {
116
+ css: bodyStyles
117
+ }, heading || headingAfterElement ? jsx(Header, null, jsx("h4", {
118
+ css: [mode === 'light' ? lightH600Styles : darkH600Styles, headingStyles]
119
+ }, heading), headingAfterElement) : null, children, actions.length > 0 || actionsBeforeElement ? jsx(Footer, null, actionsBeforeElement || jsx("span", null), jsx(DialogActionItemContainer, null, actions.map(({
120
+ text,
121
+ key,
122
+ ...rest
123
+ }, idx) => {
124
+ return jsx(DialogActionItem, {
125
+ key: key || (typeof text === 'string' ? text : `${idx}`)
126
+ }, jsx(Button, rest, text));
127
+ }))) : null))
128
+ );
129
+ }));
130
+ });
131
+ export default Card;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { TargetInner, TargetOverlay } from '../styled/Target';
2
+ import { TargetInner, TargetOverlay } from '../styled/target';
3
3
 
4
4
  function cloneAndOverrideStyles(node) {
5
5
  const shouldCloneChildren = true;
@@ -11,6 +11,15 @@ function cloneAndOverrideStyles(node) {
11
11
  clonedNode.style.transform = 'translate(0, 0) translate3d(0, 0, 0)';
12
12
  return clonedNode;
13
13
  }
14
+ /**
15
+ * __Clone__
16
+ *
17
+ * Used for cloning spotlight targets. The clone is positioned on top of the spotlight target with
18
+ * a pulsing animation.
19
+ *
20
+ * @internal
21
+ */
22
+
14
23
 
15
24
  const Clone = props => {
16
25
  const {
@@ -1,9 +1,9 @@
1
- import Modal from './Modal';
2
- import Spotlight from './Spotlight';
3
- import SpotlightCard from './SpotlightCard';
4
- import SpotlightManager from './SpotlightManager';
5
- import SpotlightTarget from './SpotlightTarget';
6
- import SpotlightTransition from './SpotlightTransition';
7
- import useSpotlight from './useSpotlight';
1
+ import Modal from './modal';
2
+ import Spotlight from './spotlight';
3
+ import SpotlightCard from './spotlight-card';
4
+ import SpotlightManager from './spotlight-manager';
5
+ import SpotlightTarget from './spotlight-target';
6
+ import SpotlightTransition from './spotlight-transition';
7
+ import useSpotlight from './use-spotlight';
8
8
  export { spotlightButtonTheme, modalButtonTheme } from './theme';
9
9
  export { Modal, Spotlight, SpotlightCard, SpotlightManager, SpotlightTarget, SpotlightTransition, useSpotlight };
@@ -1,12 +1,24 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import React, { Component } from 'react';
3
+
4
+ /** @jsx jsx */
5
+ import { Component } from 'react';
6
+ import { jsx } from '@emotion/core';
4
7
  import Button, { Theme as ButtonTheme } from '@atlaskit/button/custom-theme-button';
5
- import Modal from '@atlaskit/modal-dialog';
6
- import { ActionItem, Body, Heading, Image, Actions as ModalActions } from '../styled/Modal';
7
- import { modalButtonTheme } from './theme';
8
+ import Modal, { ModalBody } from '@atlaskit/modal-dialog';
9
+ import { ModalBody as Body, ModalHeading as Heading, ModalActionContainer, ModalActionItem, ModalImage } from '../styled/modal';
10
+ import { modalButtonTheme } from './theme'; // TODO: DSP-1250 - use a composable API consistent with normal modal dialog
8
11
 
9
12
  function noop() {}
13
+ /**
14
+ * __Onboarding modal__
15
+ *
16
+ * If the product change is large enough,
17
+ * this component can be used to outline the benefits of the change to the user.
18
+ *
19
+ * - [Examples](https://atlaskit.atlassian.com/packages/design-system/onboarding)
20
+ */
21
+
10
22
 
11
23
  export default class OnboardingModal extends Component {
12
24
  constructor(...args) {
@@ -18,9 +30,9 @@ export default class OnboardingModal extends Component {
18
30
  image: src
19
31
  } = props;
20
32
 
21
- const ImageElement = () => /*#__PURE__*/React.createElement(Image, {
22
- alt: "",
23
- src: src
33
+ const ImageElement = () => jsx(ModalImage, {
34
+ src: src,
35
+ alt: ""
24
36
  });
25
37
 
26
38
  return HeaderElement || ImageElement;
@@ -33,9 +45,9 @@ export default class OnboardingModal extends Component {
33
45
  experimental_shouldShowPrimaryButtonOnRight = false
34
46
  } = props;
35
47
 
36
- const ActionsElement = () => actionList ? /*#__PURE__*/React.createElement(ButtonTheme.Provider, {
48
+ const ActionsElement = () => actionList ? jsx(ButtonTheme.Provider, {
37
49
  value: modalButtonTheme
38
- }, /*#__PURE__*/React.createElement(ModalActions, {
50
+ }, jsx(ModalActionContainer, {
39
51
  shouldReverseButtonOrder: experimental_shouldShowPrimaryButtonOnRight
40
52
  }, actionList.map(({
41
53
  text,
@@ -43,9 +55,9 @@ export default class OnboardingModal extends Component {
43
55
  ...rest
44
56
  }, idx) => {
45
57
  const variant = idx ? 'subtle-link' : 'primary';
46
- return /*#__PURE__*/React.createElement(ActionItem, {
58
+ return jsx(ModalActionItem, {
47
59
  key: key || (typeof text === 'string' ? text : `${idx}`)
48
- }, /*#__PURE__*/React.createElement(Button, _extends({
60
+ }, jsx(Button, _extends({
49
61
  appearance: variant,
50
62
  autoFocus: !idx
51
63
  }, rest), text));
@@ -62,17 +74,15 @@ export default class OnboardingModal extends Component {
62
74
  heading,
63
75
  ...props
64
76
  } = this.props;
65
- return /*#__PURE__*/React.createElement(Modal, _extends({
77
+ const Header = this.headerComponent(this.props);
78
+ const Footer = this.footerComponent(this.props);
79
+ return jsx(Modal, _extends({
66
80
  autoFocus: true,
67
- components: {
68
- Header: this.headerComponent(this.props),
69
- Footer: this.footerComponent(this.props)
70
- },
71
81
  onClose: noop,
72
- scrollBehavior: "outside",
82
+ shouldScrollInViewport: true,
73
83
  shouldCloseOnOverlayClick: false,
74
84
  shouldCloseOnEscapePress: false
75
- }, props), /*#__PURE__*/React.createElement(Body, null, heading && /*#__PURE__*/React.createElement(Heading, null, heading), children));
85
+ }, props), jsx(Header, null), jsx(ModalBody, null, jsx(Body, null, heading && jsx(Heading, null, heading), children)), jsx(Footer, null));
76
86
  }
77
87
 
78
88
  }
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React from 'react';
4
4
  import { Theme as ButtonTheme } from '@atlaskit/button/custom-theme-button';
5
5
  import { N0, N50A, N60A, P300 } from '@atlaskit/theme/colors';
6
- import Card from './Card';
6
+ import Card from './card';
7
7
  import { spotlightButtonTheme } from './theme';
8
8
 
9
9
  class SpotlightCard extends React.Component {
@@ -32,7 +32,8 @@ class SpotlightCard extends React.Component {
32
32
  actions: actions,
33
33
  actionsBeforeElement: actionsBeforeElement,
34
34
  components: components,
35
- image: image,
35
+ image: image // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
36
+ ,
36
37
  theme: parent => {
37
38
  const {
38
39
  container,
@@ -53,6 +54,12 @@ class SpotlightCard extends React.Component {
53
54
  }
54
55
 
55
56
  }
57
+ /**
58
+ * __Spotlight card__
59
+ *
60
+ * - [Examples](https://atlaskit.atlassian.com/packages/design-system/onboarding)
61
+ */
62
+
56
63
 
57
64
  _defineProperty(SpotlightCard, "defaultProps", {
58
65
  width: 400,
@@ -3,11 +3,11 @@ import React, { Component } from 'react';
3
3
  import FocusLock from 'react-focus-lock';
4
4
  import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
5
5
  import { Popper } from '@atlaskit/popper';
6
- import { Image } from '../styled/Dialog';
7
- import SpotlightCard from './SpotlightCard';
8
- import ValueChanged from './ValueChanged';
6
+ import { DialogImage } from '../styled/dialog';
7
+ import SpotlightCard from './spotlight-card';
8
+ import ValueChanged from './value-changed';
9
9
  const packageName = "@atlaskit/onboarding";
10
- const packageVersion = "10.2.2";
10
+ const packageVersion = "10.2.6";
11
11
 
12
12
  class SpotlightDialog extends Component {
13
13
  constructor(...args) {
@@ -94,7 +94,8 @@ class SpotlightDialog extends Component {
94
94
  autoFocus: true
95
95
  }, /*#__PURE__*/React.createElement(SpotlightCard, {
96
96
  ref: ref,
97
- testId: testId,
97
+ testId: testId // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
98
+ ,
98
99
  theme: parent => {
99
100
  const {
100
101
  container,
@@ -110,7 +111,7 @@ class SpotlightDialog extends Component {
110
111
  width: dialogWidth,
111
112
  actions: actions,
112
113
  actionsBeforeElement: actionsBeforeElement,
113
- image: image && /*#__PURE__*/React.createElement(Image, {
114
+ image: image && /*#__PURE__*/React.createElement(DialogImage, {
114
115
  alt: heading,
115
116
  src: image
116
117
  }),
@@ -8,11 +8,18 @@ import scrollIntoView from 'scroll-into-view-if-needed';
8
8
  import Portal from '@atlaskit/portal';
9
9
  import { layers } from '@atlaskit/theme/constants';
10
10
  import { ElementBox } from '../utils/use-element-box';
11
- import { Fade } from './Animation';
12
- import Clone from './Clone';
13
- import SpotlightDialog from './SpotlightDialog';
14
- import { SpotlightTransitionConsumer } from './SpotlightTransition';
11
+ import { Fade } from './animation';
12
+ import Clone from './clone';
13
+ import SpotlightDialog from './spotlight-dialog';
14
+ import { SpotlightTransitionConsumer } from './spotlight-transition';
15
15
 
16
+ /**
17
+ * __Spotlight inner__
18
+ *
19
+ * Renders the spotlight target clone and dialog.
20
+ *
21
+ * @internal
22
+ */
16
23
  class SpotlightInner extends React.Component {
17
24
  constructor(...args) {
18
25
  super(...args);
@@ -94,7 +101,7 @@ class SpotlightInner extends React.Component {
94
101
  targetOnClick: targetOnClick,
95
102
  targetRadius: targetRadius
96
103
  })), TargetReplacement && !replacementElement ? null : /*#__PURE__*/React.createElement(Fade, {
97
- in: isOpen,
104
+ hasEntered: isOpen,
98
105
  onExited: onExited
99
106
  }, animationStyles => /*#__PURE__*/React.createElement(SpotlightDialog, {
100
107
  testId: `${testId}--dialog`,
@@ -3,8 +3,8 @@ import React, { createContext, PureComponent } from 'react';
3
3
  import memoizeOne from 'memoize-one';
4
4
  import Portal from '@atlaskit/portal';
5
5
  import { layers } from '@atlaskit/theme/constants';
6
- import Blanket from '../styled/Blanket';
7
- import { Fade } from './Animation';
6
+ import Blanket from '../styled/blanket';
7
+ import { Fade } from './animation';
8
8
 
9
9
  const noop = () => {};
10
10
 
@@ -28,6 +28,14 @@ const Container = ({
28
28
  component: Wrapper,
29
29
  children
30
30
  }) => /*#__PURE__*/React.createElement(Wrapper, null, children);
31
+ /**
32
+ * __Spotlight manager__
33
+ *
34
+ * Wraps usage of spotlight and manages progression through multiple spotlights.
35
+ *
36
+ * - [Examples](https://atlaskit.atlassian.com/packages/design-system/onboarding)
37
+ */
38
+
31
39
 
32
40
  export default class SpotlightManager extends PureComponent {
33
41
  constructor(...args) {
@@ -87,7 +95,7 @@ export default class SpotlightManager extends PureComponent {
87
95
  }, /*#__PURE__*/React.createElement(Container, {
88
96
  component: Tag || React.Fragment
89
97
  }, /*#__PURE__*/React.createElement(Fade, {
90
- in: this.state.spotlightCount > 0
98
+ hasEntered: this.state.spotlightCount > 0
91
99
  }, animationStyles => /*#__PURE__*/React.createElement(Portal, {
92
100
  zIndex: layers.spotlight()
93
101
  }, /*#__PURE__*/React.createElement(Blanket, {
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import NodeResolver from 'react-node-resolver';
3
+ import { TargetConsumer } from './spotlight-manager';
4
+
5
+ /**
6
+ * __Spotlight target__
7
+ *
8
+ * Wraps an element, allowing it to be targeted by a spotlight.
9
+ *
10
+ * - [Examples](https://atlaskit.atlassian.com/packages/design-system/onboarding)
11
+ */
12
+ const SpotlightTarget = ({
13
+ children,
14
+ name
15
+ }) => /*#__PURE__*/React.createElement(TargetConsumer, null, targetRef => targetRef ? /*#__PURE__*/React.createElement(NodeResolver, {
16
+ innerRef: targetRef(name)
17
+ }, children) : children);
18
+
19
+ export default SpotlightTarget;
@@ -1,13 +1,21 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React, { createContext } from 'react';
3
- const TransitionContext = /*#__PURE__*/createContext({
3
+ const SpotlightTransitionContext = /*#__PURE__*/createContext({
4
4
  isOpen: true,
5
5
  onExited: () => {}
6
6
  }); // checks if children exist and are truthy
7
7
 
8
8
  const hasChildren = children => React.Children.count(children) > 0 && React.Children.map(children, child => !!child).filter(Boolean).length > 0;
9
+ /**
10
+ * __Spotlight transition__
11
+ *
12
+ * Provides context used for fading animations.
13
+ *
14
+ * - [Examples](https://atlaskit.atlassian.com/packages/design-system/onboarding)
15
+ */
9
16
 
10
- class Transition extends React.Component {
17
+
18
+ class SpotlightTransition extends React.Component {
11
19
  constructor(...args) {
12
20
  super(...args);
13
21
 
@@ -33,7 +41,7 @@ class Transition extends React.Component {
33
41
  }
34
42
 
35
43
  render() {
36
- return /*#__PURE__*/React.createElement(TransitionContext.Provider, {
44
+ return /*#__PURE__*/React.createElement(SpotlightTransitionContext.Provider, {
37
45
  value: {
38
46
  onExited: this.onExited,
39
47
  isOpen: hasChildren(this.props.children)
@@ -42,6 +50,14 @@ class Transition extends React.Component {
42
50
  }
43
51
 
44
52
  }
53
+ /**
54
+ * __Spotlight transition consumer__
55
+ *
56
+ * Used to consume the spotlight transition context through render props.
57
+ *
58
+ * @internal
59
+ */
60
+
45
61
 
46
- export const SpotlightTransitionConsumer = TransitionContext.Consumer;
47
- export default Transition;
62
+ export const SpotlightTransitionConsumer = SpotlightTransitionContext.Consumer;
63
+ export default SpotlightTransition;
@@ -0,0 +1,40 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import SpotlightInner from './spotlight-inner';
4
+ import { SpotlightConsumer } from './spotlight-manager';
5
+
6
+ /**
7
+ * __Spotlight__
8
+ *
9
+ * A spotlight gives visual focus to an element and is paired with a dialog.
10
+ *
11
+ * Spotlights are used for onboarding and can be connected to create a tour.
12
+ *
13
+ * - [Examples](https://atlaskit.atlassian.com/packages/design-system/onboarding)
14
+ */
15
+ const Spotlight = ({
16
+ dialogWidth = 400,
17
+ pulse = true,
18
+ testId = 'spotlight',
19
+ targetNode,
20
+ target,
21
+ ...rest
22
+ }) => /*#__PURE__*/React.createElement(SpotlightConsumer, null, ({
23
+ opened,
24
+ closed,
25
+ targets
26
+ }) => {
27
+ // use the targetNode prop or try get the target from context targets using name
28
+ const actualTargetNode = targetNode || (typeof target === 'string' ? targets[target] : undefined);
29
+ return actualTargetNode ? /*#__PURE__*/React.createElement(SpotlightInner, _extends({}, rest, {
30
+ targetNode: actualTargetNode,
31
+ target: target,
32
+ onOpened: opened,
33
+ onClosed: closed,
34
+ testId: testId,
35
+ dialogWidth: dialogWidth,
36
+ pulse: pulse
37
+ })) : null;
38
+ });
39
+
40
+ export default Spotlight;
@@ -1,5 +1,15 @@
1
1
  import { useCallback, useContext, useEffect, useMemo, useRef } from 'react';
2
- import { SpotlightContext } from './SpotlightManager';
2
+ import { SpotlightContext } from './spotlight-manager';
3
+ /**
4
+ * Enables advanced usage of spotlights.
5
+ *
6
+ * Provides the following methods:
7
+ * - `isTargetRendered`
8
+ *
9
+ * Checks if the given spotlight target is currently
10
+ * being rendered.
11
+ */
12
+
3
13
  export default function useSpotlight() {
4
14
  const {
5
15
  targets
@@ -1,2 +1,2 @@
1
1
  export { Modal, Spotlight, SpotlightCard, SpotlightManager, SpotlightTarget, SpotlightTransition, modalButtonTheme, spotlightButtonTheme, useSpotlight } from './components';
2
- export { Pulse as SpotlightPulse } from './styled/Target';
2
+ export { Pulse as SpotlightPulse } from './styled/target';
@@ -0,0 +1,45 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/core';
3
+ import { DN90A, N100A } from '@atlaskit/theme/colors';
4
+ import { themed, useGlobalTheme } from '@atlaskit/theme/components';
5
+ import { layers } from '@atlaskit/theme/constants';
6
+ const backgroundColor = themed({
7
+ light: N100A,
8
+ dark: DN90A
9
+ }); // IE11 and Edge: z-index needed because fixed position calculates z-index relative
10
+ // to body instead of nearest stacking context (Portal in our case).
11
+
12
+ const blanketStyles = css({
13
+ position: 'fixed',
14
+ zIndex: layers.spotlight(),
15
+ top: 0,
16
+ right: 0,
17
+ bottom: 0,
18
+ left: 0,
19
+ transition: 'opacity 220ms'
20
+ });
21
+
22
+ /**
23
+ * __Blanket__
24
+ *
25
+ * A replacement for `@atlaskit/blanket`.
26
+ *
27
+ * We use this for spotlights instead of `@atlaskit/blanket`
28
+ * because spotlights must sit on top of other layered elements,
29
+ * such as modals, which have their own blankets.
30
+ *
31
+ * @internal
32
+ */
33
+ const Blanket = props => {
34
+ const theme = useGlobalTheme();
35
+ return jsx("div", {
36
+ css: blanketStyles,
37
+ style: { ...props.style,
38
+ backgroundColor: props.isTinted ? backgroundColor({
39
+ theme
40
+ }) : 'transparent'
41
+ }
42
+ });
43
+ };
44
+
45
+ export default Blanket;
@@ -0,0 +1,62 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
3
+ /** @jsx jsx */
4
+ import { css, jsx } from '@emotion/core';
5
+ import { gridSize as getGridSize } from '@atlaskit/theme/constants';
6
+ const gridSize = getGridSize();
7
+ const imageStyles = css({
8
+ maxWidth: '100%',
9
+ height: 'auto'
10
+ });
11
+ const actionItemContainerStyles = css({
12
+ display: 'flex',
13
+ margin: `0 -${gridSize / 2}px`,
14
+
15
+ /* When there is more than one action, place primary action visually on the
16
+ right, but keep it's position as the first focusable element in the DOM */
17
+ flexDirection: 'row-reverse'
18
+ });
19
+ const actionItemStyles = css({
20
+ margin: `0 ${gridSize / 2}px`
21
+ });
22
+ /**
23
+ * __Dialog image__
24
+ *
25
+ * An optional header image in spotlight dialogs.
26
+ *
27
+ * @internal
28
+ */
29
+
30
+ export const DialogImage = ({
31
+ alt,
32
+ ...props
33
+ }) => jsx("img", _extends({
34
+ css: imageStyles,
35
+ alt: alt
36
+ }, props));
37
+ /**
38
+ * __Dialog action item container__
39
+ *
40
+ * Flex wrapper around dialog action items.
41
+ *
42
+ * @internal
43
+ */
44
+
45
+ export const DialogActionItemContainer = ({
46
+ children
47
+ }) => jsx("div", {
48
+ css: actionItemContainerStyles
49
+ }, children);
50
+ /**
51
+ * __Dialog action item__
52
+ *
53
+ * Action items shown inside of the dialog.
54
+ *
55
+ * @internal
56
+ */
57
+
58
+ export const DialogActionItem = ({
59
+ children
60
+ }) => jsx("div", {
61
+ css: actionItemStyles
62
+ }, children);