@cerberus-design/react 0.2.0-next-ec538ca → 0.2.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/build/legacy/_tsup-dts-rollup.d.ts +0 -94
- package/build/legacy/index.d.ts +0 -10
- package/build/legacy/index.js +0 -18
- package/build/modern/_tsup-dts-rollup.d.ts +0 -94
- package/build/modern/index.d.ts +0 -10
- package/build/modern/index.js +0 -18
- package/package.json +1 -1
- package/src/index.ts +0 -4
- package/build/legacy/chunk-24B4KIPX.js +0 -46
- package/build/legacy/chunk-24B4KIPX.js.map +0 -1
- package/build/legacy/chunk-NVA4SWUI.js +0 -36
- package/build/legacy/chunk-NVA4SWUI.js.map +0 -1
- package/build/legacy/chunk-NWDAYAVH.js +0 -25
- package/build/legacy/chunk-NWDAYAVH.js.map +0 -1
- package/build/legacy/chunk-XVDQL4L6.js +0 -31
- package/build/legacy/chunk-XVDQL4L6.js.map +0 -1
- package/build/legacy/components/Tab.d.ts +0 -2
- package/build/legacy/components/Tab.js +0 -9
- package/build/legacy/components/Tab.js.map +0 -1
- package/build/legacy/components/TabList.d.ts +0 -2
- package/build/legacy/components/TabList.js +0 -7
- package/build/legacy/components/TabList.js.map +0 -1
- package/build/legacy/components/TabPanel.d.ts +0 -2
- package/build/legacy/components/TabPanel.js +0 -10
- package/build/legacy/components/TabPanel.js.map +0 -1
- package/build/legacy/context/tabs.d.ts +0 -4
- package/build/legacy/context/tabs.js +0 -10
- package/build/legacy/context/tabs.js.map +0 -1
- package/build/modern/chunk-24B4KIPX.js +0 -46
- package/build/modern/chunk-24B4KIPX.js.map +0 -1
- package/build/modern/chunk-NWDAYAVH.js +0 -25
- package/build/modern/chunk-NWDAYAVH.js.map +0 -1
- package/build/modern/chunk-X5PQA2JN.js +0 -35
- package/build/modern/chunk-X5PQA2JN.js.map +0 -1
- package/build/modern/chunk-XVDQL4L6.js +0 -31
- package/build/modern/chunk-XVDQL4L6.js.map +0 -1
- package/build/modern/components/Tab.d.ts +0 -2
- package/build/modern/components/Tab.js +0 -9
- package/build/modern/components/Tab.js.map +0 -1
- package/build/modern/components/TabList.d.ts +0 -2
- package/build/modern/components/TabList.js +0 -7
- package/build/modern/components/TabList.js.map +0 -1
- package/build/modern/components/TabPanel.d.ts +0 -2
- package/build/modern/components/TabPanel.js +0 -10
- package/build/modern/components/TabPanel.js.map +0 -1
- package/build/modern/context/tabs.d.ts +0 -4
- package/build/modern/context/tabs.js +0 -10
- package/build/modern/context/tabs.js.map +0 -1
- package/src/components/Tab.tsx +0 -39
- package/src/components/TabList.tsx +0 -39
- package/src/components/TabPanel.tsx +0 -28
- package/src/context/tabs.tsx +0 -83
|
@@ -277,96 +277,6 @@ declare interface ShowProps {
|
|
|
277
277
|
export { ShowProps }
|
|
278
278
|
export { ShowProps as ShowProps_alias_1 }
|
|
279
279
|
|
|
280
|
-
declare function Tab(props: TabProps): JSX_2.Element;
|
|
281
|
-
export { Tab }
|
|
282
|
-
export { Tab as Tab_alias_1 }
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* The TabList component provides a container for tab elements.
|
|
286
|
-
* @param description - a description of what the tab list contains
|
|
287
|
-
* @example
|
|
288
|
-
* ```tsx
|
|
289
|
-
* <TabList description="Button details">
|
|
290
|
-
* <Tab id="overview">Overview</Tab>
|
|
291
|
-
* <Tab id="guidelines">Guidelines</Tab>
|
|
292
|
-
* </TabList>
|
|
293
|
-
* ```
|
|
294
|
-
*/
|
|
295
|
-
declare function TabList(props: PropsWithChildren<TabListProps>): JSX_2.Element;
|
|
296
|
-
export { TabList }
|
|
297
|
-
export { TabList as TabList_alias_1 }
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* This module provides a TabList component.
|
|
301
|
-
* @module
|
|
302
|
-
*/
|
|
303
|
-
declare interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
304
|
-
description?: string;
|
|
305
|
-
}
|
|
306
|
-
export { TabListProps }
|
|
307
|
-
export { TabListProps as TabListProps_alias_1 }
|
|
308
|
-
|
|
309
|
-
declare function TabPanel(props: TabPanelProps): JSX_2.Element;
|
|
310
|
-
export { TabPanel }
|
|
311
|
-
export { TabPanel as TabPanel_alias_1 }
|
|
312
|
-
|
|
313
|
-
declare interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
314
|
-
tab: string;
|
|
315
|
-
}
|
|
316
|
-
export { TabPanelProps }
|
|
317
|
-
export { TabPanelProps as TabPanelProps_alias_1 }
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* This module provides a Tab component.
|
|
321
|
-
* @module
|
|
322
|
-
*/
|
|
323
|
-
declare interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
324
|
-
controls: string;
|
|
325
|
-
value: string;
|
|
326
|
-
}
|
|
327
|
-
export { TabProps }
|
|
328
|
-
export { TabProps as TabProps_alias_1 }
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* The Tabs component provides a context to manage tab state.
|
|
332
|
-
* @param active - the default active tab id,
|
|
333
|
-
* @param cache - whether to cache the active tab state
|
|
334
|
-
* @example
|
|
335
|
-
* ```tsx
|
|
336
|
-
* <Tabs cache>
|
|
337
|
-
* <TabList description="Button details">
|
|
338
|
-
* <Tab id="overview">Overview</Tab>
|
|
339
|
-
* <Tab id="guidelines">Guidelines</Tab>
|
|
340
|
-
* </TabList>
|
|
341
|
-
* <TabPanels>
|
|
342
|
-
* <TabPanel id="overview">Overview content</TabPanel>
|
|
343
|
-
* <TabPanel id="guidelines">Guidelines content</TabPanel>
|
|
344
|
-
* </TabPanels>
|
|
345
|
-
* </Tabs>
|
|
346
|
-
* ```
|
|
347
|
-
*/
|
|
348
|
-
declare function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element;
|
|
349
|
-
export { Tabs }
|
|
350
|
-
export { Tabs as Tabs_alias_1 }
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* This module provides a Tabs component and a hook to access its context.
|
|
354
|
-
* @module
|
|
355
|
-
*/
|
|
356
|
-
declare interface TabsContextValue {
|
|
357
|
-
active: string;
|
|
358
|
-
onTabUpdate: (active: string) => void;
|
|
359
|
-
}
|
|
360
|
-
export { TabsContextValue }
|
|
361
|
-
export { TabsContextValue as TabsContextValue_alias_1 }
|
|
362
|
-
|
|
363
|
-
declare interface TabsProps {
|
|
364
|
-
active?: string;
|
|
365
|
-
cache?: boolean;
|
|
366
|
-
}
|
|
367
|
-
export { TabsProps }
|
|
368
|
-
export { TabsProps as TabsProps_alias_1 }
|
|
369
|
-
|
|
370
280
|
declare const THEME_KEY = "cerberus-theme";
|
|
371
281
|
export { THEME_KEY }
|
|
372
282
|
export { THEME_KEY as THEME_KEY_alias_1 }
|
|
@@ -401,10 +311,6 @@ declare function useNavMenuContext(): NavMenuContextValue;
|
|
|
401
311
|
export { useNavMenuContext }
|
|
402
312
|
export { useNavMenuContext as useNavMenuContext_alias_1 }
|
|
403
313
|
|
|
404
|
-
declare function useTabsContext(): TabsContextValue;
|
|
405
|
-
export { useTabsContext }
|
|
406
|
-
export { useTabsContext as useTabsContext_alias_1 }
|
|
407
|
-
|
|
408
314
|
declare function useTheme<C extends string = DefaultThemes>(defaultTheme?: CustomThemes<C>, defaultColorMode?: ColorModes): ThemeContextValue<C>;
|
|
409
315
|
export { useTheme }
|
|
410
316
|
export { useTheme as useTheme_alias_1 }
|
package/build/legacy/index.d.ts
CHANGED
|
@@ -16,12 +16,6 @@ export { NavMenuList } from './_tsup-dts-rollup';
|
|
|
16
16
|
export { NavMenuListProps } from './_tsup-dts-rollup';
|
|
17
17
|
export { NavMenuLink } from './_tsup-dts-rollup';
|
|
18
18
|
export { NavMenuLinkProps } from './_tsup-dts-rollup';
|
|
19
|
-
export { Tab } from './_tsup-dts-rollup';
|
|
20
|
-
export { TabProps } from './_tsup-dts-rollup';
|
|
21
|
-
export { TabList } from './_tsup-dts-rollup';
|
|
22
|
-
export { TabListProps } from './_tsup-dts-rollup';
|
|
23
|
-
export { TabPanel } from './_tsup-dts-rollup';
|
|
24
|
-
export { TabPanelProps } from './_tsup-dts-rollup';
|
|
25
19
|
export { Show } from './_tsup-dts-rollup';
|
|
26
20
|
export { ShowProps } from './_tsup-dts-rollup';
|
|
27
21
|
export { Field } from './_tsup-dts-rollup';
|
|
@@ -32,10 +26,6 @@ export { useNavMenuContext } from './_tsup-dts-rollup';
|
|
|
32
26
|
export { NavTriggerRef } from './_tsup-dts-rollup';
|
|
33
27
|
export { NavMenuRef } from './_tsup-dts-rollup';
|
|
34
28
|
export { NavMenuContextValue } from './_tsup-dts-rollup';
|
|
35
|
-
export { Tabs } from './_tsup-dts-rollup';
|
|
36
|
-
export { useTabsContext } from './_tsup-dts-rollup';
|
|
37
|
-
export { TabsContextValue } from './_tsup-dts-rollup';
|
|
38
|
-
export { TabsProps } from './_tsup-dts-rollup';
|
|
39
29
|
export { ThemeProvider } from './_tsup-dts-rollup';
|
|
40
30
|
export { useThemeContext } from './_tsup-dts-rollup';
|
|
41
31
|
export { DefaultThemes } from './_tsup-dts-rollup';
|
package/build/legacy/index.js
CHANGED
|
@@ -15,19 +15,6 @@ import {
|
|
|
15
15
|
NavMenu,
|
|
16
16
|
useNavMenuContext
|
|
17
17
|
} from "./chunk-KJUCHZHV.js";
|
|
18
|
-
import {
|
|
19
|
-
Tab
|
|
20
|
-
} from "./chunk-NVA4SWUI.js";
|
|
21
|
-
import {
|
|
22
|
-
TabList
|
|
23
|
-
} from "./chunk-NWDAYAVH.js";
|
|
24
|
-
import {
|
|
25
|
-
TabPanel
|
|
26
|
-
} from "./chunk-XVDQL4L6.js";
|
|
27
|
-
import {
|
|
28
|
-
Tabs,
|
|
29
|
-
useTabsContext
|
|
30
|
-
} from "./chunk-24B4KIPX.js";
|
|
31
18
|
import "./chunk-55J6XMHW.js";
|
|
32
19
|
import {
|
|
33
20
|
createNavTriggerProps
|
|
@@ -72,16 +59,11 @@ export {
|
|
|
72
59
|
NavMenuTrigger,
|
|
73
60
|
Show,
|
|
74
61
|
THEME_KEY,
|
|
75
|
-
Tab,
|
|
76
|
-
TabList,
|
|
77
|
-
TabPanel,
|
|
78
|
-
Tabs,
|
|
79
62
|
ThemeProvider,
|
|
80
63
|
createNavTriggerProps,
|
|
81
64
|
getPosition,
|
|
82
65
|
useFieldContext,
|
|
83
66
|
useNavMenuContext,
|
|
84
|
-
useTabsContext,
|
|
85
67
|
useTheme,
|
|
86
68
|
useThemeContext
|
|
87
69
|
};
|
|
@@ -277,96 +277,6 @@ declare interface ShowProps {
|
|
|
277
277
|
export { ShowProps }
|
|
278
278
|
export { ShowProps as ShowProps_alias_1 }
|
|
279
279
|
|
|
280
|
-
declare function Tab(props: TabProps): JSX_2.Element;
|
|
281
|
-
export { Tab }
|
|
282
|
-
export { Tab as Tab_alias_1 }
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* The TabList component provides a container for tab elements.
|
|
286
|
-
* @param description - a description of what the tab list contains
|
|
287
|
-
* @example
|
|
288
|
-
* ```tsx
|
|
289
|
-
* <TabList description="Button details">
|
|
290
|
-
* <Tab id="overview">Overview</Tab>
|
|
291
|
-
* <Tab id="guidelines">Guidelines</Tab>
|
|
292
|
-
* </TabList>
|
|
293
|
-
* ```
|
|
294
|
-
*/
|
|
295
|
-
declare function TabList(props: PropsWithChildren<TabListProps>): JSX_2.Element;
|
|
296
|
-
export { TabList }
|
|
297
|
-
export { TabList as TabList_alias_1 }
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* This module provides a TabList component.
|
|
301
|
-
* @module
|
|
302
|
-
*/
|
|
303
|
-
declare interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
304
|
-
description?: string;
|
|
305
|
-
}
|
|
306
|
-
export { TabListProps }
|
|
307
|
-
export { TabListProps as TabListProps_alias_1 }
|
|
308
|
-
|
|
309
|
-
declare function TabPanel(props: TabPanelProps): JSX_2.Element;
|
|
310
|
-
export { TabPanel }
|
|
311
|
-
export { TabPanel as TabPanel_alias_1 }
|
|
312
|
-
|
|
313
|
-
declare interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
314
|
-
tab: string;
|
|
315
|
-
}
|
|
316
|
-
export { TabPanelProps }
|
|
317
|
-
export { TabPanelProps as TabPanelProps_alias_1 }
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* This module provides a Tab component.
|
|
321
|
-
* @module
|
|
322
|
-
*/
|
|
323
|
-
declare interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
324
|
-
controls: string;
|
|
325
|
-
value: string;
|
|
326
|
-
}
|
|
327
|
-
export { TabProps }
|
|
328
|
-
export { TabProps as TabProps_alias_1 }
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* The Tabs component provides a context to manage tab state.
|
|
332
|
-
* @param active - the default active tab id,
|
|
333
|
-
* @param cache - whether to cache the active tab state
|
|
334
|
-
* @example
|
|
335
|
-
* ```tsx
|
|
336
|
-
* <Tabs cache>
|
|
337
|
-
* <TabList description="Button details">
|
|
338
|
-
* <Tab id="overview">Overview</Tab>
|
|
339
|
-
* <Tab id="guidelines">Guidelines</Tab>
|
|
340
|
-
* </TabList>
|
|
341
|
-
* <TabPanels>
|
|
342
|
-
* <TabPanel id="overview">Overview content</TabPanel>
|
|
343
|
-
* <TabPanel id="guidelines">Guidelines content</TabPanel>
|
|
344
|
-
* </TabPanels>
|
|
345
|
-
* </Tabs>
|
|
346
|
-
* ```
|
|
347
|
-
*/
|
|
348
|
-
declare function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element;
|
|
349
|
-
export { Tabs }
|
|
350
|
-
export { Tabs as Tabs_alias_1 }
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* This module provides a Tabs component and a hook to access its context.
|
|
354
|
-
* @module
|
|
355
|
-
*/
|
|
356
|
-
declare interface TabsContextValue {
|
|
357
|
-
active: string;
|
|
358
|
-
onTabUpdate: (active: string) => void;
|
|
359
|
-
}
|
|
360
|
-
export { TabsContextValue }
|
|
361
|
-
export { TabsContextValue as TabsContextValue_alias_1 }
|
|
362
|
-
|
|
363
|
-
declare interface TabsProps {
|
|
364
|
-
active?: string;
|
|
365
|
-
cache?: boolean;
|
|
366
|
-
}
|
|
367
|
-
export { TabsProps }
|
|
368
|
-
export { TabsProps as TabsProps_alias_1 }
|
|
369
|
-
|
|
370
280
|
declare const THEME_KEY = "cerberus-theme";
|
|
371
281
|
export { THEME_KEY }
|
|
372
282
|
export { THEME_KEY as THEME_KEY_alias_1 }
|
|
@@ -401,10 +311,6 @@ declare function useNavMenuContext(): NavMenuContextValue;
|
|
|
401
311
|
export { useNavMenuContext }
|
|
402
312
|
export { useNavMenuContext as useNavMenuContext_alias_1 }
|
|
403
313
|
|
|
404
|
-
declare function useTabsContext(): TabsContextValue;
|
|
405
|
-
export { useTabsContext }
|
|
406
|
-
export { useTabsContext as useTabsContext_alias_1 }
|
|
407
|
-
|
|
408
314
|
declare function useTheme<C extends string = DefaultThemes>(defaultTheme?: CustomThemes<C>, defaultColorMode?: ColorModes): ThemeContextValue<C>;
|
|
409
315
|
export { useTheme }
|
|
410
316
|
export { useTheme as useTheme_alias_1 }
|
package/build/modern/index.d.ts
CHANGED
|
@@ -16,12 +16,6 @@ export { NavMenuList } from './_tsup-dts-rollup';
|
|
|
16
16
|
export { NavMenuListProps } from './_tsup-dts-rollup';
|
|
17
17
|
export { NavMenuLink } from './_tsup-dts-rollup';
|
|
18
18
|
export { NavMenuLinkProps } from './_tsup-dts-rollup';
|
|
19
|
-
export { Tab } from './_tsup-dts-rollup';
|
|
20
|
-
export { TabProps } from './_tsup-dts-rollup';
|
|
21
|
-
export { TabList } from './_tsup-dts-rollup';
|
|
22
|
-
export { TabListProps } from './_tsup-dts-rollup';
|
|
23
|
-
export { TabPanel } from './_tsup-dts-rollup';
|
|
24
|
-
export { TabPanelProps } from './_tsup-dts-rollup';
|
|
25
19
|
export { Show } from './_tsup-dts-rollup';
|
|
26
20
|
export { ShowProps } from './_tsup-dts-rollup';
|
|
27
21
|
export { Field } from './_tsup-dts-rollup';
|
|
@@ -32,10 +26,6 @@ export { useNavMenuContext } from './_tsup-dts-rollup';
|
|
|
32
26
|
export { NavTriggerRef } from './_tsup-dts-rollup';
|
|
33
27
|
export { NavMenuRef } from './_tsup-dts-rollup';
|
|
34
28
|
export { NavMenuContextValue } from './_tsup-dts-rollup';
|
|
35
|
-
export { Tabs } from './_tsup-dts-rollup';
|
|
36
|
-
export { useTabsContext } from './_tsup-dts-rollup';
|
|
37
|
-
export { TabsContextValue } from './_tsup-dts-rollup';
|
|
38
|
-
export { TabsProps } from './_tsup-dts-rollup';
|
|
39
29
|
export { ThemeProvider } from './_tsup-dts-rollup';
|
|
40
30
|
export { useThemeContext } from './_tsup-dts-rollup';
|
|
41
31
|
export { DefaultThemes } from './_tsup-dts-rollup';
|
package/build/modern/index.js
CHANGED
|
@@ -15,19 +15,6 @@ import {
|
|
|
15
15
|
NavMenu,
|
|
16
16
|
useNavMenuContext
|
|
17
17
|
} from "./chunk-KJUCHZHV.js";
|
|
18
|
-
import {
|
|
19
|
-
Tab
|
|
20
|
-
} from "./chunk-X5PQA2JN.js";
|
|
21
|
-
import {
|
|
22
|
-
TabList
|
|
23
|
-
} from "./chunk-NWDAYAVH.js";
|
|
24
|
-
import {
|
|
25
|
-
TabPanel
|
|
26
|
-
} from "./chunk-XVDQL4L6.js";
|
|
27
|
-
import {
|
|
28
|
-
Tabs,
|
|
29
|
-
useTabsContext
|
|
30
|
-
} from "./chunk-24B4KIPX.js";
|
|
31
18
|
import "./chunk-55J6XMHW.js";
|
|
32
19
|
import {
|
|
33
20
|
createNavTriggerProps
|
|
@@ -72,16 +59,11 @@ export {
|
|
|
72
59
|
NavMenuTrigger,
|
|
73
60
|
Show,
|
|
74
61
|
THEME_KEY,
|
|
75
|
-
Tab,
|
|
76
|
-
TabList,
|
|
77
|
-
TabPanel,
|
|
78
|
-
Tabs,
|
|
79
62
|
ThemeProvider,
|
|
80
63
|
createNavTriggerProps,
|
|
81
64
|
getPosition,
|
|
82
65
|
useFieldContext,
|
|
83
66
|
useNavMenuContext,
|
|
84
|
-
useTabsContext,
|
|
85
67
|
useTheme,
|
|
86
68
|
useThemeContext
|
|
87
69
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -13,16 +13,12 @@ export * from './components/Label'
|
|
|
13
13
|
export * from './components/NavMenuTrigger'
|
|
14
14
|
export * from './components/NavMenuList'
|
|
15
15
|
export * from './components/NavMenuLink'
|
|
16
|
-
export * from './components/Tab'
|
|
17
|
-
export * from './components/TabList'
|
|
18
|
-
export * from './components/TabPanel'
|
|
19
16
|
export * from './components/Show'
|
|
20
17
|
|
|
21
18
|
// context
|
|
22
19
|
|
|
23
20
|
export * from './context/field'
|
|
24
21
|
export * from './context/navMenu'
|
|
25
|
-
export * from './context/tabs'
|
|
26
22
|
export * from './context/theme'
|
|
27
23
|
|
|
28
24
|
// hooks
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// src/context/tabs.tsx
|
|
2
|
-
import {
|
|
3
|
-
createContext,
|
|
4
|
-
useContext,
|
|
5
|
-
useEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
useState
|
|
8
|
-
} from "react";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
var TabsContext = createContext(null);
|
|
11
|
-
function Tabs(props) {
|
|
12
|
-
const { cache } = props;
|
|
13
|
-
const [active, setActive] = useState(() => props.active ?? "");
|
|
14
|
-
const value = useMemo(
|
|
15
|
-
() => ({
|
|
16
|
-
active,
|
|
17
|
-
onTabUpdate: setActive
|
|
18
|
-
}),
|
|
19
|
-
[active, setActive]
|
|
20
|
-
);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (cache) {
|
|
23
|
-
const cachedTab = window.localStorage.getItem("cerberus-tabs");
|
|
24
|
-
setActive(cachedTab ?? active);
|
|
25
|
-
}
|
|
26
|
-
}, [cache]);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (cache) {
|
|
29
|
-
window.localStorage.setItem("cerberus-tabs", active);
|
|
30
|
-
}
|
|
31
|
-
}, [active, cache]);
|
|
32
|
-
return /* @__PURE__ */ jsx(TabsContext.Provider, { value, children: props.children });
|
|
33
|
-
}
|
|
34
|
-
function useTabsContext() {
|
|
35
|
-
const context = useContext(TabsContext);
|
|
36
|
-
if (!context) {
|
|
37
|
-
throw new Error("useTabsContext must be used within a Tabs Provider.");
|
|
38
|
-
}
|
|
39
|
-
return context;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
Tabs,
|
|
44
|
-
useTabsContext
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=chunk-24B4KIPX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/tabs.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type PropsWithChildren,\n} from 'react'\n\n/**\n * This module provides a Tabs component and a hook to access its context.\n * @module\n */\n\nexport interface TabsContextValue {\n active: string\n onTabUpdate: (active: string) => void\n}\n\nconst TabsContext = createContext<TabsContextValue | null>(null)\n\nexport interface TabsProps {\n active?: string\n cache?: boolean\n}\n\n/**\n * The Tabs component provides a context to manage tab state.\n * @param active - the default active tab id,\n * @param cache - whether to cache the active tab state\n * @example\n * ```tsx\n * <Tabs cache>\n * <TabList description=\"Button details\">\n * <Tab id=\"overview\">Overview</Tab>\n * <Tab id=\"guidelines\">Guidelines</Tab>\n * </TabList>\n * <TabPanels>\n * <TabPanel id=\"overview\">Overview content</TabPanel>\n * <TabPanel id=\"guidelines\">Guidelines content</TabPanel>\n * </TabPanels>\n * </Tabs>\n * ```\n */\nexport function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element {\n const { cache } = props\n const [active, setActive] = useState(() => props.active ?? '')\n\n const value = useMemo(\n () => ({\n active,\n onTabUpdate: setActive,\n }),\n [active, setActive],\n )\n\n useEffect(() => {\n if (cache) {\n const cachedTab = window.localStorage.getItem('cerberus-tabs')\n setActive(cachedTab ?? active)\n }\n }, [cache])\n\n useEffect(() => {\n if (cache) {\n window.localStorage.setItem('cerberus-tabs', active)\n }\n }, [active, cache])\n\n return (\n <TabsContext.Provider value={value}>{props.children}</TabsContext.Provider>\n )\n}\n\nexport function useTabsContext(): TabsContextValue {\n const context = useContext(TabsContext)\n if (!context) {\n throw new Error('useTabsContext must be used within a Tabs Provider.')\n }\n return context\n}\n"],"mappings":";AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AA+DH;AAnDJ,IAAM,cAAc,cAAuC,IAAI;AAyBxD,SAAS,KAAK,OAAkD;AACrE,QAAM,EAAE,MAAM,IAAI;AAClB,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,MAAM,MAAM,UAAU,EAAE;AAE7D,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA,aAAa;AAAA,IACf;AAAA,IACA,CAAC,QAAQ,SAAS;AAAA,EACpB;AAEA,YAAU,MAAM;AACd,QAAI,OAAO;AACT,YAAM,YAAY,OAAO,aAAa,QAAQ,eAAe;AAC7D,gBAAU,aAAa,MAAM;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,KAAK,CAAC;AAEV,YAAU,MAAM;AACd,QAAI,OAAO;AACT,aAAO,aAAa,QAAQ,iBAAiB,MAAM;AAAA,IACrD;AAAA,EACF,GAAG,CAAC,QAAQ,KAAK,CAAC;AAElB,SACE,oBAAC,YAAY,UAAZ,EAAqB,OAAe,gBAAM,UAAS;AAExD;AAEO,SAAS,iBAAmC;AACjD,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useTabsContext
|
|
3
|
-
} from "./chunk-24B4KIPX.js";
|
|
4
|
-
|
|
5
|
-
// src/components/Tab.tsx
|
|
6
|
-
import { useMemo } from "react";
|
|
7
|
-
import { css, cx } from "@cerberus/styled-system/css";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
function Tab(props) {
|
|
10
|
-
const { controls, value, ...nativeProps } = props;
|
|
11
|
-
const { active, onTabUpdate } = useTabsContext();
|
|
12
|
-
const isActive = useMemo(() => active === value, [active, value]);
|
|
13
|
-
function handleClick(e) {
|
|
14
|
-
var _a;
|
|
15
|
-
(_a = props.onClick) == null ? void 0 : _a.call(props, e);
|
|
16
|
-
onTabUpdate(e.currentTarget.value);
|
|
17
|
-
}
|
|
18
|
-
return /* @__PURE__ */ jsx(
|
|
19
|
-
"button",
|
|
20
|
-
{
|
|
21
|
-
...nativeProps,
|
|
22
|
-
...!isActive && { tabIndex: -1 },
|
|
23
|
-
"aria-controls": controls,
|
|
24
|
-
"aria-selected": isActive,
|
|
25
|
-
className: cx(nativeProps.className, css()),
|
|
26
|
-
onClick: handleClick,
|
|
27
|
-
role: "tab",
|
|
28
|
-
value
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
Tab
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=chunk-NVA4SWUI.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Tab.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type ButtonHTMLAttributes, type MouseEvent } from 'react'\nimport { useTabsContext } from '../context/tabs'\nimport { css, cx } from '@cerberus/styled-system/css'\n\n/**\n * This module provides a Tab component.\n * @module\n */\n\nexport interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n controls: string\n value: string\n}\n\nexport function Tab(props: TabProps) {\n const { controls, value, ...nativeProps } = props\n const { active, onTabUpdate } = useTabsContext()\n const isActive = useMemo(() => active === value, [active, value])\n\n function handleClick(e: MouseEvent<HTMLButtonElement>) {\n props.onClick?.(e)\n onTabUpdate(e.currentTarget.value)\n }\n\n return (\n <button\n {...nativeProps}\n {...(!isActive && { tabIndex: -1 })}\n aria-controls={controls}\n aria-selected={isActive}\n className={cx(nativeProps.className, css())}\n onClick={handleClick}\n role=\"tab\"\n value={value}\n />\n )\n}\n"],"mappings":";;;;;AAEA,SAAS,eAA2D;AAEpE,SAAS,KAAK,UAAU;AAuBpB;AAXG,SAAS,IAAI,OAAiB;AACnC,QAAM,EAAE,UAAU,OAAO,GAAG,YAAY,IAAI;AAC5C,QAAM,EAAE,QAAQ,YAAY,IAAI,eAAe;AAC/C,QAAM,WAAW,QAAQ,MAAM,WAAW,OAAO,CAAC,QAAQ,KAAK,CAAC;AAEhE,WAAS,YAAY,GAAkC;AArBzD;AAsBI,gBAAM,YAAN,+BAAgB;AAChB,gBAAY,EAAE,cAAc,KAAK;AAAA,EACnC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAI,CAAC,YAAY,EAAE,UAAU,GAAG;AAAA,MACjC,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,WAAW,GAAG,YAAY,WAAW,IAAI,CAAC;AAAA,MAC1C,SAAS;AAAA,MACT,MAAK;AAAA,MACL;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// src/components/TabList.tsx
|
|
2
|
-
import { cx } from "@cerberus/styled-system/css";
|
|
3
|
-
import { hstack } from "@cerberus/styled-system/patterns";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
function TabList(props) {
|
|
6
|
-
const { description, ...nativeProps } = props;
|
|
7
|
-
return /* @__PURE__ */ jsx(
|
|
8
|
-
"div",
|
|
9
|
-
{
|
|
10
|
-
...nativeProps,
|
|
11
|
-
"aria-describedby": description,
|
|
12
|
-
className: cx(
|
|
13
|
-
nativeProps.className,
|
|
14
|
-
hstack({
|
|
15
|
-
gap: "0"
|
|
16
|
-
})
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
TabList
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=chunk-NWDAYAVH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/TabList.tsx"],"sourcesContent":["import { cx } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\n\n/**\n * This module provides a TabList component.\n * @module\n */\n\nexport interface TabListProps extends HTMLAttributes<HTMLDivElement> {\n description?: string\n}\n\n/**\n * The TabList component provides a container for tab elements.\n * @param description - a description of what the tab list contains\n * @example\n * ```tsx\n * <TabList description=\"Button details\">\n * <Tab id=\"overview\">Overview</Tab>\n * <Tab id=\"guidelines\">Guidelines</Tab>\n * </TabList>\n * ```\n */\nexport function TabList(props: PropsWithChildren<TabListProps>) {\n const { description, ...nativeProps } = props\n return (\n <div\n {...nativeProps}\n aria-describedby={description}\n className={cx(\n nativeProps.className,\n hstack({\n gap: '0',\n }),\n )}\n />\n )\n}\n"],"mappings":";AAAA,SAAS,UAAU;AACnB,SAAS,cAAc;AA0BnB;AAHG,SAAS,QAAQ,OAAwC;AAC9D,QAAM,EAAE,aAAa,GAAG,YAAY,IAAI;AACxC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,oBAAkB;AAAA,MAClB,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,OAAO;AAAA,UACL,KAAK;AAAA,QACP,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useTabsContext
|
|
3
|
-
} from "./chunk-24B4KIPX.js";
|
|
4
|
-
import {
|
|
5
|
-
Show
|
|
6
|
-
} from "./chunk-R4H3352X.js";
|
|
7
|
-
|
|
8
|
-
// src/components/TabPanel.tsx
|
|
9
|
-
import { css, cx } from "@cerberus/styled-system/css";
|
|
10
|
-
import { useMemo } from "react";
|
|
11
|
-
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
function TabPanel(props) {
|
|
13
|
-
const { tab, ...nativeProps } = props;
|
|
14
|
-
const { active } = useTabsContext();
|
|
15
|
-
const isActive = useMemo(() => active === tab, [active, tab]);
|
|
16
|
-
return /* @__PURE__ */ jsx(Show, { when: isActive, children: /* @__PURE__ */ jsx(
|
|
17
|
-
"div",
|
|
18
|
-
{
|
|
19
|
-
...nativeProps,
|
|
20
|
-
...isActive && { tabIndex: 0 },
|
|
21
|
-
"aria-labelledby": tab,
|
|
22
|
-
className: cx(nativeProps.className, css()),
|
|
23
|
-
role: "tabpanel"
|
|
24
|
-
}
|
|
25
|
-
) });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
TabPanel
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=chunk-XVDQL4L6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/TabPanel.tsx"],"sourcesContent":["'use client'\n\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { useMemo, type HTMLAttributes } from 'react'\nimport { useTabsContext } from '../context/tabs'\nimport { Show } from './Show'\n\nexport interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {\n tab: string\n}\n\nexport function TabPanel(props: TabPanelProps) {\n const { tab, ...nativeProps } = props\n const { active } = useTabsContext()\n const isActive = useMemo(() => active === tab, [active, tab])\n\n return (\n <Show when={isActive}>\n <div\n {...nativeProps}\n {...(isActive && { tabIndex: 0 })}\n aria-labelledby={tab}\n className={cx(nativeProps.className, css())}\n role=\"tabpanel\"\n />\n </Show>\n )\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,KAAK,UAAU;AACxB,SAAS,eAAoC;AAevC;AAPC,SAAS,SAAS,OAAsB;AAC7C,QAAM,EAAE,KAAK,GAAG,YAAY,IAAI;AAChC,QAAM,EAAE,OAAO,IAAI,eAAe;AAClC,QAAM,WAAW,QAAQ,MAAM,WAAW,KAAK,CAAC,QAAQ,GAAG,CAAC;AAE5D,SACE,oBAAC,QAAK,MAAM,UACV;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAI,YAAY,EAAE,UAAU,EAAE;AAAA,MAC/B,mBAAiB;AAAA,MACjB,WAAW,GAAG,YAAY,WAAW,IAAI,CAAC;AAAA,MAC1C,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { Tabs_alias_1 as Tabs } from '../_tsup-dts-rollup';
|
|
2
|
-
export { useTabsContext_alias_1 as useTabsContext } from '../_tsup-dts-rollup';
|
|
3
|
-
export { TabsContextValue_alias_1 as TabsContextValue } from '../_tsup-dts-rollup';
|
|
4
|
-
export { TabsProps_alias_1 as TabsProps } from '../_tsup-dts-rollup';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// src/context/tabs.tsx
|
|
2
|
-
import {
|
|
3
|
-
createContext,
|
|
4
|
-
useContext,
|
|
5
|
-
useEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
useState
|
|
8
|
-
} from "react";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
var TabsContext = createContext(null);
|
|
11
|
-
function Tabs(props) {
|
|
12
|
-
const { cache } = props;
|
|
13
|
-
const [active, setActive] = useState(() => props.active ?? "");
|
|
14
|
-
const value = useMemo(
|
|
15
|
-
() => ({
|
|
16
|
-
active,
|
|
17
|
-
onTabUpdate: setActive
|
|
18
|
-
}),
|
|
19
|
-
[active, setActive]
|
|
20
|
-
);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (cache) {
|
|
23
|
-
const cachedTab = window.localStorage.getItem("cerberus-tabs");
|
|
24
|
-
setActive(cachedTab ?? active);
|
|
25
|
-
}
|
|
26
|
-
}, [cache]);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (cache) {
|
|
29
|
-
window.localStorage.setItem("cerberus-tabs", active);
|
|
30
|
-
}
|
|
31
|
-
}, [active, cache]);
|
|
32
|
-
return /* @__PURE__ */ jsx(TabsContext.Provider, { value, children: props.children });
|
|
33
|
-
}
|
|
34
|
-
function useTabsContext() {
|
|
35
|
-
const context = useContext(TabsContext);
|
|
36
|
-
if (!context) {
|
|
37
|
-
throw new Error("useTabsContext must be used within a Tabs Provider.");
|
|
38
|
-
}
|
|
39
|
-
return context;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
Tabs,
|
|
44
|
-
useTabsContext
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=chunk-24B4KIPX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/tabs.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type PropsWithChildren,\n} from 'react'\n\n/**\n * This module provides a Tabs component and a hook to access its context.\n * @module\n */\n\nexport interface TabsContextValue {\n active: string\n onTabUpdate: (active: string) => void\n}\n\nconst TabsContext = createContext<TabsContextValue | null>(null)\n\nexport interface TabsProps {\n active?: string\n cache?: boolean\n}\n\n/**\n * The Tabs component provides a context to manage tab state.\n * @param active - the default active tab id,\n * @param cache - whether to cache the active tab state\n * @example\n * ```tsx\n * <Tabs cache>\n * <TabList description=\"Button details\">\n * <Tab id=\"overview\">Overview</Tab>\n * <Tab id=\"guidelines\">Guidelines</Tab>\n * </TabList>\n * <TabPanels>\n * <TabPanel id=\"overview\">Overview content</TabPanel>\n * <TabPanel id=\"guidelines\">Guidelines content</TabPanel>\n * </TabPanels>\n * </Tabs>\n * ```\n */\nexport function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element {\n const { cache } = props\n const [active, setActive] = useState(() => props.active ?? '')\n\n const value = useMemo(\n () => ({\n active,\n onTabUpdate: setActive,\n }),\n [active, setActive],\n )\n\n useEffect(() => {\n if (cache) {\n const cachedTab = window.localStorage.getItem('cerberus-tabs')\n setActive(cachedTab ?? active)\n }\n }, [cache])\n\n useEffect(() => {\n if (cache) {\n window.localStorage.setItem('cerberus-tabs', active)\n }\n }, [active, cache])\n\n return (\n <TabsContext.Provider value={value}>{props.children}</TabsContext.Provider>\n )\n}\n\nexport function useTabsContext(): TabsContextValue {\n const context = useContext(TabsContext)\n if (!context) {\n throw new Error('useTabsContext must be used within a Tabs Provider.')\n }\n return context\n}\n"],"mappings":";AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AA+DH;AAnDJ,IAAM,cAAc,cAAuC,IAAI;AAyBxD,SAAS,KAAK,OAAkD;AACrE,QAAM,EAAE,MAAM,IAAI;AAClB,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,MAAM,MAAM,UAAU,EAAE;AAE7D,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA,aAAa;AAAA,IACf;AAAA,IACA,CAAC,QAAQ,SAAS;AAAA,EACpB;AAEA,YAAU,MAAM;AACd,QAAI,OAAO;AACT,YAAM,YAAY,OAAO,aAAa,QAAQ,eAAe;AAC7D,gBAAU,aAAa,MAAM;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,KAAK,CAAC;AAEV,YAAU,MAAM;AACd,QAAI,OAAO;AACT,aAAO,aAAa,QAAQ,iBAAiB,MAAM;AAAA,IACrD;AAAA,EACF,GAAG,CAAC,QAAQ,KAAK,CAAC;AAElB,SACE,oBAAC,YAAY,UAAZ,EAAqB,OAAe,gBAAM,UAAS;AAExD;AAEO,SAAS,iBAAmC;AACjD,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// src/components/TabList.tsx
|
|
2
|
-
import { cx } from "@cerberus/styled-system/css";
|
|
3
|
-
import { hstack } from "@cerberus/styled-system/patterns";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
function TabList(props) {
|
|
6
|
-
const { description, ...nativeProps } = props;
|
|
7
|
-
return /* @__PURE__ */ jsx(
|
|
8
|
-
"div",
|
|
9
|
-
{
|
|
10
|
-
...nativeProps,
|
|
11
|
-
"aria-describedby": description,
|
|
12
|
-
className: cx(
|
|
13
|
-
nativeProps.className,
|
|
14
|
-
hstack({
|
|
15
|
-
gap: "0"
|
|
16
|
-
})
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
TabList
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=chunk-NWDAYAVH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/TabList.tsx"],"sourcesContent":["import { cx } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport type { HTMLAttributes, PropsWithChildren } from 'react'\n\n/**\n * This module provides a TabList component.\n * @module\n */\n\nexport interface TabListProps extends HTMLAttributes<HTMLDivElement> {\n description?: string\n}\n\n/**\n * The TabList component provides a container for tab elements.\n * @param description - a description of what the tab list contains\n * @example\n * ```tsx\n * <TabList description=\"Button details\">\n * <Tab id=\"overview\">Overview</Tab>\n * <Tab id=\"guidelines\">Guidelines</Tab>\n * </TabList>\n * ```\n */\nexport function TabList(props: PropsWithChildren<TabListProps>) {\n const { description, ...nativeProps } = props\n return (\n <div\n {...nativeProps}\n aria-describedby={description}\n className={cx(\n nativeProps.className,\n hstack({\n gap: '0',\n }),\n )}\n />\n )\n}\n"],"mappings":";AAAA,SAAS,UAAU;AACnB,SAAS,cAAc;AA0BnB;AAHG,SAAS,QAAQ,OAAwC;AAC9D,QAAM,EAAE,aAAa,GAAG,YAAY,IAAI;AACxC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,oBAAkB;AAAA,MAClB,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,OAAO;AAAA,UACL,KAAK;AAAA,QACP,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useTabsContext
|
|
3
|
-
} from "./chunk-24B4KIPX.js";
|
|
4
|
-
|
|
5
|
-
// src/components/Tab.tsx
|
|
6
|
-
import { useMemo } from "react";
|
|
7
|
-
import { css, cx } from "@cerberus/styled-system/css";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
function Tab(props) {
|
|
10
|
-
const { controls, value, ...nativeProps } = props;
|
|
11
|
-
const { active, onTabUpdate } = useTabsContext();
|
|
12
|
-
const isActive = useMemo(() => active === value, [active, value]);
|
|
13
|
-
function handleClick(e) {
|
|
14
|
-
props.onClick?.(e);
|
|
15
|
-
onTabUpdate(e.currentTarget.value);
|
|
16
|
-
}
|
|
17
|
-
return /* @__PURE__ */ jsx(
|
|
18
|
-
"button",
|
|
19
|
-
{
|
|
20
|
-
...nativeProps,
|
|
21
|
-
...!isActive && { tabIndex: -1 },
|
|
22
|
-
"aria-controls": controls,
|
|
23
|
-
"aria-selected": isActive,
|
|
24
|
-
className: cx(nativeProps.className, css()),
|
|
25
|
-
onClick: handleClick,
|
|
26
|
-
role: "tab",
|
|
27
|
-
value
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
Tab
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=chunk-X5PQA2JN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Tab.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type ButtonHTMLAttributes, type MouseEvent } from 'react'\nimport { useTabsContext } from '../context/tabs'\nimport { css, cx } from '@cerberus/styled-system/css'\n\n/**\n * This module provides a Tab component.\n * @module\n */\n\nexport interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n controls: string\n value: string\n}\n\nexport function Tab(props: TabProps) {\n const { controls, value, ...nativeProps } = props\n const { active, onTabUpdate } = useTabsContext()\n const isActive = useMemo(() => active === value, [active, value])\n\n function handleClick(e: MouseEvent<HTMLButtonElement>) {\n props.onClick?.(e)\n onTabUpdate(e.currentTarget.value)\n }\n\n return (\n <button\n {...nativeProps}\n {...(!isActive && { tabIndex: -1 })}\n aria-controls={controls}\n aria-selected={isActive}\n className={cx(nativeProps.className, css())}\n onClick={handleClick}\n role=\"tab\"\n value={value}\n />\n )\n}\n"],"mappings":";;;;;AAEA,SAAS,eAA2D;AAEpE,SAAS,KAAK,UAAU;AAuBpB;AAXG,SAAS,IAAI,OAAiB;AACnC,QAAM,EAAE,UAAU,OAAO,GAAG,YAAY,IAAI;AAC5C,QAAM,EAAE,QAAQ,YAAY,IAAI,eAAe;AAC/C,QAAM,WAAW,QAAQ,MAAM,WAAW,OAAO,CAAC,QAAQ,KAAK,CAAC;AAEhE,WAAS,YAAY,GAAkC;AACrD,UAAM,UAAU,CAAC;AACjB,gBAAY,EAAE,cAAc,KAAK;AAAA,EACnC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAI,CAAC,YAAY,EAAE,UAAU,GAAG;AAAA,MACjC,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,WAAW,GAAG,YAAY,WAAW,IAAI,CAAC;AAAA,MAC1C,SAAS;AAAA,MACT,MAAK;AAAA,MACL;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useTabsContext
|
|
3
|
-
} from "./chunk-24B4KIPX.js";
|
|
4
|
-
import {
|
|
5
|
-
Show
|
|
6
|
-
} from "./chunk-R4H3352X.js";
|
|
7
|
-
|
|
8
|
-
// src/components/TabPanel.tsx
|
|
9
|
-
import { css, cx } from "@cerberus/styled-system/css";
|
|
10
|
-
import { useMemo } from "react";
|
|
11
|
-
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
function TabPanel(props) {
|
|
13
|
-
const { tab, ...nativeProps } = props;
|
|
14
|
-
const { active } = useTabsContext();
|
|
15
|
-
const isActive = useMemo(() => active === tab, [active, tab]);
|
|
16
|
-
return /* @__PURE__ */ jsx(Show, { when: isActive, children: /* @__PURE__ */ jsx(
|
|
17
|
-
"div",
|
|
18
|
-
{
|
|
19
|
-
...nativeProps,
|
|
20
|
-
...isActive && { tabIndex: 0 },
|
|
21
|
-
"aria-labelledby": tab,
|
|
22
|
-
className: cx(nativeProps.className, css()),
|
|
23
|
-
role: "tabpanel"
|
|
24
|
-
}
|
|
25
|
-
) });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
TabPanel
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=chunk-XVDQL4L6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/TabPanel.tsx"],"sourcesContent":["'use client'\n\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { useMemo, type HTMLAttributes } from 'react'\nimport { useTabsContext } from '../context/tabs'\nimport { Show } from './Show'\n\nexport interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {\n tab: string\n}\n\nexport function TabPanel(props: TabPanelProps) {\n const { tab, ...nativeProps } = props\n const { active } = useTabsContext()\n const isActive = useMemo(() => active === tab, [active, tab])\n\n return (\n <Show when={isActive}>\n <div\n {...nativeProps}\n {...(isActive && { tabIndex: 0 })}\n aria-labelledby={tab}\n className={cx(nativeProps.className, css())}\n role=\"tabpanel\"\n />\n </Show>\n )\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,KAAK,UAAU;AACxB,SAAS,eAAoC;AAevC;AAPC,SAAS,SAAS,OAAsB;AAC7C,QAAM,EAAE,KAAK,GAAG,YAAY,IAAI;AAChC,QAAM,EAAE,OAAO,IAAI,eAAe;AAClC,QAAM,WAAW,QAAQ,MAAM,WAAW,KAAK,CAAC,QAAQ,GAAG,CAAC;AAE5D,SACE,oBAAC,QAAK,MAAM,UACV;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACH,GAAI,YAAY,EAAE,UAAU,EAAE;AAAA,MAC/B,mBAAiB;AAAA,MACjB,WAAW,GAAG,YAAY,WAAW,IAAI,CAAC;AAAA,MAC1C,MAAK;AAAA;AAAA,EACP,GACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { Tabs_alias_1 as Tabs } from '../_tsup-dts-rollup';
|
|
2
|
-
export { useTabsContext_alias_1 as useTabsContext } from '../_tsup-dts-rollup';
|
|
3
|
-
export { TabsContextValue_alias_1 as TabsContextValue } from '../_tsup-dts-rollup';
|
|
4
|
-
export { TabsProps_alias_1 as TabsProps } from '../_tsup-dts-rollup';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/src/components/Tab.tsx
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useMemo, type ButtonHTMLAttributes, type MouseEvent } from 'react'
|
|
4
|
-
import { useTabsContext } from '../context/tabs'
|
|
5
|
-
import { css, cx } from '@cerberus/styled-system/css'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This module provides a Tab component.
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
13
|
-
controls: string
|
|
14
|
-
value: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function Tab(props: TabProps) {
|
|
18
|
-
const { controls, value, ...nativeProps } = props
|
|
19
|
-
const { active, onTabUpdate } = useTabsContext()
|
|
20
|
-
const isActive = useMemo(() => active === value, [active, value])
|
|
21
|
-
|
|
22
|
-
function handleClick(e: MouseEvent<HTMLButtonElement>) {
|
|
23
|
-
props.onClick?.(e)
|
|
24
|
-
onTabUpdate(e.currentTarget.value)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<button
|
|
29
|
-
{...nativeProps}
|
|
30
|
-
{...(!isActive && { tabIndex: -1 })}
|
|
31
|
-
aria-controls={controls}
|
|
32
|
-
aria-selected={isActive}
|
|
33
|
-
className={cx(nativeProps.className, css())}
|
|
34
|
-
onClick={handleClick}
|
|
35
|
-
role="tab"
|
|
36
|
-
value={value}
|
|
37
|
-
/>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { cx } from '@cerberus/styled-system/css'
|
|
2
|
-
import { hstack } from '@cerberus/styled-system/patterns'
|
|
3
|
-
import type { HTMLAttributes, PropsWithChildren } from 'react'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This module provides a TabList component.
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
11
|
-
description?: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The TabList component provides a container for tab elements.
|
|
16
|
-
* @param description - a description of what the tab list contains
|
|
17
|
-
* @example
|
|
18
|
-
* ```tsx
|
|
19
|
-
* <TabList description="Button details">
|
|
20
|
-
* <Tab id="overview">Overview</Tab>
|
|
21
|
-
* <Tab id="guidelines">Guidelines</Tab>
|
|
22
|
-
* </TabList>
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export function TabList(props: PropsWithChildren<TabListProps>) {
|
|
26
|
-
const { description, ...nativeProps } = props
|
|
27
|
-
return (
|
|
28
|
-
<div
|
|
29
|
-
{...nativeProps}
|
|
30
|
-
aria-describedby={description}
|
|
31
|
-
className={cx(
|
|
32
|
-
nativeProps.className,
|
|
33
|
-
hstack({
|
|
34
|
-
gap: '0',
|
|
35
|
-
}),
|
|
36
|
-
)}
|
|
37
|
-
/>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { css, cx } from '@cerberus/styled-system/css'
|
|
4
|
-
import { useMemo, type HTMLAttributes } from 'react'
|
|
5
|
-
import { useTabsContext } from '../context/tabs'
|
|
6
|
-
import { Show } from './Show'
|
|
7
|
-
|
|
8
|
-
export interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
-
tab: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function TabPanel(props: TabPanelProps) {
|
|
13
|
-
const { tab, ...nativeProps } = props
|
|
14
|
-
const { active } = useTabsContext()
|
|
15
|
-
const isActive = useMemo(() => active === tab, [active, tab])
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<Show when={isActive}>
|
|
19
|
-
<div
|
|
20
|
-
{...nativeProps}
|
|
21
|
-
{...(isActive && { tabIndex: 0 })}
|
|
22
|
-
aria-labelledby={tab}
|
|
23
|
-
className={cx(nativeProps.className, css())}
|
|
24
|
-
role="tabpanel"
|
|
25
|
-
/>
|
|
26
|
-
</Show>
|
|
27
|
-
)
|
|
28
|
-
}
|
package/src/context/tabs.tsx
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
createContext,
|
|
5
|
-
useContext,
|
|
6
|
-
useEffect,
|
|
7
|
-
useMemo,
|
|
8
|
-
useState,
|
|
9
|
-
type PropsWithChildren,
|
|
10
|
-
} from 'react'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* This module provides a Tabs component and a hook to access its context.
|
|
14
|
-
* @module
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export interface TabsContextValue {
|
|
18
|
-
active: string
|
|
19
|
-
onTabUpdate: (active: string) => void
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const TabsContext = createContext<TabsContextValue | null>(null)
|
|
23
|
-
|
|
24
|
-
export interface TabsProps {
|
|
25
|
-
active?: string
|
|
26
|
-
cache?: boolean
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The Tabs component provides a context to manage tab state.
|
|
31
|
-
* @param active - the default active tab id,
|
|
32
|
-
* @param cache - whether to cache the active tab state
|
|
33
|
-
* @example
|
|
34
|
-
* ```tsx
|
|
35
|
-
* <Tabs cache>
|
|
36
|
-
* <TabList description="Button details">
|
|
37
|
-
* <Tab id="overview">Overview</Tab>
|
|
38
|
-
* <Tab id="guidelines">Guidelines</Tab>
|
|
39
|
-
* </TabList>
|
|
40
|
-
* <TabPanels>
|
|
41
|
-
* <TabPanel id="overview">Overview content</TabPanel>
|
|
42
|
-
* <TabPanel id="guidelines">Guidelines content</TabPanel>
|
|
43
|
-
* </TabPanels>
|
|
44
|
-
* </Tabs>
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element {
|
|
48
|
-
const { cache } = props
|
|
49
|
-
const [active, setActive] = useState(() => props.active ?? '')
|
|
50
|
-
|
|
51
|
-
const value = useMemo(
|
|
52
|
-
() => ({
|
|
53
|
-
active,
|
|
54
|
-
onTabUpdate: setActive,
|
|
55
|
-
}),
|
|
56
|
-
[active, setActive],
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (cache) {
|
|
61
|
-
const cachedTab = window.localStorage.getItem('cerberus-tabs')
|
|
62
|
-
setActive(cachedTab ?? active)
|
|
63
|
-
}
|
|
64
|
-
}, [cache])
|
|
65
|
-
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (cache) {
|
|
68
|
-
window.localStorage.setItem('cerberus-tabs', active)
|
|
69
|
-
}
|
|
70
|
-
}, [active, cache])
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<TabsContext.Provider value={value}>{props.children}</TabsContext.Provider>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function useTabsContext(): TabsContextValue {
|
|
78
|
-
const context = useContext(TabsContext)
|
|
79
|
-
if (!context) {
|
|
80
|
-
throw new Error('useTabsContext must be used within a Tabs Provider.')
|
|
81
|
-
}
|
|
82
|
-
return context
|
|
83
|
-
}
|