@pgcorp/ui-kit 0.12.0 → 0.13.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.
Files changed (42) hide show
  1. package/README.md +62 -0
  2. package/dist/assets/src/components/shared/_internal/SDialogSurface.css_vue_type_style_index_0_src_d1b65adf_scoped_d1b65adf_lang.css +1 -1
  3. package/dist/assets/src/components/shared/_internal/SMenuItem.css_vue_type_style_index_0_src_af485607_scoped_af485607_lang.css +2 -0
  4. package/dist/assets/src/components/shared/containers/{SCollapsiblePanel.css_vue_type_style_index_0_src_4882f962_scoped_4882f962_lang.css → SCollapsiblePanel.css_vue_type_style_index_0_src_71824088_scoped_71824088_lang.css} +1 -1
  5. package/dist/assets/src/components/shared/containers/{SModal.css_vue_type_style_index_0_src_23373daf_scoped_23373daf_lang.css → SModal.css_vue_type_style_index_0_src_0dc51b74_scoped_0dc51b74_lang.css} +1 -1
  6. package/dist/assets/src/components/shared/controls/{SDropdownMenu.css_vue_type_style_index_0_src_b854a89e_scoped_b854a89e_lang.css → SDropdownMenu.css_vue_type_style_index_0_src_1ccb9efc_scoped_1ccb9efc_lang.css} +1 -1
  7. package/dist/assets/src/components/shared/controls/{SInputText.css_vue_type_style_index_0_src_a9c5f1aa_scoped_a9c5f1aa_lang.css → SInputText.css_vue_type_style_index_0_src_023c25d0_scoped_023c25d0_lang.css} +1 -1
  8. package/dist/assets/src/components/shared/controls/SMenuSurface.css_vue_type_style_index_0_src_ddcc5fbb_scoped_ddcc5fbb_lang.css +2 -0
  9. package/dist/src/components/shared/_internal/SMenuItem.vue.js +2 -2
  10. package/dist/src/components/shared/_internal/SMenuItem.vue_vue_type_script_setup_true_lang.js +88 -76
  11. package/dist/src/components/shared/_internal/dialogSurface.d.ts +1 -1
  12. package/dist/src/components/shared/_internal/dialogSurface.js +1 -0
  13. package/dist/src/components/shared/containers/SCollapsiblePanel.vue.d.ts +1 -1
  14. package/dist/src/components/shared/containers/SCollapsiblePanel.vue.js +2 -2
  15. package/dist/src/components/shared/containers/SCollapsiblePanel.vue_vue_type_script_setup_true_lang.js +60 -58
  16. package/dist/src/components/shared/containers/SModal.vue.js +2 -2
  17. package/dist/src/components/shared/containers/SModal.vue_vue_type_script_setup_true_lang.js +43 -37
  18. package/dist/src/components/shared/controls/SDropdownMenu.vue.d.ts +15 -4
  19. package/dist/src/components/shared/controls/SDropdownMenu.vue.js +2 -2
  20. package/dist/src/components/shared/controls/SDropdownMenu.vue_vue_type_script_setup_true_lang.js +98 -62
  21. package/dist/src/components/shared/controls/SInputText.vue.d.ts +2 -2
  22. package/dist/src/components/shared/controls/SInputText.vue.js +2 -2
  23. package/dist/src/components/shared/controls/SInputText.vue_vue_type_script_setup_true_lang.js +16 -25
  24. package/dist/src/components/shared/controls/SMenuSurface.vue.js +2 -2
  25. package/dist/src/components/shared/controls/SMenuSurface.vue_vue_type_script_setup_true_lang.js +132 -110
  26. package/dist/src/components/shared/controls/STextarea.vue.d.ts +4 -0
  27. package/dist/src/components/shared/controls/STextarea.vue_vue_type_script_setup_true_lang.js +154 -147
  28. package/dist/src/components/shared/controls/menu.d.ts +9 -1
  29. package/dist/src/components/shared/controls/menu.js +43 -28
  30. package/dist/src/composables/useDialogOverlay.d.ts +1 -0
  31. package/dist/src/composables/useDialogOverlay.js +5 -2
  32. package/dist/src/internal/textLengthConstraints.d.ts +9 -0
  33. package/dist/src/internal/textLengthConstraints.js +18 -0
  34. package/dist/src/internal/useMenuLayer.d.ts +2 -1
  35. package/dist/src/internal/useMenuLayer.js +20 -14
  36. package/docs/public-api.md +14 -2
  37. package/package.json +1 -1
  38. package/src/components/shared/_internal/SDialogSurface.css +4 -0
  39. package/src/components/shared/_internal/SMenuItem.css +22 -1
  40. package/src/components/shared/controls/SMenuSurface.css +20 -0
  41. package/dist/assets/src/components/shared/_internal/SMenuItem.css_vue_type_style_index_0_src_e5bd192e_scoped_e5bd192e_lang.css +0 -2
  42. package/dist/assets/src/components/shared/controls/SMenuSurface.css_vue_type_style_index_0_src_bc7c7be4_scoped_bc7c7be4_lang.css +0 -2
@@ -2,7 +2,7 @@ import { useDisclosure as e } from "../../../composables/useDisclosure.js";
2
2
  import { useOwnedAttrs as t } from "../../../internal/ownedAttrs.js";
3
3
  import n from "../controls/SButton.vue.js";
4
4
  import r from "../_internal/SDisclosureSummary.vue.js";
5
- import { computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createVNode as c, defineComponent as l, mergeProps as u, nextTick as d, normalizeClass as f, normalizeStyle as ee, onBeforeUnmount as p, onMounted as m, openBlock as h, ref as g, renderSlot as _, unref as v, useSlots as y, vShow as te, watch as b, withCtx as x, withDirectives as S } from "vue";
5
+ import { computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createVNode as c, defineComponent as l, mergeProps as u, nextTick as d, normalizeClass as f, normalizeStyle as ee, onBeforeUnmount as te, onMounted as p, openBlock as m, ref as h, renderSlot as g, unref as _, useSlots as v, vShow as y, watch as b, withCtx as x, withDirectives as S } from "vue";
6
6
  //#region src/components/shared/containers/SCollapsiblePanel.vue?vue&type=script&setup=true&lang.ts
7
7
  var C = [
8
8
  "data-density",
@@ -58,117 +58,118 @@ var C = [
58
58
  },
59
59
  emits: ["update:open"],
60
60
  setup(l, { emit: O }) {
61
- let k = l, ne = y(), A = O, j = i(() => !!ne.actions), M = t({
61
+ let k = l, ne = v(), A = O, j = i(() => !!ne.actions), M = t({
62
62
  component: "SCollapsiblePanel",
63
63
  owner: "collapsible panel root"
64
- }), N = i(() => k.density === "comfortable" ? "md" : "sm"), P = i(() => k.open ?? !1), F = e({
64
+ }), N = i(() => k.density === "comfortable" ? "md" : "sm"), P = i(() => k.density === "comfortable" ? "default" : "compact"), F = i(() => k.open ?? !1), I = e({
65
65
  id: k.id,
66
- open: k.open === void 0 ? void 0 : P,
66
+ open: k.open === void 0 ? void 0 : F,
67
67
  defaultOpen: k.open === void 0 ? k.defaultOpen : void 0,
68
68
  disabled: () => k.disabled,
69
69
  onUpdate: (e) => A("update:open", e)
70
- }), { isOpen: I, triggerId: L, panelId: R } = F, z = g(!1), B = i(() => I.value || z.value), V = g(!k.lazy || k.defaultOpen || k.open === !0);
70
+ }), { isOpen: L, triggerId: R, panelId: z } = I, B = h(!1), V = i(() => L.value || B.value), H = h(!k.lazy || k.defaultOpen || k.open === !0);
71
71
  b(() => k.open, (e) => {
72
- e && (V.value = !0);
72
+ e && (H.value = !0);
73
73
  });
74
- function H() {
74
+ function U() {
75
75
  if (k.disabled) return;
76
76
  if (k.noAnimation) {
77
- F.toggle();
77
+ I.toggle();
78
78
  return;
79
79
  }
80
- let e = G.value, t = U.value;
81
- z.value = !0, e?.classList.add("is-animating"), e?.classList.remove("is-opened"), t?.classList.add("is-animating"), t?.classList.remove("is-opened"), F.toggle();
82
- }
83
- let U = g(null), W = g(null), G = g(null), K = null, q = null;
84
- function J() {
85
- q !== null && (window.cancelAnimationFrame(q), q = null);
80
+ let e = K.value, t = W.value;
81
+ B.value = !0, e?.classList.add("is-animating"), e?.classList.remove("is-opened"), t?.classList.add("is-animating"), t?.classList.remove("is-opened"), I.toggle();
86
82
  }
83
+ let W = h(null), G = h(null), K = h(null), q = null, J = null;
87
84
  function Y() {
88
- let e = U.value, t = W.value;
89
- if (!e || !t || !I.value || !z.value) return;
85
+ J !== null && (window.cancelAnimationFrame(J), J = null);
86
+ }
87
+ function X() {
88
+ let e = W.value, t = G.value;
89
+ if (!e || !t || !L.value || !B.value) return;
90
90
  let n = `${t.scrollHeight}px`;
91
91
  e.style.maxHeight !== n && (e.style.maxHeight = n);
92
92
  }
93
- function X() {
94
- J(), q = window.requestAnimationFrame(() => {
95
- q = null, Y();
93
+ function re() {
94
+ Y(), J = window.requestAnimationFrame(() => {
95
+ J = null, X();
96
96
  });
97
97
  }
98
98
  function Z() {
99
- let e = U.value;
99
+ let e = W.value;
100
100
  if (!e) return;
101
101
  e.classList.remove("is-animating"), e.classList.add("is-opened"), e.style.overflow = "", e.style.maxHeight = "";
102
- let t = G.value;
102
+ let t = K.value;
103
103
  t && (t.classList.remove("is-animating"), t.classList.add("is-opened"));
104
104
  }
105
105
  function Q() {
106
- let e = U.value;
106
+ let e = W.value;
107
107
  if (!e) return;
108
108
  e.classList.remove("is-animating"), e.classList.remove("is-opened"), e.style.maxHeight = "0px", e.style.overflow = "hidden";
109
- let t = G.value;
109
+ let t = K.value;
110
110
  t && (t.classList.remove("is-animating"), t.classList.remove("is-opened"));
111
111
  }
112
112
  async function $(e) {
113
- e ? (await d(), V.value = !0, Z()) : Q(), z.value = !1;
113
+ e ? (await d(), H.value = !0, Z()) : Q(), B.value = !1;
114
114
  }
115
- async function re() {
116
- let e = U.value;
115
+ async function ie() {
116
+ let e = W.value;
117
117
  if (!e) return;
118
- let t = G.value;
118
+ let t = K.value;
119
119
  await d(), e.classList.remove("is-opened"), e.classList.add("is-animating"), t && (t.classList.add("is-animating"), t.classList.remove("is-opened")), e.style.overflow = "hidden", e.style.maxHeight = "0px", e.offsetHeight, e.style.maxHeight = e.scrollHeight + "px";
120
120
  let n = () => {
121
- e.removeEventListener("transitionend", n), I.value && (J(), e.style.maxHeight = "", e.style.overflow = "", e.classList.remove("is-animating"), e.classList.add("is-opened"), t && (t.classList.remove("is-animating"), t.classList.add("is-opened")), z.value = !1);
121
+ e.removeEventListener("transitionend", n), L.value && (Y(), e.style.maxHeight = "", e.style.overflow = "", e.classList.remove("is-animating"), e.classList.add("is-opened"), t && (t.classList.remove("is-animating"), t.classList.add("is-opened")), B.value = !1);
122
122
  };
123
123
  e.addEventListener("transitionend", n);
124
124
  }
125
- function ie() {
126
- let e = U.value;
125
+ function ae() {
126
+ let e = W.value;
127
127
  if (!e) return;
128
- let t = G.value;
129
- z.value = !0, e.classList.add("is-animating"), e.classList.remove("is-opened"), t && (t.classList.add("is-animating"), t.classList.remove("is-opened")), (e.style.maxHeight === "" || e.style.maxHeight === "none") && (e.style.maxHeight = e.scrollHeight + "px", e.offsetHeight), e.style.overflow = "hidden", e.style.maxHeight = "0px";
128
+ let t = K.value;
129
+ B.value = !0, e.classList.add("is-animating"), e.classList.remove("is-opened"), t && (t.classList.add("is-animating"), t.classList.remove("is-opened")), (e.style.maxHeight === "" || e.style.maxHeight === "none") && (e.style.maxHeight = e.scrollHeight + "px", e.offsetHeight), e.style.overflow = "hidden", e.style.maxHeight = "0px";
130
130
  let n = () => {
131
- e.removeEventListener("transitionend", n), !I.value && (J(), e.classList.remove("is-animating"), t && t.classList.remove("is-animating"), z.value = !1);
131
+ e.removeEventListener("transitionend", n), !L.value && (Y(), e.classList.remove("is-animating"), t && t.classList.remove("is-animating"), B.value = !1);
132
132
  };
133
133
  e.addEventListener("transitionend", n);
134
134
  }
135
- return m(() => {
136
- let e = U.value;
135
+ return p(() => {
136
+ let e = W.value;
137
137
  if (!e) return;
138
- e.style.willChange = "max-height", k.noAnimation ? $(I.value) : I.value ? Z() : Q();
139
- let t = W.value;
140
- !k.noAnimation && "ResizeObserver" in window && t && (K = new ResizeObserver(() => {
141
- X();
142
- }), K.observe(t));
143
- }), p(() => {
144
- J(), K &&= (K.disconnect(), null);
145
- }), b(I, (e) => {
138
+ e.style.willChange = "max-height", k.noAnimation ? $(L.value) : L.value ? Z() : Q();
139
+ let t = G.value;
140
+ !k.noAnimation && "ResizeObserver" in window && t && (q = new ResizeObserver(() => {
141
+ re();
142
+ }), q.observe(t));
143
+ }), te(() => {
144
+ Y(), q &&= (q.disconnect(), null);
145
+ }), b(L, (e) => {
146
146
  if (k.noAnimation) {
147
147
  $(e);
148
148
  return;
149
149
  }
150
- e ? re() : ie();
151
- }), (e, t) => (h(), o("div", u({
150
+ e ? ie() : ae();
151
+ }), (e, t) => (m(), o("div", u({
152
152
  class: "s-collapsible-panel",
153
153
  ref_key: "rootEl",
154
- ref: G,
154
+ ref: K,
155
155
  "data-density": l.density,
156
156
  "data-surface": l.surface,
157
157
  "data-content-padding": l.contentPadding
158
- }, v(M).bindings()), [s("div", w, [s("div", T, [c(n, {
159
- id: v(L),
158
+ }, _(M).bindings()), [s("div", w, [s("div", T, [c(n, {
159
+ id: _(R),
160
160
  appearance: l.headerVariant === "minimal" ? "ghost" : "soft",
161
161
  severity: "secondary",
162
162
  shape: "row",
163
163
  size: N.value,
164
+ density: P.value,
164
165
  width: "full",
165
166
  "content-align": "between",
166
167
  disabled: l.disabled,
167
168
  disclosure: {
168
- expanded: v(I),
169
- controls: v(R)
169
+ expanded: _(L),
170
+ controls: _(z)
170
171
  },
171
- onClick: H
172
+ onClick: U
172
173
  }, {
173
174
  default: x(() => [c(r, {
174
175
  title: l.summary,
@@ -192,22 +193,23 @@ var C = [
192
193
  "id",
193
194
  "appearance",
194
195
  "size",
196
+ "density",
195
197
  "disabled",
196
198
  "disclosure"
197
- ])]), j.value ? (h(), o("div", E, [_(e.$slots, "actions", {}, void 0, !0)])) : a("", !0)]), S(s("div", {
198
- id: v(R),
199
- "aria-labelledby": v(L),
199
+ ])]), j.value ? (m(), o("div", E, [g(e.$slots, "actions", {}, void 0, !0)])) : a("", !0)]), S(s("div", {
200
+ id: _(z),
201
+ "aria-labelledby": _(R),
200
202
  role: "region",
201
203
  ref_key: "contentWrapEl",
202
- ref: U,
204
+ ref: W,
203
205
  class: f(["s-collapsible-panel-content w-full min-w-0", [{ "min-h-0 flex flex-col grow overflow-y-auto overflow-x-hidden": l.fill }, { "no-transition": l.noAnimation }]]),
204
- "data-open": v(I),
206
+ "data-open": _(L),
205
207
  style: ee({ ...l.noAnimation ? { transition: "none" } : {} })
206
208
  }, [s("div", {
207
209
  ref_key: "contentInnerEl",
208
- ref: W,
210
+ ref: G,
209
211
  class: "s-collapsible-panel-inner"
210
- }, [V.value ? _(e.$slots, "default", {}, void 0, !0, 0) : a("", !0)], 512)], 14, D), [[te, B.value]])], 16, C));
212
+ }, [H.value ? g(e.$slots, "default", {}, void 0, !0, 0) : a("", !0)], 512)], 14, D), [[y, V.value]])], 16, C));
211
213
  }
212
214
  });
213
215
  //#endregion
@@ -1,8 +1,8 @@
1
- import "../../../../assets/src/components/shared/containers/SModal.css_vue_type_style_index_0_src_23373daf_scoped_23373daf_lang.css";
1
+ import "../../../../assets/src/components/shared/containers/SModal.css_vue_type_style_index_0_src_0dc51b74_scoped_0dc51b74_lang.css";
2
2
  import e from "../../../../_virtual/_plugin-vue_export-helper.js";
3
3
  import t from "./SModal.vue_vue_type_script_setup_true_lang.js";
4
4
  /* empty css */
5
5
  //#region src/components/shared/containers/SModal.vue
6
- var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-23373daf"]]);
6
+ var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-0dc51b74"]]);
7
7
  //#endregion
8
8
  export { n as default };
@@ -3,9 +3,9 @@ import { useUiKitLocale as t } from "../../../composables/useUiKitLocale.js";
3
3
  import { useOwnedAttrs as n } from "../../../internal/ownedAttrs.js";
4
4
  import { validateDialogSurfaceHeadingLevel as r } from "../_internal/dialogSurface.js";
5
5
  import i from "../_internal/SDialogSurface.vue.js";
6
- import { Teleport as a, Transition as o, computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createSlots as f, createVNode as p, defineComponent as m, mergeProps as h, normalizeClass as g, normalizeStyle as _, openBlock as v, renderSlot as y, toRef as b, unref as x, withCtx as S } from "vue";
6
+ import { Teleport as a, Transition as o, computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createSlots as f, createVNode as p, defineComponent as m, mergeProps as h, normalizeClass as g, normalizeStyle as _, onErrorCaptured as v, openBlock as y, renderSlot as b, toRef as x, unref as S, useId as C, withCtx as w } from "vue";
7
7
  //#region src/components/shared/containers/SModal.vue?vue&type=script&setup=true&lang.ts
8
- var C = /*@__PURE__*/ m({
8
+ var T = /*@__PURE__*/ m({
9
9
  inheritAttrs: !1,
10
10
  __name: "SModal",
11
11
  props: {
@@ -27,71 +27,77 @@ var C = /*@__PURE__*/ m({
27
27
  headingLevel: { default: 2 }
28
28
  },
29
29
  emits: ["update:open", "opened"],
30
- setup(m, { emit: C }) {
31
- let w = m, { t: T } = t(), E = C;
32
- function D() {
33
- E("update:open", !1);
30
+ setup(m, { emit: T }) {
31
+ let E = m, { t: D } = t(), O = `s-modal-${C()}`, k = T;
32
+ function A() {
33
+ k("update:open", !1);
34
34
  }
35
- let O = s(() => w.fullScreen || w.layout === "mobile-fullscreen"), k = n({
35
+ let j = s(() => E.fullScreen || E.layout === "mobile-fullscreen"), M = n({
36
36
  component: "SModal",
37
37
  owner: "modal dialog surface"
38
- }), A = s(() => w.ariaLabel ?? T("dialog.modal")), j = s(() => r("SModal", w.headingLevel));
39
- j.value;
40
- let M = s(() => ({
38
+ }), N = s(() => E.ariaLabel ?? D("dialog.modal")), P = s(() => r("SModal", E.headingLevel));
39
+ P.value;
40
+ let F = s(() => ({
41
41
  kind: "modal",
42
- size: w.size,
43
- fullscreen: O.value,
44
- surface: w.surface,
45
- scrollBehavior: w.scrollBehavior
46
- })), { setPanelElement: N, backdropStyle: P, surfaceStyle: F } = e({
47
- open: b(w, "open"),
48
- closable: b(w, "closable"),
49
- requestClose: D,
50
- opened: () => E("opened")
51
- });
52
- return (e, t) => (v(), c(a, { to: "body" }, [p(o, { name: "s-modal-backdrop" }, {
53
- default: S(() => [m.open ? (v(), u("div", {
42
+ size: E.size,
43
+ fullscreen: j.value,
44
+ surface: E.surface,
45
+ scrollBehavior: E.scrollBehavior
46
+ })), { setPanelElement: I, backdropStyle: L, surfaceStyle: R, dispose: z } = e({
47
+ open: x(E, "open"),
48
+ closable: x(E, "closable"),
49
+ requestClose: A,
50
+ opened: () => k("opened")
51
+ }), B = () => {
52
+ if (typeof document < "u") for (let e of document.querySelectorAll("[data-s-modal-owner]")) e.dataset.sModalOwner === O && e.remove();
53
+ };
54
+ return v(() => {
55
+ z(), B(), queueMicrotask(B);
56
+ }), (e, t) => (y(), c(a, { to: "body" }, [p(o, { name: "s-modal-backdrop" }, {
57
+ default: w(() => [m.open ? (y(), u("div", {
54
58
  key: 0,
55
59
  class: "s-modal-backdrop",
56
- style: _(x(P)),
60
+ "data-s-modal-owner": O,
61
+ style: _(S(L)),
57
62
  "aria-hidden": "true"
58
63
  }, null, 4)) : l("", !0)]),
59
64
  _: 1
60
65
  }), p(o, { name: "s-modal-panel" }, {
61
- default: S(() => [m.open ? (v(), u("div", {
66
+ default: w(() => [m.open ? (y(), u("div", {
62
67
  key: 0,
63
68
  class: "s-modal-container",
64
- style: _(x(F))
65
- }, [d("div", { class: g(["s-modal-panel-container", { "s-modal-panel-container--fullscreen": O.value }]) }, [p(i, h(x(k).bindings(), {
66
- presentation: M.value,
69
+ "data-s-modal-owner": O,
70
+ style: _(S(R))
71
+ }, [d("div", { class: g(["s-modal-panel-container", { "s-modal-panel-container--fullscreen": j.value }]) }, [p(i, h(S(M).bindings(), {
72
+ presentation: F.value,
67
73
  title: m.title,
68
- "accessible-name": A.value,
69
- "heading-level": j.value,
74
+ "accessible-name": N.value,
75
+ "heading-level": P.value,
70
76
  closable: m.closable,
71
- "set-surface-element": x(N),
72
- onRequestClose: D
77
+ "set-surface-element": S(I),
78
+ onRequestClose: A
73
79
  }), f({
74
- default: S(() => [y(e.$slots, "default", {}, void 0, !0)]),
80
+ default: w(() => [b(e.$slots, "default", {}, void 0, !0)]),
75
81
  _: 2
76
82
  }, [
77
83
  e.$slots.header ? {
78
84
  name: "header",
79
- fn: S(() => [y(e.$slots, "header", {}, void 0, !0)]),
85
+ fn: w(() => [b(e.$slots, "header", {}, void 0, !0)]),
80
86
  key: "0"
81
87
  } : void 0,
82
88
  e.$slots.footer ? {
83
89
  name: "footer",
84
- fn: S(({ close: t }) => [y(e.$slots, "footer", { close: t }, void 0, !0)]),
90
+ fn: w(({ close: t }) => [b(e.$slots, "footer", { close: t }, void 0, !0)]),
85
91
  key: "1"
86
92
  } : void 0,
87
93
  e.$slots["footer-start"] ? {
88
94
  name: "footer-start",
89
- fn: S(({ close: t }) => [y(e.$slots, "footer-start", { close: t }, void 0, !0)]),
95
+ fn: w(({ close: t }) => [b(e.$slots, "footer-start", { close: t }, void 0, !0)]),
90
96
  key: "2"
91
97
  } : void 0,
92
98
  e.$slots["footer-end"] ? {
93
99
  name: "footer-end",
94
- fn: S(({ close: t }) => [y(e.$slots, "footer-end", { close: t }, void 0, !0)]),
100
+ fn: w(({ close: t }) => [b(e.$slots, "footer-end", { close: t }, void 0, !0)]),
95
101
  key: "3"
96
102
  } : void 0
97
103
  ]), 1040, [
@@ -107,4 +113,4 @@ var C = /*@__PURE__*/ m({
107
113
  }
108
114
  });
109
115
  //#endregion
110
- export { C as default };
116
+ export { T as default };
@@ -1,11 +1,16 @@
1
1
  import { VNodeChild, VNodeRef } from 'vue';
2
2
  import { OwnedAttributeBindings } from '../../../internal/ownedAttrs';
3
3
  import { SMenuActivationEvent, SMenuEntry, SMenuSelectableEntry } from './menu';
4
- type __VLS_Props = {
4
+ export type SDropdownMenuPlacement = 'auto' | 'bottom' | 'top';
5
+ export interface Props {
5
6
  items: readonly SMenuEntry[];
6
7
  align?: 'left' | 'right';
7
8
  menuLabel?: string;
8
- };
9
+ open?: boolean;
10
+ defaultOpen?: boolean;
11
+ placement?: SDropdownMenuPlacement;
12
+ closeOnSelect?: boolean;
13
+ }
9
14
  export type SDropdownMenuTriggerAttrs = OwnedAttributeBindings<'SDropdownMenu'> & {
10
15
  readonly ref: VNodeRef;
11
16
  readonly 'aria-haspopup': 'menu';
@@ -20,13 +25,19 @@ type __VLS_Slots = {
20
25
  triggerAttrs: SDropdownMenuTriggerAttrs;
21
26
  }) => VNodeChild;
22
27
  };
23
- declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
28
+ declare const __VLS_base: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
24
29
  select: (entry: SMenuSelectableEntry, event: SMenuActivationEvent) => any;
25
- }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
30
+ "update:open": (value: boolean) => any;
31
+ }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
26
32
  onSelect?: ((entry: SMenuSelectableEntry, event: SMenuActivationEvent) => any) | undefined;
33
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
27
34
  }>, {
35
+ open: boolean;
28
36
  align: "left" | "right";
37
+ placement: SDropdownMenuPlacement;
29
38
  menuLabel: string;
39
+ defaultOpen: boolean;
40
+ closeOnSelect: boolean;
30
41
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
31
42
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
32
43
  declare const _default: typeof __VLS_export;
@@ -1,8 +1,8 @@
1
- import "../../../../assets/src/components/shared/controls/SDropdownMenu.css_vue_type_style_index_0_src_b854a89e_scoped_b854a89e_lang.css";
1
+ import "../../../../assets/src/components/shared/controls/SDropdownMenu.css_vue_type_style_index_0_src_1ccb9efc_scoped_1ccb9efc_lang.css";
2
2
  import e from "../../../../_virtual/_plugin-vue_export-helper.js";
3
3
  import t from "./SDropdownMenu.vue_vue_type_script_setup_true_lang.js";
4
4
  /* empty css */
5
5
  //#region src/components/shared/controls/SDropdownMenu.vue
6
- var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-b854a89e"]]);
6
+ var n = /*#__PURE__*/ e(t, [["__scopeId", "data-v-1ccb9efc"]]);
7
7
  //#endregion
8
8
  export { n as default };
@@ -1,11 +1,12 @@
1
1
  import { useUiKitLocale as e } from "../../../composables/useUiKitLocale.js";
2
2
  import { useOwnedAttrs as t } from "../../../internal/ownedAttrs.js";
3
- import n from "./SButton.vue.js";
4
- import { useMenuLayer as r } from "../../../internal/useMenuLayer.js";
5
- import i from "../_internal/SMenuLayer.vue.js";
6
- import { validateSMenuEntries as a } from "./menu.js";
7
- import o from "./SMenuSurface.vue.js";
8
- import { Teleport as s, computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createVNode as f, defineComponent as p, mergeProps as m, nextTick as h, onMounted as g, openBlock as _, ref as v, renderSlot as y, unref as b, useId as x, useSlots as S, watchEffect as C, withCtx as w } from "vue";
3
+ import { validateBoolean as n, validateExactString as r } from "../../../internal/runtimeContract.js";
4
+ import i from "./SButton.vue.js";
5
+ import { useMenuLayer as a } from "../../../internal/useMenuLayer.js";
6
+ import o from "../_internal/SMenuLayer.vue.js";
7
+ import { validateSMenuEntries as ee } from "./menu.js";
8
+ import s from "./SMenuSurface.vue.js";
9
+ import { Teleport as c, computed as l, createBlock as u, createCommentVNode as d, createElementBlock as f, createVNode as te, defineComponent as p, mergeProps as m, nextTick as h, onMounted as ne, openBlock as g, ref as _, renderSlot as v, unref as y, useId as b, useSlots as x, watch as S, watchEffect as C, withCtx as w } from "vue";
9
10
  //#region src/components/shared/controls/SDropdownMenu.vue?vue&type=script&setup=true&lang.ts
10
11
  var T = { class: "s-dropdown-menu" }, E = /*@__PURE__*/ p({
11
12
  inheritAttrs: !1,
@@ -13,14 +14,27 @@ var T = { class: "s-dropdown-menu" }, E = /*@__PURE__*/ p({
13
14
  props: {
14
15
  items: {},
15
16
  align: { default: "right" },
16
- menuLabel: { default: void 0 }
17
+ menuLabel: { default: void 0 },
18
+ open: {
19
+ type: Boolean,
20
+ default: void 0
21
+ },
22
+ defaultOpen: {
23
+ type: Boolean,
24
+ default: !1
25
+ },
26
+ placement: { default: "auto" },
27
+ closeOnSelect: {
28
+ type: Boolean,
29
+ default: !0
30
+ }
17
31
  },
18
- emits: ["select"],
32
+ emits: ["select", "update:open"],
19
33
  setup(p, { emit: E }) {
20
- let D = p, { t: O } = e(), k = c(() => D.menuLabel ?? O("dialog.moreActions")), A = E, j = S(), M = t({
34
+ let D = p, { t: re } = e(), O = l(() => D.menuLabel ?? re("dialog.moreActions")), k = E, A = x(), j = t({
21
35
  component: "SDropdownMenu",
22
36
  owner: "menu trigger"
23
- }), N = v(null), P = v(null), F = null, I = c(() => N.value?.getElement() ?? null), { isOpen: L, position: R, zIndex: z, close: B, closeForTab: V, open: H, toggle: U } = r(I), W = `s-dropdown-menu-${x()}`, G = v("first"), K = !!j.default;
37
+ }), M = _(null), N = _(null), P = null, F = l(() => M.value?.getElement() ?? null), { isOpen: I, position: L, zIndex: R, close: z, closeForTab: B, open: V } = a(F, { onRequestDismiss: $ }), H = `s-dropdown-menu-${b()}`, U = _("first"), W = !!A.default, G = l(() => D.open !== void 0), K = l(() => G.value ? D.open === !0 : I.value);
24
38
  function q(e) {
25
39
  if (e === null) return null;
26
40
  if (e instanceof HTMLElement) return e;
@@ -31,97 +45,119 @@ var T = { class: "s-dropdown-menu" }, E = /*@__PURE__*/ p({
31
45
  return n;
32
46
  }
33
47
  let J = (e) => {
34
- if (e !== null && F !== null && e !== F) throw Error("SDropdownMenu: trigger binding must belong to exactly one UI-kit leaf");
35
- F = e;
48
+ if (e !== null && P !== null && e !== P) throw Error("SDropdownMenu: trigger binding must belong to exactly one UI-kit leaf");
49
+ P = e;
36
50
  }, Y = () => {
37
- let e = M.bindings();
51
+ let e = j.bindings();
38
52
  if (Object.prototype.hasOwnProperty.call(e, "onClick")) throw Error("SDropdownMenu: @click belongs to the typed triggerAttrs activation contract");
39
53
  return {
40
54
  ...e,
41
55
  ref: J,
42
56
  "aria-haspopup": "menu",
43
- "aria-expanded": L.value,
44
- "aria-controls": W,
45
- onClick: Z,
46
- onKeydown: Q
57
+ "aria-expanded": K.value,
58
+ "aria-controls": H,
59
+ onClick: ae,
60
+ onKeydown: oe
47
61
  };
48
62
  };
49
63
  function X(e) {
50
- let t = q(F);
64
+ let t = q(P);
51
65
  if (!t) throw Error("SDropdownMenu: expected exactly one trigger, received 0");
52
66
  if (e?.currentTarget instanceof HTMLElement && e.currentTarget !== t) throw Error("SDropdownMenu: activation target does not match the registered trigger");
53
67
  return t;
54
68
  }
55
- g(() => {
69
+ ne(() => {
56
70
  let e = X();
57
- if (e.getAttribute("aria-haspopup") !== "menu" || e.getAttribute("aria-controls") !== W) throw Error("SDropdownMenu: expected exactly one trigger, received 0");
71
+ if (e.getAttribute("aria-haspopup") !== "menu" || e.getAttribute("aria-controls") !== H) throw Error("SDropdownMenu: expected exactly one trigger, received 0");
72
+ (G.value && D.open || !G.value && D.defaultOpen) && Z();
58
73
  });
59
- function Z(e) {
60
- let t = X(e);
61
- G.value = "first", U({
62
- type: "element",
63
- element: t,
64
- align: D.align
65
- }, t);
74
+ function ie(e) {
75
+ let t = X(e), n = D.placement === "auto" ? void 0 : D.placement;
76
+ return {
77
+ anchor: {
78
+ type: "element",
79
+ element: t,
80
+ align: D.align,
81
+ ...n === void 0 ? {} : { placement: n }
82
+ },
83
+ trigger: t
84
+ };
85
+ }
86
+ async function Z(e) {
87
+ if (I.value) return;
88
+ let { anchor: t, trigger: n } = ie(e);
89
+ await V(t, n);
90
+ }
91
+ function Q(e) {
92
+ K.value || (k("update:open", !0), G.value || Z(e));
93
+ }
94
+ function $(e) {
95
+ (K.value || I.value) && (k("update:open", !1), G.value || z(e));
96
+ }
97
+ function ae(e) {
98
+ K.value ? $("trigger") : (U.value = "first", Q(e));
99
+ }
100
+ async function oe(e) {
101
+ (e.key === "ArrowDown" || e.key === "ArrowUp") && (e.preventDefault(), e.stopPropagation(), U.value = e.key === "ArrowUp" ? "last" : "first", K.value || Q(e), await h(), await h(), I.value && (U.value === "last" ? N.value?.focusLast() : N.value?.focusFirst()));
66
102
  }
67
- async function Q(e) {
68
- if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
69
- e.preventDefault(), e.stopPropagation();
70
- let t = X(e);
71
- G.value = e.key === "ArrowUp" ? "last" : "first", L.value || await H({
72
- type: "element",
73
- element: t,
74
- align: D.align
75
- }, t), await h(), G.value === "last" ? P.value?.focusLast() : P.value?.focusFirst();
103
+ function se(e, t) {
104
+ e.disabled || (k("select", e, t), D.closeOnSelect && $("selection"));
76
105
  }
77
- function $(e, t) {
78
- e.disabled || (B("selection"), A("select", e, t));
106
+ function ce(e) {
107
+ B(e);
79
108
  }
80
- return C(() => {
81
- if (a(D.items), !k.value.trim()) throw TypeError("SDropdownMenu: menuLabel must be a non-empty string");
82
- if (D.align !== "left" && D.align !== "right") throw TypeError("SDropdownMenu: align must be 'left' or 'right'");
83
- }), (e, t) => (_(), d("div", T, [b(K) ? y(e.$slots, "default", { triggerAttrs: Y() }, void 0, !0, 0) : (_(), l(n, m({ key: 1 }, Y(), {
109
+ return S(() => D.open, (e) => {
110
+ e !== void 0 && (e && !I.value ? Z() : !e && I.value && z("programmatic"));
111
+ }), S(() => [D.align, D.placement], () => {
112
+ I.value && (z("programmatic"), Z());
113
+ }), C(() => {
114
+ if (ee(D.items), !O.value.trim()) throw TypeError("SDropdownMenu: menuLabel must be a non-empty string");
115
+ r("SDropdownMenu", "align", D.align, ["left", "right"]), r("SDropdownMenu", "placement", D.placement, [
116
+ "auto",
117
+ "bottom",
118
+ "top"
119
+ ]), n("SDropdownMenu", "defaultOpen", D.defaultOpen), n("SDropdownMenu", "closeOnSelect", D.closeOnSelect), D.open !== void 0 && n("SDropdownMenu", "open", D.open);
120
+ }), (e, t) => (g(), f("div", T, [y(W) ? v(e.$slots, "default", { triggerAttrs: Y() }, void 0, !0, 0) : (g(), u(i, m({ key: 1 }, Y(), {
84
121
  label: "Опции",
85
122
  disclosure: {
86
- expanded: b(L),
87
- controls: W
123
+ expanded: K.value,
124
+ controls: H
88
125
  },
89
126
  severity: "secondary"
90
- }), null, 16, ["disclosure"])), (_(), l(s, { to: "body" }, [b(L) ? (_(), l(i, {
127
+ }), null, 16, ["disclosure"])), (g(), u(c, { to: "body" }, [y(I) ? (g(), u(o, {
91
128
  key: 0,
92
129
  ref_key: "layerRef",
93
- ref: N,
130
+ ref: M,
94
131
  kind: "dropdown",
95
- "landmark-label": k.value,
96
- position: b(R),
97
- "z-index": b(z)
132
+ "landmark-label": O.value,
133
+ position: y(L),
134
+ "z-index": y(R)
98
135
  }, {
99
- default: w(() => [f(o, {
136
+ default: w(() => [te(s, {
100
137
  ref_key: "menuSurfaceRef",
101
- ref: P,
102
- id: W,
103
- label: k.value,
138
+ ref: N,
139
+ id: H,
140
+ label: O.value,
104
141
  density: "compact",
105
142
  autofocus: "",
106
- "initial-focus": G.value,
143
+ "initial-focus": U.value,
107
144
  items: p.items,
108
- onDismissTree: t[0] ||= (e) => b(B)("outside"),
109
- onEscape: t[1] ||= (e) => b(B)("escape"),
110
- onFocusExit: t[2] ||= (e) => b(B)("outside"),
111
- onSelect: $,
112
- onTab: b(V)
145
+ onDismissTree: t[0] ||= (e) => $("outside"),
146
+ onEscape: t[1] ||= (e) => $("escape"),
147
+ onFocusExit: t[2] ||= (e) => $("outside"),
148
+ onSelect: se,
149
+ onTab: ce
113
150
  }, null, 8, [
114
151
  "label",
115
152
  "initial-focus",
116
- "items",
117
- "onTab"
153
+ "items"
118
154
  ])]),
119
155
  _: 1
120
156
  }, 8, [
121
157
  "landmark-label",
122
158
  "position",
123
159
  "z-index"
124
- ])) : u("", !0)]))]));
160
+ ])) : d("", !0)]))]));
125
161
  }
126
162
  });
127
163
  //#endregion