@becket-ui/react 0.1.3 → 0.3.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 (68) hide show
  1. package/dist/components/Badge.d.ts +1 -1
  2. package/dist/components/Badge.js +1 -1
  3. package/dist/components/Box.d.ts +20 -0
  4. package/dist/components/Box.d.ts.map +1 -0
  5. package/dist/components/Box.js +21 -0
  6. package/dist/components/Box.js.map +1 -0
  7. package/dist/components/Container.d.ts +21 -0
  8. package/dist/components/Container.d.ts.map +1 -0
  9. package/dist/components/Container.js +21 -0
  10. package/dist/components/Container.js.map +1 -0
  11. package/dist/components/Dialog.js +1 -1
  12. package/dist/components/Drawer.js +1 -1
  13. package/dist/components/Flex.d.ts +2 -2
  14. package/dist/components/Flex.js +2 -2
  15. package/dist/components/Glyphs.d.ts +16 -0
  16. package/dist/components/Glyphs.d.ts.map +1 -0
  17. package/dist/components/Glyphs.js +83 -0
  18. package/dist/components/Glyphs.js.map +1 -0
  19. package/dist/components/Hide.d.ts +1 -1
  20. package/dist/components/Hide.js +1 -1
  21. package/dist/components/Icon.d.ts +20 -0
  22. package/dist/components/Icon.d.ts.map +1 -0
  23. package/dist/components/Icon.js +23 -0
  24. package/dist/components/Icon.js.map +1 -0
  25. package/dist/components/Prose.d.ts +20 -0
  26. package/dist/components/Prose.d.ts.map +1 -0
  27. package/dist/components/Prose.js +14 -0
  28. package/dist/components/Prose.js.map +1 -0
  29. package/dist/components/Radio.js +1 -1
  30. package/dist/components/Select.d.ts +1 -1
  31. package/dist/components/Select.js +1 -1
  32. package/dist/components/SimpleGrid.d.ts +1 -1
  33. package/dist/components/SimpleGrid.js +1 -1
  34. package/dist/components/Stack.d.ts +2 -2
  35. package/dist/components/Stack.js +2 -2
  36. package/dist/components/Tag.d.ts +1 -1
  37. package/dist/components/Tag.js +1 -1
  38. package/dist/components/TextField.d.ts +1 -1
  39. package/dist/components/TextField.js +1 -1
  40. package/dist/components/Textarea.d.ts +1 -1
  41. package/dist/components/Textarea.js +1 -1
  42. package/dist/helpers/responsive.d.ts +1 -1
  43. package/dist/helpers/responsive.js.map +1 -1
  44. package/dist/helpers/storybookControls.d.ts +1 -1
  45. package/dist/helpers/storybookControls.js +1 -1
  46. package/dist/helpers/storybookControls.js.map +1 -1
  47. package/dist/index.d.ts +44 -34
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +63 -27
  50. package/dist/index.js.map +1 -1
  51. package/guides/building-with-becket.md +39 -33
  52. package/package.json +4 -4
  53. package/dist/components/Button.test.js +0 -62
  54. package/dist/components/Button.test.js.map +0 -1
  55. package/dist/components/Dialog.test.js +0 -89
  56. package/dist/components/Dialog.test.js.map +0 -1
  57. package/dist/components/Drawer.test.js +0 -50
  58. package/dist/components/Drawer.test.js.map +0 -1
  59. package/dist/components/Field.test.js +0 -33
  60. package/dist/components/Field.test.js.map +0 -1
  61. package/dist/components/Menu.test.js +0 -69
  62. package/dist/components/Menu.test.js.map +0 -1
  63. package/dist/components/Switch.test.js +0 -28
  64. package/dist/components/Switch.test.js.map +0 -1
  65. package/dist/components/Tabs.test.js +0 -41
  66. package/dist/components/Tabs.test.js.map +0 -1
  67. package/dist/components/Tooltip.test.js +0 -58
  68. package/dist/components/Tooltip.test.js.map +0 -1
@@ -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,W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GAAG;AACtB,aAAS,oBAAC,iBAAc,MAAK,eAAc,cAAc,SAAS,CAAE;AACpE,cAAU,MAAM,OAAO,UAAU,eAAe,EAAE,MAAM,UAAU,CAAC,CAAC;AACpE,WAAO,OAAO,EAAE,IAAI,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,UAA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C,YAAY;AAChD,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,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,iCAC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