@becket-ui/react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/components/Badge.d.ts +22 -0
- package/dist/components/Badge.d.ts.map +1 -0
- package/dist/components/Badge.js +39 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Button.d.ts +24 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Button.js +46 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/Button.test.js +45 -0
- package/dist/components/Button.test.js.map +1 -0
- package/dist/components/Card.d.ts +37 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Card.js +75 -0
- package/dist/components/Card.js.map +1 -0
- package/dist/components/Checkbox.d.ts +14 -0
- package/dist/components/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox.js +46 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/Dialog.d.ts +41 -0
- package/dist/components/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog.js +173 -0
- package/dist/components/Dialog.js.map +1 -0
- package/dist/components/Dialog.test.js +89 -0
- package/dist/components/Dialog.test.js.map +1 -0
- package/dist/components/Drawer.d.ts +38 -0
- package/dist/components/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer.js +174 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/Drawer.test.js +50 -0
- package/dist/components/Drawer.test.js.map +1 -0
- package/dist/components/Field.d.ts +37 -0
- package/dist/components/Field.d.ts.map +1 -0
- package/dist/components/Field.js +186 -0
- package/dist/components/Field.js.map +1 -0
- package/dist/components/Field.test.js +33 -0
- package/dist/components/Field.test.js.map +1 -0
- package/dist/components/Flex.d.ts +38 -0
- package/dist/components/Flex.d.ts.map +1 -0
- package/dist/components/Flex.js +85 -0
- package/dist/components/Flex.js.map +1 -0
- package/dist/components/Heading.d.ts +14 -0
- package/dist/components/Heading.d.ts.map +1 -0
- package/dist/components/Heading.js +33 -0
- package/dist/components/Heading.js.map +1 -0
- package/dist/components/Hide.d.ts +39 -0
- package/dist/components/Hide.d.ts.map +1 -0
- package/dist/components/Hide.js +51 -0
- package/dist/components/Hide.js.map +1 -0
- package/dist/components/Link.d.ts +14 -0
- package/dist/components/Link.d.ts.map +1 -0
- package/dist/components/Link.js +23 -0
- package/dist/components/Link.js.map +1 -0
- package/dist/components/Menu.d.ts +11 -0
- package/dist/components/Menu.d.ts.map +1 -0
- package/dist/components/Menu.js +132 -0
- package/dist/components/Menu.js.map +1 -0
- package/dist/components/Menu.test.js +69 -0
- package/dist/components/Menu.test.js.map +1 -0
- package/dist/components/Radio.d.ts +38 -0
- package/dist/components/Radio.d.ts.map +1 -0
- package/dist/components/Radio.js +144 -0
- package/dist/components/Radio.js.map +1 -0
- package/dist/components/Select.d.ts +17 -0
- package/dist/components/Select.d.ts.map +1 -0
- package/dist/components/Select.js +33 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Separator.d.ts +14 -0
- package/dist/components/Separator.d.ts.map +1 -0
- package/dist/components/Separator.js +25 -0
- package/dist/components/Separator.js.map +1 -0
- package/dist/components/SimpleGrid.d.ts +26 -0
- package/dist/components/SimpleGrid.d.ts.map +1 -0
- package/dist/components/SimpleGrid.js +98 -0
- package/dist/components/SimpleGrid.js.map +1 -0
- package/dist/components/Spinner.d.ts +10 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +25 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Stack.d.ts +32 -0
- package/dist/components/Stack.d.ts.map +1 -0
- package/dist/components/Stack.js +81 -0
- package/dist/components/Stack.js.map +1 -0
- package/dist/components/Switch.d.ts +20 -0
- package/dist/components/Switch.d.ts.map +1 -0
- package/dist/components/Switch.js +83 -0
- package/dist/components/Switch.js.map +1 -0
- package/dist/components/Switch.test.js +28 -0
- package/dist/components/Switch.test.js.map +1 -0
- package/dist/components/Table.d.ts +23 -0
- package/dist/components/Table.d.ts.map +1 -0
- package/dist/components/Table.js +90 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/Tabs.d.ts +21 -0
- package/dist/components/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs.js +140 -0
- package/dist/components/Tabs.js.map +1 -0
- package/dist/components/Tabs.test.js +41 -0
- package/dist/components/Tabs.test.js.map +1 -0
- package/dist/components/Tag.d.ts +22 -0
- package/dist/components/Tag.d.ts.map +1 -0
- package/dist/components/Tag.js +39 -0
- package/dist/components/Tag.js.map +1 -0
- package/dist/components/Text.d.ts +9 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/Text.js +18 -0
- package/dist/components/Text.js.map +1 -0
- package/dist/components/TextField.d.ts +19 -0
- package/dist/components/TextField.d.ts.map +1 -0
- package/dist/components/TextField.js +32 -0
- package/dist/components/TextField.js.map +1 -0
- package/dist/components/Textarea.d.ts +17 -0
- package/dist/components/Textarea.d.ts.map +1 -0
- package/dist/components/Textarea.js +34 -0
- package/dist/components/Textarea.js.map +1 -0
- package/dist/components/Tooltip.d.ts +17 -0
- package/dist/components/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip.js +217 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/Tooltip.test.js +58 -0
- package/dist/components/Tooltip.test.js.map +1 -0
- package/dist/helpers/gradientBorder.d.ts +5 -0
- package/dist/helpers/gradientBorder.d.ts.map +1 -0
- package/dist/helpers/gradientBorder.js +25 -0
- package/dist/helpers/gradientBorder.js.map +1 -0
- package/dist/helpers/labelColors.d.ts +17 -0
- package/dist/helpers/labelColors.d.ts.map +1 -0
- package/dist/helpers/labelColors.js +54 -0
- package/dist/helpers/labelColors.js.map +1 -0
- package/dist/helpers/nativeDialog.d.ts +23 -0
- package/dist/helpers/nativeDialog.d.ts.map +1 -0
- package/dist/helpers/nativeDialog.js +85 -0
- package/dist/helpers/nativeDialog.js.map +1 -0
- package/dist/helpers/responsive.d.ts +63 -0
- package/dist/helpers/responsive.d.ts.map +1 -0
- package/dist/helpers/responsive.js +78 -0
- package/dist/helpers/responsive.js.map +1 -0
- package/dist/helpers/storybookControls.d.ts +16 -0
- package/dist/helpers/storybookControls.d.ts.map +1 -0
- package/dist/helpers/storybookControls.js +40 -0
- package/dist/helpers/storybookControls.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -0
- package/dist/index.js.map +1 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kolmena de Software
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ElementType } from 'react';
|
|
2
|
+
import { type LabelCustomColors, type LabelVisual } from '../helpers/labelColors';
|
|
3
|
+
type BadgeSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
type BadgeBorderRadius = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
5
|
+
export type BadgeProps = ComponentPropsWithoutRef<'span'> & {
|
|
6
|
+
size?: BadgeSize;
|
|
7
|
+
visual?: LabelVisual;
|
|
8
|
+
borderRadius?: BadgeBorderRadius;
|
|
9
|
+
withGradient?: boolean;
|
|
10
|
+
customColors?: LabelCustomColors;
|
|
11
|
+
as?: ElementType;
|
|
12
|
+
};
|
|
13
|
+
export declare const Badge: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
14
|
+
size?: BadgeSize;
|
|
15
|
+
visual?: LabelVisual;
|
|
16
|
+
borderRadius?: BadgeBorderRadius;
|
|
17
|
+
withGradient?: boolean;
|
|
18
|
+
customColors?: LabelCustomColors;
|
|
19
|
+
as?: ElementType;
|
|
20
|
+
} & import("react").RefAttributes<HTMLSpanElement>>;
|
|
21
|
+
export type { LabelCustomColors, LabelVisual };
|
|
22
|
+
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,wBAAwB,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpF,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EACjB,MAAM,wBAAwB,CAAC;AAEhC,KAAK,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACpC,KAAK,iBAAiB,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAErE,MAAM,MAAM,UAAU,GAAG,wBAAwB,CAAC,MAAM,CAAC,GAAG;IAC1D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,EAAE,CAAC,EAAE,WAAW,CAAC;CAClB,CAAC;AAMF,eAAO,MAAM,KAAK;WAZT,SAAS;aACP,WAAW;mBACL,iBAAiB;mBACjB,OAAO;mBACP,iBAAiB;SAC3B,WAAW;mDAkCjB,CAAC;AAIF,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { badge } from "@becket-ui/tokens/recipes";
|
|
4
|
+
import {
|
|
5
|
+
resolveLabelColorVars
|
|
6
|
+
} from "../helpers/labelColors";
|
|
7
|
+
function mergeClassName(...classes) {
|
|
8
|
+
return classes.filter(Boolean).join(" ");
|
|
9
|
+
}
|
|
10
|
+
const Badge = forwardRef(
|
|
11
|
+
({
|
|
12
|
+
size = "md",
|
|
13
|
+
visual = "neutral",
|
|
14
|
+
borderRadius = "full",
|
|
15
|
+
withGradient = false,
|
|
16
|
+
customColors,
|
|
17
|
+
as: Component = "span",
|
|
18
|
+
className,
|
|
19
|
+
style,
|
|
20
|
+
...props
|
|
21
|
+
}, ref) => {
|
|
22
|
+
const recipeClassName = badge({ size, visual, borderRadius, withGradient });
|
|
23
|
+
const colorVars = resolveLabelColorVars(visual, withGradient, customColors);
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
Component,
|
|
26
|
+
{
|
|
27
|
+
ref,
|
|
28
|
+
...props,
|
|
29
|
+
style: { ...colorVars, ...style },
|
|
30
|
+
className: mergeClassName(recipeClassName, className)
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
Badge.displayName = "Badge";
|
|
36
|
+
export {
|
|
37
|
+
Badge
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=Badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Badge.tsx"],"sourcesContent":["import { forwardRef, type ComponentPropsWithoutRef, type ElementType } from 'react';\nimport { badge } from '@becket-ui/tokens/recipes';\n\nimport {\n resolveLabelColorVars,\n type LabelCustomColors,\n type LabelVisual,\n} from '../helpers/labelColors';\n\ntype BadgeSize = 'sm' | 'md' | 'lg';\ntype BadgeBorderRadius = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';\n\nexport type BadgeProps = ComponentPropsWithoutRef<'span'> & {\n size?: BadgeSize;\n visual?: LabelVisual;\n borderRadius?: BadgeBorderRadius;\n withGradient?: boolean;\n customColors?: LabelCustomColors;\n as?: ElementType;\n};\n\nfunction mergeClassName(...classes: (string | undefined)[]): string {\n return classes.filter(Boolean).join(' ');\n}\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(\n (\n {\n size = 'md',\n visual = 'neutral',\n borderRadius = 'full',\n withGradient = false,\n customColors,\n as: Component = 'span',\n className,\n style,\n ...props\n },\n ref,\n ) => {\n const recipeClassName = badge({ size, visual, borderRadius, withGradient });\n const colorVars = resolveLabelColorVars(visual, withGradient, customColors);\n\n return (\n <Component\n ref={ref}\n {...props}\n style={{ ...colorVars, ...style }}\n className={mergeClassName(recipeClassName, className)}\n />\n );\n },\n);\n\nBadge.displayName = 'Badge';\n\nexport type { LabelCustomColors, LabelVisual };\n"],"mappings":"AA4CM;AA5CN,SAAS,kBAAmE;AAC5E,SAAS,aAAa;AAEtB;AAAA,EACE;AAAA,OAGK;AAcP,SAAS,kBAAkB,SAAyC;AAClE,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG;AACzC;AAEO,MAAM,QAAQ;AAAA,EACnB,CACE;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA,IACT,eAAe;AAAA,IACf,eAAe;AAAA,IACf;AAAA,IACA,IAAI,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,kBAAkB,MAAM,EAAE,MAAM,QAAQ,cAAc,aAAa,CAAC;AAC1E,UAAM,YAAY,sBAAsB,QAAQ,cAAc,YAAY;AAE1E,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACC,GAAG;AAAA,QACJ,OAAO,EAAE,GAAG,WAAW,GAAG,MAAM;AAAA,QAChC,WAAW,eAAe,iBAAiB,SAAS;AAAA;AAAA,IACtD;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
type ButtonVisual = 'outline' | 'primary' | 'secondary' | 'neutral';
|
|
3
|
+
type ButtonSize = 'sm' | 'md';
|
|
4
|
+
type ButtonBorderRadius = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
5
|
+
export type ButtonProps = React.ComponentPropsWithoutRef<'button'> & {
|
|
6
|
+
visual?: ButtonVisual;
|
|
7
|
+
size?: ButtonSize;
|
|
8
|
+
borderRadius?: ButtonBorderRadius;
|
|
9
|
+
withGradient?: boolean;
|
|
10
|
+
/** Stretch to the parent width. Default is token `sizes.field` (12.5rem). */
|
|
11
|
+
fullWidth?: boolean;
|
|
12
|
+
as?: ElementType;
|
|
13
|
+
};
|
|
14
|
+
export declare const Button: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
15
|
+
visual?: ButtonVisual;
|
|
16
|
+
size?: ButtonSize;
|
|
17
|
+
borderRadius?: ButtonBorderRadius;
|
|
18
|
+
withGradient?: boolean;
|
|
19
|
+
/** Stretch to the parent width. Default is token `sizes.field` (12.5rem). */
|
|
20
|
+
fullWidth?: boolean;
|
|
21
|
+
as?: ElementType;
|
|
22
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGzC,KAAK,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AACpE,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9B,KAAK,kBAAkB,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAStE,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IACnE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,EAAE,CAAC,EAAE,WAAW,CAAC;CAClB,CAAC;AAMF,eAAO,MAAM,MAAM;aAbR,YAAY;WACd,UAAU;mBACF,kBAAkB;mBAClB,OAAO;IACtB,6EAA6E;gBACjE,OAAO;SACd,WAAW;qDAsCjB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { button } from "@becket-ui/tokens/recipes";
|
|
4
|
+
const VISUAL_TO_RECIPE = {
|
|
5
|
+
primary: "primary",
|
|
6
|
+
secondary: "secondary",
|
|
7
|
+
neutral: "neutral",
|
|
8
|
+
outline: "outline"
|
|
9
|
+
};
|
|
10
|
+
function mergeClassName(...classes) {
|
|
11
|
+
return classes.filter(Boolean).join(" ");
|
|
12
|
+
}
|
|
13
|
+
const Button = forwardRef(
|
|
14
|
+
({
|
|
15
|
+
visual = "outline",
|
|
16
|
+
size = "md",
|
|
17
|
+
borderRadius = "md",
|
|
18
|
+
withGradient = false,
|
|
19
|
+
fullWidth = false,
|
|
20
|
+
as: ButtonComponent = "button",
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}, ref) => {
|
|
24
|
+
const recipeClassName = button({
|
|
25
|
+
visual: VISUAL_TO_RECIPE[visual],
|
|
26
|
+
size,
|
|
27
|
+
borderRadius,
|
|
28
|
+
withGradient,
|
|
29
|
+
fullWidth
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
ButtonComponent,
|
|
33
|
+
{
|
|
34
|
+
ref,
|
|
35
|
+
...ButtonComponent === "button" ? { type: "button" } : {},
|
|
36
|
+
...props,
|
|
37
|
+
className: mergeClassName(recipeClassName, className)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
Button.displayName = "Button";
|
|
43
|
+
export {
|
|
44
|
+
Button
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Button.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport type { ElementType } from 'react';\nimport { button } from '@becket-ui/tokens/recipes';\n\ntype ButtonVisual = 'outline' | 'primary' | 'secondary' | 'neutral';\ntype ButtonSize = 'sm' | 'md';\ntype ButtonBorderRadius = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';\n\nconst VISUAL_TO_RECIPE: Record<ButtonVisual, ButtonVisual> = {\n primary: 'primary',\n secondary: 'secondary',\n neutral: 'neutral',\n outline: 'outline',\n};\n\nexport type ButtonProps = React.ComponentPropsWithoutRef<'button'> & {\n visual?: ButtonVisual;\n size?: ButtonSize;\n borderRadius?: ButtonBorderRadius;\n withGradient?: boolean;\n /** Stretch to the parent width. Default is token `sizes.field` (12.5rem). */\n fullWidth?: boolean;\n as?: ElementType;\n};\n\nfunction mergeClassName(...classes: (string | undefined)[]): string {\n return classes.filter(Boolean).join(' ');\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n visual = 'outline',\n size = 'md',\n borderRadius = 'md',\n withGradient = false,\n fullWidth = false,\n as: ButtonComponent = 'button',\n className,\n ...props\n },\n ref,\n ) => {\n const recipeClassName = (button)({\n visual: VISUAL_TO_RECIPE[visual],\n size,\n borderRadius,\n withGradient,\n fullWidth,\n });\n\n return (\n <ButtonComponent\n ref={ref}\n {...(ButtonComponent === 'button' ? { type: 'button' as const } : {})}\n {...props}\n className={mergeClassName(recipeClassName, className)}\n />\n );\n },\n);\n\nButton.displayName = 'Button';\n"],"mappings":"AAoDM;AApDN,SAAS,kBAAkB;AAE3B,SAAS,cAAc;AAMvB,MAAM,mBAAuD;AAAA,EAC3D,SAAS;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,SAAS;AACX;AAYA,SAAS,kBAAkB,SAAyC;AAClE,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG;AACzC;AAEO,MAAM,SAAS;AAAA,EACpB,CACE;AAAA,IACE,SAAS;AAAA,IACT,OAAO;AAAA,IACP,eAAe;AAAA,IACf,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,IAAI,kBAAkB;AAAA,IACtB;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,kBAAmB,OAAQ;AAAA,MAC/B,QAAQ,iBAAiB,MAAM;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACC,GAAI,oBAAoB,WAAW,EAAE,MAAM,SAAkB,IAAI,CAAC;AAAA,QAClE,GAAG;AAAA,QACJ,WAAW,eAAe,iBAAiB,SAAS;AAAA;AAAA,IACtD;AAAA,EAEJ;AACF;AAEA,OAAO,cAAc;","names":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
import { assertNoAxeViolations } from "@becket-ui/a11y";
|
|
6
|
+
import { Button } from "./Button";
|
|
7
|
+
describe("Button", () => {
|
|
8
|
+
it('defaults to type="button"', () => {
|
|
9
|
+
render(/* @__PURE__ */ jsx(Button, { children: "Save" }));
|
|
10
|
+
expect(screen.getByRole("button", { name: "Save" }).getAttribute("type")).toBe("button");
|
|
11
|
+
});
|
|
12
|
+
it('keeps an explicit type="submit"', () => {
|
|
13
|
+
render(/* @__PURE__ */ jsx(Button, { type: "submit", children: "Send" }));
|
|
14
|
+
expect(screen.getByRole("button", { name: "Send" }).getAttribute("type")).toBe("submit");
|
|
15
|
+
});
|
|
16
|
+
it("does not set type when as is not button", () => {
|
|
17
|
+
render(
|
|
18
|
+
/* @__PURE__ */ jsx(Button, { as: "a", href: "#save", children: "Save" })
|
|
19
|
+
);
|
|
20
|
+
expect(screen.getByRole("link", { name: "Save" }).hasAttribute("type")).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
it("does not submit a wrapping form", async () => {
|
|
23
|
+
const onSubmit = vi.fn((event) => event.preventDefault());
|
|
24
|
+
const user = userEvent.setup();
|
|
25
|
+
render(
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
"form",
|
|
28
|
+
{
|
|
29
|
+
onSubmit: (event) => {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
onSubmit(event.nativeEvent);
|
|
32
|
+
},
|
|
33
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Confirm" })
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
);
|
|
37
|
+
await user.click(screen.getByRole("button", { name: "Confirm" }));
|
|
38
|
+
expect(onSubmit).not.toHaveBeenCalled();
|
|
39
|
+
});
|
|
40
|
+
it("has no axe violations on a named button", async () => {
|
|
41
|
+
const { container } = render(/* @__PURE__ */ jsx(Button, { children: "Save" }));
|
|
42
|
+
await assertNoAxeViolations(container);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=Button.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Button.test.tsx"],"sourcesContent":["import { describe, expect, it, vi } from 'vitest';\nimport { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { assertNoAxeViolations } from '@becket-ui/a11y';\n\nimport { Button } from './Button';\n\ndescribe('Button', () => {\n it('defaults to type=\"button\"', () => {\n render(<Button>Save</Button>);\n expect(screen.getByRole('button', { name: 'Save' }).getAttribute('type')).toBe('button');\n });\n\n it('keeps an explicit type=\"submit\"', () => {\n render(<Button type=\"submit\">Send</Button>);\n expect(screen.getByRole('button', { name: 'Send' }).getAttribute('type')).toBe('submit');\n });\n\n it('does not set type when as is not button', () => {\n render(\n <Button as=\"a\" href=\"#save\">\n Save\n </Button>,\n );\n expect(screen.getByRole('link', { name: 'Save' }).hasAttribute('type')).toBe(false);\n });\n\n it('does not submit a wrapping form', async () => {\n const onSubmit = vi.fn((event: SubmitEvent) => event.preventDefault());\n const user = userEvent.setup();\n render(\n <form\n onSubmit={(event) => {\n event.preventDefault();\n onSubmit(event.nativeEvent);\n }}\n >\n <Button>Confirm</Button>\n </form>,\n );\n\n await user.click(screen.getByRole('button', { name: 'Confirm' }));\n expect(onSubmit).not.toHaveBeenCalled();\n });\n\n it('has no axe violations on a named button', async () => {\n const { container } = render(<Button>Save</Button>);\n await assertNoAxeViolations(container);\n });\n});\n"],"mappings":"AASW;AATX,SAAS,UAAU,QAAQ,IAAI,UAAU;AACzC,SAAS,QAAQ,cAAc;AAC/B,OAAO,eAAe;AACtB,SAAS,6BAA6B;AAEtC,SAAS,cAAc;AAEvB,SAAS,UAAU,MAAM;AACvB,KAAG,6BAA6B,MAAM;AACpC,WAAO,oBAAC,UAAO,kBAAI,CAAS;AAC5B,WAAO,OAAO,UAAU,UAAU,EAAE,MAAM,OAAO,CAAC,EAAE,aAAa,MAAM,CAAC,EAAE,KAAK,QAAQ;AAAA,EACzF,CAAC;AAED,KAAG,mCAAmC,MAAM;AAC1C,WAAO,oBAAC,UAAO,MAAK,UAAS,kBAAI,CAAS;AAC1C,WAAO,OAAO,UAAU,UAAU,EAAE,MAAM,OAAO,CAAC,EAAE,aAAa,MAAM,CAAC,EAAE,KAAK,QAAQ;AAAA,EACzF,CAAC;AAED,KAAG,2CAA2C,MAAM;AAClD;AAAA,MACE,oBAAC,UAAO,IAAG,KAAI,MAAK,SAAQ,kBAE5B;AAAA,IACF;AACA,WAAO,OAAO,UAAU,QAAQ,EAAE,MAAM,OAAO,CAAC,EAAE,aAAa,MAAM,CAAC,EAAE,KAAK,KAAK;AAAA,EACpF,CAAC;AAED,KAAG,mCAAmC,YAAY;AAChD,UAAM,WAAW,GAAG,GAAG,CAAC,UAAuB,MAAM,eAAe,CAAC;AACrE,UAAM,OAAO,UAAU,MAAM;AAC7B;AAAA,MACE;AAAA,QAAC;AAAA;AAAA,UACC,UAAU,CAAC,UAAU;AACnB,kBAAM,eAAe;AACrB,qBAAS,MAAM,WAAW;AAAA,UAC5B;AAAA,UAEA,8BAAC,UAAO,qBAAO;AAAA;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,KAAK,MAAM,OAAO,UAAU,UAAU,EAAE,MAAM,UAAU,CAAC,CAAC;AAChE,WAAO,QAAQ,EAAE,IAAI,iBAAiB;AAAA,EACxC,CAAC;AAED,KAAG,2CAA2C,YAAY;AACxD,UAAM,EAAE,UAAU,IAAI,OAAO,oBAAC,UAAO,kBAAI,CAAS;AAClD,UAAM,sBAAsB,SAAS;AAAA,EACvC,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ElementType, type ReactNode } from 'react';
|
|
2
|
+
type CardSize = 'sm' | 'md' | 'lg';
|
|
3
|
+
type CardVisual = 'outline' | 'subtle' | 'elevated';
|
|
4
|
+
export type CardProps = ComponentPropsWithoutRef<'div'> & {
|
|
5
|
+
size?: CardSize;
|
|
6
|
+
visual?: CardVisual;
|
|
7
|
+
/** Stretch to the parent width. Default wraps to content (`fit-content`). */
|
|
8
|
+
fullWidth?: boolean;
|
|
9
|
+
as?: ElementType;
|
|
10
|
+
};
|
|
11
|
+
export declare const Card: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
12
|
+
size?: CardSize;
|
|
13
|
+
visual?: CardVisual;
|
|
14
|
+
/** Stretch to the parent width. Default wraps to content (`fit-content`). */
|
|
15
|
+
fullWidth?: boolean;
|
|
16
|
+
as?: ElementType;
|
|
17
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
18
|
+
export declare const CardHeader: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
19
|
+
as?: ElementType;
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
|
+
export declare const CardBody: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
23
|
+
as?: ElementType;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
26
|
+
export declare const CardFooter: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
27
|
+
as?: ElementType;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
30
|
+
export declare const CardTitle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & {
|
|
31
|
+
as?: ElementType;
|
|
32
|
+
} & import("react").RefAttributes<HTMLHeadingElement>>;
|
|
33
|
+
export declare const CardDescription: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & {
|
|
34
|
+
as?: ElementType;
|
|
35
|
+
} & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACnC,KAAK,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAapD,MAAM,MAAM,SAAS,GAAG,wBAAwB,CAAC,KAAK,CAAC,GAAG;IACxD,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,EAAE,CAAC,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,IAAI;WAPR,QAAQ;aACN,UAAU;IACnB,6EAA6E;gBACjE,OAAO;SACd,WAAW;kDA0BjB,CAAC;AAcF,eAAO,MAAM,UAAU;SAJhB,WAAW;eACL,SAAS;kDAUrB,CAAC;AAGF,eAAO,MAAM,QAAQ;SAdd,WAAW;eACL,SAAS;kDAoBrB,CAAC;AAGF,eAAO,MAAM,UAAU;SAxBhB,WAAW;eACL,SAAS;kDA8BrB,CAAC;AAGF,eAAO,MAAM,SAAS;SAA0E,WAAW;sDAO1G,CAAC;AAGF,eAAO,MAAM,eAAe;SAA2E,WAAW;wDAOjH,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useContext
|
|
7
|
+
} from "react";
|
|
8
|
+
import { card } from "@becket-ui/tokens/recipes";
|
|
9
|
+
const CardContext = createContext({ size: "md", visual: "subtle" });
|
|
10
|
+
function mergeClassName(...classes) {
|
|
11
|
+
return classes.filter(Boolean).join(" ");
|
|
12
|
+
}
|
|
13
|
+
const Card = forwardRef(
|
|
14
|
+
({
|
|
15
|
+
size = "md",
|
|
16
|
+
visual = "subtle",
|
|
17
|
+
fullWidth = false,
|
|
18
|
+
as: Component = "div",
|
|
19
|
+
className,
|
|
20
|
+
children,
|
|
21
|
+
...props
|
|
22
|
+
}, ref) => {
|
|
23
|
+
const styles = card({ size, visual, fullWidth });
|
|
24
|
+
return /* @__PURE__ */ jsx(CardContext.Provider, { value: { size, visual }, children: /* @__PURE__ */ jsx(Component, { ref, ...props, className: mergeClassName(styles.root, className), children }) });
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
Card.displayName = "Card";
|
|
28
|
+
function useCardStyles() {
|
|
29
|
+
const { size, visual } = useContext(CardContext);
|
|
30
|
+
return card({ size, visual });
|
|
31
|
+
}
|
|
32
|
+
const CardHeader = forwardRef(
|
|
33
|
+
({ as: Component = "div", className, ...props }, ref) => {
|
|
34
|
+
const styles = useCardStyles();
|
|
35
|
+
return /* @__PURE__ */ jsx(Component, { ref, ...props, className: mergeClassName(styles.header, className) });
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
CardHeader.displayName = "CardHeader";
|
|
39
|
+
const CardBody = forwardRef(
|
|
40
|
+
({ as: Component = "div", className, ...props }, ref) => {
|
|
41
|
+
const styles = useCardStyles();
|
|
42
|
+
return /* @__PURE__ */ jsx(Component, { ref, ...props, className: mergeClassName(styles.body, className) });
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
CardBody.displayName = "CardBody";
|
|
46
|
+
const CardFooter = forwardRef(
|
|
47
|
+
({ as: Component = "div", className, ...props }, ref) => {
|
|
48
|
+
const styles = useCardStyles();
|
|
49
|
+
return /* @__PURE__ */ jsx(Component, { ref, ...props, className: mergeClassName(styles.footer, className) });
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
CardFooter.displayName = "CardFooter";
|
|
53
|
+
const CardTitle = forwardRef(
|
|
54
|
+
({ as: Component = "h3", className, ...props }, ref) => {
|
|
55
|
+
const styles = useCardStyles();
|
|
56
|
+
return /* @__PURE__ */ jsx(Component, { ref, ...props, className: mergeClassName(styles.title, className) });
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
CardTitle.displayName = "CardTitle";
|
|
60
|
+
const CardDescription = forwardRef(
|
|
61
|
+
({ as: Component = "p", className, ...props }, ref) => {
|
|
62
|
+
const styles = useCardStyles();
|
|
63
|
+
return /* @__PURE__ */ jsx(Component, { ref, ...props, className: mergeClassName(styles.description, className) });
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
CardDescription.displayName = "CardDescription";
|
|
67
|
+
export {
|
|
68
|
+
Card,
|
|
69
|
+
CardBody,
|
|
70
|
+
CardDescription,
|
|
71
|
+
CardFooter,
|
|
72
|
+
CardHeader,
|
|
73
|
+
CardTitle
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=Card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Card.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n forwardRef,\n useContext,\n type ComponentPropsWithoutRef,\n type ElementType,\n type ReactNode,\n} from 'react';\nimport { card } from '@becket-ui/tokens/recipes';\n\ntype CardSize = 'sm' | 'md' | 'lg';\ntype CardVisual = 'outline' | 'subtle' | 'elevated';\n\ntype CardContextValue = {\n size: CardSize;\n visual: CardVisual;\n};\n\nconst CardContext = createContext<CardContextValue>({ size: 'md', visual: 'subtle' });\n\nfunction mergeClassName(...classes: (string | undefined)[]): string {\n return classes.filter(Boolean).join(' ');\n}\n\nexport type CardProps = ComponentPropsWithoutRef<'div'> & {\n size?: CardSize;\n visual?: CardVisual;\n /** Stretch to the parent width. Default wraps to content (`fit-content`). */\n fullWidth?: boolean;\n as?: ElementType;\n};\n\nexport const Card = forwardRef<HTMLDivElement, CardProps>(\n (\n {\n size = 'md',\n visual = 'subtle',\n fullWidth = false,\n as: Component = 'div',\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const styles = card({ size, visual, fullWidth });\n\n return (\n <CardContext.Provider value={{ size, visual }}>\n <Component ref={ref} {...props} className={mergeClassName(styles.root, className)}>\n {children}\n </Component>\n </CardContext.Provider>\n );\n },\n);\n\nCard.displayName = 'Card';\n\nfunction useCardStyles() {\n const { size, visual } = useContext(CardContext);\n return card({ size, visual });\n}\n\ntype CardSlotProps = ComponentPropsWithoutRef<'div'> & {\n as?: ElementType;\n children?: ReactNode;\n};\n\nexport const CardHeader = forwardRef<HTMLDivElement, CardSlotProps>(\n ({ as: Component = 'div', className, ...props }, ref) => {\n const styles = useCardStyles();\n return (\n <Component ref={ref} {...props} className={mergeClassName(styles.header, className)} />\n );\n },\n);\nCardHeader.displayName = 'CardHeader';\n\nexport const CardBody = forwardRef<HTMLDivElement, CardSlotProps>(\n ({ as: Component = 'div', className, ...props }, ref) => {\n const styles = useCardStyles();\n return (\n <Component ref={ref} {...props} className={mergeClassName(styles.body, className)} />\n );\n },\n);\nCardBody.displayName = 'CardBody';\n\nexport const CardFooter = forwardRef<HTMLDivElement, CardSlotProps>(\n ({ as: Component = 'div', className, ...props }, ref) => {\n const styles = useCardStyles();\n return (\n <Component ref={ref} {...props} className={mergeClassName(styles.footer, className)} />\n );\n },\n);\nCardFooter.displayName = 'CardFooter';\n\nexport const CardTitle = forwardRef<HTMLHeadingElement, ComponentPropsWithoutRef<'h3'> & { as?: ElementType }>(\n ({ as: Component = 'h3', className, ...props }, ref) => {\n const styles = useCardStyles();\n return (\n <Component ref={ref} {...props} className={mergeClassName(styles.title, className)} />\n );\n },\n);\nCardTitle.displayName = 'CardTitle';\n\nexport const CardDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<'p'> & { as?: ElementType }>(\n ({ as: Component = 'p', className, ...props }, ref) => {\n const styles = useCardStyles();\n return (\n <Component ref={ref} {...props} className={mergeClassName(styles.description, className)} />\n );\n },\n);\nCardDescription.displayName = 'CardDescription';\n"],"mappings":";AAmDQ;AAjDR;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,YAAY;AAUrB,MAAM,cAAc,cAAgC,EAAE,MAAM,MAAM,QAAQ,SAAS,CAAC;AAEpF,SAAS,kBAAkB,SAAyC;AAClE,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG;AACzC;AAUO,MAAM,OAAO;AAAA,EAClB,CACE;AAAA,IACE,OAAO;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,IAAI,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,SAAS,KAAK,EAAE,MAAM,QAAQ,UAAU,CAAC;AAE/C,WACE,oBAAC,YAAY,UAAZ,EAAqB,OAAO,EAAE,MAAM,OAAO,GAC1C,8BAAC,aAAU,KAAW,GAAG,OAAO,WAAW,eAAe,OAAO,MAAM,SAAS,GAC7E,UACH,GACF;AAAA,EAEJ;AACF;AAEA,KAAK,cAAc;AAEnB,SAAS,gBAAgB;AACvB,QAAM,EAAE,MAAM,OAAO,IAAI,WAAW,WAAW;AAC/C,SAAO,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B;AAOO,MAAM,aAAa;AAAA,EACxB,CAAC,EAAE,IAAI,YAAY,OAAO,WAAW,GAAG,MAAM,GAAG,QAAQ;AACvD,UAAM,SAAS,cAAc;AAC7B,WACE,oBAAC,aAAU,KAAW,GAAG,OAAO,WAAW,eAAe,OAAO,QAAQ,SAAS,GAAG;AAAA,EAEzF;AACF;AACA,WAAW,cAAc;AAElB,MAAM,WAAW;AAAA,EACtB,CAAC,EAAE,IAAI,YAAY,OAAO,WAAW,GAAG,MAAM,GAAG,QAAQ;AACvD,UAAM,SAAS,cAAc;AAC7B,WACE,oBAAC,aAAU,KAAW,GAAG,OAAO,WAAW,eAAe,OAAO,MAAM,SAAS,GAAG;AAAA,EAEvF;AACF;AACA,SAAS,cAAc;AAEhB,MAAM,aAAa;AAAA,EACxB,CAAC,EAAE,IAAI,YAAY,OAAO,WAAW,GAAG,MAAM,GAAG,QAAQ;AACvD,UAAM,SAAS,cAAc;AAC7B,WACE,oBAAC,aAAU,KAAW,GAAG,OAAO,WAAW,eAAe,OAAO,QAAQ,SAAS,GAAG;AAAA,EAEzF;AACF;AACA,WAAW,cAAc;AAElB,MAAM,YAAY;AAAA,EACvB,CAAC,EAAE,IAAI,YAAY,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ;AACtD,UAAM,SAAS,cAAc;AAC7B,WACE,oBAAC,aAAU,KAAW,GAAG,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS,GAAG;AAAA,EAExF;AACF;AACA,UAAU,cAAc;AAEjB,MAAM,kBAAkB;AAAA,EAC7B,CAAC,EAAE,IAAI,YAAY,KAAK,WAAW,GAAG,MAAM,GAAG,QAAQ;AACrD,UAAM,SAAS,cAAc;AAC7B,WACE,oBAAC,aAAU,KAAW,GAAG,OAAO,WAAW,eAAe,OAAO,aAAa,SAAS,GAAG;AAAA,EAE9F;AACF;AACA,gBAAgB,cAAc;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type InputHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
type CheckboxSize = 'sm' | 'md';
|
|
3
|
+
export type CheckboxProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> & {
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
description?: ReactNode;
|
|
6
|
+
size?: CheckboxSize;
|
|
7
|
+
};
|
|
8
|
+
export declare const Checkbox: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
|
|
9
|
+
label?: ReactNode;
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
size?: CheckboxSize;
|
|
12
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGpF,KAAK,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC;AAEhC,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG;IACzF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAMF,eAAO,MAAM,QAAQ;YATX,SAAS;kBACH,SAAS;WAChB,YAAY;oDA2CpB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId } from "react";
|
|
3
|
+
import { checkbox as checkboxRecipe } from "@becket-ui/tokens/recipes";
|
|
4
|
+
function mergeClassName(...classes) {
|
|
5
|
+
return classes.filter(Boolean).join(" ");
|
|
6
|
+
}
|
|
7
|
+
const Checkbox = forwardRef(
|
|
8
|
+
({ id, label, description, disabled, className, size = "md", ...props }, ref) => {
|
|
9
|
+
const autoId = useId();
|
|
10
|
+
const inputId = id ?? autoId;
|
|
11
|
+
const descriptionId = description != null ? `${inputId}-desc` : void 0;
|
|
12
|
+
const styles = checkboxRecipe({ size });
|
|
13
|
+
return /* @__PURE__ */ jsxs(
|
|
14
|
+
"label",
|
|
15
|
+
{
|
|
16
|
+
className: mergeClassName(styles.root, className),
|
|
17
|
+
htmlFor: inputId,
|
|
18
|
+
"data-disabled": disabled ? "" : void 0,
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
"input",
|
|
22
|
+
{
|
|
23
|
+
ref,
|
|
24
|
+
id: inputId,
|
|
25
|
+
type: "checkbox",
|
|
26
|
+
disabled,
|
|
27
|
+
"aria-describedby": descriptionId,
|
|
28
|
+
...props,
|
|
29
|
+
className: styles.control
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
/* @__PURE__ */ jsx("span", { className: styles.indicator, "aria-hidden": "true" }),
|
|
33
|
+
label != null || description != null ? /* @__PURE__ */ jsxs("span", { className: styles.text, children: [
|
|
34
|
+
label != null ? /* @__PURE__ */ jsx("span", { className: styles.label, children: label }) : null,
|
|
35
|
+
description != null ? /* @__PURE__ */ jsx("span", { id: descriptionId, className: styles.description, children: description }) : null
|
|
36
|
+
] }) : null
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
Checkbox.displayName = "Checkbox";
|
|
43
|
+
export {
|
|
44
|
+
Checkbox
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Checkbox.tsx"],"sourcesContent":["import { forwardRef, useId, type InputHTMLAttributes, type ReactNode } from 'react';\nimport { checkbox as checkboxRecipe } from '@becket-ui/tokens/recipes';\n\ntype CheckboxSize = 'sm' | 'md';\n\nexport type CheckboxProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> & {\n label?: ReactNode;\n description?: ReactNode;\n size?: CheckboxSize;\n};\n\nfunction mergeClassName(...classes: (string | undefined)[]): string {\n return classes.filter(Boolean).join(' ');\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(\n ({ id, label, description, disabled, className, size = 'md', ...props }, ref) => {\n const autoId = useId();\n const inputId = id ?? autoId;\n const descriptionId = description != null ? `${inputId}-desc` : undefined;\n const styles = checkboxRecipe({ size });\n\n return (\n <label\n className={mergeClassName(styles.root, className)}\n htmlFor={inputId}\n data-disabled={disabled ? '' : undefined}\n >\n <input\n ref={ref}\n id={inputId}\n type=\"checkbox\"\n disabled={disabled}\n aria-describedby={descriptionId}\n {...props}\n className={styles.control}\n />\n <span className={styles.indicator} aria-hidden=\"true\" />\n {label != null || description != null ? (\n <span className={styles.text}>\n {label != null ? <span className={styles.label}>{label}</span> : null}\n {description != null ? (\n <span id={descriptionId} className={styles.description}>\n {description}\n </span>\n ) : null}\n </span>\n ) : null}\n </label>\n );\n },\n);\n\nCheckbox.displayName = 'Checkbox';\n"],"mappings":"AA4BQ,cAWE,YAXF;AA5BR,SAAS,YAAY,aAAuD;AAC5E,SAAS,YAAY,sBAAsB;AAU3C,SAAS,kBAAkB,SAAyC;AAClE,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG;AACzC;AAEO,MAAM,WAAW;AAAA,EACtB,CAAC,EAAE,IAAI,OAAO,aAAa,UAAU,WAAW,OAAO,MAAM,GAAG,MAAM,GAAG,QAAQ;AAC/E,UAAM,SAAS,MAAM;AACrB,UAAM,UAAU,MAAM;AACtB,UAAM,gBAAgB,eAAe,OAAO,GAAG,OAAO,UAAU;AAChE,UAAM,SAAS,eAAe,EAAE,KAAK,CAAC;AAEtC,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,eAAe,OAAO,MAAM,SAAS;AAAA,QAChD,SAAS;AAAA,QACT,iBAAe,WAAW,KAAK;AAAA,QAE/B;AAAA;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,IAAI;AAAA,cACJ,MAAK;AAAA,cACL;AAAA,cACA,oBAAkB;AAAA,cACjB,GAAG;AAAA,cACJ,WAAW,OAAO;AAAA;AAAA,UACpB;AAAA,UACA,oBAAC,UAAK,WAAW,OAAO,WAAW,eAAY,QAAO;AAAA,UACrD,SAAS,QAAQ,eAAe,OAC/B,qBAAC,UAAK,WAAW,OAAO,MACrB;AAAA,qBAAS,OAAO,oBAAC,UAAK,WAAW,OAAO,OAAQ,iBAAM,IAAU;AAAA,YAChE,eAAe,OACd,oBAAC,UAAK,IAAI,eAAe,WAAW,OAAO,aACxC,uBACH,IACE;AAAA,aACN,IACE;AAAA;AAAA;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,SAAS,cAAc;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type DialogHTMLAttributes, type ElementType, type ReactNode } from 'react';
|
|
2
|
+
type DialogRole = 'dialog' | 'alertdialog';
|
|
3
|
+
export type DialogProps = Omit<DialogHTMLAttributes<HTMLDialogElement>, 'open' | 'title'> & {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
onOpenChange?: (open: boolean) => void;
|
|
7
|
+
/** Composed heading. When set, Dialog renders header + close. */
|
|
8
|
+
title?: ReactNode;
|
|
9
|
+
/** Composed actions (pass `Button` nodes). When set, Dialog renders the footer. */
|
|
10
|
+
footer?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* `alertdialog` is for confirms: no backdrop dismiss, Escape still closes,
|
|
13
|
+
* initial focus is the first footer action (Cancel) when present.
|
|
14
|
+
*/
|
|
15
|
+
role?: DialogRole;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
export declare const Dialog: import("react").ForwardRefExoticComponent<Omit<DialogHTMLAttributes<HTMLDialogElement>, "open" | "title"> & {
|
|
19
|
+
open?: boolean;
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
onOpenChange?: (open: boolean) => void;
|
|
22
|
+
/** Composed heading. When set, Dialog renders header + close. */
|
|
23
|
+
title?: ReactNode;
|
|
24
|
+
/** Composed actions (pass `Button` nodes). When set, Dialog renders the footer. */
|
|
25
|
+
footer?: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* `alertdialog` is for confirms: no backdrop dismiss, Escape still closes,
|
|
28
|
+
* initial focus is the first footer action (Cancel) when present.
|
|
29
|
+
*/
|
|
30
|
+
role?: DialogRole;
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
} & import("react").RefAttributes<HTMLDialogElement>>;
|
|
33
|
+
export declare const DialogHeader: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
|
+
export declare const DialogTitle: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & {
|
|
35
|
+
as?: ElementType;
|
|
36
|
+
} & import("react").RefAttributes<HTMLHeadingElement>>;
|
|
37
|
+
export declare const DialogBody: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
38
|
+
export declare const DialogFooter: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
39
|
+
export declare const DialogClose: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=Dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../src/components/Dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAEhB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,KAAK,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC;AAwB3C,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IAC1F,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,iEAAiE;IACjE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,mFAAmF;IACnF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,MAAM;WAfV,OAAO;kBACA,OAAO;mBACN,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI;IACtC,iEAAiE;YACzD,SAAS;IACjB,mFAAmF;aAC1E,SAAS;IAClB;;;OAGG;WACI,UAAU;eACN,SAAS;qDAyErB,CAAC;AAIF,eAAO,MAAM,YAAY,2MAKxB,CAAC;AAKF,eAAO,MAAM,WAAW;SAFwC,WAAW;sDAc1E,CAAC;AAGF,eAAO,MAAM,UAAU,2MAoBtB,CAAC;AAGF,eAAO,MAAM,YAAY,2MAYxB,CAAC;AAKF,eAAO,MAAM,WAAW,0NAqBvB,CAAC"}
|