@elliemae/ds-zipcode-search 3.0.0-next.2 → 3.0.0-next.3
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/dist/cjs/DSZipCodeSearch.js +139 -0
- package/dist/cjs/DSZipCodeSearch.js.map +7 -0
- package/dist/cjs/components/blocks.js +37 -0
- package/dist/cjs/components/blocks.js.map +7 -0
- package/dist/cjs/components/helper.js +66 -0
- package/dist/cjs/components/helper.js.map +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/props.js +68 -0
- package/dist/cjs/props.js.map +7 -0
- package/dist/esm/DSZipCodeSearch.js +112 -0
- package/dist/esm/DSZipCodeSearch.js.map +7 -0
- package/dist/esm/components/blocks.js +8 -0
- package/dist/esm/components/blocks.js.map +7 -0
- package/dist/esm/components/helper.js +39 -0
- package/dist/esm/components/helper.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/props.js +39 -0
- package/dist/esm/props.js.map +7 -0
- package/package.json +36 -27
- package/cjs/DSZipCodeSearch.js +0 -121
- package/cjs/components/blocks.js +0 -10
- package/cjs/components/helper.js +0 -39
- package/cjs/index.js +0 -11
- package/cjs/props.js +0 -66
- package/esm/DSZipCodeSearch.js +0 -109
- package/esm/components/blocks.js +0 -6
- package/esm/components/helper.js +0 -30
- package/esm/index.js +0 -1
- package/esm/props.js +0 -61
- package/types/DSZipCodeSearch.d.ts +0 -126
- package/types/components/blocks.d.ts +0 -2
- package/types/components/helper.d.ts +0 -10
- package/types/index.d.ts +0 -2
- package/types/props.d.ts +0 -102
- package/types/tests/DSZipCodeSearch.test.d.ts +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes } from "react-desc";
|
|
3
|
+
import { MASK_TYPES } from "@elliemae/ds-form";
|
|
4
|
+
const zipcodeSearchProps = {
|
|
5
|
+
className: PropTypes.string.description("html class attribute"),
|
|
6
|
+
containerProps: PropTypes.object.description("Set of Properties attached to the main container"),
|
|
7
|
+
tabIndex: PropTypes.number.description("native tabindex property to handle focus order"),
|
|
8
|
+
disabled: PropTypes.bool.description("disable component"),
|
|
9
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).description("input value").isRequired,
|
|
10
|
+
onBlur: PropTypes.func.description("function called on blur"),
|
|
11
|
+
onChange: PropTypes.func.description("function called on change"),
|
|
12
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
13
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
14
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
15
|
+
})).description("options to display"),
|
|
16
|
+
placeholder: PropTypes.string.description("placeholder value"),
|
|
17
|
+
mask: PropTypes.arrayOf(PropTypes.any).description("format mask to apply"),
|
|
18
|
+
onSearch: PropTypes.func.description("function called onsearch"),
|
|
19
|
+
selectRightOptions: PropTypes.string.description("Correction messange"),
|
|
20
|
+
activeCount: PropTypes.number.description("current amount")
|
|
21
|
+
};
|
|
22
|
+
const defaultProps = {
|
|
23
|
+
disabled: false,
|
|
24
|
+
value: "",
|
|
25
|
+
placeholder: "_____-____",
|
|
26
|
+
mask: MASK_TYPES.ZIP_CODE_SEARCH,
|
|
27
|
+
onBlur: () => null,
|
|
28
|
+
onChange: () => null,
|
|
29
|
+
onSearch: () => null,
|
|
30
|
+
containerProps: {},
|
|
31
|
+
selectRightOptions: "Please select the appropriate city",
|
|
32
|
+
activeCount: 5,
|
|
33
|
+
options: []
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
defaultProps,
|
|
37
|
+
zipcodeSearchProps
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/props.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\nimport { MASK_TYPES } from '@elliemae/ds-form';\n\nexport const zipcodeSearchProps = {\n /** html class attribute */\n className: PropTypes.string.description('html class attribute'),\n /** Set of Properties attached to the main container */\n containerProps: PropTypes.object.description('Set of Properties attached to the main container'),\n /** native tabindex property to handle focus order */\n tabIndex: PropTypes.number.description('native tabindex property to handle focus order'),\n /** disable component */\n disabled: PropTypes.bool.description('disable component'),\n /** input value */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).description('input value')\n .isRequired,\n /** function called on blur */\n onBlur: PropTypes.func.description('function called on blur'),\n /** function called on change */\n onChange: PropTypes.func.description('function called on change'),\n /** options to display */\n options: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n }),\n ).description('options to display'),\n /** placeholder value */\n placeholder: PropTypes.string.description('placeholder value'),\n /** format mask to apply */\n mask: PropTypes.arrayOf(PropTypes.any).description('format mask to apply'),\n /** function called onsearch */\n onSearch: PropTypes.func.description('function called onsearch'),\n /** Correction messange */\n selectRightOptions: PropTypes.string.description('Correction messange'),\n /** current amount */\n activeCount: PropTypes.number.description('current amount'),\n};\n\nexport const defaultProps = {\n disabled: false,\n value: '',\n placeholder: '_____-____',\n mask: MASK_TYPES.ZIP_CODE_SEARCH,\n onBlur: () => null,\n onChange: () => null,\n onSearch: () => null,\n containerProps: {},\n selectRightOptions: 'Please select the appropriate city',\n activeCount: 5,\n options: [],\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEO,MAAM,qBAAqB;AAAA,EAEhC,WAAW,UAAU,OAAO,YAAY;AAAA,EAExC,gBAAgB,UAAU,OAAO,YAAY;AAAA,EAE7C,UAAU,UAAU,OAAO,YAAY;AAAA,EAEvC,UAAU,UAAU,KAAK,YAAY;AAAA,EAErC,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,QAAQ,UAAU,SAAS,YAAY,eAC5F;AAAA,EAEH,QAAQ,UAAU,KAAK,YAAY;AAAA,EAEnC,UAAU,UAAU,KAAK,YAAY;AAAA,EAErC,SAAS,UAAU,QACjB,UAAU,MAAM;AAAA,IACd,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU;AAAA,IACxD,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU;AAAA,MAE1D,YAAY;AAAA,EAEd,aAAa,UAAU,OAAO,YAAY;AAAA,EAE1C,MAAM,UAAU,QAAQ,UAAU,KAAK,YAAY;AAAA,EAEnD,UAAU,UAAU,KAAK,YAAY;AAAA,EAErC,oBAAoB,UAAU,OAAO,YAAY;AAAA,EAEjD,aAAa,UAAU,OAAO,YAAY;AAAA;AAGrC,MAAM,eAAe;AAAA,EAC1B,UAAU;AAAA,EACV,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM,WAAW;AAAA,EACjB,QAAQ,MAAM;AAAA,EACd,UAAU,MAAM;AAAA,EAChB,UAAU,MAAM;AAAA,EAChB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,SAAS;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-zipcode-search",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Zipcode Search",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
|
-
"import": "./esm/index.js",
|
|
12
|
-
"require": "./cjs/index.js"
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
13
16
|
},
|
|
14
17
|
"./props": {
|
|
15
|
-
"import": "./esm/props.js",
|
|
16
|
-
"require": "./cjs/props.js"
|
|
18
|
+
"import": "./dist/esm/props.js",
|
|
19
|
+
"require": "./dist/cjs/props.js"
|
|
17
20
|
},
|
|
18
21
|
"./DSZipCodeSearch": {
|
|
19
|
-
"import": "./esm/DSZipCodeSearch.js",
|
|
20
|
-
"require": "./cjs/DSZipCodeSearch.js"
|
|
22
|
+
"import": "./dist/esm/DSZipCodeSearch.js",
|
|
23
|
+
"require": "./dist/cjs/DSZipCodeSearch.js"
|
|
21
24
|
},
|
|
22
25
|
"./components/helper": {
|
|
23
|
-
"import": "./esm/components/helper.js",
|
|
24
|
-
"require": "./cjs/components/helper.js"
|
|
26
|
+
"import": "./dist/esm/components/helper.js",
|
|
27
|
+
"require": "./dist/cjs/components/helper.js"
|
|
25
28
|
},
|
|
26
29
|
"./components/blocks": {
|
|
27
|
-
"import": "./esm/components/blocks.js",
|
|
28
|
-
"require": "./cjs/components/blocks.js"
|
|
30
|
+
"import": "./dist/esm/components/blocks.js",
|
|
31
|
+
"require": "./dist/cjs/components/blocks.js"
|
|
29
32
|
}
|
|
30
33
|
},
|
|
31
34
|
"sideEffects": [
|
|
@@ -37,24 +40,24 @@
|
|
|
37
40
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
38
41
|
},
|
|
39
42
|
"engines": {
|
|
40
|
-
"
|
|
41
|
-
"node": ">=
|
|
43
|
+
"pnpm": ">=6",
|
|
44
|
+
"node": ">=16"
|
|
42
45
|
},
|
|
43
46
|
"author": "ICE MT",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"jestSonar": {
|
|
48
|
+
"sonar56x": true,
|
|
49
|
+
"reportPath": "reports",
|
|
50
|
+
"reportFile": "tests.xml",
|
|
51
|
+
"indent": 4
|
|
49
52
|
},
|
|
50
53
|
"dependencies": {
|
|
51
|
-
"@elliemae/ds-classnames": "3.0.0-next.
|
|
52
|
-
"@elliemae/ds-dropdownmenu": "3.0.0-next.
|
|
53
|
-
"@elliemae/ds-form": "3.0.0-next.
|
|
54
|
+
"@elliemae/ds-classnames": "3.0.0-next.3",
|
|
55
|
+
"@elliemae/ds-dropdownmenu": "3.0.0-next.3",
|
|
56
|
+
"@elliemae/ds-form": "3.0.0-next.3",
|
|
54
57
|
"react-desc": "~4.1.3"
|
|
55
58
|
},
|
|
56
59
|
"devDependencies": {
|
|
57
|
-
"@testing-library/jest-dom": "~5.15.
|
|
60
|
+
"@testing-library/jest-dom": "~5.15.1",
|
|
58
61
|
"@testing-library/react": "~12.1.2",
|
|
59
62
|
"@testing-library/user-event": "~13.5.0"
|
|
60
63
|
},
|
|
@@ -64,7 +67,13 @@
|
|
|
64
67
|
},
|
|
65
68
|
"publishConfig": {
|
|
66
69
|
"access": "public",
|
|
67
|
-
"
|
|
68
|
-
|
|
70
|
+
"typeSafety": false
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
74
|
+
"test": "node ../../scripts/testing/test.mjs",
|
|
75
|
+
"lint": "node ../../scripts/lint.mjs",
|
|
76
|
+
"dts": "node ../../scripts/dts.mjs",
|
|
77
|
+
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
69
78
|
}
|
|
70
79
|
}
|
package/cjs/DSZipCodeSearch.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
7
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
8
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
10
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
11
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
12
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
13
|
-
var react = require('react');
|
|
14
|
-
var reactDesc = require('react-desc');
|
|
15
|
-
var DSDropdownMenu = require('@elliemae/ds-dropdownmenu');
|
|
16
|
-
var dsForm = require('@elliemae/ds-form');
|
|
17
|
-
var blocks = require('./components/blocks.js');
|
|
18
|
-
var helper = require('./components/helper.js');
|
|
19
|
-
var props = require('./props.js');
|
|
20
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
21
|
-
|
|
22
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
-
|
|
24
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
25
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
26
|
-
var DSDropdownMenu__default = /*#__PURE__*/_interopDefaultLegacy(DSDropdownMenu);
|
|
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
|
-
|
|
32
|
-
const DSZipCodeSearch = _ref2 => {
|
|
33
|
-
let {
|
|
34
|
-
disabled,
|
|
35
|
-
value,
|
|
36
|
-
placeholder,
|
|
37
|
-
mask,
|
|
38
|
-
onBlur,
|
|
39
|
-
onChange,
|
|
40
|
-
onSearch,
|
|
41
|
-
containerProps,
|
|
42
|
-
selectRightOptions,
|
|
43
|
-
activeCount,
|
|
44
|
-
options,
|
|
45
|
-
tabIndex
|
|
46
|
-
} = _ref2;
|
|
47
|
-
const ref = react.useRef(null);
|
|
48
|
-
const [searchValue, setSearchValue] = react.useState(value);
|
|
49
|
-
const [isOpen, setIsOpen] = react.useState(false);
|
|
50
|
-
const [isActive, setIsActive] = react.useState(false);
|
|
51
|
-
const [isInputFocus, setIsInputFocus] = react.useState(false);
|
|
52
|
-
const [isSelected, setIsSelected] = react.useState(false);
|
|
53
|
-
react.useEffect(() => {
|
|
54
|
-
if (isInputFocus && activeCount <= searchValue.length && !isSelected) {
|
|
55
|
-
setIsOpen(true);
|
|
56
|
-
setIsActive(true);
|
|
57
|
-
} else if (!isActive || activeCount > searchValue.length) {
|
|
58
|
-
setIsOpen(false);
|
|
59
|
-
}
|
|
60
|
-
}, [isInputFocus, isActive, activeCount, searchValue, isSelected]);
|
|
61
|
-
react.useEffect(() => {
|
|
62
|
-
setSearchValue(value || '');
|
|
63
|
-
}, [value]);
|
|
64
|
-
const onTypeInInput = react.useCallback(e => {
|
|
65
|
-
const finalVal = e.target.value;
|
|
66
|
-
onSearch(finalVal);
|
|
67
|
-
setSearchValue(finalVal);
|
|
68
|
-
setIsSelected(false);
|
|
69
|
-
}, [onSearch]);
|
|
70
|
-
const onFocusInput = react.useCallback(() => {
|
|
71
|
-
setIsInputFocus(true);
|
|
72
|
-
}, []);
|
|
73
|
-
const onInnerBlur = react.useCallback(e => {
|
|
74
|
-
setIsInputFocus(false);
|
|
75
|
-
onBlur(e);
|
|
76
|
-
}, [onBlur]);
|
|
77
|
-
const onClose = react.useCallback(() => {
|
|
78
|
-
setIsActive(false);
|
|
79
|
-
}, []);
|
|
80
|
-
const onSelectItem = react.useCallback(item => {
|
|
81
|
-
setSearchValue(item.value);
|
|
82
|
-
onChange(item);
|
|
83
|
-
setIsSelected(true);
|
|
84
|
-
ref.current.focus();
|
|
85
|
-
setIsOpen(false);
|
|
86
|
-
onClose();
|
|
87
|
-
}, [onChange, onClose]);
|
|
88
|
-
return /*#__PURE__*/jsxRuntime.jsx(blocks.InputSearchWrapper, _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
89
|
-
children: /*#__PURE__*/_jsx__default["default"](DSDropdownMenu__default["default"], {
|
|
90
|
-
isOpen: isOpen && options.length > 0,
|
|
91
|
-
menuProps: {
|
|
92
|
-
className: 'input-search-menu'
|
|
93
|
-
},
|
|
94
|
-
onClose: onClose,
|
|
95
|
-
onSelectMenuItem: onSelectItem,
|
|
96
|
-
contentStyle: {
|
|
97
|
-
maxHeight: 200
|
|
98
|
-
},
|
|
99
|
-
options: options.length > 0 ? [helper.createDisabledOption(selectRightOptions), ...helper.noAddonOptions(options)] : [],
|
|
100
|
-
triggerComponent: /*#__PURE__*/_jsx__default["default"]("div", {}, void 0, /*#__PURE__*/_jsx__default["default"](dsForm.DSInputMask, {
|
|
101
|
-
disabled: disabled,
|
|
102
|
-
innerRef: _ref => ref.current = _ref,
|
|
103
|
-
mask: mask,
|
|
104
|
-
onBlur: onInnerBlur,
|
|
105
|
-
onChange: onTypeInInput,
|
|
106
|
-
onFocus: onFocusInput,
|
|
107
|
-
placeholder: placeholder,
|
|
108
|
-
value: searchValue,
|
|
109
|
-
tabIndex: tabIndex
|
|
110
|
-
}))
|
|
111
|
-
})
|
|
112
|
-
}));
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
DSZipCodeSearch.defaultProps = props.defaultProps;
|
|
116
|
-
const ZipCodeSearchWithSchema = reactDesc.describe(DSZipCodeSearch);
|
|
117
|
-
ZipCodeSearchWithSchema.propTypes = props.zipcodeSearchProps;
|
|
118
|
-
|
|
119
|
-
exports.DSZipCodeSearch = DSZipCodeSearch;
|
|
120
|
-
exports.ZipCodeSearchWithSchema = ZipCodeSearchWithSchema;
|
|
121
|
-
exports["default"] = DSZipCodeSearch;
|
package/cjs/components/blocks.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var dsClassnames = require('@elliemae/ds-classnames');
|
|
6
|
-
|
|
7
|
-
const blockName = 'input-search';
|
|
8
|
-
const InputSearchWrapper = dsClassnames.aggregatedClasses('div')(blockName);
|
|
9
|
-
|
|
10
|
-
exports.InputSearchWrapper = InputSearchWrapper;
|
package/cjs/components/helper.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
8
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
10
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
11
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
12
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
13
|
-
|
|
14
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
-
|
|
16
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
function createDisabledOption(label) {
|
|
22
|
-
return {
|
|
23
|
-
id: 'no-option',
|
|
24
|
-
type: 'disabled',
|
|
25
|
-
label,
|
|
26
|
-
noAddon: true,
|
|
27
|
-
'aria-disabled': true,
|
|
28
|
-
className: 'no-options',
|
|
29
|
-
tabIndex: -1
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function noAddonOptions(options) {
|
|
33
|
-
return options.map(op => _objectSpread(_objectSpread({}, op), {}, {
|
|
34
|
-
noAddon: true
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
exports.createDisabledOption = createDisabledOption;
|
|
39
|
-
exports.noAddonOptions = noAddonOptions;
|
package/cjs/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var DSZipCodeSearch = require('./DSZipCodeSearch.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.DSZipCodeSearch = DSZipCodeSearch.DSZipCodeSearch;
|
|
10
|
-
exports.ZipCodeSearchWithSchema = DSZipCodeSearch.ZipCodeSearchWithSchema;
|
|
11
|
-
exports["default"] = DSZipCodeSearch.DSZipCodeSearch;
|
package/cjs/props.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactDesc = require('react-desc');
|
|
6
|
-
var dsForm = require('@elliemae/ds-form');
|
|
7
|
-
|
|
8
|
-
const zipcodeSearchProps = {
|
|
9
|
-
/** html class attribute */
|
|
10
|
-
className: reactDesc.PropTypes.string.description('html class attribute'),
|
|
11
|
-
|
|
12
|
-
/** Set of Properties attached to the main container */
|
|
13
|
-
containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container'),
|
|
14
|
-
|
|
15
|
-
/** native tabindex property to handle focus order */
|
|
16
|
-
tabIndex: reactDesc.PropTypes.number.description('native tabindex property to handle focus order'),
|
|
17
|
-
|
|
18
|
-
/** disable component */
|
|
19
|
-
disabled: reactDesc.PropTypes.bool.description('disable component'),
|
|
20
|
-
|
|
21
|
-
/** input value */
|
|
22
|
-
value: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number, reactDesc.PropTypes.object]).description('input value').isRequired,
|
|
23
|
-
|
|
24
|
-
/** function called on blur */
|
|
25
|
-
onBlur: reactDesc.PropTypes.func.description('function called on blur'),
|
|
26
|
-
|
|
27
|
-
/** function called on change */
|
|
28
|
-
onChange: reactDesc.PropTypes.func.description('function called on change'),
|
|
29
|
-
|
|
30
|
-
/** options to display */
|
|
31
|
-
options: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.shape({
|
|
32
|
-
label: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number]),
|
|
33
|
-
value: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number])
|
|
34
|
-
})).description('options to display'),
|
|
35
|
-
|
|
36
|
-
/** placeholder value */
|
|
37
|
-
placeholder: reactDesc.PropTypes.string.description('placeholder value'),
|
|
38
|
-
|
|
39
|
-
/** format mask to apply */
|
|
40
|
-
mask: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.any).description('format mask to apply'),
|
|
41
|
-
|
|
42
|
-
/** function called onsearch */
|
|
43
|
-
onSearch: reactDesc.PropTypes.func.description('function called onsearch'),
|
|
44
|
-
|
|
45
|
-
/** Correction messange */
|
|
46
|
-
selectRightOptions: reactDesc.PropTypes.string.description('Correction messange'),
|
|
47
|
-
|
|
48
|
-
/** current amount */
|
|
49
|
-
activeCount: reactDesc.PropTypes.number.description('current amount')
|
|
50
|
-
};
|
|
51
|
-
const defaultProps = {
|
|
52
|
-
disabled: false,
|
|
53
|
-
value: '',
|
|
54
|
-
placeholder: '_____-____',
|
|
55
|
-
mask: dsForm.MASK_TYPES.ZIP_CODE_SEARCH,
|
|
56
|
-
onBlur: () => null,
|
|
57
|
-
onChange: () => null,
|
|
58
|
-
onSearch: () => null,
|
|
59
|
-
containerProps: {},
|
|
60
|
-
selectRightOptions: 'Please select the appropriate city',
|
|
61
|
-
activeCount: 5,
|
|
62
|
-
options: []
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
exports.defaultProps = defaultProps;
|
|
66
|
-
exports.zipcodeSearchProps = zipcodeSearchProps;
|
package/esm/DSZipCodeSearch.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
-
import { useRef, useState, useEffect, useCallback } from 'react';
|
|
10
|
-
import { describe } from 'react-desc';
|
|
11
|
-
import DSDropdownMenu from '@elliemae/ds-dropdownmenu';
|
|
12
|
-
import { DSInputMask } from '@elliemae/ds-form';
|
|
13
|
-
import { InputSearchWrapper } from './components/blocks.js';
|
|
14
|
-
import { createDisabledOption, noAddonOptions } from './components/helper.js';
|
|
15
|
-
import { zipcodeSearchProps, defaultProps } from './props.js';
|
|
16
|
-
import { jsx } from 'react/jsx-runtime';
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
22
|
-
const DSZipCodeSearch = _ref2 => {
|
|
23
|
-
let {
|
|
24
|
-
disabled,
|
|
25
|
-
value,
|
|
26
|
-
placeholder,
|
|
27
|
-
mask,
|
|
28
|
-
onBlur,
|
|
29
|
-
onChange,
|
|
30
|
-
onSearch,
|
|
31
|
-
containerProps,
|
|
32
|
-
selectRightOptions,
|
|
33
|
-
activeCount,
|
|
34
|
-
options,
|
|
35
|
-
tabIndex
|
|
36
|
-
} = _ref2;
|
|
37
|
-
const ref = useRef(null);
|
|
38
|
-
const [searchValue, setSearchValue] = useState(value);
|
|
39
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
40
|
-
const [isActive, setIsActive] = useState(false);
|
|
41
|
-
const [isInputFocus, setIsInputFocus] = useState(false);
|
|
42
|
-
const [isSelected, setIsSelected] = useState(false);
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (isInputFocus && activeCount <= searchValue.length && !isSelected) {
|
|
45
|
-
setIsOpen(true);
|
|
46
|
-
setIsActive(true);
|
|
47
|
-
} else if (!isActive || activeCount > searchValue.length) {
|
|
48
|
-
setIsOpen(false);
|
|
49
|
-
}
|
|
50
|
-
}, [isInputFocus, isActive, activeCount, searchValue, isSelected]);
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
setSearchValue(value || '');
|
|
53
|
-
}, [value]);
|
|
54
|
-
const onTypeInInput = useCallback(e => {
|
|
55
|
-
const finalVal = e.target.value;
|
|
56
|
-
onSearch(finalVal);
|
|
57
|
-
setSearchValue(finalVal);
|
|
58
|
-
setIsSelected(false);
|
|
59
|
-
}, [onSearch]);
|
|
60
|
-
const onFocusInput = useCallback(() => {
|
|
61
|
-
setIsInputFocus(true);
|
|
62
|
-
}, []);
|
|
63
|
-
const onInnerBlur = useCallback(e => {
|
|
64
|
-
setIsInputFocus(false);
|
|
65
|
-
onBlur(e);
|
|
66
|
-
}, [onBlur]);
|
|
67
|
-
const onClose = useCallback(() => {
|
|
68
|
-
setIsActive(false);
|
|
69
|
-
}, []);
|
|
70
|
-
const onSelectItem = useCallback(item => {
|
|
71
|
-
setSearchValue(item.value);
|
|
72
|
-
onChange(item);
|
|
73
|
-
setIsSelected(true);
|
|
74
|
-
ref.current.focus();
|
|
75
|
-
setIsOpen(false);
|
|
76
|
-
onClose();
|
|
77
|
-
}, [onChange, onClose]);
|
|
78
|
-
return /*#__PURE__*/jsx(InputSearchWrapper, _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
79
|
-
children: /*#__PURE__*/_jsx(DSDropdownMenu, {
|
|
80
|
-
isOpen: isOpen && options.length > 0,
|
|
81
|
-
menuProps: {
|
|
82
|
-
className: 'input-search-menu'
|
|
83
|
-
},
|
|
84
|
-
onClose: onClose,
|
|
85
|
-
onSelectMenuItem: onSelectItem,
|
|
86
|
-
contentStyle: {
|
|
87
|
-
maxHeight: 200
|
|
88
|
-
},
|
|
89
|
-
options: options.length > 0 ? [createDisabledOption(selectRightOptions), ...noAddonOptions(options)] : [],
|
|
90
|
-
triggerComponent: /*#__PURE__*/_jsx("div", {}, void 0, /*#__PURE__*/_jsx(DSInputMask, {
|
|
91
|
-
disabled: disabled,
|
|
92
|
-
innerRef: _ref => ref.current = _ref,
|
|
93
|
-
mask: mask,
|
|
94
|
-
onBlur: onInnerBlur,
|
|
95
|
-
onChange: onTypeInInput,
|
|
96
|
-
onFocus: onFocusInput,
|
|
97
|
-
placeholder: placeholder,
|
|
98
|
-
value: searchValue,
|
|
99
|
-
tabIndex: tabIndex
|
|
100
|
-
}))
|
|
101
|
-
})
|
|
102
|
-
}));
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
DSZipCodeSearch.defaultProps = defaultProps;
|
|
106
|
-
const ZipCodeSearchWithSchema = describe(DSZipCodeSearch);
|
|
107
|
-
ZipCodeSearchWithSchema.propTypes = zipcodeSearchProps;
|
|
108
|
-
|
|
109
|
-
export { DSZipCodeSearch, ZipCodeSearchWithSchema, DSZipCodeSearch as default };
|
package/esm/components/blocks.js
DELETED
package/esm/components/helper.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
-
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
7
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
8
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
9
|
-
|
|
10
|
-
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; }
|
|
11
|
-
|
|
12
|
-
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; }
|
|
13
|
-
function createDisabledOption(label) {
|
|
14
|
-
return {
|
|
15
|
-
id: 'no-option',
|
|
16
|
-
type: 'disabled',
|
|
17
|
-
label,
|
|
18
|
-
noAddon: true,
|
|
19
|
-
'aria-disabled': true,
|
|
20
|
-
className: 'no-options',
|
|
21
|
-
tabIndex: -1
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function noAddonOptions(options) {
|
|
25
|
-
return options.map(op => _objectSpread(_objectSpread({}, op), {}, {
|
|
26
|
-
noAddon: true
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { createDisabledOption, noAddonOptions };
|
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DSZipCodeSearch, ZipCodeSearchWithSchema, DSZipCodeSearch as default } from './DSZipCodeSearch.js';
|
package/esm/props.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { PropTypes } from 'react-desc';
|
|
2
|
-
import { MASK_TYPES } from '@elliemae/ds-form';
|
|
3
|
-
|
|
4
|
-
const zipcodeSearchProps = {
|
|
5
|
-
/** html class attribute */
|
|
6
|
-
className: PropTypes.string.description('html class attribute'),
|
|
7
|
-
|
|
8
|
-
/** Set of Properties attached to the main container */
|
|
9
|
-
containerProps: PropTypes.object.description('Set of Properties attached to the main container'),
|
|
10
|
-
|
|
11
|
-
/** native tabindex property to handle focus order */
|
|
12
|
-
tabIndex: PropTypes.number.description('native tabindex property to handle focus order'),
|
|
13
|
-
|
|
14
|
-
/** disable component */
|
|
15
|
-
disabled: PropTypes.bool.description('disable component'),
|
|
16
|
-
|
|
17
|
-
/** input value */
|
|
18
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).description('input value').isRequired,
|
|
19
|
-
|
|
20
|
-
/** function called on blur */
|
|
21
|
-
onBlur: PropTypes.func.description('function called on blur'),
|
|
22
|
-
|
|
23
|
-
/** function called on change */
|
|
24
|
-
onChange: PropTypes.func.description('function called on change'),
|
|
25
|
-
|
|
26
|
-
/** options to display */
|
|
27
|
-
options: PropTypes.arrayOf(PropTypes.shape({
|
|
28
|
-
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
29
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
30
|
-
})).description('options to display'),
|
|
31
|
-
|
|
32
|
-
/** placeholder value */
|
|
33
|
-
placeholder: PropTypes.string.description('placeholder value'),
|
|
34
|
-
|
|
35
|
-
/** format mask to apply */
|
|
36
|
-
mask: PropTypes.arrayOf(PropTypes.any).description('format mask to apply'),
|
|
37
|
-
|
|
38
|
-
/** function called onsearch */
|
|
39
|
-
onSearch: PropTypes.func.description('function called onsearch'),
|
|
40
|
-
|
|
41
|
-
/** Correction messange */
|
|
42
|
-
selectRightOptions: PropTypes.string.description('Correction messange'),
|
|
43
|
-
|
|
44
|
-
/** current amount */
|
|
45
|
-
activeCount: PropTypes.number.description('current amount')
|
|
46
|
-
};
|
|
47
|
-
const defaultProps = {
|
|
48
|
-
disabled: false,
|
|
49
|
-
value: '',
|
|
50
|
-
placeholder: '_____-____',
|
|
51
|
-
mask: MASK_TYPES.ZIP_CODE_SEARCH,
|
|
52
|
-
onBlur: () => null,
|
|
53
|
-
onChange: () => null,
|
|
54
|
-
onSearch: () => null,
|
|
55
|
-
containerProps: {},
|
|
56
|
-
selectRightOptions: 'Please select the appropriate city',
|
|
57
|
-
activeCount: 5,
|
|
58
|
-
options: []
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export { defaultProps, zipcodeSearchProps };
|