@theguild/components 9.12.0-alpha-20251204002326-2a985828907ff904a08269604e8ed510d0fd16c4 → 9.12.0-alpha-20251205170657-b03f2c5dae91cc852b7d8c0a5039d54e24eedae4
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.
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { isValidElement, useMemo, useState } from "react";
|
|
4
4
|
import fuzzy from "fuzzy";
|
|
5
|
-
import { Tabs } from "./tabs";
|
|
6
5
|
import { cn } from "../cn";
|
|
7
6
|
import { Heading } from "./heading";
|
|
8
7
|
import { CloseIcon, SearchIcon } from "./icons";
|
|
9
8
|
import { MarketplaceList } from "./marketplace-list";
|
|
9
|
+
import { Tabs } from "./tabs";
|
|
10
10
|
import { Tag, TagsContainer } from "./tag";
|
|
11
11
|
const renderQueryPlaceholder = (placeholder, query) => {
|
|
12
12
|
if (!query || isValidElement(placeholder)) {
|
|
@@ -16,8 +16,12 @@ interface TabsProps extends Pick<TabGroupProps, 'defaultIndex' | 'selectedIndex'
|
|
|
16
16
|
* @default "tab"
|
|
17
17
|
*/
|
|
18
18
|
searchParamKey?: string;
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* LocalStorage key for persisting the selected tab.
|
|
21
|
+
* Defaults to `tabs-${id}` if not provided.
|
|
22
|
+
* Set to `null` to disable localStorage persistence.
|
|
23
|
+
*/
|
|
24
|
+
storageKey?: string | null;
|
|
21
25
|
/** Tabs CSS class name. */
|
|
22
26
|
className?: TabListProps['className'];
|
|
23
27
|
/** Tab CSS class name. */
|
|
@@ -33,7 +33,9 @@ const Tabs = ({
|
|
|
33
33
|
tabClassName
|
|
34
34
|
}) => {
|
|
35
35
|
const id = useId();
|
|
36
|
-
storageKey
|
|
36
|
+
if (storageKey === void 0) {
|
|
37
|
+
storageKey = `tabs-${id}`;
|
|
38
|
+
}
|
|
37
39
|
let [selectedIndex, setSelectedIndex] = useState(defaultIndex);
|
|
38
40
|
if (_selectedIndex !== void 0) {
|
|
39
41
|
selectedIndex = _selectedIndex;
|
|
@@ -58,7 +60,16 @@ const Tabs = ({
|
|
|
58
60
|
}
|
|
59
61
|
if (searchParamKey) {
|
|
60
62
|
const searchParams = new URLSearchParams(window.location.search);
|
|
61
|
-
searchParams.
|
|
63
|
+
const tabKeys = new Set(searchParams.getAll(searchParamKey));
|
|
64
|
+
for (let i = 0; i < items.length; i++) {
|
|
65
|
+
const key = getTabKey(items, i, id);
|
|
66
|
+
tabKeys.delete(key);
|
|
67
|
+
}
|
|
68
|
+
searchParams.delete(searchParamKey);
|
|
69
|
+
for (const key of tabKeys) {
|
|
70
|
+
searchParams.append(searchParamKey, key);
|
|
71
|
+
}
|
|
72
|
+
searchParams.append(searchParamKey, getTabKey(items, index, id));
|
|
62
73
|
window.history.replaceState(
|
|
63
74
|
null,
|
|
64
75
|
"",
|
|
@@ -138,6 +149,13 @@ function useActiveTabFromURL(tabPanelsRef, items, searchParamKey, setSelectedInd
|
|
|
138
149
|
const tabIndexFromSearchParams = items.findIndex(
|
|
139
150
|
(_, index) => tabsInSearchParams.includes(getTabKey(items, index, id))
|
|
140
151
|
);
|
|
152
|
+
console.log({
|
|
153
|
+
searchParams,
|
|
154
|
+
tabIndexFromSearchParams,
|
|
155
|
+
tabsInSearchParams,
|
|
156
|
+
items,
|
|
157
|
+
id
|
|
158
|
+
});
|
|
141
159
|
useIsomorphicLayoutEffect(() => {
|
|
142
160
|
const tabPanel = hash ? tabPanelsRef.current?.querySelector(`[role=tabpanel]:has([id="${hash}"])`) : null;
|
|
143
161
|
if (tabPanel) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theguild/components",
|
|
3
|
-
"version": "9.12.0-alpha-
|
|
3
|
+
"version": "9.12.0-alpha-20251205170657-b03f2c5dae91cc852b7d8c0a5039d54e24eedae4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/the-guild-org/docs",
|
|
6
6
|
"directory": "packages/components"
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"style.css"
|
|
39
39
|
],
|
|
40
40
|
"peerDependencies": {
|
|
41
|
+
"@headlessui/react": "2.2.0",
|
|
41
42
|
"@theguild/tailwind-config": "^0.6.3",
|
|
42
43
|
"next": "^13 || ^14 || ^15.0.0",
|
|
43
44
|
"react": "^18.2.0",
|
|
44
|
-
"react-dom": "^18.2.0"
|
|
45
|
-
"@headlessui/react": "2.2.0"
|
|
45
|
+
"react-dom": "^18.2.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@giscus/react": "3.1.0",
|