@k-int/stripes-kint-components 5.6.0 → 5.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 (86) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/es/lib/ActionList/ActionListFieldArray.js +32 -37
  3. package/es/lib/ComboButton/ComboButton.js +5 -6
  4. package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +4 -7
  5. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +29 -32
  6. package/es/lib/CustomProperties/Config/CustomPropertyForm.js +58 -58
  7. package/es/lib/CustomProperties/Config/CustomPropertyForm.test.js +2 -2
  8. package/es/lib/CustomProperties/Config/CustomPropertyView.js +32 -33
  9. package/es/lib/CustomProperties/Config/CustomPropertyView.test.js +1 -1
  10. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +1 -1
  11. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +3 -3
  12. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +5 -10
  13. package/es/lib/CustomProperties/Edit/CustomPropertyField.js +18 -25
  14. package/es/lib/CustomProperties/Edit/CustomPropertyField.test.js +5 -5
  15. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +2 -2
  16. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.test.js +1 -1
  17. package/es/lib/CustomProperties/Edit/testResources.js +11 -12
  18. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +6 -11
  19. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +20 -28
  20. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.test.js +1 -1
  21. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +6 -6
  22. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +8 -8
  23. package/es/lib/CustomProperties/Filter/testResources.js +1 -2
  24. package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +1 -2
  25. package/es/lib/CustomProperties/View/CustomPropertiesView.js +1 -1
  26. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +18 -26
  27. package/es/lib/CustomProperties/View/CustomPropertyCard.js +7 -11
  28. package/es/lib/CycleButton/CycleButton.js +1 -1
  29. package/es/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +26 -38
  30. package/es/lib/EditableRefdataList/EditableRefdataList.js +26 -33
  31. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +1 -1
  32. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.js +5 -5
  33. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.js +10 -12
  34. package/es/lib/EditableSettingsList/SettingField/SettingField.js +4 -4
  35. package/es/lib/FormattedKintMessage/FormattedKintMessage.js +4 -7
  36. package/es/lib/IconSelect/IconSelect.js +5 -9
  37. package/es/lib/NoResultsMessage/NoResultsMessage.js +4 -4
  38. package/es/lib/RefdataButtons/RefdataButtons.js +3 -3
  39. package/es/lib/RefdataCategoriesSettings/RefdataCategoriesSettings.js +13 -17
  40. package/es/lib/ResponsiveButtonGroup/ResponsiveButtonGroup.js +21 -28
  41. package/es/lib/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js +5 -6
  42. package/es/lib/RichSelect/RichSelect.js +14 -19
  43. package/es/lib/RichSelect/useSelectedOption.js +1 -2
  44. package/es/lib/SASQLookupComponent/SASQLookupComponent.js +14 -17
  45. package/es/lib/SASQLookupComponent/TableBody/TableBody.js +6 -8
  46. package/es/lib/SASQRoute/SASQRoute.js +2 -2
  47. package/es/lib/SASQViewComponent/SASQViewComponent.js +5 -9
  48. package/es/lib/SettingPage/SettingPagePane.js +2 -2
  49. package/es/lib/SettingsFormContainer/SettingsFormContainer.js +2 -2
  50. package/es/lib/Typedown/Typedown.js +34 -32
  51. package/es/lib/hooks/typedownHooks/useTypedown.js +2 -2
  52. package/es/lib/hooks/typedownHooks/useTypedownToggle.js +2 -2
  53. package/es/lib/hooks/useActionListRef.js +1 -1
  54. package/es/lib/hooks/useActiveElement.js +1 -1
  55. package/es/lib/hooks/useCustomProperties.js +2 -2
  56. package/es/lib/hooks/useHelperApp.js +6 -6
  57. package/es/lib/hooks/useIntlKeyStore.js +4 -7
  58. package/es/lib/hooks/useKintIntl.js +5 -11
  59. package/es/lib/hooks/useKiwtSASQuery.js +1 -1
  60. package/es/lib/hooks/useModConfigEntries.js +2 -2
  61. package/es/lib/hooks/useMutateCustomProperties.js +8 -8
  62. package/es/lib/hooks/useMutateModConfigEntry.js +2 -2
  63. package/es/lib/hooks/useMutateRefdataCategory.js +4 -4
  64. package/es/lib/hooks/useMutateRefdataValue.js +6 -6
  65. package/es/lib/hooks/useQIndex.js +5 -5
  66. package/es/lib/hooks/useRefdata.js +3 -3
  67. package/es/lib/hooks/useTemplates.js +4 -4
  68. package/es/lib/settingsHooks/useAppSettings.js +7 -11
  69. package/es/lib/settingsHooks/useSettingSection.js +2 -2
  70. package/es/lib/settingsHooks/useSettings.js +3 -3
  71. package/es/lib/utils/buildUrl.js +2 -3
  72. package/es/lib/utils/filterParsers/deparseKiwtQueryFilters.js +5 -5
  73. package/es/lib/utils/filterParsers/parseKiwtQueryFilters.js +2 -2
  74. package/es/lib/utils/filterParsers/parseKiwtQueryGroups.js +4 -5
  75. package/es/lib/utils/filterParsers/parseKiwtQueryString.js +1 -1
  76. package/es/lib/utils/generateKiwtQueryParams.js +28 -37
  77. package/es/lib/utils/groupCustomPropertiesByCtx.js +2 -3
  78. package/es/lib/utils/matchString.js +5 -7
  79. package/es/lib/utils/parseErrorResponse.js +8 -4
  80. package/es/lib/utils/selectorSafe.js +2 -3
  81. package/es/lib/utils/sortByLabel.js +2 -3
  82. package/es/lib/validators/validators.js +3 -3
  83. package/package.json +3 -5
  84. package/src/lib/Typedown/Typedown.js +12 -5
  85. package/src/lib/utils/parseErrorResponse.js +4 -1
  86. package/styles/TypeDown.css +6 -1
@@ -14,10 +14,10 @@ const useQIndex = () => {
14
14
  const history = (0, _reactRouterDom.useHistory)();
15
15
  const location = (0, _reactRouterDom.useLocation)();
16
16
  const query = _queryString.default.parse(location.search);
17
- const [currentQindex, setCurrentQindex] = (0, _react.useState)(query === null || query === void 0 ? void 0 : query.qindex);
17
+ const [currentQindex, setCurrentQindex] = (0, _react.useState)(query?.qindex);
18
18
  const handleQindexChange = newQindex => {
19
19
  setCurrentQindex(newQindex);
20
- if (newQindex !== (query === null || query === void 0 ? void 0 : query.qindex)) {
20
+ if (newQindex !== query?.qindex) {
21
21
  let newQuery;
22
22
  if (newQindex !== '') {
23
23
  newQuery = {
@@ -32,13 +32,13 @@ const useQIndex = () => {
32
32
  }
33
33
  history.push({
34
34
  pathname: location.pathname,
35
- search: "?".concat(_queryString.default.stringify(newQuery))
35
+ search: `?${_queryString.default.stringify(newQuery)}`
36
36
  });
37
37
  }
38
38
  };
39
39
  (0, _react.useEffect)(() => {
40
- if (currentQindex !== (query === null || query === void 0 ? void 0 : query.qindex)) {
41
- setCurrentQindex(query === null || query === void 0 ? void 0 : query.qindex);
40
+ if (currentQindex !== query?.qindex) {
41
+ setCurrentQindex(query?.qindex);
42
42
  }
43
43
  }, [currentQindex, history, location, query]);
44
44
  return [currentQindex, handleQindexChange];
@@ -28,13 +28,13 @@ const useRefdata = _ref => {
28
28
 
29
29
  if (Array.isArray(desc)) {
30
30
  // If we have an array, append a desc filter for each desc given
31
- nsValues.filters = desc.map(d => "DescKey.".concat(d)).join(',');
31
+ nsValues.filters = desc.map(d => `DescKey.${d}`).join(',');
32
32
  } else if (desc) {
33
33
  // If we just have a string, append a single desc filter
34
- nsValues.filters = "DescKey.".concat(desc);
34
+ nsValues.filters = `DescKey.${desc}`;
35
35
  }
36
36
  const query = (0, _utils.generateKiwtQuery)(options, nsValues);
37
- const path = "".concat(endpoint).concat(query);
37
+ const path = `${endpoint}${query}`;
38
38
  const queryObject = (0, _reactQuery.useQuery)((0, _utils.refdataQueryKey)(desc), () => ky(path).json(), queryParams);
39
39
  if (returnQueryObject) {
40
40
  return queryObject || {};
@@ -18,16 +18,16 @@ const useTemplates = _ref => {
18
18
  const ky = (0, _core.useOkapiKy)();
19
19
  const extraPathItems = [];
20
20
  if (context) {
21
- extraPathItems.push("filters=context=".concat(context));
21
+ extraPathItems.push(`filters=context=${context}`);
22
22
  }
23
23
  if (sort) {
24
- extraPathItems.push("sort=".concat(sort));
24
+ extraPathItems.push(`sort=${sort}`);
25
25
  }
26
26
  extraPathItems.push('max=500');
27
- const path = "".concat(endpoint, "?").concat(extraPathItems.join('&'));
27
+ const path = `${endpoint}?${extraPathItems.join('&')}`;
28
28
  const {
29
29
  data: templates
30
- } = (0, _reactQuery.useQuery)(['stripes-kint-components', 'useTemplates', 'templates', context !== null && context !== void 0 ? context : ''], () => ky(path).json(), queryParams);
30
+ } = (0, _reactQuery.useQuery)(['stripes-kint-components', 'useTemplates', 'templates', context ?? ''], () => ky(path).json(), queryParams);
31
31
  return templates || [];
32
32
  };
33
33
  var _default = exports.default = useTemplates;
@@ -8,7 +8,6 @@ var _reactQuery = require("react-query");
8
8
  var _core = require("@folio/stripes/core");
9
9
  var _utils = require("../utils");
10
10
  const useAppSettings = _ref => {
11
- var _ref2, _ref3, _queryObject$data2;
12
11
  let {
13
12
  endpoint,
14
13
  keyName,
@@ -24,32 +23,29 @@ const useAppSettings = _ref => {
24
23
  };
25
24
  const namespaceArray = [endpoint];
26
25
  if (sectionName) {
27
- var _defaultQueryParamObj;
28
- defaultQueryParamObject.filters = [...((_defaultQueryParamObj = defaultQueryParamObject.filters) !== null && _defaultQueryParamObj !== void 0 ? _defaultQueryParamObj : []), {
26
+ defaultQueryParamObject.filters = [...(defaultQueryParamObject.filters ?? []), {
29
27
  path: 'section',
30
28
  value: sectionName
31
29
  }];
32
30
  namespaceArray.push(sectionName);
33
31
  }
34
32
  if (keyName) {
35
- var _defaultQueryParamObj2;
36
- defaultQueryParamObject.filters = [...((_defaultQueryParamObj2 = defaultQueryParamObject.filters) !== null && _defaultQueryParamObj2 !== void 0 ? _defaultQueryParamObj2 : []), {
33
+ defaultQueryParamObject.filters = [...(defaultQueryParamObject.filters ?? []), {
37
34
  path: 'key',
38
35
  value: keyName
39
36
  }];
40
37
  defaultQueryParamObject.perPage = 1;
41
38
  namespaceArray.push(keyName);
42
39
  }
43
- const queryParamArray = (0, _utils.generateKiwtQueryParams)(options !== null && options !== void 0 ? options : defaultQueryParamObject, {});
40
+ const queryParamArray = (0, _utils.generateKiwtQueryParams)(options ?? defaultQueryParamObject, {});
44
41
  namespaceArray.push(queryParamArray);
45
- const queryObject = (0, _reactQuery.useQuery)(namespaceArray, () => ky("".concat(endpoint, "?").concat(queryParamArray === null || queryParamArray === void 0 ? void 0 : queryParamArray.join('&'))).json(), queryParams);
42
+ const queryObject = (0, _reactQuery.useQuery)(namespaceArray, () => ky(`${endpoint}?${queryParamArray?.join('&')}`).json(), queryParams);
46
43
  if (returnQueryObject) {
47
44
  return queryObject;
48
45
  }
49
- if ((_ref2 = queryParams !== null && queryParams !== void 0 ? queryParams : defaultQueryParamObject) !== null && _ref2 !== void 0 && _ref2.perPage && ((_ref3 = queryParams !== null && queryParams !== void 0 ? queryParams : defaultQueryParamObject) === null || _ref3 === void 0 ? void 0 : _ref3.perPage) === 1) {
50
- var _queryObject$data$, _queryObject$data;
51
- return (_queryObject$data$ = queryObject === null || queryObject === void 0 || (_queryObject$data = queryObject.data) === null || _queryObject$data === void 0 ? void 0 : _queryObject$data[0]) !== null && _queryObject$data$ !== void 0 ? _queryObject$data$ : {};
46
+ if ((queryParams ?? defaultQueryParamObject)?.perPage && (queryParams ?? defaultQueryParamObject)?.perPage === 1) {
47
+ return queryObject?.data?.[0] ?? {};
52
48
  }
53
- return (_queryObject$data2 = queryObject === null || queryObject === void 0 ? void 0 : queryObject.data) !== null && _queryObject$data2 !== void 0 ? _queryObject$data2 : [];
49
+ return queryObject?.data ?? [];
54
50
  };
55
51
  var _default = exports.default = useAppSettings;
@@ -26,10 +26,10 @@ const useSettingSection = _ref => {
26
26
  }, {});
27
27
  const {
28
28
  data: settings = []
29
- } = (0, _reactQuery.useQuery)(['stripes-kint-components', 'useSetting', 'appSettings', queryParams, sectionName], () => ky("".concat(settingEndpoint, "?").concat(queryParams === null || queryParams === void 0 ? void 0 : queryParams.join('&'))).json());
29
+ } = (0, _reactQuery.useQuery)(['stripes-kint-components', 'useSetting', 'appSettings', queryParams, sectionName], () => ky(`${settingEndpoint}?${queryParams?.join('&')}`).json());
30
30
  const {
31
31
  mutateAsync: putSetting
32
- } = (0, _reactQuery.useMutation)(['stripes-kint-components', 'useSetting', 'putSetting', sectionName], data => ky.put("".concat(settingEndpoint).concat(data.id ? '/' + data.id : ''), {
32
+ } = (0, _reactQuery.useMutation)(['stripes-kint-components', 'useSetting', 'putSetting', sectionName], data => ky.put(`${settingEndpoint}${data.id ? '/' + data.id : ''}`, {
33
33
  json: data
34
34
  }));
35
35
  return {
@@ -30,7 +30,7 @@ const useSettings = _ref => {
30
30
  const ky = (0, _core.useOkapiKy)();
31
31
  const kintIntl = (0, _hooks.useKintIntl)(passedIntlKey, passedIntlNS);
32
32
  const queryParams = (0, _utils.generateKiwtQueryParams)({
33
- filters: dynamicPageExclusions === null || dynamicPageExclusions === void 0 ? void 0 : dynamicPageExclusions.map(dpe => ({
33
+ filters: dynamicPageExclusions?.map(dpe => ({
34
34
  path: 'section',
35
35
  comparator: '!=',
36
36
  value: dpe
@@ -41,13 +41,13 @@ const useSettings = _ref => {
41
41
  const {
42
42
  data: appSettings = [],
43
43
  isLoading
44
- } = (0, _reactQuery.useQuery)(['stripes-kint-components', 'useSettings', 'appSettings', settingEndpoint, queryParams], () => ky("".concat(settingEndpoint, "?").concat(queryParams === null || queryParams === void 0 ? void 0 : queryParams.join('&'))).json());
44
+ } = (0, _reactQuery.useQuery)(['stripes-kint-components', 'useSettings', 'appSettings', settingEndpoint, queryParams], () => ky(`${settingEndpoint}?${queryParams?.join('&')}`).json());
45
45
  const sections = [...new Set(appSettings.map(s => s.section))];
46
46
  const dynamic = sections.map(section => {
47
47
  return {
48
48
  route: section,
49
49
  label: kintIntl.formatKintMessage({
50
- id: "settings.settingsSection.".concat((0, _utils.toCamelCase)(section)),
50
+ id: `settings.settingsSection.${(0, _utils.toCamelCase)(section)}`,
51
51
  fallbackMessage: section
52
52
  }),
53
53
  component: props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_SettingPage.SettingPagePane, {
@@ -17,13 +17,12 @@ function removeEmpty(obj) {
17
17
  return cleanObj;
18
18
  }
19
19
  function buildUrl(location, values, basePath) {
20
- var _location$query;
21
- const locationQuery = (_location$query = location === null || location === void 0 ? void 0 : location.query) !== null && _location$query !== void 0 ? _location$query : _queryString.default.parse(location.search);
20
+ const locationQuery = location?.query ?? _queryString.default.parse(location.search);
22
21
  let url = values._path || basePath || location.pathname;
23
22
  const params = removeEmpty(Object.assign(locationQuery, values));
24
23
  (0, _lodash.unset)(params, '_path');
25
24
  if (!(0, _lodash.isEmpty)(params)) {
26
- url += "?".concat(_queryString.default.stringify(params));
25
+ url += `?${_queryString.default.stringify(params)}`;
27
26
  }
28
27
  return url;
29
28
  }
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.deparseKiwtQueryFiltersObject = exports.default = void 0;
7
7
  // Does not validate object... make sure you pass it the right thing
8
8
  const deparseKiwtQueryFiltersObject = queryObject => {
9
- let returnString = "".concat(queryObject.path).concat(queryObject.comparator);
9
+ let returnString = `${queryObject.path}${queryObject.comparator}`;
10
10
  if (queryObject.value) {
11
- returnString += "".concat(queryObject.value);
11
+ returnString += `${queryObject.value}`;
12
12
  }
13
13
  return returnString;
14
14
  };
@@ -20,17 +20,17 @@ const deparseKiwtQueryFilters = queryArray => {
20
20
  let returnString = '';
21
21
  queryArray.forEach(qa => {
22
22
  if (Array.isArray(qa)) {
23
- returnString += "(".concat(deparseKiwtQueryFilters(qa), ")");
23
+ returnString += `(${deparseKiwtQueryFilters(qa)})`;
24
24
  } else if (typeof qa === 'string') {
25
25
  returnString += qa;
26
26
  } else {
27
27
  // Assuming object at this stage
28
- returnString += "".concat(deparseKiwtQueryFiltersObject(qa));
28
+ returnString += `${deparseKiwtQueryFiltersObject(qa)}`;
29
29
  }
30
30
  });
31
31
  return returnString.trim();
32
32
  } else {
33
- throw new Error("deparseKiwtQuery expects a parameter of type Array, passed: ".concat(queryArray));
33
+ throw new Error(`deparseKiwtQuery expects a parameter of type Array, passed: ${queryArray}`);
34
34
  }
35
35
  };
36
36
  var _default = exports.default = deparseKiwtQueryFilters;
@@ -21,7 +21,7 @@ const parseKiwtQueryFiltersRecursive = query => {
21
21
  return (0, _parseKiwtQueryString.default)(query);
22
22
  }
23
23
  } else {
24
- throw new Error("Unexpected query type: ".concat(query));
24
+ throw new Error(`Unexpected query type: ${query}`);
25
25
  }
26
26
  };
27
27
 
@@ -33,7 +33,7 @@ const parseKiwtQueryFilters = queryString => {
33
33
  const queryGroups = (0, _parseKiwtQueryGroups.default)(queryString);
34
34
  return parseKiwtQueryFiltersRecursive(queryGroups);
35
35
  } else {
36
- throw new Error("parseKiwtQuery expects a parameter of type String, passed: ".concat(queryString));
36
+ throw new Error(`parseKiwtQuery expects a parameter of type String, passed: ${queryString}`);
37
37
  }
38
38
  };
39
39
 
@@ -44,8 +44,7 @@ const parseKiwtQueryGroups = query => {
44
44
  let nestLevel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
45
45
  const group = [];
46
46
  // Iterate over each element in the array, recursively calling this when hitting parens
47
- parseArray === null || parseArray === void 0 || parseArray.every((element, index) => {
48
- var _skipCount;
47
+ parseArray?.every((element, index) => {
49
48
  if (skipCount[nestLevel] > 0) {
50
49
  skipCount[nestLevel] -= 1;
51
50
  return true; // Equivalent to BREAK -- move onto next element
@@ -57,14 +56,14 @@ const parseKiwtQueryGroups = query => {
57
56
  }
58
57
 
59
58
  // At the levels below all of the following will need
60
- skipCount = (_skipCount = skipCount) === null || _skipCount === void 0 ? void 0 : _skipCount.map((n, i) => {
59
+ skipCount = skipCount?.map((n, i) => {
61
60
  if (i < nestLevel) {
62
61
  return n + 1;
63
62
  }
64
63
  return n;
65
64
  });
66
65
  if (element !== '(' && element !== ')') {
67
- group === null || group === void 0 || group.push(element);
66
+ group?.push(element);
68
67
  } else if (element === ')') {
69
68
  // Remove the corresponding skipCount level because we're going down a nesting level
70
69
  skipCount.pop();
@@ -74,7 +73,7 @@ const parseKiwtQueryGroups = query => {
74
73
  // Add next index to skipcount for the nesting
75
74
  skipCount.push(0);
76
75
  unclosedParens += 1;
77
- group.push(groupParser(parseArray.slice(index + 1, parseArray === null || parseArray === void 0 ? void 0 : parseArray.length), nestLevel + 1));
76
+ group.push(groupParser(parseArray.slice(index + 1, parseArray?.length), nestLevel + 1));
78
77
  }
79
78
 
80
79
  // If all is well, continue on parsing
@@ -17,7 +17,7 @@ const FIRST = 0;
17
17
  const SECOND = 1;
18
18
  const THIRD = 2;
19
19
  const parseKiwtQueryString = queryString => {
20
- const comparatorMatch = new RegExp("(".concat(_comparators.default.join('|'), ")"));
20
+ const comparatorMatch = new RegExp(`(${_comparators.default.join('|')})`);
21
21
  // See parseKiwtQueryGroups for breakdown of why this filter is needed
22
22
  const splitString = queryString.split(comparatorMatch).filter(Boolean);
23
23
 
@@ -17,40 +17,36 @@ const conditionalEncodeURIComponent = function (str) {
17
17
  const buildFilterOptionBlock = function (opf) {
18
18
  let isNested = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
19
19
  let encode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
20
- if (opf !== null && opf !== void 0 && opf.groupValues) {
20
+ if (opf?.groupValues) {
21
21
  const groupValues = opf.groupValues;
22
22
 
23
23
  // Small utility function to add negation and brackets to the options block where necessary
24
- const negationAndNesting = str => "".concat(groupValues !== null && groupValues !== void 0 && groupValues.NOT ? '!' : '').concat(isNested || groupValues !== null && groupValues !== void 0 && groupValues.NOT ? '(' : '').concat(str).concat(isNested || groupValues !== null && groupValues !== void 0 && groupValues.NOT ? ')' : '');
24
+ const negationAndNesting = str => `${groupValues?.NOT ? '!' : ''}${isNested || groupValues?.NOT ? '(' : ''}${str}${isNested || groupValues?.NOT ? ')' : ''}`;
25
25
 
26
26
  // First check whether groupValues is ANDed or ORed together
27
- if (groupValues !== null && groupValues !== void 0 && groupValues.AND && Array.isArray(groupValues.AND) || groupValues !== null && groupValues !== void 0 && groupValues.OR && Array.isArray(groupValues.OR)) {
28
- var _groupValues$OR;
27
+ if (groupValues?.AND && Array.isArray(groupValues.AND) || groupValues?.OR && Array.isArray(groupValues.OR)) {
29
28
  // AND takes precedence
30
29
  if (groupValues.AND) {
31
- var _groupValues$AND;
32
- return negationAndNesting(groupValues === null || groupValues === void 0 || (_groupValues$AND = groupValues.AND) === null || _groupValues$AND === void 0 || (_groupValues$AND = _groupValues$AND.map(gvo => buildFilterOptionBlock(gvo, true, encode))) === null || _groupValues$AND === void 0 ? void 0 : _groupValues$AND.join('&&'));
30
+ return negationAndNesting(groupValues?.AND?.map(gvo => buildFilterOptionBlock(gvo, true, encode))?.join('&&'));
33
31
  }
34
- return negationAndNesting(groupValues === null || groupValues === void 0 || (_groupValues$OR = groupValues.OR) === null || _groupValues$OR === void 0 || (_groupValues$OR = _groupValues$OR.map(gvo => buildFilterOptionBlock(gvo, true, encode))) === null || _groupValues$OR === void 0 ? void 0 : _groupValues$OR.join('||'));
32
+ return negationAndNesting(groupValues?.OR?.map(gvo => buildFilterOptionBlock(gvo, true, encode))?.join('||'));
35
33
  }
36
34
  // If neither valid OR nor AND exist, ignore the block
37
- } else if (opf !== null && opf !== void 0 && opf.values) {
35
+ } else if (opf?.values) {
38
36
  // Build the values filter block
39
37
  const innerFilters = [];
40
38
  opf.values.forEach(opfv => {
41
39
  if (opf.path) {
42
- var _opf$comparator;
43
- innerFilters.push("".concat(opf.path).concat((_opf$comparator = opf.comparator) !== null && _opf$comparator !== void 0 ? _opf$comparator : '==').concat(opfv));
40
+ innerFilters.push(`${opf.path}${opf.comparator ?? '=='}${opfv}`);
44
41
  } else {
45
42
  innerFilters.push(opfv);
46
43
  }
47
44
  });
48
45
  return conditionalEncodeURIComponent(innerFilters.join('||'), encode);
49
- } else if (opf !== null && opf !== void 0 && opf.value) {
46
+ } else if (opf?.value) {
50
47
  // If no value OR values, then ignore
51
48
  if (opf.path) {
52
- var _opf$comparator2;
53
- const filterString = "".concat(opf.path).concat((_opf$comparator2 = opf.comparator) !== null && _opf$comparator2 !== void 0 ? _opf$comparator2 : '==').concat(opf.value);
49
+ const filterString = `${opf.path}${opf.comparator ?? '=='}${opf.value}`;
54
50
  return conditionalEncodeURIComponent(filterString, encode);
55
51
  }
56
52
  return conditionalEncodeURIComponent(opf.value, encode);
@@ -108,9 +104,8 @@ const generateKiwtQueryParams = function (options, nsValues) {
108
104
  } = options;
109
105
  const paramsArray = [];
110
106
  if (query) {
111
- var _split, _ref;
112
- paramsArray.push(...((_split = (_ref = qindex || searchKey) === null || _ref === void 0 ? void 0 : _ref.split(',')) !== null && _split !== void 0 ? _split : []).map(m => "match=".concat(conditionalEncodeURIComponent(m, encode))));
113
- paramsArray.push("term=".concat(conditionalEncodeURIComponent(query, encode)));
107
+ paramsArray.push(...((qindex || searchKey)?.split(',') ?? []).map(m => `match=${conditionalEncodeURIComponent(m, encode)}`));
108
+ paramsArray.push(`term=${conditionalEncodeURIComponent(query, encode)}`);
114
109
  }
115
110
 
116
111
  // Actually build the optionsFilters block (Moved logic to its own function to allow recursion)
@@ -118,71 +113,67 @@ const generateKiwtQueryParams = function (options, nsValues) {
118
113
  optionsFilters.forEach(opf => {
119
114
  const optionsBlock = buildFilterOptionBlock(opf, false, encode);
120
115
  if (optionsBlock) {
121
- paramsArray.push("filters=".concat(optionsBlock));
116
+ paramsArray.push(`filters=${optionsBlock}`);
122
117
  }
123
118
  });
124
119
  }
125
120
  if (filters) {
126
121
  const filterMap = {};
127
122
  filters.split(',').forEach(filter => {
128
- var _filter$trim$split, _filter$trim;
129
- const [filterName, ...filterRest] = (_filter$trim$split = (_filter$trim = filter.trim()) === null || _filter$trim === void 0 ? void 0 : _filter$trim.split('.')) !== null && _filter$trim$split !== void 0 ? _filter$trim$split : [];
123
+ const [filterName, ...filterRest] = filter.trim()?.split('.') ?? [];
130
124
  const filterValue = filterRest.join('.');
131
125
  if (filterMap[filterName] === undefined) filterMap[filterName] = [];
132
126
  filterMap[filterName].push(filterValue);
133
127
  });
134
128
 
135
129
  // We now have a filterMap of shape { status: ['active', 'cancelled'], type: ['local'] }
136
- Object.entries(filterMap).forEach(_ref2 => {
137
- let [filterName, filterValues] = _ref2;
130
+ Object.entries(filterMap).forEach(_ref => {
131
+ let [filterName, filterValues] = _ref;
138
132
  const filterConfigEntry = filterConfig.find(conf => conf.name === filterName);
139
133
  const filterKey = filterKeys[filterName];
140
134
  if (filterConfigEntry) {
141
135
  // We have a direct mapping instruction, use it
142
136
  const filterString = filterValues.map(v => {
143
- var _filterConfigEntry$va;
144
- const fceValue = filterConfigEntry === null || filterConfigEntry === void 0 || (_filterConfigEntry$va = filterConfigEntry.values) === null || _filterConfigEntry$va === void 0 || (_filterConfigEntry$va = _filterConfigEntry$va.find(fce => fce.name === v)) === null || _filterConfigEntry$va === void 0 ? void 0 : _filterConfigEntry$va.value;
145
- return "".concat(filterName, "==").concat(fceValue !== null && fceValue !== void 0 ? fceValue : v);
137
+ const fceValue = filterConfigEntry?.values?.find(fce => fce.name === v)?.value;
138
+ return `${filterName}==${fceValue ?? v}`;
146
139
  }).join('||');
147
- paramsArray.push("filters=".concat(conditionalEncodeURIComponent(filterString, encode)));
140
+ paramsArray.push(`filters=${conditionalEncodeURIComponent(filterString, encode)}`);
148
141
  } else if (!filterKey) {
149
142
  // These filters have no key mapping so we just pass the values to the backend as-is.
150
- paramsArray.push(...(filterValues !== null && filterValues !== void 0 ? filterValues : []).map(f => "filters=".concat(conditionalEncodeURIComponent(f, encode))));
143
+ paramsArray.push(...(filterValues ?? []).map(f => `filters=${conditionalEncodeURIComponent(f, encode)}`));
151
144
  } else {
152
- const filterString = filterValues.map(v => "".concat(filterKey, "==").concat(v)).join('||');
153
- paramsArray.push("filters=".concat(conditionalEncodeURIComponent(filterString, encode)));
145
+ const filterString = filterValues.map(v => `${filterKey}==${v}`).join('||');
146
+ paramsArray.push(`filters=${conditionalEncodeURIComponent(filterString, encode)}`);
154
147
  }
155
148
  });
156
149
  }
157
150
  if (optionsSort && optionsSort.length > 0) {
158
151
  optionsSort.forEach(os => {
159
152
  if (os.value) {
160
- paramsArray.push("sort=".concat(conditionalEncodeURIComponent(os.value, encode)));
153
+ paramsArray.push(`sort=${conditionalEncodeURIComponent(os.value, encode)}`);
161
154
  } else if (os.path) {
162
- var _os$direction;
163
155
  // If no path then ignore
164
- const sortString = "".concat(os.path, ";").concat((_os$direction = os.direction) !== null && _os$direction !== void 0 ? _os$direction : 'asc');
165
- paramsArray.push("sort=".concat(conditionalEncodeURIComponent(sortString, encode)));
156
+ const sortString = `${os.path};${os.direction ?? 'asc'}`;
157
+ paramsArray.push(`sort=${conditionalEncodeURIComponent(sortString, encode)}`);
166
158
  }
167
159
  });
168
160
  }
169
161
  if (sort) {
170
- var _sort$trim$split, _sort$trim;
171
- paramsArray.push(...((_sort$trim$split = (_sort$trim = sort.trim()) === null || _sort$trim === void 0 ? void 0 : _sort$trim.split(',')) !== null && _sort$trim$split !== void 0 ? _sort$trim$split : []).map(sortKey => {
162
+ paramsArray.push(...(sort.trim()?.split(',') ?? []).map(sortKey => {
172
163
  const descending = sortKey.startsWith('-');
173
164
  let term = sortKey.replace('-', '');
174
165
  if (term in sortKeys) {
175
166
  term = term.replace(term, sortKeys[term]);
176
167
  }
177
- const sortString = "".concat(term, ";").concat(descending ? 'desc' : 'asc');
178
- return "sort=".concat(conditionalEncodeURIComponent(sortString, encode));
168
+ const sortString = `${term};${descending ? 'desc' : 'asc'}`;
169
+ return `sort=${conditionalEncodeURIComponent(sortString, encode)}`;
179
170
  }));
180
171
  }
181
172
  if (stats) {
182
173
  paramsArray.push('stats=true');
183
174
  }
184
175
  for (const [key, value] of Object.entries(rest)) {
185
- paramsArray.push("".concat(key, "=").concat(conditionalEncodeURIComponent(value, encode)));
176
+ paramsArray.push(`${key}=${conditionalEncodeURIComponent(value, encode)}`);
186
177
  }
187
178
  return paramsArray;
188
179
  };
@@ -7,12 +7,11 @@ exports.default = void 0;
7
7
  const groupCustomPropertiesByCtx = function () {
8
8
  let customProperties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
9
9
  return customProperties.reduce((acc, curr) => {
10
- var _curr$ctx, _acc$ctx;
11
- const ctx = (_curr$ctx = curr.ctx) !== null && _curr$ctx !== void 0 ? _curr$ctx : 'isNull';
10
+ const ctx = curr.ctx ?? 'isNull';
12
11
  const returnObj = {
13
12
  ...acc
14
13
  };
15
- returnObj[ctx] = [...((_acc$ctx = acc === null || acc === void 0 ? void 0 : acc[ctx]) !== null && _acc$ctx !== void 0 ? _acc$ctx : []), curr];
14
+ returnObj[ctx] = [...(acc?.[ctx] ?? []), curr];
16
15
  return returnObj;
17
16
  }, {});
18
17
  };
@@ -7,28 +7,26 @@ exports.default = void 0;
7
7
  var _escapeRegExp = _interopRequireDefault(require("lodash/escapeRegExp"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  const matchString = function (match, str) {
10
- var _str$split2;
11
10
  let ignoreNull = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
12
11
  let simpleSplit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
13
12
  // Simple regex split -- this is default behaviour
14
- const regexSimple = new RegExp("".concat(match.split(/(\s+)/).filter(h => h.trim()).map(hl => '(' + (0, _escapeRegExp.default)(hl) + ')').join('|')), 'gi');
13
+ const regexSimple = new RegExp(`${match.split(/(\s+)/).filter(h => h.trim()).map(hl => '(' + (0, _escapeRegExp.default)(hl) + ')').join('|')}`, 'gi');
15
14
 
16
15
  // Split Elivis "The King" Presley into [Elvis, The King, Presley]
17
- const regex = new RegExp("".concat(match.split(/(?!\B"[^"]*)\s+(?![^"]*"\B)/).filter(h => h.trim()).map(quotedSection => {
16
+ const regex = new RegExp(`${match.split(/(?!\B"[^"]*)\s+(?![^"]*"\B)/).filter(h => h.trim()).map(quotedSection => {
18
17
  if (quotedSection.charAt(0) === '"' && quotedSection.charAt(quotedSection.length - 1) === '"') {
19
18
  return quotedSection.slice(1, quotedSection.length - 1);
20
19
  }
21
20
  return quotedSection;
22
- }).map(hl => '(' + (0, _escapeRegExp.default)(hl) + ')').join('|')), 'gi');
21
+ }).map(hl => '(' + (0, _escapeRegExp.default)(hl) + ')').join('|')}`, 'gi');
23
22
  if (ignoreNull && !match) {
24
23
  const nullRegex = /a^/gi; // Should match nothing
25
24
 
26
25
  return [[str], nullRegex];
27
26
  }
28
27
  if (simpleSplit) {
29
- var _str$split;
30
- return [(_str$split = str.split(regexSimple)) === null || _str$split === void 0 ? void 0 : _str$split.filter(s => s && s.trim()), regexSimple];
28
+ return [str.split(regexSimple)?.filter(s => s && s.trim()), regexSimple];
31
29
  }
32
- return [(_str$split2 = str.split(regex)) === null || _str$split2 === void 0 ? void 0 : _str$split2.filter(s => s && s.trim()), regex];
30
+ return [str.split(regex)?.filter(s => s && s.trim()), regex];
33
31
  };
34
32
  var _default = exports.default = matchString;
@@ -5,10 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  const parseErrorResponse = async responseObj => {
8
- var _ref;
9
- let errorResp;
10
- const code = responseObj === null || responseObj === void 0 ? void 0 : responseObj.status;
11
- const contentType = (_ref = [...(responseObj === null || responseObj === void 0 ? void 0 : responseObj.headers)]) === null || _ref === void 0 || (_ref = _ref.find(header => header[0] === 'content-type')) === null || _ref === void 0 ? void 0 : _ref[1];
8
+ let errorResp = {
9
+ message: 'something went wrong'
10
+ };
11
+ if (!responseObj) {
12
+ return errorResp;
13
+ }
14
+ const code = responseObj?.status;
15
+ const contentType = [...responseObj?.headers]?.find(header => header[0] === 'content-type')?.[1];
12
16
  if (contentType.includes('json')) {
13
17
  errorResp = await responseObj.json();
14
18
  } else {
@@ -5,12 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  const selectorSafe = string => {
8
- var _string$normalize;
9
8
  // Normalise to separate diacritics from their base characters as "marks"
10
9
  // then strip out all marks.
11
- return (_string$normalize = string.normalize('NFKD')) === null || _string$normalize === void 0 || (_string$normalize = _string$normalize.replace(/\p{M}/gu, '')
10
+ return string.normalize('NFKD')?.replace(/\p{M}/gu, '')
12
11
  // Then swap out any non-letter/number characters (Also ignore - and _) for `_`
13
- ) === null || _string$normalize === void 0 ? void 0 : _string$normalize.replace(/[^\p{L}\p{N}\-_]/gu, '_');
12
+ ?.replace(/[^\p{L}\p{N}\-_]/gu, '_');
14
13
  };
15
14
  var _default = exports.default = selectorSafe;
16
15
  /*
@@ -5,9 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  const sortByLabel = (a, b) => {
8
- var _a$label$toLowerCase, _a$label, _a$id, _b$label$toLowerCase, _b$label, _b$id;
9
- const al = (_a$label$toLowerCase = (_a$label = a.label) === null || _a$label === void 0 ? void 0 : _a$label.toLowerCase()) !== null && _a$label$toLowerCase !== void 0 ? _a$label$toLowerCase : (_a$id = a.id) === null || _a$id === void 0 ? void 0 : _a$id.toLowerCase();
10
- const bl = (_b$label$toLowerCase = (_b$label = b.label) === null || _b$label === void 0 ? void 0 : _b$label.toLowerCase()) !== null && _b$label$toLowerCase !== void 0 ? _b$label$toLowerCase : (_b$id = b.id) === null || _b$id === void 0 ? void 0 : _b$id.toLowerCase();
8
+ const al = a.label?.toLowerCase() ?? a.id?.toLowerCase();
9
+ const bl = b.label?.toLowerCase() ?? b.id?.toLowerCase();
11
10
  if (al < bl) {
12
11
  return -1;
13
12
  }
@@ -64,7 +64,7 @@ const invalidNumber = function (value, _min, _max, intlKey, intlNS) {
64
64
  id: "errors.invalidNumber",
65
65
  intlKey: intlKey,
66
66
  intlNS: intlNS,
67
- overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.invalidNumberError
67
+ overrideValue: labelOverrides?.invalidNumberError
68
68
  });
69
69
  }
70
70
  return undefined;
@@ -77,7 +77,7 @@ const rangeOverflow = function (value, min, max, intlKey, intlNS) {
77
77
  id: "errors.decimalValueNotInRange",
78
78
  intlKey: intlKey,
79
79
  intlNS: intlNS,
80
- overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.decimalValueNotInRangeError,
80
+ overrideValue: labelOverrides?.decimalValueNotInRangeError,
81
81
  values: {
82
82
  min,
83
83
  max
@@ -94,7 +94,7 @@ const rangeUnderflow = function (value, min, max, intlKey, intlNS) {
94
94
  id: "errors.decimalValueNotInRange",
95
95
  intlKey: intlKey,
96
96
  intlNS: intlNS,
97
- overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.decimalValueNotInRangeError,
97
+ overrideValue: labelOverrides?.decimalValueNotInRangeError,
98
98
  values: {
99
99
  min,
100
100
  max
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@k-int/stripes-kint-components",
3
- "version": "5.6.0",
3
+ "version": "5.7.0",
4
4
  "description": "Stripes Component library for K-Int specific applications",
5
5
  "sideEffects": [
6
6
  "*.css"
7
7
  ],
8
8
  "license": "Apache-2.0",
9
9
  "scripts": {
10
- "lint": "eslint src",
10
+ "lint": "eslint src --resolve-plugins-relative-to ./node_modules/@folio/eslint-config-stripes/",
11
11
  "test": "yarn run test:jest",
12
12
  "test:jest": "jest --ci --coverage",
13
13
  "build:es": "rm -rf ./es && babel --extensions .js --ignore ./src/**/tests/**/* ./src --out-dir es",
@@ -29,7 +29,6 @@
29
29
  "devDependencies": {
30
30
  "@babel/cli": "^7.18.10",
31
31
  "@babel/core": "^7.18.6",
32
- "@babel/eslint-parser": "^7.15.0",
33
32
  "@babel/plugin-proposal-class-properties": "^7.12.1",
34
33
  "@babel/plugin-proposal-decorators": "^7.12.1",
35
34
  "@babel/plugin-proposal-function-sent": "^7.18.6",
@@ -58,8 +57,7 @@
58
57
  "classnames": ">=2.2.6",
59
58
  "core-js": "^3.6.1",
60
59
  "eslint": "^8.0.0",
61
- "eslint-plugin-import": "^2.26.0",
62
- "eslint-plugin-jest": "^27.4.2",
60
+ "eslint-plugin-jest": "^28.0.0",
63
61
  "graphql": "^16.0.0",
64
62
  "identity-obj-proxy": "^3.0.0",
65
63
  "moment": "^2.29.4",