@carbonid1/design-system 6.0.1 → 7.0.1

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.
@@ -2,7 +2,6 @@ import { Dialog as BaseDialog } from '@base-ui/react/dialog';
2
2
  import type { ComponentPropsWithoutRef, Ref } from 'react';
3
3
  type BaseBackdropProps = ComponentPropsWithoutRef<typeof BaseDialog.Backdrop>;
4
4
  type BasePopupProps = ComponentPropsWithoutRef<typeof BaseDialog.Popup>;
5
- type BaseCloseProps = ComponentPropsWithoutRef<typeof BaseDialog.Close>;
6
5
  type BackdropProps = BaseBackdropProps & {
7
6
  ref?: Ref<HTMLDivElement>;
8
7
  };
@@ -12,9 +11,6 @@ type PopupProps = BasePopupProps & {
12
11
  * Set false for bare, transparent content such as a full-bleed media preview. Default true. */
13
12
  surface?: boolean;
14
13
  };
15
- type CloseProps = BaseCloseProps & {
16
- ref?: Ref<HTMLButtonElement>;
17
- };
18
14
  /** Modal/overlay primitive over Base UI Dialog, exposing its compound parts with design-system
19
15
  * styling. Compose `Dialog.Root` → `Dialog.Trigger` + `Dialog.Portal` (holding `Backdrop` + `Popup`).
20
16
  *
@@ -24,7 +20,10 @@ type CloseProps = BaseCloseProps & {
24
20
  *
25
21
  * Placement and size are the caller's job — Base UI's `Popup` isn't self-positioning. Position it
26
22
  * with `fixed` + a translate, and bound a surface panel's width (e.g. `w-[calc(100%-2rem)] max-w-md`)
27
- * so it can't overflow narrow viewports. */
23
+ * so it can't overflow narrow viewports.
24
+ *
25
+ * `Trigger` and `Close` supply behavior without appearance. Compose them through `render` with a
26
+ * `Button` or another appropriate interactive element. */
28
27
  export declare const Dialog: {
29
28
  Root: typeof BaseDialog.Root;
30
29
  Trigger: BaseDialog.Trigger;
@@ -34,6 +33,6 @@ export declare const Dialog: {
34
33
  Viewport: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").AlertDialogViewportProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
35
34
  Title: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").AlertDialogTitleProps, "ref"> & import("react").RefAttributes<HTMLHeadingElement>>;
36
35
  Description: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").AlertDialogDescriptionProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
37
- Close: ({ className, ...props }: CloseProps) => import("react/jsx-runtime").JSX.Element;
36
+ Close: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").AlertDialogCloseProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
38
37
  };
39
38
  export {};
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Dialog as BaseDialog } from '@base-ui/react/dialog';
4
- import { buttonVariants } from '../Button/Button';
5
4
  import { cn } from '../helpers/cn/cn';
6
5
  import { mergeStatefulClassName } from '../helpers/mergeStatefulClassName/mergeStatefulClassName';
7
6
  // Backdrop and popup fade share one duration so the scrim and the modal resolve together. Placement
@@ -12,7 +11,6 @@ const popupBaseClasses = 'outline-hidden z-50 transition-opacity duration-200 da
12
11
  const popupSurfaceClasses = 'bg-popover text-popover-foreground shadow-popover border-border rounded-xl border';
13
12
  const Backdrop = ({ className, ...props }) => (_jsx(BaseDialog.Backdrop, { className: mergeStatefulClassName(backdropClasses, className), ...props }));
14
13
  const Popup = ({ className, surface = true, ...props }) => (_jsx(BaseDialog.Popup, { className: mergeStatefulClassName(cn(popupBaseClasses, surface && popupSurfaceClasses), className), ...props }));
15
- const Close = ({ className, ...props }) => (_jsx(BaseDialog.Close, { className: mergeStatefulClassName(buttonVariants({ variant: 'ghost', size: 'icon' }), className), ...props }));
16
14
  /** Modal/overlay primitive over Base UI Dialog, exposing its compound parts with design-system
17
15
  * styling. Compose `Dialog.Root` → `Dialog.Trigger` + `Dialog.Portal` (holding `Backdrop` + `Popup`).
18
16
  *
@@ -22,7 +20,10 @@ const Close = ({ className, ...props }) => (_jsx(BaseDialog.Close, { className:
22
20
  *
23
21
  * Placement and size are the caller's job — Base UI's `Popup` isn't self-positioning. Position it
24
22
  * with `fixed` + a translate, and bound a surface panel's width (e.g. `w-[calc(100%-2rem)] max-w-md`)
25
- * so it can't overflow narrow viewports. */
23
+ * so it can't overflow narrow viewports.
24
+ *
25
+ * `Trigger` and `Close` supply behavior without appearance. Compose them through `render` with a
26
+ * `Button` or another appropriate interactive element. */
26
27
  export const Dialog = {
27
28
  Root: BaseDialog.Root,
28
29
  Trigger: BaseDialog.Trigger,
@@ -32,5 +33,5 @@ export const Dialog = {
32
33
  Viewport: BaseDialog.Viewport,
33
34
  Title: BaseDialog.Title,
34
35
  Description: BaseDialog.Description,
35
- Close,
36
+ Close: BaseDialog.Close,
36
37
  };
@@ -0,0 +1,20 @@
1
+ import type { ElementType } from 'react';
2
+ import type { ItemActionsProps, ItemContentProps, ItemDescriptionProps, ItemMediaProps, ItemRootProps, ItemTitleProps } from './Item.types';
3
+ declare const itemVariants: (props?: ({
4
+ surface?: "outline" | "raised" | "plain" | "inset" | null | undefined;
5
+ interactive?: boolean | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ /**
8
+ * One member of a collection. `Item` supplies static structure and surface styling only:
9
+ * callers keep native list markup and attach link, button, or disclosure behavior to the
10
+ * appropriate owner. `interactive` adds visual feedback without adding semantics or handlers.
11
+ */
12
+ export declare const Item: {
13
+ Root: <E extends ElementType = "div">({ as, className, surface, interactive, ...props }: ItemRootProps<E>) => import("react/jsx-runtime").JSX.Element;
14
+ Media: ({ className, ...props }: ItemMediaProps) => import("react/jsx-runtime").JSX.Element;
15
+ Content: ({ className, ...props }: ItemContentProps) => import("react/jsx-runtime").JSX.Element;
16
+ Title: ({ className, ...props }: ItemTitleProps) => import("react/jsx-runtime").JSX.Element;
17
+ Description: ({ className, ...props }: ItemDescriptionProps) => import("react/jsx-runtime").JSX.Element;
18
+ Actions: ({ className, ...props }: ItemActionsProps) => import("react/jsx-runtime").JSX.Element;
19
+ };
20
+ export { itemVariants };
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cva } from 'class-variance-authority';
3
+ import { cn } from '../helpers/cn/cn';
4
+ const itemVariants = cva('min-w-0 rounded-lg', {
5
+ variants: {
6
+ surface: {
7
+ plain: 'bg-transparent',
8
+ raised: 'bg-card shadow-card',
9
+ inset: 'bg-surface-inset inset-shadow-surface',
10
+ outline: 'border-border border bg-transparent',
11
+ },
12
+ interactive: {
13
+ true: 'outline-hidden hover:bg-accent focus-within:bg-accent focus-visible:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 dark:hover:bg-accent/50 dark:focus-within:bg-accent/50 dark:focus-visible:bg-accent/50 forced-colors:focus-visible:ring-0 forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-offset-2 forced-colors:focus-visible:outline-[Highlight]',
14
+ false: '',
15
+ },
16
+ },
17
+ defaultVariants: {
18
+ surface: 'plain',
19
+ interactive: false,
20
+ },
21
+ });
22
+ const Root = ({ as, className, surface = 'plain', interactive = false, ...props }) => {
23
+ const Component = (as ?? 'div');
24
+ return (_jsx(Component, { "data-slot": "item", className: cn('flex items-center gap-3 p-3', itemVariants({ surface, interactive }), className), ...props }));
25
+ };
26
+ const Media = ({ className, ...props }) => (_jsx("div", { "data-slot": "item-media", className: cn('flex shrink-0 items-center justify-center', className), ...props }));
27
+ const Content = ({ className, ...props }) => (_jsx("div", { "data-slot": "item-content", className: cn('flex min-w-0 flex-1 flex-col gap-1', className), ...props }));
28
+ const Title = ({ className, ...props }) => (_jsx("div", { "data-slot": "item-title", className: cn('text-sm leading-snug font-medium', className), ...props }));
29
+ const Description = ({ className, ...props }) => (_jsx("div", { "data-slot": "item-description", className: cn('text-muted-foreground text-sm leading-normal', className), ...props }));
30
+ const Actions = ({ className, ...props }) => (_jsx("div", { "data-slot": "item-actions", className: cn('flex shrink-0 items-center gap-2', className), ...props }));
31
+ /**
32
+ * One member of a collection. `Item` supplies static structure and surface styling only:
33
+ * callers keep native list markup and attach link, button, or disclosure behavior to the
34
+ * appropriate owner. `interactive` adds visual feedback without adding semantics or handlers.
35
+ */
36
+ export const Item = {
37
+ Root,
38
+ Media,
39
+ Content,
40
+ Title,
41
+ Description,
42
+ Actions,
43
+ };
44
+ export { itemVariants };
@@ -0,0 +1,21 @@
1
+ import type { ComponentPropsWithoutRef, ElementType } from 'react';
2
+ import type { VariantProps } from 'class-variance-authority';
3
+ import type { itemVariants } from './Item';
4
+ type ItemRootOwnProps<E extends ElementType = 'div'> = VariantProps<typeof itemVariants> & {
5
+ /** Override the rendered element while preserving its native props. Defaults to `div`. */
6
+ as?: E;
7
+ className?: string;
8
+ };
9
+ /**
10
+ * Props for `Item.Root`. `surface` controls elevation; `interactive` adds hover and visible-focus
11
+ * styling but never supplies behavior, roles, handlers, or focusability.
12
+ */
13
+ type ItemRootProps<E extends ElementType = 'div'> = ItemRootOwnProps<E> & Omit<ComponentPropsWithoutRef<E>, keyof ItemRootOwnProps<E>>;
14
+ /** Concrete root props for contexts that need a fixed default element, such as Storybook args. */
15
+ type ItemRootPropsDefault = ItemRootProps<'div'>;
16
+ type ItemMediaProps = ComponentPropsWithoutRef<'div'>;
17
+ type ItemContentProps = ComponentPropsWithoutRef<'div'>;
18
+ type ItemTitleProps = ComponentPropsWithoutRef<'div'>;
19
+ type ItemDescriptionProps = ComponentPropsWithoutRef<'div'>;
20
+ type ItemActionsProps = ComponentPropsWithoutRef<'div'>;
21
+ export type { ItemActionsProps, ItemContentProps, ItemDescriptionProps, ItemMediaProps, ItemRootProps, ItemRootPropsDefault, ItemTitleProps, };
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -11,6 +11,8 @@ export { InputGroup } from './InputGroup/InputGroup';
11
11
  export type { InputGroupActionProps, InputGroupControlProps, InputGroupRootProps, } from './InputGroup/InputGroup.types';
12
12
  export { Card, cardVariants } from './Card/Card';
13
13
  export type { CardActionProps, CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardRootProps, CardTitleProps, } from './Card/Card.types';
14
+ export { Item, itemVariants } from './Item/Item';
15
+ export type { ItemActionsProps, ItemContentProps, ItemDescriptionProps, ItemMediaProps, ItemRootProps, ItemRootPropsDefault, ItemTitleProps, } from './Item/Item.types';
14
16
  export { Kbd, kbdVariants } from './Kbd/Kbd';
15
17
  export type { KbdProps } from './Kbd/Kbd.types';
16
18
  export { Text, textVariants } from './Text/Text';
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ export { Input } from './Input/Input';
5
5
  export { Field } from './Field/Field';
6
6
  export { InputGroup } from './InputGroup/InputGroup';
7
7
  export { Card, cardVariants } from './Card/Card';
8
+ export { Item, itemVariants } from './Item/Item';
8
9
  export { Kbd, kbdVariants } from './Kbd/Kbd';
9
10
  export { Text, textVariants } from './Text/Text';
10
11
  export { ProgressRing } from './ProgressRing/ProgressRing';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonid1/design-system",
3
- "version": "6.0.1",
3
+ "version": "7.0.1",
4
4
  "description": "Shared React UI primitives + design tokens (themes, postcss config)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,6 +53,7 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@base-ui/react": "^1.6.0",
56
+ "@storybook/addon-a11y": "^10.3.5",
56
57
  "@storybook/addon-docs": "^10.3.5",
57
58
  "@storybook/addon-mcp": "^0.6.0",
58
59
  "@storybook/addon-themes": "^10.3.5",
@@ -59,6 +59,16 @@ application components that must retain their own design-system styling.
59
59
  ## Buttons & links
60
60
 
61
61
  - **Active/selected state** — pass `selected` (toolbar toggles, segmented controls, filter chips, tabs, nav links). It applies the selection tokens (`bg-primary/10` + `ring-1 ring-primary/20`, tint held on hover); never hand-layer those classes. `selected` is visual only — set the matching ARIA yourself: `aria-pressed` on toggle buttons, `aria-current` on nav links. It rides both `Button` and `buttonVariants(...)`.
62
+ - **Dialog actions** — `Dialog.Trigger` and `Dialog.Close` supply behavior, not button appearance. Compose a `Button` through `render` so one component owns the complete visual contract; don't attach `buttonVariants(...)` to the behavior primitive.
63
+ ```tsx
64
+ <Dialog.Close
65
+ render={
66
+ <Button variant="ghost" size="small">
67
+ Cancel
68
+ </Button>
69
+ }
70
+ />
71
+ ```
62
72
  - **A link that looks like a button** — apply `buttonVariants({ variant, size, selected })` to the `Link`, not `<Button render={<Link/>}>`. Base UI's `Button` is button-semantic: rendering an `<a>` through it either warns or forces `role="button"`, which breaks navigation for screen readers. Keep the element a real link and style it:
63
73
  ```tsx
64
74
  <Link