@reltio/components 1.4.1737 → 1.4.1739
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/BasicTableView/BasicTableHeader/ColumnsSettings/ColumnsSettings.d.ts +10 -18
- package/cjs/components/BasicTableView/BasicTableHeader/ColumnsSettings/ColumnsSettings.js +3 -12
- package/cjs/components/BasicTableView/types/index.d.ts +7 -1
- package/cjs/components/BasicViewHeader/BasicViewHeader.js +1 -1
- package/cjs/components/MultipleInput/MultipleInput.d.ts +13 -27
- package/cjs/components/MultipleInput/MultipleInput.js +15 -30
- package/cjs/components/MultipleInput/styles.d.ts +1 -1
- package/cjs/components/ScrollableTabs/ScrollableTabs.d.ts +1 -1
- package/cjs/components/SearchInput/SearchInput.d.ts +1 -1
- package/cjs/components/editors/TypeaheadEditor/TypeaheadEditor.d.ts +2 -2
- package/cjs/components/editors/TypeaheadEditor/TypeaheadEditor.js +4 -2
- package/cjs/hooks/index.d.ts +1 -0
- package/cjs/hooks/index.js +3 -1
- package/cjs/hooks/useMatchesColumnsData/helpers.d.ts +4 -0
- package/cjs/hooks/useMatchesColumnsData/helpers.js +56 -0
- package/cjs/hooks/useMatchesColumnsData/useMatchesColumnsData.d.ts +14 -0
- package/cjs/hooks/useMatchesColumnsData/useMatchesColumnsData.js +21 -0
- package/esm/components/BasicTableView/BasicTableHeader/ColumnsSettings/ColumnsSettings.d.ts +10 -18
- package/esm/components/BasicTableView/BasicTableHeader/ColumnsSettings/ColumnsSettings.js +3 -12
- package/esm/components/BasicTableView/types/index.d.ts +7 -1
- package/esm/components/BasicViewHeader/BasicViewHeader.js +1 -1
- package/esm/components/MultipleInput/MultipleInput.d.ts +13 -27
- package/esm/components/MultipleInput/MultipleInput.js +15 -30
- package/esm/components/MultipleInput/styles.d.ts +1 -1
- package/esm/components/ScrollableTabs/ScrollableTabs.d.ts +1 -1
- package/esm/components/SearchInput/SearchInput.d.ts +1 -1
- package/esm/components/editors/TypeaheadEditor/TypeaheadEditor.d.ts +2 -2
- package/esm/components/editors/TypeaheadEditor/TypeaheadEditor.js +6 -4
- package/esm/hooks/index.d.ts +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useMatchesColumnsData/helpers.d.ts +4 -0
- package/esm/hooks/useMatchesColumnsData/helpers.js +48 -0
- package/esm/hooks/useMatchesColumnsData/useMatchesColumnsData.d.ts +14 -0
- package/esm/hooks/useMatchesColumnsData/useMatchesColumnsData.js +17 -0
- package/package.json +2 -2
|
@@ -1,19 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ColumnData } from '../../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
columnsData: ColumnData[];
|
|
5
|
+
selectedColumns: string[];
|
|
6
|
+
onChangeColumns: (columns: string[]) => void;
|
|
7
|
+
title?: string;
|
|
8
|
+
tooltipTitle?: string;
|
|
9
|
+
};
|
|
10
|
+
declare const ColumnsSettings: ({ columnsData, selectedColumns, onChangeColumns, title, tooltipTitle }: Props) => JSX.Element;
|
|
1
11
|
export default ColumnsSettings;
|
|
2
|
-
declare function ColumnsSettings({ columnsData, selectedColumns, onChangeColumns, title, tooltipTitle }: {
|
|
3
|
-
columnsData: any;
|
|
4
|
-
selectedColumns: any;
|
|
5
|
-
onChangeColumns: any;
|
|
6
|
-
title: any;
|
|
7
|
-
tooltipTitle: any;
|
|
8
|
-
}): JSX.Element;
|
|
9
|
-
declare namespace ColumnsSettings {
|
|
10
|
-
namespace propTypes {
|
|
11
|
-
export { ColumnsDataType as columnsData };
|
|
12
|
-
export const selectedColumns: PropTypes.Requireable<string[]>;
|
|
13
|
-
export const onChangeColumns: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
|
-
export const title: PropTypes.Requireable<string>;
|
|
15
|
-
export const tooltipTitle: PropTypes.Requireable<string>;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
import { ColumnsDataType } from '../../../../constants';
|
|
19
|
-
import PropTypes from 'prop-types';
|
|
@@ -27,13 +27,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
var react_1 = __importStar(require("react"));
|
|
30
|
-
var
|
|
31
|
-
var
|
|
30
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
31
|
+
var ramda_1 = require("ramda");
|
|
32
32
|
var Table_1 = __importDefault(require("../../../../icons/Table"));
|
|
33
33
|
var SmallIconButton_1 = require("../../../SmallIconButton");
|
|
34
|
-
var ramda_1 = require("ramda");
|
|
35
34
|
var ColumnsSettingsPopup_1 = require("./ColumnsSettingsPopup");
|
|
36
|
-
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
37
35
|
var columnHelpers_1 = require("./columnHelpers");
|
|
38
36
|
var ColumnsSettings = function (_a) {
|
|
39
37
|
var columnsData = _a.columnsData, selectedColumns = _a.selectedColumns, onChangeColumns = _a.onChangeColumns, title = _a.title, tooltipTitle = _a.tooltipTitle;
|
|
@@ -48,14 +46,7 @@ var ColumnsSettings = function (_a) {
|
|
|
48
46
|
: (0, ramda_1.uniq)((0, ramda_1.concat)(selectedColumns, changedColumns)));
|
|
49
47
|
}, [selectedColumns, onChangeColumns]);
|
|
50
48
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
51
|
-
react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { tooltipTitle: tooltipTitle || ui_i18n_1.default.text('Show/hide columns'), size: "L", icon: Table_1.default, onClick: openPopup }),
|
|
49
|
+
react_1.default.createElement(SmallIconButton_1.SmallIconButtonWithTooltip, { "data-reltio-id": "reltio-columns-settings-button", tooltipTitle: tooltipTitle || ui_i18n_1.default.text('Show/hide columns'), size: "L", icon: Table_1.default, onClick: openPopup }),
|
|
52
50
|
react_1.default.createElement(ColumnsSettingsPopup_1.ColumnsSettingsPopup, { onColumnClick: handleColumnClick, anchorEl: anchorEl, columnsData: columnsData, onClose: closePopup, title: title, selectedColumns: selectedColumns })));
|
|
53
51
|
};
|
|
54
|
-
ColumnsSettings.propTypes = {
|
|
55
|
-
columnsData: constants_1.ColumnsDataType,
|
|
56
|
-
selectedColumns: prop_types_1.default.arrayOf(prop_types_1.default.string),
|
|
57
|
-
onChangeColumns: prop_types_1.default.func,
|
|
58
|
-
title: prop_types_1.default.string,
|
|
59
|
-
tooltipTitle: prop_types_1.default.string
|
|
60
|
-
};
|
|
61
52
|
exports.default = ColumnsSettings;
|
|
@@ -21,7 +21,7 @@ export type ColumnData = {
|
|
|
21
21
|
sortable?: boolean;
|
|
22
22
|
filterable?: boolean;
|
|
23
23
|
resizable?: boolean;
|
|
24
|
-
nestedPath?: string;
|
|
24
|
+
nestedPath?: string[];
|
|
25
25
|
headCellRenderer?: React.ElementType;
|
|
26
26
|
rowCellValueRenderer?: React.ElementType;
|
|
27
27
|
draggable?: boolean;
|
|
@@ -32,6 +32,12 @@ export type ColumnData = {
|
|
|
32
32
|
}>;
|
|
33
33
|
[key: string]: unknown;
|
|
34
34
|
};
|
|
35
|
+
export type GroupedColumns<TColumnData = ColumnData> = {
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
columns: TColumnData[];
|
|
39
|
+
};
|
|
40
|
+
export type GroupedColumnsData<TColumnData = ColumnData> = GroupedColumns<TColumnData> | TColumnData;
|
|
35
41
|
export type CollapseContext = ReturnType<typeof useCollapsibleTableRows>['collapseContextValue'];
|
|
36
42
|
export type RowId = string | number;
|
|
37
43
|
export type RowValue = {
|
|
@@ -34,7 +34,7 @@ var BasicViewHeader = function (_a) {
|
|
|
34
34
|
var _b = _a.title, title = _b === void 0 ? '' : _b, _c = _a.children, children = _c === void 0 ? null : _c, _d = _a.classes, classes = _d === void 0 ? {} : _d, otherProps = __rest(_a, ["title", "children", "classes"]);
|
|
35
35
|
var styles = (0, styles_1.useStyles)();
|
|
36
36
|
return (react_1.default.createElement(Toolbar_1.default, __assign({ className: classes.root, classes: { root: styles.toolbar } }, otherProps),
|
|
37
|
-
react_1.default.createElement(Typography_1.default, { className: classes.title, classes: { root: styles.title }, variant: "h6" }, ui_i18n_1.default.text(title)),
|
|
37
|
+
title && (react_1.default.createElement(Typography_1.default, { className: classes.title, classes: { root: styles.title }, variant: "h6" }, ui_i18n_1.default.text(title))),
|
|
38
38
|
children));
|
|
39
39
|
};
|
|
40
40
|
exports.default = BasicViewHeader;
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
type MultipleInputProps = Omit<TextFieldProps, 'classes' | 'value' | 'onChange' | 'onKeyPress' | 'onKeyDown' | 'onFocus' | 'onBlur'> & {
|
|
4
|
+
values?: string | string[];
|
|
5
|
+
InputProps?: Omit<TextFieldProps['InputProps'], 'startAdornment' | 'inputComponent'>;
|
|
6
|
+
classes?: {
|
|
7
|
+
root?: string;
|
|
8
|
+
};
|
|
9
|
+
isCrossedOut?: boolean;
|
|
10
|
+
onChange?: (values: string[]) => void;
|
|
11
|
+
getValueLabel?: (value: string) => string;
|
|
12
|
+
};
|
|
13
|
+
declare const MultipleInput: ({ values: valuesProp, InputProps, inputProps, classes, isCrossedOut, onChange, getValueLabel, ...otherProps }: MultipleInputProps) => JSX.Element;
|
|
1
14
|
export default MultipleInput;
|
|
2
|
-
declare function MultipleInput({ values, InputProps, inputProps, classes, isCrossedOut, onChange, getValueLabel, ...otherProps }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
values?: any[];
|
|
5
|
-
InputProps?: {};
|
|
6
|
-
inputProps?: {};
|
|
7
|
-
classes?: {};
|
|
8
|
-
isCrossedOut: any;
|
|
9
|
-
onChange?: () => void;
|
|
10
|
-
getValueLabel?: any;
|
|
11
|
-
}): JSX.Element;
|
|
12
|
-
declare namespace MultipleInput {
|
|
13
|
-
namespace propTypes {
|
|
14
|
-
const values: PropTypes.Requireable<string[]>;
|
|
15
|
-
const InputProps: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
-
classes: PropTypes.Requireable<PropTypes.InferProps<{
|
|
17
|
-
root: PropTypes.Requireable<string>;
|
|
18
|
-
}>>;
|
|
19
|
-
inputComponent: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
20
|
-
}>>;
|
|
21
|
-
const inputProps: PropTypes.Requireable<object>;
|
|
22
|
-
const onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
-
const classes: PropTypes.Requireable<object>;
|
|
24
|
-
const getValueLabel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
-
const isCrossedOut: PropTypes.Requireable<boolean>;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
import PropTypes from 'prop-types';
|
|
@@ -57,38 +57,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
57
57
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
58
|
};
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
var react_1 = __importStar(require("react"));
|
|
61
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
62
|
+
var ramda_1 = require("ramda");
|
|
60
63
|
var react_input_autosize_1 = __importDefault(require("react-input-autosize"));
|
|
61
64
|
var classnames_1 = __importDefault(require("classnames"));
|
|
65
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
62
66
|
var TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
63
|
-
var
|
|
64
|
-
var react_1 = __importStar(require("react"));
|
|
65
|
-
var ramda_1 = require("ramda");
|
|
67
|
+
var Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
66
68
|
var utils_1 = require("../../core/utils");
|
|
67
|
-
var styles_1 = require("./styles");
|
|
68
69
|
var ValueChip_1 = __importDefault(require("../ValueChip/ValueChip"));
|
|
69
|
-
var
|
|
70
|
-
var
|
|
70
|
+
var styles_1 = require("./styles");
|
|
71
|
+
var EMPTY_VALUES_EDIT_HINT = ui_i18n_1.default.text('Press Enter to add. You may enter multiple values');
|
|
72
|
+
var isEmptyValue = (0, ramda_1.pipe)(ramda_1.trim, ramda_1.isEmpty);
|
|
71
73
|
var AutosizeInputWrapper = (0, react_1.forwardRef)(function (props, ref) {
|
|
72
74
|
var CustomInputComponent = props.CustomInputComponent, other = __rest(props, ["CustomInputComponent"]);
|
|
73
75
|
return CustomInputComponent ? (react_1.default.createElement(CustomInputComponent, __assign({}, other, { ref: ref, customInput: react_input_autosize_1.default }))) : (react_1.default.createElement(react_input_autosize_1.default, __assign({}, other, { ref: ref })));
|
|
74
76
|
});
|
|
75
|
-
AutosizeInputWrapper.propTypes = {
|
|
76
|
-
CustomInputComponent: prop_types_1.default.elementType
|
|
77
|
-
};
|
|
78
77
|
AutosizeInputWrapper.displayName = 'AutosizeInputWrapper';
|
|
79
|
-
var BACKSPACE_KEY_CODE = 8;
|
|
80
|
-
var EMPTY_VALUES_EDIT_HINT = ui_i18n_1.default.text('Press Enter to add. You may enter multiple values');
|
|
81
|
-
var isEmptyValue = (0, ramda_1.pipe)(ramda_1.trim, ramda_1.isEmpty);
|
|
82
78
|
var MultipleInput = function (_a) {
|
|
83
79
|
var _b;
|
|
84
|
-
var _c = _a.values,
|
|
80
|
+
var _c = _a.values, valuesProp = _c === void 0 ? [] : _c, _d = _a.InputProps, InputProps = _d === void 0 ? {} : _d, _e = _a.inputProps, inputProps = _e === void 0 ? {} : _e, _f = _a.classes, classes = _f === void 0 ? {} : _f, isCrossedOut = _a.isCrossedOut, _g = _a.onChange, onChange = _g === void 0 ? utils_1.noop : _g, _h = _a.getValueLabel, getValueLabel = _h === void 0 ? ramda_1.identity : _h, otherProps = __rest(_a, ["values", "InputProps", "inputProps", "classes", "isCrossedOut", "onChange", "getValueLabel"]);
|
|
85
81
|
var styles = (0, styles_1.useStyles)();
|
|
86
82
|
var _j = InputProps.classes || {}, root = _j.root, InputClasses = __rest(_j, ["root"]);
|
|
87
83
|
var _k = (0, react_1.useState)(''), inputValue = _k[0], setInputValue = _k[1];
|
|
84
|
+
var _l = (0, react_1.useState)(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
85
|
+
var values = (0, mdm_sdk_1.wrapInArrayIfNeeded)(valuesProp);
|
|
86
|
+
var hasValues = values.length > 0;
|
|
88
87
|
var clearInputValue = function () { return setInputValue(''); };
|
|
88
|
+
var setFocused = function () { return setIsFocused(true); };
|
|
89
|
+
var setUnfocused = function () { return setIsFocused(false); };
|
|
89
90
|
var removeValueAt = function (index) { return onChange((0, ramda_1.remove)(index, 1, values)); };
|
|
90
91
|
var appendValue = function (value) { return onChange((0, ramda_1.uniq)(__spreadArray(__spreadArray([], values, true), [value], false))); };
|
|
91
|
-
var hasValues = values.length > 0;
|
|
92
92
|
var appendInputValueIfNotEmpty = function () {
|
|
93
93
|
if (!isEmptyValue(inputValue)) {
|
|
94
94
|
appendValue(inputValue);
|
|
@@ -100,25 +100,10 @@ var MultipleInput = function (_a) {
|
|
|
100
100
|
removeValueAt(-1);
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
var _l = (0, react_1.useState)(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
104
|
-
var setFocused = function () { return setIsFocused(true); };
|
|
105
|
-
var setUnfocused = function () { return setIsFocused(false); };
|
|
106
103
|
var hintText = !hasValues && isFocused ? EMPTY_VALUES_EDIT_HINT : '';
|
|
107
104
|
return (react_1.default.createElement(Tooltip_1.default, { title: hintText },
|
|
108
105
|
react_1.default.createElement(TextField_1.default, __assign({ variant: "standard" }, otherProps, { classes: {
|
|
109
106
|
root: classes.root
|
|
110
|
-
}, value: inputValue, onChange: (0, ramda_1.pipe)(utils_1.getValue, setInputValue), InputProps: __assign(__assign({}, InputProps), { startAdornment: values.map(function (value, index) { return (react_1.default.createElement(ValueChip_1.default, { key: value, label: getValueLabel(value), onDelete: function () { return removeValueAt(index); } })); }), inputComponent: AutosizeInputWrapper, classes: __assign({ root: (0, classnames_1.default)(styles.inputRoot, root, (_b = {}, _b[styles.isCrossedOut] = isCrossedOut, _b)), input: (0, classnames_1.default)(styles.autosizeInput, InputClasses.input) }, InputClasses) }), inputProps: __assign(__assign({}, inputProps), { CustomInputComponent: InputProps.inputComponent }), onKeyPress: (0, ramda_1.when)((0, ramda_1.propEq)('key', 'Enter'), appendInputValueIfNotEmpty), onKeyDown: (0, ramda_1.when)((0, ramda_1.propEq)('
|
|
111
|
-
};
|
|
112
|
-
MultipleInput.propTypes = {
|
|
113
|
-
values: prop_types_1.default.arrayOf(prop_types_1.default.string),
|
|
114
|
-
InputProps: prop_types_1.default.shape({
|
|
115
|
-
classes: prop_types_1.default.shape({ root: prop_types_1.default.string }),
|
|
116
|
-
inputComponent: prop_types_1.default.elementType
|
|
117
|
-
}),
|
|
118
|
-
inputProps: prop_types_1.default.object,
|
|
119
|
-
onChange: prop_types_1.default.func,
|
|
120
|
-
classes: prop_types_1.default.object,
|
|
121
|
-
getValueLabel: prop_types_1.default.func,
|
|
122
|
-
isCrossedOut: prop_types_1.default.bool
|
|
107
|
+
}, value: inputValue, onChange: (0, ramda_1.pipe)(utils_1.getValue, setInputValue), InputProps: __assign(__assign({}, InputProps), { startAdornment: values.map(function (value, index) { return (react_1.default.createElement(ValueChip_1.default, { key: value, label: getValueLabel(value), onDelete: function () { return removeValueAt(index); } })); }), inputComponent: AutosizeInputWrapper, classes: __assign({ root: (0, classnames_1.default)(styles.inputRoot, root, (_b = {}, _b[styles.isCrossedOut] = isCrossedOut, _b)), input: (0, classnames_1.default)(styles.autosizeInput, InputClasses.input) }, InputClasses) }), inputProps: __assign(__assign({}, inputProps), { CustomInputComponent: InputProps.inputComponent }), onKeyPress: (0, ramda_1.when)((0, ramda_1.propEq)('key', 'Enter'), appendInputValueIfNotEmpty), onKeyDown: (0, ramda_1.when)((0, ramda_1.propEq)('key', 'Backspace'), popLastValueIfInputIsEmpty), onFocus: setFocused, onBlur: (0, ramda_1.pipe)(appendInputValueIfNotEmpty, setUnfocused) }))));
|
|
123
108
|
};
|
|
124
109
|
exports.default = MultipleInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"inputRoot" | "isCrossedOut" | "autosizeInput">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"inputRoot" | "isCrossedOut" | "autosizeInput">;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { InputProps } from '@mui/material/Input';
|
|
3
3
|
export type SearchInputProps = InputProps & {
|
|
4
4
|
value?: string;
|
|
5
|
-
autofocus
|
|
5
|
+
autofocus?: boolean;
|
|
6
6
|
onSearch: (value?: string) => void;
|
|
7
7
|
rootRef?: React.MutableRefObject<HTMLInputElement>;
|
|
8
8
|
height: number;
|
|
@@ -8,7 +8,7 @@ type CommonProps = Omit<TextFieldProps, 'onChange' | 'value'> & {
|
|
|
8
8
|
isCrossedOut?: boolean;
|
|
9
9
|
};
|
|
10
10
|
type MultipleProps = CommonProps & {
|
|
11
|
-
value?: string[];
|
|
11
|
+
value?: string | string[];
|
|
12
12
|
onChange: (values: string[]) => void;
|
|
13
13
|
multiple: true;
|
|
14
14
|
};
|
|
@@ -18,5 +18,5 @@ type SingleProps = CommonProps & {
|
|
|
18
18
|
multiple?: false;
|
|
19
19
|
};
|
|
20
20
|
export type Props = MultipleProps | SingleProps;
|
|
21
|
-
declare const TypeaheadEditor: ({ value, max, getSuggestions, onChange, multiple, fullWidth, InputProps, isCrossedOut, ...inputProps }: Props) => JSX.Element;
|
|
21
|
+
declare const TypeaheadEditor: ({ value: valueProp, max, getSuggestions, onChange, multiple, fullWidth, InputProps, isCrossedOut, ...inputProps }: Props) => JSX.Element;
|
|
22
22
|
export default TypeaheadEditor;
|
|
@@ -119,7 +119,7 @@ var ChangeMethod;
|
|
|
119
119
|
ChangeMethod["Enter"] = "enter";
|
|
120
120
|
})(ChangeMethod || (ChangeMethod = {}));
|
|
121
121
|
var TypeaheadEditor = function (_a) {
|
|
122
|
-
var
|
|
122
|
+
var valueProp = _a.value, _b = _a.max, max = _b === void 0 ? PAGE_SIZE : _b, getSuggestions = _a.getSuggestions, onChange = _a.onChange, multiple = _a.multiple, fullWidth = _a.fullWidth, _c = _a.InputProps, InputProps = _c === void 0 ? {} : _c, _d = _a.isCrossedOut, isCrossedOut = _d === void 0 ? false : _d, inputProps = __rest(_a, ["value", "max", "getSuggestions", "onChange", "multiple", "fullWidth", "InputProps", "isCrossedOut"]);
|
|
123
123
|
var styles = (0, styles_1.useStyles)();
|
|
124
124
|
var inputRef = (0, react_1.useRef)(null);
|
|
125
125
|
var safePromise = (0, hooks_1.useSafePromise)();
|
|
@@ -132,6 +132,7 @@ var TypeaheadEditor = function (_a) {
|
|
|
132
132
|
var pageSizeForRequest = max + 1;
|
|
133
133
|
var displayedSuggestions = (0, react_1.useMemo)(function () { return suggestions.slice(0, pageNumber * max); }, [suggestions, pageNumber, max]);
|
|
134
134
|
var showMoreButton = suggestions.length > displayedSuggestions.length;
|
|
135
|
+
var value = multiple === true && !(0, ramda_1.isNil)(valueProp) ? (0, mdm_sdk_1.wrapInArrayIfNeeded)(valueProp) : valueProp;
|
|
135
136
|
var isFocused = function () { var _a; return ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === document.activeElement; };
|
|
136
137
|
var fetchSuggestions = (0, react_1.useCallback)(function (_a) {
|
|
137
138
|
var value = _a.value;
|
|
@@ -226,8 +227,9 @@ var TypeaheadEditor = function (_a) {
|
|
|
226
227
|
onChange(inputValue);
|
|
227
228
|
}, [inputValue, onChange, multiple]);
|
|
228
229
|
(0, react_1.useEffect)(function () {
|
|
230
|
+
var _a;
|
|
229
231
|
if (multiple !== true)
|
|
230
|
-
setInputValue(value !== null &&
|
|
232
|
+
setInputValue((_a = value) !== null && _a !== void 0 ? _a : '');
|
|
231
233
|
}, [value, multiple]);
|
|
232
234
|
(0, hooks_1.useDidUpdateEffect)(function () {
|
|
233
235
|
setPageNumber(1);
|
package/cjs/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useScrollToAttributeError } from './useScrollToAttributeError/useScrollToAttributeError';
|
|
2
|
+
export { useMatchesColumnsData } from './useMatchesColumnsData/useMatchesColumnsData';
|
|
2
3
|
export { useActions } from './useActions';
|
|
3
4
|
export { useAPI } from './useAPI';
|
|
4
5
|
export { useAsyncMount } from './useAsyncMount';
|
package/cjs/hooks/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useAutoFocus = exports.useExpandInvalidRelations = exports.useLayoutResetter = exports.useIsMountedRef = exports.useSnackbar = exports.useSavedStateForEntityType = exports.useReadableSearchState = exports.useEditableConnection = exports.useCustomScripts = exports.useMarkAsNotMatchRequest = exports.useMergeAllRequest = exports.usePagingSimulator = exports.useMatchesLoader = exports.useConfigPermissions = exports.useWhyDidYouUpdate = exports.useUsers = exports.useSavedState = exports.useSafePromise = exports.useRunOnceAfterValueInitialization = exports.useRelationsLoader = exports.useRelationTypeSelector = exports.usePrevious = exports.useDidUpdateEffect = exports.useCommentsEntitiesMap = exports.useCollaboration = exports.useAsyncMount = exports.useAPI = exports.useActions = exports.useScrollToAttributeError = void 0;
|
|
3
|
+
exports.useAutoFocus = exports.useExpandInvalidRelations = exports.useLayoutResetter = exports.useIsMountedRef = exports.useSnackbar = exports.useSavedStateForEntityType = exports.useReadableSearchState = exports.useEditableConnection = exports.useCustomScripts = exports.useMarkAsNotMatchRequest = exports.useMergeAllRequest = exports.usePagingSimulator = exports.useMatchesLoader = exports.useConfigPermissions = exports.useWhyDidYouUpdate = exports.useUsers = exports.useSavedState = exports.useSafePromise = exports.useRunOnceAfterValueInitialization = exports.useRelationsLoader = exports.useRelationTypeSelector = exports.usePrevious = exports.useDidUpdateEffect = exports.useCommentsEntitiesMap = exports.useCollaboration = exports.useAsyncMount = exports.useAPI = exports.useActions = exports.useMatchesColumnsData = exports.useScrollToAttributeError = void 0;
|
|
4
4
|
var useScrollToAttributeError_1 = require("./useScrollToAttributeError/useScrollToAttributeError");
|
|
5
5
|
Object.defineProperty(exports, "useScrollToAttributeError", { enumerable: true, get: function () { return useScrollToAttributeError_1.useScrollToAttributeError; } });
|
|
6
|
+
var useMatchesColumnsData_1 = require("./useMatchesColumnsData/useMatchesColumnsData");
|
|
7
|
+
Object.defineProperty(exports, "useMatchesColumnsData", { enumerable: true, get: function () { return useMatchesColumnsData_1.useMatchesColumnsData; } });
|
|
6
8
|
var useActions_1 = require("./useActions");
|
|
7
9
|
Object.defineProperty(exports, "useActions", { enumerable: true, get: function () { return useActions_1.useActions; } });
|
|
8
10
|
var useAPI_1 = require("./useAPI");
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ColumnData, GroupedColumnsData } from '../../components';
|
|
2
|
+
export declare const getColumnsData: any;
|
|
3
|
+
export declare const getMatchAttrColumns: (matchAttributes: string[], columnsData: ColumnData[]) => ColumnData[];
|
|
4
|
+
export declare const groupColumnsDataByMatchAttributes: <TColumnData = ColumnData>(matchAttributes: string[], columnsData: TColumnData[]) => GroupedColumnsData<TColumnData>[];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.groupColumnsDataByMatchAttributes = exports.getMatchAttrColumns = exports.getColumnsData = void 0;
|
|
7
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
8
|
+
var ramda_1 = require("ramda");
|
|
9
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
10
|
+
var ramda_2 = require("ramda");
|
|
11
|
+
var getColumnsDataFromEntityAttributes = (0, ramda_1.pipe)((0, ramda_2.map)(function (attr) { return ({
|
|
12
|
+
id: (0, mdm_sdk_1.attributeUriToSearchUri)(attr.uri),
|
|
13
|
+
label: (0, mdm_sdk_1.getLabel)(attr.label),
|
|
14
|
+
dataTypeDefinition: (0, mdm_sdk_1.getAttrDataTypeDefinition)(attr)
|
|
15
|
+
}); }));
|
|
16
|
+
exports.getColumnsData = (0, ramda_1.pipe)(mdm_sdk_1.getEntityAttributesFromMetadata, getColumnsDataFromEntityAttributes);
|
|
17
|
+
var isReferenceAttrColumn = function (column) { return (0, mdm_sdk_1.isReference)(column.dataTypeDefinition); };
|
|
18
|
+
var isMatchAttrColumn = (0, ramda_1.curry)(function (matchAttributes, column) {
|
|
19
|
+
return matchAttributes
|
|
20
|
+
.map(function (attrUri) { return (0, mdm_sdk_1.attributeUriToSearchUri)(attrUri); })
|
|
21
|
+
.some(function (id) { return column.id === id || (isReferenceAttrColumn(column) && isSubAttrIdForColumn(column, id)); });
|
|
22
|
+
});
|
|
23
|
+
var isSubAttrIdForColumn = (0, ramda_1.curry)(function (parentColumn, columnId) {
|
|
24
|
+
return columnId.startsWith("".concat(parentColumn.id, "."));
|
|
25
|
+
});
|
|
26
|
+
var isNestedForOneOfColumns = (0, ramda_1.curry)(function (columns, column) {
|
|
27
|
+
return isNestedAttrColumn(column) && columns.some(function (_a) {
|
|
28
|
+
var id = _a.id;
|
|
29
|
+
return isSubAttrIdForColumn(column, id);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
var isNestedAttrColumn = function (column) { return (0, mdm_sdk_1.isNested)(column.dataTypeDefinition); };
|
|
33
|
+
var isRelatedToColumns = function (columns) { return (0, ramda_1.either)((0, ramda_1.includes)(ramda_1.__, columns), isNestedForOneOfColumns(columns)); };
|
|
34
|
+
var getMatchAttrColumns = function (matchAttributes, columnsData) {
|
|
35
|
+
return (0, ramda_1.pipe)((0, ramda_2.reject)(isNestedAttrColumn), (0, ramda_2.filter)(isMatchAttrColumn(matchAttributes)))(columnsData);
|
|
36
|
+
};
|
|
37
|
+
exports.getMatchAttrColumns = getMatchAttrColumns;
|
|
38
|
+
var groupColumnsDataByMatchAttributes = function (matchAttributes, columnsData) {
|
|
39
|
+
var _a = (0, ramda_1.pipe)((0, ramda_2.reject)(isNestedAttrColumn), (0, ramda_2.partition)(isMatchAttrColumn(matchAttributes)))(columnsData), matchAttrColumns = _a[0], otherColumns = _a[1];
|
|
40
|
+
if (matchAttrColumns.length) {
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
id: 'match',
|
|
44
|
+
label: ui_i18n_1.default.text('Match attributes'),
|
|
45
|
+
columns: columnsData.filter(isRelatedToColumns(matchAttrColumns))
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'all',
|
|
49
|
+
label: ui_i18n_1.default.text('All attributes'),
|
|
50
|
+
columns: columnsData.filter(isRelatedToColumns(otherColumns))
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
return columnsData;
|
|
55
|
+
};
|
|
56
|
+
exports.groupColumnsDataByMatchAttributes = groupColumnsDataByMatchAttributes;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Metadata } from '@reltio/mdm-sdk';
|
|
2
|
+
import { ColumnData, GroupedColumnsData } from '../../components';
|
|
3
|
+
type MatchesColumnsDataProps<TColumnData> = {
|
|
4
|
+
defaultColumnsData: TColumnData[];
|
|
5
|
+
additionalColumnsData?: TColumnData[];
|
|
6
|
+
metadata: Metadata;
|
|
7
|
+
entityTypeUri: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const useMatchesColumnsData: <TColumnData extends ColumnData>({ defaultColumnsData, additionalColumnsData, metadata, entityTypeUri }: MatchesColumnsDataProps<TColumnData>) => {
|
|
10
|
+
allColumnsData: TColumnData[];
|
|
11
|
+
groupedColumnsData: GroupedColumnsData<TColumnData>[];
|
|
12
|
+
defaultColumns: string[];
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMatchesColumnsData = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var ramda_1 = require("ramda");
|
|
6
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
7
|
+
var helpers_1 = require("./helpers");
|
|
8
|
+
var useMatchesColumnsData = function (_a) {
|
|
9
|
+
var defaultColumnsData = _a.defaultColumnsData, additionalColumnsData = _a.additionalColumnsData, metadata = _a.metadata, entityTypeUri = _a.entityTypeUri;
|
|
10
|
+
return (0, react_1.useMemo)(function () {
|
|
11
|
+
var attrColumnsData = (0, helpers_1.getColumnsData)(metadata, entityTypeUri);
|
|
12
|
+
var allColumnsData = defaultColumnsData
|
|
13
|
+
.concat(additionalColumnsData || [])
|
|
14
|
+
.concat(attrColumnsData);
|
|
15
|
+
var matchAttributes = (0, mdm_sdk_1.getEntityTypeMatchAttributes)(metadata, entityTypeUri);
|
|
16
|
+
var groupedColumnsData = (0, helpers_1.groupColumnsDataByMatchAttributes)(matchAttributes, allColumnsData);
|
|
17
|
+
var defaultColumns = (0, ramda_1.pipe)(helpers_1.getMatchAttrColumns, (0, ramda_1.concat)(defaultColumnsData), (0, ramda_1.pluck)('id'))(matchAttributes, attrColumnsData);
|
|
18
|
+
return { allColumnsData: allColumnsData, groupedColumnsData: groupedColumnsData, defaultColumns: defaultColumns };
|
|
19
|
+
}, [defaultColumnsData, additionalColumnsData, metadata, entityTypeUri]);
|
|
20
|
+
};
|
|
21
|
+
exports.useMatchesColumnsData = useMatchesColumnsData;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ColumnData } from '../../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
columnsData: ColumnData[];
|
|
5
|
+
selectedColumns: string[];
|
|
6
|
+
onChangeColumns: (columns: string[]) => void;
|
|
7
|
+
title?: string;
|
|
8
|
+
tooltipTitle?: string;
|
|
9
|
+
};
|
|
10
|
+
declare const ColumnsSettings: ({ columnsData, selectedColumns, onChangeColumns, title, tooltipTitle }: Props) => JSX.Element;
|
|
1
11
|
export default ColumnsSettings;
|
|
2
|
-
declare function ColumnsSettings({ columnsData, selectedColumns, onChangeColumns, title, tooltipTitle }: {
|
|
3
|
-
columnsData: any;
|
|
4
|
-
selectedColumns: any;
|
|
5
|
-
onChangeColumns: any;
|
|
6
|
-
title: any;
|
|
7
|
-
tooltipTitle: any;
|
|
8
|
-
}): JSX.Element;
|
|
9
|
-
declare namespace ColumnsSettings {
|
|
10
|
-
namespace propTypes {
|
|
11
|
-
export { ColumnsDataType as columnsData };
|
|
12
|
-
export const selectedColumns: PropTypes.Requireable<string[]>;
|
|
13
|
-
export const onChangeColumns: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
|
-
export const title: PropTypes.Requireable<string>;
|
|
15
|
-
export const tooltipTitle: PropTypes.Requireable<string>;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
import { ColumnsDataType } from '../../../../constants';
|
|
19
|
-
import PropTypes from 'prop-types';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React, { useCallback, useState } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import i18n from 'ui-i18n';
|
|
3
|
+
import { pipe, uniq, pluck, difference, concat } from 'ramda';
|
|
4
4
|
import TableIcon from '../../../../icons/Table';
|
|
5
5
|
import { SmallIconButtonWithTooltip } from '../../../SmallIconButton';
|
|
6
|
-
import { pipe, uniq, pluck, difference, concat } from 'ramda';
|
|
7
6
|
import { ColumnsSettingsPopup } from './ColumnsSettingsPopup';
|
|
8
|
-
import i18n from 'ui-i18n';
|
|
9
7
|
import { getChildColumns, isColumnSelected } from './columnHelpers';
|
|
10
8
|
var ColumnsSettings = function (_a) {
|
|
11
9
|
var columnsData = _a.columnsData, selectedColumns = _a.selectedColumns, onChangeColumns = _a.onChangeColumns, title = _a.title, tooltipTitle = _a.tooltipTitle;
|
|
@@ -20,14 +18,7 @@ var ColumnsSettings = function (_a) {
|
|
|
20
18
|
: uniq(concat(selectedColumns, changedColumns)));
|
|
21
19
|
}, [selectedColumns, onChangeColumns]);
|
|
22
20
|
return (React.createElement(React.Fragment, null,
|
|
23
|
-
React.createElement(SmallIconButtonWithTooltip, { tooltipTitle: tooltipTitle || i18n.text('Show/hide columns'), size: "L", icon: TableIcon, onClick: openPopup }),
|
|
21
|
+
React.createElement(SmallIconButtonWithTooltip, { "data-reltio-id": "reltio-columns-settings-button", tooltipTitle: tooltipTitle || i18n.text('Show/hide columns'), size: "L", icon: TableIcon, onClick: openPopup }),
|
|
24
22
|
React.createElement(ColumnsSettingsPopup, { onColumnClick: handleColumnClick, anchorEl: anchorEl, columnsData: columnsData, onClose: closePopup, title: title, selectedColumns: selectedColumns })));
|
|
25
23
|
};
|
|
26
|
-
ColumnsSettings.propTypes = {
|
|
27
|
-
columnsData: ColumnsDataType,
|
|
28
|
-
selectedColumns: PropTypes.arrayOf(PropTypes.string),
|
|
29
|
-
onChangeColumns: PropTypes.func,
|
|
30
|
-
title: PropTypes.string,
|
|
31
|
-
tooltipTitle: PropTypes.string
|
|
32
|
-
};
|
|
33
24
|
export default ColumnsSettings;
|
|
@@ -21,7 +21,7 @@ export type ColumnData = {
|
|
|
21
21
|
sortable?: boolean;
|
|
22
22
|
filterable?: boolean;
|
|
23
23
|
resizable?: boolean;
|
|
24
|
-
nestedPath?: string;
|
|
24
|
+
nestedPath?: string[];
|
|
25
25
|
headCellRenderer?: React.ElementType;
|
|
26
26
|
rowCellValueRenderer?: React.ElementType;
|
|
27
27
|
draggable?: boolean;
|
|
@@ -32,6 +32,12 @@ export type ColumnData = {
|
|
|
32
32
|
}>;
|
|
33
33
|
[key: string]: unknown;
|
|
34
34
|
};
|
|
35
|
+
export type GroupedColumns<TColumnData = ColumnData> = {
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
columns: TColumnData[];
|
|
39
|
+
};
|
|
40
|
+
export type GroupedColumnsData<TColumnData = ColumnData> = GroupedColumns<TColumnData> | TColumnData;
|
|
35
41
|
export type CollapseContext = ReturnType<typeof useCollapsibleTableRows>['collapseContextValue'];
|
|
36
42
|
export type RowId = string | number;
|
|
37
43
|
export type RowValue = {
|
|
@@ -29,7 +29,7 @@ var BasicViewHeader = function (_a) {
|
|
|
29
29
|
var _b = _a.title, title = _b === void 0 ? '' : _b, _c = _a.children, children = _c === void 0 ? null : _c, _d = _a.classes, classes = _d === void 0 ? {} : _d, otherProps = __rest(_a, ["title", "children", "classes"]);
|
|
30
30
|
var styles = useStyles();
|
|
31
31
|
return (React.createElement(Toolbar, __assign({ className: classes.root, classes: { root: styles.toolbar } }, otherProps),
|
|
32
|
-
React.createElement(Typography, { className: classes.title, classes: { root: styles.title }, variant: "h6" }, i18n.text(title)),
|
|
32
|
+
title && (React.createElement(Typography, { className: classes.title, classes: { root: styles.title }, variant: "h6" }, i18n.text(title))),
|
|
33
33
|
children));
|
|
34
34
|
};
|
|
35
35
|
export default BasicViewHeader;
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
3
|
+
type MultipleInputProps = Omit<TextFieldProps, 'classes' | 'value' | 'onChange' | 'onKeyPress' | 'onKeyDown' | 'onFocus' | 'onBlur'> & {
|
|
4
|
+
values?: string | string[];
|
|
5
|
+
InputProps?: Omit<TextFieldProps['InputProps'], 'startAdornment' | 'inputComponent'>;
|
|
6
|
+
classes?: {
|
|
7
|
+
root?: string;
|
|
8
|
+
};
|
|
9
|
+
isCrossedOut?: boolean;
|
|
10
|
+
onChange?: (values: string[]) => void;
|
|
11
|
+
getValueLabel?: (value: string) => string;
|
|
12
|
+
};
|
|
13
|
+
declare const MultipleInput: ({ values: valuesProp, InputProps, inputProps, classes, isCrossedOut, onChange, getValueLabel, ...otherProps }: MultipleInputProps) => JSX.Element;
|
|
1
14
|
export default MultipleInput;
|
|
2
|
-
declare function MultipleInput({ values, InputProps, inputProps, classes, isCrossedOut, onChange, getValueLabel, ...otherProps }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
values?: any[];
|
|
5
|
-
InputProps?: {};
|
|
6
|
-
inputProps?: {};
|
|
7
|
-
classes?: {};
|
|
8
|
-
isCrossedOut: any;
|
|
9
|
-
onChange?: () => void;
|
|
10
|
-
getValueLabel?: any;
|
|
11
|
-
}): JSX.Element;
|
|
12
|
-
declare namespace MultipleInput {
|
|
13
|
-
namespace propTypes {
|
|
14
|
-
const values: PropTypes.Requireable<string[]>;
|
|
15
|
-
const InputProps: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
-
classes: PropTypes.Requireable<PropTypes.InferProps<{
|
|
17
|
-
root: PropTypes.Requireable<string>;
|
|
18
|
-
}>>;
|
|
19
|
-
inputComponent: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
20
|
-
}>>;
|
|
21
|
-
const inputProps: PropTypes.Requireable<object>;
|
|
22
|
-
const onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
-
const classes: PropTypes.Requireable<object>;
|
|
24
|
-
const getValueLabel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
-
const isCrossedOut: PropTypes.Requireable<boolean>;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
import PropTypes from 'prop-types';
|
|
@@ -29,38 +29,38 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
29
29
|
}
|
|
30
30
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
31
|
};
|
|
32
|
+
import React, { forwardRef, useState } from 'react';
|
|
33
|
+
import i18n from 'ui-i18n';
|
|
34
|
+
import { identity, pipe, propEq, remove, uniq, when, trim, isEmpty } from 'ramda';
|
|
32
35
|
import AutosizeInput from 'react-input-autosize';
|
|
33
36
|
import classnames from 'classnames';
|
|
37
|
+
import { wrapInArrayIfNeeded } from '@reltio/mdm-sdk';
|
|
34
38
|
import TextField from '@mui/material/TextField';
|
|
35
|
-
import
|
|
36
|
-
import React, { forwardRef, useState } from 'react';
|
|
37
|
-
import { identity, pipe, propEq, remove, uniq, when, trim, isEmpty } from 'ramda';
|
|
39
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
38
40
|
import { getValue, noop } from '../../core/utils';
|
|
39
|
-
import { useStyles } from './styles';
|
|
40
41
|
import ValueChip from '../ValueChip/ValueChip';
|
|
41
|
-
import
|
|
42
|
-
|
|
42
|
+
import { useStyles } from './styles';
|
|
43
|
+
var EMPTY_VALUES_EDIT_HINT = i18n.text('Press Enter to add. You may enter multiple values');
|
|
44
|
+
var isEmptyValue = pipe(trim, isEmpty);
|
|
43
45
|
var AutosizeInputWrapper = forwardRef(function (props, ref) {
|
|
44
46
|
var CustomInputComponent = props.CustomInputComponent, other = __rest(props, ["CustomInputComponent"]);
|
|
45
47
|
return CustomInputComponent ? (React.createElement(CustomInputComponent, __assign({}, other, { ref: ref, customInput: AutosizeInput }))) : (React.createElement(AutosizeInput, __assign({}, other, { ref: ref })));
|
|
46
48
|
});
|
|
47
|
-
AutosizeInputWrapper.propTypes = {
|
|
48
|
-
CustomInputComponent: PropTypes.elementType
|
|
49
|
-
};
|
|
50
49
|
AutosizeInputWrapper.displayName = 'AutosizeInputWrapper';
|
|
51
|
-
var BACKSPACE_KEY_CODE = 8;
|
|
52
|
-
var EMPTY_VALUES_EDIT_HINT = i18n.text('Press Enter to add. You may enter multiple values');
|
|
53
|
-
var isEmptyValue = pipe(trim, isEmpty);
|
|
54
50
|
var MultipleInput = function (_a) {
|
|
55
51
|
var _b;
|
|
56
|
-
var _c = _a.values,
|
|
52
|
+
var _c = _a.values, valuesProp = _c === void 0 ? [] : _c, _d = _a.InputProps, InputProps = _d === void 0 ? {} : _d, _e = _a.inputProps, inputProps = _e === void 0 ? {} : _e, _f = _a.classes, classes = _f === void 0 ? {} : _f, isCrossedOut = _a.isCrossedOut, _g = _a.onChange, onChange = _g === void 0 ? noop : _g, _h = _a.getValueLabel, getValueLabel = _h === void 0 ? identity : _h, otherProps = __rest(_a, ["values", "InputProps", "inputProps", "classes", "isCrossedOut", "onChange", "getValueLabel"]);
|
|
57
53
|
var styles = useStyles();
|
|
58
54
|
var _j = InputProps.classes || {}, root = _j.root, InputClasses = __rest(_j, ["root"]);
|
|
59
55
|
var _k = useState(''), inputValue = _k[0], setInputValue = _k[1];
|
|
56
|
+
var _l = useState(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
57
|
+
var values = wrapInArrayIfNeeded(valuesProp);
|
|
58
|
+
var hasValues = values.length > 0;
|
|
60
59
|
var clearInputValue = function () { return setInputValue(''); };
|
|
60
|
+
var setFocused = function () { return setIsFocused(true); };
|
|
61
|
+
var setUnfocused = function () { return setIsFocused(false); };
|
|
61
62
|
var removeValueAt = function (index) { return onChange(remove(index, 1, values)); };
|
|
62
63
|
var appendValue = function (value) { return onChange(uniq(__spreadArray(__spreadArray([], values, true), [value], false))); };
|
|
63
|
-
var hasValues = values.length > 0;
|
|
64
64
|
var appendInputValueIfNotEmpty = function () {
|
|
65
65
|
if (!isEmptyValue(inputValue)) {
|
|
66
66
|
appendValue(inputValue);
|
|
@@ -72,25 +72,10 @@ var MultipleInput = function (_a) {
|
|
|
72
72
|
removeValueAt(-1);
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
var _l = useState(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
76
|
-
var setFocused = function () { return setIsFocused(true); };
|
|
77
|
-
var setUnfocused = function () { return setIsFocused(false); };
|
|
78
75
|
var hintText = !hasValues && isFocused ? EMPTY_VALUES_EDIT_HINT : '';
|
|
79
76
|
return (React.createElement(Tooltip, { title: hintText },
|
|
80
77
|
React.createElement(TextField, __assign({ variant: "standard" }, otherProps, { classes: {
|
|
81
78
|
root: classes.root
|
|
82
|
-
}, value: inputValue, onChange: pipe(getValue, setInputValue), InputProps: __assign(__assign({}, InputProps), { startAdornment: values.map(function (value, index) { return (React.createElement(ValueChip, { key: value, label: getValueLabel(value), onDelete: function () { return removeValueAt(index); } })); }), inputComponent: AutosizeInputWrapper, classes: __assign({ root: classnames(styles.inputRoot, root, (_b = {}, _b[styles.isCrossedOut] = isCrossedOut, _b)), input: classnames(styles.autosizeInput, InputClasses.input) }, InputClasses) }), inputProps: __assign(__assign({}, inputProps), { CustomInputComponent: InputProps.inputComponent }), onKeyPress: when(propEq('key', 'Enter'), appendInputValueIfNotEmpty), onKeyDown: when(propEq('
|
|
83
|
-
};
|
|
84
|
-
MultipleInput.propTypes = {
|
|
85
|
-
values: PropTypes.arrayOf(PropTypes.string),
|
|
86
|
-
InputProps: PropTypes.shape({
|
|
87
|
-
classes: PropTypes.shape({ root: PropTypes.string }),
|
|
88
|
-
inputComponent: PropTypes.elementType
|
|
89
|
-
}),
|
|
90
|
-
inputProps: PropTypes.object,
|
|
91
|
-
onChange: PropTypes.func,
|
|
92
|
-
classes: PropTypes.object,
|
|
93
|
-
getValueLabel: PropTypes.func,
|
|
94
|
-
isCrossedOut: PropTypes.bool
|
|
79
|
+
}, value: inputValue, onChange: pipe(getValue, setInputValue), InputProps: __assign(__assign({}, InputProps), { startAdornment: values.map(function (value, index) { return (React.createElement(ValueChip, { key: value, label: getValueLabel(value), onDelete: function () { return removeValueAt(index); } })); }), inputComponent: AutosizeInputWrapper, classes: __assign({ root: classnames(styles.inputRoot, root, (_b = {}, _b[styles.isCrossedOut] = isCrossedOut, _b)), input: classnames(styles.autosizeInput, InputClasses.input) }, InputClasses) }), inputProps: __assign(__assign({}, inputProps), { CustomInputComponent: InputProps.inputComponent }), onKeyPress: when(propEq('key', 'Enter'), appendInputValueIfNotEmpty), onKeyDown: when(propEq('key', 'Backspace'), popLastValueIfInputIsEmpty), onFocus: setFocused, onBlur: pipe(appendInputValueIfNotEmpty, setUnfocused) }))));
|
|
95
80
|
};
|
|
96
81
|
export default MultipleInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"inputRoot" | "isCrossedOut" | "autosizeInput">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"inputRoot" | "isCrossedOut" | "autosizeInput">;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { InputProps } from '@mui/material/Input';
|
|
3
3
|
export type SearchInputProps = InputProps & {
|
|
4
4
|
value?: string;
|
|
5
|
-
autofocus
|
|
5
|
+
autofocus?: boolean;
|
|
6
6
|
onSearch: (value?: string) => void;
|
|
7
7
|
rootRef?: React.MutableRefObject<HTMLInputElement>;
|
|
8
8
|
height: number;
|
|
@@ -8,7 +8,7 @@ type CommonProps = Omit<TextFieldProps, 'onChange' | 'value'> & {
|
|
|
8
8
|
isCrossedOut?: boolean;
|
|
9
9
|
};
|
|
10
10
|
type MultipleProps = CommonProps & {
|
|
11
|
-
value?: string[];
|
|
11
|
+
value?: string | string[];
|
|
12
12
|
onChange: (values: string[]) => void;
|
|
13
13
|
multiple: true;
|
|
14
14
|
};
|
|
@@ -18,5 +18,5 @@ type SingleProps = CommonProps & {
|
|
|
18
18
|
multiple?: false;
|
|
19
19
|
};
|
|
20
20
|
export type Props = MultipleProps | SingleProps;
|
|
21
|
-
declare const TypeaheadEditor: ({ value, max, getSuggestions, onChange, multiple, fullWidth, InputProps, isCrossedOut, ...inputProps }: Props) => JSX.Element;
|
|
21
|
+
declare const TypeaheadEditor: ({ value: valueProp, max, getSuggestions, onChange, multiple, fullWidth, InputProps, isCrossedOut, ...inputProps }: Props) => JSX.Element;
|
|
22
22
|
export default TypeaheadEditor;
|
|
@@ -66,9 +66,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
66
66
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
67
|
};
|
|
68
68
|
import React, { useCallback, useRef, useMemo, useState, useEffect } from 'react';
|
|
69
|
-
import { identity, isEmpty, nthArg, path, pipe, prop, remove, T, uniq } from 'ramda';
|
|
69
|
+
import { identity, isEmpty, nthArg, path, pipe, prop, remove, T, uniq, isNil } from 'ramda';
|
|
70
70
|
import classnames from 'classnames';
|
|
71
|
-
import { debounce, isEmptyValue } from '@reltio/mdm-sdk';
|
|
71
|
+
import { debounce, isEmptyValue, wrapInArrayIfNeeded } from '@reltio/mdm-sdk';
|
|
72
72
|
import Autosuggest from 'react-autosuggest';
|
|
73
73
|
import AutosizeInput from 'react-input-autosize';
|
|
74
74
|
import TextField from '@mui/material/TextField';
|
|
@@ -91,7 +91,7 @@ var ChangeMethod;
|
|
|
91
91
|
ChangeMethod["Enter"] = "enter";
|
|
92
92
|
})(ChangeMethod || (ChangeMethod = {}));
|
|
93
93
|
var TypeaheadEditor = function (_a) {
|
|
94
|
-
var
|
|
94
|
+
var valueProp = _a.value, _b = _a.max, max = _b === void 0 ? PAGE_SIZE : _b, getSuggestions = _a.getSuggestions, onChange = _a.onChange, multiple = _a.multiple, fullWidth = _a.fullWidth, _c = _a.InputProps, InputProps = _c === void 0 ? {} : _c, _d = _a.isCrossedOut, isCrossedOut = _d === void 0 ? false : _d, inputProps = __rest(_a, ["value", "max", "getSuggestions", "onChange", "multiple", "fullWidth", "InputProps", "isCrossedOut"]);
|
|
95
95
|
var styles = useStyles();
|
|
96
96
|
var inputRef = useRef(null);
|
|
97
97
|
var safePromise = useSafePromise();
|
|
@@ -104,6 +104,7 @@ var TypeaheadEditor = function (_a) {
|
|
|
104
104
|
var pageSizeForRequest = max + 1;
|
|
105
105
|
var displayedSuggestions = useMemo(function () { return suggestions.slice(0, pageNumber * max); }, [suggestions, pageNumber, max]);
|
|
106
106
|
var showMoreButton = suggestions.length > displayedSuggestions.length;
|
|
107
|
+
var value = multiple === true && !isNil(valueProp) ? wrapInArrayIfNeeded(valueProp) : valueProp;
|
|
107
108
|
var isFocused = function () { var _a; return ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === document.activeElement; };
|
|
108
109
|
var fetchSuggestions = useCallback(function (_a) {
|
|
109
110
|
var value = _a.value;
|
|
@@ -198,8 +199,9 @@ var TypeaheadEditor = function (_a) {
|
|
|
198
199
|
onChange(inputValue);
|
|
199
200
|
}, [inputValue, onChange, multiple]);
|
|
200
201
|
useEffect(function () {
|
|
202
|
+
var _a;
|
|
201
203
|
if (multiple !== true)
|
|
202
|
-
setInputValue(value !== null &&
|
|
204
|
+
setInputValue((_a = value) !== null && _a !== void 0 ? _a : '');
|
|
203
205
|
}, [value, multiple]);
|
|
204
206
|
useDidUpdateEffect(function () {
|
|
205
207
|
setPageNumber(1);
|
package/esm/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useScrollToAttributeError } from './useScrollToAttributeError/useScrollToAttributeError';
|
|
2
|
+
export { useMatchesColumnsData } from './useMatchesColumnsData/useMatchesColumnsData';
|
|
2
3
|
export { useActions } from './useActions';
|
|
3
4
|
export { useAPI } from './useAPI';
|
|
4
5
|
export { useAsyncMount } from './useAsyncMount';
|
package/esm/hooks/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useScrollToAttributeError } from './useScrollToAttributeError/useScrollToAttributeError';
|
|
2
|
+
export { useMatchesColumnsData } from './useMatchesColumnsData/useMatchesColumnsData';
|
|
2
3
|
export { useActions } from './useActions';
|
|
3
4
|
export { useAPI } from './useAPI';
|
|
4
5
|
export { useAsyncMount } from './useAsyncMount';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ColumnData, GroupedColumnsData } from '../../components';
|
|
2
|
+
export declare const getColumnsData: any;
|
|
3
|
+
export declare const getMatchAttrColumns: (matchAttributes: string[], columnsData: ColumnData[]) => ColumnData[];
|
|
4
|
+
export declare const groupColumnsDataByMatchAttributes: <TColumnData = ColumnData>(matchAttributes: string[], columnsData: TColumnData[]) => GroupedColumnsData<TColumnData>[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import i18n from 'ui-i18n';
|
|
2
|
+
import { __, pipe, curry, either, includes } from 'ramda';
|
|
3
|
+
import { attributeUriToSearchUri, getAttrDataTypeDefinition, getEntityAttributesFromMetadata, getLabel, isNested, isReference } from '@reltio/mdm-sdk';
|
|
4
|
+
import { filter, partition, reject, map } from 'ramda';
|
|
5
|
+
var getColumnsDataFromEntityAttributes = pipe(map(function (attr) { return ({
|
|
6
|
+
id: attributeUriToSearchUri(attr.uri),
|
|
7
|
+
label: getLabel(attr.label),
|
|
8
|
+
dataTypeDefinition: getAttrDataTypeDefinition(attr)
|
|
9
|
+
}); }));
|
|
10
|
+
export var getColumnsData = pipe(getEntityAttributesFromMetadata, getColumnsDataFromEntityAttributes);
|
|
11
|
+
var isReferenceAttrColumn = function (column) { return isReference(column.dataTypeDefinition); };
|
|
12
|
+
var isMatchAttrColumn = curry(function (matchAttributes, column) {
|
|
13
|
+
return matchAttributes
|
|
14
|
+
.map(function (attrUri) { return attributeUriToSearchUri(attrUri); })
|
|
15
|
+
.some(function (id) { return column.id === id || (isReferenceAttrColumn(column) && isSubAttrIdForColumn(column, id)); });
|
|
16
|
+
});
|
|
17
|
+
var isSubAttrIdForColumn = curry(function (parentColumn, columnId) {
|
|
18
|
+
return columnId.startsWith("".concat(parentColumn.id, "."));
|
|
19
|
+
});
|
|
20
|
+
var isNestedForOneOfColumns = curry(function (columns, column) {
|
|
21
|
+
return isNestedAttrColumn(column) && columns.some(function (_a) {
|
|
22
|
+
var id = _a.id;
|
|
23
|
+
return isSubAttrIdForColumn(column, id);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
var isNestedAttrColumn = function (column) { return isNested(column.dataTypeDefinition); };
|
|
27
|
+
var isRelatedToColumns = function (columns) { return either(includes(__, columns), isNestedForOneOfColumns(columns)); };
|
|
28
|
+
export var getMatchAttrColumns = function (matchAttributes, columnsData) {
|
|
29
|
+
return pipe(reject(isNestedAttrColumn), filter(isMatchAttrColumn(matchAttributes)))(columnsData);
|
|
30
|
+
};
|
|
31
|
+
export var groupColumnsDataByMatchAttributes = function (matchAttributes, columnsData) {
|
|
32
|
+
var _a = pipe(reject(isNestedAttrColumn), partition(isMatchAttrColumn(matchAttributes)))(columnsData), matchAttrColumns = _a[0], otherColumns = _a[1];
|
|
33
|
+
if (matchAttrColumns.length) {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
id: 'match',
|
|
37
|
+
label: i18n.text('Match attributes'),
|
|
38
|
+
columns: columnsData.filter(isRelatedToColumns(matchAttrColumns))
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'all',
|
|
42
|
+
label: i18n.text('All attributes'),
|
|
43
|
+
columns: columnsData.filter(isRelatedToColumns(otherColumns))
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
return columnsData;
|
|
48
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Metadata } from '@reltio/mdm-sdk';
|
|
2
|
+
import { ColumnData, GroupedColumnsData } from '../../components';
|
|
3
|
+
type MatchesColumnsDataProps<TColumnData> = {
|
|
4
|
+
defaultColumnsData: TColumnData[];
|
|
5
|
+
additionalColumnsData?: TColumnData[];
|
|
6
|
+
metadata: Metadata;
|
|
7
|
+
entityTypeUri: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const useMatchesColumnsData: <TColumnData extends ColumnData>({ defaultColumnsData, additionalColumnsData, metadata, entityTypeUri }: MatchesColumnsDataProps<TColumnData>) => {
|
|
10
|
+
allColumnsData: TColumnData[];
|
|
11
|
+
groupedColumnsData: GroupedColumnsData<TColumnData>[];
|
|
12
|
+
defaultColumns: string[];
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { concat, pipe, pluck } from 'ramda';
|
|
3
|
+
import { getEntityTypeMatchAttributes } from '@reltio/mdm-sdk';
|
|
4
|
+
import { getColumnsData, getMatchAttrColumns, groupColumnsDataByMatchAttributes } from './helpers';
|
|
5
|
+
export var useMatchesColumnsData = function (_a) {
|
|
6
|
+
var defaultColumnsData = _a.defaultColumnsData, additionalColumnsData = _a.additionalColumnsData, metadata = _a.metadata, entityTypeUri = _a.entityTypeUri;
|
|
7
|
+
return useMemo(function () {
|
|
8
|
+
var attrColumnsData = getColumnsData(metadata, entityTypeUri);
|
|
9
|
+
var allColumnsData = defaultColumnsData
|
|
10
|
+
.concat(additionalColumnsData || [])
|
|
11
|
+
.concat(attrColumnsData);
|
|
12
|
+
var matchAttributes = getEntityTypeMatchAttributes(metadata, entityTypeUri);
|
|
13
|
+
var groupedColumnsData = groupColumnsDataByMatchAttributes(matchAttributes, allColumnsData);
|
|
14
|
+
var defaultColumns = pipe(getMatchAttrColumns, concat(defaultColumnsData), pluck('id'))(matchAttributes, attrColumnsData);
|
|
15
|
+
return { allColumnsData: allColumnsData, groupedColumnsData: groupedColumnsData, defaultColumns: defaultColumns };
|
|
16
|
+
}, [defaultColumnsData, additionalColumnsData, metadata, entityTypeUri]);
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1739",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
9
9
|
"@react-google-maps/api": "2.7.0",
|
|
10
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-sdk": "^1.4.1722",
|
|
11
11
|
"classnames": "^2.2.5",
|
|
12
12
|
"d3-cloud": "^1.2.5",
|
|
13
13
|
"d3-geo": "^2.0.1",
|