@civicactions/cmsds-open-data-components 3.2.6-alpha.1 → 3.2.6-alpha.3
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/main.css +69 -0
- package/dist/main.css.map +1 -1
- package/dist/main.js +367 -21
- package/dist/main.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -1
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./main.css";
|
|
2
2
|
import {jsxs as $hgUW1$jsxs, jsx as $hgUW1$jsx, Fragment as $hgUW1$Fragment} from "react/jsx-runtime";
|
|
3
|
-
import $hgUW1$react, {useState as $hgUW1$useState, useRef as $hgUW1$useRef, useEffect as $hgUW1$useEffect, useMemo as $hgUW1$useMemo} from "react";
|
|
3
|
+
import $hgUW1$react, {useState as $hgUW1$useState, useRef as $hgUW1$useRef, useEffect as $hgUW1$useEffect, useMemo as $hgUW1$useMemo, useCallback as $hgUW1$useCallback} from "react";
|
|
4
4
|
import {Button as $hgUW1$Button, Accordion as $hgUW1$Accordion, AccordionItem as $hgUW1$AccordionItem, TextField as $hgUW1$TextField, Spinner as $hgUW1$Spinner, Dropdown as $hgUW1$Dropdown, Alert as $hgUW1$Alert, Pagination as $hgUW1$Pagination, Dialog as $hgUW1$Dialog, Choice as $hgUW1$Choice, Tabs as $hgUW1$Tabs, TabPanel as $hgUW1$TabPanel, Tooltip as $hgUW1$Tooltip, Badge as $hgUW1$Badge, Table as $hgUW1$Table, TableBody as $hgUW1$TableBody, TableRow as $hgUW1$TableRow, TableCell as $hgUW1$TableCell, TableHead as $hgUW1$TableHead, TooltipIcon as $hgUW1$TooltipIcon} from "@cmsgov/design-system";
|
|
5
5
|
import $hgUW1$proptypes from "prop-types";
|
|
6
6
|
import {NavLink as $hgUW1$NavLink, useLocation as $hgUW1$useLocation, useSearchParams as $hgUW1$useSearchParams, Link as $hgUW1$Link, useNavigate as $hgUW1$useNavigate} from "react-router-dom";
|
|
@@ -13,6 +13,10 @@ import {useMediaQuery as $hgUW1$useMediaQuery} from "react-responsive";
|
|
|
13
13
|
import $hgUW1$dompurify from "dompurify";
|
|
14
14
|
import $hgUW1$lodashtruncate from "lodash.truncate";
|
|
15
15
|
import {createColumnHelper as $hgUW1$createColumnHelper, useReactTable as $hgUW1$useReactTable, getCoreRowModel as $hgUW1$getCoreRowModel, getSortedRowModel as $hgUW1$getSortedRowModel, flexRender as $hgUW1$flexRender, getFilteredRowModel as $hgUW1$getFilteredRowModel, getPaginationRowModel as $hgUW1$getPaginationRowModel} from "@tanstack/react-table";
|
|
16
|
+
import {KeyboardSensor as $hgUW1$KeyboardSensor, PointerSensor as $hgUW1$PointerSensor, useSensors as $hgUW1$useSensors, useSensor as $hgUW1$useSensor, DndContext as $hgUW1$DndContext, closestCenter as $hgUW1$closestCenter} from "@dnd-kit/core";
|
|
17
|
+
import {sortableKeyboardCoordinates as $hgUW1$sortableKeyboardCoordinates, arrayMove as $hgUW1$arrayMove, SortableContext as $hgUW1$SortableContext, verticalListSortingStrategy as $hgUW1$verticalListSortingStrategy, useSortable as $hgUW1$useSortable} from "@dnd-kit/sortable";
|
|
18
|
+
import {restrictToVerticalAxis as $hgUW1$restrictToVerticalAxis} from "@dnd-kit/modifiers";
|
|
19
|
+
import {CSS as $hgUW1$CSS} from "@dnd-kit/utilities";
|
|
16
20
|
import $hgUW1$reactdatepicker from "react-datepicker";
|
|
17
21
|
import "react-datepicker/dist/react-datepicker.css";
|
|
18
22
|
import {usePopper as $hgUW1$usePopper} from "react-popper";
|
|
@@ -1385,7 +1389,6 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
|
|
|
1385
1389
|
"datastore" + id + additionalParamsString
|
|
1386
1390
|
],
|
|
1387
1391
|
queryFn: ()=>{
|
|
1388
|
-
setCount(null);
|
|
1389
1392
|
return fetch(`${rootUrl}/datastore/query/${id}?${additionalParamsString}`).then((res)=>res.json());
|
|
1390
1393
|
},
|
|
1391
1394
|
enabled: enabled
|
|
@@ -1685,7 +1688,7 @@ const $64a351d3fd8413c3$var$HeaderResizeElement = ({ table: table, header: heade
|
|
|
1685
1688
|
style: {
|
|
1686
1689
|
maxWidth: header.getSize() - 16
|
|
1687
1690
|
},
|
|
1688
|
-
title: header.column.columnDef.header,
|
|
1691
|
+
title: typeof header.column.columnDef.header === "string" ? header.column.columnDef.header : "",
|
|
1689
1692
|
children: header.isPlaceholder ? null : (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
|
|
1690
1693
|
}),
|
|
1691
1694
|
sortElement && /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
|
|
@@ -1806,7 +1809,334 @@ var $23763e27eda0e8d7$export$2e2bcd8739ae039 = $23763e27eda0e8d7$var$FixedSizeTH
|
|
|
1806
1809
|
|
|
1807
1810
|
|
|
1808
1811
|
|
|
1809
|
-
|
|
1812
|
+
|
|
1813
|
+
|
|
1814
|
+
|
|
1815
|
+
|
|
1816
|
+
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
const $5fe94aeb50e0798b$var$Card = ({ id: id, visible: visible, updateVisibility: updateVisibility })=>{
|
|
1824
|
+
const { attributes: attributes, listeners: listeners, setNodeRef: setNodeRef, transform: transform, transition: transition, isDragging: isDragging } = (0, $hgUW1$useSortable)({
|
|
1825
|
+
id: id
|
|
1826
|
+
});
|
|
1827
|
+
const style = {
|
|
1828
|
+
transform: (0, $hgUW1$CSS).Transform.toString(transform),
|
|
1829
|
+
transition: transition,
|
|
1830
|
+
opacity: isDragging ? 0.7 : 1,
|
|
1831
|
+
zIndex: isDragging ? 1 : 0,
|
|
1832
|
+
position: "relative",
|
|
1833
|
+
background: "white",
|
|
1834
|
+
touchAction: "none"
|
|
1835
|
+
};
|
|
1836
|
+
return /*#__PURE__*/ (0, $hgUW1$jsxs)("li", {
|
|
1837
|
+
className: "ds-u-display--flex ds-u-justify-content--between ds-u-border-bottom--1",
|
|
1838
|
+
ref: setNodeRef,
|
|
1839
|
+
style: style,
|
|
1840
|
+
...listeners,
|
|
1841
|
+
...attributes,
|
|
1842
|
+
onPointerUp: (e)=>{
|
|
1843
|
+
// Small hack to get around a chrome / webkit rendering bug = force chrome to repaint the checkbox
|
|
1844
|
+
// For whatever reason the way dnd-kit handles events doesn't work well with chrome
|
|
1845
|
+
// Without this code checkboxes can end up visually out of sync with app state until a repaint is forced
|
|
1846
|
+
// this code forces the repaint without user interaction
|
|
1847
|
+
const target = e.target;
|
|
1848
|
+
if (isDragging && target.tagName.toLowerCase() === "label") setTimeout(()=>{
|
|
1849
|
+
target.parentNode.querySelector("input").checked = visible;
|
|
1850
|
+
}, 1);
|
|
1851
|
+
},
|
|
1852
|
+
children: [
|
|
1853
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Choice), {
|
|
1854
|
+
type: "checkbox",
|
|
1855
|
+
label: id,
|
|
1856
|
+
name: id + "_visibility",
|
|
1857
|
+
checked: visible,
|
|
1858
|
+
className: "ds-l-col--10 ds-u-margin-top--0 ds-u-margin-y--1 ds-u-padding-x--3",
|
|
1859
|
+
labelClassName: "dc-truncate",
|
|
1860
|
+
title: "Toggle Column Visible",
|
|
1861
|
+
value: "",
|
|
1862
|
+
onChange: ()=>{
|
|
1863
|
+
updateVisibility(id, !visible);
|
|
1864
|
+
}
|
|
1865
|
+
}),
|
|
1866
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("button", {
|
|
1867
|
+
className: `ds-l-col--2 dkan-manage-columns-reorder-button ${isDragging && "grabbed"}`,
|
|
1868
|
+
"aria-label": `Reorder ${id} column`,
|
|
1869
|
+
children: /*#__PURE__*/ (0, $hgUW1$jsx)("span", {
|
|
1870
|
+
className: "fa fa-sort"
|
|
1871
|
+
})
|
|
1872
|
+
})
|
|
1873
|
+
]
|
|
1874
|
+
});
|
|
1875
|
+
};
|
|
1876
|
+
var $5fe94aeb50e0798b$export$2e2bcd8739ae039 = $5fe94aeb50e0798b$var$Card;
|
|
1877
|
+
|
|
1878
|
+
|
|
1879
|
+
|
|
1880
|
+
class $5d9e2ce238d53d29$var$ExcludeCheckboxKeyboardSensor extends (0, $hgUW1$KeyboardSensor) {
|
|
1881
|
+
// Custom function to exclude checkbox from keyboard dragging
|
|
1882
|
+
static activators = [
|
|
1883
|
+
{
|
|
1884
|
+
eventName: "onKeyDown",
|
|
1885
|
+
handler: ({ nativeEvent: event })=>{
|
|
1886
|
+
// prevent scrolling the list
|
|
1887
|
+
const isCheckbox = [
|
|
1888
|
+
"input",
|
|
1889
|
+
"checkbox"
|
|
1890
|
+
].indexOf(event.target.tagName.toLowerCase()) !== -1;
|
|
1891
|
+
if (event.key === " " && !isCheckbox) event.preventDefault();
|
|
1892
|
+
// only activate on a space or return press
|
|
1893
|
+
if ([
|
|
1894
|
+
" ",
|
|
1895
|
+
"Enter"
|
|
1896
|
+
].indexOf(event.key) === -1) return false;
|
|
1897
|
+
if (!isCheckbox) return true;
|
|
1898
|
+
return false;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
];
|
|
1902
|
+
}
|
|
1903
|
+
class $5d9e2ce238d53d29$var$ExcludeCheckboxPointerSensor extends (0, $hgUW1$PointerSensor) {
|
|
1904
|
+
// Custom function to stop accidental checkbox clicks on pointer activation
|
|
1905
|
+
static activators = [
|
|
1906
|
+
{
|
|
1907
|
+
eventName: "onPointerDown",
|
|
1908
|
+
handler: ({ nativeEvent: event })=>{
|
|
1909
|
+
if (event.target.tagName.toLowerCase() === "input") return false;
|
|
1910
|
+
if (event.target.tagName.toLowerCase() === "label") event.target.blur();
|
|
1911
|
+
return true;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
];
|
|
1915
|
+
}
|
|
1916
|
+
const $5d9e2ce238d53d29$var$ManageColumns = ({ id: id, columns: columns, defaultColumnOrder: defaultColumnOrder, setColumnOrder: setColumnOrder, setColumnVisibility: setColumnVisibility })=>{
|
|
1917
|
+
const [modalOpen, setModalOpen] = (0, $hgUW1$useState)(false);
|
|
1918
|
+
const [ariaLiveFeedback, setAriaLiveFeedback] = (0, $hgUW1$useState)();
|
|
1919
|
+
// maintain card state separately from table state - only sync states when the Save button is pressed
|
|
1920
|
+
const [cards, setCards] = (0, $hgUW1$useState)(columns.map((c)=>{
|
|
1921
|
+
return {
|
|
1922
|
+
id: c.id,
|
|
1923
|
+
visible: c.getIsVisible()
|
|
1924
|
+
};
|
|
1925
|
+
}));
|
|
1926
|
+
const cardOrder = (0, $hgUW1$useMemo)(()=>cards.map(({ id: id })=>id), [
|
|
1927
|
+
cards
|
|
1928
|
+
]);
|
|
1929
|
+
const sensors = (0, $hgUW1$useSensors)((0, $hgUW1$useSensor)($5d9e2ce238d53d29$var$ExcludeCheckboxPointerSensor, {
|
|
1930
|
+
activationConstraint: {
|
|
1931
|
+
distance: 5
|
|
1932
|
+
}
|
|
1933
|
+
}), (0, $hgUW1$useSensor)($5d9e2ce238d53d29$var$ExcludeCheckboxKeyboardSensor, {
|
|
1934
|
+
coordinateGetter: (0, $hgUW1$sortableKeyboardCoordinates)
|
|
1935
|
+
}));
|
|
1936
|
+
const hiddenColumns = columns.filter((c)=>c.getIsVisible() === false).length;
|
|
1937
|
+
const cardHiddenColumns = cards.filter((c)=>c.visible === false).length;
|
|
1938
|
+
const updateVisibility = (0, $hgUW1$useCallback)((id, newVisibility)=>{
|
|
1939
|
+
setCards(cards.map((card)=>{
|
|
1940
|
+
if (card.id === id) return {
|
|
1941
|
+
...card,
|
|
1942
|
+
visible: newVisibility
|
|
1943
|
+
};
|
|
1944
|
+
return card;
|
|
1945
|
+
}));
|
|
1946
|
+
});
|
|
1947
|
+
function handleDragEnd(e) {
|
|
1948
|
+
const { active: active, over: over } = e;
|
|
1949
|
+
if (active.id !== over.id) {
|
|
1950
|
+
const oldIndex = cardOrder.indexOf(active.id);
|
|
1951
|
+
const newIndex = cardOrder.indexOf(over.id);
|
|
1952
|
+
let newCards = (0, $hgUW1$arrayMove)(cards, oldIndex, newIndex);
|
|
1953
|
+
setCards(newCards);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
const resetCards = ()=>{
|
|
1957
|
+
setCards(columns.map((c)=>{
|
|
1958
|
+
return {
|
|
1959
|
+
id: c.id,
|
|
1960
|
+
visible: c.getIsVisible()
|
|
1961
|
+
};
|
|
1962
|
+
}));
|
|
1963
|
+
};
|
|
1964
|
+
return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
|
|
1965
|
+
children: [
|
|
1966
|
+
/*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
|
|
1967
|
+
className: "ds-u-border-top--1 ds-u-fill--gray-lightest ds-u-display--flex ds-u-justify-content--between",
|
|
1968
|
+
children: [
|
|
1969
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
1970
|
+
children: hiddenColumns > 0 && /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Alert), {
|
|
1971
|
+
variation: "warn",
|
|
1972
|
+
children: [
|
|
1973
|
+
hiddenColumns,
|
|
1974
|
+
" Columns Hidden"
|
|
1975
|
+
]
|
|
1976
|
+
})
|
|
1977
|
+
}),
|
|
1978
|
+
/*#__PURE__*/ (0, $hgUW1$jsxs)("button", {
|
|
1979
|
+
"aria-label": "Manage columns - Opens in a dialog",
|
|
1980
|
+
icon: "columns",
|
|
1981
|
+
text: "Manage columns",
|
|
1982
|
+
className: "ds-c-button ds-c-button--ghost ds-u-margin-y--1",
|
|
1983
|
+
onClick: ()=>{
|
|
1984
|
+
setModalOpen(true);
|
|
1985
|
+
},
|
|
1986
|
+
children: [
|
|
1987
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("i", {
|
|
1988
|
+
className: "far fa-cog ds-u-margin-right--1"
|
|
1989
|
+
}),
|
|
1990
|
+
"Manage Columns"
|
|
1991
|
+
]
|
|
1992
|
+
})
|
|
1993
|
+
]
|
|
1994
|
+
}),
|
|
1995
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
1996
|
+
className: `ds-c-dialog-wrap${modalOpen ? " open" : ""}`,
|
|
1997
|
+
children: /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Dialog), {
|
|
1998
|
+
heading: "Manage columns",
|
|
1999
|
+
isOpen: modalOpen,
|
|
2000
|
+
onExit: ()=>{
|
|
2001
|
+
setModalOpen(false);
|
|
2002
|
+
resetCards();
|
|
2003
|
+
},
|
|
2004
|
+
className: "dkan-manage-columns-dialog",
|
|
2005
|
+
actions: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
|
|
2006
|
+
className: "ds-u-display--flex ds-u-justify-content--between ds-u-flex-wrap--wrap ds-u-padding-x--3 ds-u-padding-bottom--1 ds-u-sm-padding-bottom--3",
|
|
2007
|
+
children: [
|
|
2008
|
+
/*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
|
|
2009
|
+
className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0",
|
|
2010
|
+
children: [
|
|
2011
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
|
|
2012
|
+
variation: "solid",
|
|
2013
|
+
className: "ds-l-col--6 ds-l-sm-col--auto",
|
|
2014
|
+
onClick: ()=>{
|
|
2015
|
+
setModalOpen(false);
|
|
2016
|
+
// update table state
|
|
2017
|
+
// Visibility
|
|
2018
|
+
// This code is building a new columnVisibility state object from the card state and doing a single setState on the table
|
|
2019
|
+
// vs doing a setState on every changed column individually
|
|
2020
|
+
const newColumnVisibility = Object.fromEntries(cards.map((c)=>Object.values(c)));
|
|
2021
|
+
setColumnVisibility(newColumnVisibility);
|
|
2022
|
+
// Card order
|
|
2023
|
+
const newCardOrder = cards.map((c)=>{
|
|
2024
|
+
return c.id;
|
|
2025
|
+
});
|
|
2026
|
+
setColumnOrder(newCardOrder);
|
|
2027
|
+
// save to localStorage
|
|
2028
|
+
const localStorageData = {
|
|
2029
|
+
tableColumnOrder: newCardOrder,
|
|
2030
|
+
tableColumnVisibility: newColumnVisibility
|
|
2031
|
+
};
|
|
2032
|
+
localStorage.setItem(id, JSON.stringify(localStorageData));
|
|
2033
|
+
},
|
|
2034
|
+
children: "Save"
|
|
2035
|
+
}),
|
|
2036
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
|
|
2037
|
+
variation: "ghost",
|
|
2038
|
+
className: "ds-l-col--6 ds-l-sm-col--auto",
|
|
2039
|
+
onClick: ()=>{
|
|
2040
|
+
setModalOpen(false);
|
|
2041
|
+
resetCards();
|
|
2042
|
+
},
|
|
2043
|
+
children: "Cancel"
|
|
2044
|
+
})
|
|
2045
|
+
]
|
|
2046
|
+
}),
|
|
2047
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
2048
|
+
className: "ds-l-col--12 ds-l-sm-col--auto ds-u-padding-x--0 ds-u-padding-top--1 ds-u-sm-padding-y--0",
|
|
2049
|
+
children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
|
|
2050
|
+
variation: "ghost",
|
|
2051
|
+
className: "ds-l-col--6 ds-l-sm-col--auto",
|
|
2052
|
+
onClick: ()=>{
|
|
2053
|
+
// reset to default column order and set all cards to visible
|
|
2054
|
+
// do not save this to the table state until the "Save" button is clicked
|
|
2055
|
+
setCards(defaultColumnOrder.map((column)=>{
|
|
2056
|
+
const card = cards.filter((c)=>c.id === column)[0];
|
|
2057
|
+
return {
|
|
2058
|
+
...card,
|
|
2059
|
+
visible: true
|
|
2060
|
+
};
|
|
2061
|
+
}));
|
|
2062
|
+
},
|
|
2063
|
+
children: "Reset Columns"
|
|
2064
|
+
})
|
|
2065
|
+
})
|
|
2066
|
+
]
|
|
2067
|
+
}),
|
|
2068
|
+
children: [
|
|
2069
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("p", {
|
|
2070
|
+
id: "reorder-help",
|
|
2071
|
+
className: "ds-u-padding-x--3",
|
|
2072
|
+
children: "Activate the reorder button and use the arrow keys to reorder the list or use your mouse to drag/reorder. Press escape to cancel the reordering."
|
|
2073
|
+
}),
|
|
2074
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Choice), {
|
|
2075
|
+
checked: cardHiddenColumns === 0,
|
|
2076
|
+
type: "checkbox",
|
|
2077
|
+
onChange: ()=>{
|
|
2078
|
+
setCards(cards.map((c)=>{
|
|
2079
|
+
return {
|
|
2080
|
+
...c,
|
|
2081
|
+
visible: cardHiddenColumns !== 0
|
|
2082
|
+
};
|
|
2083
|
+
}));
|
|
2084
|
+
},
|
|
2085
|
+
className: "ds-u-padding-x--3",
|
|
2086
|
+
name: "",
|
|
2087
|
+
value: "",
|
|
2088
|
+
label: "Select all",
|
|
2089
|
+
hint: cardHiddenColumns && cardHiddenColumns + " columns hidden"
|
|
2090
|
+
}),
|
|
2091
|
+
/*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
|
|
2092
|
+
className: "ds-u-display--flex ds-u-justify-content--between ds-u-font-weight--bold ds-u-padding-y--2 ds-u-padding-x--3 ds-u-border-y--1 ds-u-margin-top--2",
|
|
2093
|
+
children: [
|
|
2094
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("span", {
|
|
2095
|
+
children: "Display column"
|
|
2096
|
+
}),
|
|
2097
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("span", {
|
|
2098
|
+
children: "Reorder"
|
|
2099
|
+
})
|
|
2100
|
+
]
|
|
2101
|
+
}),
|
|
2102
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$DndContext), {
|
|
2103
|
+
collisionDetection: (0, $hgUW1$closestCenter),
|
|
2104
|
+
modifiers: [
|
|
2105
|
+
(0, $hgUW1$restrictToVerticalAxis)
|
|
2106
|
+
],
|
|
2107
|
+
sensors: sensors,
|
|
2108
|
+
onDragEnd: handleDragEnd,
|
|
2109
|
+
children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$SortableContext), {
|
|
2110
|
+
items: cardOrder,
|
|
2111
|
+
strategy: (0, $hgUW1$verticalListSortingStrategy),
|
|
2112
|
+
children: /*#__PURE__*/ (0, $hgUW1$jsx)("ul", {
|
|
2113
|
+
className: "dkan-manage-columns-list",
|
|
2114
|
+
children: cards.map((card)=>{
|
|
2115
|
+
return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $5fe94aeb50e0798b$export$2e2bcd8739ae039), {
|
|
2116
|
+
id: card.id,
|
|
2117
|
+
visible: card.visible,
|
|
2118
|
+
updateVisibility: updateVisibility
|
|
2119
|
+
}, card.id);
|
|
2120
|
+
})
|
|
2121
|
+
})
|
|
2122
|
+
})
|
|
2123
|
+
}),
|
|
2124
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
2125
|
+
className: "sr-only aria-live-feedback",
|
|
2126
|
+
"aria-live": "assertive",
|
|
2127
|
+
"aria-atomic": "true",
|
|
2128
|
+
children: ariaLiveFeedback
|
|
2129
|
+
})
|
|
2130
|
+
]
|
|
2131
|
+
})
|
|
2132
|
+
})
|
|
2133
|
+
]
|
|
2134
|
+
});
|
|
2135
|
+
};
|
|
2136
|
+
var $5d9e2ce238d53d29$export$2e2bcd8739ae039 = $5d9e2ce238d53d29$var$ManageColumns;
|
|
2137
|
+
|
|
2138
|
+
|
|
2139
|
+
const $d98f94c79ddf4e0e$var$DataTable = ({ id: id, data: data, columns: columns, setSort: setSort, sortTransform: sortTransform, tablePadding: tablePadding, canResize: canResize, loading: loading = false, manageColumnsEnabled: manageColumnsEnabled })=>{
|
|
1810
2140
|
const [sorting, setSorting] = (0, $hgUW1$react).useState([]);
|
|
1811
2141
|
const [ariaLiveFeedback, setAriaLiveFeedback] = (0, $hgUW1$useState)("");
|
|
1812
2142
|
const columnHelper = (0, $hgUW1$createColumnHelper)();
|
|
@@ -1819,6 +2149,15 @@ const $d98f94c79ddf4e0e$var$DataTable = ({ data: data, columns: columns, setSort
|
|
|
1819
2149
|
header: col.header
|
|
1820
2150
|
});
|
|
1821
2151
|
});
|
|
2152
|
+
const localStorageData = JSON.parse(localStorage.getItem(id));
|
|
2153
|
+
const [columnOrder, setColumnOrder] = (0, $hgUW1$useState)(()=>{
|
|
2154
|
+
if (manageColumnsEnabled && localStorageData) return localStorageData.tablecolumnOrder;
|
|
2155
|
+
else return table_columns.map((c)=>c.accessorKey);
|
|
2156
|
+
});
|
|
2157
|
+
const [columnVisibility, setColumnVisibility] = (0, $hgUW1$useState)(()=>{
|
|
2158
|
+
if (manageColumnsEnabled && localStorageData) return localStorageData.tableColumnVisibility;
|
|
2159
|
+
else return {};
|
|
2160
|
+
});
|
|
1822
2161
|
const sortElement = (isSorted, onClickFn)=>{
|
|
1823
2162
|
if (isSorted === "asc") return "dc-c-sort--asc";
|
|
1824
2163
|
if (isSorted === "desc") return "dc-c-sort--desc";
|
|
@@ -1830,10 +2169,14 @@ const $d98f94c79ddf4e0e$var$DataTable = ({ data: data, columns: columns, setSort
|
|
|
1830
2169
|
columns: table_columns,
|
|
1831
2170
|
manualSorting: true,
|
|
1832
2171
|
state: {
|
|
2172
|
+
columnOrder: columnOrder,
|
|
2173
|
+
columnVisibility: columnVisibility,
|
|
1833
2174
|
sorting: sorting
|
|
1834
2175
|
},
|
|
1835
2176
|
columnResizeMode: "onChange",
|
|
1836
2177
|
onSortingChange: setSorting,
|
|
2178
|
+
onColumnOrderChange: setColumnOrder,
|
|
2179
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
1837
2180
|
getCoreRowModel: (0, $hgUW1$getCoreRowModel)(),
|
|
1838
2181
|
getSortedRowModel: (0, $hgUW1$getSortedRowModel)(),
|
|
1839
2182
|
debugTable: false
|
|
@@ -1844,8 +2187,21 @@ const $d98f94c79ddf4e0e$var$DataTable = ({ data: data, columns: columns, setSort
|
|
|
1844
2187
|
}, [
|
|
1845
2188
|
sorting
|
|
1846
2189
|
]);
|
|
2190
|
+
const defaultColumnOrder = (0, $hgUW1$useMemo)(()=>table_columns.map((column)=>{
|
|
2191
|
+
return column.accessorKey;
|
|
2192
|
+
}));
|
|
1847
2193
|
return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
|
|
1848
2194
|
children: [
|
|
2195
|
+
manageColumnsEnabled && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
2196
|
+
children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $5d9e2ce238d53d29$export$2e2bcd8739ae039), {
|
|
2197
|
+
id: id,
|
|
2198
|
+
columns: table.getAllLeafColumns(),
|
|
2199
|
+
columnOrder: columnOrder,
|
|
2200
|
+
defaultColumnOrder: defaultColumnOrder,
|
|
2201
|
+
setColumnOrder: setColumnOrder,
|
|
2202
|
+
setColumnVisibility: setColumnVisibility
|
|
2203
|
+
})
|
|
2204
|
+
}),
|
|
1849
2205
|
/*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
|
|
1850
2206
|
className: "dc-c-datatable-wrapper",
|
|
1851
2207
|
tabIndex: 0,
|
|
@@ -2668,7 +3024,7 @@ function $a35cf16d1488f54e$export$1147582dfae658c6(columns, schema) {
|
|
|
2668
3024
|
accessor: column
|
|
2669
3025
|
}));
|
|
2670
3026
|
}
|
|
2671
|
-
const $a35cf16d1488f54e$var$DatasetTable = ({ id: id, distribution: distribution, resource: resource, rootUrl: rootUrl, customColumns: customColumns = [], jsonUrl: jsonUrl, dataDictionaryBanner: dataDictionaryBanner })=>{
|
|
3027
|
+
const $a35cf16d1488f54e$var$DatasetTable = ({ id: id, distribution: distribution, resource: resource, rootUrl: rootUrl, customColumns: customColumns = [], jsonUrl: jsonUrl, dataDictionaryBanner: dataDictionaryBanner, manageColumnsEnabled: manageColumnsEnabled })=>{
|
|
2672
3028
|
const defaultPage = 1;
|
|
2673
3029
|
const defaultPageSize = 10;
|
|
2674
3030
|
const [page, setPage] = (0, $hgUW1$useState)(defaultPage);
|
|
@@ -2703,13 +3059,15 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ id: id, distribution: distribution
|
|
|
2703
3059
|
/*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
2704
3060
|
className: "ds-u-border-x--1 ds-u-border-bottom--1",
|
|
2705
3061
|
children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $d98f94c79ddf4e0e$export$2e2bcd8739ae039), {
|
|
3062
|
+
id: id,
|
|
2706
3063
|
data: resource.values,
|
|
2707
3064
|
canResize: true,
|
|
2708
3065
|
columns: columns,
|
|
2709
3066
|
setSort: resource.setSort,
|
|
2710
3067
|
sortTransform: (0, $aa4450dcbeef3ac0$export$385a5aba38cc3325),
|
|
2711
3068
|
tablePadding: "ds-u-padding-y--2",
|
|
2712
|
-
loading: resource.loading
|
|
3069
|
+
loading: resource.loading,
|
|
3070
|
+
manageColumnsEnabled: manageColumnsEnabled
|
|
2713
3071
|
})
|
|
2714
3072
|
}),
|
|
2715
3073
|
!resource.loading && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
@@ -3537,7 +3895,7 @@ const $a0f13962e513caa1$var$getDataDictionary = (dataDictionaryUrl, additionalPa
|
|
|
3537
3895
|
dataDictionaryLoading: isPending
|
|
3538
3896
|
};
|
|
3539
3897
|
};
|
|
3540
|
-
const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalParams: additionalParams, customColumns: customColumns, setDatasetTitle: setDatasetTitle, customMetadataMapping: customMetadataMapping, apiPageUrl: apiPageUrl = "/api", dataDictionaryUrl: dataDictionaryUrl, borderlessTabs: borderlessTabs = false, defaultPageSize: defaultPageSize = 25, dataDictionaryCSV: dataDictionaryCSV = false, dataDictionaryBanner: dataDictionaryBanner = false })=>{
|
|
3898
|
+
const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalParams: additionalParams, customColumns: customColumns, setDatasetTitle: setDatasetTitle, customMetadataMapping: customMetadataMapping, apiPageUrl: apiPageUrl = "/api", dataDictionaryUrl: dataDictionaryUrl, borderlessTabs: borderlessTabs = false, defaultPageSize: defaultPageSize = 25, dataDictionaryCSV: dataDictionaryCSV = false, dataDictionaryBanner: dataDictionaryBanner = false, manageColumnsEnabled: manageColumnsEnabled = false })=>{
|
|
3541
3899
|
const options = location.search ? {
|
|
3542
3900
|
...(0, $hgUW1$qs).parse(location.search, {
|
|
3543
3901
|
ignoreQueryPrefix: true
|
|
@@ -3693,7 +4051,8 @@ const $a0f13962e513caa1$var$Dataset = ({ id: id, rootUrl: rootUrl, additionalPar
|
|
|
3693
4051
|
resource: resource,
|
|
3694
4052
|
rootUrl: rootUrl,
|
|
3695
4053
|
customColumns: customColumns,
|
|
3696
|
-
dataDictionaryBanner: dataDictionaryBanner && displayDataDictionaryTab
|
|
4054
|
+
dataDictionaryBanner: dataDictionaryBanner && displayDataDictionaryTab,
|
|
4055
|
+
manageColumnsEnabled: manageColumnsEnabled
|
|
3697
4056
|
})
|
|
3698
4057
|
}),
|
|
3699
4058
|
/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TabPanel), {
|
|
@@ -5126,19 +5485,6 @@ var $1e012d1e3b534af0$export$2e2bcd8739ae039 = $1e012d1e3b534af0$var$DataTableDe
|
|
|
5126
5485
|
|
|
5127
5486
|
|
|
5128
5487
|
|
|
5129
|
-
const $e71aee394fdad8bd$var$ManageColumns = ()=>{
|
|
5130
|
-
const [modalOpen, setModalOpen] = (0, $hgUW1$useState)(false);
|
|
5131
|
-
return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
|
|
5132
|
-
onClick: ()=>setModalOpen(!modalOpen),
|
|
5133
|
-
children: "Manage Columns"
|
|
5134
|
-
});
|
|
5135
|
-
};
|
|
5136
|
-
var $e71aee394fdad8bd$export$2e2bcd8739ae039 = $e71aee394fdad8bd$var$ManageColumns;
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
5488
|
|
|
5143
5489
|
const $7848c69a021266f7$var$DataTableRowChanger = (props)=>{
|
|
5144
5490
|
const { limit: limit, rowOptions: rowOptions, setLimit: setLimit } = props;
|