@ecomcx/ecomweb-theme-sdk 2.1.0 → 2.3.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
@@ -801,7 +801,7 @@ const AUTH_PATHS: AuthPaths
801
801
 
802
802
  #### `BINDABLE`
803
803
 
804
- Thuộc tính gắn được của khối lõi: tên trong bindings → nơi đặt giá trị.
804
+ Thuộc tính gắn được của khối lõi (dùng chung với trình soạn:
805
805
 
806
806
  ```ts
807
807
  const BINDABLE: Record<string, readonly string[]>
@@ -1343,12 +1343,36 @@ Dùng trong file `"use client"`. Tên đã có ở entry chính (component clien
1343
1343
 
1344
1344
  ### Component
1345
1345
 
1346
+ #### `AudienceGate`
1347
+
1348
+ Khối theo nhóm người xem: kiểm ở trình duyệt (trang vẫn cache được). Chưa biết người xem → ẩn; khớp nhóm → hiện.
1349
+
1350
+ ```ts
1351
+ AudienceGate({ audience, children }: { audience: "guest" | "user"; children: ReactNode; }): JSX.Element
1352
+ ```
1353
+
1354
+ #### `BgVideo`
1355
+
1356
+ Video nền (Ảnh bìa): tự phát, tắt tiếng, lặp, không có điều khiển; người xem bật "giảm chuyển động" thì dừng và chỉ hiện ảnh (poster).
1357
+
1358
+ ```ts
1359
+ BgVideo({ src, poster, className, style }: { src: string; poster?: string; className?: string; style?: CSSProperties; }): JSX.Element
1360
+ ```
1361
+
1362
+ #### `CarouselClient`
1363
+
1364
+ Khối Carousel (slider): track cuộn ngang bám mép slide (vuốt được trên điện thoại, không JS vẫn cuộn), nút trước / sau, chấm theo vị trí, tự chạy tuỳ chọn (dừng khi rê chuột / đang focus / tab ẩn / người dùng tắt hiệu ứng chuyển động, có nút Tạm dừng). Số slide thấy cùng lúc theo khổ máy do CSS (style.css).
1365
+
1366
+ ```ts
1367
+ CarouselClient({ children, count, config: c, label }: { children: ReactNode; count: number; config: CarouselConfig; label?: string; }): JSX.Element
1368
+ ```
1369
+
1346
1370
  #### `CountdownClient`
1347
1371
 
1348
1372
  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.
1349
1373
 
1350
1374
  ```ts
1351
- CountdownClient({ target, label, expiredText, units, serverNow, attrs }: { target: number; label?: string; expiredText?: string; units?: Partial<Record<CountdownUnit, string>>; serverNow?: number; attrs?: Record<string, unknown>; }): JSX.Element
1375
+ CountdownClient({ target, label, expiredText, units, serverNow, rules, storageKey, attrs }: { target: number; label?: string; expiredText?: string; units?: Partial<Record<CountdownUnit, string>>; serverNow?: number; rules?: CountdownRules; storageKey?: string; attrs?: Record<string, unknown>; }): JSX.Element | null
1352
1376
  ```
1353
1377
 
1354
1378
  #### `FormBlockClient`
@@ -1356,7 +1380,15 @@ CountdownClient({ target, label, expiredText, units, serverNow, attrs }: { targe
1356
1380
  Khối form cơ bản của lõi (1.39): các ô đã vẽ sẵn ở máy chủ (children), phần này gửi bài qua /api/cms/forms, báo lỗi đúng ô (422), hiện lời cảm ơn. Chống spam: ô bẫy ẩn (_hp) + thời gian điền (máy chủ kiểm), máy chủ còn giới hạn theo IP.
1357
1381
 
1358
1382
  ```ts
1359
- FormBlockClient({ formId, source, successMessage, labels, button, className, children, fields: extraUi }: { formId: string; source: string; successMessage?: string; labels: { submit: string; sending: string; error: string; }; fields?: ReactNode; button?: { className?: string; style?: CSSProperties; }; className?: string; children?: ReactNode; }): JSX.Element
1383
+ FormBlockClient({ formId, source, successMessage, labels, button, className, children, fields: extraUi }: { formId: string; source: string; successMessage?: string; labels: { submit: string; sending: string; error: string; next?: string; back?: string; step?: string; }; fields?: ReactNode; button?: { className?: string; style?: CSSProperties; }; className?: string; children?: ReactNode; }): JSX.Element
1384
+ ```
1385
+
1386
+ #### `GalleryThumbsClient`
1387
+
1388
+ Gallery dạng thumbnail slider: ảnh lớn + dải ảnh nhỏ bấm / bàn phím (← → Home End) đổi ảnh lớn.
1389
+
1390
+ ```ts
1391
+ GalleryThumbsClient({ mains, thumbs, label }: { mains: ReactNode[]; thumbs: ReactNode[]; label?: string; }): JSX.Element
1360
1392
  ```
1361
1393
 
1362
1394
  #### `LanguageSwitcherClient`
@@ -1383,12 +1415,20 @@ Menu di động của khối Menu: nút burger mở ngăn trượt từ trái (n
1383
1415
  NavDrawer({ label, closeLabel, children }: { label: string; closeLabel: string; children: ReactNode; }): JSX.Element
1384
1416
  ```
1385
1417
 
1418
+ #### `PopupClient`
1419
+
1420
+ Popup: nút mở + hộp thoại <dialog> gốc của trình duyệt (khoá focus trong hộp, Esc đóng, trả focus về nút) — nội dung nằm sẵn trong HTML. Bấm nền tối để đóng (khi cho phép), khoá cuộn trang khi mở.
1421
+
1422
+ ```ts
1423
+ PopupClient({ trigger, triggerClass, triggerStyle, className, style, label, closeButton, closeOnOverlay, children, popupId, auto, autoDelay, autoScroll, onceDays }: { popupId?: string; auto?: "none" | "delay" | "scroll" | "exit" | "idle"; autoDelay?: number; autoScroll?: number; onceDays?: number; trigger: ReactNode; triggerClass: string; triggerStyle?: CSSProperties; className: string; style?: CSSProperties; label?: string; closeButton: boolean; closeOnOverlay: boolean; children: ReactNode; }): JSX.Element
1424
+ ```
1425
+
1386
1426
  #### `QueryFilterBar`
1387
1427
 
1388
1428
  Thanh lọc của khối Query (GET): ô tìm, mục phân loại (liên kết tới trang mục / nút lọc / ô chọn), sắp xếp. Giá trị lên URL dạng ?fq_s, ?fq_sort, ?fq_<phân loại>; khối Query bật "Nhận bộ lọc từ thanh lọc" đọc lại. Ô chọn tự gửi khi đổi.
1389
1429
 
1390
1430
  ```ts
1391
- QueryFilterBar({ action, taxonomy, termStyle, terms, currentTerm, values, showSearch, showSort, sorts, labels }: { action: string; taxonomy?: string; termStyle: "none" | "links" | "chips" | "select"; terms: Array<{ slug: string; name: string; link: string; }>; currentTerm?: string; values: Record<string, string>; showSearch: boolean; showSort: boolean; sorts: Array<{ value: string; label: string; }>; labels: { all: string; search: string; placeholder: string; submit: string; sort: string; }; }): JSX.Element
1431
+ QueryFilterBar({ action, taxonomy, termStyle, terms, currentTerm, values, showSearch, showSort, showYear, showReset, years, sorts, labels, range }: { range?: { param: string; label?: string; max?: number; }; action: string; taxonomy?: string; termStyle: "none" | "links" | "chips" | "select" | "checks"; terms: Array<{ slug: string; name: string; link: string; }>; currentTerm?: string; values: Record<string, string>; showSearch: boolean; showSort: boolean; showYear: boolean; showReset: boolean; years: number[]; sorts: Array<{ value: string; label: string; }>; labels: { all: string; search: string; placeholder: string; submit: string; sort: string; year: string; reset: string; from?: string; to?: string; }; }): JSX.Element
1392
1432
  ```
1393
1433
 
1394
1434
  #### `ScrollRow`
@@ -1412,7 +1452,7 @@ SearchFormClient({ action, defaultValue, placeholder, label, buttonLabel, postTy
1412
1452
  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. Tab dọc (`vertical`), thành accordion trên điện thoại (`mobileAccordion`, chỉ CSS: tiêu đề nằm ngay trên panel của nó); tab có neo → panel mang id = neo, mở thẳng bằng #neo.
1413
1453
 
1414
1454
  ```ts
1415
- TabsClient({ titles, panels, initial, icons, subtitles, anchors, vertical, mobileAccordion, extraClass }: { titles: string[]; panels: ReactNode[]; initial?: number; icons?: Array<string | undefined>; subtitles?: Array<string | undefined>; anchors?: Array<string | undefined>; vertical?: boolean; mobileAccordion?: boolean; extraClass?: string; }): JSX.Element
1455
+ TabsClient({ titles, panels, initial, icons, subtitles, anchors, vertical, mobileAccordion, extraClass }: { titles: string[]; panels: ReactNode[]; initial?: number; icons?: Array<ReactNode | undefined>; subtitles?: Array<string | undefined>; anchors?: Array<string | undefined>; vertical?: boolean; mobileAccordion?: boolean; extraClass?: string; }): JSX.Element
1416
1456
  ```
1417
1457
 
1418
1458
  #### `TocSpy`
@@ -1431,6 +1471,14 @@ Chuyển chuỗi đã dịch xuống component client. Server Component lấy b
1431
1471
  TranslationsProvider({ value, children }: { value: ClientMessages; children: ReactNode; }): JSX.Element
1432
1472
  ```
1433
1473
 
1474
+ #### `TypedText`
1475
+
1476
+ Chữ gõ ở cuối Tiêu đề: gõ từng ký tự, dừng, xoá, sang từ kế (lặp hoặc dừng ở từ cuối). HTML dựng sẵn là từ đầu tiên; người xem bật giảm chuyển động thì giữ nguyên từ đầu. Trình đọc màn hình đọc cả nhóm từ một lần (aria-label), không đọc từng ký tự.
1477
+
1478
+ ```ts
1479
+ TypedText({ words, speed, pause, loop }: { words: string[]; speed: number; pause: number; loop: boolean; }): JSX.Element
1480
+ ```
1481
+
1434
1482
  ### Hàm
1435
1483
 
1436
1484
  #### `emit`
@@ -10,6 +10,6 @@ export interface BindingContext {
10
10
  data?: ResolveResult | null;
11
11
  }
12
12
  export type BindingSource = (args: Record<string, string | number | boolean>, ctx: BindingContext) => unknown | Promise<unknown>;
13
- /** Thuộc tính gắn được của khối lõi: tên trong bindings → nơi đặt giá trị. */
13
+ /** Thuộc tính gắn được của khối lõi (dùng chung với trình soạn: @ecomcx/ecomweb-content CORE_BINDABLE). */
14
14
  export declare const BINDABLE: Record<string, readonly string[]>;
15
15
  export declare const CORE_BINDING_SOURCES: Record<string, BindingSource>;
package/dist/bindings.js CHANGED
@@ -1,7 +1,6 @@
1
- /** Thuộc tính gắn được của khối lõi: tên trong bindings → nơi đặt giá trị. */
2
- export const BINDABLE = {
3
- paragraph: ["content"], heading: ["content"], image: ["src", "alt", "caption"], button: ["text", "href"],
4
- };
1
+ import { CORE_BINDABLE } from "@ecomcx/ecomweb-content";
2
+ /** Thuộc tính gắn được của khối lõi (dùng chung với trình soạn: @ecomcx/ecomweb-content CORE_BINDABLE). */
3
+ export const BINDABLE = CORE_BINDABLE;
5
4
  const scalar = (v) => (typeof v === "string" || typeof v === "number" || typeof v === "boolean" ? String(v) : undefined);
6
5
  export const CORE_BINDING_SOURCES = {
7
6
  "core/post": (args, { post }) => {
@@ -14,6 +13,15 @@ export const CORE_BINDING_SOURCES = {
14
13
  case "author": return post.author?.name;
15
14
  case "link": return post.link;
16
15
  case "featuredImage": return post.featuredMedia?.url;
16
+ // 1.32: thêm trường cho các ô gắn dữ liệu
17
+ case "featuredImageAlt": return post.featuredMedia?.alt;
18
+ case "slug": return post.slug;
19
+ case "id": return String(post.id);
20
+ case "modified": return post.updatedAt ? new Date(post.updatedAt).toLocaleDateString(post.locale || "vi") : undefined;
21
+ case "comments": return String(post.commentCount ?? 0);
22
+ case "category": return post.terms?.category?.[0]?.name;
23
+ case "authorAvatar": return post.author?.avatarUrl ?? undefined;
24
+ case "authorBio": return post.author?.bio ?? undefined;
17
25
  default: return undefined;
18
26
  }
19
27
  },
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type CountdownUnit } from "@ecomcx/ecomweb-content";
1
+ import { type CountdownRules, type CarouselConfig, type CountdownUnit } from "@ecomcx/ecomweb-content";
2
2
  import { Component } from "react";
3
3
  import type { Comment } from "./types.js";
4
4
  import type { AnchorHTMLAttributes, CSSProperties, ReactNode } from "react";
@@ -147,14 +147,16 @@ export declare function LanguageSwitcherClient({ languages, current, defaultLoca
147
147
  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";
148
148
  export { safeRedirect, type CurrentUser } from "./auth-shared.js";
149
149
  /** 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. */
150
- export declare function CountdownClient({ target, label, expiredText, units, serverNow, attrs }: {
150
+ export declare function CountdownClient({ target, label, expiredText, units, serverNow, rules, storageKey, attrs }: {
151
151
  target: number;
152
152
  label?: string;
153
153
  expiredText?: string;
154
154
  units?: Partial<Record<CountdownUnit, string>>;
155
155
  serverNow?: number;
156
+ rules?: CountdownRules;
157
+ storageKey?: string;
156
158
  attrs?: Record<string, unknown>;
157
- }): import("react").JSX.Element;
159
+ }): import("react").JSX.Element | null;
158
160
  /** Mục lục: tô đậm mục của tiêu đề đang đọc (tiêu đề cuối cùng đã cuộn qua mép trên 120px) — aria-current="location". */
159
161
  export declare function TocSpy(): import("react").JSX.Element;
160
162
  /** Nút ☰ của menu trên điện thoại: <details> gốc + Escape đóng menu và trả focus về nút. */
@@ -172,7 +174,7 @@ export declare function TabsClient({ titles, panels, initial, icons, subtitles,
172
174
  titles: string[];
173
175
  panels: ReactNode[];
174
176
  initial?: number;
175
- icons?: Array<string | undefined>;
177
+ icons?: Array<ReactNode | undefined>;
176
178
  subtitles?: Array<string | undefined>;
177
179
  anchors?: Array<string | undefined>;
178
180
  vertical?: boolean;
@@ -197,6 +199,9 @@ export declare function FormBlockClient({ formId, source, successMessage, labels
197
199
  submit: string;
198
200
  sending: string;
199
201
  error: string;
202
+ next?: string;
203
+ back?: string;
204
+ step?: string;
200
205
  };
201
206
  /** Ô thêm của plugin (captcha…): <Slot name="form.fields" />. Ô name="extra.*" gửi kèm trong "extra" (hook form.submitting). */
202
207
  fields?: ReactNode;
@@ -208,6 +213,53 @@ export declare function FormBlockClient({ formId, source, successMessage, labels
208
213
  className?: string;
209
214
  children?: ReactNode;
210
215
  }): import("react").JSX.Element;
216
+ /**
217
+ * Khối Carousel (slider): track cuộn ngang bám mép slide (vuốt được trên điện thoại, không JS vẫn cuộn), nút trước / sau, chấm theo vị trí,
218
+ * tự chạy tuỳ chọn (dừng khi rê chuột / đang focus / tab ẩn / người dùng tắt hiệu ứng chuyển động, có nút Tạm dừng). Số slide thấy cùng lúc theo khổ máy do CSS (style.css).
219
+ */
220
+ export declare function CarouselClient({ children, count, config: c, label }: {
221
+ children: ReactNode;
222
+ count: number;
223
+ config: CarouselConfig;
224
+ label?: string;
225
+ }): import("react").JSX.Element;
226
+ /**
227
+ * Popup: nút mở + hộp thoại <dialog> gốc của trình duyệt (khoá focus trong hộp, Esc đóng, trả focus về nút) — nội dung nằm sẵn trong HTML.
228
+ * Bấm nền tối để đóng (khi cho phép), khoá cuộn trang khi mở.
229
+ */
230
+ export declare function PopupClient({ trigger, triggerClass, triggerStyle, className, style, label, closeButton, closeOnOverlay, children, popupId, auto, autoDelay, autoScroll, onceDays }: {
231
+ popupId?: string;
232
+ auto?: "none" | "delay" | "scroll" | "exit" | "idle";
233
+ autoDelay?: number;
234
+ autoScroll?: number;
235
+ onceDays?: number;
236
+ trigger: ReactNode;
237
+ triggerClass: string;
238
+ triggerStyle?: CSSProperties;
239
+ className: string;
240
+ style?: CSSProperties;
241
+ label?: string;
242
+ closeButton: boolean;
243
+ closeOnOverlay: boolean;
244
+ children: ReactNode;
245
+ }): import("react").JSX.Element;
246
+ /**
247
+ * Chữ gõ ở cuối Tiêu đề: gõ từng ký tự, dừng, xoá, sang từ kế (lặp hoặc dừng ở từ cuối). HTML dựng sẵn là từ đầu tiên;
248
+ * người xem bật giảm chuyển động thì giữ nguyên từ đầu. Trình đọc màn hình đọc cả nhóm từ một lần (aria-label), không đọc từng ký tự.
249
+ */
250
+ export declare function TypedText({ words, speed, pause, loop }: {
251
+ words: string[];
252
+ speed: number;
253
+ pause: number;
254
+ loop: boolean;
255
+ }): import("react").JSX.Element;
256
+ /** Video nền (Ảnh bìa): tự phát, tắt tiếng, lặp, không có điều khiển; người xem bật "giảm chuyển động" thì dừng và chỉ hiện ảnh (poster). */
257
+ export declare function BgVideo({ src, poster, className, style }: {
258
+ src: string;
259
+ poster?: string;
260
+ className?: string;
261
+ style?: CSSProperties;
262
+ }): import("react").JSX.Element;
211
263
  /** Hàng cuộn ngang có nút trước / sau (Query dạng carousel): cuộn đúng một "trang" mỗi lần bấm, ẩn nút ở hai đầu. Không có JS vẫn vuốt / cuộn được. */
212
264
  export declare function ScrollRow({ children, arrows }: {
213
265
  children: ReactNode;
@@ -226,10 +278,15 @@ export declare function NavDrawer({ label, closeLabel, children }: {
226
278
  * Thanh lọc của khối Query (GET): ô tìm, mục phân loại (liên kết tới trang mục / nút lọc / ô chọn), sắp xếp.
227
279
  * Giá trị lên URL dạng ?fq_s, ?fq_sort, ?fq_<phân loại>; khối Query bật "Nhận bộ lọc từ thanh lọc" đọc lại. Ô chọn tự gửi khi đổi.
228
280
  */
229
- export declare function QueryFilterBar({ action, taxonomy, termStyle, terms, currentTerm, values, showSearch, showSort, sorts, labels }: {
281
+ export declare function QueryFilterBar({ action, taxonomy, termStyle, terms, currentTerm, values, showSearch, showSort, showYear, showReset, years, sorts, labels, range }: {
282
+ range?: {
283
+ param: string;
284
+ label?: string;
285
+ max?: number;
286
+ };
230
287
  action: string;
231
288
  taxonomy?: string;
232
- termStyle: "none" | "links" | "chips" | "select";
289
+ termStyle: "none" | "links" | "chips" | "select" | "checks";
233
290
  terms: Array<{
234
291
  slug: string;
235
292
  name: string;
@@ -239,6 +296,9 @@ export declare function QueryFilterBar({ action, taxonomy, termStyle, terms, cur
239
296
  values: Record<string, string>;
240
297
  showSearch: boolean;
241
298
  showSort: boolean;
299
+ showYear: boolean;
300
+ showReset: boolean;
301
+ years: number[];
242
302
  sorts: Array<{
243
303
  value: string;
244
304
  label: string;
@@ -249,5 +309,20 @@ export declare function QueryFilterBar({ action, taxonomy, termStyle, terms, cur
249
309
  placeholder: string;
250
310
  submit: string;
251
311
  sort: string;
312
+ year: string;
313
+ reset: string;
314
+ from?: string;
315
+ to?: string;
252
316
  };
253
317
  }): import("react").JSX.Element;
318
+ /** Khối theo nhóm người xem: kiểm ở trình duyệt (trang vẫn cache được). Chưa biết người xem → ẩn; khớp nhóm → hiện. */
319
+ export declare function AudienceGate({ audience, children }: {
320
+ audience: "guest" | "user";
321
+ children: ReactNode;
322
+ }): import("react").JSX.Element;
323
+ /** Gallery dạng thumbnail slider: ảnh lớn + dải ảnh nhỏ bấm / bàn phím (← → Home End) đổi ảnh lớn. */
324
+ export declare function GalleryThumbsClient({ mains, thumbs, label }: {
325
+ mains: ReactNode[];
326
+ thumbs: ReactNode[];
327
+ label?: string;
328
+ }): import("react").JSX.Element;