hs-uix 2.1.1 → 2.2.0
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/README.md +3 -1
- package/common-components.d.ts +319 -68
- package/dist/calendar.js +355 -57
- package/dist/calendar.mjs +356 -57
- package/dist/common-components.js +3546 -88
- package/dist/common-components.mjs +3530 -84
- package/dist/datatable.js +108 -18
- package/dist/datatable.mjs +108 -18
- package/dist/experimental.js +2876 -0
- package/dist/experimental.mjs +2883 -0
- package/dist/feed.js +267 -38
- package/dist/feed.mjs +260 -37
- package/dist/filter.js +1379 -0
- package/dist/filter.mjs +1334 -0
- package/dist/form.js +222 -26
- package/dist/form.mjs +227 -27
- package/dist/index.js +3208 -287
- package/dist/index.mjs +3156 -283
- package/dist/kanban.js +282 -62
- package/dist/kanban.mjs +273 -61
- package/dist/safe.js +9207 -0
- package/dist/safe.mjs +9298 -0
- package/dist/utils.js +491 -75
- package/dist/utils.mjs +491 -75
- package/experimental.d.ts +1 -0
- package/filter.d.ts +1 -0
- package/index.d.ts +45 -3
- package/package.json +19 -1
- package/safe.d.ts +1 -0
- package/src/calendar/README.md +74 -5
- package/src/calendar/index.d.ts +95 -1
- package/src/common-components/README.md +140 -1
- package/src/datatable/README.md +0 -2
- package/src/experimental/README.md +126 -0
- package/src/experimental/index.d.ts +346 -0
- package/src/feed/README.md +69 -0
- package/src/feed/index.d.ts +103 -0
- package/src/filter/README.md +148 -0
- package/src/filter/index.d.ts +221 -0
- package/src/form/README.md +132 -4
- package/src/form/index.d.ts +82 -1
- package/src/kanban/README.md +119 -6
- package/src/kanban/index.d.ts +153 -2
- package/src/safe/README.md +108 -0
- package/src/safe/index.d.ts +158 -0
- package/src/utils/README.md +39 -0
- package/src/wizard/README.md +158 -0
- package/src/wizard/index.d.ts +138 -0
- package/utils.d.ts +17 -0
package/dist/datatable.js
CHANGED
|
@@ -541,7 +541,7 @@ var GENERATED_ICONS = {
|
|
|
541
541
|
"ZoomOut": { "viewBox": "0 0 32 32", "paths": ["M14.42 26.75c2.85 0 5.47-.97 7.56-2.6l-.03.02 5.28 5.34a1.619 1.619 0 0 0 2.76-1.15c0-.45-.18-.85-.47-1.14l-5.33-5.33c1.59-2.06 2.55-4.68 2.55-7.52C26.74 7.54 21.2 2 14.37 2S2 7.55 2 14.38s5.54 12.37 12.37 12.37h.05m0-21.55c5.06 0 9.16 4.1 9.16 9.16s-4.1 9.16-9.16 9.16-9.16-4.1-9.16-9.16c.01-5.05 4.11-9.14 9.16-9.15Zm-4.31 10.78h8.62c.89 0 1.62-.72 1.62-1.62s-.72-1.62-1.62-1.62h-8.62c-.89 0-1.62.72-1.62 1.62s.72 1.62 1.62 1.62"] }
|
|
542
542
|
};
|
|
543
543
|
|
|
544
|
-
// src/common-components/
|
|
544
|
+
// src/common-components/nativeIconNames.js
|
|
545
545
|
var NATIVE_ICON_NAMES = /* @__PURE__ */ new Set([
|
|
546
546
|
"add",
|
|
547
547
|
"appointment",
|
|
@@ -553,12 +553,12 @@ var NATIVE_ICON_NAMES = /* @__PURE__ */ new Set([
|
|
|
553
553
|
"block",
|
|
554
554
|
"book",
|
|
555
555
|
"bulb",
|
|
556
|
+
"callTranscript",
|
|
556
557
|
"calling",
|
|
557
558
|
"callingHangup",
|
|
558
559
|
"callingMade",
|
|
559
560
|
"callingMissed",
|
|
560
561
|
"callingVoicemail",
|
|
561
|
-
"callTranscript",
|
|
562
562
|
"campaigns",
|
|
563
563
|
"cap",
|
|
564
564
|
"checkCircle",
|
|
@@ -587,13 +587,13 @@ var NATIVE_ICON_NAMES = /* @__PURE__ */ new Set([
|
|
|
587
587
|
"enroll",
|
|
588
588
|
"exclamation",
|
|
589
589
|
"exclamationCircle",
|
|
590
|
-
"facebook",
|
|
591
590
|
"faceHappy",
|
|
592
591
|
"faceHappyFilled",
|
|
593
592
|
"faceNeutral",
|
|
594
593
|
"faceNeutralFilled",
|
|
595
594
|
"faceSad",
|
|
596
595
|
"faceSadFilled",
|
|
596
|
+
"facebook",
|
|
597
597
|
"favoriteHollow",
|
|
598
598
|
"file",
|
|
599
599
|
"filledXCircleIcon",
|
|
@@ -734,6 +734,8 @@ var NATIVE_ICON_NAMES = /* @__PURE__ */ new Set([
|
|
|
734
734
|
"zoomIn",
|
|
735
735
|
"zoomOut"
|
|
736
736
|
]);
|
|
737
|
+
|
|
738
|
+
// src/common-components/Icon.js
|
|
737
739
|
var NATIVE_COLORS = /* @__PURE__ */ new Set(["inherit", "alert", "warning", "success"]);
|
|
738
740
|
var NATIVE_SIZE_TOKENS = {
|
|
739
741
|
sm: "sm",
|
|
@@ -946,6 +948,7 @@ var CollectionFilterControl = ({
|
|
|
946
948
|
{ key: name, direction: "row", align: "center", gap: "xs" },
|
|
947
949
|
h3(import_ui_extensions5.DateInput, {
|
|
948
950
|
name: `${controlName}-from`,
|
|
951
|
+
label: filter.fromLabel ?? labels.dateFrom,
|
|
949
952
|
placeholder: filter.fromLabel ?? labels.dateFrom,
|
|
950
953
|
format: "medium",
|
|
951
954
|
value: rangeValue.from ?? null,
|
|
@@ -954,6 +957,7 @@ var CollectionFilterControl = ({
|
|
|
954
957
|
h3(Icon, { name: "right", size: "sm" }),
|
|
955
958
|
h3(import_ui_extensions5.DateInput, {
|
|
956
959
|
name: `${controlName}-to`,
|
|
960
|
+
label: filter.toLabel ?? labels.dateTo,
|
|
957
961
|
placeholder: filter.toLabel ?? labels.dateTo,
|
|
958
962
|
format: "medium",
|
|
959
963
|
value: rangeValue.to ?? null,
|
|
@@ -1092,6 +1096,45 @@ var editValidationError = (result) => {
|
|
|
1092
1096
|
return typeof result === "string" ? result : "Invalid value";
|
|
1093
1097
|
};
|
|
1094
1098
|
|
|
1099
|
+
// src/datatable/rowExpansion.js
|
|
1100
|
+
var extractRowId = (row, rowIdField = "id", fallback = void 0) => {
|
|
1101
|
+
const id = row == null ? void 0 : row[rowIdField];
|
|
1102
|
+
return id != null ? id : fallback;
|
|
1103
|
+
};
|
|
1104
|
+
var normalizeExpandedIds = (ids) => {
|
|
1105
|
+
if (ids == null) return /* @__PURE__ */ new Set();
|
|
1106
|
+
const list = ids instanceof Set ? [...ids] : Array.isArray(ids) ? ids : [ids];
|
|
1107
|
+
return new Set(list.filter((id) => id != null));
|
|
1108
|
+
};
|
|
1109
|
+
var expandRowId = (expandedIds, rowId, expandSingle = false) => {
|
|
1110
|
+
if (rowId == null) return expandedIds;
|
|
1111
|
+
if (expandSingle) return /* @__PURE__ */ new Set([rowId]);
|
|
1112
|
+
const next = new Set(expandedIds);
|
|
1113
|
+
next.add(rowId);
|
|
1114
|
+
return next;
|
|
1115
|
+
};
|
|
1116
|
+
var collapseRowId = (expandedIds, rowId) => {
|
|
1117
|
+
if (rowId == null || !expandedIds.has(rowId)) return expandedIds;
|
|
1118
|
+
const next = new Set(expandedIds);
|
|
1119
|
+
next.delete(rowId);
|
|
1120
|
+
return next;
|
|
1121
|
+
};
|
|
1122
|
+
var toggleExpandedId = (expandedIds, rowId, expandSingle = false) => {
|
|
1123
|
+
if (rowId == null) return expandedIds;
|
|
1124
|
+
return expandedIds.has(rowId) ? collapseRowId(expandedIds, rowId) : expandRowId(expandedIds, rowId, expandSingle);
|
|
1125
|
+
};
|
|
1126
|
+
var withDetailRows = (items, expandedIds, rowIdField = "id") => {
|
|
1127
|
+
if (!expandedIds || expandedIds.size === 0) return items;
|
|
1128
|
+
const out = [];
|
|
1129
|
+
items.forEach((item) => {
|
|
1130
|
+
out.push(item);
|
|
1131
|
+
if (item.type === "data" && expandedIds.has(extractRowId(item.row, rowIdField))) {
|
|
1132
|
+
out.push({ type: "detail", row: item.row });
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
return out;
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1095
1138
|
// src/datatable/DataTable.jsx
|
|
1096
1139
|
var import_ui_extensions7 = require("@hubspot/ui-extensions");
|
|
1097
1140
|
var NARROW_EDIT_TYPES = /* @__PURE__ */ new Set(["checkbox", "toggle"]);
|
|
@@ -1303,6 +1346,21 @@ var DataTable = ({
|
|
|
1303
1346
|
hideRowActionsWhenSelectionActive = false,
|
|
1304
1347
|
// hide row action column while selected-row action bar is visible
|
|
1305
1348
|
// -----------------------------------------------------------------------
|
|
1349
|
+
// Row expansion (detail rows)
|
|
1350
|
+
// -----------------------------------------------------------------------
|
|
1351
|
+
renderExpandedRow,
|
|
1352
|
+
// (row) => ReactNode — providing this enables the feature
|
|
1353
|
+
expandedRowIds: externalExpandedRowIds,
|
|
1354
|
+
// controlled — array of expanded row IDs
|
|
1355
|
+
defaultExpandedRowIds,
|
|
1356
|
+
// uncontrolled — initially expanded row IDs
|
|
1357
|
+
onExpandedRowsChange,
|
|
1358
|
+
// (expandedRowIds[]) => void
|
|
1359
|
+
expandOn = "icon",
|
|
1360
|
+
// "icon" (chevron toggle column) | "row" (click row content)
|
|
1361
|
+
expandSingle = false,
|
|
1362
|
+
// accordion mode — expanding a row collapses the others
|
|
1363
|
+
// -----------------------------------------------------------------------
|
|
1306
1364
|
// Inline editing
|
|
1307
1365
|
// -----------------------------------------------------------------------
|
|
1308
1366
|
editMode,
|
|
@@ -1547,6 +1605,25 @@ var DataTable = ({
|
|
|
1547
1605
|
});
|
|
1548
1606
|
return rows;
|
|
1549
1607
|
}, [groupedData, paginatedRows, expandedGroups]);
|
|
1608
|
+
const expandable = typeof renderExpandedRow === "function";
|
|
1609
|
+
const showExpandColumn = expandable && expandOn === "icon";
|
|
1610
|
+
const [internalExpandedRowIds, setInternalExpandedRowIds] = (0, import_react7.useState)(
|
|
1611
|
+
() => normalizeExpandedIds(defaultExpandedRowIds)
|
|
1612
|
+
);
|
|
1613
|
+
const expandedRowIds = (0, import_react7.useMemo)(
|
|
1614
|
+
() => externalExpandedRowIds != null ? normalizeExpandedIds(externalExpandedRowIds) : internalExpandedRowIds,
|
|
1615
|
+
[externalExpandedRowIds, internalExpandedRowIds]
|
|
1616
|
+
);
|
|
1617
|
+
const toggleRowExpanded = (0, import_react7.useCallback)((rowId) => {
|
|
1618
|
+
if (rowId == null) return;
|
|
1619
|
+
const next = toggleExpandedId(expandedRowIds, rowId, expandSingle);
|
|
1620
|
+
if (externalExpandedRowIds == null) setInternalExpandedRowIds(next);
|
|
1621
|
+
if (onExpandedRowsChange) onExpandedRowsChange([...next]);
|
|
1622
|
+
}, [expandedRowIds, expandSingle, externalExpandedRowIds, onExpandedRowsChange]);
|
|
1623
|
+
const renderedRows = (0, import_react7.useMemo)(() => {
|
|
1624
|
+
if (!expandable) return displayRows;
|
|
1625
|
+
return withDetailRows(displayRows, expandedRowIds, rowIdField);
|
|
1626
|
+
}, [expandable, displayRows, expandedRowIds, rowIdField]);
|
|
1550
1627
|
const footerData = serverSide ? data : filteredData;
|
|
1551
1628
|
const activeChips = (0, import_react7.useMemo)(
|
|
1552
1629
|
() => buildActiveFilterChips(filters, filterValues),
|
|
@@ -1698,6 +1775,7 @@ var DataTable = ({
|
|
|
1698
1775
|
const type = col.editType || "text";
|
|
1699
1776
|
const rowId = row[rowIdField];
|
|
1700
1777
|
const fieldName = `edit-${rowId}-${col.field}`;
|
|
1778
|
+
const inputLabel = typeof col.label === "string" ? col.label : col.field;
|
|
1701
1779
|
const commit = (val) => commitEdit(row, col.field, val);
|
|
1702
1780
|
const exitEdit = () => {
|
|
1703
1781
|
if (editError) return;
|
|
@@ -1738,15 +1816,15 @@ var DataTable = ({
|
|
|
1738
1816
|
case "multiselect":
|
|
1739
1817
|
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.MultiSelect, { ...extra, name: fieldName, label: "", value: editValue || [], onChange: commit, options: resolveEditOptions(col, data) });
|
|
1740
1818
|
case "date":
|
|
1741
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.DateInput, { ...extra, name: fieldName, label:
|
|
1819
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.DateInput, { ...extra, name: fieldName, label: inputLabel, value: editValue, onChange: commit });
|
|
1742
1820
|
case "time":
|
|
1743
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TimeInput, { ...extra, name: fieldName, label:
|
|
1821
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TimeInput, { ...extra, name: fieldName, label: inputLabel, value: editValue, onChange: commit });
|
|
1744
1822
|
case "datetime":
|
|
1745
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Flex, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.DateInput, { ...extra, name: `${fieldName}-date`, label:
|
|
1823
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Flex, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.DateInput, { ...extra, name: `${fieldName}-date`, label: `${inputLabel} date`, value: editValue == null ? void 0 : editValue.date, onChange: (val) => {
|
|
1746
1824
|
const next = { ...editValue, date: val };
|
|
1747
1825
|
handleInput(next);
|
|
1748
1826
|
commitEdit(row, col.field, next, { keepEditing: true });
|
|
1749
|
-
}, onBlur: maybeExitDatetimeEdit }), /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TimeInput, { ...extra.timeProps || {}, name: `${fieldName}-time`, label:
|
|
1827
|
+
}, onBlur: maybeExitDatetimeEdit }), /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TimeInput, { ...extra.timeProps || {}, name: `${fieldName}-time`, label: `${inputLabel} time`, value: editValue == null ? void 0 : editValue.time, onChange: (val) => {
|
|
1750
1828
|
const next = { ...editValue, time: val };
|
|
1751
1829
|
handleInput(next);
|
|
1752
1830
|
commitEdit(row, col.field, next, { keepEditing: true });
|
|
@@ -1760,7 +1838,8 @@ var DataTable = ({
|
|
|
1760
1838
|
}
|
|
1761
1839
|
};
|
|
1762
1840
|
const resolvedEditMode = editMode || (columns.some((col) => col.editable) ? "discrete" : null);
|
|
1763
|
-
const useColumnRendering = selectable || !!resolvedEditMode || editingRowId != null || showRowActionsColumn || !renderRow;
|
|
1841
|
+
const useColumnRendering = selectable || !!resolvedEditMode || editingRowId != null || showRowActionsColumn || expandable || !renderRow;
|
|
1842
|
+
const totalColumnCount = columns.length + (selectable ? 1 : 0) + (showExpandColumn ? 1 : 0) + (showRowActionsColumn ? 1 : 0);
|
|
1764
1843
|
const autoWidths = (0, import_react7.useMemo)(
|
|
1765
1844
|
() => autoWidth ? computeAutoWidths(columns, data) : {},
|
|
1766
1845
|
[columns, data, autoWidth]
|
|
@@ -1779,6 +1858,7 @@ var DataTable = ({
|
|
|
1779
1858
|
const type = col.editType || "text";
|
|
1780
1859
|
const rowId = row[rowIdField];
|
|
1781
1860
|
const fieldName = `inline-${rowId}-${col.field}`;
|
|
1861
|
+
const inputLabel = typeof col.label === "string" ? col.label : col.field;
|
|
1782
1862
|
const cellKey = `${rowId}-${col.field}`;
|
|
1783
1863
|
const value = row[col.field];
|
|
1784
1864
|
const validate = col.editValidate;
|
|
@@ -1827,13 +1907,13 @@ var DataTable = ({
|
|
|
1827
1907
|
case "multiselect":
|
|
1828
1908
|
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.MultiSelect, { ...extra, name: fieldName, label: "", value: value || [], onChange: fire, options: resolveEditOptions(col, data) });
|
|
1829
1909
|
case "date":
|
|
1830
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.DateInput, { ...extra, name: fieldName, label:
|
|
1910
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.DateInput, { ...extra, name: fieldName, label: inputLabel, value, onChange: fire });
|
|
1831
1911
|
case "time":
|
|
1832
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TimeInput, { ...extra, name: fieldName, label:
|
|
1912
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TimeInput, { ...extra, name: fieldName, label: inputLabel, value, onChange: fire });
|
|
1833
1913
|
case "datetime":
|
|
1834
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Flex, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.DateInput, { ...extra, name: `${fieldName}-date`, label:
|
|
1914
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Flex, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.DateInput, { ...extra, name: `${fieldName}-date`, label: `${inputLabel} date`, value: value == null ? void 0 : value.date, onChange: (val) => {
|
|
1835
1915
|
fire({ ...value, date: val });
|
|
1836
|
-
} }), /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TimeInput, { ...extra.timeProps || {}, name: `${fieldName}-time`, label:
|
|
1916
|
+
} }), /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TimeInput, { ...extra.timeProps || {}, name: `${fieldName}-time`, label: `${inputLabel} time`, value: value == null ? void 0 : value.time, onChange: (val) => {
|
|
1837
1917
|
fire({ ...value, time: val });
|
|
1838
1918
|
} }));
|
|
1839
1919
|
case "toggle":
|
|
@@ -1987,7 +2067,7 @@ var DataTable = ({
|
|
|
1987
2067
|
checked: allVisibleSelected,
|
|
1988
2068
|
onChange: handleSelectAll
|
|
1989
2069
|
}
|
|
1990
|
-
)), columns.map((col) => {
|
|
2070
|
+
)), showExpandColumn && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableHeader, { width: "min" }), columns.map((col) => {
|
|
1991
2071
|
const headerAlign = resolvedEditMode === "inline" && col.editable ? void 0 : col.align;
|
|
1992
2072
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
1993
2073
|
import_ui_extensions7.TableHeader,
|
|
@@ -2001,8 +2081,8 @@ var DataTable = ({
|
|
|
2001
2081
|
col.description ? /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, col.label, "\xA0", /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Link, { inline: true, variant: "dark", overlay: /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Tooltip, null, col.description) }, /* @__PURE__ */ import_react7.default.createElement(Icon, { name: "info", screenReaderText: typeof col.description === "string" ? col.description : void 0 }))) : col.label
|
|
2002
2082
|
);
|
|
2003
2083
|
}), showRowActionsColumn && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableHeader, { width: "min" }))),
|
|
2004
|
-
/* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableBody, null,
|
|
2005
|
-
(item, idx) => item.type === "group-header" ? /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableRow, { key: `group-${item.group.key}` }, selectable && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { width: "min" }), columns.map((col, colIdx) => {
|
|
2084
|
+
/* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableBody, null, renderedRows.map(
|
|
2085
|
+
(item, idx) => item.type === "group-header" ? /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableRow, { key: `group-${item.group.key}` }, selectable && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { width: "min" }), showExpandColumn && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { width: "min" }), columns.map((col, colIdx) => {
|
|
2006
2086
|
var _a, _b, _c;
|
|
2007
2087
|
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { key: col.field, width: getCellWidth(col), align: colIdx === 0 ? void 0 : col.align }, colIdx === 0 ? /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Flex, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ import_react7.default.createElement(
|
|
2008
2088
|
Icon,
|
|
@@ -2019,7 +2099,7 @@ var DataTable = ({
|
|
|
2019
2099
|
},
|
|
2020
2100
|
/* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Text, { format: { fontWeight: "demibold" } }, item.group.label)
|
|
2021
2101
|
)) : ((_a = groupBy.aggregations) == null ? void 0 : _a[col.field]) ? groupBy.aggregations[col.field](item.group.rows, item.group.key) : ((_c = (_b = groupBy.groupValues) == null ? void 0 : _b[item.group.key]) == null ? void 0 : _c[col.field]) ?? "");
|
|
2022
|
-
}), showRowActionsColumn && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { width: "min" })) : useColumnRendering ? /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableRow, { key: item.row[rowIdField] ?? idx }, selectable && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { width: "min" }, /* @__PURE__ */ import_react7.default.createElement(
|
|
2102
|
+
}), showRowActionsColumn && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { width: "min" })) : item.type === "detail" ? /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableRow, { key: `detail-${item.row[rowIdField] ?? idx}` }, /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { colSpan: totalColumnCount }, renderExpandedRow(item.row))) : useColumnRendering ? /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableRow, { key: item.row[rowIdField] ?? idx }, selectable && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { width: "min" }, /* @__PURE__ */ import_react7.default.createElement(
|
|
2023
2103
|
import_ui_extensions7.Checkbox,
|
|
2024
2104
|
{
|
|
2025
2105
|
name: `select-${item.row[rowIdField]}`,
|
|
@@ -2027,13 +2107,22 @@ var DataTable = ({
|
|
|
2027
2107
|
checked: selectedIds.has(item.row[rowIdField]),
|
|
2028
2108
|
onChange: (checked) => handleSelectRow(item.row[rowIdField], checked)
|
|
2029
2109
|
}
|
|
2110
|
+
)), showExpandColumn && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { width: "min" }, /* @__PURE__ */ import_react7.default.createElement(
|
|
2111
|
+
Icon,
|
|
2112
|
+
{
|
|
2113
|
+
name: expandedRowIds.has(item.row[rowIdField]) ? "upCarat" : "downCarat",
|
|
2114
|
+
onClick: () => toggleRowExpanded(item.row[rowIdField]),
|
|
2115
|
+
screenReaderText: expandedRowIds.has(item.row[rowIdField]) ? "Collapse row" : "Expand row"
|
|
2116
|
+
}
|
|
2030
2117
|
)), columns.map((col) => {
|
|
2031
2118
|
const rowId = item.row[rowIdField];
|
|
2032
2119
|
const isDiscreteEditing = resolvedEditMode === "discrete" && (editingCell == null ? void 0 : editingCell.rowId) === rowId && (editingCell == null ? void 0 : editingCell.field) === col.field;
|
|
2033
2120
|
const isRowEditing = editingRowId != null && rowId === editingRowId && col.editable;
|
|
2034
2121
|
const isShowingInput = isDiscreteEditing || isRowEditing || resolvedEditMode === "inline" && col.editable;
|
|
2035
2122
|
const cellAlign = isShowingInput ? void 0 : col.align;
|
|
2036
|
-
|
|
2123
|
+
const cellContent = renderCellContent(item.row, col);
|
|
2124
|
+
const wrapInRowToggle = expandable && expandOn === "row" && !col.editable && !isShowingInput;
|
|
2125
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { key: col.field, width: isDiscreteEditing || isRowEditing ? "auto" : getCellWidth(col), align: cellAlign }, wrapInRowToggle ? /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Link, { variant: "dark", onClick: () => toggleRowExpanded(rowId) }, cellContent) : cellContent);
|
|
2037
2126
|
}), showRowActionsColumn && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableCell, { width: "min" }, /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.Flex, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, (() => {
|
|
2038
2127
|
const resolvedRowActions = typeof rowActions === "function" ? rowActions(item.row) : rowActions;
|
|
2039
2128
|
const actions = Array.isArray(resolvedRowActions) ? resolvedRowActions : [];
|
|
@@ -2050,13 +2139,14 @@ var DataTable = ({
|
|
|
2050
2139
|
));
|
|
2051
2140
|
})()))) : renderRow(item.row)
|
|
2052
2141
|
)),
|
|
2053
|
-
(footer || columns.some((col) => col.footer)) && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableFooter, null, typeof footer === "function" ? footer(footerData) : /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableRow, null, selectable && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableHeader, { width: "min" }), columns.map((col) => {
|
|
2142
|
+
(footer || columns.some((col) => col.footer)) && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableFooter, null, typeof footer === "function" ? footer(footerData) : /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableRow, null, selectable && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableHeader, { width: "min" }), showExpandColumn && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableHeader, { width: "min" }), columns.map((col) => {
|
|
2054
2143
|
const footerDef = col.footer;
|
|
2055
2144
|
const content = typeof footerDef === "function" ? footerDef(footerData) : footerDef || "";
|
|
2056
2145
|
return /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableHeader, { key: col.field, align: col.align }, content);
|
|
2057
2146
|
}), showRowActionsColumn && /* @__PURE__ */ import_react7.default.createElement(import_ui_extensions7.TableHeader, { width: "min" })))
|
|
2058
2147
|
));
|
|
2059
2148
|
};
|
|
2149
|
+
DataTable.displayName = "DataTable";
|
|
2060
2150
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2061
2151
|
0 && (module.exports = {
|
|
2062
2152
|
DataTable
|
package/dist/datatable.mjs
CHANGED
|
@@ -516,7 +516,7 @@ var GENERATED_ICONS = {
|
|
|
516
516
|
"ZoomOut": { "viewBox": "0 0 32 32", "paths": ["M14.42 26.75c2.85 0 5.47-.97 7.56-2.6l-.03.02 5.28 5.34a1.619 1.619 0 0 0 2.76-1.15c0-.45-.18-.85-.47-1.14l-5.33-5.33c1.59-2.06 2.55-4.68 2.55-7.52C26.74 7.54 21.2 2 14.37 2S2 7.55 2 14.38s5.54 12.37 12.37 12.37h.05m0-21.55c5.06 0 9.16 4.1 9.16 9.16s-4.1 9.16-9.16 9.16-9.16-4.1-9.16-9.16c.01-5.05 4.11-9.14 9.16-9.15Zm-4.31 10.78h8.62c.89 0 1.62-.72 1.62-1.62s-.72-1.62-1.62-1.62h-8.62c-.89 0-1.62.72-1.62 1.62s.72 1.62 1.62 1.62"] }
|
|
517
517
|
};
|
|
518
518
|
|
|
519
|
-
// src/common-components/
|
|
519
|
+
// src/common-components/nativeIconNames.js
|
|
520
520
|
var NATIVE_ICON_NAMES = /* @__PURE__ */ new Set([
|
|
521
521
|
"add",
|
|
522
522
|
"appointment",
|
|
@@ -528,12 +528,12 @@ var NATIVE_ICON_NAMES = /* @__PURE__ */ new Set([
|
|
|
528
528
|
"block",
|
|
529
529
|
"book",
|
|
530
530
|
"bulb",
|
|
531
|
+
"callTranscript",
|
|
531
532
|
"calling",
|
|
532
533
|
"callingHangup",
|
|
533
534
|
"callingMade",
|
|
534
535
|
"callingMissed",
|
|
535
536
|
"callingVoicemail",
|
|
536
|
-
"callTranscript",
|
|
537
537
|
"campaigns",
|
|
538
538
|
"cap",
|
|
539
539
|
"checkCircle",
|
|
@@ -562,13 +562,13 @@ var NATIVE_ICON_NAMES = /* @__PURE__ */ new Set([
|
|
|
562
562
|
"enroll",
|
|
563
563
|
"exclamation",
|
|
564
564
|
"exclamationCircle",
|
|
565
|
-
"facebook",
|
|
566
565
|
"faceHappy",
|
|
567
566
|
"faceHappyFilled",
|
|
568
567
|
"faceNeutral",
|
|
569
568
|
"faceNeutralFilled",
|
|
570
569
|
"faceSad",
|
|
571
570
|
"faceSadFilled",
|
|
571
|
+
"facebook",
|
|
572
572
|
"favoriteHollow",
|
|
573
573
|
"file",
|
|
574
574
|
"filledXCircleIcon",
|
|
@@ -709,6 +709,8 @@ var NATIVE_ICON_NAMES = /* @__PURE__ */ new Set([
|
|
|
709
709
|
"zoomIn",
|
|
710
710
|
"zoomOut"
|
|
711
711
|
]);
|
|
712
|
+
|
|
713
|
+
// src/common-components/Icon.js
|
|
712
714
|
var NATIVE_COLORS = /* @__PURE__ */ new Set(["inherit", "alert", "warning", "success"]);
|
|
713
715
|
var NATIVE_SIZE_TOKENS = {
|
|
714
716
|
sm: "sm",
|
|
@@ -921,6 +923,7 @@ var CollectionFilterControl = ({
|
|
|
921
923
|
{ key: name, direction: "row", align: "center", gap: "xs" },
|
|
922
924
|
h3(DateInput, {
|
|
923
925
|
name: `${controlName}-from`,
|
|
926
|
+
label: filter.fromLabel ?? labels.dateFrom,
|
|
924
927
|
placeholder: filter.fromLabel ?? labels.dateFrom,
|
|
925
928
|
format: "medium",
|
|
926
929
|
value: rangeValue.from ?? null,
|
|
@@ -929,6 +932,7 @@ var CollectionFilterControl = ({
|
|
|
929
932
|
h3(Icon, { name: "right", size: "sm" }),
|
|
930
933
|
h3(DateInput, {
|
|
931
934
|
name: `${controlName}-to`,
|
|
935
|
+
label: filter.toLabel ?? labels.dateTo,
|
|
932
936
|
placeholder: filter.toLabel ?? labels.dateTo,
|
|
933
937
|
format: "medium",
|
|
934
938
|
value: rangeValue.to ?? null,
|
|
@@ -1067,6 +1071,45 @@ var editValidationError = (result) => {
|
|
|
1067
1071
|
return typeof result === "string" ? result : "Invalid value";
|
|
1068
1072
|
};
|
|
1069
1073
|
|
|
1074
|
+
// src/datatable/rowExpansion.js
|
|
1075
|
+
var extractRowId = (row, rowIdField = "id", fallback = void 0) => {
|
|
1076
|
+
const id = row == null ? void 0 : row[rowIdField];
|
|
1077
|
+
return id != null ? id : fallback;
|
|
1078
|
+
};
|
|
1079
|
+
var normalizeExpandedIds = (ids) => {
|
|
1080
|
+
if (ids == null) return /* @__PURE__ */ new Set();
|
|
1081
|
+
const list = ids instanceof Set ? [...ids] : Array.isArray(ids) ? ids : [ids];
|
|
1082
|
+
return new Set(list.filter((id) => id != null));
|
|
1083
|
+
};
|
|
1084
|
+
var expandRowId = (expandedIds, rowId, expandSingle = false) => {
|
|
1085
|
+
if (rowId == null) return expandedIds;
|
|
1086
|
+
if (expandSingle) return /* @__PURE__ */ new Set([rowId]);
|
|
1087
|
+
const next = new Set(expandedIds);
|
|
1088
|
+
next.add(rowId);
|
|
1089
|
+
return next;
|
|
1090
|
+
};
|
|
1091
|
+
var collapseRowId = (expandedIds, rowId) => {
|
|
1092
|
+
if (rowId == null || !expandedIds.has(rowId)) return expandedIds;
|
|
1093
|
+
const next = new Set(expandedIds);
|
|
1094
|
+
next.delete(rowId);
|
|
1095
|
+
return next;
|
|
1096
|
+
};
|
|
1097
|
+
var toggleExpandedId = (expandedIds, rowId, expandSingle = false) => {
|
|
1098
|
+
if (rowId == null) return expandedIds;
|
|
1099
|
+
return expandedIds.has(rowId) ? collapseRowId(expandedIds, rowId) : expandRowId(expandedIds, rowId, expandSingle);
|
|
1100
|
+
};
|
|
1101
|
+
var withDetailRows = (items, expandedIds, rowIdField = "id") => {
|
|
1102
|
+
if (!expandedIds || expandedIds.size === 0) return items;
|
|
1103
|
+
const out = [];
|
|
1104
|
+
items.forEach((item) => {
|
|
1105
|
+
out.push(item);
|
|
1106
|
+
if (item.type === "data" && expandedIds.has(extractRowId(item.row, rowIdField))) {
|
|
1107
|
+
out.push({ type: "detail", row: item.row });
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
return out;
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1070
1113
|
// src/datatable/DataTable.jsx
|
|
1071
1114
|
import {
|
|
1072
1115
|
Box as Box2,
|
|
@@ -1306,6 +1349,21 @@ var DataTable = ({
|
|
|
1306
1349
|
hideRowActionsWhenSelectionActive = false,
|
|
1307
1350
|
// hide row action column while selected-row action bar is visible
|
|
1308
1351
|
// -----------------------------------------------------------------------
|
|
1352
|
+
// Row expansion (detail rows)
|
|
1353
|
+
// -----------------------------------------------------------------------
|
|
1354
|
+
renderExpandedRow,
|
|
1355
|
+
// (row) => ReactNode — providing this enables the feature
|
|
1356
|
+
expandedRowIds: externalExpandedRowIds,
|
|
1357
|
+
// controlled — array of expanded row IDs
|
|
1358
|
+
defaultExpandedRowIds,
|
|
1359
|
+
// uncontrolled — initially expanded row IDs
|
|
1360
|
+
onExpandedRowsChange,
|
|
1361
|
+
// (expandedRowIds[]) => void
|
|
1362
|
+
expandOn = "icon",
|
|
1363
|
+
// "icon" (chevron toggle column) | "row" (click row content)
|
|
1364
|
+
expandSingle = false,
|
|
1365
|
+
// accordion mode — expanding a row collapses the others
|
|
1366
|
+
// -----------------------------------------------------------------------
|
|
1309
1367
|
// Inline editing
|
|
1310
1368
|
// -----------------------------------------------------------------------
|
|
1311
1369
|
editMode,
|
|
@@ -1550,6 +1608,25 @@ var DataTable = ({
|
|
|
1550
1608
|
});
|
|
1551
1609
|
return rows;
|
|
1552
1610
|
}, [groupedData, paginatedRows, expandedGroups]);
|
|
1611
|
+
const expandable = typeof renderExpandedRow === "function";
|
|
1612
|
+
const showExpandColumn = expandable && expandOn === "icon";
|
|
1613
|
+
const [internalExpandedRowIds, setInternalExpandedRowIds] = useState2(
|
|
1614
|
+
() => normalizeExpandedIds(defaultExpandedRowIds)
|
|
1615
|
+
);
|
|
1616
|
+
const expandedRowIds = useMemo(
|
|
1617
|
+
() => externalExpandedRowIds != null ? normalizeExpandedIds(externalExpandedRowIds) : internalExpandedRowIds,
|
|
1618
|
+
[externalExpandedRowIds, internalExpandedRowIds]
|
|
1619
|
+
);
|
|
1620
|
+
const toggleRowExpanded = useCallback2((rowId) => {
|
|
1621
|
+
if (rowId == null) return;
|
|
1622
|
+
const next = toggleExpandedId(expandedRowIds, rowId, expandSingle);
|
|
1623
|
+
if (externalExpandedRowIds == null) setInternalExpandedRowIds(next);
|
|
1624
|
+
if (onExpandedRowsChange) onExpandedRowsChange([...next]);
|
|
1625
|
+
}, [expandedRowIds, expandSingle, externalExpandedRowIds, onExpandedRowsChange]);
|
|
1626
|
+
const renderedRows = useMemo(() => {
|
|
1627
|
+
if (!expandable) return displayRows;
|
|
1628
|
+
return withDetailRows(displayRows, expandedRowIds, rowIdField);
|
|
1629
|
+
}, [expandable, displayRows, expandedRowIds, rowIdField]);
|
|
1553
1630
|
const footerData = serverSide ? data : filteredData;
|
|
1554
1631
|
const activeChips = useMemo(
|
|
1555
1632
|
() => buildActiveFilterChips(filters, filterValues),
|
|
@@ -1701,6 +1778,7 @@ var DataTable = ({
|
|
|
1701
1778
|
const type = col.editType || "text";
|
|
1702
1779
|
const rowId = row[rowIdField];
|
|
1703
1780
|
const fieldName = `edit-${rowId}-${col.field}`;
|
|
1781
|
+
const inputLabel = typeof col.label === "string" ? col.label : col.field;
|
|
1704
1782
|
const commit = (val) => commitEdit(row, col.field, val);
|
|
1705
1783
|
const exitEdit = () => {
|
|
1706
1784
|
if (editError) return;
|
|
@@ -1741,15 +1819,15 @@ var DataTable = ({
|
|
|
1741
1819
|
case "multiselect":
|
|
1742
1820
|
return /* @__PURE__ */ React6.createElement(MultiSelect2, { ...extra, name: fieldName, label: "", value: editValue || [], onChange: commit, options: resolveEditOptions(col, data) });
|
|
1743
1821
|
case "date":
|
|
1744
|
-
return /* @__PURE__ */ React6.createElement(DateInput2, { ...extra, name: fieldName, label:
|
|
1822
|
+
return /* @__PURE__ */ React6.createElement(DateInput2, { ...extra, name: fieldName, label: inputLabel, value: editValue, onChange: commit });
|
|
1745
1823
|
case "time":
|
|
1746
|
-
return /* @__PURE__ */ React6.createElement(TimeInput, { ...extra, name: fieldName, label:
|
|
1824
|
+
return /* @__PURE__ */ React6.createElement(TimeInput, { ...extra, name: fieldName, label: inputLabel, value: editValue, onChange: commit });
|
|
1747
1825
|
case "datetime":
|
|
1748
|
-
return /* @__PURE__ */ React6.createElement(Flex4, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ React6.createElement(DateInput2, { ...extra, name: `${fieldName}-date`, label:
|
|
1826
|
+
return /* @__PURE__ */ React6.createElement(Flex4, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ React6.createElement(DateInput2, { ...extra, name: `${fieldName}-date`, label: `${inputLabel} date`, value: editValue == null ? void 0 : editValue.date, onChange: (val) => {
|
|
1749
1827
|
const next = { ...editValue, date: val };
|
|
1750
1828
|
handleInput(next);
|
|
1751
1829
|
commitEdit(row, col.field, next, { keepEditing: true });
|
|
1752
|
-
}, onBlur: maybeExitDatetimeEdit }), /* @__PURE__ */ React6.createElement(TimeInput, { ...extra.timeProps || {}, name: `${fieldName}-time`, label:
|
|
1830
|
+
}, onBlur: maybeExitDatetimeEdit }), /* @__PURE__ */ React6.createElement(TimeInput, { ...extra.timeProps || {}, name: `${fieldName}-time`, label: `${inputLabel} time`, value: editValue == null ? void 0 : editValue.time, onChange: (val) => {
|
|
1753
1831
|
const next = { ...editValue, time: val };
|
|
1754
1832
|
handleInput(next);
|
|
1755
1833
|
commitEdit(row, col.field, next, { keepEditing: true });
|
|
@@ -1763,7 +1841,8 @@ var DataTable = ({
|
|
|
1763
1841
|
}
|
|
1764
1842
|
};
|
|
1765
1843
|
const resolvedEditMode = editMode || (columns.some((col) => col.editable) ? "discrete" : null);
|
|
1766
|
-
const useColumnRendering = selectable || !!resolvedEditMode || editingRowId != null || showRowActionsColumn || !renderRow;
|
|
1844
|
+
const useColumnRendering = selectable || !!resolvedEditMode || editingRowId != null || showRowActionsColumn || expandable || !renderRow;
|
|
1845
|
+
const totalColumnCount = columns.length + (selectable ? 1 : 0) + (showExpandColumn ? 1 : 0) + (showRowActionsColumn ? 1 : 0);
|
|
1767
1846
|
const autoWidths = useMemo(
|
|
1768
1847
|
() => autoWidth ? computeAutoWidths(columns, data) : {},
|
|
1769
1848
|
[columns, data, autoWidth]
|
|
@@ -1782,6 +1861,7 @@ var DataTable = ({
|
|
|
1782
1861
|
const type = col.editType || "text";
|
|
1783
1862
|
const rowId = row[rowIdField];
|
|
1784
1863
|
const fieldName = `inline-${rowId}-${col.field}`;
|
|
1864
|
+
const inputLabel = typeof col.label === "string" ? col.label : col.field;
|
|
1785
1865
|
const cellKey = `${rowId}-${col.field}`;
|
|
1786
1866
|
const value = row[col.field];
|
|
1787
1867
|
const validate = col.editValidate;
|
|
@@ -1830,13 +1910,13 @@ var DataTable = ({
|
|
|
1830
1910
|
case "multiselect":
|
|
1831
1911
|
return /* @__PURE__ */ React6.createElement(MultiSelect2, { ...extra, name: fieldName, label: "", value: value || [], onChange: fire, options: resolveEditOptions(col, data) });
|
|
1832
1912
|
case "date":
|
|
1833
|
-
return /* @__PURE__ */ React6.createElement(DateInput2, { ...extra, name: fieldName, label:
|
|
1913
|
+
return /* @__PURE__ */ React6.createElement(DateInput2, { ...extra, name: fieldName, label: inputLabel, value, onChange: fire });
|
|
1834
1914
|
case "time":
|
|
1835
|
-
return /* @__PURE__ */ React6.createElement(TimeInput, { ...extra, name: fieldName, label:
|
|
1915
|
+
return /* @__PURE__ */ React6.createElement(TimeInput, { ...extra, name: fieldName, label: inputLabel, value, onChange: fire });
|
|
1836
1916
|
case "datetime":
|
|
1837
|
-
return /* @__PURE__ */ React6.createElement(Flex4, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ React6.createElement(DateInput2, { ...extra, name: `${fieldName}-date`, label:
|
|
1917
|
+
return /* @__PURE__ */ React6.createElement(Flex4, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ React6.createElement(DateInput2, { ...extra, name: `${fieldName}-date`, label: `${inputLabel} date`, value: value == null ? void 0 : value.date, onChange: (val) => {
|
|
1838
1918
|
fire({ ...value, date: val });
|
|
1839
|
-
} }), /* @__PURE__ */ React6.createElement(TimeInput, { ...extra.timeProps || {}, name: `${fieldName}-time`, label:
|
|
1919
|
+
} }), /* @__PURE__ */ React6.createElement(TimeInput, { ...extra.timeProps || {}, name: `${fieldName}-time`, label: `${inputLabel} time`, value: value == null ? void 0 : value.time, onChange: (val) => {
|
|
1840
1920
|
fire({ ...value, time: val });
|
|
1841
1921
|
} }));
|
|
1842
1922
|
case "toggle":
|
|
@@ -1990,7 +2070,7 @@ var DataTable = ({
|
|
|
1990
2070
|
checked: allVisibleSelected,
|
|
1991
2071
|
onChange: handleSelectAll
|
|
1992
2072
|
}
|
|
1993
|
-
)), columns.map((col) => {
|
|
2073
|
+
)), showExpandColumn && /* @__PURE__ */ React6.createElement(TableHeader, { width: "min" }), columns.map((col) => {
|
|
1994
2074
|
const headerAlign = resolvedEditMode === "inline" && col.editable ? void 0 : col.align;
|
|
1995
2075
|
return /* @__PURE__ */ React6.createElement(
|
|
1996
2076
|
TableHeader,
|
|
@@ -2004,8 +2084,8 @@ var DataTable = ({
|
|
|
2004
2084
|
col.description ? /* @__PURE__ */ React6.createElement(React6.Fragment, null, col.label, "\xA0", /* @__PURE__ */ React6.createElement(Link2, { inline: true, variant: "dark", overlay: /* @__PURE__ */ React6.createElement(Tooltip, null, col.description) }, /* @__PURE__ */ React6.createElement(Icon, { name: "info", screenReaderText: typeof col.description === "string" ? col.description : void 0 }))) : col.label
|
|
2005
2085
|
);
|
|
2006
2086
|
}), showRowActionsColumn && /* @__PURE__ */ React6.createElement(TableHeader, { width: "min" }))),
|
|
2007
|
-
/* @__PURE__ */ React6.createElement(TableBody, null,
|
|
2008
|
-
(item, idx) => item.type === "group-header" ? /* @__PURE__ */ React6.createElement(TableRow, { key: `group-${item.group.key}` }, selectable && /* @__PURE__ */ React6.createElement(TableCell, { width: "min" }), columns.map((col, colIdx) => {
|
|
2087
|
+
/* @__PURE__ */ React6.createElement(TableBody, null, renderedRows.map(
|
|
2088
|
+
(item, idx) => item.type === "group-header" ? /* @__PURE__ */ React6.createElement(TableRow, { key: `group-${item.group.key}` }, selectable && /* @__PURE__ */ React6.createElement(TableCell, { width: "min" }), showExpandColumn && /* @__PURE__ */ React6.createElement(TableCell, { width: "min" }), columns.map((col, colIdx) => {
|
|
2009
2089
|
var _a, _b, _c;
|
|
2010
2090
|
return /* @__PURE__ */ React6.createElement(TableCell, { key: col.field, width: getCellWidth(col), align: colIdx === 0 ? void 0 : col.align }, colIdx === 0 ? /* @__PURE__ */ React6.createElement(Flex4, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, /* @__PURE__ */ React6.createElement(
|
|
2011
2091
|
Icon,
|
|
@@ -2022,7 +2102,7 @@ var DataTable = ({
|
|
|
2022
2102
|
},
|
|
2023
2103
|
/* @__PURE__ */ React6.createElement(Text2, { format: { fontWeight: "demibold" } }, item.group.label)
|
|
2024
2104
|
)) : ((_a = groupBy.aggregations) == null ? void 0 : _a[col.field]) ? groupBy.aggregations[col.field](item.group.rows, item.group.key) : ((_c = (_b = groupBy.groupValues) == null ? void 0 : _b[item.group.key]) == null ? void 0 : _c[col.field]) ?? "");
|
|
2025
|
-
}), showRowActionsColumn && /* @__PURE__ */ React6.createElement(TableCell, { width: "min" })) : useColumnRendering ? /* @__PURE__ */ React6.createElement(TableRow, { key: item.row[rowIdField] ?? idx }, selectable && /* @__PURE__ */ React6.createElement(TableCell, { width: "min" }, /* @__PURE__ */ React6.createElement(
|
|
2105
|
+
}), showRowActionsColumn && /* @__PURE__ */ React6.createElement(TableCell, { width: "min" })) : item.type === "detail" ? /* @__PURE__ */ React6.createElement(TableRow, { key: `detail-${item.row[rowIdField] ?? idx}` }, /* @__PURE__ */ React6.createElement(TableCell, { colSpan: totalColumnCount }, renderExpandedRow(item.row))) : useColumnRendering ? /* @__PURE__ */ React6.createElement(TableRow, { key: item.row[rowIdField] ?? idx }, selectable && /* @__PURE__ */ React6.createElement(TableCell, { width: "min" }, /* @__PURE__ */ React6.createElement(
|
|
2026
2106
|
Checkbox,
|
|
2027
2107
|
{
|
|
2028
2108
|
name: `select-${item.row[rowIdField]}`,
|
|
@@ -2030,13 +2110,22 @@ var DataTable = ({
|
|
|
2030
2110
|
checked: selectedIds.has(item.row[rowIdField]),
|
|
2031
2111
|
onChange: (checked) => handleSelectRow(item.row[rowIdField], checked)
|
|
2032
2112
|
}
|
|
2113
|
+
)), showExpandColumn && /* @__PURE__ */ React6.createElement(TableCell, { width: "min" }, /* @__PURE__ */ React6.createElement(
|
|
2114
|
+
Icon,
|
|
2115
|
+
{
|
|
2116
|
+
name: expandedRowIds.has(item.row[rowIdField]) ? "upCarat" : "downCarat",
|
|
2117
|
+
onClick: () => toggleRowExpanded(item.row[rowIdField]),
|
|
2118
|
+
screenReaderText: expandedRowIds.has(item.row[rowIdField]) ? "Collapse row" : "Expand row"
|
|
2119
|
+
}
|
|
2033
2120
|
)), columns.map((col) => {
|
|
2034
2121
|
const rowId = item.row[rowIdField];
|
|
2035
2122
|
const isDiscreteEditing = resolvedEditMode === "discrete" && (editingCell == null ? void 0 : editingCell.rowId) === rowId && (editingCell == null ? void 0 : editingCell.field) === col.field;
|
|
2036
2123
|
const isRowEditing = editingRowId != null && rowId === editingRowId && col.editable;
|
|
2037
2124
|
const isShowingInput = isDiscreteEditing || isRowEditing || resolvedEditMode === "inline" && col.editable;
|
|
2038
2125
|
const cellAlign = isShowingInput ? void 0 : col.align;
|
|
2039
|
-
|
|
2126
|
+
const cellContent = renderCellContent(item.row, col);
|
|
2127
|
+
const wrapInRowToggle = expandable && expandOn === "row" && !col.editable && !isShowingInput;
|
|
2128
|
+
return /* @__PURE__ */ React6.createElement(TableCell, { key: col.field, width: isDiscreteEditing || isRowEditing ? "auto" : getCellWidth(col), align: cellAlign }, wrapInRowToggle ? /* @__PURE__ */ React6.createElement(Link2, { variant: "dark", onClick: () => toggleRowExpanded(rowId) }, cellContent) : cellContent);
|
|
2040
2129
|
}), showRowActionsColumn && /* @__PURE__ */ React6.createElement(TableCell, { width: "min" }, /* @__PURE__ */ React6.createElement(Flex4, { direction: "row", align: "center", gap: "xs", wrap: "nowrap" }, (() => {
|
|
2041
2130
|
const resolvedRowActions = typeof rowActions === "function" ? rowActions(item.row) : rowActions;
|
|
2042
2131
|
const actions = Array.isArray(resolvedRowActions) ? resolvedRowActions : [];
|
|
@@ -2053,13 +2142,14 @@ var DataTable = ({
|
|
|
2053
2142
|
));
|
|
2054
2143
|
})()))) : renderRow(item.row)
|
|
2055
2144
|
)),
|
|
2056
|
-
(footer || columns.some((col) => col.footer)) && /* @__PURE__ */ React6.createElement(TableFooter, null, typeof footer === "function" ? footer(footerData) : /* @__PURE__ */ React6.createElement(TableRow, null, selectable && /* @__PURE__ */ React6.createElement(TableHeader, { width: "min" }), columns.map((col) => {
|
|
2145
|
+
(footer || columns.some((col) => col.footer)) && /* @__PURE__ */ React6.createElement(TableFooter, null, typeof footer === "function" ? footer(footerData) : /* @__PURE__ */ React6.createElement(TableRow, null, selectable && /* @__PURE__ */ React6.createElement(TableHeader, { width: "min" }), showExpandColumn && /* @__PURE__ */ React6.createElement(TableHeader, { width: "min" }), columns.map((col) => {
|
|
2057
2146
|
const footerDef = col.footer;
|
|
2058
2147
|
const content = typeof footerDef === "function" ? footerDef(footerData) : footerDef || "";
|
|
2059
2148
|
return /* @__PURE__ */ React6.createElement(TableHeader, { key: col.field, align: col.align }, content);
|
|
2060
2149
|
}), showRowActionsColumn && /* @__PURE__ */ React6.createElement(TableHeader, { width: "min" })))
|
|
2061
2150
|
));
|
|
2062
2151
|
};
|
|
2152
|
+
DataTable.displayName = "DataTable";
|
|
2063
2153
|
export {
|
|
2064
2154
|
DataTable
|
|
2065
2155
|
};
|