@cakejp/design-system 0.20.0 → 0.21.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 (161) hide show
  1. package/CHANGELOG.md +179 -0
  2. package/CLAUDE.md +5 -3
  3. package/MIGRATION.md +3 -3
  4. package/README.md +31 -11
  5. package/contracts/components.json +424 -62
  6. package/contracts/composition.json +38 -4
  7. package/contracts/rules.json +27 -5
  8. package/contracts/screen-patterns.json +6 -4
  9. package/dist/components/ec/admin-shell.js +62 -60
  10. package/dist/components/ec/anniversary-card.js +13 -12
  11. package/dist/components/ec/coupon-card.js +11 -11
  12. package/dist/components/ec/delivery-calendar.js +51 -45
  13. package/dist/components/ec/mypage-shell.js +80 -69
  14. package/dist/components/ec/product-card.js +93 -76
  15. package/dist/components/ec/product-carousel.js +65 -60
  16. package/dist/components/ec/product-detail-bar.js +13 -11
  17. package/dist/components/ec/product-detail-sidebar.js +60 -58
  18. package/dist/components/ec/product-list-item.js +64 -63
  19. package/dist/components/ec/product-option.js +30 -26
  20. package/dist/components/ec/rating-stars.js +27 -27
  21. package/dist/components/ec/review-card.js +32 -32
  22. package/dist/components/ec/review-form.js +37 -37
  23. package/dist/components/ec/shop-card.js +21 -19
  24. package/dist/components/foundations/accordion.js +33 -31
  25. package/dist/components/foundations/alert-dialog.js +4 -5
  26. package/dist/components/foundations/badge.js +5 -5
  27. package/dist/components/foundations/breadcrumb.js +27 -26
  28. package/dist/components/foundations/button.js +144 -25
  29. package/dist/components/foundations/calendar.js +28 -26
  30. package/dist/components/foundations/checkbox-card.js +71 -47
  31. package/dist/components/foundations/checkbox-group.js +30 -27
  32. package/dist/components/foundations/checkbox.js +69 -52
  33. package/dist/components/foundations/chip-variants.js +13 -0
  34. package/dist/components/foundations/command.js +81 -79
  35. package/dist/components/foundations/confirm-dialog.js +136 -0
  36. package/dist/components/foundations/context-menu.js +43 -38
  37. package/dist/components/foundations/data-table.js +88 -84
  38. package/dist/components/foundations/dialog.js +45 -36
  39. package/dist/components/foundations/dropdown-menu.js +47 -42
  40. package/dist/components/foundations/file-input.js +97 -67
  41. package/dist/components/foundations/hover-card.js +21 -21
  42. package/dist/components/foundations/menubar.js +75 -69
  43. package/dist/components/foundations/navigation-menu.js +31 -26
  44. package/dist/components/foundations/pagination.js +54 -50
  45. package/dist/components/foundations/popover.js +7 -7
  46. package/dist/components/foundations/progress.js +10 -6
  47. package/dist/components/foundations/radio-group.js +6 -3
  48. package/dist/components/foundations/responsive-dialog.js +73 -55
  49. package/dist/components/foundations/scroll-area.js +18 -14
  50. package/dist/components/foundations/select.js +44 -39
  51. package/dist/components/foundations/sheet.js +45 -37
  52. package/dist/components/foundations/skeleton.js +6 -6
  53. package/dist/components/foundations/skip-link.js +10 -8
  54. package/dist/components/foundations/slider.js +73 -48
  55. package/dist/components/foundations/sonner.js +5 -4
  56. package/dist/components/foundations/spinner.js +7 -5
  57. package/dist/components/foundations/switch.js +11 -10
  58. package/dist/components/foundations/tabs.js +54 -39
  59. package/dist/components/foundations/toggle-group.js +29 -21
  60. package/dist/components/foundations/toggle.js +20 -16
  61. package/dist/components/primitives/admin-side-nav.js +65 -62
  62. package/dist/components/primitives/banner-carousel.js +32 -29
  63. package/dist/components/primitives/bottom-tab-bar.js +16 -15
  64. package/dist/components/primitives/category-scroll.js +39 -29
  65. package/dist/components/primitives/category-shortcuts.js +9 -9
  66. package/dist/components/primitives/chat-composer.js +77 -74
  67. package/dist/components/primitives/chip.js +84 -61
  68. package/dist/components/primitives/combobox.js +63 -47
  69. package/dist/components/primitives/container.js +9 -9
  70. package/dist/components/primitives/content-card.js +15 -17
  71. package/dist/components/primitives/content-carousel.js +79 -68
  72. package/dist/components/primitives/date-picker.js +137 -99
  73. package/dist/components/primitives/footer.js +36 -37
  74. package/dist/components/primitives/header.js +175 -168
  75. package/dist/components/primitives/image-carousel.js +107 -87
  76. package/dist/components/primitives/image-gallery.js +32 -27
  77. package/dist/components/primitives/image-uploader.js +43 -22
  78. package/dist/components/primitives/list-item.js +59 -51
  79. package/dist/components/primitives/menu-drawer.js +36 -38
  80. package/dist/components/primitives/multi-select.js +89 -58
  81. package/dist/components/primitives/notification-list.js +10 -9
  82. package/dist/components/primitives/number-input.js +116 -105
  83. package/dist/components/primitives/scroll-row.js +21 -0
  84. package/dist/components/primitives/search-bar.js +31 -28
  85. package/dist/components/primitives/section-header.js +54 -53
  86. package/dist/components/primitives/side-nav.js +57 -56
  87. package/dist/components/primitives/sub-nav.js +13 -14
  88. package/dist/components/primitives/tag.js +4 -2
  89. package/dist/index.css +1 -1
  90. package/dist/index.js +3076 -929
  91. package/dist/lib/field-labelling.js +31 -21
  92. package/dist/lib/focus-ring.js +22 -4
  93. package/dist/lib/high-contrast.js +4 -0
  94. package/dist/lib/image-index.js +8 -0
  95. package/dist/lib/use-prefers-reduced-motion.js +21 -0
  96. package/dist/types/components/ec/admin-shell.d.ts +11 -1
  97. package/dist/types/components/ec/anniversary-card.d.ts +9 -1
  98. package/dist/types/components/ec/mypage-shell.d.ts +12 -1
  99. package/dist/types/components/ec/product-card.d.ts +13 -1
  100. package/dist/types/components/ec/product-carousel.d.ts +13 -1
  101. package/dist/types/components/ec/product-detail-bar.d.ts +12 -1
  102. package/dist/types/components/ec/product-detail-sidebar.d.ts +11 -1
  103. package/dist/types/components/ec/product-list-item.d.ts +9 -1
  104. package/dist/types/components/ec/rating-stars.d.ts +2 -0
  105. package/dist/types/components/ec/review-card.d.ts +1 -1
  106. package/dist/types/components/ec/shop-card.d.ts +8 -1
  107. package/dist/types/components/foundations/badge.d.ts +1 -1
  108. package/dist/types/components/foundations/breadcrumb.d.ts +8 -1
  109. package/dist/types/components/foundations/button.d.ts +38 -3
  110. package/dist/types/components/foundations/checkbox-card.d.ts +7 -1
  111. package/dist/types/components/foundations/checkbox.d.ts +1 -1
  112. package/dist/types/components/foundations/chip-variants.d.ts +2 -2
  113. package/dist/types/components/foundations/confirm-dialog.d.ts +61 -0
  114. package/dist/types/components/foundations/data-table.d.ts +9 -2
  115. package/dist/types/components/foundations/dialog.d.ts +16 -1
  116. package/dist/types/components/foundations/pagination.d.ts +1 -1
  117. package/dist/types/components/foundations/responsive-dialog.d.ts +2 -1
  118. package/dist/types/components/foundations/sheet.d.ts +12 -1
  119. package/dist/types/components/foundations/skeleton.d.ts +6 -0
  120. package/dist/types/components/foundations/slider.d.ts +15 -1
  121. package/dist/types/components/foundations/tabs.d.ts +7 -0
  122. package/dist/types/components/primitives/admin-side-nav.d.ts +22 -2
  123. package/dist/types/components/primitives/banner-carousel.d.ts +9 -1
  124. package/dist/types/components/primitives/bottom-tab-bar.d.ts +13 -2
  125. package/dist/types/components/primitives/category-scroll.d.ts +10 -1
  126. package/dist/types/components/primitives/category-shortcuts.d.ts +11 -2
  127. package/dist/types/components/primitives/chip.d.ts +22 -3
  128. package/dist/types/components/primitives/combobox.d.ts +7 -2
  129. package/dist/types/components/primitives/container.d.ts +3 -0
  130. package/dist/types/components/primitives/content-card.d.ts +1 -1
  131. package/dist/types/components/primitives/content-carousel.d.ts +12 -4
  132. package/dist/types/components/primitives/date-picker.d.ts +10 -3
  133. package/dist/types/components/primitives/footer.d.ts +1 -1
  134. package/dist/types/components/primitives/header.d.ts +14 -2
  135. package/dist/types/components/primitives/image-carousel.d.ts +23 -5
  136. package/dist/types/components/primitives/list-item.d.ts +10 -1
  137. package/dist/types/components/primitives/menu-drawer.d.ts +1 -1
  138. package/dist/types/components/primitives/multi-select.d.ts +7 -2
  139. package/dist/types/components/primitives/notification-list.d.ts +10 -1
  140. package/dist/types/components/primitives/number-input.d.ts +18 -5
  141. package/dist/types/components/primitives/scroll-row.d.ts +43 -0
  142. package/dist/types/components/primitives/section-header.d.ts +9 -2
  143. package/dist/types/components/primitives/side-nav.d.ts +13 -1
  144. package/dist/types/components/primitives/sub-nav.d.ts +1 -1
  145. package/dist/types/components/primitives/tag.d.ts +1 -1
  146. package/dist/types/index.d.ts +7 -1
  147. package/dist/types/lib/field-labelling.d.ts +23 -8
  148. package/dist/types/lib/focus-ring.d.ts +70 -3
  149. package/dist/types/lib/high-contrast.d.ts +25 -0
  150. package/dist/types/lib/image-index.d.ts +2 -0
  151. package/dist/types/lib/link-component.d.ts +26 -21
  152. package/dist/types/lib/use-prefers-reduced-motion.d.ts +9 -0
  153. package/package.json +11 -3
  154. package/src/components/COMPONENT_LOOKUP.md +19 -17
  155. package/src/preset-standalone.css +42 -0
  156. package/src/preset.css +20 -1
  157. package/src/styles/semantic.css +57 -0
  158. package/templates/AGENTS.md +5 -1
  159. package/templates/CLAUDE.md +3 -1
  160. package/tokens.json +49 -0
  161. package/dist/lib/link-component.js +0 -6
@@ -1,91 +1,108 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as c } from "react/jsx-runtime";
3
- import * as p from "react";
4
- import y from "iconsax-reactjs/dist/esm/TickSquare.js";
5
- import k from "iconsax-reactjs/dist/esm/MinusSquare.js";
6
- import { Checkbox as l } from "radix-ui";
7
- import { cn as b } from "../../lib/utils.js";
8
- import { FOCUS_RING as g } from "../../lib/focus-ring.js";
9
- import { useFieldLabelling as N, resolveFieldAria as T } from "../../lib/field-labelling.js";
10
- function m({
11
- className: i,
2
+ import { jsx as t, jsxs as x } from "react/jsx-runtime";
3
+ import * as i from "react";
4
+ import S from "iconsax-reactjs/dist/esm/TickSquare.js";
5
+ import T from "iconsax-reactjs/dist/esm/MinusSquare.js";
6
+ import { Checkbox as y } from "radix-ui";
7
+ import { cn as E } from "../../lib/utils.js";
8
+ import { FOCUS_RING as j } from "../../lib/focus-ring.js";
9
+ import { useFieldLabelling as w, resolveFieldAria as L } from "../../lib/field-labelling.js";
10
+ function k(e, r) {
11
+ if (typeof e == "function") {
12
+ const a = e(r);
13
+ return typeof a == "function" ? a : void 0;
14
+ }
15
+ e && typeof e == "object" && (e.current = r);
16
+ }
17
+ const g = i.forwardRef(function({
18
+ className: r,
12
19
  ...a
13
- }) {
14
- return /* @__PURE__ */ e(
15
- l.Root,
20
+ }, l) {
21
+ return /* @__PURE__ */ t(
22
+ y.Root,
16
23
  {
17
24
  "data-slot": "checkbox",
18
- className: b(
25
+ ref: l,
26
+ className: E(
19
27
  // lint-scratch-allow: rounded-[5px] は Figma チェックボックス固有値(トークン外)
20
- "peer flex size-5 shrink-0 items-center justify-center rounded-[5px] border-2 border-[var(--Border-Medium-Emphasis)] bg-[var(--Surface-Primary)] transition-colors outline-none",
28
+ "peer flex size-5 shrink-0 items-center justify-center rounded-[5px] border-2 border-[var(--Border-Control,var(--Border-Medium-Emphasis))] bg-[var(--Surface-Primary)] transition-colors outline-none",
21
29
  "data-[state=checked]:border-transparent data-[state=checked]:bg-transparent",
22
30
  "data-[state=indeterminate]:border-transparent data-[state=indeterminate]:bg-transparent",
23
31
  // hover はフォーカス中に抑制する(checked 時の border-transparent が
24
32
  // フォーカスリングの枠を消してしまうため)。
25
33
  "hover:border-[var(--Focus-High-Emphasis)] data-[state=checked]:hover:not-focus-visible:border-transparent data-[state=indeterminate]:hover:not-focus-visible:border-transparent",
26
- g,
27
- "disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-[var(--Border-Medium-Emphasis)]",
28
- i
34
+ j,
35
+ "disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-[var(--Border-Control,var(--Border-Medium-Emphasis))]",
36
+ r
29
37
  ),
30
38
  ...a,
31
- children: /* @__PURE__ */ e(
32
- l.Indicator,
39
+ children: /* @__PURE__ */ t(
40
+ y.Indicator,
33
41
  {
34
42
  "data-slot": "checkbox-indicator",
35
43
  className: "flex items-center justify-center",
36
- children: a.checked === "indeterminate" ? /* @__PURE__ */ e(k, { size: 24, variant: "Bold", className: "text-[var(--Object-Accent-Primary)]" }) : /* @__PURE__ */ e(y, { size: 24, variant: "Bold", className: "text-[var(--Object-Accent-Primary)]" })
44
+ children: a.checked === "indeterminate" ? /* @__PURE__ */ t(T, { size: 24, variant: "Bold", className: "text-[var(--Object-Accent-Primary)]" }) : /* @__PURE__ */ t(S, { size: 24, variant: "Bold", className: "text-[var(--Object-Accent-Primary)]" })
37
45
  }
38
46
  )
39
47
  }
40
48
  );
41
- }
42
- function w({
43
- label: i,
44
- description: a,
45
- count: o,
46
- containerClassName: h,
47
- className: s,
48
- id: u,
49
- ...r
49
+ });
50
+ function $({
51
+ label: e,
52
+ description: r,
53
+ count: a,
54
+ containerClassName: l,
55
+ className: m,
56
+ id: C,
57
+ ref: u,
58
+ ...s
50
59
  }) {
51
- const v = N(), x = p.useId(), t = u ?? x, d = `${t}-label`, n = a ? `${t}-description` : void 0;
52
- if (i === void 0) {
53
- const f = T({ ...r, id: t }, v);
54
- return /* @__PURE__ */ e(m, { id: t, className: s, ...r, ...f });
60
+ const c = w(), b = i.useRef(null), f = i.useRef(void 0), [I, R] = i.useState(!1), N = i.useId(), n = C ?? N, h = i.useCallback((o) => {
61
+ const d = f.current;
62
+ f.current = void 0, d ? d() : o || k(u, null), b.current = o, o && (f.current = k(u, o));
63
+ }, [u]), v = `${n}-label`, p = r ? `${n}-description` : void 0;
64
+ if ((typeof window > "u" ? i.useEffect : i.useLayoutEffect)(() => {
65
+ if (e !== void 0 || !b.current || !c) return;
66
+ const o = Array.from(b.current.labels ?? []).filter((d) => d.id !== c.labelId);
67
+ R(o.length > 0);
68
+ }, [c, e]), e === void 0) {
69
+ const o = L({ ...s, id: n }, c, I);
70
+ return /* @__PURE__ */ t(g, { ref: h, id: n, className: m, ...s, ...o });
55
71
  }
56
- return /* @__PURE__ */ c(
72
+ return /* @__PURE__ */ x(
57
73
  "label",
58
74
  {
59
- htmlFor: t,
75
+ htmlFor: n,
60
76
  "data-slot": "checkbox-row",
61
- "data-disabled": r.disabled || void 0,
62
- className: b(
77
+ "data-disabled": s.disabled || void 0,
78
+ className: E(
63
79
  "flex items-center gap-3 rounded-md px-3 py-2 transition-colors cursor-pointer",
64
80
  "hover:bg-[var(--Surface-Tertiary)]",
65
81
  "has-[:focus-visible]:bg-[var(--Surface-Tertiary)]",
66
- r.disabled && "cursor-not-allowed opacity-60 hover:bg-transparent has-[:focus-visible]:bg-transparent",
67
- h
82
+ s.disabled && "cursor-not-allowed opacity-60 hover:bg-transparent has-[:focus-visible]:bg-transparent",
83
+ l
68
84
  ),
69
85
  children: [
70
- /* @__PURE__ */ e(
71
- m,
86
+ /* @__PURE__ */ t(
87
+ g,
72
88
  {
73
- id: t,
74
- className: s,
75
- "aria-labelledby": r["aria-label"] ? void 0 : d,
76
- "aria-describedby": n,
77
- ...r
89
+ ref: h,
90
+ id: n,
91
+ className: m,
92
+ "aria-labelledby": s["aria-label"] ? void 0 : v,
93
+ "aria-describedby": p,
94
+ ...s
78
95
  }
79
96
  ),
80
- /* @__PURE__ */ c("div", { className: "flex-1 min-w-0", children: [
81
- /* @__PURE__ */ e("span", { id: d, className: "typo-body-md text-[var(--Text-High-Emphasis)]", children: i }),
82
- a && /* @__PURE__ */ e("span", { id: n, className: "block typo-body-sm text-[var(--Text-Medium-Emphasis)] mt-0.5", children: a })
97
+ /* @__PURE__ */ x("div", { className: "flex-1 min-w-0", children: [
98
+ /* @__PURE__ */ t("span", { id: v, className: "typo-body-md text-[var(--Text-High-Emphasis)]", children: e }),
99
+ r && /* @__PURE__ */ t("span", { id: p, className: "block typo-body-sm text-[var(--Text-Medium-Emphasis)] mt-0.5", children: r })
83
100
  ] }),
84
- o !== void 0 && /* @__PURE__ */ e("span", { className: "shrink-0 typo-label-sm text-[var(--Text-Medium-Emphasis)] tabular-nums", children: o.toLocaleString() })
101
+ a !== void 0 && /* @__PURE__ */ t("span", { className: "shrink-0 typo-label-sm text-[var(--Text-Medium-Emphasis)] tabular-nums", children: a.toLocaleString() })
85
102
  ]
86
103
  }
87
104
  );
88
105
  }
89
106
  export {
90
- w as Checkbox
107
+ $ as Checkbox
91
108
  };
@@ -10,10 +10,23 @@ const t = e(
10
10
  "hover:bg-[var(--Surface-Tertiary)]",
11
11
  "disabled:text-[var(--Text-Disable)] disabled:hover:bg-[var(--Surface-Secondary)]"
12
12
  ].join(" "),
13
+ /** accent — 薄いブランド色地 + ブランド色文字。Chip の selected は使わなくなった(明示指定の互換のために残す) */
13
14
  accent: [
14
15
  "bg-[var(--Surface-Accent-Primary-Light)] text-[var(--Brand-Cake-Orange)]",
15
16
  "hover:bg-[var(--Surface-Accent-Primary)] hover:text-[var(--Text-on-Inverse)]",
16
17
  "disabled:bg-[var(--Surface-Secondary)] disabled:text-[var(--Text-Disable)] disabled:hover:bg-[var(--Surface-Secondary)] disabled:hover:text-[var(--Text-Disable)]"
18
+ ].join(" "),
19
+ /**
20
+ * selected — Chip の選択中。ブランド色を使わず、グレー地 + 1px の黒系の枠で示す
21
+ * (contracts/composition.json の brandColorUsage。ナビ・絞り込みの選択中表示にブランド色を使わない)。
22
+ * 枠は border ではなく内側リング(inset-ring)で描く: border だと未選択→選択で 2px 大きくなる。
23
+ * inset-ring は FOCUS_RING の ring(外側)と別の box-shadow 層なので、フォーカス中も両方見える。
24
+ * forced-colors では box-shadow が消えるため、Chip 側が Highlight の塗りで選択中を示す。
25
+ */
26
+ selected: [
27
+ "bg-[var(--Surface-Tertiary)] text-[var(--Text-High-Emphasis)] inset-ring-1 inset-ring-[var(--Border-High-Emphasis)]",
28
+ "hover:bg-[var(--Hover-Tertiary-Button)]",
29
+ "disabled:bg-[var(--Surface-Secondary)] disabled:text-[var(--Text-Disable)] disabled:inset-ring-transparent disabled:hover:bg-[var(--Surface-Secondary)]"
17
30
  ].join(" ")
18
31
  },
19
32
  size: {
@@ -1,172 +1,174 @@
1
1
  "use client";
2
- import { jsx as t, jsxs as d } from "react/jsx-runtime";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
3
  import "react";
4
- import { Command as r } from "cmdk";
5
- import { SearchIcon as i } from "lucide-react";
6
- import { cn as a } from "../../lib/utils.js";
7
- import { Dialog as p, DialogHeader as l, DialogTitle as u, DialogDescription as g, DialogContent as h } from "./dialog.js";
8
- function f({
9
- className: e,
10
- ...o
4
+ import { Command as a } from "cmdk";
5
+ import { SearchIcon as c } from "lucide-react";
6
+ import { cn as r } from "../../lib/utils.js";
7
+ import { FORCED_COLORS_COMMAND_ITEM as l } from "../../lib/focus-ring.js";
8
+ import { Dialog as u, DialogHeader as p, DialogTitle as f, DialogDescription as g, DialogContent as h } from "./dialog.js";
9
+ function x({
10
+ className: o,
11
+ ...e
11
12
  }) {
12
13
  return /* @__PURE__ */ t(
13
- r,
14
+ a,
14
15
  {
15
16
  "data-slot": "command",
16
- className: a(
17
+ className: r(
17
18
  "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
18
- e
19
+ o
19
20
  ),
20
- ...o
21
+ ...e
21
22
  }
22
23
  );
23
24
  }
24
- function w({
25
- title: e = "Command Palette",
26
- description: o = "Search for a command to run...",
27
- children: n,
25
+ function N({
26
+ title: o = "Command Palette",
27
+ description: e = "Search for a command to run...",
28
+ children: d,
28
29
  className: m,
29
30
  showCloseButton: s = !0,
30
- ...c
31
+ ...i
31
32
  }) {
32
- return /* @__PURE__ */ d(p, { ...c, children: [
33
- /* @__PURE__ */ d(l, { className: "sr-only", children: [
34
- /* @__PURE__ */ t(u, { children: e }),
35
- /* @__PURE__ */ t(g, { children: o })
33
+ return /* @__PURE__ */ n(u, { ...i, children: [
34
+ /* @__PURE__ */ n(p, { className: "sr-only", children: [
35
+ /* @__PURE__ */ t(f, { children: o }),
36
+ /* @__PURE__ */ t(g, { children: e })
36
37
  ] }),
37
38
  /* @__PURE__ */ t(
38
39
  h,
39
40
  {
40
- className: a("overflow-hidden p-0", m),
41
+ className: r("overflow-hidden p-0", m),
41
42
  showCloseButton: s,
42
- children: /* @__PURE__ */ t(f, { className: "**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:typo-label-sm [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children: n })
43
+ children: /* @__PURE__ */ t(x, { className: "**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:typo-label-sm [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children: d })
43
44
  }
44
45
  )
45
46
  ] });
46
47
  }
47
- function C({
48
- className: e,
49
- ...o
48
+ function D({
49
+ className: o,
50
+ ...e
50
51
  }) {
51
- return /* @__PURE__ */ d(
52
+ return /* @__PURE__ */ n(
52
53
  "div",
53
54
  {
54
55
  "data-slot": "command-input-wrapper",
55
- className: "flex h-9 items-center gap-2 border-b border-[var(--Border-Medium-Emphasis)] px-3 focus-within:border-[var(--Focus-High-Emphasis)]",
56
+ className: "flex h-9 items-center gap-2 border-b border-[var(--Border-Medium-Emphasis)] px-3 focus-within:border-[var(--Focus-High-Emphasis)] forced-colors:focus-within:outline-solid forced-colors:focus-within:outline-2 forced-colors:focus-within:-outline-offset-2 forced-colors:focus-within:outline-[Highlight]",
56
57
  children: [
57
- /* @__PURE__ */ t(i, { className: "size-4 shrink-0 opacity-50" }),
58
+ /* @__PURE__ */ t(c, { className: "size-4 shrink-0 opacity-50" }),
58
59
  /* @__PURE__ */ t(
59
- r.Input,
60
+ a.Input,
60
61
  {
61
62
  "data-slot": "command-input",
62
- className: a(
63
- "flex h-10 w-full rounded-md bg-transparent py-3 typo-body-md outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
64
- e
63
+ className: r(
64
+ "flex h-10 w-full rounded-md bg-transparent py-3 typo-body-md outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
65
+ o
65
66
  ),
66
- ...o
67
+ ...e
67
68
  }
68
69
  )
69
70
  ]
70
71
  }
71
72
  );
72
73
  }
73
- function N({
74
- className: e,
75
- ...o
74
+ function E({
75
+ className: o,
76
+ ...e
76
77
  }) {
77
78
  return /* @__PURE__ */ t(
78
- r.List,
79
+ a.List,
79
80
  {
80
81
  "data-slot": "command-list",
81
- className: a(
82
+ className: r(
82
83
  "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
83
- e
84
+ o
84
85
  ),
85
- ...o
86
+ ...e
86
87
  }
87
88
  );
88
89
  }
89
- function D({
90
- ...e
90
+ function I({
91
+ ...o
91
92
  }) {
92
93
  return /* @__PURE__ */ t(
93
- r.Empty,
94
+ a.Empty,
94
95
  {
95
96
  "data-slot": "command-empty",
96
97
  className: "py-6 text-center typo-body-md",
97
- ...e
98
+ ...o
98
99
  }
99
100
  );
100
101
  }
101
- function I({
102
- className: e,
103
- ...o
102
+ function S({
103
+ className: o,
104
+ ...e
104
105
  }) {
105
106
  return /* @__PURE__ */ t(
106
- r.Group,
107
+ a.Group,
107
108
  {
108
109
  "data-slot": "command-group",
109
- className: a(
110
+ className: r(
110
111
  "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:typo-label-sm [&_[cmdk-group-heading]]:text-muted-foreground",
111
- e
112
+ o
112
113
  ),
113
- ...o
114
+ ...e
114
115
  }
115
116
  );
116
117
  }
117
- function S({
118
- className: e,
119
- ...o
118
+ function M({
119
+ className: o,
120
+ ...e
120
121
  }) {
121
122
  return /* @__PURE__ */ t(
122
- r.Separator,
123
+ a.Separator,
123
124
  {
124
125
  "data-slot": "command-separator",
125
- className: a("-mx-1 h-px bg-border", e),
126
- ...o
126
+ className: r("-mx-1 h-px bg-border", o),
127
+ ...e
127
128
  }
128
129
  );
129
130
  }
130
- function E({
131
- className: e,
132
- ...o
131
+ function O({
132
+ className: o,
133
+ ...e
133
134
  }) {
134
135
  return /* @__PURE__ */ t(
135
- r.Item,
136
+ a.Item,
136
137
  {
137
138
  "data-slot": "command-item",
138
- className: a(
139
- "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 typo-body-md outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
140
- e
139
+ className: r(
140
+ "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 typo-body-md outline-none select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
141
+ l,
142
+ o
141
143
  ),
142
- ...o
144
+ ...e
143
145
  }
144
146
  );
145
147
  }
146
148
  function z({
147
- className: e,
148
- ...o
149
+ className: o,
150
+ ...e
149
151
  }) {
150
152
  return /* @__PURE__ */ t(
151
153
  "span",
152
154
  {
153
155
  "data-slot": "command-shortcut",
154
- className: a(
156
+ className: r(
155
157
  "ml-auto typo-body-xs text-muted-foreground",
156
- e
158
+ o
157
159
  ),
158
- ...o
160
+ ...e
159
161
  }
160
162
  );
161
163
  }
162
164
  export {
163
- f as Command,
164
- w as CommandDialog,
165
- D as CommandEmpty,
166
- I as CommandGroup,
167
- C as CommandInput,
168
- E as CommandItem,
169
- N as CommandList,
170
- S as CommandSeparator,
165
+ x as Command,
166
+ N as CommandDialog,
167
+ I as CommandEmpty,
168
+ S as CommandGroup,
169
+ D as CommandInput,
170
+ O as CommandItem,
171
+ E as CommandList,
172
+ M as CommandSeparator,
171
173
  z as CommandShortcut
172
174
  };
@@ -0,0 +1,136 @@
1
+ "use client";
2
+ import { jsxs as D, jsx as f } from "react/jsx-runtime";
3
+ import * as o from "react";
4
+ import { AlertDialog as w, AlertDialogContent as x, AlertDialogHeader as E, AlertDialogTitle as I, AlertDialogDescription as T, AlertDialogFooter as q, AlertDialogCancel as v } from "./alert-dialog.js";
5
+ import { Button as L } from "./button.js";
6
+ const A = { active: null, open: !1, queue: [] };
7
+ function M(e, r) {
8
+ if (e.active === r) {
9
+ if (!e.open) return e;
10
+ const [n, ...u] = e.queue;
11
+ return n ? { active: n, open: !0, queue: u } : { ...e, open: !1 };
12
+ }
13
+ return e.queue.includes(r) ? { ...e, queue: e.queue.filter((n) => n !== r) } : e;
14
+ }
15
+ const R = "data-confirm-dialog";
16
+ function y(e) {
17
+ return !(e instanceof HTMLElement) || e === e.ownerDocument.body ? !1 : !e.closest(`[${R}]`);
18
+ }
19
+ function O(e) {
20
+ let r = null, n = e;
21
+ for (let u = 0; u < 8; u++) {
22
+ const s = n.closest('[role="menu"]')?.getAttribute("aria-labelledby"), t = s ? e.ownerDocument.getElementById(s) : null;
23
+ if (!(t instanceof HTMLElement) || t === n) break;
24
+ r = t, n = t;
25
+ }
26
+ return r;
27
+ }
28
+ const k = o.createContext(null);
29
+ function j({ children: e }) {
30
+ const [r, n] = o.useState(A), u = o.useRef(/* @__PURE__ */ new Set()), i = o.useRef(!1), s = o.useRef(0), t = o.useRef(
31
+ null
32
+ ), d = o.useCallback((c, l) => {
33
+ u.current.delete(c) && c.resolve(l), n((a) => M(a, c));
34
+ }, []), F = o.useCallback(
35
+ (c) => new Promise((l) => {
36
+ const a = typeof document > "u" ? null : document.activeElement, h = y(a) ? { returnFocus: a, fallbackFocus: O(a) } : t.current ?? { returnFocus: null, fallbackFocus: null };
37
+ t.current = h;
38
+ const C = { id: s.current++, options: c, resolve: l, ...h };
39
+ u.current.add(C), n(
40
+ (g) => g.active && g.open ? { ...g, queue: [...g.queue, C] } : (
41
+ // 閉じるアニメーション中の要求は key の変更で即座に差し替える
42
+ { active: C, open: !0, queue: g.queue }
43
+ )
44
+ ), i.current && queueMicrotask(() => {
45
+ i.current && d(C, !1);
46
+ });
47
+ }),
48
+ [d]
49
+ ), m = o.useCallback((c, l) => {
50
+ if (c.preventDefault(), document.activeElement?.closest(`[${R}]`)) return;
51
+ (l.returnFocus?.isConnected ? l.returnFocus : l.fallbackFocus?.isConnected ? l.fallbackFocus : null)?.focus(), t.current = null;
52
+ }, []);
53
+ o.useEffect(() => {
54
+ i.current = !1;
55
+ const c = u.current;
56
+ return () => {
57
+ i.current = !0, queueMicrotask(() => {
58
+ if (i.current) {
59
+ for (const l of c) l.resolve(!1);
60
+ c.clear(), t.current = null, n(A);
61
+ }
62
+ });
63
+ };
64
+ }, []);
65
+ const { active: b, open: p } = r;
66
+ return /* @__PURE__ */ D(k.Provider, { value: F, children: [
67
+ e,
68
+ b ? /* @__PURE__ */ f(
69
+ P,
70
+ {
71
+ request: b,
72
+ open: p,
73
+ onFinish: d,
74
+ onCloseAutoFocus: m
75
+ },
76
+ b.id
77
+ ) : null
78
+ ] });
79
+ }
80
+ function P({
81
+ request: e,
82
+ open: r,
83
+ onFinish: n,
84
+ onCloseAutoFocus: u
85
+ }) {
86
+ const {
87
+ title: i,
88
+ description: s,
89
+ confirmLabel: t = "確認",
90
+ cancelLabel: d = "キャンセル",
91
+ tone: F = "default"
92
+ } = e.options;
93
+ return /* @__PURE__ */ f(
94
+ w,
95
+ {
96
+ open: r,
97
+ onOpenChange: (m) => {
98
+ m || n(e, !1);
99
+ },
100
+ children: /* @__PURE__ */ D(
101
+ x,
102
+ {
103
+ "data-confirm-dialog": "",
104
+ onCloseAutoFocus: (m) => u(m, e),
105
+ children: [
106
+ /* @__PURE__ */ D(E, { children: [
107
+ /* @__PURE__ */ f(I, { children: i }),
108
+ s != null ? /* @__PURE__ */ f(T, { children: s }) : null
109
+ ] }),
110
+ /* @__PURE__ */ D(q, { children: [
111
+ /* @__PURE__ */ f(v, { children: d }),
112
+ /* @__PURE__ */ f(
113
+ L,
114
+ {
115
+ variant: F === "destructive" ? "destructive" : "default",
116
+ onClick: () => n(e, !0),
117
+ children: t
118
+ }
119
+ )
120
+ ] })
121
+ ]
122
+ }
123
+ )
124
+ }
125
+ );
126
+ }
127
+ function B() {
128
+ const e = o.useContext(k);
129
+ if (!e)
130
+ throw new Error("useConfirm は <ConfirmDialogProvider> の内側で使ってください。");
131
+ return e;
132
+ }
133
+ export {
134
+ j as ConfirmDialogProvider,
135
+ B as useConfirm
136
+ };