@panneau/field-resource-item 4.0.38 → 4.0.40-alpha.1
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/dist/index.d.ts +3 -7
- package/dist/index.js +142 -251
- package/package.json +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { FormError, Message } from '@panneau/core';
|
|
2
|
+
import { Item, FormError, Message } from '@panneau/core';
|
|
3
3
|
|
|
4
|
-
interface Item {
|
|
5
|
-
id?: string | number | null;
|
|
6
|
-
type?: string;
|
|
7
|
-
[key: string]: unknown;
|
|
8
|
-
}
|
|
9
4
|
interface ResourceItemFieldProps {
|
|
10
5
|
name?: string | null;
|
|
11
6
|
value?: Item | null;
|
|
@@ -31,6 +26,7 @@ interface ResourceItemFieldProps {
|
|
|
31
26
|
canEdit?: boolean;
|
|
32
27
|
canFind?: boolean;
|
|
33
28
|
withoutModal?: boolean;
|
|
29
|
+
withoutSelect?: boolean;
|
|
34
30
|
createButtonLabel?: Message | null;
|
|
35
31
|
editButtonLabel?: Message | null;
|
|
36
32
|
findButtonLabel?: Message | null;
|
|
@@ -40,7 +36,7 @@ interface ResourceItemFieldProps {
|
|
|
40
36
|
inputClassName?: string | null;
|
|
41
37
|
onChange?: ((value: Item | Item[] | null) => void) | null;
|
|
42
38
|
}
|
|
43
|
-
declare function ResourceItemField({ name, value, errors, resource: resourceId, resourceType, paginated, query: initialQuery, requestQuery: initialRequestQuery, page: initialPage, count: initialCount, options: initialOptions, searchParamName, getItemLabel: initialGetItemLabel, getItemDescription, getItemImage, itemLabelPath, itemDescriptionPath, itemImagePath, itemLabelWithId, placeholder, canCreate, canEdit, canFind, withoutModal, createButtonLabel, editButtonLabel, findButtonLabel, multiple, disabled, className, inputClassName, onChange, }: ResourceItemFieldProps): react_jsx_runtime.JSX.Element;
|
|
39
|
+
declare function ResourceItemField({ name, value, errors, resource: resourceId, resourceType, paginated, query: initialQuery, requestQuery: initialRequestQuery, page: initialPage, count: initialCount, options: initialOptions, searchParamName, getItemLabel: initialGetItemLabel, getItemDescription, getItemImage, itemLabelPath, itemDescriptionPath, itemImagePath, itemLabelWithId, placeholder, canCreate, canEdit, canFind, withoutModal, withoutSelect, createButtonLabel, editButtonLabel, findButtonLabel, multiple, disabled, className, inputClassName, onChange, }: ResourceItemFieldProps): react_jsx_runtime.JSX.Element;
|
|
44
40
|
|
|
45
41
|
declare namespace _default {
|
|
46
42
|
let id: string;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
4
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
1
|
import classNames from 'classnames';
|
|
6
2
|
import isArray from 'lodash/isArray';
|
|
7
3
|
import isEmpty from 'lodash/isEmpty';
|
|
@@ -14,166 +10,98 @@ import { useResourceItems } from '@panneau/data';
|
|
|
14
10
|
import Button from '@panneau/element-button';
|
|
15
11
|
import ResourceCard from '@panneau/element-resource-card';
|
|
16
12
|
import Select from '@panneau/element-select';
|
|
17
|
-
import ResourceForm from '@panneau/form-resource';
|
|
18
13
|
import { useResourceValues } from '@panneau/intl';
|
|
19
|
-
import
|
|
14
|
+
import ModalResourceForm from '@panneau/modal-resource-form';
|
|
20
15
|
import ModalResourceItems from '@panneau/modal-resource-items';
|
|
21
16
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
22
17
|
|
|
23
|
-
function ResourceItemField(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
_ref$canCreate = _ref.canCreate,
|
|
65
|
-
canCreate = _ref$canCreate === void 0 ? false : _ref$canCreate,
|
|
66
|
-
_ref$canEdit = _ref.canEdit,
|
|
67
|
-
canEdit = _ref$canEdit === void 0 ? false : _ref$canEdit,
|
|
68
|
-
_ref$canFind = _ref.canFind,
|
|
69
|
-
canFind = _ref$canFind === void 0 ? false : _ref$canFind,
|
|
70
|
-
_ref$withoutModal = _ref.withoutModal,
|
|
71
|
-
withoutModal = _ref$withoutModal === void 0 ? false : _ref$withoutModal,
|
|
72
|
-
_ref$createButtonLabe = _ref.createButtonLabel,
|
|
73
|
-
createButtonLabel = _ref$createButtonLabe === void 0 ? null : _ref$createButtonLabe,
|
|
74
|
-
_ref$editButtonLabel = _ref.editButtonLabel,
|
|
75
|
-
editButtonLabel = _ref$editButtonLabel === void 0 ? null : _ref$editButtonLabel,
|
|
76
|
-
_ref$findButtonLabel = _ref.findButtonLabel,
|
|
77
|
-
findButtonLabel = _ref$findButtonLabel === void 0 ? null : _ref$findButtonLabel,
|
|
78
|
-
_ref$multiple = _ref.multiple,
|
|
79
|
-
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
80
|
-
_ref$disabled = _ref.disabled,
|
|
81
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
82
|
-
_ref$className = _ref.className,
|
|
83
|
-
className = _ref$className === void 0 ? null : _ref$className,
|
|
84
|
-
_ref$inputClassName = _ref.inputClassName,
|
|
85
|
-
inputClassName = _ref$inputClassName === void 0 ? null : _ref$inputClassName,
|
|
86
|
-
_ref$onChange = _ref.onChange,
|
|
87
|
-
onChange = _ref$onChange === void 0 ? null : _ref$onChange;
|
|
88
|
-
var intl = useIntl();
|
|
89
|
-
var resource = usePanneauResource(resourceId);
|
|
90
|
-
var resourceValues = useResourceValues(resource);
|
|
91
|
-
var defaultPage = useMemo(function () {
|
|
92
|
-
return initialPage || (paginated ? 1 : null);
|
|
93
|
-
}, [initialPage, paginated]);
|
|
94
|
-
var defaultCount = useMemo(function () {
|
|
95
|
-
return initialCount || (paginated ? 8 : null);
|
|
96
|
-
}, [initialCount, paginated]);
|
|
97
|
-
var hasValue = value !== null && !isEmpty(value);
|
|
18
|
+
function ResourceItemField({
|
|
19
|
+
name = null,
|
|
20
|
+
value = null,
|
|
21
|
+
errors = null,
|
|
22
|
+
resource: resourceId = null,
|
|
23
|
+
resourceType = null,
|
|
24
|
+
paginated = true,
|
|
25
|
+
query: initialQuery = null,
|
|
26
|
+
requestQuery: initialRequestQuery = null,
|
|
27
|
+
page: initialPage = null,
|
|
28
|
+
count: initialCount = null,
|
|
29
|
+
options: initialOptions = null,
|
|
30
|
+
searchParamName = 'search',
|
|
31
|
+
getItemLabel: initialGetItemLabel = getPathValue,
|
|
32
|
+
getItemDescription = getPathValue,
|
|
33
|
+
getItemImage = getPathValue,
|
|
34
|
+
itemLabelPath = 'label',
|
|
35
|
+
itemDescriptionPath = null,
|
|
36
|
+
itemImagePath = 'image.thumbnail_url',
|
|
37
|
+
itemLabelWithId = false,
|
|
38
|
+
placeholder = null,
|
|
39
|
+
canCreate = false,
|
|
40
|
+
canEdit = false,
|
|
41
|
+
canFind = false,
|
|
42
|
+
withoutModal = false,
|
|
43
|
+
withoutSelect = false,
|
|
44
|
+
createButtonLabel = null,
|
|
45
|
+
editButtonLabel = null,
|
|
46
|
+
findButtonLabel = null,
|
|
47
|
+
multiple = false,
|
|
48
|
+
disabled = false,
|
|
49
|
+
className = null,
|
|
50
|
+
inputClassName = null,
|
|
51
|
+
onChange = null
|
|
52
|
+
}) {
|
|
53
|
+
const intl = useIntl();
|
|
54
|
+
const resource = usePanneauResource(resourceId);
|
|
55
|
+
useResourceValues(resource);
|
|
56
|
+
const defaultPage = useMemo(() => initialPage || (paginated ? 1 : null), [initialPage, paginated]);
|
|
57
|
+
const defaultCount = useMemo(() => initialCount || (paginated ? 8 : null), [initialCount, paginated]);
|
|
58
|
+
const hasValue = value !== null && !isEmpty(value);
|
|
98
59
|
|
|
99
60
|
// const [initialValue] = useState(value);
|
|
100
61
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
formOpen = _useState2[0],
|
|
104
|
-
setFormOpen = _useState2[1];
|
|
105
|
-
var _useState3 = useState(false),
|
|
106
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
107
|
-
listOpen = _useState4[0],
|
|
108
|
-
setListOpen = _useState4[1];
|
|
62
|
+
const [formOpen, setFormOpen] = useState(false);
|
|
63
|
+
const [listOpen, setListOpen] = useState(false);
|
|
109
64
|
|
|
110
65
|
// TODO: list state controls?
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var _useState7 = useState(defaultPage),
|
|
116
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
117
|
-
page = _useState8[0],
|
|
118
|
-
setPage = _useState8[1];
|
|
119
|
-
var _useState9 = useState(defaultCount),
|
|
120
|
-
_useState0 = _slicedToArray(_useState9, 2),
|
|
121
|
-
count = _useState0[0];
|
|
122
|
-
_useState0[1];
|
|
123
|
-
var _useState1 = useState(initialOptions),
|
|
124
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
125
|
-
resourceOptions = _useState10[0];
|
|
126
|
-
_useState10[1];
|
|
66
|
+
const [query, setQuery] = useState(initialQuery || initialRequestQuery || {});
|
|
67
|
+
const [page, setPage] = useState(defaultPage);
|
|
68
|
+
const [count, setCount] = useState(defaultCount);
|
|
69
|
+
const [resourceOptions, setOptions] = useState(initialOptions);
|
|
127
70
|
|
|
128
71
|
// The text input search query
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
setInputTextValue = _useState12[1];
|
|
133
|
-
var _useState13 = useState(''),
|
|
134
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
135
|
-
queryTextValue = _useState14[0],
|
|
136
|
-
setQueryTextValue = _useState14[1];
|
|
137
|
-
var onInputChange = useCallback(function (textValue) {
|
|
72
|
+
const [inputTextValue, setInputTextValue] = useState('');
|
|
73
|
+
const [queryTextValue, setQueryTextValue] = useState('');
|
|
74
|
+
const onInputChange = useCallback(textValue => {
|
|
138
75
|
setInputTextValue(textValue);
|
|
139
76
|
setPage(defaultPage);
|
|
140
77
|
}, [setInputTextValue, setPage, defaultPage]);
|
|
141
|
-
useEffect(
|
|
142
|
-
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const id = setTimeout(() => {
|
|
143
80
|
setQueryTextValue(inputTextValue);
|
|
144
81
|
}, 500);
|
|
145
|
-
return
|
|
82
|
+
return () => {
|
|
146
83
|
clearTimeout(id);
|
|
147
84
|
};
|
|
148
85
|
}, [inputTextValue, setQueryTextValue]);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
lastPage = _ref3$lastPage === void 0 ? null : _ref3$lastPage;
|
|
169
|
-
var items = uniqBy((partialItems || []).concat(multiple && isArray(value) ? value : [value]).filter(function (it) {
|
|
170
|
-
return it !== null;
|
|
171
|
-
}), function (_ref4) {
|
|
172
|
-
var _ref4$id = _ref4.id,
|
|
173
|
-
id = _ref4$id === void 0 ? null : _ref4$id;
|
|
174
|
-
return id;
|
|
175
|
-
});
|
|
176
|
-
var onScrollEnd = useCallback(function () {
|
|
86
|
+
const finalQuery = useMemo(() => ({
|
|
87
|
+
...query,
|
|
88
|
+
...(!isEmpty(queryTextValue) ? {
|
|
89
|
+
[searchParamName]: queryTextValue
|
|
90
|
+
} : null),
|
|
91
|
+
paginated
|
|
92
|
+
}), [queryTextValue, paginated, query, searchParamName]);
|
|
93
|
+
const {
|
|
94
|
+
allItems: partialItems = null,
|
|
95
|
+
reload = null,
|
|
96
|
+
pagination = null
|
|
97
|
+
} = useResourceItems(resource, finalQuery, paginated ? page : null, paginated ? count : null, resourceOptions);
|
|
98
|
+
const {
|
|
99
|
+
lastPage = null
|
|
100
|
+
} = pagination || {};
|
|
101
|
+
const items = uniqBy((partialItems || []).concat(multiple && isArray(value) ? value : [value]).filter(it => it !== null), ({
|
|
102
|
+
id: id_0 = null
|
|
103
|
+
}) => id_0);
|
|
104
|
+
const onScrollEnd = useCallback(() => {
|
|
177
105
|
if (page !== null && typeof page === 'number' && typeof lastPage === 'number' && page >= lastPage) {
|
|
178
106
|
return;
|
|
179
107
|
}
|
|
@@ -181,87 +109,80 @@ function ResourceItemField(_ref) {
|
|
|
181
109
|
setPage(page + 1);
|
|
182
110
|
}
|
|
183
111
|
}, [paginated, page, setPage, lastPage]);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
112
|
+
const getItemLabel = useCallback((it_0, path) => {
|
|
113
|
+
const {
|
|
114
|
+
id: id_1 = null
|
|
115
|
+
} = it_0 || {};
|
|
188
116
|
if (itemLabelWithId) {
|
|
189
|
-
|
|
190
|
-
return label ?
|
|
117
|
+
const label = initialGetItemLabel(it_0, path);
|
|
118
|
+
return label ? `${label} (#${id_1})` : `#${id_1}`;
|
|
191
119
|
}
|
|
192
|
-
return path !== null ? initialGetItemLabel(
|
|
120
|
+
return path !== null ? initialGetItemLabel(it_0, path) : `#${id_1}`;
|
|
193
121
|
}, [initialGetItemLabel, itemLabelWithId]);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
122
|
+
const parseItem = useCallback(it_1 => {
|
|
123
|
+
const label_0 = getItemLabel(it_1, itemLabelPath);
|
|
124
|
+
const description = getItemDescription(it_1, itemDescriptionPath);
|
|
125
|
+
const finalLabel = description !== null ? `${label_0}: ${description}` : label_0;
|
|
198
126
|
return {
|
|
199
|
-
value:
|
|
127
|
+
value: it_1.id,
|
|
200
128
|
label: finalLabel
|
|
201
129
|
};
|
|
202
130
|
}, [getItemLabel, getItemDescription, itemLabelPath, itemDescriptionPath]);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
var options = (items || []).map(function (it) {
|
|
214
|
-
return parseItem(it);
|
|
215
|
-
});
|
|
216
|
-
var onValueChange = useCallback(function (newId) {
|
|
131
|
+
const finalValue = multiple && isArray(value) ? value.map(({
|
|
132
|
+
id: id_2 = null
|
|
133
|
+
}) => id_2) : value?.id || null;
|
|
134
|
+
const {
|
|
135
|
+
type: finalType = null
|
|
136
|
+
} = !multiple && hasValue ? value : {
|
|
137
|
+
type: resourceType
|
|
138
|
+
};
|
|
139
|
+
const options = (items || []).map(it_2 => parseItem(it_2));
|
|
140
|
+
const onValueChange = useCallback(newId => {
|
|
217
141
|
if (onChange === null) return;
|
|
218
142
|
if (multiple && isArray(newId)) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return newId.indexOf(id) !== -1;
|
|
223
|
-
}) || [];
|
|
143
|
+
const newValue = items.filter(({
|
|
144
|
+
id: id_3 = null
|
|
145
|
+
}) => newId.indexOf(id_3) !== -1) || [];
|
|
224
146
|
onChange(newValue);
|
|
225
147
|
} else if (!isArray(newId)) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (_newValue !== null && _newValue.length > 0) {
|
|
232
|
-
onChange(_newValue[0]);
|
|
148
|
+
const newValue_0 = items.filter(({
|
|
149
|
+
id: id_4 = null
|
|
150
|
+
}) => id_4 === newId) || [];
|
|
151
|
+
if (newValue_0 !== null && newValue_0.length > 0) {
|
|
152
|
+
onChange(newValue_0[0]);
|
|
233
153
|
} else {
|
|
234
154
|
onChange(null);
|
|
235
155
|
}
|
|
236
156
|
}
|
|
237
157
|
}, [items, onChange, multiple]);
|
|
238
|
-
|
|
158
|
+
const onOpenForm = useCallback(() => {
|
|
239
159
|
setFormOpen(true);
|
|
240
160
|
}, [setFormOpen]);
|
|
241
|
-
|
|
161
|
+
const onClosedForm = useCallback(() => {
|
|
242
162
|
setFormOpen(false);
|
|
243
163
|
}, [setFormOpen]);
|
|
244
|
-
|
|
164
|
+
const onFormSuccess = useCallback(newValue_1 => {
|
|
245
165
|
if (onChange === null) return;
|
|
246
|
-
|
|
247
|
-
type: resourceType
|
|
248
|
-
|
|
166
|
+
const finalNewValue = resourceType !== null ? {
|
|
167
|
+
type: resourceType,
|
|
168
|
+
...newValue_1
|
|
169
|
+
} : newValue_1;
|
|
249
170
|
if (multiple) {
|
|
250
|
-
onChange(isArray(value) ? [
|
|
171
|
+
onChange(isArray(value) ? [...value, finalNewValue] : [finalNewValue]);
|
|
251
172
|
} else {
|
|
252
173
|
onChange(finalNewValue);
|
|
253
174
|
}
|
|
254
175
|
setFormOpen(false);
|
|
255
176
|
}, [onChange, multiple, value, setFormOpen, resourceType]);
|
|
256
|
-
|
|
257
|
-
setListOpen(
|
|
177
|
+
const onOpenList = useCallback(() => {
|
|
178
|
+
setListOpen(true); // TODO: fix this, see Upload Field
|
|
258
179
|
}, [setListOpen]);
|
|
259
|
-
|
|
180
|
+
const onClosedList = useCallback(() => {
|
|
260
181
|
setListOpen(false);
|
|
261
182
|
}, [setListOpen]);
|
|
262
|
-
|
|
183
|
+
const onSelectListItem = useCallback(newValue_2 => {
|
|
263
184
|
if (onChange !== null) {
|
|
264
|
-
onChange(
|
|
185
|
+
onChange(isArray(newValue_2) && !multiple ? newValue_2?.[0] || null : newValue_2);
|
|
265
186
|
setListOpen(false);
|
|
266
187
|
}
|
|
267
188
|
}, [onChange, setListOpen]);
|
|
@@ -273,7 +194,7 @@ function ResourceItemField(_ref) {
|
|
|
273
194
|
// }
|
|
274
195
|
// }, [paginated, reloadall]);
|
|
275
196
|
|
|
276
|
-
|
|
197
|
+
const onClickRemove = useCallback(() => {
|
|
277
198
|
if (onChange !== null) {
|
|
278
199
|
onChange(null);
|
|
279
200
|
}
|
|
@@ -286,15 +207,10 @@ function ResourceItemField(_ref) {
|
|
|
286
207
|
if (reload) reload();
|
|
287
208
|
}
|
|
288
209
|
}, [onChange, paginated, defaultPage, reload]);
|
|
289
|
-
var form = formOpen ? /*#__PURE__*/jsx(ResourceForm, {
|
|
290
|
-
resource: resource,
|
|
291
|
-
type: finalType,
|
|
292
|
-
item: !multiple ? value : null,
|
|
293
|
-
onSuccess: onFormSuccess,
|
|
294
|
-
isModal: true
|
|
295
|
-
}) : null;
|
|
296
210
|
return /*#__PURE__*/jsxs("div", {
|
|
297
|
-
className: classNames(['position-relative',
|
|
211
|
+
className: classNames(['position-relative', {
|
|
212
|
+
[className]: className != null
|
|
213
|
+
}]),
|
|
298
214
|
children: [hasValue && !multiple ? /*#__PURE__*/jsx("div", {
|
|
299
215
|
className: "row",
|
|
300
216
|
children: /*#__PURE__*/jsx("div", {
|
|
@@ -310,17 +226,21 @@ function ResourceItemField(_ref) {
|
|
|
310
226
|
itemImagePath: itemImagePath,
|
|
311
227
|
itemLabelWithId: itemLabelWithId,
|
|
312
228
|
disable: disabled,
|
|
313
|
-
onClickEdit: canEdit && !multiple ?
|
|
229
|
+
onClickEdit: canEdit && !multiple ? onOpenForm : null,
|
|
314
230
|
onClickRemove: onClickRemove,
|
|
315
231
|
editButtonLabel: editButtonLabel
|
|
316
232
|
})
|
|
317
233
|
})
|
|
318
234
|
}) : /*#__PURE__*/jsxs("div", {
|
|
319
|
-
className: "row align-items-center",
|
|
320
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
235
|
+
className: "row align-items-center gx-1",
|
|
236
|
+
children: [!withoutSelect ? /*#__PURE__*/jsx("div", {
|
|
321
237
|
className: "col-8 flex-grow-1",
|
|
322
238
|
children: /*#__PURE__*/jsx(Select, {
|
|
323
|
-
className: classNames(['py-1', 'shadow-none',
|
|
239
|
+
className: classNames(['py-1', 'shadow-none', {
|
|
240
|
+
disabled: disabled,
|
|
241
|
+
'is-invalid': errors !== null,
|
|
242
|
+
[inputClassName]: inputClassName !== null
|
|
243
|
+
}]),
|
|
324
244
|
disabled: disabled,
|
|
325
245
|
name: name,
|
|
326
246
|
value: finalValue,
|
|
@@ -328,11 +248,7 @@ function ResourceItemField(_ref) {
|
|
|
328
248
|
isClearable: true,
|
|
329
249
|
isSearchable: true,
|
|
330
250
|
placeholder: isMessage(placeholder) ? intl.formatMessage(placeholder) : /*#__PURE__*/jsx(FormattedMessage, {
|
|
331
|
-
id: "oc3YLT"
|
|
332
|
-
defaultMessage: [{
|
|
333
|
-
"type": 0,
|
|
334
|
-
"value": "Choose an item"
|
|
335
|
-
}]
|
|
251
|
+
id: "oc3YLT"
|
|
336
252
|
}),
|
|
337
253
|
onChange: onValueChange,
|
|
338
254
|
onInputChange: onInputChange
|
|
@@ -341,21 +257,21 @@ function ResourceItemField(_ref) {
|
|
|
341
257
|
onMenuScrollToBottom: onScrollEnd,
|
|
342
258
|
multiple: multiple
|
|
343
259
|
})
|
|
344
|
-
}), canFind ? /*#__PURE__*/jsx("div", {
|
|
260
|
+
}) : null, canFind ? /*#__PURE__*/jsx("div", {
|
|
345
261
|
className: "col-auto",
|
|
346
262
|
children: /*#__PURE__*/jsx(Button, {
|
|
347
|
-
theme: "
|
|
263
|
+
theme: "secondary",
|
|
348
264
|
icon: findButtonLabel === null ? 'search' : null,
|
|
349
|
-
onClick:
|
|
265
|
+
onClick: onOpenList,
|
|
350
266
|
outline: true,
|
|
351
267
|
children: findButtonLabel
|
|
352
268
|
})
|
|
353
269
|
}) : null, canCreate ? /*#__PURE__*/jsx("div", {
|
|
354
270
|
className: "col-auto",
|
|
355
271
|
children: /*#__PURE__*/jsx(Button, {
|
|
356
|
-
theme: "
|
|
272
|
+
theme: "secondary",
|
|
357
273
|
icon: createButtonLabel === null ? 'plus-lg' : null,
|
|
358
|
-
onClick:
|
|
274
|
+
onClick: onOpenForm,
|
|
359
275
|
outline: true,
|
|
360
276
|
children: createButtonLabel
|
|
361
277
|
})
|
|
@@ -363,41 +279,16 @@ function ResourceItemField(_ref) {
|
|
|
363
279
|
}), formOpen ? withoutModal ? /*#__PURE__*/jsx("div", {
|
|
364
280
|
className: "card mt-4 p-4",
|
|
365
281
|
children: form
|
|
366
|
-
}) : /*#__PURE__*/jsx(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
"type": 0,
|
|
373
|
-
"value": "Edit "
|
|
374
|
-
}, {
|
|
375
|
-
"type": 1,
|
|
376
|
-
"value": "a_singular"
|
|
377
|
-
}]
|
|
378
|
-
}) : /*#__PURE__*/jsx(FormattedMessage, {
|
|
379
|
-
values: resourceValues,
|
|
380
|
-
id: "6viUpq",
|
|
381
|
-
defaultMessage: [{
|
|
382
|
-
"type": 0,
|
|
383
|
-
"value": "Create "
|
|
384
|
-
}, {
|
|
385
|
-
"type": 1,
|
|
386
|
-
"value": "a_singular"
|
|
387
|
-
}]
|
|
388
|
-
}),
|
|
389
|
-
size: "lg",
|
|
390
|
-
onClose: onCloseForm,
|
|
391
|
-
children: form
|
|
282
|
+
}) : /*#__PURE__*/jsx(ModalResourceForm, {
|
|
283
|
+
resource: resource,
|
|
284
|
+
item: !multiple ? value : null,
|
|
285
|
+
isCreate: true,
|
|
286
|
+
onClosed: onClosedForm,
|
|
287
|
+
onComplete: onFormSuccess
|
|
392
288
|
}) : null, listOpen ? /*#__PURE__*/jsx(ModalResourceItems, {
|
|
393
289
|
resource: resourceId,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
actions: ['select'],
|
|
397
|
-
actionsProps: {
|
|
398
|
-
onClickSelect: onSelectListItem
|
|
399
|
-
}
|
|
400
|
-
}
|
|
290
|
+
onClosed: onClosedList,
|
|
291
|
+
onSelect: onSelectListItem
|
|
401
292
|
}) : null]
|
|
402
293
|
});
|
|
403
294
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/field-resource-item",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.40-alpha.1",
|
|
4
4
|
"description": "An item mapping a resource",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@babel/runtime": "^7.28.6",
|
|
55
|
-
"@panneau/core": "^4.0.
|
|
56
|
-
"@panneau/data": "^4.0.
|
|
57
|
-
"@panneau/element-button": "^4.0.
|
|
58
|
-
"@panneau/element-resource-card": "^4.0.
|
|
59
|
-
"@panneau/element-select": "^4.0.
|
|
60
|
-
"@panneau/form-resource": "^4.0.
|
|
61
|
-
"@panneau/intl": "^4.0.
|
|
62
|
-
"@panneau/modal-dialog": "^4.0.
|
|
63
|
-
"@panneau/modal-resource-form": "^4.0.
|
|
64
|
-
"@panneau/modal-resource-items": "^4.0.
|
|
55
|
+
"@panneau/core": "^4.0.40-alpha.1",
|
|
56
|
+
"@panneau/data": "^4.0.40-alpha.1",
|
|
57
|
+
"@panneau/element-button": "^4.0.40-alpha.1",
|
|
58
|
+
"@panneau/element-resource-card": "^4.0.40-alpha.1",
|
|
59
|
+
"@panneau/element-select": "^4.0.40-alpha.1",
|
|
60
|
+
"@panneau/form-resource": "^4.0.40-alpha.1",
|
|
61
|
+
"@panneau/intl": "^4.0.40-alpha.1",
|
|
62
|
+
"@panneau/modal-dialog": "^4.0.40-alpha.1",
|
|
63
|
+
"@panneau/modal-resource-form": "^4.0.40-alpha.1",
|
|
64
|
+
"@panneau/modal-resource-items": "^4.0.40-alpha.1",
|
|
65
65
|
"classnames": "^2.5.1",
|
|
66
66
|
"lodash": "^4.17.21",
|
|
67
67
|
"react-intl": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^10.0.0"
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "66520f92373b3aa371222b354d60ed3cf3d20c96"
|
|
73
73
|
}
|