@k-int/stripes-kint-components 2.3.1 → 2.4.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/CHANGELOG.md +15 -1
- package/es/index.js +26 -2
- package/es/lib/ActionList/ActionListFieldArray.js +3 -4
- package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +9 -6
- package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +22 -15
- package/es/lib/CustomProperties/View/CustomPropertyCard.js +3 -2
- package/es/lib/FormModal/FormModal.js +2 -0
- package/es/lib/SASQLookupComponent/SASQLookupComponent.js +61 -105
- package/es/lib/SASQLookupComponent/TableBody/TableBody.js +146 -0
- package/es/lib/SASQLookupComponent/TableBody/index.js +19 -0
- package/es/lib/SASQLookupComponent/index.js +9 -1
- package/es/lib/SASQRoute/SASQRoute.js +2 -2
- package/es/lib/utils/highlightString.js +94 -0
- package/es/lib/utils/index.js +23 -1
- package/es/lib/utils/matchString.js +59 -0
- package/package.json +1 -1
- package/src/index.js +6 -1
- package/src/lib/ActionList/ActionListFieldArray.js +2 -3
- package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +9 -6
- package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.js +13 -8
- package/src/lib/CustomProperties/View/CustomPropertyCard.js +2 -2
- package/src/lib/FormModal/FormModal.js +2 -0
- package/src/lib/SASQLookupComponent/SASQLookupComponent.js +39 -77
- package/src/lib/SASQLookupComponent/TableBody/TableBody.js +96 -0
- package/src/lib/SASQLookupComponent/TableBody/index.js +1 -0
- package/src/lib/SASQLookupComponent/index.js +2 -1
- package/src/lib/SASQRoute/SASQRoute.js +1 -1
- package/src/lib/utils/highlightString.js +42 -0
- package/src/lib/utils/index.js +4 -0
- package/src/lib/utils/matchString.js +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
## 2.
|
|
1
|
+
## 2.4.0 2022-04-21
|
|
2
2
|
* Custom Property component fixes
|
|
3
|
+
* Fix to actionAssigner callback pattern
|
|
4
|
+
* Tweak to remove marginBottom0 warning
|
|
5
|
+
* FormModal buttons have marginBottom0 prop on them now
|
|
6
|
+
* Fixed issue where cusotm property updates would not be reflected on the open view pane in settings
|
|
7
|
+
* Fixed inconsistent `retiredName` labelOverride function behaviour, where in `filters` the function accepted the name, and in `view` the function accepted the entire object. The behaviour has been standardised to be the name alone in both scenarios.
|
|
8
|
+
* Fixed improper custom property count behaviour in view mode, now only _set_ primary properties are included in the count.
|
|
9
|
+
* ActionListFieldArray changed autofocus to autoFocus to avoid react console noise
|
|
10
|
+
* Refactored SASQ Components to fix various bugs/oddities
|
|
11
|
+
* TableBody default now exported as SASQTableBody from module
|
|
12
|
+
* Table now no longer redraws on row click
|
|
13
|
+
* Formatting tweaks to fix horizontal scroll issue
|
|
14
|
+
* Manually clearing the search field now has the same effect as clicking the "x" button to clear, ensuring the items are refetched without a search term.
|
|
15
|
+
* Implementor can pass props to the filter pane via "filterPaneProps" on SASQRoute/SASQLookupComponent
|
|
16
|
+
* boldString, highlightString, matchString util functions
|
|
3
17
|
|
|
4
18
|
## 2.3.0 2022-03-25
|
|
5
19
|
* FormModal
|
package/es/index.js
CHANGED
|
@@ -140,7 +140,7 @@ Object.defineProperty(exports, "RefdataButtons", {
|
|
|
140
140
|
Object.defineProperty(exports, "SASQLookupComponent", {
|
|
141
141
|
enumerable: true,
|
|
142
142
|
get: function get() {
|
|
143
|
-
return _SASQLookupComponent.
|
|
143
|
+
return _SASQLookupComponent.SASQLookupComponent;
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
Object.defineProperty(exports, "SASQRoute", {
|
|
@@ -149,6 +149,12 @@ Object.defineProperty(exports, "SASQRoute", {
|
|
|
149
149
|
return _SASQRoute.default;
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
|
+
Object.defineProperty(exports, "SASQTableBody", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
get: function get() {
|
|
155
|
+
return _SASQLookupComponent.TableBody;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
152
158
|
Object.defineProperty(exports, "SASQViewComponent", {
|
|
153
159
|
enumerable: true,
|
|
154
160
|
get: function get() {
|
|
@@ -185,6 +191,12 @@ Object.defineProperty(exports, "Typedown", {
|
|
|
185
191
|
return _Typedown.default;
|
|
186
192
|
}
|
|
187
193
|
});
|
|
194
|
+
Object.defineProperty(exports, "boldString", {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function get() {
|
|
197
|
+
return _utils.boldString;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
188
200
|
Object.defineProperty(exports, "composeValidators", {
|
|
189
201
|
enumerable: true,
|
|
190
202
|
get: function get() {
|
|
@@ -210,12 +222,24 @@ Object.defineProperty(exports, "groupCustomPropertiesByCtx", {
|
|
|
210
222
|
return _utils.groupCustomPropertiesByCtx;
|
|
211
223
|
}
|
|
212
224
|
});
|
|
225
|
+
Object.defineProperty(exports, "highlightString", {
|
|
226
|
+
enumerable: true,
|
|
227
|
+
get: function get() {
|
|
228
|
+
return _utils.highlightString;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
213
231
|
Object.defineProperty(exports, "invalidNumber", {
|
|
214
232
|
enumerable: true,
|
|
215
233
|
get: function get() {
|
|
216
234
|
return _validators.invalidNumber;
|
|
217
235
|
}
|
|
218
236
|
});
|
|
237
|
+
Object.defineProperty(exports, "matchString", {
|
|
238
|
+
enumerable: true,
|
|
239
|
+
get: function get() {
|
|
240
|
+
return _utils.matchString;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
219
243
|
Object.defineProperty(exports, "refdataOptions", {
|
|
220
244
|
enumerable: true,
|
|
221
245
|
get: function get() {
|
|
@@ -371,7 +395,7 @@ var _SearchField = _interopRequireDefault(require("./lib/SearchField"));
|
|
|
371
395
|
|
|
372
396
|
var _SASQRoute = _interopRequireDefault(require("./lib/SASQRoute"));
|
|
373
397
|
|
|
374
|
-
var _SASQLookupComponent =
|
|
398
|
+
var _SASQLookupComponent = require("./lib/SASQLookupComponent");
|
|
375
399
|
|
|
376
400
|
var _SASQViewComponent = _interopRequireDefault(require("./lib/SASQViewComponent"));
|
|
377
401
|
|
|
@@ -137,14 +137,14 @@ var ActionListFieldArray = function ActionListFieldArray(_ref) {
|
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
var handleSave = function handleSave(index) {
|
|
140
|
-
var _actionAssigner$find;
|
|
140
|
+
var _actionAssigner, _actionAssigner$find;
|
|
141
141
|
|
|
142
142
|
var _fields$value$index = fields.value[index],
|
|
143
143
|
_a = _fields$value$index.actionListActions,
|
|
144
144
|
rowData = _objectWithoutProperties(_fields$value$index, _excluded2); // Find "edit" entry in actionAssigner
|
|
145
145
|
|
|
146
146
|
|
|
147
|
-
var editCallback = (_actionAssigner$find =
|
|
147
|
+
var editCallback = (_actionAssigner = actionAssigner(rowData)) === null || _actionAssigner === void 0 ? void 0 : (_actionAssigner$find = _actionAssigner.find(function (act) {
|
|
148
148
|
return act.name === 'edit';
|
|
149
149
|
})) === null || _actionAssigner$find === void 0 ? void 0 : _actionAssigner$find.callback;
|
|
150
150
|
|
|
@@ -255,7 +255,6 @@ var ActionListFieldArray = function ActionListFieldArray(_ref) {
|
|
|
255
255
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.IconButton, {
|
|
256
256
|
disabled: editing,
|
|
257
257
|
icon: action.icon,
|
|
258
|
-
marginBottom0: true,
|
|
259
258
|
onClick: function onClick() {
|
|
260
259
|
return actionFunction ? actionFunction() : function () {
|
|
261
260
|
return null;
|
|
@@ -323,7 +322,7 @@ var ActionListFieldArray = function ActionListFieldArray(_ref) {
|
|
|
323
322
|
returnObj[key] = fieldComponents[key] ? fieldComponents[key]({
|
|
324
323
|
name: "".concat(fieldName, ".").concat(key)
|
|
325
324
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
326
|
-
|
|
325
|
+
autoFocus: fieldIndex === 0,
|
|
327
326
|
component: _components.TextField,
|
|
328
327
|
marginBottom0: true,
|
|
329
328
|
name: "".concat(fieldName, ".").concat(key),
|
|
@@ -134,20 +134,23 @@ var CustomPropertiesSettings = function CustomPropertiesSettings(_ref) {
|
|
|
134
134
|
|
|
135
135
|
var _useMutateCustomPrope = (0, _hooks.useMutateCustomProperties)({
|
|
136
136
|
afterQueryCalls: {
|
|
137
|
-
put: function put() {
|
|
137
|
+
put: function put(res) {
|
|
138
138
|
setMode(VIEWING);
|
|
139
139
|
queryClient.invalidateQueries(['stripes-kint-components', 'useCustomProperties', 'custprops']);
|
|
140
|
-
|
|
140
|
+
setCustomProperty(res);
|
|
141
|
+
afterQueryCallsSafe.put(res);
|
|
141
142
|
},
|
|
142
|
-
post: function post() {
|
|
143
|
+
post: function post(res) {
|
|
143
144
|
setMode(VIEWING);
|
|
144
145
|
queryClient.invalidateQueries(['stripes-kint-components', 'useCustomProperties', 'custprops']);
|
|
145
|
-
|
|
146
|
+
setCustomProperty(res);
|
|
147
|
+
afterQueryCallsSafe.post(res);
|
|
146
148
|
},
|
|
147
|
-
delete: function _delete() {
|
|
149
|
+
delete: function _delete(res) {
|
|
148
150
|
setMode(VIEWING);
|
|
149
151
|
queryClient.invalidateQueries(['stripes-kint-components', 'useCustomProperties', 'custprops']);
|
|
150
|
-
|
|
152
|
+
setCustomProperty();
|
|
153
|
+
afterQueryCallsSafe.delete(res);
|
|
151
154
|
}
|
|
152
155
|
},
|
|
153
156
|
endpoint: customPropertiesEndpoint,
|
|
@@ -41,7 +41,7 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
var CustomPropertiesViewCtx = function CustomPropertiesViewCtx(_ref) {
|
|
44
|
-
var _custprops$filter$len, _custprops$filter
|
|
44
|
+
var _custprops$filter$len, _custprops$filter;
|
|
45
45
|
|
|
46
46
|
var ctx = _ref.ctx,
|
|
47
47
|
_ref$customProperties = _ref.customProperties,
|
|
@@ -112,30 +112,37 @@ var CustomPropertiesViewCtx = function CustomPropertiesViewCtx(_ref) {
|
|
|
112
112
|
label: getAccordionLabel(),
|
|
113
113
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
|
|
114
114
|
});
|
|
115
|
-
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var countSetProperties = function countSetProperties(primary) {
|
|
118
|
+
var _Object$entries$filte, _Object$entries, _Object$entries$filte2;
|
|
119
|
+
|
|
120
|
+
return (_Object$entries$filte = (_Object$entries = Object.entries(customProperties)) === null || _Object$entries === void 0 ? void 0 : (_Object$entries$filte2 = _Object$entries.filter(function (_ref2) {
|
|
121
|
+
var _cp$, _cp$$type, _cp$2, _cp$2$type, _cp$3, _cp$3$type;
|
|
122
|
+
|
|
123
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
124
|
+
_key = _ref3[0],
|
|
125
|
+
cp = _ref3[1];
|
|
126
|
+
|
|
127
|
+
return (((_cp$ = cp[0]) === null || _cp$ === void 0 ? void 0 : (_cp$$type = _cp$.type) === null || _cp$$type === void 0 ? void 0 : _cp$$type.ctx) === ctx || ctx === 'isNull' && !((_cp$2 = cp[0]) !== null && _cp$2 !== void 0 && (_cp$2$type = _cp$2.type) !== null && _cp$2$type !== void 0 && _cp$2$type.ctx)) && // Either the ctx string matches, or isNull matches blank
|
|
128
|
+
((_cp$3 = cp[0]) === null || _cp$3 === void 0 ? void 0 : (_cp$3$type = _cp$3.type) === null || _cp$3$type === void 0 ? void 0 : _cp$3$type.primary) === primary // Only count non-primary set custprops
|
|
129
|
+
;
|
|
130
|
+
})) === null || _Object$entries$filte2 === void 0 ? void 0 : _Object$entries$filte2.length) !== null && _Object$entries$filte !== void 0 ? _Object$entries$filte : 0;
|
|
131
|
+
}; // We need to display any set properties, along with any non-set primary properties
|
|
116
132
|
|
|
117
133
|
|
|
118
134
|
var primaryCount = (_custprops$filter$len = custprops === null || custprops === void 0 ? void 0 : (_custprops$filter = custprops.filter(function (cp) {
|
|
119
135
|
return cp.primary === true;
|
|
120
136
|
})) === null || _custprops$filter === void 0 ? void 0 : _custprops$filter.length) !== null && _custprops$filter$len !== void 0 ? _custprops$filter$len : 0;
|
|
121
|
-
var optionalCount = (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
125
|
-
_key = _ref3[0],
|
|
126
|
-
cp = _ref3[1];
|
|
127
|
-
|
|
128
|
-
return (((_cp$ = cp[0]) === null || _cp$ === void 0 ? void 0 : (_cp$$type = _cp$.type) === null || _cp$$type === void 0 ? void 0 : _cp$$type.ctx) === ctx || ctx === 'isNull' && !((_cp$2 = cp[0]) !== null && _cp$2 !== void 0 && (_cp$2$type = _cp$2.type) !== null && _cp$2$type !== void 0 && _cp$2$type.ctx)) && // Either the ctx string matches, or isNull matches blank
|
|
129
|
-
((_cp$3 = cp[0]) === null || _cp$3 === void 0 ? void 0 : (_cp$3$type = _cp$3.type) === null || _cp$3$type === void 0 ? void 0 : _cp$3$type.primary) === false // Only count non-primary set custprops
|
|
130
|
-
;
|
|
131
|
-
})) === null || _Object$entries$filte2 === void 0 ? void 0 : _Object$entries$filte2.length) !== null && _Object$entries$filte !== void 0 ? _Object$entries$filte : 0;
|
|
137
|
+
var optionalCount = countSetProperties(false);
|
|
138
|
+
var setPrimaryCount = countSetProperties(true);
|
|
132
139
|
return primaryCount + optionalCount > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Accordion, {
|
|
133
140
|
closedByDefault: true,
|
|
134
141
|
displayWhenClosed: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Badge, {
|
|
135
|
-
children:
|
|
142
|
+
children: setPrimaryCount + optionalCount
|
|
136
143
|
}),
|
|
137
144
|
displayWhenOpen: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Badge, {
|
|
138
|
-
children:
|
|
145
|
+
children: setPrimaryCount + optionalCount
|
|
139
146
|
}),
|
|
140
147
|
id: "".concat(id, "-accordion-").concat(ctx),
|
|
141
148
|
label: getAccordionLabel(),
|
|
@@ -37,7 +37,8 @@ var CustomPropertyCard = function CustomPropertyCard(_ref) {
|
|
|
37
37
|
|
|
38
38
|
var ctx = _ref.ctx,
|
|
39
39
|
customProperty = _ref.customProperty,
|
|
40
|
-
|
|
40
|
+
_ref$customPropertyDe = _ref.customPropertyDefinition,
|
|
41
|
+
customPropertyDefinition = _ref$customPropertyDe === void 0 ? {} : _ref$customPropertyDe,
|
|
41
42
|
index = _ref.index,
|
|
42
43
|
labelOverrides = _ref.labelOverrides;
|
|
43
44
|
// We only need to display primary and set properties
|
|
@@ -54,7 +55,7 @@ var CustomPropertyCard = function CustomPropertyCard(_ref) {
|
|
|
54
55
|
|
|
55
56
|
// Label override for default card title,
|
|
56
57
|
if (labelOverrides.retiredName && typeof labelOverrides.retiredName === 'function') {
|
|
57
|
-
return labelOverrides.retiredName(customPropertyDefinition);
|
|
58
|
+
return labelOverrides.retiredName(customPropertyDefinition.name);
|
|
58
59
|
} // Label override for default title or finally built in default
|
|
59
60
|
|
|
60
61
|
|
|
@@ -75,11 +75,13 @@ var FormModal = function FormModal(_ref) {
|
|
|
75
75
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.ModalFooter, {
|
|
76
76
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
77
77
|
buttonStyle: "primary",
|
|
78
|
+
marginBottom0: true,
|
|
78
79
|
onClick: handleSubmit,
|
|
79
80
|
children: (_labelOverrides$save = labelOverrides.save) !== null && _labelOverrides$save !== void 0 ? _labelOverrides$save : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
80
81
|
id: "stripes-kint-components.save"
|
|
81
82
|
})
|
|
82
83
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
84
|
+
marginBottom0: true,
|
|
83
85
|
onClick: handleClose,
|
|
84
86
|
children: (_labelOverrides$cance = labelOverrides.cancel) !== null && _labelOverrides$cance !== void 0 ? _labelOverrides$cance : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
85
87
|
id: "stripes-kint-components.cancel"
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
9
|
|
|
12
10
|
var _reactIntl = require("react-intl");
|
|
@@ -19,14 +17,16 @@ var _smartComponents = require("@folio/stripes/smart-components");
|
|
|
19
17
|
|
|
20
18
|
var _components = require("@folio/stripes/components");
|
|
21
19
|
|
|
22
|
-
var _NoResultsMessage = _interopRequireDefault(require("../NoResultsMessage"));
|
|
23
|
-
|
|
24
20
|
var _utils = require("../utils");
|
|
25
21
|
|
|
26
22
|
var _hooks = require("../hooks");
|
|
27
23
|
|
|
24
|
+
var _TableBody = _interopRequireDefault(require("./TableBody"));
|
|
25
|
+
|
|
28
26
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
27
|
|
|
28
|
+
var _excluded = ["data"];
|
|
29
|
+
|
|
30
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
31
|
|
|
32
32
|
(function () {
|
|
@@ -48,6 +48,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
48
48
|
|
|
49
49
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
50
50
|
|
|
51
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
52
|
+
|
|
53
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
54
|
+
|
|
51
55
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
52
56
|
|
|
53
57
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -64,32 +68,26 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
|
|
|
64
68
|
return a;
|
|
65
69
|
};
|
|
66
70
|
|
|
67
|
-
var SASQLookupComponent = function SASQLookupComponent(
|
|
71
|
+
var SASQLookupComponent = function SASQLookupComponent(props) {
|
|
68
72
|
var _totalData$pages$redu, _totalData$pages;
|
|
69
73
|
|
|
70
|
-
var _children =
|
|
71
|
-
|
|
72
|
-
fetchParameters =
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
var _children = props.children,
|
|
75
|
+
_props$fetchParameter = props.fetchParameters,
|
|
76
|
+
fetchParameters = _props$fetchParameter === void 0 ? {} : _props$fetchParameter,
|
|
77
|
+
_props$FilterComponen = props.FilterComponent,
|
|
78
|
+
FilterComponent = _props$FilterComponen === void 0 ? function () {
|
|
75
79
|
return null;
|
|
76
|
-
} :
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
} : _props$FilterComponen,
|
|
81
|
+
_props$FilterPaneHead = props.FilterPaneHeaderComponent,
|
|
82
|
+
FilterPaneHeaderComponent = _props$FilterPaneHead === void 0 ? function () {
|
|
79
83
|
return null;
|
|
80
|
-
} :
|
|
81
|
-
|
|
82
|
-
id =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
noSearchField = _ref.noSearchField,
|
|
88
|
-
path = _ref.path,
|
|
89
|
-
_ref$resultColumns = _ref.resultColumns,
|
|
90
|
-
resultColumns = _ref$resultColumns === void 0 ? [] : _ref$resultColumns,
|
|
91
|
-
RenderBody = _ref.RenderBody,
|
|
92
|
-
sasqProps = _ref.sasqProps;
|
|
84
|
+
} : _props$FilterPaneHead,
|
|
85
|
+
filterPaneProps = props.filterPaneProps,
|
|
86
|
+
id = props.id,
|
|
87
|
+
mainPaneProps = props.mainPaneProps,
|
|
88
|
+
noSearchField = props.noSearchField,
|
|
89
|
+
RenderBody = props.RenderBody,
|
|
90
|
+
sasqProps = props.sasqProps;
|
|
93
91
|
|
|
94
92
|
var _useKiwtSASQuery = (0, _hooks.useKiwtSASQuery)(),
|
|
95
93
|
query = _useKiwtSASQuery.query,
|
|
@@ -102,9 +100,9 @@ var SASQLookupComponent = function SASQLookupComponent(_ref) {
|
|
|
102
100
|
var ky = (0, _core.useOkapiKy)();
|
|
103
101
|
var filterPaneVisibileKey = "".concat(namespace, "-").concat(id, "-filterPaneVisibility");
|
|
104
102
|
|
|
105
|
-
var fetchPageData = function fetchPageData(
|
|
106
|
-
var
|
|
107
|
-
pageParam =
|
|
103
|
+
var fetchPageData = function fetchPageData(_ref) {
|
|
104
|
+
var _ref$pageParam = _ref.pageParam,
|
|
105
|
+
pageParam = _ref$pageParam === void 0 ? 0 : _ref$pageParam;
|
|
108
106
|
var queryMap = fetchParameters.SASQ_MAP;
|
|
109
107
|
queryMap.offset = pageParam;
|
|
110
108
|
return ky("".concat(fetchParameters.endpoint).concat((0, _utils.generateKiwtQuery)(queryMap, query))).json();
|
|
@@ -122,10 +120,7 @@ var SASQLookupComponent = function SASQLookupComponent(_ref) {
|
|
|
122
120
|
var _useInfiniteQuery = (0, _reactQuery.useInfiniteQuery)([namespace, id, 'data', query], fetchPageData),
|
|
123
121
|
_useInfiniteQuery$dat = _useInfiniteQuery.data,
|
|
124
122
|
totalData = _useInfiniteQuery$dat === void 0 ? {} : _useInfiniteQuery$dat,
|
|
125
|
-
|
|
126
|
-
isError = _useInfiniteQuery.isError,
|
|
127
|
-
isLoading = _useInfiniteQuery.isLoading,
|
|
128
|
-
fetchNextPage = _useInfiniteQuery.fetchNextPage;
|
|
123
|
+
restOfInfiniteQueryProps = _objectWithoutProperties(_useInfiniteQuery, _excluded);
|
|
129
124
|
|
|
130
125
|
var data = (_totalData$pages$redu = (_totalData$pages = totalData.pages) === null || _totalData$pages === void 0 ? void 0 : _totalData$pages.reduce(function (acc, curr) {
|
|
131
126
|
var _acc$results, _curr$results;
|
|
@@ -147,22 +142,7 @@ var SASQLookupComponent = function SASQLookupComponent(_ref) {
|
|
|
147
142
|
newResults.push.apply(newResults, _toConsumableArray((_curr$results = curr.results) !== null && _curr$results !== void 0 ? _curr$results : []));
|
|
148
143
|
newAcc.results = newResults;
|
|
149
144
|
return newAcc;
|
|
150
|
-
}, {})) !== null && _totalData$pages$redu !== void 0 ? _totalData$pages$redu : {};
|
|
151
|
-
|
|
152
|
-
var onNeedMoreData = function onNeedMoreData(_askAmount, index) {
|
|
153
|
-
fetchNextPage({
|
|
154
|
-
pageParam: index
|
|
155
|
-
});
|
|
156
|
-
}; // Build the map of column definitions
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
var columnMapping = Object.fromEntries(resultColumns.map(function (e) {
|
|
160
|
-
return [e.propertyPath, e.label];
|
|
161
|
-
})); // Build the list of visible columns
|
|
162
|
-
|
|
163
|
-
var visibleColumns = resultColumns.map(function (e) {
|
|
164
|
-
return e.propertyPath;
|
|
165
|
-
});
|
|
145
|
+
}, {})) !== null && _totalData$pages$redu !== void 0 ? _totalData$pages$redu : {};
|
|
166
146
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_smartComponents.SearchAndSortQuery, _objectSpread(_objectSpread({
|
|
167
147
|
initialSearchState: {
|
|
168
148
|
query: ''
|
|
@@ -170,61 +150,23 @@ var SASQLookupComponent = function SASQLookupComponent(_ref) {
|
|
|
170
150
|
queryGetter: queryGetter,
|
|
171
151
|
querySetter: querySetter
|
|
172
152
|
}, sasqProps), {}, {
|
|
173
|
-
children: function children(
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
resetAll = _ref3.resetAll,
|
|
183
|
-
searchChanged = _ref3.searchChanged,
|
|
184
|
-
searchValue = _ref3.searchValue;
|
|
153
|
+
children: function children(sasqRenderProps) {
|
|
154
|
+
var activeFilters = sasqRenderProps.activeFilters,
|
|
155
|
+
filterChanged = sasqRenderProps.filterChanged,
|
|
156
|
+
getFilterHandlers = sasqRenderProps.getFilterHandlers,
|
|
157
|
+
getSearchHandlers = sasqRenderProps.getSearchHandlers,
|
|
158
|
+
onSubmitSearch = sasqRenderProps.onSubmitSearch,
|
|
159
|
+
resetAll = sasqRenderProps.resetAll,
|
|
160
|
+
searchChanged = sasqRenderProps.searchChanged,
|
|
161
|
+
searchValue = sasqRenderProps.searchValue;
|
|
185
162
|
var searchHandlers = getSearchHandlers();
|
|
186
|
-
var sortOrder = (_query$sort = query.sort) !== null && _query$sort !== void 0 ? _query$sort : '';
|
|
187
163
|
var disableReset = !filterChanged && !searchChanged;
|
|
188
164
|
var filterCount = activeFilters.string ? activeFilters.string.split(',').length : 0;
|
|
189
|
-
|
|
190
|
-
var TableBody = function TableBody() {
|
|
191
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MultiColumnList, _objectSpread({
|
|
192
|
-
autosize: true,
|
|
193
|
-
columnMapping: columnMapping,
|
|
194
|
-
contentData: data === null || data === void 0 ? void 0 : data.results,
|
|
195
|
-
isEmptyMessage: /*#__PURE__*/(0, _jsxRuntime.jsx)(_NoResultsMessage.default, {
|
|
196
|
-
error: error,
|
|
197
|
-
isError: isError,
|
|
198
|
-
isLoading: isLoading,
|
|
199
|
-
filterPaneIsVisible: filterPaneVisible,
|
|
200
|
-
searchTerm: query.query,
|
|
201
|
-
toggleFilterPane: toggleFilterPane
|
|
202
|
-
}),
|
|
203
|
-
isSelected: function isSelected(_ref4) {
|
|
204
|
-
var _match$params;
|
|
205
|
-
|
|
206
|
-
var item = _ref4.item;
|
|
207
|
-
return item.id === (match === null || match === void 0 ? void 0 : (_match$params = match.params) === null || _match$params === void 0 ? void 0 : _match$params.id);
|
|
208
|
-
},
|
|
209
|
-
onHeaderClick: onSort,
|
|
210
|
-
onNeedMoreData: onNeedMoreData,
|
|
211
|
-
onRowClick: function onRowClick(_e, rowData) {
|
|
212
|
-
history.push("".concat(path, "/").concat(rowData === null || rowData === void 0 ? void 0 : rowData.id).concat(location === null || location === void 0 ? void 0 : location.search));
|
|
213
|
-
},
|
|
214
|
-
pagingType: "click",
|
|
215
|
-
sortDirection: sortOrder.startsWith('-') ? 'descending' : 'ascending',
|
|
216
|
-
sortOrder: sortOrder.replace(/^-/, '').replace(/,.*/, ''),
|
|
217
|
-
totalCount: data.totalRecords,
|
|
218
|
-
virtualize: true,
|
|
219
|
-
visibleColumns: visibleColumns
|
|
220
|
-
}, mclProps));
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
var Body = RenderBody !== null && RenderBody !== void 0 ? RenderBody : TableBody;
|
|
165
|
+
var Body = RenderBody !== null && RenderBody !== void 0 ? RenderBody : _TableBody.default;
|
|
224
166
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_smartComponents.PersistedPaneset, {
|
|
225
167
|
appId: namespace,
|
|
226
168
|
id: "".concat(id, "-paneset"),
|
|
227
|
-
children: [filterPaneVisible && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Pane, {
|
|
169
|
+
children: [filterPaneVisible && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Pane, _objectSpread(_objectSpread({
|
|
228
170
|
defaultWidth: "20%",
|
|
229
171
|
lastMenu: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PaneMenu, {
|
|
230
172
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.IconButton, {
|
|
@@ -236,14 +178,23 @@ var SASQLookupComponent = function SASQLookupComponent(_ref) {
|
|
|
236
178
|
}),
|
|
237
179
|
paneTitle: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
238
180
|
id: "stripes-smart-components.searchAndFilter"
|
|
239
|
-
})
|
|
181
|
+
})
|
|
182
|
+
}, filterPaneProps), {}, {
|
|
240
183
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
|
|
241
184
|
onSubmit: onSubmitSearch,
|
|
242
185
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(FilterPaneHeaderComponent, {}), !noSearchField && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
243
186
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SearchField, {
|
|
244
187
|
autoFocus: true,
|
|
245
188
|
name: "query",
|
|
246
|
-
onChange:
|
|
189
|
+
onChange: function onChange(e) {
|
|
190
|
+
var _e$target;
|
|
191
|
+
|
|
192
|
+
if ((_e$target = e.target) !== null && _e$target !== void 0 && _e$target.value) {
|
|
193
|
+
searchHandlers.query(e); // SASQ needs the whole event here
|
|
194
|
+
} else {
|
|
195
|
+
searchHandlers.reset();
|
|
196
|
+
}
|
|
197
|
+
},
|
|
247
198
|
onClear: searchHandlers.reset,
|
|
248
199
|
value: searchValue.query
|
|
249
200
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
@@ -276,7 +227,7 @@ var SASQLookupComponent = function SASQLookupComponent(_ref) {
|
|
|
276
227
|
searchValue: searchValue
|
|
277
228
|
})]
|
|
278
229
|
})
|
|
279
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Pane, _objectSpread(_objectSpread({
|
|
230
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Pane, _objectSpread(_objectSpread({
|
|
280
231
|
defaultWidth: "fill",
|
|
281
232
|
firstMenu: !filterPaneVisible ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PaneMenu, {
|
|
282
233
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.IconButton, {
|
|
@@ -287,6 +238,8 @@ var SASQLookupComponent = function SASQLookupComponent(_ref) {
|
|
|
287
238
|
}
|
|
288
239
|
})
|
|
289
240
|
}) : null,
|
|
241
|
+
noOverflow: true,
|
|
242
|
+
padContent: false,
|
|
290
243
|
paneSub: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
|
|
291
244
|
id: "stripes-kint-components.sasqLookupComponent.mainPane.found",
|
|
292
245
|
values: {
|
|
@@ -294,22 +247,25 @@ var SASQLookupComponent = function SASQLookupComponent(_ref) {
|
|
|
294
247
|
}
|
|
295
248
|
})
|
|
296
249
|
}, mainPaneProps), {}, {
|
|
297
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Body, {
|
|
298
|
-
data: data
|
|
299
|
-
|
|
250
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Body, _objectSpread(_objectSpread(_objectSpread({
|
|
251
|
+
data: data,
|
|
252
|
+
query: query,
|
|
253
|
+
toggleFilterPane: toggleFilterPane
|
|
254
|
+
}, restOfInfiniteQueryProps), sasqProps), props))
|
|
300
255
|
})), _children]
|
|
301
256
|
});
|
|
302
257
|
}
|
|
303
258
|
}));
|
|
304
259
|
};
|
|
305
260
|
|
|
306
|
-
__signature__(SASQLookupComponent, "useKiwtSASQuery{{ query, queryGetter, querySetter }}\nuseNamespace{{ 0: namespace }}\nuseOkapiKy{ky}\nuseLocalStorageState{[filterPaneVisible, setFilterPaneVisible]}\nuseInfiniteQuery{{\n data: totalData = {},\n
|
|
261
|
+
__signature__(SASQLookupComponent, "useKiwtSASQuery{{ query, queryGetter, querySetter }}\nuseNamespace{{ 0: namespace }}\nuseOkapiKy{ky}\nuseLocalStorageState{[filterPaneVisible, setFilterPaneVisible]}\nuseInfiniteQuery{{\n data: totalData = {},\n ...restOfInfiniteQueryProps\n }}", function () {
|
|
307
262
|
return [_hooks.useKiwtSASQuery, _core.useNamespace, _core.useOkapiKy, _hooks.useLocalStorageState, _reactQuery.useInfiniteQuery];
|
|
308
263
|
});
|
|
309
264
|
|
|
310
265
|
SASQLookupComponent.propTypes = {
|
|
311
266
|
children: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
312
267
|
fetchParameters: _propTypes.default.object,
|
|
268
|
+
filterPaneProps: _propTypes.default.object,
|
|
313
269
|
FilterComponent: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
314
270
|
FilterPaneHeaderComponent: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
315
271
|
history: _propTypes.default.object,
|