@civicactions/cmsds-open-data-components 2.1.0-alpha.3 → 2.1.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/main.js +22 -64
- package/dist/main.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/lib/assets/icons/close.js +4 -0
- package/lib/assets/icons/copy.js +4 -0
- package/lib/assets/icons/download.js +4 -0
- package/lib/assets/icons/settings.js +5 -2
- package/lib/assets/metadataMapping.js +9 -0
- package/lib/commands/index.js +2 -0
- package/lib/commands/templates/footer.js +2 -0
- package/lib/components/ApiDocumentation/index.js +6 -0
- package/lib/components/Breadcrumb/index.js +8 -2
- package/lib/components/DataTableDensity/datatabledensity.test.js +5 -0
- package/lib/components/DataTableDensity/index.js +7 -1
- package/lib/components/DataTableRowChanger/datatablerowchanger.test.js +5 -0
- package/lib/components/DataTableRowChanger/index.js +8 -2
- package/lib/components/DatasetAdditionalInformation/index.js +17 -4
- package/lib/components/DatasetDownloads/datasetdownloads.test.js +5 -0
- package/lib/components/DatasetDownloads/index.js +6 -1
- package/lib/components/DatasetSearchFacets/dataset_search_facets.test.js +14 -0
- package/lib/components/DatasetSearchFacets/index.js +26 -10
- package/lib/components/DatasetSearchListItem/datasetsearchlistitem.test.js +9 -1
- package/lib/components/DatasetSearchListItem/index.js +17 -6
- package/lib/components/DatasetTags/datasettags.test.js +5 -0
- package/lib/components/DatasetTags/index.js +6 -0
- package/lib/components/Hero/index.js +18 -8
- package/lib/components/ManageColumns/index.js +13 -3
- package/lib/components/NavBar/index.js +55 -0
- package/lib/components/NavLink/index.js +11 -2
- package/lib/components/NavLink/navlink.test.js +6 -0
- package/lib/components/Pagination/index.js +46 -4
- package/lib/components/Pagination/pagination.test.js +478 -367
- package/lib/components/ResourceConditionField/ResourceConditionalField.test.js +5 -1
- package/lib/components/ResourceConditionField/index.js +62 -30
- package/lib/components/ResourceFilter/index.js +39 -10
- package/lib/components/ResourceFilter/resourcefilter.test.js +297 -234
- package/lib/components/ResourceFooter/index.js +11 -4
- package/lib/components/ResourceHeader/index.js +54 -30
- package/lib/components/ResourceInformation/index.js +6 -1
- package/lib/components/ResourcePreview/index.js +30 -13
- package/lib/components/SearchModal/index.js +28 -11
- package/lib/components/SubMenu/index.js +20 -5
- package/lib/components/TransformedDate/index.js +7 -1
- package/lib/components/useAddLoginLink/index.js +13 -3
- package/lib/components/useScrollToTop/index.js +6 -1
- package/lib/index.js +247 -0
- package/lib/templates/APIPage/index.js +6 -1
- package/lib/templates/Dataset/DatasetBody.js +42 -12
- package/lib/templates/Dataset/index.js +26 -7
- package/lib/templates/DatasetSearch/datasetsearch.test.js +70 -50
- package/lib/templates/DatasetSearch/index.js +83 -43
- package/lib/templates/DrupalPage/index.js +13 -6
- package/lib/templates/FilteredResource/FilteredResourceBody.js +43 -15
- package/lib/templates/FilteredResource/QueryBuilder.js +59 -17
- package/lib/templates/FilteredResource/QueryRow.js +43 -20
- package/lib/templates/FilteredResource/QueryTitle.js +18 -2
- package/lib/templates/FilteredResource/functions.js +17 -5
- package/lib/templates/FilteredResource/index.js +36 -16
- package/lib/templates/Footer/footer.test.js +7 -2
- package/lib/templates/Footer/index.js +23 -11
- package/lib/templates/PageNotFound/index.js +5 -1
- package/lib/templates/header/index.js +26 -17
- package/lib/templates/mobile_header/index.js +42 -22
- package/package.json +1 -1
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
5
7
|
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
6
9
|
require("@testing-library/jest-dom/extend-expect");
|
|
10
|
+
|
|
7
11
|
var _index = _interopRequireDefault(require("./index"));
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
14
|
* @jest-environment jsdom
|
|
10
15
|
*/
|
|
11
|
-
|
|
12
16
|
describe('<ResourceConditionalField />', function () {
|
|
13
17
|
test('Placeholder', function () {
|
|
14
18
|
expect(true).toBeTruthy();
|
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
9
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
10
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
|
|
11
16
|
var _designSystem = require("@cmsgov/design-system");
|
|
17
|
+
|
|
12
18
|
var _reactDatepicker = _interopRequireDefault(require("react-datepicker"));
|
|
19
|
+
|
|
13
20
|
var _close = _interopRequireDefault(require("../../assets/icons/close"));
|
|
21
|
+
|
|
14
22
|
require("react-datepicker/dist/react-datepicker.css");
|
|
23
|
+
|
|
15
24
|
function convertUTCToLocalDate(date) {
|
|
16
25
|
if (!date) {
|
|
17
26
|
return date;
|
|
18
27
|
}
|
|
28
|
+
|
|
19
29
|
date = new Date(date);
|
|
20
30
|
date = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
21
31
|
return date;
|
|
22
32
|
}
|
|
33
|
+
|
|
23
34
|
function buildOperatorOptions(type) {
|
|
24
35
|
switch (type) {
|
|
25
36
|
case 'text': // Will change from text to string in future update
|
|
37
|
+
|
|
26
38
|
case 'string':
|
|
27
39
|
return [{
|
|
28
40
|
label: 'Is',
|
|
@@ -37,6 +49,7 @@ function buildOperatorOptions(type) {
|
|
|
37
49
|
label: 'Or',
|
|
38
50
|
value: 'in'
|
|
39
51
|
}];
|
|
52
|
+
|
|
40
53
|
case 'date':
|
|
41
54
|
return [{
|
|
42
55
|
label: 'Is',
|
|
@@ -51,6 +64,7 @@ function buildOperatorOptions(type) {
|
|
|
51
64
|
label: 'Less Than',
|
|
52
65
|
value: '<'
|
|
53
66
|
}];
|
|
67
|
+
|
|
54
68
|
default:
|
|
55
69
|
// These 2 should be safe for all data types
|
|
56
70
|
return [{
|
|
@@ -62,52 +76,63 @@ function buildOperatorOptions(type) {
|
|
|
62
76
|
}];
|
|
63
77
|
}
|
|
64
78
|
}
|
|
79
|
+
|
|
65
80
|
function cleanText(value, operator) {
|
|
66
81
|
var newValue = value;
|
|
82
|
+
|
|
67
83
|
if (Array.isArray(newValue)) {
|
|
68
84
|
newValue = newValue.join(',');
|
|
69
85
|
}
|
|
86
|
+
|
|
70
87
|
return newValue.replace(/(^\%+|\%+$)/gm, '');
|
|
71
88
|
}
|
|
89
|
+
|
|
72
90
|
var ResourceConditionField = function ResourceConditionField(_ref) {
|
|
73
91
|
var data = _ref.data,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
index = _ref.index,
|
|
93
|
+
remove = _ref.remove,
|
|
94
|
+
schema = _ref.schema,
|
|
95
|
+
update = _ref.update;
|
|
78
96
|
var fields = schema.fields;
|
|
97
|
+
|
|
79
98
|
var _React$useState = _react["default"].useState(data.value ? new Date(data.value) : new Date()),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
99
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
100
|
+
startDate = _React$useState2[0],
|
|
101
|
+
setStartDate = _React$useState2[1];
|
|
102
|
+
|
|
83
103
|
var _React$useState3 = _react["default"].useState(Object.keys(fields).map(function (key) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
104
|
+
return {
|
|
105
|
+
label: fields[key].description ? fields[key].description : key,
|
|
106
|
+
value: key
|
|
107
|
+
};
|
|
108
|
+
})),
|
|
109
|
+
_React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
|
|
110
|
+
propertyOptions = _React$useState4[0],
|
|
111
|
+
setPropertyOptions = _React$useState4[1];
|
|
112
|
+
|
|
92
113
|
var _React$useState5 = _react["default"].useState(data.property),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
114
|
+
_React$useState6 = (0, _slicedToArray2["default"])(_React$useState5, 2),
|
|
115
|
+
property = _React$useState6[0],
|
|
116
|
+
setProperty = _React$useState6[1];
|
|
117
|
+
|
|
96
118
|
var _React$useState7 = _react["default"].useState(data.operator),
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
119
|
+
_React$useState8 = (0, _slicedToArray2["default"])(_React$useState7, 2),
|
|
120
|
+
operator = _React$useState8[0],
|
|
121
|
+
setOperator = _React$useState8[1];
|
|
122
|
+
|
|
100
123
|
var _React$useState9 = _react["default"].useState([{
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
124
|
+
label: '--',
|
|
125
|
+
value: ''
|
|
126
|
+
}]),
|
|
127
|
+
_React$useState10 = (0, _slicedToArray2["default"])(_React$useState9, 2),
|
|
128
|
+
operatorOptions = _React$useState10[0],
|
|
129
|
+
setOperatorOptions = _React$useState10[1];
|
|
130
|
+
|
|
107
131
|
var _React$useState11 = _react["default"].useState(data.value),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
132
|
+
_React$useState12 = (0, _slicedToArray2["default"])(_React$useState11, 2),
|
|
133
|
+
value = _React$useState12[0],
|
|
134
|
+
setValue = _React$useState12[1];
|
|
135
|
+
|
|
111
136
|
_react["default"].useEffect(function () {
|
|
112
137
|
if (property) {
|
|
113
138
|
var opOptions = buildOperatorOptions(fields[property].mysql_type ? fields[property].mysql_type : fields[property].type).map(function (opt) {
|
|
@@ -117,10 +142,13 @@ var ResourceConditionField = function ResourceConditionField(_ref) {
|
|
|
117
142
|
};
|
|
118
143
|
});
|
|
119
144
|
update(index, 'property', property);
|
|
145
|
+
|
|
120
146
|
if (!operator) {
|
|
121
147
|
setOperator(opOptions[0].value);
|
|
122
148
|
}
|
|
149
|
+
|
|
123
150
|
setOperatorOptions(opOptions);
|
|
151
|
+
|
|
124
152
|
if (fields[property].mysql_type && fields[property].mysql_type === 'date' || fields[property].type === 'date') {
|
|
125
153
|
setValue(startDate.toJSON().slice(0, 10));
|
|
126
154
|
}
|
|
@@ -134,6 +162,7 @@ var ResourceConditionField = function ResourceConditionField(_ref) {
|
|
|
134
162
|
}]);
|
|
135
163
|
}
|
|
136
164
|
}, [property, operator]);
|
|
165
|
+
|
|
137
166
|
_react["default"].useEffect(function () {
|
|
138
167
|
if (operator) {
|
|
139
168
|
update(index, 'operator', operator);
|
|
@@ -141,6 +170,7 @@ var ResourceConditionField = function ResourceConditionField(_ref) {
|
|
|
141
170
|
update(index, 'operator', '');
|
|
142
171
|
}
|
|
143
172
|
}, [operator]);
|
|
173
|
+
|
|
144
174
|
_react["default"].useEffect(function () {
|
|
145
175
|
if (value) {
|
|
146
176
|
update(index, 'value', value);
|
|
@@ -148,6 +178,7 @@ var ResourceConditionField = function ResourceConditionField(_ref) {
|
|
|
148
178
|
update(index, 'value', '');
|
|
149
179
|
}
|
|
150
180
|
}, [value]);
|
|
181
|
+
|
|
151
182
|
return /*#__PURE__*/_react["default"].createElement("fieldset", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
152
183
|
className: "ds-l-form-row"
|
|
153
184
|
}, /*#__PURE__*/_react["default"].createElement(_designSystem.Dropdown, {
|
|
@@ -210,5 +241,6 @@ var ResourceConditionField = function ResourceConditionField(_ref) {
|
|
|
210
241
|
}
|
|
211
242
|
}, /*#__PURE__*/_react["default"].createElement(_close["default"], null))));
|
|
212
243
|
};
|
|
244
|
+
|
|
213
245
|
var _default = ResourceConditionField;
|
|
214
246
|
exports["default"] = _default;
|
|
@@ -1,97 +1,125 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
9
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
10
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
11
16
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
12
18
|
var _qs = _interopRequireDefault(require("qs"));
|
|
19
|
+
|
|
13
20
|
var _designSystem = require("@cmsgov/design-system");
|
|
21
|
+
|
|
14
22
|
var _ResourceConditionField = _interopRequireDefault(require("../ResourceConditionField"));
|
|
23
|
+
|
|
15
24
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
|
|
16
26
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
|
|
17
28
|
var ResourceFilter = function ResourceFilter(_ref) {
|
|
18
29
|
var id = _ref.id,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
filterOpen = _ref.filterOpen,
|
|
31
|
+
setFilterOpen = _ref.setFilterOpen,
|
|
32
|
+
defaultCondition = _ref.defaultCondition,
|
|
33
|
+
resource = _ref.resource,
|
|
34
|
+
includeSearchParams = _ref.includeSearchParams;
|
|
24
35
|
var setConditions = resource.setConditions,
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
schema = resource.schema,
|
|
37
|
+
conditions = resource.conditions;
|
|
38
|
+
|
|
27
39
|
var _React$useState = _react["default"].useState(conditions && conditions.length ? conditions : [_objectSpread({}, defaultCondition)]),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
41
|
+
formConditions = _React$useState2[0],
|
|
42
|
+
setFormConditions = _React$useState2[1];
|
|
43
|
+
|
|
31
44
|
_react["default"].useEffect(function () {
|
|
32
45
|
if (includeSearchParams) {
|
|
33
46
|
var url = new URL(window.location);
|
|
47
|
+
|
|
34
48
|
var urlString = _qs["default"].stringify({
|
|
35
49
|
conditions: conditions
|
|
36
50
|
}, {
|
|
37
51
|
encodeValuesOnly: true,
|
|
38
52
|
addQueryPrefix: true
|
|
39
53
|
});
|
|
54
|
+
|
|
40
55
|
window.history.pushState({}, '', "".concat(url.origin).concat(url.pathname).concat(urlString));
|
|
41
56
|
}
|
|
42
57
|
}, [conditions]);
|
|
58
|
+
|
|
43
59
|
function removeByIndex(index) {
|
|
44
60
|
var newConditions = (0, _toConsumableArray2["default"])(formConditions);
|
|
45
61
|
newConditions.splice(index, 1);
|
|
46
62
|
setFormConditions(newConditions);
|
|
47
63
|
setConditions(newConditions);
|
|
48
64
|
}
|
|
65
|
+
|
|
49
66
|
function updateByIndex(index, key, value) {
|
|
50
67
|
var newConditions = (0, _toConsumableArray2["default"])(formConditions);
|
|
51
68
|
newConditions[index][key] = value;
|
|
52
69
|
setFormConditions(newConditions);
|
|
53
70
|
}
|
|
71
|
+
|
|
54
72
|
function removeAll() {
|
|
55
73
|
setFormConditions([]);
|
|
56
74
|
setConditions([]);
|
|
57
75
|
}
|
|
76
|
+
|
|
58
77
|
function submitFilters(e) {
|
|
59
78
|
e.preventDefault();
|
|
79
|
+
|
|
60
80
|
if (formConditions.length) {
|
|
61
81
|
var updatedConditions = formConditions.filter(function (cond) {
|
|
62
82
|
if (cond.property) {
|
|
63
83
|
return cond;
|
|
64
84
|
}
|
|
85
|
+
|
|
65
86
|
return false;
|
|
66
87
|
}).map(function (cond) {
|
|
67
88
|
if (cond.operator === '=' || cond.operator === '<>') {
|
|
68
89
|
if (Array.isArray(cond.value)) {
|
|
69
90
|
cond.value = cond.value.join();
|
|
70
91
|
}
|
|
92
|
+
|
|
71
93
|
cond.value = cond.value.replace(/(^\%+|\%+$)/gm, '');
|
|
72
94
|
}
|
|
95
|
+
|
|
73
96
|
if (cond.operator.toLowerCase() === 'like') {
|
|
74
97
|
if (Array.isArray(cond.value)) {
|
|
75
98
|
cond.value = cond.value.join();
|
|
76
99
|
}
|
|
100
|
+
|
|
77
101
|
var cleanedValue = cond.value.replace(/(^\%+|\%+$)/gm, '');
|
|
78
102
|
cond.value = "%".concat(cleanedValue, "%");
|
|
79
103
|
}
|
|
104
|
+
|
|
80
105
|
if (cond.operator.toLowerCase() === 'in') {
|
|
81
106
|
if (!Array.isArray(cond.value)) {
|
|
82
107
|
cond.value = cond.value.split(',');
|
|
83
108
|
}
|
|
84
109
|
}
|
|
110
|
+
|
|
85
111
|
if (Array.isArray(cond.value)) {
|
|
86
112
|
cond.value = cond.value.map(function (v) {
|
|
87
113
|
return v.trim().replace(/(^\%+|\%+$)/gm, '');
|
|
88
114
|
});
|
|
89
115
|
}
|
|
116
|
+
|
|
90
117
|
return cond;
|
|
91
118
|
});
|
|
92
119
|
setConditions(updatedConditions);
|
|
93
120
|
}
|
|
94
121
|
}
|
|
122
|
+
|
|
95
123
|
return /*#__PURE__*/_react["default"].createElement(_designSystem.HelpDrawer, {
|
|
96
124
|
footerTitle: "Update actions",
|
|
97
125
|
footerBody: /*#__PURE__*/_react["default"].createElement(_designSystem.Button, {
|
|
@@ -133,6 +161,7 @@ var ResourceFilter = function ResourceFilter(_ref) {
|
|
|
133
161
|
}
|
|
134
162
|
}, "Remove all filters") : '');
|
|
135
163
|
};
|
|
164
|
+
|
|
136
165
|
ResourceFilter.defaultProps = {
|
|
137
166
|
defaultCondition: {
|
|
138
167
|
property: '',
|