@skbkontur/side-menu 0.14.7 → 0.14.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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.14.8](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.14.7...@skbkontur/side-menu@0.14.8) (2023-07-25)
7
+
8
+ **Note:** Version bump only for package @skbkontur/side-menu
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.14.7](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/side-menu@0.14.6...@skbkontur/side-menu@0.14.7) (2023-07-24)
7
15
 
8
16
  **Note:** Version bump only for package @skbkontur/side-menu
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skbkontur/side-menu",
3
- "version": "0.14.7",
3
+ "version": "0.14.8",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -7,6 +7,24 @@ import { Burger } from './Burger';
7
7
  import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
8
8
  import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
9
9
  import { ThemeContext } from '@skbkontur/react-ui';
10
+ var changeCamelCaseToKebabCase = function (str) {
11
+ return str
12
+ .split('')
13
+ .map(function (letter, idx) {
14
+ return letter.toUpperCase() === letter ? "" + (idx !== 0 ? '-' : '') + letter.toLowerCase() : letter;
15
+ })
16
+ .join('');
17
+ };
18
+ var getProductName = function (productLogo) {
19
+ var _a;
20
+ // @ts-expect-error: accessing private property
21
+ return ((_a = productLogo === null || productLogo === void 0 ? void 0 : productLogo.type) === null || _a === void 0 ? void 0 : _a.__KONTUR_REACT_UI__) ? // @ts-expect-error: accessing private property
22
+ changeCamelCaseToKebabCase(productLogo.type.__KONTUR_REACT_UI__.replace(/EN$/i, ''))
23
+ : 'kontur';
24
+ };
25
+ var getStaticIconPath = function (productName) {
26
+ return "https://s.kontur.ru/common-v2/icons-products/" + productName + "/" + productName + "-" + parseInt(sideMenuLogotypeIconSize) + ".svg";
27
+ };
10
28
  /**
11
29
  * Логотип
12
30
  *
@@ -17,8 +35,10 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
17
35
  var productLogo = _a.productLogo, withWidget = _a.withWidget, konturLogo = _a.konturLogo, iconUrl = _a.iconUrl, rest = __rest(_a, ["productLogo", "withWidget", "konturLogo", "iconUrl"]);
18
36
  var context = useContext(SideMenuContext);
19
37
  var theme = getSideMenuTheme(useContext(ThemeContext));
38
+ var productName = getProductName(productLogo);
20
39
  var refLogotype = useRef(null);
21
40
  var _d = useState(28), size = _d[0], setSize = _d[1];
41
+ var _e = useState(getStaticIconPath(productName)), productIconUrl = _e[0], setProductIconUrl = _e[1];
22
42
  useEffect(function () {
23
43
  var _a, _b;
24
44
  var logotypeWidth = (_b = (_a = refLogotype.current) === null || _a === void 0 ? void 0 : _a.logotypeRef) === null || _b === void 0 ? void 0 : _b.clientWidth;
@@ -29,25 +49,6 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
29
49
  setSize(24);
30
50
  }
31
51
  }, []);
32
- var changeCamelCaseToKebabCase = function (str) {
33
- return str
34
- .split('')
35
- .map(function (letter, idx) {
36
- return letter.toUpperCase() === letter ? "" + (idx !== 0 ? '-' : '') + letter.toLowerCase() : letter;
37
- })
38
- .join('');
39
- };
40
- var getProductName = function () {
41
- var _a;
42
- // @ts-expect-error: accessing private property
43
- return ((_a = productLogo === null || productLogo === void 0 ? void 0 : productLogo.type) === null || _a === void 0 ? void 0 : _a.__KONTUR_REACT_UI__) ? // @ts-expect-error: accessing private property
44
- changeCamelCaseToKebabCase(productLogo.type.__KONTUR_REACT_UI__)
45
- : 'kontur';
46
- };
47
- var productName = getProductName();
48
- var getStaticIconPath = function () {
49
- return "https://s.kontur.ru/common-v2/icons-products/" + productName + "/" + productName + "-" + parseInt(sideMenuLogotypeIconSize) + ".svg";
50
- };
51
52
  var getWidget = function (withWidget, isTouchScreen, isMinimizedInNarrowDesktop, showWidget) {
52
53
  if (withWidget !== undefined) {
53
54
  return withWidget;
@@ -60,11 +61,14 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
60
61
  }
61
62
  return showWidget;
62
63
  };
64
+ var handleError = function () {
65
+ setProductIconUrl(getStaticIconPath('kontur'));
66
+ };
63
67
  return (React.createElement("div", { className: jsStyles.root(), ref: ref },
64
68
  !context.isMobile && !context.isTablet && (React.createElement("img", { className: cx((_b = {},
65
69
  _b[jsStyles.iconHidden(theme)] = true,
66
70
  _b[jsStyles.icon()] = context.isMinimized,
67
- _b)), src: iconUrl || getStaticIconPath(), alt: productName })),
71
+ _b)), src: iconUrl || productIconUrl, alt: productName, onError: handleError })),
68
72
  React.createElement("div", { className: cx((_c = {},
69
73
  _c[jsStyles.logoWrapper(theme)] = true,
70
74
  _c[jsStyles.logoWrapperForTabletsOrMobiles(theme)] = context.isMobile || context.isTablet,