{"version":3,"names":["dynamic","omit","composeRefs","userRef","mergeRootProps","resolveClassStyle","useButton","Button","props","disabled","Boolean","focusableWhenDisabled","nativeButton","buttonProps","ref","buttonRef","native","stateAttrs","data-disabled","undefined","userStyling","userProps","internal","styledUserProps","merged","Tag","as"],"sources":["button.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 { resolveClassStyle } from \"../internals/resolve-class-style\";\nimport type {\n\tBaseUIComponentProps,\n\tNativeButtonProps,\n} from \"../internals/types\";\nimport { useButton } from \"../internals/use-button/use-button\";\n\nexport interface ButtonState {\n\t/**\n\t * Whether the button should ignore user interaction.\n\t */\n\tdisabled: boolean;\n}\n\nexport interface ButtonProps\n\textends NativeButtonProps,\n\t\tBaseUIComponentProps<\"button\", ButtonState> {\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 button should be focusable when disabled.\n\t * @default false\n\t */\n\tfocusableWhenDisabled?: boolean | undefined;\n}\n\n/**\n * A button component that can be used to trigger actions.\n * Renders a `<button>` element (or `as` override).\n *\n * Solid 2.0-native rewire (§1 wave 1): replaces `renderElement` with\n * `dynamic(() => props.as ?? \"button\")` and threads the\n * `useButton` reactive bag plus a local `data-disabled` getter through\n * `mergeRootProps`. Consumer's `type` still wins over the primitive's\n * default via `mergeRootProps`'s \"user-defined wins\" rule.\n */\nexport function Button(props: ButtonProps): JSX.Element {\n\tconst disabled = (): boolean => Boolean(props.disabled);\n\tconst focusableWhenDisabled = (): boolean | undefined =>\n\t\tprops.focusableWhenDisabled;\n\tconst nativeButton = (): boolean => props.nativeButton ?? true;\n\n\tconst { props: buttonProps, ref: buttonRef } = useButton({\n\t\tdisabled,\n\t\tfocusableWhenDisabled,\n\t\tnative: nativeButton,\n\t});\n\n\t// State-attr projection: emit `data-disabled` (presence) when disabled.\n\tconst stateAttrs = {\n\t\tget \"data-disabled\"(): \"\" | undefined {\n\t\t\treturn disabled() ? \"\" : undefined;\n\t\t},\n\t};\n\n\t// Strip our own API props so they don't leak onto the DOM.\n\tconst userStyling = resolveClassStyle(props, () => ({\n\t\tdisabled: disabled(),\n\t}));\n\n\tconst userProps = 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\"focusableWhenDisabled\",\n\t\t\"nativeButton\",\n\t);\n\n\t// Compose: state-attrs + buttonProps form the \"internal\" side; userProps\n\t// forms the \"user\" side. mergeRootProps gives user precedence on plain keys\n\t// (so consumer `type=\"submit\"` overrides the primitive's `type=\"button\"`),\n\t// composes class/style, and chains event handlers (internal first, user\n\t// gated by defaultPrevented).\n\tconst internal = mergeRootProps(stateAttrs, buttonProps);\n\tconst styledUserProps = mergeRootProps(userStyling, userProps);\n\n\tconst merged = mergeRootProps(internal, styledUserProps);\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,2BAA2B;AAChE,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,iBAAiB,QAAQ,kCAAkC;AAKpE,SAASC,SAAS,QAAQ,oCAAoC;AAwB9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAACC,KAAkB,EAAe;EACvD,MAAMC,QAAQ,GAAGA,CAAA,KAAeC,OAAO,CAACF,KAAK,CAACC,QAAQ,CAAC;EACvD,MAAME,qBAAqB,GAAGA,CAAA,KAC7BH,KAAK,CAACG,qB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