@steroidsjs/core 3.0.47 → 3.0.49
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.
- package/docs-autogen-result.json +78 -0
- package/en.json +1 -0
- package/hooks/useDataSelect.d.ts +5 -0
- package/hooks/useDataSelect.js +4 -3
- package/package.json +1 -1
- package/ui/form/DropDownField/DropDownField.d.ts +2 -1
- package/ui/form/DropDownField/DropDownField.js +4 -2
- package/ui/form/FieldList/FieldList.js +3 -25
package/docs-autogen-result.json
CHANGED
|
@@ -3262,6 +3262,14 @@
|
|
|
3262
3262
|
"defaultProps": null,
|
|
3263
3263
|
"extends": [],
|
|
3264
3264
|
"properties": [
|
|
3265
|
+
{
|
|
3266
|
+
"name": "autoCompleteInputRef",
|
|
3267
|
+
"decorators": [],
|
|
3268
|
+
"description": " Ref autocomplete поиска",
|
|
3269
|
+
"required": false,
|
|
3270
|
+
"type": "MutableRefObject",
|
|
3271
|
+
"example": null
|
|
3272
|
+
},
|
|
3265
3273
|
{
|
|
3266
3274
|
"name": "groupAttribute",
|
|
3267
3275
|
"decorators": [],
|
|
@@ -13633,6 +13641,15 @@
|
|
|
13633
13641
|
"example": "{\n enable: true,\n minLength: 2,\n delay: 100\n}",
|
|
13634
13642
|
"defaultValue": null
|
|
13635
13643
|
},
|
|
13644
|
+
{
|
|
13645
|
+
"name": "autoCompleteInputRef",
|
|
13646
|
+
"decorators": [],
|
|
13647
|
+
"description": " Ref autocomplete поиска",
|
|
13648
|
+
"required": false,
|
|
13649
|
+
"type": "MutableRefObject",
|
|
13650
|
+
"example": null,
|
|
13651
|
+
"defaultValue": null
|
|
13652
|
+
},
|
|
13636
13653
|
{
|
|
13637
13654
|
"name": "autoFetch",
|
|
13638
13655
|
"decorators": [],
|
|
@@ -15447,6 +15464,15 @@
|
|
|
15447
15464
|
"example": "{\n enable: true,\n minLength: 2,\n delay: 100\n}",
|
|
15448
15465
|
"defaultValue": null
|
|
15449
15466
|
},
|
|
15467
|
+
{
|
|
15468
|
+
"name": "autoCompleteInputRef",
|
|
15469
|
+
"decorators": [],
|
|
15470
|
+
"description": " Ref autocomplete поиска",
|
|
15471
|
+
"required": false,
|
|
15472
|
+
"type": "MutableRefObject",
|
|
15473
|
+
"example": null,
|
|
15474
|
+
"defaultValue": null
|
|
15475
|
+
},
|
|
15450
15476
|
{
|
|
15451
15477
|
"name": "autoFetch",
|
|
15452
15478
|
"decorators": [],
|
|
@@ -15976,6 +16002,15 @@
|
|
|
15976
16002
|
"example": "{\n enable: true,\n minLength: 2,\n delay: 100\n}",
|
|
15977
16003
|
"defaultValue": null
|
|
15978
16004
|
},
|
|
16005
|
+
{
|
|
16006
|
+
"name": "autoCompleteInputRef",
|
|
16007
|
+
"decorators": [],
|
|
16008
|
+
"description": " Ref autocomplete поиска",
|
|
16009
|
+
"required": false,
|
|
16010
|
+
"type": "MutableRefObject",
|
|
16011
|
+
"example": null,
|
|
16012
|
+
"defaultValue": null
|
|
16013
|
+
},
|
|
15979
16014
|
{
|
|
15980
16015
|
"name": "autoFetch",
|
|
15981
16016
|
"decorators": [],
|
|
@@ -18819,6 +18854,15 @@
|
|
|
18819
18854
|
"example": "{\n enable: true,\n minLength: 2,\n delay: 100\n}",
|
|
18820
18855
|
"defaultValue": null
|
|
18821
18856
|
},
|
|
18857
|
+
{
|
|
18858
|
+
"name": "autoCompleteInputRef",
|
|
18859
|
+
"decorators": [],
|
|
18860
|
+
"description": " Ref autocomplete поиска",
|
|
18861
|
+
"required": false,
|
|
18862
|
+
"type": "MutableRefObject",
|
|
18863
|
+
"example": null,
|
|
18864
|
+
"defaultValue": null
|
|
18865
|
+
},
|
|
18822
18866
|
{
|
|
18823
18867
|
"name": "autoFetch",
|
|
18824
18868
|
"decorators": [],
|
|
@@ -19264,6 +19308,14 @@
|
|
|
19264
19308
|
"type": "boolean | IAutoCompleteConfig",
|
|
19265
19309
|
"example": "{\n enable: true,\n minLength: 2,\n delay: 100\n}"
|
|
19266
19310
|
},
|
|
19311
|
+
{
|
|
19312
|
+
"name": "autoCompleteInputRef",
|
|
19313
|
+
"decorators": [],
|
|
19314
|
+
"description": " Ref autocomplete поиска",
|
|
19315
|
+
"required": false,
|
|
19316
|
+
"type": "MutableRefObject",
|
|
19317
|
+
"example": null
|
|
19318
|
+
},
|
|
19267
19319
|
{
|
|
19268
19320
|
"name": "autoFetch",
|
|
19269
19321
|
"decorators": [],
|
|
@@ -19328,6 +19380,14 @@
|
|
|
19328
19380
|
"type": "string",
|
|
19329
19381
|
"example": null
|
|
19330
19382
|
},
|
|
19383
|
+
{
|
|
19384
|
+
"name": "forwardedInputRef",
|
|
19385
|
+
"decorators": [],
|
|
19386
|
+
"description": "",
|
|
19387
|
+
"required": true,
|
|
19388
|
+
"type": "MutableRefObject",
|
|
19389
|
+
"example": null
|
|
19390
|
+
},
|
|
19331
19391
|
{
|
|
19332
19392
|
"name": "forwardedRef",
|
|
19333
19393
|
"decorators": [],
|
|
@@ -27294,6 +27354,15 @@
|
|
|
27294
27354
|
"example": "{\n enable: true,\n minLength: 2,\n delay: 100\n}",
|
|
27295
27355
|
"defaultValue": null
|
|
27296
27356
|
},
|
|
27357
|
+
{
|
|
27358
|
+
"name": "autoCompleteInputRef",
|
|
27359
|
+
"decorators": [],
|
|
27360
|
+
"description": " Ref autocomplete поиска",
|
|
27361
|
+
"required": false,
|
|
27362
|
+
"type": "MutableRefObject",
|
|
27363
|
+
"example": null,
|
|
27364
|
+
"defaultValue": null
|
|
27365
|
+
},
|
|
27297
27366
|
{
|
|
27298
27367
|
"name": "autoFetch",
|
|
27299
27368
|
"decorators": [],
|
|
@@ -29491,6 +29560,15 @@
|
|
|
29491
29560
|
"example": "{\n enable: true,\n minLength: 2,\n delay: 100\n}",
|
|
29492
29561
|
"defaultValue": null
|
|
29493
29562
|
},
|
|
29563
|
+
{
|
|
29564
|
+
"name": "autoCompleteInputRef",
|
|
29565
|
+
"decorators": [],
|
|
29566
|
+
"description": " Ref autocomplete поиска",
|
|
29567
|
+
"required": false,
|
|
29568
|
+
"type": "MutableRefObject",
|
|
29569
|
+
"example": null,
|
|
29570
|
+
"defaultValue": null
|
|
29571
|
+
},
|
|
29494
29572
|
{
|
|
29495
29573
|
"name": "autoFetch",
|
|
29496
29574
|
"decorators": [],
|
package/en.json
CHANGED
|
@@ -983,6 +983,7 @@
|
|
|
983
983
|
"Компонент, который представляет в виде дерева список с иерархической структурой данных\n\nДополнительный функционал: в кастомном view компонента есть возможность реализовать кнопку, по клику на которую\nбудет вызываться функция props.onItemFocus. Данная функция \"находит\" текущий роут в дереве -\nраскрывает родительские уровни, делает элемент активным.\nДанная функция не включает скролл к активному компоненту внутри дерева, это также необходимо\nреализовать в кастомном view локально в проекте.\n": "",
|
|
984
984
|
"Значение страницы по умолчанию.": "",
|
|
985
985
|
"Логическое значение, указывающее, можно ли загрузить еще элементы для списка при скролле.": "",
|
|
986
|
+
" Ref autocomplete поиска": "",
|
|
986
987
|
"Подключение бесконечного скролла": "",
|
|
987
988
|
"Дополнительный свойства для view части компонента": "",
|
|
988
989
|
"Используется для управления раскрытием всех элементов в дереве": "",
|
package/hooks/useDataSelect.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
1
2
|
export interface IDataSelectItem {
|
|
2
3
|
/**
|
|
3
4
|
* Идентификатор элемента
|
|
@@ -49,6 +50,10 @@ export interface IDataSelectConfig {
|
|
|
49
50
|
* Список со всеми элементами
|
|
50
51
|
*/
|
|
51
52
|
sourceItems?: IDataSelectItem[];
|
|
53
|
+
/**
|
|
54
|
+
* Ref autocomplete поиска
|
|
55
|
+
*/
|
|
56
|
+
autoCompleteInputRef?: MutableRefObject<HTMLInputElement>;
|
|
52
57
|
}
|
|
53
58
|
export interface IDataSelectResult {
|
|
54
59
|
isOpened: boolean;
|
package/hooks/useDataSelect.js
CHANGED
|
@@ -25,6 +25,7 @@ var react_use_1 = require("react-use");
|
|
|
25
25
|
var defaultProps = {
|
|
26
26
|
primaryKey: 'id'
|
|
27
27
|
};
|
|
28
|
+
var isAutoCompleteInputFocused = function (autoCompleteInputRef) { return document.activeElement === autoCompleteInputRef.current; };
|
|
28
29
|
var getFlattenedItems = function (items, groupAttribute) {
|
|
29
30
|
var result = [];
|
|
30
31
|
items.forEach(function (item) {
|
|
@@ -218,8 +219,8 @@ function useDataSelect(config) {
|
|
|
218
219
|
}
|
|
219
220
|
setIsOpened(false);
|
|
220
221
|
}
|
|
221
|
-
// Keys: space (toggle select)
|
|
222
|
-
if (e.which === 32 && isOpened) {
|
|
222
|
+
// Keys: space (toggle select), disable in DropDownField with focused autocomplete
|
|
223
|
+
if (e.which === 32 && isOpened && !isAutoCompleteInputFocused(config.autoCompleteInputRef)) {
|
|
223
224
|
if (hoveredId) {
|
|
224
225
|
e.preventDefault();
|
|
225
226
|
// Select hovered
|
|
@@ -253,7 +254,7 @@ function useDataSelect(config) {
|
|
|
253
254
|
setHoveredId(keys[newIndex]);
|
|
254
255
|
}
|
|
255
256
|
}
|
|
256
|
-
}, [isFocused, isOpened, hoveredId, selectedIds, flattenedItems, setSelectedIds]);
|
|
257
|
+
}, [isFocused, isOpened, config.autoCompleteInputRef, hoveredId, selectedIds, flattenedItems, setSelectedIds]);
|
|
257
258
|
(0, react_use_1.useEvent)('keydown', onKeyDown);
|
|
258
259
|
return {
|
|
259
260
|
isOpened: isOpened,
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { MutableRefObject } from 'react';
|
|
2
2
|
import { IAccordionItemViewProps } from '../../../ui/content/Accordion/Accordion';
|
|
3
3
|
import { DataProviderItems, IDataProviderConfig } from '../../../hooks/useDataProvider';
|
|
4
4
|
import { IDataSelectConfig } from '../../../hooks/useDataSelect';
|
|
@@ -165,6 +165,7 @@ export interface IDropDownFieldViewProps extends IDropDownFieldProps {
|
|
|
165
165
|
hoveredId: PrimaryKey | any;
|
|
166
166
|
selectedIds: (PrimaryKey | any)[];
|
|
167
167
|
forwardedRef: any;
|
|
168
|
+
forwardedInputRef: MutableRefObject<HTMLInputElement>;
|
|
168
169
|
searchInputProps: {
|
|
169
170
|
type: string;
|
|
170
171
|
name: string;
|
|
@@ -87,6 +87,7 @@ function DropDownField(props) {
|
|
|
87
87
|
var components = (0, hooks_1.useComponents)();
|
|
88
88
|
// Query state
|
|
89
89
|
var _a = (0, react_1.useState)(''), query = _a[0], setQuery = _a[1];
|
|
90
|
+
var forwardedInputRef = (0, react_1.useRef)(null);
|
|
90
91
|
var hasGroup = !!props.groupAttribute;
|
|
91
92
|
var _b = react_1["default"].useState([]), selectedAccordionItems = _b[0], setSelectedAccordionItems = _b[1];
|
|
92
93
|
var normalizedItemToSelectAll = react_1["default"].useMemo(function () { return normalizeItemToSelectAll(props.itemToSelectAll); }, [props.itemToSelectAll]);
|
|
@@ -123,7 +124,8 @@ function DropDownField(props) {
|
|
|
123
124
|
groupAttribute: props.groupAttribute,
|
|
124
125
|
items: items,
|
|
125
126
|
sourceItems: sourceItems,
|
|
126
|
-
inputValue: props.input.value
|
|
127
|
+
inputValue: props.input.value,
|
|
128
|
+
autoCompleteInputRef: forwardedInputRef
|
|
127
129
|
}), isOpened = _d.isOpened, setIsOpened = _d.setIsOpened, setIsFocused = _d.setIsFocused, hoveredId = _d.hoveredId, setHoveredId = _d.setHoveredId, selectedIds = _d.selectedIds, setSelectedIds = _d.setSelectedIds, selectedItems = _d.selectedItems, setSelectedAll = _d.setSelectedAll, isSelectedAll = _d.isSelectedAll;
|
|
128
130
|
var onOpen = (0, react_1.useCallback)(function () {
|
|
129
131
|
setQuery('');
|
|
@@ -226,7 +228,7 @@ function DropDownField(props) {
|
|
|
226
228
|
}
|
|
227
229
|
return renderItemView(item, 'default', null);
|
|
228
230
|
};
|
|
229
|
-
var viewProps = (0, react_1.useMemo)(function () { return (__assign({ isAutoComplete: isAutoComplete, items: items, hoveredId: hoveredId, selectedIds: selectedIds, forwardedRef: forwardedRef, searchInputProps: searchInputProps, isOpened: isOpened, isLoading: isLoading, onOpen: onOpen, selectedItems: selectedItems,
|
|
231
|
+
var viewProps = (0, react_1.useMemo)(function () { return (__assign({ isAutoComplete: isAutoComplete, items: items, hoveredId: hoveredId, selectedIds: selectedIds, forwardedRef: forwardedRef, forwardedInputRef: forwardedInputRef, searchInputProps: searchInputProps, isOpened: isOpened, isLoading: isLoading, onOpen: onOpen, selectedItems: selectedItems,
|
|
230
232
|
// TODO onFocus
|
|
231
233
|
// TODO onBlur
|
|
232
234
|
onReset: onReset, onClose: onClose, renderItem: renderItem, onItemRemove: onItemRemove, hasGroup: hasGroup, multiple: props.multiple, isSearchAutoFocus: props.isSearchAutoFocus, itemToSelectAll: normalizedItemToSelectAll, className: props.className, viewProps: props.viewProps, style: props.style, size: props.size, color: props.color, outline: props.outline, placeholder: props.placeholder, showReset: props.showReset, showEllipses: props.showEllipses, errors: props.errors, disabled: props.disabled }, dataProvider)); }, [isAutoComplete, items, hoveredId, selectedIds, searchInputProps, isOpened, isLoading, onOpen, selectedItems, onReset, onClose,
|
|
@@ -33,15 +33,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
33
|
__setModuleDefault(result, mod);
|
|
34
34
|
return result;
|
|
35
35
|
};
|
|
36
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
-
if (ar || !(i in from)) {
|
|
39
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
-
ar[i] = from[i];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
|
-
};
|
|
45
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
38
|
};
|
|
@@ -49,8 +40,6 @@ exports.__esModule = true;
|
|
|
49
40
|
var react_1 = __importStar(require("react"));
|
|
50
41
|
var isBoolean_1 = __importDefault(require("lodash-es/isBoolean"));
|
|
51
42
|
var range_1 = __importDefault(require("lodash-es/range"));
|
|
52
|
-
var concat_1 = __importDefault(require("lodash-es/concat"));
|
|
53
|
-
var last_1 = __importDefault(require("lodash-es/last"));
|
|
54
43
|
var isEmpty_1 = __importDefault(require("lodash-es/isEmpty"));
|
|
55
44
|
var get_1 = __importDefault(require("lodash-es/get"));
|
|
56
45
|
var react_use_1 = require("react-use");
|
|
@@ -68,26 +57,15 @@ function FieldList(props) {
|
|
|
68
57
|
var isWithReduxForm = (0, hooks_1.useSelector)(function (state) { return (0, get_1["default"])(state, ['form', context.formId]) || null; });
|
|
69
58
|
var dispatch = context.provider.useDispatch();
|
|
70
59
|
// Mapper for preserving the correct sequence of rows on the UI
|
|
71
|
-
var
|
|
72
|
-
var addRowIndexes = (0, react_1.useCallback)(function (rowsCount) {
|
|
73
|
-
setStoreToRowIndexMap(function (prevMap) {
|
|
74
|
-
var lastIndex = !(0, isEmpty_1["default"])(prevMap) ? (0, last_1["default"])(prevMap) + 1 : 0;
|
|
75
|
-
return (0, concat_1["default"])(prevMap, (0, range_1["default"])(lastIndex, lastIndex + rowsCount));
|
|
76
|
-
});
|
|
77
|
-
}, []);
|
|
78
|
-
var removeRowIndex = (0, react_1.useCallback)(function (rowIndex) {
|
|
79
|
-
setStoreToRowIndexMap(function (prevMap) { return __spreadArray(__spreadArray([], prevMap.slice(0, rowIndex), true), prevMap.slice(rowIndex + 1), true); });
|
|
80
|
-
}, []);
|
|
60
|
+
var storeToRowIndexMap = (0, react_1.useMemo)(function () { return (0, range_1["default"])(props.input.value || 0); }, [props.input.value]);
|
|
81
61
|
// Add and Remove handlers
|
|
82
62
|
var onAdd = (0, react_1.useCallback)(function (rowsCount) {
|
|
83
63
|
if (rowsCount === void 0) { rowsCount = 1; }
|
|
84
|
-
addRowIndexes(rowsCount);
|
|
85
64
|
dispatch((0, form_1.formArrayAdd)(context.formId, props.input.name, rowsCount, props.initialValues));
|
|
86
|
-
}, [context.formId, dispatch, props.initialValues, props.input.name
|
|
65
|
+
}, [context.formId, dispatch, props.initialValues, props.input.name]);
|
|
87
66
|
var onRemove = (0, react_1.useCallback)(function (rowIndex) {
|
|
88
|
-
removeRowIndex(rowIndex);
|
|
89
67
|
dispatch((0, form_1.formArrayRemove)(context.formId, props.input.name, rowIndex));
|
|
90
|
-
}, [context.formId, dispatch, props.input.name
|
|
68
|
+
}, [context.formId, dispatch, props.input.name]);
|
|
91
69
|
(0, react_use_1.useMount)(function () {
|
|
92
70
|
// Add initial rows
|
|
93
71
|
if (!props.input.value) {
|