@truedat/core 4.47.8 → 4.48.2
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/CHANGELOG.md +6 -0
- package/package.json +3 -3
- package/src/components/DateRangeFilter.js +0 -6
- package/src/components/OptionGroup.js +12 -31
- package/src/components/TemplateSelector.js +10 -9
- package/src/components/UserFilters.js +2 -2
- package/src/components/__tests__/__snapshots__/OptionGroup.spec.js.snap +1 -0
- package/src/components/__tests__/__snapshots__/UserFilters.spec.js.snap +2 -2
- package/src/services/fieldType.js +9 -7
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.48.2",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@testing-library/jest-dom": "^5.16.4",
|
|
36
36
|
"@testing-library/react": "^12.0.0",
|
|
37
37
|
"@testing-library/user-event": "^13.2.1",
|
|
38
|
-
"@truedat/test": "4.47.
|
|
38
|
+
"@truedat/test": "4.47.9",
|
|
39
39
|
"babel-jest": "^28.1.0",
|
|
40
40
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
41
41
|
"babel-plugin-lodash": "^3.3.4",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"react-dom": ">= 16.8.6 < 17",
|
|
113
113
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "93133e957332713e64c97eecdf45cc283c29bd32"
|
|
116
116
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
import moment from "moment";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import { useIntl } from "react-intl";
|
|
5
|
-
import { Form, Input, Label, Dropdown } from "semantic-ui-react";
|
|
6
4
|
import { DatesRangeInput } from "semantic-ui-calendar-react";
|
|
7
5
|
|
|
8
6
|
const validNumber = (value) => RegExp("^\\d+$").test(value);
|
|
@@ -10,10 +8,8 @@ const validRange = (value) =>
|
|
|
10
8
|
RegExp("^\\d{4}-\\d\\d-\\d\\d *- *\\d{4}-\\d\\d-\\d\\d$").test(value);
|
|
11
9
|
|
|
12
10
|
export const DateRangeFilter = ({
|
|
13
|
-
label,
|
|
14
11
|
onChange,
|
|
15
12
|
defaultValues,
|
|
16
|
-
size = "small",
|
|
17
13
|
name = "date",
|
|
18
14
|
dateFormat = "YYYY-MM-DD",
|
|
19
15
|
}) => {
|
|
@@ -47,10 +43,8 @@ export const DateRangeFilter = ({
|
|
|
47
43
|
DateRangeFilter.propTypes = {
|
|
48
44
|
dateFormat: PropTypes.string,
|
|
49
45
|
defaultValues: PropTypes.object,
|
|
50
|
-
label: PropTypes.node,
|
|
51
46
|
name: PropTypes.string,
|
|
52
47
|
onChange: PropTypes.func,
|
|
53
|
-
size: PropTypes.string,
|
|
54
48
|
};
|
|
55
49
|
|
|
56
50
|
export default DateRangeFilter;
|
|
@@ -4,21 +4,6 @@ import PropTypes from "prop-types";
|
|
|
4
4
|
import { Dropdown } from "semantic-ui-react";
|
|
5
5
|
import { lowerDeburr } from "../services/sort";
|
|
6
6
|
|
|
7
|
-
const Group = ({ label, icon, options, onClick, value }) => (
|
|
8
|
-
<>
|
|
9
|
-
<Dropdown.Divider />
|
|
10
|
-
<Dropdown.Header icon={icon} content={label} />
|
|
11
|
-
{options.map((option, i) => (
|
|
12
|
-
<Dropdown.Item
|
|
13
|
-
key={i}
|
|
14
|
-
className="group"
|
|
15
|
-
{...option}
|
|
16
|
-
onClick={onClick}
|
|
17
|
-
selected={value == option.value}
|
|
18
|
-
/>
|
|
19
|
-
))}
|
|
20
|
-
</>
|
|
21
|
-
);
|
|
22
7
|
// TODO: Refactor
|
|
23
8
|
export const OptionGroup = ({
|
|
24
9
|
fluid,
|
|
@@ -62,10 +47,7 @@ export const OptionGroup = ({
|
|
|
62
47
|
|
|
63
48
|
useEffect(() => {
|
|
64
49
|
// eslint-disable-next-line prettier/prettier
|
|
65
|
-
_.flow(
|
|
66
|
-
toFlattenedShorthands,
|
|
67
|
-
setFlattenedOptions
|
|
68
|
-
)(availableOptions);
|
|
50
|
+
_.flow(toFlattenedShorthands, setFlattenedOptions)(availableOptions);
|
|
69
51
|
}, [availableOptions]);
|
|
70
52
|
|
|
71
53
|
const flatOptionMatches = (o, searchQuery) =>
|
|
@@ -94,18 +76,17 @@ export const OptionGroup = ({
|
|
|
94
76
|
multiple && onChange(dropdown.value);
|
|
95
77
|
};
|
|
96
78
|
|
|
97
|
-
const findText = (
|
|
98
|
-
_.
|
|
99
|
-
|
|
100
|
-
(acc, o)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const text = value && !query && findText();
|
|
79
|
+
const findText = _.flow(
|
|
80
|
+
_.reduce(
|
|
81
|
+
(acc, o) =>
|
|
82
|
+
_.has("options")(o) ? [...acc, ..._.prop("options")(o)] : [...acc, o],
|
|
83
|
+
[]
|
|
84
|
+
),
|
|
85
|
+
_.find((o) => o.value == value),
|
|
86
|
+
_.prop("text")
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const text = value && !query ? findText(options) : "";
|
|
109
90
|
|
|
110
91
|
const toFlattenedShorthands = (availableOpts) =>
|
|
111
92
|
availableOpts.flatMap((option, i) => {
|
|
@@ -7,14 +7,15 @@ import { useQuery } from "@apollo/client";
|
|
|
7
7
|
import { accentInsensitivePathOrder } from "../services/sort";
|
|
8
8
|
import { TEMPLATES_QUERY } from "../api/queries";
|
|
9
9
|
|
|
10
|
-
const makeOptions =
|
|
11
|
-
_.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
10
|
+
const makeOptions = (formatMessage) =>
|
|
11
|
+
_.flow(
|
|
12
|
+
_.map(({ label, id: value }) => ({
|
|
13
|
+
key: value,
|
|
14
|
+
value,
|
|
15
|
+
text: formatMessage({ id: `templates.${label}`, defaultMessage: label }),
|
|
16
|
+
})),
|
|
17
|
+
_.sortBy(accentInsensitivePathOrder("text"))
|
|
18
|
+
);
|
|
18
19
|
|
|
19
20
|
export const TemplateSelector = ({
|
|
20
21
|
clearable,
|
|
@@ -26,7 +27,7 @@ export const TemplateSelector = ({
|
|
|
26
27
|
templates,
|
|
27
28
|
}) => {
|
|
28
29
|
const { formatMessage } = useIntl();
|
|
29
|
-
const options = makeOptions(templates);
|
|
30
|
+
const options = makeOptions(formatMessage)(templates);
|
|
30
31
|
const hidden = loading ? false : _.size(templates) <= 1;
|
|
31
32
|
|
|
32
33
|
const handleChange = (e, { value, ...data }) => {
|
|
@@ -16,11 +16,11 @@ export const UserFilters = ({
|
|
|
16
16
|
}) => {
|
|
17
17
|
return _.isEmpty(userFilters) ? null : (
|
|
18
18
|
<div className="selectedFilters">
|
|
19
|
-
{userFilters.map((userFilter,
|
|
19
|
+
{userFilters.map((userFilter, key) => (
|
|
20
20
|
<Label
|
|
21
21
|
basic={selectedUserFilter == userFilter.name ? false : true}
|
|
22
22
|
circular
|
|
23
|
-
key={
|
|
23
|
+
key={key}
|
|
24
24
|
>
|
|
25
25
|
<span
|
|
26
26
|
onClick={
|
|
@@ -7,7 +7,7 @@ exports[`<UserFilters /> matches the latest snapshot 1`] = `
|
|
|
7
7
|
<Label
|
|
8
8
|
basic={true}
|
|
9
9
|
circular={true}
|
|
10
|
-
key="
|
|
10
|
+
key="0"
|
|
11
11
|
>
|
|
12
12
|
<span
|
|
13
13
|
className="userFilter"
|
|
@@ -51,7 +51,7 @@ exports[`<UserFilters /> matches the latest snapshot 1`] = `
|
|
|
51
51
|
<Label
|
|
52
52
|
basic={true}
|
|
53
53
|
circular={true}
|
|
54
|
-
key="
|
|
54
|
+
key="1"
|
|
55
55
|
>
|
|
56
56
|
<span
|
|
57
57
|
className="userFilter"
|
|
@@ -12,12 +12,14 @@ const guessType = _.flow(
|
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
export const getFieldType = ({ data_type_class, type }) =>
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
type === "reference_dataset_field"
|
|
16
|
+
? "string"
|
|
17
|
+
: _.includes(data_type_class)([
|
|
18
|
+
"boolean",
|
|
19
|
+
"date",
|
|
20
|
+
"number",
|
|
21
|
+
"string",
|
|
22
|
+
"timestamp",
|
|
23
|
+
])
|
|
22
24
|
? data_type_class
|
|
23
25
|
: guessType(type);
|