@megafon/ui-shared 8.3.0 → 8.5.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.
- package/dist/es/components/ChipsBox/ChipBox.d.ts +5 -0
- package/dist/es/components/ChipsBox/ChipBox.js +7 -0
- package/dist/es/components/ChipsBox/ChipsBox.css +1 -0
- package/dist/es/components/ChipsBox/ChipsBox.d.ts +16 -0
- package/dist/es/components/ChipsBox/ChipsBox.js +76 -0
- package/dist/es/components/Container/Container.css +1 -1
- package/dist/es/components/ImageBanner/ImageBanner.css +1 -1
- package/dist/es/components/ImageBanner/ImageBanner.d.ts +2 -0
- package/dist/es/components/ImageBanner/ImageBanner.js +3 -0
- package/dist/es/components/InfoCards/components/InfoCard/InfoCard.js +2 -2
- package/dist/es/components/Partners/Partners.d.ts +1 -0
- package/dist/es/components/Partners/Partners.js +5 -1
- package/dist/es/components/PictureBox/PictureBox.css +1 -1
- package/dist/es/components/PictureBox/img/mac-book-1x.png +0 -0
- package/dist/es/components/PictureBox/img/mac-book-2x.png +0 -0
- package/dist/es/index.d.ts +2 -0
- package/dist/es/index.js +2 -0
- package/dist/lib/components/ChipsBox/ChipBox.d.ts +5 -0
- package/dist/lib/components/ChipsBox/ChipBox.js +17 -0
- package/dist/lib/components/ChipsBox/ChipsBox.css +1 -0
- package/dist/lib/components/ChipsBox/ChipsBox.d.ts +16 -0
- package/dist/lib/components/ChipsBox/ChipsBox.js +85 -0
- package/dist/lib/components/Container/Container.css +1 -1
- package/dist/lib/components/ImageBanner/ImageBanner.css +1 -1
- package/dist/lib/components/ImageBanner/ImageBanner.d.ts +2 -0
- package/dist/lib/components/ImageBanner/ImageBanner.js +3 -0
- package/dist/lib/components/InfoCards/components/InfoCard/InfoCard.js +1 -1
- package/dist/lib/components/Partners/Partners.d.ts +1 -0
- package/dist/lib/components/Partners/Partners.js +5 -1
- package/dist/lib/components/PictureBox/PictureBox.css +1 -1
- package/dist/lib/components/PictureBox/img/mac-book-1x.png +0 -0
- package/dist/lib/components/PictureBox/img/mac-book-2x.png +0 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +14 -0
- package/package.json +4 -4
@@ -0,0 +1 @@
|
|
1
|
+
h1,h2,h3,h4,h5{margin:0}.mfui-chips-box__wrapper{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%}.mfui-chips-box__panel{display:none}.mfui-chips-box__panel_current{display:block}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { Chips } from '@megafon/ui-core';
|
3
|
+
import { ChipBoxPropsType } from './ChipBox';
|
4
|
+
import './ChipsBox.scss';
|
5
|
+
export type ChipsItemsPropsType = React.ComponentProps<typeof Chips>['items'];
|
6
|
+
export type ChipBoxChildrenType = Array<React.ReactElement<ChipBoxPropsType>>;
|
7
|
+
export type ChipsBoxPropsType = Omit<React.ComponentProps<typeof Chips>, 'items'> & {
|
8
|
+
/** Рендер содержимого только для текущего варианта */
|
9
|
+
renderOnlyCurrentPanel?: boolean;
|
10
|
+
/** Дочерние элементы */
|
11
|
+
children: ChipBoxChildrenType;
|
12
|
+
/** Ссылка на корневой элемент */
|
13
|
+
rootRef?: React.Ref<HTMLDivElement>;
|
14
|
+
};
|
15
|
+
declare const ChipsBox: React.FC<ChipsBoxPropsType>;
|
16
|
+
export default ChipsBox;
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
3
|
+
import "core-js/modules/es.symbol.js";
|
4
|
+
import "core-js/modules/es.array.filter.js";
|
5
|
+
import "core-js/modules/es.array.index-of.js";
|
6
|
+
import "core-js/modules/es.array.map.js";
|
7
|
+
import "core-js/modules/es.object.to-string.js";
|
8
|
+
import "core-js/modules/es.promise.js";
|
9
|
+
var __rest = this && this.__rest || function (s, e) {
|
10
|
+
var t = {};
|
11
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
12
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
13
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
14
|
+
}
|
15
|
+
return t;
|
16
|
+
};
|
17
|
+
import * as React from 'react';
|
18
|
+
import { Chips } from '@megafon/ui-core';
|
19
|
+
import { cnCreate } from '@megafon/ui-helpers';
|
20
|
+
import "./ChipsBox.css";
|
21
|
+
var cn = cnCreate('mfui-chips-box');
|
22
|
+
var ChipsBox = function ChipsBox(_a) {
|
23
|
+
var _b;
|
24
|
+
var _a$renderOnlyCurrentP = _a.renderOnlyCurrentPanel,
|
25
|
+
renderOnlyCurrentPanel = _a$renderOnlyCurrentP === void 0 ? false : _a$renderOnlyCurrentP,
|
26
|
+
_a$isScrollable = _a.isScrollable,
|
27
|
+
isScrollable = _a$isScrollable === void 0 ? true : _a$isScrollable,
|
28
|
+
rootRef = _a.rootRef,
|
29
|
+
children = _a.children,
|
30
|
+
value = _a.value,
|
31
|
+
onChange = _a.onChange,
|
32
|
+
chipsProps = __rest(_a, ["renderOnlyCurrentPanel", "isScrollable", "rootRef", "children", "value", "onChange"]);
|
33
|
+
var childArray = React.Children.toArray(children).filter(function (child) {
|
34
|
+
return /*#__PURE__*/React.isValidElement(child);
|
35
|
+
});
|
36
|
+
var chipsItems = childArray.map(function (child) {
|
37
|
+
return _extends(_extends({}, child.props), {
|
38
|
+
children: null
|
39
|
+
});
|
40
|
+
});
|
41
|
+
var _React$useState = React.useState(value || ((_b = chipsItems[0]) === null || _b === void 0 ? void 0 : _b.id)),
|
42
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
43
|
+
currentId = _React$useState2[0],
|
44
|
+
setCurrentId = _React$useState2[1];
|
45
|
+
var panels = childArray.map(function (child) {
|
46
|
+
var props = child.props;
|
47
|
+
var id = props.id,
|
48
|
+
panel = props.children;
|
49
|
+
var isCurrentPanel = currentId === id;
|
50
|
+
if (!panel || renderOnlyCurrentPanel && !isCurrentPanel) {
|
51
|
+
return null;
|
52
|
+
}
|
53
|
+
return /*#__PURE__*/React.createElement("div", {
|
54
|
+
key: id,
|
55
|
+
className: cn('panel', {
|
56
|
+
current: isCurrentPanel
|
57
|
+
})
|
58
|
+
}, panel);
|
59
|
+
});
|
60
|
+
var handleChange = React.useCallback(function (id) {
|
61
|
+
setCurrentId(id);
|
62
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(id);
|
63
|
+
}, [onChange]);
|
64
|
+
return /*#__PURE__*/React.createElement("div", {
|
65
|
+
ref: rootRef,
|
66
|
+
className: cn()
|
67
|
+
}, /*#__PURE__*/React.createElement("div", {
|
68
|
+
className: cn('wrapper')
|
69
|
+
}, /*#__PURE__*/React.createElement(Chips, _extends({}, chipsProps, {
|
70
|
+
value: currentId,
|
71
|
+
items: chipsItems,
|
72
|
+
isScrollable: isScrollable,
|
73
|
+
onChange: handleChange
|
74
|
+
}))), panels);
|
75
|
+
};
|
76
|
+
export default ChipsBox;
|