@otl-core/cms-utils 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +14 -651
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -312
- package/dist/index.d.ts +2 -312
- package/dist/index.js +15 -609
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var clsx = require('clsx');
|
|
4
|
-
var tailwindMerge = require('tailwind-merge');
|
|
5
|
-
|
|
6
3
|
// src/abn-resolver.utils.ts
|
|
7
4
|
function selectVariant(bucket, variants) {
|
|
8
5
|
if (variants.length === 0) {
|
|
@@ -96,7 +93,12 @@ function resolveBlockVariant(block, bucket) {
|
|
|
96
93
|
}
|
|
97
94
|
const config = block.config;
|
|
98
95
|
if (!isRecord(config)) return block;
|
|
99
|
-
|
|
96
|
+
let childKey = null;
|
|
97
|
+
if (Array.isArray(config.children)) {
|
|
98
|
+
childKey = "children";
|
|
99
|
+
} else if (Array.isArray(config.child)) {
|
|
100
|
+
childKey = "child";
|
|
101
|
+
}
|
|
100
102
|
if (!childKey) return block;
|
|
101
103
|
const children = config[childKey];
|
|
102
104
|
const resolvedChildren = children.map(
|
|
@@ -114,409 +116,6 @@ function isRecord(value) {
|
|
|
114
116
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
// src/category.utils.ts
|
|
118
|
-
function buildCategoryTree(categories) {
|
|
119
|
-
const categoryMap = /* @__PURE__ */ new Map();
|
|
120
|
-
const roots = [];
|
|
121
|
-
categories.forEach((category) => {
|
|
122
|
-
categoryMap.set(category.id, { ...category, children: [] });
|
|
123
|
-
});
|
|
124
|
-
categories.forEach((category) => {
|
|
125
|
-
const node = categoryMap.get(category.id);
|
|
126
|
-
if (!node) return;
|
|
127
|
-
if (category.parent_id) {
|
|
128
|
-
const parent = categoryMap.get(category.parent_id);
|
|
129
|
-
if (parent) {
|
|
130
|
-
parent.children.push(node);
|
|
131
|
-
} else {
|
|
132
|
-
roots.push(node);
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
roots.push(node);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
const sortByOrder = (a, b) => a.sort_order - b.sort_order;
|
|
139
|
-
roots.sort(sortByOrder);
|
|
140
|
-
categoryMap.forEach((node) => {
|
|
141
|
-
node.children.sort(sortByOrder);
|
|
142
|
-
});
|
|
143
|
-
return roots;
|
|
144
|
-
}
|
|
145
|
-
function flattenCategoryTree(tree) {
|
|
146
|
-
const result = [];
|
|
147
|
-
const flatten = (nodes) => {
|
|
148
|
-
nodes.forEach((node) => {
|
|
149
|
-
const { children, ...category } = node;
|
|
150
|
-
result.push(category);
|
|
151
|
-
if (children.length > 0) {
|
|
152
|
-
flatten(children);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
flatten(tree);
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
function getCategoryPath(categoryId, categories, locale) {
|
|
160
|
-
const categoryMap = /* @__PURE__ */ new Map();
|
|
161
|
-
categories.forEach((cat) => categoryMap.set(cat.id, cat));
|
|
162
|
-
const path = [];
|
|
163
|
-
let currentId = categoryId;
|
|
164
|
-
while (currentId) {
|
|
165
|
-
const category = categoryMap.get(currentId);
|
|
166
|
-
if (!category) break;
|
|
167
|
-
path.unshift(category);
|
|
168
|
-
currentId = category.parent_id;
|
|
169
|
-
}
|
|
170
|
-
return path;
|
|
171
|
-
}
|
|
172
|
-
function getCategoryName(category, locale, fallbackLocale = "en") {
|
|
173
|
-
if (typeof category.name === "string") {
|
|
174
|
-
return category.name;
|
|
175
|
-
}
|
|
176
|
-
return category.name[locale] || category.name[fallbackLocale] || Object.values(category.name)[0] || "Untitled";
|
|
177
|
-
}
|
|
178
|
-
function getCategorySlug(category, locale, fallbackLocale = "en") {
|
|
179
|
-
if (typeof category.slug === "string") {
|
|
180
|
-
return category.slug;
|
|
181
|
-
}
|
|
182
|
-
return category.slug[locale] || category.slug[fallbackLocale] || Object.values(category.slug)[0] || "";
|
|
183
|
-
}
|
|
184
|
-
function isAncestor(ancestorId, descendantId, categories) {
|
|
185
|
-
const categoryMap = /* @__PURE__ */ new Map();
|
|
186
|
-
categories.forEach((cat) => categoryMap.set(cat.id, cat));
|
|
187
|
-
let currentId = descendantId;
|
|
188
|
-
while (currentId) {
|
|
189
|
-
const category = categoryMap.get(currentId);
|
|
190
|
-
if (!category) break;
|
|
191
|
-
if (category.parent_id === ancestorId) {
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
194
|
-
currentId = category.parent_id;
|
|
195
|
-
}
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
function getDescendants(categoryId, categories) {
|
|
199
|
-
const descendants = [];
|
|
200
|
-
const findChildren = (parentId) => {
|
|
201
|
-
const children = categories.filter((cat) => cat.parent_id === parentId);
|
|
202
|
-
children.forEach((child) => {
|
|
203
|
-
descendants.push(child);
|
|
204
|
-
findChildren(child.id);
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
findChildren(categoryId);
|
|
208
|
-
return descendants;
|
|
209
|
-
}
|
|
210
|
-
function findCategoryBySlug(slug, locale, categories) {
|
|
211
|
-
return categories.find((cat) => {
|
|
212
|
-
const categorySlug = typeof cat.slug === "string" ? cat.slug : cat.slug[locale];
|
|
213
|
-
return categorySlug === slug;
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
function cn(...inputs) {
|
|
217
|
-
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// src/responsive.utils.ts
|
|
221
|
-
function normalizeResponsiveValue(value) {
|
|
222
|
-
if (!value) return {};
|
|
223
|
-
if (typeof value === "object" && value !== null && "base" in value) {
|
|
224
|
-
return value;
|
|
225
|
-
}
|
|
226
|
-
return { base: value };
|
|
227
|
-
}
|
|
228
|
-
function isResponsiveConfig(value) {
|
|
229
|
-
return typeof value === "object" && value !== null && "base" in value && !Array.isArray(value);
|
|
230
|
-
}
|
|
231
|
-
function getBreakpointValue(value, breakpoint) {
|
|
232
|
-
if (!isResponsiveConfig(value)) {
|
|
233
|
-
return value;
|
|
234
|
-
}
|
|
235
|
-
return value[breakpoint] ?? value.base;
|
|
236
|
-
}
|
|
237
|
-
function getDefinedBreakpoints(value) {
|
|
238
|
-
if (!isResponsiveConfig(value)) {
|
|
239
|
-
return ["base"];
|
|
240
|
-
}
|
|
241
|
-
const breakpoints = ["base"];
|
|
242
|
-
if (value.sm !== void 0) breakpoints.push("sm");
|
|
243
|
-
if (value.md !== void 0) breakpoints.push("md");
|
|
244
|
-
if (value.lg !== void 0) breakpoints.push("lg");
|
|
245
|
-
if (value.xl !== void 0) breakpoints.push("xl");
|
|
246
|
-
if (value["2xl"] !== void 0) breakpoints.push("2xl");
|
|
247
|
-
return breakpoints;
|
|
248
|
-
}
|
|
249
|
-
function toResponsiveConfig(fields) {
|
|
250
|
-
const config = { base: fields.base };
|
|
251
|
-
if (fields.sm !== void 0) config.sm = fields.sm;
|
|
252
|
-
if (fields.md !== void 0) config.md = fields.md;
|
|
253
|
-
if (fields.lg !== void 0) config.lg = fields.lg;
|
|
254
|
-
if (fields.xl !== void 0) config.xl = fields.xl;
|
|
255
|
-
if (fields["2xl"] !== void 0) config["2xl"] = fields["2xl"];
|
|
256
|
-
return config;
|
|
257
|
-
}
|
|
258
|
-
function fromResponsiveConfig(value) {
|
|
259
|
-
if (!isResponsiveConfig(value)) {
|
|
260
|
-
return { base: value };
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
base: value.base,
|
|
264
|
-
sm: value.sm,
|
|
265
|
-
md: value.md,
|
|
266
|
-
lg: value.lg,
|
|
267
|
-
xl: value.xl,
|
|
268
|
-
"2xl": value["2xl"]
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// src/css.utils.ts
|
|
273
|
-
function minifyCSS(css) {
|
|
274
|
-
return css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~()[\]])\s*/g, "$1").replace(/:\s+/g, ":").replace(/;}/g, "}").replace(/:0px/g, ":0").replace(/:0em/g, ":0").replace(/:0rem/g, ":0").trim();
|
|
275
|
-
}
|
|
276
|
-
function resolveColorToCSS(colorRef, target) {
|
|
277
|
-
if (!colorRef) return void 0;
|
|
278
|
-
if (typeof colorRef !== "object") return void 0;
|
|
279
|
-
const resolvedTarget = target ?? (colorRef.type !== "custom" ? colorRef.target : void 0) ?? "background";
|
|
280
|
-
if (colorRef.type === "custom") {
|
|
281
|
-
if (typeof colorRef.value === "string") {
|
|
282
|
-
return resolvedTarget === "foreground" ? void 0 : colorRef.value;
|
|
283
|
-
}
|
|
284
|
-
return resolvedTarget === "foreground" ? colorRef.value.foreground : colorRef.value.background;
|
|
285
|
-
} else if (colorRef.type === "theme") {
|
|
286
|
-
return resolvedTarget === "foreground" ? `var(--${colorRef.value}-foreground)` : `var(--${colorRef.value})`;
|
|
287
|
-
} else if (colorRef.type === "variable") {
|
|
288
|
-
return resolvedTarget === "foreground" ? `var(--${colorRef.value}-foreground)` : `var(--${colorRef.value})`;
|
|
289
|
-
}
|
|
290
|
-
return void 0;
|
|
291
|
-
}
|
|
292
|
-
function resolveColorsToCSS(colorRefs) {
|
|
293
|
-
const resolved = {};
|
|
294
|
-
for (const key in colorRefs) {
|
|
295
|
-
const colorRef = colorRefs[key];
|
|
296
|
-
if (colorRef) {
|
|
297
|
-
const color = resolveColorToCSS(colorRef);
|
|
298
|
-
if (color) {
|
|
299
|
-
resolved[key] = color;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return resolved;
|
|
304
|
-
}
|
|
305
|
-
function resolveBorderToCSS(borderConfig) {
|
|
306
|
-
if (!borderConfig) return void 0;
|
|
307
|
-
const result = {};
|
|
308
|
-
const resolveSide = (side, defaultWidth, defaultStyle, defaultColor) => {
|
|
309
|
-
const width = side?.width || defaultWidth;
|
|
310
|
-
const style = side?.style || defaultStyle;
|
|
311
|
-
const color = side?.color || defaultColor;
|
|
312
|
-
if (!width || !style || !color) return void 0;
|
|
313
|
-
const resolvedColor = resolveColorToCSS(color);
|
|
314
|
-
if (!resolvedColor) return void 0;
|
|
315
|
-
return `${width} ${style} ${resolvedColor}`;
|
|
316
|
-
};
|
|
317
|
-
const hasIndividualSides = borderConfig.top || borderConfig.right || borderConfig.bottom || borderConfig.left;
|
|
318
|
-
if (hasIndividualSides) {
|
|
319
|
-
const topBorder = resolveSide(
|
|
320
|
-
borderConfig.top,
|
|
321
|
-
borderConfig.width,
|
|
322
|
-
borderConfig.style,
|
|
323
|
-
borderConfig.color
|
|
324
|
-
);
|
|
325
|
-
if (topBorder) result.borderTop = topBorder;
|
|
326
|
-
const rightBorder = resolveSide(
|
|
327
|
-
borderConfig.right,
|
|
328
|
-
borderConfig.width,
|
|
329
|
-
borderConfig.style,
|
|
330
|
-
borderConfig.color
|
|
331
|
-
);
|
|
332
|
-
if (rightBorder) result.borderRight = rightBorder;
|
|
333
|
-
const bottomBorder = resolveSide(
|
|
334
|
-
borderConfig.bottom,
|
|
335
|
-
borderConfig.width,
|
|
336
|
-
borderConfig.style,
|
|
337
|
-
borderConfig.color
|
|
338
|
-
);
|
|
339
|
-
if (bottomBorder) result.borderBottom = bottomBorder;
|
|
340
|
-
const leftBorder = resolveSide(
|
|
341
|
-
borderConfig.left,
|
|
342
|
-
borderConfig.width,
|
|
343
|
-
borderConfig.style,
|
|
344
|
-
borderConfig.color
|
|
345
|
-
);
|
|
346
|
-
if (leftBorder) result.borderLeft = leftBorder;
|
|
347
|
-
} else if (borderConfig.width && borderConfig.style && borderConfig.color) {
|
|
348
|
-
const color = resolveColorToCSS(borderConfig.color);
|
|
349
|
-
if (color) {
|
|
350
|
-
result.border = `${borderConfig.width} ${borderConfig.style} ${color}`;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
if (borderConfig.radius) {
|
|
354
|
-
result.borderRadius = borderConfig.radius;
|
|
355
|
-
}
|
|
356
|
-
return Object.keys(result).length > 0 ? result : void 0;
|
|
357
|
-
}
|
|
358
|
-
function normalizeResponsiveValue2(value) {
|
|
359
|
-
if (!value) return {};
|
|
360
|
-
if (isResponsiveConfig(value)) {
|
|
361
|
-
return {
|
|
362
|
-
base: value.base,
|
|
363
|
-
sm: value.sm,
|
|
364
|
-
md: value.md,
|
|
365
|
-
lg: value.lg,
|
|
366
|
-
xl: value.xl
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
return { base: value };
|
|
370
|
-
}
|
|
371
|
-
var BREAKPOINTS = [
|
|
372
|
-
{ key: "Sm", minWidth: "640px" },
|
|
373
|
-
{ key: "Md", minWidth: "768px" },
|
|
374
|
-
{ key: "Lg", minWidth: "1024px" },
|
|
375
|
-
{ key: "Xl", minWidth: "1280px" }
|
|
376
|
-
];
|
|
377
|
-
function generateResponsiveSpacingCSS(className, config) {
|
|
378
|
-
const css = [];
|
|
379
|
-
const targetClass = `.${className}`;
|
|
380
|
-
const normalizedBorder = normalizeResponsiveValue2(config.border);
|
|
381
|
-
const normalizedMargin = normalizeResponsiveValue2(config.margin);
|
|
382
|
-
const normalizedPadding = normalizeResponsiveValue2(config.padding);
|
|
383
|
-
const normalizedGap = normalizeResponsiveValue2(config.gap);
|
|
384
|
-
const normalizedShadow = normalizeResponsiveValue2(config.shadow);
|
|
385
|
-
const border = {
|
|
386
|
-
base: normalizedBorder.base,
|
|
387
|
-
sm: normalizedBorder.sm,
|
|
388
|
-
md: normalizedBorder.md,
|
|
389
|
-
lg: normalizedBorder.lg,
|
|
390
|
-
xl: normalizedBorder.xl
|
|
391
|
-
};
|
|
392
|
-
const margin = {
|
|
393
|
-
base: normalizedMargin.base,
|
|
394
|
-
sm: normalizedMargin.sm,
|
|
395
|
-
md: normalizedMargin.md,
|
|
396
|
-
lg: normalizedMargin.lg,
|
|
397
|
-
xl: normalizedMargin.xl
|
|
398
|
-
};
|
|
399
|
-
const padding = {
|
|
400
|
-
base: normalizedPadding.base,
|
|
401
|
-
sm: normalizedPadding.sm,
|
|
402
|
-
md: normalizedPadding.md,
|
|
403
|
-
lg: normalizedPadding.lg,
|
|
404
|
-
xl: normalizedPadding.xl
|
|
405
|
-
};
|
|
406
|
-
const gap = {
|
|
407
|
-
base: normalizedGap.base,
|
|
408
|
-
sm: normalizedGap.sm,
|
|
409
|
-
md: normalizedGap.md,
|
|
410
|
-
lg: normalizedGap.lg,
|
|
411
|
-
xl: normalizedGap.xl
|
|
412
|
-
};
|
|
413
|
-
const shadow = {
|
|
414
|
-
base: normalizedShadow.base,
|
|
415
|
-
sm: normalizedShadow.sm,
|
|
416
|
-
md: normalizedShadow.md,
|
|
417
|
-
lg: normalizedShadow.lg,
|
|
418
|
-
xl: normalizedShadow.xl
|
|
419
|
-
};
|
|
420
|
-
const shadowToCSS = (s) => {
|
|
421
|
-
const parts = [s.offsetX, s.offsetY, s.blurRadius, s.spreadRadius, s.color];
|
|
422
|
-
return s.inset ? `inset ${parts.join(" ")}` : parts.join(" ");
|
|
423
|
-
};
|
|
424
|
-
const baseStyles = [];
|
|
425
|
-
if (border.base) {
|
|
426
|
-
const resolvedBorder = resolveBorderToCSS(border.base);
|
|
427
|
-
if (resolvedBorder) {
|
|
428
|
-
Object.entries(resolvedBorder).forEach(([prop, value]) => {
|
|
429
|
-
if (value) {
|
|
430
|
-
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
431
|
-
baseStyles.push(`${cssProp}:${value}`);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if (margin.base) {
|
|
437
|
-
baseStyles.push(`margin:${margin.base}`);
|
|
438
|
-
}
|
|
439
|
-
if (padding.base) {
|
|
440
|
-
baseStyles.push(`padding:${padding.base}`);
|
|
441
|
-
}
|
|
442
|
-
if (gap.base) {
|
|
443
|
-
baseStyles.push(`gap:${gap.base}`);
|
|
444
|
-
}
|
|
445
|
-
if (shadow.base) {
|
|
446
|
-
baseStyles.push(`box-shadow:${shadowToCSS(shadow.base)}`);
|
|
447
|
-
}
|
|
448
|
-
if (baseStyles.length > 0) {
|
|
449
|
-
css.push(`${targetClass}{${baseStyles.join(";")}}`);
|
|
450
|
-
}
|
|
451
|
-
BREAKPOINTS.forEach(({ key, minWidth }) => {
|
|
452
|
-
const bpKey = key.toLowerCase();
|
|
453
|
-
const borderBp = border[bpKey];
|
|
454
|
-
const marginBp = margin[bpKey];
|
|
455
|
-
const paddingBp = padding[bpKey];
|
|
456
|
-
const gapBp = gap[bpKey];
|
|
457
|
-
const shadowBp = shadow[bpKey];
|
|
458
|
-
if (borderBp || marginBp || paddingBp || gapBp || shadowBp) {
|
|
459
|
-
const styles = [];
|
|
460
|
-
if (borderBp) {
|
|
461
|
-
const resolvedBorderBp = resolveBorderToCSS(borderBp);
|
|
462
|
-
if (resolvedBorderBp) {
|
|
463
|
-
Object.entries(resolvedBorderBp).forEach(([prop, value]) => {
|
|
464
|
-
if (value) {
|
|
465
|
-
const cssProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
466
|
-
styles.push(`${cssProp}:${value}`);
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
if (marginBp) {
|
|
472
|
-
styles.push(`margin:${marginBp}`);
|
|
473
|
-
}
|
|
474
|
-
if (paddingBp) {
|
|
475
|
-
styles.push(`padding:${paddingBp}`);
|
|
476
|
-
}
|
|
477
|
-
if (gapBp) {
|
|
478
|
-
styles.push(`gap:${gapBp}`);
|
|
479
|
-
}
|
|
480
|
-
if (shadowBp) {
|
|
481
|
-
styles.push(`box-shadow:${shadowToCSS(shadowBp)}`);
|
|
482
|
-
}
|
|
483
|
-
if (styles.length > 0) {
|
|
484
|
-
css.push(
|
|
485
|
-
`@media(min-width:${minWidth}){${targetClass}{${styles.join(";")}}}`
|
|
486
|
-
);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
return css.length > 0 ? minifyCSS(css.join("")) : null;
|
|
491
|
-
}
|
|
492
|
-
function hasAnyMargin(config) {
|
|
493
|
-
if (config.margin) {
|
|
494
|
-
if (isResponsiveConfig(config.margin)) {
|
|
495
|
-
return !!(config.margin.base || config.margin.sm || config.margin.md || config.margin.lg || config.margin.xl);
|
|
496
|
-
}
|
|
497
|
-
return true;
|
|
498
|
-
}
|
|
499
|
-
return false;
|
|
500
|
-
}
|
|
501
|
-
function getAnimationTimingFunction(timing = "ease-in-out") {
|
|
502
|
-
switch (timing) {
|
|
503
|
-
case "ease":
|
|
504
|
-
return "ease";
|
|
505
|
-
case "ease-in":
|
|
506
|
-
return "ease-in";
|
|
507
|
-
case "ease-out":
|
|
508
|
-
return "ease-out";
|
|
509
|
-
case "ease-in-out":
|
|
510
|
-
return "ease-in-out";
|
|
511
|
-
case "linear":
|
|
512
|
-
return "linear";
|
|
513
|
-
case "spring":
|
|
514
|
-
return "cubic-bezier(0.68,-0.55,0.265,1.55)";
|
|
515
|
-
default:
|
|
516
|
-
return "ease-in-out";
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
119
|
// src/localization.utils.ts
|
|
521
120
|
function getLocalizedString(value, options) {
|
|
522
121
|
if (value === null || value === void 0) return "";
|
|
@@ -545,47 +144,16 @@ function getLocalizedString(value, options) {
|
|
|
545
144
|
}
|
|
546
145
|
return "";
|
|
547
146
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
function isLocalizedString(value) {
|
|
553
|
-
return !!value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0;
|
|
147
|
+
|
|
148
|
+
// src/responsive.utils.ts
|
|
149
|
+
function isResponsiveConfig(value) {
|
|
150
|
+
return typeof value === "object" && value !== null && "base" in value && !Array.isArray(value);
|
|
554
151
|
}
|
|
555
|
-
function
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
return defaultLocale;
|
|
559
|
-
}
|
|
560
|
-
const urlParams = new URLSearchParams(glob.window.location.search);
|
|
561
|
-
const urlLang = urlParams.get("lang");
|
|
562
|
-
if (urlLang && supportedLocales.includes(urlLang)) {
|
|
563
|
-
return urlLang;
|
|
564
|
-
}
|
|
565
|
-
const pathSegments = glob.window.location.pathname.split("/").filter(Boolean);
|
|
566
|
-
if (pathSegments[0] && supportedLocales.includes(pathSegments[0])) {
|
|
567
|
-
return pathSegments[0];
|
|
568
|
-
}
|
|
569
|
-
if (typeof glob.navigator !== "undefined") {
|
|
570
|
-
const browserLang = glob.navigator.language.split("-")[0];
|
|
571
|
-
if (supportedLocales.includes(browserLang)) {
|
|
572
|
-
return browserLang;
|
|
573
|
-
}
|
|
152
|
+
function getBreakpointValue(value, breakpoint) {
|
|
153
|
+
if (!isResponsiveConfig(value)) {
|
|
154
|
+
return value;
|
|
574
155
|
}
|
|
575
|
-
return
|
|
576
|
-
}
|
|
577
|
-
function formatLocaleForHtml(locale) {
|
|
578
|
-
const localeMap = {
|
|
579
|
-
en: "en-US",
|
|
580
|
-
de: "de-DE",
|
|
581
|
-
fr: "fr-FR",
|
|
582
|
-
es: "es-ES",
|
|
583
|
-
it: "it-IT",
|
|
584
|
-
pt: "pt-PT",
|
|
585
|
-
nl: "nl-NL",
|
|
586
|
-
pl: "pl-PL"
|
|
587
|
-
};
|
|
588
|
-
return localeMap[locale] || locale;
|
|
156
|
+
return value[breakpoint] ?? value.base;
|
|
589
157
|
}
|
|
590
158
|
|
|
591
159
|
// src/schedule-resolver.utils.ts
|
|
@@ -601,114 +169,11 @@ function isContentVisible(publishAt, expiresAt, now) {
|
|
|
601
169
|
}
|
|
602
170
|
return true;
|
|
603
171
|
}
|
|
604
|
-
function filterScheduledContent(items, now) {
|
|
605
|
-
return items.filter(
|
|
606
|
-
(item) => isContentVisible(item.publish_at, item.expires_at, now)
|
|
607
|
-
);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
// src/style.utils.ts
|
|
611
|
-
function getResponsiveBase(value) {
|
|
612
|
-
if (!value) return void 0;
|
|
613
|
-
if (isResponsiveConfig(value)) {
|
|
614
|
-
return value.base;
|
|
615
|
-
}
|
|
616
|
-
return value;
|
|
617
|
-
}
|
|
618
|
-
function borderToStyle(border) {
|
|
619
|
-
if (!border) return "";
|
|
620
|
-
const borderValue = getResponsiveBase(border);
|
|
621
|
-
if (!borderValue) return "";
|
|
622
|
-
const width = borderValue.width || "1px";
|
|
623
|
-
const style = borderValue.style || "solid";
|
|
624
|
-
const color = borderValue.color || "currentColor";
|
|
625
|
-
return `${width} ${style} ${color}`;
|
|
626
|
-
}
|
|
627
|
-
function formatShadow(shadow) {
|
|
628
|
-
if (!shadow) return "";
|
|
629
|
-
const { offsetX, offsetY, blurRadius, spreadRadius, color } = shadow;
|
|
630
|
-
return `${offsetX} ${offsetY} ${blurRadius} ${spreadRadius} ${color}`;
|
|
631
|
-
}
|
|
632
|
-
function paddingToClass(padding) {
|
|
633
|
-
if (!padding) return "";
|
|
634
|
-
const paddingMap = {
|
|
635
|
-
none: "p-0",
|
|
636
|
-
sm: "p-4",
|
|
637
|
-
normal: "p-8",
|
|
638
|
-
lg: "p-12",
|
|
639
|
-
xl: "p-16"
|
|
640
|
-
};
|
|
641
|
-
return paddingMap[padding] || paddingMap["normal"];
|
|
642
|
-
}
|
|
643
|
-
function paddingTopToClass(paddingTop) {
|
|
644
|
-
if (!paddingTop) return "";
|
|
645
|
-
const paddingMap = {
|
|
646
|
-
none: "pt-0",
|
|
647
|
-
sm: "pt-4",
|
|
648
|
-
normal: "pt-8",
|
|
649
|
-
lg: "pt-12",
|
|
650
|
-
xl: "pt-16"
|
|
651
|
-
};
|
|
652
|
-
return paddingMap[paddingTop] || paddingMap["normal"];
|
|
653
|
-
}
|
|
654
|
-
function paddingBottomToClass(paddingBottom) {
|
|
655
|
-
if (!paddingBottom) return "";
|
|
656
|
-
const paddingMap = {
|
|
657
|
-
none: "pb-0",
|
|
658
|
-
sm: "pb-4",
|
|
659
|
-
normal: "pb-8",
|
|
660
|
-
lg: "pb-12",
|
|
661
|
-
xl: "pb-16"
|
|
662
|
-
};
|
|
663
|
-
return paddingMap[paddingBottom] || paddingMap["normal"];
|
|
664
|
-
}
|
|
665
|
-
function spacingToClass(spacing) {
|
|
666
|
-
if (!spacing) return "";
|
|
667
|
-
const spacingMap = {
|
|
668
|
-
tight: "space-y-2",
|
|
669
|
-
normal: "space-y-4",
|
|
670
|
-
relaxed: "space-y-6",
|
|
671
|
-
loose: "space-y-8"
|
|
672
|
-
};
|
|
673
|
-
return spacingMap[spacing] || spacingMap["normal"];
|
|
674
|
-
}
|
|
675
|
-
function widthToClass(width) {
|
|
676
|
-
if (!width) return "";
|
|
677
|
-
const widthMap = {
|
|
678
|
-
full: "w-full",
|
|
679
|
-
container: "max-w-7xl mx-auto",
|
|
680
|
-
wide: "max-w-6xl mx-auto",
|
|
681
|
-
prose: "max-w-4xl mx-auto",
|
|
682
|
-
narrow: "max-w-2xl mx-auto"
|
|
683
|
-
};
|
|
684
|
-
return widthMap[width] || widthMap["container"];
|
|
685
|
-
}
|
|
686
|
-
function colorToStyle(color) {
|
|
687
|
-
if (!color) return {};
|
|
688
|
-
return {
|
|
689
|
-
backgroundColor: color
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
function gapToClass(gap) {
|
|
693
|
-
if (gap === void 0 || gap === null) return "";
|
|
694
|
-
if (gap === 0) return "gap-0";
|
|
695
|
-
if (gap <= 4) return "gap-1";
|
|
696
|
-
if (gap <= 8) return "gap-2";
|
|
697
|
-
if (gap <= 12) return "gap-3";
|
|
698
|
-
if (gap <= 16) return "gap-4";
|
|
699
|
-
if (gap <= 24) return "gap-6";
|
|
700
|
-
if (gap <= 32) return "gap-8";
|
|
701
|
-
if (gap <= 48) return "gap-12";
|
|
702
|
-
return "gap-16";
|
|
703
|
-
}
|
|
704
172
|
|
|
705
173
|
// src/password-resolver.utils.ts
|
|
706
174
|
function isPasswordProtected(password_protected) {
|
|
707
175
|
return password_protected === true;
|
|
708
176
|
}
|
|
709
|
-
function filterPasswordProtectedContent(items) {
|
|
710
|
-
return items.filter((item) => !isPasswordProtected(item.password_protected));
|
|
711
|
-
}
|
|
712
177
|
|
|
713
178
|
// src/json-ld.utils.ts
|
|
714
179
|
function buildBreadcrumbs(path, pageTitle) {
|
|
@@ -894,48 +359,6 @@ function hasOrganizationData(org) {
|
|
|
894
359
|
}
|
|
895
360
|
|
|
896
361
|
// src/seo.utils.ts
|
|
897
|
-
function deriveSiteUrl(configs, siteUrlOverride) {
|
|
898
|
-
let url = "";
|
|
899
|
-
if (siteUrlOverride) {
|
|
900
|
-
url = siteUrlOverride;
|
|
901
|
-
} else {
|
|
902
|
-
const site = configs.site;
|
|
903
|
-
const customDomains = site?.custom_domains;
|
|
904
|
-
if (customDomains?.[0]) {
|
|
905
|
-
url = `https://${customDomains[0]}`;
|
|
906
|
-
} else {
|
|
907
|
-
const subdomain = site?.subdomain;
|
|
908
|
-
if (subdomain) url = `https://${subdomain}.otl.studio`;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
return url.replace(/\/+$/, "");
|
|
912
|
-
}
|
|
913
|
-
function deriveSiteName(configs, locale) {
|
|
914
|
-
const website = configs.website;
|
|
915
|
-
if (!website?.site_name) return "Website";
|
|
916
|
-
if (typeof website.site_name === "string") return website.site_name;
|
|
917
|
-
const names = website.site_name;
|
|
918
|
-
return names[locale] || names.en || "Website";
|
|
919
|
-
}
|
|
920
|
-
function deriveSiteDescription(configs, locale) {
|
|
921
|
-
const website = configs.website;
|
|
922
|
-
if (!website?.description) return void 0;
|
|
923
|
-
if (typeof website.description === "string") return website.description;
|
|
924
|
-
const descs = website.description;
|
|
925
|
-
return descs[locale] || void 0;
|
|
926
|
-
}
|
|
927
|
-
function detectLocaleFromSegments(segments, fullPath, supportedLocales, defaultLocale) {
|
|
928
|
-
const normalizedLocales = supportedLocales.map((l) => l.toLowerCase());
|
|
929
|
-
const firstSegment = segments[0];
|
|
930
|
-
const localeIndex = normalizedLocales.indexOf(firstSegment?.toLowerCase());
|
|
931
|
-
if (localeIndex !== -1) {
|
|
932
|
-
return [
|
|
933
|
-
supportedLocales[localeIndex],
|
|
934
|
-
"/" + segments.slice(1).join("/") || "/"
|
|
935
|
-
];
|
|
936
|
-
}
|
|
937
|
-
return [defaultLocale, fullPath];
|
|
938
|
-
}
|
|
939
362
|
function localeToOgFormat(locale) {
|
|
940
363
|
if (locale.includes("_")) return locale;
|
|
941
364
|
const map = {
|
|
@@ -1012,79 +435,19 @@ function findPaginationInBlocks(blocks) {
|
|
|
1012
435
|
return null;
|
|
1013
436
|
}
|
|
1014
437
|
|
|
1015
|
-
// src/vocabulary.utils.ts
|
|
1016
|
-
function resolveVocabularyTerm(term, locale, defaultLocale) {
|
|
1017
|
-
if (typeof term === "string") return term;
|
|
1018
|
-
if (term[locale]) return term[locale];
|
|
1019
|
-
if (defaultLocale && defaultLocale !== locale && term[defaultLocale]) {
|
|
1020
|
-
return term[defaultLocale];
|
|
1021
|
-
}
|
|
1022
|
-
return term[Object.keys(term)[0]] ?? "";
|
|
1023
|
-
}
|
|
1024
|
-
function vocabularySlug(term, locale, defaultLocale) {
|
|
1025
|
-
return resolveVocabularyTerm(term, locale, defaultLocale).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
1026
|
-
}
|
|
1027
|
-
function missingVocabularyLocales(term, requiredLocales) {
|
|
1028
|
-
if (typeof term === "string") return [];
|
|
1029
|
-
return requiredLocales.filter((loc) => !term[loc] || term[loc].trim() === "");
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
exports.borderToStyle = borderToStyle;
|
|
1033
438
|
exports.buildBreadcrumbs = buildBreadcrumbs;
|
|
1034
|
-
exports.buildCategoryTree = buildCategoryTree;
|
|
1035
439
|
exports.buildHreflangAlternates = buildHreflangAlternates;
|
|
1036
|
-
exports.cn = cn;
|
|
1037
|
-
exports.colorToStyle = colorToStyle;
|
|
1038
|
-
exports.deriveSiteDescription = deriveSiteDescription;
|
|
1039
|
-
exports.deriveSiteName = deriveSiteName;
|
|
1040
|
-
exports.deriveSiteUrl = deriveSiteUrl;
|
|
1041
|
-
exports.detectLocale = detectLocale;
|
|
1042
|
-
exports.detectLocaleFromSegments = detectLocaleFromSegments;
|
|
1043
440
|
exports.extractPaginationFromLayout = extractPaginationFromLayout;
|
|
1044
|
-
exports.filterPasswordProtectedContent = filterPasswordProtectedContent;
|
|
1045
|
-
exports.filterScheduledContent = filterScheduledContent;
|
|
1046
|
-
exports.findCategoryBySlug = findCategoryBySlug;
|
|
1047
|
-
exports.flattenCategoryTree = flattenCategoryTree;
|
|
1048
|
-
exports.formatLocaleForHtml = formatLocaleForHtml;
|
|
1049
|
-
exports.formatShadow = formatShadow;
|
|
1050
|
-
exports.fromResponsiveConfig = fromResponsiveConfig;
|
|
1051
|
-
exports.gapToClass = gapToClass;
|
|
1052
441
|
exports.generateJsonLd = generateJsonLd;
|
|
1053
|
-
exports.generateResponsiveSpacingCSS = generateResponsiveSpacingCSS;
|
|
1054
|
-
exports.getAnimationTimingFunction = getAnimationTimingFunction;
|
|
1055
|
-
exports.getAvailableLocales = getAvailableLocales;
|
|
1056
442
|
exports.getBreakpointValue = getBreakpointValue;
|
|
1057
|
-
exports.getCategoryName = getCategoryName;
|
|
1058
|
-
exports.getCategoryPath = getCategoryPath;
|
|
1059
|
-
exports.getCategorySlug = getCategorySlug;
|
|
1060
|
-
exports.getDefinedBreakpoints = getDefinedBreakpoints;
|
|
1061
|
-
exports.getDescendants = getDescendants;
|
|
1062
443
|
exports.getLocalizedString = getLocalizedString;
|
|
1063
|
-
exports.hasAnyMargin = hasAnyMargin;
|
|
1064
|
-
exports.isAncestor = isAncestor;
|
|
1065
444
|
exports.isContentVisible = isContentVisible;
|
|
1066
|
-
exports.isLocalizedString = isLocalizedString;
|
|
1067
445
|
exports.isMultivariateContent = isMultivariateContent;
|
|
1068
446
|
exports.isPasswordProtected = isPasswordProtected;
|
|
1069
447
|
exports.isResponsiveConfig = isResponsiveConfig;
|
|
1070
448
|
exports.localeToOgFormat = localeToOgFormat;
|
|
1071
|
-
exports.minifyCSS = minifyCSS;
|
|
1072
|
-
exports.missingVocabularyLocales = missingVocabularyLocales;
|
|
1073
|
-
exports.normalizeResponsiveValue = normalizeResponsiveValue;
|
|
1074
|
-
exports.paddingBottomToClass = paddingBottomToClass;
|
|
1075
|
-
exports.paddingToClass = paddingToClass;
|
|
1076
|
-
exports.paddingTopToClass = paddingTopToClass;
|
|
1077
|
-
exports.resolveBorderToCSS = resolveBorderToCSS;
|
|
1078
|
-
exports.resolveColorToCSS = resolveColorToCSS;
|
|
1079
|
-
exports.resolveColorsToCSS = resolveColorsToCSS;
|
|
1080
449
|
exports.resolveEntryVariant = resolveEntryVariant;
|
|
1081
450
|
exports.resolveFormVariantsInSections = resolveFormVariantsInSections;
|
|
1082
451
|
exports.resolvePageVariant = resolvePageVariant;
|
|
1083
|
-
exports.resolveVocabularyTerm = resolveVocabularyTerm;
|
|
1084
|
-
exports.selectVariant = selectVariant;
|
|
1085
|
-
exports.spacingToClass = spacingToClass;
|
|
1086
|
-
exports.toResponsiveConfig = toResponsiveConfig;
|
|
1087
|
-
exports.vocabularySlug = vocabularySlug;
|
|
1088
|
-
exports.widthToClass = widthToClass;
|
|
1089
452
|
//# sourceMappingURL=index.cjs.map
|
|
1090
453
|
//# sourceMappingURL=index.cjs.map
|