@pablo-v/popover 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pablo Viniegra
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # @pablo-v/popover
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Non-modal panel anchored to a trigger
4
+
5
+ ```bash
6
+ pnpm add @pablo-v/popover @pablo-v/tokens
7
+ ```
8
+
9
+ ```tsx
10
+ import '@pablo-v/tokens/styles.css';
11
+ import '@pablo-v/popover/style.css';
12
+ import { Popover } from '@pablo-v/popover';
13
+ ```
@@ -0,0 +1,21 @@
1
+ import { type Align, type Side } from '@pablo-v/core';
2
+ import { type ComponentPropsWithRef, type ReactElement } from 'react';
3
+ export interface PopoverProps extends Omit<ComponentPropsWithRef<'div'>, 'title'> {
4
+ /** Element that toggles the popover on click. */
5
+ trigger: ReactElement;
6
+ open?: boolean;
7
+ defaultOpen?: boolean;
8
+ onOpenChange?: (open: boolean) => void;
9
+ /** @default 'bottom' */
10
+ side?: Side;
11
+ /** @default 'center' */
12
+ align?: Align;
13
+ /** Accessible name of the panel, when it has no visible heading. */
14
+ label?: string;
15
+ }
16
+ /**
17
+ * Non-modal panel anchored to its trigger. It renders right after the trigger
18
+ * in the DOM, so Tab flows from the trigger into the panel without a focus trap.
19
+ */
20
+ export declare function Popover({ trigger, open: openProp, defaultOpen, onOpenChange, side, align, label, className, children, ...rest }: PopoverProps): import("react").JSX.Element;
21
+ //# sourceMappingURL=Popover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../src/Popover.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,KAAK,EAGV,KAAK,IAAI,EAKV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,YAAY,EAAiB,MAAM,OAAO,CAAC;AAErF,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAC/E,iDAAiD;IACjD,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,wBAAwB;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,wBAAwB;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,IAAI,EAAE,QAAQ,EACd,WAAmB,EACnB,YAAY,EACZ,IAAe,EACf,KAAgB,EAChB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,YAAY,+BA4Cd"}
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cloneTrigger, cx, useControllableState, useDismiss, useFloating, useIsomorphicLayoutEffect, } from '@pablo-v/core';
4
+ import { useId, useRef } from 'react';
5
+ /**
6
+ * Non-modal panel anchored to its trigger. It renders right after the trigger
7
+ * in the DOM, so Tab flows from the trigger into the panel without a focus trap.
8
+ */
9
+ export function Popover({ trigger, open: openProp, defaultOpen = false, onOpenChange, side = 'bottom', align = 'center', label, className, children, ...rest }) {
10
+ const [open, setOpen] = useControllableState({
11
+ value: openProp,
12
+ defaultValue: defaultOpen,
13
+ onChange: onOpenChange,
14
+ });
15
+ const anchorRef = useRef(null);
16
+ const floatingRef = useRef(null);
17
+ const id = useId();
18
+ useFloating({ open, anchorRef, floatingRef, side, align });
19
+ useDismiss(open, () => {
20
+ setOpen(false);
21
+ if (floatingRef.current?.contains(document.activeElement))
22
+ anchorRef.current?.focus();
23
+ }, [anchorRef, floatingRef]);
24
+ useIsomorphicLayoutEffect(() => {
25
+ if (open)
26
+ floatingRef.current?.focus({ preventScroll: true });
27
+ }, [open]);
28
+ return (_jsxs(_Fragment, { children: [cloneTrigger(trigger, {
29
+ ref: anchorRef,
30
+ onClick: () => setOpen(!open),
31
+ 'aria-expanded': open,
32
+ 'aria-controls': open ? id : undefined,
33
+ 'aria-haspopup': 'dialog',
34
+ }), open && (_jsx("div", { ref: floatingRef, id: id, role: "dialog", "aria-label": label, tabIndex: -1, popover: "manual", className: cx('pxl-popover', className), ...rest, children: children }))] }));
35
+ }
36
+ //# sourceMappingURL=Popover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popover.js","sourceRoot":"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EAAE,CAAC,CAAC;IAChE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CACL,8BACG,YAAY,CAAC,OAAO,EAAE;gBACrB,GAAG,EAAE,SAAS;gBACd,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;gBAC7B,eAAe,EAAE,IAAI;gBACrB,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;gBACtC,eAAe,EAAE,QAAQ;aAC1B,CAAC,EACD,IAAI,IAAI,CACP,cACE,GAAG,EAAE,WAAW,EAChB,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,QAAQ,gBACD,KAAK,EACjB,QAAQ,EAAE,CAAC,CAAC,EACZ,OAAO,EAAC,QAAQ,EAChB,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,KACnC,IAAI,YAEP,QAAQ,GACL,CACP,IACA,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Popover, type PopoverProps } from './Popover.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Popover } from './Popover.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,45 @@
1
+ .pxl-popover {
2
+ position: fixed;
3
+ inset: auto;
4
+ min-width: 200px;
5
+ max-width: min(360px, calc(100vw - var(--pxl-space-4)));
6
+ margin: 0;
7
+ padding: var(--pxl-space-4);
8
+ overflow: visible;
9
+ border: 1px solid var(--pxl-border);
10
+ border-radius: var(--pxl-radius-lg);
11
+ background: var(--pxl-bg);
12
+ color: var(--pxl-fg);
13
+ box-shadow: var(--pxl-shadow-lg);
14
+ font-family: var(--pxl-font-sans);
15
+ font-size: var(--pxl-text-sm);
16
+ line-height: 1.5;
17
+ animation: pxl-float-in var(--pxl-dur-fast) var(--pxl-ease-out);
18
+ }
19
+
20
+ .pxl-popover:focus {
21
+ outline: none;
22
+ }
23
+
24
+ .pxl-popover:focus-visible {
25
+ outline: 2px solid var(--pxl-accent);
26
+ outline-offset: 2px;
27
+ }
28
+
29
+ .pxl-popover[data-side="top"] {
30
+ --_from-y: 4px;
31
+ }
32
+
33
+ .pxl-popover[data-side="bottom"] {
34
+ --_from-y: -4px;
35
+ }
36
+
37
+ .pxl-popover[data-side="left"] {
38
+ --_from-x: 4px;
39
+ --_from-y: 0;
40
+ }
41
+
42
+ .pxl-popover[data-side="right"] {
43
+ --_from-x: -4px;
44
+ --_from-y: 0;
45
+ }
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@pablo-v/popover",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Non-modal panel anchored to a trigger",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/PabloViniegra/pixel-ui.git",
9
+ "directory": "packages/popover"
10
+ },
11
+ "type": "module",
12
+ "sideEffects": [
13
+ "*.css"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "source": "./src/index.ts",
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./style.css": {
22
+ "source": "./src/popover.css",
23
+ "default": "./dist/popover.css"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "dependencies": {
31
+ "@pablo-v/core": "^0.2.0"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^19.0.0",
35
+ "@pablo-v/tokens": "^0.2.0"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "devDependencies": {
41
+ "@pablo-v/button": "^1.0.0"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -b && node ../../scripts/copy-assets.mjs",
45
+ "clean": "rm -rf dist *.tsbuildinfo"
46
+ }
6
47
  }