|
1 /******/ (() => { // webpackBootstrap |
|
2 /******/ "use strict"; |
|
3 /******/ // The require scope |
|
4 /******/ var __webpack_require__ = {}; |
|
5 /******/ |
|
6 /************************************************************************/ |
|
7 /******/ /* webpack/runtime/define property getters */ |
|
8 /******/ (() => { |
|
9 /******/ // define getter functions for harmony exports |
|
10 /******/ __webpack_require__.d = (exports, definition) => { |
|
11 /******/ for(var key in definition) { |
|
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
14 /******/ } |
|
15 /******/ } |
|
16 /******/ }; |
|
17 /******/ })(); |
|
18 /******/ |
|
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
20 /******/ (() => { |
|
21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
|
22 /******/ })(); |
|
23 /******/ |
|
24 /******/ /* webpack/runtime/make namespace object */ |
|
25 /******/ (() => { |
|
26 /******/ // define __esModule on exports |
|
27 /******/ __webpack_require__.r = (exports) => { |
|
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
30 /******/ } |
|
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
32 /******/ }; |
|
33 /******/ })(); |
|
34 /******/ |
|
35 /************************************************************************/ |
|
36 var __webpack_exports__ = {}; |
|
37 // ESM COMPAT FLAG |
|
38 __webpack_require__.r(__webpack_exports__); |
|
39 |
|
40 // EXPORTS |
|
41 __webpack_require__.d(__webpack_exports__, { |
|
42 compileCSS: () => (/* binding */ compileCSS), |
|
43 getCSSRules: () => (/* binding */ getCSSRules) |
|
44 }); |
|
45 |
|
46 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs |
|
47 /****************************************************************************** |
|
48 Copyright (c) Microsoft Corporation. |
|
49 |
|
50 Permission to use, copy, modify, and/or distribute this software for any |
|
51 purpose with or without fee is hereby granted. |
|
52 |
|
53 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
|
54 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
|
55 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
|
56 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
|
57 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
|
58 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
59 PERFORMANCE OF THIS SOFTWARE. |
|
60 ***************************************************************************** */ |
|
61 /* global Reflect, Promise, SuppressedError, Symbol */ |
|
62 |
|
63 var extendStatics = function(d, b) { |
|
64 extendStatics = Object.setPrototypeOf || |
|
65 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
66 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
|
67 return extendStatics(d, b); |
|
68 }; |
|
69 |
|
70 function __extends(d, b) { |
|
71 if (typeof b !== "function" && b !== null) |
|
72 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
|
73 extendStatics(d, b); |
|
74 function __() { this.constructor = d; } |
|
75 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
76 } |
|
77 |
|
78 var __assign = function() { |
|
79 __assign = Object.assign || function __assign(t) { |
|
80 for (var s, i = 1, n = arguments.length; i < n; i++) { |
|
81 s = arguments[i]; |
|
82 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
|
83 } |
|
84 return t; |
|
85 } |
|
86 return __assign.apply(this, arguments); |
|
87 } |
|
88 |
|
89 function __rest(s, e) { |
|
90 var t = {}; |
|
91 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) |
|
92 t[p] = s[p]; |
|
93 if (s != null && typeof Object.getOwnPropertySymbols === "function") |
|
94 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { |
|
95 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) |
|
96 t[p[i]] = s[p[i]]; |
|
97 } |
|
98 return t; |
|
99 } |
|
100 |
|
101 function __decorate(decorators, target, key, desc) { |
|
102 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; |
|
103 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); |
|
104 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; |
|
105 return c > 3 && r && Object.defineProperty(target, key, r), r; |
|
106 } |
|
107 |
|
108 function __param(paramIndex, decorator) { |
|
109 return function (target, key) { decorator(target, key, paramIndex); } |
|
110 } |
|
111 |
|
112 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { |
|
113 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } |
|
114 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; |
|
115 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; |
|
116 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); |
|
117 var _, done = false; |
|
118 for (var i = decorators.length - 1; i >= 0; i--) { |
|
119 var context = {}; |
|
120 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; |
|
121 for (var p in contextIn.access) context.access[p] = contextIn.access[p]; |
|
122 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; |
|
123 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); |
|
124 if (kind === "accessor") { |
|
125 if (result === void 0) continue; |
|
126 if (result === null || typeof result !== "object") throw new TypeError("Object expected"); |
|
127 if (_ = accept(result.get)) descriptor.get = _; |
|
128 if (_ = accept(result.set)) descriptor.set = _; |
|
129 if (_ = accept(result.init)) initializers.unshift(_); |
|
130 } |
|
131 else if (_ = accept(result)) { |
|
132 if (kind === "field") initializers.unshift(_); |
|
133 else descriptor[key] = _; |
|
134 } |
|
135 } |
|
136 if (target) Object.defineProperty(target, contextIn.name, descriptor); |
|
137 done = true; |
|
138 }; |
|
139 |
|
140 function __runInitializers(thisArg, initializers, value) { |
|
141 var useValue = arguments.length > 2; |
|
142 for (var i = 0; i < initializers.length; i++) { |
|
143 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); |
|
144 } |
|
145 return useValue ? value : void 0; |
|
146 }; |
|
147 |
|
148 function __propKey(x) { |
|
149 return typeof x === "symbol" ? x : "".concat(x); |
|
150 }; |
|
151 |
|
152 function __setFunctionName(f, name, prefix) { |
|
153 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; |
|
154 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); |
|
155 }; |
|
156 |
|
157 function __metadata(metadataKey, metadataValue) { |
|
158 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); |
|
159 } |
|
160 |
|
161 function __awaiter(thisArg, _arguments, P, generator) { |
|
162 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
|
163 return new (P || (P = Promise))(function (resolve, reject) { |
|
164 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
|
165 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
|
166 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
|
167 step((generator = generator.apply(thisArg, _arguments || [])).next()); |
|
168 }); |
|
169 } |
|
170 |
|
171 function __generator(thisArg, body) { |
|
172 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
|
173 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
|
174 function verb(n) { return function (v) { return step([n, v]); }; } |
|
175 function step(op) { |
|
176 if (f) throw new TypeError("Generator is already executing."); |
|
177 while (g && (g = 0, op[0] && (_ = 0)), _) try { |
|
178 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
|
179 if (y = 0, t) op = [op[0] & 2, t.value]; |
|
180 switch (op[0]) { |
|
181 case 0: case 1: t = op; break; |
|
182 case 4: _.label++; return { value: op[1], done: false }; |
|
183 case 5: _.label++; y = op[1]; op = [0]; continue; |
|
184 case 7: op = _.ops.pop(); _.trys.pop(); continue; |
|
185 default: |
|
186 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
|
187 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
|
188 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
|
189 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
|
190 if (t[2]) _.ops.pop(); |
|
191 _.trys.pop(); continue; |
|
192 } |
|
193 op = body.call(thisArg, _); |
|
194 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
|
195 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
|
196 } |
|
197 } |
|
198 |
|
199 var __createBinding = Object.create ? (function(o, m, k, k2) { |
|
200 if (k2 === undefined) k2 = k; |
|
201 var desc = Object.getOwnPropertyDescriptor(m, k); |
|
202 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |
|
203 desc = { enumerable: true, get: function() { return m[k]; } }; |
|
204 } |
|
205 Object.defineProperty(o, k2, desc); |
|
206 }) : (function(o, m, k, k2) { |
|
207 if (k2 === undefined) k2 = k; |
|
208 o[k2] = m[k]; |
|
209 }); |
|
210 |
|
211 function __exportStar(m, o) { |
|
212 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); |
|
213 } |
|
214 |
|
215 function __values(o) { |
|
216 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; |
|
217 if (m) return m.call(o); |
|
218 if (o && typeof o.length === "number") return { |
|
219 next: function () { |
|
220 if (o && i >= o.length) o = void 0; |
|
221 return { value: o && o[i++], done: !o }; |
|
222 } |
|
223 }; |
|
224 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); |
|
225 } |
|
226 |
|
227 function __read(o, n) { |
|
228 var m = typeof Symbol === "function" && o[Symbol.iterator]; |
|
229 if (!m) return o; |
|
230 var i = m.call(o), r, ar = [], e; |
|
231 try { |
|
232 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); |
|
233 } |
|
234 catch (error) { e = { error: error }; } |
|
235 finally { |
|
236 try { |
|
237 if (r && !r.done && (m = i["return"])) m.call(i); |
|
238 } |
|
239 finally { if (e) throw e.error; } |
|
240 } |
|
241 return ar; |
|
242 } |
|
243 |
|
244 /** @deprecated */ |
|
245 function __spread() { |
|
246 for (var ar = [], i = 0; i < arguments.length; i++) |
|
247 ar = ar.concat(__read(arguments[i])); |
|
248 return ar; |
|
249 } |
|
250 |
|
251 /** @deprecated */ |
|
252 function __spreadArrays() { |
|
253 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; |
|
254 for (var r = Array(s), k = 0, i = 0; i < il; i++) |
|
255 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) |
|
256 r[k] = a[j]; |
|
257 return r; |
|
258 } |
|
259 |
|
260 function __spreadArray(to, from, pack) { |
|
261 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { |
|
262 if (ar || !(i in from)) { |
|
263 if (!ar) ar = Array.prototype.slice.call(from, 0, i); |
|
264 ar[i] = from[i]; |
|
265 } |
|
266 } |
|
267 return to.concat(ar || Array.prototype.slice.call(from)); |
|
268 } |
|
269 |
|
270 function __await(v) { |
|
271 return this instanceof __await ? (this.v = v, this) : new __await(v); |
|
272 } |
|
273 |
|
274 function __asyncGenerator(thisArg, _arguments, generator) { |
|
275 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
|
276 var g = generator.apply(thisArg, _arguments || []), i, q = []; |
|
277 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; |
|
278 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } |
|
279 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } |
|
280 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } |
|
281 function fulfill(value) { resume("next", value); } |
|
282 function reject(value) { resume("throw", value); } |
|
283 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } |
|
284 } |
|
285 |
|
286 function __asyncDelegator(o) { |
|
287 var i, p; |
|
288 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; |
|
289 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } |
|
290 } |
|
291 |
|
292 function __asyncValues(o) { |
|
293 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
|
294 var m = o[Symbol.asyncIterator], i; |
|
295 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); |
|
296 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } |
|
297 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } |
|
298 } |
|
299 |
|
300 function __makeTemplateObject(cooked, raw) { |
|
301 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } |
|
302 return cooked; |
|
303 }; |
|
304 |
|
305 var __setModuleDefault = Object.create ? (function(o, v) { |
|
306 Object.defineProperty(o, "default", { enumerable: true, value: v }); |
|
307 }) : function(o, v) { |
|
308 o["default"] = v; |
|
309 }; |
|
310 |
|
311 function __importStar(mod) { |
|
312 if (mod && mod.__esModule) return mod; |
|
313 var result = {}; |
|
314 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); |
|
315 __setModuleDefault(result, mod); |
|
316 return result; |
|
317 } |
|
318 |
|
319 function __importDefault(mod) { |
|
320 return (mod && mod.__esModule) ? mod : { default: mod }; |
|
321 } |
|
322 |
|
323 function __classPrivateFieldGet(receiver, state, kind, f) { |
|
324 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); |
|
325 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); |
|
326 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); |
|
327 } |
|
328 |
|
329 function __classPrivateFieldSet(receiver, state, value, kind, f) { |
|
330 if (kind === "m") throw new TypeError("Private method is not writable"); |
|
331 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); |
|
332 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); |
|
333 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; |
|
334 } |
|
335 |
|
336 function __classPrivateFieldIn(state, receiver) { |
|
337 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); |
|
338 return typeof state === "function" ? receiver === state : state.has(receiver); |
|
339 } |
|
340 |
|
341 function __addDisposableResource(env, value, async) { |
|
342 if (value !== null && value !== void 0) { |
|
343 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); |
|
344 var dispose; |
|
345 if (async) { |
|
346 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); |
|
347 dispose = value[Symbol.asyncDispose]; |
|
348 } |
|
349 if (dispose === void 0) { |
|
350 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); |
|
351 dispose = value[Symbol.dispose]; |
|
352 } |
|
353 if (typeof dispose !== "function") throw new TypeError("Object not disposable."); |
|
354 env.stack.push({ value: value, dispose: dispose, async: async }); |
|
355 } |
|
356 else if (async) { |
|
357 env.stack.push({ async: true }); |
|
358 } |
|
359 return value; |
|
360 } |
|
361 |
|
362 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { |
|
363 var e = new Error(message); |
|
364 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; |
|
365 }; |
|
366 |
|
367 function __disposeResources(env) { |
|
368 function fail(e) { |
|
369 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; |
|
370 env.hasError = true; |
|
371 } |
|
372 function next() { |
|
373 while (env.stack.length) { |
|
374 var rec = env.stack.pop(); |
|
375 try { |
|
376 var result = rec.dispose && rec.dispose.call(rec.value); |
|
377 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); |
|
378 } |
|
379 catch (e) { |
|
380 fail(e); |
|
381 } |
|
382 } |
|
383 if (env.hasError) throw env.error; |
|
384 } |
|
385 return next(); |
|
386 } |
|
387 |
|
388 /* harmony default export */ const tslib_es6 = ({ |
|
389 __extends, |
|
390 __assign, |
|
391 __rest, |
|
392 __decorate, |
|
393 __param, |
|
394 __metadata, |
|
395 __awaiter, |
|
396 __generator, |
|
397 __createBinding, |
|
398 __exportStar, |
|
399 __values, |
|
400 __read, |
|
401 __spread, |
|
402 __spreadArrays, |
|
403 __spreadArray, |
|
404 __await, |
|
405 __asyncGenerator, |
|
406 __asyncDelegator, |
|
407 __asyncValues, |
|
408 __makeTemplateObject, |
|
409 __importStar, |
|
410 __importDefault, |
|
411 __classPrivateFieldGet, |
|
412 __classPrivateFieldSet, |
|
413 __classPrivateFieldIn, |
|
414 __addDisposableResource, |
|
415 __disposeResources, |
|
416 }); |
|
417 |
|
418 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js |
|
419 /** |
|
420 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt |
|
421 */ |
|
422 var SUPPORTED_LOCALE = { |
|
423 tr: { |
|
424 regexp: /\u0130|\u0049|\u0049\u0307/g, |
|
425 map: { |
|
426 İ: "\u0069", |
|
427 I: "\u0131", |
|
428 İ: "\u0069", |
|
429 }, |
|
430 }, |
|
431 az: { |
|
432 regexp: /\u0130/g, |
|
433 map: { |
|
434 İ: "\u0069", |
|
435 I: "\u0131", |
|
436 İ: "\u0069", |
|
437 }, |
|
438 }, |
|
439 lt: { |
|
440 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, |
|
441 map: { |
|
442 I: "\u0069\u0307", |
|
443 J: "\u006A\u0307", |
|
444 Į: "\u012F\u0307", |
|
445 Ì: "\u0069\u0307\u0300", |
|
446 Í: "\u0069\u0307\u0301", |
|
447 Ĩ: "\u0069\u0307\u0303", |
|
448 }, |
|
449 }, |
|
450 }; |
|
451 /** |
|
452 * Localized lower case. |
|
453 */ |
|
454 function localeLowerCase(str, locale) { |
|
455 var lang = SUPPORTED_LOCALE[locale.toLowerCase()]; |
|
456 if (lang) |
|
457 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; })); |
|
458 return lowerCase(str); |
|
459 } |
|
460 /** |
|
461 * Lower case as a function. |
|
462 */ |
|
463 function lowerCase(str) { |
|
464 return str.toLowerCase(); |
|
465 } |
|
466 |
|
467 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js |
|
468 |
|
469 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). |
|
470 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; |
|
471 // Remove all non-word characters. |
|
472 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; |
|
473 /** |
|
474 * Normalize the string into something other libraries can manipulate easier. |
|
475 */ |
|
476 function noCase(input, options) { |
|
477 if (options === void 0) { options = {}; } |
|
478 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; |
|
479 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); |
|
480 var start = 0; |
|
481 var end = result.length; |
|
482 // Trim the delimiter from around the output string. |
|
483 while (result.charAt(start) === "\0") |
|
484 start++; |
|
485 while (result.charAt(end - 1) === "\0") |
|
486 end--; |
|
487 // Transform each token independently. |
|
488 return result.slice(start, end).split("\0").map(transform).join(delimiter); |
|
489 } |
|
490 /** |
|
491 * Replace `re` in the input string with the replacement value. |
|
492 */ |
|
493 function replace(input, re, value) { |
|
494 if (re instanceof RegExp) |
|
495 return input.replace(re, value); |
|
496 return re.reduce(function (input, re) { return input.replace(re, value); }, input); |
|
497 } |
|
498 |
|
499 ;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js |
|
500 |
|
501 |
|
502 function dotCase(input, options) { |
|
503 if (options === void 0) { options = {}; } |
|
504 return noCase(input, __assign({ delimiter: "." }, options)); |
|
505 } |
|
506 |
|
507 ;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js |
|
508 |
|
509 |
|
510 function paramCase(input, options) { |
|
511 if (options === void 0) { options = {}; } |
|
512 return dotCase(input, __assign({ delimiter: "-" }, options)); |
|
513 } |
|
514 |
|
515 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/constants.js |
|
516 const VARIABLE_REFERENCE_PREFIX = 'var:'; |
|
517 const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|'; |
|
518 const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--'; |
|
519 |
|
520 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/utils.js |
|
521 /** |
|
522 * External dependencies |
|
523 */ |
|
524 |
|
525 |
|
526 /** |
|
527 * Internal dependencies |
|
528 */ |
|
529 |
|
530 |
|
531 |
|
532 /** |
|
533 * Helper util to return a value from a certain path of the object. |
|
534 * Path is specified as an array of properties, like `[ 'x', 'y' ]`. |
|
535 * |
|
536 * @param object Input object. |
|
537 * @param path Path to the object property. |
|
538 * @return Value of the object property at the specified path. |
|
539 */ |
|
540 const getStyleValueByPath = (object, path) => { |
|
541 let value = object; |
|
542 path.forEach(fieldName => { |
|
543 value = value?.[fieldName]; |
|
544 }); |
|
545 return value; |
|
546 }; |
|
547 |
|
548 /** |
|
549 * Returns a JSON representation of the generated CSS rules. |
|
550 * |
|
551 * @param style Style object. |
|
552 * @param options Options object with settings to adjust how the styles are generated. |
|
553 * @param path An array of strings representing the path to the style value in the style object. |
|
554 * @param ruleKey A CSS property key. |
|
555 * |
|
556 * @return GeneratedCSSRule[] CSS rules. |
|
557 */ |
|
558 function generateRule(style, options, path, ruleKey) { |
|
559 const styleValue = getStyleValueByPath(style, path); |
|
560 return styleValue ? [{ |
|
561 selector: options?.selector, |
|
562 key: ruleKey, |
|
563 value: getCSSVarFromStyleValue(styleValue) |
|
564 }] : []; |
|
565 } |
|
566 |
|
567 /** |
|
568 * Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left. |
|
569 * |
|
570 * @param style Style object. |
|
571 * @param options Options object with settings to adjust how the styles are generated. |
|
572 * @param path An array of strings representing the path to the style value in the style object. |
|
573 * @param ruleKeys An array of CSS property keys and patterns. |
|
574 * @param individualProperties The "sides" or individual properties for which to generate rules. |
|
575 * |
|
576 * @return GeneratedCSSRule[] CSS rules. |
|
577 */ |
|
578 function generateBoxRules(style, options, path, ruleKeys, individualProperties = ['top', 'right', 'bottom', 'left']) { |
|
579 const boxStyle = getStyleValueByPath(style, path); |
|
580 if (!boxStyle) { |
|
581 return []; |
|
582 } |
|
583 const rules = []; |
|
584 if (typeof boxStyle === 'string') { |
|
585 rules.push({ |
|
586 selector: options?.selector, |
|
587 key: ruleKeys.default, |
|
588 value: boxStyle |
|
589 }); |
|
590 } else { |
|
591 const sideRules = individualProperties.reduce((acc, side) => { |
|
592 const value = getCSSVarFromStyleValue(getStyleValueByPath(boxStyle, [side])); |
|
593 if (value) { |
|
594 acc.push({ |
|
595 selector: options?.selector, |
|
596 key: ruleKeys?.individual.replace('%s', upperFirst(side)), |
|
597 value |
|
598 }); |
|
599 } |
|
600 return acc; |
|
601 }, []); |
|
602 rules.push(...sideRules); |
|
603 } |
|
604 return rules; |
|
605 } |
|
606 |
|
607 /** |
|
608 * Returns a CSS var value from incoming style value following the pattern `var:description|context|slug`. |
|
609 * |
|
610 * @param styleValue A raw style value. |
|
611 * |
|
612 * @return string A CSS var value. |
|
613 */ |
|
614 function getCSSVarFromStyleValue(styleValue) { |
|
615 if (typeof styleValue === 'string' && styleValue.startsWith(VARIABLE_REFERENCE_PREFIX)) { |
|
616 const variable = styleValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).map(presetVariable => paramCase(presetVariable, { |
|
617 splitRegexp: [/([a-z0-9])([A-Z])/g, |
|
618 // fooBar => foo-bar, 3Bar => 3-bar |
|
619 /([0-9])([a-z])/g, |
|
620 // 3bar => 3-bar |
|
621 /([A-Za-z])([0-9])/g, |
|
622 // Foo3 => foo-3, foo3 => foo-3 |
|
623 /([A-Z])([A-Z][a-z])/g // FOOBar => foo-bar |
|
624 ] |
|
625 })).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE); |
|
626 return `var(--wp--${variable})`; |
|
627 } |
|
628 return styleValue; |
|
629 } |
|
630 |
|
631 /** |
|
632 * Capitalizes the first letter in a string. |
|
633 * |
|
634 * @param string The string whose first letter the function will capitalize. |
|
635 * |
|
636 * @return String with the first letter capitalized. |
|
637 */ |
|
638 function upperFirst(string) { |
|
639 const [firstLetter, ...rest] = string; |
|
640 return firstLetter.toUpperCase() + rest.join(''); |
|
641 } |
|
642 |
|
643 /** |
|
644 * Converts an array of strings into a camelCase string. |
|
645 * |
|
646 * @param strings The strings to join into a camelCase string. |
|
647 * |
|
648 * @return camelCase string. |
|
649 */ |
|
650 function camelCaseJoin(strings) { |
|
651 const [firstItem, ...rest] = strings; |
|
652 return firstItem.toLowerCase() + rest.map(upperFirst).join(''); |
|
653 } |
|
654 |
|
655 /** |
|
656 * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if |
|
657 * `decodeURI` throws an error. |
|
658 * |
|
659 * @param {string} uri URI to decode. |
|
660 * |
|
661 * @example |
|
662 * ```js |
|
663 * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' |
|
664 * ``` |
|
665 * |
|
666 * @return {string} Decoded URI if possible. |
|
667 */ |
|
668 function safeDecodeURI(uri) { |
|
669 try { |
|
670 return decodeURI(uri); |
|
671 } catch (uriError) { |
|
672 return uri; |
|
673 } |
|
674 } |
|
675 |
|
676 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/border/index.js |
|
677 /** |
|
678 * Internal dependencies |
|
679 */ |
|
680 |
|
681 |
|
682 |
|
683 /** |
|
684 * Creates a function for generating CSS rules when the style path is the same as the camelCase CSS property used in React. |
|
685 * |
|
686 * @param path An array of strings representing the path to the style value in the style object. |
|
687 * |
|
688 * @return A function that generates CSS rules. |
|
689 */ |
|
690 function createBorderGenerateFunction(path) { |
|
691 return (style, options) => generateRule(style, options, path, camelCaseJoin(path)); |
|
692 } |
|
693 |
|
694 /** |
|
695 * Creates a function for generating border-{top,bottom,left,right}-{color,style,width} CSS rules. |
|
696 * |
|
697 * @param edge The edge to create CSS rules for. |
|
698 * |
|
699 * @return A function that generates CSS rules. |
|
700 */ |
|
701 function createBorderEdgeGenerateFunction(edge) { |
|
702 return (style, options) => { |
|
703 return ['color', 'style', 'width'].flatMap(key => { |
|
704 const path = ['border', edge, key]; |
|
705 return createBorderGenerateFunction(path)(style, options); |
|
706 }); |
|
707 }; |
|
708 } |
|
709 const color = { |
|
710 name: 'color', |
|
711 generate: createBorderGenerateFunction(['border', 'color']) |
|
712 }; |
|
713 const radius = { |
|
714 name: 'radius', |
|
715 generate: (style, options) => { |
|
716 return generateBoxRules(style, options, ['border', 'radius'], { |
|
717 default: 'borderRadius', |
|
718 individual: 'border%sRadius' |
|
719 }, ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']); |
|
720 } |
|
721 }; |
|
722 const borderStyle = { |
|
723 name: 'style', |
|
724 generate: createBorderGenerateFunction(['border', 'style']) |
|
725 }; |
|
726 const width = { |
|
727 name: 'width', |
|
728 generate: createBorderGenerateFunction(['border', 'width']) |
|
729 }; |
|
730 const borderTop = { |
|
731 name: 'borderTop', |
|
732 generate: createBorderEdgeGenerateFunction('top') |
|
733 }; |
|
734 const borderRight = { |
|
735 name: 'borderRight', |
|
736 generate: createBorderEdgeGenerateFunction('right') |
|
737 }; |
|
738 const borderBottom = { |
|
739 name: 'borderBottom', |
|
740 generate: createBorderEdgeGenerateFunction('bottom') |
|
741 }; |
|
742 const borderLeft = { |
|
743 name: 'borderLeft', |
|
744 generate: createBorderEdgeGenerateFunction('left') |
|
745 }; |
|
746 /* harmony default export */ const border = ([color, borderStyle, width, radius, borderTop, borderRight, borderBottom, borderLeft]); |
|
747 |
|
748 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/background.js |
|
749 /** |
|
750 * Internal dependencies |
|
751 */ |
|
752 |
|
753 |
|
754 const background = { |
|
755 name: 'background', |
|
756 generate: (style, options) => { |
|
757 return generateRule(style, options, ['color', 'background'], 'backgroundColor'); |
|
758 } |
|
759 }; |
|
760 /* harmony default export */ const color_background = (background); |
|
761 |
|
762 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/gradient.js |
|
763 /** |
|
764 * Internal dependencies |
|
765 */ |
|
766 |
|
767 |
|
768 const gradient = { |
|
769 name: 'gradient', |
|
770 generate: (style, options) => { |
|
771 return generateRule(style, options, ['color', 'gradient'], 'background'); |
|
772 } |
|
773 }; |
|
774 /* harmony default export */ const color_gradient = (gradient); |
|
775 |
|
776 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/text.js |
|
777 /** |
|
778 * Internal dependencies |
|
779 */ |
|
780 |
|
781 |
|
782 const text_text = { |
|
783 name: 'text', |
|
784 generate: (style, options) => { |
|
785 return generateRule(style, options, ['color', 'text'], 'color'); |
|
786 } |
|
787 }; |
|
788 /* harmony default export */ const color_text = (text_text); |
|
789 |
|
790 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/index.js |
|
791 /** |
|
792 * Internal dependencies |
|
793 */ |
|
794 |
|
795 |
|
796 |
|
797 /* harmony default export */ const styles_color = ([color_text, color_gradient, color_background]); |
|
798 |
|
799 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/dimensions/index.js |
|
800 /** |
|
801 * Internal dependencies |
|
802 */ |
|
803 |
|
804 |
|
805 const minHeight = { |
|
806 name: 'minHeight', |
|
807 generate: (style, options) => { |
|
808 return generateRule(style, options, ['dimensions', 'minHeight'], 'minHeight'); |
|
809 } |
|
810 }; |
|
811 const aspectRatio = { |
|
812 name: 'aspectRatio', |
|
813 generate: (style, options) => { |
|
814 return generateRule(style, options, ['dimensions', 'aspectRatio'], 'aspectRatio'); |
|
815 } |
|
816 }; |
|
817 /* harmony default export */ const dimensions = ([minHeight, aspectRatio]); |
|
818 |
|
819 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/background/index.js |
|
820 /** |
|
821 * Internal dependencies |
|
822 */ |
|
823 |
|
824 |
|
825 const backgroundImage = { |
|
826 name: 'backgroundImage', |
|
827 generate: (style, options) => { |
|
828 const _backgroundImage = style?.background?.backgroundImage; |
|
829 if (typeof _backgroundImage === 'object' && _backgroundImage?.url) { |
|
830 return [{ |
|
831 selector: options.selector, |
|
832 key: 'backgroundImage', |
|
833 // Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string. |
|
834 value: `url( '${encodeURI(safeDecodeURI(_backgroundImage.url))}' )` |
|
835 }]; |
|
836 } |
|
837 |
|
838 /* |
|
839 * If the background image is a string, it could already contain a url() function, |
|
840 * or have a linear-gradient value. |
|
841 */ |
|
842 if (typeof _backgroundImage === 'string') { |
|
843 return generateRule(style, options, ['background', 'backgroundImage'], 'backgroundImage'); |
|
844 } |
|
845 return []; |
|
846 } |
|
847 }; |
|
848 const backgroundPosition = { |
|
849 name: 'backgroundPosition', |
|
850 generate: (style, options) => { |
|
851 return generateRule(style, options, ['background', 'backgroundPosition'], 'backgroundPosition'); |
|
852 } |
|
853 }; |
|
854 const backgroundRepeat = { |
|
855 name: 'backgroundRepeat', |
|
856 generate: (style, options) => { |
|
857 return generateRule(style, options, ['background', 'backgroundRepeat'], 'backgroundRepeat'); |
|
858 } |
|
859 }; |
|
860 const backgroundSize = { |
|
861 name: 'backgroundSize', |
|
862 generate: (style, options) => { |
|
863 return generateRule(style, options, ['background', 'backgroundSize'], 'backgroundSize'); |
|
864 } |
|
865 }; |
|
866 /* harmony default export */ const styles_background = ([backgroundImage, backgroundPosition, backgroundRepeat, backgroundSize]); |
|
867 |
|
868 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/shadow/index.js |
|
869 /** |
|
870 * Internal dependencies |
|
871 */ |
|
872 |
|
873 |
|
874 const shadow = { |
|
875 name: 'shadow', |
|
876 generate: (style, options) => { |
|
877 return generateRule(style, options, ['shadow'], 'boxShadow'); |
|
878 } |
|
879 }; |
|
880 /* harmony default export */ const styles_shadow = ([shadow]); |
|
881 |
|
882 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/outline/index.js |
|
883 /** |
|
884 * Internal dependencies |
|
885 */ |
|
886 |
|
887 |
|
888 const outline_color = { |
|
889 name: 'color', |
|
890 generate: (style, options, path = ['outline', 'color'], ruleKey = 'outlineColor') => { |
|
891 return generateRule(style, options, path, ruleKey); |
|
892 } |
|
893 }; |
|
894 const offset = { |
|
895 name: 'offset', |
|
896 generate: (style, options, path = ['outline', 'offset'], ruleKey = 'outlineOffset') => { |
|
897 return generateRule(style, options, path, ruleKey); |
|
898 } |
|
899 }; |
|
900 const outlineStyle = { |
|
901 name: 'style', |
|
902 generate: (style, options, path = ['outline', 'style'], ruleKey = 'outlineStyle') => { |
|
903 return generateRule(style, options, path, ruleKey); |
|
904 } |
|
905 }; |
|
906 const outline_width = { |
|
907 name: 'width', |
|
908 generate: (style, options, path = ['outline', 'width'], ruleKey = 'outlineWidth') => { |
|
909 return generateRule(style, options, path, ruleKey); |
|
910 } |
|
911 }; |
|
912 /* harmony default export */ const outline = ([outline_color, outlineStyle, offset, outline_width]); |
|
913 |
|
914 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/spacing/padding.js |
|
915 /** |
|
916 * Internal dependencies |
|
917 */ |
|
918 |
|
919 |
|
920 const padding = { |
|
921 name: 'padding', |
|
922 generate: (style, options) => { |
|
923 return generateBoxRules(style, options, ['spacing', 'padding'], { |
|
924 default: 'padding', |
|
925 individual: 'padding%s' |
|
926 }); |
|
927 } |
|
928 }; |
|
929 /* harmony default export */ const spacing_padding = (padding); |
|
930 |
|
931 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/spacing/margin.js |
|
932 /** |
|
933 * Internal dependencies |
|
934 */ |
|
935 |
|
936 |
|
937 const margin = { |
|
938 name: 'margin', |
|
939 generate: (style, options) => { |
|
940 return generateBoxRules(style, options, ['spacing', 'margin'], { |
|
941 default: 'margin', |
|
942 individual: 'margin%s' |
|
943 }); |
|
944 } |
|
945 }; |
|
946 /* harmony default export */ const spacing_margin = (margin); |
|
947 |
|
948 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/spacing/index.js |
|
949 /** |
|
950 * Internal dependencies |
|
951 */ |
|
952 |
|
953 |
|
954 /* harmony default export */ const spacing = ([spacing_margin, spacing_padding]); |
|
955 |
|
956 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/typography/index.js |
|
957 /** |
|
958 * Internal dependencies |
|
959 */ |
|
960 |
|
961 |
|
962 const fontSize = { |
|
963 name: 'fontSize', |
|
964 generate: (style, options) => { |
|
965 return generateRule(style, options, ['typography', 'fontSize'], 'fontSize'); |
|
966 } |
|
967 }; |
|
968 const fontStyle = { |
|
969 name: 'fontStyle', |
|
970 generate: (style, options) => { |
|
971 return generateRule(style, options, ['typography', 'fontStyle'], 'fontStyle'); |
|
972 } |
|
973 }; |
|
974 const fontWeight = { |
|
975 name: 'fontWeight', |
|
976 generate: (style, options) => { |
|
977 return generateRule(style, options, ['typography', 'fontWeight'], 'fontWeight'); |
|
978 } |
|
979 }; |
|
980 const fontFamily = { |
|
981 name: 'fontFamily', |
|
982 generate: (style, options) => { |
|
983 return generateRule(style, options, ['typography', 'fontFamily'], 'fontFamily'); |
|
984 } |
|
985 }; |
|
986 const letterSpacing = { |
|
987 name: 'letterSpacing', |
|
988 generate: (style, options) => { |
|
989 return generateRule(style, options, ['typography', 'letterSpacing'], 'letterSpacing'); |
|
990 } |
|
991 }; |
|
992 const lineHeight = { |
|
993 name: 'lineHeight', |
|
994 generate: (style, options) => { |
|
995 return generateRule(style, options, ['typography', 'lineHeight'], 'lineHeight'); |
|
996 } |
|
997 }; |
|
998 const textColumns = { |
|
999 name: 'textColumns', |
|
1000 generate: (style, options) => { |
|
1001 return generateRule(style, options, ['typography', 'textColumns'], 'columnCount'); |
|
1002 } |
|
1003 }; |
|
1004 const textDecoration = { |
|
1005 name: 'textDecoration', |
|
1006 generate: (style, options) => { |
|
1007 return generateRule(style, options, ['typography', 'textDecoration'], 'textDecoration'); |
|
1008 } |
|
1009 }; |
|
1010 const textTransform = { |
|
1011 name: 'textTransform', |
|
1012 generate: (style, options) => { |
|
1013 return generateRule(style, options, ['typography', 'textTransform'], 'textTransform'); |
|
1014 } |
|
1015 }; |
|
1016 const writingMode = { |
|
1017 name: 'writingMode', |
|
1018 generate: (style, options) => { |
|
1019 return generateRule(style, options, ['typography', 'writingMode'], 'writingMode'); |
|
1020 } |
|
1021 }; |
|
1022 /* harmony default export */ const typography = ([fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textColumns, textDecoration, textTransform, writingMode]); |
|
1023 |
|
1024 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/index.js |
|
1025 /** |
|
1026 * Internal dependencies |
|
1027 */ |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 const styleDefinitions = [...border, ...styles_color, ...dimensions, ...outline, ...spacing, ...typography, ...styles_shadow, ...styles_background]; |
|
1037 |
|
1038 ;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/index.js |
|
1039 /** |
|
1040 * External dependencies |
|
1041 */ |
|
1042 |
|
1043 |
|
1044 /** |
|
1045 * Internal dependencies |
|
1046 */ |
|
1047 |
|
1048 |
|
1049 |
|
1050 /** |
|
1051 * Generates a stylesheet for a given style object and selector. |
|
1052 * |
|
1053 * @since 6.1.0 Introduced in WordPress core. |
|
1054 * |
|
1055 * @param style Style object, for example, the value of a block's attributes.style object or the top level styles in theme.json |
|
1056 * @param options Options object with settings to adjust how the styles are generated. |
|
1057 * |
|
1058 * @return A generated stylesheet or inline style declarations. |
|
1059 */ |
|
1060 function compileCSS(style, options = {}) { |
|
1061 const rules = getCSSRules(style, options); |
|
1062 |
|
1063 // If no selector is provided, treat generated rules as inline styles to be returned as a single string. |
|
1064 if (!options?.selector) { |
|
1065 const inlineRules = []; |
|
1066 rules.forEach(rule => { |
|
1067 inlineRules.push(`${paramCase(rule.key)}: ${rule.value};`); |
|
1068 }); |
|
1069 return inlineRules.join(' '); |
|
1070 } |
|
1071 const groupedRules = rules.reduce((acc, rule) => { |
|
1072 const { |
|
1073 selector |
|
1074 } = rule; |
|
1075 if (!selector) { |
|
1076 return acc; |
|
1077 } |
|
1078 if (!acc[selector]) { |
|
1079 acc[selector] = []; |
|
1080 } |
|
1081 acc[selector].push(rule); |
|
1082 return acc; |
|
1083 }, {}); |
|
1084 const selectorRules = Object.keys(groupedRules).reduce((acc, subSelector) => { |
|
1085 acc.push(`${subSelector} { ${groupedRules[subSelector].map(rule => `${paramCase(rule.key)}: ${rule.value};`).join(' ')} }`); |
|
1086 return acc; |
|
1087 }, []); |
|
1088 return selectorRules.join('\n'); |
|
1089 } |
|
1090 |
|
1091 /** |
|
1092 * Returns a JSON representation of the generated CSS rules. |
|
1093 * |
|
1094 * @since 6.1.0 Introduced in WordPress core. |
|
1095 * |
|
1096 * @param style Style object, for example, the value of a block's attributes.style object or the top level styles in theme.json |
|
1097 * @param options Options object with settings to adjust how the styles are generated. |
|
1098 * |
|
1099 * @return A collection of objects containing the selector, if any, the CSS property key (camelcase) and parsed CSS value. |
|
1100 */ |
|
1101 function getCSSRules(style, options = {}) { |
|
1102 const rules = []; |
|
1103 styleDefinitions.forEach(definition => { |
|
1104 if (typeof definition.generate === 'function') { |
|
1105 rules.push(...definition.generate(style, options)); |
|
1106 } |
|
1107 }); |
|
1108 return rules; |
|
1109 } |
|
1110 |
|
1111 (window.wp = window.wp || {}).styleEngine = __webpack_exports__; |
|
1112 /******/ })() |
|
1113 ; |