@khanacademy/wonder-blocks-tooltip 3.0.0 → 4.0.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 +28 -0
- package/dist/components/tooltip-anchor.d.ts +3 -4
- package/dist/components/tooltip.d.ts +2 -4
- package/dist/es/index.js +13 -26
- package/dist/index.js +12 -25
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-tooltip
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 56d961f1: - Migrate Wonder Blocks components off old id providers and onto new `Id` component
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- b6009b77: Deprecate the ID provider and unique ID utilities
|
|
12
|
+
- Updated dependencies [b6009b77]
|
|
13
|
+
- Updated dependencies [897686bc]
|
|
14
|
+
- Updated dependencies [56d961f1]
|
|
15
|
+
- @khanacademy/wonder-blocks-core@10.0.0
|
|
16
|
+
- @khanacademy/wonder-blocks-modal@7.0.0
|
|
17
|
+
- @khanacademy/wonder-blocks-layout@3.0.2
|
|
18
|
+
- @khanacademy/wonder-blocks-typography@3.0.2
|
|
19
|
+
|
|
20
|
+
## 3.0.1
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [f4abd572]
|
|
25
|
+
- Updated dependencies [0955be7e]
|
|
26
|
+
- @khanacademy/wonder-blocks-core@9.0.0
|
|
27
|
+
- @khanacademy/wonder-blocks-modal@6.0.1
|
|
28
|
+
- @khanacademy/wonder-blocks-layout@3.0.1
|
|
29
|
+
- @khanacademy/wonder-blocks-typography@3.0.1
|
|
30
|
+
|
|
3
31
|
## 3.0.0
|
|
4
32
|
|
|
5
33
|
### Major Changes
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* positioning and displaying tooltips.
|
|
4
4
|
*/
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import type { IIdentifierFactory } from "@khanacademy/wonder-blocks-core";
|
|
7
6
|
import type { IActiveTrackerSubscriber } from "../util/active-tracker";
|
|
8
7
|
type Props = {
|
|
9
8
|
/**
|
|
@@ -43,9 +42,9 @@ type Props = {
|
|
|
43
42
|
*/
|
|
44
43
|
onActiveChanged: (active: boolean) => unknown;
|
|
45
44
|
/**
|
|
46
|
-
* Optional unique id
|
|
45
|
+
* Optional unique id.
|
|
47
46
|
*/
|
|
48
|
-
|
|
47
|
+
id?: string | undefined;
|
|
49
48
|
};
|
|
50
49
|
type DefaultProps = {
|
|
51
50
|
forceAnchorFocusivity: Props["forceAnchorFocusivity"];
|
|
@@ -79,7 +78,7 @@ export default class TooltipAnchor extends React.Component<Props, State> impleme
|
|
|
79
78
|
_handleMouseLeave: () => void;
|
|
80
79
|
_handleKeyUp: (e: KeyboardEvent) => void;
|
|
81
80
|
_renderAnchorableChildren(): React.ReactElement<any>;
|
|
82
|
-
_renderAccessibleChildren(
|
|
81
|
+
_renderAccessibleChildren(uniqueId: string): React.ReactNode;
|
|
83
82
|
render(): React.ReactNode;
|
|
84
83
|
}
|
|
85
84
|
export {};
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
* callout to the anchor content)
|
|
19
19
|
*/
|
|
20
20
|
import * as React from "react";
|
|
21
|
-
import { IIdentifierFactory } from "@khanacademy/wonder-blocks-core";
|
|
22
21
|
import type { Typography } from "@khanacademy/wonder-blocks-typography";
|
|
23
22
|
import type { AriaProps } from "@khanacademy/wonder-blocks-core";
|
|
24
23
|
import { color } from "@khanacademy/wonder-blocks-tokens";
|
|
@@ -158,12 +157,11 @@ export default class Tooltip extends React.Component<Props, State> {
|
|
|
158
157
|
*/
|
|
159
158
|
static getDerivedStateFromProps(props: Props, state: State): Partial<State> | null;
|
|
160
159
|
state: State;
|
|
161
|
-
static ariaContentId: string;
|
|
162
160
|
_updateAnchorElement(ref?: Element | null): void;
|
|
163
161
|
_renderBubbleContent(): React.ReactElement<React.ComponentProps<typeof TooltipContent>>;
|
|
164
|
-
_renderPopper(
|
|
162
|
+
_renderPopper(bubbleId: string): React.ReactNode;
|
|
165
163
|
_getHost(): Element | null | undefined;
|
|
166
|
-
_renderTooltipAnchor(
|
|
164
|
+
_renderTooltipAnchor(uniqueId: string): React.ReactNode;
|
|
167
165
|
render(): React.ReactNode;
|
|
168
166
|
}
|
|
169
167
|
export {};
|
package/dist/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as ReactDOM from 'react-dom';
|
|
3
|
-
import { Text as Text$1, View,
|
|
3
|
+
import { Text as Text$1, View, Id } from '@khanacademy/wonder-blocks-core';
|
|
4
4
|
import { maybeGetPortalMountedModalHostElement } from '@khanacademy/wonder-blocks-modal';
|
|
5
5
|
import { StyleSheet, css } from 'aphrodite';
|
|
6
6
|
import { spacing, color } from '@khanacademy/wonder-blocks-tokens';
|
|
@@ -193,15 +193,15 @@ class TooltipAnchor extends React.Component {
|
|
|
193
193
|
} = this.props;
|
|
194
194
|
return typeof children === "string" ? React.createElement(Text$1, null, children) : children;
|
|
195
195
|
}
|
|
196
|
-
_renderAccessibleChildren(
|
|
196
|
+
_renderAccessibleChildren(uniqueId) {
|
|
197
197
|
const anchorableChildren = this._renderAnchorableChildren();
|
|
198
198
|
return React.cloneElement(anchorableChildren, {
|
|
199
|
-
"aria-describedby":
|
|
199
|
+
"aria-describedby": `${uniqueId}-${TooltipAnchor.ariaContentId}`
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
render() {
|
|
203
|
-
if (this.props.
|
|
204
|
-
return this._renderAccessibleChildren(this.props.
|
|
203
|
+
if (this.props.id) {
|
|
204
|
+
return this._renderAccessibleChildren(this.props.id);
|
|
205
205
|
}
|
|
206
206
|
return this._renderAnchorableChildren();
|
|
207
207
|
}
|
|
@@ -809,16 +809,9 @@ class Tooltip extends React.Component {
|
|
|
809
809
|
return content;
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
|
-
_renderPopper(
|
|
813
|
-
const {
|
|
814
|
-
id,
|
|
815
|
-
backgroundColor
|
|
816
|
-
} = this.props;
|
|
817
|
-
const bubbleId = ids ? ids.get(Tooltip.ariaContentId) : id;
|
|
818
|
-
if (!bubbleId) {
|
|
819
|
-
throw new Error("Did not get an identifier factory nor a id prop");
|
|
820
|
-
}
|
|
812
|
+
_renderPopper(bubbleId) {
|
|
821
813
|
const {
|
|
814
|
+
backgroundColor,
|
|
822
815
|
placement
|
|
823
816
|
} = this.props;
|
|
824
817
|
return React.createElement(TooltipPopper, {
|
|
@@ -846,7 +839,7 @@ class Tooltip extends React.Component {
|
|
|
846
839
|
} = this.state;
|
|
847
840
|
return maybeGetPortalMountedModalHostElement(anchorElement) || document.body;
|
|
848
841
|
}
|
|
849
|
-
_renderTooltipAnchor(
|
|
842
|
+
_renderTooltipAnchor(uniqueId) {
|
|
850
843
|
const {
|
|
851
844
|
autoUpdate,
|
|
852
845
|
children,
|
|
@@ -865,27 +858,21 @@ class Tooltip extends React.Component {
|
|
|
865
858
|
onActiveChanged: active => this.setState({
|
|
866
859
|
active
|
|
867
860
|
}),
|
|
868
|
-
|
|
869
|
-
}, children), shouldBeVisible && ReactDOM.createPortal(this._renderPopper(
|
|
861
|
+
id: `${uniqueId}-anchor`
|
|
862
|
+
}, children), shouldBeVisible && ReactDOM.createPortal(this._renderPopper(uniqueId), popperHost));
|
|
870
863
|
}
|
|
871
864
|
render() {
|
|
872
865
|
const {
|
|
873
866
|
id
|
|
874
867
|
} = this.props;
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
}
|
|
878
|
-
return React.createElement(UniqueIDProvider, {
|
|
879
|
-
scope: "tooltip",
|
|
880
|
-
mockOnFirstRender: true
|
|
881
|
-
}, ids => this._renderTooltipAnchor(ids));
|
|
882
|
-
}
|
|
868
|
+
return React.createElement(Id, {
|
|
869
|
+
id: id
|
|
870
|
+
}, uniqueId => this._renderTooltipAnchor(uniqueId));
|
|
883
871
|
}
|
|
884
872
|
}
|
|
885
873
|
Tooltip.defaultProps = {
|
|
886
874
|
forceAnchorFocusivity: true,
|
|
887
875
|
placement: "top"
|
|
888
876
|
};
|
|
889
|
-
Tooltip.ariaContentId = "aria-content";
|
|
890
877
|
|
|
891
878
|
export { TooltipContent, TooltipPopper, TooltipTail, Tooltip as default };
|
package/dist/index.js
CHANGED
|
@@ -221,15 +221,15 @@ class TooltipAnchor extends React__namespace.Component {
|
|
|
221
221
|
} = this.props;
|
|
222
222
|
return typeof children === "string" ? React__namespace.createElement(wonderBlocksCore.Text, null, children) : children;
|
|
223
223
|
}
|
|
224
|
-
_renderAccessibleChildren(
|
|
224
|
+
_renderAccessibleChildren(uniqueId) {
|
|
225
225
|
const anchorableChildren = this._renderAnchorableChildren();
|
|
226
226
|
return React__namespace.cloneElement(anchorableChildren, {
|
|
227
|
-
"aria-describedby":
|
|
227
|
+
"aria-describedby": `${uniqueId}-${TooltipAnchor.ariaContentId}`
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
render() {
|
|
231
|
-
if (this.props.
|
|
232
|
-
return this._renderAccessibleChildren(this.props.
|
|
231
|
+
if (this.props.id) {
|
|
232
|
+
return this._renderAccessibleChildren(this.props.id);
|
|
233
233
|
}
|
|
234
234
|
return this._renderAnchorableChildren();
|
|
235
235
|
}
|
|
@@ -837,16 +837,9 @@ class Tooltip extends React__namespace.Component {
|
|
|
837
837
|
return content;
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
_renderPopper(
|
|
841
|
-
const {
|
|
842
|
-
id,
|
|
843
|
-
backgroundColor
|
|
844
|
-
} = this.props;
|
|
845
|
-
const bubbleId = ids ? ids.get(Tooltip.ariaContentId) : id;
|
|
846
|
-
if (!bubbleId) {
|
|
847
|
-
throw new Error("Did not get an identifier factory nor a id prop");
|
|
848
|
-
}
|
|
840
|
+
_renderPopper(bubbleId) {
|
|
849
841
|
const {
|
|
842
|
+
backgroundColor,
|
|
850
843
|
placement
|
|
851
844
|
} = this.props;
|
|
852
845
|
return React__namespace.createElement(TooltipPopper, {
|
|
@@ -874,7 +867,7 @@ class Tooltip extends React__namespace.Component {
|
|
|
874
867
|
} = this.state;
|
|
875
868
|
return wonderBlocksModal.maybeGetPortalMountedModalHostElement(anchorElement) || document.body;
|
|
876
869
|
}
|
|
877
|
-
_renderTooltipAnchor(
|
|
870
|
+
_renderTooltipAnchor(uniqueId) {
|
|
878
871
|
const {
|
|
879
872
|
autoUpdate,
|
|
880
873
|
children,
|
|
@@ -893,28 +886,22 @@ class Tooltip extends React__namespace.Component {
|
|
|
893
886
|
onActiveChanged: active => this.setState({
|
|
894
887
|
active
|
|
895
888
|
}),
|
|
896
|
-
|
|
897
|
-
}, children), shouldBeVisible && ReactDOM__namespace.createPortal(this._renderPopper(
|
|
889
|
+
id: `${uniqueId}-anchor`
|
|
890
|
+
}, children), shouldBeVisible && ReactDOM__namespace.createPortal(this._renderPopper(uniqueId), popperHost));
|
|
898
891
|
}
|
|
899
892
|
render() {
|
|
900
893
|
const {
|
|
901
894
|
id
|
|
902
895
|
} = this.props;
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
}
|
|
906
|
-
return React__namespace.createElement(wonderBlocksCore.UniqueIDProvider, {
|
|
907
|
-
scope: "tooltip",
|
|
908
|
-
mockOnFirstRender: true
|
|
909
|
-
}, ids => this._renderTooltipAnchor(ids));
|
|
910
|
-
}
|
|
896
|
+
return React__namespace.createElement(wonderBlocksCore.Id, {
|
|
897
|
+
id: id
|
|
898
|
+
}, uniqueId => this._renderTooltipAnchor(uniqueId));
|
|
911
899
|
}
|
|
912
900
|
}
|
|
913
901
|
Tooltip.defaultProps = {
|
|
914
902
|
forceAnchorFocusivity: true,
|
|
915
903
|
placement: "top"
|
|
916
904
|
};
|
|
917
|
-
Tooltip.ariaContentId = "aria-content";
|
|
918
905
|
|
|
919
906
|
exports.TooltipContent = TooltipContent;
|
|
920
907
|
exports.TooltipPopper = TooltipPopper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-tooltip",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.18.6",
|
|
19
|
-
"@khanacademy/wonder-blocks-core": "^
|
|
20
|
-
"@khanacademy/wonder-blocks-layout": "^3.0.
|
|
21
|
-
"@khanacademy/wonder-blocks-modal": "^
|
|
19
|
+
"@khanacademy/wonder-blocks-core": "^10.0.0",
|
|
20
|
+
"@khanacademy/wonder-blocks-layout": "^3.0.2",
|
|
21
|
+
"@khanacademy/wonder-blocks-modal": "^7.0.0",
|
|
22
22
|
"@khanacademy/wonder-blocks-tokens": "^3.0.0",
|
|
23
|
-
"@khanacademy/wonder-blocks-typography": "^3.0.
|
|
23
|
+
"@khanacademy/wonder-blocks-typography": "^3.0.2"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@popperjs/core": "^2.10.1",
|