@bigbinary/neeto-themes-frontend 1.1.17 → 1.1.19

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
@@ -5,7 +5,7 @@ import i18next, { t as t$6 } from 'i18next';
5
5
  import { withImmutableActions, useMutationWithInvalidation, useDebounce, useFuncDebounce, withT, withTitle } from '@bigbinary/neeto-commons-frontend/react-utils';
6
6
  import Spinner$1 from '@bigbinary/neetoui/Spinner';
7
7
  import { create as create$3 } from 'zustand';
8
- import { isNotPresent, snakeToCamelCase, filterBy, noop as noop$3, isPresent, findBy, keysToCamelCase, humanize, isNot, findIndexBy, isNotEmpty } from '@bigbinary/neeto-cist';
8
+ import { isNotPresent, snakeToCamelCase, filterBy, isPresent, isNot, findBy, noop as noop$3, keysToCamelCase, findIndexBy, humanize, isNotEmpty } from '@bigbinary/neeto-cist';
9
9
  import Alert from '@bigbinary/neetoui/Alert';
10
10
  import { useTranslation, Trans } from 'react-i18next';
11
11
  import '@bigbinary/neetoui/Toastr';
@@ -768,6 +768,84 @@ var OVERLAY_OPACITY_SLIDER_MARKS = {
768
768
  };
769
769
  var HUNDRED = 100;
770
770
 
771
+ var buildInitialValues = function buildInitialValues(theme, themeConfig) {
772
+ if (isPresent(theme)) return theme;
773
+ return {
774
+ name: t$6("neetoThemes.build.leftSideBar.themes.createTheme.newThemeName"),
775
+ properties: themeConfig.map(function (_ref) {
776
+ var key = _ref.key,
777
+ kind = _ref.kind,
778
+ defaultValue = _ref.defaultValue;
779
+ switch (kind) {
780
+ case "color":
781
+ return {
782
+ value: defaultValue,
783
+ kind: "color",
784
+ key: key
785
+ };
786
+ case "font_family":
787
+ return {
788
+ value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
789
+ kind: "font_family",
790
+ key: key
791
+ };
792
+ case "overlay_opacity":
793
+ return {
794
+ value: 0,
795
+ kind: "overlay_opacity",
796
+ key: key
797
+ };
798
+ case "slider":
799
+ return {
800
+ value: 0,
801
+ kind: "slider",
802
+ key: key
803
+ };
804
+ case "boolean":
805
+ return {
806
+ value: false,
807
+ kind: "boolean",
808
+ key: key
809
+ };
810
+ default:
811
+ return null;
812
+ }
813
+ }).filter(isNot(null))
814
+ };
815
+ };
816
+ var buildImageData = function buildImageData(values, themeConfig) {
817
+ return filterBy({
818
+ kind: "image"
819
+ }, themeConfig).reduce(function (acc, item) {
820
+ var _values$snakeToCamelC;
821
+ var signedId = (_values$snakeToCamelC = values[snakeToCamelCase(item.key)]) === null || _values$snakeToCamelC === void 0 ? void 0 : _values$snakeToCamelC.signedId;
822
+ acc[item.key] = signedId;
823
+ return acc;
824
+ }, {});
825
+ };
826
+ var isPropertyVisible = function isPropertyVisible(key, formikValues, themeConfig) {
827
+ var _findBy;
828
+ var property = findBy({
829
+ key: key
830
+ }, themeConfig);
831
+ if (isNotPresent(property)) return false;
832
+ var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
833
+ if (isNotPresent(conditionalKey)) return true;
834
+ var dependentProperty = findBy({
835
+ key: conditionalKey
836
+ }, themeConfig);
837
+ if (dependentProperty.kind === "image") {
838
+ var _formikValues$snakeTo;
839
+ return isPresent((_formikValues$snakeTo = formikValues[snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
840
+ }
841
+ return isPresent((_findBy = findBy({
842
+ key: conditionalKey
843
+ }, formikValues.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value);
844
+ };
845
+ var buildLabel = function buildLabel(key, kind) {
846
+ return t$6("neetoThemes.properties.".concat(snakeToCamelCase(kind), ".").concat(snakeToCamelCase(key)));
847
+ };
848
+
771
849
  var Card$2 = function Card(_ref) {
772
850
  var _ref$title = _ref.title,
773
851
  title = _ref$title === void 0 ? "" : _ref$title,
@@ -6954,7 +7032,7 @@ var Images = function Images(_ref) {
6954
7032
  var _useFormikContext = useFormikContext(),
6955
7033
  values = _useFormikContext.values;
6956
7034
  var key = snakeToCamelCase(attribute);
6957
- var title = humanize(key);
7035
+ var title = buildLabel(key, "image");
6958
7036
  var imageData = values[key];
6959
7037
  return /*#__PURE__*/jsx(Card$2, {
6960
7038
  title: title,
@@ -6968,84 +7046,6 @@ var Images = function Images(_ref) {
6968
7046
  });
6969
7047
  };
6970
7048
 
6971
- var buildInitialValues = function buildInitialValues(theme, themeConfig) {
6972
- if (isPresent(theme)) return theme;
6973
- return {
6974
- name: t$6("neetoThemes.build.leftSideBar.themes.createTheme.newThemeName"),
6975
- properties: themeConfig.map(function (_ref) {
6976
- var key = _ref.key,
6977
- kind = _ref.kind,
6978
- defaultValue = _ref.defaultValue;
6979
- switch (kind) {
6980
- case "color":
6981
- return {
6982
- value: defaultValue,
6983
- kind: "color",
6984
- key: key
6985
- };
6986
- case "font_family":
6987
- return {
6988
- value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
6989
- kind: "font_family",
6990
- key: key
6991
- };
6992
- case "overlay_opacity":
6993
- return {
6994
- value: 0,
6995
- kind: "overlay_opacity",
6996
- key: key
6997
- };
6998
- case "slider":
6999
- return {
7000
- value: 0,
7001
- kind: "slider",
7002
- key: key
7003
- };
7004
- case "boolean":
7005
- return {
7006
- value: false,
7007
- kind: "boolean",
7008
- key: key
7009
- };
7010
- default:
7011
- return null;
7012
- }
7013
- }).filter(isNot(null))
7014
- };
7015
- };
7016
- var buildImageData = function buildImageData(values, themeConfig) {
7017
- return filterBy({
7018
- kind: "image"
7019
- }, themeConfig).reduce(function (acc, item) {
7020
- var _values$snakeToCamelC;
7021
- var signedId = (_values$snakeToCamelC = values[snakeToCamelCase(item.key)]) === null || _values$snakeToCamelC === void 0 ? void 0 : _values$snakeToCamelC.signedId;
7022
- acc[item.key] = signedId;
7023
- return acc;
7024
- }, {});
7025
- };
7026
- var isPropertyVisible = function isPropertyVisible(key, formikValues, themeConfig) {
7027
- var _findBy;
7028
- var property = findBy({
7029
- key: key
7030
- }, themeConfig);
7031
- if (isNotPresent(property)) return false;
7032
- var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
7033
- if (isNotPresent(conditionalKey)) return true;
7034
- var dependentProperty = findBy({
7035
- key: conditionalKey
7036
- }, themeConfig);
7037
- if (dependentProperty.kind === "image") {
7038
- var _formikValues$snakeTo;
7039
- return isPresent((_formikValues$snakeTo = formikValues[snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
7040
- }
7041
- return isPresent((_findBy = findBy({
7042
- key: conditionalKey
7043
- }, formikValues.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value);
7044
- };
7045
- var buildLabel = function buildLabel(key, kind) {
7046
- return t$6("neetoThemes.properties.".concat(snakeToCamelCase(kind), ".").concat(snakeToCamelCase(key)));
7047
- };
7048
-
7049
7049
  var ColorBlock = function ColorBlock(_ref) {
7050
7050
  var label = _ref.label,
7051
7051
  _ref$color = _ref.color,