@fragments-sdk/ui 0.11.1 → 0.13.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/README.md +15 -0
- package/dist/assets/ui.css +25 -18
- package/dist/blocks/AccountSettings.block.d.ts +1 -1
- package/dist/blocks/ActivityFeed.block.d.ts +1 -1
- package/dist/blocks/ActivityFeedSkeleton.block.d.ts +1 -1
- package/dist/blocks/BlogEditor.block.d.ts +1 -1
- package/dist/blocks/ChatInterface.block.d.ts +1 -1
- package/dist/blocks/ChatMessages.block.d.ts +1 -1
- package/dist/blocks/CheckoutForm.block.d.ts +1 -1
- package/dist/blocks/CommandPalette.block.d.ts +1 -1
- package/dist/blocks/ContactForm.block.d.ts +1 -1
- package/dist/blocks/DashboardLayout.block.d.ts +1 -1
- package/dist/blocks/DashboardPage.block.d.ts +1 -1
- package/dist/blocks/DashboardSkeleton.block.d.ts +1 -1
- package/dist/blocks/DataTable.block.d.ts +1 -1
- package/dist/blocks/EmptyState.block.d.ts +1 -1
- package/dist/blocks/FAQSection.block.d.ts +1 -1
- package/dist/blocks/FeatureGrid.block.d.ts +1 -1
- package/dist/blocks/HeroSection.block.d.ts +1 -1
- package/dist/blocks/LoginForm.block.d.ts +1 -1
- package/dist/blocks/NavigationHeader.block.d.ts +1 -1
- package/dist/blocks/PaginatedTable.block.d.ts +1 -1
- package/dist/blocks/PricingComparison.block.d.ts +1 -1
- package/dist/blocks/ProductCard.block.d.ts +1 -1
- package/dist/blocks/RegistrationForm.block.d.ts +1 -1
- package/dist/blocks/SettingsDrawer.block.d.ts +1 -1
- package/dist/blocks/SettingsPanel.block.d.ts +1 -1
- package/dist/blocks/ShoppingCart.block.d.ts +1 -1
- package/dist/blocks/StatsCard.block.d.ts +1 -1
- package/dist/blocks/StatsCardSkeleton.block.d.ts +1 -1
- package/dist/blocks/TableSkeleton.block.d.ts +1 -1
- package/dist/blocks/ThinkingStates.block.d.ts +1 -1
- package/dist/codeblock.cjs +7 -1
- package/dist/codeblock.cjs.map +1 -1
- package/dist/codeblock.js +7 -1
- package/dist/codeblock.js.map +1 -1
- package/dist/components/Accordion/index.cjs +11 -4
- package/dist/components/Accordion/index.cjs.map +1 -1
- package/dist/components/Accordion/index.d.ts +3 -3
- package/dist/components/Accordion/index.d.ts.map +1 -1
- package/dist/components/Accordion/index.js +11 -4
- package/dist/components/Accordion/index.js.map +1 -1
- package/dist/components/Alert/index.cjs.map +1 -1
- package/dist/components/Alert/index.d.ts +7 -0
- package/dist/components/Alert/index.d.ts.map +1 -1
- package/dist/components/Alert/index.js.map +1 -1
- package/dist/components/Avatar/index.cjs.map +1 -1
- package/dist/components/Avatar/index.d.ts +4 -0
- package/dist/components/Avatar/index.d.ts.map +1 -1
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.ts +12 -0
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Button/index.cjs +9 -1
- package/dist/components/Button/index.cjs.map +1 -1
- package/dist/components/Button/index.d.ts +14 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +9 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Card/index.cjs +2 -1
- package/dist/components/Card/index.cjs.map +1 -1
- package/dist/components/Card/index.d.ts +12 -2
- package/dist/components/Card/index.d.ts.map +1 -1
- package/dist/components/Card/index.js +2 -1
- package/dist/components/Card/index.js.map +1 -1
- package/dist/components/Checkbox/index.cjs.map +1 -1
- package/dist/components/Checkbox/index.d.ts +6 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Chip/index.cjs +2 -1
- package/dist/components/Chip/index.cjs.map +1 -1
- package/dist/components/Chip/index.d.ts +10 -3
- package/dist/components/Chip/index.d.ts.map +1 -1
- package/dist/components/Chip/index.js +2 -1
- package/dist/components/Chip/index.js.map +1 -1
- package/dist/components/CodeBlock/index.d.ts +1 -1
- package/dist/components/CodeBlock/index.d.ts.map +1 -1
- package/dist/components/Collapsible/index.cjs +45 -10
- package/dist/components/Collapsible/index.cjs.map +1 -1
- package/dist/components/Collapsible/index.d.ts +6 -12
- package/dist/components/Collapsible/index.d.ts.map +1 -1
- package/dist/components/Collapsible/index.js +45 -10
- package/dist/components/Collapsible/index.js.map +1 -1
- package/dist/components/Combobox/index.cjs +18 -9
- package/dist/components/Combobox/index.cjs.map +1 -1
- package/dist/components/Combobox/index.d.ts +8 -12
- package/dist/components/Combobox/index.d.ts.map +1 -1
- package/dist/components/Combobox/index.js +18 -9
- package/dist/components/Combobox/index.js.map +1 -1
- package/dist/components/Command/index.cjs +54 -21
- package/dist/components/Command/index.cjs.map +1 -1
- package/dist/components/Command/index.d.ts +2 -2
- package/dist/components/Command/index.d.ts.map +1 -1
- package/dist/components/Command/index.js +54 -21
- package/dist/components/Command/index.js.map +1 -1
- package/dist/components/DataTable/index.cjs +13 -1
- package/dist/components/DataTable/index.cjs.map +1 -1
- package/dist/components/DataTable/index.d.ts.map +1 -1
- package/dist/components/DataTable/index.js +13 -1
- package/dist/components/DataTable/index.js.map +1 -1
- package/dist/components/DatePicker/index.d.ts +2 -3
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/Dialog/index.cjs +12 -9
- package/dist/components/Dialog/index.cjs.map +1 -1
- package/dist/components/Dialog/index.d.ts +20 -12
- package/dist/components/Dialog/index.d.ts.map +1 -1
- package/dist/components/Dialog/index.js +12 -9
- package/dist/components/Dialog/index.js.map +1 -1
- package/dist/components/Drawer/index.cjs +12 -9
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.ts +22 -12
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +12 -9
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Grid/index.cjs +4 -1
- package/dist/components/Grid/index.cjs.map +1 -1
- package/dist/components/Grid/index.d.ts +6 -2
- package/dist/components/Grid/index.d.ts.map +1 -1
- package/dist/components/Grid/index.js +4 -1
- package/dist/components/Grid/index.js.map +1 -1
- package/dist/components/Input/index.cjs.map +1 -1
- package/dist/components/Input/index.d.ts +15 -1
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Menu/index.cjs +30 -16
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.ts +17 -25
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +30 -16
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenuContext.cjs.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenuContext.d.ts +1 -0
- package/dist/components/NavigationMenu/NavigationMenuContext.d.ts.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenuContext.js.map +1 -1
- package/dist/components/NavigationMenu/index.cjs +43 -11
- package/dist/components/NavigationMenu/index.cjs.map +1 -1
- package/dist/components/NavigationMenu/index.d.ts.map +1 -1
- package/dist/components/NavigationMenu/index.js +43 -11
- package/dist/components/NavigationMenu/index.js.map +1 -1
- package/dist/components/NavigationMenu/useNavigationMenu.cjs +2 -0
- package/dist/components/NavigationMenu/useNavigationMenu.cjs.map +1 -1
- package/dist/components/NavigationMenu/useNavigationMenu.d.ts +1 -0
- package/dist/components/NavigationMenu/useNavigationMenu.d.ts.map +1 -1
- package/dist/components/NavigationMenu/useNavigationMenu.js +2 -0
- package/dist/components/NavigationMenu/useNavigationMenu.js.map +1 -1
- package/dist/components/Popover/index.cjs +11 -10
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.ts +17 -12
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +11 -10
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/RadioGroup/index.cjs.map +1 -1
- package/dist/components/RadioGroup/index.d.ts +4 -0
- package/dist/components/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/RadioGroup/index.js.map +1 -1
- package/dist/components/Select/index.cjs +7 -6
- package/dist/components/Select/index.cjs.map +1 -1
- package/dist/components/Select/index.d.ts +20 -9
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +7 -6
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Sidebar/index.cjs +71 -24
- package/dist/components/Sidebar/index.cjs.map +1 -1
- package/dist/components/Sidebar/index.d.ts +21 -33
- package/dist/components/Sidebar/index.d.ts.map +1 -1
- package/dist/components/Sidebar/index.js +71 -24
- package/dist/components/Sidebar/index.js.map +1 -1
- package/dist/components/Slider/index.cjs +3 -1
- package/dist/components/Slider/index.cjs.map +1 -1
- package/dist/components/Slider/index.d.ts +10 -0
- package/dist/components/Slider/index.d.ts.map +1 -1
- package/dist/components/Slider/index.js +3 -1
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Stack/index.cjs +6 -0
- package/dist/components/Stack/index.cjs.map +1 -1
- package/dist/components/Stack/index.d.ts +12 -6
- package/dist/components/Stack/index.d.ts.map +1 -1
- package/dist/components/Stack/index.js +6 -0
- package/dist/components/Stack/index.js.map +1 -1
- package/dist/components/Tabs/index.cjs.map +1 -1
- package/dist/components/Tabs/index.d.ts +13 -1
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Text/Text.module.scss.cjs +44 -32
- package/dist/components/Text/Text.module.scss.cjs.map +1 -1
- package/dist/components/Text/Text.module.scss.js +44 -32
- package/dist/components/Text/Text.module.scss.js.map +1 -1
- package/dist/components/Text/index.cjs.map +1 -1
- package/dist/components/Text/index.d.ts +18 -3
- package/dist/components/Text/index.d.ts.map +1 -1
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Theme/index.cjs.map +1 -1
- package/dist/components/Theme/index.d.ts +12 -0
- package/dist/components/Theme/index.d.ts.map +1 -1
- package/dist/components/Theme/index.js.map +1 -1
- package/dist/components/Toggle/index.cjs +2 -1
- package/dist/components/Toggle/index.cjs.map +1 -1
- package/dist/components/Toggle/index.d.ts +9 -0
- package/dist/components/Toggle/index.d.ts.map +1 -1
- package/dist/components/Toggle/index.js +2 -1
- package/dist/components/Toggle/index.js.map +1 -1
- package/dist/components/ToggleGroup/index.cjs +4 -1
- package/dist/components/ToggleGroup/index.cjs.map +1 -1
- package/dist/components/ToggleGroup/index.d.ts +13 -4
- package/dist/components/ToggleGroup/index.d.ts.map +1 -1
- package/dist/components/ToggleGroup/index.js +4 -1
- package/dist/components/ToggleGroup/index.js.map +1 -1
- package/dist/components/Tooltip/index.cjs +20 -10
- package/dist/components/Tooltip/index.cjs.map +1 -1
- package/dist/components/Tooltip/index.d.ts +5 -1
- package/dist/components/Tooltip/index.d.ts.map +1 -1
- package/dist/components/Tooltip/index.js +20 -10
- package/dist/components/Tooltip/index.js.map +1 -1
- package/dist/datepicker.cjs +24 -10
- package/dist/datepicker.cjs.map +1 -1
- package/dist/datepicker.js +24 -10
- package/dist/datepicker.js.map +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/css-warning.cjs +18 -0
- package/dist/utils/css-warning.cjs.map +1 -0
- package/dist/utils/css-warning.d.ts +2 -0
- package/dist/utils/css-warning.d.ts.map +1 -0
- package/dist/utils/css-warning.js +18 -0
- package/dist/utils/css-warning.js.map +1 -0
- package/fragments.json +1 -1
- package/package.json +2 -2
- package/src/components/Accordion/Accordion.test.tsx +33 -0
- package/src/components/Accordion/index.tsx +10 -3
- package/src/components/Alert/index.tsx +7 -0
- package/src/components/Avatar/index.tsx +4 -0
- package/src/components/Badge/Badge.fragment.tsx +10 -2
- package/src/components/Badge/index.tsx +12 -0
- package/src/components/Button/Button.fragment.tsx +12 -2
- package/src/components/Button/Button.test.tsx +16 -0
- package/src/components/Button/index.tsx +27 -2
- package/src/components/Card/Card.fragment.tsx +14 -2
- package/src/components/Card/Card.test.tsx +5 -0
- package/src/components/Card/index.tsx +15 -2
- package/src/components/Checkbox/index.tsx +6 -1
- package/src/components/Chip/Chip.fragment.tsx +12 -2
- package/src/components/Chip/Chip.test.tsx +5 -0
- package/src/components/Chip/index.tsx +14 -4
- package/src/components/CodeBlock/index.tsx +13 -2
- package/src/components/Collapsible/Collapsible.test.tsx +41 -0
- package/src/components/Collapsible/index.tsx +53 -16
- package/src/components/Combobox/Combobox.test.tsx +55 -0
- package/src/components/Combobox/index.tsx +23 -17
- package/src/components/Command/Command.test.tsx +93 -0
- package/src/components/Command/index.tsx +61 -18
- package/src/components/DataTable/DataTable.test.tsx +11 -2
- package/src/components/DataTable/index.tsx +22 -2
- package/src/components/DatePicker/DatePicker.test.tsx +79 -0
- package/src/components/DatePicker/index.tsx +29 -14
- package/src/components/Dialog/Dialog.test.tsx +23 -0
- package/src/components/Dialog/index.tsx +27 -16
- package/src/components/Drawer/Drawer.test.tsx +27 -0
- package/src/components/Drawer/index.tsx +29 -16
- package/src/components/Grid/Grid.fragment.tsx +14 -2
- package/src/components/Grid/Grid.test.tsx +6 -0
- package/src/components/Grid/index.tsx +12 -3
- package/src/components/Input/index.tsx +15 -1
- package/src/components/Menu/index.tsx +35 -30
- package/src/components/NavigationMenu/NavigationMenu.fragment.tsx +1 -1
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +40 -4
- package/src/components/NavigationMenu/NavigationMenuContext.ts +3 -0
- package/src/components/NavigationMenu/index.tsx +49 -13
- package/src/components/NavigationMenu/useNavigationMenu.ts +4 -0
- package/src/components/Popover/Popover.test.tsx +23 -0
- package/src/components/Popover/index.tsx +24 -18
- package/src/components/RadioGroup/index.tsx +4 -0
- package/src/components/Select/Select.test.tsx +41 -0
- package/src/components/Select/index.tsx +24 -12
- package/src/components/Sidebar/Sidebar.test.tsx +83 -4
- package/src/components/Sidebar/index.tsx +87 -45
- package/src/components/Slider/Slider.fragment.tsx +5 -1
- package/src/components/Slider/Slider.test.tsx +6 -0
- package/src/components/Slider/index.tsx +13 -1
- package/src/components/Stack/Stack.fragment.tsx +22 -2
- package/src/components/Stack/Stack.test.tsx +6 -0
- package/src/components/Stack/index.tsx +20 -6
- package/src/components/Tabs/index.tsx +13 -1
- package/src/components/Text/Text.fragment.tsx +10 -8
- package/src/components/Text/Text.module.scss +8 -2
- package/src/components/Text/Text.test.tsx +15 -0
- package/src/components/Text/index.tsx +18 -3
- package/src/components/Theme/index.tsx +12 -0
- package/src/components/Toggle/Toggle.fragment.tsx +5 -1
- package/src/components/Toggle/Toggle.test.tsx +19 -0
- package/src/components/Toggle/index.tsx +11 -1
- package/src/components/ToggleGroup/ToggleGroup.fragment.tsx +5 -2
- package/src/components/ToggleGroup/ToggleGroup.test.tsx +20 -0
- package/src/components/ToggleGroup/index.tsx +15 -4
- package/src/components/Tooltip/Tooltip.test.tsx +17 -0
- package/src/components/Tooltip/index.tsx +58 -34
- package/src/index.ts +6 -0
- package/src/tokens/_seeds.scss +5 -3
- package/src/tokens/_variables.scss +2 -0
- package/src/utils/css-warning.ts +29 -0
|
@@ -43,6 +43,7 @@ function useNavigationMenu({
|
|
|
43
43
|
const skipDelayTimerRef = React__namespace.useRef(null);
|
|
44
44
|
const triggerRefs = React__namespace.useRef(/* @__PURE__ */ new Map());
|
|
45
45
|
const triggerOrder = React__namespace.useRef([]);
|
|
46
|
+
const itemOrder = React__namespace.useRef([]);
|
|
46
47
|
const itemInfoMap = React__namespace.useRef(/* @__PURE__ */ new Map());
|
|
47
48
|
const [viewportSize, setViewportSize] = React__namespace.useState({ width: 0, height: 0 });
|
|
48
49
|
const viewportRef = React__namespace.useRef(null);
|
|
@@ -68,6 +69,7 @@ function useNavigationMenu({
|
|
|
68
69
|
skipDelayTimerRef,
|
|
69
70
|
triggerRefs,
|
|
70
71
|
triggerOrder,
|
|
72
|
+
itemOrder,
|
|
71
73
|
itemInfoMap,
|
|
72
74
|
viewportSize,
|
|
73
75
|
setViewportSize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigationMenu.cjs","sources":["../../../src/components/NavigationMenu/useNavigationMenu.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { NavigationMenuItemInfo } from './NavigationMenuContext';\n\nexport interface UseNavigationMenuOptions {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n delayDuration?: number;\n skipDelayDuration?: number;\n}\n\nexport function useNavigationMenu({\n value: controlledValue,\n defaultValue = '',\n onValueChange,\n delayDuration = 200,\n skipDelayDuration = 300,\n}: UseNavigationMenuOptions) {\n const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);\n const isControlled = controlledValue !== undefined;\n const value = isControlled ? controlledValue : uncontrolledValue;\n\n const setValue = React.useCallback(\n (newValue: string) => {\n if (!isControlled) {\n setUncontrolledValue(newValue);\n }\n onValueChange?.(newValue);\n },\n [isControlled, onValueChange]\n );\n\n // Hover delay timers\n const openTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n const closeTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Skip-delay: when moving between triggers, open instantly\n const isRecentlyOpenRef = React.useRef(false);\n const skipDelayTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Trigger registry for keyboard nav\n const triggerRefs = React.useRef<Map<string, HTMLButtonElement>>(new Map());\n const triggerOrder = React.useRef<string[]>([]);\n\n // Item info registry for mobile drawer\n const itemInfoMap = React.useRef<Map<string, NavigationMenuItemInfo>>(new Map());\n\n // Viewport sizing\n const [viewportSize, setViewportSize] = React.useState({ width: 0, height: 0 });\n const viewportRef = React.useRef<HTMLDivElement>(null);\n\n // Track previous value for animation direction\n const previousValue = React.useRef(value);\n\n // Mobile state\n const [mobileOpen, setMobileOpen] = React.useState(false);\n const [mobileContentChildren, setMobileContentChildren] = React.useState<React.ReactNode>(null);\n const [mobileBrandChildren, setMobileBrandChildren] = React.useState<React.ReactNode>(null);\n\n // Clean up timers on unmount\n React.useEffect(() => {\n return () => {\n if (openTimerRef.current) clearTimeout(openTimerRef.current);\n if (closeTimerRef.current) clearTimeout(closeTimerRef.current);\n if (skipDelayTimerRef.current) clearTimeout(skipDelayTimerRef.current);\n };\n }, []);\n\n return {\n value,\n setValue,\n delayDuration,\n skipDelayDuration,\n openTimerRef,\n closeTimerRef,\n isRecentlyOpenRef,\n skipDelayTimerRef,\n triggerRefs,\n triggerOrder,\n itemInfoMap,\n viewportSize,\n setViewportSize,\n viewportRef,\n previousValue,\n mobileOpen,\n setMobileOpen,\n mobileContentChildren,\n setMobileContentChildren,\n mobileBrandChildren,\n setMobileBrandChildren,\n };\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAaO,SAAS,kBAAkB;AAAA,EAChC,OAAO;AAAA,EACP,eAAe;AAAA,EACf;AAAA,EACA,gBAAgB;AAAA,EAChB,oBAAoB;AACtB,GAA6B;AAC3B,QAAM,CAAC,mBAAmB,oBAAoB,IAAIA,iBAAM,SAAS,YAAY;AAC7E,QAAM,eAAe,oBAAoB;AACzC,QAAM,QAAQ,eAAe,kBAAkB;AAE/C,QAAM,WAAWA,iBAAM;AAAA,IACrB,CAAC,aAAqB;AACpB,UAAI,CAAC,cAAc;AACjB,6BAAqB,QAAQ;AAAA,MAC/B;AACA,qDAAgB;AAAA,IAClB;AAAA,IACA,CAAC,cAAc,aAAa;AAAA,EAAA;AAI9B,QAAM,eAAeA,iBAAM,OAA6C,IAAI;AAC5E,QAAM,gBAAgBA,iBAAM,OAA6C,IAAI;AAG7E,QAAM,oBAAoBA,iBAAM,OAAO,KAAK;AAC5C,QAAM,oBAAoBA,iBAAM,OAA6C,IAAI;AAGjF,QAAM,cAAcA,iBAAM,OAAuC,oBAAI,KAAK;AAC1E,QAAM,eAAeA,iBAAM,OAAiB,EAAE;AAG9C,QAAM,cAAcA,iBAAM,OAA4C,oBAAI,KAAK;AAG/E,QAAM,CAAC,cAAc,eAAe,IAAIA,iBAAM,SAAS,EAAE,OAAO,GAAG,QAAQ,GAAG;AAC9E,QAAM,cAAcA,iBAAM,OAAuB,IAAI;AAGrD,QAAM,gBAAgBA,iBAAM,OAAO,KAAK;AAGxC,QAAM,CAAC,YAAY,aAAa,IAAIA,iBAAM,SAAS,KAAK;AACxD,QAAM,CAAC,uBAAuB,wBAAwB,IAAIA,iBAAM,SAA0B,IAAI;AAC9F,QAAM,CAAC,qBAAqB,sBAAsB,IAAIA,iBAAM,SAA0B,IAAI;AAG1FA,mBAAM,UAAU,MAAM;AACpB,WAAO,MAAM;AACX,UAAI,aAAa,QAAS,cAAa,aAAa,OAAO;AAC3D,UAAI,cAAc,QAAS,cAAa,cAAc,OAAO;AAC7D,UAAI,kBAAkB,QAAS,cAAa,kBAAkB,OAAO;AAAA,IACvE;AAAA,EACF,GAAG,CAAA,CAAE;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;"}
|
|
1
|
+
{"version":3,"file":"useNavigationMenu.cjs","sources":["../../../src/components/NavigationMenu/useNavigationMenu.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { NavigationMenuItemInfo } from './NavigationMenuContext';\n\nexport interface UseNavigationMenuOptions {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n delayDuration?: number;\n skipDelayDuration?: number;\n}\n\nexport function useNavigationMenu({\n value: controlledValue,\n defaultValue = '',\n onValueChange,\n delayDuration = 200,\n skipDelayDuration = 300,\n}: UseNavigationMenuOptions) {\n const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);\n const isControlled = controlledValue !== undefined;\n const value = isControlled ? controlledValue : uncontrolledValue;\n\n const setValue = React.useCallback(\n (newValue: string) => {\n if (!isControlled) {\n setUncontrolledValue(newValue);\n }\n onValueChange?.(newValue);\n },\n [isControlled, onValueChange]\n );\n\n // Hover delay timers\n const openTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n const closeTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Skip-delay: when moving between triggers, open instantly\n const isRecentlyOpenRef = React.useRef(false);\n const skipDelayTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Trigger registry for keyboard nav\n const triggerRefs = React.useRef<Map<string, HTMLButtonElement>>(new Map());\n const triggerOrder = React.useRef<string[]>([]);\n\n // Full item order registry (includes link-only items)\n const itemOrder = React.useRef<string[]>([]);\n\n // Item info registry for mobile drawer\n const itemInfoMap = React.useRef<Map<string, NavigationMenuItemInfo>>(new Map());\n\n // Viewport sizing\n const [viewportSize, setViewportSize] = React.useState({ width: 0, height: 0 });\n const viewportRef = React.useRef<HTMLDivElement>(null);\n\n // Track previous value for animation direction\n const previousValue = React.useRef(value);\n\n // Mobile state\n const [mobileOpen, setMobileOpen] = React.useState(false);\n const [mobileContentChildren, setMobileContentChildren] = React.useState<React.ReactNode>(null);\n const [mobileBrandChildren, setMobileBrandChildren] = React.useState<React.ReactNode>(null);\n\n // Clean up timers on unmount\n React.useEffect(() => {\n return () => {\n if (openTimerRef.current) clearTimeout(openTimerRef.current);\n if (closeTimerRef.current) clearTimeout(closeTimerRef.current);\n if (skipDelayTimerRef.current) clearTimeout(skipDelayTimerRef.current);\n };\n }, []);\n\n return {\n value,\n setValue,\n delayDuration,\n skipDelayDuration,\n openTimerRef,\n closeTimerRef,\n isRecentlyOpenRef,\n skipDelayTimerRef,\n triggerRefs,\n triggerOrder,\n itemOrder,\n itemInfoMap,\n viewportSize,\n setViewportSize,\n viewportRef,\n previousValue,\n mobileOpen,\n setMobileOpen,\n mobileContentChildren,\n setMobileContentChildren,\n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AAO,MAAM;AACX,UAAI,aAAa,QAAS,cAAa,aAAa,OAAO;AAC3D,UAAI,cAAc,QAAS,cAAa,cAAc,OAAO;AAC7D,UAAI,kBAAkB,QAAS,cAAa,kBAAkB,OAAO;AAAA,IACvE;AAAA,EACF,GAAG,CAAA,CAAE;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;"}
|
|
@@ -18,6 +18,7 @@ export declare function useNavigationMenu({ value: controlledValue, defaultValue
|
|
|
18
18
|
skipDelayTimerRef: React.RefObject<NodeJS.Timeout | null>;
|
|
19
19
|
triggerRefs: React.RefObject<Map<string, HTMLButtonElement>>;
|
|
20
20
|
triggerOrder: React.RefObject<string[]>;
|
|
21
|
+
itemOrder: React.RefObject<string[]>;
|
|
21
22
|
itemInfoMap: React.RefObject<Map<string, NavigationMenuItemInfo>>;
|
|
22
23
|
viewportSize: {
|
|
23
24
|
width: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigationMenu.d.ts","sourceRoot":"","sources":["../../../src/components/NavigationMenu/useNavigationMenu.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EAAE,eAAe,EACtB,YAAiB,EACjB,aAAa,EACb,aAAmB,EACnB,iBAAuB,GACxB,EAAE,wBAAwB;;yBAMZ,MAAM
|
|
1
|
+
{"version":3,"file":"useNavigationMenu.d.ts","sourceRoot":"","sources":["../../../src/components/NavigationMenu/useNavigationMenu.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EAAE,eAAe,EACtB,YAAiB,EACjB,aAAa,EACb,aAAmB,EACnB,iBAAuB,GACxB,EAAE,wBAAwB;;yBAMZ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwEpB"}
|
|
@@ -24,6 +24,7 @@ function useNavigationMenu({
|
|
|
24
24
|
const skipDelayTimerRef = React.useRef(null);
|
|
25
25
|
const triggerRefs = React.useRef(/* @__PURE__ */ new Map());
|
|
26
26
|
const triggerOrder = React.useRef([]);
|
|
27
|
+
const itemOrder = React.useRef([]);
|
|
27
28
|
const itemInfoMap = React.useRef(/* @__PURE__ */ new Map());
|
|
28
29
|
const [viewportSize, setViewportSize] = React.useState({ width: 0, height: 0 });
|
|
29
30
|
const viewportRef = React.useRef(null);
|
|
@@ -49,6 +50,7 @@ function useNavigationMenu({
|
|
|
49
50
|
skipDelayTimerRef,
|
|
50
51
|
triggerRefs,
|
|
51
52
|
triggerOrder,
|
|
53
|
+
itemOrder,
|
|
52
54
|
itemInfoMap,
|
|
53
55
|
viewportSize,
|
|
54
56
|
setViewportSize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNavigationMenu.js","sources":["../../../src/components/NavigationMenu/useNavigationMenu.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { NavigationMenuItemInfo } from './NavigationMenuContext';\n\nexport interface UseNavigationMenuOptions {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n delayDuration?: number;\n skipDelayDuration?: number;\n}\n\nexport function useNavigationMenu({\n value: controlledValue,\n defaultValue = '',\n onValueChange,\n delayDuration = 200,\n skipDelayDuration = 300,\n}: UseNavigationMenuOptions) {\n const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);\n const isControlled = controlledValue !== undefined;\n const value = isControlled ? controlledValue : uncontrolledValue;\n\n const setValue = React.useCallback(\n (newValue: string) => {\n if (!isControlled) {\n setUncontrolledValue(newValue);\n }\n onValueChange?.(newValue);\n },\n [isControlled, onValueChange]\n );\n\n // Hover delay timers\n const openTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n const closeTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Skip-delay: when moving between triggers, open instantly\n const isRecentlyOpenRef = React.useRef(false);\n const skipDelayTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Trigger registry for keyboard nav\n const triggerRefs = React.useRef<Map<string, HTMLButtonElement>>(new Map());\n const triggerOrder = React.useRef<string[]>([]);\n\n // Item info registry for mobile drawer\n const itemInfoMap = React.useRef<Map<string, NavigationMenuItemInfo>>(new Map());\n\n // Viewport sizing\n const [viewportSize, setViewportSize] = React.useState({ width: 0, height: 0 });\n const viewportRef = React.useRef<HTMLDivElement>(null);\n\n // Track previous value for animation direction\n const previousValue = React.useRef(value);\n\n // Mobile state\n const [mobileOpen, setMobileOpen] = React.useState(false);\n const [mobileContentChildren, setMobileContentChildren] = React.useState<React.ReactNode>(null);\n const [mobileBrandChildren, setMobileBrandChildren] = React.useState<React.ReactNode>(null);\n\n // Clean up timers on unmount\n React.useEffect(() => {\n return () => {\n if (openTimerRef.current) clearTimeout(openTimerRef.current);\n if (closeTimerRef.current) clearTimeout(closeTimerRef.current);\n if (skipDelayTimerRef.current) clearTimeout(skipDelayTimerRef.current);\n };\n }, []);\n\n return {\n value,\n setValue,\n delayDuration,\n skipDelayDuration,\n openTimerRef,\n closeTimerRef,\n isRecentlyOpenRef,\n skipDelayTimerRef,\n triggerRefs,\n triggerOrder,\n itemInfoMap,\n viewportSize,\n setViewportSize,\n viewportRef,\n previousValue,\n mobileOpen,\n setMobileOpen,\n mobileContentChildren,\n setMobileContentChildren,\n mobileBrandChildren,\n setMobileBrandChildren,\n };\n}\n"],"names":[],"mappings":";AAaO,SAAS,kBAAkB;AAAA,EAChC,OAAO;AAAA,EACP,eAAe;AAAA,EACf;AAAA,EACA,gBAAgB;AAAA,EAChB,oBAAoB;AACtB,GAA6B;AAC3B,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,MAAM,SAAS,YAAY;AAC7E,QAAM,eAAe,oBAAoB;AACzC,QAAM,QAAQ,eAAe,kBAAkB;AAE/C,QAAM,WAAW,MAAM;AAAA,IACrB,CAAC,aAAqB;AACpB,UAAI,CAAC,cAAc;AACjB,6BAAqB,QAAQ;AAAA,MAC/B;AACA,qDAAgB;AAAA,IAClB;AAAA,IACA,CAAC,cAAc,aAAa;AAAA,EAAA;AAI9B,QAAM,eAAe,MAAM,OAA6C,IAAI;AAC5E,QAAM,gBAAgB,MAAM,OAA6C,IAAI;AAG7E,QAAM,oBAAoB,MAAM,OAAO,KAAK;AAC5C,QAAM,oBAAoB,MAAM,OAA6C,IAAI;AAGjF,QAAM,cAAc,MAAM,OAAuC,oBAAI,KAAK;AAC1E,QAAM,eAAe,MAAM,OAAiB,EAAE;AAG9C,QAAM,cAAc,MAAM,OAA4C,oBAAI,KAAK;AAG/E,QAAM,CAAC,cAAc,eAAe,IAAI,MAAM,SAAS,EAAE,OAAO,GAAG,QAAQ,GAAG;AAC9E,QAAM,cAAc,MAAM,OAAuB,IAAI;AAGrD,QAAM,gBAAgB,MAAM,OAAO,KAAK;AAGxC,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,KAAK;AACxD,QAAM,CAAC,uBAAuB,wBAAwB,IAAI,MAAM,SAA0B,IAAI;AAC9F,QAAM,CAAC,qBAAqB,sBAAsB,IAAI,MAAM,SAA0B,IAAI;AAG1F,QAAM,UAAU,MAAM;AACpB,WAAO,MAAM;AACX,UAAI,aAAa,QAAS,cAAa,aAAa,OAAO;AAC3D,UAAI,cAAc,QAAS,cAAa,cAAc,OAAO;AAC7D,UAAI,kBAAkB,QAAS,cAAa,kBAAkB,OAAO;AAAA,IACvE;AAAA,EACF,GAAG,CAAA,CAAE;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"useNavigationMenu.js","sources":["../../../src/components/NavigationMenu/useNavigationMenu.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { NavigationMenuItemInfo } from './NavigationMenuContext';\n\nexport interface UseNavigationMenuOptions {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n delayDuration?: number;\n skipDelayDuration?: number;\n}\n\nexport function useNavigationMenu({\n value: controlledValue,\n defaultValue = '',\n onValueChange,\n delayDuration = 200,\n skipDelayDuration = 300,\n}: UseNavigationMenuOptions) {\n const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);\n const isControlled = controlledValue !== undefined;\n const value = isControlled ? controlledValue : uncontrolledValue;\n\n const setValue = React.useCallback(\n (newValue: string) => {\n if (!isControlled) {\n setUncontrolledValue(newValue);\n }\n onValueChange?.(newValue);\n },\n [isControlled, onValueChange]\n );\n\n // Hover delay timers\n const openTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n const closeTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Skip-delay: when moving between triggers, open instantly\n const isRecentlyOpenRef = React.useRef(false);\n const skipDelayTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Trigger registry for keyboard nav\n const triggerRefs = React.useRef<Map<string, HTMLButtonElement>>(new Map());\n const triggerOrder = React.useRef<string[]>([]);\n\n // Full item order registry (includes link-only items)\n const itemOrder = React.useRef<string[]>([]);\n\n // Item info registry for mobile drawer\n const itemInfoMap = React.useRef<Map<string, NavigationMenuItemInfo>>(new Map());\n\n // Viewport sizing\n const [viewportSize, setViewportSize] = React.useState({ width: 0, height: 0 });\n const viewportRef = React.useRef<HTMLDivElement>(null);\n\n // Track previous value for animation direction\n const previousValue = React.useRef(value);\n\n // Mobile state\n const [mobileOpen, setMobileOpen] = React.useState(false);\n const [mobileContentChildren, setMobileContentChildren] = React.useState<React.ReactNode>(null);\n const [mobileBrandChildren, setMobileBrandChildren] = React.useState<React.ReactNode>(null);\n\n // Clean up timers on unmount\n React.useEffect(() => {\n return () => {\n if (openTimerRef.current) clearTimeout(openTimerRef.current);\n if (closeTimerRef.current) clearTimeout(closeTimerRef.current);\n if (skipDelayTimerRef.current) clearTimeout(skipDelayTimerRef.current);\n };\n }, []);\n\n return {\n value,\n setValue,\n delayDuration,\n skipDelayDuration,\n openTimerRef,\n closeTimerRef,\n isRecentlyOpenRef,\n skipDelayTimerRef,\n triggerRefs,\n triggerOrder,\n itemOrder,\n itemInfoMap,\n viewportSize,\n setViewportSize,\n viewportRef,\n previousValue,\n mobileOpen,\n setMobileOpen,\n mobileContentChildren,\n setMobileContentChildren,\n mobileB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QAAS,cAAa,cAAc,OAAO;AAC7D,UAAI,kBAAkB,QAAS,cAAa,kBAAkB,OAAO;AAAA,IACvE;AAAA,EACF,GAAG,CAAA,CAAE;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -42,11 +42,11 @@ function PopoverRoot({
|
|
|
42
42
|
}
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
|
-
function PopoverTrigger({ children, asChild, className }) {
|
|
45
|
+
function PopoverTrigger({ children, asChild, className, ...htmlProps }) {
|
|
46
46
|
if (asChild) {
|
|
47
|
-
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Trigger, { className, render: children, children: null });
|
|
47
|
+
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Trigger, { ...htmlProps, className, render: children, children: null });
|
|
48
48
|
}
|
|
49
|
-
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Trigger, { className, children });
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Trigger, { ...htmlProps, className, children });
|
|
50
50
|
}
|
|
51
51
|
function PopoverContent({
|
|
52
52
|
children,
|
|
@@ -77,13 +77,13 @@ function PopoverContent({
|
|
|
77
77
|
}
|
|
78
78
|
) });
|
|
79
79
|
}
|
|
80
|
-
function PopoverTitle({ children, className }) {
|
|
80
|
+
function PopoverTitle({ children, className, ...htmlProps }) {
|
|
81
81
|
const classes = [Popover_module.default.title, className].filter(Boolean).join(" ");
|
|
82
|
-
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Title, { className: classes, children });
|
|
82
|
+
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Title, { ...htmlProps, className: classes, children });
|
|
83
83
|
}
|
|
84
|
-
function PopoverDescription({ children, className }) {
|
|
84
|
+
function PopoverDescription({ children, className, ...htmlProps }) {
|
|
85
85
|
const classes = [Popover_module.default.description, className].filter(Boolean).join(" ");
|
|
86
|
-
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Description, { className: classes, children });
|
|
86
|
+
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Description, { ...htmlProps, className: classes, children });
|
|
87
87
|
}
|
|
88
88
|
function PopoverBody({ children, className, ...htmlProps }) {
|
|
89
89
|
const classes = [Popover_module.default.body, className].filter(Boolean).join(" ");
|
|
@@ -93,11 +93,12 @@ function PopoverFooter({ children, className, ...htmlProps }) {
|
|
|
93
93
|
const classes = [Popover_module.default.footer, className].filter(Boolean).join(" ");
|
|
94
94
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...htmlProps, className: classes, children });
|
|
95
95
|
}
|
|
96
|
-
function PopoverClose({ children, asChild, className }) {
|
|
96
|
+
function PopoverClose({ children, asChild, className, ...htmlProps }) {
|
|
97
97
|
if (!children) {
|
|
98
98
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
99
99
|
popover.Popover.Close,
|
|
100
100
|
{
|
|
101
|
+
...htmlProps,
|
|
101
102
|
"aria-label": "Close popover",
|
|
102
103
|
className: [Popover_module.default.close, className].filter(Boolean).join(" "),
|
|
103
104
|
children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {})
|
|
@@ -105,9 +106,9 @@ function PopoverClose({ children, asChild, className }) {
|
|
|
105
106
|
);
|
|
106
107
|
}
|
|
107
108
|
if (asChild) {
|
|
108
|
-
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Close, { className, render: children, children: null });
|
|
109
|
+
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Close, { ...htmlProps, className, render: children, children: null });
|
|
109
110
|
}
|
|
110
|
-
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Close, { className, children });
|
|
111
|
+
return /* @__PURE__ */ jsxRuntime.jsx(popover.Popover.Close, { ...htmlProps, className, children });
|
|
111
112
|
}
|
|
112
113
|
const Popover = Object.assign(PopoverRoot, {
|
|
113
114
|
Trigger: PopoverTrigger,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/Popover/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport styles from './Popover.module.scss';\n\n// ============================================\n// Types\n// ============================================\n\nexport interface PopoverProps {\n children: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n modal?: boolean;\n}\n\nexport interface PopoverTriggerProps {\n children: React.ReactNode;\n asChild?: boolean;\n
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Popover/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport styles from './Popover.module.scss';\n\n// ============================================\n// Types\n// ============================================\n\n/**\n * Popover for floating content attached to a trigger element.\n * @see https://usefragments.com/components/popover\n */\nexport interface PopoverProps {\n children: React.ReactNode;\n /** Controlled open state */\n open?: boolean;\n /** Default open state */\n defaultOpen?: boolean;\n /** Called when open state changes */\n onOpenChange?: (open: boolean) => void;\n /** Whether the popover blocks interaction with the rest of the page.\n * @default false */\n modal?: boolean;\n}\n\nexport interface PopoverTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nexport interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n size?: 'sm' | 'md' | 'lg';\n side?: 'top' | 'bottom' | 'left' | 'right';\n align?: 'start' | 'center' | 'end';\n sideOffset?: number;\n arrow?: boolean;\n}\n\nexport interface PopoverTitleProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n children: React.ReactNode;\n}\n\nexport interface PopoverDescriptionProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n children: React.ReactNode;\n}\n\nexport interface PopoverBodyProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n}\n\nexport interface PopoverFooterProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n}\n\nexport interface PopoverCloseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n children?: React.ReactNode;\n asChild?: boolean;\n}\n\n// ============================================\n// Icons\n// ============================================\n\nfunction CloseIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n// ============================================\n// Components\n// ============================================\n\nfunction PopoverRoot({\n children,\n open,\n defaultOpen,\n onOpenChange,\n modal = false,\n}: PopoverProps) {\n return (\n <BasePopover.Root\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n modal={modal}\n >\n {children}\n </BasePopover.Root>\n );\n}\n\nfunction PopoverTrigger({ children, asChild, className, ...htmlProps }: PopoverTriggerProps) {\n if (asChild) {\n return (\n <BasePopover.Trigger {...htmlProps} className={className} render={children as React.ReactElement}>\n {null}\n </BasePopover.Trigger>\n );\n }\n\n return (\n <BasePopover.Trigger {...htmlProps} className={className}>\n {children}\n </BasePopover.Trigger>\n );\n}\n\nfunction PopoverContent({\n children,\n size = 'md',\n side = 'bottom',\n align = 'center',\n sideOffset = 8,\n arrow = false,\n className,\n ...htmlProps\n}: PopoverContentProps) {\n const popupClasses = [\n styles.popup,\n size !== 'md' && styles[size],\n className,\n ].filter(Boolean).join(' ');\n\n return (\n <BasePopover.Portal>\n <BasePopover.Positioner\n side={side}\n align={align}\n sideOffset={sideOffset}\n className={styles.positioner}\n >\n <BasePopover.Popup {...htmlProps} className={popupClasses}>\n {children}\n {arrow && <BasePopover.Arrow className={styles.arrow} />}\n </BasePopover.Popup>\n </BasePopover.Positioner>\n </BasePopover.Portal>\n );\n}\n\nfunction PopoverTitle({ children, className, ...htmlProps }: PopoverTitleProps) {\n const classes = [styles.title, className].filter(Boolean).join(' ');\n return <BasePopover.Title {...htmlProps} className={classes}>{children}</BasePopover.Title>;\n}\n\nfunction PopoverDescription({ children, className, ...htmlProps }: PopoverDescriptionProps) {\n const classes = [styles.description, className].filter(Boolean).join(' ');\n return (\n <BasePopover.Description {...htmlProps} className={classes}>\n {children}\n </BasePopover.Description>\n );\n}\n\nfunction PopoverBody({ children, className, ...htmlProps }: PopoverBodyProps) {\n const classes = [styles.body, className].filter(Boolean).join(' ');\n return <div {...htmlProps} className={classes}>{children}</div>;\n}\n\nfunction PopoverFooter({ children, className, ...htmlProps }: PopoverFooterProps) {\n const classes = [styles.footer, className].filter(Boolean).join(' ');\n return <div {...htmlProps} className={classes}>{children}</div>;\n}\n\nfunction PopoverClose({ children, asChild, className, ...htmlProps }: PopoverCloseProps) {\n // Default close button (X icon)\n if (!children) {\n return (\n <BasePopover.Close\n {...htmlProps}\n aria-label=\"Close popover\"\n className={[styles.close, className].filter(Boolean).join(' ')}\n >\n <CloseIcon />\n </BasePopover.Close>\n );\n }\n\n if (asChild) {\n return (\n <BasePopover.Close {...htmlProps} className={className} render={children as React.ReactElement}>\n {null}\n </BasePopover.Close>\n );\n }\n\n return (\n <BasePopover.Close {...htmlProps} className={className}>\n {children}\n </BasePopover.Close>\n );\n}\n\n// ============================================\n// Export compound component\n// ============================================\n\nexport const Popover = Object.assign(PopoverRoot, {\n Trigger: PopoverTrigger,\n Content: PopoverContent,\n Title: PopoverTitle,\n Description: PopoverDescription,\n Body: PopoverBody,\n Footer: PopoverFooter,\n Close: PopoverClose,\n});\n\n// Re-export individual components\nexport {\n PopoverRoot,\n PopoverTrigger,\n PopoverContent,\n PopoverTitle,\n PopoverDescription,\n PopoverBody,\n PopoverFooter,\n PopoverClose,\n};\n"],"names":["jsxs","jsx","BasePopover","styles"],"mappings":";;;;;AAkEA,SAAS,YAAY;AACnB,SACEA,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAM;AAAA,MACN,OAAM;AAAA,MACN,QAAO;AAAA,MACP,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA,MACf,eAAY;AAAA,MAEZ,UAAA;AAAA,QAAAC,2BAAAA,IAAC,QAAA,EAAK,IAAG,MAAK,IAAG,KAAI,IAAG,KAAI,IAAG,KAAA,CAAK;AAAA,QACpCA,2BAAAA,IAAC,UAAK,IAAG,KAAI,IAAG,KAAI,IAAG,MAAK,IAAG,KAAA,CAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG1C;AAMA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAAiB;AACf,SACEA,2BAAAA;AAAAA,IAACC,QAAAA,QAAY;AAAA,IAAZ;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA,IAAA;AAAA,EAAA;AAGP;AAEA,SAAS,eAAe,EAAE,UAAU,SAAS,WAAW,GAAG,aAAkC;AAC3F,MAAI,SAAS;AACX,WACED,+BAACC,QAAAA,QAAY,SAAZ,EAAqB,GAAG,WAAW,WAAsB,QAAQ,UAC/D,UAAA,KAAA,CACH;AAAA,EAEJ;AAEA,wCACGA,QAAAA,QAAY,SAAZ,EAAqB,GAAG,WAAW,WACjC,UACH;AAEJ;AAEA,SAAS,eAAe;AAAA,EACtB;AAAA,EACA,OAAO;AAAA,EACP,OAAO;AAAA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GAAG;AACjE,wCAAQ,OAAA,EAAK,GAAG,WAAW,WAAW,SAAU,UAAS;AAC3D;AAEA,SAAS,cAAc,EAAE,UAAU,WAAW,GAAG,aAAiC;AAChF,QAAM,UAAU,CAACA,eAAAA,QAAO,QAAQ,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACnE,wCAAQ,OAAA,EAAK,GAAG,WAAW,WAAW,SAAU,UAAS;AAC3D;AAEA,SAAS,aAAa,EAAE,UAAU,SAAS,WAAW,GAAG,aAAgC;AAEvF,MAAI,CAAC,UAAU;AACb,WACEF,2BAAAA;AAAAA,MAACC,QAAAA,QAAY;AAAA,MAAZ;AAAA,QACE,GAAG;AAAA,QACJ,cAAW;AAAA,QACX,WAAW,CAACC,uBAAO,OAAO,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,QAE7D,yCAAC,WAAA,CAAA,CAAU;AAAA,MAAA;AAAA,IAAA;AAAA,EAGjB;AAEA,MAAI,SAAS;AACX,WACEF,+BAACC,QAAAA,QAAY,OAAZ,EAAmB,GAAG,WAAW,WAAsB,QAAQ,UAC7D,UAAA,KAAA,CACH;AAAA,EAEJ;AAEA,wCACGA,QAAAA,QAAY,OAAZ,EAAmB,GAAG,WAAW,WAC/B,UACH;AAEJ;AAMO,MAAM,UAAU,OAAO,OAAO,aAAa;AAAA,EAChD,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AACT,CAAC;;;;;;;;;;"}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Popover for floating content attached to a trigger element.
|
|
4
|
+
* @see https://usefragments.com/components/popover
|
|
5
|
+
*/
|
|
2
6
|
export interface PopoverProps {
|
|
3
7
|
children: React.ReactNode;
|
|
8
|
+
/** Controlled open state */
|
|
4
9
|
open?: boolean;
|
|
10
|
+
/** Default open state */
|
|
5
11
|
defaultOpen?: boolean;
|
|
12
|
+
/** Called when open state changes */
|
|
6
13
|
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
/** Whether the popover blocks interaction with the rest of the page.
|
|
15
|
+
* @default false */
|
|
7
16
|
modal?: boolean;
|
|
8
17
|
}
|
|
9
|
-
export interface PopoverTriggerProps {
|
|
18
|
+
export interface PopoverTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
10
19
|
children: React.ReactNode;
|
|
11
20
|
asChild?: boolean;
|
|
12
|
-
className?: string;
|
|
13
21
|
}
|
|
14
22
|
export interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
15
23
|
children: React.ReactNode;
|
|
@@ -19,13 +27,11 @@ export interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement
|
|
|
19
27
|
sideOffset?: number;
|
|
20
28
|
arrow?: boolean;
|
|
21
29
|
}
|
|
22
|
-
export interface PopoverTitleProps {
|
|
30
|
+
export interface PopoverTitleProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
23
31
|
children: React.ReactNode;
|
|
24
|
-
className?: string;
|
|
25
32
|
}
|
|
26
|
-
export interface PopoverDescriptionProps {
|
|
33
|
+
export interface PopoverDescriptionProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
27
34
|
children: React.ReactNode;
|
|
28
|
-
className?: string;
|
|
29
35
|
}
|
|
30
36
|
export interface PopoverBodyProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
31
37
|
children: React.ReactNode;
|
|
@@ -33,19 +39,18 @@ export interface PopoverBodyProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
33
39
|
export interface PopoverFooterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
34
40
|
children: React.ReactNode;
|
|
35
41
|
}
|
|
36
|
-
export interface PopoverCloseProps {
|
|
42
|
+
export interface PopoverCloseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
37
43
|
children?: React.ReactNode;
|
|
38
44
|
asChild?: boolean;
|
|
39
|
-
className?: string;
|
|
40
45
|
}
|
|
41
46
|
declare function PopoverRoot({ children, open, defaultOpen, onOpenChange, modal, }: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
-
declare function PopoverTrigger({ children, asChild, className }: PopoverTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
declare function PopoverTrigger({ children, asChild, className, ...htmlProps }: PopoverTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
43
48
|
declare function PopoverContent({ children, size, side, align, sideOffset, arrow, className, ...htmlProps }: PopoverContentProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
-
declare function PopoverTitle({ children, className }: PopoverTitleProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
-
declare function PopoverDescription({ children, className }: PopoverDescriptionProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
declare function PopoverTitle({ children, className, ...htmlProps }: PopoverTitleProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
declare function PopoverDescription({ children, className, ...htmlProps }: PopoverDescriptionProps): import("react/jsx-runtime").JSX.Element;
|
|
46
51
|
declare function PopoverBody({ children, className, ...htmlProps }: PopoverBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
47
52
|
declare function PopoverFooter({ children, className, ...htmlProps }: PopoverFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
-
declare function PopoverClose({ children, asChild, className }: PopoverCloseProps): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
declare function PopoverClose({ children, asChild, className, ...htmlProps }: PopoverCloseProps): import("react/jsx-runtime").JSX.Element;
|
|
49
54
|
export declare const Popover: typeof PopoverRoot & {
|
|
50
55
|
Trigger: typeof PopoverTrigger;
|
|
51
56
|
Content: typeof PopoverContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/index.tsx"],"names":[],"mappings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,iBAAiB,2CAG7E;AAED,iBAAS,kBAAkB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE,uBAAuB,2CAOzF;AAED,iBAAS,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE,gBAAgB,2CAG3E;AAED,iBAAS,aAAa,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE,kBAAkB,2CAG/E;AAED,iBAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE,iBAAiB,2CA2BtF;AAMD,eAAO,MAAM,OAAO;;;;;;;;CAQlB,CAAC;AAGH,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,YAAY,GACb,CAAC"}
|
|
@@ -40,11 +40,11 @@ function PopoverRoot({
|
|
|
40
40
|
}
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
|
-
function PopoverTrigger({ children, asChild, className }) {
|
|
43
|
+
function PopoverTrigger({ children, asChild, className, ...htmlProps }) {
|
|
44
44
|
if (asChild) {
|
|
45
|
-
return /* @__PURE__ */ jsx(Popover$1.Trigger, { className, render: children, children: null });
|
|
45
|
+
return /* @__PURE__ */ jsx(Popover$1.Trigger, { ...htmlProps, className, render: children, children: null });
|
|
46
46
|
}
|
|
47
|
-
return /* @__PURE__ */ jsx(Popover$1.Trigger, { className, children });
|
|
47
|
+
return /* @__PURE__ */ jsx(Popover$1.Trigger, { ...htmlProps, className, children });
|
|
48
48
|
}
|
|
49
49
|
function PopoverContent({
|
|
50
50
|
children,
|
|
@@ -75,13 +75,13 @@ function PopoverContent({
|
|
|
75
75
|
}
|
|
76
76
|
) });
|
|
77
77
|
}
|
|
78
|
-
function PopoverTitle({ children, className }) {
|
|
78
|
+
function PopoverTitle({ children, className, ...htmlProps }) {
|
|
79
79
|
const classes = [styles.title, className].filter(Boolean).join(" ");
|
|
80
|
-
return /* @__PURE__ */ jsx(Popover$1.Title, { className: classes, children });
|
|
80
|
+
return /* @__PURE__ */ jsx(Popover$1.Title, { ...htmlProps, className: classes, children });
|
|
81
81
|
}
|
|
82
|
-
function PopoverDescription({ children, className }) {
|
|
82
|
+
function PopoverDescription({ children, className, ...htmlProps }) {
|
|
83
83
|
const classes = [styles.description, className].filter(Boolean).join(" ");
|
|
84
|
-
return /* @__PURE__ */ jsx(Popover$1.Description, { className: classes, children });
|
|
84
|
+
return /* @__PURE__ */ jsx(Popover$1.Description, { ...htmlProps, className: classes, children });
|
|
85
85
|
}
|
|
86
86
|
function PopoverBody({ children, className, ...htmlProps }) {
|
|
87
87
|
const classes = [styles.body, className].filter(Boolean).join(" ");
|
|
@@ -91,11 +91,12 @@ function PopoverFooter({ children, className, ...htmlProps }) {
|
|
|
91
91
|
const classes = [styles.footer, className].filter(Boolean).join(" ");
|
|
92
92
|
return /* @__PURE__ */ jsx("div", { ...htmlProps, className: classes, children });
|
|
93
93
|
}
|
|
94
|
-
function PopoverClose({ children, asChild, className }) {
|
|
94
|
+
function PopoverClose({ children, asChild, className, ...htmlProps }) {
|
|
95
95
|
if (!children) {
|
|
96
96
|
return /* @__PURE__ */ jsx(
|
|
97
97
|
Popover$1.Close,
|
|
98
98
|
{
|
|
99
|
+
...htmlProps,
|
|
99
100
|
"aria-label": "Close popover",
|
|
100
101
|
className: [styles.close, className].filter(Boolean).join(" "),
|
|
101
102
|
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
@@ -103,9 +104,9 @@ function PopoverClose({ children, asChild, className }) {
|
|
|
103
104
|
);
|
|
104
105
|
}
|
|
105
106
|
if (asChild) {
|
|
106
|
-
return /* @__PURE__ */ jsx(Popover$1.Close, { className, render: children, children: null });
|
|
107
|
+
return /* @__PURE__ */ jsx(Popover$1.Close, { ...htmlProps, className, render: children, children: null });
|
|
107
108
|
}
|
|
108
|
-
return /* @__PURE__ */ jsx(Popover$1.Close, { className, children });
|
|
109
|
+
return /* @__PURE__ */ jsx(Popover$1.Close, { ...htmlProps, className, children });
|
|
109
110
|
}
|
|
110
111
|
const Popover = Object.assign(PopoverRoot, {
|
|
111
112
|
Trigger: PopoverTrigger,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Popover/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport styles from './Popover.module.scss';\n\n// ============================================\n// Types\n// ============================================\n\nexport interface PopoverProps {\n children: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n modal?: boolean;\n}\n\nexport interface PopoverTriggerProps {\n children: React.ReactNode;\n asChild?: boolean;\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Popover/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport styles from './Popover.module.scss';\n\n// ============================================\n// Types\n// ============================================\n\n/**\n * Popover for floating content attached to a trigger element.\n * @see https://usefragments.com/components/popover\n */\nexport interface PopoverProps {\n children: React.ReactNode;\n /** Controlled open state */\n open?: boolean;\n /** Default open state */\n defaultOpen?: boolean;\n /** Called when open state changes */\n onOpenChange?: (open: boolean) => void;\n /** Whether the popover blocks interaction with the rest of the page.\n * @default false */\n modal?: boolean;\n}\n\nexport interface PopoverTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nexport interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n size?: 'sm' | 'md' | 'lg';\n side?: 'top' | 'bottom' | 'left' | 'right';\n align?: 'start' | 'center' | 'end';\n sideOffset?: number;\n arrow?: boolean;\n}\n\nexport interface PopoverTitleProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n children: React.ReactNode;\n}\n\nexport interface PopoverDescriptionProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n children: React.ReactNode;\n}\n\nexport interface PopoverBodyProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n}\n\nexport interface PopoverFooterProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n}\n\nexport interface PopoverCloseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n children?: React.ReactNode;\n asChild?: boolean;\n}\n\n// ============================================\n// Icons\n// ============================================\n\nfunction CloseIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n// ============================================\n// Components\n// ============================================\n\nfunction PopoverRoot({\n children,\n open,\n defaultOpen,\n onOpenChange,\n modal = false,\n}: PopoverProps) {\n return (\n <BasePopover.Root\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n modal={modal}\n >\n {children}\n </BasePopover.Root>\n );\n}\n\nfunction PopoverTrigger({ children, asChild, className, ...htmlProps }: PopoverTriggerProps) {\n if (asChild) {\n return (\n <BasePopover.Trigger {...htmlProps} className={className} render={children as React.ReactElement}>\n {null}\n </BasePopover.Trigger>\n );\n }\n\n return (\n <BasePopover.Trigger {...htmlProps} className={className}>\n {children}\n </BasePopover.Trigger>\n );\n}\n\nfunction PopoverContent({\n children,\n size = 'md',\n side = 'bottom',\n align = 'center',\n sideOffset = 8,\n arrow = false,\n className,\n ...htmlProps\n}: PopoverContentProps) {\n const popupClasses = [\n styles.popup,\n size !== 'md' && styles[size],\n className,\n ].filter(Boolean).join(' ');\n\n return (\n <BasePopover.Portal>\n <BasePopover.Positioner\n side={side}\n align={align}\n sideOffset={sideOffset}\n className={styles.positioner}\n >\n <BasePopover.Popup {...htmlProps} className={popupClasses}>\n {children}\n {arrow && <BasePopover.Arrow className={styles.arrow} />}\n </BasePopover.Popup>\n </BasePopover.Positioner>\n </BasePopover.Portal>\n );\n}\n\nfunction PopoverTitle({ children, className, ...htmlProps }: PopoverTitleProps) {\n const classes = [styles.title, className].filter(Boolean).join(' ');\n return <BasePopover.Title {...htmlProps} className={classes}>{children}</BasePopover.Title>;\n}\n\nfunction PopoverDescription({ children, className, ...htmlProps }: PopoverDescriptionProps) {\n const classes = [styles.description, className].filter(Boolean).join(' ');\n return (\n <BasePopover.Description {...htmlProps} className={classes}>\n {children}\n </BasePopover.Description>\n );\n}\n\nfunction PopoverBody({ children, className, ...htmlProps }: PopoverBodyProps) {\n const classes = [styles.body, className].filter(Boolean).join(' ');\n return <div {...htmlProps} className={classes}>{children}</div>;\n}\n\nfunction PopoverFooter({ children, className, ...htmlProps }: PopoverFooterProps) {\n const classes = [styles.footer, className].filter(Boolean).join(' ');\n return <div {...htmlProps} className={classes}>{children}</div>;\n}\n\nfunction PopoverClose({ children, asChild, className, ...htmlProps }: PopoverCloseProps) {\n // Default close button (X icon)\n if (!children) {\n return (\n <BasePopover.Close\n {...htmlProps}\n aria-label=\"Close popover\"\n className={[styles.close, className].filter(Boolean).join(' ')}\n >\n <CloseIcon />\n </BasePopover.Close>\n );\n }\n\n if (asChild) {\n return (\n <BasePopover.Close {...htmlProps} className={className} render={children as React.ReactElement}>\n {null}\n </BasePopover.Close>\n );\n }\n\n return (\n <BasePopover.Close {...htmlProps} className={className}>\n {children}\n </BasePopover.Close>\n );\n}\n\n// ============================================\n// Export compound component\n// ============================================\n\nexport const Popover = Object.assign(PopoverRoot, {\n Trigger: PopoverTrigger,\n Content: PopoverContent,\n Title: PopoverTitle,\n Description: PopoverDescription,\n Body: PopoverBody,\n Footer: PopoverFooter,\n Close: PopoverClose,\n});\n\n// Re-export individual components\nexport {\n PopoverRoot,\n PopoverTrigger,\n PopoverContent,\n PopoverTitle,\n PopoverDescription,\n PopoverBody,\n PopoverFooter,\n PopoverClose,\n};\n"],"names":["BasePopover"],"mappings":";;;AAkEA,SAAS,YAAY;AACnB,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAM;AAAA,MACN,OAAM;AAAA,MACN,QAAO;AAAA,MACP,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAY;AAAA,MACZ,eAAc;AAAA,MACd,gBAAe;AAAA,MACf,eAAY;AAAA,MAEZ,UAAA;AAAA,QAAA,oBAAC,QAAA,EAAK,IAAG,MAAK,IAAG,KAAI,IAAG,KAAI,IAAG,KAAA,CAAK;AAAA,QACpC,oBAAC,UAAK,IAAG,KAAI,IAAG,KAAI,IAAG,MAAK,IAAG,KAAA,CAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG1C;AAMA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAAiB;AACf,SACE;AAAA,IAACA,UAAY;AAAA,IAAZ;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA,IAAA;AAAA,EAAA;AAGP;AAEA,SAAS,eAAe,EAAE,UAAU,SAAS,WAAW,GAAG,aAAkC;AAC3F,MAAI,SAAS;AACX,WACE,oBAACA,UAAY,SAAZ,EAAqB,GAAG,WAAW,WAAsB,QAAQ,UAC/D,UAAA,KAAA,CACH;AAAA,EAEJ;AAEA,6BACGA,UAAY,SAAZ,EAAqB,GAAG,WAAW,WACjC,UACH;AAEJ;AAEA,SAAS,eAAe;AAAA,EACtB;AAAA,EACA,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;A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,OAAA,EAAK,GAAG,WAAW,WAAW,SAAU,UAAS;AAC3D;AAEA,SAAS,aAAa,EAAE,UAAU,SAAS,WAAW,GAAG,aAAgC;AAEvF,MAAI,CAAC,UAAU;AACb,WACE;AAAA,MAACA,UAAY;AAAA,MAAZ;AAAA,QACE,GAAG;AAAA,QACJ,cAAW;AAAA,QACX,WAAW,CAAC,OAAO,OAAO,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,QAE7D,8BAAC,WAAA,CAAA,CAAU;AAAA,MAAA;AAAA,IAAA;AAAA,EAGjB;AAEA,MAAI,SAAS;AACX,WACE,oBAACA,UAAY,OAAZ,EAAmB,GAAG,WAAW,WAAsB,QAAQ,UAC7D,UAAA,KAAA,CACH;AAAA,EAEJ;AAEA,6BACGA,UAAY,OAAZ,EAAmB,GAAG,WAAW,WAC/B,UACH;AAEJ;AAMO,MAAM,UAAU,OAAO,OAAO,aAAa;AAAA,EAChD,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AACT,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/RadioGroup/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';\nimport { Radio as BaseRadio } from '@base-ui/react/radio';\nimport styles from './RadioGroup.module.scss';\n\n// ============================================\n// Types\n// ============================================\n\nexport interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** Current value (controlled) */\n value?: string;\n /** Default value (uncontrolled) */\n defaultValue?: string;\n /** Callback when value changes */\n onValueChange?: (value: string) => void;\n /** Orientation of the radio group */\n orientation?: 'horizontal' | 'vertical';\n /** Whether the group is disabled */\n disabled?: boolean;\n /** Form field name */\n name?: string;\n /** Label for the group */\n label?: string;\n /** Error message */\n error?: string;\n /** Size variant */\n size?: 'sm' | 'md' | 'lg';\n /** Children (Radio.Item components) */\n children: React.ReactNode;\n}\n\nexport interface RadioItemProps {\n /** The value for this radio item */\n value: string;\n /** Label text */\n label?: string;\n /** Description text below the label */\n description?: string;\n /** Whether this item is disabled */\n disabled?: boolean;\n /** Accessible name for icon-only mode */\n 'aria-label'?: string;\n /** Accessible labelled-by relationship */\n 'aria-labelledby'?: string;\n /** Accessible described-by relationship */\n 'aria-describedby'?: string;\n /** Additional class name */\n className?: string;\n}\n\nfunction mergeAriaIds(...ids: Array<string | undefined>): string | undefined {\n const merged = ids.filter(Boolean).join(' ').trim();\n return merged.length > 0 ? merged : undefined;\n}\n\n// ============================================\n// Context for size\n// ============================================\n\nconst RadioSizeContext = React.createContext<'sm' | 'md' | 'lg'>('md');\n\n// ============================================\n// Radio Item Component\n// ============================================\n\nfunction RadioItem({\n value,\n label,\n description,\n disabled = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n className,\n}: RadioItemProps) {\n const size = React.useContext(RadioSizeContext);\n const id = React.useId();\n const labelId = label ? `radio-label-${id}` : undefined;\n const descriptionId = description ? `radio-desc-${id}` : undefined;\n\n const radioClasses = [\n styles.radio,\n size === 'sm' && styles.radioSm,\n size === 'lg' && styles.radioLg,\n ].filter(Boolean).join(' ');\n\n const labelClasses = [\n styles.label,\n size === 'sm' && styles.labelSm,\n size === 'lg' && styles.labelLg,\n ].filter(Boolean).join(' ');\n\n const wrapperClasses = [styles.itemWrapper, className].filter(Boolean).join(' ');\n\n // If no label/description, render just the radio\n if (!label && !description) {\n return (\n <BaseRadio.Root\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n className={[radioClasses, className].filter(Boolean).join(' ')}\n >\n <BaseRadio.Indicator className={styles.indicator} />\n </BaseRadio.Root>\n );\n }\n\n return (\n <label\n className={wrapperClasses}\n data-disabled={disabled || undefined}\n data-has-description={description ? true : undefined}\n >\n <BaseRadio.Root\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={mergeAriaIds(ariaLabelledBy, labelId)}\n aria-describedby={mergeAriaIds(ariaDescribedBy, descriptionId)}\n className={radioClasses}\n >\n <BaseRadio.Indicator className={styles.indicator} />\n </BaseRadio.Root>\n <div className={styles.content}>\n <span id={labelId} className={labelClasses}>{label}</span>\n {description && (\n <span id={descriptionId} className={styles.description}>{description}</span>\n )}\n </div>\n </label>\n );\n}\n\n// ============================================\n// Radio Group Component\n// ============================================\n\nfunction RadioGroupRoot({\n value,\n defaultValue,\n onValueChange,\n orientation = 'vertical',\n disabled = false,\n name,\n label,\n error,\n size = 'md',\n children,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...htmlProps\n}: RadioGroupProps) {\n const groupId = React.useId();\n const labelId = label ? `radio-group-label-${groupId}` : undefined;\n const errorId = error ? `radio-group-error-${groupId}` : undefined;\n\n const groupClasses = [\n styles.group,\n styles[orientation],\n className,\n ].filter(Boolean).join(' ');\n\n return (\n <RadioSizeContext.Provider value={size}>\n <div {...htmlProps} className={styles.wrapper}>\n {label && <span id={labelId} className={styles.groupLabel}>{label}</span>}\n <BaseRadioGroup\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n disabled={disabled}\n name={name}\n aria-label={ariaLabel}\n aria-labelledby={mergeAriaIds(ariaLabelledBy, labelId)}\n aria-describedby={mergeAriaIds(ariaDescribedBy, errorId)}\n className={groupClasses}\n >\n {children}\n </BaseRadioGroup>\n {error && <span id={errorId} className={styles.error}>{error}</span>}\n </div>\n </RadioSizeContext.Provider>\n );\n}\n\n// ============================================\n// Compound Component Export\n// ============================================\n\nexport const RadioGroup = Object.assign(RadioGroupRoot, {\n Item: RadioItem,\n});\n\nexport type { RadioGroupProps as RadioGroupRootProps };\n"],"names":["React","styles","jsx","BaseRadio.Root","BaseRadio.Indicator","jsxs","BaseRadioGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/RadioGroup/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';\nimport { Radio as BaseRadio } from '@base-ui/react/radio';\nimport styles from './RadioGroup.module.scss';\n\n// ============================================\n// Types\n// ============================================\n\n/**\n * Radio group for selecting one option from a set.\n * @see https://usefragments.com/components/radiogroup\n */\nexport interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** Current value (controlled) */\n value?: string;\n /** Default value (uncontrolled) */\n defaultValue?: string;\n /** Callback when value changes */\n onValueChange?: (value: string) => void;\n /** Orientation of the radio group */\n orientation?: 'horizontal' | 'vertical';\n /** Whether the group is disabled */\n disabled?: boolean;\n /** Form field name */\n name?: string;\n /** Label for the group */\n label?: string;\n /** Error message */\n error?: string;\n /** Size variant */\n size?: 'sm' | 'md' | 'lg';\n /** Children (Radio.Item components) */\n children: React.ReactNode;\n}\n\nexport interface RadioItemProps {\n /** The value for this radio item */\n value: string;\n /** Label text */\n label?: string;\n /** Description text below the label */\n description?: string;\n /** Whether this item is disabled */\n disabled?: boolean;\n /** Accessible name for icon-only mode */\n 'aria-label'?: string;\n /** Accessible labelled-by relationship */\n 'aria-labelledby'?: string;\n /** Accessible described-by relationship */\n 'aria-describedby'?: string;\n /** Additional class name */\n className?: string;\n}\n\nfunction mergeAriaIds(...ids: Array<string | undefined>): string | undefined {\n const merged = ids.filter(Boolean).join(' ').trim();\n return merged.length > 0 ? merged : undefined;\n}\n\n// ============================================\n// Context for size\n// ============================================\n\nconst RadioSizeContext = React.createContext<'sm' | 'md' | 'lg'>('md');\n\n// ============================================\n// Radio Item Component\n// ============================================\n\nfunction RadioItem({\n value,\n label,\n description,\n disabled = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n className,\n}: RadioItemProps) {\n const size = React.useContext(RadioSizeContext);\n const id = React.useId();\n const labelId = label ? `radio-label-${id}` : undefined;\n const descriptionId = description ? `radio-desc-${id}` : undefined;\n\n const radioClasses = [\n styles.radio,\n size === 'sm' && styles.radioSm,\n size === 'lg' && styles.radioLg,\n ].filter(Boolean).join(' ');\n\n const labelClasses = [\n styles.label,\n size === 'sm' && styles.labelSm,\n size === 'lg' && styles.labelLg,\n ].filter(Boolean).join(' ');\n\n const wrapperClasses = [styles.itemWrapper, className].filter(Boolean).join(' ');\n\n // If no label/description, render just the radio\n if (!label && !description) {\n return (\n <BaseRadio.Root\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n className={[radioClasses, className].filter(Boolean).join(' ')}\n >\n <BaseRadio.Indicator className={styles.indicator} />\n </BaseRadio.Root>\n );\n }\n\n return (\n <label\n className={wrapperClasses}\n data-disabled={disabled || undefined}\n data-has-description={description ? true : undefined}\n >\n <BaseRadio.Root\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={mergeAriaIds(ariaLabelledBy, labelId)}\n aria-describedby={mergeAriaIds(ariaDescribedBy, descriptionId)}\n className={radioClasses}\n >\n <BaseRadio.Indicator className={styles.indicator} />\n </BaseRadio.Root>\n <div className={styles.content}>\n <span id={labelId} className={labelClasses}>{label}</span>\n {description && (\n <span id={descriptionId} className={styles.description}>{description}</span>\n )}\n </div>\n </label>\n );\n}\n\n// ============================================\n// Radio Group Component\n// ============================================\n\nfunction RadioGroupRoot({\n value,\n defaultValue,\n onValueChange,\n orientation = 'vertical',\n disabled = false,\n name,\n label,\n error,\n size = 'md',\n children,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...htmlProps\n}: RadioGroupProps) {\n const groupId = React.useId();\n const labelId = label ? `radio-group-label-${groupId}` : undefined;\n const errorId = error ? `radio-group-error-${groupId}` : undefined;\n\n const groupClasses = [\n styles.group,\n styles[orientation],\n className,\n ].filter(Boolean).join(' ');\n\n return (\n <RadioSizeContext.Provider value={size}>\n <div {...htmlProps} className={styles.wrapper}>\n {label && <span id={labelId} className={styles.groupLabel}>{label}</span>}\n <BaseRadioGroup\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n disabled={disabled}\n name={name}\n aria-label={ariaLabel}\n aria-labelledby={mergeAriaIds(ariaLabelledBy, labelId)}\n aria-describedby={mergeAriaIds(ariaDescribedBy, errorId)}\n className={groupClasses}\n >\n {children}\n </BaseRadioGroup>\n {error && <span id={errorId} className={styles.error}>{error}</span>}\n </div>\n </RadioSizeContext.Provider>\n );\n}\n\n// ============================================\n// Compound Component Export\n// ============================================\n\nexport const RadioGroup = Object.assign(RadioGroupRoot, {\n Item: RadioItem,\n});\n\nexport type { RadioGroupProps as RadioGroupRootProps };\n"],"names":["React","styles","jsx","BaseRadio.Root","BaseRadio.Indicator","jsxs","BaseRadioGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAS,gBAAgB,KAAoD;AAC3E,QAAM,SAAS,IAAI,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,KAAA;AAC7C,SAAO,OAAO,SAAS,IAAI,SAAS;AACtC;AAMA,MAAM,mBAAmBA,iBAAM,cAAkC,IAAI;AAMrE,SAAS,UAAU;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB;AACF,GAAmB;AACjB,QAAM,OAAOA,iBAAM,WAAW,gBAAgB;AAC9C,QAAM,KAAKA,iBAAM,MAAA;AACjB,QAAM,UAAU,QAAQ,eAAe,EAAE,KAAK;AAC9C,QAAM,gBAAgB,cAAc,cAA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QACvD,WAAW;AAAA,QAEV;AAAA,MAAA;AAAA,IAAA;AAAA,IAEF,wCAAU,QAAA,EAAK,IAAI,SAAS,WAAWL,0BAAO,OAAQ,UAAA,MAAA,CAAM;AAAA,EAAA,EAAA,CAC/D,EAAA,CACF;AAEJ;AAMO,MAAM,aAAa,OAAO,OAAO,gBAAgB;AAAA,EACtD,MAAM;AACR,CAAC;;"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Radio group for selecting one option from a set.
|
|
4
|
+
* @see https://usefragments.com/components/radiogroup
|
|
5
|
+
*/
|
|
2
6
|
export interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
3
7
|
/** Current value (controlled) */
|
|
4
8
|
value?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RadioGroup/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,cAAc,CAAC;IAC9G,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,qCAAqC;IACrC,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,uCAAuC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2CAA2C;IAC3C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAiBD,iBAAS,SAAS,CAAC,EACjB,KAAK,EACL,KAAK,EACL,WAAW,EACX,QAAgB,EAChB,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,SAAS,GACV,EAAE,cAAc,2CA4DhB;AAMD,iBAAS,cAAc,CAAC,EACtB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,WAAwB,EACxB,QAAgB,EAChB,IAAI,EACJ,KAAK,EACL,KAAK,EACL,IAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,GAAG,SAAS,EACb,EAAE,eAAe,2CAgCjB;AAMD,eAAO,MAAM,UAAU;;CAErB,CAAC;AAEH,YAAY,EAAE,eAAe,IAAI,mBAAmB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RadioGroup/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,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,EACX,QAAgB,EAChB,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,SAAS,GACV,EAAE,cAAc,2CA4DhB;AAMD,iBAAS,cAAc,CAAC,EACtB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,WAAwB,EACxB,QAAgB,EAChB,IAAI,EACJ,KAAK,EACL,KAAK,EACL,IAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,GAAG,SAAS,EACb,EAAE,eAAe,2CAgCjB;AAMD,eAAO,MAAM,UAAU;;CAErB,CAAC;AAEH,YAAY,EAAE,eAAe,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/RadioGroup/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';\nimport { Radio as BaseRadio } from '@base-ui/react/radio';\nimport styles from './RadioGroup.module.scss';\n\n// ============================================\n// Types\n// ============================================\n\nexport interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** Current value (controlled) */\n value?: string;\n /** Default value (uncontrolled) */\n defaultValue?: string;\n /** Callback when value changes */\n onValueChange?: (value: string) => void;\n /** Orientation of the radio group */\n orientation?: 'horizontal' | 'vertical';\n /** Whether the group is disabled */\n disabled?: boolean;\n /** Form field name */\n name?: string;\n /** Label for the group */\n label?: string;\n /** Error message */\n error?: string;\n /** Size variant */\n size?: 'sm' | 'md' | 'lg';\n /** Children (Radio.Item components) */\n children: React.ReactNode;\n}\n\nexport interface RadioItemProps {\n /** The value for this radio item */\n value: string;\n /** Label text */\n label?: string;\n /** Description text below the label */\n description?: string;\n /** Whether this item is disabled */\n disabled?: boolean;\n /** Accessible name for icon-only mode */\n 'aria-label'?: string;\n /** Accessible labelled-by relationship */\n 'aria-labelledby'?: string;\n /** Accessible described-by relationship */\n 'aria-describedby'?: string;\n /** Additional class name */\n className?: string;\n}\n\nfunction mergeAriaIds(...ids: Array<string | undefined>): string | undefined {\n const merged = ids.filter(Boolean).join(' ').trim();\n return merged.length > 0 ? merged : undefined;\n}\n\n// ============================================\n// Context for size\n// ============================================\n\nconst RadioSizeContext = React.createContext<'sm' | 'md' | 'lg'>('md');\n\n// ============================================\n// Radio Item Component\n// ============================================\n\nfunction RadioItem({\n value,\n label,\n description,\n disabled = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n className,\n}: RadioItemProps) {\n const size = React.useContext(RadioSizeContext);\n const id = React.useId();\n const labelId = label ? `radio-label-${id}` : undefined;\n const descriptionId = description ? `radio-desc-${id}` : undefined;\n\n const radioClasses = [\n styles.radio,\n size === 'sm' && styles.radioSm,\n size === 'lg' && styles.radioLg,\n ].filter(Boolean).join(' ');\n\n const labelClasses = [\n styles.label,\n size === 'sm' && styles.labelSm,\n size === 'lg' && styles.labelLg,\n ].filter(Boolean).join(' ');\n\n const wrapperClasses = [styles.itemWrapper, className].filter(Boolean).join(' ');\n\n // If no label/description, render just the radio\n if (!label && !description) {\n return (\n <BaseRadio.Root\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n className={[radioClasses, className].filter(Boolean).join(' ')}\n >\n <BaseRadio.Indicator className={styles.indicator} />\n </BaseRadio.Root>\n );\n }\n\n return (\n <label\n className={wrapperClasses}\n data-disabled={disabled || undefined}\n data-has-description={description ? true : undefined}\n >\n <BaseRadio.Root\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={mergeAriaIds(ariaLabelledBy, labelId)}\n aria-describedby={mergeAriaIds(ariaDescribedBy, descriptionId)}\n className={radioClasses}\n >\n <BaseRadio.Indicator className={styles.indicator} />\n </BaseRadio.Root>\n <div className={styles.content}>\n <span id={labelId} className={labelClasses}>{label}</span>\n {description && (\n <span id={descriptionId} className={styles.description}>{description}</span>\n )}\n </div>\n </label>\n );\n}\n\n// ============================================\n// Radio Group Component\n// ============================================\n\nfunction RadioGroupRoot({\n value,\n defaultValue,\n onValueChange,\n orientation = 'vertical',\n disabled = false,\n name,\n label,\n error,\n size = 'md',\n children,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...htmlProps\n}: RadioGroupProps) {\n const groupId = React.useId();\n const labelId = label ? `radio-group-label-${groupId}` : undefined;\n const errorId = error ? `radio-group-error-${groupId}` : undefined;\n\n const groupClasses = [\n styles.group,\n styles[orientation],\n className,\n ].filter(Boolean).join(' ');\n\n return (\n <RadioSizeContext.Provider value={size}>\n <div {...htmlProps} className={styles.wrapper}>\n {label && <span id={labelId} className={styles.groupLabel}>{label}</span>}\n <BaseRadioGroup\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n disabled={disabled}\n name={name}\n aria-label={ariaLabel}\n aria-labelledby={mergeAriaIds(ariaLabelledBy, labelId)}\n aria-describedby={mergeAriaIds(ariaDescribedBy, errorId)}\n className={groupClasses}\n >\n {children}\n </BaseRadioGroup>\n {error && <span id={errorId} className={styles.error}>{error}</span>}\n </div>\n </RadioSizeContext.Provider>\n );\n}\n\n// ============================================\n// Compound Component Export\n// ============================================\n\nexport const RadioGroup = Object.assign(RadioGroupRoot, {\n Item: RadioItem,\n});\n\nexport type { RadioGroupProps as RadioGroupRootProps };\n"],"names":["BaseRadio.Root","BaseRadio.Indicator","BaseRadioGroup"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/RadioGroup/index.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group';\nimport { Radio as BaseRadio } from '@base-ui/react/radio';\nimport styles from './RadioGroup.module.scss';\n\n// ============================================\n// Types\n// ============================================\n\n/**\n * Radio group for selecting one option from a set.\n * @see https://usefragments.com/components/radiogroup\n */\nexport interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n /** Current value (controlled) */\n value?: string;\n /** Default value (uncontrolled) */\n defaultValue?: string;\n /** Callback when value changes */\n onValueChange?: (value: string) => void;\n /** Orientation of the radio group */\n orientation?: 'horizontal' | 'vertical';\n /** Whether the group is disabled */\n disabled?: boolean;\n /** Form field name */\n name?: string;\n /** Label for the group */\n label?: string;\n /** Error message */\n error?: string;\n /** Size variant */\n size?: 'sm' | 'md' | 'lg';\n /** Children (Radio.Item components) */\n children: React.ReactNode;\n}\n\nexport interface RadioItemProps {\n /** The value for this radio item */\n value: string;\n /** Label text */\n label?: string;\n /** Description text below the label */\n description?: string;\n /** Whether this item is disabled */\n disabled?: boolean;\n /** Accessible name for icon-only mode */\n 'aria-label'?: string;\n /** Accessible labelled-by relationship */\n 'aria-labelledby'?: string;\n /** Accessible described-by relationship */\n 'aria-describedby'?: string;\n /** Additional class name */\n className?: string;\n}\n\nfunction mergeAriaIds(...ids: Array<string | undefined>): string | undefined {\n const merged = ids.filter(Boolean).join(' ').trim();\n return merged.length > 0 ? merged : undefined;\n}\n\n// ============================================\n// Context for size\n// ============================================\n\nconst RadioSizeContext = React.createContext<'sm' | 'md' | 'lg'>('md');\n\n// ============================================\n// Radio Item Component\n// ============================================\n\nfunction RadioItem({\n value,\n label,\n description,\n disabled = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n className,\n}: RadioItemProps) {\n const size = React.useContext(RadioSizeContext);\n const id = React.useId();\n const labelId = label ? `radio-label-${id}` : undefined;\n const descriptionId = description ? `radio-desc-${id}` : undefined;\n\n const radioClasses = [\n styles.radio,\n size === 'sm' && styles.radioSm,\n size === 'lg' && styles.radioLg,\n ].filter(Boolean).join(' ');\n\n const labelClasses = [\n styles.label,\n size === 'sm' && styles.labelSm,\n size === 'lg' && styles.labelLg,\n ].filter(Boolean).join(' ');\n\n const wrapperClasses = [styles.itemWrapper, className].filter(Boolean).join(' ');\n\n // If no label/description, render just the radio\n if (!label && !description) {\n return (\n <BaseRadio.Root\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n className={[radioClasses, className].filter(Boolean).join(' ')}\n >\n <BaseRadio.Indicator className={styles.indicator} />\n </BaseRadio.Root>\n );\n }\n\n return (\n <label\n className={wrapperClasses}\n data-disabled={disabled || undefined}\n data-has-description={description ? true : undefined}\n >\n <BaseRadio.Root\n value={value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={mergeAriaIds(ariaLabelledBy, labelId)}\n aria-describedby={mergeAriaIds(ariaDescribedBy, descriptionId)}\n className={radioClasses}\n >\n <BaseRadio.Indicator className={styles.indicator} />\n </BaseRadio.Root>\n <div className={styles.content}>\n <span id={labelId} className={labelClasses}>{label}</span>\n {description && (\n <span id={descriptionId} className={styles.description}>{description}</span>\n )}\n </div>\n </label>\n );\n}\n\n// ============================================\n// Radio Group Component\n// ============================================\n\nfunction RadioGroupRoot({\n value,\n defaultValue,\n onValueChange,\n orientation = 'vertical',\n disabled = false,\n name,\n label,\n error,\n size = 'md',\n children,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...htmlProps\n}: RadioGroupProps) {\n const groupId = React.useId();\n const labelId = label ? `radio-group-label-${groupId}` : undefined;\n const errorId = error ? `radio-group-error-${groupId}` : undefined;\n\n const groupClasses = [\n styles.group,\n styles[orientation],\n className,\n ].filter(Boolean).join(' ');\n\n return (\n <RadioSizeContext.Provider value={size}>\n <div {...htmlProps} className={styles.wrapper}>\n {label && <span id={labelId} className={styles.groupLabel}>{label}</span>}\n <BaseRadioGroup\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n disabled={disabled}\n name={name}\n aria-label={ariaLabel}\n aria-labelledby={mergeAriaIds(ariaLabelledBy, labelId)}\n aria-describedby={mergeAriaIds(ariaDescribedBy, errorId)}\n className={groupClasses}\n >\n {children}\n </BaseRadioGroup>\n {error && <span id={errorId} className={styles.error}>{error}</span>}\n </div>\n </RadioSizeContext.Provider>\n );\n}\n\n// ============================================\n// Compound Component Export\n// ============================================\n\nexport const RadioGroup = Object.assign(RadioGroupRoot, {\n Item: RadioItem,\n});\n\nexport type { RadioGroupProps as RadioGroupRootProps };\n"],"names":["BaseRadio.Root","BaseRadio.Indicator","BaseRadioGroup"],"mappings":";;;;;;AAyDA,SAAS,gBAAgB,KAAoD;AAC3E,QAAM,SAAS,IAAI,OAAO,OAAO,EAAE,KAAK,GAAG,EAAE,KAAA;AAC7C,SAAO,OAAO,SAAS,IAAI,SAAS;AACtC;AAMA,MAAM,mBAAmB,MAAM,cAAkC,IAAI;AAMrE,SAAS,UAAU;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB;AACF,GAAmB;AACjB,QAAM,OAAO,MAAM,WAAW,gBAAgB;AAC9C,QAAM,KAAK,MAAM,MAAA;AACjB,QAAM,UAAU,QAAQ,eAAe,EAAE,KAAK;AAC9C,QAAM,gBAAgB,cAAc,cAAc,EAAE,KAAK;AAEzD,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,IACP,SAAS,QAAQ,OAAO;AAAA,IACxB,SAAS,QAAQ,OAAO;AAAA,EAAA,EACxB,OAAO,OAAO,EAAE,KAAK,GAAG;AAE1B,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,IACP,SAAS,QAAQ,OAAO;AAAA,IACxB,SAAS,QAAQ,OAAO;AAAA,EAAA,EACxB,OAAO,OAAO,EAAE,KAAK,GAAG;AAE1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AA,EACd,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,GAAG;AACL,GAAoB;AAClB,QAAM,UAAU,MAAM,MAAA;AACtB,QAAM,UAAU,QAAQ,qBAAqB,OAAO,KAAK;AACzD,QAAM,UAAU,QAAQ,qBAAqB,OAAO,KAAK;AAEzD,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,IACP,OAAO,WAAW;AAAA,IAClB;AAAA,EAAA,EACA,OAAO,OAAO,EAAE,KAAK,GAAG;AAE1B,SACE,oBAAC,iBAAiB,UAAjB,EAA0B,OAAO,MAChC,UAAA,qBAAC,OAAA,EAAK,GAAG,WAAW,WAAW,OAAO,SACnC,UAAA;AAAA,IAAA,6BAAU,QAAA,EAAK,IAAI,SAAS,WAAW,OAAO,YAAa,UAAA,MAAA,CAAM;AAAA,IAClE;AAAA,MAACC;AAAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAY;AAAA,QACZ,mBAAiB,aAAa,gBAAgB,OAAO;AAAA,QACrD,oBAAkB,aAAa,iBAAiB,OAAO;AAAA,QACvD,WAAW;AAAA,QAEV;AAAA,MAAA;AAAA,IAAA;AAAA,IAEF,6BAAU,QAAA,EAAK,IAAI,SAAS,WAAW,OAAO,OAAQ,UAAA,MAAA,CAAM;AAAA,EAAA,EAAA,CAC/D,EAAA,CACF;AAEJ;AAMO,MAAM,aAAa,OAAO,OAAO,gBAAgB;AAAA,EACtD,MAAM;AACR,CAAC;"}
|
|
@@ -156,7 +156,7 @@ function SelectContent({
|
|
|
156
156
|
}
|
|
157
157
|
) });
|
|
158
158
|
}
|
|
159
|
-
function SelectItem({ children, value, disabled, className }) {
|
|
159
|
+
function SelectItem({ children, value, disabled, className, ...htmlProps }) {
|
|
160
160
|
const { itemsRef, incrementItemsVersion } = React__namespace.useContext(SelectContext);
|
|
161
161
|
const classes = [Select_module.default.item, className].filter(Boolean).join(" ");
|
|
162
162
|
React__namespace.useEffect(() => {
|
|
@@ -165,20 +165,21 @@ function SelectItem({ children, value, disabled, className }) {
|
|
|
165
165
|
incrementItemsVersion();
|
|
166
166
|
return () => {
|
|
167
167
|
items.delete(value);
|
|
168
|
+
incrementItemsVersion();
|
|
168
169
|
};
|
|
169
170
|
}, [itemsRef, incrementItemsVersion, value, children]);
|
|
170
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(select.Select.Item, { value, disabled, className: classes, children: [
|
|
171
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(select.Select.Item, { ...htmlProps, value, disabled, className: classes, children: [
|
|
171
172
|
/* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemText, { children }),
|
|
172
173
|
/* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemIndicator, { className: Select_module.default.itemIndicator, children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) })
|
|
173
174
|
] });
|
|
174
175
|
}
|
|
175
|
-
function SelectGroup({ children, className }) {
|
|
176
|
+
function SelectGroup({ children, className, ...htmlProps }) {
|
|
176
177
|
const classes = [Select_module.default.group, className].filter(Boolean).join(" ");
|
|
177
|
-
return /* @__PURE__ */ jsxRuntime.jsx(select.Select.Group, { className: classes, children });
|
|
178
|
+
return /* @__PURE__ */ jsxRuntime.jsx(select.Select.Group, { ...htmlProps, className: classes, children });
|
|
178
179
|
}
|
|
179
|
-
function SelectGroupLabel({ children, className }) {
|
|
180
|
+
function SelectGroupLabel({ children, className, ...htmlProps }) {
|
|
180
181
|
const classes = [Select_module.default.groupLabel, className].filter(Boolean).join(" ");
|
|
181
|
-
return /* @__PURE__ */ jsxRuntime.jsx(select.Select.GroupLabel, { className: classes, children });
|
|
182
|
+
return /* @__PURE__ */ jsxRuntime.jsx(select.Select.GroupLabel, { ...htmlProps, className: classes, children });
|
|
182
183
|
}
|
|
183
184
|
const Select = Object.assign(SelectRoot, {
|
|
184
185
|
Trigger: SelectTrigger,
|