@geckou/ui-react 0.1.0 → 0.2.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.
Files changed (103) hide show
  1. package/README.md +46 -5
  2. package/dist/components/BasicButton.d.ts +14 -0
  3. package/dist/components/BasicButton.js +57 -0
  4. package/dist/components/CheckBox.d.ts +13 -0
  5. package/dist/components/CheckBox.js +74 -0
  6. package/dist/components/CheckBoxes.d.ts +12 -0
  7. package/dist/components/CheckBoxes.js +68 -0
  8. package/dist/components/CheckButton.d.ts +13 -0
  9. package/dist/components/CheckButton.js +56 -0
  10. package/dist/components/DatePicker.d.ts +18 -0
  11. package/dist/components/DatePicker.js +131 -0
  12. package/dist/components/DateRangePicker.d.ts +22 -0
  13. package/dist/components/DateRangePicker.js +65 -0
  14. package/dist/components/DateSelector.d.ts +13 -0
  15. package/dist/components/DateSelector.js +129 -0
  16. package/dist/components/DropdownUi.d.ts +16 -0
  17. package/dist/components/DropdownUi.js +88 -0
  18. package/dist/components/ErrorMessage.d.ts +9 -0
  19. package/dist/components/ErrorMessage.js +21 -0
  20. package/dist/components/FileInput.d.ts +7 -0
  21. package/dist/components/FileInput.js +91 -0
  22. package/dist/components/InputBox.d.ts +11 -0
  23. package/dist/components/InputBox.js +75 -0
  24. package/dist/components/InputGroup.d.ts +6 -0
  25. package/dist/components/InputGroup.js +7 -0
  26. package/dist/components/LabeledCheckbox.d.ts +12 -0
  27. package/dist/components/LabeledCheckbox.js +46 -0
  28. package/dist/components/LabeledFieldset.d.ts +8 -0
  29. package/dist/components/LabeledFieldset.js +10 -0
  30. package/dist/components/LoadingSpinner.d.ts +1 -0
  31. package/dist/components/LoadingSpinner.js +26 -0
  32. package/dist/components/ModalBox.d.ts +12 -0
  33. package/dist/components/ModalBox.js +83 -0
  34. package/dist/components/PopupBox.d.ts +14 -0
  35. package/dist/components/PopupBox.js +41 -0
  36. package/dist/components/RadioButtons.d.ts +13 -0
  37. package/dist/components/RadioButtons.js +64 -0
  38. package/dist/components/SearchableSelectBox.d.ts +14 -0
  39. package/dist/components/SearchableSelectBox.js +61 -0
  40. package/dist/components/SelectBox.d.ts +16 -0
  41. package/dist/components/SelectBox.js +107 -0
  42. package/dist/components/SlideDownUi.d.ts +17 -0
  43. package/dist/components/SlideDownUi.js +86 -0
  44. package/dist/components/TabUI.d.ts +19 -0
  45. package/dist/components/TabUI.js +76 -0
  46. package/dist/components/TextArea.d.ts +18 -0
  47. package/dist/components/TextArea.js +75 -0
  48. package/dist/components/TextBox.d.ts +20 -0
  49. package/dist/components/TextBox.js +90 -0
  50. package/dist/components/ToggleButton.d.ts +15 -0
  51. package/dist/components/ToggleButton.js +92 -0
  52. package/dist/components/icons/BackupIcon.d.ts +5 -0
  53. package/dist/components/icons/BackupIcon.js +16 -0
  54. package/dist/components/icons/CalendarIcon.d.ts +5 -0
  55. package/dist/components/icons/CalendarIcon.js +15 -0
  56. package/dist/components/icons/CheckIcon.d.ts +1 -0
  57. package/dist/components/icons/CheckIcon.js +7 -0
  58. package/dist/components/icons/CloseIcon.d.ts +5 -0
  59. package/dist/components/icons/CloseIcon.js +16 -0
  60. package/dist/components/icons/KeyboardArrowDownIcon.d.ts +5 -0
  61. package/dist/components/icons/KeyboardArrowDownIcon.js +16 -0
  62. package/dist/constants/index.d.ts +1 -0
  63. package/dist/hooks/useFormValidation.d.ts +33 -0
  64. package/dist/hooks/useFormValidation.js +28 -0
  65. package/dist/index.d.ts +38 -0
  66. package/dist/index.js +70 -0
  67. package/{src → dist}/styles/tokens.css +1 -1
  68. package/dist/types/index.d.ts +1 -0
  69. package/package.json +17 -12
  70. package/src/components/BasicButton.tsx +0 -81
  71. package/src/components/CheckBox.tsx +0 -87
  72. package/src/components/CheckBoxes.tsx +0 -93
  73. package/src/components/CheckButton.tsx +0 -66
  74. package/src/components/DatePicker.tsx +0 -154
  75. package/src/components/DateRangePicker.tsx +0 -59
  76. package/src/components/DateSelector.tsx +0 -162
  77. package/src/components/DropdownUi.tsx +0 -126
  78. package/src/components/ErrorMessage.tsx +0 -30
  79. package/src/components/FileInput.tsx +0 -93
  80. package/src/components/InputBox.tsx +0 -118
  81. package/src/components/InputGroup.tsx +0 -13
  82. package/src/components/LabeledCheckbox.tsx +0 -61
  83. package/src/components/LabeledFieldset.tsx +0 -18
  84. package/src/components/LoadingSpinner.tsx +0 -23
  85. package/src/components/ModalBox.tsx +0 -109
  86. package/src/components/PopupBox.tsx +0 -70
  87. package/src/components/RadioButtons.tsx +0 -94
  88. package/src/components/SearchableSelectBox.tsx +0 -108
  89. package/src/components/SelectBox.tsx +0 -152
  90. package/src/components/SlideDownUi.tsx +0 -123
  91. package/src/components/TabUI.tsx +0 -112
  92. package/src/components/TextArea.tsx +0 -102
  93. package/src/components/TextBox.tsx +0 -120
  94. package/src/components/ToggleButton.tsx +0 -102
  95. package/src/components/icons/BackupIcon.tsx +0 -16
  96. package/src/components/icons/CalendarIcon.tsx +0 -15
  97. package/src/components/icons/CheckIcon.tsx +0 -7
  98. package/src/components/icons/CloseIcon.tsx +0 -16
  99. package/src/components/icons/KeyboardArrowDownIcon.tsx +0 -16
  100. package/src/constants/index.ts +0 -2
  101. package/src/hooks/useFormValidation.ts +0 -69
  102. package/src/index.ts +0 -66
  103. package/src/types/index.ts +0 -23
package/README.md CHANGED
@@ -13,11 +13,32 @@ Mobile(Expo / NativeWind)では使えない(DOM 前提のため)。
13
13
  yarn add @geckou/ui-react
14
14
  ```
15
15
 
16
- ソースをそのまま配布しているため、利用側でトランスパイルの対象に含める。
16
+ ビルド済みの JavaScript と型定義(`dist/`)を配布しています。トランスパイルの設定は要りません。
17
17
 
18
- 1. `next.config.ts` `transpilePackages` `'@geckou/ui-react'` を追加
19
- 2. `tailwind.config.ts` の `content` に `'./node_modules/@geckou/ui-react/src/**/*.{ts,tsx}'` を追加
20
- 3. グローバル CSS に `@import '@geckou/ui-react/styles/tokens.css';` を追加(デザイントークン)
18
+ 1. グローバル CSS`@import '@geckou/ui-react/styles/tokens.css';` を追加(デザイントークン)
19
+ 2. Tailwind を使う場合は、配布物をスキャン対象に加える
20
+
21
+ **Tailwind CSS v4 が必須です。** コンポーネントは `bg-(--background-color)`、
22
+ `rounded-(--radius-size)`、`flex-none!` のような v4 の記法を直書きしているため、
23
+ v3 ではこれらのクラスが生成されません。v4 はスキャン対象を CSS 側の `@source` で指定します。
24
+
25
+ ```css
26
+ /* グローバル CSS */
27
+ @import 'tailwindcss';
28
+ @source '../node_modules/@geckou/ui-react/dist';
29
+
30
+ @import '@geckou/ui-react/styles/tokens.css';
31
+ ```
32
+
33
+ `@source` のパスは、その CSS ファイルからの相対で書きます。
34
+
35
+ `'use client'` はビルド後も各ファイルの先頭に残るので、Next.js の App Router では
36
+ Server Component から直接 import できます(状態を持つコンポーネントだけが Client Component になります)。
37
+
38
+ > **0.1.1 以前から更新する場合**: ソース配布をやめたため、`next.config.ts` の
39
+ > `transpilePackages` から `'@geckou/ui-react'` を外し、Tailwind のスキャン対象を
40
+ > `src/**/*.{ts,tsx}` から `dist` に変えてください。`transpilePackages` は
41
+ > 残しても動きますが、スキャン対象が `src` のままだとクラスが検出されずスタイルが当たりません。
21
42
 
22
43
  `tokens.css` は既定値です。上書きする変数の一覧はリポジトリの [README](../../README.md#design-tokens) を参照してください。
23
44
 
@@ -31,18 +52,38 @@ import { TextBox, BasicButton, ModalBox } from '@geckou/ui-react'
31
52
 
32
53
  `useFormValidation` で各入力の検証結果を集約する。
33
54
  Vue 版の `FormValidationManager` と同じストア(`@geckou/ui-core`)を使う。
55
+ **`store` を入力コンポーネントの `formValidationStore` に渡してください**(渡さない入力は集計されません)。
56
+ 対応しているのは `DatePicker` / `DateRangePicker` / `DateSelector`。
34
57
 
35
58
  ```tsx
36
59
  const { isAllValid, store } = useFormValidation()
60
+ const [startedOn, setStartedOn] = useState('')
61
+ const [period, setPeriod] = useState({ start: '', end: '' })
37
62
 
38
63
  return (
39
64
  <form>
40
- <DatePicker name="startedOn" isRequired />
65
+ <DatePicker
66
+ name="startedOn"
67
+ value={startedOn}
68
+ onChange={setStartedOn}
69
+ isRequired
70
+ formValidationStore={store}
71
+ />
72
+ <DateRangePicker name="period" value={period} onChange={setPeriod} />
41
73
  <button disabled={!isAllValid}>送信</button>
42
74
  </form>
43
75
  )
44
76
  ```
45
77
 
78
+ props は Vue 版(`@geckou/ui-vue`)と揃えている。`v-model` にあたるものが
79
+ `value` + `onChange` になるだけで、名前と意味は同じ。
80
+
81
+ | Component | value | 主な props |
82
+ |-----------|-------|-----------|
83
+ | `DatePicker` | `string`(`YYYY-MM-DD` / `type="month"` なら `YYYY-MM`) | `name` / `isRequired` / `isDisabled` / `minDate` / `maxDate` / `size` / `type` / `formValidationStore` |
84
+ | `DateRangePicker` | `{ start: string; end: string }` | `DatePicker` と同じ(開始日と終了日の min / max が自動連動)。各入力の name は `<name>Start` / `<name>End` |
85
+ | `DateSelector` | `string`(`YYYY-MM-DD` / `type="month"` なら `YYYY-MM`) | `name` / `isRequired` / `type` / `formValidationStore` |
86
+
46
87
  ## 収録コンポーネント
47
88
 
48
89
  フォーム系 25 種(`TextBox` / `TextArea` / `SelectBox` / `SearchableSelectBox` / `CheckBox` 系 /
@@ -0,0 +1,14 @@
1
+ import { MouseEventHandler, ReactNode } from 'react';
2
+ import { ButtonStyleForEachStatus } from '../types';
3
+ type Props = {
4
+ cssStyle?: ButtonStyleForEachStatus;
5
+ duration?: number;
6
+ isLoading?: boolean;
7
+ isDisabled?: boolean;
8
+ buttonType?: 'button' | 'submit' | 'reset';
9
+ onClick?: MouseEventHandler<HTMLButtonElement>;
10
+ loading?: ReactNode;
11
+ children?: ReactNode;
12
+ };
13
+ export declare function BasicButton({ cssStyle, duration, isLoading, isDisabled, buttonType, onClick, loading, children, }: Props): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { jsxs as z, jsx as t } from "react/jsx-runtime";
3
+ import { LoadingSpinner as $ } from "./LoadingSpinner.js";
4
+ import { COLOR as n } from "@geckou/ui-core";
5
+ function B({
6
+ cssStyle: r,
7
+ duration: m = 0.3,
8
+ isLoading: d,
9
+ isDisabled: a,
10
+ buttonType: v = "button",
11
+ onClick: f,
12
+ loading: k,
13
+ children: p
14
+ }) {
15
+ var b, u, i, l, c, s, h, x, g;
16
+ const w = a ? r == null ? void 0 : r.disabled : r == null ? void 0 : r.default, o = {
17
+ textColor: n.white,
18
+ backgroundColor: a ? n.darkGray : n.blue,
19
+ backgroundImage: "none",
20
+ border: {
21
+ color: a ? n.darkGray : n.blue,
22
+ size: "1px",
23
+ radius: ".25rem"
24
+ },
25
+ boxShadow: "0 0 0 0 transparent",
26
+ ...w
27
+ }, e = (r == null ? void 0 : r.hover) || {}, C = {
28
+ "--text-color": o.textColor,
29
+ "--background-color": o.backgroundColor,
30
+ "--background-image": o.backgroundImage,
31
+ "--radius-size": (b = o.border) == null ? void 0 : b.radius,
32
+ "--button-shadow": `0 0 0 ${(u = o.border) == null ? void 0 : u.size} ${(i = o.border) == null ? void 0 : i.color} inset, ${o.boxShadow}`,
33
+ "--hover-text-color": e.textColor || o.textColor,
34
+ "--hover-background-color": e.backgroundColor || o.backgroundColor && `${o.backgroundColor}cc`,
35
+ "--hover-background-image": e.backgroundImage || o.backgroundImage,
36
+ "--hover-radius-size": ((l = e.border) == null ? void 0 : l.radius) || ((c = o.border) == null ? void 0 : c.radius),
37
+ "--hover-button-shadow": `0 0 0 ${((s = e.border) == null ? void 0 : s.size) || ((h = o.border) == null ? void 0 : h.size)} ${((x = e.border) == null ? void 0 : x.color) || ((g = o.border) == null ? void 0 : g.color)} inset, ${e.boxShadow || o.boxShadow}`,
38
+ "--duration": `${m}s`
39
+ };
40
+ return /* @__PURE__ */ z(
41
+ "button",
42
+ {
43
+ type: v,
44
+ disabled: a || d,
45
+ onClick: f,
46
+ style: C,
47
+ className: "relative inline-flex w-max cursor-pointer items-center justify-center rounded-(--radius-size) border-none bg-(--background-color) px-8 py-4 leading-none text-(--text-color) shadow-(--button-shadow) transition-all duration-(--duration) enabled:hover:rounded-(--hover-radius-size) enabled:hover:bg-(--hover-background-color) enabled:hover:text-(--hover-text-color) enabled:hover:shadow-(--hover-button-shadow) disabled:pointer-events-none disabled:before:pointer-events-auto disabled:before:absolute disabled:before:inset-0 disabled:before:cursor-not-allowed disabled:before:content-['']",
48
+ children: [
49
+ d && /* @__PURE__ */ t("span", { className: "absolute inset-0 m-auto flex max-h-[calc(100%-1.5rem)] items-center justify-center fill-current text-current [&_*]:max-h-full [&_*]:fill-current", children: k ?? /* @__PURE__ */ t($, {}) }),
50
+ /* @__PURE__ */ t("span", { className: d ? "invisible" : void 0, children: p })
51
+ ]
52
+ }
53
+ );
54
+ }
55
+ export {
56
+ B as BasicButton
57
+ };
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ import { CheckBoxStyleForEachStatus } from '../types';
3
+ type Props = {
4
+ name: string;
5
+ checked?: boolean;
6
+ onChange?: (newValue: boolean) => void;
7
+ isDisabled?: boolean;
8
+ cssStyle?: CheckBoxStyleForEachStatus;
9
+ isDisableAnimation?: boolean;
10
+ check?: ReactNode;
11
+ };
12
+ export declare function CheckBox({ name, checked, onChange, isDisabled, cssStyle, isDisableAnimation, check, }: Props): import("react").JSX.Element;
13
+ export {};
@@ -0,0 +1,74 @@
1
+ "use client";
2
+ import { jsxs as b, Fragment as x, jsx as c } from "react/jsx-runtime";
3
+ import { CheckIcon as v } from "./icons/CheckIcon.js";
4
+ import { COLOR as t } from "@geckou/ui-core";
5
+ function j({
6
+ name: l,
7
+ checked: f,
8
+ onChange: r,
9
+ isDisabled: e,
10
+ cssStyle: o,
11
+ isDisableAnimation: p,
12
+ check: k
13
+ }) {
14
+ var u, s, n;
15
+ const i = f ?? !1, h = e ? o == null ? void 0 : o.disabled : o == null ? void 0 : o.default, d = {
16
+ textColor: e ? t.darkGray : t.blue,
17
+ backgroundColor: e ? t.lightGray : t.white,
18
+ border: {
19
+ color: e ? t.darkGray : t.blue,
20
+ size: "1px",
21
+ radius: ".25rem"
22
+ },
23
+ ...h
24
+ }, m = {
25
+ "--text-color": d.textColor,
26
+ "--border-color": (u = d.border) == null ? void 0 : u.color,
27
+ "--border-size": (s = d.border) == null ? void 0 : s.size,
28
+ "--radius-size": (n = d.border) == null ? void 0 : n.radius,
29
+ "--background-color": d.backgroundColor,
30
+ "--duration": p ? "0s" : ".3s"
31
+ };
32
+ return /* @__PURE__ */ b(x, { children: [
33
+ /* @__PURE__ */ c("style", { children: "@keyframes uiCheckPop{0%{scale:1}10%{scale:.8}50%{scale:1.1}100%{scale:1}}" }),
34
+ /* @__PURE__ */ b(
35
+ "button",
36
+ {
37
+ type: "button",
38
+ style: m,
39
+ "aria-label": l,
40
+ "aria-pressed": i,
41
+ disabled: e,
42
+ onClick: (a) => {
43
+ a.stopPropagation(), e || r == null || r(!i);
44
+ },
45
+ 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
+ children: [
47
+ /* @__PURE__ */ c(
48
+ "input",
49
+ {
50
+ type: "checkbox",
51
+ name: l,
52
+ checked: i,
53
+ disabled: e,
54
+ onChange: (a) => {
55
+ e || r == null || r(a.target.checked);
56
+ },
57
+ className: "hidden"
58
+ }
59
+ ),
60
+ /* @__PURE__ */ c(
61
+ "div",
62
+ {
63
+ className: `flex h-4 w-4 items-center justify-center [&>*]:fill-current [&>*]:text-current ${i ? "text-(--background-color)" : "text-(--border-color)"}`,
64
+ children: k ?? /* @__PURE__ */ c(v, {})
65
+ }
66
+ )
67
+ ]
68
+ }
69
+ )
70
+ ] });
71
+ }
72
+ export {
73
+ j as CheckBox
74
+ };
@@ -0,0 +1,12 @@
1
+ import { Option, SelectValue, CheckBoxStyleForEachStatus } from '../types';
2
+ type Props = {
3
+ name: string;
4
+ options: Option[];
5
+ value?: SelectValue[];
6
+ onChange?: (newValue: SelectValue[]) => void;
7
+ isDisabled?: boolean;
8
+ isRequired?: boolean;
9
+ cssStyle?: CheckBoxStyleForEachStatus;
10
+ };
11
+ export declare function CheckBoxes({ name, options, value, onChange, isDisabled, isRequired, cssStyle, }: Props): import("react").JSX.Element;
12
+ export {};
@@ -0,0 +1,68 @@
1
+ "use client";
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";
5
+ import { LabeledCheckbox as j } from "./LabeledCheckbox.js";
6
+ import { ErrorMessage as L } from "./ErrorMessage.js";
7
+ function F({
8
+ name: b,
9
+ options: a,
10
+ value: r,
11
+ onChange: s,
12
+ isDisabled: k,
13
+ isRequired: C,
14
+ cssStyle: o
15
+ }) {
16
+ const [u, d] = p(r ?? []), [f, h] = p(""), m = (e) => h(
17
+ C && e.length === 0 ? V.required : ""
18
+ ), n = w(!0);
19
+ R(() => {
20
+ if (n.current) {
21
+ n.current = !1, r != null && r.length && m(r);
22
+ return;
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)
29
+ );
30
+ d(l), m(l), s == null || s(l);
31
+ }, x = {
32
+ ...(o == null ? void 0 : o.error) ?? {},
33
+ textColor: i.white,
34
+ backgroundColor: i.red,
35
+ border: {
36
+ color: i.red,
37
+ size: "1px",
38
+ radius: ".25rem"
39
+ }
40
+ };
41
+ return /* @__PURE__ */ M("div", { className: "relative flex flex-wrap gap-x-6 gap-y-4", children: [
42
+ a.map((e) => /* @__PURE__ */ g(
43
+ j,
44
+ {
45
+ name: b,
46
+ label: e.label,
47
+ checked: u.includes(e.value),
48
+ onChange: (c) => E(e.value, c),
49
+ isDisabled: k,
50
+ cssStyle: o
51
+ },
52
+ e.value
53
+ )),
54
+ /* @__PURE__ */ g(
55
+ L,
56
+ {
57
+ errorMessages: f ? [f] : [],
58
+ cssStyle: {
59
+ textColor: x.textColor,
60
+ backgroundColor: x.backgroundColor
61
+ }
62
+ }
63
+ )
64
+ ] });
65
+ }
66
+ export {
67
+ F as CheckBoxes
68
+ };
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ import { CheckBoxStyleForEachStatus } from '../types';
3
+ type Props = {
4
+ name: string;
5
+ checked?: boolean;
6
+ onChange?: (newValue: boolean) => void;
7
+ isDisabled?: boolean;
8
+ cssStyle?: CheckBoxStyleForEachStatus;
9
+ isDisableAnimation?: boolean;
10
+ check?: ReactNode;
11
+ };
12
+ export declare function CheckButton({ name, checked, onChange, isDisabled, cssStyle, isDisableAnimation, check, }: Props): import("react").JSX.Element;
13
+ export {};
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ import { jsxs as l, Fragment as k, jsx as o } from "react/jsx-runtime";
3
+ import { CheckIcon as m } from "./icons/CheckIcon.js";
4
+ function _({
5
+ name: n,
6
+ checked: u,
7
+ onChange: r,
8
+ isDisabled: i,
9
+ cssStyle: s = { default: {} },
10
+ isDisableAnimation: b,
11
+ check: f
12
+ }) {
13
+ var a, d, c;
14
+ const t = u ?? !1, e = i ? s.disabled : s.default, h = {
15
+ "--border-color": ((a = e == null ? void 0 : e.border) == null ? void 0 : a.color) || "blue",
16
+ "--border-size": ((d = e == null ? void 0 : e.border) == null ? void 0 : d.size) || "1px",
17
+ "--radius-size": ((c = e == null ? void 0 : e.border) == null ? void 0 : c.radius) || "0.25rem",
18
+ "--background-color": (e == null ? void 0 : e.backgroundColor) || "#fff",
19
+ "--duration": b ? "0s" : ".3s"
20
+ };
21
+ return /* @__PURE__ */ l(k, { children: [
22
+ /* @__PURE__ */ o("style", { children: "@keyframes uiCheckPop{0%{scale:1}10%{scale:.8}50%{scale:1.1}100%{scale:1}}" }),
23
+ /* @__PURE__ */ l(
24
+ "label",
25
+ {
26
+ style: h,
27
+ className: `relative flex h-6 w-6 cursor-pointer items-center justify-center rounded-(--radius-size) shadow-[0_0_0_var(--border-size)_var(--border-color)_inset] 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-[''] has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-offset-2 has-[input:focus-visible]:outline-(--border-color) ${t ? "animate-[uiCheckPop_var(--duration)_ease-out] bg-(--border-color)" : "bg-(--background-color)"}`,
28
+ children: [
29
+ /* @__PURE__ */ o(
30
+ "input",
31
+ {
32
+ type: "checkbox",
33
+ name: n,
34
+ checked: t,
35
+ disabled: i,
36
+ onChange: (p) => {
37
+ i || r == null || r(p.target.checked);
38
+ },
39
+ className: "sr-only"
40
+ }
41
+ ),
42
+ /* @__PURE__ */ o(
43
+ "div",
44
+ {
45
+ className: `flex h-4 w-4 items-center justify-center [&>*]:fill-current [&>*]:text-current ${t ? "text-(--background-color)" : "text-(--border-color)"}`,
46
+ children: f ?? /* @__PURE__ */ o(m, {})
47
+ }
48
+ )
49
+ ]
50
+ }
51
+ )
52
+ ] });
53
+ }
54
+ export {
55
+ _ as CheckButton
56
+ };
@@ -0,0 +1,18 @@
1
+ import { FormValidationStore } from '@geckou/ui-core';
2
+ import { InputBoxStyleForEachStatus } from '../types';
3
+ type Props = {
4
+ name: string;
5
+ value?: string;
6
+ onChange?: (newValue: string) => void;
7
+ cssStyle?: InputBoxStyleForEachStatus;
8
+ isDisabled?: boolean;
9
+ isRequired?: boolean;
10
+ /** useFormValidation() が返す store。渡すとフォーム全体の検証状態に参加する */
11
+ formValidationStore?: FormValidationStore | null;
12
+ minDate?: string;
13
+ maxDate?: string;
14
+ size?: 'small' | 'medium';
15
+ type?: 'date' | 'month';
16
+ };
17
+ export declare function DatePicker({ name, value, onChange, cssStyle, isDisabled, isRequired, formValidationStore, minDate, maxDate, size, type, }: Props): import("react").JSX.Element;
18
+ export {};
@@ -0,0 +1,131 @@
1
+ "use client";
2
+ import { jsxs as V, jsx as t } from "react/jsx-runtime";
3
+ import { formatDateValue as b, splitDate as h, COLOR as A, MESSAGES as B, composeDateValue as G, validateDateObject as R } from "@geckou/ui-core";
4
+ import { useState as g, useRef as q, useEffect as C } from "react";
5
+ import { InputBox as F } from "./InputBox.js";
6
+ import { ErrorMessage as H } from "./ErrorMessage.js";
7
+ import { CalendarIcon as J } from "./icons/CalendarIcon.js";
8
+ import { useRegisterValidation as K } from "../hooks/useFormValidation.js";
9
+ function _({
10
+ name: l,
11
+ value: a,
12
+ onChange: s,
13
+ cssStyle: N,
14
+ isDisabled: i,
15
+ isRequired: o,
16
+ formValidationStore: O,
17
+ minDate: E = "",
18
+ maxDate: S = "",
19
+ size: M = "medium",
20
+ type: r = "date"
21
+ }) {
22
+ const [k, n] = g(
23
+ () => a ? b(a, r) : ""
24
+ ), [c, d] = g(
25
+ () => a ? h(b(a, r)) : { year: "", month: "", day: "" }
26
+ ), [p, $] = g(""), w = q(a);
27
+ C(() => {
28
+ if (w.current === a)
29
+ return;
30
+ w.current = a;
31
+ const e = a ? b(a, r) : "";
32
+ n(e), d(h(e));
33
+ }, [a, r]);
34
+ const y = (e) => !e && o ? { isValid: !1, message: B.required } : { isValid: !0, message: "" }, D = (e) => R(e, { type: r, isRequired: o }), I = (e) => {
35
+ n(e), d(h(e));
36
+ const { message: v } = y(e);
37
+ $(v), s == null || s(e);
38
+ }, u = (e, v) => {
39
+ const x = { ...c, [e]: v };
40
+ d(x);
41
+ const { isValid: z, message: P } = D(x);
42
+ if ($(P), z) {
43
+ const j = G(x, r);
44
+ n(j), s == null || s(j);
45
+ }
46
+ };
47
+ K(
48
+ O,
49
+ l,
50
+ y(k).isValid
51
+ );
52
+ const m = M === "small", f = `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)]!"}`, L = { "--icon-color": A.blue };
53
+ return /* @__PURE__ */ V(
54
+ F,
55
+ {
56
+ cssStyle: N,
57
+ isDisabled: i,
58
+ isErrored: !!p,
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
+ children: [
61
+ /* @__PURE__ */ V("div", { className: "relative flex-none", style: L, children: [
62
+ /* @__PURE__ */ t(
63
+ J,
64
+ {
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
+ }
67
+ ),
68
+ /* @__PURE__ */ t(
69
+ "input",
70
+ {
71
+ type: r,
72
+ name: l,
73
+ value: k,
74
+ max: S,
75
+ min: E,
76
+ required: o,
77
+ disabled: i,
78
+ onChange: (e) => I(e.target.value),
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
+ }
81
+ )
82
+ ] }),
83
+ /* @__PURE__ */ t(
84
+ "input",
85
+ {
86
+ value: c.year,
87
+ placeholder: "年",
88
+ "aria-label": `${l}の年`,
89
+ maxLength: 4,
90
+ type: "text",
91
+ disabled: i,
92
+ onChange: (e) => u("year", e.target.value),
93
+ className: `w-[calc(var(--sp-medium,0.75rem)*2+5ch)]! ${f}`
94
+ }
95
+ ),
96
+ "/",
97
+ /* @__PURE__ */ t(
98
+ "input",
99
+ {
100
+ value: c.month,
101
+ placeholder: "月",
102
+ "aria-label": `${l}の月`,
103
+ maxLength: 2,
104
+ type: "text",
105
+ disabled: i,
106
+ onChange: (e) => u("month", e.target.value),
107
+ className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${f}`
108
+ }
109
+ ),
110
+ r === "date" && /* @__PURE__ */ t("span", { children: "/" }),
111
+ r === "date" && /* @__PURE__ */ t(
112
+ "input",
113
+ {
114
+ value: c.day,
115
+ placeholder: "日",
116
+ "aria-label": `${l}の日`,
117
+ maxLength: 2,
118
+ type: "text",
119
+ disabled: i,
120
+ onChange: (e) => u("day", e.target.value),
121
+ className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${f}`
122
+ }
123
+ ),
124
+ /* @__PURE__ */ t(H, { errorMessages: p ? [p] : void 0 })
125
+ ]
126
+ }
127
+ );
128
+ }
129
+ export {
130
+ _ as DatePicker
131
+ };
@@ -0,0 +1,22 @@
1
+ import { FormValidationStore } from '@geckou/ui-core';
2
+ export type DateRange = {
3
+ start: string;
4
+ end: string;
5
+ };
6
+ type Props = {
7
+ /** 各入力の name は `<name>Start` / `<name>End` になる */
8
+ name: string;
9
+ /** 制御コンポーネントとして使う。省略時は空の範囲から始まる */
10
+ value?: DateRange;
11
+ onChange?: (newValue: DateRange) => void;
12
+ isDisabled?: boolean;
13
+ isRequired?: boolean;
14
+ /** useFormValidation() が返す store。渡すとフォーム全体の検証状態に参加する */
15
+ formValidationStore?: FormValidationStore | null;
16
+ minDate?: string;
17
+ maxDate?: string;
18
+ size?: 'small' | 'medium';
19
+ type?: 'date' | 'month';
20
+ };
21
+ export declare function DateRangePicker({ name, value, onChange, isDisabled, isRequired, formValidationStore, minDate, maxDate, size, type, }: Props): import("react").JSX.Element;
22
+ export {};
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { jsxs as g, jsx as d } from "react/jsx-runtime";
3
+ import { DatePicker as b } from "./DatePicker.js";
4
+ import { COLOR as f } from "@geckou/ui-core";
5
+ const h = { start: "", end: "" };
6
+ function N({
7
+ name: c,
8
+ value: r = h,
9
+ onChange: t,
10
+ isDisabled: n,
11
+ isRequired: a,
12
+ formValidationStore: o,
13
+ minDate: s = "",
14
+ maxDate: l = "",
15
+ size: m = "medium",
16
+ type: i = "date"
17
+ }) {
18
+ const x = (e) => t == null ? void 0 : t({ start: e, end: r.end }), u = (e) => t == null ? void 0 : t({ start: r.start, end: e }), v = {
19
+ "--range-background-color": f.white,
20
+ "--range-border-color": f.gray
21
+ };
22
+ return /* @__PURE__ */ g(
23
+ "div",
24
+ {
25
+ style: v,
26
+ 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)",
27
+ children: [
28
+ /* @__PURE__ */ d(
29
+ b,
30
+ {
31
+ name: `${c}Start`,
32
+ value: r.start,
33
+ isDisabled: n,
34
+ isRequired: a,
35
+ formValidationStore: o,
36
+ minDate: s,
37
+ maxDate: r.end || l,
38
+ size: m,
39
+ type: i,
40
+ onChange: x
41
+ }
42
+ ),
43
+ /* @__PURE__ */ d("div", { className: "flex flex-none! items-center px-[var(--bv,0.375rem)]", children: "〜" }),
44
+ /* @__PURE__ */ d(
45
+ b,
46
+ {
47
+ name: `${c}End`,
48
+ value: r.end,
49
+ isDisabled: n,
50
+ isRequired: a,
51
+ formValidationStore: o,
52
+ minDate: r.start || s,
53
+ maxDate: l,
54
+ size: m,
55
+ type: i,
56
+ onChange: u
57
+ }
58
+ )
59
+ ]
60
+ }
61
+ );
62
+ }
63
+ export {
64
+ N as DateRangePicker
65
+ };
@@ -0,0 +1,13 @@
1
+ import { FormValidationStore } from '@geckou/ui-core';
2
+ type Props = {
3
+ name: string;
4
+ value?: string;
5
+ onChange?: (newValue: string) => void;
6
+ isRequired?: boolean;
7
+ /** useFormValidation() が返す store。渡すとフォーム全体の検証状態に参加する */
8
+ formValidationStore?: FormValidationStore | null;
9
+ /** 'month' なら日の選択を出さない(Vue 版と揃える) */
10
+ type?: 'date' | 'month';
11
+ };
12
+ export declare function DateSelector({ name, value, onChange, isRequired, formValidationStore, type, }: Props): import("react").JSX.Element;
13
+ export {};