@cerberus-design/react 0.15.0-next-7669d47 → 0.15.0-next-e5dbdbd
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 +123 -29
- package/build/legacy/components/Accordion.cjs.map +1 -1
- package/build/legacy/components/AccordionItemGroup.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +101 -60
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/{Modal.cjs → deprecated/Modal.cjs} +1 -1
- package/build/legacy/components/deprecated/Modal.cjs.map +1 -0
- package/build/legacy/components/{ModalDescription.cjs → deprecated/ModalDescription.cjs} +1 -1
- package/build/legacy/components/deprecated/ModalDescription.cjs.map +1 -0
- package/build/legacy/components/{ModalHeader.cjs → deprecated/ModalHeader.cjs} +1 -1
- package/build/legacy/components/deprecated/ModalHeader.cjs.map +1 -0
- package/build/legacy/components/{ModalHeading.cjs → deprecated/ModalHeading.cjs} +1 -1
- package/build/legacy/components/deprecated/ModalHeading.cjs.map +1 -0
- package/build/legacy/components/{NavMenuLink.cjs → deprecated/NavMenuLink.cjs} +2 -2
- package/build/legacy/components/deprecated/NavMenuLink.cjs.map +1 -0
- package/build/legacy/components/{NavMenuList.cjs → deprecated/NavMenuList.cjs} +2 -2
- package/build/legacy/components/deprecated/NavMenuList.cjs.map +1 -0
- package/build/legacy/components/{NavMenuTrigger.cjs → deprecated/NavMenuTrigger.cjs} +2 -2
- package/build/legacy/components/deprecated/NavMenuTrigger.cjs.map +1 -0
- package/build/legacy/config/types.cjs.map +1 -1
- package/build/legacy/index.cjs +207 -189
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +123 -29
- package/build/modern/{chunk-UZVQ4INR.js → chunk-AIJ75ENY.js} +2 -2
- package/build/modern/chunk-AIJ75ENY.js.map +1 -0
- package/build/modern/{chunk-NUMM4TNC.js → chunk-AUALRL3U.js} +2 -2
- package/build/modern/chunk-AUALRL3U.js.map +1 -0
- package/build/modern/{chunk-IGHMP4WA.js → chunk-AZRFYQO7.js} +1 -1
- package/build/modern/chunk-AZRFYQO7.js.map +1 -0
- package/build/modern/{chunk-PM7CWT3N.js → chunk-BRVZVAPT.js} +2 -2
- package/build/modern/chunk-BRVZVAPT.js.map +1 -0
- package/build/modern/{chunk-JIRW4XOJ.js → chunk-Q3I4H6EC.js} +2 -2
- package/build/modern/chunk-Q3I4H6EC.js.map +1 -0
- package/build/modern/{chunk-7NN3SJ7W.js → chunk-SWX5JWZR.js} +2 -2
- package/build/modern/chunk-SWX5JWZR.js.map +1 -0
- package/build/modern/{chunk-ZL6ZITLA.js → chunk-WECB67DC.js} +2 -2
- package/build/modern/chunk-WECB67DC.js.map +1 -0
- package/build/modern/{chunk-BAWZBF5Q.js → chunk-WN7TJX6J.js} +2 -2
- package/build/modern/chunk-X6WFDKKJ.js +90 -0
- package/build/modern/chunk-X6WFDKKJ.js.map +1 -0
- package/build/modern/{chunk-WPVDQRRF.js → chunk-YOTXFCCC.js} +2 -2
- package/build/modern/chunk-YOTXFCCC.js.map +1 -0
- package/build/modern/components/Accordion.js +1 -1
- package/build/modern/components/AccordionItemGroup.js +2 -2
- package/build/modern/components/Select.js +11 -4
- package/build/modern/components/deprecated/Modal.js +7 -0
- package/build/modern/components/deprecated/ModalDescription.js +7 -0
- package/build/modern/components/deprecated/ModalHeader.js +7 -0
- package/build/modern/components/deprecated/ModalHeading.js +7 -0
- package/build/modern/components/deprecated/NavMenuLink.js +8 -0
- package/build/modern/components/deprecated/NavMenuList.js +12 -0
- package/build/modern/components/deprecated/NavMenuTrigger.js +11 -0
- package/build/modern/index.js +52 -46
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Accordion.tsx +1 -0
- package/src/components/Select.tsx +191 -74
- package/src/components/{NavMenuLink.tsx → deprecated/NavMenuLink.tsx} +1 -1
- package/src/components/{NavMenuList.tsx → deprecated/NavMenuList.tsx} +3 -3
- package/src/components/{NavMenuTrigger.tsx → deprecated/NavMenuTrigger.tsx} +4 -4
- package/src/config/types.ts +1 -0
- package/src/index.ts +8 -8
- package/build/legacy/components/Modal.cjs.map +0 -1
- package/build/legacy/components/ModalDescription.cjs.map +0 -1
- package/build/legacy/components/ModalHeader.cjs.map +0 -1
- package/build/legacy/components/ModalHeading.cjs.map +0 -1
- package/build/legacy/components/NavMenuLink.cjs.map +0 -1
- package/build/legacy/components/NavMenuList.cjs.map +0 -1
- package/build/legacy/components/NavMenuTrigger.cjs.map +0 -1
- package/build/modern/chunk-7NN3SJ7W.js.map +0 -1
- package/build/modern/chunk-IGHMP4WA.js.map +0 -1
- package/build/modern/chunk-JIRW4XOJ.js.map +0 -1
- package/build/modern/chunk-KKHL3ZO4.js +0 -69
- package/build/modern/chunk-KKHL3ZO4.js.map +0 -1
- package/build/modern/chunk-NUMM4TNC.js.map +0 -1
- package/build/modern/chunk-PM7CWT3N.js.map +0 -1
- package/build/modern/chunk-UZVQ4INR.js.map +0 -1
- package/build/modern/chunk-WPVDQRRF.js.map +0 -1
- package/build/modern/chunk-ZL6ZITLA.js.map +0 -1
- package/build/modern/components/Modal.js +0 -7
- package/build/modern/components/ModalDescription.js +0 -7
- package/build/modern/components/ModalHeader.js +0 -7
- package/build/modern/components/ModalHeading.js +0 -7
- package/build/modern/components/NavMenuLink.js +0 -8
- package/build/modern/components/NavMenuList.js +0 -12
- package/build/modern/components/NavMenuTrigger.js +0 -11
- /package/build/modern/{chunk-BAWZBF5Q.js.map → chunk-WN7TJX6J.js.map} +0 -0
- /package/build/modern/components/{Modal.js.map → deprecated/Modal.js.map} +0 -0
- /package/build/modern/components/{ModalDescription.js.map → deprecated/ModalDescription.js.map} +0 -0
- /package/build/modern/components/{ModalHeader.js.map → deprecated/ModalHeader.js.map} +0 -0
- /package/build/modern/components/{ModalHeading.js.map → deprecated/ModalHeading.js.map} +0 -0
- /package/build/modern/components/{NavMenuLink.js.map → deprecated/NavMenuLink.js.map} +0 -0
- /package/build/modern/components/{NavMenuList.js.map → deprecated/NavMenuList.js.map} +0 -0
- /package/build/modern/components/{NavMenuTrigger.js.map → deprecated/NavMenuTrigger.js.map} +0 -0
- /package/src/components/{Modal.tsx → deprecated/Modal.tsx} +0 -0
- /package/src/components/{ModalDescription.tsx → deprecated/ModalDescription.tsx} +0 -0
- /package/src/components/{ModalHeader.tsx → deprecated/ModalHeader.tsx} +0 -0
- /package/src/components/{ModalHeading.tsx → deprecated/ModalHeading.tsx} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
NavMenuTrigger
|
|
4
|
+
} from "../../chunk-BRVZVAPT.js";
|
|
5
|
+
import "../../chunk-6WS765J3.js";
|
|
6
|
+
import "../../chunk-BUVVRQLZ.js";
|
|
7
|
+
import "../../chunk-JF76VIL3.js";
|
|
8
|
+
export {
|
|
9
|
+
NavMenuTrigger
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=NavMenuTrigger.js.map
|
package/build/modern/index.js
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Modal
|
|
3
|
+
} from "./chunk-Q3I4H6EC.js";
|
|
4
|
+
import {
|
|
5
|
+
ModalDescription
|
|
6
|
+
} from "./chunk-WECB67DC.js";
|
|
7
|
+
import {
|
|
8
|
+
ModalHeader
|
|
9
|
+
} from "./chunk-AUALRL3U.js";
|
|
10
|
+
import {
|
|
11
|
+
ModalHeading
|
|
12
|
+
} from "./chunk-SWX5JWZR.js";
|
|
13
|
+
import {
|
|
14
|
+
NavMenuLink
|
|
15
|
+
} from "./chunk-YOTXFCCC.js";
|
|
16
|
+
import {
|
|
17
|
+
NavMenuList,
|
|
18
|
+
getPosition
|
|
19
|
+
} from "./chunk-AIJ75ENY.js";
|
|
20
|
+
import {
|
|
21
|
+
NavMenuTrigger
|
|
22
|
+
} from "./chunk-BRVZVAPT.js";
|
|
23
|
+
import {
|
|
24
|
+
CTAModal,
|
|
25
|
+
useCTAModal
|
|
26
|
+
} from "./chunk-FGCO27TC.js";
|
|
27
|
+
import {
|
|
28
|
+
NavMenu,
|
|
29
|
+
useNavMenuContext
|
|
30
|
+
} from "./chunk-6WS765J3.js";
|
|
1
31
|
import {
|
|
2
32
|
NotificationCenter,
|
|
3
33
|
useNotificationCenter
|
|
@@ -30,9 +60,15 @@ import {
|
|
|
30
60
|
useConfirmModal
|
|
31
61
|
} from "./chunk-BHB56M7S.js";
|
|
32
62
|
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
63
|
+
Option,
|
|
64
|
+
OptionGroup,
|
|
65
|
+
OptionGroupLabel,
|
|
66
|
+
Select,
|
|
67
|
+
createSelectCollection
|
|
68
|
+
} from "./chunk-X6WFDKKJ.js";
|
|
69
|
+
import {
|
|
70
|
+
Text
|
|
71
|
+
} from "./chunk-RU5LOXWI.js";
|
|
36
72
|
import {
|
|
37
73
|
Spinner
|
|
38
74
|
} from "./chunk-7SYJFI5E.js";
|
|
@@ -61,28 +97,6 @@ import {
|
|
|
61
97
|
import {
|
|
62
98
|
Td
|
|
63
99
|
} from "./chunk-3R4TIF2X.js";
|
|
64
|
-
import {
|
|
65
|
-
Text
|
|
66
|
-
} from "./chunk-RU5LOXWI.js";
|
|
67
|
-
import {
|
|
68
|
-
NavMenuTrigger
|
|
69
|
-
} from "./chunk-PM7CWT3N.js";
|
|
70
|
-
import {
|
|
71
|
-
Notification
|
|
72
|
-
} from "./chunk-RDRD6ACD.js";
|
|
73
|
-
import {
|
|
74
|
-
NotificationDescription
|
|
75
|
-
} from "./chunk-UXY3KCC3.js";
|
|
76
|
-
import {
|
|
77
|
-
NotificationHeading
|
|
78
|
-
} from "./chunk-SLHYBPJ5.js";
|
|
79
|
-
import {
|
|
80
|
-
Radio
|
|
81
|
-
} from "./chunk-FTPZHG6J.js";
|
|
82
|
-
import {
|
|
83
|
-
Option,
|
|
84
|
-
Select
|
|
85
|
-
} from "./chunk-KKHL3ZO4.js";
|
|
86
100
|
import {
|
|
87
101
|
Legend
|
|
88
102
|
} from "./chunk-ILQW5VZT.js";
|
|
@@ -96,28 +110,17 @@ import {
|
|
|
96
110
|
MenuTrigger
|
|
97
111
|
} from "./chunk-RUR5MV54.js";
|
|
98
112
|
import {
|
|
99
|
-
|
|
100
|
-
} from "./chunk-
|
|
101
|
-
import {
|
|
102
|
-
ModalDescription
|
|
103
|
-
} from "./chunk-ZL6ZITLA.js";
|
|
104
|
-
import {
|
|
105
|
-
ModalHeader
|
|
106
|
-
} from "./chunk-NUMM4TNC.js";
|
|
107
|
-
import {
|
|
108
|
-
ModalHeading
|
|
109
|
-
} from "./chunk-7NN3SJ7W.js";
|
|
113
|
+
Notification
|
|
114
|
+
} from "./chunk-RDRD6ACD.js";
|
|
110
115
|
import {
|
|
111
|
-
|
|
112
|
-
} from "./chunk-
|
|
116
|
+
NotificationDescription
|
|
117
|
+
} from "./chunk-UXY3KCC3.js";
|
|
113
118
|
import {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
} from "./chunk-UZVQ4INR.js";
|
|
119
|
+
NotificationHeading
|
|
120
|
+
} from "./chunk-SLHYBPJ5.js";
|
|
117
121
|
import {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
} from "./chunk-6WS765J3.js";
|
|
122
|
+
Radio
|
|
123
|
+
} from "./chunk-FTPZHG6J.js";
|
|
121
124
|
import {
|
|
122
125
|
Fieldset
|
|
123
126
|
} from "./chunk-3ZDFQO25.js";
|
|
@@ -207,7 +210,7 @@ import {
|
|
|
207
210
|
} from "./chunk-CJFW36DZ.js";
|
|
208
211
|
import {
|
|
209
212
|
AccordionItemGroup
|
|
210
|
-
} from "./chunk-
|
|
213
|
+
} from "./chunk-WN7TJX6J.js";
|
|
211
214
|
import {
|
|
212
215
|
AccordionItemIndicator
|
|
213
216
|
} from "./chunk-XZGXRRSQ.js";
|
|
@@ -216,7 +219,7 @@ import {
|
|
|
216
219
|
AccordionItem,
|
|
217
220
|
AccordionItemContent,
|
|
218
221
|
AccordionItemTrigger
|
|
219
|
-
} from "./chunk-
|
|
222
|
+
} from "./chunk-AZRFYQO7.js";
|
|
220
223
|
import {
|
|
221
224
|
Admonition,
|
|
222
225
|
AdmonitionDescription,
|
|
@@ -363,6 +366,8 @@ export {
|
|
|
363
366
|
NotificationDescription,
|
|
364
367
|
NotificationHeading,
|
|
365
368
|
Option,
|
|
369
|
+
OptionGroup,
|
|
370
|
+
OptionGroupLabel,
|
|
366
371
|
Portal,
|
|
367
372
|
ProgressBar,
|
|
368
373
|
PromptModal,
|
|
@@ -392,6 +397,7 @@ export {
|
|
|
392
397
|
Tooltip,
|
|
393
398
|
Tr,
|
|
394
399
|
createNavTriggerProps,
|
|
400
|
+
createSelectCollection,
|
|
395
401
|
defineIcons,
|
|
396
402
|
formatISOToMilitary,
|
|
397
403
|
formatMilitaryDate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// deprecated\n\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\n\n// components\n\nexport * from './components/Accordion'\nexport * from './components/Accordion.client'\nexport * from './components/AccordionItemGroup'\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/DatePicker.client'\nexport * from './components/DatePicker.server'\nexport * from './components/Dialog'\nexport * from './components/Dialog.client'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/Fieldset'\nexport * from './components/FieldsetLabel'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Legend'\nexport * from './components/Menu'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// deprecated\n\nexport * from './components/deprecated/Modal'\nexport * from './components/deprecated/ModalHeader'\nexport * from './components/deprecated/ModalHeading'\nexport * from './components/deprecated/ModalDescription'\nexport * from './components/deprecated/NavMenuTrigger'\nexport * from './components/deprecated/NavMenuList'\nexport * from './components/deprecated/NavMenuLink'\n\n// components\n\nexport * from './components/Accordion'\nexport * from './components/Accordion.client'\nexport * from './components/AccordionItemGroup'\nexport * from './components/Admonition'\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/CircularProgress'\nexport * from './components/DatePicker.client'\nexport * from './components/DatePicker.server'\nexport * from './components/Dialog'\nexport * from './components/Dialog.client'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/Fieldset'\nexport * from './components/FieldsetLabel'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Legend'\nexport * from './components/Menu'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Spinner'\nexport * from './components/Tabs.client'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Text'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Tooltip'\nexport * from './components/Select'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/cerberus'\nexport * from './context/confirm-modal'\nexport * from './context/cta-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useDate'\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\nexport * from './hooks/useRootColors'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/index'\nexport * from './utils/index'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGA,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.15.0-next-
|
|
3
|
+
"version": "0.15.0-next-e5dbdbd",
|
|
4
4
|
"description": "The Cerberus Design React component library.",
|
|
5
5
|
"browserslist": "> 0.25%, not dead",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react-dom": "^18",
|
|
27
27
|
"tsup": "^8.1.0",
|
|
28
28
|
"@cerberus-design/configs": "0.0.0",
|
|
29
|
-
"@cerberus/styled-system": "npm:@cerberus-design/styled-system@0.15.0-next-
|
|
29
|
+
"@cerberus/styled-system": "npm:@cerberus-design/styled-system@0.15.0-next-e5dbdbd"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
@@ -22,6 +22,7 @@ export type AccordionProps = ArkAccordion.RootProps & AccordionVariantProps
|
|
|
22
22
|
export function Accordion(props: AccordionProps) {
|
|
23
23
|
const { size, className, ...rootProps } = props
|
|
24
24
|
const styles = accordion({ size })
|
|
25
|
+
|
|
25
26
|
return (
|
|
26
27
|
<ArkAccordion.Root
|
|
27
28
|
collapsible
|
|
@@ -1,108 +1,225 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
Select as ArkSelect,
|
|
5
|
+
createListCollection,
|
|
6
|
+
type SelectRootProps,
|
|
7
|
+
type SelectItemProps,
|
|
8
|
+
type SelectItemGroupProps,
|
|
9
|
+
type SelectItemGroupLabelProps,
|
|
10
|
+
type ListCollection,
|
|
11
|
+
type SelectValueChangeDetails,
|
|
12
|
+
} from '@ark-ui/react/select'
|
|
5
13
|
import {
|
|
6
14
|
select,
|
|
7
15
|
type SelectVariantProps,
|
|
8
16
|
} from '@cerberus/styled-system/recipes'
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
17
|
+
import { cx } from '@cerberus/styled-system/css'
|
|
18
|
+
import { HStack } from '@cerberus/styled-system/jsx'
|
|
11
19
|
import { useCerberusContext } from '../context/cerberus'
|
|
20
|
+
import { Portal } from './Portal'
|
|
12
21
|
import { Show } from './Show'
|
|
22
|
+
import { Text } from './Text'
|
|
13
23
|
|
|
14
24
|
/**
|
|
15
|
-
* This module contains the
|
|
16
|
-
* @module
|
|
25
|
+
* This module contains the Select components.
|
|
26
|
+
* @module 'react/select'
|
|
17
27
|
*/
|
|
18
28
|
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
export interface SelectCollectionItem {
|
|
30
|
+
/**
|
|
31
|
+
* What is displayed in the dropdown list.
|
|
32
|
+
*/
|
|
33
|
+
label: string
|
|
34
|
+
/**
|
|
35
|
+
* The value of the selected item used in the form.
|
|
36
|
+
*/
|
|
37
|
+
value: string
|
|
38
|
+
/**
|
|
39
|
+
* If the item is disabled.
|
|
40
|
+
*/
|
|
41
|
+
disabled?: boolean
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface SelectCollection {
|
|
45
|
+
/**
|
|
46
|
+
* The items to be displayed in the dropdown list.
|
|
47
|
+
*/
|
|
48
|
+
items: SelectCollectionItem[]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface BaseSelectProps {
|
|
52
|
+
/**
|
|
53
|
+
* The placeholder text when no option is selected.
|
|
54
|
+
*/
|
|
55
|
+
placeholder?: string
|
|
56
|
+
/**
|
|
57
|
+
* The label of the select.
|
|
58
|
+
*/
|
|
59
|
+
label: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type SelectProps = SelectRootProps<SelectCollectionItem> &
|
|
63
|
+
BaseSelectProps &
|
|
64
|
+
SelectVariantProps
|
|
33
65
|
|
|
34
66
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
67
|
+
* The Select component is a dropdown list that allows users to select an
|
|
68
|
+
* option from a list.
|
|
69
|
+
* @definition [Select docs](https://cerberus.digitalu.design/react/select)
|
|
70
|
+
* @definition [ARK docs](https://ark-ui.com/react/docs/components/select)
|
|
38
71
|
* @example
|
|
39
72
|
* ```tsx
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
73
|
+
* import { Select, Option, createListCollection } from '@cerberus-design/react'
|
|
74
|
+
*
|
|
75
|
+
* export function SelectBasicPreview() {
|
|
76
|
+
* const collection = createListCollection({
|
|
77
|
+
* items: [
|
|
78
|
+
* { label: 'Hades', value: 'hades' },
|
|
79
|
+
* { label: 'Persephone', value: 'persephone' },
|
|
80
|
+
* { label: 'Zeus', value: 'zeus', disabled: true },
|
|
81
|
+
* ]
|
|
82
|
+
* })
|
|
83
|
+
*
|
|
84
|
+
* return (
|
|
85
|
+
* <Select
|
|
86
|
+
* collection={collection}
|
|
87
|
+
* label="Select Relative"
|
|
88
|
+
* placeholder="Choose option"
|
|
89
|
+
* >
|
|
90
|
+
* {collection.items.map((item) => (
|
|
91
|
+
* <Option key={item.value} item={item} />
|
|
92
|
+
* ))}
|
|
93
|
+
* </Select>
|
|
94
|
+
* )
|
|
95
|
+
* }
|
|
49
96
|
*/
|
|
50
97
|
export function Select(props: SelectProps) {
|
|
51
|
-
const {
|
|
52
|
-
const { invalid, ...fieldStates } = useFieldContext()
|
|
53
|
-
|
|
98
|
+
const { collection, label, placeholder, size, ...rootProps } = props
|
|
54
99
|
const { icons } = useCerberusContext()
|
|
55
|
-
const {
|
|
100
|
+
const { selectArrow: SelectArrow, invalid: InvalidIcon } = icons
|
|
56
101
|
|
|
57
|
-
const styles = select({
|
|
58
|
-
size,
|
|
59
|
-
})
|
|
102
|
+
const styles = select({ size })
|
|
60
103
|
|
|
61
104
|
return (
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
hstack({
|
|
74
|
-
gap: '2',
|
|
75
|
-
}),
|
|
76
|
-
)}
|
|
77
|
-
>
|
|
78
|
-
<Show when={invalid}>
|
|
79
|
-
<span
|
|
80
|
-
{...(invalid && { 'data-invalid': true })}
|
|
81
|
-
className={styles.stateIcon}
|
|
82
|
-
>
|
|
83
|
-
<InvalidIcon />
|
|
84
|
-
</span>
|
|
105
|
+
<ArkSelect.Root
|
|
106
|
+
className={styles.root}
|
|
107
|
+
collection={collection}
|
|
108
|
+
{...rootProps}
|
|
109
|
+
>
|
|
110
|
+
<ArkSelect.Label className={styles.label}>
|
|
111
|
+
{label}
|
|
112
|
+
<Show when={props.required}>
|
|
113
|
+
<Text as="span" color="page.text.100">
|
|
114
|
+
(required)
|
|
115
|
+
</Text>
|
|
85
116
|
</Show>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
117
|
+
</ArkSelect.Label>
|
|
118
|
+
|
|
119
|
+
<ArkSelect.Control className={styles.control}>
|
|
120
|
+
<ArkSelect.Trigger className={styles.trigger}>
|
|
121
|
+
<ArkSelect.ValueText placeholder={placeholder} />
|
|
122
|
+
|
|
123
|
+
<HStack>
|
|
124
|
+
<Show when={props.invalid}>
|
|
125
|
+
<InvalidIcon data-part="invalid-icon" />
|
|
126
|
+
</Show>
|
|
127
|
+
<ArkSelect.Indicator className={styles.indicator}>
|
|
128
|
+
<SelectArrow />
|
|
129
|
+
</ArkSelect.Indicator>
|
|
130
|
+
</HStack>
|
|
131
|
+
</ArkSelect.Trigger>
|
|
132
|
+
</ArkSelect.Control>
|
|
133
|
+
|
|
134
|
+
<Portal>
|
|
135
|
+
<ArkSelect.Positioner className={styles.positioner}>
|
|
136
|
+
<ArkSelect.Content className={styles.content}>
|
|
137
|
+
{props.children}
|
|
138
|
+
</ArkSelect.Content>
|
|
139
|
+
</ArkSelect.Positioner>
|
|
140
|
+
</Portal>
|
|
141
|
+
|
|
142
|
+
<ArkSelect.HiddenSelect />
|
|
143
|
+
</ArkSelect.Root>
|
|
91
144
|
)
|
|
92
145
|
}
|
|
93
146
|
|
|
94
|
-
|
|
147
|
+
export interface OptionProps extends SelectItemProps {
|
|
148
|
+
/**
|
|
149
|
+
* The CollectionListItem to be displayed in the dropdown list.
|
|
150
|
+
*/
|
|
151
|
+
item: SelectCollectionItem
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function Option(props: OptionProps) {
|
|
155
|
+
const { item, ...itemProps } = props
|
|
156
|
+
|
|
157
|
+
const { icons } = useCerberusContext()
|
|
158
|
+
const { selectChecked: CheckedIcon } = icons
|
|
159
|
+
|
|
160
|
+
const styles = select()
|
|
95
161
|
|
|
96
|
-
|
|
162
|
+
return (
|
|
163
|
+
<ArkSelect.Item {...itemProps} item={item} className={styles.item}>
|
|
164
|
+
<ArkSelect.ItemText className={styles.itemText}>
|
|
165
|
+
{item?.label}
|
|
166
|
+
</ArkSelect.ItemText>
|
|
167
|
+
<ArkSelect.ItemIndicator className={styles.itemIndicator}>
|
|
168
|
+
<CheckedIcon />
|
|
169
|
+
</ArkSelect.ItemIndicator>
|
|
170
|
+
</ArkSelect.Item>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
97
173
|
|
|
98
174
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
175
|
+
* The OptionGroup component is a group of options in the dropdown list.
|
|
176
|
+
* @definition [Select docs](https://cerberus.digitalu.design/react/select)
|
|
177
|
+
* @definition [ARK docs](https://ark-ui.com/react/docs/components/select)
|
|
101
178
|
* @example
|
|
102
179
|
* ```tsx
|
|
103
|
-
* <
|
|
180
|
+
* <OptionGroup>
|
|
181
|
+
* <OptionGroupLabel>Greek gods</OptionGroupLabel>
|
|
182
|
+
* ...
|
|
183
|
+
* </OptionGroup>
|
|
104
184
|
* ```
|
|
105
185
|
*/
|
|
106
|
-
export function
|
|
107
|
-
return <
|
|
186
|
+
export function OptionGroup(props: SelectItemGroupProps) {
|
|
187
|
+
return <ArkSelect.ItemGroup {...props} />
|
|
108
188
|
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The OptionGroupLabel component is the label of the OptionGroup.
|
|
192
|
+
* @definition [Select docs](https://cerberus.digitalu.design/react/select)
|
|
193
|
+
* @definition [ARK docs](https://ark-ui.com/react/docs/components/select)
|
|
194
|
+
* @example
|
|
195
|
+
* ```tsx
|
|
196
|
+
* <OptionGroupLabel>Greek gods</OptionGroupLabel>
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
export function OptionGroupLabel(props: SelectItemGroupLabelProps) {
|
|
200
|
+
const styles = select()
|
|
201
|
+
return (
|
|
202
|
+
<ArkSelect.ItemGroupLabel
|
|
203
|
+
{...props}
|
|
204
|
+
className={cx(props.className, styles.itemGroupLabel)}
|
|
205
|
+
/>
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A helper function to create a SelectCollection object.
|
|
211
|
+
* @param collection - An array of SelectCollectionItem objects that matches
|
|
212
|
+
* the following shape:
|
|
213
|
+
* ```ts
|
|
214
|
+
* [{ label: 'Hades', value: 'hades', disabled?: true }]
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export function createSelectCollection(
|
|
218
|
+
collection: SelectCollectionItem[],
|
|
219
|
+
): ListCollection<SelectCollectionItem> {
|
|
220
|
+
return createListCollection({
|
|
221
|
+
items: collection,
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export type { SelectValueChangeDetails, ListCollection }
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { useMemo, type HTMLAttributes } from 'react'
|
|
4
4
|
import { cx } from '@cerberus/styled-system/css'
|
|
5
5
|
import { vstack } from '@cerberus/styled-system/patterns'
|
|
6
|
-
import { useNavMenuContext } from '
|
|
7
|
-
import type { Positions } from '
|
|
8
|
-
import { Show } from '
|
|
6
|
+
import { useNavMenuContext } from '../../context/navMenu'
|
|
7
|
+
import type { Positions } from '../../types'
|
|
8
|
+
import { Show } from '../Show'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* This module contains the NavMenuList component.
|
|
@@ -11,10 +11,10 @@ import { button } from '@cerberus/styled-system/recipes'
|
|
|
11
11
|
import {
|
|
12
12
|
createNavTriggerProps,
|
|
13
13
|
type NavTriggerAriaValues,
|
|
14
|
-
} from '
|
|
15
|
-
import { useNavMenuContext } from '
|
|
16
|
-
import type { ButtonProps } from '
|
|
17
|
-
import { Show } from '
|
|
14
|
+
} from '../../aria-helpers/nav-menu.aria'
|
|
15
|
+
import { useNavMenuContext } from '../../context/navMenu'
|
|
16
|
+
import type { ButtonProps } from '../Button'
|
|
17
|
+
import { Show } from '../Show'
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* This module contains the NavMenuTrigger component.
|
package/src/config/types.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
// deprecated
|
|
7
7
|
|
|
8
|
-
export * from './components/Modal'
|
|
9
|
-
export * from './components/ModalHeader'
|
|
10
|
-
export * from './components/ModalHeading'
|
|
11
|
-
export * from './components/ModalDescription'
|
|
12
|
-
export * from './components/NavMenuTrigger'
|
|
13
|
-
export * from './components/NavMenuList'
|
|
14
|
-
export * from './components/NavMenuLink'
|
|
8
|
+
export * from './components/deprecated/Modal'
|
|
9
|
+
export * from './components/deprecated/ModalHeader'
|
|
10
|
+
export * from './components/deprecated/ModalHeading'
|
|
11
|
+
export * from './components/deprecated/ModalDescription'
|
|
12
|
+
export * from './components/deprecated/NavMenuTrigger'
|
|
13
|
+
export * from './components/deprecated/NavMenuList'
|
|
14
|
+
export * from './components/deprecated/NavMenuLink'
|
|
15
15
|
|
|
16
16
|
// components
|
|
17
17
|
|
|
@@ -45,7 +45,6 @@ export * from './components/NotificationDescription'
|
|
|
45
45
|
export * from './components/Portal'
|
|
46
46
|
export * from './components/ProgressBar'
|
|
47
47
|
export * from './components/Radio'
|
|
48
|
-
export * from './components/Select'
|
|
49
48
|
export * from './components/Spinner'
|
|
50
49
|
export * from './components/Tabs.client'
|
|
51
50
|
export * from './components/Table'
|
|
@@ -58,6 +57,7 @@ export * from './components/Text'
|
|
|
58
57
|
export * from './components/Textarea'
|
|
59
58
|
export * from './components/Toggle'
|
|
60
59
|
export * from './components/Tooltip'
|
|
60
|
+
export * from './components/Select'
|
|
61
61
|
export * from './components/Show'
|
|
62
62
|
|
|
63
63
|
// context
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Modal.tsx"],"sourcesContent":["import { cx } from '@cerberus/styled-system/css'\nimport { modal } from '@cerberus/styled-system/recipes'\nimport { forwardRef, type ForwardedRef, type HTMLAttributes } from 'react'\n\n/**\n * This module contains the Modal root component for a customizable modal.\n * @module\n */\n\n// Modal\n\nexport type ModalProps = HTMLAttributes<HTMLDialogElement>\n\nfunction ModalEl(props: ModalProps, ref: ForwardedRef<HTMLDialogElement>) {\n return (\n <dialog\n {...props}\n className={cx(props.className, modal().dialog)}\n ref={ref}\n />\n )\n}\n\n/**\n * @deprecated use `Dialog` instead\n */\nexport const Modal = forwardRef(ModalEl)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmB;AACnB,qBAAsB;AACtB,mBAAmE;AAa/D;AAFJ,SAAS,QAAQ,OAAmB,KAAsC;AACxE,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,eAAW,eAAG,MAAM,eAAW,sBAAM,EAAE,MAAM;AAAA,MAC7C;AAAA;AAAA,EACF;AAEJ;AAKO,IAAM,YAAQ,yBAAW,OAAO;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ModalDescription.tsx"],"sourcesContent":["import { cx } from '@cerberus/styled-system/css'\nimport { modal } from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalDescription component for a customizable modal.\n * @module\n */\n\nexport type ModalDescriptionProps = HTMLAttributes<HTMLParagraphElement>\n\n/**\n * @deprecated use `DialogDescription` instead\n */\nexport function ModalDescription(props: ModalDescriptionProps) {\n return <p {...props} className={cx(props.className, modal().description)} />\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmB;AACnB,qBAAsB;AAcb;AADF,SAAS,iBAAiB,OAA8B;AAC7D,SAAO,4CAAC,OAAG,GAAG,OAAO,eAAW,eAAG,MAAM,eAAW,sBAAM,EAAE,WAAW,GAAG;AAC5E;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ModalHeader.tsx"],"sourcesContent":["import { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalHeader component for a customizable modal.\n * @module\n */\n\nexport type ModalHeaderProps = HTMLAttributes<HTMLDivElement>\n\n/**\n * @deprecated there is no replacement for this component\n */\nexport function ModalHeader(props: ModalHeaderProps) {\n return (\n <div\n {...props}\n className={cx(\n props.className,\n vstack({\n alignItems: 'flex-start',\n gap: 'md',\n position: 'relative',\n }),\n )}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmB;AACnB,sBAAuB;AAenB;AAFG,SAAS,YAAY,OAAyB;AACnD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,eAAW;AAAA,QACT,MAAM;AAAA,YACN,wBAAO;AAAA,UACL,YAAY;AAAA,UACZ,KAAK;AAAA,UACL,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ModalHeading.tsx"],"sourcesContent":["import { cx } from '@cerberus/styled-system/css'\nimport { modal } from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalHeading component for a customizable modal.\n * @module\n */\n\nexport type ModalHeadingProps = HTMLAttributes<HTMLParagraphElement>\n\n/**\n * @deprecated use `DialogHeading` instead\n */\nexport function ModalHeading(props: ModalHeadingProps) {\n return <p {...props} className={cx(props.className, modal().heading)} />\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmB;AACnB,qBAAsB;AAcb;AADF,SAAS,aAAa,OAA0B;AACrD,SAAO,4CAAC,OAAG,GAAG,OAAO,eAAW,eAAG,MAAM,eAAW,sBAAM,EAAE,OAAO,GAAG;AACxE;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/NavMenuLink.tsx","../../../src/components/Show.tsx"],"sourcesContent":["import type { AnchorHTMLAttributes, ElementType } from 'react'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { Show } from './Show'\n\n/**\n * This module contains the NavMenuLink component.\n * @module\n */\n\nexport interface NavMenuLinkProps\n extends AnchorHTMLAttributes<HTMLAnchorElement> {\n /**\n * The element type to render as. Recommended to use for Next apps with the\n * `Link` component.\n */\n as?: ElementType\n}\n\n/**\n * @deprecated use the {@link Menu} family instead\n */\nexport function NavMenuLink(props: NavMenuLinkProps): JSX.Element {\n const { as, ...nativeProps } = props\n const hasAs = Boolean(as)\n const AsSub: ElementType = as!\n\n return (\n <li\n className={css({\n w: 'full',\n })}\n >\n <Show\n when={hasAs}\n fallback={\n <a\n {...nativeProps}\n className={cx(\n nativeProps.className,\n css({\n color: 'action.navigation.initial',\n textStyle: 'link',\n _hover: {\n color: 'action.navigation.hover',\n },\n }),\n )}\n />\n }\n >\n {hasAs && <AsSub {...nativeProps} />}\n </Show>\n </li>\n )\n}\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAwB;;;ACCxB,mBAAgE;AA4BzD,SAAS,KAAK,OAAgD;AACnE,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,gBAAY,sBAAQ,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC;AAErD,aAAO,sBAAQ,MAAM;AACnB,QAAI,UAAW,QAAO;AACtB,WAAO,YAAY;AAAA,EACrB,GAAG,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;;;ADHU;AAdH,SAAS,YAAY,OAAsC;AAChE,QAAM,EAAE,IAAI,GAAG,YAAY,IAAI;AAC/B,QAAM,QAAQ,QAAQ,EAAE;AACxB,QAAM,QAAqB;AAE3B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,gBAAI;AAAA,QACb,GAAG;AAAA,MACL,CAAC;AAAA,MAED;AAAA,QAAC;AAAA;AAAA,UACC,MAAM;AAAA,UACN,UACE;AAAA,YAAC;AAAA;AAAA,cACE,GAAG;AAAA,cACJ,eAAW;AAAA,gBACT,YAAY;AAAA,oBACZ,gBAAI;AAAA,kBACF,OAAO;AAAA,kBACP,WAAW;AAAA,kBACX,QAAQ;AAAA,oBACN,OAAO;AAAA,kBACT;AAAA,gBACF,CAAC;AAAA,cACH;AAAA;AAAA,UACF;AAAA,UAGD,mBAAS,4CAAC,SAAO,GAAG,aAAa;AAAA;AAAA,MACpC;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/NavMenuList.tsx","../../../src/context/navMenu.tsx","../../../src/components/Show.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type HTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { useNavMenuContext } from '../context/navMenu'\nimport type { Positions } from '../types'\nimport { Show } from './Show'\n\n/**\n * This module contains the NavMenuList component.\n * @module\n */\n\ninterface GetPositionResult {\n /**\n * The left position of the element.\n */\n left: string\n /**\n * The right position of the element.\n */\n right: string\n /**\n * The top position of the element.\n */\n top: string\n /**\n * The bottom position of the element.\n */\n bottom: string\n}\n\n/**\n * @deprecated use the {@link Menu} family instead\n */\nexport function getPosition(position: Positions): GetPositionResult {\n const defaultPositions = {\n left: 'auto',\n right: 'auto',\n top: 'auto',\n bottom: 'auto',\n }\n switch (position) {\n case 'right':\n return { ...defaultPositions, top: '0%', left: '105%' }\n case 'left':\n return { ...defaultPositions, top: '0%', right: '105%' }\n case 'bottom':\n return { ...defaultPositions, top: '110%' }\n case 'top':\n return { ...defaultPositions, bottom: '110%' }\n default:\n return defaultPositions\n }\n}\n\nconst navListStyles = vstack({\n alignItems: 'flex-start',\n bgColor: 'page.surface.100',\n boxShadow: 'lg',\n gap: '2',\n opacity: '0',\n p: '4',\n position: 'absolute',\n rounded: 'md',\n zIndex: 'dropdown',\n _motionSafe: {\n animationName: 'zoomIn',\n animationDelay: '100ms',\n animationDuration: '150ms',\n animationFillMode: 'both',\n animationTimingFunction: 'ease-in-out',\n },\n _positionBottom: {\n transformOrigin: 'top left',\n },\n _positionTop: {\n transformOrigin: 'bottom left',\n },\n _positionLeft: {\n transformOrigin: 'top right',\n },\n _positionRight: {\n transformOrigin: 'top left',\n },\n})\n\nexport interface NavMenuListProps extends HTMLAttributes<HTMLUListElement> {\n /**\n * The unique identifier for the NavMenuList. Required for accessibility.\n */\n id: string\n /**\n * The position of the NavMenuList.\n * @type 'top' | 'right' | 'bottom' | 'left'\n * @default 'bottom'\n */\n position?: Positions\n}\n\n/**\n * A component that allows the user to display a menu of navigation links.\n * @definition [Disclosure Nav](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/)\n * @see https://cerberus.digitalu.design/react/nav-menu\n *\n * @example\n * ```tsx\n * <NavMenu>\n * <NavMenuList id=\"nav-menu-list\" position=\"bottom\">\n * <NavMenuLink href=\"/home\">Home</NavMenuLink>\n * <NavMenuLink href=\"/about\">About</NavMenuLink>\n * </NavMenuList>\n * </NavMenu>\n * ```\n **/\nexport function NavMenuList(props: NavMenuListProps): JSX.Element {\n const { position, ...nativeProps } = props\n const { menuRef, expanded } = useNavMenuContext()\n const locationStyles = useMemo(\n () => getPosition(position ?? 'bottom'),\n [position],\n )\n\n return (\n <Show when={expanded}>\n <ul\n {...nativeProps}\n data-position={position ?? 'bottom'}\n className={cx(nativeProps.className, navListStyles)}\n ref={menuRef}\n style={locationStyles}\n />\n </Show>\n )\n}\n","'use client'\n\nimport { css } from '@cerberus/styled-system/css'\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type PropsWithChildren,\n type RefObject,\n} from 'react'\n\n/**\n * This module provides a context and hook for the nav menu.\n * @module NavMenu\n */\n\nexport type NavTriggerRef = RefObject<HTMLButtonElement>\nexport type NavMenuRef = RefObject<HTMLUListElement>\n\nexport interface NavMenuContextValue {\n /**\n * The ref for the trigger button.\n */\n triggerRef: NavTriggerRef | null\n /**\n * The ref for the menu.\n */\n menuRef: NavMenuRef | null\n /**\n * Whether the menu is expanded.\n */\n expanded: boolean\n /**\n * Called when the menu button is clicked.\n */\n onToggle: () => void\n}\n\nconst NavMenuContext = createContext<NavMenuContextValue | null>(null)\n\n/**\n * @deprecated use the {@link Menu} family instead\n */\nexport function NavMenu(props: PropsWithChildren): JSX.Element {\n const triggerRef = useRef<HTMLButtonElement>(null)\n const menuRef = useRef<HTMLUListElement>(null)\n const [expanded, setExpanded] = useState<boolean>(false)\n\n const handleToggle = useCallback(() => {\n setExpanded((prev) => !prev)\n }, [])\n\n const value = useMemo(\n () => ({\n triggerRef,\n menuRef,\n expanded,\n onToggle: handleToggle,\n }),\n [expanded, handleToggle],\n )\n\n return (\n <NavMenuContext.Provider value={value}>\n <nav\n className={css({\n position: 'relative',\n })}\n >\n {props.children}\n </nav>\n </NavMenuContext.Provider>\n )\n}\n\n/**\n * Used to access the nav menu context.\n * @returns The nav menu context.\n */\nexport function useNavMenuContext(): NavMenuContextValue {\n const context = useContext(NavMenuContext)\n if (!context) {\n throw new Error('useNavMenuContext must be used within a NavMenu.')\n }\n return context\n}\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAA6C;AAC7C,IAAAC,cAAmB;AACnB,sBAAuB;;;ACFvB,iBAAoB;AACpB,mBASO;AAuDD;AA1BN,IAAM,qBAAiB,4BAA0C,IAAI;AAyC9D,SAAS,oBAAyC;AACvD,QAAM,cAAU,yBAAW,cAAc;AACzC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAO;AACT;;;ACtFA,IAAAC,gBAAgE;AA4BzD,SAAS,KAAK,OAAgD;AACnE,QAAM,EAAE,MAAM,UAAU,SAAS,IAAI;AACrC,QAAM,gBAAY,uBAAQ,MAAM,QAAQ,OAAO,CAAC,IAAI,CAAC;AAErD,aAAO,uBAAQ,MAAM;AACnB,QAAI,UAAW,QAAO;AACtB,WAAO,YAAY;AAAA,EACrB,GAAG,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;;;AFwFM,IAAAC,sBAAA;AA1FC,SAAS,YAAY,UAAwC;AAClE,QAAM,mBAAmB;AAAA,IACvB,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,QAAQ;AAAA,EACV;AACA,UAAQ,UAAU;AAAA,IAChB,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,MAAM,OAAO;AAAA,IACxD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,MAAM,OAAO,OAAO;AAAA,IACzD,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,KAAK,OAAO;AAAA,IAC5C,KAAK;AACH,aAAO,EAAE,GAAG,kBAAkB,QAAQ,OAAO;AAAA,IAC/C;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,oBAAgB,wBAAO;AAAA,EAC3B,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,WAAW;AAAA,EACX,KAAK;AAAA,EACL,SAAS;AAAA,EACT,GAAG;AAAA,EACH,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,IACX,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,yBAAyB;AAAA,EAC3B;AAAA,EACA,iBAAiB;AAAA,IACf,iBAAiB;AAAA,EACnB;AAAA,EACA,cAAc;AAAA,IACZ,iBAAiB;AAAA,EACnB;AAAA,EACA,eAAe;AAAA,IACb,iBAAiB;AAAA,EACnB;AAAA,EACA,gBAAgB;AAAA,IACd,iBAAiB;AAAA,EACnB;AACF,CAAC;AA8BM,SAAS,YAAY,OAAsC;AAChE,QAAM,EAAE,UAAU,GAAG,YAAY,IAAI;AACrC,QAAM,EAAE,SAAS,SAAS,IAAI,kBAAkB;AAChD,QAAM,qBAAiB;AAAA,IACrB,MAAM,YAAY,YAAY,QAAQ;AAAA,IACtC,CAAC,QAAQ;AAAA,EACX;AAEA,SACE,6CAAC,QAAK,MAAM,UACV;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,iBAAe,YAAY;AAAA,MAC3B,eAAW,gBAAG,YAAY,WAAW,aAAa;AAAA,MAClD,KAAK;AAAA,MACL,OAAO;AAAA;AAAA,EACT,GACF;AAEJ;","names":["import_react","import_css","import_react","import_jsx_runtime"]}
|