@illinois-grad/grad-vue 3.0.6 → 3.0.7

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.
@@ -1065,6 +1065,15 @@
1065
1065
  "optional": true,
1066
1066
  "description": "Sidebar channel key for custom elements mode",
1067
1067
  "default": "\"default\""
1068
+ },
1069
+ {
1070
+ "kind": "field",
1071
+ "name": "mediaQuery",
1072
+ "type": {
1073
+ "text": "string"
1074
+ },
1075
+ "optional": true,
1076
+ "description": "Sidebar media query for custom elements mode"
1068
1077
  }
1069
1078
  ],
1070
1079
  "events": [
@@ -1852,6 +1861,15 @@
1852
1861
  "optional": true,
1853
1862
  "description": "Sidebar channel key for custom elements mode",
1854
1863
  "default": "\"default\""
1864
+ },
1865
+ {
1866
+ "kind": "field",
1867
+ "name": "mediaQuery",
1868
+ "type": {
1869
+ "text": "string"
1870
+ },
1871
+ "optional": true,
1872
+ "description": "Sidebar media query for custom elements mode"
1855
1873
  }
1856
1874
  ],
1857
1875
  "events": []
@@ -26,7 +26,7 @@
26
26
  * > [!NOTE]
27
27
  * > This button hides itself automatically according to the useSidebar media query.
28
28
  * > In web components mode, use the `sidebar-key` prop to pair this menu with a
29
- * > matching GSidebar instance.
29
+ * > matching GSidebar instance and `media-query` to set the collapsible breakpoint.
30
30
  */
31
31
  declare const _default: typeof __VLS_export;
32
32
  export default _default;
@@ -41,6 +41,11 @@ declare const __VLS_export: import("vue").DefineComponent<{
41
41
  * @demo
42
42
  */
43
43
  sidebarKey?: string;
44
+ /**
45
+ * Sidebar media query for custom elements mode
46
+ * @demo
47
+ */
48
+ mediaQuery?: string;
44
49
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
45
50
  toggle: () => any;
46
51
  }, string, import("vue").PublicProps, Readonly<{
@@ -54,6 +59,11 @@ declare const __VLS_export: import("vue").DefineComponent<{
54
59
  * @demo
55
60
  */
56
61
  sidebarKey?: string;
62
+ /**
63
+ * Sidebar media query for custom elements mode
64
+ * @demo
65
+ */
66
+ mediaQuery?: string;
57
67
  }> & Readonly<{
58
68
  onToggle?: (() => any) | undefined;
59
69
  }>, {
@@ -13,7 +13,8 @@
13
13
  * for details.
14
14
  *
15
15
  * In web components mode, use the `sidebar-key` prop to pair this sidebar
16
- * with a matching GHamburgerMenu instance.
16
+ * with a matching GHamburgerMenu instance and `media-query` to set the
17
+ * collapsible breakpoint.
17
18
  */
18
19
  declare const _default: typeof __VLS_export;
19
20
  export default _default;
@@ -53,6 +54,11 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
53
54
  * @demo
54
55
  */
55
56
  sidebarKey?: string;
57
+ /**
58
+ * Sidebar media query for custom elements mode
59
+ * @demo
60
+ */
61
+ mediaQuery?: string;
56
62
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
57
63
  /**
58
64
  * Custom background color
@@ -89,6 +95,11 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
89
95
  * @demo
90
96
  */
91
97
  sidebarKey?: string;
98
+ /**
99
+ * Sidebar media query for custom elements mode
100
+ * @demo
101
+ */
102
+ mediaQuery?: string;
92
103
  }> & Readonly<{}>, {
93
104
  width: string;
94
105
  theme: "light" | "dark";
@@ -2,8 +2,9 @@ import { Ref } from "vue";
2
2
  type SidebarChannel = {
3
3
  id: string;
4
4
  open: Ref<boolean>;
5
+ breakpoint: Ref<string>;
5
6
  isCollapsible: Ref<boolean>;
6
7
  toggle: () => void;
7
8
  };
8
- export declare function useWebComponentSidebar(key?: string, breakpoint?: Ref<string> | string): SidebarChannel;
9
+ export declare function useWebComponentSidebar(key?: string, breakpoint?: Ref<string | undefined> | string): SidebarChannel;
9
10
  export {};
@@ -119,42 +119,66 @@ var me = { class: "g-btn--icon" }, he = { class: "g-btn--label" }, Q = /* @__PUR
119
119
  }
120
120
  return null;
121
121
  }
122
- let d = null;
123
- function f() {
122
+ let d = null, f = null, p = null, m = !1;
123
+ function v() {
124
124
  l && d && (l.value = d.scrollTop);
125
125
  }
126
+ function y() {
127
+ f &&= (f.disconnect(), null), p &&= (p.disconnect(), null);
128
+ }
129
+ function b() {
130
+ !l || !d || m || l.value <= 0 || (d.scrollTop = l.value, m = d.scrollTop > 0, m && y());
131
+ }
132
+ function x(e) {
133
+ if (typeof MutationObserver > "u") return;
134
+ p = new MutationObserver(() => {
135
+ b();
136
+ });
137
+ let t = e;
138
+ for (; t;) p.observe(t, {
139
+ attributes: !0,
140
+ attributeFilter: [
141
+ "class",
142
+ "style",
143
+ "hidden",
144
+ "open"
145
+ ]
146
+ }), t = t.parentElement;
147
+ }
126
148
  S(() => {
127
- !l || !i.value || (d = u(i.value), d && (l.value > 0 && g(() => {
128
- d && (d.scrollTop = l.value);
129
- }), d.addEventListener("scroll", f)));
149
+ !l || !i.value || (d = u(i.value), d && (g(() => {
150
+ b();
151
+ }), typeof ResizeObserver < "u" && (f = new ResizeObserver(() => {
152
+ b();
153
+ }), f.observe(i.value), f.observe(d)), x(i.value), d.addEventListener("scroll", v)));
130
154
  }), C(() => {
131
- d &&= (d.removeEventListener("scroll", f), null);
155
+ y(), d &&= (d.removeEventListener("scroll", v), null), m = !1;
132
156
  });
133
- let p = D(/* @__PURE__ */ new Map());
134
- E("g-tree-menu-expandable-items", p);
135
- let m = O({
157
+ let w = D(/* @__PURE__ */ new Map());
158
+ E("g-tree-menu-expandable-items", w);
159
+ let k = O({
136
160
  expanded: !0,
137
161
  version: 0
138
162
  });
139
- E("g-tree-menu-expand-all-signal", m);
140
- let v = r(() => {
141
- if (p.size === 0) return !1;
142
- for (let e of p.values()) if (!e) return !1;
163
+ E("g-tree-menu-expand-all-signal", k);
164
+ let j = r(() => {
165
+ if (w.size === 0) return !1;
166
+ for (let e of w.values()) if (!e) return !1;
143
167
  return !0;
144
168
  });
145
- function y() {
146
- m.value = {
147
- expanded: !v.value,
148
- version: m.value.version + 1
169
+ function M() {
170
+ k.value = {
171
+ expanded: !j.value,
172
+ version: k.value.version + 1
149
173
  };
150
174
  }
151
- function b(e) {
175
+ function N(e) {
152
176
  return e.querySelector("a, button, [tabindex='0']") || e;
153
177
  }
154
- function x(e) {
178
+ function F(e) {
155
179
  return Array.from(e.querySelectorAll("[data-tree-primary]"));
156
180
  }
157
- function w(e) {
181
+ function I(e) {
158
182
  let t = e.currentTarget, n = document.activeElement;
159
183
  if (!t.contains(n) || ![
160
184
  "ArrowUp",
@@ -164,16 +188,16 @@ var me = { class: "g-btn--icon" }, he = { class: "g-btn--label" }, Q = /* @__PUR
164
188
  "Home",
165
189
  "End"
166
190
  ].includes(e.key)) return;
167
- let r = n.closest(".g-tree-menu__item"), i = r?.querySelector("[data-tree-primary]") ?? null, a = x(t), o = i ? a.indexOf(i) : -1;
191
+ let r = n.closest(".g-tree-menu__item"), i = r?.querySelector("[data-tree-primary]") ?? null, a = F(t), o = i ? a.indexOf(i) : -1;
168
192
  switch (e.key) {
169
193
  case "ArrowDown": {
170
194
  let e = a[o + 1];
171
- e && b(e).focus();
195
+ e && N(e).focus();
172
196
  break;
173
197
  }
174
198
  case "ArrowUp": {
175
199
  let e = a[o - 1];
176
- e && b(e).focus();
200
+ e && N(e).focus();
177
201
  break;
178
202
  }
179
203
  case "ArrowRight":
@@ -183,27 +207,27 @@ var me = { class: "g-btn--icon" }, he = { class: "g-btn--label" }, Q = /* @__PUR
183
207
  e && e.click();
184
208
  } else {
185
209
  let e = a[o + 1];
186
- e && b(e).focus();
210
+ e && N(e).focus();
187
211
  }
188
212
  break;
189
213
  case "ArrowLeft":
190
214
  if (!r) break;
191
215
  if (r.querySelector("[aria-expanded='true']") !== null) {
192
216
  let e = r.querySelector(".g-tree-menu__toggle-btn");
193
- e && e.click(), i && g(() => b(i).focus());
217
+ e && e.click(), i && g(() => N(i).focus());
194
218
  } else {
195
219
  let e = r.parentElement?.closest(".g-tree-menu__item");
196
220
  if (e) {
197
221
  let t = e.querySelector("[data-tree-primary]");
198
- t && b(t).focus();
222
+ t && N(t).focus();
199
223
  }
200
224
  }
201
225
  break;
202
226
  case "Home":
203
- a.length > 0 && b(a[0]).focus();
227
+ a.length > 0 && N(a[0]).focus();
204
228
  break;
205
229
  case "End":
206
- a.length > 0 && b(a[a.length - 1]).focus();
230
+ a.length > 0 && N(a[a.length - 1]).focus();
207
231
  break;
208
232
  }
209
233
  e.preventDefault();
@@ -214,7 +238,7 @@ var me = { class: "g-btn--icon" }, he = { class: "g-btn--label" }, Q = /* @__PUR
214
238
  }, {
215
239
  "aria-labelledby": e.heading ? R(n) : void 0,
216
240
  "aria-label": e.heading ? void 0 : "Tree Menu"
217
- }, { onKeydown: w }), [
241
+ }, { onKeydown: I }), [
218
242
  e.heading ? (T(), o("h2", {
219
243
  key: 0,
220
244
  id: R(n),
@@ -222,9 +246,9 @@ var me = { class: "g-btn--icon" }, he = { class: "g-btn--label" }, Q = /* @__PUR
222
246
  }, P(e.heading), 9, ge)) : a("", !0),
223
247
  s("div", _e, [i[1] ||= s("div", { class: "g-tree-menu__divider-line" }, null, -1), e.showExpandAll ? (T(), o("div", ve, [s("button", {
224
248
  class: "g-tree-menu__expand-all-btn",
225
- onClick: y
249
+ onClick: M
226
250
  }, [(T(), o("svg", {
227
- class: _(["g-tree-menu__expand-all-icon", { "g-tree-menu__expand-all-icon--collapse": v.value }]),
251
+ class: _(["g-tree-menu__expand-all-icon", { "g-tree-menu__expand-all-icon--collapse": j.value }]),
228
252
  role: "none",
229
253
  viewBox: "0 0 24 24",
230
254
  fill: "none",
@@ -232,7 +256,7 @@ var me = { class: "g-btn--icon" }, he = { class: "g-btn--label" }, Q = /* @__PUR
232
256
  "stroke-width": "2.5",
233
257
  "stroke-linecap": "round",
234
258
  "stroke-linejoin": "round"
235
- }, [...i[0] ||= [s("polyline", { points: "7 8 12 13 17 8" }, null, -1), s("polyline", { points: "7 13 12 18 17 13" }, null, -1)]], 2)), c(" " + P(v.value ? "Collapse all" : "Expand all"), 1)])])) : a("", !0)]),
259
+ }, [...i[0] ||= [s("polyline", { points: "7 8 12 13 17 8" }, null, -1), s("polyline", { points: "7 13 12 18 17 13" }, null, -1)]], 2)), c(" " + P(j.value ? "Collapse all" : "Expand all"), 1)])])) : a("", !0)]),
236
260
  s("div", ye, [A(r.$slots, "default")])
237
261
  ], 16));
238
262
  }
@@ -1769,40 +1793,43 @@ function cn() {
1769
1793
  let e = globalThis;
1770
1794
  return e.__GRAD_VUE_WC_SIDEBAR_CHANNELS__ ||= /* @__PURE__ */ new Map(), e.__GRAD_VUE_WC_SIDEBAR_CHANNELS__;
1771
1795
  }
1772
- function ln(e = "default", t = "(max-width: 800px)") {
1773
- let n = cn(), r = e || "default";
1796
+ function ln(e = "default", t) {
1797
+ let n = cn(), r = e || "default", i = typeof t == "string" ? t : t?.value, a = i && i.trim() ? i : "(max-width: 800px)";
1774
1798
  if (!n.has(r)) {
1775
- let e = sn(r);
1799
+ let e = sn(r), t = O(a);
1776
1800
  n.set(r, {
1777
1801
  id: `g-wc-sidebar-${e}`,
1778
1802
  open: O(!1),
1803
+ breakpoint: t,
1779
1804
  isCollapsible: se(t, { ssrWidth: 1e3 }),
1780
1805
  toggle: () => void 0
1781
1806
  });
1782
1807
  }
1783
- let i = n.get(r);
1784
- i.toggle = () => i.open.value = !i.open.value;
1785
- function a(e) {
1786
- if (!i.isCollapsible.value || !i.open.value) return;
1787
- let t = e.target, n = document.getElementById(`${i.id}-sidebar`);
1808
+ let o = n.get(r);
1809
+ o.toggle = () => o.open.value = !o.open.value, typeof t == "string" ? t.trim() && (o.breakpoint.value = t) : t && K(t, (e) => {
1810
+ e && e.trim() && (o.breakpoint.value = e);
1811
+ }, { immediate: !0 });
1812
+ function s(e) {
1813
+ if (!o.isCollapsible.value || !o.open.value) return;
1814
+ let t = e.target, n = document.getElementById(`${o.id}-sidebar`);
1788
1815
  n && (n.contains(t) || setTimeout(() => {
1789
- i.open.value = !1;
1816
+ o.open.value = !1;
1790
1817
  }, 5));
1791
1818
  }
1792
- function o(e) {
1793
- if (!i.isCollapsible.value || !i.open.value) return;
1794
- let t = e.target, n = document.getElementById(`${i.id}-sidebar`), r = document.getElementById(`${i.id}-hamburger`);
1819
+ function c(e) {
1820
+ if (!o.isCollapsible.value || !o.open.value) return;
1821
+ let t = e.target, n = document.getElementById(`${o.id}-sidebar`), r = document.getElementById(`${o.id}-hamburger`);
1795
1822
  n && (n.contains(t) || r?.contains(t) || setTimeout(() => {
1796
- i.open.value = !1;
1823
+ o.open.value = !1;
1797
1824
  }, 5));
1798
1825
  }
1799
1826
  return S(() => {
1800
- K(i.isCollapsible, (e) => {
1801
- e ? (document.addEventListener("mousedown", a), document.addEventListener("focusin", o)) : (document.removeEventListener("mousedown", a), document.removeEventListener("focusin", o));
1827
+ K(o.isCollapsible, (e) => {
1828
+ e ? (document.addEventListener("mousedown", s), document.addEventListener("focusin", c)) : (document.removeEventListener("mousedown", s), document.removeEventListener("focusin", c));
1802
1829
  }, { immediate: !0 });
1803
1830
  }), x(() => {
1804
- document.removeEventListener("mousedown", a), document.removeEventListener("focusin", o);
1805
- }), i;
1831
+ document.removeEventListener("mousedown", s), document.removeEventListener("focusin", c);
1832
+ }), o;
1806
1833
  }
1807
1834
  //#endregion
1808
1835
  //#region src/components/GSidebar.vue?vue&type=script&setup=true&lang.ts
@@ -1815,10 +1842,11 @@ var un = ["id"], dn = /* @__PURE__ */ u({
1815
1842
  topOffset: { default: "" },
1816
1843
  topOffsetVar: { default: "" },
1817
1844
  width: { default: "300px" },
1818
- sidebarKey: { default: "default" }
1845
+ sidebarKey: { default: "default" },
1846
+ mediaQuery: {}
1819
1847
  },
1820
1848
  setup(e) {
1821
- let t = e, n = p("sidebar", () => void 0, !0) ?? (fe() ? ln(t.sidebarKey) : void 0), i = r(() => t.backgroundImage ? t.backgroundImage : t.theme === "light" ? "none" : "url('https://gradcdn.blob.core.windows.net/public/sidebar-bg2.jpg')"), a = r(() => t.backgroundColor ? t.backgroundColor : t.theme === "light" ? "#f9f9f9" : "#030913"), s = r(() => t.topOffsetVar ? `var(${t.topOffsetVar})` : t.topOffset ? t.topOffset : "var(--g-toolbar-height)"), c = B();
1849
+ let t = e, n = p("sidebar", () => void 0, !0) ?? (fe() ? ln(t.sidebarKey, I(t, "mediaQuery")) : void 0), i = r(() => t.backgroundImage ? t.backgroundImage : t.theme === "light" ? "none" : "url('https://gradcdn.blob.core.windows.net/public/sidebar-bg2.jpg')"), a = r(() => t.backgroundColor ? t.backgroundColor : t.theme === "light" ? "#f9f9f9" : "#030913"), s = r(() => t.topOffsetVar ? `var(${t.topOffsetVar})` : t.topOffset ? t.topOffset : "var(--g-toolbar-height)"), c = B();
1822
1850
  function l(e) {
1823
1851
  e.key === "Escape" && n?.isCollapsible?.value && n?.open?.value && (n.open.value = !1, document.getElementById(`${n.id}-hamburger`)?.focus());
1824
1852
  }
@@ -3223,11 +3251,12 @@ var yr = { class: "g-table-outer-wrap" }, br = {
3223
3251
  __name: "GHamburgerMenu",
3224
3252
  props: {
3225
3253
  label: { default: "Main Navigation" },
3226
- sidebarKey: { default: "default" }
3254
+ sidebarKey: { default: "default" },
3255
+ mediaQuery: {}
3227
3256
  },
3228
3257
  emits: ["toggle"],
3229
3258
  setup(e, { emit: t }) {
3230
- let n = e, r = p("sidebar") ?? (fe() ? ln(n.sidebarKey) : void 0), i = t;
3259
+ let n = e, r = p("sidebar") ?? (fe() ? ln(n.sidebarKey, I(n, "mediaQuery")) : void 0), i = t;
3231
3260
  function a() {
3232
3261
  i("toggle"), r?.toggle();
3233
3262
  }
@@ -4231,4 +4260,4 @@ function ga() {
4231
4260
  //#endregion
4232
4261
  export { ke as $, $n as A, Ht as B, hr as C, _r as D, mr as E, hn as F, it as G, wt as H, dn as I, Qe as J, et as K, ln as L, Cn as M, vn as N, vr as O, gn as P, $ as Q, on as R, qr as S, gr as T, yt as U, At as V, ft as W, qe as X, Ke as Y, Re as Z, hi as _, sa as a, ci as b, qi as c, Mi as d, De as et, ji as f, _i as g, xi as h, pa as i, Q as it, Rn as j, fr as k, Bi as l, Ti as m, ha as n, xe as nt, Xi as o, Ai as p, $e as q, ma as r, be as rt, Yi as s, ga as t, Ee as tt, zi as u, di as v, pr as w, ni as x, ui as y, Qt as z };
4233
4262
 
4234
- //# sourceMappingURL=grad-vue-CAmKhHhp.js.map
4263
+ //# sourceMappingURL=grad-vue-DmUhI4Ja.js.map