@geckou/ui-vue 0.12.0 → 0.14.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,35 @@ const articles = ref<any[]>([])
301
301
 
302
302
  定義例はデモの `demo/styles/base.scss` を参照。
303
303
 
304
+ ## 0.14.0 の変更
305
+
306
+ - `DropdownUi` が Escape で閉じ、トリガーへフォーカスを戻す。処理したときは
307
+ `preventDefault()` するので、`ModalBox` の中に置いてもダイアログまで閉じない
308
+ - `DropdownUi` / `SlideDownUi` のトリガーに `aria-controls` が付き、
309
+ `DropdownUi` には `aria-haspopup="true"` も付く
310
+ - `DropdownUi` / `SlideDownUi` の中身の高さを `ResizeObserver` で測るようにした。
311
+ `onUpdated` だけでは、スロットの中の子コンポーネントが自前の状態で伸縮したときに
312
+ 高さがずれていた
313
+
314
+ ## 0.13.0 の変更
315
+
316
+ - `BasicButton` はローディング中に `disabled` にしない(押した瞬間にフォーカスが
317
+ `body` へ落ちるため)。代わりに `aria-disabled` / `aria-busy` を付け、
318
+ `pointer-events` と click ガードで押せなくする。**`:disabled` を前提に
319
+ スタイルを当てている場合は `[aria-disabled]` の追従が要る**
320
+ - `BasicButton` のローディング中もアクセシブル名を保つ(`visibility: hidden` → `opacity: 0`)。
321
+ `LoadingSpinner` は `aria-hidden="true"`
322
+ - `BasicButton` の hover 色が `color-mix()` になった(3 桁 hex 等で不正値になっていた)。
323
+ `cssStyle` の差し替えにも追従する(`hoverStyle` を `computed` に)
324
+ - `PopupBox` は**表示している間だけ**スロットを描画する
325
+ - `ModalBox` はマウント時点で `isShown` が true でもダイアログへフォーカスを移す
326
+ - `ModalBox` の背景クリック判定が「押し始めも背景だったとき」だけになった
327
+ - `RadioButtons` が `role="radiogroup"`、`CheckBoxes` が `role="group"` になり、
328
+ どちらも `ariaLabel` / `ariaLabelledBy` を受ける。エラーは `aria-describedby` で結び付く
329
+ - `RadioButtons` が `cssStyle.textColor` を `--text-color` へ出す(React 版と揃えた)
330
+ - `CheckButton` が `ariaLabel` / `ariaLabelledBy` を受ける
331
+ - `CheckBoxes` の `errorColor` が `cssStyle` の差し替えに追従する
332
+ - `ErrorMessage` が `id` を受ける
304
333
  ## 0.12.0 の変更
305
334
 
306
335
  - `GenericArticleList` が `theme='grid'` を実装した(型には含まれるのに switch に無く、
@@ -1,7 +1,7 @@
1
- import { defineComponent as K, computed as M, openBlock as A, createElementBlock as P, normalizeClass as F, normalizeStyle as Q, unref as l, withDirectives as U, createElementVNode as H, renderSlot as J, createBlock as W, vShow as X } from "vue";
2
- import Y from "./LoadingSpinner.vue.js";
3
- import { COLOR as s } from "@geckou/ui-core";
4
- const Z = ["type", "disabled"], ro = /* @__PURE__ */ K({
1
+ import { defineComponent as J, computed as R, openBlock as V, createElementBlock as K, normalizeClass as j, normalizeStyle as M, withDirectives as Q, createElementVNode as q, renderSlot as A, createBlock as U, vShow as W } from "vue";
2
+ import X from "./LoadingSpinner.vue.js";
3
+ import { COLOR as i } from "@geckou/ui-core";
4
+ const Y = ["type", "disabled", "aria-disabled", "aria-busy"], oe = /* @__PURE__ */ J({
5
5
  __name: "BasicButton",
6
6
  props: {
7
7
  cssStyle: {},
@@ -10,62 +10,70 @@ const Z = ["type", "disabled"], ro = /* @__PURE__ */ K({
10
10
  isDisabled: { type: Boolean },
11
11
  buttonType: {}
12
12
  },
13
- setup(r) {
14
- var i;
15
- const d = r, o = M(() => {
16
- var n, t;
17
- const e = d.isDisabled ? (n = d.cssStyle) == null ? void 0 : n.disabled : (t = d.cssStyle) == null ? void 0 : t.default;
13
+ setup(a) {
14
+ const r = a, o = R(() => {
15
+ var t, d;
16
+ const e = r.isDisabled ? (t = r.cssStyle) == null ? void 0 : t.disabled : (d = r.cssStyle) == null ? void 0 : d.default;
18
17
  return {
19
- textColor: s.white,
20
- backgroundColor: d.isDisabled ? s.darkGray : s.blue,
18
+ textColor: i.white,
19
+ backgroundColor: r.isDisabled ? i.darkGray : i.blue,
21
20
  backgroundImage: "none",
22
21
  border: {
23
- color: d.isDisabled ? s.darkGray : s.blue,
22
+ color: r.isDisabled ? i.darkGray : i.blue,
24
23
  size: "1px",
25
24
  radius: ".25rem"
26
25
  },
27
26
  boxShadow: "0 0 0 0 transparent",
28
27
  ...e
29
28
  };
30
- }), a = ((i = d.cssStyle) == null ? void 0 : i.hover) || {};
31
- return (e, n) => {
32
- var t, u, b, c, g, v, m, y, h, k, S, C, f, z, p, w, x, $, B, D, L, I, E, G, O, T, N, R, V, j, q;
33
- return A(), P("button", {
34
- class: F([e.$style.button, { [e.$style.loading]: r.isLoading }]),
35
- style: Q({
36
- "--text-color": (t = o.value) == null ? void 0 : t.textColor,
37
- "--background-color": (u = o.value) == null ? void 0 : u.backgroundColor,
38
- "--background-image": (b = o.value) == null ? void 0 : b.backgroundImage,
39
- "--border-color": (g = (c = o.value) == null ? void 0 : c.border) == null ? void 0 : g.color,
40
- "--border-size": (m = (v = o.value) == null ? void 0 : v.border) == null ? void 0 : m.size,
41
- "--radius-size": (h = (y = o.value) == null ? void 0 : y.border) == null ? void 0 : h.radius,
42
- "--box-shadow": (k = o.value) == null ? void 0 : k.boxShadow,
43
- "--hover-text-color": ((S = l(a)) == null ? void 0 : S.textColor) || ((C = o.value) == null ? void 0 : C.textColor),
44
- "--hover-background-color": ((f = l(a)) == null ? void 0 : f.backgroundColor) || ((z = o.value) == null ? void 0 : z.backgroundColor) && `${(p = o.value) == null ? void 0 : p.backgroundColor}cc`,
45
- "--hover-background-image": ((w = l(a)) == null ? void 0 : w.backgroundImage) || ((x = o.value) == null ? void 0 : x.backgroundImage),
46
- "--hover-border-color": ((B = ($ = l(a)) == null ? void 0 : $.border) == null ? void 0 : B.color) || ((L = (D = o.value) == null ? void 0 : D.border) == null ? void 0 : L.color),
47
- "--hover-border-size": ((E = (I = l(a)) == null ? void 0 : I.border) == null ? void 0 : E.size) || ((O = (G = o.value) == null ? void 0 : G.border) == null ? void 0 : O.size),
48
- "--hover-radius-size": ((N = (T = l(a)) == null ? void 0 : T.border) == null ? void 0 : N.radius) || ((V = (R = o.value) == null ? void 0 : R.border) == null ? void 0 : V.radius),
49
- "--hover-box-shadow": ((j = l(a)) == null ? void 0 : j.boxShadow) || ((q = o.value) == null ? void 0 : q.boxShadow),
50
- "--duration": `${r.duration || 0.3}s`
29
+ }), l = R(() => {
30
+ var e;
31
+ return ((e = r.cssStyle) == null ? void 0 : e.hover) || {};
32
+ }), F = (e) => e && `color-mix(in srgb, ${e} 80%, transparent)`, H = (e) => {
33
+ r.isLoading && (e.preventDefault(), e.stopImmediatePropagation());
34
+ };
35
+ return (e, t) => {
36
+ var d, n, s, u, b, c, v, g, m, y, h, k, S, f, C, x, z, p, w, D, L, $, B, I, E, G, O, T, N, P;
37
+ return V(), K("button", {
38
+ class: j([e.$style.button, { [e.$style.loading]: a.isLoading }]),
39
+ style: M({
40
+ "--text-color": (d = o.value) == null ? void 0 : d.textColor,
41
+ "--background-color": (n = o.value) == null ? void 0 : n.backgroundColor,
42
+ "--background-image": (s = o.value) == null ? void 0 : s.backgroundImage,
43
+ "--border-color": (b = (u = o.value) == null ? void 0 : u.border) == null ? void 0 : b.color,
44
+ "--border-size": (v = (c = o.value) == null ? void 0 : c.border) == null ? void 0 : v.size,
45
+ "--radius-size": (m = (g = o.value) == null ? void 0 : g.border) == null ? void 0 : m.radius,
46
+ "--box-shadow": (y = o.value) == null ? void 0 : y.boxShadow,
47
+ "--hover-text-color": ((h = l.value) == null ? void 0 : h.textColor) || ((k = o.value) == null ? void 0 : k.textColor),
48
+ "--hover-background-color": ((S = l.value) == null ? void 0 : S.backgroundColor) || F((f = o.value) == null ? void 0 : f.backgroundColor),
49
+ "--hover-background-image": ((C = l.value) == null ? void 0 : C.backgroundImage) || ((x = o.value) == null ? void 0 : x.backgroundImage),
50
+ "--hover-border-color": ((p = (z = l.value) == null ? void 0 : z.border) == null ? void 0 : p.color) || ((D = (w = o.value) == null ? void 0 : w.border) == null ? void 0 : D.color),
51
+ "--hover-border-size": (($ = (L = l.value) == null ? void 0 : L.border) == null ? void 0 : $.size) || ((I = (B = o.value) == null ? void 0 : B.border) == null ? void 0 : I.size),
52
+ "--hover-radius-size": ((G = (E = l.value) == null ? void 0 : E.border) == null ? void 0 : G.radius) || ((T = (O = o.value) == null ? void 0 : O.border) == null ? void 0 : T.radius),
53
+ "--hover-box-shadow": ((N = l.value) == null ? void 0 : N.boxShadow) || ((P = o.value) == null ? void 0 : P.boxShadow),
54
+ "--duration": `${a.duration || 0.3}s`
51
55
  }),
52
- type: r.buttonType || "button",
53
- disabled: r.isDisabled || r.isLoading
56
+ type: a.buttonType || "button",
57
+ disabled: a.isDisabled,
58
+ "aria-disabled": a.isDisabled || a.isLoading || void 0,
59
+ "aria-busy": a.isLoading || void 0,
60
+ onClick: H
54
61
  }, [
55
- U(H("div", {
56
- class: F(e.$style.loading_animation)
62
+ Q(q("div", {
63
+ class: j(e.$style.loading_animation),
64
+ "aria-hidden": "true"
57
65
  }, [
58
- e.$slots.loading ? J(e.$slots, "loading", {}, void 0, void 0, 0) : (A(), W(Y, { key: 1 }))
66
+ e.$slots.loading ? A(e.$slots, "loading", {}, void 0, void 0, 0) : (V(), U(X, { key: 1 }))
59
67
  ], 2), [
60
- [X, r.isLoading]
68
+ [W, a.isLoading]
61
69
  ]),
62
- H("div", null, [
63
- J(e.$slots, "default")
70
+ q("div", null, [
71
+ A(e.$slots, "default")
64
72
  ])
65
- ], 14, Z);
73
+ ], 14, Y);
66
74
  };
67
75
  }
68
76
  });
69
77
  export {
70
- ro as default
78
+ oe as default
71
79
  };
@@ -1,11 +1,11 @@
1
- const n = "_button_pz98w_1", o = "_loading_pz98w_25", t = "_loading_animation_pz98w_35", a = {
2
- button: n,
3
- loading: o,
1
+ const o = "_button_1ocs4_1", n = "_loading_1ocs4_25", t = "_loading_animation_1ocs4_35", a = {
2
+ button: o,
3
+ loading: n,
4
4
  loading_animation: t
5
5
  };
6
6
  export {
7
- n as button,
7
+ o as button,
8
8
  a as default,
9
- o as loading,
9
+ n as loading,
10
10
  t as loading_animation
11
11
  };
@@ -6,6 +6,12 @@ type __VLS_Props = {
6
6
  isDisabled?: boolean;
7
7
  isRequired?: boolean;
8
8
  cssStyle?: CheckBoxStyleForEachStatus;
9
+ /**
10
+ * チェックボックス群自体のアクセシブル名。
11
+ * 可視ラベル(見出し等)があるなら ariaLabelledBy でその要素を指すこと
12
+ */
13
+ ariaLabel?: string;
14
+ ariaLabelledBy?: string;
9
15
  };
10
16
  declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
11
17
  "update:modelValue": (newValue: SelectValue[]) => any;
@@ -14,5 +20,7 @@ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {
14
20
  }>, {
15
21
  cssStyle: CheckBoxStyleForEachStatus;
16
22
  modelValue: SelectValue[];
23
+ ariaLabel: string;
24
+ ariaLabelledBy: string;
17
25
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
18
26
  export default _default;
@@ -1,8 +1,9 @@
1
- import { defineComponent as V, ref as k, computed as E, watch as m, openBlock as i, createElementBlock as y, normalizeClass as q, Fragment as M, renderList as x, createBlock as B, createVNode as D } from "vue";
2
- import { COLOR as v, MESSAGES as _ } from "@geckou/ui-core";
3
- import A from "./LabeledCheckbox.vue.js";
4
- import L from "./ErrorMessage.vue.js";
5
- const F = /* @__PURE__ */ V({
1
+ import { defineComponent as B, ref as p, computed as k, watch as m, openBlock as v, createElementBlock as g, normalizeClass as E, unref as S, Fragment as q, renderList as x, createBlock as M, createVNode as D } from "vue";
2
+ import { COLOR as b, MESSAGES as A } from "@geckou/ui-core";
3
+ import I from "./LabeledCheckbox.vue.js";
4
+ import R from "./ErrorMessage.vue.js";
5
+ import { nextUniqueId as U } from "../scripts/unique-id.js";
6
+ const z = ["aria-label", "aria-labelledby", "aria-describedby"], $ = /* @__PURE__ */ B({
6
7
  __name: "CheckBoxes",
7
8
  props: {
8
9
  name: {},
@@ -10,12 +11,14 @@ const F = /* @__PURE__ */ V({
10
11
  modelValue: { default: void 0 },
11
12
  isDisabled: { type: Boolean },
12
13
  isRequired: { type: Boolean },
13
- cssStyle: { default: void 0 }
14
+ cssStyle: { default: void 0 },
15
+ ariaLabel: { default: void 0 },
16
+ ariaLabelledBy: { default: void 0 }
14
17
  },
15
18
  emits: ["update:modelValue"],
16
- setup(p, { emit: g }) {
17
- var b, f;
18
- const S = g, a = p, s = k(
19
+ setup(s, { emit: C }) {
20
+ var y;
21
+ const V = C, a = s, f = U("check_boxes_error"), u = p(
19
22
  a.options.map((e) => {
20
23
  var r;
21
24
  return {
@@ -24,22 +27,22 @@ const F = /* @__PURE__ */ V({
24
27
  checked: ((r = a.modelValue) == null ? void 0 : r.includes(e.value)) || !1
25
28
  };
26
29
  })
27
- ), c = E(
28
- () => s.value.filter((e) => e.checked).map((e) => e.value)
29
- ), n = k(""), C = () => n.value = a.isRequired && c.value.length === 0 ? _.required : "";
30
+ ), n = k(
31
+ () => u.value.filter((e) => e.checked).map((e) => e.value)
32
+ ), o = p(""), L = () => o.value = a.isRequired && n.value.length === 0 ? A.required : "";
30
33
  m(
31
- c,
34
+ n,
32
35
  (e, r) => {
33
- r && ((l, u) => l.length === u.length && l.every((o, d) => o === u[d]))(e, r) || (C(), S("update:modelValue", e));
36
+ r && ((l, d) => l.length === d.length && l.every((i, c) => i === d[c]))(e, r) || (L(), V("update:modelValue", e));
34
37
  },
35
38
  {
36
39
  deep: !0,
37
- immediate: !!((b = a.modelValue) != null && b.length)
40
+ immediate: !!((y = a.modelValue) != null && y.length)
38
41
  }
39
42
  ), m(
40
43
  () => a.modelValue,
41
44
  (e) => {
42
- e && s.value.forEach(
45
+ e && u.value.forEach(
43
46
  (r) => r.checked = e.includes(r.value)
44
47
  );
45
48
  },
@@ -50,15 +53,15 @@ const F = /* @__PURE__ */ V({
50
53
  ), m(
51
54
  () => a.options,
52
55
  (e) => {
53
- if (e.length === s.value.length && e.every(
54
- (l, u) => {
55
- var o, d;
56
- return l.value === ((o = s.value[u]) == null ? void 0 : o.value) && l.label === ((d = s.value[u]) == null ? void 0 : d.label);
56
+ if (e.length === u.value.length && e.every(
57
+ (l, d) => {
58
+ var i, c;
59
+ return l.value === ((i = u.value[d]) == null ? void 0 : i.value) && l.label === ((c = u.value[d]) == null ? void 0 : c.label);
57
60
  }
58
61
  ))
59
62
  return;
60
- const t = new Set(c.value);
61
- s.value = e.map((l) => ({
63
+ const t = new Set(n.value);
64
+ u.value = e.map((l) => ({
62
65
  value: l.value,
63
66
  label: l.label,
64
67
  checked: a.modelValue ? a.modelValue.includes(l.value) : t.has(l.value)
@@ -66,39 +69,47 @@ const F = /* @__PURE__ */ V({
66
69
  },
67
70
  { deep: !0 }
68
71
  );
69
- const h = {
70
- ...((f = a.cssStyle) == null ? void 0 : f.error) ?? {},
71
- textColor: v.white,
72
- backgroundColor: v.red,
73
- border: {
74
- color: v.red,
75
- size: "1px",
76
- radius: ".25rem"
77
- }
78
- };
79
- return (e, r) => (i(), y("div", {
80
- class: q(e.$style.check_boxes)
72
+ const h = k(() => {
73
+ var e;
74
+ return {
75
+ ...((e = a.cssStyle) == null ? void 0 : e.error) ?? {},
76
+ textColor: b.white,
77
+ backgroundColor: b.red,
78
+ border: {
79
+ color: b.red,
80
+ size: "1px",
81
+ radius: ".25rem"
82
+ }
83
+ };
84
+ });
85
+ return (e, r) => (v(), g("div", {
86
+ class: E(e.$style.check_boxes),
87
+ role: "group",
88
+ "aria-label": s.ariaLabelledBy ? void 0 : s.ariaLabel,
89
+ "aria-labelledby": s.ariaLabelledBy,
90
+ "aria-describedby": o.value ? S(f) : void 0
81
91
  }, [
82
- (i(!0), y(M, null, x(s.value, (t, l) => (i(), B(A, {
92
+ (v(!0), g(q, null, x(u.value, (t, l) => (v(), M(I, {
83
93
  key: t.value,
84
- modelValue: s.value[l].checked,
85
- "onUpdate:modelValue": (u) => s.value[l].checked = u,
86
- name: p.name,
94
+ modelValue: u.value[l].checked,
95
+ "onUpdate:modelValue": (d) => u.value[l].checked = d,
96
+ name: s.name,
87
97
  value: t.value,
88
98
  label: t.label,
89
99
  isDisabled: a.isDisabled,
90
100
  cssStyle: a.cssStyle
91
101
  }, null, 8, ["modelValue", "onUpdate:modelValue", "name", "value", "label", "isDisabled", "cssStyle"]))), 128)),
92
- D(L, {
93
- errorMessages: n.value ? [n.value] : [],
102
+ D(R, {
103
+ id: S(f),
104
+ errorMessages: o.value ? [o.value] : [],
94
105
  cssStyle: {
95
- textColor: h.textColor,
96
- backgroundColor: h.backgroundColor
106
+ textColor: h.value.textColor,
107
+ backgroundColor: h.value.backgroundColor
97
108
  }
98
- }, null, 8, ["errorMessages", "cssStyle"])
99
- ], 2));
109
+ }, null, 8, ["id", "errorMessages", "cssStyle"])
110
+ ], 10, z));
100
111
  }
101
112
  });
102
113
  export {
103
- F as default
114
+ $ as default
104
115
  };
@@ -5,6 +5,13 @@ type __VLS_Props = {
5
5
  isDisabled?: boolean;
6
6
  cssStyle?: CheckBoxStyleForEachStatus;
7
7
  isDisableAnimation?: boolean;
8
+ /**
9
+ * アクセシブル名。可視ラベルがあるなら ariaLabelledBy でその要素を指すこと。
10
+ * 文言を持たない label で包むだけだったため、
11
+ * スクリーンリーダーでは「チェックボックス」としか読まれなかった
12
+ */
13
+ ariaLabel?: string;
14
+ ariaLabelledBy?: string;
8
15
  };
9
16
  declare function __VLS_template(): {
10
17
  attrs: Partial<{}>;
@@ -21,6 +28,8 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}
21
28
  "onUpdate:modelValue"?: ((newValue: boolean) => any) | undefined;
22
29
  }>, {
23
30
  cssStyle: CheckBoxStyleForEachStatus;
31
+ ariaLabel: string;
32
+ ariaLabelledBy: string;
24
33
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLLabelElement>;
25
34
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
26
35
  export default _default;
@@ -1,54 +1,58 @@
1
- import { defineComponent as C, ref as V, computed as B, watch as b, openBlock as k, createElementBlock as D, normalizeClass as f, normalizeStyle as S, withDirectives as z, createElementVNode as p, vModelCheckbox as $, renderSlot as g, createBlock as w, createCommentVNode as x } from "vue";
2
- import A from "./Icon/CheckIcon.vue.js";
3
- const E = ["name", "disabled"], M = /* @__PURE__ */ C({
1
+ import { defineComponent as C, ref as V, computed as p, watch as b, openBlock as f, createElementBlock as D, normalizeClass as y, normalizeStyle as S, withDirectives as z, createElementVNode as k, vModelCheckbox as L, renderSlot as $, createBlock as g, createCommentVNode as w } from "vue";
2
+ import x from "./Icon/CheckIcon.vue.js";
3
+ const A = ["name", "aria-label", "aria-labelledby", "disabled"], I = /* @__PURE__ */ C({
4
4
  __name: "CheckButton",
5
5
  props: {
6
6
  name: {},
7
7
  modelValue: { type: Boolean },
8
8
  isDisabled: { type: Boolean },
9
9
  cssStyle: { default: () => ({ default: {} }) },
10
- isDisableAnimation: { type: Boolean }
10
+ isDisableAnimation: { type: Boolean },
11
+ ariaLabel: { default: void 0 },
12
+ ariaLabelledBy: { default: void 0 }
11
13
  },
12
14
  emits: ["update:modelValue"],
13
- setup(o, { emit: y }) {
14
- const h = y, l = o, t = V(l.modelValue ?? !1), a = B(() => l.isDisabled ? l.cssStyle.disabled : l.cssStyle.default);
15
+ setup(e, { emit: h }) {
16
+ const v = h, l = e, t = V(l.modelValue ?? !1), o = p(() => l.isDisabled ? l.cssStyle.disabled : l.cssStyle.default);
15
17
  return b(
16
18
  () => t.value,
17
- (e) => h("update:modelValue", e)
19
+ (a) => v("update:modelValue", a)
18
20
  ), b(
19
21
  () => l.modelValue,
20
- (e) => t.value = e,
22
+ (a) => t.value = a,
21
23
  { immediate: !0 }
22
- ), (e, s) => {
23
- var r, n, i, d, c, u, m;
24
- return k(), D("label", {
25
- class: f(e.$style.check_box),
24
+ ), (a, d) => {
25
+ var i, r, n, s, u, c, m;
26
+ return f(), D("label", {
27
+ class: y(a.$style.check_box),
26
28
  style: S({
27
- "--border-color": ((n = (r = a.value) == null ? void 0 : r.border) == null ? void 0 : n.color) || "blue",
28
- "--border-size": ((d = (i = a.value) == null ? void 0 : i.border) == null ? void 0 : d.size) || "1px",
29
- "--radius-size": ((u = (c = a.value) == null ? void 0 : c.border) == null ? void 0 : u.radius) || "0.25rem",
30
- "--background-color": ((m = a.value) == null ? void 0 : m.backgroundColor) || "#fff",
31
- "--duration": o.isDisableAnimation ? "0s" : ".3s"
29
+ "--border-color": ((r = (i = o.value) == null ? void 0 : i.border) == null ? void 0 : r.color) || "blue",
30
+ "--border-size": ((s = (n = o.value) == null ? void 0 : n.border) == null ? void 0 : s.size) || "1px",
31
+ "--radius-size": ((c = (u = o.value) == null ? void 0 : u.border) == null ? void 0 : c.radius) || "0.25rem",
32
+ "--background-color": ((m = o.value) == null ? void 0 : m.backgroundColor) || "#fff",
33
+ "--duration": e.isDisableAnimation ? "0s" : ".3s"
32
34
  })
33
35
  }, [
34
- z(p("input", {
35
- "onUpdate:modelValue": s[0] || (s[0] = (v) => t.value = v),
36
+ z(k("input", {
37
+ "onUpdate:modelValue": d[0] || (d[0] = (B) => t.value = B),
36
38
  type: "checkbox",
37
- name: o.name,
38
- disabled: o.isDisabled
39
- }, null, 8, E), [
40
- [$, t.value]
39
+ name: e.name,
40
+ "aria-label": e.ariaLabelledBy ? void 0 : e.ariaLabel ?? e.name,
41
+ "aria-labelledby": e.ariaLabelledBy,
42
+ disabled: e.isDisabled
43
+ }, null, 8, A), [
44
+ [L, t.value]
41
45
  ]),
42
- p("div", {
43
- class: f(e.$style.check_container)
46
+ k("div", {
47
+ class: y(a.$style.check_container)
44
48
  }, [
45
- g(e.$slots, "check"),
46
- e.$slots.check ? x("", !0) : (k(), w(A, { key: 0 }))
49
+ $(a.$slots, "check"),
50
+ a.$slots.check ? w("", !0) : (f(), g(x, { key: 0 }))
47
51
  ], 2)
48
52
  ], 6);
49
53
  };
50
54
  }
51
55
  });
52
56
  export {
53
- M as default
57
+ I as default
54
58
  };
@@ -12,6 +12,7 @@ declare function __VLS_template(): {
12
12
  };
13
13
  refs: {
14
14
  root: HTMLDivElement;
15
+ trigger: HTMLButtonElement;
15
16
  contents: HTMLDivElement;
16
17
  };
17
18
  rootEl: HTMLDivElement;
@@ -27,6 +28,7 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {
27
28
  contentsWidth: string;
28
29
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
29
30
  root: HTMLDivElement;
31
+ trigger: HTMLButtonElement;
30
32
  contents: HTMLDivElement;
31
33
  }, HTMLDivElement>;
32
34
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -1,7 +1,8 @@
1
- import { defineComponent as h, ref as o, onMounted as k, onUpdated as $, openBlock as a, createElementBlock as u, normalizeClass as l, createElementVNode as f, normalizeStyle as v, withModifiers as p, renderSlot as m, createBlock as w, createCommentVNode as b } from "vue";
2
- import C from "./Icon/KeyboardArrowDownIcon.vue.js";
3
- import { useClickOutside as D } from "../scripts/use-click-outside.js";
4
- const B = ["disabled", "aria-expanded"], z = ["inert"], E = /* @__PURE__ */ h({
1
+ import { defineComponent as D, ref as s, onMounted as C, onBeforeUnmount as z, openBlock as c, createElementBlock as m, normalizeClass as a, withKeys as B, createElementVNode as y, normalizeStyle as b, withModifiers as A, renderSlot as g, createBlock as H, createCommentVNode as h } from "vue";
2
+ import S from "./Icon/KeyboardArrowDownIcon.vue.js";
3
+ import { useClickOutside as I } from "../scripts/use-click-outside.js";
4
+ import { nextUniqueId as O } from "../scripts/unique-id.js";
5
+ const V = ["disabled", "aria-expanded", "aria-haspopup", "aria-controls"], R = ["inert"], N = /* @__PURE__ */ D({
5
6
  __name: "DropdownUi",
6
7
  props: {
7
8
  isHiddenArrow: { type: Boolean, default: !1 },
@@ -9,57 +10,72 @@ const B = ["disabled", "aria-expanded"], z = ["inert"], E = /* @__PURE__ */ h({
9
10
  isDisabled: { type: Boolean, default: !1 },
10
11
  contentsWidth: { default: "auto" }
11
12
  },
12
- setup(n, { expose: y }) {
13
- const t = o(!1), i = o(null), r = o(null), c = o(0), g = () => t.value = !t.value, s = () => t.value = !1, d = () => {
14
- const e = r.value;
15
- e && (c.value = e.clientHeight);
13
+ setup(n, { expose: $ }) {
14
+ const t = s(!1), d = s(null), i = s(null), u = s(null), f = s(0), v = O("dropdown") + "_panel", k = () => t.value = !t.value, l = () => t.value = !1, w = (e) => {
15
+ var r;
16
+ t.value && (e.preventDefault(), l(), (r = u.value) == null || r.focus());
17
+ }, p = () => {
18
+ const e = i.value;
19
+ e && (f.value = e.clientHeight);
16
20
  };
17
- return D(i, () => s()), k(() => d()), $(() => d()), y({ isContentsOpened: t, close: s }), (e, A) => (a(), u("div", {
21
+ I(d, () => l());
22
+ let o = null;
23
+ return C(() => {
24
+ p();
25
+ const e = i.value;
26
+ !e || typeof ResizeObserver > "u" || (o = new ResizeObserver(p), o.observe(e));
27
+ }), z(() => o == null ? void 0 : o.disconnect()), $({ isContentsOpened: t, close: l }), (e, r) => (c(), m("div", {
18
28
  ref_key: "root",
19
- ref: i,
20
- class: l(e.$style.drop_down_box)
29
+ ref: d,
30
+ class: a(e.$style.drop_down_box),
31
+ onKeydown: B(w, ["escape"])
21
32
  }, [
22
- f("button", {
23
- class: l(e.$style.button),
33
+ y("button", {
34
+ ref_key: "trigger",
35
+ ref: u,
36
+ class: a(e.$style.button),
24
37
  disabled: n.isDisabled,
25
38
  "aria-expanded": t.value,
39
+ "aria-haspopup": e.$slots.contents ? "true" : void 0,
40
+ "aria-controls": e.$slots.contents ? v : void 0,
26
41
  type: "button",
27
- style: v({
42
+ style: b({
28
43
  "--trigger-color": n.isDisabled || !e.$slots.contents ? "var(--text-color)" : "var(--link-color)",
29
44
  cursor: n.isDisabled || !e.$slots.contents ? "auto" : "pointer"
30
45
  }),
31
- onClick: p(g, ["prevent"])
46
+ onClick: A(k, ["prevent"])
32
47
  }, [
33
- m(e.$slots, "trigger"),
34
- n.isHiddenArrow || !e.$slots.contents || n.isDisabled ? b("", !0) : (a(), w(C, {
48
+ g(e.$slots, "trigger"),
49
+ n.isHiddenArrow || !e.$slots.contents || n.isDisabled ? h("", !0) : (c(), H(S, {
35
50
  key: 0,
36
- class: l([e.$style.icon, { [e.$style.open]: t.value }])
51
+ class: a([e.$style.icon, { [e.$style.open]: t.value }])
37
52
  }, null, 8, ["class"]))
38
- ], 14, B),
39
- e.$slots.contents ? (a(), u("div", {
53
+ ], 14, V),
54
+ e.$slots.contents ? (c(), m("div", {
40
55
  key: 0,
41
- class: l(e.$style.contents),
56
+ id: v,
57
+ class: a(e.$style.contents),
42
58
  inert: !t.value || void 0,
43
- style: v({
59
+ style: b({
44
60
  boxShadow: t.value ? "var(--box-shadow)" : "none",
45
- blockSize: t.value ? `${c.value}px` : 0,
61
+ blockSize: t.value ? `${f.value}px` : 0,
46
62
  inlineSize: n.contentsWidth,
47
63
  right: n.contentAlignment === "right" ? "calc(var(--bv) * -0.5)" : "auto",
48
64
  left: n.contentAlignment === "left" ? "calc(var(--bv) * -0.5)" : "auto",
49
65
  zIndex: "2"
50
66
  })
51
67
  }, [
52
- f("div", {
68
+ y("div", {
53
69
  ref_key: "contents",
54
- ref: r,
55
- onClick: s
70
+ ref: i,
71
+ onClick: l
56
72
  }, [
57
- m(e.$slots, "contents")
73
+ g(e.$slots, "contents")
58
74
  ], 512)
59
- ], 14, z)) : b("", !0)
60
- ], 2));
75
+ ], 14, R)) : h("", !0)
76
+ ], 34));
61
77
  }
62
78
  });
63
79
  export {
64
- E as default
80
+ N as default
65
81
  };
@@ -1,4 +1,6 @@
1
1
  type __VLS_Props = {
2
+ /** aria-describedby から参照させたいときに渡す */
3
+ id?: string;
2
4
  cssStyle?: {
3
5
  textColor: string | undefined;
4
6
  backgroundColor: string | undefined;