@geckou/ui-react 0.5.1 → 0.6.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 +15 -0
- package/dist/components/DatePicker.js +80 -71
- package/dist/components/ModalBox.js +35 -30
- package/dist/components/PopupBox.js +4 -3
- package/dist/components/SearchableSelectBox.js +14 -14
- package/dist/index.d.ts +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -108,6 +108,21 @@ props は Vue 版(`@geckou/ui-vue`)と揃えている。`v-model` にあた
|
|
|
108
108
|
yarn workspace @geckou/ui-react test
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
+
## 0.6.0 の変更
|
|
112
|
+
|
|
113
|
+
- `ModalBox` を重ねたとき、Escape で閉じるのは**最前面の 1 枚だけ**になった
|
|
114
|
+
(従来は内側と外側の `onClose` が両方呼ばれていた)。あわせて自分が Escape を
|
|
115
|
+
処理したら `preventDefault()` する。外側で Escape を見ているアプリ側のハンドラが
|
|
116
|
+
一緒に反応しなくなるので、`defaultPrevented` を見ずに閉じている処理があれば追従が要る
|
|
117
|
+
- `SearchableSelectBox` が候補 0 件のときは Escape を握らない(`preventDefault()` しない)。
|
|
118
|
+
`ModalBox` の中で「何にもマッチしない語を入れた状態だと Escape を 2 回押す必要がある」
|
|
119
|
+
のが直る
|
|
120
|
+
- `DatePicker` のカレンダー起動用入力にアクセシブル名(「◯◯のカレンダー」)が付き、
|
|
121
|
+
キーボードで到達したときアイコン側に可視フォーカスが出る
|
|
122
|
+
- `PopupBox` が `role="status"`(ライブリージョン)になり、支援技術に通知が伝わる
|
|
123
|
+
- `DateRange` 型を公開の入口から export するようにした
|
|
124
|
+
(`import type { DateRange } from '@geckou/ui-react'`)
|
|
125
|
+
|
|
111
126
|
## 0.5.0 の変更
|
|
112
127
|
|
|
113
128
|
- `DatePicker` / `DateSelector` が `ariaLabel` / `ariaLabelledBy` を受ける
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as j, jsx as
|
|
2
|
+
import { jsxs as j, jsx as a } from "react/jsx-runtime";
|
|
3
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
4
|
import { useState as m, useRef as T, useEffect as U, useId as W } from "react";
|
|
5
5
|
import { InputBox as X } from "./InputBox.js";
|
|
@@ -7,128 +7,137 @@ import { ErrorMessage as Y } from "./ErrorMessage.js";
|
|
|
7
7
|
import { CalendarIcon as Z } from "./icons/CalendarIcon.js";
|
|
8
8
|
import { useRegisterValidation as _ } from "../hooks/useFormValidation.js";
|
|
9
9
|
function le({
|
|
10
|
-
name:
|
|
11
|
-
value:
|
|
10
|
+
name: d,
|
|
11
|
+
value: r,
|
|
12
12
|
onChange: s,
|
|
13
13
|
cssStyle: M,
|
|
14
14
|
isDisabled: i,
|
|
15
|
-
isRequired:
|
|
15
|
+
isRequired: p,
|
|
16
16
|
formValidationStore: D,
|
|
17
17
|
minDate: L = "",
|
|
18
18
|
maxDate: z = "",
|
|
19
19
|
size: P = "medium",
|
|
20
20
|
type: t = "date",
|
|
21
21
|
ariaLabel: A,
|
|
22
|
-
ariaLabelledBy:
|
|
22
|
+
ariaLabelledBy: u
|
|
23
23
|
}) {
|
|
24
|
-
const [y,
|
|
25
|
-
() =>
|
|
26
|
-
), [
|
|
27
|
-
() =>
|
|
28
|
-
), [
|
|
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
29
|
U(() => {
|
|
30
|
-
if (N.current ===
|
|
30
|
+
if (N.current === r)
|
|
31
31
|
return;
|
|
32
|
-
N.current =
|
|
33
|
-
const e =
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
const I = (e) => !e &&
|
|
37
|
-
|
|
38
|
-
const { message:
|
|
39
|
-
O(
|
|
40
|
-
},
|
|
41
|
-
const k = { ...
|
|
42
|
-
|
|
32
|
+
N.current = r;
|
|
33
|
+
const e = r ? V(r, t) : "";
|
|
34
|
+
f(e), v(w(e)), b(!0);
|
|
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
43
|
const { isValid: E, message: F } = R(k);
|
|
44
|
-
if (O(F),
|
|
44
|
+
if (O(F), b(E), E) {
|
|
45
45
|
const S = K(k, t);
|
|
46
|
-
|
|
46
|
+
f(S), s == null || s(S);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
_(
|
|
50
50
|
D,
|
|
51
|
-
|
|
51
|
+
d,
|
|
52
52
|
I(y).isValid && G
|
|
53
53
|
);
|
|
54
|
-
const
|
|
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
55
|
return /* @__PURE__ */ j(
|
|
56
56
|
X,
|
|
57
57
|
{
|
|
58
58
|
cssStyle: M,
|
|
59
59
|
isDisabled: i,
|
|
60
|
-
isErrored: !!
|
|
61
|
-
className: `flex w-full items-center leading-none ${
|
|
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)]"}`,
|
|
62
62
|
children: [
|
|
63
|
-
/* @__PURE__ */ j(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
63
|
+
/* @__PURE__ */ j(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
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
|
+
style: C,
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ a(
|
|
70
|
+
Z,
|
|
71
|
+
{
|
|
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)]"}`
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ a(
|
|
76
|
+
"input",
|
|
77
|
+
{
|
|
78
|
+
type: t,
|
|
79
|
+
name: d,
|
|
80
|
+
value: y,
|
|
81
|
+
...n("カレンダー"),
|
|
82
|
+
max: z,
|
|
83
|
+
min: L,
|
|
84
|
+
required: p,
|
|
85
|
+
disabled: i,
|
|
86
|
+
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)]!"}`
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ a(
|
|
86
94
|
"input",
|
|
87
95
|
{
|
|
88
|
-
value:
|
|
96
|
+
value: c.year,
|
|
89
97
|
placeholder: "年",
|
|
90
|
-
...
|
|
98
|
+
...n("年"),
|
|
91
99
|
maxLength: 4,
|
|
92
100
|
type: "text",
|
|
93
101
|
disabled: i,
|
|
94
|
-
onChange: (e) =>
|
|
95
|
-
className: `w-[calc(var(--sp-medium,0.75rem)*2+5ch)]! ${
|
|
102
|
+
onChange: (e) => x("year", e.target.value),
|
|
103
|
+
className: `w-[calc(var(--sp-medium,0.75rem)*2+5ch)]! ${$}`
|
|
96
104
|
}
|
|
97
105
|
),
|
|
98
106
|
"/",
|
|
99
|
-
/* @__PURE__ */
|
|
107
|
+
/* @__PURE__ */ a(
|
|
100
108
|
"input",
|
|
101
109
|
{
|
|
102
|
-
value:
|
|
110
|
+
value: c.month,
|
|
103
111
|
placeholder: "月",
|
|
104
|
-
...
|
|
112
|
+
...n("月"),
|
|
105
113
|
maxLength: 2,
|
|
106
114
|
type: "text",
|
|
107
115
|
disabled: i,
|
|
108
|
-
onChange: (e) =>
|
|
109
|
-
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${
|
|
116
|
+
onChange: (e) => x("month", e.target.value),
|
|
117
|
+
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${$}`
|
|
110
118
|
}
|
|
111
119
|
),
|
|
112
|
-
t === "date" && /* @__PURE__ */
|
|
113
|
-
t === "date" && /* @__PURE__ */
|
|
120
|
+
t === "date" && /* @__PURE__ */ a("span", { children: "/" }),
|
|
121
|
+
t === "date" && /* @__PURE__ */ a(
|
|
114
122
|
"input",
|
|
115
123
|
{
|
|
116
|
-
value:
|
|
124
|
+
value: c.day,
|
|
117
125
|
placeholder: "日",
|
|
118
|
-
...
|
|
126
|
+
...n("日"),
|
|
119
127
|
maxLength: 2,
|
|
120
128
|
type: "text",
|
|
121
129
|
disabled: i,
|
|
122
|
-
onChange: (e) =>
|
|
123
|
-
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${
|
|
130
|
+
onChange: (e) => x("day", e.target.value),
|
|
131
|
+
className: `w-[calc(var(--sp-medium,0.75rem)*2+3ch)]! ${$}`
|
|
124
132
|
}
|
|
125
133
|
),
|
|
126
|
-
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
/* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */
|
|
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: "の日" })
|
|
130
139
|
] }),
|
|
131
|
-
/* @__PURE__ */
|
|
140
|
+
/* @__PURE__ */ a(Y, { errorMessages: h ? [h] : void 0 })
|
|
132
141
|
]
|
|
133
142
|
}
|
|
134
143
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as t, jsxs as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { createScrollLock as
|
|
5
|
-
const
|
|
2
|
+
import { jsx as t, jsxs as b } from "react/jsx-runtime";
|
|
3
|
+
import { useId as g, useRef as i, useEffect as u } from "react";
|
|
4
|
+
import { createScrollLock as y, createModalLayer as w, handleTabKey as h } from "@geckou/ui-core";
|
|
5
|
+
const k = {
|
|
6
6
|
small: "max-w-[var(--mobile-lower-width,430px)]",
|
|
7
7
|
medium: "max-w-[var(--desktop-lower-width,1025px)]",
|
|
8
8
|
large: "max-w-[var(--contents-max-width,1440px)]"
|
|
9
9
|
};
|
|
10
|
-
function
|
|
10
|
+
function E() {
|
|
11
11
|
return /* @__PURE__ */ t(
|
|
12
12
|
"svg",
|
|
13
13
|
{
|
|
@@ -18,38 +18,43 @@ function y() {
|
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function _({
|
|
22
22
|
isShown: r,
|
|
23
|
-
size:
|
|
23
|
+
size: p = "medium",
|
|
24
24
|
onClose: o,
|
|
25
|
-
header:
|
|
26
|
-
footer:
|
|
27
|
-
children:
|
|
28
|
-
ariaLabel:
|
|
25
|
+
header: n,
|
|
26
|
+
footer: d,
|
|
27
|
+
children: f,
|
|
28
|
+
ariaLabel: v
|
|
29
29
|
}) {
|
|
30
|
-
const c =
|
|
31
|
-
|
|
32
|
-
const e =
|
|
30
|
+
const c = g(), m = i(null), x = i(y());
|
|
31
|
+
u(() => {
|
|
32
|
+
const e = x.current;
|
|
33
33
|
return e.toggle(r), () => e.release();
|
|
34
34
|
}, [r]);
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const s = i(w());
|
|
36
|
+
u(() => {
|
|
37
|
+
const e = s.current;
|
|
38
|
+
return e.toggle(r, m.current), () => e.release();
|
|
39
|
+
}, [r]);
|
|
40
|
+
const l = i(null);
|
|
41
|
+
return u(() => {
|
|
37
42
|
var e, a;
|
|
38
43
|
if (r) {
|
|
39
44
|
l.current ?? (l.current = document.activeElement), (e = m.current) == null || e.focus();
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
42
47
|
(a = l.current) == null || a.focus(), l.current = null;
|
|
43
|
-
}, [r]),
|
|
48
|
+
}, [r]), u(() => {
|
|
44
49
|
if (!r)
|
|
45
50
|
return;
|
|
46
51
|
const e = (a) => {
|
|
47
|
-
if (!a.defaultPrevented) {
|
|
52
|
+
if (s.current.isTopmost() && !a.defaultPrevented) {
|
|
48
53
|
if (a.key === "Escape") {
|
|
49
|
-
o();
|
|
54
|
+
a.preventDefault(), o();
|
|
50
55
|
return;
|
|
51
56
|
}
|
|
52
|
-
|
|
57
|
+
h(m.current, a, document.activeElement);
|
|
53
58
|
}
|
|
54
59
|
};
|
|
55
60
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
@@ -62,27 +67,27 @@ function I({
|
|
|
62
67
|
onClick: (e) => {
|
|
63
68
|
e.target === e.currentTarget && o();
|
|
64
69
|
},
|
|
65
|
-
children: /* @__PURE__ */
|
|
70
|
+
children: /* @__PURE__ */ b(
|
|
66
71
|
"div",
|
|
67
72
|
{
|
|
68
73
|
ref: m,
|
|
69
74
|
role: "dialog",
|
|
70
75
|
"aria-modal": "true",
|
|
71
|
-
"aria-labelledby":
|
|
72
|
-
"aria-label":
|
|
76
|
+
"aria-labelledby": n ? c : void 0,
|
|
77
|
+
"aria-label": n ? void 0 : v ?? "ダイアログ",
|
|
73
78
|
tabIndex: -1,
|
|
74
|
-
className: `relative flex max-h-full w-full cursor-auto flex-col rounded-[var(--radius-small,0.1875rem)] bg-white drop-shadow-[0_0_6px_#33333355] ${
|
|
79
|
+
className: `relative flex max-h-full w-full cursor-auto flex-col rounded-[var(--radius-small,0.1875rem)] bg-white drop-shadow-[0_0_6px_#33333355] ${k[p]}`,
|
|
75
80
|
children: [
|
|
76
|
-
|
|
81
|
+
n && /* @__PURE__ */ t(
|
|
77
82
|
"header",
|
|
78
83
|
{
|
|
79
84
|
id: c,
|
|
80
85
|
className: "border-b border-[#eee] px-[var(--sp-large,1.5rem)] py-[var(--sp-medium,0.75rem)] max-md:p-[var(--sp-medium,0.75rem)] [&>h2]:font-bold [&>h2]:text-[var(--fs-large,0.875rem)]",
|
|
81
|
-
children:
|
|
86
|
+
children: n
|
|
82
87
|
}
|
|
83
88
|
),
|
|
84
|
-
/* @__PURE__ */ t("div", { className: "flex-auto overflow-auto p-[var(--sp-large,1.5rem)] max-md:p-[var(--sp-medium,0.75rem)]", children:
|
|
85
|
-
|
|
89
|
+
/* @__PURE__ */ t("div", { className: "flex-auto overflow-auto p-[var(--sp-large,1.5rem)] max-md:p-[var(--sp-medium,0.75rem)]", children: f }),
|
|
90
|
+
d && /* @__PURE__ */ t("footer", { className: "flex justify-center gap-[var(--sp-large,1.5rem)] border-t border-[#eee] px-[var(--sp-large,1.5rem)] py-[var(--sp-medium,0.75rem)] max-md:gap-[var(--sp-medium,0.75rem)] max-md:p-[var(--sp-medium,0.75rem)] max-md:[&>*]:flex-auto", children: d }),
|
|
86
91
|
/* @__PURE__ */ t(
|
|
87
92
|
"button",
|
|
88
93
|
{
|
|
@@ -90,7 +95,7 @@ function I({
|
|
|
90
95
|
"aria-label": "閉じる",
|
|
91
96
|
className: "absolute bottom-full left-full size-[var(--icon-medium,1.125rem)] cursor-pointer leading-none text-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white [&>*]:size-full",
|
|
92
97
|
onClick: o,
|
|
93
|
-
children: /* @__PURE__ */ t(
|
|
98
|
+
children: /* @__PURE__ */ t(E, {})
|
|
94
99
|
}
|
|
95
100
|
)
|
|
96
101
|
]
|
|
@@ -100,5 +105,5 @@ function I({
|
|
|
100
105
|
);
|
|
101
106
|
}
|
|
102
107
|
export {
|
|
103
|
-
|
|
108
|
+
_ as ModalBox
|
|
104
109
|
};
|
|
@@ -17,19 +17,20 @@ function y({
|
|
|
17
17
|
ref: n,
|
|
18
18
|
children: m
|
|
19
19
|
}) {
|
|
20
|
-
const [
|
|
20
|
+
const [s, r] = o(!1), [u, a] = o(!1), e = c(null);
|
|
21
21
|
return l(() => (a(!0), () => {
|
|
22
22
|
e.current && clearTimeout(e.current);
|
|
23
23
|
}), []), f(n, () => ({
|
|
24
24
|
showPopup: () => {
|
|
25
25
|
r(!0), e.current && clearTimeout(e.current), e.current = setTimeout(() => r(!1), 3e3);
|
|
26
26
|
}
|
|
27
|
-
})),
|
|
27
|
+
})), u ? p(
|
|
28
28
|
/* @__PURE__ */ i(
|
|
29
29
|
"div",
|
|
30
30
|
{
|
|
31
|
+
role: "status",
|
|
31
32
|
style: { borderColor: d.blue },
|
|
32
|
-
className: `pointer-events-none fixed z-50 h-max w-max max-w-40 rounded-[var(--radius-small,0.1875rem)] border bg-white p-[var(--sp-medium,0.75rem)] transition-[transform,opacity] duration-300 ${x[t.x]} ${S[t.y]} ${
|
|
33
|
+
className: `pointer-events-none fixed z-50 h-max w-max max-w-40 rounded-[var(--radius-small,0.1875rem)] border bg-white p-[var(--sp-medium,0.75rem)] transition-[transform,opacity] duration-300 ${x[t.x]} ${S[t.y]} ${s ? "opacity-100" : "opacity-0"}`,
|
|
33
34
|
children: m
|
|
34
35
|
}
|
|
35
36
|
),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as N, jsx as
|
|
3
|
-
import { useState as
|
|
2
|
+
import { jsxs as N, jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import { useState as w, useRef as k, useId as _, useEffect as y } from "react";
|
|
4
4
|
import { TextBox as $ } from "./TextBox.js";
|
|
5
5
|
function R({
|
|
6
|
-
options:
|
|
6
|
+
options: v,
|
|
7
7
|
value: o,
|
|
8
8
|
onChange: s,
|
|
9
9
|
onSelect: d,
|
|
@@ -14,7 +14,7 @@ function R({
|
|
|
14
14
|
cssStyle: L,
|
|
15
15
|
ariaLabel: O
|
|
16
16
|
}) {
|
|
17
|
-
const [u, f] =
|
|
17
|
+
const [u, f] = w(o), [h, a] = w(!1), [i, n] = w(-1), x = k(null), p = _(), b = (e) => `${p}-option-${e}`, E = k(o);
|
|
18
18
|
y(() => {
|
|
19
19
|
E.current !== o && (E.current = o, f(o));
|
|
20
20
|
}, [o]), y(() => {
|
|
@@ -24,17 +24,17 @@ function R({
|
|
|
24
24
|
};
|
|
25
25
|
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
26
26
|
}, []);
|
|
27
|
-
const l = u ?
|
|
27
|
+
const l = u ? v.filter(
|
|
28
28
|
(e) => String(e[B]).toLowerCase().includes(u.toLowerCase())
|
|
29
|
-
) :
|
|
29
|
+
) : v, F = (e) => {
|
|
30
30
|
const r = String(e);
|
|
31
31
|
f(r), a(!!r), n(-1), s == null || s(r);
|
|
32
32
|
}, D = (e) => {
|
|
33
33
|
const r = e.value.toString();
|
|
34
34
|
f(r), a(!1), n(-1), s == null || s(r), d == null || d(r);
|
|
35
|
-
}, c =
|
|
35
|
+
}, c = h && l.length > 0, S = (e) => {
|
|
36
36
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
37
|
-
if (e.preventDefault(), !
|
|
37
|
+
if (e.preventDefault(), !h) {
|
|
38
38
|
a(!0), n(
|
|
39
39
|
e.key === "ArrowDown" ? 0 : l.length - 1
|
|
40
40
|
);
|
|
@@ -53,10 +53,10 @@ function R({
|
|
|
53
53
|
r && (e.preventDefault(), D(r));
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
e.key === "Escape" &&
|
|
56
|
+
e.key === "Escape" && c && (e.preventDefault(), a(!1), n(-1));
|
|
57
57
|
};
|
|
58
58
|
return /* @__PURE__ */ N("div", { ref: x, className: "relative", children: [
|
|
59
|
-
/* @__PURE__ */
|
|
59
|
+
/* @__PURE__ */ m(
|
|
60
60
|
$,
|
|
61
61
|
{
|
|
62
62
|
name: A,
|
|
@@ -69,18 +69,18 @@ function R({
|
|
|
69
69
|
ariaLabel: O,
|
|
70
70
|
ariaAutocomplete: "list",
|
|
71
71
|
ariaExpanded: c,
|
|
72
|
-
ariaControls:
|
|
72
|
+
ariaControls: p,
|
|
73
73
|
ariaActivedescendant: c && i >= 0 ? b(i) : void 0,
|
|
74
74
|
onKeyDown: S
|
|
75
75
|
}
|
|
76
76
|
),
|
|
77
|
-
c && /* @__PURE__ */
|
|
77
|
+
c && /* @__PURE__ */ m(
|
|
78
78
|
"div",
|
|
79
79
|
{
|
|
80
|
-
id:
|
|
80
|
+
id: p,
|
|
81
81
|
role: "listbox",
|
|
82
82
|
className: "absolute top-[calc(100%-var(--sp-min,0.1875rem))] left-0 z-[2] max-h-[calc(var(--bv,0.375rem)*56)] min-w-full overflow-auto rounded-[var(--radius-small,0.1875rem)] bg-white py-[var(--sp-small,0.375rem)] shadow-[0_0_6px_#33333333]",
|
|
83
|
-
children: l.map((e, r) => /* @__PURE__ */
|
|
83
|
+
children: l.map((e, r) => /* @__PURE__ */ m(
|
|
84
84
|
"div",
|
|
85
85
|
{
|
|
86
86
|
id: b(r),
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { CheckBoxes } from './components/CheckBoxes';
|
|
|
4
4
|
export { CheckButton } from './components/CheckButton';
|
|
5
5
|
export { DatePicker } from './components/DatePicker';
|
|
6
6
|
export { DateRangePicker } from './components/DateRangePicker';
|
|
7
|
+
export type { DateRange } from './components/DateRangePicker';
|
|
7
8
|
export { DateSelector } from './components/DateSelector';
|
|
8
9
|
export { DropdownUi } from './components/DropdownUi';
|
|
9
10
|
export type { DropdownUiHandle } from './components/DropdownUi';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geckou/ui-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A set of reusable React UI components (forms) by Geckou",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"react-dom": "^19.0.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@geckou/ui-core": "^0.
|
|
43
|
+
"@geckou/ui-core": "^0.6.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "vite build && node scripts/copy-assets.mjs",
|