@nswds/app 1.83.6 → 1.85.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/dist/index.cjs CHANGED
@@ -16595,12 +16595,13 @@ function DataTable({
16595
16595
  search,
16596
16596
  toolbar,
16597
16597
  columns,
16598
- data
16598
+ data,
16599
+ initialSorting = []
16599
16600
  }) {
16600
16601
  const [rowSelection, setRowSelection] = React5__namespace.useState({});
16601
16602
  const [columnVisibility, setColumnVisibility] = React5__namespace.useState({});
16602
16603
  const [columnFilters, setColumnFilters] = React5__namespace.useState([]);
16603
- const [sorting, setSorting] = React5__namespace.useState([]);
16604
+ const [sorting, setSorting] = React5__namespace.useState(initialSorting);
16604
16605
  const [globalFilter, setGlobalFilter] = React5__namespace.useState("");
16605
16606
  const table = reactTable.useReactTable({
16606
16607
  data,
@@ -16648,11 +16649,23 @@ function DataTable({
16648
16649
  function DataTableColumnHeader({
16649
16650
  column,
16650
16651
  title,
16651
- className
16652
+ className,
16653
+ sortType = "string"
16652
16654
  }) {
16653
16655
  if (!column.getCanSort()) {
16654
16656
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(className), children: title });
16655
16657
  }
16658
+ const getSortLabels = () => {
16659
+ switch (sortType) {
16660
+ case "date":
16661
+ return { asc: "Oldest First", desc: "Newest First" };
16662
+ case "number":
16663
+ return { asc: "Lowest First", desc: "Highest First" };
16664
+ default:
16665
+ return { asc: "Asc", desc: "Desc" };
16666
+ }
16667
+ };
16668
+ const labels = getSortLabels();
16656
16669
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex items-center space-x-2", className), children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
16657
16670
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button2, { variant: "ghost", size: "sm", className: "-ml-3 data-[state=open]:bg-accent", children: [
16658
16671
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: title }),
@@ -16660,12 +16673,17 @@ function DataTableColumnHeader({
16660
16673
  ] }) }),
16661
16674
  /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuContent, { align: "start", children: [
16662
16675
  /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: () => column.toggleSorting(false), children: [
16663
- /* @__PURE__ */ jsxRuntime.jsx(Icons.south, { className: "h-3.5 w-3.5 text-muted-foreground/70" }),
16664
- "Asc"
16676
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.north, { className: "h-3.5 w-3.5 text-muted-foreground/70" }),
16677
+ labels.asc
16665
16678
  ] }),
16666
16679
  /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: () => column.toggleSorting(true), children: [
16667
- /* @__PURE__ */ jsxRuntime.jsx(Icons.north, { className: "h-3.5 w-3.5 text-muted-foreground/70" }),
16668
- "Desc"
16680
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.south, { className: "h-3.5 w-3.5 text-muted-foreground/70" }),
16681
+ labels.desc
16682
+ ] }),
16683
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
16684
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: () => column.clearSorting(), children: [
16685
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.unfold_more, { className: "h-3.5 w-3.5 text-muted-foreground/70" }),
16686
+ "Clear Sort"
16669
16687
  ] }),
16670
16688
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
16671
16689
  /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: () => column.toggleVisibility(false), children: [
@@ -17529,7 +17547,7 @@ function FormatToggle({ format, setFormat }) {
17529
17547
 
17530
17548
  // package.json
17531
17549
  var package_default = {
17532
- version: "1.83.4"};
17550
+ version: "1.83.6"};
17533
17551
  var SluggerContext = React5__namespace.default.createContext(null);
17534
17552
  function flattenText(nodes) {
17535
17553
  if (nodes == null || typeof nodes === "boolean") return "";