@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.js CHANGED
@@ -55,6 +55,72 @@ var import_MenuItem = __toESM(require("@mui/material/MenuItem"));
55
55
  var import_Checkbox = __toESM(require("@mui/material/Checkbox"));
56
56
  var import_Collapse = __toESM(require("@mui/material/Collapse"));
57
57
 
58
+ // src/wikex/fees-cell-layout.ts
59
+ var queues = /* @__PURE__ */ new WeakMap();
60
+ function enqueue(element, queue) {
61
+ queue.pending.add(element);
62
+ if (queue.frame) return;
63
+ const view = element.ownerDocument.defaultView;
64
+ queue.frame = view.requestAnimationFrame(() => {
65
+ queue.frame = 0;
66
+ const cells = [...queue.pending].filter((cell) => cell.isConnected);
67
+ queue.pending.clear();
68
+ for (const cell of cells) cell.style.height = "0px";
69
+ const heights = cells.map((cell) => {
70
+ const style = view.getComputedStyle(cell);
71
+ return cell.scrollHeight + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
72
+ });
73
+ cells.forEach((cell, index) => {
74
+ cell.style.height = `${heights[index]}px`;
75
+ });
76
+ });
77
+ }
78
+ function observeFeesCell(element) {
79
+ const document2 = element.ownerDocument;
80
+ const view = document2.defaultView;
81
+ let queue = queues.get(document2);
82
+ if (!queue) {
83
+ const current2 = {
84
+ elements: /* @__PURE__ */ new Map(),
85
+ pending: /* @__PURE__ */ new Set(),
86
+ frame: 0,
87
+ observer: new view.ResizeObserver((entries) => {
88
+ for (const { target, contentRect } of entries) {
89
+ const cell = target;
90
+ if (current2.elements.get(cell) !== contentRect.width) {
91
+ current2.elements.set(cell, contentRect.width);
92
+ enqueue(cell, current2);
93
+ }
94
+ }
95
+ })
96
+ };
97
+ queue = current2;
98
+ queues.set(document2, current2);
99
+ void document2.fonts.ready.then(() => {
100
+ for (const cell of current2.elements.keys()) enqueue(cell, current2);
101
+ });
102
+ }
103
+ queue.elements.set(element, -1);
104
+ queue.observer.observe(element);
105
+ enqueue(element, queue);
106
+ const current = queue;
107
+ return () => {
108
+ current.observer.unobserve(element);
109
+ current.elements.delete(element);
110
+ current.pending.delete(element);
111
+ if (!current.elements.size) {
112
+ current.observer.disconnect();
113
+ if (current.frame) view.cancelAnimationFrame(current.frame);
114
+ current.frame = 0;
115
+ queues.delete(document2);
116
+ }
117
+ };
118
+ }
119
+ function scheduleFeesCell(element) {
120
+ const queue = queues.get(element.ownerDocument);
121
+ if (queue) enqueue(element, queue);
122
+ }
123
+
58
124
  // src/wikex/fees-typography-controls.tsx
59
125
  var import_react = require("react");
60
126
  var import_material = require("@mui/material");
@@ -100,12 +166,14 @@ var FEES_DEFAULT_API_FIELDS = {
100
166
  function feesColumnApiField(column) {
101
167
  return column.apiField ?? FEES_DEFAULT_API_FIELDS[column.key] ?? "";
102
168
  }
169
+ var feesNumberFormats = { vi: new Intl.NumberFormat("vi-VN", { maximumFractionDigits: 8 }), en: new Intl.NumberFormat("en-US", { maximumFractionDigits: 8 }) };
170
+ var numericFeeFields = new Set(FEES_COMMODITY_FIELDS.filter((field) => field.numeric).map((field) => field.key));
103
171
  function formatFeesApiValue(value, field, language) {
104
172
  if (value === null || value === void 0 || typeof value === "string" && !value.trim()) return " - - ";
105
- if (FEES_COMMODITY_FIELDS.find((item) => item.key === field)?.numeric) {
173
+ if (numericFeeFields.has(field)) {
106
174
  const number = typeof value === "number" ? value : Number(value);
107
175
  if (!Number.isFinite(number)) return " - - ";
108
- return number === 0 ? "0" : new Intl.NumberFormat(language === "vi" ? "vi-VN" : "en-US", { maximumFractionDigits: 8 }).format(number);
176
+ return number === 0 ? "0" : feesNumberFormats[language].format(number);
109
177
  }
110
178
  return String(value);
111
179
  }
@@ -1057,34 +1125,31 @@ var feesTheme = {
1057
1125
  ]))
1058
1126
  };
1059
1127
  var EditorActions = import_styled_components6.default.div.withConfig({
1060
- componentId: "sc-20fe3bfd-0"
1128
+ componentId: "sc-508961e9-0"
1061
1129
  })([
1062
- `display:flex;flex-wrap:wrap;gap:8px;margin-top:16px;`
1130
+ `display:flex;flex-wrap:wrap;gap:6px;margin-top:12px;`
1063
1131
  ]);
1064
1132
  var EditGroup = import_styled_components6.default.div.withConfig({
1065
- componentId: "sc-20fe3bfd-1"
1133
+ componentId: "sc-508961e9-1"
1066
1134
  })([
1067
1135
  `display:flex;flex-direction:column;gap:6px;`
1068
1136
  ]);
1069
1137
  var HeaderGroup = (0, import_styled_components6.default)(EditGroup).withConfig({
1070
- componentId: "sc-20fe3bfd-2"
1138
+ componentId: "sc-508961e9-2"
1071
1139
  })([
1072
1140
  `gap:8px;`
1073
1141
  ]);
1074
1142
  var HeaderTitle = import_styled_components6.default.div.withConfig({
1075
- componentId: "sc-20fe3bfd-3"
1143
+ componentId: "sc-508961e9-3"
1076
1144
  })([
1077
1145
  `display:flex;align-items:flex-start;min-height:var(--fees-header-title-height,36px);`
1078
1146
  ]);
1079
- var HeaderActions = import_styled_components6.default.div.withConfig({
1080
- componentId: "sc-20fe3bfd-4"
1081
- })([
1082
- `display:flex;align-items:center;min-height:24px;`
1083
- ]);
1084
1147
  var AlignedFeesTable = (0, import_styled_components6.default)(FeesAndMarginTable).withConfig({
1085
- componentId: "sc-20fe3bfd-5"
1148
+ componentId: "sc-508961e9-4"
1086
1149
  })([
1087
- `&[data-editable] th{vertical-align:top;}--fees-row-background:`,
1150
+ `&[data-editable] th{vertical-align:top;}&&&[data-editable] thead > tr > th{font-size:`,
1151
+ `px;line-height:1.4;}&&&[data-editable] tbody > tr > td{font-size:`,
1152
+ `px;line-height:1.4;}--fees-row-background:`,
1088
1153
  `;--fees-stripe-background:`,
1089
1154
  `;--fees-text:`,
1090
1155
  `;:root[data-theme="dark"] &{--fees-row-background:#39393d;--fees-stripe-background:`,
@@ -1107,7 +1172,7 @@ var AlignedFeesTable = (0, import_styled_components6.default)(FeesAndMarginTable
1107
1172
  `px;line-height:`,
1108
1173
  `;}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:`,
1109
1174
  `;}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);}}}`
1110
- ], ({ 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) => `
1175
+ ], ({ $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) => `
1111
1176
  th:nth-child(${index + 1}), td:nth-child(${index + 1}) {
1112
1177
  width: ${width}px;
1113
1178
  min-width: ${width}px;
@@ -1115,14 +1180,14 @@ var AlignedFeesTable = (0, import_styled_components6.default)(FeesAndMarginTable
1115
1180
  }
1116
1181
  `).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);
1117
1182
  var FeesCellContent = import_styled_components6.default.span.withConfig({
1118
- componentId: "sc-20fe3bfd-6"
1183
+ componentId: "sc-508961e9-5"
1119
1184
  })([
1120
1185
  `display:block;text-align:`,
1121
1186
  `;@media (max-width:767px){text-align:`,
1122
1187
  `;}`
1123
1188
  ], ({ $align, $alignRight }) => $align ?? ($alignRight ? "right" : "left"), ({ $align }) => $align ?? "left");
1124
1189
  var EditorButton = import_styled_components6.default.button.withConfig({
1125
- componentId: "sc-20fe3bfd-7"
1190
+ componentId: "sc-508961e9-6"
1126
1191
  })([
1127
1192
  `padding:7px 12px;border:1px solid `,
1128
1193
  `;border-radius:6px;background:`,
@@ -1131,17 +1196,17 @@ var EditorButton = import_styled_components6.default.button.withConfig({
1131
1196
  `;}&:disabled{cursor:default;opacity:.4;}`
1132
1197
  ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
1133
1198
  var OrderActions = import_styled_components6.default.div.withConfig({
1134
- componentId: "sc-20fe3bfd-8"
1199
+ componentId: "sc-508961e9-7"
1135
1200
  })([
1136
1201
  `display:flex;gap:6px;align-items:center;flex-wrap:wrap;`
1137
1202
  ]);
1138
1203
  var PositionLabel = import_styled_components6.default.label.withConfig({
1139
- componentId: "sc-20fe3bfd-9"
1204
+ componentId: "sc-508961e9-8"
1140
1205
  })([
1141
1206
  `display:inline-flex;align-items:center;gap:6px;font-size:12px;`
1142
1207
  ]);
1143
1208
  var PositionInput = import_styled_components6.default.input.withConfig({
1144
- componentId: "sc-20fe3bfd-10"
1209
+ componentId: "sc-508961e9-9"
1145
1210
  })([
1146
1211
  `width:56px;padding:5px;border:1px solid `,
1147
1212
  `;border-radius:4px;background:`,
@@ -1150,18 +1215,18 @@ var PositionInput = import_styled_components6.default.input.withConfig({
1150
1215
  `;}`
1151
1216
  ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
1152
1217
  var ColumnRow = import_styled_components6.default.div.withConfig({
1153
- componentId: "sc-20fe3bfd-11"
1218
+ componentId: "sc-508961e9-10"
1154
1219
  })([
1155
1220
  `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;}`
1156
1221
  ]);
1157
1222
  var PaginationControls = (0, import_styled_components6.default)(FeesAndMarginPagination).withConfig({
1158
- componentId: "sc-20fe3bfd-12"
1223
+ componentId: "sc-508961e9-11"
1159
1224
  })([
1160
1225
  `align-items:center;flex-wrap:wrap;gap:16px 24px;color:`,
1161
1226
  `;`
1162
1227
  ], ({ theme }) => theme.colors.text.primary);
1163
1228
  var PageSizeLabel = import_styled_components6.default.div.withConfig({
1164
- componentId: "sc-20fe3bfd-13"
1229
+ componentId: "sc-508961e9-12"
1165
1230
  })([
1166
1231
  `display:inline-flex;align-items:center;gap:8px;color:`,
1167
1232
  `;font:inherit;font-size:13px;`
@@ -1189,60 +1254,58 @@ function Position({ value, max, label, onMove }) {
1189
1254
  });
1190
1255
  }
1191
1256
  var DeleteButton = (0, import_styled_components6.default)(EditorButton).withConfig({
1192
- componentId: "sc-20fe3bfd-14"
1257
+ componentId: "sc-508961e9-13"
1193
1258
  })([
1194
1259
  `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;}`
1195
1260
  ]);
1196
1261
  var CellEditorInput = import_styled_components6.default.textarea.withConfig({
1197
- componentId: "sc-20fe3bfd-15"
1262
+ componentId: "sc-508961e9-14"
1198
1263
  })([
1199
1264
  `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:`,
1200
1265
  `;}&:focus{outline:1px solid `,
1201
1266
  `;}&[data-fees-column-selected="true"]{border-color:`,
1202
1267
  `;}`
1203
1268
  ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.accent.primary);
1204
- function CellEditor({ onInput, ...props }) {
1269
+ function CellEditor({ onInput, layoutKey, ...props }) {
1205
1270
  const ref = (0, import_react4.useRef)(null);
1206
- const fit = () => {
1207
- const element = ref.current;
1208
- if (!element) return;
1209
- element.style.height = "0px";
1210
- const style = element.ownerDocument.defaultView.getComputedStyle(element);
1211
- const border = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
1212
- element.style.height = `${element.scrollHeight + border}px`;
1213
- };
1214
- (0, import_react4.useLayoutEffect)(fit);
1271
+ (0, import_react4.useLayoutEffect)(() => ref.current ? observeFeesCell(ref.current) : void 0, []);
1215
1272
  (0, import_react4.useLayoutEffect)(() => {
1216
- const element = ref.current;
1217
- if (!element) return;
1218
- let width = element.getBoundingClientRect().width;
1219
- const observer = new ResizeObserver(() => {
1220
- const nextWidth = element.getBoundingClientRect().width;
1221
- if (nextWidth !== width) {
1222
- width = nextWidth;
1223
- fit();
1224
- }
1225
- });
1226
- observer.observe(element);
1227
- let active = true;
1228
- void element.ownerDocument.fonts.ready.then(() => {
1229
- if (active) fit();
1230
- });
1231
- return () => {
1232
- active = false;
1233
- observer.disconnect();
1234
- };
1235
- }, []);
1273
+ if (ref.current) scheduleFeesCell(ref.current);
1274
+ }, [
1275
+ props.value,
1276
+ layoutKey
1277
+ ]);
1236
1278
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellEditorInput, {
1237
1279
  ...props,
1238
1280
  ref,
1239
1281
  rows: 1,
1240
1282
  onInput: (event) => {
1241
- fit();
1283
+ scheduleFeesCell(event.currentTarget);
1242
1284
  onInput?.(event);
1243
1285
  }
1244
1286
  });
1245
1287
  }
1288
+ var ManualCell = /* @__PURE__ */ (0, import_react4.memo)(function ManualCell2({ rowId, columnKey, text, label, align, selected, layoutKey, onEdit }) {
1289
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellEditor, {
1290
+ value: text,
1291
+ "aria-label": label,
1292
+ style: {
1293
+ textAlign: align ?? "left"
1294
+ },
1295
+ layoutKey,
1296
+ "data-fees-column-selected": selected,
1297
+ onChange: (event) => onEdit(rowId, columnKey, event.target.value)
1298
+ });
1299
+ });
1300
+ var ReadOnlyCell = /* @__PURE__ */ (0, import_react4.memo)(function ReadOnlyCell2({ text, label, align, alignRight, selected }) {
1301
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FeesCellContent, {
1302
+ "aria-label": label,
1303
+ $align: align,
1304
+ $alignRight: alignRight,
1305
+ "data-fees-column-selected": selected || void 0,
1306
+ children: text
1307
+ });
1308
+ });
1246
1309
  function RowTagSelect({ selected, options, onChange, disabled = false }) {
1247
1310
  const selectRoot = (0, import_react4.useRef)(null);
1248
1311
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditGroup, {
@@ -1256,9 +1319,9 @@ function RowTagSelect({ selected, options, onChange, disabled = false }) {
1256
1319
  value: selected,
1257
1320
  disabled,
1258
1321
  inputProps: {
1259
- "aria-label": "Ch\u1ECDn tag"
1322
+ "aria-label": "Ch\u1ECDn nh\xF3m"
1260
1323
  },
1261
- renderValue: (value) => value.length ? `\u0110\xE3 ch\u1ECDn ${value.length} tag` : "Ch\u1ECDn tag\u2026",
1324
+ renderValue: (value) => value.length ? `\u0110\xE3 ch\u1ECDn ${value.length} nh\xF3m` : "Ch\u1ECDn nh\xF3m\u2026",
1262
1325
  MenuProps: {
1263
1326
  container: () => selectRoot.current?.ownerDocument.body ?? document.body
1264
1327
  },
@@ -1284,13 +1347,53 @@ function RowTagSelect({ selected, options, onChange, disabled = false }) {
1284
1347
  }, item)),
1285
1348
  !options.length && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_MenuItem.default, {
1286
1349
  disabled: true,
1287
- children: "Ch\u01B0a c\xF3 tag \u2014 d\xF9ng n\xFAt Th\xEAm tag ph\xEDa tr\xEAn"
1350
+ children: "Ch\u01B0a c\xF3 nh\xF3m \u2014 d\xF9ng n\xFAt Th\xEAm nh\xF3m ph\xEDa tr\xEAn"
1288
1351
  })
1289
1352
  ]
1290
1353
  })
1291
1354
  })
1292
1355
  });
1293
1356
  }
1357
+ var ManualRowControls = /* @__PURE__ */ (0, import_react4.memo)(function ManualRowControls2({ id, name, tags, options, index, count, onTags, onMove, onDelete }) {
1358
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(EditGroup, {
1359
+ children: [
1360
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RowTagSelect, {
1361
+ selected: tags,
1362
+ options,
1363
+ onChange: (next) => onTags(id, next)
1364
+ }),
1365
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(OrderActions, {
1366
+ children: [
1367
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Position, {
1368
+ value: index,
1369
+ max: count,
1370
+ label: `V\u1ECB tr\xED d\xF2ng ${name}`,
1371
+ onMove: (to) => onMove(id, to)
1372
+ }),
1373
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditorButton, {
1374
+ type: "button",
1375
+ "aria-label": `\u0110\u01B0a d\xF2ng ${name} l\xEAn`,
1376
+ disabled: index === 0,
1377
+ onClick: () => onMove(id, index - 1),
1378
+ children: "\u2191"
1379
+ }),
1380
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditorButton, {
1381
+ type: "button",
1382
+ "aria-label": `\u0110\u01B0a d\xF2ng ${name} xu\u1ED1ng`,
1383
+ disabled: index === count - 1,
1384
+ onClick: () => onMove(id, index + 1),
1385
+ children: "\u2193"
1386
+ })
1387
+ ]
1388
+ }),
1389
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DeleteButton, {
1390
+ type: "button",
1391
+ onClick: () => onDelete(id, name || "H\xE0ng m\u1EDBi"),
1392
+ children: "X\xF3a h\xE0ng"
1393
+ })
1394
+ ]
1395
+ });
1396
+ });
1294
1397
  var columnWidths = {
1295
1398
  name: 100,
1296
1399
  code: 96,
@@ -1331,8 +1434,9 @@ var rightAlignedColumns = /* @__PURE__ */ new Set([
1331
1434
  "priceUnit",
1332
1435
  "unit"
1333
1436
  ]);
1334
- function FeesTable({ value, editable = false, onChange, labels: labels2, size = "md", tagOrder = [], language = "vi" }) {
1437
+ var FeesTable = /* @__PURE__ */ (0, import_react4.memo)(function FeesTable2({ value, editable = false, onChange, labels: labels2, size = "md", tagOrder = [], language = "vi" }) {
1335
1438
  const [search, setSearch] = (0, import_react4.useState)("");
1439
+ const deferredSearch = (0, import_react4.useDeferredValue)(search);
1336
1440
  const [tag, setTag] = (0, import_react4.useState)("");
1337
1441
  const [page, setPage] = (0, import_react4.useState)(1);
1338
1442
  const [pageSize, setPageSize] = (0, import_react4.useState)(FEES_PAGE_SIZE);
@@ -1341,11 +1445,38 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1341
1445
  const [columnTitle, setColumnTitle] = (0, import_react4.useState)("");
1342
1446
  const [columnField, setColumnField] = (0, import_react4.useState)("");
1343
1447
  const [typographyOpen, setTypographyOpen] = (0, import_react4.useState)(false);
1448
+ const [alignmentOpen, setAlignmentOpen] = (0, import_react4.useState)(false);
1344
1449
  const [selectedColumnKey, setSelectedColumnKey] = (0, import_react4.useState)("");
1345
1450
  const english = language === "en";
1346
1451
  const canEdit = editable && Boolean(onChange);
1347
1452
  const apiManaged = value.dataSource === "wikex-api";
1348
- const visibleColumns = value.columns.filter((column) => !column.hidden);
1453
+ const visibleColumns = (0, import_react4.useMemo)(() => value.columns.filter((column) => !column.hidden), [
1454
+ value.columns
1455
+ ]);
1456
+ const latest = (0, import_react4.useRef)({
1457
+ value,
1458
+ onChange
1459
+ });
1460
+ latest.current = {
1461
+ value,
1462
+ onChange
1463
+ };
1464
+ const editCell = (0, import_react4.useCallback)((rowId, key, text) => {
1465
+ const { value: value2, onChange: onChange2 } = latest.current;
1466
+ if (value2.dataSource === "wikex-api") return;
1467
+ onChange2?.({
1468
+ ...value2,
1469
+ rows: value2.rows.map((row) => row.id === rowId ? {
1470
+ ...row,
1471
+ cells: {
1472
+ ...row.cells,
1473
+ [key]: text
1474
+ }
1475
+ } : row)
1476
+ });
1477
+ }, []);
1478
+ const headerLayout = JSON.stringify(value.typography?.thead ?? {});
1479
+ const bodyLayout = JSON.stringify(value.typography?.tbody ?? {});
1349
1480
  const tableRoot = (0, import_react4.useRef)(null);
1350
1481
  (0, import_react4.useLayoutEffect)(() => {
1351
1482
  const root = tableRoot.current;
@@ -1402,10 +1533,19 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1402
1533
  ...value.rows.flatMap((row) => row.tags)
1403
1534
  ])
1404
1535
  ].filter(Boolean);
1405
- const tags = [
1536
+ const orderedTags = [
1406
1537
  ...tagOrder.filter((item) => rowTags.includes(item)),
1407
1538
  ...rowTags.filter((item) => !tagOrder.includes(item))
1408
1539
  ];
1540
+ const stableTags = (0, import_react4.useRef)([]);
1541
+ if (orderedTags.length !== stableTags.current.length || orderedTags.some((tag2, index) => tag2 !== stableTags.current[index])) stableTags.current = orderedTags;
1542
+ const tags = stableTags.current;
1543
+ const rowPositions = (0, import_react4.useMemo)(() => new Map(value.rows.map((row, index) => [
1544
+ row.id,
1545
+ index
1546
+ ])), [
1547
+ value.rows
1548
+ ]);
1409
1549
  const newTagName = tagDraft.trim().replace(/\s+/g, " ");
1410
1550
  const duplicateTag = tags.some((item) => item.toLocaleLowerCase("vi") === newTagName.toLocaleLowerCase("vi"));
1411
1551
  const createTag = () => {
@@ -1421,9 +1561,21 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1421
1561
  setTagDraft("");
1422
1562
  };
1423
1563
  const activeTag = tags.includes(tag) ? tag : "";
1424
- const filtered = filterFeesRows(value, search, activeTag);
1425
- const displayedRows = canEdit ? filtered : sortFeesRowsByName(filtered, language);
1426
- const pagination = paginateFeesRows(displayedRows, page, pageSize);
1564
+ const filtered = (0, import_react4.useMemo)(() => filterFeesRows(value, deferredSearch, activeTag), [
1565
+ value,
1566
+ deferredSearch,
1567
+ activeTag
1568
+ ]);
1569
+ const displayedRows = (0, import_react4.useMemo)(() => canEdit ? filtered : sortFeesRowsByName(filtered, language), [
1570
+ canEdit,
1571
+ filtered,
1572
+ language
1573
+ ]);
1574
+ const pagination = (0, import_react4.useMemo)(() => paginateFeesRows(displayedRows, page, pageSize), [
1575
+ displayedRows,
1576
+ page,
1577
+ pageSize
1578
+ ]);
1427
1579
  const selectedColumn = value.columns.find((column) => column.key === selectedColumnKey);
1428
1580
  (0, import_react4.useLayoutEffect)(() => {
1429
1581
  if (selectedColumnKey && !selectedColumn) setSelectedColumnKey("");
@@ -1445,6 +1597,25 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1445
1597
  const index = rows.filter((row) => filteredIds.has(row.id)).findIndex((row) => row.id === id);
1446
1598
  setPage(pageSize === -1 ? 1 : Math.floor(Math.max(0, index) / pageSize) + 1);
1447
1599
  };
1600
+ const moveRowRef = (0, import_react4.useRef)(moveRow);
1601
+ moveRowRef.current = moveRow;
1602
+ const moveManualRow = (0, import_react4.useCallback)((id, position) => moveRowRef.current(id, position), []);
1603
+ const deleteManualRow = (0, import_react4.useCallback)((id, name) => setDeleteTarget({
1604
+ kind: "row",
1605
+ id,
1606
+ label: name
1607
+ }), []);
1608
+ const tagManualRow = (0, import_react4.useCallback)((id, tags2) => {
1609
+ const { value: value2, onChange: onChange2 } = latest.current;
1610
+ if (value2.dataSource === "wikex-api") return;
1611
+ onChange2?.({
1612
+ ...value2,
1613
+ rows: value2.rows.map((row) => row.id === id ? {
1614
+ ...row,
1615
+ tags: tags2
1616
+ } : row)
1617
+ });
1618
+ }, []);
1448
1619
  const addColumn = () => {
1449
1620
  if (apiManaged) {
1450
1621
  setColumnTitle("");
@@ -1488,140 +1659,70 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1488
1659
  onChange?.(setFeesColumnApiField(next, key, columnField, language));
1489
1660
  setAddColumnOpen(false);
1490
1661
  };
1491
- const changeRow = (id, patch) => {
1492
- if (apiManaged) return;
1493
- onChange?.({
1494
- ...value,
1495
- rows: value.rows.map((row) => row.id === id ? {
1496
- ...row,
1497
- ...patch
1498
- } : row)
1499
- });
1500
- };
1501
1662
  const columns = visibleColumns.map((column, index) => ({
1502
1663
  key: column.key,
1503
1664
  width: canEdit ? columnWidths[column.key] ?? 140 : index === 0 ? 178 : 170,
1504
1665
  fixed: index === 0 ? "left" : void 0,
1505
- title: canEdit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(HeaderGroup, {
1506
- children: [
1507
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderTitle, {
1508
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellEditor, {
1509
- rows: 2,
1510
- value: column.title,
1511
- "aria-label": `Ti\xEAu \u0111\u1EC1 c\u1ED9t ${index + 1}`,
1512
- style: {
1513
- textAlign: column.textAlign ?? value.typography?.thead?.textAlign ?? "left"
1514
- },
1515
- "data-fees-column-selected": selectedColumnKey === column.key,
1516
- onChange: (event) => onChange?.({
1517
- ...value,
1518
- columns: value.columns.map((item) => item.key === column.key ? {
1519
- ...item,
1520
- title: event.target.value
1521
- } : item)
1522
- })
1523
- })
1524
- }),
1525
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderActions, {
1526
- children: column.key !== "name" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DeleteButton, {
1527
- type: "button",
1528
- onClick: () => {
1529
- setDeleteTarget({
1530
- kind: "column",
1531
- id: column.key,
1532
- label: column.title
1533
- });
1534
- },
1535
- children: "X\xF3a c\u1ED9t"
1666
+ title: canEdit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderGroup, {
1667
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderTitle, {
1668
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellEditor, {
1669
+ rows: 2,
1670
+ layoutKey: headerLayout,
1671
+ value: column.title,
1672
+ "aria-label": `Ti\xEAu \u0111\u1EC1 c\u1ED9t ${index + 1}`,
1673
+ style: {
1674
+ textAlign: column.textAlign ?? value.typography?.thead?.textAlign ?? "left"
1675
+ },
1676
+ "data-fees-column-selected": selectedColumnKey === column.key,
1677
+ onChange: (event) => onChange?.({
1678
+ ...value,
1679
+ columns: value.columns.map((item) => item.key === column.key ? {
1680
+ ...item,
1681
+ title: event.target.value
1682
+ } : item)
1536
1683
  })
1537
1684
  })
1538
- ]
1685
+ })
1539
1686
  }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FeesCellContent, {
1540
1687
  $align: column.textAlign ?? value.typography?.thead?.textAlign,
1541
1688
  $alignRight: rightAlignedColumns.has(column.key),
1542
1689
  children: column.title
1543
1690
  }),
1544
- render: (_unused, row) => canEdit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CellEditor, {
1545
- rows: Math.max(2, (row.cells[column.key] ?? "").split("\n").length),
1546
- value: row.cells[column.key] || (apiManaged ? " - - " : ""),
1547
- "aria-label": `${column.title} \u2014 ${row.cells.name || "H\xE0ng m\u1EDBi"}`,
1548
- readOnly: apiManaged,
1549
- style: {
1550
- textAlign: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign ?? "left"
1551
- },
1552
- "data-fees-column-selected": selectedColumnKey === column.key,
1553
- onChange: (event) => {
1554
- if (!apiManaged) changeRow(row.id, {
1555
- cells: {
1556
- ...row.cells,
1557
- [column.key]: event.target.value
1558
- }
1559
- });
1560
- }
1561
- }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FeesCellContent, {
1562
- $align: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign,
1563
- $alignRight: rightAlignedColumns.has(column.key),
1564
- children: row.cells[column.key] || (apiManaged ? " - - " : "")
1691
+ render: (_unused, row) => canEdit && !apiManaged ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ManualCell, {
1692
+ rowId: row.id,
1693
+ columnKey: column.key,
1694
+ text: row.cells[column.key] ?? "",
1695
+ label: `${column.title} \u2014 ${row.cells.name || "H\xE0ng m\u1EDBi"}`,
1696
+ align: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign,
1697
+ selected: selectedColumnKey === column.key,
1698
+ layoutKey: bodyLayout,
1699
+ onEdit: editCell
1700
+ }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ReadOnlyCell, {
1701
+ text: row.cells[column.key] || (apiManaged ? " - - " : ""),
1702
+ label: canEdit ? `${column.title} \u2014 ${row.cells.name || "H\xE0ng m\u1EDBi"}` : void 0,
1703
+ align: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign,
1704
+ alignRight: rightAlignedColumns.has(column.key),
1705
+ selected: canEdit && selectedColumnKey === column.key
1565
1706
  })
1566
1707
  }));
1567
- if (canEdit) columns.push({
1708
+ if (canEdit && !apiManaged) columns.push({
1568
1709
  key: "__tags",
1569
- title: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(HeaderGroup, {
1570
- children: [
1571
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderTitle, {
1572
- children: "Tag & th\u1EE9 t\u1EF1 d\xF2ng"
1573
- }),
1574
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderActions, {})
1575
- ]
1710
+ title: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderGroup, {
1711
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderTitle, {
1712
+ children: "Nh\xF3m & th\u1EE9 t\u1EF1 d\xF2ng"
1713
+ })
1576
1714
  }),
1577
1715
  width: 300,
1578
- render: (_unused, row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(EditGroup, {
1579
- children: [
1580
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RowTagSelect, {
1581
- disabled: apiManaged,
1582
- selected: row.tags,
1583
- options: tags,
1584
- onChange: (next) => changeRow(row.id, {
1585
- tags: next
1586
- })
1587
- }),
1588
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(OrderActions, {
1589
- children: [
1590
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Position, {
1591
- value: value.rows.findIndex((item) => item.id === row.id),
1592
- max: value.rows.length,
1593
- label: `V\u1ECB tr\xED d\xF2ng ${row.cells.name}`,
1594
- onMove: (to) => moveRow(row.id, to)
1595
- }),
1596
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditorButton, {
1597
- type: "button",
1598
- "aria-label": `\u0110\u01B0a d\xF2ng ${row.cells.name} l\xEAn`,
1599
- disabled: value.rows[0]?.id === row.id,
1600
- onClick: () => moveRow(row.id, value.rows.findIndex((item) => item.id === row.id) - 1),
1601
- children: "\u2191"
1602
- }),
1603
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditorButton, {
1604
- type: "button",
1605
- "aria-label": `\u0110\u01B0a d\xF2ng ${row.cells.name} xu\u1ED1ng`,
1606
- disabled: value.rows[value.rows.length - 1]?.id === row.id,
1607
- onClick: () => moveRow(row.id, value.rows.findIndex((item) => item.id === row.id) + 1),
1608
- children: "\u2193"
1609
- })
1610
- ]
1611
- }),
1612
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DeleteButton, {
1613
- type: "button",
1614
- disabled: apiManaged,
1615
- onClick: () => {
1616
- setDeleteTarget({
1617
- kind: "row",
1618
- id: row.id,
1619
- label: row.cells.name || "H\xE0ng m\u1EDBi"
1620
- });
1621
- },
1622
- children: "X\xF3a h\xE0ng"
1623
- })
1624
- ]
1716
+ render: (_unused, row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ManualRowControls, {
1717
+ id: row.id,
1718
+ name: row.cells.name || "",
1719
+ tags: row.tags,
1720
+ options: tags,
1721
+ index: rowPositions.get(row.id) ?? 0,
1722
+ count: value.rows.length,
1723
+ onTags: tagManualRow,
1724
+ onMove: moveManualRow,
1725
+ onDelete: deleteManualRow
1625
1726
  })
1626
1727
  });
1627
1728
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_styled_components6.ThemeProvider, {
@@ -1629,6 +1730,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1629
1730
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", {
1630
1731
  ref: tableRoot,
1631
1732
  "data-cms-table-editor": true,
1733
+ "data-editable": canEdit || void 0,
1632
1734
  onClick: (event) => {
1633
1735
  if (canEdit) event.stopPropagation();
1634
1736
  },
@@ -1642,7 +1744,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1642
1744
  minWidth: 0
1643
1745
  },
1644
1746
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TabCommon, {
1645
- ariaLabel: "L\u1ECDc theo tag",
1747
+ ariaLabel: "L\u1ECDc theo nh\xF3m",
1646
1748
  size,
1647
1749
  items: [
1648
1750
  {
@@ -1690,9 +1792,8 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1690
1792
  },
1691
1793
  children: english ? "Sort names A\u2013Z" : "S\u1EAFp x\u1EBFp t\xEAn A\u2013Z"
1692
1794
  }),
1693
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditorButton, {
1795
+ !apiManaged && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditorButton, {
1694
1796
  type: "button",
1695
- disabled: apiManaged,
1696
1797
  onClick: () => {
1697
1798
  const row = {
1698
1799
  id: crypto.randomUUID(),
@@ -1738,12 +1839,17 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1738
1839
  }),
1739
1840
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditorButton, {
1740
1841
  type: "button",
1741
- disabled: apiManaged,
1842
+ "aria-expanded": alignmentOpen,
1843
+ onClick: () => setAlignmentOpen((open) => !open),
1844
+ children: english ? "Alignment" : "C\u0103n l\u1EC1"
1845
+ }),
1846
+ !apiManaged && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditorButton, {
1847
+ type: "button",
1742
1848
  onClick: () => {
1743
1849
  setTagDraft("");
1744
1850
  setCreateTagOpen(true);
1745
1851
  },
1746
- children: "+ Th\xEAm tag"
1852
+ children: "+ Th\xEAm nh\xF3m"
1747
1853
  })
1748
1854
  ]
1749
1855
  }),
@@ -1766,14 +1872,18 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1766
1872
  })
1767
1873
  })
1768
1874
  }),
1769
- canEdit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FeesColumnAlignmentControls, {
1770
- columns: value.columns,
1771
- columnKey: selectedColumnKey,
1772
- english,
1773
- onSelectColumn: setSelectedColumnKey,
1774
- onChange: (textAlign) => {
1775
- if (selectedColumn) onChange?.(setFeesColumnAlignment(value, selectedColumn.key, textAlign));
1776
- }
1875
+ canEdit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_Collapse.default, {
1876
+ in: alignmentOpen,
1877
+ unmountOnExit: true,
1878
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FeesColumnAlignmentControls, {
1879
+ columns: value.columns,
1880
+ columnKey: selectedColumnKey,
1881
+ english,
1882
+ onSelectColumn: setSelectedColumnKey,
1883
+ onChange: (textAlign) => {
1884
+ if (selectedColumn) onChange?.(setFeesColumnAlignment(value, selectedColumn.key, textAlign));
1885
+ }
1886
+ })
1777
1887
  }),
1778
1888
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AlignedFeesTable, {
1779
1889
  $typography: value.typography,
@@ -1787,7 +1897,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
1787
1897
  size,
1788
1898
  empty: labels2?.empty ?? "Kh\xF4ng t\xECm th\u1EA5y h\xE0ng h\xF3a",
1789
1899
  scroll: {
1790
- x: canEdit ? Math.max(1440, value.columns.reduce((sum, column) => sum + (columnWidths[column.key] ?? 140), 0) + 300) : visibleColumns.length * 170 + 8
1900
+ x: canEdit ? Math.max(apiManaged ? 900 : 1100, columns.reduce((sum, column) => sum + (typeof column.width === "number" ? column.width : 140), 0)) : visibleColumns.length * 170 + 8
1791
1901
  }
1792
1902
  })
1793
1903
  }),
@@ -2118,18 +2228,18 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
2118
2228
  children: [
2119
2229
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_DialogTitle.default, {
2120
2230
  id: `${dialogId}-create-tag-title`,
2121
- children: "T\u1EA1o tag m\u1EDBi"
2231
+ children: "T\u1EA1o nh\xF3m m\u1EDBi"
2122
2232
  }),
2123
2233
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_DialogContent.default, {
2124
2234
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_TextField.default, {
2125
2235
  autoFocus: true,
2126
2236
  fullWidth: true,
2127
2237
  margin: "dense",
2128
- label: "T\xEAn tag",
2238
+ label: "T\xEAn nh\xF3m",
2129
2239
  value: tagDraft,
2130
2240
  onChange: (event) => setTagDraft(event.target.value),
2131
2241
  error: duplicateTag,
2132
- 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.",
2242
+ 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.",
2133
2243
  onKeyDown: (event) => {
2134
2244
  if (event.key === "Enter") {
2135
2245
  event.preventDefault();
@@ -2148,7 +2258,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
2148
2258
  variant: "contained",
2149
2259
  disabled: !newTagName || duplicateTag,
2150
2260
  onClick: createTag,
2151
- children: "T\u1EA1o tag"
2261
+ children: "T\u1EA1o nh\xF3m"
2152
2262
  })
2153
2263
  ]
2154
2264
  })
@@ -2200,7 +2310,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
2200
2310
  ]
2201
2311
  })
2202
2312
  });
2203
- }
2313
+ });
2204
2314
 
2205
2315
  // src/wikex/fees-manager.tsx
2206
2316
  var import_jsx_runtime8 = require("react/jsx-runtime");
@@ -2215,6 +2325,8 @@ function FeesManager({
2215
2325
  notice,
2216
2326
  parseError,
2217
2327
  dataSourceControls,
2328
+ sourceControl,
2329
+ headerActions,
2218
2330
  statusChipVariant = "filled",
2219
2331
  onSelectEntry,
2220
2332
  onSelectLanguage,
@@ -2224,14 +2336,14 @@ function FeesManager({
2224
2336
  }) {
2225
2337
  const entry = entries.find((item) => item.id === selectedId);
2226
2338
  const key = `${selectedId}:${language}`;
2227
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { spacing: 3, sx: { minWidth: 0, width: 1 }, children: [
2228
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: { xs: "column", md: "row" }, justifyContent: "space-between", alignItems: { md: "center" }, gap: 2.5, children: [
2229
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { spacing: 1, sx: { minWidth: 0, maxWidth: 720 }, children: [
2339
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { spacing: 2, sx: { minWidth: 0, width: 1 }, children: [
2340
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: { xs: "column", sm: "row" }, justifyContent: "space-between", alignItems: { sm: "center" }, gap: 1.5, children: [
2341
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { spacing: 0.5, children: [
2230
2342
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Typography, { variant: "h4", children: "Ph\xED & k\xFD qu\u1EF9" }),
2231
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Typography, { 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." })
2343
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Typography, { 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." })
2232
2344
  ] }),
2233
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: "row", spacing: 1.5, alignItems: "center", flexShrink: 0, children: [
2234
- dirtyKeys.includes(key) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Chip, { size: "small", color: "warning", label: "Ch\u01B0a l\u01B0u" }),
2345
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: "row", spacing: 1, alignItems: "center", flexShrink: 0, justifyContent: "flex-end", children: [
2346
+ headerActions,
2235
2347
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2236
2348
  import_material3.Button,
2237
2349
  {
@@ -2239,21 +2351,17 @@ function FeesManager({
2239
2351
  loading: saving,
2240
2352
  disabled: !canWrite || !dirtyKeys.includes(key) || saving,
2241
2353
  onClick: onSave,
2242
- sx: { minHeight: 44, px: 3, flex: { xs: 1, md: "initial" }, minWidth: { md: 156 } },
2354
+ sx: { minHeight: 40, px: 2.5 },
2243
2355
  children: "L\u01B0u b\u1EA3ng ph\xED"
2244
2356
  }
2245
2357
  )
2246
2358
  ] })
2247
2359
  ] }),
2248
- !canWrite && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.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." }),
2360
+ !canWrite && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.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." }),
2249
2361
  notice && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Alert, { severity: notice.severity, onClose: onDismissNotice, children: notice.message }),
2250
- !entries.length ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.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__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2251
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Card, { variant: "outlined", sx: { p: { xs: 2.5, md: 3 }, boxShadow: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { spacing: 2.5, children: [
2252
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", gap: 1.5, flexWrap: "wrap", children: [
2253
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Typography, { variant: "subtitle1", children: "B\u1EA3ng \u0111ang qu\u1EA3n l\xFD" }),
2254
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.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" })
2255
- ] }),
2256
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: { xs: "column", md: "row" }, spacing: 2.5, alignItems: { md: "flex-end" }, children: [
2362
+ !entries.length ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.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__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2363
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Card, { variant: "outlined", sx: { boxShadow: "none", overflow: "visible" }, children: [
2364
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Box, { 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: [
2257
2365
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2258
2366
  import_material3.TextField,
2259
2367
  {
@@ -2263,65 +2371,49 @@ function FeesManager({
2263
2371
  value: selectedId,
2264
2372
  disabled: saving,
2265
2373
  fullWidth: true,
2266
- sx: { flex: 1, minWidth: 0 },
2267
2374
  onChange: (event) => onSelectEntry(event.target.value),
2268
2375
  children: entries.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.MenuItem, { value: item.id, children: [
2269
2376
  item.pageTitle,
2270
2377
  " \xB7 /",
2271
2378
  item.slug,
2272
2379
  " \xB7 #",
2273
- index + 1,
2274
- dirtyKeys.some((draft) => draft.startsWith(`${item.id}:`)) ? " (ch\u01B0a l\u01B0u)" : ""
2380
+ index + 1
2275
2381
  ] }, item.id))
2276
2382
  }
2277
2383
  ),
2278
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { spacing: 1, sx: { width: { xs: 1, md: 240 }, flexShrink: 0 }, children: [
2279
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Typography, { variant: "caption", color: "text.secondary", children: "Ng\xF4n ng\u1EEF n\u1ED9i dung" }),
2280
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
2281
- import_material3.ToggleButtonGroup,
2282
- {
2283
- size: "small",
2284
- exclusive: true,
2285
- value: language,
2286
- disabled: saving,
2287
- "aria-label": "Ng\xF4n ng\u1EEF b\u1EA3ng ph\xED",
2288
- sx: { minHeight: 40, "& .MuiToggleButton-root": { flex: 1, px: 2 } },
2289
- onChange: (_, next) => {
2290
- if (next === "vi" || next === "en") onSelectLanguage(next);
2291
- },
2292
- children: [
2293
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.ToggleButton, { value: "vi", children: [
2294
- "Ti\u1EBFng Vi\u1EC7t",
2295
- dirtyKeys.includes(`${selectedId}:vi`) ? " \u2022" : ""
2296
- ] }),
2297
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.ToggleButton, { value: "en", children: [
2298
- "English",
2299
- dirtyKeys.includes(`${selectedId}:en`) ? " \u2022" : ""
2300
- ] })
2301
- ]
2302
- }
2303
- )
2304
- ] })
2305
- ] })
2306
- ] }) }),
2307
- dataSourceControls,
2384
+ sourceControl,
2385
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
2386
+ import_material3.ToggleButtonGroup,
2387
+ {
2388
+ size: "small",
2389
+ exclusive: true,
2390
+ value: language,
2391
+ disabled: saving,
2392
+ "aria-label": "Ng\xF4n ng\u1EEF b\u1EA3ng ph\xED",
2393
+ sx: { minHeight: 40, minWidth: { md: 200 }, "& .MuiToggleButton-root": { flex: 1, px: 1.5, whiteSpace: "nowrap" } },
2394
+ onChange: (_, next) => {
2395
+ if (next === "vi" || next === "en") onSelectLanguage(next);
2396
+ },
2397
+ children: [
2398
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.ToggleButton, { value: "vi", children: "Ti\u1EBFng Vi\u1EC7t" }),
2399
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.ToggleButton, { value: "en", children: "English" })
2400
+ ]
2401
+ }
2402
+ )
2403
+ ] }),
2404
+ dataSourceControls && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Box, { sx: { px: 2, py: 1.5, borderTop: "1px solid", borderColor: "divider", bgcolor: "background.neutral", borderRadius: "0 0 12px 12px" }, children: dataSourceControls })
2405
+ ] }),
2308
2406
  parseError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Alert, { severity: "error", children: parseError }),
2309
- table && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Card, { inert: saving, "aria-busy": saving, sx: { minWidth: 0, opacity: saving ? 0.65 : 1 }, children: [
2310
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, justifyContent: "space-between", alignItems: { sm: "center" }, sx: { px: { xs: 2.5, md: 3 }, py: 2.5 }, children: [
2311
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { spacing: 0.5, children: [
2312
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Typography, { variant: "subtitle1", children: "D\u1EEF li\u1EC7u ph\xED & k\xFD qu\u1EF9" }),
2313
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Typography, { 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." })
2314
- ] }),
2315
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: "row", spacing: 1, flexShrink: 0, children: [
2407
+ table && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Card, { inert: saving, "aria-busy": saving, sx: { minWidth: 0 }, children: [
2408
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: "row", flexWrap: "wrap", gap: 1, justifyContent: "space-between", alignItems: "center", sx: { px: 2, py: 1.5, borderBottom: "1px solid", borderColor: "divider" }, children: [
2409
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Typography, { 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" }),
2410
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Stack, { direction: "row", spacing: 0.75, children: [
2316
2411
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Chip, { size: "small", variant: "outlined", label: `${table.rows.length} d\xF2ng` }),
2317
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Chip, { size: "small", variant: "outlined", label: `${table.columns.length} c\u1ED9t` })
2412
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Chip, { size: "small", variant: "outlined", label: `${table.columns.filter((column) => !column.hidden).length} c\u1ED9t hi\u1EC3n th\u1ECB` }),
2413
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Chip, { size: "small", variant: statusChipVariant, label: entry?.status === "published" ? "\u0110\xE3 xu\u1EA5t b\u1EA3n" : "Trang nh\xE1p", color: entry?.status === "published" ? "success" : "default" })
2318
2414
  ] })
2319
2415
  ] }),
2320
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Divider, {}),
2321
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material3.Box, { sx: { p: { xs: 2.5, md: 3 }, minWidth: 0 }, children: [
2322
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Typography, { 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." }),
2323
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FeesTable, { value: table, language, editable: canWrite, onChange: canWrite && !saving ? onChange : void 0 }, key)
2324
- ] })
2416
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material3.Box, { sx: { p: 2, minWidth: 0, "& [data-cms-table-editor] > section:first-of-type": { mt: 0 } }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FeesTable, { value: table, language, editable: canWrite, onChange: canWrite ? onChange : void 0 }, key) })
2325
2417
  ] })
2326
2418
  ] })
2327
2419
  ] });
@@ -2331,4 +2423,3 @@ function FeesManager({
2331
2423
  FeesManager,
2332
2424
  FeesTable
2333
2425
  });
2334
- //# sourceMappingURL=fees.js.map