{"version":3,"names":["dynamic","omit","composeRefs","userRef","mergeRootProps","useButton","useCollapsible","CollapsibleTrigger","props","c","disabled","own","undefined","Boolean","nativeButton","buttonProps","ref","buttonRef","focusableWhenDisabled","native","userProps","merged","trigger","Tag","as"],"sources":["collapsible-trigger.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { omit } from \"solid-js\";\nimport { composeRefs, userRef } from \"../../internals/compose-refs\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport type { NativeButtonProps } from \"../../internals/types\";\nimport { useButton } from \"../../internals/use-button/use-button\";\nimport { useCollapsible } from \"../create-collapsible.tsx\";\n\n/**\n * Props for {@link CollapsibleTrigger}.\n *\n * Stage-01c rewire: this wrapper is now a structural adapter over\n * `useCollapsible()` (axes A + G + P). `render={}` is gone — use `as=`\n * to swap the underlying tag/component.\n */\nexport interface CollapsibleTriggerProps\n\textends JSX.ButtonHTMLAttributes<HTMLButtonElement>,\n\t\tNativeButtonProps {\n\t/**\n\t * Tag/component to render. Defaults to `\"button\"`. Replaces the\n\t * pre-spike `render` prop (axis G).\n\t */\n\tas?: ValidComponent;\n\t/**\n\t * Whether the trigger is disabled. Falls back to the collapsible's own\n\t * disabled state when not specified.\n\t */\n\tdisabled?: boolean | undefined;\n}\n\n/**\n * A button that opens and closes the collapsible panel. Renders a `<button>`\n * element (or `as` override).\n *\n * Solid 2 notes:\n *\n * - Reads the collapsible API via `useCollapsible()` — works both under\n *   `<Collapsible.Root>` (which provides the new `CollapsibleContext`) and\n *   inside accordion items (which bridge both contexts).\n * - `useButton` provides keyboard activation (Space/Enter) and\n *   disabled-suppression via `event.preventDefault()`. Composed via\n *   `mergeRootProps(buttonProps, c.trigger(userProps))`: `buttonProps` is\n *   the \"internal\" side (runs first), `c.trigger(userProps)` is the \"user\"\n *   side. This ordering ensures `useButton`'s disabled check fires before the\n *   toggle onClick. When disabled, `useButton.onClick` calls `preventDefault()`\n *   which gates the `mergeRootProps` chain and stops the toggle from running.\n * - All keys from both sides use plain-object getters (not a Proxy), so every\n *   key is always in `ownKeys` regardless of its current value. This avoids the\n *   Solid 2 undefined-attr tracking footgun: `data-panel-open` is in `ownKeys`\n *   even when closed (returning `undefined`) so the reactive binding is\n *   established on first spread.\n * - `aria-expanded` emits the literal `\"true\"`/`\"false\"` string (not a raw\n *   boolean) because RFC 07's enumerated-pseudo-boolean rules collapse raw\n *   `true` to a presence-only attribute, and screen readers expect the string.\n * - `aria-controls` is gated on `open` (matching React's `open ? panelId :\n *   undefined`) — the getter returns `undefined` while closed, so the attribute\n *   is omitted rather than dangling at a panel that isn't in the DOM (notably\n *   under SSR). `mergeRootProps` keeps the key reactive across spreads even when\n *   it starts `undefined`, so the old `\"\"`-seed undefined-attr workaround is no\n *   longer needed (see `create-collapsible.tsx`).\n */\nexport function CollapsibleTrigger(\n\tprops: CollapsibleTriggerProps,\n): JSX.Element {\n\tconst c = useCollapsible();\n\n\t// Context `disabled` wins unless the consumer explicitly overrides it.\n\tconst disabled = (): boolean => {\n\t\tconst own = props.disabled;\n\t\tif (own !== undefined) return Boolean(own);\n\t\treturn c.disabled();\n\t};\n\tconst nativeButton = (): boolean => props.nativeButton ?? true;\n\n\tconst { props: buttonProps, ref: buttonRef } = useButton({\n\t\tdisabled,\n\t\tfocusableWhenDisabled: () => true,\n\t\tnative: nativeButton,\n\t});\n\n\t// Strip our config keys before passing user props into the trigger slot.\n\tconst userProps = omit(props, \"as\", \"disabled\", \"nativeButton\");\n\n\t// Compose: buttonProps is \"internal\" (runs first on onClick), c.trigger()\n\t// is \"user\" (runs second, gated by defaultPrevented). This ordering preserves\n\t// the disabled check from useButton gating the toggle handler.\n\t//\n\t// Both sides return plain objects with Object.defineProperty getters, so ALL\n\t// keys survive in the output's ownKeys regardless of current value — Solid's\n\t// compiled spread sees them and sets up reactive bindings even for keys whose\n\t// initial value is undefined (e.g. data-panel-open when closed).\n\tconst merged = mergeRootProps(buttonProps, c.trigger(userProps));\n\n\tconst Tag = dynamic(() => props.as ?? \"button\");\n\treturn <Tag {...merged} ref={composeRefs(buttonRef, userRef(props))} />;\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,IAAI,QAAQ,UAAU;AAC/B,SAASC,WAAW,EAAEC,OAAO,QAAQ,8BAA8B;AACnE,SAASC,cAAc,QAAQ,kCAAkC;AAEjE,SAASC,SAAS,QAAQ,uCAAuC;AACjE,SAASC,cAAc,QAAQ,2BAA2B;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CACjCC,KAA8B,EAChB;EACd,MAAMC,CAAC,GAAGH,cAAc,CAAC,CAAC;;EAE1B;EACA,MAAMI,QAAQ,GAAGA,CAAA,KAAe;IAC/B,MAAMC,GAAG,GAAGH,KAAK,CAACE,QAAQ;IAC1B,IAAIC,GAAG,KAAKC,SAAS,EAAE,OAAOC,OAAO,CAACF,GAAG,CAAC;IAC1C,OAAOF,CAAC,CAACC,QAAQ,CAAC,CAAC;EACpB,CAAC;EACD,MAAMI,YAAY,GAAGA,CAAA,KAAeN,KAAK,CAACM,YAAY,IAAI,IAAI;EAE9D,MAAM;IAAEN,KAAK,EAAEO,WAAW;IAAEC,GAAG,EAAEC;EAAU,CAAC,GAAGZ,SAAS,CAAC;IACxDK,QAAQ;IACRQ,qBAAqB,EAAEA,CAAA,KAAM,IAAI;IACjCC,MAAM,EAAEL;EACT,CAAC,CAAC;;EAEF;EACA,MAAMM,SAAS,GAAGnB,IAAI,CAACO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC;;EAE/D;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMa,MAAM,GAAGjB,cAAc,CAACW,WAAW,EAAEN,CAAC,CAACa,OAAO,CAACF,SAAS,CAAC,CAAC;EAEhE,MAAMG,GAAG,GAAGvB,OAAO,CAAC,MAAMQ,KAAK,CAACgB,EAAE,IAAI,QAAQ,CAAC;EAC/C,OAAO,CAAC,GAAG,CAAC,IAAIH,MAAM,CAAC,CAAC,GAAG,CAAC,CAACnB,WAAW,CAACe,SAAS,EAAEd,OAAO,CAACK,KAAK,CAAC,CAAC,CAAC,GAAG;AACxE","ignoreList":[]}