@khanacademy/wonder-blocks-popover 2.1.7 → 3.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @khanacademy/wonder-blocks-popover
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 674a1e5c: Props are using discriminated union types to prevent invalid combinations of props
8
+
9
+ ### Patch Changes
10
+
11
+ - 674a1e5c: We're no longer building flow types
12
+ - Updated dependencies [674a1e5c]
13
+ - Updated dependencies [674a1e5c]
14
+ - @khanacademy/wonder-blocks-modal@4.0.19
15
+ - @khanacademy/wonder-blocks-core@6.0.0
16
+ - @khanacademy/wonder-blocks-icon-button@4.1.3
17
+ - @khanacademy/wonder-blocks-icon@2.1.1
18
+ - @khanacademy/wonder-blocks-tooltip@2.1.2
19
+ - @khanacademy/wonder-blocks-typography@2.1.3
20
+
3
21
  ## 2.1.7
4
22
 
5
23
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import type { AriaProps, StyleType } from "@khanacademy/wonder-blocks-core";
3
3
  import type { PopoverContextType } from "./popover-context";
4
- type Props = AriaProps & {
4
+ type CommonProps = AriaProps & {
5
5
  /**
6
6
  * The content to render inside the popover.
7
7
  */
@@ -37,6 +37,8 @@ type Props = AriaProps & {
37
37
  * Test ID used for e2e testing.
38
38
  */
39
39
  testId?: string;
40
+ };
41
+ type Props = (CommonProps & {
40
42
  /**
41
43
  * Decorate the popover with an illustrated icon. It cannot be used at the
42
44
  * same time with image.
@@ -47,13 +49,17 @@ type Props = AriaProps & {
47
49
  * the same time with icon.
48
50
  */
49
51
  image?: React.ReactElement<React.ComponentProps<"img">> | React.ReactElement<React.ComponentProps<"svg">>;
52
+ emphasized?: never;
53
+ }) | (CommonProps & {
50
54
  /**
51
55
  * When true, changes the popover dialog background to blue; otherwise, the
52
56
  * popover dialog background is not modified. It can be used only with
53
57
  * Text-only popovers. It cannot be used with icon or image.
54
58
  */
55
59
  emphasized?: boolean;
56
- };
60
+ icon?: never;
61
+ image?: never;
62
+ });
57
63
  type DefaultProps = {
58
64
  closeButtonVisible: Props["closeButtonVisible"];
59
65
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-popover",
3
- "version": "2.1.7",
3
+ "version": "3.0.0",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,13 +17,13 @@
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
19
  "@khanacademy/wonder-blocks-color": "^2.0.1",
20
- "@khanacademy/wonder-blocks-core": "^5.4.0",
21
- "@khanacademy/wonder-blocks-icon": "^2.1.0",
22
- "@khanacademy/wonder-blocks-icon-button": "^4.1.2",
23
- "@khanacademy/wonder-blocks-modal": "^4.0.18",
20
+ "@khanacademy/wonder-blocks-core": "^6.0.0",
21
+ "@khanacademy/wonder-blocks-icon": "^2.1.1",
22
+ "@khanacademy/wonder-blocks-icon-button": "^4.1.3",
23
+ "@khanacademy/wonder-blocks-modal": "^4.0.19",
24
24
  "@khanacademy/wonder-blocks-spacing": "^4.0.1",
25
- "@khanacademy/wonder-blocks-tooltip": "^2.1.1",
26
- "@khanacademy/wonder-blocks-typography": "^2.1.2"
25
+ "@khanacademy/wonder-blocks-tooltip": "^2.1.2",
26
+ "@khanacademy/wonder-blocks-typography": "^2.1.3"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@popperjs/core": "^2.10.1",
@@ -33,6 +33,6 @@
33
33
  "react-popper": "^2.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "wb-dev-build-settings": "^0.9.7"
36
+ "@khanacademy/wb-dev-build-settings": "^1.0.0"
37
37
  }
38
38
  }
@@ -0,0 +1,38 @@
1
+ import * as React from "react";
2
+
3
+ import PopoverContent from "../popover-content";
4
+
5
+ <PopoverContent title="Title" content="Content" />;
6
+
7
+ <PopoverContent title="Title" content="Content" icon="close" />;
8
+
9
+ <PopoverContent
10
+ title="Title"
11
+ content="Content"
12
+ image={<img src="domokun.jpg" alt="domokun" />}
13
+ />;
14
+
15
+ <PopoverContent
16
+ title="Title"
17
+ content="Content"
18
+ icon="close"
19
+ image={<img src="domokun.jpg" alt="domokun" />}
20
+ />;
21
+
22
+ <PopoverContent title="Title" content="Content" emphasized={true} />;
23
+
24
+ // @ts-expect-error `emphasized` cannot be used with `icon`
25
+ <PopoverContent
26
+ title="Title"
27
+ content="Content"
28
+ icon="close"
29
+ emphasized={true}
30
+ />;
31
+
32
+ // @ts-expect-error `emphasized` cannot be used with `img`
33
+ <PopoverContent
34
+ title="Title"
35
+ content="Content"
36
+ image={<img src="domokun.jpg" alt="domokun" />}
37
+ emphasized={true}
38
+ />;
@@ -11,8 +11,7 @@ import type {PopoverContextType} from "./popover-context";
11
11
  import PopoverContentCore from "./popover-content-core";
12
12
  import PopoverContext from "./popover-context";
13
13
 
14
- // TODO(FEI-5000): Convert back to conditional props after TS migration is complete.
15
- type Props = AriaProps & {
14
+ type CommonProps = AriaProps & {
16
15
  /**
17
16
  * The content to render inside the popover.
18
17
  */
@@ -48,29 +47,40 @@ type Props = AriaProps & {
48
47
  * Test ID used for e2e testing.
49
48
  */
50
49
  testId?: string;
51
- /**
52
- * Decorate the popover with an illustrated icon. It cannot be used at the
53
- * same time with image.
54
- */
55
- icon?:
56
- | string
57
- | React.ReactElement<React.ComponentProps<"img">>
58
- | React.ReactElement<React.ComponentProps<"svg">>;
59
- /**
60
- * Decorate the popover with a full-bleed illustration. It cannot be used at
61
- * the same time with icon.
62
- */
63
- image?:
64
- | React.ReactElement<React.ComponentProps<"img">>
65
- | React.ReactElement<React.ComponentProps<"svg">>;
66
- /**
67
- * When true, changes the popover dialog background to blue; otherwise, the
68
- * popover dialog background is not modified. It can be used only with
69
- * Text-only popovers. It cannot be used with icon or image.
70
- */
71
- emphasized?: boolean;
72
50
  };
73
51
 
52
+ type Props =
53
+ | (CommonProps & {
54
+ /**
55
+ * Decorate the popover with an illustrated icon. It cannot be used at the
56
+ * same time with image.
57
+ */
58
+ icon?:
59
+ | string
60
+ | React.ReactElement<React.ComponentProps<"img">>
61
+ | React.ReactElement<React.ComponentProps<"svg">>;
62
+ /**
63
+ * Decorate the popover with a full-bleed illustration. It cannot be used at
64
+ * the same time with icon.
65
+ */
66
+ image?:
67
+ | React.ReactElement<React.ComponentProps<"img">>
68
+ | React.ReactElement<React.ComponentProps<"svg">>;
69
+
70
+ emphasized?: never;
71
+ })
72
+ | (CommonProps & {
73
+ /**
74
+ * When true, changes the popover dialog background to blue; otherwise, the
75
+ * popover dialog background is not modified. It can be used only with
76
+ * Text-only popovers. It cannot be used with icon or image.
77
+ */
78
+ emphasized?: boolean;
79
+
80
+ icon?: never;
81
+ image?: never;
82
+ });
83
+
74
84
  type DefaultProps = {
75
85
  closeButtonVisible: Props["closeButtonVisible"];
76
86
  };