react-admin-base-bootstrap 0.8.10 → 0.8.12
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.
|
@@ -20,6 +20,9 @@ function Option(props) {
|
|
|
20
20
|
function SingleValue(props) {
|
|
21
21
|
return jsx(components.SingleValue, Object.assign({}, props), (props.selectProps.children && props.selectProps.children(props.data)) || (props.data.__isNew__ ? jsx(FormattedMessage, { id: "CREATE_VALUE", values: { text: props.children } }) : props.children));
|
|
22
22
|
}
|
|
23
|
+
function MultiValue(props) {
|
|
24
|
+
return jsx(components.MultiValue, Object.assign({}, props), (props.selectProps.children && props.selectProps.children(props.data)) || props.children);
|
|
25
|
+
}
|
|
23
26
|
function EditOrAddIndicator(props) {
|
|
24
27
|
const { className, cx, getStyles, innerProps, isMulti } = props;
|
|
25
28
|
return (jsx("div", Object.assign({}, innerProps, { className: cx({
|
|
@@ -45,7 +48,7 @@ function MultiValueRemove(props) {
|
|
|
45
48
|
jsx("i", { className: "fas fa-pencil", style: { fontSize: '.75em' } })),
|
|
46
49
|
jsx(components.MultiValueRemove, Object.assign({}, props)));
|
|
47
50
|
}
|
|
48
|
-
const Components = { Option, SingleValue, IndicatorsContainer, MultiValueRemove };
|
|
51
|
+
const Components = { Option, SingleValue, MultiValue, IndicatorsContainer, MultiValueRemove };
|
|
49
52
|
export default function ApiSelect(props) {
|
|
50
53
|
const { disabled, url, getOptionLabel, getOptionValue, idKey, nameKey, filter, group, onCreateOption, getNewOptionData, isMulti, onChange, value, placeholder, staticOptions } = props;
|
|
51
54
|
const intl = useIntl();
|
|
@@ -93,13 +96,13 @@ export function CreateSelect(props) {
|
|
|
93
96
|
const { Component, onChange, value, isMulti, idKey } = props;
|
|
94
97
|
const update = useRefresh();
|
|
95
98
|
const [isOpen, setIsOpen] = useState(false);
|
|
96
|
-
const isOpenId = isOpen && isOpen[idKey || "id"];
|
|
99
|
+
const isOpenId = isOpen === true ? null : isOpen && isOpen[idKey || "id"];
|
|
97
100
|
const onReload = useCallback(function (data) {
|
|
98
101
|
setIsOpen(false);
|
|
99
102
|
data && onChange(isMulti ? isOpenId ? value.map(b => b.id === isOpenId ? data : b) : (value || []).concat([data]) : data);
|
|
100
103
|
update && update();
|
|
101
104
|
}, [value, onChange, isMulti, isOpenId, isOpen, update, setIsOpen]);
|
|
102
105
|
return jsx(Fragment, null,
|
|
103
|
-
isOpen && jsx(Component, { id: isOpenId || (!isMulti && value && value[
|
|
106
|
+
isOpen && jsx(Component, { id: isOpenId || (!isMulti && value && value[idKey || "id"]), onReload: onReload }),
|
|
104
107
|
jsx(ApiSelect, Object.assign({}, props, { onAddOrEdit: item => setIsOpen(item || true) })));
|
|
105
108
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-admin-base-bootstrap",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"modal-cropper": "^1.2.3",
|
|
39
39
|
"nprogress": "^0.2.0",
|
|
40
40
|
"prettysize": "^2.0.0",
|
|
41
|
-
"react-admin-base": "^0.8.
|
|
41
|
+
"react-admin-base": "^0.8.5",
|
|
42
42
|
"react-dnd": "^16.0.1",
|
|
43
43
|
"react-dnd-html5-backend": "^16.0.1",
|
|
44
44
|
"react-password-strength-bar": "^0.4.1",
|
|
@@ -24,6 +24,12 @@ function SingleValue(props) {
|
|
|
24
24
|
</components.SingleValue>
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
function MultiValue(props) {
|
|
28
|
+
return <components.MultiValue {...props}>
|
|
29
|
+
{ (props.selectProps.children && props.selectProps.children(props.data)) || props.children }
|
|
30
|
+
</components.MultiValue>
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
function EditOrAddIndicator(props) {
|
|
28
34
|
const { className, cx, getStyles, innerProps, isMulti } = props;
|
|
29
35
|
return (
|
|
@@ -66,7 +72,7 @@ function MultiValueRemove(props) {
|
|
|
66
72
|
</Fragment>;
|
|
67
73
|
}
|
|
68
74
|
|
|
69
|
-
const Components = { Option, SingleValue, IndicatorsContainer, MultiValueRemove };
|
|
75
|
+
const Components = { Option, SingleValue, MultiValue, IndicatorsContainer, MultiValueRemove };
|
|
70
76
|
|
|
71
77
|
export interface ApiSelectProps<Option = any> {
|
|
72
78
|
url?: string;
|
|
@@ -163,7 +169,7 @@ export function CreateSelect(props: CreateSelectProps) {
|
|
|
163
169
|
|
|
164
170
|
const update = useRefresh();
|
|
165
171
|
const [ isOpen, setIsOpen ] = useState<any>(false);
|
|
166
|
-
const isOpenId = isOpen && isOpen[idKey || "id"];
|
|
172
|
+
const isOpenId = isOpen === true ? null : isOpen && isOpen[idKey || "id"];
|
|
167
173
|
|
|
168
174
|
const onReload = useCallback(function(data) {
|
|
169
175
|
setIsOpen(false);
|
|
@@ -172,7 +178,7 @@ export function CreateSelect(props: CreateSelectProps) {
|
|
|
172
178
|
}, [value, onChange, isMulti, isOpenId, isOpen, update, setIsOpen]);
|
|
173
179
|
|
|
174
180
|
return <Fragment>
|
|
175
|
-
{ isOpen && <Component id={isOpenId || (!isMulti && value && value[
|
|
181
|
+
{ isOpen && <Component id={isOpenId || (!isMulti && value && value[idKey || "id"])} onReload={onReload} /> }
|
|
176
182
|
<ApiSelect {...props} onAddOrEdit={item => setIsOpen(item || true)} />
|
|
177
183
|
</Fragment>;
|
|
178
184
|
}
|