@poly-x/react 0.1.0-alpha.11 → 0.1.0-alpha.12

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/dist/index.cjs CHANGED
@@ -1615,6 +1615,15 @@ function UserButtonRoot(props) {
1615
1615
  setOpen(false);
1616
1616
  if (returnFocus) triggerRef.current?.focus();
1617
1617
  }, []);
1618
+ const onOpenChange = props.onOpenChange;
1619
+ const mounted = (0, react.useRef)(false);
1620
+ (0, react.useEffect)(() => {
1621
+ if (!mounted.current) {
1622
+ mounted.current = true;
1623
+ return;
1624
+ }
1625
+ onOpenChange?.(open);
1626
+ }, [open, onOpenChange]);
1618
1627
  (0, react.useEffect)(() => {
1619
1628
  if (!open) return;
1620
1629
  const onKeyDown = (event) => {
@@ -1709,7 +1718,7 @@ function UserButtonRoot(props) {
1709
1718
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1710
1719
  ref: triggerRef,
1711
1720
  type: "button",
1712
- className: "polyx-userbutton__trigger",
1721
+ className: ["polyx-userbutton__trigger", props.triggerClassName].filter(Boolean).join(" "),
1713
1722
  "aria-haspopup": "menu",
1714
1723
  "aria-expanded": open,
1715
1724
  "aria-controls": open ? menuId : void 0,
package/dist/index.d.cts CHANGED
@@ -470,6 +470,13 @@ interface UserButtonProps {
470
470
  fallback?: ReactNode;
471
471
  /** Appended to the root element's class list, for escape-hatch styling. */
472
472
  className?: string;
473
+ /**
474
+ * Appended to the trigger button's class list. The SDK owns that button, so without this a
475
+ * consumer could style everything except the one element they place in their own layout.
476
+ */
477
+ triggerClassName?: string;
478
+ /** Notified when the menu opens or closes — hosts often coordinate their own chrome around it. */
479
+ onOpenChange?: (open: boolean) => void;
473
480
  labels?: Partial<UserButtonLabels>;
474
481
  /**
475
482
  * `<UserButton.MenuItems>` with `<UserButton.Action>` / `<UserButton.Link>` / `<UserButton.Custom>`
package/dist/index.d.mts CHANGED
@@ -470,6 +470,13 @@ interface UserButtonProps {
470
470
  fallback?: ReactNode;
471
471
  /** Appended to the root element's class list, for escape-hatch styling. */
472
472
  className?: string;
473
+ /**
474
+ * Appended to the trigger button's class list. The SDK owns that button, so without this a
475
+ * consumer could style everything except the one element they place in their own layout.
476
+ */
477
+ triggerClassName?: string;
478
+ /** Notified when the menu opens or closes — hosts often coordinate their own chrome around it. */
479
+ onOpenChange?: (open: boolean) => void;
473
480
  labels?: Partial<UserButtonLabels>;
474
481
  /**
475
482
  * `<UserButton.MenuItems>` with `<UserButton.Action>` / `<UserButton.Link>` / `<UserButton.Custom>`
package/dist/index.mjs CHANGED
@@ -1614,6 +1614,15 @@ function UserButtonRoot(props) {
1614
1614
  setOpen(false);
1615
1615
  if (returnFocus) triggerRef.current?.focus();
1616
1616
  }, []);
1617
+ const onOpenChange = props.onOpenChange;
1618
+ const mounted = useRef(false);
1619
+ useEffect(() => {
1620
+ if (!mounted.current) {
1621
+ mounted.current = true;
1622
+ return;
1623
+ }
1624
+ onOpenChange?.(open);
1625
+ }, [open, onOpenChange]);
1617
1626
  useEffect(() => {
1618
1627
  if (!open) return;
1619
1628
  const onKeyDown = (event) => {
@@ -1708,7 +1717,7 @@ function UserButtonRoot(props) {
1708
1717
  children: [/* @__PURE__ */ jsx("button", {
1709
1718
  ref: triggerRef,
1710
1719
  type: "button",
1711
- className: "polyx-userbutton__trigger",
1720
+ className: ["polyx-userbutton__trigger", props.triggerClassName].filter(Boolean).join(" "),
1712
1721
  "aria-haspopup": "menu",
1713
1722
  "aria-expanded": open,
1714
1723
  "aria-controls": open ? menuId : void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poly-x/react",
3
- "version": "0.1.0-alpha.11",
3
+ "version": "0.1.0-alpha.12",
4
4
  "description": "PolyX SDK for React SPAs - provider, hooks, drop-in auth UI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "module": "./dist/index.mjs",
28
28
  "types": "./dist/index.d.cts",
29
29
  "dependencies": {
30
- "@poly-x/core": "0.1.0-alpha.11"
30
+ "@poly-x/core": "0.1.0-alpha.12"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=18",