@khanacademy/wonder-blocks-tabs 0.0.0-PR2905-20251212180618 → 0.0.0-PR2906-20251212234252
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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
|
+
import { AriaLabelOrAriaLabelledby } from "./types";
|
|
4
|
+
type TabDropdownItem = {
|
|
5
|
+
/**
|
|
6
|
+
* The label of the tab
|
|
7
|
+
*/
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* The id of the tab
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* The contents for the tab
|
|
15
|
+
*/
|
|
16
|
+
panel: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Optional test ID for e2e testing of the menu item.
|
|
19
|
+
*/
|
|
20
|
+
testId?: string;
|
|
21
|
+
};
|
|
22
|
+
type Props = AriaLabelOrAriaLabelledby & {
|
|
23
|
+
/**
|
|
24
|
+
* A unique id for the component. If not provided, a unique base id will be
|
|
25
|
+
* generated automatically.
|
|
26
|
+
*
|
|
27
|
+
* Here is how the id is used for the different elements in the component:
|
|
28
|
+
* - The root will have an id of `${id}`
|
|
29
|
+
* - The opener will have an id of `${id}-opener`
|
|
30
|
+
* - The panel will have an id of `${id}-panel`
|
|
31
|
+
*/
|
|
32
|
+
id?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Optional test ID for e2e testing.
|
|
35
|
+
*
|
|
36
|
+
* Here is how the testId is used for the different elements in the component:
|
|
37
|
+
* - The root will have a testId of `${testId}`
|
|
38
|
+
* - The opener will have a testId of `${testId}-opener`
|
|
39
|
+
* - The panel will have a testId of `${testId}-panel`
|
|
40
|
+
*/
|
|
41
|
+
testId?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The tabs to render in the dropdown.
|
|
44
|
+
*/
|
|
45
|
+
tabs: Array<TabDropdownItem>;
|
|
46
|
+
/**
|
|
47
|
+
* The id of the tab that is selected.
|
|
48
|
+
*
|
|
49
|
+
* If the selectedTabId is not valid, the `labels.defaultOpenerLabel` will
|
|
50
|
+
* be used to label the dropdown opener.
|
|
51
|
+
*/
|
|
52
|
+
selectedTabId: string;
|
|
53
|
+
/**
|
|
54
|
+
* Called when a tab is selected.
|
|
55
|
+
*/
|
|
56
|
+
onTabSelected: (id: string) => unknown;
|
|
57
|
+
/**
|
|
58
|
+
* Labels for the dropdown.
|
|
59
|
+
*/
|
|
60
|
+
labels?: {
|
|
61
|
+
defaultOpenerLabel?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Can be used to override the opened state for the dropdown
|
|
65
|
+
*/
|
|
66
|
+
opened?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Styling for the tabs dropdown.
|
|
69
|
+
*/
|
|
70
|
+
styles?: {
|
|
71
|
+
root?: StyleType;
|
|
72
|
+
actionMenu?: StyleType;
|
|
73
|
+
opener?: StyleType;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The TabsDropdown component is used to represent tabs in an ActionMenu when
|
|
78
|
+
* there is not enough horizontal space to render the tabs as a horizontal layout.
|
|
79
|
+
*
|
|
80
|
+
* Note: This component is meant to be used internally to address responsiveness
|
|
81
|
+
* in the ResponsiveTabs component. Please reach out to the WB team if there is
|
|
82
|
+
* a need to use this component directly.
|
|
83
|
+
*/
|
|
84
|
+
export declare const TabsDropdown: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
85
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { AriaProps, PropsFor, StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
3
|
import { Tab } from "./tab";
|
|
4
|
+
import { AriaLabelOrAriaLabelledby } from "./types";
|
|
4
5
|
export type TabRenderProps = Omit<PropsFor<typeof Tab>, "children">;
|
|
5
6
|
export type TabItem = AriaProps & {
|
|
6
7
|
/**
|
|
@@ -36,24 +37,6 @@ export type TabItem = AriaProps & {
|
|
|
36
37
|
*/
|
|
37
38
|
testId?: string;
|
|
38
39
|
};
|
|
39
|
-
/**
|
|
40
|
-
* Type to help ensure aria-label or aria-labelledby is set.
|
|
41
|
-
*/
|
|
42
|
-
type AriaLabelOrAriaLabelledby = {
|
|
43
|
-
/**
|
|
44
|
-
* If there is no visible label for the tabs, set aria-label to a
|
|
45
|
-
* label describing the tabs.
|
|
46
|
-
*/
|
|
47
|
-
"aria-label": string;
|
|
48
|
-
"aria-labelledby"?: never;
|
|
49
|
-
} | {
|
|
50
|
-
/**
|
|
51
|
-
* If the tabs have a visible label, set aria-labelledby to a value
|
|
52
|
-
* that refers to the labelling element.
|
|
53
|
-
*/
|
|
54
|
-
"aria-labelledby": string;
|
|
55
|
-
"aria-label"?: never;
|
|
56
|
-
};
|
|
57
40
|
type Props = {
|
|
58
41
|
/**
|
|
59
42
|
* A unique id to use as the base of the ids for the elements within the
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type to help ensure aria-label or aria-labelledby is set.
|
|
3
|
+
*/
|
|
4
|
+
export type AriaLabelOrAriaLabelledby = {
|
|
5
|
+
/**
|
|
6
|
+
* If there is no visible label for the tabs, set aria-label to a
|
|
7
|
+
* label describing the tabs.
|
|
8
|
+
*/
|
|
9
|
+
"aria-label": string;
|
|
10
|
+
"aria-labelledby"?: never;
|
|
11
|
+
} | {
|
|
12
|
+
/**
|
|
13
|
+
* If the tabs have a visible label, set aria-labelledby to a value
|
|
14
|
+
* that refers to the labelling element.
|
|
15
|
+
*/
|
|
16
|
+
"aria-labelledby": string;
|
|
17
|
+
"aria-label"?: never;
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Tabs are used to control what content is shown",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.0.0-
|
|
6
|
+
"version": "0.0.0-PR2906-20251212234252",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -20,8 +20,12 @@
|
|
|
20
20
|
"module": "dist/es/index.js",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@phosphor-icons/core": "^2.0.2",
|
|
24
|
+
"@khanacademy/wonder-blocks-button": "11.2.10",
|
|
23
25
|
"@khanacademy/wonder-blocks-core": "12.4.2",
|
|
26
|
+
"@khanacademy/wonder-blocks-dropdown": "10.6.0",
|
|
24
27
|
"@khanacademy/wonder-blocks-tokens": "14.1.3",
|
|
28
|
+
"@khanacademy/wonder-blocks-icon": "5.3.5",
|
|
25
29
|
"@khanacademy/wonder-blocks-typography": "4.2.27"
|
|
26
30
|
},
|
|
27
31
|
"peerDependencies": {
|