@bigbinary/neeto-themes-frontend 3.1.8 → 3.1.10

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.
@@ -9,7 +9,7 @@ var reactI18next = require('react-i18next');
9
9
  var utils = require('../index-BCC98npS.js');
10
10
  var reactQuery = require('@tanstack/react-query');
11
11
  var axios = require('axios');
12
- var useThemeUtils = require('../useThemeUtils-B_bPCE4d.js');
12
+ var useThemeUtils = require('../useThemeUtils-7t8QA7GV.js');
13
13
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
14
14
  var classnames = require('classnames');
15
15
  var utils$1 = require('@bigbinary/neeto-commons-frontend/utils');
@@ -28,11 +28,9 @@ var Tooltip = require('@bigbinary/neetoui/Tooltip');
28
28
  var Form = require('@bigbinary/neetoui/formik/Form');
29
29
  var BlockNavigation = require('@bigbinary/neetoui/formik/BlockNavigation');
30
30
  var ramda = require('ramda');
31
- var yup = require('yup');
32
- var Editor = require('@monaco-editor/react');
33
31
  var formik = require('formik');
34
- var Down = require('@bigbinary/neeto-icons/Down');
35
32
  var jsxRuntime = require('react/jsx-runtime');
33
+ var Down = require('@bigbinary/neeto-icons/Down');
36
34
  var i18next = require('i18next');
37
35
  var CenterAlign = require('@bigbinary/neeto-icons/CenterAlign');
38
36
  var LeftAlign = require('@bigbinary/neeto-icons/LeftAlign');
@@ -51,25 +49,7 @@ var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
51
49
  var LeftArrow = require('@bigbinary/neeto-icons/LeftArrow');
52
50
  var Plus = require('@bigbinary/neeto-icons/Plus');
53
51
  require('zustand');
54
-
55
- function _interopNamespaceDefault(e) {
56
- var n = Object.create(null);
57
- if (e) {
58
- Object.keys(e).forEach(function (k) {
59
- if (k !== 'default') {
60
- var d = Object.getOwnPropertyDescriptor(e, k);
61
- Object.defineProperty(n, k, d.get ? d : {
62
- enumerable: true,
63
- get: function () { return e[k]; }
64
- });
65
- }
66
- });
67
- }
68
- n.default = e;
69
- return Object.freeze(n);
70
- }
71
-
72
- var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
52
+ require('yup');
73
53
 
74
54
  var show$2 = function show(entityId) {
75
55
  return axios.get("".concat(utils.BASE_URL, "/api/v1/entities/").concat(entityId));
@@ -244,94 +224,6 @@ var useShowGlobalTheme = function useShowGlobalTheme(entityType) {
244
224
  });
245
225
  };
246
226
 
247
- var POSITION_OPTIONS = [{
248
- label: "Left",
249
- value: "left"
250
- }, {
251
- label: "Right",
252
- value: "right"
253
- }];
254
- var FONT_OPTIONS = [{
255
- label: "System UI",
256
- value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
257
- }, {
258
- label: "Cedarville Cursive",
259
- value: "'Cedarville Cursive', cursive"
260
- }, {
261
- label: "Poppins",
262
- value: "Poppins, sans-serif"
263
- }, {
264
- label: "Roboto",
265
- value: "Roboto, sans-serif"
266
- }, {
267
- label: "Open Sans",
268
- value: "Open Sans, sans-serif"
269
- }, {
270
- label: "Montserrat",
271
- value: "Montserrat, sans-serif"
272
- }, {
273
- label: "Raleway",
274
- value: "Raleway, sans-serif"
275
- }, {
276
- label: "Quicksand",
277
- value: "Quicksand, sans-serif"
278
- }, {
279
- label: "Inter",
280
- value: "Inter, sans-serif"
281
- }, {
282
- label: "Satoshi",
283
- value: "Satoshi, sans-serif"
284
- }, {
285
- label: "Chillax",
286
- value: "Chillax, sans-serif"
287
- }, {
288
- label: "Clash Display",
289
- value: "Clash Display, sans-serif"
290
- }, {
291
- label: "General Sans",
292
- value: "General Sans, sans-serif"
293
- }, {
294
- label: "Cabinet Grotesk",
295
- value: "Cabinet Grotesk, sans-serif"
296
- }, {
297
- label: "Lora",
298
- value: "Lora, serif"
299
- }, {
300
- label: "Merriweather",
301
- value: "Merriweather, serif"
302
- }, {
303
- label: "Boska",
304
- value: "Boska, serif"
305
- }, {
306
- label: "Playfair Display",
307
- value: "Playfair Display, serif"
308
- }, {
309
- label: "Roboto Slab",
310
- value: "Roboto Slab, serif"
311
- }, {
312
- label: "Dancing Script",
313
- value: "Dancing Script, cursive"
314
- }, {
315
- label: "Tw Cent",
316
- value: "Tw Cen MT, Tahoma, sans-serif"
317
- }, {
318
- label: "Comic Sans",
319
- value: "Comic Sans MS, cursive"
320
- }];
321
- var THEME_VALIDATION_SCHEMA = yup__namespace.object().shape({
322
- name: yup__namespace.string().required("Name is required")
323
- });
324
- var OVERLAY_OPACITY_SLIDER_MARKS = {
325
- 0: " "
326
- };
327
- var HUNDRED = 100;
328
- var ACCORDIAN_OPEN_STATE = {
329
- name: true,
330
- style: true,
331
- images: false,
332
- customcss: false
333
- };
334
-
335
227
  var DESIGN_SCREENS = {
336
228
  THEMES: "Themes",
337
229
  Customize: "Customize",
@@ -339,6 +231,35 @@ var DESIGN_SCREENS = {
339
231
  };
340
232
  var ONE_MEGABYTE = 1;
341
233
 
234
+ var MonacoEditor = /*#__PURE__*/react.lazy(function () {
235
+ return import('@monaco-editor/react');
236
+ });
237
+ var Editor = function Editor(_ref) {
238
+ var value = _ref.value,
239
+ isCustomCssScreen = _ref.isCustomCssScreen,
240
+ onChange = _ref.onChange;
241
+ return /*#__PURE__*/jsxRuntime.jsx(react.Suspense, {
242
+ fallback: /*#__PURE__*/jsxRuntime.jsx(Spinner, {}),
243
+ children: /*#__PURE__*/jsxRuntime.jsx(MonacoEditor, {
244
+ onChange: onChange,
245
+ value: value,
246
+ language: "css",
247
+ theme: "vs-dark",
248
+ className: classnames({
249
+ rounded: true,
250
+ "css-editor-height__expanded": isCustomCssScreen,
251
+ "css-editor-height__regular": !isCustomCssScreen
252
+ }),
253
+ options: {
254
+ scrollBeyondLastLine: false,
255
+ minimap: {
256
+ enabled: false
257
+ }
258
+ }
259
+ })
260
+ });
261
+ };
262
+
342
263
  function ownKeys$4(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; }
343
264
  function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
344
265
  var Card$2 = function Card(_ref) {
@@ -347,21 +268,25 @@ var Card$2 = function Card(_ref) {
347
268
  children = _ref.children,
348
269
  name = _ref.name,
349
270
  className = _ref.className;
350
- var _useState = react.useState(ACCORDIAN_OPEN_STATE),
351
- _useState2 = _slicedToArray(_useState, 2),
352
- accordianOpenState = _useState2[0],
353
- setAccordianOpenState = _useState2[1];
271
+ var _useConfigStore = useThemeUtils.useConfigStore(function (store) {
272
+ return {
273
+ accordionOpenState: store["accordionOpenState"],
274
+ setAccordionOpenState: store["setAccordionOpenState"]
275
+ };
276
+ }, shallow.shallow),
277
+ accordionOpenState = _useConfigStore.accordionOpenState,
278
+ setAccordionOpenState = _useConfigStore.setAccordionOpenState;
354
279
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
355
280
  "data-cy": "theme-".concat(neetoCist.hyphenate(title), "-properties"),
356
281
  className: classnames("neeto-themes-nano-section neeto-ui-border-gray-200 border-b pt-2 transition-all duration-300 last:border-none", className, {
357
- "pb-2": !accordianOpenState[name],
358
- "pb-3": accordianOpenState[name]
282
+ "pb-2": !accordionOpenState[name],
283
+ "pb-3": accordionOpenState[name]
359
284
  }),
360
285
  children: [title && /*#__PURE__*/jsxRuntime.jsxs("button", {
361
286
  className: "neeto-themes-nano-section__title flex w-full cursor-pointer items-center justify-between px-1 py-2 focus:outline-none",
362
287
  type: "button",
363
288
  onClick: function onClick() {
364
- return setAccordianOpenState(_objectSpread$4(_objectSpread$4({}, accordianOpenState), {}, _defineProperty({}, name, !accordianOpenState[name])));
289
+ return setAccordionOpenState(_objectSpread$4(_objectSpread$4({}, accordionOpenState), {}, _defineProperty({}, name, !accordionOpenState[name])));
365
290
  },
366
291
  children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
367
292
  className: "min-w-0 flex-grow text-left",
@@ -374,13 +299,13 @@ var Card$2 = function Card(_ref) {
374
299
  }), /*#__PURE__*/jsxRuntime.jsx(Down, {
375
300
  size: 20,
376
301
  className: classnames("transition-all duration-300", {
377
- "rotate-180": accordianOpenState[name]
302
+ "rotate-180": accordionOpenState[name]
378
303
  })
379
304
  })]
380
305
  }), children && /*#__PURE__*/jsxRuntime.jsx("div", {
381
306
  className: classnames("neeto-themes-nano-section__content w-full space-y-3 overflow-hidden px-1 transition-all duration-300", {
382
- "neeto-themes-nano-section__content--closed": !accordianOpenState[name],
383
- "neeto-themes-nano-section__content--open pb-1": accordianOpenState[name]
307
+ "neeto-themes-nano-section__content--closed": !accordionOpenState[name],
308
+ "neeto-themes-nano-section__content--open pb-1": accordionOpenState[name]
384
309
  }),
385
310
  children: children
386
311
  })]
@@ -426,10 +351,12 @@ var CustomCSS = function CustomCSS(_ref) {
426
351
  setFieldValue = _useFormikContext.setFieldValue;
427
352
  var _useConfigStore = useThemeUtils.useConfigStore(function (store) {
428
353
  return {
429
- themePropertiesSchema: store["themePropertiesSchema"]
354
+ themePropertiesSchema: store["themePropertiesSchema"],
355
+ accordionOpenState: store["accordionOpenState"]
430
356
  };
431
357
  }, shallow.shallow),
432
- themePropertiesSchema = _useConfigStore.themePropertiesSchema;
358
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema,
359
+ accordionOpenState = _useConfigStore.accordionOpenState;
433
360
  var customCSS = neetoCist.findBy({
434
361
  kind: "custom_css"
435
362
  }, values.properties);
@@ -474,21 +401,9 @@ var CustomCSS = function CustomCSS(_ref) {
474
401
  label: isCustomCssScreen ? t("neetoThemes.buttons.minimizeEditor") : t("neetoThemes.buttons.expandEditor"),
475
402
  onClick: handleEditorToggle
476
403
  })
477
- }), /*#__PURE__*/jsxRuntime.jsx(Editor, {
478
- language: "css",
479
- theme: "vs-dark",
404
+ }), accordionOpenState.customcss && /*#__PURE__*/jsxRuntime.jsx(Editor, {
405
+ isCustomCssScreen: isCustomCssScreen,
480
406
  value: customCSS.value,
481
- className: classnames({
482
- rounded: true,
483
- "css-editor-height__expanded": isCustomCssScreen,
484
- "css-editor-height__regular": !isCustomCssScreen
485
- }),
486
- options: {
487
- scrollBeyondLastLine: false,
488
- minimap: {
489
- enabled: false
490
- }
491
- },
492
407
  onChange: handleChange
493
408
  })]
494
409
  })
@@ -954,10 +869,10 @@ var Properties = function Properties(_ref) {
954
869
  case "font_family":
955
870
  return /*#__PURE__*/jsxRuntime.jsx(FontPickerBlock, {
956
871
  label: buildLabel(key, kind),
957
- options: FONT_OPTIONS,
872
+ options: useThemeUtils.FONT_OPTIONS,
958
873
  value: neetoCist.findBy({
959
874
  value: value || null
960
- }, FONT_OPTIONS),
875
+ }, useThemeUtils.FONT_OPTIONS),
961
876
  onChange: function onChange(_ref4) {
962
877
  var value = _ref4.value;
963
878
  return handleChange(key, value);
@@ -985,9 +900,9 @@ var Properties = function Properties(_ref) {
985
900
  case "overlay_opacity":
986
901
  return /*#__PURE__*/jsxRuntime.jsx(SliderBlock, {
987
902
  label: buildLabel(key, kind),
988
- marks: OVERLAY_OPACITY_SLIDER_MARKS,
989
- max: HUNDRED,
990
- min: ramda.negate(HUNDRED),
903
+ marks: useThemeUtils.OVERLAY_OPACITY_SLIDER_MARKS,
904
+ max: useThemeUtils.HUNDRED,
905
+ min: ramda.negate(useThemeUtils.HUNDRED),
991
906
  value: Number(value) || 0,
992
907
  onChange: function onChange(opacity) {
993
908
  return handleOverlayChange(key, opacity);
@@ -1004,7 +919,7 @@ var Properties = function Properties(_ref) {
1004
919
  }, themePropertiesSchema)) === null || _findBy3 === void 0 || (_findBy3 = _findBy3.options) === null || _findBy3 === void 0 ? void 0 : _findBy3.map(neetoCist.toLabelAndValue);
1005
920
  return /*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
1006
921
  label: buildLabel(key, kind),
1007
- options: options || POSITION_OPTIONS,
922
+ options: options || useThemeUtils.POSITION_OPTIONS,
1008
923
  placeholder: "left",
1009
924
  value: neetoCist.toLabelAndValue(value),
1010
925
  onChange: function onChange(option) {
@@ -1142,7 +1057,7 @@ var ImageBlock = function ImageBlock(_ref) {
1142
1057
  onUploadComplete: handleImageChange
1143
1058
  }), isPositionChangerVisible && /*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
1144
1059
  label: buildLabel("".concat(name, "Position"), "image"),
1145
- options: options || POSITION_OPTIONS,
1060
+ options: options || useThemeUtils.POSITION_OPTIONS,
1146
1061
  placeholder: t("neetoThemes.common.left"),
1147
1062
  value: neetoCist.toLabelAndValue(((_findBy = neetoCist.findBy({
1148
1063
  key: "".concat(name, "_position")
@@ -1169,7 +1084,7 @@ var Images = function Images(_ref) {
1169
1084
  return /*#__PURE__*/jsxRuntime.jsxs(Card$2, {
1170
1085
  className: className,
1171
1086
  title: title,
1172
- name: "images",
1087
+ name: key,
1173
1088
  children: [/*#__PURE__*/jsxRuntime.jsx(ImageBlock, {
1174
1089
  attribute: attribute,
1175
1090
  defaultImageSize: defaultImageSize,
@@ -1314,7 +1229,7 @@ var Customize = function Customize(_ref) {
1314
1229
  shouldSetAsGlobalTheme: isThemeGlobalTheme,
1315
1230
  entityType: entityType
1316
1231
  }),
1317
- validationSchema: THEME_VALIDATION_SCHEMA,
1232
+ validationSchema: useThemeUtils.THEME_VALIDATION_SCHEMA,
1318
1233
  enableReinitialize: true,
1319
1234
  onSubmit: onSubmit
1320
1235
  },
@@ -1905,7 +1820,7 @@ var TitleBar = function TitleBar(_ref) {
1905
1820
  lineHeight: "normal",
1906
1821
  style: "h3",
1907
1822
  weight: "semibold",
1908
- children: [isCustomizeScreen && (utils.isNewThemeRoute() ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
1823
+ children: [isCustomizeScreen && !isCustomCssScreen && (utils.isNewThemeRoute() ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
1909
1824
  })]
1910
1825
  })
1911
1826
  });