sparkle-design 1.0.3 → 1.0.5

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 function Button({ className, variant, size, theme, isLoading, isDisabled, asChild, disabled, prefixIcon, suffixIcon, children, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
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, Object.assign({ "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({
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 };
@@ -52,6 +52,11 @@ export const Icon = React.forwardRef((_a, ref) => {
52
52
  const iconTypographyClass = hasIconTypographyClass
53
53
  ? ""
54
54
  : `icon-${size}-fill-${fillValue}`;
55
- return (_jsx("span", Object.assign({ ref: ref, className: cn(iconTypographyClass, "select-none", className), "aria-hidden": "true" }, props, { children: icon })));
55
+ return (_jsx("span", Object.assign({ ref: ref,
56
+ // font-medium: アイコンの weight は 500 で統一。親要素(Button の bold 等)から
57
+ // font-weight が継承されると疑似ボールド(faux bold)で太く描画されるため明示する。
58
+ // en: Icons are unified at weight 500. Set font-weight explicitly so an inherited
59
+ // font-weight (e.g. bold Button labels) does not trigger faux-bold rendering.
60
+ className: cn(iconTypographyClass, "select-none font-medium", className), "aria-hidden": "true" }, props, { children: icon })));
56
61
  });
57
62
  Icon.displayName = "Icon";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sparkle-design",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public"
@@ -83,8 +83,8 @@
83
83
  "@types/node": "^20",
84
84
  "@types/react": "^18",
85
85
  "@types/react-dom": "^18",
86
- "@vitest/browser": "^3.0.9",
87
- "@vitest/coverage-v8": "^3.0.9",
86
+ "@vitest/browser-playwright": "^4.1.0",
87
+ "@vitest/coverage-v8": "^4.1.0",
88
88
  "axe-core": "^4.10.3",
89
89
  "eslint": "^9",
90
90
  "eslint-config-next": "15.3.1",
@@ -99,7 +99,7 @@
99
99
  "tsc-alias": "^1.8.16",
100
100
  "typescript": "^5",
101
101
  "vite": "6.4.2",
102
- "vitest": "^3.0.9"
102
+ "vitest": "^4.1.0"
103
103
  },
104
104
  "pnpm": {
105
105
  "overrides": {