@atlaskit/onboarding 12.1.9 → 12.2.1
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 +23 -0
- package/dist/cjs/components/node-resolver-spotlight-target.js +7 -6
- package/dist/cjs/components/spotlight-inner.js +1 -1
- package/dist/cjs/components/spotlight-manager.js +2 -2
- package/dist/cjs/components/spotlight-target.js +8 -3
- package/dist/es2019/components/node-resolver-spotlight-target.js +7 -6
- package/dist/es2019/components/spotlight-inner.js +1 -1
- package/dist/es2019/components/spotlight-manager.js +2 -2
- package/dist/es2019/components/spotlight-target.js +12 -5
- package/dist/esm/components/node-resolver-spotlight-target.js +7 -6
- package/dist/esm/components/spotlight-inner.js +1 -1
- package/dist/esm/components/spotlight-manager.js +2 -2
- package/dist/esm/components/spotlight-target.js +8 -3
- package/dist/types/components/node-resolver-spotlight-target.d.ts +3 -3
- package/dist/types/components/spotlight-manager.d.ts +12 -2
- package/dist/types/components/spotlight-target.d.ts +24 -1
- package/dist/types-ts4.5/components/node-resolver-spotlight-target.d.ts +3 -3
- package/dist/types-ts4.5/components/spotlight-manager.d.ts +12 -2
- package/dist/types-ts4.5/components/spotlight-target.d.ts +24 -1
- package/package.json +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/onboarding
|
|
2
2
|
|
|
3
|
+
## 12.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 12.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#176005](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/176005)
|
|
14
|
+
[`a7f4659856234`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a7f4659856234) -
|
|
15
|
+
Adds optional render prop API to `SpotlightTarget` component. You can now use a function as the
|
|
16
|
+
children of `SpotlightTarget` and explicitly connect the `targetRef` to your component. This
|
|
17
|
+
provides fine-grained control over which element is cloned and avoids the need for a wrapping div
|
|
18
|
+
element.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [#176005](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/176005)
|
|
23
|
+
[`3f689d259d12e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f689d259d12e) -
|
|
24
|
+
GA layering into spotlight
|
|
25
|
+
|
|
3
26
|
## 12.1.9
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -24,27 +24,28 @@ var spanStyles = (0, _react2.css)({
|
|
|
24
24
|
* @param {boolean} props.hasNodeResolver - Determines whether to apply the NodeResolver.
|
|
25
25
|
* @param {ReactElement} props.children - The child elements to be wrapped.
|
|
26
26
|
* @param {string} props.name - The name to reference from Spotlight.
|
|
27
|
-
* @param {ReactElement} props.
|
|
27
|
+
* @param {ReactElement} props.getTargetRef - Setting up Target Node in Spotlight Manager.
|
|
28
28
|
* @returns {ReactElement} The children wrapped with NodeResolver if hasNodeResolver is true, wrape the children in a div setting innerRef with ref to the div.
|
|
29
29
|
*/
|
|
30
30
|
var NodeResolverSpotlightTarget = function NodeResolverSpotlightTarget(_ref) {
|
|
31
31
|
var hasNodeResolver = _ref.hasNodeResolver,
|
|
32
32
|
children = _ref.children,
|
|
33
|
-
|
|
33
|
+
getTargetRef = _ref.getTargetRef,
|
|
34
34
|
name = _ref.name;
|
|
35
35
|
var divRef = (0, _react.useRef)(null);
|
|
36
36
|
(0, _react.useEffect)(function () {
|
|
37
|
+
var targetRef = getTargetRef(name);
|
|
37
38
|
if (!hasNodeResolver) {
|
|
38
39
|
var _divRef$current;
|
|
39
|
-
targetRef(
|
|
40
|
+
targetRef((_divRef$current = divRef.current) === null || _divRef$current === void 0 ? void 0 : _divRef$current.firstElementChild);
|
|
40
41
|
}
|
|
41
42
|
return function () {
|
|
42
|
-
!hasNodeResolver && targetRef(
|
|
43
|
+
!hasNodeResolver && targetRef(undefined);
|
|
43
44
|
};
|
|
44
|
-
}, [hasNodeResolver, name,
|
|
45
|
+
}, [hasNodeResolver, name, getTargetRef]);
|
|
45
46
|
if (hasNodeResolver) {
|
|
46
47
|
return (0, _react2.jsx)(_reactNodeResolver.default, {
|
|
47
|
-
innerRef:
|
|
48
|
+
innerRef: getTargetRef(name)
|
|
48
49
|
}, children);
|
|
49
50
|
}
|
|
50
51
|
return (0, _react2.jsx)("span", {
|
|
@@ -156,7 +156,7 @@ var SpotlightInner = /*#__PURE__*/function (_React$Component) {
|
|
|
156
156
|
onExited: onExited
|
|
157
157
|
}, function (animationStyles) {
|
|
158
158
|
return /*#__PURE__*/_react.default.createElement(_layering.Layering, {
|
|
159
|
-
isDisabled:
|
|
159
|
+
isDisabled: false
|
|
160
160
|
}, /*#__PURE__*/_react.default.createElement(_spotlightDialog.default, {
|
|
161
161
|
testId: "".concat(testId, "--dialog"),
|
|
162
162
|
actions: _this2.props.actions,
|
|
@@ -66,7 +66,7 @@ var SpotlightManager = exports.default = /*#__PURE__*/function (_PureComponent)
|
|
|
66
66
|
spotlightCount: 0,
|
|
67
67
|
targets: {}
|
|
68
68
|
});
|
|
69
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
69
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getTargetRef", function (name) {
|
|
70
70
|
return function (element) {
|
|
71
71
|
_this.setState(function (state) {
|
|
72
72
|
return {
|
|
@@ -119,7 +119,7 @@ var SpotlightManager = exports.default = /*#__PURE__*/function (_PureComponent)
|
|
|
119
119
|
return /*#__PURE__*/_react.default.createElement(SpotlightStateProvider, {
|
|
120
120
|
value: this.getStateProviderValue(this.state.targets)
|
|
121
121
|
}, /*#__PURE__*/_react.default.createElement(TargetProvider, {
|
|
122
|
-
value: this.
|
|
122
|
+
value: this.getTargetRef
|
|
123
123
|
}, /*#__PURE__*/_react.default.createElement(Container, {
|
|
124
124
|
component: Tag || _react.default.Fragment
|
|
125
125
|
}, /*#__PURE__*/_react.default.createElement(_animation.Fade, {
|
|
@@ -21,11 +21,16 @@ var _spotlightManager = require("./spotlight-manager");
|
|
|
21
21
|
var SpotlightTarget = function SpotlightTarget(_ref) {
|
|
22
22
|
var children = _ref.children,
|
|
23
23
|
name = _ref.name;
|
|
24
|
-
return /*#__PURE__*/_react.default.createElement(_spotlightManager.TargetConsumer, null, function (
|
|
25
|
-
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_spotlightManager.TargetConsumer, null, function (getTargetRef) {
|
|
25
|
+
if (typeof children === 'function') {
|
|
26
|
+
return children({
|
|
27
|
+
targetRef: getTargetRef === null || getTargetRef === void 0 ? void 0 : getTargetRef(name)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return getTargetRef ? /*#__PURE__*/_react.default.createElement(_nodeResolverSpotlightTarget.default, {
|
|
26
31
|
name: name,
|
|
27
32
|
hasNodeResolver: !(0, _platformFeatureFlags.fg)('platform_design_system_team_onboarding_noderesolve'),
|
|
28
|
-
|
|
33
|
+
getTargetRef: getTargetRef
|
|
29
34
|
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children)) : children;
|
|
30
35
|
});
|
|
31
36
|
};
|
|
@@ -16,28 +16,29 @@ const spanStyles = css({
|
|
|
16
16
|
* @param {boolean} props.hasNodeResolver - Determines whether to apply the NodeResolver.
|
|
17
17
|
* @param {ReactElement} props.children - The child elements to be wrapped.
|
|
18
18
|
* @param {string} props.name - The name to reference from Spotlight.
|
|
19
|
-
* @param {ReactElement} props.
|
|
19
|
+
* @param {ReactElement} props.getTargetRef - Setting up Target Node in Spotlight Manager.
|
|
20
20
|
* @returns {ReactElement} The children wrapped with NodeResolver if hasNodeResolver is true, wrape the children in a div setting innerRef with ref to the div.
|
|
21
21
|
*/
|
|
22
22
|
const NodeResolverSpotlightTarget = ({
|
|
23
23
|
hasNodeResolver,
|
|
24
24
|
children,
|
|
25
|
-
|
|
25
|
+
getTargetRef,
|
|
26
26
|
name
|
|
27
27
|
}) => {
|
|
28
28
|
const divRef = useRef(null);
|
|
29
29
|
useEffect(() => {
|
|
30
|
+
const targetRef = getTargetRef(name);
|
|
30
31
|
if (!hasNodeResolver) {
|
|
31
32
|
var _divRef$current;
|
|
32
|
-
targetRef(
|
|
33
|
+
targetRef((_divRef$current = divRef.current) === null || _divRef$current === void 0 ? void 0 : _divRef$current.firstElementChild);
|
|
33
34
|
}
|
|
34
35
|
return () => {
|
|
35
|
-
!hasNodeResolver && targetRef(
|
|
36
|
+
!hasNodeResolver && targetRef(undefined);
|
|
36
37
|
};
|
|
37
|
-
}, [hasNodeResolver, name,
|
|
38
|
+
}, [hasNodeResolver, name, getTargetRef]);
|
|
38
39
|
if (hasNodeResolver) {
|
|
39
40
|
return jsx(NodeResolver, {
|
|
40
|
-
innerRef:
|
|
41
|
+
innerRef: getTargetRef(name)
|
|
41
42
|
}, children);
|
|
42
43
|
}
|
|
43
44
|
return jsx("span", {
|
|
@@ -121,7 +121,7 @@ class SpotlightInner extends React.Component {
|
|
|
121
121
|
hasEntered: isOpen,
|
|
122
122
|
onExited: onExited
|
|
123
123
|
}, animationStyles => /*#__PURE__*/React.createElement(Layering, {
|
|
124
|
-
isDisabled:
|
|
124
|
+
isDisabled: false
|
|
125
125
|
}, /*#__PURE__*/React.createElement(SpotlightDialog, {
|
|
126
126
|
testId: `${testId}--dialog`,
|
|
127
127
|
actions: this.props.actions,
|
|
@@ -43,7 +43,7 @@ export default class SpotlightManager extends PureComponent {
|
|
|
43
43
|
spotlightCount: 0,
|
|
44
44
|
targets: {}
|
|
45
45
|
});
|
|
46
|
-
_defineProperty(this, "
|
|
46
|
+
_defineProperty(this, "getTargetRef", name => element => {
|
|
47
47
|
this.setState(state => ({
|
|
48
48
|
targets: {
|
|
49
49
|
...state.targets,
|
|
@@ -85,7 +85,7 @@ export default class SpotlightManager extends PureComponent {
|
|
|
85
85
|
return /*#__PURE__*/React.createElement(SpotlightStateProvider, {
|
|
86
86
|
value: this.getStateProviderValue(this.state.targets)
|
|
87
87
|
}, /*#__PURE__*/React.createElement(TargetProvider, {
|
|
88
|
-
value: this.
|
|
88
|
+
value: this.getTargetRef
|
|
89
89
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
90
90
|
component: Tag || React.Fragment
|
|
91
91
|
}, /*#__PURE__*/React.createElement(Fade, {
|
|
@@ -14,9 +14,16 @@ import { TargetConsumer } from './spotlight-manager';
|
|
|
14
14
|
const SpotlightTarget = ({
|
|
15
15
|
children,
|
|
16
16
|
name
|
|
17
|
-
}) => /*#__PURE__*/React.createElement(TargetConsumer, null,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
17
|
+
}) => /*#__PURE__*/React.createElement(TargetConsumer, null, getTargetRef => {
|
|
18
|
+
if (typeof children === 'function') {
|
|
19
|
+
return children({
|
|
20
|
+
targetRef: getTargetRef === null || getTargetRef === void 0 ? void 0 : getTargetRef(name)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return getTargetRef ? /*#__PURE__*/React.createElement(NodeResolverSpotlightTarget, {
|
|
24
|
+
name: name,
|
|
25
|
+
hasNodeResolver: !fg('platform_design_system_team_onboarding_noderesolve'),
|
|
26
|
+
getTargetRef: getTargetRef
|
|
27
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, children)) : children;
|
|
28
|
+
});
|
|
22
29
|
export default SpotlightTarget;
|
|
@@ -16,27 +16,28 @@ var spanStyles = css({
|
|
|
16
16
|
* @param {boolean} props.hasNodeResolver - Determines whether to apply the NodeResolver.
|
|
17
17
|
* @param {ReactElement} props.children - The child elements to be wrapped.
|
|
18
18
|
* @param {string} props.name - The name to reference from Spotlight.
|
|
19
|
-
* @param {ReactElement} props.
|
|
19
|
+
* @param {ReactElement} props.getTargetRef - Setting up Target Node in Spotlight Manager.
|
|
20
20
|
* @returns {ReactElement} The children wrapped with NodeResolver if hasNodeResolver is true, wrape the children in a div setting innerRef with ref to the div.
|
|
21
21
|
*/
|
|
22
22
|
var NodeResolverSpotlightTarget = function NodeResolverSpotlightTarget(_ref) {
|
|
23
23
|
var hasNodeResolver = _ref.hasNodeResolver,
|
|
24
24
|
children = _ref.children,
|
|
25
|
-
|
|
25
|
+
getTargetRef = _ref.getTargetRef,
|
|
26
26
|
name = _ref.name;
|
|
27
27
|
var divRef = useRef(null);
|
|
28
28
|
useEffect(function () {
|
|
29
|
+
var targetRef = getTargetRef(name);
|
|
29
30
|
if (!hasNodeResolver) {
|
|
30
31
|
var _divRef$current;
|
|
31
|
-
targetRef(
|
|
32
|
+
targetRef((_divRef$current = divRef.current) === null || _divRef$current === void 0 ? void 0 : _divRef$current.firstElementChild);
|
|
32
33
|
}
|
|
33
34
|
return function () {
|
|
34
|
-
!hasNodeResolver && targetRef(
|
|
35
|
+
!hasNodeResolver && targetRef(undefined);
|
|
35
36
|
};
|
|
36
|
-
}, [hasNodeResolver, name,
|
|
37
|
+
}, [hasNodeResolver, name, getTargetRef]);
|
|
37
38
|
if (hasNodeResolver) {
|
|
38
39
|
return jsx(NodeResolver, {
|
|
39
|
-
innerRef:
|
|
40
|
+
innerRef: getTargetRef(name)
|
|
40
41
|
}, children);
|
|
41
42
|
}
|
|
42
43
|
return jsx("span", {
|
|
@@ -149,7 +149,7 @@ var SpotlightInner = /*#__PURE__*/function (_React$Component) {
|
|
|
149
149
|
onExited: onExited
|
|
150
150
|
}, function (animationStyles) {
|
|
151
151
|
return /*#__PURE__*/React.createElement(Layering, {
|
|
152
|
-
isDisabled:
|
|
152
|
+
isDisabled: false
|
|
153
153
|
}, /*#__PURE__*/React.createElement(SpotlightDialog, {
|
|
154
154
|
testId: "".concat(testId, "--dialog"),
|
|
155
155
|
actions: _this2.props.actions,
|
|
@@ -58,7 +58,7 @@ var SpotlightManager = /*#__PURE__*/function (_PureComponent) {
|
|
|
58
58
|
spotlightCount: 0,
|
|
59
59
|
targets: {}
|
|
60
60
|
});
|
|
61
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
61
|
+
_defineProperty(_assertThisInitialized(_this), "getTargetRef", function (name) {
|
|
62
62
|
return function (element) {
|
|
63
63
|
_this.setState(function (state) {
|
|
64
64
|
return {
|
|
@@ -111,7 +111,7 @@ var SpotlightManager = /*#__PURE__*/function (_PureComponent) {
|
|
|
111
111
|
return /*#__PURE__*/React.createElement(SpotlightStateProvider, {
|
|
112
112
|
value: this.getStateProviderValue(this.state.targets)
|
|
113
113
|
}, /*#__PURE__*/React.createElement(TargetProvider, {
|
|
114
|
-
value: this.
|
|
114
|
+
value: this.getTargetRef
|
|
115
115
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
116
116
|
component: Tag || React.Fragment
|
|
117
117
|
}, /*#__PURE__*/React.createElement(Fade, {
|
|
@@ -14,11 +14,16 @@ import { TargetConsumer } from './spotlight-manager';
|
|
|
14
14
|
var SpotlightTarget = function SpotlightTarget(_ref) {
|
|
15
15
|
var children = _ref.children,
|
|
16
16
|
name = _ref.name;
|
|
17
|
-
return /*#__PURE__*/React.createElement(TargetConsumer, null, function (
|
|
18
|
-
|
|
17
|
+
return /*#__PURE__*/React.createElement(TargetConsumer, null, function (getTargetRef) {
|
|
18
|
+
if (typeof children === 'function') {
|
|
19
|
+
return children({
|
|
20
|
+
targetRef: getTargetRef === null || getTargetRef === void 0 ? void 0 : getTargetRef(name)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return getTargetRef ? /*#__PURE__*/React.createElement(NodeResolverSpotlightTarget, {
|
|
19
24
|
name: name,
|
|
20
25
|
hasNodeResolver: !fg('platform_design_system_team_onboarding_noderesolve'),
|
|
21
|
-
|
|
26
|
+
getTargetRef: getTargetRef
|
|
22
27
|
}, /*#__PURE__*/React.createElement(React.Fragment, null, children)) : children;
|
|
23
28
|
});
|
|
24
29
|
};
|
|
@@ -7,7 +7,7 @@ import { jsx } from '@emotion/react';
|
|
|
7
7
|
interface NodeResolverSpotlightTargetProps {
|
|
8
8
|
hasNodeResolver: boolean;
|
|
9
9
|
children: ReactElement;
|
|
10
|
-
|
|
10
|
+
getTargetRef: (name: string) => (element: HTMLElement | null | undefined) => void;
|
|
11
11
|
name: string;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -18,8 +18,8 @@ interface NodeResolverSpotlightTargetProps {
|
|
|
18
18
|
* @param {boolean} props.hasNodeResolver - Determines whether to apply the NodeResolver.
|
|
19
19
|
* @param {ReactElement} props.children - The child elements to be wrapped.
|
|
20
20
|
* @param {string} props.name - The name to reference from Spotlight.
|
|
21
|
-
* @param {ReactElement} props.
|
|
21
|
+
* @param {ReactElement} props.getTargetRef - Setting up Target Node in Spotlight Manager.
|
|
22
22
|
* @returns {ReactElement} The children wrapped with NodeResolver if hasNodeResolver is true, wrape the children in a div setting innerRef with ref to the div.
|
|
23
23
|
*/
|
|
24
|
-
declare const NodeResolverSpotlightTarget: ({ hasNodeResolver, children,
|
|
24
|
+
declare const NodeResolverSpotlightTarget: ({ hasNodeResolver, children, getTargetRef, name, }: NodeResolverSpotlightTargetProps) => jsx.JSX.Element;
|
|
25
25
|
export default NodeResolverSpotlightTarget;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import React, { type ElementType, PureComponent, type ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
export type TargetRef = (element: HTMLElement | null | undefined) => void;
|
|
3
|
+
export type GetTargetRef = (
|
|
4
|
+
/**
|
|
5
|
+
* The `name` prop passed to the corresponding `SpotlightTarget`
|
|
6
|
+
*
|
|
7
|
+
* This is used as a key into the `targets` map owned by `SpotlightManager`
|
|
8
|
+
* because the `SpotlightManager` stores the target nodes for
|
|
9
|
+
* descendant `SpotlightTarget` instances.
|
|
10
|
+
*/
|
|
11
|
+
name: string) => TargetRef;
|
|
12
|
+
declare const TargetConsumer: React.Consumer<GetTargetRef | undefined>;
|
|
3
13
|
declare const SpotlightContext: React.Context<{
|
|
4
14
|
opened: () => void;
|
|
5
15
|
closed: () => void;
|
|
@@ -58,7 +68,7 @@ export default class SpotlightManager extends PureComponent<SpotlightManagerProp
|
|
|
58
68
|
spotlightCount: number;
|
|
59
69
|
targets: {};
|
|
60
70
|
};
|
|
61
|
-
|
|
71
|
+
getTargetRef: (name: string) => (element: HTMLElement | null | undefined) => void;
|
|
62
72
|
spotlightOpen: () => void;
|
|
63
73
|
spotlightClose: () => void;
|
|
64
74
|
getStateProviderValue: import("memoize-one").MemoizedFn<(this: any, targets: any) => {
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type TargetRef } from './spotlight-manager';
|
|
3
|
+
type RenderChildrenFunction = (props: {
|
|
4
|
+
/**
|
|
5
|
+
* Pass this as the `ref` of the element that should be cloned.
|
|
6
|
+
*
|
|
7
|
+
* This is useful if:
|
|
8
|
+
*
|
|
9
|
+
* - you don't want a wrapping `<div>`
|
|
10
|
+
* - a component exposes specific children through ref props
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <SpotlightTarget>
|
|
15
|
+
* {({ targetRef }) => (
|
|
16
|
+
* <OpaqueComponent
|
|
17
|
+
* headingRef={targetRef}
|
|
18
|
+
* />
|
|
19
|
+
* )}
|
|
20
|
+
* </SpotlightTarget>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
targetRef?: TargetRef;
|
|
24
|
+
}) => ReactNode;
|
|
2
25
|
interface SpotlightTargetProps {
|
|
3
26
|
/**
|
|
4
27
|
* A single child.
|
|
5
28
|
*/
|
|
6
|
-
children: ReactNode;
|
|
29
|
+
children: ReactNode | RenderChildrenFunction;
|
|
7
30
|
/**
|
|
8
31
|
* The name to reference from Spotlight.
|
|
9
32
|
*/
|
|
@@ -7,7 +7,7 @@ import { jsx } from '@emotion/react';
|
|
|
7
7
|
interface NodeResolverSpotlightTargetProps {
|
|
8
8
|
hasNodeResolver: boolean;
|
|
9
9
|
children: ReactElement;
|
|
10
|
-
|
|
10
|
+
getTargetRef: (name: string) => (element: HTMLElement | null | undefined) => void;
|
|
11
11
|
name: string;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -18,8 +18,8 @@ interface NodeResolverSpotlightTargetProps {
|
|
|
18
18
|
* @param {boolean} props.hasNodeResolver - Determines whether to apply the NodeResolver.
|
|
19
19
|
* @param {ReactElement} props.children - The child elements to be wrapped.
|
|
20
20
|
* @param {string} props.name - The name to reference from Spotlight.
|
|
21
|
-
* @param {ReactElement} props.
|
|
21
|
+
* @param {ReactElement} props.getTargetRef - Setting up Target Node in Spotlight Manager.
|
|
22
22
|
* @returns {ReactElement} The children wrapped with NodeResolver if hasNodeResolver is true, wrape the children in a div setting innerRef with ref to the div.
|
|
23
23
|
*/
|
|
24
|
-
declare const NodeResolverSpotlightTarget: ({ hasNodeResolver, children,
|
|
24
|
+
declare const NodeResolverSpotlightTarget: ({ hasNodeResolver, children, getTargetRef, name, }: NodeResolverSpotlightTargetProps) => jsx.JSX.Element;
|
|
25
25
|
export default NodeResolverSpotlightTarget;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import React, { type ElementType, PureComponent, type ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
export type TargetRef = (element: HTMLElement | null | undefined) => void;
|
|
3
|
+
export type GetTargetRef = (
|
|
4
|
+
/**
|
|
5
|
+
* The `name` prop passed to the corresponding `SpotlightTarget`
|
|
6
|
+
*
|
|
7
|
+
* This is used as a key into the `targets` map owned by `SpotlightManager`
|
|
8
|
+
* because the `SpotlightManager` stores the target nodes for
|
|
9
|
+
* descendant `SpotlightTarget` instances.
|
|
10
|
+
*/
|
|
11
|
+
name: string) => TargetRef;
|
|
12
|
+
declare const TargetConsumer: React.Consumer<GetTargetRef | undefined>;
|
|
3
13
|
declare const SpotlightContext: React.Context<{
|
|
4
14
|
opened: () => void;
|
|
5
15
|
closed: () => void;
|
|
@@ -58,7 +68,7 @@ export default class SpotlightManager extends PureComponent<SpotlightManagerProp
|
|
|
58
68
|
spotlightCount: number;
|
|
59
69
|
targets: {};
|
|
60
70
|
};
|
|
61
|
-
|
|
71
|
+
getTargetRef: (name: string) => (element: HTMLElement | null | undefined) => void;
|
|
62
72
|
spotlightOpen: () => void;
|
|
63
73
|
spotlightClose: () => void;
|
|
64
74
|
getStateProviderValue: import("memoize-one").MemoizedFn<(this: any, targets: any) => {
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type TargetRef } from './spotlight-manager';
|
|
3
|
+
type RenderChildrenFunction = (props: {
|
|
4
|
+
/**
|
|
5
|
+
* Pass this as the `ref` of the element that should be cloned.
|
|
6
|
+
*
|
|
7
|
+
* This is useful if:
|
|
8
|
+
*
|
|
9
|
+
* - you don't want a wrapping `<div>`
|
|
10
|
+
* - a component exposes specific children through ref props
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <SpotlightTarget>
|
|
15
|
+
* {({ targetRef }) => (
|
|
16
|
+
* <OpaqueComponent
|
|
17
|
+
* headingRef={targetRef}
|
|
18
|
+
* />
|
|
19
|
+
* )}
|
|
20
|
+
* </SpotlightTarget>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
targetRef?: TargetRef;
|
|
24
|
+
}) => ReactNode;
|
|
2
25
|
interface SpotlightTargetProps {
|
|
3
26
|
/**
|
|
4
27
|
* A single child.
|
|
5
28
|
*/
|
|
6
|
-
children: ReactNode;
|
|
29
|
+
children: ReactNode | RenderChildrenFunction;
|
|
7
30
|
/**
|
|
8
31
|
* The name to reference from Spotlight.
|
|
9
32
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/onboarding",
|
|
3
|
-
"version": "12.1
|
|
3
|
+
"version": "12.2.1",
|
|
4
4
|
"description": "An onboarding spotlight introduces new features to users through focused messages or multi-step tours.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/button": "^20.3.0",
|
|
42
42
|
"@atlaskit/ds-lib": "^3.3.0",
|
|
43
43
|
"@atlaskit/heading": "^4.0.0",
|
|
44
|
-
"@atlaskit/layering": "^0.
|
|
44
|
+
"@atlaskit/layering": "^1.0.0",
|
|
45
45
|
"@atlaskit/modal-dialog": "^12.18.0",
|
|
46
46
|
"@atlaskit/motion": "^1.9.0",
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
@@ -86,9 +86,6 @@
|
|
|
86
86
|
"platform_design_system_team_onboarding_noderesolve": {
|
|
87
87
|
"type": "boolean"
|
|
88
88
|
},
|
|
89
|
-
"platform_design_system_team_spotlight_layering": {
|
|
90
|
-
"type": "boolean"
|
|
91
|
-
},
|
|
92
89
|
"design-system-closed-all-when-click-outside": {
|
|
93
90
|
"type": "boolean",
|
|
94
91
|
"referenceOnly": true
|