sparkle-design 1.0.7 → 2.0.0-beta.0

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.
Files changed (61) hide show
  1. package/dist/components/ui/badge/index.d.ts +2 -2
  2. package/dist/components/ui/badge/index.js +8 -8
  3. package/dist/components/ui/breadcrumb/index.d.ts +6 -6
  4. package/dist/components/ui/breadcrumb/index.js +2 -2
  5. package/dist/components/ui/button/index.d.ts +70 -5
  6. package/dist/components/ui/button/index.js +257 -103
  7. package/dist/components/ui/card/index.d.ts +119 -23
  8. package/dist/components/ui/card/index.js +155 -45
  9. package/dist/components/ui/checkbox/index.d.ts +1 -1
  10. package/dist/components/ui/checkbox/index.js +23 -23
  11. package/dist/components/ui/dialog/index.d.ts +15 -15
  12. package/dist/components/ui/dialog/index.js +6 -6
  13. package/dist/components/ui/divider/index.d.ts +5 -2
  14. package/dist/components/ui/divider/index.js +6 -11
  15. package/dist/components/ui/form/index.d.ts +10 -7
  16. package/dist/components/ui/form/index.js +17 -7
  17. package/dist/components/ui/form/label.d.ts +1 -1
  18. package/dist/components/ui/icon/index.d.ts +6 -3
  19. package/dist/components/ui/icon/index.js +4 -9
  20. package/dist/components/ui/icon-button/index.d.ts +118 -5
  21. package/dist/components/ui/icon-button/index.js +270 -52
  22. package/dist/components/ui/inline-message/index.d.ts +13 -4
  23. package/dist/components/ui/inline-message/index.js +20 -20
  24. package/dist/components/ui/input/index.d.ts +6 -3
  25. package/dist/components/ui/input/index.js +14 -14
  26. package/dist/components/ui/input-password/index.d.ts +4 -1
  27. package/dist/components/ui/input-password/index.js +14 -2
  28. package/dist/components/ui/link/index.d.ts +13 -6
  29. package/dist/components/ui/link/index.js +16 -13
  30. package/dist/components/ui/modal/index.d.ts +11 -11
  31. package/dist/components/ui/modal/index.js +2 -2
  32. package/dist/components/ui/overlay/index.d.ts +5 -2
  33. package/dist/components/ui/overlay/index.js +4 -5
  34. package/dist/components/ui/radio/index.d.ts +10 -4
  35. package/dist/components/ui/radio/index.js +90 -20
  36. package/dist/components/ui/select/index.d.ts +11 -11
  37. package/dist/components/ui/select/index.js +13 -13
  38. package/dist/components/ui/skeleton/index.d.ts +1 -1
  39. package/dist/components/ui/skeleton/index.js +1 -1
  40. package/dist/components/ui/slider/index.d.ts +53 -1
  41. package/dist/components/ui/slider/index.js +75 -13
  42. package/dist/components/ui/spinner/index.d.ts +6 -3
  43. package/dist/components/ui/spinner/index.js +5 -10
  44. package/dist/components/ui/switch/index.d.ts +1 -1
  45. package/dist/components/ui/switch/index.js +11 -7
  46. package/dist/components/ui/tabs/index.d.ts +8 -4
  47. package/dist/components/ui/tabs/index.js +40 -37
  48. package/dist/components/ui/tag/index.d.ts +6 -3
  49. package/dist/components/ui/tag/index.js +19 -24
  50. package/dist/components/ui/textarea/index.d.ts +5 -2
  51. package/dist/components/ui/textarea/index.js +9 -14
  52. package/dist/components/ui/toast/index.d.ts +1 -1
  53. package/dist/components/ui/toast/index.js +1 -1
  54. package/dist/components/ui/tooltip/index.d.ts +4 -4
  55. package/dist/components/ui/tooltip/index.js +1 -1
  56. package/dist/lib/utils.d.ts +8 -0
  57. package/dist/lib/utils.js +60 -1
  58. package/dist/test/helpers.d.ts +3 -2
  59. package/dist/test/helpers.js +23 -4
  60. package/dist/test/setup.js +37 -31
  61. package/package.json +17 -10
@@ -54,7 +54,7 @@ export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {
54
54
  * // ❌ Wrong - ステータスラベルに Badge を使わない
55
55
  * <Badge>未紐付け</Badge>
56
56
  * ```
57
-
57
+ *
58
58
  * **使用例 / Usage Example**
59
59
  *
60
60
  * ```tsx
@@ -63,5 +63,5 @@ export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {
63
63
  *
64
64
  * @param {BadgeProps} props
65
65
  */
66
- declare function Badge({ className, isNumberVisible, size, variant, isGapped, children, role, ...props }: BadgeProps): import("react/jsx-runtime").JSX.Element;
66
+ declare function Badge({ className, isNumberVisible, size, variant, isGapped, children, role, ...props }: BadgeProps): React.JSX.Element;
67
67
  export { Badge, badgeVariants };
@@ -12,11 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { cva } from "class-variance-authority";
14
14
  import { cn } from "../../../lib/utils.js";
15
- const badgeVariants = cva("inline-flex items-center text-white text-center justify-center rounded-full transition-colors focus:outline-hidden focus:ring-2 focus:ring-[var(--color-ring-normal)] focus:ring-offset-2", {
15
+ const badgeVariants = cva("inline-flex items-center text-text-inverse text-center justify-center rounded-full transition-colors focus:outline-hidden focus:ring-2 focus:ring-border-ring focus:ring-offset-2", {
16
16
  variants: {
17
17
  variant: {
18
- normal: "bg-info-500",
19
- emphasis: "bg-negative-500",
18
+ normal: "bg-surface-primary-high-enabled",
19
+ emphasis: "bg-surface-negative-high-enabled",
20
20
  },
21
21
  isNumberVisible: {
22
22
  true: "",
@@ -38,22 +38,22 @@ const badgeVariants = cva("inline-flex items-center text-white text-center justi
38
38
  {
39
39
  isGapped: true,
40
40
  size: "xs",
41
- class: "outline-white outline-2",
41
+ class: "outline-border-inverse outline-2",
42
42
  },
43
43
  {
44
44
  isGapped: true,
45
45
  size: "sm",
46
- class: "outline-white outline-4",
46
+ class: "outline-border-inverse outline-4",
47
47
  },
48
48
  {
49
49
  isGapped: true,
50
50
  size: "md",
51
- class: "outline-white outline-4",
51
+ class: "outline-border-inverse outline-4",
52
52
  },
53
53
  {
54
54
  isGapped: true,
55
55
  size: "lg",
56
- class: "outline-white outline-4",
56
+ class: "outline-border-inverse outline-4",
57
57
  },
58
58
  // 数字がない場合はheightを指定
59
59
  {
@@ -95,7 +95,7 @@ const badgeVariants = cva("inline-flex items-center text-white text-center justi
95
95
  * // ❌ Wrong - ステータスラベルに Badge を使わない
96
96
  * <Badge>未紐付け</Badge>
97
97
  * ```
98
-
98
+ *
99
99
  * **使用例 / Usage Example**
100
100
  *
101
101
  * ```tsx
@@ -32,39 +32,39 @@ import { Link } from "@/components/ui/link";
32
32
  *
33
33
  * @param {BreadcrumbProps} props
34
34
  */
35
- export declare function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">): import("react/jsx-runtime").JSX.Element;
35
+ export declare function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">): React.JSX.Element;
36
36
  /**
37
37
  * パンくずリスト(ol)
38
38
  * en: Breadcrumb list (ol)
39
39
  *
40
40
  * @param {React.ComponentProps<"ol">} props
41
41
  */
42
- export declare function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">): import("react/jsx-runtime").JSX.Element;
42
+ export declare function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">): React.JSX.Element;
43
43
  /**
44
44
  * パンくずアイテム(li)
45
45
  * en: Breadcrumb item (li)
46
46
  *
47
47
  * @param {React.ComponentProps<"li">} props
48
48
  */
49
- export declare function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">): import("react/jsx-runtime").JSX.Element;
49
+ export declare function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
50
50
  /**
51
51
  * パンくずリンク
52
52
  * en: Breadcrumb link
53
53
  *
54
54
  * @param {React.ComponentProps<typeof Link>} props
55
55
  */
56
- export declare function BreadcrumbLink({ className, ...props }: React.ComponentProps<typeof Link>): import("react/jsx-runtime").JSX.Element;
56
+ export declare function BreadcrumbLink({ className, ...props }: React.ComponentProps<typeof Link>): React.JSX.Element;
57
57
  /**
58
58
  * パンくずの区切り(/など)
59
59
  * en: Breadcrumb separator (e.g. /)
60
60
  *
61
61
  * @param {React.ComponentProps<"span">} props
62
62
  */
63
- export declare function BreadcrumbSeparator({ className, children, ...props }: React.ComponentProps<"span">): import("react/jsx-runtime").JSX.Element;
63
+ export declare function BreadcrumbSeparator({ className, children, ...props }: React.ComponentProps<"span">): React.JSX.Element;
64
64
  /**
65
65
  * 現在ページ表示用
66
66
  * en: Current page label (not a link)
67
67
  *
68
68
  * @param {React.ComponentProps<"span">} props
69
69
  */
70
- export declare function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">): import("react/jsx-runtime").JSX.Element;
70
+ export declare function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
@@ -82,7 +82,7 @@ export function BreadcrumbLink(_a) {
82
82
  */
83
83
  export function BreadcrumbSeparator(_a) {
84
84
  var { className, children } = _a, props = __rest(_a, ["className", "children"]);
85
- return (_jsx("span", Object.assign({ "aria-hidden": "true", "data-slot": "breadcrumb-separator", className: cn("mx-1 text-neutral-500 select-none", className) }, props, { children: children !== null && children !== void 0 ? children : "/" })));
85
+ return (_jsx("span", Object.assign({ "aria-hidden": "true", "data-slot": "breadcrumb-separator", className: cn("mx-1 text-text-neutral-low select-none", className) }, props, { children: children !== null && children !== void 0 ? children : "/" })));
86
86
  }
87
87
  /**
88
88
  * 現在ページ表示用
@@ -92,5 +92,5 @@ export function BreadcrumbSeparator(_a) {
92
92
  */
93
93
  export function BreadcrumbPage(_a) {
94
94
  var { className } = _a, props = __rest(_a, ["className"]);
95
- return (_jsx("span", Object.assign({ "data-slot": "breadcrumb-page", "aria-disabled": "true", "aria-current": "page", className: cn("character-3-regular-pro text-text-high cursor-default", className) }, props)));
95
+ return (_jsx("span", Object.assign({ "data-slot": "breadcrumb-page", "aria-current": "page", className: cn("character-3-regular-pro text-text-neutral-high cursor-default", className) }, props)));
96
96
  }
@@ -7,8 +7,15 @@ declare const buttonVariants: (props?: ({
7
7
  isLoading?: boolean | null | undefined;
8
8
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
9
9
  type ButtonVariantProps = VariantProps<typeof buttonVariants>;
10
- type NativeButtonProps = React.ComponentPropsWithoutRef<"button">;
11
- export interface ButtonProps extends Omit<NativeButtonProps, "onClick" | "onKeyDown"> {
10
+ type NativeButtonProps = React.ComponentProps<"button">;
11
+ export interface ButtonProps extends Omit<NativeButtonProps, "onClick" | "onKeyDown" | "onClickCapture" | "onKeyDownCapture" | "onAuxClickCapture" | "ref"> {
12
+ /**
13
+ * ルート要素への ref。`asChild` で `<a>` 等を差し込むケースを受け入れるため
14
+ * `HTMLButtonElement` ではなく `HTMLElement` で広く受ける
15
+ * en: Ref to the root element. Typed as `HTMLElement` (not `HTMLButtonElement`)
16
+ * so `asChild` targets such as `<a>` are accepted.
17
+ */
18
+ ref?: React.Ref<HTMLElement>;
12
19
  /**
13
20
  * ボタンのサイズバリエーション
14
21
  * en: Size variation of the button
@@ -61,6 +68,21 @@ export interface ButtonProps extends Omit<NativeButtonProps, "onClick" | "onKeyD
61
68
  * We intentionally type this as HTMLElement because `asChild` can render non-button elements.
62
69
  */
63
70
  onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
71
+ /**
72
+ * capture フェーズのクリックハンドラ。無効時はコンポーネント側のガードが優先される
73
+ * en: Capture-phase click handler. The component's disabled guard takes precedence.
74
+ */
75
+ onClickCapture?: React.MouseEventHandler<HTMLElement>;
76
+ /**
77
+ * capture フェーズのキー押下ハンドラ。無効時はコンポーネント側のガードが優先される
78
+ * en: Capture-phase keydown handler. The component's disabled guard takes precedence.
79
+ */
80
+ onKeyDownCapture?: React.KeyboardEventHandler<HTMLElement>;
81
+ /**
82
+ * capture フェーズの中クリックハンドラ。無効時はコンポーネント側のガードが優先される
83
+ * en: Capture-phase auxclick handler. The component's disabled guard takes precedence.
84
+ */
85
+ onAuxClickCapture?: React.MouseEventHandler<HTMLElement>;
64
86
  /**
65
87
  * @deprecated アクセシビリティ観点(WCAG 2.5.2 Pointer Cancellation)により、基本的に使用を避けてください。
66
88
  * en: Deprecated for accessibility reasons (WCAG 2.5.2 Pointer Cancellation). Avoid using this in most cases.
@@ -106,6 +128,10 @@ export interface ButtonProps extends Omit<NativeButtonProps, "onClick" | "onKeyD
106
128
  * en: Use `IconButton` for icon-only buttons.
107
129
  * - `asChild` 使用時は `prefixIcon` / `suffixIcon` / `isLoading` が反映されません。必要ならスロット先でアイコンやローディング表現を構成してください。
108
130
  * en: In `asChild` mode, `prefixIcon`, `suffixIcon`, and `isLoading` are ignored. Render icons and loading states inside the slotted child when needed.
131
+ * - `asChild` で差し込んだ要素が指定した props(`type` や `disabled` など)は、Slot のマージで
132
+ * コンポーネント側の値より優先されます。
133
+ * en: Props set on the slotted element itself (such as `type` or `disabled`) win over the
134
+ * component's own values through Slot's prop merging.
109
135
  *
110
136
  * ```tsx
111
137
  * // ✅ Correct
@@ -128,15 +154,54 @@ export interface ButtonProps extends Omit<NativeButtonProps, "onClick" | "onKeyD
128
154
  * <Link href="/items/new">新規作成</Link>
129
155
  * </Button>
130
156
  * ```
131
-
157
+ *
132
158
  * **アクセシビリティ / Accessibility**
133
159
  *
134
160
  * - ボタンにはアクセシブルネームが必要です(通常は `children` のテキスト)。
135
161
  * アイコンのみの場合は `aria-label` / `aria-labelledby` を付与するか、可能なら `IconButton` を使用してください。
136
162
  * - `isLoading` の場合でもアクセシブルネームは維持されます。
137
- * - `asChild` を使う場合、子要素がボタン相当のセマンティクス(role/disabled/キーボード操作)を満たすようにしてください。
163
+ * - `asChild` を使う場合、子要素がボタン相当のセマンティクス(role/キーボード操作)を満たすようにしてください。
164
+ * - `asChild` で `<a>` など button 以外の要素を差し込んで無効化した場合、`aria-disabled` の付与、
165
+ * click / auxclick / Enter・Space の抑止、`aria-disabled:` プレフィックスによる無効時の配色まで
166
+ * このコンポーネントが行います(`data-disabled="true"` も利用側のスタイルフックとして出力)。
167
+ * 差し込み先が native の `<button>` の場合は `disabled` 属性がそのまま渡ります。
168
+ * - `type` / `form` / `value` など button 専用の props は、差し込み先が native の `<button>` の
169
+ * ときだけ転送されます。それ以外の要素では不正な属性になるため落とし、dev ビルドで警告します。
170
+ * 差し込み先が内部で `<button>` を描画するコンポーネントの場合のみ、その要素側に直接指定してください
171
+ * (Slot のマージで子の指定が優先されます)。`<a>` 等では属性自体が機能しないため指定不要です。
172
+ * en: Button-only props such as `type`, `form`, and `value` are forwarded only when the slot is a
173
+ * native `<button>`; on other elements they would be invalid attributes, so they are dropped with
174
+ * a dev warning. Set them on the slotted element only when that component renders a `<button>`
175
+ * internally (child props win in Slot's merge) — on `<a>` and friends the attributes do nothing.
176
+ * - `aria-disabled` を直接渡した場合も、無効時の配色が当たり操作が抑止されます(native の
177
+ * `disabled` 属性は付けないため、フォーカスは残ります)。無効化には基本的に `isDisabled` を
178
+ * 使ってください。
179
+ * en: Passing `aria-disabled` directly also applies the disabled colors and blocks activation
180
+ * (the native `disabled` attribute is not set, so the element stays focusable). Prefer
181
+ * `isDisabled` for disabling.
182
+ * なお `aria-disabled` の要素は既定でフォーカス可能なままです。無効な項目の存在と理由を
183
+ * 支援技術の利用者に伝えられるため通常はそのままで構いません。タブ順から外す必要がある場合のみ
184
+ * 差し込む要素側で `tabIndex={-1}` を指定してください。
185
+ * en: When disabled with `asChild` and a non-button element such as `<a>`, this component sets
186
+ * `aria-disabled`, blocks click / auxclick / Enter / Space, and applies the disabled colors via
187
+ * `aria-disabled:`-prefixed utilities (`data-disabled="true"` is also emitted as a styling hook).
188
+ * A slotted native `<button>` receives the real `disabled` attribute instead.
189
+ * - native の `<button>` かどうかは差し込んだ要素そのもので判定するため、内部で `<button>` を
190
+ * 描画するカスタムコンポーネントを渡した場合は非 button として扱われます。
191
+ * また無効時に抑止できるのは click / auxclick / Enter・Space までで、コンテキストメニューの
192
+ * 「新しいタブで開く」は止められません。確実に遷移させたくない場合は差し込む要素側で
193
+ * `href` を外してください。
194
+ * en: Whether the slot is a native `<button>` is decided from the slotted element itself, so a
195
+ * custom component that renders a `<button>` internally is treated as a non-button. Also, only
196
+ * click / auxclick / Enter / Space can be blocked while disabled — "open in new tab" from the
197
+ * context menu cannot. Drop `href` on the slotted element when navigation must not happen.
198
+ * An `aria-disabled` element stays focusable by design, which is usually what you want; set
199
+ * `tabIndex={-1}` on the slotted element only when it must leave the tab order.
138
200
  *
139
201
  * @param {ButtonProps} props
140
202
  */
141
- declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLElement>>;
203
+ declare function Button({ className, variant, size, theme, isLoading, isDisabled, asChild, disabled, prefixIcon, suffixIcon, ref, children, ...props }: ButtonProps): React.JSX.Element;
204
+ declare namespace Button {
205
+ var displayName: string;
206
+ }
142
207
  export { Button, buttonVariants };