@truedat/core 4.46.4 → 4.46.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,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.46.5] 2022-06-17
4
+
5
+ ### Added
6
+
7
+ - [TD-4894] Multiple column operator in implementation creation
8
+
3
9
  ## [4.46.4] 2022-06-16
4
10
 
5
11
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "4.46.4",
3
+ "version": "4.46.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.46.4",
38
+ "@truedat/test": "4.46.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": "dcd0aa42ffe1fb816945154ec2a2d06889dca7e7"
115
+ "gitHead": "cc6e42515345adf2926f47216622e0fc4f7a0d86"
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,9 +27,12 @@ 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
 
@@ -55,6 +58,14 @@ export const OptionGroup = ({
55
58
  );
56
59
  };
57
60
 
61
+ useEffect(() => {
62
+ // eslint-disable-next-line prettier/prettier
63
+ _.flow(
64
+ toFlattenedShorthands,
65
+ setFlattenedOptions
66
+ )(availableOptions);
67
+ }, [availableOptions]);
68
+
58
69
  const flatOptionMatches = (o, searchQuery) =>
59
70
  !_.has("options")(o) && optionMatches(lowerDeburr(searchQuery))(o);
60
71
 
@@ -76,6 +87,10 @@ export const OptionGroup = ({
76
87
  onClick(values);
77
88
  };
78
89
 
90
+ const onChangeOptionsGroup = (e, dropdown) => {
91
+ multiple && onChange(dropdown.value);
92
+ };
93
+
79
94
  const findText = () =>
80
95
  _.flow(
81
96
  _.reduce(
@@ -89,10 +104,43 @@ export const OptionGroup = ({
89
104
 
90
105
  const text = value && !query && findText();
91
106
 
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
+
92
136
  return (
93
137
  <>
94
138
  {label && <label>{label}</label>}
139
+
95
140
  <Dropdown
141
+ multiple={multiple}
142
+ options={flattenedOptions}
143
+ onChange={onChangeOptionsGroup}
96
144
  fluid={fluid}
97
145
  className="selection"
98
146
  placeholder={placeholder}
@@ -106,41 +154,21 @@ export const OptionGroup = ({
106
154
  onBlur={() => openMenu(false)}
107
155
  text={text}
108
156
  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>
157
+ />
132
158
  </>
133
159
  );
134
160
  };
135
161
 
136
162
  OptionGroup.propTypes = {
137
163
  onClick: PropTypes.func,
164
+ onChange: PropTypes.func,
138
165
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
139
166
  fluid: PropTypes.bool,
140
167
  inline: PropTypes.bool,
141
168
  label: PropTypes.string,
142
169
  placeholder: PropTypes.string,
143
170
  options: PropTypes.array,
171
+ multiple: PropTypes.bool,
144
172
  };
145
173
 
146
174
  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
  `;