@edux-design/popovers 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edux-design/popovers",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "scripts": {
17
17
  "lint": "eslint . --max-warnings 0",
18
- "build": "tsup src/index.js --format esm,cjs --dts",
19
- "dev": "tsup src/index.js --watch --format esm,cjs --dts",
18
+ "build": "tsup src/index.js --format esm,cjs --external react,react-dom,@radix-ui/react-popover",
19
+ "dev": "tsup src/index.js --format esm,cjs --external react,react-dom,@radix-ui/react-popover",
20
20
  "generate:component": "turbo gen react-component",
21
21
  "check-types": "tsc --noEmit"
22
22
  },
@@ -48,7 +48,7 @@ Built with [@radix-ui/react-popover](https://www.radix-ui.com/primitives/docs/co
48
48
  export default meta;
49
49
  /**
50
50
  * ───────────────────────────────────────────────
51
- * 📍 Basic Popover
51
+ * Basic Popover
52
52
  * ───────────────────────────────────────────────
53
53
  */
54
54
  export const Basic = {
@@ -86,7 +86,7 @@ export const Basic = {
86
86
 
87
87
  /**
88
88
  * ───────────────────────────────────────────────
89
- * 🎨 Custom Content
89
+ * Custom Content
90
90
  * ───────────────────────────────────────────────
91
91
  */
92
92
  export const CustomContent = {
@@ -131,7 +131,7 @@ export const CustomContent = {
131
131
 
132
132
  /**
133
133
  * ───────────────────────────────────────────────
134
- * ⚙️ Controlled Popover
134
+ * Controlled Popover
135
135
  * ───────────────────────────────────────────────
136
136
  */
137
137
  export const Controlled = {
@@ -169,7 +169,7 @@ export const Controlled = {
169
169
 
170
170
  /**
171
171
  * ───────────────────────────────────────────────
172
- * 📐 All Sides Example
172
+ * All Sides Example
173
173
  * ───────────────────────────────────────────────
174
174
  */
175
175
  export const Sides = {
@@ -200,7 +200,7 @@ export const Sides = {
200
200
 
201
201
  /**
202
202
  * ───────────────────────────────────────────────
203
- * 🧭 No Auto Focus Example
203
+ * No Auto Focus Example
204
204
  * ───────────────────────────────────────────────
205
205
  */
206
206
  export const NoAutoFocus = {
@@ -118,7 +118,7 @@ export const PopoverContent = forwardRef(
118
118
  // Base styling; consuming apps can override via className or wrapping
119
119
  const base =
120
120
  "bg-fg-base text-fg-invert text-sm font-normal rounded-xl shadow-lg px-12 py-8 animate-fade-in";
121
- // A transform to “nudge” content initially (you can enhance animation later)
121
+ // A transform to “nudge” content initially
122
122
  const positioning = {
123
123
  top: "translate-y-[-4px]",
124
124
  right: "translate-x-[4px]",
@@ -0,0 +1,62 @@
1
+ import React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import {
4
+ Popover,
5
+ PopoverTrigger,
6
+ PopoverContent,
7
+ PopoverClose,
8
+ } from "./Popover";
9
+
10
+ vi.mock("@radix-ui/react-popover", () => {
11
+ const Passthrough = ({ children, ...props }) => (
12
+ <div {...props}>{children}</div>
13
+ );
14
+ const Buttonish = ({ children, ...props }) => (
15
+ <button type="button" {...props}>
16
+ {children}
17
+ </button>
18
+ );
19
+ const Content = React.forwardRef(
20
+ ({ sideOffset, alignOffset, avoidCollisions, forceMount, ...props }, ref) => (
21
+ <div ref={ref} data-testid="radix-content" {...props} />
22
+ )
23
+ );
24
+ Content.displayName = "RadixContent";
25
+ const Arrow = (props) => <div data-testid="popover-arrow" {...props} />;
26
+
27
+ return {
28
+ Provider: Passthrough,
29
+ Root: Passthrough,
30
+ Trigger: Buttonish,
31
+ Anchor: Passthrough,
32
+ Portal: Passthrough,
33
+ Content,
34
+ Close: Buttonish,
35
+ Arrow,
36
+ };
37
+ });
38
+
39
+ describe("PopoverContent", () => {
40
+ it("merges Tailwind classes and optionally renders arrow", () => {
41
+ render(
42
+ <PopoverContent className="custom" showArrow side="top" data-testid="content">
43
+ Body
44
+ </PopoverContent>
45
+ );
46
+ const content = screen.getByTestId("content");
47
+ expect(content).toHaveClass("custom");
48
+ expect(screen.getByTestId("popover-arrow")).toBeInTheDocument();
49
+ });
50
+
51
+ it("plays nicely with Popover + Trigger exports", () => {
52
+ render(
53
+ <Popover>
54
+ <PopoverTrigger>Open</PopoverTrigger>
55
+ <PopoverContent>Panel</PopoverContent>
56
+ <PopoverClose>Close</PopoverClose>
57
+ </Popover>
58
+ );
59
+ expect(screen.getByText("Open")).toBeInTheDocument();
60
+ expect(screen.getAllByText(/close|panel/i).length).toBeGreaterThan(0);
61
+ });
62
+ });