@c-rex/templates 0.0.8 → 0.0.9
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/dist/home/layout.cjs.js +893 -0
- package/dist/home/layout.cjs.js.map +1 -0
- package/dist/home/layout.d.cts +13 -0
- package/dist/home/layout.d.ts +13 -0
- package/dist/home/layout.esm.js +827 -0
- package/dist/home/layout.esm.js.map +1 -0
- package/dist/home/page.cjs.js +812 -0
- package/dist/home/page.cjs.js.map +1 -0
- package/dist/home/page.d.cts +9 -0
- package/dist/home/page.d.ts +9 -0
- package/dist/home/page.esm.js +746 -0
- package/dist/home/page.esm.js.map +1 -0
- package/dist/info/page.cjs.js +820 -0
- package/dist/info/page.cjs.js.map +1 -0
- package/dist/info/page.d.cts +9 -0
- package/dist/info/page.d.ts +9 -0
- package/dist/info/page.esm.js +755 -0
- package/dist/info/page.esm.js.map +1 -0
- package/dist/layout.cjs.js +89 -0
- package/dist/layout.cjs.js.map +1 -0
- package/dist/layout.d.cts +9 -0
- package/dist/layout.d.ts +9 -0
- package/dist/layout.esm.js +28 -0
- package/dist/layout.esm.js.map +1 -0
- package/package.json +18 -12
- package/src/home/layout.tsx +0 -61
- package/src/home/page.tsx +0 -65
- package/src/info/page.tsx +0 -66
- package/src/layout.tsx +0 -26
|
@@ -0,0 +1,893 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _array_without_holes(arr) {
|
|
11
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
+
}
|
|
13
|
+
function _assert_this_initialized(self) {
|
|
14
|
+
if (self === void 0) {
|
|
15
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
16
|
+
}
|
|
17
|
+
return self;
|
|
18
|
+
}
|
|
19
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
20
|
+
try {
|
|
21
|
+
var info = gen[key](arg);
|
|
22
|
+
var value = info.value;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
reject(error);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (info.done) {
|
|
28
|
+
resolve(value);
|
|
29
|
+
} else {
|
|
30
|
+
Promise.resolve(value).then(_next, _throw);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function _async_to_generator(fn) {
|
|
34
|
+
return function() {
|
|
35
|
+
var self = this, args = arguments;
|
|
36
|
+
return new Promise(function(resolve, reject) {
|
|
37
|
+
var gen = fn.apply(self, args);
|
|
38
|
+
function _next(value) {
|
|
39
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
40
|
+
}
|
|
41
|
+
function _throw(err) {
|
|
42
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
43
|
+
}
|
|
44
|
+
_next(undefined);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function _call_super(_this, derived, args) {
|
|
49
|
+
derived = _get_prototype_of(derived);
|
|
50
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
51
|
+
}
|
|
52
|
+
function _class_call_check(instance, Constructor) {
|
|
53
|
+
if (!(instance instanceof Constructor)) {
|
|
54
|
+
throw new TypeError("Cannot call a class as a function");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function _defineProperties(target, props) {
|
|
58
|
+
for(var i = 0; i < props.length; i++){
|
|
59
|
+
var descriptor = props[i];
|
|
60
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
61
|
+
descriptor.configurable = true;
|
|
62
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
63
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
67
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
68
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
69
|
+
return Constructor;
|
|
70
|
+
}
|
|
71
|
+
function _get_prototype_of(o) {
|
|
72
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
73
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
74
|
+
};
|
|
75
|
+
return _get_prototype_of(o);
|
|
76
|
+
}
|
|
77
|
+
function _inherits(subClass, superClass) {
|
|
78
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
79
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
80
|
+
}
|
|
81
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
82
|
+
constructor: {
|
|
83
|
+
value: subClass,
|
|
84
|
+
writable: true,
|
|
85
|
+
configurable: true
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
89
|
+
}
|
|
90
|
+
function _iterable_to_array(iter) {
|
|
91
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
92
|
+
}
|
|
93
|
+
function _iterable_to_array_limit(arr, i) {
|
|
94
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
95
|
+
if (_i == null) return;
|
|
96
|
+
var _arr = [];
|
|
97
|
+
var _n = true;
|
|
98
|
+
var _d = false;
|
|
99
|
+
var _s, _e;
|
|
100
|
+
try {
|
|
101
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
102
|
+
_arr.push(_s.value);
|
|
103
|
+
if (i && _arr.length === i) break;
|
|
104
|
+
}
|
|
105
|
+
} catch (err) {
|
|
106
|
+
_d = true;
|
|
107
|
+
_e = err;
|
|
108
|
+
} finally{
|
|
109
|
+
try {
|
|
110
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
111
|
+
} finally{
|
|
112
|
+
if (_d) throw _e;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return _arr;
|
|
116
|
+
}
|
|
117
|
+
function _non_iterable_rest() {
|
|
118
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
119
|
+
}
|
|
120
|
+
function _non_iterable_spread() {
|
|
121
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
122
|
+
}
|
|
123
|
+
function _possible_constructor_return(self, call) {
|
|
124
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
125
|
+
return call;
|
|
126
|
+
}
|
|
127
|
+
return _assert_this_initialized(self);
|
|
128
|
+
}
|
|
129
|
+
function _set_prototype_of(o, p) {
|
|
130
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
131
|
+
o.__proto__ = p;
|
|
132
|
+
return o;
|
|
133
|
+
};
|
|
134
|
+
return _set_prototype_of(o, p);
|
|
135
|
+
}
|
|
136
|
+
function _sliced_to_array(arr, i) {
|
|
137
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
138
|
+
}
|
|
139
|
+
function _to_consumable_array(arr) {
|
|
140
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
141
|
+
}
|
|
142
|
+
function _type_of(obj) {
|
|
143
|
+
"@swc/helpers - typeof";
|
|
144
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
145
|
+
}
|
|
146
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
147
|
+
if (!o) return;
|
|
148
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
149
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
150
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
151
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
152
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
153
|
+
}
|
|
154
|
+
function _is_native_reflect_construct() {
|
|
155
|
+
try {
|
|
156
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
157
|
+
} catch (_) {}
|
|
158
|
+
return (_is_native_reflect_construct = function() {
|
|
159
|
+
return !!result;
|
|
160
|
+
})();
|
|
161
|
+
}
|
|
162
|
+
function _ts_generator(thisArg, body) {
|
|
163
|
+
var f, y, t, _ = {
|
|
164
|
+
label: 0,
|
|
165
|
+
sent: function() {
|
|
166
|
+
if (t[0] & 1) throw t[1];
|
|
167
|
+
return t[1];
|
|
168
|
+
},
|
|
169
|
+
trys: [],
|
|
170
|
+
ops: []
|
|
171
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
172
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
173
|
+
return this;
|
|
174
|
+
}), g;
|
|
175
|
+
function verb(n) {
|
|
176
|
+
return function(v) {
|
|
177
|
+
return step([
|
|
178
|
+
n,
|
|
179
|
+
v
|
|
180
|
+
]);
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function step(op) {
|
|
184
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
185
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
186
|
+
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;
|
|
187
|
+
if (y = 0, t) op = [
|
|
188
|
+
op[0] & 2,
|
|
189
|
+
t.value
|
|
190
|
+
];
|
|
191
|
+
switch(op[0]){
|
|
192
|
+
case 0:
|
|
193
|
+
case 1:
|
|
194
|
+
t = op;
|
|
195
|
+
break;
|
|
196
|
+
case 4:
|
|
197
|
+
_.label++;
|
|
198
|
+
return {
|
|
199
|
+
value: op[1],
|
|
200
|
+
done: false
|
|
201
|
+
};
|
|
202
|
+
case 5:
|
|
203
|
+
_.label++;
|
|
204
|
+
y = op[1];
|
|
205
|
+
op = [
|
|
206
|
+
0
|
|
207
|
+
];
|
|
208
|
+
continue;
|
|
209
|
+
case 7:
|
|
210
|
+
op = _.ops.pop();
|
|
211
|
+
_.trys.pop();
|
|
212
|
+
continue;
|
|
213
|
+
default:
|
|
214
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
215
|
+
_ = 0;
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
219
|
+
_.label = op[1];
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
223
|
+
_.label = t[1];
|
|
224
|
+
t = op;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
if (t && _.label < t[2]) {
|
|
228
|
+
_.label = t[2];
|
|
229
|
+
_.ops.push(op);
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
if (t[2]) _.ops.pop();
|
|
233
|
+
_.trys.pop();
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
op = body.call(thisArg, _);
|
|
237
|
+
} catch (e) {
|
|
238
|
+
op = [
|
|
239
|
+
6,
|
|
240
|
+
e
|
|
241
|
+
];
|
|
242
|
+
y = 0;
|
|
243
|
+
} finally{
|
|
244
|
+
f = t = 0;
|
|
245
|
+
}
|
|
246
|
+
if (op[0] & 5) throw op[1];
|
|
247
|
+
return {
|
|
248
|
+
value: op[0] ? op[1] : void 0,
|
|
249
|
+
done: true
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
var __create = Object.create;
|
|
254
|
+
var __defProp = Object.defineProperty;
|
|
255
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
256
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
257
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
258
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
259
|
+
var __export = function(target, all) {
|
|
260
|
+
for(var name in all)__defProp(target, name, {
|
|
261
|
+
get: all[name],
|
|
262
|
+
enumerable: true
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
var __copyProps = function(to, from, except, desc) {
|
|
266
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
267
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
268
|
+
try {
|
|
269
|
+
var _loop = function() {
|
|
270
|
+
var key = _step.value;
|
|
271
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
272
|
+
get: function() {
|
|
273
|
+
return from[key];
|
|
274
|
+
},
|
|
275
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
279
|
+
} catch (err) {
|
|
280
|
+
_didIteratorError = true;
|
|
281
|
+
_iteratorError = err;
|
|
282
|
+
} finally{
|
|
283
|
+
try {
|
|
284
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
285
|
+
_iterator.return();
|
|
286
|
+
}
|
|
287
|
+
} finally{
|
|
288
|
+
if (_didIteratorError) {
|
|
289
|
+
throw _iteratorError;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return to;
|
|
295
|
+
};
|
|
296
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
297
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
298
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
299
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
300
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
301
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
302
|
+
value: mod,
|
|
303
|
+
enumerable: true
|
|
304
|
+
}) : target, mod);
|
|
305
|
+
};
|
|
306
|
+
var __toCommonJS = function(mod) {
|
|
307
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
308
|
+
value: true
|
|
309
|
+
}), mod);
|
|
310
|
+
};
|
|
311
|
+
// src/home/layout.tsx
|
|
312
|
+
var layout_exports = {};
|
|
313
|
+
__export(layout_exports, {
|
|
314
|
+
HomeLayout: function() {
|
|
315
|
+
return HomeLayout;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
module.exports = __toCommonJS(layout_exports);
|
|
319
|
+
// ../core/src/requests.ts
|
|
320
|
+
var import_axios = __toESM(require("axios"));
|
|
321
|
+
// ../constants/src/index.ts
|
|
322
|
+
var API = {
|
|
323
|
+
MAX_RETRY: 3,
|
|
324
|
+
API_TIMEOUT: 1e4,
|
|
325
|
+
API_HEADERS: {
|
|
326
|
+
"content-Type": "application/json"
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
// ../core/src/requests.ts
|
|
330
|
+
var CrexApi = /*#__PURE__*/ function() {
|
|
331
|
+
function CrexApi(baseUrl, logger) {
|
|
332
|
+
_class_call_check(this, CrexApi);
|
|
333
|
+
this.apiClient = import_axios.default.create({
|
|
334
|
+
baseURL: baseUrl,
|
|
335
|
+
headers: {
|
|
336
|
+
"content-Type": "application/json"
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
this.logger = logger;
|
|
340
|
+
}
|
|
341
|
+
_create_class(CrexApi, [
|
|
342
|
+
{
|
|
343
|
+
key: "execute",
|
|
344
|
+
value: function execute(_0) {
|
|
345
|
+
return /*#__PURE__*/ _async_to_generator(function(param) {
|
|
346
|
+
var url, method, params, body, headers, response, retry, error;
|
|
347
|
+
return _ts_generator(this, function(_state) {
|
|
348
|
+
switch(_state.label){
|
|
349
|
+
case 0:
|
|
350
|
+
url = param.url, method = param.method, params = param.params, body = param.body, headers = param.headers;
|
|
351
|
+
response = void 0;
|
|
352
|
+
retry = 0;
|
|
353
|
+
_state.label = 1;
|
|
354
|
+
case 1:
|
|
355
|
+
if (!(retry < API.MAX_RETRY)) return [
|
|
356
|
+
3,
|
|
357
|
+
6
|
|
358
|
+
];
|
|
359
|
+
_state.label = 2;
|
|
360
|
+
case 2:
|
|
361
|
+
_state.trys.push([
|
|
362
|
+
2,
|
|
363
|
+
4,
|
|
364
|
+
,
|
|
365
|
+
5
|
|
366
|
+
]);
|
|
367
|
+
return [
|
|
368
|
+
4,
|
|
369
|
+
this.apiClient.request({
|
|
370
|
+
url: url,
|
|
371
|
+
method: method,
|
|
372
|
+
data: body,
|
|
373
|
+
params: params,
|
|
374
|
+
headers: headers
|
|
375
|
+
})
|
|
376
|
+
];
|
|
377
|
+
case 3:
|
|
378
|
+
response = _state.sent();
|
|
379
|
+
return [
|
|
380
|
+
3,
|
|
381
|
+
5
|
|
382
|
+
];
|
|
383
|
+
case 4:
|
|
384
|
+
error = _state.sent();
|
|
385
|
+
this.logger.log("error", "API.execute error when request ".concat(url, ". Error: ").concat(error));
|
|
386
|
+
throw error;
|
|
387
|
+
case 5:
|
|
388
|
+
retry++;
|
|
389
|
+
return [
|
|
390
|
+
3,
|
|
391
|
+
1
|
|
392
|
+
];
|
|
393
|
+
case 6:
|
|
394
|
+
if (response) {
|
|
395
|
+
return [
|
|
396
|
+
2,
|
|
397
|
+
response.data
|
|
398
|
+
];
|
|
399
|
+
}
|
|
400
|
+
throw new Error("API.execute error: Failed to retrieve a valid response");
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}).apply(this, arguments);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
]);
|
|
407
|
+
return CrexApi;
|
|
408
|
+
}();
|
|
409
|
+
// ../core/src/cookies.ts
|
|
410
|
+
var GLOBAL_KEY = "__CREX_INITIAL_CONFIG__";
|
|
411
|
+
var CONFIG_COOKIE_KEY = "crex_config";
|
|
412
|
+
function isBrowser() {
|
|
413
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
414
|
+
}
|
|
415
|
+
function parseCookies() {
|
|
416
|
+
var cookies = {};
|
|
417
|
+
if (typeof document === "undefined") {
|
|
418
|
+
return cookies;
|
|
419
|
+
}
|
|
420
|
+
document.cookie.split(";").forEach(function(cookie) {
|
|
421
|
+
var _cookie_split = _sliced_to_array(cookie.split("="), 2), key = _cookie_split[0], value = _cookie_split[1];
|
|
422
|
+
if (key && value) {
|
|
423
|
+
cookies[key.trim()] = decodeURIComponent(value.trim());
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
return cookies;
|
|
427
|
+
}
|
|
428
|
+
function setCookie(name, value) {
|
|
429
|
+
var days = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 30;
|
|
430
|
+
if (typeof document === "undefined") return;
|
|
431
|
+
var expires = new Date(Date.now() + days * 86400 * 1e3).toUTCString();
|
|
432
|
+
document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; path=/; expires=").concat(expires, "; SameSite=Lax");
|
|
433
|
+
}
|
|
434
|
+
function setConfig(config) {
|
|
435
|
+
if (isBrowser()) {
|
|
436
|
+
setCookie(CONFIG_COOKIE_KEY, JSON.stringify(config));
|
|
437
|
+
} else {
|
|
438
|
+
if (typeof global !== "undefined" && !(GLOBAL_KEY in global)) {
|
|
439
|
+
global[GLOBAL_KEY] = null;
|
|
440
|
+
}
|
|
441
|
+
var globalConfig = global[GLOBAL_KEY];
|
|
442
|
+
if (globalConfig === null) {
|
|
443
|
+
global[GLOBAL_KEY] = config;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
function getConfig() {
|
|
448
|
+
var returnValue;
|
|
449
|
+
if (isBrowser()) {
|
|
450
|
+
var cookies = parseCookies();
|
|
451
|
+
var configStr = cookies[CONFIG_COOKIE_KEY];
|
|
452
|
+
if (configStr) {
|
|
453
|
+
try {
|
|
454
|
+
return JSON.parse(configStr);
|
|
455
|
+
} catch (e) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return null;
|
|
460
|
+
} else {
|
|
461
|
+
returnValue = global[GLOBAL_KEY];
|
|
462
|
+
}
|
|
463
|
+
return returnValue;
|
|
464
|
+
}
|
|
465
|
+
// ../core/src/sdk.ts
|
|
466
|
+
var CrexSDK = /*#__PURE__*/ function() {
|
|
467
|
+
function CrexSDK() {
|
|
468
|
+
_class_call_check(this, CrexSDK);
|
|
469
|
+
var config = getConfig();
|
|
470
|
+
this.customerConfig = config;
|
|
471
|
+
this.api = new CrexApi(this.customerConfig.baseUrl, null);
|
|
472
|
+
}
|
|
473
|
+
_create_class(CrexSDK, null, [
|
|
474
|
+
{
|
|
475
|
+
key: "setConfig",
|
|
476
|
+
value: function setConfig1(config) {
|
|
477
|
+
setConfig(config);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
]);
|
|
481
|
+
return CrexSDK;
|
|
482
|
+
}();
|
|
483
|
+
// ../utils/src/utils.ts
|
|
484
|
+
var createParams = function(fieldsList) {
|
|
485
|
+
var key = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Fields";
|
|
486
|
+
return fieldsList.map(function(item) {
|
|
487
|
+
return {
|
|
488
|
+
key: key,
|
|
489
|
+
value: item
|
|
490
|
+
};
|
|
491
|
+
});
|
|
492
|
+
};
|
|
493
|
+
var updateUrlWithParams = function(router, params) {
|
|
494
|
+
var searchParams = new URLSearchParams(window.location.search);
|
|
495
|
+
params.forEach(function(param) {
|
|
496
|
+
searchParams.set(param.key, param.value.toString());
|
|
497
|
+
});
|
|
498
|
+
var queryString = searchParams.toString();
|
|
499
|
+
router.push("".concat(window.location.pathname, "?").concat(queryString));
|
|
500
|
+
};
|
|
501
|
+
var generateQueryParams = function(params) {
|
|
502
|
+
var queryParams = params.map(function(param) {
|
|
503
|
+
return "".concat(encodeURIComponent(param.key), "=").concat(encodeURIComponent(param.value));
|
|
504
|
+
}).join("&");
|
|
505
|
+
return queryParams;
|
|
506
|
+
};
|
|
507
|
+
// ../utils/src/classMerge.ts
|
|
508
|
+
var import_clsx = require("clsx");
|
|
509
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
510
|
+
// ../services/src/baseService.ts
|
|
511
|
+
var BaseService = /*#__PURE__*/ function() {
|
|
512
|
+
function BaseService(endpoint) {
|
|
513
|
+
_class_call_check(this, BaseService);
|
|
514
|
+
this.SDK = new CrexSDK();
|
|
515
|
+
this.api = this.SDK.api;
|
|
516
|
+
this.endpoint = endpoint;
|
|
517
|
+
}
|
|
518
|
+
_create_class(BaseService, [
|
|
519
|
+
{
|
|
520
|
+
key: "request",
|
|
521
|
+
value: function request(_0) {
|
|
522
|
+
return /*#__PURE__*/ _async_to_generator(function(param) {
|
|
523
|
+
var _param_path, path, _param_method, method, _param_params, params, _param_headers, headers, _param_transformer, transformer, url, queryParams, response, error;
|
|
524
|
+
return _ts_generator(this, function(_state) {
|
|
525
|
+
switch(_state.label){
|
|
526
|
+
case 0:
|
|
527
|
+
_param_path = param.path, path = _param_path === void 0 ? "" : _param_path, _param_method = param.method, method = _param_method === void 0 ? "get" : _param_method, _param_params = param.params, params = _param_params === void 0 ? [] : _param_params, _param_headers = param.headers, headers = _param_headers === void 0 ? {} : _param_headers, _param_transformer = param.transformer, transformer = _param_transformer === void 0 ? function(response) {
|
|
528
|
+
return response;
|
|
529
|
+
} : _param_transformer;
|
|
530
|
+
_state.label = 1;
|
|
531
|
+
case 1:
|
|
532
|
+
_state.trys.push([
|
|
533
|
+
1,
|
|
534
|
+
4,
|
|
535
|
+
,
|
|
536
|
+
5
|
|
537
|
+
]);
|
|
538
|
+
url = "".concat(this.endpoint).concat(path);
|
|
539
|
+
queryParams = generateQueryParams(params);
|
|
540
|
+
if (queryParams.length > 0) {
|
|
541
|
+
url += "?".concat(queryParams);
|
|
542
|
+
}
|
|
543
|
+
return [
|
|
544
|
+
4,
|
|
545
|
+
this.api.execute({
|
|
546
|
+
url: url,
|
|
547
|
+
method: method,
|
|
548
|
+
headers: headers
|
|
549
|
+
})
|
|
550
|
+
];
|
|
551
|
+
case 2:
|
|
552
|
+
response = _state.sent();
|
|
553
|
+
return [
|
|
554
|
+
4,
|
|
555
|
+
transformer(response)
|
|
556
|
+
];
|
|
557
|
+
case 3:
|
|
558
|
+
return [
|
|
559
|
+
2,
|
|
560
|
+
_state.sent()
|
|
561
|
+
];
|
|
562
|
+
case 4:
|
|
563
|
+
error = _state.sent();
|
|
564
|
+
console.log("error", "BaseService.request error when request ".concat(path, ". Error: ").concat(error));
|
|
565
|
+
throw error;
|
|
566
|
+
case 5:
|
|
567
|
+
return [
|
|
568
|
+
2
|
|
569
|
+
];
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
}).apply(this, arguments);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
]);
|
|
576
|
+
return BaseService;
|
|
577
|
+
}();
|
|
578
|
+
// ../services/src/transforms/information.ts
|
|
579
|
+
var transformInformationUnits = function(data) {
|
|
580
|
+
return {
|
|
581
|
+
items: data.items.map(function(item) {
|
|
582
|
+
return item;
|
|
583
|
+
}),
|
|
584
|
+
pageInfo: data.pageInfo
|
|
585
|
+
};
|
|
586
|
+
};
|
|
587
|
+
// ../services/src/informationUnits.ts
|
|
588
|
+
var InformationUnitsService = /*#__PURE__*/ function(BaseService) {
|
|
589
|
+
_inherits(InformationUnitsService, BaseService);
|
|
590
|
+
function InformationUnitsService() {
|
|
591
|
+
_class_call_check(this, InformationUnitsService);
|
|
592
|
+
return _call_super(this, InformationUnitsService, [
|
|
593
|
+
"InformationUnits/"
|
|
594
|
+
]);
|
|
595
|
+
}
|
|
596
|
+
_create_class(InformationUnitsService, [
|
|
597
|
+
{
|
|
598
|
+
key: "getList",
|
|
599
|
+
value: function getList(queries, page, fields, language) {
|
|
600
|
+
return /*#__PURE__*/ _async_to_generator(function() {
|
|
601
|
+
var remainFields, params;
|
|
602
|
+
return _ts_generator(this, function(_state) {
|
|
603
|
+
switch(_state.label){
|
|
604
|
+
case 0:
|
|
605
|
+
remainFields = createParams(fields, "Fields");
|
|
606
|
+
params = [
|
|
607
|
+
{
|
|
608
|
+
key: "pageSize",
|
|
609
|
+
value: "8"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
key: "PageNumber",
|
|
613
|
+
value: (page - 1).toString()
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
key: "Query",
|
|
617
|
+
value: queries
|
|
618
|
+
}
|
|
619
|
+
].concat(_to_consumable_array(remainFields));
|
|
620
|
+
if (language != null) {
|
|
621
|
+
language.forEach(function(item) {
|
|
622
|
+
params.push({
|
|
623
|
+
key: "Restrict",
|
|
624
|
+
value: "languages~".concat(item)
|
|
625
|
+
});
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
return [
|
|
629
|
+
4,
|
|
630
|
+
this.request({
|
|
631
|
+
params: params,
|
|
632
|
+
transformer: transformInformationUnits
|
|
633
|
+
})
|
|
634
|
+
];
|
|
635
|
+
case 1:
|
|
636
|
+
return [
|
|
637
|
+
2,
|
|
638
|
+
_state.sent()
|
|
639
|
+
];
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
}).call(this);
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
key: "getItem",
|
|
647
|
+
value: function getItem(id) {
|
|
648
|
+
return /*#__PURE__*/ _async_to_generator(function() {
|
|
649
|
+
var params;
|
|
650
|
+
return _ts_generator(this, function(_state) {
|
|
651
|
+
switch(_state.label){
|
|
652
|
+
case 0:
|
|
653
|
+
params = [
|
|
654
|
+
{
|
|
655
|
+
key: "Fields",
|
|
656
|
+
value: "renditions"
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
key: "Fields",
|
|
660
|
+
value: "directoryNodes"
|
|
661
|
+
}
|
|
662
|
+
];
|
|
663
|
+
return [
|
|
664
|
+
4,
|
|
665
|
+
this.request({
|
|
666
|
+
path: id,
|
|
667
|
+
params: params
|
|
668
|
+
})
|
|
669
|
+
];
|
|
670
|
+
case 1:
|
|
671
|
+
return [
|
|
672
|
+
2,
|
|
673
|
+
_state.sent()
|
|
674
|
+
];
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}).call(this);
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
key: "getLanguages",
|
|
682
|
+
value: function getLanguages() {
|
|
683
|
+
return /*#__PURE__*/ _async_to_generator(function() {
|
|
684
|
+
return _ts_generator(this, function(_state) {
|
|
685
|
+
switch(_state.label){
|
|
686
|
+
case 0:
|
|
687
|
+
return [
|
|
688
|
+
4,
|
|
689
|
+
this.request({
|
|
690
|
+
path: "Languages",
|
|
691
|
+
transformer: function(data) {
|
|
692
|
+
return data.map(function(item) {
|
|
693
|
+
return item.value;
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
})
|
|
697
|
+
];
|
|
698
|
+
case 1:
|
|
699
|
+
return [
|
|
700
|
+
2,
|
|
701
|
+
_state.sent()
|
|
702
|
+
];
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
}).call(this);
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
key: "getSuggestions",
|
|
710
|
+
value: function getSuggestions(query) {
|
|
711
|
+
return /*#__PURE__*/ _async_to_generator(function() {
|
|
712
|
+
return _ts_generator(this, function(_state) {
|
|
713
|
+
switch(_state.label){
|
|
714
|
+
case 0:
|
|
715
|
+
return [
|
|
716
|
+
4,
|
|
717
|
+
this.request({
|
|
718
|
+
path: "Suggestions",
|
|
719
|
+
params: [
|
|
720
|
+
{
|
|
721
|
+
key: "prefix",
|
|
722
|
+
value: query
|
|
723
|
+
}
|
|
724
|
+
],
|
|
725
|
+
transformer: function(data) {
|
|
726
|
+
return data.suggestions.map(function(item) {
|
|
727
|
+
return item.value;
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
})
|
|
731
|
+
];
|
|
732
|
+
case 1:
|
|
733
|
+
return [
|
|
734
|
+
2,
|
|
735
|
+
_state.sent()
|
|
736
|
+
];
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}).call(this);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
]);
|
|
743
|
+
return InformationUnitsService;
|
|
744
|
+
}(BaseService);
|
|
745
|
+
// src/home/layout.tsx
|
|
746
|
+
var import_search_wrapper = require("@c-rex/components/search-wrapper");
|
|
747
|
+
// src/home/page.tsx
|
|
748
|
+
var import_navigation = require("next/navigation");
|
|
749
|
+
var import_button = require("@c-rex/ui/button");
|
|
750
|
+
var import_autocomplete = require("@c-rex/components/autocomplete");
|
|
751
|
+
var import_result_list = require("@c-rex/components/result-list");
|
|
752
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
753
|
+
var HomePage = function(param) {
|
|
754
|
+
var data = param.data;
|
|
755
|
+
var router = (0, import_navigation.useRouter)();
|
|
756
|
+
var initialValue = null;
|
|
757
|
+
var onSearch = function(value) {
|
|
758
|
+
var service = new InformationUnitsService();
|
|
759
|
+
return service.getSuggestions(value);
|
|
760
|
+
};
|
|
761
|
+
var onSelect = function(value) {
|
|
762
|
+
updateUrlWithParams(router, [
|
|
763
|
+
{
|
|
764
|
+
key: "search",
|
|
765
|
+
value: value.split(" ").join(",")
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
key: "operator",
|
|
769
|
+
value: "OR"
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
key: "page",
|
|
773
|
+
value: "1"
|
|
774
|
+
}
|
|
775
|
+
]);
|
|
776
|
+
};
|
|
777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
778
|
+
className: "container",
|
|
779
|
+
children: [
|
|
780
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
781
|
+
className: "grid grid-cols-12 gap-4 py-6",
|
|
782
|
+
children: [
|
|
783
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
784
|
+
className: "col-span-12 sm:col-span-9 md:col-span-10",
|
|
785
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_autocomplete.AutoComplete, {
|
|
786
|
+
initialValue: initialValue !== null && initialValue !== void 0 ? initialValue : "",
|
|
787
|
+
onSearch: onSearch,
|
|
788
|
+
onSelect: onSelect
|
|
789
|
+
})
|
|
790
|
+
}),
|
|
791
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
792
|
+
className: "col-span-12 sm:col-span-3 md:col-span-2",
|
|
793
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
794
|
+
className: "flex justify-end",
|
|
795
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, {
|
|
796
|
+
variant: "default",
|
|
797
|
+
children: "Filters"
|
|
798
|
+
})
|
|
799
|
+
})
|
|
800
|
+
})
|
|
801
|
+
]
|
|
802
|
+
}),
|
|
803
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_result_list.ResultList, {
|
|
804
|
+
items: data.items
|
|
805
|
+
})
|
|
806
|
+
]
|
|
807
|
+
});
|
|
808
|
+
};
|
|
809
|
+
// src/home/layout.tsx
|
|
810
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
811
|
+
var loadData = function(param) {
|
|
812
|
+
var search = param.search, page = param.page, language = param.language;
|
|
813
|
+
return /*#__PURE__*/ _async_to_generator(function() {
|
|
814
|
+
var service, pageAux, searchValue, availableLanguages, data, selectedLanguages, aux;
|
|
815
|
+
return _ts_generator(this, function(_state) {
|
|
816
|
+
switch(_state.label){
|
|
817
|
+
case 0:
|
|
818
|
+
service = new InformationUnitsService();
|
|
819
|
+
pageAux = page != void 0 ? Number(page) : 0;
|
|
820
|
+
searchValue = search != void 0 ? search : "";
|
|
821
|
+
return [
|
|
822
|
+
4,
|
|
823
|
+
service.getLanguages()
|
|
824
|
+
];
|
|
825
|
+
case 1:
|
|
826
|
+
availableLanguages = _state.sent();
|
|
827
|
+
data = {
|
|
828
|
+
items: []
|
|
829
|
+
};
|
|
830
|
+
selectedLanguages = [];
|
|
831
|
+
if (language != void 0) {
|
|
832
|
+
aux = language;
|
|
833
|
+
selectedLanguages = aux.split(",");
|
|
834
|
+
}
|
|
835
|
+
if (!searchValue) return [
|
|
836
|
+
3,
|
|
837
|
+
3
|
|
838
|
+
];
|
|
839
|
+
return [
|
|
840
|
+
4,
|
|
841
|
+
service.getList(searchValue, pageAux, selectedLanguages, [])
|
|
842
|
+
];
|
|
843
|
+
case 2:
|
|
844
|
+
data = _state.sent();
|
|
845
|
+
_state.label = 3;
|
|
846
|
+
case 3:
|
|
847
|
+
return [
|
|
848
|
+
2,
|
|
849
|
+
{
|
|
850
|
+
data: data,
|
|
851
|
+
filters: {
|
|
852
|
+
searchValue: searchValue,
|
|
853
|
+
page: pageAux,
|
|
854
|
+
selectedLanguage: selectedLanguages,
|
|
855
|
+
availableLanguages: availableLanguages
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
];
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
})();
|
|
862
|
+
};
|
|
863
|
+
var HomeLayout = function(param) {
|
|
864
|
+
var searchParams = param.searchParams;
|
|
865
|
+
return /*#__PURE__*/ _async_to_generator(function() {
|
|
866
|
+
var _ref, data, filters;
|
|
867
|
+
return _ts_generator(this, function(_state) {
|
|
868
|
+
switch(_state.label){
|
|
869
|
+
case 0:
|
|
870
|
+
return [
|
|
871
|
+
4,
|
|
872
|
+
loadData(searchParams)
|
|
873
|
+
];
|
|
874
|
+
case 1:
|
|
875
|
+
_ref = _state.sent(), data = _ref.data, filters = _ref.filters;
|
|
876
|
+
return [
|
|
877
|
+
2,
|
|
878
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_search_wrapper.SearchStateWrapper, {
|
|
879
|
+
filters: filters,
|
|
880
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(HomePage, {
|
|
881
|
+
data: data
|
|
882
|
+
})
|
|
883
|
+
})
|
|
884
|
+
];
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
})();
|
|
888
|
+
};
|
|
889
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
890
|
+
0 && (module.exports = {
|
|
891
|
+
HomeLayout: HomeLayout
|
|
892
|
+
});
|
|
893
|
+
//# sourceMappingURL=layout.cjs.js.map
|