@aclymatepackages/modules 3.0.8 → 4.0.1

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.
@@ -1,20 +1,18 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.weak-map.js");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
7
  require("core-js/modules/es.promise.js");
9
8
  require("core-js/modules/web.dom-collections.iterator.js");
10
- var _react = _interopRequireWildcard(require("react"));
9
+ var _react = require("react");
11
10
  var _material = require("@mui/material");
12
11
  var _Search = _interopRequireDefault(require("@mui/icons-material/Search"));
13
12
  var _atoms = require("@aclymatepackages/atoms");
13
+ var _themes = require("@aclymatepackages/themes");
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- 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); }
16
- 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; }
17
- const PdlCompanySelect = _ref => {
15
+ const DbCompanySelect = _ref => {
18
16
  let {
19
17
  onCompanyNotFound,
20
18
  onCompanySelected,
@@ -46,13 +44,15 @@ const PdlCompanySelect = _ref => {
46
44
  await onCompanySelected(companyId, name);
47
45
  return onSelectClick();
48
46
  };
49
- return /*#__PURE__*/_react.default.createElement(_material.Grid, {
47
+ return /*#__PURE__*/React.createElement(_material.ThemeProvider, {
48
+ theme: _themes.mainTheme
49
+ }, /*#__PURE__*/React.createElement(_material.Grid, {
50
50
  container: true,
51
51
  spacing: 2,
52
52
  direction: "column"
53
- }, /*#__PURE__*/_react.default.createElement(_material.Grid, {
53
+ }, /*#__PURE__*/React.createElement(_material.Grid, {
54
54
  item: true
55
- }, /*#__PURE__*/_react.default.createElement(_atoms.TextField, {
55
+ }, /*#__PURE__*/React.createElement(_atoms.TextField, {
56
56
  disabled: pdlFetchLoading,
57
57
  label: label,
58
58
  value: inputValue,
@@ -67,47 +67,47 @@ const PdlCompanySelect = _ref => {
67
67
  },
68
68
  helperText: helperText || "Press enter or click the search icon to search for matching companies",
69
69
  InputProps: {
70
- endAdornment: /*#__PURE__*/_react.default.createElement(_material.InputAdornment, null, /*#__PURE__*/_react.default.createElement(_material.IconButton, {
70
+ endAdornment: /*#__PURE__*/React.createElement(_material.InputAdornment, null, /*#__PURE__*/React.createElement(_material.IconButton, {
71
71
  disabled: pdlFetchLoading,
72
72
  onClick: fetchMatchingCompanies
73
- }, pdlFetchLoading ? /*#__PURE__*/_react.default.createElement(_material.CircularProgress, {
73
+ }, pdlFetchLoading ? /*#__PURE__*/React.createElement(_material.CircularProgress, {
74
74
  size: 20
75
- }) : /*#__PURE__*/_react.default.createElement(_Search.default, null)))
75
+ }) : /*#__PURE__*/React.createElement(_Search.default, null)))
76
76
  }
77
- })), /*#__PURE__*/_react.default.createElement(_material.Grid, {
77
+ })), /*#__PURE__*/React.createElement(_material.Grid, {
78
78
  item: true,
79
79
  container: true,
80
80
  justifyContent: "center"
81
- }), inputComplete && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_material.Grid, {
81
+ }), inputComplete && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_material.Grid, {
82
82
  item: true
83
- }, /*#__PURE__*/_react.default.createElement(_material.Typography, {
83
+ }, /*#__PURE__*/React.createElement(_material.Typography, {
84
84
  variant: "h6",
85
85
  align: "center"
86
- }, actionLabel)), /*#__PURE__*/_react.default.createElement(_material.Grid, {
86
+ }, actionLabel)), /*#__PURE__*/React.createElement(_material.Grid, {
87
87
  item: true
88
- }, /*#__PURE__*/_react.default.createElement(_atoms.MatchingCompanyChips, {
88
+ }, /*#__PURE__*/React.createElement(_atoms.MatchingCompanyChips, {
89
89
  matchingCompanies: matchingCompanies,
90
90
  selectedCompany: selectedCompany,
91
91
  setSelectedCompany: setSelectedCompany
92
- })), /*#__PURE__*/_react.default.createElement(_material.Grid, {
92
+ })), /*#__PURE__*/React.createElement(_material.Grid, {
93
93
  item: true,
94
94
  container: true,
95
95
  spacing: 2,
96
96
  justifyContent: "center"
97
- }, /*#__PURE__*/_react.default.createElement(_material.Grid, {
97
+ }, /*#__PURE__*/React.createElement(_material.Grid, {
98
98
  item: true
99
- }, selectedCompany ? /*#__PURE__*/_react.default.createElement(_atoms.LoadingButton, {
99
+ }, selectedCompany ? /*#__PURE__*/React.createElement(_atoms.LoadingButton, {
100
100
  isLoading: nextStepLoading,
101
101
  label: "Choose This Company",
102
102
  variant: "contained",
103
103
  color: "secondary",
104
104
  onClick: () => onSelectCompany(selectedCompany)
105
- }) : /*#__PURE__*/_react.default.createElement(_atoms.LoadingButton, {
105
+ }) : /*#__PURE__*/React.createElement(_atoms.LoadingButton, {
106
106
  isLoading: nextStepLoading,
107
107
  color: "primary",
108
108
  onClick: () => onSelectCompany("none", inputValue),
109
109
  label: "I don't see my company",
110
110
  variant: "text"
111
- })))));
111
+ }))))));
112
112
  };
113
- var _default = exports.default = PdlCompanySelect;
113
+ var _default = exports.default = DbCompanySelect;
package/dist/index.js CHANGED
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "ComparisonChart", {
21
21
  return _ComparisonChart.default;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "DbCompanySelect", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _DbCompanySelect.default;
28
+ }
29
+ });
24
30
  Object.defineProperty(exports, "EmissionsPieChart", {
25
31
  enumerable: true,
26
32
  get: function get() {
@@ -57,12 +63,6 @@ Object.defineProperty(exports, "IndustryAutocomplete", {
57
63
  return _IndustryAutocomplete.default;
58
64
  }
59
65
  });
60
- Object.defineProperty(exports, "PdlCompanySelect", {
61
- enumerable: true,
62
- get: function get() {
63
- return _PdlCompanySelect.default;
64
- }
65
- });
66
66
  Object.defineProperty(exports, "PlacesAutocomplete", {
67
67
  enumerable: true,
68
68
  get: function get() {
@@ -93,5 +93,5 @@ var _CompanyOnboardingInput = _interopRequireDefault(require("./components/Compa
93
93
  var _EmissionsPieChart = _interopRequireDefault(require("./components/EmissionsPieChart"));
94
94
  var _useChartWarningLabels = _interopRequireDefault(require("./components/useChartWarningLabels"));
95
95
  var _EmissionsSummarySentence = _interopRequireDefault(require("./components/EmissionsSummarySentence"));
96
- var _PdlCompanySelect = _interopRequireDefault(require("./components/PdlCompanySelect"));
96
+ var _DbCompanySelect = _interopRequireDefault(require("./components/DbCompanySelect"));
97
97
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aclymatepackages/modules",
3
- "version": "3.0.8",
3
+ "version": "4.0.1",
4
4
  "description": "Aclymate modules",
5
5
  "author": "William Loopesko",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,136 @@
1
+ import { useState } from "react";
2
+
3
+ import {
4
+ Grid,
5
+ InputAdornment,
6
+ CircularProgress,
7
+ IconButton,
8
+ Typography,
9
+ ThemeProvider,
10
+ } from "@mui/material";
11
+ import SearchIcon from "@mui/icons-material/Search";
12
+
13
+ import {
14
+ TextField,
15
+ LoadingButton,
16
+ MatchingCompanyChips,
17
+ } from "@aclymatepackages/atoms";
18
+
19
+ import { mainTheme } from "@aclymatepackages/themes";
20
+
21
+ const DbCompanySelect = ({
22
+ onCompanyNotFound,
23
+ onCompanySelected,
24
+ onSelectClick = () => {},
25
+ matchingFunction,
26
+ label = "Enter your company's name",
27
+ actionLabel = "Please select your company from these options",
28
+ helperText,
29
+ }) => {
30
+ const [inputValue, setInputValue] = useState("");
31
+ const [matchingCompanies, setMatchingCompanies] = useState([]);
32
+ const [inputComplete, setInputComplete] = useState(false);
33
+ const [pdlFetchLoading, setPdlFetchLoading] = useState(false);
34
+ const [nextStepLoading, setNextStepLoading] = useState(false);
35
+ const [selectedCompany, setSelectedCompany] = useState(null);
36
+
37
+ const fetchMatchingCompanies = async () => {
38
+ setPdlFetchLoading(true);
39
+
40
+ const matchingCompanies = await matchingFunction(inputValue);
41
+
42
+ setPdlFetchLoading(false);
43
+ setMatchingCompanies(matchingCompanies);
44
+ return setInputComplete(true);
45
+ };
46
+
47
+ const onSelectCompany = async (companyId, name) => {
48
+ setNextStepLoading(true);
49
+ if (!companyId || companyId === "none") {
50
+ await onCompanyNotFound(name);
51
+ return onSelectClick();
52
+ }
53
+
54
+ await onCompanySelected(companyId, name);
55
+ return onSelectClick();
56
+ };
57
+
58
+ return (
59
+ <ThemeProvider theme={mainTheme}>
60
+ <Grid container spacing={2} direction="column">
61
+ <Grid item>
62
+ <TextField
63
+ disabled={pdlFetchLoading}
64
+ label={label}
65
+ value={inputValue}
66
+ setValue={setInputValue}
67
+ onKeyPress={({ key }) => {
68
+ if (key === "Enter") {
69
+ return fetchMatchingCompanies();
70
+ }
71
+ }}
72
+ helperText={
73
+ helperText ||
74
+ "Press enter or click the search icon to search for matching companies"
75
+ }
76
+ InputProps={{
77
+ endAdornment: (
78
+ <InputAdornment>
79
+ <IconButton
80
+ disabled={pdlFetchLoading}
81
+ onClick={fetchMatchingCompanies}
82
+ >
83
+ {pdlFetchLoading ? (
84
+ <CircularProgress size={20} />
85
+ ) : (
86
+ <SearchIcon />
87
+ )}
88
+ </IconButton>
89
+ </InputAdornment>
90
+ ),
91
+ }}
92
+ />
93
+ </Grid>
94
+ <Grid item container justifyContent="center"></Grid>
95
+ {inputComplete && (
96
+ <>
97
+ <Grid item>
98
+ <Typography variant="h6" align="center">
99
+ {actionLabel}
100
+ </Typography>
101
+ </Grid>
102
+ <Grid item>
103
+ <MatchingCompanyChips
104
+ matchingCompanies={matchingCompanies}
105
+ selectedCompany={selectedCompany}
106
+ setSelectedCompany={setSelectedCompany}
107
+ />
108
+ </Grid>
109
+ <Grid item container spacing={2} justifyContent="center">
110
+ <Grid item>
111
+ {selectedCompany ? (
112
+ <LoadingButton
113
+ isLoading={nextStepLoading}
114
+ label="Choose This Company"
115
+ variant="contained"
116
+ color="secondary"
117
+ onClick={() => onSelectCompany(selectedCompany)}
118
+ />
119
+ ) : (
120
+ <LoadingButton
121
+ isLoading={nextStepLoading}
122
+ color="primary"
123
+ onClick={() => onSelectCompany("none", inputValue)}
124
+ label="I don't see my company"
125
+ variant="text"
126
+ />
127
+ )}
128
+ </Grid>
129
+ </Grid>
130
+ </>
131
+ )}
132
+ </Grid>
133
+ </ThemeProvider>
134
+ );
135
+ };
136
+ export default DbCompanySelect;
package/src/index.js CHANGED
@@ -10,7 +10,7 @@ import CompanyOnboardingInput from "./components/CompanyOnboardingInput";
10
10
  import EmissionsPieChart from "./components/EmissionsPieChart";
11
11
  import useChartWarningLabels from "./components/useChartWarningLabels";
12
12
  import EmissionsSummarySentence from "./components/EmissionsSummarySentence";
13
- import PdlCompanySelect from "./components/PdlCompanySelect";
13
+ import DbCompanySelect from "./components/DbCompanySelect";
14
14
 
15
15
  export {
16
16
  AccountingChart,
@@ -25,5 +25,5 @@ export {
25
25
  EmissionsPieChart,
26
26
  useChartWarningLabels,
27
27
  EmissionsSummarySentence,
28
- PdlCompanySelect,
28
+ DbCompanySelect,
29
29
  };
@@ -1,131 +0,0 @@
1
- import React, { useState } from "react";
2
-
3
- import {
4
- Grid,
5
- InputAdornment,
6
- CircularProgress,
7
- IconButton,
8
- Typography,
9
- } from "@mui/material";
10
- import SearchIcon from "@mui/icons-material/Search";
11
-
12
- import {
13
- TextField,
14
- LoadingButton,
15
- MatchingCompanyChips,
16
- } from "@aclymatepackages/atoms";
17
-
18
- const PdlCompanySelect = ({
19
- onCompanyNotFound,
20
- onCompanySelected,
21
- onSelectClick = () => {},
22
- matchingFunction,
23
- label = "Enter your company's name",
24
- actionLabel = "Please select your company from these options",
25
- helperText,
26
- }) => {
27
- const [inputValue, setInputValue] = useState("");
28
- const [matchingCompanies, setMatchingCompanies] = useState([]);
29
- const [inputComplete, setInputComplete] = useState(false);
30
- const [pdlFetchLoading, setPdlFetchLoading] = useState(false);
31
- const [nextStepLoading, setNextStepLoading] = useState(false);
32
- const [selectedCompany, setSelectedCompany] = useState(null);
33
-
34
- const fetchMatchingCompanies = async () => {
35
- setPdlFetchLoading(true);
36
-
37
- const matchingCompanies = await matchingFunction(inputValue);
38
-
39
- setPdlFetchLoading(false);
40
- setMatchingCompanies(matchingCompanies);
41
- return setInputComplete(true);
42
- };
43
-
44
- const onSelectCompany = async (companyId, name) => {
45
- setNextStepLoading(true);
46
- if (!companyId || companyId === "none") {
47
- await onCompanyNotFound(name);
48
- return onSelectClick();
49
- }
50
-
51
- await onCompanySelected(companyId, name);
52
- return onSelectClick();
53
- };
54
-
55
- return (
56
- <Grid container spacing={2} direction="column">
57
- <Grid item>
58
- <TextField
59
- disabled={pdlFetchLoading}
60
- label={label}
61
- value={inputValue}
62
- setValue={setInputValue}
63
- onKeyPress={({ key }) => {
64
- if (key === "Enter") {
65
- return fetchMatchingCompanies();
66
- }
67
- }}
68
- helperText={
69
- helperText ||
70
- "Press enter or click the search icon to search for matching companies"
71
- }
72
- InputProps={{
73
- endAdornment: (
74
- <InputAdornment>
75
- <IconButton
76
- disabled={pdlFetchLoading}
77
- onClick={fetchMatchingCompanies}
78
- >
79
- {pdlFetchLoading ? (
80
- <CircularProgress size={20} />
81
- ) : (
82
- <SearchIcon />
83
- )}
84
- </IconButton>
85
- </InputAdornment>
86
- ),
87
- }}
88
- />
89
- </Grid>
90
- <Grid item container justifyContent="center"></Grid>
91
- {inputComplete && (
92
- <>
93
- <Grid item>
94
- <Typography variant="h6" align="center">
95
- {actionLabel}
96
- </Typography>
97
- </Grid>
98
- <Grid item>
99
- <MatchingCompanyChips
100
- matchingCompanies={matchingCompanies}
101
- selectedCompany={selectedCompany}
102
- setSelectedCompany={setSelectedCompany}
103
- />
104
- </Grid>
105
- <Grid item container spacing={2} justifyContent="center">
106
- <Grid item>
107
- {selectedCompany ? (
108
- <LoadingButton
109
- isLoading={nextStepLoading}
110
- label="Choose This Company"
111
- variant="contained"
112
- color="secondary"
113
- onClick={() => onSelectCompany(selectedCompany)}
114
- />
115
- ) : (
116
- <LoadingButton
117
- isLoading={nextStepLoading}
118
- color="primary"
119
- onClick={() => onSelectCompany("none", inputValue)}
120
- label="I don't see my company"
121
- variant="text"
122
- />
123
- )}
124
- </Grid>
125
- </Grid>
126
- </>
127
- )}
128
- </Grid>
129
- );
130
- };
131
- export default PdlCompanySelect;