@enyxs/wikex-components 0.11.32 → 0.11.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/dist/fees-model.d.mts +3 -1
- package/dist/fees-model.d.ts +3 -1
- package/dist/fees-model.js +20 -0
- package/dist/fees-model.js.map +1 -1
- package/dist/fees-model.mjs +19 -0
- package/dist/fees-model.mjs.map +1 -1
- package/dist/fees.js +125 -112
- package/dist/fees.js.map +1 -1
- package/dist/fees.mjs +120 -107
- package/dist/fees.mjs.map +1 -1
- package/dist/index.js +278 -265
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +194 -181
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/fees.js
CHANGED
|
@@ -41,7 +41,7 @@ var import_material3 = require("@mui/material");
|
|
|
41
41
|
|
|
42
42
|
// src/wikex/fees-table.tsx
|
|
43
43
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
44
|
-
var
|
|
44
|
+
var import_react4 = require("react");
|
|
45
45
|
var import_styled_components6 = __toESM(require("styled-components"));
|
|
46
46
|
var import_TextField = __toESM(require("@mui/material/TextField"));
|
|
47
47
|
var import_Dialog = __toESM(require("@mui/material/Dialog"));
|
|
@@ -94,23 +94,23 @@ function moveFeesItem(items, from, to) {
|
|
|
94
94
|
next.splice(to, 0, item);
|
|
95
95
|
return next;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
if (!table.columns.some((column) => column.key ===
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
function setFeesColumnAlignment(table, columnKey, textAlign) {
|
|
98
|
+
if (!table.columns.some((column) => column.key === columnKey)) return table;
|
|
99
|
+
return {
|
|
100
|
+
...table,
|
|
101
|
+
columns: table.columns.map((column) => {
|
|
102
|
+
if (column.key !== columnKey) return column;
|
|
102
103
|
const { textAlign: _previous, ...rest } = column;
|
|
103
104
|
return { ...rest, ...textAlign ? { textAlign } : {} };
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}) };
|
|
105
|
+
}),
|
|
106
|
+
rows: table.rows.map((row) => {
|
|
107
|
+
if (!row.cellAlignments || !Object.prototype.hasOwnProperty.call(row.cellAlignments, columnKey)) return row;
|
|
108
|
+
const { cellAlignments, ...rest } = row;
|
|
109
|
+
const alignments = { ...cellAlignments };
|
|
110
|
+
delete alignments[columnKey];
|
|
111
|
+
return { ...rest, ...Object.keys(alignments).length ? { cellAlignments: alignments } : {} };
|
|
112
|
+
})
|
|
113
|
+
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
// src/wikex/fees-typography-controls.tsx
|
|
@@ -167,7 +167,7 @@ function FeesTypographyControls({ value, onChange }) {
|
|
|
167
167
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Stack, { direction: { xs: "column", sm: "row" }, gap: 1.5, justifyContent: "space-between", alignItems: { sm: "center" }, sx: { mb: 2 }, children: [
|
|
168
168
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Box, { children: [
|
|
169
169
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "subtitle2", children: "\u0110\u1ECBnh d\u1EA1ng ch\u1EEF" }),
|
|
170
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", color: "text.secondary", children: "C\u1EE1 ch\u1EEF v\xE0 \u0111\u1ED9 \u0111\u1EADm \xE1p d\u1EE5ng cho to\xE0n b\u1EA3ng, theo ng\xF4n ng\u1EEF \u0111ang ch\u1ECDn. C\u0103n l\u1EC1 \u0111\
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { variant: "caption", color: "text.secondary", children: "C\u1EE1 ch\u1EEF v\xE0 \u0111\u1ED9 \u0111\u1EADm \xE1p d\u1EE5ng cho to\xE0n b\u1EA3ng, theo ng\xF4n ng\u1EEF \u0111ang ch\u1ECDn. Ch\u1ECDn c\u1ED9t trong m\u1EE5c C\u0103n l\u1EC1 theo c\u1ED9t \u0111\u1EC3 ch\u1EC9nh ti\xEAu \u0111\u1EC1 v\xE0 to\xE0n b\u1ED9 gi\xE1 tr\u1ECB c\u1EE7a c\u1ED9t." })
|
|
171
171
|
] }),
|
|
172
172
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Stack, { direction: "row", gap: 1, flexShrink: 0, children: [
|
|
173
173
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Button, { size: "small", variant: "outlined", onClick: () => onChange({ thead: { ...value?.thead, fontSize: 14, fontWeight: 700 }, tbody: { ...value?.tbody, fontSize: 14, fontWeight: 500 } }), children: "D\u1EC5 \u0111\u1ECDc" }),
|
|
@@ -206,53 +206,78 @@ function FeesTypographyControls({ value, onChange }) {
|
|
|
206
206
|
] });
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
// src/wikex/fees-
|
|
209
|
+
// src/wikex/fees-column-alignment-controls.tsx
|
|
210
|
+
var import_react2 = require("react");
|
|
210
211
|
var import_material2 = require("@mui/material");
|
|
211
212
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
212
213
|
var labels = { left: "C\u0103n tr\xE1i", center: "C\u0103n gi\u1EEFa", right: "C\u0103n ph\u1EA3i" };
|
|
213
214
|
var englishLabels = { left: "Align left", center: "Align center", right: "Align right" };
|
|
214
|
-
function
|
|
215
|
+
function FeesColumnAlignmentControls({ columns, columnKey, english, onSelectColumn, onChange }) {
|
|
216
|
+
const root = (0, import_react2.useRef)(null);
|
|
217
|
+
const column = columns.find((item) => item.key === columnKey);
|
|
215
218
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
216
219
|
import_material2.Stack,
|
|
217
220
|
{
|
|
221
|
+
ref: root,
|
|
218
222
|
role: "group",
|
|
219
|
-
"aria-label": english ? "
|
|
220
|
-
direction: { xs: "column", sm: "row" },
|
|
223
|
+
"aria-label": english ? "Column alignment" : "C\u0103n l\u1EC1 theo c\u1ED9t",
|
|
221
224
|
spacing: 1.5,
|
|
222
|
-
alignItems: { sm: "center" },
|
|
223
225
|
sx: { my: 2, p: 1.5, border: "1px solid", borderColor: "divider", borderRadius: 1.5 },
|
|
224
226
|
children: [
|
|
225
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
226
|
-
|
|
227
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
228
|
-
|
|
229
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material2.Stack, { direction: "row", spacing: 0.5, flexWrap: "wrap", useFlexGap: true, children: [
|
|
230
|
-
FEES_TEXT_ALIGNS.map((align) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
231
|
-
import_material2.Button,
|
|
232
|
-
{
|
|
233
|
-
size: "small",
|
|
234
|
-
disabled: !label,
|
|
235
|
-
variant: value === align ? "contained" : "outlined",
|
|
236
|
-
"aria-pressed": value === align,
|
|
237
|
-
onMouseDown: (event) => event.preventDefault(),
|
|
238
|
-
onClick: () => onChange(align),
|
|
239
|
-
children: (english ? englishLabels : labels)[align]
|
|
240
|
-
},
|
|
241
|
-
align
|
|
242
|
-
)),
|
|
243
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
244
|
-
import_material2.Button,
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.Typography, { variant: "subtitle2", children: english ? "Column alignment" : "C\u0103n l\u1EC1 theo c\u1ED9t" }),
|
|
228
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material2.Stack, { direction: { xs: "column", sm: "row" }, spacing: 1.5, alignItems: { sm: "center" }, children: [
|
|
229
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
230
|
+
import_material2.TextField,
|
|
245
231
|
{
|
|
232
|
+
select: true,
|
|
246
233
|
size: "small",
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
234
|
+
label: english ? "Column to align" : "C\u1ED9t c\u1EA7n c\u0103n l\u1EC1",
|
|
235
|
+
value: column?.key ?? "",
|
|
236
|
+
sx: { flex: 1, minWidth: 0 },
|
|
237
|
+
slotProps: { inputLabel: { shrink: true }, select: {
|
|
238
|
+
displayEmpty: true,
|
|
239
|
+
SelectDisplayProps: { "aria-labelledby": void 0 },
|
|
240
|
+
inputProps: { "aria-label": english ? "Column to align" : "C\u1ED9t c\u1EA7n c\u0103n l\u1EC1" },
|
|
241
|
+
MenuProps: { container: () => root.current?.ownerDocument.body ?? document.body }
|
|
242
|
+
} },
|
|
243
|
+
onChange: (event) => onSelectColumn(event.target.value),
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.MenuItem, { value: "", disabled: true, children: english ? "Select a column" : "Ch\u1ECDn c\u1ED9t" }),
|
|
246
|
+
columns.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material2.MenuItem, { value: item.key, children: [
|
|
247
|
+
index + 1,
|
|
248
|
+
". ",
|
|
249
|
+
item.title || (english ? "Untitled column" : "C\u1ED9t ch\u01B0a c\xF3 ti\xEAu \u0111\u1EC1")
|
|
250
|
+
] }, item.key))
|
|
251
|
+
]
|
|
253
252
|
}
|
|
254
|
-
)
|
|
255
|
-
|
|
253
|
+
),
|
|
254
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material2.Stack, { direction: "row", spacing: 0.5, flexWrap: "wrap", useFlexGap: true, children: [
|
|
255
|
+
FEES_TEXT_ALIGNS.map((align) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
256
|
+
import_material2.Button,
|
|
257
|
+
{
|
|
258
|
+
size: "small",
|
|
259
|
+
disabled: !column,
|
|
260
|
+
variant: column?.textAlign === align ? "contained" : "outlined",
|
|
261
|
+
"aria-pressed": column?.textAlign === align,
|
|
262
|
+
onClick: () => onChange(align),
|
|
263
|
+
children: (english ? englishLabels : labels)[align]
|
|
264
|
+
},
|
|
265
|
+
align
|
|
266
|
+
)),
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
268
|
+
import_material2.Button,
|
|
269
|
+
{
|
|
270
|
+
size: "small",
|
|
271
|
+
color: "inherit",
|
|
272
|
+
disabled: !column,
|
|
273
|
+
"aria-label": english ? "Reset selected column alignment" : "C\u0103n l\u1EC1 m\u1EB7c \u0111\u1ECBnh cho c\u1ED9t \u0111ang ch\u1ECDn",
|
|
274
|
+
onClick: () => onChange(void 0),
|
|
275
|
+
children: english ? "Default" : "M\u1EB7c \u0111\u1ECBnh"
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
] })
|
|
279
|
+
] }),
|
|
280
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.Typography, { variant: "caption", color: "text.secondary", children: english ? "Applies to the header and all values in the selected column, including filtered rows and other pages." : "\xC1p d\u1EE5ng cho ti\xEAu \u0111\u1EC1 v\xE0 to\xE0n b\u1ED9 gi\xE1 tr\u1ECB c\u1EE7a c\u1ED9t \u0111\xE3 ch\u1ECDn, k\u1EC3 c\u1EA3 c\xE1c d\xF2ng \u0111ang l\u1ECDc v\xE0 \u1EDF trang kh\xE1c." })
|
|
256
281
|
]
|
|
257
282
|
}
|
|
258
283
|
);
|
|
@@ -356,7 +381,7 @@ var appTheme = {
|
|
|
356
381
|
};
|
|
357
382
|
|
|
358
383
|
// src/commodity-original/components/Table/index.tsx
|
|
359
|
-
var
|
|
384
|
+
var import_react3 = require("react");
|
|
360
385
|
|
|
361
386
|
// src/commodity-original/components/Table/style.ts
|
|
362
387
|
var import_styled_components = __toESM(require("styled-components"));
|
|
@@ -591,7 +616,7 @@ function Table({
|
|
|
591
616
|
const recordKey = getRowKey(record);
|
|
592
617
|
const selectionProps = rowSelection?.getCheckboxProps?.(record);
|
|
593
618
|
const isExpanded = expandedRowKeySet.has(recordKey);
|
|
594
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react3.Fragment, { children: [
|
|
595
620
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(TableRow, { "data-row-key": recordKey, children: [
|
|
596
621
|
rowSelection ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
597
622
|
TableSelectionInput,
|
|
@@ -972,32 +997,32 @@ var feesTheme = {
|
|
|
972
997
|
]))
|
|
973
998
|
};
|
|
974
999
|
var EditorActions = import_styled_components6.default.div.withConfig({
|
|
975
|
-
componentId: "sc-
|
|
1000
|
+
componentId: "sc-a4d52175-0"
|
|
976
1001
|
})([
|
|
977
1002
|
`display:flex;flex-wrap:wrap;gap:8px;margin-top:16px;`
|
|
978
1003
|
]);
|
|
979
1004
|
var EditGroup = import_styled_components6.default.div.withConfig({
|
|
980
|
-
componentId: "sc-
|
|
1005
|
+
componentId: "sc-a4d52175-1"
|
|
981
1006
|
})([
|
|
982
1007
|
`display:flex;flex-direction:column;gap:6px;`
|
|
983
1008
|
]);
|
|
984
1009
|
var HeaderGroup = (0, import_styled_components6.default)(EditGroup).withConfig({
|
|
985
|
-
componentId: "sc-
|
|
1010
|
+
componentId: "sc-a4d52175-2"
|
|
986
1011
|
})([
|
|
987
1012
|
`gap:8px;`
|
|
988
1013
|
]);
|
|
989
1014
|
var HeaderTitle = import_styled_components6.default.div.withConfig({
|
|
990
|
-
componentId: "sc-
|
|
1015
|
+
componentId: "sc-a4d52175-3"
|
|
991
1016
|
})([
|
|
992
1017
|
`display:flex;align-items:flex-start;min-height:var(--fees-header-title-height,36px);`
|
|
993
1018
|
]);
|
|
994
1019
|
var HeaderActions = import_styled_components6.default.div.withConfig({
|
|
995
|
-
componentId: "sc-
|
|
1020
|
+
componentId: "sc-a4d52175-4"
|
|
996
1021
|
})([
|
|
997
1022
|
`display:flex;align-items:center;min-height:24px;`
|
|
998
1023
|
]);
|
|
999
1024
|
var AlignedFeesTable = (0, import_styled_components6.default)(FeesAndMarginTable).withConfig({
|
|
1000
|
-
componentId: "sc-
|
|
1025
|
+
componentId: "sc-a4d52175-5"
|
|
1001
1026
|
})([
|
|
1002
1027
|
`&[data-editable] th{vertical-align:top;}--fees-row-background:`,
|
|
1003
1028
|
`;--fees-stripe-background:`,
|
|
@@ -1030,14 +1055,14 @@ var AlignedFeesTable = (0, import_styled_components6.default)(FeesAndMarginTable
|
|
|
1030
1055
|
}
|
|
1031
1056
|
`).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);
|
|
1032
1057
|
var FeesCellContent = import_styled_components6.default.span.withConfig({
|
|
1033
|
-
componentId: "sc-
|
|
1058
|
+
componentId: "sc-a4d52175-6"
|
|
1034
1059
|
})([
|
|
1035
1060
|
`display:block;text-align:`,
|
|
1036
1061
|
`;@media (max-width:767px){text-align:`,
|
|
1037
1062
|
`;}`
|
|
1038
1063
|
], ({ $align, $alignRight }) => $align ?? ($alignRight ? "right" : "left"), ({ $align }) => $align ?? "left");
|
|
1039
1064
|
var EditorButton = import_styled_components6.default.button.withConfig({
|
|
1040
|
-
componentId: "sc-
|
|
1065
|
+
componentId: "sc-a4d52175-7"
|
|
1041
1066
|
})([
|
|
1042
1067
|
`padding:7px 12px;border:1px solid `,
|
|
1043
1068
|
`;border-radius:6px;background:`,
|
|
@@ -1046,17 +1071,17 @@ var EditorButton = import_styled_components6.default.button.withConfig({
|
|
|
1046
1071
|
`;}&:disabled{cursor:default;opacity:.4;}`
|
|
1047
1072
|
], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
|
|
1048
1073
|
var OrderActions = import_styled_components6.default.div.withConfig({
|
|
1049
|
-
componentId: "sc-
|
|
1074
|
+
componentId: "sc-a4d52175-8"
|
|
1050
1075
|
})([
|
|
1051
1076
|
`display:flex;gap:6px;align-items:center;flex-wrap:wrap;`
|
|
1052
1077
|
]);
|
|
1053
1078
|
var PositionLabel = import_styled_components6.default.label.withConfig({
|
|
1054
|
-
componentId: "sc-
|
|
1079
|
+
componentId: "sc-a4d52175-9"
|
|
1055
1080
|
})([
|
|
1056
1081
|
`display:inline-flex;align-items:center;gap:6px;font-size:12px;`
|
|
1057
1082
|
]);
|
|
1058
1083
|
var PositionInput = import_styled_components6.default.input.withConfig({
|
|
1059
|
-
componentId: "sc-
|
|
1084
|
+
componentId: "sc-a4d52175-10"
|
|
1060
1085
|
})([
|
|
1061
1086
|
`width:56px;padding:5px;border:1px solid `,
|
|
1062
1087
|
`;border-radius:4px;background:`,
|
|
@@ -1065,17 +1090,17 @@ var PositionInput = import_styled_components6.default.input.withConfig({
|
|
|
1065
1090
|
`;}`
|
|
1066
1091
|
], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
|
|
1067
1092
|
var ColumnRow = import_styled_components6.default.div.withConfig({
|
|
1068
|
-
componentId: "sc-
|
|
1093
|
+
componentId: "sc-a4d52175-11"
|
|
1069
1094
|
})([
|
|
1070
1095
|
`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;}`
|
|
1071
1096
|
]);
|
|
1072
1097
|
var PaginationControls = (0, import_styled_components6.default)(FeesAndMarginPagination).withConfig({
|
|
1073
|
-
componentId: "sc-
|
|
1098
|
+
componentId: "sc-a4d52175-12"
|
|
1074
1099
|
})([
|
|
1075
1100
|
`align-items:center;flex-wrap:wrap;gap:16px 24px;`
|
|
1076
1101
|
]);
|
|
1077
1102
|
var PageSizeLabel = import_styled_components6.default.div.withConfig({
|
|
1078
|
-
componentId: "sc-
|
|
1103
|
+
componentId: "sc-a4d52175-13"
|
|
1079
1104
|
})([
|
|
1080
1105
|
`display:inline-flex;align-items:center;gap:8px;color:`,
|
|
1081
1106
|
`;font:inherit;font-size:13px;`
|
|
@@ -1103,20 +1128,20 @@ function Position({ value, max, label, onMove }) {
|
|
|
1103
1128
|
});
|
|
1104
1129
|
}
|
|
1105
1130
|
var DeleteButton = (0, import_styled_components6.default)(EditorButton).withConfig({
|
|
1106
|
-
componentId: "sc-
|
|
1131
|
+
componentId: "sc-a4d52175-14"
|
|
1107
1132
|
})([
|
|
1108
1133
|
`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;}`
|
|
1109
1134
|
]);
|
|
1110
1135
|
var CellEditorInput = import_styled_components6.default.textarea.withConfig({
|
|
1111
|
-
componentId: "sc-
|
|
1136
|
+
componentId: "sc-a4d52175-15"
|
|
1112
1137
|
})([
|
|
1113
1138
|
`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:`,
|
|
1114
1139
|
`;}&:focus{outline:1px solid `,
|
|
1115
|
-
`;}&[data-fees-
|
|
1140
|
+
`;}&[data-fees-column-selected="true"]{border-color:`,
|
|
1116
1141
|
`;}`
|
|
1117
1142
|
], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.accent.primary);
|
|
1118
1143
|
function CellEditor({ onInput, ...props }) {
|
|
1119
|
-
const ref = (0,
|
|
1144
|
+
const ref = (0, import_react4.useRef)(null);
|
|
1120
1145
|
const fit = () => {
|
|
1121
1146
|
const element = ref.current;
|
|
1122
1147
|
if (!element) return;
|
|
@@ -1125,8 +1150,8 @@ function CellEditor({ onInput, ...props }) {
|
|
|
1125
1150
|
const border = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
|
1126
1151
|
element.style.height = `${element.scrollHeight + border}px`;
|
|
1127
1152
|
};
|
|
1128
|
-
(0,
|
|
1129
|
-
(0,
|
|
1153
|
+
(0, import_react4.useLayoutEffect)(fit);
|
|
1154
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
1130
1155
|
const element = ref.current;
|
|
1131
1156
|
if (!element) return;
|
|
1132
1157
|
let width = element.getBoundingClientRect().width;
|
|
@@ -1158,7 +1183,7 @@ function CellEditor({ onInput, ...props }) {
|
|
|
1158
1183
|
});
|
|
1159
1184
|
}
|
|
1160
1185
|
function RowTagSelect({ selected, options, onChange }) {
|
|
1161
|
-
const selectRoot = (0,
|
|
1186
|
+
const selectRoot = (0, import_react4.useRef)(null);
|
|
1162
1187
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditGroup, {
|
|
1163
1188
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
|
|
1164
1189
|
ref: selectRoot,
|
|
@@ -1245,17 +1270,17 @@ var rightAlignedColumns = /* @__PURE__ */ new Set([
|
|
|
1245
1270
|
"unit"
|
|
1246
1271
|
]);
|
|
1247
1272
|
function FeesTable({ value, editable = false, onChange, labels: labels2, size = "md", tagOrder = [], language = "vi" }) {
|
|
1248
|
-
const [search, setSearch] = (0,
|
|
1249
|
-
const [tag, setTag] = (0,
|
|
1250
|
-
const [page, setPage] = (0,
|
|
1251
|
-
const [pageSize, setPageSize] = (0,
|
|
1252
|
-
const [columnsOpen, setColumnsOpen] = (0,
|
|
1253
|
-
const [typographyOpen, setTypographyOpen] = (0,
|
|
1254
|
-
const [
|
|
1273
|
+
const [search, setSearch] = (0, import_react4.useState)("");
|
|
1274
|
+
const [tag, setTag] = (0, import_react4.useState)("");
|
|
1275
|
+
const [page, setPage] = (0, import_react4.useState)(1);
|
|
1276
|
+
const [pageSize, setPageSize] = (0, import_react4.useState)(FEES_PAGE_SIZE);
|
|
1277
|
+
const [columnsOpen, setColumnsOpen] = (0, import_react4.useState)(false);
|
|
1278
|
+
const [typographyOpen, setTypographyOpen] = (0, import_react4.useState)(false);
|
|
1279
|
+
const [selectedColumnKey, setSelectedColumnKey] = (0, import_react4.useState)("");
|
|
1255
1280
|
const english = language === "en";
|
|
1256
1281
|
const canEdit = editable && Boolean(onChange);
|
|
1257
|
-
const tableRoot = (0,
|
|
1258
|
-
(0,
|
|
1282
|
+
const tableRoot = (0, import_react4.useRef)(null);
|
|
1283
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
1259
1284
|
const root = tableRoot.current;
|
|
1260
1285
|
if (!root || !canEdit) return;
|
|
1261
1286
|
const editors = [
|
|
@@ -1273,11 +1298,11 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
|
|
|
1273
1298
|
canEdit,
|
|
1274
1299
|
value.columns
|
|
1275
1300
|
]);
|
|
1276
|
-
const dialogId = (0,
|
|
1301
|
+
const dialogId = (0, import_react4.useId)();
|
|
1277
1302
|
const mobileFontScale = Math.max(1, (value.typography?.thead?.fontSize ?? 8) / 8, (value.typography?.tbody?.fontSize ?? 10) / 10);
|
|
1278
|
-
const [createTagOpen, setCreateTagOpen] = (0,
|
|
1279
|
-
const [tagDraft, setTagDraft] = (0,
|
|
1280
|
-
const [deleteTarget, setDeleteTarget] = (0,
|
|
1303
|
+
const [createTagOpen, setCreateTagOpen] = (0, import_react4.useState)(false);
|
|
1304
|
+
const [tagDraft, setTagDraft] = (0, import_react4.useState)("");
|
|
1305
|
+
const [deleteTarget, setDeleteTarget] = (0, import_react4.useState)(null);
|
|
1281
1306
|
const confirmDelete = () => {
|
|
1282
1307
|
if (!deleteTarget || !canEdit) return;
|
|
1283
1308
|
if (deleteTarget.kind === "row") {
|
|
@@ -1332,16 +1357,12 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
|
|
|
1332
1357
|
const filtered = filterFeesRows(value, search, activeTag);
|
|
1333
1358
|
const displayedRows = canEdit ? filtered : sortFeesRowsByName(filtered, language);
|
|
1334
1359
|
const pagination = paginateFeesRows(displayedRows, page, pageSize);
|
|
1335
|
-
const selectedColumn =
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
const selectedAlign = selectedTarget?.part === "thead" ? selectedColumn?.textAlign : selectedRow?.cellAlignments?.[selectedTarget?.columnKey ?? ""];
|
|
1339
|
-
const selectedLabel = selectedTarget ? selectedTarget.part === "thead" ? `${english ? "Header" : "Ti\xEAu \u0111\u1EC1"}: ${selectedColumn?.title}` : `${selectedColumn?.title} \u2014 ${selectedRow?.cells.name || (english ? "New row" : "H\xE0ng m\u1EDBi")}` : void 0;
|
|
1340
|
-
(0, import_react3.useLayoutEffect)(() => {
|
|
1341
|
-
if (selectedCell && !selectedTarget) setSelectedCell(null);
|
|
1360
|
+
const selectedColumn = value.columns.find((column) => column.key === selectedColumnKey);
|
|
1361
|
+
(0, import_react4.useLayoutEffect)(() => {
|
|
1362
|
+
if (selectedColumnKey && !selectedColumn) setSelectedColumnKey("");
|
|
1342
1363
|
}, [
|
|
1343
|
-
|
|
1344
|
-
|
|
1364
|
+
selectedColumnKey,
|
|
1365
|
+
selectedColumn
|
|
1345
1366
|
]);
|
|
1346
1367
|
const moveColumn = (from, to) => onChange?.({
|
|
1347
1368
|
...value,
|
|
@@ -1398,11 +1419,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
|
|
|
1398
1419
|
style: {
|
|
1399
1420
|
textAlign: column.textAlign ?? value.typography?.thead?.textAlign ?? "left"
|
|
1400
1421
|
},
|
|
1401
|
-
"data-fees-
|
|
1402
|
-
onFocus: () => setSelectedCell({
|
|
1403
|
-
part: "thead",
|
|
1404
|
-
columnKey: column.key
|
|
1405
|
-
}),
|
|
1422
|
+
"data-fees-column-selected": selectedColumnKey === column.key,
|
|
1406
1423
|
onChange: (event) => onChange?.({
|
|
1407
1424
|
...value,
|
|
1408
1425
|
columns: value.columns.map((item) => item.key === column.key ? {
|
|
@@ -1436,14 +1453,9 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
|
|
|
1436
1453
|
value: row.cells[column.key] ?? "",
|
|
1437
1454
|
"aria-label": `${column.title} \u2014 ${row.cells.name || "H\xE0ng m\u1EDBi"}`,
|
|
1438
1455
|
style: {
|
|
1439
|
-
textAlign: row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign ?? "left"
|
|
1456
|
+
textAlign: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign ?? "left"
|
|
1440
1457
|
},
|
|
1441
|
-
"data-fees-
|
|
1442
|
-
onFocus: () => setSelectedCell({
|
|
1443
|
-
part: "tbody",
|
|
1444
|
-
rowId: row.id,
|
|
1445
|
-
columnKey: column.key
|
|
1446
|
-
}),
|
|
1458
|
+
"data-fees-column-selected": selectedColumnKey === column.key,
|
|
1447
1459
|
onChange: (event) => changeRow(row.id, {
|
|
1448
1460
|
cells: {
|
|
1449
1461
|
...row.cells,
|
|
@@ -1451,7 +1463,7 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
|
|
|
1451
1463
|
}
|
|
1452
1464
|
})
|
|
1453
1465
|
}) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FeesCellContent, {
|
|
1454
|
-
$align: row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign,
|
|
1466
|
+
$align: column.textAlign ?? row.cellAlignments?.[column.key] ?? value.typography?.tbody?.textAlign,
|
|
1455
1467
|
$alignRight: rightAlignedColumns.has(column.key),
|
|
1456
1468
|
children: row.cells[column.key] ?? ""
|
|
1457
1469
|
})
|
|
@@ -1654,12 +1666,13 @@ function FeesTable({ value, editable = false, onChange, labels: labels2, size =
|
|
|
1654
1666
|
})
|
|
1655
1667
|
})
|
|
1656
1668
|
}),
|
|
1657
|
-
canEdit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1658
|
-
|
|
1659
|
-
|
|
1669
|
+
canEdit && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FeesColumnAlignmentControls, {
|
|
1670
|
+
columns: value.columns,
|
|
1671
|
+
columnKey: selectedColumnKey,
|
|
1660
1672
|
english,
|
|
1673
|
+
onSelectColumn: setSelectedColumnKey,
|
|
1661
1674
|
onChange: (textAlign) => {
|
|
1662
|
-
if (
|
|
1675
|
+
if (selectedColumn) onChange?.(setFeesColumnAlignment(value, selectedColumn.key, textAlign));
|
|
1663
1676
|
}
|
|
1664
1677
|
}),
|
|
1665
1678
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AlignedFeesTable, {
|