@seniorsistemas/tecnologia-webcomponents
Version:
A webcomponents library for Senior Sistemas - Suite BPM products.
205 lines (204 loc) • 9.55 kB
JavaScript
var __spreadArray = this && this.__spreadArray || function(t, e) {
for (var r = 0, n = e.length, s = t.length; r < n; r++, s++) t[s] = e[r];
return t;
};
System.register([], (function(t) {
"use strict";
return {
execute: function() {
/*
Stencil Client Platform v2.5.2 | MIT Licensed | https://stenciljs.com
*/
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*
* This file is a port of shadowCSS from webcomponents.js to TypeScript.
* https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
* https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts
*/
var e = "-shadowcsshost", r = "-shadowcssslotted", n = "-shadowcsscontext", s = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", o = new RegExp("(-shadowcsshost" + s, "gim"), c = new RegExp("(-shadowcsscontext" + s, "gim"), a = new RegExp("(-shadowcssslotted" + s, "gim"), i = "-shadowcsshost-no-combinator", u = /-shadowcsshost-no-combinator([^\s]*)/, l = [ /::shadow/g, /::content/g ], h = /-shadowcsshost/gim, f = /:host/gim, p = /::slotted/gim, g = /:host-context/gim, d = /\/\*\s*[\s\S]*?\*\//g, m = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g, v = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g, _ = /([{}])/g, x = "%BLOCK%", processRules = function(t, e) {
var r = escapeBlocks(t), n = 0;
return r.escapedString.replace(v, (function() {
for (var t = [], s = 0; s < arguments.length; s++) t[s] = arguments[s];
var o = t[2], c = "", a = t[4], i = "";
a && a.startsWith("{%BLOCK%") && (c = r.blocks[n++], a = a.substring(x.length + 1),
i = "{");
var u = {
selector: o,
content: c
}, l = e(u);
return "" + t[1] + l.selector + t[3] + i + l.content + a;
}));
}, escapeBlocks = function(t) {
for (var e = t.split(_), r = [], n = [], s = 0, o = [], c = 0; c < e.length; c++) {
var a = e[c];
"}" === a && s--, s > 0 ? o.push(a) : (o.length > 0 && (n.push(o.join("")), r.push(x),
o = []), r.push(a)), "{" === a && s++;
}
return o.length > 0 && (n.push(o.join("")), r.push(x)), {
escapedString: r.join(""),
blocks: n
};
}, convertColonRule = function(t, e, r) {
// m[1] = :host(-context), m[2] = contents of (), m[3] rest of rule
return t.replace(e, (function() {
for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
if (t[2]) {
for (var n = t[2].split(","), s = [], o = 0; o < n.length; o++) {
var c = n[o].trim();
if (!c) break;
s.push(r(i, c, t[3]));
}
return s.join(",");
}
return i + t[3];
}));
}, colonHostPartReplacer = function(t, r, n) {
return t + r.replace(e, "") + n;
}, colonHostContextPartReplacer = function(t, r, n) {
return r.indexOf(e) > -1 ? colonHostPartReplacer(t, r, n) : t + r + n + ", " + r + " " + t + n;
}, selectorNeedsScoping = function(t, e) {
return !function(t) {
return t = t.replace(/\[/g, "\\[").replace(/\]/g, "\\]"), new RegExp("^(" + t + ")([>\\s~+[.,{:][\\s\\S]*)?$", "m");
}(e).test(t);
}, applyStrictSelectorScope = function(t, e, r) {
for (var n, s = "." + (e = e.replace(/\[is=([^\]]*)\]/g, (function(t) {
for (var e = [], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r];
return e[0];
}))), _scopeSelectorPart = function(t) {
var n = t.trim();
if (!n) return "";
if (t.indexOf(i) > -1) n = function(t, e, r) {
if (
// In Android browser, the lastIndex is not reset when the regex is used in String.replace()
h.lastIndex = 0, h.test(t)) {
var n = "." + r;
return t.replace(u, (function(t, e) {
return e.replace(/([^:]*)(:*)(.*)/, (function(t, e, r, s) {
return e + n + r + s;
}));
})).replace(h, n + " ");
}
return e + " " + t;
}(t, e, r); else {
// remove :host since it should be unnecessary
var o = t.replace(h, "");
if (o.length > 0) {
var c = o.match(/([^:]*)(:*)(.*)/);
c && (n = c[1] + s + c[2] + c[3]);
}
}
return n;
}, o = function(t) {
var e = [], r = 0;
return {
content: (
// Replaces attribute selectors with placeholders.
// The WS in [attr="va lue"] would otherwise be interpreted as a selector separator.
t = t.replace(/(\[[^\]]*\])/g, (function(t, n) {
var s = "__ph-" + r + "__";
return e.push(n), r++, s;
}))).replace(/(:nth-[-\w]+)(\([^)]+\))/g, (function(t, n, s) {
var o = "__ph-" + r + "__";
return e.push(s), r++, n + o;
})),
placeholders: e
};
}(t), c = "", a = 0, l = /( |>|\+|~(?!=))\s*/g, f = !((t = o.content).indexOf(i) > -1); null !== (n = l.exec(t)); ) {
var p = n[1], g = t.slice(a, n.index).trim();
c += ((f = f || g.indexOf(i) > -1) ? _scopeSelectorPart(g) : g) + " " + p + " ",
a = l.lastIndex;
}
var d, m = t.substring(a);
// replace the placeholders with their original values
return c += (f = f || m.indexOf(i) > -1) ? _scopeSelectorPart(m) : m, d = o.placeholders,
c.replace(/__ph-(\d+)__/g, (function(t, e) {
return d[+e];
}));
}, scopeSelectors = function(t, e, r, n, s) {
return processRules(t, (function(t) {
var s = t.selector, o = t.content;
return "@" !== t.selector[0] ? s = function(t, e, r, n) {
return t.split(",").map((function(t) {
return n && t.indexOf("." + n) > -1 ? t.trim() : selectorNeedsScoping(t, e) ? applyStrictSelectorScope(t, e, r).trim() : t.trim();
})).join(", ");
}(t.selector, e, r, n) : (t.selector.startsWith("@media") || t.selector.startsWith("@supports") || t.selector.startsWith("@page") || t.selector.startsWith("@document")) && (o = scopeSelectors(t.content, e, r, n)),
{
selector: s.replace(/\s{2,}/g, " ").trim(),
content: o
};
}));
}, scopeCssText = function(t, s, u, h, d) {
var m = function(t, e) {
var r = "." + e + " > ", n = [];
return t = t.replace(a, (function() {
for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
if (t[2]) {
for (var s = t[2].trim(), o = t[3], c = r + s + o, a = "", u = t[4] - 1; u >= 0; u--) {
var l = t[5][u];
if ("}" === l || "," === l) break;
a = l + a;
}
var h = a + c, f = "" + a.trimRight() + c.trim();
if (h.trim() !== f.trim()) {
var p = f + ", " + h;
n.push({
orgSelector: h,
updatedSelector: p
});
}
return c;
}
return i + t[3];
})), {
selectors: n,
cssText: t
};
}(t = function(t) {
return convertColonRule(t, c, colonHostContextPartReplacer);
}(t = function(t) {
return convertColonRule(t, o, colonHostPartReplacer);
}(t = t.replace(g, n).replace(f, e).replace(p, r))), h);
return t = function(t) {
return l.reduce((function(t, e) {
return t.replace(e, " ");
}), t);
}(t = m.cssText), s && (t = scopeSelectors(t, s, u, h)), {
cssText: (t = (t = t.replace(/-shadowcsshost-no-combinator/g, "." + u)).replace(/>\s*\*\s+([^{, ]+)/gm, " $1 ")).trim(),
slottedSelectors: m.selectors
};
};
t("scopeCss", (function(t, e, r) {
var n = e + "-h", s = e + "-s", o = t.match(m) || [];
t = function(t) {
return t.replace(d, "");
}(t);
var c = [];
if (r) {
var processCommentedSelector_1 = function(t) {
var e = "/*!@___" + c.length + "___*/", r = "/*!@" + t.selector + "*/";
return c.push({
placeholder: e,
comment: r
}), t.selector = e + t.selector, t;
};
t = processRules(t, (function(t) {
return "@" !== t.selector[0] ? processCommentedSelector_1(t) : t.selector.startsWith("@media") || t.selector.startsWith("@supports") || t.selector.startsWith("@page") || t.selector.startsWith("@document") ? (t.content = processRules(t.content, processCommentedSelector_1),
t) : t;
}));
}
var a = scopeCssText(t, e, n, s);
return t = __spreadArray([ a.cssText ], o).join("\n"), r && c.forEach((function(e) {
var r = e.placeholder, n = e.comment;
t = t.replace(r, n);
})), a.slottedSelectors.forEach((function(e) {
t = t.replace(e.orgSelector, e.updatedSelector);
})), t;
}));
}
};
}));