@themarioga/grid-editor 7.2.0 → 8.0.0-beta.2

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 (97) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +96 -30
  3. package/UPGRADING.md +86 -0
  4. package/dist/grideditor.bundle.min.js +3 -3
  5. package/dist/grideditor.css +149 -6
  6. package/dist/grideditor.d.ts +18 -0
  7. package/dist/grideditor.esm.js +257 -48
  8. package/dist/grideditor.jquery.js +0 -13
  9. package/dist/grideditor.jquery.min.js +1 -1
  10. package/dist/grideditor.jquery.min.js.map +3 -3
  11. package/dist/grideditor.js +257 -48
  12. package/dist/grideditor.min.css +1 -1
  13. package/dist/grideditor.min.css.map +1 -1
  14. package/dist/grideditor.min.js +2 -2
  15. package/dist/grideditor.min.js.map +3 -3
  16. package/dist/locales/grideditor.es.esm.js +80 -6
  17. package/dist/locales/grideditor.es.js +80 -6
  18. package/dist/locales/grideditor.es.min.js +1 -1
  19. package/dist/locales/grideditor.es.min.js.map +2 -2
  20. package/dist/plugins/grideditor.accordion.min.js.map +2 -2
  21. package/dist/plugins/grideditor.alignment.esm.js +11 -38
  22. package/dist/plugins/grideditor.alignment.js +11 -38
  23. package/dist/plugins/grideditor.alignment.min.js +1 -1
  24. package/dist/plugins/grideditor.alignment.min.js.map +3 -3
  25. package/dist/plugins/grideditor.card.min.js.map +1 -1
  26. package/dist/plugins/grideditor.ckeditor.esm.js +0 -5
  27. package/dist/plugins/grideditor.ckeditor.js +0 -5
  28. package/dist/plugins/grideditor.ckeditor.min.js +1 -1
  29. package/dist/plugins/grideditor.ckeditor.min.js.map +3 -3
  30. package/dist/plugins/grideditor.clipboard.min.js.map +1 -1
  31. package/dist/plugins/grideditor.codemirror-inline.min.js.map +1 -1
  32. package/dist/plugins/grideditor.codemirror.min.js.map +1 -1
  33. package/dist/plugins/grideditor.elements.min.js.map +2 -2
  34. package/dist/plugins/grideditor.gutters.min.js.map +1 -1
  35. package/dist/plugins/grideditor.order.min.js.map +1 -1
  36. package/dist/plugins/grideditor.popup.min.js.map +1 -1
  37. package/dist/plugins/grideditor.sections.min.js.map +2 -2
  38. package/dist/plugins/grideditor.style.esm.js +1926 -0
  39. package/dist/plugins/grideditor.style.js +1923 -0
  40. package/dist/plugins/grideditor.style.min.js +4 -0
  41. package/dist/plugins/grideditor.style.min.js.map +7 -0
  42. package/dist/plugins/grideditor.summernote.min.js.map +2 -2
  43. package/dist/plugins/grideditor.tabs.min.js.map +2 -2
  44. package/dist/plugins/grideditor.tinymce.esm.js +1 -8
  45. package/dist/plugins/grideditor.tinymce.js +1 -8
  46. package/dist/plugins/grideditor.tinymce.min.js +1 -1
  47. package/dist/plugins/grideditor.tinymce.min.js.map +3 -3
  48. package/docs/events.md +4 -6
  49. package/docs/locale-keys.md +99 -15
  50. package/docs/plugins.md +47 -23
  51. package/example/ckeditor.html +0 -5
  52. package/example/index.html +17 -2
  53. package/example/style.html +163 -0
  54. package/example/utilities.html +21 -16
  55. package/package.json +1 -1
  56. package/src/js/dom.js +1 -2
  57. package/src/js/grideditor.jquery.js +7 -28
  58. package/src/js/grideditor.js +336 -67
  59. package/src/js/locales/grideditor.es.js +80 -6
  60. package/src/js/plugins/grideditor.alignment.js +21 -50
  61. package/src/js/plugins/grideditor.ckeditor.js +10 -23
  62. package/src/js/plugins/grideditor.style.js +185 -0
  63. package/src/js/plugins/grideditor.summernote.js +4 -5
  64. package/src/js/plugins/grideditor.tinymce.js +4 -17
  65. package/src/js/style/accordion.js +168 -0
  66. package/src/js/style/catalog.js +76 -0
  67. package/src/js/style/custom.js +84 -0
  68. package/src/js/style/display.js +229 -0
  69. package/src/js/style/drawerflow.js +118 -0
  70. package/src/js/style/fields.js +382 -0
  71. package/src/js/style/flex.js +156 -0
  72. package/src/js/{plugins/grideditor.float.js → style/float.js} +6 -16
  73. package/src/js/style/options.js +60 -0
  74. package/src/js/style/sections.js +298 -0
  75. package/src/js/{plugins/grideditor.spacing.js → style/spacing.js} +7 -19
  76. package/src/js/style/sticky.js +39 -0
  77. package/src/js/{plugins/grideditor.textalign.js → style/textalign.js} +6 -14
  78. package/src/js/text/grideditor.text.js +1 -1
  79. package/src/less/grideditor.less +151 -10
  80. package/types/grideditor.d.ts +18 -0
  81. package/dist/plugins/grideditor.float.esm.js +0 -34
  82. package/dist/plugins/grideditor.float.js +0 -41
  83. package/dist/plugins/grideditor.float.min.js +0 -1
  84. package/dist/plugins/grideditor.float.min.js.map +0 -7
  85. package/dist/plugins/grideditor.spacing.esm.js +0 -318
  86. package/dist/plugins/grideditor.spacing.js +0 -323
  87. package/dist/plugins/grideditor.spacing.min.js +0 -1
  88. package/dist/plugins/grideditor.spacing.min.js.map +0 -7
  89. package/dist/plugins/grideditor.textalign.esm.js +0 -40
  90. package/dist/plugins/grideditor.textalign.js +0 -47
  91. package/dist/plugins/grideditor.textalign.min.js +0 -1
  92. package/dist/plugins/grideditor.textalign.min.js.map +0 -7
  93. package/dist/plugins/grideditor.visibility.esm.js +0 -158
  94. package/dist/plugins/grideditor.visibility.js +0 -163
  95. package/dist/plugins/grideditor.visibility.min.js +0 -1
  96. package/dist/plugins/grideditor.visibility.min.js.map +0 -7
  97. package/src/js/plugins/grideditor.visibility.js +0 -171
@@ -0,0 +1,1923 @@
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 selfAndAll(root, selector) {
16
+ if (!root) {
17
+ return [];
18
+ }
19
+ var found = all(root, selector);
20
+ if (root.nodeType === 1 && root.matches(selector)) {
21
+ found.unshift(root);
22
+ }
23
+ return found;
24
+ }
25
+ function children(node, selector) {
26
+ if (!node) {
27
+ return [];
28
+ }
29
+ return Array.prototype.filter.call(node.children, function(each2) {
30
+ return !selector || each2.matches(selector);
31
+ });
32
+ }
33
+ function child(node, selector) {
34
+ return children(node, selector)[0] || null;
35
+ }
36
+ function is(node, selector) {
37
+ return !!node && node.nodeType === 1 && node.matches(selector);
38
+ }
39
+ function element(tag, attributes, text) {
40
+ var node = document.createElement(tag);
41
+ Object.keys(attributes || {}).forEach(function(name) {
42
+ var value = attributes[name];
43
+ if (value !== null && value !== void 0 && value !== false) {
44
+ node.setAttribute(name, value);
45
+ }
46
+ });
47
+ if (text !== void 0 && text !== null) {
48
+ node.textContent = text;
49
+ }
50
+ return node;
51
+ }
52
+ function addClass(node, names) {
53
+ split(names).forEach(function(name) {
54
+ node.classList.add(name);
55
+ });
56
+ return node;
57
+ }
58
+ function removeClass(node, names) {
59
+ split(names).forEach(function(name) {
60
+ node.classList.remove(name);
61
+ });
62
+ return node;
63
+ }
64
+ function toggleClass(node, names, state) {
65
+ split(names).forEach(function(name) {
66
+ if (state === void 0) {
67
+ node.classList.toggle(name);
68
+ } else {
69
+ node.classList.toggle(name, !!state);
70
+ }
71
+ });
72
+ return node;
73
+ }
74
+ function hasClass(node, name) {
75
+ return !!node && node.nodeType === 1 && node.classList.contains(name);
76
+ }
77
+ function split(names) {
78
+ return String(names || "").split(/\s+/).filter(Boolean);
79
+ }
80
+ function dropEmptyClass(node) {
81
+ if (!node.getAttribute("class")) {
82
+ node.removeAttribute("class");
83
+ }
84
+ return node;
85
+ }
86
+ function css(node, styles) {
87
+ Object.keys(styles).forEach(function(property) {
88
+ var value = styles[property];
89
+ if (typeof value === "number" && !UNITLESS[property]) {
90
+ value = value + "px";
91
+ }
92
+ node.style.setProperty(property, value === null || value === void 0 ? "" : String(value));
93
+ });
94
+ return node;
95
+ }
96
+ var UNITLESS = { opacity: true, "z-index": true, "flex-grow": true, "flex-shrink": true, order: true };
97
+ var defaultDisplays = {};
98
+ function defaultDisplay(node) {
99
+ var tag = node.nodeName;
100
+ if (!defaultDisplays[tag]) {
101
+ var probe = document.body.appendChild(document.createElement(tag));
102
+ defaultDisplays[tag] = getComputedStyle(probe).display;
103
+ probe.remove();
104
+ if (defaultDisplays[tag] === "none") {
105
+ defaultDisplays[tag] = "block";
106
+ }
107
+ }
108
+ return defaultDisplays[tag];
109
+ }
110
+ function show(node) {
111
+ node.style.removeProperty("display");
112
+ if (getComputedStyle(node).display === "none") {
113
+ node.style.display = defaultDisplay(node);
114
+ }
115
+ return node;
116
+ }
117
+ function hide(node) {
118
+ node.style.display = "none";
119
+ return node;
120
+ }
121
+ function toggle(node, state) {
122
+ if (state === void 0) {
123
+ state = !visible(node);
124
+ }
125
+ return state ? show(node) : hide(node);
126
+ }
127
+ function visible(node) {
128
+ return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);
129
+ }
130
+
131
+ // src/js/style/spacing.js
132
+ Object.assign(GridEditor.locales.en, {
133
+ "utility.padding": "Padding",
134
+ "utility.margin": "Margin",
135
+ "utility.side_all": "All sides",
136
+ "utility.side_x": "Left and right",
137
+ "utility.side_y": "Top and bottom",
138
+ "utility.side_t": "Top",
139
+ "utility.side_b": "Bottom",
140
+ "utility.side_s": "Start",
141
+ "utility.side_e": "End",
142
+ "utility.spacing_gutter": "A column's side padding is its gutter: changing it changes the gutter"
143
+ });
144
+ var VALUES = ["0", "1", "2", "3", "4", "5"];
145
+ var SCALE = ["0", ".25rem", ".5rem", "1rem", "1.5rem", "3rem"];
146
+ var SIDES = ["", "x", "y", "t", "e", "b", "s"];
147
+ var SET = {
148
+ "": ["top", "right", "bottom", "left"],
149
+ x: ["left", "right"],
150
+ y: ["top", "bottom"],
151
+ t: ["top"],
152
+ e: ["right"],
153
+ b: ["bottom"],
154
+ s: ["left"]
155
+ };
156
+ var INFIXES = ["", "sm", "md", "lg", "xl", "xxl"];
157
+ var PROPERTIES = { p: "padding", m: "margin" };
158
+ function pattern(key) {
159
+ return new RegExp("^" + key + "[xytbse]?-(?:(?:sm|md|lg|xl|xxl)-)?(?:[0-5]|auto)$");
160
+ }
161
+ function spacingPart(ge, given) {
162
+ var options = Object.assign({ values: VALUES, scale: SCALE }, given);
163
+ var patterns = { p: pattern("p"), m: pattern("m") };
164
+ function applies(node, kind) {
165
+ return kind === "row" || kind === "column" || kind === "element" || is(node, "[data-ge-container]");
166
+ }
167
+ function classes(node) {
168
+ return (node.getAttribute("class") || "").split(/\s+/);
169
+ }
170
+ function carries(node, key) {
171
+ return classes(node).some(function(name) {
172
+ return patterns[key].test(name);
173
+ });
174
+ }
175
+ function source(node, family, tier) {
176
+ var names = classes(node);
177
+ var values = family.charAt(0) === "m" ? VALUES.concat(["auto"]) : VALUES;
178
+ for (var i = tier; i >= 0; i--) {
179
+ for (var v = 0; v < values.length; v++) {
180
+ var name = family + (INFIXES[i] ? "-" + INFIXES[i] : "") + "-" + values[v];
181
+ if (names.indexOf(name) !== -1) {
182
+ return { tier: i, value: values[v] };
183
+ }
184
+ }
185
+ }
186
+ return null;
187
+ }
188
+ function without(node, key) {
189
+ var original = node.getAttribute("class");
190
+ var style;
191
+ var bare = {};
192
+ node.setAttribute("class", classes(node).filter(function(name) {
193
+ return !patterns[key].test(name);
194
+ }).join(" "));
195
+ style = getComputedStyle(node);
196
+ ["top", "right", "bottom", "left"].forEach(function(side) {
197
+ bare[side] = style.getPropertyValue(PROPERTIES[key] + "-" + side);
198
+ });
199
+ if (original === null) {
200
+ node.removeAttribute("class");
201
+ } else {
202
+ node.setAttribute("class", original);
203
+ }
204
+ return bare;
205
+ }
206
+ function sides(node, key, breakpoint) {
207
+ var tier = ge.breakpoints.indexOf(breakpoint);
208
+ var winners = {};
209
+ var styles = {};
210
+ var neutral = null;
211
+ SIDES.forEach(function(side, order) {
212
+ var found = source(node, key + side, tier);
213
+ if (!found) {
214
+ return;
215
+ }
216
+ SET[side].forEach(function(set) {
217
+ var current = winners[set];
218
+ if (!current || found.tier > current.tier || found.tier === current.tier && order > current.order) {
219
+ winners[set] = { tier: found.tier, order, value: found.value };
220
+ }
221
+ });
222
+ });
223
+ ["top", "right", "bottom", "left"].forEach(function(set) {
224
+ var winner = winners[set];
225
+ if (!winner) {
226
+ neutral = neutral || without(node, key);
227
+ styles[PROPERTIES[key] + "-" + set] = neutral[set];
228
+ } else {
229
+ styles[PROPERTIES[key] + "-" + set] = winner.value === "auto" ? "auto" : options.scale[winner.value];
230
+ }
231
+ });
232
+ return styles;
233
+ }
234
+ function startingSide(node, key) {
235
+ var names = classes(node).filter(function(name) {
236
+ return patterns[key].test(name);
237
+ });
238
+ var found = SIDES.filter(function(side) {
239
+ return names.some(function(name) {
240
+ return name.indexOf(key + side + "-") === 0;
241
+ });
242
+ });
243
+ return found.length ? found[0] : "";
244
+ }
245
+ function sideLabel(side) {
246
+ switch (side) {
247
+ case "x":
248
+ return ge.t("utility.side_x");
249
+ case "y":
250
+ return ge.t("utility.side_y");
251
+ case "t":
252
+ return ge.t("utility.side_t");
253
+ case "b":
254
+ return ge.t("utility.side_b");
255
+ case "s":
256
+ return ge.t("utility.side_s");
257
+ case "e":
258
+ return ge.t("utility.side_e");
259
+ default:
260
+ return ge.t("utility.side_all");
261
+ }
262
+ }
263
+ function group2(node, key, labelText) {
264
+ var box = element("div", { "class": "ge-spacing-group", "data-ge-spacing": key });
265
+ var side = element("select", { "class": "ge-spacing-side form-select form-select-sm" });
266
+ box.appendChild(element("span", { "class": "ge-utility-label" }, labelText));
267
+ SIDES.forEach(function(value) {
268
+ side.appendChild(element("option", { value }, sideLabel(value)));
269
+ });
270
+ var field = ge.utilityField(node, key + startingSide(node, key));
271
+ side.value = field.getAttribute("data-ge-family").slice(1);
272
+ side.addEventListener("change", function() {
273
+ var next = ge.utilityField(node, key + this.value);
274
+ field.replaceWith(next);
275
+ field = next;
276
+ });
277
+ box.appendChild(side);
278
+ box.appendChild(field);
279
+ return box;
280
+ }
281
+ var NODES3 = ".row, .column, .ge-element, [data-ge-container]";
282
+ function mark2(scope) {
283
+ selfAndAll(scope, NODES3).forEach(function(node) {
284
+ var drawer = child(node, ".ge-tools-drawer");
285
+ if (!drawer || !applies(node, ge.kindOf(node))) {
286
+ return;
287
+ }
288
+ if (carries(node, "p")) {
289
+ var style = getComputedStyle(node);
290
+ css(drawer, {
291
+ "margin-top": "-" + style.paddingTop,
292
+ "margin-left": "-" + style.paddingLeft,
293
+ "margin-right": "-" + style.paddingRight,
294
+ width: "calc(100% + " + style.paddingLeft + " + " + style.paddingRight + ")"
295
+ });
296
+ } else {
297
+ css(drawer, { "margin-top": "", "margin-left": "", "margin-right": "", width: "" });
298
+ }
299
+ if (hasClass(node, "column")) {
300
+ var padded = classes(node).some(function(name) {
301
+ return /^p[xse]?-/.test(name) && patterns.p.test(name);
302
+ });
303
+ all(drawer, ".ge-spacing-gutter").forEach(function(note) {
304
+ toggle(note, padded);
305
+ });
306
+ }
307
+ });
308
+ }
309
+ function families(key, labelKey) {
310
+ var values = key === "m" ? VALUES.concat(["auto"]) : VALUES;
311
+ var offered = options.values.concat(key === "m" ? ["auto"] : []);
312
+ return SIDES.map(function(side) {
313
+ return {
314
+ name: key + side,
315
+ prefix: key + side,
316
+ values,
317
+ appliesTo: ["row", "column", "text", "element", "container"],
318
+ labelKey,
319
+ panel: false,
320
+ choices: function() {
321
+ return values.filter(function(value) {
322
+ return offered.indexOf(value) !== -1;
323
+ });
324
+ }
325
+ };
326
+ });
327
+ }
328
+ return {
329
+ families: families("p", "utility.padding").concat(families("m", "utility.margin")),
330
+ panel: function(node, kind) {
331
+ if (!applies(node, kind)) {
332
+ return null;
333
+ }
334
+ var box = element("div", { "class": "ge-spacing" });
335
+ box.appendChild(group2(node, "p", ge.t("utility.padding")));
336
+ box.appendChild(group2(node, "m", ge.t("utility.margin")));
337
+ if (kind === "column") {
338
+ box.appendChild(element("small", { "class": "ge-spacing-gutter" }, ge.t("utility.spacing_gutter")));
339
+ }
340
+ return box;
341
+ },
342
+ preview: function(node, kind, breakpoint) {
343
+ if (!applies(node, kind)) {
344
+ return {};
345
+ }
346
+ var styles = {};
347
+ ["p", "m"].forEach(function(key) {
348
+ if (carries(node, key)) {
349
+ Object.assign(styles, sides(node, key, breakpoint));
350
+ }
351
+ });
352
+ return styles;
353
+ },
354
+ onRefresh: mark2
355
+ };
356
+ }
357
+
358
+ // src/js/style/textalign.js
359
+ Object.assign(GridEditor.locales.en, {
360
+ "utility.text_align": "Text alignment",
361
+ "utility.text_start": "Start",
362
+ "utility.text_center": "Center",
363
+ "utility.text_end": "End"
364
+ });
365
+ var CSS = { start: "left", center: "center", end: "right" };
366
+ function textalignPart(ge) {
367
+ function label(value) {
368
+ if (value === "start") {
369
+ return ge.t("utility.text_start");
370
+ }
371
+ if (value === "center") {
372
+ return ge.t("utility.text_center");
373
+ }
374
+ return ge.t("utility.text_end");
375
+ }
376
+ return {
377
+ families: [{
378
+ name: "text-align",
379
+ prefix: "text",
380
+ values: ["start", "center", "end"],
381
+ appliesTo: ["row", "column", "text", "element", "container"],
382
+ labelKey: "utility.text_align",
383
+ label,
384
+ /**
385
+ * With no class applying here, the node aligns as its parent
386
+ * does - or as the host's css says - which only the browser can
387
+ * tell, so it is asked with the classes out of the way. Parents
388
+ * are previewed before their children, so the parent's answer is
389
+ * already the view's.
390
+ */
391
+ preview: function(value, node) {
392
+ return { "text-align": value === null ? ge.bareStyle(node, "text-align", "text-align") : CSS[value] };
393
+ }
394
+ }]
395
+ };
396
+ }
397
+
398
+ // src/js/style/display.js
399
+ Object.assign(GridEditor.locales.en, {
400
+ "utility.display": "Display",
401
+ "utility.visibility_hidden": "Hidden",
402
+ "tool.hide_in_view": "Hide in this view",
403
+ "tool.show_in_view": "Show in this view",
404
+ "badge.hidden_in": "Hidden at {breakpoints}"
405
+ });
406
+ var VALUES2 = ["none", "inline", "inline-block", "block", "grid", "inline-grid", "flex", "inline-flex"];
407
+ var CLASS_PATTERN = new RegExp("(?:^|\\s)d-(?:(?:sm|md|lg|xl|xxl)-)?(?:" + VALUES2.join("|") + ")(?:\\s|$)");
408
+ var NONE_PATTERN = /^d-(?:(?:sm|md|lg|xl|xxl)-)?none$/;
409
+ var NODES = ".row, .column, .ge-content, .ge-element, [data-ge-container]";
410
+ var SHOWN_ATTR = "data-ge-display";
411
+ function displayPart(ge, given) {
412
+ var options = Object.assign({ drawer: true }, given);
413
+ function choices(kind) {
414
+ if (kind === "row") {
415
+ return ["none", "flex"];
416
+ }
417
+ if (kind === "text" || kind === "plain") {
418
+ return ["none", "block"];
419
+ }
420
+ return VALUES2;
421
+ }
422
+ function shownByDefault(kind) {
423
+ return kind === "row" ? "flex" : "block";
424
+ }
425
+ function applies(node, kind) {
426
+ return kind === "row" || kind === "column" || kind === "element" || kind === "text" || kind === "plain" || is(node, "[data-ge-container]");
427
+ }
428
+ function hiddenAt(node, view) {
429
+ return ge.getUtility(node, "display", view) === "none";
430
+ }
431
+ function hiddenTiers(node) {
432
+ return ge.breakpoints.filter(function(key) {
433
+ return hiddenAt(node, key);
434
+ });
435
+ }
436
+ function hiddenHere(node) {
437
+ return ge.view() === "all" ? hiddenTiers(node).length === ge.breakpoints.length : hiddenAt(node, ge.view());
438
+ }
439
+ function hiddenBelow(node) {
440
+ var index = ge.breakpoints.indexOf(ge.view());
441
+ return index > 0 && hiddenAt(node, ge.breakpoints[index - 1]);
442
+ }
443
+ function shownBelow(node, view) {
444
+ for (var i = ge.breakpoints.indexOf(view) - 1; i >= 0; i--) {
445
+ var value = ge.getUtility(node, "display", ge.breakpoints[i]);
446
+ if (value === null) {
447
+ return null;
448
+ }
449
+ if (value !== "none") {
450
+ return value;
451
+ }
452
+ }
453
+ return null;
454
+ }
455
+ function toggle2(node, kind) {
456
+ var hide2 = !hiddenHere(node);
457
+ var value;
458
+ if (ge.view() === "all") {
459
+ value = hide2 ? "none" : null;
460
+ } else if (hide2) {
461
+ value = hiddenBelow(node) ? null : "none";
462
+ } else {
463
+ value = hiddenBelow(node) ? shownBelow(node, ge.view()) || shownByDefault(kind) : null;
464
+ }
465
+ ge.setUtility(node, "display", value, { source: "tool" });
466
+ }
467
+ function shownAs(node) {
468
+ var original = node.getAttribute("class");
469
+ node.setAttribute("class", original.split(/\s+/).filter(function(name) {
470
+ return !NONE_PATTERN.test(name);
471
+ }).join(" "));
472
+ var display = getComputedStyle(node).display;
473
+ node.setAttribute("class", original);
474
+ return display !== "none" && VALUES2.indexOf(display) !== -1 ? display : "block";
475
+ }
476
+ function mark2(scope) {
477
+ selfAndAll(scope, NODES).forEach(function(node) {
478
+ var kind = ge.kindOf(node);
479
+ var carries = applies(node, kind) && CLASS_PATTERN.test(node.getAttribute("class") || "");
480
+ var tiers = carries ? hiddenTiers(node) : [];
481
+ var here = carries && hiddenHere(node);
482
+ var partly = carries && ge.view() === "all" && tiers.length > 0 && !here;
483
+ node.removeAttribute(SHOWN_ATTR);
484
+ if (carries && getComputedStyle(node).display === "none") {
485
+ node.setAttribute(SHOWN_ATTR, shownAs(node));
486
+ }
487
+ toggleClass(node, "ge-hidden-in-view", here);
488
+ if (partly) {
489
+ node.setAttribute("data-ge-hidden-in", ge.t("badge.hidden_in", { breakpoints: tiers.join(", ") }));
490
+ } else {
491
+ node.removeAttribute("data-ge-hidden-in");
492
+ }
493
+ children(node, ".ge-tools-drawer").forEach(function(drawer) {
494
+ children(drawer, ".ge-visibility-tool").forEach(function(tool) {
495
+ tool.setAttribute("title", here ? ge.t("tool.show_in_view") : ge.t("tool.hide_in_view"));
496
+ all(tool, "i").forEach(function(icon) {
497
+ icon.setAttribute("class", here ? "bi bi-eye-slash" : "bi bi-eye");
498
+ });
499
+ });
500
+ });
501
+ });
502
+ }
503
+ function unmark() {
504
+ all(ge.canvas, ".ge-hidden-in-view, [data-ge-hidden-in], [" + SHOWN_ATTR + "]").forEach(function(node) {
505
+ removeClass(node, "ge-hidden-in-view");
506
+ node.removeAttribute("data-ge-hidden-in");
507
+ node.removeAttribute(SHOWN_ATTR);
508
+ dropEmptyClass(node);
509
+ });
510
+ }
511
+ return {
512
+ families: [{
513
+ name: "display",
514
+ prefix: "d",
515
+ values: VALUES2,
516
+ appliesTo: ["row", "column", "text", "element", "container"],
517
+ labelKey: "utility.display",
518
+ choices: function(node, kind) {
519
+ return choices(kind);
520
+ },
521
+ label: function(value) {
522
+ return value === "none" ? ge.t("utility.visibility_hidden") : value;
523
+ },
524
+ /**
525
+ * What the view being edited displays the node as. Hidden is
526
+ * shown the way the breakpoints below show it, since the canvas
527
+ * keeps a hidden node, faded; with no class applying, it is what
528
+ * the node is without any.
529
+ */
530
+ preview: function(value, node) {
531
+ if (value === "none") {
532
+ value = shownBelow(node, ge.view());
533
+ }
534
+ return { display: value === null ? ge.bareStyle(node, "display", "display") : value };
535
+ }
536
+ }],
537
+ drawerTools: function(drawer, node, kind) {
538
+ if (!options.drawer || !applies(node, kind)) {
539
+ return;
540
+ }
541
+ ge.createTool(drawer, ge.t("tool.hide_in_view"), "ge-visibility-tool", "bi bi-eye", function() {
542
+ toggle2(node, kind);
543
+ });
544
+ },
545
+ onRefresh: mark2,
546
+ onDeinit: unmark
547
+ };
548
+ }
549
+
550
+ // src/js/style/flex.js
551
+ Object.assign(GridEditor.locales.en, {
552
+ "utility.flex_direction": "Direction",
553
+ "utility.flex_wrap": "Wrap",
554
+ "utility.justify_content": "Justify columns",
555
+ "utility.align_items": "Align columns",
556
+ "utility.align_content": "Align lines",
557
+ "utility.gap": "Gap",
558
+ "utility.row_gap": "Row gap",
559
+ "utility.column_gap": "Column gap",
560
+ "utility.flex_fill": "Fill",
561
+ "utility.flex_grow": "Grow",
562
+ "utility.flex_shrink": "Shrink"
563
+ });
564
+ var FLEX = {
565
+ start: "flex-start",
566
+ end: "flex-end",
567
+ center: "center",
568
+ between: "space-between",
569
+ around: "space-around",
570
+ evenly: "space-evenly",
571
+ baseline: "baseline",
572
+ stretch: "stretch"
573
+ };
574
+ var GAPS = ["0", "1", "2", "3", "4", "5"];
575
+ var SCALE2 = ["0", ".25rem", ".5rem", "1rem", "1.5rem", "3rem"];
576
+ var CONTAINERS = ["row", "column", "element", "container"];
577
+ var ITEMS = ["column", "element", "container"];
578
+ function flexPart(ge, spacing2) {
579
+ var scale = spacing2 && spacing2.scale || SCALE2;
580
+ function family(definition) {
581
+ var property = definition.property || definition.name;
582
+ return Object.assign({
583
+ prefix: definition.name,
584
+ panel: false,
585
+ preview: function(value, node) {
586
+ var styles = {};
587
+ styles[property] = value === null ? ge.bareStyle(node, definition.name, property) : definition.css(value);
588
+ return styles;
589
+ }
590
+ }, definition);
591
+ }
592
+ function alignment(definition) {
593
+ return family(Object.assign({
594
+ appliesTo: CONTAINERS,
595
+ preview: function(value) {
596
+ var styles = {};
597
+ styles[definition.name] = value === null ? "normal" : FLEX[value];
598
+ return styles;
599
+ }
600
+ }, definition));
601
+ }
602
+ function gap(definition) {
603
+ return family(Object.assign({
604
+ values: GAPS,
605
+ appliesTo: ITEMS,
606
+ css: function(value) {
607
+ return scale[value];
608
+ }
609
+ }, definition));
610
+ }
611
+ function same(value) {
612
+ return value;
613
+ }
614
+ return {
615
+ families: [
616
+ family({
617
+ name: "flex-direction",
618
+ prefix: "flex",
619
+ labelKey: "utility.flex_direction",
620
+ values: ["row", "row-reverse", "column", "column-reverse"],
621
+ appliesTo: CONTAINERS,
622
+ css: same
623
+ }),
624
+ family({
625
+ name: "flex-wrap",
626
+ prefix: "flex",
627
+ labelKey: "utility.flex_wrap",
628
+ values: ["wrap", "nowrap", "wrap-reverse"],
629
+ appliesTo: CONTAINERS,
630
+ css: same
631
+ }),
632
+ alignment({
633
+ name: "justify-content",
634
+ labelKey: "utility.justify_content",
635
+ values: ["start", "center", "end", "between", "around", "evenly"]
636
+ }),
637
+ alignment({
638
+ name: "align-items",
639
+ labelKey: "utility.align_items",
640
+ values: ["start", "center", "end", "baseline", "stretch"]
641
+ }),
642
+ alignment({
643
+ name: "align-content",
644
+ labelKey: "utility.align_content",
645
+ values: ["start", "center", "end", "between", "around", "stretch"]
646
+ }),
647
+ gap({ name: "gap", labelKey: "utility.gap" }),
648
+ gap({ name: "row-gap", labelKey: "utility.row_gap" }),
649
+ gap({ name: "column-gap", labelKey: "utility.column_gap" }),
650
+ family({
651
+ name: "flex-fill",
652
+ prefix: "flex",
653
+ property: "flex",
654
+ labelKey: "utility.flex_fill",
655
+ values: ["fill"],
656
+ appliesTo: ITEMS,
657
+ css: function() {
658
+ return "1 1 auto";
659
+ }
660
+ }),
661
+ family({
662
+ name: "flex-grow",
663
+ prefix: "flex",
664
+ labelKey: "utility.flex_grow",
665
+ values: ["grow-0", "grow-1"],
666
+ appliesTo: ITEMS,
667
+ css: function(value) {
668
+ return value.slice(-1);
669
+ }
670
+ }),
671
+ family({
672
+ name: "flex-shrink",
673
+ prefix: "flex",
674
+ labelKey: "utility.flex_shrink",
675
+ values: ["shrink-0", "shrink-1"],
676
+ appliesTo: ITEMS,
677
+ css: function(value) {
678
+ return value.slice(-1);
679
+ }
680
+ })
681
+ ]
682
+ };
683
+ }
684
+
685
+ // src/js/style/float.js
686
+ Object.assign(GridEditor.locales.en, {
687
+ "utility.float": "Float",
688
+ "utility.float_start": "Start",
689
+ "utility.float_end": "End",
690
+ "utility.float_none": "None"
691
+ });
692
+ var CSS2 = { start: "left", end: "right", none: "none" };
693
+ function floatPart(ge) {
694
+ function label(value) {
695
+ if (value === "start") {
696
+ return ge.t("utility.float_start");
697
+ }
698
+ if (value === "end") {
699
+ return ge.t("utility.float_end");
700
+ }
701
+ return ge.t("utility.float_none");
702
+ }
703
+ return {
704
+ families: [{
705
+ name: "float",
706
+ prefix: "float",
707
+ values: ["start", "end", "none"],
708
+ appliesTo: ["element"],
709
+ labelKey: "utility.float",
710
+ label,
711
+ /** With no class applying here, whatever the host's css floats it as. */
712
+ preview: function(value, node) {
713
+ return { float: value === null ? ge.bareStyle(node, "float", "float") : CSS2[value] };
714
+ }
715
+ }]
716
+ };
717
+ }
718
+
719
+ // src/js/style/sticky.js
720
+ Object.assign(GridEditor.locales.en, {
721
+ "utility.sticky": "Sticky"
722
+ });
723
+ var STUCK = {
724
+ top: { position: "sticky", top: "0", "z-index": "1020" },
725
+ bottom: { position: "sticky", bottom: "0", "z-index": "1020" }
726
+ };
727
+ function stickyPart(ge) {
728
+ return {
729
+ families: [{
730
+ name: "sticky",
731
+ prefix: "sticky",
732
+ values: ["top", "bottom"],
733
+ appliesTo: ["row", "column", "element", "container"],
734
+ labelKey: "utility.sticky",
735
+ panel: false,
736
+ /** With no class applying here, where the node is without one. */
737
+ preview: function(value, node) {
738
+ if (value !== null) {
739
+ return STUCK[value];
740
+ }
741
+ return { position: ge.bareStyle(node, "sticky", "position") };
742
+ }
743
+ }]
744
+ };
745
+ }
746
+
747
+ // src/js/style/drawerflow.js
748
+ var NODES2 = ".row, .column, .ge-element, [data-ge-container]";
749
+ var OUT_CLASS = "ge-drawer-out";
750
+ var OUT_ATTR = "data-ge-drawer-out";
751
+ var GAP = 5;
752
+ var LAYS_OUT = /^(?:inline-)?(?:flex|grid)$/;
753
+ function drawerflowPart(ge) {
754
+ var sheet = null;
755
+ var heights = {};
756
+ var observer = null;
757
+ function rule(room) {
758
+ if (heights[room]) {
759
+ return;
760
+ }
761
+ heights[room] = true;
762
+ if (!sheet) {
763
+ sheet = document.head.appendChild(element("style", { "data-ge-drawer-flow": "" }));
764
+ }
765
+ var node = ".ge-canvas.ge-editing [" + OUT_ATTR + '="' + room + '"]';
766
+ sheet.appendChild(document.createTextNode(
767
+ node + " { border-top-width: " + room + "px !important; }\n" + node + " > .ge-tools-drawer { top: -" + room + "px; }\n"
768
+ ));
769
+ }
770
+ function laysOut(node) {
771
+ var style = getComputedStyle(node);
772
+ if (!LAYS_OUT.test(style.display)) {
773
+ return false;
774
+ }
775
+ return !(hasClass(node, "row") && style.flexDirection === "row" && style.flexWrap === "wrap");
776
+ }
777
+ function measure(node, drawer) {
778
+ var room = Math.ceil(drawer.offsetHeight) + GAP;
779
+ rule(room);
780
+ node.setAttribute(OUT_ATTR, String(room));
781
+ }
782
+ function watch(drawer) {
783
+ if (typeof ResizeObserver === "undefined") {
784
+ return;
785
+ }
786
+ if (!observer) {
787
+ observer = new ResizeObserver(function(entries) {
788
+ entries.forEach(function(entry) {
789
+ var node = entry.target.parentNode;
790
+ if (node && hasClass(node, OUT_CLASS)) {
791
+ measure(node, entry.target);
792
+ }
793
+ });
794
+ });
795
+ }
796
+ observer.observe(drawer);
797
+ }
798
+ function mark2(scope) {
799
+ selfAndAll(scope, NODES2).forEach(function(node) {
800
+ var drawer = child(node, ".ge-tools-drawer");
801
+ if (!drawer) {
802
+ return;
803
+ }
804
+ if (laysOut(node)) {
805
+ addClass(node, OUT_CLASS);
806
+ measure(node, drawer);
807
+ watch(drawer);
808
+ } else if (hasClass(node, OUT_CLASS)) {
809
+ removeClass(node, OUT_CLASS);
810
+ node.removeAttribute(OUT_ATTR);
811
+ dropEmptyClass(node);
812
+ if (observer) {
813
+ observer.unobserve(drawer);
814
+ }
815
+ }
816
+ });
817
+ }
818
+ function unmark() {
819
+ if (observer) {
820
+ observer.disconnect();
821
+ }
822
+ observer = null;
823
+ all(ge.canvas, "." + OUT_CLASS).forEach(function(node) {
824
+ removeClass(node, OUT_CLASS);
825
+ node.removeAttribute(OUT_ATTR);
826
+ dropEmptyClass(node);
827
+ });
828
+ if (sheet) {
829
+ sheet.remove();
830
+ }
831
+ sheet = null;
832
+ heights = {};
833
+ }
834
+ return {
835
+ families: [],
836
+ onRefresh: mark2,
837
+ onDeinit: unmark
838
+ };
839
+ }
840
+
841
+ // src/js/style/sections.js
842
+ var COLORS = ["primary", "secondary", "success", "danger", "warning", "info", "light", "dark"];
843
+ var SIDES2 = ["top", "end", "bottom", "start"];
844
+ var OPACITIES = ["10", "25", "50", "75", "100"];
845
+ function each(prefix, values, suffix) {
846
+ return values.map(function(value) {
847
+ return prefix + value + (suffix || "");
848
+ });
849
+ }
850
+ function group(classes, exclusive, notOn, onlyOn) {
851
+ return { classes, exclusive: exclusive !== false, notOn: notOn || [], onlyOn: onlyOn || null };
852
+ }
853
+ function prop(name, options) {
854
+ return {
855
+ name,
856
+ labelKey: options.labelKey,
857
+ type: options.type || "text",
858
+ values: options.values || null,
859
+ notOn: options.notOn || []
860
+ };
861
+ }
862
+ var NOT_ON_COLUMN = ["column"];
863
+ var ONLY_ON_ELEMENT = ["element"];
864
+ var SECTIONS = [
865
+ {
866
+ key: "size",
867
+ labelKey: "style.section_size",
868
+ properties: [
869
+ prop("width", { labelKey: "style.prop_width", notOn: NOT_ON_COLUMN }),
870
+ prop("height", { labelKey: "style.prop_height", notOn: NOT_ON_COLUMN }),
871
+ prop("min-width", { labelKey: "style.prop_min_width" }),
872
+ prop("min-height", { labelKey: "style.prop_min_height" }),
873
+ prop("max-width", { labelKey: "style.prop_max_width" }),
874
+ prop("max-height", { labelKey: "style.prop_max_height" })
875
+ ],
876
+ catalog: [
877
+ group(each("w-", ["25", "50", "75", "100", "auto"]), true, NOT_ON_COLUMN),
878
+ group(each("h-", ["25", "50", "75", "100", "auto"]), true, NOT_ON_COLUMN),
879
+ group(["mw-100", "mh-100", "vw-100", "vh-100", "min-vw-100", "min-vh-100"], false, NOT_ON_COLUMN),
880
+ group(["img-fluid", "img-thumbnail"], false, [], ONLY_ON_ELEMENT),
881
+ group(each("object-fit-", ["contain", "cover", "fill", "scale", "none"]), true, [], ONLY_ON_ELEMENT)
882
+ ],
883
+ parts: []
884
+ },
885
+ {
886
+ key: "spacing",
887
+ labelKey: "style.section_spacing",
888
+ properties: [
889
+ prop("margin-top", { labelKey: "style.prop_margin_top" }),
890
+ prop("margin-right", { labelKey: "style.prop_margin_right" }),
891
+ prop("margin-bottom", { labelKey: "style.prop_margin_bottom" }),
892
+ prop("margin-left", { labelKey: "style.prop_margin_left" }),
893
+ prop("padding-top", { labelKey: "style.prop_padding_top" }),
894
+ prop("padding-right", { labelKey: "style.prop_padding_right" }),
895
+ prop("padding-bottom", { labelKey: "style.prop_padding_bottom" }),
896
+ prop("padding-left", { labelKey: "style.prop_padding_left" })
897
+ ],
898
+ catalog: [],
899
+ parts: ["spacing"]
900
+ },
901
+ {
902
+ key: "border",
903
+ labelKey: "style.section_border",
904
+ properties: [
905
+ prop("border-width", { labelKey: "style.prop_border_width" }),
906
+ prop("border-style", { labelKey: "style.prop_border_style", type: "select", values: ["none", "solid", "dashed", "dotted", "double", "groove", "ridge", "inset", "outset"] }),
907
+ prop("border-color", { labelKey: "style.prop_border_color", type: "color" }),
908
+ prop("border-radius", { labelKey: "style.prop_border_radius" }),
909
+ prop("box-shadow", { labelKey: "style.prop_box_shadow", type: "shadow" })
910
+ ],
911
+ catalog: [
912
+ group(["border", "border-0"].concat(each("border-", SIDES2), each("border-", SIDES2, "-0")), false),
913
+ group(each("border-", ["1", "2", "3", "4", "5"])),
914
+ group(each("border-", COLORS.concat(["black", "white"])).concat(each("border-", COLORS, "-subtle"))),
915
+ group(each("border-opacity-", OPACITIES)),
916
+ group(["rounded"].concat(each("rounded-", ["0", "1", "2", "3", "4", "5", "circle", "pill"]))),
917
+ group(each("rounded-", SIDES2), false),
918
+ group(["shadow-none", "shadow-sm", "shadow", "shadow-lg"])
919
+ ],
920
+ parts: []
921
+ },
922
+ {
923
+ key: "background",
924
+ labelKey: "style.section_background",
925
+ properties: [
926
+ prop("background-color", { labelKey: "style.prop_background_color", type: "color" }),
927
+ prop("background-image", { labelKey: "style.prop_background_image", type: "url" }),
928
+ prop("background-size", { labelKey: "style.prop_background_size" }),
929
+ prop("background-position", { labelKey: "style.prop_background_position" }),
930
+ prop("background-repeat", { labelKey: "style.prop_background_repeat", type: "select", values: ["repeat", "no-repeat", "repeat-x", "repeat-y", "space", "round"] })
931
+ ],
932
+ catalog: [
933
+ group(each("bg-", COLORS.concat(["body", "body-secondary", "body-tertiary", "white", "black", "transparent"])).concat(each("bg-", COLORS, "-subtle"), each("text-bg-", COLORS))),
934
+ group(["bg-gradient"], false),
935
+ group(each("bg-opacity-", OPACITIES))
936
+ ],
937
+ parts: []
938
+ },
939
+ {
940
+ key: "text",
941
+ labelKey: "style.section_text",
942
+ properties: [
943
+ prop("color", { labelKey: "style.prop_color", type: "color" }),
944
+ prop("font-size", { labelKey: "style.prop_font_size" }),
945
+ prop("text-align", { labelKey: "style.prop_text_align", type: "select", values: ["start", "center", "end", "left", "right", "justify"] }),
946
+ prop("text-shadow", { labelKey: "style.prop_text_shadow", type: "shadow" })
947
+ ],
948
+ catalog: [
949
+ group(each("text-", COLORS.concat(["body", "body-secondary", "body-tertiary", "white", "black"])).concat(each("text-", COLORS, "-emphasis"), ["text-body-emphasis"])),
950
+ group(each("text-opacity-", ["25", "50", "75", "100"])),
951
+ group(each("fs-", ["1", "2", "3", "4", "5", "6"])),
952
+ group(each("text-decoration-", ["none", "underline", "line-through"]))
953
+ ],
954
+ parts: ["textalign"]
955
+ },
956
+ {
957
+ key: "typography",
958
+ labelKey: "style.section_typography",
959
+ properties: [
960
+ prop("font-family", { labelKey: "style.prop_font_family" }),
961
+ prop("font-weight", { labelKey: "style.prop_font_weight", type: "select", values: ["100", "200", "300", "400", "500", "600", "700", "800", "900", "normal", "bold", "lighter", "bolder"] }),
962
+ prop("font-style", { labelKey: "style.prop_font_style", type: "select", values: ["normal", "italic", "oblique"] }),
963
+ prop("line-height", { labelKey: "style.prop_line_height" }),
964
+ prop("letter-spacing", { labelKey: "style.prop_letter_spacing" }),
965
+ prop("text-transform", { labelKey: "style.prop_text_transform", type: "select", values: ["none", "uppercase", "lowercase", "capitalize"] }),
966
+ prop("text-decoration", { labelKey: "style.prop_text_decoration", type: "select", values: ["none", "underline", "line-through", "overline"] })
967
+ ],
968
+ catalog: [
969
+ group(each("fw-", ["lighter", "light", "normal", "medium", "semibold", "bold", "bolder"])),
970
+ group(each("fst-", ["italic", "normal"])),
971
+ group(each("lh-", ["1", "sm", "base", "lg"])),
972
+ group(each("text-", ["lowercase", "uppercase", "capitalize"])),
973
+ group(["font-monospace"], false),
974
+ group(["text-wrap", "text-nowrap"]),
975
+ group(["text-break"], false)
976
+ ],
977
+ parts: []
978
+ },
979
+ {
980
+ key: "display",
981
+ labelKey: "style.section_display",
982
+ properties: [
983
+ prop("display", { labelKey: "style.prop_display", type: "select", values: ["none", "block", "inline", "inline-block", "flex", "inline-flex", "grid", "inline-grid"] }),
984
+ prop("opacity", { labelKey: "style.prop_opacity" }),
985
+ prop("overflow", { labelKey: "style.prop_overflow", type: "select", values: ["visible", "hidden", "auto", "scroll", "clip"] }),
986
+ prop("visibility", { labelKey: "style.prop_visibility", type: "select", values: ["visible", "hidden"] })
987
+ ],
988
+ catalog: [
989
+ group(each("opacity-", ["0", "25", "50", "75", "100"])),
990
+ group(each("overflow-", ["auto", "hidden", "visible", "scroll"])),
991
+ group(["visible", "invisible"])
992
+ ],
993
+ parts: ["display"]
994
+ },
995
+ {
996
+ key: "flex",
997
+ labelKey: "style.section_flex",
998
+ properties: [],
999
+ catalog: [
1000
+ group(["vstack", "hstack"], true, ["row"])
1001
+ ],
1002
+ parts: ["flex"]
1003
+ },
1004
+ {
1005
+ key: "position",
1006
+ labelKey: "style.section_position",
1007
+ properties: [
1008
+ prop("position", { labelKey: "style.prop_position", type: "select", values: ["static", "relative", "absolute", "fixed", "sticky"] }),
1009
+ prop("top", { labelKey: "style.prop_top", notOn: NOT_ON_COLUMN }),
1010
+ prop("right", { labelKey: "style.prop_right", notOn: NOT_ON_COLUMN }),
1011
+ prop("bottom", { labelKey: "style.prop_bottom", notOn: NOT_ON_COLUMN }),
1012
+ prop("left", { labelKey: "style.prop_left", notOn: NOT_ON_COLUMN }),
1013
+ prop("z-index", { labelKey: "style.prop_z_index" })
1014
+ ],
1015
+ catalog: [
1016
+ group(each("position-", ["static", "relative", "absolute", "fixed", "sticky"])),
1017
+ group(each("top-", ["0", "50", "100"])),
1018
+ group(each("bottom-", ["0", "50", "100"])),
1019
+ group(each("start-", ["0", "50", "100"])),
1020
+ group(each("end-", ["0", "50", "100"])),
1021
+ group(["translate-middle", "translate-middle-x", "translate-middle-y"]),
1022
+ group(["z-n1", "z-0", "z-1", "z-2", "z-3"]),
1023
+ group(["fixed-top", "fixed-bottom"])
1024
+ ],
1025
+ parts: ["float", "sticky"]
1026
+ },
1027
+ {
1028
+ key: "custom",
1029
+ labelKey: "style.section_custom",
1030
+ properties: [],
1031
+ catalog: [],
1032
+ parts: [],
1033
+ custom: true
1034
+ }
1035
+ ];
1036
+ function section(key) {
1037
+ return SECTIONS.filter(function(each_) {
1038
+ return each_.key === key;
1039
+ })[0] || null;
1040
+ }
1041
+ function offeredOn(item, kind) {
1042
+ if (item.onlyOn && item.onlyOn.indexOf(kind) === -1) {
1043
+ return false;
1044
+ }
1045
+ return item.notOn.indexOf(kind) === -1;
1046
+ }
1047
+ var BREAKPOINT = "(?:(?:sm|md|lg|xl|xxl)-)?";
1048
+ var SPACER = "(?:[0-5]|auto)";
1049
+ var COLOR = "(?:" + COLORS.join("|") + "|black|white)";
1050
+ var BG = "(?:" + COLORS.join("|") + "|body|body-secondary|body-tertiary|white|black|transparent)";
1051
+ var TEXT_COLOR = "(?:" + COLORS.join("|") + "|body|body-secondary|body-tertiary|white|black|muted|black-50|white-50)";
1052
+ var BORDER = "border(?:-(?:top|end|bottom|start))?(?:-0)?";
1053
+ var SUBTLE = "(?:" + COLORS.join("|") + ")-subtle";
1054
+ var EMPHASIS = "(?:" + COLORS.join("|") + "|body)-emphasis";
1055
+ var TEXT_BG = "text-bg-(?:" + COLORS.join("|") + ")";
1056
+ var STICKY = "sticky-" + BREAKPOINT;
1057
+ function spacing(key, side) {
1058
+ var sides = { top: "[ty]?", bottom: "[by]?", left: "[sx]?", right: "[ex]?" }[side];
1059
+ return new RegExp("^" + key + sides + "-" + BREAKPOINT + SPACER + "$");
1060
+ }
1061
+ var SETS = {
1062
+ "width": /^(?:w-(?:25|50|75|100|auto)|vw-100)$/,
1063
+ "height": /^(?:h-(?:25|50|75|100|auto)|vh-100)$/,
1064
+ "max-width": /^mw-100$/,
1065
+ "max-height": /^mh-100$/,
1066
+ "min-width": /^min-vw-100$/,
1067
+ "min-height": /^min-vh-100$/,
1068
+ "margin-top": spacing("m", "top"),
1069
+ "margin-right": spacing("m", "right"),
1070
+ "margin-bottom": spacing("m", "bottom"),
1071
+ "margin-left": spacing("m", "left"),
1072
+ "padding-top": spacing("p", "top"),
1073
+ "padding-right": spacing("p", "right"),
1074
+ "padding-bottom": spacing("p", "bottom"),
1075
+ "padding-left": spacing("p", "left"),
1076
+ "border-width": new RegExp("^(?:" + BORDER + "|border-[1-5])$"),
1077
+ "border-style": new RegExp("^" + BORDER + "$"),
1078
+ "border-color": new RegExp("^(?:" + BORDER + "|border-" + COLOR + "|border-" + SUBTLE + ")$"),
1079
+ "border-radius": /^rounded(?:-(?:[0-5]|circle|pill|top|end|bottom|start))?$/,
1080
+ "box-shadow": /^shadow(?:-(?:none|sm|lg))?$/,
1081
+ "background-color": new RegExp("^(?:bg-" + BG + "|bg-" + SUBTLE + "|" + TEXT_BG + ")$"),
1082
+ "background-image": /^bg-gradient$/,
1083
+ "color": new RegExp("^(?:text-" + TEXT_COLOR + "|text-" + EMPHASIS + "|" + TEXT_BG + ")$"),
1084
+ "font-size": /^fs-[1-6]$/,
1085
+ "text-align": new RegExp("^text-" + BREAKPOINT + "(?:start|center|end)$"),
1086
+ "text-decoration": /^text-decoration-(?:none|underline|line-through)$/,
1087
+ "font-family": /^font-monospace$/,
1088
+ "font-weight": /^fw-(?:lighter|light|normal|medium|semibold|bold|bolder)$/,
1089
+ "font-style": /^fst-(?:italic|normal)$/,
1090
+ "line-height": /^lh-(?:1|sm|base|lg)$/,
1091
+ "text-transform": /^text-(?:lowercase|uppercase|capitalize)$/,
1092
+ "display": new RegExp("^(?:d-" + BREAKPOINT + "(?:none|inline|inline-block|block|grid|inline-grid|table|table-row|table-cell|flex|inline-flex)|vstack|hstack)$"),
1093
+ "opacity": /^opacity-(?:0|25|50|75|100)$/,
1094
+ "overflow": /^overflow-(?:auto|hidden|visible|scroll)$/,
1095
+ "visibility": /^(?:visible|invisible)$/,
1096
+ "position": new RegExp("^(?:position-(?:static|relative|absolute|fixed|sticky)|fixed-(?:top|bottom)|" + STICKY + "(?:top|bottom))$"),
1097
+ "top": new RegExp("^(?:top-(?:0|50|100)|fixed-top|" + STICKY + "top)$"),
1098
+ "bottom": new RegExp("^(?:bottom-(?:0|50|100)|fixed-bottom|" + STICKY + "bottom)$"),
1099
+ "left": /^start-(?:0|50|100)$/,
1100
+ "right": /^end-(?:0|50|100)$/,
1101
+ "z-index": /^z-(?:n1|[0-3])$/
1102
+ };
1103
+ function overriding(property, classes) {
1104
+ var pattern2 = SETS[property];
1105
+ if (!pattern2) {
1106
+ return null;
1107
+ }
1108
+ return classes.filter(function(name) {
1109
+ return pattern2.test(name);
1110
+ })[0] || null;
1111
+ }
1112
+
1113
+ // src/js/style/options.js
1114
+ function resolveSections(ge, given) {
1115
+ var resolved = {};
1116
+ Object.keys(given || {}).forEach(function(key) {
1117
+ if (!section(key)) {
1118
+ ge.warn('style.sections: there is no "' + key + '" section: ignored');
1119
+ }
1120
+ });
1121
+ SECTIONS.forEach(function(each2) {
1122
+ var option = given && given[each2.key] !== void 0 ? given[each2.key] : true;
1123
+ if (option === false) {
1124
+ return;
1125
+ }
1126
+ var own = each2.properties.map(function(property) {
1127
+ return property.name;
1128
+ });
1129
+ var properties = each2.properties;
1130
+ var catalog = true;
1131
+ if (option && typeof option === "object") {
1132
+ if (Array.isArray(option.properties)) {
1133
+ option.properties.forEach(function(name) {
1134
+ if (own.indexOf(name) === -1) {
1135
+ ge.warn("style.sections." + each2.key + ': "' + name + '" is not one of its properties: ignored');
1136
+ }
1137
+ });
1138
+ properties = option.properties.filter(function(name) {
1139
+ return own.indexOf(name) !== -1;
1140
+ }).map(function(name) {
1141
+ return each2.properties[own.indexOf(name)];
1142
+ });
1143
+ }
1144
+ if (option.catalog === false) {
1145
+ catalog = false;
1146
+ }
1147
+ }
1148
+ resolved[each2.key] = { section: each2, properties, catalog };
1149
+ });
1150
+ return resolved;
1151
+ }
1152
+ function resolveOptions(ge) {
1153
+ var style = ge.settings.style || {};
1154
+ return {
1155
+ sections: resolveSections(ge, style.sections),
1156
+ spacing: style.spacing,
1157
+ visibility: style.visibility
1158
+ };
1159
+ }
1160
+
1161
+ // src/js/style/fields.js
1162
+ var renderers = /* @__PURE__ */ new WeakMap();
1163
+ var fieldCounter = 0;
1164
+ function classesOf(node) {
1165
+ return (node.getAttribute("class") || "").split(/\s+/).filter(Boolean);
1166
+ }
1167
+ function write(ge, node, property, raw) {
1168
+ var text = String(raw === null || raw === void 0 ? "" : raw).trim();
1169
+ var important = /\s*!\s*important\s*$/i.exec(text);
1170
+ var priority;
1171
+ if (important) {
1172
+ text = text.slice(0, important.index).trim();
1173
+ priority = "important";
1174
+ }
1175
+ return ge.setHostStyle(node, property, text, priority);
1176
+ }
1177
+ function mark(input, ok, ge) {
1178
+ toggleClass(input, "is-invalid", !ok);
1179
+ if (ok) {
1180
+ input.removeAttribute("title");
1181
+ } else {
1182
+ input.setAttribute("title", ge.t("style.invalid"));
1183
+ }
1184
+ }
1185
+ function fill(input, value) {
1186
+ if (!hasClass(input, "is-invalid")) {
1187
+ input.value = value;
1188
+ }
1189
+ }
1190
+ function textInput(className) {
1191
+ return element("input", { type: "text", "class": "form-control form-control-sm " + (className || "") });
1192
+ }
1193
+ var HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
1194
+ function pickable(value) {
1195
+ var match = HEX.exec(value.trim());
1196
+ if (!match) {
1197
+ return null;
1198
+ }
1199
+ var hex = match[1];
1200
+ if (hex.length === 3) {
1201
+ hex = hex.split("").map(function(c) {
1202
+ return c + c;
1203
+ }).join("");
1204
+ }
1205
+ return "#" + hex.toLowerCase();
1206
+ }
1207
+ function colorControl(onValue) {
1208
+ var box = element("div", { "class": "input-group input-group-sm ge-style-color" });
1209
+ var picker = box.appendChild(element("input", { type: "color", "class": "form-control form-control-color" }));
1210
+ var text = box.appendChild(textInput());
1211
+ picker.addEventListener("input", function() {
1212
+ removeClass(text, "is-invalid");
1213
+ text.value = picker.value;
1214
+ onValue(picker.value, text);
1215
+ });
1216
+ text.addEventListener("change", function() {
1217
+ var hex = pickable(text.value);
1218
+ if (hex) {
1219
+ picker.value = hex;
1220
+ }
1221
+ onValue(text.value, text);
1222
+ });
1223
+ return {
1224
+ element: box,
1225
+ set: function(value) {
1226
+ fill(text, value);
1227
+ var hex = pickable(value);
1228
+ if (hex) {
1229
+ picker.value = hex;
1230
+ }
1231
+ }
1232
+ };
1233
+ }
1234
+ var URL_VALUE = /^url\(\s*(["']?)(.*)\1\s*\)$/i;
1235
+ function shownUrl(value) {
1236
+ var match = URL_VALUE.exec(value.trim());
1237
+ if (!match) {
1238
+ return value;
1239
+ }
1240
+ return match[1] ? match[2].replace(/\\(["\\])/g, "$1") : match[2];
1241
+ }
1242
+ function urlValue(text) {
1243
+ text = text.trim();
1244
+ if (text === "" || /^(?:none|inherit|initial|unset|revert)$/i.test(text) || /^[a-z-]+\(/i.test(text)) {
1245
+ return text;
1246
+ }
1247
+ return 'url("' + text.replace(/(["\\])/g, "\\$1") + '")';
1248
+ }
1249
+ function tokens(value) {
1250
+ var list = [];
1251
+ var depth = 0;
1252
+ var current = "";
1253
+ for (var i = 0; i < value.length; i++) {
1254
+ var c = value.charAt(i);
1255
+ if (c === "(") {
1256
+ depth++;
1257
+ }
1258
+ if (c === ")") {
1259
+ depth--;
1260
+ }
1261
+ if (depth === 0 && (c === " " || c === ",")) {
1262
+ if (current) {
1263
+ list.push(current);
1264
+ }
1265
+ if (c === ",") {
1266
+ list.push(",");
1267
+ }
1268
+ current = "";
1269
+ } else {
1270
+ current += c;
1271
+ }
1272
+ }
1273
+ if (current) {
1274
+ list.push(current);
1275
+ }
1276
+ return list;
1277
+ }
1278
+ var LENGTH = /^-?(?:\d*\.)?\d+(?:[a-z%]+)?$/i;
1279
+ var SHADOW_PARTS = [
1280
+ { name: "x", labelKey: "style.shadow_x" },
1281
+ { name: "y", labelKey: "style.shadow_y" },
1282
+ { name: "blur", labelKey: "style.shadow_blur" },
1283
+ { name: "spread", labelKey: "style.shadow_spread" }
1284
+ ];
1285
+ function parseShadow(value, box) {
1286
+ value = value.trim();
1287
+ if (value === "") {
1288
+ return { inset: false, lengths: [], color: "" };
1289
+ }
1290
+ if (/var\(/i.test(value)) {
1291
+ return null;
1292
+ }
1293
+ var list = tokens(value);
1294
+ if (list.indexOf(",") !== -1) {
1295
+ return null;
1296
+ }
1297
+ var inset = false;
1298
+ var lengths = [];
1299
+ var colors = [];
1300
+ list.forEach(function(token) {
1301
+ if (box && token.toLowerCase() === "inset") {
1302
+ inset = true;
1303
+ } else if (LENGTH.test(token)) {
1304
+ lengths.push(token);
1305
+ } else {
1306
+ colors.push(token);
1307
+ }
1308
+ });
1309
+ if (colors.length > 1 || lengths.length < 2 || lengths.length > (box ? 4 : 3)) {
1310
+ return null;
1311
+ }
1312
+ if (colors.length && /^(?:none|inherit|initial|unset|revert)$/i.test(colors[0])) {
1313
+ return null;
1314
+ }
1315
+ return { inset, lengths, color: colors[0] || "" };
1316
+ }
1317
+ function composeShadow(parts, box) {
1318
+ var lengths = parts.lengths.slice();
1319
+ for (var i = lengths.length - 1; i >= 0; i--) {
1320
+ if (lengths[i] === "" && lengths.slice(i + 1).some(Boolean)) {
1321
+ lengths[i] = "0";
1322
+ }
1323
+ }
1324
+ lengths = lengths.filter(Boolean);
1325
+ if (!lengths.length && !parts.color && !parts.inset) {
1326
+ return "";
1327
+ }
1328
+ while (lengths.length < 2) {
1329
+ lengths.push("0");
1330
+ }
1331
+ return (box && parts.inset ? "inset " : "") + lengths.join(" ") + (parts.color ? " " + parts.color : "");
1332
+ }
1333
+ function shadowControl(ge, node, property, changed) {
1334
+ var box = property === "box-shadow";
1335
+ var holder = element("div", { "class": "ge-style-shadow" });
1336
+ var textMode = false;
1337
+ function writeValue(value, input) {
1338
+ var ok = write(ge, node, property, value);
1339
+ mark(input, ok, ge);
1340
+ if (ok) {
1341
+ changed();
1342
+ }
1343
+ return ok;
1344
+ }
1345
+ function builder(parts) {
1346
+ holder.innerHTML = "";
1347
+ var grid = holder.appendChild(element("div", { "class": "ge-style-shadow-builder" }));
1348
+ var names = box ? SHADOW_PARTS : SHADOW_PARTS.slice(0, 3);
1349
+ var inputs = names.map(function(part, i) {
1350
+ var cell = grid.appendChild(element("label", { "class": "ge-style-shadow-part" }));
1351
+ cell.appendChild(element("span", { "class": "ge-style-shadow-label" }, ge.t(part.labelKey)));
1352
+ var input = cell.appendChild(textInput("ge-style-shadow-" + part.name));
1353
+ input.value = parts.lengths[i] || "";
1354
+ return input;
1355
+ });
1356
+ var colorCell = grid.appendChild(element("label", { "class": "ge-style-shadow-part ge-style-shadow-color" }));
1357
+ colorCell.appendChild(element("span", { "class": "ge-style-shadow-label" }, ge.t("style.shadow_color")));
1358
+ var color = colorControl(function() {
1359
+ update();
1360
+ });
1361
+ colorCell.appendChild(color.element);
1362
+ color.set(parts.color);
1363
+ var inset = null;
1364
+ if (box) {
1365
+ var insetCell = grid.appendChild(element("label", { "class": "form-check ge-style-shadow-inset" }));
1366
+ inset = insetCell.appendChild(element("input", { type: "checkbox", "class": "form-check-input" }));
1367
+ insetCell.appendChild(element("span", { "class": "form-check-label" }, ge.t("style.shadow_inset")));
1368
+ inset.checked = parts.inset;
1369
+ inset.addEventListener("change", function() {
1370
+ update();
1371
+ });
1372
+ }
1373
+ inputs.forEach(function(input) {
1374
+ input.addEventListener("change", function() {
1375
+ update();
1376
+ });
1377
+ });
1378
+ var toText = holder.appendChild(element("a", { href: "#", "class": "ge-style-shadow-mode" }, ge.t("style.shadow_text_mode")));
1379
+ toText.addEventListener("click", function(e) {
1380
+ e.preventDefault();
1381
+ textMode = true;
1382
+ render();
1383
+ });
1384
+ function update() {
1385
+ var value = composeShadow({
1386
+ inset: inset ? inset.checked : false,
1387
+ lengths: inputs.map(function(input) {
1388
+ return input.value.trim();
1389
+ }),
1390
+ color: one(color.element, 'input[type="text"]').value.trim()
1391
+ }, box);
1392
+ writeValue(value, inputs[0]);
1393
+ }
1394
+ }
1395
+ function text(value) {
1396
+ holder.innerHTML = "";
1397
+ var input = holder.appendChild(textInput("ge-style-shadow-text"));
1398
+ input.value = value;
1399
+ input.addEventListener("change", function() {
1400
+ if (input.value.trim() === "") {
1401
+ if (writeValue("", input)) {
1402
+ textMode = false;
1403
+ render();
1404
+ }
1405
+ return;
1406
+ }
1407
+ writeValue(input.value, input);
1408
+ });
1409
+ }
1410
+ var shown = null;
1411
+ function render() {
1412
+ if (holder.querySelector(".is-invalid")) {
1413
+ return;
1414
+ }
1415
+ var value = ge.hostStyle(node, property).value;
1416
+ var parts = parseShadow(value, box);
1417
+ if (value === shown && holder.firstChild && textMode === !!holder.querySelector(".ge-style-shadow-text")) {
1418
+ return;
1419
+ }
1420
+ shown = value;
1421
+ if (textMode || !parts) {
1422
+ textMode = !!value || textMode;
1423
+ text(value);
1424
+ } else {
1425
+ builder(parts);
1426
+ }
1427
+ }
1428
+ return { element: holder, render, value: function() {
1429
+ return ge.hostStyle(node, property).value;
1430
+ } };
1431
+ }
1432
+ function createStyleField(ge, node, property, changed) {
1433
+ var field = element("div", { "class": "ge-style-field", "data-ge-style-property": property.name });
1434
+ var label = field.appendChild(element("label", { "class": "ge-style-label" }, ge.t(property.labelKey)));
1435
+ var render;
1436
+ function current() {
1437
+ return ge.hostStyle(node, property.name).value;
1438
+ }
1439
+ function commit(value, input2) {
1440
+ var ok = write(ge, node, property.name, value);
1441
+ mark(input2, ok, ge);
1442
+ if (ok) {
1443
+ changed();
1444
+ }
1445
+ }
1446
+ if (property.type === "select") {
1447
+ var select = field.appendChild(element("select", { "class": "form-select form-select-sm" }));
1448
+ select.addEventListener("change", function() {
1449
+ commit(select.value, select);
1450
+ });
1451
+ render = function() {
1452
+ var value = current();
1453
+ var values = property.values.slice();
1454
+ if (value && values.indexOf(value) === -1) {
1455
+ values.push(value);
1456
+ }
1457
+ select.innerHTML = "";
1458
+ select.appendChild(element("option", { value: "" }, ""));
1459
+ values.forEach(function(each2) {
1460
+ select.appendChild(element("option", { value: each2 }, each2));
1461
+ });
1462
+ select.value = value;
1463
+ };
1464
+ } else if (property.type === "color") {
1465
+ var color = colorControl(function(value, input2) {
1466
+ commit(value, input2);
1467
+ });
1468
+ field.appendChild(color.element);
1469
+ render = function() {
1470
+ color.set(current());
1471
+ };
1472
+ } else if (property.type === "url") {
1473
+ var url = field.appendChild(textInput());
1474
+ url.addEventListener("change", function() {
1475
+ commit(urlValue(url.value), url);
1476
+ });
1477
+ render = function() {
1478
+ fill(url, shownUrl(current()));
1479
+ };
1480
+ } else if (property.type === "shadow") {
1481
+ var shadow = shadowControl(ge, node, property.name, changed);
1482
+ field.appendChild(shadow.element);
1483
+ render = shadow.render;
1484
+ } else {
1485
+ var input = field.appendChild(textInput());
1486
+ input.addEventListener("change", function() {
1487
+ commit(input.value, input);
1488
+ });
1489
+ render = function() {
1490
+ fill(input, current());
1491
+ };
1492
+ }
1493
+ var control = field.querySelector("input, select");
1494
+ if (control) {
1495
+ control.id = "ge-style-field-" + ++fieldCounter;
1496
+ label.setAttribute("for", control.id);
1497
+ }
1498
+ field.appendChild(element("small", { "class": "ge-style-note ge-style-overridden" }));
1499
+ renderers.set(field, function() {
1500
+ render();
1501
+ var winner = current() ? overriding(property.name, classesOf(node)) : null;
1502
+ var note = child(field, ".ge-style-overridden");
1503
+ note.textContent = winner ? ge.t("style.overridden", { "class": winner }) : "";
1504
+ toggle(note, !!winner);
1505
+ });
1506
+ renderStyleField(field);
1507
+ return field;
1508
+ }
1509
+ function renderStyleField(field) {
1510
+ var render = renderers.get(field);
1511
+ if (render) {
1512
+ render();
1513
+ }
1514
+ }
1515
+
1516
+ // src/js/style/catalog.js
1517
+ function classesOf2(node) {
1518
+ return (node.getAttribute("class") || "").split(/\s+/).filter(Boolean);
1519
+ }
1520
+ function choose(ge, node, group2, name) {
1521
+ var details = ge.detailsOf(node);
1522
+ var input = details ? one(details, ".ge-classes") : null;
1523
+ if (!input) {
1524
+ return;
1525
+ }
1526
+ var on = classesOf2(node).indexOf(name) !== -1;
1527
+ var list = input.value.split(/\s+/).filter(Boolean).filter(function(each2) {
1528
+ if (each2 === name) {
1529
+ return false;
1530
+ }
1531
+ return !(group2.exclusive && !on && group2.classes.indexOf(each2) !== -1);
1532
+ });
1533
+ if (!on) {
1534
+ list.push(name);
1535
+ }
1536
+ input.value = list.join(" ");
1537
+ input.dispatchEvent(new Event("change", { bubbles: true }));
1538
+ }
1539
+ function createCatalog(ge, node, kind, groups) {
1540
+ var offered = groups.filter(function(group2) {
1541
+ return offeredOn(group2, kind);
1542
+ });
1543
+ if (!offered.length) {
1544
+ return null;
1545
+ }
1546
+ var box = element("div", { "class": "ge-style-catalog" });
1547
+ box.appendChild(element("span", { "class": "ge-style-label" }, ge.t("style.catalog")));
1548
+ offered.forEach(function(group2) {
1549
+ var row = box.appendChild(element("div", { "class": "ge-style-chips" }));
1550
+ group2.classes.forEach(function(name) {
1551
+ var chip = row.appendChild(element("button", {
1552
+ type: "button",
1553
+ "class": "btn btn-sm btn-outline-secondary ge-style-chip",
1554
+ "data-ge-class": name,
1555
+ "aria-pressed": "false"
1556
+ }, name));
1557
+ chip.addEventListener("click", function() {
1558
+ choose(ge, node, group2, name);
1559
+ });
1560
+ });
1561
+ });
1562
+ renderCatalog(box, node);
1563
+ return box;
1564
+ }
1565
+ function renderCatalog(box, node) {
1566
+ var classes = classesOf2(node);
1567
+ all(box, ".ge-style-chip").forEach(function(chip) {
1568
+ var on = classes.indexOf(chip.getAttribute("data-ge-class")) !== -1;
1569
+ toggleClass(chip, "active", on);
1570
+ chip.setAttribute("aria-pressed", on ? "true" : "false");
1571
+ });
1572
+ }
1573
+
1574
+ // src/js/style/custom.js
1575
+ function longhands(property) {
1576
+ var probe = document.createElement("div").style;
1577
+ var list = [];
1578
+ probe.setProperty(property, "initial");
1579
+ for (var i = 0; i < probe.length; i++) {
1580
+ list.push(probe[i]);
1581
+ }
1582
+ return list.length ? list : [property];
1583
+ }
1584
+ function declaration(cssText) {
1585
+ var style = document.createElement("div").style;
1586
+ style.cssText = cssText;
1587
+ return style;
1588
+ }
1589
+ function createCustom(ge, node, properties, changed) {
1590
+ var covered = {};
1591
+ properties.forEach(function(property) {
1592
+ longhands(property).forEach(function(longhand) {
1593
+ covered[longhand] = true;
1594
+ });
1595
+ });
1596
+ var box = element("div", { "class": "ge-style-custom" });
1597
+ var textarea = box.appendChild(element("textarea", {
1598
+ "class": "form-control form-control-sm font-monospace ge-style-custom-css",
1599
+ rows: "4",
1600
+ spellcheck: "false",
1601
+ "aria-label": ge.t("style.section_custom")
1602
+ }));
1603
+ function free() {
1604
+ var style = declaration(ge.hostStyle(node));
1605
+ var rest = document.createElement("div").style;
1606
+ for (var i = 0; i < style.length; i++) {
1607
+ var name = style[i];
1608
+ if (!covered[name]) {
1609
+ rest.setProperty(name, style.getPropertyValue(name), style.getPropertyPriority(name));
1610
+ }
1611
+ }
1612
+ return rest;
1613
+ }
1614
+ textarea.addEventListener("change", function() {
1615
+ var before = free();
1616
+ var wanted = declaration(textarea.value);
1617
+ var i;
1618
+ for (i = 0; i < before.length; i++) {
1619
+ if (wanted.getPropertyValue(before[i]) === "") {
1620
+ ge.setHostStyle(node, before[i], "");
1621
+ }
1622
+ }
1623
+ for (i = 0; i < wanted.length; i++) {
1624
+ ge.setHostStyle(node, wanted[i], wanted.getPropertyValue(wanted[i]), wanted.getPropertyPriority(wanted[i]));
1625
+ }
1626
+ render();
1627
+ changed();
1628
+ });
1629
+ function render() {
1630
+ if (document.activeElement === textarea) {
1631
+ return;
1632
+ }
1633
+ textarea.value = free().cssText.replace(/; /g, ";\n");
1634
+ }
1635
+ render();
1636
+ return { element: box, render };
1637
+ }
1638
+
1639
+ // src/js/style/accordion.js
1640
+ function takesInlineStyle(node, kind) {
1641
+ if (kind === "row" || kind === "column" || kind === "element" || kind === "section") {
1642
+ return true;
1643
+ }
1644
+ if (is(node, "[data-ge-container]")) {
1645
+ return true;
1646
+ }
1647
+ return !!child(node, ".ge-tools-drawer.ge-pane-drawer");
1648
+ }
1649
+ function familyApplies(family, node, kind) {
1650
+ if (kind === "plain") {
1651
+ kind = "text";
1652
+ }
1653
+ if (family.appliesTo.indexOf(kind) !== -1) {
1654
+ return true;
1655
+ }
1656
+ return family.appliesTo.indexOf("container") !== -1 && is(node, "[data-ge-container]");
1657
+ }
1658
+ function partContent(ge, part, node, kind) {
1659
+ if (part.panel) {
1660
+ return part.panel(node, kind);
1661
+ }
1662
+ var fields = part.families.filter(function(family) {
1663
+ return familyApplies(family, node, kind);
1664
+ }).map(function(family) {
1665
+ return ge.utilityField(node, family.name);
1666
+ });
1667
+ if (fields.length < 2) {
1668
+ return fields[0] || null;
1669
+ }
1670
+ var box = element("div", { "class": "ge-style-part-fields" });
1671
+ fields.forEach(function(field) {
1672
+ box.appendChild(field);
1673
+ });
1674
+ return box;
1675
+ }
1676
+ function createAccordion(ge, node, kind, context) {
1677
+ var inline = takesInlineStyle(node, kind);
1678
+ var accordion = element("div", { "class": "accordion ge-style" });
1679
+ var fields = [];
1680
+ var catalogs = [];
1681
+ var notes = [];
1682
+ var custom = null;
1683
+ var customItem = null;
1684
+ var changed = function() {
1685
+ render();
1686
+ };
1687
+ function item(key, labelKey) {
1688
+ var entry = accordion.appendChild(element("div", { "class": "accordion-item", "data-ge-style-section": key }));
1689
+ var header = entry.appendChild(element("h2", { "class": "accordion-header" }));
1690
+ var button = header.appendChild(element("button", {
1691
+ type: "button",
1692
+ "class": "accordion-button collapsed",
1693
+ "aria-expanded": "false"
1694
+ }, ge.t(labelKey)));
1695
+ var collapse = entry.appendChild(element("div", { "class": "accordion-collapse collapse" }));
1696
+ var body = collapse.appendChild(element("div", { "class": "accordion-body" }));
1697
+ button.addEventListener("click", function() {
1698
+ var opening = !hasClass(collapse, "show");
1699
+ context.state.open = opening ? key : null;
1700
+ context.opened(context.state.open);
1701
+ });
1702
+ return { entry, body };
1703
+ }
1704
+ function toggle2(entry, shown) {
1705
+ toggleClass(one(entry, ".accordion-collapse"), "show", shown);
1706
+ var button = one(entry, ".accordion-button");
1707
+ toggleClass(button, "collapsed", !shown);
1708
+ button.setAttribute("aria-expanded", shown ? "true" : "false");
1709
+ }
1710
+ Object.keys(context.sections).forEach(function(key) {
1711
+ var resolved = context.sections[key];
1712
+ var section2 = resolved.section;
1713
+ if (section2.custom) {
1714
+ if (inline) {
1715
+ customItem = item(key, section2.labelKey);
1716
+ }
1717
+ return;
1718
+ }
1719
+ var parts = section2.parts.map(function(name) {
1720
+ return context.parts[name] ? partContent(ge, context.parts[name], node, kind) : null;
1721
+ }).filter(Boolean);
1722
+ var properties = inline ? resolved.properties.filter(function(property) {
1723
+ return offeredOn(property, kind);
1724
+ }) : [];
1725
+ var catalog = inline && resolved.catalog ? createCatalog(ge, node, kind, section2.catalog) : null;
1726
+ if (!parts.length && !properties.length && !catalog) {
1727
+ return;
1728
+ }
1729
+ var body = item(key, section2.labelKey).body;
1730
+ parts.forEach(function(part) {
1731
+ body.appendChild(addClass(part, "ge-style-part"));
1732
+ });
1733
+ if (properties.length) {
1734
+ var note = body.appendChild(element("small", { "class": "ge-style-note ge-style-all-sizes" }, ge.t("style.all_sizes")));
1735
+ notes.push(note);
1736
+ var grid = body.appendChild(element("div", { "class": "ge-style-fields" }));
1737
+ properties.forEach(function(property) {
1738
+ var field = createStyleField(ge, node, property, changed);
1739
+ fields.push(field);
1740
+ grid.appendChild(field);
1741
+ });
1742
+ }
1743
+ if (catalog) {
1744
+ catalogs.push(catalog);
1745
+ body.appendChild(catalog);
1746
+ }
1747
+ });
1748
+ if (customItem) {
1749
+ custom = createCustom(ge, node, fields.map(function(field) {
1750
+ return field.getAttribute("data-ge-style-property");
1751
+ }), changed);
1752
+ customItem.body.appendChild(custom.element);
1753
+ accordion.appendChild(customItem.entry);
1754
+ }
1755
+ if (!accordion.children.length) {
1756
+ return null;
1757
+ }
1758
+ function open(key) {
1759
+ all(accordion, ".accordion-item").forEach(function(entry) {
1760
+ toggle2(entry, entry.getAttribute("data-ge-style-section") === key);
1761
+ });
1762
+ }
1763
+ open(context.state.open);
1764
+ function render() {
1765
+ fields.forEach(renderStyleField);
1766
+ catalogs.forEach(function(catalog) {
1767
+ renderCatalog(catalog, node);
1768
+ });
1769
+ if (custom) {
1770
+ custom.render();
1771
+ }
1772
+ notes.forEach(function(note) {
1773
+ toggle(note, ge.view() !== "all");
1774
+ });
1775
+ }
1776
+ render();
1777
+ return { element: accordion, render, open };
1778
+ }
1779
+
1780
+ // src/js/plugins/grideditor.style.js
1781
+ Object.assign(GridEditor.locales.en, {
1782
+ "style.section_title": "Style",
1783
+ "style.dialog_title": "Style: {kind}",
1784
+ "style.section_size": "Size",
1785
+ "style.section_spacing": "Spacing",
1786
+ "style.section_border": "Border",
1787
+ "style.section_background": "Background",
1788
+ "style.section_text": "Text",
1789
+ "style.section_typography": "Typography",
1790
+ "style.section_display": "Display",
1791
+ "style.section_flex": "Flex",
1792
+ "style.section_position": "Position",
1793
+ "style.section_custom": "Custom css",
1794
+ "style.all_sizes": "Applies to every size",
1795
+ "style.overridden": "The class {class} takes priority over this value",
1796
+ "style.invalid": "Not a value this property takes",
1797
+ "style.catalog": "Bootstrap classes",
1798
+ "style.shadow_x": "X",
1799
+ "style.shadow_y": "Y",
1800
+ "style.shadow_blur": "Blur",
1801
+ "style.shadow_spread": "Spread",
1802
+ "style.shadow_color": "Color",
1803
+ "style.shadow_inset": "Inset",
1804
+ "style.shadow_text_mode": "Edit as text",
1805
+ "style.prop_width": "Width",
1806
+ "style.prop_height": "Height",
1807
+ "style.prop_min_width": "Min width",
1808
+ "style.prop_min_height": "Min height",
1809
+ "style.prop_max_width": "Max width",
1810
+ "style.prop_max_height": "Max height",
1811
+ "style.prop_margin_top": "Margin top",
1812
+ "style.prop_margin_right": "Margin right",
1813
+ "style.prop_margin_bottom": "Margin bottom",
1814
+ "style.prop_margin_left": "Margin left",
1815
+ "style.prop_padding_top": "Padding top",
1816
+ "style.prop_padding_right": "Padding right",
1817
+ "style.prop_padding_bottom": "Padding bottom",
1818
+ "style.prop_padding_left": "Padding left",
1819
+ "style.prop_border_width": "Border width",
1820
+ "style.prop_border_style": "Border style",
1821
+ "style.prop_border_color": "Border color",
1822
+ "style.prop_border_radius": "Border radius",
1823
+ "style.prop_box_shadow": "Shadow",
1824
+ "style.prop_background_color": "Background color",
1825
+ "style.prop_background_image": "Background image",
1826
+ "style.prop_background_size": "Background size",
1827
+ "style.prop_background_position": "Background position",
1828
+ "style.prop_background_repeat": "Background repeat",
1829
+ "style.prop_color": "Color",
1830
+ "style.prop_font_size": "Font size",
1831
+ "style.prop_text_align": "Text align",
1832
+ "style.prop_text_shadow": "Text shadow",
1833
+ "style.prop_font_family": "Font family",
1834
+ "style.prop_font_weight": "Font weight",
1835
+ "style.prop_font_style": "Font style",
1836
+ "style.prop_line_height": "Line height",
1837
+ "style.prop_letter_spacing": "Letter spacing",
1838
+ "style.prop_text_transform": "Text transform",
1839
+ "style.prop_text_decoration": "Text decoration",
1840
+ "style.prop_display": "Display",
1841
+ "style.prop_opacity": "Opacity",
1842
+ "style.prop_overflow": "Overflow",
1843
+ "style.prop_visibility": "Visibility",
1844
+ "style.prop_position": "Position",
1845
+ "style.prop_top": "Top",
1846
+ "style.prop_right": "Right",
1847
+ "style.prop_bottom": "Bottom",
1848
+ "style.prop_left": "Left",
1849
+ "style.prop_z_index": "Z-index"
1850
+ });
1851
+ var PARTS = ["spacing", "textalign", "display", "flex", "float", "sticky", "drawerflow"];
1852
+ GridEditor.utilities.style = function(ge) {
1853
+ var options = resolveOptions(ge);
1854
+ var parts = {
1855
+ spacing: spacingPart(ge, options.spacing),
1856
+ textalign: textalignPart(ge),
1857
+ display: displayPart(ge, options.visibility),
1858
+ flex: flexPart(ge, options.spacing),
1859
+ float: floatPart(ge),
1860
+ sticky: stickyPart(ge),
1861
+ drawerflow: drawerflowPart(ge)
1862
+ };
1863
+ var accordions = [];
1864
+ var context = {
1865
+ sections: options.sections,
1866
+ parts,
1867
+ state: { open: null },
1868
+ opened: function(key) {
1869
+ accordions.forEach(function(entry) {
1870
+ entry.accordion.open(key);
1871
+ });
1872
+ }
1873
+ };
1874
+ function each2(hook) {
1875
+ return function() {
1876
+ var args = arguments;
1877
+ PARTS.forEach(function(name) {
1878
+ if (parts[name][hook]) {
1879
+ parts[name][hook].apply(null, args);
1880
+ }
1881
+ });
1882
+ };
1883
+ }
1884
+ var partsRefresh = each2("onRefresh");
1885
+ return {
1886
+ // The parts' families, edited in the sections rather than in Responsive
1887
+ families: PARTS.reduce(function(all2, name) {
1888
+ return all2.concat(parts[name].families.map(function(family) {
1889
+ return Object.assign({}, family, { panel: false });
1890
+ }));
1891
+ }, []),
1892
+ panelSection: function(node, kind) {
1893
+ var accordion = createAccordion(ge, node, kind, context);
1894
+ if (!accordion) {
1895
+ return null;
1896
+ }
1897
+ accordions.push({ node, accordion });
1898
+ return { labelKey: "style.section_title", titleKey: "style.dialog_title", body: accordion.element };
1899
+ },
1900
+ preview: function(node, kind, breakpoint) {
1901
+ return parts.spacing.preview(node, kind, breakpoint);
1902
+ },
1903
+ // After a write, a change of classes or of view: the accordions of
1904
+ // the nodes it touched follow
1905
+ onRefresh: function(scope) {
1906
+ partsRefresh(scope);
1907
+ accordions = accordions.filter(function(entry) {
1908
+ return entry.accordion.element.isConnected;
1909
+ });
1910
+ accordions.forEach(function(entry) {
1911
+ if (entry.node === scope || scope.contains(entry.node)) {
1912
+ entry.accordion.render();
1913
+ }
1914
+ });
1915
+ },
1916
+ drawerTools: each2("drawerTools"),
1917
+ onDeinit: function() {
1918
+ each2("onDeinit")();
1919
+ accordions = [];
1920
+ }
1921
+ };
1922
+ };
1923
+ })();