code7-leia 0.1.49 → 0.1.52

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,14 +1,347 @@
1
- import React, { forwardRef, useRef, useCallback, useEffect, useState, useMemo, Suspense } from 'react';
2
- import { useLocation, useRouteMatch, useHistory, Switch, Route } from 'react-router-dom';
1
+ import React, { forwardRef, useRef, useCallback, useEffect, useState, createContext, useContext, useMemo, Suspense } from 'react';
2
+ import { useRouteMatch, useLocation, useHistory, Switch, Route } from 'react-router-dom';
3
3
  import PropTypes from 'prop-types';
4
4
  import cc from 'classcat';
5
5
  import styled from 'styled-components';
6
+ import { useDispatch, useSelector } from 'react-redux';
6
7
  import { FaSearch, FaUpload, FaList, FaPlus, FaMicrophone } from 'react-icons/fa';
7
8
  import unorm from 'unorm';
8
9
  import { MdClose, MdPerson2 } from 'react-icons/md';
9
10
  import { useDropzone } from 'react-dropzone';
11
+ import axios from 'axios';
10
12
  import { PiWaveformBold } from 'react-icons/pi';
11
13
 
14
+ function _regeneratorRuntime() {
15
+ _regeneratorRuntime = function () {
16
+ return e;
17
+ };
18
+ var t,
19
+ e = {},
20
+ r = Object.prototype,
21
+ n = r.hasOwnProperty,
22
+ o = Object.defineProperty || function (t, e, r) {
23
+ t[e] = r.value;
24
+ },
25
+ i = "function" == typeof Symbol ? Symbol : {},
26
+ a = i.iterator || "@@iterator",
27
+ c = i.asyncIterator || "@@asyncIterator",
28
+ u = i.toStringTag || "@@toStringTag";
29
+ function define(t, e, r) {
30
+ return Object.defineProperty(t, e, {
31
+ value: r,
32
+ enumerable: !0,
33
+ configurable: !0,
34
+ writable: !0
35
+ }), t[e];
36
+ }
37
+ try {
38
+ define({}, "");
39
+ } catch (t) {
40
+ define = function (t, e, r) {
41
+ return t[e] = r;
42
+ };
43
+ }
44
+ function wrap(t, e, r, n) {
45
+ var i = e && e.prototype instanceof Generator ? e : Generator,
46
+ a = Object.create(i.prototype),
47
+ c = new Context(n || []);
48
+ return o(a, "_invoke", {
49
+ value: makeInvokeMethod(t, r, c)
50
+ }), a;
51
+ }
52
+ function tryCatch(t, e, r) {
53
+ try {
54
+ return {
55
+ type: "normal",
56
+ arg: t.call(e, r)
57
+ };
58
+ } catch (t) {
59
+ return {
60
+ type: "throw",
61
+ arg: t
62
+ };
63
+ }
64
+ }
65
+ e.wrap = wrap;
66
+ var h = "suspendedStart",
67
+ l = "suspendedYield",
68
+ f = "executing",
69
+ s = "completed",
70
+ y = {};
71
+ function Generator() {}
72
+ function GeneratorFunction() {}
73
+ function GeneratorFunctionPrototype() {}
74
+ var p = {};
75
+ define(p, a, function () {
76
+ return this;
77
+ });
78
+ var d = Object.getPrototypeOf,
79
+ v = d && d(d(values([])));
80
+ v && v !== r && n.call(v, a) && (p = v);
81
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
82
+ function defineIteratorMethods(t) {
83
+ ["next", "throw", "return"].forEach(function (e) {
84
+ define(t, e, function (t) {
85
+ return this._invoke(e, t);
86
+ });
87
+ });
88
+ }
89
+ function AsyncIterator(t, e) {
90
+ function invoke(r, o, i, a) {
91
+ var c = tryCatch(t[r], t, o);
92
+ if ("throw" !== c.type) {
93
+ var u = c.arg,
94
+ h = u.value;
95
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
96
+ invoke("next", t, i, a);
97
+ }, function (t) {
98
+ invoke("throw", t, i, a);
99
+ }) : e.resolve(h).then(function (t) {
100
+ u.value = t, i(u);
101
+ }, function (t) {
102
+ return invoke("throw", t, i, a);
103
+ });
104
+ }
105
+ a(c.arg);
106
+ }
107
+ var r;
108
+ o(this, "_invoke", {
109
+ value: function (t, n) {
110
+ function callInvokeWithMethodAndArg() {
111
+ return new e(function (e, r) {
112
+ invoke(t, n, e, r);
113
+ });
114
+ }
115
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
116
+ }
117
+ });
118
+ }
119
+ function makeInvokeMethod(e, r, n) {
120
+ var o = h;
121
+ return function (i, a) {
122
+ if (o === f) throw new Error("Generator is already running");
123
+ if (o === s) {
124
+ if ("throw" === i) throw a;
125
+ return {
126
+ value: t,
127
+ done: !0
128
+ };
129
+ }
130
+ for (n.method = i, n.arg = a;;) {
131
+ var c = n.delegate;
132
+ if (c) {
133
+ var u = maybeInvokeDelegate(c, n);
134
+ if (u) {
135
+ if (u === y) continue;
136
+ return u;
137
+ }
138
+ }
139
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
140
+ if (o === h) throw o = s, n.arg;
141
+ n.dispatchException(n.arg);
142
+ } else "return" === n.method && n.abrupt("return", n.arg);
143
+ o = f;
144
+ var p = tryCatch(e, r, n);
145
+ if ("normal" === p.type) {
146
+ if (o = n.done ? s : l, p.arg === y) continue;
147
+ return {
148
+ value: p.arg,
149
+ done: n.done
150
+ };
151
+ }
152
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
153
+ }
154
+ };
155
+ }
156
+ function maybeInvokeDelegate(e, r) {
157
+ var n = r.method,
158
+ o = e.iterator[n];
159
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
160
+ var i = tryCatch(o, e.iterator, r.arg);
161
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
162
+ var a = i.arg;
163
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
164
+ }
165
+ function pushTryEntry(t) {
166
+ var e = {
167
+ tryLoc: t[0]
168
+ };
169
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
170
+ }
171
+ function resetTryEntry(t) {
172
+ var e = t.completion || {};
173
+ e.type = "normal", delete e.arg, t.completion = e;
174
+ }
175
+ function Context(t) {
176
+ this.tryEntries = [{
177
+ tryLoc: "root"
178
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
179
+ }
180
+ function values(e) {
181
+ if (e || "" === e) {
182
+ var r = e[a];
183
+ if (r) return r.call(e);
184
+ if ("function" == typeof e.next) return e;
185
+ if (!isNaN(e.length)) {
186
+ var o = -1,
187
+ i = function next() {
188
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
189
+ return next.value = t, next.done = !0, next;
190
+ };
191
+ return i.next = i;
192
+ }
193
+ }
194
+ throw new TypeError(typeof e + " is not iterable");
195
+ }
196
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
197
+ value: GeneratorFunctionPrototype,
198
+ configurable: !0
199
+ }), o(GeneratorFunctionPrototype, "constructor", {
200
+ value: GeneratorFunction,
201
+ configurable: !0
202
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
203
+ var e = "function" == typeof t && t.constructor;
204
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
205
+ }, e.mark = function (t) {
206
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
207
+ }, e.awrap = function (t) {
208
+ return {
209
+ __await: t
210
+ };
211
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
212
+ return this;
213
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
214
+ void 0 === i && (i = Promise);
215
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
216
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
217
+ return t.done ? t.value : a.next();
218
+ });
219
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
220
+ return this;
221
+ }), define(g, "toString", function () {
222
+ return "[object Generator]";
223
+ }), e.keys = function (t) {
224
+ var e = Object(t),
225
+ r = [];
226
+ for (var n in e) r.push(n);
227
+ return r.reverse(), function next() {
228
+ for (; r.length;) {
229
+ var t = r.pop();
230
+ if (t in e) return next.value = t, next.done = !1, next;
231
+ }
232
+ return next.done = !0, next;
233
+ };
234
+ }, e.values = values, Context.prototype = {
235
+ constructor: Context,
236
+ reset: function (e) {
237
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
238
+ },
239
+ stop: function () {
240
+ this.done = !0;
241
+ var t = this.tryEntries[0].completion;
242
+ if ("throw" === t.type) throw t.arg;
243
+ return this.rval;
244
+ },
245
+ dispatchException: function (e) {
246
+ if (this.done) throw e;
247
+ var r = this;
248
+ function handle(n, o) {
249
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
250
+ }
251
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
252
+ var i = this.tryEntries[o],
253
+ a = i.completion;
254
+ if ("root" === i.tryLoc) return handle("end");
255
+ if (i.tryLoc <= this.prev) {
256
+ var c = n.call(i, "catchLoc"),
257
+ u = n.call(i, "finallyLoc");
258
+ if (c && u) {
259
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
260
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
261
+ } else if (c) {
262
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
263
+ } else {
264
+ if (!u) throw new Error("try statement without catch or finally");
265
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
266
+ }
267
+ }
268
+ }
269
+ },
270
+ abrupt: function (t, e) {
271
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
272
+ var o = this.tryEntries[r];
273
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
274
+ var i = o;
275
+ break;
276
+ }
277
+ }
278
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
279
+ var a = i ? i.completion : {};
280
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
281
+ },
282
+ complete: function (t, e) {
283
+ if ("throw" === t.type) throw t.arg;
284
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
285
+ },
286
+ finish: function (t) {
287
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
288
+ var r = this.tryEntries[e];
289
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
290
+ }
291
+ },
292
+ catch: function (t) {
293
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
294
+ var r = this.tryEntries[e];
295
+ if (r.tryLoc === t) {
296
+ var n = r.completion;
297
+ if ("throw" === n.type) {
298
+ var o = n.arg;
299
+ resetTryEntry(r);
300
+ }
301
+ return o;
302
+ }
303
+ }
304
+ throw new Error("illegal catch attempt");
305
+ },
306
+ delegateYield: function (e, r, n) {
307
+ return this.delegate = {
308
+ iterator: values(e),
309
+ resultName: r,
310
+ nextLoc: n
311
+ }, "next" === this.method && (this.arg = t), y;
312
+ }
313
+ }, e;
314
+ }
315
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
316
+ try {
317
+ var info = gen[key](arg);
318
+ var value = info.value;
319
+ } catch (error) {
320
+ reject(error);
321
+ return;
322
+ }
323
+ if (info.done) {
324
+ resolve(value);
325
+ } else {
326
+ Promise.resolve(value).then(_next, _throw);
327
+ }
328
+ }
329
+ function _asyncToGenerator(fn) {
330
+ return function () {
331
+ var self = this,
332
+ args = arguments;
333
+ return new Promise(function (resolve, reject) {
334
+ var gen = fn.apply(self, args);
335
+ function _next(value) {
336
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
337
+ }
338
+ function _throw(err) {
339
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
340
+ }
341
+ _next(undefined);
342
+ });
343
+ };
344
+ }
12
345
  function _extends() {
13
346
  _extends = Object.assign ? Object.assign.bind() : function (target) {
14
347
  for (var i = 1; i < arguments.length; i++) {
@@ -562,7 +895,7 @@ var getColor = function getColor(props) {
562
895
  }
563
896
  return '#979aa5';
564
897
  };
565
- var Container$3 = /*#__PURE__*/styled.div(_templateObject$7 || (_templateObject$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background-color: #f3f5f9;\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n border-width: 2px;\n border-radius: 4px;\n border-color: var(", ");\n border-style: dashed;\n color: #5a5d68;\n outline: none;\n transition: border 0.24s ease-in-out;\n\n & > span {\n margin: 8px 10px 0 0;\n display: flex;\n }\n"])), function (props) {
898
+ var Container$3 = /*#__PURE__*/styled.div(_templateObject$7 || (_templateObject$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background-color: #f3f5f9;\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n padding: 20px;\n border-width: 2px;\n border-radius: 4px;\n border-color: var(", ");\n border-style: dashed;\n color: #5a5d68;\n outline: none;\n transition: border 0.24s ease-in-out;\n\n & > span {\n margin: 8px 10px 0 0;\n display: flex;\n }\n\n button {\n padding: 8px 16px 8px 16px;\n border-radius: 4px;\n border: 2px #102693 solid;\n margin-top: 10px;\n }\n"])), function (props) {
566
899
  return getColor(props);
567
900
  });
568
901
 
@@ -653,6 +986,58 @@ AreaUpload.defaultProps = {
653
986
  hasListFiles: true
654
987
  };
655
988
 
989
+ var _excluded$5 = ["children"];
990
+ var SharedPropsContext = /*#__PURE__*/createContext(undefined);
991
+ var useSharedProps = function useSharedProps() {
992
+ var context = useContext(SharedPropsContext);
993
+ if (!context) {
994
+ throw new Error('useSharedProps deve ser usado dentro de um SharedPropsProvider');
995
+ }
996
+ return context.props;
997
+ };
998
+ var SharedPropsProvider = function SharedPropsProvider(_ref) {
999
+ var children = _ref.children,
1000
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
1001
+ return React.createElement(SharedPropsContext.Provider, {
1002
+ value: {
1003
+ props: props
1004
+ }
1005
+ }, children);
1006
+ };
1007
+
1008
+ var url = process.env.REACT_APP_API_URL || 'http://localhost:5000/';
1009
+ axios.defaults.baseURL = url + "/";
1010
+ var api = /*#__PURE__*/axios.create();
1011
+
1012
+ var getFiles = /*#__PURE__*/function () {
1013
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(id) {
1014
+ var files;
1015
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1016
+ while (1) switch (_context.prev = _context.next) {
1017
+ case 0:
1018
+ _context.next = 2;
1019
+ return api.get("/files/" + id);
1020
+ case 2:
1021
+ files = _context.sent;
1022
+ return _context.abrupt("return", files);
1023
+ case 4:
1024
+ case "end":
1025
+ return _context.stop();
1026
+ }
1027
+ }, _callee);
1028
+ }));
1029
+ return function getFiles(_x) {
1030
+ return _ref.apply(this, arguments);
1031
+ };
1032
+ }();
1033
+
1034
+ function getFilesAction(id) {
1035
+ return {
1036
+ type: 'GET_FILES',
1037
+ payload: getFiles(id)
1038
+ };
1039
+ }
1040
+
656
1041
  var FileArea = function FileArea() {
657
1042
  var _useState = useState([]),
658
1043
  files = _useState[0],
@@ -663,42 +1048,25 @@ var FileArea = function FileArea() {
663
1048
  var _useState3 = useState(),
664
1049
  uploadFile = _useState3[0],
665
1050
  setUploadFile = _useState3[1];
666
- var _useLocation = useLocation(),
667
- pathname = _useLocation.pathname;
668
1051
  var _useState4 = useState(false),
669
1052
  modal = _useState4[0],
670
1053
  setModal = _useState4[1];
671
- var id = pathname.split('/')[4];
672
- var t = getLanguage('pt-br');
1054
+ var _useSharedProps = useSharedProps(),
1055
+ id = _useSharedProps.id,
1056
+ language = _useSharedProps.language;
1057
+ var t = getLanguage(language);
1058
+ var dispatch = useDispatch();
1059
+ var initFiles = useSelector(function (state) {
1060
+ return state.initFiles;
1061
+ });
673
1062
  var tags = ["pae", "boteria", "vr", "code7", "vidalink"];
674
1063
  useEffect(function () {
675
- setFiles([{
676
- "name": "Documentação conceitual Code7_v3",
677
- "tags": "boteria, code7"
678
- }, {
679
- "name": "PAE_Programa_Apoio_ao_Empregado",
680
- "tags": "pae, vr"
681
- }, {
682
- "name": "Vidalink",
683
- "tags": "vidalink, vr"
684
- }, {
685
- "name": "[GUIA PRÁTICO] Como criar o chatbot perfeito",
686
- "tags": "ebook, code7"
687
- }]);
688
- setInitialFiles([{
689
- "name": "Documentação conceitual Code7_v3",
690
- "tags": "boteria, code7"
691
- }, {
692
- "name": "PAE_Programa_Apoio_ao_Empregado",
693
- "tags": "pae, vr"
694
- }, {
695
- "name": "Vidalink",
696
- "tags": "vidalink, vr"
697
- }, {
698
- "name": "[GUIA PRÁTICO] Como criar o chatbot perfeito",
699
- "tags": "ebook, code7"
700
- }]);
1064
+ dispatch(getFilesAction(id));
701
1065
  }, []);
1066
+ useEffect(function () {
1067
+ setFiles(initFiles);
1068
+ setInitialFiles(initFiles);
1069
+ }, [initFiles]);
702
1070
  useEffect(function () {
703
1071
  console.log('files, id, t: ', files, id, t);
704
1072
  }, [files]);
@@ -910,7 +1278,7 @@ var Leia = function Leia(props) {
910
1278
  var activeTab = useMemo(function () {
911
1279
  return pathname.split('/')[5] || 'files';
912
1280
  }, [pathname]);
913
- return React.createElement(React.Fragment, null, React.createElement(Tabs, {
1281
+ return React.createElement(SharedPropsProvider, Object.assign({}, props), React.createElement(React.Fragment, null, React.createElement(Tabs, {
914
1282
  value: activeTab,
915
1283
  onChange: function onChange(value) {
916
1284
  return history.push(match.url + "/" + value);
@@ -931,7 +1299,7 @@ var Leia = function Leia(props) {
931
1299
  }), React.createElement(Route, {
932
1300
  path: match.path + "/test",
933
1301
  component: TestArea
934
- }))));
1302
+ })))));
935
1303
  };
936
1304
 
937
1305
  function Code7(props) {