@civicactions/cmsds-open-data-components 3.0.0-alpha.3 → 3.0.0-alpha.5
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 +33 -10
- package/dist/main.css.map +1 -1
- package/dist/main.js +122 -173
- package/dist/main.js.map +1 -1
- package/dist/types.d.ts +0 -14
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/assets/frequencyMap.js +0 -22
- package/lib/assets/icons/close.js +0 -33
- package/lib/assets/icons/close.jsx +0 -24
- package/lib/assets/icons/copy.js +0 -33
- package/lib/assets/icons/copy.jsx +0 -23
- package/lib/assets/icons/download.js +0 -33
- package/lib/assets/icons/download.jsx +0 -23
- package/lib/assets/icons/settings.js +0 -34
- package/lib/assets/icons/settings.jsx +0 -24
- package/lib/assets/images/CMSGovLogo-O.png +0 -0
- package/lib/assets/images/CMSgov@2x-white-O.png +0 -0
- package/lib/assets/metadataMapping.js +0 -161
- package/lib/assets/metadataMapping.jsx +0 -110
- package/lib/commands/index.js +0 -7
- package/lib/commands/templates/footer.js +0 -61
- package/lib/commands/templates/header.js +0 -84
- package/lib/commands/templates/page_not_found.js +0 -14
- package/lib/components/ApiDocumentation/index.js +0 -24
- package/lib/components/Breadcrumb/index.js +0 -47
- package/lib/components/DataTableDensity/datatabledensity.test.js +0 -30
- package/lib/components/DataTableDensity/index.js +0 -47
- package/lib/components/DataTableRowChanger/datatablerowchanger.test.js +0 -49
- package/lib/components/DataTableRowChanger/index.js +0 -46
- package/lib/components/DatasetAdditionalInformation/index.js +0 -59
- package/lib/components/DatasetDownloads/datasetdownloads.test.js +0 -30
- package/lib/components/DatasetDownloads/index.js +0 -34
- package/lib/components/DatasetSearchFacets/dataset_search_facets.test.js +0 -103
- package/lib/components/DatasetSearchFacets/index.js +0 -104
- package/lib/components/DatasetSearchListItem/datasetsearchlistitem.test.js +0 -44
- package/lib/components/DatasetSearchListItem/index.js +0 -86
- package/lib/components/DatasetTags/datasettags.test.js +0 -40
- package/lib/components/DatasetTags/index.js +0 -38
- package/lib/components/Hero/index.js +0 -92
- package/lib/components/ManageColumns/index.js +0 -36
- package/lib/components/NavBar/index.js +0 -55
- package/lib/components/NavLink/index.js +0 -60
- package/lib/components/NavLink/navlink.test.js +0 -35
- package/lib/components/Pagination/index.js +0 -263
- package/lib/components/Pagination/pagination.test.js +0 -541
- package/lib/components/ResourceConditionField/ResourceConditionalField.test.js +0 -20
- package/lib/components/ResourceConditionField/index.js +0 -246
- package/lib/components/ResourceFilter/index.js +0 -174
- package/lib/components/ResourceFilter/resourcefilter.test.js +0 -440
- package/lib/components/ResourceFooter/index.js +0 -34
- package/lib/components/ResourceHeader/index.js +0 -149
- package/lib/components/ResourceInformation/index.js +0 -37
- package/lib/components/ResourcePreview/index.js +0 -139
- package/lib/components/SearchModal/index.js +0 -116
- package/lib/components/SubMenu/index.js +0 -86
- package/lib/components/TransformedDate/index.js +0 -34
- package/lib/components/useAddLoginLink/index.js +0 -44
- package/lib/components/useScrollToTop/index.js +0 -22
- package/lib/index.js +0 -247
- package/lib/templates/APIPage/index.js +0 -30
- package/lib/templates/Dataset/DatasetBody.js +0 -189
- package/lib/templates/Dataset/index.js +0 -83
- package/lib/templates/DatasetSearch/datasetsearch.test.js +0 -122
- package/lib/templates/DatasetSearch/index.js +0 -356
- package/lib/templates/DrupalPage/index.js +0 -37
- package/lib/templates/FilteredResource/FilteredResourceBody.js +0 -160
- package/lib/templates/FilteredResource/QueryBuilder.js +0 -235
- package/lib/templates/FilteredResource/QueryRow.js +0 -175
- package/lib/templates/FilteredResource/QueryTitle.js +0 -89
- package/lib/templates/FilteredResource/functions.js +0 -142
- package/lib/templates/FilteredResource/index.js +0 -95
- package/lib/templates/Footer/footer.test.js +0 -48
- package/lib/templates/Footer/index.js +0 -366
- package/lib/templates/PageNotFound/index.js +0 -25
- package/lib/templates/header/index.js +0 -112
- package/lib/templates/mobile_header/index.js +0 -199
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = void 0;
|
|
11
|
-
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
|
-
var _qs = _interopRequireDefault(require("qs"));
|
|
21
|
-
|
|
22
|
-
var _designSystem = require("@cmsgov/design-system");
|
|
23
|
-
|
|
24
|
-
var _QueryRow = _interopRequireDefault(require("./QueryRow"));
|
|
25
|
-
|
|
26
|
-
var _QueryTitle = _interopRequireDefault(require("./QueryTitle"));
|
|
27
|
-
|
|
28
|
-
var _functions = require("./functions");
|
|
29
|
-
|
|
30
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
34
|
-
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; }
|
|
35
|
-
|
|
36
|
-
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; }
|
|
37
|
-
|
|
38
|
-
function updateQueryForDatastore(condition) {
|
|
39
|
-
var cond = condition;
|
|
40
|
-
delete cond.key;
|
|
41
|
-
|
|
42
|
-
if (cond.operator === '=' || cond.operator === '<>') {
|
|
43
|
-
if (Array.isArray(cond.value)) {
|
|
44
|
-
cond.value = cond.value.join();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
cond.value = cond.value.replace(/(^\%+|\%+$)/gm, '');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (cond.operator.toLowerCase() === 'like') {
|
|
51
|
-
if (Array.isArray(cond.value)) {
|
|
52
|
-
cond.value = cond.value.join();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var cleanedValue = cond.value.replace(/(^\%+|\%+$)/gm, '');
|
|
56
|
-
cond.value = "%".concat(cleanedValue, "%");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (cond.operator.toLowerCase() === 'in') {
|
|
60
|
-
if (!Array.isArray(cond.value)) {
|
|
61
|
-
cond.value = cond.value.split(',');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (Array.isArray(cond.value)) {
|
|
66
|
-
cond.value = cond.value.map(function (v) {
|
|
67
|
-
return v.trim().replace(/(^\%+|\%+$)/gm, '');
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return cond;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
var QueryBuilder = function QueryBuilder(_ref) {
|
|
75
|
-
var resource = _ref.resource,
|
|
76
|
-
id = _ref.id,
|
|
77
|
-
includeSearchParams = _ref.includeSearchParams,
|
|
78
|
-
customColumns = _ref.customColumns;
|
|
79
|
-
var conditions = resource.conditions,
|
|
80
|
-
schema = resource.schema,
|
|
81
|
-
setConditions = resource.setConditions;
|
|
82
|
-
var fields = Object.keys(schema[id].fields);
|
|
83
|
-
var hasConditions = conditions.length > 0;
|
|
84
|
-
|
|
85
|
-
var _useState = (0, _react.useState)(0),
|
|
86
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
87
|
-
queryCount = _useState2[0],
|
|
88
|
-
setQueryCount = _useState2[1];
|
|
89
|
-
|
|
90
|
-
var _useState3 = (0, _react.useState)([]),
|
|
91
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
92
|
-
queryConditions = _useState4[0],
|
|
93
|
-
setQueryConditions = _useState4[1];
|
|
94
|
-
|
|
95
|
-
var _useState5 = (0, _react.useState)([]),
|
|
96
|
-
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
97
|
-
titleConditions = _useState6[0],
|
|
98
|
-
setTitleConditions = _useState6[1]; // Add use effect to load conditions on first load if needed
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var _useState7 = (0, _react.useState)(false),
|
|
102
|
-
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
103
|
-
conditionsChanged = _useState8[0],
|
|
104
|
-
setConditionsChanged = _useState8[1];
|
|
105
|
-
|
|
106
|
-
var addCondition = function addCondition(condition) {
|
|
107
|
-
if (Array.isArray(condition)) {
|
|
108
|
-
var keyedConditions = condition.map(function (oc) {
|
|
109
|
-
return _objectSpread(_objectSpread({}, oc), {}, {
|
|
110
|
-
key: Date.now() + oc.value + oc.property
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
setQueryConditions(keyedConditions);
|
|
114
|
-
} else {
|
|
115
|
-
setQueryConditions([].concat((0, _toConsumableArray2["default"])(queryConditions), [{
|
|
116
|
-
property: fields[0],
|
|
117
|
-
value: '',
|
|
118
|
-
operator: (0, _functions.buildOperatorOptions)(schema[id].fields[fields[0]].mysql_type)[0].value,
|
|
119
|
-
key: Date.now()
|
|
120
|
-
}]));
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
_react["default"].useEffect(function () {
|
|
125
|
-
addCondition(conditions);
|
|
126
|
-
setTitleConditions(conditions);
|
|
127
|
-
}, []);
|
|
128
|
-
|
|
129
|
-
var propertyOptions = fields.map(function (f) {
|
|
130
|
-
if (schema[id].fields[f].description) {
|
|
131
|
-
return {
|
|
132
|
-
label: schema[id].fields[f].description,
|
|
133
|
-
value: f
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
label: f,
|
|
139
|
-
value: f
|
|
140
|
-
};
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
var submitConditions = function submitConditions(e) {
|
|
144
|
-
e.preventDefault();
|
|
145
|
-
var submitConditions = queryConditions.filter(function (oc) {
|
|
146
|
-
if (oc.property) {
|
|
147
|
-
return oc;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return false;
|
|
151
|
-
}).map(function (oc) {
|
|
152
|
-
var cond = Object.assign({}, oc);
|
|
153
|
-
return updateQueryForDatastore(cond);
|
|
154
|
-
});
|
|
155
|
-
setConditions(submitConditions);
|
|
156
|
-
setTitleConditions(queryConditions.map(function (oc) {
|
|
157
|
-
return Object.assign({}, oc);
|
|
158
|
-
}));
|
|
159
|
-
setConditionsChanged(false);
|
|
160
|
-
|
|
161
|
-
if (includeSearchParams) {
|
|
162
|
-
var url = new URL(window.location);
|
|
163
|
-
|
|
164
|
-
var urlString = _qs["default"].stringify({
|
|
165
|
-
conditions: submitConditions
|
|
166
|
-
}, {
|
|
167
|
-
encodeValuesOnly: true,
|
|
168
|
-
addQueryPrefix: true
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
window.history.pushState({}, '', "".concat(url.origin).concat(url.pathname).concat(urlString));
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
var updateCondition = function updateCondition(index, key, value) {
|
|
176
|
-
var newConditions = (0, _toConsumableArray2["default"])(queryConditions);
|
|
177
|
-
newConditions[index][key] = value;
|
|
178
|
-
setQueryConditions(newConditions);
|
|
179
|
-
setConditionsChanged(true);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
var removeCondition = function removeCondition(index) {
|
|
183
|
-
var newConditions = queryConditions.map(function (oc) {
|
|
184
|
-
return Object.assign({}, oc);
|
|
185
|
-
});
|
|
186
|
-
newConditions.splice(index, 1);
|
|
187
|
-
setQueryConditions(newConditions);
|
|
188
|
-
setConditionsChanged(true);
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
192
|
-
className: "dc-query-builder ds-u-margin-bottom--3"
|
|
193
|
-
}, /*#__PURE__*/_react["default"].createElement(_designSystem.Accordion, {
|
|
194
|
-
bordered: true
|
|
195
|
-
}, /*#__PURE__*/_react["default"].createElement(_designSystem.AccordionItem, {
|
|
196
|
-
heading: /*#__PURE__*/_react["default"].createElement(_QueryTitle["default"], {
|
|
197
|
-
schema: schema[id],
|
|
198
|
-
conditions: titleConditions,
|
|
199
|
-
customColumns: customColumns
|
|
200
|
-
}),
|
|
201
|
-
defaultOpen: false
|
|
202
|
-
}, /*#__PURE__*/_react["default"].createElement("form", {
|
|
203
|
-
onSubmit: function onSubmit(e) {
|
|
204
|
-
return submitConditions(e);
|
|
205
|
-
}
|
|
206
|
-
}, /*#__PURE__*/_react["default"].createElement("div", null, queryConditions.map(function (qf, index) {
|
|
207
|
-
return /*#__PURE__*/_react["default"].createElement(_QueryRow["default"], {
|
|
208
|
-
key: qf.key,
|
|
209
|
-
id: id,
|
|
210
|
-
schema: schema,
|
|
211
|
-
condition: qf,
|
|
212
|
-
index: index,
|
|
213
|
-
propertyOptions: propertyOptions,
|
|
214
|
-
update: updateCondition,
|
|
215
|
-
remove: removeCondition
|
|
216
|
-
});
|
|
217
|
-
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
218
|
-
className: "dc-query-bulder--form-buttons ds-u-padding-y--2"
|
|
219
|
-
}, /*#__PURE__*/_react["default"].createElement(_designSystem.Button, {
|
|
220
|
-
variation: "transparent",
|
|
221
|
-
onClick: function onClick() {
|
|
222
|
-
return addCondition(null);
|
|
223
|
-
}
|
|
224
|
-
}, "+ Add filter"), /*#__PURE__*/_react["default"].createElement(_designSystem.Button, {
|
|
225
|
-
disabled: !conditionsChanged,
|
|
226
|
-
className: "ds-u-float--right",
|
|
227
|
-
type: "submit"
|
|
228
|
-
}, "Apply filters"))))));
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
QueryBuilder.defaultProps = {
|
|
232
|
-
includeSearchParams: true
|
|
233
|
-
};
|
|
234
|
-
var _default = QueryBuilder;
|
|
235
|
-
exports["default"] = _default;
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = void 0;
|
|
11
|
-
|
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
|
-
var _reactDatepicker = _interopRequireDefault(require("react-datepicker"));
|
|
17
|
-
|
|
18
|
-
var _reactResponsive = require("react-responsive");
|
|
19
|
-
|
|
20
|
-
var _designSystem = require("@cmsgov/design-system");
|
|
21
|
-
|
|
22
|
-
var _functions = require("./functions");
|
|
23
|
-
|
|
24
|
-
require("react-datepicker/dist/react-datepicker.css");
|
|
25
|
-
|
|
26
|
-
var _close = _interopRequireDefault(require("../../assets/icons/close"));
|
|
27
|
-
|
|
28
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
-
|
|
30
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
-
|
|
32
|
-
function getStartDate(condition, schema, id) {
|
|
33
|
-
if (schema[id].fields[condition.property].mysql_type === 'date') {
|
|
34
|
-
var newDate = new Date(condition.value);
|
|
35
|
-
|
|
36
|
-
if (newDate instanceof Date && !isNaN(newDate)) {
|
|
37
|
-
return newDate;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return new Date();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var QueryRow = function QueryRow(_ref) {
|
|
45
|
-
var id = _ref.id,
|
|
46
|
-
condition = _ref.condition,
|
|
47
|
-
index = _ref.index,
|
|
48
|
-
update = _ref.update,
|
|
49
|
-
remove = _ref.remove,
|
|
50
|
-
propertyOptions = _ref.propertyOptions,
|
|
51
|
-
schema = _ref.schema;
|
|
52
|
-
var md = (0, _reactResponsive.useMediaQuery)({
|
|
53
|
-
minWidth: 0,
|
|
54
|
-
maxWidth: 768
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
var _useState = (0, _react.useState)(condition.operator),
|
|
58
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
59
|
-
operator = _useState2[0],
|
|
60
|
-
setOperator = _useState2[1];
|
|
61
|
-
|
|
62
|
-
var _useState3 = (0, _react.useState)(condition.property),
|
|
63
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
64
|
-
property = _useState4[0],
|
|
65
|
-
setProperty = _useState4[1];
|
|
66
|
-
|
|
67
|
-
var _useState5 = (0, _react.useState)(condition.value),
|
|
68
|
-
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
69
|
-
value = _useState6[0],
|
|
70
|
-
setValue = _useState6[1];
|
|
71
|
-
|
|
72
|
-
var _React$useState = _react["default"].useState(getStartDate(condition, schema, id)),
|
|
73
|
-
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
74
|
-
startDate = _React$useState2[0],
|
|
75
|
-
setStartDate = _React$useState2[1];
|
|
76
|
-
|
|
77
|
-
(0, _react.useEffect)(function () {
|
|
78
|
-
if (property !== condition.property) {
|
|
79
|
-
if (property) {
|
|
80
|
-
update(index, 'property', property);
|
|
81
|
-
} else {
|
|
82
|
-
update(index, 'property', '');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (schema[id].fields[condition.property].mysql_type === 'date') {
|
|
86
|
-
if (!value) {
|
|
87
|
-
setValue(startDate.toJSON().slice(0, 10));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}, [property, value, startDate, schema, id, condition]);
|
|
92
|
-
(0, _react.useEffect)(function () {
|
|
93
|
-
if (operator !== condition.operator) {
|
|
94
|
-
if (operator) {
|
|
95
|
-
update(index, 'operator', operator);
|
|
96
|
-
} else {
|
|
97
|
-
update(index, 'operator', '');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}, [operator]);
|
|
101
|
-
(0, _react.useEffect)(function () {
|
|
102
|
-
if (value !== condition.value) {
|
|
103
|
-
if (value) {
|
|
104
|
-
update(index, 'value', value);
|
|
105
|
-
} else {
|
|
106
|
-
update(index, 'value', '');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}, [value]);
|
|
110
|
-
return /*#__PURE__*/_react["default"].createElement("fieldset", {
|
|
111
|
-
className: "ds-u-display--flex ds-u-justify-content--between ds-u-align-items--center"
|
|
112
|
-
}, /*#__PURE__*/_react["default"].createElement(_designSystem.Dropdown, {
|
|
113
|
-
options: propertyOptions,
|
|
114
|
-
value: property,
|
|
115
|
-
label: "Property",
|
|
116
|
-
name: "".concat(condition.key, "_property"),
|
|
117
|
-
onChange: function onChange(e) {
|
|
118
|
-
return setProperty(e.target.value);
|
|
119
|
-
}
|
|
120
|
-
}), /*#__PURE__*/_react["default"].createElement(_designSystem.Dropdown, {
|
|
121
|
-
options: (0, _functions.buildOperatorOptions)(schema[id].fields[property].mysql_type),
|
|
122
|
-
value: operator,
|
|
123
|
-
size: "small",
|
|
124
|
-
label: "Operator",
|
|
125
|
-
name: "".concat(condition.key, "_operator"),
|
|
126
|
-
onChange: function onChange(e) {
|
|
127
|
-
return setOperator(e.target.value);
|
|
128
|
-
}
|
|
129
|
-
}), schema[id].fields[property].mysql_type === 'date' ? /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("label", {
|
|
130
|
-
className: "ds-c-label",
|
|
131
|
-
htmlFor: "".concat(condition.key, "_date_value"),
|
|
132
|
-
id: "".concat(condition.key, "_date_value-label")
|
|
133
|
-
}, /*#__PURE__*/_react["default"].createElement("span", null, "Value")), /*#__PURE__*/_react["default"].createElement(_reactDatepicker["default"], {
|
|
134
|
-
name: "".concat(condition.key, "_date_value"),
|
|
135
|
-
selected: (0, _functions.convertUTCToLocalDate)(startDate),
|
|
136
|
-
onChange: function onChange(date) {
|
|
137
|
-
setStartDate(date);
|
|
138
|
-
setValue(date.toJSON().slice(0, 10));
|
|
139
|
-
},
|
|
140
|
-
showMonthDropdown: true,
|
|
141
|
-
showYearDropdown: true,
|
|
142
|
-
dropdownMode: "select",
|
|
143
|
-
className: "ds-c-field",
|
|
144
|
-
withPortal: true // popperPlacement="top-end"
|
|
145
|
-
// popperModifiers={[
|
|
146
|
-
// {
|
|
147
|
-
// name: 'preventOverflow',
|
|
148
|
-
// options: {
|
|
149
|
-
// rootBoundary: 'viewport',
|
|
150
|
-
// // tether: true,
|
|
151
|
-
// altAxis: true,
|
|
152
|
-
// },
|
|
153
|
-
// },
|
|
154
|
-
// ]}
|
|
155
|
-
|
|
156
|
-
})) : /*#__PURE__*/_react["default"].createElement(_designSystem.TextField, {
|
|
157
|
-
label: "Value",
|
|
158
|
-
name: "".concat(condition.key, "_value"),
|
|
159
|
-
value: (0, _functions.cleanText)(value, operator),
|
|
160
|
-
onChange: function onChange(e) {
|
|
161
|
-
return setValue(e.target.value);
|
|
162
|
-
}
|
|
163
|
-
}), /*#__PURE__*/_react["default"].createElement(_designSystem.Button, {
|
|
164
|
-
variation: md ? 'transparent' : null,
|
|
165
|
-
size: "small",
|
|
166
|
-
className: "ds-u-margin-top--3",
|
|
167
|
-
"aria-label": "Delete filter",
|
|
168
|
-
onClick: function onClick() {
|
|
169
|
-
return remove(index);
|
|
170
|
-
}
|
|
171
|
-
}, !md ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, "Delete filter") : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_close["default"], null), ' ')));
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
var _default = QueryRow;
|
|
175
|
-
exports["default"] = _default;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var _designSystem = require("@cmsgov/design-system");
|
|
13
|
-
|
|
14
|
-
var _functions = require("./functions");
|
|
15
|
-
|
|
16
|
-
var QueryTitle = function QueryTitle(_ref) {
|
|
17
|
-
var conditions = _ref.conditions,
|
|
18
|
-
schema = _ref.schema,
|
|
19
|
-
customColumns = _ref.customColumns;
|
|
20
|
-
var fields = schema.fields;
|
|
21
|
-
|
|
22
|
-
if (!conditions.length) {
|
|
23
|
-
return 'Add a filter';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function formatValue(text, property) {
|
|
27
|
-
if (customColumns.length > 0) {
|
|
28
|
-
var newValue = text;
|
|
29
|
-
var customColumn = customColumns.find(function (c) {
|
|
30
|
-
return c.accessor === property;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (customColumn && customColumn.Cell) {
|
|
34
|
-
return customColumn.Cell({
|
|
35
|
-
value: text
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return text;
|
|
40
|
-
} else {
|
|
41
|
-
return text;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function buildTitle() {
|
|
46
|
-
var newTitle = conditions.map(function (c) {
|
|
47
|
-
var field = fields[c.property];
|
|
48
|
-
var description = field && field.description ? field.description : c.property;
|
|
49
|
-
|
|
50
|
-
var operator = _functions.operatorMapping.find(function (op) {
|
|
51
|
-
return op.value === c.operator;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return "".concat(description, " ").concat(operator.label, " ").concat((0, _functions.cleanText)(c.value));
|
|
55
|
-
});
|
|
56
|
-
return newTitle.join(' AND ');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
60
|
-
className: "dc-querybuilder-title"
|
|
61
|
-
}, conditions.map(function (c) {
|
|
62
|
-
var field = fields[c.property];
|
|
63
|
-
var description = field && field.description ? field.description : c.property;
|
|
64
|
-
|
|
65
|
-
var operator = _functions.operatorMapping.find(function (op) {
|
|
66
|
-
return op.value === c.operator;
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
var cleanedText = (0, _functions.cleanText)(c.value);
|
|
70
|
-
var formattedText = formatValue(cleanedText, c.property);
|
|
71
|
-
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
72
|
-
className: "ds-u-fill--background ds-u-padding--1 ds-u-margin-y--1 ds-u-display--inline-block ds-u-font-weight--semibold"
|
|
73
|
-
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
74
|
-
className: "ds-u-font-weight--bold"
|
|
75
|
-
}, description), ' ', /*#__PURE__*/_react["default"].createElement("span", {
|
|
76
|
-
className: "ds-u-font-weight--normal"
|
|
77
|
-
}, operator.label.toUpperCase()), ' ', /*#__PURE__*/_react["default"].createElement("span", {
|
|
78
|
-
className: "ds-u-color--success"
|
|
79
|
-
}, formattedText));
|
|
80
|
-
}).reduce(function (prev, curr) {
|
|
81
|
-
return [prev, /*#__PURE__*/_react["default"].createElement(_designSystem.Badge, {
|
|
82
|
-
className: "ds-u-margin-x--1",
|
|
83
|
-
variation: "info"
|
|
84
|
-
}, "AND"), curr];
|
|
85
|
-
}));
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
var _default = QueryTitle;
|
|
89
|
-
exports["default"] = _default;
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.buildCustomColHeaders = buildCustomColHeaders;
|
|
7
|
-
exports.buildOperatorOptions = buildOperatorOptions;
|
|
8
|
-
exports.cleanText = cleanText;
|
|
9
|
-
exports.convertUTCToLocalDate = convertUTCToLocalDate;
|
|
10
|
-
exports.operatorMapping = void 0;
|
|
11
|
-
|
|
12
|
-
// Example custom column headers, where only effective date has an ! at the end
|
|
13
|
-
// [
|
|
14
|
-
// {schema: 'date', Cell: ({ value }) => localeDate(value),},
|
|
15
|
-
// {accessor: 'effective_date',Cell: ({ value }) => localeDate(value) + '!',},
|
|
16
|
-
// ]
|
|
17
|
-
function buildCustomColHeaders(customHeaders, columns, schema) {
|
|
18
|
-
return columns.map(function (column) {
|
|
19
|
-
var customAccessorIndex = customHeaders.findIndex(function (header) {
|
|
20
|
-
return header.accessor === column;
|
|
21
|
-
});
|
|
22
|
-
var customSchemaIndex = customHeaders.findIndex(function (header) {
|
|
23
|
-
return header.schema === schema.fields[column].mysql_type;
|
|
24
|
-
});
|
|
25
|
-
var newColumn = {}; // If specific accessor is passed, this will override a general mysql_type Cell rewrite.
|
|
26
|
-
|
|
27
|
-
if (customAccessorIndex > -1) {
|
|
28
|
-
newColumn.Header = schema && schema.fields[column].description ? schema.fields[column].description : column;
|
|
29
|
-
newColumn.accessor = column;
|
|
30
|
-
newColumn.Cell = customHeaders[customAccessorIndex].Cell;
|
|
31
|
-
} else {
|
|
32
|
-
newColumn.Header = schema && schema.fields[column].description ? schema.fields[column].description : column;
|
|
33
|
-
newColumn.accessor = column;
|
|
34
|
-
|
|
35
|
-
if (customSchemaIndex > -1) {
|
|
36
|
-
newColumn.Cell = customHeaders[customSchemaIndex].Cell;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return newColumn;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function convertUTCToLocalDate(date) {
|
|
45
|
-
if (!date) {
|
|
46
|
-
return date;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
date = new Date(date);
|
|
50
|
-
date = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
51
|
-
return date;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function cleanText(value, operator) {
|
|
55
|
-
var newValue = value;
|
|
56
|
-
|
|
57
|
-
if (Array.isArray(newValue)) {
|
|
58
|
-
newValue = newValue.join(',');
|
|
59
|
-
} // return newValue.replace(/(^\%+|\%+$)/gm, '');
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return newValue;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
var operatorMapping = [{
|
|
66
|
-
label: 'Is',
|
|
67
|
-
value: '='
|
|
68
|
-
}, {
|
|
69
|
-
label: 'Starts With',
|
|
70
|
-
value: 'starts with'
|
|
71
|
-
}, {
|
|
72
|
-
label: 'Contains',
|
|
73
|
-
value: 'contains'
|
|
74
|
-
}, {
|
|
75
|
-
label: 'Is Not',
|
|
76
|
-
value: '<>'
|
|
77
|
-
}, {
|
|
78
|
-
label: 'Or',
|
|
79
|
-
value: 'in'
|
|
80
|
-
}, {
|
|
81
|
-
label: 'Is',
|
|
82
|
-
value: '='
|
|
83
|
-
}, {
|
|
84
|
-
label: 'Is Not',
|
|
85
|
-
value: '<>'
|
|
86
|
-
}, {
|
|
87
|
-
label: 'Greater Than',
|
|
88
|
-
value: '>'
|
|
89
|
-
}, {
|
|
90
|
-
label: 'Less Than',
|
|
91
|
-
value: '<'
|
|
92
|
-
}];
|
|
93
|
-
exports.operatorMapping = operatorMapping;
|
|
94
|
-
|
|
95
|
-
function buildOperatorOptions(type) {
|
|
96
|
-
switch (type) {
|
|
97
|
-
case 'text': // Will change from text to string in future update
|
|
98
|
-
|
|
99
|
-
case 'string':
|
|
100
|
-
return [{
|
|
101
|
-
label: 'Is',
|
|
102
|
-
value: '='
|
|
103
|
-
}, {
|
|
104
|
-
label: 'Starts With',
|
|
105
|
-
value: 'starts with'
|
|
106
|
-
}, {
|
|
107
|
-
label: 'Contains',
|
|
108
|
-
value: 'contains'
|
|
109
|
-
}, {
|
|
110
|
-
label: 'Is Not',
|
|
111
|
-
value: '<>'
|
|
112
|
-
}, {
|
|
113
|
-
label: 'Or',
|
|
114
|
-
value: 'in'
|
|
115
|
-
}];
|
|
116
|
-
|
|
117
|
-
case 'date':
|
|
118
|
-
return [{
|
|
119
|
-
label: 'Is',
|
|
120
|
-
value: '='
|
|
121
|
-
}, {
|
|
122
|
-
label: 'Is Not',
|
|
123
|
-
value: '<>'
|
|
124
|
-
}, {
|
|
125
|
-
label: 'Greater Than',
|
|
126
|
-
value: '>'
|
|
127
|
-
}, {
|
|
128
|
-
label: 'Less Than',
|
|
129
|
-
value: '<'
|
|
130
|
-
}];
|
|
131
|
-
|
|
132
|
-
default:
|
|
133
|
-
// These 2 should be safe for all data types
|
|
134
|
-
return [{
|
|
135
|
-
label: 'Is',
|
|
136
|
-
value: '='
|
|
137
|
-
}, {
|
|
138
|
-
label: 'Is Not',
|
|
139
|
-
value: '<>'
|
|
140
|
-
}];
|
|
141
|
-
}
|
|
142
|
-
}
|