@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
package/README.md
CHANGED
|
@@ -108,6 +108,43 @@ props は Vue 版(`@geckou/ui-vue`)と揃えている。`v-model` にあた
|
|
|
108
108
|
yarn workspace @geckou/ui-react test
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
+
## 0.7.0 の変更
|
|
112
|
+
|
|
113
|
+
- `CheckBox` / `LabeledCheckbox` に `value` を追加。`CheckBoxes` は各選択肢の
|
|
114
|
+
`value` を送信用の hidden へ渡すようになった。これまでは全て `value="on"` で、
|
|
115
|
+
ネイティブ送信(Server Actions / `<form action>`)でどれが選ばれたか区別できなかった
|
|
116
|
+
- `DatePicker` の年月日欄は**入力中にエラー文言を出さない**。判定は入力のたびに
|
|
117
|
+
更新し、文言は欄を離れた時点(blur)で出す。あわせて 1 桁の月・日は blur で
|
|
118
|
+
2 桁へ正規化する(「1」→「01」)
|
|
119
|
+
- `DatePicker` の年月日欄が不正なとき、送信値と `onChange` が空文字になる
|
|
120
|
+
(これまでは valid のときだけ更新していたため、画面と送信値が食い違っていた)
|
|
121
|
+
- `SelectBox` が `isDisabled` かつ値が `0` / `'NA'` のときにプレースホルダを
|
|
122
|
+
出す分岐を削除した。0 は正当な選択値として扱う
|
|
123
|
+
- `SelectBox` がエラー時に `InputBox` へ `isErrored` を渡し、`aria-invalid` を付ける
|
|
124
|
+
- `SearchableSelectBox` は `isDisabled` の選択肢を候補に出さず、確定後の入力欄には
|
|
125
|
+
`value` ではなく**ラベル**を表示する(通知は従来どおり `value`)。
|
|
126
|
+
`ariaLabelledBy` を追加(`TextBox` にも追加)
|
|
127
|
+
- `TextArea` の `autoAdjustHeight` が `box-sizing` を見て高さを補正する
|
|
128
|
+
(border-box のリセット CSS を当てた環境で 2rem 足りなかった)
|
|
129
|
+
- `DateRangePicker` は範囲の比較前に日付を正規化する
|
|
130
|
+
- `ErrorMessage` は同じ文言を複数受け取っても重複キーの警告を出さない
|
|
131
|
+
- `SlideDownUi` のトリガーが `<button>` の中に `<div>` を置かなくなった
|
|
132
|
+
|
|
133
|
+
## 0.6.0 の変更
|
|
134
|
+
|
|
135
|
+
- `ModalBox` を重ねたとき、Escape で閉じるのは**最前面の 1 枚だけ**になった
|
|
136
|
+
(従来は内側と外側の `onClose` が両方呼ばれていた)。あわせて自分が Escape を
|
|
137
|
+
処理したら `preventDefault()` する。外側で Escape を見ているアプリ側のハンドラが
|
|
138
|
+
一緒に反応しなくなるので、`defaultPrevented` を見ずに閉じている処理があれば追従が要る
|
|
139
|
+
- `SearchableSelectBox` が候補 0 件のときは Escape を握らない(`preventDefault()` しない)。
|
|
140
|
+
`ModalBox` の中で「何にもマッチしない語を入れた状態だと Escape を 2 回押す必要がある」
|
|
141
|
+
のが直る
|
|
142
|
+
- `DatePicker` のカレンダー起動用入力にアクセシブル名(「◯◯のカレンダー」)が付き、
|
|
143
|
+
キーボードで到達したときアイコン側に可視フォーカスが出る
|
|
144
|
+
- `PopupBox` が `role="status"`(ライブリージョン)になり、支援技術に通知が伝わる
|
|
145
|
+
- `DateRange` 型を公開の入口から export するようにした
|
|
146
|
+
(`import type { DateRange } from '@geckou/ui-react'`)
|
|
147
|
+
|
|
111
148
|
## 0.5.0 の変更
|
|
112
149
|
|
|
113
150
|
- `DatePicker` / `DateSelector` が `ariaLabel` / `ariaLabelledBy` を受ける
|
|
@@ -2,6 +2,12 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { CheckBoxStyleForEachStatus } from '../types';
|
|
3
3
|
type Props = {
|
|
4
4
|
name: string;
|
|
5
|
+
/**
|
|
6
|
+
* ネイティブ送信時の値。既定は 'on'(<input type="checkbox"> と同じ)。
|
|
7
|
+
* 同じ name を共有する複数のチェックボックスでは、これを指定しないと
|
|
8
|
+
* FormData からどれが選ばれたか区別できない
|
|
9
|
+
*/
|
|
10
|
+
value?: string | number;
|
|
5
11
|
checked?: boolean;
|
|
6
12
|
onChange?: (newValue: boolean) => void;
|
|
7
13
|
isDisabled?: boolean;
|
|
@@ -15,5 +21,5 @@ type Props = {
|
|
|
15
21
|
ariaLabel?: string;
|
|
16
22
|
ariaLabelledBy?: string;
|
|
17
23
|
};
|
|
18
|
-
export declare function CheckBox({ name, checked, onChange, isDisabled, cssStyle, isDisableAnimation, check, ariaLabel, ariaLabelledBy, }: Props): import("react").JSX.Element;
|
|
24
|
+
export declare function CheckBox({ name, value, checked, onChange, isDisabled, cssStyle, isDisableAnimation, check, ariaLabel, ariaLabelledBy, }: Props): import("react").JSX.Element;
|
|
19
25
|
export {};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { CheckIcon as
|
|
2
|
+
import { jsxs as C, Fragment as _, jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { CheckIcon as g } from "./icons/CheckIcon.js";
|
|
4
4
|
import { COLOR as t } from "@geckou/ui-core";
|
|
5
|
-
function
|
|
5
|
+
function y({
|
|
6
6
|
name: l,
|
|
7
|
-
|
|
7
|
+
value: s,
|
|
8
|
+
checked: f,
|
|
8
9
|
onChange: c,
|
|
9
10
|
isDisabled: e,
|
|
10
11
|
cssStyle: r,
|
|
11
|
-
isDisableAnimation:
|
|
12
|
-
check:
|
|
13
|
-
ariaLabel:
|
|
12
|
+
isDisableAnimation: k,
|
|
13
|
+
check: p,
|
|
14
|
+
ariaLabel: h,
|
|
14
15
|
ariaLabelledBy: a
|
|
15
16
|
}) {
|
|
16
17
|
var n, u, b;
|
|
17
|
-
const o =
|
|
18
|
+
const o = f ?? !1, x = e ? r == null ? void 0 : r.disabled : r == null ? void 0 : r.default, d = {
|
|
18
19
|
textColor: e ? t.darkGray : t.blue,
|
|
19
20
|
backgroundColor: e ? t.lightGray : t.white,
|
|
20
21
|
border: {
|
|
@@ -22,44 +23,52 @@ function j({
|
|
|
22
23
|
size: "1px",
|
|
23
24
|
radius: ".25rem"
|
|
24
25
|
},
|
|
25
|
-
...
|
|
26
|
-
},
|
|
26
|
+
...x
|
|
27
|
+
}, m = {
|
|
27
28
|
"--text-color": d.textColor,
|
|
28
29
|
"--border-color": (n = d.border) == null ? void 0 : n.color,
|
|
29
30
|
"--border-size": (u = d.border) == null ? void 0 : u.size,
|
|
30
31
|
"--radius-size": (b = d.border) == null ? void 0 : b.radius,
|
|
31
32
|
"--background-color": d.backgroundColor,
|
|
32
|
-
"--duration":
|
|
33
|
+
"--duration": k ? "0s" : ".3s"
|
|
33
34
|
};
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ C(_, { children: [
|
|
35
36
|
/* @__PURE__ */ i("style", { children: "@keyframes uiCheckPop{0%{scale:1}10%{scale:.8}50%{scale:1.1}100%{scale:1}}" }),
|
|
36
37
|
/* @__PURE__ */ i(
|
|
37
38
|
"button",
|
|
38
39
|
{
|
|
39
40
|
type: "button",
|
|
40
|
-
style:
|
|
41
|
+
style: m,
|
|
41
42
|
role: "checkbox",
|
|
42
43
|
"aria-checked": o,
|
|
43
44
|
"data-checked": o,
|
|
44
45
|
"aria-labelledby": a,
|
|
45
|
-
"aria-label": a ? void 0 :
|
|
46
|
+
"aria-label": a ? void 0 : h ?? l,
|
|
46
47
|
disabled: e,
|
|
47
|
-
onClick: (
|
|
48
|
-
|
|
48
|
+
onClick: (v) => {
|
|
49
|
+
v.stopPropagation(), e || c == null || c(!o);
|
|
49
50
|
},
|
|
50
51
|
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) disabled:pointer-events-none disabled:before:pointer-events-auto disabled:before:absolute disabled:before:inset-0 disabled:before:cursor-not-allowed disabled:before:content-[''] ${o ? "animate-[uiCheckPop_var(--duration)_ease-out] bg-(--border-color)" : "bg-(--background-color)"}`,
|
|
51
52
|
children: /* @__PURE__ */ i(
|
|
52
53
|
"div",
|
|
53
54
|
{
|
|
54
55
|
className: `flex h-4 w-4 items-center justify-center [&>*]:fill-current [&>*]:text-current ${o ? "text-(--background-color)" : "text-(--border-color)"}`,
|
|
55
|
-
children:
|
|
56
|
+
children: p ?? /* @__PURE__ */ i(g, {})
|
|
56
57
|
}
|
|
57
58
|
)
|
|
58
59
|
}
|
|
59
60
|
),
|
|
60
|
-
o && /* @__PURE__ */ i(
|
|
61
|
+
o && /* @__PURE__ */ i(
|
|
62
|
+
"input",
|
|
63
|
+
{
|
|
64
|
+
type: "hidden",
|
|
65
|
+
name: l,
|
|
66
|
+
value: s ?? "on",
|
|
67
|
+
disabled: e
|
|
68
|
+
}
|
|
69
|
+
)
|
|
61
70
|
] });
|
|
62
71
|
}
|
|
63
72
|
export {
|
|
64
|
-
|
|
73
|
+
y as CheckBox
|
|
65
74
|
};
|
|
@@ -1,55 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as M, jsx as g } from "react/jsx-runtime";
|
|
3
|
-
import { COLOR as
|
|
4
|
-
import { useState as
|
|
3
|
+
import { COLOR as a, MESSAGES as V } from "@geckou/ui-core";
|
|
4
|
+
import { useState as b, useRef as w, useEffect as R } from "react";
|
|
5
5
|
import { LabeledCheckbox as j } from "./LabeledCheckbox.js";
|
|
6
6
|
import { ErrorMessage as L } from "./ErrorMessage.js";
|
|
7
7
|
function F({
|
|
8
|
-
name:
|
|
9
|
-
options:
|
|
10
|
-
value:
|
|
8
|
+
name: k,
|
|
9
|
+
options: u,
|
|
10
|
+
value: e,
|
|
11
11
|
onChange: s,
|
|
12
|
-
isDisabled:
|
|
12
|
+
isDisabled: p,
|
|
13
13
|
isRequired: C,
|
|
14
14
|
cssStyle: o
|
|
15
15
|
}) {
|
|
16
|
-
const [
|
|
17
|
-
C &&
|
|
16
|
+
const [i, d] = b(e ?? []), [f, h] = b(""), m = (r) => h(
|
|
17
|
+
C && r.length === 0 ? V.required : ""
|
|
18
18
|
), n = w(!0);
|
|
19
19
|
R(() => {
|
|
20
20
|
if (n.current) {
|
|
21
|
-
n.current = !1,
|
|
21
|
+
n.current = !1, e != null && e.length && m(e);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
}, [
|
|
26
|
-
const E = (
|
|
27
|
-
const
|
|
28
|
-
(t) => t ===
|
|
24
|
+
e && d(e);
|
|
25
|
+
}, [e]);
|
|
26
|
+
const E = (r, l) => {
|
|
27
|
+
const c = u.map((t) => t.value).filter(
|
|
28
|
+
(t) => t === r ? l : i.includes(t)
|
|
29
29
|
);
|
|
30
|
-
d(
|
|
30
|
+
d(c), m(c), s == null || s(c);
|
|
31
31
|
}, x = {
|
|
32
32
|
...(o == null ? void 0 : o.error) ?? {},
|
|
33
|
-
textColor:
|
|
34
|
-
backgroundColor:
|
|
33
|
+
textColor: a.white,
|
|
34
|
+
backgroundColor: a.red,
|
|
35
35
|
border: {
|
|
36
|
-
color:
|
|
36
|
+
color: a.red,
|
|
37
37
|
size: "1px",
|
|
38
38
|
radius: ".25rem"
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
return /* @__PURE__ */ M("div", { className: "relative flex flex-wrap gap-x-6 gap-y-4", children: [
|
|
42
|
-
|
|
42
|
+
u.map((r) => /* @__PURE__ */ g(
|
|
43
43
|
j,
|
|
44
44
|
{
|
|
45
|
-
name:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
name: k,
|
|
46
|
+
value: r.value,
|
|
47
|
+
label: r.label,
|
|
48
|
+
checked: i.includes(r.value),
|
|
49
|
+
onChange: (l) => E(r.value, l),
|
|
50
|
+
isDisabled: p,
|
|
50
51
|
cssStyle: o
|
|
51
52
|
},
|
|
52
|
-
|
|
53
|
+
r.value
|
|
53
54
|
)),
|
|
54
55
|
/* @__PURE__ */ g(
|
|
55
56
|
L,
|
|
@@ -1,138 +1,153 @@
|
|
|
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
|
|
10
|
-
name:
|
|
11
|
-
value:
|
|
2
|
+
import { jsxs as V, jsx as a } from "react/jsx-runtime";
|
|
3
|
+
import { formatDateValue as w, splitDate as N, COLOR as H, MESSAGES as J, normalizeDateObject as K, composeDateValue as Q, validateDateObject as T } from "@geckou/ui-core";
|
|
4
|
+
import { useState as u, useRef as U, useEffect as W, useId as X } from "react";
|
|
5
|
+
import { InputBox as Y } from "./InputBox.js";
|
|
6
|
+
import { ErrorMessage as Z } from "./ErrorMessage.js";
|
|
7
|
+
import { CalendarIcon as _ } from "./icons/CalendarIcon.js";
|
|
8
|
+
import { useRegisterValidation as ee } from "../hooks/useFormValidation.js";
|
|
9
|
+
function ne({
|
|
10
|
+
name: f,
|
|
11
|
+
value: r,
|
|
12
12
|
onChange: s,
|
|
13
|
-
cssStyle:
|
|
14
|
-
isDisabled:
|
|
15
|
-
isRequired:
|
|
16
|
-
formValidationStore:
|
|
13
|
+
cssStyle: D,
|
|
14
|
+
isDisabled: l,
|
|
15
|
+
isRequired: v,
|
|
16
|
+
formValidationStore: M,
|
|
17
17
|
minDate: L = "",
|
|
18
|
-
maxDate:
|
|
18
|
+
maxDate: B = "",
|
|
19
19
|
size: P = "medium",
|
|
20
20
|
type: t = "date",
|
|
21
21
|
ariaLabel: A,
|
|
22
|
-
ariaLabelledBy:
|
|
22
|
+
ariaLabelledBy: b
|
|
23
23
|
}) {
|
|
24
|
-
const [
|
|
25
|
-
() =>
|
|
26
|
-
), [
|
|
27
|
-
() =>
|
|
28
|
-
), [
|
|
29
|
-
|
|
30
|
-
if (
|
|
24
|
+
const [h, x] = u(
|
|
25
|
+
() => r ? w(r, t) : ""
|
|
26
|
+
), [i, m] = u(
|
|
27
|
+
() => r ? N(w(r, t)) : { year: "", month: "", day: "" }
|
|
28
|
+
), [$, I] = u(""), [G, g] = u(!0), E = U(r);
|
|
29
|
+
W(() => {
|
|
30
|
+
if (E.current === r)
|
|
31
31
|
return;
|
|
32
|
-
|
|
33
|
-
const e =
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const { message:
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
E.current = r;
|
|
33
|
+
const e = r ? w(r, t) : "";
|
|
34
|
+
x(e), m(N(e)), g(!0);
|
|
35
|
+
}, [r, t]);
|
|
36
|
+
const S = (e) => !e && v ? { isValid: !1, message: J.required } : { isValid: !0, message: "" }, R = (e) => T(e, { type: t, isRequired: v }), q = (e) => {
|
|
37
|
+
x(e), m(N(e));
|
|
38
|
+
const { message: n } = S(e);
|
|
39
|
+
I(n), g(!0), s == null || s(e);
|
|
40
|
+
}, z = (e, n) => {
|
|
41
|
+
const { isValid: o, message: F } = R(e);
|
|
42
|
+
g(o), I(n ? F : "");
|
|
43
|
+
const y = o ? Q(e, t) : "";
|
|
44
|
+
y !== h && (x(y), s == null || s(y));
|
|
45
|
+
}, j = (e, n) => {
|
|
46
|
+
const o = { ...i, [e]: n };
|
|
47
|
+
m(o), z(o, !1);
|
|
48
|
+
}, k = () => {
|
|
49
|
+
const e = K(i);
|
|
50
|
+
m(e), z(e, !0);
|
|
48
51
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
ee(
|
|
53
|
+
M,
|
|
54
|
+
f,
|
|
55
|
+
S(h).isValid && G
|
|
53
56
|
);
|
|
54
|
-
const c =
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
|
|
57
|
+
const c = X(), d = (e) => b ? { "aria-labelledby": `${b} ${c}-${e}` } : { "aria-label": `${A ?? f}の${e}` }, p = P === "small", O = `flex-none! ${p ? "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)]!"}`, C = { "--icon-color": H.blue };
|
|
58
|
+
return /* @__PURE__ */ V(
|
|
59
|
+
Y,
|
|
57
60
|
{
|
|
58
|
-
cssStyle:
|
|
59
|
-
isDisabled:
|
|
60
|
-
isErrored:
|
|
61
|
-
className: `flex w-full items-center leading-none ${
|
|
61
|
+
cssStyle: D,
|
|
62
|
+
isDisabled: l,
|
|
63
|
+
isErrored: !!$,
|
|
64
|
+
className: `flex w-full items-center leading-none ${p ? "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)]"}`,
|
|
62
65
|
children: [
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
/* @__PURE__ */ V(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
className: "relative flex-none rounded-[var(--radius-small,0.1875rem)] has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-offset-2 has-[input:focus-visible]:outline-(--icon-color)",
|
|
70
|
+
style: C,
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ a(
|
|
73
|
+
_,
|
|
74
|
+
{
|
|
75
|
+
className: `pointer-events-none absolute inset-y-0 left-[var(--sp-small,0.375rem)] m-auto fill-(--icon-color) ${p ? "size-[var(--icon-small,0.9375rem)]" : "size-[var(--icon-medium,1.125rem)]"}`
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ a(
|
|
79
|
+
"input",
|
|
80
|
+
{
|
|
81
|
+
type: t,
|
|
82
|
+
name: f,
|
|
83
|
+
value: h,
|
|
84
|
+
...d("カレンダー"),
|
|
85
|
+
max: B,
|
|
86
|
+
min: L,
|
|
87
|
+
required: v,
|
|
88
|
+
disabled: l,
|
|
89
|
+
onChange: (e) => q(e.target.value),
|
|
90
|
+
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 ${p ? "py-[var(--sp-min,0.1875rem)]!" : "py-[var(--sp-medium,0.75rem)]!"}`
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ a(
|
|
86
97
|
"input",
|
|
87
98
|
{
|
|
88
|
-
value:
|
|
99
|
+
value: i.year,
|
|
89
100
|
placeholder: "年",
|
|
90
|
-
...
|
|
101
|
+
...d("年"),
|
|
91
102
|
maxLength: 4,
|
|
92
103
|
type: "text",
|
|
93
|
-
disabled:
|
|
94
|
-
onChange: (e) =>
|
|
95
|
-
|
|
104
|
+
disabled: l,
|
|
105
|
+
onChange: (e) => j("year", e.target.value),
|
|
106
|
+
onBlur: k,
|
|
107
|
+
className: `w-[calc(var(--sp-medium,0.75rem)*2+5ch)]! ${O}`
|
|
96
108
|
}
|
|
97
109
|
),
|
|
98
110
|
"/",
|
|
99
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ a(
|
|
100
112
|
"input",
|
|
101
113
|
{
|
|
102
|
-
value:
|
|
114
|
+
value: i.month,
|
|
103
115
|
placeholder: "月",
|
|
104
|
-
...
|
|
116
|
+
...d("月"),
|
|
105
117
|
maxLength: 2,
|
|
106
118
|
type: "text",
|
|
107
|
-
disabled:
|
|
108
|
-
onChange: (e) =>
|
|
109
|
-
|
|
119
|
+
disabled: l,
|
|
120
|
+
onChange: (e) => j("month", e.target.value),
|
|
121
|
+
onBlur: k,
|
|
122
|
+
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${O}`
|
|
110
123
|
}
|
|
111
124
|
),
|
|
112
|
-
t === "date" && /* @__PURE__ */
|
|
113
|
-
t === "date" && /* @__PURE__ */
|
|
125
|
+
t === "date" && /* @__PURE__ */ a("span", { children: "/" }),
|
|
126
|
+
t === "date" && /* @__PURE__ */ a(
|
|
114
127
|
"input",
|
|
115
128
|
{
|
|
116
|
-
value:
|
|
129
|
+
value: i.day,
|
|
117
130
|
placeholder: "日",
|
|
118
|
-
...
|
|
131
|
+
...d("日"),
|
|
119
132
|
maxLength: 2,
|
|
120
133
|
type: "text",
|
|
121
|
-
disabled:
|
|
122
|
-
onChange: (e) =>
|
|
123
|
-
|
|
134
|
+
disabled: l,
|
|
135
|
+
onChange: (e) => j("day", e.target.value),
|
|
136
|
+
onBlur: k,
|
|
137
|
+
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${O}`
|
|
124
138
|
}
|
|
125
139
|
),
|
|
126
|
-
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
/* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */
|
|
140
|
+
b && /* @__PURE__ */ V("span", { className: "sr-only", children: [
|
|
141
|
+
/* @__PURE__ */ a("span", { id: `${c}-カレンダー`, children: "のカレンダー" }),
|
|
142
|
+
/* @__PURE__ */ a("span", { id: `${c}-年`, children: "の年" }),
|
|
143
|
+
/* @__PURE__ */ a("span", { id: `${c}-月`, children: "の月" }),
|
|
144
|
+
/* @__PURE__ */ a("span", { id: `${c}-日`, children: "の日" })
|
|
130
145
|
] }),
|
|
131
|
-
/* @__PURE__ */
|
|
146
|
+
/* @__PURE__ */ a(Z, { errorMessages: $ ? [$] : void 0 })
|
|
132
147
|
]
|
|
133
148
|
}
|
|
134
149
|
);
|
|
135
150
|
}
|
|
136
151
|
export {
|
|
137
|
-
|
|
152
|
+
ne as DatePicker
|
|
138
153
|
};
|
|
@@ -1,75 +1,75 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { COLOR as
|
|
4
|
-
import { DatePicker as
|
|
5
|
-
import { ErrorMessage as
|
|
6
|
-
import { useRegisterValidation as
|
|
7
|
-
const
|
|
8
|
-
function
|
|
2
|
+
import { jsxs as u, jsx as a } from "react/jsx-runtime";
|
|
3
|
+
import { formatDateValue as E, COLOR as x, MESSAGES as p } from "@geckou/ui-core";
|
|
4
|
+
import { DatePicker as v } from "./DatePicker.js";
|
|
5
|
+
import { ErrorMessage as M } from "./ErrorMessage.js";
|
|
6
|
+
import { useRegisterValidation as N } from "../hooks/useFormValidation.js";
|
|
7
|
+
const S = { start: "", end: "" };
|
|
8
|
+
function G({
|
|
9
9
|
name: d,
|
|
10
|
-
value: r =
|
|
10
|
+
value: r = S,
|
|
11
11
|
onChange: e,
|
|
12
|
-
isDisabled:
|
|
13
|
-
isRequired:
|
|
14
|
-
formValidationStore:
|
|
15
|
-
minDate:
|
|
16
|
-
maxDate:
|
|
17
|
-
size:
|
|
18
|
-
type:
|
|
12
|
+
isDisabled: l,
|
|
13
|
+
isRequired: i,
|
|
14
|
+
formValidationStore: n,
|
|
15
|
+
minDate: m = "",
|
|
16
|
+
maxDate: f = "",
|
|
17
|
+
size: b = "medium",
|
|
18
|
+
type: t = "date"
|
|
19
19
|
}) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
"--range-background-color":
|
|
24
|
-
"--range-border-color":
|
|
20
|
+
const s = E(r.start, t), o = E(r.end, t), g = !(s && o && s > o);
|
|
21
|
+
N(n, `${d}Range`, g);
|
|
22
|
+
const h = (c) => e == null ? void 0 : e({ start: c, end: r.end }), R = (c) => e == null ? void 0 : e({ start: r.start, end: c }), k = {
|
|
23
|
+
"--range-background-color": x.white,
|
|
24
|
+
"--range-border-color": x.gray
|
|
25
25
|
};
|
|
26
26
|
return (
|
|
27
27
|
// 角丸・区切り線は :first-child / :last-child で割り当てるため、
|
|
28
28
|
// ErrorMessage を同じ階層に置くとエラー表示時だけ枠の見た目が変わる。
|
|
29
29
|
// 入力群を内側にまとめ、ErrorMessage は外側(relative)に置く
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
/* @__PURE__ */
|
|
33
|
-
|
|
30
|
+
/* @__PURE__ */ u("div", { style: k, className: "relative", children: [
|
|
31
|
+
/* @__PURE__ */ u("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__ */ a(
|
|
33
|
+
v,
|
|
34
34
|
{
|
|
35
35
|
name: `${d}Start`,
|
|
36
36
|
value: r.start,
|
|
37
|
-
isDisabled:
|
|
38
|
-
isRequired:
|
|
39
|
-
formValidationStore:
|
|
40
|
-
minDate:
|
|
41
|
-
maxDate:
|
|
42
|
-
size:
|
|
43
|
-
type:
|
|
44
|
-
onChange:
|
|
37
|
+
isDisabled: l,
|
|
38
|
+
isRequired: i,
|
|
39
|
+
formValidationStore: n,
|
|
40
|
+
minDate: m,
|
|
41
|
+
maxDate: o || f,
|
|
42
|
+
size: b,
|
|
43
|
+
type: t,
|
|
44
|
+
onChange: h
|
|
45
45
|
}
|
|
46
46
|
),
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
|
|
47
|
+
/* @__PURE__ */ a("div", { className: "flex flex-none! items-center px-[var(--bv,0.375rem)]", children: "〜" }),
|
|
48
|
+
/* @__PURE__ */ a(
|
|
49
|
+
v,
|
|
50
50
|
{
|
|
51
51
|
name: `${d}End`,
|
|
52
52
|
value: r.end,
|
|
53
|
-
isDisabled:
|
|
54
|
-
isRequired:
|
|
55
|
-
formValidationStore:
|
|
56
|
-
minDate:
|
|
57
|
-
maxDate:
|
|
58
|
-
size:
|
|
59
|
-
type:
|
|
60
|
-
onChange:
|
|
53
|
+
isDisabled: l,
|
|
54
|
+
isRequired: i,
|
|
55
|
+
formValidationStore: n,
|
|
56
|
+
minDate: s || m,
|
|
57
|
+
maxDate: f,
|
|
58
|
+
size: b,
|
|
59
|
+
type: t,
|
|
60
|
+
onChange: R
|
|
61
61
|
}
|
|
62
62
|
)
|
|
63
63
|
] }),
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
|
|
64
|
+
/* @__PURE__ */ a(
|
|
65
|
+
M,
|
|
66
66
|
{
|
|
67
|
-
errorMessages:
|
|
67
|
+
errorMessages: g ? void 0 : [p.startAfterEnd]
|
|
68
68
|
}
|
|
69
69
|
)
|
|
70
70
|
] })
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
export {
|
|
74
|
-
|
|
74
|
+
G as DateRangePicker
|
|
75
75
|
};
|