@cerberus-design/react 0.13.2 → 0.14.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.cts +607 -129
- package/build/legacy/components/Accordion.cjs +101 -0
- package/build/legacy/components/Accordion.cjs.map +1 -0
- package/build/legacy/components/AccordionItemGroup.cjs +119 -0
- package/build/legacy/components/AccordionItemGroup.cjs.map +1 -0
- package/build/legacy/components/Admonition.cjs +3 -0
- package/build/legacy/components/Admonition.cjs.map +1 -1
- package/build/legacy/components/Avatar.cjs +3 -0
- package/build/legacy/components/Avatar.cjs.map +1 -1
- package/build/legacy/components/Checkbox.cjs +3 -0
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- package/build/legacy/components/DatePicker.client.cjs +497 -0
- package/build/legacy/components/DatePicker.client.cjs.map +1 -0
- package/build/legacy/components/DatePicker.server.cjs +364 -0
- package/build/legacy/components/DatePicker.server.cjs.map +1 -0
- package/build/legacy/components/FileStatus.cjs +3 -0
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/FileUploader.cjs +3 -0
- package/build/legacy/components/FileUploader.cjs.map +1 -1
- package/build/legacy/components/Input.cjs +3 -0
- package/build/legacy/components/Input.cjs.map +1 -1
- package/build/legacy/components/Notification.cjs +3 -0
- package/build/legacy/components/Notification.cjs.map +1 -1
- package/build/legacy/components/NotificationDescription.cjs.map +1 -1
- package/build/legacy/components/NotificationHeading.cjs.map +1 -1
- package/build/legacy/components/ProgressBar.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +3 -0
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Tabs.client.cjs +104 -0
- package/build/legacy/components/Tabs.client.cjs.map +1 -0
- package/build/legacy/components/Tag.cjs +3 -0
- package/build/legacy/components/Tag.cjs.map +1 -1
- package/build/legacy/components/Text.cjs +59 -0
- package/build/legacy/components/Text.cjs.map +1 -0
- package/build/legacy/components/Toggle.cjs +3 -0
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/components/Tooltip.cjs +2 -2
- package/build/legacy/components/Tooltip.cjs.map +1 -1
- package/build/legacy/config/cerbIcons.cjs +3 -0
- package/build/legacy/config/cerbIcons.cjs.map +1 -1
- package/build/legacy/config/defineIcons.cjs +3 -0
- package/build/legacy/config/defineIcons.cjs.map +1 -1
- package/build/legacy/config/icons/checkbox.icons.cjs.map +1 -1
- package/build/legacy/context/confirm-modal.cjs +3 -0
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +5 -3
- package/build/legacy/context/cta-modal.cjs.map +1 -1
- package/build/legacy/context/notification-center.cjs +3 -0
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +3 -0
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/context/tabs.cjs +53 -24
- package/build/legacy/context/tabs.cjs.map +1 -1
- package/build/legacy/hooks/useDate.cjs +8 -0
- package/build/legacy/hooks/useDate.cjs.map +1 -1
- package/build/legacy/index.cjs +1083 -711
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/utils/index.cjs +21 -2
- package/build/legacy/utils/index.cjs.map +1 -1
- package/build/legacy/utils/localStorage.cjs +44 -0
- package/build/legacy/utils/localStorage.cjs.map +1 -0
- package/build/modern/_tsup-dts-rollup.d.ts +607 -129
- package/build/modern/chunk-2ZNIYPDV.js +47 -0
- package/build/modern/chunk-2ZNIYPDV.js.map +1 -0
- package/build/modern/chunk-34E3UFFB.js +75 -0
- package/build/modern/chunk-34E3UFFB.js.map +1 -0
- package/build/modern/{chunk-CZND26FC.js → chunk-3BM6MZ4A.js} +8 -1
- package/build/modern/{chunk-CZND26FC.js.map → chunk-3BM6MZ4A.js.map} +1 -1
- package/build/modern/{chunk-N4QTLDVM.js → chunk-4IMOKN2D.js} +3 -3
- package/build/modern/{chunk-F27AAKQ3.js → chunk-5KHU6MM5.js} +8 -2
- package/build/modern/chunk-5KHU6MM5.js.map +1 -0
- package/build/modern/{chunk-WFJWCZ7E.js → chunk-77B4HFKT.js} +13 -14
- package/build/modern/chunk-77B4HFKT.js.map +1 -0
- package/build/modern/{chunk-FBSESDWJ.js → chunk-BHSYQCDV.js} +16 -16
- package/build/modern/chunk-BHSYQCDV.js.map +1 -0
- package/build/modern/{chunk-SPZYPRZ6.js → chunk-BU5JK37R.js} +2 -2
- package/build/modern/{chunk-UTGEFJ3L.js → chunk-C5EHJUS5.js} +1 -1
- package/build/modern/{chunk-UTGEFJ3L.js.map → chunk-C5EHJUS5.js.map} +1 -1
- package/build/modern/{chunk-VERRHMW4.js → chunk-DDOTCGGA.js} +2 -2
- package/build/modern/{chunk-CP7OUC2Q.js → chunk-E3PAEB7Y.js} +1 -1
- package/build/modern/chunk-E3PAEB7Y.js.map +1 -0
- package/build/modern/{chunk-F72ZABKX.js → chunk-F4LTOZAN.js} +2 -2
- package/build/modern/{chunk-NKM6PISB.js → chunk-F7EWTOML.js} +2 -2
- package/build/modern/chunk-F7XWOSN3.js +39 -0
- package/build/modern/chunk-F7XWOSN3.js.map +1 -0
- package/build/modern/chunk-FQLMPEYX.js +18 -0
- package/build/modern/chunk-FQLMPEYX.js.map +1 -0
- package/build/modern/{chunk-7MM5KYEX.js → chunk-GI6CSUU4.js} +7 -7
- package/build/modern/{chunk-7SGPJM66.js → chunk-HP4ZN473.js} +2 -2
- package/build/modern/chunk-HP4ZN473.js.map +1 -0
- package/build/modern/chunk-IP5VFOPZ.js +132 -0
- package/build/modern/chunk-IP5VFOPZ.js.map +1 -0
- package/build/modern/{chunk-KML4CTMK.js → chunk-LPALHB6R.js} +3 -3
- package/build/modern/chunk-LPALHB6R.js.map +1 -0
- package/build/modern/{chunk-3XGLNXJJ.js → chunk-M73ECA25.js} +8 -8
- package/build/modern/chunk-M73ECA25.js.map +1 -0
- package/build/modern/chunk-N7O6D7BW.js +63 -0
- package/build/modern/chunk-N7O6D7BW.js.map +1 -0
- package/build/modern/{chunk-W4DXACNV.js → chunk-O7QVCF3H.js} +3 -3
- package/build/modern/chunk-RIZGWERR.js +161 -0
- package/build/modern/chunk-RIZGWERR.js.map +1 -0
- package/build/modern/chunk-RZ7NG77U.js +77 -0
- package/build/modern/chunk-RZ7NG77U.js.map +1 -0
- package/build/modern/{chunk-XL4JREDT.js → chunk-S25RHYZV.js} +2 -2
- package/build/modern/{chunk-SXIXDXG3.js → chunk-SLHYBPJ5.js} +1 -1
- package/build/modern/chunk-SLHYBPJ5.js.map +1 -0
- package/build/modern/{chunk-GRUXP3NG.js → chunk-T6U7AKKP.js} +10 -10
- package/build/modern/chunk-T6U7AKKP.js.map +1 -0
- package/build/modern/{chunk-XEW6TJJ4.js → chunk-UXY3KCC3.js} +1 -1
- package/build/modern/chunk-UXY3KCC3.js.map +1 -0
- package/build/modern/{chunk-NB6DV4VA.js → chunk-W2LSPRQ3.js} +2 -2
- package/build/modern/{chunk-KCANMM64.js → chunk-WZJ5UQNM.js} +1 -1
- package/build/modern/chunk-WZJ5UQNM.js.map +1 -0
- package/build/modern/{chunk-NMNONSHU.js → chunk-XVU2NQCW.js} +2 -2
- package/build/modern/components/Accordion.js +15 -0
- package/build/modern/components/AccordionItemGroup.js +9 -0
- package/build/modern/components/Admonition.js +5 -5
- package/build/modern/components/Avatar.js +4 -4
- package/build/modern/components/Checkbox.js +4 -4
- package/build/modern/components/DatePicker.client.js +31 -0
- package/build/modern/components/DatePicker.server.js +31 -0
- package/build/modern/components/FileStatus.js +7 -7
- package/build/modern/components/FileUploader.js +5 -5
- package/build/modern/components/Input.js +4 -4
- package/build/modern/components/Notification.js +4 -4
- package/build/modern/components/NotificationDescription.js +1 -1
- package/build/modern/components/NotificationHeading.js +1 -1
- package/build/modern/components/ProgressBar.js +1 -1
- package/build/modern/components/Select.js +4 -4
- package/build/modern/components/Tabs.client.js +18 -0
- package/build/modern/components/Tabs.client.js.map +1 -0
- package/build/modern/components/Tag.js +4 -4
- package/build/modern/components/Text.js +7 -0
- package/build/modern/components/Text.js.map +1 -0
- package/build/modern/components/Toggle.js +4 -4
- package/build/modern/components/Tooltip.js +1 -1
- package/build/modern/config/cerbIcons.js +2 -2
- package/build/modern/config/defineIcons.js +3 -3
- package/build/modern/config/icons/checkbox.icons.js +1 -1
- package/build/modern/context/confirm-modal.js +8 -8
- package/build/modern/context/cta-modal.js +8 -8
- package/build/modern/context/notification-center.js +7 -7
- package/build/modern/context/prompt-modal.js +11 -11
- package/build/modern/context/tabs.js +2 -1
- package/build/modern/hooks/useDate.js +3 -1
- package/build/modern/index.js +158 -94
- package/build/modern/index.js.map +1 -1
- package/build/modern/utils/index.js +8 -2
- package/build/modern/utils/localStorage.js +10 -0
- package/build/modern/utils/localStorage.js.map +1 -0
- package/package.json +2 -2
- package/src/components/Accordion.tsx +160 -0
- package/src/components/AccordionItemGroup.tsx +79 -0
- package/src/components/DatePicker.client.tsx +365 -0
- package/src/components/DatePicker.server.tsx +229 -0
- package/src/components/Notification.tsx +6 -3
- package/src/components/NotificationDescription.tsx +2 -2
- package/src/components/NotificationHeading.tsx +1 -2
- package/src/components/ProgressBar.tsx +1 -1
- package/src/components/Tabs.client.tsx +113 -0
- package/src/components/Text.tsx +70 -0
- package/src/components/Tooltip.tsx +2 -2
- package/src/config/cerbIcons.ts +9 -0
- package/src/config/icons/checkbox.icons.tsx +2 -2
- package/src/context/confirm-modal.tsx +1 -1
- package/src/context/cta-modal.tsx +6 -7
- package/src/context/notification-center.tsx +1 -1
- package/src/context/prompt-modal.tsx +1 -1
- package/src/context/tabs.tsx +66 -65
- package/src/hooks/useDate.ts +12 -0
- package/src/index.ts +6 -4
- package/src/utils/index.ts +2 -0
- package/src/utils/localStorage.ts +28 -0
- package/build/legacy/aria-helpers/tabs.aria.cjs +0 -100
- package/build/legacy/aria-helpers/tabs.aria.cjs.map +0 -1
- package/build/legacy/components/Tab.cjs +0 -135
- package/build/legacy/components/Tab.cjs.map +0 -1
- package/build/legacy/components/TabList.cjs +0 -69
- package/build/legacy/components/TabList.cjs.map +0 -1
- package/build/legacy/components/TabPanel.cjs +0 -76
- package/build/legacy/components/TabPanel.cjs.map +0 -1
- package/build/modern/aria-helpers/tabs.aria.js +0 -9
- package/build/modern/chunk-3XGLNXJJ.js.map +0 -1
- package/build/modern/chunk-7SGPJM66.js.map +0 -1
- package/build/modern/chunk-AYIRV5CL.js +0 -32
- package/build/modern/chunk-AYIRV5CL.js.map +0 -1
- package/build/modern/chunk-CP7OUC2Q.js.map +0 -1
- package/build/modern/chunk-F27AAKQ3.js.map +0 -1
- package/build/modern/chunk-FBSESDWJ.js.map +0 -1
- package/build/modern/chunk-GRUXP3NG.js.map +0 -1
- package/build/modern/chunk-ITOIXNJS.js +0 -64
- package/build/modern/chunk-ITOIXNJS.js.map +0 -1
- package/build/modern/chunk-KCANMM64.js.map +0 -1
- package/build/modern/chunk-KML4CTMK.js.map +0 -1
- package/build/modern/chunk-RIFQSCHT.js +0 -58
- package/build/modern/chunk-RIFQSCHT.js.map +0 -1
- package/build/modern/chunk-SLF6SIPB.js +0 -46
- package/build/modern/chunk-SLF6SIPB.js.map +0 -1
- package/build/modern/chunk-SXIXDXG3.js.map +0 -1
- package/build/modern/chunk-UKPF7JOB.js +0 -33
- package/build/modern/chunk-UKPF7JOB.js.map +0 -1
- package/build/modern/chunk-WFJWCZ7E.js.map +0 -1
- package/build/modern/chunk-XEW6TJJ4.js.map +0 -1
- package/build/modern/components/Tab.js +0 -10
- package/build/modern/components/TabList.js +0 -9
- package/build/modern/components/TabPanel.js +0 -10
- package/src/aria-helpers/tabs.aria.ts +0 -70
- package/src/components/Tab.tsx +0 -68
- package/src/components/TabList.tsx +0 -51
- package/src/components/TabPanel.tsx +0 -49
- /package/build/modern/{chunk-N4QTLDVM.js.map → chunk-4IMOKN2D.js.map} +0 -0
- /package/build/modern/{chunk-SPZYPRZ6.js.map → chunk-BU5JK37R.js.map} +0 -0
- /package/build/modern/{chunk-VERRHMW4.js.map → chunk-DDOTCGGA.js.map} +0 -0
- /package/build/modern/{chunk-F72ZABKX.js.map → chunk-F4LTOZAN.js.map} +0 -0
- /package/build/modern/{chunk-NKM6PISB.js.map → chunk-F7EWTOML.js.map} +0 -0
- /package/build/modern/{chunk-7MM5KYEX.js.map → chunk-GI6CSUU4.js.map} +0 -0
- /package/build/modern/{chunk-W4DXACNV.js.map → chunk-O7QVCF3H.js.map} +0 -0
- /package/build/modern/{chunk-XL4JREDT.js.map → chunk-S25RHYZV.js.map} +0 -0
- /package/build/modern/{chunk-NB6DV4VA.js.map → chunk-W2LSPRQ3.js.map} +0 -0
- /package/build/modern/{chunk-NMNONSHU.js.map → chunk-XVU2NQCW.js.map} +0 -0
- /package/build/modern/{aria-helpers/tabs.aria.js.map → components/Accordion.js.map} +0 -0
- /package/build/modern/components/{Tab.js.map → AccordionItemGroup.js.map} +0 -0
- /package/build/modern/components/{TabList.js.map → DatePicker.client.js.map} +0 -0
- /package/build/modern/components/{TabPanel.js.map → DatePicker.server.js.map} +0 -0
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from 'react'
|
|
4
|
-
import { useTabsContext } from '../context/tabs'
|
|
5
|
-
|
|
6
|
-
function getNextIndex(index: number, length: number) {
|
|
7
|
-
return index === length - 1 ? 0 : index + 1
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function getPrevIndex(index: number, length: number) {
|
|
11
|
-
return index === 0 ? length - 1 : index - 1
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function useTabsKeyboardNavigation() {
|
|
15
|
-
const { tabs } = useTabsContext()
|
|
16
|
-
const [activeTab, setActiveTab] = useState(-1)
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
20
|
-
const index =
|
|
21
|
-
activeTab === -1
|
|
22
|
-
? tabs.current.findIndex((tab) => tab.ariaSelected === 'true')
|
|
23
|
-
: activeTab
|
|
24
|
-
const nextIndex = getNextIndex(index, tabs.current.length)
|
|
25
|
-
const prevIndex = getPrevIndex(index, tabs.current.length)
|
|
26
|
-
|
|
27
|
-
// If the active tab is not found, do nothing
|
|
28
|
-
if (index === -1) return
|
|
29
|
-
|
|
30
|
-
switch (event.key) {
|
|
31
|
-
case 'ArrowLeft':
|
|
32
|
-
event.preventDefault()
|
|
33
|
-
setActiveTab(prevIndex)
|
|
34
|
-
tabs.current[prevIndex].focus()
|
|
35
|
-
break
|
|
36
|
-
case 'ArrowRight':
|
|
37
|
-
event.preventDefault()
|
|
38
|
-
setActiveTab(nextIndex)
|
|
39
|
-
tabs.current[nextIndex].focus()
|
|
40
|
-
break
|
|
41
|
-
case 'Home':
|
|
42
|
-
event.preventDefault()
|
|
43
|
-
setActiveTab(0)
|
|
44
|
-
tabs.current[0].focus()
|
|
45
|
-
break
|
|
46
|
-
case 'End':
|
|
47
|
-
event.preventDefault()
|
|
48
|
-
setActiveTab(tabs.current.length - 1)
|
|
49
|
-
tabs.current[tabs.current.length - 1].focus()
|
|
50
|
-
break
|
|
51
|
-
default:
|
|
52
|
-
break
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
document.addEventListener('keydown', handleKeyDown)
|
|
57
|
-
|
|
58
|
-
return () => {
|
|
59
|
-
document.removeEventListener('keydown', handleKeyDown)
|
|
60
|
-
}
|
|
61
|
-
}, [activeTab, tabs.current])
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
ref: (tab: HTMLButtonElement) => {
|
|
65
|
-
if (tab && !tabs.current.includes(tab)) {
|
|
66
|
-
tabs.current.push(tab)
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/components/Tab.tsx
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useMemo,
|
|
5
|
-
useTransition,
|
|
6
|
-
type ButtonHTMLAttributes,
|
|
7
|
-
type MouseEvent,
|
|
8
|
-
} from 'react'
|
|
9
|
-
import { useTabsContext } from '../context/tabs'
|
|
10
|
-
import { cx } from '@cerberus/styled-system/css'
|
|
11
|
-
import { useTabsKeyboardNavigation } from '../aria-helpers/tabs.aria'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This module provides a Tab component.
|
|
15
|
-
* @module
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
19
|
-
/**
|
|
20
|
-
* The id of the tab that will be tracked as the active tab and used for aria
|
|
21
|
-
* attributes.
|
|
22
|
-
*/
|
|
23
|
-
value: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The Tab component provides a tab element to be used in a TabList.
|
|
28
|
-
* @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)
|
|
29
|
-
* @see https://cerberus.digitalu.design/react/tabs
|
|
30
|
-
* @memberof module:Tabs
|
|
31
|
-
* @example
|
|
32
|
-
* ```tsx
|
|
33
|
-
* <Tabs>
|
|
34
|
-
* <TabList description="Profile settings">
|
|
35
|
-
* <Tab value="overview">Overview</Tab>
|
|
36
|
-
* </TabList>
|
|
37
|
-
* <TabPanel tab="overview">...</TabPanel>
|
|
38
|
-
* </Tabs>
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export function Tab(props: TabProps) {
|
|
42
|
-
const { value, ...nativeProps } = props
|
|
43
|
-
const { active, onTabUpdate, styles } = useTabsContext()
|
|
44
|
-
const [isPending, startTransition] = useTransition()
|
|
45
|
-
const { ref } = useTabsKeyboardNavigation()
|
|
46
|
-
const isActive = useMemo(() => active === value, [active, value])
|
|
47
|
-
|
|
48
|
-
function handleClick(e: MouseEvent<HTMLButtonElement>) {
|
|
49
|
-
props.onClick?.(e)
|
|
50
|
-
startTransition(() => onTabUpdate(e.currentTarget.value))
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<button
|
|
55
|
-
{...nativeProps}
|
|
56
|
-
{...(!isActive && { tabIndex: -1 })}
|
|
57
|
-
aria-controls={`panel:${value}`}
|
|
58
|
-
aria-busy={isPending}
|
|
59
|
-
aria-selected={isActive}
|
|
60
|
-
id={`tab:${value}`}
|
|
61
|
-
className={cx(nativeProps.className, styles.tab)}
|
|
62
|
-
onClick={handleClick}
|
|
63
|
-
role="tab"
|
|
64
|
-
ref={ref}
|
|
65
|
-
value={value}
|
|
66
|
-
/>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { cx } from '@cerberus/styled-system/css'
|
|
4
|
-
import { hstack } from '@cerberus/styled-system/patterns'
|
|
5
|
-
import type { HTMLAttributes, PropsWithChildren } from 'react'
|
|
6
|
-
import { useTabsContext } from '../context/tabs'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This module provides a TabList component.
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
-
/**
|
|
15
|
-
* A description of what the tab list contains. Required for accessibility.
|
|
16
|
-
*/
|
|
17
|
-
description: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The TabList component provides a container for tab elements.
|
|
22
|
-
* @see https://cerberus.digitalu.design/react/tabs
|
|
23
|
-
* @memberof module:Tabs
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* <TabList description="Button details">
|
|
27
|
-
* <Tab id="overview">Overview</Tab>
|
|
28
|
-
* <Tab id="guidelines">Guidelines</Tab>
|
|
29
|
-
* </TabList>
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export function TabList(props: PropsWithChildren<TabListProps>) {
|
|
33
|
-
const { description, ...nativeProps } = props
|
|
34
|
-
const { id, styles } = useTabsContext()
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div
|
|
38
|
-
{...nativeProps}
|
|
39
|
-
aria-label={description}
|
|
40
|
-
className={cx(
|
|
41
|
-
nativeProps.className,
|
|
42
|
-
hstack({
|
|
43
|
-
gap: '0',
|
|
44
|
-
}),
|
|
45
|
-
styles.tabList,
|
|
46
|
-
)}
|
|
47
|
-
id={id ?? nativeProps.id}
|
|
48
|
-
role="tablist"
|
|
49
|
-
/>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { 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
|
-
/**
|
|
9
|
-
* This module provides a TabPanel component.
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
-
/**
|
|
15
|
-
* The unique value of the Tab that is associated with the TabPanel.
|
|
16
|
-
*/
|
|
17
|
-
tab: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The TabPanel component provides a panel element to be used in a Tabs
|
|
22
|
-
* provider.
|
|
23
|
-
* @see https://cerberus.digitalu.design/react/tabs
|
|
24
|
-
* @memberof module:Tabs
|
|
25
|
-
* @example
|
|
26
|
-
* ```tsx
|
|
27
|
-
* <TabPanel tab="overview">
|
|
28
|
-
* Overview content
|
|
29
|
-
* </TabPanel>
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export function TabPanel(props: TabPanelProps) {
|
|
33
|
-
const { tab, ...nativeProps } = props
|
|
34
|
-
const { active, styles } = useTabsContext()
|
|
35
|
-
const isActive = useMemo(() => active === tab, [active, tab])
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Show when={isActive}>
|
|
39
|
-
<div
|
|
40
|
-
{...nativeProps}
|
|
41
|
-
{...(isActive && { tabIndex: 0 })}
|
|
42
|
-
aria-labelledby={`tab:${tab}`}
|
|
43
|
-
className={cx(nativeProps.className, styles.tabPanel)}
|
|
44
|
-
id={`panel:${tab}`}
|
|
45
|
-
role="tabpanel"
|
|
46
|
-
/>
|
|
47
|
-
</Show>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|