@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.
@@ -0,0 +1,827 @@
1
+ // ../core/src/requests.ts
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
+ import axios from "axios";
254
+ // ../constants/src/index.ts
255
+ var API = {
256
+ MAX_RETRY: 3,
257
+ API_TIMEOUT: 1e4,
258
+ API_HEADERS: {
259
+ "content-Type": "application/json"
260
+ }
261
+ };
262
+ // ../core/src/requests.ts
263
+ var CrexApi = /*#__PURE__*/ function() {
264
+ "use strict";
265
+ function CrexApi(baseUrl, logger) {
266
+ _class_call_check(this, CrexApi);
267
+ this.apiClient = axios.create({
268
+ baseURL: baseUrl,
269
+ headers: {
270
+ "content-Type": "application/json"
271
+ }
272
+ });
273
+ this.logger = logger;
274
+ }
275
+ _create_class(CrexApi, [
276
+ {
277
+ key: "execute",
278
+ value: function execute(_0) {
279
+ return /*#__PURE__*/ _async_to_generator(function(param) {
280
+ var url, method, params, body, headers, response, retry, error;
281
+ return _ts_generator(this, function(_state) {
282
+ switch(_state.label){
283
+ case 0:
284
+ url = param.url, method = param.method, params = param.params, body = param.body, headers = param.headers;
285
+ response = void 0;
286
+ retry = 0;
287
+ _state.label = 1;
288
+ case 1:
289
+ if (!(retry < API.MAX_RETRY)) return [
290
+ 3,
291
+ 6
292
+ ];
293
+ _state.label = 2;
294
+ case 2:
295
+ _state.trys.push([
296
+ 2,
297
+ 4,
298
+ ,
299
+ 5
300
+ ]);
301
+ return [
302
+ 4,
303
+ this.apiClient.request({
304
+ url: url,
305
+ method: method,
306
+ data: body,
307
+ params: params,
308
+ headers: headers
309
+ })
310
+ ];
311
+ case 3:
312
+ response = _state.sent();
313
+ return [
314
+ 3,
315
+ 5
316
+ ];
317
+ case 4:
318
+ error = _state.sent();
319
+ this.logger.log("error", "API.execute error when request ".concat(url, ". Error: ").concat(error));
320
+ throw error;
321
+ case 5:
322
+ retry++;
323
+ return [
324
+ 3,
325
+ 1
326
+ ];
327
+ case 6:
328
+ if (response) {
329
+ return [
330
+ 2,
331
+ response.data
332
+ ];
333
+ }
334
+ throw new Error("API.execute error: Failed to retrieve a valid response");
335
+ }
336
+ });
337
+ }).apply(this, arguments);
338
+ }
339
+ }
340
+ ]);
341
+ return CrexApi;
342
+ }();
343
+ // ../core/src/cookies.ts
344
+ var GLOBAL_KEY = "__CREX_INITIAL_CONFIG__";
345
+ var CONFIG_COOKIE_KEY = "crex_config";
346
+ function isBrowser() {
347
+ return typeof window !== "undefined" && typeof document !== "undefined";
348
+ }
349
+ function parseCookies() {
350
+ var cookies = {};
351
+ if (typeof document === "undefined") {
352
+ return cookies;
353
+ }
354
+ document.cookie.split(";").forEach(function(cookie) {
355
+ var _cookie_split = _sliced_to_array(cookie.split("="), 2), key = _cookie_split[0], value = _cookie_split[1];
356
+ if (key && value) {
357
+ cookies[key.trim()] = decodeURIComponent(value.trim());
358
+ }
359
+ });
360
+ return cookies;
361
+ }
362
+ function setCookie(name, value) {
363
+ var days = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 30;
364
+ if (typeof document === "undefined") return;
365
+ var expires = new Date(Date.now() + days * 86400 * 1e3).toUTCString();
366
+ document.cookie = "".concat(name, "=").concat(encodeURIComponent(value), "; path=/; expires=").concat(expires, "; SameSite=Lax");
367
+ }
368
+ function setConfig(config) {
369
+ if (isBrowser()) {
370
+ setCookie(CONFIG_COOKIE_KEY, JSON.stringify(config));
371
+ } else {
372
+ if (typeof global !== "undefined" && !(GLOBAL_KEY in global)) {
373
+ global[GLOBAL_KEY] = null;
374
+ }
375
+ var globalConfig = global[GLOBAL_KEY];
376
+ if (globalConfig === null) {
377
+ global[GLOBAL_KEY] = config;
378
+ }
379
+ }
380
+ }
381
+ function getConfig() {
382
+ var returnValue;
383
+ if (isBrowser()) {
384
+ var cookies = parseCookies();
385
+ var configStr = cookies[CONFIG_COOKIE_KEY];
386
+ if (configStr) {
387
+ try {
388
+ return JSON.parse(configStr);
389
+ } catch (e) {
390
+ return null;
391
+ }
392
+ }
393
+ return null;
394
+ } else {
395
+ returnValue = global[GLOBAL_KEY];
396
+ }
397
+ return returnValue;
398
+ }
399
+ // ../core/src/sdk.ts
400
+ var CrexSDK = /*#__PURE__*/ function() {
401
+ "use strict";
402
+ function CrexSDK() {
403
+ _class_call_check(this, CrexSDK);
404
+ var config = getConfig();
405
+ this.customerConfig = config;
406
+ this.api = new CrexApi(this.customerConfig.baseUrl, null);
407
+ }
408
+ _create_class(CrexSDK, null, [
409
+ {
410
+ key: "setConfig",
411
+ value: function setConfig1(config) {
412
+ setConfig(config);
413
+ }
414
+ }
415
+ ]);
416
+ return CrexSDK;
417
+ }();
418
+ // ../utils/src/utils.ts
419
+ var createParams = function(fieldsList) {
420
+ var key = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Fields";
421
+ return fieldsList.map(function(item) {
422
+ return {
423
+ key: key,
424
+ value: item
425
+ };
426
+ });
427
+ };
428
+ var updateUrlWithParams = function(router, params) {
429
+ var searchParams = new URLSearchParams(window.location.search);
430
+ params.forEach(function(param) {
431
+ searchParams.set(param.key, param.value.toString());
432
+ });
433
+ var queryString = searchParams.toString();
434
+ router.push("".concat(window.location.pathname, "?").concat(queryString));
435
+ };
436
+ var generateQueryParams = function(params) {
437
+ var queryParams = params.map(function(param) {
438
+ return "".concat(encodeURIComponent(param.key), "=").concat(encodeURIComponent(param.value));
439
+ }).join("&");
440
+ return queryParams;
441
+ };
442
+ // ../utils/src/classMerge.ts
443
+ import { clsx } from "clsx";
444
+ import { twMerge } from "tailwind-merge";
445
+ // ../services/src/baseService.ts
446
+ var BaseService = /*#__PURE__*/ function() {
447
+ "use strict";
448
+ function BaseService(endpoint) {
449
+ _class_call_check(this, BaseService);
450
+ this.SDK = new CrexSDK();
451
+ this.api = this.SDK.api;
452
+ this.endpoint = endpoint;
453
+ }
454
+ _create_class(BaseService, [
455
+ {
456
+ key: "request",
457
+ value: function request(_0) {
458
+ return /*#__PURE__*/ _async_to_generator(function(param) {
459
+ var _param_path, path, _param_method, method, _param_params, params, _param_headers, headers, _param_transformer, transformer, url, queryParams, response, error;
460
+ return _ts_generator(this, function(_state) {
461
+ switch(_state.label){
462
+ case 0:
463
+ _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) {
464
+ return response;
465
+ } : _param_transformer;
466
+ _state.label = 1;
467
+ case 1:
468
+ _state.trys.push([
469
+ 1,
470
+ 4,
471
+ ,
472
+ 5
473
+ ]);
474
+ url = "".concat(this.endpoint).concat(path);
475
+ queryParams = generateQueryParams(params);
476
+ if (queryParams.length > 0) {
477
+ url += "?".concat(queryParams);
478
+ }
479
+ return [
480
+ 4,
481
+ this.api.execute({
482
+ url: url,
483
+ method: method,
484
+ headers: headers
485
+ })
486
+ ];
487
+ case 2:
488
+ response = _state.sent();
489
+ return [
490
+ 4,
491
+ transformer(response)
492
+ ];
493
+ case 3:
494
+ return [
495
+ 2,
496
+ _state.sent()
497
+ ];
498
+ case 4:
499
+ error = _state.sent();
500
+ console.log("error", "BaseService.request error when request ".concat(path, ". Error: ").concat(error));
501
+ throw error;
502
+ case 5:
503
+ return [
504
+ 2
505
+ ];
506
+ }
507
+ });
508
+ }).apply(this, arguments);
509
+ }
510
+ }
511
+ ]);
512
+ return BaseService;
513
+ }();
514
+ // ../services/src/transforms/information.ts
515
+ var transformInformationUnits = function(data) {
516
+ return {
517
+ items: data.items.map(function(item) {
518
+ return item;
519
+ }),
520
+ pageInfo: data.pageInfo
521
+ };
522
+ };
523
+ // ../services/src/informationUnits.ts
524
+ var InformationUnitsService = /*#__PURE__*/ function(BaseService) {
525
+ "use strict";
526
+ _inherits(InformationUnitsService, BaseService);
527
+ function InformationUnitsService() {
528
+ _class_call_check(this, InformationUnitsService);
529
+ return _call_super(this, InformationUnitsService, [
530
+ "InformationUnits/"
531
+ ]);
532
+ }
533
+ _create_class(InformationUnitsService, [
534
+ {
535
+ key: "getList",
536
+ value: function getList(queries, page, fields, language) {
537
+ return /*#__PURE__*/ _async_to_generator(function() {
538
+ var remainFields, params;
539
+ return _ts_generator(this, function(_state) {
540
+ switch(_state.label){
541
+ case 0:
542
+ remainFields = createParams(fields, "Fields");
543
+ params = [
544
+ {
545
+ key: "pageSize",
546
+ value: "8"
547
+ },
548
+ {
549
+ key: "PageNumber",
550
+ value: (page - 1).toString()
551
+ },
552
+ {
553
+ key: "Query",
554
+ value: queries
555
+ }
556
+ ].concat(_to_consumable_array(remainFields));
557
+ if (language != null) {
558
+ language.forEach(function(item) {
559
+ params.push({
560
+ key: "Restrict",
561
+ value: "languages~".concat(item)
562
+ });
563
+ });
564
+ }
565
+ return [
566
+ 4,
567
+ this.request({
568
+ params: params,
569
+ transformer: transformInformationUnits
570
+ })
571
+ ];
572
+ case 1:
573
+ return [
574
+ 2,
575
+ _state.sent()
576
+ ];
577
+ }
578
+ });
579
+ }).call(this);
580
+ }
581
+ },
582
+ {
583
+ key: "getItem",
584
+ value: function getItem(id) {
585
+ return /*#__PURE__*/ _async_to_generator(function() {
586
+ var params;
587
+ return _ts_generator(this, function(_state) {
588
+ switch(_state.label){
589
+ case 0:
590
+ params = [
591
+ {
592
+ key: "Fields",
593
+ value: "renditions"
594
+ },
595
+ {
596
+ key: "Fields",
597
+ value: "directoryNodes"
598
+ }
599
+ ];
600
+ return [
601
+ 4,
602
+ this.request({
603
+ path: id,
604
+ params: params
605
+ })
606
+ ];
607
+ case 1:
608
+ return [
609
+ 2,
610
+ _state.sent()
611
+ ];
612
+ }
613
+ });
614
+ }).call(this);
615
+ }
616
+ },
617
+ {
618
+ key: "getLanguages",
619
+ value: function getLanguages() {
620
+ return /*#__PURE__*/ _async_to_generator(function() {
621
+ return _ts_generator(this, function(_state) {
622
+ switch(_state.label){
623
+ case 0:
624
+ return [
625
+ 4,
626
+ this.request({
627
+ path: "Languages",
628
+ transformer: function(data) {
629
+ return data.map(function(item) {
630
+ return item.value;
631
+ });
632
+ }
633
+ })
634
+ ];
635
+ case 1:
636
+ return [
637
+ 2,
638
+ _state.sent()
639
+ ];
640
+ }
641
+ });
642
+ }).call(this);
643
+ }
644
+ },
645
+ {
646
+ key: "getSuggestions",
647
+ value: function getSuggestions(query) {
648
+ return /*#__PURE__*/ _async_to_generator(function() {
649
+ return _ts_generator(this, function(_state) {
650
+ switch(_state.label){
651
+ case 0:
652
+ return [
653
+ 4,
654
+ this.request({
655
+ path: "Suggestions",
656
+ params: [
657
+ {
658
+ key: "prefix",
659
+ value: query
660
+ }
661
+ ],
662
+ transformer: function(data) {
663
+ return data.suggestions.map(function(item) {
664
+ return item.value;
665
+ });
666
+ }
667
+ })
668
+ ];
669
+ case 1:
670
+ return [
671
+ 2,
672
+ _state.sent()
673
+ ];
674
+ }
675
+ });
676
+ }).call(this);
677
+ }
678
+ }
679
+ ]);
680
+ return InformationUnitsService;
681
+ }(BaseService);
682
+ // src/home/layout.tsx
683
+ import { SearchStateWrapper } from "@c-rex/components/search-wrapper";
684
+ // src/home/page.tsx
685
+ import { useRouter } from "next/navigation";
686
+ import { Button } from "@c-rex/ui/button";
687
+ import { AutoComplete } from "@c-rex/components/autocomplete";
688
+ import { ResultList } from "@c-rex/components/result-list";
689
+ import { jsx, jsxs } from "react/jsx-runtime";
690
+ var HomePage = function(param) {
691
+ var data = param.data;
692
+ var router = useRouter();
693
+ var initialValue = null;
694
+ var onSearch = function(value) {
695
+ var service = new InformationUnitsService();
696
+ return service.getSuggestions(value);
697
+ };
698
+ var onSelect = function(value) {
699
+ updateUrlWithParams(router, [
700
+ {
701
+ key: "search",
702
+ value: value.split(" ").join(",")
703
+ },
704
+ {
705
+ key: "operator",
706
+ value: "OR"
707
+ },
708
+ {
709
+ key: "page",
710
+ value: "1"
711
+ }
712
+ ]);
713
+ };
714
+ return /* @__PURE__ */ jsxs("div", {
715
+ className: "container",
716
+ children: [
717
+ /* @__PURE__ */ jsxs("div", {
718
+ className: "grid grid-cols-12 gap-4 py-6",
719
+ children: [
720
+ /* @__PURE__ */ jsx("div", {
721
+ className: "col-span-12 sm:col-span-9 md:col-span-10",
722
+ children: /* @__PURE__ */ jsx(AutoComplete, {
723
+ initialValue: initialValue !== null && initialValue !== void 0 ? initialValue : "",
724
+ onSearch: onSearch,
725
+ onSelect: onSelect
726
+ })
727
+ }),
728
+ /* @__PURE__ */ jsx("div", {
729
+ className: "col-span-12 sm:col-span-3 md:col-span-2",
730
+ children: /* @__PURE__ */ jsx("div", {
731
+ className: "flex justify-end",
732
+ children: /* @__PURE__ */ jsx(Button, {
733
+ variant: "default",
734
+ children: "Filters"
735
+ })
736
+ })
737
+ })
738
+ ]
739
+ }),
740
+ /* @__PURE__ */ jsx(ResultList, {
741
+ items: data.items
742
+ })
743
+ ]
744
+ });
745
+ };
746
+ // src/home/layout.tsx
747
+ import { jsx as jsx2 } from "react/jsx-runtime";
748
+ var loadData = function(param) {
749
+ var search = param.search, page = param.page, language = param.language;
750
+ return /*#__PURE__*/ _async_to_generator(function() {
751
+ var service, pageAux, searchValue, availableLanguages, data, selectedLanguages, aux;
752
+ return _ts_generator(this, function(_state) {
753
+ switch(_state.label){
754
+ case 0:
755
+ service = new InformationUnitsService();
756
+ pageAux = page != void 0 ? Number(page) : 0;
757
+ searchValue = search != void 0 ? search : "";
758
+ return [
759
+ 4,
760
+ service.getLanguages()
761
+ ];
762
+ case 1:
763
+ availableLanguages = _state.sent();
764
+ data = {
765
+ items: []
766
+ };
767
+ selectedLanguages = [];
768
+ if (language != void 0) {
769
+ aux = language;
770
+ selectedLanguages = aux.split(",");
771
+ }
772
+ if (!searchValue) return [
773
+ 3,
774
+ 3
775
+ ];
776
+ return [
777
+ 4,
778
+ service.getList(searchValue, pageAux, selectedLanguages, [])
779
+ ];
780
+ case 2:
781
+ data = _state.sent();
782
+ _state.label = 3;
783
+ case 3:
784
+ return [
785
+ 2,
786
+ {
787
+ data: data,
788
+ filters: {
789
+ searchValue: searchValue,
790
+ page: pageAux,
791
+ selectedLanguage: selectedLanguages,
792
+ availableLanguages: availableLanguages
793
+ }
794
+ }
795
+ ];
796
+ }
797
+ });
798
+ })();
799
+ };
800
+ var HomeLayout = function(param) {
801
+ var searchParams = param.searchParams;
802
+ return /*#__PURE__*/ _async_to_generator(function() {
803
+ var _ref, data, filters;
804
+ return _ts_generator(this, function(_state) {
805
+ switch(_state.label){
806
+ case 0:
807
+ return [
808
+ 4,
809
+ loadData(searchParams)
810
+ ];
811
+ case 1:
812
+ _ref = _state.sent(), data = _ref.data, filters = _ref.filters;
813
+ return [
814
+ 2,
815
+ /* @__PURE__ */ jsx2(SearchStateWrapper, {
816
+ filters: filters,
817
+ children: /* @__PURE__ */ jsx2(HomePage, {
818
+ data: data
819
+ })
820
+ })
821
+ ];
822
+ }
823
+ });
824
+ })();
825
+ };
826
+ export { HomeLayout };
827
+ //# sourceMappingURL=layout.esm.js.map