@bento-core/table 1.0.1-ccdihub.100 → 1.0.1-ccdihub.101
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/index.js +7 -0
- package/dist/wrapper/components/AddToCart/AddToCartView.js +126 -0
- package/dist/wrapper/components/AddToCart/ReduxAddToCart.js +27 -0
- package/package.json +1 -1
- package/src/index.js +1 -0
- package/src/wrapper/components/AddToCart/AddToCartView.js +132 -0
- package/src/wrapper/components/AddToCart/ReduxAddToCart.js +20 -0
package/dist/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "AddToCart", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _ReduxAddToCart.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "ComponentTypes", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -48,4 +54,5 @@ Object.defineProperty(exports, "headerTypes", {
|
|
|
48
54
|
var _TableView = _interopRequireDefault(require("./TableView"));
|
|
49
55
|
var _Types = require("./util/Types");
|
|
50
56
|
var _Dataformat = require("./util/Dataformat");
|
|
57
|
+
var _ReduxAddToCart = _interopRequireDefault(require("./wrapper/components/AddToCart/ReduxAddToCart"));
|
|
51
58
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.ToolTipView = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _toolTip = _interopRequireDefault(require("@bento-core/tool-tip"));
|
|
9
|
+
var _core = require("@material-ui/core");
|
|
10
|
+
var _Snackbar = _interopRequireDefault(require("../Snackbar/Snackbar"));
|
|
11
|
+
var _AddToCartDialogAlertView = _interopRequireDefault(require("../AddToCartDialog/AddToCartDialogAlertView"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
const customTooltip = {
|
|
16
|
+
border: '#03A383 1px solid'
|
|
17
|
+
};
|
|
18
|
+
const customArrow = {
|
|
19
|
+
'&::before': {
|
|
20
|
+
border: '#03A383 1px solid'
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const iconStyle = {
|
|
24
|
+
paddingRight: '20px',
|
|
25
|
+
paddingBottom: '20px',
|
|
26
|
+
paddingLeft: '5px'
|
|
27
|
+
};
|
|
28
|
+
const ToolTipView = props => {
|
|
29
|
+
const {
|
|
30
|
+
section,
|
|
31
|
+
tooltipCofig
|
|
32
|
+
} = props;
|
|
33
|
+
const {
|
|
34
|
+
icon,
|
|
35
|
+
src,
|
|
36
|
+
alt,
|
|
37
|
+
arrow = false,
|
|
38
|
+
tooltipText
|
|
39
|
+
} = tooltipCofig;
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement(_toolTip.default, {
|
|
41
|
+
placement: "top",
|
|
42
|
+
title: tooltipText || "".concat(tooltipCofig[section]),
|
|
43
|
+
arrow: arrow,
|
|
44
|
+
classes: {
|
|
45
|
+
tooltip: customTooltip,
|
|
46
|
+
arrow: customArrow
|
|
47
|
+
}
|
|
48
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
49
|
+
src: icon || src,
|
|
50
|
+
alt: alt,
|
|
51
|
+
style: iconStyle
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// const checkDuplicate = (cartFiles, ids) => {
|
|
56
|
+
// const newIds = [];
|
|
57
|
+
// for (let i = 0; i < ids.length; i += 1) {
|
|
58
|
+
// if (!cartFiles.includes(ids[i])) {
|
|
59
|
+
// newIds.push(ids[i]);
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
62
|
+
// return newIds;
|
|
63
|
+
// };
|
|
64
|
+
exports.ToolTipView = ToolTipView;
|
|
65
|
+
const checkDuplicate = (cartFiles, ids) => ids.filter(id => !cartFiles[id]);
|
|
66
|
+
const AddToCartView = props => {
|
|
67
|
+
const {
|
|
68
|
+
cartFiles,
|
|
69
|
+
fileId,
|
|
70
|
+
buttonStyle,
|
|
71
|
+
addFiles,
|
|
72
|
+
count
|
|
73
|
+
} = props;
|
|
74
|
+
|
|
75
|
+
// const [isDataloading, setIsDataloading] = useState(false);
|
|
76
|
+
const [openSnackbar, setOpenSnackbar] = (0, _react.useState)(false);
|
|
77
|
+
const [displayAlter, setAlterDisplay] = (0, _react.useState)(false);
|
|
78
|
+
const cartFilesDict = {};
|
|
79
|
+
cartFiles.forEach(file => {
|
|
80
|
+
cartFilesDict[file] = true;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// const backdropCls = {
|
|
84
|
+
// width: '100%',
|
|
85
|
+
// zIndex: 99999,
|
|
86
|
+
// background: 'rgba(0, 0, 0, 0.1)',
|
|
87
|
+
// };
|
|
88
|
+
/**
|
|
89
|
+
* verify and set file ids
|
|
90
|
+
*/
|
|
91
|
+
const addAllFiles = () => {
|
|
92
|
+
const idsInitial = fileId || [];
|
|
93
|
+
const ids = [idsInitial];
|
|
94
|
+
const fileCount = ids.length;
|
|
95
|
+
const upperLimit = 200000;
|
|
96
|
+
const cartCount = cartFiles.length;
|
|
97
|
+
if (fileCount <= upperLimit && cartCount < upperLimit) {
|
|
98
|
+
const newIds = checkDuplicate(cartFiles, ids);
|
|
99
|
+
if (cartCount + newIds.length <= upperLimit) {
|
|
100
|
+
addFiles(newIds);
|
|
101
|
+
setOpenSnackbar(true);
|
|
102
|
+
} else {
|
|
103
|
+
setAlterDisplay(true);
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
setAlterDisplay(true);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
110
|
+
variant: "outlined",
|
|
111
|
+
onClick: addAllFiles,
|
|
112
|
+
disableRipple: true,
|
|
113
|
+
style: buttonStyle,
|
|
114
|
+
disabled: false
|
|
115
|
+
}, "ADD TO CART"), /*#__PURE__*/_react.default.createElement(_Snackbar.default, {
|
|
116
|
+
open: openSnackbar,
|
|
117
|
+
count: count,
|
|
118
|
+
onClose: () => setOpenSnackbar(false)
|
|
119
|
+
}), displayAlter && /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
|
|
120
|
+
alertMessage: "The cart is limited to 200,000 files. Please narrow the search criteria or remove some files from the cart to add more.",
|
|
121
|
+
open: displayAlter,
|
|
122
|
+
onClose: () => setAlterDisplay(false)
|
|
123
|
+
}));
|
|
124
|
+
};
|
|
125
|
+
var _default = AddToCartView;
|
|
126
|
+
exports.default = _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactRedux = require("react-redux");
|
|
9
|
+
var _cart = require("@bento-core/cart");
|
|
10
|
+
var _AddToCartView = _interopRequireDefault(require("./AddToCartView"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
const AddToCartRedux = props => /*#__PURE__*/_react.default.createElement(_AddToCartView.default, props);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* create query variable with actie filters
|
|
16
|
+
*/
|
|
17
|
+
const mapStateToProps = state => ({
|
|
18
|
+
count: state.cartReducer && state.cartReducer.count,
|
|
19
|
+
cartFiles: state.cartReducer && state.cartReducer.filesId
|
|
20
|
+
});
|
|
21
|
+
const mapDispatchToProps = dispatch => ({
|
|
22
|
+
addFiles: files => {
|
|
23
|
+
dispatch((0, _cart.onAddCartFiles)(files));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(AddToCartRedux);
|
|
27
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/table",
|
|
3
|
-
"version": "1.0.1-ccdihub.
|
|
3
|
+
"version": "1.0.1-ccdihub.101",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import ToolTip from '@bento-core/tool-tip';
|
|
3
|
+
import { Button } from '@material-ui/core';
|
|
4
|
+
import SnackbarView from '../Snackbar/Snackbar';
|
|
5
|
+
import AlertView from '../AddToCartDialog/AddToCartDialogAlertView';
|
|
6
|
+
|
|
7
|
+
const customTooltip = {
|
|
8
|
+
border: '#03A383 1px solid',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const customArrow = {
|
|
12
|
+
'&::before': {
|
|
13
|
+
border: '#03A383 1px solid',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const iconStyle = {
|
|
18
|
+
paddingRight: '20px',
|
|
19
|
+
paddingBottom: '20px',
|
|
20
|
+
paddingLeft: '5px',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const ToolTipView = (props) => {
|
|
24
|
+
const {
|
|
25
|
+
section,
|
|
26
|
+
tooltipCofig,
|
|
27
|
+
} = props;
|
|
28
|
+
const {
|
|
29
|
+
icon,
|
|
30
|
+
src,
|
|
31
|
+
alt,
|
|
32
|
+
arrow = false,
|
|
33
|
+
tooltipText,
|
|
34
|
+
} = tooltipCofig;
|
|
35
|
+
return (
|
|
36
|
+
<ToolTip
|
|
37
|
+
placement="top"
|
|
38
|
+
title={tooltipText || `${tooltipCofig[section]}`}
|
|
39
|
+
arrow={arrow}
|
|
40
|
+
classes={{
|
|
41
|
+
tooltip: customTooltip,
|
|
42
|
+
arrow: customArrow,
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<img src={icon || src} alt={alt} style={iconStyle} />
|
|
46
|
+
</ToolTip>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// const checkDuplicate = (cartFiles, ids) => {
|
|
51
|
+
// const newIds = [];
|
|
52
|
+
// for (let i = 0; i < ids.length; i += 1) {
|
|
53
|
+
// if (!cartFiles.includes(ids[i])) {
|
|
54
|
+
// newIds.push(ids[i]);
|
|
55
|
+
// }
|
|
56
|
+
// }
|
|
57
|
+
// return newIds;
|
|
58
|
+
// };
|
|
59
|
+
|
|
60
|
+
const checkDuplicate = (cartFiles, ids) => (ids.filter((id) => !cartFiles[id]));
|
|
61
|
+
|
|
62
|
+
const AddToCartView = (props) => {
|
|
63
|
+
const {
|
|
64
|
+
cartFiles,
|
|
65
|
+
fileId,
|
|
66
|
+
buttonStyle,
|
|
67
|
+
addFiles,
|
|
68
|
+
count,
|
|
69
|
+
} = props;
|
|
70
|
+
|
|
71
|
+
// const [isDataloading, setIsDataloading] = useState(false);
|
|
72
|
+
const [openSnackbar, setOpenSnackbar] = useState(false);
|
|
73
|
+
const [displayAlter, setAlterDisplay] = useState(false);
|
|
74
|
+
|
|
75
|
+
const cartFilesDict = {};
|
|
76
|
+
cartFiles.forEach((file) => { cartFilesDict[file] = true; });
|
|
77
|
+
|
|
78
|
+
// const backdropCls = {
|
|
79
|
+
// width: '100%',
|
|
80
|
+
// zIndex: 99999,
|
|
81
|
+
// background: 'rgba(0, 0, 0, 0.1)',
|
|
82
|
+
// };
|
|
83
|
+
/**
|
|
84
|
+
* verify and set file ids
|
|
85
|
+
*/
|
|
86
|
+
const addAllFiles = () => {
|
|
87
|
+
const idsInitial = fileId || [];
|
|
88
|
+
const ids = [idsInitial];
|
|
89
|
+
const fileCount = ids.length;
|
|
90
|
+
const upperLimit = 200000;
|
|
91
|
+
const cartCount = cartFiles.length;
|
|
92
|
+
if (fileCount <= upperLimit && cartCount < upperLimit) {
|
|
93
|
+
const newIds = checkDuplicate(cartFiles, ids);
|
|
94
|
+
if (cartCount + newIds.length <= upperLimit) {
|
|
95
|
+
addFiles(newIds);
|
|
96
|
+
setOpenSnackbar(true);
|
|
97
|
+
} else {
|
|
98
|
+
setAlterDisplay(true);
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
setAlterDisplay(true);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<>
|
|
107
|
+
<Button
|
|
108
|
+
variant="outlined"
|
|
109
|
+
onClick={addAllFiles}
|
|
110
|
+
disableRipple
|
|
111
|
+
style={buttonStyle}
|
|
112
|
+
disabled={false}
|
|
113
|
+
>
|
|
114
|
+
ADD TO CART
|
|
115
|
+
</Button>
|
|
116
|
+
<SnackbarView
|
|
117
|
+
open={openSnackbar}
|
|
118
|
+
count={count}
|
|
119
|
+
onClose={() => setOpenSnackbar(false)}
|
|
120
|
+
/>
|
|
121
|
+
{displayAlter && (
|
|
122
|
+
<AlertView
|
|
123
|
+
alertMessage="The cart is limited to 200,000 files. Please narrow the search criteria or remove some files from the cart to add more."
|
|
124
|
+
open={displayAlter}
|
|
125
|
+
onClose={() => setAlterDisplay(false)}
|
|
126
|
+
/>
|
|
127
|
+
)}
|
|
128
|
+
</>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default AddToCartView;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import { onAddCartFiles } from '@bento-core/cart';
|
|
4
|
+
import AddToCartView from './AddToCartView';
|
|
5
|
+
|
|
6
|
+
const AddToCartRedux = (props) => <AddToCartView {...props} />;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* create query variable with actie filters
|
|
10
|
+
*/
|
|
11
|
+
const mapStateToProps = (state) => ({
|
|
12
|
+
count: state.cartReducer && state.cartReducer.count,
|
|
13
|
+
cartFiles: state.cartReducer && state.cartReducer.filesId,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const mapDispatchToProps = (dispatch) => ({
|
|
17
|
+
addFiles: (files) => { dispatch(onAddCartFiles(files)); },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export default connect(mapStateToProps, mapDispatchToProps)(AddToCartRedux);
|