@stackshift-ui/popover 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/README.md +24 -0
- package/dist/chunk-3EYN2AKU.mjs +1 -0
- package/dist/chunk-ZXIJRDRR.mjs +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/dist/popover.d.ts +16 -0
- package/dist/popover.js +2 -0
- package/dist/popover.mjs +2 -0
- package/dist/setupTests.d.ts +2 -0
- package/dist/setupTests.js +51 -0
- package/dist/setupTests.mjs +51 -0
- package/package.json +65 -0
- package/src/index.ts +4 -0
- package/src/popover.test.tsx +33 -0
- package/src/popover.tsx +59 -0
- package/src/setupTests.ts +4 -0
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stackshift-ui/popover",
|
|
3
|
+
"description": "Displays rich content in a portal, triggered by a button.",
|
|
4
|
+
"version": "1.0.0-beta.1",
|
|
5
|
+
"private": false,
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/**",
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"author": "WebriQ <info@webriq.com>",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
17
|
+
"@testing-library/react": "^16.0.1",
|
|
18
|
+
"@testing-library/user-event": "^14.6.1",
|
|
19
|
+
"@types/node": "^22.7.0",
|
|
20
|
+
"@types/react": "^18.3.9",
|
|
21
|
+
"@types/react-dom": "^18.3.0",
|
|
22
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
23
|
+
"@vitest/coverage-v8": "^2.1.1",
|
|
24
|
+
"esbuild-plugin-rdi": "^0.0.0",
|
|
25
|
+
"esbuild-plugin-react18": "^0.2.5",
|
|
26
|
+
"esbuild-plugin-react18-css": "^0.0.4",
|
|
27
|
+
"jsdom": "^25.0.1",
|
|
28
|
+
"react": "^18.3.1",
|
|
29
|
+
"react-dom": "^18.3.1",
|
|
30
|
+
"tsup": "^8.3.0",
|
|
31
|
+
"typescript": "^5.6.2",
|
|
32
|
+
"vite-tsconfig-paths": "^5.0.1",
|
|
33
|
+
"vitest": "^2.1.1",
|
|
34
|
+
"@stackshift-ui/eslint-config": "6.0.10",
|
|
35
|
+
"@stackshift-ui/typescript-config": "6.0.10"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@radix-ui/react-popover": "^1.1.14",
|
|
39
|
+
"add": "^2.0.6",
|
|
40
|
+
"classnames": "^2.5.1",
|
|
41
|
+
"pnpm": "^10.12.4",
|
|
42
|
+
"@stackshift-ui/system": "6.1.0-beta.0",
|
|
43
|
+
"@stackshift-ui/scripts": "6.1.0-beta.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@stackshift-ui/system": ">=6.1.0-beta.0",
|
|
47
|
+
"@types/react": "16.8 - 19",
|
|
48
|
+
"next": "10 - 14",
|
|
49
|
+
"react": "16.8 - 19",
|
|
50
|
+
"react-dom": "16.8 - 19"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"next": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsup && tsc -p tsconfig-build.json",
|
|
59
|
+
"clean": "rm -rf dist",
|
|
60
|
+
"dev": "tsup --watch && tsc -p tsconfig-build.json -w",
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
62
|
+
"lint": "eslint src/",
|
|
63
|
+
"test": "vitest run --coverage"
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { afterEach, describe, test } from "vitest";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover";
|
|
5
|
+
|
|
6
|
+
describe.concurrent("popover", () => {
|
|
7
|
+
afterEach(cleanup);
|
|
8
|
+
|
|
9
|
+
test("Dummy test - test if renders without errors", async ({ expect }) => {
|
|
10
|
+
const clx = "my-class";
|
|
11
|
+
const user = userEvent.setup();
|
|
12
|
+
|
|
13
|
+
const { unmount } = render(
|
|
14
|
+
<Popover data-testid="popover">
|
|
15
|
+
<PopoverTrigger asChild data-testid="popover-trigger">
|
|
16
|
+
<button>Open Popover</button>
|
|
17
|
+
</PopoverTrigger>
|
|
18
|
+
<PopoverContent data-testid="popover-content" className={clx}>
|
|
19
|
+
<p>This is a popover</p>
|
|
20
|
+
</PopoverContent>
|
|
21
|
+
</Popover>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const trigger = screen.getByTestId("popover-trigger");
|
|
25
|
+
expect(trigger).toBeInTheDocument();
|
|
26
|
+
|
|
27
|
+
user.click(trigger);
|
|
28
|
+
|
|
29
|
+
const popover = await screen.findByTestId("popover-content");
|
|
30
|
+
expect(popover).toBeInTheDocument();
|
|
31
|
+
unmount();
|
|
32
|
+
});
|
|
33
|
+
});
|
package/src/popover.tsx
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import { cn, DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
|
|
7
|
+
|
|
8
|
+
const displayName = "Popover";
|
|
9
|
+
const displayNameTrigger = "PopoverTrigger";
|
|
10
|
+
const displayNameContent = "PopoverContent";
|
|
11
|
+
const displayNameAnchor = "PopoverAnchor";
|
|
12
|
+
|
|
13
|
+
function Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
|
14
|
+
const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
15
|
+
|
|
16
|
+
return <Component as={PopoverPrimitive.Root} data-slot="popover" {...props} />;
|
|
17
|
+
}
|
|
18
|
+
Popover.displayName = displayName;
|
|
19
|
+
|
|
20
|
+
function PopoverTrigger({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
|
21
|
+
const { [displayNameTrigger]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
22
|
+
|
|
23
|
+
return <Component as={PopoverPrimitive.Trigger} data-slot="popover-trigger" {...props} />;
|
|
24
|
+
}
|
|
25
|
+
PopoverTrigger.displayName = displayNameTrigger;
|
|
26
|
+
|
|
27
|
+
function PopoverContent({
|
|
28
|
+
className,
|
|
29
|
+
align = "center",
|
|
30
|
+
sideOffset = 4,
|
|
31
|
+
...props
|
|
32
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
|
33
|
+
const { [displayNameContent]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<PopoverPrimitive.Portal>
|
|
37
|
+
<Component
|
|
38
|
+
as={PopoverPrimitive.Content}
|
|
39
|
+
data-slot="popover-content"
|
|
40
|
+
align={align}
|
|
41
|
+
sideOffset={sideOffset}
|
|
42
|
+
className={cn(
|
|
43
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
</PopoverPrimitive.Portal>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
PopoverContent.displayName = displayNameContent;
|
|
52
|
+
|
|
53
|
+
function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
|
54
|
+
const { [displayNameAnchor]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
55
|
+
|
|
56
|
+
return <Component as={PopoverPrimitive.Anchor} data-slot="popover-anchor" {...props} />;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };
|