@knovator/pagecreator 1.0.2 → 1.0.4

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.
Files changed (3) hide show
  1. package/index.js +689 -0
  2. package/package.json +33 -26
  3. package/style.css +2 -0
package/index.js ADDED
@@ -0,0 +1,689 @@
1
+ import React, { Fragment, useState } from 'react';
2
+ import { Swiper, SwiperSlide } from 'swiper/react';
3
+ import { Pagination, Autoplay, Virtual } from 'swiper';
4
+ import { Tabs, TabList, Tab, TabPanel } from 'react-tabs';
5
+
6
+ var regeneratorRuntime$1 = {exports: {}};
7
+
8
+ var _typeof = {exports: {}};
9
+
10
+ (function (module) {
11
+ function _typeof(obj) {
12
+ "@babel/helpers - typeof";
13
+
14
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
15
+ return typeof obj;
16
+ } : function (obj) {
17
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
18
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
19
+ }
20
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
21
+ }(_typeof));
22
+
23
+ (function (module) {
24
+ var _typeof$1 = _typeof.exports["default"];
25
+ function _regeneratorRuntime() {
26
+ module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
27
+ return exports;
28
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
29
+ var exports = {},
30
+ Op = Object.prototype,
31
+ hasOwn = Op.hasOwnProperty,
32
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
33
+ obj[key] = desc.value;
34
+ },
35
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
36
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
37
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
38
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
39
+ function define(obj, key, value) {
40
+ return Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: !0,
43
+ configurable: !0,
44
+ writable: !0
45
+ }), obj[key];
46
+ }
47
+ try {
48
+ define({}, "");
49
+ } catch (err) {
50
+ define = function define(obj, key, value) {
51
+ return obj[key] = value;
52
+ };
53
+ }
54
+ function wrap(innerFn, outerFn, self, tryLocsList) {
55
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
56
+ generator = Object.create(protoGenerator.prototype),
57
+ context = new Context(tryLocsList || []);
58
+ return defineProperty(generator, "_invoke", {
59
+ value: makeInvokeMethod(innerFn, self, context)
60
+ }), generator;
61
+ }
62
+ function tryCatch(fn, obj, arg) {
63
+ try {
64
+ return {
65
+ type: "normal",
66
+ arg: fn.call(obj, arg)
67
+ };
68
+ } catch (err) {
69
+ return {
70
+ type: "throw",
71
+ arg: err
72
+ };
73
+ }
74
+ }
75
+ exports.wrap = wrap;
76
+ var ContinueSentinel = {};
77
+ function Generator() {}
78
+ function GeneratorFunction() {}
79
+ function GeneratorFunctionPrototype() {}
80
+ var IteratorPrototype = {};
81
+ define(IteratorPrototype, iteratorSymbol, function () {
82
+ return this;
83
+ });
84
+ var getProto = Object.getPrototypeOf,
85
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
86
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
87
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
88
+ function defineIteratorMethods(prototype) {
89
+ ["next", "throw", "return"].forEach(function (method) {
90
+ define(prototype, method, function (arg) {
91
+ return this._invoke(method, arg);
92
+ });
93
+ });
94
+ }
95
+ function AsyncIterator(generator, PromiseImpl) {
96
+ function invoke(method, arg, resolve, reject) {
97
+ var record = tryCatch(generator[method], generator, arg);
98
+ if ("throw" !== record.type) {
99
+ var result = record.arg,
100
+ value = result.value;
101
+ return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
102
+ invoke("next", value, resolve, reject);
103
+ }, function (err) {
104
+ invoke("throw", err, resolve, reject);
105
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
106
+ result.value = unwrapped, resolve(result);
107
+ }, function (error) {
108
+ return invoke("throw", error, resolve, reject);
109
+ });
110
+ }
111
+ reject(record.arg);
112
+ }
113
+ var previousPromise;
114
+ defineProperty(this, "_invoke", {
115
+ value: function value(method, arg) {
116
+ function callInvokeWithMethodAndArg() {
117
+ return new PromiseImpl(function (resolve, reject) {
118
+ invoke(method, arg, resolve, reject);
119
+ });
120
+ }
121
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
122
+ }
123
+ });
124
+ }
125
+ function makeInvokeMethod(innerFn, self, context) {
126
+ var state = "suspendedStart";
127
+ return function (method, arg) {
128
+ if ("executing" === state) throw new Error("Generator is already running");
129
+ if ("completed" === state) {
130
+ if ("throw" === method) throw arg;
131
+ return doneResult();
132
+ }
133
+ for (context.method = method, context.arg = arg;;) {
134
+ var delegate = context.delegate;
135
+ if (delegate) {
136
+ var delegateResult = maybeInvokeDelegate(delegate, context);
137
+ if (delegateResult) {
138
+ if (delegateResult === ContinueSentinel) continue;
139
+ return delegateResult;
140
+ }
141
+ }
142
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
143
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
144
+ context.dispatchException(context.arg);
145
+ } else "return" === context.method && context.abrupt("return", context.arg);
146
+ state = "executing";
147
+ var record = tryCatch(innerFn, self, context);
148
+ if ("normal" === record.type) {
149
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
150
+ return {
151
+ value: record.arg,
152
+ done: context.done
153
+ };
154
+ }
155
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
156
+ }
157
+ };
158
+ }
159
+ function maybeInvokeDelegate(delegate, context) {
160
+ var methodName = context.method,
161
+ method = delegate.iterator[methodName];
162
+ if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
163
+ var record = tryCatch(method, delegate.iterator, context.arg);
164
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
165
+ var info = record.arg;
166
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
167
+ }
168
+ function pushTryEntry(locs) {
169
+ var entry = {
170
+ tryLoc: locs[0]
171
+ };
172
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
173
+ }
174
+ function resetTryEntry(entry) {
175
+ var record = entry.completion || {};
176
+ record.type = "normal", delete record.arg, entry.completion = record;
177
+ }
178
+ function Context(tryLocsList) {
179
+ this.tryEntries = [{
180
+ tryLoc: "root"
181
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
182
+ }
183
+ function values(iterable) {
184
+ if (iterable) {
185
+ var iteratorMethod = iterable[iteratorSymbol];
186
+ if (iteratorMethod) return iteratorMethod.call(iterable);
187
+ if ("function" == typeof iterable.next) return iterable;
188
+ if (!isNaN(iterable.length)) {
189
+ var i = -1,
190
+ next = function next() {
191
+ for (; ++i < iterable.length;) {
192
+ if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
193
+ }
194
+ return next.value = undefined, next.done = !0, next;
195
+ };
196
+ return next.next = next;
197
+ }
198
+ }
199
+ return {
200
+ next: doneResult
201
+ };
202
+ }
203
+ function doneResult() {
204
+ return {
205
+ value: undefined,
206
+ done: !0
207
+ };
208
+ }
209
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
210
+ value: GeneratorFunctionPrototype,
211
+ configurable: !0
212
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
213
+ value: GeneratorFunction,
214
+ configurable: !0
215
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
216
+ var ctor = "function" == typeof genFun && genFun.constructor;
217
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
218
+ }, exports.mark = function (genFun) {
219
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
220
+ }, exports.awrap = function (arg) {
221
+ return {
222
+ __await: arg
223
+ };
224
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
225
+ return this;
226
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
227
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
228
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
229
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
230
+ return result.done ? result.value : iter.next();
231
+ });
232
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
233
+ return this;
234
+ }), define(Gp, "toString", function () {
235
+ return "[object Generator]";
236
+ }), exports.keys = function (val) {
237
+ var object = Object(val),
238
+ keys = [];
239
+ for (var key in object) {
240
+ keys.push(key);
241
+ }
242
+ return keys.reverse(), function next() {
243
+ for (; keys.length;) {
244
+ var key = keys.pop();
245
+ if (key in object) return next.value = key, next.done = !1, next;
246
+ }
247
+ return next.done = !0, next;
248
+ };
249
+ }, exports.values = values, Context.prototype = {
250
+ constructor: Context,
251
+ reset: function reset(skipTempReset) {
252
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
253
+ "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
254
+ }
255
+ },
256
+ stop: function stop() {
257
+ this.done = !0;
258
+ var rootRecord = this.tryEntries[0].completion;
259
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
260
+ return this.rval;
261
+ },
262
+ dispatchException: function dispatchException(exception) {
263
+ if (this.done) throw exception;
264
+ var context = this;
265
+ function handle(loc, caught) {
266
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
267
+ }
268
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
269
+ var entry = this.tryEntries[i],
270
+ record = entry.completion;
271
+ if ("root" === entry.tryLoc) return handle("end");
272
+ if (entry.tryLoc <= this.prev) {
273
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
274
+ hasFinally = hasOwn.call(entry, "finallyLoc");
275
+ if (hasCatch && hasFinally) {
276
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
277
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
278
+ } else if (hasCatch) {
279
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
280
+ } else {
281
+ if (!hasFinally) throw new Error("try statement without catch or finally");
282
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
283
+ }
284
+ }
285
+ }
286
+ },
287
+ abrupt: function abrupt(type, arg) {
288
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
289
+ var entry = this.tryEntries[i];
290
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
291
+ var finallyEntry = entry;
292
+ break;
293
+ }
294
+ }
295
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
296
+ var record = finallyEntry ? finallyEntry.completion : {};
297
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
298
+ },
299
+ complete: function complete(record, afterLoc) {
300
+ if ("throw" === record.type) throw record.arg;
301
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
302
+ },
303
+ finish: function finish(finallyLoc) {
304
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
305
+ var entry = this.tryEntries[i];
306
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
307
+ }
308
+ },
309
+ "catch": function _catch(tryLoc) {
310
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
311
+ var entry = this.tryEntries[i];
312
+ if (entry.tryLoc === tryLoc) {
313
+ var record = entry.completion;
314
+ if ("throw" === record.type) {
315
+ var thrown = record.arg;
316
+ resetTryEntry(entry);
317
+ }
318
+ return thrown;
319
+ }
320
+ }
321
+ throw new Error("illegal catch attempt");
322
+ },
323
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
324
+ return this.delegate = {
325
+ iterator: values(iterable),
326
+ resultName: resultName,
327
+ nextLoc: nextLoc
328
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
329
+ }
330
+ }, exports;
331
+ }
332
+ module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
333
+ }(regeneratorRuntime$1));
334
+
335
+ // TODO(Babel 8): Remove this file.
336
+
337
+ var runtime = regeneratorRuntime$1.exports();
338
+ var regenerator = runtime;
339
+
340
+ // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
341
+ try {
342
+ regeneratorRuntime = runtime;
343
+ } catch (accidentalStrictMode) {
344
+ if (typeof globalThis === "object") {
345
+ globalThis.regeneratorRuntime = runtime;
346
+ } else {
347
+ Function("r", "regeneratorRuntime = r")(runtime);
348
+ }
349
+ }
350
+
351
+ /******************************************************************************
352
+ Copyright (c) Microsoft Corporation.
353
+
354
+ Permission to use, copy, modify, and/or distribute this software for any
355
+ purpose with or without fee is hereby granted.
356
+
357
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
358
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
359
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
360
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
361
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
362
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
363
+ PERFORMANCE OF THIS SOFTWARE.
364
+ ***************************************************************************** */
365
+
366
+ function __awaiter(thisArg, _arguments, P, generator) {
367
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
368
+ return new (P || (P = Promise))(function (resolve, reject) {
369
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
370
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
371
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
372
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
373
+ });
374
+ }
375
+
376
+ var _a;
377
+ function getData(_ref) {
378
+ var url = _ref.url,
379
+ code = _ref.code,
380
+ token = _ref.token;
381
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
382
+ var response, data;
383
+ return regenerator.wrap(function _callee$(_context) {
384
+ while (1) {
385
+ switch (_context.prev = _context.next) {
386
+ case 0:
387
+ _context.next = 2;
388
+ return fetch(url, {
389
+ method: 'POST',
390
+ headers: {
391
+ 'Content-Type': 'application/json',
392
+ Authorization: token ? "Bearer ".concat(token) : ''
393
+ },
394
+ body: JSON.stringify({
395
+ code: code
396
+ })
397
+ });
398
+ case 2:
399
+ response = _context.sent;
400
+ if (response.ok) {
401
+ _context.next = 5;
402
+ break;
403
+ }
404
+ throw new Error(response.statusText);
405
+ case 5:
406
+ _context.next = 7;
407
+ return response.json();
408
+ case 7:
409
+ data = _context.sent;
410
+ return _context.abrupt("return", data['data']);
411
+ case 9:
412
+ case "end":
413
+ return _context.stop();
414
+ }
415
+ }
416
+ }, _callee);
417
+ }));
418
+ }
419
+ function buildSrcSets(imageBaseUrl, srcSets) {
420
+ if (!srcSets) return '';
421
+ if (!imageBaseUrl) return srcSets;
422
+ return srcSets.split(', ').map(function (srcSetItem) {
423
+ return "".concat(imageBaseUrl).concat(srcSetItem);
424
+ }).join(', ');
425
+ }
426
+ var isMobileDevice = typeof window !== 'undefined' && /Mobi/i.test((_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent);
427
+ var filterItemData = function filterItemData(data) {
428
+ return isMobileDevice ? data.itemType === 'Mobile' : data.itemType === 'Web';
429
+ };
430
+
431
+ function FixedWidget(_ref) {
432
+ var widgetData = _ref.widgetData,
433
+ formatItem = _ref.formatItem,
434
+ className = _ref.className,
435
+ itemsContainer = _ref.itemsContainer;
436
+ var gridClasses = "grid grid-cols-".concat(widgetData.mobilePerRow, " md:grid-cols-").concat(widgetData.tabletPerRow, " lg:grid-cols-").concat(widgetData.webPerRow);
437
+ if (typeof itemsContainer === 'function') return itemsContainer(widgetData.itemsType === 'Image' ? widgetData.items.filter(filterItemData).map(function (item, index) {
438
+ return /*#__PURE__*/React.createElement(Fragment, {
439
+ key: index
440
+ }, formatItem(item));
441
+ }) : widgetData.collectionItems.map(function (item, index) {
442
+ return /*#__PURE__*/React.createElement(Fragment, {
443
+ key: index
444
+ }, formatItem(item));
445
+ }));
446
+ return /*#__PURE__*/React.createElement("div", {
447
+ className: className || gridClasses
448
+ }, widgetData.itemsType === 'Image' ? widgetData.items.filter(filterItemData).map(function (item, index) {
449
+ return /*#__PURE__*/React.createElement(Fragment, {
450
+ key: index
451
+ }, formatItem(item));
452
+ }) : widgetData.collectionItems.map(function (item, index) {
453
+ return /*#__PURE__*/React.createElement(Fragment, {
454
+ key: index
455
+ }, formatItem(item));
456
+ }));
457
+ }
458
+
459
+ function CarouselWidget(_ref) {
460
+ var widgetData = _ref.widgetData,
461
+ formatItem = _ref.formatItem,
462
+ settings = _ref.settings,
463
+ className = _ref.className,
464
+ itemsContainer = _ref.itemsContainer;
465
+ var defaultSetting = {
466
+ slidesPerView: widgetData.mobilePerRow,
467
+ loop: true,
468
+ loopAdditionalSlides: 2,
469
+ speed: 5000,
470
+ breakpoints: {
471
+ 640: {
472
+ slidesPerView: widgetData.mobilePerRow,
473
+ spaceBetween: 20
474
+ },
475
+ 768: {
476
+ slidesPerView: widgetData.tabletPerRow,
477
+ spaceBetween: 40
478
+ },
479
+ 1024: {
480
+ slidesPerView: widgetData.webPerRow,
481
+ spaceBetween: 50
482
+ }
483
+ }
484
+ };
485
+ if (!widgetData) return null;
486
+ if (typeof itemsContainer === 'function') return itemsContainer(widgetData.itemsType === 'Image' ? widgetData.items.filter(filterItemData).map(function (item, index) {
487
+ return /*#__PURE__*/React.createElement(Fragment, {
488
+ key: index
489
+ }, formatItem(item));
490
+ }) : widgetData.collectionItems.map(function (item, index) {
491
+ return /*#__PURE__*/React.createElement(Fragment, {
492
+ key: index
493
+ }, formatItem(item));
494
+ }));
495
+ return /*#__PURE__*/React.createElement(Swiper, Object.assign({}, Object.assign(Object.assign({}, defaultSetting), settings || {}), {
496
+ className: className,
497
+ modules: [Pagination, Autoplay, Virtual],
498
+ virtual: typeof window === 'undefined'
499
+ }), widgetData.itemsType === 'Image' ? widgetData.items.filter(filterItemData).map(function (item, index) {
500
+ return /*#__PURE__*/React.createElement(SwiperSlide, {
501
+ key: index
502
+ }, formatItem(item));
503
+ }) : widgetData.collectionItems.map(function (item, index) {
504
+ return /*#__PURE__*/React.createElement(SwiperSlide, {
505
+ key: index
506
+ }, formatItem(item));
507
+ }));
508
+ }
509
+
510
+ function Banner(_ref) {
511
+ var imageAltText = _ref.imageAltText,
512
+ imageUrl = _ref.imageUrl,
513
+ _onClick = _ref.onClick,
514
+ srcSets = _ref.srcSets,
515
+ title = _ref.title,
516
+ subtitle = _ref.subtitle;
517
+ return /*#__PURE__*/React.createElement("div", {
518
+ className: "kpc_banner"
519
+ }, /*#__PURE__*/React.createElement("b", null, title), subtitle ? /*#__PURE__*/React.createElement("p", null, subtitle) : null, /*#__PURE__*/React.createElement("img", {
520
+ src: imageUrl,
521
+ alt: imageAltText,
522
+ className: "kpc_banner-image",
523
+ srcSet: srcSets,
524
+ loading: "lazy",
525
+ onClick: function onClick() {
526
+ return _onClick && _onClick();
527
+ }
528
+ }));
529
+ }
530
+
531
+ function CollectionItem(_ref) {
532
+ var name = _ref.name,
533
+ _onClick = _ref.onClick;
534
+ return /*#__PURE__*/React.createElement("div", {
535
+ className: "kpc_item",
536
+ onClick: function onClick() {
537
+ return _onClick && _onClick();
538
+ }
539
+ }, /*#__PURE__*/React.createElement("p", {
540
+ className: "kpc_item-text"
541
+ }, name || 'Laurem Ipsum'));
542
+ }
543
+
544
+ function TabWidget(_ref) {
545
+ var widgetData = _ref.widgetData,
546
+ formatItem = _ref.formatItem,
547
+ className = _ref.className,
548
+ formatTabTitle = _ref.formatTabTitle,
549
+ itemsContainer = _ref.itemsContainer;
550
+ var _useState = useState(0),
551
+ activeTab = _useState[0],
552
+ setActiveTab = _useState[1];
553
+ var gridClasses = "grid grid-cols-".concat(widgetData.mobilePerRow, " md:grid-cols-").concat(widgetData.tabletPerRow, " lg:grid-cols-").concat(widgetData.webPerRow);
554
+ return /*#__PURE__*/React.createElement(Tabs, {
555
+ selectedIndex: activeTab,
556
+ onSelect: setActiveTab
557
+ }, /*#__PURE__*/React.createElement(TabList, null, widgetData.tabs.map(function (tab, index) {
558
+ return /*#__PURE__*/React.createElement(Tab, {
559
+ key: index
560
+ }, formatTabTitle(tab.names || tab.name, tab.collectionItems, activeTab === index));
561
+ })), widgetData.tabs.map(function (tab, index) {
562
+ return /*#__PURE__*/React.createElement(TabPanel, {
563
+ key: index
564
+ }, typeof itemsContainer === 'function' ? itemsContainer(tab.collectionItems.map(function (item, index) {
565
+ return /*#__PURE__*/React.createElement(Fragment, {
566
+ key: index
567
+ }, formatItem(item));
568
+ })) : /*#__PURE__*/React.createElement("div", {
569
+ className: className || gridClasses
570
+ }, tab.collectionItems.map(function (item, index) {
571
+ return /*#__PURE__*/React.createElement(Fragment, {
572
+ key: index
573
+ }, formatItem(item));
574
+ })));
575
+ }));
576
+ }
577
+
578
+ function Widget(_ref) {
579
+ var widgetData = _ref.widgetData,
580
+ imageBaseUrl = _ref.imageBaseUrl,
581
+ formatItem = _ref.formatItem,
582
+ _onClick = _ref.onClick,
583
+ settings = _ref.settings,
584
+ hideTitle = _ref.hideTitle,
585
+ className = _ref.className,
586
+ formatFooter = _ref.formatFooter,
587
+ formatHeader = _ref.formatHeader,
588
+ formatTabTitle = _ref.formatTabTitle,
589
+ itemsContainer = _ref.itemsContainer;
590
+ var formatItems = function formatItems(item) {
591
+ var _a;
592
+ if (typeof formatItem === 'function' && formatItem) return formatItem(item);else if (widgetData.itemsType === 'Image') return /*#__PURE__*/React.createElement(Banner, {
593
+ key: item._id,
594
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
595
+ // @ts-ignore
596
+ imageUrl: "".concat(imageBaseUrl || '').concat((_a = item.image) === null || _a === void 0 ? void 0 : _a.uri),
597
+ imageAltText: item._id,
598
+ onClick: function onClick() {
599
+ return _onClick && _onClick(item);
600
+ },
601
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
602
+ // @ts-ignore
603
+ srcSets: buildSrcSets(imageBaseUrl, item.srcSets),
604
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
605
+ // @ts-ignore
606
+ title: item.title,
607
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
608
+ // @ts-ignore
609
+ subtitle: item.subtitle
610
+ });else return /*#__PURE__*/React.createElement(CollectionItem, Object.assign({
611
+ key: item._id,
612
+ onClick: function onClick() {
613
+ return _onClick && _onClick(item);
614
+ }
615
+ }, item));
616
+ };
617
+ var formatTabTitles = function formatTabTitles(title, collectionData, isActive) {
618
+ if (typeof formatTabTitle === 'function' && formatTabTitle) return formatTabTitle(title, collectionData, isActive);
619
+ return /*#__PURE__*/React.createElement("div", null, typeof title === 'string' ? title : JSON.stringify(title));
620
+ };
621
+ if (!widgetData) return null;
622
+ return /*#__PURE__*/React.createElement("div", {
623
+ className: "kpc_widget",
624
+ style: {
625
+ backgroundColor: widgetData.backgroundColor
626
+ }
627
+ }, hideTitle === true ? null : typeof formatHeader === 'function' ? formatHeader(widgetData.widgetTitles || widgetData.widgetTitle, widgetData) : /*#__PURE__*/React.createElement("h2", {
628
+ className: "kpc_widget-title",
629
+ dangerouslySetInnerHTML: {
630
+ __html: widgetData.widgetTitles ? JSON.stringify(widgetData.widgetTitles) : widgetData.widgetTitle
631
+ }
632
+ }), /*#__PURE__*/React.createElement("div", {
633
+ className: "kpc_widget-body"
634
+ }, widgetData.widgetType === 'Carousel' ? /*#__PURE__*/React.createElement(CarouselWidget, {
635
+ settings: settings,
636
+ widgetData: widgetData,
637
+ formatItem: formatItems,
638
+ className: className,
639
+ formatTabTitle: formatTabTitles,
640
+ itemsContainer: itemsContainer
641
+ }) : widgetData.widgetType === 'Tabs' ? /*#__PURE__*/React.createElement(TabWidget, {
642
+ formatItem: formatItems,
643
+ formatTabTitle: formatTabTitles,
644
+ widgetData: widgetData,
645
+ className: className,
646
+ itemsContainer: itemsContainer
647
+ }) : /*#__PURE__*/React.createElement(FixedWidget, {
648
+ widgetData: widgetData,
649
+ formatItem: formatItems,
650
+ className: className,
651
+ formatTabTitle: formatTabTitles,
652
+ itemsContainer: itemsContainer
653
+ })), typeof formatFooter === 'function' ? formatFooter(widgetData) : null);
654
+ }
655
+
656
+ function Page(_ref) {
657
+ var title = _ref.title,
658
+ imageBaseUrl = _ref.imageBaseUrl,
659
+ pageData = _ref.pageData,
660
+ formatItem = _ref.formatItem,
661
+ onClick = _ref.onClick,
662
+ formatWidget = _ref.formatWidget,
663
+ hideWidgetTitles = _ref.hideWidgetTitles;
664
+ if (!pageData) return null;
665
+ return /*#__PURE__*/React.createElement("div", {
666
+ className: "kpc_page"
667
+ }, title && /*#__PURE__*/React.createElement("h1", {
668
+ className: "kpc_page-title"
669
+ }, title), /*#__PURE__*/React.createElement("div", {
670
+ className: "kpc_page-widgets"
671
+ }, pageData.widgets.map(function (widgetData, index) {
672
+ return typeof formatWidget === 'function' ? /*#__PURE__*/React.createElement(Fragment, {
673
+ key: index
674
+ }, formatWidget(widgetData, index)) : /*#__PURE__*/React.createElement(Widget, {
675
+ widgetData: widgetData,
676
+ key: index,
677
+ imageBaseUrl: imageBaseUrl,
678
+ hideTitle: hideWidgetTitles === true,
679
+ formatItem: formatItem && function (itemData) {
680
+ return formatItem(widgetData.code, itemData);
681
+ },
682
+ onClick: onClick && function (itemData) {
683
+ return onClick(widgetData.code, itemData);
684
+ }
685
+ });
686
+ })));
687
+ }
688
+
689
+ export { Page, Widget, getData };
package/package.json CHANGED
@@ -1,26 +1,33 @@
1
- {
2
- "name": "@knovator/pagecreator",
3
- "version": "1.0.2",
4
- "repository": {
5
- "type": "git",
6
- "url": "git@github.com:knovator/pagecreator.git"
7
- },
8
- "keywords": [
9
- "pagecreator",
10
- "pagebuilder",
11
- "knovator",
12
- "chavda-bhavik"
13
- ],
14
- "author": "knovator (https://knovator.com/)",
15
- "dependencies": {
16
- "swiper": "^8.4.5",
17
- "react-tabs": "^6.0.0"
18
- },
19
- "files": [
20
- "lib",
21
- "package.json",
22
- "README.md",
23
- "style.css",
24
- "index.js"
25
- ]
26
- }
1
+ {
2
+ "name": "@knovator/pagecreator",
3
+ "version": "1.0.4",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git@github.com:knovator/pagecreator.git"
7
+ },
8
+ "keywords": [
9
+ "pagecreator",
10
+ "pagebuilder",
11
+ "knovator",
12
+ "chavda-bhavik"
13
+ ],
14
+ "author": "knovator (https://knovator.com/)",
15
+ "dependencies": {
16
+ "swiper": "^8.4.5",
17
+ "react-tabs": "^6.0.0"
18
+ },
19
+ "files": [
20
+ "lib",
21
+ "package.json",
22
+ "README.md",
23
+ "style.css",
24
+ "index.js"
25
+ ],
26
+ "module": "./index.js",
27
+ "main": "./index.js",
28
+ "type": "module",
29
+ "types": "./src\\index.d.ts",
30
+ "peerDependencies": {
31
+ "react": "18.2.0"
32
+ }
33
+ }
package/style.css ADDED
@@ -0,0 +1,2 @@
1
+ /*! tailwindcss v4.1.12 | MIT License | https://tailwindcss.com */
2
+ @import "swiper/swiper-bundle.min.css";@import "react-tabs/style/react-tabs.css";@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-font-weight:initial;--tw-border-style:solid;--tw-space-y-reverse:0}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-base:1rem;--text-base--line-height:calc(1.5/1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--radius-md:.375rem;--radius-lg:.5rem;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.grid{display:grid}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}}.kpc_widget-title{margin-bottom:calc(var(--spacing)*2);font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height));--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.kpc_simple-card{gap:calc(var(--spacing)*2);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-gray-400);padding:calc(var(--spacing)*3);flex-direction:column;display:flex;overflow:hidden}.kpc_simple-card-heading{flex-shrink:0}.kpc_simple-card-image{aspect-ratio:1;border-radius:var(--radius-md);object-fit:cover}.kpc_simple-card-body{width:100%;display:contents}.kpc_simple-card-label{text-overflow:ellipsis;white-space:nowrap;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-gray-600);overflow:hidden}.kpc_simple-card-content{justify-content:space-between;align-items:center;width:100%}.kpc_simple-card-title{text-align:center;font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.kpc_simple-card-subtitle{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-gray-600)}.kpc_banner{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-gray-500);padding:calc(var(--spacing)*1)}.kpc_banner-image{aspect-ratio:1;width:100%;height:100%}.kpc_page-title{margin-bottom:calc(var(--spacing)*2);font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height));--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}:where(.kpc_page-widgets>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}.kpc_item{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-gray-500);padding:calc(var(--spacing)*2)}.kpc_item-text{text-align:center;font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}