@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.
@@ -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 {};
@@ -1,35 +1,37 @@
1
1
  "use client";
2
- import { jsxs as b, jsx as t } from "react/jsx-runtime";
3
- import { useId as h } from "react";
4
- import { CheckBox as p } from "./CheckBox.js";
2
+ import { jsxs as h, jsx as t } from "react/jsx-runtime";
3
+ import { useId as p } from "react";
4
+ import { CheckBox as C } from "./CheckBox.js";
5
5
  import { COLOR as r } from "@geckou/ui-core";
6
- function L({
6
+ function N({
7
7
  name: l,
8
8
  label: d,
9
- checked: i,
10
- onChange: m,
9
+ value: i,
10
+ checked: m,
11
+ onChange: u,
11
12
  isDisabled: e,
12
13
  cssStyle: o,
13
- isDisableAnimation: u
14
+ isDisableAnimation: x
14
15
  }) {
15
- const a = i ?? !1, n = h(), x = e ? o == null ? void 0 : o.disabled : o == null ? void 0 : o.default, c = {
16
+ const a = m ?? !1, n = p(), k = e ? o == null ? void 0 : o.disabled : o == null ? void 0 : o.default, c = {
16
17
  textColor: e ? r.darkGray : r.black,
17
18
  backgroundColor: e ? r.darkGray : r.blue,
18
- ...x ?? {}
19
- }, k = {
19
+ ...k ?? {}
20
+ }, b = {
20
21
  "--text-color": c.textColor,
21
22
  "--checked-color": c.backgroundColor
22
23
  };
23
- return /* @__PURE__ */ b("label", { className: "inline-flex cursor-pointer items-center gap-[.5em] has-[button:disabled]:cursor-auto", children: [
24
+ return /* @__PURE__ */ h("label", { className: "inline-flex cursor-pointer items-center gap-[.5em] has-[button:disabled]:cursor-auto", children: [
24
25
  /* @__PURE__ */ t("span", { className: "pointer-events-none", children: /* @__PURE__ */ t(
25
- p,
26
+ C,
26
27
  {
27
28
  name: l,
29
+ value: i,
28
30
  checked: a,
29
- onChange: m,
31
+ onChange: u,
30
32
  isDisabled: e,
31
33
  cssStyle: o,
32
- isDisableAnimation: u,
34
+ isDisableAnimation: x,
33
35
  ariaLabelledBy: n
34
36
  }
35
37
  ) }),
@@ -37,7 +39,7 @@ function L({
37
39
  "span",
38
40
  {
39
41
  id: n,
40
- style: k,
42
+ style: b,
41
43
  className: a ? "text-(--text-color)" : "text-(--checked-color)",
42
44
  children: d
43
45
  }
@@ -45,5 +47,5 @@ function L({
45
47
  ] });
46
48
  }
47
49
  export {
48
- L as LabeledCheckbox
50
+ N as LabeledCheckbox
49
51
  };
@@ -1,13 +1,13 @@
1
1
  "use client";
2
- import { jsx as t, jsxs as x } from "react/jsx-runtime";
3
- import { useId as b, useRef as n, useEffect as d } from "react";
4
- import { createScrollLock as g, handleTabKey as w } from "@geckou/ui-core";
5
- const h = {
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 y() {
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 I({
21
+ function _({
22
22
  isShown: r,
23
- size: s = "medium",
23
+ size: p = "medium",
24
24
  onClose: o,
25
- header: i,
26
- footer: u,
27
- children: p,
28
- ariaLabel: f
25
+ header: n,
26
+ footer: d,
27
+ children: f,
28
+ ariaLabel: v
29
29
  }) {
30
- const c = b(), m = n(null), v = n(g());
31
- d(() => {
32
- const e = v.current;
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 l = n(null);
36
- return d(() => {
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]), d(() => {
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
- w(m.current, a, document.activeElement);
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__ */ x(
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": i ? c : void 0,
72
- "aria-label": i ? void 0 : f ?? "ダイアログ",
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] ${h[s]}`,
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
- i && /* @__PURE__ */ t(
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: i
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: p }),
85
- u && /* @__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: u }),
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(y, {})
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
- I as ModalBox
108
+ _ as ModalBox
104
109
  };
@@ -17,19 +17,20 @@ function y({
17
17
  ref: n,
18
18
  children: m
19
19
  }) {
20
- const [u, r] = o(!1), [s, a] = o(!1), e = c(null);
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
- })), s ? p(
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]} ${u ? "opacity-100" : "opacity-0"}`,
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
  ),
@@ -11,6 +11,7 @@ type Props = {
11
11
  cssStyle?: InputBoxStyleForEachStatus;
12
12
  /** combobox のアクセシブル名。可視ラベルがあるならそちらを ariaLabelledBy で指すこと */
13
13
  ariaLabel?: string;
14
+ ariaLabelledBy?: string;
14
15
  };
15
- export declare function SearchableSelectBox({ options, value, onChange, onSelect, name, placeholder, isDisabled, searchTarget, cssStyle, ariaLabel, }: Props): import("react").JSX.Element;
16
+ export declare function SearchableSelectBox({ options, value, onChange, onSelect, name, placeholder, isDisabled, searchTarget, cssStyle, ariaLabel, ariaLabelledBy, }: Props): import("react").JSX.Element;
16
17
  export {};
@@ -1,96 +1,103 @@
1
1
  "use client";
2
- import { jsxs as N, jsx as w } from "react/jsx-runtime";
3
- import { useState as v, useRef as k, useId as _, useEffect as y } from "react";
4
- import { TextBox as $ } from "./TextBox.js";
5
- function R({
6
- options: h,
2
+ import { jsxs as $, jsx as m } from "react/jsx-runtime";
3
+ import { useState as v, useRef as A, useId as j, useEffect as I } from "react";
4
+ import { TextBox as K } from "./TextBox.js";
5
+ function z({
6
+ options: w,
7
7
  value: o,
8
8
  onChange: s,
9
9
  onSelect: d,
10
- name: A,
11
- placeholder: I = "入力してください",
12
- isDisabled: g,
13
- searchTarget: B = "label",
14
- cssStyle: L,
15
- ariaLabel: O
10
+ name: g,
11
+ placeholder: O = "入力してください",
12
+ isDisabled: B,
13
+ searchTarget: L = "label",
14
+ cssStyle: S,
15
+ ariaLabel: F,
16
+ ariaLabelledBy: N
16
17
  }) {
17
- const [u, f] = v(o), [p, a] = v(!1), [i, n] = v(-1), x = k(null), m = _(), b = (e) => `${m}-option-${e}`, E = k(o);
18
- y(() => {
19
- E.current !== o && (E.current = o, f(o));
20
- }, [o]), y(() => {
18
+ const b = (e) => {
19
+ var r;
20
+ return ((r = w.find((t) => String(t.value) === e)) == null ? void 0 : r.label) ?? e;
21
+ }, [u, f] = v(() => b(o)), [h, a] = v(!1), [i, l] = v(-1), x = A(null), p = j(), D = (e) => `${p}-option-${e}`, E = A(o);
22
+ I(() => {
23
+ E.current !== o && (E.current = o, f(b(o)));
24
+ }, [o]), I(() => {
21
25
  const e = (r) => {
22
26
  const t = x.current;
23
27
  t && !t.contains(r.target) && a(!1);
24
28
  };
25
29
  return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
26
30
  }, []);
27
- const l = u ? h.filter(
28
- (e) => String(e[B]).toLowerCase().includes(u.toLowerCase())
29
- ) : h, F = (e) => {
31
+ const y = w.filter((e) => !e.isDisabled), n = u ? y.filter(
32
+ (e) => String(e[L]).toLowerCase().includes(u.toLowerCase())
33
+ ) : y, V = (e) => {
30
34
  const r = String(e);
31
- f(r), a(!!r), n(-1), s == null || s(r);
32
- }, D = (e) => {
35
+ f(r), a(!!r), l(-1), s == null || s(r);
36
+ }, k = (e) => {
37
+ if (e.isDisabled)
38
+ return;
33
39
  const r = e.value.toString();
34
- f(r), a(!1), n(-1), s == null || s(r), d == null || d(r);
35
- }, c = p && l.length > 0, S = (e) => {
40
+ f(e.label), a(!1), l(-1), s == null || s(r), d == null || d(r);
41
+ }, c = h && n.length > 0, _ = (e) => {
36
42
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
37
- if (e.preventDefault(), !p) {
38
- a(!0), n(
39
- e.key === "ArrowDown" ? 0 : l.length - 1
43
+ if (e.preventDefault(), !h) {
44
+ a(!0), l(
45
+ e.key === "ArrowDown" ? 0 : n.length - 1
40
46
  );
41
47
  return;
42
48
  }
43
- if (l.length === 0)
49
+ if (n.length === 0)
44
50
  return;
45
- n((r) => {
46
- const t = l.length - 1;
51
+ l((r) => {
52
+ const t = n.length - 1;
47
53
  return e.key === "ArrowDown" ? r >= t ? 0 : r + 1 : r <= 0 ? t : r - 1;
48
54
  });
49
55
  return;
50
56
  }
51
57
  if (e.key === "Enter") {
52
- const r = c ? l[i] : void 0;
53
- r && (e.preventDefault(), D(r));
58
+ const r = c ? n[i] : void 0;
59
+ r && (e.preventDefault(), k(r));
54
60
  return;
55
61
  }
56
- e.key === "Escape" && p && (e.preventDefault(), a(!1), n(-1));
62
+ e.key === "Escape" && c && (e.preventDefault(), a(!1), l(-1));
57
63
  };
58
- return /* @__PURE__ */ N("div", { ref: x, className: "relative", children: [
59
- /* @__PURE__ */ w(
60
- $,
64
+ return /* @__PURE__ */ $("div", { ref: x, className: "relative", children: [
65
+ /* @__PURE__ */ m(
66
+ K,
61
67
  {
62
- name: A,
68
+ name: g,
63
69
  value: u,
64
- onChange: F,
65
- isDisabled: g,
66
- placeholder: I,
67
- cssStyle: L,
70
+ onChange: V,
71
+ isDisabled: B,
72
+ placeholder: O,
73
+ cssStyle: S,
68
74
  role: "combobox",
69
- ariaLabel: O,
75
+ ariaLabel: F,
76
+ ariaLabelledBy: N,
70
77
  ariaAutocomplete: "list",
71
78
  ariaExpanded: c,
72
- ariaControls: m,
73
- ariaActivedescendant: c && i >= 0 ? b(i) : void 0,
74
- onKeyDown: S
79
+ ariaControls: p,
80
+ ariaActivedescendant: c && i >= 0 ? D(i) : void 0,
81
+ onKeyDown: _
75
82
  }
76
83
  ),
77
- c && /* @__PURE__ */ w(
84
+ c && /* @__PURE__ */ m(
78
85
  "div",
79
86
  {
80
- id: m,
87
+ id: p,
81
88
  role: "listbox",
82
89
  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__ */ w(
90
+ children: n.map((e, r) => /* @__PURE__ */ m(
84
91
  "div",
85
92
  {
86
- id: b(r),
93
+ id: D(r),
87
94
  role: "option",
88
95
  "aria-selected": r === i,
89
96
  className: `block w-full cursor-pointer p-[var(--sp-medium,0.75rem)] text-left text-[length:var(--fs-small,0.6875rem)] text-[var(--link-color,#1c4ac9)] hover:bg-[var(--hover-color,#EEF7FB)] hover:transition-all hover:duration-100 ${r === i ? "bg-[var(--hover-color,#EEF7FB)]" : ""}`,
90
97
  onPointerDown: (t) => {
91
- t.preventDefault(), D(e);
98
+ t.preventDefault(), k(e);
92
99
  },
93
- onMouseEnter: () => n(r),
100
+ onMouseEnter: () => l(r),
94
101
  children: e.label
95
102
  },
96
103
  e.value
@@ -100,5 +107,5 @@ function R({
100
107
  ] });
101
108
  }
102
109
  export {
103
- R as SearchableSelectBox
110
+ z as SearchableSelectBox
104
111
  };
@@ -1,69 +1,70 @@
1
1
  "use client";
2
- import { jsxs as f, jsx as r } from "react/jsx-runtime";
2
+ import { jsxs as d, jsx as r } from "react/jsx-runtime";
3
3
  import { MESSAGES as I } from "@geckou/ui-core";
4
- import { useState as O, useRef as x, useEffect as V, Fragment as q } from "react";
5
- import { InputBox as w } from "./InputBox.js";
6
- import { ErrorMessage as D } from "./ErrorMessage.js";
4
+ import { useState as N, useRef as p, useEffect as O, Fragment as V } from "react";
5
+ import { InputBox as q } from "./InputBox.js";
6
+ import { ErrorMessage as w } from "./ErrorMessage.js";
7
7
  import { KeyboardArrowDownIcon as F } from "./icons/KeyboardArrowDownIcon.js";
8
- function p(t) {
9
- return typeof t == "object" && t !== null && "label" in t && typeof t.label == "string" && "value" in t;
8
+ function g(l) {
9
+ return typeof l == "object" && l !== null && "label" in l && typeof l.label == "string" && "value" in l;
10
10
  }
11
11
  function P({
12
- options: t,
13
- name: g,
14
- value: E,
12
+ options: l,
13
+ name: E,
14
+ value: M,
15
15
  onChange: u,
16
- cssStyle: a,
17
- placeholder: o = "選択してください",
18
- canOmitSelect: M,
19
- isDisabled: s,
20
- isRequired: m,
21
- arrow: A
16
+ cssStyle: t,
17
+ placeholder: f = "選択してください",
18
+ canOmitSelect: B,
19
+ isDisabled: m,
20
+ isRequired: v,
21
+ arrow: C
22
22
  }) {
23
- var b, h;
24
- const [B, C] = O([]), l = E ?? "", c = () => {
23
+ var b, x;
24
+ const [s, j] = N([]), a = M ?? "", o = () => {
25
25
  const e = [];
26
- l === "" && m && e.push(I.required), C(e);
27
- }, N = x(l), v = x(!1);
28
- V(() => {
29
- if (!v.current) {
30
- if (l === N.current) {
31
- l !== "" && c();
26
+ a === "" && v && e.push(I.required), j(e);
27
+ }, k = p(a), h = p(!1);
28
+ O(() => {
29
+ if (!h.current) {
30
+ if (a === k.current) {
31
+ a !== "" && o();
32
32
  return;
33
33
  }
34
- v.current = !0;
34
+ h.current = !0;
35
35
  }
36
- c();
37
- }, [l]);
38
- const j = t.flatMap(
39
- (e) => p(e) ? [e] : Object.values(e).flat()
40
- ), k = (e) => {
41
- const n = j.find(
42
- (d) => String(d.value) === e
36
+ o();
37
+ }, [a]);
38
+ const A = l.flatMap(
39
+ (e) => g(e) ? [e] : Object.values(e).flat()
40
+ ), D = (e) => {
41
+ const n = A.find(
42
+ (c) => String(c.value) === e
43
43
  );
44
44
  u == null || u(n ? n.value : e);
45
45
  };
46
- return /* @__PURE__ */ f(
47
- w,
46
+ return /* @__PURE__ */ d(
47
+ q,
48
48
  {
49
- cssStyle: a,
49
+ cssStyle: t,
50
50
  className: "inline-flex [&>select]:flex-auto [&>select]:cursor-pointer [&>select]:pe-8",
51
- isDisabled: s,
51
+ isDisabled: m,
52
+ isErrored: !!s.length,
52
53
  children: [
53
- /* @__PURE__ */ f(
54
+ /* @__PURE__ */ d(
54
55
  "select",
55
56
  {
56
- name: g,
57
- value: l,
58
- disabled: s,
59
- required: m,
60
- onChange: (e) => k(e.target.value),
61
- onBlur: () => c(),
57
+ name: E,
58
+ value: a,
59
+ disabled: m,
60
+ required: v,
61
+ "aria-invalid": s.length > 0 || void 0,
62
+ onChange: (e) => D(e.target.value),
63
+ onBlur: () => o(),
62
64
  children: [
63
- M ? /* @__PURE__ */ r("option", { value: "", children: o || "選択しない" }) : /* @__PURE__ */ r("option", { disabled: !0, value: "", children: o || "選択してください" }),
64
- ["0", "NA"].includes(l.toString()) && s && /* @__PURE__ */ r("option", { disabled: !0, value: l, children: o || "選択してください" }),
65
- t.map(
66
- (e) => p(e) ? /* @__PURE__ */ r(
65
+ B ? /* @__PURE__ */ r("option", { value: "", children: f || "選択しない" }) : /* @__PURE__ */ r("option", { disabled: !0, value: "", children: f || "選択してください" }),
66
+ l.map(
67
+ (e) => g(e) ? /* @__PURE__ */ r(
67
68
  "option",
68
69
  {
69
70
  value: e.value,
@@ -71,8 +72,8 @@ function P({
71
72
  children: e.label
72
73
  },
73
74
  e.value
74
- ) : /* @__PURE__ */ f(q, { children: [
75
- Object.entries(e).map(([n, d]) => /* @__PURE__ */ r("optgroup", { label: n, children: d.map((i) => /* @__PURE__ */ r(
75
+ ) : /* @__PURE__ */ d(V, { children: [
76
+ Object.entries(e).map(([n, c]) => /* @__PURE__ */ r("optgroup", { label: n, children: c.map((i) => /* @__PURE__ */ r(
76
77
  "option",
77
78
  {
78
79
  value: i.value,
@@ -87,14 +88,14 @@ function P({
87
88
  ]
88
89
  }
89
90
  ),
90
- /* @__PURE__ */ r("div", { className: "pointer-events-none absolute inset-y-0 end-2 flex items-center [&>*]:h-4 [&>*]:fill-current [&>*]:text-current", children: A ?? /* @__PURE__ */ r(F, {}) }),
91
+ /* @__PURE__ */ r("div", { className: "pointer-events-none absolute inset-y-0 end-2 flex items-center [&>*]:h-4 [&>*]:fill-current [&>*]:text-current", children: C ?? /* @__PURE__ */ r(F, {}) }),
91
92
  /* @__PURE__ */ r(
92
- D,
93
+ w,
93
94
  {
94
- errorMessages: B,
95
+ errorMessages: s,
95
96
  cssStyle: {
96
- textColor: (b = a == null ? void 0 : a.error) == null ? void 0 : b.backgroundColor,
97
- backgroundColor: (h = a == null ? void 0 : a.error) == null ? void 0 : h.textColor
97
+ textColor: (b = t == null ? void 0 : t.error) == null ? void 0 : b.backgroundColor,
98
+ backgroundColor: (x = t == null ? void 0 : t.error) == null ? void 0 : x.textColor
98
99
  }
99
100
  }
100
101
  )
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import { jsxs as v, jsx as i } from "react/jsx-runtime";
3
- import { useState as a, useRef as h, useImperativeHandle as E, useEffect as l } from "react";
3
+ import { useState as a, useRef as p, useImperativeHandle as E, useEffect as l } from "react";
4
4
  import { KeyboardArrowDownIcon as I } from "./icons/KeyboardArrowDownIcon.js";
5
5
  import { COLOR as N } from "@geckou/ui-core";
6
6
  function $({
7
7
  isOpened: n = null,
8
- isHiddenArrow: p = !1,
8
+ isHiddenArrow: h = !1,
9
9
  isDisabled: b = !1,
10
10
  isDisableClickOutside: f = !1,
11
11
  duration: c = 0.3,
@@ -13,7 +13,7 @@ function $({
13
13
  children: w,
14
14
  ref: x
15
15
  }) {
16
- const [t, r] = a(n || !1), [C, u] = a(n || !1), [y, H] = a(0), d = h(null), m = h(null), R = () => r((e) => !e);
16
+ const [t, r] = a(n || !1), [C, u] = a(n || !1), [y, k] = a(0), d = p(null), m = p(null), H = () => r((e) => !e);
17
17
  E(x, () => ({
18
18
  isOpenedContents: () => t,
19
19
  close: () => r(!1)
@@ -31,7 +31,7 @@ function $({
31
31
  const e = m.current;
32
32
  if (!e)
33
33
  return;
34
- const s = () => H(e.clientHeight);
34
+ const s = () => k(e.clientHeight);
35
35
  s();
36
36
  const o = new ResizeObserver(s);
37
37
  return o.observe(e), () => o.disconnect();
@@ -43,8 +43,8 @@ function $({
43
43
  const e = setTimeout(() => u(!0), c * 1e3);
44
44
  return () => clearTimeout(e);
45
45
  }, [t, c]);
46
- const k = { "--link-color": N.blue };
47
- return /* @__PURE__ */ v("div", { ref: d, style: k, children: [
46
+ const R = { "--link-color": N.blue };
47
+ return /* @__PURE__ */ v("div", { ref: d, style: R, children: [
48
48
  /* @__PURE__ */ v(
49
49
  "button",
50
50
  {
@@ -53,11 +53,11 @@ function $({
53
53
  "aria-expanded": t,
54
54
  className: "relative grid w-full cursor-pointer grid-cols-[1fr_auto] items-center justify-items-start text-(--link-color)",
55
55
  onClick: (e) => {
56
- e.preventDefault(), R();
56
+ e.preventDefault(), H();
57
57
  },
58
58
  children: [
59
- /* @__PURE__ */ i("div", { className: "w-full text-left", children: g }),
60
- !p && /* @__PURE__ */ i(
59
+ /* @__PURE__ */ i("span", { className: "block w-full text-left", children: g }),
60
+ !h && /* @__PURE__ */ i(
61
61
  I,
62
62
  {
63
63
  className: `size-[var(--icon-medium,1.125rem)] flex-none text-(--link-color) transition-all duration-100 ${t ? "rotate-180" : ""}`