@bigbinary/neeto-themes-frontend 4.0.19 → 4.0.21

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.
Files changed (45) hide show
  1. package/app/javascript/src/translations/ar.json +4 -1
  2. package/app/javascript/src/translations/bg.json +4 -1
  3. package/app/javascript/src/translations/ca.json +4 -1
  4. package/app/javascript/src/translations/cs.json +4 -1
  5. package/app/javascript/src/translations/da.json +4 -1
  6. package/app/javascript/src/translations/de.json +4 -1
  7. package/app/javascript/src/translations/es-MX.json +4 -1
  8. package/app/javascript/src/translations/es.json +4 -1
  9. package/app/javascript/src/translations/et.json +4 -1
  10. package/app/javascript/src/translations/fi.json +4 -1
  11. package/app/javascript/src/translations/fil.json +4 -1
  12. package/app/javascript/src/translations/fr.json +4 -1
  13. package/app/javascript/src/translations/he.json +4 -1
  14. package/app/javascript/src/translations/hi.json +4 -1
  15. package/app/javascript/src/translations/hr.json +4 -1
  16. package/app/javascript/src/translations/hu.json +4 -1
  17. package/app/javascript/src/translations/id.json +4 -1
  18. package/app/javascript/src/translations/it.json +4 -1
  19. package/app/javascript/src/translations/ja.json +4 -1
  20. package/app/javascript/src/translations/ko.json +4 -1
  21. package/app/javascript/src/translations/nl.json +4 -1
  22. package/app/javascript/src/translations/pl.json +4 -1
  23. package/app/javascript/src/translations/pt-BR.json +4 -1
  24. package/app/javascript/src/translations/pt.json +4 -1
  25. package/app/javascript/src/translations/ro.json +4 -1
  26. package/app/javascript/src/translations/ru.json +4 -1
  27. package/app/javascript/src/translations/sk.json +4 -1
  28. package/app/javascript/src/translations/sl.json +4 -1
  29. package/app/javascript/src/translations/sv.json +4 -1
  30. package/app/javascript/src/translations/th.json +4 -1
  31. package/app/javascript/src/translations/tr.json +4 -1
  32. package/app/javascript/src/translations/uk.json +4 -1
  33. package/app/javascript/src/translations/vi.json +4 -1
  34. package/app/javascript/src/translations/zh-CN.json +4 -1
  35. package/app/javascript/src/translations/zh-TW.json +4 -1
  36. package/dist/.ready +1 -1
  37. package/dist/NeetoThemesBuilder.js +53 -19
  38. package/dist/NeetoThemesBuilder.js.map +1 -1
  39. package/dist/cjs/NeetoThemesBuilder.js +52 -18
  40. package/dist/cjs/NeetoThemesBuilder.js.map +1 -1
  41. package/dist/cjs/index.js +1 -0
  42. package/dist/cjs/index.js.map +1 -1
  43. package/dist/index.js +1 -0
  44. package/dist/index.js.map +1 -1
  45. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  import { shallow } from 'zustand/shallow';
2
2
  import { Suspense, lazy, useEffect, createElement, useState, useRef, memo, useCallback } from 'react';
3
- import { isPresent, hyphenate, findBy, findIndexBy, isNot, filterBy, snakeToCamelCase, isNotPresent, toLabelAndValue, humanize, capitalize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
3
+ import { isPresent, hyphenate, findBy, findIndexBy, isNot, filterBy, snakeToCamelCase, isNotPresent, toLabelAndValue, capitalize, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
4
4
  import { useMutationWithInvalidation, useQueryParams, useBreakpoints, PageTitle } from '@bigbinary/neeto-commons-frontend/react-utils';
5
5
  import Spinner from '@bigbinary/neetoui/Spinner';
6
6
  import { useTranslation, Trans } from 'react-i18next';
@@ -39,6 +39,7 @@ import LeftAlign from '@bigbinary/neeto-icons/LeftAlign';
39
39
  import ColorPicker from '@bigbinary/neetoui/ColorPicker';
40
40
  import Select from '@bigbinary/neetoui/Select';
41
41
  import { Slider } from 'antd';
42
+ import Checkbox from '@bigbinary/neetoui/Checkbox';
42
43
  import Input from '@bigbinary/neetoui/Input';
43
44
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
44
45
  import _regeneratorRuntime from '@babel/runtime/regenerator';
@@ -555,6 +556,19 @@ var LogoPosition = function LogoPosition() {
555
556
 
556
557
  function ownKeys$3(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; }
557
558
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
559
+
560
+ // Capitalizes the first letter of the displayed label while keeping the
561
+ // underlying value untouched (position values like "top left" are used
562
+ // verbatim as CSS background-position, so they must stay lowercase).
563
+ var toCapitalizedOption = function toCapitalizedOption(value) {
564
+ var _toLabelAndValue = toLabelAndValue(value),
565
+ label = _toLabelAndValue.label,
566
+ optionValue = _toLabelAndValue.value;
567
+ return {
568
+ label: label ? capitalize(label) : label,
569
+ value: optionValue
570
+ };
571
+ };
558
572
  var buildInitialValues = function buildInitialValues(theme, themePropertiesSchema) {
559
573
  if (isPresent(theme)) return theme;
560
574
  return {
@@ -869,20 +883,17 @@ var SelectBlock = function SelectBlock(_ref) {
869
883
  options = _ref.options,
870
884
  onChange = _ref.onChange;
871
885
  return /*#__PURE__*/jsxs("div", {
872
- className: "flex items-center justify-between",
886
+ className: "neeto-ui-border-gray-200 flex flex-col gap-2 border-t pt-3",
873
887
  "data-testid": "theme-style-".concat(joinHyphenCase(label)),
874
888
  children: [/*#__PURE__*/jsx(Typography, {
875
889
  "data-testid": "logo-field-labels",
876
890
  style: "body2",
877
891
  children: label
878
- }), /*#__PURE__*/jsx("div", {
879
- className: "w-40",
880
- children: /*#__PURE__*/jsx(Select, {
881
- onChange: onChange,
882
- options: options,
883
- placeholder: placeholder,
884
- value: value
885
- })
892
+ }), /*#__PURE__*/jsx(Select, {
893
+ onChange: onChange,
894
+ options: options,
895
+ placeholder: placeholder,
896
+ value: value
886
897
  })]
887
898
  });
888
899
  };
@@ -915,18 +926,35 @@ var SliderBlock = function SliderBlock(_ref) {
915
926
  });
916
927
  };
917
928
 
918
- var _excluded = ["label", "name"];
929
+ var _excluded = ["label", "name", "asCheckbox"];
919
930
  function ownKeys$1(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; }
920
931
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
921
932
  var SwitchBlock = function SwitchBlock(_ref) {
922
933
  var label = _ref.label,
923
934
  name = _ref.name,
924
- switchProps = _objectWithoutProperties(_ref, _excluded);
935
+ _ref$asCheckbox = _ref.asCheckbox,
936
+ asCheckbox = _ref$asCheckbox === void 0 ? false : _ref$asCheckbox,
937
+ inputProps = _objectWithoutProperties(_ref, _excluded);
925
938
  var _useTranslation = useTranslation(),
926
939
  t = _useTranslation.t,
927
940
  i18n = _useTranslation.i18n;
928
941
  var translationKey = "neetoThemes.properties.boolean.".concat(name, "HelpText");
929
942
  var doesHelpTextExist = i18n.exists(translationKey);
943
+ if (asCheckbox) {
944
+ return /*#__PURE__*/jsxs("div", {
945
+ className: "flex items-center gap-2",
946
+ "data-testid": "theme-style-content-background",
947
+ children: [/*#__PURE__*/jsx(Checkbox, _objectSpread$1(_objectSpread$1({}, _objectSpread$1({
948
+ label: label,
949
+ name: name
950
+ }, inputProps)), {}, {
951
+ "data-testid": "enable-background-color-toggle"
952
+ })), doesHelpTextExist && /*#__PURE__*/jsx(HelpPopover, {
953
+ className: "shrink-0",
954
+ description: t(translationKey)
955
+ })]
956
+ });
957
+ }
930
958
  return /*#__PURE__*/jsxs("div", {
931
959
  className: "flex items-center justify-between",
932
960
  "data-testid": "theme-style-content-background",
@@ -946,7 +974,7 @@ var SwitchBlock = function SwitchBlock(_ref) {
946
974
  })]
947
975
  }), /*#__PURE__*/jsx(Switch, _objectSpread$1(_objectSpread$1({}, _objectSpread$1({
948
976
  name: name
949
- }, switchProps)), {}, {
977
+ }, inputProps)), {}, {
950
978
  "data-testid": "enable-background-color-toggle"
951
979
  }))]
952
980
  });
@@ -1076,15 +1104,16 @@ var Properties = function Properties(_ref) {
1076
1104
  key: key
1077
1105
  }, values.properties);
1078
1106
  var error = errors === null || errors === void 0 || (_errors$properties = errors.properties) === null || _errors$properties === void 0 || (_errors$properties = _errors$properties[index]) === null || _errors$properties === void 0 ? void 0 : _errors$properties.value;
1079
- return /*#__PURE__*/jsx(TextBlock, {
1107
+ return /*#__PURE__*/createElement(TextBlock, {
1080
1108
  error: error,
1109
+ key: key,
1081
1110
  label: buildLabel(key, kind),
1082
1111
  name: "properties[".concat(index, "].value"),
1083
1112
  value: value || "",
1084
1113
  onChange: function onChange(e) {
1085
1114
  return setFieldValue("properties[".concat(index, "].value"), e.target.value);
1086
1115
  }
1087
- }, key);
1116
+ });
1088
1117
  }
1089
1118
  case "font_family":
1090
1119
  return /*#__PURE__*/jsx(FontPickerBlock, {
@@ -1136,12 +1165,12 @@ var Properties = function Properties(_ref) {
1136
1165
  }, values.properties);
1137
1166
  var options = (_findBy4 = findBy({
1138
1167
  key: key
1139
- }, themePropertiesSchema)) === null || _findBy4 === void 0 || (_findBy4 = _findBy4.options) === null || _findBy4 === void 0 ? void 0 : _findBy4.map(toLabelAndValue);
1168
+ }, themePropertiesSchema)) === null || _findBy4 === void 0 || (_findBy4 = _findBy4.options) === null || _findBy4 === void 0 ? void 0 : _findBy4.map(toCapitalizedOption);
1140
1169
  return /*#__PURE__*/jsx(SelectBlock, {
1141
1170
  label: buildLabel(key, kind),
1142
1171
  options: options || POSITION_OPTIONS,
1143
1172
  placeholder: "left",
1144
- value: toLabelAndValue(value),
1173
+ value: toCapitalizedOption(value),
1145
1174
  onChange: function onChange(option) {
1146
1175
  return setFieldValue("properties[".concat(_index, "].value"), option.value);
1147
1176
  }
@@ -1149,10 +1178,15 @@ var Properties = function Properties(_ref) {
1149
1178
  }
1150
1179
  case "boolean":
1151
1180
  {
1181
+ var _findBy5;
1152
1182
  var _index2 = findIndexBy({
1153
1183
  key: key
1154
1184
  }, values.properties);
1185
+ var renderAsCheckbox = ((_findBy5 = findBy({
1186
+ key: key
1187
+ }, themePropertiesSchema)) === null || _findBy5 === void 0 ? void 0 : _findBy5.renderAsCheckbox) || false;
1155
1188
  return /*#__PURE__*/jsx(SwitchBlock, {
1189
+ asCheckbox: renderAsCheckbox,
1156
1190
  checked: value !== "false",
1157
1191
  label: buildLabel(key, kind),
1158
1192
  name: snakeToCamelCase(key),
@@ -1279,9 +1313,9 @@ var ImageBlock = function ImageBlock(_ref) {
1279
1313
  onUploadComplete: handleImageChange
1280
1314
  }), isPositionChangerVisible && /*#__PURE__*/jsx(SelectBlock, {
1281
1315
  label: buildLabel("".concat(name, "Position"), "image"),
1282
- options: options || POSITION_OPTIONS,
1316
+ options: (options === null || options === void 0 ? void 0 : options.map(toCapitalizedOption)) || POSITION_OPTIONS,
1283
1317
  placeholder: t("neetoThemes.common.left"),
1284
- value: toLabelAndValue(((_findBy = findBy({
1318
+ value: toCapitalizedOption(((_findBy = findBy({
1285
1319
  key: "".concat(name, "_position")
1286
1320
  }, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) || (positionKeyInSchema === null || positionKeyInSchema === void 0 ? void 0 : positionKeyInSchema.defaultValue)),
1287
1321
  onChange: function onChange(option) {