@k-int/stripes-kint-components 2.1.0 → 2.1.3

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 CHANGED
@@ -1,4 +1,10 @@
1
- ## 2.1.0 In progress
1
+ ## 2.1.3 2022-03-10
2
+ * ActionList -- added a hideCreateButton prop for custom rolled solutions
3
+
4
+ ## 2.1.1 2022-03-10
5
+ * Fix -- GenerateQueryParams no longer assumes you want EITHER nsValues filters or options filters, it simply adds both to the params array
6
+ * ActionList -- added a hideCreateButton prop for custom rolled solutions
7
+ ## 2.1.0 2022-03-09
2
8
  * Fixes for ActionList
3
9
  * When no formatter is present, it no longer crashes
4
10
  * Formatting for buttons
@@ -19,7 +19,7 @@ var _ActionListFieldArray = _interopRequireDefault(require("./ActionListFieldArr
19
19
 
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
21
 
22
- var _excluded = ["actionAssigner", "actionCalls", "columnMapping", "contentData", "creatableFields", "editableFields", "fieldComponents", "visibleFields"];
22
+ var _excluded = ["actionAssigner", "actionCalls", "columnMapping", "contentData", "creatableFields", "editableFields", "fieldComponents", "hideCreateButton", "visibleFields"];
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
@@ -50,6 +50,7 @@ var propTypes = {
50
50
  creatableFields: _propTypes.default.object,
51
51
  editableFields: _propTypes.default.object,
52
52
  fieldComponents: _propTypes.default.object,
53
+ hideCreateButton: _propTypes.default.bool,
53
54
  visibleFields: _propTypes.default.arrayOf(_propTypes.default.string)
54
55
  };
55
56
 
@@ -65,6 +66,7 @@ var ActionList = function ActionList(_ref) {
65
66
  editableFields = _ref$editableFields === void 0 ? {} : _ref$editableFields,
66
67
  _ref$fieldComponents = _ref.fieldComponents,
67
68
  fieldComponents = _ref$fieldComponents === void 0 ? {} : _ref$fieldComponents,
69
+ hideCreateButton = _ref.hideCreateButton,
68
70
  visibleFields = _ref.visibleFields,
69
71
  mclProps = _objectWithoutProperties(_ref, _excluded);
70
72
 
@@ -92,6 +94,7 @@ var ActionList = function ActionList(_ref) {
92
94
  creatableFields: creatableFields,
93
95
  editableFields: editableFields,
94
96
  fieldComponents: fieldComponents,
97
+ hideCreateButton: hideCreateButton,
95
98
  name: "contentData",
96
99
  visibleFields: visibleFields
97
100
  }, mclProps))
@@ -23,7 +23,7 @@ var _ActionListFieldArray = _interopRequireDefault(require("../../../styles/Acti
23
23
 
24
24
  var _jsxRuntime = require("react/jsx-runtime");
25
25
 
26
- var _excluded = ["actionAssigner", "actionCalls", "columnMapping", "creatableFields", "editableFields", "fields", "fieldComponents", "visibleFields"],
26
+ var _excluded = ["actionAssigner", "actionCalls", "columnMapping", "creatableFields", "editableFields", "fields", "fieldComponents", "hideCreateButton", "visibleFields"],
27
27
  _excluded2 = ["actionListActions"],
28
28
  _excluded3 = ["actionListActions"],
29
29
  _excluded4 = ["actionListActions"],
@@ -88,6 +88,7 @@ var propTypes = {
88
88
  fields: _propTypes.default.object,
89
89
  fieldComponents: _propTypes.default.object,
90
90
  formatter: _propTypes.default.object,
91
+ hideCreateButton: _propTypes.default.bool,
91
92
  visibleFields: _propTypes.default.arrayOf(_propTypes.default.string)
92
93
  };
93
94
 
@@ -99,6 +100,8 @@ var ActionListFieldArray = function ActionListFieldArray(_ref) {
99
100
  editableFields = _ref.editableFields,
100
101
  fields = _ref.fields,
101
102
  fieldComponents = _ref.fieldComponents,
103
+ _ref$hideCreateButton = _ref.hideCreateButton,
104
+ hideCreateButton = _ref$hideCreateButton === void 0 ? false : _ref$hideCreateButton,
102
105
  visibleFields = _ref.visibleFields,
103
106
  mclProps = _objectWithoutProperties(_ref, _excluded);
104
107
 
@@ -328,7 +331,7 @@ var ActionListFieldArray = function ActionListFieldArray(_ref) {
328
331
  };
329
332
 
330
333
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
331
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
334
+ children: [!hideCreateButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
332
335
  buttonClass: _ActionListFieldArray.default.buttonRight,
333
336
  disabled: !actionCalls.create,
334
337
  onClick: function onClick() {
@@ -96,7 +96,9 @@ var generateKiwtQueryParams = function generateKiwtQueryParams(options, nsValues
96
96
  }
97
97
  }
98
98
  });
99
- } else if (filters) {
99
+ }
100
+
101
+ if (filters) {
100
102
  var filterMap = {};
101
103
  filters.split(',').forEach(function (filter) {
102
104
  var _filter$trim;
@@ -143,7 +145,9 @@ var generateKiwtQueryParams = function generateKiwtQueryParams(options, nsValues
143
145
  paramsArray.push("sort=".concat(os.path, ";").concat((_os$direction = os.direction) !== null && _os$direction !== void 0 ? _os$direction : 'asc'));
144
146
  }
145
147
  });
146
- } else if (sort) {
148
+ }
149
+
150
+ if (sort) {
147
151
  var _sort$trim;
148
152
 
149
153
  paramsArray.push.apply(paramsArray, _toConsumableArray((_sort$trim = sort.trim()) === null || _sort$trim === void 0 ? void 0 : _sort$trim.split(',').map(function (sortKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-int/stripes-kint-components",
3
- "version": "2.1.0",
3
+ "version": "2.1.3",
4
4
  "description": "Stripes Component library for K-Int specific applications",
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -15,6 +15,7 @@ const propTypes = {
15
15
  creatableFields: PropTypes.object,
16
16
  editableFields: PropTypes.object,
17
17
  fieldComponents: PropTypes.object,
18
+ hideCreateButton: PropTypes.bool,
18
19
  visibleFields: PropTypes.arrayOf(PropTypes.string)
19
20
  };
20
21
 
@@ -26,6 +27,7 @@ const ActionList = ({
26
27
  creatableFields = {},
27
28
  editableFields = {},
28
29
  fieldComponents = {},
30
+ hideCreateButton,
29
31
  visibleFields,
30
32
  ...mclProps // Assume anything left over is to directly apply to the MCL
31
33
  }) => {
@@ -48,6 +50,7 @@ const ActionList = ({
48
50
  creatableFields={creatableFields}
49
51
  editableFields={editableFields}
50
52
  fieldComponents={fieldComponents}
53
+ hideCreateButton={hideCreateButton}
51
54
  name="contentData"
52
55
  visibleFields={visibleFields}
53
56
  {...mclProps}
@@ -20,6 +20,7 @@ const propTypes = {
20
20
  fields: PropTypes.object,
21
21
  fieldComponents: PropTypes.object,
22
22
  formatter: PropTypes.object,
23
+ hideCreateButton: PropTypes.bool,
23
24
  visibleFields: PropTypes.arrayOf(PropTypes.string)
24
25
  };
25
26
 
@@ -31,6 +32,7 @@ const ActionListFieldArray = ({
31
32
  editableFields,
32
33
  fields,
33
34
  fieldComponents,
35
+ hideCreateButton = false,
34
36
  visibleFields,
35
37
  ...mclProps // Assume anything left over is to directly apply to the MCL
36
38
  }) => {
@@ -242,16 +244,18 @@ const ActionListFieldArray = ({
242
244
 
243
245
  return (
244
246
  <>
245
- <Button
246
- buttonClass={css.buttonRight}
247
- disabled={!actionCalls.create}
248
- onClick={() => {
249
- toggleEditing('NEW_ROW');
250
- fields.push({});
251
- }}
252
- >
253
- <FormattedMessage id="stripes-kint-components.actionList.create" />
254
- </Button>
247
+ {!hideCreateButton &&
248
+ <Button
249
+ buttonClass={css.buttonRight}
250
+ disabled={!actionCalls.create}
251
+ onClick={() => {
252
+ toggleEditing('NEW_ROW');
253
+ fields.push({});
254
+ }}
255
+ >
256
+ <FormattedMessage id="stripes-kint-components.actionList.create" />
257
+ </Button>
258
+ }
255
259
  <MultiColumnList
256
260
  columnMapping={{
257
261
  ...columnMapping,
@@ -65,5 +65,6 @@ creatableFields | object<function> | An object with keys from the `visibleFields
65
65
  editableFields | object<function> | An object with keys from the `visibleFields` array, and values of functions which take the entire row object and return a boolean indicating whether that field is editable or not. No key for a given field will be interpreted as () => true, so a field is editable by default. | | ✕ |
66
66
  fieldComponents | object<function> | An object with keys from the `visibleFields` array, and values of functions which take some `fieldProps` (currently only the name of the field `name`), and returns a Field component to be used in "edit mode" for the visible field specified. | | ✕ |
67
67
  formatter | object<function> | A "formatter" object that takes the same shape as an MCL formatter, and is used in the same way whilst a row is NOT being edited. While editing a given row, this formatter entry is ignored. | | ✕ |
68
+ hideCreateButton | boolean | A simple bool to hide the create button. Default behaviour without create action is disabled. | false | ✕ |
68
69
  visibleFields | array<String> | An array of strings corresponding to those fields to be displayed in the rendered MultiColumnList | | ✓ |
69
70
  ...mclProps | any | Any other props supplied to ActionList will be applied to the MCL directly. *WARNING* Some MCL props may override important functionality within ActionList | | ✕ |
@@ -6,14 +6,12 @@ const generateKiwtQueryParams = (options, nsValues) => {
6
6
  filterKeys = {},
7
7
  sortKeys = {},
8
8
  stats = true,
9
- /* Assumption made that if a direct sort array is passed in options, it overrides the nsValues
10
- * Of the form [{ path: 'this.is.some.path', direction: 'asc'/'desc', value: 'someOverrideValue'}, ...]
9
+ /* Of the form [{ path: 'this.is.some.path', direction: 'asc'/'desc', value: 'someOverrideValue'}, ...]
11
10
  * If only path is passed then assume asc.
12
11
  * If value is passed then we ignore path/direction and append "sort=${value}" directly
13
12
  */
14
13
  sort: optionsSort,
15
- /* Assumption made that if a direct filters array is passed in options, it overrides the nsValues
16
- * Of the form
14
+ /* Of the form
17
15
  [
18
16
  {
19
17
  path: 'this.is.some.path'
@@ -62,7 +60,9 @@ const generateKiwtQueryParams = (options, nsValues) => {
62
60
  }
63
61
  }
64
62
  });
65
- } else if (filters) {
63
+ }
64
+
65
+ if (filters) {
66
66
  const filterMap = {};
67
67
  filters.split(',').forEach(filter => {
68
68
  const [filterName, ...filterRest] = filter.trim()?.split('.');
@@ -94,7 +94,9 @@ const generateKiwtQueryParams = (options, nsValues) => {
94
94
  paramsArray.push(`sort=${os.path};${os.direction ?? 'asc'}`);
95
95
  }
96
96
  });
97
- } else if (sort) {
97
+ }
98
+
99
+ if (sort) {
98
100
  paramsArray.push(...sort.trim()?.split(',').map(sortKey => {
99
101
  const descending = sortKey.startsWith('-');
100
102
  let term = sortKey.replace('-', '');