orc-shared 5.7.0-dev.7 → 5.7.0-dev.8

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.
@@ -7,6 +7,7 @@ var _filterHelper = require("../../../utils/filterHelper");
7
7
  var _metadata = require("../../../selectors/metadata");
8
8
  var _localizationHelper = require("../../../utils/localizationHelper");
9
9
  var _createInput = _interopRequireWildcard(require("./createInput"));
10
+ var _excluded = ["moduleName", "lookupName", "value", "onChange", "disabled", "metadata"];
10
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
11
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
13
  (function () {
@@ -17,6 +18,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
17
18
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
18
19
  enterModule && enterModule(module);
19
20
  })();
21
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
23
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
21
24
  return a;
22
25
  };
@@ -29,7 +32,8 @@ var LookupSelect = function LookupSelect(_ref) {
29
32
  value = _ref.value,
30
33
  onChange = _ref.onChange,
31
34
  disabled = _ref.disabled,
32
- metadata = _ref.metadata;
35
+ metadata = _ref.metadata,
36
+ props = _objectWithoutProperties(_ref, _excluded);
33
37
  var options = (0, _filterHelper.extractDropboxOptions)((0, _reactRedux.useSelector)((0, _metadata.namedLookupValuesSelector)(moduleName, lookupName)));
34
38
  if (value !== null && !options.some(function (x) {
35
39
  return x.value === value;
@@ -40,13 +44,18 @@ var LookupSelect = function LookupSelect(_ref) {
40
44
  sortOrder: 0
41
45
  });
42
46
  }
47
+ var inputProps = {};
48
+ if (props != null && props["data-qa"]) {
49
+ inputProps["data-qa"] = props["data-qa"];
50
+ }
43
51
  return (0, _createInput.default)(_createInput.inputTypes.select, {
44
52
  options: options,
45
53
  value: value,
46
54
  update: function update(newValue) {
47
55
  return onChange(newValue, metadata);
48
56
  },
49
- disabled: disabled
57
+ disabled: disabled,
58
+ inputProps: inputProps
50
59
  });
51
60
  };
52
61
  __signature__(LookupSelect, "useSelector{}", function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "5.7.0-dev.7",
3
+ "version": "5.7.0-dev.8",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -4,7 +4,7 @@ import { namedLookupValuesSelector } from "../../../selectors/metadata";
4
4
  import { getNotLocalizedString } from "../../../utils/localizationHelper";
5
5
  import createInput, { inputTypes } from "./createInput";
6
6
 
7
- const LookupSelect = ({ moduleName, lookupName, value, onChange, disabled, metadata }) => {
7
+ const LookupSelect = ({ moduleName, lookupName, value, onChange, disabled, metadata, ...props }) => {
8
8
  const options = extractDropboxOptions(useSelector(namedLookupValuesSelector(moduleName, lookupName)));
9
9
 
10
10
  if (value !== null && !options.some(x => x.value === value)) {
@@ -15,11 +15,18 @@ const LookupSelect = ({ moduleName, lookupName, value, onChange, disabled, metad
15
15
  });
16
16
  }
17
17
 
18
+ const inputProps = {};
19
+
20
+ if (props?.["data-qa"]) {
21
+ inputProps["data-qa"] = props["data-qa"];
22
+ }
23
+
18
24
  return createInput(inputTypes.select, {
19
25
  options: options,
20
26
  value: value,
21
27
  update: newValue => onChange(newValue, metadata),
22
28
  disabled: disabled,
29
+ inputProps: inputProps,
23
30
  });
24
31
  };
25
32
 
@@ -210,4 +210,25 @@ describe("LookupSelect Component", () => {
210
210
 
211
211
  expect(update, "to have calls satisfying", [{ args: ["CanceledReason2", { a: 123 }] }]);
212
212
  });
213
+
214
+ it("LookupSelect component with data-qa", () => {
215
+ const update = sinon.spy().named("update");
216
+ const component = (
217
+ <TestWrapper provider={{ store }} stylesProvider muiThemeProvider={{ theme }}>
218
+ <LookupSelect
219
+ moduleName={"order"}
220
+ lookupName={"CanceledStatusReasons"}
221
+ value={"CanceledReason3"}
222
+ onChange={update}
223
+ metadata={{ a: 123 }}
224
+ data-qa="custom-value"
225
+ />
226
+ </TestWrapper>
227
+ );
228
+
229
+ const mountedComponent = mount(component);
230
+
231
+ const controls = mountedComponent.find("[data-qa='custom-value']").hostNodes();
232
+ expect(controls.length, "to equal", 1);
233
+ });
213
234
  });