@themarioga/grid-editor 9.2.6 → 9.3.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 (45) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +68 -5
  3. package/dist/grideditor.bundle.min.js +2 -2
  4. package/dist/grideditor.css +267 -0
  5. package/dist/grideditor.d.ts +88 -0
  6. package/dist/grideditor.esm.js +27 -5
  7. package/dist/grideditor.js +27 -5
  8. package/dist/grideditor.min.css +1 -1
  9. package/dist/grideditor.min.css.map +1 -1
  10. package/dist/grideditor.min.js +1 -1
  11. package/dist/grideditor.min.js.map +3 -3
  12. package/dist/locales/grideditor.es.esm.js +102 -0
  13. package/dist/locales/grideditor.es.js +102 -0
  14. package/dist/locales/grideditor.es.min.js +1 -1
  15. package/dist/locales/grideditor.es.min.js.map +2 -2
  16. package/dist/plugins/grideditor.navbar.esm.js +2084 -0
  17. package/dist/plugins/grideditor.navbar.js +2085 -0
  18. package/dist/plugins/grideditor.navbar.min.js +1 -0
  19. package/dist/plugins/grideditor.navbar.min.js.map +7 -0
  20. package/dist/plugins/grideditor.sidenav.esm.js +1978 -0
  21. package/dist/plugins/grideditor.sidenav.js +1979 -0
  22. package/dist/plugins/grideditor.sidenav.min.js +1 -0
  23. package/dist/plugins/grideditor.sidenav.min.js.map +7 -0
  24. package/docs/events.md +5 -1
  25. package/docs/locale-keys.md +103 -1
  26. package/docs/plugins.md +23 -4
  27. package/example/containers.html +59 -2
  28. package/example/index.html +1 -1
  29. package/example/playground.html +2 -0
  30. package/package.json +1 -1
  31. package/src/js/grideditor.js +36 -4
  32. package/src/js/locales/grideditor.es.js +102 -0
  33. package/src/js/nav/browse.js +51 -0
  34. package/src/js/nav/canvas.js +170 -0
  35. package/src/js/nav/convert.js +175 -0
  36. package/src/js/nav/drawers.js +258 -0
  37. package/src/js/nav/feature.js +94 -0
  38. package/src/js/nav/locale.js +128 -0
  39. package/src/js/nav/markup.js +121 -0
  40. package/src/js/nav/panels.js +443 -0
  41. package/src/js/nav/pieces.js +207 -0
  42. package/src/js/plugins/grideditor.navbar.js +454 -0
  43. package/src/js/plugins/grideditor.sidenav.js +349 -0
  44. package/src/less/grideditor.less +199 -0
  45. package/types/grideditor.d.ts +88 -0
@@ -0,0 +1,1979 @@
1
+ (() => {
2
+ // src/js/register.js
3
+ var GridEditor = window.GridEditor;
4
+ if (!GridEditor || typeof GridEditor.get !== "function") {
5
+ throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");
6
+ }
7
+
8
+ // src/js/dom.js
9
+ function all(root, selector) {
10
+ return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
11
+ }
12
+ function one(root, selector) {
13
+ return root ? root.querySelector(selector) : null;
14
+ }
15
+ function children(node, selector) {
16
+ if (!node) {
17
+ return [];
18
+ }
19
+ return Array.prototype.filter.call(node.children, function(each) {
20
+ return !selector || each.matches(selector);
21
+ });
22
+ }
23
+ function child(node, selector) {
24
+ return children(node, selector)[0] || null;
25
+ }
26
+ function closest(node, selector, stopAt) {
27
+ var found = node && node.nodeType === 1 ? node.closest(selector) : null;
28
+ if (found && stopAt && found !== stopAt && !stopAt.contains(found)) {
29
+ return null;
30
+ }
31
+ return found;
32
+ }
33
+ function is(node, selector) {
34
+ return !!node && node.nodeType === 1 && node.matches(selector);
35
+ }
36
+ function element(tag, attributes, text2) {
37
+ var node = document.createElement(tag);
38
+ Object.keys(attributes || {}).forEach(function(name) {
39
+ var value = attributes[name];
40
+ if (value !== null && value !== void 0 && value !== false) {
41
+ node.setAttribute(name, value);
42
+ }
43
+ });
44
+ if (text2 !== void 0 && text2 !== null) {
45
+ node.textContent = text2;
46
+ }
47
+ return node;
48
+ }
49
+ function addClass(node, names) {
50
+ split(names).forEach(function(name) {
51
+ node.classList.add(name);
52
+ });
53
+ return node;
54
+ }
55
+ function removeClass(node, names) {
56
+ split(names).forEach(function(name) {
57
+ node.classList.remove(name);
58
+ });
59
+ return node;
60
+ }
61
+ function toggleClass(node, names, state) {
62
+ split(names).forEach(function(name) {
63
+ if (state === void 0) {
64
+ node.classList.toggle(name);
65
+ } else {
66
+ node.classList.toggle(name, !!state);
67
+ }
68
+ });
69
+ return node;
70
+ }
71
+ function hasClass(node, name) {
72
+ return !!node && node.nodeType === 1 && node.classList.contains(name);
73
+ }
74
+ function split(names) {
75
+ return String(names || "").split(/\s+/).filter(Boolean);
76
+ }
77
+ function dropEmptyClass(node) {
78
+ if (!node.getAttribute("class")) {
79
+ node.removeAttribute("class");
80
+ }
81
+ return node;
82
+ }
83
+ function dropEmptyStyle(node) {
84
+ if (!node.getAttribute("style")) {
85
+ node.removeAttribute("style");
86
+ }
87
+ return node;
88
+ }
89
+ function attr(node, attributes) {
90
+ Object.keys(attributes).forEach(function(name) {
91
+ var value = attributes[name];
92
+ if (value === null || value === void 0) {
93
+ node.removeAttribute(name);
94
+ } else {
95
+ node.setAttribute(name, value);
96
+ }
97
+ });
98
+ return node;
99
+ }
100
+ function hide(node) {
101
+ node.style.display = "none";
102
+ return node;
103
+ }
104
+ function visible(node) {
105
+ return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);
106
+ }
107
+ function delegate(root, types, selector, handler, options) {
108
+ var listener = function(event) {
109
+ var match = closest(event.target, selector, root);
110
+ if (match && root.contains(match)) {
111
+ return handler.call(match, event);
112
+ }
113
+ return void 0;
114
+ };
115
+ split(types).forEach(function(type) {
116
+ root.addEventListener(type, listener, options);
117
+ });
118
+ return listener;
119
+ }
120
+ var DEFAULT_DURATION = 400;
121
+ function animateAway(node, frames, duration, done) {
122
+ duration = duration === void 0 ? DEFAULT_DURATION : duration;
123
+ addClass(node, "ge-leaving");
124
+ var finish = function() {
125
+ removeClass(node, "ge-leaving");
126
+ dropEmptyClass(node);
127
+ hide(node);
128
+ if (done) {
129
+ done();
130
+ }
131
+ };
132
+ if (!visible(node) || !node.animate || duration <= 0) {
133
+ window.setTimeout(finish, 0);
134
+ return;
135
+ }
136
+ var animation = node.animate(frames(getComputedStyle(node)), {
137
+ duration,
138
+ easing: "ease-in-out"
139
+ });
140
+ var called = false;
141
+ var once = function() {
142
+ if (called) {
143
+ return;
144
+ }
145
+ called = true;
146
+ finish();
147
+ };
148
+ animation.onfinish = once;
149
+ animation.oncancel = once;
150
+ }
151
+ function fadeOut(node, duration, done) {
152
+ animateAway(node, function(style) {
153
+ return [{ opacity: style.opacity }, { opacity: 0 }];
154
+ }, duration, done);
155
+ }
156
+
157
+ // src/js/nav/locale.js
158
+ var EN = {
159
+ "container.navbar_brand": "Brand",
160
+ "container.sidenav_brand": "Brand",
161
+ "container.nav_link": "Link",
162
+ "container.nav_dropdown": "Dropdown",
163
+ "container.nav_submenu": "Submenu",
164
+ "container.nav_menu_link": "Action",
165
+ "container.nav_menu_header": "Header",
166
+ "container.nav_text": "Text",
167
+ "container.navbar_toggle": "Toggle navigation",
168
+ "container.navbar_offcanvas_title": "Menu",
169
+ "container.sidenav_trigger": "Menu",
170
+ "tool.add_nav_piece": "Add\u2026",
171
+ "tool.add_nav_link": "Add link or dropdown",
172
+ "tool.add_nav_menu_item": "Add item",
173
+ "tool.fold_nav_menu": "Fold this menu while editing",
174
+ "confirm.delete_nav_piece": "Delete this and everything in it?",
175
+ "container.navbar_section": "Navbar",
176
+ "container.sidenav_section": "Sidebar",
177
+ "container.nav_brand_show": "Brand",
178
+ "container.nav_brand_image": "Image",
179
+ "container.nav_brand_alt": "Alt text",
180
+ "container.nav_brand_height": "Height (px)",
181
+ "container.navbar_expand": "Expand",
182
+ "container.navbar_expand_never": "Never",
183
+ "container.navbar_expand_always": "Always",
184
+ "container.navbar_expand_from": "From {breakpoint}",
185
+ "container.navbar_collapse": "Collapse",
186
+ "container.navbar_collapse_collapse": "Collapse",
187
+ "container.navbar_collapse_offcanvas": "Offcanvas",
188
+ "container.navbar_collapse_none": "Not collapsed",
189
+ "container.navbar_offcanvas_placement": "Side",
190
+ "container.nav_start": "Start",
191
+ "container.nav_end": "End",
192
+ "container.nav_bg": "Background",
193
+ "container.nav_bg_none": "None",
194
+ "container.nav_bg_body_tertiary": "Light grey",
195
+ "container.nav_bg_body": "Page",
196
+ "container.nav_bg_primary": "Primary",
197
+ "container.nav_bg_secondary": "Secondary",
198
+ "container.nav_bg_success": "Success",
199
+ "container.nav_bg_danger": "Danger",
200
+ "container.nav_bg_warning": "Warning",
201
+ "container.nav_bg_info": "Info",
202
+ "container.nav_bg_light": "Light",
203
+ "container.nav_bg_dark": "Dark",
204
+ "container.nav_theme": "Theme",
205
+ "container.nav_theme_auto": "Auto",
206
+ "container.nav_theme_light": "Light",
207
+ "container.nav_theme_dark": "Dark",
208
+ "container.navbar_position": "Position",
209
+ "container.navbar_position_none": "In the flow",
210
+ "container.navbar_position_fixed_top": "Fixed top",
211
+ "container.navbar_position_fixed_bottom": "Fixed bottom",
212
+ "container.navbar_position_sticky_top": "Sticky top",
213
+ "container.navbar_position_sticky_bottom": "Sticky bottom",
214
+ "container.navbar_width": "Inner width",
215
+ "container.navbar_width_fluid": "Full",
216
+ "container.navbar_width_fixed": "Fixed",
217
+ "container.navbar_width_from": "Full up to {breakpoint}",
218
+ "container.sidenav_width": "Width",
219
+ "container.sidenav_style": "Link style",
220
+ "container.sidenav_style_pills": "Pills",
221
+ "container.sidenav_style_plain": "Plain",
222
+ "container.sidenav_full_height": "Full height",
223
+ "container.sidenav_responsive": "Responsive",
224
+ "container.sidenav_responsive_never": "Always visible",
225
+ "container.sidenav_responsive_from": "Offcanvas below {breakpoint}",
226
+ "container.sidenav_offcanvas_title": "Menu",
227
+ "container.nav_close": "Close",
228
+ "container.nav_list_section": "List",
229
+ "container.nav_link_section": "Link",
230
+ "container.nav_dropdown_section": "Dropdown",
231
+ "container.nav_menu_item_section": "Item",
232
+ "container.nav_text_section": "Text",
233
+ "container.nav_zone_section": "Free zone",
234
+ "container.nav_brand_section": "Brand",
235
+ "container.nav_align": "Alignment",
236
+ "container.nav_align_after": "After the previous",
237
+ "container.nav_align_end": "At the end",
238
+ "container.nav_align_center": "Centered",
239
+ "container.nav_scroll": "Scroll",
240
+ "container.nav_scroll_height": "Height",
241
+ "container.nav_bottom": "At the bottom",
242
+ "container.nav_href": "URL",
243
+ "container.nav_active": "Active",
244
+ "container.nav_disabled": "Disabled",
245
+ "container.nav_new_tab": "New tab",
246
+ "container.nav_menu_end": "Menu on the right",
247
+ "container.nav_submenu_type": "Type",
248
+ "container.nav_submenu_type_collapse": "Collapsible",
249
+ "container.nav_submenu_type_dropdown": "Dropdown",
250
+ "container.nav_submenu_open": "Open on load",
251
+ "container.nav_menu_divider": "Divider",
252
+ "container.nav_zone": "Free zone",
253
+ "tool.add_nav_list": "Add list",
254
+ "tool.add_nav_text": "Add text",
255
+ "tool.add_nav_zone": "Add free zone",
256
+ "tool.unfold_nav_menu": "Unfold this menu",
257
+ "container.nav_browse": "Browse\u2026",
258
+ "tool.delete_nav_piece": "Delete"
259
+ };
260
+ var BACKGROUND_CHOICES = [
261
+ { value: "body-tertiary", labelKey: "container.nav_bg_body_tertiary" },
262
+ { value: "body", labelKey: "container.nav_bg_body" },
263
+ { value: "primary", labelKey: "container.nav_bg_primary" },
264
+ { value: "secondary", labelKey: "container.nav_bg_secondary" },
265
+ { value: "success", labelKey: "container.nav_bg_success" },
266
+ { value: "danger", labelKey: "container.nav_bg_danger" },
267
+ { value: "warning", labelKey: "container.nav_bg_warning" },
268
+ { value: "info", labelKey: "container.nav_bg_info" },
269
+ { value: "light", labelKey: "container.nav_bg_light" },
270
+ { value: "dark", labelKey: "container.nav_bg_dark" }
271
+ ];
272
+
273
+ // src/js/nav/pieces.js
274
+ var TYPES = ["navbar", "sidenav"];
275
+ var WRAPS = ".container, .container-fluid, .container-sm, .container-md, .container-lg, .container-xl, .container-xxl";
276
+ var KINDS = ["nav-list", "nav-link", "nav-dropdown", "nav-menu-item", "nav-text", "nav-zone", "nav-brand"];
277
+ function typeOf(container) {
278
+ return container ? container.getAttribute("data-ge-container") : null;
279
+ }
280
+ function isZone(node) {
281
+ return is(node, '[data-ge-nav="zone"]');
282
+ }
283
+ function isSubmenu(node) {
284
+ return is(node, 'li[data-ge-nav="submenu"]');
285
+ }
286
+ function navOf(container) {
287
+ return child(container, "nav");
288
+ }
289
+ function wrapOf(container) {
290
+ var nav = navOf(container);
291
+ return nav ? child(nav, WRAPS) || nav : null;
292
+ }
293
+ function areaOf(container) {
294
+ var wrap = wrapOf(container);
295
+ if (!wrap) {
296
+ return null;
297
+ }
298
+ var collapse = child(wrap, ".navbar-collapse");
299
+ if (collapse) {
300
+ return collapse;
301
+ }
302
+ var offcanvas = child(wrap, ".offcanvas");
303
+ var body = offcanvas ? child(offcanvas, ".offcanvas-body") : null;
304
+ return body || wrap;
305
+ }
306
+ function offcanvasOf(container) {
307
+ var wrap = wrapOf(container);
308
+ return wrap ? child(wrap, ".offcanvas") : null;
309
+ }
310
+ function panelOf(container) {
311
+ return children(container).filter(function(node) {
312
+ return !hasClass(node, "ge-tools-drawer") && node.tagName !== "BUTTON";
313
+ })[0] || null;
314
+ }
315
+ function triggerOf(container) {
316
+ return child(container, "button");
317
+ }
318
+ function holderOf(container) {
319
+ return typeOf(container) === "sidenav" ? panelOf(container) : areaOf(container);
320
+ }
321
+ function ownerOf(node, loaded) {
322
+ var holder = node && node.parentElement ? node.parentElement.closest('[data-ge-container], [data-ge-nav="zone"]') : null;
323
+ if (!holder || isZone(holder)) {
324
+ return null;
325
+ }
326
+ return loaded(typeOf(holder)) ? holder : null;
327
+ }
328
+ function isMenu(node) {
329
+ return is(node, ".dropdown-menu");
330
+ }
331
+ function menuOf(dropdown2) {
332
+ if (isSubmenu(dropdown2)) {
333
+ return one(dropdown2, ":scope > .collapse > ul");
334
+ }
335
+ return child(dropdown2, ".dropdown-menu");
336
+ }
337
+ function itemType(item) {
338
+ if (child(item, "hr")) {
339
+ return "divider";
340
+ }
341
+ if (child(item, "h6")) {
342
+ return "header";
343
+ }
344
+ if (child(item, "a")) {
345
+ return "link";
346
+ }
347
+ return "text";
348
+ }
349
+ function anchorOf(piece) {
350
+ return child(piece, "a");
351
+ }
352
+ function kindOf(node, loaded) {
353
+ var container = ownerOf(node, loaded);
354
+ if (!container) {
355
+ return null;
356
+ }
357
+ var type = typeOf(container);
358
+ var parent = node.parentElement;
359
+ var holder = holderOf(container);
360
+ if (parent === holder || type === "navbar" && parent === wrapOf(container) && is(node, ".navbar-brand")) {
361
+ if (isZone(node)) {
362
+ return "nav-zone";
363
+ }
364
+ if (type === "navbar") {
365
+ if (is(node, ".navbar-brand")) {
366
+ return "nav-brand";
367
+ }
368
+ if (is(node, "ul.navbar-nav")) {
369
+ return "nav-list";
370
+ }
371
+ if (is(node, ".navbar-text")) {
372
+ return "nav-text";
373
+ }
374
+ return null;
375
+ }
376
+ if (is(node, 'a[data-ge-nav="brand"]')) {
377
+ return "nav-brand";
378
+ }
379
+ if (is(node, "ul.nav")) {
380
+ return "nav-list";
381
+ }
382
+ if (is(node, '[data-ge-nav="text"]')) {
383
+ return "nav-text";
384
+ }
385
+ return null;
386
+ }
387
+ if (!is(node, "li") || !parent) {
388
+ return null;
389
+ }
390
+ if (is(parent, "ul") && parent.parentElement && kindOf(parent, loaded) === "nav-list") {
391
+ if (is(node, ".nav-item.dropdown") || type === "sidenav" && isSubmenu(node)) {
392
+ return "nav-dropdown";
393
+ }
394
+ if (is(node, ".nav-item") && child(node, "a.nav-link")) {
395
+ return "nav-link";
396
+ }
397
+ return null;
398
+ }
399
+ if (isMenu(parent) && is(parent.parentElement, "li.nav-item.dropdown") && kindOf(parent.parentElement, loaded) === "nav-dropdown") {
400
+ return "nav-menu-item";
401
+ }
402
+ if (type === "sidenav" && is(parent, "ul") && is(parent.parentElement, ".collapse") && isSubmenu(parent.parentElement.parentElement) && kindOf(parent.parentElement.parentElement, loaded) === "nav-dropdown") {
403
+ return "nav-menu-item";
404
+ }
405
+ return null;
406
+ }
407
+ function piecesOf(container, loaded) {
408
+ var found = [];
409
+ all(container, "*").forEach(function(node) {
410
+ if (ownerOf(node, loaded) !== container) {
411
+ return;
412
+ }
413
+ var kind = kindOf(node, loaded);
414
+ if (kind) {
415
+ found.push({ node, kind });
416
+ }
417
+ });
418
+ return found;
419
+ }
420
+ function isOwn(container, node) {
421
+ var scope = node.parentElement ? node.parentElement.closest('[data-ge-container], [data-ge-nav="zone"]') : null;
422
+ return scope === container;
423
+ }
424
+ function togglesOf(container) {
425
+ return all(container, "[data-bs-toggle], [data-ge-bs-toggle], [data-bs-dismiss], [data-ge-bs-dismiss]").filter(function(node) {
426
+ return isOwn(container, node);
427
+ });
428
+ }
429
+ function defaultLabelKey(node, kind, container) {
430
+ var type = typeOf(container);
431
+ if (kind === "nav-link") {
432
+ return "container.nav_link";
433
+ }
434
+ if (kind === "nav-dropdown") {
435
+ return isSubmenu(node) ? "container.nav_submenu" : "container.nav_dropdown";
436
+ }
437
+ if (kind === "nav-text") {
438
+ return "container.nav_text";
439
+ }
440
+ if (kind === "nav-brand") {
441
+ return type === "sidenav" ? "container.sidenav_brand" : "container.navbar_brand";
442
+ }
443
+ var itemKind = itemType(node);
444
+ if (itemKind === "header") {
445
+ return "container.nav_menu_header";
446
+ }
447
+ if (itemKind === "text") {
448
+ return "container.nav_text";
449
+ }
450
+ return "container.nav_menu_link";
451
+ }
452
+
453
+ // src/js/nav/markup.js
454
+ var MENU_CLASSES = {
455
+ link: "dropdown-item",
456
+ divider: "dropdown-divider",
457
+ header: "dropdown-header",
458
+ text: "dropdown-item-text"
459
+ };
460
+ var SUBMENU_CLASSES = {
461
+ link: "nav-link",
462
+ divider: "my-1",
463
+ header: "small text-body-secondary px-3 pt-2 mb-1",
464
+ text: "d-block small px-3 py-1"
465
+ };
466
+ var ITEM_TAGS = { link: "a", divider: "hr", header: "h6", text: "span" };
467
+ function menuItem(ge, type, context) {
468
+ var classes = context === "submenu" ? SUBMENU_CLASSES : MENU_CLASSES;
469
+ var item = element("li", type === "link" && context === "submenu" ? { "class": "nav-item" } : {});
470
+ var inner = element(ITEM_TAGS[type], { "class": classes[type] });
471
+ if (type === "link") {
472
+ inner.setAttribute("href", "#");
473
+ inner.textContent = ge.t("container.nav_menu_link");
474
+ } else if (type === "header") {
475
+ inner.textContent = ge.t("container.nav_menu_header");
476
+ } else if (type === "text") {
477
+ inner.textContent = ge.t("container.nav_text");
478
+ }
479
+ item.appendChild(inner);
480
+ return item;
481
+ }
482
+ function link(ge) {
483
+ var item = element("li", { "class": "nav-item" });
484
+ item.appendChild(element("a", { "class": "nav-link", href: "#" }, ge.t("container.nav_link")));
485
+ return item;
486
+ }
487
+ function dropdown(ge) {
488
+ var item = element("li", { "class": "nav-item dropdown" });
489
+ item.appendChild(element("a", {
490
+ "class": "nav-link dropdown-toggle",
491
+ href: "#",
492
+ role: "button",
493
+ "data-bs-toggle": "dropdown",
494
+ "aria-expanded": "false"
495
+ }, ge.t("container.nav_dropdown")));
496
+ var menu = item.appendChild(element("ul", { "class": "dropdown-menu" }));
497
+ menu.appendChild(menuItem(ge, "link", "menu"));
498
+ menu.appendChild(menuItem(ge, "link", "menu"));
499
+ return item;
500
+ }
501
+ function submenu(ge) {
502
+ var id = ge.containerId("nav");
503
+ var item = element("li", { "class": "nav-item", "data-ge-nav": "submenu" });
504
+ item.appendChild(element("a", {
505
+ "class": "nav-link dropdown-toggle",
506
+ href: "#" + id,
507
+ "data-bs-toggle": "collapse",
508
+ role: "button",
509
+ "aria-expanded": "false",
510
+ "aria-controls": id
511
+ }, ge.t("container.nav_submenu")));
512
+ var menu = item.appendChild(element("div", { "class": "collapse", id })).appendChild(element("ul", { "class": "nav flex-column ms-3" }));
513
+ menu.appendChild(menuItem(ge, "link", "submenu"));
514
+ menu.appendChild(menuItem(ge, "link", "submenu"));
515
+ return item;
516
+ }
517
+ function listClass(type, pills) {
518
+ return type === "sidenav" ? "nav" + (pills ? " nav-pills" : "") + " flex-column" : "navbar-nav";
519
+ }
520
+ function list(ge, type, pills, count) {
521
+ var ul = element("ul", { "class": listClass(type, pills) });
522
+ for (var i = 0; i < count; i++) {
523
+ ul.appendChild(link(ge));
524
+ }
525
+ return ul;
526
+ }
527
+ function text(ge, type) {
528
+ var label = ge.t("container.nav_text");
529
+ return type === "sidenav" ? element("div", { "class": "px-3 py-2", "data-ge-nav": "text" }, label) : element("span", { "class": "navbar-text" }, label);
530
+ }
531
+ function zone(ge) {
532
+ var node = element("div", { "class": "d-block", "data-ge-nav": "zone" });
533
+ node.appendChild(ge.defaultRegion());
534
+ return node;
535
+ }
536
+
537
+ // src/js/nav/convert.js
538
+ function setItemContext(item, context) {
539
+ var type = itemType(item);
540
+ var inner = child(item, ITEM_TAGS[type]);
541
+ var from = context === "submenu" ? MENU_CLASSES : SUBMENU_CLASSES;
542
+ var to = context === "submenu" ? SUBMENU_CLASSES : MENU_CLASSES;
543
+ if (!inner) {
544
+ return;
545
+ }
546
+ var own = String(from[type]).split(" ");
547
+ var rest = Array.prototype.filter.call(inner.classList, function(name) {
548
+ return own.indexOf(name) === -1;
549
+ });
550
+ inner.className = [to[type]].concat(rest).join(" ");
551
+ if (type === "link") {
552
+ toggleClass(item, "nav-item", context === "submenu");
553
+ }
554
+ dropEmptyClass(item);
555
+ }
556
+ function apartAgain(ge, node) {
557
+ if (!ge.previewing()) {
558
+ ge.suspendToggles(node);
559
+ }
560
+ }
561
+ function setToggle(a, attributes) {
562
+ ["data-bs-toggle", "data-ge-bs-toggle", "aria-controls", "aria-expanded", "role"].forEach(function(name) {
563
+ a.removeAttribute(name);
564
+ });
565
+ attr(a, attributes);
566
+ }
567
+ function toDropdown(ge, item) {
568
+ if (!isSubmenu(item)) {
569
+ return;
570
+ }
571
+ var toggle = child(item, "a");
572
+ var collapse = child(item, ".collapse");
573
+ var menu = collapse ? child(collapse, "ul") : null;
574
+ item.removeAttribute("data-ge-nav");
575
+ addClass(item, "dropdown");
576
+ setToggle(toggle, { href: "#", role: "button", "data-bs-toggle": "dropdown", "aria-expanded": "false" });
577
+ if (menu) {
578
+ removeClass(menu, "nav flex-column ms-3");
579
+ addClass(menu, "dropdown-menu");
580
+ children(menu, "li").forEach(function(each) {
581
+ setItemContext(each, "menu");
582
+ });
583
+ item.insertBefore(menu, collapse);
584
+ collapse.remove();
585
+ }
586
+ apartAgain(ge, item);
587
+ }
588
+ function toSubmenu(ge, item) {
589
+ if (isSubmenu(item)) {
590
+ return;
591
+ }
592
+ var id = ge.containerId("nav");
593
+ var toggle = child(item, "a");
594
+ var menu = child(item, ".dropdown-menu");
595
+ item.setAttribute("data-ge-nav", "submenu");
596
+ removeClass(item, "dropdown");
597
+ setToggle(toggle, { href: "#" + id, "data-bs-toggle": "collapse", role: "button", "aria-expanded": "false", "aria-controls": id });
598
+ if (menu) {
599
+ var collapse = element("div", { "class": "collapse", id });
600
+ removeClass(menu, "dropdown-menu dropdown-menu-end show");
601
+ addClass(menu, "nav flex-column ms-3");
602
+ menu.removeAttribute("data-bs-popper");
603
+ children(menu, "li").forEach(function(each) {
604
+ setItemContext(each, "submenu");
605
+ });
606
+ item.insertBefore(collapse, menu);
607
+ collapse.appendChild(menu);
608
+ }
609
+ apartAgain(ge, item);
610
+ }
611
+ function pillsIn(container, except) {
612
+ var lists = children(panelOf(container), "ul.nav").filter(function(each) {
613
+ return each !== except;
614
+ });
615
+ return !lists.length || hasClass(lists[0], "nav-pills");
616
+ }
617
+ function convertList(list2, toType, pills) {
618
+ removeClass(list2, "navbar-nav nav nav-pills flex-column");
619
+ addClass(list2, listClass(toType, pills));
620
+ if (toType === "sidenav") {
621
+ removeClass(list2, "navbar-nav-scroll");
622
+ list2.style.removeProperty("--bs-scroll-height");
623
+ dropEmptyStyle(list2);
624
+ }
625
+ }
626
+ function textOf(node) {
627
+ var label = child(node, ".ge-pane-label");
628
+ if (label) {
629
+ return label.textContent;
630
+ }
631
+ return Array.prototype.filter.call(node.childNodes, function(each) {
632
+ return each.nodeType === 3;
633
+ }).map(function(each) {
634
+ return each.textContent;
635
+ }).join("");
636
+ }
637
+ function convertText(ge, node, toType) {
638
+ var made = text(ge, toType);
639
+ var own = Array.prototype.filter.call(node.classList, function(name) {
640
+ return !/^ge-/.test(name) && ["navbar-text", "px-3", "py-2"].indexOf(name) === -1;
641
+ });
642
+ made.textContent = textOf(node);
643
+ addClass(made, own.join(" "));
644
+ node.parentNode.replaceChild(made, node);
645
+ return made;
646
+ }
647
+ function dropped(ge, node, loaded) {
648
+ var parent = node.parentElement;
649
+ var container = ownerOf(node, loaded);
650
+ if (!parent || !container) {
651
+ return node;
652
+ }
653
+ var type = typeOf(container);
654
+ if (parent === holderOf(container)) {
655
+ if (is(node, "ul.navbar-nav, ul.nav")) {
656
+ convertList(node, type, pillsIn(container, node));
657
+ } else if (is(node, '.navbar-text, [data-ge-nav="text"]') && !is(node, type === "sidenav" ? '[data-ge-nav="text"]' : ".navbar-text")) {
658
+ node = convertText(ge, node, type);
659
+ }
660
+ removeClass(node, type === "sidenav" ? "ms-auto mx-auto" : "mt-auto");
661
+ dropEmptyClass(node);
662
+ return node;
663
+ }
664
+ if (is(parent, "ul") && kindOf(parent, loaded) === "nav-list") {
665
+ if (type === "navbar" && isSubmenu(node)) {
666
+ toDropdown(ge, node);
667
+ }
668
+ return node;
669
+ }
670
+ if (is(parent, ".dropdown-menu")) {
671
+ setItemContext(node, "menu");
672
+ } else if (is(parent, "ul") && is(parent.parentElement, ".collapse")) {
673
+ setItemContext(node, "submenu");
674
+ }
675
+ return node;
676
+ }
677
+
678
+ // src/js/nav/browse.js
679
+ function browseButton(ge, context, browse, node, property, current, apply) {
680
+ if (typeof browse !== "function") {
681
+ return null;
682
+ }
683
+ var button = element("button", {
684
+ type: "button",
685
+ "class": "btn btn-outline-secondary ge-nav-browse",
686
+ title: ge.t("container.nav_browse"),
687
+ "aria-label": ge.t("container.nav_browse")
688
+ });
689
+ button.appendChild(element("i", { "class": "bi bi-folder2-open", "aria-hidden": "true" }));
690
+ button.addEventListener("click", function() {
691
+ var answered = false;
692
+ var target = typeof node === "function" ? node() : node;
693
+ function answer(url) {
694
+ if (answered) {
695
+ return;
696
+ }
697
+ answered = true;
698
+ if (url === null || url === void 0) {
699
+ return;
700
+ }
701
+ if (typeof url !== "string") {
702
+ ge.warn("navbar and sidenav browse gave " + typeof url + ", not a text: ignored");
703
+ return;
704
+ }
705
+ if (url.trim() === "" || context.destroyed || !ge.canvas.contains(target)) {
706
+ return;
707
+ }
708
+ apply(url.trim());
709
+ }
710
+ var result = browse(answer, { node: target, property, value: current() });
711
+ if (result && typeof result.then === "function") {
712
+ result.then(answer);
713
+ }
714
+ });
715
+ return button;
716
+ }
717
+
718
+ // src/js/nav/drawers.js
719
+ var wired = /* @__PURE__ */ new WeakSet();
720
+ var MARKS = /^ge-nav-/;
721
+ function labelOf(node) {
722
+ var existing = child(node, ".ge-pane-label");
723
+ if (existing) {
724
+ return existing;
725
+ }
726
+ var texts = Array.prototype.filter.call(node.childNodes, function(each) {
727
+ return each.nodeType === 3;
728
+ });
729
+ var content = texts.map(function(each) {
730
+ return each.textContent;
731
+ }).join("").trim();
732
+ if (!content) {
733
+ return null;
734
+ }
735
+ texts.forEach(function(each) {
736
+ each.remove();
737
+ });
738
+ return node.appendChild(element("span", { "class": "ge-pane-label" }, content));
739
+ }
740
+ function editInPlace(ge, node, fallback) {
741
+ var label = labelOf(node);
742
+ if (!label) {
743
+ return null;
744
+ }
745
+ ge.makeLabelEditable(label);
746
+ if (!wired.has(label)) {
747
+ wired.add(label);
748
+ label.addEventListener("blur", function() {
749
+ if (label.textContent.trim() === "") {
750
+ label.textContent = fallback();
751
+ }
752
+ });
753
+ }
754
+ return label;
755
+ }
756
+ function fallbackFor(ge, node, kind, container) {
757
+ return function() {
758
+ return ge.t(defaultLabelKey(node, kind, container));
759
+ };
760
+ }
761
+ function labelTarget(node, kind) {
762
+ if (kind === "nav-link" || kind === "nav-dropdown") {
763
+ return child(node, "a");
764
+ }
765
+ if (kind === "nav-menu-item") {
766
+ var type = itemType(node);
767
+ return type === "divider" ? null : child(node, ITEM_TAGS[type]);
768
+ }
769
+ return kind === "nav-text" || kind === "nav-brand" ? node : null;
770
+ }
771
+ function brandDrawer(ge, node) {
772
+ var drawer = element("div", { "class": "ge-tools-drawer ge-pane-drawer" });
773
+ node.insertBefore(drawer, node.firstChild);
774
+ ge.addSettingsTool(drawer, node, []);
775
+ }
776
+ function choice(label, choose, title) {
777
+ return { label, title: title || label, choose };
778
+ }
779
+ function pickerTool(ge, drawer, title, choices) {
780
+ var tool = one(drawer, ".ge-nav-add");
781
+ function open() {
782
+ ge.openPicker(tool, choices(), "ge-nav-picker");
783
+ }
784
+ if (!tool) {
785
+ tool = ge.createTool(drawer, title, "ge-nav-add", "bi bi-plus-circle", function(e) {
786
+ if (e) {
787
+ e.preventDefault();
788
+ }
789
+ if (ge.closePicker()) {
790
+ return;
791
+ }
792
+ open();
793
+ });
794
+ }
795
+ ge.attachPicker(tool, open);
796
+ return tool;
797
+ }
798
+ function add(ge, node, kind, holder) {
799
+ return ge.place(node, kind, { appendTo: holder, source: "tool" });
800
+ }
801
+ function containerTools(ge, drawer, container) {
802
+ var type = typeOf(container);
803
+ pickerTool(ge, drawer, ge.t("tool.add_nav_piece"), function() {
804
+ var holder = holderOf(container);
805
+ return [
806
+ choice(ge.t("container.nav_list_section"), function() {
807
+ add(ge, list(ge, type, pillsIn(container), 1), "nav-list", holder);
808
+ }, ge.t("tool.add_nav_list")),
809
+ choice(ge.t("container.nav_text"), function() {
810
+ add(ge, text(ge, type), "nav-text", holder);
811
+ }, ge.t("tool.add_nav_text")),
812
+ choice(ge.t("container.nav_zone"), function() {
813
+ add(ge, zone(ge), "nav-zone", holder);
814
+ }, ge.t("tool.add_nav_zone"))
815
+ ];
816
+ });
817
+ }
818
+ function addsOf(ge, node, kind, container) {
819
+ var type = typeOf(container);
820
+ if (kind === "nav-list") {
821
+ return {
822
+ title: ge.t("tool.add_nav_link"),
823
+ choices: function() {
824
+ return [
825
+ choice(ge.t("container.nav_link"), function() {
826
+ add(ge, link(ge), "nav-link", node);
827
+ }),
828
+ choice(ge.t(type === "sidenav" ? "container.nav_submenu" : "container.nav_dropdown"), function() {
829
+ add(ge, type === "sidenav" ? submenu(ge) : dropdown(ge), "nav-dropdown", node);
830
+ })
831
+ ];
832
+ }
833
+ };
834
+ }
835
+ if (kind !== "nav-dropdown") {
836
+ return null;
837
+ }
838
+ var addItem = function(itemType2) {
839
+ add(ge, menuItem(ge, itemType2, isSubmenu(node) ? "submenu" : "menu"), "nav-menu-item", menuOf(node));
840
+ };
841
+ return {
842
+ title: ge.t("tool.add_nav_menu_item"),
843
+ choices: function() {
844
+ return [
845
+ choice(ge.t("container.nav_menu_link"), function() {
846
+ addItem("link");
847
+ }),
848
+ choice(ge.t("container.nav_menu_divider"), function() {
849
+ addItem("divider");
850
+ }),
851
+ choice(ge.t("container.nav_menu_header"), function() {
852
+ addItem("header");
853
+ }),
854
+ choice(ge.t("container.nav_text"), function() {
855
+ addItem("text");
856
+ })
857
+ ];
858
+ }
859
+ };
860
+ }
861
+ function foldTool(ge, drawer, node) {
862
+ var tool = ge.createTool(drawer, ge.t("tool.fold_nav_menu"), "ge-nav-fold", "bi bi-chevron-bar-contract", function(e) {
863
+ if (e) {
864
+ e.preventDefault();
865
+ }
866
+ var folded = toggleClass(node, "ge-nav-folded").classList.contains("ge-nav-folded");
867
+ tool.setAttribute("title", folded ? ge.t("tool.unfold_nav_menu") : ge.t("tool.fold_nav_menu"));
868
+ });
869
+ return tool;
870
+ }
871
+ function markContainer(ge, container, loaded) {
872
+ var type = typeOf(container);
873
+ if (!ge.previewing()) {
874
+ togglesOf(container).forEach(function(node) {
875
+ ge.suspendToggles(node);
876
+ });
877
+ }
878
+ piecesOf(container, loaded).forEach(function(each) {
879
+ var node = each.node;
880
+ var kind = each.kind;
881
+ addClass(node, "ge-nav-piece ge-" + kind);
882
+ var labeled = labelTarget(node, kind);
883
+ if (labeled) {
884
+ editInPlace(ge, labeled, fallbackFor(ge, node, kind, container));
885
+ }
886
+ if (child(node, ".ge-tools-drawer")) {
887
+ return;
888
+ }
889
+ if (kind === "nav-brand") {
890
+ brandDrawer(ge, node);
891
+ return;
892
+ }
893
+ var drawer = ge.createPaneControls(node, kind, [], ge.t("confirm.delete_nav_piece"), function(removed) {
894
+ fadeOut(node, 200, removed);
895
+ }, { presets: [] });
896
+ var del = one(drawer, ".ge-delete-pane");
897
+ if (del) {
898
+ del.setAttribute("title", ge.t("tool.delete_nav_piece"));
899
+ del.setAttribute("aria-label", ge.t("tool.delete_nav_piece"));
900
+ }
901
+ var adds = addsOf(ge, node, kind, container);
902
+ if (adds) {
903
+ pickerTool(ge, drawer, adds.title, adds.choices);
904
+ }
905
+ if (kind === "nav-dropdown") {
906
+ foldTool(ge, drawer, node);
907
+ }
908
+ });
909
+ var offcanvas = type === "navbar" ? offcanvasOf(container) : panelOf(container);
910
+ var title = offcanvas ? one(offcanvas, ":scope > .offcanvas-header .offcanvas-title") : null;
911
+ if (title) {
912
+ editInPlace(ge, title, function() {
913
+ return ge.t(type === "navbar" ? "container.navbar_offcanvas_title" : "container.sidenav_offcanvas_title");
914
+ });
915
+ }
916
+ var trigger = type === "sidenav" ? triggerOf(container) : null;
917
+ if (trigger) {
918
+ editInPlace(ge, trigger, function() {
919
+ return ge.t("container.sidenav_trigger");
920
+ });
921
+ }
922
+ }
923
+ function unmarkContainer(ge, container) {
924
+ var own = function(node) {
925
+ return isOwn(container, node);
926
+ };
927
+ all(container, '[class*="ge-nav-"]').filter(own).forEach(function(node) {
928
+ Array.prototype.filter.call(node.classList, function(name) {
929
+ return MARKS.test(name);
930
+ }).forEach(function(name) {
931
+ node.classList.remove(name);
932
+ });
933
+ dropEmptyClass(node);
934
+ });
935
+ all(container, ".ge-pane-label").filter(own).forEach(function(label) {
936
+ ge.unwrapLabels(label.parentElement);
937
+ });
938
+ togglesOf(container).forEach(function(node) {
939
+ ge.resumeToggles(node);
940
+ });
941
+ }
942
+ function afterMove(ge, container, node, loaded) {
943
+ if (ownerOf(node, loaded) !== container) {
944
+ return;
945
+ }
946
+ var moved = dropped(ge, node, loaded);
947
+ if (moved !== node) {
948
+ children(moved, ".ge-tools-drawer").forEach(function(drawer) {
949
+ drawer.remove();
950
+ });
951
+ }
952
+ markContainer(ge, container, loaded);
953
+ }
954
+
955
+ // src/js/nav/panels.js
956
+ var counter = 0;
957
+ var SECTION_KEYS = {
958
+ "nav-list": { labelKey: "container.nav_list_section" },
959
+ "nav-link": { labelKey: "container.nav_link_section" },
960
+ "nav-dropdown": { labelKey: "container.nav_dropdown_section" },
961
+ "nav-menu-item": { labelKey: "container.nav_menu_item_section" },
962
+ "nav-text": { labelKey: "container.nav_text_section" },
963
+ "nav-zone": { labelKey: "container.nav_zone_section" },
964
+ "nav-brand": { labelKey: "container.nav_brand_section" }
965
+ };
966
+ function nextId() {
967
+ return "ge-nav-option-" + ++counter;
968
+ }
969
+ function fieldRow(name, label, control, id) {
970
+ var box = element("div", { "class": "ge-nav-option mb-2", "data-ge-nav-option": name });
971
+ if (label) {
972
+ box.appendChild(element("label", { "class": "form-label", "for": id }, label));
973
+ }
974
+ box.appendChild(control);
975
+ return box;
976
+ }
977
+ function selectControl(choices, onChange) {
978
+ var id = nextId();
979
+ var control = element("select", { "class": "form-select form-select-sm", id });
980
+ choices.forEach(function(each) {
981
+ control.appendChild(element("option", { value: each.value }, each.label));
982
+ });
983
+ control.addEventListener("change", function() {
984
+ onChange(control.value);
985
+ });
986
+ return { id, control };
987
+ }
988
+ function checkControl(label, onChange) {
989
+ var id = nextId();
990
+ var box = element("div", { "class": "form-check ge-nav-option mb-2" });
991
+ var input = box.appendChild(element("input", { "class": "form-check-input", type: "checkbox", id }));
992
+ box.appendChild(element("label", { "class": "form-check-label", "for": id }, label));
993
+ input.addEventListener("change", function() {
994
+ onChange(input.checked);
995
+ });
996
+ return { box, input };
997
+ }
998
+ function textControl(onChange) {
999
+ var id = nextId();
1000
+ var control = element("input", { "class": "form-control form-control-sm", type: "text", id });
1001
+ ["input", "change"].forEach(function(name) {
1002
+ control.addEventListener(name, function() {
1003
+ onChange(control.value);
1004
+ });
1005
+ });
1006
+ return { id, control };
1007
+ }
1008
+ function markInvalid(control, invalid) {
1009
+ toggleClass(control, "is-invalid", invalid);
1010
+ }
1011
+ function sectionsOf() {
1012
+ var kept = [];
1013
+ return {
1014
+ add: function(entry) {
1015
+ kept = kept.filter(function(each) {
1016
+ return each.element.isConnected;
1017
+ });
1018
+ kept.push(entry);
1019
+ },
1020
+ render: function(scope) {
1021
+ kept = kept.filter(function(each) {
1022
+ return each.element.isConnected;
1023
+ });
1024
+ kept.forEach(function(each) {
1025
+ if (!scope || each.node === scope || scope.contains(each.node)) {
1026
+ each.render();
1027
+ }
1028
+ });
1029
+ },
1030
+ clear: function() {
1031
+ kept = [];
1032
+ }
1033
+ };
1034
+ }
1035
+ function setActive(container, anchor, on) {
1036
+ var clear = function(each) {
1037
+ removeClass(each, "active");
1038
+ each.removeAttribute("aria-current");
1039
+ dropEmptyClass(each);
1040
+ };
1041
+ if (!on) {
1042
+ clear(anchor);
1043
+ return;
1044
+ }
1045
+ all(container, "a.nav-link, a.dropdown-item").filter(function(each) {
1046
+ return isOwn(container, each);
1047
+ }).forEach(clear);
1048
+ addClass(anchor, "active");
1049
+ anchor.setAttribute("aria-current", "page");
1050
+ }
1051
+ function alignOf(node) {
1052
+ return hasClass(node, "ms-auto") ? "end" : hasClass(node, "mx-auto") ? "center" : "after";
1053
+ }
1054
+ function createPanels(ge, loaded) {
1055
+ var kept = sectionsOf();
1056
+ var context = { destroyed: false };
1057
+ function settingsOf(container) {
1058
+ return ge.settings[typeOf(container)] || {};
1059
+ }
1060
+ function urlField(container, node, property, name, label, read, write, browseNode) {
1061
+ var field = textControl(write);
1062
+ var holder = element("div", { "class": "input-group input-group-sm" });
1063
+ holder.appendChild(field.control);
1064
+ var button = browseButton(ge, context, settingsOf(container).browse, browseNode || node, property, read, function(url) {
1065
+ write(url);
1066
+ kept.render();
1067
+ });
1068
+ if (button) {
1069
+ holder.appendChild(button);
1070
+ }
1071
+ return {
1072
+ row: fieldRow(name, label, holder, field.id),
1073
+ render: function() {
1074
+ field.control.value = read();
1075
+ }
1076
+ };
1077
+ }
1078
+ function linkFields(container, node, anchor, fields) {
1079
+ fields.push(urlField(
1080
+ container,
1081
+ node,
1082
+ "href",
1083
+ "href",
1084
+ ge.t("container.nav_href"),
1085
+ function() {
1086
+ return anchor.getAttribute("href") || "";
1087
+ },
1088
+ function(value) {
1089
+ anchor.setAttribute("href", value);
1090
+ },
1091
+ anchor
1092
+ ));
1093
+ var active = checkControl(ge.t("container.nav_active"), function(on) {
1094
+ setActive(container, anchor, on);
1095
+ kept.render();
1096
+ });
1097
+ var disabled = checkControl(ge.t("container.nav_disabled"), function(on) {
1098
+ toggleClass(anchor, "disabled", on);
1099
+ if (on) {
1100
+ anchor.setAttribute("aria-disabled", "true");
1101
+ } else {
1102
+ anchor.removeAttribute("aria-disabled");
1103
+ dropEmptyClass(anchor);
1104
+ }
1105
+ });
1106
+ var tab = checkControl(ge.t("container.nav_new_tab"), function(on) {
1107
+ if (on) {
1108
+ anchor.setAttribute("target", "_blank");
1109
+ anchor.setAttribute("rel", "noopener");
1110
+ } else {
1111
+ anchor.removeAttribute("target");
1112
+ anchor.removeAttribute("rel");
1113
+ }
1114
+ });
1115
+ active.box.setAttribute("data-ge-nav-option", "active");
1116
+ disabled.box.setAttribute("data-ge-nav-option", "disabled");
1117
+ tab.box.setAttribute("data-ge-nav-option", "new_tab");
1118
+ fields.push({ row: active.box, render: function() {
1119
+ active.input.checked = hasClass(anchor, "active");
1120
+ } });
1121
+ fields.push({ row: disabled.box, render: function() {
1122
+ disabled.input.checked = hasClass(anchor, "disabled");
1123
+ } });
1124
+ fields.push({ row: tab.box, render: function() {
1125
+ tab.input.checked = anchor.getAttribute("target") === "_blank";
1126
+ } });
1127
+ }
1128
+ function dropdownFields(container, node, fields) {
1129
+ var type = typeOf(container);
1130
+ if (type === "sidenav") {
1131
+ var kind = selectControl([
1132
+ { value: "collapse", label: ge.t("container.nav_submenu_type_collapse") },
1133
+ { value: "dropdown", label: ge.t("container.nav_submenu_type_dropdown") }
1134
+ ], function(value) {
1135
+ if (value === "collapse") {
1136
+ toSubmenu(ge, node);
1137
+ } else {
1138
+ toDropdown(ge, node);
1139
+ }
1140
+ kept.render();
1141
+ });
1142
+ fields.push({
1143
+ row: fieldRow("submenu_type", ge.t("container.nav_submenu_type"), kind.control, kind.id),
1144
+ render: function() {
1145
+ kind.control.value = isSubmenu(node) ? "collapse" : "dropdown";
1146
+ }
1147
+ });
1148
+ }
1149
+ var end = checkControl(ge.t("container.nav_menu_end"), function(on) {
1150
+ var menu = menuOf(node);
1151
+ if (!menu) {
1152
+ return;
1153
+ }
1154
+ toggleClass(menu, "dropdown-menu-end", on);
1155
+ dropEmptyClass(menu);
1156
+ });
1157
+ end.box.setAttribute("data-ge-nav-option", "menu_end");
1158
+ fields.push({
1159
+ row: end.box,
1160
+ render: function() {
1161
+ var menu = menuOf(node);
1162
+ end.input.checked = hasClass(menu, "dropdown-menu-end");
1163
+ end.input.disabled = isSubmenu(node);
1164
+ }
1165
+ });
1166
+ if (type !== "sidenav") {
1167
+ return;
1168
+ }
1169
+ var open = checkControl(ge.t("container.nav_submenu_open"), function(on) {
1170
+ var collapse = child(node, ".collapse");
1171
+ var toggle = child(node, "a");
1172
+ if (!collapse) {
1173
+ return;
1174
+ }
1175
+ toggleClass(collapse, "show", on);
1176
+ toggle.setAttribute("aria-expanded", on ? "true" : "false");
1177
+ });
1178
+ open.box.setAttribute("data-ge-nav-option", "submenu_open");
1179
+ fields.push({
1180
+ row: open.box,
1181
+ render: function() {
1182
+ var collapse = child(node, ".collapse");
1183
+ open.input.checked = hasClass(collapse, "show");
1184
+ open.input.disabled = !isSubmenu(node);
1185
+ }
1186
+ });
1187
+ }
1188
+ function alignmentField(node, fields) {
1189
+ var align = selectControl([
1190
+ { value: "after", label: ge.t("container.nav_align_after") },
1191
+ { value: "end", label: ge.t("container.nav_align_end") },
1192
+ { value: "center", label: ge.t("container.nav_align_center") }
1193
+ ], function(value) {
1194
+ removeClass(node, "ms-auto mx-auto");
1195
+ if (value === "end") {
1196
+ addClass(node, "ms-auto");
1197
+ }
1198
+ if (value === "center") {
1199
+ addClass(node, "mx-auto");
1200
+ }
1201
+ dropEmptyClass(node);
1202
+ });
1203
+ fields.push({
1204
+ row: fieldRow("align", ge.t("container.nav_align"), align.control, align.id),
1205
+ render: function() {
1206
+ align.control.value = alignOf(node);
1207
+ }
1208
+ });
1209
+ }
1210
+ function scrollFields(node, fields) {
1211
+ var height = textControl(function(value) {
1212
+ if (!hasClass(node, "navbar-nav-scroll")) {
1213
+ return;
1214
+ }
1215
+ var valid = value.trim() !== "" && window.CSS && CSS.supports("height", value.trim());
1216
+ markInvalid(height.control, !valid);
1217
+ if (valid) {
1218
+ ge.setHostStyle(node, "--bs-scroll-height", value.trim());
1219
+ }
1220
+ });
1221
+ var scroll = checkControl(ge.t("container.nav_scroll"), function(on) {
1222
+ if (on) {
1223
+ var typed = height.control.value.trim();
1224
+ var wanted = typed && CSS.supports("height", typed) ? typed : "75vh";
1225
+ addClass(node, "navbar-nav-scroll");
1226
+ ge.setHostStyle(node, "--bs-scroll-height", wanted);
1227
+ } else {
1228
+ removeClass(node, "navbar-nav-scroll");
1229
+ dropEmptyClass(node);
1230
+ ge.setHostStyle(node, "--bs-scroll-height", "");
1231
+ }
1232
+ markInvalid(height.control, false);
1233
+ });
1234
+ scroll.box.setAttribute("data-ge-nav-option", "scroll");
1235
+ fields.push({ row: scroll.box, render: function() {
1236
+ scroll.input.checked = hasClass(node, "navbar-nav-scroll");
1237
+ } });
1238
+ fields.push({
1239
+ row: fieldRow("scroll_height", ge.t("container.nav_scroll_height"), height.control, height.id),
1240
+ render: function() {
1241
+ var shown = ge.hostStyle(node, "--bs-scroll-height").value;
1242
+ height.control.value = shown || "75vh";
1243
+ height.control.disabled = !hasClass(node, "navbar-nav-scroll");
1244
+ markInvalid(height.control, false);
1245
+ }
1246
+ });
1247
+ }
1248
+ function bottomField(node, fields) {
1249
+ var bottom = checkControl(ge.t("container.nav_bottom"), function(on) {
1250
+ toggleClass(node, "mt-auto", on);
1251
+ dropEmptyClass(node);
1252
+ });
1253
+ bottom.box.setAttribute("data-ge-nav-option", "bottom");
1254
+ fields.push({ row: bottom.box, render: function() {
1255
+ bottom.input.checked = hasClass(node, "mt-auto");
1256
+ } });
1257
+ }
1258
+ function brandFields(container, node, fields) {
1259
+ var imageOf = function() {
1260
+ return child(node, "img");
1261
+ };
1262
+ fields.push(urlField(
1263
+ container,
1264
+ node,
1265
+ "href",
1266
+ "href",
1267
+ ge.t("container.nav_href"),
1268
+ function() {
1269
+ return node.getAttribute("href") || "";
1270
+ },
1271
+ function(value) {
1272
+ node.setAttribute("href", value);
1273
+ }
1274
+ ));
1275
+ fields.push(urlField(
1276
+ container,
1277
+ node,
1278
+ "src",
1279
+ "image",
1280
+ ge.t("container.nav_brand_image"),
1281
+ function() {
1282
+ var img = imageOf();
1283
+ return img ? img.getAttribute("src") || "" : "";
1284
+ },
1285
+ function(value) {
1286
+ setImage(value);
1287
+ },
1288
+ function() {
1289
+ return imageOf() || node;
1290
+ }
1291
+ ));
1292
+ var alt = textControl(function(value) {
1293
+ var img = imageOf();
1294
+ if (img) {
1295
+ img.setAttribute("alt", value);
1296
+ }
1297
+ });
1298
+ fields.push({
1299
+ row: fieldRow("alt", ge.t("container.nav_brand_alt"), alt.control, alt.id),
1300
+ render: function() {
1301
+ var img = imageOf();
1302
+ alt.control.value = img ? img.getAttribute("alt") || "" : "";
1303
+ alt.control.disabled = !img;
1304
+ }
1305
+ });
1306
+ var height = textControl(function(value) {
1307
+ var img = imageOf();
1308
+ var valid = /^\d+$/.test(value.trim()) && parseInt(value, 10) >= 1;
1309
+ markInvalid(height.control, !valid);
1310
+ if (valid && img) {
1311
+ img.setAttribute("height", String(parseInt(value, 10)));
1312
+ }
1313
+ });
1314
+ fields.push({
1315
+ row: fieldRow("image_height", ge.t("container.nav_brand_height"), height.control, height.id),
1316
+ render: function() {
1317
+ var img = imageOf();
1318
+ height.control.value = img ? img.getAttribute("height") || "30" : "30";
1319
+ height.control.disabled = !img;
1320
+ markInvalid(height.control, false);
1321
+ }
1322
+ });
1323
+ function setImage(url) {
1324
+ var img = imageOf();
1325
+ if (url === "") {
1326
+ if (img) {
1327
+ img.remove();
1328
+ }
1329
+ if (!node.textContent.trim().replace(/\s+/g, "")) {
1330
+ node.appendChild(document.createTextNode(ge.t(defaultLabelKey(node, "nav-brand", container))));
1331
+ editInPlace(ge, node, function() {
1332
+ return ge.t(defaultLabelKey(node, "nav-brand", container));
1333
+ });
1334
+ }
1335
+ return;
1336
+ }
1337
+ if (img) {
1338
+ img.setAttribute("src", url);
1339
+ return;
1340
+ }
1341
+ var first = children(node).filter(function(each) {
1342
+ return !hasClass(each, "ge-tools-drawer");
1343
+ })[0] || null;
1344
+ node.insertBefore(element("img", { src: url, alt: "", height: "30" }), first || node.firstChild);
1345
+ }
1346
+ }
1347
+ function fieldsOf(container, node, kind) {
1348
+ var type = typeOf(container);
1349
+ var fields = [];
1350
+ if (kind === "nav-link") {
1351
+ linkFields(container, node, anchorOf(node), fields);
1352
+ }
1353
+ if (kind === "nav-dropdown") {
1354
+ dropdownFields(container, node, fields);
1355
+ }
1356
+ if (kind === "nav-menu-item" && itemType(node) === "link") {
1357
+ linkFields(container, node, anchorOf(node), fields);
1358
+ }
1359
+ if (kind === "nav-list") {
1360
+ if (type === "navbar") {
1361
+ alignmentField(node, fields);
1362
+ scrollFields(node, fields);
1363
+ } else {
1364
+ bottomField(node, fields);
1365
+ }
1366
+ }
1367
+ if (kind === "nav-text" || kind === "nav-zone") {
1368
+ if (type === "navbar") {
1369
+ alignmentField(node, fields);
1370
+ } else {
1371
+ bottomField(node, fields);
1372
+ }
1373
+ }
1374
+ if (kind === "nav-brand") {
1375
+ brandFields(container, node, fields);
1376
+ }
1377
+ return fields;
1378
+ }
1379
+ return {
1380
+ context,
1381
+ /** The section of a piece's settings panel, or null for a piece with nothing to set. */
1382
+ pieceSection: function(node, kind) {
1383
+ if (KINDS.indexOf(kind) === -1) {
1384
+ return null;
1385
+ }
1386
+ var container = ownerOf(node, loaded);
1387
+ if (!container) {
1388
+ return null;
1389
+ }
1390
+ var fields = fieldsOf(container, node, kind);
1391
+ if (!fields.length) {
1392
+ return null;
1393
+ }
1394
+ var body = element("div", { "class": "ge-nav-options" });
1395
+ fields.forEach(function(each) {
1396
+ body.appendChild(each.row);
1397
+ });
1398
+ var render = function() {
1399
+ fields.forEach(function(each) {
1400
+ each.render();
1401
+ });
1402
+ };
1403
+ render();
1404
+ kept.add({ node, element: body, render });
1405
+ return { labelKey: SECTION_KEYS[kind].labelKey, body };
1406
+ },
1407
+ /** Every section open, filled again from the markup. */
1408
+ refresh: function() {
1409
+ kept.render();
1410
+ },
1411
+ onRefresh: function(scope) {
1412
+ kept.render(scope);
1413
+ },
1414
+ onDeinit: function() {
1415
+ kept.clear();
1416
+ },
1417
+ onDestroy: function() {
1418
+ context.destroyed = true;
1419
+ }
1420
+ };
1421
+ }
1422
+
1423
+ // src/js/nav/canvas.js
1424
+ function loadedFor(ge) {
1425
+ return function(type) {
1426
+ return TYPES.indexOf(type) !== -1 && !!GridEditor.containers[type] && (!ge.settings.plugins || ge.settings.plugins.indexOf(type) !== -1);
1427
+ };
1428
+ }
1429
+ function guardLinks(ge, loaded) {
1430
+ var listening = null;
1431
+ return {
1432
+ start: function() {
1433
+ if (listening) {
1434
+ listening.abort();
1435
+ }
1436
+ listening = new AbortController();
1437
+ delegate(ge.canvas, "click", "a", function(e) {
1438
+ var holder = this.closest('[data-ge-container], [data-ge-nav="zone"]');
1439
+ if (holder && !isZone(holder) && loaded(typeOf(holder))) {
1440
+ e.preventDefault();
1441
+ }
1442
+ }, { signal: listening.signal });
1443
+ },
1444
+ stop: function() {
1445
+ if (listening) {
1446
+ listening.abort();
1447
+ }
1448
+ listening = null;
1449
+ }
1450
+ };
1451
+ }
1452
+ var STATE_ATTRIBUTES = ["class", "style", "aria-expanded", "aria-hidden", "aria-modal", "role", "data-bs-popper"];
1453
+ function stateOf(node) {
1454
+ var state = {};
1455
+ STATE_ATTRIBUTES.forEach(function(name) {
1456
+ state[name] = node.getAttribute(name);
1457
+ });
1458
+ return state;
1459
+ }
1460
+ function putState(node, state) {
1461
+ STATE_ATTRIBUTES.forEach(function(name) {
1462
+ node.getAttribute(name);
1463
+ if (state[name] === null) {
1464
+ node.removeAttribute(name);
1465
+ } else {
1466
+ node.setAttribute(name, state[name]);
1467
+ }
1468
+ });
1469
+ }
1470
+ function isOffcanvas(node) {
1471
+ return Array.prototype.some.call(node.classList, function(name) {
1472
+ return name === "offcanvas" || /^offcanvas-(sm|md|lg|xl|xxl)$/.test(name);
1473
+ });
1474
+ }
1475
+ function closer(node) {
1476
+ var bootstrap = window.bootstrap;
1477
+ if (!bootstrap) {
1478
+ return null;
1479
+ }
1480
+ var name = hasClass(node, "dropdown-menu") ? "Dropdown" : isOffcanvas(node) ? "Offcanvas" : "Collapse";
1481
+ var target = name === "Dropdown" ? node.previousElementSibling : node;
1482
+ var instance = target && bootstrap[name] && bootstrap[name].getInstance ? bootstrap[name].getInstance(target) : null;
1483
+ return instance ? { instance, target, event: "hidden.bs." + name.toLowerCase() } : null;
1484
+ }
1485
+ function previewFor(ge, type) {
1486
+ var found = /* @__PURE__ */ new Map();
1487
+ function containers() {
1488
+ return all(ge.canvas, '[data-ge-container="' + type + '"]');
1489
+ }
1490
+ return function(previewing) {
1491
+ if (previewing) {
1492
+ containers().forEach(function(container) {
1493
+ all(container, '.navbar-collapse, .collapse, .offcanvas, [class*="offcanvas-"], .dropdown-menu, [aria-expanded]').filter(function(node) {
1494
+ return isOwn(container, node);
1495
+ }).forEach(function(node) {
1496
+ if (!found.has(node)) {
1497
+ found.set(node, stateOf(node));
1498
+ }
1499
+ });
1500
+ togglesOf(container).forEach(function(node) {
1501
+ ge.resumeToggles(node);
1502
+ });
1503
+ });
1504
+ return;
1505
+ }
1506
+ var left = Array.from(found.entries());
1507
+ var waiting = 0;
1508
+ var restored = false;
1509
+ var restoreAll = function() {
1510
+ if (restored) {
1511
+ return;
1512
+ }
1513
+ restored = true;
1514
+ left.forEach(function(entry) {
1515
+ putState(entry[0], entry[1]);
1516
+ });
1517
+ };
1518
+ left.forEach(function(entry) {
1519
+ var close = hasClass(entry[0], "show") ? closer(entry[0]) : null;
1520
+ if (!close) {
1521
+ return;
1522
+ }
1523
+ waiting++;
1524
+ close.target.addEventListener(close.event, function() {
1525
+ waiting--;
1526
+ if (!waiting) {
1527
+ restoreAll();
1528
+ }
1529
+ }, { once: true });
1530
+ close.instance.hide();
1531
+ });
1532
+ found = /* @__PURE__ */ new Map();
1533
+ if (waiting) {
1534
+ window.setTimeout(restoreAll, 1500);
1535
+ } else {
1536
+ restoreAll();
1537
+ }
1538
+ containers().forEach(function(container) {
1539
+ togglesOf(container).forEach(function(node) {
1540
+ ge.suspendToggles(node);
1541
+ });
1542
+ });
1543
+ };
1544
+ }
1545
+ function containerBase(ge, type) {
1546
+ var loaded = loadedFor(ge);
1547
+ return {
1548
+ loaded,
1549
+ mark: function(container) {
1550
+ markContainer(ge, container, loaded);
1551
+ },
1552
+ unmark: function(container) {
1553
+ unmarkContainer(ge, container);
1554
+ },
1555
+ // The same on a copy of the canvas: unmark only touches markup
1556
+ cleanMarkup: function(root) {
1557
+ var definition = this;
1558
+ all(root, '[data-ge-container="' + type + '"]').forEach(function(container) {
1559
+ definition.unmark(container);
1560
+ });
1561
+ },
1562
+ tools: function(drawer, container) {
1563
+ containerTools(ge, drawer, container);
1564
+ },
1565
+ afterPaneMove: function(container, node) {
1566
+ afterMove(ge, container, node, loaded);
1567
+ },
1568
+ onPreviewChange: previewFor(ge, type)
1569
+ };
1570
+ }
1571
+
1572
+ // src/js/nav/feature.js
1573
+ function holdsNav(node) {
1574
+ var selector = TYPES.map(function(type) {
1575
+ return '[data-ge-container="' + type + '"]';
1576
+ }).join(", ");
1577
+ return is(node, selector) || !!one(node, selector);
1578
+ }
1579
+ function registerNav() {
1580
+ if (GridEditor.features.nav) {
1581
+ return;
1582
+ }
1583
+ var factory = function(ge) {
1584
+ var loaded = loadedFor(ge);
1585
+ var panels = createPanels(ge, loaded);
1586
+ var guard = guardLinks(ge, loaded);
1587
+ return {
1588
+ kindOf: function(node) {
1589
+ return kindOf(node, loaded);
1590
+ },
1591
+ // A free zone is a list rows go in, as a section is
1592
+ regions: '[data-ge-nav="zone"]',
1593
+ /**
1594
+ * A zone takes rows and nothing else, and no navbar or sidenav
1595
+ * at any depth: not in it, not in a column of it, and not in a
1596
+ * row that holds one.
1597
+ */
1598
+ accepts: function(region, node) {
1599
+ if (isZone(region) && !is(node, ".row")) {
1600
+ return false;
1601
+ }
1602
+ if (region.closest && region.closest('[data-ge-nav="zone"]') && holdsNav(node)) {
1603
+ return false;
1604
+ }
1605
+ return true;
1606
+ },
1607
+ panelSection: function(node, kind) {
1608
+ return panels.pieceSection(node, kind);
1609
+ },
1610
+ kindLabel: function(kind) {
1611
+ return SECTION_KEYS[kind] ? ge.t(SECTION_KEYS[kind].labelKey) : null;
1612
+ },
1613
+ // What moves: the lists, texts and zones of an area, the links and
1614
+ // dropdowns of a list, and the items of a menu, each among its own
1615
+ onSortable: function(sortable) {
1616
+ var holders = [];
1617
+ var lists = [];
1618
+ var menus = [];
1619
+ all(ge.canvas, "[data-ge-container]").forEach(function(container) {
1620
+ if (!loaded(typeOf(container))) {
1621
+ return;
1622
+ }
1623
+ var holder = holderOf(container);
1624
+ if (holder) {
1625
+ holders.push(holder);
1626
+ }
1627
+ piecesOf(container, loaded).forEach(function(each) {
1628
+ if (each.kind === "nav-list") {
1629
+ lists.push(each.node);
1630
+ }
1631
+ if (each.kind === "nav-dropdown") {
1632
+ menus.push(menuOf(each.node));
1633
+ }
1634
+ });
1635
+ });
1636
+ sortable(holders, { draggable: ".ge-nav-list, .ge-nav-text, .ge-nav-zone", group: "nav-block" });
1637
+ sortable(lists, { draggable: ".ge-nav-link, .ge-nav-dropdown", group: "nav-item" });
1638
+ sortable(menus.filter(Boolean), { draggable: ".ge-nav-menu-item", group: "nav-menu-item" });
1639
+ },
1640
+ onInit: function() {
1641
+ guard.start();
1642
+ },
1643
+ onDeinit: function() {
1644
+ guard.stop();
1645
+ panels.onDeinit();
1646
+ },
1647
+ // Nothing of the feature's is in the markup
1648
+ cleanMarkup: function() {
1649
+ },
1650
+ onRefresh: function(scope) {
1651
+ panels.onRefresh(scope);
1652
+ },
1653
+ onDestroy: function() {
1654
+ panels.onDestroy();
1655
+ }
1656
+ };
1657
+ };
1658
+ factory.always = true;
1659
+ GridEditor.features.nav = factory;
1660
+ }
1661
+
1662
+ // src/js/plugins/grideditor.sidenav.js
1663
+ Object.assign(GridEditor.locales.en, EN, { "container.add_sidenav": "Sidebar" });
1664
+ registerNav();
1665
+ var BACKGROUNDS = BACKGROUND_CHOICES.map(function(each) {
1666
+ return each.value;
1667
+ });
1668
+ var FULL_HEIGHT = "vh-100 sticky-top overflow-y-auto";
1669
+ var DEFAULTS = {
1670
+ width: "280px",
1671
+ bg: "body-tertiary",
1672
+ theme: null,
1673
+ style: "pills",
1674
+ full_height: false,
1675
+ responsive: null
1676
+ };
1677
+ GridEditor.containers.sidenav = function(ge) {
1678
+ var base = containerBase(ge, "sidenav");
1679
+ var baseMark = base.mark;
1680
+ var BREAKPOINTS = ge.breakpoints.filter(function(key) {
1681
+ return key !== "xs";
1682
+ });
1683
+ var sections = sectionsOf();
1684
+ var VALUES = {
1685
+ bg: [null].concat(BACKGROUNDS),
1686
+ theme: [null, "light", "dark"],
1687
+ style: ["pills", "plain"],
1688
+ responsive: [null].concat(BREAKPOINTS)
1689
+ };
1690
+ function widthOk(panel, value) {
1691
+ return typeof value === "string" && value.trim() !== "" && ge.setHostStyle(panel, "width", value) !== false;
1692
+ }
1693
+ function chosen(options, key, panel) {
1694
+ var setting = ge.settings.sidenav || {};
1695
+ var value = options[key] !== void 0 ? options[key] : setting[key];
1696
+ if (value === void 0) {
1697
+ return DEFAULTS[key];
1698
+ }
1699
+ if (key === "width") {
1700
+ if (widthOk(panel, value)) {
1701
+ return value;
1702
+ }
1703
+ ge.warn("sidenav: " + JSON.stringify(value) + " is not a width: " + JSON.stringify(DEFAULTS.width) + " is used");
1704
+ return DEFAULTS.width;
1705
+ }
1706
+ var valid = key === "full_height" ? typeof value === "boolean" : VALUES[key].indexOf(value) !== -1;
1707
+ if (valid) {
1708
+ return value;
1709
+ }
1710
+ ge.warn("sidenav: " + JSON.stringify(value) + " is not a " + key + ", which takes " + JSON.stringify(key === "full_height" ? [true, false] : VALUES[key]) + ": " + JSON.stringify(DEFAULTS[key]) + " is used");
1711
+ return DEFAULTS[key];
1712
+ }
1713
+ function brandOf(options) {
1714
+ var brand = options.brand;
1715
+ if (brand === void 0) {
1716
+ return ge.t("container.sidenav_brand");
1717
+ }
1718
+ if (brand === false || typeof brand === "string" && brand !== "") {
1719
+ return brand;
1720
+ }
1721
+ ge.warn("sidenav: " + JSON.stringify(brand) + " is not a brand, which takes a text or false: " + JSON.stringify(ge.t("container.sidenav_brand")) + " is used");
1722
+ return ge.t("container.sidenav_brand");
1723
+ }
1724
+ function offcanvasClassOf(panel) {
1725
+ return Array.prototype.filter.call(panel.classList, function(name) {
1726
+ return /^offcanvas-(sm|md|lg|xl|xxl)$/.test(name);
1727
+ })[0] || null;
1728
+ }
1729
+ function read(container) {
1730
+ var panel = panelOf(container);
1731
+ var lists = children(panel, "ul.nav");
1732
+ var bg = BACKGROUNDS.filter(function(name) {
1733
+ return hasClass(panel, "bg-" + name);
1734
+ })[0];
1735
+ var responsive = offcanvasClassOf(panel);
1736
+ return {
1737
+ brand: !!child(panel, 'a[data-ge-nav="brand"]'),
1738
+ width: ge.hostStyle(panel, "width").value,
1739
+ bg: bg === void 0 ? null : bg,
1740
+ theme: panel.getAttribute("data-bs-theme") || null,
1741
+ style: lists.length && !hasClass(lists[0], "nav-pills") ? "plain" : "pills",
1742
+ full_height: hasClass(panel, "vh-100"),
1743
+ responsive: responsive ? responsive.slice(10) : null
1744
+ };
1745
+ }
1746
+ function makeTrigger(id, breakpoint, label) {
1747
+ return element("button", {
1748
+ "class": "btn btn-outline-secondary d-" + breakpoint + "-none",
1749
+ type: "button",
1750
+ "data-bs-toggle": "offcanvas",
1751
+ "data-bs-target": "#" + id,
1752
+ "aria-controls": id
1753
+ }, label);
1754
+ }
1755
+ function makeHeader(id) {
1756
+ var header = element("div", { "class": "offcanvas-header" });
1757
+ header.appendChild(element(
1758
+ "h5",
1759
+ { "class": "offcanvas-title", id: id + "-label" },
1760
+ ge.t("container.sidenav_offcanvas_title")
1761
+ ));
1762
+ header.appendChild(element("button", {
1763
+ type: "button",
1764
+ "class": "btn-close",
1765
+ "data-bs-dismiss": "offcanvas",
1766
+ "data-bs-target": "#" + id,
1767
+ "aria-label": ge.t("container.nav_close")
1768
+ }));
1769
+ return header;
1770
+ }
1771
+ function setResponsive(container, value, label) {
1772
+ var panel = panelOf(container);
1773
+ var before = offcanvasClassOf(panel);
1774
+ var trigger = triggerOf(container);
1775
+ var id = panel.id || ge.containerId("sidenav");
1776
+ if (before) {
1777
+ removeClass(panel, before);
1778
+ }
1779
+ if (value === null) {
1780
+ removeClass(panel, "offcanvas-start");
1781
+ ["id", "tabindex", "aria-labelledby"].forEach(function(name) {
1782
+ panel.removeAttribute(name);
1783
+ });
1784
+ children(panel, ".offcanvas-header").forEach(function(header) {
1785
+ header.remove();
1786
+ });
1787
+ if (trigger) {
1788
+ trigger.remove();
1789
+ }
1790
+ dropEmptyClass(panel);
1791
+ return;
1792
+ }
1793
+ addClass(panel, "offcanvas-" + value);
1794
+ addClass(panel, "offcanvas-start");
1795
+ panel.setAttribute("id", id);
1796
+ panel.setAttribute("tabindex", "-1");
1797
+ panel.setAttribute("aria-labelledby", id + "-label");
1798
+ if (!child(panel, ".offcanvas-header")) {
1799
+ panel.insertBefore(makeHeader(id), panel.firstChild);
1800
+ }
1801
+ if (trigger) {
1802
+ removeClass(trigger, before ? "d-" + before.slice(10) + "-none" : "");
1803
+ addClass(trigger, "d-" + value + "-none");
1804
+ } else {
1805
+ container.insertBefore(makeTrigger(id, value, label || ge.t("container.sidenav_trigger")), panel);
1806
+ }
1807
+ }
1808
+ function setBrand(container, text2) {
1809
+ var panel = panelOf(container);
1810
+ var brand = child(panel, 'a[data-ge-nav="brand"]');
1811
+ if (text2 === false) {
1812
+ if (brand) {
1813
+ brand.remove();
1814
+ }
1815
+ return;
1816
+ }
1817
+ if (brand) {
1818
+ return;
1819
+ }
1820
+ var after = child(panel, ".offcanvas-header");
1821
+ var made = element("a", {
1822
+ "class": "d-flex align-items-center mb-3 link-body-emphasis text-decoration-none fs-4",
1823
+ href: "#",
1824
+ "data-ge-nav": "brand"
1825
+ }, text2);
1826
+ panel.insertBefore(made, after ? after.nextSibling : panel.firstChild);
1827
+ }
1828
+ function write(container, key, value, label) {
1829
+ var panel = panelOf(container);
1830
+ if (key === "width") {
1831
+ ge.setHostStyle(panel, "width", value);
1832
+ }
1833
+ if (key === "bg") {
1834
+ Array.prototype.filter.call(panel.classList, function(name) {
1835
+ return /^bg-/.test(name);
1836
+ }).forEach(function(name) {
1837
+ panel.classList.remove(name);
1838
+ });
1839
+ if (value !== null) {
1840
+ addClass(panel, "bg-" + value);
1841
+ }
1842
+ }
1843
+ if (key === "theme") {
1844
+ if (value === null) {
1845
+ panel.removeAttribute("data-bs-theme");
1846
+ } else {
1847
+ panel.setAttribute("data-bs-theme", value);
1848
+ }
1849
+ }
1850
+ if (key === "style") {
1851
+ children(panel, "ul.nav").forEach(function(list2) {
1852
+ toggleClass(list2, "nav-pills", value === "pills");
1853
+ });
1854
+ }
1855
+ if (key === "full_height") {
1856
+ toggleClass(panel, FULL_HEIGHT, value);
1857
+ dropEmptyClass(panel);
1858
+ }
1859
+ if (key === "responsive") {
1860
+ setResponsive(container, value, label);
1861
+ }
1862
+ if (key === "brand") {
1863
+ setBrand(container, value);
1864
+ }
1865
+ }
1866
+ function createSection(container) {
1867
+ var body = element("div", { "class": "ge-nav-options" });
1868
+ var fields = {};
1869
+ function change(key, value) {
1870
+ write(container, key, value);
1871
+ baseMark(container);
1872
+ sections.render();
1873
+ }
1874
+ function select(name, label, choices, onChange) {
1875
+ var field = selectControl(choices, onChange);
1876
+ fields[name] = field.control;
1877
+ body.appendChild(fieldRow(name, label, field.control, field.id));
1878
+ }
1879
+ var brand = checkControl(ge.t("container.nav_brand_show"), function(on) {
1880
+ write(container, "brand", on ? ge.t("container.sidenav_brand") : false);
1881
+ baseMark(container);
1882
+ sections.render();
1883
+ });
1884
+ brand.box.setAttribute("data-ge-nav-option", "brand");
1885
+ body.appendChild(brand.box);
1886
+ var width = textControl(function(value) {
1887
+ var panel = panelOf(container);
1888
+ var valid = widthOk(panel, value);
1889
+ markInvalid(width.control, !valid);
1890
+ });
1891
+ fields.width = width.control;
1892
+ body.appendChild(fieldRow("width", ge.t("container.sidenav_width"), width.control, width.id));
1893
+ select("bg", ge.t("container.nav_bg"), [{ value: "none", label: ge.t("container.nav_bg_none") }].concat(
1894
+ BACKGROUND_CHOICES.map(function(each) {
1895
+ return { value: each.value, label: ge.t(each.labelKey) };
1896
+ })
1897
+ ), function(value) {
1898
+ change("bg", value === "none" ? null : value);
1899
+ });
1900
+ select("theme", ge.t("container.nav_theme"), [
1901
+ { value: "auto", label: ge.t("container.nav_theme_auto") },
1902
+ { value: "light", label: ge.t("container.nav_theme_light") },
1903
+ { value: "dark", label: ge.t("container.nav_theme_dark") }
1904
+ ], function(value) {
1905
+ change("theme", value === "auto" ? null : value);
1906
+ });
1907
+ select("style", ge.t("container.sidenav_style"), [
1908
+ { value: "pills", label: ge.t("container.sidenav_style_pills") },
1909
+ { value: "plain", label: ge.t("container.sidenav_style_plain") }
1910
+ ], function(value) {
1911
+ change("style", value);
1912
+ });
1913
+ var full = checkControl(ge.t("container.sidenav_full_height"), function(on) {
1914
+ change("full_height", on);
1915
+ });
1916
+ full.box.setAttribute("data-ge-nav-option", "full_height");
1917
+ body.appendChild(full.box);
1918
+ select("responsive", ge.t("container.sidenav_responsive"), [
1919
+ { value: "never", label: ge.t("container.sidenav_responsive_never") }
1920
+ ].concat(BREAKPOINTS.map(function(key) {
1921
+ return { value: key, label: ge.t("container.sidenav_responsive_from", { breakpoint: key }) };
1922
+ })), function(value) {
1923
+ change("responsive", value === "never" ? null : value);
1924
+ });
1925
+ function render() {
1926
+ var values = read(container);
1927
+ brand.input.checked = values.brand;
1928
+ width.control.value = values.width;
1929
+ markInvalid(width.control, false);
1930
+ fields.bg.value = values.bg === null ? "none" : values.bg;
1931
+ fields.theme.value = values.theme === null ? "auto" : values.theme;
1932
+ fields.style.value = values.style;
1933
+ full.input.checked = values.full_height;
1934
+ fields.responsive.value = values.responsive === null ? "never" : values.responsive;
1935
+ }
1936
+ render();
1937
+ sections.add({ node: container, element: body, render });
1938
+ return body;
1939
+ }
1940
+ return Object.assign(base, {
1941
+ labelKey: "container.add_sidenav",
1942
+ create: function(options) {
1943
+ options = options || {};
1944
+ var container = element("div", { "data-ge-container": "sidenav" });
1945
+ var panel = container.appendChild(element("div", { "class": "d-flex flex-column flex-shrink-0 p-3" }));
1946
+ var width = chosen(options, "width", panel);
1947
+ var pills = chosen(options, "style") === "pills";
1948
+ var brand = brandOf(options);
1949
+ ge.setHostStyle(panel, "width", width);
1950
+ if (brand !== false) {
1951
+ setBrand(container, brand);
1952
+ }
1953
+ panel.appendChild(list(ge, "sidenav", pills, 3));
1954
+ write(container, "bg", chosen(options, "bg"));
1955
+ write(container, "theme", chosen(options, "theme"));
1956
+ write(container, "full_height", chosen(options, "full_height"));
1957
+ write(
1958
+ container,
1959
+ "responsive",
1960
+ chosen(options, "responsive"),
1961
+ typeof options.trigger_label === "string" && options.trigger_label !== "" ? options.trigger_label : void 0
1962
+ );
1963
+ return container;
1964
+ },
1965
+ panelSection: function(node, kind) {
1966
+ if (kind !== "sidenav" || !panelOf(node)) {
1967
+ return null;
1968
+ }
1969
+ return { labelKey: "container.sidenav_section", body: createSection(node) };
1970
+ },
1971
+ onRefresh: function(scope) {
1972
+ sections.render(scope);
1973
+ },
1974
+ onDeinit: function() {
1975
+ sections.clear();
1976
+ }
1977
+ });
1978
+ };
1979
+ })();