code7-leia 0.1.49 → 0.1.53

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