@geckou/ui-react 0.5.1 → 0.7.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 +37 -0
- package/dist/components/CheckBox.d.ts +7 -1
- package/dist/components/CheckBox.js +28 -19
- package/dist/components/CheckBoxes.js +26 -25
- package/dist/components/DatePicker.js +112 -97
- package/dist/components/DateRangePicker.js +47 -47
- package/dist/components/ErrorMessage.js +10 -10
- package/dist/components/LabeledCheckbox.d.ts +3 -1
- package/dist/components/LabeledCheckbox.js +18 -16
- package/dist/components/ModalBox.js +35 -30
- package/dist/components/PopupBox.js +4 -3
- package/dist/components/SearchableSelectBox.d.ts +2 -1
- package/dist/components/SearchableSelectBox.js +57 -50
- package/dist/components/SelectBox.js +54 -53
- package/dist/components/SlideDownUi.js +9 -9
- package/dist/components/TextArea.js +51 -43
- package/dist/components/TextBox.d.ts +3 -1
- package/dist/components/TextBox.js +62 -60
- package/dist/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { COLOR as
|
|
3
|
-
function
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { COLOR as n } from "@geckou/ui-core";
|
|
3
|
+
function m({ errorMessages: o, cssStyle: r }) {
|
|
4
4
|
if (!o || !o.length)
|
|
5
5
|
return null;
|
|
6
|
-
const
|
|
7
|
-
"--error-text-color": (r == null ? void 0 : r.textColor) ||
|
|
8
|
-
"--error-background-color": (r == null ? void 0 : r.backgroundColor) ||
|
|
6
|
+
const t = {
|
|
7
|
+
"--error-text-color": (r == null ? void 0 : r.textColor) || n.white,
|
|
8
|
+
"--error-background-color": (r == null ? void 0 : r.backgroundColor) || n.red
|
|
9
9
|
};
|
|
10
|
-
return /* @__PURE__ */
|
|
10
|
+
return /* @__PURE__ */ e(
|
|
11
11
|
"div",
|
|
12
12
|
{
|
|
13
13
|
role: "alert",
|
|
14
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%)]",
|
|
15
|
-
style:
|
|
16
|
-
children: o.map((
|
|
15
|
+
style: t,
|
|
16
|
+
children: o.map((b, l) => /* @__PURE__ */ e("span", { children: b }, l))
|
|
17
17
|
}
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
m as ErrorMessage
|
|
22
22
|
};
|
|
@@ -2,11 +2,13 @@ import { CheckBoxStyleForEachStatus } from '../types';
|
|
|
2
2
|
type Props = {
|
|
3
3
|
name: string;
|
|
4
4
|
label: string;
|
|
5
|
+
/** ネイティブ送信時の値(→ CheckBox の value) */
|
|
6
|
+
value?: string | number;
|
|
5
7
|
checked?: boolean;
|
|
6
8
|
onChange?: (newValue: boolean) => void;
|
|
7
9
|
isDisabled?: boolean;
|
|
8
10
|
cssStyle?: CheckBoxStyleForEachStatus;
|
|
9
11
|
isDisableAnimation?: boolean;
|
|
10
12
|
};
|
|
11
|
-
export declare function LabeledCheckbox({ name, label, checked, onChange, isDisabled, cssStyle, isDisableAnimation, }: Props): import("react").JSX.Element;
|
|
13
|
+
export declare function LabeledCheckbox({ name, label, value, checked, onChange, isDisabled, cssStyle, isDisableAnimation, }: Props): import("react").JSX.Element;
|
|
12
14
|
export {};
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { CheckBox as
|
|
2
|
+
import { jsxs as h, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { useId as p } from "react";
|
|
4
|
+
import { CheckBox as C } from "./CheckBox.js";
|
|
5
5
|
import { COLOR as r } from "@geckou/ui-core";
|
|
6
|
-
function
|
|
6
|
+
function N({
|
|
7
7
|
name: l,
|
|
8
8
|
label: d,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
value: i,
|
|
10
|
+
checked: m,
|
|
11
|
+
onChange: u,
|
|
11
12
|
isDisabled: e,
|
|
12
13
|
cssStyle: o,
|
|
13
|
-
isDisableAnimation:
|
|
14
|
+
isDisableAnimation: x
|
|
14
15
|
}) {
|
|
15
|
-
const a =
|
|
16
|
+
const a = m ?? !1, n = p(), k = e ? o == null ? void 0 : o.disabled : o == null ? void 0 : o.default, c = {
|
|
16
17
|
textColor: e ? r.darkGray : r.black,
|
|
17
18
|
backgroundColor: e ? r.darkGray : r.blue,
|
|
18
|
-
...
|
|
19
|
-
},
|
|
19
|
+
...k ?? {}
|
|
20
|
+
}, b = {
|
|
20
21
|
"--text-color": c.textColor,
|
|
21
22
|
"--checked-color": c.backgroundColor
|
|
22
23
|
};
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
+
return /* @__PURE__ */ h("label", { className: "inline-flex cursor-pointer items-center gap-[.5em] has-[button:disabled]:cursor-auto", children: [
|
|
24
25
|
/* @__PURE__ */ t("span", { className: "pointer-events-none", children: /* @__PURE__ */ t(
|
|
25
|
-
|
|
26
|
+
C,
|
|
26
27
|
{
|
|
27
28
|
name: l,
|
|
29
|
+
value: i,
|
|
28
30
|
checked: a,
|
|
29
|
-
onChange:
|
|
31
|
+
onChange: u,
|
|
30
32
|
isDisabled: e,
|
|
31
33
|
cssStyle: o,
|
|
32
|
-
isDisableAnimation:
|
|
34
|
+
isDisableAnimation: x,
|
|
33
35
|
ariaLabelledBy: n
|
|
34
36
|
}
|
|
35
37
|
) }),
|
|
@@ -37,7 +39,7 @@ function L({
|
|
|
37
39
|
"span",
|
|
38
40
|
{
|
|
39
41
|
id: n,
|
|
40
|
-
style:
|
|
42
|
+
style: b,
|
|
41
43
|
className: a ? "text-(--text-color)" : "text-(--checked-color)",
|
|
42
44
|
children: d
|
|
43
45
|
}
|
|
@@ -45,5 +47,5 @@ function L({
|
|
|
45
47
|
] });
|
|
46
48
|
}
|
|
47
49
|
export {
|
|
48
|
-
|
|
50
|
+
N as LabeledCheckbox
|
|
49
51
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as t, jsxs as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { createScrollLock as
|
|
5
|
-
const
|
|
2
|
+
import { jsx as t, jsxs as b } from "react/jsx-runtime";
|
|
3
|
+
import { useId as g, useRef as i, useEffect as u } from "react";
|
|
4
|
+
import { createScrollLock as y, createModalLayer as w, handleTabKey as h } from "@geckou/ui-core";
|
|
5
|
+
const k = {
|
|
6
6
|
small: "max-w-[var(--mobile-lower-width,430px)]",
|
|
7
7
|
medium: "max-w-[var(--desktop-lower-width,1025px)]",
|
|
8
8
|
large: "max-w-[var(--contents-max-width,1440px)]"
|
|
9
9
|
};
|
|
10
|
-
function
|
|
10
|
+
function E() {
|
|
11
11
|
return /* @__PURE__ */ t(
|
|
12
12
|
"svg",
|
|
13
13
|
{
|
|
@@ -18,38 +18,43 @@ function y() {
|
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function _({
|
|
22
22
|
isShown: r,
|
|
23
|
-
size:
|
|
23
|
+
size: p = "medium",
|
|
24
24
|
onClose: o,
|
|
25
|
-
header:
|
|
26
|
-
footer:
|
|
27
|
-
children:
|
|
28
|
-
ariaLabel:
|
|
25
|
+
header: n,
|
|
26
|
+
footer: d,
|
|
27
|
+
children: f,
|
|
28
|
+
ariaLabel: v
|
|
29
29
|
}) {
|
|
30
|
-
const c =
|
|
31
|
-
|
|
32
|
-
const e =
|
|
30
|
+
const c = g(), m = i(null), x = i(y());
|
|
31
|
+
u(() => {
|
|
32
|
+
const e = x.current;
|
|
33
33
|
return e.toggle(r), () => e.release();
|
|
34
34
|
}, [r]);
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const s = i(w());
|
|
36
|
+
u(() => {
|
|
37
|
+
const e = s.current;
|
|
38
|
+
return e.toggle(r, m.current), () => e.release();
|
|
39
|
+
}, [r]);
|
|
40
|
+
const l = i(null);
|
|
41
|
+
return u(() => {
|
|
37
42
|
var e, a;
|
|
38
43
|
if (r) {
|
|
39
44
|
l.current ?? (l.current = document.activeElement), (e = m.current) == null || e.focus();
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
42
47
|
(a = l.current) == null || a.focus(), l.current = null;
|
|
43
|
-
}, [r]),
|
|
48
|
+
}, [r]), u(() => {
|
|
44
49
|
if (!r)
|
|
45
50
|
return;
|
|
46
51
|
const e = (a) => {
|
|
47
|
-
if (!a.defaultPrevented) {
|
|
52
|
+
if (s.current.isTopmost() && !a.defaultPrevented) {
|
|
48
53
|
if (a.key === "Escape") {
|
|
49
|
-
o();
|
|
54
|
+
a.preventDefault(), o();
|
|
50
55
|
return;
|
|
51
56
|
}
|
|
52
|
-
|
|
57
|
+
h(m.current, a, document.activeElement);
|
|
53
58
|
}
|
|
54
59
|
};
|
|
55
60
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
@@ -62,27 +67,27 @@ function I({
|
|
|
62
67
|
onClick: (e) => {
|
|
63
68
|
e.target === e.currentTarget && o();
|
|
64
69
|
},
|
|
65
|
-
children: /* @__PURE__ */
|
|
70
|
+
children: /* @__PURE__ */ b(
|
|
66
71
|
"div",
|
|
67
72
|
{
|
|
68
73
|
ref: m,
|
|
69
74
|
role: "dialog",
|
|
70
75
|
"aria-modal": "true",
|
|
71
|
-
"aria-labelledby":
|
|
72
|
-
"aria-label":
|
|
76
|
+
"aria-labelledby": n ? c : void 0,
|
|
77
|
+
"aria-label": n ? void 0 : v ?? "ダイアログ",
|
|
73
78
|
tabIndex: -1,
|
|
74
|
-
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] ${
|
|
79
|
+
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] ${k[p]}`,
|
|
75
80
|
children: [
|
|
76
|
-
|
|
81
|
+
n && /* @__PURE__ */ t(
|
|
77
82
|
"header",
|
|
78
83
|
{
|
|
79
84
|
id: c,
|
|
80
85
|
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)]",
|
|
81
|
-
children:
|
|
86
|
+
children: n
|
|
82
87
|
}
|
|
83
88
|
),
|
|
84
|
-
/* @__PURE__ */ t("div", { className: "flex-auto overflow-auto p-[var(--sp-large,1.5rem)] max-md:p-[var(--sp-medium,0.75rem)]", children:
|
|
85
|
-
|
|
89
|
+
/* @__PURE__ */ t("div", { className: "flex-auto overflow-auto p-[var(--sp-large,1.5rem)] max-md:p-[var(--sp-medium,0.75rem)]", children: f }),
|
|
90
|
+
d && /* @__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: d }),
|
|
86
91
|
/* @__PURE__ */ t(
|
|
87
92
|
"button",
|
|
88
93
|
{
|
|
@@ -90,7 +95,7 @@ function I({
|
|
|
90
95
|
"aria-label": "閉じる",
|
|
91
96
|
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",
|
|
92
97
|
onClick: o,
|
|
93
|
-
children: /* @__PURE__ */ t(
|
|
98
|
+
children: /* @__PURE__ */ t(E, {})
|
|
94
99
|
}
|
|
95
100
|
)
|
|
96
101
|
]
|
|
@@ -100,5 +105,5 @@ function I({
|
|
|
100
105
|
);
|
|
101
106
|
}
|
|
102
107
|
export {
|
|
103
|
-
|
|
108
|
+
_ as ModalBox
|
|
104
109
|
};
|
|
@@ -17,19 +17,20 @@ function y({
|
|
|
17
17
|
ref: n,
|
|
18
18
|
children: m
|
|
19
19
|
}) {
|
|
20
|
-
const [
|
|
20
|
+
const [s, r] = o(!1), [u, a] = o(!1), e = c(null);
|
|
21
21
|
return l(() => (a(!0), () => {
|
|
22
22
|
e.current && clearTimeout(e.current);
|
|
23
23
|
}), []), f(n, () => ({
|
|
24
24
|
showPopup: () => {
|
|
25
25
|
r(!0), e.current && clearTimeout(e.current), e.current = setTimeout(() => r(!1), 3e3);
|
|
26
26
|
}
|
|
27
|
-
})),
|
|
27
|
+
})), u ? p(
|
|
28
28
|
/* @__PURE__ */ i(
|
|
29
29
|
"div",
|
|
30
30
|
{
|
|
31
|
+
role: "status",
|
|
31
32
|
style: { borderColor: d.blue },
|
|
32
|
-
className: `pointer-events-none fixed z-50 h-max w-max max-w-40 rounded-[var(--radius-small,0.1875rem)] border bg-white p-[var(--sp-medium,0.75rem)] transition-[transform,opacity] duration-300 ${x[t.x]} ${S[t.y]} ${
|
|
33
|
+
className: `pointer-events-none fixed z-50 h-max w-max max-w-40 rounded-[var(--radius-small,0.1875rem)] border bg-white p-[var(--sp-medium,0.75rem)] transition-[transform,opacity] duration-300 ${x[t.x]} ${S[t.y]} ${s ? "opacity-100" : "opacity-0"}`,
|
|
33
34
|
children: m
|
|
34
35
|
}
|
|
35
36
|
),
|
|
@@ -11,6 +11,7 @@ type Props = {
|
|
|
11
11
|
cssStyle?: InputBoxStyleForEachStatus;
|
|
12
12
|
/** combobox のアクセシブル名。可視ラベルがあるならそちらを ariaLabelledBy で指すこと */
|
|
13
13
|
ariaLabel?: string;
|
|
14
|
+
ariaLabelledBy?: string;
|
|
14
15
|
};
|
|
15
|
-
export declare function SearchableSelectBox({ options, value, onChange, onSelect, name, placeholder, isDisabled, searchTarget, cssStyle, ariaLabel, }: Props): import("react").JSX.Element;
|
|
16
|
+
export declare function SearchableSelectBox({ options, value, onChange, onSelect, name, placeholder, isDisabled, searchTarget, cssStyle, ariaLabel, ariaLabelledBy, }: Props): import("react").JSX.Element;
|
|
16
17
|
export {};
|
|
@@ -1,96 +1,103 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as v, useRef as
|
|
4
|
-
import { TextBox as
|
|
5
|
-
function
|
|
6
|
-
options:
|
|
2
|
+
import { jsxs as $, jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import { useState as v, useRef as A, useId as j, useEffect as I } from "react";
|
|
4
|
+
import { TextBox as K } from "./TextBox.js";
|
|
5
|
+
function z({
|
|
6
|
+
options: w,
|
|
7
7
|
value: o,
|
|
8
8
|
onChange: s,
|
|
9
9
|
onSelect: d,
|
|
10
|
-
name:
|
|
11
|
-
placeholder:
|
|
12
|
-
isDisabled:
|
|
13
|
-
searchTarget:
|
|
14
|
-
cssStyle:
|
|
15
|
-
ariaLabel:
|
|
10
|
+
name: g,
|
|
11
|
+
placeholder: O = "入力してください",
|
|
12
|
+
isDisabled: B,
|
|
13
|
+
searchTarget: L = "label",
|
|
14
|
+
cssStyle: S,
|
|
15
|
+
ariaLabel: F,
|
|
16
|
+
ariaLabelledBy: N
|
|
16
17
|
}) {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, [o]),
|
|
18
|
+
const b = (e) => {
|
|
19
|
+
var r;
|
|
20
|
+
return ((r = w.find((t) => String(t.value) === e)) == null ? void 0 : r.label) ?? e;
|
|
21
|
+
}, [u, f] = v(() => b(o)), [h, a] = v(!1), [i, l] = v(-1), x = A(null), p = j(), D = (e) => `${p}-option-${e}`, E = A(o);
|
|
22
|
+
I(() => {
|
|
23
|
+
E.current !== o && (E.current = o, f(b(o)));
|
|
24
|
+
}, [o]), I(() => {
|
|
21
25
|
const e = (r) => {
|
|
22
26
|
const t = x.current;
|
|
23
27
|
t && !t.contains(r.target) && a(!1);
|
|
24
28
|
};
|
|
25
29
|
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
26
30
|
}, []);
|
|
27
|
-
const
|
|
28
|
-
(e) => String(e[
|
|
29
|
-
) :
|
|
31
|
+
const y = w.filter((e) => !e.isDisabled), n = u ? y.filter(
|
|
32
|
+
(e) => String(e[L]).toLowerCase().includes(u.toLowerCase())
|
|
33
|
+
) : y, V = (e) => {
|
|
30
34
|
const r = String(e);
|
|
31
|
-
f(r), a(!!r),
|
|
32
|
-
},
|
|
35
|
+
f(r), a(!!r), l(-1), s == null || s(r);
|
|
36
|
+
}, k = (e) => {
|
|
37
|
+
if (e.isDisabled)
|
|
38
|
+
return;
|
|
33
39
|
const r = e.value.toString();
|
|
34
|
-
f(
|
|
35
|
-
}, c =
|
|
40
|
+
f(e.label), a(!1), l(-1), s == null || s(r), d == null || d(r);
|
|
41
|
+
}, c = h && n.length > 0, _ = (e) => {
|
|
36
42
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
37
|
-
if (e.preventDefault(), !
|
|
38
|
-
a(!0),
|
|
39
|
-
e.key === "ArrowDown" ? 0 :
|
|
43
|
+
if (e.preventDefault(), !h) {
|
|
44
|
+
a(!0), l(
|
|
45
|
+
e.key === "ArrowDown" ? 0 : n.length - 1
|
|
40
46
|
);
|
|
41
47
|
return;
|
|
42
48
|
}
|
|
43
|
-
if (
|
|
49
|
+
if (n.length === 0)
|
|
44
50
|
return;
|
|
45
|
-
|
|
46
|
-
const t =
|
|
51
|
+
l((r) => {
|
|
52
|
+
const t = n.length - 1;
|
|
47
53
|
return e.key === "ArrowDown" ? r >= t ? 0 : r + 1 : r <= 0 ? t : r - 1;
|
|
48
54
|
});
|
|
49
55
|
return;
|
|
50
56
|
}
|
|
51
57
|
if (e.key === "Enter") {
|
|
52
|
-
const r = c ?
|
|
53
|
-
r && (e.preventDefault(),
|
|
58
|
+
const r = c ? n[i] : void 0;
|
|
59
|
+
r && (e.preventDefault(), k(r));
|
|
54
60
|
return;
|
|
55
61
|
}
|
|
56
|
-
e.key === "Escape" &&
|
|
62
|
+
e.key === "Escape" && c && (e.preventDefault(), a(!1), l(-1));
|
|
57
63
|
};
|
|
58
|
-
return /* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
|
|
64
|
+
return /* @__PURE__ */ $("div", { ref: x, className: "relative", children: [
|
|
65
|
+
/* @__PURE__ */ m(
|
|
66
|
+
K,
|
|
61
67
|
{
|
|
62
|
-
name:
|
|
68
|
+
name: g,
|
|
63
69
|
value: u,
|
|
64
|
-
onChange:
|
|
65
|
-
isDisabled:
|
|
66
|
-
placeholder:
|
|
67
|
-
cssStyle:
|
|
70
|
+
onChange: V,
|
|
71
|
+
isDisabled: B,
|
|
72
|
+
placeholder: O,
|
|
73
|
+
cssStyle: S,
|
|
68
74
|
role: "combobox",
|
|
69
|
-
ariaLabel:
|
|
75
|
+
ariaLabel: F,
|
|
76
|
+
ariaLabelledBy: N,
|
|
70
77
|
ariaAutocomplete: "list",
|
|
71
78
|
ariaExpanded: c,
|
|
72
|
-
ariaControls:
|
|
73
|
-
ariaActivedescendant: c && i >= 0 ?
|
|
74
|
-
onKeyDown:
|
|
79
|
+
ariaControls: p,
|
|
80
|
+
ariaActivedescendant: c && i >= 0 ? D(i) : void 0,
|
|
81
|
+
onKeyDown: _
|
|
75
82
|
}
|
|
76
83
|
),
|
|
77
|
-
c && /* @__PURE__ */
|
|
84
|
+
c && /* @__PURE__ */ m(
|
|
78
85
|
"div",
|
|
79
86
|
{
|
|
80
|
-
id:
|
|
87
|
+
id: p,
|
|
81
88
|
role: "listbox",
|
|
82
89
|
className: "absolute top-[calc(100%-var(--sp-min,0.1875rem))] left-0 z-[2] max-h-[calc(var(--bv,0.375rem)*56)] min-w-full overflow-auto rounded-[var(--radius-small,0.1875rem)] bg-white py-[var(--sp-small,0.375rem)] shadow-[0_0_6px_#33333333]",
|
|
83
|
-
children:
|
|
90
|
+
children: n.map((e, r) => /* @__PURE__ */ m(
|
|
84
91
|
"div",
|
|
85
92
|
{
|
|
86
|
-
id:
|
|
93
|
+
id: D(r),
|
|
87
94
|
role: "option",
|
|
88
95
|
"aria-selected": r === i,
|
|
89
96
|
className: `block w-full cursor-pointer p-[var(--sp-medium,0.75rem)] text-left text-[length:var(--fs-small,0.6875rem)] text-[var(--link-color,#1c4ac9)] hover:bg-[var(--hover-color,#EEF7FB)] hover:transition-all hover:duration-100 ${r === i ? "bg-[var(--hover-color,#EEF7FB)]" : ""}`,
|
|
90
97
|
onPointerDown: (t) => {
|
|
91
|
-
t.preventDefault(),
|
|
98
|
+
t.preventDefault(), k(e);
|
|
92
99
|
},
|
|
93
|
-
onMouseEnter: () =>
|
|
100
|
+
onMouseEnter: () => l(r),
|
|
94
101
|
children: e.label
|
|
95
102
|
},
|
|
96
103
|
e.value
|
|
@@ -100,5 +107,5 @@ function R({
|
|
|
100
107
|
] });
|
|
101
108
|
}
|
|
102
109
|
export {
|
|
103
|
-
|
|
110
|
+
z as SearchableSelectBox
|
|
104
111
|
};
|
|
@@ -1,69 +1,70 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as d, jsx as r } from "react/jsx-runtime";
|
|
3
3
|
import { MESSAGES as I } from "@geckou/ui-core";
|
|
4
|
-
import { useState as
|
|
5
|
-
import { InputBox as
|
|
6
|
-
import { ErrorMessage as
|
|
4
|
+
import { useState as N, useRef as p, useEffect as O, Fragment as V } from "react";
|
|
5
|
+
import { InputBox as q } from "./InputBox.js";
|
|
6
|
+
import { ErrorMessage as w } from "./ErrorMessage.js";
|
|
7
7
|
import { KeyboardArrowDownIcon as F } from "./icons/KeyboardArrowDownIcon.js";
|
|
8
|
-
function
|
|
9
|
-
return typeof
|
|
8
|
+
function g(l) {
|
|
9
|
+
return typeof l == "object" && l !== null && "label" in l && typeof l.label == "string" && "value" in l;
|
|
10
10
|
}
|
|
11
11
|
function P({
|
|
12
|
-
options:
|
|
13
|
-
name:
|
|
14
|
-
value:
|
|
12
|
+
options: l,
|
|
13
|
+
name: E,
|
|
14
|
+
value: M,
|
|
15
15
|
onChange: u,
|
|
16
|
-
cssStyle:
|
|
17
|
-
placeholder:
|
|
18
|
-
canOmitSelect:
|
|
19
|
-
isDisabled:
|
|
20
|
-
isRequired:
|
|
21
|
-
arrow:
|
|
16
|
+
cssStyle: t,
|
|
17
|
+
placeholder: f = "選択してください",
|
|
18
|
+
canOmitSelect: B,
|
|
19
|
+
isDisabled: m,
|
|
20
|
+
isRequired: v,
|
|
21
|
+
arrow: C
|
|
22
22
|
}) {
|
|
23
|
-
var b,
|
|
24
|
-
const [
|
|
23
|
+
var b, x;
|
|
24
|
+
const [s, j] = N([]), a = M ?? "", o = () => {
|
|
25
25
|
const e = [];
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
if (!
|
|
30
|
-
if (
|
|
31
|
-
|
|
26
|
+
a === "" && v && e.push(I.required), j(e);
|
|
27
|
+
}, k = p(a), h = p(!1);
|
|
28
|
+
O(() => {
|
|
29
|
+
if (!h.current) {
|
|
30
|
+
if (a === k.current) {
|
|
31
|
+
a !== "" && o();
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
h.current = !0;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
const
|
|
39
|
-
(e) =>
|
|
40
|
-
),
|
|
41
|
-
const n =
|
|
42
|
-
(
|
|
36
|
+
o();
|
|
37
|
+
}, [a]);
|
|
38
|
+
const A = l.flatMap(
|
|
39
|
+
(e) => g(e) ? [e] : Object.values(e).flat()
|
|
40
|
+
), D = (e) => {
|
|
41
|
+
const n = A.find(
|
|
42
|
+
(c) => String(c.value) === e
|
|
43
43
|
);
|
|
44
44
|
u == null || u(n ? n.value : e);
|
|
45
45
|
};
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
|
|
46
|
+
return /* @__PURE__ */ d(
|
|
47
|
+
q,
|
|
48
48
|
{
|
|
49
|
-
cssStyle:
|
|
49
|
+
cssStyle: t,
|
|
50
50
|
className: "inline-flex [&>select]:flex-auto [&>select]:cursor-pointer [&>select]:pe-8",
|
|
51
|
-
isDisabled:
|
|
51
|
+
isDisabled: m,
|
|
52
|
+
isErrored: !!s.length,
|
|
52
53
|
children: [
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ d(
|
|
54
55
|
"select",
|
|
55
56
|
{
|
|
56
|
-
name:
|
|
57
|
-
value:
|
|
58
|
-
disabled:
|
|
59
|
-
required:
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
name: E,
|
|
58
|
+
value: a,
|
|
59
|
+
disabled: m,
|
|
60
|
+
required: v,
|
|
61
|
+
"aria-invalid": s.length > 0 || void 0,
|
|
62
|
+
onChange: (e) => D(e.target.value),
|
|
63
|
+
onBlur: () => o(),
|
|
62
64
|
children: [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
(e) => p(e) ? /* @__PURE__ */ r(
|
|
65
|
+
B ? /* @__PURE__ */ r("option", { value: "", children: f || "選択しない" }) : /* @__PURE__ */ r("option", { disabled: !0, value: "", children: f || "選択してください" }),
|
|
66
|
+
l.map(
|
|
67
|
+
(e) => g(e) ? /* @__PURE__ */ r(
|
|
67
68
|
"option",
|
|
68
69
|
{
|
|
69
70
|
value: e.value,
|
|
@@ -71,8 +72,8 @@ function P({
|
|
|
71
72
|
children: e.label
|
|
72
73
|
},
|
|
73
74
|
e.value
|
|
74
|
-
) : /* @__PURE__ */
|
|
75
|
-
Object.entries(e).map(([n,
|
|
75
|
+
) : /* @__PURE__ */ d(V, { children: [
|
|
76
|
+
Object.entries(e).map(([n, c]) => /* @__PURE__ */ r("optgroup", { label: n, children: c.map((i) => /* @__PURE__ */ r(
|
|
76
77
|
"option",
|
|
77
78
|
{
|
|
78
79
|
value: i.value,
|
|
@@ -87,14 +88,14 @@ function P({
|
|
|
87
88
|
]
|
|
88
89
|
}
|
|
89
90
|
),
|
|
90
|
-
/* @__PURE__ */ r("div", { className: "pointer-events-none absolute inset-y-0 end-2 flex items-center [&>*]:h-4 [&>*]:fill-current [&>*]:text-current", children:
|
|
91
|
+
/* @__PURE__ */ r("div", { className: "pointer-events-none absolute inset-y-0 end-2 flex items-center [&>*]:h-4 [&>*]:fill-current [&>*]:text-current", children: C ?? /* @__PURE__ */ r(F, {}) }),
|
|
91
92
|
/* @__PURE__ */ r(
|
|
92
|
-
|
|
93
|
+
w,
|
|
93
94
|
{
|
|
94
|
-
errorMessages:
|
|
95
|
+
errorMessages: s,
|
|
95
96
|
cssStyle: {
|
|
96
|
-
textColor: (b =
|
|
97
|
-
backgroundColor: (
|
|
97
|
+
textColor: (b = t == null ? void 0 : t.error) == null ? void 0 : b.backgroundColor,
|
|
98
|
+
backgroundColor: (x = t == null ? void 0 : t.error) == null ? void 0 : x.textColor
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as v, jsx as i } from "react/jsx-runtime";
|
|
3
|
-
import { useState as a, useRef as
|
|
3
|
+
import { useState as a, useRef as p, useImperativeHandle as E, useEffect as l } from "react";
|
|
4
4
|
import { KeyboardArrowDownIcon as I } from "./icons/KeyboardArrowDownIcon.js";
|
|
5
5
|
import { COLOR as N } from "@geckou/ui-core";
|
|
6
6
|
function $({
|
|
7
7
|
isOpened: n = null,
|
|
8
|
-
isHiddenArrow:
|
|
8
|
+
isHiddenArrow: h = !1,
|
|
9
9
|
isDisabled: b = !1,
|
|
10
10
|
isDisableClickOutside: f = !1,
|
|
11
11
|
duration: c = 0.3,
|
|
@@ -13,7 +13,7 @@ function $({
|
|
|
13
13
|
children: w,
|
|
14
14
|
ref: x
|
|
15
15
|
}) {
|
|
16
|
-
const [t, r] = a(n || !1), [C, u] = a(n || !1), [y,
|
|
16
|
+
const [t, r] = a(n || !1), [C, u] = a(n || !1), [y, k] = a(0), d = p(null), m = p(null), H = () => r((e) => !e);
|
|
17
17
|
E(x, () => ({
|
|
18
18
|
isOpenedContents: () => t,
|
|
19
19
|
close: () => r(!1)
|
|
@@ -31,7 +31,7 @@ function $({
|
|
|
31
31
|
const e = m.current;
|
|
32
32
|
if (!e)
|
|
33
33
|
return;
|
|
34
|
-
const s = () =>
|
|
34
|
+
const s = () => k(e.clientHeight);
|
|
35
35
|
s();
|
|
36
36
|
const o = new ResizeObserver(s);
|
|
37
37
|
return o.observe(e), () => o.disconnect();
|
|
@@ -43,8 +43,8 @@ function $({
|
|
|
43
43
|
const e = setTimeout(() => u(!0), c * 1e3);
|
|
44
44
|
return () => clearTimeout(e);
|
|
45
45
|
}, [t, c]);
|
|
46
|
-
const
|
|
47
|
-
return /* @__PURE__ */ v("div", { ref: d, style:
|
|
46
|
+
const R = { "--link-color": N.blue };
|
|
47
|
+
return /* @__PURE__ */ v("div", { ref: d, style: R, children: [
|
|
48
48
|
/* @__PURE__ */ v(
|
|
49
49
|
"button",
|
|
50
50
|
{
|
|
@@ -53,11 +53,11 @@ function $({
|
|
|
53
53
|
"aria-expanded": t,
|
|
54
54
|
className: "relative grid w-full cursor-pointer grid-cols-[1fr_auto] items-center justify-items-start text-(--link-color)",
|
|
55
55
|
onClick: (e) => {
|
|
56
|
-
e.preventDefault(),
|
|
56
|
+
e.preventDefault(), H();
|
|
57
57
|
},
|
|
58
58
|
children: [
|
|
59
|
-
/* @__PURE__ */ i("
|
|
60
|
-
!
|
|
59
|
+
/* @__PURE__ */ i("span", { className: "block w-full text-left", children: g }),
|
|
60
|
+
!h && /* @__PURE__ */ i(
|
|
61
61
|
I,
|
|
62
62
|
{
|
|
63
63
|
className: `size-[var(--icon-medium,1.125rem)] flex-none text-(--link-color) transition-all duration-100 ${t ? "rotate-180" : ""}`
|