@ecomcx/ecomweb-admin-sdk 1.28.0 → 1.30.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/index.d.ts CHANGED
@@ -9,6 +9,13 @@ export declare const registerDashboardWidget: (w: DashboardWidget) => void;
9
9
  export declare const registerPostListColumn: (c: import("./types.js").PostListColumn) => void;
10
10
  /** Thêm hộp vào form sửa chuyên mục/thẻ (dữ liệu lưu trong term.meta). */
11
11
  export declare const registerTermMetaBox: (b: import("./types.js").TermMetaBox) => void;
12
+ /**
13
+ * Thêm hộp vào trang sửa đối tượng của plugin khác (đơn hàng, mã giảm giá, dòng bảng [PluginTable] có cột [ObjectMeta]…) —
14
+ * giá trị đặt qua setMeta được plugin chủ lưu cùng đối tượng. CMS < 1.18.0: bỏ qua.
15
+ */
16
+ export declare const registerObjectMetaBox: (b: import("./types.js").ObjectMetaBox) => void | undefined;
17
+ /** Hộp đã đăng ký cho một đối tượng (bỏ trống = tất cả). */
18
+ export declare const getObjectMetaBoxes: (object?: string) => import("./types.js").ObjectMetaBox[];
12
19
  /** Lấy các MetaBox đã đăng ký trong hệ thống (tùy chọn lọc theo postType). */
13
20
  export declare const getMetaBoxes: (postType?: string) => MetaBox[];
14
21
  /** Hook lấy toàn bộ state plugin UI trong host. */
@@ -241,6 +248,8 @@ export declare const Tabs: NonNullable<import("react").ComponentType<{
241
248
  }>;
242
249
  }>>;
243
250
  export declare const MetaBoxes: NonNullable<import("react").ComponentType<import("./types.js").MetaBoxesProps>>;
251
+ /** Plugin chủ vẽ chỗ cho hộp của plugin khác trong trang sửa đối tượng của mình (CMS < 1.18.0: không vẽ gì). */
252
+ export declare const ObjectMetaBoxes: NonNullable<import("react").ComponentType<import("./types.js").ObjectMetaBoxesProps> | undefined>;
244
253
  export declare const Slot: NonNullable<import("react").ComponentType<{
245
254
  name: string;
246
255
  props?: any;
package/dist/index.js CHANGED
@@ -9,6 +9,13 @@ export const registerDashboardWidget = (w) => host().registerDashboardWidget(w);
9
9
  export const registerPostListColumn = (c) => host().registerPostListColumn(c);
10
10
  /** Thêm hộp vào form sửa chuyên mục/thẻ (dữ liệu lưu trong term.meta). */
11
11
  export const registerTermMetaBox = (b) => host().registerTermMetaBox(b);
12
+ /**
13
+ * Thêm hộp vào trang sửa đối tượng của plugin khác (đơn hàng, mã giảm giá, dòng bảng [PluginTable] có cột [ObjectMeta]…) —
14
+ * giá trị đặt qua setMeta được plugin chủ lưu cùng đối tượng. CMS < 1.18.0: bỏ qua.
15
+ */
16
+ export const registerObjectMetaBox = (b) => host().registerObjectMetaBox?.(b);
17
+ /** Hộp đã đăng ký cho một đối tượng (bỏ trống = tất cả). */
18
+ export const getObjectMetaBoxes = (object) => host().getObjectMetaBoxes?.(object) ?? [];
12
19
  /** Lấy các MetaBox đã đăng ký trong hệ thống (tùy chọn lọc theo postType). */
13
20
  export const getMetaBoxes = (postType) => (host().getMetaBoxes ? host().getMetaBoxes(postType) : []);
14
21
  /** Hook lấy toàn bộ state plugin UI trong host. */
@@ -137,6 +144,8 @@ export const IconButton = ui("IconButton");
137
144
  export const Section = ui("Section");
138
145
  export const Tabs = ui("Tabs");
139
146
  export const MetaBoxes = ui("MetaBoxes");
147
+ /** Plugin chủ vẽ chỗ cho hộp của plugin khác trong trang sửa đối tượng của mình (CMS < 1.18.0: không vẽ gì). */
148
+ export const ObjectMetaBoxes = ui("ObjectMetaBoxes", () => null);
140
149
  export const Slot = ui("Slot");
141
150
  export const Fill = ui("Fill");
142
151
  // ----- UI kit v2 (xem trang /ui-kit trong admin) -----
package/dist/types.d.ts CHANGED
@@ -91,6 +91,40 @@ export interface TermMetaBox {
91
91
  taxonomies?: string[];
92
92
  component: ComponentType<TermMetaBoxProps>;
93
93
  }
94
+ /**
95
+ * Đối tượng của plugin lưu trong bảng riêng (vd "ecomcx-ecommerce/order") — plugin chủ khai báo bằng ctx.Objects.Register ở backend
96
+ * (hoặc bảng [PluginTable] có cột [ObjectMeta]); danh sách nằm trong bootstrap của admin (`objectTypes`).
97
+ */
98
+ export interface ObjectMetaBoxProps {
99
+ /** Tên đối tượng "{slug}/{name}". */
100
+ object: string;
101
+ /** Mã đối tượng; bỏ trống khi đang tạo mới. */
102
+ id?: string | number;
103
+ /** Dữ liệu đang sửa của đối tượng (chỉ để đọc, vd tổng tiền đơn hàng) — tuỳ plugin chủ. */
104
+ record?: Record<string, any>;
105
+ /** Meta hiện tại (đã gồm thay đổi chưa lưu). */
106
+ meta: Record<string, any>;
107
+ /** Đặt meta — plugin chủ lưu cùng đối tượng khi bấm Lưu. */
108
+ setMeta(key: string, value: any): void;
109
+ }
110
+ /** Hộp thêm vào trang sửa đối tượng của plugin khác (CMS ≥ 1.18.0), vd trường tuỳ biến cho đơn hàng. */
111
+ export interface ObjectMetaBox {
112
+ id: string;
113
+ title: string;
114
+ /** Tên đối tượng "{slug}/{name}"; bỏ trống = mọi đối tượng. */
115
+ objects?: string[];
116
+ context?: "main" | "side";
117
+ priority?: number;
118
+ /** Trả false để ẩn hộp với đối tượng này (vd không có nhóm trường nào áp dụng). */
119
+ visible?(props: ObjectMetaBoxProps): boolean;
120
+ component: ComponentType<ObjectMetaBoxProps>;
121
+ }
122
+ /** Chỗ vẽ hộp của plugin khác trong trang sửa đối tượng của mình (plugin chủ dùng). */
123
+ export interface ObjectMetaBoxesProps extends ObjectMetaBoxProps {
124
+ context?: "main" | "side" | "all";
125
+ excludeIds?: string[];
126
+ className?: string;
127
+ }
94
128
  export interface MetaBox {
95
129
  id: string;
96
130
  title: string;
@@ -520,6 +554,8 @@ export interface UiKit {
520
554
  }>;
521
555
  }>;
522
556
  MetaBoxes: ComponentType<MetaBoxesProps>;
557
+ /** Hộp của plugin khác cho đối tượng trong bảng riêng (CMS ≥ 1.18.0). */
558
+ ObjectMetaBoxes?: ComponentType<ObjectMetaBoxesProps>;
523
559
  Slot: ComponentType<{
524
560
  name: string;
525
561
  props?: any;
@@ -686,6 +722,8 @@ export interface CmsAdmin {
686
722
  registerDashboardWidget(widget: DashboardWidget): void;
687
723
  registerPostListColumn(column: PostListColumn): void;
688
724
  registerTermMetaBox(box: TermMetaBox): void;
725
+ registerObjectMetaBox?(box: ObjectMetaBox): void;
726
+ getObjectMetaBoxes?(object?: string): ObjectMetaBox[];
689
727
  registerSlot(slot: AdminSlotItem): void;
690
728
  getSlots(slot: string, postType?: string): Array<AdminSlotItem>;
691
729
  registerPostRowAction(action: PostRowAction): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecomcx/ecomweb-admin-sdk",
3
- "version": "1.28.0",
3
+ "version": "1.30.0",
4
4
  "description": "SDK cho phần admin của plugin: đăng ký trang, meta box, widget dashboard và dùng bộ UI của admin.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",