@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,68 +1,76 @@
1
1
  "use client";
2
- import { jsxs as j, jsx as p } from "react/jsx-runtime";
3
- import { isEmptyValue as k, validateInputValue as B } from "@geckou/ui-core";
4
- import { useState as I, useRef as n, useEffect as A } from "react";
5
- import { InputBox as H } from "./InputBox.js";
6
- import { ErrorMessage as N } from "./ErrorMessage.js";
7
- function z({
8
- name: d,
9
- value: s,
10
- onChange: o,
2
+ import { jsxs as H, jsx as h } from "react/jsx-runtime";
3
+ import { isEmptyValue as M, validateInputValue as T } from "@geckou/ui-core";
4
+ import { useState as j, useRef as m, useEffect as k } from "react";
5
+ import { InputBox as I } from "./InputBox.js";
6
+ import { ErrorMessage as W } from "./ErrorMessage.js";
7
+ function z(n) {
8
+ const e = getComputedStyle(n), t = (...r) => r.reduce((a, i) => a + (parseFloat(i) || 0), 0);
9
+ return e.boxSizing === "border-box" ? n.scrollHeight + t(e.borderTopWidth, e.borderBottomWidth) : n.scrollHeight - t(e.paddingTop, e.paddingBottom);
10
+ }
11
+ function q({
12
+ name: n,
13
+ value: e,
14
+ onChange: t,
11
15
  cssStyle: r,
12
- placeholder: x = "入力してください",
16
+ placeholder: a = "入力してください",
13
17
  isDisabled: i,
14
- isRequired: l,
15
- rows: g,
16
- maxLength: h = 100,
18
+ isRequired: p,
19
+ rows: x,
20
+ maxLength: b = 100,
17
21
  autocomplete: v = "off",
18
22
  validates: E = [],
19
23
  autoAdjustHeight: V
20
24
  }) {
21
- var m, c;
22
- const [u, C] = I([]), t = n(null), e = s ?? "", a = () => {
23
- C(B(e, { isRequired: l, validates: E }));
24
- }, M = n(e), f = n(!1);
25
- return A(() => {
26
- if (V && t.current && (t.current.style.height = "auto", t.current.style.height = `calc(${t.current.scrollHeight}px - 2rem)`), !f.current) {
27
- if (e === M.current) {
28
- k(e) || a();
25
+ var c, g;
26
+ const [l, B] = j([]), d = m(null), o = e ?? "", f = () => {
27
+ B(T(o, { isRequired: p, validates: E }));
28
+ }, C = m(o), s = m(!1);
29
+ return k(() => {
30
+ if (V && d.current) {
31
+ const u = d.current;
32
+ u.style.height = "auto", u.style.height = `${z(u)}px`;
33
+ }
34
+ if (!s.current) {
35
+ if (o === C.current) {
36
+ M(o) || f();
29
37
  return;
30
38
  }
31
- f.current = !0;
39
+ s.current = !0;
32
40
  }
33
- a();
34
- }, [e]), /* @__PURE__ */ j(
35
- H,
41
+ f();
42
+ }, [o]), /* @__PURE__ */ H(
43
+ I,
36
44
  {
37
45
  cssStyle: r,
38
46
  className: "min-h-[4em]",
39
- isErrored: !!u.length,
47
+ isErrored: !!l.length,
40
48
  isDisabled: i,
41
49
  children: [
42
- /* @__PURE__ */ p(
50
+ /* @__PURE__ */ h(
43
51
  "textarea",
44
52
  {
45
- ref: t,
46
- name: d,
47
- value: e,
48
- required: l,
49
- placeholder: x,
53
+ ref: d,
54
+ name: n,
55
+ value: o,
56
+ required: p,
57
+ placeholder: a,
50
58
  disabled: i,
51
59
  autoComplete: v,
52
- rows: g,
53
- maxLength: h,
54
- "aria-invalid": u.length ? "true" : void 0,
55
- onChange: (b) => o == null ? void 0 : o(b.target.value),
56
- onBlur: () => a()
60
+ rows: x,
61
+ maxLength: b,
62
+ "aria-invalid": l.length ? "true" : void 0,
63
+ onChange: (u) => t == null ? void 0 : t(u.target.value),
64
+ onBlur: () => f()
57
65
  }
58
66
  ),
59
- /* @__PURE__ */ p(
60
- N,
67
+ /* @__PURE__ */ h(
68
+ W,
61
69
  {
62
- errorMessages: u,
70
+ errorMessages: l,
63
71
  cssStyle: {
64
- textColor: (m = r == null ? void 0 : r.error) == null ? void 0 : m.backgroundColor,
65
- backgroundColor: (c = r == null ? void 0 : r.error) == null ? void 0 : c.textColor
72
+ textColor: (c = r == null ? void 0 : r.error) == null ? void 0 : c.backgroundColor,
73
+ backgroundColor: (g = r == null ? void 0 : r.error) == null ? void 0 : g.textColor
66
74
  }
67
75
  }
68
76
  )
@@ -71,5 +79,5 @@ function z({
71
79
  );
72
80
  }
73
81
  export {
74
- z as TextArea
82
+ q as TextArea
75
83
  };
@@ -23,11 +23,13 @@ type Props = {
23
23
  */
24
24
  role?: string;
25
25
  ariaLabel?: string;
26
+ /** 可視ラベルがあるなら、その要素の id をここで指す(ariaLabel より優先) */
27
+ ariaLabelledBy?: string;
26
28
  ariaExpanded?: boolean;
27
29
  ariaControls?: string;
28
30
  ariaActivedescendant?: string;
29
31
  ariaAutocomplete?: 'none' | 'inline' | 'list' | 'both';
30
32
  onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
31
33
  };
32
- export declare function TextBox({ name, value, onChange, cssStyle, inputType, placeholder, isDisabled, isRequired, maxLength, autocomplete, validates, before, after, id, role, ariaLabel, ariaExpanded, ariaControls, ariaActivedescendant, ariaAutocomplete, onKeyDown, }: Props): import("react").JSX.Element;
34
+ export declare function TextBox({ name, value, onChange, cssStyle, inputType, placeholder, isDisabled, isRequired, maxLength, autocomplete, validates, before, after, id, role, ariaLabel, ariaLabelledBy, ariaExpanded, ariaControls, ariaActivedescendant, ariaAutocomplete, onKeyDown, }: Props): import("react").JSX.Element;
33
35
  export {};
@@ -1,99 +1,101 @@
1
1
  "use client";
2
- import { jsxs as A, jsx as s } from "react/jsx-runtime";
3
- import { isEmptyValue as G, convertFullWidthToHalfWidth as x, validateInputValue as J } from "@geckou/ui-core";
4
- import { useState as K, useRef as n, useEffect as L } from "react";
5
- import { InputBox as O } from "./InputBox.js";
6
- import { ErrorMessage as P } from "./ErrorMessage.js";
7
- function Z({
8
- name: v,
9
- value: E,
10
- onChange: t,
2
+ import { jsxs as G, jsx as x } from "react/jsx-runtime";
3
+ import { isEmptyValue as J, convertFullWidthToHalfWidth as v, validateInputValue as K } from "@geckou/ui-core";
4
+ import { useState as O, useRef as n, useEffect as P } from "react";
5
+ import { InputBox as Q } from "./InputBox.js";
6
+ import { ErrorMessage as R } from "./ErrorMessage.js";
7
+ function $({
8
+ name: E,
9
+ value: V,
10
+ onChange: e,
11
11
  cssStyle: r,
12
- inputType: V = "text",
13
- placeholder: b = "入力してください",
12
+ inputType: b = "text",
13
+ placeholder: g = "入力してください",
14
14
  isDisabled: l,
15
15
  isRequired: f,
16
- maxLength: g = 30,
17
- autocomplete: B = "off",
18
- validates: M = [],
19
- before: T,
20
- after: j,
21
- id: k,
22
- role: I,
23
- ariaLabel: W,
24
- ariaExpanded: w,
25
- ariaControls: C,
26
- ariaActivedescendant: F,
27
- ariaAutocomplete: H,
28
- onKeyDown: N
16
+ maxLength: M = 30,
17
+ autocomplete: T = "off",
18
+ validates: j = [],
19
+ before: k,
20
+ after: B,
21
+ id: I,
22
+ role: W,
23
+ ariaLabel: w,
24
+ ariaLabelledBy: d,
25
+ ariaExpanded: C,
26
+ ariaControls: F,
27
+ ariaActivedescendant: H,
28
+ ariaAutocomplete: N,
29
+ onKeyDown: q
29
30
  }) {
30
- var d, c;
31
- const [o, q] = K([]), e = E ?? "", a = () => {
32
- q(J(e, { isRequired: f, validates: M }));
33
- }, z = n(e), p = n(!1);
34
- L(() => {
31
+ var c, m;
32
+ const [o, z] = O([]), t = V ?? "", a = () => {
33
+ z(K(t, { isRequired: f, validates: j }));
34
+ }, A = n(t), p = n(!1);
35
+ P(() => {
35
36
  if (!p.current) {
36
- if (e === z.current) {
37
- G(e) || a();
37
+ if (t === A.current) {
38
+ J(t) || a();
38
39
  return;
39
40
  }
40
41
  p.current = !0;
41
42
  }
42
43
  a();
43
- }, [e]);
44
+ }, [t]);
44
45
  const i = n(!1);
45
- return /* @__PURE__ */ A(
46
- O,
46
+ return /* @__PURE__ */ G(
47
+ Q,
47
48
  {
48
49
  cssStyle: r,
49
50
  className: "inline-flex [&>input]:flex-auto",
50
51
  isErrored: !!o.length,
51
52
  isDisabled: l,
52
53
  children: [
53
- T,
54
- /* @__PURE__ */ s(
54
+ k,
55
+ /* @__PURE__ */ x(
55
56
  "input",
56
57
  {
57
- type: V,
58
- id: k,
59
- name: v,
60
- role: I,
61
- "aria-label": W,
62
- "aria-expanded": w,
63
- "aria-controls": C,
64
- "aria-activedescendant": F,
65
- "aria-autocomplete": H,
66
- onKeyDown: N,
67
- value: e,
58
+ type: b,
59
+ id: I,
60
+ name: E,
61
+ role: W,
62
+ "aria-label": d ? void 0 : w,
63
+ "aria-labelledby": d,
64
+ "aria-expanded": C,
65
+ "aria-controls": F,
66
+ "aria-activedescendant": H,
67
+ "aria-autocomplete": N,
68
+ onKeyDown: q,
69
+ value: t,
68
70
  required: f,
69
- placeholder: b,
71
+ placeholder: g,
70
72
  disabled: l,
71
- autoComplete: B,
72
- maxLength: g,
73
+ autoComplete: T,
74
+ maxLength: M,
73
75
  "aria-invalid": o.length ? "true" : void 0,
74
76
  onChange: (u) => {
75
- const m = u.target.value;
76
- t == null || t(
77
- i.current ? m : x(m)
77
+ const s = u.target.value;
78
+ e == null || e(
79
+ i.current ? s : v(s)
78
80
  );
79
81
  },
80
82
  onCompositionStart: () => {
81
83
  i.current = !0;
82
84
  },
83
85
  onCompositionEnd: (u) => {
84
- i.current = !1, t == null || t(x(u.currentTarget.value));
86
+ i.current = !1, e == null || e(v(u.currentTarget.value));
85
87
  },
86
88
  onBlur: () => a()
87
89
  }
88
90
  ),
89
- j,
90
- /* @__PURE__ */ s(
91
- P,
91
+ B,
92
+ /* @__PURE__ */ x(
93
+ R,
92
94
  {
93
95
  errorMessages: o,
94
96
  cssStyle: {
95
- textColor: (d = r == null ? void 0 : r.error) == null ? void 0 : d.backgroundColor,
96
- backgroundColor: (c = r == null ? void 0 : r.error) == null ? void 0 : c.textColor
97
+ textColor: (c = r == null ? void 0 : r.error) == null ? void 0 : c.backgroundColor,
98
+ backgroundColor: (m = r == null ? void 0 : r.error) == null ? void 0 : m.textColor
97
99
  }
98
100
  }
99
101
  )
@@ -102,5 +104,5 @@ function Z({
102
104
  );
103
105
  }
104
106
  export {
105
- Z as TextBox
107
+ $ as TextBox
106
108
  };
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.5.1",
3
+ "version": "0.7.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.5.0"
43
+ "@geckou/ui-core": "^0.7.0"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "vite build && node scripts/copy-assets.mjs",