@geckou/ui-react 0.6.0 → 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 +22 -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 +86 -80
- 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/SearchableSelectBox.d.ts +2 -1
- package/dist/components/SearchableSelectBox.js +52 -45
- 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/package.json +2 -2
|
@@ -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
|
};
|
|
@@ -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,77 +1,84 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState 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 = h &&
|
|
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
43
|
if (e.preventDefault(), !h) {
|
|
38
|
-
a(!0),
|
|
39
|
-
e.key === "ArrowDown" ? 0 :
|
|
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" && c && (e.preventDefault(), a(!1),
|
|
62
|
+
e.key === "Escape" && c && (e.preventDefault(), a(!1), l(-1));
|
|
57
63
|
};
|
|
58
|
-
return /* @__PURE__ */
|
|
64
|
+
return /* @__PURE__ */ $("div", { ref: x, className: "relative", children: [
|
|
59
65
|
/* @__PURE__ */ m(
|
|
60
|
-
|
|
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
79
|
ariaControls: p,
|
|
73
|
-
ariaActivedescendant: c && i >= 0 ?
|
|
74
|
-
onKeyDown:
|
|
80
|
+
ariaActivedescendant: c && i >= 0 ? D(i) : void 0,
|
|
81
|
+
onKeyDown: _
|
|
75
82
|
}
|
|
76
83
|
),
|
|
77
84
|
c && /* @__PURE__ */ m(
|
|
@@ -80,17 +87,17 @@ function R({
|
|
|
80
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" : ""}`
|
|
@@ -1,68 +1,76 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { isEmptyValue as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { InputBox as
|
|
6
|
-
import { ErrorMessage as
|
|
7
|
-
function z({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { jsxs as H, jsx as h } from "react/jsx-runtime";
|
|
3
|
+
import { isEmptyValue as M, validateInputValue as T } from "@geckou/ui-core";
|
|
4
|
+
import { useState as j, useRef as m, useEffect as k } from "react";
|
|
5
|
+
import { InputBox as I } from "./InputBox.js";
|
|
6
|
+
import { ErrorMessage as W } from "./ErrorMessage.js";
|
|
7
|
+
function z(n) {
|
|
8
|
+
const e = getComputedStyle(n), t = (...r) => r.reduce((a, i) => a + (parseFloat(i) || 0), 0);
|
|
9
|
+
return e.boxSizing === "border-box" ? n.scrollHeight + t(e.borderTopWidth, e.borderBottomWidth) : n.scrollHeight - t(e.paddingTop, e.paddingBottom);
|
|
10
|
+
}
|
|
11
|
+
function q({
|
|
12
|
+
name: n,
|
|
13
|
+
value: e,
|
|
14
|
+
onChange: t,
|
|
11
15
|
cssStyle: r,
|
|
12
|
-
placeholder:
|
|
16
|
+
placeholder: a = "入力してください",
|
|
13
17
|
isDisabled: i,
|
|
14
|
-
isRequired:
|
|
15
|
-
rows:
|
|
16
|
-
maxLength:
|
|
18
|
+
isRequired: p,
|
|
19
|
+
rows: x,
|
|
20
|
+
maxLength: b = 100,
|
|
17
21
|
autocomplete: v = "off",
|
|
18
22
|
validates: E = [],
|
|
19
23
|
autoAdjustHeight: V
|
|
20
24
|
}) {
|
|
21
|
-
var
|
|
22
|
-
const [
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
return
|
|
26
|
-
if (V &&
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
var c, g;
|
|
26
|
+
const [l, B] = j([]), d = m(null), o = e ?? "", f = () => {
|
|
27
|
+
B(T(o, { isRequired: p, validates: E }));
|
|
28
|
+
}, C = m(o), s = m(!1);
|
|
29
|
+
return k(() => {
|
|
30
|
+
if (V && d.current) {
|
|
31
|
+
const u = d.current;
|
|
32
|
+
u.style.height = "auto", u.style.height = `${z(u)}px`;
|
|
33
|
+
}
|
|
34
|
+
if (!s.current) {
|
|
35
|
+
if (o === C.current) {
|
|
36
|
+
M(o) || f();
|
|
29
37
|
return;
|
|
30
38
|
}
|
|
31
|
-
|
|
39
|
+
s.current = !0;
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
}, [
|
|
35
|
-
|
|
41
|
+
f();
|
|
42
|
+
}, [o]), /* @__PURE__ */ H(
|
|
43
|
+
I,
|
|
36
44
|
{
|
|
37
45
|
cssStyle: r,
|
|
38
46
|
className: "min-h-[4em]",
|
|
39
|
-
isErrored: !!
|
|
47
|
+
isErrored: !!l.length,
|
|
40
48
|
isDisabled: i,
|
|
41
49
|
children: [
|
|
42
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ h(
|
|
43
51
|
"textarea",
|
|
44
52
|
{
|
|
45
|
-
ref:
|
|
46
|
-
name:
|
|
47
|
-
value:
|
|
48
|
-
required:
|
|
49
|
-
placeholder:
|
|
53
|
+
ref: d,
|
|
54
|
+
name: n,
|
|
55
|
+
value: o,
|
|
56
|
+
required: p,
|
|
57
|
+
placeholder: a,
|
|
50
58
|
disabled: i,
|
|
51
59
|
autoComplete: v,
|
|
52
|
-
rows:
|
|
53
|
-
maxLength:
|
|
54
|
-
"aria-invalid":
|
|
55
|
-
onChange: (
|
|
56
|
-
onBlur: () =>
|
|
60
|
+
rows: x,
|
|
61
|
+
maxLength: b,
|
|
62
|
+
"aria-invalid": l.length ? "true" : void 0,
|
|
63
|
+
onChange: (u) => t == null ? void 0 : t(u.target.value),
|
|
64
|
+
onBlur: () => f()
|
|
57
65
|
}
|
|
58
66
|
),
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
|
|
67
|
+
/* @__PURE__ */ h(
|
|
68
|
+
W,
|
|
61
69
|
{
|
|
62
|
-
errorMessages:
|
|
70
|
+
errorMessages: l,
|
|
63
71
|
cssStyle: {
|
|
64
|
-
textColor: (
|
|
65
|
-
backgroundColor: (
|
|
72
|
+
textColor: (c = r == null ? void 0 : r.error) == null ? void 0 : c.backgroundColor,
|
|
73
|
+
backgroundColor: (g = r == null ? void 0 : r.error) == null ? void 0 : g.textColor
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
)
|
|
@@ -71,5 +79,5 @@ function z({
|
|
|
71
79
|
);
|
|
72
80
|
}
|
|
73
81
|
export {
|
|
74
|
-
|
|
82
|
+
q as TextArea
|
|
75
83
|
};
|
|
@@ -23,11 +23,13 @@ type Props = {
|
|
|
23
23
|
*/
|
|
24
24
|
role?: string;
|
|
25
25
|
ariaLabel?: string;
|
|
26
|
+
/** 可視ラベルがあるなら、その要素の id をここで指す(ariaLabel より優先) */
|
|
27
|
+
ariaLabelledBy?: string;
|
|
26
28
|
ariaExpanded?: boolean;
|
|
27
29
|
ariaControls?: string;
|
|
28
30
|
ariaActivedescendant?: string;
|
|
29
31
|
ariaAutocomplete?: 'none' | 'inline' | 'list' | 'both';
|
|
30
32
|
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
31
33
|
};
|
|
32
|
-
export declare function TextBox({ name, value, onChange, cssStyle, inputType, placeholder, isDisabled, isRequired, maxLength, autocomplete, validates, before, after, id, role, ariaLabel, ariaExpanded, ariaControls, ariaActivedescendant, ariaAutocomplete, onKeyDown, }: Props): import("react").JSX.Element;
|
|
34
|
+
export declare function TextBox({ name, value, onChange, cssStyle, inputType, placeholder, isDisabled, isRequired, maxLength, autocomplete, validates, before, after, id, role, ariaLabel, ariaLabelledBy, ariaExpanded, ariaControls, ariaActivedescendant, ariaAutocomplete, onKeyDown, }: Props): import("react").JSX.Element;
|
|
33
35
|
export {};
|