@themarioga/grid-editor 7.2.0 → 7.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.
- package/CHANGELOG.md +41 -0
- package/README.md +83 -14
- package/UPGRADING.md +31 -0
- package/dist/grideditor.bundle.min.js +2 -2
- package/dist/grideditor.css +102 -0
- package/dist/grideditor.d.ts +18 -0
- package/dist/grideditor.esm.js +291 -31
- package/dist/grideditor.js +291 -31
- package/dist/grideditor.min.css +1 -1
- package/dist/grideditor.min.css.map +1 -1
- package/dist/grideditor.min.js +1 -1
- package/dist/grideditor.min.js.map +3 -3
- package/dist/locales/grideditor.es.esm.js +67 -0
- package/dist/locales/grideditor.es.js +67 -0
- package/dist/locales/grideditor.es.min.js +1 -1
- package/dist/locales/grideditor.es.min.js.map +2 -2
- package/dist/plugins/grideditor.float.esm.js +10 -1
- package/dist/plugins/grideditor.float.js +8 -2
- package/dist/plugins/grideditor.float.min.js +1 -1
- package/dist/plugins/grideditor.float.min.js.map +4 -4
- package/dist/plugins/grideditor.spacing.esm.js +12 -3
- package/dist/plugins/grideditor.spacing.js +9 -3
- package/dist/plugins/grideditor.spacing.min.js +1 -1
- package/dist/plugins/grideditor.spacing.min.js.map +4 -4
- package/dist/plugins/grideditor.style.esm.js +1593 -0
- package/dist/plugins/grideditor.style.js +1592 -0
- package/dist/plugins/grideditor.style.min.js +2 -0
- package/dist/plugins/grideditor.style.min.js.map +7 -0
- package/dist/plugins/grideditor.textalign.esm.js +10 -1
- package/dist/plugins/grideditor.textalign.js +8 -2
- package/dist/plugins/grideditor.textalign.min.js +1 -1
- package/dist/plugins/grideditor.textalign.min.js.map +4 -4
- package/dist/plugins/grideditor.visibility.esm.js +12 -3
- package/dist/plugins/grideditor.visibility.js +9 -3
- package/dist/plugins/grideditor.visibility.min.js +1 -1
- package/dist/plugins/grideditor.visibility.min.js.map +4 -4
- package/docs/locale-keys.md +86 -7
- package/docs/plugins.md +49 -5
- package/example/index.html +14 -0
- package/example/style.html +151 -0
- package/example/utilities.html +15 -11
- package/package.json +1 -1
- package/src/js/grideditor.js +365 -27
- package/src/js/locales/grideditor.es.js +67 -0
- package/src/js/plugins/grideditor.float.js +8 -33
- package/src/js/plugins/grideditor.spacing.js +8 -273
- package/src/js/plugins/grideditor.style.js +179 -0
- package/src/js/plugins/grideditor.textalign.js +8 -39
- package/src/js/plugins/grideditor.visibility.js +8 -147
- package/src/js/style/accordion.js +157 -0
- package/src/js/style/catalog.js +76 -0
- package/src/js/style/custom.js +84 -0
- package/src/js/style/fields.js +382 -0
- package/src/js/style/float.js +46 -0
- package/src/js/style/options.js +75 -0
- package/src/js/style/sections.js +271 -0
- package/src/js/style/spacing.js +286 -0
- package/src/js/style/textalign.js +52 -0
- package/src/js/style/visibility.js +160 -0
- package/src/less/grideditor.less +111 -0
- package/types/grideditor.d.ts +18 -0
|
@@ -0,0 +1,1592 @@
|
|
|
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 NODES2 = ".row, .column, .ge-element, [data-ge-container]";
|
|
282
|
+
function mark2(scope) {
|
|
283
|
+
selfAndAll(scope, NODES2).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/visibility.js
|
|
399
|
+
Object.assign(GridEditor.locales.en, {
|
|
400
|
+
"utility.visibility": "Visibility",
|
|
401
|
+
"utility.visibility_hidden": "Hidden",
|
|
402
|
+
"utility.visibility_shown": "Shown",
|
|
403
|
+
"tool.hide_in_view": "Hide in this view",
|
|
404
|
+
"tool.show_in_view": "Show in this view",
|
|
405
|
+
"badge.hidden_in": "Hidden at {breakpoints}"
|
|
406
|
+
});
|
|
407
|
+
var CLASS_PATTERN = /(?:^|\s)d-(?:(?:sm|md|lg|xl|xxl)-)?(?:none|block|flex)(?:\s|$)/;
|
|
408
|
+
var NODES = ".row, .column, .ge-content, .ge-element, [data-ge-container]";
|
|
409
|
+
function visibilityPart(ge, given) {
|
|
410
|
+
var options = Object.assign({ drawer: true }, given);
|
|
411
|
+
function shown(kind) {
|
|
412
|
+
return kind === "row" ? "flex" : "block";
|
|
413
|
+
}
|
|
414
|
+
function applies(node, kind) {
|
|
415
|
+
return kind === "row" || kind === "column" || kind === "element" || kind === "text" || kind === "plain" || is(node, "[data-ge-container]");
|
|
416
|
+
}
|
|
417
|
+
function hiddenAt(node, view) {
|
|
418
|
+
return ge.getUtility(node, "visibility", view) === "none";
|
|
419
|
+
}
|
|
420
|
+
function hiddenTiers(node) {
|
|
421
|
+
return ge.breakpoints.filter(function(key) {
|
|
422
|
+
return hiddenAt(node, key);
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function hiddenHere(node) {
|
|
426
|
+
return ge.view() === "all" ? hiddenTiers(node).length === ge.breakpoints.length : hiddenAt(node, ge.view());
|
|
427
|
+
}
|
|
428
|
+
function hiddenBelow(node) {
|
|
429
|
+
var index = ge.breakpoints.indexOf(ge.view());
|
|
430
|
+
return index > 0 && hiddenAt(node, ge.breakpoints[index - 1]);
|
|
431
|
+
}
|
|
432
|
+
function toggle2(node, kind) {
|
|
433
|
+
var hide2 = !hiddenHere(node);
|
|
434
|
+
var value;
|
|
435
|
+
if (ge.view() === "all") {
|
|
436
|
+
value = hide2 ? "none" : null;
|
|
437
|
+
} else if (hide2) {
|
|
438
|
+
value = hiddenBelow(node) ? null : "none";
|
|
439
|
+
} else {
|
|
440
|
+
value = hiddenBelow(node) ? shown(kind) : null;
|
|
441
|
+
}
|
|
442
|
+
ge.setUtility(node, "visibility", value, { source: "tool" });
|
|
443
|
+
}
|
|
444
|
+
function mark2(scope) {
|
|
445
|
+
selfAndAll(scope, NODES).forEach(function(node) {
|
|
446
|
+
var kind = ge.kindOf(node);
|
|
447
|
+
var carries = applies(node, kind) && CLASS_PATTERN.test(node.getAttribute("class") || "");
|
|
448
|
+
var tiers = carries ? hiddenTiers(node) : [];
|
|
449
|
+
var here = carries && hiddenHere(node);
|
|
450
|
+
var partly = carries && ge.view() === "all" && tiers.length > 0 && !here;
|
|
451
|
+
toggleClass(node, "ge-visibility", carries);
|
|
452
|
+
toggleClass(node, "ge-hidden-in-view", here);
|
|
453
|
+
if (partly) {
|
|
454
|
+
node.setAttribute("data-ge-hidden-in", ge.t("badge.hidden_in", { breakpoints: tiers.join(", ") }));
|
|
455
|
+
} else {
|
|
456
|
+
node.removeAttribute("data-ge-hidden-in");
|
|
457
|
+
}
|
|
458
|
+
children(node, ".ge-tools-drawer").forEach(function(drawer) {
|
|
459
|
+
children(drawer, ".ge-visibility-tool").forEach(function(tool) {
|
|
460
|
+
tool.setAttribute("title", here ? ge.t("tool.show_in_view") : ge.t("tool.hide_in_view"));
|
|
461
|
+
all(tool, "i").forEach(function(icon) {
|
|
462
|
+
icon.setAttribute("class", here ? "bi bi-eye-slash" : "bi bi-eye");
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
function unmark() {
|
|
469
|
+
all(ge.canvas, ".ge-visibility, .ge-hidden-in-view, [data-ge-hidden-in]").forEach(function(node) {
|
|
470
|
+
removeClass(node, "ge-visibility ge-hidden-in-view");
|
|
471
|
+
node.removeAttribute("data-ge-hidden-in");
|
|
472
|
+
dropEmptyClass(node);
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
return {
|
|
476
|
+
families: [{
|
|
477
|
+
name: "visibility",
|
|
478
|
+
prefix: "d",
|
|
479
|
+
values: ["none", "block", "flex"],
|
|
480
|
+
appliesTo: ["row", "column", "text", "element", "container"],
|
|
481
|
+
labelKey: "utility.visibility",
|
|
482
|
+
/** Hidden, or shown the way this kind of node is shown. */
|
|
483
|
+
choices: function(node, kind) {
|
|
484
|
+
return ["none", shown(kind)];
|
|
485
|
+
},
|
|
486
|
+
label: function(value) {
|
|
487
|
+
return value === "none" ? ge.t("utility.visibility_hidden") : ge.t("utility.visibility_shown");
|
|
488
|
+
}
|
|
489
|
+
}],
|
|
490
|
+
drawerTools: function(drawer, node, kind) {
|
|
491
|
+
if (!options.drawer || !applies(node, kind)) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
ge.createTool(drawer, ge.t("tool.hide_in_view"), "ge-visibility-tool", "bi bi-eye", function() {
|
|
495
|
+
toggle2(node, kind);
|
|
496
|
+
});
|
|
497
|
+
},
|
|
498
|
+
onRefresh: mark2,
|
|
499
|
+
onDeinit: unmark
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/js/style/float.js
|
|
504
|
+
Object.assign(GridEditor.locales.en, {
|
|
505
|
+
"utility.float": "Float",
|
|
506
|
+
"utility.float_start": "Start",
|
|
507
|
+
"utility.float_end": "End",
|
|
508
|
+
"utility.float_none": "None"
|
|
509
|
+
});
|
|
510
|
+
var CSS2 = { start: "left", end: "right", none: "none" };
|
|
511
|
+
function floatPart(ge) {
|
|
512
|
+
function label(value) {
|
|
513
|
+
if (value === "start") {
|
|
514
|
+
return ge.t("utility.float_start");
|
|
515
|
+
}
|
|
516
|
+
if (value === "end") {
|
|
517
|
+
return ge.t("utility.float_end");
|
|
518
|
+
}
|
|
519
|
+
return ge.t("utility.float_none");
|
|
520
|
+
}
|
|
521
|
+
return {
|
|
522
|
+
families: [{
|
|
523
|
+
name: "float",
|
|
524
|
+
prefix: "float",
|
|
525
|
+
values: ["start", "end", "none"],
|
|
526
|
+
appliesTo: ["element"],
|
|
527
|
+
labelKey: "utility.float",
|
|
528
|
+
label,
|
|
529
|
+
/** With no class applying here, whatever the host's css floats it as. */
|
|
530
|
+
preview: function(value, node) {
|
|
531
|
+
return { float: value === null ? ge.bareStyle(node, "float", "float") : CSS2[value] };
|
|
532
|
+
}
|
|
533
|
+
}]
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// src/js/style/sections.js
|
|
538
|
+
var COLORS = ["primary", "secondary", "success", "danger", "warning", "info", "light", "dark"];
|
|
539
|
+
var SIDES2 = ["top", "end", "bottom", "start"];
|
|
540
|
+
function each(prefix, values, suffix) {
|
|
541
|
+
return values.map(function(value) {
|
|
542
|
+
return prefix + value + (suffix || "");
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
function group(classes, exclusive, notOn) {
|
|
546
|
+
return { classes, exclusive: exclusive !== false, notOn: notOn || [] };
|
|
547
|
+
}
|
|
548
|
+
function prop(name, options) {
|
|
549
|
+
return {
|
|
550
|
+
name,
|
|
551
|
+
labelKey: options.labelKey,
|
|
552
|
+
type: options.type || "text",
|
|
553
|
+
values: options.values || null,
|
|
554
|
+
notOn: options.notOn || []
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
var NOT_ON_COLUMN = ["column"];
|
|
558
|
+
var SECTIONS = [
|
|
559
|
+
{
|
|
560
|
+
key: "size",
|
|
561
|
+
labelKey: "style.section_size",
|
|
562
|
+
properties: [
|
|
563
|
+
prop("width", { labelKey: "style.prop_width", notOn: NOT_ON_COLUMN }),
|
|
564
|
+
prop("height", { labelKey: "style.prop_height", notOn: NOT_ON_COLUMN }),
|
|
565
|
+
prop("min-width", { labelKey: "style.prop_min_width" }),
|
|
566
|
+
prop("min-height", { labelKey: "style.prop_min_height" }),
|
|
567
|
+
prop("max-width", { labelKey: "style.prop_max_width" }),
|
|
568
|
+
prop("max-height", { labelKey: "style.prop_max_height" })
|
|
569
|
+
],
|
|
570
|
+
catalog: [
|
|
571
|
+
group(each("w-", ["25", "50", "75", "100", "auto"]), true, NOT_ON_COLUMN),
|
|
572
|
+
group(each("h-", ["25", "50", "75", "100", "auto"]), true, NOT_ON_COLUMN),
|
|
573
|
+
group(["mw-100", "mh-100", "vw-100", "vh-100", "min-vw-100", "min-vh-100"], false, NOT_ON_COLUMN)
|
|
574
|
+
],
|
|
575
|
+
parts: []
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
key: "spacing",
|
|
579
|
+
labelKey: "style.section_spacing",
|
|
580
|
+
properties: [
|
|
581
|
+
prop("margin-top", { labelKey: "style.prop_margin_top" }),
|
|
582
|
+
prop("margin-right", { labelKey: "style.prop_margin_right" }),
|
|
583
|
+
prop("margin-bottom", { labelKey: "style.prop_margin_bottom" }),
|
|
584
|
+
prop("margin-left", { labelKey: "style.prop_margin_left" }),
|
|
585
|
+
prop("padding-top", { labelKey: "style.prop_padding_top" }),
|
|
586
|
+
prop("padding-right", { labelKey: "style.prop_padding_right" }),
|
|
587
|
+
prop("padding-bottom", { labelKey: "style.prop_padding_bottom" }),
|
|
588
|
+
prop("padding-left", { labelKey: "style.prop_padding_left" })
|
|
589
|
+
],
|
|
590
|
+
catalog: [],
|
|
591
|
+
parts: ["spacing"]
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
key: "border",
|
|
595
|
+
labelKey: "style.section_border",
|
|
596
|
+
properties: [
|
|
597
|
+
prop("border-width", { labelKey: "style.prop_border_width" }),
|
|
598
|
+
prop("border-style", { labelKey: "style.prop_border_style", type: "select", values: ["none", "solid", "dashed", "dotted", "double", "groove", "ridge", "inset", "outset"] }),
|
|
599
|
+
prop("border-color", { labelKey: "style.prop_border_color", type: "color" }),
|
|
600
|
+
prop("border-radius", { labelKey: "style.prop_border_radius" }),
|
|
601
|
+
prop("box-shadow", { labelKey: "style.prop_box_shadow", type: "shadow" })
|
|
602
|
+
],
|
|
603
|
+
catalog: [
|
|
604
|
+
group(["border", "border-0"].concat(each("border-", SIDES2), each("border-", SIDES2, "-0")), false),
|
|
605
|
+
group(each("border-", ["1", "2", "3", "4", "5"])),
|
|
606
|
+
group(each("border-", COLORS.concat(["black", "white"]))),
|
|
607
|
+
group(["rounded"].concat(each("rounded-", ["0", "1", "2", "3", "4", "5", "circle", "pill"]))),
|
|
608
|
+
group(each("rounded-", SIDES2), false),
|
|
609
|
+
group(["shadow-none", "shadow-sm", "shadow", "shadow-lg"])
|
|
610
|
+
],
|
|
611
|
+
parts: []
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
key: "background",
|
|
615
|
+
labelKey: "style.section_background",
|
|
616
|
+
properties: [
|
|
617
|
+
prop("background-color", { labelKey: "style.prop_background_color", type: "color" }),
|
|
618
|
+
prop("background-image", { labelKey: "style.prop_background_image", type: "url" }),
|
|
619
|
+
prop("background-size", { labelKey: "style.prop_background_size" }),
|
|
620
|
+
prop("background-position", { labelKey: "style.prop_background_position" }),
|
|
621
|
+
prop("background-repeat", { labelKey: "style.prop_background_repeat", type: "select", values: ["repeat", "no-repeat", "repeat-x", "repeat-y", "space", "round"] })
|
|
622
|
+
],
|
|
623
|
+
catalog: [
|
|
624
|
+
group(each("bg-", COLORS.concat(["body", "body-secondary", "body-tertiary", "white", "black", "transparent"]))),
|
|
625
|
+
group(["bg-gradient"], false)
|
|
626
|
+
],
|
|
627
|
+
parts: []
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
key: "text",
|
|
631
|
+
labelKey: "style.section_text",
|
|
632
|
+
properties: [
|
|
633
|
+
prop("color", { labelKey: "style.prop_color", type: "color" }),
|
|
634
|
+
prop("font-size", { labelKey: "style.prop_font_size" }),
|
|
635
|
+
prop("text-align", { labelKey: "style.prop_text_align", type: "select", values: ["start", "center", "end", "left", "right", "justify"] }),
|
|
636
|
+
prop("text-shadow", { labelKey: "style.prop_text_shadow", type: "shadow" })
|
|
637
|
+
],
|
|
638
|
+
catalog: [
|
|
639
|
+
group(each("text-", COLORS.concat(["body", "body-secondary", "body-tertiary", "white", "black"]))),
|
|
640
|
+
group(each("fs-", ["1", "2", "3", "4", "5", "6"])),
|
|
641
|
+
group(each("text-decoration-", ["none", "underline", "line-through"]))
|
|
642
|
+
],
|
|
643
|
+
parts: ["textalign"]
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
key: "typography",
|
|
647
|
+
labelKey: "style.section_typography",
|
|
648
|
+
properties: [
|
|
649
|
+
prop("font-family", { labelKey: "style.prop_font_family" }),
|
|
650
|
+
prop("font-weight", { labelKey: "style.prop_font_weight", type: "select", values: ["100", "200", "300", "400", "500", "600", "700", "800", "900", "normal", "bold", "lighter", "bolder"] }),
|
|
651
|
+
prop("font-style", { labelKey: "style.prop_font_style", type: "select", values: ["normal", "italic", "oblique"] }),
|
|
652
|
+
prop("line-height", { labelKey: "style.prop_line_height" }),
|
|
653
|
+
prop("letter-spacing", { labelKey: "style.prop_letter_spacing" }),
|
|
654
|
+
prop("text-transform", { labelKey: "style.prop_text_transform", type: "select", values: ["none", "uppercase", "lowercase", "capitalize"] }),
|
|
655
|
+
prop("text-decoration", { labelKey: "style.prop_text_decoration", type: "select", values: ["none", "underline", "line-through", "overline"] })
|
|
656
|
+
],
|
|
657
|
+
catalog: [
|
|
658
|
+
group(each("fw-", ["lighter", "light", "normal", "medium", "semibold", "bold", "bolder"])),
|
|
659
|
+
group(each("fst-", ["italic", "normal"])),
|
|
660
|
+
group(each("lh-", ["1", "sm", "base", "lg"])),
|
|
661
|
+
group(each("text-", ["lowercase", "uppercase", "capitalize"])),
|
|
662
|
+
group(["font-monospace"], false),
|
|
663
|
+
group(["text-wrap", "text-nowrap"]),
|
|
664
|
+
group(["text-break"], false)
|
|
665
|
+
],
|
|
666
|
+
parts: []
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
key: "display",
|
|
670
|
+
labelKey: "style.section_display",
|
|
671
|
+
properties: [
|
|
672
|
+
prop("display", { labelKey: "style.prop_display", type: "select", values: ["none", "block", "inline", "inline-block", "flex", "inline-flex", "grid", "inline-grid"] }),
|
|
673
|
+
prop("opacity", { labelKey: "style.prop_opacity" }),
|
|
674
|
+
prop("overflow", { labelKey: "style.prop_overflow", type: "select", values: ["visible", "hidden", "auto", "scroll", "clip"] }),
|
|
675
|
+
prop("visibility", { labelKey: "style.prop_visibility", type: "select", values: ["visible", "hidden"] })
|
|
676
|
+
],
|
|
677
|
+
catalog: [
|
|
678
|
+
group(each("opacity-", ["0", "25", "50", "75", "100"])),
|
|
679
|
+
group(each("overflow-", ["auto", "hidden", "visible", "scroll"])),
|
|
680
|
+
group(["visible", "invisible"])
|
|
681
|
+
],
|
|
682
|
+
parts: ["visibility"]
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
key: "position",
|
|
686
|
+
labelKey: "style.section_position",
|
|
687
|
+
properties: [
|
|
688
|
+
prop("position", { labelKey: "style.prop_position", type: "select", values: ["static", "relative", "absolute", "fixed", "sticky"] }),
|
|
689
|
+
prop("top", { labelKey: "style.prop_top", notOn: NOT_ON_COLUMN }),
|
|
690
|
+
prop("right", { labelKey: "style.prop_right", notOn: NOT_ON_COLUMN }),
|
|
691
|
+
prop("bottom", { labelKey: "style.prop_bottom", notOn: NOT_ON_COLUMN }),
|
|
692
|
+
prop("left", { labelKey: "style.prop_left", notOn: NOT_ON_COLUMN }),
|
|
693
|
+
prop("z-index", { labelKey: "style.prop_z_index" })
|
|
694
|
+
],
|
|
695
|
+
catalog: [
|
|
696
|
+
group(each("position-", ["static", "relative", "absolute", "fixed", "sticky"])),
|
|
697
|
+
group(each("top-", ["0", "50", "100"])),
|
|
698
|
+
group(each("bottom-", ["0", "50", "100"])),
|
|
699
|
+
group(each("start-", ["0", "50", "100"])),
|
|
700
|
+
group(each("end-", ["0", "50", "100"])),
|
|
701
|
+
group(["translate-middle", "translate-middle-x", "translate-middle-y"]),
|
|
702
|
+
group(["z-n1", "z-0", "z-1", "z-2", "z-3"])
|
|
703
|
+
],
|
|
704
|
+
parts: ["float"]
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
key: "custom",
|
|
708
|
+
labelKey: "style.section_custom",
|
|
709
|
+
properties: [],
|
|
710
|
+
catalog: [],
|
|
711
|
+
parts: [],
|
|
712
|
+
custom: true
|
|
713
|
+
}
|
|
714
|
+
];
|
|
715
|
+
function section(key) {
|
|
716
|
+
return SECTIONS.filter(function(each_) {
|
|
717
|
+
return each_.key === key;
|
|
718
|
+
})[0] || null;
|
|
719
|
+
}
|
|
720
|
+
function offeredOn(item, kind) {
|
|
721
|
+
return item.notOn.indexOf(kind) === -1;
|
|
722
|
+
}
|
|
723
|
+
var BREAKPOINT = "(?:(?:sm|md|lg|xl|xxl)-)?";
|
|
724
|
+
var SPACER = "(?:[0-5]|auto)";
|
|
725
|
+
var COLOR = "(?:" + COLORS.join("|") + "|black|white)";
|
|
726
|
+
var BG = "(?:" + COLORS.join("|") + "|body|body-secondary|body-tertiary|white|black|transparent)";
|
|
727
|
+
var TEXT_COLOR = "(?:" + COLORS.join("|") + "|body|body-secondary|body-tertiary|white|black|muted|black-50|white-50)";
|
|
728
|
+
var BORDER = "border(?:-(?:top|end|bottom|start))?(?:-0)?";
|
|
729
|
+
function spacing(key, side) {
|
|
730
|
+
var sides = { top: "[ty]?", bottom: "[by]?", left: "[sx]?", right: "[ex]?" }[side];
|
|
731
|
+
return new RegExp("^" + key + sides + "-" + BREAKPOINT + SPACER + "$");
|
|
732
|
+
}
|
|
733
|
+
var SETS = {
|
|
734
|
+
"width": /^(?:w-(?:25|50|75|100|auto)|vw-100)$/,
|
|
735
|
+
"height": /^(?:h-(?:25|50|75|100|auto)|vh-100)$/,
|
|
736
|
+
"max-width": /^mw-100$/,
|
|
737
|
+
"max-height": /^mh-100$/,
|
|
738
|
+
"min-width": /^min-vw-100$/,
|
|
739
|
+
"min-height": /^min-vh-100$/,
|
|
740
|
+
"margin-top": spacing("m", "top"),
|
|
741
|
+
"margin-right": spacing("m", "right"),
|
|
742
|
+
"margin-bottom": spacing("m", "bottom"),
|
|
743
|
+
"margin-left": spacing("m", "left"),
|
|
744
|
+
"padding-top": spacing("p", "top"),
|
|
745
|
+
"padding-right": spacing("p", "right"),
|
|
746
|
+
"padding-bottom": spacing("p", "bottom"),
|
|
747
|
+
"padding-left": spacing("p", "left"),
|
|
748
|
+
"border-width": new RegExp("^(?:" + BORDER + "|border-[1-5])$"),
|
|
749
|
+
"border-style": new RegExp("^" + BORDER + "$"),
|
|
750
|
+
"border-color": new RegExp("^(?:" + BORDER + "|border-" + COLOR + ")$"),
|
|
751
|
+
"border-radius": /^rounded(?:-(?:[0-5]|circle|pill|top|end|bottom|start))?$/,
|
|
752
|
+
"box-shadow": /^shadow(?:-(?:none|sm|lg))?$/,
|
|
753
|
+
"background-color": new RegExp("^bg-" + BG + "$"),
|
|
754
|
+
"background-image": /^bg-gradient$/,
|
|
755
|
+
"color": new RegExp("^text-" + TEXT_COLOR + "$"),
|
|
756
|
+
"font-size": /^fs-[1-6]$/,
|
|
757
|
+
"text-align": new RegExp("^text-" + BREAKPOINT + "(?:start|center|end)$"),
|
|
758
|
+
"text-decoration": /^text-decoration-(?:none|underline|line-through)$/,
|
|
759
|
+
"font-family": /^font-monospace$/,
|
|
760
|
+
"font-weight": /^fw-(?:lighter|light|normal|medium|semibold|bold|bolder)$/,
|
|
761
|
+
"font-style": /^fst-(?:italic|normal)$/,
|
|
762
|
+
"line-height": /^lh-(?:1|sm|base|lg)$/,
|
|
763
|
+
"text-transform": /^text-(?:lowercase|uppercase|capitalize)$/,
|
|
764
|
+
"display": new RegExp("^d-" + BREAKPOINT + "(?:none|inline|inline-block|block|grid|inline-grid|table|table-row|table-cell|flex|inline-flex)$"),
|
|
765
|
+
"opacity": /^opacity-(?:0|25|50|75|100)$/,
|
|
766
|
+
"overflow": /^overflow-(?:auto|hidden|visible|scroll)$/,
|
|
767
|
+
"visibility": /^(?:visible|invisible)$/,
|
|
768
|
+
"position": /^position-(?:static|relative|absolute|fixed|sticky)$/,
|
|
769
|
+
"top": /^top-(?:0|50|100)$/,
|
|
770
|
+
"bottom": /^bottom-(?:0|50|100)$/,
|
|
771
|
+
"left": /^start-(?:0|50|100)$/,
|
|
772
|
+
"right": /^end-(?:0|50|100)$/,
|
|
773
|
+
"z-index": /^z-(?:n1|[0-3])$/
|
|
774
|
+
};
|
|
775
|
+
function overriding(property, classes) {
|
|
776
|
+
var pattern2 = SETS[property];
|
|
777
|
+
if (!pattern2) {
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
return classes.filter(function(name) {
|
|
781
|
+
return pattern2.test(name);
|
|
782
|
+
})[0] || null;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// src/js/style/options.js
|
|
786
|
+
function resolveSections(ge, given) {
|
|
787
|
+
var resolved = {};
|
|
788
|
+
Object.keys(given || {}).forEach(function(key) {
|
|
789
|
+
if (!section(key)) {
|
|
790
|
+
ge.warn('style.sections: there is no "' + key + '" section: ignored');
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
SECTIONS.forEach(function(each2) {
|
|
794
|
+
var option = given && given[each2.key] !== void 0 ? given[each2.key] : true;
|
|
795
|
+
if (option === false) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
var own = each2.properties.map(function(property) {
|
|
799
|
+
return property.name;
|
|
800
|
+
});
|
|
801
|
+
var properties = each2.properties;
|
|
802
|
+
var catalog = true;
|
|
803
|
+
if (option && typeof option === "object") {
|
|
804
|
+
if (Array.isArray(option.properties)) {
|
|
805
|
+
option.properties.forEach(function(name) {
|
|
806
|
+
if (own.indexOf(name) === -1) {
|
|
807
|
+
ge.warn("style.sections." + each2.key + ': "' + name + '" is not one of its properties: ignored');
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
properties = option.properties.filter(function(name) {
|
|
811
|
+
return own.indexOf(name) !== -1;
|
|
812
|
+
}).map(function(name) {
|
|
813
|
+
return each2.properties[own.indexOf(name)];
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
if (option.catalog === false) {
|
|
817
|
+
catalog = false;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
resolved[each2.key] = { section: each2, properties, catalog };
|
|
821
|
+
});
|
|
822
|
+
return resolved;
|
|
823
|
+
}
|
|
824
|
+
function partOption(ge, style, name) {
|
|
825
|
+
if (style[name] !== void 0) {
|
|
826
|
+
return style[name];
|
|
827
|
+
}
|
|
828
|
+
var old = (ge.settings.utilities || {})[name];
|
|
829
|
+
if (old !== void 0) {
|
|
830
|
+
ge.warn("utilities." + name + " is deprecated and will be removed in 8.0: use style." + name);
|
|
831
|
+
return old;
|
|
832
|
+
}
|
|
833
|
+
return void 0;
|
|
834
|
+
}
|
|
835
|
+
function resolveOptions(ge) {
|
|
836
|
+
var style = ge.settings.style || {};
|
|
837
|
+
return {
|
|
838
|
+
sections: resolveSections(ge, style.sections),
|
|
839
|
+
spacing: partOption(ge, style, "spacing"),
|
|
840
|
+
visibility: partOption(ge, style, "visibility")
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// src/js/style/fields.js
|
|
845
|
+
var renderers = /* @__PURE__ */ new WeakMap();
|
|
846
|
+
var fieldCounter = 0;
|
|
847
|
+
function classesOf(node) {
|
|
848
|
+
return (node.getAttribute("class") || "").split(/\s+/).filter(Boolean);
|
|
849
|
+
}
|
|
850
|
+
function write(ge, node, property, raw) {
|
|
851
|
+
var text = String(raw === null || raw === void 0 ? "" : raw).trim();
|
|
852
|
+
var important = /\s*!\s*important\s*$/i.exec(text);
|
|
853
|
+
var priority;
|
|
854
|
+
if (important) {
|
|
855
|
+
text = text.slice(0, important.index).trim();
|
|
856
|
+
priority = "important";
|
|
857
|
+
}
|
|
858
|
+
return ge.setHostStyle(node, property, text, priority);
|
|
859
|
+
}
|
|
860
|
+
function mark(input, ok, ge) {
|
|
861
|
+
toggleClass(input, "is-invalid", !ok);
|
|
862
|
+
if (ok) {
|
|
863
|
+
input.removeAttribute("title");
|
|
864
|
+
} else {
|
|
865
|
+
input.setAttribute("title", ge.t("style.invalid"));
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
function fill(input, value) {
|
|
869
|
+
if (!hasClass(input, "is-invalid")) {
|
|
870
|
+
input.value = value;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
function textInput(className) {
|
|
874
|
+
return element("input", { type: "text", "class": "form-control form-control-sm " + (className || "") });
|
|
875
|
+
}
|
|
876
|
+
var HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
877
|
+
function pickable(value) {
|
|
878
|
+
var match = HEX.exec(value.trim());
|
|
879
|
+
if (!match) {
|
|
880
|
+
return null;
|
|
881
|
+
}
|
|
882
|
+
var hex = match[1];
|
|
883
|
+
if (hex.length === 3) {
|
|
884
|
+
hex = hex.split("").map(function(c) {
|
|
885
|
+
return c + c;
|
|
886
|
+
}).join("");
|
|
887
|
+
}
|
|
888
|
+
return "#" + hex.toLowerCase();
|
|
889
|
+
}
|
|
890
|
+
function colorControl(onValue) {
|
|
891
|
+
var box = element("div", { "class": "input-group input-group-sm ge-style-color" });
|
|
892
|
+
var picker = box.appendChild(element("input", { type: "color", "class": "form-control form-control-color" }));
|
|
893
|
+
var text = box.appendChild(textInput());
|
|
894
|
+
picker.addEventListener("input", function() {
|
|
895
|
+
removeClass(text, "is-invalid");
|
|
896
|
+
text.value = picker.value;
|
|
897
|
+
onValue(picker.value, text);
|
|
898
|
+
});
|
|
899
|
+
text.addEventListener("change", function() {
|
|
900
|
+
var hex = pickable(text.value);
|
|
901
|
+
if (hex) {
|
|
902
|
+
picker.value = hex;
|
|
903
|
+
}
|
|
904
|
+
onValue(text.value, text);
|
|
905
|
+
});
|
|
906
|
+
return {
|
|
907
|
+
element: box,
|
|
908
|
+
set: function(value) {
|
|
909
|
+
fill(text, value);
|
|
910
|
+
var hex = pickable(value);
|
|
911
|
+
if (hex) {
|
|
912
|
+
picker.value = hex;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
var URL_VALUE = /^url\(\s*(["']?)(.*)\1\s*\)$/i;
|
|
918
|
+
function shownUrl(value) {
|
|
919
|
+
var match = URL_VALUE.exec(value.trim());
|
|
920
|
+
if (!match) {
|
|
921
|
+
return value;
|
|
922
|
+
}
|
|
923
|
+
return match[1] ? match[2].replace(/\\(["\\])/g, "$1") : match[2];
|
|
924
|
+
}
|
|
925
|
+
function urlValue(text) {
|
|
926
|
+
text = text.trim();
|
|
927
|
+
if (text === "" || /^(?:none|inherit|initial|unset|revert)$/i.test(text) || /^[a-z-]+\(/i.test(text)) {
|
|
928
|
+
return text;
|
|
929
|
+
}
|
|
930
|
+
return 'url("' + text.replace(/(["\\])/g, "\\$1") + '")';
|
|
931
|
+
}
|
|
932
|
+
function tokens(value) {
|
|
933
|
+
var list = [];
|
|
934
|
+
var depth = 0;
|
|
935
|
+
var current = "";
|
|
936
|
+
for (var i = 0; i < value.length; i++) {
|
|
937
|
+
var c = value.charAt(i);
|
|
938
|
+
if (c === "(") {
|
|
939
|
+
depth++;
|
|
940
|
+
}
|
|
941
|
+
if (c === ")") {
|
|
942
|
+
depth--;
|
|
943
|
+
}
|
|
944
|
+
if (depth === 0 && (c === " " || c === ",")) {
|
|
945
|
+
if (current) {
|
|
946
|
+
list.push(current);
|
|
947
|
+
}
|
|
948
|
+
if (c === ",") {
|
|
949
|
+
list.push(",");
|
|
950
|
+
}
|
|
951
|
+
current = "";
|
|
952
|
+
} else {
|
|
953
|
+
current += c;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
if (current) {
|
|
957
|
+
list.push(current);
|
|
958
|
+
}
|
|
959
|
+
return list;
|
|
960
|
+
}
|
|
961
|
+
var LENGTH = /^-?(?:\d*\.)?\d+(?:[a-z%]+)?$/i;
|
|
962
|
+
var SHADOW_PARTS = [
|
|
963
|
+
{ name: "x", labelKey: "style.shadow_x" },
|
|
964
|
+
{ name: "y", labelKey: "style.shadow_y" },
|
|
965
|
+
{ name: "blur", labelKey: "style.shadow_blur" },
|
|
966
|
+
{ name: "spread", labelKey: "style.shadow_spread" }
|
|
967
|
+
];
|
|
968
|
+
function parseShadow(value, box) {
|
|
969
|
+
value = value.trim();
|
|
970
|
+
if (value === "") {
|
|
971
|
+
return { inset: false, lengths: [], color: "" };
|
|
972
|
+
}
|
|
973
|
+
if (/var\(/i.test(value)) {
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
976
|
+
var list = tokens(value);
|
|
977
|
+
if (list.indexOf(",") !== -1) {
|
|
978
|
+
return null;
|
|
979
|
+
}
|
|
980
|
+
var inset = false;
|
|
981
|
+
var lengths = [];
|
|
982
|
+
var colors = [];
|
|
983
|
+
list.forEach(function(token) {
|
|
984
|
+
if (box && token.toLowerCase() === "inset") {
|
|
985
|
+
inset = true;
|
|
986
|
+
} else if (LENGTH.test(token)) {
|
|
987
|
+
lengths.push(token);
|
|
988
|
+
} else {
|
|
989
|
+
colors.push(token);
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
if (colors.length > 1 || lengths.length < 2 || lengths.length > (box ? 4 : 3)) {
|
|
993
|
+
return null;
|
|
994
|
+
}
|
|
995
|
+
if (colors.length && /^(?:none|inherit|initial|unset|revert)$/i.test(colors[0])) {
|
|
996
|
+
return null;
|
|
997
|
+
}
|
|
998
|
+
return { inset, lengths, color: colors[0] || "" };
|
|
999
|
+
}
|
|
1000
|
+
function composeShadow(parts, box) {
|
|
1001
|
+
var lengths = parts.lengths.slice();
|
|
1002
|
+
for (var i = lengths.length - 1; i >= 0; i--) {
|
|
1003
|
+
if (lengths[i] === "" && lengths.slice(i + 1).some(Boolean)) {
|
|
1004
|
+
lengths[i] = "0";
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
lengths = lengths.filter(Boolean);
|
|
1008
|
+
if (!lengths.length && !parts.color && !parts.inset) {
|
|
1009
|
+
return "";
|
|
1010
|
+
}
|
|
1011
|
+
while (lengths.length < 2) {
|
|
1012
|
+
lengths.push("0");
|
|
1013
|
+
}
|
|
1014
|
+
return (box && parts.inset ? "inset " : "") + lengths.join(" ") + (parts.color ? " " + parts.color : "");
|
|
1015
|
+
}
|
|
1016
|
+
function shadowControl(ge, node, property, changed) {
|
|
1017
|
+
var box = property === "box-shadow";
|
|
1018
|
+
var holder = element("div", { "class": "ge-style-shadow" });
|
|
1019
|
+
var textMode = false;
|
|
1020
|
+
function writeValue(value, input) {
|
|
1021
|
+
var ok = write(ge, node, property, value);
|
|
1022
|
+
mark(input, ok, ge);
|
|
1023
|
+
if (ok) {
|
|
1024
|
+
changed();
|
|
1025
|
+
}
|
|
1026
|
+
return ok;
|
|
1027
|
+
}
|
|
1028
|
+
function builder(parts) {
|
|
1029
|
+
holder.innerHTML = "";
|
|
1030
|
+
var grid = holder.appendChild(element("div", { "class": "ge-style-shadow-builder" }));
|
|
1031
|
+
var names = box ? SHADOW_PARTS : SHADOW_PARTS.slice(0, 3);
|
|
1032
|
+
var inputs = names.map(function(part, i) {
|
|
1033
|
+
var cell = grid.appendChild(element("label", { "class": "ge-style-shadow-part" }));
|
|
1034
|
+
cell.appendChild(element("span", { "class": "ge-style-shadow-label" }, ge.t(part.labelKey)));
|
|
1035
|
+
var input = cell.appendChild(textInput("ge-style-shadow-" + part.name));
|
|
1036
|
+
input.value = parts.lengths[i] || "";
|
|
1037
|
+
return input;
|
|
1038
|
+
});
|
|
1039
|
+
var colorCell = grid.appendChild(element("label", { "class": "ge-style-shadow-part ge-style-shadow-color" }));
|
|
1040
|
+
colorCell.appendChild(element("span", { "class": "ge-style-shadow-label" }, ge.t("style.shadow_color")));
|
|
1041
|
+
var color = colorControl(function() {
|
|
1042
|
+
update();
|
|
1043
|
+
});
|
|
1044
|
+
colorCell.appendChild(color.element);
|
|
1045
|
+
color.set(parts.color);
|
|
1046
|
+
var inset = null;
|
|
1047
|
+
if (box) {
|
|
1048
|
+
var insetCell = grid.appendChild(element("label", { "class": "form-check ge-style-shadow-inset" }));
|
|
1049
|
+
inset = insetCell.appendChild(element("input", { type: "checkbox", "class": "form-check-input" }));
|
|
1050
|
+
insetCell.appendChild(element("span", { "class": "form-check-label" }, ge.t("style.shadow_inset")));
|
|
1051
|
+
inset.checked = parts.inset;
|
|
1052
|
+
inset.addEventListener("change", function() {
|
|
1053
|
+
update();
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
inputs.forEach(function(input) {
|
|
1057
|
+
input.addEventListener("change", function() {
|
|
1058
|
+
update();
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1061
|
+
var toText = holder.appendChild(element("a", { href: "#", "class": "ge-style-shadow-mode" }, ge.t("style.shadow_text_mode")));
|
|
1062
|
+
toText.addEventListener("click", function(e) {
|
|
1063
|
+
e.preventDefault();
|
|
1064
|
+
textMode = true;
|
|
1065
|
+
render();
|
|
1066
|
+
});
|
|
1067
|
+
function update() {
|
|
1068
|
+
var value = composeShadow({
|
|
1069
|
+
inset: inset ? inset.checked : false,
|
|
1070
|
+
lengths: inputs.map(function(input) {
|
|
1071
|
+
return input.value.trim();
|
|
1072
|
+
}),
|
|
1073
|
+
color: one(color.element, 'input[type="text"]').value.trim()
|
|
1074
|
+
}, box);
|
|
1075
|
+
writeValue(value, inputs[0]);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
function text(value) {
|
|
1079
|
+
holder.innerHTML = "";
|
|
1080
|
+
var input = holder.appendChild(textInput("ge-style-shadow-text"));
|
|
1081
|
+
input.value = value;
|
|
1082
|
+
input.addEventListener("change", function() {
|
|
1083
|
+
if (input.value.trim() === "") {
|
|
1084
|
+
if (writeValue("", input)) {
|
|
1085
|
+
textMode = false;
|
|
1086
|
+
render();
|
|
1087
|
+
}
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
writeValue(input.value, input);
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
var shown = null;
|
|
1094
|
+
function render() {
|
|
1095
|
+
if (holder.querySelector(".is-invalid")) {
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
var value = ge.hostStyle(node, property).value;
|
|
1099
|
+
var parts = parseShadow(value, box);
|
|
1100
|
+
if (value === shown && holder.firstChild && textMode === !!holder.querySelector(".ge-style-shadow-text")) {
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
shown = value;
|
|
1104
|
+
if (textMode || !parts) {
|
|
1105
|
+
textMode = !!value || textMode;
|
|
1106
|
+
text(value);
|
|
1107
|
+
} else {
|
|
1108
|
+
builder(parts);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
return { element: holder, render, value: function() {
|
|
1112
|
+
return ge.hostStyle(node, property).value;
|
|
1113
|
+
} };
|
|
1114
|
+
}
|
|
1115
|
+
function createStyleField(ge, node, property, changed) {
|
|
1116
|
+
var field = element("div", { "class": "ge-style-field", "data-ge-style-property": property.name });
|
|
1117
|
+
var label = field.appendChild(element("label", { "class": "ge-style-label" }, ge.t(property.labelKey)));
|
|
1118
|
+
var render;
|
|
1119
|
+
function current() {
|
|
1120
|
+
return ge.hostStyle(node, property.name).value;
|
|
1121
|
+
}
|
|
1122
|
+
function commit(value, input2) {
|
|
1123
|
+
var ok = write(ge, node, property.name, value);
|
|
1124
|
+
mark(input2, ok, ge);
|
|
1125
|
+
if (ok) {
|
|
1126
|
+
changed();
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
if (property.type === "select") {
|
|
1130
|
+
var select = field.appendChild(element("select", { "class": "form-select form-select-sm" }));
|
|
1131
|
+
select.addEventListener("change", function() {
|
|
1132
|
+
commit(select.value, select);
|
|
1133
|
+
});
|
|
1134
|
+
render = function() {
|
|
1135
|
+
var value = current();
|
|
1136
|
+
var values = property.values.slice();
|
|
1137
|
+
if (value && values.indexOf(value) === -1) {
|
|
1138
|
+
values.push(value);
|
|
1139
|
+
}
|
|
1140
|
+
select.innerHTML = "";
|
|
1141
|
+
select.appendChild(element("option", { value: "" }, ""));
|
|
1142
|
+
values.forEach(function(each2) {
|
|
1143
|
+
select.appendChild(element("option", { value: each2 }, each2));
|
|
1144
|
+
});
|
|
1145
|
+
select.value = value;
|
|
1146
|
+
};
|
|
1147
|
+
} else if (property.type === "color") {
|
|
1148
|
+
var color = colorControl(function(value, input2) {
|
|
1149
|
+
commit(value, input2);
|
|
1150
|
+
});
|
|
1151
|
+
field.appendChild(color.element);
|
|
1152
|
+
render = function() {
|
|
1153
|
+
color.set(current());
|
|
1154
|
+
};
|
|
1155
|
+
} else if (property.type === "url") {
|
|
1156
|
+
var url = field.appendChild(textInput());
|
|
1157
|
+
url.addEventListener("change", function() {
|
|
1158
|
+
commit(urlValue(url.value), url);
|
|
1159
|
+
});
|
|
1160
|
+
render = function() {
|
|
1161
|
+
fill(url, shownUrl(current()));
|
|
1162
|
+
};
|
|
1163
|
+
} else if (property.type === "shadow") {
|
|
1164
|
+
var shadow = shadowControl(ge, node, property.name, changed);
|
|
1165
|
+
field.appendChild(shadow.element);
|
|
1166
|
+
render = shadow.render;
|
|
1167
|
+
} else {
|
|
1168
|
+
var input = field.appendChild(textInput());
|
|
1169
|
+
input.addEventListener("change", function() {
|
|
1170
|
+
commit(input.value, input);
|
|
1171
|
+
});
|
|
1172
|
+
render = function() {
|
|
1173
|
+
fill(input, current());
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
var control = field.querySelector("input, select");
|
|
1177
|
+
if (control) {
|
|
1178
|
+
control.id = "ge-style-field-" + ++fieldCounter;
|
|
1179
|
+
label.setAttribute("for", control.id);
|
|
1180
|
+
}
|
|
1181
|
+
field.appendChild(element("small", { "class": "ge-style-note ge-style-overridden" }));
|
|
1182
|
+
renderers.set(field, function() {
|
|
1183
|
+
render();
|
|
1184
|
+
var winner = current() ? overriding(property.name, classesOf(node)) : null;
|
|
1185
|
+
var note = child(field, ".ge-style-overridden");
|
|
1186
|
+
note.textContent = winner ? ge.t("style.overridden", { "class": winner }) : "";
|
|
1187
|
+
toggle(note, !!winner);
|
|
1188
|
+
});
|
|
1189
|
+
renderStyleField(field);
|
|
1190
|
+
return field;
|
|
1191
|
+
}
|
|
1192
|
+
function renderStyleField(field) {
|
|
1193
|
+
var render = renderers.get(field);
|
|
1194
|
+
if (render) {
|
|
1195
|
+
render();
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// src/js/style/catalog.js
|
|
1200
|
+
function classesOf2(node) {
|
|
1201
|
+
return (node.getAttribute("class") || "").split(/\s+/).filter(Boolean);
|
|
1202
|
+
}
|
|
1203
|
+
function choose(ge, node, group2, name) {
|
|
1204
|
+
var details = ge.detailsOf(node);
|
|
1205
|
+
var input = details ? one(details, ".ge-classes") : null;
|
|
1206
|
+
if (!input) {
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
var on = classesOf2(node).indexOf(name) !== -1;
|
|
1210
|
+
var list = input.value.split(/\s+/).filter(Boolean).filter(function(each2) {
|
|
1211
|
+
if (each2 === name) {
|
|
1212
|
+
return false;
|
|
1213
|
+
}
|
|
1214
|
+
return !(group2.exclusive && !on && group2.classes.indexOf(each2) !== -1);
|
|
1215
|
+
});
|
|
1216
|
+
if (!on) {
|
|
1217
|
+
list.push(name);
|
|
1218
|
+
}
|
|
1219
|
+
input.value = list.join(" ");
|
|
1220
|
+
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1221
|
+
}
|
|
1222
|
+
function createCatalog(ge, node, kind, groups) {
|
|
1223
|
+
var offered = groups.filter(function(group2) {
|
|
1224
|
+
return offeredOn(group2, kind);
|
|
1225
|
+
});
|
|
1226
|
+
if (!offered.length) {
|
|
1227
|
+
return null;
|
|
1228
|
+
}
|
|
1229
|
+
var box = element("div", { "class": "ge-style-catalog" });
|
|
1230
|
+
box.appendChild(element("span", { "class": "ge-style-label" }, ge.t("style.catalog")));
|
|
1231
|
+
offered.forEach(function(group2) {
|
|
1232
|
+
var row = box.appendChild(element("div", { "class": "ge-style-chips" }));
|
|
1233
|
+
group2.classes.forEach(function(name) {
|
|
1234
|
+
var chip = row.appendChild(element("button", {
|
|
1235
|
+
type: "button",
|
|
1236
|
+
"class": "btn btn-sm btn-outline-secondary ge-style-chip",
|
|
1237
|
+
"data-ge-class": name,
|
|
1238
|
+
"aria-pressed": "false"
|
|
1239
|
+
}, name));
|
|
1240
|
+
chip.addEventListener("click", function() {
|
|
1241
|
+
choose(ge, node, group2, name);
|
|
1242
|
+
});
|
|
1243
|
+
});
|
|
1244
|
+
});
|
|
1245
|
+
renderCatalog(box, node);
|
|
1246
|
+
return box;
|
|
1247
|
+
}
|
|
1248
|
+
function renderCatalog(box, node) {
|
|
1249
|
+
var classes = classesOf2(node);
|
|
1250
|
+
all(box, ".ge-style-chip").forEach(function(chip) {
|
|
1251
|
+
var on = classes.indexOf(chip.getAttribute("data-ge-class")) !== -1;
|
|
1252
|
+
toggleClass(chip, "active", on);
|
|
1253
|
+
chip.setAttribute("aria-pressed", on ? "true" : "false");
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
// src/js/style/custom.js
|
|
1258
|
+
function longhands(property) {
|
|
1259
|
+
var probe = document.createElement("div").style;
|
|
1260
|
+
var list = [];
|
|
1261
|
+
probe.setProperty(property, "initial");
|
|
1262
|
+
for (var i = 0; i < probe.length; i++) {
|
|
1263
|
+
list.push(probe[i]);
|
|
1264
|
+
}
|
|
1265
|
+
return list.length ? list : [property];
|
|
1266
|
+
}
|
|
1267
|
+
function declaration(cssText) {
|
|
1268
|
+
var style = document.createElement("div").style;
|
|
1269
|
+
style.cssText = cssText;
|
|
1270
|
+
return style;
|
|
1271
|
+
}
|
|
1272
|
+
function createCustom(ge, node, properties, changed) {
|
|
1273
|
+
var covered = {};
|
|
1274
|
+
properties.forEach(function(property) {
|
|
1275
|
+
longhands(property).forEach(function(longhand) {
|
|
1276
|
+
covered[longhand] = true;
|
|
1277
|
+
});
|
|
1278
|
+
});
|
|
1279
|
+
var box = element("div", { "class": "ge-style-custom" });
|
|
1280
|
+
var textarea = box.appendChild(element("textarea", {
|
|
1281
|
+
"class": "form-control form-control-sm font-monospace ge-style-custom-css",
|
|
1282
|
+
rows: "4",
|
|
1283
|
+
spellcheck: "false",
|
|
1284
|
+
"aria-label": ge.t("style.section_custom")
|
|
1285
|
+
}));
|
|
1286
|
+
function free() {
|
|
1287
|
+
var style = declaration(ge.hostStyle(node));
|
|
1288
|
+
var rest = document.createElement("div").style;
|
|
1289
|
+
for (var i = 0; i < style.length; i++) {
|
|
1290
|
+
var name = style[i];
|
|
1291
|
+
if (!covered[name]) {
|
|
1292
|
+
rest.setProperty(name, style.getPropertyValue(name), style.getPropertyPriority(name));
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
return rest;
|
|
1296
|
+
}
|
|
1297
|
+
textarea.addEventListener("change", function() {
|
|
1298
|
+
var before = free();
|
|
1299
|
+
var wanted = declaration(textarea.value);
|
|
1300
|
+
var i;
|
|
1301
|
+
for (i = 0; i < before.length; i++) {
|
|
1302
|
+
if (wanted.getPropertyValue(before[i]) === "") {
|
|
1303
|
+
ge.setHostStyle(node, before[i], "");
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
for (i = 0; i < wanted.length; i++) {
|
|
1307
|
+
ge.setHostStyle(node, wanted[i], wanted.getPropertyValue(wanted[i]), wanted.getPropertyPriority(wanted[i]));
|
|
1308
|
+
}
|
|
1309
|
+
render();
|
|
1310
|
+
changed();
|
|
1311
|
+
});
|
|
1312
|
+
function render() {
|
|
1313
|
+
if (document.activeElement === textarea) {
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
textarea.value = free().cssText.replace(/; /g, ";\n");
|
|
1317
|
+
}
|
|
1318
|
+
render();
|
|
1319
|
+
return { element: box, render };
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
// src/js/style/accordion.js
|
|
1323
|
+
function takesInlineStyle(node, kind) {
|
|
1324
|
+
if (kind === "row" || kind === "column" || kind === "element" || kind === "section") {
|
|
1325
|
+
return true;
|
|
1326
|
+
}
|
|
1327
|
+
if (is(node, "[data-ge-container]")) {
|
|
1328
|
+
return true;
|
|
1329
|
+
}
|
|
1330
|
+
return !!child(node, ".ge-tools-drawer.ge-pane-drawer");
|
|
1331
|
+
}
|
|
1332
|
+
function familyApplies(family, node, kind) {
|
|
1333
|
+
if (kind === "plain") {
|
|
1334
|
+
kind = "text";
|
|
1335
|
+
}
|
|
1336
|
+
if (family.appliesTo.indexOf(kind) !== -1) {
|
|
1337
|
+
return true;
|
|
1338
|
+
}
|
|
1339
|
+
return family.appliesTo.indexOf("container") !== -1 && is(node, "[data-ge-container]");
|
|
1340
|
+
}
|
|
1341
|
+
function partContent(ge, part, node, kind) {
|
|
1342
|
+
if (part.panel) {
|
|
1343
|
+
return part.panel(node, kind);
|
|
1344
|
+
}
|
|
1345
|
+
var family = part.families[0];
|
|
1346
|
+
return familyApplies(family, node, kind) ? ge.utilityField(node, family.name) : null;
|
|
1347
|
+
}
|
|
1348
|
+
function createAccordion(ge, node, kind, context) {
|
|
1349
|
+
var inline = takesInlineStyle(node, kind);
|
|
1350
|
+
var accordion = element("div", { "class": "accordion ge-style" });
|
|
1351
|
+
var fields = [];
|
|
1352
|
+
var catalogs = [];
|
|
1353
|
+
var notes = [];
|
|
1354
|
+
var custom = null;
|
|
1355
|
+
var customItem = null;
|
|
1356
|
+
var changed = function() {
|
|
1357
|
+
render();
|
|
1358
|
+
};
|
|
1359
|
+
function item(key, labelKey) {
|
|
1360
|
+
var entry = accordion.appendChild(element("div", { "class": "accordion-item", "data-ge-style-section": key }));
|
|
1361
|
+
var header = entry.appendChild(element("h2", { "class": "accordion-header" }));
|
|
1362
|
+
var button = header.appendChild(element("button", {
|
|
1363
|
+
type: "button",
|
|
1364
|
+
"class": "accordion-button collapsed",
|
|
1365
|
+
"aria-expanded": "false"
|
|
1366
|
+
}, ge.t(labelKey)));
|
|
1367
|
+
var collapse = entry.appendChild(element("div", { "class": "accordion-collapse collapse" }));
|
|
1368
|
+
var body = collapse.appendChild(element("div", { "class": "accordion-body" }));
|
|
1369
|
+
button.addEventListener("click", function() {
|
|
1370
|
+
var opening = !hasClass(collapse, "show");
|
|
1371
|
+
context.state.open = opening ? key : null;
|
|
1372
|
+
context.opened(context.state.open);
|
|
1373
|
+
});
|
|
1374
|
+
return { entry, body };
|
|
1375
|
+
}
|
|
1376
|
+
function toggle2(entry, shown) {
|
|
1377
|
+
toggleClass(one(entry, ".accordion-collapse"), "show", shown);
|
|
1378
|
+
var button = one(entry, ".accordion-button");
|
|
1379
|
+
toggleClass(button, "collapsed", !shown);
|
|
1380
|
+
button.setAttribute("aria-expanded", shown ? "true" : "false");
|
|
1381
|
+
}
|
|
1382
|
+
Object.keys(context.sections).forEach(function(key) {
|
|
1383
|
+
var resolved = context.sections[key];
|
|
1384
|
+
var section2 = resolved.section;
|
|
1385
|
+
if (section2.custom) {
|
|
1386
|
+
if (inline) {
|
|
1387
|
+
customItem = item(key, section2.labelKey);
|
|
1388
|
+
}
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
var parts = section2.parts.map(function(name) {
|
|
1392
|
+
return context.parts[name] ? partContent(ge, context.parts[name], node, kind) : null;
|
|
1393
|
+
}).filter(Boolean);
|
|
1394
|
+
var properties = inline ? resolved.properties.filter(function(property) {
|
|
1395
|
+
return offeredOn(property, kind);
|
|
1396
|
+
}) : [];
|
|
1397
|
+
var catalog = inline && resolved.catalog ? createCatalog(ge, node, kind, section2.catalog) : null;
|
|
1398
|
+
if (!parts.length && !properties.length && !catalog) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
var body = item(key, section2.labelKey).body;
|
|
1402
|
+
parts.forEach(function(part) {
|
|
1403
|
+
body.appendChild(addClass(part, "ge-style-part"));
|
|
1404
|
+
});
|
|
1405
|
+
if (properties.length) {
|
|
1406
|
+
var note = body.appendChild(element("small", { "class": "ge-style-note ge-style-all-sizes" }, ge.t("style.all_sizes")));
|
|
1407
|
+
notes.push(note);
|
|
1408
|
+
var grid = body.appendChild(element("div", { "class": "ge-style-fields" }));
|
|
1409
|
+
properties.forEach(function(property) {
|
|
1410
|
+
var field = createStyleField(ge, node, property, changed);
|
|
1411
|
+
fields.push(field);
|
|
1412
|
+
grid.appendChild(field);
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
if (catalog) {
|
|
1416
|
+
catalogs.push(catalog);
|
|
1417
|
+
body.appendChild(catalog);
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
if (customItem) {
|
|
1421
|
+
custom = createCustom(ge, node, fields.map(function(field) {
|
|
1422
|
+
return field.getAttribute("data-ge-style-property");
|
|
1423
|
+
}), changed);
|
|
1424
|
+
customItem.body.appendChild(custom.element);
|
|
1425
|
+
accordion.appendChild(customItem.entry);
|
|
1426
|
+
}
|
|
1427
|
+
if (!accordion.children.length) {
|
|
1428
|
+
return null;
|
|
1429
|
+
}
|
|
1430
|
+
function open(key) {
|
|
1431
|
+
all(accordion, ".accordion-item").forEach(function(entry) {
|
|
1432
|
+
toggle2(entry, entry.getAttribute("data-ge-style-section") === key);
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
open(context.state.open);
|
|
1436
|
+
function render() {
|
|
1437
|
+
fields.forEach(renderStyleField);
|
|
1438
|
+
catalogs.forEach(function(catalog) {
|
|
1439
|
+
renderCatalog(catalog, node);
|
|
1440
|
+
});
|
|
1441
|
+
if (custom) {
|
|
1442
|
+
custom.render();
|
|
1443
|
+
}
|
|
1444
|
+
notes.forEach(function(note) {
|
|
1445
|
+
toggle(note, ge.view() !== "all");
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
render();
|
|
1449
|
+
return { element: accordion, render, open };
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
// src/js/plugins/grideditor.style.js
|
|
1453
|
+
Object.assign(GridEditor.locales.en, {
|
|
1454
|
+
"style.section_title": "Style",
|
|
1455
|
+
"style.dialog_title": "Style: {kind}",
|
|
1456
|
+
"style.section_size": "Size",
|
|
1457
|
+
"style.section_spacing": "Spacing",
|
|
1458
|
+
"style.section_border": "Border",
|
|
1459
|
+
"style.section_background": "Background",
|
|
1460
|
+
"style.section_text": "Text",
|
|
1461
|
+
"style.section_typography": "Typography",
|
|
1462
|
+
"style.section_display": "Display",
|
|
1463
|
+
"style.section_position": "Position",
|
|
1464
|
+
"style.section_custom": "Custom css",
|
|
1465
|
+
"style.all_sizes": "Applies to every size",
|
|
1466
|
+
"style.overridden": "The class {class} takes priority over this value",
|
|
1467
|
+
"style.invalid": "Not a value this property takes",
|
|
1468
|
+
"style.catalog": "Bootstrap classes",
|
|
1469
|
+
"style.shadow_x": "X",
|
|
1470
|
+
"style.shadow_y": "Y",
|
|
1471
|
+
"style.shadow_blur": "Blur",
|
|
1472
|
+
"style.shadow_spread": "Spread",
|
|
1473
|
+
"style.shadow_color": "Color",
|
|
1474
|
+
"style.shadow_inset": "Inset",
|
|
1475
|
+
"style.shadow_text_mode": "Edit as text",
|
|
1476
|
+
"style.prop_width": "Width",
|
|
1477
|
+
"style.prop_height": "Height",
|
|
1478
|
+
"style.prop_min_width": "Min width",
|
|
1479
|
+
"style.prop_min_height": "Min height",
|
|
1480
|
+
"style.prop_max_width": "Max width",
|
|
1481
|
+
"style.prop_max_height": "Max height",
|
|
1482
|
+
"style.prop_margin_top": "Margin top",
|
|
1483
|
+
"style.prop_margin_right": "Margin right",
|
|
1484
|
+
"style.prop_margin_bottom": "Margin bottom",
|
|
1485
|
+
"style.prop_margin_left": "Margin left",
|
|
1486
|
+
"style.prop_padding_top": "Padding top",
|
|
1487
|
+
"style.prop_padding_right": "Padding right",
|
|
1488
|
+
"style.prop_padding_bottom": "Padding bottom",
|
|
1489
|
+
"style.prop_padding_left": "Padding left",
|
|
1490
|
+
"style.prop_border_width": "Border width",
|
|
1491
|
+
"style.prop_border_style": "Border style",
|
|
1492
|
+
"style.prop_border_color": "Border color",
|
|
1493
|
+
"style.prop_border_radius": "Border radius",
|
|
1494
|
+
"style.prop_box_shadow": "Shadow",
|
|
1495
|
+
"style.prop_background_color": "Background color",
|
|
1496
|
+
"style.prop_background_image": "Background image",
|
|
1497
|
+
"style.prop_background_size": "Background size",
|
|
1498
|
+
"style.prop_background_position": "Background position",
|
|
1499
|
+
"style.prop_background_repeat": "Background repeat",
|
|
1500
|
+
"style.prop_color": "Color",
|
|
1501
|
+
"style.prop_font_size": "Font size",
|
|
1502
|
+
"style.prop_text_align": "Text align",
|
|
1503
|
+
"style.prop_text_shadow": "Text shadow",
|
|
1504
|
+
"style.prop_font_family": "Font family",
|
|
1505
|
+
"style.prop_font_weight": "Font weight",
|
|
1506
|
+
"style.prop_font_style": "Font style",
|
|
1507
|
+
"style.prop_line_height": "Line height",
|
|
1508
|
+
"style.prop_letter_spacing": "Letter spacing",
|
|
1509
|
+
"style.prop_text_transform": "Text transform",
|
|
1510
|
+
"style.prop_text_decoration": "Text decoration",
|
|
1511
|
+
"style.prop_display": "Display",
|
|
1512
|
+
"style.prop_opacity": "Opacity",
|
|
1513
|
+
"style.prop_overflow": "Overflow",
|
|
1514
|
+
"style.prop_visibility": "Visibility",
|
|
1515
|
+
"style.prop_position": "Position",
|
|
1516
|
+
"style.prop_top": "Top",
|
|
1517
|
+
"style.prop_right": "Right",
|
|
1518
|
+
"style.prop_bottom": "Bottom",
|
|
1519
|
+
"style.prop_left": "Left",
|
|
1520
|
+
"style.prop_z_index": "Z-index"
|
|
1521
|
+
});
|
|
1522
|
+
var PARTS = ["spacing", "textalign", "visibility", "float"];
|
|
1523
|
+
GridEditor.utilities.style = function(ge) {
|
|
1524
|
+
var options = resolveOptions(ge);
|
|
1525
|
+
var parts = {
|
|
1526
|
+
spacing: spacingPart(ge, options.spacing),
|
|
1527
|
+
textalign: textalignPart(ge),
|
|
1528
|
+
visibility: visibilityPart(ge, options.visibility),
|
|
1529
|
+
float: floatPart(ge)
|
|
1530
|
+
};
|
|
1531
|
+
var accordions = [];
|
|
1532
|
+
var context = {
|
|
1533
|
+
sections: options.sections,
|
|
1534
|
+
parts,
|
|
1535
|
+
state: { open: null },
|
|
1536
|
+
opened: function(key) {
|
|
1537
|
+
accordions.forEach(function(entry) {
|
|
1538
|
+
entry.accordion.open(key);
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
};
|
|
1542
|
+
function each2(hook) {
|
|
1543
|
+
return function() {
|
|
1544
|
+
var args = arguments;
|
|
1545
|
+
PARTS.forEach(function(name) {
|
|
1546
|
+
if (parts[name][hook]) {
|
|
1547
|
+
parts[name][hook].apply(null, args);
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
var partsRefresh = each2("onRefresh");
|
|
1553
|
+
return {
|
|
1554
|
+
// The parts' families, edited in the sections rather than in Responsive
|
|
1555
|
+
families: PARTS.reduce(function(all2, name) {
|
|
1556
|
+
return all2.concat(parts[name].families.map(function(family) {
|
|
1557
|
+
return Object.assign({}, family, { panel: false });
|
|
1558
|
+
}));
|
|
1559
|
+
}, []),
|
|
1560
|
+
panelSection: function(node, kind) {
|
|
1561
|
+
var accordion = createAccordion(ge, node, kind, context);
|
|
1562
|
+
if (!accordion) {
|
|
1563
|
+
return null;
|
|
1564
|
+
}
|
|
1565
|
+
accordions.push({ node, accordion });
|
|
1566
|
+
return { labelKey: "style.section_title", titleKey: "style.dialog_title", body: accordion.element };
|
|
1567
|
+
},
|
|
1568
|
+
preview: function(node, kind, breakpoint) {
|
|
1569
|
+
return parts.spacing.preview(node, kind, breakpoint);
|
|
1570
|
+
},
|
|
1571
|
+
// After a write, a change of classes or of view: the accordions of
|
|
1572
|
+
// the nodes it touched follow
|
|
1573
|
+
onRefresh: function(scope) {
|
|
1574
|
+
partsRefresh(scope);
|
|
1575
|
+
accordions = accordions.filter(function(entry) {
|
|
1576
|
+
return entry.accordion.element.isConnected;
|
|
1577
|
+
});
|
|
1578
|
+
accordions.forEach(function(entry) {
|
|
1579
|
+
if (entry.node === scope || scope.contains(entry.node)) {
|
|
1580
|
+
entry.accordion.render();
|
|
1581
|
+
}
|
|
1582
|
+
});
|
|
1583
|
+
},
|
|
1584
|
+
drawerTools: each2("drawerTools"),
|
|
1585
|
+
onDeinit: function() {
|
|
1586
|
+
each2("onDeinit")();
|
|
1587
|
+
accordions = [];
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1590
|
+
};
|
|
1591
|
+
GridEditor.utilities.style.replaces = PARTS;
|
|
1592
|
+
})();
|