@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 +20 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -331,7 +331,11 @@ type InlineEditProps = {
|
|
|
331
331
|
declare const InlineEdit: ({ value, placeholder, multiline, onSave, label, className }: InlineEditProps) => react_jsx_runtime.JSX.Element;
|
|
332
332
|
|
|
333
333
|
type TableSize = "small" | "middle" | "large";
|
|
334
|
-
type ColumnType = "date" | "datetime" | "yes/no" | "boolean" | "dot";
|
|
334
|
+
type ColumnType = "date" | "datetime" | "yes/no" | "boolean" | "dot" | "money";
|
|
335
|
+
type MoneyOptions = {
|
|
336
|
+
currency?: string;
|
|
337
|
+
decimals?: number;
|
|
338
|
+
};
|
|
335
339
|
type TableColumn<T> = {
|
|
336
340
|
title?: string;
|
|
337
341
|
dataField?: keyof T;
|
|
@@ -399,6 +403,7 @@ type GridColumn<T, TSortField = never> = {
|
|
|
399
403
|
dataField?: NestedKeyOf<T>;
|
|
400
404
|
sortBy?: TSortField;
|
|
401
405
|
type?: ColumnType;
|
|
406
|
+
moneyOptions?: MoneyOptions;
|
|
402
407
|
align?: "left" | "center" | "right";
|
|
403
408
|
width?: number | string;
|
|
404
409
|
wrap?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -331,7 +331,11 @@ type InlineEditProps = {
|
|
|
331
331
|
declare const InlineEdit: ({ value, placeholder, multiline, onSave, label, className }: InlineEditProps) => react_jsx_runtime.JSX.Element;
|
|
332
332
|
|
|
333
333
|
type TableSize = "small" | "middle" | "large";
|
|
334
|
-
type ColumnType = "date" | "datetime" | "yes/no" | "boolean" | "dot";
|
|
334
|
+
type ColumnType = "date" | "datetime" | "yes/no" | "boolean" | "dot" | "money";
|
|
335
|
+
type MoneyOptions = {
|
|
336
|
+
currency?: string;
|
|
337
|
+
decimals?: number;
|
|
338
|
+
};
|
|
335
339
|
type TableColumn<T> = {
|
|
336
340
|
title?: string;
|
|
337
341
|
dataField?: keyof T;
|
|
@@ -399,6 +403,7 @@ type GridColumn<T, TSortField = never> = {
|
|
|
399
403
|
dataField?: NestedKeyOf<T>;
|
|
400
404
|
sortBy?: TSortField;
|
|
401
405
|
type?: ColumnType;
|
|
406
|
+
moneyOptions?: MoneyOptions;
|
|
402
407
|
align?: "left" | "center" | "right";
|
|
403
408
|
width?: number | string;
|
|
404
409
|
wrap?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1543,7 +1543,7 @@ var columnTypeWidth = {
|
|
|
1543
1543
|
datetime: 130,
|
|
1544
1544
|
dot: 36
|
|
1545
1545
|
};
|
|
1546
|
-
function formatCellValue(value, type) {
|
|
1546
|
+
function formatCellValue(value, type, moneyOptions) {
|
|
1547
1547
|
if (value === null || value === void 0) return "-";
|
|
1548
1548
|
switch (type) {
|
|
1549
1549
|
case "date":
|
|
@@ -1554,6 +1554,16 @@ function formatCellValue(value, type) {
|
|
|
1554
1554
|
return /* @__PURE__ */ jsx("input", { type: "checkbox", readOnly: true, checked: value, className: "cursor-default" });
|
|
1555
1555
|
case "yes/no":
|
|
1556
1556
|
return value ? "Ano" : "Ne";
|
|
1557
|
+
case "money": {
|
|
1558
|
+
const currency = moneyOptions?.currency ?? "CZK";
|
|
1559
|
+
const decimals = moneyOptions?.decimals ?? 0;
|
|
1560
|
+
return new Intl.NumberFormat("cs-CZ", {
|
|
1561
|
+
style: "currency",
|
|
1562
|
+
currency,
|
|
1563
|
+
minimumFractionDigits: decimals,
|
|
1564
|
+
maximumFractionDigits: decimals
|
|
1565
|
+
}).format(value);
|
|
1566
|
+
}
|
|
1557
1567
|
default:
|
|
1558
1568
|
return String(value);
|
|
1559
1569
|
}
|
|
@@ -1857,6 +1867,7 @@ var Grid = (props) => {
|
|
|
1857
1867
|
props.columns.map((col, i) => {
|
|
1858
1868
|
const isSortable = col.sortBy !== void 0;
|
|
1859
1869
|
const isCurrent = isSortable && grid.sortBy === col.sortBy;
|
|
1870
|
+
const colAlign = col.align ?? (col.type === "money" ? "right" : void 0);
|
|
1860
1871
|
return /* @__PURE__ */ jsx(
|
|
1861
1872
|
"th",
|
|
1862
1873
|
{
|
|
@@ -1867,8 +1878,8 @@ var Grid = (props) => {
|
|
|
1867
1878
|
"font-normal text-left whitespace-nowrap",
|
|
1868
1879
|
verticalBorders && tableHeaderVerticalBorderClass,
|
|
1869
1880
|
isSortable && "cursor-pointer select-none hover:bg-white/10",
|
|
1870
|
-
|
|
1871
|
-
|
|
1881
|
+
colAlign === "center" && "text-center",
|
|
1882
|
+
colAlign === "right" && "text-right",
|
|
1872
1883
|
props.classNames?.headerCell
|
|
1873
1884
|
),
|
|
1874
1885
|
children: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
|
|
@@ -1927,9 +1938,10 @@ var Grid = (props) => {
|
|
|
1927
1938
|
}
|
|
1928
1939
|
),
|
|
1929
1940
|
props.columns.map((col, colIdx) => {
|
|
1930
|
-
const content = col.render ? col.render(item) : col.dataField ? formatCellValue(getNestedValue(item, col.dataField), col.type) : null;
|
|
1931
|
-
const
|
|
1932
|
-
const
|
|
1941
|
+
const content = col.render ? col.render(item) : col.dataField ? formatCellValue(getNestedValue(item, col.dataField), col.type, col.moneyOptions) : null;
|
|
1942
|
+
const effectiveAlign = col.align ?? (col.type === "money" ? "right" : void 0);
|
|
1943
|
+
const centeredContent = effectiveAlign === "center";
|
|
1944
|
+
const rightAlignedContent = effectiveAlign === "right";
|
|
1933
1945
|
return /* @__PURE__ */ jsx(
|
|
1934
1946
|
"td",
|
|
1935
1947
|
{
|
|
@@ -1940,8 +1952,8 @@ var Grid = (props) => {
|
|
|
1940
1952
|
verticalBorders && tableCellVerticalBorderClass,
|
|
1941
1953
|
col.ellipsis && "max-w-60 truncate",
|
|
1942
1954
|
col.wrap && "whitespace-normal",
|
|
1943
|
-
|
|
1944
|
-
|
|
1955
|
+
effectiveAlign === "center" && "text-center",
|
|
1956
|
+
effectiveAlign === "right" && "text-right",
|
|
1945
1957
|
col.type === "dot" && "w-9",
|
|
1946
1958
|
props.classNames?.bodyCell
|
|
1947
1959
|
),
|