@martinsura/ui 0.1.13 → 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 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
- col.align === "center" && "text-center",
1877
- col.align === "right" && "text-right",
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: [
@@ -1933,9 +1944,10 @@ var Grid = (props) => {
1933
1944
  }
1934
1945
  ),
1935
1946
  props.columns.map((col, colIdx) => {
1936
- const content = col.render ? col.render(item) : col.dataField ? formatCellValue(getNestedValue(item, col.dataField), col.type) : null;
1937
- const centeredContent = col.align === "center";
1938
- const rightAlignedContent = col.align === "right";
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";
1939
1951
  return /* @__PURE__ */ jsxRuntime.jsx(
1940
1952
  "td",
1941
1953
  {
@@ -1946,8 +1958,8 @@ var Grid = (props) => {
1946
1958
  verticalBorders && tableCellVerticalBorderClass,
1947
1959
  col.ellipsis && "max-w-60 truncate",
1948
1960
  col.wrap && "whitespace-normal",
1949
- col.align === "center" && "text-center",
1950
- col.align === "right" && "text-right",
1961
+ effectiveAlign === "center" && "text-center",
1962
+ effectiveAlign === "right" && "text-right",
1951
1963
  col.type === "dot" && "w-9",
1952
1964
  props.classNames?.bodyCell
1953
1965
  ),