@truedat/core 4.47.4 → 4.47.5
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
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.47.5] 2022-06-30
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- [TD-4894] Multiple column operator in implementation creation
|
|
8
|
+
|
|
3
9
|
## [4.46.12] 2022-06-20
|
|
4
10
|
|
|
5
|
-
###
|
|
11
|
+
### Removed
|
|
6
12
|
|
|
7
13
|
- [TD-4894] Multiple column operator in implementation creation
|
|
8
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "4.47.
|
|
3
|
+
"version": "4.47.5",
|
|
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.5",
|
|
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": "1265272aa7b8fcb415592916f0e557ae226befe3"
|
|
116
116
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import React, { useState } from "react";
|
|
2
|
+
import React, { useState, useEffect } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { Dropdown } from "semantic-ui-react";
|
|
5
5
|
import { lowerDeburr } from "../services/sort";
|
|
@@ -27,13 +27,18 @@ export const OptionGroup = ({
|
|
|
27
27
|
options = [],
|
|
28
28
|
placeholder = "Select",
|
|
29
29
|
onClick,
|
|
30
|
+
onChange,
|
|
30
31
|
value,
|
|
32
|
+
multiple,
|
|
31
33
|
}) => {
|
|
32
34
|
const [availableOptions, setOptions] = useState(options);
|
|
35
|
+
const [flattenedOptions, setFlattenedOptions] = useState();
|
|
33
36
|
const [open, openMenu] = useState(false);
|
|
34
37
|
const [query, setQuery] = useState("");
|
|
35
38
|
|
|
36
|
-
if (_.isEmpty(query) && options !== availableOptions)
|
|
39
|
+
if (_.isEmpty(query) && options !== availableOptions) {
|
|
40
|
+
setOptions(options);
|
|
41
|
+
}
|
|
37
42
|
|
|
38
43
|
const doSearch = ({ searchQuery }) => {
|
|
39
44
|
!open && openMenu(true);
|
|
@@ -55,6 +60,14 @@ export const OptionGroup = ({
|
|
|
55
60
|
);
|
|
56
61
|
};
|
|
57
62
|
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
// eslint-disable-next-line prettier/prettier
|
|
65
|
+
_.flow(
|
|
66
|
+
toFlattenedShorthands,
|
|
67
|
+
setFlattenedOptions
|
|
68
|
+
)(availableOptions);
|
|
69
|
+
}, [availableOptions]);
|
|
70
|
+
|
|
58
71
|
const flatOptionMatches = (o, searchQuery) =>
|
|
59
72
|
!_.has("options")(o) && optionMatches(lowerDeburr(searchQuery))(o);
|
|
60
73
|
|
|
@@ -72,10 +85,15 @@ export const OptionGroup = ({
|
|
|
72
85
|
const optionMatches = (q) => (o) => matches(q)(selection(o));
|
|
73
86
|
|
|
74
87
|
const doOnClick = (e, values) => {
|
|
88
|
+
!multiple && openMenu(false);
|
|
75
89
|
setQuery("");
|
|
76
90
|
onClick(values);
|
|
77
91
|
};
|
|
78
92
|
|
|
93
|
+
const onChangeOptionsGroup = (e, dropdown) => {
|
|
94
|
+
multiple && onChange(dropdown.value);
|
|
95
|
+
};
|
|
96
|
+
|
|
79
97
|
const findText = () =>
|
|
80
98
|
_.flow(
|
|
81
99
|
_.reduce(
|
|
@@ -89,10 +107,44 @@ export const OptionGroup = ({
|
|
|
89
107
|
|
|
90
108
|
const text = value && !query && findText();
|
|
91
109
|
|
|
110
|
+
const toFlattenedShorthands = (availableOpts) =>
|
|
111
|
+
availableOpts.flatMap((option, i) => {
|
|
112
|
+
const result = _.has("options")(option)
|
|
113
|
+
? [
|
|
114
|
+
{
|
|
115
|
+
key: i,
|
|
116
|
+
children: (
|
|
117
|
+
<>
|
|
118
|
+
<Dropdown.Divider />
|
|
119
|
+
<Dropdown.Header icon={option.icon} content={option.label} />
|
|
120
|
+
</>
|
|
121
|
+
),
|
|
122
|
+
disabled: true,
|
|
123
|
+
},
|
|
124
|
+
...option.options.map((innerOption, i) => ({
|
|
125
|
+
...innerOption,
|
|
126
|
+
className: "group",
|
|
127
|
+
onClick: doOnClick,
|
|
128
|
+
})),
|
|
129
|
+
]
|
|
130
|
+
: [
|
|
131
|
+
{
|
|
132
|
+
...option,
|
|
133
|
+
className: "header",
|
|
134
|
+
onClick: doOnClick,
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
return result;
|
|
138
|
+
});
|
|
139
|
+
|
|
92
140
|
return (
|
|
93
141
|
<>
|
|
94
142
|
{label && <label>{label}</label>}
|
|
143
|
+
|
|
95
144
|
<Dropdown
|
|
145
|
+
multiple={multiple}
|
|
146
|
+
options={flattenedOptions}
|
|
147
|
+
onChange={onChangeOptionsGroup}
|
|
96
148
|
fluid={fluid}
|
|
97
149
|
className="selection"
|
|
98
150
|
placeholder={placeholder}
|
|
@@ -106,41 +158,25 @@ export const OptionGroup = ({
|
|
|
106
158
|
onBlur={() => openMenu(false)}
|
|
107
159
|
text={text}
|
|
108
160
|
value={value}
|
|
109
|
-
|
|
110
|
-
<Dropdown.Menu>
|
|
111
|
-
{availableOptions.map((option, i) =>
|
|
112
|
-
_.has("options")(option) ? (
|
|
113
|
-
<Group
|
|
114
|
-
key={i}
|
|
115
|
-
value={value}
|
|
116
|
-
onClick={doOnClick}
|
|
117
|
-
options={_.prop("options")(option)}
|
|
118
|
-
{...option}
|
|
119
|
-
/>
|
|
120
|
-
) : (
|
|
121
|
-
<Dropdown.Item
|
|
122
|
-
key={i}
|
|
123
|
-
{...option}
|
|
124
|
-
onClick={doOnClick}
|
|
125
|
-
className="header"
|
|
126
|
-
selected={value == option.value}
|
|
127
|
-
/>
|
|
128
|
-
)
|
|
129
|
-
)}
|
|
130
|
-
</Dropdown.Menu>
|
|
131
|
-
</Dropdown>
|
|
161
|
+
/>
|
|
132
162
|
</>
|
|
133
163
|
);
|
|
134
164
|
};
|
|
135
165
|
|
|
136
166
|
OptionGroup.propTypes = {
|
|
137
167
|
onClick: PropTypes.func,
|
|
138
|
-
|
|
168
|
+
onChange: PropTypes.func,
|
|
169
|
+
value: PropTypes.oneOfType([
|
|
170
|
+
PropTypes.string,
|
|
171
|
+
PropTypes.number,
|
|
172
|
+
PropTypes.array,
|
|
173
|
+
]),
|
|
139
174
|
fluid: PropTypes.bool,
|
|
140
175
|
inline: PropTypes.bool,
|
|
141
176
|
label: PropTypes.string,
|
|
142
177
|
placeholder: PropTypes.string,
|
|
143
178
|
options: PropTypes.array,
|
|
179
|
+
multiple: PropTypes.bool,
|
|
144
180
|
};
|
|
145
181
|
|
|
146
182
|
export default OptionGroup;
|
|
@@ -13,6 +13,7 @@ exports[`<OptionGroup /> matches the latest snapshot 1`] = `
|
|
|
13
13
|
minCharacters={1}
|
|
14
14
|
noResultsMessage="No results found."
|
|
15
15
|
onBlur={[Function]}
|
|
16
|
+
onChange={[Function]}
|
|
16
17
|
onClick={[Function]}
|
|
17
18
|
onSearchChange={[Function]}
|
|
18
19
|
open={false}
|
|
@@ -25,8 +26,6 @@ exports[`<OptionGroup /> matches the latest snapshot 1`] = `
|
|
|
25
26
|
selectOnBlur={true}
|
|
26
27
|
selectOnNavigation={true}
|
|
27
28
|
wrapSelection={true}
|
|
28
|
-
|
|
29
|
-
<DropdownMenu />
|
|
30
|
-
</Dropdown>
|
|
29
|
+
/>
|
|
31
30
|
</Fragment>
|
|
32
31
|
`;
|