@becket-ui/react 0.1.3 → 0.2.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.
Files changed (38) hide show
  1. package/dist/components/Box.d.ts +20 -0
  2. package/dist/components/Box.d.ts.map +1 -0
  3. package/dist/components/Box.js +21 -0
  4. package/dist/components/Box.js.map +1 -0
  5. package/dist/components/Container.d.ts +21 -0
  6. package/dist/components/Container.d.ts.map +1 -0
  7. package/dist/components/Container.js +21 -0
  8. package/dist/components/Container.js.map +1 -0
  9. package/dist/components/Glyphs.d.ts +16 -0
  10. package/dist/components/Glyphs.d.ts.map +1 -0
  11. package/dist/components/Glyphs.js +83 -0
  12. package/dist/components/Glyphs.js.map +1 -0
  13. package/dist/components/Icon.d.ts +20 -0
  14. package/dist/components/Icon.d.ts.map +1 -0
  15. package/dist/components/Icon.js +23 -0
  16. package/dist/components/Icon.js.map +1 -0
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +34 -0
  20. package/dist/index.js.map +1 -1
  21. package/guides/building-with-becket.md +38 -33
  22. package/package.json +3 -3
  23. package/dist/components/Button.test.js +0 -62
  24. package/dist/components/Button.test.js.map +0 -1
  25. package/dist/components/Dialog.test.js +0 -89
  26. package/dist/components/Dialog.test.js.map +0 -1
  27. package/dist/components/Drawer.test.js +0 -50
  28. package/dist/components/Drawer.test.js.map +0 -1
  29. package/dist/components/Field.test.js +0 -33
  30. package/dist/components/Field.test.js.map +0 -1
  31. package/dist/components/Menu.test.js +0 -69
  32. package/dist/components/Menu.test.js.map +0 -1
  33. package/dist/components/Switch.test.js +0 -28
  34. package/dist/components/Switch.test.js.map +0 -1
  35. package/dist/components/Tabs.test.js +0 -41
  36. package/dist/components/Tabs.test.js.map +0 -1
  37. package/dist/components/Tooltip.test.js +0 -58
  38. package/dist/components/Tooltip.test.js.map +0 -1
@@ -0,0 +1,20 @@
1
+ import { type ComponentPropsWithoutRef, type ElementType } from 'react';
2
+ type BoxSpacing = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
3
+ type BoxBackground = 'none' | 'background' | 'surface' | 'subtle';
4
+ type BoxRadius = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
5
+ export type BoxProps = ComponentPropsWithoutRef<'div'> & {
6
+ padding?: BoxSpacing;
7
+ /** Token surfaces only; text color follows the theme. */
8
+ background?: BoxBackground;
9
+ radius?: BoxRadius;
10
+ as?: ElementType;
11
+ };
12
+ export declare const Box: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
13
+ padding?: BoxSpacing;
14
+ /** Token surfaces only; text color follows the theme. */
15
+ background?: BoxBackground;
16
+ radius?: BoxRadius;
17
+ as?: ElementType;
18
+ } & import("react").RefAttributes<HTMLDivElement>>;
19
+ export {};
20
+ //# sourceMappingURL=Box.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../src/components/Box.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,wBAAwB,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpF,KAAK,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC5D,KAAK,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAClE,KAAK,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAE7D,MAAM,MAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,GAAG;IACvD,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,yDAAyD;IACzD,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,EAAE,CAAC,EAAE,WAAW,CAAC;CAClB,CAAC;AAMF,eAAO,MAAM,GAAG;cAXJ,UAAU;IACpB,yDAAyD;iBAC5C,aAAa;aACjB,SAAS;SACb,WAAW;kDAkBjB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { box as boxRecipe } from "@becket-ui/tokens/recipes";
4
+ function mergeClassName(...classes) {
5
+ return classes.filter(Boolean).join(" ");
6
+ }
7
+ const Box = forwardRef(
8
+ ({ padding = "none", background = "none", radius = "none", as: Component = "div", className, ...props }, ref) => /* @__PURE__ */ jsx(
9
+ Component,
10
+ {
11
+ ref,
12
+ ...props,
13
+ className: mergeClassName(boxRecipe({ padding, background, radius }), className)
14
+ }
15
+ )
16
+ );
17
+ Box.displayName = "Box";
18
+ export {
19
+ Box
20
+ };
21
+ //# sourceMappingURL=Box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/Box.tsx"],"sourcesContent":["import { forwardRef, type ComponentPropsWithoutRef, type ElementType } from 'react';\nimport { box as boxRecipe } from '@becket-ui/tokens/recipes';\n\ntype BoxSpacing = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\ntype BoxBackground = 'none' | 'background' | 'surface' | 'subtle';\ntype BoxRadius = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full';\n\nexport type BoxProps = ComponentPropsWithoutRef<'div'> & {\n padding?: BoxSpacing;\n /** Token surfaces only; text color follows the theme. */\n background?: BoxBackground;\n radius?: BoxRadius;\n as?: ElementType;\n};\n\nfunction mergeClassName(...classes: (string | undefined)[]): string {\n return classes.filter(Boolean).join(' ');\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n { padding = 'none', background = 'none', radius = 'none', as: Component = 'div', className, ...props },\n ref,\n ) => (\n <Component\n ref={ref}\n {...props}\n className={mergeClassName(boxRecipe({ padding, background, radius }), className)}\n />\n ),\n);\n\nBox.displayName = 'Box';\n"],"mappings":"AAwBI;AAxBJ,SAAS,kBAAmE;AAC5E,SAAS,OAAO,iBAAiB;AAcjC,SAAS,kBAAkB,SAAyC;AAClE,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG;AACzC;AAEO,MAAM,MAAM;AAAA,EACjB,CACE,EAAE,UAAU,QAAQ,aAAa,QAAQ,SAAS,QAAQ,IAAI,YAAY,OAAO,WAAW,GAAG,MAAM,GACrG,QAEA;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACC,GAAG;AAAA,MACJ,WAAW,eAAe,UAAU,EAAE,SAAS,YAAY,OAAO,CAAC,GAAG,SAAS;AAAA;AAAA,EACjF;AAEJ;AAEA,IAAI,cAAc;","names":[]}
@@ -0,0 +1,21 @@
1
+ import { type ComponentPropsWithoutRef, type ElementType } from 'react';
2
+ type ContainerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';
3
+ type ContainerPadding = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4
+ export type ContainerProps = ComponentPropsWithoutRef<'div'> & {
5
+ /** Max width from the size scale: sm 48rem, md 64rem, lg 72rem, xl 80rem, full none. */
6
+ size?: ContainerSize;
7
+ /** Inline (left and right) page gutter. Vertical spacing belongs to Stack. */
8
+ padding?: ContainerPadding;
9
+ /** Render as a landmark, e.g. `main` or `section`. */
10
+ as?: ElementType;
11
+ };
12
+ export declare const Container: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
13
+ /** Max width from the size scale: sm 48rem, md 64rem, lg 72rem, xl 80rem, full none. */
14
+ size?: ContainerSize;
15
+ /** Inline (left and right) page gutter. Vertical spacing belongs to Stack. */
16
+ padding?: ContainerPadding;
17
+ /** Render as a landmark, e.g. `main` or `section`. */
18
+ as?: ElementType;
19
+ } & import("react").RefAttributes<HTMLDivElement>>;
20
+ export {};
21
+ //# sourceMappingURL=Container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../src/components/Container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,wBAAwB,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpF,KAAK,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AACxD,KAAK,gBAAgB,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG,wBAAwB,CAAC,KAAK,CAAC,GAAG;IAC7D,wFAAwF;IACxF,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,sDAAsD;IACtD,EAAE,CAAC,EAAE,WAAW,CAAC;CAClB,CAAC;AAMF,eAAO,MAAM,SAAS;IAZpB,wFAAwF;WACjF,aAAa;IACpB,8EAA8E;cACpE,gBAAgB;IAC1B,sDAAsD;SACjD,WAAW;kDAejB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { container as containerRecipe } from "@becket-ui/tokens/recipes";
4
+ function mergeClassName(...classes) {
5
+ return classes.filter(Boolean).join(" ");
6
+ }
7
+ const Container = forwardRef(
8
+ ({ size = "lg", padding = "md", as: Component = "div", className, ...props }, ref) => /* @__PURE__ */ jsx(
9
+ Component,
10
+ {
11
+ ref,
12
+ ...props,
13
+ className: mergeClassName(containerRecipe({ size, padding }), className)
14
+ }
15
+ )
16
+ );
17
+ Container.displayName = "Container";
18
+ export {
19
+ Container
20
+ };
21
+ //# sourceMappingURL=Container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/Container.tsx"],"sourcesContent":["import { forwardRef, type ComponentPropsWithoutRef, type ElementType } from 'react';\nimport { container as containerRecipe } from '@becket-ui/tokens/recipes';\n\ntype ContainerSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';\ntype ContainerPadding = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\nexport type ContainerProps = ComponentPropsWithoutRef<'div'> & {\n /** Max width from the size scale: sm 48rem, md 64rem, lg 72rem, xl 80rem, full none. */\n size?: ContainerSize;\n /** Inline (left and right) page gutter. Vertical spacing belongs to Stack. */\n padding?: ContainerPadding;\n /** Render as a landmark, e.g. `main` or `section`. */\n as?: ElementType;\n};\n\nfunction mergeClassName(...classes: (string | undefined)[]): string {\n return classes.filter(Boolean).join(' ');\n}\n\nexport const Container = forwardRef<HTMLDivElement, ContainerProps>(\n ({ size = 'lg', padding = 'md', as: Component = 'div', className, ...props }, ref) => (\n <Component\n ref={ref}\n {...props}\n className={mergeClassName(containerRecipe({ size, padding }), className)}\n />\n ),\n);\n\nContainer.displayName = 'Container';\n"],"mappings":"AAqBI;AArBJ,SAAS,kBAAmE;AAC5E,SAAS,aAAa,uBAAuB;AAc7C,SAAS,kBAAkB,SAAyC;AAClE,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG;AACzC;AAEO,MAAM,YAAY;AAAA,EACvB,CAAC,EAAE,OAAO,MAAM,UAAU,MAAM,IAAI,YAAY,OAAO,WAAW,GAAG,MAAM,GAAG,QAC5E;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACC,GAAG;AAAA,MACJ,WAAW,eAAe,gBAAgB,EAAE,MAAM,QAAQ,CAAC,GAAG,SAAS;AAAA;AAAA,EACzE;AAEJ;AAEA,UAAU,cAAc;","names":[]}
@@ -0,0 +1,16 @@
1
+ import { type IconProps } from './Icon';
2
+ export type GlyphProps = Omit<IconProps, 'children'>;
3
+ export declare const ChevronDownIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
4
+ export declare const ChevronRightIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
5
+ export declare const CloseIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
6
+ export declare const MenuIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
7
+ export declare const CheckIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
8
+ export declare const CopyIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
9
+ export declare const ExternalLinkIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
10
+ export declare const LinkIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
11
+ export declare const SearchIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
12
+ export declare const SunIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
13
+ export declare const MoonIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
14
+ export declare const InfoIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
15
+ export declare const WarningIcon: import("react").ForwardRefExoticComponent<GlyphProps & import("react").RefAttributes<HTMLSpanElement>>;
16
+ //# sourceMappingURL=Glyphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Glyphs.d.ts","sourceRoot":"","sources":["../../src/components/Glyphs.tsx"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAwBrD,eAAO,MAAM,eAAe,wGAA4E,CAAC;AAEzG,eAAO,MAAM,gBAAgB,wGAA6E,CAAC;AAE3G,eAAO,MAAM,SAAS,wGAA8E,CAAC;AAErG,eAAO,MAAM,QAAQ,wGAAgF,CAAC;AAEtG,eAAO,MAAM,SAAS,wGAA8E,CAAC;AAErG,eAAO,MAAM,QAAQ,wGAMpB,CAAC;AAEF,eAAO,MAAM,gBAAgB,wGAG5B,CAAC;AAEF,eAAO,MAAM,QAAQ,wGAGpB,CAAC;AAEF,eAAO,MAAM,UAAU,wGAMtB,CAAC;AAEF,eAAO,MAAM,OAAO,wGAMnB,CAAC;AAEF,eAAO,MAAM,QAAQ,wGAAsG,CAAC;AAE5H,eAAO,MAAM,QAAQ,wGAMpB,CAAC;AAEF,eAAO,MAAM,WAAW,wGAGvB,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { Icon } from "./Icon";
4
+ function createGlyph(displayName, shapes) {
5
+ const Glyph = forwardRef((props, ref) => /* @__PURE__ */ jsx(Icon, { ref, ...props, children: /* @__PURE__ */ jsx(
6
+ "svg",
7
+ {
8
+ viewBox: "0 0 24 24",
9
+ fill: "none",
10
+ stroke: "currentColor",
11
+ strokeWidth: 2,
12
+ strokeLinecap: "round",
13
+ strokeLinejoin: "round",
14
+ "aria-hidden": "true",
15
+ focusable: "false",
16
+ children: shapes
17
+ }
18
+ ) }));
19
+ Glyph.displayName = displayName;
20
+ return Glyph;
21
+ }
22
+ const ChevronDownIcon = /* @__PURE__ */ createGlyph("ChevronDownIcon", /* @__PURE__ */ jsx("path", { d: "M6 9l6 6 6-6" }));
23
+ const ChevronRightIcon = /* @__PURE__ */ createGlyph("ChevronRightIcon", /* @__PURE__ */ jsx("path", { d: "M9 6l6 6-6 6" }));
24
+ const CloseIcon = /* @__PURE__ */ createGlyph("CloseIcon", /* @__PURE__ */ jsx("path", { d: "M6 6l12 12M18 6L6 18" }));
25
+ const MenuIcon = /* @__PURE__ */ createGlyph("MenuIcon", /* @__PURE__ */ jsx("path", { d: "M4 6h16M4 12h16M4 18h16" }));
26
+ const CheckIcon = /* @__PURE__ */ createGlyph("CheckIcon", /* @__PURE__ */ jsx("path", { d: "M5 12.5l4.5 4.5L19 7" }));
27
+ const CopyIcon = /* @__PURE__ */ createGlyph(
28
+ "CopyIcon",
29
+ /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "11", height: "11", rx: "2" }),
31
+ /* @__PURE__ */ jsx("path", { d: "M15 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h3" })
32
+ ] })
33
+ );
34
+ const ExternalLinkIcon = /* @__PURE__ */ createGlyph(
35
+ "ExternalLinkIcon",
36
+ /* @__PURE__ */ jsx("path", { d: "M14 4h6v6M20 4l-9 9M18 14v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4" })
37
+ );
38
+ const LinkIcon = /* @__PURE__ */ createGlyph(
39
+ "LinkIcon",
40
+ /* @__PURE__ */ jsx("path", { d: "M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1" })
41
+ );
42
+ const SearchIcon = /* @__PURE__ */ createGlyph(
43
+ "SearchIcon",
44
+ /* @__PURE__ */ jsxs(Fragment, { children: [
45
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "7" }),
46
+ /* @__PURE__ */ jsx("path", { d: "M20 20l-4-4" })
47
+ ] })
48
+ );
49
+ const SunIcon = /* @__PURE__ */ createGlyph(
50
+ "SunIcon",
51
+ /* @__PURE__ */ jsxs(Fragment, { children: [
52
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "4" }),
53
+ /* @__PURE__ */ jsx("path", { d: "M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" })
54
+ ] })
55
+ );
56
+ const MoonIcon = /* @__PURE__ */ createGlyph("MoonIcon", /* @__PURE__ */ jsx("path", { d: "M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z" }));
57
+ const InfoIcon = /* @__PURE__ */ createGlyph(
58
+ "InfoIcon",
59
+ /* @__PURE__ */ jsxs(Fragment, { children: [
60
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9" }),
61
+ /* @__PURE__ */ jsx("path", { d: "M12 11v5M12 8h.01" })
62
+ ] })
63
+ );
64
+ const WarningIcon = /* @__PURE__ */ createGlyph(
65
+ "WarningIcon",
66
+ /* @__PURE__ */ jsx("path", { d: "M12 3.5L21.5 20h-19L12 3.5zM12 10v4M12 17h.01" })
67
+ );
68
+ export {
69
+ CheckIcon,
70
+ ChevronDownIcon,
71
+ ChevronRightIcon,
72
+ CloseIcon,
73
+ CopyIcon,
74
+ ExternalLinkIcon,
75
+ InfoIcon,
76
+ LinkIcon,
77
+ MenuIcon,
78
+ MoonIcon,
79
+ SearchIcon,
80
+ SunIcon,
81
+ WarningIcon
82
+ };
83
+ //# sourceMappingURL=Glyphs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/Glyphs.tsx"],"sourcesContent":["import { forwardRef, type ReactNode } from 'react';\nimport { Icon, type IconProps } from './Icon';\n\nexport type GlyphProps = Omit<IconProps, 'children'>;\n\n// Every glyph shares one 24px grid and stroke so they sit together without tuning.\nfunction createGlyph(displayName: string, shapes: ReactNode) {\n const Glyph = forwardRef<HTMLSpanElement, GlyphProps>((props, ref) => (\n <Icon ref={ref} {...props}>\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {shapes}\n </svg>\n </Icon>\n ));\n Glyph.displayName = displayName;\n return Glyph;\n}\n\nexport const ChevronDownIcon = /* @__PURE__ */ createGlyph('ChevronDownIcon', <path d=\"M6 9l6 6 6-6\" />);\n\nexport const ChevronRightIcon = /* @__PURE__ */ createGlyph('ChevronRightIcon', <path d=\"M9 6l6 6-6 6\" />);\n\nexport const CloseIcon = /* @__PURE__ */ createGlyph('CloseIcon', <path d=\"M6 6l12 12M18 6L6 18\" />);\n\nexport const MenuIcon = /* @__PURE__ */ createGlyph('MenuIcon', <path d=\"M4 6h16M4 12h16M4 18h16\" />);\n\nexport const CheckIcon = /* @__PURE__ */ createGlyph('CheckIcon', <path d=\"M5 12.5l4.5 4.5L19 7\" />);\n\nexport const CopyIcon = /* @__PURE__ */ createGlyph(\n 'CopyIcon',\n <>\n <rect x=\"9\" y=\"9\" width=\"11\" height=\"11\" rx=\"2\" />\n <path d=\"M15 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h3\" />\n </>,\n);\n\nexport const ExternalLinkIcon = /* @__PURE__ */ createGlyph(\n 'ExternalLinkIcon',\n <path d=\"M14 4h6v6M20 4l-9 9M18 14v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4\" />,\n);\n\nexport const LinkIcon = /* @__PURE__ */ createGlyph(\n 'LinkIcon',\n <path d=\"M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1\" />,\n);\n\nexport const SearchIcon = /* @__PURE__ */ createGlyph(\n 'SearchIcon',\n <>\n <circle cx=\"11\" cy=\"11\" r=\"7\" />\n <path d=\"M20 20l-4-4\" />\n </>,\n);\n\nexport const SunIcon = /* @__PURE__ */ createGlyph(\n 'SunIcon',\n <>\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4\" />\n </>,\n);\n\nexport const MoonIcon = /* @__PURE__ */ createGlyph('MoonIcon', <path d=\"M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z\" />);\n\nexport const InfoIcon = /* @__PURE__ */ createGlyph(\n 'InfoIcon',\n <>\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <path d=\"M12 11v5M12 8h.01\" />\n </>,\n);\n\nexport const WarningIcon = /* @__PURE__ */ createGlyph(\n 'WarningIcon',\n <path d=\"M12 3.5L21.5 20h-19L12 3.5zM12 10v4M12 17h.01\" />,\n);\n"],"mappings":"AASM,SA8BJ,UA9BI,KA8BJ,YA9BI;AATN,SAAS,kBAAkC;AAC3C,SAAS,YAA4B;AAKrC,SAAS,YAAY,aAAqB,QAAmB;AAC3D,QAAM,QAAQ,WAAwC,CAAC,OAAO,QAC5D,oBAAC,QAAK,KAAW,GAAG,OAClB;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,QAAO;AAAA,MACP,aAAa;AAAA,MACb,eAAc;AAAA,MACd,gBAAe;AAAA,MACf,eAAY;AAAA,MACZ,WAAU;AAAA,MAET;AAAA;AAAA,EACH,GACF,CACD;AACD,QAAM,cAAc;AACpB,SAAO;AACT;AAEO,MAAM,kBAAkC,4BAAY,mBAAmB,oBAAC,UAAK,GAAE,gBAAe,CAAE;AAEhG,MAAM,mBAAmC,4BAAY,oBAAoB,oBAAC,UAAK,GAAE,gBAAe,CAAE;AAElG,MAAM,YAA4B,4BAAY,aAAa,oBAAC,UAAK,GAAE,wBAAuB,CAAE;AAE5F,MAAM,WAA2B,4BAAY,YAAY,oBAAC,UAAK,GAAE,2BAA0B,CAAE;AAE7F,MAAM,YAA4B,4BAAY,aAAa,oBAAC,UAAK,GAAE,wBAAuB,CAAE;AAE5F,MAAM,WAA2B;AAAA,EACtC;AAAA,EACA,iCACE;AAAA,wBAAC,UAAK,GAAE,KAAI,GAAE,KAAI,OAAM,MAAK,QAAO,MAAK,IAAG,KAAI;AAAA,IAChD,oBAAC,UAAK,GAAE,2DAA0D;AAAA,KACpE;AACF;AAEO,MAAM,mBAAmC;AAAA,EAC9C;AAAA,EACA,oBAAC,UAAK,GAAE,+EAA8E;AACxF;AAEO,MAAM,WAA2B;AAAA,EACtC;AAAA,EACA,oBAAC,UAAK,GAAE,4GAA2G;AACrH;AAEO,MAAM,aAA6B;AAAA,EACxC;AAAA,EACA,iCACE;AAAA,wBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KAAI;AAAA,IAC9B,oBAAC,UAAK,GAAE,eAAc;AAAA,KACxB;AACF;AAEO,MAAM,UAA0B;AAAA,EACrC;AAAA,EACA,iCACE;AAAA,wBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KAAI;AAAA,IAC9B,oBAAC,UAAK,GAAE,sGAAqG;AAAA,KAC/G;AACF;AAEO,MAAM,WAA2B,4BAAY,YAAY,oBAAC,UAAK,GAAE,iDAAgD,CAAE;AAEnH,MAAM,WAA2B;AAAA,EACtC;AAAA,EACA,iCACE;AAAA,wBAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KAAI;AAAA,IAC9B,oBAAC,UAAK,GAAE,qBAAoB;AAAA,KAC9B;AACF;AAEO,MAAM,cAA8B;AAAA,EACzC;AAAA,EACA,oBAAC,UAAK,GAAE,iDAAgD;AAC1D;","names":[]}
@@ -0,0 +1,20 @@
1
+ import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
2
+ type IconSize = 'sm' | 'md' | 'lg' | 'xl';
3
+ export type IconProps = Omit<ComponentPropsWithoutRef<'span'>, 'children'> & {
4
+ /** sm 1rem, md 1.25rem, lg 1.5rem, xl 2rem. */
5
+ size?: IconSize;
6
+ /** Accessible name. Without it the icon is decorative and hidden from assistive tech. */
7
+ label?: string;
8
+ /** One inline `<svg>`, drawn with `currentColor`. */
9
+ children: ReactNode;
10
+ };
11
+ export declare const Icon: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">, "children"> & {
12
+ /** sm 1rem, md 1.25rem, lg 1.5rem, xl 2rem. */
13
+ size?: IconSize;
14
+ /** Accessible name. Without it the icon is decorative and hidden from assistive tech. */
15
+ label?: string;
16
+ /** One inline `<svg>`, drawn with `currentColor`. */
17
+ children: ReactNode;
18
+ } & import("react").RefAttributes<HTMLSpanElement>>;
19
+ export {};
20
+ //# sourceMappingURL=Icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../src/components/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,wBAAwB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlF,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1C,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;IAC3E,+CAA+C;IAC/C,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,yFAAyF;IACzF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAMF,eAAO,MAAM,IAAI;IAZf,+CAA+C;WACxC,QAAQ;IACf,yFAAyF;YACjF,MAAM;IACd,qDAAqD;cAC3C,SAAS;mDAkBpB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { icon as iconRecipe } from "@becket-ui/tokens/recipes";
4
+ function mergeClassName(...classes) {
5
+ return classes.filter(Boolean).join(" ");
6
+ }
7
+ const Icon = forwardRef(
8
+ ({ size = "md", label, className, children, ...props }, ref) => /* @__PURE__ */ jsx(
9
+ "span",
10
+ {
11
+ ref,
12
+ ...props,
13
+ ...label ? { role: "img", "aria-label": label } : { "aria-hidden": true },
14
+ className: mergeClassName(iconRecipe({ size }), className),
15
+ children
16
+ }
17
+ )
18
+ );
19
+ Icon.displayName = "Icon";
20
+ export {
21
+ Icon
22
+ };
23
+ //# sourceMappingURL=Icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/Icon.tsx"],"sourcesContent":["import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from 'react';\nimport { icon as iconRecipe } from '@becket-ui/tokens/recipes';\n\ntype IconSize = 'sm' | 'md' | 'lg' | 'xl';\n\nexport type IconProps = Omit<ComponentPropsWithoutRef<'span'>, 'children'> & {\n /** sm 1rem, md 1.25rem, lg 1.5rem, xl 2rem. */\n size?: IconSize;\n /** Accessible name. Without it the icon is decorative and hidden from assistive tech. */\n label?: string;\n /** One inline `<svg>`, drawn with `currentColor`. */\n children: ReactNode;\n};\n\nfunction mergeClassName(...classes: (string | undefined)[]): string {\n return classes.filter(Boolean).join(' ');\n}\n\nexport const Icon = forwardRef<HTMLSpanElement, IconProps>(\n ({ size = 'md', label, className, children, ...props }, ref) => (\n <span\n ref={ref}\n {...props}\n {...(label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true })}\n className={mergeClassName(iconRecipe({ size }), className)}\n >\n {children}\n </span>\n ),\n);\n\nIcon.displayName = 'Icon';\n"],"mappings":"AAoBI;AApBJ,SAAS,kBAAiE;AAC1E,SAAS,QAAQ,kBAAkB;AAanC,SAAS,kBAAkB,SAAyC;AAClE,SAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG;AACzC;AAEO,MAAM,OAAO;AAAA,EAClB,CAAC,EAAE,OAAO,MAAM,OAAO,WAAW,UAAU,GAAG,MAAM,GAAG,QACtD;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACC,GAAG;AAAA,MACH,GAAI,QAAQ,EAAE,MAAM,OAAO,cAAc,MAAM,IAAI,EAAE,eAAe,KAAK;AAAA,MAC1E,WAAW,eAAe,WAAW,EAAE,KAAK,CAAC,GAAG,SAAS;AAAA,MAExD;AAAA;AAAA,EACH;AAEJ;AAEA,KAAK,cAAc;","names":[]}
package/dist/index.d.ts CHANGED
@@ -17,6 +17,10 @@ export { Select } from './components/Select';
17
17
  export { Textarea } from './components/Textarea';
18
18
  export { Card, CardHeader, CardBody, CardFooter, CardTitle, CardDescription, } from './components/Card';
19
19
  export { SimpleGrid } from './components/SimpleGrid';
20
+ export { Container } from './components/Container';
21
+ export type { ContainerProps } from './components/Container';
22
+ export { Box } from './components/Box';
23
+ export type { BoxProps } from './components/Box';
20
24
  export { Hide } from './components/Hide';
21
25
  export type { HideProps } from './components/Hide';
22
26
  export { Tooltip } from './components/Tooltip';
@@ -27,6 +31,10 @@ export { Menu, MenuItem } from './components/Menu';
27
31
  export { Tabs, TabList, Tab, TabPanel } from './components/Tabs';
28
32
  export { Table, TableCaption, TableHeader, TableBody, TableFooter, TableRow, TableColumnHeader, TableCell, Thead, Tbody, Tfoot, Tr, Th, Td, } from './components/Table';
29
33
  export { Spinner } from './components/Spinner';
34
+ export { Icon } from './components/Icon';
35
+ export type { IconProps } from './components/Icon';
36
+ export { CheckIcon, ChevronDownIcon, ChevronRightIcon, CloseIcon, CopyIcon, ExternalLinkIcon, InfoIcon, LinkIcon, MenuIcon, MoonIcon, SearchIcon, SunIcon, WarningIcon, } from './components/Glyphs';
37
+ export type { GlyphProps } from './components/Glyphs';
30
38
  export { Link } from './components/Link';
31
39
  export { Separator } from './components/Separator';
32
40
  export type { LabelCustomColors, LabelVisual } from './helpers/labelColors';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACz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AAM,wBAAwB,CAAC;AACnD,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC5E,YAAY,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,eAAe,EACf,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -30,6 +30,8 @@ import {
30
30
  CardDescription
31
31
  } from "./components/Card";
32
32
  import { SimpleGrid } from "./components/SimpleGrid";
33
+ import { Container } from "./components/Container";
34
+ import { Box } from "./components/Box";
33
35
  import { Hide } from "./components/Hide";
34
36
  import { Tooltip } from "./components/Tooltip";
35
37
  import {
@@ -67,6 +69,22 @@ import {
67
69
  Td
68
70
  } from "./components/Table";
69
71
  import { Spinner } from "./components/Spinner";
72
+ import { Icon } from "./components/Icon";
73
+ import {
74
+ CheckIcon,
75
+ ChevronDownIcon,
76
+ ChevronRightIcon,
77
+ CloseIcon,
78
+ CopyIcon,
79
+ ExternalLinkIcon,
80
+ InfoIcon,
81
+ LinkIcon,
82
+ MenuIcon,
83
+ MoonIcon,
84
+ SearchIcon,
85
+ SunIcon,
86
+ WarningIcon
87
+ } from "./components/Glyphs";
70
88
  import { Link } from "./components/Link";
71
89
  import { Separator } from "./components/Separator";
72
90
  import {
@@ -81,6 +99,7 @@ import {
81
99
  export {
82
100
  BREAKPOINTS,
83
101
  Badge,
102
+ Box,
84
103
  Button,
85
104
  Card,
86
105
  CardBody,
@@ -88,7 +107,13 @@ export {
88
107
  CardFooter,
89
108
  CardHeader,
90
109
  CardTitle,
110
+ CheckIcon,
91
111
  Checkbox,
112
+ ChevronDownIcon,
113
+ ChevronRightIcon,
114
+ CloseIcon,
115
+ Container,
116
+ CopyIcon,
92
117
  Dialog,
93
118
  DialogBody,
94
119
  DialogClose,
@@ -101,6 +126,7 @@ export {
101
126
  DrawerFooter,
102
127
  DrawerHeader,
103
128
  DrawerTitle,
129
+ ExternalLinkIcon,
104
130
  Field,
105
131
  FieldControl,
106
132
  FieldError,
@@ -112,19 +138,26 @@ export {
112
138
  HStack,
113
139
  Heading,
114
140
  Hide,
141
+ Icon,
142
+ InfoIcon,
115
143
  Link,
144
+ LinkIcon,
116
145
  Menu,
146
+ MenuIcon,
117
147
  MenuItem,
148
+ MoonIcon,
118
149
  Radio,
119
150
  RadioGroup,
120
151
  SEMANTIC_BREAKPOINTS,
121
152
  SEMANTIC_TO_BREAKPOINT,
122
153
  SPACING_SCALE,
154
+ SearchIcon,
123
155
  Select,
124
156
  Separator,
125
157
  SimpleGrid,
126
158
  Spinner,
127
159
  Stack,
160
+ SunIcon,
128
161
  Switch,
129
162
  Tab,
130
163
  TabList,
@@ -150,6 +183,7 @@ export {
150
183
  Tooltip,
151
184
  Tr,
152
185
  VStack,
186
+ WarningIcon,
153
187
  normalizeGapValue,
154
188
  normalizeResponsiveValue,
155
189
  resolveBreakpointAlias,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { Button } from './components/Button';\nexport { Heading } from './components/Heading';\nexport { Text } from './components/Text';\nexport { Flex } from './components/Flex';\nexport { Stack, HStack, VStack } from './components/Stack';\nexport { Tag } from './components/Tag';\nexport { Badge } from './components/Badge';\nexport { Switch } from './components/Switch';\nexport type { SwitchProps } from './components/Switch';\nexport {\n Field,\n FieldLabel,\n FieldHelper,\n FieldError,\n FieldControl,\n FieldSelect,\n FieldTextarea,\n useField,\n} from './components/Field';\nexport type { FieldSize, FieldContextValue } from './components/Field';\nexport { TextField } from './components/TextField';\nexport { Checkbox } from './components/Checkbox';\nexport { Radio, RadioGroup } from './components/Radio';\nexport type { RadioProps, RadioGroupProps } from './components/Radio';\nexport { Select } from './components/Select';\nexport { Textarea } from './components/Textarea';\nexport {\n Card,\n CardHeader,\n CardBody,\n CardFooter,\n CardTitle,\n CardDescription,\n} from './components/Card';\nexport { SimpleGrid } from './components/SimpleGrid';\nexport { Hide } from './components/Hide';\nexport type { HideProps } from './components/Hide';\nexport { Tooltip } from './components/Tooltip';\nexport type { TooltipPlacement, TooltipProps } from './components/Tooltip';\nexport {\n Dialog,\n DialogHeader,\n DialogBody,\n DialogFooter,\n DialogTitle,\n DialogClose,\n} from './components/Dialog';\nexport {\n Drawer,\n DrawerHeader,\n DrawerBody,\n DrawerFooter,\n DrawerTitle,\n DrawerClose,\n} from './components/Drawer';\nexport { Menu, MenuItem } from './components/Menu';\nexport { Tabs, TabList, Tab, TabPanel } from './components/Tabs';\nexport {\n Table,\n TableCaption,\n TableHeader,\n TableBody,\n TableFooter,\n TableRow,\n TableColumnHeader,\n TableCell,\n Thead,\n Tbody,\n Tfoot,\n Tr,\n Th,\n Td,\n} from './components/Table';\nexport { Spinner } from './components/Spinner';\nexport { Link } from './components/Link';\nexport { Separator } from './components/Separator';\nexport type { LabelCustomColors, LabelVisual } from './helpers/labelColors';\nexport type {\n Breakpoint,\n BreakpointAlias,\n BreakpointMap,\n ResponsiveValue,\n GapValue,\n SpacingScale,\n SpacingStep,\n SpacingSemantic,\n SemanticBreakpoint,\n} from './helpers/responsive';\nexport {\n BREAKPOINTS,\n SEMANTIC_BREAKPOINTS,\n SEMANTIC_TO_BREAKPOINT,\n SPACING_SCALE,\n normalizeResponsiveValue,\n normalizeGapValue,\n resolveBreakpointAlias,\n} from './helpers/responsive';\n"],"mappings":"AAAA,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,OAAO,QAAQ,cAAc;AACtC,SAAS,WAAW;AACpB,SAAS,aAAa;AACtB,SAAS,cAAc;AAEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,OAAO,kBAAkB;AAElC,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAErB,SAAS,eAAe;AAExB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,MAAM,gBAAgB;AAC/B,SAAS,MAAM,SAAS,KAAK,gBAAgB;AAC7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAa1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { Button } from './components/Button';\nexport { Heading } from './components/Heading';\nexport { Text } from './components/Text';\nexport { Flex } from './components/Flex';\nexport { Stack, HStack, VStack } from './components/Stack';\nexport { Tag } from './components/Tag';\nexport { Badge } from './components/Badge';\nexport { Switch } from './components/Switch';\nexport type { SwitchProps } from './components/Switch';\nexport {\n Field,\n FieldLabel,\n FieldHelper,\n FieldError,\n FieldControl,\n FieldSelect,\n FieldTextarea,\n useField,\n} from './components/Field';\nexport type { FieldSize, FieldContextValue } from './components/Field';\nexport { TextField } from './components/TextField';\nexport { Checkbox } from './components/Checkbox';\nexport { Radio, RadioGroup } from './components/Radio';\nexport type { RadioProps, RadioGroupProps } from './components/Radio';\nexport { Select } from './components/Select';\nexport { Textarea } from './components/Textarea';\nexport {\n Card,\n CardHeader,\n CardBody,\n CardFooter,\n CardTitle,\n CardDescription,\n} from './components/Card';\nexport { SimpleGrid } from './components/SimpleGrid';\nexport { Container } from './components/Container';\nexport type { ContainerProps } from './components/Container';\nexport { Box } from './components/Box';\nexport type { BoxProps } from './components/Box';\nexport { Hide } from './components/Hide';\nexport type { HideProps } from './components/Hide';\nexport { Tooltip } from './components/Tooltip';\nexport type { TooltipPlacement, TooltipProps } from './components/Tooltip';\nexport {\n Dialog,\n DialogHeader,\n DialogBody,\n DialogFooter,\n DialogTitle,\n DialogClose,\n} from './components/Dialog';\nexport {\n Drawer,\n DrawerHeader,\n DrawerBody,\n DrawerFooter,\n DrawerTitle,\n DrawerClose,\n} from './components/Drawer';\nexport { Menu, MenuItem } from './components/Menu';\nexport { Tabs, TabList, Tab, TabPanel } from './components/Tabs';\nexport {\n Table,\n TableCaption,\n TableHeader,\n TableBody,\n TableFooter,\n TableRow,\n TableColumnHeader,\n TableCell,\n Thead,\n Tbody,\n Tfoot,\n Tr,\n Th,\n Td,\n} from './components/Table';\nexport { Spinner } from './components/Spinner';\nexport { Icon } from './components/Icon';\nexport type { IconProps } from './components/Icon';\nexport {\n CheckIcon,\n ChevronDownIcon,\n ChevronRightIcon,\n CloseIcon,\n CopyIcon,\n ExternalLinkIcon,\n InfoIcon,\n LinkIcon,\n MenuIcon,\n MoonIcon,\n SearchIcon,\n SunIcon,\n WarningIcon,\n} from './components/Glyphs';\nexport type { GlyphProps } from './components/Glyphs';\nexport { Link } from './components/Link';\nexport { Separator } from './components/Separator';\nexport type { LabelCustomColors, LabelVisual } from './helpers/labelColors';\nexport type {\n Breakpoint,\n BreakpointAlias,\n BreakpointMap,\n ResponsiveValue,\n GapValue,\n SpacingScale,\n SpacingStep,\n SpacingSemantic,\n SemanticBreakpoint,\n} from './helpers/responsive';\nexport {\n BREAKPOINTS,\n SEMANTIC_BREAKPOINTS,\n SEMANTIC_TO_BREAKPOINT,\n SPACING_SCALE,\n normalizeResponsiveValue,\n normalizeGapValue,\n resolveBreakpointAlias,\n} from './helpers/responsive';\n"],"mappings":"AAAA,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,OAAO,QAAQ,cAAc;AACtC,SAAS,WAAW;AACpB,SAAS,aAAa;AACtB,SAAS,cAAc;AAEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,OAAO,kBAAkB;AAElC,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAE1B,SAAS,WAAW;AAEpB,SAAS,YAAY;AAErB,SAAS,eAAe;AAExB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,MAAM,gBAAgB;AAC/B,SAAS,MAAM,SAAS,KAAK,gBAAgB;AAC7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,YAAY;AAErB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAa1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -21,25 +21,28 @@ comment).
21
21
 
22
22
  Raw elements with inline styles are the most common mistake. Use this table:
23
23
 
24
- | Instead of | Use |
25
- | --------------------------------------------------- | ------------------------------------------------------------------------- |
26
- | `div` with `display: flex; flex-direction: column` | `VStack` / `Stack` |
27
- | `div` with `display: flex` (row) | `HStack`, or `Flex` for wrap, grow and basis |
28
- | `div` with `display: grid` | `SimpleGrid columns={{ base: 1, md: 2 }}` |
29
- | `h1`–`h6` with font styles | `Heading as="h1" size="2xl"` |
30
- | `p` / `span` with font size or color | `Text fontSize="sm" color="muted"` |
31
- | bold `span` | `Text as="strong"` |
32
- | `hr`, or a 1px `div` | `Separator` (`orientation="vertical"` inside a row) |
33
- | `button` | `Button visual="primary\|secondary\|neutral\|outline"` |
34
- | `input` + `label` | `Field` + `FieldLabel` + `FieldControl`, or `TextField label` |
35
- | `select` / `textarea` | `Select` / `Textarea` (or `FieldSelect` / `FieldTextarea` inside `Field`) |
36
- | checkbox / radio / toggle `input` | `Checkbox`, `RadioGroup` + `Radio`, `Switch` |
37
- | `table`, `tr`, `td` | `Table`, `Thead`, `Tbody`, `Tr`, `Th`, `Td` |
38
- | panel `div` with border and padding | `Card` + `CardHeader` / `CardBody` / `CardFooter` |
39
- | pill `span` | `Tag` (label) or `Badge` (count or status) |
40
- | `a` | `Link` |
41
- | `a` styled as a button (call to action) | `Button as="a" href="…"` (anchor props are typed) |
42
- | custom modal, side panel, dropdown, tabs or tooltip | `Dialog`, `Drawer`, `Menu`, `Tabs`, `Tooltip` |
24
+ | Instead of | Use |
25
+ | ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
26
+ | page wrapper `div` (max width, centering, gutters) | `Container as="main" size="md"` |
27
+ | plain block `div` with padding, background or radius | `Box padding="md" background="subtle" radius="md"` |
28
+ | `div` with `display: flex; flex-direction: column` | `VStack` / `Stack` |
29
+ | `div` with `display: flex` (row) | `HStack`, or `Flex` for wrap, grow and basis |
30
+ | `div` with `display: grid` | `SimpleGrid columns={{ base: 1, md: 2 }}` |
31
+ | `h1`–`h6` with font styles | `Heading as="h1" size="2xl"` |
32
+ | `p` / `span` with font size or color | `Text fontSize="sm" color="muted"` |
33
+ | bold `span` | `Text as="strong"` |
34
+ | `hr`, or a 1px `div` | `Separator` (`orientation="vertical"` inside a row) |
35
+ | `button` | `Button visual="primary\|secondary\|neutral\|outline"` |
36
+ | `input` + `label` | `Field` + `FieldLabel` + `FieldControl`, or `TextField label` |
37
+ | `select` / `textarea` | `Select` / `Textarea` (or `FieldSelect` / `FieldTextarea` inside `Field`) |
38
+ | checkbox / radio / toggle `input` | `Checkbox`, `RadioGroup` + `Radio`, `Switch` |
39
+ | `table`, `tr`, `td` | `Table`, `Thead`, `Tbody`, `Tr`, `Th`, `Td` |
40
+ | panel `div` with border and padding | `Card` + `CardHeader` / `CardBody` / `CardFooter` |
41
+ | pill `span` | `Tag` (label) or `Badge` (count or status) |
42
+ | inline `svg` icon | `Icon` around your SVG, or a built-in glyph (`SearchIcon`, `ChevronDownIcon`, …); add `label` only when it carries meaning |
43
+ | `a` | `Link` |
44
+ | `a` styled as a button (call to action) | `Button as="a" href="…"` (anchor props are typed) |
45
+ | custom modal, side panel, dropdown, tabs or tooltip | `Dialog`, `Drawer`, `Menu`, `Tabs`, `Tooltip` |
43
46
 
44
47
  Raw elements are fine for semantics Becket doesn't cover (`form`, `main`, `nav`, `section`,
45
48
  `ul`/`li`). Render them through a layout component's `as` prop when they also lay things out:
@@ -48,7 +51,6 @@ Raw elements are fine for semantics Becket doesn't cover (`form`, `main`, `nav`,
48
51
  **Known gaps** (until these ship, an inline `style` with tokens is allowed, with a `TODO` naming the
49
52
  ticket):
50
53
 
51
- - Page width, padding and centering: no `Container` yet (MAV-90).
52
54
  - Font weight on `Text`: no `weight` prop yet (MAV-106). Use `Text as="strong"` for bold.
53
55
  - Status colors on `Badge` and `Tag`: no `success` / `warning` / `danger` visuals yet (MAV-107).
54
56
  Don't use a brand visual (`primary`, `secondary`) to mean a status.
@@ -126,7 +128,7 @@ that holds state or handlers, never on a whole page or barrel file.
126
128
  initialisms in one case (`userID`, `inviteURL`).
127
129
  - Sort imports: third-party (React, then `@becket-ui/react`), then absolute app modules, then
128
130
  relative.
129
- - Comment **why**, not what. A `TODO` names its ticket: `// TODO (MAV-90): use Container`.
131
+ - Comment **why**, not what. A `TODO` names its ticket: `// TODO (MAV-106): use Text weight`.
130
132
 
131
133
  ## 10. Example: a settings screen
132
134
 
@@ -169,7 +171,17 @@ What's wrong:
169
171
 
170
172
  ```tsx
171
173
  import { useState } from "react";
172
- import { Card, CardBody, Heading, HStack, Separator, Switch, Text, VStack } from "@becket-ui/react";
174
+ import {
175
+ Card,
176
+ CardBody,
177
+ Container,
178
+ Heading,
179
+ HStack,
180
+ Separator,
181
+ Switch,
182
+ Text,
183
+ VStack,
184
+ } from "@becket-ui/react";
173
185
 
174
186
  const PREFERENCES = [
175
187
  {
@@ -199,14 +211,7 @@ export function WorkspaceSettings() {
199
211
  });
200
212
 
201
213
  return (
202
- // TODO (MAV-90): replace with Container once it ships.
203
- <div
204
- style={{
205
- maxWidth: "var(--beckui--sizes-4xl)",
206
- marginInline: "auto",
207
- padding: "var(--beckui--spacing-xl)",
208
- }}
209
- >
214
+ <Container as="main" size="md">
210
215
  <VStack gap="xl">
211
216
  <VStack gap="xs">
212
217
  <Heading as="h1" size="2xl">
@@ -246,13 +251,13 @@ export function WorkspaceSettings() {
246
251
  </CardBody>
247
252
  </Card>
248
253
  </VStack>
249
- </div>
254
+ </Container>
250
255
  );
251
256
  }
252
257
  ```
253
258
 
254
- The only raw element left is the page wrapper. It's a known gap with a ticket, and it uses token
255
- values.
259
+ No raw layout or text elements are left: `Container` renders the `main` landmark, and every visual
260
+ decision is a prop with a token value.
256
261
 
257
262
  ## 11. Before you finish
258
263
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@becket-ui/react",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Becket React component library",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,13 +38,13 @@
38
38
  "access": "public"
39
39
  },
40
40
  "peerDependencies": {
41
- "@becket-ui/tokens": "^0.1.3",
41
+ "@becket-ui/tokens": "^0.2.0",
42
42
  "react": ">=19",
43
43
  "react-dom": ">=19"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@becket-ui/a11y": "0.0.0",
47
- "@becket-ui/tokens": "0.1.3",
47
+ "@becket-ui/tokens": "0.2.0",
48
48
  "@pandacss/dev": "^1.12.1",
49
49
  "@storybook/react": "^10.6.0",
50
50
  "@storybook/react-vite": "^10.6.0",
@@ -1,62 +0,0 @@
1
- import { Fragment, jsx, jsxs } 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('renders a link with anchor props when as="a"', () => {
23
- render(
24
- /* @__PURE__ */ jsx(Button, { as: "a", href: "https://example.com", target: "_blank", rel: "noopener noreferrer", visual: "primary", children: "Get started" })
25
- );
26
- const link = screen.getByRole("link", { name: "Get started" });
27
- expect(link.getAttribute("href")).toBe("https://example.com");
28
- expect(link.getAttribute("target")).toBe("_blank");
29
- expect(link.className).toMatch(/beckui--button/);
30
- });
31
- it("types props by the rendered element", () => {
32
- const typed = /* @__PURE__ */ jsxs(Fragment, { children: [
33
- /* @__PURE__ */ jsx(Button, { as: "a", href: "/docs", download: true, children: "Docs" }),
34
- /* @__PURE__ */ jsx(Button, { href: "/docs", children: "Docs" }),
35
- /* @__PURE__ */ jsx(Button, { as: "a", href: "/docs", disabled: true, children: "Docs" })
36
- ] });
37
- expect(typed).toBeTruthy();
38
- });
39
- it("does not submit a wrapping form", async () => {
40
- const onSubmit = vi.fn((event) => event.preventDefault());
41
- const user = userEvent.setup();
42
- render(
43
- /* @__PURE__ */ jsx(
44
- "form",
45
- {
46
- onSubmit: (event) => {
47
- event.preventDefault();
48
- onSubmit(event.nativeEvent);
49
- },
50
- children: /* @__PURE__ */ jsx(Button, { children: "Confirm" })
51
- }
52
- )
53
- );
54
- await user.click(screen.getByRole("button", { name: "Confirm" }));
55
- expect(onSubmit).not.toHaveBeenCalled();
56
- });
57
- it("has no axe violations on a named button", async () => {
58
- const { container } = render(/* @__PURE__ */ jsx(Button, { children: "Save" }));
59
- await assertNoAxeViolations(container);
60
- });
61
- });
62
- //# sourceMappingURL=Button.test.js.map
@@ -1 +0,0 @@
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('renders a link with anchor props when as=\"a\"', () => {\n render(\n <Button as=\"a\" href=\"https://example.com\" target=\"_blank\" rel=\"noopener noreferrer\" visual=\"primary\">\n Get started\n </Button>,\n );\n const link = screen.getByRole('link', { name: 'Get started' });\n expect(link.getAttribute('href')).toBe('https://example.com');\n expect(link.getAttribute('target')).toBe('_blank');\n expect(link.className).toMatch(/beckui--button/);\n });\n\n it('types props by the rendered element', () => {\n // Compile-time checks: these lines fail `tsc` if the polymorphic types regress.\n const typed = (\n <>\n <Button as=\"a\" href=\"/docs\" download>\n Docs\n </Button>\n {/* @ts-expect-error href is not a button prop */}\n <Button href=\"/docs\">Docs</Button>\n {/* @ts-expect-error disabled is not an anchor prop */}\n <Button as=\"a\" href=\"/docs\" disabled>\n Docs\n </Button>\n </>\n );\n expect(typed).toBeTruthy();\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,SAiCL,UAjCK,KAiCL,YAjCK;AATX,SAAS,UAAU,QAAQ,IAAI,UAAU;AACzC,SAAS,QAAQ,cAAc;AAC/B,OAAO,eAAe;AACtB,SAAS,6BAA6B;AAEtC,SAAS,cA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AA,OACF;AAEF,WAAO,KAAK,EAAE,WAAW;AAAA,EAC3B,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":[]}
@@ -1,89 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { describe, expect, it, vi } from "vitest";
3
- import { fireEvent, render, screen, waitFor } 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
- import { Dialog } from "./Dialog";
8
- function ConfirmDialog({
9
- open = true,
10
- role = "dialog",
11
- onOpenChange = () => {
12
- },
13
- ariaLabel
14
- }) {
15
- return /* @__PURE__ */ jsx(
16
- Dialog,
17
- {
18
- open,
19
- onOpenChange,
20
- role,
21
- title: ariaLabel ? void 0 : "Confirm",
22
- "aria-label": ariaLabel,
23
- footer: /* @__PURE__ */ jsxs(Fragment, { children: [
24
- /* @__PURE__ */ jsx(Button, { visual: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
25
- /* @__PURE__ */ jsx(Button, { visual: "primary", onClick: () => onOpenChange(false), children: "Confirm" })
26
- ] }),
27
- children: "Native dialog body."
28
- }
29
- );
30
- }
31
- describe("Dialog", () => {
32
- it("points labelledby and describedby at rendered title and body", () => {
33
- render(/* @__PURE__ */ jsx(ConfirmDialog, {}));
34
- const dialog = screen.getByRole("dialog", { name: "Confirm" });
35
- const labelledBy = dialog.getAttribute("aria-labelledby");
36
- const describedBy = dialog.getAttribute("aria-describedby");
37
- expect(document.getElementById(labelledBy)?.textContent).toBe("Confirm");
38
- expect(document.getElementById(describedBy)?.textContent).toContain("Native dialog body");
39
- });
40
- it("omits labelledby when there is no title node", () => {
41
- render(/* @__PURE__ */ jsx(ConfirmDialog, { ariaLabel: "Unnamed confirm" }));
42
- const dialog = screen.getByRole("dialog", { name: "Unnamed confirm" });
43
- expect(dialog.getAttribute("aria-labelledby")).toBeNull();
44
- });
45
- it("moves initial focus to Cancel, not Close", async () => {
46
- render(/* @__PURE__ */ jsx(ConfirmDialog, {}));
47
- await waitFor(() => {
48
- expect(document.activeElement).toBe(screen.getByRole("button", { name: "Cancel" }));
49
- });
50
- expect(document.activeElement).not.toBe(screen.getByRole("button", { name: "Close" }));
51
- });
52
- it("tabs from the first footer action to Confirm", async () => {
53
- const user = userEvent.setup();
54
- render(/* @__PURE__ */ jsx(ConfirmDialog, {}));
55
- await waitFor(() => {
56
- expect(document.activeElement).toBe(screen.getByRole("button", { name: "Cancel" }));
57
- });
58
- await user.tab();
59
- expect(document.activeElement).toBe(screen.getByRole("button", { name: "Confirm" }));
60
- });
61
- it("closes a dialog on backdrop click but not an alertdialog", () => {
62
- const onDialog = vi.fn();
63
- const { rerender } = render(/* @__PURE__ */ jsx(ConfirmDialog, { onOpenChange: onDialog }));
64
- fireEvent.click(screen.getByRole("dialog", { name: "Confirm" }));
65
- expect(onDialog).toHaveBeenCalledWith(false);
66
- const onAlert = vi.fn();
67
- rerender(/* @__PURE__ */ jsx(ConfirmDialog, { role: "alertdialog", onOpenChange: onAlert }));
68
- fireEvent.click(screen.getByRole("alertdialog", { name: "Confirm" }));
69
- expect(onAlert).not.toHaveBeenCalled();
70
- });
71
- it("lets Close aria-label be overridden", () => {
72
- render(
73
- /* @__PURE__ */ jsx(Dialog, { open: true, title: "Confirm", children: "Body" })
74
- );
75
- expect(screen.getByRole("button", { name: "Close" })).toBeTruthy();
76
- });
77
- it("closes on Escape via the native dialog close event", () => {
78
- const onOpenChange = vi.fn();
79
- render(/* @__PURE__ */ jsx(ConfirmDialog, { onOpenChange }));
80
- fireEvent.keyDown(screen.getByRole("dialog", { name: "Confirm" }), { key: "Escape" });
81
- fireEvent(screen.getByRole("dialog", { name: "Confirm" }), new Event("close", { bubbles: true }));
82
- expect(onOpenChange).toHaveBeenCalledWith(false);
83
- });
84
- it("has no axe violations when open", async () => {
85
- const { container } = render(/* @__PURE__ */ jsx(ConfirmDialog, {}));
86
- await assertNoAxeViolations(container);
87
- });
88
- });
89
- //# sourceMappingURL=Dialog.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Dialog.test.tsx"],"sourcesContent":["import { describe, expect, it, vi } from 'vitest';\nimport { fireEvent, render, screen, waitFor } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { assertNoAxeViolations } from '@becket-ui/a11y';\n\nimport { Button } from './Button';\nimport { Dialog } from './Dialog';\n\nfunction ConfirmDialog({\n open = true,\n role = 'dialog' as 'dialog' | 'alertdialog',\n onOpenChange = () => {},\n ariaLabel,\n}: {\n open?: boolean;\n role?: 'dialog' | 'alertdialog';\n onOpenChange?: (open: boolean) => void;\n ariaLabel?: string;\n}) {\n return (\n <Dialog\n open={open}\n onOpenChange={onOpenChange}\n role={role}\n title={ariaLabel ? undefined : 'Confirm'}\n aria-label={ariaLabel}\n footer={\n <>\n <Button visual=\"outline\" onClick={() => onOpenChange(false)}>\n Cancel\n </Button>\n <Button visual=\"primary\" onClick={() => onOpenChange(false)}>\n Confirm\n </Button>\n </>\n }\n >\n Native dialog body.\n </Dialog>\n );\n}\n\ndescribe('Dialog', () => {\n it('points labelledby and describedby at rendered title and body', () => {\n render(<ConfirmDialog />);\n const dialog = screen.getByRole('dialog', { name: 'Confirm' });\n const labelledBy = dialog.getAttribute('aria-labelledby');\n const describedBy = dialog.getAttribute('aria-describedby');\n expect(document.getElementById(labelledBy as string)?.textContent).toBe('Confirm');\n expect(document.getElementById(describedBy as string)?.textContent).toContain('Native dialog body');\n });\n\n it('omits labelledby when there is no title node', () => {\n render(<ConfirmDialog ariaLabel=\"Unnamed confirm\" />);\n const dialog = screen.getByRole('dialog', { name: 'Unnamed confirm' });\n expect(dialog.getAttribute('aria-labelledby')).toBeNull();\n });\n\n it('moves initial focus to Cancel, not Close', async () => {\n render(<ConfirmDialog />);\n await waitFor(() => {\n expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Cancel' }));\n });\n expect(document.activeElement).not.toBe(screen.getByRole('button', { name: 'Close' }));\n });\n\n it('tabs from the first footer action to Confirm', async () => {\n const user = userEvent.setup();\n render(<ConfirmDialog />);\n await waitFor(() => {\n expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Cancel' }));\n });\n await user.tab();\n expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Confirm' }));\n });\n\n it('closes a dialog on backdrop click but not an alertdialog', () => {\n const onDialog = vi.fn();\n const { rerender } = render(<ConfirmDialog onOpenChange={onDialog} />);\n fireEvent.click(screen.getByRole('dialog', { name: 'Confirm' }));\n expect(onDialog).toHaveBeenCalledWith(false);\n\n const onAlert = vi.fn();\n rerender(<ConfirmDialog role=\"alertdialog\" onOpenChange={onAlert} />);\n fireEvent.click(screen.getByRole('alertdialog', { name: 'Confirm' }));\n expect(onAlert).not.toHaveBeenCalled();\n });\n\n it('lets Close aria-label be overridden', () => {\n render(\n <Dialog open title=\"Confirm\">\n Body\n </Dialog>,\n );\n expect(screen.getByRole('button', { name: 'Close' })).toBeTruthy();\n });\n\n it('closes on Escape via the native dialog close event', () => {\n const onOpenChange = vi.fn();\n render(<ConfirmDialog onOpenChange={onOpenChange} />);\n fireEvent.keyDown(screen.getByRole('dialog', { name: 'Confirm' }), { key: 'Escape' });\n fireEvent(screen.getByRole('dialog', { name: 'Confirm' }), new Event('close', { bubbles: true }));\n expect(onOpenChange).toHaveBeenCalledWith(false);\n });\n\n it('has no axe violations when open', async () => {\n const { container } = render(<ConfirmDialog />);\n await assertNoAxeViolations(container);\n });\n});\n"],"mappings":"AA2BQ,mBACE,KADF;AA3BR,SAAS,UAAU,QAAQ,IAAI,UAAU;AACzC,SAAS,WAAW,QAAQ,QAAQ,eAAe;AACnD,OAAO,eAAe;AACtB,SAAS,6BAA6B;AAEtC,SAAS,cAAc;AACvB,SAAS,cAAc;AAEvB,SAAS,cAAc;AAAA,EACrB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB;AACF,GAKG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO,YAAY,SAAY;AAAA,MAC/B,cAAY;AAAA,MACZ,QACE,iCACE;AAAA,4BAAC,UAAO,QAAO,WAAU,SAAS,MAAM,aAAa,KAAK,GAAG,oBAE7D;AAAA,QACA,oBAAC,UAAO,QAAO,WAAU,SAAS,MAAM,aAAa,KAAK,GAAG,qBAE7D;AAAA,SACF;AAAA,MAEH;AAAA;AAAA,EAED;AAEJ;AAEA,SAAS,UAAU,MAAM;AACvB,KAAG,gEAAgE,MAAM;AACvE,WAAO,oBAAC,iBAAc,CAAE;AACxB,UAAM,SAAS,OAAO,UAAU,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7D,UAAM,aAAa,OAAO,aAAa,iBAAiB;AACxD,UAAM,cAAc,OAAO,aAAa,kBAAkB;AAC1D,WAAO,SAAS,eAAe,UAAoB,GAAG,WAAW,EAAE,KAAK,SAAS;AACjF,WAAO,SAAS,eAAe,WAAqB,GAAG,WAAW,EAAE,UAAU,oBAAoB;AAAA,EACpG,CAAC;AAED,KAAG,gDAAgD,M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I,iBAAiB;AAAA,EACvC,CAAC;AAED,KAAG,uCAAuC,MAAM;AAC9C;AAAA,MACE,oBAAC,UAAO,MAAI,MAAC,OAAM,WAAU,kBAE7B;AAAA,IACF;AACA,WAAO,OAAO,UAAU,UAAU,EAAE,MAAM,QAAQ,CAAC,CAAC,EAAE,WAAW;AAAA,EACnE,CAAC;AAED,KAAG,sDAAsD,MAAM;AAC7D,UAAM,eAAe,GAAG,GAAG;AAC3B,WAAO,oBAAC,iBAAc,cAA4B,CAAE;AACpD,cAAU,QAAQ,OAAO,UAAU,UAAU,EAAE,MAAM,UAAU,CAAC,GAAG,EAAE,KAAK,SAAS,CAAC;AACpF,cAAU,OAAO,UAAU,UAAU,EAAE,MAAM,UAAU,CAAC,GAAG,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC,CAAC;AAChG,WAAO,YAAY,EAAE,qBAAqB,KAAK;AAAA,EACjD,CAAC;AAED,KAAG,mCAAmC,YAAY;AAChD,UAAM,EAAE,UAAU,IAAI,OAAO,oBAAC,iBAAc,CAAE;AAC9C,UAAM,sBAAsB,SAAS;AAAA,EACvC,CAAC;AACH,CAAC;","names":[]}
@@ -1,50 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { describe, expect, it, vi } from "vitest";
3
- import { fireEvent, render, screen, waitFor } from "@testing-library/react";
4
- import { assertNoAxeViolations } from "@becket-ui/a11y";
5
- import { Button } from "./Button";
6
- import { Drawer } from "./Drawer";
7
- function FiltersDrawer({
8
- onOpenChange = () => {
9
- },
10
- role = "dialog"
11
- }) {
12
- return /* @__PURE__ */ jsx(
13
- Drawer,
14
- {
15
- open: true,
16
- role,
17
- onOpenChange,
18
- title: "Filters",
19
- footer: /* @__PURE__ */ jsx(Button, { visual: "primary", onClick: () => onOpenChange(false), children: "Done" }),
20
- children: "Same a11y as Dialog."
21
- }
22
- );
23
- }
24
- describe("Drawer", () => {
25
- it("names the dialog from the title and describes it from the body", () => {
26
- render(/* @__PURE__ */ jsx(FiltersDrawer, {}));
27
- const dialog = screen.getByRole("dialog", { name: "Filters" });
28
- const labelledBy = dialog.getAttribute("aria-labelledby");
29
- const describedBy = dialog.getAttribute("aria-describedby");
30
- expect(document.getElementById(labelledBy)?.textContent).toBe("Filters");
31
- expect(document.getElementById(describedBy)?.textContent).toContain("Same a11y as Dialog");
32
- });
33
- it("moves initial focus to the footer action, not Close", async () => {
34
- render(/* @__PURE__ */ jsx(FiltersDrawer, {}));
35
- await waitFor(() => {
36
- expect(document.activeElement).toBe(screen.getByRole("button", { name: "Done" }));
37
- });
38
- });
39
- it("does not light-dismiss an alertdialog", () => {
40
- const onOpenChange = vi.fn();
41
- render(/* @__PURE__ */ jsx(FiltersDrawer, { role: "alertdialog", onOpenChange }));
42
- fireEvent.click(screen.getByRole("alertdialog", { name: "Filters" }));
43
- expect(onOpenChange).not.toHaveBeenCalled();
44
- });
45
- it("has no axe violations when open", async () => {
46
- const { container } = render(/* @__PURE__ */ jsx(FiltersDrawer, {}));
47
- await assertNoAxeViolations(container);
48
- });
49
- });
50
- //# sourceMappingURL=Drawer.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Drawer.test.tsx"],"sourcesContent":["import { describe, expect, it, vi } from 'vitest';\nimport { fireEvent, render, screen, waitFor } from '@testing-library/react';\nimport { assertNoAxeViolations } from '@becket-ui/a11y';\n\nimport { Button } from './Button';\nimport { Drawer } from './Drawer';\n\nfunction FiltersDrawer({\n onOpenChange = () => {},\n role = 'dialog' as 'dialog' | 'alertdialog',\n}: {\n onOpenChange?: (open: boolean) => void;\n role?: 'dialog' | 'alertdialog';\n}) {\n return (\n <Drawer\n open\n role={role}\n onOpenChange={onOpenChange}\n title=\"Filters\"\n footer={\n <Button visual=\"primary\" onClick={() => onOpenChange(false)}>\n Done\n </Button>\n }\n >\n Same a11y as Dialog.\n </Drawer>\n );\n}\n\ndescribe('Drawer', () => {\n it('names the dialog from the title and describes it from the body', () => {\n render(<FiltersDrawer />);\n const dialog = screen.getByRole('dialog', { name: 'Filters' });\n const labelledBy = dialog.getAttribute('aria-labelledby');\n const describedBy = dialog.getAttribute('aria-describedby');\n expect(document.getElementById(labelledBy as string)?.textContent).toBe('Filters');\n expect(document.getElementById(describedBy as string)?.textContent).toContain('Same a11y as Dialog');\n });\n\n it('moves initial focus to the footer action, not Close', async () => {\n render(<FiltersDrawer />);\n await waitFor(() => {\n expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Done' }));\n });\n });\n\n it('does not light-dismiss an alertdialog', () => {\n const onOpenChange = vi.fn();\n render(<FiltersDrawer role=\"alertdialog\" onOpenChange={onOpenChange} />);\n fireEvent.click(screen.getByRole('alertdialog', { name: 'Filters' }));\n expect(onOpenChange).not.toHaveBeenCalled();\n });\n\n it('has no axe violations when open', async () => {\n const { container } = render(<FiltersDrawer />);\n await assertNoAxeViolations(container);\n });\n});\n"],"mappings":"AAqBQ;AArBR,SAAS,UAAU,QAAQ,IAAI,UAAU;AACzC,SAAS,WAAW,QAAQ,QAAQ,eAAe;AACnD,SAAS,6BAA6B;AAEtC,SAAS,cAAc;AACvB,SAAS,cAAc;AAEvB,SAAS,cAAc;AAAA,EACrB,eAAe,MAAM;AAAA,EAAC;AAAA,EACtB,OAAO;AACT,GAGG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAI;AAAA,MACJ;AAAA,MACA;AAAA,MACA,OAAM;AAAA,MACN,QACE,oBAAC,UAAO,QAAO,WAAU,SAAS,MAAM,aAAa,KAAK,GAAG,kBAE7D;AAAA,MAEH;AAAA;AAAA,EAED;AAEJ;AAEA,SAAS,UAAU,MAAM;AACvB,KAAG,kEAAkE,MAAM;AACzE,WAAO,oBAAC,iBAAc,CAAE;AACxB,UAAM,SAAS,OAAO,UAAU,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7D,UAAM,aAAa,OAAO,aAAa,iBAAiB;AACxD,UAAM,cAAc,OAAO,aAAa,kBAAkB;AAC1D,WAAO,SAAS,eAAe,UAAoB,GAAG,WAAW,EAAE,KAAK,SAAS;AACjF,WAAO,SAAS,eAAe,WAAqB,GAAG,WAAW,EAAE,UAAU,qBAAqB;AAAA,EACrG,CAAC;AAED,KAAG,uDAAuD,YAAY;AACpE,WAAO,oBAAC,iBAAc,CAAE;AACxB,UAAM,QAAQ,MAAM;AAClB,aAAO,SAAS,aAAa,EAAE,KAAK,OAAO,UAAU,UAAU,EAAE,MAAM,OAAO,CAAC,CAAC;AAAA,IAClF,CAAC;AAAA,EACH,CAAC;AAED,KAAG,yCAAyC,MAAM;AAChD,UAAM,eAAe,GAAG,GAAG;AAC3B,WAAO,oBAAC,iBAAc,MAAK,eAAc,cAA4B,CAAE;AACvE,cAAU,MAAM,OAAO,UAAU,eAAe,EAAE,MAAM,UAAU,CAAC,CAAC;AACpE,WAAO,YAAY,EAAE,IAAI,iBAAiB;AAAA,EAC5C,CAAC;AAED,KAAG,mCAAmC,YAAY;AAChD,UAAM,EAAE,UAAU,IAAI,OAAO,oBAAC,iBAAc,CAAE;AAC9C,UAAM,sBAAsB,SAAS;AAAA,EACvC,CAAC;AACH,CAAC;","names":[]}
@@ -1,33 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { describe, expect, it } from "vitest";
3
- import { render, screen } from "@testing-library/react";
4
- import { Field } from "./Field";
5
- import { Radio, RadioGroup } from "./Radio";
6
- import { TextField } from "./TextField";
7
- describe("Field describedBy", () => {
8
- it("omits aria-describedby when TextField has no helper", () => {
9
- render(/* @__PURE__ */ jsx(TextField, { label: "Offset" }));
10
- expect(screen.getByLabelText("Offset").getAttribute("aria-describedby")).toBeNull();
11
- });
12
- it("points at FieldHelper when valid with helperText", () => {
13
- render(/* @__PURE__ */ jsx(TextField, { label: "Offset", helperText: "Optional hint" }));
14
- const describedBy = screen.getByLabelText("Offset").getAttribute("aria-describedby");
15
- expect(describedBy).toBeTruthy();
16
- expect(document.getElementById(describedBy)?.textContent).toBe("Optional hint");
17
- });
18
- it("points at FieldError when invalid with helperText", () => {
19
- render(/* @__PURE__ */ jsx(TextField, { label: "Email", invalid: true, helperText: "Enter a valid email address" }));
20
- const describedBy = screen.getByLabelText("Email").getAttribute("aria-describedby");
21
- expect(describedBy).toBeTruthy();
22
- const node = document.getElementById(describedBy);
23
- expect(node?.getAttribute("role")).toBe("alert");
24
- expect(node?.textContent).toBe("Enter a valid email address");
25
- });
26
- it("does not give RadioGroup a dangling describedBy", () => {
27
- render(
28
- /* @__PURE__ */ jsx(Field, { children: /* @__PURE__ */ jsx(RadioGroup, { legend: "Side", children: /* @__PURE__ */ jsx(Radio, { value: "yes", label: "Yes" }) }) })
29
- );
30
- expect(screen.getByRole("group", { name: "Side" }).getAttribute("aria-describedby")).toBeNull();
31
- });
32
- });
33
- //# sourceMappingURL=Field.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Field.test.tsx"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { render, screen } from '@testing-library/react';\n\nimport { Field } from './Field';\nimport { Radio, RadioGroup } from './Radio';\nimport { TextField } from './TextField';\n\ndescribe('Field describedBy', () => {\n it('omits aria-describedby when TextField has no helper', () => {\n render(<TextField label=\"Offset\" />);\n expect(screen.getByLabelText('Offset').getAttribute('aria-describedby')).toBeNull();\n });\n\n it('points at FieldHelper when valid with helperText', () => {\n render(<TextField label=\"Offset\" helperText=\"Optional hint\" />);\n const describedBy = screen.getByLabelText('Offset').getAttribute('aria-describedby');\n expect(describedBy).toBeTruthy();\n expect(document.getElementById(describedBy as string)?.textContent).toBe('Optional hint');\n });\n\n it('points at FieldError when invalid with helperText', () => {\n render(<TextField label=\"Email\" invalid helperText=\"Enter a valid email address\" />);\n const describedBy = screen.getByLabelText('Email').getAttribute('aria-describedby');\n expect(describedBy).toBeTruthy();\n const node = document.getElementById(describedBy as string);\n expect(node?.getAttribute('role')).toBe('alert');\n expect(node?.textContent).toBe('Enter a valid email address');\n });\n\n it('does not give RadioGroup a dangling describedBy', () => {\n render(\n <Field>\n <RadioGroup legend=\"Side\">\n <Radio value=\"yes\" label=\"Yes\" />\n </RadioGroup>\n </Field>,\n );\n expect(screen.getByRole('group', { name: 'Side' }).getAttribute('aria-describedby')).toBeNull();\n });\n});\n"],"mappings":"AASW;AATX,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,QAAQ,cAAc;AAE/B,SAAS,aAAa;AACtB,SAAS,OAAO,kBAAkB;AAClC,SAAS,iBAAiB;AAE1B,SAAS,qBAAqB,MAAM;AAClC,KAAG,uDAAuD,MAAM;AAC9D,WAAO,oBAAC,aAAU,OAAM,UAAS,CAAE;AACnC,WAAO,OAAO,eAAe,QAAQ,EAAE,aAAa,kBAAkB,CAAC,EAAE,SAAS;AAAA,EACpF,CAAC;AAED,KAAG,oDAAoD,MAAM;AAC3D,WAAO,oBAAC,aAAU,OAAM,UAAS,YAAW,iBAAgB,CAAE;AAC9D,UAAM,cAAc,OAAO,eAAe,QAAQ,EAAE,aAAa,kBAAkB;AACnF,WAAO,WAAW,EAAE,WAAW;AAC/B,WAAO,SAAS,eAAe,WAAqB,GAAG,WAAW,EAAE,KAAK,eAAe;AAAA,EAC1F,CAAC;AAED,KAAG,qDAAqD,MAAM;AAC5D,WAAO,oBAAC,aAAU,OAAM,SAAQ,SAAO,MAAC,YAAW,+BAA8B,CAAE;AACnF,UAAM,cAAc,OAAO,eAAe,OAAO,EAAE,aAAa,kBAAkB;AAClF,WAAO,WAAW,EAAE,WAAW;AAC/B,UAAM,OAAO,SAAS,eAAe,WAAqB;AAC1D,WAAO,MAAM,aAAa,MAAM,CAAC,EAAE,KAAK,OAAO;AAC/C,WAAO,MAAM,WAAW,EAAE,KAAK,6BAA6B;AAAA,EAC9D,CAAC;AAED,KAAG,mDAAmD,MAAM;AAC1D;AAAA,MACE,oBAAC,SACC,8BAAC,cAAW,QAAO,QACjB,8BAAC,SAAM,OAAM,OAAM,OAAM,OAAM,GACjC,GACF;AAAA,IACF;AACA,WAAO,OAAO,UAAU,SAAS,EAAE,MAAM,OAAO,CAAC,EAAE,aAAa,kBAAkB,CAAC,EAAE,SAAS;AAAA,EAChG,CAAC;AACH,CAAC;","names":[]}
@@ -1,69 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { describe, expect, it } from "vitest";
3
- import { render, screen, waitFor } from "@testing-library/react";
4
- import userEvent from "@testing-library/user-event";
5
- import { assertNoAxeViolations } from "@becket-ui/a11y";
6
- import { Menu, MenuItem } from "./Menu";
7
- describe("Menu", () => {
8
- it("exposes expanded and haspopup on the trigger", async () => {
9
- const user = userEvent.setup();
10
- render(
11
- /* @__PURE__ */ jsxs(Menu, { label: "Actions", children: [
12
- /* @__PURE__ */ jsx(MenuItem, { children: "Edit" }),
13
- /* @__PURE__ */ jsx(MenuItem, { children: "Duplicate" })
14
- ] })
15
- );
16
- const trigger = screen.getByText("Actions");
17
- expect(trigger.tagName).toBe("SUMMARY");
18
- expect(trigger.getAttribute("aria-haspopup")).toBe("menu");
19
- expect(trigger.getAttribute("aria-expanded")).toBe("false");
20
- await user.click(trigger);
21
- expect(trigger.getAttribute("aria-expanded")).toBe("true");
22
- });
23
- it("keeps open items out of Tab order", async () => {
24
- const user = userEvent.setup();
25
- render(
26
- /* @__PURE__ */ jsxs(Fragment, { children: [
27
- /* @__PURE__ */ jsx("button", { type: "button", children: "Before" }),
28
- /* @__PURE__ */ jsxs(Menu, { label: "Actions", children: [
29
- /* @__PURE__ */ jsx(MenuItem, { children: "Edit" }),
30
- /* @__PURE__ */ jsx(MenuItem, { children: "Duplicate" })
31
- ] }),
32
- /* @__PURE__ */ jsx("button", { type: "button", children: "After" })
33
- ] })
34
- );
35
- await user.click(screen.getByText("Actions"));
36
- expect(screen.getByRole("menuitem", { name: "Edit" }).getAttribute("tabindex")).toBe("-1");
37
- expect(screen.getByRole("menuitem", { name: "Duplicate" }).getAttribute("tabindex")).toBe("-1");
38
- await waitFor(() => {
39
- expect(document.activeElement).toBe(screen.getByRole("menuitem", { name: "Edit" }));
40
- });
41
- await user.tab();
42
- expect(document.activeElement).toBe(screen.getByRole("button", { name: "After" }));
43
- });
44
- it("moves between items with arrows", async () => {
45
- const user = userEvent.setup();
46
- render(
47
- /* @__PURE__ */ jsxs(Menu, { label: "Actions", children: [
48
- /* @__PURE__ */ jsx(MenuItem, { children: "Edit" }),
49
- /* @__PURE__ */ jsx(MenuItem, { children: "Duplicate" })
50
- ] })
51
- );
52
- await user.click(screen.getByText("Actions"));
53
- await waitFor(() => {
54
- expect(document.activeElement).toBe(screen.getByRole("menuitem", { name: "Edit" }));
55
- });
56
- await user.keyboard("{ArrowDown}");
57
- expect(document.activeElement).toBe(screen.getByRole("menuitem", { name: "Duplicate" }));
58
- });
59
- it("has no axe violations", async () => {
60
- const { container } = render(
61
- /* @__PURE__ */ jsxs(Menu, { label: "Actions", children: [
62
- /* @__PURE__ */ jsx(MenuItem, { children: "Edit" }),
63
- /* @__PURE__ */ jsx(MenuItem, { children: "Duplicate" })
64
- ] })
65
- );
66
- await assertNoAxeViolations(container);
67
- });
68
- });
69
- //# sourceMappingURL=Menu.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Menu.test.tsx"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { render, screen, waitFor } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { assertNoAxeViolations } from '@becket-ui/a11y';\n\nimport { Menu, MenuItem } from './Menu';\n\ndescribe('Menu', () => {\n it('exposes expanded and haspopup on the trigger', async () => {\n const user = userEvent.setup();\n render(\n <Menu label=\"Actions\">\n <MenuItem>Edit</MenuItem>\n <MenuItem>Duplicate</MenuItem>\n </Menu>,\n );\n const trigger = screen.getByText('Actions');\n expect(trigger.tagName).toBe('SUMMARY');\n expect(trigger.getAttribute('aria-haspopup')).toBe('menu');\n expect(trigger.getAttribute('aria-expanded')).toBe('false');\n\n await user.click(trigger);\n expect(trigger.getAttribute('aria-expanded')).toBe('true');\n });\n\n it('keeps open items out of Tab order', async () => {\n const user = userEvent.setup();\n render(\n <>\n <button type=\"button\">Before</button>\n <Menu label=\"Actions\">\n <MenuItem>Edit</MenuItem>\n <MenuItem>Duplicate</MenuItem>\n </Menu>\n <button type=\"button\">After</button>\n </>,\n );\n\n await user.click(screen.getByText('Actions'));\n expect(screen.getByRole('menuitem', { name: 'Edit' }).getAttribute('tabindex')).toBe('-1');\n expect(screen.getByRole('menuitem', { name: 'Duplicate' }).getAttribute('tabindex')).toBe('-1');\n\n await waitFor(() => {\n expect(document.activeElement).toBe(screen.getByRole('menuitem', { name: 'Edit' }));\n });\n await user.tab();\n expect(document.activeElement).toBe(screen.getByRole('button', { name: 'After' }));\n });\n\n it('moves between items with arrows', async () => {\n const user = userEvent.setup();\n render(\n <Menu label=\"Actions\">\n <MenuItem>Edit</MenuItem>\n <MenuItem>Duplicate</MenuItem>\n </Menu>,\n );\n await user.click(screen.getByText('Actions'));\n await waitFor(() => {\n expect(document.activeElement).toBe(screen.getByRole('menuitem', { name: 'Edit' }));\n });\n await user.keyboard('{ArrowDown}');\n expect(document.activeElement).toBe(screen.getByRole('menuitem', { name: 'Duplicate' }));\n });\n\n it('has no axe violations', async () => {\n const { container } = render(\n <Menu label=\"Actions\">\n <MenuItem>Edit</MenuItem>\n <MenuItem>Duplicate</MenuItem>\n </Menu>,\n );\n await assertNoAxeViolations(container);\n });\n});\n"],"mappings":"AAWM,SAiBA,UAhBE,KADF;AAXN,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,QAAQ,QAAQ,eAAe;AACxC,OAAO,eAAe;AACtB,SAAS,6BAA6B;AAEtC,SAAS,MAAM,gBAAgB;AAE/B,SAAS,QAAQ,MAAM;AACrB,KAAG,gDAAgD,YAAY;AAC7D,UAAM,OAAO,UAAU,MAAM;AAC7B;AAAA,MACE,qBAAC,QAAK,OAAM,WACV;AAAA,4BAAC,YAAS,kBAAI;AAAA,QACd,oBAAC,YAAS,uBAAS;AAAA,SACrB;AAAA,IACF;AACA,UAAM,UAAU,OAAO,UA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IACF;AACA,UAAM,KAAK,MAAM,OAAO,UAAU,SAAS,CAAC;AAC5C,UAAM,QAAQ,MAAM;AAClB,aAAO,SAAS,aAAa,EAAE,KAAK,OAAO,UAAU,YAAY,EAAE,MAAM,OAAO,CAAC,CAAC;AAAA,IACpF,CAAC;AACD,UAAM,KAAK,SAAS,aAAa;AACjC,WAAO,SAAS,aAAa,EAAE,KAAK,OAAO,UAAU,YAAY,EAAE,MAAM,YAAY,CAAC,CAAC;AAAA,EACzF,CAAC;AAED,KAAG,yBAAyB,YAAY;AACtC,UAAM,EAAE,UAAU,IAAI;AAAA,MACpB,qBAAC,QAAK,OAAM,WACV;AAAA,4BAAC,YAAS,kBAAI;AAAA,QACd,oBAAC,YAAS,uBAAS;AAAA,SACrB;AAAA,IACF;AACA,UAAM,sBAAsB,SAAS;AAAA,EACvC,CAAC;AACH,CAAC;","names":[]}
@@ -1,28 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { describe, expect, it } 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 { Switch } from "./Switch";
7
- describe("Switch", () => {
8
- it("gets its accessible name from label", () => {
9
- render(/* @__PURE__ */ jsx(Switch, { label: "Notifications" }));
10
- expect(screen.getByRole("switch", { name: "Notifications" })).toBeTruthy();
11
- });
12
- it("toggles on Space and Enter", async () => {
13
- const user = userEvent.setup();
14
- render(/* @__PURE__ */ jsx(Switch, { label: "Notifications" }));
15
- const control = screen.getByRole("switch", { name: "Notifications" });
16
- expect(control.getAttribute("aria-checked")).toBe("false");
17
- control.focus();
18
- await user.keyboard(" ");
19
- expect(control.getAttribute("aria-checked")).toBe("true");
20
- await user.keyboard("{Enter}");
21
- expect(control.getAttribute("aria-checked")).toBe("false");
22
- });
23
- it("has no axe violations with a visible label", async () => {
24
- const { container } = render(/* @__PURE__ */ jsx(Switch, { label: "Notifications" }));
25
- await assertNoAxeViolations(container);
26
- });
27
- });
28
- //# sourceMappingURL=Switch.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Switch.test.tsx"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { assertNoAxeViolations } from '@becket-ui/a11y';\n\nimport { Switch } from './Switch';\n\ndescribe('Switch', () => {\n it('gets its accessible name from label', () => {\n render(<Switch label=\"Notifications\" />);\n expect(screen.getByRole('switch', { name: 'Notifications' })).toBeTruthy();\n });\n\n it('toggles on Space and Enter', async () => {\n const user = userEvent.setup();\n render(<Switch label=\"Notifications\" />);\n const control = screen.getByRole('switch', { name: 'Notifications' });\n expect(control.getAttribute('aria-checked')).toBe('false');\n control.focus();\n await user.keyboard(' ');\n expect(control.getAttribute('aria-checked')).toBe('true');\n await user.keyboard('{Enter}');\n expect(control.getAttribute('aria-checked')).toBe('false');\n });\n\n it('has no axe violations with a visible label', async () => {\n const { container } = render(<Switch label=\"Notifications\" />);\n await assertNoAxeViolations(container);\n });\n});\n"],"mappings":"AASW;AATX,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,QAAQ,cAAc;AAC/B,OAAO,eAAe;AACtB,SAAS,6BAA6B;AAEtC,SAAS,cAAc;AAEvB,SAAS,UAAU,MAAM;AACvB,KAAG,uCAAuC,MAAM;AAC9C,WAAO,oBAAC,UAAO,OAAM,iBAAgB,CAAE;AACvC,WAAO,OAAO,UAAU,UAAU,EAAE,MAAM,gBAAgB,CAAC,CAAC,EAAE,WAAW;AAAA,EAC3E,CAAC;AAED,KAAG,8BAA8B,YAAY;AAC3C,UAAM,OAAO,UAAU,MAAM;AAC7B,WAAO,oBAAC,UAAO,OAAM,iBAAgB,CAAE;AACvC,UAAM,UAAU,OAAO,UAAU,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpE,WAAO,QAAQ,aAAa,cAAc,CAAC,EAAE,KAAK,OAAO;AACzD,YAAQ,MAAM;AACd,UAAM,KAAK,SAAS,GAAG;AACvB,WAAO,QAAQ,aAAa,cAAc,CAAC,EAAE,KAAK,MAAM;AACxD,UAAM,KAAK,SAAS,SAAS;AAC7B,WAAO,QAAQ,aAAa,cAAc,CAAC,EAAE,KAAK,OAAO;AAAA,EAC3D,CAAC;AAED,KAAG,8CAA8C,YAAY;AAC3D,UAAM,EAAE,UAAU,IAAI,OAAO,oBAAC,UAAO,OAAM,iBAAgB,CAAE;AAC7D,UAAM,sBAAsB,SAAS;AAAA,EACvC,CAAC;AACH,CAAC;","names":[]}
@@ -1,41 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { describe, expect, it } 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 { Tab, TabList, TabPanel, Tabs } from "./Tabs";
7
- function DemoTabs() {
8
- return /* @__PURE__ */ jsxs(Tabs, { defaultValue: "one", children: [
9
- /* @__PURE__ */ jsxs(TabList, { children: [
10
- /* @__PURE__ */ jsx(Tab, { value: "one", children: "Overview" }),
11
- /* @__PURE__ */ jsx(Tab, { value: "two", children: "Activity" }),
12
- /* @__PURE__ */ jsx(Tab, { value: "three", disabled: true, children: "Disabled" })
13
- ] }),
14
- /* @__PURE__ */ jsx(TabPanel, { value: "one", children: "First panel." }),
15
- /* @__PURE__ */ jsx(TabPanel, { value: "two", children: "Second panel." }),
16
- /* @__PURE__ */ jsx(TabPanel, { value: "three", children: "Hidden." })
17
- ] });
18
- }
19
- describe("Tabs", () => {
20
- it("sets horizontal orientation", () => {
21
- render(/* @__PURE__ */ jsx(DemoTabs, {}));
22
- expect(screen.getByRole("tablist").getAttribute("aria-orientation")).toBe("horizontal");
23
- });
24
- it("moves to first and last enabled tab with Home and End", async () => {
25
- const user = userEvent.setup();
26
- render(/* @__PURE__ */ jsx(DemoTabs, {}));
27
- screen.getByRole("tab", { name: "Overview" }).focus();
28
- await user.keyboard("{End}");
29
- expect(document.activeElement).toBe(screen.getByRole("tab", { name: "Activity" }));
30
- expect(screen.getByRole("tab", { name: "Activity" }).getAttribute("aria-selected")).toBe("true");
31
- await user.keyboard("{Home}");
32
- expect(document.activeElement).toBe(screen.getByRole("tab", { name: "Overview" }));
33
- await user.keyboard("{ArrowRight}");
34
- expect(document.activeElement).toBe(screen.getByRole("tab", { name: "Activity" }));
35
- });
36
- it("has no axe violations", async () => {
37
- const { container } = render(/* @__PURE__ */ jsx(DemoTabs, {}));
38
- await assertNoAxeViolations(container);
39
- });
40
- });
41
- //# sourceMappingURL=Tabs.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Tabs.test.tsx"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { assertNoAxeViolations } from '@becket-ui/a11y';\n\nimport { Tab, TabList, TabPanel, Tabs } from './Tabs';\n\nfunction DemoTabs() {\n return (\n <Tabs defaultValue=\"one\">\n <TabList>\n <Tab value=\"one\">Overview</Tab>\n <Tab value=\"two\">Activity</Tab>\n <Tab value=\"three\" disabled>\n Disabled\n </Tab>\n </TabList>\n <TabPanel value=\"one\">First panel.</TabPanel>\n <TabPanel value=\"two\">Second panel.</TabPanel>\n <TabPanel value=\"three\">Hidden.</TabPanel>\n </Tabs>\n );\n}\n\ndescribe('Tabs', () => {\n it('sets horizontal orientation', () => {\n render(<DemoTabs />);\n expect(screen.getByRole('tablist').getAttribute('aria-orientation')).toBe('horizontal');\n });\n\n it('moves to first and last enabled tab with Home and End', async () => {\n const user = userEvent.setup();\n render(<DemoTabs />);\n screen.getByRole('tab', { name: 'Overview' }).focus();\n await user.keyboard('{End}');\n expect(document.activeElement).toBe(screen.getByRole('tab', { name: 'Activity' }));\n expect(screen.getByRole('tab', { name: 'Activity' }).getAttribute('aria-selected')).toBe('true');\n await user.keyboard('{Home}');\n expect(document.activeElement).toBe(screen.getByRole('tab', { name: 'Overview' }));\n await user.keyboard('{ArrowRight}');\n expect(document.activeElement).toBe(screen.getByRole('tab', { name: 'Activity' }));\n });\n\n it('has no axe violations', async () => {\n const { container } = render(<DemoTabs />);\n await assertNoAxeViolations(container);\n });\n});\n"],"mappings":"AAUM,SACE,KADF;AAVN,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,QAAQ,cAAc;AAC/B,OAAO,eAAe;AACtB,SAAS,6BAA6B;AAEtC,SAAS,KAAK,SAAS,UAAU,YAAY;AAE7C,SAAS,WAAW;AAClB,SACE,qBAAC,QAAK,cAAa,OACjB;AAAA,yBAAC,WACC;AAAA,0BAAC,OAAI,OAAM,OAAM,sBAAQ;AAAA,MACzB,oBAAC,OAAI,OAAM,OAAM,sBAAQ;AAAA,MACzB,oBAAC,OAAI,OAAM,SAAQ,UAAQ,MAAC,sBAE5B;AAAA,OACF;AAAA,IACA,oBAAC,YAAS,OAAM,OAAM,0BAAY;AAAA,IAClC,oBAAC,YAAS,OAAM,OAAM,2BAAa;AAAA,IACnC,oBAAC,YAAS,OAAM,SAAQ,qBAAO;AAAA,KACjC;AAEJ;AAEA,SAAS,QAAQ,MAAM;AACrB,KAAG,+BAA+B,MAAM;AACtC,WAAO,oBAAC,YAAS,CAAE;AACnB,WAAO,OAAO,UAAU,SAAS,EAAE,aAAa,kBAAkB,CAAC,EAAE,KAAK,YAAY;AAAA,EACxF,CAAC;AAED,KAAG,yDAAyD,YAAY;AACtE,UAAM,OAAO,UAAU,MAAM;AAC7B,WAAO,oBAAC,YAAS,CAAE;AACnB,WAAO,UAAU,OAAO,EAAE,MAAM,WAAW,CAAC,EAAE,MAAM;AACpD,UAAM,KAAK,SAAS,OAAO;AAC3B,WAAO,SAAS,aAAa,EAAE,KAAK,OAAO,UAAU,OAAO,EAAE,MAAM,WAAW,CAAC,CAAC;AACjF,WAAO,OAAO,UAAU,OAAO,EAAE,MAAM,WAAW,CAAC,EAAE,aAAa,eAAe,CAAC,EAAE,KAAK,MAAM;AAC/F,UAAM,KAAK,SAAS,QAAQ;AAC5B,WAAO,SAAS,aAAa,EAAE,KAAK,OAAO,UAAU,OAAO,EAAE,MAAM,WAAW,CAAC,CAAC;AACjF,UAAM,KAAK,SAAS,cAAc;AAClC,WAAO,SAAS,aAAa,EAAE,KAAK,OAAO,UAAU,OAAO,EAAE,MAAM,WAAW,CAAC,CAAC;AAAA,EACnF,CAAC;AAED,KAAG,yBAAyB,YAAY;AACtC,UAAM,EAAE,UAAU,IAAI,OAAO,oBAAC,YAAS,CAAE;AACzC,UAAM,sBAAsB,SAAS;AAAA,EACvC,CAAC;AACH,CAAC;","names":[]}
@@ -1,58 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { describe, expect, it } 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
- import { Tooltip } from "./Tooltip";
8
- describe("Tooltip", () => {
9
- it("does not add an extra tab stop around Button", async () => {
10
- const user = userEvent.setup();
11
- render(
12
- /* @__PURE__ */ jsxs(Fragment, { children: [
13
- /* @__PURE__ */ jsx("button", { type: "button", children: "Before" }),
14
- /* @__PURE__ */ jsx(Tooltip, { content: "Short glossary hint.", delayMs: 0, children: /* @__PURE__ */ jsx(Button, { children: "Hover me" }) }),
15
- /* @__PURE__ */ jsx("button", { type: "button", children: "After" })
16
- ] })
17
- );
18
- const trigger = screen.getByRole("button", { name: "Hover me" });
19
- expect(trigger.parentElement?.getAttribute("tabindex")).not.toBe("0");
20
- await user.tab();
21
- expect(document.activeElement).toBe(screen.getByRole("button", { name: "Before" }));
22
- await user.tab();
23
- expect(document.activeElement).toBe(trigger);
24
- await user.tab();
25
- expect(document.activeElement).toBe(screen.getByRole("button", { name: "After" }));
26
- });
27
- it("has no axe violations when wrapping a named Button", async () => {
28
- const { container } = render(
29
- /* @__PURE__ */ jsx(Tooltip, { content: "Short glossary hint.", delayMs: 0, children: /* @__PURE__ */ jsx(Button, { children: "Hover me" }) })
30
- );
31
- await assertNoAxeViolations(container);
32
- });
33
- it("sets aria-describedby on the Button while open and closes on Escape", async () => {
34
- const user = userEvent.setup();
35
- render(
36
- /* @__PURE__ */ jsx(Tooltip, { content: "Short glossary hint.", delayMs: 0, children: /* @__PURE__ */ jsx(Button, { children: "Hover me" }) })
37
- );
38
- const trigger = screen.getByRole("button", { name: "Hover me" });
39
- await user.hover(trigger);
40
- const tip = await screen.findByRole("tooltip");
41
- expect(trigger.getAttribute("aria-describedby")).toBe(tip.id);
42
- await user.keyboard("{Escape}");
43
- expect(screen.queryByRole("tooltip")).toBeNull();
44
- });
45
- it("wraps plain text so it is keyboard reachable", async () => {
46
- const user = userEvent.setup();
47
- render(
48
- /* @__PURE__ */ jsx(Tooltip, { content: "Hint", delayMs: 0, children: "glossary" })
49
- );
50
- const trigger = screen.getByText("glossary");
51
- expect(trigger.tagName).toBe("SPAN");
52
- expect(trigger.getAttribute("tabindex")).toBe("0");
53
- trigger.focus();
54
- await user.hover(trigger);
55
- expect(await screen.findByRole("tooltip")).toBeTruthy();
56
- });
57
- });
58
- //# sourceMappingURL=Tooltip.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Tooltip.test.tsx"],"sourcesContent":["import { describe, expect, it } 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';\nimport { Tooltip } from './Tooltip';\n\ndescribe('Tooltip', () => {\n it('does not add an extra tab stop around Button', async () => {\n const user = userEvent.setup();\n render(\n <>\n <button type=\"button\">Before</button>\n <Tooltip content=\"Short glossary hint.\" delayMs={0}>\n <Button>Hover me</Button>\n </Tooltip>\n <button type=\"button\">After</button>\n </>,\n );\n\n const trigger = screen.getByRole('button', { name: 'Hover me' });\n expect(trigger.parentElement?.getAttribute('tabindex')).not.toBe('0');\n\n await user.tab();\n expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Before' }));\n await user.tab();\n expect(document.activeElement).toBe(trigger);\n await user.tab();\n expect(document.activeElement).toBe(screen.getByRole('button', { name: 'After' }));\n });\n\n it('has no axe violations when wrapping a named Button', async () => {\n const { container } = render(\n <Tooltip content=\"Short glossary hint.\" delayMs={0}>\n <Button>Hover me</Button>\n </Tooltip>,\n );\n await assertNoAxeViolations(container);\n });\n\n it('sets aria-describedby on the Button while open and closes on Escape', async () => {\n const user = userEvent.setup();\n render(\n <Tooltip content=\"Short glossary hint.\" delayMs={0}>\n <Button>Hover me</Button>\n </Tooltip>,\n );\n\n const trigger = screen.getByRole('button', { name: 'Hover me' });\n await user.hover(trigger);\n const tip = await screen.findByRole('tooltip');\n expect(trigger.getAttribute('aria-describedby')).toBe(tip.id);\n\n await user.keyboard('{Escape}');\n expect(screen.queryByRole('tooltip')).toBeNull();\n });\n\n it('wraps plain text so it is keyboard reachable', async () => {\n const user = userEvent.setup();\n render(\n <Tooltip content=\"Hint\" delayMs={0}>\n glossary\n </Tooltip>,\n );\n\n const trigger = screen.getByText('glossary');\n expect(trigger.tagName).toBe('SPAN');\n expect(trigger.getAttribute('tabindex')).toBe('0');\n\n trigger.focus();\n await user.hover(trigger);\n expect(await screen.findByRole('tooltip')).toBeTruthy();\n });\n});\n"],"mappings":"AAYM,mBACE,KADF;AAZN,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,QAAQ,cAAc;AAC/B,OAAO,eAAe;AACtB,SAAS,6BAA6B;AAEtC,SAAS,cAAc;AACvB,SAAS,eAAe;AAExB,SAAS,WAAW,MAAM;AACxB,KAAG,gDAAgD,YAAY;AAC7D,UAAM,OAAO,UAAU,MAAM;AAC7B;AAAA,MACE,iCACE;AAAA,4BAAC,YAAO,MAAK,UAAS,oBAAM;AAAA,QAC5B,oBAAC,WAAQ,SAAQ,wBAAuB,SAAS,GAC/C,8BAAC,UAAO,sBAAQ,GAClB;AAAA,QACA,oBAAC,YAAO,MAAK,U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