@steroidsjs/core 3.0.89 → 3.0.91
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 +201 -0
- package/en.json +2 -0
- package/hooks/useSaveCursorPosition.d.ts +16 -3
- package/hooks/useSaveCursorPosition.js +50 -15
- package/package.json +1 -1
- package/ui/form/DropDownField/DropDownField.d.ts +4 -0
- package/ui/form/DropDownField/DropDownField.js +2 -1
- package/ui/form/EmailField/EmailField.js +3 -1
- package/ui/form/InputField/InputField.d.ts +5 -0
- package/ui/form/InputField/InputField.js +8 -6
- package/ui/form/NumberField/NumberField.d.ts +5 -0
- package/ui/form/NumberField/NumberField.js +8 -6
- package/ui/form/PasswordField/PasswordField.js +1 -1
- package/ui/form/TextField/TextField.js +3 -1
- package/ui/layout/Tooltip/Tooltip.d.ts +4 -0
- package/ui/layout/Tooltip/Tooltip.js +1 -1
- package/ui/modal/Modal/Modal.d.ts +4 -0
- package/ui/modal/Modal/Modal.js +3 -3
package/docs-autogen-result.json
CHANGED
|
@@ -4365,6 +4365,81 @@
|
|
|
4365
4365
|
],
|
|
4366
4366
|
"methods": []
|
|
4367
4367
|
},
|
|
4368
|
+
"ISaveCursorPositionConfig": {
|
|
4369
|
+
"name": "ISaveCursorPositionConfig",
|
|
4370
|
+
"moduleName": "hooks/useSaveCursorPosition",
|
|
4371
|
+
"title": "",
|
|
4372
|
+
"description": "",
|
|
4373
|
+
"tags": {},
|
|
4374
|
+
"defaultProps": null,
|
|
4375
|
+
"extends": [],
|
|
4376
|
+
"properties": [
|
|
4377
|
+
{
|
|
4378
|
+
"name": "debounce",
|
|
4379
|
+
"decorators": [],
|
|
4380
|
+
"description": "",
|
|
4381
|
+
"required": false,
|
|
4382
|
+
"type": "ISaveCursorPositionDebounceConfig",
|
|
4383
|
+
"example": null
|
|
4384
|
+
},
|
|
4385
|
+
{
|
|
4386
|
+
"name": "inputParams",
|
|
4387
|
+
"decorators": [],
|
|
4388
|
+
"description": "",
|
|
4389
|
+
"required": true,
|
|
4390
|
+
"type": "IInputParams",
|
|
4391
|
+
"example": null
|
|
4392
|
+
}
|
|
4393
|
+
],
|
|
4394
|
+
"methods": [
|
|
4395
|
+
{
|
|
4396
|
+
"name": "onChangeCallback",
|
|
4397
|
+
"decorators": [],
|
|
4398
|
+
"description": "",
|
|
4399
|
+
"required": false,
|
|
4400
|
+
"type": "void",
|
|
4401
|
+
"example": null,
|
|
4402
|
+
"parameters": [
|
|
4403
|
+
{
|
|
4404
|
+
"name": "value",
|
|
4405
|
+
"decorators": [],
|
|
4406
|
+
"description": "",
|
|
4407
|
+
"required": true,
|
|
4408
|
+
"type": "any",
|
|
4409
|
+
"example": null
|
|
4410
|
+
}
|
|
4411
|
+
]
|
|
4412
|
+
}
|
|
4413
|
+
]
|
|
4414
|
+
},
|
|
4415
|
+
"ISaveCursorPositionDebounceConfig": {
|
|
4416
|
+
"name": "ISaveCursorPositionDebounceConfig",
|
|
4417
|
+
"moduleName": "hooks/useSaveCursorPosition",
|
|
4418
|
+
"title": "",
|
|
4419
|
+
"description": "",
|
|
4420
|
+
"tags": {},
|
|
4421
|
+
"defaultProps": null,
|
|
4422
|
+
"extends": [],
|
|
4423
|
+
"properties": [
|
|
4424
|
+
{
|
|
4425
|
+
"name": "delayMs",
|
|
4426
|
+
"decorators": [],
|
|
4427
|
+
"description": "Задержка в мс",
|
|
4428
|
+
"required": false,
|
|
4429
|
+
"type": "number",
|
|
4430
|
+
"example": null
|
|
4431
|
+
},
|
|
4432
|
+
{
|
|
4433
|
+
"name": "enabled",
|
|
4434
|
+
"decorators": [],
|
|
4435
|
+
"description": "",
|
|
4436
|
+
"required": true,
|
|
4437
|
+
"type": "boolean",
|
|
4438
|
+
"example": null
|
|
4439
|
+
}
|
|
4440
|
+
],
|
|
4441
|
+
"methods": []
|
|
4442
|
+
},
|
|
4368
4443
|
"IPreparedTreeItem": {
|
|
4369
4444
|
"name": "IPreparedTreeItem",
|
|
4370
4445
|
"moduleName": "hooks/useTree",
|
|
@@ -7496,6 +7571,14 @@
|
|
|
7496
7571
|
"required": false,
|
|
7497
7572
|
"type": "React.ReactNode | {}",
|
|
7498
7573
|
"example": "MyCustomView"
|
|
7574
|
+
},
|
|
7575
|
+
{
|
|
7576
|
+
"name": "viewProps",
|
|
7577
|
+
"decorators": [],
|
|
7578
|
+
"description": "Свойства для view компонента",
|
|
7579
|
+
"required": false,
|
|
7580
|
+
"type": "any",
|
|
7581
|
+
"example": null
|
|
7499
7582
|
}
|
|
7500
7583
|
],
|
|
7501
7584
|
"methods": [
|
|
@@ -7709,6 +7792,14 @@
|
|
|
7709
7792
|
"required": false,
|
|
7710
7793
|
"type": "React.ReactNode | {}",
|
|
7711
7794
|
"example": "MyCustomView"
|
|
7795
|
+
},
|
|
7796
|
+
{
|
|
7797
|
+
"name": "viewProps",
|
|
7798
|
+
"decorators": [],
|
|
7799
|
+
"description": "Свойства для view компонента",
|
|
7800
|
+
"required": false,
|
|
7801
|
+
"type": "any",
|
|
7802
|
+
"example": null
|
|
7712
7803
|
}
|
|
7713
7804
|
],
|
|
7714
7805
|
"methods": [
|
|
@@ -11243,6 +11334,14 @@
|
|
|
11243
11334
|
"required": false,
|
|
11244
11335
|
"type": "React.ReactNode | {}",
|
|
11245
11336
|
"example": "MyCustomView"
|
|
11337
|
+
},
|
|
11338
|
+
{
|
|
11339
|
+
"name": "viewProps",
|
|
11340
|
+
"decorators": [],
|
|
11341
|
+
"description": "Свойства для view компонента",
|
|
11342
|
+
"required": false,
|
|
11343
|
+
"type": "any",
|
|
11344
|
+
"example": null
|
|
11246
11345
|
}
|
|
11247
11346
|
],
|
|
11248
11347
|
"methods": [
|
|
@@ -11743,6 +11842,14 @@
|
|
|
11743
11842
|
"required": false,
|
|
11744
11843
|
"type": "React.ReactNode | {}",
|
|
11745
11844
|
"example": "MyCustomView"
|
|
11845
|
+
},
|
|
11846
|
+
{
|
|
11847
|
+
"name": "viewProps",
|
|
11848
|
+
"decorators": [],
|
|
11849
|
+
"description": "Свойства для view компонента",
|
|
11850
|
+
"required": false,
|
|
11851
|
+
"type": "any",
|
|
11852
|
+
"example": null
|
|
11746
11853
|
}
|
|
11747
11854
|
],
|
|
11748
11855
|
"methods": [
|
|
@@ -19521,6 +19628,15 @@
|
|
|
19521
19628
|
"example": null,
|
|
19522
19629
|
"defaultValue": null
|
|
19523
19630
|
},
|
|
19631
|
+
{
|
|
19632
|
+
"name": "itemViewProps",
|
|
19633
|
+
"decorators": [],
|
|
19634
|
+
"description": "Пропсы для отображения элемента",
|
|
19635
|
+
"required": false,
|
|
19636
|
+
"type": "any",
|
|
19637
|
+
"example": null,
|
|
19638
|
+
"defaultValue": null
|
|
19639
|
+
},
|
|
19524
19640
|
{
|
|
19525
19641
|
"name": "items",
|
|
19526
19642
|
"decorators": [],
|
|
@@ -20055,6 +20171,14 @@
|
|
|
20055
20171
|
"type": "React.ReactNode | {}",
|
|
20056
20172
|
"example": null
|
|
20057
20173
|
},
|
|
20174
|
+
{
|
|
20175
|
+
"name": "itemViewProps",
|
|
20176
|
+
"decorators": [],
|
|
20177
|
+
"description": "Пропсы для отображения элемента",
|
|
20178
|
+
"required": false,
|
|
20179
|
+
"type": "any",
|
|
20180
|
+
"example": null
|
|
20181
|
+
},
|
|
20058
20182
|
{
|
|
20059
20183
|
"name": "items",
|
|
20060
20184
|
"decorators": [],
|
|
@@ -24544,6 +24668,14 @@
|
|
|
24544
24668
|
"required": false,
|
|
24545
24669
|
"type": "React.ReactNode | {}",
|
|
24546
24670
|
"example": "MyCustomView"
|
|
24671
|
+
},
|
|
24672
|
+
{
|
|
24673
|
+
"name": "viewProps",
|
|
24674
|
+
"decorators": [],
|
|
24675
|
+
"description": "Свойства для view компонента",
|
|
24676
|
+
"required": false,
|
|
24677
|
+
"type": "any",
|
|
24678
|
+
"example": null
|
|
24547
24679
|
}
|
|
24548
24680
|
],
|
|
24549
24681
|
"methods": [
|
|
@@ -25512,6 +25644,15 @@
|
|
|
25512
25644
|
"example": null,
|
|
25513
25645
|
"defaultValue": null
|
|
25514
25646
|
},
|
|
25647
|
+
{
|
|
25648
|
+
"name": "debounce",
|
|
25649
|
+
"decorators": [],
|
|
25650
|
+
"description": "Задержка применения введённого значения",
|
|
25651
|
+
"required": false,
|
|
25652
|
+
"type": "boolean | ISaveCursorPositionDebounceConfig",
|
|
25653
|
+
"example": null,
|
|
25654
|
+
"defaultValue": null
|
|
25655
|
+
},
|
|
25515
25656
|
{
|
|
25516
25657
|
"name": "disabled",
|
|
25517
25658
|
"decorators": [],
|
|
@@ -25819,6 +25960,14 @@
|
|
|
25819
25960
|
"type": "any",
|
|
25820
25961
|
"example": null
|
|
25821
25962
|
},
|
|
25963
|
+
{
|
|
25964
|
+
"name": "debounce",
|
|
25965
|
+
"decorators": [],
|
|
25966
|
+
"description": "Задержка применения введённого значения",
|
|
25967
|
+
"required": false,
|
|
25968
|
+
"type": "boolean | ISaveCursorPositionDebounceConfig",
|
|
25969
|
+
"example": null
|
|
25970
|
+
},
|
|
25822
25971
|
{
|
|
25823
25972
|
"name": "defaultValue",
|
|
25824
25973
|
"decorators": [],
|
|
@@ -26168,6 +26317,15 @@
|
|
|
26168
26317
|
"example": null,
|
|
26169
26318
|
"defaultValue": null
|
|
26170
26319
|
},
|
|
26320
|
+
{
|
|
26321
|
+
"name": "debounce",
|
|
26322
|
+
"decorators": [],
|
|
26323
|
+
"description": "Задержка применения введённого значения",
|
|
26324
|
+
"required": false,
|
|
26325
|
+
"type": "boolean | ISaveCursorPositionDebounceConfig",
|
|
26326
|
+
"example": null,
|
|
26327
|
+
"defaultValue": null
|
|
26328
|
+
},
|
|
26171
26329
|
{
|
|
26172
26330
|
"name": "disabled",
|
|
26173
26331
|
"decorators": [],
|
|
@@ -26751,6 +26909,15 @@
|
|
|
26751
26909
|
"example": null,
|
|
26752
26910
|
"defaultValue": null
|
|
26753
26911
|
},
|
|
26912
|
+
{
|
|
26913
|
+
"name": "debounce",
|
|
26914
|
+
"decorators": [],
|
|
26915
|
+
"description": "Задержка применения введённого значения",
|
|
26916
|
+
"required": false,
|
|
26917
|
+
"type": "boolean | ISaveCursorPositionDebounceConfig",
|
|
26918
|
+
"example": null,
|
|
26919
|
+
"defaultValue": null
|
|
26920
|
+
},
|
|
26754
26921
|
{
|
|
26755
26922
|
"name": "decimal",
|
|
26756
26923
|
"decorators": [],
|
|
@@ -27042,6 +27209,14 @@
|
|
|
27042
27209
|
"type": "any",
|
|
27043
27210
|
"example": null
|
|
27044
27211
|
},
|
|
27212
|
+
{
|
|
27213
|
+
"name": "debounce",
|
|
27214
|
+
"decorators": [],
|
|
27215
|
+
"description": "Задержка применения введённого значения",
|
|
27216
|
+
"required": false,
|
|
27217
|
+
"type": "boolean | ISaveCursorPositionDebounceConfig",
|
|
27218
|
+
"example": null
|
|
27219
|
+
},
|
|
27045
27220
|
{
|
|
27046
27221
|
"name": "decimal",
|
|
27047
27222
|
"decorators": [],
|
|
@@ -33395,6 +33570,15 @@
|
|
|
33395
33570
|
"type": "ITooltipStylePosition",
|
|
33396
33571
|
"example": null,
|
|
33397
33572
|
"defaultValue": null
|
|
33573
|
+
},
|
|
33574
|
+
{
|
|
33575
|
+
"name": "viewProps",
|
|
33576
|
+
"decorators": [],
|
|
33577
|
+
"description": "Пропсы для отображения элемента",
|
|
33578
|
+
"required": false,
|
|
33579
|
+
"type": "any",
|
|
33580
|
+
"example": null,
|
|
33581
|
+
"defaultValue": null
|
|
33398
33582
|
}
|
|
33399
33583
|
],
|
|
33400
33584
|
"methods": [
|
|
@@ -33552,6 +33736,14 @@
|
|
|
33552
33736
|
"required": true,
|
|
33553
33737
|
"type": "ITooltipStylePosition",
|
|
33554
33738
|
"example": null
|
|
33739
|
+
},
|
|
33740
|
+
{
|
|
33741
|
+
"name": "viewProps",
|
|
33742
|
+
"decorators": [],
|
|
33743
|
+
"description": "Пропсы для отображения элемента",
|
|
33744
|
+
"required": false,
|
|
33745
|
+
"type": "any",
|
|
33746
|
+
"example": null
|
|
33555
33747
|
}
|
|
33556
33748
|
],
|
|
33557
33749
|
"methods": [
|
|
@@ -37957,6 +38149,15 @@
|
|
|
37957
38149
|
"type": "React.ReactNode | {}",
|
|
37958
38150
|
"example": "MyCustomView",
|
|
37959
38151
|
"defaultValue": null
|
|
38152
|
+
},
|
|
38153
|
+
{
|
|
38154
|
+
"name": "viewProps",
|
|
38155
|
+
"decorators": [],
|
|
38156
|
+
"description": "Свойства для view компонента",
|
|
38157
|
+
"required": false,
|
|
38158
|
+
"type": "any",
|
|
38159
|
+
"example": null,
|
|
38160
|
+
"defaultValue": null
|
|
37960
38161
|
}
|
|
37961
38162
|
],
|
|
37962
38163
|
"methods": [
|
package/en.json
CHANGED
|
@@ -1047,5 +1047,7 @@
|
|
|
1047
1047
|
"Логическое значение, указывающее, есть ли еще элементы в списке с бесконечным скроллом": "",
|
|
1048
1048
|
"Кастомный домен для куки": "",
|
|
1049
1049
|
" Автоматически устанавливает куку для всех поддоменов текущего домена,\n но только если параметр domain не указан явно": "",
|
|
1050
|
+
"Задержка в мс": "",
|
|
1051
|
+
"Задержка применения введённого значения": "",
|
|
1050
1052
|
"Флаг, который указывает, что высота поля должна быть равна высоте контента": ""
|
|
1051
1053
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ChangeEvent } from 'react';
|
|
2
2
|
import { IInputParams } from '../ui/form/Field/fieldWrapper';
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export interface ISaveCursorPositionDebounceConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Задержка в мс
|
|
6
|
+
*/
|
|
7
|
+
delayMs?: number;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ISaveCursorPositionConfig {
|
|
11
|
+
inputParams: IInputParams;
|
|
12
|
+
onChangeCallback?: (value: any) => void;
|
|
13
|
+
debounce?: ISaveCursorPositionDebounceConfig;
|
|
14
|
+
}
|
|
15
|
+
export default function useSaveCursorPosition(config: ISaveCursorPositionConfig): {
|
|
16
|
+
inputRef: import("react").MutableRefObject<any>;
|
|
5
17
|
onChange: (event: ChangeEvent<HTMLInputElement>, value?: any) => void;
|
|
18
|
+
value: any;
|
|
6
19
|
};
|
|
@@ -3,17 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
/* eslint-disable max-len */
|
|
7
|
-
/* eslint-disable no-unneeded-ternary */
|
|
8
6
|
/* eslint-disable consistent-return */
|
|
9
7
|
/* eslint-disable no-return-assign */
|
|
10
8
|
/* eslint-disable no-unused-expressions */
|
|
11
|
-
var react_1 =
|
|
9
|
+
var react_1 = require("react");
|
|
10
|
+
var debounce_1 = __importDefault(require("lodash-es/debounce"));
|
|
12
11
|
var isNull_1 = __importDefault(require("lodash-es/isNull"));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
react_1
|
|
12
|
+
var DEFAULT_DEBOUNCE_DELAY_MS = 300;
|
|
13
|
+
function useSaveCursorPosition(config) {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
var _d = (0, react_1.useState)(null), cursor = _d[0], setCursor = _d[1];
|
|
16
|
+
var inputRef = (0, react_1.useRef)(null);
|
|
17
|
+
var _e = (0, react_1.useState)((_a = config.inputParams.value) !== null && _a !== void 0 ? _a : ''), localValue = _e[0], setLocalValue = _e[1];
|
|
18
|
+
(0, react_1.useEffect)(function () {
|
|
17
19
|
var el = inputRef.current;
|
|
18
20
|
if (!el || (0, isNull_1["default"])(cursor)) {
|
|
19
21
|
return;
|
|
@@ -25,19 +27,52 @@ function useSaveCursorPosition(inputParams, onChangeCallback) {
|
|
|
25
27
|
catch (e) {
|
|
26
28
|
console.error(e);
|
|
27
29
|
}
|
|
28
|
-
}, [cursor,
|
|
29
|
-
|
|
30
|
+
}, [cursor, localValue]);
|
|
31
|
+
/**
|
|
32
|
+
* Синхронизация ТОЛЬКО при внешнем reset (например, очистка формы)
|
|
33
|
+
*/
|
|
34
|
+
(0, react_1.useEffect)(function () {
|
|
35
|
+
var _a;
|
|
36
|
+
if (config.inputParams.value !== localValue) {
|
|
37
|
+
setLocalValue((_a = config.inputParams.value) !== null && _a !== void 0 ? _a : '');
|
|
38
|
+
}
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [config.inputParams.value]);
|
|
41
|
+
/**
|
|
42
|
+
* Создаём debounce только при смене delay или enabled.
|
|
43
|
+
* onChange и onChangeCallback не добавляем в зависимости,
|
|
44
|
+
* чтобы debounce не пересоздавался каждый рендер.
|
|
45
|
+
*/
|
|
46
|
+
var debouncedCommit = (0, react_1.useMemo)(function () {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
if (!((_a = config.debounce) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return (0, debounce_1["default"])(function (value) {
|
|
52
|
+
var _a;
|
|
53
|
+
config.inputParams.onChange(value);
|
|
54
|
+
(_a = config.onChangeCallback) === null || _a === void 0 ? void 0 : _a.call(config, value);
|
|
55
|
+
}, (_b = config.debounce.delayMs) !== null && _b !== void 0 ? _b : DEFAULT_DEBOUNCE_DELAY_MS);
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
}, [(_b = config.debounce) === null || _b === void 0 ? void 0 : _b.enabled, (_c = config.debounce) === null || _c === void 0 ? void 0 : _c.delayMs]);
|
|
58
|
+
var onChange = (0, react_1.useCallback)(function (event, value) {
|
|
30
59
|
var _a, _b, _c;
|
|
31
60
|
if (value === void 0) { value = null; }
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
var val = value !== null && value !== void 0 ? value : event.target.value;
|
|
62
|
+
setCursor((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.selectionStart);
|
|
63
|
+
setLocalValue(val);
|
|
64
|
+
if ((_b = config.debounce) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
65
|
+
debouncedCommit(val);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
config.inputParams.onChange(val);
|
|
69
|
+
(_c = config.onChangeCallback) === null || _c === void 0 ? void 0 : _c.call(config, val);
|
|
34
70
|
}
|
|
35
|
-
|
|
36
|
-
inputParams.onChange(value || ((_c = event.target) === null || _c === void 0 ? void 0 : _c.value));
|
|
37
|
-
}, [inputParams, onChangeCallback]);
|
|
71
|
+
}, [config, debouncedCommit]);
|
|
38
72
|
return {
|
|
39
73
|
inputRef: inputRef,
|
|
40
|
-
onChange: onChange
|
|
74
|
+
onChange: onChange,
|
|
75
|
+
value: localValue
|
|
41
76
|
};
|
|
42
77
|
}
|
|
43
78
|
exports["default"] = useSaveCursorPosition;
|
package/package.json
CHANGED
|
@@ -174,6 +174,10 @@ export interface IDropDownFieldProps extends IFieldWrapperInputProps, Omit<IData
|
|
|
174
174
|
* Сигнал, запрещающий отправку запроса на получение данных
|
|
175
175
|
*/
|
|
176
176
|
isFetchDisabled?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Пропсы для отображения элемента
|
|
179
|
+
*/
|
|
180
|
+
itemViewProps?: CustomViewProps;
|
|
177
181
|
[key: string]: any;
|
|
178
182
|
}
|
|
179
183
|
export interface IDropDownFieldViewProps extends IDropDownFieldProps {
|
|
@@ -228,7 +228,8 @@ function DropDownField(props) {
|
|
|
228
228
|
childIndex: item.id,
|
|
229
229
|
toggleCollapse: toggleCollapse,
|
|
230
230
|
isItemToSelectAll: item.id === (normalizedItemToSelectAll === null || normalizedItemToSelectAll === void 0 ? void 0 : normalizedItemToSelectAll.id),
|
|
231
|
-
isSelectedAll: isSelectedAll
|
|
231
|
+
isSelectedAll: isSelectedAll,
|
|
232
|
+
itemViewProps: props.itemViewProps
|
|
232
233
|
}); };
|
|
233
234
|
var renderItem = (0, react_1.useCallback)(function (item) {
|
|
234
235
|
if (hasGroup && Array.isArray(item[props.groupAttribute])) {
|
|
@@ -44,7 +44,9 @@ var useInputTypeEmail_1 = __importDefault(require("./hooks/useInputTypeEmail"));
|
|
|
44
44
|
var enums_1 = require("../../../enums");
|
|
45
45
|
function EmailField(props) {
|
|
46
46
|
var components = (0, hooks_1.useComponents)();
|
|
47
|
-
var _a = (0, hooks_1.useSaveCursorPosition)(
|
|
47
|
+
var _a = (0, hooks_1.useSaveCursorPosition)({
|
|
48
|
+
inputParams: props.input
|
|
49
|
+
}), currentInputRef = _a.inputRef, onChange = _a.onChange;
|
|
48
50
|
var onInputChange = (0, useInputTypeEmail_1["default"])(currentInputRef, onChange, props.input.value, props.required).onInputChange;
|
|
49
51
|
var onClear = react_1["default"].useCallback(function () { return props.input.onChange(''); }, [props.input]);
|
|
50
52
|
var inputProps = react_1["default"].useMemo(function () {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InputHTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
import { MaskitoOptions } from '@maskito/core';
|
|
4
|
+
import { ISaveCursorPositionDebounceConfig } from '@steroidsjs/core/hooks/useSaveCursorPosition';
|
|
4
5
|
import { IFieldWrapperInputProps, IFieldWrapperOutputProps } from '../Field/fieldWrapper';
|
|
5
6
|
export declare const MASK_PRESETS: {
|
|
6
7
|
date: Required<MaskitoOptions>;
|
|
@@ -87,6 +88,10 @@ export interface IInputFieldProps extends IBaseFieldProps {
|
|
|
87
88
|
* Пользовательская иконка svg или название иконки
|
|
88
89
|
*/
|
|
89
90
|
leadIcon?: React.ReactElement | string;
|
|
91
|
+
/**
|
|
92
|
+
* Задержка применения введённого значения
|
|
93
|
+
*/
|
|
94
|
+
debounce?: boolean | ISaveCursorPositionDebounceConfig;
|
|
90
95
|
}
|
|
91
96
|
export interface IInputFieldViewProps extends IInputFieldProps, IFieldWrapperOutputProps {
|
|
92
97
|
inputProps: {
|
|
@@ -87,11 +87,16 @@ exports.MASK_PRESETS = {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
function InputField(props) {
|
|
90
|
+
var _a;
|
|
90
91
|
var components = (0, hooks_1.useComponents)();
|
|
91
92
|
var maskedInputRef = (0, react_2.useMaskito)({
|
|
92
93
|
options: props.maskOptions
|
|
93
94
|
});
|
|
94
|
-
var
|
|
95
|
+
var _b = (0, hooks_1.useSaveCursorPosition)({
|
|
96
|
+
inputParams: props.input,
|
|
97
|
+
onChangeCallback: props.onChange,
|
|
98
|
+
debounce: __assign({ enabled: !!props.debounce }, (typeof props.debounce === 'boolean' ? { enabled: props.debounce } : ((_a = props.debounce) !== null && _a !== void 0 ? _a : {})))
|
|
99
|
+
}), inputRef = _b.inputRef, onChange = _b.onChange, value = _b.value;
|
|
95
100
|
React.useEffect(function () {
|
|
96
101
|
if (inputRef.current) {
|
|
97
102
|
maskedInputRef(inputRef.current);
|
|
@@ -103,11 +108,8 @@ function InputField(props) {
|
|
|
103
108
|
props.onClear('');
|
|
104
109
|
}
|
|
105
110
|
props.input.onChange('');
|
|
106
|
-
}, [props
|
|
107
|
-
var inputProps = (0, react_1.useMemo)(function () {
|
|
108
|
-
var _a;
|
|
109
|
-
return (__assign({ type: props.type, name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onInput: onChange, placeholder: props.placeholder }, props.inputProps));
|
|
110
|
-
}, [onChange, props.input.name, props.input.value, props.inputProps, props.placeholder, props.type]);
|
|
111
|
+
}, [props]);
|
|
112
|
+
var inputProps = (0, react_1.useMemo)(function () { return (__assign({ type: props.type, name: props.input.name, value: value, onInput: onChange, placeholder: props.placeholder }, props.inputProps)); }, [value, onChange, props.input.name, props.inputProps, props.placeholder, props.type]);
|
|
111
113
|
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
112
114
|
inputRef: useInputFieldWarningByType_1.INPUT_TYPES_SUPPORTED_SELECTION.includes(props.type) ? inputRef : null,
|
|
113
115
|
onClear: onClear,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { ChangeEvent } from 'react';
|
|
2
|
+
import { ISaveCursorPositionDebounceConfig } from '@steroidsjs/core/hooks/useSaveCursorPosition';
|
|
2
3
|
import { IBaseFieldProps } from '../InputField/InputField';
|
|
3
4
|
import { IFieldWrapperInputProps, IFieldWrapperOutputProps } from '../Field/fieldWrapper';
|
|
4
5
|
/**
|
|
@@ -30,6 +31,10 @@ export interface INumberFieldProps extends IFieldWrapperInputProps, IBaseFieldPr
|
|
|
30
31
|
* Может ли число быть отрицательным
|
|
31
32
|
*/
|
|
32
33
|
isCanBeNegative?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Задержка применения введённого значения
|
|
36
|
+
*/
|
|
37
|
+
debounce?: boolean | ISaveCursorPositionDebounceConfig;
|
|
33
38
|
}
|
|
34
39
|
export interface INumberFieldViewProps extends INumberFieldProps, IFieldWrapperOutputProps {
|
|
35
40
|
inputProps: {
|
|
@@ -45,8 +45,13 @@ var useInputTypeNumber_1 = __importDefault(require("./hooks/useInputTypeNumber")
|
|
|
45
45
|
var enums_1 = require("../../../enums");
|
|
46
46
|
var DEFAULT_STEP = 1;
|
|
47
47
|
function NumberField(props) {
|
|
48
|
+
var _a;
|
|
48
49
|
var components = (0, hooks_1.useComponents)();
|
|
49
|
-
var
|
|
50
|
+
var _b = (0, hooks_1.useSaveCursorPosition)({
|
|
51
|
+
inputParams: props.input,
|
|
52
|
+
onChangeCallback: props.onChange,
|
|
53
|
+
debounce: __assign({ enabled: !!props.debounce }, (typeof props.debounce === 'boolean' ? { enabled: props.debounce } : ((_a = props.debounce) !== null && _a !== void 0 ? _a : {})))
|
|
54
|
+
}), currentInputRef = _b.inputRef, onChange = _b.onChange, value = _b.value;
|
|
50
55
|
var step = react_1["default"].useMemo(function () { var _a; return (_a = props.step) !== null && _a !== void 0 ? _a : DEFAULT_STEP; }, [props.step]);
|
|
51
56
|
var onInputChange = (0, useInputTypeNumber_1["default"])(currentInputRef, {
|
|
52
57
|
max: props.max,
|
|
@@ -58,7 +63,7 @@ function NumberField(props) {
|
|
|
58
63
|
var _a;
|
|
59
64
|
var currentValue = Number((_a = currentInputRef === null || currentInputRef === void 0 ? void 0 : currentInputRef.current) === null || _a === void 0 ? void 0 : _a.value);
|
|
60
65
|
var newValue;
|
|
61
|
-
var fixToDecimal = function (
|
|
66
|
+
var fixToDecimal = function (rawValue) { return props.decimal ? rawValue.toFixed(props.decimal) : rawValue; };
|
|
62
67
|
if (isIncrement) {
|
|
63
68
|
newValue = fixToDecimal(currentValue + step);
|
|
64
69
|
}
|
|
@@ -75,10 +80,7 @@ function NumberField(props) {
|
|
|
75
80
|
onStep(false);
|
|
76
81
|
}
|
|
77
82
|
}, [onStep]);
|
|
78
|
-
var inputProps = (0, react_1.useMemo)(function () {
|
|
79
|
-
var _a;
|
|
80
|
-
return (__assign(__assign({}, props.inputProps), { name: props.input.name, value: (_a = props.input.value) !== null && _a !== void 0 ? _a : '', onChange: onInputChange, type: 'text', min: props.min, max: props.max, step: props.step, placeholder: props.placeholder, disabled: props.disabled, required: props.required, autoComplete: 'off', onKeyDown: onKeyDown }));
|
|
81
|
-
}, [props.inputProps, props.input.name, props.input.value, props.min, props.max, props.step, props.placeholder, props.disabled, props.required, onInputChange, onKeyDown]);
|
|
83
|
+
var inputProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props.inputProps), { name: props.input.name, value: value, onChange: onInputChange, type: 'text', min: props.min, max: props.max, step: props.step, placeholder: props.placeholder, disabled: props.disabled, required: props.required, autoComplete: 'off', onKeyDown: onKeyDown })); }, [props.inputProps, props.input.name, props.min, props.max, props.step, props.placeholder, props.disabled, props.required, value, onInputChange, onKeyDown]);
|
|
82
84
|
var viewProps = (0, react_1.useMemo)(function () { return ({
|
|
83
85
|
viewProps: props.viewProps,
|
|
84
86
|
inputProps: inputProps,
|
|
@@ -56,7 +56,7 @@ exports.checkPassword = checkPassword;
|
|
|
56
56
|
function PasswordField(props) {
|
|
57
57
|
var _a = (0, react_1.useState)(InputType.PASSWORD), type = _a[0], setType = _a[1];
|
|
58
58
|
var components = (0, hooks_1.useComponents)();
|
|
59
|
-
var _b = (0, hooks_1.useSaveCursorPosition)(props.input), inputRef = _b.inputRef, onChange = _b.onChange;
|
|
59
|
+
var _b = (0, hooks_1.useSaveCursorPosition)({ inputParams: props.input }), inputRef = _b.inputRef, onChange = _b.onChange;
|
|
60
60
|
var onClear = (0, react_1.useCallback)(function () { return props.input.onChange(''); }, [props.input]);
|
|
61
61
|
var onShowButtonClick = (0, react_1.useCallback)(function () {
|
|
62
62
|
type === InputType.PASSWORD ? setType(InputType.TEXT) : setType(InputType.PASSWORD);
|
|
@@ -21,7 +21,9 @@ var enums_1 = require("../../../enums");
|
|
|
21
21
|
function TextField(props) {
|
|
22
22
|
// const dispatch = useDispatch();
|
|
23
23
|
var components = (0, hooks_1.useComponents)();
|
|
24
|
-
var _a = (0, hooks_1.useSaveCursorPosition)(
|
|
24
|
+
var _a = (0, hooks_1.useSaveCursorPosition)({
|
|
25
|
+
inputParams: props.input
|
|
26
|
+
}), inputRef = _a.inputRef, onChange = _a.onChange;
|
|
25
27
|
var onKeyUp = (0, react_1.useCallback)(function (e) {
|
|
26
28
|
if (props.submitOnEnter
|
|
27
29
|
&& props.formId
|
|
@@ -87,6 +87,10 @@ export interface ITooltipProps {
|
|
|
87
87
|
* Дополнительный CSS-класс для элемента отображения
|
|
88
88
|
*/
|
|
89
89
|
className?: CssClassName;
|
|
90
|
+
/**
|
|
91
|
+
* Пропсы для отображения элемента
|
|
92
|
+
*/
|
|
93
|
+
viewProps?: CustomViewProps;
|
|
90
94
|
[key: string]: any;
|
|
91
95
|
}
|
|
92
96
|
export interface ITooltipViewProps extends ITooltipProps {
|
|
@@ -77,7 +77,7 @@ function Tooltip(props) {
|
|
|
77
77
|
})
|
|
78
78
|
: (React.createElement("span", { ref: childRef, onFocus: onShow, onMouseOver: onShow, onBlur: onHide, onMouseOut: onHide }, props.children)),
|
|
79
79
|
isComponentExist && (React.createElement(TooltipPortalInner_1["default"], null,
|
|
80
|
-
React.createElement(TooltipView, { isTooltipVisible: isComponentVisible, content: props.content, position: position, style: style, arrowPosition: arrowPosition, calculatePosition: calculatePosition, className: props.className })))));
|
|
80
|
+
React.createElement(TooltipView, { isTooltipVisible: isComponentVisible, content: props.content, position: position, style: style, arrowPosition: arrowPosition, calculatePosition: calculatePosition, className: props.className, viewProps: props.viewProps })))));
|
|
81
81
|
}
|
|
82
82
|
Tooltip.defaultProps = {
|
|
83
83
|
content: '',
|
package/ui/modal/Modal/Modal.js
CHANGED
|
@@ -56,9 +56,9 @@ function Modal(props) {
|
|
|
56
56
|
shouldCloseOnOverlayClick: props.shouldCloseOnOverlayClick,
|
|
57
57
|
title: props.title,
|
|
58
58
|
children: props.children,
|
|
59
|
-
buttons: props.buttons
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
buttons: props.buttons,
|
|
60
|
+
viewProps: props.viewProps
|
|
61
|
+
}); }, [props.buttons, props.children, props.className, props.closeTimeoutMs, props.isClosing, props.onClose, props.shouldCloseOnEsc, props.shouldCloseOnOverlayClick, props.size, props.title, props.viewProps]);
|
|
62
62
|
return (react_1["default"].createElement(ModalView, __assign({}, viewProps), (ContentComponent && (react_1["default"].createElement(ContentComponent, __assign({}, props, props.componentProps)))) || (props.children)));
|
|
63
63
|
}
|
|
64
64
|
Modal.defaultProps = {
|