orc-shared 1.5.0-dev.11 → 1.5.0-dev.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.
@@ -24,6 +24,7 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
24
24
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
25
25
  return a;
26
26
  };
27
+ /* istanbul ignore file */
27
28
  var acquireEntityLockRequest = {
28
29
  name: "acquireEntityLockRequest",
29
30
  buildUrl: function buildUrl(scopeId, entity, entityId) {
@@ -35,6 +35,12 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
35
35
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
36
36
  return a;
37
37
  };
38
+ /*
39
+ Multiple lists with a single header, aligned with each other
40
+ No virtualization or page loading
41
+ Categories can be folded up to hide content
42
+ Sortable, within categories
43
+ */
38
44
  var arrayToggle = function arrayToggle(array, item) {
39
45
  return array.includes(item) ? array.filter(function (x) {
40
46
  return x !== item;
@@ -21,6 +21,7 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
21
21
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
22
22
  return a;
23
23
  };
24
+ /* eslint-disable react/style-prop-object */
24
25
  var useStyles = (0, _styles.makeStyles)(function (theme) {
25
26
  return {
26
27
  regular: {
@@ -182,7 +182,9 @@ var SearchControl = function SearchControl(_ref) {
182
182
  searchOption = _ref.searchOption,
183
183
  _ref$onSearch = _ref.onSearch,
184
184
  onSearch = _ref$onSearch === void 0 ? function () {} : _ref$onSearch,
185
- disabled = _ref.disabled;
185
+ disabled = _ref.disabled,
186
+ _ref$focusAndSelectSe = _ref.focusAndSelectSearchFieldOnLoad,
187
+ focusAndSelectSearchFieldOnLoad = _ref$focusAndSelectSe === void 0 ? true : _ref$focusAndSelectSe;
186
188
  searchOptions = !((_searchOptions = searchOptions) != null && _searchOptions.length) ? null : searchOptions;
187
189
  searchOption = getSearchOptionValue(searchOptions, searchOption);
188
190
  var _useState = (0, _react.useState)(false),
@@ -223,6 +225,13 @@ var SearchControl = function SearchControl(_ref) {
223
225
  event.preventDefault();
224
226
  event.stopPropagation();
225
227
  };
228
+ (0, _react.useEffect)(function () {
229
+ if (focusAndSelectSearchFieldOnLoad && inputRef.current) {
230
+ inputRef.current.focus();
231
+ inputRef.current.select();
232
+ setInputFocused(true);
233
+ }
234
+ }, [focusAndSelectSearchFieldOnLoad]);
226
235
  var SelectSection = function SelectSection() {
227
236
  if (searchOptions === null) return null;else return /*#__PURE__*/_react.default.createElement(_Select.default, {
228
237
  className: classes.selectInput,
@@ -287,10 +296,10 @@ var SearchControl = function SearchControl(_ref) {
287
296
  className: classes.container
288
297
  }, /*#__PURE__*/_react.default.createElement(SelectSection, null), inputSection, searchSection);
289
298
  };
290
- __signature__(SearchControl, "useState{[inputFocused, setInputFocused](false)}\nuseStyles{classes}\nuseRef{inputRef}", function () {
299
+ __signature__(SearchControl, "useState{[inputFocused, setInputFocused](false)}\nuseStyles{classes}\nuseRef{inputRef}\nuseEffect{}", function () {
291
300
  return [useStyles];
292
301
  });
293
- __signature__(SearchControl, "useState{[inputFocused, setInputFocused](false)}\nuseStyles{classes}\nuseRef{inputRef}", function () {
302
+ __signature__(SearchControl, "useState{[inputFocused, setInputFocused](false)}\nuseStyles{classes}\nuseRef{inputRef}\nuseEffect{}", function () {
294
303
  return [useStyles];
295
304
  });
296
305
  var _default = SearchControl;
@@ -35,7 +35,6 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
35
35
  // Pay attention that if component you are passed to this HOC contains titleValue property
36
36
  // by itself then that property will be disappeared after using that HOC.
37
37
  // To fix it rename that property and pass titleValue just as a title for tooltip.
38
-
39
38
  var withDeferredTooltip = function withDeferredTooltip(Comp) {
40
39
  return __signature__(__signature__(function (_ref) {
41
40
  var titleValue = _ref.titleValue,
@@ -26,7 +26,6 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
26
26
  // Scope concern: Changing scope means subpages may no longer be valid.
27
27
  // Grey out other-scoped tabs, change scope when opened?
28
28
  // Warn when changing scopes, close out-scope tabs?
29
-
30
29
  var Navigation = (0, _withErrorBoundary.default)("Navigation")(__signature__(__signature__(function (_ref) {
31
30
  var modules = _ref.modules;
32
31
  return /*#__PURE__*/_react.default.createElement(_TabBar.default, (0, _useNavigationState.useNavigationState)(modules));
@@ -27,7 +27,7 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
27
27
  };
28
28
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
29
29
  return a;
30
- };
30
+ }; // HOC that sets the currently matched route of a component in state, including params
31
31
  var withWaypointing = function withWaypointing(Comp, isVisible, componentProps) {
32
32
  if (isVisible === void 0) {
33
33
  isVisible = true;
@@ -8,6 +8,7 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
8
8
  var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
9
9
  return a;
10
10
  };
11
+ /* istanbul ignore file */
11
12
  // If you want to investigate rerenderer of components, import that file before "react-hot-loader", usually in App.js
12
13
  if (process.env.NODE_ENV === "development") {
13
14
  var whyDidYouRender = require("@welldone-software/why-did-you-render");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "1.5.0-dev.11",
3
+ "version": "1.5.0-dev.12",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -1,4 +1,4 @@
1
- import React, { useState, useRef } from "react";
1
+ import React, { useState, useRef, useEffect } from "react";
2
2
  import { makeStyles } from "@material-ui/core/styles";
3
3
  import SelectProps from "../SelectProps";
4
4
  import Icon from "../../DataDisplay/Icon";
@@ -149,6 +149,7 @@ const SearchControl = ({
149
149
  searchOption,
150
150
  onSearch = () => {},
151
151
  disabled,
152
+ focusAndSelectSearchFieldOnLoad = true,
152
153
  }) => {
153
154
  searchOptions = !searchOptions?.length ? null : searchOptions;
154
155
  searchOption = getSearchOptionValue(searchOptions, searchOption);
@@ -192,6 +193,14 @@ const SearchControl = ({
192
193
  event.stopPropagation();
193
194
  };
194
195
 
196
+ useEffect(() => {
197
+ if (focusAndSelectSearchFieldOnLoad && inputRef.current) {
198
+ inputRef.current.focus();
199
+ inputRef.current.select();
200
+ setInputFocused(true);
201
+ }
202
+ }, [focusAndSelectSearchFieldOnLoad]);
203
+
195
204
  const SelectSection = () => {
196
205
  if (searchOptions === null) return null;
197
206
  else return <Select className={classes.selectInput} options={searchOptions} selectProps={selectProps} />;
@@ -408,7 +408,7 @@ describe("SearchControl Component", () => {
408
408
 
409
409
  const component = (
410
410
  <TestWrapper stylesProvider muiThemeProvider={{ theme }}>
411
- <SearchControl placeholder="placeHolderTest" searchOptions={options} />
411
+ <SearchControl placeholder="placeHolderTest" searchOptions={options} focusAndSelectSearchFieldOnLoad={false} />
412
412
  </TestWrapper>
413
413
  );
414
414
 
@@ -484,6 +484,46 @@ describe("SearchControl Component", () => {
484
484
 
485
485
  expect(component, "when mounted", "to satisfy", expected);
486
486
  });
487
+
488
+ it("focusAndSelectSearchFieldOnLoad set to true gives focus to control", () => {
489
+ jest.spyOn(React, "useState").mockImplementation(useStateMock);
490
+
491
+ const options = [
492
+ { value: "aValue", label: "aLabel" },
493
+ { value: "anotherValue", label: "anotherLabel" },
494
+ ];
495
+
496
+ const component = (
497
+ <TestWrapper stylesProvider muiThemeProvider={{ theme }}>
498
+ <SearchControl placeholder="placeHolderTest" searchOptions={options} focusAndSelectSearchFieldOnLoad={true} />
499
+ </TestWrapper>
500
+ );
501
+
502
+ const mountedComponent = mount(component);
503
+ const searchEditParent = mountedComponent.find('[data-qa="searchInput"]');
504
+
505
+ expect(searchEditParent.props()["data-qa-is-focused"], "to be", true);
506
+ });
507
+
508
+ it("focusAndSelectSearchFieldOnLoad set to false does not give focus to control", () => {
509
+ jest.spyOn(React, "useState").mockImplementation(useStateMock);
510
+
511
+ const options = [
512
+ { value: "aValue", label: "aLabel" },
513
+ { value: "anotherValue", label: "anotherLabel" },
514
+ ];
515
+
516
+ const component = (
517
+ <TestWrapper stylesProvider muiThemeProvider={{ theme }}>
518
+ <SearchControl placeholder="placeHolderTest" searchOptions={options} focusAndSelectSearchFieldOnLoad={false} />
519
+ </TestWrapper>
520
+ );
521
+
522
+ const mountedComponent = mount(component);
523
+ const searchEditParent = mountedComponent.find('[data-qa="searchInput"]');
524
+
525
+ expect(searchEditParent.props()["data-qa-is-focused"], "to be", false);
526
+ });
487
527
  });
488
528
 
489
529
  describe("getSearchOptionValue function", () => {