@k-int/stripes-kint-components 2.6.6 → 2.7.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +13 -16
  2. package/es/index.js +24 -0
  3. package/es/lib/ActionList/ActionList.js +6 -2
  4. package/es/lib/ActionList/ActionListFieldArray.js +24 -14
  5. package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +2 -1
  6. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +2 -1
  7. package/es/lib/CustomProperties/Config/CustomPropertyForm.js +2 -1
  8. package/es/lib/CustomProperties/Config/CustomPropertyView.js +2 -1
  9. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +2 -1
  10. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +2 -1
  11. package/es/lib/CustomProperties/Edit/CustomPropertyField.js +2 -1
  12. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +2 -1
  13. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +2 -1
  14. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +2 -1
  15. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +2 -1
  16. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +3 -2
  17. package/es/lib/CustomProperties/View/CustomPropertyCard.js +2 -1
  18. package/es/lib/CycleButton/CycleButton.js +81 -0
  19. package/es/lib/CycleButton/index.js +15 -0
  20. package/es/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +281 -0
  21. package/es/lib/EditableRefdataCategoryList/index.js +15 -0
  22. package/es/lib/EditableRefdataList/EditableRefdataList.js +2 -1
  23. package/es/lib/IconSelect/IconSelect.js +183 -0
  24. package/es/lib/IconSelect/index.js +15 -0
  25. package/es/lib/hooks/index.js +8 -0
  26. package/es/lib/hooks/useMutateRefdataCategory.js +108 -0
  27. package/es/lib/utils/refdataOptions.js +3 -0
  28. package/package.json +1 -1
  29. package/src/index.js +4 -0
  30. package/src/lib/ActionList/ActionList.js +4 -1
  31. package/src/lib/ActionList/ActionListFieldArray.js +22 -11
  32. package/src/lib/ActionList/README.md +9 -8
  33. package/src/lib/CustomProperties/Config/CustomPropertiesLookup.js +1 -1
  34. package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +1 -1
  35. package/src/lib/CustomProperties/Config/CustomPropertyForm.js +1 -1
  36. package/src/lib/CustomProperties/Config/CustomPropertyView.js +1 -1
  37. package/src/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +1 -1
  38. package/src/lib/CustomProperties/Edit/CustomPropertiesListField.js +1 -1
  39. package/src/lib/CustomProperties/Edit/CustomPropertyField.js +1 -1
  40. package/src/lib/CustomProperties/Edit/CustomPropertyFormCard.js +1 -1
  41. package/src/lib/CustomProperties/Filter/CustomPropertiesFilter.js +1 -1
  42. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +1 -1
  43. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +1 -1
  44. package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.js +2 -3
  45. package/src/lib/CustomProperties/View/CustomPropertyCard.js +1 -1
  46. package/src/lib/CycleButton/CycleButton.js +43 -0
  47. package/src/lib/CycleButton/README.md +28 -0
  48. package/src/lib/CycleButton/index.js +1 -0
  49. package/src/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +167 -0
  50. package/src/lib/EditableRefdataCategoryList/index.js +1 -0
  51. package/src/lib/EditableRefdataList/EditableRefdataList.js +1 -1
  52. package/src/lib/IconSelect/IconSelect.js +149 -0
  53. package/src/lib/IconSelect/README.md +36 -0
  54. package/src/lib/IconSelect/index.js +1 -0
  55. package/src/lib/hooks/index.js +1 -0
  56. package/src/lib/hooks/useMutateRefdataCategory.js +63 -0
  57. package/src/lib/utils/refdataOptions.js +1 -0
  58. package/styles/CycleButton.css +5 -0
  59. package/styles/IconSelect.css +5 -0
  60. package/translations/stripes-kint-components/ar.json +14 -7
  61. package/translations/stripes-kint-components/cs_CZ.json +14 -7
  62. package/translations/stripes-kint-components/de.json +14 -7
  63. package/translations/stripes-kint-components/en.json +13 -1
  64. package/translations/stripes-kint-components/es.json +14 -7
  65. package/translations/stripes-kint-components/hi_IN.json +121 -1
  66. package/translations/stripes-kint-components/hu.json +14 -7
  67. package/translations/stripes-kint-components/it_IT.json +14 -7
  68. package/translations/stripes-kint-components/ja.json +14 -7
  69. package/translations/stripes-kint-components/ko.json +14 -7
  70. package/translations/stripes-kint-components/pl.json +1 -114
  71. package/translations/stripes-kint-components/pt_PT.json +14 -7
  72. package/translations/stripes-kint-components/ru.json +14 -7
  73. package/translations/stripes-kint-components/sv.json +14 -7
  74. package/translations/stripes-kint-components/zh_CN.json +14 -7
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _reactQuery = require("react-query");
11
+
12
+ var _core = require("@folio/stripes/core");
13
+
14
+ var _useInvalidateRefdata = _interopRequireDefault(require("./useInvalidateRefdata"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ 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; }
19
+
20
+ 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) { _defineProperty(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; }
21
+
22
+ 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; }
23
+
24
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
25
+
26
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
27
+
28
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
29
+
30
+ var useMutateRefdataCategory = function useMutateRefdataCategory(_ref) {
31
+ var afterQueryCalls = _ref.afterQueryCalls,
32
+ catchQueryCalls = _ref.catchQueryCalls,
33
+ endpoint = _ref.endpoint,
34
+ queryParams = _ref.queryParams,
35
+ _ref$returnQueryObjec = _ref.returnQueryObject,
36
+ returnQueryObject = _ref$returnQueryObjec === void 0 ? {
37
+ post: false,
38
+ delete: false
39
+ } : _ref$returnQueryObjec;
40
+ var returnObj = {};
41
+ var ky = (0, _core.useOkapiKy)();
42
+ var invalidateRefdata = (0, _useInvalidateRefdata.default)();
43
+ var deleteQueryObject = (0, _reactQuery.useMutation)(['stripes-kint-components', 'useMutateRefdataCategory', 'delete'], /*#__PURE__*/function () {
44
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(id) {
45
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
46
+ while (1) {
47
+ switch (_context.prev = _context.next) {
48
+ case 0:
49
+ return _context.abrupt("return", ky.delete("".concat(endpoint, "/").concat(id)).json().then(afterQueryCalls === null || afterQueryCalls === void 0 ? void 0 : afterQueryCalls.delete).then(function () {
50
+ return invalidateRefdata();
51
+ }).catch(catchQueryCalls === null || catchQueryCalls === void 0 ? void 0 : catchQueryCalls.delete));
52
+
53
+ case 1:
54
+ case "end":
55
+ return _context.stop();
56
+ }
57
+ }
58
+ }, _callee);
59
+ }));
60
+
61
+ return function (_x) {
62
+ return _ref2.apply(this, arguments);
63
+ };
64
+ }(), queryParams === null || queryParams === void 0 ? void 0 : queryParams.delete);
65
+ var postQueryObject = (0, _reactQuery.useMutation)(['stripes-kint-components', 'useMutateRefdataCategory', 'post'], /*#__PURE__*/function () {
66
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload) {
67
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
68
+ while (1) {
69
+ switch (_context2.prev = _context2.next) {
70
+ case 0:
71
+ return _context2.abrupt("return", ky.post(endpoint, {
72
+ json: _objectSpread(_objectSpread({}, payload), {}, {
73
+ values: []
74
+ })
75
+ }).json().then(afterQueryCalls === null || afterQueryCalls === void 0 ? void 0 : afterQueryCalls.post).then(function () {
76
+ return invalidateRefdata();
77
+ }).catch(catchQueryCalls === null || catchQueryCalls === void 0 ? void 0 : catchQueryCalls.post));
78
+
79
+ case 1:
80
+ case "end":
81
+ return _context2.stop();
82
+ }
83
+ }
84
+ }, _callee2);
85
+ }));
86
+
87
+ return function (_x2) {
88
+ return _ref3.apply(this, arguments);
89
+ };
90
+ }(), queryParams === null || queryParams === void 0 ? void 0 : queryParams.post);
91
+
92
+ if (returnQueryObject !== null && returnQueryObject !== void 0 && returnQueryObject.delete) {
93
+ returnObj.delete = deleteQueryObject;
94
+ } else {
95
+ returnObj.delete = deleteQueryObject.mutateAsync;
96
+ }
97
+
98
+ if (returnQueryObject !== null && returnQueryObject !== void 0 && returnQueryObject.post) {
99
+ returnObj.post = postQueryObject;
100
+ } else {
101
+ returnObj.post = postQueryObject.mutateAsync;
102
+ }
103
+
104
+ return returnObj;
105
+ };
106
+
107
+ var _default = useMutateRefdataCategory;
108
+ exports.default = _default;
@@ -8,6 +8,9 @@ var _default = {
8
8
  filterKeys: {
9
9
  DescKey: 'desc'
10
10
  },
11
+ sort: [{
12
+ path: 'desc'
13
+ }],
11
14
  stats: false,
12
15
  max: 100
13
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-int/stripes-kint-components",
3
- "version": "2.6.6",
3
+ "version": "2.7.0",
4
4
  "description": "Stripes Component library for K-Int specific applications",
5
5
  "sideEffects": [
6
6
  "*.css"
package/src/index.js CHANGED
@@ -53,6 +53,7 @@ export {
53
53
  // ActionList & RefdataEditor components
54
54
  export { default as ActionList } from './lib/ActionList';
55
55
  export { default as EditableRefdataList } from './lib/EditableRefdataList';
56
+ export { default as EditableRefdataCategoryList } from './lib/EditableRefdataCategoryList';
56
57
 
57
58
  // Typedown
58
59
  export {
@@ -121,3 +122,6 @@ export {
121
122
  } from './lib/CustomProperties';
122
123
 
123
124
  export * as customPropertyContants from './lib/constants/customProperties';
125
+
126
+ export { default as CycleButton } from './lib/CycleButton';
127
+ export { default as IconSelect } from './lib/IconSelect';
@@ -32,6 +32,7 @@ const ActionList = forwardRef(({
32
32
  fieldComponents = {},
33
33
  hideCreateButton,
34
34
  label,
35
+ validateFields,
35
36
  visibleFields,
36
37
  ...mclProps // Assume anything left over is to directly apply to the MCL
37
38
  }, ref) => {
@@ -48,7 +49,7 @@ const ActionList = forwardRef(({
48
49
  onSubmit={() => null}
49
50
  subscription={{ contentData: true }}
50
51
  >
51
- {() => (
52
+ {({ handleSubmit }) => (
52
53
  <form onSubmit={e => { e.preventDefault(); }}>
53
54
  <FieldArray
54
55
  actionAssigner={actionAssigner}
@@ -62,6 +63,8 @@ const ActionList = forwardRef(({
62
63
  hideCreateButton={hideCreateButton}
63
64
  label={label}
64
65
  name="contentData"
66
+ triggerFormSubmit={handleSubmit}
67
+ validateFields={validateFields}
65
68
  visibleFields={visibleFields}
66
69
  {...mclProps}
67
70
  />
@@ -37,12 +37,14 @@ const ActionListFieldArray = forwardRef(({
37
37
  fieldComponents,
38
38
  hideCreateButton = false,
39
39
  label,
40
+ validateFields,
40
41
  visibleFields,
42
+ triggerFormSubmit,
41
43
  ...mclProps // Assume anything left over is to directly apply to the MCL
42
44
  }, ref) => {
43
45
  // Grab finalForm functions/values from form hooks
44
46
  const { change } = useForm();
45
- const { initialValues, pristine, submitting, values } = useFormState();
47
+ const { hasValidationErrors, initialValues, pristine, submitting, values } = useFormState();
46
48
 
47
49
  /*
48
50
  Keep track of which field we are editing.
@@ -136,13 +138,18 @@ const ActionListFieldArray = forwardRef(({
136
138
  disabled={submitting || pristine}
137
139
  marginBottom0
138
140
  onClick={() => {
139
- if (!data.id && editing === 'NEW_ROW') {
140
- handleCreate(data.rowIndex);
141
- } else {
142
- handleSave(data.rowIndex);
141
+ triggerFormSubmit(); // This is set up as () => null in ActionList, so essentially only acts here to force validation
142
+
143
+ if (!hasValidationErrors) {
144
+ if (!data.id && editing === 'NEW_ROW') {
145
+ handleCreate(data.rowIndex);
146
+ } else {
147
+ handleSave(data.rowIndex);
148
+ }
149
+ toggleEditing(data.id);
143
150
  }
144
- toggleEditing(data.id);
145
151
  }}
152
+ type="submit"
146
153
  >
147
154
  <FormattedMessage id="stripes-kint-components.actionList.save" />
148
155
  </Button>
@@ -241,6 +248,9 @@ const ActionListFieldArray = forwardRef(({
241
248
  const fieldAwareFormatter = () => {
242
249
  const returnObj = {};
243
250
  // For each visible field, if it's being edited then ignore passed formatters, else use them
251
+
252
+ // Track whether we've autoFocused on a field yet
253
+ let autoFocus = true;
244
254
  visibleFields.forEach(key => {
245
255
  returnObj[key] = cd => {
246
256
  // Row is being edited if it has no id, or its id is in the editing string
@@ -269,25 +279,26 @@ const ActionListFieldArray = forwardRef(({
269
279
  (!cd.id && createFunction(cd)) ||
270
280
  (editFunction(cd))
271
281
  ) {
282
+ const validateFunction = validateFields?.[key] ? validateFields?.[key](cd) : null;
283
+
272
284
  returnValue =
273
285
  fieldComponents[key] ?
274
286
  fieldComponents[key]({
275
287
  name: `${cd.fieldName}.${key}`
276
288
  }) :
277
289
  <Field
278
- autoFocus={cd.fieldIndex === 0}
290
+ autoFocus={autoFocus}
279
291
  component={TextField}
280
292
  marginBottom0
281
293
  name={`${cd.fieldName}.${key}`}
282
294
  parse={v => v}
295
+ validate={validateFunction}
283
296
  />;
297
+ // After first field, every other field should not autofocus
298
+ autoFocus = false;
284
299
  }
285
300
  }
286
301
 
287
- if (formatter?.[key]) {
288
- returnValue = formatter[key](cd);
289
- }
290
-
291
302
  return returnValue;
292
303
  };
293
304
  });
@@ -89,15 +89,16 @@ const myRef = useRef();
89
89
 
90
90
  Name | Type | Description | default | required
91
91
  --- | --- | --- | --- | ---
92
- actionAssigner | function | A function which will be passed the entire row object, and can use that to assign an array of actions valid for that row, in the form `{ name: 'actionName', label: "Action Label", icon: 'someIcon', callback: () => null, to: toObject, ariaLabel: () => null }`. The prop `name` is required, but `label` and `icon` are optional props. The `callback` prop will be prioritised ahead of the deprecated actionCalls prop. The `ariaLabel` prop, which can be either a static string or a function accepting the row data and returning a string, will give the associated icon button an aria-label. If a `to` prop is passed, then the resulting button will be rendered as a <Link/> element, as per Stripes Button/IconButton.| | ✓ |
93
- actionCalls (DEPRECATED) | object<function> | An object with keys matching any "actions" the `actionAssigner` may have assigned (In addition to special case `create`, if relevant), and values which are functions. These functions will be handed the row as a parameter. THESE CAN NOW BE PASSED AS "callback" in the actionAssigner. | {} | ✕ |
92
+ actionAssigner | function | A function which will be passed the entire row object, and can use that to assign an array of actions valid for that row, in the form `{ name: 'actionName', label: "Action Label", icon: 'someIcon', callback: () => null, to: toObject, ariaLabel: () => null }`. The prop `name` is required, but `label` and `icon` are optional props. The `callback` prop will be prioritised ahead of the deprecated actionCalls prop. The `ariaLabel` prop, which can be either a static string or a function accepting the row data and returning a string, will give the associated icon button an aria-label. If a `to` prop is passed, then the resulting button will be rendered as a \<Link/> element, as per Stripes Button/IconButton.| | ✓ |
93
+ actionCalls (DEPRECATED) | object\<function> | An object with keys matching any "actions" the `actionAssigner` may have assigned (In addition to special case `create`, if relevant), and values which are functions. These functions will be handed the row as a parameter. THESE CAN NOW BE PASSED AS "callback" in the actionAssigner. | {} | ✕ |
94
94
  columnMapping | object | An object which will act on the rendered MultiColumnList headers to map the labels for each `visibleField` | | ✕ |
95
95
  contentData | array | An array of objects to render along with their actions | | ✓ |
96
- creatableFields | 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 fillable on create or not. | | ✕ |
97
- createCallback | <function> | A callback to be used for the built in "create" action (ie "save" on a new row). Will be prioritised ahead of a `create` entry in the deprecated actionCalls prop. | {} | ✕ |
98
- 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. | | ✕ |
99
- 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. | | ✕ |
100
- 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. | | ✕ |
96
+ creatableFields | 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 fillable on create or not. | | ✕ |
97
+ createCallback | function | A callback to be used for the built in "create" action (ie "save" on a new row). Will be prioritised ahead of a `create` entry in the deprecated actionCalls prop. | {} | ✕ |
98
+ 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. | | ✕ |
99
+ 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. | | ✕ |
100
+ 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. | | ✕ |
101
101
  hideCreateButton | boolean | A simple bool to hide the create button. Default behaviour without create action is disabled. | false | ✕ |
102
- visibleFields | array<String> | An array of strings corresponding to those fields to be displayed in the rendered MultiColumnList | | |
102
+ validateFields | object\<function> | An object with keys from the `visibleFields` array, and values of functions which take the entire row object and either return a validate function for final-form, or null | | |
103
+ visibleFields | array\<String> | An array of strings corresponding to those fields to be displayed in the rendered MultiColumnList | | ✓ |
103
104
  ...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 | | ✕ |
@@ -14,7 +14,7 @@ import css from '../../../../styles/CustomProperties.css';
14
14
  const CustomPropertiesLookup = ({
15
15
  contextFilterOptions, // expects an array of the form [{value: "OpenAccess", label: "Open Access"}, {value: false, label: "None"}]
16
16
  customPropertiesEndpoint: endpoint,
17
- labelOverrides,
17
+ labelOverrides = {},
18
18
  mclProps,
19
19
  onSelectCustomProperty,
20
20
  queryParams
@@ -27,7 +27,7 @@ const CustomPropertiesSettings = ({
27
27
  contextFilterOptions,
28
28
  customPropertiesEndpoint,
29
29
  helpPopovers,
30
- labelOverrides,
30
+ labelOverrides = {},
31
31
  refdataEndpoint,
32
32
  }) => {
33
33
  const callout = useContext(CalloutContext);
@@ -26,7 +26,7 @@ import {
26
26
  const CustomPropertyForm = ({
27
27
  contextFilterOptions,
28
28
  helpPopovers,
29
- labelOverrides,
29
+ labelOverrides = {},
30
30
  refdata
31
31
  }) => {
32
32
  const { values } = useFormState();
@@ -8,7 +8,7 @@ import { MULTI_REFDATA_CLASS_NAME, REFDATA_CLASS_NAME } from '../../constants/cu
8
8
  const CustomPropertyView = ({
9
9
  customProperty,
10
10
  helpPopovers,
11
- labelOverrides
11
+ labelOverrides = {}
12
12
  }) => {
13
13
  return (
14
14
  <>
@@ -9,7 +9,7 @@ const CustomPropertiesEditCtx = ({
9
9
  ctx,
10
10
  customPropertiesEndpoint,
11
11
  id,
12
- labelOverrides,
12
+ labelOverrides = {},
13
13
  nameOverride
14
14
  }) => {
15
15
  // Deal with all the possible label override options
@@ -14,7 +14,7 @@ const CustomPropertiesList = ({
14
14
  onChange,
15
15
  value
16
16
  },
17
- labelOverrides,
17
+ labelOverrides = {},
18
18
  meta: {
19
19
  pristine
20
20
  },
@@ -24,7 +24,7 @@ const CustomPropertyField = ({
24
24
  customPropertyType,
25
25
  customProperties,
26
26
  index,
27
- labelOverrides,
27
+ labelOverrides = {},
28
28
  name,
29
29
  onChange,
30
30
  value,
@@ -19,7 +19,7 @@ const CustomPropertyFormCard = ({
19
19
  handleDeleteCustomProperty,
20
20
  index,
21
21
  internalPropertyCounter,
22
- labelOverrides,
22
+ labelOverrides = {},
23
23
  name,
24
24
  onChange,
25
25
  setCustomProperties,
@@ -20,7 +20,7 @@ const CustomPropertiesFilter = ({
20
20
  },
21
21
  customPropertiesEndpoint,
22
22
  filterHandlers,
23
- labelOverrides
23
+ labelOverrides = {}
24
24
  }) => {
25
25
  const [editingFilters, setEditingFilters] = useState(false);
26
26
  const openEditModal = () => setEditingFilters(true);
@@ -17,7 +17,7 @@ import CustomPropertiesFilterField from './CustomPropertiesFilterField';
17
17
 
18
18
  const CustomPropertiesFilterFieldArray = ({
19
19
  customProperties,
20
- labelOverrides,
20
+ labelOverrides = {},
21
21
  }) => {
22
22
  const { mutators: { push } } = useForm();
23
23
 
@@ -19,7 +19,7 @@ const CustomPropertyFiltersForm = ({
19
19
  closeEditModal,
20
20
  openEditModal,
21
21
  },
22
- labelOverrides,
22
+ labelOverrides = {},
23
23
  onSubmit,
24
24
  }) => {
25
25
  return (
@@ -11,7 +11,7 @@ const CustomPropertiesViewCtx = ({
11
11
  customProperties = [],
12
12
  customPropertiesEndpoint,
13
13
  id,
14
- labelOverrides
14
+ labelOverrides = {}
15
15
  }) => {
16
16
  // Deal with all the possible label override options
17
17
  const getAccordionLabel = () => {
@@ -51,8 +51,7 @@ const CustomPropertiesViewCtx = ({
51
51
  { path: 'retired' }, // Place retired custprops at the end
52
52
  { path: 'primary', direction: 'desc' }, // Primary properties should display before optional
53
53
  { path: 'weight' }, // Within those groups, sort by weight
54
- { path: 'label' } // For those with the same weight, sort by label
55
-
54
+ { path: 'label' } //For those with the same weight, sort by label
56
55
  ]
57
56
  }
58
57
  });
@@ -19,7 +19,7 @@ const CustomPropertyCard = ({
19
19
  customProperty,
20
20
  customPropertyDefinition = {},
21
21
  index,
22
- labelOverrides
22
+ labelOverrides = {}
23
23
  }) => {
24
24
  // We only need to display primary and set properties
25
25
  const toDisplay = !!(customPropertyDefinition.primary || customProperty);
@@ -0,0 +1,43 @@
1
+ import { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import classnames from 'classnames';
5
+
6
+ import { IconButton } from '@folio/stripes/components';
7
+ import css from '../../../styles/CycleButton.css';
8
+
9
+ const CycleButton = ({
10
+ buttons,
11
+ startIndex = 0
12
+ }) => {
13
+ const [index, setIndex] = useState(startIndex);
14
+
15
+ const { className, onClick, ...buttonProps } = buttons[index];
16
+
17
+ return (
18
+ <IconButton
19
+ {...buttonProps}
20
+ className={classnames(
21
+ className,
22
+ css.buttonStyle,
23
+ )}
24
+ onClick={(e) => {
25
+ if (onClick) {
26
+ onClick(e);
27
+ }
28
+
29
+ setIndex(index !== (buttons?.length -1) ? index + 1 : 0);
30
+ }}
31
+ />
32
+ );
33
+ };
34
+
35
+ CycleButton.propTypes = {
36
+ buttons: PropTypes.arrayOf(PropTypes.shape({
37
+ className: PropTypes.object,
38
+ icon: PropTypes.string.isRequired,
39
+ onClick: PropTypes.func.isRequired,
40
+ }))
41
+ };
42
+
43
+ export default CycleButton;
@@ -0,0 +1,28 @@
1
+ # CycleButton
2
+ A component designed to render an icon button which cycles through a list of available icons, styles and actions.
3
+
4
+ ## Basic Usage
5
+ ```
6
+ import { CycleButton } from '@k-int/stripes-kint-components'
7
+
8
+ <CycleButton
9
+ buttons={[
10
+ {
11
+ icon: "comment",
12
+ onClick: () => console.log("CLICKED BUTTON"),
13
+ },
14
+ {
15
+ icon: "trash",
16
+ onClick: () => console.log("CLICKED OTHER BUTTON"),
17
+ }
18
+ ]}
19
+ />
20
+ ```
21
+
22
+
23
+ ## Props
24
+
25
+ Name | Type | Description | default | required
26
+ --- | --- | --- | --- | ---
27
+ buttons | array\<Object> | An array of objects corresponding to states in the cycle of the action button. Object of the form `{icon: "trash", onClick: () => alert("Clicked trash icon"), ...rest }`, where `icon` and `onClick` are mandatory props and all other props are directly passed through to the underlying `IconButton`. On clicking the icon button, the `onClick` call will fire before the button is moved onto the next state. | | ✓ |
28
+ startIndex | integer | The starting index in the array for the cycle. | 0 | ✕ |
@@ -0,0 +1 @@
1
+ export { default } from './CycleButton';