@vendorflow/components 2.0.95 → 2.0.97
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/TempHooks.d.ts +9 -0
- package/lib/TempHooks.js +25 -0
- package/lib/components/InfiniteScroll/InfiniteScroll.d.ts +16 -0
- package/lib/components/InfiniteScroll/InfiniteScroll.js +159 -0
- package/lib/components/InfiniteScroll/index.d.ts +1 -0
- package/lib/components/InfiniteScroll/index.js +8 -0
- package/lib/components/blueprint/InputGroup/InputGroup.d.ts +20 -0
- package/lib/components/blueprint/InputGroup/InputGroup.js +13 -0
- package/lib/components/blueprint/InputGroup/InputGroup.story.d.ts +2 -0
- package/lib/components/blueprint/InputGroup/InputGroup.story.js +11 -0
- package/lib/components/blueprint/InputGroup/index.d.ts +1 -0
- package/lib/components/blueprint/InputGroup/index.js +4 -0
- package/lib/components/blueprint/InputSelect/InputSelect.d.ts +51 -0
- package/lib/components/blueprint/InputSelect/InputSelect.js +98 -0
- package/lib/components/blueprint/InputSelect/InputSelect.story.d.ts +3 -0
- package/lib/components/blueprint/InputSelect/InputSelect.story.js +19 -0
- package/lib/components/blueprint/InputSelect/index.d.ts +1 -0
- package/lib/components/blueprint/InputSelect/index.js +4 -0
- package/lib/components/blueprint/InputTime/InputTime.d.ts +24 -0
- package/lib/components/blueprint/InputTime/InputTime.js +28 -0
- package/lib/components/blueprint/InputTime/InputTime.story.d.ts +2 -0
- package/lib/components/blueprint/InputTime/InputTime.story.js +11 -0
- package/lib/components/blueprint/InputTime/index.d.ts +1 -0
- package/lib/components/blueprint/InputTime/index.js +4 -0
- package/lib/components/material-ui/ChatInterface/ActionsMenu.d.ts +4 -0
- package/lib/components/material-ui/ChatInterface/ActionsMenu.js +37 -0
- package/lib/components/material-ui/ChatInterface/ChatInterface.d.ts +33 -0
- package/lib/components/material-ui/ChatInterface/ChatInterface.js +109 -0
- package/lib/components/material-ui/ChatInterface/ChatInterface.story.d.ts +1 -0
- package/lib/components/material-ui/ChatInterface/ChatInterface.story.js +134 -0
- package/lib/components/material-ui/ChatInterface/MessageInput.d.ts +9 -0
- package/lib/components/material-ui/ChatInterface/MessageInput.js +53 -0
- package/lib/components/material-ui/ChatInterface/MessageItem.d.ts +8 -0
- package/lib/components/material-ui/ChatInterface/MessageItem.js +71 -0
- package/lib/components/material-ui/ChatInterface/MessageThread.d.ts +6 -0
- package/lib/components/material-ui/ChatInterface/MessageThread.js +119 -0
- package/lib/components/material-ui/ChatInterface/index.d.ts +1 -0
- package/lib/components/material-ui/ChatInterface/index.js +8 -0
- package/lib/components/material-ui/ColorPicker/styles.d.ts +1 -1
- package/lib/components/material-ui/DataTable/AppliedFilters.d.ts +12 -0
- package/lib/components/material-ui/DataTable/AppliedFilters.js +26 -0
- package/lib/components/material-ui/DataTable/GlobalSearchFilter.d.ts +10 -0
- package/lib/components/material-ui/DataTable/GlobalSearchFilter.js +49 -0
- package/lib/components/material-ui/DataTable/IndeterminateCheckbox.d.ts +4 -0
- package/lib/components/material-ui/DataTable/IndeterminateCheckbox.js +65 -0
- package/lib/components/material-ui/DataTable/SortIndicator.d.ts +10 -0
- package/lib/components/material-ui/DataTable/SortIndicator.js +33 -0
- package/lib/components/material-ui/DataTable/Toolbar.d.ts +24 -0
- package/lib/components/material-ui/DataTable/Toolbar.js +63 -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/DataTable/ViewColumnTool.d.ts +11 -0
- package/lib/components/material-ui/DataTable/ViewColumnTool.js +76 -0
- package/lib/components/material-ui/ErrorBoundary/ErrorBoundary.d.ts +7 -0
- package/lib/components/material-ui/ErrorBoundary/ErrorBoundary.js +20 -0
- package/lib/components/material-ui/ErrorBoundary/index.d.ts +1 -0
- package/lib/components/material-ui/ErrorBoundary/index.js +8 -0
- package/lib/components/material-ui/InputCheckboxGroup/InputCheckboxGroup.d.ts +1 -0
- package/lib/components/material-ui/InputCheckboxGroup/InputCheckboxGroup.js +3 -3
- package/lib/components/material-ui/InputRadioGroup/InputRadioGroup.d.ts +1 -0
- package/lib/components/material-ui/InputRadioGroup/InputRadioGroup.js +3 -3
- package/lib/components/material-ui/InputSearchDropdown/InputSearchDropdown.d.ts +2 -1
- package/lib/components/material-ui/InputSearchDropdown/InputSearchDropdown.js +2 -2
- package/lib/services/Select.service.d.ts +5 -0
- package/lib/services/Select.service.js +67 -0
- package/package.json +1 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
|
+
function step(op) {
|
|
20
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
+
while (_) try {
|
|
22
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
23
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
|
+
switch (op[0]) {
|
|
25
|
+
case 0: case 1: t = op; break;
|
|
26
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
27
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
28
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
29
|
+
default:
|
|
30
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
31
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
32
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
33
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34
|
+
if (t[2]) _.ops.pop();
|
|
35
|
+
_.trys.pop(); continue;
|
|
36
|
+
}
|
|
37
|
+
op = body.call(thisArg, _);
|
|
38
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
39
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
43
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
44
|
+
if (!m) return o;
|
|
45
|
+
var i = m.call(o), r, ar = [], e;
|
|
46
|
+
try {
|
|
47
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
48
|
+
}
|
|
49
|
+
catch (error) { e = { error: error }; }
|
|
50
|
+
finally {
|
|
51
|
+
try {
|
|
52
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
53
|
+
}
|
|
54
|
+
finally { if (e) throw e.error; }
|
|
55
|
+
}
|
|
56
|
+
return ar;
|
|
57
|
+
};
|
|
58
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
/** @jsxRuntime classic */
|
|
63
|
+
/** @jsx jsx */
|
|
64
|
+
var react_1 = require("@emotion/react");
|
|
65
|
+
var react_2 = require("react");
|
|
66
|
+
var react_measure_1 = __importDefault(require("react-measure"));
|
|
67
|
+
var MessageInput_1 = __importDefault(require("./MessageInput"));
|
|
68
|
+
var MessageThread_1 = __importDefault(require("./MessageThread"));
|
|
69
|
+
function ChatInterface(_a) {
|
|
70
|
+
var userId = _a.userId, messages = _a.messages, fetchNextPage = _a.fetchNextPage, handleSend = _a.handleSend, hasNextPage = _a.hasNextPage, className = _a.className, style = _a.style, isSubmitting = _a.isSubmitting, placeholder = _a.placeholder, isLoading = _a.isLoading, isFetching = _a.isFetching, colors = _a.colors, renderInputComponent = _a.renderInputComponent;
|
|
71
|
+
var _b = __read((0, react_2.useState)(''), 2), message = _b[0], setMessage = _b[1];
|
|
72
|
+
var _c = __read((0, react_2.useState)(-1), 2), inputHeight = _c[0], setInputHeight = _c[1];
|
|
73
|
+
function handleClickSend() {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
var success, e_1;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
_a.trys.push([0, 2, , 3]);
|
|
80
|
+
return [4 /*yield*/, handleSend(message)];
|
|
81
|
+
case 1:
|
|
82
|
+
success = _a.sent();
|
|
83
|
+
if (success) {
|
|
84
|
+
setMessage('');
|
|
85
|
+
}
|
|
86
|
+
return [3 /*break*/, 3];
|
|
87
|
+
case 2:
|
|
88
|
+
e_1 = _a.sent();
|
|
89
|
+
// tslint:disable-next-line:no-console
|
|
90
|
+
console.error(e_1);
|
|
91
|
+
return [3 /*break*/, 3];
|
|
92
|
+
case 3: return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n min-height: 15rem;\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',\n 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n "], ["\n width: 100%;\n height: 100%;\n min-height: 15rem;\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',\n 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n "]))), className: className, style: style },
|
|
98
|
+
(0, react_1.jsx)(react_measure_1.default, { bounds: true, onResize: function (_a) {
|
|
99
|
+
var bounds = _a.bounds;
|
|
100
|
+
return setInputHeight((bounds === null || bounds === void 0 ? void 0 : bounds.height) || 0);
|
|
101
|
+
} }, function (_a) {
|
|
102
|
+
var measureRef = _a.measureRef;
|
|
103
|
+
return ((0, react_1.jsx)(react_2.Fragment, null,
|
|
104
|
+
(0, react_1.jsx)(MessageThread_1.default, { userId: userId, messages: messages, inputHeight: inputHeight, hasNextPage: hasNextPage, fetchNextPage: fetchNextPage, isLoading: isLoading, isFetching: isFetching, isSubmitting: isSubmitting, colors: colors }),
|
|
105
|
+
renderInputComponent ? (renderInputComponent(measureRef)) : ((0, react_1.jsx)(MessageInput_1.default, { ref: measureRef, handleClickSend: handleClickSend, message: message, setMessage: setMessage, isSubmitting: isSubmitting, placeholder: placeholder }))));
|
|
106
|
+
})));
|
|
107
|
+
}
|
|
108
|
+
exports.default = ChatInterface;
|
|
109
|
+
var templateObject_1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ChatInterface(): JSX.Element;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
7
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
8
|
+
if (!m) return o;
|
|
9
|
+
var i = m.call(o), r, ar = [], e;
|
|
10
|
+
try {
|
|
11
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
12
|
+
}
|
|
13
|
+
catch (error) { e = { error: error }; }
|
|
14
|
+
finally {
|
|
15
|
+
try {
|
|
16
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
17
|
+
}
|
|
18
|
+
finally { if (e) throw e.error; }
|
|
19
|
+
}
|
|
20
|
+
return ar;
|
|
21
|
+
};
|
|
22
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
23
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
24
|
+
if (ar || !(i in from)) {
|
|
25
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
26
|
+
ar[i] = from[i];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.ChatInterface = void 0;
|
|
36
|
+
/** @jsxRuntime classic */
|
|
37
|
+
/** @jsx jsx */
|
|
38
|
+
var react_1 = require("@emotion/react");
|
|
39
|
+
var react_2 = require("react");
|
|
40
|
+
var faker_1 = __importDefault(require("faker"));
|
|
41
|
+
var short_uuid_1 = __importDefault(require("short-uuid"));
|
|
42
|
+
var ChatInterface_1 = __importDefault(require("./ChatInterface"));
|
|
43
|
+
var Workspaces_constants_1 = require("@vendorflow/common/lib/constants/Workspaces.constants");
|
|
44
|
+
// tslint:disable-next-line:no-console
|
|
45
|
+
function ChatInterface() {
|
|
46
|
+
var _a = __read((0, react_2.useState)(true), 2), isLoading = _a[0], setLoading = _a[1];
|
|
47
|
+
var _b = __read((0, react_2.useState)(true), 2), isFetching = _b[0], setFetching = _b[1];
|
|
48
|
+
var _c = __read((0, react_2.useState)(false), 2), isSubmitting = _c[0], setSubmitting = _c[1];
|
|
49
|
+
var _d = __read((0, react_2.useState)([]), 2), messages = _d[0], setMessages = _d[1];
|
|
50
|
+
var _e = __read((0, react_2.useState)(true), 2), hasMore = _e[0], setHasMore = _e[1];
|
|
51
|
+
(0, react_2.useEffect)(function () {
|
|
52
|
+
setMessages(new Array(5).fill(null).map(generateMessage).concat([generateSystemMessage()]));
|
|
53
|
+
setLoading(false);
|
|
54
|
+
setFetching(false);
|
|
55
|
+
}, []);
|
|
56
|
+
function generateTimestamp() {
|
|
57
|
+
return new Date().toISOString();
|
|
58
|
+
}
|
|
59
|
+
function generateId() {
|
|
60
|
+
return short_uuid_1.default.generate();
|
|
61
|
+
}
|
|
62
|
+
function generateSystemMessage() {
|
|
63
|
+
return {
|
|
64
|
+
id: generateId(),
|
|
65
|
+
userId: Workspaces_constants_1.SYSTEM_IDENTITY_ID,
|
|
66
|
+
username: 'System',
|
|
67
|
+
initials: 'S',
|
|
68
|
+
timestamp: generateTimestamp(),
|
|
69
|
+
content: faker_1.default.lorem.sentence(5, 2),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function generateMessage() {
|
|
73
|
+
var user = faker_1.default.random.arrayElement([
|
|
74
|
+
{
|
|
75
|
+
id: 'user1',
|
|
76
|
+
name: 'Socorro Aguilar',
|
|
77
|
+
initials: 'SA',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'user2',
|
|
81
|
+
name: 'Greg Bujak',
|
|
82
|
+
initials: 'GB',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'user3',
|
|
86
|
+
name: 'xinyi@vendorflow.co',
|
|
87
|
+
initials: 'X',
|
|
88
|
+
},
|
|
89
|
+
]);
|
|
90
|
+
return {
|
|
91
|
+
id: generateId(),
|
|
92
|
+
userId: user.id,
|
|
93
|
+
username: user.name,
|
|
94
|
+
initials: user.initials,
|
|
95
|
+
timestamp: generateTimestamp(),
|
|
96
|
+
content: faker_1.default.lorem.sentence(5, 2),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function generateMessagePage() {
|
|
100
|
+
return new Array(10).fill(null).map(generateMessage);
|
|
101
|
+
}
|
|
102
|
+
var fetchNextPage = (0, react_2.useCallback)(function () {
|
|
103
|
+
setFetching(true);
|
|
104
|
+
setTimeout(function () {
|
|
105
|
+
setMessages(__spreadArray(__spreadArray([], __read(messages), false), __read(generateMessagePage()), false));
|
|
106
|
+
setFetching(false);
|
|
107
|
+
}, 100);
|
|
108
|
+
}, [messages, generateMessagePage, setMessages]);
|
|
109
|
+
function handleSend(message) {
|
|
110
|
+
setSubmitting(true);
|
|
111
|
+
setFetching(true);
|
|
112
|
+
return new Promise(function (resolve) {
|
|
113
|
+
setTimeout(function () {
|
|
114
|
+
setMessages(__spreadArray([
|
|
115
|
+
{
|
|
116
|
+
id: generateId(),
|
|
117
|
+
userId: 'user1',
|
|
118
|
+
username: 'Socorro Aguilar',
|
|
119
|
+
initials: 'SA',
|
|
120
|
+
timestamp: generateTimestamp(),
|
|
121
|
+
content: message,
|
|
122
|
+
}
|
|
123
|
+
], __read(messages), false));
|
|
124
|
+
setSubmitting(false);
|
|
125
|
+
setFetching(false);
|
|
126
|
+
resolve(true);
|
|
127
|
+
}, 500);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: 1px solid #ededed;\n height: 30rem;\n "], ["\n border: 1px solid #ededed;\n height: 30rem;\n "]))) },
|
|
131
|
+
(0, react_1.jsx)(ChatInterface_1.default, { userId: "user1", messages: messages, handleSend: handleSend, fetchNextPage: fetchNextPage, hasNextPage: hasMore, isLoading: isLoading, isFetching: isFetching, isSubmitting: isSubmitting })));
|
|
132
|
+
}
|
|
133
|
+
exports.ChatInterface = ChatInterface;
|
|
134
|
+
var templateObject_1;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { ChatInterfaceProps } from './ChatInterface';
|
|
3
|
+
interface Props extends Pick<ChatInterfaceProps, 'isSubmitting' | 'placeholder'> {
|
|
4
|
+
handleClickSend: () => Promise<void>;
|
|
5
|
+
message: string;
|
|
6
|
+
setMessage: Dispatch<SetStateAction<string>>;
|
|
7
|
+
}
|
|
8
|
+
declare const MessageInput: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export default MessageInput;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
/** @jsxRuntime classic */
|
|
11
|
+
/** @jsx jsx */
|
|
12
|
+
var react_1 = require("@emotion/react");
|
|
13
|
+
var react_2 = require("react");
|
|
14
|
+
var react_textarea_autosize_1 = __importDefault(require("react-textarea-autosize"));
|
|
15
|
+
var material_1 = require("@mui/material");
|
|
16
|
+
var icons_material_1 = require("@mui/icons-material");
|
|
17
|
+
var ActionsMenu_1 = __importDefault(require("./ActionsMenu"));
|
|
18
|
+
var MessageInput = (0, react_2.forwardRef)(function (_a, ref) {
|
|
19
|
+
var handleClickSend = _a.handleClickSend, message = _a.message, placeholder = _a.placeholder, setMessage = _a.setMessage, isSubmitting = _a.isSubmitting;
|
|
20
|
+
function handleOnChange(_a) {
|
|
21
|
+
var value = _a.target.value;
|
|
22
|
+
setMessage(value);
|
|
23
|
+
}
|
|
24
|
+
function handleOnKeyDown(evt) {
|
|
25
|
+
if (evt.key === 'Enter') {
|
|
26
|
+
evt.stopPropagation();
|
|
27
|
+
evt.preventDefault();
|
|
28
|
+
if (!evt.metaKey && message.trim().length) {
|
|
29
|
+
handleClickSend().then();
|
|
30
|
+
}
|
|
31
|
+
else if (evt.metaKey) {
|
|
32
|
+
setMessage(message + '\n');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function handleOnClickSend() {
|
|
37
|
+
if (message.trim().length) {
|
|
38
|
+
handleClickSend().then();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return ((0, react_1.jsx)("div", { ref: ref, css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n background-color: white;\n bottom: 0;\n left: 0;\n position: absolute;\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: center;\n "], ["\n width: 100%;\n background-color: white;\n bottom: 0;\n left: 0;\n position: absolute;\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: center;\n "]))) },
|
|
42
|
+
(0, react_1.jsx)(react_textarea_autosize_1.default, { css: function (theme) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
return (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',\n 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n resize: none;\n width: calc(100% - 3.5rem);\n outline: 0 none transparent;\n font-size: 16px;\n margin: 0.5rem;\n padding: 0.5rem;\n box-sizing: border-box;\n border-radius: 5px;\n border-color: ", ";\n "], ["\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',\n 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n resize: none;\n width: calc(100% - 3.5rem);\n outline: 0 none transparent;\n font-size: 16px;\n margin: 0.5rem;\n padding: 0.5rem;\n box-sizing: border-box;\n border-radius: 5px;\n border-color: ", ";\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(0, 0%, 89%)');
|
|
45
|
+
}, placeholder: placeholder || 'Type your message here...', value: message, onChange: handleOnChange, onKeyDown: handleOnKeyDown, minRows: 3, maxRows: 8 }),
|
|
46
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n align-items: center;\n padding-right: 0.5rem;\n overflow: hidden;\n "], ["\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n align-items: center;\n padding-right: 0.5rem;\n overflow: hidden;\n "]))) },
|
|
47
|
+
(0, react_1.jsx)(ActionsMenu_1.default, null),
|
|
48
|
+
isSubmitting ? ((0, react_1.jsx)(material_1.CircularProgress, { css: (0, react_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin: 8px;\n "], ["\n margin: 8px;\n "]))), size: "1.5rem" })) : ((0, react_1.jsx)(material_1.Tooltip, { title: "Send Now", placement: "bottom" },
|
|
49
|
+
(0, react_1.jsx)(material_1.IconButton, { onClick: handleOnClickSend, disabled: isSubmitting },
|
|
50
|
+
(0, react_1.jsx)(icons_material_1.Send, null)))))));
|
|
51
|
+
});
|
|
52
|
+
exports.default = MessageInput;
|
|
53
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
7
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
8
|
+
if (!m) return o;
|
|
9
|
+
var i = m.call(o), r, ar = [], e;
|
|
10
|
+
try {
|
|
11
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
12
|
+
}
|
|
13
|
+
catch (error) { e = { error: error }; }
|
|
14
|
+
finally {
|
|
15
|
+
try {
|
|
16
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
17
|
+
}
|
|
18
|
+
finally { if (e) throw e.error; }
|
|
19
|
+
}
|
|
20
|
+
return ar;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
/** @jsxRuntime classic */
|
|
24
|
+
/** @jsx jsx */
|
|
25
|
+
var react_1 = require("@emotion/react");
|
|
26
|
+
var date_fns_1 = require("date-fns");
|
|
27
|
+
var icons_material_1 = require("@mui/icons-material");
|
|
28
|
+
var material_1 = require("@mui/material");
|
|
29
|
+
var react_2 = require("react");
|
|
30
|
+
var Workspaces_constants_1 = require("@vendorflow/common/lib/constants/Workspaces.constants");
|
|
31
|
+
function MessageItem(_a) {
|
|
32
|
+
var userId = _a.userId, message = _a.message, colors = _a.colors;
|
|
33
|
+
var _b = __read((0, react_2.useState)(getUnixTimestamp()), 2), displayUpdateAt = _b[0], setDisplayUpdateAt = _b[1];
|
|
34
|
+
(0, react_2.useEffect)(function () {
|
|
35
|
+
var interval = setInterval(function () { return setDisplayUpdateAt(getUnixTimestamp()); }, 60 * 1000);
|
|
36
|
+
return function () { return clearInterval(interval); };
|
|
37
|
+
}, []);
|
|
38
|
+
function getUnixTimestamp() {
|
|
39
|
+
return Math.floor(new Date().getTime() / 1000);
|
|
40
|
+
}
|
|
41
|
+
var timeDisplay = (0, react_2.useMemo)(function () {
|
|
42
|
+
var now = new Date();
|
|
43
|
+
var timestamp = new Date(message.timestamp);
|
|
44
|
+
if ((0, date_fns_1.isToday)(timestamp)) {
|
|
45
|
+
var hours = (0, date_fns_1.differenceInHours)(now, timestamp);
|
|
46
|
+
if (hours > 0) {
|
|
47
|
+
return hours + " hour" + (hours === 1 ? '' : 's') + " ago";
|
|
48
|
+
}
|
|
49
|
+
var minutes = (0, date_fns_1.differenceInMinutes)(now, timestamp);
|
|
50
|
+
if (minutes > 0) {
|
|
51
|
+
return minutes + " minute" + (minutes === 1 ? '' : 's') + " ago";
|
|
52
|
+
}
|
|
53
|
+
return "now";
|
|
54
|
+
}
|
|
55
|
+
return (0, date_fns_1.format)(new Date(message.timestamp), 'H:mm MM/dd/yyyy');
|
|
56
|
+
}, [message.timestamp, displayUpdateAt]);
|
|
57
|
+
return ((0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n background: white;\n margin-top: 0.5rem;\n border-radius: 4px;\n display: flex;\n flex-direction: row;\n "], ["\n width: 100%;\n background: white;\n margin-top: 0.5rem;\n border-radius: 4px;\n display: flex;\n flex-direction: row;\n "]))) },
|
|
58
|
+
(0, react_1.jsx)(material_1.Avatar, { css: function (theme) {
|
|
59
|
+
var _a, _b, _c, _d, _e;
|
|
60
|
+
return (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n && {\n font-size: 1rem;\n height: 2rem;\n width: 2rem;\n margin-right: 0.5rem;\n visibility: ", ";\n background-color: ", ";\n }\n "], ["\n && {\n font-size: 1rem;\n height: 2rem;\n width: 2rem;\n margin-right: 0.5rem;\n visibility: ", ";\n background-color: ", ";\n }\n "])), message.userId === Workspaces_constants_1.SYSTEM_IDENTITY_ID ? 'hidden' : 'visible', userId === message.userId
|
|
61
|
+
? (colors === null || colors === void 0 ? void 0 : colors.user) || ((_c = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.custom) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.tertiary) === null || _c === void 0 ? void 0 : _c.main) || 'hsl(0, 0%, 89%)'
|
|
62
|
+
: (colors === null || colors === void 0 ? void 0 : colors.others) || ((_e = (_d = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _d === void 0 ? void 0 : _d.primary) === null || _e === void 0 ? void 0 : _e.main) || 'hsl(0, 0%, 47%)');
|
|
63
|
+
} }, message.initials === '' ? (0, react_1.jsx)(icons_material_1.Person, null) : message.initials),
|
|
64
|
+
(0, react_1.jsx)("div", null,
|
|
65
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: flex-start;\n "], ["\n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: flex-start;\n "]))) },
|
|
66
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-weight: 700;\n font-size: 0.75rem;\n display: inline-block;\n margin-right: 0.25rem;\n "], ["\n font-weight: 700;\n font-size: 0.75rem;\n display: inline-block;\n margin-right: 0.25rem;\n "]))) }, message.username),
|
|
67
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-size: 0.75rem;\n display: inline-block;\n "], ["\n font-size: 0.75rem;\n display: inline-block;\n "]))) }, timeDisplay)),
|
|
68
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n color: ", ";\n font-size: 0.875rem;\n white-space: break-spaces;\n "], ["\n color: ", ";\n font-size: 0.875rem;\n white-space: break-spaces;\n "])), message.userId === Workspaces_constants_1.SYSTEM_IDENTITY_ID ? 'hsl(0, 0%, 65%)' : 'inherit') }, message.content))));
|
|
69
|
+
}
|
|
70
|
+
exports.default = MessageItem;
|
|
71
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChatInterfaceProps } from './ChatInterface';
|
|
2
|
+
interface Props extends Pick<ChatInterfaceProps, 'userId' | 'messages' | 'hasNextPage' | 'fetchNextPage' | 'isLoading' | 'isFetching' | 'isSubmitting' | 'colors'> {
|
|
3
|
+
inputHeight: number;
|
|
4
|
+
}
|
|
5
|
+
export default function MessageThread({ userId, messages, inputHeight, hasNextPage, fetchNextPage, isLoading, isFetching, isSubmitting, colors, }: Props): JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
/** @jsxRuntime classic */
|
|
11
|
+
/** @jsx jsx */
|
|
12
|
+
var react_1 = require("@emotion/react");
|
|
13
|
+
var react_2 = require("react");
|
|
14
|
+
var MessageItem_1 = __importDefault(require("./MessageItem"));
|
|
15
|
+
var lodash_1 = require("lodash");
|
|
16
|
+
var material_1 = require("@mui/material");
|
|
17
|
+
function MessageThread(_a) {
|
|
18
|
+
var _b;
|
|
19
|
+
var userId = _a.userId, messages = _a.messages, inputHeight = _a.inputHeight, hasNextPage = _a.hasNextPage, fetchNextPage = _a.fetchNextPage, isLoading = _a.isLoading, isFetching = _a.isFetching, isSubmitting = _a.isSubmitting, colors = _a.colors;
|
|
20
|
+
var isInitialized = (0, react_2.useRef)(false);
|
|
21
|
+
var isScrollLoad = (0, react_2.useRef)(false);
|
|
22
|
+
var hasSubmitted = (0, react_2.useRef)(false);
|
|
23
|
+
var prevScrollTop = (0, react_2.useRef)(null);
|
|
24
|
+
var prevScrollHeight = (0, react_2.useRef)(null);
|
|
25
|
+
var shouldScrollToPrevPosition = (0, react_2.useRef)(false);
|
|
26
|
+
var scrollParent = (0, react_2.useRef)(null);
|
|
27
|
+
var handleScrollEvent = (0, react_2.useCallback)((0, lodash_1.debounce)(function (evt) {
|
|
28
|
+
var parent = evt.target;
|
|
29
|
+
if (parent.scrollTop === 0 && hasNextPage && fetchNextPage && !isLoading && !isFetching) {
|
|
30
|
+
isScrollLoad.current = true;
|
|
31
|
+
prevScrollHeight.current = parent.scrollHeight;
|
|
32
|
+
fetchNextPage();
|
|
33
|
+
}
|
|
34
|
+
}, 300), [hasNextPage, fetchNextPage, isLoading, isFetching]);
|
|
35
|
+
(0, react_2.useEffect)(function () {
|
|
36
|
+
if (isSubmitting) {
|
|
37
|
+
hasSubmitted.current = true;
|
|
38
|
+
}
|
|
39
|
+
}, [isSubmitting]);
|
|
40
|
+
// This will handle the initial loading of messages, then scroll to bottom
|
|
41
|
+
(0, react_2.useEffect)(function () {
|
|
42
|
+
if (!isInitialized.current && !isFetching && scrollParent.current) {
|
|
43
|
+
var _a = scrollParent.current, clientHeight = _a.clientHeight, scrollHeight = _a.scrollHeight;
|
|
44
|
+
if (clientHeight >= scrollHeight && hasNextPage && fetchNextPage) {
|
|
45
|
+
fetchNextPage();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
isInitialized.current = true;
|
|
49
|
+
scrollParent.current.scrollTo(0, scrollHeight - clientHeight);
|
|
50
|
+
}
|
|
51
|
+
}, [isFetching, isInitialized.current, hasNextPage, fetchNextPage]);
|
|
52
|
+
// Sets up the scroll event listener
|
|
53
|
+
(0, react_2.useEffect)(function () {
|
|
54
|
+
if (scrollParent.current) {
|
|
55
|
+
scrollParent.current.addEventListener('scroll', handleScrollEvent);
|
|
56
|
+
}
|
|
57
|
+
return function () {
|
|
58
|
+
if (scrollParent.current) {
|
|
59
|
+
scrollParent.current.removeEventListener('scroll', handleScrollEvent);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}, [scrollParent.current, hasNextPage, fetchNextPage, isLoading, isFetching]);
|
|
63
|
+
// Handles the scroll position adjustment after fetching the next page
|
|
64
|
+
(0, react_2.useEffect)(function () {
|
|
65
|
+
if (!isFetching &&
|
|
66
|
+
isInitialized.current &&
|
|
67
|
+
scrollParent.current &&
|
|
68
|
+
isScrollLoad.current &&
|
|
69
|
+
prevScrollHeight.current &&
|
|
70
|
+
scrollParent.current.scrollHeight !== prevScrollHeight.current) {
|
|
71
|
+
var delta = scrollParent.current.scrollHeight - prevScrollHeight.current;
|
|
72
|
+
scrollParent.current.scrollTo(0, delta);
|
|
73
|
+
isScrollLoad.current = false;
|
|
74
|
+
prevScrollHeight.current = 0;
|
|
75
|
+
}
|
|
76
|
+
}, [isFetching, prevScrollHeight.current]);
|
|
77
|
+
// Manages scroll position for data changes that are triggered from anything other than the scroll event
|
|
78
|
+
(0, react_2.useEffect)(function () {
|
|
79
|
+
var _a;
|
|
80
|
+
if (scrollParent.current && !isScrollLoad.current && isInitialized.current) {
|
|
81
|
+
var _b = scrollParent.current, scrollHeight = _b.scrollHeight, scrollTop = _b.scrollTop, clientHeight = _b.clientHeight;
|
|
82
|
+
if (isFetching) {
|
|
83
|
+
// track the current position
|
|
84
|
+
prevScrollHeight.current = scrollHeight;
|
|
85
|
+
prevScrollTop.current = scrollTop;
|
|
86
|
+
var distanceFromBottom = scrollHeight - scrollTop - clientHeight;
|
|
87
|
+
if (!isSubmitting && distanceFromBottom > 200) {
|
|
88
|
+
shouldScrollToPrevPosition.current = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// init to scroll to bottom delta
|
|
93
|
+
var delta = scrollHeight - clientHeight;
|
|
94
|
+
if (hasSubmitted.current) {
|
|
95
|
+
// scroll to bottom if this was triggered by the current user's sent message
|
|
96
|
+
(_a = scrollParent.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, delta);
|
|
97
|
+
}
|
|
98
|
+
else if (!isFetching && prevScrollHeight.current !== null && prevScrollTop.current !== null) {
|
|
99
|
+
if (shouldScrollToPrevPosition.current) {
|
|
100
|
+
delta = prevScrollTop.current;
|
|
101
|
+
}
|
|
102
|
+
scrollParent.current.scrollTo(0, delta);
|
|
103
|
+
}
|
|
104
|
+
// clean up
|
|
105
|
+
prevScrollHeight.current = null;
|
|
106
|
+
prevScrollTop.current = null;
|
|
107
|
+
hasSubmitted.current = false;
|
|
108
|
+
shouldScrollToPrevPosition.current = false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, [isFetching, (_b = scrollParent.current) === null || _b === void 0 ? void 0 : _b.scrollHeight]);
|
|
112
|
+
return ((0, react_1.jsx)("div", { ref: scrollParent, css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n box-sizing: border-box;\n height: calc(100% - ", "px);\n width: 100%;\n padding: 0.5rem 1rem;\n overflow-y: auto;\n "], ["\n box-sizing: border-box;\n height: calc(100% - ", "px);\n width: 100%;\n padding: 0.5rem 1rem;\n overflow-y: auto;\n "])), inputHeight) },
|
|
113
|
+
(0, react_1.jsx)("div", { css: (0, react_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: column-reverse;\n justify-content: flex-start;\n align-items: flex-start;\n "], ["\n display: flex;\n flex-direction: column-reverse;\n justify-content: flex-start;\n align-items: flex-start;\n "]))) },
|
|
114
|
+
messages.map(function (message) { return ((0, react_1.jsx)(MessageItem_1.default, { key: "" + message.id, message: message, userId: userId, colors: colors })); }),
|
|
115
|
+
hasNextPage && ((0, react_1.jsx)("div", { key: "loader", css: (0, react_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 100%;\n margin: 0.5rem 0;\n height: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n\n && {\n visibility: ", ";\n }\n "], ["\n width: 100%;\n margin: 0.5rem 0;\n height: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n\n && {\n visibility: ", ";\n }\n "])), isFetching && isScrollLoad ? 'visible' : 'hidden') },
|
|
116
|
+
(0, react_1.jsx)(material_1.CircularProgress, { size: "1.5rem", disableShrink: true }))))));
|
|
117
|
+
}
|
|
118
|
+
exports.default = MessageThread;
|
|
119
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ChatInterface';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var ChatInterface_1 = require("./ChatInterface");
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(ChatInterface_1).default; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const colorPaletteStyles: import("@emotion/
|
|
1
|
+
export declare const colorPaletteStyles: import("@emotion/react").SerializedStyles;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { Filters, UseFiltersInstanceProps } from 'react-table';
|
|
5
|
+
import { SimpleMap } from '../../../types/Internal.types';
|
|
6
|
+
interface Props<D extends object> {
|
|
7
|
+
columnNameById: SimpleMap<string>;
|
|
8
|
+
filters: Filters<D>;
|
|
9
|
+
setFilter: UseFiltersInstanceProps<D>['setFilter'];
|
|
10
|
+
}
|
|
11
|
+
export default function AppliedFilters<D extends object>({ columnNameById, filters, setFilter }: Props<D>): jsx.JSX.Element | null;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
/** @jsxRuntime classic */
|
|
8
|
+
/** @jsx jsx */
|
|
9
|
+
var react_1 = require("@emotion/react");
|
|
10
|
+
var material_1 = require("@mui/material");
|
|
11
|
+
var SingleSelectFilter_1 = require("./FilterTool/Filters/SingleSelectFilter");
|
|
12
|
+
var PADDING = 24;
|
|
13
|
+
function AppliedFilters(_a) {
|
|
14
|
+
var columnNameById = _a.columnNameById, filters = _a.filters, setFilter = _a.setFilter;
|
|
15
|
+
if (!filters.length) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return ((0, react_1.jsx)(material_1.Stack, { direction: "row", overflow: "none", css: (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: calc(100% - ", "px);\n padding: 8px ", "px;\n flex-wrap: wrap;\n gap: 0.25rem 0.25rem;\n "], ["\n width: calc(100% - ", "px);\n padding: 8px ", "px;\n flex-wrap: wrap;\n gap: 0.25rem 0.25rem;\n "])), PADDING * 2, PADDING) }, filters
|
|
19
|
+
.filter(function (filter) {
|
|
20
|
+
return (Array.isArray(filter.value) && !!filter.value.length) ||
|
|
21
|
+
(!Array.isArray(filter.value) && filter.value != null);
|
|
22
|
+
})
|
|
23
|
+
.map(function (filter) { return ((0, react_1.jsx)(material_1.Chip, { key: filter.id, label: columnNameById[filter.id] + ": " + (filter.value === '' ? SingleSelectFilter_1.BLANK_VALUE_LABEL : filter.value), onDelete: function () { return setFilter(filter.id, null); } })); })));
|
|
24
|
+
}
|
|
25
|
+
exports.default = AppliedFilters;
|
|
26
|
+
var templateObject_1;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
interface Props {
|
|
5
|
+
setShowSearch: (value: boolean) => void;
|
|
6
|
+
globalFilter: string;
|
|
7
|
+
setGlobalFilter: (filterValue: any) => void;
|
|
8
|
+
}
|
|
9
|
+
export default function GlobalSearchFilter({ globalFilter, setGlobalFilter, setShowSearch }: Props): jsx.JSX.Element;
|
|
10
|
+
export {};
|