jaci-ui 0.7.0 → 0.8.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/CHANGELOG.md +6 -0
- package/README.md +17 -0
- package/dist/components/alert-dialog/alert-dialog.cjs +4 -1
- package/dist/components/alert-dialog/alert-dialog.cjs.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.d.cts +2 -2
- package/dist/components/alert-dialog/alert-dialog.d.ts +2 -2
- package/dist/components/alert-dialog/alert-dialog.js +4 -1
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/color-picker/color-picker.cjs +4 -1
- package/dist/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/components/color-picker/color-picker.d.cts +2 -2
- package/dist/components/color-picker/color-picker.d.ts +2 -2
- package/dist/components/color-picker/color-picker.js +4 -1
- package/dist/components/color-picker/color-picker.js.map +1 -1
- package/dist/components/combobox/combobox.cjs +4 -1
- package/dist/components/combobox/combobox.cjs.map +1 -1
- package/dist/components/combobox/combobox.d.cts +2 -2
- package/dist/components/combobox/combobox.d.ts +2 -2
- package/dist/components/combobox/combobox.js +4 -1
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/command/command.cjs +73 -12
- package/dist/components/command/command.cjs.map +1 -1
- package/dist/components/command/command.d.cts +7 -1
- package/dist/components/command/command.d.ts +7 -1
- package/dist/components/command/command.js +73 -12
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/command/index.d.cts +2 -2
- package/dist/components/command/index.d.ts +2 -2
- package/dist/components/context-menu/context-menu.cjs +4 -1
- package/dist/components/context-menu/context-menu.cjs.map +1 -1
- package/dist/components/context-menu/context-menu.d.cts +2 -2
- package/dist/components/context-menu/context-menu.d.ts +2 -2
- package/dist/components/context-menu/context-menu.js +4 -1
- package/dist/components/context-menu/context-menu.js.map +1 -1
- package/dist/components/date-picker/date-picker.cjs +4 -1
- package/dist/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/components/date-picker/date-picker.d.cts +2 -2
- package/dist/components/date-picker/date-picker.d.ts +2 -2
- package/dist/components/date-picker/date-picker.js +4 -1
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.cjs +4 -1
- package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.d.cts +2 -2
- package/dist/components/date-range-picker/date-range-picker.d.ts +2 -2
- package/dist/components/date-range-picker/date-range-picker.js +4 -1
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/dialog/dialog.cjs +4 -1
- package/dist/components/dialog/dialog.cjs.map +1 -1
- package/dist/components/dialog/dialog.d.cts +2 -2
- package/dist/components/dialog/dialog.d.ts +2 -2
- package/dist/components/dialog/dialog.js +4 -1
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.cjs +4 -1
- package/dist/components/drawer/drawer.cjs.map +1 -1
- package/dist/components/drawer/drawer.d.cts +2 -2
- package/dist/components/drawer/drawer.d.ts +2 -2
- package/dist/components/drawer/drawer.js +4 -1
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/figure/figure.cjs +45 -36
- package/dist/components/figure/figure.cjs.map +1 -1
- package/dist/components/figure/figure.js +45 -36
- package/dist/components/figure/figure.js.map +1 -1
- package/dist/components/image/image.cjs +41 -32
- package/dist/components/image/image.cjs.map +1 -1
- package/dist/components/image/image.js +41 -32
- package/dist/components/image/image.js.map +1 -1
- package/dist/components/menu/menu.cjs +4 -1
- package/dist/components/menu/menu.cjs.map +1 -1
- package/dist/components/menu/menu.d.cts +2 -2
- package/dist/components/menu/menu.d.ts +2 -2
- package/dist/components/menu/menu.js +4 -1
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/menubar/menubar.cjs +4 -1
- package/dist/components/menubar/menubar.cjs.map +1 -1
- package/dist/components/menubar/menubar.d.cts +2 -2
- package/dist/components/menubar/menubar.d.ts +2 -2
- package/dist/components/menubar/menubar.js +4 -1
- package/dist/components/menubar/menubar.js.map +1 -1
- package/dist/components/navigation/navigation.cjs +3 -1
- package/dist/components/navigation/navigation.cjs.map +1 -1
- package/dist/components/navigation/navigation.js +3 -1
- package/dist/components/navigation/navigation.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.cjs +4 -1
- package/dist/components/navigation-menu/navigation-menu.cjs.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.d.cts +2 -2
- package/dist/components/navigation-menu/navigation-menu.d.ts +2 -2
- package/dist/components/navigation-menu/navigation-menu.js +4 -1
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/popover/popover.cjs +4 -1
- package/dist/components/popover/popover.cjs.map +1 -1
- package/dist/components/popover/popover.d.cts +2 -2
- package/dist/components/popover/popover.d.ts +2 -2
- package/dist/components/popover/popover.js +4 -1
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/select/select.cjs +4 -1
- package/dist/components/select/select.cjs.map +1 -1
- package/dist/components/select/select.d.cts +2 -2
- package/dist/components/select/select.d.ts +2 -2
- package/dist/components/select/select.js +4 -1
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/sidebar/sidebar.cjs +24 -17
- package/dist/components/sidebar/sidebar.cjs.map +1 -1
- package/dist/components/sidebar/sidebar.d.cts +4 -2
- package/dist/components/sidebar/sidebar.d.ts +4 -2
- package/dist/components/sidebar/sidebar.js +24 -17
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/toast/toast.cjs +4 -1
- package/dist/components/toast/toast.cjs.map +1 -1
- package/dist/components/toast/toast.d.cts +1 -1
- package/dist/components/toast/toast.d.ts +1 -1
- package/dist/components/toast/toast.js +4 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/tooltip/tooltip.cjs +4 -1
- package/dist/components/tooltip/tooltip.cjs.map +1 -1
- package/dist/components/tooltip/tooltip.d.cts +2 -2
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/tooltip.js +4 -1
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/styled-system/recipes/command.cjs +3 -3
- package/dist/styled-system/recipes/command.cjs.map +1 -1
- package/dist/styled-system/recipes/command.js +3 -3
- package/dist/styled-system/recipes/command.js.map +1 -1
- package/dist/styled-system/recipes/figure.cjs +1 -0
- package/dist/styled-system/recipes/figure.cjs.map +1 -1
- package/dist/styled-system/recipes/figure.js +1 -0
- package/dist/styled-system/recipes/figure.js.map +1 -1
- package/dist/styled-system/recipes/image.cjs +1 -0
- package/dist/styled-system/recipes/image.cjs.map +1 -1
- package/dist/styled-system/recipes/image.js +1 -0
- package/dist/styled-system/recipes/image.js.map +1 -1
- package/dist/styles.css +70 -50
- package/dist/theme/theme-provider.cjs +18 -8
- package/dist/theme/theme-provider.cjs.map +1 -1
- package/dist/theme/theme-provider.js +18 -8
- package/dist/theme/theme-provider.js.map +1 -1
- package/dist/theme/theme-scope.cjs +21 -0
- package/dist/theme/theme-scope.cjs.map +1 -0
- package/dist/theme/theme-scope.js +19 -0
- package/dist/theme/theme-scope.js.map +1 -0
- package/package.json +7 -4
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const require_cx = require("../../styled-system/css/cx.cjs");
|
|
3
3
|
const require_base_ui = require("../base-ui.cjs");
|
|
4
4
|
const require_sidebar = require("../../styled-system/recipes/sidebar.cjs");
|
|
5
|
+
const require_theme_scope = require("../../theme/theme-scope.cjs");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
8
|
let _base_ui_react_dialog = require("@base-ui/react/dialog");
|
|
@@ -45,6 +46,7 @@ const SidebarRoot = (0, react.forwardRef)(function SidebarRoot({ children, class
|
|
|
45
46
|
toggle
|
|
46
47
|
]);
|
|
47
48
|
const styles = require_sidebar.sidebar({ open });
|
|
49
|
+
const scopedPortalProps = require_theme_scope.useThemePortalProps({});
|
|
48
50
|
const surface = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
|
|
49
51
|
...props,
|
|
50
52
|
ref,
|
|
@@ -67,23 +69,26 @@ const SidebarRoot = (0, react.forwardRef)(function SidebarRoot({ children, class
|
|
|
67
69
|
}
|
|
68
70
|
setOpen(nextOpen);
|
|
69
71
|
},
|
|
70
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_dialog.Dialog.Portal, {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Viewport, {
|
|
75
|
-
className: require_cx.cx(styles.viewport),
|
|
76
|
-
"data-slot": "sidebar-viewport",
|
|
77
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Popup, {
|
|
78
|
-
"aria-label": props["aria-label"] ?? "Sidebar navigation",
|
|
79
|
-
className: require_cx.cx(styles.popup),
|
|
72
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_dialog.Dialog.Portal, {
|
|
73
|
+
...scopedPortalProps,
|
|
74
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Backdrop, {
|
|
75
|
+
className: require_cx.cx(styles.backdrop),
|
|
80
76
|
"data-jaci-component": "sidebar",
|
|
81
|
-
"data-slot": "sidebar-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
"data-slot": "sidebar-backdrop"
|
|
78
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Viewport, {
|
|
79
|
+
className: require_cx.cx(styles.viewport),
|
|
80
|
+
"data-slot": "sidebar-viewport",
|
|
81
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Popup, {
|
|
82
|
+
"aria-label": props["aria-label"] ?? "Sidebar navigation",
|
|
83
|
+
className: require_cx.cx(styles.popup),
|
|
84
|
+
"data-jaci-component": "sidebar",
|
|
85
|
+
"data-slot": "sidebar-popup",
|
|
86
|
+
finalFocus: restoreFocus,
|
|
87
|
+
initialFocus: true,
|
|
88
|
+
children: surface
|
|
89
|
+
})
|
|
90
|
+
})]
|
|
91
|
+
})
|
|
87
92
|
})
|
|
88
93
|
});
|
|
89
94
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarContext.Provider, {
|
|
@@ -91,7 +96,9 @@ const SidebarRoot = (0, react.forwardRef)(function SidebarRoot({ children, class
|
|
|
91
96
|
children: surface
|
|
92
97
|
});
|
|
93
98
|
});
|
|
94
|
-
|
|
99
|
+
function SidebarPortal(props) {
|
|
100
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Portal, { ...require_theme_scope.useThemePortalProps(props) });
|
|
101
|
+
}
|
|
95
102
|
const SidebarBackdrop = (0, react.forwardRef)(function SidebarBackdrop({ className, ...props }, ref) {
|
|
96
103
|
const { open } = useSidebar();
|
|
97
104
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_dialog.Dialog.Backdrop, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.cjs","names":["sidebar","cx","BaseDialog","withRecipeClassName"],"sources":["../../../src/components/sidebar/sidebar.tsx"],"sourcesContent":["\"use client\";\n\nimport { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { sidebar } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\nexport interface SidebarContextValue {\n /** Whether the sidebar is visually expanded. */\n open: boolean;\n /** Updates the expanded state, respecting controlled usage. */\n setOpen: (open: boolean) => void;\n /** Convenience callback for toggles placed anywhere in the sidebar. */\n toggle: () => void;\n}\n\nconst SidebarContext = createContext<SidebarContextValue | null>(null);\n\n/**\n * Reads the state exposed by `Sidebar.Root`.\n *\n * Use it in custom sidebar parts when the built-in composition is not enough.\n */\nexport function useSidebar() {\n const context = useContext(SidebarContext);\n\n if (!context) {\n throw new Error(\"useSidebar must be used within a Sidebar.Root component.\");\n }\n\n return context;\n}\n\nfunction useSidebarStyles() {\n const { open } = useSidebar();\n return sidebar({ open });\n}\n\nexport interface SidebarRootProps extends ComponentPropsWithoutRef<\"aside\"> {\n /** Controlled expanded state. */\n open?: boolean;\n /** Initial expanded state for uncontrolled use. */\n defaultOpen?: boolean;\n /** Called after the requested expanded state changes. */\n onOpenChange?: (open: boolean) => void;\n /** Renders the sidebar as a modal mobile surface when set to overlay. */\n mode?: \"static\" | \"overlay\";\n /** Allows Escape to be disabled for overlay mode. */\n closeOnEscape?: boolean;\n /** Allows outside presses to be disabled for overlay mode. */\n closeOnOutsidePress?: boolean;\n /** Restores focus to the element that opened the overlay. */\n restoreFocus?: boolean;\n /** Controls whether the overlay traps focus and locks page scroll. */\n modal?: boolean | \"trap-focus\";\n children?: ReactNode;\n}\n\n/**\n * The sidebar container. It supports both controlled and uncontrolled state.\n */\nexport const SidebarRoot = forwardRef<HTMLElement, SidebarRootProps>(function SidebarRoot(\n {\n children,\n className,\n closeOnEscape = true,\n closeOnOutsidePress = true,\n defaultOpen = true,\n modal = true,\n mode = \"static\",\n onOpenChange,\n open: controlledOpen,\n restoreFocus = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isControlled = controlledOpen !== undefined;\n const open = controlledOpen ?? uncontrolledOpen;\n\n const setOpen = useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(nextOpen);\n }\n\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const toggle = useCallback(() => {\n setOpen(!open);\n }, [open, setOpen]);\n\n const context = useMemo<SidebarContextValue>(\n () => ({ open, setOpen, toggle }),\n [open, setOpen, toggle],\n );\n const styles = sidebar({ open });\n\n const surface = (\n <aside\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-jaci-component=\"sidebar\"\n data-open={open}\n data-slot=\"sidebar\"\n data-state={open ? \"open\" : \"closed\"}\n >\n {children}\n </aside>\n );\n\n if (mode === \"overlay\") {\n return (\n <SidebarContext.Provider value={context}>\n <BaseDialog.Root\n open={open}\n modal={modal}\n onOpenChange={(nextOpen, details) => {\n if (\n !nextOpen &&\n ((!closeOnEscape && details.reason === \"escape-key\") ||\n (!closeOnOutsidePress && details.reason === \"outside-press\"))\n ) {\n details.cancel();\n return;\n }\n setOpen(nextOpen);\n }}\n >\n <BaseDialog.Portal>\n <BaseDialog.Backdrop\n className={cx(styles.backdrop)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-backdrop\"\n />\n <BaseDialog.Viewport className={cx(styles.viewport)} data-slot=\"sidebar-viewport\">\n <BaseDialog.Popup\n aria-label={props[\"aria-label\"] ?? \"Sidebar navigation\"}\n className={cx(styles.popup)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-popup\"\n finalFocus={restoreFocus}\n initialFocus\n >\n {surface}\n </BaseDialog.Popup>\n </BaseDialog.Viewport>\n </BaseDialog.Portal>\n </BaseDialog.Root>\n </SidebarContext.Provider>\n );\n }\n\n return <SidebarContext.Provider value={context}>{surface}</SidebarContext.Provider>;\n});\n\nexport type SidebarPortalProps = ComponentPropsWithoutRef<typeof BaseDialog.Portal>;\nexport const SidebarPortal: typeof BaseDialog.Portal = BaseDialog.Portal;\n\nexport type SidebarBackdropProps = ComponentPropsWithoutRef<typeof BaseDialog.Backdrop>;\nexport const SidebarBackdrop = forwardRef<HTMLDivElement, SidebarBackdropProps>(\n function SidebarBackdrop({ className, ...props }, ref) {\n const { open } = useSidebar();\n return (\n <BaseDialog.Backdrop\n {...props}\n className={withRecipeClassName(sidebar({ open }).backdrop, className)}\n data-slot=\"sidebar-backdrop\"\n ref={ref}\n />\n );\n },\n);\n\nexport type SidebarToggleProps = ComponentPropsWithoutRef<\"button\">;\n\n/**\n * A floating, accessible control that expands or collapses the sidebar.\n */\nexport const SidebarToggle = forwardRef<HTMLButtonElement, SidebarToggleProps>(\n function SidebarToggle(\n { \"aria-label\": ariaLabel, children, className, onClick, type = \"button\", ...props },\n ref,\n ) {\n const { open, toggle } = useSidebar();\n const styles = useSidebarStyles();\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n\n if (!event.defaultPrevented) {\n toggle();\n }\n };\n\n return (\n <button\n {...props}\n aria-expanded={open}\n aria-label={ariaLabel ?? (open ? \"Collapse sidebar\" : \"Expand sidebar\")}\n className={cx(styles.toggle, className)}\n data-slot=\"sidebar-toggle\"\n onClick={handleClick}\n ref={ref}\n type={type}\n >\n {children ?? <span aria-hidden=\"true\">{open ? \"‹\" : \"›\"}</span>}\n </button>\n );\n },\n);\n\nexport type SidebarHeaderProps = ComponentPropsWithoutRef<\"header\">;\n\nexport const SidebarHeader = forwardRef<HTMLElement, SidebarHeaderProps>(function SidebarHeader(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <header\n {...props}\n ref={ref}\n className={cx(styles.header, className)}\n data-slot=\"sidebar-header\"\n />\n );\n});\n\nexport type SidebarContentProps = ComponentPropsWithoutRef<\"nav\">;\n\nexport const SidebarContent = forwardRef<HTMLElement, SidebarContentProps>(function SidebarContent(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Sidebar navigation\"}\n ref={ref}\n className={cx(styles.content, className)}\n data-slot=\"sidebar-content\"\n />\n );\n});\n\nexport type SidebarFooterProps = ComponentPropsWithoutRef<\"footer\">;\n\nexport const SidebarFooter = forwardRef<HTMLElement, SidebarFooterProps>(function SidebarFooter(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <footer\n {...props}\n ref={ref}\n className={cx(styles.footer, className)}\n data-slot=\"sidebar-footer\"\n />\n );\n});\n\nexport interface SidebarItemProps extends ComponentPropsWithoutRef<\"a\"> {\n /** Marks the current navigation destination. */\n active?: boolean;\n}\n\n/**\n * A semantic navigation item. Pair its icon/content with `Sidebar.Label` so\n * the text transitions out of view while remaining available to assistive\n * technology when the sidebar is collapsed.\n */\nexport const SidebarItem = forwardRef<HTMLAnchorElement, SidebarItemProps>(function SidebarItem(\n { \"aria-current\": ariaCurrent, active = false, className, ...props },\n ref,\n) {\n const { open } = useSidebar();\n const styles = sidebar({ active, open });\n\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n ref={ref}\n className={cx(styles.item, className)}\n data-active={active || undefined}\n data-slot=\"sidebar-item\"\n />\n );\n});\n\nexport type SidebarLabelProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const SidebarLabel = forwardRef<HTMLSpanElement, SidebarLabelProps>(function SidebarLabel(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <span {...props} ref={ref} className={cx(styles.label, className)} data-slot=\"sidebar-label\" />\n );\n});\n\nexport const Sidebar = {\n Root: SidebarRoot,\n Portal: SidebarPortal,\n Backdrop: SidebarBackdrop,\n Toggle: SidebarToggle,\n Header: SidebarHeader,\n Content: SidebarContent,\n Footer: SidebarFooter,\n Item: SidebarItem,\n Label: SidebarLabel,\n};\n"],"mappings":";;;;;;;;AAmBA,MAAM,kBAAA,GAAA,MAAA,cAAA,CAA2D,IAAI;;;;;;AAOrE,SAAgB,aAAa;CAC3B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,cAAc;CAEzC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,0DAA0D;C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AAO,QAAQ,SAAS;EACtC,aAAU;CACX,CAAA;AAEL,CAAC;;;;;;AAYD,MAAa,eAAA,GAAA,MAAA,WAAA,CAA8D,SAAS,YAClF,EAAE,gBAAgB,aAAa,SAAS,OAAO,WAAW,GAAG,SAC7D,KACA;CACA,MAAM,EAAE,SAAS,WAAW;CAC5B,MAAM,SAASD,gBAAAA,QAAQ;EAAE;EAAQ;CAAK,CAAC;CAEvC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EACE,GAAI;EACJ,gBAAc,gBAAgB,SAAS,SAAS,KAAA;EAC3C;EACL,WAAWC,WAAAA,GAAG,OAAO,MAAM,SAAS;EACpC,eAAa,UAAU,KAAA;EACvB,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA8D,SAAS,aAClF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,MAAM,SAAS,iBAAiB;CAEhC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAM,GAAI;EAAY;EAAK,WAAWA,WAAAA,GAAG,OAAO,OAAO,SAAS;EAAG,aAAU;CAAiB,CAAA;AAElG,CAAC;AAED,MAAa,UAAU;CACrB,MAAM;CACN,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,MAAM;CACN,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"sidebar.cjs","names":["sidebar","useThemePortalProps","cx","BaseDialog","withRecipeClassName"],"sources":["../../../src/components/sidebar/sidebar.tsx"],"sourcesContent":["\"use client\";\n\nimport { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { sidebar } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\nexport interface SidebarContextValue {\n /** Whether the sidebar is visually expanded. */\n open: boolean;\n /** Updates the expanded state, respecting controlled usage. */\n setOpen: (open: boolean) => void;\n /** Convenience callback for toggles placed anywhere in the sidebar. */\n toggle: () => void;\n}\n\nconst SidebarContext = createContext<SidebarContextValue | null>(null);\n\n/**\n * Reads the state exposed by `Sidebar.Root`.\n *\n * Use it in custom sidebar parts when the built-in composition is not enough.\n */\nexport function useSidebar() {\n const context = useContext(SidebarContext);\n\n if (!context) {\n throw new Error(\"useSidebar must be used within a Sidebar.Root component.\");\n }\n\n return context;\n}\n\nfunction useSidebarStyles() {\n const { open } = useSidebar();\n return sidebar({ open });\n}\n\nexport interface SidebarRootProps extends ComponentPropsWithoutRef<\"aside\"> {\n /** Controlled expanded state. */\n open?: boolean;\n /** Initial expanded state for uncontrolled use. */\n defaultOpen?: boolean;\n /** Called after the requested expanded state changes. */\n onOpenChange?: (open: boolean) => void;\n /** Renders the sidebar as a modal mobile surface when set to overlay. */\n mode?: \"static\" | \"overlay\";\n /** Allows Escape to be disabled for overlay mode. */\n closeOnEscape?: boolean;\n /** Allows outside presses to be disabled for overlay mode. */\n closeOnOutsidePress?: boolean;\n /** Restores focus to the element that opened the overlay. */\n restoreFocus?: boolean;\n /** Controls whether the overlay traps focus and locks page scroll. */\n modal?: boolean | \"trap-focus\";\n children?: ReactNode;\n}\n\n/**\n * The sidebar container. It supports both controlled and uncontrolled state.\n */\nexport const SidebarRoot = forwardRef<HTMLElement, SidebarRootProps>(function SidebarRoot(\n {\n children,\n className,\n closeOnEscape = true,\n closeOnOutsidePress = true,\n defaultOpen = true,\n modal = true,\n mode = \"static\",\n onOpenChange,\n open: controlledOpen,\n restoreFocus = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isControlled = controlledOpen !== undefined;\n const open = controlledOpen ?? uncontrolledOpen;\n\n const setOpen = useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(nextOpen);\n }\n\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const toggle = useCallback(() => {\n setOpen(!open);\n }, [open, setOpen]);\n\n const context = useMemo<SidebarContextValue>(\n () => ({ open, setOpen, toggle }),\n [open, setOpen, toggle],\n );\n const styles = sidebar({ open });\n const scopedPortalProps = useThemePortalProps({});\n\n const surface = (\n <aside\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-jaci-component=\"sidebar\"\n data-open={open}\n data-slot=\"sidebar\"\n data-state={open ? \"open\" : \"closed\"}\n >\n {children}\n </aside>\n );\n\n if (mode === \"overlay\") {\n return (\n <SidebarContext.Provider value={context}>\n <BaseDialog.Root\n open={open}\n modal={modal}\n onOpenChange={(nextOpen, details) => {\n if (\n !nextOpen &&\n ((!closeOnEscape && details.reason === \"escape-key\") ||\n (!closeOnOutsidePress && details.reason === \"outside-press\"))\n ) {\n details.cancel();\n return;\n }\n setOpen(nextOpen);\n }}\n >\n <BaseDialog.Portal {...scopedPortalProps}>\n <BaseDialog.Backdrop\n className={cx(styles.backdrop)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-backdrop\"\n />\n <BaseDialog.Viewport className={cx(styles.viewport)} data-slot=\"sidebar-viewport\">\n <BaseDialog.Popup\n aria-label={props[\"aria-label\"] ?? \"Sidebar navigation\"}\n className={cx(styles.popup)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-popup\"\n finalFocus={restoreFocus}\n initialFocus\n >\n {surface}\n </BaseDialog.Popup>\n </BaseDialog.Viewport>\n </BaseDialog.Portal>\n </BaseDialog.Root>\n </SidebarContext.Provider>\n );\n }\n\n return <SidebarContext.Provider value={context}>{surface}</SidebarContext.Provider>;\n});\n\nexport type SidebarPortalProps = ComponentPropsWithoutRef<typeof BaseDialog.Portal>;\nexport function SidebarPortal(props: SidebarPortalProps) {\n return <BaseDialog.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type SidebarBackdropProps = ComponentPropsWithoutRef<typeof BaseDialog.Backdrop>;\nexport const SidebarBackdrop = forwardRef<HTMLDivElement, SidebarBackdropProps>(\n function SidebarBackdrop({ className, ...props }, ref) {\n const { open } = useSidebar();\n return (\n <BaseDialog.Backdrop\n {...props}\n className={withRecipeClassName(sidebar({ open }).backdrop, className)}\n data-slot=\"sidebar-backdrop\"\n ref={ref}\n />\n );\n },\n);\n\nexport type SidebarToggleProps = ComponentPropsWithoutRef<\"button\">;\n\n/**\n * A floating, accessible control that expands or collapses the sidebar.\n */\nexport const SidebarToggle = forwardRef<HTMLButtonElement, SidebarToggleProps>(\n function SidebarToggle(\n { \"aria-label\": ariaLabel, children, className, onClick, type = \"button\", ...props },\n ref,\n ) {\n const { open, toggle } = useSidebar();\n const styles = useSidebarStyles();\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n\n if (!event.defaultPrevented) {\n toggle();\n }\n };\n\n return (\n <button\n {...props}\n aria-expanded={open}\n aria-label={ariaLabel ?? (open ? \"Collapse sidebar\" : \"Expand sidebar\")}\n className={cx(styles.toggle, className)}\n data-slot=\"sidebar-toggle\"\n onClick={handleClick}\n ref={ref}\n type={type}\n >\n {children ?? <span aria-hidden=\"true\">{open ? \"‹\" : \"›\"}</span>}\n </button>\n );\n },\n);\n\nexport type SidebarHeaderProps = ComponentPropsWithoutRef<\"header\">;\n\nexport const SidebarHeader = forwardRef<HTMLElement, SidebarHeaderProps>(function SidebarHeader(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <header\n {...props}\n ref={ref}\n className={cx(styles.header, className)}\n data-slot=\"sidebar-header\"\n />\n );\n});\n\nexport type SidebarContentProps = ComponentPropsWithoutRef<\"nav\">;\n\nexport const SidebarContent = forwardRef<HTMLElement, SidebarContentProps>(function SidebarContent(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Sidebar navigation\"}\n ref={ref}\n className={cx(styles.content, className)}\n data-slot=\"sidebar-content\"\n />\n );\n});\n\nexport type SidebarFooterProps = ComponentPropsWithoutRef<\"footer\">;\n\nexport const SidebarFooter = forwardRef<HTMLElement, SidebarFooterProps>(function SidebarFooter(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <footer\n {...props}\n ref={ref}\n className={cx(styles.footer, className)}\n data-slot=\"sidebar-footer\"\n />\n );\n});\n\nexport interface SidebarItemProps extends ComponentPropsWithoutRef<\"a\"> {\n /** Marks the current navigation destination. */\n active?: boolean;\n}\n\n/**\n * A semantic navigation item. Pair its icon/content with `Sidebar.Label` so\n * the text transitions out of view while remaining available to assistive\n * technology when the sidebar is collapsed.\n */\nexport const SidebarItem = forwardRef<HTMLAnchorElement, SidebarItemProps>(function SidebarItem(\n { \"aria-current\": ariaCurrent, active = false, className, ...props },\n ref,\n) {\n const { open } = useSidebar();\n const styles = sidebar({ active, open });\n\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n ref={ref}\n className={cx(styles.item, className)}\n data-active={active || undefined}\n data-slot=\"sidebar-item\"\n />\n );\n});\n\nexport type SidebarLabelProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const SidebarLabel = forwardRef<HTMLSpanElement, SidebarLabelProps>(function SidebarLabel(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <span {...props} ref={ref} className={cx(styles.label, className)} data-slot=\"sidebar-label\" />\n );\n});\n\nexport const Sidebar = {\n Root: SidebarRoot,\n Portal: SidebarPortal,\n Backdrop: SidebarBackdrop,\n Toggle: SidebarToggle,\n Header: SidebarHeader,\n Content: SidebarContent,\n Footer: SidebarFooter,\n Item: SidebarItem,\n Label: SidebarLabel,\n};\n"],"mappings":";;;;;;;;;AAoBA,MAAM,kBAAA,GAAA,MAAA,cAAA,CAA2D,IAAI;;;;;;AAOrE,SAAgB,aAAa;CAC3B,M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G,OAAO,SAAS,SAAS;EACvC,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,iBAAA,GAAA,MAAA,WAAA,CAA4D,SAAS,cAChF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,MAAM,SAAS,iBAAiB;CAEhC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;EACE,GAAI;EACC;EACL,WAAWA,WAAAA,GAAG,OAAO,QAAQ,SAAS;EACtC,aAAU;CACX,CAAA;AAEL,CAAC;;;;;;AAYD,MAAa,eAAA,GAAA,MAAA,WAAA,CAA8D,SAAS,YAClF,EAAE,gBAAgB,aAAa,SAAS,OAAO,WAAW,GAAG,SAC7D,KACA;CACA,MAAM,EAAE,SAAS,WAAW;CAC5B,MAAM,SAASF,gBAAAA,QAAQ;EAAE;EAAQ;CAAK,CAAC;CAEvC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EACE,GAAI;EACJ,gBAAc,gBAAgB,SAAS,SAAS,KAAA;EAC3C;EACL,WAAWE,WAAAA,GAAG,OAAO,MAAM,SAAS;EACpC,eAAa,UAAU,KAAA;EACvB,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA8D,SAAS,aAClF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,MAAM,SAAS,iBAAiB;CAEhC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAM,GAAI;EAAY;EAAK,WAAWA,WAAAA,GAAG,OAAO,OAAO,SAAS;EAAG,aAAU;CAAiB,CAAA;AAElG,CAAC;AAED,MAAa,UAAU;CACrB,MAAM;CACN,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,MAAM;CACN,OAAO;AACT"}
|
|
@@ -38,6 +38,8 @@ interface SidebarRootProps extends ComponentPropsWithoutRef<"aside"> {
|
|
|
38
38
|
* The sidebar container. It supports both controlled and uncontrolled state.
|
|
39
39
|
*/
|
|
40
40
|
declare const SidebarRoot: import("react").ForwardRefExoticComponent<SidebarRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
41
|
+
type SidebarPortalProps = ComponentPropsWithoutRef<typeof Dialog.Portal>;
|
|
42
|
+
declare function SidebarPortal(props: SidebarPortalProps): import("react").JSX.Element;
|
|
41
43
|
type SidebarToggleProps = ComponentPropsWithoutRef<"button">;
|
|
42
44
|
/**
|
|
43
45
|
* A floating, accessible control that expands or collapses the sidebar.
|
|
@@ -63,7 +65,7 @@ type SidebarLabelProps = ComponentPropsWithoutRef<"span">;
|
|
|
63
65
|
declare const SidebarLabel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
64
66
|
declare const Sidebar: {
|
|
65
67
|
Root: import("react").ForwardRefExoticComponent<SidebarRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
66
|
-
Portal:
|
|
68
|
+
Portal: typeof SidebarPortal;
|
|
67
69
|
Backdrop: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").AlertDialogBackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
68
70
|
Toggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
69
71
|
Header: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -73,5 +75,5 @@ declare const Sidebar: {
|
|
|
73
75
|
Label: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
74
76
|
};
|
|
75
77
|
//#endregion
|
|
76
|
-
export { Sidebar, SidebarContent, SidebarContentProps, SidebarContextValue, SidebarFooter, SidebarFooterProps, SidebarHeader, SidebarHeaderProps, SidebarItem, SidebarItemProps, SidebarLabel, SidebarLabelProps, SidebarRoot, SidebarRootProps, SidebarToggle, SidebarToggleProps, useSidebar };
|
|
78
|
+
export { Sidebar, SidebarContent, SidebarContentProps, SidebarContextValue, SidebarFooter, SidebarFooterProps, SidebarHeader, SidebarHeaderProps, SidebarItem, SidebarItemProps, SidebarLabel, SidebarLabelProps, SidebarPortal, SidebarPortalProps, SidebarRoot, SidebarRootProps, SidebarToggle, SidebarToggleProps, useSidebar };
|
|
77
79
|
//# sourceMappingURL=sidebar.d.cts.map
|
|
@@ -38,6 +38,8 @@ interface SidebarRootProps extends ComponentPropsWithoutRef<"aside"> {
|
|
|
38
38
|
* The sidebar container. It supports both controlled and uncontrolled state.
|
|
39
39
|
*/
|
|
40
40
|
declare const SidebarRoot: import("react").ForwardRefExoticComponent<SidebarRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
41
|
+
type SidebarPortalProps = ComponentPropsWithoutRef<typeof Dialog.Portal>;
|
|
42
|
+
declare function SidebarPortal(props: SidebarPortalProps): import("react").JSX.Element;
|
|
41
43
|
type SidebarToggleProps = ComponentPropsWithoutRef<"button">;
|
|
42
44
|
/**
|
|
43
45
|
* A floating, accessible control that expands or collapses the sidebar.
|
|
@@ -63,7 +65,7 @@ type SidebarLabelProps = ComponentPropsWithoutRef<"span">;
|
|
|
63
65
|
declare const SidebarLabel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
64
66
|
declare const Sidebar: {
|
|
65
67
|
Root: import("react").ForwardRefExoticComponent<SidebarRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
66
|
-
Portal:
|
|
68
|
+
Portal: typeof SidebarPortal;
|
|
67
69
|
Backdrop: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").AlertDialogBackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
68
70
|
Toggle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
69
71
|
Header: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -73,5 +75,5 @@ declare const Sidebar: {
|
|
|
73
75
|
Label: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
74
76
|
};
|
|
75
77
|
//#endregion
|
|
76
|
-
export { Sidebar, SidebarContent, SidebarContentProps, SidebarContextValue, SidebarFooter, SidebarFooterProps, SidebarHeader, SidebarHeaderProps, SidebarItem, SidebarItemProps, SidebarLabel, SidebarLabelProps, SidebarRoot, SidebarRootProps, SidebarToggle, SidebarToggleProps, useSidebar };
|
|
78
|
+
export { Sidebar, SidebarContent, SidebarContentProps, SidebarContextValue, SidebarFooter, SidebarFooterProps, SidebarHeader, SidebarHeaderProps, SidebarItem, SidebarItemProps, SidebarLabel, SidebarLabelProps, SidebarPortal, SidebarPortalProps, SidebarRoot, SidebarRootProps, SidebarToggle, SidebarToggleProps, useSidebar };
|
|
77
79
|
//# sourceMappingURL=sidebar.d.ts.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { cx } from "../../styled-system/css/cx.js";
|
|
3
3
|
import { withRecipeClassName } from "../base-ui.js";
|
|
4
4
|
import { sidebar } from "../../styled-system/recipes/sidebar.js";
|
|
5
|
+
import { useThemePortalProps } from "../../theme/theme-scope.js";
|
|
5
6
|
import { createContext, forwardRef, useCallback, useContext, useMemo, useState } from "react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { Dialog } from "@base-ui/react/dialog";
|
|
@@ -45,6 +46,7 @@ const SidebarRoot = forwardRef(function SidebarRoot({ children, className, close
|
|
|
45
46
|
toggle
|
|
46
47
|
]);
|
|
47
48
|
const styles = sidebar({ open });
|
|
49
|
+
const scopedPortalProps = useThemePortalProps({});
|
|
48
50
|
const surface = /* @__PURE__ */ jsx("aside", {
|
|
49
51
|
...props,
|
|
50
52
|
ref,
|
|
@@ -67,23 +69,26 @@ const SidebarRoot = forwardRef(function SidebarRoot({ children, className, close
|
|
|
67
69
|
}
|
|
68
70
|
setOpen(nextOpen);
|
|
69
71
|
},
|
|
70
|
-
children: /* @__PURE__ */ jsxs(Dialog.Portal, {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}), /* @__PURE__ */ jsx(Dialog.Viewport, {
|
|
75
|
-
className: cx(styles.viewport),
|
|
76
|
-
"data-slot": "sidebar-viewport",
|
|
77
|
-
children: /* @__PURE__ */ jsx(Dialog.Popup, {
|
|
78
|
-
"aria-label": props["aria-label"] ?? "Sidebar navigation",
|
|
79
|
-
className: cx(styles.popup),
|
|
72
|
+
children: /* @__PURE__ */ jsxs(Dialog.Portal, {
|
|
73
|
+
...scopedPortalProps,
|
|
74
|
+
children: [/* @__PURE__ */ jsx(Dialog.Backdrop, {
|
|
75
|
+
className: cx(styles.backdrop),
|
|
80
76
|
"data-jaci-component": "sidebar",
|
|
81
|
-
"data-slot": "sidebar-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
"data-slot": "sidebar-backdrop"
|
|
78
|
+
}), /* @__PURE__ */ jsx(Dialog.Viewport, {
|
|
79
|
+
className: cx(styles.viewport),
|
|
80
|
+
"data-slot": "sidebar-viewport",
|
|
81
|
+
children: /* @__PURE__ */ jsx(Dialog.Popup, {
|
|
82
|
+
"aria-label": props["aria-label"] ?? "Sidebar navigation",
|
|
83
|
+
className: cx(styles.popup),
|
|
84
|
+
"data-jaci-component": "sidebar",
|
|
85
|
+
"data-slot": "sidebar-popup",
|
|
86
|
+
finalFocus: restoreFocus,
|
|
87
|
+
initialFocus: true,
|
|
88
|
+
children: surface
|
|
89
|
+
})
|
|
90
|
+
})]
|
|
91
|
+
})
|
|
87
92
|
})
|
|
88
93
|
});
|
|
89
94
|
return /* @__PURE__ */ jsx(SidebarContext.Provider, {
|
|
@@ -91,7 +96,9 @@ const SidebarRoot = forwardRef(function SidebarRoot({ children, className, close
|
|
|
91
96
|
children: surface
|
|
92
97
|
});
|
|
93
98
|
});
|
|
94
|
-
|
|
99
|
+
function SidebarPortal(props) {
|
|
100
|
+
return /* @__PURE__ */ jsx(Dialog.Portal, { ...useThemePortalProps(props) });
|
|
101
|
+
}
|
|
95
102
|
const SidebarBackdrop = forwardRef(function SidebarBackdrop({ className, ...props }, ref) {
|
|
96
103
|
const { open } = useSidebar();
|
|
97
104
|
return /* @__PURE__ */ jsx(Dialog.Backdrop, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.js","names":["BaseDialog"],"sources":["../../../src/components/sidebar/sidebar.tsx"],"sourcesContent":["\"use client\";\n\nimport { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { sidebar } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\nexport interface SidebarContextValue {\n /** Whether the sidebar is visually expanded. */\n open: boolean;\n /** Updates the expanded state, respecting controlled usage. */\n setOpen: (open: boolean) => void;\n /** Convenience callback for toggles placed anywhere in the sidebar. */\n toggle: () => void;\n}\n\nconst SidebarContext = createContext<SidebarContextValue | null>(null);\n\n/**\n * Reads the state exposed by `Sidebar.Root`.\n *\n * Use it in custom sidebar parts when the built-in composition is not enough.\n */\nexport function useSidebar() {\n const context = useContext(SidebarContext);\n\n if (!context) {\n throw new Error(\"useSidebar must be used within a Sidebar.Root component.\");\n }\n\n return context;\n}\n\nfunction useSidebarStyles() {\n const { open } = useSidebar();\n return sidebar({ open });\n}\n\nexport interface SidebarRootProps extends ComponentPropsWithoutRef<\"aside\"> {\n /** Controlled expanded state. */\n open?: boolean;\n /** Initial expanded state for uncontrolled use. */\n defaultOpen?: boolean;\n /** Called after the requested expanded state changes. */\n onOpenChange?: (open: boolean) => void;\n /** Renders the sidebar as a modal mobile surface when set to overlay. */\n mode?: \"static\" | \"overlay\";\n /** Allows Escape to be disabled for overlay mode. */\n closeOnEscape?: boolean;\n /** Allows outside presses to be disabled for overlay mode. */\n closeOnOutsidePress?: boolean;\n /** Restores focus to the element that opened the overlay. */\n restoreFocus?: boolean;\n /** Controls whether the overlay traps focus and locks page scroll. */\n modal?: boolean | \"trap-focus\";\n children?: ReactNode;\n}\n\n/**\n * The sidebar container. It supports both controlled and uncontrolled state.\n */\nexport const SidebarRoot = forwardRef<HTMLElement, SidebarRootProps>(function SidebarRoot(\n {\n children,\n className,\n closeOnEscape = true,\n closeOnOutsidePress = true,\n defaultOpen = true,\n modal = true,\n mode = \"static\",\n onOpenChange,\n open: controlledOpen,\n restoreFocus = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isControlled = controlledOpen !== undefined;\n const open = controlledOpen ?? uncontrolledOpen;\n\n const setOpen = useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(nextOpen);\n }\n\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const toggle = useCallback(() => {\n setOpen(!open);\n }, [open, setOpen]);\n\n const context = useMemo<SidebarContextValue>(\n () => ({ open, setOpen, toggle }),\n [open, setOpen, toggle],\n );\n const styles = sidebar({ open });\n\n const surface = (\n <aside\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-jaci-component=\"sidebar\"\n data-open={open}\n data-slot=\"sidebar\"\n data-state={open ? \"open\" : \"closed\"}\n >\n {children}\n </aside>\n );\n\n if (mode === \"overlay\") {\n return (\n <SidebarContext.Provider value={context}>\n <BaseDialog.Root\n open={open}\n modal={modal}\n onOpenChange={(nextOpen, details) => {\n if (\n !nextOpen &&\n ((!closeOnEscape && details.reason === \"escape-key\") ||\n (!closeOnOutsidePress && details.reason === \"outside-press\"))\n ) {\n details.cancel();\n return;\n }\n setOpen(nextOpen);\n }}\n >\n <BaseDialog.Portal>\n <BaseDialog.Backdrop\n className={cx(styles.backdrop)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-backdrop\"\n />\n <BaseDialog.Viewport className={cx(styles.viewport)} data-slot=\"sidebar-viewport\">\n <BaseDialog.Popup\n aria-label={props[\"aria-label\"] ?? \"Sidebar navigation\"}\n className={cx(styles.popup)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-popup\"\n finalFocus={restoreFocus}\n initialFocus\n >\n {surface}\n </BaseDialog.Popup>\n </BaseDialog.Viewport>\n </BaseDialog.Portal>\n </BaseDialog.Root>\n </SidebarContext.Provider>\n );\n }\n\n return <SidebarContext.Provider value={context}>{surface}</SidebarContext.Provider>;\n});\n\nexport type SidebarPortalProps = ComponentPropsWithoutRef<typeof BaseDialog.Portal>;\nexport const SidebarPortal: typeof BaseDialog.Portal = BaseDialog.Portal;\n\nexport type SidebarBackdropProps = ComponentPropsWithoutRef<typeof BaseDialog.Backdrop>;\nexport const SidebarBackdrop = forwardRef<HTMLDivElement, SidebarBackdropProps>(\n function SidebarBackdrop({ className, ...props }, ref) {\n const { open } = useSidebar();\n return (\n <BaseDialog.Backdrop\n {...props}\n className={withRecipeClassName(sidebar({ open }).backdrop, className)}\n data-slot=\"sidebar-backdrop\"\n ref={ref}\n />\n );\n },\n);\n\nexport type SidebarToggleProps = ComponentPropsWithoutRef<\"button\">;\n\n/**\n * A floating, accessible control that expands or collapses the sidebar.\n */\nexport const SidebarToggle = forwardRef<HTMLButtonElement, SidebarToggleProps>(\n function SidebarToggle(\n { \"aria-label\": ariaLabel, children, className, onClick, type = \"button\", ...props },\n ref,\n ) {\n const { open, toggle } = useSidebar();\n const styles = useSidebarStyles();\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n\n if (!event.defaultPrevented) {\n toggle();\n }\n };\n\n return (\n <button\n {...props}\n aria-expanded={open}\n aria-label={ariaLabel ?? (open ? \"Collapse sidebar\" : \"Expand sidebar\")}\n className={cx(styles.toggle, className)}\n data-slot=\"sidebar-toggle\"\n onClick={handleClick}\n ref={ref}\n type={type}\n >\n {children ?? <span aria-hidden=\"true\">{open ? \"‹\" : \"›\"}</span>}\n </button>\n );\n },\n);\n\nexport type SidebarHeaderProps = ComponentPropsWithoutRef<\"header\">;\n\nexport const SidebarHeader = forwardRef<HTMLElement, SidebarHeaderProps>(function SidebarHeader(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <header\n {...props}\n ref={ref}\n className={cx(styles.header, className)}\n data-slot=\"sidebar-header\"\n />\n );\n});\n\nexport type SidebarContentProps = ComponentPropsWithoutRef<\"nav\">;\n\nexport const SidebarContent = forwardRef<HTMLElement, SidebarContentProps>(function SidebarContent(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Sidebar navigation\"}\n ref={ref}\n className={cx(styles.content, className)}\n data-slot=\"sidebar-content\"\n />\n );\n});\n\nexport type SidebarFooterProps = ComponentPropsWithoutRef<\"footer\">;\n\nexport const SidebarFooter = forwardRef<HTMLElement, SidebarFooterProps>(function SidebarFooter(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <footer\n {...props}\n ref={ref}\n className={cx(styles.footer, className)}\n data-slot=\"sidebar-footer\"\n />\n );\n});\n\nexport interface SidebarItemProps extends ComponentPropsWithoutRef<\"a\"> {\n /** Marks the current navigation destination. */\n active?: boolean;\n}\n\n/**\n * A semantic navigation item. Pair its icon/content with `Sidebar.Label` so\n * the text transitions out of view while remaining available to assistive\n * technology when the sidebar is collapsed.\n */\nexport const SidebarItem = forwardRef<HTMLAnchorElement, SidebarItemProps>(function SidebarItem(\n { \"aria-current\": ariaCurrent, active = false, className, ...props },\n ref,\n) {\n const { open } = useSidebar();\n const styles = sidebar({ active, open });\n\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n ref={ref}\n className={cx(styles.item, className)}\n data-active={active || undefined}\n data-slot=\"sidebar-item\"\n />\n );\n});\n\nexport type SidebarLabelProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const SidebarLabel = forwardRef<HTMLSpanElement, SidebarLabelProps>(function SidebarLabel(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <span {...props} ref={ref} className={cx(styles.label, className)} data-slot=\"sidebar-label\" />\n );\n});\n\nexport const Sidebar = {\n Root: SidebarRoot,\n Portal: SidebarPortal,\n Backdrop: SidebarBackdrop,\n Toggle: SidebarToggle,\n Header: SidebarHeader,\n Content: SidebarContent,\n Footer: SidebarFooter,\n Item: SidebarItem,\n Label: SidebarLabel,\n};\n"],"mappings":";;;;;;;;AAmBA,MAAM,iBAAiB,cAA0C,IAAI;;;;;;AAOrE,SAAgB,aAAa;CAC3B,MAAM,UAAU,WAAW,cAAc;CAEzC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,0DAA0D;CAG5E,OAAO;AACT;AAEA,SAAS,mBAAmB;CAC1B,MAAM,EAAE,SAAS,WAAW;CAC5B,OAAO,QAAQ,EAAE,KAAK,CAAC;AACzB;;;;AAyBA,MAAa,cAAc,WAA0C,SA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A;AAEL,CAAC;AAID,MAAa,iBAAiB,WAA6C,SAAS,eAClF,EAAE,cAAc,WAAW,WAAW,GAAG,SACzC,KACA;CACA,MAAM,SAAS,iBAAiB;CAEhC,OACE,oBAAC,OAAD;EACE,GAAI;EACJ,cAAY,aAAa;EACpB;EACL,WAAW,GAAG,OAAO,SAAS,SAAS;EACvC,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,gBAAgB,WAA4C,SAAS,cAChF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,MAAM,SAAS,iBAAiB;CAEhC,OACE,oBAAC,UAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,OAAO,QAAQ,SAAS;EACtC,aAAU;CACX,CAAA;AAEL,CAAC;;;;;;AAYD,MAAa,cAAc,WAAgD,SAAS,YAClF,EAAE,gBAAgB,aAAa,SAAS,OAAO,WAAW,GAAG,SAC7D,KACA;CACA,MAAM,EAAE,SAAS,WAAW;CAC5B,MAAM,SAAS,QAAQ;EAAE;EAAQ;CAAK,CAAC;CAEvC,OACE,oBAAC,KAAD;EACE,GAAI;EACJ,gBAAc,gBAAgB,SAAS,SAAS,KAAA;EAC3C;EACL,WAAW,GAAG,OAAO,MAAM,SAAS;EACpC,eAAa,UAAU,KAAA;EACvB,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,eAAe,WAA+C,SAAS,aAClF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,MAAM,SAAS,iBAAiB;CAEhC,OACE,oBAAC,QAAD;EAAM,GAAI;EAAY;EAAK,WAAW,GAAG,OAAO,OAAO,SAAS;EAAG,aAAU;CAAiB,CAAA;AAElG,CAAC;AAED,MAAa,UAAU;CACrB,MAAM;CACN,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,MAAM;CACN,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"sidebar.js","names":["BaseDialog"],"sources":["../../../src/components/sidebar/sidebar.tsx"],"sourcesContent":["\"use client\";\n\nimport { Dialog as BaseDialog } from \"@base-ui/react/dialog\";\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { sidebar } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\nexport interface SidebarContextValue {\n /** Whether the sidebar is visually expanded. */\n open: boolean;\n /** Updates the expanded state, respecting controlled usage. */\n setOpen: (open: boolean) => void;\n /** Convenience callback for toggles placed anywhere in the sidebar. */\n toggle: () => void;\n}\n\nconst SidebarContext = createContext<SidebarContextValue | null>(null);\n\n/**\n * Reads the state exposed by `Sidebar.Root`.\n *\n * Use it in custom sidebar parts when the built-in composition is not enough.\n */\nexport function useSidebar() {\n const context = useContext(SidebarContext);\n\n if (!context) {\n throw new Error(\"useSidebar must be used within a Sidebar.Root component.\");\n }\n\n return context;\n}\n\nfunction useSidebarStyles() {\n const { open } = useSidebar();\n return sidebar({ open });\n}\n\nexport interface SidebarRootProps extends ComponentPropsWithoutRef<\"aside\"> {\n /** Controlled expanded state. */\n open?: boolean;\n /** Initial expanded state for uncontrolled use. */\n defaultOpen?: boolean;\n /** Called after the requested expanded state changes. */\n onOpenChange?: (open: boolean) => void;\n /** Renders the sidebar as a modal mobile surface when set to overlay. */\n mode?: \"static\" | \"overlay\";\n /** Allows Escape to be disabled for overlay mode. */\n closeOnEscape?: boolean;\n /** Allows outside presses to be disabled for overlay mode. */\n closeOnOutsidePress?: boolean;\n /** Restores focus to the element that opened the overlay. */\n restoreFocus?: boolean;\n /** Controls whether the overlay traps focus and locks page scroll. */\n modal?: boolean | \"trap-focus\";\n children?: ReactNode;\n}\n\n/**\n * The sidebar container. It supports both controlled and uncontrolled state.\n */\nexport const SidebarRoot = forwardRef<HTMLElement, SidebarRootProps>(function SidebarRoot(\n {\n children,\n className,\n closeOnEscape = true,\n closeOnOutsidePress = true,\n defaultOpen = true,\n modal = true,\n mode = \"static\",\n onOpenChange,\n open: controlledOpen,\n restoreFocus = true,\n ...props\n },\n ref,\n) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);\n const isControlled = controlledOpen !== undefined;\n const open = controlledOpen ?? uncontrolledOpen;\n\n const setOpen = useCallback(\n (nextOpen: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(nextOpen);\n }\n\n onOpenChange?.(nextOpen);\n },\n [isControlled, onOpenChange],\n );\n\n const toggle = useCallback(() => {\n setOpen(!open);\n }, [open, setOpen]);\n\n const context = useMemo<SidebarContextValue>(\n () => ({ open, setOpen, toggle }),\n [open, setOpen, toggle],\n );\n const styles = sidebar({ open });\n const scopedPortalProps = useThemePortalProps({});\n\n const surface = (\n <aside\n {...props}\n ref={ref}\n className={cx(styles.root, className)}\n data-jaci-component=\"sidebar\"\n data-open={open}\n data-slot=\"sidebar\"\n data-state={open ? \"open\" : \"closed\"}\n >\n {children}\n </aside>\n );\n\n if (mode === \"overlay\") {\n return (\n <SidebarContext.Provider value={context}>\n <BaseDialog.Root\n open={open}\n modal={modal}\n onOpenChange={(nextOpen, details) => {\n if (\n !nextOpen &&\n ((!closeOnEscape && details.reason === \"escape-key\") ||\n (!closeOnOutsidePress && details.reason === \"outside-press\"))\n ) {\n details.cancel();\n return;\n }\n setOpen(nextOpen);\n }}\n >\n <BaseDialog.Portal {...scopedPortalProps}>\n <BaseDialog.Backdrop\n className={cx(styles.backdrop)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-backdrop\"\n />\n <BaseDialog.Viewport className={cx(styles.viewport)} data-slot=\"sidebar-viewport\">\n <BaseDialog.Popup\n aria-label={props[\"aria-label\"] ?? \"Sidebar navigation\"}\n className={cx(styles.popup)}\n data-jaci-component=\"sidebar\"\n data-slot=\"sidebar-popup\"\n finalFocus={restoreFocus}\n initialFocus\n >\n {surface}\n </BaseDialog.Popup>\n </BaseDialog.Viewport>\n </BaseDialog.Portal>\n </BaseDialog.Root>\n </SidebarContext.Provider>\n );\n }\n\n return <SidebarContext.Provider value={context}>{surface}</SidebarContext.Provider>;\n});\n\nexport type SidebarPortalProps = ComponentPropsWithoutRef<typeof BaseDialog.Portal>;\nexport function SidebarPortal(props: SidebarPortalProps) {\n return <BaseDialog.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type SidebarBackdropProps = ComponentPropsWithoutRef<typeof BaseDialog.Backdrop>;\nexport const SidebarBackdrop = forwardRef<HTMLDivElement, SidebarBackdropProps>(\n function SidebarBackdrop({ className, ...props }, ref) {\n const { open } = useSidebar();\n return (\n <BaseDialog.Backdrop\n {...props}\n className={withRecipeClassName(sidebar({ open }).backdrop, className)}\n data-slot=\"sidebar-backdrop\"\n ref={ref}\n />\n );\n },\n);\n\nexport type SidebarToggleProps = ComponentPropsWithoutRef<\"button\">;\n\n/**\n * A floating, accessible control that expands or collapses the sidebar.\n */\nexport const SidebarToggle = forwardRef<HTMLButtonElement, SidebarToggleProps>(\n function SidebarToggle(\n { \"aria-label\": ariaLabel, children, className, onClick, type = \"button\", ...props },\n ref,\n ) {\n const { open, toggle } = useSidebar();\n const styles = useSidebarStyles();\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n\n if (!event.defaultPrevented) {\n toggle();\n }\n };\n\n return (\n <button\n {...props}\n aria-expanded={open}\n aria-label={ariaLabel ?? (open ? \"Collapse sidebar\" : \"Expand sidebar\")}\n className={cx(styles.toggle, className)}\n data-slot=\"sidebar-toggle\"\n onClick={handleClick}\n ref={ref}\n type={type}\n >\n {children ?? <span aria-hidden=\"true\">{open ? \"‹\" : \"›\"}</span>}\n </button>\n );\n },\n);\n\nexport type SidebarHeaderProps = ComponentPropsWithoutRef<\"header\">;\n\nexport const SidebarHeader = forwardRef<HTMLElement, SidebarHeaderProps>(function SidebarHeader(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <header\n {...props}\n ref={ref}\n className={cx(styles.header, className)}\n data-slot=\"sidebar-header\"\n />\n );\n});\n\nexport type SidebarContentProps = ComponentPropsWithoutRef<\"nav\">;\n\nexport const SidebarContent = forwardRef<HTMLElement, SidebarContentProps>(function SidebarContent(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Sidebar navigation\"}\n ref={ref}\n className={cx(styles.content, className)}\n data-slot=\"sidebar-content\"\n />\n );\n});\n\nexport type SidebarFooterProps = ComponentPropsWithoutRef<\"footer\">;\n\nexport const SidebarFooter = forwardRef<HTMLElement, SidebarFooterProps>(function SidebarFooter(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <footer\n {...props}\n ref={ref}\n className={cx(styles.footer, className)}\n data-slot=\"sidebar-footer\"\n />\n );\n});\n\nexport interface SidebarItemProps extends ComponentPropsWithoutRef<\"a\"> {\n /** Marks the current navigation destination. */\n active?: boolean;\n}\n\n/**\n * A semantic navigation item. Pair its icon/content with `Sidebar.Label` so\n * the text transitions out of view while remaining available to assistive\n * technology when the sidebar is collapsed.\n */\nexport const SidebarItem = forwardRef<HTMLAnchorElement, SidebarItemProps>(function SidebarItem(\n { \"aria-current\": ariaCurrent, active = false, className, ...props },\n ref,\n) {\n const { open } = useSidebar();\n const styles = sidebar({ active, open });\n\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n ref={ref}\n className={cx(styles.item, className)}\n data-active={active || undefined}\n data-slot=\"sidebar-item\"\n />\n );\n});\n\nexport type SidebarLabelProps = ComponentPropsWithoutRef<\"span\">;\n\nexport const SidebarLabel = forwardRef<HTMLSpanElement, SidebarLabelProps>(function SidebarLabel(\n { className, ...props },\n ref,\n) {\n const styles = useSidebarStyles();\n\n return (\n <span {...props} ref={ref} className={cx(styles.label, className)} data-slot=\"sidebar-label\" />\n );\n});\n\nexport const Sidebar = {\n Root: SidebarRoot,\n Portal: SidebarPortal,\n Backdrop: SidebarBackdrop,\n Toggle: SidebarToggle,\n Header: SidebarHeader,\n Content: SidebarContent,\n Footer: SidebarFooter,\n Item: SidebarItem,\n Label: SidebarLabel,\n};\n"],"mappings":";;;;;;;;;AAoBA,MAAM,iBAAiB,cAA0C,IAAI;;;;;;AAOrE,SAAgB,aAAa;CAC3B,MAAM,UAAU,WAAW,cAAc;CAEzC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,0DAA0D;CAG5E,OAAO;AACT;AAEA,SAAS,mBAAmB;CAC1B,MAAM,EAAE,SAAS,WAAW;CAC5B,OAAO,QAAQ,EAAE,KAAK,CAAC;AACzB;;;;AAyBA,MAAa,cAAc,WAA0C,SAAS,YAC5E,EACE,UACA,WACA,gBAAgB,MAChB,sBAAsB,MACtB,cAAc,MACd,QAAQ,MACR,OAAO,UACP,cACA,MAAM,gBACN,eAAe,MACf,GAAG,SAEL,KACA;CACA,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,WAAW;CACpE,MAAM,eAAe,mBAAmB,KAAA;CACxC,MAAM,OAAO,kBAAkB;CAE/B,MAAM,UAAU,aACb,aAAsB;EACrB,IAAI,CAAC,cACH,oBAAoB,QAAQ;EAG9B,eAAe,QAAQ;CACzB,GACA,CAAC,cAAc,YAAY,CAC7B;CAEA,MAAM,SAAS,kBAAkB;EAC/B,QAAQ,CAAC,IAAI;CACf,GAAG,CAAC,MAAM,OAAO,CAAC;CAElB,MAAM,UAAU,eACP;EAAE;EAAM;EAAS;CAAO,IAC/B;EAAC;EAAM;EAAS;CAAM,CACxB;CACA,MAAM,SAAS,QAAQ,EAAE,KAAK,CAAC;CAC/B,MAAM,oBAAoB,oBAAoB,CAAC,CAAC;CAEhD,MAAM,UACJ,oBAAC,SAAD;EACE,GAAI;EACC;EACL,WAAW,GAAG,OAAO,MAAM,SAAS;EACpC,uBAAoB;EACpB,aAAW;EACX,aAAU;EACV,cAAY,OAAO,SAAS;EAE3B;CACI,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D;EACE,GAAI;EACJ,gBAAc,gBAAgB,SAAS,SAAS,KAAA;EAC3C;EACL,WAAW,GAAG,OAAO,MAAM,SAAS;EACpC,eAAa,UAAU,KAAA;EACvB,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,eAAe,WAA+C,SAAS,aAClF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,MAAM,SAAS,iBAAiB;CAEhC,OACE,oBAAC,QAAD;EAAM,GAAI;EAAY;EAAK,WAAW,GAAG,OAAO,OAAO,SAAS;EAAG,aAAU;CAAiB,CAAA;AAElG,CAAC;AAED,MAAa,UAAU;CACrB,MAAM;CACN,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,MAAM;CACN,OAAO;AACT"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const require_cx = require("../../styled-system/css/cx.cjs");
|
|
3
3
|
const require_base_ui = require("../base-ui.cjs");
|
|
4
4
|
const require_toast = require("../../styled-system/recipes/toast.cjs");
|
|
5
|
+
const require_theme_scope = require("../../theme/theme-scope.cjs");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
8
|
let _base_ui_react_toast = require("@base-ui/react/toast");
|
|
@@ -107,7 +108,9 @@ const ToastAction = (0, react.forwardRef)(function ToastAction({ className, ...p
|
|
|
107
108
|
});
|
|
108
109
|
});
|
|
109
110
|
/** Base UI's portal is preserved for rendering the viewport at document level. */
|
|
110
|
-
|
|
111
|
+
function ToastPortal(props) {
|
|
112
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Portal, { ...require_theme_scope.useThemePortalProps(props) });
|
|
113
|
+
}
|
|
111
114
|
const Toast = {
|
|
112
115
|
Provider: ToastProvider,
|
|
113
116
|
Viewport: ToastViewport,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.cjs","names":["BaseToast","withRecipeClassName","toastRecipe","cx"],"sources":["../../../src/components/toast/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { Toast as BaseToast } from \"@base-ui/react/toast\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { toast as toastRecipe } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst toneByToastType: Record<string, ToastTone> = {\n danger: \"danger\",\n error: \"danger\",\n info: \"info\",\n success: \"success\",\n warning: \"warning\",\n};\n\nfunction resolveTone(type: string | undefined, tone: ToastTone | undefined): ToastTone {\n return tone ?? (type === undefined ? \"neutral\" : (toneByToastType[type] ?? \"neutral\"));\n}\n\nexport type ToastProviderProps = ComponentPropsWithoutRef<typeof BaseToast.Provider>;\n\n/**\n * Creates an isolated, declarative toast region. Configure `timeout` and\n * `limit` here; use `Toast.Root` to render each toast from local state or\n * `Toast.useToastManager()`.\n */\nexport function ToastProvider(props: ToastProviderProps) {\n return <BaseToast.Provider {...props} />;\n}\n\nexport type ToastViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;\n\n/**\n * A bottom-centred notification region.\n */\nexport const ToastViewport = forwardRef<HTMLDivElement, ToastViewportProps>(function ToastViewport(\n { \"aria-label\": ariaLabel, \"aria-live\": ariaLive, className, ...props },\n ref,\n) {\n return (\n <BaseToast.Viewport\n {...props}\n aria-label={ariaLabel ?? \"Notifications\"}\n aria-live={ariaLive ?? \"polite\"}\n ref={ref}\n className={withRecipeClassName(toastRecipe().viewport, className)}\n data-jaci-component=\"toast-viewport\"\n data-slot=\"toast-viewport\"\n />\n );\n});\n\nexport interface ToastRootProps extends ComponentPropsWithoutRef<typeof BaseToast.Root> {\n /**\n * Visual status. When omitted, the value is inferred from the toast's\n * `type` (`error` maps to `danger`) and otherwise remains neutral.\n */\n tone?: ToastTone;\n}\n\n/**\n * Renders a toast object while preserving Base UI's lifecycle, focus, swipe,\n * and auto-dismiss behavior. It is intentionally composed rather than a\n * global imperative notification API.\n */\nexport const ToastRoot = forwardRef<HTMLDivElement, ToastRootProps>(function ToastRoot(\n { className, toast: toastObject, tone, ...props },\n ref,\n) {\n const resolvedTone = resolveTone(toastObject.type, tone);\n\n return (\n <BaseToast.Root\n {...props}\n ref={ref}\n toast={toastObject}\n className={withRecipeClassName(toastRecipe({ tone: resolvedTone }).root, className)}\n data-jaci-component=\"toast\"\n data-jaci-tone={resolvedTone}\n data-slot=\"toast\"\n />\n );\n});\n\nexport type ToastContentProps = ComponentPropsWithoutRef<typeof BaseToast.Content>;\n\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(function ToastContent(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Content\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().content, className)}\n data-slot=\"toast-content\"\n />\n );\n});\n\n/** A layout wrapper for `Toast.Title` and `Toast.Description`. */\nexport type ToastTextProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const ToastText = forwardRef<HTMLDivElement, ToastTextProps>(function ToastText(\n { className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(toastRecipe().text, className)}\n data-slot=\"toast-text\"\n />\n );\n});\n\nexport type ToastTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;\n\nexport const ToastTitle = forwardRef<HTMLHeadingElement, ToastTitleProps>(function ToastTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().title, className)}\n data-slot=\"toast-title\"\n />\n );\n});\n\nexport type ToastDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Description>;\n\nexport const ToastDescription = forwardRef<HTMLParagraphElement, ToastDescriptionProps>(\n function ToastDescription({ className, ...props }, ref) {\n return (\n <BaseToast.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().description, className)}\n data-slot=\"toast-description\"\n />\n );\n },\n);\n\nexport type ToastCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;\n\nexport const ToastClose = forwardRef<HTMLButtonElement, ToastCloseProps>(function ToastClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BaseToast.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Dismiss notification\")}\n ref={ref}\n className={withRecipeClassName(toastRecipe().close, className)}\n data-slot=\"toast-close\"\n >\n {children ?? \"×\"}\n </BaseToast.Close>\n );\n});\n\nexport type ToastActionProps = ComponentPropsWithoutRef<typeof BaseToast.Action>;\n\nexport const ToastAction = forwardRef<HTMLButtonElement, ToastActionProps>(function ToastAction(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Action\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().action, className)}\n data-slot=\"toast-action\"\n />\n );\n});\n\n/** Base UI's portal is preserved for rendering the viewport at document level. */\nexport
|
|
1
|
+
{"version":3,"file":"toast.cjs","names":["BaseToast","withRecipeClassName","toastRecipe","cx","useThemePortalProps"],"sources":["../../../src/components/toast/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { Toast as BaseToast } from \"@base-ui/react/toast\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { toast as toastRecipe } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst toneByToastType: Record<string, ToastTone> = {\n danger: \"danger\",\n error: \"danger\",\n info: \"info\",\n success: \"success\",\n warning: \"warning\",\n};\n\nfunction resolveTone(type: string | undefined, tone: ToastTone | undefined): ToastTone {\n return tone ?? (type === undefined ? \"neutral\" : (toneByToastType[type] ?? \"neutral\"));\n}\n\nexport type ToastProviderProps = ComponentPropsWithoutRef<typeof BaseToast.Provider>;\n\n/**\n * Creates an isolated, declarative toast region. Configure `timeout` and\n * `limit` here; use `Toast.Root` to render each toast from local state or\n * `Toast.useToastManager()`.\n */\nexport function ToastProvider(props: ToastProviderProps) {\n return <BaseToast.Provider {...props} />;\n}\n\nexport type ToastViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;\n\n/**\n * A bottom-centred notification region.\n */\nexport const ToastViewport = forwardRef<HTMLDivElement, ToastViewportProps>(function ToastViewport(\n { \"aria-label\": ariaLabel, \"aria-live\": ariaLive, className, ...props },\n ref,\n) {\n return (\n <BaseToast.Viewport\n {...props}\n aria-label={ariaLabel ?? \"Notifications\"}\n aria-live={ariaLive ?? \"polite\"}\n ref={ref}\n className={withRecipeClassName(toastRecipe().viewport, className)}\n data-jaci-component=\"toast-viewport\"\n data-slot=\"toast-viewport\"\n />\n );\n});\n\nexport interface ToastRootProps extends ComponentPropsWithoutRef<typeof BaseToast.Root> {\n /**\n * Visual status. When omitted, the value is inferred from the toast's\n * `type` (`error` maps to `danger`) and otherwise remains neutral.\n */\n tone?: ToastTone;\n}\n\n/**\n * Renders a toast object while preserving Base UI's lifecycle, focus, swipe,\n * and auto-dismiss behavior. It is intentionally composed rather than a\n * global imperative notification API.\n */\nexport const ToastRoot = forwardRef<HTMLDivElement, ToastRootProps>(function ToastRoot(\n { className, toast: toastObject, tone, ...props },\n ref,\n) {\n const resolvedTone = resolveTone(toastObject.type, tone);\n\n return (\n <BaseToast.Root\n {...props}\n ref={ref}\n toast={toastObject}\n className={withRecipeClassName(toastRecipe({ tone: resolvedTone }).root, className)}\n data-jaci-component=\"toast\"\n data-jaci-tone={resolvedTone}\n data-slot=\"toast\"\n />\n );\n});\n\nexport type ToastContentProps = ComponentPropsWithoutRef<typeof BaseToast.Content>;\n\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(function ToastContent(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Content\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().content, className)}\n data-slot=\"toast-content\"\n />\n );\n});\n\n/** A layout wrapper for `Toast.Title` and `Toast.Description`. */\nexport type ToastTextProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const ToastText = forwardRef<HTMLDivElement, ToastTextProps>(function ToastText(\n { className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(toastRecipe().text, className)}\n data-slot=\"toast-text\"\n />\n );\n});\n\nexport type ToastTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;\n\nexport const ToastTitle = forwardRef<HTMLHeadingElement, ToastTitleProps>(function ToastTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().title, className)}\n data-slot=\"toast-title\"\n />\n );\n});\n\nexport type ToastDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Description>;\n\nexport const ToastDescription = forwardRef<HTMLParagraphElement, ToastDescriptionProps>(\n function ToastDescription({ className, ...props }, ref) {\n return (\n <BaseToast.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().description, className)}\n data-slot=\"toast-description\"\n />\n );\n },\n);\n\nexport type ToastCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;\n\nexport const ToastClose = forwardRef<HTMLButtonElement, ToastCloseProps>(function ToastClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BaseToast.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Dismiss notification\")}\n ref={ref}\n className={withRecipeClassName(toastRecipe().close, className)}\n data-slot=\"toast-close\"\n >\n {children ?? \"×\"}\n </BaseToast.Close>\n );\n});\n\nexport type ToastActionProps = ComponentPropsWithoutRef<typeof BaseToast.Action>;\n\nexport const ToastAction = forwardRef<HTMLButtonElement, ToastActionProps>(function ToastAction(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Action\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().action, className)}\n data-slot=\"toast-action\"\n />\n );\n});\n\n/** Base UI's portal is preserved for rendering the viewport at document level. */\nexport function ToastPortal(props: ComponentPropsWithoutRef<typeof BaseToast.Portal>) {\n return <BaseToast.Portal {...useThemePortalProps(props)} />;\n}\n\nexport interface ToastComponent {\n Provider: typeof ToastProvider;\n Viewport: typeof ToastViewport;\n Root: typeof ToastRoot;\n Content: typeof ToastContent;\n Text: typeof ToastText;\n Title: typeof ToastTitle;\n Description: typeof ToastDescription;\n Close: typeof ToastClose;\n Action: typeof ToastAction;\n Portal: typeof ToastPortal;\n useToastManager: typeof BaseToast.useToastManager;\n}\n\nexport const Toast: ToastComponent = {\n Provider: ToastProvider,\n Viewport: ToastViewport,\n Root: ToastRoot,\n Content: ToastContent,\n Text: ToastText,\n Title: ToastTitle,\n Description: ToastDescription,\n Close: ToastClose,\n Action: ToastAction,\n Portal: ToastPortal,\n useToastManager: BaseToast.useToastManager,\n};\n"],"mappings":";;;;;;;;;AAaA,MAAM,kBAA6C;CACjD,QAAQ;CACR,OAAO;CACP,MAAM;CACN,SAAS;CACT,SAAS;AACX;AAEA,SAAS,YAAY,MAA0B,MAAwC;CACrF,OAAO,SAAS,SAAS,KAAA,IAAY,YAAa,gBAAgB,SAAS;AAC7E;;;;;;AASA,SAAgB,cAAc,OAA2B;CACvD,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,qBAAAA,MAAU,UAAX,EAAoB,GAAI,MAAQ,CAAA;AACzC;;;;AAOA,MAAa,iBAAA,GAAA,MAAA,WAAA,CAA+D,SAAS,cACnF,EAAE,cAAc,WAAW,aAAa,UAAU,WAAW,GAAG,SAChE,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,qBAAAA,MAAU,UAAX;EACE,GAAI;EACJ,cAAY,aAAa;EACzB,aAAW,YAAY;EAClB;EACL,WAA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,iBAAiBJ,qBAAAA,MAAU;AAC7B"}
|
|
@@ -41,7 +41,7 @@ declare const ToastClose: import("react").ForwardRefExoticComponent<Omit<Omit<im
|
|
|
41
41
|
type ToastActionProps = ComponentPropsWithoutRef<typeof Toast.Action>;
|
|
42
42
|
declare const ToastAction: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ToastActionProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
43
43
|
/** Base UI's portal is preserved for rendering the viewport at document level. */
|
|
44
|
-
declare
|
|
44
|
+
declare function ToastPortal(props: ComponentPropsWithoutRef<typeof Toast.Portal>): import("react").JSX.Element;
|
|
45
45
|
interface ToastComponent {
|
|
46
46
|
Provider: typeof ToastProvider;
|
|
47
47
|
Viewport: typeof ToastViewport;
|
|
@@ -41,7 +41,7 @@ declare const ToastClose: import("react").ForwardRefExoticComponent<Omit<Omit<im
|
|
|
41
41
|
type ToastActionProps = ComponentPropsWithoutRef<typeof Toast.Action>;
|
|
42
42
|
declare const ToastAction: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").ToastActionProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
43
43
|
/** Base UI's portal is preserved for rendering the viewport at document level. */
|
|
44
|
-
declare
|
|
44
|
+
declare function ToastPortal(props: ComponentPropsWithoutRef<typeof Toast.Portal>): import("react").JSX.Element;
|
|
45
45
|
interface ToastComponent {
|
|
46
46
|
Provider: typeof ToastProvider;
|
|
47
47
|
Viewport: typeof ToastViewport;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { cx } from "../../styled-system/css/cx.js";
|
|
3
3
|
import { withRecipeClassName } from "../base-ui.js";
|
|
4
4
|
import { toast } from "../../styled-system/recipes/toast.js";
|
|
5
|
+
import { useThemePortalProps } from "../../theme/theme-scope.js";
|
|
5
6
|
import { forwardRef } from "react";
|
|
6
7
|
import { jsx } from "react/jsx-runtime";
|
|
7
8
|
import { Toast } from "@base-ui/react/toast";
|
|
@@ -107,7 +108,9 @@ const ToastAction = forwardRef(function ToastAction({ className, ...props }, ref
|
|
|
107
108
|
});
|
|
108
109
|
});
|
|
109
110
|
/** Base UI's portal is preserved for rendering the viewport at document level. */
|
|
110
|
-
|
|
111
|
+
function ToastPortal(props) {
|
|
112
|
+
return /* @__PURE__ */ jsx(Toast.Portal, { ...useThemePortalProps(props) });
|
|
113
|
+
}
|
|
111
114
|
const Toast$1 = {
|
|
112
115
|
Provider: ToastProvider,
|
|
113
116
|
Viewport: ToastViewport,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","names":["BaseToast","toastRecipe","Toast"],"sources":["../../../src/components/toast/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { Toast as BaseToast } from \"@base-ui/react/toast\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { toast as toastRecipe } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst toneByToastType: Record<string, ToastTone> = {\n danger: \"danger\",\n error: \"danger\",\n info: \"info\",\n success: \"success\",\n warning: \"warning\",\n};\n\nfunction resolveTone(type: string | undefined, tone: ToastTone | undefined): ToastTone {\n return tone ?? (type === undefined ? \"neutral\" : (toneByToastType[type] ?? \"neutral\"));\n}\n\nexport type ToastProviderProps = ComponentPropsWithoutRef<typeof BaseToast.Provider>;\n\n/**\n * Creates an isolated, declarative toast region. Configure `timeout` and\n * `limit` here; use `Toast.Root` to render each toast from local state or\n * `Toast.useToastManager()`.\n */\nexport function ToastProvider(props: ToastProviderProps) {\n return <BaseToast.Provider {...props} />;\n}\n\nexport type ToastViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;\n\n/**\n * A bottom-centred notification region.\n */\nexport const ToastViewport = forwardRef<HTMLDivElement, ToastViewportProps>(function ToastViewport(\n { \"aria-label\": ariaLabel, \"aria-live\": ariaLive, className, ...props },\n ref,\n) {\n return (\n <BaseToast.Viewport\n {...props}\n aria-label={ariaLabel ?? \"Notifications\"}\n aria-live={ariaLive ?? \"polite\"}\n ref={ref}\n className={withRecipeClassName(toastRecipe().viewport, className)}\n data-jaci-component=\"toast-viewport\"\n data-slot=\"toast-viewport\"\n />\n );\n});\n\nexport interface ToastRootProps extends ComponentPropsWithoutRef<typeof BaseToast.Root> {\n /**\n * Visual status. When omitted, the value is inferred from the toast's\n * `type` (`error` maps to `danger`) and otherwise remains neutral.\n */\n tone?: ToastTone;\n}\n\n/**\n * Renders a toast object while preserving Base UI's lifecycle, focus, swipe,\n * and auto-dismiss behavior. It is intentionally composed rather than a\n * global imperative notification API.\n */\nexport const ToastRoot = forwardRef<HTMLDivElement, ToastRootProps>(function ToastRoot(\n { className, toast: toastObject, tone, ...props },\n ref,\n) {\n const resolvedTone = resolveTone(toastObject.type, tone);\n\n return (\n <BaseToast.Root\n {...props}\n ref={ref}\n toast={toastObject}\n className={withRecipeClassName(toastRecipe({ tone: resolvedTone }).root, className)}\n data-jaci-component=\"toast\"\n data-jaci-tone={resolvedTone}\n data-slot=\"toast\"\n />\n );\n});\n\nexport type ToastContentProps = ComponentPropsWithoutRef<typeof BaseToast.Content>;\n\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(function ToastContent(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Content\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().content, className)}\n data-slot=\"toast-content\"\n />\n );\n});\n\n/** A layout wrapper for `Toast.Title` and `Toast.Description`. */\nexport type ToastTextProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const ToastText = forwardRef<HTMLDivElement, ToastTextProps>(function ToastText(\n { className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(toastRecipe().text, className)}\n data-slot=\"toast-text\"\n />\n );\n});\n\nexport type ToastTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;\n\nexport const ToastTitle = forwardRef<HTMLHeadingElement, ToastTitleProps>(function ToastTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().title, className)}\n data-slot=\"toast-title\"\n />\n );\n});\n\nexport type ToastDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Description>;\n\nexport const ToastDescription = forwardRef<HTMLParagraphElement, ToastDescriptionProps>(\n function ToastDescription({ className, ...props }, ref) {\n return (\n <BaseToast.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().description, className)}\n data-slot=\"toast-description\"\n />\n );\n },\n);\n\nexport type ToastCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;\n\nexport const ToastClose = forwardRef<HTMLButtonElement, ToastCloseProps>(function ToastClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BaseToast.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Dismiss notification\")}\n ref={ref}\n className={withRecipeClassName(toastRecipe().close, className)}\n data-slot=\"toast-close\"\n >\n {children ?? \"×\"}\n </BaseToast.Close>\n );\n});\n\nexport type ToastActionProps = ComponentPropsWithoutRef<typeof BaseToast.Action>;\n\nexport const ToastAction = forwardRef<HTMLButtonElement, ToastActionProps>(function ToastAction(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Action\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().action, className)}\n data-slot=\"toast-action\"\n />\n );\n});\n\n/** Base UI's portal is preserved for rendering the viewport at document level. */\nexport
|
|
1
|
+
{"version":3,"file":"toast.js","names":["BaseToast","toastRecipe","Toast"],"sources":["../../../src/components/toast/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { Toast as BaseToast } from \"@base-ui/react/toast\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { toast as toastRecipe } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\nexport type ToastTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\";\n\nconst toneByToastType: Record<string, ToastTone> = {\n danger: \"danger\",\n error: \"danger\",\n info: \"info\",\n success: \"success\",\n warning: \"warning\",\n};\n\nfunction resolveTone(type: string | undefined, tone: ToastTone | undefined): ToastTone {\n return tone ?? (type === undefined ? \"neutral\" : (toneByToastType[type] ?? \"neutral\"));\n}\n\nexport type ToastProviderProps = ComponentPropsWithoutRef<typeof BaseToast.Provider>;\n\n/**\n * Creates an isolated, declarative toast region. Configure `timeout` and\n * `limit` here; use `Toast.Root` to render each toast from local state or\n * `Toast.useToastManager()`.\n */\nexport function ToastProvider(props: ToastProviderProps) {\n return <BaseToast.Provider {...props} />;\n}\n\nexport type ToastViewportProps = ComponentPropsWithoutRef<typeof BaseToast.Viewport>;\n\n/**\n * A bottom-centred notification region.\n */\nexport const ToastViewport = forwardRef<HTMLDivElement, ToastViewportProps>(function ToastViewport(\n { \"aria-label\": ariaLabel, \"aria-live\": ariaLive, className, ...props },\n ref,\n) {\n return (\n <BaseToast.Viewport\n {...props}\n aria-label={ariaLabel ?? \"Notifications\"}\n aria-live={ariaLive ?? \"polite\"}\n ref={ref}\n className={withRecipeClassName(toastRecipe().viewport, className)}\n data-jaci-component=\"toast-viewport\"\n data-slot=\"toast-viewport\"\n />\n );\n});\n\nexport interface ToastRootProps extends ComponentPropsWithoutRef<typeof BaseToast.Root> {\n /**\n * Visual status. When omitted, the value is inferred from the toast's\n * `type` (`error` maps to `danger`) and otherwise remains neutral.\n */\n tone?: ToastTone;\n}\n\n/**\n * Renders a toast object while preserving Base UI's lifecycle, focus, swipe,\n * and auto-dismiss behavior. It is intentionally composed rather than a\n * global imperative notification API.\n */\nexport const ToastRoot = forwardRef<HTMLDivElement, ToastRootProps>(function ToastRoot(\n { className, toast: toastObject, tone, ...props },\n ref,\n) {\n const resolvedTone = resolveTone(toastObject.type, tone);\n\n return (\n <BaseToast.Root\n {...props}\n ref={ref}\n toast={toastObject}\n className={withRecipeClassName(toastRecipe({ tone: resolvedTone }).root, className)}\n data-jaci-component=\"toast\"\n data-jaci-tone={resolvedTone}\n data-slot=\"toast\"\n />\n );\n});\n\nexport type ToastContentProps = ComponentPropsWithoutRef<typeof BaseToast.Content>;\n\nexport const ToastContent = forwardRef<HTMLDivElement, ToastContentProps>(function ToastContent(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Content\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().content, className)}\n data-slot=\"toast-content\"\n />\n );\n});\n\n/** A layout wrapper for `Toast.Title` and `Toast.Description`. */\nexport type ToastTextProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const ToastText = forwardRef<HTMLDivElement, ToastTextProps>(function ToastText(\n { className, ...props },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n className={cx(toastRecipe().text, className)}\n data-slot=\"toast-text\"\n />\n );\n});\n\nexport type ToastTitleProps = ComponentPropsWithoutRef<typeof BaseToast.Title>;\n\nexport const ToastTitle = forwardRef<HTMLHeadingElement, ToastTitleProps>(function ToastTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().title, className)}\n data-slot=\"toast-title\"\n />\n );\n});\n\nexport type ToastDescriptionProps = ComponentPropsWithoutRef<typeof BaseToast.Description>;\n\nexport const ToastDescription = forwardRef<HTMLParagraphElement, ToastDescriptionProps>(\n function ToastDescription({ className, ...props }, ref) {\n return (\n <BaseToast.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().description, className)}\n data-slot=\"toast-description\"\n />\n );\n },\n);\n\nexport type ToastCloseProps = ComponentPropsWithoutRef<typeof BaseToast.Close>;\n\nexport const ToastClose = forwardRef<HTMLButtonElement, ToastCloseProps>(function ToastClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BaseToast.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Dismiss notification\")}\n ref={ref}\n className={withRecipeClassName(toastRecipe().close, className)}\n data-slot=\"toast-close\"\n >\n {children ?? \"×\"}\n </BaseToast.Close>\n );\n});\n\nexport type ToastActionProps = ComponentPropsWithoutRef<typeof BaseToast.Action>;\n\nexport const ToastAction = forwardRef<HTMLButtonElement, ToastActionProps>(function ToastAction(\n { className, ...props },\n ref,\n) {\n return (\n <BaseToast.Action\n {...props}\n ref={ref}\n className={withRecipeClassName(toastRecipe().action, className)}\n data-slot=\"toast-action\"\n />\n );\n});\n\n/** Base UI's portal is preserved for rendering the viewport at document level. */\nexport function ToastPortal(props: ComponentPropsWithoutRef<typeof BaseToast.Portal>) {\n return <BaseToast.Portal {...useThemePortalProps(props)} />;\n}\n\nexport interface ToastComponent {\n Provider: typeof ToastProvider;\n Viewport: typeof ToastViewport;\n Root: typeof ToastRoot;\n Content: typeof ToastContent;\n Text: typeof ToastText;\n Title: typeof ToastTitle;\n Description: typeof ToastDescription;\n Close: typeof ToastClose;\n Action: typeof ToastAction;\n Portal: typeof ToastPortal;\n useToastManager: typeof BaseToast.useToastManager;\n}\n\nexport const Toast: ToastComponent = {\n Provider: ToastProvider,\n Viewport: ToastViewport,\n Root: ToastRoot,\n Content: ToastContent,\n Text: ToastText,\n Title: ToastTitle,\n Description: ToastDescription,\n Close: ToastClose,\n Action: ToastAction,\n Portal: ToastPortal,\n useToastManager: BaseToast.useToastManager,\n};\n"],"mappings":";;;;;;;;;AAaA,MAAM,kBAA6C;CACjD,QAAQ;CACR,OAAO;CACP,MAAM;CACN,SAAS;CACT,SAAS;AACX;AAEA,SAAS,YAAY,MAA0B,MAA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BAACD,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAW,oBAAoBC,MAAY,CAAC,CAAC,OAAO,SAAS;EAC7D,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,mBAAmB,WAC9B,SAAS,iBAAiB,EAAE,WAAW,GAAG,SAAS,KAAK;CACtD,OACE,oBAACD,MAAU,aAAX;EACE,GAAI;EACC;EACL,WAAW,oBAAoBC,MAAY,CAAC,CAAC,aAAa,SAAS;EACnE,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,aAAa,WAA+C,SAAS,WAChF,EAAE,cAAc,WAAW,UAAU,WAAW,GAAG,SACnD,KACA;CACA,MAAM,kBAAkB,YAAY;CAEpC,OACE,oBAACD,MAAU,OAAX;EACE,GAAI;EACJ,cAAY,cAAc,kBAAkB,KAAA,IAAY;EACnD;EACL,WAAW,oBAAoBC,MAAY,CAAC,CAAC,OAAO,SAAS;EAC7D,aAAU;YAET,YAAY;CACE,CAAA;AAErB,CAAC;AAID,MAAa,cAAc,WAAgD,SAAS,YAClF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAACD,MAAU,QAAX;EACE,GAAI;EACC;EACL,WAAW,oBAAoBC,MAAY,CAAC,CAAC,QAAQ,SAAS;EAC9D,aAAU;CACX,CAAA;AAEL,CAAC;;AAGD,SAAgB,YAAY,OAA0D;CACpF,OAAO,oBAACD,MAAU,QAAX,EAAkB,GAAI,oBAAoB,KAAK,EAAI,CAAA;AAC5D;AAgBA,MAAaE,UAAwB;CACnC,UAAU;CACV,UAAU;CACV,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,aAAa;CACb,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,iBAAiBF,MAAU;AAC7B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_base_ui = require("../base-ui.cjs");
|
|
3
3
|
const require_tooltip = require("../../styled-system/recipes/tooltip.cjs");
|
|
4
|
+
const require_theme_scope = require("../../theme/theme-scope.cjs");
|
|
4
5
|
let react = require("react");
|
|
5
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
7
|
let _base_ui_react_tooltip = require("@base-ui/react/tooltip");
|
|
@@ -18,7 +19,9 @@ const TooltipTrigger = (0, react.forwardRef)(function TooltipTrigger({ className
|
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
21
|
/** Preserves Base UI's optional portal container and mount controls. */
|
|
21
|
-
|
|
22
|
+
function TooltipPortal(props) {
|
|
23
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Portal, { ...require_theme_scope.useThemePortalProps(props) });
|
|
24
|
+
}
|
|
22
25
|
const TooltipPositioner = (0, react.forwardRef)(function TooltipPositioner({ className, ...props }, ref) {
|
|
23
26
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Positioner, {
|
|
24
27
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.cjs","names":["BaseTooltip","withRecipeClassName","tooltip"],"sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport { Tooltip as BaseTooltip } from \"@base-ui/react/tooltip\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { TooltipRoot as BaseTooltipRoot } from \"@base-ui/react/tooltip\";\n\nimport { tooltip } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\n\n/** Preserves Base UI's controlled `open` API and uncontrolled `defaultOpen` API. */\nexport type TooltipRootProps<Payload = unknown> = BaseTooltipRoot.Props<Payload>;\n\nexport function TooltipRoot<Payload = unknown>(props: TooltipRootProps<Payload>) {\n return <BaseTooltip.Root {...props} />;\n}\n\nexport type TooltipTriggerProps = ComponentPropsWithoutRef<typeof BaseTooltip.Trigger>;\n\nexport const TooltipTrigger = forwardRef<HTMLButtonElement, TooltipTriggerProps>(\n function TooltipTrigger({ className, ...props }, ref) {\n return (\n <BaseTooltip.Trigger\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().trigger, className)}\n data-jaci-component=\"tooltip\"\n data-slot=\"tooltip-trigger\"\n />\n );\n },\n);\n\n/** Preserves Base UI's optional portal container and mount controls. */\nexport
|
|
1
|
+
{"version":3,"file":"tooltip.cjs","names":["BaseTooltip","withRecipeClassName","tooltip","useThemePortalProps"],"sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport { Tooltip as BaseTooltip } from \"@base-ui/react/tooltip\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { TooltipRoot as BaseTooltipRoot } from \"@base-ui/react/tooltip\";\n\nimport { tooltip } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\n/** Preserves Base UI's controlled `open` API and uncontrolled `defaultOpen` API. */\nexport type TooltipRootProps<Payload = unknown> = BaseTooltipRoot.Props<Payload>;\n\nexport function TooltipRoot<Payload = unknown>(props: TooltipRootProps<Payload>) {\n return <BaseTooltip.Root {...props} />;\n}\n\nexport type TooltipTriggerProps = ComponentPropsWithoutRef<typeof BaseTooltip.Trigger>;\n\nexport const TooltipTrigger = forwardRef<HTMLButtonElement, TooltipTriggerProps>(\n function TooltipTrigger({ className, ...props }, ref) {\n return (\n <BaseTooltip.Trigger\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().trigger, className)}\n data-jaci-component=\"tooltip\"\n data-slot=\"tooltip-trigger\"\n />\n );\n },\n);\n\n/** Preserves Base UI's optional portal container and mount controls. */\nexport function TooltipPortal(props: ComponentPropsWithoutRef<typeof BaseTooltip.Portal>) {\n return <BaseTooltip.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type TooltipPositionerProps = ComponentPropsWithoutRef<typeof BaseTooltip.Positioner>;\n\nexport const TooltipPositioner = forwardRef<HTMLDivElement, TooltipPositionerProps>(\n function TooltipPositioner({ className, ...props }, ref) {\n return (\n <BaseTooltip.Positioner\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().positioner, className)}\n data-slot=\"tooltip-positioner\"\n />\n );\n },\n);\n\nexport type TooltipPopupProps = ComponentPropsWithoutRef<typeof BaseTooltip.Popup>;\n\nexport const TooltipPopup = forwardRef<HTMLDivElement, TooltipPopupProps>(function TooltipPopup(\n { className, ...props },\n ref,\n) {\n return (\n <BaseTooltip.Popup\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().popup, className)}\n data-jaci-component=\"tooltip\"\n data-slot=\"tooltip-popup\"\n />\n );\n});\n\nexport type TooltipArrowProps = ComponentPropsWithoutRef<typeof BaseTooltip.Arrow>;\n\nexport const TooltipArrow = forwardRef<HTMLDivElement, TooltipArrowProps>(function TooltipArrow(\n { className, ...props },\n ref,\n) {\n return (\n <BaseTooltip.Arrow\n {...props}\n ref={ref}\n className={withRecipeClassName(tooltip().arrow, className)}\n data-slot=\"tooltip-arrow\"\n />\n );\n});\n\nexport const Tooltip = {\n Root: TooltipRoot,\n Trigger: TooltipTrigger,\n Portal: TooltipPortal,\n Positioner: TooltipPositioner,\n Popup: TooltipPopup,\n Arrow: TooltipArrow,\n createHandle: BaseTooltip.createHandle,\n};\n"],"mappings":";;;;;;;;AAcA,SAAgB,YAA+B,OAAkC;CAC/E,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,uBAAAA,QAAY,MAAb,EAAkB,GAAI,MAAQ,CAAA;AACvC;AAIA,MAAa,kBAAA,GAAA,MAAA,WAAA,CACX,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CACpD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,uBAAAA,QAAY,SAAb;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,SAAS,SAAS;EAC3D,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CACF;;AAGA,SAAgB,cAAc,OAA4D;CACxF,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACF,uBAAAA,QAAY,QAAb,EAAoB,GAAIG,oBAAAA,oBAAoB,KAAK,EAAI,CAAA;AAC9D;AAIA,MAAa,qBAAA,GAAA,MAAA,WAAA,CACX,SAAS,kBAAkB,EAAE,WAAW,GAAG,SAAS,KAAK;CACvD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACH,uBAAAA,QAAY,YAAb;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,YAAY,SAAS;EAC9D,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA6D,SAAS,aACjF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACF,uBAAAA,QAAY,OAAb;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,OAAO,SAAS;EACzD,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA6D,SAAS,aACjF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACF,uBAAAA,QAAY,OAAb;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,OAAO,SAAS;EACzD,aAAU;CACX,CAAA;AAEL,CAAC;AAED,MAAa,UAAU;CACrB,MAAM;CACN,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,OAAO;CACP,OAAO;CACP,cAAcF,uBAAAA,QAAY;AAC5B"}
|
|
@@ -7,7 +7,7 @@ declare function TooltipRoot$1<Payload = unknown>(props: TooltipRootProps<Payloa
|
|
|
7
7
|
type TooltipTriggerProps = ComponentPropsWithoutRef<typeof Tooltip.Trigger>;
|
|
8
8
|
declare const TooltipTrigger: import("react").ForwardRefExoticComponent<Omit<Tooltip.Trigger.Props<unknown> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
9
9
|
/** Preserves Base UI's optional portal container and mount controls. */
|
|
10
|
-
declare
|
|
10
|
+
declare function TooltipPortal(props: ComponentPropsWithoutRef<typeof Tooltip.Portal>): import("react").JSX.Element;
|
|
11
11
|
type TooltipPositionerProps = ComponentPropsWithoutRef<typeof Tooltip.Positioner>;
|
|
12
12
|
declare const TooltipPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").TooltipPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
13
|
type TooltipPopupProps = ComponentPropsWithoutRef<typeof Tooltip.Popup>;
|
|
@@ -17,7 +17,7 @@ declare const TooltipArrow: import("react").ForwardRefExoticComponent<Omit<Omit<
|
|
|
17
17
|
declare const Tooltip$1: {
|
|
18
18
|
Root: typeof TooltipRoot$1;
|
|
19
19
|
Trigger: import("react").ForwardRefExoticComponent<Omit<Tooltip.Trigger.Props<unknown> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
20
|
-
Portal:
|
|
20
|
+
Portal: typeof TooltipPortal;
|
|
21
21
|
Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").TooltipPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
22
|
Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").TooltipPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
23
23
|
Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").TooltipArrowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -7,7 +7,7 @@ declare function TooltipRoot$1<Payload = unknown>(props: TooltipRootProps<Payloa
|
|
|
7
7
|
type TooltipTriggerProps = ComponentPropsWithoutRef<typeof Tooltip.Trigger>;
|
|
8
8
|
declare const TooltipTrigger: import("react").ForwardRefExoticComponent<Omit<Tooltip.Trigger.Props<unknown> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
9
9
|
/** Preserves Base UI's optional portal container and mount controls. */
|
|
10
|
-
declare
|
|
10
|
+
declare function TooltipPortal(props: ComponentPropsWithoutRef<typeof Tooltip.Portal>): import("react").JSX.Element;
|
|
11
11
|
type TooltipPositionerProps = ComponentPropsWithoutRef<typeof Tooltip.Positioner>;
|
|
12
12
|
declare const TooltipPositioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").TooltipPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
13
|
type TooltipPopupProps = ComponentPropsWithoutRef<typeof Tooltip.Popup>;
|
|
@@ -17,7 +17,7 @@ declare const TooltipArrow: import("react").ForwardRefExoticComponent<Omit<Omit<
|
|
|
17
17
|
declare const Tooltip$1: {
|
|
18
18
|
Root: typeof TooltipRoot$1;
|
|
19
19
|
Trigger: import("react").ForwardRefExoticComponent<Omit<Tooltip.Trigger.Props<unknown> & import("react").RefAttributes<HTMLElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
20
|
-
Portal:
|
|
20
|
+
Portal: typeof TooltipPortal;
|
|
21
21
|
Positioner: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").TooltipPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
22
|
Popup: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").TooltipPopupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
23
23
|
Arrow: import("react").ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react").TooltipArrowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|