@megafon/ui-shared 8.4.0 → 8.6.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.
Files changed (45) hide show
  1. package/dist/es/components/ChipsBox/ChipBox.d.ts +5 -0
  2. package/dist/es/components/ChipsBox/ChipBox.js +7 -0
  3. package/dist/es/components/ChipsBox/ChipsBox.css +1 -0
  4. package/dist/es/components/ChipsBox/ChipsBox.d.ts +16 -0
  5. package/dist/es/components/ChipsBox/ChipsBox.js +76 -0
  6. package/dist/es/components/Container/Container.css +1 -1
  7. package/dist/es/components/ImageBanner/ImageBanner.css +1 -1
  8. package/dist/es/components/ImageBanner/ImageBanner.d.ts +2 -0
  9. package/dist/es/components/ImageBanner/ImageBanner.js +3 -0
  10. package/dist/es/components/InfoCards/components/InfoCard/InfoCard.js +2 -2
  11. package/dist/es/components/PictureBox/PictureBox.css +1 -1
  12. package/dist/es/components/PictureBox/img/mac-book-1x.png +0 -0
  13. package/dist/es/components/PictureBox/img/mac-book-2x.png +0 -0
  14. package/dist/es/components/Stepper/Stepper.css +1 -1
  15. package/dist/es/components/Stepper/Stepper.d.ts +4 -0
  16. package/dist/es/components/Stepper/Stepper.js +38 -23
  17. package/dist/es/components/Stepper/StepperItem.css +1 -1
  18. package/dist/es/components/Stepper/StepperItem.d.ts +7 -0
  19. package/dist/es/components/Stepper/StepperItem.js +15 -5
  20. package/dist/es/components/Stepper/img/separator-mobile.png +0 -0
  21. package/dist/es/index.d.ts +2 -0
  22. package/dist/es/index.js +2 -0
  23. package/dist/lib/components/ChipsBox/ChipBox.d.ts +5 -0
  24. package/dist/lib/components/ChipsBox/ChipBox.js +17 -0
  25. package/dist/lib/components/ChipsBox/ChipsBox.css +1 -0
  26. package/dist/lib/components/ChipsBox/ChipsBox.d.ts +16 -0
  27. package/dist/lib/components/ChipsBox/ChipsBox.js +85 -0
  28. package/dist/lib/components/Container/Container.css +1 -1
  29. package/dist/lib/components/ImageBanner/ImageBanner.css +1 -1
  30. package/dist/lib/components/ImageBanner/ImageBanner.d.ts +2 -0
  31. package/dist/lib/components/ImageBanner/ImageBanner.js +3 -0
  32. package/dist/lib/components/InfoCards/components/InfoCard/InfoCard.js +1 -1
  33. package/dist/lib/components/PictureBox/PictureBox.css +1 -1
  34. package/dist/lib/components/PictureBox/img/mac-book-1x.png +0 -0
  35. package/dist/lib/components/PictureBox/img/mac-book-2x.png +0 -0
  36. package/dist/lib/components/Stepper/Stepper.css +1 -1
  37. package/dist/lib/components/Stepper/Stepper.d.ts +4 -0
  38. package/dist/lib/components/Stepper/Stepper.js +37 -22
  39. package/dist/lib/components/Stepper/StepperItem.css +1 -1
  40. package/dist/lib/components/Stepper/StepperItem.d.ts +7 -0
  41. package/dist/lib/components/Stepper/StepperItem.js +16 -6
  42. package/dist/lib/components/Stepper/img/separator-mobile.png +0 -0
  43. package/dist/lib/index.d.ts +2 -0
  44. package/dist/lib/index.js +14 -0
  45. package/package.json +4 -4
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { Chip } from '@megafon/ui-core';
3
+ export type ChipBoxPropsType = Omit<React.ComponentProps<typeof Chip>, 'color' | 'checked'>;
4
+ declare const ChipBox: React.FC<ChipBoxPropsType>;
5
+ export default ChipBox;
@@ -0,0 +1,7 @@
1
+ /* eslint-disable react/no-unused-prop-types */
2
+ import * as React from 'react';
3
+ var ChipBox = function ChipBox(_ref) {
4
+ var children = _ref.children;
5
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
6
+ };
7
+ export default ChipBox;
@@ -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;