@salutejs/plasma-new-hope 0.173.4-canary.1502.11499843355.0 → 0.173.4-canary.1508.11499305539.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/cjs/components/Drawer/Drawer.js +2 -1
  2. package/cjs/components/Drawer/Drawer.js.map +1 -1
  3. package/cjs/components/Tabs/createTabsController.js.map +1 -1
  4. package/cjs/components/Tabs/ui/horizontal/HorizontalTabItem/HorizontalTabItem.js +1 -3
  5. package/cjs/components/Tabs/ui/horizontal/HorizontalTabItem/HorizontalTabItem.js.map +1 -1
  6. package/cjs/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.css +1 -1
  7. package/cjs/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.js +3 -8
  8. package/cjs/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.js.map +1 -1
  9. package/cjs/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/base.js +1 -1
  10. package/cjs/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/base.js.map +1 -1
  11. package/cjs/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/{base_4ob3q5.css → base_9miwn.css} +1 -1
  12. package/cjs/index.css +1 -1
  13. package/emotion/cjs/components/Drawer/Drawer.js +4 -3
  14. package/emotion/cjs/components/Tabs/ui/horizontal/HorizontalTabItem/HorizontalTabItem.js +1 -3
  15. package/emotion/cjs/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.js +3 -8
  16. package/emotion/cjs/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/base.js +1 -1
  17. package/emotion/cjs/examples/plasma_b2c/components/Tabs/Tabs.stories.tsx +33 -72
  18. package/emotion/cjs/examples/plasma_web/components/Tabs/Tabs.stories.tsx +33 -72
  19. package/emotion/es/components/Drawer/Drawer.js +2 -1
  20. package/emotion/es/components/Tabs/ui/horizontal/HorizontalTabItem/HorizontalTabItem.js +1 -3
  21. package/emotion/es/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.js +3 -8
  22. package/emotion/es/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/base.js +1 -1
  23. package/emotion/es/examples/plasma_b2c/components/Tabs/Tabs.stories.tsx +33 -72
  24. package/emotion/es/examples/plasma_web/components/Tabs/Tabs.stories.tsx +33 -72
  25. package/es/components/Drawer/Drawer.js +2 -1
  26. package/es/components/Drawer/Drawer.js.map +1 -1
  27. package/es/components/Tabs/createTabsController.js.map +1 -1
  28. package/es/components/Tabs/ui/horizontal/HorizontalTabItem/HorizontalTabItem.js +1 -3
  29. package/es/components/Tabs/ui/horizontal/HorizontalTabItem/HorizontalTabItem.js.map +1 -1
  30. package/es/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.css +1 -1
  31. package/es/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.js +3 -8
  32. package/es/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.js.map +1 -1
  33. package/es/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/base.js +1 -1
  34. package/es/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/base.js.map +1 -1
  35. package/es/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/{base_4ob3q5.css → base_9miwn.css} +1 -1
  36. package/es/index.css +1 -1
  37. package/package.json +2 -2
  38. package/styled-components/cjs/components/Drawer/Drawer.js +4 -3
  39. package/styled-components/cjs/components/Tabs/ui/horizontal/HorizontalTabItem/HorizontalTabItem.js +1 -3
  40. package/styled-components/cjs/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.js +3 -8
  41. package/styled-components/cjs/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/base.js +1 -1
  42. package/styled-components/cjs/examples/plasma_b2c/components/Tabs/Tabs.stories.tsx +33 -72
  43. package/styled-components/cjs/examples/plasma_web/components/Tabs/Tabs.stories.tsx +33 -72
  44. package/styled-components/es/components/Drawer/Drawer.js +2 -1
  45. package/styled-components/es/components/Tabs/ui/horizontal/HorizontalTabItem/HorizontalTabItem.js +1 -3
  46. package/styled-components/es/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.js +3 -8
  47. package/styled-components/es/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/base.js +1 -1
  48. package/styled-components/es/examples/plasma_b2c/components/Tabs/Tabs.stories.tsx +33 -72
  49. package/styled-components/es/examples/plasma_web/components/Tabs/Tabs.stories.tsx +33 -72
  50. package/types/components/Drawer/Drawer.d.ts.map +1 -1
  51. package/types/components/Tabs/TabItem.types.d.ts +8 -50
  52. package/types/components/Tabs/TabItem.types.d.ts.map +1 -1
  53. package/types/components/Tabs/Tabs.types.d.ts +2 -44
  54. package/types/components/Tabs/Tabs.types.d.ts.map +1 -1
  55. package/types/components/Tabs/createTabsController.d.ts +2 -2
  56. package/types/components/Tabs/createTabsController.d.ts.map +1 -1
  57. package/types/components/Tabs/index.d.ts +2 -2
  58. package/types/components/Tabs/index.d.ts.map +1 -1
  59. package/types/components/Tabs/ui/horizontal/HorizontalTabItem/HorizontalTabItem.d.ts.map +1 -1
  60. package/types/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.d.ts +2 -2
  61. package/types/components/Tabs/ui/horizontal/HorizontalTabs/HorizontalTabs.d.ts.map +1 -1
  62. package/types/components/Tabs/ui/horizontal/HorizontalTabs/variations/_view/base.d.ts.map +1 -1
  63. package/types/examples/plasma_b2c/components/Tabs/TabItem.d.ts +6 -21
  64. package/types/examples/plasma_b2c/components/Tabs/TabItem.d.ts.map +1 -1
  65. package/types/examples/plasma_b2c/components/Tabs/Tabs.d.ts +2 -2
  66. package/types/examples/plasma_b2c/components/Tabs/Tabs.d.ts.map +1 -1
  67. package/types/examples/plasma_web/components/Tabs/TabItem.d.ts +6 -21
  68. package/types/examples/plasma_web/components/Tabs/TabItem.d.ts.map +1 -1
  69. package/types/examples/plasma_web/components/Tabs/Tabs.d.ts +2 -2
  70. package/types/examples/plasma_web/components/Tabs/Tabs.d.ts.map +1 -1
@@ -13,13 +13,14 @@ var _Overlay = /*#__PURE__*/require("../Overlay");
13
13
  var _utils = /*#__PURE__*/require("../Popup/utils");
14
14
  var _Panel = /*#__PURE__*/require("../Panel");
15
15
  var _utils2 = /*#__PURE__*/require("../../utils");
16
+ var _hooks = /*#__PURE__*/require("../../hooks");
16
17
  var _Drawer = /*#__PURE__*/require("./Drawer.tokens");
17
18
  var _base = /*#__PURE__*/require("./variations/_view/base");
18
19
  var _base2 = /*#__PURE__*/require("./variations/_size/base");
19
20
  var _base3 = /*#__PURE__*/require("./variations/_borderRadius/base");
20
21
  var _Drawer2 = /*#__PURE__*/require("./Drawer.styles");
21
22
  var _DrawerContext = /*#__PURE__*/require("./DrawerContext");
22
- var _hooks = /*#__PURE__*/require("./hooks");
23
+ var _hooks2 = /*#__PURE__*/require("./hooks");
23
24
  var _excluded = ["id", "zIndex", "popupInfo", "withBlur", "children", "view", "size", "width", "height", "isOpen", "opened", "initialFocusRef", "focusAfterRef", "className", "onClose", "onOverlayClick", "onEscKeyDown", "offset", "frame", "borderRadius", "placement", "closeOnEsc", "closeOnOverlayClick", "asModal"];
24
25
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
25
26
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -62,7 +63,7 @@ var drawerRoot = exports.drawerRoot = function drawerRoot(Root) {
62
63
  asModal = _ref$asModal === void 0 ? true : _ref$asModal,
63
64
  rest = _objectWithoutProperties(_ref, _excluded);
64
65
  var innerIsOpen = Boolean(isOpen || opened);
65
- var trapRef = (0, _plasmaCore.useFocusTrap)(true, initialFocusRef, focusAfterRef);
66
+ var trapRef = (0, _hooks.useFocusTrap)(true, initialFocusRef, focusAfterRef);
66
67
  var popupController = (0, _Popup.usePopupContext)();
67
68
  var innerRef = (0, _plasmaCore.useForkRef)(trapRef, outerRef);
68
69
  var uniqId = (0, _plasmaCore.safeUseId)();
@@ -71,7 +72,7 @@ var drawerRoot = exports.drawerRoot = function drawerRoot(Root) {
71
72
  var innerWidth = width ? (0, _utils2.getSizeValueFromProp)(width) : '100%';
72
73
  var innerHeight = height ? (0, _utils2.getSizeValueFromProp)(height) : '100%';
73
74
  var placementClass = placement ? _Drawer.classes["".concat(placement, "Placement")] : undefined;
74
- var _useDrawer = (0, _hooks.useDrawer)({
75
+ var _useDrawer = (0, _hooks2.useDrawer)({
75
76
  id: innerId,
76
77
  isOpen: innerIsOpen,
77
78
  closeOnEsc: closeOnEsc,
@@ -101,9 +101,7 @@ var horizontalTabItemRoot = exports.horizontalTabItemRoot = function horizontalT
101
101
  disabled: disabled,
102
102
  pilled: pilled,
103
103
  role: role,
104
- view: view
105
- // TODO: убрать каст any, когда будут удалены deprecated props
106
- ,
104
+ view: view,
107
105
  size: size,
108
106
  onFocus: onItemFocus,
109
107
  tabIndex: hasKeyNavigation ? navigationTabIndex : tabIndex,
@@ -17,7 +17,7 @@ var _base3 = /*#__PURE__*/require("./variations/_disabled/base");
17
17
  var _base4 = /*#__PURE__*/require("./variations/_pilled/base");
18
18
  var _base5 = /*#__PURE__*/require("./variations/_stretch/base");
19
19
  var _HorizontalTabs = /*#__PURE__*/require("./HorizontalTabs.styles");
20
- var _excluded = ["id", "stretch", "disabled", "clip", "size", "view", "children", "pilled", "index", "className", "hasDivider"];
20
+ var _excluded = ["id", "stretch", "disabled", "clip", "size", "view", "children", "pilled", "index", "className"];
21
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
22
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
23
23
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -52,8 +52,6 @@ var horizontalTabsRoot = exports.horizontalTabsRoot = function horizontalTabsRoo
52
52
  pilled = _props$pilled === void 0 ? false : _props$pilled,
53
53
  index = props.index,
54
54
  className = props.className,
55
- _props$hasDivider = props.hasDivider,
56
- hasDivider = _props$hasDivider === void 0 ? true : _props$hasDivider,
57
55
  rest = _objectWithoutProperties(props, _excluded);
58
56
  var _useState = (0, _react.useState)(true),
59
57
  _useState2 = _slicedToArray(_useState, 2),
@@ -71,7 +69,6 @@ var horizontalTabsRoot = exports.horizontalTabsRoot = function horizontalTabsRoo
71
69
  var isFilled = view === 'filled'; // outer padding is only for filled view
72
70
  var pilledAttr = view !== 'clear' && pilled;
73
71
  var pilledClass = pilledAttr ? _tokens.classes.tabsPilled : undefined;
74
- var noDividerClass = !hasDivider ? _tokens.classes.tabsNoDivider : undefined;
75
72
  var stretchClass = firstItemVisible && lastItemVisible && stretch ? _tokens.classes.tabsStretch : undefined;
76
73
  var hasLeftArrowClass = !firstItemVisible ? _tokens.classes.tabsHasLeftArrow : undefined;
77
74
  var hasRightArrowClass = !lastItemVisible ? _tokens.classes.tabsHasRightArrow : undefined;
@@ -201,15 +198,13 @@ var horizontalTabsRoot = exports.horizontalTabsRoot = function horizontalTabsRoo
201
198
  value: refs
202
199
  }, /*#__PURE__*/_react["default"].createElement(Root, _extends({
203
200
  view: view,
204
- role: "tablist"
205
- // TODO: убрать каст any, когда будут удалены deprecated props
206
- ,
201
+ role: "tablist",
207
202
  size: size,
208
203
  pilled: pilled,
209
204
  id: tabsId,
210
205
  ref: outerRef,
211
206
  disabled: disabled,
212
- className: (0, _utils.cx)(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, noDividerClass, className),
207
+ className: (0, _utils.cx)(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, className),
213
208
  onKeyDown: onKeyDown
214
209
  }, rest), !firstItemVisible && PreviousButton, /*#__PURE__*/_react["default"].createElement(_HorizontalTabs.StyledContentWrapper, {
215
210
  className: (0, _utils.cx)(clipScrollClass, clipShowAllClass),
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.base = void 0;
7
7
  var _styledComponents = /*#__PURE__*/require("styled-components");
8
8
  var _tokens = /*#__PURE__*/require("../../../../../tokens");
9
- var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)(["background-color:var(", ");&::after{content:'';position:absolute;bottom:0.125rem;left:0.125rem;right:0.125rem;background:var(", ");height:var(", ");border-radius:var(", ");}&.", "{&::after{left:1.5rem;}}&.", "{&::after{right:1.5rem;}}&.", "{&::after{height:0;}}"], _tokens.tokens.tabsBackgroundColor, _tokens.tokens.tabsDividerColor, _tokens.tokens.tabsDividerHeight, _tokens.tokens.tabsDividerBorderRadius, _tokens.classes.tabsHasLeftArrow, _tokens.classes.tabsHasRightArrow, _tokens.classes.tabsNoDivider);
9
+ var base = exports.base = /*#__PURE__*/(0, _styledComponents.css)(["background-color:var(", ");&::after{content:'';position:absolute;bottom:0.125rem;left:0.125rem;right:0.125rem;background:var(", ");height:var(", ");border-radius:var(", ");}&.", "{&::after{left:1.5rem;}}&.", "{&::after{right:1.5rem;}}"], _tokens.tokens.tabsBackgroundColor, _tokens.tokens.tabsDividerColor, _tokens.tokens.tabsDividerHeight, _tokens.tokens.tabsDividerBorderRadius, _tokens.classes.tabsHasLeftArrow, _tokens.classes.tabsHasRightArrow);
@@ -12,7 +12,6 @@ import { Tabs } from './Tabs';
12
12
  import { TabItem } from './TabItem';
13
13
 
14
14
  const clips = ['none', 'scroll', 'showAll'];
15
- const headerClips = ['none', 'scroll'];
16
15
  const sizes = ['xs', 's', 'm', 'l'] as const;
17
16
  const headerSizes = ['h5', 'h4', 'h3', 'h2', 'h1'] as const;
18
17
 
@@ -21,6 +20,7 @@ type HeaderSize = typeof headerSizes[number];
21
20
 
22
21
  type CustomStoryTabsProps = {
23
22
  itemQuantity: number;
23
+ hasDivider: boolean;
24
24
  contentLeft: string;
25
25
  contentRight: string;
26
26
  stretch: boolean;
@@ -30,12 +30,12 @@ type CustomStoryTabsProps = {
30
30
  const contentLeftOptions = ['none', 'icon'];
31
31
  const contentRightOptions = ['none', 'counter', 'icon'];
32
32
 
33
- const getContentLeft = (contentLeftOption: string, size: string) => {
33
+ const getContentLeft = (contentLeftOption: string, size: Size) => {
34
34
  const iconSize = size === 'xs' ? 'xs' : 's';
35
35
  return contentLeftOption === 'icon' ? <IconMic size={iconSize} color="inherit" /> : undefined;
36
36
  };
37
37
 
38
- const getContentRight = (contentRightOption: string, size: string) => {
38
+ const getContentRight = (contentRightOption: string, size: Size) => {
39
39
  const iconSize = size === 'xs' ? 'xs' : 's';
40
40
  const counterSize = size === 'xs' ? 'xxs' : 'xs';
41
41
 
@@ -96,7 +96,7 @@ const StoryHorizontalDefault = (props: HorizontalStoryTabsProps) => {
96
96
  const [index, setIndex] = useState(0);
97
97
 
98
98
  return (
99
- <Tabs view="divider" hasDivider={hasDivider} stretch={stretch} disabled={disabled} size={size}>
99
+ <Tabs view={hasDivider ? 'divider' : 'clear'} stretch={stretch} disabled={disabled} size={size}>
100
100
  {items.map((_, i) => {
101
101
  if (helperText !== '') {
102
102
  return (
@@ -152,7 +152,7 @@ const StoryHorizontalScroll = (props: HorizontalStoryTabsProps) => {
152
152
  const [index, setIndex] = useState(0);
153
153
 
154
154
  return (
155
- <Tabs clip={clip} view="divider" hasDivider={hasDivider} disabled={disabled} size={size} style={{ width }}>
155
+ <Tabs clip={clip} view={hasDivider ? 'divider' : 'clear'} disabled={disabled} size={size} style={{ width }}>
156
156
  {items.map((_, i) => {
157
157
  if (helperText !== '') {
158
158
  return (
@@ -220,7 +220,7 @@ const StoryHorizontalShowAll = (props: HorizontalStoryTabsProps) => {
220
220
  });
221
221
 
222
222
  return (
223
- <Tabs clip={clip} view="divider" hasDivider={hasDivider} disabled={disabled} size={size}>
223
+ <Tabs clip={clip} view={hasDivider ? 'divider' : 'clear'} disabled={disabled} size={size}>
224
224
  {visibleItems.map((_, i) => {
225
225
  if (helperText !== '') {
226
226
  return (
@@ -603,47 +603,31 @@ export const VerticalTabs: StoryObj<VerticalStoryTabsProps> = {
603
603
  },
604
604
  };
605
605
 
606
- const StoryHeaderDefault = (props: HorizontalStoryTabsProps) => {
607
- const { disabled, itemQuantity, size, helperText } = props;
608
- const items = Array(itemQuantity).fill(0);
609
- const [index, setIndex] = useState(0);
610
-
611
- return (
612
- <Tabs view="clear" disabled={disabled} size={size as HeaderSize}>
613
- {items.map((_, i) => (
614
- <TabItem
615
- key={`item:${i}`}
616
- view="clear"
617
- selected={i === index}
618
- onClick={() => !disabled && setIndex(i)}
619
- tabIndex={!disabled ? 0 : -1}
620
- disabled={disabled}
621
- value={helperText}
622
- size={size as HeaderSize}
623
- >
624
- {`Label${i + 1}`}
625
- </TabItem>
626
- ))}
627
- </Tabs>
628
- );
629
- };
630
-
631
- const StoryHeaderScroll = (props: HorizontalStoryTabsProps) => {
632
- const { disabled, itemQuantity, size, helperText, width } = props;
606
+ const StoryHeaderTabs = (props: StoryTabsProps) => {
607
+ const {
608
+ disabled,
609
+ itemQuantity,
610
+ size,
611
+ contentLeft: contentLeftOption,
612
+ contentRight: contentRightOption,
613
+ hasDivider,
614
+ stretch,
615
+ } = props;
633
616
  const items = Array(itemQuantity).fill(0);
634
617
  const [index, setIndex] = useState(0);
635
618
 
636
619
  return (
637
- <Tabs view="clear" disabled={disabled} size={size as HeaderSize} style={{ width }}>
620
+ <Tabs view={hasDivider ? 'divider' : 'clear'} disabled={disabled} size={size} stretch={stretch}>
638
621
  {items.map((_, i) => (
639
622
  <TabItem
640
623
  key={`item:${i}`}
641
- view="clear"
624
+ view="divider"
642
625
  selected={i === index}
643
626
  onClick={() => !disabled && setIndex(i)}
644
627
  tabIndex={!disabled ? 0 : -1}
645
628
  disabled={disabled}
646
- value={helperText}
629
+ contentLeft={getContentLeft(contentLeftOption, size as Size)}
630
+ contentRight={getContentRight(contentRightOption, size as Size)}
647
631
  size={size as HeaderSize}
648
632
  >
649
633
  {`Label${i + 1}`}
@@ -653,60 +637,37 @@ const StoryHeaderScroll = (props: HorizontalStoryTabsProps) => {
653
637
  );
654
638
  };
655
639
 
656
- export const HeaderTabs: StoryObj<HorizontalStoryTabsProps> = {
640
+ export const HeaderTabs: StoryObj<StoryTabsProps> = {
657
641
  args: {
658
642
  size: 'h5',
659
643
  disabled: false,
660
- helperText: '',
661
- itemQuantity: 6,
662
- width: '12rem',
644
+ hasDivider: true,
645
+ itemQuantity: 4,
663
646
  },
664
647
  argTypes: {
665
- clip: {
666
- options: headerClips,
648
+ size: {
649
+ options: headerSizes,
667
650
  control: {
668
651
  type: 'select',
669
652
  },
670
653
  },
671
- width: {
672
- control: {
673
- type: 'text',
674
- },
675
- if: { arg: 'clip', eq: 'scroll' },
676
- },
677
- stretch: {
678
- table: {
679
- disable: true,
680
- },
681
- },
682
654
  contentLeft: {
683
- table: {
684
- disable: true,
655
+ options: contentLeftOptions,
656
+ control: {
657
+ type: 'select',
685
658
  },
686
659
  },
687
660
  contentRight: {
688
- table: {
689
- disable: true,
661
+ options: contentRightOptions,
662
+ control: {
663
+ type: 'select',
690
664
  },
691
665
  },
692
- hasDivider: {
666
+ clip: {
693
667
  table: {
694
668
  disable: true,
695
669
  },
696
670
  },
697
- size: {
698
- options: headerSizes,
699
- control: {
700
- type: 'select',
701
- },
702
- },
703
- },
704
- render: (args) => {
705
- switch (args.clip) {
706
- case 'scroll':
707
- return <StoryHeaderScroll {...args} />;
708
- default:
709
- return <StoryHeaderDefault {...args} />;
710
- }
711
671
  },
672
+ render: (args) => <StoryHeaderTabs {...args} />,
712
673
  };
@@ -12,7 +12,6 @@ import { Tabs } from './Tabs';
12
12
  import { TabItem } from './TabItem';
13
13
 
14
14
  const clips = ['none', 'scroll', 'showAll'];
15
- const headerClips = ['none', 'scroll'];
16
15
  const sizes = ['xs', 's', 'm', 'l'] as const;
17
16
  const headerSizes = ['h5', 'h4', 'h3', 'h2', 'h1'] as const;
18
17
 
@@ -21,6 +20,7 @@ type HeaderSize = typeof headerSizes[number];
21
20
 
22
21
  type CustomStoryTabsProps = {
23
22
  itemQuantity: number;
23
+ hasDivider: boolean;
24
24
  contentLeft: string;
25
25
  contentRight: string;
26
26
  stretch: boolean;
@@ -30,12 +30,12 @@ type CustomStoryTabsProps = {
30
30
  const contentLeftOptions = ['none', 'icon'];
31
31
  const contentRightOptions = ['none', 'counter', 'icon'];
32
32
 
33
- const getContentLeft = (contentLeftOption: string, size: string) => {
33
+ const getContentLeft = (contentLeftOption: string, size: Size) => {
34
34
  const iconSize = size === 'xs' ? 'xs' : 's';
35
35
  return contentLeftOption === 'icon' ? <IconMic size={iconSize} color="inherit" /> : undefined;
36
36
  };
37
37
 
38
- const getContentRight = (contentRightOption: string, size: string) => {
38
+ const getContentRight = (contentRightOption: string, size: Size) => {
39
39
  const iconSize = size === 'xs' ? 'xs' : 's';
40
40
  const counterSize = size === 'xs' ? 'xxs' : 'xs';
41
41
 
@@ -96,7 +96,7 @@ const StoryHorizontalDefault = (props: HorizontalStoryTabsProps) => {
96
96
  const [index, setIndex] = useState(0);
97
97
 
98
98
  return (
99
- <Tabs view="divider" hasDivider={hasDivider} stretch={stretch} disabled={disabled} size={size}>
99
+ <Tabs view={hasDivider ? 'divider' : 'clear'} stretch={stretch} disabled={disabled} size={size}>
100
100
  {items.map((_, i) => {
101
101
  if (helperText !== '') {
102
102
  return (
@@ -152,7 +152,7 @@ const StoryHorizontalScroll = (props: HorizontalStoryTabsProps) => {
152
152
  const [index, setIndex] = useState(0);
153
153
 
154
154
  return (
155
- <Tabs clip={clip} view="divider" hasDivider={hasDivider} disabled={disabled} size={size} style={{ width }}>
155
+ <Tabs clip={clip} view={hasDivider ? 'divider' : 'clear'} disabled={disabled} size={size} style={{ width }}>
156
156
  {items.map((_, i) => {
157
157
  if (helperText !== '') {
158
158
  return (
@@ -220,7 +220,7 @@ const StoryHorizontalShowAll = (props: HorizontalStoryTabsProps) => {
220
220
  });
221
221
 
222
222
  return (
223
- <Tabs clip={clip} view="divider" hasDivider={hasDivider} disabled={disabled} size={size}>
223
+ <Tabs clip={clip} view={hasDivider ? 'divider' : 'clear'} disabled={disabled} size={size}>
224
224
  {visibleItems.map((_, i) => {
225
225
  if (helperText !== '') {
226
226
  return (
@@ -603,47 +603,31 @@ export const VerticalTabs: StoryObj<VerticalStoryTabsProps> = {
603
603
  },
604
604
  };
605
605
 
606
- const StoryHeaderDefault = (props: HorizontalStoryTabsProps) => {
607
- const { disabled, itemQuantity, size, helperText } = props;
608
- const items = Array(itemQuantity).fill(0);
609
- const [index, setIndex] = useState(0);
610
-
611
- return (
612
- <Tabs view="clear" disabled={disabled} size={size as HeaderSize}>
613
- {items.map((_, i) => (
614
- <TabItem
615
- key={`item:${i}`}
616
- view="clear"
617
- selected={i === index}
618
- onClick={() => !disabled && setIndex(i)}
619
- tabIndex={!disabled ? 0 : -1}
620
- disabled={disabled}
621
- value={helperText}
622
- size={size as HeaderSize}
623
- >
624
- {`Label${i + 1}`}
625
- </TabItem>
626
- ))}
627
- </Tabs>
628
- );
629
- };
630
-
631
- const StoryHeaderScroll = (props: HorizontalStoryTabsProps) => {
632
- const { disabled, itemQuantity, size, helperText, width } = props;
606
+ const StoryHeaderTabs = (props: StoryTabsProps) => {
607
+ const {
608
+ disabled,
609
+ itemQuantity,
610
+ size,
611
+ contentLeft: contentLeftOption,
612
+ contentRight: contentRightOption,
613
+ hasDivider,
614
+ stretch,
615
+ } = props;
633
616
  const items = Array(itemQuantity).fill(0);
634
617
  const [index, setIndex] = useState(0);
635
618
 
636
619
  return (
637
- <Tabs view="clear" disabled={disabled} size={size as HeaderSize} style={{ width }}>
620
+ <Tabs view={hasDivider ? 'divider' : 'clear'} disabled={disabled} size={size} stretch={stretch}>
638
621
  {items.map((_, i) => (
639
622
  <TabItem
640
623
  key={`item:${i}`}
641
- view="clear"
624
+ view="divider"
642
625
  selected={i === index}
643
626
  onClick={() => !disabled && setIndex(i)}
644
627
  tabIndex={!disabled ? 0 : -1}
645
628
  disabled={disabled}
646
- value={helperText}
629
+ contentLeft={getContentLeft(contentLeftOption, size as Size)}
630
+ contentRight={getContentRight(contentRightOption, size as Size)}
647
631
  size={size as HeaderSize}
648
632
  >
649
633
  {`Label${i + 1}`}
@@ -653,60 +637,37 @@ const StoryHeaderScroll = (props: HorizontalStoryTabsProps) => {
653
637
  );
654
638
  };
655
639
 
656
- export const HeaderTabs: StoryObj<HorizontalStoryTabsProps> = {
640
+ export const HeaderTabs: StoryObj<StoryTabsProps> = {
657
641
  args: {
658
642
  size: 'h5',
659
643
  disabled: false,
660
- helperText: '',
661
- itemQuantity: 6,
662
- width: '12rem',
644
+ hasDivider: true,
645
+ itemQuantity: 4,
663
646
  },
664
647
  argTypes: {
665
- clip: {
666
- options: headerClips,
648
+ size: {
649
+ options: headerSizes,
667
650
  control: {
668
651
  type: 'select',
669
652
  },
670
653
  },
671
- width: {
672
- control: {
673
- type: 'text',
674
- },
675
- if: { arg: 'clip', eq: 'scroll' },
676
- },
677
- stretch: {
678
- table: {
679
- disable: true,
680
- },
681
- },
682
654
  contentLeft: {
683
- table: {
684
- disable: true,
655
+ options: contentLeftOptions,
656
+ control: {
657
+ type: 'select',
685
658
  },
686
659
  },
687
660
  contentRight: {
688
- table: {
689
- disable: true,
661
+ options: contentRightOptions,
662
+ control: {
663
+ type: 'select',
690
664
  },
691
665
  },
692
- hasDivider: {
666
+ clip: {
693
667
  table: {
694
668
  disable: true,
695
669
  },
696
670
  },
697
- size: {
698
- options: headerSizes,
699
- control: {
700
- type: 'select',
701
- },
702
- },
703
- },
704
- render: (args) => {
705
- switch (args.clip) {
706
- case 'scroll':
707
- return <StoryHeaderScroll {...args} />;
708
- default:
709
- return <StoryHeaderDefault {...args} />;
710
- }
711
671
  },
672
+ render: (args) => <StoryHeaderTabs {...args} />,
712
673
  };
@@ -3,13 +3,14 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
3
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
5
  import React, { forwardRef, useMemo } from 'react';
6
- import { useFocusTrap, useForkRef, safeUseId } from '@salutejs/plasma-core';
6
+ import { useForkRef, safeUseId } from '@salutejs/plasma-core';
7
7
  import { component, mergeConfig } from '../../engines';
8
8
  import { usePopupContext } from '../Popup';
9
9
  import { Overlay } from '../Overlay';
10
10
  import { DEFAULT_Z_INDEX } from '../Popup/utils';
11
11
  import { panelConfig } from '../Panel';
12
12
  import { cx, getSizeValueFromProp } from '../../utils';
13
+ import { useFocusTrap } from '../../hooks';
13
14
  import { classes, tokens } from './Drawer.tokens';
14
15
  import { base as viewCSS } from './variations/_view/base';
15
16
  import { base as sizeCSS } from './variations/_size/base';
@@ -92,9 +92,7 @@ export var horizontalTabItemRoot = function horizontalTabItemRoot(Root) {
92
92
  disabled: disabled,
93
93
  pilled: pilled,
94
94
  role: role,
95
- view: view
96
- // TODO: убрать каст any, когда будут удалены deprecated props
97
- ,
95
+ view: view,
98
96
  size: size,
99
97
  onFocus: onItemFocus,
100
98
  tabIndex: hasKeyNavigation ? navigationTabIndex : tabIndex,
@@ -1,4 +1,4 @@
1
- var _excluded = ["id", "stretch", "disabled", "clip", "size", "view", "children", "pilled", "index", "className", "hasDivider"];
1
+ var _excluded = ["id", "stretch", "disabled", "clip", "size", "view", "children", "pilled", "index", "className"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -43,8 +43,6 @@ export var horizontalTabsRoot = function horizontalTabsRoot(Root) {
43
43
  pilled = _props$pilled === void 0 ? false : _props$pilled,
44
44
  index = props.index,
45
45
  className = props.className,
46
- _props$hasDivider = props.hasDivider,
47
- hasDivider = _props$hasDivider === void 0 ? true : _props$hasDivider,
48
46
  rest = _objectWithoutProperties(props, _excluded);
49
47
  var _useState = useState(true),
50
48
  _useState2 = _slicedToArray(_useState, 2),
@@ -62,7 +60,6 @@ export var horizontalTabsRoot = function horizontalTabsRoot(Root) {
62
60
  var isFilled = view === 'filled'; // outer padding is only for filled view
63
61
  var pilledAttr = view !== 'clear' && pilled;
64
62
  var pilledClass = pilledAttr ? classes.tabsPilled : undefined;
65
- var noDividerClass = !hasDivider ? classes.tabsNoDivider : undefined;
66
63
  var stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.tabsStretch : undefined;
67
64
  var hasLeftArrowClass = !firstItemVisible ? classes.tabsHasLeftArrow : undefined;
68
65
  var hasRightArrowClass = !lastItemVisible ? classes.tabsHasRightArrow : undefined;
@@ -192,15 +189,13 @@ export var horizontalTabsRoot = function horizontalTabsRoot(Root) {
192
189
  value: refs
193
190
  }, /*#__PURE__*/React.createElement(Root, _extends({
194
191
  view: view,
195
- role: "tablist"
196
- // TODO: убрать каст any, когда будут удалены deprecated props
197
- ,
192
+ role: "tablist",
198
193
  size: size,
199
194
  pilled: pilled,
200
195
  id: tabsId,
201
196
  ref: outerRef,
202
197
  disabled: disabled,
203
- className: cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, noDividerClass, className),
198
+ className: cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass, className),
204
199
  onKeyDown: onKeyDown
205
200
  }, rest), !firstItemVisible && PreviousButton, /*#__PURE__*/React.createElement(StyledContentWrapper, {
206
201
  className: cx(clipScrollClass, clipShowAllClass),
@@ -1,3 +1,3 @@
1
1
  import { css } from 'styled-components';
2
2
  import { classes, tokens } from '../../../../../tokens';
3
- export var base = /*#__PURE__*/css(["background-color:var(", ");&::after{content:'';position:absolute;bottom:0.125rem;left:0.125rem;right:0.125rem;background:var(", ");height:var(", ");border-radius:var(", ");}&.", "{&::after{left:1.5rem;}}&.", "{&::after{right:1.5rem;}}&.", "{&::after{height:0;}}"], tokens.tabsBackgroundColor, tokens.tabsDividerColor, tokens.tabsDividerHeight, tokens.tabsDividerBorderRadius, classes.tabsHasLeftArrow, classes.tabsHasRightArrow, classes.tabsNoDivider);
3
+ export var base = /*#__PURE__*/css(["background-color:var(", ");&::after{content:'';position:absolute;bottom:0.125rem;left:0.125rem;right:0.125rem;background:var(", ");height:var(", ");border-radius:var(", ");}&.", "{&::after{left:1.5rem;}}&.", "{&::after{right:1.5rem;}}"], tokens.tabsBackgroundColor, tokens.tabsDividerColor, tokens.tabsDividerHeight, tokens.tabsDividerBorderRadius, classes.tabsHasLeftArrow, classes.tabsHasRightArrow);