@steroidsjs/core 3.0.17 → 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/docs-autogen-result.json +20 -1
- package/en.json +1 -0
- package/hooks/useDataProvider.js +12 -7
- package/package.json +1 -1
- package/ui/form/Form/Form.d.ts +5 -0
- package/ui/form/Form/Form.js +7 -2
- 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/docs-autogen-result.json
CHANGED
|
@@ -22134,7 +22134,8 @@
|
|
|
22134
22134
|
"actionMethod": "'POST'",
|
|
22135
22135
|
"autoStartTwoFactor": "true",
|
|
22136
22136
|
"captchaActionName": "'submit'",
|
|
22137
|
-
"size": "'md'"
|
|
22137
|
+
"size": "'md'",
|
|
22138
|
+
"useClearErrors": "true"
|
|
22138
22139
|
},
|
|
22139
22140
|
"extends": [
|
|
22140
22141
|
"IUiComponent"
|
|
@@ -22320,6 +22321,15 @@
|
|
|
22320
22321
|
"example": "Submit",
|
|
22321
22322
|
"defaultValue": null
|
|
22322
22323
|
},
|
|
22324
|
+
{
|
|
22325
|
+
"name": "useClearErrors",
|
|
22326
|
+
"decorators": [],
|
|
22327
|
+
"description": "Очищать сообщение об ошибке при редактировании поля. По-умолчанию включено",
|
|
22328
|
+
"required": false,
|
|
22329
|
+
"type": "boolean",
|
|
22330
|
+
"example": null,
|
|
22331
|
+
"defaultValue": "true"
|
|
22332
|
+
},
|
|
22323
22333
|
{
|
|
22324
22334
|
"name": "useRedux",
|
|
22325
22335
|
"decorators": [],
|
|
@@ -36612,6 +36622,15 @@
|
|
|
36612
36622
|
"example": "Submit",
|
|
36613
36623
|
"defaultValue": null
|
|
36614
36624
|
},
|
|
36625
|
+
{
|
|
36626
|
+
"name": "useClearErrors",
|
|
36627
|
+
"decorators": [],
|
|
36628
|
+
"description": "Очищать сообщение об ошибке при редактировании поля. По-умолчанию включено",
|
|
36629
|
+
"required": false,
|
|
36630
|
+
"type": "boolean",
|
|
36631
|
+
"example": null,
|
|
36632
|
+
"defaultValue": null
|
|
36633
|
+
},
|
|
36615
36634
|
{
|
|
36616
36635
|
"name": "useRedux",
|
|
36617
36636
|
"decorators": [],
|
package/en.json
CHANGED
|
@@ -999,6 +999,7 @@
|
|
|
999
999
|
"Отображать чекбоксы только на узлах, не имеющих вложенных элементов": "",
|
|
1000
1000
|
"Размер компонента и вложенных полей": "",
|
|
1001
1001
|
"Параметры для кнопки отправки формы": "",
|
|
1002
|
+
"Очищать сообщение об ошибке при редактировании поля. По-умолчанию включено": "",
|
|
1002
1003
|
"Конструктор редактора 'ckeditor5-react' из библиотеки @steroidsjs/ckeditor5/packages/ckeditor5-build-classic\nПримечание: для использования встроенного отображения 'HtmlField', данный компонент должен быть передан": "",
|
|
1003
1004
|
"Компонент редактора 'ckeditor5-react' из библиотеки @ckeditor\nПримечание: для использования встроенного отображения 'HtmlField', данный компонент должен быть передан": "",
|
|
1004
1005
|
"Допустимое количество символов после разделителя": "",
|
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
package/ui/form/Form/Form.d.ts
CHANGED
|
@@ -166,6 +166,10 @@ export interface IFormProps extends IUiComponent {
|
|
|
166
166
|
* Размер компонента и вложенных полей
|
|
167
167
|
*/
|
|
168
168
|
size?: Size;
|
|
169
|
+
/**
|
|
170
|
+
* Очищать сообщение об ошибке при редактировании поля. По-умолчанию включено
|
|
171
|
+
*/
|
|
172
|
+
useClearErrors?: boolean;
|
|
169
173
|
[key: string]: any;
|
|
170
174
|
}
|
|
171
175
|
export interface IFormViewProps {
|
|
@@ -229,6 +233,7 @@ declare namespace Form {
|
|
|
229
233
|
autoStartTwoFactor: boolean;
|
|
230
234
|
captchaActionName: string;
|
|
231
235
|
size: string;
|
|
236
|
+
useClearErrors: boolean;
|
|
232
237
|
};
|
|
233
238
|
}
|
|
234
239
|
export default Form;
|
package/ui/form/Form/Form.js
CHANGED
|
@@ -147,7 +147,11 @@ function Form(props) {
|
|
|
147
147
|
});
|
|
148
148
|
// Clear Errors
|
|
149
149
|
var prevValues = (0, react_use_1.usePrevious)(values);
|
|
150
|
-
(0, react_use_1.useUpdateEffect)(function () {
|
|
150
|
+
(0, react_use_1.useUpdateEffect)(function () {
|
|
151
|
+
if (props.useClearErrors) {
|
|
152
|
+
(0, form_1.clearErrors)(values, prevValues, errors, setErrors);
|
|
153
|
+
}
|
|
154
|
+
}, [props.useClearErrors, errors, prevValues, setErrors, values]);
|
|
151
155
|
// OnChange handler
|
|
152
156
|
(0, react_use_1.useUpdateEffect)(function () {
|
|
153
157
|
if (props.onChange) {
|
|
@@ -336,6 +340,7 @@ Form.defaultProps = {
|
|
|
336
340
|
actionMethod: 'POST',
|
|
337
341
|
autoStartTwoFactor: true,
|
|
338
342
|
captchaActionName: 'submit',
|
|
339
|
-
size: 'md'
|
|
343
|
+
size: 'md',
|
|
344
|
+
useClearErrors: true
|
|
340
345
|
};
|
|
341
346
|
exports["default"] = Form;
|
|
@@ -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
|
}
|