@sima-land/moleculas 13.2.2 → 13.4.0

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.
@@ -3,13 +3,11 @@ export interface BadgeField {
3
3
  type: 'text' | 'timer' | 'svg-url';
4
4
  value: string;
5
5
  }
6
- export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
6
+ export interface BadgeProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'color'> {
7
7
  /** Основной цвет, используется как цвет обводки, иконок и текста. */
8
8
  color?: string;
9
9
  /** Содержимое шильдика. */
10
10
  fields: Array<BadgeField>;
11
- /** Ссылка, переход по которой будет произведён по нажатию на шильдик. */
12
- href?: string;
13
11
  /** Идентификатор для систем автоматизированного тестирования. */
14
12
  'data-testid'?: string;
15
13
  }
@@ -30,9 +30,8 @@ const cx = bind_1.default.bind(badge_module_scss_1.default);
30
30
  */
31
31
  const Badge = (_a) => {
32
32
  var { className, color, fields, href, style, 'data-testid': testId = 'badge' } = _a, restProps = __rest(_a, ["className", "color", "fields", "href", "style", 'data-testid']);
33
- const Element = href ? 'a' : 'span';
34
33
  const iconOnly = fields.length === 1 && fields[0].type === 'svg-url';
35
- return (react_1.default.createElement(Element, Object.assign({}, restProps, { "data-testid": testId, href: href, style: Object.assign(Object.assign({}, style), { '--badge-color': color }), className: cx('root', iconOnly && 'icon-only', href && 'interactive', className), children: iconOnly ? (react_1.default.createElement("img", { className: cx('icon'), src: fields[0].value })) : (
34
+ return (react_1.default.createElement("a", Object.assign({}, restProps, { "data-testid": testId, href: href, style: Object.assign(Object.assign({}, style), { '--badge-color': color }), className: cx('root', iconOnly && 'icon-only', href && 'interactive', className), children: iconOnly ? (react_1.default.createElement("img", { className: cx('icon'), src: fields[0].value })) : (
36
35
  // вложенный span нужен для того чтобы объединить `display: inline-flex` и `text-overflow: ellipsis`
37
36
  react_1.default.createElement("span", { className: cx('content') }, fields.reduce((acc, item, i) => {
38
37
  let result = null;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ export interface InteractiveImageProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ children?: React.ReactNode;
4
+ 'data-testid'?: string;
5
+ }
6
+ export interface InteractiveImageImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
7
+ 'data-testid'?: string;
8
+ }
9
+ export interface InteractiveImagePointProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
10
+ x: number;
11
+ y: number;
12
+ 'data-testid'?: string;
13
+ }
14
+ export declare const InteractiveImage: ({ children, "data-testid": testId, className, ...rest }: InteractiveImageProps) => JSX.Element;
15
+ export declare const Parts: {
16
+ readonly Image: React.ForwardRefExoticComponent<InteractiveImageImageProps & React.RefAttributes<HTMLImageElement>>;
17
+ readonly Point: React.ForwardRefExoticComponent<InteractiveImagePointProps & React.RefAttributes<HTMLAnchorElement>>;
18
+ };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __rest = (this && this.__rest) || function (s, e) {
22
+ var t = {};
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
+ t[p] = s[p];
25
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
+ t[p[i]] = s[p[i]];
29
+ }
30
+ return t;
31
+ };
32
+ var __importDefault = (this && this.__importDefault) || function (mod) {
33
+ return (mod && mod.__esModule) ? mod : { "default": mod };
34
+ };
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Parts = exports.InteractiveImage = void 0;
37
+ const react_1 = __importStar(require("react"));
38
+ const classnames_1 = __importDefault(require("classnames"));
39
+ const interactive_image_module_scss_1 = __importDefault(require("./interactive-image.module.scss"));
40
+ const InteractiveImage = (_a) => {
41
+ var { children, 'data-testid': testId, className } = _a, rest = __rest(_a, ["children", 'data-testid', "className"]);
42
+ return (react_1.default.createElement("div", Object.assign({ className: (0, classnames_1.default)(interactive_image_module_scss_1.default.root, className) }, rest, { "data-testid": testId }), react_1.Children.toArray(children).filter(child => (0, react_1.isValidElement)(child) && (child.type === Image || child.type === Point))));
43
+ };
44
+ exports.InteractiveImage = InteractiveImage;
45
+ const Image = (0, react_1.forwardRef)((_a, ref) => {
46
+ var { className, 'data-testid': testId = 'interactive-image:image' } = _a, rest = __rest(_a, ["className", 'data-testid']);
47
+ return (react_1.default.createElement("img", Object.assign({ ref: ref, className: (0, classnames_1.default)(interactive_image_module_scss_1.default.image, className), "data-testid": testId }, rest)));
48
+ });
49
+ const Point = (0, react_1.forwardRef)((_a, ref) => {
50
+ var { x, y, className, style, 'data-testid': testId = 'interactive-image:point' } = _a, rest = __rest(_a, ["x", "y", "className", "style", 'data-testid']);
51
+ return (react_1.default.createElement("a", Object.assign({ ref: ref, "aria-label": '\u0422\u043E\u0447\u043A\u0430 \u043D\u0430 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0438', "data-testid": testId, className: (0, classnames_1.default)(interactive_image_module_scss_1.default.point, className), style: Object.assign(Object.assign({}, style), { top: `${y}%`, left: `${x}%` }) }, rest)));
52
+ });
53
+ exports.Parts = { Image, Point };
@@ -0,0 +1,50 @@
1
+ @use 'node_modules/@sima-land/ui-nucleons/colors';
2
+ @use 'node_modules/@sima-land/ui-nucleons/breakpoints';
3
+
4
+ .root {
5
+ display: inline-block;
6
+ font-size: 0;
7
+ position: relative;
8
+ overflow: hidden;
9
+ background: colors.$basic-gray4;
10
+ }
11
+
12
+ .image {
13
+ display: block;
14
+ max-width: 100%;
15
+ max-height: 100%;
16
+ min-width: 100%;
17
+ min-height: 100%;
18
+ }
19
+
20
+ .point {
21
+ position: absolute;
22
+ display: flex;
23
+ justify-content: center;
24
+ align-items: center;
25
+ width: 64px;
26
+ height: 64px;
27
+ background: rgba(colors.$basic-gray87, 0.4);
28
+ border-radius: 50%;
29
+ transform: translate(-50%, -50%);
30
+ &:hover {
31
+ cursor: pointer;
32
+ background: rgba(colors.$basic-gray87, 0.64);
33
+ }
34
+ &::after {
35
+ content: '';
36
+ display: block;
37
+ width: 24px;
38
+ height: 24px;
39
+ background: #fff;
40
+ border-radius: 50%;
41
+ }
42
+ @include breakpoints.down('xs') {
43
+ width: 40px;
44
+ height: 40px;
45
+ &::after {
46
+ width: 16px;
47
+ height: 16px;
48
+ }
49
+ }
50
+ }
@@ -21,6 +21,7 @@
21
21
  top: 0;
22
22
  left: 0;
23
23
  display: block;
24
+ width: 100%;
24
25
  height: 100%;
25
26
  }
26
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sima-land/moleculas",
3
- "version": "13.2.2",
3
+ "version": "13.4.0",
4
4
  "repository": "ssh://git@github.com:sima-land/moleculas.git",
5
5
  "author": "www.sima-land.ru team",
6
6
  "license": "Apache-2.0",
@@ -25,7 +25,7 @@
25
25
  "prettier:check": "prettier --check \"./src/**/*.{js,jsx,ts,tsx,css,scss}\" --loglevel error"
26
26
  },
27
27
  "dependencies": {
28
- "@sima-land/ui-nucleons": "^43.0.1",
28
+ "@sima-land/ui-nucleons": "^43.1.0",
29
29
  "@sima-land/ui-quarks": "^2.2.0",
30
30
  "classnames": "^2.3.1",
31
31
  "date-fns": "^2.26.0",