@cerberus-design/react 0.2.0-next-ae70f9a → 0.2.0-next-87c3df1
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 +125 -0
- package/build/legacy/chunk-24B4KIPX.js +46 -0
- package/build/legacy/chunk-24B4KIPX.js.map +1 -0
- package/build/legacy/chunk-6DXQW4WK.js +109 -0
- package/build/legacy/chunk-6DXQW4WK.js.map +1 -0
- package/build/legacy/chunk-BVILNJ6M.js +28 -0
- package/build/legacy/chunk-BVILNJ6M.js.map +1 -0
- package/build/legacy/chunk-UI7OR6PG.js +31 -0
- package/build/legacy/chunk-UI7OR6PG.js.map +1 -0
- package/build/legacy/components/Tab.d.ts +2 -0
- package/build/legacy/components/Tab.js +9 -0
- package/build/legacy/components/Tab.js.map +1 -0
- package/build/legacy/components/TabList.d.ts +2 -0
- package/build/legacy/components/TabList.js +7 -0
- package/build/legacy/components/TabList.js.map +1 -0
- package/build/legacy/components/TabPanel.d.ts +2 -0
- package/build/legacy/components/TabPanel.js +10 -0
- package/build/legacy/components/TabPanel.js.map +1 -0
- package/build/legacy/context/tabs.d.ts +4 -0
- package/build/legacy/context/tabs.js +10 -0
- package/build/legacy/context/tabs.js.map +1 -0
- package/build/legacy/index.d.ts +10 -0
- package/build/legacy/index.js +18 -0
- package/build/modern/_tsup-dts-rollup.d.ts +125 -0
- package/build/modern/chunk-24B4KIPX.js +46 -0
- package/build/modern/chunk-24B4KIPX.js.map +1 -0
- package/build/modern/chunk-AMFL3PZV.js +108 -0
- package/build/modern/chunk-AMFL3PZV.js.map +1 -0
- package/build/modern/chunk-BVILNJ6M.js +28 -0
- package/build/modern/chunk-BVILNJ6M.js.map +1 -0
- package/build/modern/chunk-UI7OR6PG.js +31 -0
- package/build/modern/chunk-UI7OR6PG.js.map +1 -0
- package/build/modern/components/Tab.d.ts +2 -0
- package/build/modern/components/Tab.js +9 -0
- package/build/modern/components/Tab.js.map +1 -0
- package/build/modern/components/TabList.d.ts +2 -0
- package/build/modern/components/TabList.js +7 -0
- package/build/modern/components/TabList.js.map +1 -0
- package/build/modern/components/TabPanel.d.ts +2 -0
- package/build/modern/components/TabPanel.js +10 -0
- package/build/modern/components/TabPanel.js.map +1 -0
- package/build/modern/context/tabs.d.ts +4 -0
- package/build/modern/context/tabs.js +10 -0
- package/build/modern/context/tabs.js.map +1 -0
- package/build/modern/index.d.ts +10 -0
- package/build/modern/index.js +18 -0
- package/package.json +1 -1
- package/src/components/Tab.tsx +128 -0
- package/src/components/TabList.tsx +42 -0
- package/src/components/TabPanel.tsx +45 -0
- package/src/context/tabs.tsx +83 -0
- package/src/index.ts +4 -0
|
@@ -277,6 +277,127 @@ declare interface ShowProps {
|
|
|
277
277
|
export { ShowProps }
|
|
278
278
|
export { ShowProps as ShowProps_alias_1 }
|
|
279
279
|
|
|
280
|
+
/**
|
|
281
|
+
* The Tab component provides a tab element to be used in a TabList.
|
|
282
|
+
* @definition [ARIA Target Size](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=Understanding%20SC%202.5.,%3ATarget%20Size%20(Level%20AAA)&text=The%20size%20of%20the%20target,Equivalent)
|
|
283
|
+
* @definition [Tab docs](https://cerberus.digitalu.design/react/tabs)
|
|
284
|
+
* @param id - the id of the tab (used for aria-labelledby in the panel)
|
|
285
|
+
* @param controls - the id of the tab panel that the tab controls
|
|
286
|
+
* @param value - the id of the tab that will be tracked as the active tab
|
|
287
|
+
* @example
|
|
288
|
+
* ```tsx
|
|
289
|
+
* <Tab controls="panel:overview" value="overview">
|
|
290
|
+
* Overview
|
|
291
|
+
* </Tab>
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
declare function Tab(props: TabProps): JSX_2.Element;
|
|
295
|
+
export { Tab }
|
|
296
|
+
export { Tab as Tab_alias_1 }
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* The TabList component provides a container for tab elements.
|
|
300
|
+
* @param description - a description of what the tab list contains
|
|
301
|
+
* @example
|
|
302
|
+
* ```tsx
|
|
303
|
+
* <TabList description="Button details">
|
|
304
|
+
* <Tab id="overview">Overview</Tab>
|
|
305
|
+
* <Tab id="guidelines">Guidelines</Tab>
|
|
306
|
+
* </TabList>
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
declare function TabList(props: PropsWithChildren<TabListProps>): JSX_2.Element;
|
|
310
|
+
export { TabList }
|
|
311
|
+
export { TabList as TabList_alias_1 }
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* This module provides a TabList component.
|
|
315
|
+
* @module
|
|
316
|
+
*/
|
|
317
|
+
declare interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
318
|
+
description?: string;
|
|
319
|
+
}
|
|
320
|
+
export { TabListProps }
|
|
321
|
+
export { TabListProps as TabListProps_alias_1 }
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The TabPanel component provides a panel element to be used in a Tabs provider.
|
|
325
|
+
* @param id - the id of the tab panel which is used for the Tab's control prop
|
|
326
|
+
* @param tab - the id of the tab that will be tracked as the active tab
|
|
327
|
+
* @example
|
|
328
|
+
* ```tsx
|
|
329
|
+
* <TabPanel id="panel:overview" tab="overview">
|
|
330
|
+
* Overview content
|
|
331
|
+
* </TabPanel>
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
declare function TabPanel(props: TabPanelProps): JSX_2.Element;
|
|
335
|
+
export { TabPanel }
|
|
336
|
+
export { TabPanel as TabPanel_alias_1 }
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* This module provides a TabPanel component.
|
|
340
|
+
* @module
|
|
341
|
+
*/
|
|
342
|
+
declare interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
343
|
+
id: string;
|
|
344
|
+
tab: string;
|
|
345
|
+
}
|
|
346
|
+
export { TabPanelProps }
|
|
347
|
+
export { TabPanelProps as TabPanelProps_alias_1 }
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* This module provides a Tab component.
|
|
351
|
+
* @module
|
|
352
|
+
*/
|
|
353
|
+
declare interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
354
|
+
id: string;
|
|
355
|
+
controls: string;
|
|
356
|
+
value: string;
|
|
357
|
+
}
|
|
358
|
+
export { TabProps }
|
|
359
|
+
export { TabProps as TabProps_alias_1 }
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The Tabs component provides a context to manage tab state.
|
|
363
|
+
* @param active - the default active tab id,
|
|
364
|
+
* @param cache - whether to cache the active tab state
|
|
365
|
+
* @example
|
|
366
|
+
* ```tsx
|
|
367
|
+
* <Tabs cache>
|
|
368
|
+
* <TabList description="Button details">
|
|
369
|
+
* <Tab id="overview">Overview</Tab>
|
|
370
|
+
* <Tab id="guidelines">Guidelines</Tab>
|
|
371
|
+
* </TabList>
|
|
372
|
+
* <TabPanels>
|
|
373
|
+
* <TabPanel id="overview">Overview content</TabPanel>
|
|
374
|
+
* <TabPanel id="guidelines">Guidelines content</TabPanel>
|
|
375
|
+
* </TabPanels>
|
|
376
|
+
* </Tabs>
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
declare function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element;
|
|
380
|
+
export { Tabs }
|
|
381
|
+
export { Tabs as Tabs_alias_1 }
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* This module provides a Tabs component and a hook to access its context.
|
|
385
|
+
* @module
|
|
386
|
+
*/
|
|
387
|
+
declare interface TabsContextValue {
|
|
388
|
+
active: string;
|
|
389
|
+
onTabUpdate: (active: string) => void;
|
|
390
|
+
}
|
|
391
|
+
export { TabsContextValue }
|
|
392
|
+
export { TabsContextValue as TabsContextValue_alias_1 }
|
|
393
|
+
|
|
394
|
+
declare interface TabsProps {
|
|
395
|
+
active?: string;
|
|
396
|
+
cache?: boolean;
|
|
397
|
+
}
|
|
398
|
+
export { TabsProps }
|
|
399
|
+
export { TabsProps as TabsProps_alias_1 }
|
|
400
|
+
|
|
280
401
|
declare const THEME_KEY = "cerberus-theme";
|
|
281
402
|
export { THEME_KEY }
|
|
282
403
|
export { THEME_KEY as THEME_KEY_alias_1 }
|
|
@@ -311,6 +432,10 @@ declare function useNavMenuContext(): NavMenuContextValue;
|
|
|
311
432
|
export { useNavMenuContext }
|
|
312
433
|
export { useNavMenuContext as useNavMenuContext_alias_1 }
|
|
313
434
|
|
|
435
|
+
declare function useTabsContext(): TabsContextValue;
|
|
436
|
+
export { useTabsContext }
|
|
437
|
+
export { useTabsContext as useTabsContext_alias_1 }
|
|
438
|
+
|
|
314
439
|
declare function useTheme<C extends string = DefaultThemes>(defaultTheme?: CustomThemes<C>, defaultColorMode?: ColorModes): ThemeContextValue<C>;
|
|
315
440
|
export { useTheme }
|
|
316
441
|
export { useTheme as useTheme_alias_1 }
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,109 @@
|
|
|
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, btnStyles),
|
|
26
|
+
onClick: handleClick,
|
|
27
|
+
role: "tab",
|
|
28
|
+
value
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
var btnStyles = css({
|
|
33
|
+
fontSize: "sm",
|
|
34
|
+
fontWeight: "600",
|
|
35
|
+
h: "2.75rem",
|
|
36
|
+
position: "relative",
|
|
37
|
+
pxi: "4",
|
|
38
|
+
zIndex: "base",
|
|
39
|
+
_motionSafe: {
|
|
40
|
+
transition: "all 200ms ease-in-out",
|
|
41
|
+
_before: {
|
|
42
|
+
transitionProperty: "height",
|
|
43
|
+
transitionDuration: "200ms",
|
|
44
|
+
transitionTimingFunction: "ease-in-out"
|
|
45
|
+
},
|
|
46
|
+
_after: {
|
|
47
|
+
transitionProperty: "height",
|
|
48
|
+
transitionDuration: "200ms",
|
|
49
|
+
transitionTimingFunction: "ease-in-out"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
_before: {
|
|
53
|
+
bgColor: "action.border.initial",
|
|
54
|
+
bottom: "0",
|
|
55
|
+
content: '""',
|
|
56
|
+
h: "0",
|
|
57
|
+
position: "absolute",
|
|
58
|
+
left: "0",
|
|
59
|
+
right: "0",
|
|
60
|
+
w: "full",
|
|
61
|
+
willChange: "height",
|
|
62
|
+
zIndex: "decorator"
|
|
63
|
+
},
|
|
64
|
+
_after: {
|
|
65
|
+
borderTopLeftRadius: "md",
|
|
66
|
+
borderTopRightRadius: "md",
|
|
67
|
+
bottom: "0",
|
|
68
|
+
bgColor: "neutral.surface.100",
|
|
69
|
+
content: '""',
|
|
70
|
+
left: "0",
|
|
71
|
+
position: "absolute",
|
|
72
|
+
right: "0",
|
|
73
|
+
h: "0",
|
|
74
|
+
w: "full",
|
|
75
|
+
willChange: "height",
|
|
76
|
+
zIndex: "-1"
|
|
77
|
+
},
|
|
78
|
+
_hover: {
|
|
79
|
+
_after: {
|
|
80
|
+
h: "full"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
_focusVisible: {
|
|
84
|
+
boxShadow: "none",
|
|
85
|
+
outline: "3px solid",
|
|
86
|
+
outlineColor: "action.border.focus",
|
|
87
|
+
outlineOffset: "2px"
|
|
88
|
+
},
|
|
89
|
+
_disabled: {
|
|
90
|
+
cursor: "not-allowed",
|
|
91
|
+
opacity: "0.5"
|
|
92
|
+
},
|
|
93
|
+
_selected: {
|
|
94
|
+
color: "action.text.200",
|
|
95
|
+
_before: {
|
|
96
|
+
h: "3px"
|
|
97
|
+
},
|
|
98
|
+
_hover: {
|
|
99
|
+
_after: {
|
|
100
|
+
h: "0"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
Tab
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=chunk-6DXQW4WK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 id: string\n controls: string\n value: string\n}\n\n/**\n * The Tab component provides a tab element to be used in a TabList.\n * @definition [ARIA Target Size](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=Understanding%20SC%202.5.,%3ATarget%20Size%20(Level%20AAA)&text=The%20size%20of%20the%20target,Equivalent)\n * @definition [Tab docs](https://cerberus.digitalu.design/react/tabs)\n * @param id - the id of the tab (used for aria-labelledby in the panel)\n * @param controls - the id of the tab panel that the tab controls\n * @param value - the id of the tab that will be tracked as the active tab\n * @example\n * ```tsx\n * <Tab controls=\"panel:overview\" value=\"overview\">\n * Overview\n * </Tab>\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, btnStyles)}\n onClick={handleClick}\n role=\"tab\"\n value={value}\n />\n )\n}\n\nconst btnStyles = css({\n fontSize: 'sm',\n fontWeight: '600',\n h: '2.75rem',\n position: 'relative',\n pxi: '4',\n zIndex: 'base',\n _motionSafe: {\n transition: 'all 200ms ease-in-out',\n _before: {\n transitionProperty: 'height',\n transitionDuration: '200ms',\n transitionTimingFunction: 'ease-in-out',\n },\n _after: {\n transitionProperty: 'height',\n transitionDuration: '200ms',\n transitionTimingFunction: 'ease-in-out',\n },\n },\n _before: {\n bgColor: 'action.border.initial',\n bottom: '0',\n content: '\"\"',\n h: '0',\n position: 'absolute',\n left: '0',\n right: '0',\n w: 'full',\n willChange: 'height',\n zIndex: 'decorator',\n },\n _after: {\n borderTopLeftRadius: 'md',\n borderTopRightRadius: 'md',\n bottom: '0',\n bgColor: 'neutral.surface.100',\n content: '\"\"',\n left: '0',\n position: 'absolute',\n right: '0',\n h: '0',\n w: 'full',\n willChange: 'height',\n zIndex: '-1',\n },\n _hover: {\n _after: {\n h: 'full',\n },\n },\n _focusVisible: {\n boxShadow: 'none',\n outline: '3px solid',\n outlineColor: 'action.border.focus',\n outlineOffset: '2px',\n },\n _disabled: {\n cursor: 'not-allowed',\n opacity: '0.5',\n },\n _selected: {\n color: 'action.text.200',\n _before: {\n h: '3px',\n },\n _hover: {\n _after: {\n h: '0',\n },\n },\n },\n})\n"],"mappings":";;;;;AAEA,SAAS,eAA2D;AAEpE,SAAS,KAAK,UAAU;AAsCpB;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;AApCzD;AAqCI,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,SAAS;AAAA,MAC9C,SAAS;AAAA,MACT,MAAK;AAAA,MACL;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,YAAY,IAAI;AAAA,EACpB,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,GAAG;AAAA,EACH,UAAU;AAAA,EACV,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,aAAa;AAAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,MACP,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,0BAA0B;AAAA,IAC5B;AAAA,IACA,QAAQ;AAAA,MACN,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,0BAA0B;AAAA,IAC5B;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,GAAG;AAAA,IACH,UAAU;AAAA,IACV,MAAM;AAAA,IACN,OAAO;AAAA,IACP,GAAG;AAAA,IACH,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV;AAAA,EACA,QAAQ;AAAA,IACN,qBAAqB;AAAA,IACrB,sBAAsB;AAAA,IACtB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,IACT,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,IACP,GAAG;AAAA,IACH,GAAG;AAAA,IACH,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,MACN,GAAG;AAAA,IACL;AAAA,EACF;AAAA,EACA,eAAe;AAAA,IACb,WAAW;AAAA,IACX,SAAS;AAAA,IACT,cAAc;AAAA,IACd,eAAe;AAAA,EACjB;AAAA,EACA,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,WAAW;AAAA,IACT,OAAO;AAAA,IACP,SAAS;AAAA,MACP,GAAG;AAAA,IACL;AAAA,IACA,QAAQ;AAAA,MACN,QAAQ;AAAA,QACN,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
borderBottom: "1px solid",
|
|
16
|
+
borderBottomColor: "action.border.100",
|
|
17
|
+
gap: "0",
|
|
18
|
+
w: "full"
|
|
19
|
+
})
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
TabList
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=chunk-BVILNJ6M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 borderBottom: '1px solid',\n borderBottomColor: 'action.border.100',\n gap: '0',\n w: 'full',\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,cAAc;AAAA,UACd,mBAAmB;AAAA,UACnB,KAAK;AAAA,UACL,GAAG;AAAA,QACL,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
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-UI7OR6PG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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\n/**\n * This module provides a TabPanel component.\n * @module\n */\n\nexport interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {\n id: string\n tab: string\n}\n\n/**\n * The TabPanel component provides a panel element to be used in a Tabs provider.\n * @param id - the id of the tab panel which is used for the Tab's control prop\n * @param tab - the id of the tab that will be tracked as the active tab\n * @example\n * ```tsx\n * <TabPanel id=\"panel:overview\" tab=\"overview\">\n * Overview content\n * </TabPanel>\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;AAgCvC;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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/build/legacy/index.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ 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';
|
|
19
25
|
export { Show } from './_tsup-dts-rollup';
|
|
20
26
|
export { ShowProps } from './_tsup-dts-rollup';
|
|
21
27
|
export { Field } from './_tsup-dts-rollup';
|
|
@@ -26,6 +32,10 @@ export { useNavMenuContext } from './_tsup-dts-rollup';
|
|
|
26
32
|
export { NavTriggerRef } from './_tsup-dts-rollup';
|
|
27
33
|
export { NavMenuRef } from './_tsup-dts-rollup';
|
|
28
34
|
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';
|
|
29
39
|
export { ThemeProvider } from './_tsup-dts-rollup';
|
|
30
40
|
export { useThemeContext } from './_tsup-dts-rollup';
|
|
31
41
|
export { DefaultThemes } from './_tsup-dts-rollup';
|
package/build/legacy/index.js
CHANGED
|
@@ -15,6 +15,19 @@ import {
|
|
|
15
15
|
NavMenu,
|
|
16
16
|
useNavMenuContext
|
|
17
17
|
} from "./chunk-KJUCHZHV.js";
|
|
18
|
+
import {
|
|
19
|
+
Tab
|
|
20
|
+
} from "./chunk-6DXQW4WK.js";
|
|
21
|
+
import {
|
|
22
|
+
TabList
|
|
23
|
+
} from "./chunk-BVILNJ6M.js";
|
|
24
|
+
import {
|
|
25
|
+
TabPanel
|
|
26
|
+
} from "./chunk-UI7OR6PG.js";
|
|
27
|
+
import {
|
|
28
|
+
Tabs,
|
|
29
|
+
useTabsContext
|
|
30
|
+
} from "./chunk-24B4KIPX.js";
|
|
18
31
|
import "./chunk-55J6XMHW.js";
|
|
19
32
|
import {
|
|
20
33
|
createNavTriggerProps
|
|
@@ -59,11 +72,16 @@ export {
|
|
|
59
72
|
NavMenuTrigger,
|
|
60
73
|
Show,
|
|
61
74
|
THEME_KEY,
|
|
75
|
+
Tab,
|
|
76
|
+
TabList,
|
|
77
|
+
TabPanel,
|
|
78
|
+
Tabs,
|
|
62
79
|
ThemeProvider,
|
|
63
80
|
createNavTriggerProps,
|
|
64
81
|
getPosition,
|
|
65
82
|
useFieldContext,
|
|
66
83
|
useNavMenuContext,
|
|
84
|
+
useTabsContext,
|
|
67
85
|
useTheme,
|
|
68
86
|
useThemeContext
|
|
69
87
|
};
|
|
@@ -277,6 +277,127 @@ declare interface ShowProps {
|
|
|
277
277
|
export { ShowProps }
|
|
278
278
|
export { ShowProps as ShowProps_alias_1 }
|
|
279
279
|
|
|
280
|
+
/**
|
|
281
|
+
* The Tab component provides a tab element to be used in a TabList.
|
|
282
|
+
* @definition [ARIA Target Size](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=Understanding%20SC%202.5.,%3ATarget%20Size%20(Level%20AAA)&text=The%20size%20of%20the%20target,Equivalent)
|
|
283
|
+
* @definition [Tab docs](https://cerberus.digitalu.design/react/tabs)
|
|
284
|
+
* @param id - the id of the tab (used for aria-labelledby in the panel)
|
|
285
|
+
* @param controls - the id of the tab panel that the tab controls
|
|
286
|
+
* @param value - the id of the tab that will be tracked as the active tab
|
|
287
|
+
* @example
|
|
288
|
+
* ```tsx
|
|
289
|
+
* <Tab controls="panel:overview" value="overview">
|
|
290
|
+
* Overview
|
|
291
|
+
* </Tab>
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
declare function Tab(props: TabProps): JSX_2.Element;
|
|
295
|
+
export { Tab }
|
|
296
|
+
export { Tab as Tab_alias_1 }
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* The TabList component provides a container for tab elements.
|
|
300
|
+
* @param description - a description of what the tab list contains
|
|
301
|
+
* @example
|
|
302
|
+
* ```tsx
|
|
303
|
+
* <TabList description="Button details">
|
|
304
|
+
* <Tab id="overview">Overview</Tab>
|
|
305
|
+
* <Tab id="guidelines">Guidelines</Tab>
|
|
306
|
+
* </TabList>
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
declare function TabList(props: PropsWithChildren<TabListProps>): JSX_2.Element;
|
|
310
|
+
export { TabList }
|
|
311
|
+
export { TabList as TabList_alias_1 }
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* This module provides a TabList component.
|
|
315
|
+
* @module
|
|
316
|
+
*/
|
|
317
|
+
declare interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
318
|
+
description?: string;
|
|
319
|
+
}
|
|
320
|
+
export { TabListProps }
|
|
321
|
+
export { TabListProps as TabListProps_alias_1 }
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The TabPanel component provides a panel element to be used in a Tabs provider.
|
|
325
|
+
* @param id - the id of the tab panel which is used for the Tab's control prop
|
|
326
|
+
* @param tab - the id of the tab that will be tracked as the active tab
|
|
327
|
+
* @example
|
|
328
|
+
* ```tsx
|
|
329
|
+
* <TabPanel id="panel:overview" tab="overview">
|
|
330
|
+
* Overview content
|
|
331
|
+
* </TabPanel>
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
declare function TabPanel(props: TabPanelProps): JSX_2.Element;
|
|
335
|
+
export { TabPanel }
|
|
336
|
+
export { TabPanel as TabPanel_alias_1 }
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* This module provides a TabPanel component.
|
|
340
|
+
* @module
|
|
341
|
+
*/
|
|
342
|
+
declare interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
343
|
+
id: string;
|
|
344
|
+
tab: string;
|
|
345
|
+
}
|
|
346
|
+
export { TabPanelProps }
|
|
347
|
+
export { TabPanelProps as TabPanelProps_alias_1 }
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* This module provides a Tab component.
|
|
351
|
+
* @module
|
|
352
|
+
*/
|
|
353
|
+
declare interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
354
|
+
id: string;
|
|
355
|
+
controls: string;
|
|
356
|
+
value: string;
|
|
357
|
+
}
|
|
358
|
+
export { TabProps }
|
|
359
|
+
export { TabProps as TabProps_alias_1 }
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The Tabs component provides a context to manage tab state.
|
|
363
|
+
* @param active - the default active tab id,
|
|
364
|
+
* @param cache - whether to cache the active tab state
|
|
365
|
+
* @example
|
|
366
|
+
* ```tsx
|
|
367
|
+
* <Tabs cache>
|
|
368
|
+
* <TabList description="Button details">
|
|
369
|
+
* <Tab id="overview">Overview</Tab>
|
|
370
|
+
* <Tab id="guidelines">Guidelines</Tab>
|
|
371
|
+
* </TabList>
|
|
372
|
+
* <TabPanels>
|
|
373
|
+
* <TabPanel id="overview">Overview content</TabPanel>
|
|
374
|
+
* <TabPanel id="guidelines">Guidelines content</TabPanel>
|
|
375
|
+
* </TabPanels>
|
|
376
|
+
* </Tabs>
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
declare function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element;
|
|
380
|
+
export { Tabs }
|
|
381
|
+
export { Tabs as Tabs_alias_1 }
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* This module provides a Tabs component and a hook to access its context.
|
|
385
|
+
* @module
|
|
386
|
+
*/
|
|
387
|
+
declare interface TabsContextValue {
|
|
388
|
+
active: string;
|
|
389
|
+
onTabUpdate: (active: string) => void;
|
|
390
|
+
}
|
|
391
|
+
export { TabsContextValue }
|
|
392
|
+
export { TabsContextValue as TabsContextValue_alias_1 }
|
|
393
|
+
|
|
394
|
+
declare interface TabsProps {
|
|
395
|
+
active?: string;
|
|
396
|
+
cache?: boolean;
|
|
397
|
+
}
|
|
398
|
+
export { TabsProps }
|
|
399
|
+
export { TabsProps as TabsProps_alias_1 }
|
|
400
|
+
|
|
280
401
|
declare const THEME_KEY = "cerberus-theme";
|
|
281
402
|
export { THEME_KEY }
|
|
282
403
|
export { THEME_KEY as THEME_KEY_alias_1 }
|
|
@@ -311,6 +432,10 @@ declare function useNavMenuContext(): NavMenuContextValue;
|
|
|
311
432
|
export { useNavMenuContext }
|
|
312
433
|
export { useNavMenuContext as useNavMenuContext_alias_1 }
|
|
313
434
|
|
|
435
|
+
declare function useTabsContext(): TabsContextValue;
|
|
436
|
+
export { useTabsContext }
|
|
437
|
+
export { useTabsContext as useTabsContext_alias_1 }
|
|
438
|
+
|
|
314
439
|
declare function useTheme<C extends string = DefaultThemes>(defaultTheme?: CustomThemes<C>, defaultColorMode?: ColorModes): ThemeContextValue<C>;
|
|
315
440
|
export { useTheme }
|
|
316
441
|
export { useTheme as useTheme_alias_1 }
|