@bigbinary/neeto-templates-frontend 2.0.1 → 2.1.0

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 @@
1
+ {"version":3,"file":"TemplateTags.js","sources":["../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js","../node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js","../app/javascript/src/components/TemplateTags/constants.jsx","../app/javascript/src/components/TemplateTags/index.jsx"],"sourcesContent":["export default function _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n return target;\n}","import objectWithoutPropertiesLoose from \"./objectWithoutPropertiesLoose.js\";\nexport default function _objectWithoutProperties(source, excluded) {\n if (source == null) return {};\n var target = objectWithoutPropertiesLoose(source, excluded);\n var key, i;\n if (Object.getOwnPropertySymbols) {\n var sourceSymbolKeys = Object.getOwnPropertySymbols(source);\n for (i = 0; i < sourceSymbolKeys.length; i++) {\n key = sourceSymbolKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;\n target[key] = source[key];\n }\n }\n return target;\n}","import React from \"react\";\n\nimport { t } from \"i18next\";\nimport { Typography } from \"neetoui\";\n\nimport { NEETO_TEMPLATES_URL } from \"src/constants\";\n\nexport const TAG_TYPES = [\n {\n id: 1,\n label: t(\"neetoTemplate.templatesTags.template\"),\n url: `${NEETO_TEMPLATES_URL}/tags/template_tags`,\n columns: [\n {\n title: t(\"neetoTemplate.templatesTags.numberOfActiveTemplates\"),\n key: \"templates_count\",\n dataIndex: \"templatesCount\",\n align: \"center\",\n width: 300,\n sorter: true,\n render: templatesCount =>\n templatesCount !== 0 ? (\n <Typography style=\"body1\"> {templatesCount} </Typography>\n ) : (\n \"-\"\n ),\n },\n ],\n },\n];\n","import React from \"react\";\n\nimport { NeetoTags } from \"@bigbinary/neeto-tags-frontend\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { noop } from \"neetocist\";\n\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nimport { TAG_TYPES } from \"./constants\";\n\nconst TemplateTags = ({ breadcrumbs, tagsPath, ...otherProps }) => {\n const queryClient = useQueryClient();\n\n const invalidateTags = () => {\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEYS.TEMPLATE_TAGS],\n });\n };\n\n const invalidateTagsAndTemplates = () => {\n invalidateTags();\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEYS.TEMPLATES_LIST],\n });\n\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEYS.TEMPLATE],\n });\n };\n\n const config = {\n tagTypes: TAG_TYPES,\n tagsMergable: true,\n breadcrumbs,\n displayMenu: false,\n tagsPath,\n onTagRowClick: noop,\n createTags: { onSuccess: { callback: invalidateTags } },\n updateTags: { onSuccess: { callback: invalidateTagsAndTemplates } },\n deleteTags: { onSuccess: { callback: invalidateTagsAndTemplates } },\n mergeTags: { onSuccess: { callback: invalidateTagsAndTemplates } },\n ...otherProps,\n };\n\n return <NeetoTags {...{ config }} />;\n};\n\nexport default TemplateTags;\n"],"names":["objectWithoutPropertiesLoose","TAG_TYPES","id","label","t","url","concat","NEETO_TEMPLATES_URL","columns","title","key","dataIndex","align","width","sorter","render","templatesCount","_jsxs","Typography","style","children","TemplateTags","_ref","breadcrumbs","tagsPath","otherProps","_objectWithoutProperties","_excluded","queryClient","useQueryClient","invalidateTags","invalidateQueries","queryKey","QUERY_KEYS","TEMPLATE_TAGS","invalidateTagsAndTemplates","TEMPLATES_LIST","TEMPLATE","config","_objectSpread","tagTypes","tagsMergable","displayMenu","onTagRowClick","noop","createTags","onSuccess","callback","updateTags","deleteTags","mergeTags","_jsx","NeetoTags"],"mappings":";;;;;;;;;AAAe,SAAS,6BAA6B,CAAC,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d,CAAA;EAED,oBAAO0B,GAAA,CAACC,SAAS,EAAA;AAAOd,IAAAA,MAAM,EAANA,MAAAA;AAAM,GAAK,CAAC,CAAA;AACtC;;;;"}
@@ -0,0 +1,664 @@
1
+ 'use strict';
2
+
3
+ var useTemplatesApi = require('../useTemplatesApi-f81c070d.js');
4
+ var React = require('react');
5
+ var neetoCist = require('@bigbinary/neeto-cist');
6
+ var Modal = require('@bigbinary/neetoui/Modal');
7
+ var query = require('../query-96f06430.js');
8
+ var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
9
+ var Search = require('@bigbinary/neeto-molecules/Search');
10
+ var Spinner = require('@bigbinary/neetoui/Spinner');
11
+ var Typography = require('@bigbinary/neetoui/Typography');
12
+ var reactI18next = require('react-i18next');
13
+ var jsxRuntime = require('react/jsx-runtime');
14
+ var classnames = require('classnames');
15
+ var utils = require('@bigbinary/neeto-commons-frontend/utils');
16
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
17
+ var ResponsiveDevicePicker = require('@bigbinary/neeto-molecules/ResponsiveDevicePicker');
18
+ var Button = require('@bigbinary/neetoui/Button');
19
+ require('@bigbinary/neeto-tags-frontend');
20
+ require('@tanstack/react-query');
21
+ require('ramda');
22
+ require('axios');
23
+
24
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
25
+
26
+ function _interopNamespace(e) {
27
+ if (e && e.__esModule) return e;
28
+ var n = Object.create(null);
29
+ if (e) {
30
+ Object.keys(e).forEach(function (k) {
31
+ if (k !== 'default') {
32
+ var d = Object.getOwnPropertyDescriptor(e, k);
33
+ Object.defineProperty(n, k, d.get ? d : {
34
+ enumerable: true,
35
+ get: function () { return e[k]; }
36
+ });
37
+ }
38
+ });
39
+ }
40
+ n["default"] = e;
41
+ return Object.freeze(n);
42
+ }
43
+
44
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
45
+ var Modal__default = /*#__PURE__*/_interopDefaultLegacy(Modal);
46
+ var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
47
+ var Search__default = /*#__PURE__*/_interopDefaultLegacy(Search);
48
+ var Spinner__default = /*#__PURE__*/_interopDefaultLegacy(Spinner);
49
+ var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
50
+ var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
51
+ var ResponsiveDevicePicker__default = /*#__PURE__*/_interopDefaultLegacy(ResponsiveDevicePicker);
52
+ var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
53
+
54
+ var TEMPLATE_SCREENS = {
55
+ LIST: "List",
56
+ PREVIEW: "Preview"
57
+ };
58
+ var DEFAULT_CATEGORY = {
59
+ id: "all",
60
+ name: "All"
61
+ };
62
+ var INFINITE_SCROLL_DELAY = 500;
63
+ var RESPONSIVE_DEVICES = {
64
+ DESKTOP: "desktop",
65
+ TABLET: "tablet",
66
+ MOBILE: "mobile"
67
+ };
68
+
69
+ function createObserverCache() {
70
+ var cachesByRoot = new Map();
71
+
72
+ function getObserver(_ref) {
73
+ var root = _ref.root,
74
+ rootMargin = _ref.rootMargin,
75
+ threshold = _ref.threshold;
76
+ var cacheByRoot = cachesByRoot.get(root);
77
+
78
+ if (!cacheByRoot) {
79
+ cacheByRoot = new Map();
80
+ cachesByRoot.set(root, cacheByRoot);
81
+ }
82
+
83
+ var cacheKey = JSON.stringify({
84
+ rootMargin: rootMargin,
85
+ threshold: threshold
86
+ });
87
+ var cachedObserver = cacheByRoot.get(cacheKey);
88
+
89
+ if (!cachedObserver) {
90
+ var entryCallbacks = new Map();
91
+ var observer = new IntersectionObserver(function (entries) {
92
+ entries.forEach(function (entry) {
93
+ var callback = entryCallbacks.get(entry.target);
94
+ callback == null ? void 0 : callback(entry);
95
+ });
96
+ }, {
97
+ root: root,
98
+ rootMargin: rootMargin,
99
+ threshold: threshold
100
+ });
101
+ cachedObserver = {
102
+ observer: observer,
103
+ entryCallbacks: entryCallbacks
104
+ };
105
+ cacheByRoot.set(cacheKey, cachedObserver);
106
+ }
107
+
108
+ return {
109
+ observe: function observe(node, callback) {
110
+ var _cachedObserver, _cachedObserver2;
111
+
112
+ (_cachedObserver = cachedObserver) == null ? void 0 : _cachedObserver.entryCallbacks.set(node, callback);
113
+ (_cachedObserver2 = cachedObserver) == null ? void 0 : _cachedObserver2.observer.observe(node);
114
+ },
115
+ unobserve: function unobserve(node) {
116
+ var _cachedObserver3, _cachedObserver4;
117
+
118
+ (_cachedObserver3 = cachedObserver) == null ? void 0 : _cachedObserver3.entryCallbacks["delete"](node);
119
+ (_cachedObserver4 = cachedObserver) == null ? void 0 : _cachedObserver4.observer.unobserve(node);
120
+ }
121
+ };
122
+ }
123
+
124
+ return {
125
+ getObserver: getObserver
126
+ };
127
+ }
128
+
129
+ var DEFAULT_ROOT_MARGIN = '0px';
130
+ var DEFAULT_THRESHOLD = [0];
131
+ var observerCache = /*#__PURE__*/createObserverCache(); // For more info:
132
+ // https://developers.google.com/web/updates/2016/04/intersectionobserver
133
+ // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
134
+
135
+ function useIntersectionObserver(args) {
136
+ var _args$rootMargin, _args$threshold;
137
+
138
+ var rootMargin = (_args$rootMargin = args == null ? void 0 : args.rootMargin) != null ? _args$rootMargin : DEFAULT_ROOT_MARGIN;
139
+ var threshold = (_args$threshold = args == null ? void 0 : args.threshold) != null ? _args$threshold : DEFAULT_THRESHOLD;
140
+ var nodeRef = React.useRef(null);
141
+ var rootRef = React.useRef(null);
142
+ var observerRef = React.useRef(null);
143
+
144
+ var _useState = React.useState(),
145
+ entry = _useState[0],
146
+ setEntry = _useState[1];
147
+
148
+ var observe = React.useCallback(function () {
149
+ var node = nodeRef.current;
150
+
151
+ if (!node) {
152
+ setEntry(undefined);
153
+ return;
154
+ }
155
+
156
+ var observer = observerCache.getObserver({
157
+ root: rootRef.current,
158
+ rootMargin: rootMargin,
159
+ threshold: threshold
160
+ });
161
+ observer.observe(node, function (observedEntry) {
162
+ setEntry(observedEntry);
163
+ });
164
+ observerRef.current = observer;
165
+ }, [rootMargin, threshold]);
166
+ var unobserve = React.useCallback(function () {
167
+ var currentObserver = observerRef.current;
168
+ var node = nodeRef.current;
169
+
170
+ if (node) {
171
+ currentObserver == null ? void 0 : currentObserver.unobserve(node);
172
+ }
173
+
174
+ observerRef.current = null;
175
+ }, []); // React will call the ref callback with the DOM element when the component mounts,
176
+ // and call it with null when it unmounts.
177
+ // So, we don't need an useEffect etc to unobserve nodes.
178
+ // When nodeRef.current is null, it will be unobserved and observe function
179
+ // won't do anything.
180
+
181
+ var refCallback = React.useCallback(function (node) {
182
+ unobserve();
183
+ nodeRef.current = node;
184
+ observe();
185
+ }, [observe, unobserve]);
186
+ var rootRefCallback = React.useCallback(function (rootNode) {
187
+ unobserve();
188
+ rootRef.current = rootNode;
189
+ observe();
190
+ }, [observe, unobserve]);
191
+ return [refCallback, {
192
+ entry: entry,
193
+ rootRef: rootRefCallback
194
+ }];
195
+ }
196
+
197
+ function _extends$1() {
198
+ _extends$1 = Object.assign || function (target) {
199
+ for (var i = 1; i < arguments.length; i++) {
200
+ var source = arguments[i];
201
+
202
+ for (var key in source) {
203
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
204
+ target[key] = source[key];
205
+ }
206
+ }
207
+ }
208
+
209
+ return target;
210
+ };
211
+
212
+ return _extends$1.apply(this, arguments);
213
+ }
214
+
215
+ function useTrackVisibility(args) {
216
+ var _result$entry;
217
+
218
+ var _useIntersectionObser = useIntersectionObserver(args),
219
+ ref = _useIntersectionObser[0],
220
+ result = _useIntersectionObser[1];
221
+
222
+ var isVisible = Boolean((_result$entry = result.entry) == null ? void 0 : _result$entry.isIntersecting);
223
+
224
+ var _useState = React.useState(isVisible),
225
+ wasEverVisible = _useState[0],
226
+ setWasEverVisible = _useState[1];
227
+
228
+ if (isVisible && !wasEverVisible) {
229
+ setWasEverVisible(true);
230
+ }
231
+
232
+ return [ref, _extends$1({}, result, {
233
+ isVisible: isVisible,
234
+ wasEverVisible: wasEverVisible
235
+ })];
236
+ }
237
+
238
+ var DEFAULT_DELAY_IN_MS = 100;
239
+
240
+ function useInfiniteScroll(_ref) {
241
+ var loading = _ref.loading,
242
+ hasNextPage = _ref.hasNextPage,
243
+ onLoadMore = _ref.onLoadMore,
244
+ rootMargin = _ref.rootMargin,
245
+ disabled = _ref.disabled,
246
+ _ref$delayInMs = _ref.delayInMs,
247
+ delayInMs = _ref$delayInMs === void 0 ? DEFAULT_DELAY_IN_MS : _ref$delayInMs;
248
+
249
+ var _useTrackVisibility = useTrackVisibility({
250
+ rootMargin: rootMargin
251
+ }),
252
+ ref = _useTrackVisibility[0],
253
+ _useTrackVisibility$ = _useTrackVisibility[1],
254
+ rootRef = _useTrackVisibility$.rootRef,
255
+ isVisible = _useTrackVisibility$.isVisible;
256
+
257
+ var shouldLoadMore = !disabled && !loading && isVisible && hasNextPage; // eslint-disable-next-line consistent-return
258
+
259
+ React.useEffect(function () {
260
+ if (shouldLoadMore) {
261
+ // When we trigger 'onLoadMore' and new items are added to the list,
262
+ // right before they become rendered on the screen, 'loading' becomes false
263
+ // and 'isVisible' can be true for a brief time, based on the scroll position.
264
+ // So, it triggers 'onLoadMore' just after the first one is finished.
265
+ // We use a small delay here to prevent this kind of situations.
266
+ // It can be configured by hook args.
267
+ var timer = setTimeout(function () {
268
+ onLoadMore();
269
+ }, delayInMs);
270
+ return function () {
271
+ clearTimeout(timer);
272
+ };
273
+ }
274
+ }, [onLoadMore, shouldLoadMore, delayInMs]);
275
+ return [ref, {
276
+ rootRef: rootRef
277
+ }];
278
+ }
279
+
280
+ var _rect, _path;
281
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
282
+ const SvgCustom = props => /*#__PURE__*/React__namespace.createElement("svg", _extends({
283
+ xmlns: "http://www.w3.org/2000/svg",
284
+ width: 46,
285
+ height: 46,
286
+ fill: "none"
287
+ }, props), _rect || (_rect = /*#__PURE__*/React__namespace.createElement("rect", {
288
+ width: 40,
289
+ height: 40,
290
+ x: 3,
291
+ y: 2,
292
+ fill: "#008068",
293
+ rx: 2
294
+ })), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
295
+ fill: "#fff",
296
+ fillRule: "evenodd",
297
+ d: "M23.75 16a.75.75 0 0 0-1.5 0v5.25H17a.75.75 0 0 0 0 1.5h5.25V28a.75.75 0 0 0 1.5 0v-5.25H29a.75.75 0 0 0 0-1.5h-5.25V16Z",
298
+ clipRule: "evenodd"
299
+ })));
300
+
301
+ var BlankCard = function BlankCard(_ref) {
302
+ var Icon = _ref.icon,
303
+ title = _ref.title,
304
+ description = _ref.description,
305
+ _ref$onClick = _ref.onClick,
306
+ onClick = _ref$onClick === void 0 ? neetoCist.noop : _ref$onClick,
307
+ _ref$disabled = _ref.disabled,
308
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
309
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
310
+ className: "neeto-ui-rounded-lg neeto-ui-bg-white hover:neeto-ui-bg-white neeto-ui-border-primary-500 flex cursor-pointer flex-col items-center justify-center border border-dashed p-6 outline-none transition-all duration-300 ease-in-out hover:border-solid focus:border-solid",
311
+ "data-cy": "start-from-scratch-button",
312
+ tabIndex: 0,
313
+ onClick: !disabled ? onClick : neetoCist.noop,
314
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
315
+ className: "neeto-ui-text-primary-500 mb-4",
316
+ children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
317
+ size: 40
318
+ })
319
+ }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
320
+ className: "text-center",
321
+ lineHeight: "normal",
322
+ style: "h5",
323
+ weight: "semibold",
324
+ children: title
325
+ }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
326
+ className: "neeto-ui-text-gray-600 text-center",
327
+ lineHeight: "leading-4",
328
+ style: "body3",
329
+ children: description
330
+ })]
331
+ });
332
+ };
333
+
334
+ var Card = function Card(_ref) {
335
+ var template = _ref.template,
336
+ onClick = _ref.onClick;
337
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
338
+ onClick: onClick,
339
+ className: "neeto-template neeto-template-thumbnail neeto-ui-bg-white neeto-ui-shadow-xs hover:neeto-ui-border-gray-500 focus:neeto-ui-border-gray-500 neeto-ui-rounded-lg flex cursor-pointer flex-col overflow-hidden border outline-none transition-colors duration-300 ease-in-out",
340
+ "data-cy": "template-card",
341
+ tabIndex: 0,
342
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
343
+ className: "neeto-template__header relative overflow-hidden",
344
+ children: /*#__PURE__*/jsxRuntime.jsx("img", {
345
+ className: "neeto-template__image",
346
+ "data-cy": "template-thumbnail-image",
347
+ src: template.imageUrl || "https://d2v7kzglnr2dnh.cloudfront.net/images/neetoForm/default-form-template.svg"
348
+ })
349
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
350
+ className: "neeto-template__description neeto-ui-bg-white flex items-center justify-between gap-2 rounded-b-lg px-3 py-1.5",
351
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
352
+ className: "neeto-template-thumbnail__title line-clamp-2",
353
+ "data-cy": "template-card-title",
354
+ lineHeight: "normal",
355
+ style: "h5",
356
+ children: template.title
357
+ })
358
+ })]
359
+ });
360
+ };
361
+
362
+ var CategoryItem = function CategoryItem(_ref) {
363
+ var label = _ref.label,
364
+ count = _ref.count,
365
+ isActive = _ref.isActive,
366
+ setCurrentCategory = _ref.setCurrentCategory;
367
+ return /*#__PURE__*/jsxRuntime.jsxs("button", {
368
+ "data-cy": "category-".concat(utils.joinHyphenCase(label)),
369
+ tabIndex: 0,
370
+ className: classnames__default["default"]("neeto-ui-rounded-lg outline-none flex w-full items-center justify-between gap-2 border border-solid px-3 py-2 text-sm font-medium leading-4 transition-all duration-300 ease-in-out", {
371
+ "neeto-ui-text-gray-700 hover:neeto-ui-bg-gray-200 focus:neeto-ui-bg-gray-200 border-transparent": !isActive,
372
+ "neeto-ui-text-gray-800 neeto-ui-bg-white neeto-ui-border-gray-300 focus:neeto-ui-border-gray-500": isActive
373
+ }),
374
+ onClick: setCurrentCategory,
375
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
376
+ children: label
377
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
378
+ children: count
379
+ })]
380
+ });
381
+ };
382
+
383
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
384
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { query._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
385
+ var List = function List(_ref) {
386
+ var setCurrentScreen = _ref.setCurrentScreen,
387
+ setSelectedTemplate = _ref.setSelectedTemplate,
388
+ onCreate = _ref.onCreate,
389
+ isCreating = _ref.isCreating,
390
+ afterCreate = _ref.afterCreate,
391
+ refetchResource = _ref.refetchResource;
392
+ var _useTranslation = reactI18next.useTranslation(),
393
+ t = _useTranslation.t;
394
+ var _useState = React.useState(DEFAULT_CATEGORY),
395
+ _useState2 = useTemplatesApi._slicedToArray(_useState, 2),
396
+ currentCategory = _useState2[0],
397
+ _setCurrentCategory = _useState2[1];
398
+ var _useState3 = React.useState(""),
399
+ _useState4 = useTemplatesApi._slicedToArray(_useState3, 2),
400
+ searchTerm = _useState4[0],
401
+ setSearchTerm = _useState4[1];
402
+ var _useFetchTemplates = useTemplatesApi.useFetchTemplates({
403
+ searchTerm: searchTerm,
404
+ category: currentCategory
405
+ }),
406
+ _useFetchTemplates$ha = _useFetchTemplates.hasNextPage,
407
+ hasNextPage = _useFetchTemplates$ha === void 0 ? false : _useFetchTemplates$ha,
408
+ fetchNextPage = _useFetchTemplates.fetchNextPage,
409
+ isTemplatesLoading = _useFetchTemplates.isLoading,
410
+ _useFetchTemplates$da = _useFetchTemplates.data,
411
+ data = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da;
412
+ var _useInfiniteScroll = useInfiniteScroll({
413
+ loading: isTemplatesLoading,
414
+ hasNextPage: hasNextPage,
415
+ onLoadMore: fetchNextPage,
416
+ rootMargin: "0px 0px 700px 0px",
417
+ delayInMs: INFINITE_SCROLL_DELAY
418
+ }),
419
+ _useInfiniteScroll2 = useTemplatesApi._slicedToArray(_useInfiniteScroll, 2),
420
+ sentryRef = _useInfiniteScroll2[0],
421
+ rootRef = _useInfiniteScroll2[1].rootRef;
422
+ var handleCardClick = function handleCardClick(template) {
423
+ setCurrentScreen(TEMPLATE_SCREENS.PREVIEW);
424
+ setSelectedTemplate(template);
425
+ };
426
+ if (isTemplatesLoading) {
427
+ return /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {});
428
+ }
429
+ var _data$tags = data.tags,
430
+ tags = _data$tags === void 0 ? [] : _data$tags,
431
+ _data$templates = data.templates,
432
+ templates = _data$templates === void 0 ? [] : _data$templates,
433
+ _data$templatesCount = data.templatesCount,
434
+ templatesCount = _data$templatesCount === void 0 ? 0 : _data$templatesCount;
435
+ var categories = [_objectSpread(_objectSpread({}, DEFAULT_CATEGORY), {}, {
436
+ count: templatesCount
437
+ })].concat(useTemplatesApi._toConsumableArray(tags));
438
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
439
+ className: "neeto-ui-bg-gray-100 relative flex min-h-full items-start",
440
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
441
+ className: "sticky left-0 top-0 w-52 flex-shrink-0 space-y-8 py-6 pl-4 md:w-72 md:pl-10 lg:w-80 xl:pl-16",
442
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
443
+ className: "space-y-4",
444
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
445
+ className: "space-y-1",
446
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
447
+ "data-cy": "create-new-form-title",
448
+ style: "h2",
449
+ weight: "semibold",
450
+ children: t("neetoTemplate.templates.createNewEntity")
451
+ }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
452
+ lineHeight: "normal",
453
+ style: "body2",
454
+ children: t("neetoTemplate.templates.description")
455
+ })]
456
+ }), /*#__PURE__*/jsxRuntime.jsx(Search__default["default"], {
457
+ autoFocus: true,
458
+ disableTrimOnBlur: true,
459
+ "data-cy": "template-search-input",
460
+ placeholder: t("neetoTemplate.templates.search"),
461
+ onSearch: function onSearch(value) {
462
+ return setSearchTerm(value);
463
+ }
464
+ })]
465
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
466
+ className: "space-y-3",
467
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
468
+ className: "uppercase",
469
+ "data-cy": "template-categories-label",
470
+ style: "h6",
471
+ children: t("neetoTemplate.templates.categories")
472
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
473
+ className: "space-y-2",
474
+ children: categories.map(function (_ref2) {
475
+ var id = _ref2.id,
476
+ name = _ref2.name,
477
+ count = _ref2.count;
478
+ return /*#__PURE__*/React.createElement(CategoryItem, {
479
+ count: count,
480
+ isActive: currentCategory.id === id,
481
+ key: id,
482
+ label: name,
483
+ setCurrentCategory: function setCurrentCategory() {
484
+ return _setCurrentCategory({
485
+ id: id,
486
+ name: name
487
+ });
488
+ }
489
+ });
490
+ })
491
+ })]
492
+ })]
493
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
494
+ className: "h-screen w-full overflow-y-auto py-8 pl-5 pr-4 md:pl-8 md:pr-20 xl:px-20",
495
+ ref: rootRef,
496
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
497
+ className: "flex-grow space-y-6",
498
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
499
+ className: "grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 lg:gap-5 xl:gap-6 2xl:grid-cols-4",
500
+ children: [/*#__PURE__*/jsxRuntime.jsx(BlankCard, {
501
+ description: t("neetoTemplate.templates.blankCard.description"),
502
+ disabled: isCreating,
503
+ icon: isCreating ? Spinner__default["default"] : SvgCustom,
504
+ title: t("neetoTemplate.templates.blankCard.title"),
505
+ onClick: onCreate
506
+ }), templates.map(function (template, index) {
507
+ return /*#__PURE__*/React.createElement(Card, {
508
+ afterCreate: afterCreate,
509
+ refetchResource: refetchResource,
510
+ template: template,
511
+ key: index,
512
+ onClick: function onClick() {
513
+ return handleCardClick(template);
514
+ }
515
+ });
516
+ })]
517
+ }), hasNextPage && /*#__PURE__*/jsxRuntime.jsx("div", {
518
+ className: "my-10 text-center",
519
+ ref: sentryRef,
520
+ children: /*#__PURE__*/jsxRuntime.jsx(Spinner__default["default"], {})
521
+ })]
522
+ })
523
+ })]
524
+ });
525
+ };
526
+
527
+ var Preview = function Preview(_ref) {
528
+ var selectedTemplate = _ref.selectedTemplate,
529
+ setCurrentScreen = _ref.setCurrentScreen,
530
+ afterCreate = _ref.afterCreate,
531
+ refetchResource = _ref.refetchResource;
532
+ var _useTranslation = reactI18next.useTranslation(),
533
+ t = _useTranslation.t;
534
+ var _useBreakpoints = reactUtils.useBreakpoints(),
535
+ isSize = _useBreakpoints.isSize;
536
+ var _useCreateTemplate = useTemplatesApi.useCreateTemplate(),
537
+ createTemplate = _useCreateTemplate.mutate,
538
+ isCreating = _useCreateTemplate.isPending;
539
+ var _useState = React.useState(RESPONSIVE_DEVICES.DESKTOP),
540
+ _useState2 = useTemplatesApi._slicedToArray(_useState, 2),
541
+ selectedDevice = _useState2[0],
542
+ setSelectedDevice = _useState2[1];
543
+ var handleCreateTemplate = function handleCreateTemplate() {
544
+ createTemplate({
545
+ id: selectedTemplate.id
546
+ }, {
547
+ onSuccess: function onSuccess(response) {
548
+ afterCreate(response);
549
+ refetchResource();
550
+ }
551
+ });
552
+ };
553
+ var title = selectedTemplate.title,
554
+ previewUrl = selectedTemplate.previewUrl;
555
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
556
+ className: "neeto-templates-full-page-preview flex h-full w-full flex-col",
557
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
558
+ className: "neeto-templates-full-page-preview__header neeto-ui-border-gray-200 border-b px-4",
559
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
560
+ className: "mx-auto flex w-full max-w-6xl items-center justify-between py-[9px]",
561
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
562
+ className: "w-1/3",
563
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
564
+ className: "truncate leading-tight",
565
+ "data-cy": "preview-template-title",
566
+ style: "h3",
567
+ weight: "semibold",
568
+ children: title
569
+ })
570
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
571
+ className: "hidden flex-shrink-0 lg:flex",
572
+ children: /*#__PURE__*/jsxRuntime.jsx(ResponsiveDevicePicker__default["default"], {
573
+ selectedDevice: selectedDevice,
574
+ onDeviceChange: setSelectedDevice
575
+ })
576
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
577
+ className: "flex w-1/3 items-center justify-end gap-2",
578
+ children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
579
+ className: "flex-shrink-0",
580
+ "data-cy": "preview-template-back-button",
581
+ style: "secondary",
582
+ label: isSize("mobile") ? t("neetoTemplate.templates.back") : t("neetoTemplate.templates.backToTemplates"),
583
+ onClick: function onClick() {
584
+ return setCurrentScreen(TEMPLATE_SCREENS.LIST);
585
+ }
586
+ }), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
587
+ className: "flex-shrink-0",
588
+ "data-cy": "preview-use-template-button",
589
+ disabled: isCreating,
590
+ label: t("neetoTemplate.templates.editTemplate"),
591
+ loading: isCreating,
592
+ onClick: handleCreateTemplate
593
+ })]
594
+ })]
595
+ })
596
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
597
+ className: "neeto-ui-bg-gray-200 neeto-templates-full-page-preview__holder-wrapper min-h-0 flex-grow",
598
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
599
+ className: classnames__default["default"]("neeto-templates-full-page-preview__holder m-auto", {
600
+ "neeto-templates-full-page-preview__holder--desktop": selectedDevice === RESPONSIVE_DEVICES.DESKTOP,
601
+ "neeto-templates-full-page-preview__holder--tablet": selectedDevice === RESPONSIVE_DEVICES.TABLET,
602
+ "neeto-templates-full-page-preview__holder--mobile": selectedDevice === RESPONSIVE_DEVICES.MOBILE
603
+ }),
604
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
605
+ className: "neeto-templates-full-page-preview__device-border h-full w-full",
606
+ children: /*#__PURE__*/jsxRuntime.jsx("iframe", {
607
+ className: "neeto-templates-full-page-preview__iframe h-full w-full border-none",
608
+ "data-cy": "iframe-id",
609
+ src: previewUrl
610
+ })
611
+ })
612
+ })
613
+ })]
614
+ });
615
+ };
616
+
617
+ var CreateTemplateModal = function CreateTemplateModal(_ref) {
618
+ var isOpen = _ref.isOpen,
619
+ onClose = _ref.onClose,
620
+ isCreating = _ref.isCreating,
621
+ refetchResource = _ref.refetchResource,
622
+ _ref$onCreate = _ref.onCreate,
623
+ onCreate = _ref$onCreate === void 0 ? neetoCist.noop : _ref$onCreate,
624
+ _ref$afterCreate = _ref.afterCreate,
625
+ afterCreate = _ref$afterCreate === void 0 ? neetoCist.noop : _ref$afterCreate;
626
+ var _useState = React.useState(TEMPLATE_SCREENS.LIST),
627
+ _useState2 = useTemplatesApi._slicedToArray(_useState, 2),
628
+ currentScreen = _useState2[0],
629
+ setCurrentScreen = _useState2[1];
630
+ var _useState3 = React.useState({}),
631
+ _useState4 = useTemplatesApi._slicedToArray(_useState3, 2),
632
+ selectedTemplate = _useState4[0],
633
+ setSelectedTemplate = _useState4[1];
634
+ var onModalClose = function onModalClose() {
635
+ onClose();
636
+ setTimeout(function () {
637
+ setCurrentScreen(TEMPLATE_SCREENS.LIST);
638
+ }, 300); //To accommodate the animation duration.
639
+ };
640
+
641
+ return /*#__PURE__*/jsxRuntime.jsx(Modal__default["default"], {
642
+ isOpen: isOpen,
643
+ className: "neeto-template-list h-screen w-screen overflow-y-auto",
644
+ closeButton: currentScreen === TEMPLATE_SCREENS.LIST,
645
+ size: "fullScreen",
646
+ onClose: onModalClose,
647
+ children: currentScreen === TEMPLATE_SCREENS.LIST ? /*#__PURE__*/jsxRuntime.jsx(List, {
648
+ afterCreate: afterCreate,
649
+ isCreating: isCreating,
650
+ onCreate: onCreate,
651
+ refetchResource: refetchResource,
652
+ setCurrentScreen: setCurrentScreen,
653
+ setSelectedTemplate: setSelectedTemplate
654
+ }) : /*#__PURE__*/jsxRuntime.jsx(Preview, {
655
+ afterCreate: afterCreate,
656
+ refetchResource: refetchResource,
657
+ selectedTemplate: selectedTemplate,
658
+ setCurrentScreen: setCurrentScreen
659
+ })
660
+ });
661
+ };
662
+
663
+ module.exports = CreateTemplateModal;
664
+ //# sourceMappingURL=CreateTemplateModal.js.map