@ecomcx/ecomweb-theme-sdk 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/API.md CHANGED
@@ -1068,7 +1068,7 @@ interface ListPage<T> { items: T[]; total: number; page: number; totalPages: num
1068
1068
  #### `Media`
1069
1069
 
1070
1070
  ```ts
1071
- interface Media { id: number; url: string; fileName: string; mimeType: string; size: number; width?: number | null; height?: number | null; alt: string; caption: string; sizes: Record<string, MediaSize>; /** Bản WebP của ảnh gốc. */ webpUrl?: string | null; /** Điểm lấy nét 0–1 (object-position). */ focalX?: number | null; focalY?: number | null; title?: string; createdAt?: string; }
1071
+ interface Media { id: number; url: string; fileName: string; mimeType: string; size: number; width?: number | null; height?: number | null; alt: string; caption: string; sizes: Record<string, MediaSize>; /** Bản WebP của ảnh gốc. */ webpUrl?: string | null; /** Video: ảnh poster (CMS ≥ 1.37). */ posterUrl?: string | null; /** Video: thời lượng (giây). */ duration?: number | null; /** Điểm lấy nét 0–1 (object-position). */ focalX?: number | null; focalY?: number | null; title?: string; createdAt?: string; }
1072
1072
  ```
1073
1073
 
1074
1074
  #### `MediaQuery`
@@ -1407,6 +1407,14 @@ Phóng to ảnh: bấm ảnh mở lớp phủ (Esc hoặc bấm nền để đó
1407
1407
  LightboxClient({ src, alt, children }: { src: string; alt: string; children: ReactNode; }): JSX.Element
1408
1408
  ```
1409
1409
 
1410
+ #### `LottieClient`
1411
+
1412
+ Hoạt ảnh Lottie: poster (ảnh tĩnh) hiện sẵn từ máy chủ; thư viện chỉ nạp khi khối gần vào màn hình; chạy theo `trigger` (auto / hover / click / scroll). Tôn trọng "giảm chuyển động" (không tự chạy). Mọi lỗi → giữ poster, trang không hỏng.
1413
+
1414
+ ```ts
1415
+ LottieClient({ src, poster, label, loop, autoplay, speed, trigger, className, style }: { src: string; poster?: string; label?: string; loop: boolean; autoplay: boolean; speed: number; trigger: "auto" | "hover" | "click" | "scroll"; className: string; style?: CSSProperties; }): JSX.Element
1416
+ ```
1417
+
1410
1418
  #### `NavDrawer`
1411
1419
 
1412
1420
  Menu di động của khối Menu: nút burger mở ngăn trượt từ trái (nền mờ, nút đóng, khoá cuộn trang, Esc / bấm nền / bấm liên kết để đóng, trả focus về nút). Menu con hiện thụt vào ngay dưới mục cha. Khác NavToggle (giữ nguyên cho theme cũ dùng <details>).
@@ -1513,6 +1521,14 @@ Khách đã cho phép nhóm cookie này chưa (gọi trong useEffect / handler
1513
1521
  hasConsent(category: ConsentCategory): boolean
1514
1522
  ```
1515
1523
 
1524
+ #### `loadDotLottie`
1525
+
1526
+ Nạp thư viện một lần cho cả trang, từ cùng nguồn (CSP 'self') chứ không gộp vào gói của website — nên gỡ thư viện đi thì website vẫn build và chạy bình thường. Lỗi ở bất kỳ bước nào (404, wasm bị chặn, trình duyệt cũ) → null.
1527
+
1528
+ ```ts
1529
+ loadDotLottie(base?: string): Promise<DotLottieModule | null>
1530
+ ```
1531
+
1516
1532
  #### `on`
1517
1533
 
1518
1534
  Nghe sự kiện; trả hàm huỷ. Nhận cả sự kiện từ tab khác nếu bên phát dùng crossTab.
@@ -1589,6 +1605,14 @@ Client phía trình duyệt: gọi các route proxy /api/cms/* của frontend.
1589
1605
  const browserApi: FetchKitInstance
1590
1606
  ```
1591
1607
 
1608
+ #### `LOTTIE_BASE`
1609
+
1610
+ Nơi website phục vụ thư viện (route /ecx-lottie của core); không có thư viện → 404 → khối chỉ hiện poster.
1611
+
1612
+ ```ts
1613
+ const LOTTIE_BASE: "/ecx-lottie"
1614
+ ```
1615
+
1592
1616
  ### Kiểu
1593
1617
 
1594
1618
  #### `BlockReadyFn`
package/dist/client.d.ts CHANGED
@@ -326,3 +326,37 @@ export declare function GalleryThumbsClient({ mains, thumbs, label }: {
326
326
  thumbs: ReactNode[];
327
327
  label?: string;
328
328
  }): import("react").JSX.Element;
329
+ /** Nơi website phục vụ thư viện (route /ecx-lottie của core); không có thư viện → 404 → khối chỉ hiện poster. */
330
+ export declare const LOTTIE_BASE = "/ecx-lottie";
331
+ type DotLottieCtor = new (cfg: Record<string, unknown>) => {
332
+ play(): void;
333
+ pause(): void;
334
+ destroy(): void;
335
+ addEventListener(ev: string, fn: () => void): void;
336
+ isPlaying?: boolean;
337
+ };
338
+ type DotLottieModule = {
339
+ DotLottie: DotLottieCtor & {
340
+ setWasmUrl?(url: string): void;
341
+ };
342
+ };
343
+ /**
344
+ * Nạp thư viện một lần cho cả trang, từ cùng nguồn (CSP 'self') chứ không gộp vào gói của website — nên gỡ thư viện đi thì
345
+ * website vẫn build và chạy bình thường. Lỗi ở bất kỳ bước nào (404, wasm bị chặn, trình duyệt cũ) → null.
346
+ */
347
+ export declare function loadDotLottie(base?: string): Promise<DotLottieModule | null>;
348
+ /**
349
+ * Hoạt ảnh Lottie: poster (ảnh tĩnh) hiện sẵn từ máy chủ; thư viện chỉ nạp khi khối gần vào màn hình; chạy theo `trigger`
350
+ * (auto / hover / click / scroll). Tôn trọng "giảm chuyển động" (không tự chạy). Mọi lỗi → giữ poster, trang không hỏng.
351
+ */
352
+ export declare function LottieClient({ src, poster, label, loop, autoplay, speed, trigger, className, style }: {
353
+ src: string;
354
+ poster?: string;
355
+ label?: string;
356
+ loop: boolean;
357
+ autoplay: boolean;
358
+ speed: number;
359
+ trigger: "auto" | "hover" | "click" | "scroll";
360
+ className: string;
361
+ style?: CSSProperties;
362
+ }): import("react").JSX.Element;
package/dist/client.js CHANGED
@@ -808,3 +808,93 @@ export function GalleryThumbsClient({ mains, thumbs, label }) {
808
808
  go(mains.length - 1);
809
809
  } }, children: thumbs.map((t, i) => _jsx("button", { type: "button", role: "tab", className: "ecx-gt-thumb", "aria-selected": i === active, tabIndex: i === active ? 0 : -1, "aria-label": `${i + 1} / ${thumbs.length}`, onClick: () => setActive(i), children: t }, i)) })] }));
810
810
  }
811
+ // ---------------------------------------------------------------------------
812
+ // Lottie (khối "lottie", content ≥ 1.29): thư viện @lottiefiles/dotlottie-web là TUỲ CHỌN
813
+ // ---------------------------------------------------------------------------
814
+ /** Nơi website phục vụ thư viện (route /ecx-lottie của core); không có thư viện → 404 → khối chỉ hiện poster. */
815
+ export const LOTTIE_BASE = "/ecx-lottie";
816
+ /**
817
+ * Nạp thư viện một lần cho cả trang, từ cùng nguồn (CSP 'self') chứ không gộp vào gói của website — nên gỡ thư viện đi thì
818
+ * website vẫn build và chạy bình thường. Lỗi ở bất kỳ bước nào (404, wasm bị chặn, trình duyệt cũ) → null.
819
+ */
820
+ export function loadDotLottie(base = LOTTIE_BASE) {
821
+ const g = globalThis;
822
+ g.__ecxLottie ??= (async () => {
823
+ try {
824
+ const mod = (await import(/* webpackIgnore: true */ /* turbopackIgnore: true */ /* @vite-ignore */ `${base}/index.js`));
825
+ mod.DotLottie.setWasmUrl?.(`${base}/player.wasm`);
826
+ return mod;
827
+ }
828
+ catch {
829
+ return null;
830
+ }
831
+ })();
832
+ return g.__ecxLottie;
833
+ }
834
+ /**
835
+ * Hoạt ảnh Lottie: poster (ảnh tĩnh) hiện sẵn từ máy chủ; thư viện chỉ nạp khi khối gần vào màn hình; chạy theo `trigger`
836
+ * (auto / hover / click / scroll). Tôn trọng "giảm chuyển động" (không tự chạy). Mọi lỗi → giữ poster, trang không hỏng.
837
+ */
838
+ export function LottieClient({ src, poster, label, loop, autoplay, speed, trigger, className, style }) {
839
+ const box = useRef(null);
840
+ const canvas = useRef(null);
841
+ const [ready, setReady] = useState(false);
842
+ useEffect(() => {
843
+ const el = box.current, cv = canvas.current;
844
+ if (!src || !el || !cv)
845
+ return;
846
+ let dead = false;
847
+ let player;
848
+ const reduce = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
849
+ const visible = { now: false };
850
+ const io = typeof IntersectionObserver === "function" ? new IntersectionObserver(([e]) => {
851
+ visible.now = e.isIntersecting;
852
+ if (e.isIntersecting && !player)
853
+ void start();
854
+ if (player) {
855
+ if (e.isIntersecting && (trigger === "scroll" || (trigger === "auto" && autoplay && !reduce)))
856
+ player.play();
857
+ else if (!e.isIntersecting)
858
+ player.pause();
859
+ }
860
+ }, { rootMargin: "200px" }) : null;
861
+ async function start() {
862
+ const mod = await loadDotLottie();
863
+ if (dead || !mod || player)
864
+ return;
865
+ try {
866
+ const p = new mod.DotLottie({ canvas: cv, src, loop, speed, autoplay: !reduce && visible.now && (trigger === "scroll" || (trigger === "auto" && autoplay)) });
867
+ player = p;
868
+ p.addEventListener("load", () => { if (!dead)
869
+ setReady(true); });
870
+ p.addEventListener("loadError", () => { if (!dead)
871
+ setReady(false); });
872
+ }
873
+ catch { /* giữ poster */ }
874
+ }
875
+ if (io)
876
+ io.observe(el);
877
+ else
878
+ void start();
879
+ const on = () => player?.play(), off = () => player?.pause();
880
+ const toggle = () => (player?.isPlaying ? player.pause() : player?.play());
881
+ if (trigger === "hover") {
882
+ el.addEventListener("mouseenter", on);
883
+ el.addEventListener("mouseleave", off);
884
+ }
885
+ if (trigger === "click")
886
+ el.addEventListener("click", toggle);
887
+ return () => {
888
+ dead = true;
889
+ io?.disconnect();
890
+ el.removeEventListener("mouseenter", on);
891
+ el.removeEventListener("mouseleave", off);
892
+ el.removeEventListener("click", toggle);
893
+ try {
894
+ player?.destroy();
895
+ }
896
+ catch { /* bỏ qua */ }
897
+ };
898
+ }, [src, loop, autoplay, speed, trigger]);
899
+ return (_jsxs("div", { ref: box, className: cx(className, ready && "is-ready"), style: style, "data-trigger": trigger, role: "img", "aria-label": label || undefined, "aria-hidden": label ? undefined : true, children: [poster && _jsx("img", { className: "ecx-lottie-poster", src: poster, alt: "", loading: "lazy", decoding: "async" }), _jsx("canvas", { ref: canvas, className: "ecx-lottie-canvas" })] }));
900
+ }
package/dist/dynamic.js CHANGED
@@ -9,7 +9,7 @@ import { applyFilters } from "./runtime.js";
9
9
  import { localeHref } from "./locale.js";
10
10
  import { renderContent } from "./rich.js";
11
11
  import { cx } from "./utils.js";
12
- import { applyPatternOverrides, spacingValue } from "@ecomcx/ecomweb-content";
12
+ import { applyPatternOverrides, clipExcerpt, spacingValue } from "@ecomcx/ecomweb-content";
13
13
  const align = (a) => (a.textAlign && a.textAlign !== "left" ? { textAlign: a.textAlign } : undefined);
14
14
  const ASPECT = { "16/9": "16 / 9", "4/3": "4 / 3", "1/1": "1 / 1", "3/4": "3 / 4" };
15
15
  /**
@@ -64,7 +64,7 @@ export async function renderDynamic(node, key, ctx, children) {
64
64
  case "postExcerpt":
65
65
  if (!post?.excerpt)
66
66
  return null;
67
- return _jsxs("p", { className: "ecx-post-excerpt", children: [post.excerpt, a.moreText && _jsxs(_Fragment, { children: [" ", _jsx(Link, { href: post.link, className: "ecx-more-link", children: a.moreText })] })] }, key);
67
+ return _jsxs("p", { className: "ecx-post-excerpt", children: [clipExcerpt(post.excerpt, a.length), a.moreText && _jsxs(_Fragment, { children: [" ", _jsx(Link, { href: post.link, className: "ecx-more-link", children: a.moreText })] })] }, key);
68
68
  case "featuredImage": {
69
69
  if (!post?.featuredMedia)
70
70
  return null;
package/dist/image.js CHANGED
@@ -26,12 +26,12 @@ export function Img({ media, size = "large", sizes, className, alt, priority, st
26
26
  const list = imageCandidates(media, size);
27
27
  const main = list[list.length - 1] ?? { url: media.url, width: media.width ?? 0, height: media.height ?? 0 };
28
28
  const srcSet = list.map((s) => `${s.url} ${s.width}w`).join(", ");
29
- const webp = list.every((s) => s.webpUrl) ? list.map((s) => `${s.webpUrl} ${s.width}w`).join(", ") : null;
29
+ const webp = media.mimeType !== "image/webp" && list.every((s) => s.webpUrl) ? list.map((s) => `${s.webpUrl} ${s.width}w`).join(", ") : null;
30
30
  const sz = sizes ?? (main.width ? `(max-width: ${main.width}px) 100vw, ${main.width}px` : undefined);
31
31
  const focal = media.focalX != null && media.focalY != null
32
32
  ? { objectPosition: `${Math.round(media.focalX * 100)}% ${Math.round(media.focalY * 100)}%` } : undefined;
33
33
  const img = (_jsx("img", { src: main.url, srcSet: list.length > 1 ? srcSet : undefined, sizes: list.length > 1 ? sz : undefined, width: main.width || undefined, height: main.height || undefined, alt: alt ?? media.alt ?? "", loading: priority ? "eager" : "lazy", decoding: "async", fetchPriority: priority ? "high" : undefined, className: className, style: { ...focal, ...style } }));
34
- if (!webp || media.mimeType === "image/webp")
34
+ if (!webp)
35
35
  return img;
36
36
  return _jsxs("picture", { className: cx("cms-picture"), children: [_jsx("source", { type: "image/webp", srcSet: webp, sizes: sz }), img] });
37
37
  }
package/dist/rich.js CHANGED
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { Fragment, cloneElement, createElement, isValidElement } from "react";
3
3
  import { ICON_LIBRARY } from "@ecomcx/ecomweb-content/icon-library";
4
4
  import { iconSvg } from "./icon-svg.js";
5
- import { BINDING_URL_ATTRS, CORE_BINDABLE, registerIconLibrary, tableClass, blockBgVideo, typedConfig, coverVideo, scheduleVisible, normalizeStyle, imageFx, countdownRules, testimonialsConfig, testimonialsVars, popupClass, popupConfig, popupPlayStyle, popupVars, carouselConfig, DYNAMIC_NODES, countdownTarget, nodeText, buttonIcon, widgetMarkup, tabsClass, formSizeClass, widthClass, blockCitation, blockShell, buttonWrapShell, coverParts, linkRel, embedInfo, motionClasses, normalizeContent, safeUrl, styleClass, styleCss, controlsCss, CORE_CONTROLS } from "@ecomcx/ecomweb-content";
5
+ import { sizedImage, lottieConfig, BINDING_URL_ATTRS, CORE_BINDABLE, registerIconLibrary, tableClass, blockBgVideo, typedConfig, coverVideo, scheduleVisible, normalizeStyle, imageFx, countdownRules, testimonialsConfig, testimonialsVars, popupClass, popupConfig, popupPlayStyle, popupVars, carouselConfig, DYNAMIC_NODES, countdownTarget, nodeText, buttonIcon, widgetMarkup, tabsClass, formSizeClass, widthClass, blockCitation, blockShell, buttonWrapShell, coverParts, linkRel, embedInfo, motionClasses, normalizeContent, safeUrl, styleClass, styleCss, controlsCss, CORE_CONTROLS } from "@ecomcx/ecomweb-content";
6
6
  import { cx } from "./utils.js";
7
7
  import { SOCIAL_ICONS } from "./social-icons.js";
8
- import { GalleryThumbsClient, AudienceGate, TypedText, BgVideo, PopupClient, CarouselClient, CountdownClient, FormBlockClient, LightboxClient, Link, TabsClient, TocSpy } from "./client.js";
8
+ import { GalleryThumbsClient, AudienceGate, TypedText, BgVideo, PopupClient, LottieClient, CarouselClient, CountdownClient, FormBlockClient, LightboxClient, Link, TabsClient, TocSpy } from "./client.js";
9
9
  import { CounterClient } from "./counter-client.js";
10
10
  import { AssetScript } from "./browser.js";
11
11
  import { getT } from "./i18n.js";
@@ -283,6 +283,8 @@ async function renderNode(node, key, ctx) {
283
283
  }
284
284
  const emptyAttr = (v) => v === undefined || v === null || v === "" || (Array.isArray(v) && !v.length);
285
285
  /** Nút không chọn riêng được trong khung soạn (hoặc bọc thêm thẻ sẽ sai cấu trúc HTML: li trong ul, ô trong bảng). */
286
+ /** Độ rộng cột đã kéo trong trình soạn (attrs.colwidth = [px]). */
287
+ const cellWidth = (a) => (Array.isArray(a.colwidth) && Number(a.colwidth[0]) > 0 ? { width: Number(a.colwidth[0]), minWidth: Number(a.colwidth[0]) } : undefined);
286
288
  const UNMARKED = new Set(["text", "hardBreak", "listItem", "tableRow", "tableCell", "tableHeader"]);
287
289
  /** Gắn vị trí khối: thẻ HTML thì thêm thuộc tính, component thì bọc thẻ display:contents (không đổi bố cục). */
288
290
  function markBlock(el, source, path, key) {
@@ -329,6 +331,24 @@ async function renderNodeInner(node, key, ctx) {
329
331
  case "blockquote": return shelled("blockquote", a, key, _jsxs(_Fragment, { children: [await children(), blockCitation(a) && _jsx("cite", { children: blockCitation(a) })] }));
330
332
  case "codeBlock": return _jsx("pre", { children: _jsx("code", { className: a.language ? `language-${a.language}` : undefined, children: plainText(node) }) }, key);
331
333
  case "hardBreak": return _jsx("br", {}, key);
334
+ case "inlineImage": {
335
+ // Ảnh trong dòng chữ: src qua safeUrl; width / height / radius đã được lược đồ chặn dạng lạ; có liên kết thì bọc <a>
336
+ const src = safeUrl(a.src, "");
337
+ if (!src)
338
+ return null;
339
+ const style = {};
340
+ if (typeof a.width === "string")
341
+ style.width = a.width;
342
+ if (typeof a.height === "string")
343
+ style.height = a.height;
344
+ if (typeof a.radius === "string")
345
+ style.borderRadius = a.radius;
346
+ if (typeof a.valign === "string" && a.valign !== "middle")
347
+ style.verticalAlign = a.valign;
348
+ const img = _jsx("img", { className: "ecx-inline-image", src: src, alt: typeof a.alt === "string" ? a.alt : "", loading: "lazy", decoding: "async", style: Object.keys(style).length ? style : undefined });
349
+ const href = safeUrl(a.href, "");
350
+ return href ? _jsx("a", { href: href, target: a.target === "_blank" ? "_blank" : undefined, rel: a.target === "_blank" ? "noopener noreferrer" : undefined, children: img }, key) : _jsx("span", { className: "ecx-inline-image-wrap", children: img }, key);
351
+ }
332
352
  case "icon": {
333
353
  const size = Math.min(128, Math.max(12, Number(a.size) || 24));
334
354
  const stroke = Math.min(4, Math.max(0.5, Number(a.stroke) || 2));
@@ -346,12 +366,14 @@ async function renderNodeInner(node, key, ctx) {
346
366
  case "image": {
347
367
  // Ảnh chèn từ thư viện mang sẵn srcset (JPEG + WebP) và kích thước → responsive, không nhảy layout
348
368
  // Bề rộng hiển thị = cỡ người viết kéo trong trình soạn → trình duyệt chọn file vừa đúng
349
- const sizes = a.width ? `(max-width: ${a.width}px) 100vw, ${a.width}px` : (a.sizes || "(max-width: 1024px) 100vw, 1024px");
350
- const imgSrc = safeUrl(a.src, "");
369
+ // Cỡ Nhỏ / Vừa (thumbnail / medium): dùng bản thu nhỏ và hiện đúng cỡ đó — chỉ khi người viết chưa kéo tay bề rộng
370
+ const sz = sizedImage(a);
371
+ const sizes = sz ? `${sz.width}px` : a.width ? `(max-width: ${a.width}px) 100vw, ${a.width}px` : (a.sizes || "(max-width: 1024px) 100vw, 1024px");
372
+ const imgSrc = safeUrl(sz?.src ?? a.src, "");
351
373
  if (!imgSrc)
352
374
  return null; // chưa chọn ảnh: không in <img> không có địa chỉ (hiện icon ảnh hỏng)
353
375
  const fx = imageFx(a);
354
- const img = _jsx("img", { src: imgSrc, srcSet: a.srcset || undefined, sizes: a.srcset ? sizes : undefined, alt: a.alt ?? "", title: a.title ?? undefined, width: a.width ?? undefined, height: a.height ?? undefined, loading: "lazy", decoding: "async", className: fx.className || undefined, style: fx.style });
376
+ const img = _jsx("img", { src: imgSrc, srcSet: a.srcset || undefined, sizes: a.srcset ? sizes : undefined, alt: a.alt ?? "", title: a.title ?? undefined, width: sz?.width ?? a.width ?? undefined, height: sz?.height ?? a.height ?? undefined, loading: "lazy", decoding: "async", className: fx.className || undefined, style: fx.style });
355
377
  const bare = a.webpSrcset ? _jsxs("picture", { children: [_jsx("source", { type: "image/webp", srcSet: a.webpSrcset, sizes: sizes }), img] }) : img;
356
378
  // next: ảnh có liên kết (href qua safeUrl; mở tab mới thì noopener)
357
379
  const pic = a.lightbox === true && !a.href ? _jsx(LightboxClient, { src: safeUrl(a.src, ""), alt: a.alt ?? "", children: bare }) : a.href ? _jsx(Link, { href: safeUrl(a.href), target: a.linkTarget === "_blank" ? "_blank" : undefined, rel: a.linkTarget === "_blank" ? "noopener noreferrer" : undefined, children: bare }) : bare;
@@ -379,8 +401,13 @@ async function renderNodeInner(node, key, ctx) {
379
401
  }
380
402
  return _jsxs("figure", { className: blockShell("gallery", a).className, style: blockShell("gallery", a).style, children: [items.map((im, i) => galleryItem(im, i)), caption] }, key);
381
403
  }
382
- case "video":
383
- return _jsxs("figure", { className: "ecx-video cms-video", children: [_jsx("video", { src: safeUrl(a.src, ""), poster: a.poster ? safeUrl(a.poster, "") : undefined, controls: a.controls !== false, autoPlay: a.autoplay === true, loop: a.loop === true, muted: a.muted === true || a.autoplay === true, preload: ["none", "metadata", "auto"].includes(a.preload) ? a.preload : "metadata", playsInline: a.playsInline !== false, style: { width: "100%", height: "auto" } }), a.caption && _jsx("figcaption", { children: a.caption })] }, key);
404
+ case "video": {
405
+ // Link YouTube / Vimeo… dán vào khối Video → khung nhúng (thẻ <video> không phát được trang web)
406
+ const embed = embedInfo(a.src);
407
+ if (embed)
408
+ return _jsxs("figure", { className: "ecx-video cms-video", children: [_jsx("div", { style: embed.aspect ? { position: "relative", aspectRatio: String(embed.aspect) } : { position: "relative", height: embed.height }, children: _jsx("iframe", { src: embed.src, title: a.caption || embed.title, loading: "lazy", allowFullScreen: true, referrerPolicy: "strict-origin-when-cross-origin", allow: "autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture", style: { position: "absolute", inset: 0, width: "100%", height: "100%", border: 0, borderRadius: 8 } }) }), a.caption && _jsx("figcaption", { children: a.caption })] }, key);
409
+ return _jsxs("figure", { className: "ecx-video cms-video", children: [_jsx("video", { src: safeUrl(a.src, ""), poster: a.poster ? safeUrl(a.poster, "") : undefined, controls: a.controls !== false, autoPlay: a.autoplay === true, loop: a.loop === true, muted: a.muted === true || a.autoplay === true, preload: ["none", "metadata", "auto"].includes(a.preload) ? a.preload : "metadata", playsInline: a.playsInline !== false, width: Number(a.width) || undefined, height: Number(a.height) || undefined, style: { width: "100%", height: "auto" } }), a.caption && _jsx("figcaption", { children: a.caption })] }, key);
410
+ }
384
411
  case "audio":
385
412
  return _jsxs("figure", { className: "ecx-audio cms-audio", children: [_jsx("audio", { src: safeUrl(a.src, ""), controls: true, autoPlay: a.autoplay === true, loop: a.loop === true, preload: ["none", "metadata", "auto"].includes(a.preload) ? a.preload : "metadata", style: { width: "100%" } }), a.caption && _jsx("figcaption", { children: a.caption })] }, key);
386
413
  case "file": {
@@ -398,9 +425,9 @@ async function renderNodeInner(node, key, ctx) {
398
425
  const body = rows.slice(head ? 1 : 0, foot ? -1 : undefined);
399
426
  return _jsx("div", { className: tableClass(a), children: _jsxs("table", { className: a.fixed ? "is-fixed" : undefined, children: [typeof a.caption === "string" && a.caption.trim() && _jsx("caption", { children: a.caption }), head && _jsx("thead", { children: rows[0] }), _jsx("tbody", { children: body }), foot && _jsx("tfoot", { children: rows.at(-1) })] }) }, key);
400
427
  }
401
- case "tableRow": return _jsx("tr", { children: await children() }, key);
402
- case "tableHeader": return _jsx("th", { colSpan: a.colspan > 1 ? a.colspan : undefined, rowSpan: a.rowspan > 1 ? a.rowspan : undefined, children: await children() }, key);
403
- case "tableCell": return _jsx("td", { colSpan: a.colspan > 1 ? a.colspan : undefined, rowSpan: a.rowspan > 1 ? a.rowspan : undefined, children: await children() }, key);
428
+ case "tableRow": return _jsx("tr", { style: Number(a.height) > 0 ? { height: Number(a.height) } : undefined, children: await children() }, key);
429
+ case "tableHeader": return _jsx("th", { colSpan: a.colspan > 1 ? a.colspan : undefined, rowSpan: a.rowspan > 1 ? a.rowspan : undefined, style: cellWidth(a), children: await children() }, key);
430
+ case "tableCell": return _jsx("td", { colSpan: a.colspan > 1 ? a.colspan : undefined, rowSpan: a.rowspan > 1 ? a.rowspan : undefined, style: cellWidth(a), children: await children() }, key);
404
431
  // Bố cục (@ecomcx/ecomweb-content 1.2). Cấu trúc dùng style trực tiếp → mọi theme hiển thị đúng; class `ecx-*` để theme tạo kiểu thêm (`cms-*` giữ tới 2.0).
405
432
  case "columns": {
406
433
  const cols = await Promise.all((node.content ?? []).map(async (c, i) => {
@@ -546,6 +573,20 @@ async function renderNodeInner(node, key, ctx) {
546
573
  }
547
574
  return _jsx("div", { className: "ecx-testimonials", style: testimonialsVars(c), children: await children() }, key);
548
575
  }
576
+ case "lottie": {
577
+ // Hoạt ảnh Lottie: poster hiện ngay từ máy chủ; thư viện (tuỳ chọn) nạp phía trình duyệt — thiếu thư viện / tệp lỗi thì chỉ hiện poster
578
+ const c = lottieConfig(a);
579
+ const src = c.kind ? safeUrl(c.src, "") : "";
580
+ const poster = safeUrl(c.poster, "");
581
+ if (!src && !poster)
582
+ return null;
583
+ const style = {};
584
+ if (c.height)
585
+ style.height = `${c.height}px`;
586
+ if (c.maxWidth)
587
+ style.maxWidth = `${c.maxWidth}px`;
588
+ return _jsx(LottieClient, { src: src, poster: poster || undefined, label: c.label, loop: c.loop, autoplay: c.autoplay, speed: c.speed, trigger: c.trigger, className: cx("ecx-lottie", `is-align-${c.align}`), style: style }, key);
589
+ }
549
590
  case "popup": {
550
591
  // Nút mở (kiểu như khối Nút) + hộp thoại; không có chữ nút thì không vẽ gì (không có cách mở)
551
592
  const c = popupConfig(a);
package/dist/types.d.ts CHANGED
@@ -37,6 +37,10 @@ export interface Media {
37
37
  sizes: Record<string, MediaSize>;
38
38
  /** Bản WebP của ảnh gốc. */
39
39
  webpUrl?: string | null;
40
+ /** Video: ảnh poster (CMS ≥ 1.37). */
41
+ posterUrl?: string | null;
42
+ /** Video: thời lượng (giây). */
43
+ duration?: number | null;
40
44
  /** Điểm lấy nét 0–1 (object-position). */
41
45
  focalX?: number | null;
42
46
  focalY?: number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecomcx/ecomweb-theme-sdk",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "description": "SDK để viết theme và phần frontend của plugin cho Ecomweb",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "API.md"
37
37
  ],
38
38
  "dependencies": {
39
- "@ecomcx/ecomweb-content": "^1.28.1",
39
+ "@ecomcx/ecomweb-content": "^1.30.0",
40
40
  "intl-messageformat": "12.1.3",
41
41
  "server-only": "0.0.1"
42
42
  },