@geckou/ui-react 0.3.0 → 0.4.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 +12 -0
- package/dist/components/CheckBox.d.ts +7 -1
- package/dist/components/CheckBox.js +30 -26
- package/dist/components/DatePicker.js +58 -58
- package/dist/components/DateRangePicker.js +60 -50
- package/dist/components/DateSelector.d.ts +4 -1
- package/dist/components/DateSelector.js +52 -47
- package/dist/components/ErrorMessage.js +7 -6
- package/dist/components/InputBox.js +36 -40
- package/dist/components/LabeledCheckbox.js +32 -29
- package/dist/components/ModalBox.js +49 -34
- package/dist/components/RadioButtons.js +45 -39
- package/dist/components/TabUI.js +28 -27
- package/dist/components/ToggleButton.d.ts +4 -1
- package/dist/components/ToggleButton.js +22 -18
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -98,6 +98,18 @@ props は Vue 版(`@geckou/ui-vue`)と揃えている。`v-model` にあた
|
|
|
98
98
|
yarn workspace @geckou/ui-react test
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
## 0.4.0 の変更
|
|
102
|
+
|
|
103
|
+
- `RadioButtons` が必須エラー(「必須項目です」)を描画する。Vue 版と同じく、
|
|
104
|
+
値が空へ変化したときに出る
|
|
105
|
+
- `CheckBox` / `ToggleButton` のロールが `aria-pressed` から
|
|
106
|
+
`role="checkbox" + aria-checked` / `role="switch" + aria-checked` に変わった。
|
|
107
|
+
アクセシブル名は `ariaLabel` / `ariaLabelledBy` で渡せる(未指定なら従来どおり `name`)
|
|
108
|
+
- `DateSelector` に `minYear` / `maxYear` を追加(既定は従来どおり「今年 -100 〜 今年 -14」)
|
|
109
|
+
- `DateRangePicker` が範囲(開始 > 終了)を検証し、`<name>Range` という名前で
|
|
110
|
+
`FormValidationStore` に登録する。`invalidNames` を見ている場合は増える
|
|
111
|
+
- `TabUI` の `color.text` を配線した
|
|
112
|
+
|
|
101
113
|
## License
|
|
102
114
|
|
|
103
115
|
[MIT](../../LICENSE)
|
|
@@ -8,6 +8,12 @@ type Props = {
|
|
|
8
8
|
cssStyle?: CheckBoxStyleForEachStatus;
|
|
9
9
|
isDisableAnimation?: boolean;
|
|
10
10
|
check?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* アクセシブル名。可視ラベルがあるなら ariaLabelledBy でその要素を指すこと。
|
|
13
|
+
* どちらも無いときだけ name を名前として使う(機械名でも無いよりはマシ)
|
|
14
|
+
*/
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
ariaLabelledBy?: string;
|
|
11
17
|
};
|
|
12
|
-
export declare function CheckBox({ name, checked, onChange, isDisabled, cssStyle, isDisableAnimation, check, }: Props): import("react").JSX.Element;
|
|
18
|
+
export declare function CheckBox({ name, checked, onChange, isDisabled, cssStyle, isDisableAnimation, check, ariaLabel, ariaLabelledBy, }: Props): import("react").JSX.Element;
|
|
13
19
|
export {};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { CheckIcon as
|
|
2
|
+
import { jsxs as f, Fragment as _, jsx as d } from "react/jsx-runtime";
|
|
3
|
+
import { CheckIcon as z } from "./icons/CheckIcon.js";
|
|
4
4
|
import { COLOR as t } from "@geckou/ui-core";
|
|
5
|
-
function
|
|
5
|
+
function g({
|
|
6
6
|
name: l,
|
|
7
|
-
checked:
|
|
7
|
+
checked: p,
|
|
8
8
|
onChange: r,
|
|
9
9
|
isDisabled: e,
|
|
10
10
|
cssStyle: o,
|
|
11
|
-
isDisableAnimation:
|
|
12
|
-
check:
|
|
11
|
+
isDisableAnimation: k,
|
|
12
|
+
check: h,
|
|
13
|
+
ariaLabel: x,
|
|
14
|
+
ariaLabelledBy: u
|
|
13
15
|
}) {
|
|
14
|
-
var
|
|
15
|
-
const i =
|
|
16
|
+
var n, s, b;
|
|
17
|
+
const i = p ?? !1, m = e ? o == null ? void 0 : o.disabled : o == null ? void 0 : o.default, c = {
|
|
16
18
|
textColor: e ? t.darkGray : t.blue,
|
|
17
19
|
backgroundColor: e ? t.lightGray : t.white,
|
|
18
20
|
border: {
|
|
@@ -20,31 +22,33 @@ function j({
|
|
|
20
22
|
size: "1px",
|
|
21
23
|
radius: ".25rem"
|
|
22
24
|
},
|
|
23
|
-
...
|
|
24
|
-
},
|
|
25
|
-
"--text-color":
|
|
26
|
-
"--border-color": (
|
|
27
|
-
"--border-size": (s =
|
|
28
|
-
"--radius-size": (
|
|
29
|
-
"--background-color":
|
|
30
|
-
"--duration":
|
|
25
|
+
...m
|
|
26
|
+
}, v = {
|
|
27
|
+
"--text-color": c.textColor,
|
|
28
|
+
"--border-color": (n = c.border) == null ? void 0 : n.color,
|
|
29
|
+
"--border-size": (s = c.border) == null ? void 0 : s.size,
|
|
30
|
+
"--radius-size": (b = c.border) == null ? void 0 : b.radius,
|
|
31
|
+
"--background-color": c.backgroundColor,
|
|
32
|
+
"--duration": k ? "0s" : ".3s"
|
|
31
33
|
};
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ f(_, { children: [
|
|
35
|
+
/* @__PURE__ */ d("style", { children: "@keyframes uiCheckPop{0%{scale:1}10%{scale:.8}50%{scale:1.1}100%{scale:1}}" }),
|
|
36
|
+
/* @__PURE__ */ f(
|
|
35
37
|
"button",
|
|
36
38
|
{
|
|
37
39
|
type: "button",
|
|
38
|
-
style:
|
|
39
|
-
"
|
|
40
|
-
"aria-
|
|
40
|
+
style: v,
|
|
41
|
+
role: "checkbox",
|
|
42
|
+
"aria-checked": i,
|
|
43
|
+
"aria-labelledby": u,
|
|
44
|
+
"aria-label": u ? void 0 : x ?? l,
|
|
41
45
|
disabled: e,
|
|
42
46
|
onClick: (a) => {
|
|
43
47
|
a.stopPropagation(), e || r == null || r(!i);
|
|
44
48
|
},
|
|
45
49
|
className: `relative flex h-6 w-6 cursor-pointer items-center justify-center rounded-(--radius-size) border-none shadow-[0_0_0_var(--border-size)_var(--border-color)_inset] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--border-color) has-[input:disabled]:pointer-events-none has-[input:disabled]:before:pointer-events-auto has-[input:disabled]:before:absolute has-[input:disabled]:before:inset-0 has-[input:disabled]:before:cursor-not-allowed has-[input:disabled]:before:content-[''] ${i ? "animate-[uiCheckPop_var(--duration)_ease-out] bg-(--border-color)" : "bg-(--background-color)"}`,
|
|
46
50
|
children: [
|
|
47
|
-
/* @__PURE__ */
|
|
51
|
+
/* @__PURE__ */ d(
|
|
48
52
|
"input",
|
|
49
53
|
{
|
|
50
54
|
type: "checkbox",
|
|
@@ -57,11 +61,11 @@ function j({
|
|
|
57
61
|
className: "hidden"
|
|
58
62
|
}
|
|
59
63
|
),
|
|
60
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ d(
|
|
61
65
|
"div",
|
|
62
66
|
{
|
|
63
67
|
className: `flex h-4 w-4 items-center justify-center [&>*]:fill-current [&>*]:text-current ${i ? "text-(--background-color)" : "text-(--border-color)"}`,
|
|
64
|
-
children:
|
|
68
|
+
children: h ?? /* @__PURE__ */ d(z, {})
|
|
65
69
|
}
|
|
66
70
|
)
|
|
67
71
|
]
|
|
@@ -70,5 +74,5 @@ function j({
|
|
|
70
74
|
] });
|
|
71
75
|
}
|
|
72
76
|
export {
|
|
73
|
-
|
|
77
|
+
g as CheckBox
|
|
74
78
|
};
|
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { formatDateValue as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { InputBox as
|
|
6
|
-
import { ErrorMessage as
|
|
7
|
-
import { CalendarIcon as
|
|
8
|
-
import { useRegisterValidation as
|
|
9
|
-
function
|
|
2
|
+
import { jsxs as N, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { formatDateValue as g, splitDate as k, COLOR as G, MESSAGES as R, composeDateValue as q, validateDateObject as C } from "@geckou/ui-core";
|
|
4
|
+
import { useState as o, useRef as F, useEffect as H } from "react";
|
|
5
|
+
import { InputBox as J } from "./InputBox.js";
|
|
6
|
+
import { ErrorMessage as K } from "./ErrorMessage.js";
|
|
7
|
+
import { CalendarIcon as Q } from "./icons/CalendarIcon.js";
|
|
8
|
+
import { useRegisterValidation as T } from "../hooks/useFormValidation.js";
|
|
9
|
+
function ae({
|
|
10
10
|
name: l,
|
|
11
11
|
value: a,
|
|
12
12
|
onChange: s,
|
|
13
|
-
cssStyle:
|
|
13
|
+
cssStyle: E,
|
|
14
14
|
isDisabled: i,
|
|
15
|
-
isRequired:
|
|
16
|
-
formValidationStore:
|
|
17
|
-
minDate:
|
|
18
|
-
maxDate:
|
|
19
|
-
size:
|
|
15
|
+
isRequired: n,
|
|
16
|
+
formValidationStore: S,
|
|
17
|
+
minDate: I = "",
|
|
18
|
+
maxDate: M = "",
|
|
19
|
+
size: D = "medium",
|
|
20
20
|
type: r = "date"
|
|
21
21
|
}) {
|
|
22
|
-
const [
|
|
23
|
-
() => a ?
|
|
24
|
-
), [c,
|
|
25
|
-
() => a ?
|
|
26
|
-
), [
|
|
27
|
-
|
|
28
|
-
if (
|
|
22
|
+
const [j, d] = o(
|
|
23
|
+
() => a ? g(a, r) : ""
|
|
24
|
+
), [c, p] = o(
|
|
25
|
+
() => a ? k(g(a, r)) : { year: "", month: "", day: "" }
|
|
26
|
+
), [u, V] = o(""), [L, f] = o(!0), $ = F(a);
|
|
27
|
+
H(() => {
|
|
28
|
+
if ($.current === a)
|
|
29
29
|
return;
|
|
30
|
-
|
|
31
|
-
const e = a ?
|
|
32
|
-
|
|
30
|
+
$.current = a;
|
|
31
|
+
const e = a ? g(a, r) : "";
|
|
32
|
+
d(e), p(k(e)), f(!0);
|
|
33
33
|
}, [a, r]);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const { message:
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
const { isValid:
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
|
|
34
|
+
const w = (e) => !e && n ? { isValid: !1, message: R.required } : { isValid: !0, message: "" }, z = (e) => C(e, { type: r, isRequired: n }), P = (e) => {
|
|
35
|
+
d(e), p(k(e));
|
|
36
|
+
const { message: x } = w(e);
|
|
37
|
+
V(x), f(!0), s == null || s(e);
|
|
38
|
+
}, v = (e, x) => {
|
|
39
|
+
const h = { ...c, [e]: x };
|
|
40
|
+
p(h);
|
|
41
|
+
const { isValid: y, message: B } = z(h);
|
|
42
|
+
if (V(B), f(y), y) {
|
|
43
|
+
const O = q(h, r);
|
|
44
|
+
d(O), s == null || s(O);
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
T(
|
|
48
|
+
S,
|
|
49
49
|
l,
|
|
50
|
-
|
|
50
|
+
w(j).isValid && L
|
|
51
51
|
);
|
|
52
|
-
const m =
|
|
53
|
-
return /* @__PURE__ */
|
|
54
|
-
|
|
52
|
+
const m = D === "small", b = `flex-none! ${m ? "px-[var(--sp-small,0.375rem)]! py-[var(--sp-min,0.1875rem)]! text-[length:var(--fs-small,0.6875rem)]" : "p-[var(--sp-medium,0.75rem)]!"}`, A = { "--icon-color": G.blue };
|
|
53
|
+
return /* @__PURE__ */ N(
|
|
54
|
+
J,
|
|
55
55
|
{
|
|
56
|
-
cssStyle:
|
|
56
|
+
cssStyle: E,
|
|
57
57
|
isDisabled: i,
|
|
58
|
-
isErrored: !!
|
|
58
|
+
isErrored: !!u,
|
|
59
59
|
className: `flex w-full items-center leading-none ${m ? "h-[calc(var(--bv,0.375rem)*5)] px-[var(--sp-min,0.1875rem)]" : "h-[calc(var(--bv,0.375rem)*6)] px-[var(--sp-small,0.375rem)]"}`,
|
|
60
60
|
children: [
|
|
61
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ N("div", { className: "relative flex-none", style: A, children: [
|
|
62
62
|
/* @__PURE__ */ t(
|
|
63
|
-
|
|
63
|
+
Q,
|
|
64
64
|
{
|
|
65
65
|
className: `pointer-events-none absolute inset-y-0 left-[var(--sp-small,0.375rem)] m-auto fill-(--icon-color) ${m ? "size-[var(--icon-small,0.9375rem)]" : "size-[var(--icon-medium,1.125rem)]"}`
|
|
66
66
|
}
|
|
@@ -70,12 +70,12 @@ function _({
|
|
|
70
70
|
{
|
|
71
71
|
type: r,
|
|
72
72
|
name: l,
|
|
73
|
-
value:
|
|
74
|
-
max:
|
|
75
|
-
min:
|
|
76
|
-
required:
|
|
73
|
+
value: j,
|
|
74
|
+
max: M,
|
|
75
|
+
min: I,
|
|
76
|
+
required: n,
|
|
77
77
|
disabled: i,
|
|
78
|
-
onChange: (e) =>
|
|
78
|
+
onChange: (e) => P(e.target.value),
|
|
79
79
|
className: `w-[calc(var(--icon-medium,1.125rem)+var(--sp-small,0.375rem)*2)]! cursor-pointer px-[var(--sp-small,0.375rem)]! opacity-0 [&::-webkit-calendar-picker-indicator]:absolute [&::-webkit-calendar-picker-indicator]:left-0 [&::-webkit-calendar-picker-indicator]:h-full [&::-webkit-calendar-picker-indicator]:w-full [&::-webkit-calendar-picker-indicator]:cursor-pointer [&::-webkit-calendar-picker-indicator]:opacity-0 ${m ? "py-[var(--sp-min,0.1875rem)]!" : "py-[var(--sp-medium,0.75rem)]!"}`
|
|
80
80
|
}
|
|
81
81
|
)
|
|
@@ -89,8 +89,8 @@ function _({
|
|
|
89
89
|
maxLength: 4,
|
|
90
90
|
type: "text",
|
|
91
91
|
disabled: i,
|
|
92
|
-
onChange: (e) =>
|
|
93
|
-
className: `w-[calc(var(--sp-medium,0.75rem)*2+5ch)]! ${
|
|
92
|
+
onChange: (e) => v("year", e.target.value),
|
|
93
|
+
className: `w-[calc(var(--sp-medium,0.75rem)*2+5ch)]! ${b}`
|
|
94
94
|
}
|
|
95
95
|
),
|
|
96
96
|
"/",
|
|
@@ -103,8 +103,8 @@ function _({
|
|
|
103
103
|
maxLength: 2,
|
|
104
104
|
type: "text",
|
|
105
105
|
disabled: i,
|
|
106
|
-
onChange: (e) =>
|
|
107
|
-
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${
|
|
106
|
+
onChange: (e) => v("month", e.target.value),
|
|
107
|
+
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${b}`
|
|
108
108
|
}
|
|
109
109
|
),
|
|
110
110
|
r === "date" && /* @__PURE__ */ t("span", { children: "/" }),
|
|
@@ -117,15 +117,15 @@ function _({
|
|
|
117
117
|
maxLength: 2,
|
|
118
118
|
type: "text",
|
|
119
119
|
disabled: i,
|
|
120
|
-
onChange: (e) =>
|
|
121
|
-
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${
|
|
120
|
+
onChange: (e) => v("day", e.target.value),
|
|
121
|
+
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${b}`
|
|
122
122
|
}
|
|
123
123
|
),
|
|
124
|
-
/* @__PURE__ */ t(
|
|
124
|
+
/* @__PURE__ */ t(K, { errorMessages: u ? [u] : void 0 })
|
|
125
125
|
]
|
|
126
126
|
}
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
export {
|
|
130
|
-
|
|
130
|
+
ae as DatePicker
|
|
131
131
|
};
|
|
@@ -1,65 +1,75 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
import { jsxs as b, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { COLOR as g, MESSAGES as R } from "@geckou/ui-core";
|
|
4
|
+
import { DatePicker as x } from "./DatePicker.js";
|
|
5
|
+
import { ErrorMessage as k } from "./ErrorMessage.js";
|
|
6
|
+
import { useRegisterValidation as u } from "../hooks/useFormValidation.js";
|
|
7
|
+
const M = { start: "", end: "" };
|
|
8
|
+
function $({
|
|
9
|
+
name: d,
|
|
10
|
+
value: r = M,
|
|
11
|
+
onChange: e,
|
|
12
|
+
isDisabled: a,
|
|
13
|
+
isRequired: c,
|
|
14
|
+
formValidationStore: s,
|
|
15
|
+
minDate: o = "",
|
|
16
|
+
maxDate: i = "",
|
|
17
|
+
size: l = "medium",
|
|
18
|
+
type: m = "date"
|
|
17
19
|
}) {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const f = !(r.start && r.end && r.start > r.end);
|
|
21
|
+
u(s, `${d}Range`, f);
|
|
22
|
+
const E = (n) => e == null ? void 0 : e({ start: n, end: r.end }), p = (n) => e == null ? void 0 : e({ start: r.start, end: n }), h = {
|
|
23
|
+
"--range-background-color": g.white,
|
|
24
|
+
"--range-border-color": g.gray
|
|
21
25
|
};
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
children: [
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
-
|
|
26
|
+
return (
|
|
27
|
+
// 角丸・区切り線は :first-child / :last-child で割り当てるため、
|
|
28
|
+
// ErrorMessage を同じ階層に置くとエラー表示時だけ枠の見た目が変わる。
|
|
29
|
+
// 入力群を内側にまとめ、ErrorMessage は外側(relative)に置く
|
|
30
|
+
/* @__PURE__ */ b("div", { style: h, className: "relative", children: [
|
|
31
|
+
/* @__PURE__ */ b("div", { className: "flex bg-(--range-background-color) [&>*]:flex-auto [&>*]:rounded-none! [&>*:first-child]:rounded-s-[calc(var(--bv,0.375rem)/2)]! [&>*:last-child]:rounded-e-[calc(var(--bv,0.375rem)/2)]! [&>*:not(:last-child)]:border-e [&>*:not(:last-child)]:border-(--range-border-color)", children: [
|
|
32
|
+
/* @__PURE__ */ t(
|
|
33
|
+
x,
|
|
30
34
|
{
|
|
31
|
-
name: `${
|
|
35
|
+
name: `${d}Start`,
|
|
32
36
|
value: r.start,
|
|
33
|
-
isDisabled:
|
|
34
|
-
isRequired:
|
|
35
|
-
formValidationStore:
|
|
36
|
-
minDate:
|
|
37
|
-
maxDate: r.end ||
|
|
38
|
-
size:
|
|
39
|
-
type:
|
|
40
|
-
onChange:
|
|
37
|
+
isDisabled: a,
|
|
38
|
+
isRequired: c,
|
|
39
|
+
formValidationStore: s,
|
|
40
|
+
minDate: o,
|
|
41
|
+
maxDate: r.end || i,
|
|
42
|
+
size: l,
|
|
43
|
+
type: m,
|
|
44
|
+
onChange: E
|
|
41
45
|
}
|
|
42
46
|
),
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
|
|
47
|
+
/* @__PURE__ */ t("div", { className: "flex flex-none! items-center px-[var(--bv,0.375rem)]", children: "〜" }),
|
|
48
|
+
/* @__PURE__ */ t(
|
|
49
|
+
x,
|
|
46
50
|
{
|
|
47
|
-
name: `${
|
|
51
|
+
name: `${d}End`,
|
|
48
52
|
value: r.end,
|
|
49
|
-
isDisabled:
|
|
50
|
-
isRequired:
|
|
51
|
-
formValidationStore:
|
|
52
|
-
minDate: r.start ||
|
|
53
|
-
maxDate:
|
|
54
|
-
size:
|
|
55
|
-
type:
|
|
56
|
-
onChange:
|
|
53
|
+
isDisabled: a,
|
|
54
|
+
isRequired: c,
|
|
55
|
+
formValidationStore: s,
|
|
56
|
+
minDate: r.start || o,
|
|
57
|
+
maxDate: i,
|
|
58
|
+
size: l,
|
|
59
|
+
type: m,
|
|
60
|
+
onChange: p
|
|
57
61
|
}
|
|
58
62
|
)
|
|
59
|
-
]
|
|
60
|
-
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ t(
|
|
65
|
+
k,
|
|
66
|
+
{
|
|
67
|
+
errorMessages: f ? void 0 : [R.startAfterEnd]
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
] })
|
|
61
71
|
);
|
|
62
72
|
}
|
|
63
73
|
export {
|
|
64
|
-
|
|
74
|
+
$ as DateRangePicker
|
|
65
75
|
};
|
|
@@ -8,6 +8,9 @@ type Props = {
|
|
|
8
8
|
formValidationStore?: FormValidationStore | null;
|
|
9
9
|
/** 'month' なら日の選択を出さない(Vue 版と揃える) */
|
|
10
10
|
type?: 'date' | 'month';
|
|
11
|
+
/** 選べる年の下限・上限。既定は「今年 -100 〜 今年 -14」(生年月日向け) */
|
|
12
|
+
minYear?: number;
|
|
13
|
+
maxYear?: number;
|
|
11
14
|
};
|
|
12
|
-
export declare function DateSelector({ name, value, onChange, isRequired, formValidationStore, type, }: Props): import("react").JSX.Element;
|
|
15
|
+
export declare function DateSelector({ name, value, onChange, isRequired, formValidationStore, type, minYear, maxYear, }: Props): import("react").JSX.Element;
|
|
13
16
|
export {};
|
|
@@ -1,45 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as s, jsx as l } from "react/jsx-runtime";
|
|
3
3
|
import { useState as C, useEffect as F } from "react";
|
|
4
|
-
import { splitDate as
|
|
5
|
-
import { InputBox as
|
|
4
|
+
import { splitDate as z, COLOR as I, daysInMonth as H } from "@geckou/ui-core";
|
|
5
|
+
import { InputBox as K } from "./InputBox.js";
|
|
6
6
|
import { KeyboardArrowDownIcon as f } from "./icons/KeyboardArrowDownIcon.js";
|
|
7
|
-
import { useRegisterValidation as
|
|
7
|
+
import { useRegisterValidation as L } from "../hooks/useFormValidation.js";
|
|
8
8
|
const b = { year: "", month: "", day: "" };
|
|
9
|
-
function
|
|
10
|
-
name:
|
|
11
|
-
value:
|
|
12
|
-
onChange:
|
|
9
|
+
function R({
|
|
10
|
+
name: o,
|
|
11
|
+
value: i,
|
|
12
|
+
onChange: n,
|
|
13
13
|
isRequired: c,
|
|
14
|
-
formValidationStore:
|
|
15
|
-
type:
|
|
14
|
+
formValidationStore: $,
|
|
15
|
+
type: m = "date",
|
|
16
|
+
minYear: A,
|
|
17
|
+
maxYear: M
|
|
16
18
|
}) {
|
|
17
|
-
const [r, d] = C(b), g = !!(r.year && r.month && (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
c ? g : g ||
|
|
19
|
+
const [r, d] = C(b), g = !!(r.year && r.month && (m === "month" || r.day)), O = !r.year && !r.month && !r.day;
|
|
20
|
+
L(
|
|
21
|
+
$,
|
|
22
|
+
o,
|
|
23
|
+
c ? g : g || O
|
|
22
24
|
), F(() => {
|
|
23
|
-
d(
|
|
24
|
-
}, [
|
|
25
|
-
const N = /* @__PURE__ */ new Date(), S = N
|
|
26
|
-
{ length:
|
|
25
|
+
d(i ? z(i) : b);
|
|
26
|
+
}, [i]);
|
|
27
|
+
const N = (/* @__PURE__ */ new Date()).getFullYear(), S = A ?? N - 100, k = M ?? N - 14, E = Array.from(
|
|
28
|
+
{ length: Math.max(k - S + 1, 0) },
|
|
27
29
|
(e, a) => (S + a).toString()
|
|
28
|
-
).map((e) => ({ label: e, value: e })),
|
|
30
|
+
).map((e) => ({ label: e, value: e })), T = Array.from({ length: 12 }, (e, a) => {
|
|
29
31
|
const t = (a + 1).toString();
|
|
30
32
|
return { label: t, value: t.padStart(2, "0") };
|
|
31
|
-
}), w = (e, a) =>
|
|
33
|
+
}), w = (e, a) => H(Number(e) || 2e3, Number(a)), Y = w(r.year, r.month), _ = Array.from({ length: Y }, (e, a) => {
|
|
32
34
|
const t = (a + 1).toString();
|
|
33
35
|
return { label: t, value: t.padStart(2, "0") };
|
|
34
36
|
}), D = (e) => {
|
|
35
37
|
d(e);
|
|
36
|
-
const a =
|
|
38
|
+
const a = m === "month" ? [e.year, e.month] : [e.year, e.month, e.day];
|
|
37
39
|
if (!e.year && !e.month && !e.day)
|
|
38
|
-
|
|
40
|
+
n == null || n("");
|
|
39
41
|
else {
|
|
40
42
|
if (a.some((t) => !t))
|
|
41
43
|
return;
|
|
42
|
-
|
|
44
|
+
n == null || n(a.join("-"));
|
|
43
45
|
}
|
|
44
46
|
}, u = (e, a) => {
|
|
45
47
|
const t = { ...r, [e]: a };
|
|
@@ -51,68 +53,71 @@ function J({
|
|
|
51
53
|
}, p = (e) => {
|
|
52
54
|
const t = e.currentTarget.firstElementChild;
|
|
53
55
|
t && t.click();
|
|
54
|
-
},
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
-
/* @__PURE__ */
|
|
56
|
+
}, y = "relative w-max [&:has(select:focus)>svg]:rotate-180", v = "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 };
|
|
57
|
+
return /* @__PURE__ */ s(K, { className: "flex w-max items-center [&>*:not(:last-of-type)]:after:content-['/']", children: [
|
|
58
|
+
/* @__PURE__ */ s("div", { className: y, style: h, onClick: p, children: [
|
|
59
|
+
/* @__PURE__ */ s(
|
|
58
60
|
"select",
|
|
59
61
|
{
|
|
60
62
|
value: r.year,
|
|
61
|
-
name: `${
|
|
63
|
+
name: `${o}-year`,
|
|
64
|
+
"aria-label": `${o}の年`,
|
|
62
65
|
required: c,
|
|
63
66
|
onChange: (e) => u("year", e.target.value),
|
|
64
67
|
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
68
|
children: [
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
|
|
69
|
+
/* @__PURE__ */ l("option", { disabled: !0, value: "", children: "年" }),
|
|
70
|
+
E.map((e) => /* @__PURE__ */ l("option", { value: e.value, children: e.label }, e.value))
|
|
68
71
|
]
|
|
69
72
|
}
|
|
70
73
|
),
|
|
71
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ l(f, { className: v })
|
|
72
75
|
] }),
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ s("div", { className: y, style: h, onClick: p, children: [
|
|
77
|
+
/* @__PURE__ */ s(
|
|
75
78
|
"select",
|
|
76
79
|
{
|
|
77
80
|
value: r.month,
|
|
78
|
-
name: `${
|
|
81
|
+
name: `${o}-month`,
|
|
82
|
+
"aria-label": `${o}の月`,
|
|
79
83
|
required: c,
|
|
80
84
|
onChange: (e) => u("month", e.target.value),
|
|
81
85
|
className: x,
|
|
82
86
|
children: [
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
87
|
+
/* @__PURE__ */ l("option", { disabled: !0, value: "", children: "月" }),
|
|
88
|
+
T.map((e) => /* @__PURE__ */ l("option", { value: e.value, children: e.label }, e.value))
|
|
85
89
|
]
|
|
86
90
|
}
|
|
87
91
|
),
|
|
88
|
-
/* @__PURE__ */
|
|
92
|
+
/* @__PURE__ */ l(f, { className: v })
|
|
89
93
|
] }),
|
|
90
|
-
|
|
94
|
+
m === "date" && /* @__PURE__ */ s(
|
|
91
95
|
"div",
|
|
92
96
|
{
|
|
93
|
-
className:
|
|
97
|
+
className: y,
|
|
94
98
|
style: h,
|
|
95
99
|
onClick: p,
|
|
96
100
|
children: [
|
|
97
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ s(
|
|
98
102
|
"select",
|
|
99
103
|
{
|
|
100
104
|
value: r.day,
|
|
101
|
-
name: `${
|
|
105
|
+
name: `${o}-day`,
|
|
106
|
+
"aria-label": `${o}の日`,
|
|
102
107
|
required: c,
|
|
103
108
|
onChange: (e) => u("day", e.target.value),
|
|
104
109
|
className: x,
|
|
105
110
|
children: [
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
_.map((e) => /* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ l("option", { disabled: !0, value: "", children: "日" }),
|
|
112
|
+
_.map((e) => /* @__PURE__ */ l("option", { value: e.value, children: e.label }, e.value))
|
|
108
113
|
]
|
|
109
114
|
}
|
|
110
115
|
),
|
|
111
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ l(f, { className: v })
|
|
112
117
|
]
|
|
113
118
|
}
|
|
114
119
|
),
|
|
115
|
-
/* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ l(
|
|
116
121
|
"button",
|
|
117
122
|
{
|
|
118
123
|
type: "button",
|
|
@@ -125,5 +130,5 @@ function J({
|
|
|
125
130
|
] });
|
|
126
131
|
}
|
|
127
132
|
export {
|
|
128
|
-
|
|
133
|
+
R as DateSelector
|
|
129
134
|
};
|
|
@@ -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
|
};
|