@reltio/components 1.4.1348 → 1.4.1349
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/DateRangePicker/DateRangePicker.d.ts +9 -2
- package/cjs/components/DateRangePicker/DateRangePicker.js +0 -7
- package/cjs/components/DateRangePicker/styles.d.ts +1 -1
- package/cjs/components/editors/CustomDateRangeEditor/CustomDateRangeEditor.js +1 -7
- package/cjs/components/editors/DateRangeEditor/DateRangeEditor.d.ts +21 -28
- package/cjs/components/editors/DateRangeEditor/DateRangeEditor.js +13 -41
- package/cjs/components/editors/DateRangeEditor/helpers.d.ts +9 -0
- package/cjs/components/editors/DateRangeEditor/helpers.js +24 -0
- package/cjs/components/editors/TimestampEditor/TimestampEditor.d.ts +2 -2
- package/esm/components/DateRangePicker/DateRangePicker.d.ts +9 -2
- package/esm/components/DateRangePicker/DateRangePicker.js +0 -7
- package/esm/components/DateRangePicker/styles.d.ts +1 -1
- package/esm/components/editors/CustomDateRangeEditor/CustomDateRangeEditor.js +1 -7
- package/esm/components/editors/DateRangeEditor/DateRangeEditor.d.ts +21 -28
- package/esm/components/editors/DateRangeEditor/DateRangeEditor.js +15 -43
- package/esm/components/editors/DateRangeEditor/helpers.d.ts +9 -0
- package/esm/components/editors/DateRangeEditor/helpers.js +20 -0
- package/esm/components/editors/TimestampEditor/TimestampEditor.d.ts +2 -2
- package/package.json +3 -3
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type Values = [Date, Date];
|
|
3
|
+
declare type Props = {
|
|
4
|
+
onCancel: () => void;
|
|
5
|
+
onApply: ([startDate, endDate]: Values) => void;
|
|
6
|
+
values?: Values;
|
|
7
|
+
type?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const DateRangePicker: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
1
10
|
export default DateRangePicker;
|
|
2
|
-
declare const DateRangePicker: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
3
|
-
import React from "react";
|
|
@@ -27,7 +27,6 @@ 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 prop_types_1 = __importDefault(require("prop-types"));
|
|
31
30
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
32
31
|
var nanoid_1 = __importDefault(require("nanoid"));
|
|
33
32
|
var ramda_1 = require("ramda");
|
|
@@ -81,11 +80,5 @@ var DateRangePicker = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
81
80
|
react_1.default.createElement("div", { className: styles.actionButtons },
|
|
82
81
|
react_1.default.createElement(Button_1.default, { color: "primary", onClick: onUpdate, className: styles.button }, ui_i18n_1.default.text('Update')))));
|
|
83
82
|
});
|
|
84
|
-
DateRangePicker.propTypes = {
|
|
85
|
-
onCancel: prop_types_1.default.func.isRequired,
|
|
86
|
-
onApply: prop_types_1.default.func.isRequired,
|
|
87
|
-
values: prop_types_1.default.arrayOf(prop_types_1.default.instanceOf(Date)),
|
|
88
|
-
type: prop_types_1.default.string
|
|
89
|
-
};
|
|
90
83
|
DateRangePicker.displayName = 'DateRangePicker';
|
|
91
84
|
exports.default = DateRangePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"button" | "title" | "header" | "container" | "dateRangeContainer" | "dateInput" | "actionButtons">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"button" | "title" | "header" | "container" | "dateRangeContainer" | "dateInput" | "actionButtons">;
|
|
@@ -81,12 +81,6 @@ var CustomDateRangeEditor = function (_a) {
|
|
|
81
81
|
autoFocusItem: open,
|
|
82
82
|
style: { width: '100%' }
|
|
83
83
|
} },
|
|
84
|
-
react_1.default.createElement(DateRangePicker_1.default
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
, {
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
values: values, onCancel: onCancel, onApply: onApply, type: mdm_sdk_1.DataTypes.TYPE_ACTIVENESS_DATE }))));
|
|
84
|
+
react_1.default.createElement(DateRangePicker_1.default, { values: values, onCancel: onCancel, onApply: onApply, type: mdm_sdk_1.DataTypes.TYPE_ACTIVENESS_DATE }))));
|
|
91
85
|
};
|
|
92
86
|
exports.default = CustomDateRangeEditor;
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DataTypeDefinition } from '@reltio/mdm-sdk';
|
|
3
|
+
import { TextFieldProps } from '@material-ui/core/TextField';
|
|
4
|
+
import { MenuProps } from '@material-ui/core/Menu';
|
|
5
|
+
import { Option, Values } from './helpers';
|
|
6
|
+
export declare type DateRangeEditorProps = {
|
|
7
|
+
label?: string;
|
|
8
|
+
values?: Values;
|
|
9
|
+
options?: Option[];
|
|
10
|
+
getValuesDateRange?: (value: Values) => [Date, Date];
|
|
11
|
+
onChange?: (value: Values) => void;
|
|
12
|
+
dataTypeDefinition?: DataTypeDefinition;
|
|
13
|
+
MenuProps?: Partial<MenuProps>;
|
|
14
|
+
TextFieldProps?: TextFieldProps;
|
|
15
|
+
className?: string;
|
|
16
|
+
classes?: {
|
|
17
|
+
dropdownIndicator?: string;
|
|
18
|
+
root?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
declare const DateRangeEditor: ({ label, values, options, getValuesDateRange, onChange, dataTypeDefinition, TextFieldProps, MenuProps, ...otherProps }: DateRangeEditorProps) => JSX.Element;
|
|
1
22
|
export default DateRangeEditor;
|
|
2
|
-
declare function DateRangeEditor({ label, values, options, getValuesDateRange, onChange, dataTypeDefinition, TextFieldProps, MenuProps, ...otherProps }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
label: any;
|
|
5
|
-
values: any;
|
|
6
|
-
options: any;
|
|
7
|
-
getValuesDateRange?: any;
|
|
8
|
-
onChange?: any;
|
|
9
|
-
dataTypeDefinition?: {};
|
|
10
|
-
TextFieldProps?: {};
|
|
11
|
-
MenuProps?: {};
|
|
12
|
-
}): JSX.Element;
|
|
13
|
-
declare namespace DateRangeEditor {
|
|
14
|
-
namespace propTypes {
|
|
15
|
-
const label: PropTypes.Requireable<string>;
|
|
16
|
-
const values: PropTypes.Requireable<NonNullable<string | any[]>>;
|
|
17
|
-
const options: PropTypes.Requireable<PropTypes.InferProps<{
|
|
18
|
-
value: PropTypes.Requireable<string>;
|
|
19
|
-
label: PropTypes.Requireable<string>;
|
|
20
|
-
}>[]>;
|
|
21
|
-
const getValuesDateRange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
-
const onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
-
const dataTypeDefinition: PropTypes.Requireable<object>;
|
|
24
|
-
const TextFieldProps: PropTypes.Requireable<object>;
|
|
25
|
-
const MenuProps: PropTypes.Requireable<object>;
|
|
26
|
-
const classes: PropTypes.Requireable<object>;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
import PropTypes from "prop-types";
|
|
@@ -49,7 +49,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
49
49
|
};
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
51
|
var react_1 = __importStar(require("react"));
|
|
52
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
53
52
|
var classnames_1 = __importDefault(require("classnames"));
|
|
54
53
|
var moment_1 = __importDefault(require("moment"));
|
|
55
54
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
@@ -58,31 +57,18 @@ var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
|
58
57
|
var TextField_1 = __importDefault(require("@material-ui/core/TextField"));
|
|
59
58
|
var MenuItem_1 = __importDefault(require("@material-ui/core/MenuItem"));
|
|
60
59
|
var Typography_1 = __importDefault(require("@material-ui/core/Typography"));
|
|
61
|
-
var styles_1 = require("./styles");
|
|
62
60
|
var Menu_1 = __importDefault(require("@material-ui/core/Menu"));
|
|
61
|
+
var helpers_1 = require("./helpers");
|
|
63
62
|
var DropdownIndicatorWithIconButton_1 = __importDefault(require("../../commonReactSelectComponents/DropdownIndicatorWithIconButton"));
|
|
64
63
|
var DateRangePicker_1 = __importDefault(require("../../DateRangePicker/DateRangePicker"));
|
|
64
|
+
var styles_1 = require("./styles");
|
|
65
65
|
var localeFormat = moment_1.default.localeData().longDateFormat('L');
|
|
66
|
-
var formatValue = function (value, dataTypeDefinition, placeholder) {
|
|
67
|
-
return (0, ramda_1.isNil)(value) ? "".concat(placeholder) : "".concat((0, mdm_sdk_1.formatDataTypeValue)({ dataTypeDefinition: dataTypeDefinition }, value));
|
|
68
|
-
};
|
|
69
|
-
var getEditorValue = (0, ramda_1.curry)(function (placeholder, dataTypeDefinition, value, options) {
|
|
70
|
-
return (0, ramda_1.cond)([
|
|
71
|
-
[mdm_sdk_1.isEmptyValue, (0, ramda_1.always)({ value: '', label: '' })],
|
|
72
|
-
[
|
|
73
|
-
(0, ramda_1.is)(Array),
|
|
74
|
-
function (value) { return ({
|
|
75
|
-
value: value,
|
|
76
|
-
label: value.map(function (value) { return formatValue(value, dataTypeDefinition, placeholder); }).join(' \u2014 ')
|
|
77
|
-
}); }
|
|
78
|
-
],
|
|
79
|
-
[(0, ramda_1.is)(String), function (value) { return options.find((0, ramda_1.propEq)('value', value)); }]
|
|
80
|
-
])(value);
|
|
81
|
-
});
|
|
82
|
-
var convertValuesToDate = (0, ramda_1.pipe)(mdm_sdk_1.getDateRangeByValue, (0, ramda_1.defaultTo)([]), (0, ramda_1.map)(function (value) { return value && new Date(value); }));
|
|
83
66
|
var DateRangeEditor = function (_a) {
|
|
84
67
|
var _b;
|
|
85
|
-
var
|
|
68
|
+
var _c;
|
|
69
|
+
var label = _a.label, values = _a.values, options = _a.options, _d = _a.getValuesDateRange, getValuesDateRange = _d === void 0 ? helpers_1.convertValuesToDate : _d, _e = _a.onChange, onChange = _e === void 0 ? ramda_1.identity : _e, _f = _a.dataTypeDefinition, dataTypeDefinition = _f === void 0 ? {
|
|
70
|
+
type: mdm_sdk_1.DataTypes.TYPE_DATE
|
|
71
|
+
} : _f, TextFieldProps = _a.TextFieldProps, MenuProps = _a.MenuProps, otherProps = __rest(_a, ["label", "values", "options", "getValuesDateRange", "onChange", "dataTypeDefinition", "TextFieldProps", "MenuProps"]);
|
|
86
72
|
var classes = otherProps.classes;
|
|
87
73
|
var placeholder = localeFormat + (dataTypeDefinition.type === mdm_sdk_1.DataTypes.TYPE_TIMESTAMP ? ' HH:MM' : '');
|
|
88
74
|
var rangeOptions = (0, react_1.useMemo)(function () {
|
|
@@ -90,8 +76,8 @@ var DateRangeEditor = function (_a) {
|
|
|
90
76
|
Object.values(mdm_sdk_1.AllDateRangeValues).map(function (option) { return ({ value: option, label: (0, mdm_sdk_1.getRangeOptionLabel)(option) }); });
|
|
91
77
|
}, [options]);
|
|
92
78
|
var inputRef = (0, react_1.useRef)(null);
|
|
93
|
-
var
|
|
94
|
-
var
|
|
79
|
+
var _g = (0, react_1.useState)(false), open = _g[0], setOpen = _g[1];
|
|
80
|
+
var _h = (0, react_1.useState)(), customValue = _h[0], setCustomValue = _h[1];
|
|
95
81
|
var styles = (0, styles_1.useStyles)();
|
|
96
82
|
var onItemClick = function (value) {
|
|
97
83
|
if (value === mdm_sdk_1.AllDateRangeValues.PICK_DATE) {
|
|
@@ -99,18 +85,18 @@ var DateRangeEditor = function (_a) {
|
|
|
99
85
|
}
|
|
100
86
|
else {
|
|
101
87
|
setOpen(false);
|
|
102
|
-
setCustomValue();
|
|
88
|
+
setCustomValue(null);
|
|
103
89
|
onChange(value);
|
|
104
90
|
}
|
|
105
91
|
};
|
|
106
92
|
var handleToggle = (0, react_1.useCallback)(function () { return setOpen(function (open) { return !open; }); }, []);
|
|
107
93
|
var onCancel = function () {
|
|
108
|
-
setCustomValue();
|
|
94
|
+
setCustomValue(null);
|
|
109
95
|
setOpen(false);
|
|
110
96
|
};
|
|
111
97
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
112
|
-
react_1.default.createElement(TextField_1.default, __assign({}, TextFieldProps, otherProps, { label: label, value: TextFieldProps.value ||
|
|
113
|
-
getEditorValue(placeholder, dataTypeDefinition, customValue || values, rangeOptions).label, onClick: handleToggle, variant: "filled", margin: "dense", ref: inputRef, InputProps: __assign({ endAdornment: (react_1.default.createElement(DropdownIndicatorWithIconButton_1.default, { selectProps: {
|
|
98
|
+
react_1.default.createElement(TextField_1.default, __assign({}, TextFieldProps, otherProps, { label: label, value: (TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.value) ||
|
|
99
|
+
((_c = (0, helpers_1.getEditorValue)(placeholder, dataTypeDefinition, customValue || values, rangeOptions)) === null || _c === void 0 ? void 0 : _c.label), onClick: handleToggle, variant: "filled", margin: "dense", ref: inputRef, InputProps: __assign({ endAdornment: (react_1.default.createElement(DropdownIndicatorWithIconButton_1.default, { selectProps: {
|
|
114
100
|
classes: {
|
|
115
101
|
dropdownIndicator: (0, classnames_1.default)(styles.dropdownIndicator, classes === null || classes === void 0 ? void 0 : classes.dropdownIndicator)
|
|
116
102
|
},
|
|
@@ -119,7 +105,7 @@ var DateRangeEditor = function (_a) {
|
|
|
119
105
|
root: styles.inputRoot,
|
|
120
106
|
underline: (0, classnames_1.default)((_b = {}, _b[styles.underline] = open, _b)),
|
|
121
107
|
adornedEnd: styles.adornedEnd
|
|
122
|
-
}, disableUnderline: (0, ramda_1.isNil)(values), readOnly: true }, TextFieldProps.InputProps), InputLabelProps: {
|
|
108
|
+
}, disableUnderline: (0, ramda_1.isNil)(values), readOnly: true }, TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.InputProps), InputLabelProps: {
|
|
123
109
|
classes: {
|
|
124
110
|
root: open ? styles.inputLabel : undefined
|
|
125
111
|
},
|
|
@@ -139,18 +125,4 @@ var DateRangeEditor = function (_a) {
|
|
|
139
125
|
} }, MenuProps), customValue ? (react_1.default.createElement(DateRangePicker_1.default, { values: getValuesDateRange(values), onCancel: onCancel, onApply: onItemClick, type: dataTypeDefinition.type })) : (rangeOptions.map(function (option) { return (react_1.default.createElement(MenuItem_1.default, { key: option.value, value: option.value, onClick: function () { return onItemClick(option.value); }, className: styles.menuItem },
|
|
140
126
|
react_1.default.createElement(Typography_1.default, { classes: { root: styles.menuText } }, option.label))); })))));
|
|
141
127
|
};
|
|
142
|
-
DateRangeEditor.propTypes = {
|
|
143
|
-
label: prop_types_1.default.string,
|
|
144
|
-
values: prop_types_1.default.oneOfType([prop_types_1.default.string, prop_types_1.default.array]),
|
|
145
|
-
options: prop_types_1.default.arrayOf(prop_types_1.default.shape({
|
|
146
|
-
value: prop_types_1.default.string,
|
|
147
|
-
label: prop_types_1.default.string
|
|
148
|
-
})),
|
|
149
|
-
getValuesDateRange: prop_types_1.default.func,
|
|
150
|
-
onChange: prop_types_1.default.func,
|
|
151
|
-
dataTypeDefinition: prop_types_1.default.object,
|
|
152
|
-
TextFieldProps: prop_types_1.default.object,
|
|
153
|
-
MenuProps: prop_types_1.default.object,
|
|
154
|
-
classes: prop_types_1.default.object
|
|
155
|
-
};
|
|
156
128
|
exports.default = DateRangeEditor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DatePeriod } from '@reltio/mdm-sdk';
|
|
2
|
+
export declare type Option = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type Values = DatePeriod | string;
|
|
7
|
+
declare const getEditorValue: any;
|
|
8
|
+
declare const convertValuesToDate: any;
|
|
9
|
+
export { getEditorValue, convertValuesToDate };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertValuesToDate = exports.getEditorValue = void 0;
|
|
4
|
+
var ramda_1 = require("ramda");
|
|
5
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
6
|
+
var formatValue = function (value, dataTypeDefinition, placeholder) {
|
|
7
|
+
return (0, ramda_1.isNil)(value) ? "".concat(placeholder) : "".concat((0, mdm_sdk_1.formatDataTypeValue)({ dataTypeDefinition: dataTypeDefinition }, value));
|
|
8
|
+
};
|
|
9
|
+
var getEditorValue = (0, ramda_1.curry)(function (placeholder, dataTypeDefinition, value, options) {
|
|
10
|
+
return (0, ramda_1.cond)([
|
|
11
|
+
[mdm_sdk_1.isEmptyValue, (0, ramda_1.always)({ value: '', label: '' })],
|
|
12
|
+
[
|
|
13
|
+
(0, ramda_1.is)(Array),
|
|
14
|
+
function (value) { return ({
|
|
15
|
+
value: value,
|
|
16
|
+
label: value.map(function (value) { return formatValue(value, dataTypeDefinition, placeholder); }).join(' \u2014 ')
|
|
17
|
+
}); }
|
|
18
|
+
],
|
|
19
|
+
[(0, ramda_1.is)(String), function (value) { return options.find((0, ramda_1.propEq)('value', value)); }]
|
|
20
|
+
])(value);
|
|
21
|
+
});
|
|
22
|
+
exports.getEditorValue = getEditorValue;
|
|
23
|
+
var convertValuesToDate = (0, ramda_1.pipe)(mdm_sdk_1.getDateRangeByValue, (0, ramda_1.defaultTo)([]), (0, ramda_1.map)(function (value) { return value && new Date(value); }));
|
|
24
|
+
exports.convertValuesToDate = convertValuesToDate;
|
|
@@ -7,13 +7,13 @@ declare type TimestampEditorProps = {
|
|
|
7
7
|
value: number | Date;
|
|
8
8
|
label?: string;
|
|
9
9
|
variant: TextFieldProps['variant'];
|
|
10
|
-
InputProps
|
|
10
|
+
InputProps?: TextFieldProps['InputProps'];
|
|
11
11
|
format?: string;
|
|
12
12
|
InputLabelProps?: Partial<InputLabelProps>;
|
|
13
13
|
onBlur?: () => void;
|
|
14
14
|
onFocus?: () => void;
|
|
15
15
|
onChange: (value: number | Date) => void;
|
|
16
|
-
onAccept
|
|
16
|
+
onAccept?: (value: number | Date | Moment) => void;
|
|
17
17
|
} & Omit<KeyboardDateTimePickerProps, 'value' | 'label' | 'variant' | 'size' | 'hiddenLabel' | 'onBlur' | 'onFocus' | 'onChange' | 'onAccept'>;
|
|
18
18
|
declare const TimestampEditor: ({ value, label, variant, onChange, InputProps, format, ...otherProps }: TimestampEditorProps) => JSX.Element;
|
|
19
19
|
export default TimestampEditor;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type Values = [Date, Date];
|
|
3
|
+
declare type Props = {
|
|
4
|
+
onCancel: () => void;
|
|
5
|
+
onApply: ([startDate, endDate]: Values) => void;
|
|
6
|
+
values?: Values;
|
|
7
|
+
type?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const DateRangePicker: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
1
10
|
export default DateRangePicker;
|
|
2
|
-
declare const DateRangePicker: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
3
|
-
import React from "react";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { forwardRef, useRef, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import i18n from 'ui-i18n';
|
|
4
3
|
import nanoid from 'nanoid';
|
|
5
4
|
import { pathOr } from 'ramda';
|
|
@@ -53,11 +52,5 @@ var DateRangePicker = forwardRef(function (_a, ref) {
|
|
|
53
52
|
React.createElement("div", { className: styles.actionButtons },
|
|
54
53
|
React.createElement(Button, { color: "primary", onClick: onUpdate, className: styles.button }, i18n.text('Update')))));
|
|
55
54
|
});
|
|
56
|
-
DateRangePicker.propTypes = {
|
|
57
|
-
onCancel: PropTypes.func.isRequired,
|
|
58
|
-
onApply: PropTypes.func.isRequired,
|
|
59
|
-
values: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
|
|
60
|
-
type: PropTypes.string
|
|
61
|
-
};
|
|
62
55
|
DateRangePicker.displayName = 'DateRangePicker';
|
|
63
56
|
export default DateRangePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"button" | "title" | "header" | "container" | "dateRangeContainer" | "dateInput" | "actionButtons">;
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"button" | "title" | "header" | "container" | "dateRangeContainer" | "dateInput" | "actionButtons">;
|
|
@@ -53,12 +53,6 @@ var CustomDateRangeEditor = function (_a) {
|
|
|
53
53
|
autoFocusItem: open,
|
|
54
54
|
style: { width: '100%' }
|
|
55
55
|
} },
|
|
56
|
-
React.createElement(DateRangePicker
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
, {
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
values: values, onCancel: onCancel, onApply: onApply, type: DataTypes.TYPE_ACTIVENESS_DATE }))));
|
|
56
|
+
React.createElement(DateRangePicker, { values: values, onCancel: onCancel, onApply: onApply, type: DataTypes.TYPE_ACTIVENESS_DATE }))));
|
|
63
57
|
};
|
|
64
58
|
export default CustomDateRangeEditor;
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DataTypeDefinition } from '@reltio/mdm-sdk';
|
|
3
|
+
import { TextFieldProps } from '@material-ui/core/TextField';
|
|
4
|
+
import { MenuProps } from '@material-ui/core/Menu';
|
|
5
|
+
import { Option, Values } from './helpers';
|
|
6
|
+
export declare type DateRangeEditorProps = {
|
|
7
|
+
label?: string;
|
|
8
|
+
values?: Values;
|
|
9
|
+
options?: Option[];
|
|
10
|
+
getValuesDateRange?: (value: Values) => [Date, Date];
|
|
11
|
+
onChange?: (value: Values) => void;
|
|
12
|
+
dataTypeDefinition?: DataTypeDefinition;
|
|
13
|
+
MenuProps?: Partial<MenuProps>;
|
|
14
|
+
TextFieldProps?: TextFieldProps;
|
|
15
|
+
className?: string;
|
|
16
|
+
classes?: {
|
|
17
|
+
dropdownIndicator?: string;
|
|
18
|
+
root?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
declare const DateRangeEditor: ({ label, values, options, getValuesDateRange, onChange, dataTypeDefinition, TextFieldProps, MenuProps, ...otherProps }: DateRangeEditorProps) => JSX.Element;
|
|
1
22
|
export default DateRangeEditor;
|
|
2
|
-
declare function DateRangeEditor({ label, values, options, getValuesDateRange, onChange, dataTypeDefinition, TextFieldProps, MenuProps, ...otherProps }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
label: any;
|
|
5
|
-
values: any;
|
|
6
|
-
options: any;
|
|
7
|
-
getValuesDateRange?: any;
|
|
8
|
-
onChange?: any;
|
|
9
|
-
dataTypeDefinition?: {};
|
|
10
|
-
TextFieldProps?: {};
|
|
11
|
-
MenuProps?: {};
|
|
12
|
-
}): JSX.Element;
|
|
13
|
-
declare namespace DateRangeEditor {
|
|
14
|
-
namespace propTypes {
|
|
15
|
-
const label: PropTypes.Requireable<string>;
|
|
16
|
-
const values: PropTypes.Requireable<NonNullable<string | any[]>>;
|
|
17
|
-
const options: PropTypes.Requireable<PropTypes.InferProps<{
|
|
18
|
-
value: PropTypes.Requireable<string>;
|
|
19
|
-
label: PropTypes.Requireable<string>;
|
|
20
|
-
}>[]>;
|
|
21
|
-
const getValuesDateRange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
-
const onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
-
const dataTypeDefinition: PropTypes.Requireable<object>;
|
|
24
|
-
const TextFieldProps: PropTypes.Requireable<object>;
|
|
25
|
-
const MenuProps: PropTypes.Requireable<object>;
|
|
26
|
-
const classes: PropTypes.Requireable<object>;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
import PropTypes from "prop-types";
|
|
@@ -21,40 +21,26 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
24
|
-
import PropTypes from 'prop-types';
|
|
25
24
|
import classnames from 'classnames';
|
|
26
25
|
import moment from 'moment';
|
|
27
26
|
import i18n from 'ui-i18n';
|
|
28
|
-
import {
|
|
29
|
-
import { DataTypes, AllDateRangeValues,
|
|
27
|
+
import { identity, isNil, prop } from 'ramda';
|
|
28
|
+
import { DataTypes, AllDateRangeValues, getRangeOptionLabel } from '@reltio/mdm-sdk';
|
|
30
29
|
import TextField from '@material-ui/core/TextField';
|
|
31
30
|
import MenuItem from '@material-ui/core/MenuItem';
|
|
32
31
|
import Typography from '@material-ui/core/Typography';
|
|
33
|
-
import { useStyles } from './styles';
|
|
34
32
|
import Menu from '@material-ui/core/Menu';
|
|
33
|
+
import { getEditorValue, convertValuesToDate } from './helpers';
|
|
35
34
|
import DropdownIndicatorWithIconButton from '../../commonReactSelectComponents/DropdownIndicatorWithIconButton';
|
|
36
35
|
import DateRangePicker from '../../DateRangePicker/DateRangePicker';
|
|
36
|
+
import { useStyles } from './styles';
|
|
37
37
|
var localeFormat = moment.localeData().longDateFormat('L');
|
|
38
|
-
var formatValue = function (value, dataTypeDefinition, placeholder) {
|
|
39
|
-
return isNil(value) ? "".concat(placeholder) : "".concat(formatDataTypeValue({ dataTypeDefinition: dataTypeDefinition }, value));
|
|
40
|
-
};
|
|
41
|
-
var getEditorValue = curry(function (placeholder, dataTypeDefinition, value, options) {
|
|
42
|
-
return cond([
|
|
43
|
-
[isEmptyValue, always({ value: '', label: '' })],
|
|
44
|
-
[
|
|
45
|
-
is(Array),
|
|
46
|
-
function (value) { return ({
|
|
47
|
-
value: value,
|
|
48
|
-
label: value.map(function (value) { return formatValue(value, dataTypeDefinition, placeholder); }).join(' \u2014 ')
|
|
49
|
-
}); }
|
|
50
|
-
],
|
|
51
|
-
[is(String), function (value) { return options.find(propEq('value', value)); }]
|
|
52
|
-
])(value);
|
|
53
|
-
});
|
|
54
|
-
var convertValuesToDate = pipe(getDateRangeByValue, defaultTo([]), map(function (value) { return value && new Date(value); }));
|
|
55
38
|
var DateRangeEditor = function (_a) {
|
|
56
39
|
var _b;
|
|
57
|
-
var
|
|
40
|
+
var _c;
|
|
41
|
+
var label = _a.label, values = _a.values, options = _a.options, _d = _a.getValuesDateRange, getValuesDateRange = _d === void 0 ? convertValuesToDate : _d, _e = _a.onChange, onChange = _e === void 0 ? identity : _e, _f = _a.dataTypeDefinition, dataTypeDefinition = _f === void 0 ? {
|
|
42
|
+
type: DataTypes.TYPE_DATE
|
|
43
|
+
} : _f, TextFieldProps = _a.TextFieldProps, MenuProps = _a.MenuProps, otherProps = __rest(_a, ["label", "values", "options", "getValuesDateRange", "onChange", "dataTypeDefinition", "TextFieldProps", "MenuProps"]);
|
|
58
44
|
var classes = otherProps.classes;
|
|
59
45
|
var placeholder = localeFormat + (dataTypeDefinition.type === DataTypes.TYPE_TIMESTAMP ? ' HH:MM' : '');
|
|
60
46
|
var rangeOptions = useMemo(function () {
|
|
@@ -62,8 +48,8 @@ var DateRangeEditor = function (_a) {
|
|
|
62
48
|
Object.values(AllDateRangeValues).map(function (option) { return ({ value: option, label: getRangeOptionLabel(option) }); });
|
|
63
49
|
}, [options]);
|
|
64
50
|
var inputRef = useRef(null);
|
|
65
|
-
var
|
|
66
|
-
var
|
|
51
|
+
var _g = useState(false), open = _g[0], setOpen = _g[1];
|
|
52
|
+
var _h = useState(), customValue = _h[0], setCustomValue = _h[1];
|
|
67
53
|
var styles = useStyles();
|
|
68
54
|
var onItemClick = function (value) {
|
|
69
55
|
if (value === AllDateRangeValues.PICK_DATE) {
|
|
@@ -71,18 +57,18 @@ var DateRangeEditor = function (_a) {
|
|
|
71
57
|
}
|
|
72
58
|
else {
|
|
73
59
|
setOpen(false);
|
|
74
|
-
setCustomValue();
|
|
60
|
+
setCustomValue(null);
|
|
75
61
|
onChange(value);
|
|
76
62
|
}
|
|
77
63
|
};
|
|
78
64
|
var handleToggle = useCallback(function () { return setOpen(function (open) { return !open; }); }, []);
|
|
79
65
|
var onCancel = function () {
|
|
80
|
-
setCustomValue();
|
|
66
|
+
setCustomValue(null);
|
|
81
67
|
setOpen(false);
|
|
82
68
|
};
|
|
83
69
|
return (React.createElement(React.Fragment, null,
|
|
84
|
-
React.createElement(TextField, __assign({}, TextFieldProps, otherProps, { label: label, value: TextFieldProps.value ||
|
|
85
|
-
getEditorValue(placeholder, dataTypeDefinition, customValue || values, rangeOptions).label, onClick: handleToggle, variant: "filled", margin: "dense", ref: inputRef, InputProps: __assign({ endAdornment: (React.createElement(DropdownIndicatorWithIconButton, { selectProps: {
|
|
70
|
+
React.createElement(TextField, __assign({}, TextFieldProps, otherProps, { label: label, value: (TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.value) ||
|
|
71
|
+
((_c = getEditorValue(placeholder, dataTypeDefinition, customValue || values, rangeOptions)) === null || _c === void 0 ? void 0 : _c.label), onClick: handleToggle, variant: "filled", margin: "dense", ref: inputRef, InputProps: __assign({ endAdornment: (React.createElement(DropdownIndicatorWithIconButton, { selectProps: {
|
|
86
72
|
classes: {
|
|
87
73
|
dropdownIndicator: classnames(styles.dropdownIndicator, classes === null || classes === void 0 ? void 0 : classes.dropdownIndicator)
|
|
88
74
|
},
|
|
@@ -91,7 +77,7 @@ var DateRangeEditor = function (_a) {
|
|
|
91
77
|
root: styles.inputRoot,
|
|
92
78
|
underline: classnames((_b = {}, _b[styles.underline] = open, _b)),
|
|
93
79
|
adornedEnd: styles.adornedEnd
|
|
94
|
-
}, disableUnderline: isNil(values), readOnly: true }, TextFieldProps.InputProps), InputLabelProps: {
|
|
80
|
+
}, disableUnderline: isNil(values), readOnly: true }, TextFieldProps === null || TextFieldProps === void 0 ? void 0 : TextFieldProps.InputProps), InputLabelProps: {
|
|
95
81
|
classes: {
|
|
96
82
|
root: open ? styles.inputLabel : undefined
|
|
97
83
|
},
|
|
@@ -111,18 +97,4 @@ var DateRangeEditor = function (_a) {
|
|
|
111
97
|
} }, MenuProps), customValue ? (React.createElement(DateRangePicker, { values: getValuesDateRange(values), onCancel: onCancel, onApply: onItemClick, type: dataTypeDefinition.type })) : (rangeOptions.map(function (option) { return (React.createElement(MenuItem, { key: option.value, value: option.value, onClick: function () { return onItemClick(option.value); }, className: styles.menuItem },
|
|
112
98
|
React.createElement(Typography, { classes: { root: styles.menuText } }, option.label))); })))));
|
|
113
99
|
};
|
|
114
|
-
DateRangeEditor.propTypes = {
|
|
115
|
-
label: PropTypes.string,
|
|
116
|
-
values: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
117
|
-
options: PropTypes.arrayOf(PropTypes.shape({
|
|
118
|
-
value: PropTypes.string,
|
|
119
|
-
label: PropTypes.string
|
|
120
|
-
})),
|
|
121
|
-
getValuesDateRange: PropTypes.func,
|
|
122
|
-
onChange: PropTypes.func,
|
|
123
|
-
dataTypeDefinition: PropTypes.object,
|
|
124
|
-
TextFieldProps: PropTypes.object,
|
|
125
|
-
MenuProps: PropTypes.object,
|
|
126
|
-
classes: PropTypes.object
|
|
127
|
-
};
|
|
128
100
|
export default DateRangeEditor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DatePeriod } from '@reltio/mdm-sdk';
|
|
2
|
+
export declare type Option = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type Values = DatePeriod | string;
|
|
7
|
+
declare const getEditorValue: any;
|
|
8
|
+
declare const convertValuesToDate: any;
|
|
9
|
+
export { getEditorValue, convertValuesToDate };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { always, cond, curry, defaultTo, is, isNil, map, pipe, propEq } from 'ramda';
|
|
2
|
+
import { formatDataTypeValue, getDateRangeByValue, isEmptyValue } from '@reltio/mdm-sdk';
|
|
3
|
+
var formatValue = function (value, dataTypeDefinition, placeholder) {
|
|
4
|
+
return isNil(value) ? "".concat(placeholder) : "".concat(formatDataTypeValue({ dataTypeDefinition: dataTypeDefinition }, value));
|
|
5
|
+
};
|
|
6
|
+
var getEditorValue = curry(function (placeholder, dataTypeDefinition, value, options) {
|
|
7
|
+
return cond([
|
|
8
|
+
[isEmptyValue, always({ value: '', label: '' })],
|
|
9
|
+
[
|
|
10
|
+
is(Array),
|
|
11
|
+
function (value) { return ({
|
|
12
|
+
value: value,
|
|
13
|
+
label: value.map(function (value) { return formatValue(value, dataTypeDefinition, placeholder); }).join(' \u2014 ')
|
|
14
|
+
}); }
|
|
15
|
+
],
|
|
16
|
+
[is(String), function (value) { return options.find(propEq('value', value)); }]
|
|
17
|
+
])(value);
|
|
18
|
+
});
|
|
19
|
+
var convertValuesToDate = pipe(getDateRangeByValue, defaultTo([]), map(function (value) { return value && new Date(value); }));
|
|
20
|
+
export { getEditorValue, convertValuesToDate };
|
|
@@ -7,13 +7,13 @@ declare type TimestampEditorProps = {
|
|
|
7
7
|
value: number | Date;
|
|
8
8
|
label?: string;
|
|
9
9
|
variant: TextFieldProps['variant'];
|
|
10
|
-
InputProps
|
|
10
|
+
InputProps?: TextFieldProps['InputProps'];
|
|
11
11
|
format?: string;
|
|
12
12
|
InputLabelProps?: Partial<InputLabelProps>;
|
|
13
13
|
onBlur?: () => void;
|
|
14
14
|
onFocus?: () => void;
|
|
15
15
|
onChange: (value: number | Date) => void;
|
|
16
|
-
onAccept
|
|
16
|
+
onAccept?: (value: number | Date | Moment) => void;
|
|
17
17
|
} & Omit<KeyboardDateTimePickerProps, 'value' | 'label' | 'variant' | 'size' | 'hiddenLabel' | 'onBlur' | 'onFocus' | 'onChange' | 'onAccept'>;
|
|
18
18
|
declare const TimestampEditor: ({ value, label, variant, onChange, InputProps, format, ...otherProps }: TimestampEditorProps) => JSX.Element;
|
|
19
19
|
export default TimestampEditor;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1349",
|
|
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.
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-module": "^1.4.1349",
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1349",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|