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

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
@@ -12,7 +12,7 @@ import {useQuery as $hgUW1$useQuery, QueryClient as $hgUW1$QueryClient, QueryCli
12
12
  import {useMediaQuery as $hgUW1$useMediaQuery} from "react-responsive";
13
13
  import $hgUW1$dompurify from "dompurify";
14
14
  import $hgUW1$lodashtruncate from "lodash.truncate";
15
- import {createColumnHelper as $hgUW1$createColumnHelper, useReactTable as $hgUW1$useReactTable, getCoreRowModel as $hgUW1$getCoreRowModel, getSortedRowModel as $hgUW1$getSortedRowModel, flexRender as $hgUW1$flexRender, getPaginationRowModel as $hgUW1$getPaginationRowModel} from "@tanstack/react-table";
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
16
  import $hgUW1$reactdatepicker from "react-datepicker";
17
17
  import "react-datepicker/dist/react-datepicker.css";
18
18
  import {usePopper as $hgUW1$usePopper} from "react-popper";
@@ -1307,9 +1307,11 @@ var $b4aa9c66f2e86959$export$2e2bcd8739ae039 = $b4aa9c66f2e86959$var$useMetastor
1307
1307
  const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, additionalParams = {})=>{
1308
1308
  const keys = options.keys ? options.keys : true;
1309
1309
  const { prepareColumns: prepareColumns } = options;
1310
+ const [values, setValues] = (0, $hgUW1$useState)([]);
1310
1311
  const [id, setResource] = (0, $hgUW1$useState)(resourceId);
1311
1312
  const [rootUrl, setRootUrl] = (0, $hgUW1$useState)(rootAPIUrl);
1312
1313
  const [limit, setLimit] = (0, $hgUW1$useState)(options.limit ? options.limit : 20);
1314
+ const [count, setCount] = (0, $hgUW1$useState)(null);
1313
1315
  const [columns, setColumns] = (0, $hgUW1$useState)([]);
1314
1316
  const [offset, setOffset] = (0, $hgUW1$useState)(options.offset ? options.offset : 0);
1315
1317
  const [conditions, setConditions] = (0, $hgUW1$useState)(options.conditions ? options.conditions : undefined);
@@ -1347,6 +1349,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
1347
1349
  (0, $hgUW1$useEffect)(()=>{
1348
1350
  if (data) {
1349
1351
  const propertyKeys = data.schema && data.schema[id] && data.schema[id].fields ? Object.keys(data.schema[id].fields) : [];
1352
+ setValues(data.results), setCount(data.count);
1350
1353
  if (propertyKeys.length) setColumns(prepareColumns ? prepareColumns(propertyKeys) : propertyKeys);
1351
1354
  if (data.schema) setSchema(data.schema);
1352
1355
  }
@@ -1355,8 +1358,8 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
1355
1358
  ]);
1356
1359
  return {
1357
1360
  loading: enabled ? isPending : false,
1358
- values: data ? data.results : undefined,
1359
- count: data ? data.count : null,
1361
+ values: values,
1362
+ count: count,
1360
1363
  columns: columns,
1361
1364
  limit: limit,
1362
1365
  offset: offset,
@@ -2345,6 +2348,26 @@ const $6369abf590ca298f$var$QueryRow = ({ id: id, condition: condition, index: i
2345
2348
  var $6369abf590ca298f$export$2e2bcd8739ae039 = $6369abf590ca298f$var$QueryRow;
2346
2349
 
2347
2350
 
2351
+
2352
+
2353
+
2354
+
2355
+ const $2eec38d4d0dbf714$var$ClearFiltersButton = ({ disabled: disabled = false, clearFiltersFn: clearFiltersFn })=>{
2356
+ const small = (0, $hgUW1$useMediaQuery)({
2357
+ minWidth: 0,
2358
+ maxWidth: 544
2359
+ });
2360
+ return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
2361
+ disabled: disabled,
2362
+ className: "ds-u-float--right ds-l-md-col--6 ds-l-col--5",
2363
+ variation: small ? "ghost" : undefined,
2364
+ onClick: ()=>clearFiltersFn(),
2365
+ children: small ? "Clear all" : "Clear all filters"
2366
+ });
2367
+ };
2368
+ var $2eec38d4d0dbf714$export$2e2bcd8739ae039 = $2eec38d4d0dbf714$var$ClearFiltersButton;
2369
+
2370
+
2348
2371
  function $ee4ad47aa483e5b5$var$updateQueryForDatastore(condition) {
2349
2372
  let cond = condition;
2350
2373
  delete cond.key;
@@ -2500,16 +2523,13 @@ const $ee4ad47aa483e5b5$var$QueryBuilder = (props)=>{
2500
2523
  variation: "solid",
2501
2524
  children: "Apply filters"
2502
2525
  }),
2503
- /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
2526
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $2eec38d4d0dbf714$export$2e2bcd8739ae039), {
2504
2527
  disabled: queryConditions.length === 0,
2505
- className: "ds-u-float--right ds-l-md-col--6 ds-l-col--5",
2506
- variation: small ? "ghost" : undefined,
2507
- onClick: ()=>{
2528
+ clearFiltersFn: ()=>{
2508
2529
  setQueryConditions([]);
2509
2530
  setTitleConditions([]);
2510
2531
  setConditionsCleared(true);
2511
- },
2512
- children: small ? "Clear all" : "Clear all filters"
2532
+ }
2513
2533
  })
2514
2534
  ]
2515
2535
  })
@@ -2964,21 +2984,37 @@ var $cf6eaefd6b928de3$export$2e2bcd8739ae039 = $cf6eaefd6b928de3$var$DatasetAPI;
2964
2984
 
2965
2985
 
2966
2986
 
2967
- const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns, tableData: tableData, count: count, pageSize: pageSize })=>{
2987
+
2988
+ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns, tableData: tableData, count: count, pageSize: pageSize, columnFilters: columnFilters })=>{
2968
2989
  const [pagination, setPagination] = (0, $hgUW1$useState)({
2969
2990
  pageIndex: 1,
2970
2991
  pageSize: pageSize
2971
2992
  });
2993
+ const [sorting, setSorting] = (0, $hgUW1$useState)([]);
2972
2994
  const [ariaLiveFeedback, setAriaLiveFeedback] = (0, $hgUW1$useState)("");
2995
+ const mobile = (0, $hgUW1$useMediaQuery)({
2996
+ minWidth: 0,
2997
+ maxWidth: 544
2998
+ });
2999
+ const sortElement = (isSorted)=>{
3000
+ if (isSorted === "asc") return "dc-c-sort--asc";
3001
+ if (isSorted === "desc") return "dc-c-sort--desc";
3002
+ return "dc-c-sort--default";
3003
+ };
2973
3004
  const table = (0, $hgUW1$useReactTable)({
2974
3005
  data: tableData,
2975
3006
  columns: tableColumns,
2976
3007
  columnResizeMode: "onChange",
2977
3008
  getCoreRowModel: (0, $hgUW1$getCoreRowModel)(),
3009
+ getFilteredRowModel: (0, $hgUW1$getFilteredRowModel)(),
2978
3010
  getPaginationRowModel: (0, $hgUW1$getPaginationRowModel)(),
2979
3011
  onPaginationChange: setPagination,
3012
+ getSortedRowModel: (0, $hgUW1$getSortedRowModel)(),
3013
+ onSortingChange: setSorting,
2980
3014
  state: {
2981
- pagination: pagination
3015
+ pagination: pagination,
3016
+ sorting: sorting,
3017
+ columnFilters: columnFilters
2982
3018
  }
2983
3019
  });
2984
3020
  return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
@@ -2991,6 +3027,7 @@ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns,
2991
3027
  style: {
2992
3028
  width: "100%"
2993
3029
  },
3030
+ stackable: true,
2994
3031
  children: [
2995
3032
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableHead), {
2996
3033
  className: "dc-thead--truncated dc-thead--resizeable",
@@ -2999,25 +3036,37 @@ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns,
2999
3036
  return header.id === "titleResizable" ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $64a351d3fd8413c3$export$2e2bcd8739ae039), {
3000
3037
  table: table,
3001
3038
  header: header,
3002
- setAriaLiveFeedback: setAriaLiveFeedback
3003
- }, header.id + "_resize") : /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3039
+ setAriaLiveFeedback: setAriaLiveFeedback,
3040
+ sortElement: sortElement
3041
+ }, header.id + "_resize") : /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$TableCell), {
3004
3042
  key: header.id,
3005
- className: "ds-u-border-y--2 ds-u-border--dark ds-u-border-x--0",
3006
- children: (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext())
3043
+ className: `ds-u-border-y--2 ds-u-border--dark ds-u-border-x--0`,
3044
+ id: "dataDictionary_" + header.id,
3045
+ children: [
3046
+ (0, $hgUW1$flexRender)(header.column.columnDef.header, header.getContext()),
3047
+ header.id === "type" && /*#__PURE__*/ (0, $hgUW1$jsx)("button", {
3048
+ onClick: header.column.getToggleSortingHandler(),
3049
+ className: header.column.getCanSort() ? `cursor-pointer select-none ds-u-focus-visible ${sortElement(header.column.getIsSorted())}` : "",
3050
+ "aria-label": `${header.column.columnDef.header} sort order`
3051
+ })
3052
+ ]
3007
3053
  });
3008
3054
  })
3009
3055
  }, "header" + headerGroup.id))
3010
3056
  }),
3011
3057
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableBody), {
3012
- children: table.getRowModel().rows.map((row, index)=>{
3058
+ children: table.getFilteredRowModel().rows.map((row, index)=>{
3013
3059
  return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableRow), {
3014
3060
  children: row.getVisibleCells().map((cell)=>{
3015
3061
  return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TableCell), {
3016
3062
  key: cell.id,
3017
3063
  style: {
3018
- maxWidth: cell.column.getSize()
3064
+ maxWidth: mobile ? "100%" : cell.column.getSize(),
3065
+ whiteSpace: cell.column.id === "description" ? "pre-wrap" : "normal"
3019
3066
  },
3020
3067
  className: `${cell.column.id === "titleResizable" ? "ds-u-word-break" : ""}`,
3068
+ headers: "dataDictionary_" + cell.column.id,
3069
+ stackedTitle: cell.column.id === "titleResizable" ? "Title" : cell.column.columnDef.header,
3021
3070
  children: (0, $hgUW1$flexRender)(cell.column.columnDef.cell, cell.getContext())
3022
3071
  });
3023
3072
  })
@@ -3034,8 +3083,8 @@ const $6765a74df807d015$var$DataDictionaryTable = ({ tableColumns: tableColumns,
3034
3083
  })
3035
3084
  ]
3036
3085
  }),
3037
- count > pageSize ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
3038
- totalPages: Math.ceil(count / pagination.pageSize),
3086
+ table.getRowCount() > pageSize ? /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Pagination), {
3087
+ totalPages: table.getPageCount(),
3039
3088
  currentPage: pagination.pageIndex + 1,
3040
3089
  onPageChange: (evt, page)=>{
3041
3090
  evt.preventDefault();
@@ -3086,7 +3135,11 @@ var $a24829b27758fe6c$export$2e2bcd8739ae039 = $a24829b27758fe6c$var$SitewideDat
3086
3135
 
3087
3136
 
3088
3137
 
3138
+
3089
3139
  const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datasetDictionary, pageSize: pageSize })=>{
3140
+ const [titleFilter, setTitleFilter] = (0, $hgUW1$useState)("");
3141
+ const [typeFilter, setTypeFilter] = (0, $hgUW1$useState)("all");
3142
+ const [columnFilters, setColumnFilters] = (0, $hgUW1$useState)([]);
3090
3143
  const tableData = datasetDictionary.map((item)=>{
3091
3144
  return {
3092
3145
  titleResizable: item.title,
@@ -3102,7 +3155,7 @@ const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datas
3102
3155
  children: [
3103
3156
  "Title",
3104
3157
  /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Tooltip), {
3105
- title: "Title represents the column headers of the data file (e.g., Change_Type)",
3158
+ title: "Title represents the column headers of the data file",
3106
3159
  // @ts-ignore
3107
3160
  style: {
3108
3161
  border: "none",
@@ -3125,11 +3178,114 @@ const $a6e312940f7003ef$var$DatasetDictionaryTable = ({ datasetDictionary: datas
3125
3178
  enableResizing: false
3126
3179
  })
3127
3180
  ];
3128
- return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
3129
- tableColumns: tableColumns,
3130
- tableData: tableData,
3131
- count: datasetDictionary.length,
3132
- pageSize: pageSize
3181
+ const typeOptions = [
3182
+ {
3183
+ value: "all",
3184
+ label: "All Types"
3185
+ },
3186
+ {
3187
+ value: "string",
3188
+ label: "String"
3189
+ },
3190
+ {
3191
+ value: "date",
3192
+ label: "Date"
3193
+ },
3194
+ {
3195
+ value: "datetime",
3196
+ label: "Datetime"
3197
+ },
3198
+ {
3199
+ value: "year",
3200
+ label: "Year"
3201
+ },
3202
+ {
3203
+ value: "integer",
3204
+ label: "Integer"
3205
+ },
3206
+ {
3207
+ value: "number",
3208
+ label: "Number"
3209
+ },
3210
+ {
3211
+ value: "boolean",
3212
+ label: "Boolean"
3213
+ }
3214
+ ];
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
+ return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
3228
+ children: [
3229
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3230
+ className: "dc-query-builder ds-u-margin-bottom--3",
3231
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3232
+ className: "ds-c-accordion ds-c-accordion--bordered",
3233
+ children: /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$AccordionItem), {
3234
+ heading: "Data Dictionary Filters",
3235
+ defaultOpen: true,
3236
+ children: /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3237
+ className: "ds-u-display--flex ds-u-flex-wrap--wrap",
3238
+ children: [
3239
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$TextField), {
3240
+ className: "ds-l-col--12 ds-l-sm-col--6",
3241
+ labelClassName: "ds-u-margin-top--1 ds-u-sm-margin-top--0",
3242
+ label: "Title",
3243
+ value: titleFilter,
3244
+ name: "dc-data-dictionary-title",
3245
+ onChange: (e)=>setTitleFilter(e.target.value)
3246
+ }),
3247
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Dropdown), {
3248
+ className: "ds-l-col--12 ds-l-sm-col--6",
3249
+ labelClassName: "ds-u-margin-top--1 ds-u-sm-margin-top--0",
3250
+ options: typeOptions,
3251
+ label: "Type",
3252
+ value: typeFilter,
3253
+ name: "dc-data-dictionary-type",
3254
+ onChange: (e)=>setTypeFilter(e.target.value)
3255
+ }),
3256
+ /*#__PURE__*/ (0, $hgUW1$jsx)("div", {
3257
+ 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", {
3259
+ 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
+ ]
3274
+ })
3275
+ })
3276
+ ]
3277
+ })
3278
+ })
3279
+ })
3280
+ }),
3281
+ /*#__PURE__*/ (0, $hgUW1$jsx)((0, $6765a74df807d015$export$2e2bcd8739ae039), {
3282
+ tableColumns: tableColumns,
3283
+ tableData: tableData,
3284
+ count: datasetDictionary.length,
3285
+ pageSize: pageSize,
3286
+ columnFilters: columnFilters
3287
+ })
3288
+ ]
3133
3289
  });
3134
3290
  };
3135
3291
  var $a6e312940f7003ef$export$2e2bcd8739ae039 = $a6e312940f7003ef$var$DatasetDictionaryTable;
@@ -5398,8 +5554,6 @@ function $3b6ca952e79f0695$var$updateQueryForDatastore(condition) {
5398
5554
  const $3b6ca952e79f0695$var$QueryBuilder = ({ resource: resource, id: id, includeSearchParams: includeSearchParams, customColumns: customColumns })=>{
5399
5555
  const { conditions: conditions, schema: schema, setConditions: setConditions } = resource;
5400
5556
  const fields = Object.keys(schema[id].fields);
5401
- const hasConditions = conditions.length > 0;
5402
- const [queryCount, setQueryCount] = (0, $hgUW1$useState)(0);
5403
5557
  const [queryConditions, setQueryConditions] = (0, $hgUW1$useState)([]);
5404
5558
  const [titleConditions, setTitleConditions] = (0, $hgUW1$useState)([]); // Add use effect to load conditions on first load if needed
5405
5559
  const [conditionsChanged, setConditionsChanged] = (0, $hgUW1$useState)(false);