@studiocubics/components 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/Cards/Card/Card.js +1 -44
- package/dist/Cards/Card/Card.js.map +1 -1
- package/dist/Cards/Card/Card.module.css.js +1 -3
- package/dist/Cards/Card/Card.module.css.js.map +1 -1
- package/dist/Cards/CollectionItemCard/CollectionItemCard.js +1 -47
- package/dist/Cards/CollectionItemCard/CollectionItemCard.js.map +1 -1
- package/dist/Cards/CollectionItemCard/CollectionItemCard.module.css.js +1 -3
- package/dist/Cards/CollectionItemCard/CollectionItemCard.module.css.js.map +1 -1
- package/dist/Cards/CollectionItemCard/CollectionItemCardActions.js +1 -33
- package/dist/Cards/CollectionItemCard/CollectionItemCardActions.js.map +1 -1
- package/dist/Cards/GlassCard/GlassCard.js +1 -51
- package/dist/Cards/GlassCard/GlassCard.js.map +1 -1
- package/dist/Cards/GlassCard/GlassCard.module.css.js +1 -3
- package/dist/Cards/GlassCard/GlassCard.module.css.js.map +1 -1
- package/dist/Display/Accordion/Accordion.js +1 -27
- package/dist/Display/Accordion/Accordion.js.map +1 -1
- package/dist/Display/Accordion/Accordion.module.css.js +1 -3
- package/dist/Display/Accordion/Accordion.module.css.js.map +1 -1
- package/dist/Display/Accordion/AccordionItem.js +1 -55
- package/dist/Display/Accordion/AccordionItem.js.map +1 -1
- package/dist/Display/Chip/Chip.js +1 -42
- package/dist/Display/Chip/Chip.js.map +1 -1
- package/dist/Display/Chip/Chip.module.css.js +1 -3
- package/dist/Display/Chip/Chip.module.css.js.map +1 -1
- package/dist/Display/IdentityDisplay/IdentityDisplay.js +1 -35
- package/dist/Display/IdentityDisplay/IdentityDisplay.js.map +1 -1
- package/dist/Display/IdentityDisplay/IdentityDisplay.module.css.js +1 -3
- package/dist/Display/IdentityDisplay/IdentityDisplay.module.css.js.map +1 -1
- package/dist/Display/InputErrors/InputErrors.js +1 -24
- package/dist/Display/InputErrors/InputErrors.js.map +1 -1
- package/dist/Display/InputErrors/InputErrors.module.css.js +1 -3
- package/dist/Display/InputErrors/InputErrors.module.css.js.map +1 -1
- package/dist/Display/Kbd/Kbd.js +1 -18
- package/dist/Display/Kbd/Kbd.js.map +1 -1
- package/dist/Display/Kbd/Kbd.module.css.js +1 -3
- package/dist/Display/Kbd/Kbd.module.css.js.map +1 -1
- package/dist/Display/Kbd/buttonList.js +1 -197
- package/dist/Display/Kbd/buttonList.js.map +1 -1
- package/dist/Display/LabeledValue/LabeledValue.js +1 -10
- package/dist/Display/LabeledValue/LabeledValue.js.map +1 -1
- package/dist/Display/LabeledValue/LabeledValue.module.css.js +1 -3
- package/dist/Display/LabeledValue/LabeledValue.module.css.js.map +1 -1
- package/dist/Display/List/List.js +1 -95
- package/dist/Display/List/List.js.map +1 -1
- package/dist/Display/List/List.module.css.js +1 -3
- package/dist/Display/List/List.module.css.js.map +1 -1
- package/dist/Display/PasswordStrength/PasswordStrength.js +1 -16
- package/dist/Display/PasswordStrength/PasswordStrength.js.map +1 -1
- package/dist/Display/PasswordStrength/PasswordStrength.module.css.js +1 -3
- package/dist/Display/PasswordStrength/PasswordStrength.module.css.js.map +1 -1
- package/dist/Display/PasswordStrength/usePasswordStrength.js +1 -48
- package/dist/Display/PasswordStrength/usePasswordStrength.js.map +1 -1
- package/dist/Display/Skeleton/Skeleton.js +1 -10
- package/dist/Display/Skeleton/Skeleton.js.map +1 -1
- package/dist/Display/Skeleton/Skeleton.module.css.js +1 -3
- package/dist/Display/Skeleton/Skeleton.module.css.js.map +1 -1
- package/dist/Display/Toast/Toaster.js +1 -44
- package/dist/Display/Toast/Toaster.js.map +1 -1
- package/dist/Display/Toast/toast.js +1 -31
- package/dist/Display/Toast/toast.js.map +1 -1
- package/dist/Display/Tooltip/Tooltip.js +1 -44
- package/dist/Display/Tooltip/Tooltip.js.map +1 -1
- package/dist/Display/Tooltip/Tooltip.module.css.js +1 -3
- package/dist/Display/Tooltip/Tooltip.module.css.js.map +1 -1
- package/dist/Display/Tooltip/getArrowDirection.js +1 -47
- package/dist/Display/Tooltip/getArrowDirection.js.map +1 -1
- package/dist/Display/Tooltip/useTooltip.js +1 -47
- package/dist/Display/Tooltip/useTooltip.js.map +1 -1
- package/dist/Display/WIP/WIP.d.ts +5 -0
- package/dist/Forms/ConfirmationForm/ConfirmationForm.js +1 -11
- package/dist/Forms/ConfirmationForm/ConfirmationForm.js.map +1 -1
- package/dist/Forms/ConfirmationForm/ConfirmationForm.module.css.js +1 -3
- package/dist/Forms/ConfirmationForm/ConfirmationForm.module.css.js.map +1 -1
- package/dist/Inputs/Button/Button.js +1 -55
- package/dist/Inputs/Button/Button.js.map +1 -1
- package/dist/Inputs/Button/Button.module.css.js +1 -3
- package/dist/Inputs/Button/Button.module.css.js.map +1 -1
- package/dist/Inputs/Checkbox/Checkbox.js +1 -54
- package/dist/Inputs/Checkbox/Checkbox.js.map +1 -1
- package/dist/Inputs/Checkbox/Checkbox.module.css.js +1 -3
- package/dist/Inputs/Checkbox/Checkbox.module.css.js.map +1 -1
- package/dist/Inputs/Checkbox/CheckboxGroup/CheckboxGroup.js +1 -34
- package/dist/Inputs/Checkbox/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/dist/Inputs/Checkbox/CheckboxGroup/CheckboxGroup.module.css.js +1 -3
- package/dist/Inputs/Checkbox/CheckboxGroup/CheckboxGroup.module.css.js.map +1 -1
- package/dist/Inputs/Checkbox/CheckboxSelectAll.js +1 -18
- package/dist/Inputs/Checkbox/CheckboxSelectAll.js.map +1 -1
- package/dist/Inputs/PasswordInput/PasswordInput.js +1 -44
- package/dist/Inputs/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/Inputs/PasswordInput/PasswordInput.module.css.js +1 -3
- package/dist/Inputs/PasswordInput/PasswordInput.module.css.js.map +1 -1
- package/dist/Inputs/Select/Select.js +1 -25
- package/dist/Inputs/Select/Select.js.map +1 -1
- package/dist/Inputs/Select/Select.module.css.js +1 -3
- package/dist/Inputs/Select/Select.module.css.js.map +1 -1
- package/dist/Inputs/Switch/Switch.js +1 -80
- package/dist/Inputs/Switch/Switch.js.map +1 -1
- package/dist/Inputs/Switch/Switch.module.css.js +1 -3
- package/dist/Inputs/Switch/Switch.module.css.js.map +1 -1
- package/dist/Inputs/TextAreaInput/TextAreaInput.js +1 -29
- package/dist/Inputs/TextAreaInput/TextAreaInput.js.map +1 -1
- package/dist/Inputs/TextAreaInput/TextAreaInput.module.css.js +1 -3
- package/dist/Inputs/TextAreaInput/TextAreaInput.module.css.js.map +1 -1
- package/dist/Inputs/TextInput/TextInput.js +1 -22
- package/dist/Inputs/TextInput/TextInput.js.map +1 -1
- package/dist/Inputs/TextInput/TextInput.module.css.js +1 -3
- package/dist/Inputs/TextInput/TextInput.module.css.js.map +1 -1
- package/dist/Inputs/ThemeToggle/ThemeToggleListItem.js +1 -30
- package/dist/Inputs/ThemeToggle/ThemeToggleListItem.js.map +1 -1
- package/dist/Layout/Dialog/Dialog.js +1 -74
- package/dist/Layout/Dialog/Dialog.js.map +1 -1
- package/dist/Layout/Dialog/Dialog.module.css.js +1 -3
- package/dist/Layout/Dialog/Dialog.module.css.js.map +1 -1
- package/dist/Layout/Drawer/Drawer.d.ts +1 -1
- package/dist/Layout/Drawer/Drawer.js +1 -38
- package/dist/Layout/Drawer/Drawer.js.map +1 -1
- package/dist/Layout/Drawer/Drawer.module.css.js +1 -3
- package/dist/Layout/Drawer/Drawer.module.css.js.map +1 -1
- package/dist/Layout/PageLayout/PageLayout.js +1 -24
- package/dist/Layout/PageLayout/PageLayout.js.map +1 -1
- package/dist/Layout/PageLayout/PageLayout.module.css.js +1 -3
- package/dist/Layout/PageLayout/PageLayout.module.css.js.map +1 -1
- package/dist/Layout/PageLayoutPagination/PageLayoutPagination.js +1 -12
- package/dist/Layout/PageLayoutPagination/PageLayoutPagination.js.map +1 -1
- package/dist/Layout/PageLayoutPagination/PageLayoutPagination.module.css.js +1 -3
- package/dist/Layout/PageLayoutPagination/PageLayoutPagination.module.css.js.map +1 -1
- package/dist/Layout/PageLayoutTabs/PageLayoutTabs.js +1 -21
- package/dist/Layout/PageLayoutTabs/PageLayoutTabs.js.map +1 -1
- package/dist/Layout/PageLayoutTabs/PageLayoutTabs.module.css.js +1 -3
- package/dist/Layout/PageLayoutTabs/PageLayoutTabs.module.css.js.map +1 -1
- package/dist/Layout/Popover/Popover.js +1 -102
- package/dist/Layout/Popover/Popover.js.map +1 -1
- package/dist/Layout/Popover/Popover.module.css.js +1 -3
- package/dist/Layout/Popover/Popover.module.css.js.map +1 -1
- package/dist/Layout/SectionWrapper/SectionWrapper.js +1 -10
- package/dist/Layout/SectionWrapper/SectionWrapper.js.map +1 -1
- package/dist/Layout/SectionWrapper/SectionWrapper.module.css.js +1 -3
- package/dist/Layout/SectionWrapper/SectionWrapper.module.css.js.map +1 -1
- package/dist/Layout/Sidebar/Sidebar.js +1 -24
- package/dist/Layout/Sidebar/Sidebar.js.map +1 -1
- package/dist/Layout/Sidebar/Sidebar.module.css.js +1 -3
- package/dist/Layout/Sidebar/Sidebar.module.css.js.map +1 -1
- package/dist/Layout/Sidebar/SidebarBody/SidebarBody.js +1 -13
- package/dist/Layout/Sidebar/SidebarBody/SidebarBody.js.map +1 -1
- package/dist/Layout/Sidebar/SidebarBody/SidebarBody.module.css.js +1 -3
- package/dist/Layout/Sidebar/SidebarBody/SidebarBody.module.css.js.map +1 -1
- package/dist/Layout/Sidebar/SidebarDrawer/SidebarDrawer.js +1 -13
- package/dist/Layout/Sidebar/SidebarDrawer/SidebarDrawer.js.map +1 -1
- package/dist/Layout/Sidebar/SidebarDrawer/SidebarDrawer.module.css.js +1 -3
- package/dist/Layout/Sidebar/SidebarDrawer/SidebarDrawer.module.css.js.map +1 -1
- package/dist/Layout/Sidebar/SidebarFooter/SidebarFooter.js +1 -13
- package/dist/Layout/Sidebar/SidebarFooter/SidebarFooter.js.map +1 -1
- package/dist/Layout/Sidebar/SidebarFooter/SidebarFooter.module.css.js +1 -3
- package/dist/Layout/Sidebar/SidebarFooter/SidebarFooter.module.css.js.map +1 -1
- package/dist/Layout/Sidebar/SidebarHeader/SidebarHeader.js +1 -11
- package/dist/Layout/Sidebar/SidebarHeader/SidebarHeader.js.map +1 -1
- package/dist/Layout/Sidebar/SidebarViewport/SidebarViewport.js +1 -10
- package/dist/Layout/Sidebar/SidebarViewport/SidebarViewport.js.map +1 -1
- package/dist/Layout/Sidebar/SidebarViewport/SidebarViewport.module.css.js +1 -3
- package/dist/Layout/Sidebar/SidebarViewport/SidebarViewport.module.css.js.map +1 -1
- package/dist/Layout/Table/Table.js +1 -130
- package/dist/Layout/Table/Table.js.map +1 -1
- package/dist/Layout/Table/Table.module.css.js +1 -3
- package/dist/Layout/Table/Table.module.css.js.map +1 -1
- package/dist/Layout/Table/TableFooter.js +1 -8
- package/dist/Layout/Table/TableFooter.js.map +1 -1
- package/dist/Layout/Table/TableHeader.js +1 -8
- package/dist/Layout/Table/TableHeader.js.map +1 -1
- package/dist/Layout/Table/tableUtils.js +1 -123
- package/dist/Layout/Table/tableUtils.js.map +1 -1
- package/dist/Misc/Cursor/Cursor.js +1 -58
- package/dist/Misc/Cursor/Cursor.js.map +1 -1
- package/dist/Misc/Cursor/Cursor.module.css.js +1 -3
- package/dist/Misc/Cursor/Cursor.module.css.js.map +1 -1
- package/dist/Misc/Logos.js +1 -28
- package/dist/Misc/Logos.js.map +1 -1
- package/dist/Misc/PoweredByBanner/PoweredByBanner.js +1 -11
- package/dist/Misc/PoweredByBanner/PoweredByBanner.js.map +1 -1
- package/dist/Misc/PoweredByBanner/PoweredByBanner.module.css.js +1 -3
- package/dist/Misc/PoweredByBanner/PoweredByBanner.module.css.js.map +1 -1
- package/dist/Misc/Ripple/Ripple.js +1 -61
- package/dist/Misc/Ripple/Ripple.js.map +1 -1
- package/dist/Misc/Ripple/Ripple.module.css.js +1 -3
- package/dist/Misc/Ripple/Ripple.module.css.js.map +1 -1
- package/dist/Misc/Spinner/Spinner.js +1 -11
- package/dist/Misc/Spinner/Spinner.js.map +1 -1
- package/dist/Misc/Spinner/Spinner.module.css.js +1 -3
- package/dist/Misc/Spinner/Spinner.module.css.js.map +1 -1
- package/dist/Misc/TransitionAnimation/TransitionAnimation.js +1 -86
- package/dist/Misc/TransitionAnimation/TransitionAnimation.js.map +1 -1
- package/dist/Misc/TransitionAnimation/TransitionAnimation.module.css.js +1 -3
- package/dist/Misc/TransitionAnimation/TransitionAnimation.module.css.js.map +1 -1
- package/dist/Navigation/Breadcrumbs/Breadcrumbs.js +1 -35
- package/dist/Navigation/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/Navigation/Breadcrumbs/Breadcrumbs.module.css.js +1 -3
- package/dist/Navigation/Breadcrumbs/Breadcrumbs.module.css.js.map +1 -1
- package/dist/Navigation/Breadcrumbs/BreadcrumbsItem.js +1 -14
- package/dist/Navigation/Breadcrumbs/BreadcrumbsItem.js.map +1 -1
- package/dist/Navigation/Breadcrumbs/useBreadcrumbs.js +1 -43
- package/dist/Navigation/Breadcrumbs/useBreadcrumbs.js.map +1 -1
- package/dist/Navigation/Pagination/Pagination.js +1 -60
- package/dist/Navigation/Pagination/Pagination.js.map +1 -1
- package/dist/Navigation/Pagination/Pagination.module.css.js +1 -3
- package/dist/Navigation/Pagination/Pagination.module.css.js.map +1 -1
- package/dist/Navigation/Pagination/PaginationItem.js +1 -13
- package/dist/Navigation/Pagination/PaginationItem.js.map +1 -1
- package/dist/Navigation/Pagination/usePagination.js +1 -37
- package/dist/Navigation/Pagination/usePagination.js.map +1 -1
- package/dist/Navigation/Tabs/Tab/Tab.js +1 -69
- package/dist/Navigation/Tabs/Tab/Tab.js.map +1 -1
- package/dist/Navigation/Tabs/Tab/Tab.module.css.js +1 -3
- package/dist/Navigation/Tabs/Tab/Tab.module.css.js.map +1 -1
- package/dist/Navigation/Tabs/Tabs.js +1 -21
- package/dist/Navigation/Tabs/Tabs.js.map +1 -1
- package/dist/Navigation/Tabs/TabsBar/TabsBar.d.ts +5 -2
- package/dist/Navigation/Tabs/TabsBar/TabsBar.js +1 -43
- package/dist/Navigation/Tabs/TabsBar/TabsBar.js.map +1 -1
- package/dist/Navigation/Tabs/TabsBar/TabsBar.module.css.js +1 -3
- package/dist/Navigation/Tabs/TabsBar/TabsBar.module.css.js.map +1 -1
- package/dist/Typography/ClampedText/ClampedText.js +1 -43
- package/dist/Typography/ClampedText/ClampedText.js.map +1 -1
- package/dist/Typography/ClampedText/ClampedText.module.css.js +1 -3
- package/dist/Typography/ClampedText/ClampedText.module.css.js.map +1 -1
- package/dist/Typography/CopyableText/CopyableText.js +1 -38
- package/dist/Typography/CopyableText/CopyableText.js.map +1 -1
- package/dist/Typography/CopyableText/CopyableText.module.css.js +1 -3
- package/dist/Typography/CopyableText/CopyableText.module.css.js.map +1 -1
- package/dist/Typography/PageTitle/PageTitle.js +1 -9
- package/dist/Typography/PageTitle/PageTitle.js.map +1 -1
- package/dist/Typography/PageTitle/PageTitle.module.css.js +1 -3
- package/dist/Typography/PageTitle/PageTitle.module.css.js.map +1 -1
- package/dist/index.css +1 -2398
- package/dist/index.js +1 -64
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/rollup.config.js +0 -34
package/README.md
CHANGED
package/dist/Cards/Card/Card.js
CHANGED
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import 'react';
|
|
4
|
-
import { cn } from '@studiocubics/utils';
|
|
5
|
-
import styles from './Card.module.css.js';
|
|
6
|
-
|
|
7
|
-
const defaultElement = "div";
|
|
8
|
-
/**
|
|
9
|
-
* Base implementation for the Card component.
|
|
10
|
-
*
|
|
11
|
-
* This is a polymorphic component that defaults to rendering a `<Card>`.
|
|
12
|
-
* Use the `as` prop to change the underlying element.
|
|
13
|
-
*
|
|
14
|
-
* @typeParam C - The intrinsic or custom element type to render.
|
|
15
|
-
*
|
|
16
|
-
* @group Card
|
|
17
|
-
* @category inputs
|
|
18
|
-
*/
|
|
19
|
-
function CardBase(props) {
|
|
20
|
-
const { as, className, variant = "contained", size = "md", fullWidth = false, square, ref, ...restProps } = props;
|
|
21
|
-
const Component = (as || defaultElement);
|
|
22
|
-
const componentProps = {
|
|
23
|
-
className: cn(className, square ? styles.square : "", fullWidth ? styles.fullWidth : "", styles[`size_${size}`], styles[variant]),
|
|
24
|
-
ref,
|
|
25
|
-
...restProps,
|
|
26
|
-
};
|
|
27
|
-
return jsx(Component, { ...componentProps });
|
|
28
|
-
}
|
|
29
|
-
CardBase.displayName = "Card";
|
|
30
|
-
/**
|
|
31
|
-
* A polymorphic Card component.
|
|
32
|
-
*
|
|
33
|
-
* By default it renders a `<Card>`, but any element can be used via the `as` prop:
|
|
34
|
-
*
|
|
35
|
-
* ```tsx
|
|
36
|
-
* <Card as="a" href="/docs">Read docs</Card>
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @group Card
|
|
40
|
-
* @category inputs
|
|
41
|
-
*/
|
|
42
|
-
const Card = CardBase;
|
|
43
|
-
|
|
44
|
-
export { Card };
|
|
1
|
+
"use client";import{jsx as r}from"react/jsx-runtime";import"react";import{cn as s}from"@studiocubics/utils";import t from"./Card.module.css.js";function e(e){const{as:i,className:a,variant:o="contained",size:m="md",fullWidth:c=!1,square:u,ref:d,...l}=e,n=i||"div",f={className:s(a,u?t.square:"",c?t.fullWidth:"",t[`size_${m}`],t[o]),ref:d,...l};return r(n,{...f})}e.displayName="Card";const i=e;export{i as Card};
|
|
45
2
|
//# sourceMappingURL=Card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","sources":["../../../src/Cards/Card/Card.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n PolymorphicComponentProps,\n PolymorphicComponentType,\n} from \"@studiocubics/types\";\nimport { type ElementType } from \"react\";\n\nimport { cn } from \"@studiocubics/utils\";\nimport styles from \"./Card.module.css\";\n\n/**\n * Props specific to the Card component.\n *\n * These extend the intrinsic element props of whatever element is passed via `as`.\n * @group Card\n * @category inputs\n */\nexport interface CardBaseProps {\n /** Visual style variant.\n * @default \"contained\"\n */\n variant?: \"contained\" | \"outlined\";\n\n /** Expands width to 100%. */\n fullWidth?: boolean;\n\n /** Force a 1:1 aspect ratio. */\n square?: boolean;\n\n /** Card size.\n * @default \"md\"\n */\n size?: \"sm\" | \"md\" | \"lg\";\n}\nconst defaultElement = \"div\";\ntype DefaultElement = typeof defaultElement;\n/**\n * Polymorphic props for the Card component.\n *\n * `C` defines the element type rendered by the component (e.g. `\"Card\"`, `\"a\"`, `\"div\"`).\n * All intrinsic props for `C` are supported unless overridden by `CardBaseProps`.\n *\n * @group Card\n * @category inputs\n */\nexport type CardProps<C extends ElementType = DefaultElement> =\n PolymorphicComponentProps<C, CardBaseProps>;\n\n/**\n * Base implementation for the Card component.\n *\n * This is a polymorphic component that defaults to rendering a `<Card>`.\n * Use the `as` prop to change the underlying element.\n *\n * @typeParam C - The intrinsic or custom element type to render.\n *\n * @group Card\n * @category inputs\n */\nfunction CardBase<C extends ElementType = DefaultElement>(props: CardProps<C>) {\n const {\n as,\n className,\n variant = \"contained\",\n size = \"md\",\n fullWidth = false,\n square,\n ref,\n ...restProps\n } = props;\n const Component = (as || defaultElement) as ElementType;\n\n const componentProps = {\n className: cn(\n className,\n square ? styles.square : \"\",\n fullWidth ? styles.fullWidth : \"\",\n styles[`size_${size}`],\n styles[variant]\n ),\n ref,\n ...restProps,\n };\n\n return <Component {...componentProps} />;\n}\nCardBase.displayName = \"Card\";\n\n/**\n * A polymorphic Card component.\n *\n * By default it renders a `<Card>`, but any element can be used via the `as` prop:\n *\n * ```tsx\n * <Card as=\"a\" href=\"/docs\">Read docs</Card>\n * ```\n *\n * @group Card\n * @category inputs\n */\nexport const Card = CardBase as PolymorphicComponentType<\n CardBaseProps,\n DefaultElement\n>;\n"],"names":["
|
|
1
|
+
{"version":3,"file":"Card.js","sources":["../../../src/Cards/Card/Card.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n PolymorphicComponentProps,\n PolymorphicComponentType,\n} from \"@studiocubics/types\";\nimport { type ElementType } from \"react\";\n\nimport { cn } from \"@studiocubics/utils\";\nimport styles from \"./Card.module.css\";\n\n/**\n * Props specific to the Card component.\n *\n * These extend the intrinsic element props of whatever element is passed via `as`.\n * @group Card\n * @category inputs\n */\nexport interface CardBaseProps {\n /** Visual style variant.\n * @default \"contained\"\n */\n variant?: \"contained\" | \"outlined\";\n\n /** Expands width to 100%. */\n fullWidth?: boolean;\n\n /** Force a 1:1 aspect ratio. */\n square?: boolean;\n\n /** Card size.\n * @default \"md\"\n */\n size?: \"sm\" | \"md\" | \"lg\";\n}\nconst defaultElement = \"div\";\ntype DefaultElement = typeof defaultElement;\n/**\n * Polymorphic props for the Card component.\n *\n * `C` defines the element type rendered by the component (e.g. `\"Card\"`, `\"a\"`, `\"div\"`).\n * All intrinsic props for `C` are supported unless overridden by `CardBaseProps`.\n *\n * @group Card\n * @category inputs\n */\nexport type CardProps<C extends ElementType = DefaultElement> =\n PolymorphicComponentProps<C, CardBaseProps>;\n\n/**\n * Base implementation for the Card component.\n *\n * This is a polymorphic component that defaults to rendering a `<Card>`.\n * Use the `as` prop to change the underlying element.\n *\n * @typeParam C - The intrinsic or custom element type to render.\n *\n * @group Card\n * @category inputs\n */\nfunction CardBase<C extends ElementType = DefaultElement>(props: CardProps<C>) {\n const {\n as,\n className,\n variant = \"contained\",\n size = \"md\",\n fullWidth = false,\n square,\n ref,\n ...restProps\n } = props;\n const Component = (as || defaultElement) as ElementType;\n\n const componentProps = {\n className: cn(\n className,\n square ? styles.square : \"\",\n fullWidth ? styles.fullWidth : \"\",\n styles[`size_${size}`],\n styles[variant]\n ),\n ref,\n ...restProps,\n };\n\n return <Component {...componentProps} />;\n}\nCardBase.displayName = \"Card\";\n\n/**\n * A polymorphic Card component.\n *\n * By default it renders a `<Card>`, but any element can be used via the `as` prop:\n *\n * ```tsx\n * <Card as=\"a\" href=\"/docs\">Read docs</Card>\n * ```\n *\n * @group Card\n * @category inputs\n */\nexport const Card = CardBase as PolymorphicComponentType<\n CardBaseProps,\n DefaultElement\n>;\n"],"names":["CardBase","props","as","className","variant","size","fullWidth","square","ref","restProps","Component","componentProps","cn","styles","_jsx","displayName","Card"],"mappings":"gJA4DA,SAASA,EAAiDC,GACxD,MAAMC,GACJA,EAAEC,UACFA,EAASC,QACTA,EAAU,YAAWC,KACrBA,EAAO,KAAIC,UACXA,GAAY,EAAKC,OACjBA,EAAMC,IACNA,KACGC,GACDR,EACES,EAAaR,GApCE,MAsCfS,EAAiB,CACrBR,UAAWS,EACTT,EACAI,EAASM,EAAON,OAAS,GACzBD,EAAYO,EAAOP,UAAY,GAC/BO,EAAO,QAAQR,KACfQ,EAAOT,IAETI,SACGC,GAGL,OAAOK,EAACJ,EAAS,IAAKC,GACxB,CACAX,EAASe,YAAc,OAchB,MAAMC,EAAOhB"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
export { styles as default };
|
|
1
|
+
var _={square:"Card-module_square__SK-KQ",fullWidth:"Card-module_fullWidth__pIEIZ",size_sm:"Card-module_size_sm__B3eSI",size_md:"Card-module_size_md__15alI",size_lg:"Card-module_size_lg__HCTUY",outlined:"Card-module_outlined__TPads",contained:"Card-module_contained__EFPqh"};export{_ as default};
|
|
4
2
|
//# sourceMappingURL=Card.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Card.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import styles from './CollectionItemCard.module.css.js';
|
|
4
|
-
import { cn } from '@studiocubics/utils';
|
|
5
|
-
import { ClampedText } from '../../Typography/ClampedText/ClampedText.js';
|
|
6
|
-
import { Chip } from '../../Display/Chip/Chip.js';
|
|
7
|
-
|
|
8
|
-
const defaultElement = "a";
|
|
9
|
-
/**
|
|
10
|
-
* Base implementation for the CollectionItemCard component.
|
|
11
|
-
*
|
|
12
|
-
* This is a polymorphic component that defaults to rendering a `<CollectionItemCard>`.
|
|
13
|
-
* Use the `as` prop to change the underlying element.
|
|
14
|
-
*
|
|
15
|
-
* @typeParam C - The intrinsic or custom element type to render.
|
|
16
|
-
*
|
|
17
|
-
* @group CollectionItemCard
|
|
18
|
-
* @category inputs
|
|
19
|
-
*/
|
|
20
|
-
function CollectionItemCardBase(props) {
|
|
21
|
-
const { as, className, ref, thumbnail, title, chip, subtitle, description, footer, slotProps = {}, ...restProps } = props;
|
|
22
|
-
const Component = as || defaultElement;
|
|
23
|
-
const clickable = !!props.href || !!props.onClick;
|
|
24
|
-
const componentProps = {
|
|
25
|
-
className: cn(className, styles.main),
|
|
26
|
-
ref,
|
|
27
|
-
...restProps,
|
|
28
|
-
};
|
|
29
|
-
return (jsxs("div", { ...slotProps.root, className: cn(styles.root, clickable ? styles.clickable : "", slotProps.root?.className), children: [thumbnail && (jsx("div", { ...slotProps.thumbnail, className: cn(styles.image, slotProps.thumbnail?.className), children: thumbnail })), jsxs(Component, { ...componentProps, children: [jsxs("div", { ...slotProps.titleContainer, className: cn(styles.title, slotProps.titleContainer?.className), children: [chip &&
|
|
30
|
-
(typeof chip == "string" ? (jsx(Chip, { size: "sm", ...slotProps.chip, children: chip })) : (chip)), jsx(ClampedText, { as: "h4", ...slotProps.title, children: title })] }), subtitle && (jsx(ClampedText, { ...slotProps.subtitle, className: cn(styles.subtitle, slotProps.subtitle?.className), children: subtitle })), description && (jsx(ClampedText, { ...slotProps.description, className: cn(styles.description, slotProps.description?.className), children: description }))] }), footer && (jsx("div", { ...slotProps.footerContainer, className: cn(styles.footer, slotProps.footerContainer?.className), children: footer }))] }));
|
|
31
|
-
}
|
|
32
|
-
CollectionItemCardBase.displayName = "CollectionItemCard";
|
|
33
|
-
/**
|
|
34
|
-
* A polymorphic CollectionItemCard component.
|
|
35
|
-
*
|
|
36
|
-
* By default it renders a `<CollectionItemCard>`, but any element can be used via the `as` prop:
|
|
37
|
-
*
|
|
38
|
-
* ```tsx
|
|
39
|
-
* <CollectionItemCard as="a" href="/docs">Read docs</CollectionItemCard>
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @group CollectionItemCard
|
|
43
|
-
* @category inputs
|
|
44
|
-
*/
|
|
45
|
-
const CollectionItemCard = CollectionItemCardBase;
|
|
46
|
-
|
|
47
|
-
export { CollectionItemCard };
|
|
1
|
+
"use client";import{jsxs as e,jsx as i}from"react/jsx-runtime";import t from"./CollectionItemCard.module.css.js";import{cn as s}from"@studiocubics/utils";import{ClampedText as a}from"../../Typography/ClampedText/ClampedText.js";import{Chip as l}from"../../Display/Chip/Chip.js";function o(o){const{as:r,className:c,ref:m,thumbnail:n,title:d,chip:p,subtitle:h,description:u,footer:N,slotProps:f={},...C}=o,b=r||"a",y=!!o.href||!!o.onClick,j={className:s(c,t.main),ref:m,...C};return e("div",{...f.root,className:s(t.root,y?t.clickable:"",f.root?.className),children:[n&&i("div",{...f.thumbnail,className:s(t.image,f.thumbnail?.className),children:n}),e(b,{...j,children:[e("div",{...f.titleContainer,className:s(t.title,f.titleContainer?.className),children:[p&&("string"==typeof p?i(l,{size:"sm",...f.chip,children:p}):p),i(a,{as:"h4",...f.title,children:d})]}),h&&i(a,{...f.subtitle,className:s(t.subtitle,f.subtitle?.className),children:h}),u&&i(a,{...f.description,className:s(t.description,f.description?.className),children:u})]}),N&&i("div",{...f.footerContainer,className:s(t.footer,f.footerContainer?.className),children:N})]})}o.displayName="CollectionItemCard";const r=o;export{r as CollectionItemCard};
|
|
48
2
|
//# sourceMappingURL=CollectionItemCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionItemCard.js","sources":["../../../src/Cards/CollectionItemCard/CollectionItemCard.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentProps, ElementType, ReactNode } from \"react\";\nimport styles from \"./CollectionItemCard.module.css\";\nimport type {\n PolymorphicComponentProps,\n PolymorphicComponentType,\n} from \"@studiocubics/types\";\nimport { cn } from \"@studiocubics/utils\";\nimport {\n ClampedText,\n type ClampedTextProps,\n} from \"../../Typography/ClampedText/ClampedText\";\nimport { Chip, type ChipProps } from \"../../Display/Chip/Chip\";\n/**\n * Props specific to the CollectionItemCard component.\n *\n * These extend the intrinsic element props of whatever element is passed via `as`.\n * @group CollectionItemCard\n * @category inputs\n */\nexport interface CollectionItemCardBaseProps {\n thumbnail?: ReactNode;\n title: ReactNode;\n chip?: ReactNode;\n subtitle?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n slotProps?: {\n root?: ComponentProps<\"div\">;\n chip?: ChipProps;\n thumbnail?: ComponentProps<\"div\">;\n titleContainer?: ComponentProps<\"div\">;\n title?: ClampedTextProps;\n subtitle?: ClampedTextProps;\n description?: ClampedTextProps;\n footerContainer?: ComponentProps<\"div\">;\n };\n}\nconst defaultElement = \"a\";\ntype DefaultElement = typeof defaultElement;\n/**\n * Polymorphic props for the CollectionItemCard component.\n *\n * `C` defines the element type rendered by the component (e.g. `\"CollectionItemCard\"`, `\"a\"`, `\"div\"`).\n * All intrinsic props for `C` are supported unless overridden by `CollectionItemCardBaseProps`.\n *\n * @group CollectionItemCard\n * @category inputs\n */\nexport type CollectionItemCardProps<C extends ElementType = DefaultElement> =\n PolymorphicComponentProps<C, CollectionItemCardBaseProps>;\n\n/**\n * Base implementation for the CollectionItemCard component.\n *\n * This is a polymorphic component that defaults to rendering a `<CollectionItemCard>`.\n * Use the `as` prop to change the underlying element.\n *\n * @typeParam C - The intrinsic or custom element type to render.\n *\n * @group CollectionItemCard\n * @category inputs\n */\nfunction CollectionItemCardBase<C extends ElementType = DefaultElement>(\n props: CollectionItemCardProps<C>,\n) {\n const {\n as,\n className,\n ref,\n thumbnail,\n title,\n chip,\n subtitle,\n description,\n footer,\n slotProps = {},\n ...restProps\n } = props;\n const Component = as || defaultElement;\n\n const clickable = !!props.href || !!props.onClick;\n const componentProps = {\n className: cn(className, styles.main),\n ref,\n ...restProps,\n };\n\n return (\n <div\n {...slotProps.root}\n className={cn(\n styles.root,\n clickable ? styles.clickable : \"\",\n slotProps.root?.className,\n )}\n >\n {thumbnail && (\n <div\n {...slotProps.thumbnail}\n className={cn(styles.image, slotProps.thumbnail?.className)}\n >\n {thumbnail}\n </div>\n )}\n <Component {...componentProps}>\n <div\n {...slotProps.titleContainer}\n className={cn(styles.title, slotProps.titleContainer?.className)}\n >\n {chip &&\n (typeof chip == \"string\" ? (\n <Chip size=\"sm\" {...slotProps.chip}>\n {chip}\n </Chip>\n ) : (\n chip\n ))}\n <ClampedText as=\"h4\" {...slotProps.title}>\n {title}\n </ClampedText>\n </div>\n {subtitle && (\n <ClampedText\n {...slotProps.subtitle}\n className={cn(styles.subtitle, slotProps.subtitle?.className)}\n >\n {subtitle}\n </ClampedText>\n )}\n {description && (\n <ClampedText\n {...slotProps.description}\n className={cn(styles.description, slotProps.description?.className)}\n >\n {description}\n </ClampedText>\n )}\n </Component>\n {footer && (\n <div\n {...slotProps.footerContainer}\n className={cn(styles.footer, slotProps.footerContainer?.className)}\n >\n {footer}\n </div>\n )}\n </div>\n );\n}\nCollectionItemCardBase.displayName = \"CollectionItemCard\";\n\n/**\n * A polymorphic CollectionItemCard component.\n *\n * By default it renders a `<CollectionItemCard>`, but any element can be used via the `as` prop:\n *\n * ```tsx\n * <CollectionItemCard as=\"a\" href=\"/docs\">Read docs</CollectionItemCard>\n * ```\n *\n * @group CollectionItemCard\n * @category inputs\n */\nexport const CollectionItemCard =\n CollectionItemCardBase as PolymorphicComponentType<\n CollectionItemCardBaseProps,\n DefaultElement\n >;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAuCA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,C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AA,CAAA,CAAM,CAAC,MAAM,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,EAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAEjE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CACH,CACP,CAAA,EAAA,CACG,CAAA;AAEV;AACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsB,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAoB;AAEzD,CAAA,CAAA;;;;;;;;;;;AAWG,CAAA,CAAA;AACI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,kBAAkB,CAAA,CAAA,CAC7B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"CollectionItemCard.js","sources":["../../../src/Cards/CollectionItemCard/CollectionItemCard.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentProps, ElementType, ReactNode } from \"react\";\nimport styles from \"./CollectionItemCard.module.css\";\nimport type {\n PolymorphicComponentProps,\n PolymorphicComponentType,\n} from \"@studiocubics/types\";\nimport { cn } from \"@studiocubics/utils\";\nimport {\n ClampedText,\n type ClampedTextProps,\n} from \"../../Typography/ClampedText/ClampedText\";\nimport { Chip, type ChipProps } from \"../../Display/Chip/Chip\";\n/**\n * Props specific to the CollectionItemCard component.\n *\n * These extend the intrinsic element props of whatever element is passed via `as`.\n * @group CollectionItemCard\n * @category inputs\n */\nexport interface CollectionItemCardBaseProps {\n thumbnail?: ReactNode;\n title: ReactNode;\n chip?: ReactNode;\n subtitle?: ReactNode;\n description?: ReactNode;\n footer?: ReactNode;\n slotProps?: {\n root?: ComponentProps<\"div\">;\n chip?: ChipProps;\n thumbnail?: ComponentProps<\"div\">;\n titleContainer?: ComponentProps<\"div\">;\n title?: ClampedTextProps;\n subtitle?: ClampedTextProps;\n description?: ClampedTextProps;\n footerContainer?: ComponentProps<\"div\">;\n };\n}\nconst defaultElement = \"a\";\ntype DefaultElement = typeof defaultElement;\n/**\n * Polymorphic props for the CollectionItemCard component.\n *\n * `C` defines the element type rendered by the component (e.g. `\"CollectionItemCard\"`, `\"a\"`, `\"div\"`).\n * All intrinsic props for `C` are supported unless overridden by `CollectionItemCardBaseProps`.\n *\n * @group CollectionItemCard\n * @category inputs\n */\nexport type CollectionItemCardProps<C extends ElementType = DefaultElement> =\n PolymorphicComponentProps<C, CollectionItemCardBaseProps>;\n\n/**\n * Base implementation for the CollectionItemCard component.\n *\n * This is a polymorphic component that defaults to rendering a `<CollectionItemCard>`.\n * Use the `as` prop to change the underlying element.\n *\n * @typeParam C - The intrinsic or custom element type to render.\n *\n * @group CollectionItemCard\n * @category inputs\n */\nfunction CollectionItemCardBase<C extends ElementType = DefaultElement>(\n props: CollectionItemCardProps<C>,\n) {\n const {\n as,\n className,\n ref,\n thumbnail,\n title,\n chip,\n subtitle,\n description,\n footer,\n slotProps = {},\n ...restProps\n } = props;\n const Component = as || defaultElement;\n\n const clickable = !!props.href || !!props.onClick;\n const componentProps = {\n className: cn(className, styles.main),\n ref,\n ...restProps,\n };\n\n return (\n <div\n {...slotProps.root}\n className={cn(\n styles.root,\n clickable ? styles.clickable : \"\",\n slotProps.root?.className,\n )}\n >\n {thumbnail && (\n <div\n {...slotProps.thumbnail}\n className={cn(styles.image, slotProps.thumbnail?.className)}\n >\n {thumbnail}\n </div>\n )}\n <Component {...componentProps}>\n <div\n {...slotProps.titleContainer}\n className={cn(styles.title, slotProps.titleContainer?.className)}\n >\n {chip &&\n (typeof chip == \"string\" ? (\n <Chip size=\"sm\" {...slotProps.chip}>\n {chip}\n </Chip>\n ) : (\n chip\n ))}\n <ClampedText as=\"h4\" {...slotProps.title}>\n {title}\n </ClampedText>\n </div>\n {subtitle && (\n <ClampedText\n {...slotProps.subtitle}\n className={cn(styles.subtitle, slotProps.subtitle?.className)}\n >\n {subtitle}\n </ClampedText>\n )}\n {description && (\n <ClampedText\n {...slotProps.description}\n className={cn(styles.description, slotProps.description?.className)}\n >\n {description}\n </ClampedText>\n )}\n </Component>\n {footer && (\n <div\n {...slotProps.footerContainer}\n className={cn(styles.footer, slotProps.footerContainer?.className)}\n >\n {footer}\n </div>\n )}\n </div>\n );\n}\nCollectionItemCardBase.displayName = \"CollectionItemCard\";\n\n/**\n * A polymorphic CollectionItemCard component.\n *\n * By default it renders a `<CollectionItemCard>`, but any element can be used via the `as` prop:\n *\n * ```tsx\n * <CollectionItemCard as=\"a\" href=\"/docs\">Read docs</CollectionItemCard>\n * ```\n *\n * @group CollectionItemCard\n * @category inputs\n */\nexport const CollectionItemCard =\n CollectionItemCardBase as PolymorphicComponentType<\n CollectionItemCardBaseProps,\n DefaultElement\n >;\n"],"names":["CollectionItemCardBase","props","as","className","ref","thumbnail","title","chip","subtitle","description","footer","slotProps","restProps","Component","clickable","href","onClick","componentProps","cn","styles","main","_jsxs","root","children","_jsx","image","titleContainer","Chip","size","ClampedText","footerContainer","displayName","CollectionItemCard"],"mappings":"sRAgEA,SAASA,EACPC,GAEA,MAAMC,GACJA,EAAEC,UACFA,EAASC,IACTA,EAAGC,UACHA,EAASC,MACTA,EAAKC,KACLA,EAAIC,SACJA,EAAQC,YACRA,EAAWC,OACXA,EAAMC,UACNA,EAAY,CAAA,KACTC,GACDX,EACEY,EAAYX,GAzCG,IA2CfY,IAAcb,EAAMc,QAAUd,EAAMe,QACpCC,EAAiB,CACrBd,UAAWe,EAAGf,EAAWgB,EAAOC,MAChChB,SACGQ,GAGL,OACES,EAAA,MAAA,IACMV,EAAUW,KACdnB,UAAWe,EACTC,EAAOG,KACPR,EAAYK,EAAOL,UAAY,GAC/BH,EAAUW,MAAMnB,WACjBoB,SAAA,CAEAlB,GACCmB,YACMb,EAAUN,UACdF,UAAWe,EAAGC,EAAOM,MAAOd,EAAUN,WAAWF,oBAEhDE,IAGLgB,EAACR,EAAS,IAAKI,EAAcM,SAAA,CAC3BF,EAAA,MAAA,IACMV,EAAUe,eACdvB,UAAWe,EAAGC,EAAOb,MAAOK,EAAUe,gBAAgBvB,qBAErDI,IACiB,iBAARA,EACNiB,EAACG,EAAI,CAACC,KAAK,QAASjB,EAAUJ,KAAIgB,SAC/BhB,IACI,GAIXiB,EAACK,EAAW,CAAC3B,GAAG,QAASS,EAAUL,MAAKiB,SACrCjB,OAGJE,GACCgB,EAACK,EAAW,IACNlB,EAAUH,SACdL,UAAWe,EAAGC,EAAOX,SAAUG,EAAUH,UAAUL,WAAUoB,SAE5Df,IAGJC,GACCe,EAACK,EAAW,IACNlB,EAAUF,YACdN,UAAWe,EAAGC,EAAOV,YAAaE,EAAUF,aAAaN,WAAUoB,SAElEd,OAINC,GACCc,EAAA,MAAA,IACMb,EAAUmB,gBACd3B,UAAWe,EAAGC,EAAOT,OAAQC,EAAUmB,iBAAiB3B,WAAUoB,SAEjEb,MAKX,CACAV,EAAuB+B,YAAc,qBAc9B,MAAMC,EACXhC"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
export { styles as default };
|
|
1
|
+
var e={root:"CollectionItemCard-module_root__v3IlF",image:"CollectionItemCard-module_image__TfkAn",main:"CollectionItemCard-module_main__47qRO",description:"CollectionItemCard-module_description__BQapV",subtitle:"CollectionItemCard-module_subtitle__gThMk",clickable:"CollectionItemCard-module_clickable__d3rRV",title:"CollectionItemCard-module_title__B-sLi",footer:"CollectionItemCard-module_footer__-8LZo"};export{e as default};
|
|
4
2
|
//# sourceMappingURL=CollectionItemCard.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionItemCard.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CollectionItemCard.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useAnchorElement } from '@studiocubics/hooks';
|
|
3
|
-
import { Fragment as Fragment$1 } from 'react';
|
|
4
|
-
import { Button } from '../../Inputs/Button/Button.js';
|
|
5
|
-
import { Tooltip } from '../../Display/Tooltip/Tooltip.js';
|
|
6
|
-
import { Popover } from '../../Layout/Popover/Popover.js';
|
|
7
|
-
|
|
8
|
-
function CollectionItemCardActions({ actions, }) {
|
|
9
|
-
return (jsx(Fragment, { children: actions.map((action, i) => {
|
|
10
|
-
switch (action.actionType) {
|
|
11
|
-
case "popover":
|
|
12
|
-
return jsx(PopoverTypeAction, { action: action }, i);
|
|
13
|
-
case "link":
|
|
14
|
-
return jsx(LinkTypeAction, { action: action }, i);
|
|
15
|
-
default:
|
|
16
|
-
return jsx(Fragment$1, { children: action.children }, i);
|
|
17
|
-
}
|
|
18
|
-
}) }));
|
|
19
|
-
}
|
|
20
|
-
function PopoverTypeAction({ action, }) {
|
|
21
|
-
const { actionType: _, icon, popoverChildren, onClick, ...rest } = action;
|
|
22
|
-
const { anchorEl, open, handleClick, handleClose } = useAnchorElement();
|
|
23
|
-
return (jsxs(Fragment, { children: [jsx(Tooltip, { renderArrow: true, title: action.label, children: jsx(Button, { ...rest, onClick: (e) => {
|
|
24
|
-
handleClick(e);
|
|
25
|
-
onClick?.(e);
|
|
26
|
-
}, children: icon }) }), jsx(Popover, { open: open, anchorEl: anchorEl, onClose: handleClose, children: popoverChildren })] }));
|
|
27
|
-
}
|
|
28
|
-
function LinkTypeAction({ action, }) {
|
|
29
|
-
const { actionType: _, icon, ...rest } = action;
|
|
30
|
-
return (jsx(Tooltip, { renderArrow: true, title: action.label, children: jsx(Button, { ...rest, children: icon }) }));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { CollectionItemCardActions };
|
|
1
|
+
import{jsx as o,Fragment as r,jsxs as n}from"react/jsx-runtime";import{useAnchorElement as e}from"@studiocubics/hooks";import{Fragment as t}from"react";import{Button as i}from"../../Inputs/Button/Button.js";import{Tooltip as c}from"../../Display/Tooltip/Tooltip.js";import{Popover as l}from"../../Layout/Popover/Popover.js";function a({actions:n}){return o(r,{children:n.map((r,n)=>{switch(r.actionType){case"popover":return o(p,{action:r},n);case"link":return o(s,{action:r},n);default:return o(t,{children:r.children},n)}})})}function p({action:t}){const{actionType:a,icon:p,popoverChildren:s,onClick:u,...d}=t,{anchorEl:h,open:m,handleClick:f,handleClose:C}=e();return n(r,{children:[o(c,{renderArrow:!0,title:t.label,children:o(i,{...d,onClick:o=>{f(o),u?.(o)},children:p})}),o(l,{open:m,anchorEl:h,onClose:C,children:s})]})}function s({action:r}){const{actionType:n,icon:e,...t}=r;return o(c,{renderArrow:!0,title:r.label,children:o(i,{...t,children:e})})}export{a as CollectionItemCardActions};
|
|
34
2
|
//# sourceMappingURL=CollectionItemCardActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionItemCardActions.js","sources":["../../../src/Cards/CollectionItemCard/CollectionItemCardActions.tsx"],"sourcesContent":["import { useAnchorElement } from \"@studiocubics/hooks\";\nimport {\n type ElementType,\n type ReactNode,\n type MouseEvent,\n Fragment,\n} from \"react\";\nimport { Button, type ButtonProps } from \"../../Inputs/Button/Button\";\nimport { Tooltip } from \"../../Display/Tooltip/Tooltip\";\nimport { Popover } from \"../../Layout/Popover/Popover\";\n\nexport type DocumentAction<C extends ElementType = \"a\"> = {\n label?: string;\n} & (\n | ({\n actionType: \"popover\";\n popoverChildren: ReactNode;\n icon: ReactNode;\n } & ButtonProps<C>)\n | { actionType: \"node\"; children: ReactNode }\n | ({\n actionType: \"link\";\n href: string;\n icon: ReactNode;\n } & ButtonProps) //TODO Avoid 'as' conflict\n);\nexport function CollectionItemCardActions({\n actions,\n}: {\n actions: DocumentAction[];\n}) {\n return (\n <>\n {actions.map((action, i) => {\n switch (action.actionType) {\n case \"popover\":\n return <PopoverTypeAction key={i} action={action} />;\n case \"link\":\n return <LinkTypeAction key={i} action={action} />;\n default:\n return <Fragment key={i}>{action.children}</Fragment>;\n }\n })}\n </>\n );\n}\n\nfunction PopoverTypeAction({\n action,\n}: {\n action: DocumentAction & { actionType: \"popover\" };\n}) {\n const { actionType: _, icon, popoverChildren, onClick, ...rest } = action;\n const { anchorEl, open, handleClick, handleClose } = useAnchorElement();\n return (\n <>\n <Tooltip renderArrow title={action.label}>\n <Button\n {...rest}\n onClick={(e: MouseEvent<HTMLAnchorElement>) => {\n handleClick(e);\n onClick?.(e);\n }}\n >\n {icon}\n </Button>\n </Tooltip>\n <Popover open={open} anchorEl={anchorEl} onClose={handleClose}>\n {popoverChildren}\n </Popover>\n </>\n );\n}\nfunction LinkTypeAction({\n action,\n}: {\n action: DocumentAction & { actionType: \"link\" };\n}) {\n const { actionType: _, icon, ...rest } = action;\n return (\n <Tooltip renderArrow title={action.label}>\n <Button {...rest}>{icon}</Button>\n </Tooltip>\n );\n}\n"],"names":["_jsx","_Fragment","
|
|
1
|
+
{"version":3,"file":"CollectionItemCardActions.js","sources":["../../../src/Cards/CollectionItemCard/CollectionItemCardActions.tsx"],"sourcesContent":["import { useAnchorElement } from \"@studiocubics/hooks\";\nimport {\n type ElementType,\n type ReactNode,\n type MouseEvent,\n Fragment,\n} from \"react\";\nimport { Button, type ButtonProps } from \"../../Inputs/Button/Button\";\nimport { Tooltip } from \"../../Display/Tooltip/Tooltip\";\nimport { Popover } from \"../../Layout/Popover/Popover\";\n\nexport type DocumentAction<C extends ElementType = \"a\"> = {\n label?: string;\n} & (\n | ({\n actionType: \"popover\";\n popoverChildren: ReactNode;\n icon: ReactNode;\n } & ButtonProps<C>)\n | { actionType: \"node\"; children: ReactNode }\n | ({\n actionType: \"link\";\n href: string;\n icon: ReactNode;\n } & ButtonProps) //TODO Avoid 'as' conflict\n);\nexport function CollectionItemCardActions({\n actions,\n}: {\n actions: DocumentAction[];\n}) {\n return (\n <>\n {actions.map((action, i) => {\n switch (action.actionType) {\n case \"popover\":\n return <PopoverTypeAction key={i} action={action} />;\n case \"link\":\n return <LinkTypeAction key={i} action={action} />;\n default:\n return <Fragment key={i}>{action.children}</Fragment>;\n }\n })}\n </>\n );\n}\n\nfunction PopoverTypeAction({\n action,\n}: {\n action: DocumentAction & { actionType: \"popover\" };\n}) {\n const { actionType: _, icon, popoverChildren, onClick, ...rest } = action;\n const { anchorEl, open, handleClick, handleClose } = useAnchorElement();\n return (\n <>\n <Tooltip renderArrow title={action.label}>\n <Button\n {...rest}\n onClick={(e: MouseEvent<HTMLAnchorElement>) => {\n handleClick(e);\n onClick?.(e);\n }}\n >\n {icon}\n </Button>\n </Tooltip>\n <Popover open={open} anchorEl={anchorEl} onClose={handleClose}>\n {popoverChildren}\n </Popover>\n </>\n );\n}\nfunction LinkTypeAction({\n action,\n}: {\n action: DocumentAction & { actionType: \"link\" };\n}) {\n const { actionType: _, icon, ...rest } = action;\n return (\n <Tooltip renderArrow title={action.label}>\n <Button {...rest}>{icon}</Button>\n </Tooltip>\n );\n}\n"],"names":["CollectionItemCardActions","actions","_jsx","_Fragment","children","map","action","i","actionType","PopoverTypeAction","LinkTypeAction","Fragment","_","icon","popoverChildren","onClick","rest","anchorEl","open","handleClick","handleClose","useAnchorElement","_jsxs","Tooltip","renderArrow","title","label","Button","e","Popover","onClose"],"mappings":"oUA0BM,SAAUA,GAA0BC,QACxCA,IAIA,OACEC,EAAAC,EAAA,CAAAC,SACGH,EAAQI,IAAI,CAACC,EAAQC,KACpB,OAAQD,EAAOE,YACb,IAAK,UACH,OAAON,EAACO,EAAiB,CAASH,OAAQA,GAAXC,GACjC,IAAK,OACH,OAAOL,EAACQ,EAAc,CAASJ,OAAQA,GAAXC,GAC9B,QACE,OAAOL,EAACS,EAAQ,CAAAP,SAAUE,EAAOF,UAAXG,OAKlC,CAEA,SAASE,GAAkBH,OACzBA,IAIA,MAAQE,WAAYI,EAACC,KAAEA,EAAIC,gBAAEA,EAAeC,QAAEA,KAAYC,GAASV,GAC7DW,SAAEA,EAAQC,KAAEA,EAAIC,YAAEA,EAAWC,YAAEA,GAAgBC,IACrD,OACEC,eACEpB,EAACqB,GAAQC,aAAW,EAACC,MAAOnB,EAAOoB,MAAKtB,SACtCF,EAACyB,EAAM,IACDX,EACJD,QAAUa,IACRT,EAAYS,GACZb,IAAUa,IACXxB,SAEAS,MAGLX,EAAC2B,EAAO,CAACX,KAAMA,EAAMD,SAAUA,EAAUa,QAASV,WAC/CN,MAIT,CACA,SAASJ,GAAeJ,OACtBA,IAIA,MAAQE,WAAYI,EAACC,KAAEA,KAASG,GAASV,EACzC,OACEJ,EAACqB,EAAO,CAACC,aAAW,EAACC,MAAOnB,EAAOoB,MAAKtB,SACtCF,EAACyB,EAAM,IAAKX,WAAOH,KAGzB"}
|
|
@@ -1,52 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useMousePosition } from '@studiocubics/hooks';
|
|
4
|
-
import { cn, mergeRefs } from '@studiocubics/utils';
|
|
5
|
-
import { useRef, useEffect } from 'react';
|
|
6
|
-
import styles from './GlassCard.module.css.js';
|
|
7
|
-
|
|
8
|
-
const defaultElement = "div";
|
|
9
|
-
// Create the base component with forwardRef
|
|
10
|
-
function GlassCardBase({ as, children, className, ref, ...restProps }) {
|
|
11
|
-
const Component = (as || defaultElement);
|
|
12
|
-
const { mousePosition } = useMousePosition({ includeTouch: false });
|
|
13
|
-
const cardRef = useRef(null);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (!cardRef.current)
|
|
16
|
-
return;
|
|
17
|
-
if (!mousePosition.x || !mousePosition.y)
|
|
18
|
-
return;
|
|
19
|
-
const rect = cardRef.current.getBoundingClientRect();
|
|
20
|
-
const x = mousePosition.x - rect.left;
|
|
21
|
-
const y = mousePosition.y - rect.top;
|
|
22
|
-
const xCenter = rect.left + rect.width / 2;
|
|
23
|
-
const yCenter = rect.top + rect.height / 2;
|
|
24
|
-
const dx = (mousePosition.x - xCenter) / rect.width;
|
|
25
|
-
const dy = (mousePosition.y - yCenter) / rect.height;
|
|
26
|
-
// Angle from card center to mouse
|
|
27
|
-
const angle = Math.atan2(dy, dx) * (180 / Math.PI) + 270;
|
|
28
|
-
// Distance normalized against window width/height
|
|
29
|
-
const dxGlobal = mousePosition.x - xCenter;
|
|
30
|
-
const dyGlobal = mousePosition.y - yCenter;
|
|
31
|
-
const tX = Math.min(Math.abs(dxGlobal) / window.innerWidth, 1);
|
|
32
|
-
const tY = Math.min(Math.abs(dyGlobal) / window.innerHeight, 1);
|
|
33
|
-
const t = Math.min(tX + tY, 1); // Manhattan distance capped at 1
|
|
34
|
-
const intensity = 1 - 0.8 * t; // maps to 0.2..1
|
|
35
|
-
cardRef.current.style.setProperty("--mouse-x", `${x}px`);
|
|
36
|
-
cardRef.current.style.setProperty("--mouse-y", `${y}px`);
|
|
37
|
-
cardRef.current.style.setProperty("--gradient-angle", `${angle}deg`);
|
|
38
|
-
cardRef.current.style.setProperty("--glass-reflection-intensity", `${intensity}`);
|
|
39
|
-
}, [mousePosition]);
|
|
40
|
-
const componentProps = {
|
|
41
|
-
ref: mergeRefs(ref, cardRef),
|
|
42
|
-
className: cn(className, styles.root),
|
|
43
|
-
...restProps,
|
|
44
|
-
};
|
|
45
|
-
return jsx(Component, { ...componentProps, children: children });
|
|
46
|
-
}
|
|
47
|
-
GlassCardBase.displayName = "GlassCard";
|
|
48
|
-
// Type assertion to make it polymorphic
|
|
49
|
-
const GlassCard = GlassCardBase;
|
|
50
|
-
|
|
51
|
-
export { GlassCard };
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{useMousePosition as e}from"@studiocubics/hooks";import{cn as r,mergeRefs as s}from"@studiocubics/utils";import{useRef as i,useEffect as n}from"react";import o from"./GlassCard.module.css.js";function a({as:a,children:c,className:u,ref:l,...m}){const h=a||"div",{mousePosition:d}=e({includeTouch:!1}),p=i(null);n(()=>{if(!p.current)return;if(!d.x||!d.y)return;const t=p.current.getBoundingClientRect(),e=d.x-t.left,r=d.y-t.top,s=t.left+t.width/2,i=t.top+t.height/2,n=(d.x-s)/t.width,o=(d.y-i)/t.height,a=Math.atan2(o,n)*(180/Math.PI)+270,c=d.x-s,u=d.y-i,l=Math.min(Math.abs(c)/window.innerWidth,1),m=Math.min(Math.abs(u)/window.innerHeight,1),h=1-.8*Math.min(l+m,1);p.current.style.setProperty("--mouse-x",`${e}px`),p.current.style.setProperty("--mouse-y",`${r}px`),p.current.style.setProperty("--gradient-angle",`${a}deg`),p.current.style.setProperty("--glass-reflection-intensity",`${h}`)},[d]);const y={ref:s(l,p),className:r(u,o.root),...m};return t(h,{...y,children:c})}a.displayName="GlassCard";const c=a;export{c as GlassCard};
|
|
52
2
|
//# sourceMappingURL=GlassCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlassCard.js","sources":["../../../src/Cards/GlassCard/GlassCard.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMousePosition } from \"@studiocubics/hooks\";\nimport type {\n PolymorphicComponentProps,\n PolymorphicComponentType,\n} from \"@studiocubics/types\";\nimport { mergeRefs, cn } from \"@studiocubics/utils\";\nimport { type ElementType, useRef, useEffect } from \"react\";\nimport styles from \"./GlassCard.module.css\";\n\nconst defaultElement = \"div\";\ntype DefaultElement = typeof defaultElement;\n\nexport type GlassCardProps<C extends ElementType = DefaultElement> = Omit<\n PolymorphicComponentProps<C, object>,\n \"ref\"\n>;\n\n// Create the base component with forwardRef\nfunction GlassCardBase<C extends ElementType = DefaultElement>({\n as,\n children,\n className,\n ref,\n ...restProps\n}: GlassCardProps<C>) {\n const Component = (as || defaultElement) as ElementType;\n const { mousePosition } = useMousePosition({ includeTouch: false });\n const cardRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!cardRef.current) return;\n if (!mousePosition.x || !mousePosition.y) return;\n\n const rect = cardRef.current.getBoundingClientRect();\n const x = mousePosition.x - rect.left;\n const y = mousePosition.y - rect.top;\n const xCenter = rect.left + rect.width / 2;\n const yCenter = rect.top + rect.height / 2;\n\n const dx = (mousePosition.x - xCenter) / rect.width;\n const dy = (mousePosition.y - yCenter) / rect.height;\n\n // Angle from card center to mouse\n const angle = Math.atan2(dy, dx) * (180 / Math.PI) + 270;\n\n // Distance normalized against window width/height\n const dxGlobal = mousePosition.x - xCenter;\n const dyGlobal = mousePosition.y - yCenter;\n const tX = Math.min(Math.abs(dxGlobal) / window.innerWidth, 1);\n const tY = Math.min(Math.abs(dyGlobal) / window.innerHeight, 1);\n const t = Math.min(tX + tY, 1); // Manhattan distance capped at 1\n const intensity = 1 - 0.8 * t; // maps to 0.2..1\n\n cardRef.current.style.setProperty(\"--mouse-x\", `${x}px`);\n cardRef.current.style.setProperty(\"--mouse-y\", `${y}px`);\n cardRef.current.style.setProperty(\"--gradient-angle\", `${angle}deg`);\n cardRef.current.style.setProperty(\n \"--glass-reflection-intensity\",\n `${intensity}`\n );\n }, [mousePosition]);\n\n const componentProps = {\n ref: mergeRefs(ref, cardRef),\n className: cn(className, styles.root),\n ...restProps,\n };\n\n return <Component {...componentProps}>{children}</Component>;\n}\n\nGlassCardBase.displayName = \"GlassCard\";\n\n// Type assertion to make it polymorphic\nexport const GlassCard = GlassCardBase as PolymorphicComponentType<\n object,\n DefaultElement\n>;\n"],"names":["_jsx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A,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,GAAa;AAC9D;AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW;AAEvC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,SAAS,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"GlassCard.js","sources":["../../../src/Cards/GlassCard/GlassCard.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMousePosition } from \"@studiocubics/hooks\";\nimport type {\n PolymorphicComponentProps,\n PolymorphicComponentType,\n} from \"@studiocubics/types\";\nimport { mergeRefs, cn } from \"@studiocubics/utils\";\nimport { type ElementType, useRef, useEffect } from \"react\";\nimport styles from \"./GlassCard.module.css\";\n\nconst defaultElement = \"div\";\ntype DefaultElement = typeof defaultElement;\n\nexport type GlassCardProps<C extends ElementType = DefaultElement> = Omit<\n PolymorphicComponentProps<C, object>,\n \"ref\"\n>;\n\n// Create the base component with forwardRef\nfunction GlassCardBase<C extends ElementType = DefaultElement>({\n as,\n children,\n className,\n ref,\n ...restProps\n}: GlassCardProps<C>) {\n const Component = (as || defaultElement) as ElementType;\n const { mousePosition } = useMousePosition({ includeTouch: false });\n const cardRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!cardRef.current) return;\n if (!mousePosition.x || !mousePosition.y) return;\n\n const rect = cardRef.current.getBoundingClientRect();\n const x = mousePosition.x - rect.left;\n const y = mousePosition.y - rect.top;\n const xCenter = rect.left + rect.width / 2;\n const yCenter = rect.top + rect.height / 2;\n\n const dx = (mousePosition.x - xCenter) / rect.width;\n const dy = (mousePosition.y - yCenter) / rect.height;\n\n // Angle from card center to mouse\n const angle = Math.atan2(dy, dx) * (180 / Math.PI) + 270;\n\n // Distance normalized against window width/height\n const dxGlobal = mousePosition.x - xCenter;\n const dyGlobal = mousePosition.y - yCenter;\n const tX = Math.min(Math.abs(dxGlobal) / window.innerWidth, 1);\n const tY = Math.min(Math.abs(dyGlobal) / window.innerHeight, 1);\n const t = Math.min(tX + tY, 1); // Manhattan distance capped at 1\n const intensity = 1 - 0.8 * t; // maps to 0.2..1\n\n cardRef.current.style.setProperty(\"--mouse-x\", `${x}px`);\n cardRef.current.style.setProperty(\"--mouse-y\", `${y}px`);\n cardRef.current.style.setProperty(\"--gradient-angle\", `${angle}deg`);\n cardRef.current.style.setProperty(\n \"--glass-reflection-intensity\",\n `${intensity}`\n );\n }, [mousePosition]);\n\n const componentProps = {\n ref: mergeRefs(ref, cardRef),\n className: cn(className, styles.root),\n ...restProps,\n };\n\n return <Component {...componentProps}>{children}</Component>;\n}\n\nGlassCardBase.displayName = \"GlassCard\";\n\n// Type assertion to make it polymorphic\nexport const GlassCard = GlassCardBase as PolymorphicComponentType<\n object,\n DefaultElement\n>;\n"],"names":["GlassCardBase","as","children","className","ref","restProps","Component","mousePosition","useMousePosition","includeTouch","cardRef","useRef","useEffect","current","x","y","rect","getBoundingClientRect","left","top","xCenter","width","yCenter","height","dx","dy","angle","Math","atan2","PI","dxGlobal","dyGlobal","tX","min","abs","window","innerWidth","tY","innerHeight","intensity","style","setProperty","componentProps","mergeRefs","cn","styles","root","_jsx","displayName","GlassCard"],"mappings":"2PAoBA,SAASA,GAAsDC,GAC7DA,EAAEC,SACFA,EAAQC,UACRA,EAASC,IACTA,KACGC,IAEH,MAAMC,EAAaL,GAhBE,OAiBfM,cAAEA,GAAkBC,EAAiB,CAAEC,cAAc,IACrDC,EAAUC,EAAuB,MAEvCC,EAAU,KACR,IAAKF,EAAQG,QAAS,OACtB,IAAKN,EAAcO,IAAMP,EAAcQ,EAAG,OAE1C,MAAMC,EAAON,EAAQG,QAAQI,wBACvBH,EAAIP,EAAcO,EAAIE,EAAKE,KAC3BH,EAAIR,EAAcQ,EAAIC,EAAKG,IAC3BC,EAAUJ,EAAKE,KAAOF,EAAKK,MAAQ,EACnCC,EAAUN,EAAKG,IAAMH,EAAKO,OAAS,EAEnCC,GAAMjB,EAAcO,EAAIM,GAAWJ,EAAKK,MACxCI,GAAMlB,EAAcQ,EAAIO,GAAWN,EAAKO,OAGxCG,EAAQC,KAAKC,MAAMH,EAAID,IAAO,IAAMG,KAAKE,IAAM,IAG/CC,EAAWvB,EAAcO,EAAIM,EAC7BW,EAAWxB,EAAcQ,EAAIO,EAC7BU,EAAKL,KAAKM,IAAIN,KAAKO,IAAIJ,GAAYK,OAAOC,WAAY,GACtDC,EAAKV,KAAKM,IAAIN,KAAKO,IAAIH,GAAYI,OAAOG,YAAa,GAEvDC,EAAY,EAAI,GADZZ,KAAKM,IAAID,EAAKK,EAAI,GAG5B3B,EAAQG,QAAQ2B,MAAMC,YAAY,YAAa,GAAG3B,OAClDJ,EAAQG,QAAQ2B,MAAMC,YAAY,YAAa,GAAG1B,OAClDL,EAAQG,QAAQ2B,MAAMC,YAAY,mBAAoB,GAAGf,QACzDhB,EAAQG,QAAQ2B,MAAMC,YACpB,+BACA,GAAGF,MAEJ,CAAChC,IAEJ,MAAMmC,EAAiB,CACrBtC,IAAKuC,EAAUvC,EAAKM,GACpBP,UAAWyC,EAAGzC,EAAW0C,EAAOC,SAC7BzC,GAGL,OAAO0C,EAACzC,EAAS,IAAKoC,EAAcxC,SAAGA,GACzC,CAEAF,EAAcgD,YAAc,YAGrB,MAAMC,EAAYjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlassCard.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GlassCard.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useState, useRef, useCallback } from 'react';
|
|
4
|
-
|
|
5
|
-
const AccordionContext = createContext(null);
|
|
6
|
-
function Accordion({ children, exclusive = false, onChange, }) {
|
|
7
|
-
const [values, setValues] = useState([]);
|
|
8
|
-
const indexRef = useRef(-1);
|
|
9
|
-
const register = useCallback(() => {
|
|
10
|
-
const index = indexRef.current++;
|
|
11
|
-
setValues((prev) => [...prev, false]);
|
|
12
|
-
return index;
|
|
13
|
-
}, []);
|
|
14
|
-
const update = useCallback((index, checked) => {
|
|
15
|
-
console.log("index", index, checked);
|
|
16
|
-
setValues((prev) => {
|
|
17
|
-
let next = exclusive && checked ? new Array(prev.length).fill(false) : [...prev];
|
|
18
|
-
next[index] = checked;
|
|
19
|
-
onChange?.(next);
|
|
20
|
-
return next;
|
|
21
|
-
});
|
|
22
|
-
}, [exclusive, onChange]);
|
|
23
|
-
const context = { values, register, update };
|
|
24
|
-
return (jsx(AccordionContext.Provider, { value: context, children: children }));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { Accordion, AccordionContext };
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import{createContext as r,useState as n,useRef as t,useCallback as l}from"react";const o=r(null);function c({children:r,exclusive:c=!1,onChange:i}){const[u,s]=n([]),a=t(-1),d={values:u,register:l(()=>{const e=a.current++;return s(e=>[...e,!1]),e},[]),update:l((e,r)=>{console.log("index",e,r),s(n=>{let t=c&&r?new Array(n.length).fill(!1):[...n];return t[e]=r,i?.(t),t})},[c,i])};return e(o.Provider,{value:d,children:r})}export{c as Accordion,o as AccordionContext};
|
|
28
2
|
//# sourceMappingURL=Accordion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sources":["../../../src/Display/Accordion/Accordion.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\ninterface AccordionContextProps {\n values: boolean[];\n register: () => number;\n update: (index: number, checked: boolean) => void;\n}\ninterface AccordionProviderProps {\n children: ReactNode;\n exclusive?: boolean;\n onChange?: (checked: boolean[]) => void;\n}\n\nexport const AccordionContext = createContext<AccordionContextProps | null>(\n null,\n);\n\nexport function Accordion({\n children,\n exclusive = false,\n onChange,\n}: AccordionProviderProps) {\n const [values, setValues] = useState<boolean[]>([]);\n const indexRef = useRef(-1);\n\n const register = useCallback(() => {\n const index = indexRef.current++;\n setValues((prev) => [...prev, false]);\n return index;\n }, []);\n\n const update = useCallback(\n (index: number, checked: boolean) => {\n console.log(\"index\", index, checked);\n\n setValues((prev) => {\n let next =\n exclusive && checked ? new Array(prev.length).fill(false) : [...prev];\n next[index] = checked;\n onChange?.(next);\n return next;\n });\n },\n [exclusive, onChange],\n );\n const context = { values, register, update };\n\n return (\n <AccordionContext.Provider value={context}>\n {children}\n </AccordionContext.Provider>\n );\n}\n"],"names":["
|
|
1
|
+
{"version":3,"file":"Accordion.js","sources":["../../../src/Display/Accordion/Accordion.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\ninterface AccordionContextProps {\n values: boolean[];\n register: () => number;\n update: (index: number, checked: boolean) => void;\n}\ninterface AccordionProviderProps {\n children: ReactNode;\n exclusive?: boolean;\n onChange?: (checked: boolean[]) => void;\n}\n\nexport const AccordionContext = createContext<AccordionContextProps | null>(\n null,\n);\n\nexport function Accordion({\n children,\n exclusive = false,\n onChange,\n}: AccordionProviderProps) {\n const [values, setValues] = useState<boolean[]>([]);\n const indexRef = useRef(-1);\n\n const register = useCallback(() => {\n const index = indexRef.current++;\n setValues((prev) => [...prev, false]);\n return index;\n }, []);\n\n const update = useCallback(\n (index: number, checked: boolean) => {\n console.log(\"index\", index, checked);\n\n setValues((prev) => {\n let next =\n exclusive && checked ? new Array(prev.length).fill(false) : [...prev];\n next[index] = checked;\n onChange?.(next);\n return next;\n });\n },\n [exclusive, onChange],\n );\n const context = { values, register, update };\n\n return (\n <AccordionContext.Provider value={context}>\n {children}\n </AccordionContext.Provider>\n );\n}\n"],"names":["AccordionContext","createContext","Accordion","children","exclusive","onChange","values","setValues","useState","indexRef","useRef","context","register","useCallback","index","current","prev","update","checked","console","log","next","Array","length","fill","_jsx","Provider","value"],"mappings":"4IAqBaA,EAAmBC,EAC9B,MAGI,SAAUC,GAAUC,SACxBA,EAAQC,UACRA,GAAY,EAAKC,SACjBA,IAEA,MAAOC,EAAQC,GAAaC,EAAoB,IAC1CC,EAAWC,MAsBXC,EAAU,CAAEL,SAAQM,SApBTC,EAAY,KAC3B,MAAMC,EAAQL,EAASM,UAEvB,OADAR,EAAWS,GAAS,IAAIA,GAAM,IACvBF,GACN,IAgBiCG,OAdrBJ,EACb,CAACC,EAAeI,KACdC,QAAQC,IAAI,QAASN,EAAOI,GAE5BX,EAAWS,IACT,IAAIK,EACFjB,GAAac,EAAU,IAAII,MAAMN,EAAKO,QAAQC,MAAK,GAAS,IAAIR,GAGlE,OAFAK,EAAKP,GAASI,EACdb,IAAWgB,GACJA,KAGX,CAACjB,EAAWC,KAId,OACEoB,EAACzB,EAAiB0B,SAAQ,CAACC,MAAOhB,EAAOR,SACtCA,GAGP"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
export { styles as default };
|
|
1
|
+
var o={summary:"Accordion-module_summary__3uXXu",highlight:"Accordion-module_highlight__YzcnA",summaryContent:"Accordion-module_summaryContent__-Wu52",marker:"Accordion-module_marker__7gmt8",root:"Accordion-module_root__-tG1G",content:"Accordion-module_content__NPbBr"};export{o as default};
|
|
4
2
|
//# sourceMappingURL=Accordion.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Accordion.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,56 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { useState, useRef, useContext, useEffect } from 'react';
|
|
4
|
-
import { AccordionContext } from './Accordion.js';
|
|
5
|
-
import styles from './Accordion.module.css.js';
|
|
6
|
-
import { mergeRefs, cn } from '@studiocubics/utils';
|
|
7
|
-
import { GlassCard } from '../../Cards/GlassCard/GlassCard.js';
|
|
8
|
-
|
|
9
|
-
function AccordionItem(props) {
|
|
10
|
-
const { summary, open: htmlOpen, children, className, onToggle, highlightOpen = true, openMarker = jsx(OpenMarkerIcon, {}), closeMarker = jsx(CloseMarkerIcon, {}), slotProps = {}, ref, ...rest } = props;
|
|
11
|
-
const [index, setIndex] = useState(null);
|
|
12
|
-
const isRegistered = useRef(false);
|
|
13
|
-
const [uncontrolledOpen, setUncontrolledOpen] = useState(!!htmlOpen);
|
|
14
|
-
const itemRef = useRef(null);
|
|
15
|
-
const group = useContext(AccordionContext);
|
|
16
|
-
const open = group && index !== null ? group.values[index] : uncontrolledOpen;
|
|
17
|
-
const handleToggle = async (e) => {
|
|
18
|
-
const next = e.currentTarget.open;
|
|
19
|
-
if (group && index !== null)
|
|
20
|
-
group.update(index, next);
|
|
21
|
-
else
|
|
22
|
-
setUncontrolledOpen(next);
|
|
23
|
-
onToggle?.(e, next);
|
|
24
|
-
if (next) {
|
|
25
|
-
itemRef.current?.scrollIntoView({
|
|
26
|
-
block: "nearest",
|
|
27
|
-
inline: "nearest",
|
|
28
|
-
behavior: "smooth",
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const componentProps = {
|
|
33
|
-
open,
|
|
34
|
-
onToggle: handleToggle,
|
|
35
|
-
className: cn(className, styles.root, open ? styles.open : ""),
|
|
36
|
-
ref: mergeRefs(ref, itemRef),
|
|
37
|
-
...rest,
|
|
38
|
-
};
|
|
39
|
-
// Register with group if present
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (!group || isRegistered.current)
|
|
42
|
-
return;
|
|
43
|
-
isRegistered.current = true;
|
|
44
|
-
setIndex(group.register());
|
|
45
|
-
}, [group]);
|
|
46
|
-
return (jsxs("details", { ...componentProps, children: [jsxs("summary", { className: cn(className, styles.summary), children: [open && highlightOpen && jsx(GlassCard, { className: styles.highlight }), jsx("div", { ...slotProps.summaryContent, className: cn(styles.summaryContent, slotProps.summaryContent?.className), children: summary }), jsx("span", { ...slotProps.marker, className: cn(styles.marker), children: open ? closeMarker : openMarker })] }), jsx("div", { ...slotProps.content, className: cn(styles.content, slotProps.content?.className), children: children })] }));
|
|
47
|
-
}
|
|
48
|
-
function OpenMarkerIcon(props) {
|
|
49
|
-
return (jsx("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", strokeWidth: "2.3", stroke: "currentColor", children: jsx("path", { d: "m6 9 6 6 6-6" }) }));
|
|
50
|
-
}
|
|
51
|
-
function CloseMarkerIcon(props) {
|
|
52
|
-
return (jsx("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", strokeWidth: "2.3", stroke: "currentColor", children: jsx("path", { d: "m18 15-6-6-6 6" }) }));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export { AccordionItem };
|
|
1
|
+
"use client";import{jsx as r,jsxs as e}from"react/jsx-runtime";import{useState as n,useRef as o,useContext as s,useEffect as t}from"react";import{AccordionContext as l}from"./Accordion.js";import a from"./Accordion.module.css.js";import{mergeRefs as c,cn as i}from"@studiocubics/utils";import{GlassCard as m}from"../../Cards/GlassCard/GlassCard.js";function u(u){const{summary:p,open:g,children:f,className:w,onToggle:v,highlightOpen:k=!0,openMarker:N=r(d,{}),closeMarker:C=r(h,{}),slotProps:y={},ref:x,...j}=u,[b,T]=n(null),A=o(!1),[B,G]=n(!!g),M=o(null),W=s(l),I=W&&null!==b?W.values[b]:B,O={open:I,onToggle:async r=>{const e=r.currentTarget.open;W&&null!==b?W.update(b,e):G(e),v?.(r,e),e&&M.current?.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})},className:i(w,a.root,I?a.open:""),ref:c(x,M),...j};return t(()=>{W&&!A.current&&(A.current=!0,T(W.register()))},[W]),e("details",{...O,children:[e("summary",{className:i(w,a.summary),children:[I&&k&&r(m,{className:a.highlight}),r("div",{...y.summaryContent,className:i(a.summaryContent,y.summaryContent?.className),children:p}),r("span",{...y.marker,className:i(a.marker),children:I?C:N})]}),r("div",{...y.content,className:i(a.content,y.content?.className),children:f})]})}function d(e){return r("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",strokeWidth:"2.3",stroke:"currentColor",children:r("path",{d:"m6 9 6 6 6-6"})})}function h(e){return r("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",strokeWidth:"2.3",stroke:"currentColor",children:r("path",{d:"m18 15-6-6-6 6"})})}export{u as AccordionItem};
|
|
56
2
|
//# sourceMappingURL=AccordionItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionItem.js","sources":["../../../src/Display/Accordion/AccordionItem.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentProps,\n type ReactNode,\n type ToggleEvent,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { AccordionContext } from \"./Accordion\";\nimport styles from \"./Accordion.module.css\";\nimport { cn, mergeRefs } from \"@studiocubics/utils\";\nimport { GlassCard } from \"../../Cards/GlassCard/GlassCard\";\n\nexport type AccordionProps = {\n summary: ReactNode;\n onToggle?: (e: ToggleEvent<HTMLDetailsElement>, current: boolean) => void;\n openMarker?: ReactNode;\n closeMarker?: ReactNode;\n highlightOpen?: boolean;\n slotProps?: {\n marker?: ComponentProps<\"span\">;\n summary?: ComponentProps<\"summary\">;\n summaryContent?: ComponentProps<\"div\">;\n content?: ComponentProps<\"div\">;\n };\n} & ComponentProps<\"details\">;\n\nexport function AccordionItem(props: AccordionProps) {\n const {\n summary,\n open: htmlOpen,\n children,\n className,\n onToggle,\n highlightOpen = true,\n openMarker = <OpenMarkerIcon />,\n closeMarker = <CloseMarkerIcon />,\n slotProps = {},\n ref,\n ...rest\n } = props;\n\n const [index, setIndex] = useState<number | null>(null);\n const isRegistered = useRef(false);\n const [uncontrolledOpen, setUncontrolledOpen] = useState(!!htmlOpen);\n const itemRef = useRef<HTMLDetailsElement | null>(null);\n const group = useContext(AccordionContext);\n\n const open = group && index !== null ? group.values[index] : uncontrolledOpen;\n\n const handleToggle = async (e: ToggleEvent<HTMLDetailsElement>) => {\n const next = e.currentTarget.open;\n if (group && index !== null) group.update(index, next);\n else setUncontrolledOpen(next);\n onToggle?.(e, next);\n if (next) {\n itemRef.current?.scrollIntoView({\n block: \"nearest\",\n inline: \"nearest\",\n behavior: \"smooth\",\n });\n }\n };\n\n const componentProps = {\n open,\n onToggle: handleToggle,\n className: cn(className, styles.root, open ? styles.open : \"\"),\n ref: mergeRefs(ref, itemRef),\n ...rest,\n };\n // Register with group if present\n useEffect(() => {\n if (!group || isRegistered.current) return;\n isRegistered.current = true;\n setIndex(group.register());\n }, [group]);\n\n return (\n <details {...componentProps}>\n <summary className={cn(className, styles.summary)}>\n {open && highlightOpen && <GlassCard className={styles.highlight} />}\n <div\n {...slotProps.summaryContent}\n className={cn(\n styles.summaryContent,\n slotProps.summaryContent?.className,\n )}\n >\n {summary}\n </div>\n <span {...slotProps.marker} className={cn(styles.marker)}>\n {open ? closeMarker : openMarker}\n </span>\n </summary>\n <div\n {...slotProps.content}\n className={cn(styles.content, slotProps.content?.className)}\n >\n {children}\n </div>\n </details>\n );\n}\nfunction OpenMarkerIcon(props: ComponentProps<\"svg\">) {\n return (\n <svg\n {...props}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n strokeWidth=\"2.3\"\n stroke=\"currentColor\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n );\n}\nfunction CloseMarkerIcon(props: ComponentProps<\"svg\">) {\n return (\n <svg\n {...props}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n strokeWidth=\"2.3\"\n stroke=\"currentColor\"\n >\n <path d=\"m18 15-6-6-6 6\" />\n </svg>\n );\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AA8BM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAC,CAAA,CAAA,CAAA,CAAA,CAAqB,CAAA,CAAA;AACjD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,EACJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CACP,IAAI,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,EACd,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CACR,SAAS,CAAA,CACT,CAAA,CAAA,CAAA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AA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,QAAA,CAAA,CAErBA,CAAAA,CAAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAM,CAAC,CAAA,CAAC,gBAAgB,CAAA,CAAA,CAAG,EAAA,CACvB,CAAA;AAEV;;"}
|
|
1
|
+
{"version":3,"file":"AccordionItem.js","sources":["../../../src/Display/Accordion/AccordionItem.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentProps,\n type ReactNode,\n type ToggleEvent,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { AccordionContext } from \"./Accordion\";\nimport styles from \"./Accordion.module.css\";\nimport { cn, mergeRefs } from \"@studiocubics/utils\";\nimport { GlassCard } from \"../../Cards/GlassCard/GlassCard\";\n\nexport type AccordionProps = {\n summary: ReactNode;\n onToggle?: (e: ToggleEvent<HTMLDetailsElement>, current: boolean) => void;\n openMarker?: ReactNode;\n closeMarker?: ReactNode;\n highlightOpen?: boolean;\n slotProps?: {\n marker?: ComponentProps<\"span\">;\n summary?: ComponentProps<\"summary\">;\n summaryContent?: ComponentProps<\"div\">;\n content?: ComponentProps<\"div\">;\n };\n} & ComponentProps<\"details\">;\n\nexport function AccordionItem(props: AccordionProps) {\n const {\n summary,\n open: htmlOpen,\n children,\n className,\n onToggle,\n highlightOpen = true,\n openMarker = <OpenMarkerIcon />,\n closeMarker = <CloseMarkerIcon />,\n slotProps = {},\n ref,\n ...rest\n } = props;\n\n const [index, setIndex] = useState<number | null>(null);\n const isRegistered = useRef(false);\n const [uncontrolledOpen, setUncontrolledOpen] = useState(!!htmlOpen);\n const itemRef = useRef<HTMLDetailsElement | null>(null);\n const group = useContext(AccordionContext);\n\n const open = group && index !== null ? group.values[index] : uncontrolledOpen;\n\n const handleToggle = async (e: ToggleEvent<HTMLDetailsElement>) => {\n const next = e.currentTarget.open;\n if (group && index !== null) group.update(index, next);\n else setUncontrolledOpen(next);\n onToggle?.(e, next);\n if (next) {\n itemRef.current?.scrollIntoView({\n block: \"nearest\",\n inline: \"nearest\",\n behavior: \"smooth\",\n });\n }\n };\n\n const componentProps = {\n open,\n onToggle: handleToggle,\n className: cn(className, styles.root, open ? styles.open : \"\"),\n ref: mergeRefs(ref, itemRef),\n ...rest,\n };\n // Register with group if present\n useEffect(() => {\n if (!group || isRegistered.current) return;\n isRegistered.current = true;\n setIndex(group.register());\n }, [group]);\n\n return (\n <details {...componentProps}>\n <summary className={cn(className, styles.summary)}>\n {open && highlightOpen && <GlassCard className={styles.highlight} />}\n <div\n {...slotProps.summaryContent}\n className={cn(\n styles.summaryContent,\n slotProps.summaryContent?.className,\n )}\n >\n {summary}\n </div>\n <span {...slotProps.marker} className={cn(styles.marker)}>\n {open ? closeMarker : openMarker}\n </span>\n </summary>\n <div\n {...slotProps.content}\n className={cn(styles.content, slotProps.content?.className)}\n >\n {children}\n </div>\n </details>\n );\n}\nfunction OpenMarkerIcon(props: ComponentProps<\"svg\">) {\n return (\n <svg\n {...props}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n strokeWidth=\"2.3\"\n stroke=\"currentColor\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n );\n}\nfunction CloseMarkerIcon(props: ComponentProps<\"svg\">) {\n return (\n <svg\n {...props}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n strokeWidth=\"2.3\"\n stroke=\"currentColor\"\n >\n <path d=\"m18 15-6-6-6 6\" />\n </svg>\n );\n}\n"],"names":["AccordionItem","props","summary","open","htmlOpen","children","className","onToggle","highlightOpen","openMarker","_jsx","OpenMarkerIcon","closeMarker","CloseMarkerIcon","slotProps","ref","rest","index","setIndex","useState","isRegistered","useRef","uncontrolledOpen","setUncontrolledOpen","itemRef","group","useContext","AccordionContext","values","componentProps","async","e","next","currentTarget","update","current","scrollIntoView","block","inline","behavior","cn","styles","root","mergeRefs","useEffect","register","_jsxs","GlassCard","highlight","summaryContent","marker","content","xmlns","viewBox","fill","strokeWidth","stroke","d"],"mappings":"6VA8BM,SAAUA,EAAcC,GAC5B,MAAMC,QACJA,EACAC,KAAMC,EAAQC,SACdA,EAAQC,UACRA,EAASC,SACTA,EAAQC,cACRA,GAAgB,EAAIC,WACpBA,EAAaC,EAACC,EAAc,CAAA,GAAGC,YAC/BA,EAAcF,EAACG,EAAe,CAAA,GAAGC,UACjCA,EAAY,GAAEC,IACdA,KACGC,GACDf,GAEGgB,EAAOC,GAAYC,EAAwB,MAC5CC,EAAeC,GAAO,IACrBC,EAAkBC,GAAuBJ,IAAWf,GACrDoB,EAAUH,EAAkC,MAC5CI,EAAQC,EAAWC,GAEnBxB,EAAOsB,GAAmB,OAAVR,EAAiBQ,EAAMG,OAAOX,GAASK,EAgBvDO,EAAiB,CACrB1B,OACAI,SAhBmBuB,MAAOC,IAC1B,MAAMC,EAAOD,EAAEE,cAAc9B,KACzBsB,GAAmB,OAAVR,EAAgBQ,EAAMS,OAAOjB,EAAOe,GAC5CT,EAAoBS,GACzBzB,IAAWwB,EAAGC,GACVA,GACFR,EAAQW,SAASC,eAAe,CAC9BC,MAAO,UACPC,OAAQ,UACRC,SAAU,YAQdjC,UAAWkC,EAAGlC,EAAWmC,EAAOC,KAAMvC,EAAOsC,EAAOtC,KAAO,IAC3DY,IAAK4B,EAAU5B,EAAKS,MACjBR,GASL,OANA4B,EAAU,KACHnB,IAASL,EAAae,UAC3Bf,EAAae,SAAU,EACvBjB,EAASO,EAAMoB,cACd,CAACpB,IAGFqB,gBAAajB,EAAcxB,SAAA,CACzByC,aAASxC,UAAWkC,EAAGlC,EAAWmC,EAAOvC,SAAQG,SAAA,CAC9CF,GAAQK,GAAiBE,EAACqC,EAAS,CAACzC,UAAWmC,EAAOO,YACvDtC,YACMI,EAAUmC,eACd3C,UAAWkC,EACTC,EAAOQ,eACPnC,EAAUmC,gBAAgB3C,WAC3BD,SAEAH,IA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