@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.
- package/CHANGELOG.md +82 -0
- package/CLAUDE.md +3 -1
- package/MIGRATION.md +43 -0
- package/UPDATING.md +1 -1
- package/bin/check-tokens.mjs +20 -0
- package/contracts/components.json +87 -25
- package/contracts/composition.json +9 -9
- package/contracts/rules.json +1 -1
- package/contracts/screen-patterns.json +1 -1
- package/dist/components/ec/admin-shell.js +7 -7
- package/dist/components/ec/anniversary-card.js +1 -1
- package/dist/components/ec/chart-controls.js +7 -7
- package/dist/components/ec/coupon-card.js +10 -10
- package/dist/components/ec/delivery-calendar.js +1 -1
- package/dist/components/ec/mypage-shell.js +1 -1
- package/dist/components/ec/order-section.js +1 -1
- package/dist/components/ec/order-summary.js +7 -5
- package/dist/components/ec/product-card.js +32 -30
- package/dist/components/ec/product-detail-sidebar.js +1 -1
- package/dist/components/ec/product-list-item.js +57 -56
- package/dist/components/ec/product-option.js +30 -30
- package/dist/components/ec/review-summary.js +1 -1
- package/dist/components/ec/shop-card.js +7 -7
- package/dist/components/foundations/accordion.js +1 -1
- package/dist/components/foundations/alert-dialog.js +65 -43
- package/dist/components/foundations/alert.js +74 -68
- package/dist/components/foundations/badge.js +4 -4
- package/dist/components/foundations/button.js +15 -15
- package/dist/components/foundations/checkbox-card.js +18 -18
- package/dist/components/foundations/checkbox.js +6 -6
- package/dist/components/foundations/chip-variants.js +8 -8
- package/dist/components/foundations/data-table.js +244 -209
- package/dist/components/foundations/dialog.js +84 -60
- package/dist/components/foundations/drawer.js +61 -53
- package/dist/components/foundations/field.js +51 -35
- package/dist/components/foundations/file-input.js +1 -1
- package/dist/components/foundations/input.js +9 -8
- package/dist/components/foundations/popover.js +15 -12
- package/dist/components/foundations/progress.js +19 -18
- package/dist/components/foundations/radio-group.js +26 -23
- package/dist/components/foundations/select.js +9 -8
- package/dist/components/foundations/sheet.js +82 -59
- package/dist/components/foundations/skeleton.js +6 -6
- package/dist/components/foundations/slider.js +7 -7
- package/dist/components/foundations/sonner.js +9 -8
- package/dist/components/foundations/switch.js +3 -2
- package/dist/components/foundations/tabs.js +5 -5
- package/dist/components/foundations/textarea.js +7 -6
- package/dist/components/foundations/toggle-group.js +5 -5
- package/dist/components/primitives/admin-header.js +3 -3
- package/dist/components/primitives/admin-side-nav.js +101 -92
- package/dist/components/primitives/category-shortcuts.js +6 -6
- package/dist/components/primitives/chat-composer.js +1 -1
- package/dist/components/primitives/chip.js +25 -25
- package/dist/components/primitives/combobox.js +74 -63
- package/dist/components/primitives/content-carousel.js +64 -62
- package/dist/components/primitives/date-picker.js +99 -96
- package/dist/components/primitives/error-state.js +9 -9
- package/dist/components/primitives/filter-bar.js +4 -4
- package/dist/components/primitives/footer.js +1 -1
- package/dist/components/primitives/form-field.js +8 -8
- package/dist/components/primitives/funnel-shell.js +5 -5
- package/dist/components/primitives/header.js +16 -16
- package/dist/components/primitives/image-carousel.js +42 -41
- package/dist/components/primitives/image-gallery.js +61 -58
- package/dist/components/primitives/image-input.js +2 -2
- package/dist/components/primitives/image-uploader.js +1 -1
- package/dist/components/primitives/kebab-menu.js +20 -16
- package/dist/components/primitives/list-item.js +17 -17
- package/dist/components/primitives/menu-drawer.js +11 -11
- package/dist/components/primitives/multi-select.js +66 -66
- package/dist/components/primitives/notification-list.js +13 -13
- package/dist/components/primitives/number-input.js +118 -112
- package/dist/components/primitives/progress-steps.js +3 -3
- package/dist/components/primitives/search-bar.js +6 -6
- package/dist/components/primitives/section-nav.js +1 -1
- package/dist/components/primitives/side-nav.js +1 -1
- package/dist/components/primitives/sub-nav.js +12 -12
- package/dist/components/primitives/tag.js +3 -3
- package/dist/components/primitives/workspace-shell.js +8 -8
- package/dist/index.css +1 -1
- package/dist/index.js +1479 -704
- package/dist/lib/focus-restore.js +67 -0
- package/dist/lib/focus-ring.js +1 -1
- package/dist/lib/ime.js +17 -0
- package/dist/lib/search-normalize.js +30 -0
- package/dist/types/components/ec/admin-shell.d.ts +1 -1
- package/dist/types/components/foundations/alert-dialog.d.ts +2 -2
- package/dist/types/components/foundations/alert.d.ts +14 -1
- package/dist/types/components/foundations/card.d.ts +3 -3
- package/dist/types/components/foundations/confirm-dialog.d.ts +3 -3
- package/dist/types/components/foundations/data-table.d.ts +1 -1
- package/dist/types/components/foundations/dialog.d.ts +2 -2
- package/dist/types/components/foundations/drawer.d.ts +1 -1
- package/dist/types/components/foundations/field.d.ts +23 -3
- package/dist/types/components/foundations/popover.d.ts +1 -1
- package/dist/types/components/foundations/sheet.d.ts +4 -3
- package/dist/types/components/foundations/sonner.d.ts +3 -2
- package/dist/types/components/primitives/admin-side-nav.d.ts +2 -0
- package/dist/types/components/primitives/combobox.d.ts +6 -0
- package/dist/types/components/primitives/date-picker.d.ts +8 -3
- package/dist/types/components/primitives/funnel-shell.d.ts +1 -1
- package/dist/types/components/primitives/kebab-menu.d.ts +10 -1
- package/dist/types/components/primitives/number-input.d.ts +20 -1
- package/dist/types/components/primitives/progress-steps.d.ts +1 -1
- package/dist/types/components/primitives/section.d.ts +1 -1
- package/dist/types/components/primitives/workspace-shell.d.ts +2 -2
- package/dist/types/index.d.ts +3 -4
- package/dist/types/lib/focus-restore.d.ts +52 -0
- package/dist/types/lib/focus-ring.d.ts +3 -0
- package/dist/types/lib/ime.d.ts +36 -0
- package/dist/types/lib/search-normalize.d.ts +28 -0
- package/package.json +3 -1
- package/src/components/COMPONENT_LOOKUP.md +12 -12
- package/src/preset-standalone.css +43 -21
- package/src/preset.css +36 -18
- package/src/styles/primitive.css +1 -0
- package/src/styles/semantic.css +12 -2
- 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(
|
|
19
|
-
return Object.fromEntries(Object.entries(
|
|
18
|
+
function y(r) {
|
|
19
|
+
return Object.fromEntries(Object.entries(r).filter(([n]) => !F.has(n)));
|
|
20
20
|
}
|
|
21
21
|
function V({
|
|
22
|
-
className:
|
|
22
|
+
className: r,
|
|
23
23
|
variant: n = "filled",
|
|
24
24
|
size: c,
|
|
25
25
|
shape: d,
|
|
26
|
-
href:
|
|
26
|
+
href: o,
|
|
27
27
|
selected: a = !1,
|
|
28
28
|
soldOut: T = !1,
|
|
29
|
-
removable:
|
|
30
|
-
onRemove:
|
|
31
|
-
removeLabel:
|
|
29
|
+
removable: N = !1,
|
|
30
|
+
onRemove: E,
|
|
31
|
+
removeLabel: S = "削除",
|
|
32
32
|
count: b,
|
|
33
33
|
linkComponent: C,
|
|
34
|
-
children:
|
|
34
|
+
children: u,
|
|
35
35
|
...t
|
|
36
36
|
}) {
|
|
37
|
-
const p = C ?? "a",
|
|
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 (
|
|
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:
|
|
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
|
-
|
|
61
|
+
r
|
|
62
62
|
),
|
|
63
63
|
children: [
|
|
64
|
-
|
|
64
|
+
o ? /* @__PURE__ */ s(
|
|
65
65
|
p,
|
|
66
66
|
{
|
|
67
|
-
href:
|
|
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
|
-
|
|
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
|
-
|
|
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":
|
|
96
|
+
"aria-label": S,
|
|
97
97
|
disabled: e || t.disabled,
|
|
98
98
|
onClick: (j) => {
|
|
99
|
-
j.stopPropagation(),
|
|
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
|
-
|
|
109
|
+
u,
|
|
110
110
|
m,
|
|
111
111
|
x
|
|
112
112
|
] });
|
|
113
|
-
return
|
|
113
|
+
return o ? /* @__PURE__ */ i(
|
|
114
114
|
p,
|
|
115
115
|
{
|
|
116
|
-
href:
|
|
116
|
+
href: o,
|
|
117
117
|
"data-slot": "chip",
|
|
118
118
|
"data-selected": a || void 0,
|
|
119
|
-
className: l("group", v({ variant:
|
|
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:
|
|
132
|
+
v({ variant: f, size: c, shape: d }),
|
|
133
133
|
e ? g : void 0,
|
|
134
134
|
e && "relative",
|
|
135
135
|
h,
|
|
136
|
-
|
|
136
|
+
r
|
|
137
137
|
),
|
|
138
138
|
...t,
|
|
139
139
|
children: O
|
|
@@ -1,60 +1,62 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import * as
|
|
4
|
-
import { ChevronsUpDown as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { Command as
|
|
8
|
-
import { Popover as
|
|
9
|
-
import { useFieldLabelling as
|
|
10
|
-
import { HIGH_CONTRAST_OUTLINE as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"aria-
|
|
23
|
-
"aria-
|
|
24
|
-
"aria-
|
|
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 [
|
|
27
|
+
const [f, h] = g.useState(!1), l = c.find((e) => e.value === s), o = J(), E = K(
|
|
27
28
|
{
|
|
28
|
-
id:
|
|
29
|
-
"aria-label":
|
|
30
|
-
"aria-labelledby":
|
|
31
|
-
"aria-describedby":
|
|
29
|
+
id: p,
|
|
30
|
+
"aria-label": i,
|
|
31
|
+
"aria-labelledby": r,
|
|
32
|
+
"aria-describedby": v,
|
|
32
33
|
// 渡さないと、利用側の明示指定が FormField 由来の値(error の有無)で上書きされる
|
|
33
|
-
"aria-invalid":
|
|
34
|
+
"aria-invalid": u
|
|
34
35
|
},
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
|
|
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:
|
|
45
|
-
"aria-expanded":
|
|
45
|
+
id: p,
|
|
46
|
+
"aria-expanded": f,
|
|
46
47
|
"aria-haspopup": "listbox",
|
|
47
|
-
"aria-invalid":
|
|
48
|
-
"aria-describedby":
|
|
49
|
-
"aria-label":
|
|
50
|
-
"aria-labelledby":
|
|
51
|
-
...
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
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
|
-
|
|
67
|
+
k
|
|
66
68
|
),
|
|
67
69
|
children: [
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
|
|
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__ */
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
|
|
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: [
|
|
81
|
-
|
|
90
|
+
value: [e.label, ...e.keywords ?? []].join(" "),
|
|
91
|
+
keywords: [e.label, ...e.keywords ?? []],
|
|
92
|
+
disabled: e.disabled,
|
|
82
93
|
onSelect: () => {
|
|
83
|
-
|
|
94
|
+
w?.(e.value), h(!1);
|
|
84
95
|
},
|
|
85
96
|
children: [
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
|
|
97
|
+
/* @__PURE__ */ a(
|
|
98
|
+
$,
|
|
88
99
|
{
|
|
89
100
|
"aria-hidden": "true",
|
|
90
|
-
className:
|
|
101
|
+
className: N(e.value === s ? "opacity-100" : "opacity-0")
|
|
91
102
|
}
|
|
92
103
|
),
|
|
93
|
-
|
|
94
|
-
|
|
104
|
+
e.label,
|
|
105
|
+
e.value === s && /* @__PURE__ */ a("span", { className: "sr-only", children: "選択済み" })
|
|
95
106
|
]
|
|
96
107
|
},
|
|
97
|
-
|
|
108
|
+
e.value
|
|
98
109
|
)) })
|
|
99
110
|
] })
|
|
100
111
|
] }) })
|
|
101
112
|
] });
|
|
102
113
|
}
|
|
103
114
|
export {
|
|
104
|
-
|
|
115
|
+
le as Combobox
|
|
105
116
|
};
|
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as w, jsx as n, Fragment as
|
|
2
|
+
import { jsxs as w, jsx as n, Fragment as T } from "react/jsx-runtime";
|
|
3
3
|
import * as s from "react";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { cn as
|
|
7
|
-
import {
|
|
8
|
-
|
|
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:
|
|
20
|
-
itemsPerView:
|
|
21
|
-
ariaLabel:
|
|
22
|
-
className:
|
|
23
|
-
...
|
|
20
|
+
peek: b = !1,
|
|
21
|
+
itemsPerView: y = 1,
|
|
22
|
+
ariaLabel: S = "コンテンツカルーセル",
|
|
23
|
+
className: L,
|
|
24
|
+
...z
|
|
24
25
|
}) {
|
|
25
|
-
const
|
|
26
|
+
const l = s.useRef(null), [i, A] = s.useState(0), c = W(), r = p.length;
|
|
26
27
|
s.useEffect(() => {
|
|
27
|
-
const e =
|
|
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
|
|
33
|
+
const f = Array.from(
|
|
33
34
|
e.querySelectorAll("[data-slide]")
|
|
34
|
-
),
|
|
35
|
-
let g = 0,
|
|
36
|
-
|
|
37
|
-
const C = Math.abs(k.offsetLeft -
|
|
38
|
-
C <
|
|
39
|
-
}),
|
|
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
|
|
49
|
+
const u = s.useCallback(
|
|
49
50
|
(e) => {
|
|
50
|
-
const t =
|
|
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:
|
|
56
|
+
behavior: c ? "auto" : "smooth"
|
|
56
57
|
});
|
|
57
58
|
},
|
|
58
|
-
[
|
|
59
|
-
),
|
|
60
|
-
const e =
|
|
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
|
|
65
|
-
return Math.max(1, Math.floor((e.clientWidth +
|
|
66
|
-
}, []),
|
|
67
|
-
const e =
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
}, [
|
|
72
|
+
}, [i, r, u, x]);
|
|
72
73
|
s.useEffect(() => {
|
|
73
|
-
if (
|
|
74
|
-
const e = setInterval(
|
|
74
|
+
if (c || m <= 0 || r <= 1) return;
|
|
75
|
+
const e = setInterval(h, m);
|
|
75
76
|
return () => clearInterval(e);
|
|
76
|
-
}, [m, r,
|
|
77
|
-
function
|
|
78
|
-
|
|
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":
|
|
87
|
-
className:
|
|
88
|
-
...
|
|
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:
|
|
94
|
-
className:
|
|
95
|
-
"flex snap-x snap-mandatory overflow-x-auto scroll-smooth motion-reduce:scroll-auto scrollbar-
|
|
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
|
-
|
|
100
|
-
|
|
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:
|
|
112
|
+
className: d(
|
|
112
113
|
"shrink-0 snap-start",
|
|
113
114
|
// peek: 端の余白 16px のとき、カード幅は導入前(全幅に置いた場合)と同じ「全幅 - 76px」
|
|
114
|
-
|
|
115
|
-
|
|
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(
|
|
124
|
+
I && r > 1 && /* @__PURE__ */ w(T, { children: [
|
|
124
125
|
/* @__PURE__ */ n(
|
|
125
126
|
"button",
|
|
126
127
|
{
|
|
127
128
|
type: "button",
|
|
128
|
-
onClick:
|
|
129
|
+
onClick: M,
|
|
129
130
|
"aria-label": "前へ",
|
|
130
|
-
className:
|
|
131
|
-
children: /* @__PURE__ */ n(
|
|
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:
|
|
139
|
+
onClick: h,
|
|
139
140
|
"aria-label": "次へ",
|
|
140
|
-
className:
|
|
141
|
-
children: /* @__PURE__ */ n(
|
|
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: () =>
|
|
150
|
+
onClick: () => u(t),
|
|
150
151
|
"aria-label": `スライド ${t + 1}`,
|
|
151
|
-
className:
|
|
152
|
+
className: d(
|
|
152
153
|
// shrink-0 必須: 空要素なので min-content 幅が 0、既定の flex-shrink:1 だとドットが消える
|
|
153
|
-
"size-2 shrink-0 rounded-full transition-colors",
|
|
154
|
-
|
|
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
|
-
|
|
166
|
+
D as ContentCarousel
|
|
165
167
|
};
|