@steroidsjs/core 2.2.9 → 2.2.10

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.
@@ -29,6 +29,12 @@ export interface IDataSelectConfig {
29
29
  * @example id
30
30
  */
31
31
  primaryKey?: string;
32
+ /**
33
+ * Атрибут, в котором должны лежать дочерние элементы списка (для группировки)
34
+ * Если аттрибут не задан - группировка не производится
35
+ * @example items
36
+ */
37
+ groupAttribute?: string;
32
38
  /**
33
39
  * Значение поля в форме
34
40
  */
@@ -178,7 +178,21 @@ function useDataSelect(config) {
178
178
  else {
179
179
  // Navigate on items by keys
180
180
  var direction = isDown ? 1 : -1;
181
- var keys = config.items.map(function (item) { return item.id; });
181
+ var getKeysRecursive_1 = function (items) {
182
+ var ids = [];
183
+ items.forEach(function (item) {
184
+ if (config.groupAttribute && Array.isArray(item[config.groupAttribute])) {
185
+ ids = ids.concat(getKeysRecursive_1(item[config.groupAttribute]));
186
+ }
187
+ else {
188
+ ids.push(item.id);
189
+ }
190
+ return ids;
191
+ });
192
+ return ids;
193
+ };
194
+ //const keys = config.items.map(item => item.id);
195
+ var keys = getKeysRecursive_1(config.items);
182
196
  // Get current index
183
197
  var index = hoveredId ? keys.indexOf(hoveredId) : -1;
184
198
  if (index === -1 && selectedIds.length === 1) {
@@ -192,7 +206,7 @@ function useDataSelect(config) {
192
206
  setHoveredId(keys[newIndex]);
193
207
  }
194
208
  }
195
- }, [config.items, hoveredId, isFocused, isOpened, setSelectedIds, selectedIds]);
209
+ }, [isFocused, isOpened, hoveredId, selectedIds, config.items, config.groupAttribute, setSelectedIds]);
196
210
  react_use_1.useEvent('keydown', onKeyDown);
197
211
  return {
198
212
  isOpened: isOpened,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "2.2.9",
3
+ "version": "2.2.10",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -31,6 +31,12 @@ export interface IDropDownFieldProps extends IFieldWrapperInputProps, IDataProvi
31
31
  * @example true
32
32
  */
33
33
  showReset?: boolean;
34
+ /**
35
+ * Атрибут, в котором должны лежать дочерние элементы списка (для группировки)
36
+ * Если аттрибут не задан - группировка не производится
37
+ * @example items
38
+ */
39
+ groupAttribute?: string;
34
40
  /**
35
41
  * Включает стиль без 'border'
36
42
  * @example true
@@ -39,6 +39,7 @@ function DropDownField(props) {
39
39
  selectFirst: props.selectFirst,
40
40
  selectedIds: inputSelectedIds,
41
41
  primaryKey: props.primaryKey,
42
+ groupAttribute: props.groupAttribute,
42
43
  items: items,
43
44
  sourceItems: sourceItems,
44
45
  inputValue: props.input.value