@ecomcx/ecomweb-theme-sdk 1.37.0 → 1.38.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/dist/client.d.ts CHANGED
@@ -118,10 +118,11 @@ export declare function LanguageSwitcherClient({ languages, current, defaultLoca
118
118
  export { LoginForm, RegisterForm, ForgotPasswordForm, ResetPasswordForm, LogoutButton, LoginOutLink, useCurrentUser, extraFields, ProfileForm, ChangePasswordForm, DeleteAccountForm, AUTH_LABELS, AUTH_PATHS, type AuthLabels, type AuthPaths, type SignInProvider } from "./auth-forms.js";
119
119
  export { safeRedirect, type CurrentUser } from "./auth-shared.js";
120
120
  /** Khối countdown: đếm ngược tới `target` (ms). Dựng lần đầu cùng giá trị trên máy chủ, rồi cập nhật mỗi giây. */
121
- export declare function CountdownClient({ target, label, expiredText }: {
121
+ export declare function CountdownClient({ target, label, expiredText, units }: {
122
122
  target: number;
123
123
  label?: string;
124
124
  expiredText?: string;
125
+ units?: Partial<Record<"d" | "h" | "m" | "s", string>>;
125
126
  }): import("react").JSX.Element;
126
127
  /** Khối tabs: các panel đã vẽ sẵn trên máy chủ (nội dung vẫn có trong HTML cho SEO); chỉ đổi panel đang hiện. */
127
128
  export declare function TabsClient({ titles, panels }: {
package/dist/client.js CHANGED
@@ -193,7 +193,7 @@ export function LanguageSwitcherClient({ languages, current, defaultLocale, labe
193
193
  export { LoginForm, RegisterForm, ForgotPasswordForm, ResetPasswordForm, LogoutButton, LoginOutLink, useCurrentUser, extraFields, ProfileForm, ChangePasswordForm, DeleteAccountForm, AUTH_LABELS, AUTH_PATHS } from "./auth-forms.js";
194
194
  export { safeRedirect } from "./auth-shared.js";
195
195
  /** Khối countdown: đếm ngược tới `target` (ms). Dựng lần đầu cùng giá trị trên máy chủ, rồi cập nhật mỗi giây. */
196
- export function CountdownClient({ target, label, expiredText }) {
196
+ export function CountdownClient({ target, label, expiredText, units }) {
197
197
  const [now, setNow] = useState(() => Date.now());
198
198
  useEffect(() => { const id = setInterval(() => setNow(Date.now()), 1000); return () => clearInterval(id); }, []);
199
199
  const left = Math.max(0, target - now);
@@ -202,7 +202,7 @@ export function CountdownClient({ target, label, expiredText }) {
202
202
  const p = (n) => String(n).padStart(2, "0");
203
203
  const s = Math.floor(left / 1000);
204
204
  const parts = [["d", Math.floor(s / 86400)], ["h", Math.floor(s / 3600) % 24], ["m", Math.floor(s / 60) % 60], ["s", s % 60]];
205
- return (_jsxs("div", { className: "ecx-countdown", role: "timer", "aria-live": "off", suppressHydrationWarning: true, children: [label && _jsx("p", { className: "ecx-countdown-label", children: label }), _jsx("div", { className: "ecx-countdown-parts", children: parts.map(([u, n]) => _jsxs("span", { className: `ecx-countdown-${u}`, children: [_jsx("strong", { children: p(n) }), _jsx("small", { children: u })] }, u)) })] }));
205
+ return (_jsxs("div", { className: "ecx-countdown", role: "timer", "aria-live": "off", suppressHydrationWarning: true, children: [label && _jsx("p", { className: "ecx-countdown-label", children: label }), _jsx("div", { className: "ecx-countdown-parts", children: parts.map(([u, n]) => _jsxs("span", { className: `ecx-countdown-${u}`, children: [_jsx("strong", { children: p(n) }), _jsx("small", { children: units?.[u] ?? u })] }, u)) })] }));
206
206
  }
207
207
  /** Khối tabs: các panel đã vẽ sẵn trên máy chủ (nội dung vẫn có trong HTML cho SEO); chỉ đổi panel đang hiện. */
208
208
  export function TabsClient({ titles, panels }) {
package/dist/i18n.js CHANGED
@@ -7,7 +7,7 @@ export const BUILTIN = {
7
7
  vi: {
8
8
  "search.placeholder": "Tìm kiếm…", "search.button": "Tìm", "search.label": "Từ khoá", "navigation.menu": "Menu", "toc.title": "Mục lục", "query.search": "Kết quả tìm kiếm: {q}", "query.category": "Chuyên mục: {name}", "query.tag": "Thẻ: {name}", "query.author": "Tác giả: {name}", "breadcrumbs.home": "Trang chủ", "breadcrumbs.label": "Đường dẫn", "postNav.previous": "Bài trước", "postNav.next": "Bài sau", "postNav.label": "Bài khác",
9
9
  "post.read_more": "Đọc tiếp", "pagination.prev": "« Trước", "pagination.next": "Sau »", "pagination.label": "Phân trang",
10
- "comments.title": "Bình luận", "comments.closed": "Bình luận đã đóng.",
10
+ "comments.title": "Bình luận", "comments.closed": "Bình luận đã đóng.", "countdown.d": "ngày", "countdown.h": "giờ", "countdown.m": "phút", "countdown.s": "giây",
11
11
  "comments.form.title": "Để lại bình luận", "comments.form.content": "Bình luận", "comments.form.name": "Tên",
12
12
  "comments.form.email": "Email", "comments.form.website": "Website", "comments.form.submit": "Gửi bình luận",
13
13
  "comments.form.sending": "Đang gửi…", "comments.form.approved": "Cảm ơn bạn! Bình luận đã được đăng (tải lại trang để xem).",
@@ -28,11 +28,12 @@ export const BUILTIN = {
28
28
  "auth.submitProfile": "Lưu hồ sơ", "auth.submitPassword": "Đổi mật khẩu", "auth.notSignedIn": "Bạn cần đăng nhập để xem trang này.",
29
29
  "auth.deleteWarning": "Xoá tài khoản là vĩnh viễn: bạn không đăng nhập được nữa, bài viết của bạn không còn tác giả.",
30
30
  "auth.deleteConfirm": "Tôi hiểu, xoá tài khoản của tôi", "auth.submitDelete": "Xoá tài khoản",
31
+ "styleBook.title": "Mẫu kiểu dáng", "styleBook.h": "Tiêu đề", "styleBook.para": "Đoạn văn mẫu: chữ của bài viết trên website hiển thị như thế này.", "styleBook.bold": "chữ đậm", "styleBook.italic": "chữ nghiêng", "styleBook.link": "liên kết", "styleBook.item": "Mục", "styleBook.quote": "Trích dẫn mẫu: một câu đáng nhớ.", "styleBook.cite": "Tác giả", "styleBook.button": "Nút bấm", "styleBook.callout": "Hộp lưu ý: thông tin cần chú ý.", "styleBook.group": "Nhóm có nền", "styleBook.column": "Cột", "styleBook.details": "Bấm để xem thêm", "styleBook.cover": "Ảnh bìa",
31
32
  },
32
33
  en: {
33
34
  "search.placeholder": "Search…", "search.button": "Search", "search.label": "Keyword", "navigation.menu": "Menu", "toc.title": "Contents", "query.search": "Search results: {q}", "query.category": "Category: {name}", "query.tag": "Tag: {name}", "query.author": "Author: {name}", "breadcrumbs.home": "Home", "breadcrumbs.label": "Breadcrumb", "postNav.previous": "Previous", "postNav.next": "Next", "postNav.label": "More posts",
34
35
  "post.read_more": "Read more", "pagination.prev": "« Previous", "pagination.next": "Next »", "pagination.label": "Pagination",
35
- "comments.title": "Comments", "comments.closed": "Comments are closed.",
36
+ "comments.title": "Comments", "comments.closed": "Comments are closed.", "countdown.d": "d", "countdown.h": "h", "countdown.m": "m", "countdown.s": "s",
36
37
  "comments.form.title": "Leave a comment", "comments.form.content": "Comment", "comments.form.name": "Name",
37
38
  "comments.form.email": "Email", "comments.form.website": "Website", "comments.form.submit": "Post comment",
38
39
  "comments.form.sending": "Sending…", "comments.form.approved": "Thanks! Your comment is published (reload to see it).",
@@ -53,6 +54,7 @@ export const BUILTIN = {
53
54
  "auth.submitProfile": "Save profile", "auth.submitPassword": "Change password", "auth.notSignedIn": "Please log in to see this page.",
54
55
  "auth.deleteWarning": "Deleting your account is permanent: you can no longer log in and your posts will have no author.",
55
56
  "auth.deleteConfirm": "I understand, delete my account", "auth.submitDelete": "Delete account",
57
+ "styleBook.title": "Style book", "styleBook.h": "Heading", "styleBook.para": "Sample paragraph: post text on the website looks like this.", "styleBook.bold": "bold text", "styleBook.italic": "italic text", "styleBook.link": "a link", "styleBook.item": "Item", "styleBook.quote": "Sample quote: a memorable line.", "styleBook.cite": "Author", "styleBook.button": "Button", "styleBook.callout": "Callout: something worth noticing.", "styleBook.group": "Group with background", "styleBook.column": "Column", "styleBook.details": "Click to see more", "styleBook.cover": "Cover",
56
58
  },
57
59
  };
58
60
  /**
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { PostContent } from "./content.js";
3
3
  /** Template "canvas": không có header/footer của theme, chỉ nội dung trang (trang dựng bằng khối). */
4
4
  export default function Canvas({ data }) {
5
- return _jsx("main", { className: "ecx-canvas", children: _jsx(PostContent, { post: data.post }) });
5
+ // Chữ ở cột giữa, khối "Rộng" / "Toàn trang" tràn ra (như template trống của WordPress)
6
+ return _jsx("main", { className: "ecx-canvas", children: _jsx(PostContent, { post: data.post, className: "entry-content ecx-layout-constrained" }) });
6
7
  }
7
8
  export const layout = false;
@@ -1,3 +1,6 @@
1
1
  import type { TemplateProps } from "./types.js";
2
- /** Template "full-width": giữ header/footer của theme, nội dung trải hết chiều ngang màn hình. */
2
+ /**
3
+ * Template "full-width": giữ header/footer của theme, vùng bài trải hết chiều ngang màn hình. Như WordPress: chữ vẫn ở cột giữa
4
+ * (--ecx-content-width), chỉ khối đặt độ rộng "Rộng" / "Toàn trang" mới tràn ra.
5
+ */
3
6
  export default function FullWidth({ data }: TemplateProps): import("react").JSX.Element;
@@ -1,6 +1,9 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { PostContent } from "./content.js";
3
- /** Template "full-width": giữ header/footer của theme, nội dung trải hết chiều ngang màn hình. */
3
+ /**
4
+ * Template "full-width": giữ header/footer của theme, vùng bài trải hết chiều ngang màn hình. Như WordPress: chữ vẫn ở cột giữa
5
+ * (--ecx-content-width), chỉ khối đặt độ rộng "Rộng" / "Toàn trang" mới tràn ra.
6
+ */
4
7
  export default function FullWidth({ data }) {
5
- return _jsx("div", { className: "ecx-full-width", children: _jsx(PostContent, { post: data.post }) });
8
+ return (_jsxs("div", { className: "ecx-full-width", children: [data.post?.title && _jsx("h1", { className: "entry-title ecx-page-title", children: data.post.title }), _jsx(PostContent, { post: data.post, className: "entry-content ecx-layout-constrained" })] }));
6
9
  }
package/dist/rich.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Fragment, cloneElement, createElement, isValidElement } from "react";
3
3
  import { ICON_PATHS } from "./icons.js";
4
- import { DYNAMIC_NODES, blockCitation, blockShell, buttonWrapShell, coverParts, linkRel, embedInfo, motionClasses, normalizeContent, safeUrl, styleClass, styleCss } from "@ecomcx/ecomweb-content";
4
+ import { DYNAMIC_NODES, widthClass, blockCitation, blockShell, buttonWrapShell, coverParts, linkRel, embedInfo, motionClasses, normalizeContent, safeUrl, styleClass, styleCss } from "@ecomcx/ecomweb-content";
5
5
  import { cx } from "./utils.js";
6
6
  import { SOCIAL_ICONS } from "./social-icons.js";
7
7
  import { CountdownClient, LightboxClient, TabsClient } from "./client.js";
8
+ import { getT } from "./i18n.js";
8
9
  const DYNAMIC = new Set(DYNAMIC_NODES);
9
10
  const SHORTCODE = /^\s*\[([a-z0-9_-]+)((?:\s+[a-z0-9_-]+=(?:"[^"]*"|'[^']*'|[^\s\]]+))*)\s*\]\s*$/i;
10
11
  const SHORTCODE_INLINE = /\[([a-z0-9_-]+)((?:\s+[a-z0-9_-]+=(?:"[^"]*"|'[^']*'|[^\s\]]+))*)\s*\]/gi;
@@ -155,14 +156,14 @@ function overridden(style) {
155
156
  * Gắn kiểu dáng (class `ecx-s-…`), biến thể (`ecx-is-…`), class riêng và neo (id) của khối vào phần tử đã vẽ
156
157
  * (không có phần tử bọc ngoài → thêm div). Giá trị đã được normalizeContent kiểm.
157
158
  */
158
- function decorate(el, a, key, ctx) {
159
+ function decorate(el, a, key, ctx, type) {
159
160
  if (el == null || el === false)
160
161
  return el;
161
162
  const style = a.style && typeof a.style === "object" ? a.style : null;
162
163
  const cls = style ? styleClass(style) : null;
163
164
  if (style && cls && ctx.styles && !ctx.styles.has(cls))
164
165
  ctx.styles.set(cls, styleCss(style, cls));
165
- const extra = cx(cls, motionClasses(style), a.blockStyle && `ecx-is-${a.blockStyle}`, a.className);
166
+ const extra = cx(cls, motionClasses(style), widthClass(type, a), a.blockStyle && `ecx-is-${a.blockStyle}`, a.className);
166
167
  if (isValidElement(el) && el.type !== Fragment && typeof el.type === "string") {
167
168
  const e = el;
168
169
  let inline = e.props.style;
@@ -220,7 +221,7 @@ async function renderNode(node, key, ctx) {
220
221
  if (ctx.filterBlock && node.type !== "text" && node.type !== "doc")
221
222
  el = await ctx.filterBlock(node, el);
222
223
  const a = node.attrs;
223
- const out = a && (a.style || a.blockStyle || a.className || a.anchor) ? decorate(el, a, key, ctx) : el;
224
+ const out = a && (a.style || a.blockStyle || a.className || a.anchor || widthClass(node.type, a)) ? decorate(el, a, key, ctx, node.type) : el;
224
225
  return ctx.markBlocks && ctx.source && ctx.pathRoot != null && key.startsWith(ctx.pathRoot + "-") && !UNMARKED.has(node.type)
225
226
  ? markBlock(out, ctx.source, key.slice(ctx.pathRoot.length + 1), key)
226
227
  : out;
@@ -365,7 +366,9 @@ async function renderNodeInner(node, key, ctx) {
365
366
  }
366
367
  case "mediaText": return shelled("mediaText", a, key, _jsxs(_Fragment, { children: [_jsx("figure", { className: "ecx-media-text-media", style: { margin: 0 }, children: a.src && _jsx("img", { src: safeUrl(a.src, ""), alt: a.alt ?? "", loading: "lazy", decoding: "async" }) }), _jsx("div", { className: "ecx-media-text-content", children: await children() })] }));
367
368
  case "pullquote":
368
- return shelled("pullquote", a, key, _jsxs(_Fragment, { children: [_jsx("blockquote", { children: _jsx("p", { children: await children() }) }), blockCitation(a) && _jsx("figcaption", { children: blockCitation(a) })] }));
369
+ // Nội dung là các khối (đoạn văn…) → không bọc <p> (<p><p> sai HTML: trình duyệt tách thẻ → React báo lệch khi hydrate);
370
+ // chữ trần (dữ liệu cũ) mới cần <p>
371
+ return shelled("pullquote", a, key, _jsxs(_Fragment, { children: [_jsx("blockquote", { children: (node.content ?? []).every((c) => c.type === "text" || c.type === "hardBreak") ? _jsx("p", { children: await children() }) : await children() }), blockCitation(a) && _jsx("figcaption", { children: blockCitation(a) })] }));
369
372
  case "accordion": {
370
373
  const sub = a.multiple === true ? ctx : { ...ctx, accordion: `ecx-acc-${key}` };
371
374
  return _jsx("div", { className: "ecx-accordion", children: await Promise.all((node.content ?? []).map((c, i) => renderNode(c, `${key}-${i}`, sub))) }, key);
@@ -374,7 +377,9 @@ async function renderNodeInner(node, key, ctx) {
374
377
  const ms = Date.parse(String(a.target ?? ""));
375
378
  if (!Number.isFinite(ms))
376
379
  return null;
377
- return _jsx(CountdownClient, { target: ms, label: a.label ? String(a.label) : undefined, expiredText: a.expiredText ? String(a.expiredText) : undefined }, key);
380
+ const t = await getT();
381
+ const units = { d: t("countdown.d"), h: t("countdown.h"), m: t("countdown.m"), s: t("countdown.s") }; // theo ngôn ngữ của trang (vi: ngày/giờ/phút/giây)
382
+ return _jsx(CountdownClient, { target: ms, units: units, label: a.label ? String(a.label) : undefined, expiredText: a.expiredText ? String(a.expiredText) : undefined }, key);
378
383
  }
379
384
  case "rating": {
380
385
  const max = Math.min(10, Math.max(1, Math.round(Number(a.max) || 5)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecomcx/ecomweb-theme-sdk",
3
- "version": "1.37.0",
3
+ "version": "1.38.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",
@@ -33,7 +33,7 @@
33
33
  "README.md"
34
34
  ],
35
35
  "dependencies": {
36
- "@ecomcx/ecomweb-content": "^1.19.0",
36
+ "@ecomcx/ecomweb-content": "^1.20.0",
37
37
  "intl-messageformat": "12.1.3"
38
38
  },
39
39
  "peerDependencies": {