@enyxs/wikex-components 0.11.20 → 0.11.22

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/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # @enyxs/wikex-components
2
+
3
+ Reusable Material UI blocks with CMS metadata and inline-edit support.
4
+
5
+ ## Included blocks
6
+
7
+ - `hero-banner`
8
+ - `feature-grid`
9
+ - `image-text`
10
+ - `call-to-action`
11
+ - `announcement-bar`
12
+ - `metrics-strip`
13
+ - `testimonial-grid`
14
+ - `faq-section`
15
+ - `pricing-plans`
16
+ - `logo-cloud`
17
+ - `site-header` (Minimal UI)
18
+ - `centered-header` (Minimal UI)
19
+ - `utility-header` (Minimal UI)
20
+ - `site-footer` (Minimal UI)
21
+ - `compact-footer` (Minimal UI)
22
+ - `newsletter-footer` (Minimal UI)
23
+ - `social-footer` (Minimal UI)
24
+ - `download-section` (Wikex)
25
+ - Bộ section Wikex Commodity cho landing, giới thiệu, chính sách, khiếu nại,
26
+ thông tin, thông báo MXV, sản phẩm, biểu phí và coming-soon
27
+
28
+ Các block Wikex Commodity thuộc category `wikex`, cho phép admin hiển thị riêng
29
+ thư viện component của website hàng hóa.
30
+
31
+ Package cũng export `wikexCommodityPageTemplates` và `wikexCommodityRoutes` từ
32
+ entry `@enyxs/wikex-components/page-templates`. Đây là nguồn route/template dùng
33
+ chung giữa frontend và CMS, không kéo Material UI vào code chỉ cần metadata route.
34
+
35
+ Wikex download assets are stored in `src/wikex/assets/download-section/`. Replace the placeholder
36
+ files there, then update `src/wikex/download-assets.ts` if the filenames or formats change.
37
+
38
+ ## Install
39
+
40
+ Before publishing to an npm registry, consume the versioned GitLab package:
41
+
42
+ ```bash
43
+ npm install git+ssh://git@gitlab.com/tamenyxs/wikex-components.git#v0.8.1
44
+ ```
45
+
46
+ ## Use with a CMS registry
47
+
48
+ ```ts
49
+ import { wikexCmsBlocks } from "@enyxs/wikex-components";
50
+
51
+ export const cmsCodeBlocks = [...wikexCmsBlocks];
52
+ ```
53
+
54
+ The package has React, Material UI and Emotion as peer dependencies, so the host app owns their versions.
55
+
56
+ ## Release
57
+
58
+ ```bash
59
+ npm run check
60
+ npm run build
61
+ git tag v0.8.1
62
+ git push origin main --tags
63
+ ```
64
+
65
+
66
+ ### Editable fees and margin table
67
+
68
+ `commodity-fees` supports editing every data cell and column title in CMS preview,
69
+ adding/removing rows and columns with confirmation dialogs, and selecting multiple tags per row with MUI Select.
70
+ Search ignores Vietnamese accents and searches commodity names/codes. Tag and
71
+ search filters are combined before pagination (25 rows per page by default; selectable 5/10/25/50/100/all). Adding a row
72
+ clears filters and opens its page. Deleting all rows keeps the table empty.
73
+
74
+ CMS stores the table as JSON strings in `vi.feesTable` and `en.feesTable`, so the
75
+ existing page save/publish flow persists it without separate database tables.
76
+ Old pages retain their original sample table until edited. Visitors only get
77
+ search, tag filters and pagination, with no editing controls.
78
+
79
+ For another app, import `FeesTable` and `FeesTableData` from
80
+ `@enyxs/wikex-components`. Pass controlled `value`, `onChange`, and `editable`.
81
+ The component supplies its table theme; provide the package's existing icon
82
+ assets for pagination, as with other Wikex components. Run `npm run test:fees`
83
+ for data/search/pagination regression checks.
84
+
85
+ Create tags from the toolbar dialog; unassigned tags persist in the table catalog.
86
+ Editor textareas automatically fit their text. Header actions share an aligned row.
87
+
88
+
89
+ ## Product UI and shared controls
90
+
91
+ Import product UI from `@enyxs/wikex-components/products` and standalone
92
+ `ProductCard`, `Pagination`, `Breadcrumb` (with their prop types) from
93
+ `@enyxs/wikex-components/ui`. These are client entries; the product UI supplies
94
+ its own styled-components theme. Standalone controls use the host's Wikex theme.
95
+ Icons and the default product placeholder are bundled into the package.
96
+
97
+ ```tsx
98
+ import { ProductListing, ProductDetailView, ProductListingSkeleton } from '@enyxs/wikex-components/products';
99
+
100
+ <ProductListing products={items} />
101
+ <ProductDetailView product={detail} related={items} listingHref="/san-pham/" />
102
+ <ProductListingSkeleton language="vi" />
103
+ ```
104
+
105
+ Each list item supplies `href`; the host owns the API, categories, publication
106
+ rules, SEO and route generation. The detail view accepts introduction, contract
107
+ specifications, quality tables (including per-table columns, units, conditions
108
+ and source notes). Pass `language="en"`, `homeHref`, or `placeholderImage` to
109
+ customize navigation, labels and fallback imagery. Product listing renders and
110
+ paginates the supplied public list; category selection belongs to the host menu; no API is called by this UI.
111
+ Existing CMS demo blocks remain available through the root entry.
112
+
113
+ Run `npm run check`, `npm run build`, and `npm run test:products` before packaging.
114
+ ESM and CommonJS builds preserve client directives and matching styled-components
115
+ IDs for server rendering and hydration.
116
+
117
+ ## Fees management UI and shared validation
118
+
119
+ Import `FeesManager` and its prop types from `@enyxs/wikex-components/fees`.
120
+ This controlled screen includes the table selector, language selector, save
121
+ button, notices, row/column counts and the responsive management layout. Supply
122
+ `entries`, `selectedId`, `language`, `table`, `dirtyKeys` (`id:language`),
123
+ `canWrite`, `saving` and the selection/change/save callbacks. The host owns API
124
+ calls, authentication, draft state and navigation warnings. The host may pass
125
+ `statusChipVariant` if its MUI theme supports additional Chip variants.
126
+
127
+ Import pure types, `validateFeesTable`, `defaultFeesTable`, `parseFeesTable`,
128
+ filtering, pagination and ordering helpers from
129
+ `@enyxs/wikex-components/fees/model`. This entry has no React or CMS dependency
130
+ and can run on a backend. Strict validation throws for invalid table data;
131
+ `parseFeesTable` retains public rendering's legacy fallback behavior.
132
+
133
+ ## Consultation forms and management
134
+
135
+ The original landing registration renderer accepts `onConsultationSubmit`, an
136
+ async callback receiving `ConsultationSubmission` exported from the root entry.
137
+ It preserves the existing form style, uses MUI selects and shows accessible
138
+ success/error notices. While sending, fields are disabled; failures retain the
139
+ values and submission ID for idempotent retries. Success clears all fields.
140
+ Editable CMS previews do not submit live requests. The host owns the endpoint,
141
+ validation, authentication and storage. The separate partnership form is unchanged.
142
+
143
+ Use `ConsultationManager` from `@enyxs/wikex-components/consultations` for the
144
+ controlled admin table, filters, pagination, detail/status/notes dialog and delete
145
+ confirmation. Supply data, permissions and API callbacks. Pure models and labels
146
+ are exported from `@enyxs/wikex-components/consultations/model`.
package/dist/index.d.mts CHANGED
@@ -84,6 +84,7 @@ type CmsTextMark = {
84
84
  start: number;
85
85
  end: number;
86
86
  bold?: boolean;
87
+ italic?: boolean;
87
88
  underline?: boolean;
88
89
  href?: string;
89
90
  newTab?: boolean;
@@ -95,7 +96,7 @@ type CmsRichText = {
95
96
  declare function safeCmsTextHref(value: string): string | undefined;
96
97
  declare function parseCmsRichText(value: unknown): CmsRichText | undefined;
97
98
  declare function rebaseCmsRichText(value: unknown, text: string): CmsRichText;
98
- declare function patchCmsRichText(value: unknown, text: string, start: number, end: number, patch: Partial<Pick<CmsTextMark, 'bold' | 'underline' | 'href'>>): CmsRichText;
99
+ declare function patchCmsRichText(value: unknown, text: string, start: number, end: number, patch: Partial<Pick<CmsTextMark, 'bold' | 'italic' | 'underline' | 'href'>>): CmsRichText;
99
100
  declare function renderCmsRichText(children: ReactNode, value: unknown, allowLinks?: boolean): ReactNode;
100
101
 
101
102
  declare const CMS_TEXT_FONTS: {
package/dist/index.d.ts CHANGED
@@ -84,6 +84,7 @@ type CmsTextMark = {
84
84
  start: number;
85
85
  end: number;
86
86
  bold?: boolean;
87
+ italic?: boolean;
87
88
  underline?: boolean;
88
89
  href?: string;
89
90
  newTab?: boolean;
@@ -95,7 +96,7 @@ type CmsRichText = {
95
96
  declare function safeCmsTextHref(value: string): string | undefined;
96
97
  declare function parseCmsRichText(value: unknown): CmsRichText | undefined;
97
98
  declare function rebaseCmsRichText(value: unknown, text: string): CmsRichText;
98
- declare function patchCmsRichText(value: unknown, text: string, start: number, end: number, patch: Partial<Pick<CmsTextMark, 'bold' | 'underline' | 'href'>>): CmsRichText;
99
+ declare function patchCmsRichText(value: unknown, text: string, start: number, end: number, patch: Partial<Pick<CmsTextMark, 'bold' | 'italic' | 'underline' | 'href'>>): CmsRichText;
99
100
  declare function renderCmsRichText(children: ReactNode, value: unknown, allowLinks?: boolean): ReactNode;
100
101
 
101
102
  declare const CMS_TEXT_FONTS: {
package/dist/index.js CHANGED
@@ -383,9 +383,10 @@ function parseCmsRichText(value4) {
383
383
  if (!mark || !Number.isInteger(mark.start) || !Number.isInteger(mark.end) || mark.start < 0 || mark.end <= mark.start || mark.end > raw.text.length) continue;
384
384
  const next = { start: mark.start, end: mark.end };
385
385
  if (typeof mark.bold === "boolean") next.bold = mark.bold;
386
+ if (typeof mark.italic === "boolean") next.italic = mark.italic;
386
387
  if (typeof mark.underline === "boolean") next.underline = mark.underline;
387
388
  if (typeof mark.href === "string") next.href = safeCmsTextHref(mark.href);
388
- if (next.bold !== void 0 || next.underline !== void 0 || next.href) marks.push(next);
389
+ if (next.bold !== void 0 || next.italic !== void 0 || next.underline !== void 0 || next.href) marks.push(next);
389
390
  }
390
391
  return { text: raw.text, marks };
391
392
  }
@@ -421,10 +422,10 @@ function patchCmsRichText(value4, text, start, end, patch) {
421
422
  const style = {};
422
423
  rich.marks.filter((m) => m.start <= a && m.end >= b).forEach((m) => Object.assign(style, m));
423
424
  if (a >= start && b <= end) Object.assign(style, patch);
424
- const next = { start: a, end: b, bold: style.bold, underline: style.underline, newTab: style.newTab, href: style.href ? safeCmsTextHref(style.href) : void 0 };
425
- if (next.bold === void 0 && next.underline === void 0 && !next.href) continue;
425
+ const next = { start: a, end: b, bold: style.bold, italic: style.italic, underline: style.underline, newTab: style.newTab, href: style.href ? safeCmsTextHref(style.href) : void 0 };
426
+ if (next.bold === void 0 && next.italic === void 0 && next.underline === void 0 && !next.href) continue;
426
427
  const previous = marks[marks.length - 1];
427
- if (previous && previous.end === a && previous.bold === next.bold && previous.underline === next.underline && previous.href === next.href && previous.newTab === next.newTab) previous.end = b;
428
+ if (previous && previous.end === a && previous.bold === next.bold && previous.italic === next.italic && previous.underline === next.underline && previous.href === next.href && previous.newTab === next.newTab) previous.end = b;
428
429
  else marks.push(next);
429
430
  }
430
431
  return { text, marks };
@@ -448,9 +449,10 @@ function renderCmsRichText(children, value4, allowLinks = true) {
448
449
  const end = points[index + 1];
449
450
  const mark = Object.assign({}, ...rich.marks.filter((m) => m.start <= start && m.end >= end));
450
451
  const part = text.slice(start - base, end - base);
451
- if (mark.bold === void 0 && mark.underline === void 0 && !mark.href) return part;
452
+ if (mark.bold === void 0 && mark.italic === void 0 && mark.underline === void 0 && !mark.href) return part;
452
453
  const style = {
453
454
  ...mark.bold !== void 0 ? { fontWeight: mark.bold ? 700 : 400 } : {},
455
+ ...mark.italic !== void 0 ? { fontStyle: mark.italic ? "italic" : "normal" } : {},
454
456
  ...mark.underline !== void 0 ? { textDecorationLine: mark.underline ? "underline" : "none" } : {}
455
457
  };
456
458
  return mark.href && links ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: mark.href, target: mark.newTab ? "_blank" : void 0, rel: mark.newTab ? "noopener noreferrer" : void 0, style: { color: "inherit", textDecoration: "underline", ...style }, children: part }, start) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style, children: part }, start);
@@ -16653,7 +16655,7 @@ function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureC
16653
16655
  "data-cms-text-toolbar": true,
16654
16656
  sx: { display: "flex", flexDirection: "column", gap: 0.5, p: 0.75, border: "1px solid", borderColor: "divider", borderRadius: 1, bgcolor: "background.paper", boxShadow: 8, color: "text.primary", maxWidth: "100%" },
16655
16657
  children: [
16656
- /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_material.Box, { sx: { ...groupSx, flexWrap: "wrap", pb: 0.5, borderBottom: "1px solid", borderColor: "divider" }, children: [
16658
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_material.Box, { sx: { ...groupSx, flexWrap: "wrap", "& > .MuiInputBase-root:nth-of-type(-n+2)": { flexGrow: 1 }, pb: 0.5, borderBottom: "1px solid", borderColor: "divider" }, children: [
16657
16659
  /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
16658
16660
  import_material.Select,
16659
16661
  {
@@ -16673,7 +16675,7 @@ function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureC
16673
16675
  ),
16674
16676
  structureControls
16675
16677
  ] }),
16676
- /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_material.Box, { sx: { ...groupSx, flexWrap: "wrap" }, children: [
16678
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_material.Box, { sx: { ...groupSx, flexWrap: "wrap", justifyContent: "space-between" }, children: [
16677
16679
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.Tooltip, { title: "C\u1EE1 ch\u1EEF (px)", ...tooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
16678
16680
  import_material.TextField,
16679
16681
  {
@@ -16725,7 +16727,7 @@ function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureC
16725
16727
  "aria-label": label,
16726
16728
  onMouseDown: (event) => event.preventDefault(),
16727
16729
  onClick: () => onLayoutChange({ textAlign: align }),
16728
- sx: { width: 30, height: 30, p: 0.5, border: 0 },
16730
+ sx: { width: 30, minWidth: 30, height: 30, p: 0.5, border: 0 },
16729
16731
  children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.SvgIcon, { sx: { fontSize: 19 }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: align === "left" ? "M3 4h18v2H3zm0 5h12v2H3zm0 5h18v2H3zm0 5h12v2H3z" : align === "right" ? "M3 4h18v2H3zm6 5h12v2H9zm-6 5h18v2H3zm6 5h12v2H9z" : "M3 4h18v2H3zm3 5h12v2H6zm-3 5h18v2H3zm3 5h12v2H6z" }) })
16730
16732
  }
16731
16733
  ) }, align)) }),
@@ -16746,7 +16748,7 @@ function CmsTextToolbar({ layout, color, colorPicker, inlineControls, structureC
16746
16748
  }
16747
16749
  }
16748
16750
  ),
16749
- /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.Tooltip, { title: "\u0110\u1EB7t l\u1EA1i \u0111\u1ECBnh d\u1EA1ng ch\u1EEF", ...tooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.IconButton, { size: "small", "aria-label": "\u0110\u1EB7t l\u1EA1i \u0111\u1ECBnh d\u1EA1ng ch\u1EEF", onClick: onReset, sx: { width: 30, height: 30, ml: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.SvgIcon, { sx: { fontSize: 19 }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: "m18 4 3 3-9 9-3-3 9-9zM8 14l3 3-3 3H4l-3-3 4-4 3 1zm4 6h10v2H10z" }) }) }) })
16751
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.Tooltip, { title: "\u0110\u1EB7t l\u1EA1i \u0111\u1ECBnh d\u1EA1ng ch\u1EEF", ...tooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.IconButton, { size: "small", "aria-label": "\u0110\u1EB7t l\u1EA1i \u0111\u1ECBnh d\u1EA1ng ch\u1EEF", onClick: onReset, sx: { width: 30, height: 30 }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_material.SvgIcon, { sx: { fontSize: 19 }, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("path", { d: "m18 4 3 3-9 9-3-3 9-9zM8 14l3 3-3 3H4l-3-3 4-4 3 1zm4 6h10v2H10z" }) }) }) })
16750
16752
  ] })
16751
16753
  ]
16752
16754
  }