sparkle-design 1.0.3 → 1.0.4
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.
|
@@ -138,8 +138,5 @@ export interface ButtonProps extends Omit<NativeButtonProps, "onClick" | "onKeyD
|
|
|
138
138
|
*
|
|
139
139
|
* @param {ButtonProps} props
|
|
140
140
|
*/
|
|
141
|
-
declare
|
|
142
|
-
declare namespace Button {
|
|
143
|
-
var displayName: string;
|
|
144
|
-
}
|
|
141
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLElement>>;
|
|
145
142
|
export { Button, buttonVariants };
|
|
@@ -308,7 +308,7 @@ const buttonVariants = cva([
|
|
|
308
308
|
*
|
|
309
309
|
* @param {ButtonProps} props
|
|
310
310
|
*/
|
|
311
|
-
function Button(_a) {
|
|
311
|
+
const Button = React.forwardRef(function Button(_a, ref) {
|
|
312
312
|
var { className, variant, size, theme, isLoading = false, isDisabled = false, asChild = false, disabled, prefixIcon, suffixIcon, children } = _a, props = __rest(_a, ["className", "variant", "size", "theme", "isLoading", "isDisabled", "asChild", "disabled", "prefixIcon", "suffixIcon", "children"]);
|
|
313
313
|
const Comp = asChild ? SlotPrimitive.Slot : "button";
|
|
314
314
|
// disabled状態の管理(isDisabled、disabled、またはisLoadingがtrueの場合)
|
|
@@ -363,13 +363,21 @@ function Button(_a) {
|
|
|
363
363
|
}
|
|
364
364
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
365
365
|
};
|
|
366
|
-
return (_jsx(Comp
|
|
366
|
+
return (_jsx(Comp
|
|
367
|
+
// asChild ケースで <a> 等を受け入れるため公開 API は HTMLElement で広く受けるが、
|
|
368
|
+
// 内部の Comp は <button> 固定の union が含まれるためここで narrow する。
|
|
369
|
+
// en: Public ref is HTMLElement (covers asChild targets); inner Comp's button branch needs narrowing.
|
|
370
|
+
, Object.assign({
|
|
371
|
+
// asChild ケースで <a> 等を受け入れるため公開 API は HTMLElement で広く受けるが、
|
|
372
|
+
// 内部の Comp は <button> 固定の union が含まれるためここで narrow する。
|
|
373
|
+
// en: Public ref is HTMLElement (covers asChild targets); inner Comp's button branch needs narrowing.
|
|
374
|
+
ref: ref, "data-slot": "button", "aria-busy": isLoading || undefined, "aria-disabled": asChild && isButtonDisabled ? true : undefined, "data-disabled": asChild && isButtonDisabled ? "true" : undefined, disabled: asChild ? undefined : isButtonDisabled, className: cn(buttonVariants({
|
|
367
375
|
variant,
|
|
368
376
|
size,
|
|
369
377
|
theme,
|
|
370
378
|
isLoading,
|
|
371
379
|
className,
|
|
372
380
|
})), type: asChild ? undefined : props.type || "button", onClick: handleClick, onKeyDown: handleKeyDown }, restProps, { children: asChild ? (children) : (_jsxs(_Fragment, { children: [prefixIcon && (_jsx(Icon, { icon: prefixIcon, size: getIconSize(), className: cn({ "opacity-0": isLoading }) })), isLoading ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 inline-flex", children: _jsx(Spinner, { size: getIconSize(), className: "text-current" }) }), _jsx("span", { className: "opacity-0", children: children })] })) : (_jsx("span", { className: "px-1", children: children })), suffixIcon && (_jsx(Icon, { icon: suffixIcon, size: getIconSize(), className: cn({ "opacity-0": isLoading }) }))] })) })));
|
|
373
|
-
}
|
|
381
|
+
});
|
|
374
382
|
Button.displayName = "Button";
|
|
375
383
|
export { Button, buttonVariants };
|