@aclymatepackages/modules 2.1.10 → 2.1.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.
@@ -53,6 +53,8 @@ const CompanySelectionChip = _ref => {
53
53
  const PdlCompanySelect = _ref2 => {
54
54
  let {
55
55
  onSelectCompany,
56
+ label = "Enter your company's name",
57
+ actionLabel = "Please select your company from these options",
56
58
  apiKey
57
59
  } = _ref2;
58
60
  const [inputValue, setInputValue] = (0, _react.useState)("");
@@ -90,9 +92,9 @@ const PdlCompanySelect = _ref2 => {
90
92
  name: selectedCompanyName
91
93
  } = matchingCompanies.find(_ref4 => {
92
94
  let {
93
- id
95
+ meta
94
96
  } = _ref4;
95
- return selectedCompanyId === id;
97
+ return selectedCompanyId === meta.id;
96
98
  }) || {};
97
99
  return /*#__PURE__*/_react.default.createElement(_material.Grid, {
98
100
  container: true,
@@ -102,7 +104,7 @@ const PdlCompanySelect = _ref2 => {
102
104
  item: true
103
105
  }, /*#__PURE__*/_react.default.createElement(_atoms.TextField, {
104
106
  disabled: pdlFetchLoading,
105
- label: "Enter your company's name",
107
+ label: label,
106
108
  value: inputValue,
107
109
  setValue: setInputValue,
108
110
  onKeyPress: _ref5 => {
@@ -130,7 +132,7 @@ const PdlCompanySelect = _ref2 => {
130
132
  }, /*#__PURE__*/_react.default.createElement(_material.Typography, {
131
133
  variant: "h6",
132
134
  align: "center"
133
- }, "Please select your company from these options")), /*#__PURE__*/_react.default.createElement(_material.Grid, {
135
+ }, actionLabel)), /*#__PURE__*/_react.default.createElement(_material.Grid, {
134
136
  item: true,
135
137
  container: true,
136
138
  spacing: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aclymatepackages/modules",
3
- "version": "2.1.10",
3
+ "version": "2.1.12",
4
4
  "description": "Aclymate modules",
5
5
  "author": "William Loopesko",
6
6
  "main": "dist/index.js",
@@ -35,7 +35,12 @@ const CompanySelectionChip = ({
35
35
  </Grid>
36
36
  );
37
37
 
38
- const PdlCompanySelect = ({ onSelectCompany, apiKey }) => {
38
+ const PdlCompanySelect = ({
39
+ onSelectCompany,
40
+ label = "Enter your company's name",
41
+ actionLabel = "Please select your company from these options",
42
+ apiKey,
43
+ }) => {
39
44
  const [inputValue, setInputValue] = useState("");
40
45
  const [matchingCompanies, setMatchingCompanies] = useState([]);
41
46
  const [inputComplete, setInputComplete] = useState(false);
@@ -73,14 +78,14 @@ const PdlCompanySelect = ({ onSelectCompany, apiKey }) => {
73
78
  };
74
79
 
75
80
  const { name: selectedCompanyName } =
76
- matchingCompanies.find(({ id }) => selectedCompanyId === id) || {};
81
+ matchingCompanies.find(({ meta }) => selectedCompanyId === meta.id) || {};
77
82
 
78
83
  return (
79
84
  <Grid container spacing={2} direction="column">
80
85
  <Grid item>
81
86
  <TextField
82
87
  disabled={pdlFetchLoading}
83
- label="Enter your company's name"
88
+ label={label}
84
89
  value={inputValue}
85
90
  setValue={setInputValue}
86
91
  onKeyPress={({ key }) => {
@@ -111,7 +116,7 @@ const PdlCompanySelect = ({ onSelectCompany, apiKey }) => {
111
116
  <>
112
117
  <Grid item>
113
118
  <Typography variant="h6" align="center">
114
- Please select your company from these options
119
+ {actionLabel}
115
120
  </Typography>
116
121
  </Grid>
117
122
  <Grid item container spacing={2} justifyContent="center">
@@ -1,124 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.object.assign.js");
4
- require("core-js/modules/es.weak-map.js");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- require("core-js/modules/es.promise.js");
10
- require("core-js/modules/web.dom-collections.iterator.js");
11
- var _react = _interopRequireWildcard(require("react"));
12
- var _peopledatalabs = _interopRequireDefault(require("peopledatalabs"));
13
- var _material = require("@mui/material");
14
- var _formatters = require("@aclymatepackages/formatters");
15
- var _otherHelpers = require("@aclymatepackages/other-helpers");
16
- const _excluded = ["name"];
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
- 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); }
19
- 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; }
20
- 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); }
21
- 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; }
22
- 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; }
23
- 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; }
24
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
25
- 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); }
26
- 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; }
27
- 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; }
28
- const CompaniesAutocomplete = _ref => {
29
- let {
30
- setCompanyName,
31
- onSelectCompany,
32
- label,
33
- variant = "outlined",
34
- size = "medium",
35
- disabled,
36
- helperText = "",
37
- id,
38
- style,
39
- textFieldProps,
40
- pdlApiKey
41
- } = _ref;
42
- const [nextStepIsLoading, setNextStepIsLoading] = (0, _react.useState)(false);
43
- const [inputValue, setInputValue] = (0, _react.useState)("");
44
- const [options, setOptions] = (0, _react.useState)([]);
45
- const pdlClient = (0, _react.useMemo)(() => new _peopledatalabs.default({
46
- apiKey: pdlApiKey
47
- }), [pdlApiKey]);
48
- const fetchCompanies = async value => {
49
- setNextStepIsLoading(true);
50
- const autocompleteParamsObj = {
51
- field: "company",
52
- text: value || inputValue,
53
- size: 10,
54
- pretty: true
55
- };
56
- return await pdlClient.autocomplete(autocompleteParamsObj).then(_ref2 => {
57
- let {
58
- data
59
- } = _ref2;
60
- const capitalizedCompanyNamesOptions = data.map(_ref3 => {
61
- let {
62
- name
63
- } = _ref3,
64
- otherProps = _objectWithoutProperties(_ref3, _excluded);
65
- return _objectSpread({
66
- name: (0, _formatters.ucFirstLetters)(name)
67
- }, otherProps);
68
- });
69
- setNextStepIsLoading(false);
70
- setOptions(capitalizedCompanyNamesOptions);
71
- return data;
72
- }).catch(() => setOptions([]));
73
- };
74
- const onInputChange = (_, newInputValue) => {
75
- if (newInputValue === "I don't see my company") {
76
- setNextStepIsLoading(false);
77
- return setCompanyName(inputValue);
78
- }
79
- setNextStepIsLoading(false);
80
- setInputValue(newInputValue);
81
- if (newInputValue === "") {
82
- return setOptions([]);
83
- }
84
- return fetchCompanies();
85
- };
86
- const isError = !!inputValue && (0, _otherHelpers.incorrectNameCheck)(inputValue, 60);
87
- return /*#__PURE__*/_react.default.createElement(_material.Grid, {
88
- container: true,
89
- spacing: 1,
90
- direction: "column"
91
- }, /*#__PURE__*/_react.default.createElement(_material.Grid, {
92
- item: true
93
- }, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
94
- id: id || "companies-autocomplete",
95
- freeSolo: true,
96
- options: [...options, "I don't see my company"],
97
- getOptionLabel: option => typeof option === "string" ? option : option.name || "",
98
- filterOptions: option => option,
99
- autoComplete: true,
100
- includeInputInList: true,
101
- disabled: disabled,
102
- renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({
103
- id: "companies-autocomplete-input"
104
- }, params, {
105
- label: label,
106
- variant: variant,
107
- error: isError,
108
- size: size,
109
- autoComplete: "off",
110
- helperText: isError ? "This company name is not valid" : helperText || "",
111
- style: style
112
- }, textFieldProps)),
113
- getOptionSelected: (option, value) => option === "" || option.name === value.name || option === value,
114
- value: inputValue,
115
- onChange: (_, newValue) => {
116
- setOptions(newValue ? [newValue, ...options] : options);
117
- return onSelectCompany(newValue);
118
- },
119
- onInputChange: onInputChange
120
- })), nextStepIsLoading && /*#__PURE__*/_react.default.createElement(_material.Grid, {
121
- item: true
122
- }, /*#__PURE__*/_react.default.createElement(_material.LinearProgress, null)));
123
- };
124
- var _default = exports.default = CompaniesAutocomplete;
@@ -1,125 +0,0 @@
1
- import React, { useState, useMemo } from "react";
2
- import PDLJS from "peopledatalabs";
3
-
4
- import { LinearProgress, TextField, Autocomplete, Grid } from "@mui/material";
5
-
6
- import { ucFirstLetters } from "@aclymatepackages/formatters";
7
- import { incorrectNameCheck } from "@aclymatepackages/other-helpers";
8
-
9
- const CompaniesAutocomplete = ({
10
- setCompanyName,
11
- onSelectCompany,
12
- label,
13
- variant = "outlined",
14
- size = "medium",
15
- disabled,
16
- helperText = "",
17
- id,
18
- style,
19
- textFieldProps,
20
- pdlApiKey,
21
- }) => {
22
- const [nextStepIsLoading, setNextStepIsLoading] = useState(false);
23
- const [inputValue, setInputValue] = useState("");
24
- const [options, setOptions] = useState([]);
25
-
26
- const pdlClient = useMemo(
27
- () =>
28
- new PDLJS({
29
- apiKey: pdlApiKey,
30
- }),
31
- [pdlApiKey]
32
- );
33
-
34
- const fetchCompanies = async (value) => {
35
- setNextStepIsLoading(true);
36
- const autocompleteParamsObj = {
37
- field: "company",
38
- text: value || inputValue,
39
- size: 10,
40
- pretty: true,
41
- };
42
-
43
- return await pdlClient
44
- .autocomplete(autocompleteParamsObj)
45
- .then(({ data }) => {
46
- const capitalizedCompanyNamesOptions = data.map(
47
- ({ name, ...otherProps }) => ({
48
- name: ucFirstLetters(name),
49
- ...otherProps,
50
- })
51
- );
52
- setNextStepIsLoading(false);
53
- setOptions(capitalizedCompanyNamesOptions);
54
- return data;
55
- })
56
- .catch(() => setOptions([]));
57
- };
58
-
59
- const onInputChange = (_, newInputValue) => {
60
- if (newInputValue === "I don't see my company") {
61
- setNextStepIsLoading(false);
62
- return setCompanyName(inputValue);
63
- }
64
-
65
- setNextStepIsLoading(false);
66
- setInputValue(newInputValue);
67
- if (newInputValue === "") {
68
- return setOptions([]);
69
- }
70
-
71
- return fetchCompanies();
72
- };
73
-
74
- const isError = !!inputValue && incorrectNameCheck(inputValue, 60);
75
-
76
- return (
77
- <Grid container spacing={1} direction="column">
78
- <Grid item>
79
- <Autocomplete
80
- id={id || "companies-autocomplete"}
81
- freeSolo
82
- options={[...options, "I don't see my company"]}
83
- getOptionLabel={(option) =>
84
- typeof option === "string" ? option : option.name || ""
85
- }
86
- filterOptions={(option) => option}
87
- autoComplete
88
- includeInputInList
89
- disabled={disabled}
90
- renderInput={(params) => (
91
- <TextField
92
- id="companies-autocomplete-input"
93
- {...params}
94
- label={label}
95
- variant={variant}
96
- error={isError}
97
- size={size}
98
- autoComplete="off"
99
- helperText={
100
- isError ? "This company name is not valid" : helperText || ""
101
- }
102
- style={style}
103
- {...textFieldProps}
104
- />
105
- )}
106
- getOptionSelected={(option, value) =>
107
- option === "" || option.name === value.name || option === value
108
- }
109
- value={inputValue}
110
- onChange={(_, newValue) => {
111
- setOptions(newValue ? [newValue, ...options] : options);
112
- return onSelectCompany(newValue);
113
- }}
114
- onInputChange={onInputChange}
115
- />
116
- </Grid>
117
- {nextStepIsLoading && (
118
- <Grid item>
119
- <LinearProgress />
120
- </Grid>
121
- )}
122
- </Grid>
123
- );
124
- };
125
- export default CompaniesAutocomplete;