react-admin-base-bootstrap 0.9.10 → 0.9.11
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.
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
3
1
|
import React from 'react';
|
|
4
2
|
export interface ApiSelectProps<Option = any> {
|
|
5
3
|
url?: string;
|
|
@@ -20,8 +18,8 @@ export interface ApiSelectProps<Option = any> {
|
|
|
20
18
|
onAddOrEdit?: (item: any) => void;
|
|
21
19
|
getNewOptionData?: (name: string, elem: React.ReactNode) => any | null;
|
|
22
20
|
}
|
|
23
|
-
export default function ApiSelect<Option = any>(props: ApiSelectProps<Option>): jsx.JSX.Element;
|
|
21
|
+
export default function ApiSelect<Option = any>(props: ApiSelectProps<Option>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
24
22
|
export interface CreateSelectProps<Option = any> extends ApiSelectProps<Option> {
|
|
25
23
|
Component: any;
|
|
26
24
|
}
|
|
27
|
-
export declare function CreateSelect(props: CreateSelectProps): jsx.JSX.Element;
|
|
25
|
+
export declare function CreateSelect(props: CreateSelectProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -7,8 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
import { jsx } from '@emotion/react';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
12
11
|
import React, { Fragment, useCallback, useMemo, useState } from 'react';
|
|
13
12
|
import { RefreshScope, useFetch, useRefresh } from 'react-admin-base';
|
|
14
13
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
@@ -19,38 +18,30 @@ import { restrictToParentElement } from '@dnd-kit/modifiers';
|
|
|
19
18
|
import { arrayMove, horizontalListSortingStrategy, SortableContext, useSortable, } from '@dnd-kit/sortable';
|
|
20
19
|
import { CSS } from '@dnd-kit/utilities';
|
|
21
20
|
function Option(props) {
|
|
22
|
-
return
|
|
21
|
+
return _jsx(components.Option, Object.assign({}, props, { children: (props.selectProps.children && props.selectProps.children(props.data)) || (props.data.__isNew__ ? _jsx(FormattedMessage, { id: "CREATE_VALUE", values: { text: props.children } }) : props.children) }));
|
|
23
22
|
}
|
|
24
23
|
function SingleValue(props) {
|
|
25
|
-
return
|
|
24
|
+
return _jsx(components.SingleValue, Object.assign({}, props, { children: (props.selectProps.children && props.selectProps.children(props.data)) || (props.data.__isNew__ ? _jsx(FormattedMessage, { id: "CREATE_VALUE", values: { text: props.children } }) : props.children) }));
|
|
26
25
|
}
|
|
27
26
|
function MultiValue(props) {
|
|
28
|
-
return
|
|
27
|
+
return _jsx(components.MultiValue, Object.assign({}, props, { children: (props.selectProps.children && props.selectProps.children(props.data)) || props.children }));
|
|
29
28
|
}
|
|
30
29
|
function EditOrAddIndicator(props) {
|
|
31
30
|
const { className, cx, getStyles, innerProps, isMulti } = props;
|
|
32
|
-
return (
|
|
31
|
+
return (_jsx("div", Object.assign({}, innerProps, { className: cx({
|
|
33
32
|
indicator: true,
|
|
34
33
|
'clear-indicator': true
|
|
35
34
|
}, className), css: getStyles('clearIndicator', props), onMouseDown: e => {
|
|
36
35
|
e.stopPropagation();
|
|
37
36
|
e.preventDefault();
|
|
38
37
|
props.selectProps.onAddOrEdit();
|
|
39
|
-
} })
|
|
40
|
-
jsx("i", { className: "fas " + (props.hasValue && !isMulti ? 'fa-pencil-alt' : 'fa-plus') })));
|
|
38
|
+
}, children: _jsx("i", { className: "fas " + (props.hasValue && !isMulti ? 'fa-pencil-alt' : 'fa-plus') }) })));
|
|
41
39
|
}
|
|
42
40
|
function IndicatorsContainer(props) {
|
|
43
|
-
return
|
|
44
|
-
props.selectProps.onAddOrEdit && jsx(React.Fragment, null,
|
|
45
|
-
jsx(EditOrAddIndicator, Object.assign({}, props)),
|
|
46
|
-
jsx(components.IndicatorSeparator, Object.assign({}, props))),
|
|
47
|
-
props.children);
|
|
41
|
+
return _jsxs(components.IndicatorsContainer, Object.assign({}, props, { children: [props.selectProps.onAddOrEdit && _jsxs(React.Fragment, { children: [_jsx(EditOrAddIndicator, Object.assign({}, props)), _jsx(components.IndicatorSeparator, Object.assign({}, props))] }), props.children] }));
|
|
48
42
|
}
|
|
49
43
|
function MultiValueRemove(props) {
|
|
50
|
-
return
|
|
51
|
-
props.selectProps.onAddOrEdit && jsx(components.MultiValueRemove, Object.assign({}, props, { innerProps: Object.assign(Object.assign({}, props.innerProps), { onClick: () => props.selectProps.onAddOrEdit(props.data) }) }),
|
|
52
|
-
jsx("i", { className: "fas fa-pencil", style: { fontSize: '.75em' } })),
|
|
53
|
-
jsx(components.MultiValueRemove, Object.assign({}, props)));
|
|
44
|
+
return _jsxs(Fragment, { children: [props.selectProps.onAddOrEdit && _jsx(components.MultiValueRemove, Object.assign({}, props, { innerProps: Object.assign(Object.assign({}, props.innerProps), { onClick: () => props.selectProps.onAddOrEdit(props.data) }), children: _jsx("i", { className: "fas fa-pencil", style: { fontSize: '.75em' } }) })), _jsx(components.MultiValueRemove, Object.assign({}, props))] });
|
|
54
45
|
}
|
|
55
46
|
const Components = { Option, SingleValue, MultiValue, IndicatorsContainer, MultiValueRemove };
|
|
56
47
|
const SortableMultiValue = (props) => {
|
|
@@ -66,11 +57,10 @@ const SortableMultiValue = (props) => {
|
|
|
66
57
|
transform: CSS.Transform.toString(transform),
|
|
67
58
|
transition,
|
|
68
59
|
};
|
|
69
|
-
return (
|
|
70
|
-
jsx(MultiValue, Object.assign({}, props, { innerProps: innerProps }))));
|
|
60
|
+
return (_jsx("div", Object.assign({ style: style, ref: setNodeRef }, attributes, listeners, { children: _jsx(MultiValue, Object.assign({}, props, { innerProps: innerProps })) })));
|
|
71
61
|
};
|
|
72
62
|
const SortableMultiValueRemove = (props) => {
|
|
73
|
-
return (
|
|
63
|
+
return (_jsx(MultiValueRemove, Object.assign({}, props, { innerProps: Object.assign({ onPointerDown: (e) => e.stopPropagation() }, props.innerProps) })));
|
|
74
64
|
};
|
|
75
65
|
const SortableComponents = { Option, SingleValue, MultiValue: SortableMultiValue, IndicatorsContainer, MultiValueRemove: SortableMultiValueRemove };
|
|
76
66
|
export default function ApiSelect(props) {
|
|
@@ -123,9 +113,8 @@ export default function ApiSelect(props) {
|
|
|
123
113
|
}, [_getOptionValue, value, onChange]);
|
|
124
114
|
const Component = (onCreateOption ? CreatableSelect : Select);
|
|
125
115
|
const useSort = isMulti && sortable;
|
|
126
|
-
const elem =
|
|
127
|
-
return
|
|
128
|
-
jsx(SortableContext, { items: (value || []).map(_getOptionValue), strategy: horizontalListSortingStrategy }, elem)) : elem);
|
|
116
|
+
const elem = _jsx(Component, Object.assign({}, props, { className: 'react-select-container', classNamePrefix: "react-select", onCreateOption: (onCreateOption && handleCreateOption), getNewOptionData: (onCreateOption && (getNewOptionData || ((inputValue) => ({ [nameKey || 'name']: inputValue, __isNew__: true })))) || undefined, inputValue: search, onInputChange: a => setSearch(a), components: (useSort ? SortableComponents : Components), isLoading: !!loading || creating, getOptionLabel: getOptionLabel || ((row) => row[nameKey || 'name']), getOptionValue: _getOptionValue, isDisabled: !!disabled || creating, isClearable: true, isSearchable: true, placeholder: placeholder || intl.formatMessage({ id: 'SELECT' }), options: !options ? [] : ((filter && options.filter(filter)) || options), onMenuOpen: onMenuOpen, onMenuClose: onMenuClose }));
|
|
117
|
+
return _jsx(RefreshScope, { update: update, children: useSort ? _jsx(DndContext, { modifiers: [restrictToParentElement], onDragEnd: onDragEnd, collisionDetection: closestCenter, children: _jsx(SortableContext, { items: (value || []).map(_getOptionValue), strategy: horizontalListSortingStrategy, children: elem }) }) : elem });
|
|
129
118
|
}
|
|
130
119
|
export function CreateSelect(props) {
|
|
131
120
|
const { Component, onChange, value, isMulti, idKey } = props;
|
|
@@ -137,7 +126,5 @@ export function CreateSelect(props) {
|
|
|
137
126
|
data && onChange(isMulti ? isOpenId ? value.map(b => b.id === isOpenId ? data : b) : (value || []).concat([data]) : data);
|
|
138
127
|
update && update();
|
|
139
128
|
}, [value, onChange, isMulti, isOpenId, isOpen, update, setIsOpen]);
|
|
140
|
-
return
|
|
141
|
-
isOpen && jsx(Component, { id: isOpenId || (!isMulti && value && value[idKey || "id"]), onReload: onReload }),
|
|
142
|
-
jsx(ApiSelect, Object.assign({}, props, { onAddOrEdit: item => setIsOpen(item || true) })));
|
|
129
|
+
return _jsxs(Fragment, { children: [isOpen && _jsx(Component, { id: isOpenId || (!isMulti && value && value[idKey || "id"]), onReload: onReload }), _jsx(ApiSelect, Object.assign({}, props, { onAddOrEdit: item => setIsOpen(item || true) }))] });
|
|
143
130
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
import {
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import { css } from "@emotion/react"
|
|
3
3
|
import React, {Fragment, useCallback, useMemo, useState} from 'react';
|
|
4
4
|
import {RefreshScope, useFetch, useRefresh} from 'react-admin-base';
|
|
5
5
|
import { FormattedMessage, useIntl } from 'react-intl';
|