@k-int/stripes-kint-components 5.6.1 → 5.7.1

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 (148) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/es/index.js +1 -1
  3. package/es/lib/ActionList/ActionList.js +1 -1
  4. package/es/lib/ActionList/ActionListFieldArray.js +33 -38
  5. package/es/lib/ActionList/index.js +1 -1
  6. package/es/lib/ComboButton/ComboButton.js +6 -7
  7. package/es/lib/ComboButton/index.js +1 -1
  8. package/es/lib/CustomProperties/Config/CustomPropertiesLookup.js +5 -8
  9. package/es/lib/CustomProperties/Config/CustomPropertiesLookup.test.js +1 -1
  10. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.js +30 -33
  11. package/es/lib/CustomProperties/Config/CustomPropertiesSettings.test.js +1 -1
  12. package/es/lib/CustomProperties/Config/CustomPropertyForm.js +59 -59
  13. package/es/lib/CustomProperties/Config/CustomPropertyForm.test.js +3 -3
  14. package/es/lib/CustomProperties/Config/CustomPropertyView.js +33 -34
  15. package/es/lib/CustomProperties/Config/CustomPropertyView.test.js +2 -2
  16. package/es/lib/CustomProperties/Config/index.js +1 -1
  17. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.js +2 -2
  18. package/es/lib/CustomProperties/Edit/CustomPropertiesEdit.test.js +1 -1
  19. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.js +4 -4
  20. package/es/lib/CustomProperties/Edit/CustomPropertiesEditCtx.test.js +1 -1
  21. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.js +6 -11
  22. package/es/lib/CustomProperties/Edit/CustomPropertiesListField.test.js +1 -1
  23. package/es/lib/CustomProperties/Edit/CustomPropertyField.js +19 -26
  24. package/es/lib/CustomProperties/Edit/CustomPropertyField.test.js +6 -6
  25. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.js +3 -3
  26. package/es/lib/CustomProperties/Edit/CustomPropertyFormCard.test.js +2 -2
  27. package/es/lib/CustomProperties/Edit/index.js +1 -1
  28. package/es/lib/CustomProperties/Edit/testResources.js +11 -12
  29. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.js +7 -12
  30. package/es/lib/CustomProperties/Filter/CustomPropertiesFilter.test.js +1 -1
  31. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.js +21 -29
  32. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterField.test.js +2 -2
  33. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.js +7 -7
  34. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterFieldArray.test.js +1 -1
  35. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.js +1 -1
  36. package/es/lib/CustomProperties/Filter/CustomPropertiesFilterForm.test.js +1 -1
  37. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.js +9 -9
  38. package/es/lib/CustomProperties/Filter/CustomPropertiesRule.test.js +1 -1
  39. package/es/lib/CustomProperties/Filter/index.js +1 -1
  40. package/es/lib/CustomProperties/Filter/testResources.js +1 -2
  41. package/es/lib/CustomProperties/Filter/useParseActiveFilterStrings.js +2 -3
  42. package/es/lib/CustomProperties/View/CustomPropertiesView.js +2 -2
  43. package/es/lib/CustomProperties/View/CustomPropertiesView.test.js +1 -1
  44. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.js +19 -27
  45. package/es/lib/CustomProperties/View/CustomPropertiesViewCtx.test.js +1 -1
  46. package/es/lib/CustomProperties/View/CustomPropertyCard.js +8 -12
  47. package/es/lib/CustomProperties/View/index.js +1 -1
  48. package/es/lib/CycleButton/CycleButton.js +2 -2
  49. package/es/lib/CycleButton/index.js +1 -1
  50. package/es/lib/EditableRefdataCategoryList/EditableRefdataCategoryList.js +27 -39
  51. package/es/lib/EditableRefdataCategoryList/index.js +1 -1
  52. package/es/lib/EditableRefdataList/EditableRefdataList.js +27 -34
  53. package/es/lib/EditableRefdataList/index.js +1 -1
  54. package/es/lib/EditableSettingsList/EditableSettingsList.js +1 -1
  55. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.js +2 -2
  56. package/es/lib/EditableSettingsList/EditableSettingsListFieldArray.test.js +1 -1
  57. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.js +6 -6
  58. package/es/lib/EditableSettingsList/SettingField/EditSettingValue.test.js +1 -1
  59. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.js +11 -13
  60. package/es/lib/EditableSettingsList/SettingField/RenderSettingValue.test.js +1 -1
  61. package/es/lib/EditableSettingsList/SettingField/SettingField.js +5 -5
  62. package/es/lib/EditableSettingsList/SettingField/SettingField.test.js +1 -1
  63. package/es/lib/EditableSettingsList/SettingField/index.js +1 -1
  64. package/es/lib/EditableSettingsList/index.js +1 -1
  65. package/es/lib/FormModal/FormModal.js +1 -1
  66. package/es/lib/FormModal/index.js +1 -1
  67. package/es/lib/FormattedKintMessage/FormattedKintMessage.js +5 -8
  68. package/es/lib/FormattedKintMessage/index.js +1 -1
  69. package/es/lib/IconSelect/IconSelect.js +6 -10
  70. package/es/lib/IconSelect/index.js +1 -1
  71. package/es/lib/NoResultsMessage/NoResultsMessage.js +5 -5
  72. package/es/lib/NoResultsMessage/index.js +1 -1
  73. package/es/lib/QueryTypedown/QueryTypedown.js +1 -1
  74. package/es/lib/QueryTypedown/index.js +1 -1
  75. package/es/lib/RefdataButtons/RefdataButtons.js +4 -4
  76. package/es/lib/RefdataButtons/index.js +1 -1
  77. package/es/lib/RefdataCategoriesSettings/RefdataCategoriesSettings.js +14 -18
  78. package/es/lib/RefdataCategoriesSettings/index.js +1 -1
  79. package/es/lib/ResponsiveButtonGroup/ResponsiveButtonGroup.js +22 -29
  80. package/es/lib/ResponsiveButtonGroup/index.js +1 -1
  81. package/es/lib/ResponsiveButtonGroup/useResponsiveButtonGroupSizing.js +6 -7
  82. package/es/lib/RichSelect/RichSelect.js +15 -20
  83. package/es/lib/RichSelect/index.js +1 -1
  84. package/es/lib/RichSelect/useSelectedOption.js +1 -2
  85. package/es/lib/SASQLookupComponent/SASQLookupComponent.js +15 -18
  86. package/es/lib/SASQLookupComponent/TableBody/TableBody.js +8 -10
  87. package/es/lib/SASQLookupComponent/TableBody/index.js +1 -1
  88. package/es/lib/SASQLookupComponent/index.js +1 -1
  89. package/es/lib/SASQRoute/SASQRoute.js +3 -3
  90. package/es/lib/SASQRoute/index.js +1 -1
  91. package/es/lib/SASQViewComponent/SASQViewComponent.js +6 -10
  92. package/es/lib/SASQViewComponent/index.js +1 -1
  93. package/es/lib/SearchField/SearchField.js +1 -1
  94. package/es/lib/SearchField/index.js +1 -1
  95. package/es/lib/SettingPage/SettingPage.js +1 -1
  96. package/es/lib/SettingPage/SettingPagePane.js +3 -3
  97. package/es/lib/SettingPage/index.js +1 -1
  98. package/es/lib/SettingsFormContainer/SettingsFormContainer.js +3 -3
  99. package/es/lib/SettingsFormContainer/index.js +1 -1
  100. package/es/lib/Typedown/Typedown.js +35 -33
  101. package/es/lib/Typedown/index.js +1 -1
  102. package/es/lib/contexts/index.js +1 -1
  103. package/es/lib/hooks/__mocks__/index.js +1 -1
  104. package/es/lib/hooks/index.js +1 -1
  105. package/es/lib/hooks/typedownHooks/index.js +1 -1
  106. package/es/lib/hooks/typedownHooks/useTypedown.js +3 -3
  107. package/es/lib/hooks/typedownHooks/useTypedownToggle.js +3 -3
  108. package/es/lib/hooks/useActionListRef.js +1 -1
  109. package/es/lib/hooks/useActiveElement.js +1 -1
  110. package/es/lib/hooks/useCustomProperties.js +3 -3
  111. package/es/lib/hooks/useHelperApp.js +7 -7
  112. package/es/lib/hooks/useIntlKey.js +1 -1
  113. package/es/lib/hooks/useIntlKeyStore.js +4 -7
  114. package/es/lib/hooks/useKintIntl.js +6 -12
  115. package/es/lib/hooks/useKiwtSASQuery.js +2 -2
  116. package/es/lib/hooks/useModConfigEntries.js +3 -3
  117. package/es/lib/hooks/useMutateCustomProperties.js +8 -8
  118. package/es/lib/hooks/useMutateModConfigEntry.js +2 -2
  119. package/es/lib/hooks/useMutateRefdataCategory.js +5 -5
  120. package/es/lib/hooks/useMutateRefdataValue.js +7 -7
  121. package/es/lib/hooks/useQIndex.js +6 -6
  122. package/es/lib/hooks/useRefdata.js +4 -4
  123. package/es/lib/hooks/useTemplates.js +5 -5
  124. package/es/lib/settingsHooks/index.js +1 -1
  125. package/es/lib/settingsHooks/useAppSettings.js +7 -11
  126. package/es/lib/settingsHooks/useSettingSection.js +2 -2
  127. package/es/lib/settingsHooks/useSettings.js +4 -4
  128. package/es/lib/utils/buildUrl.js +3 -4
  129. package/es/lib/utils/filterParsers/deparseKiwtQueryFilters.js +5 -5
  130. package/es/lib/utils/filterParsers/index.js +1 -1
  131. package/es/lib/utils/filterParsers/parseKiwtQueryFilters.js +3 -3
  132. package/es/lib/utils/filterParsers/parseKiwtQueryGroups.js +4 -5
  133. package/es/lib/utils/filterParsers/parseKiwtQueryGroups.test.js +1 -1
  134. package/es/lib/utils/filterParsers/parseKiwtQueryString.js +2 -2
  135. package/es/lib/utils/generateKiwtQuery.js +1 -1
  136. package/es/lib/utils/generateKiwtQueryParams.js +28 -37
  137. package/es/lib/utils/groupCustomPropertiesByCtx.js +2 -3
  138. package/es/lib/utils/highlightString.js +1 -1
  139. package/es/lib/utils/index.js +1 -1
  140. package/es/lib/utils/matchString.js +6 -8
  141. package/es/lib/utils/parseErrorResponse.js +2 -3
  142. package/es/lib/utils/selectorSafe.js +2 -3
  143. package/es/lib/utils/sortByLabel.js +2 -3
  144. package/es/lib/validators/validators.js +4 -4
  145. package/package.json +2 -4
  146. package/src/lib/SASQLookupComponent/TableBody/TableBody.js +1 -1
  147. package/src/lib/Typedown/Typedown.js +12 -5
  148. package/styles/TypeDown.css +6 -1
@@ -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
  };
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.highlightString = exports.boldString = void 0;
7
7
  var _matchString = _interopRequireDefault(require("./matchString"));
8
8
  var _jsxRuntime = require("react/jsx-runtime");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
10
  const highlightString = function (match, str) {
11
11
  let ignoreNull = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
12
12
  let simpleSplit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
@@ -151,4 +151,4 @@ var _filterParsers = require("./filterParsers");
151
151
  var _parseErrorResponse = _interopRequireDefault(require("./parseErrorResponse"));
152
152
  var _modConfigEntriesQueryKey = _interopRequireDefault(require("./modConfigEntriesQueryKey"));
153
153
  var _parseModConfigEntry = _interopRequireDefault(require("./parseModConfigEntry"));
154
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
154
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -5,30 +5,28 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _escapeRegExp = _interopRequireDefault(require("lodash/escapeRegExp"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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,15 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  const parseErrorResponse = async responseObj => {
8
- var _ref;
9
8
  let errorResp = {
10
9
  message: 'something went wrong'
11
10
  };
12
11
  if (!responseObj) {
13
12
  return errorResp;
14
13
  }
15
- const code = responseObj === null || responseObj === void 0 ? void 0 : responseObj.status;
16
- 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];
14
+ const code = responseObj?.status;
15
+ const contentType = [...responseObj?.headers]?.find(header => header[0] === 'content-type')?.[1];
17
16
  if (contentType.includes('json')) {
18
17
  errorResp = await responseObj.json();
19
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
  }
@@ -7,7 +7,7 @@ exports.requiredObject = exports.required = exports.rangeUnderflow = exports.ran
7
7
  var _reactIntl = require("react-intl");
8
8
  var _FormattedKintMessage = _interopRequireDefault(require("../FormattedKintMessage"));
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  const required = value => {
12
12
  const blankString = /^\s+$/;
13
13
  if (value && !blankString.test(value) || value === false || value === 0) {
@@ -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.1",
3
+ "version": "5.7.1",
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,7 +57,6 @@
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
60
  "eslint-plugin-jest": "^28.0.0",
63
61
  "graphql": "^16.0.0",
64
62
  "identity-obj-proxy": "^3.0.0",
@@ -22,7 +22,7 @@ const TableBody = ({
22
22
  mclProps: {
23
23
  formatter = {},
24
24
  ...mclProps
25
- },
25
+ } = {},
26
26
  onSort,
27
27
  path,
28
28
  resultColumns,
@@ -28,6 +28,7 @@ const Typedown = ({
28
28
  renderFooter = null,
29
29
  renderListItem = null,
30
30
  required,
31
+ selectedStyles, // A way to pass any styles that need to be applied globally on selection
31
32
  uniqueIdentificationPath = 'id'
32
33
  }) => {
33
34
  const selectedUniqueId = get(input.value, uniqueIdentificationPath);
@@ -86,12 +87,12 @@ const Typedown = ({
86
87
  }
87
88
  } = useTypedown(input.name);
88
89
 
89
- const renderItem = useCallback((option) => (
90
+ const renderItem = useCallback((option, optionIsSelected = false) => (
90
91
  <div
91
92
  className={css.listItem}
92
93
  >
93
94
  {renderListItem ?
94
- renderListItem(option, currentlyTyped, exactMatch) :
95
+ renderListItem(option, currentlyTyped, exactMatch, optionIsSelected) :
95
96
  get(option, uniqueIdentificationPath)
96
97
  }
97
98
  </div>
@@ -119,12 +120,15 @@ const Typedown = ({
119
120
  >
120
121
  {displayData?.length ? displayData?.map((d, index) => {
121
122
  const isSelectedEval = isSelected ? isSelected(input.value, d) : get(input.value, uniqueIdentificationPath) === get(d, uniqueIdentificationPath);
123
+
124
+ const selectedCSS = selectedStyles ?? css.selectedMenuButton;
122
125
  return (
123
126
  <button
124
127
  key={`typedown-button-[${index}]`}
125
128
  className={classnames(
126
129
  css.fullWidth,
127
- css.menuButton
130
+ css.menuButton,
131
+ { [`${selectedCSS}`]: isSelectedEval },
128
132
  )}
129
133
  data-selected={isSelectedEval}
130
134
  id={`typedown-button-[${index}]`}
@@ -135,7 +139,7 @@ const Typedown = ({
135
139
  onKeyDown={listKeyDownHandler}
136
140
  type="button"
137
141
  >
138
- {renderItem(d)}
142
+ {renderItem(d, isSelectedEval)}
139
143
  </button>
140
144
  );
141
145
  }) :
@@ -161,13 +165,15 @@ const Typedown = ({
161
165
  footerRef,
162
166
  handleChange,
163
167
  handleNextFocus,
164
- input,
168
+ input.name,
169
+ input.value,
165
170
  isSelected,
166
171
  listKeyDownHandler,
167
172
  listRef,
168
173
  renderFooter,
169
174
  renderItem,
170
175
  searchWidth,
176
+ selectedStyles,
171
177
  uniqueIdentificationPath
172
178
  ]);
173
179
 
@@ -270,6 +276,7 @@ Typedown.propTypes = {
270
276
  renderFooter: PropTypes.func,
271
277
  renderListItem: PropTypes.func,
272
278
  required: PropTypes.bool,
279
+ selectedStyles: PropTypes.string,
273
280
  uniqueIdentificationPath: PropTypes.string
274
281
  };
275
282
 
@@ -33,7 +33,12 @@
33
33
  text-align: left;
34
34
  }
35
35
 
36
- .menuButton[data-selected=true], .selected {
36
+ /* .menuButton[data-selected=true], .selected {
37
+ background-color: var(--primary);
38
+ color: #fff;
39
+ } */
40
+
41
+ .selectedMenuButton {
37
42
  background-color: var(--primary);
38
43
  color: #fff;
39
44
  }