{"version":3,"names":["dynamic","createRenderEffect","omit","untrack","useCollapsible","ARROW_DOWN","ARROW_LEFT","ARROW_RIGHT","ARROW_UP","END","HOME","isElementDisabled","mergeRootProps","resolveClassStyle","useButton","useAccordionItemContext","useAccordionRootContext","SUPPORTED_KEYS","Set","getActiveTriggers","accordionItemRefs","output","section","trigger","querySelector","push","AccordionTrigger","props","collapsible","root","item","disabled","own","undefined","Boolean","nativeButton","buttonProps","ref","buttonRef","focusableWhenDisabled","native","composite","id","idProp","setTriggerId","triggerId","handleClick","event","setOpen","open","handleKeyDown","has","key","preventDefault","stopPropagation","triggers","numEnabled","length","lastIndex","thisIndex","indexOf","currentTarget","loopFocus","isHorizontal","orientation","isRtl","direction","nextIndex","toNext","Math","min","toPrev","focus","userStyling","state","userHtmlProps","internalProps","tabIndex","onClick","onKeyDown","aria-controls","panelId","aria-expanded","data-panel-open","data-disabled","data-index","i","index","Number","isInteger","String","styledUserProps","merged","Tag","as"],"sources":["accordion-trigger.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { createRenderEffect, omit, untrack } from \"solid-js\";\nimport { useCollapsible } from \"../../collapsible/create-collapsible.tsx\";\nimport {\n\tARROW_DOWN,\n\tARROW_LEFT,\n\tARROW_RIGHT,\n\tARROW_UP,\n\tEND,\n\tHOME,\n} from \"../../internals/composite/composite-constants.ts\";\nimport { isElementDisabled } from \"../../internals/dom/is-element-disabled.ts\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { resolveClassStyle } from \"../../internals/resolve-class-style\";\nimport type {\n\tBaseUIComponentProps,\n\tNativeButtonProps,\n} from \"../../internals/types\";\nimport { useButton } from \"../../internals/use-button/use-button\";\nimport {\n\ttype AccordionItemState,\n\tuseAccordionItemContext,\n} from \"../accordion-item-context.ts\";\nimport { useAccordionRootContext } from \"../accordion-root-context.ts\";\n\nexport interface AccordionTriggerState extends AccordionItemState {}\n\nexport interface AccordionTriggerProps\n\textends NativeButtonProps,\n\t\tBaseUIComponentProps<\"button\", AccordionTriggerState> {\n\t/** Tag/component to render. Defaults to `\"button\"`. */\n\tas?: ValidComponent;\n}\n\nconst SUPPORTED_KEYS = new Set<string>([\n\tARROW_DOWN,\n\tARROW_UP,\n\tARROW_RIGHT,\n\tARROW_LEFT,\n\tHOME,\n\tEND,\n]);\n\n/**\n * Walk the accordion's registered items and collect the trigger element from\n * each non-disabled item. Mirrors Base UI React's `getActiveTriggers`.\n *\n * Shadow-DOM-safe DOM traversal via `isElementDisabled` from\n * `src/internals/dom/` (the shadow-DOM-safe helper). `querySelector` is used\n * to find the trigger within each item — we target `[type=\"button\"]` and\n * `[role=\"button\"]` so both native and non-native triggers work.\n */\nfunction getActiveTriggers(\n\taccordionItemRefs: Array<HTMLElement | null>,\n): HTMLElement[] {\n\tconst output: HTMLElement[] = [];\n\tfor (const section of accordionItemRefs) {\n\t\tif (!section || isElementDisabled(section)) continue;\n\t\tconst trigger = section.querySelector<HTMLElement>(\n\t\t\t'[type=\"button\"], [role=\"button\"]',\n\t\t);\n\t\tif (trigger && !isElementDisabled(trigger)) {\n\t\t\toutput.push(trigger);\n\t\t}\n\t}\n\treturn output;\n}\n\n/**\n * Button that expands or collapses its item's panel. Renders a `<button>` by\n * default; use `nativeButton={false}` with a `render` prop override to render\n * a non-button element.\n *\n * Solid 2 notes:\n *\n * - The keyboard handler walks `root.accordionItemRefs` (a plain array kept\n *   in DOM order by `<CompositeList>`) and builds a \"live\" list of sibling\n *   triggers on every key press. This matches React's approach — no\n *   pre-computed ref tracking, so re-ordering is handled naturally.\n * - `aria-controls` is gated on `open` (matching React) — the getter returns\n *   `undefined` while closed so the attribute is omitted (not `aria-controls=\"\"`\n *   pointing at a non-existent panel). `id` uses a `\"\"` seed so the key stays\n *   in `ownKeys` from the first spread. `mergeRootProps` declares every getter\n *   key as `own` regardless of value, so a getter starting `undefined` still\n *   tracks (see `test/internals/merge-props-undefined-attr.test.tsx`).\n * - `aria-expanded` emits the literal `\"true\"`/`\"false\"` string — RFC 07's\n *   enumerated-pseudo-boolean rules collapse raw `true` to a presence\n *   attribute, which breaks AT that keys off the literal string.\n * - The consumer-supplied `id` registers as the item's `triggerId` so the\n *   panel's `aria-labelledby` can point to it. We also use it as the\n *   trigger's own `id` (so the trigger and panel form a two-way ARIA link).\n *   Registration happens in a `createRenderEffect` and is cleaned up on\n *   unmount — matches React's `useIsoLayoutEffect`.\n */\nexport function AccordionTrigger(props: AccordionTriggerProps): JSX.Element {\n\tconst collapsible = useCollapsible();\n\tconst root = useAccordionRootContext();\n\tconst item = useAccordionItemContext();\n\n\tconst disabled = (): boolean => {\n\t\tconst own = props.disabled;\n\t\tif (own !== undefined) return Boolean(own);\n\t\treturn collapsible.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\tcomposite: () => true,\n\t});\n\n\t// React reads `idProp` at setup and registers on every change; our effect\n\t// mirrors that. We only register a consumer-supplied id — the\n\t// auto-generated fallback stays registered by the item (via the initial\n\t// `createSignal(useBaseUiId())`). The 2-arg form (compute, apply) is what\n\t// `@solidjs/signals` v2 expects — see every `createRenderEffect` call in\n\t// `src/collapsible/` and `src/internals/use-transition-status/`.\n\tcreateRenderEffect(\n\t\t() => (typeof props.id === \"string\" ? (props.id as string) : undefined),\n\t\t(idProp: string | undefined) => {\n\t\t\tif (!idProp) return undefined;\n\t\t\titem.setTriggerId(idProp);\n\t\t\treturn () => {\n\t\t\t\t// Only clear if we're still the registered id — matches the\n\t\t\t\t// collapsible panel's cleanup guard. A later re-registration\n\t\t\t\t// (e.g. the root's `get children()` re-evaluating) must not\n\t\t\t\t// clobber the fresh write.\n\t\t\t\tif (untrack(item.triggerId) === idProp) {\n\t\t\t\t\titem.setTriggerId(undefined);\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t);\n\n\tconst handleClick = (event: MouseEvent): void => {\n\t\tif (disabled()) return;\n\t\tcollapsible.setOpen(!collapsible.open(), event, \"trigger-press\");\n\t};\n\n\tconst handleKeyDown = (event: KeyboardEvent): void => {\n\t\tif (!SUPPORTED_KEYS.has(event.key)) return;\n\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\tconst triggers = getActiveTriggers(root.accordionItemRefs);\n\t\tconst numEnabled = triggers.length;\n\t\tconst lastIndex = numEnabled - 1;\n\t\tconst thisIndex = triggers.indexOf(event.currentTarget as HTMLElement);\n\n\t\tconst loopFocus = root.loopFocus();\n\t\tconst isHorizontal = root.orientation() === \"horizontal\";\n\t\tconst isRtl = root.direction() === \"rtl\";\n\n\t\tlet nextIndex = -1;\n\n\t\tconst toNext = (): void => {\n\t\t\tif (loopFocus) {\n\t\t\t\tnextIndex = thisIndex + 1 > lastIndex ? 0 : thisIndex + 1;\n\t\t\t} else {\n\t\t\t\tnextIndex = Math.min(thisIndex + 1, lastIndex);\n\t\t\t}\n\t\t};\n\t\tconst toPrev = (): void => {\n\t\t\tif (loopFocus) {\n\t\t\t\tnextIndex = thisIndex === 0 ? lastIndex : thisIndex - 1;\n\t\t\t} else {\n\t\t\t\tnextIndex = thisIndex - 1;\n\t\t\t}\n\t\t};\n\n\t\tswitch (event.key) {\n\t\t\tcase ARROW_DOWN:\n\t\t\t\tif (!isHorizontal) toNext();\n\t\t\t\tbreak;\n\t\t\tcase ARROW_UP:\n\t\t\t\tif (!isHorizontal) toPrev();\n\t\t\t\tbreak;\n\t\t\tcase ARROW_RIGHT:\n\t\t\t\tif (isHorizontal) (isRtl ? toPrev : toNext)();\n\t\t\t\tbreak;\n\t\t\tcase ARROW_LEFT:\n\t\t\t\tif (isHorizontal) (isRtl ? toNext : toPrev)();\n\t\t\t\tbreak;\n\t\t\tcase HOME:\n\t\t\t\tnextIndex = 0;\n\t\t\t\tbreak;\n\t\t\tcase END:\n\t\t\t\tnextIndex = lastIndex;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (nextIndex > -1 && nextIndex <= lastIndex) {\n\t\t\ttriggers[nextIndex]?.focus();\n\t\t}\n\t};\n\n\tconst userStyling = resolveClassStyle(props, () => item.state());\n\n\tconst userHtmlProps = omit(\n\t\tprops,\n\t\t\"class\",\n\t\t\"style\",\n\t\t\"attrs\",\n\t\t\"as\",\n\t\t\"disabled\",\n\t\t\"nativeButton\",\n\t) as Record<string, unknown>;\n\n\tconst internalProps = {\n\t\tref: buttonRef,\n\t\ttabIndex: 0,\n\t\tonClick: handleClick,\n\t\tonKeyDown: handleKeyDown,\n\t\tget \"aria-controls\"() {\n\t\t\t// Match React: omit `aria-controls` entirely (not `\"\"`) while closed,\n\t\t\t// so it never points at a panel that isn't rendered. `mergeRootProps`\n\t\t\t// keeps the key reactive across spreads even though it can start\n\t\t\t// `undefined`.\n\t\t\treturn collapsible.open() ? collapsible.panelId() : undefined;\n\t\t},\n\t\tget \"aria-expanded\"() {\n\t\t\treturn collapsible.open() ? \"true\" : \"false\";\n\t\t},\n\t\tget id() {\n\t\t\treturn item.triggerId() ?? \"\";\n\t\t},\n\t\tget \"data-panel-open\"(): \"\" | undefined {\n\t\t\treturn collapsible.open() ? \"\" : undefined;\n\t\t},\n\t\tget \"data-disabled\"(): \"\" | undefined {\n\t\t\treturn disabled() ? \"\" : undefined;\n\t\t},\n\t\tget \"data-index\"() {\n\t\t\tconst i = item.state().index;\n\t\t\treturn Number.isInteger(i) ? String(i) : undefined;\n\t\t},\n\t};\n\n\tconst styledUserProps = mergeRootProps(userStyling, userHtmlProps);\n\n\tconst merged = mergeRootProps(\n\t\tmergeRootProps(internalProps, buttonProps),\n\t\tstyledUserProps,\n\t);\n\n\tconst Tag = dynamic(() => props.as ?? \"button\");\n\treturn <Tag {...merged} />;\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,kBAAkB,EAAEC,IAAI,E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