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.
@@ -10,12 +10,345 @@ var reactRouterDom = require('react-router-dom');
10
10
  var PropTypes = _interopDefault(require('prop-types'));
11
11
  var cc = _interopDefault(require('classcat'));
12
12
  var styled = _interopDefault(require('styled-components'));
13
+ var reactRedux = require('react-redux');
13
14
  var fa = require('react-icons/fa');
14
15
  var unorm = _interopDefault(require('unorm'));
15
16
  var md = require('react-icons/md');
16
17
  var reactDropzone = require('react-dropzone');
18
+ var axios = _interopDefault(require('axios'));
17
19
  var pi = require('react-icons/pi');
18
20
 
21
+ function _regeneratorRuntime() {
22
+ _regeneratorRuntime = function () {
23
+ return e;
24
+ };
25
+ var t,
26
+ e = {},
27
+ r = Object.prototype,
28
+ n = r.hasOwnProperty,
29
+ o = Object.defineProperty || function (t, e, r) {
30
+ t[e] = r.value;
31
+ },
32
+ i = "function" == typeof Symbol ? Symbol : {},
33
+ a = i.iterator || "@@iterator",
34
+ c = i.asyncIterator || "@@asyncIterator",
35
+ u = i.toStringTag || "@@toStringTag";
36
+ function define(t, e, r) {
37
+ return Object.defineProperty(t, e, {
38
+ value: r,
39
+ enumerable: !0,
40
+ configurable: !0,
41
+ writable: !0
42
+ }), t[e];
43
+ }
44
+ try {
45
+ define({}, "");
46
+ } catch (t) {
47
+ define = function (t, e, r) {
48
+ return t[e] = r;
49
+ };
50
+ }
51
+ function wrap(t, e, r, n) {
52
+ var i = e && e.prototype instanceof Generator ? e : Generator,
53
+ a = Object.create(i.prototype),
54
+ c = new Context(n || []);
55
+ return o(a, "_invoke", {
56
+ value: makeInvokeMethod(t, r, c)
57
+ }), a;
58
+ }
59
+ function tryCatch(t, e, r) {
60
+ try {
61
+ return {
62
+ type: "normal",
63
+ arg: t.call(e, r)
64
+ };
65
+ } catch (t) {
66
+ return {
67
+ type: "throw",
68
+ arg: t
69
+ };
70
+ }
71
+ }
72
+ e.wrap = wrap;
73
+ var h = "suspendedStart",
74
+ l = "suspendedYield",
75
+ f = "executing",
76
+ s = "completed",
77
+ y = {};
78
+ function Generator() {}
79
+ function GeneratorFunction() {}
80
+ function GeneratorFunctionPrototype() {}
81
+ var p = {};
82
+ define(p, a, function () {
83
+ return this;
84
+ });
85
+ var d = Object.getPrototypeOf,
86
+ v = d && d(d(values([])));
87
+ v && v !== r && n.call(v, a) && (p = v);
88
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
89
+ function defineIteratorMethods(t) {
90
+ ["next", "throw", "return"].forEach(function (e) {
91
+ define(t, e, function (t) {
92
+ return this._invoke(e, t);
93
+ });
94
+ });
95
+ }
96
+ function AsyncIterator(t, e) {
97
+ function invoke(r, o, i, a) {
98
+ var c = tryCatch(t[r], t, o);
99
+ if ("throw" !== c.type) {
100
+ var u = c.arg,
101
+ h = u.value;
102
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
103
+ invoke("next", t, i, a);
104
+ }, function (t) {
105
+ invoke("throw", t, i, a);
106
+ }) : e.resolve(h).then(function (t) {
107
+ u.value = t, i(u);
108
+ }, function (t) {
109
+ return invoke("throw", t, i, a);
110
+ });
111
+ }
112
+ a(c.arg);
113
+ }
114
+ var r;
115
+ o(this, "_invoke", {
116
+ value: function (t, n) {
117
+ function callInvokeWithMethodAndArg() {
118
+ return new e(function (e, r) {
119
+ invoke(t, n, e, r);
120
+ });
121
+ }
122
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
123
+ }
124
+ });
125
+ }
126
+ function makeInvokeMethod(e, r, n) {
127
+ var o = h;
128
+ return function (i, a) {
129
+ if (o === f) throw new Error("Generator is already running");
130
+ if (o === s) {
131
+ if ("throw" === i) throw a;
132
+ return {
133
+ value: t,
134
+ done: !0
135
+ };
136
+ }
137
+ for (n.method = i, n.arg = a;;) {
138
+ var c = n.delegate;
139
+ if (c) {
140
+ var u = maybeInvokeDelegate(c, n);
141
+ if (u) {
142
+ if (u === y) continue;
143
+ return u;
144
+ }
145
+ }
146
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
147
+ if (o === h) throw o = s, n.arg;
148
+ n.dispatchException(n.arg);
149
+ } else "return" === n.method && n.abrupt("return", n.arg);
150
+ o = f;
151
+ var p = tryCatch(e, r, n);
152
+ if ("normal" === p.type) {
153
+ if (o = n.done ? s : l, p.arg === y) continue;
154
+ return {
155
+ value: p.arg,
156
+ done: n.done
157
+ };
158
+ }
159
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
160
+ }
161
+ };
162
+ }
163
+ function maybeInvokeDelegate(e, r) {
164
+ var n = r.method,
165
+ o = e.iterator[n];
166
+ 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;
167
+ var i = tryCatch(o, e.iterator, r.arg);
168
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
169
+ var a = i.arg;
170
+ 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);
171
+ }
172
+ function pushTryEntry(t) {
173
+ var e = {
174
+ tryLoc: t[0]
175
+ };
176
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
177
+ }
178
+ function resetTryEntry(t) {
179
+ var e = t.completion || {};
180
+ e.type = "normal", delete e.arg, t.completion = e;
181
+ }
182
+ function Context(t) {
183
+ this.tryEntries = [{
184
+ tryLoc: "root"
185
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
186
+ }
187
+ function values(e) {
188
+ if (e || "" === e) {
189
+ var r = e[a];
190
+ if (r) return r.call(e);
191
+ if ("function" == typeof e.next) return e;
192
+ if (!isNaN(e.length)) {
193
+ var o = -1,
194
+ i = function next() {
195
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
196
+ return next.value = t, next.done = !0, next;
197
+ };
198
+ return i.next = i;
199
+ }
200
+ }
201
+ throw new TypeError(typeof e + " is not iterable");
202
+ }
203
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
204
+ value: GeneratorFunctionPrototype,
205
+ configurable: !0
206
+ }), o(GeneratorFunctionPrototype, "constructor", {
207
+ value: GeneratorFunction,
208
+ configurable: !0
209
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
210
+ var e = "function" == typeof t && t.constructor;
211
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
212
+ }, e.mark = function (t) {
213
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
214
+ }, e.awrap = function (t) {
215
+ return {
216
+ __await: t
217
+ };
218
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
219
+ return this;
220
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
221
+ void 0 === i && (i = Promise);
222
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
223
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
224
+ return t.done ? t.value : a.next();
225
+ });
226
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
227
+ return this;
228
+ }), define(g, "toString", function () {
229
+ return "[object Generator]";
230
+ }), e.keys = function (t) {
231
+ var e = Object(t),
232
+ r = [];
233
+ for (var n in e) r.push(n);
234
+ return r.reverse(), function next() {
235
+ for (; r.length;) {
236
+ var t = r.pop();
237
+ if (t in e) return next.value = t, next.done = !1, next;
238
+ }
239
+ return next.done = !0, next;
240
+ };
241
+ }, e.values = values, Context.prototype = {
242
+ constructor: Context,
243
+ reset: function (e) {
244
+ 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);
245
+ },
246
+ stop: function () {
247
+ this.done = !0;
248
+ var t = this.tryEntries[0].completion;
249
+ if ("throw" === t.type) throw t.arg;
250
+ return this.rval;
251
+ },
252
+ dispatchException: function (e) {
253
+ if (this.done) throw e;
254
+ var r = this;
255
+ function handle(n, o) {
256
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
257
+ }
258
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
259
+ var i = this.tryEntries[o],
260
+ a = i.completion;
261
+ if ("root" === i.tryLoc) return handle("end");
262
+ if (i.tryLoc <= this.prev) {
263
+ var c = n.call(i, "catchLoc"),
264
+ u = n.call(i, "finallyLoc");
265
+ if (c && u) {
266
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
267
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
268
+ } else if (c) {
269
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
270
+ } else {
271
+ if (!u) throw new Error("try statement without catch or finally");
272
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
273
+ }
274
+ }
275
+ }
276
+ },
277
+ abrupt: function (t, e) {
278
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
279
+ var o = this.tryEntries[r];
280
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
281
+ var i = o;
282
+ break;
283
+ }
284
+ }
285
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
286
+ var a = i ? i.completion : {};
287
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
288
+ },
289
+ complete: function (t, e) {
290
+ if ("throw" === t.type) throw t.arg;
291
+ 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;
292
+ },
293
+ finish: function (t) {
294
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
295
+ var r = this.tryEntries[e];
296
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
297
+ }
298
+ },
299
+ catch: function (t) {
300
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
301
+ var r = this.tryEntries[e];
302
+ if (r.tryLoc === t) {
303
+ var n = r.completion;
304
+ if ("throw" === n.type) {
305
+ var o = n.arg;
306
+ resetTryEntry(r);
307
+ }
308
+ return o;
309
+ }
310
+ }
311
+ throw new Error("illegal catch attempt");
312
+ },
313
+ delegateYield: function (e, r, n) {
314
+ return this.delegate = {
315
+ iterator: values(e),
316
+ resultName: r,
317
+ nextLoc: n
318
+ }, "next" === this.method && (this.arg = t), y;
319
+ }
320
+ }, e;
321
+ }
322
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
323
+ try {
324
+ var info = gen[key](arg);
325
+ var value = info.value;
326
+ } catch (error) {
327
+ reject(error);
328
+ return;
329
+ }
330
+ if (info.done) {
331
+ resolve(value);
332
+ } else {
333
+ Promise.resolve(value).then(_next, _throw);
334
+ }
335
+ }
336
+ function _asyncToGenerator(fn) {
337
+ return function () {
338
+ var self = this,
339
+ args = arguments;
340
+ return new Promise(function (resolve, reject) {
341
+ var gen = fn.apply(self, args);
342
+ function _next(value) {
343
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
344
+ }
345
+ function _throw(err) {
346
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
347
+ }
348
+ _next(undefined);
349
+ });
350
+ };
351
+ }
19
352
  function _extends() {
20
353
  _extends = Object.assign ? Object.assign.bind() : function (target) {
21
354
  for (var i = 1; i < arguments.length; i++) {
@@ -569,7 +902,7 @@ var getColor = function getColor(props) {
569
902
  }
570
903
  return '#979aa5';
571
904
  };
572
- 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) {
905
+ 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) {
573
906
  return getColor(props);
574
907
  });
575
908
 
@@ -660,6 +993,58 @@ AreaUpload.defaultProps = {
660
993
  hasListFiles: true
661
994
  };
662
995
 
996
+ var _excluded$5 = ["children"];
997
+ var SharedPropsContext = /*#__PURE__*/React.createContext(undefined);
998
+ var useSharedProps = function useSharedProps() {
999
+ var context = React.useContext(SharedPropsContext);
1000
+ if (!context) {
1001
+ throw new Error('useSharedProps deve ser usado dentro de um SharedPropsProvider');
1002
+ }
1003
+ return context.props;
1004
+ };
1005
+ var SharedPropsProvider = function SharedPropsProvider(_ref) {
1006
+ var children = _ref.children,
1007
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
1008
+ return React__default.createElement(SharedPropsContext.Provider, {
1009
+ value: {
1010
+ props: props
1011
+ }
1012
+ }, children);
1013
+ };
1014
+
1015
+ var url = process.env.REACT_APP_API_URL || 'http://localhost:5000/';
1016
+ axios.defaults.baseURL = url + "/";
1017
+ var api = /*#__PURE__*/axios.create();
1018
+
1019
+ var getFiles = /*#__PURE__*/function () {
1020
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(id) {
1021
+ var files;
1022
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1023
+ while (1) switch (_context.prev = _context.next) {
1024
+ case 0:
1025
+ _context.next = 2;
1026
+ return api.get("/files/" + id);
1027
+ case 2:
1028
+ files = _context.sent;
1029
+ return _context.abrupt("return", files);
1030
+ case 4:
1031
+ case "end":
1032
+ return _context.stop();
1033
+ }
1034
+ }, _callee);
1035
+ }));
1036
+ return function getFiles(_x) {
1037
+ return _ref.apply(this, arguments);
1038
+ };
1039
+ }();
1040
+
1041
+ function getFilesAction(id) {
1042
+ return {
1043
+ type: 'GET_FILES',
1044
+ payload: getFiles(id)
1045
+ };
1046
+ }
1047
+
663
1048
  var FileArea = function FileArea() {
664
1049
  var _useState = React.useState([]),
665
1050
  files = _useState[0],
@@ -670,42 +1055,25 @@ var FileArea = function FileArea() {
670
1055
  var _useState3 = React.useState(),
671
1056
  uploadFile = _useState3[0],
672
1057
  setUploadFile = _useState3[1];
673
- var _useLocation = reactRouterDom.useLocation(),
674
- pathname = _useLocation.pathname;
675
1058
  var _useState4 = React.useState(false),
676
1059
  modal = _useState4[0],
677
1060
  setModal = _useState4[1];
678
- var id = pathname.split('/')[4];
679
- var t = getLanguage('pt-br');
1061
+ var _useSharedProps = useSharedProps(),
1062
+ id = _useSharedProps.id,
1063
+ language = _useSharedProps.language;
1064
+ var t = getLanguage(language);
1065
+ var dispatch = reactRedux.useDispatch();
1066
+ var initFiles = reactRedux.useSelector(function (state) {
1067
+ return state.initFiles;
1068
+ });
680
1069
  var tags = ["pae", "boteria", "vr", "code7", "vidalink"];
681
1070
  React.useEffect(function () {
682
- setFiles([{
683
- "name": "Documentação conceitual Code7_v3",
684
- "tags": "boteria, code7"
685
- }, {
686
- "name": "PAE_Programa_Apoio_ao_Empregado",
687
- "tags": "pae, vr"
688
- }, {
689
- "name": "Vidalink",
690
- "tags": "vidalink, vr"
691
- }, {
692
- "name": "[GUIA PRÁTICO] Como criar o chatbot perfeito",
693
- "tags": "ebook, code7"
694
- }]);
695
- setInitialFiles([{
696
- "name": "Documentação conceitual Code7_v3",
697
- "tags": "boteria, code7"
698
- }, {
699
- "name": "PAE_Programa_Apoio_ao_Empregado",
700
- "tags": "pae, vr"
701
- }, {
702
- "name": "Vidalink",
703
- "tags": "vidalink, vr"
704
- }, {
705
- "name": "[GUIA PRÁTICO] Como criar o chatbot perfeito",
706
- "tags": "ebook, code7"
707
- }]);
1071
+ dispatch(getFilesAction(id));
708
1072
  }, []);
1073
+ React.useEffect(function () {
1074
+ setFiles(initFiles);
1075
+ setInitialFiles(initFiles);
1076
+ }, [initFiles]);
709
1077
  React.useEffect(function () {
710
1078
  console.log('files, id, t: ', files, id, t);
711
1079
  }, [files]);
@@ -917,7 +1285,7 @@ var Leia = function Leia(props) {
917
1285
  var activeTab = React.useMemo(function () {
918
1286
  return pathname.split('/')[5] || 'files';
919
1287
  }, [pathname]);
920
- return React__default.createElement(React__default.Fragment, null, React__default.createElement(Tabs, {
1288
+ return React__default.createElement(SharedPropsProvider, Object.assign({}, props), React__default.createElement(React__default.Fragment, null, React__default.createElement(Tabs, {
921
1289
  value: activeTab,
922
1290
  onChange: function onChange(value) {
923
1291
  return history.push(match.url + "/" + value);
@@ -938,7 +1306,7 @@ var Leia = function Leia(props) {
938
1306
  }), React__default.createElement(reactRouterDom.Route, {
939
1307
  path: match.path + "/test",
940
1308
  component: TestArea
941
- }))));
1309
+ })))));
942
1310
  };
943
1311
 
944
1312
  function Code7(props) {