@cerberus-design/react 0.2.0-next-87c3df1 → 0.2.0-next-1b244ce

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.
Files changed (63) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.ts +19 -12
  2. package/build/legacy/aria-helpers/tabs.aria.d.ts +1 -0
  3. package/build/legacy/aria-helpers/tabs.aria.js +9 -0
  4. package/build/legacy/aria-helpers/tabs.aria.js.map +1 -0
  5. package/build/legacy/chunk-57HOQM4E.js +65 -0
  6. package/build/legacy/chunk-57HOQM4E.js.map +1 -0
  7. package/build/legacy/{chunk-24B4KIPX.js → chunk-HQK7SM56.js} +9 -5
  8. package/build/legacy/chunk-HQK7SM56.js.map +1 -0
  9. package/build/legacy/{chunk-X6PHIZRM.js → chunk-MJB3V6J4.js} +4 -4
  10. package/build/{modern/chunk-BVILNJ6M.js → legacy/chunk-ODSSU3JD.js} +1 -1
  11. package/build/legacy/chunk-ODSSU3JD.js.map +1 -0
  12. package/build/{modern/chunk-UI7OR6PG.js → legacy/chunk-RCE2XXL7.js} +17 -5
  13. package/build/legacy/chunk-RCE2XXL7.js.map +1 -0
  14. package/build/legacy/{chunk-6DXQW4WK.js → chunk-TG5VW7KN.js} +12 -4
  15. package/build/legacy/chunk-TG5VW7KN.js.map +1 -0
  16. package/build/legacy/components/NavMenuTrigger.js +2 -2
  17. package/build/legacy/components/Tab.js +3 -2
  18. package/build/legacy/components/TabList.js +1 -1
  19. package/build/legacy/components/TabPanel.js +2 -2
  20. package/build/legacy/context/tabs.d.ts +1 -0
  21. package/build/legacy/context/tabs.js +3 -1
  22. package/build/legacy/index.d.ts +2 -0
  23. package/build/legacy/index.js +25 -19
  24. package/build/modern/_tsup-dts-rollup.d.ts +19 -12
  25. package/build/modern/aria-helpers/tabs.aria.d.ts +1 -0
  26. package/build/modern/aria-helpers/tabs.aria.js +9 -0
  27. package/build/modern/aria-helpers/tabs.aria.js.map +1 -0
  28. package/build/modern/chunk-57HOQM4E.js +65 -0
  29. package/build/modern/chunk-57HOQM4E.js.map +1 -0
  30. package/build/modern/{chunk-24B4KIPX.js → chunk-HQK7SM56.js} +9 -5
  31. package/build/modern/chunk-HQK7SM56.js.map +1 -0
  32. package/build/modern/{chunk-X6PHIZRM.js → chunk-MJB3V6J4.js} +4 -4
  33. package/build/{legacy/chunk-BVILNJ6M.js → modern/chunk-ODSSU3JD.js} +1 -1
  34. package/build/modern/chunk-ODSSU3JD.js.map +1 -0
  35. package/build/{legacy/chunk-UI7OR6PG.js → modern/chunk-RCE2XXL7.js} +17 -5
  36. package/build/modern/chunk-RCE2XXL7.js.map +1 -0
  37. package/build/modern/{chunk-AMFL3PZV.js → chunk-SWCK7V2N.js} +12 -4
  38. package/build/modern/chunk-SWCK7V2N.js.map +1 -0
  39. package/build/modern/components/NavMenuTrigger.js +2 -2
  40. package/build/modern/components/Tab.js +3 -2
  41. package/build/modern/components/TabList.js +1 -1
  42. package/build/modern/components/TabPanel.js +2 -2
  43. package/build/modern/context/tabs.d.ts +1 -0
  44. package/build/modern/context/tabs.js +3 -1
  45. package/build/modern/index.d.ts +2 -0
  46. package/build/modern/index.js +25 -19
  47. package/package.json +1 -1
  48. package/src/aria-helpers/tabs.aria.ts +70 -0
  49. package/src/components/Tab.tsx +10 -8
  50. package/src/components/TabList.tsx +1 -1
  51. package/src/components/TabPanel.tsx +15 -5
  52. package/src/context/tabs.tsx +11 -6
  53. package/src/index.ts +1 -0
  54. package/build/legacy/chunk-24B4KIPX.js.map +0 -1
  55. package/build/legacy/chunk-6DXQW4WK.js.map +0 -1
  56. package/build/legacy/chunk-BVILNJ6M.js.map +0 -1
  57. package/build/legacy/chunk-UI7OR6PG.js.map +0 -1
  58. package/build/modern/chunk-24B4KIPX.js.map +0 -1
  59. package/build/modern/chunk-AMFL3PZV.js.map +0 -1
  60. package/build/modern/chunk-BVILNJ6M.js.map +0 -1
  61. package/build/modern/chunk-UI7OR6PG.js.map +0 -1
  62. /package/build/legacy/{chunk-X6PHIZRM.js.map → chunk-MJB3V6J4.js.map} +0 -0
  63. /package/build/modern/{chunk-X6PHIZRM.js.map → chunk-MJB3V6J4.js.map} +0 -0
@@ -3,6 +3,7 @@
3
3
  import { useMemo, type ButtonHTMLAttributes, type MouseEvent } from 'react'
4
4
  import { useTabsContext } from '../context/tabs'
5
5
  import { css, cx } from '@cerberus/styled-system/css'
6
+ import { useTabsKeyboardNavigation } from '../aria-helpers/tabs.aria'
6
7
 
7
8
  /**
8
9
  * This module provides a Tab component.
@@ -10,8 +11,6 @@ import { css, cx } from '@cerberus/styled-system/css'
10
11
  */
11
12
 
12
13
  export interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
13
- id: string
14
- controls: string
15
14
  value: string
16
15
  }
17
16
 
@@ -19,19 +18,18 @@ export interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
19
18
  * The Tab component provides a tab element to be used in a TabList.
20
19
  * @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)
21
20
  * @definition [Tab docs](https://cerberus.digitalu.design/react/tabs)
22
- * @param id - the id of the tab (used for aria-labelledby in the panel)
23
- * @param controls - the id of the tab panel that the tab controls
24
- * @param value - the id of the tab that will be tracked as the active tab
21
+ * @param value - the id of the tab that will be tracked as the active tab and used for aria attributes
25
22
  * @example
26
23
  * ```tsx
27
- * <Tab controls="panel:overview" value="overview">
24
+ * <Tab value="overview">
28
25
  * Overview
29
26
  * </Tab>
30
27
  * ```
31
28
  */
32
29
  export function Tab(props: TabProps) {
33
- const { controls, value, ...nativeProps } = props
30
+ const { value, ...nativeProps } = props
34
31
  const { active, onTabUpdate } = useTabsContext()
32
+ const { ref } = useTabsKeyboardNavigation()
35
33
  const isActive = useMemo(() => active === value, [active, value])
36
34
 
37
35
  function handleClick(e: MouseEvent<HTMLButtonElement>) {
@@ -43,17 +41,21 @@ export function Tab(props: TabProps) {
43
41
  <button
44
42
  {...nativeProps}
45
43
  {...(!isActive && { tabIndex: -1 })}
46
- aria-controls={controls}
44
+ aria-controls={`panel:${value}`}
47
45
  aria-selected={isActive}
46
+ id={value}
48
47
  className={cx(nativeProps.className, btnStyles)}
49
48
  onClick={handleClick}
50
49
  role="tab"
50
+ ref={ref}
51
51
  value={value}
52
52
  />
53
53
  )
54
54
  }
55
55
 
56
56
  const btnStyles = css({
57
+ borderTopLeftRadius: 'md',
58
+ borderTopRightRadius: 'md',
57
59
  fontSize: 'sm',
58
60
  fontWeight: '600',
59
61
  h: '2.75rem',
@@ -8,7 +8,7 @@ import type { HTMLAttributes, PropsWithChildren } from 'react'
8
8
  */
9
9
 
10
10
  export interface TabListProps extends HTMLAttributes<HTMLDivElement> {
11
- description?: string
11
+ description: string
12
12
  }
13
13
 
14
14
  /**
@@ -11,17 +11,15 @@ import { Show } from './Show'
11
11
  */
12
12
 
13
13
  export interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
14
- id: string
15
14
  tab: string
16
15
  }
17
16
 
18
17
  /**
19
18
  * The TabPanel component provides a panel element to be used in a Tabs provider.
20
- * @param id - the id of the tab panel which is used for the Tab's control prop
21
- * @param tab - the id of the tab that will be tracked as the active tab
19
+ * @param tab - the value of the tab that will be tracked as the active tab and used for aria attributes
22
20
  * @example
23
21
  * ```tsx
24
- * <TabPanel id="panel:overview" tab="overview">
22
+ * <TabPanel tab="overview">
25
23
  * Overview content
26
24
  * </TabPanel>
27
25
  * ```
@@ -37,7 +35,19 @@ export function TabPanel(props: TabPanelProps) {
37
35
  {...nativeProps}
38
36
  {...(isActive && { tabIndex: 0 })}
39
37
  aria-labelledby={tab}
40
- className={cx(nativeProps.className, css())}
38
+ className={cx(
39
+ nativeProps.className,
40
+ css({
41
+ rounded: 'md',
42
+ _focusVisible: {
43
+ boxShadow: 'none',
44
+ outline: '3px solid',
45
+ outlineColor: 'action.border.focus',
46
+ outlineOffset: '2px',
47
+ },
48
+ }),
49
+ )}
50
+ id={`panel:${tab}`}
41
51
  role="tabpanel"
42
52
  />
43
53
  </Show>
@@ -5,7 +5,9 @@ import {
5
5
  useContext,
6
6
  useEffect,
7
7
  useMemo,
8
+ useRef,
8
9
  useState,
10
+ type MutableRefObject,
9
11
  type PropsWithChildren,
10
12
  } from 'react'
11
13
 
@@ -16,10 +18,11 @@ import {
16
18
 
17
19
  export interface TabsContextValue {
18
20
  active: string
21
+ tabs: MutableRefObject<HTMLButtonElement[]>
19
22
  onTabUpdate: (active: string) => void
20
23
  }
21
24
 
22
- const TabsContext = createContext<TabsContextValue | null>(null)
25
+ export const TabsContext = createContext<TabsContextValue | null>(null)
23
26
 
24
27
  export interface TabsProps {
25
28
  active?: string
@@ -29,7 +32,7 @@ export interface TabsProps {
29
32
  /**
30
33
  * The Tabs component provides a context to manage tab state.
31
34
  * @param active - the default active tab id,
32
- * @param cache - whether to cache the active tab state
35
+ * @param cache - whether to cache the active tab state in local storage
33
36
  * @example
34
37
  * ```tsx
35
38
  * <Tabs cache>
@@ -46,20 +49,22 @@ export interface TabsProps {
46
49
  */
47
50
  export function Tabs(props: PropsWithChildren<TabsProps>): JSX.Element {
48
51
  const { cache } = props
49
- const [active, setActive] = useState(() => props.active ?? '')
52
+ const [active, setActive] = useState(() => (cache ? '' : props.active ?? ''))
53
+ const tabs = useRef<HTMLButtonElement[]>([])
50
54
 
51
55
  const value = useMemo(
52
56
  () => ({
53
57
  active,
58
+ tabs,
54
59
  onTabUpdate: setActive,
55
60
  }),
56
61
  [active, setActive],
57
62
  )
58
63
 
59
64
  useEffect(() => {
60
- if (cache) {
61
- const cachedTab = window.localStorage.getItem('cerberus-tabs')
62
- setActive(cachedTab ?? active)
65
+ const cachedTab = window.localStorage.getItem('cerberus-tabs')
66
+ if (cache && cachedTab) {
67
+ setActive(cachedTab)
63
68
  }
64
69
  }, [cache])
65
70
 
package/src/index.ts CHANGED
@@ -32,6 +32,7 @@ export * from './hooks/useTheme'
32
32
  // aria-helpers
33
33
 
34
34
  export * from './aria-helpers/nav-menu.aria'
35
+ export * from './aria-helpers/tabs.aria'
35
36
 
36
37
  // shared types
37
38
 
@@ -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 +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 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":[]}
@@ -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 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":[]}
@@ -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\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":[]}
@@ -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 +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 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;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,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":[]}
@@ -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 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":[]}
@@ -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\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":[]}