@bergetai/ui 0.17.0 → 0.19.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/dist/components/alert-dialog/AlertDialog.cjs +3 -3
- package/dist/components/alert-dialog/AlertDialog.cjs.map +1 -1
- package/dist/components/alert-dialog/AlertDialog.d.cts +3 -3
- package/dist/components/alert-dialog/AlertDialog.d.mts +3 -3
- package/dist/components/alert-dialog/AlertDialog.mjs +3 -3
- package/dist/components/alert-dialog/AlertDialog.mjs.map +1 -1
- package/dist/components/box/Box.cjs.map +1 -1
- package/dist/components/box/Box.d.cts +3 -3
- package/dist/components/box/Box.d.mts +3 -3
- package/dist/components/box/Box.mjs.map +1 -1
- package/dist/components/button/Button.cjs +3 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.d.cts +1 -1
- package/dist/components/button/Button.d.mts +1 -1
- package/dist/components/button/Button.mjs +3 -1
- package/dist/components/button/Button.mjs.map +1 -1
- package/dist/components/code-block/CodeBlock.cjs +50 -48
- package/dist/components/code-block/CodeBlock.cjs.map +1 -1
- package/dist/components/code-block/CodeBlock.d.cts +27 -7
- package/dist/components/code-block/CodeBlock.d.cts.map +1 -1
- package/dist/components/code-block/CodeBlock.d.mts +27 -7
- package/dist/components/code-block/CodeBlock.d.mts.map +1 -1
- package/dist/components/code-block/CodeBlock.mjs +45 -50
- package/dist/components/code-block/CodeBlock.mjs.map +1 -1
- package/dist/components/code-block/index.d.cts +3 -0
- package/dist/components/code-block/index.d.mts +3 -0
- package/dist/components/container/Container.cjs.map +1 -1
- package/dist/components/container/Container.d.cts +3 -3
- package/dist/components/container/Container.d.mts +3 -3
- package/dist/components/container/Container.mjs.map +1 -1
- package/dist/components/country-select/CountrySelect.cjs +2 -2
- package/dist/components/country-select/CountrySelect.cjs.map +1 -1
- package/dist/components/country-select/CountrySelect.mjs +2 -2
- package/dist/components/country-select/CountrySelect.mjs.map +1 -1
- package/dist/components/dialog/Dialog.cjs +3 -3
- package/dist/components/dialog/Dialog.cjs.map +1 -1
- package/dist/components/dialog/Dialog.d.cts +1 -1
- package/dist/components/dialog/Dialog.d.mts +1 -1
- package/dist/components/dialog/Dialog.mjs +3 -3
- package/dist/components/dialog/Dialog.mjs.map +1 -1
- package/dist/components/dropdown-menu/DropdownMenu.cjs.map +1 -1
- package/dist/components/dropdown-menu/DropdownMenu.d.cts +9 -9
- package/dist/components/dropdown-menu/DropdownMenu.d.mts +9 -9
- package/dist/components/dropdown-menu/DropdownMenu.mjs.map +1 -1
- package/dist/components/grid/Grid.cjs.map +1 -1
- package/dist/components/grid/Grid.d.cts +3 -3
- package/dist/components/grid/Grid.d.mts +3 -3
- package/dist/components/grid/Grid.mjs.map +1 -1
- package/dist/components/item/Item.cjs.map +1 -1
- package/dist/components/item/Item.d.cts +1 -1
- package/dist/components/item/Item.d.mts +1 -1
- package/dist/components/item/Item.mjs.map +1 -1
- package/dist/components/typography/Typography.d.cts +1 -1
- package/dist/components/typography/Typography.d.mts +1 -1
- package/dist/hooks/use-highlighted-code.cjs +58 -0
- package/dist/hooks/use-highlighted-code.cjs.map +1 -0
- package/dist/hooks/use-highlighted-code.d.cts +5 -0
- package/dist/hooks/use-highlighted-code.d.cts.map +1 -0
- package/dist/hooks/use-highlighted-code.d.mts +5 -0
- package/dist/hooks/use-highlighted-code.d.mts.map +1 -0
- package/dist/hooks/use-highlighted-code.mjs +56 -0
- package/dist/hooks/use-highlighted-code.mjs.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.d.cts +6 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +5 -2
- package/dist/lib/highlighter.cjs +81 -0
- package/dist/lib/highlighter.cjs.map +1 -0
- package/dist/lib/highlighter.mjs +79 -0
- package/dist/lib/highlighter.mjs.map +1 -0
- package/dist/lib/utils.cjs +4 -4
- package/dist/lib/utils.cjs.map +1 -1
- package/dist/lib/utils.d.cts +6 -0
- package/dist/lib/utils.d.cts.map +1 -0
- package/dist/lib/utils.d.mts +6 -0
- package/dist/lib/utils.d.mts.map +1 -0
- package/dist/lib/utils.mjs +4 -4
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/primitives/button.d.cts +1 -1
- package/dist/primitives/button.d.mts +1 -1
- package/dist/primitives/code-block.cjs +133 -0
- package/dist/primitives/code-block.cjs.map +1 -0
- package/dist/primitives/code-block.d.cts +29 -0
- package/dist/primitives/code-block.d.cts.map +1 -0
- package/dist/primitives/code-block.d.mts +29 -0
- package/dist/primitives/code-block.d.mts.map +1 -0
- package/dist/primitives/code-block.mjs +124 -0
- package/dist/primitives/code-block.mjs.map +1 -0
- package/dist/styles/index.css +61 -0
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.cjs","names":["React","DropdownMenuTriggerPrimitive","asChildRender","DropdownMenuSubTriggerPrimitive","cn","DropdownMenuSubContentPrimitive","DropdownMenuContentPrimitive","DropdownMenuItemPrimitive","DropdownMenuCheckboxItemPrimitive","DropdownMenuRadioItemPrimitive","DropdownMenuLabelPrimitive","DropdownMenuSeparatorPrimitive","DropdownMenuShortcutPrimitive"],"sources":["../../../src/components/dropdown-menu/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport {\n DropdownMenuCheckboxItem as DropdownMenuCheckboxItemPrimitive,\n DropdownMenuContent as DropdownMenuContentPrimitive,\n DropdownMenuItem as DropdownMenuItemPrimitive,\n DropdownMenuLabel as DropdownMenuLabelPrimitive,\n DropdownMenuRadioItem as DropdownMenuRadioItemPrimitive,\n DropdownMenuSeparator as DropdownMenuSeparatorPrimitive,\n DropdownMenuShortcut as DropdownMenuShortcutPrimitive,\n DropdownMenuSubContent as DropdownMenuSubContentPrimitive,\n DropdownMenuSubTrigger as DropdownMenuSubTriggerPrimitive,\n DropdownMenuTrigger as DropdownMenuTriggerPrimitive,\n} from '../../primitives/dropdown-menu';\nimport { cn, asChildRender } from '../../lib/utils';\n\n/* ------------------------------------------------------------------ */\n/* Root & inert sub-components (re-exported from the primitive) */\n/* ------------------------------------------------------------------ */\n\nexport {\n DropdownMenu,\n DropdownMenuGroup,\n DropdownMenuPortal,\n DropdownMenuSub,\n DropdownMenuRadioGroup,\n} from '../../primitives/dropdown-menu';\n\n/* ------------------------------------------------------------------ */\n/* Trigger */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuTriggerProps = Omit<\n React.ComponentProps<typeof DropdownMenuTriggerPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuTrigger = React.forwardRef<HTMLButtonElement, DropdownMenuTriggerProps>(\n ({ asChild, children, ...props }, ref) => (\n <DropdownMenuTriggerPrimitive ref={ref} render={asChildRender(asChild, children)} {...props}>\n {asChild ? undefined : children}\n </DropdownMenuTriggerPrimitive>\n ),\n);\nDropdownMenuTrigger.displayName = 'DropdownMenuTrigger';\n\n/* ------------------------------------------------------------------ */\n/* SubTrigger */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSubTriggerProps = Omit<\n React.ComponentProps<typeof DropdownMenuSubTriggerPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n inset?: boolean;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuSubTrigger = React.forwardRef<HTMLDivElement, DropdownMenuSubTriggerProps>(\n ({ className, inset, asChild, children, ...props }, ref) => (\n <DropdownMenuSubTriggerPrimitive\n ref={ref}\n className={cn(\n // Berget density & radius; focus/accent styling comes from the primitive.\n 'gap-2 rounded-berget-xs px-2 py-1.5',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuSubTriggerPrimitive>\n ),\n);\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\n/* ------------------------------------------------------------------ */\n/* SubContent */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSubContentProps = React.ComponentProps<typeof DropdownMenuSubContentPrimitive>;\n\nconst DropdownMenuSubContent = React.forwardRef<HTMLDivElement, DropdownMenuSubContentProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuSubContentPrimitive\n ref={ref}\n className={cn(\n `\n rounded-berget-xs bg-berget-popover text-berget-popover-foreground\n shadow-berget-lg\n `,\n className,\n )}\n {...props}\n />\n ),\n);\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\n/* ------------------------------------------------------------------ */\n/* Content */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuContentProps = React.ComponentProps<typeof DropdownMenuContentPrimitive>;\n\nconst DropdownMenuContent = React.forwardRef<HTMLDivElement, DropdownMenuContentProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuContentPrimitive\n ref={ref}\n className={cn(\n `\n rounded-berget-xs bg-berget-popover text-berget-popover-foreground\n shadow-berget-md\n `,\n className,\n )}\n {...props}\n />\n ),\n);\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\n/* ------------------------------------------------------------------ */\n/* Item */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n inset?: boolean;\n /** Typeahead label. Replaces the Radix `textValue` prop. */\n textValue?: string;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuItem = React.forwardRef<HTMLDivElement, DropdownMenuItemProps>(\n ({ className, inset, asChild, children, textValue, ...props }, ref) => (\n <DropdownMenuItemPrimitive\n ref={ref}\n label={textValue}\n className={cn(\n // Berget density & radius; focus accent and destructive variant from the primitive.\n 'gap-2 rounded-berget-xs px-2 py-1.5',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuItemPrimitive>\n ),\n);\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\n/* ------------------------------------------------------------------ */\n/* CheckboxItem */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuCheckboxItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuCheckboxItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n /** Typeahead label. Replaces the Radix `textValue` prop. */\n textValue?: string;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuCheckboxItem = React.forwardRef<HTMLDivElement, DropdownMenuCheckboxItemProps>(\n ({ className, children, asChild, textValue, ...props }, ref) => (\n <DropdownMenuCheckboxItemPrimitive\n ref={ref}\n label={textValue}\n className={cn('rounded-berget-xs', className)}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuCheckboxItemPrimitive>\n ),\n);\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\n/* ------------------------------------------------------------------ */\n/* RadioItem */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuRadioItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuRadioItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n /** Typeahead label. Replaces the Radix `textValue` prop. */\n textValue?: string;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuRadioItem = React.forwardRef<HTMLDivElement, DropdownMenuRadioItemProps>(\n ({ className, children, asChild, textValue, ...props }, ref) => (\n <DropdownMenuRadioItemPrimitive\n ref={ref}\n label={textValue}\n className={cn('rounded-berget-xs', className)}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuRadioItemPrimitive>\n ),\n);\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\n/* ------------------------------------------------------------------ */\n/* Label */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuLabelProps = Omit<\n React.ComponentProps<typeof DropdownMenuLabelPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n inset?: boolean;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuLabel = React.forwardRef<HTMLDivElement, DropdownMenuLabelProps>(\n ({ className, inset, asChild, children, ...props }, ref) => (\n <DropdownMenuLabelPrimitive\n ref={ref}\n className={cn(\n 'px-2 py-1.5 text-sm font-semibold text-berget-foreground',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuLabelPrimitive>\n ),\n);\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\n/* ------------------------------------------------------------------ */\n/* Separator */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSeparatorProps = Omit<\n React.ComponentProps<typeof DropdownMenuSeparatorPrimitive>,\n 'className'\n> & { className?: string };\n\nconst DropdownMenuSeparator = React.forwardRef<HTMLDivElement, DropdownMenuSeparatorProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuSeparatorPrimitive\n ref={ref}\n className={cn('bg-berget-separator', className)}\n {...props}\n />\n ),\n);\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/* ------------------------------------------------------------------ */\n/* Shortcut */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuShortcutProps = React.ComponentProps<typeof DropdownMenuShortcutPrimitive>;\n\nconst DropdownMenuShortcut = ({ className, ...props }: DropdownMenuShortcutProps) => {\n return (\n <DropdownMenuShortcutPrimitive\n className={cn('text-berget-muted-foreground', className)}\n {...props}\n />\n );\n};\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/* ------------------------------------------------------------------ */\n/* Exports */\n/* ------------------------------------------------------------------ */\n\nexport {\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"DropdownMenu.cjs","names":["React","DropdownMenuTriggerPrimitive","asChildRender","DropdownMenuSubTriggerPrimitive","cn","DropdownMenuSubContentPrimitive","DropdownMenuContentPrimitive","DropdownMenuItemPrimitive","DropdownMenuCheckboxItemPrimitive","DropdownMenuRadioItemPrimitive","DropdownMenuLabelPrimitive","DropdownMenuSeparatorPrimitive","DropdownMenuShortcutPrimitive"],"sources":["../../../src/components/dropdown-menu/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport {\n DropdownMenuCheckboxItem as DropdownMenuCheckboxItemPrimitive,\n DropdownMenuContent as DropdownMenuContentPrimitive,\n DropdownMenuItem as DropdownMenuItemPrimitive,\n DropdownMenuLabel as DropdownMenuLabelPrimitive,\n DropdownMenuRadioItem as DropdownMenuRadioItemPrimitive,\n DropdownMenuSeparator as DropdownMenuSeparatorPrimitive,\n DropdownMenuShortcut as DropdownMenuShortcutPrimitive,\n DropdownMenuSubContent as DropdownMenuSubContentPrimitive,\n DropdownMenuSubTrigger as DropdownMenuSubTriggerPrimitive,\n DropdownMenuTrigger as DropdownMenuTriggerPrimitive,\n} from '../../primitives/dropdown-menu';\nimport { cn, asChildRender } from '../../lib/utils';\n\n/* ------------------------------------------------------------------ */\n/* Root & inert sub-components (re-exported from the primitive) */\n/* ------------------------------------------------------------------ */\n\nexport {\n DropdownMenu,\n DropdownMenuGroup,\n DropdownMenuPortal,\n DropdownMenuSub,\n DropdownMenuRadioGroup,\n} from '../../primitives/dropdown-menu';\n\n/* ------------------------------------------------------------------ */\n/* Trigger */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuTriggerProps = Omit<\n React.ComponentProps<typeof DropdownMenuTriggerPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuTrigger = React.forwardRef<HTMLButtonElement, DropdownMenuTriggerProps>(\n ({ asChild, children, ...props }, ref) => (\n <DropdownMenuTriggerPrimitive ref={ref} render={asChildRender(asChild, children)} {...props}>\n {asChild ? undefined : children}\n </DropdownMenuTriggerPrimitive>\n ),\n);\nDropdownMenuTrigger.displayName = 'DropdownMenuTrigger';\n\n/* ------------------------------------------------------------------ */\n/* SubTrigger */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSubTriggerProps = Omit<\n React.ComponentProps<typeof DropdownMenuSubTriggerPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n inset?: boolean;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuSubTrigger = React.forwardRef<HTMLDivElement, DropdownMenuSubTriggerProps>(\n ({ className, inset, asChild, children, ...props }, ref) => (\n <DropdownMenuSubTriggerPrimitive\n ref={ref}\n className={cn(\n // Berget density & radius; focus/accent styling comes from the primitive.\n 'gap-2 rounded-berget-xs px-2 py-1.5',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuSubTriggerPrimitive>\n ),\n);\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\n/* ------------------------------------------------------------------ */\n/* SubContent */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSubContentProps = React.ComponentProps<typeof DropdownMenuSubContentPrimitive>;\n\nconst DropdownMenuSubContent = React.forwardRef<HTMLDivElement, DropdownMenuSubContentProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuSubContentPrimitive\n ref={ref}\n className={cn(\n `\n rounded-berget-xs bg-berget-popover text-berget-popover-foreground\n shadow-berget-lg\n `,\n className,\n )}\n {...props}\n />\n ),\n);\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\n/* ------------------------------------------------------------------ */\n/* Content */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuContentProps = React.ComponentProps<typeof DropdownMenuContentPrimitive>;\n\nconst DropdownMenuContent = React.forwardRef<HTMLDivElement, DropdownMenuContentProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuContentPrimitive\n ref={ref}\n className={cn(\n `\n rounded-berget-xs bg-berget-popover text-berget-popover-foreground\n shadow-berget-md\n `,\n className,\n )}\n {...props}\n />\n ),\n);\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\n/* ------------------------------------------------------------------ */\n/* Item */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n inset?: boolean;\n /** Typeahead label for keyboard typeahead. */\n textValue?: string;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuItem = React.forwardRef<HTMLDivElement, DropdownMenuItemProps>(\n ({ className, inset, asChild, children, textValue, ...props }, ref) => (\n <DropdownMenuItemPrimitive\n ref={ref}\n label={textValue}\n className={cn(\n // Berget density & radius; focus accent and destructive variant from the primitive.\n 'gap-2 rounded-berget-xs px-2 py-1.5',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuItemPrimitive>\n ),\n);\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\n/* ------------------------------------------------------------------ */\n/* CheckboxItem */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuCheckboxItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuCheckboxItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n /** Typeahead label for keyboard typeahead. */\n textValue?: string;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuCheckboxItem = React.forwardRef<HTMLDivElement, DropdownMenuCheckboxItemProps>(\n ({ className, children, asChild, textValue, ...props }, ref) => (\n <DropdownMenuCheckboxItemPrimitive\n ref={ref}\n label={textValue}\n className={cn('rounded-berget-xs', className)}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuCheckboxItemPrimitive>\n ),\n);\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\n/* ------------------------------------------------------------------ */\n/* RadioItem */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuRadioItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuRadioItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n /** Typeahead label for keyboard typeahead. */\n textValue?: string;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuRadioItem = React.forwardRef<HTMLDivElement, DropdownMenuRadioItemProps>(\n ({ className, children, asChild, textValue, ...props }, ref) => (\n <DropdownMenuRadioItemPrimitive\n ref={ref}\n label={textValue}\n className={cn('rounded-berget-xs', className)}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuRadioItemPrimitive>\n ),\n);\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\n/* ------------------------------------------------------------------ */\n/* Label */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuLabelProps = Omit<\n React.ComponentProps<typeof DropdownMenuLabelPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n inset?: boolean;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuLabel = React.forwardRef<HTMLDivElement, DropdownMenuLabelProps>(\n ({ className, inset, asChild, children, ...props }, ref) => (\n <DropdownMenuLabelPrimitive\n ref={ref}\n className={cn(\n 'px-2 py-1.5 text-sm font-semibold text-berget-foreground',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuLabelPrimitive>\n ),\n);\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\n/* ------------------------------------------------------------------ */\n/* Separator */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSeparatorProps = Omit<\n React.ComponentProps<typeof DropdownMenuSeparatorPrimitive>,\n 'className'\n> & { className?: string };\n\nconst DropdownMenuSeparator = React.forwardRef<HTMLDivElement, DropdownMenuSeparatorProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuSeparatorPrimitive\n ref={ref}\n className={cn('bg-berget-separator', className)}\n {...props}\n />\n ),\n);\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/* ------------------------------------------------------------------ */\n/* Shortcut */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuShortcutProps = React.ComponentProps<typeof DropdownMenuShortcutPrimitive>;\n\nconst DropdownMenuShortcut = ({ className, ...props }: DropdownMenuShortcutProps) => {\n return (\n <DropdownMenuShortcutPrimitive\n className={cn('text-berget-muted-foreground', className)}\n {...props}\n />\n );\n};\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/* ------------------------------------------------------------------ */\n/* Exports */\n/* ------------------------------------------------------------------ */\n\nexport {\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n};\n"],"mappings":"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"}
|
|
@@ -3,14 +3,14 @@ import * as React from "react";
|
|
|
3
3
|
//#region src/components/dropdown-menu/DropdownMenu.d.ts
|
|
4
4
|
type DropdownMenuTriggerProps = Omit<React.ComponentProps<typeof DropdownMenuTrigger$1>, 'className' | 'render'> & {
|
|
5
5
|
className?: string;
|
|
6
|
-
/** Render as a different element/component
|
|
6
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
7
7
|
asChild?: boolean;
|
|
8
8
|
};
|
|
9
9
|
declare const DropdownMenuTrigger: React.ForwardRefExoticComponent<Omit<DropdownMenuTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
10
10
|
type DropdownMenuSubTriggerProps = Omit<React.ComponentProps<typeof DropdownMenuSubTrigger$1>, 'className' | 'render'> & {
|
|
11
11
|
className?: string;
|
|
12
12
|
inset?: boolean;
|
|
13
|
-
/** Render as a different element/component
|
|
13
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
14
14
|
asChild?: boolean;
|
|
15
15
|
};
|
|
16
16
|
declare const DropdownMenuSubTrigger: React.ForwardRefExoticComponent<Omit<DropdownMenuSubTriggerProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -19,32 +19,32 @@ declare const DropdownMenuContent: React.ForwardRefExoticComponent<Omit<import("
|
|
|
19
19
|
type DropdownMenuItemProps = Omit<React.ComponentProps<typeof DropdownMenuItem$1>, 'className' | 'render' | 'label'> & {
|
|
20
20
|
className?: string;
|
|
21
21
|
inset?: boolean;
|
|
22
|
-
/** Typeahead label
|
|
22
|
+
/** Typeahead label for keyboard typeahead. */
|
|
23
23
|
textValue?: string;
|
|
24
|
-
/** Render as a different element/component
|
|
24
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
25
25
|
asChild?: boolean;
|
|
26
26
|
};
|
|
27
27
|
declare const DropdownMenuItem: React.ForwardRefExoticComponent<Omit<DropdownMenuItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
28
28
|
type DropdownMenuCheckboxItemProps = Omit<React.ComponentProps<typeof DropdownMenuCheckboxItem$1>, 'className' | 'render' | 'label'> & {
|
|
29
29
|
className?: string;
|
|
30
|
-
/** Typeahead label
|
|
30
|
+
/** Typeahead label for keyboard typeahead. */
|
|
31
31
|
textValue?: string;
|
|
32
|
-
/** Render as a different element/component
|
|
32
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
33
33
|
asChild?: boolean;
|
|
34
34
|
};
|
|
35
35
|
declare const DropdownMenuCheckboxItem: React.ForwardRefExoticComponent<Omit<DropdownMenuCheckboxItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
36
36
|
type DropdownMenuRadioItemProps = Omit<React.ComponentProps<typeof DropdownMenuRadioItem$1>, 'className' | 'render' | 'label'> & {
|
|
37
37
|
className?: string;
|
|
38
|
-
/** Typeahead label
|
|
38
|
+
/** Typeahead label for keyboard typeahead. */
|
|
39
39
|
textValue?: string;
|
|
40
|
-
/** Render as a different element/component
|
|
40
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
41
41
|
asChild?: boolean;
|
|
42
42
|
};
|
|
43
43
|
declare const DropdownMenuRadioItem: React.ForwardRefExoticComponent<Omit<DropdownMenuRadioItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
44
44
|
type DropdownMenuLabelProps = Omit<React.ComponentProps<typeof DropdownMenuLabel$1>, 'className' | 'render'> & {
|
|
45
45
|
className?: string;
|
|
46
46
|
inset?: boolean;
|
|
47
|
-
/** Render as a different element/component
|
|
47
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
48
48
|
asChild?: boolean;
|
|
49
49
|
};
|
|
50
50
|
declare const DropdownMenuLabel: React.ForwardRefExoticComponent<Omit<DropdownMenuLabelProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -3,14 +3,14 @@ import * as React from "react";
|
|
|
3
3
|
//#region src/components/dropdown-menu/DropdownMenu.d.ts
|
|
4
4
|
type DropdownMenuTriggerProps = Omit<React.ComponentProps<typeof DropdownMenuTrigger$1>, 'className' | 'render'> & {
|
|
5
5
|
className?: string;
|
|
6
|
-
/** Render as a different element/component
|
|
6
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
7
7
|
asChild?: boolean;
|
|
8
8
|
};
|
|
9
9
|
declare const DropdownMenuTrigger: React.ForwardRefExoticComponent<Omit<DropdownMenuTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
10
10
|
type DropdownMenuSubTriggerProps = Omit<React.ComponentProps<typeof DropdownMenuSubTrigger$1>, 'className' | 'render'> & {
|
|
11
11
|
className?: string;
|
|
12
12
|
inset?: boolean;
|
|
13
|
-
/** Render as a different element/component
|
|
13
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
14
14
|
asChild?: boolean;
|
|
15
15
|
};
|
|
16
16
|
declare const DropdownMenuSubTrigger: React.ForwardRefExoticComponent<Omit<DropdownMenuSubTriggerProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -19,32 +19,32 @@ declare const DropdownMenuContent: React.ForwardRefExoticComponent<Omit<import("
|
|
|
19
19
|
type DropdownMenuItemProps = Omit<React.ComponentProps<typeof DropdownMenuItem$1>, 'className' | 'render' | 'label'> & {
|
|
20
20
|
className?: string;
|
|
21
21
|
inset?: boolean;
|
|
22
|
-
/** Typeahead label
|
|
22
|
+
/** Typeahead label for keyboard typeahead. */
|
|
23
23
|
textValue?: string;
|
|
24
|
-
/** Render as a different element/component
|
|
24
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
25
25
|
asChild?: boolean;
|
|
26
26
|
};
|
|
27
27
|
declare const DropdownMenuItem: React.ForwardRefExoticComponent<Omit<DropdownMenuItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
28
28
|
type DropdownMenuCheckboxItemProps = Omit<React.ComponentProps<typeof DropdownMenuCheckboxItem$1>, 'className' | 'render' | 'label'> & {
|
|
29
29
|
className?: string;
|
|
30
|
-
/** Typeahead label
|
|
30
|
+
/** Typeahead label for keyboard typeahead. */
|
|
31
31
|
textValue?: string;
|
|
32
|
-
/** Render as a different element/component
|
|
32
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
33
33
|
asChild?: boolean;
|
|
34
34
|
};
|
|
35
35
|
declare const DropdownMenuCheckboxItem: React.ForwardRefExoticComponent<Omit<DropdownMenuCheckboxItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
36
36
|
type DropdownMenuRadioItemProps = Omit<React.ComponentProps<typeof DropdownMenuRadioItem$1>, 'className' | 'render' | 'label'> & {
|
|
37
37
|
className?: string;
|
|
38
|
-
/** Typeahead label
|
|
38
|
+
/** Typeahead label for keyboard typeahead. */
|
|
39
39
|
textValue?: string;
|
|
40
|
-
/** Render as a different element/component
|
|
40
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
41
41
|
asChild?: boolean;
|
|
42
42
|
};
|
|
43
43
|
declare const DropdownMenuRadioItem: React.ForwardRefExoticComponent<Omit<DropdownMenuRadioItemProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
44
44
|
type DropdownMenuLabelProps = Omit<React.ComponentProps<typeof DropdownMenuLabel$1>, 'className' | 'render'> & {
|
|
45
45
|
className?: string;
|
|
46
46
|
inset?: boolean;
|
|
47
|
-
/** Render as a different element/component
|
|
47
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
48
48
|
asChild?: boolean;
|
|
49
49
|
};
|
|
50
50
|
declare const DropdownMenuLabel: React.ForwardRefExoticComponent<Omit<DropdownMenuLabelProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.mjs","names":["DropdownMenuTriggerPrimitive","DropdownMenuSubTriggerPrimitive","DropdownMenuSubContentPrimitive","DropdownMenuContentPrimitive","DropdownMenuItemPrimitive","DropdownMenuCheckboxItemPrimitive","DropdownMenuRadioItemPrimitive","DropdownMenuLabelPrimitive","DropdownMenuSeparatorPrimitive","DropdownMenuShortcutPrimitive"],"sources":["../../../src/components/dropdown-menu/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport {\n DropdownMenuCheckboxItem as DropdownMenuCheckboxItemPrimitive,\n DropdownMenuContent as DropdownMenuContentPrimitive,\n DropdownMenuItem as DropdownMenuItemPrimitive,\n DropdownMenuLabel as DropdownMenuLabelPrimitive,\n DropdownMenuRadioItem as DropdownMenuRadioItemPrimitive,\n DropdownMenuSeparator as DropdownMenuSeparatorPrimitive,\n DropdownMenuShortcut as DropdownMenuShortcutPrimitive,\n DropdownMenuSubContent as DropdownMenuSubContentPrimitive,\n DropdownMenuSubTrigger as DropdownMenuSubTriggerPrimitive,\n DropdownMenuTrigger as DropdownMenuTriggerPrimitive,\n} from '../../primitives/dropdown-menu';\nimport { cn, asChildRender } from '../../lib/utils';\n\n/* ------------------------------------------------------------------ */\n/* Root & inert sub-components (re-exported from the primitive) */\n/* ------------------------------------------------------------------ */\n\nexport {\n DropdownMenu,\n DropdownMenuGroup,\n DropdownMenuPortal,\n DropdownMenuSub,\n DropdownMenuRadioGroup,\n} from '../../primitives/dropdown-menu';\n\n/* ------------------------------------------------------------------ */\n/* Trigger */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuTriggerProps = Omit<\n React.ComponentProps<typeof DropdownMenuTriggerPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuTrigger = React.forwardRef<HTMLButtonElement, DropdownMenuTriggerProps>(\n ({ asChild, children, ...props }, ref) => (\n <DropdownMenuTriggerPrimitive ref={ref} render={asChildRender(asChild, children)} {...props}>\n {asChild ? undefined : children}\n </DropdownMenuTriggerPrimitive>\n ),\n);\nDropdownMenuTrigger.displayName = 'DropdownMenuTrigger';\n\n/* ------------------------------------------------------------------ */\n/* SubTrigger */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSubTriggerProps = Omit<\n React.ComponentProps<typeof DropdownMenuSubTriggerPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n inset?: boolean;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuSubTrigger = React.forwardRef<HTMLDivElement, DropdownMenuSubTriggerProps>(\n ({ className, inset, asChild, children, ...props }, ref) => (\n <DropdownMenuSubTriggerPrimitive\n ref={ref}\n className={cn(\n // Berget density & radius; focus/accent styling comes from the primitive.\n 'gap-2 rounded-berget-xs px-2 py-1.5',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuSubTriggerPrimitive>\n ),\n);\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\n/* ------------------------------------------------------------------ */\n/* SubContent */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSubContentProps = React.ComponentProps<typeof DropdownMenuSubContentPrimitive>;\n\nconst DropdownMenuSubContent = React.forwardRef<HTMLDivElement, DropdownMenuSubContentProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuSubContentPrimitive\n ref={ref}\n className={cn(\n `\n rounded-berget-xs bg-berget-popover text-berget-popover-foreground\n shadow-berget-lg\n `,\n className,\n )}\n {...props}\n />\n ),\n);\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\n/* ------------------------------------------------------------------ */\n/* Content */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuContentProps = React.ComponentProps<typeof DropdownMenuContentPrimitive>;\n\nconst DropdownMenuContent = React.forwardRef<HTMLDivElement, DropdownMenuContentProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuContentPrimitive\n ref={ref}\n className={cn(\n `\n rounded-berget-xs bg-berget-popover text-berget-popover-foreground\n shadow-berget-md\n `,\n className,\n )}\n {...props}\n />\n ),\n);\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\n/* ------------------------------------------------------------------ */\n/* Item */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n inset?: boolean;\n /** Typeahead label. Replaces the Radix `textValue` prop. */\n textValue?: string;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuItem = React.forwardRef<HTMLDivElement, DropdownMenuItemProps>(\n ({ className, inset, asChild, children, textValue, ...props }, ref) => (\n <DropdownMenuItemPrimitive\n ref={ref}\n label={textValue}\n className={cn(\n // Berget density & radius; focus accent and destructive variant from the primitive.\n 'gap-2 rounded-berget-xs px-2 py-1.5',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuItemPrimitive>\n ),\n);\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\n/* ------------------------------------------------------------------ */\n/* CheckboxItem */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuCheckboxItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuCheckboxItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n /** Typeahead label. Replaces the Radix `textValue` prop. */\n textValue?: string;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuCheckboxItem = React.forwardRef<HTMLDivElement, DropdownMenuCheckboxItemProps>(\n ({ className, children, asChild, textValue, ...props }, ref) => (\n <DropdownMenuCheckboxItemPrimitive\n ref={ref}\n label={textValue}\n className={cn('rounded-berget-xs', className)}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuCheckboxItemPrimitive>\n ),\n);\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\n/* ------------------------------------------------------------------ */\n/* RadioItem */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuRadioItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuRadioItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n /** Typeahead label. Replaces the Radix `textValue` prop. */\n textValue?: string;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuRadioItem = React.forwardRef<HTMLDivElement, DropdownMenuRadioItemProps>(\n ({ className, children, asChild, textValue, ...props }, ref) => (\n <DropdownMenuRadioItemPrimitive\n ref={ref}\n label={textValue}\n className={cn('rounded-berget-xs', className)}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuRadioItemPrimitive>\n ),\n);\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\n/* ------------------------------------------------------------------ */\n/* Label */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuLabelProps = Omit<\n React.ComponentProps<typeof DropdownMenuLabelPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n inset?: boolean;\n /** Render as a different element/component. Replaces the Radix `asChild` prop. */\n asChild?: boolean;\n};\n\nconst DropdownMenuLabel = React.forwardRef<HTMLDivElement, DropdownMenuLabelProps>(\n ({ className, inset, asChild, children, ...props }, ref) => (\n <DropdownMenuLabelPrimitive\n ref={ref}\n className={cn(\n 'px-2 py-1.5 text-sm font-semibold text-berget-foreground',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuLabelPrimitive>\n ),\n);\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\n/* ------------------------------------------------------------------ */\n/* Separator */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSeparatorProps = Omit<\n React.ComponentProps<typeof DropdownMenuSeparatorPrimitive>,\n 'className'\n> & { className?: string };\n\nconst DropdownMenuSeparator = React.forwardRef<HTMLDivElement, DropdownMenuSeparatorProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuSeparatorPrimitive\n ref={ref}\n className={cn('bg-berget-separator', className)}\n {...props}\n />\n ),\n);\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/* ------------------------------------------------------------------ */\n/* Shortcut */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuShortcutProps = React.ComponentProps<typeof DropdownMenuShortcutPrimitive>;\n\nconst DropdownMenuShortcut = ({ className, ...props }: DropdownMenuShortcutProps) => {\n return (\n <DropdownMenuShortcutPrimitive\n className={cn('text-berget-muted-foreground', className)}\n {...props}\n />\n );\n};\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/* ------------------------------------------------------------------ */\n/* Exports */\n/* ------------------------------------------------------------------ */\n\nexport {\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n};\n"],"mappings":";;;;;;AA2CA,MAAM,sBAAsB,MAAM,YAC/B,EAAE,SAAS,UAAU,GAAG,SAAS,QAChC,oBAACA,uBAAD;CAAmC;CAAK,QAAQ,cAAc,SAAS,QAAQ;CAAG,GAAI;CACnF,UAAA,UAAU,KAAA,IAAY;AACK,CAAA,CAElC;AACA,oBAAoB,cAAc;AAgBlC,MAAM,yBAAyB,MAAM,YAClC,EAAE,WAAW,OAAO,SAAS,UAAU,GAAG,SAAS,QAClD,oBAACC,0BAAD;CACO;CACL,WAAW,GAET,uCACA,SAAS,QACT,SACF;CACA,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACQ,CAAA,CAErC;AACA,uBAAuB,cAAc;AAQrC,MAAM,yBAAyB,MAAM,YAClC,EAAE,WAAW,GAAG,SAAS,QACxB,oBAACC,0BAAD;CACO;CACL,WAAW,GACT;;;WAIA,SACF;CACA,GAAI;AACL,CAAA,CAEL;AACA,uBAAuB,cAAc;AAQrC,MAAM,sBAAsB,MAAM,YAC/B,EAAE,WAAW,GAAG,SAAS,QACxB,oBAACC,uBAAD;CACO;CACL,WAAW,GACT;;;WAIA,SACF;CACA,GAAI;AACL,CAAA,CAEL;AACA,oBAAoB,cAAc;AAkBlC,MAAM,mBAAmB,MAAM,YAC5B,EAAE,WAAW,OAAO,SAAS,UAAU,WAAW,GAAG,SAAS,QAC7D,oBAACC,oBAAD;CACO;CACL,OAAO;CACP,WAAW,GAET,uCACA,SAAS,QACT,SACF;CACA,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACE,CAAA,CAE/B;AACA,iBAAiB,cAAc;AAiB/B,MAAM,2BAA2B,MAAM,YACpC,EAAE,WAAW,UAAU,SAAS,WAAW,GAAG,SAAS,QACtD,oBAACC,4BAAD;CACO;CACL,OAAO;CACP,WAAW,GAAG,qBAAqB,SAAS;CAC5C,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACU,CAAA,CAEvC;AACA,yBAAyB,cAAc;AAiBvC,MAAM,wBAAwB,MAAM,YACjC,EAAE,WAAW,UAAU,SAAS,WAAW,GAAG,SAAS,QACtD,oBAACC,yBAAD;CACO;CACL,OAAO;CACP,WAAW,GAAG,qBAAqB,SAAS;CAC5C,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACO,CAAA,CAEpC;AACA,sBAAsB,cAAc;AAgBpC,MAAM,oBAAoB,MAAM,YAC7B,EAAE,WAAW,OAAO,SAAS,UAAU,GAAG,SAAS,QAClD,oBAACC,qBAAD;CACO;CACL,WAAW,GACT,4DACA,SAAS,QACT,SACF;CACA,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACG,CAAA,CAEhC;AACA,kBAAkB,cAAc;AAWhC,MAAM,wBAAwB,MAAM,YACjC,EAAE,WAAW,GAAG,SAAS,QACxB,oBAACC,yBAAD;CACO;CACL,WAAW,GAAG,uBAAuB,SAAS;CAC9C,GAAI;AACL,CAAA,CAEL;AACA,sBAAsB,cAAc;AAQpC,MAAM,wBAAwB,EAAE,WAAW,GAAG,YAAuC;CACnF,OACE,oBAACC,wBAAD;EACE,WAAW,GAAG,gCAAgC,SAAS;EACvD,GAAI;CACL,CAAA;AAEL;AACA,qBAAqB,cAAc"}
|
|
1
|
+
{"version":3,"file":"DropdownMenu.mjs","names":["DropdownMenuTriggerPrimitive","DropdownMenuSubTriggerPrimitive","DropdownMenuSubContentPrimitive","DropdownMenuContentPrimitive","DropdownMenuItemPrimitive","DropdownMenuCheckboxItemPrimitive","DropdownMenuRadioItemPrimitive","DropdownMenuLabelPrimitive","DropdownMenuSeparatorPrimitive","DropdownMenuShortcutPrimitive"],"sources":["../../../src/components/dropdown-menu/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport {\n DropdownMenuCheckboxItem as DropdownMenuCheckboxItemPrimitive,\n DropdownMenuContent as DropdownMenuContentPrimitive,\n DropdownMenuItem as DropdownMenuItemPrimitive,\n DropdownMenuLabel as DropdownMenuLabelPrimitive,\n DropdownMenuRadioItem as DropdownMenuRadioItemPrimitive,\n DropdownMenuSeparator as DropdownMenuSeparatorPrimitive,\n DropdownMenuShortcut as DropdownMenuShortcutPrimitive,\n DropdownMenuSubContent as DropdownMenuSubContentPrimitive,\n DropdownMenuSubTrigger as DropdownMenuSubTriggerPrimitive,\n DropdownMenuTrigger as DropdownMenuTriggerPrimitive,\n} from '../../primitives/dropdown-menu';\nimport { cn, asChildRender } from '../../lib/utils';\n\n/* ------------------------------------------------------------------ */\n/* Root & inert sub-components (re-exported from the primitive) */\n/* ------------------------------------------------------------------ */\n\nexport {\n DropdownMenu,\n DropdownMenuGroup,\n DropdownMenuPortal,\n DropdownMenuSub,\n DropdownMenuRadioGroup,\n} from '../../primitives/dropdown-menu';\n\n/* ------------------------------------------------------------------ */\n/* Trigger */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuTriggerProps = Omit<\n React.ComponentProps<typeof DropdownMenuTriggerPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuTrigger = React.forwardRef<HTMLButtonElement, DropdownMenuTriggerProps>(\n ({ asChild, children, ...props }, ref) => (\n <DropdownMenuTriggerPrimitive ref={ref} render={asChildRender(asChild, children)} {...props}>\n {asChild ? undefined : children}\n </DropdownMenuTriggerPrimitive>\n ),\n);\nDropdownMenuTrigger.displayName = 'DropdownMenuTrigger';\n\n/* ------------------------------------------------------------------ */\n/* SubTrigger */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSubTriggerProps = Omit<\n React.ComponentProps<typeof DropdownMenuSubTriggerPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n inset?: boolean;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuSubTrigger = React.forwardRef<HTMLDivElement, DropdownMenuSubTriggerProps>(\n ({ className, inset, asChild, children, ...props }, ref) => (\n <DropdownMenuSubTriggerPrimitive\n ref={ref}\n className={cn(\n // Berget density & radius; focus/accent styling comes from the primitive.\n 'gap-2 rounded-berget-xs px-2 py-1.5',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuSubTriggerPrimitive>\n ),\n);\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\n/* ------------------------------------------------------------------ */\n/* SubContent */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSubContentProps = React.ComponentProps<typeof DropdownMenuSubContentPrimitive>;\n\nconst DropdownMenuSubContent = React.forwardRef<HTMLDivElement, DropdownMenuSubContentProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuSubContentPrimitive\n ref={ref}\n className={cn(\n `\n rounded-berget-xs bg-berget-popover text-berget-popover-foreground\n shadow-berget-lg\n `,\n className,\n )}\n {...props}\n />\n ),\n);\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\n/* ------------------------------------------------------------------ */\n/* Content */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuContentProps = React.ComponentProps<typeof DropdownMenuContentPrimitive>;\n\nconst DropdownMenuContent = React.forwardRef<HTMLDivElement, DropdownMenuContentProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuContentPrimitive\n ref={ref}\n className={cn(\n `\n rounded-berget-xs bg-berget-popover text-berget-popover-foreground\n shadow-berget-md\n `,\n className,\n )}\n {...props}\n />\n ),\n);\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\n/* ------------------------------------------------------------------ */\n/* Item */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n inset?: boolean;\n /** Typeahead label for keyboard typeahead. */\n textValue?: string;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuItem = React.forwardRef<HTMLDivElement, DropdownMenuItemProps>(\n ({ className, inset, asChild, children, textValue, ...props }, ref) => (\n <DropdownMenuItemPrimitive\n ref={ref}\n label={textValue}\n className={cn(\n // Berget density & radius; focus accent and destructive variant from the primitive.\n 'gap-2 rounded-berget-xs px-2 py-1.5',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuItemPrimitive>\n ),\n);\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\n/* ------------------------------------------------------------------ */\n/* CheckboxItem */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuCheckboxItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuCheckboxItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n /** Typeahead label for keyboard typeahead. */\n textValue?: string;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuCheckboxItem = React.forwardRef<HTMLDivElement, DropdownMenuCheckboxItemProps>(\n ({ className, children, asChild, textValue, ...props }, ref) => (\n <DropdownMenuCheckboxItemPrimitive\n ref={ref}\n label={textValue}\n className={cn('rounded-berget-xs', className)}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuCheckboxItemPrimitive>\n ),\n);\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\n/* ------------------------------------------------------------------ */\n/* RadioItem */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuRadioItemProps = Omit<\n React.ComponentProps<typeof DropdownMenuRadioItemPrimitive>,\n 'className' | 'render' | 'label'\n> & {\n className?: string;\n /** Typeahead label for keyboard typeahead. */\n textValue?: string;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuRadioItem = React.forwardRef<HTMLDivElement, DropdownMenuRadioItemProps>(\n ({ className, children, asChild, textValue, ...props }, ref) => (\n <DropdownMenuRadioItemPrimitive\n ref={ref}\n label={textValue}\n className={cn('rounded-berget-xs', className)}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuRadioItemPrimitive>\n ),\n);\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\n/* ------------------------------------------------------------------ */\n/* Label */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuLabelProps = Omit<\n React.ComponentProps<typeof DropdownMenuLabelPrimitive>,\n 'className' | 'render'\n> & {\n className?: string;\n inset?: boolean;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n};\n\nconst DropdownMenuLabel = React.forwardRef<HTMLDivElement, DropdownMenuLabelProps>(\n ({ className, inset, asChild, children, ...props }, ref) => (\n <DropdownMenuLabelPrimitive\n ref={ref}\n className={cn(\n 'px-2 py-1.5 text-sm font-semibold text-berget-foreground',\n inset && 'pl-8',\n className,\n )}\n render={asChildRender(asChild, children)}\n {...props}\n >\n {asChild ? undefined : children}\n </DropdownMenuLabelPrimitive>\n ),\n);\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\n/* ------------------------------------------------------------------ */\n/* Separator */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuSeparatorProps = Omit<\n React.ComponentProps<typeof DropdownMenuSeparatorPrimitive>,\n 'className'\n> & { className?: string };\n\nconst DropdownMenuSeparator = React.forwardRef<HTMLDivElement, DropdownMenuSeparatorProps>(\n ({ className, ...props }, ref) => (\n <DropdownMenuSeparatorPrimitive\n ref={ref}\n className={cn('bg-berget-separator', className)}\n {...props}\n />\n ),\n);\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/* ------------------------------------------------------------------ */\n/* Shortcut */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuShortcutProps = React.ComponentProps<typeof DropdownMenuShortcutPrimitive>;\n\nconst DropdownMenuShortcut = ({ className, ...props }: DropdownMenuShortcutProps) => {\n return (\n <DropdownMenuShortcutPrimitive\n className={cn('text-berget-muted-foreground', className)}\n {...props}\n />\n );\n};\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/* ------------------------------------------------------------------ */\n/* Exports */\n/* ------------------------------------------------------------------ */\n\nexport {\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n};\n"],"mappings":";;;;;;AA2CA,MAAM,sBAAsB,MAAM,YAC/B,EAAE,SAAS,UAAU,GAAG,SAAS,QAChC,oBAACA,uBAAD;CAAmC;CAAK,QAAQ,cAAc,SAAS,QAAQ;CAAG,GAAI;CACnF,UAAA,UAAU,KAAA,IAAY;AACK,CAAA,CAElC;AACA,oBAAoB,cAAc;AAgBlC,MAAM,yBAAyB,MAAM,YAClC,EAAE,WAAW,OAAO,SAAS,UAAU,GAAG,SAAS,QAClD,oBAACC,0BAAD;CACO;CACL,WAAW,GAET,uCACA,SAAS,QACT,SACF;CACA,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACQ,CAAA,CAErC;AACA,uBAAuB,cAAc;AAQrC,MAAM,yBAAyB,MAAM,YAClC,EAAE,WAAW,GAAG,SAAS,QACxB,oBAACC,0BAAD;CACO;CACL,WAAW,GACT;;;WAIA,SACF;CACA,GAAI;AACL,CAAA,CAEL;AACA,uBAAuB,cAAc;AAQrC,MAAM,sBAAsB,MAAM,YAC/B,EAAE,WAAW,GAAG,SAAS,QACxB,oBAACC,uBAAD;CACO;CACL,WAAW,GACT;;;WAIA,SACF;CACA,GAAI;AACL,CAAA,CAEL;AACA,oBAAoB,cAAc;AAkBlC,MAAM,mBAAmB,MAAM,YAC5B,EAAE,WAAW,OAAO,SAAS,UAAU,WAAW,GAAG,SAAS,QAC7D,oBAACC,oBAAD;CACO;CACL,OAAO;CACP,WAAW,GAET,uCACA,SAAS,QACT,SACF;CACA,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACE,CAAA,CAE/B;AACA,iBAAiB,cAAc;AAiB/B,MAAM,2BAA2B,MAAM,YACpC,EAAE,WAAW,UAAU,SAAS,WAAW,GAAG,SAAS,QACtD,oBAACC,4BAAD;CACO;CACL,OAAO;CACP,WAAW,GAAG,qBAAqB,SAAS;CAC5C,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACU,CAAA,CAEvC;AACA,yBAAyB,cAAc;AAiBvC,MAAM,wBAAwB,MAAM,YACjC,EAAE,WAAW,UAAU,SAAS,WAAW,GAAG,SAAS,QACtD,oBAACC,yBAAD;CACO;CACL,OAAO;CACP,WAAW,GAAG,qBAAqB,SAAS;CAC5C,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACO,CAAA,CAEpC;AACA,sBAAsB,cAAc;AAgBpC,MAAM,oBAAoB,MAAM,YAC7B,EAAE,WAAW,OAAO,SAAS,UAAU,GAAG,SAAS,QAClD,oBAACC,qBAAD;CACO;CACL,WAAW,GACT,4DACA,SAAS,QACT,SACF;CACA,QAAQ,cAAc,SAAS,QAAQ;CACvC,GAAI;CAEH,UAAA,UAAU,KAAA,IAAY;AACG,CAAA,CAEhC;AACA,kBAAkB,cAAc;AAWhC,MAAM,wBAAwB,MAAM,YACjC,EAAE,WAAW,GAAG,SAAS,QACxB,oBAACC,yBAAD;CACO;CACL,WAAW,GAAG,uBAAuB,SAAS;CAC9C,GAAI;AACL,CAAA,CAEL;AACA,sBAAsB,cAAc;AAQpC,MAAM,wBAAwB,EAAE,WAAW,GAAG,YAAuC;CACnF,OACE,oBAACC,wBAAD;EACE,WAAW,GAAG,gCAAgC,SAAS;EACvD,GAAI;CACL,CAAA;AAEL;AACA,qBAAqB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.cjs","names":["cva","React","useRender","mergeProps","cn"],"sources":["../../../src/components/grid/Grid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { useRender } from '@base-ui/react/use-render';\nimport { cn } from '../../lib/utils';\n\nconst gridVariants = cva('grid', {\n variants: {\n align: {\n start: 'items-start',\n center: 'items-center',\n end: 'items-end',\n stretch: 'items-stretch',\n },\n justify: {\n start: 'justify-start',\n center: 'justify-center',\n end: 'justify-end',\n between: 'justify-between',\n around: 'justify-around',\n evenly: 'justify-evenly',\n },\n },\n defaultVariants: {\n align: 'stretch',\n justify: 'start',\n },\n});\n\nexport type SpacingScale =\n | 0\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6\n | 8\n | 10\n | 12\n | 16\n | 20\n | 24\n | 32\n | 40\n | 48\n | 56\n | 64\n | 72\n | 80\n | 96;\n\nexport type GridColsScale = 1 | 2 | 3 | 4 | 6 | 12;\n\nexport type GridRowsScale = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport interface GridProps\n extends useRender.ComponentProps<'div'>, VariantProps<typeof gridVariants> {\n children?: React.ReactNode;\n cols?: GridColsScale;\n rows?: GridRowsScale;\n gap?: SpacingScale;\n gapX?: SpacingScale;\n gapY?: SpacingScale;\n /** Render as a different element/component
|
|
1
|
+
{"version":3,"file":"Grid.cjs","names":["cva","React","useRender","mergeProps","cn"],"sources":["../../../src/components/grid/Grid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { useRender } from '@base-ui/react/use-render';\nimport { cn } from '../../lib/utils';\n\nconst gridVariants = cva('grid', {\n variants: {\n align: {\n start: 'items-start',\n center: 'items-center',\n end: 'items-end',\n stretch: 'items-stretch',\n },\n justify: {\n start: 'justify-start',\n center: 'justify-center',\n end: 'justify-end',\n between: 'justify-between',\n around: 'justify-around',\n evenly: 'justify-evenly',\n },\n },\n defaultVariants: {\n align: 'stretch',\n justify: 'start',\n },\n});\n\nexport type SpacingScale =\n | 0\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6\n | 8\n | 10\n | 12\n | 16\n | 20\n | 24\n | 32\n | 40\n | 48\n | 56\n | 64\n | 72\n | 80\n | 96;\n\nexport type GridColsScale = 1 | 2 | 3 | 4 | 6 | 12;\n\nexport type GridRowsScale = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport interface GridProps\n extends useRender.ComponentProps<'div'>, VariantProps<typeof gridVariants> {\n children?: React.ReactNode;\n cols?: GridColsScale;\n rows?: GridRowsScale;\n gap?: SpacingScale;\n gapX?: SpacingScale;\n gapY?: SpacingScale;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n}\n\nconst Grid = React.forwardRef<HTMLElement, GridProps>(\n (\n { className, align, justify, cols, rows, gap, gapX, gapY, asChild = false, children, ...props },\n ref,\n ) => {\n return useRender({\n ref,\n defaultTagName: 'div',\n render: asChild ? (children as React.ReactElement) : undefined,\n props: mergeProps<'div'>(\n {\n className: cn(\n gridVariants({ align, justify }),\n cols !== undefined &&\n `\n grid-cols-${cols}\n `,\n rows !== undefined &&\n `\n grid-rows-${rows}\n `,\n gap !== undefined &&\n `\n gap-${gap}\n `,\n gapX !== undefined &&\n `\n gap-x-${gapX}\n `,\n gapY !== undefined &&\n `\n gap-y-${gapY}\n `,\n className,\n ),\n children: asChild ? undefined : children,\n } as React.ComponentProps<'div'>,\n props,\n ),\n });\n },\n);\nGrid.displayName = 'Grid';\n\nexport { Grid, gridVariants };\n"],"mappings":";;;;;;;;;AAQA,MAAM,gBAAA,GAAeA,yBAAAA,IAAAA,CAAI,QAAQ;CAC/B,UAAU;EACR,OAAO;GACL,OAAO;GACP,QAAQ;GACR,KAAK;GACL,SAAS;EACX;EACA,SAAS;GACP,OAAO;GACP,QAAQ;GACR,KAAK;GACL,SAAS;GACT,QAAQ;GACR,QAAQ;EACV;CACF;CACA,iBAAiB;EACf,OAAO;EACP,SAAS;CACX;AACF,CAAC;AAyCD,MAAM,OAAOC,MAAM,YAEf,EAAE,WAAW,OAAO,SAAS,MAAM,MAAM,KAAK,MAAM,MAAM,UAAU,OAAO,UAAU,GAAG,SACxF,QACG;CACH,QAAA,GAAOC,0BAAAA,UAAAA,CAAU;EACf;EACA,gBAAgB;EAChB,QAAQ,UAAW,WAAkC,KAAA;EACrD,QAAA,GAAOC,2BAAAA,WAAAA,CACL;GACE,WAAWC,cAAAA,GACT,aAAa;IAAE;IAAO;GAAQ,CAAC,GAC/B,SAAS,KAAA,KACP;4BACc,KAAK;iBAErB,SAAS,KAAA,KACP;4BACc,KAAK;iBAErB,QAAQ,KAAA,KACN;sBACQ,IAAI;iBAEd,SAAS,KAAA,KACP;wBACU,KAAK;iBAEjB,SAAS,KAAA,KACP;wBACU,KAAK;iBAEjB,SACF;GACA,UAAU,UAAU,KAAA,IAAY;EAClC,GACA,KACF;CACF,CAAC;AACH,CACF;AACA,KAAK,cAAc"}
|
|
@@ -3,8 +3,8 @@ import { VariantProps } from "class-variance-authority";
|
|
|
3
3
|
import { useRender } from "@base-ui/react/use-render";
|
|
4
4
|
//#region src/components/grid/Grid.d.ts
|
|
5
5
|
declare const gridVariants: (props?: ({
|
|
6
|
-
align?: "
|
|
7
|
-
justify?: "
|
|
6
|
+
align?: "end" | "start" | "center" | "stretch" | null | undefined;
|
|
7
|
+
justify?: "end" | "start" | "center" | "between" | "around" | "evenly" | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
9
|
export type SpacingScale = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96;
|
|
10
10
|
export type GridColsScale = 1 | 2 | 3 | 4 | 6 | 12;
|
|
@@ -16,7 +16,7 @@ export interface GridProps extends useRender.ComponentProps<'div'>, VariantProps
|
|
|
16
16
|
gap?: SpacingScale;
|
|
17
17
|
gapX?: SpacingScale;
|
|
18
18
|
gapY?: SpacingScale;
|
|
19
|
-
/** Render as a different element/component
|
|
19
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
20
20
|
asChild?: boolean;
|
|
21
21
|
}
|
|
22
22
|
declare const Grid: React.ForwardRefExoticComponent<Omit<GridProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -3,8 +3,8 @@ import { VariantProps } from "class-variance-authority";
|
|
|
3
3
|
import { useRender } from "@base-ui/react/use-render";
|
|
4
4
|
//#region src/components/grid/Grid.d.ts
|
|
5
5
|
declare const gridVariants: (props?: ({
|
|
6
|
-
align?: "
|
|
7
|
-
justify?: "
|
|
6
|
+
align?: "end" | "start" | "center" | "stretch" | null | undefined;
|
|
7
|
+
justify?: "end" | "start" | "center" | "between" | "around" | "evenly" | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
9
|
export type SpacingScale = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 96;
|
|
10
10
|
export type GridColsScale = 1 | 2 | 3 | 4 | 6 | 12;
|
|
@@ -16,7 +16,7 @@ export interface GridProps extends useRender.ComponentProps<'div'>, VariantProps
|
|
|
16
16
|
gap?: SpacingScale;
|
|
17
17
|
gapX?: SpacingScale;
|
|
18
18
|
gapY?: SpacingScale;
|
|
19
|
-
/** Render as a different element/component
|
|
19
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
20
20
|
asChild?: boolean;
|
|
21
21
|
}
|
|
22
22
|
declare const Grid: React.ForwardRefExoticComponent<Omit<GridProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.mjs","names":[],"sources":["../../../src/components/grid/Grid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { useRender } from '@base-ui/react/use-render';\nimport { cn } from '../../lib/utils';\n\nconst gridVariants = cva('grid', {\n variants: {\n align: {\n start: 'items-start',\n center: 'items-center',\n end: 'items-end',\n stretch: 'items-stretch',\n },\n justify: {\n start: 'justify-start',\n center: 'justify-center',\n end: 'justify-end',\n between: 'justify-between',\n around: 'justify-around',\n evenly: 'justify-evenly',\n },\n },\n defaultVariants: {\n align: 'stretch',\n justify: 'start',\n },\n});\n\nexport type SpacingScale =\n | 0\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6\n | 8\n | 10\n | 12\n | 16\n | 20\n | 24\n | 32\n | 40\n | 48\n | 56\n | 64\n | 72\n | 80\n | 96;\n\nexport type GridColsScale = 1 | 2 | 3 | 4 | 6 | 12;\n\nexport type GridRowsScale = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport interface GridProps\n extends useRender.ComponentProps<'div'>, VariantProps<typeof gridVariants> {\n children?: React.ReactNode;\n cols?: GridColsScale;\n rows?: GridRowsScale;\n gap?: SpacingScale;\n gapX?: SpacingScale;\n gapY?: SpacingScale;\n /** Render as a different element/component
|
|
1
|
+
{"version":3,"file":"Grid.mjs","names":[],"sources":["../../../src/components/grid/Grid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { useRender } from '@base-ui/react/use-render';\nimport { cn } from '../../lib/utils';\n\nconst gridVariants = cva('grid', {\n variants: {\n align: {\n start: 'items-start',\n center: 'items-center',\n end: 'items-end',\n stretch: 'items-stretch',\n },\n justify: {\n start: 'justify-start',\n center: 'justify-center',\n end: 'justify-end',\n between: 'justify-between',\n around: 'justify-around',\n evenly: 'justify-evenly',\n },\n },\n defaultVariants: {\n align: 'stretch',\n justify: 'start',\n },\n});\n\nexport type SpacingScale =\n | 0\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6\n | 8\n | 10\n | 12\n | 16\n | 20\n | 24\n | 32\n | 40\n | 48\n | 56\n | 64\n | 72\n | 80\n | 96;\n\nexport type GridColsScale = 1 | 2 | 3 | 4 | 6 | 12;\n\nexport type GridRowsScale = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport interface GridProps\n extends useRender.ComponentProps<'div'>, VariantProps<typeof gridVariants> {\n children?: React.ReactNode;\n cols?: GridColsScale;\n rows?: GridRowsScale;\n gap?: SpacingScale;\n gapX?: SpacingScale;\n gapY?: SpacingScale;\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n}\n\nconst Grid = React.forwardRef<HTMLElement, GridProps>(\n (\n { className, align, justify, cols, rows, gap, gapX, gapY, asChild = false, children, ...props },\n ref,\n ) => {\n return useRender({\n ref,\n defaultTagName: 'div',\n render: asChild ? (children as React.ReactElement) : undefined,\n props: mergeProps<'div'>(\n {\n className: cn(\n gridVariants({ align, justify }),\n cols !== undefined &&\n `\n grid-cols-${cols}\n `,\n rows !== undefined &&\n `\n grid-rows-${rows}\n `,\n gap !== undefined &&\n `\n gap-${gap}\n `,\n gapX !== undefined &&\n `\n gap-x-${gapX}\n `,\n gapY !== undefined &&\n `\n gap-y-${gapY}\n `,\n className,\n ),\n children: asChild ? undefined : children,\n } as React.ComponentProps<'div'>,\n props,\n ),\n });\n },\n);\nGrid.displayName = 'Grid';\n\nexport { Grid, gridVariants };\n"],"mappings":";;;;;;;AAQA,MAAM,eAAe,IAAI,QAAQ;CAC/B,UAAU;EACR,OAAO;GACL,OAAO;GACP,QAAQ;GACR,KAAK;GACL,SAAS;EACX;EACA,SAAS;GACP,OAAO;GACP,QAAQ;GACR,KAAK;GACL,SAAS;GACT,QAAQ;GACR,QAAQ;EACV;CACF;CACA,iBAAiB;EACf,OAAO;EACP,SAAS;CACX;AACF,CAAC;AAyCD,MAAM,OAAO,MAAM,YAEf,EAAE,WAAW,OAAO,SAAS,MAAM,MAAM,KAAK,MAAM,MAAM,UAAU,OAAO,UAAU,GAAG,SACxF,QACG;CACH,OAAO,UAAU;EACf;EACA,gBAAgB;EAChB,QAAQ,UAAW,WAAkC,KAAA;EACrD,OAAO,WACL;GACE,WAAW,GACT,aAAa;IAAE;IAAO;GAAQ,CAAC,GAC/B,SAAS,KAAA,KACP;4BACc,KAAK;iBAErB,SAAS,KAAA,KACP;4BACc,KAAK;iBAErB,QAAQ,KAAA,KACN;sBACQ,IAAI;iBAEd,SAAS,KAAA,KACP;wBACU,KAAK;iBAEjB,SAAS,KAAA,KACP;wBACU,KAAK;iBAEjB,SACF;GACA,UAAU,UAAU,KAAA,IAAY;EAClC,GACA,KACF;CACF,CAAC;AACH,CACF;AACA,KAAK,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.cjs","names":["ItemPrimitive","cn","React","ItemMediaPrimitive","ItemTitlePrimitive","ItemDescriptionPrimitive","ItemSeparatorPrimitive"],"sources":["../../../src/components/item/Item.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../lib/utils';\nimport {\n Item as ItemPrimitive,\n ItemGroup,\n ItemSeparator as ItemSeparatorPrimitive,\n ItemMedia as ItemMediaPrimitive,\n ItemContent,\n ItemTitle as ItemTitlePrimitive,\n ItemDescription as ItemDescriptionPrimitive,\n ItemActions,\n ItemHeader,\n ItemFooter,\n} from '@/primitives/item';\nimport type { VariantProps } from 'class-variance-authority';\n\nexport interface ItemProps extends React.ComponentProps<typeof ItemPrimitive> {\n variant?: VariantProps<typeof ItemPrimitive>['variant'];\n size?: VariantProps<typeof ItemPrimitive>['size'];\n /** Render as a different element/component
|
|
1
|
+
{"version":3,"file":"Item.cjs","names":["ItemPrimitive","cn","React","ItemMediaPrimitive","ItemTitlePrimitive","ItemDescriptionPrimitive","ItemSeparatorPrimitive"],"sources":["../../../src/components/item/Item.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../lib/utils';\nimport {\n Item as ItemPrimitive,\n ItemGroup,\n ItemSeparator as ItemSeparatorPrimitive,\n ItemMedia as ItemMediaPrimitive,\n ItemContent,\n ItemTitle as ItemTitlePrimitive,\n ItemDescription as ItemDescriptionPrimitive,\n ItemActions,\n ItemHeader,\n ItemFooter,\n} from '@/primitives/item';\nimport type { VariantProps } from 'class-variance-authority';\n\nexport interface ItemProps extends React.ComponentProps<typeof ItemPrimitive> {\n variant?: VariantProps<typeof ItemPrimitive>['variant'];\n size?: VariantProps<typeof ItemPrimitive>['size'];\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n}\n\nexport function Item({ className, asChild, children, ...props }: ItemProps) {\n return (\n <ItemPrimitive\n render={asChild ? (children as React.ReactElement) : undefined}\n className={cn(\n /* Variant colours — override primitive defaults */\n 'data-[variant=outline]:border-berget-item-outline-border',\n 'data-[variant=muted]:bg-berget-item-muted-bg',\n 'data-[variant=muted]:text-berget-item-muted-fg',\n /* Hover / focus */\n '[&_a]:hover:bg-berget-item-link-hover-surface',\n `\n focus-visible:border-berget-item-focus-ring\n focus-visible:ring-berget-item-focus-ring/50\n `,\n className,\n )}\n {...props}\n >\n {asChild ? undefined : children}\n </ItemPrimitive>\n );\n}\n\n/** Re-export unchanged sub-components. */\nexport { ItemGroup, ItemContent, ItemActions, ItemHeader, ItemFooter };\n\n/** ItemMedia — override icon background. */\nexport const ItemMedia = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<typeof ItemMediaPrimitive>\n>(({ className, ...props }, ref) => {\n return (\n <ItemMediaPrimitive\n ref={ref}\n className={cn('data-[variant=icon]:bg-berget-item-media-icon-bg', className)}\n {...props}\n />\n );\n});\nItemMedia.displayName = 'ItemMedia';\n\n/** ItemTitle — override to use semantic foreground. */\nexport const ItemTitle = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<typeof ItemTitlePrimitive>\n>(({ className, ...props }, ref) => {\n return (\n <ItemTitlePrimitive\n ref={ref}\n className={cn('text-berget-item-default-fg', className)}\n {...props}\n />\n );\n});\nItemTitle.displayName = 'ItemTitle';\n\n/** ItemDescription — override muted text colour. */\nexport const ItemDescription = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<typeof ItemDescriptionPrimitive>\n>(({ className, ...props }, ref) => {\n return (\n <ItemDescriptionPrimitive\n ref={ref}\n className={cn('text-berget-item-description-fg', className)}\n {...props}\n />\n );\n});\nItemDescription.displayName = 'ItemDescription';\n\n/** ItemSeparator — override colour. */\nexport const ItemSeparator = React.forwardRef<\n React.ComponentRef<typeof ItemSeparatorPrimitive>,\n React.ComponentProps<typeof ItemSeparatorPrimitive>\n>(({ className, ...props }, ref) => {\n return (\n <ItemSeparatorPrimitive\n ref={ref}\n className={cn('bg-berget-item-separator', className)}\n {...props}\n />\n );\n});\nItemSeparator.displayName = 'ItemSeparator';\n"],"mappings":";;;;;;;;AAyBA,SAAgB,KAAK,EAAE,WAAW,SAAS,UAAU,GAAG,SAAoB;CAC1E,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,MAAD;EACE,QAAQ,UAAW,WAAkC,KAAA;EACrD,WAAWC,cAAAA,GAET,4DACA,gDACA,kDAEA,iDACA;;;WAIA,SACF;EACA,GAAI;EAEH,UAAA,UAAU,KAAA,IAAY;CACV,CAAA;AAEnB;;AAMA,MAAa,YAAYC,MAAM,YAG5B,EAAE,WAAW,GAAG,SAAS,QAAQ;CAClC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,WAAD;EACO;EACL,WAAWF,cAAAA,GAAG,oDAAoD,SAAS;EAC3E,GAAI;CACL,CAAA;AAEL,CAAC;AACD,UAAU,cAAc;;AAGxB,MAAa,YAAYC,MAAM,YAG5B,EAAE,WAAW,GAAG,SAAS,QAAQ;CAClC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACE,aAAAA,WAAD;EACO;EACL,WAAWH,cAAAA,GAAG,+BAA+B,SAAS;EACtD,GAAI;CACL,CAAA;AAEL,CAAC;AACD,UAAU,cAAc;;AAGxB,MAAa,kBAAkBC,MAAM,YAGlC,EAAE,WAAW,GAAG,SAAS,QAAQ;CAClC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACG,aAAAA,iBAAD;EACO;EACL,WAAWJ,cAAAA,GAAG,mCAAmC,SAAS;EAC1D,GAAI;CACL,CAAA;AAEL,CAAC;AACD,gBAAgB,cAAc;;AAG9B,MAAa,gBAAgBC,MAAM,YAGhC,EAAE,WAAW,GAAG,SAAS,QAAQ;CAClC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACI,aAAAA,eAAD;EACO;EACL,WAAWL,cAAAA,GAAG,4BAA4B,SAAS;EACnD,GAAI;CACL,CAAA;AAEL,CAAC;AACD,cAAc,cAAc"}
|
|
@@ -5,7 +5,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
5
5
|
export interface ItemProps extends React.ComponentProps<typeof Item$1> {
|
|
6
6
|
variant?: VariantProps<typeof Item$1>['variant'];
|
|
7
7
|
size?: VariantProps<typeof Item$1>['size'];
|
|
8
|
-
/** Render as a different element/component
|
|
8
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
9
9
|
asChild?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare function Item({ className, asChild, children, ...props }: ItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
5
5
|
export interface ItemProps extends React.ComponentProps<typeof Item$1> {
|
|
6
6
|
variant?: VariantProps<typeof Item$1>['variant'];
|
|
7
7
|
size?: VariantProps<typeof Item$1>['size'];
|
|
8
|
-
/** Render as a different element/component
|
|
8
|
+
/** Render as a different element/component by merging props onto the child. */
|
|
9
9
|
asChild?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare function Item({ className, asChild, children, ...props }: ItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.mjs","names":["ItemPrimitive","ItemMediaPrimitive","ItemTitlePrimitive","ItemDescriptionPrimitive","ItemSeparatorPrimitive"],"sources":["../../../src/components/item/Item.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../lib/utils';\nimport {\n Item as ItemPrimitive,\n ItemGroup,\n ItemSeparator as ItemSeparatorPrimitive,\n ItemMedia as ItemMediaPrimitive,\n ItemContent,\n ItemTitle as ItemTitlePrimitive,\n ItemDescription as ItemDescriptionPrimitive,\n ItemActions,\n ItemHeader,\n ItemFooter,\n} from '@/primitives/item';\nimport type { VariantProps } from 'class-variance-authority';\n\nexport interface ItemProps extends React.ComponentProps<typeof ItemPrimitive> {\n variant?: VariantProps<typeof ItemPrimitive>['variant'];\n size?: VariantProps<typeof ItemPrimitive>['size'];\n /** Render as a different element/component
|
|
1
|
+
{"version":3,"file":"Item.mjs","names":["ItemPrimitive","ItemMediaPrimitive","ItemTitlePrimitive","ItemDescriptionPrimitive","ItemSeparatorPrimitive"],"sources":["../../../src/components/item/Item.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../lib/utils';\nimport {\n Item as ItemPrimitive,\n ItemGroup,\n ItemSeparator as ItemSeparatorPrimitive,\n ItemMedia as ItemMediaPrimitive,\n ItemContent,\n ItemTitle as ItemTitlePrimitive,\n ItemDescription as ItemDescriptionPrimitive,\n ItemActions,\n ItemHeader,\n ItemFooter,\n} from '@/primitives/item';\nimport type { VariantProps } from 'class-variance-authority';\n\nexport interface ItemProps extends React.ComponentProps<typeof ItemPrimitive> {\n variant?: VariantProps<typeof ItemPrimitive>['variant'];\n size?: VariantProps<typeof ItemPrimitive>['size'];\n /** Render as a different element/component by merging props onto the child. */\n asChild?: boolean;\n}\n\nexport function Item({ className, asChild, children, ...props }: ItemProps) {\n return (\n <ItemPrimitive\n render={asChild ? (children as React.ReactElement) : undefined}\n className={cn(\n /* Variant colours — override primitive defaults */\n 'data-[variant=outline]:border-berget-item-outline-border',\n 'data-[variant=muted]:bg-berget-item-muted-bg',\n 'data-[variant=muted]:text-berget-item-muted-fg',\n /* Hover / focus */\n '[&_a]:hover:bg-berget-item-link-hover-surface',\n `\n focus-visible:border-berget-item-focus-ring\n focus-visible:ring-berget-item-focus-ring/50\n `,\n className,\n )}\n {...props}\n >\n {asChild ? undefined : children}\n </ItemPrimitive>\n );\n}\n\n/** Re-export unchanged sub-components. */\nexport { ItemGroup, ItemContent, ItemActions, ItemHeader, ItemFooter };\n\n/** ItemMedia — override icon background. */\nexport const ItemMedia = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<typeof ItemMediaPrimitive>\n>(({ className, ...props }, ref) => {\n return (\n <ItemMediaPrimitive\n ref={ref}\n className={cn('data-[variant=icon]:bg-berget-item-media-icon-bg', className)}\n {...props}\n />\n );\n});\nItemMedia.displayName = 'ItemMedia';\n\n/** ItemTitle — override to use semantic foreground. */\nexport const ItemTitle = React.forwardRef<\n HTMLDivElement,\n React.ComponentProps<typeof ItemTitlePrimitive>\n>(({ className, ...props }, ref) => {\n return (\n <ItemTitlePrimitive\n ref={ref}\n className={cn('text-berget-item-default-fg', className)}\n {...props}\n />\n );\n});\nItemTitle.displayName = 'ItemTitle';\n\n/** ItemDescription — override muted text colour. */\nexport const ItemDescription = React.forwardRef<\n HTMLParagraphElement,\n React.ComponentProps<typeof ItemDescriptionPrimitive>\n>(({ className, ...props }, ref) => {\n return (\n <ItemDescriptionPrimitive\n ref={ref}\n className={cn('text-berget-item-description-fg', className)}\n {...props}\n />\n );\n});\nItemDescription.displayName = 'ItemDescription';\n\n/** ItemSeparator — override colour. */\nexport const ItemSeparator = React.forwardRef<\n React.ComponentRef<typeof ItemSeparatorPrimitive>,\n React.ComponentProps<typeof ItemSeparatorPrimitive>\n>(({ className, ...props }, ref) => {\n return (\n <ItemSeparatorPrimitive\n ref={ref}\n className={cn('bg-berget-item-separator', className)}\n {...props}\n />\n );\n});\nItemSeparator.displayName = 'ItemSeparator';\n"],"mappings":";;;;;;AAyBA,SAAgB,KAAK,EAAE,WAAW,SAAS,UAAU,GAAG,SAAoB;CAC1E,OACE,oBAACA,QAAD;EACE,QAAQ,UAAW,WAAkC,KAAA;EACrD,WAAW,GAET,4DACA,gDACA,kDAEA,iDACA;;;WAIA,SACF;EACA,GAAI;EAEH,UAAA,UAAU,KAAA,IAAY;CACV,CAAA;AAEnB;;AAMA,MAAa,YAAY,MAAM,YAG5B,EAAE,WAAW,GAAG,SAAS,QAAQ;CAClC,OACE,oBAACC,aAAD;EACO;EACL,WAAW,GAAG,oDAAoD,SAAS;EAC3E,GAAI;CACL,CAAA;AAEL,CAAC;AACD,UAAU,cAAc;;AAGxB,MAAa,YAAY,MAAM,YAG5B,EAAE,WAAW,GAAG,SAAS,QAAQ;CAClC,OACE,oBAACC,aAAD;EACO;EACL,WAAW,GAAG,+BAA+B,SAAS;EACtD,GAAI;CACL,CAAA;AAEL,CAAC;AACD,UAAU,cAAc;;AAGxB,MAAa,kBAAkB,MAAM,YAGlC,EAAE,WAAW,GAAG,SAAS,QAAQ;CAClC,OACE,oBAACC,mBAAD;EACO;EACL,WAAW,GAAG,mCAAmC,SAAS;EAC1D,GAAI;CACL,CAAA;AAEL,CAAC;AACD,gBAAgB,cAAc;;AAG9B,MAAa,gBAAgB,MAAM,YAGhC,EAAE,WAAW,GAAG,SAAS,QAAQ;CAClC,OACE,oBAACC,iBAAD;EACO;EACL,WAAW,GAAG,4BAA4B,SAAS;EACnD,GAAI;CACL,CAAA;AAEL,CAAC;AACD,cAAc,cAAc"}
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
//#region src/components/typography/Typography.d.ts
|
|
4
4
|
declare const typographyVariants: (props?: ({
|
|
5
|
-
variant?: "
|
|
5
|
+
variant?: "caption" | "body" | "code" | "h1" | "h2" | "h3" | "h4" | "h5" | "small" | "hero" | "large" | "xs" | "mono" | null | undefined;
|
|
6
6
|
color?: "default" | "muted" | "dim" | "primary" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
export interface TypographyProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, VariantProps<typeof typographyVariants> {
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
//#region src/components/typography/Typography.d.ts
|
|
4
4
|
declare const typographyVariants: (props?: ({
|
|
5
|
-
variant?: "
|
|
5
|
+
variant?: "caption" | "body" | "code" | "h1" | "h2" | "h3" | "h4" | "h5" | "small" | "hero" | "large" | "xs" | "mono" | null | undefined;
|
|
6
6
|
color?: "default" | "muted" | "dim" | "primary" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
export interface TypographyProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, VariantProps<typeof typographyVariants> {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_highlighter = require("../lib/highlighter.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
react = require_runtime.__toESM(react, 1);
|
|
5
|
+
//#region src/hooks/use-highlighted-code.ts
|
|
6
|
+
function useHighlightedCode(value, language) {
|
|
7
|
+
const code = value.endsWith("\n") ? value.slice(0, -1) : value;
|
|
8
|
+
const [loaded, setLoaded] = react.useState(null);
|
|
9
|
+
const highlighter = loaded?.language === language ? loaded.highlighter : null;
|
|
10
|
+
react.useEffect(() => {
|
|
11
|
+
let cancelled = false;
|
|
12
|
+
require_highlighter.loadHighlighter(language).then((next) => {
|
|
13
|
+
if (!cancelled) setLoaded({
|
|
14
|
+
language,
|
|
15
|
+
highlighter: next
|
|
16
|
+
});
|
|
17
|
+
}).catch(() => {});
|
|
18
|
+
return () => {
|
|
19
|
+
cancelled = true;
|
|
20
|
+
};
|
|
21
|
+
}, [language]);
|
|
22
|
+
const [done, setDone] = react.useState({
|
|
23
|
+
highlighter: null,
|
|
24
|
+
text: "",
|
|
25
|
+
lines: []
|
|
26
|
+
});
|
|
27
|
+
let next = done;
|
|
28
|
+
if (next.highlighter !== highlighter || !code.startsWith(next.text)) next = {
|
|
29
|
+
highlighter,
|
|
30
|
+
text: "",
|
|
31
|
+
lines: []
|
|
32
|
+
};
|
|
33
|
+
const end = code.lastIndexOf("\n") + 1;
|
|
34
|
+
if (highlighter && end > next.text.length) {
|
|
35
|
+
const result = highlighter.highlight(code.slice(next.text.length, end - 1), next.state);
|
|
36
|
+
next = {
|
|
37
|
+
highlighter,
|
|
38
|
+
text: code.slice(0, end),
|
|
39
|
+
lines: [...next.lines, ...result.lines],
|
|
40
|
+
state: result.state
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (next !== done) setDone(next);
|
|
44
|
+
const tail = code.slice(end);
|
|
45
|
+
return react.useMemo(() => {
|
|
46
|
+
if (!highlighter) return code.split("\n");
|
|
47
|
+
return [...next.lines, highlighter.highlight(tail, next.state).lines[0]];
|
|
48
|
+
}, [
|
|
49
|
+
code,
|
|
50
|
+
highlighter,
|
|
51
|
+
next,
|
|
52
|
+
tail
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
exports.useHighlightedCode = useHighlightedCode;
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=use-highlighted-code.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-highlighted-code.cjs","names":["React"],"sources":["../../src/hooks/use-highlighted-code.ts"],"sourcesContent":["// BERGET: upstream uses an intentional mutate-during-render streaming pattern\n// (see the init/render loop below); the React Compiler skips this file, which\n// is safe and expected. Keep this minimal when replaying upstream updates.\n/* eslint-disable react-hooks/preserve-manual-memoization */\nimport * as React from 'react';\n\nimport { loadHighlighter } from '@/lib/highlighter';\n\nexport function useHighlightedCode(value: string, language: string) {\n // A trailing newline would render as an extra empty line.\n const code = value.endsWith('\\n') ? value.slice(0, -1) : value;\n const [loaded, setLoaded] = React.useState<{\n language: string;\n highlighter: Awaited<ReturnType<typeof loadHighlighter>>;\n } | null>(null);\n const highlighter = loaded?.language === language ? loaded.highlighter : null;\n\n React.useEffect(() => {\n let cancelled = false;\n\n loadHighlighter(language)\n .then((next) => {\n if (!cancelled) {\n setLoaded({ language, highlighter: next });\n }\n })\n .catch(() => {});\n\n return () => {\n cancelled = true;\n };\n }, [language]);\n\n // The complete lines, highlighted. While the code streams, only the new\n // lines are tokenized, starting from the grammar state of the last one.\n const [done, setDone] = React.useState<{\n highlighter: typeof highlighter;\n text: string;\n lines: React.ReactNode[];\n state?: Parameters<NonNullable<typeof highlighter>['highlight']>[1];\n }>({ highlighter: null, text: '', lines: [] });\n\n let next = done;\n\n if (next.highlighter !== highlighter || !code.startsWith(next.text)) {\n next = { highlighter, text: '', lines: [] };\n }\n\n const end = code.lastIndexOf('\\n') + 1;\n\n if (highlighter && end > next.text.length) {\n const result = highlighter.highlight(code.slice(next.text.length, end - 1), next.state);\n\n next = {\n highlighter,\n text: code.slice(0, end),\n lines: [...next.lines, ...result.lines],\n state: result.state,\n };\n }\n\n if (next !== done) {\n setDone(next);\n }\n\n // The last line is still being written, so it is tokenized on every render.\n const tail = code.slice(end);\n\n return React.useMemo(() => {\n if (!highlighter) {\n return code.split('\\n');\n }\n\n return [...next.lines, highlighter.highlight(tail, next.state).lines[0]];\n }, [code, highlighter, next, tail]);\n}\n"],"mappings":";;;;;AAQA,SAAgB,mBAAmB,OAAe,UAAkB;CAElE,MAAM,OAAO,MAAM,SAAS,IAAI,IAAI,MAAM,MAAM,GAAG,EAAE,IAAI;CACzD,MAAM,CAAC,QAAQ,aAAaA,MAAM,SAGxB,IAAI;CACd,MAAM,cAAc,QAAQ,aAAa,WAAW,OAAO,cAAc;CAEzE,MAAM,gBAAgB;EACpB,IAAI,YAAY;EAEhB,oBAAA,gBAAgB,QAAQ,CAAC,CACtB,MAAM,SAAS;GACd,IAAI,CAAC,WACH,UAAU;IAAE;IAAU,aAAa;GAAK,CAAC;EAE7C,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EAEjB,aAAa;GACX,YAAY;EACd;CACF,GAAG,CAAC,QAAQ,CAAC;CAIb,MAAM,CAAC,MAAM,WAAWA,MAAM,SAK3B;EAAE,aAAa;EAAM,MAAM;EAAI,OAAO,CAAC;CAAE,CAAC;CAE7C,IAAI,OAAO;CAEX,IAAI,KAAK,gBAAgB,eAAe,CAAC,KAAK,WAAW,KAAK,IAAI,GAChE,OAAO;EAAE;EAAa,MAAM;EAAI,OAAO,CAAC;CAAE;CAG5C,MAAM,MAAM,KAAK,YAAY,IAAI,IAAI;CAErC,IAAI,eAAe,MAAM,KAAK,KAAK,QAAQ;EACzC,MAAM,SAAS,YAAY,UAAU,KAAK,MAAM,KAAK,KAAK,QAAQ,MAAM,CAAC,GAAG,KAAK,KAAK;EAEtF,OAAO;GACL;GACA,MAAM,KAAK,MAAM,GAAG,GAAG;GACvB,OAAO,CAAC,GAAG,KAAK,OAAO,GAAG,OAAO,KAAK;GACtC,OAAO,OAAO;EAChB;CACF;CAEA,IAAI,SAAS,MACX,QAAQ,IAAI;CAId,MAAM,OAAO,KAAK,MAAM,GAAG;CAE3B,OAAOA,MAAM,cAAc;EACzB,IAAI,CAAC,aACH,OAAO,KAAK,MAAM,IAAI;EAGxB,OAAO,CAAC,GAAG,KAAK,OAAO,YAAY,UAAU,MAAM,KAAK,KAAK,CAAC,CAAC,MAAM,EAAE;CACzE,GAAG;EAAC;EAAM;EAAa;EAAM;CAAI,CAAC;AACpC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
//#region src/hooks/use-highlighted-code.d.ts
|
|
3
|
+
export declare function useHighlightedCode(value: string, language: string): (string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element[] | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined)[];
|
|
4
|
+
//#endregion
|
|
5
|
+
//# sourceMappingURL=use-highlighted-code.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-highlighted-code.d.cts","names":[],"sources":["../../src/hooks/use-highlighted-code.ts"],"mappings":";;wBAQgB,mBAAmB,eAAe,qFAAgB,IAAA,YAAA,MAAA,+BAAA,MAAA,8BAAA,SAAA,MAAA,aAAA,6CAAA,MAAA,cAAA,MAAA,+BAAA,MAAA,8BAAA,SAAA,MAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
//#region src/hooks/use-highlighted-code.d.ts
|
|
3
|
+
export declare function useHighlightedCode(value: string, language: string): (string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element[] | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined)[];
|
|
4
|
+
//#endregion
|
|
5
|
+
//# sourceMappingURL=use-highlighted-code.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-highlighted-code.d.mts","names":[],"sources":["../../src/hooks/use-highlighted-code.ts"],"mappings":";;wBAQgB,mBAAmB,eAAe,qFAAgB,IAAA,YAAA,MAAA,+BAAA,MAAA,8BAAA,SAAA,MAAA,aAAA,6CAAA,MAAA,cAAA,MAAA,+BAAA,MAAA,8BAAA,SAAA,MAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { loadHighlighter } from "../lib/highlighter.mjs";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region src/hooks/use-highlighted-code.ts
|
|
4
|
+
function useHighlightedCode(value, language) {
|
|
5
|
+
const code = value.endsWith("\n") ? value.slice(0, -1) : value;
|
|
6
|
+
const [loaded, setLoaded] = React.useState(null);
|
|
7
|
+
const highlighter = loaded?.language === language ? loaded.highlighter : null;
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
let cancelled = false;
|
|
10
|
+
loadHighlighter(language).then((next) => {
|
|
11
|
+
if (!cancelled) setLoaded({
|
|
12
|
+
language,
|
|
13
|
+
highlighter: next
|
|
14
|
+
});
|
|
15
|
+
}).catch(() => {});
|
|
16
|
+
return () => {
|
|
17
|
+
cancelled = true;
|
|
18
|
+
};
|
|
19
|
+
}, [language]);
|
|
20
|
+
const [done, setDone] = React.useState({
|
|
21
|
+
highlighter: null,
|
|
22
|
+
text: "",
|
|
23
|
+
lines: []
|
|
24
|
+
});
|
|
25
|
+
let next = done;
|
|
26
|
+
if (next.highlighter !== highlighter || !code.startsWith(next.text)) next = {
|
|
27
|
+
highlighter,
|
|
28
|
+
text: "",
|
|
29
|
+
lines: []
|
|
30
|
+
};
|
|
31
|
+
const end = code.lastIndexOf("\n") + 1;
|
|
32
|
+
if (highlighter && end > next.text.length) {
|
|
33
|
+
const result = highlighter.highlight(code.slice(next.text.length, end - 1), next.state);
|
|
34
|
+
next = {
|
|
35
|
+
highlighter,
|
|
36
|
+
text: code.slice(0, end),
|
|
37
|
+
lines: [...next.lines, ...result.lines],
|
|
38
|
+
state: result.state
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (next !== done) setDone(next);
|
|
42
|
+
const tail = code.slice(end);
|
|
43
|
+
return React.useMemo(() => {
|
|
44
|
+
if (!highlighter) return code.split("\n");
|
|
45
|
+
return [...next.lines, highlighter.highlight(tail, next.state).lines[0]];
|
|
46
|
+
}, [
|
|
47
|
+
code,
|
|
48
|
+
highlighter,
|
|
49
|
+
next,
|
|
50
|
+
tail
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { useHighlightedCode };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=use-highlighted-code.mjs.map
|