pam-grid 1.0.8 → 1.0.9
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.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +51 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -16,9 +16,13 @@ interface SortState {
|
|
|
16
16
|
dir: SortDir;
|
|
17
17
|
}
|
|
18
18
|
interface TableAction<T extends object> {
|
|
19
|
-
label: string;
|
|
20
|
-
icon?: string;
|
|
19
|
+
label?: string | ((row: T) => string);
|
|
20
|
+
icon?: string | ((row: T) => string);
|
|
21
|
+
onlyIcon?: boolean;
|
|
22
|
+
className?: string | ((row: T) => string);
|
|
23
|
+
disabled?: boolean | ((row: T) => boolean);
|
|
21
24
|
isVisible?: boolean | ((row: T) => boolean);
|
|
25
|
+
tooltip?: string | ((row: T) => string);
|
|
22
26
|
onClick: (row: T) => void;
|
|
23
27
|
}
|
|
24
28
|
interface AdvancedFilter {
|
package/dist/index.d.ts
CHANGED
|
@@ -16,9 +16,13 @@ interface SortState {
|
|
|
16
16
|
dir: SortDir;
|
|
17
17
|
}
|
|
18
18
|
interface TableAction<T extends object> {
|
|
19
|
-
label: string;
|
|
20
|
-
icon?: string;
|
|
19
|
+
label?: string | ((row: T) => string);
|
|
20
|
+
icon?: string | ((row: T) => string);
|
|
21
|
+
onlyIcon?: boolean;
|
|
22
|
+
className?: string | ((row: T) => string);
|
|
23
|
+
disabled?: boolean | ((row: T) => boolean);
|
|
21
24
|
isVisible?: boolean | ((row: T) => boolean);
|
|
25
|
+
tooltip?: string | ((row: T) => string);
|
|
22
26
|
onClick: (row: T) => void;
|
|
23
27
|
}
|
|
24
28
|
interface AdvancedFilter {
|
package/dist/index.js
CHANGED
|
@@ -97,7 +97,7 @@ function AdvanceFilter({
|
|
|
97
97
|
);
|
|
98
98
|
};
|
|
99
99
|
if (!type) return null;
|
|
100
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { width:
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { width: 270 }, onClick: (e) => e.stopPropagation(), children: [
|
|
101
101
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-2", children: [
|
|
102
102
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "form-label", children: "Condition" }),
|
|
103
103
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
@@ -222,6 +222,9 @@ function useLocalStorageState(key, initialValue) {
|
|
|
222
222
|
}, [key]);
|
|
223
223
|
return [value, updateValue];
|
|
224
224
|
}
|
|
225
|
+
var resolveValue = (value, row) => {
|
|
226
|
+
return typeof value === "function" ? value(row) : value;
|
|
227
|
+
};
|
|
225
228
|
|
|
226
229
|
// src/components/FacetFilter.tsx
|
|
227
230
|
var import_react3 = require("react");
|
|
@@ -1562,8 +1565,7 @@ var PamGrid = ({
|
|
|
1562
1565
|
{
|
|
1563
1566
|
className: `bx bx-sm ${sortBy.dir === "asc" ? "bxs-chevron-up" : "bxs-chevron-down"} cursor-pointer`
|
|
1564
1567
|
}
|
|
1565
|
-
)
|
|
1566
|
-
col.pinned === col.key && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("i", { className: "bx bx-x cursor-pointer" })
|
|
1568
|
+
)
|
|
1567
1569
|
]
|
|
1568
1570
|
}
|
|
1569
1571
|
),
|
|
@@ -1751,34 +1753,58 @@ var PamGrid = ({
|
|
|
1751
1753
|
width: "1%",
|
|
1752
1754
|
whiteSpace: "nowrap"
|
|
1753
1755
|
},
|
|
1754
|
-
children: isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-center
|
|
1756
|
+
children: isDropdown ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-center", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TableAction, { gridFetaures: features, row }) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1755
1757
|
"div",
|
|
1756
1758
|
{
|
|
1757
1759
|
className: "d-inline-flex justify-content-center align-items-center gap-2",
|
|
1758
1760
|
style: { minWidth: "fit-content", padding: "0 4px" },
|
|
1759
1761
|
children: Array.isArray(features.actions) ? features.actions.filter((act) => {
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1762
|
+
const visible = resolveValue(
|
|
1763
|
+
act.isVisible ?? true,
|
|
1764
|
+
row
|
|
1765
|
+
);
|
|
1766
|
+
return visible;
|
|
1767
|
+
}).map((act, i) => {
|
|
1768
|
+
const label = resolveValue(act.label, row);
|
|
1769
|
+
const icon = resolveValue(act.icon, row);
|
|
1770
|
+
const className = resolveValue(act.className, row);
|
|
1771
|
+
const disabled = resolveValue(
|
|
1772
|
+
act.disabled ?? false,
|
|
1773
|
+
row
|
|
1774
|
+
);
|
|
1775
|
+
return act.onlyIcon ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1776
|
+
"i",
|
|
1777
|
+
{
|
|
1778
|
+
title: label,
|
|
1779
|
+
onClick: (e) => {
|
|
1780
|
+
e.stopPropagation();
|
|
1781
|
+
if (!disabled) act.onClick?.(row);
|
|
1782
|
+
},
|
|
1783
|
+
className: `${icon} ${disabled ? "opacity-50" : ""}`,
|
|
1784
|
+
style: {
|
|
1785
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
1786
|
+
},
|
|
1787
|
+
onMouseMove: (e) => typeof label === "string" && showTooltip(label, e.clientX, e.clientY),
|
|
1788
|
+
onMouseLeave: hideTooltip
|
|
1789
|
+
},
|
|
1790
|
+
i
|
|
1791
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1792
|
+
"button",
|
|
1793
|
+
{
|
|
1794
|
+
className,
|
|
1795
|
+
disabled,
|
|
1796
|
+
onClick: (e) => {
|
|
1797
|
+
e.stopPropagation();
|
|
1798
|
+
if (!disabled) act.onClick?.(row);
|
|
1799
|
+
},
|
|
1800
|
+
children: [
|
|
1801
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("i", { className: `${icon} me-1` }),
|
|
1802
|
+
label
|
|
1803
|
+
]
|
|
1774
1804
|
},
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
onMouseLeave: hideTooltip
|
|
1779
|
-
},
|
|
1780
|
-
i
|
|
1781
|
-
)) : typeof features.actions === "function" ? features.actions(row, toggleExpand) : null
|
|
1805
|
+
i
|
|
1806
|
+
);
|
|
1807
|
+
}) : typeof features.actions === "function" ? features.actions(row, toggleExpand) : null
|
|
1782
1808
|
}
|
|
1783
1809
|
)
|
|
1784
1810
|
}
|