@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.
@@ -12512,6 +12512,13 @@ var bytesToSize = function bytesToSize(bytes) {
12512
12512
  if (i === 0) return "".concat(bytes, " ").concat(sizes[i], ")");
12513
12513
  return "".concat((bytes / Math.pow(1024, i)).toFixed(1), " ").concat(sizes[i]);
12514
12514
  };
12515
+ var scrollElementIntoView = function scrollElementIntoView(elementId) {
12516
+ var _elementToScroll$scro;
12517
+ var elementToScroll = document.getElementById(elementId);
12518
+ elementToScroll === null || elementToScroll === void 0 ? void 0 : (_elementToScroll$scro = elementToScroll.scrollIntoView) === null || _elementToScroll$scro === void 0 ? void 0 : _elementToScroll$scro.call(elementToScroll, {
12519
+ behavior: "smooth"
12520
+ });
12521
+ };
12515
12522
 
12516
12523
  var useDropzoneWithValidation = function useDropzoneWithValidation(_ref) {
12517
12524
  var maxSize = _ref.maxSize,
@@ -13210,19 +13217,27 @@ var ThemeCard = function ThemeCard(_ref) {
13210
13217
  onEditTheme = _ref.onEditTheme,
13211
13218
  onApplyTheme = _ref.onApplyTheme,
13212
13219
  onCloneTheme = _ref.onCloneTheme,
13213
- theme = _ref.theme;
13220
+ theme = _ref.theme,
13221
+ isHighLightedTheme = _ref.isHighLightedTheme,
13222
+ isApplyingTheme = _ref.isApplyingTheme;
13214
13223
  var _useTranslation = useTranslation(),
13215
13224
  t = _useTranslation.t;
13216
13225
  var name = theme.name,
13217
13226
  styles = _objectWithoutProperties(theme, _excluded);
13227
+ var handleApplyTheme = function handleApplyTheme() {
13228
+ if (isApplyingTheme) return;
13229
+ onApplyTheme(theme);
13230
+ };
13218
13231
  return /*#__PURE__*/React__default.createElement("div", {
13219
13232
  className: "group space-y-2",
13220
- "data-cy": active ? "active-theme-card" : "theme-card"
13233
+ "data-cy": active ? "active-theme-card" : "theme-card",
13234
+ id: theme.id
13221
13235
  }, /*#__PURE__*/React__default.createElement("div", {
13222
13236
  className: classnames("neeto-molecules-theme-thumbnail neeto-ui-rounded-lg border transition-all duration-300 ease-in-out", {
13223
13237
  "neeto-ui-border-gray-400": !active,
13224
13238
  "neeto-ui-border-gray-800 neeto-molecules-theme-thumbnail--active": active,
13225
- "neeto-molecules-theme-thumbnail--preview-active": isPreviewing
13239
+ "neeto-molecules-theme-thumbnail--preview-active": isPreviewing,
13240
+ "neeto-molecules-theme-thumbnail--highlight-active": isHighLightedTheme
13226
13241
  }),
13227
13242
  style: {
13228
13243
  backgroundColor: path(["colorScheme", "backgroundColor"], styles),
@@ -13272,12 +13287,12 @@ var ThemeCard = function ThemeCard(_ref) {
13272
13287
  }) : /*#__PURE__*/React__default.createElement(Button, {
13273
13288
  className: "flex-shrink-0",
13274
13289
  "data-cy": "apply-theme-button",
13290
+ disabled: isApplyingTheme,
13275
13291
  label: t("neetoMolecules.common.actions.apply"),
13292
+ loading: isApplyingTheme,
13276
13293
  size: "small",
13277
13294
  style: "link",
13278
- onClick: function onClick() {
13279
- return onApplyTheme(theme);
13280
- }
13295
+ onClick: handleApplyTheme
13281
13296
  }), /*#__PURE__*/React__default.createElement(Dropdown, {
13282
13297
  buttonProps: {
13283
13298
  "data-cy": "theme-card-options"
@@ -13316,7 +13331,10 @@ var Themes = function Themes(_ref) {
13316
13331
  onEditTheme = _ref.onEditTheme,
13317
13332
  onApplyTheme = _ref.onApplyTheme,
13318
13333
  previewingTheme = _ref.previewingTheme,
13319
- setPreviewingTheme = _ref.setPreviewingTheme;
13334
+ setPreviewingTheme = _ref.setPreviewingTheme,
13335
+ themeToHighlight = _ref.themeToHighlight,
13336
+ didScrollActiveThemeIntoView = _ref.didScrollActiveThemeIntoView,
13337
+ applyingThemeId = _ref.applyingThemeId;
13320
13338
  var _useTranslation = useTranslation(),
13321
13339
  t = _useTranslation.t;
13322
13340
  var _useState = useState(""),
@@ -13330,6 +13348,13 @@ var Themes = function Themes(_ref) {
13330
13348
  return theme.name.toLowerCase().includes(searchQuery.toLowerCase());
13331
13349
  });
13332
13350
  var isSearchFieldVisible = (customThemes === null || customThemes === void 0 ? void 0 : customThemes.length) + (defaultThemes === null || defaultThemes === void 0 ? void 0 : defaultThemes.length) > 10;
13351
+ useEffect(function () {
13352
+ if (didScrollActiveThemeIntoView.current || !(currentTheme !== null && currentTheme !== void 0 && currentTheme.id)) return;
13353
+ didScrollActiveThemeIntoView.current = true;
13354
+ setTimeout(function () {
13355
+ scrollElementIntoView(currentTheme.id);
13356
+ }, 200);
13357
+ }, [didScrollActiveThemeIntoView, currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id]);
13333
13358
  return /*#__PURE__*/React__default.createElement("div", {
13334
13359
  className: "neeto-molecules-theme-design-sidebar__scroll"
13335
13360
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -13362,6 +13387,7 @@ var Themes = function Themes(_ref) {
13362
13387
  }, filteredDefaultThemes.map(function (theme) {
13363
13388
  return /*#__PURE__*/React__default.createElement(ThemeCard, {
13364
13389
  active: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id,
13390
+ isApplyingTheme: applyingThemeId === theme.id,
13365
13391
  isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
13366
13392
  key: theme.id,
13367
13393
  theme: theme,
@@ -13382,6 +13408,7 @@ var Themes = function Themes(_ref) {
13382
13408
  var isActive = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id;
13383
13409
  return /*#__PURE__*/React__default.createElement(ThemeCard, {
13384
13410
  active: isActive,
13411
+ isHighLightedTheme: theme.id === themeToHighlight,
13385
13412
  isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
13386
13413
  key: theme.id,
13387
13414
  theme: theme,
@@ -13396,7 +13423,7 @@ var Themes = function Themes(_ref) {
13396
13423
 
13397
13424
  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}}
13398
13425
 
13399
- 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))}";
13426
+ 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}";
13400
13427
  n(css,{});
13401
13428
 
13402
13429
  var TitleBar = function TitleBar(_ref) {
@@ -13464,7 +13491,8 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13464
13491
  editTheme = _ref.editTheme,
13465
13492
  applyTheme = _ref.applyTheme,
13466
13493
  currentTheme = _ref.currentTheme,
13467
- isLoadingThemes = _ref.isLoadingThemes;
13494
+ isLoadingThemes = _ref.isLoadingThemes,
13495
+ applyingThemeId = _ref.applyingThemeId;
13468
13496
  var _useTranslation = useTranslation(),
13469
13497
  t = _useTranslation.t;
13470
13498
  var _useState = useState(DESIGN_SCREENS.THEMES),
@@ -13475,6 +13503,11 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13475
13503
  _useState4 = _slicedToArray$2(_useState3, 2),
13476
13504
  previewingTheme = _useState4[0],
13477
13505
  setPreviewingTheme = _useState4[1];
13506
+ var _useState5 = useState(null),
13507
+ _useState6 = _slicedToArray$2(_useState5, 2),
13508
+ themeToHighlight = _useState6[0],
13509
+ setThemeToHighlight = _useState6[1];
13510
+ var didScrollActiveThemeIntoView = useRef(null);
13478
13511
  useEffect(function () {
13479
13512
  isLoadingThemes && setCurrentScreen(DESIGN_SCREENS.LOADING);
13480
13513
  }, [isLoadingThemes]);
@@ -13485,12 +13518,6 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13485
13518
  setPreviewingTheme(theme);
13486
13519
  setCurrentScreen(DESIGN_SCREENS.CUSTOMIZE);
13487
13520
  };
13488
- var handleCloneTheme = function handleCloneTheme(data) {
13489
- var themeToClone = _objectSpread(_objectSpread({}, data), {}, {
13490
- name: "".concat(data.name, " - clone")
13491
- });
13492
- createTheme(themeToClone);
13493
- };
13494
13521
  var handleBackPress = function handleBackPress() {
13495
13522
  setCurrentScreen(DESIGN_SCREENS.THEMES);
13496
13523
  setPreviewingTheme(null);
@@ -13502,10 +13529,30 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13502
13529
  }));
13503
13530
  setCurrentScreen(DESIGN_SCREENS.CUSTOMIZE);
13504
13531
  };
13532
+ var highlightTheme = function highlightTheme(themeToHighlight) {
13533
+ setTimeout(function () {
13534
+ scrollElementIntoView(themeToHighlight.id);
13535
+ }, 1500);
13536
+ setTimeout(function () {
13537
+ setThemeToHighlight(null);
13538
+ }, 4000);
13539
+ setThemeToHighlight(themeToHighlight.id);
13540
+ };
13541
+ var createThemeCallback = function createThemeCallback(createdTheme) {
13542
+ setCurrentScreen(DESIGN_SCREENS.THEMES);
13543
+ setPreviewingTheme(createdTheme.id);
13544
+ highlightTheme(createdTheme);
13545
+ };
13546
+ var handleCloneTheme = function handleCloneTheme(data) {
13547
+ var themeToClone = _objectSpread(_objectSpread({}, data), {}, {
13548
+ name: "".concat(data.name, " - clone")
13549
+ });
13550
+ createTheme(themeToClone, createThemeCallback);
13551
+ };
13505
13552
  var handleFormSubmit = function handleFormSubmit(values) {
13506
13553
  var formattedValues = transformTheme(values);
13507
13554
  if (!(previewingTheme !== null && previewingTheme !== void 0 && previewingTheme.id)) {
13508
- createTheme(formattedValues);
13555
+ createTheme(formattedValues, createThemeCallback);
13509
13556
  } else {
13510
13557
  editTheme(_objectSpread(_objectSpread({}, formattedValues), {}, {
13511
13558
  id: previewingTheme.id
@@ -13522,11 +13569,15 @@ var ThemeSidebar = function ThemeSidebar(_ref) {
13522
13569
  }), currentScreen === DESIGN_SCREENS.LOADING && /*#__PURE__*/React__default.createElement("div", {
13523
13570
  className: "flex h-full w-full items-center justify-center"
13524
13571
  }, /*#__PURE__*/React__default.createElement(Spinner, null)), currentScreen === DESIGN_SCREENS.THEMES && /*#__PURE__*/React__default.createElement(Themes, {
13572
+ applyingThemeId: applyingThemeId,
13525
13573
  currentTheme: currentTheme,
13526
13574
  customThemes: customThemes,
13527
13575
  defaultThemes: defaultThemes,
13576
+ didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
13577
+ highlightTheme: highlightTheme,
13528
13578
  previewingTheme: previewingTheme,
13529
13579
  setPreviewingTheme: setPreviewingTheme,
13580
+ themeToHighlight: themeToHighlight,
13530
13581
  onApplyTheme: applyTheme,
13531
13582
  onCloneTheme: handleCloneTheme,
13532
13583
  onDeleteTheme: deleteTheme,