@geckou/ui-react 0.3.0 → 0.5.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.
@@ -1,39 +1,43 @@
1
1
  "use client";
2
- import { jsxs as l, jsx as o } from "react/jsx-runtime";
3
- import { useState as C, useEffect as F } from "react";
4
- import { splitDate as T, COLOR as I, daysInMonth as $ } from "@geckou/ui-core";
5
- import { InputBox as z } from "./InputBox.js";
6
- import { KeyboardArrowDownIcon as f } from "./icons/KeyboardArrowDownIcon.js";
7
- import { useRegisterValidation as H } from "../hooks/useFormValidation.js";
8
- const b = { year: "", month: "", day: "" };
9
- function J({
2
+ import { jsxs as o, jsx as r } from "react/jsx-runtime";
3
+ import { useState as H, useEffect as K, useId as L } from "react";
4
+ import { splitDate as V, COLOR as O, daysInMonth as q } from "@geckou/ui-core";
5
+ import { InputBox as G } from "./InputBox.js";
6
+ import { KeyboardArrowDownIcon as g } from "./icons/KeyboardArrowDownIcon.js";
7
+ import { useRegisterValidation as J } from "../hooks/useFormValidation.js";
8
+ const S = { year: "", month: "", day: "" };
9
+ function ee({
10
10
  name: n,
11
11
  value: m,
12
12
  onChange: s,
13
13
  isRequired: c,
14
- formValidationStore: Y,
15
- type: i = "date"
14
+ formValidationStore: k,
15
+ type: d = "date",
16
+ minYear: B,
17
+ maxYear: E,
18
+ ariaLabel: T,
19
+ ariaLabelledBy: u
16
20
  }) {
17
- const [r, d] = C(b), g = !!(r.year && r.month && (i === "month" || r.day)), A = !r.year && !r.month && !r.day;
18
- H(
19
- Y,
21
+ const [l, p] = H(S), $ = !!(l.year && l.month && (d === "month" || l.day)), Y = !l.year && !l.month && !l.day;
22
+ J(
23
+ k,
20
24
  n,
21
- c ? g : g || A
22
- ), F(() => {
23
- d(m ? T(m) : b);
25
+ c ? $ : $ || Y
26
+ ), K(() => {
27
+ p(m ? V(m) : S);
24
28
  }, [m]);
25
- const N = /* @__PURE__ */ new Date(), S = N.getFullYear() - 100, O = N.getFullYear() - 14, k = Array.from(
26
- { length: O - S + 1 },
27
- (e, a) => (S + a).toString()
28
- ).map((e) => ({ label: e, value: e })), E = Array.from({ length: 12 }, (e, a) => {
29
+ const w = (/* @__PURE__ */ new Date()).getFullYear(), D = B ?? w - 100, _ = E ?? w - 14, j = Array.from(
30
+ { length: Math.max(_ - D + 1, 0) },
31
+ (e, a) => (D + a).toString()
32
+ ).map((e) => ({ label: e, value: e })), C = Array.from({ length: 12 }, (e, a) => {
29
33
  const t = (a + 1).toString();
30
34
  return { label: t, value: t.padStart(2, "0") };
31
- }), w = (e, a) => $(Number(e) || 2e3, Number(a)), M = w(r.year, r.month), _ = Array.from({ length: M }, (e, a) => {
35
+ }), I = (e, a) => q(Number(e) || 2e3, Number(a)), F = I(l.year, l.month), P = Array.from({ length: F }, (e, a) => {
32
36
  const t = (a + 1).toString();
33
37
  return { label: t, value: t.padStart(2, "0") };
34
- }), D = (e) => {
35
- d(e);
36
- const a = i === "month" ? [e.year, e.month] : [e.year, e.month, e.day];
38
+ }), x = (e) => {
39
+ p(e);
40
+ const a = d === "month" ? [e.year, e.month] : [e.year, e.month, e.day];
37
41
  if (!e.year && !e.month && !e.day)
38
42
  s == null || s("");
39
43
  else {
@@ -41,89 +45,97 @@ function J({
41
45
  return;
42
46
  s == null || s(a.join("-"));
43
47
  }
44
- }, u = (e, a) => {
45
- const t = { ...r, [e]: a };
48
+ }, h = (e, a) => {
49
+ const t = { ...l, [e]: a };
46
50
  if (e !== "day" && t.day && t.month) {
47
- const B = w(t.year, t.month);
48
- Number(t.day) > B && (t.day = String(B).padStart(2, "0"));
51
+ const M = I(t.year, t.month);
52
+ Number(t.day) > M && (t.day = String(M).padStart(2, "0"));
49
53
  }
50
- D(t);
51
- }, p = (e) => {
54
+ x(t);
55
+ }, y = (e) => {
52
56
  const t = e.currentTarget.firstElementChild;
53
57
  t && t.click();
54
- }, v = "relative w-max [&:has(select:focus)>svg]:rotate-180", y = "pointer-events-none absolute inset-y-0 right-[var(--sp-small,0.375rem)] m-auto size-[var(--icon-medium,1.125rem)] fill-(--icon-color)", x = "w-[calc(3ch+var(--sp-medium,0.75rem)*2+var(--icon-medium,1.125rem))]! p-[var(--sp-medium,0.75rem)]! pe-[calc(var(--sp-small,0.375rem)*2+var(--icon-medium,1.125rem))]! cursor-pointer", h = { "--icon-color": I.blue }, j = { "--caution-color": I.red };
55
- return /* @__PURE__ */ l(z, { className: "flex w-max items-center [&>*:not(:last-of-type)]:after:content-['/']", children: [
56
- /* @__PURE__ */ l("div", { className: v, style: h, onClick: p, children: [
57
- /* @__PURE__ */ l(
58
+ }, i = L(), v = (e) => u ? { "aria-labelledby": `${u} ${i}-${e}` } : { "aria-label": `${T ?? n}の${e}` }, f = "relative w-max [&:has(select:focus)>svg]:rotate-180", b = "pointer-events-none absolute inset-y-0 right-[var(--sp-small,0.375rem)] m-auto size-[var(--icon-medium,1.125rem)] fill-(--icon-color)", A = "w-[calc(3ch+var(--sp-medium,0.75rem)*2+var(--icon-medium,1.125rem))]! p-[var(--sp-medium,0.75rem)]! pe-[calc(var(--sp-small,0.375rem)*2+var(--icon-medium,1.125rem))]! cursor-pointer", N = { "--icon-color": O.blue }, z = { "--caution-color": O.red };
59
+ return /* @__PURE__ */ o(G, { className: "flex w-max items-center [&>*:not(:last-of-type)]:after:content-['/']", children: [
60
+ /* @__PURE__ */ o("div", { className: f, style: N, onClick: y, children: [
61
+ /* @__PURE__ */ o(
58
62
  "select",
59
63
  {
60
- value: r.year,
64
+ value: l.year,
61
65
  name: `${n}-year`,
66
+ ...v("年"),
62
67
  required: c,
63
- onChange: (e) => u("year", e.target.value),
68
+ onChange: (e) => h("year", e.target.value),
64
69
  className: "w-[calc(5ch+var(--sp-medium,0.75rem)*2+var(--icon-medium,1.125rem))]! cursor-pointer p-[var(--sp-medium,0.75rem)]! pe-[calc(var(--sp-small,0.375rem)*2+var(--icon-medium,1.125rem))]!",
65
70
  children: [
66
- /* @__PURE__ */ o("option", { disabled: !0, value: "", children: "年" }),
67
- k.map((e) => /* @__PURE__ */ o("option", { value: e.value, children: e.label }, e.value))
71
+ /* @__PURE__ */ r("option", { disabled: !0, value: "", children: "年" }),
72
+ j.map((e) => /* @__PURE__ */ r("option", { value: e.value, children: e.label }, e.value))
68
73
  ]
69
74
  }
70
75
  ),
71
- /* @__PURE__ */ o(f, { className: y })
76
+ /* @__PURE__ */ r(g, { className: b })
72
77
  ] }),
73
- /* @__PURE__ */ l("div", { className: v, style: h, onClick: p, children: [
74
- /* @__PURE__ */ l(
78
+ /* @__PURE__ */ o("div", { className: f, style: N, onClick: y, children: [
79
+ /* @__PURE__ */ o(
75
80
  "select",
76
81
  {
77
- value: r.month,
82
+ value: l.month,
78
83
  name: `${n}-month`,
84
+ ...v("月"),
79
85
  required: c,
80
- onChange: (e) => u("month", e.target.value),
81
- className: x,
86
+ onChange: (e) => h("month", e.target.value),
87
+ className: A,
82
88
  children: [
83
- /* @__PURE__ */ o("option", { disabled: !0, value: "", children: "月" }),
84
- E.map((e) => /* @__PURE__ */ o("option", { value: e.value, children: e.label }, e.value))
89
+ /* @__PURE__ */ r("option", { disabled: !0, value: "", children: "月" }),
90
+ C.map((e) => /* @__PURE__ */ r("option", { value: e.value, children: e.label }, e.value))
85
91
  ]
86
92
  }
87
93
  ),
88
- /* @__PURE__ */ o(f, { className: y })
94
+ /* @__PURE__ */ r(g, { className: b })
89
95
  ] }),
90
- i === "date" && /* @__PURE__ */ l(
96
+ d === "date" && /* @__PURE__ */ o(
91
97
  "div",
92
98
  {
93
- className: v,
94
- style: h,
95
- onClick: p,
99
+ className: f,
100
+ style: N,
101
+ onClick: y,
96
102
  children: [
97
- /* @__PURE__ */ l(
103
+ /* @__PURE__ */ o(
98
104
  "select",
99
105
  {
100
- value: r.day,
106
+ value: l.day,
101
107
  name: `${n}-day`,
108
+ ...v("日"),
102
109
  required: c,
103
- onChange: (e) => u("day", e.target.value),
104
- className: x,
110
+ onChange: (e) => h("day", e.target.value),
111
+ className: A,
105
112
  children: [
106
- /* @__PURE__ */ o("option", { disabled: !0, value: "", children: "日" }),
107
- _.map((e) => /* @__PURE__ */ o("option", { value: e.value, children: e.label }, e.value))
113
+ /* @__PURE__ */ r("option", { disabled: !0, value: "", children: "日" }),
114
+ P.map((e) => /* @__PURE__ */ r("option", { value: e.value, children: e.label }, e.value))
108
115
  ]
109
116
  }
110
117
  ),
111
- /* @__PURE__ */ o(f, { className: y })
118
+ /* @__PURE__ */ r(g, { className: b })
112
119
  ]
113
120
  }
114
121
  ),
115
- /* @__PURE__ */ o(
122
+ u && /* @__PURE__ */ o("span", { className: "sr-only", children: [
123
+ /* @__PURE__ */ r("span", { id: `${i}-年`, children: "の年" }),
124
+ /* @__PURE__ */ r("span", { id: `${i}-月`, children: "の月" }),
125
+ /* @__PURE__ */ r("span", { id: `${i}-日`, children: "の日" })
126
+ ] }),
127
+ /* @__PURE__ */ r(
116
128
  "button",
117
129
  {
118
130
  type: "button",
119
- style: j,
131
+ style: z,
120
132
  className: "mx-[var(--sp-medium,0.75rem)] inline-flex cursor-pointer items-center gap-[var(--sp-min,0.1875rem)] text-[length:var(--fs-small,0.6875rem)] text-(--caution-color)",
121
- onClick: () => D(b),
133
+ onClick: () => x(S),
122
134
  children: "削除"
123
135
  }
124
136
  )
125
137
  ] });
126
138
  }
127
139
  export {
128
- J as DateSelector
140
+ ee as DateSelector
129
141
  };
@@ -1,21 +1,22 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
2
  import { COLOR as t } from "@geckou/ui-core";
3
- function a({ errorMessages: r, cssStyle: o }) {
4
- if (!r || !r.length)
3
+ function f({ errorMessages: o, cssStyle: r }) {
4
+ if (!o || !o.length)
5
5
  return null;
6
6
  const b = {
7
- "--error-text-color": (o == null ? void 0 : o.textColor) || t.white,
8
- "--error-background-color": (o == null ? void 0 : o.backgroundColor) || t.red
7
+ "--error-text-color": (r == null ? void 0 : r.textColor) || t.white,
8
+ "--error-background-color": (r == null ? void 0 : r.backgroundColor) || t.red
9
9
  };
10
10
  return /* @__PURE__ */ n(
11
11
  "div",
12
12
  {
13
+ role: "alert",
13
14
  className: "absolute top-[calc(100%+0.25rem)] flex w-max flex-col gap-2 rounded-sm bg-(--error-background-color) px-3 py-2 text-sm leading-none text-(--error-text-color) shadow-[0_0_0.5rem_0.25rem_#33333322] before:absolute before:bottom-[calc(100%-1px)] before:left-[0.85rem] before:block before:h-[0.53rem] before:w-[0.85rem] before:bg-(--error-background-color) before:content-[''] before:[clip-path:polygon(50%_0%,100%_100%,0%_100%)]",
14
15
  style: b,
15
- children: r.map((e) => /* @__PURE__ */ n("span", { children: e }, e))
16
+ children: o.map((e) => /* @__PURE__ */ n("span", { children: e }, e))
16
17
  }
17
18
  );
18
19
  }
19
20
  export {
20
- a as ErrorMessage
21
+ f as ErrorMessage
21
22
  };
@@ -1,72 +1,68 @@
1
1
  "use client";
2
- import { jsx as C } from "react/jsx-runtime";
3
- import { useRef as a, useState as L, useCallback as E, useEffect as v } from "react";
4
- import { INPUT_BOX_DEFAULT_STYLES as k } from "@geckou/ui-core";
2
+ import { jsx as y } from "react/jsx-runtime";
3
+ import { useRef as u, useState as C, useCallback as L, useEffect as v } from "react";
4
+ import { INPUT_BOX_DEFAULT_STYLES as E } from "@geckou/ui-core";
5
5
  function $({
6
6
  cssStyle: m,
7
- isErrored: u,
8
- isDisabled: n,
7
+ isErrored: l,
8
+ isDisabled: s,
9
9
  className: _,
10
- children: w
10
+ children: S
11
11
  }) {
12
- var b, p, h;
13
- const l = a(null), [S, t] = L("default"), c = a(u);
14
- c.current = u;
15
- const r = E(() => {
16
- var s;
17
- const e = (s = l.current) == null ? void 0 : s.querySelector("input, textarea, select");
18
- if (!e)
12
+ var p, x, h;
13
+ const c = u(null), [g, t] = C("default"), i = u(l);
14
+ i.current = l;
15
+ const r = L(() => {
16
+ var a;
17
+ const e = Array.from(
18
+ ((a = c.current) == null ? void 0 : a.querySelectorAll("input, textarea, select")) ?? []
19
+ );
20
+ if (e.length === 0)
19
21
  return t("default");
20
- if (e.matches(":disabled"))
22
+ if (e.every((n) => n.matches(":disabled")))
21
23
  return t("disabled");
22
- if (e.matches(":focus"))
24
+ if (e.some((n) => n.matches(":focus")))
23
25
  return t("focus");
24
- if (e.tagName.toLowerCase() === "select") {
25
- const x = e;
26
- return t(
27
- x.required && !x.value ? "error" : "valid"
28
- );
29
- }
30
- if (c.current || e.matches(":invalid"))
26
+ if (i.current || e.some((n) => n.matches(":invalid")))
31
27
  return t("error");
32
- if (e.matches(":valid") && e.matches(":not(:placeholder-shown)") && e.matches(":not(:invalid)"))
28
+ if (e.every((n) => n.value !== ""))
33
29
  return t("valid");
34
30
  t("default");
35
31
  }, []);
36
32
  v(() => {
37
- const e = l.current;
33
+ const e = c.current;
38
34
  if (!e)
39
35
  return;
40
- const s = new MutationObserver(r);
41
- return s.observe(e, { childList: !0, subtree: !0 }), e.addEventListener("focusin", r, !0), e.addEventListener("blur", r, !0), () => {
42
- s.disconnect(), e.removeEventListener("focusin", r, !0), e.removeEventListener("blur", r, !0);
36
+ const a = new MutationObserver(r);
37
+ return a.observe(e, { childList: !0, subtree: !0 }), e.addEventListener("focusin", r, !0), e.addEventListener("blur", r, !0), () => {
38
+ a.disconnect(), e.removeEventListener("focusin", r, !0), e.removeEventListener("blur", r, !0);
43
39
  };
44
40
  }, [r]);
45
- const i = a(!0), d = a(n);
41
+ const d = u(!0), f = u(s);
46
42
  v(() => {
47
- const e = d.current !== n;
48
- if (d.current = n, i.current) {
49
- i.current = !1, n && t("disabled");
43
+ const e = f.current !== s;
44
+ if (f.current = s, d.current) {
45
+ d.current = !1, s && t("disabled");
50
46
  return;
51
47
  }
52
48
  if (e)
53
- return t(n ? "disabled" : "default");
49
+ return t(s ? "disabled" : "default");
54
50
  r();
55
- }, [n, u, r]);
56
- const f = { ...k, ...m }, o = f[S] ?? f.default, g = {
51
+ }, [s, l, r]);
52
+ const b = { ...E, ...m }, o = b[g] ?? b.default, w = {
57
53
  "--text-color": o.textColor,
58
54
  "--placeholder-color": o.placeholderColor,
59
55
  "--background-color": o.backgroundColor,
60
- "--radius-size": ((b = o.border) == null ? void 0 : b.radius) || ".25rem",
61
- "--input-box-shadow": `0 0 0 ${((p = o.border) == null ? void 0 : p.size) || "1px"} ${(h = o.border) == null ? void 0 : h.color} inset, ${o.boxShadow || "0 0 0 0 rgba(0, 0, 0, 0)"}`
56
+ "--radius-size": ((p = o.border) == null ? void 0 : p.radius) || ".25rem",
57
+ "--input-box-shadow": `0 0 0 ${((x = o.border) == null ? void 0 : x.size) || "1px"} ${(h = o.border) == null ? void 0 : h.color} inset, ${o.boxShadow || "0 0 0 0 rgba(0, 0, 0, 0)"}`
62
58
  };
63
- return /* @__PURE__ */ C(
59
+ return /* @__PURE__ */ y(
64
60
  "div",
65
61
  {
66
- ref: l,
62
+ ref: c,
67
63
  className: `relative inline-flex max-w-full rounded-(--radius-size) bg-(--background-color) text-(--text-color) shadow-(--input-box-shadow) has-[:disabled]:pointer-events-none has-[:disabled]:before:pointer-events-auto has-[:disabled]:before:absolute has-[:disabled]:before:inset-0 has-[:disabled]:before:cursor-not-allowed has-[:disabled]:before:content-[''] [&_*::placeholder]:font-normal [&_*::placeholder]:text-(--placeholder-color) [&_*:focus]:outline-none [&_:is(input,textarea,select)]:w-full [&_:is(input,textarea,select)]:appearance-none [&_:is(input,textarea,select)]:border-none [&_:is(input,textarea,select)]:bg-transparent [&_:is(input,textarea,select)]:p-4 [&_:is(input,textarea,select)]:outline-none ${_ || ""}`,
68
- style: g,
69
- children: w
64
+ style: w,
65
+ children: S
70
66
  }
71
67
  );
72
68
  }
@@ -1,46 +1,49 @@
1
1
  "use client";
2
- import { jsxs as m, jsx as n } from "react/jsx-runtime";
3
- import { CheckBox as h } from "./CheckBox.js";
2
+ import { jsxs as b, jsx as t } from "react/jsx-runtime";
3
+ import { useId as h } from "react";
4
+ import { CheckBox as p } from "./CheckBox.js";
4
5
  import { COLOR as r } from "@geckou/ui-core";
5
- function f({
6
- name: c,
7
- label: l,
8
- checked: d,
9
- onChange: u,
6
+ function L({
7
+ name: l,
8
+ label: d,
9
+ checked: i,
10
+ onChange: m,
10
11
  isDisabled: e,
11
12
  cssStyle: o,
12
- isDisableAnimation: x
13
+ isDisableAnimation: u
13
14
  }) {
14
- const t = d ?? !1, i = e ? o == null ? void 0 : o.disabled : o == null ? void 0 : o.default, a = {
15
+ const a = i ?? !1, n = h(), x = e ? o == null ? void 0 : o.disabled : o == null ? void 0 : o.default, c = {
15
16
  textColor: e ? r.darkGray : r.black,
16
17
  backgroundColor: e ? r.darkGray : r.blue,
17
- ...i ?? {}
18
+ ...x ?? {}
18
19
  }, k = {
19
- "--text-color": a.textColor,
20
- "--checked-color": a.backgroundColor
20
+ "--text-color": c.textColor,
21
+ "--checked-color": c.backgroundColor
21
22
  };
22
- return /* @__PURE__ */ m("label", { className: "inline-flex cursor-pointer items-center gap-[.5em] has-[input:disabled]:cursor-auto", children: [
23
- /* @__PURE__ */ n("span", { className: "pointer-events-none", children: /* @__PURE__ */ n(
24
- h,
23
+ return /* @__PURE__ */ b("label", { className: "inline-flex cursor-pointer items-center gap-[.5em] has-[button:disabled]:cursor-auto", children: [
24
+ /* @__PURE__ */ t("span", { className: "pointer-events-none", children: /* @__PURE__ */ t(
25
+ p,
25
26
  {
26
- name: c,
27
- checked: t,
28
- onChange: u,
27
+ name: l,
28
+ checked: a,
29
+ onChange: m,
29
30
  isDisabled: e,
30
31
  cssStyle: o,
31
- isDisableAnimation: x
32
+ isDisableAnimation: u,
33
+ ariaLabelledBy: n
32
34
  }
33
35
  ) }),
34
- /* @__PURE__ */ n(
36
+ /* @__PURE__ */ t(
35
37
  "span",
36
38
  {
39
+ id: n,
37
40
  style: k,
38
- className: t ? "text-(--text-color)" : "text-(--checked-color)",
39
- children: l
41
+ className: a ? "text-(--text-color)" : "text-(--checked-color)",
42
+ children: d
40
43
  }
41
44
  )
42
45
  ] });
43
46
  }
44
47
  export {
45
- f as LabeledCheckbox
48
+ L as LabeledCheckbox
46
49
  };
@@ -1,75 +1,94 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as c } from "react/jsx-runtime";
3
- import { useId as p, useRef as f, useEffect as d } from "react";
4
- const v = {
2
+ import { jsx as t, jsxs as x } from "react/jsx-runtime";
3
+ import { useId as b, useRef as n, useEffect as d } from "react";
4
+ import { createScrollLock as g, handleTabKey as w } from "@geckou/ui-core";
5
+ const h = {
5
6
  small: "max-w-[var(--mobile-lower-width,430px)]",
6
7
  medium: "max-w-[var(--desktop-lower-width,1025px)]",
7
8
  large: "max-w-[var(--contents-max-width,1440px)]"
8
9
  };
9
- function x() {
10
- return /* @__PURE__ */ e(
10
+ function y() {
11
+ return /* @__PURE__ */ t(
11
12
  "svg",
12
13
  {
13
14
  xmlns: "http://www.w3.org/2000/svg",
14
15
  viewBox: "0 -960 960 960",
15
16
  fill: "currentColor",
16
- children: /* @__PURE__ */ e("path", { d: "m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z" })
17
+ children: /* @__PURE__ */ t("path", { d: "m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z" })
17
18
  }
18
19
  );
19
20
  }
20
- function w({
21
+ function I({
21
22
  isShown: r,
22
23
  size: s = "medium",
23
- onClose: t,
24
- header: l,
25
- footer: o,
26
- children: u,
27
- ariaLabel: n
24
+ onClose: o,
25
+ header: m,
26
+ footer: u,
27
+ children: p,
28
+ ariaLabel: f
28
29
  }) {
29
- const i = p(), m = f(null);
30
- return d(() => (r ? document.body.style.overflow = "hidden" : document.body.style.overflow = "", () => {
31
- document.body.style.overflow = "";
32
- }), [r]), d(() => {
33
- var a;
34
- r && ((a = m.current) == null || a.focus());
35
- }, [r]), /* @__PURE__ */ e(
30
+ const c = b(), i = n(null), v = n(g());
31
+ d(() => {
32
+ const e = v.current;
33
+ return e.toggle(r), () => e.release();
34
+ }, [r]);
35
+ const a = n(null);
36
+ return d(() => {
37
+ var e, l;
38
+ if (r) {
39
+ a.current ?? (a.current = document.activeElement), (e = i.current) == null || e.focus();
40
+ return;
41
+ }
42
+ (l = a.current) == null || l.focus(), a.current = null;
43
+ }, [r]), d(() => {
44
+ if (!r)
45
+ return;
46
+ const e = (l) => {
47
+ if (l.key === "Escape") {
48
+ o();
49
+ return;
50
+ }
51
+ w(i.current, l, document.activeElement);
52
+ };
53
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
54
+ }, [r, o]), /* @__PURE__ */ t(
36
55
  "div",
37
56
  {
38
57
  className: `fixed top-0 left-0 z-50 flex h-dvh w-dvw cursor-pointer items-center justify-center overflow-hidden bg-[#33333380] p-[var(--sp-larger,3rem)] backdrop-blur-sm transition-opacity duration-100 max-md:px-[var(--sp-large,1.5rem)] ${r ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"}`,
39
58
  "aria-hidden": !r,
40
59
  inert: !r,
41
- onClick: (a) => {
42
- a.target === a.currentTarget && t();
60
+ onClick: (e) => {
61
+ e.target === e.currentTarget && o();
43
62
  },
44
- children: /* @__PURE__ */ c(
63
+ children: /* @__PURE__ */ x(
45
64
  "div",
46
65
  {
47
- ref: m,
66
+ ref: i,
48
67
  role: "dialog",
49
68
  "aria-modal": "true",
50
- "aria-labelledby": l ? i : void 0,
51
- "aria-label": l ? void 0 : n ?? "ダイアログ",
69
+ "aria-labelledby": m ? c : void 0,
70
+ "aria-label": m ? void 0 : f ?? "ダイアログ",
52
71
  tabIndex: -1,
53
- className: `relative flex max-h-full w-full cursor-auto flex-col rounded-[var(--radius-small,0.1875rem)] bg-white drop-shadow-[0_0_6px_#33333355] ${v[s]}`,
72
+ className: `relative flex max-h-full w-full cursor-auto flex-col rounded-[var(--radius-small,0.1875rem)] bg-white drop-shadow-[0_0_6px_#33333355] ${h[s]}`,
54
73
  children: [
55
- l && /* @__PURE__ */ e(
74
+ m && /* @__PURE__ */ t(
56
75
  "header",
57
76
  {
58
- id: i,
77
+ id: c,
59
78
  className: "border-b border-[#eee] px-[var(--sp-large,1.5rem)] py-[var(--sp-medium,0.75rem)] max-md:p-[var(--sp-medium,0.75rem)] [&>h2]:font-bold [&>h2]:text-[var(--fs-large,0.875rem)]",
60
- children: l
79
+ children: m
61
80
  }
62
81
  ),
63
- /* @__PURE__ */ e("div", { className: "flex-auto overflow-auto p-[var(--sp-large,1.5rem)] max-md:p-[var(--sp-medium,0.75rem)]", children: u }),
64
- o && /* @__PURE__ */ e("footer", { className: "flex justify-center gap-[var(--sp-large,1.5rem)] border-t border-[#eee] px-[var(--sp-large,1.5rem)] py-[var(--sp-medium,0.75rem)] max-md:gap-[var(--sp-medium,0.75rem)] max-md:p-[var(--sp-medium,0.75rem)] max-md:[&>*]:flex-auto", children: o }),
65
- /* @__PURE__ */ e(
82
+ /* @__PURE__ */ t("div", { className: "flex-auto overflow-auto p-[var(--sp-large,1.5rem)] max-md:p-[var(--sp-medium,0.75rem)]", children: p }),
83
+ u && /* @__PURE__ */ t("footer", { className: "flex justify-center gap-[var(--sp-large,1.5rem)] border-t border-[#eee] px-[var(--sp-large,1.5rem)] py-[var(--sp-medium,0.75rem)] max-md:gap-[var(--sp-medium,0.75rem)] max-md:p-[var(--sp-medium,0.75rem)] max-md:[&>*]:flex-auto", children: u }),
84
+ /* @__PURE__ */ t(
66
85
  "button",
67
86
  {
68
87
  type: "button",
69
88
  "aria-label": "閉じる",
70
89
  className: "absolute bottom-full left-full size-[var(--icon-medium,1.125rem)] cursor-pointer leading-none text-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white [&>*]:size-full",
71
- onClick: t,
72
- children: /* @__PURE__ */ e(x, {})
90
+ onClick: o,
91
+ children: /* @__PURE__ */ t(y, {})
73
92
  }
74
93
  )
75
94
  ]
@@ -79,5 +98,5 @@ function w({
79
98
  );
80
99
  }
81
100
  export {
82
- w as ModalBox
101
+ I as ModalBox
83
102
  };