@carbonid1/design-system 5.16.1 → 5.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,8 @@ import type { ButtonProps } from './Button.types';
2
2
  declare const buttonVariants: (props?: ({
3
3
  variant?: "primary" | "attention" | "destructive" | "link" | "ghost" | "outline" | "subtle" | "danger" | null | undefined;
4
4
  size?: "default" | "small" | "large" | "icon" | "smallIcon" | "largeIcon" | null | undefined;
5
+ contentSpacing?: "default" | "relaxed" | null | undefined;
5
6
  selected?: boolean | null | undefined;
6
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
- declare const Button: ({ className, variant, size, selected, fullWidth, loading, disabled, children, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
8
+ declare const Button: ({ className, variant, size, contentSpacing, selected, fullWidth, loading, disabled, children, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
8
9
  export { Button, buttonVariants };
@@ -4,7 +4,7 @@ import { cn } from '../helpers/cn/cn';
4
4
  import { Button as ButtonPrimitive } from '@base-ui/react/button';
5
5
  import { cva } from 'class-variance-authority';
6
6
  import { Loader2 } from 'lucide-react';
7
- const buttonVariants = cva("group/button inline-flex shrink-0 items-center justify-center gap-2 rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-hidden select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
7
+ const buttonVariants = cva("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-[color,background-color,opacity,transform] outline-hidden select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
8
8
  variants: {
9
9
  variant: {
10
10
  ghost: 'hover:bg-accent aria-expanded:bg-accent dark:hover:bg-accent/50',
@@ -17,19 +17,38 @@ const buttonVariants = cva("group/button inline-flex shrink-0 items-center justi
17
17
  link: 'text-primary underline-offset-4 hover:underline',
18
18
  },
19
19
  size: {
20
- small: 'h-7 gap-1 px-2.5 text-[0.8rem]',
21
- default: 'h-8 gap-1.5 px-2.5',
22
- large: 'h-9 gap-1.5 px-3',
20
+ small: 'h-7 px-2.5 text-[0.8rem]',
21
+ default: 'h-8 px-2.5',
22
+ large: 'h-9 px-3',
23
23
  icon: 'size-8 rounded-full',
24
24
  smallIcon: 'size-6 rounded-full',
25
25
  largeIcon: 'size-12 rounded-full',
26
26
  },
27
+ contentSpacing: {
28
+ default: '',
29
+ relaxed: 'gap-2',
30
+ },
27
31
  selected: {
28
32
  true: 'bg-primary/10 ring-1 ring-primary/20',
29
33
  false: '',
30
34
  },
31
35
  },
32
36
  compoundVariants: [
37
+ {
38
+ contentSpacing: 'default',
39
+ size: 'small',
40
+ className: 'gap-1',
41
+ },
42
+ {
43
+ contentSpacing: 'default',
44
+ size: 'default',
45
+ className: 'gap-1.5',
46
+ },
47
+ {
48
+ contentSpacing: 'default',
49
+ size: 'large',
50
+ className: 'gap-1.5',
51
+ },
33
52
  // Hold the selection tint on hover instead of letting the variant's own hover background win.
34
53
  {
35
54
  selected: true,
@@ -45,8 +64,9 @@ const buttonVariants = cva("group/button inline-flex shrink-0 items-center justi
45
64
  defaultVariants: {
46
65
  variant: 'ghost',
47
66
  size: 'default',
67
+ contentSpacing: 'default',
48
68
  selected: false,
49
69
  },
50
70
  });
51
- const Button = ({ className, variant, size, selected, fullWidth, loading, disabled, children, ...props }) => (_jsxs(ButtonPrimitive, { "data-slot": "button", className: cn(buttonVariants({ variant, size, selected }), fullWidth && 'w-full justify-start', className), disabled: disabled ?? loading, "aria-busy": loading ?? undefined, ...props, children: [loading && _jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }), children] }));
71
+ const Button = ({ className, variant, size, contentSpacing, selected, fullWidth, loading, disabled, children, ...props }) => (_jsxs(ButtonPrimitive, { "data-slot": "button", className: cn(buttonVariants({ variant, size, contentSpacing, selected }), fullWidth && 'w-full justify-start', className), disabled: disabled ?? loading, "aria-busy": loading ?? undefined, ...props, children: [loading && _jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" }), children] }));
52
72
  export { Button, buttonVariants };
@@ -0,0 +1,3 @@
1
+ import type { InputProps } from './Input.types';
2
+ declare const Input: ({ className, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
3
+ export { Input };
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Input as BaseInput } from '@base-ui/react/input';
4
+ import { cn } from '../helpers/cn/cn';
5
+ const Input = ({ className, ...props }) => (_jsx(BaseInput, { ...props, "data-slot": "input", className: cn('border-input-border bg-surface-inset inset-shadow-surface text-foreground placeholder:text-muted-foreground h-9 w-full min-w-0 rounded-lg border px-3 py-1 text-sm outline-hidden dark:inset-shadow-none', 'enabled:hover:border-ring', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3', '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]', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 aria-invalid:ring-3', className) }));
6
+ export { Input };
@@ -0,0 +1,3 @@
1
+ import type { Input as BaseInput } from '@base-ui/react/input';
2
+ type InputProps = BaseInput.Props;
3
+ export type { InputProps };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { InputGroupActionProps, InputGroupControlProps, InputGroupRootProps } from './InputGroup.types';
2
+ export declare const InputGroup: {
3
+ Root: ({ className, onPointerDown, ...props }: InputGroupRootProps) => import("react/jsx-runtime").JSX.Element;
4
+ Control: ({ className, ...props }: InputGroupControlProps) => import("react/jsx-runtime").JSX.Element;
5
+ Action: ({ className, variant, size, replacesNativePicker, ...props }: InputGroupActionProps) => import("react/jsx-runtime").JSX.Element;
6
+ };
@@ -0,0 +1,27 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Input as BaseInput } from '@base-ui/react/input';
4
+ import { Button } from '../Button/Button';
5
+ import { cn } from '../helpers/cn/cn';
6
+ const Root = ({ className, onPointerDown, ...props }) => {
7
+ const focusControlFromShell = (event) => {
8
+ onPointerDown?.(event);
9
+ if (event.defaultPrevented || event.button !== 0 || event.target !== event.currentTarget)
10
+ return;
11
+ event.preventDefault();
12
+ event.currentTarget
13
+ .querySelector('[data-slot="input-group-control"]')
14
+ ?.focus();
15
+ };
16
+ return (_jsx("div", { ...props, "data-slot": "input-group", onPointerDown: focusControlFromShell, className: cn('border-input-border bg-surface-inset inset-shadow-surface flex min-h-11 w-full min-w-0 items-center gap-1 rounded-lg border p-2 dark:inset-shadow-none', 'has-[[data-slot=input-group-control]:enabled]:hover:border-ring', 'has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-3', 'has-[[data-slot=input-group-control][aria-invalid=true]]:border-destructive has-[[data-slot=input-group-control][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot=input-group-control][aria-invalid=true]]:border-destructive/50 dark:has-[[data-slot=input-group-control][aria-invalid=true]]:ring-destructive/40 has-[[data-slot=input-group-control][aria-invalid=true]]:ring-3', 'forced-colors:has-[[data-slot=input-group-control]:focus-visible]:ring-0 forced-colors:has-[[data-slot=input-group-control]:focus-visible]:outline-2 forced-colors:has-[[data-slot=input-group-control]:focus-visible]:outline-offset-2 forced-colors:has-[[data-slot=input-group-control]:focus-visible]:outline-[Highlight]', '[&:has([data-native-picker-action])_[data-slot=input-group-control]::-webkit-calendar-picker-indicator]:hidden', className) }));
17
+ };
18
+ const Control = ({ className, ...props }) => (_jsx(BaseInput, { ...props, "data-slot": "input-group-control", className: cn('text-foreground placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent px-2 py-1 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50 forced-colors:focus-visible:outline-none', className) }));
19
+ const Action = ({ className, variant = 'subtle', size = 'icon', replacesNativePicker = false, ...props }) => (_jsx(Button, { ...props, "data-slot": "input-group-action", "data-native-picker-action": replacesNativePicker ? '' : undefined, variant: variant, size: size, className: cn('rounded-md',
20
+ // Firefox does not expose its native date indicator to author CSS, so it keeps that
21
+ // affordance and omits the replacement action instead of rendering two calendar buttons.
22
+ replacesNativePicker && 'supports-[-moz-appearance:none]:hidden', className) }));
23
+ export const InputGroup = {
24
+ Root,
25
+ Control,
26
+ Action,
27
+ };
@@ -0,0 +1,10 @@
1
+ import type { Input as BaseInput } from '@base-ui/react/input';
2
+ import type { ComponentPropsWithoutRef } from 'react';
3
+ import type { ButtonProps } from '../Button/Button.types';
4
+ type InputGroupRootProps = ComponentPropsWithoutRef<'div'>;
5
+ type InputGroupControlProps = BaseInput.Props;
6
+ type InputGroupActionProps = ButtonProps & {
7
+ /** Replaces the native date affordance where the browser lets author CSS hide it. */
8
+ replacesNativePicker?: boolean;
9
+ };
10
+ export type { InputGroupActionProps, InputGroupControlProps, InputGroupRootProps };
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -3,6 +3,10 @@ export { Badge, badgeVariants } from './Badge/Badge';
3
3
  export type { BadgeProps } from './Badge/Badge.types';
4
4
  export { Button, buttonVariants } from './Button/Button';
5
5
  export type { ButtonProps } from './Button/Button.types';
6
+ export { Input } from './Input/Input';
7
+ export type { InputProps } from './Input/Input.types';
8
+ export { InputGroup } from './InputGroup/InputGroup';
9
+ export type { InputGroupActionProps, InputGroupControlProps, InputGroupRootProps, } from './InputGroup/InputGroup.types';
6
10
  export { Card, cardVariants } from './Card/Card';
7
11
  export type { CardActionProps, CardContentProps, CardDescriptionProps, CardFooterProps, CardHeaderProps, CardRootProps, CardTitleProps, } from './Card/Card.types';
8
12
  export { Kbd, kbdVariants } from './Kbd/Kbd';
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { HotkeysProvider as HotkeysProviderHook, isHotkeyPressed as isHotkeyPressedHook, useHotkeys as useHotkeysHook, useHotkeysContext as useHotkeysContextHook, useRecordHotkeys as useRecordHotkeysHook, } from 'react-hotkeys-hook';
2
2
  export { Badge, badgeVariants } from './Badge/Badge';
3
3
  export { Button, buttonVariants } from './Button/Button';
4
+ export { Input } from './Input/Input';
5
+ export { InputGroup } from './InputGroup/InputGroup';
4
6
  export { Card, cardVariants } from './Card/Card';
5
7
  export { Kbd, kbdVariants } from './Kbd/Kbd';
6
8
  export { Text, textVariants } from './Text/Text';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carbonid1/design-system",
3
- "version": "5.16.1",
3
+ "version": "5.18.0",
4
4
  "description": "Shared React UI primitives + design tokens (themes, postcss config)",
5
5
  "repository": {
6
6
  "type": "git",