@martinsura/ui 0.1.12 → 0.1.14
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/index.cjs +22 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1549,7 +1549,7 @@ var columnTypeWidth = {
|
|
|
1549
1549
|
datetime: 130,
|
|
1550
1550
|
dot: 36
|
|
1551
1551
|
};
|
|
1552
|
-
function formatCellValue(value, type) {
|
|
1552
|
+
function formatCellValue(value, type, moneyOptions) {
|
|
1553
1553
|
if (value === null || value === void 0) return "-";
|
|
1554
1554
|
switch (type) {
|
|
1555
1555
|
case "date":
|
|
@@ -1560,6 +1560,16 @@ function formatCellValue(value, type) {
|
|
|
1560
1560
|
return /* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", readOnly: true, checked: value, className: "cursor-default" });
|
|
1561
1561
|
case "yes/no":
|
|
1562
1562
|
return value ? "Ano" : "Ne";
|
|
1563
|
+
case "money": {
|
|
1564
|
+
const currency = moneyOptions?.currency ?? "CZK";
|
|
1565
|
+
const decimals = moneyOptions?.decimals ?? 0;
|
|
1566
|
+
return new Intl.NumberFormat("cs-CZ", {
|
|
1567
|
+
style: "currency",
|
|
1568
|
+
currency,
|
|
1569
|
+
minimumFractionDigits: decimals,
|
|
1570
|
+
maximumFractionDigits: decimals
|
|
1571
|
+
}).format(value);
|
|
1572
|
+
}
|
|
1563
1573
|
default:
|
|
1564
1574
|
return String(value);
|
|
1565
1575
|
}
|
|
@@ -1863,6 +1873,7 @@ var Grid = (props) => {
|
|
|
1863
1873
|
props.columns.map((col, i) => {
|
|
1864
1874
|
const isSortable = col.sortBy !== void 0;
|
|
1865
1875
|
const isCurrent = isSortable && grid.sortBy === col.sortBy;
|
|
1876
|
+
const colAlign = col.align ?? (col.type === "money" ? "right" : void 0);
|
|
1866
1877
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1867
1878
|
"th",
|
|
1868
1879
|
{
|
|
@@ -1873,8 +1884,8 @@ var Grid = (props) => {
|
|
|
1873
1884
|
"font-normal text-left whitespace-nowrap",
|
|
1874
1885
|
verticalBorders && tableHeaderVerticalBorderClass,
|
|
1875
1886
|
isSortable && "cursor-pointer select-none hover:bg-white/10",
|
|
1876
|
-
|
|
1877
|
-
|
|
1887
|
+
colAlign === "center" && "text-center",
|
|
1888
|
+
colAlign === "right" && "text-right",
|
|
1878
1889
|
props.classNames?.headerCell
|
|
1879
1890
|
),
|
|
1880
1891
|
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
@@ -1902,7 +1913,7 @@ var Grid = (props) => {
|
|
|
1902
1913
|
}
|
|
1903
1914
|
) }) : items.map((item, rowIdx) => {
|
|
1904
1915
|
const key = getKey2(item, items, props.rowKey);
|
|
1905
|
-
const isSelected = selectedKeys.has(key);
|
|
1916
|
+
const isSelected = selectedKeys.has(key) || !!props.isRowSelected?.(item);
|
|
1906
1917
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1907
1918
|
"tr",
|
|
1908
1919
|
{
|
|
@@ -1912,6 +1923,7 @@ var Grid = (props) => {
|
|
|
1912
1923
|
rowIdx % 2 === 1 && !isSelected && neutralSurfaceClasses.subtle,
|
|
1913
1924
|
isSelected && "bg-blue-50",
|
|
1914
1925
|
props.onRowClick && "cursor-pointer hover:bg-blue-50",
|
|
1926
|
+
props.rowClassName?.(item),
|
|
1915
1927
|
props.classNames?.bodyRow
|
|
1916
1928
|
),
|
|
1917
1929
|
children: [
|
|
@@ -1932,9 +1944,10 @@ var Grid = (props) => {
|
|
|
1932
1944
|
}
|
|
1933
1945
|
),
|
|
1934
1946
|
props.columns.map((col, colIdx) => {
|
|
1935
|
-
const content = col.render ? col.render(item) : col.dataField ? formatCellValue(getNestedValue(item, col.dataField), col.type) : null;
|
|
1936
|
-
const
|
|
1937
|
-
const
|
|
1947
|
+
const content = col.render ? col.render(item) : col.dataField ? formatCellValue(getNestedValue(item, col.dataField), col.type, col.moneyOptions) : null;
|
|
1948
|
+
const effectiveAlign = col.align ?? (col.type === "money" ? "right" : void 0);
|
|
1949
|
+
const centeredContent = effectiveAlign === "center";
|
|
1950
|
+
const rightAlignedContent = effectiveAlign === "right";
|
|
1938
1951
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1939
1952
|
"td",
|
|
1940
1953
|
{
|
|
@@ -1945,8 +1958,8 @@ var Grid = (props) => {
|
|
|
1945
1958
|
verticalBorders && tableCellVerticalBorderClass,
|
|
1946
1959
|
col.ellipsis && "max-w-60 truncate",
|
|
1947
1960
|
col.wrap && "whitespace-normal",
|
|
1948
|
-
|
|
1949
|
-
|
|
1961
|
+
effectiveAlign === "center" && "text-center",
|
|
1962
|
+
effectiveAlign === "right" && "text-right",
|
|
1950
1963
|
col.type === "dot" && "w-9",
|
|
1951
1964
|
props.classNames?.bodyCell
|
|
1952
1965
|
),
|