@steroidsjs/core 3.1.4 → 3.1.5
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 +43 -0
- package/en.json +2 -1
- package/package.json +1 -1
- package/ui/form/CheckboxField/CheckboxField.d.ts +5 -0
- package/ui/form/CheckboxField/CheckboxField.js +3 -2
- package/ui/form/CheckboxTreeField/CheckboxTreeField.d.ts +1 -0
- package/ui/form/CheckboxTreeField/CheckboxTreeField.js +13 -5
package/docs-autogen-result.json
CHANGED
|
@@ -15416,6 +15416,15 @@
|
|
|
15416
15416
|
"example": null,
|
|
15417
15417
|
"defaultValue": null
|
|
15418
15418
|
},
|
|
15419
|
+
{
|
|
15420
|
+
"name": "indeterminate",
|
|
15421
|
+
"decorators": [],
|
|
15422
|
+
"description": "Промежуточное состояние чекбокса — часть дочерних элементов выбрана",
|
|
15423
|
+
"required": false,
|
|
15424
|
+
"type": "boolean",
|
|
15425
|
+
"example": null,
|
|
15426
|
+
"defaultValue": null
|
|
15427
|
+
},
|
|
15419
15428
|
{
|
|
15420
15429
|
"name": "inputProps",
|
|
15421
15430
|
"decorators": [],
|
|
@@ -15645,6 +15654,14 @@
|
|
|
15645
15654
|
"type": "string",
|
|
15646
15655
|
"example": null
|
|
15647
15656
|
},
|
|
15657
|
+
{
|
|
15658
|
+
"name": "indeterminate",
|
|
15659
|
+
"decorators": [],
|
|
15660
|
+
"description": "Промежуточное состояние чекбокса — часть дочерних элементов выбрана",
|
|
15661
|
+
"required": false,
|
|
15662
|
+
"type": "boolean",
|
|
15663
|
+
"example": null
|
|
15664
|
+
},
|
|
15648
15665
|
{
|
|
15649
15666
|
"name": "input",
|
|
15650
15667
|
"decorators": [],
|
|
@@ -16836,6 +16853,14 @@
|
|
|
16836
16853
|
"type": "number",
|
|
16837
16854
|
"example": "32"
|
|
16838
16855
|
},
|
|
16856
|
+
{
|
|
16857
|
+
"name": "primaryKey",
|
|
16858
|
+
"decorators": [],
|
|
16859
|
+
"description": "",
|
|
16860
|
+
"required": false,
|
|
16861
|
+
"type": "string",
|
|
16862
|
+
"example": null
|
|
16863
|
+
},
|
|
16839
16864
|
{
|
|
16840
16865
|
"name": "selectedIds",
|
|
16841
16866
|
"decorators": [],
|
|
@@ -28152,6 +28177,15 @@
|
|
|
28152
28177
|
"example": null,
|
|
28153
28178
|
"defaultValue": null
|
|
28154
28179
|
},
|
|
28180
|
+
{
|
|
28181
|
+
"name": "indeterminate",
|
|
28182
|
+
"decorators": [],
|
|
28183
|
+
"description": "Промежуточное состояние чекбокса — часть дочерних элементов выбрана",
|
|
28184
|
+
"required": false,
|
|
28185
|
+
"type": "boolean",
|
|
28186
|
+
"example": null,
|
|
28187
|
+
"defaultValue": null
|
|
28188
|
+
},
|
|
28155
28189
|
{
|
|
28156
28190
|
"name": "inputProps",
|
|
28157
28191
|
"decorators": [],
|
|
@@ -30482,6 +30516,15 @@
|
|
|
30482
30516
|
"example": null,
|
|
30483
30517
|
"defaultValue": null
|
|
30484
30518
|
},
|
|
30519
|
+
{
|
|
30520
|
+
"name": "indeterminate",
|
|
30521
|
+
"decorators": [],
|
|
30522
|
+
"description": "Промежуточное состояние чекбокса — часть дочерних элементов выбрана",
|
|
30523
|
+
"required": false,
|
|
30524
|
+
"type": "boolean",
|
|
30525
|
+
"example": null,
|
|
30526
|
+
"defaultValue": null
|
|
30527
|
+
},
|
|
30485
30528
|
{
|
|
30486
30529
|
"name": "inputProps",
|
|
30487
30530
|
"decorators": [],
|
package/en.json
CHANGED
|
@@ -1062,5 +1062,6 @@
|
|
|
1062
1062
|
"Название цвета для Alert и Notification": "Color name for Alert and Notification",
|
|
1063
1063
|
"Название цвета для Badge": "Color name for Badge",
|
|
1064
1064
|
"Название цвета для Button": "Color name for Button",
|
|
1065
|
-
"Название цвета для Text, Title": "Color name for Text, Title"
|
|
1065
|
+
"Название цвета для Text, Title": "Color name for Text, Title",
|
|
1066
|
+
"Промежуточное состояние чекбокса — часть дочерних элементов выбрана": ""
|
|
1066
1067
|
}
|
package/package.json
CHANGED
|
@@ -20,6 +20,10 @@ export interface ICheckboxFieldProps extends IFieldWrapperInputProps, IUiCompone
|
|
|
20
20
|
* Пользовательский цвет для чекбокса
|
|
21
21
|
*/
|
|
22
22
|
color?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Промежуточное состояние чекбокса — часть дочерних элементов выбрана
|
|
25
|
+
*/
|
|
26
|
+
indeterminate?: boolean;
|
|
23
27
|
[key: string]: any;
|
|
24
28
|
}
|
|
25
29
|
export interface ICheckboxFieldViewProps extends ICheckboxFieldProps, IFieldWrapperOutputProps {
|
|
@@ -31,6 +35,7 @@ export interface ICheckboxFieldViewProps extends ICheckboxFieldProps, IFieldWrap
|
|
|
31
35
|
disabled?: boolean;
|
|
32
36
|
required?: boolean;
|
|
33
37
|
};
|
|
38
|
+
indeterminate?: boolean;
|
|
34
39
|
}
|
|
35
40
|
declare const _default: import("../Field/fieldWrapper").FieldWrapperComponent<ICheckboxFieldProps>;
|
|
36
41
|
export default _default;
|
|
@@ -44,9 +44,10 @@ function CheckboxField(props) {
|
|
|
44
44
|
id: props.id,
|
|
45
45
|
label: props.label,
|
|
46
46
|
onChange: props.onChange,
|
|
47
|
-
required: props.required
|
|
47
|
+
required: props.required,
|
|
48
|
+
indeterminate: props.indeterminate
|
|
48
49
|
}); }, [inputProps, props.checked, props.className, props.color, props.disabled,
|
|
49
|
-
props.errors, props.id, props.label, props.onChange, props.required, props.size, props.style]);
|
|
50
|
+
props.errors, props.id, props.indeterminate, props.label, props.onChange, props.required, props.size, props.style]);
|
|
50
51
|
return components.ui.renderView(props.view || 'form.CheckboxFieldView', viewProps);
|
|
51
52
|
}
|
|
52
53
|
CheckboxField.defaultProps = {
|
|
@@ -66,6 +66,7 @@ export interface ICheckboxTreeFieldViewProps extends IFieldWrapperOutputProps, P
|
|
|
66
66
|
required?: boolean;
|
|
67
67
|
} & IPreparedTreeItem[];
|
|
68
68
|
selectedIds: (PrimaryKey | any)[];
|
|
69
|
+
primaryKey?: string;
|
|
69
70
|
onItemSelect: (checkbox: IPreparedTreeItem) => void;
|
|
70
71
|
renderCheckbox: (checkboxProps: ICheckboxFieldViewProps) => JSX.Element;
|
|
71
72
|
size?: Size;
|
|
@@ -17,6 +17,7 @@ exports.__esModule = true;
|
|
|
17
17
|
exports.getNestedItemsIds = void 0;
|
|
18
18
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
var isArray_1 = __importDefault(require("lodash-es/isArray"));
|
|
20
|
+
var isEmpty_1 = __importDefault(require("lodash-es/isEmpty"));
|
|
20
21
|
var isEqual_1 = __importDefault(require("lodash-es/isEqual"));
|
|
21
22
|
var react_1 = require("react");
|
|
22
23
|
var react_use_1 = require("react-use");
|
|
@@ -71,13 +72,19 @@ function CheckboxTreeField(props) {
|
|
|
71
72
|
}), selectedIds = _a.selectedIds, setSelectedIds = _a.setSelectedIds;
|
|
72
73
|
var onItemSelect = (0, react_1.useCallback)(function (checkbox) {
|
|
73
74
|
if (checkbox.hasItems) {
|
|
74
|
-
var
|
|
75
|
-
|
|
75
|
+
var nestedIds = (0, exports.getNestedItemsIds)(checkbox, props.primaryKey, props.hasOnlyLeafCheckboxes);
|
|
76
|
+
var childIds = nestedIds.filter(function (id) { return id !== checkbox.id; });
|
|
77
|
+
var allChildrenSelected = !(0, isEmpty_1["default"])(childIds) && childIds.every(function (id) { return selectedIds.includes(id); });
|
|
78
|
+
// Передаём только те ID, что уже в selectedIds — useDataSelect сбросит эту ветку через isEqual,
|
|
79
|
+
// не затронув остальные выбранные элементы.
|
|
80
|
+
setSelectedIds(allChildrenSelected
|
|
81
|
+
? nestedIds.filter(function (id) { return selectedIds.includes(id); })
|
|
82
|
+
: nestedIds);
|
|
76
83
|
}
|
|
77
|
-
else if (checkbox.id && !checkbox.hasItems) {
|
|
84
|
+
else if (checkbox.id && !checkbox.hasItems && typeof checkbox.id !== 'boolean') {
|
|
78
85
|
setSelectedIds(checkbox.id);
|
|
79
86
|
}
|
|
80
|
-
}, [props.hasOnlyLeafCheckboxes, props.primaryKey, setSelectedIds]);
|
|
87
|
+
}, [props.hasOnlyLeafCheckboxes, props.primaryKey, selectedIds, setSelectedIds]);
|
|
81
88
|
var onReset = (0, react_1.useCallback)(function () {
|
|
82
89
|
setSelectedIds([]);
|
|
83
90
|
}, [setSelectedIds]);
|
|
@@ -105,6 +112,7 @@ function CheckboxTreeField(props) {
|
|
|
105
112
|
items: treeItems,
|
|
106
113
|
onItemSelect: onItemSelect,
|
|
107
114
|
selectedIds: selectedIds,
|
|
115
|
+
primaryKey: props.primaryKey,
|
|
108
116
|
renderCheckbox: renderCheckbox,
|
|
109
117
|
size: props.size,
|
|
110
118
|
levelPadding: props.levelPadding,
|
|
@@ -112,7 +120,7 @@ function CheckboxTreeField(props) {
|
|
|
112
120
|
hasIconExpandOnly: props.hasIconExpandOnly,
|
|
113
121
|
itemView: TreeItemView,
|
|
114
122
|
itemProps: props.itemProps
|
|
115
|
-
}); }, [treeItems, onItemSelect, selectedIds, renderCheckbox, props.size, props.levelPadding,
|
|
123
|
+
}); }, [treeItems, onItemSelect, selectedIds, props.primaryKey, renderCheckbox, props.size, props.levelPadding,
|
|
116
124
|
props.hasOnlyLeafCheckboxes, props.hasIconExpandOnly, props.itemProps, TreeItemView]);
|
|
117
125
|
return components.ui.renderView(props.view || 'form.CheckboxTreeFieldView', viewProps);
|
|
118
126
|
}
|