@steroidsjs/core 3.0.18 → 3.0.19
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/README.md +8 -0
- package/hooks/useDataProvider.js +12 -7
- package/package.json +1 -1
- package/ui/form/TextField/TextField.js +2 -2
package/README.md
CHANGED
|
@@ -24,3 +24,11 @@ Our Open-Source **Steroids** framework is an ecosystem based on React and Redux
|
|
|
24
24
|
|
|
25
25
|
Explore and immerse yourself in the world of rapid development through documentation [Documentation](https://steroids.kozhin.dev/ru/docs/getting-started).
|
|
26
26
|
|
|
27
|
+
## Directions for applied use of the Steroids framework
|
|
28
|
+
|
|
29
|
+
- Creation of various websites (for example, an online store website)
|
|
30
|
+
- Creation of CRM and ERP systems
|
|
31
|
+
- Creation of SPA applications
|
|
32
|
+
- Creation of admin panels
|
|
33
|
+
- Creation of personal accounts
|
|
34
|
+
|
package/hooks/useDataProvider.js
CHANGED
|
@@ -86,7 +86,7 @@ var defaultProps = {
|
|
|
86
86
|
*/
|
|
87
87
|
function useDataProvider(config) {
|
|
88
88
|
var _this = this;
|
|
89
|
-
var _a;
|
|
89
|
+
var _a, _b;
|
|
90
90
|
var components = (0, index_1.useComponents)();
|
|
91
91
|
var dispatch = (0, index_1.useDispatch)();
|
|
92
92
|
var reduxDataProviderId = (_a = config.dataProvider) === null || _a === void 0 ? void 0 : _a.reduxId;
|
|
@@ -95,10 +95,10 @@ function useDataProvider(config) {
|
|
|
95
95
|
// Initial items
|
|
96
96
|
var initialItems = (0, data_1.normalizeItems)(enumItems || config.items);
|
|
97
97
|
// Items state
|
|
98
|
-
var
|
|
99
|
-
var
|
|
98
|
+
var _c = (0, react_1.useState)(initialItems), items = _c[0], setItems = _c[1];
|
|
99
|
+
var _d = (0, react_1.useState)(false), isLoading = _d[0], setIsLoading = _d[1];
|
|
100
100
|
// Source items state (redux or local)
|
|
101
|
-
var
|
|
101
|
+
var _e = (0, react_1.useState)(initialItems), sourceInternalItems = _e[0], setSourceInternalItems = _e[1];
|
|
102
102
|
var sourceReduxItems = (0, react_redux_1.useSelector)(function (state) { return (0, fields_2.getDataProviderItems)(state, reduxDataProviderId); });
|
|
103
103
|
var sourceItems = reduxDataProviderId ? sourceReduxItems : sourceInternalItems;
|
|
104
104
|
var setSourceItems = (0, react_1.useCallback)(function (value) {
|
|
@@ -125,7 +125,9 @@ function useDataProvider(config) {
|
|
|
125
125
|
var prevQuery = (0, react_use_1.usePrevious)(config.query);
|
|
126
126
|
var prevParams = (0, react_use_1.usePrevious)(dataProvider.params);
|
|
127
127
|
var prevValues = (0, react_use_1.usePrevious)(config.initialSelectedIds);
|
|
128
|
+
var prevAction = (0, react_use_1.usePrevious)((_b = config === null || config === void 0 ? void 0 : config.dataProvider) === null || _b === void 0 ? void 0 : _b.action);
|
|
128
129
|
(0, react_1.useEffect)(function () {
|
|
130
|
+
var _a;
|
|
129
131
|
var fetchRemote = function (isAuto) { return __awaiter(_this, void 0, void 0, function () {
|
|
130
132
|
var searchHandler, result, newItems;
|
|
131
133
|
var _a;
|
|
@@ -169,6 +171,10 @@ function useDataProvider(config) {
|
|
|
169
171
|
fetchRemote(false);
|
|
170
172
|
}
|
|
171
173
|
else if (autoComplete.enable || (config.autoFetch && isAutoFetchedRef.current === true)) {
|
|
174
|
+
// Fetch data when action changes
|
|
175
|
+
if (prevAction !== ((_a = config === null || config === void 0 ? void 0 : config.dataProvider) === null || _a === void 0 ? void 0 : _a.action)) {
|
|
176
|
+
fetchRemote(false);
|
|
177
|
+
}
|
|
172
178
|
if (delayTimerRef.current) {
|
|
173
179
|
clearTimeout(delayTimerRef.current);
|
|
174
180
|
}
|
|
@@ -178,9 +184,8 @@ function useDataProvider(config) {
|
|
|
178
184
|
delayTimerRef.current = setTimeout(fetchRemote, autoComplete.delay);
|
|
179
185
|
}
|
|
180
186
|
}
|
|
181
|
-
}, [autoComplete, components.http, config.autoFetch,
|
|
182
|
-
|
|
183
|
-
dataProvider.action, dataProvider.onSearch, prevParams, prevQuery, prevValues, setSourceItems, sourceItems]);
|
|
187
|
+
}, [autoComplete, components.http, config.autoFetch, config.dataProvider, config.initialSelectedIds, config.query, dataProvider,
|
|
188
|
+
dataProvider.action, dataProvider.onSearch, prevAction, prevParams, prevQuery, prevValues, setSourceItems, sourceItems]);
|
|
184
189
|
return {
|
|
185
190
|
sourceItems: sourceItems,
|
|
186
191
|
items: items,
|
package/package.json
CHANGED
|
@@ -35,8 +35,8 @@ function TextField(props) {
|
|
|
35
35
|
var onClear = (0, react_1.useCallback)(function () { return props.input.onChange(''); }, [props.input]);
|
|
36
36
|
var inputProps = (0, react_1.useMemo)(function () {
|
|
37
37
|
var _a;
|
|
38
|
-
return (__assign({ name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onChange: handleChange, onKeyUp: onKeyUp, placeholder: props.placeholder, disabled: props.disabled, ref: inputRef }, props.inputProps));
|
|
39
|
-
}, [props.input.name, props.input.value, props.placeholder, props.disabled, props.inputProps, handleChange, onKeyUp, inputRef]);
|
|
38
|
+
return (__assign({ name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onChange: handleChange, onKeyUp: onKeyUp, placeholder: props.placeholder, disabled: props.disabled, required: props.required, ref: inputRef }, props.inputProps));
|
|
39
|
+
}, [props.input.name, props.input.value, props.placeholder, props.disabled, props.required, props.inputProps, handleChange, onKeyUp, inputRef]);
|
|
40
40
|
var viewProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props.viewProps), { inputProps: inputProps, onClear: onClear, errors: props.errors, size: props.size, className: props.className, showClear: props.showClear })); }, [inputProps, onClear, props.className, props.errors, props.showClear, props.size, props.viewProps]);
|
|
41
41
|
return components.ui.renderView(props.view || 'form.TextFieldView', viewProps);
|
|
42
42
|
}
|