@reltio/components 1.4.886 → 1.4.887

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.
@@ -11,10 +11,11 @@ export namespace DropDownSelectorType {
11
11
  const textFieldInputRef: PropTypes.Requireable<object>;
12
12
  const TextFieldProps: PropTypes.Requireable<object>;
13
13
  const height: PropTypes.Requireable<number>;
14
+ const classes: PropTypes.Requireable<object>;
14
15
  }
15
16
  export default DropDownSelector;
16
17
  import PropTypes from "prop-types";
17
- declare function DropDownSelector({ value, label, createLabel, getOptions, options, height, onChange, onCreate, onClear, components, textFieldInputRef, TextFieldProps, ...otherProps }: {
18
+ declare function DropDownSelector({ value, label, createLabel, getOptions, options, height, onChange, onCreate, onClear, components, textFieldInputRef, TextFieldProps, classes, ...otherProps }: {
18
19
  [x: string]: any;
19
20
  value: any;
20
21
  label: any;
@@ -28,6 +29,7 @@ declare function DropDownSelector({ value, label, createLabel, getOptions, optio
28
29
  components: any;
29
30
  textFieldInputRef: any;
30
31
  TextFieldProps: any;
32
+ classes: any;
31
33
  }): JSX.Element;
32
34
  declare namespace DropDownSelector {
33
35
  export { DropDownSelectorType as propTypes };
@@ -60,7 +60,7 @@ var SingleValue_1 = __importDefault(require("./components/SingleValue"));
60
60
  var styles_1 = require("./styles");
61
61
  var DropDownSelector = function (_a) {
62
62
  var _b;
63
- var value = _a.value, label = _a.label, createLabel = _a.createLabel, getOptions = _a.getOptions, options = _a.options, _c = _a.height, height = _c === void 0 ? 46 : _c, _d = _a.onChange, onChange = _d === void 0 ? ramda_1.identity : _d, onCreate = _a.onCreate, _e = _a.onClear, onClear = _e === void 0 ? ramda_1.identity : _e, components = _a.components, textFieldInputRef = _a.textFieldInputRef, TextFieldProps = _a.TextFieldProps, otherProps = __rest(_a, ["value", "label", "createLabel", "getOptions", "options", "height", "onChange", "onCreate", "onClear", "components", "textFieldInputRef", "TextFieldProps"]);
63
+ var value = _a.value, label = _a.label, createLabel = _a.createLabel, getOptions = _a.getOptions, options = _a.options, _c = _a.height, height = _c === void 0 ? 46 : _c, _d = _a.onChange, onChange = _d === void 0 ? ramda_1.identity : _d, onCreate = _a.onCreate, _e = _a.onClear, onClear = _e === void 0 ? ramda_1.identity : _e, components = _a.components, textFieldInputRef = _a.textFieldInputRef, TextFieldProps = _a.TextFieldProps, classes = _a.classes, otherProps = __rest(_a, ["value", "label", "createLabel", "getOptions", "options", "height", "onChange", "onCreate", "onClear", "components", "textFieldInputRef", "TextFieldProps", "classes"]);
64
64
  var styles = styles_1.useStyles({ height: height });
65
65
  var underlineStyle = constants_1.useInputStyles();
66
66
  var _f = react_1.useState(false), open = _f[0], setOpen = _f[1];
@@ -78,7 +78,8 @@ var DropDownSelector = function (_a) {
78
78
  var overloadStylesIfGroup = ramda_1.prop('Group', components) ? styles_1.overloadMenuListStyle : {};
79
79
  var overloadStylesIfNoLabel = ramda_1.isEmpty(label) ? styles_1.withoutLabelInputStyle : {};
80
80
  var mergedStyles = __assign(__assign(__assign({}, styles_1.customStyles), overloadStylesIfGroup), overloadStylesIfNoLabel);
81
- return (react_1.default.createElement(SelectComponent, __assign({ placeholder: "", defaultOptions: true }, otherProps, { value: ramda_1.defaultTo(null, value), loadOptions: getOptions, options: options, cacheOptions: true, onChange: onChange, onCreate: handleCreate, onClear: onClear, createLabel: createLabel, classes: styles, styles: mergedStyles, components: __assign(__assign({ DropdownIndicator: DropdownIndicator_1.default, LoadingIndicator: core_1.EmptyStub, SingleValue: SingleValue_1.default,
81
+ var mergedClasses = __assign(__assign({}, styles), classes);
82
+ return (react_1.default.createElement(SelectComponent, __assign({ placeholder: "", defaultOptions: true }, otherProps, { value: ramda_1.defaultTo(null, value), loadOptions: getOptions, options: options, cacheOptions: true, onChange: onChange, onCreate: handleCreate, onClear: onClear, createLabel: createLabel, classes: mergedClasses, styles: mergedStyles, components: __assign(__assign({ DropdownIndicator: DropdownIndicator_1.default, LoadingIndicator: core_1.EmptyStub, SingleValue: SingleValue_1.default,
82
83
  Menu: Menu_1.default }, showIndicatorSeparator), components), menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { label: label, variant: 'filled', margin: 'dense', classes: __assign(__assign({}, ramda_1.prop('classes', TextFieldProps)), { root: classnames_1.default(styles.formControl, ramda_1.path(['classes', 'root'], TextFieldProps)) }), inputProps: __assign({}, ramda_1.prop('inputProps', TextFieldProps)), InputProps: __assign(__assign({}, ramda_1.prop('InputProps', TextFieldProps)), { classes: __assign(__assign({}, ramda_1.path(['InputProps', 'classes'], TextFieldProps)), { root: classnames_1.default(styles.filledInputRoot, ramda_1.path(['InputProps', 'classes', 'root'], TextFieldProps)), underline: classnames_1.default((_b = {}, _b[underlineStyle.filledInputUnderline] = mdm_sdk_1.isEmptyValue(value), _b), ramda_1.path(['InputProps', 'classes', 'underline'], TextFieldProps)), focused: classnames_1.default('focused', ramda_1.path(['InputProps', 'classes', 'focused'], TextFieldProps)) }) }), InputLabelProps: __assign(__assign({}, ramda_1.prop('InputLabelProps', TextFieldProps)), { classes: __assign(__assign({}, ramda_1.path(['InputLabelProps', 'classes'], TextFieldProps)), { root: classnames_1.default(styles.inputLabel, ramda_1.path(['InputLabelProps', 'classes', 'root'], TextFieldProps)), shrink: classnames_1.default('shrink', ramda_1.path(['InputLabelProps', 'classes', 'shrink'], TextFieldProps)) }), shrink: !mdm_sdk_1.isEmptyValue(value) ? true : undefined }), ref: textFieldInputRef || inputRef }), inputRef: textFieldInputRef || inputRef, menuIsOpen: open, onMenuOpen: function () { return setOpen(true); }, onMenuClose: function () { return setOpen(false); } })));
83
84
  };
84
85
  exports.DropDownSelectorType = {
@@ -93,7 +94,8 @@ exports.DropDownSelectorType = {
93
94
  components: prop_types_1.default.object,
94
95
  textFieldInputRef: prop_types_1.default.object,
95
96
  TextFieldProps: prop_types_1.default.object,
96
- height: prop_types_1.default.number
97
+ height: prop_types_1.default.number,
98
+ classes: prop_types_1.default.object
97
99
  };
98
100
  DropDownSelector.propTypes = exports.DropDownSelectorType;
99
101
  exports.default = DropDownSelector;
@@ -51,8 +51,8 @@ var Title_1 = __importDefault(require("../../../Title/Title"));
51
51
  var CardinalityMessage_1 = __importDefault(require("./CardinalityMessage"));
52
52
  var ErrorMessage_1 = __importDefault(require("../../../ErrorWrapper/ErrorMessage"));
53
53
  var Attribute_1 = __importDefault(require("../AttributesFactory/Attribute"));
54
+ var Roles_1 = require("../Roles/Roles");
54
55
  var Tags_1 = __importDefault(require("../Tags"));
55
- var Roles_1 = __importDefault(require("../../readMode/SpecialAttributes/Roles")); //TODO: should be edit mode
56
56
  var styles_1 = require("./styles");
57
57
  var SpecialRenderer = function (_a) {
58
58
  var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage"]);
@@ -68,7 +68,7 @@ var SpecialRenderer = function (_a) {
68
68
  case mdm_sdk_1.EntityAttrTypes.tags.uri:
69
69
  return react_1.default.createElement(Tags_1.default, { values: values });
70
70
  case mdm_sdk_1.EntityAttrTypes.roles.uri: {
71
- return react_1.default.createElement(Roles_1.default, { values: values });
71
+ return react_1.default.createElement(Roles_1.Roles, { values: values });
72
72
  }
73
73
  default: {
74
74
  //startDate, endDate
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ values: string[];
4
+ };
5
+ export declare const Roles: ({ values }: Props) => JSX.Element;
6
+ export {};
@@ -0,0 +1,64 @@
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.Roles = void 0;
26
+ var react_1 = __importDefault(require("react"));
27
+ var ramda_1 = require("ramda");
28
+ var react_redux_1 = require("react-redux");
29
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
30
+ var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
31
+ var SimpleDropDownSelector_1 = __importDefault(require("../../../SimpleDropDownSelector/SimpleDropDownSelector"));
32
+ var __1 = require("../../..");
33
+ var styles_1 = require("./styles");
34
+ var components = { MultiValue: __1.MultiValueChip };
35
+ var Roles = function (_a) {
36
+ var values = _a.values;
37
+ var styles = styles_1.useStyles();
38
+ var dispatch = react_redux_1.useDispatch();
39
+ var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata);
40
+ var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity);
41
+ var entityUri = entity.uri;
42
+ var options = mdm_sdk_1.getRolesForEntityType(metadata, entity.type).map(function (role) { return ({
43
+ value: role.uri,
44
+ label: role.label
45
+ }); });
46
+ var formattedValues = values.map(function (value) {
47
+ var _a;
48
+ var label = (_a = options.find(ramda_1.propEq('value', value))) === null || _a === void 0 ? void 0 : _a.label;
49
+ return {
50
+ value: value,
51
+ label: label || mdm_sdk_1.getLastUriPart(value)
52
+ };
53
+ });
54
+ var handleChange = function (values) {
55
+ var roles = (values === null || values === void 0 ? void 0 : values.map(ramda_1.prop('value'))) || [];
56
+ dispatch(mdm_module_1.profile.actions.modifyAttribute({
57
+ value: roles,
58
+ attributeType: mdm_sdk_1.EntityAttrTypes.roles,
59
+ uri: entityUri
60
+ }));
61
+ };
62
+ return (react_1.default.createElement(SimpleDropDownSelector_1.default, { label: '', height: 40, isMulti: true, options: options, value: formattedValues, onChange: handleChange, components: components, classes: styles }));
63
+ };
64
+ exports.Roles = Roles;
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"valueContainer">;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useStyles = void 0;
4
+ var styles_1 = require("@material-ui/core/styles");
5
+ exports.useStyles = styles_1.makeStyles({
6
+ valueContainer: {
7
+ marginLeft: '8px',
8
+ width: 0
9
+ }
10
+ });
@@ -11,10 +11,11 @@ export namespace DropDownSelectorType {
11
11
  const textFieldInputRef: PropTypes.Requireable<object>;
12
12
  const TextFieldProps: PropTypes.Requireable<object>;
13
13
  const height: PropTypes.Requireable<number>;
14
+ const classes: PropTypes.Requireable<object>;
14
15
  }
15
16
  export default DropDownSelector;
16
17
  import PropTypes from "prop-types";
17
- declare function DropDownSelector({ value, label, createLabel, getOptions, options, height, onChange, onCreate, onClear, components, textFieldInputRef, TextFieldProps, ...otherProps }: {
18
+ declare function DropDownSelector({ value, label, createLabel, getOptions, options, height, onChange, onCreate, onClear, components, textFieldInputRef, TextFieldProps, classes, ...otherProps }: {
18
19
  [x: string]: any;
19
20
  value: any;
20
21
  label: any;
@@ -28,6 +29,7 @@ declare function DropDownSelector({ value, label, createLabel, getOptions, optio
28
29
  components: any;
29
30
  textFieldInputRef: any;
30
31
  TextFieldProps: any;
32
+ classes: any;
31
33
  }): JSX.Element;
32
34
  declare namespace DropDownSelector {
33
35
  export { DropDownSelectorType as propTypes };
@@ -35,7 +35,7 @@ import SingleValue from './components/SingleValue';
35
35
  import { useStyles, customStyles, overloadMenuListStyle, withoutLabelInputStyle } from './styles';
36
36
  var DropDownSelector = function (_a) {
37
37
  var _b;
38
- var value = _a.value, label = _a.label, createLabel = _a.createLabel, getOptions = _a.getOptions, options = _a.options, _c = _a.height, height = _c === void 0 ? 46 : _c, _d = _a.onChange, onChange = _d === void 0 ? identity : _d, onCreate = _a.onCreate, _e = _a.onClear, onClear = _e === void 0 ? identity : _e, components = _a.components, textFieldInputRef = _a.textFieldInputRef, TextFieldProps = _a.TextFieldProps, otherProps = __rest(_a, ["value", "label", "createLabel", "getOptions", "options", "height", "onChange", "onCreate", "onClear", "components", "textFieldInputRef", "TextFieldProps"]);
38
+ var value = _a.value, label = _a.label, createLabel = _a.createLabel, getOptions = _a.getOptions, options = _a.options, _c = _a.height, height = _c === void 0 ? 46 : _c, _d = _a.onChange, onChange = _d === void 0 ? identity : _d, onCreate = _a.onCreate, _e = _a.onClear, onClear = _e === void 0 ? identity : _e, components = _a.components, textFieldInputRef = _a.textFieldInputRef, TextFieldProps = _a.TextFieldProps, classes = _a.classes, otherProps = __rest(_a, ["value", "label", "createLabel", "getOptions", "options", "height", "onChange", "onCreate", "onClear", "components", "textFieldInputRef", "TextFieldProps", "classes"]);
39
39
  var styles = useStyles({ height: height });
40
40
  var underlineStyle = useInputStyles();
41
41
  var _f = useState(false), open = _f[0], setOpen = _f[1];
@@ -53,7 +53,8 @@ var DropDownSelector = function (_a) {
53
53
  var overloadStylesIfGroup = prop('Group', components) ? overloadMenuListStyle : {};
54
54
  var overloadStylesIfNoLabel = isEmpty(label) ? withoutLabelInputStyle : {};
55
55
  var mergedStyles = __assign(__assign(__assign({}, customStyles), overloadStylesIfGroup), overloadStylesIfNoLabel);
56
- return (React.createElement(SelectComponent, __assign({ placeholder: "", defaultOptions: true }, otherProps, { value: defaultTo(null, value), loadOptions: getOptions, options: options, cacheOptions: true, onChange: onChange, onCreate: handleCreate, onClear: onClear, createLabel: createLabel, classes: styles, styles: mergedStyles, components: __assign(__assign({ DropdownIndicator: DropdownIndicator, LoadingIndicator: EmptyStub, SingleValue: SingleValue,
56
+ var mergedClasses = __assign(__assign({}, styles), classes);
57
+ return (React.createElement(SelectComponent, __assign({ placeholder: "", defaultOptions: true }, otherProps, { value: defaultTo(null, value), loadOptions: getOptions, options: options, cacheOptions: true, onChange: onChange, onCreate: handleCreate, onClear: onClear, createLabel: createLabel, classes: mergedClasses, styles: mergedStyles, components: __assign(__assign({ DropdownIndicator: DropdownIndicator, LoadingIndicator: EmptyStub, SingleValue: SingleValue,
57
58
  Menu: Menu }, showIndicatorSeparator), components), menuPlacement: "auto", TextFieldProps: __assign(__assign({}, TextFieldProps), { label: label, variant: 'filled', margin: 'dense', classes: __assign(__assign({}, prop('classes', TextFieldProps)), { root: classnames(styles.formControl, path(['classes', 'root'], TextFieldProps)) }), inputProps: __assign({}, prop('inputProps', TextFieldProps)), InputProps: __assign(__assign({}, prop('InputProps', TextFieldProps)), { classes: __assign(__assign({}, path(['InputProps', 'classes'], TextFieldProps)), { root: classnames(styles.filledInputRoot, path(['InputProps', 'classes', 'root'], TextFieldProps)), underline: classnames((_b = {}, _b[underlineStyle.filledInputUnderline] = isEmptyValue(value), _b), path(['InputProps', 'classes', 'underline'], TextFieldProps)), focused: classnames('focused', path(['InputProps', 'classes', 'focused'], TextFieldProps)) }) }), InputLabelProps: __assign(__assign({}, prop('InputLabelProps', TextFieldProps)), { classes: __assign(__assign({}, path(['InputLabelProps', 'classes'], TextFieldProps)), { root: classnames(styles.inputLabel, path(['InputLabelProps', 'classes', 'root'], TextFieldProps)), shrink: classnames('shrink', path(['InputLabelProps', 'classes', 'shrink'], TextFieldProps)) }), shrink: !isEmptyValue(value) ? true : undefined }), ref: textFieldInputRef || inputRef }), inputRef: textFieldInputRef || inputRef, menuIsOpen: open, onMenuOpen: function () { return setOpen(true); }, onMenuClose: function () { return setOpen(false); } })));
58
59
  };
59
60
  export var DropDownSelectorType = {
@@ -68,7 +69,8 @@ export var DropDownSelectorType = {
68
69
  components: PropTypes.object,
69
70
  textFieldInputRef: PropTypes.object,
70
71
  TextFieldProps: PropTypes.object,
71
- height: PropTypes.number
72
+ height: PropTypes.number,
73
+ classes: PropTypes.object
72
74
  };
73
75
  DropDownSelector.propTypes = DropDownSelectorType;
74
76
  export default DropDownSelector;
@@ -27,8 +27,8 @@ import Title from '../../../Title/Title';
27
27
  import Cardinality from './CardinalityMessage';
28
28
  import ErrorMessage from '../../../ErrorWrapper/ErrorMessage';
29
29
  import Attribute from '../AttributesFactory/Attribute';
30
+ import { Roles } from '../Roles/Roles';
30
31
  import Tags from '../Tags';
31
- import Roles from '../../readMode/SpecialAttributes/Roles'; //TODO: should be edit mode
32
32
  import { useStyles } from './styles';
33
33
  var SpecialRenderer = function (_a) {
34
34
  var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage"]);
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ values: string[];
4
+ };
5
+ export declare const Roles: ({ values }: Props) => JSX.Element;
6
+ export {};
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { prop, propEq } from 'ramda';
3
+ import { useSelector, useDispatch } from 'react-redux';
4
+ import { EntityAttrTypes, getRolesForEntityType, getLastUriPart } from '@reltio/mdm-sdk';
5
+ import mdmModule, { profile } from '@reltio/mdm-module';
6
+ import SimpleDropDownSelector from '../../../SimpleDropDownSelector/SimpleDropDownSelector';
7
+ import { MultiValueChip } from '../../..';
8
+ import { useStyles } from './styles';
9
+ var components = { MultiValue: MultiValueChip };
10
+ export var Roles = function (_a) {
11
+ var values = _a.values;
12
+ var styles = useStyles();
13
+ var dispatch = useDispatch();
14
+ var metadata = useSelector(mdmModule.selectors.getMetadata);
15
+ var entity = useSelector(mdmModule.selectors.getEntity);
16
+ var entityUri = entity.uri;
17
+ var options = getRolesForEntityType(metadata, entity.type).map(function (role) { return ({
18
+ value: role.uri,
19
+ label: role.label
20
+ }); });
21
+ var formattedValues = values.map(function (value) {
22
+ var _a;
23
+ var label = (_a = options.find(propEq('value', value))) === null || _a === void 0 ? void 0 : _a.label;
24
+ return {
25
+ value: value,
26
+ label: label || getLastUriPart(value)
27
+ };
28
+ });
29
+ var handleChange = function (values) {
30
+ var roles = (values === null || values === void 0 ? void 0 : values.map(prop('value'))) || [];
31
+ dispatch(profile.actions.modifyAttribute({
32
+ value: roles,
33
+ attributeType: EntityAttrTypes.roles,
34
+ uri: entityUri
35
+ }));
36
+ };
37
+ return (React.createElement(SimpleDropDownSelector, { label: '', height: 40, isMulti: true, options: options, value: formattedValues, onChange: handleChange, components: components, classes: styles }));
38
+ };
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"valueContainer">;
@@ -0,0 +1,7 @@
1
+ import { makeStyles } from '@material-ui/core/styles';
2
+ export var useStyles = makeStyles({
3
+ valueContainer: {
4
+ marginLeft: '8px',
5
+ width: 0
6
+ }
7
+ });
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.886",
3
+ "version": "1.4.887",
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
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "^2.7.0",
10
- "@reltio/mdm-module": "^1.4.886",
11
- "@reltio/mdm-sdk": "^1.4.886",
10
+ "@reltio/mdm-module": "^1.4.887",
11
+ "@reltio/mdm-sdk": "^1.4.887",
12
12
  "classnames": "^2.2.5",
13
13
  "frontend-collective-react-dnd-scrollzone": "^1.0.2",
14
14
  "nanoid": "^2.0.0",