@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.
- package/README.md +33 -0
- package/dist/components/CheckBox.d.ts +7 -1
- package/dist/components/CheckBox.js +37 -46
- package/dist/components/DatePicker.d.ts +8 -1
- package/dist/components/DatePicker.js +86 -79
- package/dist/components/DateRangePicker.js +60 -50
- package/dist/components/DateSelector.d.ts +11 -1
- package/dist/components/DateSelector.js +74 -62
- package/dist/components/ErrorMessage.js +7 -6
- package/dist/components/InputBox.js +36 -40
- package/dist/components/LabeledCheckbox.js +26 -23
- package/dist/components/ModalBox.js +54 -35
- package/dist/components/RadioButtons.js +45 -39
- package/dist/components/SearchableSelectBox.d.ts +3 -1
- package/dist/components/SearchableSelectBox.js +86 -43
- package/dist/components/TabUI.js +28 -27
- package/dist/components/TextBox.d.ts +15 -2
- package/dist/components/TextBox.js +54 -38
- package/dist/components/ToggleButton.d.ts +4 -1
- package/dist/components/ToggleButton.js +50 -53
- package/package.json +8 -6
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { splitDate as
|
|
5
|
-
import { InputBox as
|
|
6
|
-
import { KeyboardArrowDownIcon as
|
|
7
|
-
import { useRegisterValidation as
|
|
8
|
-
const
|
|
9
|
-
function
|
|
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:
|
|
15
|
-
type:
|
|
14
|
+
formValidationStore: k,
|
|
15
|
+
type: d = "date",
|
|
16
|
+
minYear: B,
|
|
17
|
+
maxYear: E,
|
|
18
|
+
ariaLabel: T,
|
|
19
|
+
ariaLabelledBy: u
|
|
16
20
|
}) {
|
|
17
|
-
const [
|
|
18
|
-
|
|
19
|
-
|
|
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 ?
|
|
22
|
-
),
|
|
23
|
-
|
|
25
|
+
c ? $ : $ || Y
|
|
26
|
+
), K(() => {
|
|
27
|
+
p(m ? V(m) : S);
|
|
24
28
|
}, [m]);
|
|
25
|
-
const
|
|
26
|
-
{ length:
|
|
27
|
-
(e, a) => (
|
|
28
|
-
).map((e) => ({ label: e, value: e })),
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
35
|
-
|
|
36
|
-
const a =
|
|
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
|
-
},
|
|
45
|
-
const t = { ...
|
|
48
|
+
}, h = (e, a) => {
|
|
49
|
+
const t = { ...l, [e]: a };
|
|
46
50
|
if (e !== "day" && t.day && t.month) {
|
|
47
|
-
const
|
|
48
|
-
Number(t.day) >
|
|
51
|
+
const M = I(t.year, t.month);
|
|
52
|
+
Number(t.day) > M && (t.day = String(M).padStart(2, "0"));
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
},
|
|
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",
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
-
/* @__PURE__ */
|
|
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:
|
|
64
|
+
value: l.year,
|
|
61
65
|
name: `${n}-year`,
|
|
66
|
+
...v("年"),
|
|
62
67
|
required: c,
|
|
63
|
-
onChange: (e) =>
|
|
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__ */
|
|
67
|
-
|
|
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__ */
|
|
76
|
+
/* @__PURE__ */ r(g, { className: b })
|
|
72
77
|
] }),
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */
|
|
78
|
+
/* @__PURE__ */ o("div", { className: f, style: N, onClick: y, children: [
|
|
79
|
+
/* @__PURE__ */ o(
|
|
75
80
|
"select",
|
|
76
81
|
{
|
|
77
|
-
value:
|
|
82
|
+
value: l.month,
|
|
78
83
|
name: `${n}-month`,
|
|
84
|
+
...v("月"),
|
|
79
85
|
required: c,
|
|
80
|
-
onChange: (e) =>
|
|
81
|
-
className:
|
|
86
|
+
onChange: (e) => h("month", e.target.value),
|
|
87
|
+
className: A,
|
|
82
88
|
children: [
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
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__ */
|
|
94
|
+
/* @__PURE__ */ r(g, { className: b })
|
|
89
95
|
] }),
|
|
90
|
-
|
|
96
|
+
d === "date" && /* @__PURE__ */ o(
|
|
91
97
|
"div",
|
|
92
98
|
{
|
|
93
|
-
className:
|
|
94
|
-
style:
|
|
95
|
-
onClick:
|
|
99
|
+
className: f,
|
|
100
|
+
style: N,
|
|
101
|
+
onClick: y,
|
|
96
102
|
children: [
|
|
97
|
-
/* @__PURE__ */
|
|
103
|
+
/* @__PURE__ */ o(
|
|
98
104
|
"select",
|
|
99
105
|
{
|
|
100
|
-
value:
|
|
106
|
+
value: l.day,
|
|
101
107
|
name: `${n}-day`,
|
|
108
|
+
...v("日"),
|
|
102
109
|
required: c,
|
|
103
|
-
onChange: (e) =>
|
|
104
|
-
className:
|
|
110
|
+
onChange: (e) => h("day", e.target.value),
|
|
111
|
+
className: A,
|
|
105
112
|
children: [
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
|
|
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__ */
|
|
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:
|
|
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: () =>
|
|
133
|
+
onClick: () => x(S),
|
|
122
134
|
children: "削除"
|
|
123
135
|
}
|
|
124
136
|
)
|
|
125
137
|
] });
|
|
126
138
|
}
|
|
127
139
|
export {
|
|
128
|
-
|
|
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
|
|
4
|
-
if (!
|
|
3
|
+
function f({ errorMessages: o, cssStyle: r }) {
|
|
4
|
+
if (!o || !o.length)
|
|
5
5
|
return null;
|
|
6
6
|
const b = {
|
|
7
|
-
"--error-text-color": (
|
|
8
|
-
"--error-background-color": (
|
|
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:
|
|
16
|
+
children: o.map((e) => /* @__PURE__ */ n("span", { children: e }, e))
|
|
16
17
|
}
|
|
17
18
|
);
|
|
18
19
|
}
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
+
f as ErrorMessage
|
|
21
22
|
};
|
|
@@ -1,72 +1,68 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { INPUT_BOX_DEFAULT_STYLES as
|
|
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:
|
|
8
|
-
isDisabled:
|
|
7
|
+
isErrored: l,
|
|
8
|
+
isDisabled: s,
|
|
9
9
|
className: _,
|
|
10
|
-
children:
|
|
10
|
+
children: S
|
|
11
11
|
}) {
|
|
12
|
-
var
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const r =
|
|
16
|
-
var
|
|
17
|
-
const e =
|
|
18
|
-
|
|
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.
|
|
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.
|
|
28
|
+
if (e.every((n) => n.value !== ""))
|
|
33
29
|
return t("valid");
|
|
34
30
|
t("default");
|
|
35
31
|
}, []);
|
|
36
32
|
v(() => {
|
|
37
|
-
const e =
|
|
33
|
+
const e = c.current;
|
|
38
34
|
if (!e)
|
|
39
35
|
return;
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
|
|
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
|
|
41
|
+
const d = u(!0), f = u(s);
|
|
46
42
|
v(() => {
|
|
47
|
-
const e =
|
|
48
|
-
if (
|
|
49
|
-
|
|
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(
|
|
49
|
+
return t(s ? "disabled" : "default");
|
|
54
50
|
r();
|
|
55
|
-
}, [
|
|
56
|
-
const
|
|
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": ((
|
|
61
|
-
"--input-box-shadow": `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__ */
|
|
59
|
+
return /* @__PURE__ */ y(
|
|
64
60
|
"div",
|
|
65
61
|
{
|
|
66
|
-
ref:
|
|
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:
|
|
69
|
-
children:
|
|
64
|
+
style: w,
|
|
65
|
+
children: S
|
|
70
66
|
}
|
|
71
67
|
);
|
|
72
68
|
}
|
|
@@ -1,46 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import {
|
|
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
|
|
6
|
-
name:
|
|
7
|
-
label:
|
|
8
|
-
checked:
|
|
9
|
-
onChange:
|
|
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:
|
|
13
|
+
isDisableAnimation: u
|
|
13
14
|
}) {
|
|
14
|
-
const
|
|
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
|
-
...
|
|
18
|
+
...x ?? {}
|
|
18
19
|
}, k = {
|
|
19
|
-
"--text-color":
|
|
20
|
-
"--checked-color":
|
|
20
|
+
"--text-color": c.textColor,
|
|
21
|
+
"--checked-color": c.backgroundColor
|
|
21
22
|
};
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
-
|
|
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:
|
|
27
|
-
checked:
|
|
28
|
-
onChange:
|
|
27
|
+
name: l,
|
|
28
|
+
checked: a,
|
|
29
|
+
onChange: m,
|
|
29
30
|
isDisabled: e,
|
|
30
31
|
cssStyle: o,
|
|
31
|
-
isDisableAnimation:
|
|
32
|
+
isDisableAnimation: u,
|
|
33
|
+
ariaLabelledBy: n
|
|
32
34
|
}
|
|
33
35
|
) }),
|
|
34
|
-
/* @__PURE__ */
|
|
36
|
+
/* @__PURE__ */ t(
|
|
35
37
|
"span",
|
|
36
38
|
{
|
|
39
|
+
id: n,
|
|
37
40
|
style: k,
|
|
38
|
-
className:
|
|
39
|
-
children:
|
|
41
|
+
className: a ? "text-(--text-color)" : "text-(--checked-color)",
|
|
42
|
+
children: d
|
|
40
43
|
}
|
|
41
44
|
)
|
|
42
45
|
] });
|
|
43
46
|
}
|
|
44
47
|
export {
|
|
45
|
-
|
|
48
|
+
L as LabeledCheckbox
|
|
46
49
|
};
|
|
@@ -1,75 +1,94 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useId as
|
|
4
|
-
|
|
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
|
|
10
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
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
|
|
21
|
+
function I({
|
|
21
22
|
isShown: r,
|
|
22
23
|
size: s = "medium",
|
|
23
|
-
onClose:
|
|
24
|
-
header:
|
|
25
|
-
footer:
|
|
26
|
-
children:
|
|
27
|
-
ariaLabel:
|
|
24
|
+
onClose: o,
|
|
25
|
+
header: m,
|
|
26
|
+
footer: u,
|
|
27
|
+
children: p,
|
|
28
|
+
ariaLabel: f
|
|
28
29
|
}) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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: (
|
|
42
|
-
|
|
60
|
+
onClick: (e) => {
|
|
61
|
+
e.target === e.currentTarget && o();
|
|
43
62
|
},
|
|
44
|
-
children: /* @__PURE__ */
|
|
63
|
+
children: /* @__PURE__ */ x(
|
|
45
64
|
"div",
|
|
46
65
|
{
|
|
47
|
-
ref:
|
|
66
|
+
ref: i,
|
|
48
67
|
role: "dialog",
|
|
49
68
|
"aria-modal": "true",
|
|
50
|
-
"aria-labelledby":
|
|
51
|
-
"aria-label":
|
|
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] ${
|
|
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
|
-
|
|
74
|
+
m && /* @__PURE__ */ t(
|
|
56
75
|
"header",
|
|
57
76
|
{
|
|
58
|
-
id:
|
|
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:
|
|
79
|
+
children: m
|
|
61
80
|
}
|
|
62
81
|
),
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
|
|
65
|
-
/* @__PURE__ */
|
|
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:
|
|
72
|
-
children: /* @__PURE__ */
|
|
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
|
-
|
|
101
|
+
I as ModalBox
|
|
83
102
|
};
|