@truedat/core 4.46.10 → 4.46.12
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "4.46.
|
|
3
|
+
"version": "4.46.12",
|
|
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.46.
|
|
38
|
+
"@truedat/test": "4.46.12",
|
|
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": "97adb120fffb6392692f94ed99b5f74385ce0f0b"
|
|
116
116
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
-
import React, { useState
|
|
2
|
+
import React, { useState } 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,12 +27,9 @@ export const OptionGroup = ({
|
|
|
27
27
|
options = [],
|
|
28
28
|
placeholder = "Select",
|
|
29
29
|
onClick,
|
|
30
|
-
onChange,
|
|
31
30
|
value,
|
|
32
|
-
multiple,
|
|
33
31
|
}) => {
|
|
34
32
|
const [availableOptions, setOptions] = useState(options);
|
|
35
|
-
const [flattenedOptions, setFlattenedOptions] = useState();
|
|
36
33
|
const [open, openMenu] = useState(false);
|
|
37
34
|
const [query, setQuery] = useState("");
|
|
38
35
|
|
|
@@ -58,14 +55,6 @@ export const OptionGroup = ({
|
|
|
58
55
|
);
|
|
59
56
|
};
|
|
60
57
|
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
// eslint-disable-next-line prettier/prettier
|
|
63
|
-
_.flow(
|
|
64
|
-
toFlattenedShorthands,
|
|
65
|
-
setFlattenedOptions
|
|
66
|
-
)(availableOptions);
|
|
67
|
-
}, [availableOptions]);
|
|
68
|
-
|
|
69
58
|
const flatOptionMatches = (o, searchQuery) =>
|
|
70
59
|
!_.has("options")(o) && optionMatches(lowerDeburr(searchQuery))(o);
|
|
71
60
|
|
|
@@ -87,10 +76,6 @@ export const OptionGroup = ({
|
|
|
87
76
|
onClick(values);
|
|
88
77
|
};
|
|
89
78
|
|
|
90
|
-
const onChangeOptionsGroup = (e, dropdown) => {
|
|
91
|
-
multiple && onChange(dropdown.value);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
79
|
const findText = () =>
|
|
95
80
|
_.flow(
|
|
96
81
|
_.reduce(
|
|
@@ -104,43 +89,10 @@ export const OptionGroup = ({
|
|
|
104
89
|
|
|
105
90
|
const text = value && !query && findText();
|
|
106
91
|
|
|
107
|
-
const toFlattenedShorthands = (availableOpts) =>
|
|
108
|
-
availableOpts.flatMap((option, i) => {
|
|
109
|
-
const result = _.has("options")(option)
|
|
110
|
-
? [
|
|
111
|
-
{
|
|
112
|
-
key: i,
|
|
113
|
-
children: (
|
|
114
|
-
<>
|
|
115
|
-
<Dropdown.Divider />
|
|
116
|
-
<Dropdown.Header icon={option.icon} content={option.label} />
|
|
117
|
-
</>
|
|
118
|
-
),
|
|
119
|
-
},
|
|
120
|
-
...option.options.map((innerOption, i) => ({
|
|
121
|
-
...innerOption,
|
|
122
|
-
className: "group",
|
|
123
|
-
onClick: doOnClick,
|
|
124
|
-
})),
|
|
125
|
-
]
|
|
126
|
-
: [
|
|
127
|
-
{
|
|
128
|
-
...option,
|
|
129
|
-
className: "header",
|
|
130
|
-
onClick: doOnClick,
|
|
131
|
-
},
|
|
132
|
-
];
|
|
133
|
-
return result;
|
|
134
|
-
});
|
|
135
|
-
|
|
136
92
|
return (
|
|
137
93
|
<>
|
|
138
94
|
{label && <label>{label}</label>}
|
|
139
|
-
|
|
140
95
|
<Dropdown
|
|
141
|
-
multiple={multiple}
|
|
142
|
-
options={flattenedOptions}
|
|
143
|
-
onChange={onChangeOptionsGroup}
|
|
144
96
|
fluid={fluid}
|
|
145
97
|
className="selection"
|
|
146
98
|
placeholder={placeholder}
|
|
@@ -154,21 +106,41 @@ export const OptionGroup = ({
|
|
|
154
106
|
onBlur={() => openMenu(false)}
|
|
155
107
|
text={text}
|
|
156
108
|
value={value}
|
|
157
|
-
|
|
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>
|
|
158
132
|
</>
|
|
159
133
|
);
|
|
160
134
|
};
|
|
161
135
|
|
|
162
136
|
OptionGroup.propTypes = {
|
|
163
137
|
onClick: PropTypes.func,
|
|
164
|
-
onChange: PropTypes.func,
|
|
165
138
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
166
139
|
fluid: PropTypes.bool,
|
|
167
140
|
inline: PropTypes.bool,
|
|
168
141
|
label: PropTypes.string,
|
|
169
142
|
placeholder: PropTypes.string,
|
|
170
143
|
options: PropTypes.array,
|
|
171
|
-
multiple: PropTypes.bool,
|
|
172
144
|
};
|
|
173
145
|
|
|
174
146
|
export default OptionGroup;
|
|
@@ -13,7 +13,6 @@ exports[`<OptionGroup /> matches the latest snapshot 1`] = `
|
|
|
13
13
|
minCharacters={1}
|
|
14
14
|
noResultsMessage="No results found."
|
|
15
15
|
onBlur={[Function]}
|
|
16
|
-
onChange={[Function]}
|
|
17
16
|
onClick={[Function]}
|
|
18
17
|
onSearchChange={[Function]}
|
|
19
18
|
open={false}
|
|
@@ -26,6 +25,8 @@ exports[`<OptionGroup /> matches the latest snapshot 1`] = `
|
|
|
26
25
|
selectOnBlur={true}
|
|
27
26
|
selectOnNavigation={true}
|
|
28
27
|
wrapSelection={true}
|
|
29
|
-
|
|
28
|
+
>
|
|
29
|
+
<DropdownMenu />
|
|
30
|
+
</Dropdown>
|
|
30
31
|
</Fragment>
|
|
31
32
|
`;
|