@aclymatepackages/modules 2.1.13 → 2.1.16
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.
|
@@ -9,24 +9,14 @@ exports.default = void 0;
|
|
|
9
9
|
require("core-js/modules/es.promise.js");
|
|
10
10
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
-
var _peopledatalabs = _interopRequireDefault(require("peopledatalabs"));
|
|
13
12
|
var _material = require("@mui/material");
|
|
14
13
|
var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
|
|
15
14
|
var _Search = _interopRequireDefault(require("@mui/icons-material/Search"));
|
|
16
15
|
var _atoms = require("@aclymatepackages/atoms");
|
|
17
|
-
var _formatters = require("@aclymatepackages/formatters");
|
|
18
|
-
const _excluded = ["name"];
|
|
19
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
17
|
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); }
|
|
21
18
|
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 && {}.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; }
|
|
22
19
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
24
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
27
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
28
|
-
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; }
|
|
29
|
-
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; }
|
|
30
20
|
const CompanySelectionChip = _ref => {
|
|
31
21
|
let {
|
|
32
22
|
id,
|
|
@@ -53,48 +43,29 @@ const CompanySelectionChip = _ref => {
|
|
|
53
43
|
const PdlCompanySelect = _ref2 => {
|
|
54
44
|
let {
|
|
55
45
|
onSelectCompany,
|
|
46
|
+
matchingFunction,
|
|
56
47
|
label = "Enter your company's name",
|
|
57
|
-
actionLabel = "Please select your company from these options"
|
|
58
|
-
apiKey
|
|
48
|
+
actionLabel = "Please select your company from these options"
|
|
59
49
|
} = _ref2;
|
|
60
50
|
const [inputValue, setInputValue] = (0, _react.useState)("");
|
|
61
51
|
const [matchingCompanies, setMatchingCompanies] = (0, _react.useState)([]);
|
|
62
52
|
const [inputComplete, setInputComplete] = (0, _react.useState)(false);
|
|
63
53
|
const [pdlFetchLoading, setPdlFetchLoading] = (0, _react.useState)(false);
|
|
64
54
|
const [selectedCompanyId, setSelectedCompanyId] = (0, _react.useState)(null);
|
|
65
|
-
const pdlClient = (0, _react.useMemo)(() => new _peopledatalabs.default({
|
|
66
|
-
apiKey
|
|
67
|
-
}), []);
|
|
68
55
|
const fetchMatchingCompanies = async () => {
|
|
69
56
|
setPdlFetchLoading(true);
|
|
70
|
-
const
|
|
71
|
-
data: matchingPdlCompanies
|
|
72
|
-
} = await pdlClient.autocomplete({
|
|
73
|
-
field: "company",
|
|
74
|
-
text: inputValue,
|
|
75
|
-
size: 10,
|
|
76
|
-
pretty: true
|
|
77
|
-
});
|
|
78
|
-
const capitalizedCompanies = matchingPdlCompanies.map(_ref3 => {
|
|
79
|
-
let {
|
|
80
|
-
name
|
|
81
|
-
} = _ref3,
|
|
82
|
-
otherProps = _objectWithoutProperties(_ref3, _excluded);
|
|
83
|
-
return _objectSpread({
|
|
84
|
-
name: (0, _formatters.ucFirstLetters)(name)
|
|
85
|
-
}, otherProps);
|
|
86
|
-
});
|
|
57
|
+
const matchingCompanies = await matchingFunction(inputValue);
|
|
87
58
|
setPdlFetchLoading(false);
|
|
88
|
-
setMatchingCompanies(
|
|
59
|
+
setMatchingCompanies(matchingCompanies);
|
|
89
60
|
return setInputComplete(true);
|
|
90
61
|
};
|
|
91
62
|
const {
|
|
92
63
|
name: selectedCompanyName
|
|
93
|
-
} = matchingCompanies.find(
|
|
64
|
+
} = matchingCompanies.find(_ref3 => {
|
|
94
65
|
let {
|
|
95
|
-
|
|
96
|
-
} =
|
|
97
|
-
return selectedCompanyId ===
|
|
66
|
+
id
|
|
67
|
+
} = _ref3;
|
|
68
|
+
return selectedCompanyId === id;
|
|
98
69
|
}) || {};
|
|
99
70
|
return /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
100
71
|
container: true,
|
|
@@ -107,10 +78,10 @@ const PdlCompanySelect = _ref2 => {
|
|
|
107
78
|
label: label,
|
|
108
79
|
value: inputValue,
|
|
109
80
|
setValue: setInputValue,
|
|
110
|
-
onKeyPress:
|
|
81
|
+
onKeyPress: _ref4 => {
|
|
111
82
|
let {
|
|
112
83
|
key
|
|
113
|
-
} =
|
|
84
|
+
} = _ref4;
|
|
114
85
|
if (key === "Enter") {
|
|
115
86
|
return fetchMatchingCompanies();
|
|
116
87
|
}
|
|
@@ -137,11 +108,11 @@ const PdlCompanySelect = _ref2 => {
|
|
|
137
108
|
container: true,
|
|
138
109
|
spacing: 2,
|
|
139
110
|
justifyContent: "center"
|
|
140
|
-
}, matchingCompanies.map((
|
|
111
|
+
}, matchingCompanies.map((_ref5, idx) => {
|
|
141
112
|
let {
|
|
142
113
|
name,
|
|
143
114
|
meta
|
|
144
|
-
} =
|
|
115
|
+
} = _ref5;
|
|
145
116
|
return /*#__PURE__*/_react.default.createElement(CompanySelectionChip, _extends({
|
|
146
117
|
key: "company-list-item-".concat(idx),
|
|
147
118
|
name: name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aclymatepackages/modules",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.16",
|
|
4
4
|
"description": "Aclymate modules",
|
|
5
5
|
"author": "William Loopesko",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"autosuggest-highlight": "^3.2.1",
|
|
30
30
|
"dayjs": "^1.11.7",
|
|
31
31
|
"npm": "^8.19.4",
|
|
32
|
-
"peopledatalabs": "^5.0.4",
|
|
33
32
|
"react-countup": "^4.4.0",
|
|
34
33
|
"recharts": "^2.10.4",
|
|
35
34
|
"typewriter-effect": "^2.18.2"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React, { useState
|
|
2
|
-
import PDLJS from "peopledatalabs";
|
|
1
|
+
import React, { useState } from "react";
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
Grid,
|
|
@@ -14,7 +13,6 @@ import CheckIcon from "@mui/icons-material/Check";
|
|
|
14
13
|
import SearchIcon from "@mui/icons-material/Search";
|
|
15
14
|
|
|
16
15
|
import { TextField } from "@aclymatepackages/atoms";
|
|
17
|
-
import { ucFirstLetters } from "@aclymatepackages/formatters";
|
|
18
16
|
|
|
19
17
|
const CompanySelectionChip = ({
|
|
20
18
|
id,
|
|
@@ -37,9 +35,9 @@ const CompanySelectionChip = ({
|
|
|
37
35
|
|
|
38
36
|
const PdlCompanySelect = ({
|
|
39
37
|
onSelectCompany,
|
|
38
|
+
matchingFunction,
|
|
40
39
|
label = "Enter your company's name",
|
|
41
40
|
actionLabel = "Please select your company from these options",
|
|
42
|
-
apiKey,
|
|
43
41
|
}) => {
|
|
44
42
|
const [inputValue, setInputValue] = useState("");
|
|
45
43
|
const [matchingCompanies, setMatchingCompanies] = useState([]);
|
|
@@ -47,38 +45,18 @@ const PdlCompanySelect = ({
|
|
|
47
45
|
const [pdlFetchLoading, setPdlFetchLoading] = useState(false);
|
|
48
46
|
const [selectedCompanyId, setSelectedCompanyId] = useState(null);
|
|
49
47
|
|
|
50
|
-
const pdlClient = useMemo(
|
|
51
|
-
() =>
|
|
52
|
-
new PDLJS({
|
|
53
|
-
apiKey,
|
|
54
|
-
}),
|
|
55
|
-
[]
|
|
56
|
-
);
|
|
57
|
-
|
|
58
48
|
const fetchMatchingCompanies = async () => {
|
|
59
49
|
setPdlFetchLoading(true);
|
|
60
50
|
|
|
61
|
-
const
|
|
62
|
-
field: "company",
|
|
63
|
-
text: inputValue,
|
|
64
|
-
size: 10,
|
|
65
|
-
pretty: true,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const capitalizedCompanies = matchingPdlCompanies.map(
|
|
69
|
-
({ name, ...otherProps }) => ({
|
|
70
|
-
name: ucFirstLetters(name),
|
|
71
|
-
...otherProps,
|
|
72
|
-
})
|
|
73
|
-
);
|
|
51
|
+
const matchingCompanies = await matchingFunction(inputValue);
|
|
74
52
|
|
|
75
53
|
setPdlFetchLoading(false);
|
|
76
|
-
setMatchingCompanies(
|
|
54
|
+
setMatchingCompanies(matchingCompanies);
|
|
77
55
|
return setInputComplete(true);
|
|
78
56
|
};
|
|
79
57
|
|
|
80
58
|
const { name: selectedCompanyName } =
|
|
81
|
-
matchingCompanies.find(({
|
|
59
|
+
matchingCompanies.find(({ id }) => selectedCompanyId === id) || {};
|
|
82
60
|
|
|
83
61
|
return (
|
|
84
62
|
<Grid container spacing={2} direction="column">
|