@bigbinary/neeto-molecules 1.0.60 → 1.0.62

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.
@@ -12537,6 +12537,13 @@ var bytesToSize = function bytesToSize(bytes) {
12537
12537
  if (i === 0) return "".concat(bytes, " ").concat(sizes[i], ")");
12538
12538
  return "".concat((bytes / Math.pow(1024, i)).toFixed(1), " ").concat(sizes[i]);
12539
12539
  };
12540
+ var scrollElementIntoView = function scrollElementIntoView(elementId) {
12541
+ var _elementToScroll$scro;
12542
+ var elementToScroll = document.getElementById(elementId);
12543
+ elementToScroll === null || elementToScroll === void 0 ? void 0 : (_elementToScroll$scro = elementToScroll.scrollIntoView) === null || _elementToScroll$scro === void 0 ? void 0 : _elementToScroll$scro.call(elementToScroll, {
12544
+ behavior: "smooth"
12545
+ });
12546
+ };
12540
12547
 
12541
12548
  var useDropzoneWithValidation = function useDropzoneWithValidation(_ref) {
12542
12549
  var maxSize = _ref.maxSize,
@@ -13235,19 +13242,27 @@ var ThemeCard = function ThemeCard(_ref) {
13235
13242
  onEditTheme = _ref.onEditTheme,
13236
13243
  onApplyTheme = _ref.onApplyTheme,
13237
13244
  onCloneTheme = _ref.onCloneTheme,
13238
- theme = _ref.theme;
13245
+ theme = _ref.theme,
13246
+ isHighLightedTheme = _ref.isHighLightedTheme,
13247
+ isApplyingTheme = _ref.isApplyingTheme;
13239
13248
  var _useTranslation = reactI18next.useTranslation(),
13240
13249
  t = _useTranslation.t;
13241
13250
  var name = theme.name,
13242
13251
  styles = _objectWithoutProperties(theme, _excluded);
13252
+ var handleApplyTheme = function handleApplyTheme() {
13253
+ if (isApplyingTheme) return;
13254
+ onApplyTheme(theme);
13255
+ };
13243
13256
  return /*#__PURE__*/React__default["default"].createElement("div", {
13244
13257
  className: "group space-y-2",
13245
- "data-cy": active ? "active-theme-card" : "theme-card"
13258
+ "data-cy": active ? "active-theme-card" : "theme-card",
13259
+ id: theme.id
13246
13260
  }, /*#__PURE__*/React__default["default"].createElement("div", {
13247
13261
  className: classnames("neeto-molecules-theme-thumbnail neeto-ui-rounded-lg border transition-all duration-300 ease-in-out", {
13248
13262
  "neeto-ui-border-gray-400": !active,
13249
13263
  "neeto-ui-border-gray-800 neeto-molecules-theme-thumbnail--active": active,
13250
- "neeto-molecules-theme-thumbnail--preview-active": isPreviewing
13264
+ "neeto-molecules-theme-thumbnail--preview-active": isPreviewing,
13265
+ "neeto-molecules-theme-thumbnail--highlight-active": isHighLightedTheme
13251
13266
  }),
13252
13267
  style: {
13253
13268
  backgroundColor: ramda.path(["colorScheme", "backgroundColor"], styles),
@@ -13297,12 +13312,12 @@ var ThemeCard = function ThemeCard(_ref) {
13297
13312
  }) : /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
13298
13313
  className: "flex-shrink-0",
13299
13314
  "data-cy": "apply-theme-button",
13315
+ disabled: isApplyingTheme,
13300
13316
  label: t("neetoMolecules.common.actions.apply"),
13317
+ loading: isApplyingTheme,
13301
13318
  size: "small",
13302
13319
  style: "link",
13303
- onClick: function onClick() {
13304
- return onApplyTheme(theme);
13305
- }
13320
+ onClick: handleApplyTheme
13306
13321
  }), /*#__PURE__*/React__default["default"].createElement(neetoui.Dropdown, {
13307
13322
  buttonProps: {
13308
13323
  "data-cy": "theme-card-options"
@@ -13341,7 +13356,10 @@ var Themes = function Themes(_ref) {
13341
13356
  onEditTheme = _ref.onEditTheme,
13342
13357
  onApplyTheme = _ref.onApplyTheme,
13343
13358
  previewingTheme = _ref.previewingTheme,
13344
- setPreviewingTheme = _ref.setPreviewingTheme;
13359
+ setPreviewingTheme = _ref.setPreviewingTheme,
13360
+ themeToHighlight = _ref.themeToHighlight,
13361
+ didScrollActiveThemeIntoView = _ref.didScrollActiveThemeIntoView,
13362
+ applyingThemeId = _ref.applyingThemeId;
13345
13363
  var _useTranslation = reactI18next.useTranslation(),
13346
13364
  t = _useTranslation.t;
13347
13365
  var _useState = React.useState(""),
@@ -13355,6 +13373,13 @@ var Themes = function Themes(_ref) {
13355
13373
  return theme.name.toLowerCase().includes(searchQuery.toLowerCase());
13356
13374
  });
13357
13375
  var isSearchFieldVisible = (customThemes === null || customThemes === void 0 ? void 0 : customThemes.length) + (defaultThemes === null || defaultThemes === void 0 ? void 0 : defaultThemes.length) > 10;
13376
+ React.useEffect(function () {
13377
+ if (didScrollActiveThemeIntoView.current || !(currentTheme !== null && currentTheme !== void 0 && currentTheme.id)) return;
13378
+ didScrollActiveThemeIntoView.current = true;
13379
+ setTimeout(function () {
13380
+ scrollElementIntoView(currentTheme.id);
13381
+ }, 200);
13382
+ }, [didScrollActiveThemeIntoView, currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id]);
13358
13383
  return /*#__PURE__*/React__default["default"].createElement("div", {
13359
13384
  className: "neeto-molecules-theme-design-sidebar__scroll"
13360
13385
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -13387,6 +13412,7 @@ var Themes = function Themes(_ref) {
13387
13412
  }, filteredDefaultThemes.map(function (theme) {
13388
13413
  return /*#__PURE__*/React__default["default"].createElement(ThemeCard, {
13389
13414
  active: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id,
13415
+ isApplyingTheme: applyingThemeId === theme.id,
13390
13416
  isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
13391
13417
  key: theme.id,
13392
13418
  theme: theme,
@@ -13407,6 +13433,7 @@ var Themes = function Themes(_ref) {
13407
13433
  var isActive = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id;
13408
13434
  return /*#__PURE__*/React__default["default"].createElement(ThemeCard, {
13409
13435
  active: isActive,
13436
+ isHighLightedTheme: theme.id === themeToHighlight,
13410
13437
  isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
13411
13438
  key: theme.id,
13412
13439
  theme: theme,
@@ -13421,7 +13448,7 @@ var Themes = function Themes(_ref) {
13421
13448
 
13422
13449
  var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
13423
13450
 
13424
- var css = ".neeto-molecules-theme-design-sidebar{background-color:rgb(var(--neeto-ui-white));box-shadow:var(--neeto-ui-shadow-s);height:100%;width:320px}.neeto-molecules-theme-design-sidebar .neeto-molecules-theme-design-sidebar__header{padding-bottom:8px;padding-top:16px}.neeto-molecules-theme-design-sidebar .neeto-molecules-theme-design-sidebar__scroll{height:94%;overflow-y:auto}.neeto-molecules-theme-design-sidebar .neeto-molecules-theme-design-sidebar__scroll .neeto-ui-colorpicker__target .neeto-ui-colorpicker-target__code{display:none}.neeto-molecules-theme-design-preview__wrapper{background-color:rgb(var(--neeto-ui-gray-100));flex-grow:1;height:100%;position:relative}.neeto-molecules-theme-thumbnail--active{border-color:rgb(var(--neeto-ui-primary-500))!important;box-shadow:0 0 0 1px rgb(var(--neeto-ui-primary-500))!important}.neeto-molecules-theme-thumbnail--preview-active{border-color:rgb(var(--neeto-ui-gray-700));box-shadow:0 0 0 1px rgb(var(--neeto-ui-gray-700))}";
13451
+ var css = ".neeto-molecules-theme-design-sidebar{background-color:rgb(var(--neeto-ui-white));box-shadow:var(--neeto-ui-shadow-s);height:100%;width:320px}.neeto-molecules-theme-design-sidebar .neeto-molecules-theme-design-sidebar__header{padding-bottom:8px;padding-top:16px}.neeto-molecules-theme-design-sidebar .neeto-molecules-theme-design-sidebar__scroll{height:94%;overflow-y:auto}.neeto-molecules-theme-design-sidebar .neeto-molecules-theme-design-sidebar__scroll .neeto-ui-colorpicker__target .neeto-ui-colorpicker-target__code{display:none}.neeto-molecules-theme-design-preview__wrapper{background-color:rgb(var(--neeto-ui-gray-100));flex-grow:1;height:100%;position:relative}.neeto-molecules-theme-thumbnail--active{border-color:rgb(var(--neeto-ui-primary-500))!important;box-shadow:0 0 0 1px rgb(var(--neeto-ui-primary-500))!important}.neeto-molecules-theme-thumbnail--preview-active{border-color:rgb(var(--neeto-ui-gray-700));box-shadow:0 0 0 1px rgb(var(--neeto-ui-gray-700))}.neeto-molecules-theme-thumbnail--highlight-active{border-color:rgb(var(--neeto-ui-success-500));box-shadow:0 0 0 1px rgb(var(--neeto-ui-success-500));transition:border-color box-shadow .1s .1s}";
13425
13452
  n(css,{});
13426
13453
 
13427
13454
  var TitleBar = function TitleBar(_ref) {
@@ -13489,7 +13516,8 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13489
13516
  editTheme = _ref.editTheme,
13490
13517
  applyTheme = _ref.applyTheme,
13491
13518
  currentTheme = _ref.currentTheme,
13492
- isLoadingThemes = _ref.isLoadingThemes;
13519
+ isLoadingThemes = _ref.isLoadingThemes,
13520
+ applyingThemeId = _ref.applyingThemeId;
13493
13521
  var _useTranslation = reactI18next.useTranslation(),
13494
13522
  t = _useTranslation.t;
13495
13523
  var _useState = React.useState(DESIGN_SCREENS.THEMES),
@@ -13500,6 +13528,11 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13500
13528
  _useState4 = _slicedToArray$2(_useState3, 2),
13501
13529
  previewingTheme = _useState4[0],
13502
13530
  setPreviewingTheme = _useState4[1];
13531
+ var _useState5 = React.useState(null),
13532
+ _useState6 = _slicedToArray$2(_useState5, 2),
13533
+ themeToHighlight = _useState6[0],
13534
+ setThemeToHighlight = _useState6[1];
13535
+ var didScrollActiveThemeIntoView = React.useRef(null);
13503
13536
  React.useEffect(function () {
13504
13537
  isLoadingThemes && setCurrentScreen(DESIGN_SCREENS.LOADING);
13505
13538
  }, [isLoadingThemes]);
@@ -13510,12 +13543,6 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13510
13543
  setPreviewingTheme(theme);
13511
13544
  setCurrentScreen(DESIGN_SCREENS.CUSTOMIZE);
13512
13545
  };
13513
- var handleCloneTheme = function handleCloneTheme(data) {
13514
- var themeToClone = _objectSpread(_objectSpread({}, data), {}, {
13515
- name: "".concat(data.name, " - clone")
13516
- });
13517
- createTheme(themeToClone);
13518
- };
13519
13546
  var handleBackPress = function handleBackPress() {
13520
13547
  setCurrentScreen(DESIGN_SCREENS.THEMES);
13521
13548
  setPreviewingTheme(null);
@@ -13527,10 +13554,30 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13527
13554
  }));
13528
13555
  setCurrentScreen(DESIGN_SCREENS.CUSTOMIZE);
13529
13556
  };
13557
+ var highlightTheme = function highlightTheme(themeToHighlight) {
13558
+ setTimeout(function () {
13559
+ scrollElementIntoView(themeToHighlight.id);
13560
+ }, 1500);
13561
+ setTimeout(function () {
13562
+ setThemeToHighlight(null);
13563
+ }, 4000);
13564
+ setThemeToHighlight(themeToHighlight.id);
13565
+ };
13566
+ var createThemeCallback = function createThemeCallback(createdTheme) {
13567
+ setCurrentScreen(DESIGN_SCREENS.THEMES);
13568
+ setPreviewingTheme(createdTheme.id);
13569
+ highlightTheme(createdTheme);
13570
+ };
13571
+ var handleCloneTheme = function handleCloneTheme(data) {
13572
+ var themeToClone = _objectSpread(_objectSpread({}, data), {}, {
13573
+ name: "".concat(data.name, " - clone")
13574
+ });
13575
+ createTheme(themeToClone, createThemeCallback);
13576
+ };
13530
13577
  var handleFormSubmit = function handleFormSubmit(values) {
13531
13578
  var formattedValues = transformTheme(values);
13532
13579
  if (!(previewingTheme !== null && previewingTheme !== void 0 && previewingTheme.id)) {
13533
- createTheme(formattedValues);
13580
+ createTheme(formattedValues, createThemeCallback);
13534
13581
  } else {
13535
13582
  editTheme(_objectSpread(_objectSpread({}, formattedValues), {}, {
13536
13583
  id: previewingTheme.id
@@ -13547,11 +13594,15 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13547
13594
  }), currentScreen === DESIGN_SCREENS.LOADING && /*#__PURE__*/React__default["default"].createElement("div", {
13548
13595
  className: "flex h-full w-full items-center justify-center"
13549
13596
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Spinner, null)), currentScreen === DESIGN_SCREENS.THEMES && /*#__PURE__*/React__default["default"].createElement(Themes, {
13597
+ applyingThemeId: applyingThemeId,
13550
13598
  currentTheme: currentTheme,
13551
13599
  customThemes: customThemes,
13552
13600
  defaultThemes: defaultThemes,
13601
+ didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
13602
+ highlightTheme: highlightTheme,
13553
13603
  previewingTheme: previewingTheme,
13554
13604
  setPreviewingTheme: setPreviewingTheme,
13605
+ themeToHighlight: themeToHighlight,
13555
13606
  onApplyTheme: applyTheme,
13556
13607
  onCloneTheme: handleCloneTheme,
13557
13608
  onDeleteTheme: deleteTheme,