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

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/dist/styles.css CHANGED
@@ -10,8 +10,33 @@
10
10
  * (`:root`, a wrapper div, …) — that is the supported theming surface. Dark mode
11
11
  * follows the OS by default and defers to an explicit `.dark` / `[data-theme]`
12
12
  * on a host ancestor when one is present.
13
+ *
14
+ * ---------------------------------------------------------------------------
15
+ * Cascade: everything here lives in the `polyx` layer, and that is load-bearing.
16
+ *
17
+ * Unlayered CSS beats layered CSS outright — not by specificity, but by rank; no
18
+ * import order or selector weight changes it. Shipping these rules unlayered
19
+ * therefore beat every Tailwind utility a host wrote (Tailwind emits utilities
20
+ * into `@layer utilities`), so `className`/`triggerClassName` silently did
21
+ * nothing and hosts were pushed toward `!important`. Layering hands that control
22
+ * back: a host's utilities and unlayered CSS both outrank us now.
23
+ *
24
+ * The statement below fixes where `polyx` sits. It must land AFTER `base` —
25
+ * Tailwind's preflight puts `*, ::before, ::after { border: 0 solid }` there, and
26
+ * that would erase our own borders if we ranked lower — and BEFORE `utilities`,
27
+ * so host utilities still win. Naming Tailwind's layers costs nothing when the
28
+ * host doesn't use Tailwind: the names simply resolve to empty layers.
29
+ *
30
+ * Layer order is set by first declaration, so this only holds if our stylesheet
31
+ * is imported BEFORE the host's Tailwind entry. Import it later and `polyx` is
32
+ * appended last, which puts us back to outranking utilities — no worse than the
33
+ * unlayered behaviour, but not the fix either. Import us first.
13
34
  */
14
35
 
36
+ @layer theme, base, polyx, components, utilities;
37
+
38
+ @layer polyx {
39
+
15
40
  .polyx-signin {
16
41
  /* Colors */
17
42
  --polyx-brand: #4f46e5;
@@ -683,3 +708,8 @@
683
708
  height: 1rem;
684
709
  color: var(--polyx-muted-fg);
685
710
  }
711
+
712
+ /* Closes `@layer polyx` — opened at the top of the file. The rules above are left
713
+ unindented deliberately: wrapping the sheet in a layer is a cascade change, not a
714
+ reformat, and re-indenting 600 lines would bury it in the diff. */
715
+ }
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.13",
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.13"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=18",