@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 CHANGED
@@ -108,6 +108,28 @@ 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
+
111
133
  ## 0.6.0 の変更
112
134
 
113
135
  - `ModalBox` を重ねたとき、Escape で閉じるのは**最前面の 1 枚だけ**になった
@@ -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 v, Fragment as C, jsx as i } from "react/jsx-runtime";
3
- import { CheckIcon as _ } from "./icons/CheckIcon.js";
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 j({
5
+ function y({
6
6
  name: l,
7
- checked: s,
7
+ value: s,
8
+ checked: f,
8
9
  onChange: c,
9
10
  isDisabled: e,
10
11
  cssStyle: r,
11
- isDisableAnimation: f,
12
- check: k,
13
- ariaLabel: p,
12
+ isDisableAnimation: k,
13
+ check: p,
14
+ ariaLabel: h,
14
15
  ariaLabelledBy: a
15
16
  }) {
16
17
  var n, u, b;
17
- const o = s ?? !1, h = e ? r == null ? void 0 : r.disabled : r == null ? void 0 : r.default, d = {
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
- ...h
26
- }, x = {
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": f ? "0s" : ".3s"
33
+ "--duration": k ? "0s" : ".3s"
33
34
  };
34
- return /* @__PURE__ */ v(C, { children: [
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: x,
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 : p ?? l,
46
+ "aria-label": a ? void 0 : h ?? l,
46
47
  disabled: e,
47
- onClick: (m) => {
48
- m.stopPropagation(), e || c == null || c(!o);
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: k ?? /* @__PURE__ */ i(_, {})
56
+ children: p ?? /* @__PURE__ */ i(g, {})
56
57
  }
57
58
  )
58
59
  }
59
60
  ),
60
- o && /* @__PURE__ */ i("input", { type: "hidden", name: l, value: "on", disabled: e })
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
- j as CheckBox
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 i, MESSAGES as V } from "@geckou/ui-core";
4
- import { useState as p, useRef as w, useEffect as R } from "react";
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: b,
9
- options: a,
10
- value: r,
8
+ name: k,
9
+ options: u,
10
+ value: e,
11
11
  onChange: s,
12
- isDisabled: k,
12
+ isDisabled: p,
13
13
  isRequired: C,
14
14
  cssStyle: o
15
15
  }) {
16
- const [u, d] = p(r ?? []), [f, h] = p(""), m = (e) => h(
17
- C && e.length === 0 ? V.required : ""
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, r != null && r.length && m(r);
21
+ n.current = !1, e != null && e.length && m(e);
22
22
  return;
23
23
  }
24
- r && d(r);
25
- }, [r]);
26
- const E = (e, c) => {
27
- const l = a.map((t) => t.value).filter(
28
- (t) => t === e ? c : u.includes(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(l), m(l), s == null || s(l);
30
+ d(c), m(c), s == null || s(c);
31
31
  }, x = {
32
32
  ...(o == null ? void 0 : o.error) ?? {},
33
- textColor: i.white,
34
- backgroundColor: i.red,
33
+ textColor: a.white,
34
+ backgroundColor: a.red,
35
35
  border: {
36
- color: i.red,
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
- a.map((e) => /* @__PURE__ */ g(
42
+ u.map((r) => /* @__PURE__ */ g(
43
43
  j,
44
44
  {
45
- name: b,
46
- label: e.label,
47
- checked: u.includes(e.value),
48
- onChange: (c) => E(e.value, c),
49
- isDisabled: k,
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
- e.value
53
+ r.value
53
54
  )),
54
55
  /* @__PURE__ */ g(
55
56
  L,
@@ -1,90 +1,93 @@
1
1
  "use client";
2
- import { jsxs as j, jsx as a } from "react/jsx-runtime";
3
- import { formatDateValue as V, splitDate as w, COLOR as H, MESSAGES as J, composeDateValue as K, validateDateObject as Q } from "@geckou/ui-core";
4
- import { useState as m, useRef as T, useEffect as U, useId as W } from "react";
5
- import { InputBox as X } from "./InputBox.js";
6
- import { ErrorMessage as Y } from "./ErrorMessage.js";
7
- import { CalendarIcon as Z } from "./icons/CalendarIcon.js";
8
- import { useRegisterValidation as _ } from "../hooks/useFormValidation.js";
9
- function le({
10
- name: d,
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
11
  value: r,
12
12
  onChange: s,
13
- cssStyle: M,
14
- isDisabled: i,
15
- isRequired: p,
16
- formValidationStore: D,
13
+ cssStyle: D,
14
+ isDisabled: l,
15
+ isRequired: v,
16
+ formValidationStore: M,
17
17
  minDate: L = "",
18
- maxDate: z = "",
18
+ maxDate: B = "",
19
19
  size: P = "medium",
20
20
  type: t = "date",
21
21
  ariaLabel: A,
22
- ariaLabelledBy: u
22
+ ariaLabelledBy: b
23
23
  }) {
24
- const [y, f] = m(
25
- () => r ? V(r, t) : ""
26
- ), [c, v] = m(
27
- () => r ? w(V(r, t)) : { year: "", month: "", day: "" }
28
- ), [h, O] = m(""), [G, b] = m(!0), N = T(r);
29
- U(() => {
30
- if (N.current === r)
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
- N.current = r;
33
- const e = r ? V(r, t) : "";
34
- f(e), v(w(e)), b(!0);
32
+ E.current = r;
33
+ const e = r ? w(r, t) : "";
34
+ x(e), m(N(e)), g(!0);
35
35
  }, [r, t]);
36
- const I = (e) => !e && p ? { isValid: !1, message: J.required } : { isValid: !0, message: "" }, R = (e) => Q(e, { type: t, isRequired: p }), q = (e) => {
37
- f(e), v(w(e));
38
- const { message: g } = I(e);
39
- O(g), b(!0), s == null || s(e);
40
- }, x = (e, g) => {
41
- const k = { ...c, [e]: g };
42
- v(k);
43
- const { isValid: E, message: F } = R(k);
44
- if (O(F), b(E), E) {
45
- const S = K(k, t);
46
- f(S), s == null || s(S);
47
- }
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
- D,
51
- d,
52
- I(y).isValid && G
52
+ ee(
53
+ M,
54
+ f,
55
+ S(h).isValid && G
53
56
  );
54
- const l = W(), n = (e) => u ? { "aria-labelledby": `${u} ${l}-${e}` } : { "aria-label": `${A ?? d}の${e}` }, o = P === "small", $ = `flex-none! ${o ? "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 };
55
- return /* @__PURE__ */ j(
56
- X,
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: M,
59
- isDisabled: i,
60
- isErrored: !!h,
61
- className: `flex w-full items-center leading-none ${o ? "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)]"}`,
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__ */ j(
66
+ /* @__PURE__ */ V(
64
67
  "div",
65
68
  {
66
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)",
67
70
  style: C,
68
71
  children: [
69
72
  /* @__PURE__ */ a(
70
- Z,
73
+ _,
71
74
  {
72
- className: `pointer-events-none absolute inset-y-0 left-[var(--sp-small,0.375rem)] m-auto fill-(--icon-color) ${o ? "size-[var(--icon-small,0.9375rem)]" : "size-[var(--icon-medium,1.125rem)]"}`
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)]"}`
73
76
  }
74
77
  ),
75
78
  /* @__PURE__ */ a(
76
79
  "input",
77
80
  {
78
81
  type: t,
79
- name: d,
80
- value: y,
81
- ...n("カレンダー"),
82
- max: z,
82
+ name: f,
83
+ value: h,
84
+ ...d("カレンダー"),
85
+ max: B,
83
86
  min: L,
84
- required: p,
85
- disabled: i,
87
+ required: v,
88
+ disabled: l,
86
89
  onChange: (e) => q(e.target.value),
87
- 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 ${o ? "py-[var(--sp-min,0.1875rem)]!" : "py-[var(--sp-medium,0.75rem)]!"}`
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)]!"}`
88
91
  }
89
92
  )
90
93
  ]
@@ -93,55 +96,58 @@ function le({
93
96
  /* @__PURE__ */ a(
94
97
  "input",
95
98
  {
96
- value: c.year,
99
+ value: i.year,
97
100
  placeholder: "年",
98
- ...n("年"),
101
+ ...d("年"),
99
102
  maxLength: 4,
100
103
  type: "text",
101
- disabled: i,
102
- onChange: (e) => x("year", e.target.value),
103
- className: `w-[calc(var(--sp-medium,0.75rem)*2+5ch)]! ${$}`
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}`
104
108
  }
105
109
  ),
106
110
  "/",
107
111
  /* @__PURE__ */ a(
108
112
  "input",
109
113
  {
110
- value: c.month,
114
+ value: i.month,
111
115
  placeholder: "月",
112
- ...n("月"),
116
+ ...d("月"),
113
117
  maxLength: 2,
114
118
  type: "text",
115
- disabled: i,
116
- onChange: (e) => x("month", e.target.value),
117
- className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${$}`
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}`
118
123
  }
119
124
  ),
120
125
  t === "date" && /* @__PURE__ */ a("span", { children: "/" }),
121
126
  t === "date" && /* @__PURE__ */ a(
122
127
  "input",
123
128
  {
124
- value: c.day,
129
+ value: i.day,
125
130
  placeholder: "日",
126
- ...n("日"),
131
+ ...d("日"),
127
132
  maxLength: 2,
128
133
  type: "text",
129
- disabled: i,
130
- onChange: (e) => x("day", e.target.value),
131
- className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${$}`
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}`
132
138
  }
133
139
  ),
134
- u && /* @__PURE__ */ j("span", { className: "sr-only", children: [
135
- /* @__PURE__ */ a("span", { id: `${l}-カレンダー`, children: "のカレンダー" }),
136
- /* @__PURE__ */ a("span", { id: `${l}-年`, children: "の年" }),
137
- /* @__PURE__ */ a("span", { id: `${l}-月`, children: "の月" }),
138
- /* @__PURE__ */ a("span", { id: `${l}-日`, children: "の日" })
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: "の日" })
139
145
  ] }),
140
- /* @__PURE__ */ a(Y, { errorMessages: h ? [h] : void 0 })
146
+ /* @__PURE__ */ a(Z, { errorMessages: $ ? [$] : void 0 })
141
147
  ]
142
148
  }
143
149
  );
144
150
  }
145
151
  export {
146
- le as DatePicker
152
+ ne as DatePicker
147
153
  };
@@ -1,75 +1,75 @@
1
1
  "use client";
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 $({
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 = M,
10
+ value: r = S,
11
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"
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 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
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__ */ 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
+ /* @__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: a,
38
- isRequired: c,
39
- formValidationStore: s,
40
- minDate: o,
41
- maxDate: r.end || i,
42
- size: l,
43
- type: m,
44
- onChange: E
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__ */ t("div", { className: "flex flex-none! items-center px-[var(--bv,0.375rem)]", children: "〜" }),
48
- /* @__PURE__ */ t(
49
- x,
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: a,
54
- isRequired: c,
55
- formValidationStore: s,
56
- minDate: r.start || o,
57
- maxDate: i,
58
- size: l,
59
- type: m,
60
- onChange: p
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__ */ t(
65
- k,
64
+ /* @__PURE__ */ a(
65
+ M,
66
66
  {
67
- errorMessages: f ? void 0 : [R.startAfterEnd]
67
+ errorMessages: g ? void 0 : [p.startAfterEnd]
68
68
  }
69
69
  )
70
70
  ] })
71
71
  );
72
72
  }
73
73
  export {
74
- $ as DateRangePicker
74
+ G as DateRangePicker
75
75
  };
@@ -1,22 +1,22 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { COLOR as t } from "@geckou/ui-core";
3
- function f({ errorMessages: o, cssStyle: r }) {
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 b = {
7
- "--error-text-color": (r == null ? void 0 : r.textColor) || t.white,
8
- "--error-background-color": (r == null ? void 0 : r.backgroundColor) || t.red
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__ */ n(
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: b,
16
- children: o.map((e) => /* @__PURE__ */ n("span", { children: e }, e))
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
- f as ErrorMessage
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 {};