@bigbinary/neeto-themes-frontend 2.0.6 → 2.0.8

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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { shallow } from 'zustand/shallow';
2
2
  import { useEffect, createElement, useState, useRef, memo, useCallback } from 'react';
3
3
  import { t as t$1 } from 'i18next';
4
- import { isNotPresent, snakeToCamelCase, filterBy, isPresent, isNot, findBy, findIndexBy, toLabelAndValue, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
4
+ import { isNotPresent, snakeToCamelCase, filterBy, findBy, isPresent, isNot, findIndexBy, toLabelAndValue, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
5
5
  import { withImmutableActions, useMutationWithInvalidation, withT, withTitle } from '@bigbinary/neeto-commons-frontend/react-utils';
6
6
  import Spinner from '@bigbinary/neetoui/Spinner';
7
7
  import { useQuery } from '@tanstack/react-query';
@@ -162,10 +162,35 @@ var setVariable = function setVariable(name, value, variableNamesMap) {
162
162
  if (!variableName) return;
163
163
  root.style.setProperty(variableName, value);
164
164
  };
165
+ var isPropertyIndependent = function isPropertyIndependent(key, theme, schema) {
166
+ var property = findBy({
167
+ key: key
168
+ }, schema);
169
+ if (isNotPresent(property)) return false;
170
+ var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
171
+ if (isNotPresent(conditionalKey)) return true;
172
+ var dependentPropertySchema = findBy({
173
+ key: conditionalKey
174
+ }, schema);
175
+ var dependentProperty = findBy({
176
+ key: conditionalKey
177
+ }, theme.properties);
178
+ if (dependentPropertySchema.kind === "image") {
179
+ var _theme$snakeToCamelCa;
180
+ return isPresent((_theme$snakeToCamelCa = theme[snakeToCamelCase(conditionalKey)]) === null || _theme$snakeToCamelCa === void 0 ? void 0 : _theme$snakeToCamelCa.url);
181
+ } else if (dependentPropertySchema.kind === "boolean") {
182
+ return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
183
+ }
184
+ return isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
185
+ };
165
186
  var setTheme = function setTheme(theme, variableNamesMap, themeConfig) {
166
187
  if (isNotPresent(theme === null || theme === void 0 ? void 0 : theme.properties)) return;
167
188
  theme.properties.forEach(function (property) {
168
189
  var attribute = snakeToCamelCase(property.key);
190
+ if (!isPropertyIndependent(property.key, theme, themeConfig)) {
191
+ setVariable(attribute, "", variableNamesMap);
192
+ return;
193
+ }
169
194
  if (property.kind === "color") {
170
195
  setVariable(attribute, hexToRgba(property.value), variableNamesMap);
171
196
  } else if (property.kind === "overlay_opacity") {
@@ -1915,15 +1940,17 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
1915
1940
  useEffect(function () {
1916
1941
  if (isNotPresent(currentTheme)) return;
1917
1942
  setThemeState({
1918
- currentTheme: currentTheme,
1919
- isCurrentThemeLoading: isCurrentThemeLoading,
1920
1943
  previewingTheme: currentTheme
1921
1944
  });
1922
- }, [currentTheme, isCurrentThemeLoading]);
1945
+ setTheme(currentTheme);
1946
+ }, [isLoading, entityId]);
1923
1947
  useEffect(function () {
1924
1948
  if (isNotPresent(currentTheme)) return;
1925
- setTheme(currentTheme);
1926
- }, [currentTheme, entityId]);
1949
+ setThemeState({
1950
+ currentTheme: currentTheme,
1951
+ isCurrentThemeLoading: isCurrentThemeLoading
1952
+ });
1953
+ }, [currentTheme, isCurrentThemeLoading]);
1927
1954
  return /*#__PURE__*/jsxs("div", {
1928
1955
  className: "neeto-themes__wrapper",
1929
1956
  children: [/*#__PURE__*/jsx(Sidebar, {