@geckou/ui-vue 0.9.0 → 0.10.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
@@ -301,6 +301,21 @@ const articles = ref<any[]>([])
301
301
 
302
302
  定義例はデモの `demo/styles/base.scss` を参照。
303
303
 
304
+ ## 0.10.0 の変更
305
+
306
+ - `DatePicker` の年月日欄は**入力中にエラー文言を出さない**。判定は入力のたびに
307
+ 更新し、文言は欄を離れた時点(blur)で出す。あわせて 1 桁の月・日は blur で
308
+ 2 桁へ正規化する(「1」→「01」)。年に「2」と打った瞬間に
309
+ `role="alert"` で「年は4桁の数字で入力してください」が読み上げられていたのが直る
310
+ - `DatePicker` の年月日欄が不正なとき、`update:modelValue` が空文字になる
311
+ (これまでは valid のときだけ更新していたため、画面と送信値が食い違っていた)
312
+ - `SelectBox` が `isDisabled` かつ値が `0` / `'NA'` のときにプレースホルダを
313
+ 出す分岐を削除した。0 は正当な選択値として扱う
314
+ - `SelectBox` がエラー時に `InputBox` へ `isErrored` を渡し、`aria-invalid` を付ける
315
+ - `TextArea` の `autoAdjustHeight` が `box-sizing` を見て高さを補正する
316
+ (border-box のリセット CSS を当てた環境で 2rem 足りなかった)
317
+ - `DateRangePicker` は範囲の比較前に日付を正規化する
318
+
304
319
  ## 0.9.0 の変更
305
320
 
306
321
  - `ModalBox` を重ねたとき、Escape で閉じるのは**最前面の 1 枚だけ**になった
@@ -1,10 +1,10 @@
1
- import { defineComponent as I, ref as D, reactive as R, watch as h, onBeforeUnmount as N, openBlock as f, createBlock as O, normalizeClass as u, withCtx as z, createElementVNode as n, createVNode as M, withDirectives as c, vModelDynamic as P, vModelText as $, createTextVNode as S, createElementBlock as g, createCommentVNode as B, unref as p } from "vue";
2
- import { MESSAGES as j, validateDateObject as T, splitDate as w, composeDateValue as A, formatDateValue as G } from "@geckou/ui-core";
3
- import F from "./InputBox.vue.js";
4
- import H from "./Icon/CalendarIcon.vue.js";
5
- import J from "./ErrorMessage.vue.js";
6
- import { nextUniqueId as K } from "../scripts/unique-id.js";
7
- const Q = ["type", "name", "aria-label", "aria-labelledby", "max", "min", "required", "disabled"], W = ["aria-label", "aria-labelledby", "disabled"], X = ["aria-label", "aria-labelledby", "disabled"], Y = { key: 0 }, Z = ["aria-label", "aria-labelledby", "disabled"], _ = ["id"], ee = ["id"], ae = ["id"], le = ["id"], oe = /* @__PURE__ */ I({
1
+ import { defineComponent as z, ref as B, reactive as C, watch as R, onBeforeUnmount as N, openBlock as p, createBlock as w, normalizeClass as y, withCtx as P, createElementVNode as s, createVNode as M, createTextVNode as S, createElementBlock as $, createCommentVNode as k, unref as V } from "vue";
2
+ import { MESSAGES as U, normalizeDateObject as A, formatDateValue as G, splitDate as T, validateDateObject as F, composeDateValue as H } from "@geckou/ui-core";
3
+ import J from "./InputBox.vue.js";
4
+ import K from "./Icon/CalendarIcon.vue.js";
5
+ import Q from "./ErrorMessage.vue.js";
6
+ import { nextUniqueId as W } from "../scripts/unique-id.js";
7
+ const X = ["value", "type", "name", "aria-label", "aria-labelledby", "max", "min", "required", "disabled"], Y = ["value", "aria-label", "aria-labelledby", "disabled"], Z = ["value", "aria-label", "aria-labelledby", "disabled"], _ = { key: 0 }, ee = ["value", "aria-label", "aria-labelledby", "disabled"], ae = ["id"], le = ["id"], te = ["id"], ie = ["id"], me = /* @__PURE__ */ z({
8
8
  __name: "DatePicker",
9
9
  props: {
10
10
  name: {},
@@ -20,136 +20,134 @@ const Q = ["type", "name", "aria-label", "aria-labelledby", "max", "min", "requi
20
20
  ariaLabelledBy: { default: void 0 }
21
21
  },
22
22
  emits: ["update:modelValue"],
23
- setup(t, { emit: x }) {
24
- const L = x, q = D(null), l = t, o = K("date_picker_unit"), m = (e) => l.ariaLabelledBy ? void 0 : `${l.ariaLabel ?? l.name}の${e}`, y = (e) => l.ariaLabelledBy ? `${l.ariaLabelledBy} ${o}_${e}` : void 0, d = R({
23
+ setup(t, { emit: q }) {
24
+ const v = q, x = B(null), l = t, u = W("date_picker_unit"), b = (e) => l.ariaLabelledBy ? void 0 : `${l.ariaLabel ?? l.name}の${e}`, c = (e) => l.ariaLabelledBy ? `${l.ariaLabelledBy} ${u}_${e}` : void 0, i = C({
25
25
  year: "",
26
26
  month: "",
27
27
  day: ""
28
- }), s = D(""), r = D(""), b = (e) => {
28
+ }), n = B(""), r = B(""), m = (e) => {
29
29
  l.formValidationManager && l.formValidationManager.setValid(l.name, e);
30
- }, V = (e) => !e && l.isRequired ? { isValid: !1, message: j.required } : { isValid: !0, message: "" }, E = (e) => T(
30
+ }, f = (e) => !e && l.isRequired ? { isValid: !1, message: U.required } : { isValid: !0, message: "" }, O = (e) => F(
31
31
  { year: e.year, month: e.month, day: e.day ?? "" },
32
32
  { type: l.type, isRequired: l.isRequired }
33
- ), v = (e) => {
34
- const { year: a, month: i, day: C } = w(e);
35
- d.year = a, d.month = i, d.day = l.type === "month" ? "" : C;
36
- }, U = () => A({ ...d }, l.type);
37
- h(
38
- () => s.value,
39
- (e) => {
40
- v(e);
41
- const { isValid: a, message: i } = V(e);
42
- r.value = i, L("update:modelValue", e), b(a);
43
- }
44
- ), h(
45
- () => d,
46
- (e) => {
47
- const { isValid: a, message: i } = E(e);
48
- r.value = i, b(a), a && (s.value = U());
49
- },
50
- { deep: !0 }
51
- );
52
- const k = (e) => {
33
+ ), h = (e) => {
34
+ const { year: a, month: d, day: o } = T(e);
35
+ i.year = a, i.month = d, i.day = l.type === "month" ? "" : o;
36
+ }, E = () => H({ ...i }, l.type), j = (e) => {
37
+ const a = e.target.value;
38
+ n.value = a, h(a);
39
+ const { isValid: d, message: o } = f(a);
40
+ r.value = o, m(d), v("update:modelValue", a);
41
+ }, I = (e) => {
42
+ const { isValid: a, message: d } = O(i);
43
+ m(a), r.value = e ? d : "";
44
+ const o = a ? E() : "";
45
+ o !== n.value && (n.value = o, v("update:modelValue", o));
46
+ }, D = (e, a) => {
47
+ i[e] = a.target.value, I(!1);
48
+ }, g = () => {
49
+ const e = A({ ...i });
50
+ i.year = e.year, i.month = e.month, i.day = e.day, I(!0);
51
+ }, L = (e) => {
53
52
  if (!e) {
54
- s.value = "", v(""), r.value = "", b(V("").isValid);
53
+ n.value = "", h(""), r.value = "", m(f("").isValid);
55
54
  return;
56
55
  }
57
56
  const a = G(e, l.type);
58
- !a || a === s.value || (s.value = a, v(a));
57
+ !a || a === n.value || (n.value = a, h(a), r.value = "", m(f(a).isValid), a !== e && v("update:modelValue", a));
59
58
  };
60
- return h(
59
+ return R(
61
60
  () => l.modelValue,
62
- (e) => k(e)
63
- ), k(l.modelValue), b(V(s.value).isValid), N(() => {
61
+ (e) => L(e)
62
+ ), L(l.modelValue), m(f(n.value).isValid), N(() => {
64
63
  var e;
65
64
  return (e = l.formValidationManager) == null ? void 0 : e.remove(l.name);
66
- }), (e, a) => (f(), O(F, {
65
+ }), (e, a) => (p(), w(J, {
67
66
  isDisabled: t.isDisabled,
68
- class: u([
67
+ class: y([
69
68
  e.$style.date_picker,
70
69
  e.$style[t.size],
71
70
  { [e.$style.is_disabled]: t.isDisabled }
72
71
  ]),
73
72
  isErrored: !!r.value
74
73
  }, {
75
- default: z(() => [
76
- n("div", {
77
- class: u(e.$style.date_input)
74
+ default: P(() => [
75
+ s("div", {
76
+ class: y(e.$style.date_input)
78
77
  }, [
79
- M(H, {
80
- class: u(e.$style.icon)
78
+ M(K, {
79
+ class: y(e.$style.icon)
81
80
  }, null, 8, ["class"]),
82
- c(n("input", {
81
+ s("input", {
83
82
  ref_key: "datePicker",
84
- ref: q,
85
- "onUpdate:modelValue": a[0] || (a[0] = (i) => s.value = i),
83
+ ref: x,
84
+ value: n.value,
86
85
  type: t.type,
87
86
  name: t.name,
88
- "aria-label": m("カレンダー"),
89
- "aria-labelledby": y("カレンダー"),
87
+ "aria-label": b("カレンダー"),
88
+ "aria-labelledby": c("カレンダー"),
90
89
  max: t.maxDate,
91
90
  min: t.minDate,
92
91
  required: t.isRequired,
93
- disabled: t.isDisabled
94
- }, null, 8, Q), [
95
- [P, s.value]
96
- ])
92
+ disabled: t.isDisabled,
93
+ onInput: j
94
+ }, null, 40, X)
97
95
  ], 2),
98
- c(n("input", {
99
- "onUpdate:modelValue": a[1] || (a[1] = (i) => d.year = i),
96
+ s("input", {
97
+ value: i.year,
100
98
  placeholder: "年",
101
- "aria-label": m("年"),
102
- "aria-labelledby": y("年"),
99
+ "aria-label": b("年"),
100
+ "aria-labelledby": c("年"),
103
101
  maxlength: "4",
104
102
  type: "text",
105
103
  disabled: t.isDisabled,
106
- class: u(e.$style.year)
107
- }, null, 10, W), [
108
- [$, d.year]
109
- ]),
110
- a[4] || (a[4] = S("/ ", -1)),
111
- c(n("input", {
112
- "onUpdate:modelValue": a[2] || (a[2] = (i) => d.month = i),
104
+ class: y(e.$style.year),
105
+ onInput: a[0] || (a[0] = (d) => D("year", d)),
106
+ onBlur: g
107
+ }, null, 42, Y),
108
+ a[3] || (a[3] = S("/ ", -1)),
109
+ s("input", {
110
+ value: i.month,
113
111
  placeholder: "月",
114
- "aria-label": m("月"),
115
- "aria-labelledby": y("月"),
112
+ "aria-label": b("月"),
113
+ "aria-labelledby": c("月"),
116
114
  maxlength: "2",
117
115
  type: "text",
118
- disabled: t.isDisabled
119
- }, null, 8, X), [
120
- [$, d.month]
121
- ]),
122
- t.type === "date" ? (f(), g("span", Y, "/")) : B("", !0),
123
- t.type === "date" ? c((f(), g("input", {
116
+ disabled: t.isDisabled,
117
+ onInput: a[1] || (a[1] = (d) => D("month", d)),
118
+ onBlur: g
119
+ }, null, 40, Z),
120
+ t.type === "date" ? (p(), $("span", _, "/")) : k("", !0),
121
+ t.type === "date" ? (p(), $("input", {
124
122
  key: 1,
125
- "onUpdate:modelValue": a[3] || (a[3] = (i) => d.day = i),
123
+ value: i.day,
126
124
  placeholder: "日",
127
- "aria-label": m("日"),
128
- "aria-labelledby": y("日"),
125
+ "aria-label": b("日"),
126
+ "aria-labelledby": c("日"),
129
127
  maxlength: "2",
130
128
  type: "text",
131
- disabled: t.isDisabled
132
- }, null, 8, Z)), [
133
- [$, d.day]
134
- ]) : B("", !0),
135
- t.ariaLabelledBy ? (f(), g("span", {
129
+ disabled: t.isDisabled,
130
+ onInput: a[2] || (a[2] = (d) => D("day", d)),
131
+ onBlur: g
132
+ }, null, 40, ee)) : k("", !0),
133
+ t.ariaLabelledBy ? (p(), $("span", {
136
134
  key: 2,
137
- class: u(e.$style.unit_labels)
135
+ class: y(e.$style.unit_labels)
138
136
  }, [
139
- n("span", {
140
- id: `${p(o)}_カレンダー`
141
- }, "のカレンダー", 8, _),
142
- n("span", {
143
- id: `${p(o)}_年`
144
- }, "の年", 8, ee),
145
- n("span", {
146
- id: `${p(o)}_月`
147
- }, "の月", 8, ae),
148
- n("span", {
149
- id: `${p(o)}_日`
150
- }, "の日", 8, le)
151
- ], 2)) : B("", !0),
152
- M(J, {
137
+ s("span", {
138
+ id: `${V(u)}_カレンダー`
139
+ }, "のカレンダー", 8, ae),
140
+ s("span", {
141
+ id: `${V(u)}_年`
142
+ }, "の年", 8, le),
143
+ s("span", {
144
+ id: `${V(u)}_月`
145
+ }, "の月", 8, te),
146
+ s("span", {
147
+ id: `${V(u)}_日`
148
+ }, "の日", 8, ie)
149
+ ], 2)) : k("", !0),
150
+ M(Q, {
153
151
  errorMessages: r.value ? [r.value] : []
154
152
  }, null, 8, ["errorMessages"])
155
153
  ]),
@@ -158,5 +156,5 @@ const Q = ["type", "name", "aria-label", "aria-labelledby", "max", "min", "requi
158
156
  }
159
157
  });
160
158
  export {
161
- oe as default
159
+ me as default
162
160
  };
@@ -1,8 +1,8 @@
1
- import { defineComponent as R, computed as i, watch as z, onBeforeUnmount as E, openBlock as b, createElementBlock as q, normalizeClass as c, createVNode as r, createElementVNode as x, unref as k } from "vue";
2
- import { MESSAGES as B } from "@geckou/ui-core";
3
- import g from "./DatePicker.vue.js";
4
- import S from "./ErrorMessage.vue.js";
5
- const A = /* @__PURE__ */ R({
1
+ import { defineComponent as b, computed as l, watch as q, onBeforeUnmount as x, openBlock as S, createElementBlock as k, normalizeClass as v, createVNode as s, createElementVNode as B, unref as $ } from "vue";
2
+ import { formatDateValue as M, MESSAGES as N } from "@geckou/ui-core";
3
+ import y from "./DatePicker.vue.js";
4
+ import U from "./ErrorMessage.vue.js";
5
+ const w = /* @__PURE__ */ b({
6
6
  __name: "DateRangePicker",
7
7
  props: {
8
8
  name: {},
@@ -16,59 +16,61 @@ const A = /* @__PURE__ */ R({
16
16
  type: { default: "date" }
17
17
  },
18
18
  emits: ["update:modelValue"],
19
- setup(e, { emit: M }) {
20
- const u = M, t = e, l = i(() => t.modelValue.start), n = i(() => t.modelValue.end), s = i(
21
- () => !(l.value && n.value && l.value > n.value)
22
- ), f = i(() => `${t.name}Range`);
23
- z(
24
- [s, f],
25
- ([a, d], m) => {
26
- var V, D;
27
- const o = m == null ? void 0 : m[1];
28
- o && o !== d && ((V = t.formValidationManager) == null || V.remove(o)), (D = t.formValidationManager) == null || D.setValid(d, a);
19
+ setup(e, { emit: z }) {
20
+ const f = z, t = e, n = l(() => t.modelValue.start), i = l(() => t.modelValue.end), d = l(
21
+ () => M(n.value, t.type)
22
+ ), m = l(() => M(i.value, t.type)), V = l(
23
+ () => !(d.value && m.value && d.value > m.value)
24
+ ), c = l(() => `${t.name}Range`);
25
+ q(
26
+ [V, c],
27
+ ([a, o], r) => {
28
+ var D, g;
29
+ const u = r == null ? void 0 : r[1];
30
+ u && u !== o && ((D = t.formValidationManager) == null || D.remove(u)), (g = t.formValidationManager) == null || g.setValid(o, a);
29
31
  },
30
32
  { immediate: !0 }
31
- ), E(() => {
33
+ ), x(() => {
32
34
  var a;
33
- return (a = t.formValidationManager) == null ? void 0 : a.remove(f.value);
35
+ return (a = t.formValidationManager) == null ? void 0 : a.remove(c.value);
34
36
  });
35
- const v = (a) => u("update:modelValue", { start: a ?? "", end: n.value }), y = (a) => u("update:modelValue", { start: l.value, end: a ?? "" });
36
- return (a, d) => (b(), q("div", {
37
- class: c(a.$style.date_range_picker)
37
+ const R = (a) => f("update:modelValue", { start: a ?? "", end: i.value }), E = (a) => f("update:modelValue", { start: n.value, end: a ?? "" });
38
+ return (a, o) => (S(), k("div", {
39
+ class: v(a.$style.date_range_picker)
38
40
  }, [
39
- r(g, {
41
+ s(y, {
40
42
  name: `${e.name}Start`,
41
- modelValue: l.value,
43
+ modelValue: n.value,
42
44
  isDisabled: e.isDisabled,
43
45
  isRequired: e.isRequired,
44
46
  formValidationManager: e.formValidationManager,
45
47
  minDate: e.minDate,
46
- maxDate: n.value || e.maxDate,
48
+ maxDate: m.value || e.maxDate,
47
49
  size: e.size,
48
50
  type: e.type,
49
- "onUpdate:modelValue": v
51
+ "onUpdate:modelValue": R
50
52
  }, null, 8, ["name", "modelValue", "isDisabled", "isRequired", "formValidationManager", "minDate", "maxDate", "size", "type"]),
51
- x("div", {
52
- class: c(a.$style.range)
53
+ B("div", {
54
+ class: v(a.$style.range)
53
55
  }, "〜", 2),
54
- r(g, {
56
+ s(y, {
55
57
  name: `${e.name}End`,
56
- modelValue: n.value,
58
+ modelValue: i.value,
57
59
  isDisabled: e.isDisabled,
58
60
  isRequired: e.isRequired,
59
61
  formValidationManager: e.formValidationManager,
60
- minDate: l.value || e.minDate,
62
+ minDate: d.value || e.minDate,
61
63
  maxDate: e.maxDate,
62
64
  size: e.size,
63
65
  type: e.type,
64
- "onUpdate:modelValue": y
66
+ "onUpdate:modelValue": E
65
67
  }, null, 8, ["name", "modelValue", "isDisabled", "isRequired", "formValidationManager", "minDate", "maxDate", "size", "type"]),
66
- r(S, {
67
- errorMessages: s.value ? void 0 : [k(B).startAfterEnd]
68
+ s(U, {
69
+ errorMessages: V.value ? void 0 : [$(N).startAfterEnd]
68
70
  }, null, 8, ["errorMessages"])
69
71
  ], 2));
70
72
  }
71
73
  });
72
74
  export {
73
- A as default
75
+ w as default
74
76
  };
@@ -1,9 +1,9 @@
1
- import { defineComponent as q, ref as E, computed as M, watch as N, openBlock as t, createBlock as D, normalizeClass as n, withCtx as O, withDirectives as R, createElementVNode as v, createElementBlock as a, toDisplayString as d, createCommentVNode as B, Fragment as i, renderList as y, vModelSelect as x, renderSlot as A, createVNode as I } from "vue";
2
- import { isEmptyValue as C, MESSAGES as z } from "@geckou/ui-core";
1
+ import { defineComponent as E, ref as $, computed as q, watch as M, openBlock as t, createBlock as p, normalizeClass as u, withCtx as O, withDirectives as N, createElementVNode as v, createElementBlock as a, toDisplayString as c, Fragment as i, renderList as y, vModelSelect as R, renderSlot as x, createCommentVNode as I, createVNode as z } from "vue";
2
+ import { isEmptyValue as D, MESSAGES as A } from "@geckou/ui-core";
3
3
  import F from "./InputBox.vue.js";
4
4
  import G from "./ErrorMessage.vue.js";
5
5
  import L from "./Icon/KeyboardArrowDownIcon.vue.js";
6
- const U = ["name", "disabled", "required"], H = {
6
+ const U = ["name", "disabled", "required", "aria-invalid"], H = {
7
7
  key: 0,
8
8
  value: ""
9
9
  }, J = {
@@ -11,7 +11,7 @@ const U = ["name", "disabled", "required"], H = {
11
11
  disabled: "",
12
12
  selected: "",
13
13
  value: ""
14
- }, K = ["value"], P = ["value", "disabled"], Q = ["label"], T = ["value", "disabled"], _ = /* @__PURE__ */ q({
14
+ }, K = ["value", "disabled"], P = ["label"], Q = ["value", "disabled"], j = /* @__PURE__ */ E({
15
15
  __name: "SelectBox",
16
16
  props: {
17
17
  options: {},
@@ -24,86 +24,82 @@ const U = ["name", "disabled", "required"], H = {
24
24
  isRequired: { type: Boolean }
25
25
  },
26
26
  emits: ["update:modelValue"],
27
- setup(e, { emit: p }) {
28
- const w = p, c = e, m = E([]), o = M({
29
- get: () => c.modelValue ?? "",
30
- set: (l) => w("update:modelValue", l)
31
- }), b = (l) => typeof l == "object" && l !== null && "label" in l && typeof l.label == "string" && "value" in l, f = () => {
32
- m.value = [], C(o.value) && c.isRequired && m.value.push(z.required);
27
+ setup(l, { emit: B }) {
28
+ const C = B, m = l, o = $([]), d = q({
29
+ get: () => m.modelValue ?? "",
30
+ set: (e) => C("update:modelValue", e)
31
+ }), b = (e) => typeof e == "object" && e !== null && "label" in e && typeof e.label == "string" && "value" in e, f = () => {
32
+ o.value = [], D(d.value) && m.isRequired && o.value.push(A.required);
33
33
  };
34
- return N(
35
- () => o.value,
34
+ return M(
35
+ () => d.value,
36
36
  () => f(),
37
- { immediate: !C(c.modelValue), flush: "post" }
38
- ), (l, r) => (t(), D(F, {
39
- cssStyle: e.cssStyle,
40
- class: n(l.$style.select_box),
41
- isDisabled: e.isDisabled
37
+ { immediate: !D(m.modelValue), flush: "post" }
38
+ ), (e, r) => (t(), p(F, {
39
+ cssStyle: l.cssStyle,
40
+ class: u(e.$style.select_box),
41
+ isDisabled: l.isDisabled,
42
+ isErrored: !!o.value.length
42
43
  }, {
43
44
  default: O(() => {
44
- var S, h, k, g;
45
+ var S, g, h, k;
45
46
  return [
46
- R(v("select", {
47
- "onUpdate:modelValue": r[0] || (r[0] = (s) => o.value = s),
48
- name: e.name,
49
- disabled: e.isDisabled,
50
- required: e.isRequired,
51
- class: n(l.$style.select),
47
+ N(v("select", {
48
+ "onUpdate:modelValue": r[0] || (r[0] = (s) => d.value = s),
49
+ name: l.name,
50
+ disabled: l.isDisabled,
51
+ required: l.isRequired,
52
+ "aria-invalid": o.value.length > 0 || void 0,
53
+ class: u(e.$style.select),
52
54
  onBlur: r[1] || (r[1] = (s) => f())
53
55
  }, [
54
- e.canOmitSelect ? (t(), a("option", H, d(e.placeholder || "選択しない"), 1)) : (t(), a("option", J, d(e.placeholder || "選択してください"), 1)),
55
- ["0", "NA"].includes(o.value.toString()) && e.isDisabled ? (t(), a("option", {
56
- key: 2,
57
- disabled: "",
58
- selected: "",
59
- value: o.value
60
- }, d(e.placeholder || "選択してください"), 9, K)) : B("", !0),
61
- (t(!0), a(i, null, y(e.options, (s) => (t(), a(i, {
56
+ l.canOmitSelect ? (t(), a("option", H, c(l.placeholder || "選択しない"), 1)) : (t(), a("option", J, c(l.placeholder || "選択してください"), 1)),
57
+ (t(!0), a(i, null, y(l.options, (s) => (t(), a(i, {
62
58
  key: b(s) ? s.value : Object.keys(s)[0]
63
59
  }, [
64
60
  b(s) ? (t(), a("option", {
65
61
  key: 0,
66
62
  value: s.value,
67
63
  disabled: s.isDisabled
68
- }, d(s.label), 9, P)) : (t(), a(i, { key: 1 }, [
69
- (t(!0), a(i, null, y(s, ($, V) => (t(), a("optgroup", {
64
+ }, c(s.label), 9, K)) : (t(), a(i, { key: 1 }, [
65
+ (t(!0), a(i, null, y(s, (w, V) => (t(), a("optgroup", {
70
66
  key: V,
71
67
  label: V
72
68
  }, [
73
- (t(!0), a(i, null, y($, (u) => (t(), a("option", {
74
- key: u.value,
75
- value: u.value,
76
- disabled: u.isDisabled
77
- }, d(u.label), 9, T))), 128))
78
- ], 8, Q))), 128)),
69
+ (t(!0), a(i, null, y(w, (n) => (t(), a("option", {
70
+ key: n.value,
71
+ value: n.value,
72
+ disabled: n.isDisabled
73
+ }, c(n.label), 9, Q))), 128))
74
+ ], 8, P))), 128)),
79
75
  r[2] || (r[2] = v("hr", null, null, -1))
80
76
  ], 64))
81
77
  ], 64))), 128))
82
78
  ], 42, U), [
83
- [x, o.value]
79
+ [R, d.value]
84
80
  ]),
85
81
  v("div", {
86
- class: n(l.$style.arrow_container)
82
+ class: u(e.$style.arrow_container)
87
83
  }, [
88
- A(l.$slots, "arrow"),
89
- l.$slots.arrow ? B("", !0) : (t(), D(L, {
84
+ x(e.$slots, "arrow"),
85
+ e.$slots.arrow ? I("", !0) : (t(), p(L, {
90
86
  key: 0,
91
- class: n(l.$style.arrow)
87
+ class: u(e.$style.arrow)
92
88
  }, null, 8, ["class"]))
93
89
  ], 2),
94
- I(G, {
95
- errorMessages: m.value,
90
+ z(G, {
91
+ errorMessages: o.value,
96
92
  cssStyle: {
97
- textColor: (h = (S = e.cssStyle) == null ? void 0 : S.error) == null ? void 0 : h.backgroundColor,
98
- backgroundColor: (g = (k = e.cssStyle) == null ? void 0 : k.error) == null ? void 0 : g.textColor
93
+ textColor: (g = (S = l.cssStyle) == null ? void 0 : S.error) == null ? void 0 : g.backgroundColor,
94
+ backgroundColor: (k = (h = l.cssStyle) == null ? void 0 : h.error) == null ? void 0 : k.textColor
99
95
  }
100
96
  }, null, 8, ["errorMessages", "cssStyle"])
101
97
  ];
102
98
  }),
103
99
  _: 3
104
- }, 8, ["cssStyle", "class", "isDisabled"]));
100
+ }, 8, ["cssStyle", "class", "isDisabled", "isErrored"]));
105
101
  }
106
102
  });
107
103
  export {
108
- _ as default
104
+ j as default
109
105
  };
@@ -1,8 +1,8 @@
1
- import { defineComponent as x, computed as y, ref as v, onMounted as V, watch as p, openBlock as b, createBlock as S, normalizeClass as w, withCtx as B, withDirectives as C, createElementVNode as k, vModelText as q, createVNode as D, nextTick as M } from "vue";
2
- import { isEmptyValue as R, validateInputValue as E } from "@geckou/ui-core";
3
- import H from "./InputBox.vue.js";
4
- import T from "./ErrorMessage.vue.js";
5
- const j = ["name", "required", "placeholder", "disabled", "autocomplete", "rows", "maxlength", "aria-invalid"], N = /* @__PURE__ */ x({
1
+ import { defineComponent as y, computed as p, ref as g, onMounted as b, watch as V, openBlock as S, createBlock as B, normalizeClass as C, withCtx as w, withDirectives as k, createElementVNode as q, vModelText as D, createVNode as H, nextTick as M } from "vue";
2
+ import { isEmptyValue as R, validateInputValue as T } from "@geckou/ui-core";
3
+ import E from "./InputBox.vue.js";
4
+ import j from "./ErrorMessage.vue.js";
5
+ const A = ["name", "required", "placeholder", "disabled", "autocomplete", "rows", "maxlength", "aria-invalid"], N = /* @__PURE__ */ y({
6
6
  __name: "TextArea",
7
7
  props: {
8
8
  name: {},
@@ -19,39 +19,42 @@ const j = ["name", "required", "placeholder", "disabled", "autocomplete", "rows"
19
19
  },
20
20
  emits: ["update:modelValue"],
21
21
  setup(e, { emit: h }) {
22
- const g = h, t = e, l = y({
23
- get: () => t.modelValue ?? "",
24
- set: (r) => g("update:modelValue", r)
25
- }), o = v([]), a = v(null), u = () => {
26
- o.value = E(l.value, {
27
- isRequired: t.isRequired,
28
- validates: t.validates
22
+ const v = h, a = e, d = p({
23
+ get: () => a.modelValue ?? "",
24
+ set: (l) => v("update:modelValue", l)
25
+ }), r = g([]), o = g(null), m = () => {
26
+ r.value = T(d.value, {
27
+ isRequired: a.isRequired,
28
+ validates: a.validates
29
29
  });
30
- }, d = () => {
31
- t.autoAdjustHeight && M(() => {
32
- a.value && (a.value.style.height = "auto", a.value.style.height = `calc(${a.value.scrollHeight}px - 2rem)`);
30
+ }, x = (l) => {
31
+ const t = getComputedStyle(l), s = (...i) => i.reduce((u, n) => u + (parseFloat(n) || 0), 0);
32
+ return t.boxSizing === "border-box" ? l.scrollHeight + s(t.borderTopWidth, t.borderBottomWidth) : l.scrollHeight - s(t.paddingTop, t.paddingBottom);
33
+ }, c = () => {
34
+ a.autoAdjustHeight && M(() => {
35
+ o.value && (o.value.style.height = "auto", o.value.style.height = `${x(o.value)}px`);
33
36
  });
34
37
  };
35
- return V(d), p(
36
- l,
38
+ return b(c), V(
39
+ d,
37
40
  () => {
38
- u(), d();
41
+ m(), c();
39
42
  },
40
43
  // 数値 0 も初期値として扱うため truthy 判定は使わない
41
- { immediate: !R(t.modelValue), flush: "post" }
42
- ), (r, s) => (b(), S(H, {
44
+ { immediate: !R(a.modelValue), flush: "post" }
45
+ ), (l, t) => (S(), B(E, {
43
46
  cssStyle: e.cssStyle,
44
- class: w(r.$style.text_area),
45
- isErrored: !!o.value.length,
47
+ class: C(l.$style.text_area),
48
+ isErrored: !!r.value.length,
46
49
  isDisabled: e.isDisabled
47
50
  }, {
48
- default: B(() => {
49
- var i, n, m, c;
51
+ default: w(() => {
52
+ var s, i, u, n;
50
53
  return [
51
- C(k("textarea", {
54
+ k(q("textarea", {
52
55
  ref_key: "textareaRef",
53
- ref: a,
54
- "onUpdate:modelValue": s[0] || (s[0] = (f) => l.value = f),
56
+ ref: o,
57
+ "onUpdate:modelValue": t[0] || (t[0] = (f) => d.value = f),
55
58
  name: e.name,
56
59
  required: e.isRequired,
57
60
  placeholder: e.placeholder,
@@ -59,16 +62,16 @@ const j = ["name", "required", "placeholder", "disabled", "autocomplete", "rows"
59
62
  autocomplete: e.autocomplete,
60
63
  rows: e.rows,
61
64
  maxlength: e.maxLength,
62
- "aria-invalid": o.value.length ? "true" : void 0,
63
- onBlur: s[1] || (s[1] = (f) => u())
64
- }, null, 40, j), [
65
- [q, l.value]
65
+ "aria-invalid": r.value.length ? "true" : void 0,
66
+ onBlur: t[1] || (t[1] = (f) => m())
67
+ }, null, 40, A), [
68
+ [D, d.value]
66
69
  ]),
67
- D(T, {
68
- errorMessages: o.value,
70
+ H(j, {
71
+ errorMessages: r.value,
69
72
  cssStyle: {
70
- textColor: (n = (i = e.cssStyle) == null ? void 0 : i.error) == null ? void 0 : n.backgroundColor,
71
- backgroundColor: (c = (m = e.cssStyle) == null ? void 0 : m.error) == null ? void 0 : c.textColor
73
+ textColor: (i = (s = e.cssStyle) == null ? void 0 : s.error) == null ? void 0 : i.backgroundColor,
74
+ backgroundColor: (n = (u = e.cssStyle) == null ? void 0 : u.error) == null ? void 0 : n.textColor
72
75
  }
73
76
  }, null, 8, ["errorMessages", "cssStyle"])
74
77
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geckou/ui-vue",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "A set of reusable Vue UI components (forms & article lists) by Geckou",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "vue": "^3.5.0"
33
33
  },
34
34
  "dependencies": {
35
- "@geckou/ui-core": "^0.6.0",
35
+ "@geckou/ui-core": "^0.7.0",
36
36
  "date-fns": "^4.4.0"
37
37
  },
38
38
  "scripts": {