@reltio/components 1.4.1038 → 1.4.1042
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/cjs/components/EntityTypesSelector/EntityTypesSelector.d.ts +17 -55
- package/cjs/components/EntityTypesSelector/EntityTypesSelector.js +8 -118
- package/cjs/components/MetadataTypesSelector/ListLabel/ListLabel.d.ts +7 -0
- package/cjs/components/{EntityTypesSelector → MetadataTypesSelector}/ListLabel/ListLabel.js +2 -6
- package/cjs/components/MetadataTypesSelector/ListLabel/helpers.d.ts +4 -0
- package/cjs/components/{EntityTypesSelector → MetadataTypesSelector}/ListLabel/helpers.js +1 -1
- package/cjs/components/MetadataTypesSelector/ListLabel/styles.d.ts +1 -0
- package/cjs/components/{EntityTypesSelector → MetadataTypesSelector}/ListLabel/styles.js +0 -0
- package/cjs/components/MetadataTypesSelector/MetadataTypesSelector.d.ts +26 -0
- package/cjs/components/MetadataTypesSelector/MetadataTypesSelector.js +123 -0
- package/cjs/components/MetadataTypesSelector/SelectMetadataTypesList.d.ts +20 -0
- package/cjs/components/{EntityTypesSelector/SelectEntityTypesList.js → MetadataTypesSelector/SelectMetadataTypesList.js} +7 -12
- package/cjs/components/MetadataTypesSelector/styles.d.ts +1 -0
- package/cjs/components/{EntityTypesSelector → MetadataTypesSelector}/styles.js +0 -0
- package/cjs/components/RelationTypesSelector/RelationTypesSelector.d.ts +17 -0
- package/cjs/components/RelationTypesSelector/RelationTypesSelector.js +35 -0
- package/cjs/components/SearchInput/SearchInput.d.ts +3 -2
- package/cjs/components/SearchInput/SearchInput.js +3 -3
- package/cjs/components/SelectionPopup/SelectionPopup.d.ts +17 -44
- package/cjs/components/SelectionPopup/SelectionPopup.js +8 -26
- package/cjs/components/SelectionPopup/SelectionPopupPopper/SelectionPopupPopper.d.ts +17 -35
- package/cjs/components/SelectionPopup/SelectionPopupPopper/SelectionPopupPopper.js +0 -21
- package/cjs/components/SelectionPopup/helpers.d.ts +23 -9
- package/cjs/components/attributes/PivotingAttributes/PivotingTooltip.js +10 -3
- package/cjs/components/attributes/PivotingAttributes/PivotingTooltipContent.d.ts +4 -3
- package/cjs/components/attributes/PivotingAttributes/PivotingTooltipContent.js +4 -11
- package/cjs/components/attributes/PivotingAttributes/helpers.d.ts +5 -5
- package/cjs/components/attributes/PivotingAttributes/styles.js +2 -1
- package/cjs/components/attributes/editMode/AttributesPager/index.d.ts +2 -2
- package/cjs/components/history/HistoryGraph/HistoryCircle.d.ts +1 -1
- package/cjs/components/history/HistoryGraph/HistoryGraph.d.ts +1 -1
- package/cjs/components/index.d.ts +2 -1
- package/cjs/components/index.js +5 -3
- package/cjs/components/workflow/types/dcrTypes.d.ts +2 -2
- package/esm/components/EntityTypesSelector/EntityTypesSelector.d.ts +17 -55
- package/esm/components/EntityTypesSelector/EntityTypesSelector.js +9 -120
- package/esm/components/MetadataTypesSelector/ListLabel/ListLabel.d.ts +7 -0
- package/esm/components/{EntityTypesSelector → MetadataTypesSelector}/ListLabel/ListLabel.js +1 -7
- package/esm/components/MetadataTypesSelector/ListLabel/helpers.d.ts +4 -0
- package/esm/components/{EntityTypesSelector → MetadataTypesSelector}/ListLabel/helpers.js +1 -1
- package/esm/components/MetadataTypesSelector/ListLabel/styles.d.ts +1 -0
- package/esm/components/{EntityTypesSelector → MetadataTypesSelector}/ListLabel/styles.js +0 -0
- package/esm/components/MetadataTypesSelector/MetadataTypesSelector.d.ts +26 -0
- package/esm/components/MetadataTypesSelector/MetadataTypesSelector.js +98 -0
- package/esm/components/MetadataTypesSelector/SelectMetadataTypesList.d.ts +20 -0
- package/esm/components/{EntityTypesSelector/SelectEntityTypesList.js → MetadataTypesSelector/SelectMetadataTypesList.js} +6 -12
- package/esm/components/MetadataTypesSelector/styles.d.ts +1 -0
- package/esm/components/{EntityTypesSelector → MetadataTypesSelector}/styles.js +0 -0
- package/esm/components/RelationTypesSelector/RelationTypesSelector.d.ts +17 -0
- package/esm/components/RelationTypesSelector/RelationTypesSelector.js +10 -0
- package/esm/components/SearchInput/SearchInput.d.ts +3 -2
- package/esm/components/SearchInput/SearchInput.js +3 -3
- package/esm/components/SelectionPopup/SelectionPopup.d.ts +17 -44
- package/esm/components/SelectionPopup/SelectionPopup.js +8 -26
- package/esm/components/SelectionPopup/SelectionPopupPopper/SelectionPopupPopper.d.ts +17 -35
- package/esm/components/SelectionPopup/SelectionPopupPopper/SelectionPopupPopper.js +0 -21
- package/esm/components/SelectionPopup/helpers.d.ts +23 -9
- package/esm/components/attributes/PivotingAttributes/PivotingTooltip.js +12 -5
- package/esm/components/attributes/PivotingAttributes/PivotingTooltipContent.d.ts +4 -3
- package/esm/components/attributes/PivotingAttributes/PivotingTooltipContent.js +6 -13
- package/esm/components/attributes/PivotingAttributes/helpers.d.ts +5 -5
- package/esm/components/attributes/PivotingAttributes/styles.js +2 -1
- package/esm/components/attributes/editMode/AttributesPager/index.d.ts +2 -2
- package/esm/components/history/HistoryGraph/HistoryCircle.d.ts +1 -1
- package/esm/components/history/HistoryGraph/HistoryGraph.d.ts +1 -1
- package/esm/components/index.d.ts +2 -1
- package/esm/components/index.js +2 -1
- package/esm/components/workflow/types/dcrTypes.d.ts +2 -2
- package/package.json +5 -5
- package/cjs/components/EntityTypesSelector/ListLabel/ListLabel.d.ts +0 -12
- package/cjs/components/EntityTypesSelector/ListLabel/helpers.d.ts +0 -3
- package/cjs/components/EntityTypesSelector/ListLabel/styles.d.ts +0 -1
- package/cjs/components/EntityTypesSelector/SelectEntityTypesList.d.ts +0 -16
- package/cjs/components/EntityTypesSelector/styles.d.ts +0 -1
- package/esm/components/EntityTypesSelector/ListLabel/ListLabel.d.ts +0 -12
- package/esm/components/EntityTypesSelector/ListLabel/helpers.d.ts +0 -3
- package/esm/components/EntityTypesSelector/ListLabel/styles.d.ts +0 -1
- package/esm/components/EntityTypesSelector/SelectEntityTypesList.d.ts +0 -16
- package/esm/components/EntityTypesSelector/styles.d.ts +0 -1
|
@@ -1,55 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
label: PropTypes.Requireable<string>;
|
|
19
|
-
uri: PropTypes.Requireable<string>;
|
|
20
|
-
attributes: PropTypes.Requireable<PropTypes.InferProps<{
|
|
21
|
-
label: PropTypes.Requireable<string>;
|
|
22
|
-
name: PropTypes.Requireable<string>;
|
|
23
|
-
description: PropTypes.Requireable<string>;
|
|
24
|
-
type: PropTypes.Requireable<string>;
|
|
25
|
-
hidden: PropTypes.Requireable<boolean>;
|
|
26
|
-
faceted: PropTypes.Requireable<boolean>;
|
|
27
|
-
searchable: PropTypes.Requireable<boolean>;
|
|
28
|
-
uri: PropTypes.Requireable<string>;
|
|
29
|
-
access: PropTypes.Requireable<string[]>;
|
|
30
|
-
cardinality: PropTypes.Requireable<PropTypes.InferProps<{
|
|
31
|
-
minValue: PropTypes.Requireable<number>;
|
|
32
|
-
maxValue: PropTypes.Requireable<number>;
|
|
33
|
-
}>>;
|
|
34
|
-
}>[]>;
|
|
35
|
-
}>[]>;
|
|
36
|
-
selectedEntityTypes: PropTypes.Validator<string[]>;
|
|
37
|
-
onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
38
|
-
single: PropTypes.Requireable<boolean>;
|
|
39
|
-
enableEmptyValueUnderline: PropTypes.Requireable<boolean>;
|
|
40
|
-
placeholder: PropTypes.Requireable<string>;
|
|
41
|
-
classes: PropTypes.Requireable<PropTypes.InferProps<{
|
|
42
|
-
root: PropTypes.Requireable<string>;
|
|
43
|
-
label: PropTypes.Requireable<string>;
|
|
44
|
-
inputText: PropTypes.Requireable<string>;
|
|
45
|
-
input: PropTypes.Requireable<string>;
|
|
46
|
-
}>>;
|
|
47
|
-
ListLabelProps: PropTypes.Requireable<PropTypes.InferProps<{
|
|
48
|
-
maxWidth: PropTypes.Requireable<number>;
|
|
49
|
-
}>>;
|
|
50
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
51
|
-
};
|
|
52
|
-
}>;
|
|
53
|
-
export default _default;
|
|
54
|
-
import PropTypes from "prop-types";
|
|
55
|
-
import React from "react";
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TEntityType } from '@reltio/mdm-sdk';
|
|
3
|
+
import { MetadataTypesSelector } from '../MetadataTypesSelector/MetadataTypesSelector';
|
|
4
|
+
declare type MetadataTypesSelectorProps = React.ComponentProps<typeof MetadataTypesSelector>;
|
|
5
|
+
declare type Props = {
|
|
6
|
+
entityTypes: TEntityType[];
|
|
7
|
+
selectedEntityTypes: string[];
|
|
8
|
+
onChange: (values: string[]) => void;
|
|
9
|
+
single?: boolean;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
enableEmptyValueUnderline?: boolean;
|
|
12
|
+
classes?: MetadataTypesSelectorProps['classes'];
|
|
13
|
+
ListLabelProps?: MetadataTypesSelectorProps['ListLabelProps'];
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const EntityTypesSelector: React.MemoExoticComponent<({ entityTypes, selectedEntityTypes, single, placeholder, enableEmptyValueUnderline, onChange, classes, ListLabelProps, disabled }: Props) => JSX.Element>;
|
|
17
|
+
export {};
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -33,113 +22,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
33
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
23
|
};
|
|
35
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.EntityTypesSelector = void 0;
|
|
36
26
|
var react_1 = __importStar(require("react"));
|
|
37
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
38
27
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
39
|
-
var ramda_1 = require("ramda");
|
|
40
|
-
var classnames_1 = __importDefault(require("classnames"));
|
|
41
|
-
var icons_1 = require("@material-ui/icons");
|
|
42
|
-
var TextField_1 = __importDefault(require("@material-ui/core/TextField"));
|
|
43
28
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var LIST_HEIGHT = 245;
|
|
52
|
-
var POPUP_HEIGHT = 355;
|
|
53
|
-
var EntityTypesSelector = function (_a) {
|
|
54
|
-
var _b, _c, _d, _e;
|
|
55
|
-
var entityTypes = _a.entityTypes, selectedEntityTypes = _a.selectedEntityTypes, single = _a.single, placeholder = _a.placeholder, enableEmptyValueUnderline = _a.enableEmptyValueUnderline, onChange = _a.onChange, _f = _a.classes, classes = _f === void 0 ? {} : _f, _g = _a.ListLabelProps, ListLabelProps = _g === void 0 ? {} : _g, _h = _a.disabled, disabled = _h === void 0 ? false : _h;
|
|
56
|
-
var styles = styles_1.useStyles();
|
|
57
|
-
var _j = react_1.useState(false), isPopupOpen = _j[0], setIsPopupOpen = _j[1];
|
|
58
|
-
var openPopup = react_1.useCallback(function () { return setIsPopupOpen(true); }, []);
|
|
59
|
-
var closePopup = react_1.useCallback(function () { return setIsPopupOpen(false); }, []);
|
|
60
|
-
var _k = react_1.useState(''), filterText = _k[0], setFilterText = _k[1];
|
|
61
|
-
var clearFilterText = react_1.useCallback(function () { return setFilterText(''); }, []);
|
|
62
|
-
var handleClose = react_1.useCallback(ramda_1.pipe(clearFilterText, closePopup), [closePopup, clearFilterText]);
|
|
63
|
-
var items = react_1.useMemo(function () {
|
|
64
|
-
return entityTypes
|
|
65
|
-
.filter(mdm_sdk_1.isAvailableEntityType)
|
|
66
|
-
.filter(function (_a) {
|
|
67
|
-
var label = _a.label;
|
|
68
|
-
return mdm_sdk_1.utils.strings.search(label, filterText);
|
|
69
|
-
})
|
|
70
|
-
.map(function (item, index) { return ({ item: { item: __assign(__assign({}, item), { filterText: filterText }) }, index: index }); });
|
|
71
|
-
}, [entityTypes, filterText]);
|
|
72
|
-
var selectedLabels = react_1.useMemo(function () { return selectedEntityTypes.map(function (uri) { return entityTypes.find(ramda_1.propEq('uri', uri)); }).map(ramda_1.prop('label')); }, [selectedEntityTypes, entityTypes]);
|
|
73
|
-
var handleListItemClick = react_1.useCallback(function (entityType, checked) {
|
|
74
|
-
if (single) {
|
|
75
|
-
onChange(checked ? [entityType.uri] : []);
|
|
76
|
-
handleClose();
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
onChange(checked
|
|
80
|
-
? selectedEntityTypes.concat(entityType.uri)
|
|
81
|
-
: selectedEntityTypes.filter(function (uri) { return uri !== entityType.uri; }));
|
|
82
|
-
}
|
|
83
|
-
}, [selectedEntityTypes, onChange, single, handleClose]);
|
|
84
|
-
var handleSearchOnEnter = react_1.useCallback(function (_a) {
|
|
85
|
-
var item = _a.item;
|
|
86
|
-
var checked = !selectedEntityTypes.includes(item.uri);
|
|
87
|
-
handleListItemClick(item, checked);
|
|
88
|
-
}, [selectedEntityTypes, handleListItemClick]);
|
|
89
|
-
var _l = helpers_1.useKeyboardNavigation({
|
|
90
|
-
items: items,
|
|
91
|
-
open: isPopupOpen,
|
|
92
|
-
onSelectFocusedItem: handleSearchOnEnter,
|
|
93
|
-
selectedItems: selectedEntityTypes,
|
|
94
|
-
onClose: handleClose
|
|
95
|
-
}), focusIndex = _l.focusIndex, handleKeyDown = _l.handleKeyDown;
|
|
96
|
-
var rootRef = react_1.useRef();
|
|
97
|
-
var rootWidth = rootRef.current ? rootRef.current.getBoundingClientRect().width : 0;
|
|
98
|
-
var containerWidth = Math.max(rootWidth, MIN_CONTAINER_WIDTH);
|
|
99
|
-
var noTypesSelected = selectedEntityTypes.length === 0;
|
|
100
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
101
|
-
react_1.default.createElement(TextField_1.default, { label: ui_i18n_1.default.text('Entity type'), ref: rootRef, InputProps: {
|
|
102
|
-
startAdornment: noTypesSelected && !placeholder ? null : (react_1.default.createElement("div", { className: classnames_1.default(styles.inputText, classes.inputText) }, noTypesSelected ? (react_1.default.createElement("div", null, placeholder)) : (react_1.default.createElement(ListLabel_1.default, __assign({}, ListLabelProps, { list: selectedLabels }))))),
|
|
103
|
-
classes: {
|
|
104
|
-
root: styles.inputRoot,
|
|
105
|
-
input: classnames_1.default(styles.input, classes.input, (_b = {},
|
|
106
|
-
_b[styles.emptyInput] = noTypesSelected && !placeholder,
|
|
107
|
-
_b)),
|
|
108
|
-
disabled: classnames_1.default(styles.disabledInput, (_c = {}, _c[styles.disabledPointer] = disabled, _c)),
|
|
109
|
-
underline: styles.disabledUnderline
|
|
110
|
-
},
|
|
111
|
-
endAdornment: (react_1.default.createElement(SmallIconButton_1.default, { size: 'L', icon: icons_1.ArrowDropDown, iconClassName: classnames_1.default(styles.icon, (_d = {},
|
|
112
|
-
_d[styles['popup-opened-icon']] = isPopupOpen,
|
|
113
|
-
_d)), disabled: disabled })),
|
|
114
|
-
readOnly: true,
|
|
115
|
-
disabled: true,
|
|
116
|
-
disableUnderline: noTypesSelected && !enableEmptyValueUnderline
|
|
117
|
-
}, inputProps: {
|
|
118
|
-
tabIndex: -1
|
|
119
|
-
}, InputLabelProps: {
|
|
120
|
-
classes: {
|
|
121
|
-
root: classnames_1.default(styles.inputLabel, classes.label)
|
|
122
|
-
}
|
|
123
|
-
}, value: "", onClick: disabled ? undefined : openPopup, classes: { root: classnames_1.default(styles.root, classes.root) }, margin: "dense", variant: "filled", disabled: disabled, "data-reltio-id": "entity-type-selector" }),
|
|
124
|
-
react_1.default.createElement(SelectionPopup_1.default, { open: isPopupOpen, anchorEl: rootRef.current, onClose: handleClose, onSearch: setFilterText, title: ui_i18n_1.default.text('Select entity types'), containerWidth: containerWidth, containerHeight: POPUP_HEIGHT, searchInputOnKeyDown: handleKeyDown, transformOrigin: { horizontal: 'left', vertical: 'top' }, anchorOrigin: { horizontal: 'left', vertical: 'bottom' }, PaperProps: (_e = {}, _e['data-reltio-id'] = 'entity-type-selector-popup', _e) },
|
|
125
|
-
react_1.default.createElement(SelectEntityTypesList_1.default, { items: items, onItemClick: handleListItemClick, selectedEntityTypes: selectedEntityTypes, width: containerWidth, height: LIST_HEIGHT, focusIndex: focusIndex }))));
|
|
126
|
-
};
|
|
127
|
-
EntityTypesSelector.propTypes = {
|
|
128
|
-
entityTypes: prop_types_1.default.arrayOf(mdm_sdk_1.EntityTypeType),
|
|
129
|
-
selectedEntityTypes: prop_types_1.default.arrayOf(prop_types_1.default.string).isRequired,
|
|
130
|
-
onChange: prop_types_1.default.func.isRequired,
|
|
131
|
-
single: prop_types_1.default.bool,
|
|
132
|
-
enableEmptyValueUnderline: prop_types_1.default.bool,
|
|
133
|
-
placeholder: prop_types_1.default.string,
|
|
134
|
-
classes: prop_types_1.default.shape({
|
|
135
|
-
root: prop_types_1.default.string,
|
|
136
|
-
label: prop_types_1.default.string,
|
|
137
|
-
inputText: prop_types_1.default.string,
|
|
138
|
-
input: prop_types_1.default.string
|
|
139
|
-
}),
|
|
140
|
-
ListLabelProps: prop_types_1.default.shape({
|
|
141
|
-
maxWidth: prop_types_1.default.number
|
|
142
|
-
}),
|
|
143
|
-
disabled: prop_types_1.default.bool
|
|
144
|
-
};
|
|
145
|
-
exports.default = react_1.memo(EntityTypesSelector);
|
|
29
|
+
var MetadataTypesSelector_1 = require("../MetadataTypesSelector/MetadataTypesSelector");
|
|
30
|
+
exports.EntityTypesSelector = react_1.memo(function (_a) {
|
|
31
|
+
var entityTypes = _a.entityTypes, selectedEntityTypes = _a.selectedEntityTypes, single = _a.single, placeholder = _a.placeholder, enableEmptyValueUnderline = _a.enableEmptyValueUnderline, onChange = _a.onChange, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.ListLabelProps, ListLabelProps = _c === void 0 ? {} : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d;
|
|
32
|
+
var items = react_1.useMemo(function () { return entityTypes.filter(mdm_sdk_1.isAvailableEntityType); }, [entityTypes]);
|
|
33
|
+
return (react_1.default.createElement(MetadataTypesSelector_1.MetadataTypesSelector, { items: items, selectedItemsUris: selectedEntityTypes, single: single, placeholder: placeholder, enableEmptyValueUnderline: enableEmptyValueUnderline, onChange: onChange, classes: classes, ListLabelProps: ListLabelProps, disabled: disabled, label: ui_i18n_1.default.text('Entity type'), dataReltioId: "entity-type-selector", selectionPopupTitle: ui_i18n_1.default.text('Select entity types') }));
|
|
34
|
+
});
|
|
35
|
+
exports.EntityTypesSelector.displayName = 'EntityTypesSelector';
|
|
@@ -22,8 +22,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ListLabel = void 0;
|
|
25
26
|
var react_1 = __importStar(require("react"));
|
|
26
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
27
27
|
var Tooltip_1 = __importDefault(require("@material-ui/core/Tooltip"));
|
|
28
28
|
var styles_1 = require("./styles");
|
|
29
29
|
var helpers_1 = require("./helpers");
|
|
@@ -44,8 +44,4 @@ var ListLabel = function (_a) {
|
|
|
44
44
|
react_1.default.createElement("div", { className: styles.visibleItemsLabel }, visibleItemsLabel),
|
|
45
45
|
hasHiddenItems && react_1.default.createElement("div", { className: styles.hiddenCount }, "+" + hiddenItemsCount))));
|
|
46
46
|
};
|
|
47
|
-
ListLabel
|
|
48
|
-
list: prop_types_1.default.arrayOf(prop_types_1.default.string).isRequired,
|
|
49
|
-
maxWidth: prop_types_1.default.number
|
|
50
|
-
};
|
|
51
|
-
exports.default = ListLabel;
|
|
47
|
+
exports.ListLabel = ListLabel;
|
|
@@ -24,7 +24,7 @@ var countOverflowItems = function (list, labelEl) {
|
|
|
24
24
|
var findFirstOverflowItemIndex = function (list, labelEl) {
|
|
25
25
|
var childNodes = labelEl.childNodes, clientLeft = labelEl.clientLeft, clientWidth = labelEl.clientWidth;
|
|
26
26
|
if (childNodes.length > 0) {
|
|
27
|
-
var textNode = childNodes[0];
|
|
27
|
+
var textNode = Array.from(childNodes)[0];
|
|
28
28
|
var range = document.createRange();
|
|
29
29
|
range.setStart(textNode, 0);
|
|
30
30
|
for (var index = 0; index < list.length; index++) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"listLabelContainer" | "listLabel" | "visibleItemsLabel" | "hiddenCount">;
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TEntityType, TRelationType } from '@reltio/mdm-sdk';
|
|
3
|
+
import { ListLabel } from './ListLabel/ListLabel';
|
|
4
|
+
declare type ListLabelProps = React.ComponentPropsWithoutRef<typeof ListLabel>;
|
|
5
|
+
declare type Classes = {
|
|
6
|
+
inputText?: string;
|
|
7
|
+
input?: string;
|
|
8
|
+
root?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
};
|
|
11
|
+
declare type Props = {
|
|
12
|
+
items: (TEntityType | TRelationType)[];
|
|
13
|
+
selectedItemsUris: string[];
|
|
14
|
+
onChange: (values: string[]) => void;
|
|
15
|
+
label: string;
|
|
16
|
+
dataReltioId: string;
|
|
17
|
+
selectionPopupTitle: string;
|
|
18
|
+
classes?: Classes;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
ListLabelProps?: Omit<ListLabelProps, 'list'>;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
enableEmptyValueUnderline?: boolean;
|
|
23
|
+
single?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const MetadataTypesSelector: React.MemoExoticComponent<({ placeholder, classes, items, selectedItemsUris, onChange, ListLabelProps, disabled, enableEmptyValueUnderline, single, label, dataReltioId, selectionPopupTitle }: Props) => JSX.Element>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MetadataTypesSelector = void 0;
|
|
37
|
+
var react_1 = __importStar(require("react"));
|
|
38
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
39
|
+
var ramda_1 = require("ramda");
|
|
40
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
41
|
+
var TextField_1 = __importDefault(require("@material-ui/core/TextField"));
|
|
42
|
+
var ArrowDropDown_1 = __importDefault(require("@material-ui/icons/ArrowDropDown"));
|
|
43
|
+
var ListLabel_1 = require("./ListLabel/ListLabel");
|
|
44
|
+
var SmallIconButton_1 = require("../SmallIconButton");
|
|
45
|
+
var SelectionPopup_1 = __importDefault(require("../SelectionPopup/SelectionPopup"));
|
|
46
|
+
var helpers_1 = require("../SelectionPopup/helpers");
|
|
47
|
+
var SelectMetadataTypesList_1 = require("./SelectMetadataTypesList");
|
|
48
|
+
var styles_1 = require("./styles");
|
|
49
|
+
var MIN_CONTAINER_WIDTH = 255;
|
|
50
|
+
var LIST_HEIGHT = 245;
|
|
51
|
+
var POPUP_HEIGHT = 355;
|
|
52
|
+
exports.MetadataTypesSelector = react_1.memo(function (_a) {
|
|
53
|
+
var _b, _c, _d, _e;
|
|
54
|
+
var placeholder = _a.placeholder, _f = _a.classes, classes = _f === void 0 ? {} : _f, items = _a.items, selectedItemsUris = _a.selectedItemsUris, onChange = _a.onChange, _g = _a.ListLabelProps, ListLabelProps = _g === void 0 ? {} : _g, disabled = _a.disabled, enableEmptyValueUnderline = _a.enableEmptyValueUnderline, single = _a.single, label = _a.label, dataReltioId = _a.dataReltioId, selectionPopupTitle = _a.selectionPopupTitle;
|
|
55
|
+
var styles = styles_1.useStyles();
|
|
56
|
+
var _h = react_1.useState(false), isPopupOpen = _h[0], setIsPopupOpen = _h[1];
|
|
57
|
+
var openPopup = react_1.useCallback(function () { return setIsPopupOpen(true); }, []);
|
|
58
|
+
var closePopup = react_1.useCallback(function () { return setIsPopupOpen(false); }, []);
|
|
59
|
+
var _j = react_1.useState(''), filterText = _j[0], setFilterText = _j[1];
|
|
60
|
+
var clearFilterText = react_1.useCallback(function () { return setFilterText(''); }, []);
|
|
61
|
+
var handleClose = react_1.useCallback(ramda_1.pipe(clearFilterText, closePopup), [closePopup, clearFilterText]);
|
|
62
|
+
var filteredItems = items
|
|
63
|
+
.filter(function (_a) {
|
|
64
|
+
var label = _a.label;
|
|
65
|
+
return mdm_sdk_1.utils.strings.search(label, filterText);
|
|
66
|
+
})
|
|
67
|
+
.map(function (item, index) { return ({ item: { item: __assign(__assign({}, item), { filterText: filterText }) }, index: index }); });
|
|
68
|
+
var selectedLabels = react_1.useMemo(function () { return selectedItemsUris.map(function (uri) { return items.find(ramda_1.propEq('uri', uri)); }).map(ramda_1.prop('label')); }, [selectedItemsUris, items]);
|
|
69
|
+
var handleListItemClick = react_1.useCallback(function (item, checked) {
|
|
70
|
+
if (single) {
|
|
71
|
+
onChange(checked ? [item.uri] : []);
|
|
72
|
+
handleClose();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
onChange(checked
|
|
76
|
+
? selectedItemsUris.concat(item.uri)
|
|
77
|
+
: selectedItemsUris.filter(function (uri) { return uri !== item.uri; }));
|
|
78
|
+
}
|
|
79
|
+
}, [selectedItemsUris, onChange, single, handleClose]);
|
|
80
|
+
var handleSearchOnEnter = react_1.useCallback(function (_a) {
|
|
81
|
+
var item = _a.item;
|
|
82
|
+
var checked = !selectedItemsUris.includes(item.uri);
|
|
83
|
+
handleListItemClick(item, checked);
|
|
84
|
+
}, [selectedItemsUris, handleListItemClick]);
|
|
85
|
+
var _k = helpers_1.useKeyboardNavigation({
|
|
86
|
+
items: filteredItems,
|
|
87
|
+
open: isPopupOpen,
|
|
88
|
+
onSelectFocusedItem: handleSearchOnEnter,
|
|
89
|
+
selectedItems: selectedItemsUris,
|
|
90
|
+
onClose: handleClose
|
|
91
|
+
}), focusIndex = _k.focusIndex, handleKeyDown = _k.handleKeyDown;
|
|
92
|
+
var rootRef = react_1.useRef();
|
|
93
|
+
var rootWidth = rootRef.current ? rootRef.current.getBoundingClientRect().width : 0;
|
|
94
|
+
var containerWidth = Math.max(rootWidth, MIN_CONTAINER_WIDTH);
|
|
95
|
+
var noTypesSelected = selectedItemsUris.length === 0;
|
|
96
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
97
|
+
react_1.default.createElement(TextField_1.default, { label: label, ref: rootRef, InputProps: {
|
|
98
|
+
startAdornment: noTypesSelected && !placeholder ? null : (react_1.default.createElement("div", { className: classnames_1.default(styles.inputText, classes.inputText) }, noTypesSelected ? (react_1.default.createElement("div", null, placeholder)) : (react_1.default.createElement(ListLabel_1.ListLabel, __assign({}, ListLabelProps, { list: selectedLabels }))))),
|
|
99
|
+
classes: {
|
|
100
|
+
root: styles.inputRoot,
|
|
101
|
+
input: classnames_1.default(styles.input, classes.input, (_b = {},
|
|
102
|
+
_b[styles.emptyInput] = noTypesSelected && !placeholder,
|
|
103
|
+
_b)),
|
|
104
|
+
disabled: classnames_1.default(styles.disabledInput, (_c = {}, _c[styles.disabledPointer] = disabled, _c)),
|
|
105
|
+
underline: styles.disabledUnderline
|
|
106
|
+
},
|
|
107
|
+
endAdornment: (react_1.default.createElement(SmallIconButton_1.SmallIconButton, { size: 'L', icon: ArrowDropDown_1.default, iconClassName: classnames_1.default(styles.icon, (_d = {},
|
|
108
|
+
_d[styles['popup-opened-icon']] = isPopupOpen,
|
|
109
|
+
_d)), disabled: disabled })),
|
|
110
|
+
readOnly: true,
|
|
111
|
+
disabled: true,
|
|
112
|
+
disableUnderline: noTypesSelected && !enableEmptyValueUnderline
|
|
113
|
+
}, inputProps: {
|
|
114
|
+
tabIndex: -1
|
|
115
|
+
}, InputLabelProps: {
|
|
116
|
+
classes: {
|
|
117
|
+
root: classnames_1.default(styles.inputLabel, classes.label)
|
|
118
|
+
}
|
|
119
|
+
}, value: "", onClick: disabled ? undefined : openPopup, classes: { root: classnames_1.default(styles.root, classes.root) }, margin: "dense", variant: "filled", disabled: disabled, "data-reltio-id": dataReltioId }),
|
|
120
|
+
react_1.default.createElement(SelectionPopup_1.default, { open: isPopupOpen, anchorEl: rootRef.current, onClose: handleClose, onSearch: setFilterText, title: selectionPopupTitle, containerWidth: containerWidth, containerHeight: POPUP_HEIGHT, searchInputOnKeyDown: handleKeyDown, transformOrigin: { horizontal: 'left', vertical: 'top' }, anchorOrigin: { horizontal: 'left', vertical: 'bottom' }, PaperProps: (_e = {}, _e['data-reltio-id'] = dataReltioId + "-popup", _e) },
|
|
121
|
+
react_1.default.createElement(SelectMetadataTypesList_1.SelectMetadataTypesList, { items: filteredItems, onItemClick: handleListItemClick, selectedItems: selectedItemsUris, width: containerWidth, height: LIST_HEIGHT, focusIndex: focusIndex }))));
|
|
122
|
+
});
|
|
123
|
+
exports.MetadataTypesSelector.displayName = 'MetadataTypesSelector';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TEntityType, TRelationType } from '@reltio/mdm-sdk';
|
|
3
|
+
import AttributeListItem from '../AttributeListItem/AttributeListItem';
|
|
4
|
+
declare type AttributeListItemProps = React.ComponentPropsWithoutRef<typeof AttributeListItem>;
|
|
5
|
+
declare type Item = {
|
|
6
|
+
item: {
|
|
7
|
+
item: TEntityType | TRelationType;
|
|
8
|
+
};
|
|
9
|
+
index: number;
|
|
10
|
+
};
|
|
11
|
+
declare type Props = {
|
|
12
|
+
selectedItems: string[];
|
|
13
|
+
onItemClick: AttributeListItemProps['onClick'];
|
|
14
|
+
focusIndex: number;
|
|
15
|
+
items: Item[];
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
export declare const SelectMetadataTypesList: React.MemoExoticComponent<({ selectedItems, onItemClick, focusIndex, width, height, ...otherProps }: Props) => JSX.Element>;
|
|
20
|
+
export {};
|
|
@@ -44,27 +44,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
44
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
45
45
|
};
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.SelectMetadataTypesList = void 0;
|
|
47
48
|
var react_1 = __importStar(require("react"));
|
|
48
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
49
49
|
var ramda_1 = require("ramda");
|
|
50
50
|
var AttributeListItem_1 = __importDefault(require("../AttributeListItem/AttributeListItem"));
|
|
51
51
|
var Highlighter_1 = __importDefault(require("../Highlighter/Highlighter"));
|
|
52
52
|
var VirtualGroupedList_1 = __importDefault(require("../VirtualGroupedList/VirtualGroupedList"));
|
|
53
53
|
var ITEM_HEIGHT = 32;
|
|
54
54
|
var getItemSize = ramda_1.always(ITEM_HEIGHT);
|
|
55
|
-
|
|
56
|
-
var
|
|
55
|
+
exports.SelectMetadataTypesList = react_1.memo(function (_a) {
|
|
56
|
+
var selectedItems = _a.selectedItems, onItemClick = _a.onItemClick, focusIndex = _a.focusIndex, width = _a.width, height = _a.height, otherProps = __rest(_a, ["selectedItems", "onItemClick", "focusIndex", "width", "height"]);
|
|
57
57
|
var renderItem = function (style, _a, index) {
|
|
58
58
|
var item = _a.item;
|
|
59
|
-
var isSelected = !!
|
|
59
|
+
var isSelected = !!selectedItems.find(function (uri) { return item.uri === uri; });
|
|
60
60
|
var isFocused = index === focusIndex;
|
|
61
61
|
return (react_1.default.createElement(AttributeListItem_1.default, { key: item.uri, onClick: onItemClick, checked: isSelected, data: item, label: react_1.default.createElement(Highlighter_1.default, { text: item.label, highlight: item.filterText }), labelInText: item.label, style: style, isFocused: isFocused, hideIcon: true, LogoIcon: item.LogoIcon }));
|
|
62
62
|
};
|
|
63
|
-
return (react_1.default.createElement(VirtualGroupedList_1.default, __assign({ getItemSize: getItemSize, renderItem: renderItem, focusIndex: focusIndex, fixedTitle: false, disableHorizontalScrollbar: true }, otherProps)));
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
selectedEntityTypes: prop_types_1.default.array,
|
|
67
|
-
onItemClick: prop_types_1.default.func,
|
|
68
|
-
focusIndex: prop_types_1.default.number
|
|
69
|
-
};
|
|
70
|
-
exports.default = react_1.memo(SelectEntityTypesList);
|
|
63
|
+
return (react_1.default.createElement(VirtualGroupedList_1.default, __assign({ getItemSize: getItemSize, renderItem: renderItem, focusIndex: focusIndex, fixedTitle: false, disableHorizontalScrollbar: true, width: width, height: height }, otherProps)));
|
|
64
|
+
});
|
|
65
|
+
exports.SelectMetadataTypesList.displayName = 'SelectMetadataTypesList';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"icon" | "input" | "root" | "inputLabel" | "inputRoot" | "inputText" | "emptyInput" | "disabledInput" | "disabledPointer" | "disabledUnderline" | "popup-opened-icon">;
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TRelationType } from '@reltio/mdm-sdk';
|
|
3
|
+
import { MetadataTypesSelector } from '../MetadataTypesSelector/MetadataTypesSelector';
|
|
4
|
+
declare type MetadataTypesSelectorProps = React.ComponentProps<typeof MetadataTypesSelector>;
|
|
5
|
+
declare type Props = {
|
|
6
|
+
relationTypes: TRelationType[];
|
|
7
|
+
selectedRelationTypes: string[];
|
|
8
|
+
enableEmptyValueUnderline?: boolean;
|
|
9
|
+
onChange: (values: string[]) => void;
|
|
10
|
+
single?: boolean;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
classes?: MetadataTypesSelectorProps['classes'];
|
|
13
|
+
ListLabelProps?: MetadataTypesSelectorProps['ListLabelProps'];
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const RelationTypesSelector: React.MemoExoticComponent<({ relationTypes, selectedRelationTypes, single, placeholder, enableEmptyValueUnderline, onChange, classes, ListLabelProps, disabled }: Props) => JSX.Element>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.RelationTypesSelector = void 0;
|
|
26
|
+
var react_1 = __importStar(require("react"));
|
|
27
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
28
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
29
|
+
var MetadataTypesSelector_1 = require("../MetadataTypesSelector/MetadataTypesSelector");
|
|
30
|
+
exports.RelationTypesSelector = react_1.memo(function (_a) {
|
|
31
|
+
var relationTypes = _a.relationTypes, selectedRelationTypes = _a.selectedRelationTypes, single = _a.single, placeholder = _a.placeholder, enableEmptyValueUnderline = _a.enableEmptyValueUnderline, onChange = _a.onChange, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.ListLabelProps, ListLabelProps = _c === void 0 ? {} : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d;
|
|
32
|
+
var items = react_1.useMemo(function () { return relationTypes.filter(mdm_sdk_1.isAvailableRelationType); }, [relationTypes]);
|
|
33
|
+
return (react_1.default.createElement(MetadataTypesSelector_1.MetadataTypesSelector, { items: items, selectedItemsUris: selectedRelationTypes, single: single, placeholder: placeholder, enableEmptyValueUnderline: enableEmptyValueUnderline, onChange: onChange, classes: classes, ListLabelProps: ListLabelProps, disabled: disabled, label: ui_i18n_1.default.text('Relation type'), dataReltioId: "relation-type-selector", selectionPopupTitle: ui_i18n_1.default.text('Select relation types') }));
|
|
34
|
+
});
|
|
35
|
+
exports.RelationTypesSelector.displayName = 'RelationTypesSelector';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InputProps } from '@material-ui/core/Input';
|
|
3
3
|
export declare type SearchInputProps = InputProps & {
|
|
4
|
-
value
|
|
4
|
+
value?: string;
|
|
5
5
|
autofocus: boolean;
|
|
6
6
|
onSearch: (value?: string) => void;
|
|
7
7
|
rootRef?: React.MutableRefObject<HTMLInputElement>;
|
|
8
8
|
height: number;
|
|
9
|
+
placeholder?: string;
|
|
9
10
|
};
|
|
10
|
-
declare const _default: React.MemoExoticComponent<({ value, autofocus, onSearch, rootRef, classes, height, ...otherProps }: SearchInputProps) => JSX.Element>;
|
|
11
|
+
declare const _default: React.MemoExoticComponent<({ value, autofocus, onSearch, rootRef, classes, height, placeholder, ...otherProps }: SearchInputProps) => JSX.Element>;
|
|
11
12
|
export default _default;
|
|
@@ -56,13 +56,13 @@ var core_1 = require("../../core");
|
|
|
56
56
|
var SmallIconButton_1 = __importDefault(require("../SmallIconButton/SmallIconButton"));
|
|
57
57
|
var styles_1 = require("./styles");
|
|
58
58
|
var SearchInput = function (_a) {
|
|
59
|
-
var value = _a.value, autofocus = _a.autofocus, _b = _a.onSearch, onSearch = _b === void 0 ? core_1.noop : _b, rootRef = _a.rootRef, _c = _a.classes, classes = _c === void 0 ? {} : _c, height = _a.height, otherProps = __rest(_a, ["value", "autofocus", "onSearch", "rootRef", "classes", "height"]);
|
|
59
|
+
var value = _a.value, autofocus = _a.autofocus, _b = _a.onSearch, onSearch = _b === void 0 ? core_1.noop : _b, rootRef = _a.rootRef, _c = _a.classes, classes = _c === void 0 ? {} : _c, height = _a.height, _d = _a.placeholder, placeholder = _d === void 0 ? ui_i18n_1.default.text('Search') : _d, otherProps = __rest(_a, ["value", "autofocus", "onSearch", "rootRef", "classes", "height", "placeholder"]);
|
|
60
60
|
var styles = styles_1.useStyles({ height: height });
|
|
61
|
-
var
|
|
61
|
+
var _e = react_1.useState(''), localValue = _e[0], setLocalValue = _e[1];
|
|
62
62
|
var updateValue = ramda_1.pipe(ramda_1.tap(onSearch), setLocalValue);
|
|
63
63
|
var clearValue = function () { return updateValue(''); };
|
|
64
64
|
var inputValue = ramda_1.isNil(value) ? localValue : value;
|
|
65
65
|
return (react_1.default.createElement(Input_1.default, __assign({ startAdornment: react_1.default.createElement(InputAdornment_1.default, { position: "start" },
|
|
66
|
-
react_1.default.createElement(Search_1.default, { className: styles.icon })), endAdornment: react_1.default.createElement(InputAdornment_1.default, { position: "end" }, inputValue.length > 0 && (react_1.default.createElement(SmallIconButton_1.default, { icon: Close_1.default, className: styles.clearButton, onClick: clearValue }))), autoFocus: autofocus, classes: __assign(__assign({}, classes), { input: classnames_1.default(styles.input, classes.input), root: classnames_1.default(styles.container, classes.root) }), placeholder:
|
|
66
|
+
react_1.default.createElement(Search_1.default, { className: styles.icon })), endAdornment: react_1.default.createElement(InputAdornment_1.default, { position: "end" }, inputValue.length > 0 && (react_1.default.createElement(SmallIconButton_1.default, { icon: Close_1.default, className: styles.clearButton, onClick: clearValue }))), autoFocus: autofocus, classes: __assign(__assign({}, classes), { input: classnames_1.default(styles.input, classes.input), root: classnames_1.default(styles.container, classes.root) }), placeholder: placeholder, value: inputValue, onChange: ramda_1.pipe(core_1.getValue, updateValue), disableUnderline: true, ref: rootRef }, otherProps)));
|
|
67
67
|
};
|
|
68
68
|
exports.default = react_1.memo(SearchInput);
|
|
@@ -1,45 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PopoverProps } from '@material-ui/core/Popover';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
title: string;
|
|
5
|
+
containerWidth: number;
|
|
6
|
+
containerHeight: number;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
PaperProps: Record<string, unknown>;
|
|
9
|
+
searchInputOnKeyDown: (event: React.KeyboardEvent) => void;
|
|
10
|
+
onSearch: (value?: string) => void;
|
|
11
|
+
className?: string;
|
|
12
|
+
hideTitle?: boolean;
|
|
13
|
+
hideSearchInput?: boolean;
|
|
14
|
+
headerPlacement?: 'top' | 'bottom';
|
|
15
|
+
searchInputRef?: React.Ref<unknown>;
|
|
16
|
+
} & PopoverProps;
|
|
17
|
+
declare const SelectionPopup: ({ title, className, onSearch, hideTitle, hideSearchInput, headerPlacement, containerWidth, containerHeight, searchInputOnKeyDown, children, searchInputRef, anchorOrigin, transformOrigin, ...otherProps }: Props) => JSX.Element;
|
|
1
18
|
export default SelectionPopup;
|
|
2
|
-
declare function SelectionPopup({ title, className, onSearch, hideTitle, hideSearchInput, headerPlacement, containerWidth, containerHeight, searchInputOnKeyDown, children, searchInputRef, ...otherProps }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
title: any;
|
|
5
|
-
className: any;
|
|
6
|
-
onSearch: any;
|
|
7
|
-
hideTitle: any;
|
|
8
|
-
hideSearchInput: any;
|
|
9
|
-
headerPlacement?: string;
|
|
10
|
-
containerWidth: any;
|
|
11
|
-
containerHeight: any;
|
|
12
|
-
searchInputOnKeyDown: any;
|
|
13
|
-
children: any;
|
|
14
|
-
searchInputRef: any;
|
|
15
|
-
}): JSX.Element;
|
|
16
|
-
declare namespace SelectionPopup {
|
|
17
|
-
namespace propTypes {
|
|
18
|
-
const className: PropTypes.Requireable<string>;
|
|
19
|
-
const title: PropTypes.Requireable<string>;
|
|
20
|
-
const headerPlacement: PropTypes.Requireable<string>;
|
|
21
|
-
const onSearch: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
-
const searchInputOnKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
-
const containerWidth: PropTypes.Requireable<number>;
|
|
24
|
-
const containerHeight: PropTypes.Requireable<number>;
|
|
25
|
-
const hideTitle: PropTypes.Requireable<boolean>;
|
|
26
|
-
const hideSearchInput: PropTypes.Requireable<boolean>;
|
|
27
|
-
const searchInputRef: PropTypes.Requireable<PropTypes.InferProps<{
|
|
28
|
-
current: PropTypes.Requireable<Element>;
|
|
29
|
-
}>>;
|
|
30
|
-
const children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
31
|
-
}
|
|
32
|
-
namespace defaultProps {
|
|
33
|
-
namespace anchorOrigin {
|
|
34
|
-
const vertical: string;
|
|
35
|
-
const horizontal: string;
|
|
36
|
-
}
|
|
37
|
-
namespace transformOrigin {
|
|
38
|
-
const vertical_1: string;
|
|
39
|
-
export { vertical_1 as vertical };
|
|
40
|
-
const horizontal_1: string;
|
|
41
|
-
export { horizontal_1 as horizontal };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
import PropTypes from "prop-types";
|