react-admin-base-bootstrap 0.9.22 → 0.9.24
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.
|
@@ -16,6 +16,7 @@ export interface ApiSelectProps<Option = any> {
|
|
|
16
16
|
staticOptions?: any[];
|
|
17
17
|
sortable?: boolean;
|
|
18
18
|
onAddOrEdit?: (item: any) => void;
|
|
19
|
+
free?: boolean;
|
|
19
20
|
getNewOptionData?: (name: string, elem: React.ReactNode) => any | null;
|
|
20
21
|
}
|
|
21
22
|
export default function ApiSelect<Option = any>(props: ApiSelectProps<Option>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
11
11
|
import React, { Fragment, useCallback, useMemo, useState } from 'react';
|
|
12
|
-
import { RefreshScope, useFetch, useRefresh } from 'react-admin-base';
|
|
12
|
+
import { RefreshScope, useFetch, useFreeFetch, useRefresh } from 'react-admin-base';
|
|
13
13
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
14
14
|
import Select, { components } from "react-select";
|
|
15
15
|
import CreatableSelect from 'react-select/creatable';
|
|
@@ -35,6 +35,8 @@ function EditOrAddIndicator(props) {
|
|
|
35
35
|
e.stopPropagation();
|
|
36
36
|
e.preventDefault();
|
|
37
37
|
props.selectProps.onAddOrEdit();
|
|
38
|
+
}, onTouchEnd: e => {
|
|
39
|
+
props.selectProps.onAddOrEdit();
|
|
38
40
|
}, children: _jsx("i", { className: "fas " + (props.hasValue && !isMulti ? 'fa-pencil-alt' : 'fa-plus') }) })));
|
|
39
41
|
}
|
|
40
42
|
function IndicatorsContainer(props) {
|
|
@@ -64,13 +66,13 @@ const SortableMultiValueRemove = (props) => {
|
|
|
64
66
|
};
|
|
65
67
|
const SortableComponents = { Option, SingleValue, MultiValue: SortableMultiValue, IndicatorsContainer, MultiValueRemove: SortableMultiValueRemove };
|
|
66
68
|
export default function ApiSelect(props) {
|
|
67
|
-
const { disabled, url, getOptionLabel, sortable, getOptionValue, idKey, nameKey, filter, group, onCreateOption, getNewOptionData, isMulti, onChange, value, placeholder, staticOptions } = props;
|
|
69
|
+
const { disabled, url, getOptionLabel, sortable, free, getOptionValue, idKey, nameKey, filter, group, onCreateOption, getNewOptionData, isMulti, onChange, value, placeholder, staticOptions } = props;
|
|
68
70
|
const intl = useIntl();
|
|
69
71
|
const [search, setSearch] = useState('');
|
|
70
72
|
const params = useMemo(() => ({ query: search }), [search]);
|
|
71
73
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
72
74
|
const [hasMenuOpen, setHasMenuOpen] = useState(false);
|
|
73
|
-
const [data, loading, error, update] = useFetch((isMenuOpen && url) || false, params);
|
|
75
|
+
const [data, loading, error, update] = (free ? useFreeFetch : useFetch)((isMenuOpen && url) || false, params);
|
|
74
76
|
const [creating, setCreating] = useState(false);
|
|
75
77
|
let options = staticOptions || (data && data.data) || data;
|
|
76
78
|
if (group) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
|
2
2
|
import { css } from "@emotion/react"
|
|
3
|
-
import React, {Fragment, useCallback, useMemo, useState} from 'react';
|
|
4
|
-
import {RefreshScope, useFetch, useRefresh} from 'react-admin-base';
|
|
3
|
+
import React, {Fragment, useCallback, useMemo, useRef, useState} from 'react';
|
|
4
|
+
import {RefreshScope, useFetch, useFreeFetch, useRefresh} from 'react-admin-base';
|
|
5
5
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
6
6
|
import Select, { components } from "react-select";
|
|
7
7
|
import CreatableSelect from 'react-select/creatable';
|
|
@@ -42,6 +42,7 @@ function MultiValue(props) {
|
|
|
42
42
|
|
|
43
43
|
function EditOrAddIndicator(props) {
|
|
44
44
|
const { className, cx, getStyles, innerProps, isMulti } = props;
|
|
45
|
+
|
|
45
46
|
return (
|
|
46
47
|
<div
|
|
47
48
|
{...innerProps}
|
|
@@ -58,6 +59,9 @@ function EditOrAddIndicator(props) {
|
|
|
58
59
|
e.preventDefault();
|
|
59
60
|
props.selectProps.onAddOrEdit();
|
|
60
61
|
}}
|
|
62
|
+
onTouchEnd={e => {
|
|
63
|
+
props.selectProps.onAddOrEdit();
|
|
64
|
+
}}
|
|
61
65
|
>
|
|
62
66
|
<i className={"fas " + (props.hasValue && !isMulti ? 'fa-pencil-alt' : 'fa-plus')} />
|
|
63
67
|
</div>);
|
|
@@ -137,18 +141,19 @@ export interface ApiSelectProps<Option = any> {
|
|
|
137
141
|
staticOptions?: any[];
|
|
138
142
|
sortable?: boolean;
|
|
139
143
|
onAddOrEdit?: (item: any) => void;
|
|
144
|
+
free?: boolean;
|
|
140
145
|
getNewOptionData?: (name: string, elem: React.ReactNode) => any|null;
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
|
|
144
149
|
export default function ApiSelect<Option = any>(props: ApiSelectProps<Option>) {
|
|
145
|
-
const { disabled, url, getOptionLabel, sortable, getOptionValue, idKey, nameKey, filter, group, onCreateOption, getNewOptionData, isMulti, onChange, value, placeholder, staticOptions } = props;
|
|
150
|
+
const { disabled, url, getOptionLabel, sortable, free, getOptionValue, idKey, nameKey, filter, group, onCreateOption, getNewOptionData, isMulti, onChange, value, placeholder, staticOptions } = props;
|
|
146
151
|
const intl = useIntl();
|
|
147
152
|
const [ search, setSearch ] = useState('');
|
|
148
153
|
const params = useMemo(() => ({ query: search }), [search]);
|
|
149
154
|
const [ isMenuOpen, setIsMenuOpen ] = useState(false);
|
|
150
155
|
const [ hasMenuOpen, setHasMenuOpen ] = useState(false);
|
|
151
|
-
const [ data, loading, error, update ] = useFetch((isMenuOpen && url) || false, params);
|
|
156
|
+
const [ data, loading, error, update ] = (free ? useFreeFetch : useFetch)((isMenuOpen && url) || false, params);
|
|
152
157
|
const [ creating, setCreating ] = useState(false);
|
|
153
158
|
|
|
154
159
|
let options = staticOptions || (data && data.data) || data;
|
package/bun.lockb
DELETED
|
Binary file
|