trotl-table 1.0.66 → 1.0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Table.cjs.js +65 -2
- package/dist/Table.cjs.js.map +1 -1
- package/dist/Table.esm.js +65 -2
- package/dist/Table.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/Table.cjs.js
CHANGED
|
@@ -10347,9 +10347,72 @@ function TableInner({
|
|
|
10347
10347
|
|
|
10348
10348
|
// Input column type (editable text)
|
|
10349
10349
|
if (col && col.type === 'input') {
|
|
10350
|
+
const text = isNoData ? "" : v == null ? "" : String(v);
|
|
10351
|
+
return /*#__PURE__*/React.createElement("input", {
|
|
10352
|
+
type: "text",
|
|
10353
|
+
className: "table-cell-input",
|
|
10354
|
+
value: text,
|
|
10355
|
+
placeholder: isNoData ? "..." : undefined,
|
|
10356
|
+
title: isNoData ? translate("noData") : text,
|
|
10357
|
+
onClick: e => {
|
|
10358
|
+
e.stopPropagation();
|
|
10359
|
+
triggerCellCallback(row, col, text);
|
|
10360
|
+
},
|
|
10361
|
+
onChange: e => {
|
|
10362
|
+
const next = e.target.value;
|
|
10363
|
+
setLocalData(prev => {
|
|
10364
|
+
if (isGrouped) {
|
|
10365
|
+
return prev.map(g => ({
|
|
10366
|
+
...g,
|
|
10367
|
+
rows: (g.rows || []).map(r => r.id === row.id ? {
|
|
10368
|
+
...r,
|
|
10369
|
+
[accessor]: next
|
|
10370
|
+
} : r)
|
|
10371
|
+
}));
|
|
10372
|
+
}
|
|
10373
|
+
return (prev || []).map(r => r.id === row.id ? {
|
|
10374
|
+
...r,
|
|
10375
|
+
[accessor]: next
|
|
10376
|
+
} : r);
|
|
10377
|
+
});
|
|
10378
|
+
refreshTriggerRef.current?.();
|
|
10379
|
+
try {
|
|
10380
|
+
onCellChangeRef.current?.(row, accessor, next);
|
|
10381
|
+
} catch (err) {
|
|
10382
|
+
console.error('onCellChange error', err);
|
|
10383
|
+
}
|
|
10384
|
+
},
|
|
10385
|
+
style: {
|
|
10386
|
+
border: "1px solid var(--border-light, #ccc)",
|
|
10387
|
+
padding: "2px 4px"
|
|
10388
|
+
}
|
|
10389
|
+
});
|
|
10390
|
+
}
|
|
10391
|
+
|
|
10392
|
+
// Number column type (format decimals) - default two decimals
|
|
10393
|
+
if (col && col.type === 'number') {
|
|
10394
|
+
if (isNoData) {
|
|
10395
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
10396
|
+
title: translate("noData")
|
|
10397
|
+
}, "...");
|
|
10398
|
+
}
|
|
10399
|
+
const rawValue = Number(v);
|
|
10400
|
+
if (Number.isNaN(rawValue)) {
|
|
10401
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
10402
|
+
title: String(v)
|
|
10403
|
+
}, String(v));
|
|
10404
|
+
}
|
|
10405
|
+
let precision = 2;
|
|
10406
|
+
if (col.numberFormat != null) {
|
|
10407
|
+
const nf = Number(col.numberFormat);
|
|
10408
|
+
if (!Number.isNaN(nf) && nf >= 0) {
|
|
10409
|
+
precision = nf;
|
|
10410
|
+
}
|
|
10411
|
+
}
|
|
10412
|
+
const formatted = rawValue.toFixed(precision);
|
|
10350
10413
|
return /*#__PURE__*/React.createElement("span", {
|
|
10351
|
-
title:
|
|
10352
|
-
},
|
|
10414
|
+
title: formatted
|
|
10415
|
+
}, formatted);
|
|
10353
10416
|
}
|
|
10354
10417
|
|
|
10355
10418
|
// If column has dateFormat, format value as date/time
|