@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.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;
|
|
@@ -420,6 +425,8 @@ type GridProps<T, TSortField = never, TFilter extends object = Record<string, ne
|
|
|
420
425
|
size?: TableSize;
|
|
421
426
|
selection?: GridSelection<T>;
|
|
422
427
|
onRowClick?: (item: T) => void;
|
|
428
|
+
rowClassName?: (item: T) => string;
|
|
429
|
+
isRowSelected?: (item: T) => boolean;
|
|
423
430
|
verticalBorders?: boolean;
|
|
424
431
|
attachedTop?: boolean;
|
|
425
432
|
showPageNumberChanger?: 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;
|
|
@@ -420,6 +425,8 @@ type GridProps<T, TSortField = never, TFilter extends object = Record<string, ne
|
|
|
420
425
|
size?: TableSize;
|
|
421
426
|
selection?: GridSelection<T>;
|
|
422
427
|
onRowClick?: (item: T) => void;
|
|
428
|
+
rowClassName?: (item: T) => string;
|
|
429
|
+
isRowSelected?: (item: T) => boolean;
|
|
423
430
|
verticalBorders?: boolean;
|
|
424
431
|
attachedTop?: boolean;
|
|
425
432
|
showPageNumberChanger?: 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: [
|
|
@@ -1896,7 +1907,7 @@ var Grid = (props) => {
|
|
|
1896
1907
|
}
|
|
1897
1908
|
) }) : items.map((item, rowIdx) => {
|
|
1898
1909
|
const key = getKey2(item, items, props.rowKey);
|
|
1899
|
-
const isSelected = selectedKeys.has(key);
|
|
1910
|
+
const isSelected = selectedKeys.has(key) || !!props.isRowSelected?.(item);
|
|
1900
1911
|
return /* @__PURE__ */ jsxs(
|
|
1901
1912
|
"tr",
|
|
1902
1913
|
{
|
|
@@ -1906,6 +1917,7 @@ var Grid = (props) => {
|
|
|
1906
1917
|
rowIdx % 2 === 1 && !isSelected && neutralSurfaceClasses.subtle,
|
|
1907
1918
|
isSelected && "bg-blue-50",
|
|
1908
1919
|
props.onRowClick && "cursor-pointer hover:bg-blue-50",
|
|
1920
|
+
props.rowClassName?.(item),
|
|
1909
1921
|
props.classNames?.bodyRow
|
|
1910
1922
|
),
|
|
1911
1923
|
children: [
|
|
@@ -1926,9 +1938,10 @@ var Grid = (props) => {
|
|
|
1926
1938
|
}
|
|
1927
1939
|
),
|
|
1928
1940
|
props.columns.map((col, colIdx) => {
|
|
1929
|
-
const content = col.render ? col.render(item) : col.dataField ? formatCellValue(getNestedValue(item, col.dataField), col.type) : null;
|
|
1930
|
-
const
|
|
1931
|
-
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";
|
|
1932
1945
|
return /* @__PURE__ */ jsx(
|
|
1933
1946
|
"td",
|
|
1934
1947
|
{
|
|
@@ -1939,8 +1952,8 @@ var Grid = (props) => {
|
|
|
1939
1952
|
verticalBorders && tableCellVerticalBorderClass,
|
|
1940
1953
|
col.ellipsis && "max-w-60 truncate",
|
|
1941
1954
|
col.wrap && "whitespace-normal",
|
|
1942
|
-
|
|
1943
|
-
|
|
1955
|
+
effectiveAlign === "center" && "text-center",
|
|
1956
|
+
effectiveAlign === "right" && "text-right",
|
|
1944
1957
|
col.type === "dot" && "w-9",
|
|
1945
1958
|
props.classNames?.bodyCell
|
|
1946
1959
|
),
|