@vendorflow/components 2.0.71 → 2.0.74
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/lib/components/material-ui/AudioPlayer/AudioPlayer.d.ts +3 -2
- package/lib/components/material-ui/AudioPlayer/AudioPlayer.js +2 -2
- package/lib/components/material-ui/AudioPlayer/AudioPlayer.story.js +1 -1
- package/lib/components/material-ui/DataTable/Data.js +1 -1
- package/lib/components/material-ui/DataTable/DataTable.d.ts +7 -3
- package/lib/components/material-ui/DataTable/DataTable.js +71 -66
- package/lib/components/material-ui/DataTable/DataTable.story.js +11 -2
- package/lib/components/material-ui/DataTable/SortIndicator.js +2 -2
- package/lib/components/material-ui/DataTable/TablePieces/AppliedFilters.d.ts +12 -0
- package/lib/components/material-ui/DataTable/TablePieces/AppliedFilters.js +26 -0
- package/lib/components/material-ui/DataTable/TablePieces/BodyCell.d.ts +10 -0
- package/lib/components/material-ui/DataTable/TablePieces/BodyCell.js +49 -0
- package/lib/components/material-ui/DataTable/TablePieces/BodyRow.d.ts +15 -0
- package/lib/components/material-ui/DataTable/TablePieces/BodyRow.js +88 -0
- package/lib/components/material-ui/DataTable/TablePieces/GlobalSearchFilter.d.ts +10 -0
- package/lib/components/material-ui/DataTable/TablePieces/GlobalSearchFilter.js +49 -0
- package/lib/components/material-ui/DataTable/TablePieces/HeaderCell.d.ts +12 -0
- package/lib/components/material-ui/DataTable/TablePieces/HeaderCell.js +53 -0
- package/lib/components/material-ui/DataTable/TablePieces/IndeterminateCheckbox.d.ts +4 -0
- package/lib/components/material-ui/DataTable/TablePieces/IndeterminateCheckbox.js +65 -0
- package/lib/components/material-ui/DataTable/TablePieces/SortIndicator.d.ts +10 -0
- package/lib/components/material-ui/DataTable/TablePieces/SortIndicator.js +33 -0
- package/lib/components/material-ui/DataTable/TablePieces/Table.d.ts +12 -0
- package/lib/components/material-ui/DataTable/TablePieces/Table.js +47 -0
- package/lib/components/material-ui/DataTable/TablePieces/TableBodyContent.d.ts +25 -0
- package/lib/components/material-ui/DataTable/TablePieces/TableBodyContent.js +71 -0
- package/lib/components/material-ui/DataTable/TablePieces/Toolbar.d.ts +24 -0
- package/lib/components/material-ui/DataTable/TablePieces/Toolbar.js +63 -0
- package/lib/components/material-ui/DataTable/TablePieces/ViewColumnTool.d.ts +11 -0
- package/lib/components/material-ui/DataTable/TablePieces/ViewColumnTool.js +76 -0
- package/lib/components/material-ui/DataTable/Utils.d.ts +25 -0
- package/lib/components/material-ui/DataTable/Utils.js +119 -0
- package/lib/components/material-ui/Modal/Modal.d.ts +1 -0
- package/lib/components/material-ui/Modal/Modal.js +13 -7
- package/lib/components/material-ui/Modal/Modal.story.js +30 -3
- package/package.json +5 -2
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
var react_1 = require("react");
|
|
23
|
+
var short_uuid_1 = __importDefault(require("short-uuid"));
|
|
24
|
+
var server_1 = require("react-dom/server");
|
|
25
|
+
var resize_observer_polyfill_1 = __importDefault(require("resize-observer-polyfill"));
|
|
26
|
+
/**
|
|
27
|
+
* This custom hook is designed to replace the `<CellMeasurer />` component in `react-virtualized`
|
|
28
|
+
* in `react-window`
|
|
29
|
+
*
|
|
30
|
+
* This hook returns props to be given to the `<VariableSizeList />` component in `react-window`
|
|
31
|
+
*
|
|
32
|
+
* `items` are react elements
|
|
33
|
+
*/
|
|
34
|
+
function useCellMeasurer(_a) {
|
|
35
|
+
var items = _a.items, renderItem = _a.renderItem;
|
|
36
|
+
// create a ref to get the `div` element the `VariableSizeList` uses
|
|
37
|
+
var innerRef = (0, react_1.useRef)(null);
|
|
38
|
+
// create a unique ID for this cell measurer instance
|
|
39
|
+
var id = (0, react_1.useMemo)(function () { return short_uuid_1.default.generate(); }, []);
|
|
40
|
+
// create a "hidden sizing element" in state.
|
|
41
|
+
//
|
|
42
|
+
// when the innerRef element mounts, the width of the innerRef will be used for width of
|
|
43
|
+
// the hidden sizing element
|
|
44
|
+
var _b = __read((0, react_1.useState)(null), 2), hiddenSizingEl = _b[0], setHiddenSizingEl = _b[1];
|
|
45
|
+
// this width is used to determine whether the list needs to be re-rendered due to a resize
|
|
46
|
+
var _c = __read((0, react_1.useState)(0), 2), width = _c[0], setWidth = _c[1];
|
|
47
|
+
// `itemSize` is a function required by `VariableSizeList`. This function is called when it needs
|
|
48
|
+
// to get the height of the item inside it.
|
|
49
|
+
// note: the result of this function is memoized by `react-window` so it will only be called once
|
|
50
|
+
// to get the item size
|
|
51
|
+
var itemSize = (0, react_1.useCallback)(function (index) {
|
|
52
|
+
if (!hiddenSizingEl)
|
|
53
|
+
return 0;
|
|
54
|
+
// get the item (which is a react node)
|
|
55
|
+
var item = items[index];
|
|
56
|
+
// then render the react node to a string synchronously with `react-dom/server`
|
|
57
|
+
hiddenSizingEl.innerHTML = (0, server_1.renderToString)(renderItem(item));
|
|
58
|
+
// get and return the size of the hidden sizing element
|
|
59
|
+
return hiddenSizingEl.clientHeight || 0;
|
|
60
|
+
}, [hiddenSizingEl, items]);
|
|
61
|
+
// this effects adds the hidden sizing element to the DOM
|
|
62
|
+
(0, react_1.useEffect)(function () {
|
|
63
|
+
/** @type {HTMLElement} */
|
|
64
|
+
var innerEl = innerRef.current;
|
|
65
|
+
if (!innerEl)
|
|
66
|
+
return;
|
|
67
|
+
if (hiddenSizingEl)
|
|
68
|
+
return;
|
|
69
|
+
var newHiddenSizingEl = document.createElement('div');
|
|
70
|
+
var width = innerEl.clientWidth;
|
|
71
|
+
newHiddenSizingEl.classList.add("hidden-sizing-element-" + id);
|
|
72
|
+
newHiddenSizingEl.style.position = 'absolute';
|
|
73
|
+
newHiddenSizingEl.style.top = '0';
|
|
74
|
+
newHiddenSizingEl.style.width = width + "px";
|
|
75
|
+
newHiddenSizingEl.style.pointerEvents = 'none';
|
|
76
|
+
newHiddenSizingEl.style.visibility = 'hidden';
|
|
77
|
+
setHiddenSizingEl(newHiddenSizingEl);
|
|
78
|
+
document.body.appendChild(newHiddenSizingEl);
|
|
79
|
+
}, [hiddenSizingEl, id]);
|
|
80
|
+
// this removes all hidden sizing elements on unmount
|
|
81
|
+
(0, react_1.useEffect)(function () {
|
|
82
|
+
// returning a function from `useEffect` is the "clean-up" phase
|
|
83
|
+
return function () {
|
|
84
|
+
var hiddenSizingElement = document.querySelector(".hidden-sizing-element-" + id);
|
|
85
|
+
if (hiddenSizingElement) {
|
|
86
|
+
document.body.removeChild(hiddenSizingElement);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}, [id]);
|
|
90
|
+
// this is used to watch for changes in the size of the list element and sets the width
|
|
91
|
+
(0, react_1.useEffect)(function () {
|
|
92
|
+
var el = innerRef.current;
|
|
93
|
+
if (!el)
|
|
94
|
+
return;
|
|
95
|
+
function handleResize() {
|
|
96
|
+
var width = ((el === null || el === void 0 ? void 0 : el.getBoundingClientRect()) || { width: 0 }).width;
|
|
97
|
+
setWidth(width);
|
|
98
|
+
}
|
|
99
|
+
var resizeObserver = new resize_observer_polyfill_1.default(handleResize);
|
|
100
|
+
resizeObserver.observe(el);
|
|
101
|
+
return function () { return resizeObserver.disconnect(); };
|
|
102
|
+
}, []);
|
|
103
|
+
// this key is used to re-render the list when the dependencies array changes
|
|
104
|
+
var key = (0, react_1.useMemo)(function () { return short_uuid_1.default.generate(); }, [itemSize, hiddenSizingEl, width]);
|
|
105
|
+
// while there is no hidden sizing element, hide the list element
|
|
106
|
+
var style = hiddenSizingEl
|
|
107
|
+
? {}
|
|
108
|
+
: {
|
|
109
|
+
visibility: 'hidden',
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
innerRef: innerRef,
|
|
113
|
+
itemSize: itemSize,
|
|
114
|
+
itemCount: items.length,
|
|
115
|
+
key: key,
|
|
116
|
+
style: style,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
exports.default = useCellMeasurer;
|
|
@@ -35,16 +35,22 @@ var react_1 = require("@emotion/react");
|
|
|
35
35
|
var material_1 = require("@mui/material");
|
|
36
36
|
var Button_1 = __importDefault(require("../Button"));
|
|
37
37
|
function Modal(props) {
|
|
38
|
-
var children = props.children, classes = props.classes, cancelButton = props.cancelButton, okayButton = props.okayButton, onClose = props.onClose, submitting = props.submitting, open = props.open, title = props.title, restOfProps = __rest(props, ["children", "classes", "cancelButton", "okayButton", "onClose", "submitting", "open", "title"]);
|
|
38
|
+
var children = props.children, classes = props.classes, cancelButton = props.cancelButton, okayButton = props.okayButton, onClose = props.onClose, submitting = props.submitting, open = props.open, title = props.title, progressValue = props.progressValue, restOfProps = __rest(props, ["children", "classes", "cancelButton", "okayButton", "onClose", "submitting", "open", "title", "progressValue"]);
|
|
39
|
+
var showProgressBar = typeof progressValue !== 'undefined' && submitting;
|
|
39
40
|
return ((0, react_1.jsx)(material_1.Dialog, __assign({}, restOfProps, { classes: classes, open: open, onClose: onClose }),
|
|
40
41
|
(0, react_1.jsx)(material_1.DialogTitle, null, title),
|
|
41
42
|
(0, react_1.jsx)(material_1.DialogContent, null, typeof children === 'string' ? (0, react_1.jsx)(material_1.DialogContentText, null, children) : children),
|
|
42
|
-
(0, react_1.jsx)(
|
|
43
|
-
|
|
44
|
-
okayButton && ((0, react_1.jsx)(Button_1.default, { css: function (theme) {
|
|
43
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n align-items: center;\n "], ["\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n align-items: center;\n "]))) },
|
|
44
|
+
showProgressBar && ((0, react_1.jsx)(material_1.LinearProgress, { css: function (theme) {
|
|
45
45
|
var _a, _b;
|
|
46
|
-
return (0, react_1.css)(
|
|
47
|
-
},
|
|
46
|
+
return (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: 20px;\n width: -webkit-fill-available;\n border-radius: 5px;\n color: ", ";\n\n & .MuiLinearProgress-bar {\n border-radius: 5px;\n }\n "], ["\n margin-left: 20px;\n width: -webkit-fill-available;\n border-radius: 5px;\n color: ", ";\n\n & .MuiLinearProgress-bar {\n border-radius: 5px;\n }\n "])), ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) || 'hsl(321, 53%, 31%)');
|
|
47
|
+
}, variant: "determinate", value: progressValue })),
|
|
48
|
+
(0, react_1.jsx)(material_1.DialogActions, null,
|
|
49
|
+
cancelButton && !showProgressBar && ((0, react_1.jsx)(Button_1.default, { variant: "text", disabled: cancelButton.disabled || submitting, onClick: cancelButton.onClick }, cancelButton.text)),
|
|
50
|
+
okayButton && ((0, react_1.jsx)(Button_1.default, { css: function (theme) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &&.MuiButton-root .MuiCircularProgress-root {\n color: ", ";\n }\n "], ["\n &&.MuiButton-root .MuiCircularProgress-root {\n color: ", ";\n }\n "])), ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) || 'hsl(321, 53%, 31%)');
|
|
53
|
+
}, color: "primary", variant: "text", disabled: okayButton.disabled, onClick: okayButton.onClick, loading: submitting }, okayButton.text))))));
|
|
48
54
|
}
|
|
49
55
|
exports.default = Modal;
|
|
50
|
-
var templateObject_1;
|
|
56
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -44,14 +44,41 @@ var Button_1 = __importDefault(require("../Button"));
|
|
|
44
44
|
var Modal_1 = __importDefault(require("./Modal"));
|
|
45
45
|
var Modal = function () {
|
|
46
46
|
var _a = __read((0, react_1.useState)(false), 2), open = _a[0], setOpen = _a[1];
|
|
47
|
+
var _b = __read((0, react_1.useState)(0), 2), progressValue = _b[0], setProgressValue = _b[1];
|
|
48
|
+
var _c = __read((0, react_1.useState)(false), 2), isSubmitting = _c[0], setIsSubmitting = _c[1];
|
|
49
|
+
react_1.default.useEffect(function () {
|
|
50
|
+
var timer = setInterval(function () {
|
|
51
|
+
if (isSubmitting) {
|
|
52
|
+
setProgressValue(function (progressValue) {
|
|
53
|
+
if (progressValue === 100) {
|
|
54
|
+
alert('Have a great day!!');
|
|
55
|
+
handleOnClose();
|
|
56
|
+
}
|
|
57
|
+
var diff = Math.random() * 15;
|
|
58
|
+
return Math.min(progressValue + diff, 100);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, 500);
|
|
62
|
+
return function () {
|
|
63
|
+
clearInterval(timer);
|
|
64
|
+
};
|
|
65
|
+
}, [isSubmitting]);
|
|
66
|
+
function handleOnClose() {
|
|
67
|
+
setOpen(false);
|
|
68
|
+
setIsSubmitting(false);
|
|
69
|
+
setProgressValue(0);
|
|
70
|
+
}
|
|
47
71
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
48
72
|
react_1.default.createElement(Button_1.default, { color: "primary", onClick: function () { return setOpen(true); } }, "Open"),
|
|
49
|
-
react_1.default.createElement(Modal_1.default, { open: open, submitting:
|
|
73
|
+
react_1.default.createElement(Modal_1.default, { open: open, submitting: isSubmitting, title: "My Modal", onClose: handleOnClose, cancelButton: {
|
|
50
74
|
text: 'Cancel',
|
|
51
75
|
onClick: function () { return alert('You canceled it!'); },
|
|
52
76
|
}, okayButton: {
|
|
53
77
|
text: 'Okay',
|
|
54
|
-
onClick: function () {
|
|
55
|
-
|
|
78
|
+
onClick: function () {
|
|
79
|
+
alert('Okay!');
|
|
80
|
+
setIsSubmitting(true);
|
|
81
|
+
},
|
|
82
|
+
}, progressValue: progressValue }, "Hello there! How are you today?")));
|
|
56
83
|
};
|
|
57
84
|
exports.Modal = Modal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendorflow/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.74",
|
|
4
4
|
"description": "React components for vendorflow",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@types/react-table": "^7.7.6",
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
|
64
64
|
"@typescript-eslint/parser": "^4.32.0",
|
|
65
|
-
"@vendorflow/common": "^1.0.
|
|
65
|
+
"@vendorflow/common": "^1.0.44",
|
|
66
66
|
"babel-eslint": "10.1.0",
|
|
67
67
|
"babel-jest": "^24.9.0",
|
|
68
68
|
"babel-loader": "^8.2.2",
|
|
@@ -115,9 +115,11 @@
|
|
|
115
115
|
"react-h5-audio-player": "^3.8.1",
|
|
116
116
|
"react-measure": "^2.5.2",
|
|
117
117
|
"react-scripts": "^4.0.3",
|
|
118
|
+
"react-scrollbar-size": "^4.0.0",
|
|
118
119
|
"react-table": "^7.7.0",
|
|
119
120
|
"react-text-mask": "^5.4.3",
|
|
120
121
|
"react-textarea-autosize": "^8.3.3",
|
|
122
|
+
"react-virtualized": "^9.22.3",
|
|
121
123
|
"resolve": "1.15.0",
|
|
122
124
|
"resolve-url-loader": "3.1.1",
|
|
123
125
|
"sass-loader": "8.0.2",
|
|
@@ -145,6 +147,7 @@
|
|
|
145
147
|
"@types/lodash": "^4.14.150",
|
|
146
148
|
"@types/react-measure": "^2.0.7",
|
|
147
149
|
"@types/react-text-mask": "^5.4.6",
|
|
150
|
+
"@types/react-virtualized": "^9.21.21",
|
|
148
151
|
"eslint-config-prettier": "^8.3.0",
|
|
149
152
|
"eslint-plugin-prettier": "^3.4.0",
|
|
150
153
|
"eslint-webpack-plugin": "^2.5.4",
|