@civicactions/cmsds-open-data-components 3.1.10-alpha.2 → 3.1.10-alpha.4

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.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} from "react";
3
+ import $hgUW1$react, {useState as $hgUW1$useState, useRef as $hgUW1$useRef, useEffect as $hgUW1$useEffect, useMemo as $hgUW1$useMemo} 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, AddIcon as $hgUW1$AddIcon, RemoveIcon as $hgUW1$RemoveIcon, 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";
@@ -1641,6 +1641,7 @@ const $64a351d3fd8413c3$var$HeaderResizeElement = ({ table: table, header: heade
1641
1641
  style: {
1642
1642
  maxWidth: header.getSize() - 16
1643
1643
  },
1644
+ title: header.column.columnDef.header,
1644
1645
  children: header.isPlaceholder ? null : (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
1645
1646
  }),
1646
1647
  sortElement && /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
@@ -2985,11 +2986,7 @@ var $cf6eaefd6b928de3$export$2e2bcd8739ae039 = $cf6eaefd6b928de3$var$DatasetAPI;
2985
2986
 
2986
2987
 
2987
2988
 
2988
- const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns, tableData: tableData, count: count, pageSize: pageSize, columnFilters: columnFilters })=>{
2989
- const [pagination, setPagination] = (0, $hgUW1$useState)({
2990
- pageIndex: 1,
2991
- pageSize: pageSize
2992
- });
2989
+ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns, tableData: tableData, pageSize: pageSize, columnFilters: columnFilters })=>{
2993
2990
  const [sorting, setSorting] = (0, $hgUW1$useState)([]);
2994
2991
  const [ariaLiveFeedback, setAriaLiveFeedback] = (0, $hgUW1$useState)("");
2995
2992
  const mobile = (0, $hgUW1$useMediaQuery)({
@@ -3008,17 +3005,80 @@ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns,
3008
3005
  getCoreRowModel: (0, $hgUW1$getCoreRowModel)(),
3009
3006
  getFilteredRowModel: (0, $hgUW1$getFilteredRowModel)(),
3010
3007
  getPaginationRowModel: (0, $hgUW1$getPaginationRowModel)(),
3011
- onPaginationChange: setPagination,
3012
3008
  getSortedRowModel: (0, $hgUW1$getSortedRowModel)(),
3013
3009
  onSortingChange: setSorting,
3014
3010
  state: {
3015
- pagination: pagination,
3016
3011
  sorting: sorting,
3017
3012
  columnFilters: columnFilters
3018
3013
  }
3019
3014
  });
3015
+ const sortOptions = [
3016
+ {
3017
+ value: "default",
3018
+ label: "No Sort"
3019
+ },
3020
+ {
3021
+ value: "titleasc",
3022
+ label: "Title A-Z"
3023
+ },
3024
+ {
3025
+ value: "titledesc",
3026
+ label: "Title Z-A"
3027
+ },
3028
+ {
3029
+ value: "typeasc",
3030
+ label: "Type A-Z"
3031
+ },
3032
+ {
3033
+ value: "typedesc",
3034
+ label: "Type Z-A"
3035
+ }
3036
+ ];
3037
+ const sortStatesLookup = {
3038
+ default: [],
3039
+ titleasc: [
3040
+ {
3041
+ id: "titleResizable",
3042
+ desc: false
3043
+ }
3044
+ ],
3045
+ titledesc: [
3046
+ {
3047
+ id: "titleResizable",
3048
+ desc: true
3049
+ }
3050
+ ],
3051
+ typeasc: [
3052
+ {
3053
+ id: "type",
3054
+ desc: false
3055
+ }
3056
+ ],
3057
+ typedesc: [
3058
+ {
3059
+ id: "type",
3060
+ desc: true
3061
+ }
3062
+ ]
3063
+ };
3020
3064
  return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3021
3065
  children: [
3066
+ mobile && /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3067
+ className: "ds-u-margin-bottom--3",
3068
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
3069
+ className: "ds-l-col--12 ds-l-sm-col--6",
3070
+ labelClassName: "ds-u-margin-top--1 ds-u-sm-margin-top--0",
3071
+ options: sortOptions,
3072
+ label: "Sort",
3073
+ value: Object.keys(sortStatesLookup).find((key)=>{
3074
+ return JSON.stringify(sortStatesLookup[key]) == JSON.stringify(sorting);
3075
+ }),
3076
+ name: "dc-data-dictionary-type",
3077
+ onChange: (e)=>{
3078
+ setSorting(sortStatesLookup[e.target.value]);
3079
+ }
3080
+ })
3081
+ }),
3022
3082
  /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3023
3083
  className: "dc-c-datadictionary-table",
3024
3084
  children: [
@@ -3055,7 +3115,7 @@ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns,
3055
3115
  }, "header" + headerGroup.id))
3056
3116
  }),
3057
3117
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
3058
- children: table.getFilteredRowModel().rows.map((row, index)=>{
3118
+ children: table.getRowModel().rows.map((row, index)=>{
3059
3119
  return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
3060
3120
  children: row.getVisibleCells().map((cell)=>{
3061
3121
  return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
@@ -3085,13 +3145,10 @@ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns,
3085
3145
  }),
3086
3146
  table.getRowCount() > pageSize ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
3087
3147
  totalPages: table.getPageCount(),
3088
- currentPage: pagination.pageIndex + 1,
3148
+ currentPage: table.getState().pagination.pageIndex + 1,
3089
3149
  onPageChange: (evt, page)=>{
3090
3150
  evt.preventDefault();
3091
- setPagination({
3092
- pageIndex: page - 1,
3093
- pageSize: pageSize
3094
- });
3151
+ table.setPageIndex(page - 1);
3095
3152
  },
3096
3153
  renderHref: (page)=>{
3097
3154
  return "";
@@ -3122,7 +3179,6 @@ const $a24829b27758fe6c$var$SitewideDataDictionaryTable = ({ datasetDictionary:
3122
3179
  return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
3123
3180
  tableColumns: tableColumns,
3124
3181
  tableData: datasetDictionary,
3125
- count: datasetDictionary.length,
3126
3182
  pageSize: pageSize
3127
3183
  });
3128
3184
  };
@@ -3139,7 +3195,19 @@ var $a24829b27758fe6c$export$2e2bcd8739ae039 = $a24829b27758fe6c$var$SitewideDat
3139
3195
  const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datasetDictionary, pageSize: pageSize })=>{
3140
3196
  const [titleFilter, setTitleFilter] = (0, $hgUW1$useState)("");
3141
3197
  const [typeFilter, setTypeFilter] = (0, $hgUW1$useState)("all");
3142
- const [columnFilters, setColumnFilters] = (0, $hgUW1$useState)([]);
3198
+ const columnFilters = (0, $hgUW1$useMemo)(()=>[
3199
+ {
3200
+ id: "titleResizable",
3201
+ value: titleFilter
3202
+ },
3203
+ {
3204
+ id: "type",
3205
+ value: typeFilter === "all" ? "" : typeFilter
3206
+ }
3207
+ ], [
3208
+ titleFilter,
3209
+ typeFilter
3210
+ ]);
3143
3211
  const tableData = datasetDictionary.map((item)=>{
3144
3212
  return {
3145
3213
  titleResizable: item.title,
@@ -3212,18 +3280,6 @@ const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datas
3212
3280
  label: "Boolean"
3213
3281
  }
3214
3282
  ];
3215
- const setFilters = ()=>{
3216
- setColumnFilters([
3217
- {
3218
- id: "titleResizable",
3219
- value: titleFilter
3220
- },
3221
- {
3222
- id: "type",
3223
- value: typeFilter === "all" ? "" : typeFilter
3224
- }
3225
- ]);
3226
- };
3227
3283
  return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3228
3284
  children: [
3229
3285
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
@@ -3255,22 +3311,14 @@ const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datas
3255
3311
  }),
3256
3312
  /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3257
3313
  className: "ds-u-float--right ds-u-padding-y--2 ds-l-col--12 ds-u-display--flex ds-u-flex-wrap--wrap ds-u-justify-content--end",
3258
- children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3314
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3259
3315
  className: "ds-u-display--flex ds-u-justify-content--end ds-l-col--12 ds-l-md-col--6 ds-u-padding-x--0",
3260
- children: [
3261
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
3262
- onClick: setFilters,
3263
- className: "ds-l-col--5 ds-u-margin-right--0 ds-u-sm-margin-right--1",
3264
- children: "Apply filters"
3265
- }),
3266
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2eec38d4d0dbf714$export$2e2bcd8739ae039), {
3267
- clearFiltersFn: ()=>{
3268
- setTitleFilter("");
3269
- setTypeFilter("all");
3270
- setColumnFilters([]);
3271
- }
3272
- })
3273
- ]
3316
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2eec38d4d0dbf714$export$2e2bcd8739ae039), {
3317
+ clearFiltersFn: ()=>{
3318
+ setTitleFilter("");
3319
+ setTypeFilter("all");
3320
+ }
3321
+ })
3274
3322
  })
3275
3323
  })
3276
3324
  ]
@@ -3281,7 +3329,6 @@ const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datas
3281
3329
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
3282
3330
  tableColumns: tableColumns,
3283
3331
  tableData: tableData,
3284
- count: datasetDictionary.length,
3285
3332
  pageSize: pageSize,
3286
3333
  columnFilters: columnFilters
3287
3334
  })