@purpurds/tabs 5.1.0 → 5.1.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/dist/LICENSE.txt +1 -1
- package/dist/styles.css +1 -1
- package/dist/tabs.cjs.js +3 -3
- package/dist/tabs.cjs.js.map +1 -1
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.es.js +110 -107
- package/dist/tabs.es.js.map +1 -1
- package/package.json +4 -4
- package/src/tab-content.module.scss +6 -10
- package/src/tab-header.module.scss +6 -5
- package/src/tabs.stories.tsx +3 -3
- package/src/tabs.tsx +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/tabs",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/tabs.cjs.js",
|
|
6
6
|
"types": "./dist/tabs.d.ts",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"classnames": "~2.5.0",
|
|
18
18
|
"@radix-ui/react-tabs": "~1.0.4",
|
|
19
|
-
"@purpurds/tokens": "5.1.
|
|
20
|
-
"@purpurds/paragraph": "5.1.
|
|
21
|
-
"@purpurds/icon": "5.1.
|
|
19
|
+
"@purpurds/tokens": "5.1.1",
|
|
20
|
+
"@purpurds/paragraph": "5.1.1",
|
|
21
|
+
"@purpurds/icon": "5.1.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@rushstack/eslint-patch": "~1.10.0",
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
.purpur-tab-content {
|
|
2
2
|
position: relative;
|
|
3
3
|
|
|
4
|
-
&:focus {
|
|
4
|
+
&:focus-visible {
|
|
5
5
|
outline: 0;
|
|
6
6
|
|
|
7
7
|
&::before {
|
|
8
8
|
content: "";
|
|
9
9
|
position: absolute;
|
|
10
|
-
inset:
|
|
11
|
-
|
|
12
|
-
border: var(--purpur-border-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&:not(:focus-visible)::before {
|
|
17
|
-
border: 0;
|
|
10
|
+
inset: 0;
|
|
11
|
+
outline: var(--purpur-border-width-sm) solid var(--purpur-color-border-interactive-focus);
|
|
12
|
+
border-radius: var(--purpur-border-radius-xs);
|
|
13
|
+
pointer-events: none;
|
|
18
14
|
}
|
|
19
15
|
}
|
|
20
|
-
}
|
|
16
|
+
}
|
|
@@ -19,23 +19,24 @@
|
|
|
19
19
|
cursor: auto;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
&:focus {
|
|
22
|
+
&:focus-visible {
|
|
23
23
|
outline: 0;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
&::after {
|
|
26
26
|
content: "";
|
|
27
27
|
position: absolute;
|
|
28
28
|
inset: 0;
|
|
29
29
|
z-index: 20;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
outline: var(--purpur-border-width-sm) solid var(--purpur-color-border-interactive-focus);
|
|
31
|
+
outline-offset: calc(-1 * var(--purpur-border-width-sm));
|
|
32
|
+
border-radius: var(--purpur-border-radius-sm) var(--purpur-border-radius-sm) 0 0;
|
|
32
33
|
pointer-events: none;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
&--contained,
|
|
37
38
|
&--contained-negative {
|
|
38
|
-
&:focus
|
|
39
|
+
&:focus-visible::after {
|
|
39
40
|
top: calc(-1 * var(--purpur-border-width-sm));
|
|
40
41
|
}
|
|
41
42
|
}
|
package/src/tabs.stories.tsx
CHANGED
|
@@ -39,7 +39,7 @@ export const Showcase: Story = {
|
|
|
39
39
|
key="1"
|
|
40
40
|
tabId={`${tabId}-1`}
|
|
41
41
|
name={`${name}-1`}
|
|
42
|
-
style={{ padding: "var(--purpur-spacing-250" }}
|
|
42
|
+
style={{ padding: "var(--purpur-spacing-250)" }}
|
|
43
43
|
>
|
|
44
44
|
<div>Content 1</div>
|
|
45
45
|
</Tabs.Content>,
|
|
@@ -47,7 +47,7 @@ export const Showcase: Story = {
|
|
|
47
47
|
key="2"
|
|
48
48
|
tabId={`${tabId}-2`}
|
|
49
49
|
name={`${name}-2`}
|
|
50
|
-
style={{ padding: "var(--purpur-spacing-250" }}
|
|
50
|
+
style={{ padding: "var(--purpur-spacing-250)" }}
|
|
51
51
|
>
|
|
52
52
|
<div>Content 2</div>
|
|
53
53
|
</Tabs.Content>,
|
|
@@ -55,7 +55,7 @@ export const Showcase: Story = {
|
|
|
55
55
|
key="3"
|
|
56
56
|
tabId={`${tabId}-3`}
|
|
57
57
|
name={`${name}-3`}
|
|
58
|
-
style={{ padding: "var(--purpur-spacing-250" }}
|
|
58
|
+
style={{ padding: "var(--purpur-spacing-250)" }}
|
|
59
59
|
>
|
|
60
60
|
<div>Content 3</div>
|
|
61
61
|
</Tabs.Content>,
|
package/src/tabs.tsx
CHANGED
|
@@ -93,7 +93,11 @@ export const Tabs: TabsCmp<TabsProps> = ({
|
|
|
93
93
|
|
|
94
94
|
const tabIds = Children.map(tabContentChildren, ({ props: { tabId } }) => tabId);
|
|
95
95
|
|
|
96
|
-
const getDefaultTabIndex = () =>
|
|
96
|
+
const getDefaultTabIndex = () => {
|
|
97
|
+
const defaultIndex = tabIds.findIndex((tabIndex) => tabIndex === defaultValue);
|
|
98
|
+
return defaultIndex >= 0 ? defaultIndex : 0;
|
|
99
|
+
};
|
|
100
|
+
|
|
97
101
|
const [activeIndex, setActiveIndex] = useState(getDefaultTabIndex);
|
|
98
102
|
|
|
99
103
|
if (new Set(tabIds).size !== tabIds.length) {
|