@ozen-ui/kit 0.84.3 → 0.84.4

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.
@@ -28,6 +28,14 @@
28
28
  }
29
29
  .Menu {
30
30
  overflow: hidden auto;
31
- max-block-size: 40vh;
32
- background-color: transparent;
31
+ max-block-size: var(--menu-max-height);
32
+ background-color: var(--menu-bg-color);
33
33
  }
34
+
35
+ .Menu_color_main {
36
+ --menu-bg-color: var(--color-background-main);
37
+ }
38
+
39
+ .Menu_color_accent {
40
+ --menu-bg-color: var(--color-accent-main);
41
+ }
@@ -6,6 +6,7 @@ require("./Menu.css");
6
6
  var react_1 = tslib_1.__importStar(require("react"));
7
7
  var useDeprecated_1 = require("../../hooks/useDeprecated");
8
8
  var useThemeProps_1 = require("../../hooks/useThemeProps");
9
+ var utils_1 = require("../../utils");
9
10
  var classname_1 = require("../../utils/classname");
10
11
  var getPaperSizeToFormElement_1 = require("../../utils/getPaperSizeToFormElement");
11
12
  var Paper_1 = require("../Paper");
@@ -14,11 +15,26 @@ var components_1 = require("./components");
14
15
  var constants_1 = require("./constants");
15
16
  exports.cnMenu = (0, classname_1.cn)('Menu');
16
17
  exports.Menu = (0, react_1.forwardRef)(function (inProps, ref) {
18
+ var _a;
17
19
  var props = (0, useThemeProps_1.useThemeProps)({ props: inProps, name: 'Menu' });
18
- var _a = props.size, size = _a === void 0 ? constants_1.MENU_DEFAULT_SIZE : _a, open = props.open, menuListProps = props.menuListProps, menuListRef = props.menuListRef, onClose = props.onClose, children = props.children, className = props.className, _b = props.color, color = _b === void 0 ? constants_1.MENU_DEFAULT_COLOR : _b, other = tslib_1.__rest(props, ["size", "open", "menuListProps", "menuListRef", "onClose", "children", "className", "color"]);
20
+ var _b = props.size, size = _b === void 0 ? constants_1.MENU_DEFAULT_SIZE : _b, open = props.open, menuListProps = props.menuListProps, menuListRef = props.menuListRef, onClose = props.onClose, children = props.children, className = props.className, _c = props.color, color = _c === void 0 ? constants_1.MENU_DEFAULT_COLOR : _c, _d = props.maxHeight, maxHeightProp = _d === void 0 ? constants_1.MENU_DEFAULT_MAX_HEIGHT : _d, other = tslib_1.__rest(props, ["size", "open", "menuListProps", "menuListRef", "onClose", "children", "className", "color", "maxHeight"]);
19
21
  var radius = (0, getPaperSizeToFormElement_1.getPaperSizeToFormElement)(size);
20
22
  (0, useDeprecated_1.useDeprecatedProperty)(!!menuListRef, 'menuListRef', 'menuListProps.ref');
21
- return (react_1.default.createElement(Popover_1.Popover, tslib_1.__assign({ as: Paper_1.Paper, offset: [0, 4], radius: radius }, other, { open: open, onClose: onClose, className: (0, exports.cnMenu)('', [className]), disableEnforceFocus: true, ref: ref }),
23
+ var maxHeight = (function () {
24
+ if ((0, utils_1.isString)(maxHeightProp)) {
25
+ return maxHeightProp;
26
+ }
27
+ if ((0, utils_1.isNumber)(maxHeightProp)) {
28
+ return "".concat(maxHeightProp, "px");
29
+ }
30
+ if (maxHeightProp) {
31
+ return constants_1.MENU_DEFAULT_MAX_HEIGHT;
32
+ }
33
+ return 'initial';
34
+ })();
35
+ return (react_1.default.createElement(Popover_1.Popover, tslib_1.__assign({ as: Paper_1.Paper, offset: [0, 4], radius: radius }, other, { style: tslib_1.__assign(tslib_1.__assign({}, other.style), (0, utils_1.generateCSSVariables)((_a = {},
36
+ _a[constants_1.MENU_CSS_VARIABLES.MAX_HEIGHT] = maxHeight,
37
+ _a))), open: open, onClose: onClose, className: (0, exports.cnMenu)({ color: color }, [className]), disableEnforceFocus: true, ref: ref }),
22
38
  react_1.default.createElement(components_1.MenuContextConsumer, { onClose: onClose, menuListRef: menuListRef, menuListProps: tslib_1.__assign(tslib_1.__assign({ size: size, color: color }, menuListProps), { ref: menuListRef || (menuListProps === null || menuListProps === void 0 ? void 0 : menuListProps.ref) }) }, children)));
23
39
  });
24
40
  exports.Menu.displayName = 'Menu';
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MENU_DEFAULT_COLOR = exports.MENU_DEFAULT_SIZE = void 0;
3
+ exports.MENU_CSS_VARIABLES = exports.MENU_DEFAULT_MAX_HEIGHT = exports.MENU_DEFAULT_COLOR = exports.MENU_DEFAULT_SIZE = void 0;
4
4
  exports.MENU_DEFAULT_SIZE = 'm';
5
5
  exports.MENU_DEFAULT_COLOR = 'main';
6
+ exports.MENU_DEFAULT_MAX_HEIGHT = '40vh';
7
+ exports.MENU_CSS_VARIABLES = {
8
+ MAX_HEIGHT: 'menu-max-height',
9
+ };
@@ -28,6 +28,14 @@
28
28
  }
29
29
  .Menu {
30
30
  overflow: hidden auto;
31
- max-block-size: 40vh;
32
- background-color: transparent;
31
+ max-block-size: var(--menu-max-height);
32
+ background-color: var(--menu-bg-color);
33
33
  }
34
+
35
+ .Menu_color_main {
36
+ --menu-bg-color: var(--color-background-main);
37
+ }
38
+
39
+ .Menu_color_accent {
40
+ --menu-bg-color: var(--color-accent-main);
41
+ }
@@ -3,19 +3,35 @@ import './Menu.css';
3
3
  import React, { forwardRef } from 'react';
4
4
  import { useDeprecatedProperty } from '../../hooks/useDeprecated';
5
5
  import { useThemeProps } from '../../hooks/useThemeProps';
6
+ import { generateCSSVariables, isNumber, isString } from '../../utils';
6
7
  import { cn } from '../../utils/classname';
7
8
  import { getPaperSizeToFormElement } from '../../utils/getPaperSizeToFormElement';
8
9
  import { Paper } from '../Paper';
9
10
  import { Popover } from '../Popover';
10
11
  import { MenuContextConsumer } from './components';
11
- import { MENU_DEFAULT_COLOR, MENU_DEFAULT_SIZE } from './constants';
12
+ import { MENU_CSS_VARIABLES, MENU_DEFAULT_COLOR, MENU_DEFAULT_SIZE, MENU_DEFAULT_MAX_HEIGHT, } from './constants';
12
13
  export var cnMenu = cn('Menu');
13
14
  export var Menu = forwardRef(function (inProps, ref) {
15
+ var _a;
14
16
  var props = useThemeProps({ props: inProps, name: 'Menu' });
15
- var _a = props.size, size = _a === void 0 ? MENU_DEFAULT_SIZE : _a, open = props.open, menuListProps = props.menuListProps, menuListRef = props.menuListRef, onClose = props.onClose, children = props.children, className = props.className, _b = props.color, color = _b === void 0 ? MENU_DEFAULT_COLOR : _b, other = __rest(props, ["size", "open", "menuListProps", "menuListRef", "onClose", "children", "className", "color"]);
17
+ var _b = props.size, size = _b === void 0 ? MENU_DEFAULT_SIZE : _b, open = props.open, menuListProps = props.menuListProps, menuListRef = props.menuListRef, onClose = props.onClose, children = props.children, className = props.className, _c = props.color, color = _c === void 0 ? MENU_DEFAULT_COLOR : _c, _d = props.maxHeight, maxHeightProp = _d === void 0 ? MENU_DEFAULT_MAX_HEIGHT : _d, other = __rest(props, ["size", "open", "menuListProps", "menuListRef", "onClose", "children", "className", "color", "maxHeight"]);
16
18
  var radius = getPaperSizeToFormElement(size);
17
19
  useDeprecatedProperty(!!menuListRef, 'menuListRef', 'menuListProps.ref');
18
- return (React.createElement(Popover, __assign({ as: Paper, offset: [0, 4], radius: radius }, other, { open: open, onClose: onClose, className: cnMenu('', [className]), disableEnforceFocus: true, ref: ref }),
20
+ var maxHeight = (function () {
21
+ if (isString(maxHeightProp)) {
22
+ return maxHeightProp;
23
+ }
24
+ if (isNumber(maxHeightProp)) {
25
+ return "".concat(maxHeightProp, "px");
26
+ }
27
+ if (maxHeightProp) {
28
+ return MENU_DEFAULT_MAX_HEIGHT;
29
+ }
30
+ return 'initial';
31
+ })();
32
+ return (React.createElement(Popover, __assign({ as: Paper, offset: [0, 4], radius: radius }, other, { style: __assign(__assign({}, other.style), generateCSSVariables((_a = {},
33
+ _a[MENU_CSS_VARIABLES.MAX_HEIGHT] = maxHeight,
34
+ _a))), open: open, onClose: onClose, className: cnMenu({ color: color }, [className]), disableEnforceFocus: true, ref: ref }),
19
35
  React.createElement(MenuContextConsumer, { onClose: onClose, menuListRef: menuListRef, menuListProps: __assign(__assign({ size: size, color: color }, menuListProps), { ref: menuListRef || (menuListProps === null || menuListProps === void 0 ? void 0 : menuListProps.ref) }) }, children)));
20
36
  });
21
37
  Menu.displayName = 'Menu';
@@ -1,2 +1,6 @@
1
1
  export var MENU_DEFAULT_SIZE = 'm';
2
2
  export var MENU_DEFAULT_COLOR = 'main';
3
+ export var MENU_DEFAULT_MAX_HEIGHT = '40vh';
4
+ export var MENU_CSS_VARIABLES = {
5
+ MAX_HEIGHT: 'menu-max-height',
6
+ };
@@ -1,2 +1,6 @@
1
1
  export declare const MENU_DEFAULT_SIZE = "m";
2
2
  export declare const MENU_DEFAULT_COLOR = "main";
3
+ export declare const MENU_DEFAULT_MAX_HEIGHT = "40vh";
4
+ export declare const MENU_CSS_VARIABLES: {
5
+ MAX_HEIGHT: string;
6
+ };
@@ -4,6 +4,7 @@ import type { PopoverBaseProps } from '../Popover';
4
4
  import type { MenuListProps } from './components';
5
5
  import type { MenuColorVariant, MenuSizeVariant } from './entities';
6
6
  export type MenuRef = ComponentRef<'div'>;
7
+ export type MenuMaxHeight = boolean | number | string;
7
8
  export type MenuProps = ExtendableComponentPropsWithRef<{
8
9
  /** Свойства компонента MenuList */
9
10
  menuListProps?: Omit<MenuListProps, 'children'>;
@@ -16,4 +17,6 @@ export type MenuProps = ExtendableComponentPropsWithRef<{
16
17
  size?: MenuSizeVariant;
17
18
  /** Цвет компонента */
18
19
  color?: MenuColorVariant;
20
+ /** Свойство максимальной высоты меню */
21
+ maxHeight?: MenuMaxHeight;
19
22
  } & Omit<PopoverBaseProps, 'disableEnforceFocus'>, 'div'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozen-ui/kit",
3
- "version": "0.84.3",
3
+ "version": "0.84.4",
4
4
  "description": "React component library",
5
5
  "files": [
6
6
  "*"
@@ -29,9 +29,9 @@
29
29
  "react-popper": "^2.3.0",
30
30
  "react-transition-group": "^4.4.5",
31
31
  "tslib": "^2.6.3",
32
- "@ozen-ui/logger": "0.84.3",
33
- "@ozen-ui/fonts": "0.84.3",
34
- "@ozen-ui/icons": "0.84.3"
32
+ "@ozen-ui/fonts": "0.84.4",
33
+ "@ozen-ui/logger": "0.84.4",
34
+ "@ozen-ui/icons": "0.84.4"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/lodash.isequal": "^4.5.0"