@elliemae/ds-search-field 2.3.0-next.3 → 3.0.0-alpha.0

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.
Files changed (50) hide show
  1. package/dist/cjs/DSSearchField.js +133 -0
  2. package/dist/cjs/DSSearchField.js.map +7 -0
  3. package/dist/cjs/impl/DSSeachFieldImpl.js +212 -0
  4. package/dist/cjs/impl/DSSeachFieldImpl.js.map +7 -0
  5. package/dist/cjs/impl/components/AdvanceSearchOption/AdvanceSearchOption.js +44 -0
  6. package/dist/cjs/impl/components/AdvanceSearchOption/AdvanceSearchOption.js.map +7 -0
  7. package/dist/cjs/impl/components/LookupIndicator/LookupIndicator.js +50 -0
  8. package/dist/cjs/impl/components/LookupIndicator/LookupIndicator.js.map +7 -0
  9. package/dist/cjs/impl/components/ModalSearchField/DataGridSearch.js +107 -0
  10. package/dist/cjs/impl/components/ModalSearchField/DataGridSearch.js.map +7 -0
  11. package/dist/cjs/impl/components/ModalSearchField/ModalSearchField.js +94 -0
  12. package/dist/cjs/impl/components/ModalSearchField/ModalSearchField.js.map +7 -0
  13. package/dist/cjs/index.js +37 -0
  14. package/dist/cjs/index.js.map +7 -0
  15. package/dist/esm/DSSearchField.js +104 -0
  16. package/dist/esm/DSSearchField.js.map +7 -0
  17. package/dist/esm/impl/DSSeachFieldImpl.js +183 -0
  18. package/dist/esm/impl/DSSeachFieldImpl.js.map +7 -0
  19. package/dist/esm/impl/components/AdvanceSearchOption/AdvanceSearchOption.js +15 -0
  20. package/dist/esm/impl/components/AdvanceSearchOption/AdvanceSearchOption.js.map +7 -0
  21. package/dist/esm/impl/components/LookupIndicator/LookupIndicator.js +21 -0
  22. package/dist/esm/impl/components/LookupIndicator/LookupIndicator.js.map +7 -0
  23. package/dist/esm/impl/components/ModalSearchField/DataGridSearch.js +78 -0
  24. package/dist/esm/impl/components/ModalSearchField/DataGridSearch.js.map +7 -0
  25. package/dist/esm/impl/components/ModalSearchField/ModalSearchField.js +65 -0
  26. package/dist/esm/impl/components/ModalSearchField/ModalSearchField.js.map +7 -0
  27. package/dist/esm/index.js +12 -0
  28. package/dist/esm/index.js.map +7 -0
  29. package/{types → dist/types}/DSSearchField.d.ts +0 -0
  30. package/{types → dist/types}/impl/DSSeachFieldImpl.d.ts +0 -0
  31. package/{types → dist/types}/impl/components/AdvanceSearchOption/AdvanceSearchOption.d.ts +0 -0
  32. package/{types → dist/types}/impl/components/LookupIndicator/LookupIndicator.d.ts +0 -0
  33. package/{types → dist/types}/impl/components/ModalSearchField/DataGridSearch.d.ts +0 -0
  34. package/{types → dist/types}/impl/components/ModalSearchField/ModalSearchField.d.ts +0 -0
  35. package/{types → dist/types}/index.d.ts +0 -0
  36. package/package.json +44 -36
  37. package/cjs/DSSearchField.js +0 -169
  38. package/cjs/impl/DSSeachFieldImpl.js +0 -243
  39. package/cjs/impl/components/AdvanceSearchOption/AdvanceSearchOption.js +0 -26
  40. package/cjs/impl/components/LookupIndicator/LookupIndicator.js +0 -34
  41. package/cjs/impl/components/ModalSearchField/DataGridSearch.js +0 -117
  42. package/cjs/impl/components/ModalSearchField/ModalSearchField.js +0 -83
  43. package/cjs/index.js +0 -12
  44. package/esm/DSSearchField.js +0 -159
  45. package/esm/impl/DSSeachFieldImpl.js +0 -234
  46. package/esm/impl/components/AdvanceSearchOption/AdvanceSearchOption.js +0 -19
  47. package/esm/impl/components/LookupIndicator/LookupIndicator.js +0 -27
  48. package/esm/impl/components/ModalSearchField/DataGridSearch.js +0 -108
  49. package/esm/impl/components/ModalSearchField/ModalSearchField.js +0 -76
  50. package/esm/index.js +0 -2
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- var _jsx = require('@babel/runtime/helpers/jsx');
4
- require('react');
5
- var DSButton = require('@elliemae/ds-button');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
10
- var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
11
-
12
- const AdvanceSearchOption = _ref => {
13
- let {
14
- advanceSearchLabel = 'Advanced Search',
15
- onAdvanceSearchClick = () => null
16
- } = _ref;
17
- return /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
18
- className: "advance-search-option-btn",
19
- labelText: advanceSearchLabel,
20
- onClick: onAdvanceSearchClick,
21
- tabIndex: -1,
22
- type: "button"
23
- });
24
- };
25
-
26
- module.exports = AdvanceSearchOption;
@@ -1,34 +0,0 @@
1
- 'use strict';
2
-
3
- var _jsx = require('@babel/runtime/helpers/jsx');
4
- require('react');
5
- var dsIcons = require('@elliemae/ds-icons');
6
- var DSButton = require('@elliemae/ds-button');
7
-
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
11
- var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
12
-
13
- var _Search;
14
-
15
- const LookupIndicator = _ref => {
16
- let {
17
- onAdvanceSearchClick = () => null,
18
- className = ''
19
- } = _ref;
20
- return /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
21
- "data-testid": "ds-searchfield-search-btn",
22
- buttonType: "secondary",
23
- className: className,
24
- icon: _Search || (_Search = /*#__PURE__*/_jsx__default["default"](dsIcons.Search, {})),
25
- iconSize: "s",
26
- onClick: e => {
27
- e.stopPropagation();
28
- e.preventDefault();
29
- onAdvanceSearchClick();
30
- }
31
- });
32
- };
33
-
34
- module.exports = LookupIndicator;
@@ -1,117 +0,0 @@
1
- 'use strict';
2
-
3
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
- var _jsx = require('@babel/runtime/helpers/jsx');
5
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
6
- require('core-js/modules/web.dom-collections.iterator.js');
7
- require('core-js/modules/esnext.async-iterator.filter.js');
8
- require('core-js/modules/esnext.iterator.constructor.js');
9
- require('core-js/modules/esnext.iterator.filter.js');
10
- require('core-js/modules/esnext.async-iterator.for-each.js');
11
- require('core-js/modules/esnext.iterator.for-each.js');
12
- var react = require('react');
13
- var DSToolbar = require('@elliemae/ds-toolbar');
14
- var dsForm = require('@elliemae/ds-form');
15
- var dsDatagrids = require('@elliemae/ds-datagrids');
16
- var uid = require('uid');
17
- var jsxRuntime = require('react/jsx-runtime');
18
-
19
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
-
21
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
22
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
23
- var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
24
- var DSToolbar__default = /*#__PURE__*/_interopDefaultLegacy(DSToolbar);
25
-
26
- const _excluded = ["onFiltersChange"];
27
-
28
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
29
-
30
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
31
- class DataGridSearch extends react.Component {
32
- constructor(props) {
33
- super(props);
34
- this.state = {
35
- filters: props.filters || []
36
- };
37
- this.handleSearch = this.handleSearch.bind(this);
38
- this.handleFiltersChange = this.handleFiltersChange.bind(this);
39
- }
40
-
41
- handleSearch() {
42
- const {
43
- customDataGridOptions
44
- } = this.props;
45
- const {
46
- property,
47
- value
48
- } = arguments.length <= 0 ? undefined : arguments[0];
49
- const {
50
- filters
51
- } = this.state;
52
- this.setState({
53
- filters: [...filters, {
54
- group: property,
55
- label: 'All',
56
- value,
57
- id: uid.uid(16)
58
- }]
59
- });
60
- if (customDataGridOptions.onFiltersChange) customDataGridOptions.onFiltersChange(...arguments);
61
- }
62
-
63
- handleFiltersChange(nextFilters) {
64
- const {
65
- customDataGridOptions
66
- } = this.props;
67
- this.setState({
68
- filters: nextFilters
69
- });
70
- if (customDataGridOptions.onFiltersChange) customDataGridOptions.onFiltersChange(nextFilters);
71
- }
72
-
73
- render() {
74
- const {
75
- id,
76
- rows,
77
- columns,
78
- boundFetchRows,
79
- searchFilters,
80
- searchGrid = true,
81
- customDataGridOptions,
82
- handleSelect
83
- } = this.props;
84
-
85
- const restCustomDataGridOptions = _objectWithoutProperties__default["default"](customDataGridOptions, _excluded);
86
-
87
- const {
88
- filters
89
- } = this.state;
90
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
91
- children: [/*#__PURE__*/_jsx__default["default"](DSToolbar__default["default"], {
92
- withDepth: false
93
- }, void 0, /*#__PURE__*/_jsx__default["default"](DSToolbar.ToolbarGroup, {}, void 0, /*#__PURE__*/_jsx__default["default"](dsForm.DSSearchBox, {
94
- cleanOnSearch: true,
95
- onSearch: this.handleSearch,
96
- placeholder: "Search all"
97
- }))), /*#__PURE__*/_jsx__default["default"]("div", {
98
- className: "datagrid-tab-content"
99
- }, void 0, /*#__PURE__*/jsxRuntime.jsx(dsDatagrids.DSDataGrid, _objectSpread({
100
- columns: columns,
101
- filters: filters,
102
- fluidHeight: true,
103
- getData: boundFetchRows,
104
- id: id,
105
- onFiltersChange: this.handleFiltersChange,
106
- onSelectRow: rowId => handleSelect(rowId, rows),
107
- rows: rows,
108
- searchFilters: searchFilters,
109
- searchGrid: searchGrid,
110
- selectable: true
111
- }, restCustomDataGridOptions)))]
112
- });
113
- }
114
-
115
- }
116
-
117
- module.exports = DataGridSearch;
@@ -1,83 +0,0 @@
1
- 'use strict';
2
-
3
- var _jsx = require('@babel/runtime/helpers/jsx');
4
- require('core-js/modules/esnext.async-iterator.map.js');
5
- require('core-js/modules/esnext.iterator.map.js');
6
- require('react');
7
- var DSModal = require('@elliemae/ds-modal');
8
- var dsTabs = require('@elliemae/ds-tabs');
9
- var DataGridSearch = require('./DataGridSearch.js');
10
-
11
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
-
13
- var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
14
- var DSModal__default = /*#__PURE__*/_interopDefaultLegacy(DSModal);
15
-
16
- const ModalSearchField = _ref => {
17
- let {
18
- isOpen = false,
19
- onClose = () => null,
20
- modalTitle = 'Search Field ID',
21
- modalSize = 'x-large',
22
- tabsAnimated = true,
23
- tabsEnableMouseEvents = true,
24
- tabType = dsTabs.TabTypes.NORMAL,
25
- tabData = [],
26
- searchFilters = true,
27
- searchGrid = false,
28
- confirmLabel = 'Apply',
29
- rejectLabel = 'Cancel',
30
- modalType = 'confirm',
31
- onConfirmField = () => null,
32
- onRejectField = () => null,
33
- handleSelect = () => null,
34
- onTabChange = () => null,
35
- appElement = null,
36
- customDataGridOptions = {}
37
- } = _ref;
38
- return /*#__PURE__*/_jsx__default["default"](DSModal__default["default"], {
39
- dataTestId: "ds-searchfield-modal",
40
- appElement: appElement,
41
- centered: false,
42
- className: "modal-search-field",
43
- confirmLabel: confirmLabel,
44
- isOpen: isOpen,
45
- modalTitle: modalTitle,
46
- modalType: modalType,
47
- onClose: onClose,
48
- onConfirm: onConfirmField,
49
- onReject: onRejectField,
50
- rejectLabel: rejectLabel,
51
- size: modalSize
52
- }, void 0, tabData.length > 0 && /*#__PURE__*/_jsx__default["default"](dsTabs.DSTabs, {
53
- animated: tabsAnimated,
54
- enableMouseEvents: tabsEnableMouseEvents,
55
- onlyRenderActiveTab: true,
56
- onTabChange: onTabChange,
57
- type: tabType
58
- }, void 0, tabData.map(_ref2 => {
59
- let {
60
- tabId,
61
- tabTitle,
62
- columns,
63
- rows,
64
- boundFetchRows
65
- } = _ref2;
66
- return /*#__PURE__*/_jsx__default["default"](dsTabs.DSTab, {
67
- className: "tab-content",
68
- tabId: tabId,
69
- title: tabTitle
70
- }, tabId, /*#__PURE__*/_jsx__default["default"](DataGridSearch, {
71
- boundFetchRows: boundFetchRows,
72
- columns: columns,
73
- customDataGridOptions: customDataGridOptions,
74
- handleSelect: handleSelect,
75
- id: "datagrid_search_field_".concat(tabId),
76
- rows: rows,
77
- searchFilters: searchFilters,
78
- searchGrid: searchGrid
79
- }));
80
- })));
81
- };
82
-
83
- module.exports = ModalSearchField;
package/cjs/index.js DELETED
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var DSSearchField = require('./DSSearchField.js');
6
- var ModalSearchField = require('./impl/components/ModalSearchField/ModalSearchField.js');
7
-
8
-
9
-
10
- exports.DSSearchFieldWithSchema = DSSearchField.DSSearchFieldWithSchema;
11
- exports["default"] = DSSearchField["default"];
12
- exports.DSModalSearchField = ModalSearchField;
@@ -1,159 +0,0 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import 'react';
3
- import { PropTypes, describe } from 'react-desc';
4
- import { TabTypes } from '@elliemae/ds-tabs';
5
- import DSSearchFieldImpl from './impl/DSSeachFieldImpl.js';
6
- export { default as DSModalSearchField } from './impl/components/ModalSearchField/ModalSearchField.js';
7
-
8
- const DSSearchField = _ref => {
9
- let {
10
- containerProps = {},
11
- onChange = () => null,
12
- searchOptionLabel = 'Advanced Search',
13
- placeholder = 'Select field',
14
- modalSize = 'x-large',
15
- modalTitle = 'Search Field ID',
16
- tabsAnimated = true,
17
- tabsEnableMouseEvents = true,
18
- tabType = TabTypes.NORMAL,
19
- tabData = [],
20
- searchGrid = false,
21
- searchFilters = true,
22
- confirmLabel = 'Apply',
23
- rejectLabel = 'Cancel',
24
- modalType = 'confirm',
25
- onConfirmField = () => null,
26
- onRejectField = () => null,
27
- onTabChange = () => null,
28
- appElement = '#root',
29
- value = null,
30
- additionalInfo = null,
31
- displayProperty = 'name',
32
- dropdownOptions = [],
33
- customDataGridOptions = {},
34
- customDropdownOptions = {},
35
- useLookupIndicator = true,
36
- searchable = false
37
- } = _ref;
38
- return /*#__PURE__*/_jsx(DSSearchFieldImpl, {
39
- additionalInfo: additionalInfo,
40
- appElement: appElement,
41
- searchable: searchable,
42
- confirmLabel: confirmLabel,
43
- containerProps: containerProps,
44
- customDataGridOptions: customDataGridOptions,
45
- customDropdownOptions: customDropdownOptions,
46
- displayProperty: displayProperty,
47
- dropdownOptions: dropdownOptions,
48
- modalSize: modalSize,
49
- modalTitle: modalTitle,
50
- modalType: modalType,
51
- onChange: onChange,
52
- onConfirmField: onConfirmField,
53
- onRejectField: onRejectField,
54
- onTabChange: onTabChange,
55
- placeholder: placeholder,
56
- rejectLabel: rejectLabel,
57
- searchFilters: searchFilters,
58
- searchGrid: searchGrid,
59
- searchOptionLabel: searchOptionLabel,
60
- tabData: tabData,
61
- tabsAnimated: tabsAnimated,
62
- tabsEnableMouseEvents: tabsEnableMouseEvents,
63
- tabType: tabType,
64
- useLookupIndicator: useLookupIndicator,
65
- value: value
66
- });
67
- };
68
-
69
- const props = {
70
- /*
71
- Enable the user to search on combobox
72
- */
73
- searchable: PropTypes.bool.description('Enable the user to search on combobox'),
74
-
75
- /** inject props to wrapper */
76
- containerProps: PropTypes.object.description('inject props to wrapper'),
77
-
78
- /** change handler */
79
- onChange: PropTypes.func.description('change handler'),
80
-
81
- /** search option label */
82
- searchOptionLabel: PropTypes.string.description('search option label'),
83
-
84
- /** placeholder for search input */
85
- placeholder: PropTypes.string.description('placeholder for search input'),
86
-
87
- /** search modal size */
88
- modalSize: PropTypes.oneOf(['x-large', 'large', 'medium']).description('search modal size'),
89
-
90
- /** search modal title */
91
- modalTitle: PropTypes.string.description('search modal title'),
92
-
93
- /** animate modal tabs */
94
- tabsAnimated: PropTypes.bool.description('animate modal tabs'),
95
-
96
- /** enable mouse event on tabs */
97
- tabsEnableMouseEvents: PropTypes.bool.description('enable mouse event on tabs'),
98
-
99
- /** tab types on modal */
100
- tabType: PropTypes.oneOf([TabTypes.NORMAL, TabTypes.SUBTABS]).description('tab types on modal'),
101
-
102
- /** data for modal tabs */
103
- tabData: PropTypes.array.description('data for modal tabs'),
104
-
105
- /** use search grid */
106
- searchGrid: PropTypes.bool.description('use search grid'),
107
-
108
- /** add search filters */
109
- searchFilters: PropTypes.bool.description('add search filters'),
110
-
111
- /** confirm modal label */
112
- confirmLabel: PropTypes.string.description('confirm modal label'),
113
-
114
- /** reject modal label */
115
- rejectLabel: PropTypes.string.description('reject modal label'),
116
-
117
- /** modal type */
118
- modalType: PropTypes.oneOf(['alert', 'confirm']).description('modal type'),
119
-
120
- /** on confirm handler */
121
- onConfirmField: PropTypes.func.description('on confirm handler'),
122
-
123
- /** on cancel handler */
124
- onRejectField: PropTypes.func.description('on cancel handler'),
125
-
126
- /** tab change handler */
127
- onTabChange: PropTypes.func.description('tab change handler'),
128
-
129
- /** app element */
130
- appElement: PropTypes.string.description('app element'),
131
-
132
- /** value for search */
133
- value: PropTypes.string.description('value for search'),
134
-
135
- /** additional info */
136
- additionalInfo: PropTypes.object.description('additional info'),
137
-
138
- /** display property */
139
- displayProperty: PropTypes.string.description('display property'),
140
-
141
- /** options for dropdown */
142
- dropdownOptions: PropTypes.arrayOf(PropTypes.shape({
143
- label: PropTypes.string,
144
- value: PropTypes.string
145
- })).description('options for dropdown'),
146
-
147
- /** pass down props for datagrid in modal */
148
- customDataGridOptions: PropTypes.object.description('pass down props for datagrid in modal'),
149
-
150
- /** custom props for dropdown */
151
- customDropdownOptions: PropTypes.object.description('custom props for dropdown'),
152
-
153
- /** enable lookup */
154
- useLookupIndicator: PropTypes.bool.description('enable lookup')
155
- };
156
- const DSSearchFieldWithSchema = describe(DSSearchField);
157
- DSSearchFieldWithSchema.propTypes = props;
158
-
159
- export { DSSearchFieldWithSchema, DSSearchField as default };
@@ -1,234 +0,0 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
3
- import 'core-js/modules/web.dom-collections.iterator.js';
4
- import 'core-js/modules/esnext.async-iterator.find.js';
5
- import 'core-js/modules/esnext.iterator.constructor.js';
6
- import 'core-js/modules/esnext.iterator.find.js';
7
- import 'core-js/modules/esnext.async-iterator.filter.js';
8
- import 'core-js/modules/esnext.iterator.filter.js';
9
- import 'core-js/modules/esnext.async-iterator.for-each.js';
10
- import 'core-js/modules/esnext.iterator.for-each.js';
11
- import { Component } from 'react';
12
- import { components } from 'react-select';
13
- import { convertPropToCssClassName } from '@elliemae/ds-classnames';
14
- import { DSComboBox2 } from '@elliemae/ds-form';
15
- import ModalSearchField from './components/ModalSearchField/ModalSearchField.js';
16
- export { default as DSModalSearchField } from './components/ModalSearchField/ModalSearchField.js';
17
- import AdvanceSearchOption from './components/AdvanceSearchOption/AdvanceSearchOption.js';
18
- import LookupIndicator from './components/LookupIndicator/LookupIndicator.js';
19
- import { jsxs, jsx } from 'react/jsx-runtime';
20
-
21
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22
-
23
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
- const advanceOption = {
25
- className: 'advanced-search-option',
26
- label: 'Advanced search',
27
- value: 'search-field-advance-option',
28
- isAdvance: true
29
- };
30
- const {
31
- cssClassName,
32
- classNameElement,
33
- classNameModifier,
34
- classNameBlock
35
- } = convertPropToCssClassName('query-builder-addon-search-field');
36
-
37
- class DSSearchFieldImpl extends Component {
38
- constructor(props) {
39
- super(props);
40
-
41
- this.onChange = () => {
42
- const {
43
- selected: id,
44
- additionalInfo: [row]
45
- } = this.state;
46
- const {
47
- onChange
48
- } = this.props;
49
- onChange(id, row);
50
- };
51
-
52
- this.onChangeDropdown = value => {
53
- const {
54
- dropdownOptions
55
- } = this.props;
56
- const selected = dropdownOptions.find(op => op.value === value);
57
- const {
58
- onChange,
59
- displayProperty
60
- } = this.props;
61
- if (selected) onChange(value, {
62
- [displayProperty]: selected.label
63
- });
64
- };
65
-
66
- this.onKeyDown = event => {
67
- setTimeout(() => {
68
- const {
69
- keycode
70
- } = event;
71
- const {
72
- value
73
- } = this.props;
74
- if (value && keycode === 13) this.handleCloseModal();
75
- }, 0);
76
- };
77
-
78
- this.handleSelect = (selectedRow, rows) => {
79
- let selected = selectedRow; // fix new datagrid callback format
80
-
81
- if (!selected) return;
82
- if (selected.id) selected = selected.id;else if (selected[0] && selected[0].id) selected = selected[0].id;
83
- const additionalInfo = rows.filter(row => selected === row.id);
84
- this.setState({
85
- selected,
86
- additionalInfo
87
- });
88
- };
89
-
90
- this.handleConfirm = () => {
91
- const {
92
- onConfirmField
93
- } = this.props;
94
- this.onChange();
95
- this.handleCloseModal();
96
- onConfirmField();
97
- };
98
-
99
- this.handleReject = () => {
100
- const {
101
- onRejectField
102
- } = this.props;
103
- this.handleCloseModal();
104
- onRejectField();
105
- };
106
-
107
- this.handleOpenModal = () => {
108
- this.setState({
109
- openModal: true
110
- });
111
- };
112
-
113
- this.handleCloseModal = () => this.setState({
114
- openModal: false,
115
- selected: [],
116
- additionalInfo: []
117
- });
118
-
119
- advanceOption.label = props.searchOptionLabel;
120
- this.state = {
121
- openModal: false,
122
- selected: null,
123
- additionalInfo: []
124
- };
125
- }
126
-
127
- render() {
128
- const {
129
- placeholder,
130
- modalTitle,
131
- modalSize,
132
- tabsAnimated,
133
- tabsEnableMouseEvents,
134
- tabType,
135
- tabData,
136
- searchFilters,
137
- searchGrid,
138
- confirmLabel,
139
- rejectLabel,
140
- modalType,
141
- appElement,
142
- value,
143
- additionalInfo,
144
- displayProperty,
145
- dropdownOptions,
146
- searchOptionLabel,
147
- customDataGridOptions,
148
- customDropdownOptions,
149
- useLookupIndicator,
150
- onTabChange,
151
- containerProps,
152
- searchable
153
- } = this.props;
154
- const {
155
- openModal
156
- } = this.state;
157
- let options = [...dropdownOptions, advanceOption];
158
- let displayValue = !value ? placeholder : value;
159
- if (additionalInfo && additionalInfo[displayProperty]) displayValue = additionalInfo[displayProperty];
160
- const defaultoption = {
161
- value,
162
- label: displayValue
163
- };
164
- const customComponents = {
165
- Option: props => {
166
- // return <AdvanceSearchOption onAdvanceSearchClick={this.handleOpenModal} />
167
- props.innerProps.className = 'em-ds-combobox__option';
168
-
169
- if (props.data.isAdvance) {
170
- props.innerProps.onClick = this.handleOpenModal;
171
- props.innerProps.className = "".concat(props.innerProps.className, " ").concat(advanceOption.className);
172
- }
173
-
174
- return /*#__PURE__*/jsx(components.Option, _objectSpread({}, props));
175
- },
176
- IndicatorSeparator: () => null,
177
- NoOptionsMessage: props => /*#__PURE__*/jsx(AdvanceSearchOption, _objectSpread({
178
- advanceSearchLabel: searchOptionLabel,
179
- onAdvanceSearchClick: this.handleOpenModal
180
- }, props))
181
- };
182
-
183
- if (useLookupIndicator) {
184
- customComponents.DropdownIndicator = () => null;
185
- }
186
-
187
- if (!options.find(o => o.value === defaultoption.value)) {
188
- options = [defaultoption, ...options];
189
- }
190
-
191
- return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({}, containerProps), {}, {
192
- className: "".concat(cssClassName),
193
- children: [/*#__PURE__*/_jsx("div", {
194
- className: "".concat(classNameBlock('container-selector'))
195
- }, void 0, /*#__PURE__*/jsx(DSComboBox2, _objectSpread({
196
- className: "".concat(classNameElement('dropdown-field-selector')),
197
- components: customComponents,
198
- onChange: this.onChangeDropdown,
199
- onKeyDown: this.onKeyDown,
200
- options: options,
201
- value: value,
202
- searchable: searchable
203
- }, customDropdownOptions)), useLookupIndicator && /*#__PURE__*/_jsx(LookupIndicator, {
204
- buttonType: "text",
205
- className: "".concat(classNameElement('btn-selector'), " ").concat(!value ? classNameModifier('btn-placeholder', 'btn-selector') : ''),
206
- onAdvanceSearchClick: this.handleOpenModal
207
- })), /*#__PURE__*/_jsx(ModalSearchField, {
208
- appElement: appElement,
209
- confirmLabel: confirmLabel,
210
- customDataGridOptions: customDataGridOptions,
211
- handleSelect: this.handleSelect,
212
- isOpen: openModal,
213
- modalSize: modalSize,
214
- modalTitle: modalTitle,
215
- modalType: modalType,
216
- onClose: this.handleCloseModal,
217
- onConfirmField: this.handleConfirm,
218
- onRejectField: this.handleReject,
219
- onTabChange: onTabChange,
220
- placeholder: placeholder,
221
- rejectLabel: rejectLabel,
222
- searchFilters: searchFilters,
223
- searchGrid: searchGrid,
224
- tabData: tabData,
225
- tabsAnimated: tabsAnimated,
226
- tabsEnableMouseEvents: tabsEnableMouseEvents,
227
- tabType: tabType
228
- })]
229
- }));
230
- }
231
-
232
- }
233
-
234
- export { DSSearchFieldImpl as default };
@@ -1,19 +0,0 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import 'react';
3
- import DSButton from '@elliemae/ds-button';
4
-
5
- const AdvanceSearchOption = _ref => {
6
- let {
7
- advanceSearchLabel = 'Advanced Search',
8
- onAdvanceSearchClick = () => null
9
- } = _ref;
10
- return /*#__PURE__*/_jsx(DSButton, {
11
- className: "advance-search-option-btn",
12
- labelText: advanceSearchLabel,
13
- onClick: onAdvanceSearchClick,
14
- tabIndex: -1,
15
- type: "button"
16
- });
17
- };
18
-
19
- export { AdvanceSearchOption as default };