@themarioga/grid-editor 9.2.5 → 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 +51 -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 +29 -6
  7. package/dist/grideditor.js +29 -6
  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 +27 -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 +43 -5
  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,349 @@
1
+ /**
2
+ * Sidebars for grid-editor: a vertical navigation, as in Bootstrap's
3
+ * Sidebars example.
4
+ *
5
+ * A container plugin: load this file after the editor and the toolbar offers
6
+ * a sidebar - a brand, lists of links, dropdowns or collapsible submenus,
7
+ * texts and free zones of rows and columns - that below a breakpoint of your
8
+ * choice becomes an offcanvas a button opens. It is called `sidenav` because
9
+ * the editor's `sidebar` setting is its own settings panel.
10
+ *
11
+ * <script src="dist/grideditor.min.js"></script>
12
+ * <script src="dist/plugins/grideditor.sidenav.min.js"></script>
13
+ *
14
+ * It is edited as the navbar plugin's navbar is: every piece has a drawer,
15
+ * its text is renamed where it stands, and its options are in the settings
16
+ * panel.
17
+ *
18
+ * new GridEditor('#myGrid', { sidenav: { width: '20rem', responsive: 'lg' } });
19
+ * ge.createContainer('sidenav', { brand: 'ACME', full_height: true });
20
+ */
21
+ import { GridEditor } from '../grideditor.js';
22
+ import * as dom from '../dom.js';
23
+ import { EN, BACKGROUND_CHOICES } from '../nav/locale.js';
24
+ import * as pieces from '../nav/pieces.js';
25
+ import * as markup from '../nav/markup.js';
26
+ import { registerNav } from '../nav/feature.js';
27
+ import { containerBase } from '../nav/canvas.js';
28
+ import { fieldRow, selectControl, checkControl, textControl, markInvalid, sectionsOf } from '../nav/panels.js';
29
+
30
+ Object.assign(GridEditor.locales.en, EN, { 'container.add_sidenav': 'Sidebar' });
31
+
32
+ registerNav();
33
+
34
+ var BACKGROUNDS = BACKGROUND_CHOICES.map(function(each) { return each.value; });
35
+ var FULL_HEIGHT = 'vh-100 sticky-top overflow-y-auto';
36
+
37
+ /** What a sidenav made new has when neither the call nor the setting says. */
38
+ var DEFAULTS = {
39
+ width: '280px',
40
+ bg: 'body-tertiary',
41
+ theme: null,
42
+ style: 'pills',
43
+ full_height: false,
44
+ responsive: null,
45
+ };
46
+
47
+ GridEditor.containers.sidenav = function(ge) {
48
+ var base = containerBase(ge, 'sidenav');
49
+ var baseMark = base.mark;
50
+ var BREAKPOINTS = ge.breakpoints.filter(function(key) { return key !== 'xs'; });
51
+ var sections = sectionsOf();
52
+
53
+ var VALUES = {
54
+ bg: [null].concat(BACKGROUNDS),
55
+ theme: [null, 'light', 'dark'],
56
+ style: ['pills', 'plain'],
57
+ responsive: [null].concat(BREAKPOINTS),
58
+ };
59
+
60
+ /** A width the browser takes: a text that is not blank, and that `width` accepts. */
61
+ function widthOk(panel, value) {
62
+ return typeof value === 'string' && value.trim() !== '' && ge.setHostStyle(panel, 'width', value) !== false;
63
+ }
64
+
65
+ /**
66
+ * A value for a new sidenav: the option, or the sidenav setting, or the
67
+ * default. One the option does not take is warned about and the default
68
+ * used.
69
+ */
70
+ function chosen(options, key, panel) {
71
+ var setting = ge.settings.sidenav || {};
72
+ var value = options[key] !== undefined ? options[key] : setting[key];
73
+
74
+ if (value === undefined) { return DEFAULTS[key]; }
75
+
76
+ if (key === 'width') {
77
+ if (widthOk(panel, value)) { return value; }
78
+
79
+ ge.warn('sidenav: ' + JSON.stringify(value) + ' is not a width: ' + JSON.stringify(DEFAULTS.width) + ' is used');
80
+ return DEFAULTS.width;
81
+ }
82
+
83
+ var valid = key === 'full_height' ? typeof value === 'boolean' : VALUES[key].indexOf(value) !== -1;
84
+ if (valid) { return value; }
85
+
86
+ ge.warn('sidenav: ' + JSON.stringify(value) + ' is not a ' + key + ', which takes ' +
87
+ JSON.stringify(key === 'full_height' ? [true, false] : VALUES[key]) + ': ' + JSON.stringify(DEFAULTS[key]) + ' is used');
88
+ return DEFAULTS[key];
89
+ }
90
+
91
+ function brandOf(options) {
92
+ var brand = options.brand;
93
+
94
+ if (brand === undefined) { return ge.t('container.sidenav_brand'); }
95
+ if (brand === false || (typeof brand === 'string' && brand !== '')) { return brand; }
96
+
97
+ ge.warn('sidenav: ' + JSON.stringify(brand) + ' is not a brand, which takes a text or false: ' +
98
+ JSON.stringify(ge.t('container.sidenav_brand')) + ' is used');
99
+ return ge.t('container.sidenav_brand');
100
+ }
101
+
102
+ function offcanvasClassOf(panel) {
103
+ return Array.prototype.filter.call(panel.classList, function(name) {
104
+ return /^offcanvas-(sm|md|lg|xl|xxl)$/.test(name);
105
+ })[0] || null;
106
+ }
107
+
108
+ /** What a sidenav's classes say it is. */
109
+ function read(container) {
110
+ var panel = pieces.panelOf(container);
111
+ var lists = dom.children(panel, 'ul.nav');
112
+ var bg = BACKGROUNDS.filter(function(name) { return dom.hasClass(panel, 'bg-' + name); })[0];
113
+ var responsive = offcanvasClassOf(panel);
114
+
115
+ return {
116
+ brand: !!dom.child(panel, 'a[data-ge-nav="brand"]'),
117
+ width: ge.hostStyle(panel, 'width').value,
118
+ bg: bg === undefined ? null : bg,
119
+ theme: panel.getAttribute('data-bs-theme') || null,
120
+ style: lists.length && !dom.hasClass(lists[0], 'nav-pills') ? 'plain' : 'pills',
121
+ full_height: dom.hasClass(panel, 'vh-100'),
122
+ responsive: responsive ? responsive.slice(10) : null,
123
+ };
124
+ }
125
+
126
+ function makeTrigger(id, breakpoint, label) {
127
+ return dom.element('button', {
128
+ 'class': 'btn btn-outline-secondary d-' + breakpoint + '-none',
129
+ type: 'button',
130
+ 'data-bs-toggle': 'offcanvas',
131
+ 'data-bs-target': '#' + id,
132
+ 'aria-controls': id,
133
+ }, label);
134
+ }
135
+
136
+ function makeHeader(id) {
137
+ var header = dom.element('div', { 'class': 'offcanvas-header' });
138
+
139
+ header.appendChild(dom.element('h5', { 'class': 'offcanvas-title', id: id + '-label' },
140
+ ge.t('container.sidenav_offcanvas_title')));
141
+ header.appendChild(dom.element('button', {
142
+ type: 'button',
143
+ 'class': 'btn-close',
144
+ 'data-bs-dismiss': 'offcanvas',
145
+ 'data-bs-target': '#' + id,
146
+ 'aria-label': ge.t('container.nav_close'),
147
+ }));
148
+
149
+ return header;
150
+ }
151
+
152
+ /** The panel an offcanvas below `value`, or a panel that is always there. */
153
+ function setResponsive(container, value, label) {
154
+ var panel = pieces.panelOf(container);
155
+ var before = offcanvasClassOf(panel);
156
+ var trigger = pieces.triggerOf(container);
157
+ var id = panel.id || ge.containerId('sidenav');
158
+
159
+ if (before) { dom.removeClass(panel, before); }
160
+
161
+ if (value === null) {
162
+ dom.removeClass(panel, 'offcanvas-start');
163
+ ['id', 'tabindex', 'aria-labelledby'].forEach(function(name) { panel.removeAttribute(name); });
164
+ dom.children(panel, '.offcanvas-header').forEach(function(header) { header.remove(); });
165
+ if (trigger) { trigger.remove(); }
166
+ dom.dropEmptyClass(panel);
167
+ return;
168
+ }
169
+
170
+ dom.addClass(panel, 'offcanvas-' + value);
171
+ dom.addClass(panel, 'offcanvas-start');
172
+ panel.setAttribute('id', id);
173
+ panel.setAttribute('tabindex', '-1');
174
+ panel.setAttribute('aria-labelledby', id + '-label');
175
+
176
+ if (!dom.child(panel, '.offcanvas-header')) { panel.insertBefore(makeHeader(id), panel.firstChild); }
177
+
178
+ if (trigger) {
179
+ dom.removeClass(trigger, before ? 'd-' + before.slice(10) + '-none' : '');
180
+ dom.addClass(trigger, 'd-' + value + '-none');
181
+ } else {
182
+ container.insertBefore(makeTrigger(id, value, label || ge.t('container.sidenav_trigger')), panel);
183
+ }
184
+ }
185
+
186
+ function setBrand(container, text) {
187
+ var panel = pieces.panelOf(container);
188
+ var brand = dom.child(panel, 'a[data-ge-nav="brand"]');
189
+
190
+ if (text === false) {
191
+ if (brand) { brand.remove(); }
192
+ return;
193
+ }
194
+ if (brand) { return; }
195
+
196
+ var after = dom.child(panel, '.offcanvas-header');
197
+ var made = dom.element('a', {
198
+ 'class': 'd-flex align-items-center mb-3 link-body-emphasis text-decoration-none fs-4',
199
+ href: '#',
200
+ 'data-ge-nav': 'brand',
201
+ }, text);
202
+
203
+ panel.insertBefore(made, after ? after.nextSibling : panel.firstChild);
204
+ }
205
+
206
+ function write(container, key, value, label) {
207
+ var panel = pieces.panelOf(container);
208
+
209
+ if (key === 'width') { ge.setHostStyle(panel, 'width', value); }
210
+
211
+ if (key === 'bg') {
212
+ Array.prototype.filter.call(panel.classList, function(name) { return /^bg-/.test(name); })
213
+ .forEach(function(name) { panel.classList.remove(name); });
214
+ if (value !== null) { dom.addClass(panel, 'bg-' + value); }
215
+ }
216
+
217
+ if (key === 'theme') {
218
+ if (value === null) { panel.removeAttribute('data-bs-theme'); } else { panel.setAttribute('data-bs-theme', value); }
219
+ }
220
+
221
+ if (key === 'style') {
222
+ dom.children(panel, 'ul.nav').forEach(function(list) { dom.toggleClass(list, 'nav-pills', value === 'pills'); });
223
+ }
224
+
225
+ if (key === 'full_height') {
226
+ dom.toggleClass(panel, FULL_HEIGHT, value);
227
+ dom.dropEmptyClass(panel);
228
+ }
229
+
230
+ if (key === 'responsive') { setResponsive(container, value, label); }
231
+ if (key === 'brand') { setBrand(container, value); }
232
+ }
233
+
234
+ /** The Sidebar section of a sidenav's settings panel. */
235
+ function createSection(container) {
236
+ var body = dom.element('div', { 'class': 'ge-nav-options' });
237
+ var fields = {};
238
+
239
+ function change(key, value) {
240
+ write(container, key, value);
241
+ baseMark(container);
242
+ sections.render();
243
+ }
244
+
245
+ function select(name, label, choices, onChange) {
246
+ var field = selectControl(choices, onChange);
247
+
248
+ fields[name] = field.control;
249
+ body.appendChild(fieldRow(name, label, field.control, field.id));
250
+ }
251
+
252
+ var brand = checkControl(ge.t('container.nav_brand_show'), function(on) {
253
+ write(container, 'brand', on ? ge.t('container.sidenav_brand') : false);
254
+ baseMark(container);
255
+ sections.render();
256
+ });
257
+ brand.box.setAttribute('data-ge-nav-option', 'brand');
258
+ body.appendChild(brand.box);
259
+
260
+ var width = textControl(function(value) {
261
+ var panel = pieces.panelOf(container);
262
+ var valid = widthOk(panel, value);
263
+
264
+ markInvalid(width.control, !valid);
265
+ });
266
+ fields.width = width.control;
267
+ body.appendChild(fieldRow('width', ge.t('container.sidenav_width'), width.control, width.id));
268
+
269
+ select('bg', ge.t('container.nav_bg'), [{ value: 'none', label: ge.t('container.nav_bg_none') }].concat(
270
+ BACKGROUND_CHOICES.map(function(each) { return { value: each.value, label: ge.t(each.labelKey) }; })
271
+ ), function(value) { change('bg', value === 'none' ? null : value); });
272
+
273
+ select('theme', ge.t('container.nav_theme'), [
274
+ { value: 'auto', label: ge.t('container.nav_theme_auto') },
275
+ { value: 'light', label: ge.t('container.nav_theme_light') },
276
+ { value: 'dark', label: ge.t('container.nav_theme_dark') },
277
+ ], function(value) { change('theme', value === 'auto' ? null : value); });
278
+
279
+ select('style', ge.t('container.sidenav_style'), [
280
+ { value: 'pills', label: ge.t('container.sidenav_style_pills') },
281
+ { value: 'plain', label: ge.t('container.sidenav_style_plain') },
282
+ ], function(value) { change('style', value); });
283
+
284
+ var full = checkControl(ge.t('container.sidenav_full_height'), function(on) { change('full_height', on); });
285
+ full.box.setAttribute('data-ge-nav-option', 'full_height');
286
+ body.appendChild(full.box);
287
+
288
+ select('responsive', ge.t('container.sidenav_responsive'), [
289
+ { value: 'never', label: ge.t('container.sidenav_responsive_never') },
290
+ ].concat(BREAKPOINTS.map(function(key) {
291
+ return { value: key, label: ge.t('container.sidenav_responsive_from', { breakpoint: key }) };
292
+ })), function(value) { change('responsive', value === 'never' ? null : value); });
293
+
294
+ function render() {
295
+ var values = read(container);
296
+
297
+ brand.input.checked = values.brand;
298
+ width.control.value = values.width;
299
+ markInvalid(width.control, false);
300
+ fields.bg.value = values.bg === null ? 'none' : values.bg;
301
+ fields.theme.value = values.theme === null ? 'auto' : values.theme;
302
+ fields.style.value = values.style;
303
+ full.input.checked = values.full_height;
304
+ fields.responsive.value = values.responsive === null ? 'never' : values.responsive;
305
+ }
306
+
307
+ render();
308
+ sections.add({ node: container, element: body, render: render });
309
+
310
+ return body;
311
+ }
312
+
313
+ return Object.assign(base, {
314
+ labelKey: 'container.add_sidenav',
315
+
316
+ create: function(options) {
317
+ options = options || {};
318
+
319
+ var container = dom.element('div', { 'data-ge-container': 'sidenav' });
320
+ var panel = container.appendChild(dom.element('div', { 'class': 'd-flex flex-column flex-shrink-0 p-3' }));
321
+
322
+ var width = chosen(options, 'width', panel);
323
+ var pills = chosen(options, 'style') === 'pills';
324
+ var brand = brandOf(options);
325
+
326
+ ge.setHostStyle(panel, 'width', width);
327
+ if (brand !== false) { setBrand(container, brand); }
328
+ panel.appendChild(markup.list(ge, 'sidenav', pills, 3));
329
+
330
+ write(container, 'bg', chosen(options, 'bg'));
331
+ write(container, 'theme', chosen(options, 'theme'));
332
+ write(container, 'full_height', chosen(options, 'full_height'));
333
+ write(container, 'responsive', chosen(options, 'responsive'),
334
+ typeof options.trigger_label === 'string' && options.trigger_label !== '' ? options.trigger_label : undefined);
335
+
336
+ return container;
337
+ },
338
+
339
+ panelSection: function(node, kind) {
340
+ if (kind !== 'sidenav' || !pieces.panelOf(node)) { return null; }
341
+
342
+ return { labelKey: 'container.sidenav_section', body: createSection(node) };
343
+ },
344
+
345
+ onRefresh: function(scope) { sections.render(scope); },
346
+
347
+ onDeinit: function() { sections.clear(); },
348
+ });
349
+ };
@@ -1325,6 +1325,205 @@ html.ge-sidebar-open {
1325
1325
  .column.ge-resizing > .ge-tools-drawer > .ge-resize-size {
1326
1326
  display: block;
1327
1327
  }
1328
+
1329
+ /* Navbars and sidenavs. Every piece has a small drawer beside its text,
1330
+ the part that folds is open and so are the menus, and nothing of
1331
+ Bootstrap's javascript is involved: what it would open on a click is
1332
+ rendered open here. */
1333
+ [data-ge-container="navbar"],
1334
+ [data-ge-container="sidenav"] {
1335
+ .ge-nav-link,
1336
+ .ge-nav-dropdown,
1337
+ .ge-nav-menu-item {
1338
+ display: flex;
1339
+ flex-wrap: wrap;
1340
+ align-items: center;
1341
+
1342
+ > a,
1343
+ > h6,
1344
+ > span,
1345
+ > hr {
1346
+ flex: 1 1 auto;
1347
+ }
1348
+ > .dropdown-menu,
1349
+ > .collapse {
1350
+ flex: 0 0 100%;
1351
+ }
1352
+ }
1353
+ .ge-nav-text,
1354
+ .ge-nav-brand {
1355
+ align-items: center;
1356
+
1357
+ > .ge-pane-drawer {
1358
+ margin-right: 4px;
1359
+ }
1360
+ }
1361
+ .ge-nav-text {
1362
+ display: inline-flex;
1363
+ }
1364
+
1365
+ /* Rows and columns in a free zone are an ordinary region */
1366
+ .ge-nav-zone {
1367
+ min-width: 10rem;
1368
+ padding: @editGutter;
1369
+ outline: 1px dashed @containerColor;
1370
+ outline-offset: -2px;
1371
+ }
1372
+
1373
+ /* A menu is shown open, in its place, and folded away with its tool */
1374
+ .ge-nav-dropdown > .dropdown-menu {
1375
+ display: block;
1376
+ position: static;
1377
+ float: none;
1378
+ transform: none;
1379
+ margin: 0;
1380
+ }
1381
+ .ge-nav-dropdown > .collapse {
1382
+ display: block;
1383
+ }
1384
+ .ge-nav-dropdown.ge-nav-folded {
1385
+ > .dropdown-menu,
1386
+ > .collapse {
1387
+ display: none;
1388
+ }
1389
+ }
1390
+ }
1391
+
1392
+ /* The part of a navbar that folds is shown open, whichever the window.
1393
+ Expanded, Bootstrap's own rules, which are !important, win */
1394
+ [data-ge-container="navbar"] {
1395
+ .navbar-collapse.collapse:not(.show) {
1396
+ display: block;
1397
+ }
1398
+
1399
+ /* An offcanvas is a block in place: Bootstrap fixes it to the
1400
+ window and hides it until its javascript shows it */
1401
+ .offcanvas {
1402
+ position: static;
1403
+ z-index: auto;
1404
+ visibility: visible;
1405
+ transform: none;
1406
+ transition: none;
1407
+ width: auto;
1408
+ height: auto;
1409
+ max-width: none;
1410
+ }
1411
+ }
1412
+
1413
+ /* A sidenav that becomes an offcanvas: the button and the panel both
1414
+ show, at any width, as the offcanvas plugin's do */
1415
+ [data-ge-container="sidenav"] {
1416
+ > button {
1417
+ display: inline-block !important;
1418
+ margin-bottom: @editGutter;
1419
+ }
1420
+ each(@ge-offcanvases, {
1421
+ > .@{value} {
1422
+ position: static;
1423
+ z-index: auto;
1424
+ visibility: visible;
1425
+ transform: none;
1426
+ transition: none;
1427
+ max-width: none;
1428
+ display: flex;
1429
+
1430
+ > .offcanvas-header {
1431
+ display: flex;
1432
+ }
1433
+ }
1434
+ });
1435
+ }
1436
+ }
1437
+
1438
+ /* A navbar kept in place by Bootstrap's fixed-* and sticky-* would cover
1439
+ the editor: on the canvas it stays where it is in the page, the preview's
1440
+ too */
1441
+ .ge-canvas [data-ge-container="navbar"] {
1442
+ &.fixed-top,
1443
+ &.fixed-bottom,
1444
+ &.sticky-top,
1445
+ &.sticky-bottom {
1446
+ position: static !important;
1447
+ }
1448
+ }
1449
+
1450
+ /* A breakpoint view narrows the canvas, not the window, and Bootstrap's
1451
+ classes answer to the window: so the navbar plugin says how the view lays
1452
+ a navbar out, and that is what shows - in the preview too. The selectors
1453
+ outweigh Bootstrap's !important utilities. In the all view there is no
1454
+ attribute, and the window decides */
1455
+ .ge-canvas {
1456
+ [data-ge-navbar-layout="collapsed"] {
1457
+ .navbar-toggler {
1458
+ display: block !important;
1459
+ }
1460
+ .navbar-collapse {
1461
+ display: none !important;
1462
+ flex-basis: 100% !important;
1463
+
1464
+ &.show,
1465
+ &.collapsing {
1466
+ display: block !important;
1467
+ }
1468
+ }
1469
+ .navbar-nav {
1470
+ flex-direction: column !important;
1471
+
1472
+ .dropdown-menu {
1473
+ position: static !important;
1474
+ }
1475
+ }
1476
+ }
1477
+ [data-ge-navbar-layout="expanded"] {
1478
+ .navbar-toggler {
1479
+ display: none !important;
1480
+ }
1481
+ .navbar-collapse {
1482
+ display: flex !important;
1483
+ flex-basis: auto !important;
1484
+ flex-grow: 1;
1485
+ }
1486
+ .navbar-nav {
1487
+ flex-direction: row !important;
1488
+ }
1489
+ }
1490
+ }
1491
+
1492
+ /* The same while editing: the part that folds is open, and an offcanvas is
1493
+ a block with its header when collapsed and plain content when expanded */
1494
+ .ge-canvas.ge-editing {
1495
+ [data-ge-navbar-layout="collapsed"] {
1496
+ .navbar-collapse {
1497
+ display: block !important;
1498
+ }
1499
+ .offcanvas {
1500
+ background-color: var(--bs-offcanvas-bg) !important;
1501
+ border: var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color) !important;
1502
+
1503
+ > .offcanvas-header {
1504
+ display: flex !important;
1505
+ }
1506
+ > .offcanvas-body {
1507
+ display: block !important;
1508
+ padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x) !important;
1509
+ }
1510
+ }
1511
+ }
1512
+ [data-ge-navbar-layout="expanded"] {
1513
+ .offcanvas {
1514
+ background-color: transparent !important;
1515
+ border-width: 0 !important;
1516
+
1517
+ > .offcanvas-header {
1518
+ display: none !important;
1519
+ }
1520
+ > .offcanvas-body {
1521
+ display: flex !important;
1522
+ flex-grow: 0;
1523
+ padding: 0 !important;
1524
+ }
1525
+ }
1526
+ }
1328
1527
  }
1329
1528
 
1330
1529
  /* drawer_overflow: 'menu'. A drawer keeps its tools to one line; the ones
@@ -140,6 +140,88 @@ export interface CreateOffcanvasOptions extends Placement, OffcanvasOptions {
140
140
  trigger_label?: string;
141
141
  }
142
142
 
143
+ /** A breakpoint a navbar or a sidenav answers to: Bootstrap has none below `sm`. */
144
+ export type NavBreakpoint = 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
145
+
146
+ /** The backgrounds a navbar and a sidenav offer: `bg-*`. */
147
+ export type NavBackground = 'body-tertiary' | 'body' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark';
148
+
149
+ /** What the browse of the navbar and sidenav plugins is told: the node the field is for, which field, and what it shows. */
150
+ export interface NavBrowseContext {
151
+ node: HTMLElement;
152
+ /** `'href'` for a link, an item or the brand; `'src'` for the brand's image. */
153
+ property: 'href' | 'src';
154
+ value: string;
155
+ }
156
+
157
+ /** The host's file browser of the navbar and sidenav plugins, with the form of `inline_style.browse`. */
158
+ export type NavBrowse = (
159
+ done: (url?: string | null) => void,
160
+ context: NavBrowseContext,
161
+ ) => void | Promise<string | null | undefined>;
162
+
163
+ /**
164
+ * The navbar plugin's options, the ones a navbar made new has, as the navbar
165
+ * setting gives them and createContainer overrides them.
166
+ */
167
+ export interface NavbarOptions {
168
+ /** From this breakpoint up it is expanded; `true` always, `false` never. Default `'lg'`. */
169
+ expand?: boolean | NavBreakpoint;
170
+ /** How it folds: a collapse, an offcanvas, or `false` for not at all. Default `'collapse'`. */
171
+ collapse?: 'collapse' | 'offcanvas' | false;
172
+ /** The edge an offcanvas comes from. Default `'end'`. */
173
+ offcanvas_placement?: 'start' | 'end';
174
+ /** `bg-*`; `null` for none. Default `'body-tertiary'`. */
175
+ bg?: NavBackground | null;
176
+ /** `data-bs-theme`. Default null. */
177
+ theme?: 'light' | 'dark' | null;
178
+ /** `fixed-*` or `sticky-*`; null for in the flow. Default null. */
179
+ position?: 'fixed-top' | 'fixed-bottom' | 'sticky-top' | 'sticky-bottom' | null;
180
+ /** The width of what is inside: `'fluid'` (`container-fluid`), `'fixed'` (`container`) or a breakpoint (`container-{bp}`). Default `'fluid'`. */
181
+ width?: 'fluid' | 'fixed' | NavBreakpoint;
182
+ }
183
+
184
+ /** The navbar setting: the options of the navbars made new, and the host's file browser. */
185
+ export interface NavbarSetting extends NavbarOptions {
186
+ browse?: NavBrowse;
187
+ }
188
+
189
+ /** createContainer('navbar', …): the options, and the brand's text or `false` for none. */
190
+ export interface CreateNavbarOptions extends Placement, NavbarOptions {
191
+ brand?: string | false;
192
+ }
193
+
194
+ /**
195
+ * The sidenav plugin's options, the ones a sidebar made new has, as the
196
+ * sidenav setting gives them and createContainer overrides them.
197
+ */
198
+ export interface SidenavOptions {
199
+ /** A css length the browser takes as a width. Default `'280px'`. */
200
+ width?: string;
201
+ /** `bg-*`; `null` for none. Default `'body-tertiary'`. */
202
+ bg?: NavBackground | null;
203
+ /** `data-bs-theme`. Default null. */
204
+ theme?: 'light' | 'dark' | null;
205
+ /** The links as pills, or plain. Default `'pills'`. */
206
+ style?: 'pills' | 'plain';
207
+ /** `vh-100 sticky-top overflow-y-auto`. Default false. */
208
+ full_height?: boolean;
209
+ /** Below this breakpoint it is an offcanvas a button opens; null for always visible. Default null. */
210
+ responsive?: NavBreakpoint | null;
211
+ }
212
+
213
+ /** The sidenav setting: the options of the sidebars made new, and the host's file browser. */
214
+ export interface SidenavSetting extends SidenavOptions {
215
+ browse?: NavBrowse;
216
+ }
217
+
218
+ /** createContainer('sidenav', …): the options, the brand's text or `false` for none, and the button's text. */
219
+ export interface CreateSidenavOptions extends Placement, SidenavOptions {
220
+ brand?: string | false;
221
+ /** The text of the button that opens a responsive sidebar. */
222
+ trigger_label?: string;
223
+ }
224
+
143
225
  /** What a file browser is told about the field it was opened from. */
144
226
  export interface InlineStyleBrowseContext {
145
227
  node: HTMLElement;
@@ -226,6 +308,10 @@ export interface GridEditorOptions {
226
308
  carousel?: CarouselOptions;
227
309
  /** The offcanvas plugin: the options of the offcanvases made new. */
228
310
  offcanvas?: OffcanvasOptions;
311
+ /** The navbar plugin: the options of the navbars made new, and `browse`. */
312
+ navbar?: NavbarSetting;
313
+ /** The sidenav plugin: the options of the sidebars made new, and `browse`. */
314
+ sidenav?: SidenavSetting;
229
315
  elements?: { enabled?: boolean | 'auto'; selector?: string; auto?: boolean; types?: ElementType[] };
230
316
  /** The autosave plugin: what is edited, kept in the browser's storage as it changes. */
231
317
  autosave?: AutosaveOptions;
@@ -594,6 +680,8 @@ export declare class GridEditor {
594
680
  createContainer(type: 'tabs', options?: CreateTabsOptions): HTMLElement | null;
595
681
  createContainer(type: 'carousel', options?: CreateCarouselOptions): HTMLElement | null;
596
682
  createContainer(type: 'offcanvas', options?: CreateOffcanvasOptions): HTMLElement | null;
683
+ createContainer(type: 'navbar', options?: CreateNavbarOptions): HTMLElement | null;
684
+ createContainer(type: 'sidenav', options?: CreateSidenavOptions): HTMLElement | null;
597
685
  createContainer(type: string, options?: Placement & Record<string, unknown>): HTMLElement | null;
598
686
  addTab(container: Target, options?: PaneOptions): HTMLElement | null;
599
687
  addAccordionItem(container: Target, options?: PaneOptions): HTMLElement | null;