@k-int/stripes-kint-components 2.2.0 → 2.3.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 (109) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/es/index.js +124 -4
  3. package/es/lib/ActionList/ActionList.js +7 -2
  4. package/es/lib/ActionList/ActionListFieldArray.js +49 -10
  5. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +2 -2
  6. package/es/lib/CustomProperties/Config/{CustomPropertiesView.js → CustomPropertyView.js} +5 -5
  7. package/es/lib/CustomProperties/Config/index.js +6 -4
  8. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +72 -0
  9. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +133 -0
  10. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +279 -0
  11. package/es/lib/CustomProperties/Edit/CustomPropertyField.js +370 -0
  12. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +156 -0
  13. package/es/lib/CustomProperties/Edit/index.js +51 -0
  14. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +216 -0
  15. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +236 -0
  16. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +159 -0
  17. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +119 -0
  18. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +173 -0
  19. package/es/lib/CustomProperties/Filter/index.js +59 -0
  20. package/es/lib/CustomProperties/Filter/useOperators.js +138 -0
  21. package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +97 -0
  22. package/es/lib/CustomProperties/Filter/useValueProps.js +101 -0
  23. package/es/lib/CustomProperties/View/CustomPropertiesView.js +73 -0
  24. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +187 -0
  25. package/es/lib/CustomProperties/View/CustomPropertyCard.js +204 -0
  26. package/es/lib/CustomProperties/View/index.js +35 -0
  27. package/es/lib/CustomProperties/index.js +125 -0
  28. package/es/lib/EditableRefdataList/EditableRefdataList.js +12 -16
  29. package/es/lib/FormModal/FormModal.js +18 -4
  30. package/es/lib/QueryTypedown/QueryTypedown.js +9 -4
  31. package/es/lib/constants/customProperties.js +4 -1
  32. package/es/lib/hooks/index.js +16 -0
  33. package/es/lib/hooks/typedownHooks/useTypedownData.js +9 -2
  34. package/es/lib/hooks/useAvailableCustomProperties.js +106 -0
  35. package/es/lib/hooks/useInvalidateRefdata.js +53 -0
  36. package/es/lib/hooks/useMutateRefdataValue.js +11 -6
  37. package/es/lib/hooks/useRefdata.js +1 -3
  38. package/es/lib/utils/groupCustomPropertiesByCtx.js +69 -0
  39. package/es/lib/utils/index.js +24 -0
  40. package/es/lib/utils/refdataQueryKey.js +48 -0
  41. package/es/lib/utils/typedownQueryKey.js +48 -0
  42. package/es/lib/utils/validators.js +60 -1
  43. package/git_translate.sh +8 -0
  44. package/package.json +1 -1
  45. package/src/index.js +27 -3
  46. package/src/lib/ActionList/ActionList.js +5 -2
  47. package/src/lib/ActionList/ActionListFieldArray.js +31 -8
  48. package/src/lib/ActionList/README.md +23 -20
  49. package/src/lib/CustomProperties/Config/CustomPropertiesSettings.js +2 -2
  50. package/src/lib/CustomProperties/Config/{CustomPropertiesView.js → CustomPropertyView.js} +3 -3
  51. package/src/lib/CustomProperties/Config/index.js +1 -1
  52. package/src/lib/CustomProperties/Edit/CustomPropertiesEdit.js +35 -0
  53. package/src/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +85 -0
  54. package/src/lib/CustomProperties/Edit/CustomPropertiesListField.js +194 -0
  55. package/src/lib/CustomProperties/Edit/CustomPropertyField.js +299 -0
  56. package/src/lib/CustomProperties/Edit/CustomPropertyFormCard.js +131 -0
  57. package/src/lib/CustomProperties/Edit/index.js +5 -0
  58. package/src/lib/CustomProperties/Filter/CustomPropertiesFilter.js +125 -0
  59. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +148 -0
  60. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +113 -0
  61. package/src/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +74 -0
  62. package/src/lib/CustomProperties/Filter/CustomPropertiesRule.js +122 -0
  63. package/src/lib/CustomProperties/Filter/index.js +6 -0
  64. package/src/lib/CustomProperties/Filter/useOperators.js +55 -0
  65. package/src/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +35 -0
  66. package/src/lib/CustomProperties/Filter/useValueProps.js +45 -0
  67. package/src/lib/CustomProperties/View/CustomPropertiesView.js +36 -0
  68. package/src/lib/CustomProperties/View/CustomPropertiesViewCtx.js +112 -0
  69. package/src/lib/CustomProperties/View/CustomPropertyCard.js +177 -0
  70. package/src/lib/CustomProperties/View/index.js +3 -0
  71. package/src/lib/CustomProperties/index.js +30 -0
  72. package/src/lib/EditableRefdataList/EditableRefdataList.js +13 -10
  73. package/src/lib/FormModal/FormModal.js +37 -17
  74. package/src/lib/QueryTypedown/QueryTypedown.js +3 -1
  75. package/src/lib/constants/customProperties.js +1 -0
  76. package/src/lib/hooks/index.js +2 -0
  77. package/src/lib/hooks/typedownHooks/useTypedownData.js +9 -3
  78. package/src/lib/hooks/useAvailableCustomProperties.js +40 -0
  79. package/src/lib/hooks/useInvalidateRefdata.js +11 -0
  80. package/src/lib/hooks/useMutateRefdataValue.js +7 -3
  81. package/src/lib/hooks/useRefdata.js +2 -3
  82. package/src/lib/utils/groupCustomPropertiesByCtx.js +13 -0
  83. package/src/lib/utils/index.js +5 -0
  84. package/src/lib/utils/refdataQueryKey.js +9 -0
  85. package/src/lib/utils/typedownQueryKey.js +9 -0
  86. package/src/lib/utils/validators.js +40 -0
  87. package/translate.sh +63 -0
  88. package/translations/stripes-kint-components/ar.json +105 -0
  89. package/translations/stripes-kint-components/ca.json +1 -0
  90. package/translations/stripes-kint-components/cs_CZ.json +105 -0
  91. package/translations/stripes-kint-components/da.json +1 -0
  92. package/translations/stripes-kint-components/de.json +105 -0
  93. package/translations/stripes-kint-components/en.json +54 -2
  94. package/translations/stripes-kint-components/es.json +105 -0
  95. package/translations/stripes-kint-components/fr.json +105 -0
  96. package/translations/stripes-kint-components/he.json +1 -0
  97. package/translations/stripes-kint-components/hi_IN.json +105 -0
  98. package/translations/stripes-kint-components/hu.json +105 -0
  99. package/translations/stripes-kint-components/it_IT.json +105 -0
  100. package/translations/stripes-kint-components/ja.json +105 -0
  101. package/translations/stripes-kint-components/ko.json +105 -0
  102. package/translations/stripes-kint-components/nb.json +1 -0
  103. package/translations/stripes-kint-components/nn.json +1 -0
  104. package/translations/stripes-kint-components/pl.json +105 -0
  105. package/translations/stripes-kint-components/pt_PT.json +105 -0
  106. package/translations/stripes-kint-components/ru.json +105 -0
  107. package/translations/stripes-kint-components/sv.json +105 -0
  108. package/translations/stripes-kint-components/ur.json +1 -0
  109. package/translations/stripes-kint-components/zh_CN.json +105 -0
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ (function () {
9
+ var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
10
+ enterModule && enterModule(module);
11
+ })();
12
+
13
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
14
+
15
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
+
17
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
+
19
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
20
+
21
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
22
+
23
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
24
+
25
+ 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; }
26
+
27
+ 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; }
28
+
29
+ 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; }
30
+
31
+ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
32
+ return a;
33
+ };
34
+
35
+ var groupCustomPropertiesByCtx = function groupCustomPropertiesByCtx(customProperties) {
36
+ return customProperties.reduce(function (acc, curr) {
37
+ var _curr$ctx, _acc$ctx;
38
+
39
+ var ctx = (_curr$ctx = curr.ctx) !== null && _curr$ctx !== void 0 ? _curr$ctx : 'isNull';
40
+
41
+ var returnObj = _objectSpread({}, acc);
42
+
43
+ returnObj[ctx] = [].concat(_toConsumableArray((_acc$ctx = acc === null || acc === void 0 ? void 0 : acc[ctx]) !== null && _acc$ctx !== void 0 ? _acc$ctx : []), [curr]);
44
+ return returnObj;
45
+ }, {});
46
+ };
47
+
48
+ var _default = groupCustomPropertiesByCtx;
49
+ var _default2 = _default;
50
+ exports.default = _default2;
51
+ ;
52
+
53
+ (function () {
54
+ var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
55
+
56
+ if (!reactHotLoader) {
57
+ return;
58
+ }
59
+
60
+ reactHotLoader.register(groupCustomPropertiesByCtx, "groupCustomPropertiesByCtx", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/groupCustomPropertiesByCtx.js");
61
+ reactHotLoader.register(_default, "default", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/groupCustomPropertiesByCtx.js");
62
+ })();
63
+
64
+ ;
65
+
66
+ (function () {
67
+ var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
68
+ leaveModule && leaveModule(module);
69
+ })();
@@ -21,12 +21,24 @@ Object.defineProperty(exports, "generateKiwtQueryParams", {
21
21
  return _generateKiwtQueryParams.default;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "groupCustomPropertiesByCtx", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _groupCustomPropertiesByCtx.default;
28
+ }
29
+ });
24
30
  Object.defineProperty(exports, "refdataOptions", {
25
31
  enumerable: true,
26
32
  get: function get() {
27
33
  return _refdataOptions.default;
28
34
  }
29
35
  });
36
+ Object.defineProperty(exports, "refdataQueryKey", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _refdataQueryKey.default;
40
+ }
41
+ });
30
42
  Object.defineProperty(exports, "renderHelpText", {
31
43
  enumerable: true,
32
44
  get: function get() {
@@ -51,6 +63,12 @@ Object.defineProperty(exports, "toCamelCase", {
51
63
  return _toCamelCase.default;
52
64
  }
53
65
  });
66
+ Object.defineProperty(exports, "typedownQueryKey", {
67
+ enumerable: true,
68
+ get: function get() {
69
+ return _typedownQueryKey.default;
70
+ }
71
+ });
54
72
 
55
73
  var _generateKiwtQuery = _interopRequireDefault(require("./generateKiwtQuery"));
56
74
 
@@ -62,6 +80,12 @@ var _buildUrl = _interopRequireDefault(require("./buildUrl"));
62
80
 
63
81
  var _refdataOptions = _interopRequireDefault(require("./refdataOptions"));
64
82
 
83
+ var _refdataQueryKey = _interopRequireDefault(require("./refdataQueryKey"));
84
+
85
+ var _typedownQueryKey = _interopRequireDefault(require("./typedownQueryKey"));
86
+
87
+ var _groupCustomPropertiesByCtx = _interopRequireDefault(require("./groupCustomPropertiesByCtx"));
88
+
65
89
  var _renderHelpText = _interopRequireDefault(require("./renderHelpText"));
66
90
 
67
91
  var _sortByLabel = _interopRequireDefault(require("./sortByLabel"));
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ (function () {
9
+ var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
10
+ enterModule && enterModule(module);
11
+ })();
12
+
13
+ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
14
+ return a;
15
+ };
16
+
17
+ var refdataQueryKey = function refdataQueryKey(desc) {
18
+ var keyArray = ['stripes-kint-components', 'refdata'];
19
+
20
+ if (desc) {
21
+ keyArray.push(desc);
22
+ }
23
+
24
+ return keyArray;
25
+ };
26
+
27
+ var _default = refdataQueryKey;
28
+ var _default2 = _default;
29
+ exports.default = _default2;
30
+ ;
31
+
32
+ (function () {
33
+ var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
34
+
35
+ if (!reactHotLoader) {
36
+ return;
37
+ }
38
+
39
+ reactHotLoader.register(refdataQueryKey, "refdataQueryKey", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/refdataQueryKey.js");
40
+ reactHotLoader.register(_default, "default", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/refdataQueryKey.js");
41
+ })();
42
+
43
+ ;
44
+
45
+ (function () {
46
+ var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
47
+ leaveModule && leaveModule(module);
48
+ })();
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ (function () {
9
+ var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
10
+ enterModule && enterModule(module);
11
+ })();
12
+
13
+ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
14
+ return a;
15
+ };
16
+
17
+ var typedownQueryKey = function typedownQueryKey(path) {
18
+ var keyArray = ['stripes-kint-components', 'typedown'];
19
+
20
+ if (path) {
21
+ keyArray.push(path);
22
+ }
23
+
24
+ return keyArray;
25
+ };
26
+
27
+ var _default = typedownQueryKey;
28
+ var _default2 = _default;
29
+ exports.default = _default2;
30
+ ;
31
+
32
+ (function () {
33
+ var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
34
+
35
+ if (!reactHotLoader) {
36
+ return;
37
+ }
38
+
39
+ reactHotLoader.register(typedownQueryKey, "typedownQueryKey", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/typedownQueryKey.js");
40
+ reactHotLoader.register(_default, "default", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/typedownQueryKey.js");
41
+ })();
42
+
43
+ ;
44
+
45
+ (function () {
46
+ var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
47
+ leaveModule && leaveModule(module);
48
+ })();
@@ -1,16 +1,24 @@
1
1
  "use strict";
2
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
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
- exports.requiredObject = exports.required = exports.invalidNumber = exports.composeValidators = void 0;
8
+ exports.requiredObject = exports.required = exports.invalidNumber = exports.customPropertyValidator = exports.composeValidators = void 0;
7
9
 
8
10
  var _reactIntl = require("react-intl");
9
11
 
12
+ var CUSTOM_PROPERTY_TYPES = _interopRequireWildcard(require("../constants/customProperties"));
13
+
10
14
  var _jsxRuntime = require("react/jsx-runtime");
11
15
 
12
16
  var _excluded = ["_delete"];
13
17
 
18
+ 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); }
19
+
20
+ 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; }
21
+
14
22
  (function () {
15
23
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
16
24
  enterModule && enterModule(module);
@@ -65,6 +73,56 @@ var requiredObject = function requiredObject() {
65
73
 
66
74
  exports.requiredObject = requiredObject;
67
75
 
76
+ var customPropertyValidator = function customPropertyValidator(fieldValue, allValues, customProperty) {
77
+ var _allValues$customProp, _allValues$customProp2, _allValues$customProp3;
78
+
79
+ var _ref = (_allValues$customProp = allValues === null || allValues === void 0 ? void 0 : (_allValues$customProp2 = allValues.customProperties) === null || _allValues$customProp2 === void 0 ? void 0 : (_allValues$customProp3 = _allValues$customProp2[customProperty === null || customProperty === void 0 ? void 0 : customProperty.value]) === null || _allValues$customProp3 === void 0 ? void 0 : _allValues$customProp3[0]) !== null && _allValues$customProp !== void 0 ? _allValues$customProp : {},
80
+ note = _ref.note,
81
+ publicNote = _ref.publicNote,
82
+ currentValue = _ref.value;
83
+
84
+ if (note && !currentValue || publicNote && !currentValue) {
85
+ if (customProperty.type === CUSTOM_PROPERTY_TYPES.DECIMAL_CLASS_NAME || customProperty.type === CUSTOM_PROPERTY_TYPES.INTEGER_CLASS_NAME) {
86
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
87
+ id: "stripes-kint-components.errors.customPropertyNoteInvalidNumber"
88
+ });
89
+ } else {
90
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
91
+ id: "stripes-kint-components.errors.customPropertyNoteWithoutValue"
92
+ });
93
+ }
94
+ }
95
+
96
+ if (customProperty.type === CUSTOM_PROPERTY_TYPES.DECIMAL_CLASS_NAME) {
97
+ var regexp = /^-?[\d]*(\.[\d]{0,2})?$/;
98
+ return fieldValue && !regexp.test(fieldValue) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
99
+ id: "stripes-kint-components.errors.customPropertyMaxTwoDecimals"
100
+ }) : undefined;
101
+ }
102
+
103
+ if (customProperty.type === CUSTOM_PROPERTY_TYPES.INTEGER_CLASS_NAME) {
104
+ var min = Number.MIN_SAFE_INTEGER;
105
+ var max = Number.MAX_SAFE_INTEGER;
106
+ return fieldValue && !Number.isInteger(+fieldValue) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
107
+ id: "stripes-kint-components.errors.customPropertyValueNotInRange",
108
+ values: {
109
+ min: min,
110
+ max: max
111
+ }
112
+ }) : undefined;
113
+ }
114
+
115
+ if (!customProperty.primary && !currentValue) {
116
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactIntl.FormattedMessage, {
117
+ id: "stripes-core.label.missingRequiredField"
118
+ });
119
+ }
120
+
121
+ return undefined;
122
+ };
123
+
124
+ exports.customPropertyValidator = customPropertyValidator;
125
+
68
126
  var composeValidators = function composeValidators() {
69
127
  for (var _len = arguments.length, validators = new Array(_len), _key = 0; _key < _len; _key++) {
70
128
  validators[_key] = arguments[_key];
@@ -90,6 +148,7 @@ exports.composeValidators = composeValidators;
90
148
  reactHotLoader.register(invalidNumber, "invalidNumber", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/validators.js");
91
149
  reactHotLoader.register(required, "required", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/validators.js");
92
150
  reactHotLoader.register(requiredObject, "requiredObject", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/validators.js");
151
+ reactHotLoader.register(customPropertyValidator, "customPropertyValidator", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/validators.js");
93
152
  reactHotLoader.register(composeValidators, "composeValidators", "/home/ethan/FolioModules/stripes-kint-components/src/lib/utils/validators.js");
94
153
  })();
95
154
 
@@ -0,0 +1,8 @@
1
+ git stash
2
+
3
+ ./translate.sh
4
+
5
+ git add ./translations
6
+ git commit -m "chore: translations"
7
+ git push
8
+ git stash pop
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-int/stripes-kint-components",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Stripes Component library for K-Int specific applications",
5
5
  "sideEffects": [
6
6
  "*.css"
package/src/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  // Useful hooks
2
2
  export {
3
3
  useActiveElement,
4
+ useAvailableCustomProperties,
4
5
  useCustomProperties,
5
6
  useHelperApp,
7
+ useInvalidateRefdata,
6
8
  useKiwtFieldArray,
7
9
  useKiwtSASQuery,
8
10
  useLocalStorageState,
@@ -18,8 +20,11 @@ export {
18
20
  export {
19
21
  generateKiwtQuery,
20
22
  generateKiwtQueryParams,
23
+ groupCustomPropertiesByCtx,
21
24
  refdataOptions,
22
- selectorSafe
25
+ refdataQueryKey,
26
+ selectorSafe,
27
+ typedownQueryKey,
23
28
  } from './lib/utils';
24
29
 
25
30
  // Validators (Some/all copied from stripes-erm-components but this gives another way to acquire them)
@@ -85,9 +90,28 @@ export { default as FormModal } from './lib/FormModal';
85
90
 
86
91
  // Custom properties
87
92
  export {
93
+ // Config
88
94
  CustomPropertiesLookup,
89
95
  CustomPropertiesSettings,
90
- CustomPropertiesView
91
- } from './lib/CustomProperties/Config';
96
+ CustomPropertyView,
97
+ CustomPropertyForm,
98
+ // Edit
99
+ CustomPropertiesEdit,
100
+ CustomPropertiesEditCtx,
101
+ CustomPropertiesListField,
102
+ CustomPropertyFormCard,
103
+ CustomPropertyField,
104
+ // View
105
+ CustomPropertiesView,
106
+ CustomPropertiesViewCtx,
107
+ CustomPropertyCard,
108
+ // Filter
109
+ CustomPropertiesFilter,
110
+ CustomPropertiesFilterForm,
111
+ CustomPropertiesFilterField,
112
+ CustomPropertiesFilterFieldArray,
113
+ useOperators,
114
+ useParseActiveFilterStrings
115
+ } from './lib/CustomProperties';
92
116
 
93
117
  export * as customPropertyContants from './lib/constants/customProperties';
@@ -13,6 +13,7 @@ const propTypes = {
13
13
  columnMapping: PropTypes.object,
14
14
  contentData: PropTypes.arrayOf(PropTypes.object),
15
15
  creatableFields: PropTypes.object,
16
+ createCallback: PropTypes.func,
16
17
  editableFields: PropTypes.object,
17
18
  fieldComponents: PropTypes.object,
18
19
  hideCreateButton: PropTypes.bool,
@@ -21,10 +22,11 @@ const propTypes = {
21
22
 
22
23
  const ActionList = ({
23
24
  actionAssigner,
24
- actionCalls = {},
25
+ actionCalls = {}, // DEPRECATED
25
26
  columnMapping,
26
27
  contentData,
27
28
  creatableFields = {},
29
+ createCallback,
28
30
  editableFields = {},
29
31
  fieldComponents = {},
30
32
  hideCreateButton,
@@ -37,7 +39,7 @@ const ActionList = ({
37
39
  enableReinitialize
38
40
  initialValues={{ contentData }}
39
41
  mutators={arrayMutators}
40
- onSubmit={actionCalls.edit}
42
+ onSubmit={() => null}
41
43
  subscription={{ contentData: true }}
42
44
  >
43
45
  {() => (
@@ -48,6 +50,7 @@ const ActionList = ({
48
50
  columnMapping={columnMapping}
49
51
  component={ActionListFieldArray}
50
52
  creatableFields={creatableFields}
53
+ createCallback={createCallback}
51
54
  editableFields={editableFields}
52
55
  fieldComponents={fieldComponents}
53
56
  hideCreateButton={hideCreateButton}
@@ -16,6 +16,7 @@ const propTypes = {
16
16
  actionCalls: PropTypes.object,
17
17
  columnMapping: PropTypes.object,
18
18
  creatableFields: PropTypes.object,
19
+ createCallback: PropTypes.func,
19
20
  editableFields: PropTypes.object,
20
21
  fields: PropTypes.object,
21
22
  fieldComponents: PropTypes.object,
@@ -26,9 +27,10 @@ const propTypes = {
26
27
 
27
28
  const ActionListFieldArray = ({
28
29
  actionAssigner,
29
- actionCalls,
30
+ actionCalls, // DEPRECATED
30
31
  columnMapping,
31
32
  creatableFields,
33
+ createCallback,
32
34
  editableFields,
33
35
  fields,
34
36
  fieldComponents,
@@ -55,15 +57,26 @@ const ActionListFieldArray = ({
55
57
  }
56
58
  };
57
59
 
58
-
59
60
  const handleSave = (index) => {
60
61
  const { actionListActions: _a, ...rowData } = fields.value[index];
61
- actionCalls.edit(rowData);
62
+
63
+ // Find "edit" entry in actionAssigner
64
+ const editCallback = actionAssigner.find(act => act.name === 'edit')?.callback;
65
+ if (editCallback) {
66
+ editCallback(rowData);
67
+ } else {
68
+ actionCalls.edit(rowData); // DEPRECATED
69
+ }
62
70
  };
63
71
 
64
72
  const handleCreate = (index) => {
65
73
  const { actionListActions: _a, ...rowData } = fields.value[index];
66
- actionCalls.create(rowData);
74
+
75
+ if (createCallback) {
76
+ createCallback(rowData);
77
+ } else {
78
+ actionCalls.create(rowData); // DEPRECATED
79
+ }
67
80
  };
68
81
 
69
82
  const getColumnWidths = () => {
@@ -133,7 +146,15 @@ const ActionListFieldArray = ({
133
146
  return (
134
147
  <div>
135
148
  {actions?.map(action => {
136
- let actionFunction = () => actionCalls[action.name](rest);
149
+ let actionFunction;
150
+ if (action.callback) {
151
+ actionFunction = () => action.callback(rest);
152
+ }
153
+
154
+ if (!actionFunction && actionCalls[action.name]) {
155
+ actionFunction = () => actionCalls[action.name](rest); // DEPRECATED
156
+ }
157
+
137
158
  // Edit has special action functionality, revealing fields etc.
138
159
  if (action.name === 'edit') {
139
160
  actionFunction = () => toggleEditing(data.id);
@@ -147,7 +168,8 @@ const ActionListFieldArray = ({
147
168
  disabled={editing}
148
169
  icon={action.icon}
149
170
  marginBottom0
150
- onClick={actionFunction}
171
+ onClick={() => (actionFunction ? actionFunction() : () => null)}
172
+ to={action.to}
151
173
  />
152
174
  );
153
175
  }
@@ -158,7 +180,8 @@ const ActionListFieldArray = ({
158
180
  key={`action-${action.name}[${data.rowIndex}]`}
159
181
  disabled={editing}
160
182
  marginBottom0
161
- onClick={actionFunction}
183
+ onClick={() => (actionFunction ? actionFunction() : () => null)}
184
+ to={action.to}
162
185
  >
163
186
  {action.label ?? action.name}
164
187
  </Button>
@@ -247,7 +270,7 @@ const ActionListFieldArray = ({
247
270
  {!hideCreateButton &&
248
271
  <Button
249
272
  buttonClass={css.buttonRight}
250
- disabled={!actionCalls.create}
273
+ disabled={(!actionCalls.create && !createCallback)} // DEPRECATED actionCalls
251
274
  onClick={() => {
252
275
  toggleEditing('NEW_ROW');
253
276
  fields.push({});
@@ -23,32 +23,34 @@ const [contentData, setContentData] = useState({
23
23
 
24
24
  const actionAssigner = () => {
25
25
  return [
26
- { name: 'edit' },
27
- { name: 'delete' }
26
+ {
27
+ name: 'edit',
28
+ callback: (data) => setContentData({
29
+ ...contentData,
30
+ data
31
+ )}
32
+ },
33
+ {
34
+ name: 'delete',
35
+ callback: (data) => {
36
+ setContentData(contentData.filter(cd => cd.id !== data.id))
37
+ }
38
+ }
28
39
  ];
29
40
  };
30
41
 
31
- const actionCalls = {
32
- create: (data) => setContentData({
33
- ...contentData,
34
- {
35
- id: generateUUID(),
36
- ...data
37
- }
38
- }),
39
- edit: (data) => setContentData({
40
- ...contentData,
41
- data
42
- ),
43
- delete: (data) => {
44
- setContentData(contentData.filter(cd => cd.id !== data.id))
42
+ createCallback = (data) => setContentData({
43
+ ...contentData,
44
+ {
45
+ id: generateUUID(),
46
+ ...data
45
47
  }
46
- };
48
+ });
47
49
 
48
50
  <ActionList
49
51
  actionAssigner={actionAssigner}
50
- actionCalls={actionCalls}
51
52
  contentData={contentData}
53
+ createCallback={createCallback}
52
54
  visibleFields={['name', 'occupation']}
53
55
  />
54
56
  ```
@@ -57,11 +59,12 @@ const actionCalls = {
57
59
 
58
60
  Name | Type | Description | default | required
59
61
  --- | --- | --- | --- | ---
60
- 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' }`. The prop `name` is required, but `label` and `icon` are optional props. | | ✓ |
61
- actionCalls | 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. | {} | ✕ |
62
+ 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 }`. The prop `name` is required, but `label` and `icon` are optional props. The `callback` prop will be prioritised ahead of the deprecated actionCalls prop. If a `to` prop is passed, then the resulting button will be rendered as a <Link/> element, as per Stripes Button/IconButton.| | ✓ |
63
+ 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. | {} | ✕ |
62
64
  columnMapping | object | An object which will act on the rendered MultiColumnList headers to map the labels for each `visibleField` | | ✕ |
63
65
  contentData | array | An array of objects to render along with their actions | | ✓ |
64
66
  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. | | ✕ |
67
+ 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. | {} | ✕ |
65
68
  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
69
  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
70
  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. | | ✕ |
@@ -14,7 +14,7 @@ import { Button, ConfirmationModal, Pane } from '@folio/stripes/components';
14
14
  import FormModal from '../../FormModal/FormModal';
15
15
 
16
16
  import CustomPropertiesLookup from './CustomPropertiesLookup';
17
- import CustomPropertiesView from './CustomPropertiesView';
17
+ import CustomPropertyView from './CustomPropertyView';
18
18
  import CustomPropertiesForm from './CustomPropertyForm';
19
19
  import { useMutateCustomProperties, useRefdata } from '../../hooks';
20
20
 
@@ -160,7 +160,7 @@ const CustomPropertiesSettings = ({
160
160
  renderViewPaneTitle ?? customProperty?.label ?? customProperty?.name
161
161
  }
162
162
  >
163
- <CustomPropertiesView
163
+ <CustomPropertyView
164
164
  customProperty={customProperty}
165
165
  labelOverrides={labelOverrides}
166
166
  />
@@ -5,7 +5,7 @@ import { Col, KeyValue, NoValue, Row } from '@folio/stripes/components';
5
5
  import { REFDATA_CLASS_NAME } from '../../constants/customProperties';
6
6
 
7
7
  // A default option for CustProp view pane, with the ability to override labels for fields
8
- const CustomPropertiesView = ({
8
+ const CustomPropertyView = ({
9
9
  customProperty,
10
10
  labelOverrides
11
11
  }) => {
@@ -149,7 +149,7 @@ const CustomPropertiesView = ({
149
149
  );
150
150
  };
151
151
 
152
- CustomPropertiesView.propTypes = {
152
+ CustomPropertyView.propTypes = {
153
153
  customProperty: PropTypes.shape({
154
154
  id: PropTypes.string,
155
155
  label: PropTypes.string,
@@ -169,4 +169,4 @@ CustomPropertiesView.propTypes = {
169
169
  labelOverrides: PropTypes.object
170
170
  };
171
171
 
172
- export default CustomPropertiesView;
172
+ export default CustomPropertyView;
@@ -1,4 +1,4 @@
1
1
  export { default as CustomPropertiesLookup } from './CustomPropertiesLookup';
2
- export { default as CustomPropertiesView } from './CustomPropertiesLookup';
2
+ export { default as CustomPropertyView } from './CustomPropertyView';
3
3
  export { default as CustomPropertiesSettings } from './CustomPropertiesSettings';
4
4
  export { default as CustomPropertyForm } from './CustomPropertyForm';
@@ -0,0 +1,35 @@
1
+ import PropTypes from 'prop-types';
2
+ import CustomPropertiesEditCtx from './CustomPropertiesEditCtx';
3
+
4
+ const CustomPropertiesEdit = ({
5
+ contexts = [],
6
+ customPropertiesEndpoint,
7
+ id,
8
+ labelOverrides = {},
9
+ nameOverride
10
+ }) => {
11
+ return (
12
+ contexts.map(ctx => (
13
+ <CustomPropertiesEditCtx
14
+ key={`customPropertiesEdit-${ctx}`}
15
+ {...{
16
+ ctx,
17
+ customPropertiesEndpoint,
18
+ id,
19
+ labelOverrides,
20
+ nameOverride
21
+ }}
22
+ />
23
+ ))
24
+ );
25
+ };
26
+
27
+ CustomPropertiesEdit.propTypes = {
28
+ contexts: PropTypes.arrayOf(PropTypes.string),
29
+ customPropertiesEndpoint: PropTypes.string,
30
+ id: PropTypes.string,
31
+ labelOverrides: PropTypes.object,
32
+ nameOverride: PropTypes.string
33
+ };
34
+
35
+ export default CustomPropertiesEdit;