@enyxs/wikex-components 0.11.39 → 0.11.45

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.
Files changed (55) hide show
  1. package/dist/chrome-model.css +0 -1
  2. package/dist/chrome-model.js +0 -1
  3. package/dist/chrome-model.mjs +0 -1
  4. package/dist/consultation-model.js +0 -1
  5. package/dist/consultation-model.mjs +0 -1
  6. package/dist/consultations.js +0 -1
  7. package/dist/consultations.mjs +0 -1
  8. package/dist/fees-model.d.mts +1 -0
  9. package/dist/fees-model.d.ts +1 -0
  10. package/dist/fees-model.js +7 -5
  11. package/dist/fees-model.mjs +7 -5
  12. package/dist/{fees-table-BxHiMpdc.d.mts → fees-table-BeGo7_0N.d.mts} +1 -1
  13. package/dist/{fees-table-i7g0SHgV.d.ts → fees-table-DdbbVv6r.d.ts} +1 -1
  14. package/dist/fees.d.mts +4 -2
  15. package/dist/fees.d.ts +4 -2
  16. package/dist/fees.js +355 -264
  17. package/dist/fees.mjs +357 -266
  18. package/dist/index.css +0 -1
  19. package/dist/index.d.mts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +315 -205
  22. package/dist/index.mjs +339 -229
  23. package/dist/page-templates.js +0 -1
  24. package/dist/page-templates.mjs +0 -1
  25. package/dist/partner.css +0 -1
  26. package/dist/partner.js +0 -1
  27. package/dist/partner.mjs +0 -1
  28. package/dist/products.js +0 -1
  29. package/dist/products.mjs +0 -1
  30. package/dist/ui.js +0 -1
  31. package/dist/ui.mjs +0 -1
  32. package/package.json +1 -1
  33. package/dist/chrome-model.css.map +0 -1
  34. package/dist/chrome-model.js.map +0 -1
  35. package/dist/chrome-model.mjs.map +0 -1
  36. package/dist/consultation-model.js.map +0 -1
  37. package/dist/consultation-model.mjs.map +0 -1
  38. package/dist/consultations.js.map +0 -1
  39. package/dist/consultations.mjs.map +0 -1
  40. package/dist/fees-model.js.map +0 -1
  41. package/dist/fees-model.mjs.map +0 -1
  42. package/dist/fees.js.map +0 -1
  43. package/dist/fees.mjs.map +0 -1
  44. package/dist/index.css.map +0 -1
  45. package/dist/index.js.map +0 -1
  46. package/dist/index.mjs.map +0 -1
  47. package/dist/page-templates.js.map +0 -1
  48. package/dist/page-templates.mjs.map +0 -1
  49. package/dist/partner.css.map +0 -1
  50. package/dist/partner.js.map +0 -1
  51. package/dist/partner.mjs.map +0 -1
  52. package/dist/products.js.map +0 -1
  53. package/dist/products.mjs.map +0 -1
  54. package/dist/ui.js.map +0 -1
  55. package/dist/ui.mjs.map +0 -1
package/dist/fees.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
 
3
3
  // src/wikex/fees-manager.tsx
4
- import { Alert, Box as Box2, Button as Button4, Card, Chip, Divider, MenuItem as MenuItem4, Stack as Stack3, TextField as TextField4, ToggleButton, ToggleButtonGroup, Typography as Typography3 } from "@mui/material";
4
+ import { Alert, Box as Box2, Button as Button4, Card, Chip, MenuItem as MenuItem4, Stack as Stack3, TextField as TextField4, ToggleButton, ToggleButtonGroup, Typography as Typography3 } from "@mui/material";
5
5
 
6
6
  // src/wikex/fees-table.tsx
7
7
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
- import { useId, useLayoutEffect, useRef as useRef3, useState as useState2 } from "react";
8
+ import { memo, useCallback, useDeferredValue, useId, useLayoutEffect, useMemo, useRef as useRef3, useState as useState2 } from "react";
9
9
  import styled6, { ThemeProvider } from "styled-components";
10
10
  import TextField3 from "@mui/material/TextField";
11
11
  import Dialog from "@mui/material/Dialog";
@@ -19,6 +19,72 @@ import MenuItem3 from "@mui/material/MenuItem";
19
19
  import Checkbox from "@mui/material/Checkbox";
20
20
  import Collapse from "@mui/material/Collapse";
21
21
 
22
+ // src/wikex/fees-cell-layout.ts
23
+ var queues = /* @__PURE__ */ new WeakMap();
24
+ function enqueue(element, queue) {
25
+ queue.pending.add(element);
26
+ if (queue.frame) return;
27
+ const view = element.ownerDocument.defaultView;
28
+ queue.frame = view.requestAnimationFrame(() => {
29
+ queue.frame = 0;
30
+ const cells = [...queue.pending].filter((cell) => cell.isConnected);
31
+ queue.pending.clear();
32
+ for (const cell of cells) cell.style.height = "0px";
33
+ const heights = cells.map((cell) => {
34
+ const style = view.getComputedStyle(cell);
35
+ return cell.scrollHeight + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
36
+ });
37
+ cells.forEach((cell, index) => {
38
+ cell.style.height = `${heights[index]}px`;
39
+ });
40
+ });
41
+ }
42
+ function observeFeesCell(element) {
43
+ const document2 = element.ownerDocument;
44
+ const view = document2.defaultView;
45
+ let queue = queues.get(document2);
46
+ if (!queue) {
47
+ const current2 = {
48
+ elements: /* @__PURE__ */ new Map(),
49
+ pending: /* @__PURE__ */ new Set(),
50
+ frame: 0,
51
+ observer: new view.ResizeObserver((entries) => {
52
+ for (const { target, contentRect } of entries) {
53
+ const cell = target;
54
+ if (current2.elements.get(cell) !== contentRect.width) {
55
+ current2.elements.set(cell, contentRect.width);
56
+ enqueue(cell, current2);
57
+ }
58
+ }
59
+ })
60
+ };
61
+ queue = current2;
62
+ queues.set(document2, current2);
63
+ void document2.fonts.ready.then(() => {
64
+ for (const cell of current2.elements.keys()) enqueue(cell, current2);
65
+ });
66
+ }
67
+ queue.elements.set(element, -1);
68
+ queue.observer.observe(element);
69
+ enqueue(element, queue);
70
+ const current = queue;
71
+ return () => {
72
+ current.observer.unobserve(element);
73
+ current.elements.delete(element);
74
+ current.pending.delete(element);
75
+ if (!current.elements.size) {
76
+ current.observer.disconnect();
77
+ if (current.frame) view.cancelAnimationFrame(current.frame);
78
+ current.frame = 0;
79
+ queues.delete(document2);
80
+ }
81
+ };
82
+ }
83
+ function scheduleFeesCell(element) {
84
+ const queue = queues.get(element.ownerDocument);
85
+ if (queue) enqueue(element, queue);
86
+ }
87
+
22
88
  // src/wikex/fees-typography-controls.tsx
23
89
  import { useEffect, useRef, useState } from "react";
24
90
  import { Box, Button, MenuItem, Stack, TextField, Typography } from "@mui/material";
@@ -64,12 +130,14 @@ var FEES_DEFAULT_API_FIELDS = {
64
130
  function feesColumnApiField(column) {
65
131
  return column.apiField ?? FEES_DEFAULT_API_FIELDS[column.key] ?? "";
66
132
  }
133
+ var feesNumberFormats = { vi: new Intl.NumberFormat("vi-VN", { maximumFractionDigits: 8 }), en: new Intl.NumberFormat("en-US", { maximumFractionDigits: 8 }) };
134
+ var numericFeeFields = new Set(FEES_COMMODITY_FIELDS.filter((field) => field.numeric).map((field) => field.key));
67
135
  function formatFeesApiValue(value, field, language) {
68
136
  if (value === null || value === void 0 || typeof value === "string" && !value.trim()) return " - - ";
69
- if (FEES_COMMODITY_FIELDS.find((item) => item.key === field)?.numeric) {
137
+ if (numericFeeFields.has(field)) {
70
138
  const number = typeof value === "number" ? value : Number(value);
71
139
  if (!Number.isFinite(number)) return " - - ";
72
- return number === 0 ? "0" : new Intl.NumberFormat(language === "vi" ? "vi-VN" : "en-US", { maximumFractionDigits: 8 }).format(number);
140
+ return number === 0 ? "0" : feesNumberFormats[language].format(number);
73
141
  }
74
142
  return String(value);
75
143
  }
@@ -1021,34 +1089,31 @@ var feesTheme = {
1021
1089
  ]))
1022
1090
  };
1023
1091
  var EditorActions = styled6.div.withConfig({
1024
- componentId: "sc-20fe3bfd-0"
1092
+ componentId: "sc-508961e9-0"
1025
1093
  })([
1026
- `display:flex;flex-wrap:wrap;gap:8px;margin-top:16px;`
1094
+ `display:flex;flex-wrap:wrap;gap:6px;margin-top:12px;`
1027
1095
  ]);
1028
1096
  var EditGroup = styled6.div.withConfig({
1029
- componentId: "sc-20fe3bfd-1"
1097
+ componentId: "sc-508961e9-1"
1030
1098
  })([
1031
1099
  `display:flex;flex-direction:column;gap:6px;`
1032
1100
  ]);
1033
1101
  var HeaderGroup = styled6(EditGroup).withConfig({
1034
- componentId: "sc-20fe3bfd-2"
1102
+ componentId: "sc-508961e9-2"
1035
1103
  })([
1036
1104
  `gap:8px;`
1037
1105
  ]);
1038
1106
  var HeaderTitle = styled6.div.withConfig({
1039
- componentId: "sc-20fe3bfd-3"
1107
+ componentId: "sc-508961e9-3"
1040
1108
  })([
1041
1109
  `display:flex;align-items:flex-start;min-height:var(--fees-header-title-height,36px);`
1042
1110
  ]);
1043
- var HeaderActions = styled6.div.withConfig({
1044
- componentId: "sc-20fe3bfd-4"
1045
- })([
1046
- `display:flex;align-items:center;min-height:24px;`
1047
- ]);
1048
1111
  var AlignedFeesTable = styled6(FeesAndMarginTable).withConfig({
1049
- componentId: "sc-20fe3bfd-5"
1112
+ componentId: "sc-508961e9-4"
1050
1113
  })([
1051
- `&[data-editable] th{vertical-align:top;}--fees-row-background:`,
1114
+ `&[data-editable] th{vertical-align:top;}&&&[data-editable] thead > tr > th{font-size:`,
1115
+ `px;line-height:1.4;}&&&[data-editable] tbody > tr > td{font-size:`,
1116
+ `px;line-height:1.4;}--fees-row-background:`,
1052
1117
  `;--fees-stripe-background:`,
1053
1118
  `;--fees-text:`,
1054
1119
  `;:root[data-theme="dark"] &{--fees-row-background:#39393d;--fees-stripe-background:`,
@@ -1071,7 +1136,7 @@ var AlignedFeesTable = styled6(FeesAndMarginTable).withConfig({
1071
1136
  `px;line-height:`,
1072
1137
  `;}thead > tr > th:last-child,tbody > tr > td:last-child{padding-right:12px;}thead > tr > th:first-child,tbody > tr > td:first-child{position:sticky;left:0;padding-left:12px;}thead > tr > th:first-child{z-index:3;background:`,
1073
1138
  `;}tbody > tr > td:first-child{z-index:2;background:var(--fees-row-background);}tbody > tr:nth-child(even) > td:first-child{background:var(--fees-stripe-background);}}}`
1074
- ], ({ theme }) => theme.colors.background.deep, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.accent.foreground, ({ theme }) => theme.colors.background.card, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.accent.foreground, ({ $typography }) => $typography?.thead?.fontSize ?? 10, ({ $typography }) => $typography?.thead?.fontWeight ?? 600, ({ $typography }) => $typography?.thead?.textAlign ?? "left", ({ $typography }) => $typography?.thead?.fontSize ? 1.4 : "14px", ({ $typography }) => $typography?.tbody?.fontSize ?? 12, ({ $typography }) => $typography?.tbody?.fontWeight ?? 500, ({ $typography }) => $typography?.tbody?.textAlign ?? "left", ({ $typography }) => $typography?.tbody?.fontSize ? 1.4 : "16px", ({ $mobileColumnWidths }) => $mobileColumnWidths.reduce((sum, width) => sum + width, 0), ({ $mobileColumnWidths }) => $mobileColumnWidths.map((width, index) => `
1139
+ ], ({ $typography }) => $typography?.thead?.fontSize ?? 12, ({ $typography }) => $typography?.tbody?.fontSize ?? 13, ({ theme }) => theme.colors.background.deep, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.accent.foreground, ({ theme }) => theme.colors.background.card, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.accent.foreground, ({ $typography }) => $typography?.thead?.fontSize ?? 10, ({ $typography }) => $typography?.thead?.fontWeight ?? 600, ({ $typography }) => $typography?.thead?.textAlign ?? "left", ({ $typography }) => $typography?.thead?.fontSize ? 1.4 : "14px", ({ $typography }) => $typography?.tbody?.fontSize ?? 12, ({ $typography }) => $typography?.tbody?.fontWeight ?? 500, ({ $typography }) => $typography?.tbody?.textAlign ?? "left", ({ $typography }) => $typography?.tbody?.fontSize ? 1.4 : "16px", ({ $mobileColumnWidths }) => $mobileColumnWidths.reduce((sum, width) => sum + width, 0), ({ $mobileColumnWidths }) => $mobileColumnWidths.map((width, index) => `
1075
1140
  th:nth-child(${index + 1}), td:nth-child(${index + 1}) {
1076
1141
  width: ${width}px;
1077
1142
  min-width: ${width}px;
@@ -1079,14 +1144,14 @@ var AlignedFeesTable = styled6(FeesAndMarginTable).withConfig({
1079
1144
  }
1080
1145
  `).join(""), ({ $typography }) => $typography?.thead?.fontSize ?? 8, ({ $typography }) => $typography?.thead?.fontSize ? 1.4 : "10px", ({ $typography }) => $typography?.tbody?.fontSize ?? 10, ({ $typography }) => $typography?.tbody?.fontSize ? 1.4 : "14px", ({ theme }) => theme.colors.accent.primary);
1081
1146
  var FeesCellContent = styled6.span.withConfig({
1082
- componentId: "sc-20fe3bfd-6"
1147
+ componentId: "sc-508961e9-5"
1083
1148
  })([
1084
1149
  `display:block;text-align:`,
1085
1150
  `;@media (max-width:767px){text-align:`,
1086
1151
  `;}`
1087
1152
  ], ({ $align, $alignRight }) => $align ?? ($alignRight ? "right" : "left"), ({ $align }) => $align ?? "left");
1088
1153
  var EditorButton = styled6.button.withConfig({
1089
- componentId: "sc-20fe3bfd-7"
1154
+ componentId: "sc-508961e9-6"
1090
1155
  })([
1091
1156
  `padding:7px 12px;border:1px solid `,
1092
1157
  `;border-radius:6px;background:`,
@@ -1095,17 +1160,17 @@ var EditorButton = styled6.button.withConfig({
1095
1160
  `;}&:disabled{cursor:default;opacity:.4;}`
1096
1161
  ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
1097
1162
  var OrderActions = styled6.div.withConfig({
1098
- componentId: "sc-20fe3bfd-8"
1163
+ componentId: "sc-508961e9-7"
1099
1164
  })([
1100
1165
  `display:flex;gap:6px;align-items:center;flex-wrap:wrap;`
1101
1166
  ]);
1102
1167
  var PositionLabel = styled6.label.withConfig({
1103
- componentId: "sc-20fe3bfd-9"
1168
+ componentId: "sc-508961e9-8"
1104
1169
  })([
1105
1170
  `display:inline-flex;align-items:center;gap:6px;font-size:12px;`
1106
1171
  ]);
1107
1172
  var PositionInput = styled6.input.withConfig({
1108
- componentId: "sc-20fe3bfd-10"
1173
+ componentId: "sc-508961e9-9"
1109
1174
  })([
1110
1175
  `width:56px;padding:5px;border:1px solid `,
1111
1176
  `;border-radius:4px;background:`,
@@ -1114,18 +1179,18 @@ var PositionInput = styled6.input.withConfig({
1114
1179
  `;}`
1115
1180
  ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
1116
1181
  var ColumnRow = styled6.div.withConfig({
1117
- componentId: "sc-20fe3bfd-11"
1182
+ componentId: "sc-508961e9-10"
1118
1183
  })([
1119
1184
  `display:flex;gap:12px;align-items:center;margin:16px 0;> textarea{flex:1;min-width:120px;}@media (max-width:600px){align-items:stretch;flex-direction:column;}`
1120
1185
  ]);
1121
1186
  var PaginationControls = styled6(FeesAndMarginPagination).withConfig({
1122
- componentId: "sc-20fe3bfd-12"
1187
+ componentId: "sc-508961e9-11"
1123
1188
  })([
1124
1189
  `align-items:center;flex-wrap:wrap;gap:16px 24px;color:`,
1125
1190
  `;`
1126
1191
  ], ({ theme }) => theme.colors.text.primary);
1127
1192
  var PageSizeLabel = styled6.div.withConfig({
1128
- componentId: "sc-20fe3bfd-13"
1193
+ componentId: "sc-508961e9-12"
1129
1194
  })([
1130
1195
  `display:inline-flex;align-items:center;gap:8px;color:`,
1131
1196
  `;font:inherit;font-size:13px;`
@@ -1153,60 +1218,58 @@ function Position({ value, max, label, onMove }) {
1153
1218
  });
1154
1219
  }
1155
1220
  var DeleteButton = styled6(EditorButton).withConfig({
1156
- componentId: "sc-20fe3bfd-14"
1221
+ componentId: "sc-508961e9-13"
1157
1222
  })([
1158
1223
  `align-self:flex-start;padding:4px 8px;border:0;border-radius:4px;background:#d32f2f;color:#fff;font-size:11px;font-weight:600;line-height:16px;white-space:nowrap;text-decoration:none;&:hover{background:#b71c1c;}&:focus-visible{outline:2px solid #d32f2f;outline-offset:2px;}`
1159
1224
  ]);
1160
1225
  var CellEditorInput = styled6.textarea.withConfig({
1161
- componentId: "sc-20fe3bfd-15"
1226
+ componentId: "sc-508961e9-14"
1162
1227
  })([
1163
1228
  `display:block;box-sizing:border-box;width:100%;min-width:0;padding:3px;border:1px solid transparent;border-radius:3px;color:inherit;background:transparent;font:inherit;line-height:inherit;text-align:inherit;resize:none;overflow:hidden;&:hover{border-color:`,
1164
1229
  `;}&:focus{outline:1px solid `,
1165
1230
  `;}&[data-fees-column-selected="true"]{border-color:`,
1166
1231
  `;}`
1167
1232
  ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.accent.primary);
1168
- function CellEditor({ onInput, ...props }) {
1233
+ function CellEditor({ onInput, layoutKey, ...props }) {
1169
1234
  const ref = useRef3(null);
1170
- const fit = () => {
1171
- const element = ref.current;
1172
- if (!element) return;
1173
- element.style.height = "0px";
1174
- const style = element.ownerDocument.defaultView.getComputedStyle(element);
1175
- const border = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
1176
- element.style.height = `${element.scrollHeight + border}px`;
1177
- };
1178
- useLayoutEffect(fit);
1235
+ useLayoutEffect(() => ref.current ? observeFeesCell(ref.current) : void 0, []);
1179
1236
  useLayoutEffect(() => {
1180
- const element = ref.current;
1181
- if (!element) return;
1182
- let width = element.getBoundingClientRect().width;
1183
- const observer = new ResizeObserver(() => {
1184
- const nextWidth = element.getBoundingClientRect().width;
1185
- if (nextWidth !== width) {
1186
- width = nextWidth;
1187
- fit();
1188
- }
1189
- });
1190
- observer.observe(element);
1191
- let active = true;
1192
- void element.ownerDocument.fonts.ready.then(() => {
1193
- if (active) fit();
1194
- });
1195
- return () => {
1196
- active = false;
1197
- observer.disconnect();
1198
- };
1199
- }, []);
1237
+ if (ref.current) scheduleFeesCell(ref.current);
1238
+ }, [
1239
+ props.value,
1240
+ layoutKey
1241
+ ]);
1200
1242
  return /* @__PURE__ */ _jsx(CellEditorInput, {
1201
1243
  ...props,
1202
1244
  ref,
1203
1245
  rows: 1,
1204
1246
  onInput: (event) => {
1205
- fit();
1247
+ scheduleFeesCell(event.currentTarget);
1206
1248
  onInput?.(event);
1207
1249
  }
1208
1250
  });
1209
1251
  }
1252
+ var ManualCell = /* @__PURE__ */ memo(function ManualCell2({ rowId, columnKey, text, label, align, selected, layoutKey, onEdit }) {
1253
+ return /* @__PURE__ */ _jsx(CellEditor, {
1254
+ value: text,
1255
+ "aria-label": label,
1256
+ style: {
1257
+ textAlign: align ?? "left"
1258
+ },
1259
+ layoutKey,
1260
+ "data-fees-column-selected": selected,
1261
+ onChange: (event) => onEdit(rowId, columnKey, event.target.value)
1262
+ });
1263
+ });
1264
+ var ReadOnlyCell = /* @__PURE__ */ memo(function ReadOnlyCell2({ text, label, align, alignRight, selected }) {
1265
+ return /* @__PURE__ */ _jsx(FeesCellContent, {
1266
+ "aria-label": label,
1267
+ $align: align,
1268
+ $alignRight: alignRight,
1269
+ "data-fees-column-selected": selected || void 0,
1270
+ children: text
1271
+ });
1272
+ });
1210
1273
  function RowTagSelect({ selected, options, onChange, disabled = false }) {
1211
1274
  const selectRoot = useRef3(null);
1212
1275
  return /* @__PURE__ */ _jsx(EditGroup, {
@@ -1220,9 +1283,9 @@ function RowTagSelect({ selected, options, onChange, disabled = false }) {
1220
1283
  value: selected,
1221
1284
  disabled,
1222
1285
  inputProps: {
1223
- "aria-label": "Ch\u1ECDn tag"
1286
+ "aria-label": "Ch\u1ECDn nh\xF3m"
1224
1287
  },
1225
- renderValue: (value) => value.length ? `\u0110\xE3 ch\u1ECDn ${value.length} tag` : "Ch\u1ECDn tag\u2026",
1288
+ renderValue: (value) => value.length ? `\u0110\xE3 ch\u1ECDn ${value.length} nh\xF3m` : "Ch\u1ECDn nh\xF3m\u2026",
1226
1289
  MenuProps: {
1227
1290
  container: () => selectRoot.current?.ownerDocument.body ?? document.body
1228
1291
  },
@@ -1248,13 +1311,53 @@ function RowTagSelect({ selected, options, onChange, disabled = false }) {
1248
1311
  }, item)),
1249
1312
  !options.length && /* @__PURE__ */ _jsx(MenuItem3, {
1250
1313
  disabled: true,
1251
- children: "Ch\u01B0a c\xF3 tag \u2014 d\xF9ng n\xFAt Th\xEAm tag ph\xEDa tr\xEAn"
1314
+ children: "Ch\u01B0a c\xF3 nh\xF3m \u2014 d\xF9ng n\xFAt Th\xEAm nh\xF3m ph\xEDa tr\xEAn"
1252
1315
  })
1253
1316
  ]
1254
1317
  })
1255
1318
  })
1256
1319
  });
1257
1320
  }
1321
+ var ManualRowControls = /* @__PURE__ */ memo(function ManualRowControls2({ id, name, tags, options, index, count, onTags, onMove, onDelete }) {
1322
+ return /* @__PURE__ */ _jsxs(EditGroup, {
1323
+ children: [
1324
+ /* @__PURE__ */ _jsx(RowTagSelect, {
1325
+ selected: tags,
1326
+ options,
1327
+ onChange: (next) => onTags(id, next)
1328
+ }),
1329
+ /* @__PURE__ */ _jsxs(OrderActions, {
1330
+ children: [
1331
+ /* @__PURE__ */ _jsx(Position, {
1332
+ value: index,
1333
+ max: count,
1334
+ label: `V\u1ECB tr\xED d\xF2ng ${name}`,
1335
+ onMove: (to) => onMove(id, to)
1336
+ }),
1337
+ /* @__PURE__ */ _jsx(EditorButton, {
1338
+ type: "button",
1339
+ "aria-label": `\u0110\u01B0a d\xF2ng ${name} l\xEAn`,
1340
+ disabled: index === 0,
1341
+ onClick: () => onMove(id, index - 1),
1342
+ children: "\u2191"
1343
+ }),
1344
+ /* @__PURE__ */ _jsx(EditorButton, {
1345
+ type: "button",
1346
+ "aria-label": `\u0110\u01B0a d\xF2ng ${name} xu\u1ED1ng`,
1347
+ disabled: index === count - 1,
1348
+ onClick: () => onMove(id, index + 1),
1349
+ children: "\u2193"
1350
+ })
1351
+ ]
1352
+ }),
1353
+ /* @__PURE__ */ _jsx(DeleteButton, {
1354
+ type: "button",
1355
+ onClick: () => onDelete(id, name || "H\xE0ng m\u1EDBi"),
1356
+ children: "X\xF3a h\xE0ng"
1357
+ })
1358
+ ]
1359
+ });
1360
+ });
1258
1361
  var columnWidths = {
1259
1362
  name: 100,
1260
1363
  code: 96,
@@ -1295,8 +1398,9 @@ var rightAlignedColumns = /* @__PURE__ */ new Set([
1295
1398
  "priceUnit",
1296
1399
  "unit"
1297
1400
  ]);
1298
- function FeesTable({ value, editable = false, onChange, labels: labels2, size = "md", tagOrder = [], language = "vi" }) {
1401
+ var FeesTable = /* @__PURE__ */ memo(function FeesTable2({ value, editable = false, onChange, labels: labels2, size = "md", tagOrder = [], language = "vi" }) {
1299
1402
  const [search, setSearch] = useState2("");
1403
+ const deferredSearch = useDeferredValue(search);
1300
1404
  const [tag, setTag] = useState2("");
1301
1405
  const [page, setPage] = useState2(1);
1302
1406
  const [pageSize, setPageSize] = useState2(FEES_PAGE_SIZE);
@@ -1305,11 +1409,38 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1305
1409
  const [columnTitle, setColumnTitle] = useState2("");
1306
1410
  const [columnField, setColumnField] = useState2("");
1307
1411
  const [typographyOpen, setTypographyOpen] = useState2(false);
1412
+ const [alignmentOpen, setAlignmentOpen] = useState2(false);
1308
1413
  const [selectedColumnKey, setSelectedColumnKey] = useState2("");
1309
1414
  const english = language === "en";
1310
1415
  const canEdit = editable && Boolean(onChange);
1311
1416
  const apiManaged = value.dataSource === "wikex-api";
1312
- const visibleColumns = value.columns.filter((column) => !column.hidden);
1417
+ const visibleColumns = useMemo(() => value.columns.filter((column) => !column.hidden), [
1418
+ value.columns
1419
+ ]);
1420
+ const latest = useRef3({
1421
+ value,
1422
+ onChange
1423
+ });
1424
+ latest.current = {
1425
+ value,
1426
+ onChange
1427
+ };
1428
+ const editCell = useCallback((rowId, key, text) => {
1429
+ const { value: value2, onChange: onChange2 } = latest.current;
1430
+ if (value2.dataSource === "wikex-api") return;
1431
+ onChange2?.({
1432
+ ...value2,
1433
+ rows: value2.rows.map((row) => row.id === rowId ? {
1434
+ ...row,
1435
+ cells: {
1436
+ ...row.cells,
1437
+ [key]: text
1438
+ }
1439
+ } : row)
1440
+ });
1441
+ }, []);
1442
+ const headerLayout = JSON.stringify(value.typography?.thead ?? {});
1443
+ const bodyLayout = JSON.stringify(value.typography?.tbody ?? {});
1313
1444
  const tableRoot = useRef3(null);
1314
1445
  useLayoutEffect(() => {
1315
1446
  const root = tableRoot.current;
@@ -1366,10 +1497,19 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1366
1497
  ...value.rows.flatMap((row) => row.tags)
1367
1498
  ])
1368
1499
  ].filter(Boolean);
1369
- const tags = [
1500
+ const orderedTags = [
1370
1501
  ...tagOrder.filter((item) => rowTags.includes(item)),
1371
1502
  ...rowTags.filter((item) => !tagOrder.includes(item))
1372
1503
  ];
1504
+ const stableTags = useRef3([]);
1505
+ if (orderedTags.length !== stableTags.current.length || orderedTags.some((tag2, index) => tag2 !== stableTags.current[index])) stableTags.current = orderedTags;
1506
+ const tags = stableTags.current;
1507
+ const rowPositions = useMemo(() => new Map(value.rows.map((row, index) => [
1508
+ row.id,
1509
+ index
1510
+ ])), [
1511
+ value.rows
1512
+ ]);
1373
1513
  const newTagName = tagDraft.trim().replace(/\s+/g, " ");
1374
1514
  const duplicateTag = tags.some((item) => item.toLocaleLowerCase("vi") === newTagName.toLocaleLowerCase("vi"));
1375
1515
  const createTag = () => {
@@ -1385,9 +1525,21 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1385
1525
  setTagDraft("");
1386
1526
  };
1387
1527
  const activeTag = tags.includes(tag) ? tag : "";
1388
- const filtered = filterFeesRows(value, search, activeTag);
1389
- const displayedRows = canEdit ? filtered : sortFeesRowsByName(filtered, language);
1390
- const pagination = paginateFeesRows(displayedRows, page, pageSize);
1528
+ const filtered = useMemo(() => filterFeesRows(value, deferredSearch, activeTag), [
1529
+ value,
1530
+ deferredSearch,
1531
+ activeTag
1532
+ ]);
1533
+ const displayedRows = useMemo(() => canEdit ? filtered : sortFeesRowsByName(filtered, language), [
1534
+ canEdit,
1535
+ filtered,
1536
+ language
1537
+ ]);
1538
+ const pagination = useMemo(() => paginateFeesRows(displayedRows, page, pageSize), [
1539
+ displayedRows,
1540
+ page,
1541
+ pageSize
1542
+ ]);
1391
1543
  const selectedColumn = value.columns.find((column) => column.key === selectedColumnKey);
1392
1544
  useLayoutEffect(() => {
1393
1545
  if (selectedColumnKey && !selectedColumn) setSelectedColumnKey("");
@@ -1409,6 +1561,25 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1409
1561
  const index = rows.filter((row) => filteredIds.has(row.id)).findIndex((row) => row.id === id);
1410
1562
  setPage(pageSize === -1 ? 1 : Math.floor(Math.max(0, index) / pageSize) + 1);
1411
1563
  };
1564
+ const moveRowRef = useRef3(moveRow);
1565
+ moveRowRef.current = moveRow;
1566
+ const moveManualRow = useCallback((id, position) => moveRowRef.current(id, position), []);
1567
+ const deleteManualRow = useCallback((id, name) => setDeleteTarget({
1568
+ kind: "row",
1569
+ id,
1570
+ label: name
1571
+ }), []);
1572
+ const tagManualRow = useCallback((id, tags2) => {
1573
+ const { value: value2, onChange: onChange2 } = latest.current;
1574
+ if (value2.dataSource === "wikex-api") return;
1575
+ onChange2?.({
1576
+ ...value2,
1577
+ rows: value2.rows.map((row) => row.id === id ? {
1578
+ ...row,
1579
+ tags: tags2
1580
+ } : row)
1581
+ });
1582
+ }, []);
1412
1583
  const addColumn = () => {
1413
1584
  if (apiManaged) {
1414
1585
  setColumnTitle("");
@@ -1452,140 +1623,70 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1452
1623
  onChange?.(setFeesColumnApiField(next, key, columnField, language));
1453
1624
  setAddColumnOpen(false);
1454
1625
  };
1455
- const changeRow = (id, patch) => {
1456
- if (apiManaged) return;
1457
- onChange?.({
1458
- ...value,
1459
- rows: value.rows.map((row) => row.id === id ? {
1460
- ...row,
1461
- ...patch
1462
- } : row)
1463
- });
1464
- };
1465
1626
  const columns = visibleColumns.map((column, index) => ({
1466
1627
  key: column.key,
1467
1628
  width: canEdit ? columnWidths[column.key] ?? 140 : index === 0 ? 178 : 170,
1468
1629
  fixed: index === 0 ? "left" : void 0,
1469
- title: canEdit ? /* @__PURE__ */ _jsxs(HeaderGroup, {
1470
- children: [
1471
- /* @__PURE__ */ _jsx(HeaderTitle, {
1472
- children: /* @__PURE__ */ _jsx(CellEditor, {
1473
- rows: 2,
1474
- value: column.title,
1475
- "aria-label": `Ti\xEAu \u0111\u1EC1 c\u1ED9t ${index + 1}`,
1476
- style: {
1477
- textAlign: column.textAlign ?? value.typography?.thead?.textAlign ?? "left"
1478
- },
1479
- "data-fees-column-selected": selectedColumnKey === column.key,
1480
- onChange: (event) => onChange?.({
1481
- ...value,
1482
- columns: value.columns.map((item) => item.key === column.key ? {
1483
- ...item,
1484
- title: event.target.value
1485
- } : item)
1486
- })
1487
- })
1488
- }),
1489
- /* @__PURE__ */ _jsx(HeaderActions, {
1490
- children: column.key !== "name" && /* @__PURE__ */ _jsx(DeleteButton, {
1491
- type: "button",
1492
- onClick: () => {
1493
- setDeleteTarget({
1494
- kind: "column",
1495
- id: column.key,
1496
- label: column.title
1497
- });
1498
- },
1499
- children: "X\xF3a c\u1ED9t"
1630
+ title: canEdit ? /* @__PURE__ */ _jsx(HeaderGroup, {
1631
+ children: /* @__PURE__ */ _jsx(HeaderTitle, {
1632
+ children: /* @__PURE__ */ _jsx(CellEditor, {
1633
+ rows: 2,
1634
+ layoutKey: headerLayout,
1635
+ value: column.title,
1636
+ "aria-label": `Ti\xEAu \u0111\u1EC1 c\u1ED9t ${index + 1}`,
1637
+ style: {
1638
+ textAlign: column.textAlign ?? value.typography?.thead?.textAlign ?? "left"
1639
+ },
1640
+ "data-fees-column-selected": selectedColumnKey === column.key,
1641
+ onChange: (event) => onChange?.({
1642
+ ...value,
1643
+ columns: value.columns.map((item) => item.key === column.key ? {
1644
+ ...item,
1645
+ title: event.target.value
1646
+ } : item)
1500
1647
  })
1501
1648
  })
1502
- ]
1649
+ })
1503
1650
  }) : /* @__PURE__ */ _jsx(FeesCellContent, {
1504
1651
  $align: column.textAlign ?? value.typography?.thead?.textAlign,
1505
1652
  $alignRight: rightAlignedColumns.has(column.key),
1506
1653
  children: column.title
1507
1654
  }),
1508
- render: (_unused, row) => canEdit ? /* @__PURE__ */ _jsx(CellEditor, {
1509
- rows: Math.max(2, (row.cells[column.key] ?? "").split("\n").length),
1510
- value: row.cells[column.key] || (apiManaged ? " - - " : ""),
1511
- "aria-label": `${column.title} \u2014 ${row.cells.name || "H\xE0ng m\u1EDBi"}`,
1512
- readOnly: apiManaged,
1513
- style: {
1514
- textAlign: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign ?? "left"
1515
- },
1516
- "data-fees-column-selected": selectedColumnKey === column.key,
1517
- onChange: (event) => {
1518
- if (!apiManaged) changeRow(row.id, {
1519
- cells: {
1520
- ...row.cells,
1521
- [column.key]: event.target.value
1522
- }
1523
- });
1524
- }
1525
- }) : /* @__PURE__ */ _jsx(FeesCellContent, {
1526
- $align: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign,
1527
- $alignRight: rightAlignedColumns.has(column.key),
1528
- children: row.cells[column.key] || (apiManaged ? " - - " : "")
1655
+ render: (_unused, row) => canEdit && !apiManaged ? /* @__PURE__ */ _jsx(ManualCell, {
1656
+ rowId: row.id,
1657
+ columnKey: column.key,
1658
+ text: row.cells[column.key] ?? "",
1659
+ label: `${column.title} \u2014 ${row.cells.name || "H\xE0ng m\u1EDBi"}`,
1660
+ align: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign,
1661
+ selected: selectedColumnKey === column.key,
1662
+ layoutKey: bodyLayout,
1663
+ onEdit: editCell
1664
+ }) : /* @__PURE__ */ _jsx(ReadOnlyCell, {
1665
+ text: row.cells[column.key] || (apiManaged ? " - - " : ""),
1666
+ label: canEdit ? `${column.title} \u2014 ${row.cells.name || "H\xE0ng m\u1EDBi"}` : void 0,
1667
+ align: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign,
1668
+ alignRight: rightAlignedColumns.has(column.key),
1669
+ selected: canEdit && selectedColumnKey === column.key
1529
1670
  })
1530
1671
  }));
1531
- if (canEdit) columns.push({
1672
+ if (canEdit && !apiManaged) columns.push({
1532
1673
  key: "__tags",
1533
- title: /* @__PURE__ */ _jsxs(HeaderGroup, {
1534
- children: [
1535
- /* @__PURE__ */ _jsx(HeaderTitle, {
1536
- children: "Tag & th\u1EE9 t\u1EF1 d\xF2ng"
1537
- }),
1538
- /* @__PURE__ */ _jsx(HeaderActions, {})
1539
- ]
1674
+ title: /* @__PURE__ */ _jsx(HeaderGroup, {
1675
+ children: /* @__PURE__ */ _jsx(HeaderTitle, {
1676
+ children: "Nh\xF3m & th\u1EE9 t\u1EF1 d\xF2ng"
1677
+ })
1540
1678
  }),
1541
1679
  width: 300,
1542
- render: (_unused, row) => /* @__PURE__ */ _jsxs(EditGroup, {
1543
- children: [
1544
- /* @__PURE__ */ _jsx(RowTagSelect, {
1545
- disabled: apiManaged,
1546
- selected: row.tags,
1547
- options: tags,
1548
- onChange: (next) => changeRow(row.id, {
1549
- tags: next
1550
- })
1551
- }),
1552
- /* @__PURE__ */ _jsxs(OrderActions, {
1553
- children: [
1554
- /* @__PURE__ */ _jsx(Position, {
1555
- value: value.rows.findIndex((item) => item.id === row.id),
1556
- max: value.rows.length,
1557
- label: `V\u1ECB tr\xED d\xF2ng ${row.cells.name}`,
1558
- onMove: (to) => moveRow(row.id, to)
1559
- }),
1560
- /* @__PURE__ */ _jsx(EditorButton, {
1561
- type: "button",
1562
- "aria-label": `\u0110\u01B0a d\xF2ng ${row.cells.name} l\xEAn`,
1563
- disabled: value.rows[0]?.id === row.id,
1564
- onClick: () => moveRow(row.id, value.rows.findIndex((item) => item.id === row.id) - 1),
1565
- children: "\u2191"
1566
- }),
1567
- /* @__PURE__ */ _jsx(EditorButton, {
1568
- type: "button",
1569
- "aria-label": `\u0110\u01B0a d\xF2ng ${row.cells.name} xu\u1ED1ng`,
1570
- disabled: value.rows[value.rows.length - 1]?.id === row.id,
1571
- onClick: () => moveRow(row.id, value.rows.findIndex((item) => item.id === row.id) + 1),
1572
- children: "\u2193"
1573
- })
1574
- ]
1575
- }),
1576
- /* @__PURE__ */ _jsx(DeleteButton, {
1577
- type: "button",
1578
- disabled: apiManaged,
1579
- onClick: () => {
1580
- setDeleteTarget({
1581
- kind: "row",
1582
- id: row.id,
1583
- label: row.cells.name || "H\xE0ng m\u1EDBi"
1584
- });
1585
- },
1586
- children: "X\xF3a h\xE0ng"
1587
- })
1588
- ]
1680
+ render: (_unused, row) => /* @__PURE__ */ _jsx(ManualRowControls, {
1681
+ id: row.id,
1682
+ name: row.cells.name || "",
1683
+ tags: row.tags,
1684
+ options: tags,
1685
+ index: rowPositions.get(row.id) ?? 0,
1686
+ count: value.rows.length,
1687
+ onTags: tagManualRow,
1688
+ onMove: moveManualRow,
1689
+ onDelete: deleteManualRow
1589
1690
  })
1590
1691
  });
1591
1692
  return /* @__PURE__ */ _jsx(ThemeProvider, {
@@ -1593,6 +1694,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1593
1694
  children: /* @__PURE__ */ _jsxs("div", {
1594
1695
  ref: tableRoot,
1595
1696
  "data-cms-table-editor": true,
1697
+ "data-editable": canEdit || void 0,
1596
1698
  onClick: (event) => {
1597
1699
  if (canEdit) event.stopPropagation();
1598
1700
  },
@@ -1606,7 +1708,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1606
1708
  minWidth: 0
1607
1709
  },
1608
1710
  children: /* @__PURE__ */ _jsx(TabCommon, {
1609
- ariaLabel: "L\u1ECDc theo tag",
1711
+ ariaLabel: "L\u1ECDc theo nh\xF3m",
1610
1712
  size,
1611
1713
  items: [
1612
1714
  {
@@ -1654,9 +1756,8 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1654
1756
  },
1655
1757
  children: english ? "Sort names A\u2013Z" : "S\u1EAFp x\u1EBFp t\xEAn A\u2013Z"
1656
1758
  }),
1657
- /* @__PURE__ */ _jsx(EditorButton, {
1759
+ !apiManaged && /* @__PURE__ */ _jsx(EditorButton, {
1658
1760
  type: "button",
1659
- disabled: apiManaged,
1660
1761
  onClick: () => {
1661
1762
  const row = {
1662
1763
  id: crypto.randomUUID(),
@@ -1702,12 +1803,17 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1702
1803
  }),
1703
1804
  /* @__PURE__ */ _jsx(EditorButton, {
1704
1805
  type: "button",
1705
- disabled: apiManaged,
1806
+ "aria-expanded": alignmentOpen,
1807
+ onClick: () => setAlignmentOpen((open) => !open),
1808
+ children: english ? "Alignment" : "C\u0103n l\u1EC1"
1809
+ }),
1810
+ !apiManaged && /* @__PURE__ */ _jsx(EditorButton, {
1811
+ type: "button",
1706
1812
  onClick: () => {
1707
1813
  setTagDraft("");
1708
1814
  setCreateTagOpen(true);
1709
1815
  },
1710
- children: "+ Th\xEAm tag"
1816
+ children: "+ Th\xEAm nh\xF3m"
1711
1817
  })
1712
1818
  ]
1713
1819
  }),
@@ -1730,14 +1836,18 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1730
1836
  })
1731
1837
  })
1732
1838
  }),
1733
- canEdit && /* @__PURE__ */ _jsx(FeesColumnAlignmentControls, {
1734
- columns: value.columns,
1735
- columnKey: selectedColumnKey,
1736
- english,
1737
- onSelectColumn: setSelectedColumnKey,
1738
- onChange: (textAlign) => {
1739
- if (selectedColumn) onChange?.(setFeesColumnAlignment(value, selectedColumn.key, textAlign));
1740
- }
1839
+ canEdit && /* @__PURE__ */ _jsx(Collapse, {
1840
+ in: alignmentOpen,
1841
+ unmountOnExit: true,
1842
+ children: /* @__PURE__ */ _jsx(FeesColumnAlignmentControls, {
1843
+ columns: value.columns,
1844
+ columnKey: selectedColumnKey,
1845
+ english,
1846
+ onSelectColumn: setSelectedColumnKey,
1847
+ onChange: (textAlign) => {
1848
+ if (selectedColumn) onChange?.(setFeesColumnAlignment(value, selectedColumn.key, textAlign));
1849
+ }
1850
+ })
1741
1851
  }),
1742
1852
  /* @__PURE__ */ _jsx(AlignedFeesTable, {
1743
1853
  $typography: value.typography,
@@ -1751,7 +1861,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1751
1861
  size,
1752
1862
  empty: labels2?.empty ?? "Kh\xF4ng t\xECm th\u1EA5y h\xE0ng h\xF3a",
1753
1863
  scroll: {
1754
- x: canEdit ? Math.max(1440, value.columns.reduce((sum, column) => sum + (columnWidths[column.key] ?? 140), 0) + 300) : visibleColumns.length * 170 + 8
1864
+ x: canEdit ? Math.max(apiManaged ? 900 : 1100, columns.reduce((sum, column) => sum + (typeof column.width === "number" ? column.width : 140), 0)) : visibleColumns.length * 170 + 8
1755
1865
  }
1756
1866
  })
1757
1867
  }),
@@ -2082,18 +2192,18 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
2082
2192
  children: [
2083
2193
  /* @__PURE__ */ _jsx(DialogTitle, {
2084
2194
  id: `${dialogId}-create-tag-title`,
2085
- children: "T\u1EA1o tag m\u1EDBi"
2195
+ children: "T\u1EA1o nh\xF3m m\u1EDBi"
2086
2196
  }),
2087
2197
  /* @__PURE__ */ _jsx(DialogContent, {
2088
2198
  children: /* @__PURE__ */ _jsx(TextField3, {
2089
2199
  autoFocus: true,
2090
2200
  fullWidth: true,
2091
2201
  margin: "dense",
2092
- label: "T\xEAn tag",
2202
+ label: "T\xEAn nh\xF3m",
2093
2203
  value: tagDraft,
2094
2204
  onChange: (event) => setTagDraft(event.target.value),
2095
2205
  error: duplicateTag,
2096
- helperText: duplicateTag ? "Tag n\xE0y \u0111\xE3 t\u1ED3n t\u1EA1i." : "Tag m\u1EDBi s\u1EBD c\xF3 trong danh s\xE1ch ch\u1ECDn c\u1EE7a t\u1EA5t c\u1EA3 h\xE0ng.",
2206
+ helperText: duplicateTag ? "Nh\xF3m n\xE0y \u0111\xE3 t\u1ED3n t\u1EA1i." : "Nh\xF3m m\u1EDBi s\u1EBD c\xF3 trong danh s\xE1ch ch\u1ECDn c\u1EE7a t\u1EA5t c\u1EA3 h\xE0ng.",
2097
2207
  onKeyDown: (event) => {
2098
2208
  if (event.key === "Enter") {
2099
2209
  event.preventDefault();
@@ -2112,7 +2222,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
2112
2222
  variant: "contained",
2113
2223
  disabled: !newTagName || duplicateTag,
2114
2224
  onClick: createTag,
2115
- children: "T\u1EA1o tag"
2225
+ children: "T\u1EA1o nh\xF3m"
2116
2226
  })
2117
2227
  ]
2118
2228
  })
@@ -2164,7 +2274,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
2164
2274
  ]
2165
2275
  })
2166
2276
  });
2167
- }
2277
+ });
2168
2278
 
2169
2279
  // src/wikex/fees-manager.tsx
2170
2280
  import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
@@ -2179,6 +2289,8 @@ function FeesManager({
2179
2289
  notice,
2180
2290
  parseError,
2181
2291
  dataSourceControls,
2292
+ sourceControl,
2293
+ headerActions,
2182
2294
  statusChipVariant = "filled",
2183
2295
  onSelectEntry,
2184
2296
  onSelectLanguage,
@@ -2188,14 +2300,14 @@ function FeesManager({
2188
2300
  }) {
2189
2301
  const entry = entries.find((item) => item.id === selectedId);
2190
2302
  const key = `${selectedId}:${language}`;
2191
- return /* @__PURE__ */ jsxs7(Stack3, { spacing: 3, sx: { minWidth: 0, width: 1 }, children: [
2192
- /* @__PURE__ */ jsxs7(Stack3, { direction: { xs: "column", md: "row" }, justifyContent: "space-between", alignItems: { md: "center" }, gap: 2.5, children: [
2193
- /* @__PURE__ */ jsxs7(Stack3, { spacing: 1, sx: { minWidth: 0, maxWidth: 720 }, children: [
2303
+ return /* @__PURE__ */ jsxs7(Stack3, { spacing: 2, sx: { minWidth: 0, width: 1 }, children: [
2304
+ /* @__PURE__ */ jsxs7(Stack3, { direction: { xs: "column", sm: "row" }, justifyContent: "space-between", alignItems: { sm: "center" }, gap: 1.5, children: [
2305
+ /* @__PURE__ */ jsxs7(Stack3, { spacing: 0.5, children: [
2194
2306
  /* @__PURE__ */ jsx7(Typography3, { variant: "h4", children: "Ph\xED & k\xFD qu\u1EF9" }),
2195
- /* @__PURE__ */ jsx7(Typography3, { variant: "body2", color: "text.secondary", children: "Qu\u1EA3n l\xFD d\u1EEF li\u1EC7u, tag v\xE0 th\u1EE9 t\u1EF1 hi\u1EC3n th\u1ECB. B\u1ED1 c\u1EE5c v\xE0 n\u1ED9i dung gi\u1EDBi thi\u1EC7u \u0111\u01B0\u1EE3c ch\u1EC9nh trong Layout trang t\u0129nh." })
2307
+ /* @__PURE__ */ jsx7(Typography3, { variant: "body2", color: "text.secondary", children: "Thay \u0111\u1ED5i t\u1EF1 l\u01B0u nh\xE1p. L\u01B0u b\u1EA3ng ph\xED \u0111\u1EC3 \xE1p d\u1EE5ng l\xEAn website." })
2196
2308
  ] }),
2197
- /* @__PURE__ */ jsxs7(Stack3, { direction: "row", spacing: 1.5, alignItems: "center", flexShrink: 0, children: [
2198
- dirtyKeys.includes(key) && /* @__PURE__ */ jsx7(Chip, { size: "small", color: "warning", label: "Ch\u01B0a l\u01B0u" }),
2309
+ /* @__PURE__ */ jsxs7(Stack3, { direction: "row", spacing: 1, alignItems: "center", flexShrink: 0, justifyContent: "flex-end", children: [
2310
+ headerActions,
2199
2311
  /* @__PURE__ */ jsx7(
2200
2312
  Button4,
2201
2313
  {
@@ -2203,21 +2315,17 @@ function FeesManager({
2203
2315
  loading: saving,
2204
2316
  disabled: !canWrite || !dirtyKeys.includes(key) || saving,
2205
2317
  onClick: onSave,
2206
- sx: { minHeight: 44, px: 3, flex: { xs: 1, md: "initial" }, minWidth: { md: 156 } },
2318
+ sx: { minHeight: 40, px: 2.5 },
2207
2319
  children: "L\u01B0u b\u1EA3ng ph\xED"
2208
2320
  }
2209
2321
  )
2210
2322
  ] })
2211
2323
  ] }),
2212
- !canWrite && /* @__PURE__ */ jsx7(Alert, { severity: "info", children: "B\u1EA1n c\xF3 quy\u1EC1n xem b\u1EA3ng ph\xED. C\u1EA7n quy\u1EC1n s\u1EEDa n\u1ED9i dung \u0111\u1EC3 thay \u0111\u1ED5i d\u1EEF li\u1EC7u." }),
2324
+ !canWrite && /* @__PURE__ */ jsx7(Alert, { severity: "info", children: "B\u1EA1n c\xF3 quy\u1EC1n xem. C\u1EA7n quy\u1EC1n s\u1EEDa n\u1ED9i dung \u0111\u1EC3 thay \u0111\u1ED5i b\u1EA3ng ph\xED." }),
2213
2325
  notice && /* @__PURE__ */ jsx7(Alert, { severity: notice.severity, onClose: onDismissNotice, children: notice.message }),
2214
- !entries.length ? /* @__PURE__ */ jsx7(Alert, { severity: "info", children: "Ch\u01B0a c\xF3 b\u1EA3ng ph\xED. Th\xEAm component B\u1EA3ng ph\xED & K\xFD qu\u1EF9 v\xE0o m\u1ED9t trang trong Layout trang t\u0129nh \u0111\u1EC3 b\u1EAFt \u0111\u1EA7u." }) : /* @__PURE__ */ jsxs7(Fragment2, { children: [
2215
- /* @__PURE__ */ jsx7(Card, { variant: "outlined", sx: { p: { xs: 2.5, md: 3 }, boxShadow: "none" }, children: /* @__PURE__ */ jsxs7(Stack3, { spacing: 2.5, children: [
2216
- /* @__PURE__ */ jsxs7(Stack3, { direction: "row", alignItems: "center", justifyContent: "space-between", gap: 1.5, flexWrap: "wrap", children: [
2217
- /* @__PURE__ */ jsx7(Typography3, { variant: "subtitle1", children: "B\u1EA3ng \u0111ang qu\u1EA3n l\xFD" }),
2218
- /* @__PURE__ */ jsx7(Chip, { size: "small", variant: statusChipVariant, label: entry?.status === "published" ? "Trang \u0111\xE3 xu\u1EA5t b\u1EA3n" : "Trang b\u1EA3n nh\xE1p", color: entry?.status === "published" ? "success" : "default" })
2219
- ] }),
2220
- /* @__PURE__ */ jsxs7(Stack3, { direction: { xs: "column", md: "row" }, spacing: 2.5, alignItems: { md: "flex-end" }, children: [
2326
+ !entries.length ? /* @__PURE__ */ jsx7(Alert, { severity: "info", children: "Th\xEAm b\u1EA3ng ph\xED v\xE0o m\u1ED9t trang trong Layout trang t\u0129nh \u0111\u1EC3 b\u1EAFt \u0111\u1EA7u." }) : /* @__PURE__ */ jsxs7(Fragment2, { children: [
2327
+ /* @__PURE__ */ jsxs7(Card, { variant: "outlined", sx: { boxShadow: "none", overflow: "visible" }, children: [
2328
+ /* @__PURE__ */ jsxs7(Box2, { sx: { p: 2, display: "grid", gridTemplateColumns: { xs: "minmax(0, 1fr)", md: sourceControl ? "minmax(220px, 1fr) minmax(220px, 280px) auto" : "minmax(220px, 1fr) auto" }, gap: 2, alignItems: "end" }, children: [
2221
2329
  /* @__PURE__ */ jsx7(
2222
2330
  TextField4,
2223
2331
  {
@@ -2227,65 +2335,49 @@ function FeesManager({
2227
2335
  value: selectedId,
2228
2336
  disabled: saving,
2229
2337
  fullWidth: true,
2230
- sx: { flex: 1, minWidth: 0 },
2231
2338
  onChange: (event) => onSelectEntry(event.target.value),
2232
2339
  children: entries.map((item, index) => /* @__PURE__ */ jsxs7(MenuItem4, { value: item.id, children: [
2233
2340
  item.pageTitle,
2234
2341
  " \xB7 /",
2235
2342
  item.slug,
2236
2343
  " \xB7 #",
2237
- index + 1,
2238
- dirtyKeys.some((draft) => draft.startsWith(`${item.id}:`)) ? " (ch\u01B0a l\u01B0u)" : ""
2344
+ index + 1
2239
2345
  ] }, item.id))
2240
2346
  }
2241
2347
  ),
2242
- /* @__PURE__ */ jsxs7(Stack3, { spacing: 1, sx: { width: { xs: 1, md: 240 }, flexShrink: 0 }, children: [
2243
- /* @__PURE__ */ jsx7(Typography3, { variant: "caption", color: "text.secondary", children: "Ng\xF4n ng\u1EEF n\u1ED9i dung" }),
2244
- /* @__PURE__ */ jsxs7(
2245
- ToggleButtonGroup,
2246
- {
2247
- size: "small",
2248
- exclusive: true,
2249
- value: language,
2250
- disabled: saving,
2251
- "aria-label": "Ng\xF4n ng\u1EEF b\u1EA3ng ph\xED",
2252
- sx: { minHeight: 40, "& .MuiToggleButton-root": { flex: 1, px: 2 } },
2253
- onChange: (_, next) => {
2254
- if (next === "vi" || next === "en") onSelectLanguage(next);
2255
- },
2256
- children: [
2257
- /* @__PURE__ */ jsxs7(ToggleButton, { value: "vi", children: [
2258
- "Ti\u1EBFng Vi\u1EC7t",
2259
- dirtyKeys.includes(`${selectedId}:vi`) ? " \u2022" : ""
2260
- ] }),
2261
- /* @__PURE__ */ jsxs7(ToggleButton, { value: "en", children: [
2262
- "English",
2263
- dirtyKeys.includes(`${selectedId}:en`) ? " \u2022" : ""
2264
- ] })
2265
- ]
2266
- }
2267
- )
2268
- ] })
2269
- ] })
2270
- ] }) }),
2271
- dataSourceControls,
2348
+ sourceControl,
2349
+ /* @__PURE__ */ jsxs7(
2350
+ ToggleButtonGroup,
2351
+ {
2352
+ size: "small",
2353
+ exclusive: true,
2354
+ value: language,
2355
+ disabled: saving,
2356
+ "aria-label": "Ng\xF4n ng\u1EEF b\u1EA3ng ph\xED",
2357
+ sx: { minHeight: 40, minWidth: { md: 200 }, "& .MuiToggleButton-root": { flex: 1, px: 1.5, whiteSpace: "nowrap" } },
2358
+ onChange: (_, next) => {
2359
+ if (next === "vi" || next === "en") onSelectLanguage(next);
2360
+ },
2361
+ children: [
2362
+ /* @__PURE__ */ jsx7(ToggleButton, { value: "vi", children: "Ti\u1EBFng Vi\u1EC7t" }),
2363
+ /* @__PURE__ */ jsx7(ToggleButton, { value: "en", children: "English" })
2364
+ ]
2365
+ }
2366
+ )
2367
+ ] }),
2368
+ dataSourceControls && /* @__PURE__ */ jsx7(Box2, { sx: { px: 2, py: 1.5, borderTop: "1px solid", borderColor: "divider", bgcolor: "background.neutral", borderRadius: "0 0 12px 12px" }, children: dataSourceControls })
2369
+ ] }),
2272
2370
  parseError && /* @__PURE__ */ jsx7(Alert, { severity: "error", children: parseError }),
2273
- table && /* @__PURE__ */ jsxs7(Card, { inert: saving, "aria-busy": saving, sx: { minWidth: 0, opacity: saving ? 0.65 : 1 }, children: [
2274
- /* @__PURE__ */ jsxs7(Stack3, { direction: { xs: "column", sm: "row" }, spacing: 2, justifyContent: "space-between", alignItems: { sm: "center" }, sx: { px: { xs: 2.5, md: 3 }, py: 2.5 }, children: [
2275
- /* @__PURE__ */ jsxs7(Stack3, { spacing: 0.5, children: [
2276
- /* @__PURE__ */ jsx7(Typography3, { variant: "subtitle1", children: "D\u1EEF li\u1EC7u ph\xED & k\xFD qu\u1EF9" }),
2277
- /* @__PURE__ */ jsx7(Typography3, { variant: "body2", color: "text.secondary", children: canWrite && table?.dataSource === "wikex-api" ? "To\xE0n b\u1ED9 gi\xE1 tr\u1ECB d\xF2ng v\xE0 nh\xF3m l\u1EA5y t\u1EEB API, ch\u1EC9 \u0111\u1ECDc. D\xF9ng Qu\u1EA3n l\xFD c\u1ED9t \u0111\u1EC3 \u1EA9n/hi\u1EC7n c\u1ED9t; v\u1EABn c\xF3 th\u1EC3 \u0111\u1ED5i ti\xEAu \u0111\u1EC1, \u0111\u1ECBnh d\u1EA1ng v\xE0 th\u1EE9 t\u1EF1. Chuy\u1EC3n sang Nh\u1EADp tay \u0111\u1EC3 kh\xF4i ph\u1EE5c b\u1EA3ng th\u1EE7 c\xF4ng." : canWrite ? "S\u1EEDa tr\u1EF1c ti\u1EBFp trong \xF4. D\xF9ng Qu\u1EA3n l\xFD c\u1ED9t ho\u1EB7c V\u1ECB tr\xED \u0111\u1EC3 \u0111\u1ED5i th\u1EE9 t\u1EF1." : "Tra c\u1EE9u d\u1EEF li\u1EC7u v\xE0 l\u1ECDc theo nh\xF3m h\xE0ng h\xF3a." })
2278
- ] }),
2279
- /* @__PURE__ */ jsxs7(Stack3, { direction: "row", spacing: 1, flexShrink: 0, children: [
2371
+ table && /* @__PURE__ */ jsxs7(Card, { inert: saving, "aria-busy": saving, sx: { minWidth: 0 }, children: [
2372
+ /* @__PURE__ */ jsxs7(Stack3, { direction: "row", flexWrap: "wrap", gap: 1, justifyContent: "space-between", alignItems: "center", sx: { px: 2, py: 1.5, borderBottom: "1px solid", borderColor: "divider" }, children: [
2373
+ /* @__PURE__ */ jsx7(Typography3, { variant: "subtitle2", children: table.dataSource === "wikex-api" ? "Danh m\u1EE5c \u0111\u1ED3ng b\u1ED9 \xB7 d\u1EEF li\u1EC7u ch\u1EC9 \u0111\u1ECDc" : "B\u1EA3ng nh\u1EADp tay \xB7 ch\u1EC9nh s\u1EEDa tr\u1EF1c ti\u1EBFp" }),
2374
+ /* @__PURE__ */ jsxs7(Stack3, { direction: "row", spacing: 0.75, children: [
2280
2375
  /* @__PURE__ */ jsx7(Chip, { size: "small", variant: "outlined", label: `${table.rows.length} d\xF2ng` }),
2281
- /* @__PURE__ */ jsx7(Chip, { size: "small", variant: "outlined", label: `${table.columns.length} c\u1ED9t` })
2376
+ /* @__PURE__ */ jsx7(Chip, { size: "small", variant: "outlined", label: `${table.columns.filter((column) => !column.hidden).length} c\u1ED9t hi\u1EC3n th\u1ECB` }),
2377
+ /* @__PURE__ */ jsx7(Chip, { size: "small", variant: statusChipVariant, label: entry?.status === "published" ? "\u0110\xE3 xu\u1EA5t b\u1EA3n" : "Trang nh\xE1p", color: entry?.status === "published" ? "success" : "default" })
2282
2378
  ] })
2283
2379
  ] }),
2284
- /* @__PURE__ */ jsx7(Divider, {}),
2285
- /* @__PURE__ */ jsxs7(Box2, { sx: { p: { xs: 2.5, md: 3 }, minWidth: 0 }, children: [
2286
- /* @__PURE__ */ jsx7(Typography3, { variant: "caption", color: "text.secondary", sx: { display: { xs: "block", md: "none" }, mb: 2 }, children: "Vu\u1ED1t ngang trong b\u1EA3ng \u0111\u1EC3 xem th\xEAm c\xE1c c\u1ED9t." }),
2287
- /* @__PURE__ */ jsx7(FeesTable, { value: table, language, editable: canWrite, onChange: canWrite && !saving ? onChange : void 0 }, key)
2288
- ] })
2380
+ /* @__PURE__ */ jsx7(Box2, { sx: { p: 2, minWidth: 0, "& [data-cms-table-editor] > section:first-of-type": { mt: 0 } }, children: /* @__PURE__ */ jsx7(FeesTable, { value: table, language, editable: canWrite, onChange: canWrite ? onChange : void 0 }, key) })
2289
2381
  ] })
2290
2382
  ] })
2291
2383
  ] });
@@ -2294,4 +2386,3 @@ export {
2294
2386
  FeesManager,
2295
2387
  FeesTable
2296
2388
  };
2297
- //# sourceMappingURL=fees.mjs.map