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