@cakejp/design-system 0.22.1 → 0.23.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 (119) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/CLAUDE.md +3 -1
  3. package/MIGRATION.md +43 -0
  4. package/UPDATING.md +1 -1
  5. package/bin/check-tokens.mjs +20 -0
  6. package/contracts/components.json +87 -25
  7. package/contracts/composition.json +9 -9
  8. package/contracts/rules.json +1 -1
  9. package/contracts/screen-patterns.json +1 -1
  10. package/dist/components/ec/admin-shell.js +7 -7
  11. package/dist/components/ec/anniversary-card.js +1 -1
  12. package/dist/components/ec/chart-controls.js +7 -7
  13. package/dist/components/ec/coupon-card.js +10 -10
  14. package/dist/components/ec/delivery-calendar.js +1 -1
  15. package/dist/components/ec/mypage-shell.js +1 -1
  16. package/dist/components/ec/order-section.js +1 -1
  17. package/dist/components/ec/order-summary.js +7 -5
  18. package/dist/components/ec/product-card.js +32 -30
  19. package/dist/components/ec/product-detail-sidebar.js +1 -1
  20. package/dist/components/ec/product-list-item.js +57 -56
  21. package/dist/components/ec/product-option.js +30 -30
  22. package/dist/components/ec/review-summary.js +1 -1
  23. package/dist/components/ec/shop-card.js +7 -7
  24. package/dist/components/foundations/accordion.js +1 -1
  25. package/dist/components/foundations/alert-dialog.js +65 -43
  26. package/dist/components/foundations/alert.js +74 -68
  27. package/dist/components/foundations/badge.js +4 -4
  28. package/dist/components/foundations/button.js +15 -15
  29. package/dist/components/foundations/checkbox-card.js +18 -18
  30. package/dist/components/foundations/checkbox.js +6 -6
  31. package/dist/components/foundations/chip-variants.js +8 -8
  32. package/dist/components/foundations/data-table.js +244 -209
  33. package/dist/components/foundations/dialog.js +84 -60
  34. package/dist/components/foundations/drawer.js +61 -53
  35. package/dist/components/foundations/field.js +51 -35
  36. package/dist/components/foundations/file-input.js +1 -1
  37. package/dist/components/foundations/input.js +9 -8
  38. package/dist/components/foundations/popover.js +15 -12
  39. package/dist/components/foundations/progress.js +19 -18
  40. package/dist/components/foundations/radio-group.js +26 -23
  41. package/dist/components/foundations/select.js +9 -8
  42. package/dist/components/foundations/sheet.js +82 -59
  43. package/dist/components/foundations/skeleton.js +6 -6
  44. package/dist/components/foundations/slider.js +7 -7
  45. package/dist/components/foundations/sonner.js +9 -8
  46. package/dist/components/foundations/switch.js +3 -2
  47. package/dist/components/foundations/tabs.js +5 -5
  48. package/dist/components/foundations/textarea.js +7 -6
  49. package/dist/components/foundations/toggle-group.js +5 -5
  50. package/dist/components/primitives/admin-header.js +3 -3
  51. package/dist/components/primitives/admin-side-nav.js +101 -92
  52. package/dist/components/primitives/category-shortcuts.js +6 -6
  53. package/dist/components/primitives/chat-composer.js +1 -1
  54. package/dist/components/primitives/chip.js +25 -25
  55. package/dist/components/primitives/combobox.js +74 -63
  56. package/dist/components/primitives/content-carousel.js +64 -62
  57. package/dist/components/primitives/date-picker.js +99 -96
  58. package/dist/components/primitives/error-state.js +9 -9
  59. package/dist/components/primitives/filter-bar.js +4 -4
  60. package/dist/components/primitives/footer.js +1 -1
  61. package/dist/components/primitives/form-field.js +8 -8
  62. package/dist/components/primitives/funnel-shell.js +5 -5
  63. package/dist/components/primitives/header.js +16 -16
  64. package/dist/components/primitives/image-carousel.js +42 -41
  65. package/dist/components/primitives/image-gallery.js +61 -58
  66. package/dist/components/primitives/image-input.js +2 -2
  67. package/dist/components/primitives/image-uploader.js +1 -1
  68. package/dist/components/primitives/kebab-menu.js +20 -16
  69. package/dist/components/primitives/list-item.js +17 -17
  70. package/dist/components/primitives/menu-drawer.js +11 -11
  71. package/dist/components/primitives/multi-select.js +66 -66
  72. package/dist/components/primitives/notification-list.js +13 -13
  73. package/dist/components/primitives/number-input.js +118 -112
  74. package/dist/components/primitives/progress-steps.js +3 -3
  75. package/dist/components/primitives/search-bar.js +6 -6
  76. package/dist/components/primitives/section-nav.js +1 -1
  77. package/dist/components/primitives/side-nav.js +1 -1
  78. package/dist/components/primitives/sub-nav.js +12 -12
  79. package/dist/components/primitives/tag.js +3 -3
  80. package/dist/components/primitives/workspace-shell.js +8 -8
  81. package/dist/index.css +1 -1
  82. package/dist/index.js +1479 -704
  83. package/dist/lib/focus-restore.js +67 -0
  84. package/dist/lib/focus-ring.js +1 -1
  85. package/dist/lib/ime.js +17 -0
  86. package/dist/lib/search-normalize.js +30 -0
  87. package/dist/types/components/ec/admin-shell.d.ts +1 -1
  88. package/dist/types/components/foundations/alert-dialog.d.ts +2 -2
  89. package/dist/types/components/foundations/alert.d.ts +14 -1
  90. package/dist/types/components/foundations/card.d.ts +3 -3
  91. package/dist/types/components/foundations/confirm-dialog.d.ts +3 -3
  92. package/dist/types/components/foundations/data-table.d.ts +1 -1
  93. package/dist/types/components/foundations/dialog.d.ts +2 -2
  94. package/dist/types/components/foundations/drawer.d.ts +1 -1
  95. package/dist/types/components/foundations/field.d.ts +23 -3
  96. package/dist/types/components/foundations/popover.d.ts +1 -1
  97. package/dist/types/components/foundations/sheet.d.ts +4 -3
  98. package/dist/types/components/foundations/sonner.d.ts +3 -2
  99. package/dist/types/components/primitives/admin-side-nav.d.ts +2 -0
  100. package/dist/types/components/primitives/combobox.d.ts +6 -0
  101. package/dist/types/components/primitives/date-picker.d.ts +8 -3
  102. package/dist/types/components/primitives/funnel-shell.d.ts +1 -1
  103. package/dist/types/components/primitives/kebab-menu.d.ts +10 -1
  104. package/dist/types/components/primitives/number-input.d.ts +20 -1
  105. package/dist/types/components/primitives/progress-steps.d.ts +1 -1
  106. package/dist/types/components/primitives/section.d.ts +1 -1
  107. package/dist/types/components/primitives/workspace-shell.d.ts +2 -2
  108. package/dist/types/index.d.ts +3 -4
  109. package/dist/types/lib/focus-restore.d.ts +52 -0
  110. package/dist/types/lib/focus-ring.d.ts +3 -0
  111. package/dist/types/lib/ime.d.ts +36 -0
  112. package/dist/types/lib/search-normalize.d.ts +28 -0
  113. package/package.json +3 -1
  114. package/src/components/COMPONENT_LOOKUP.md +12 -12
  115. package/src/preset-standalone.css +43 -21
  116. package/src/preset.css +36 -18
  117. package/src/styles/primitive.css +1 -0
  118. package/src/styles/semantic.css +12 -2
  119. package/tokens.json +22 -3
@@ -15,36 +15,36 @@ const h = "forced-colors:data-[selected]:bg-[Highlight] forced-colors:data-[sele
15
15
  "name",
16
16
  "value"
17
17
  ]);
18
- function y(o) {
19
- return Object.fromEntries(Object.entries(o).filter(([n]) => !F.has(n)));
18
+ function y(r) {
19
+ return Object.fromEntries(Object.entries(r).filter(([n]) => !F.has(n)));
20
20
  }
21
21
  function V({
22
- className: o,
22
+ className: r,
23
23
  variant: n = "filled",
24
24
  size: c,
25
25
  shape: d,
26
- href: r,
26
+ href: o,
27
27
  selected: a = !1,
28
28
  soldOut: T = !1,
29
- removable: E = !1,
30
- onRemove: S,
31
- removeLabel: N = "削除",
29
+ removable: N = !1,
30
+ onRemove: E,
31
+ removeLabel: S = "削除",
32
32
  count: b,
33
33
  linkComponent: C,
34
- children: f,
34
+ children: u,
35
35
  ...t
36
36
  }) {
37
- const p = C ?? "a", u = a ? "selected" : n, e = T && !a, g = e ? "border border-[var(--Text-Disable)] bg-[var(--Surface-Secondary)] text-[var(--Text-Disable)]" : void 0, m = b !== void 0 && /* @__PURE__ */ i(
37
+ const p = C ?? "a", f = a ? "selected" : n, e = T && !a, g = e ? "border border-[var(--Text-Disable)] bg-[var(--Surface-Neutral-Secondary)] text-[var(--Text-Disable)]" : void 0, m = b !== void 0 && /* @__PURE__ */ i(
38
38
  "span",
39
39
  {
40
40
  className: l(
41
41
  "inline-flex items-center justify-center rounded-full px-1.5 min-w-[1.25rem] typo-label-xs transition-colors",
42
- a ? "bg-[var(--Surface-Primary)] text-[var(--Text-High-Emphasis)]" : "bg-[var(--Surface-Tertiary)] text-[var(--Text-Medium-Emphasis)]"
42
+ a ? "bg-[var(--Surface-Primary)] text-[var(--Text-High-Emphasis)]" : "bg-[var(--Surface-Neutral-Tertiary)] text-[var(--Text-Medium-Emphasis)]"
43
43
  ),
44
44
  children: b
45
45
  }
46
46
  ), x = e && /* @__PURE__ */ i("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ i("div", { className: "h-[67px] w-px origin-center rotate-45 bg-[var(--Text-Disable)]" }) });
47
- if (E)
47
+ if (N)
48
48
  return /* @__PURE__ */ s(
49
49
  "span",
50
50
  {
@@ -52,24 +52,24 @@ function V({
52
52
  "data-selected": a || void 0,
53
53
  className: l(
54
54
  "group",
55
- v({ variant: u, size: c, shape: d }),
55
+ v({ variant: f, size: c, shape: d }),
56
56
  e ? g : void 0,
57
57
  e && "relative",
58
58
  "has-[[data-slot=chip-trigger]:focus-visible]:ring-2 has-[[data-slot=chip-trigger]:focus-visible]:ring-[var(--Focus-High-Emphasis)]",
59
59
  h,
60
60
  D,
61
- o
61
+ r
62
62
  ),
63
63
  children: [
64
- r ? /* @__PURE__ */ s(
64
+ o ? /* @__PURE__ */ s(
65
65
  p,
66
66
  {
67
- href: r,
67
+ href: o,
68
68
  "data-slot": "chip-trigger",
69
69
  className: "inline-flex items-center gap-1.5 focus-visible:outline-none",
70
70
  ...y(t),
71
71
  children: [
72
- f,
72
+ u,
73
73
  m
74
74
  ]
75
75
  }
@@ -82,7 +82,7 @@ function V({
82
82
  className: "inline-flex items-center gap-1.5 focus-visible:outline-none",
83
83
  ...t,
84
84
  children: [
85
- f,
85
+ u,
86
86
  m
87
87
  ]
88
88
  }
@@ -93,10 +93,10 @@ function V({
93
93
  {
94
94
  type: "button",
95
95
  "data-slot": "chip-remove",
96
- "aria-label": N,
96
+ "aria-label": S,
97
97
  disabled: e || t.disabled,
98
98
  onClick: (j) => {
99
- j.stopPropagation(), S?.();
99
+ j.stopPropagation(), E?.();
100
100
  },
101
101
  className: "-mr-1 ml-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-full hover:bg-[var(--Overlay-Light)] focus-visible:ring-2 focus-visible:ring-[var(--Focus-High-Emphasis)]",
102
102
  children: /* @__PURE__ */ i(_, { className: "size-3.5" })
@@ -106,17 +106,17 @@ function V({
106
106
  }
107
107
  );
108
108
  const O = /* @__PURE__ */ s(R, { children: [
109
- f,
109
+ u,
110
110
  m,
111
111
  x
112
112
  ] });
113
- return r ? /* @__PURE__ */ i(
113
+ return o ? /* @__PURE__ */ i(
114
114
  p,
115
115
  {
116
- href: r,
116
+ href: o,
117
117
  "data-slot": "chip",
118
118
  "data-selected": a || void 0,
119
- className: l("group", v({ variant: u, size: c, shape: d }), g, h, o),
119
+ className: l("group", v({ variant: f, size: c, shape: d }), g, h, r),
120
120
  ...y(t),
121
121
  children: O
122
122
  }
@@ -129,11 +129,11 @@ function V({
129
129
  disabled: e || t.disabled,
130
130
  className: l(
131
131
  "group",
132
- v({ variant: u, size: c, shape: d }),
132
+ v({ variant: f, size: c, shape: d }),
133
133
  e ? g : void 0,
134
134
  e && "relative",
135
135
  h,
136
- o
136
+ r
137
137
  ),
138
138
  ...t,
139
139
  children: O
@@ -1,60 +1,62 @@
1
1
  "use client";
2
- import { jsxs as r, jsx as e } from "react/jsx-runtime";
3
- import * as N from "react";
4
- import { ChevronsUpDown as w, Check as T } from "lucide-react";
5
- import { cn as f } from "../../lib/utils.js";
6
- import { Button as j } from "../foundations/button.js";
7
- import { Command as E, CommandInput as O, CommandList as k, CommandEmpty as P, CommandGroup as S, CommandItem as A } from "../foundations/command.js";
8
- import { Popover as H, PopoverTrigger as I, PopoverContent as B } from "../foundations/popover.js";
9
- import { useFieldLabelling as F, resolveFieldAria as G } from "../../lib/field-labelling.js";
10
- import { HIGH_CONTRAST_OUTLINE as L } from "../../lib/high-contrast.js";
11
- function Q({
12
- options: n,
13
- value: i,
14
- onValueChange: u,
15
- placeholder: t = "選択してください",
16
- searchPlaceholder: h = "検索",
17
- emptyLabel: C = "候補がありません",
18
- disabled: x,
19
- className: y,
20
- id: d,
21
- "aria-invalid": s,
22
- "aria-describedby": c,
23
- "aria-label": l,
24
- "aria-labelledby": o
2
+ import { jsxs as d, jsx as a } from "react/jsx-runtime";
3
+ import * as g from "react";
4
+ import { ChevronsUpDown as P, Check as $ } from "lucide-react";
5
+ import { cn as N } from "../../lib/utils.js";
6
+ import { Button as B } from "../foundations/button.js";
7
+ import { Command as F, CommandInput as G, CommandList as R, CommandEmpty as U, CommandGroup as _, CommandItem as M } from "../foundations/command.js";
8
+ import { Popover as q, PopoverTrigger as z, PopoverContent as D } from "../foundations/popover.js";
9
+ import { useFieldLabelling as J, resolveFieldAria as K } from "../../lib/field-labelling.js";
10
+ import { HIGH_CONTRAST_OUTLINE as Q } from "../../lib/high-contrast.js";
11
+ import { matchesSearch as V } from "../../lib/search-normalize.js";
12
+ function le({
13
+ options: c,
14
+ value: s,
15
+ onValueChange: w,
16
+ placeholder: m = "選択してください",
17
+ searchPlaceholder: I = "検索",
18
+ emptyLabel: T = "候補がありません",
19
+ disabled: j,
20
+ className: k,
21
+ id: p,
22
+ "aria-invalid": u,
23
+ "aria-describedby": v,
24
+ "aria-label": i,
25
+ "aria-labelledby": r
25
26
  }) {
26
- const [m, p] = N.useState(!1), v = n.find((a) => a.value === i), b = F(), g = G(
27
+ const [f, h] = g.useState(!1), l = c.find((e) => e.value === s), o = J(), E = K(
27
28
  {
28
- id: d,
29
- "aria-label": l,
30
- "aria-labelledby": o,
31
- "aria-describedby": c,
29
+ id: p,
30
+ "aria-label": i,
31
+ "aria-labelledby": r,
32
+ "aria-describedby": v,
32
33
  // 渡さないと、利用側の明示指定が FormField 由来の値(error の有無)で上書きされる
33
- "aria-invalid": s
34
+ "aria-invalid": u
34
35
  },
35
- b
36
- );
37
- return /* @__PURE__ */ r(H, { open: m, onOpenChange: p, children: [
38
- /* @__PURE__ */ e(I, { asChild: !0, children: /* @__PURE__ */ r(
39
- j,
36
+ o
37
+ ), n = !o && !i && !r ? m : void 0, O = r ? { "aria-labelledby": r } : i ?? n ? { "aria-label": i ?? n } : o ? { "aria-labelledby": o.labelId } : {}, b = g.useId(), x = `${b}-value`, C = `${b}-name`, t = r ? void 0 : i ?? n, y = r ?? (t ? C : o?.labelId), S = l && y ? { "aria-labelledby": `${y} ${x}` } : {};
38
+ return /* @__PURE__ */ d(q, { open: f, onOpenChange: h, children: [
39
+ /* @__PURE__ */ a(z, { asChild: !0, children: /* @__PURE__ */ d(
40
+ B,
40
41
  {
41
42
  type: "button",
42
43
  variant: "tertiary",
43
44
  role: "combobox",
44
- id: d,
45
- "aria-expanded": m,
45
+ id: p,
46
+ "aria-expanded": f,
46
47
  "aria-haspopup": "listbox",
47
- "aria-invalid": s,
48
- "aria-describedby": c,
49
- "aria-label": l ?? (!b && !l && !o ? t : void 0),
50
- "aria-labelledby": o,
51
- ...g,
52
- disabled: x,
53
- className: f(
48
+ "aria-invalid": u,
49
+ "aria-describedby": v,
50
+ "aria-label": i ?? n,
51
+ "aria-labelledby": r,
52
+ ...E,
53
+ ...S,
54
+ disabled: j,
55
+ className: N(
54
56
  "w-full justify-between bg-[var(--Surface-Primary)]",
55
57
  // 高コントラスト(prefers-contrast: more / data-contrast="more")のときだけ見える内側 1px の輪郭。
56
58
  // トリガーは枠を持たず地もページ地と同色で、既定では境界が 3:1 に届かない(#301)
57
- L,
59
+ Q,
58
60
  // エラー時の赤枠。トリガーは Button tertiary(枠幅 0)なので border 色だけ変えても見えず、
59
61
  // border を足すと 1px 広がる。内側リング(inset-ring)で描いて高さを変えない。
60
62
  // inset-ring は ring(フォーカスリング)と別の box-shadow 層なので同時に表示される。
@@ -62,44 +64,53 @@ function Q({
62
64
  // forced-colors(Windows ハイコントラスト)では box-shadow が消えるため、エラー時だけ輪郭線
63
65
  // (outline。レイアウトに影響しない)で境界を出す。forced-colors 以外では効かない
64
66
  "forced-colors:aria-invalid:outline-solid forced-colors:aria-invalid:outline-1 forced-colors:aria-invalid:-outline-offset-1 forced-colors:aria-invalid:outline-[CanvasText]",
65
- y
67
+ k
66
68
  ),
67
69
  children: [
68
- /* @__PURE__ */ e("span", { className: v ? "text-[var(--Text-High-Emphasis)]" : "text-[var(--Text-Low-Emphasis)]", children: v?.label ?? t }),
69
- /* @__PURE__ */ e(w, { "aria-hidden": "true", className: "text-[var(--Object-Medium-Emphasis)]" })
70
+ /* @__PURE__ */ a(
71
+ "span",
72
+ {
73
+ id: l ? x : void 0,
74
+ className: l ? "text-[var(--Text-High-Emphasis)]" : "text-[var(--Text-Low-Emphasis)]",
75
+ children: l?.label ?? m
76
+ }
77
+ ),
78
+ l && t && /* @__PURE__ */ a("span", { id: C, hidden: !0, children: t }),
79
+ /* @__PURE__ */ a(P, { "aria-hidden": "true", className: "text-[var(--Object-Medium-Emphasis)]" })
70
80
  ]
71
81
  }
72
82
  ) }),
73
- /* @__PURE__ */ e(B, { align: "start", className: "w-[var(--radix-popover-trigger-width)] p-0", children: /* @__PURE__ */ r(E, { children: [
74
- /* @__PURE__ */ e(O, { placeholder: h }),
75
- /* @__PURE__ */ r(k, { children: [
76
- /* @__PURE__ */ e(P, { children: C }),
77
- /* @__PURE__ */ e(S, { children: n.map((a) => /* @__PURE__ */ r(
78
- A,
83
+ /* @__PURE__ */ a(D, { align: "start", className: "w-[var(--radix-popover-trigger-width)] p-0", ...O, children: /* @__PURE__ */ d(F, { filter: (e, A, H) => V(H ?? [e], A) ? 1 : 0, children: [
84
+ /* @__PURE__ */ a(G, { placeholder: I }),
85
+ /* @__PURE__ */ d(R, { children: [
86
+ /* @__PURE__ */ a(U, { children: T }),
87
+ /* @__PURE__ */ a(_, { children: c.map((e) => /* @__PURE__ */ d(
88
+ M,
79
89
  {
80
- value: [a.label, ...a.keywords ?? []].join(" "),
81
- disabled: a.disabled,
90
+ value: [e.label, ...e.keywords ?? []].join(" "),
91
+ keywords: [e.label, ...e.keywords ?? []],
92
+ disabled: e.disabled,
82
93
  onSelect: () => {
83
- u?.(a.value), p(!1);
94
+ w?.(e.value), h(!1);
84
95
  },
85
96
  children: [
86
- /* @__PURE__ */ e(
87
- T,
97
+ /* @__PURE__ */ a(
98
+ $,
88
99
  {
89
100
  "aria-hidden": "true",
90
- className: f(a.value === i ? "opacity-100" : "opacity-0")
101
+ className: N(e.value === s ? "opacity-100" : "opacity-0")
91
102
  }
92
103
  ),
93
- a.label,
94
- a.value === i && /* @__PURE__ */ e("span", { className: "sr-only", children: "選択済み" })
104
+ e.label,
105
+ e.value === s && /* @__PURE__ */ a("span", { className: "sr-only", children: "選択済み" })
95
106
  ]
96
107
  },
97
- a.value
108
+ e.value
98
109
  )) })
99
110
  ] })
100
111
  ] }) })
101
112
  ] });
102
113
  }
103
114
  export {
104
- Q as Combobox
115
+ le as Combobox
105
116
  };
@@ -1,42 +1,43 @@
1
1
  "use client";
2
- import { jsxs as w, jsx as n, Fragment as j } from "react/jsx-runtime";
2
+ import { jsxs as w, jsx as n, Fragment as T } from "react/jsx-runtime";
3
3
  import * as s from "react";
4
- import O from "iconsax-reactjs/dist/esm/ArrowLeft2.js";
5
- import R from "iconsax-reactjs/dist/esm/ArrowRight2.js";
6
- import { cn as f } from "../../lib/utils.js";
7
- import { usePrefersReducedMotion as F } from "../../lib/use-prefers-reduced-motion.js";
8
- const W = {
4
+ import j from "iconsax-reactjs/dist/esm/ArrowLeft2.js";
5
+ import F from "iconsax-reactjs/dist/esm/ArrowRight2.js";
6
+ import { cn as d } from "../../lib/utils.js";
7
+ import { FOCUS_RING_ONLY as v } from "../../lib/focus-ring.js";
8
+ import { usePrefersReducedMotion as W } from "../../lib/use-prefers-reduced-motion.js";
9
+ const $ = {
9
10
  1: "@[960px]:w-full",
10
11
  2: "@[960px]:w-[calc((100%-16px)/2)]",
11
12
  3: "@[960px]:w-[calc((100%-32px)/3)]",
12
13
  4: "@[960px]:w-[calc((100%-48px)/4)]"
13
14
  };
14
- function _({
15
+ function D({
15
16
  slides: p,
16
17
  showDots: E = !0,
17
18
  showArrows: I = !0,
18
19
  autoPlay: m = 0,
19
- peek: v = !1,
20
- itemsPerView: b = 1,
21
- ariaLabel: N = "コンテンツカルーセル",
22
- className: S,
23
- ...L
20
+ peek: b = !1,
21
+ itemsPerView: y = 1,
22
+ ariaLabel: S = "コンテンツカルーセル",
23
+ className: L,
24
+ ...z
24
25
  }) {
25
- const i = s.useRef(null), [c, z] = s.useState(0), l = F(), r = p.length;
26
+ const l = s.useRef(null), [i, A] = s.useState(0), c = W(), r = p.length;
26
27
  s.useEffect(() => {
27
- const e = i.current;
28
+ const e = l.current;
28
29
  if (!e) return;
29
30
  let t = 0;
30
31
  const o = () => {
31
32
  cancelAnimationFrame(t), t = requestAnimationFrame(() => {
32
- const u = Array.from(
33
+ const f = Array.from(
33
34
  e.querySelectorAll("[data-slide]")
34
- ), M = u[0]?.offsetLeft ?? 0;
35
- let g = 0, y = Number.POSITIVE_INFINITY;
36
- u.forEach((k, T) => {
37
- const C = Math.abs(k.offsetLeft - M - e.scrollLeft);
38
- C < y && (y = C, g = T);
39
- }), z(g);
35
+ ), O = f[0]?.offsetLeft ?? 0;
36
+ let g = 0, N = Number.POSITIVE_INFINITY;
37
+ f.forEach((k, R) => {
38
+ const C = Math.abs(k.offsetLeft - O - e.scrollLeft);
39
+ C < N && (N = C, g = R);
40
+ }), A(g);
40
41
  });
41
42
  };
42
43
  o(), e.addEventListener("scroll", o, { passive: !0 });
@@ -45,37 +46,37 @@ function _({
45
46
  cancelAnimationFrame(t), e.removeEventListener("scroll", o), a?.disconnect();
46
47
  };
47
48
  }, [r]);
48
- const d = s.useCallback(
49
+ const u = s.useCallback(
49
50
  (e) => {
50
- const t = i.current;
51
+ const t = l.current;
51
52
  if (!t) return;
52
53
  const o = t.children[e], a = t.children[0];
53
54
  o && a && t.scrollTo({
54
55
  left: o.offsetLeft - a.offsetLeft,
55
- behavior: l ? "auto" : "smooth"
56
+ behavior: c ? "auto" : "smooth"
56
57
  });
57
58
  },
58
- [l]
59
- ), h = s.useCallback(() => {
60
- const e = i.current, t = e?.children[0], o = e?.children[1];
59
+ [c]
60
+ ), x = s.useCallback(() => {
61
+ const e = l.current, t = e?.children[0], o = e?.children[1];
61
62
  if (!e || !t || !o) return 1;
62
63
  const a = o.offsetLeft - t.offsetLeft;
63
64
  if (a <= 0) return 1;
64
- const u = a - t.offsetWidth;
65
- return Math.max(1, Math.floor((e.clientWidth + u + 1) / a));
66
- }, []), x = s.useCallback(() => {
67
- const e = i.current, t = e ? e.scrollLeft >= e.scrollWidth - e.clientWidth - 1 : !1;
68
- d(
69
- c >= r - 1 || t ? 0 : Math.min(c + h(), r - 1)
65
+ const f = a - t.offsetWidth;
66
+ return Math.max(1, Math.floor((e.clientWidth + f + 1) / a));
67
+ }, []), h = s.useCallback(() => {
68
+ const e = l.current, t = e ? e.scrollLeft >= e.scrollWidth - e.clientWidth - 1 : !1;
69
+ u(
70
+ i >= r - 1 || t ? 0 : Math.min(i + x(), r - 1)
70
71
  );
71
- }, [c, r, d, h]);
72
+ }, [i, r, u, x]);
72
73
  s.useEffect(() => {
73
- if (l || m <= 0 || r <= 1) return;
74
- const e = setInterval(x, m);
74
+ if (c || m <= 0 || r <= 1) return;
75
+ const e = setInterval(h, m);
75
76
  return () => clearInterval(e);
76
- }, [m, r, l, x]);
77
- function A() {
78
- d(c <= 0 ? r - 1 : Math.max(0, c - h()));
77
+ }, [m, r, c, h]);
78
+ function M() {
79
+ u(i <= 0 ? r - 1 : Math.max(0, i - x()));
79
80
  }
80
81
  return r === 0 ? null : /* @__PURE__ */ w(
81
82
  "div",
@@ -83,21 +84,21 @@ function _({
83
84
  "data-slot": "content-carousel",
84
85
  role: "region",
85
86
  "aria-roledescription": "carousel",
86
- "aria-label": N,
87
- className: f("@container group/carousel relative", S),
88
- ...L,
87
+ "aria-label": S,
88
+ className: d("@container group/carousel relative", L),
89
+ ...z,
89
90
  children: [
90
91
  /* @__PURE__ */ n(
91
92
  "div",
92
93
  {
93
- ref: i,
94
- className: f(
95
- "flex snap-x snap-mandatory overflow-x-auto scroll-smooth motion-reduce:scroll-auto scrollbar-none",
94
+ ref: l,
95
+ className: d(
96
+ "flex snap-x snap-mandatory overflow-x-auto scroll-smooth motion-reduce:scroll-auto scrollbar-hide",
96
97
  // peek: 端の余白 = Container の gutter(外に置いたときは 16px)。Container の中では
97
98
  // gutter 分だけ外へはみ出して画面端までスクロールさせる。scroll-padding も同じ幅にして、
98
99
  // スナップ後も端の余白が消えないようにする。PC (@[960px]:) では peek しないので外す
99
- v && "-mx-[var(--Container-Gutter,0px)] gap-3 px-[var(--Container-Gutter,16px)] scroll-px-[var(--Container-Gutter,16px)] @[960px]:mx-0 @[960px]:gap-0 @[960px]:px-0 @[960px]:scroll-px-0",
100
- b > 1 && "@[960px]:gap-4"
100
+ b && "-mx-[var(--Container-Gutter,0px)] gap-3 px-[var(--Container-Gutter,16px)] scroll-px-[var(--Container-Gutter,16px)] @[960px]:mx-0 @[960px]:gap-0 @[960px]:px-0 @[960px]:scroll-px-0",
101
+ y > 1 && "@[960px]:gap-4"
101
102
  ),
102
103
  style: { scrollbarWidth: "none", msOverflowStyle: "none" },
103
104
  children: p.map((e, t) => /* @__PURE__ */ n(
@@ -108,11 +109,11 @@ function _({
108
109
  role: "group",
109
110
  "aria-roledescription": "スライド",
110
111
  "aria-label": `${t + 1} / ${r}`,
111
- className: f(
112
+ className: d(
112
113
  "shrink-0 snap-start",
113
114
  // peek: 端の余白 16px のとき、カード幅は導入前(全幅に置いた場合)と同じ「全幅 - 76px」
114
- v ? "w-[calc(100%-44px)]" : "w-full",
115
- W[b]
115
+ b ? "w-[calc(100%-44px)]" : "w-full",
116
+ $[y]
116
117
  ),
117
118
  children: e
118
119
  },
@@ -120,25 +121,25 @@ function _({
120
121
  ))
121
122
  }
122
123
  ),
123
- I && r > 1 && /* @__PURE__ */ w(j, { children: [
124
+ I && r > 1 && /* @__PURE__ */ w(T, { children: [
124
125
  /* @__PURE__ */ n(
125
126
  "button",
126
127
  {
127
128
  type: "button",
128
- onClick: A,
129
+ onClick: M,
129
130
  "aria-label": "前へ",
130
- className: "absolute left-2 top-1/2 z-10 hidden size-10 -translate-y-1/2 items-center justify-center rounded-full border border-[var(--Border-Control,var(--Border-Medium-Emphasis))] bg-[var(--Surface-Secondary)] shadow-md transition-opacity hover:bg-[var(--Surface-Tertiary)] @md:flex @[960px]:opacity-0 @[960px]:group-hover/carousel:opacity-100",
131
- children: /* @__PURE__ */ n(O, { size: 20, className: "text-[var(--Object-High-Emphasis)]" })
131
+ className: `absolute left-2 top-1/2 z-10 hidden size-10 -translate-y-1/2 items-center justify-center rounded-full border border-[var(--Border-Control,var(--Border-Medium-Emphasis))] bg-[var(--Surface-Neutral-Secondary)] shadow-md transition-opacity hover:bg-[var(--Surface-Neutral-Tertiary)] @md:flex @[960px]:opacity-0 @[960px]:group-hover/carousel:opacity-100 @[960px]:focus-visible:opacity-100 focus-visible:outline-none ${v}`,
132
+ children: /* @__PURE__ */ n(j, { size: 20, className: "text-[var(--Object-High-Emphasis)]" })
132
133
  }
133
134
  ),
134
135
  /* @__PURE__ */ n(
135
136
  "button",
136
137
  {
137
138
  type: "button",
138
- onClick: x,
139
+ onClick: h,
139
140
  "aria-label": "次へ",
140
- className: "absolute right-2 top-1/2 z-10 hidden size-10 -translate-y-1/2 items-center justify-center rounded-full border border-[var(--Border-Control,var(--Border-Medium-Emphasis))] bg-[var(--Surface-Secondary)] shadow-md transition-opacity hover:bg-[var(--Surface-Tertiary)] @md:flex @[960px]:opacity-0 @[960px]:group-hover/carousel:opacity-100",
141
- children: /* @__PURE__ */ n(R, { size: 20, className: "text-[var(--Object-High-Emphasis)]" })
141
+ className: `absolute right-2 top-1/2 z-10 hidden size-10 -translate-y-1/2 items-center justify-center rounded-full border border-[var(--Border-Control,var(--Border-Medium-Emphasis))] bg-[var(--Surface-Neutral-Secondary)] shadow-md transition-opacity hover:bg-[var(--Surface-Neutral-Tertiary)] @md:flex @[960px]:opacity-0 @[960px]:group-hover/carousel:opacity-100 @[960px]:focus-visible:opacity-100 focus-visible:outline-none ${v}`,
142
+ children: /* @__PURE__ */ n(F, { size: 20, className: "text-[var(--Object-High-Emphasis)]" })
142
143
  }
143
144
  )
144
145
  ] }),
@@ -146,12 +147,13 @@ function _({
146
147
  "button",
147
148
  {
148
149
  type: "button",
149
- onClick: () => d(t),
150
+ onClick: () => u(t),
150
151
  "aria-label": `スライド ${t + 1}`,
151
- className: f(
152
+ className: d(
152
153
  // shrink-0 必須: 空要素なので min-content 幅が 0、既定の flex-shrink:1 だとドットが消える
153
- "size-2 shrink-0 rounded-full transition-colors",
154
- t === c ? "bg-[var(--Text-High-Emphasis)]" : "bg-[var(--Surface-Tertiary)]"
154
+ "size-2 shrink-0 rounded-full transition-colors focus-visible:outline-none",
155
+ v,
156
+ t === i ? "bg-[var(--Text-High-Emphasis)]" : "bg-[var(--Surface-Neutral-Tertiary)]"
155
157
  )
156
158
  },
157
159
  t
@@ -161,5 +163,5 @@ function _({
161
163
  );
162
164
  }
163
165
  export {
164
- _ as ContentCarousel
166
+ D as ContentCarousel
165
167
  };