@salutejs/plasma-new-hope 0.171.0-canary.1484.11400899769.0 → 0.171.0-canary.1492.11402523696.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Accordion/ui/AccordionItem/AccordionItem.js +13 -19
- package/cjs/components/Accordion/ui/AccordionItem/AccordionItem.js.map +1 -1
- package/cjs/components/TextArea/TextArea.js +1 -1
- package/cjs/components/TextArea/TextArea.js.map +1 -1
- package/cjs/components/TextArea/hooks/useAutoResize.js +2 -2
- package/cjs/components/TextArea/hooks/useAutoResize.js.map +1 -1
- package/emotion/cjs/components/Accordion/Accordion.template-doc.mdx +0 -32
- package/emotion/cjs/components/Accordion/ui/AccordionItem/AccordionItem.js +13 -19
- package/emotion/cjs/components/TextArea/TextArea.js +2 -2
- package/emotion/cjs/components/TextArea/hooks/useAutoResize.js +2 -2
- package/emotion/cjs/examples/plasma_b2c/components/Accordion/Accordion.stories.tsx +1 -63
- package/emotion/cjs/examples/plasma_web/components/Accordion/Accordion.stories.tsx +1 -63
- package/emotion/es/components/Accordion/Accordion.template-doc.mdx +0 -32
- package/emotion/es/components/Accordion/ui/AccordionItem/AccordionItem.js +14 -20
- package/emotion/es/components/TextArea/TextArea.js +2 -2
- package/emotion/es/components/TextArea/hooks/useAutoResize.js +2 -2
- package/emotion/es/examples/plasma_b2c/components/Accordion/Accordion.stories.tsx +1 -63
- package/emotion/es/examples/plasma_web/components/Accordion/Accordion.stories.tsx +1 -63
- package/es/components/Accordion/ui/AccordionItem/AccordionItem.js +14 -20
- package/es/components/Accordion/ui/AccordionItem/AccordionItem.js.map +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextArea/TextArea.js.map +1 -1
- package/es/components/TextArea/hooks/useAutoResize.js +2 -2
- package/es/components/TextArea/hooks/useAutoResize.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Accordion/Accordion.template-doc.mdx +0 -32
- package/styled-components/cjs/components/Accordion/ui/AccordionItem/AccordionItem.js +13 -19
- package/styled-components/cjs/components/TextArea/TextArea.js +1 -1
- package/styled-components/cjs/components/TextArea/hooks/useAutoResize.js +2 -2
- package/styled-components/cjs/examples/plasma_b2c/components/Accordion/Accordion.stories.tsx +1 -63
- package/styled-components/cjs/examples/plasma_web/components/Accordion/Accordion.stories.tsx +1 -63
- package/styled-components/es/components/Accordion/Accordion.template-doc.mdx +0 -32
- package/styled-components/es/components/Accordion/ui/AccordionItem/AccordionItem.js +14 -20
- package/styled-components/es/components/TextArea/TextArea.js +1 -1
- package/styled-components/es/components/TextArea/hooks/useAutoResize.js +2 -2
- package/styled-components/es/examples/plasma_b2c/components/Accordion/Accordion.stories.tsx +1 -63
- package/styled-components/es/examples/plasma_web/components/Accordion/Accordion.stories.tsx +1 -63
- package/types/components/Accordion/ui/AccordionItem/AccordionItem.d.ts +2 -17
- package/types/components/Accordion/ui/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/types/components/Accordion/ui/AccordionItem/AccordionItem.types.d.ts +9 -17
- package/types/components/Accordion/ui/AccordionItem/AccordionItem.types.d.ts.map +1 -1
- package/types/components/TextArea/hooks/useAutoResize.d.ts +1 -1
- package/types/components/TextArea/hooks/useAutoResize.d.ts.map +1 -1
package/styled-components/cjs/examples/plasma_web/components/Accordion/Accordion.stories.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react';
|
2
2
|
import type { ComponentProps, ReactNode } from 'react';
|
3
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
4
4
|
import { disableProps } from '@salutejs/plasma-sb-utils';
|
@@ -7,8 +7,6 @@ import { mergeConfig } from '../../../../engines';
|
|
7
7
|
import { WithTheme, argTypesFromConfig } from '../../../_helpers';
|
8
8
|
import { accordionConfig } from '../../../../components/Accordion';
|
9
9
|
import { Pin } from '../../../../utils/roundness';
|
10
|
-
import { IconButton } from '../IconButton/IconButton';
|
11
|
-
import { IconPlus } from '../../../../components/_Icon';
|
12
10
|
|
13
11
|
import { config } from './Accordion.config';
|
14
12
|
import { Accordion, AccordionItem } from './Accordion';
|
@@ -93,63 +91,3 @@ export const Default: StoryObj<AccordionProps> = {
|
|
93
91
|
);
|
94
92
|
},
|
95
93
|
};
|
96
|
-
|
97
|
-
const getSizeForIcon = (size) => (size === 'xs' ? 'xs' : 's');
|
98
|
-
|
99
|
-
const ControlledAccordion = (props: AccordionProps) => {
|
100
|
-
const args = { ...props, text: undefined };
|
101
|
-
const [activeFirst, setActiveFirst] = useState(false);
|
102
|
-
const [activeSecond, setActiveSecond] = useState(false);
|
103
|
-
const [activeThree, setActiveThree] = useState(false);
|
104
|
-
|
105
|
-
return (
|
106
|
-
<Accordion {...args}>
|
107
|
-
<AccordionItem
|
108
|
-
contentRight={
|
109
|
-
<IconButton view="secondary" size={args.size} onClick={() => setActiveFirst(!activeFirst)}>
|
110
|
-
<IconPlus size={getSizeForIcon(args.size)} />
|
111
|
-
</IconButton>
|
112
|
-
}
|
113
|
-
alignWithTitle={args.alignWithTitle}
|
114
|
-
type={args.type}
|
115
|
-
pin={args.pin}
|
116
|
-
title={args.title}
|
117
|
-
opened={activeFirst}
|
118
|
-
>
|
119
|
-
{args.body}
|
120
|
-
</AccordionItem>
|
121
|
-
<AccordionItem
|
122
|
-
contentRight={
|
123
|
-
<IconButton view="secondary" size={args.size} onClick={() => setActiveSecond(!activeSecond)}>
|
124
|
-
<IconPlus size={getSizeForIcon(args.size)} />
|
125
|
-
</IconButton>
|
126
|
-
}
|
127
|
-
alignWithTitle={args.alignWithTitle}
|
128
|
-
type={args.type}
|
129
|
-
pin={args.pin}
|
130
|
-
title={args.title}
|
131
|
-
opened={activeSecond}
|
132
|
-
>
|
133
|
-
{args.body}
|
134
|
-
</AccordionItem>
|
135
|
-
<AccordionItem
|
136
|
-
contentRight={
|
137
|
-
<IconButton view="secondary" size={args.size} onClick={() => setActiveThree(!activeThree)}>
|
138
|
-
<IconPlus size={getSizeForIcon(args.size)} />
|
139
|
-
</IconButton>
|
140
|
-
}
|
141
|
-
alignWithTitle={args.alignWithTitle}
|
142
|
-
type={args.type}
|
143
|
-
pin={args.pin}
|
144
|
-
title={args.title}
|
145
|
-
opened={activeThree}
|
146
|
-
>
|
147
|
-
{args.body}
|
148
|
-
</AccordionItem>
|
149
|
-
</Accordion>
|
150
|
-
);
|
151
|
-
};
|
152
|
-
|
153
|
-
export const Controlled: StoryObj<AccordionProps> = {
|
154
|
-
render: (props: AccordionProps) => ControlledAccordion(props),
|
155
|
-
};
|
@@ -135,38 +135,6 @@ import TabItem from '@theme/TabItem';
|
|
135
135
|
</TabItem>
|
136
136
|
</Tabs>
|
137
137
|
|
138
|
-
### Использование Accordion в Controlled варианте
|
139
|
-
|
140
|
-
```tsx live
|
141
|
-
import React, { useState } from 'react';
|
142
|
-
import { Accordion, AccordionItem, IconButton } from '@salutejs/{{ package }}';
|
143
|
-
import { IconPlus } from '@salutejs/plasma-icons';
|
144
|
-
|
145
|
-
export function App() {
|
146
|
-
const [activeFirst, setActiveFirst] = useState(false);
|
147
|
-
const [activeSecond, setActiveSecond] = useState(false);
|
148
|
-
const [activeThree, setActiveThree] = useState(false);
|
149
|
-
|
150
|
-
const contentRight = (active, setActive) => {
|
151
|
-
return (
|
152
|
-
<IconButton view="secondary" size="s" onClick={() => setActive(!active)}>
|
153
|
-
<IconPlus size="xs" />
|
154
|
-
</IconButton>
|
155
|
-
)
|
156
|
-
}
|
157
|
-
|
158
|
-
return (
|
159
|
-
<div>
|
160
|
-
<Accordion size="s" singleActive={true}>
|
161
|
-
<AccordionItem opened={activeFirst} contentRight={contentRight(activeFirst, setActiveFirst)} type="arrow" title="Как оплатить заправку бонусами СберСпасибо?">После указания деталей заправки нажмите кнопку «К оплате». Откроется окно оплаты, где вы сможете списать бонусы и оплатить ими до 99% стоимости топлива</AccordionItem>
|
162
|
-
<AccordionItem opened={activeSecond} contentRight={contentRight(activeSecond, setActiveSecond)} type="arrow" title="Как оплатить заправку бонусами СберСпасибо?">После указания деталей заправки нажмите кнопку «К оплате». Откроется окно оплаты, где вы сможете списать бонусы и оплатить ими до 99% стоимости топлива</AccordionItem>
|
163
|
-
<AccordionItem opened={activeThree} contentRight={contentRight(activeThree, setActiveThree)} type="arrow" title="Как оплатить заправку бонусами СберСпасибо?">После указания деталей заправки нажмите кнопку «К оплате». Откроется окно оплаты, где вы сможете списать бонусы и оплатить ими до 99% стоимости топлива</AccordionItem>
|
164
|
-
</Accordion>
|
165
|
-
</div>
|
166
|
-
);
|
167
|
-
}
|
168
|
-
```
|
169
|
-
|
170
138
|
### Использование Accordion SingleActive
|
171
139
|
|
172
140
|
```tsx live
|
@@ -11,12 +11,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
11
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
12
12
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
14
|
-
import React, { useState, useRef,
|
14
|
+
import React, { useState, useRef, useEffect } from 'react';
|
15
15
|
import { convertRoundnessMatrix } from '../../../../utils/roundness';
|
16
16
|
import { classes, tokens } from '../../Accordion.tokens';
|
17
17
|
import { cx } from '../../../../utils';
|
18
18
|
import { StyledAccordionItem, StyledAccordionHeader, StyledAccordionBody, StyledAccordionTitle, StyledAccordionContentLeft, StyledAccordionHeaderLeft, StyledAccordionContentRight, StyledArrow, StyledMinus, StyledPlus, StyledAccordionBodyAnimate } from './AccordionItem.styles';
|
19
|
-
export var AccordionItem =
|
19
|
+
export var AccordionItem = function AccordionItem(_ref) {
|
20
20
|
var _ref2;
|
21
21
|
var value = _ref.value,
|
22
22
|
contentRight = _ref.contentRight,
|
@@ -34,10 +34,8 @@ export var AccordionItem = /*#__PURE__*/forwardRef(function (_ref, outerRef) {
|
|
34
34
|
disabled = _ref.disabled,
|
35
35
|
_ref$alignWithTitle = _ref.alignWithTitle,
|
36
36
|
alignWithTitle = _ref$alignWithTitle === void 0 ? true : _ref$alignWithTitle,
|
37
|
-
opened = _ref.opened,
|
38
37
|
view = _ref.view,
|
39
|
-
onChange = _ref.onChange
|
40
|
-
onClick = _ref.onClick;
|
38
|
+
onChange = _ref.onChange;
|
41
39
|
var key = (_ref2 = eventKey !== null && eventKey !== void 0 ? eventKey : index) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
42
40
|
var _useState = useState(),
|
43
41
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -50,9 +48,6 @@ export var AccordionItem = /*#__PURE__*/forwardRef(function (_ref, outerRef) {
|
|
50
48
|
if (onChange) {
|
51
49
|
onChange(key, !value);
|
52
50
|
}
|
53
|
-
if (onClick) {
|
54
|
-
onClick(key, !value);
|
55
|
-
}
|
56
51
|
};
|
57
52
|
var leftContentRef = useRef(null);
|
58
53
|
useEffect(function () {
|
@@ -61,11 +56,11 @@ export var AccordionItem = /*#__PURE__*/forwardRef(function (_ref, outerRef) {
|
|
61
56
|
var leftPaddingBody = leftContentWidth && (alignWithTitle || view === 'clear') ? "calc(".concat(leftContentWidth, "px + var(").concat(tokens.accordionItemGap, "))") : 0;
|
62
57
|
setLeftPadding(leftPaddingBody);
|
63
58
|
}, [value, type, leftContentRef, setLeftPadding]);
|
64
|
-
var openedBodyClass =
|
65
|
-
var
|
59
|
+
var openedBodyClass = value ? classes.accordionItemShowBody : undefined;
|
60
|
+
var StyledAnimationPLus = function StyledAnimationPLus() {
|
66
61
|
return /*#__PURE__*/React.createElement(StyledPlus, null, _StyledMinus || (_StyledMinus = /*#__PURE__*/React.createElement(StyledMinus, {
|
67
62
|
size: "xs",
|
68
|
-
color: "
|
63
|
+
color: "inhert"
|
69
64
|
})), /*#__PURE__*/React.createElement(StyledMinus, {
|
70
65
|
size: "xs",
|
71
66
|
color: "inhert",
|
@@ -76,15 +71,14 @@ export var AccordionItem = /*#__PURE__*/forwardRef(function (_ref, outerRef) {
|
|
76
71
|
var disabledClass = disabled ? classes.accordionDisabled : '';
|
77
72
|
var leftContent = contentLeft !== null && contentLeft !== void 0 ? contentLeft : type === 'arrow' ? _StyledArrow || (_StyledArrow = /*#__PURE__*/React.createElement(StyledArrow, {
|
78
73
|
size: "xs",
|
79
|
-
color: "
|
74
|
+
color: "inhert"
|
80
75
|
})) : undefined;
|
81
|
-
var leftContentRotate = type === 'arrow' &&
|
82
|
-
var rightContent = contentRight !== null && contentRight !== void 0 ? contentRight : type === 'sign' ? /*#__PURE__*/React.createElement(
|
83
|
-
var rightContentRotate = type === 'sign' &&
|
76
|
+
var leftContentRotate = type === 'arrow' && value ? classes.accordionItemShowBody : undefined;
|
77
|
+
var rightContent = contentRight !== null && contentRight !== void 0 ? contentRight : type === 'sign' ? /*#__PURE__*/React.createElement(StyledAnimationPLus, null) : undefined;
|
78
|
+
var rightContentRotate = type === 'sign' && value ? classes.accordionItemShowBody : undefined;
|
84
79
|
return /*#__PURE__*/React.createElement(StyledAccordionItem, {
|
85
80
|
className: cx(classes.accordionItem, className, disabledClass),
|
86
81
|
key: key,
|
87
|
-
ref: outerRef,
|
88
82
|
style: _objectSpread({
|
89
83
|
borderRadius: accordionBorderRadius
|
90
84
|
}, style)
|
@@ -92,17 +86,17 @@ export var AccordionItem = /*#__PURE__*/forwardRef(function (_ref, outerRef) {
|
|
92
86
|
role: "tab",
|
93
87
|
tabIndex: 0,
|
94
88
|
onClick: handleOpen,
|
95
|
-
"aria-expanded":
|
89
|
+
"aria-expanded": value,
|
96
90
|
"aria-controls": "accordion-item-section".concat(key),
|
97
91
|
id: "accordion-item-".concat(key)
|
98
92
|
}, /*#__PURE__*/React.createElement(StyledAccordionHeaderLeft, null, leftContent && /*#__PURE__*/React.createElement(StyledAccordionContentLeft, {
|
99
93
|
ref: leftContentRef,
|
100
94
|
className: leftContentRotate
|
101
|
-
}, leftContent), /*#__PURE__*/React.createElement(StyledAccordionTitle, null, title)),
|
95
|
+
}, leftContent), /*#__PURE__*/React.createElement(StyledAccordionTitle, null, title)), /*#__PURE__*/React.createElement(StyledAccordionContentRight, {
|
102
96
|
className: rightContentRotate
|
103
97
|
}, rightContent && rightContent)), /*#__PURE__*/React.createElement(StyledAccordionBodyAnimate, {
|
104
98
|
"aria-labelledby": "accordion-item-".concat(key),
|
105
|
-
"aria-hidden": !
|
99
|
+
"aria-hidden": !value,
|
106
100
|
id: "accordion-item-section".concat(key),
|
107
101
|
className: cx(openedBodyClass),
|
108
102
|
style: {
|
@@ -111,4 +105,4 @@ export var AccordionItem = /*#__PURE__*/forwardRef(function (_ref, outerRef) {
|
|
111
105
|
}, /*#__PURE__*/React.createElement(StyledAccordionBody, {
|
112
106
|
className: classes.accordionItemBody
|
113
107
|
}, children)));
|
114
|
-
}
|
108
|
+
};
|
@@ -142,7 +142,7 @@ export var textAreaRoot = function textAreaRoot(Root) {
|
|
142
142
|
setHelperWidth("".concat(elementWidth / ROOT_FONT_SIZE, "rem"));
|
143
143
|
}
|
144
144
|
});
|
145
|
-
useAutoResize(autoResize || Boolean(clear), outerRef, value, minAuto, maxAuto);
|
145
|
+
useAutoResize(autoResize || Boolean(clear), outerRef, value, minAuto, maxAuto, defaultValue);
|
146
146
|
var onFocusHandler = useCallback(function () {
|
147
147
|
setFocused(true);
|
148
148
|
}, []);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
2
2
|
export var ROOT_FONT_SIZE = 16;
|
3
|
-
export var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto) {
|
3
|
+
export var useAutoResize = function useAutoResize(active, ref, value, minAuto, maxAuto, defaultValue) {
|
4
4
|
var isManualResize = useRef(false);
|
5
5
|
var previousHeight = useRef();
|
6
6
|
useEffect(function () {
|
@@ -23,5 +23,5 @@ export var useAutoResize = function useAutoResize(active, ref, value, minAuto, m
|
|
23
23
|
ref.current.style.height = "".concat(newHeight, "rem");
|
24
24
|
previousHeight.current = newHeight;
|
25
25
|
}
|
26
|
-
}, [ref, active, value]);
|
26
|
+
}, [ref, active, value, defaultValue]);
|
27
27
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react';
|
2
2
|
import type { ComponentProps, ReactNode } from 'react';
|
3
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
4
4
|
import { disableProps } from '@salutejs/plasma-sb-utils';
|
@@ -7,8 +7,6 @@ import { mergeConfig } from '../../../../engines';
|
|
7
7
|
import { WithTheme, argTypesFromConfig } from '../../../_helpers';
|
8
8
|
import { accordionConfig } from '../../../../components/Accordion';
|
9
9
|
import { Pin } from '../../../../utils/roundness';
|
10
|
-
import { IconButton } from '../IconButton/IconButton';
|
11
|
-
import { IconPlus } from '../../../../components/_Icon';
|
12
10
|
|
13
11
|
import { config } from './Accordion.config';
|
14
12
|
import { Accordion, AccordionItem } from './Accordion';
|
@@ -93,63 +91,3 @@ export const Default: StoryObj<AccordionProps> = {
|
|
93
91
|
);
|
94
92
|
},
|
95
93
|
};
|
96
|
-
|
97
|
-
const getSizeForIcon = (size) => (size === 'xs' ? 'xs' : 's');
|
98
|
-
|
99
|
-
const ControlledAccordion = (props: AccordionProps) => {
|
100
|
-
const args = { ...props, text: undefined };
|
101
|
-
const [activeFirst, setActiveFirst] = useState(false);
|
102
|
-
const [activeSecond, setActiveSecond] = useState(false);
|
103
|
-
const [activeThree, setActiveThree] = useState(false);
|
104
|
-
|
105
|
-
return (
|
106
|
-
<Accordion {...args}>
|
107
|
-
<AccordionItem
|
108
|
-
contentRight={
|
109
|
-
<IconButton view="secondary" size={args.size} onClick={() => setActiveFirst(!activeFirst)}>
|
110
|
-
<IconPlus size={getSizeForIcon(args.size)} />
|
111
|
-
</IconButton>
|
112
|
-
}
|
113
|
-
alignWithTitle={args.alignWithTitle}
|
114
|
-
type={args.type}
|
115
|
-
pin={args.pin}
|
116
|
-
title={args.title}
|
117
|
-
opened={activeFirst}
|
118
|
-
>
|
119
|
-
{args.body}
|
120
|
-
</AccordionItem>
|
121
|
-
<AccordionItem
|
122
|
-
contentRight={
|
123
|
-
<IconButton view="secondary" size={args.size} onClick={() => setActiveSecond(!activeSecond)}>
|
124
|
-
<IconPlus size={getSizeForIcon(args.size)} />
|
125
|
-
</IconButton>
|
126
|
-
}
|
127
|
-
alignWithTitle={args.alignWithTitle}
|
128
|
-
type={args.type}
|
129
|
-
pin={args.pin}
|
130
|
-
title={args.title}
|
131
|
-
opened={activeSecond}
|
132
|
-
>
|
133
|
-
{args.body}
|
134
|
-
</AccordionItem>
|
135
|
-
<AccordionItem
|
136
|
-
contentRight={
|
137
|
-
<IconButton view="secondary" size={args.size} onClick={() => setActiveThree(!activeThree)}>
|
138
|
-
<IconPlus size={getSizeForIcon(args.size)} />
|
139
|
-
</IconButton>
|
140
|
-
}
|
141
|
-
alignWithTitle={args.alignWithTitle}
|
142
|
-
type={args.type}
|
143
|
-
pin={args.pin}
|
144
|
-
title={args.title}
|
145
|
-
opened={activeThree}
|
146
|
-
>
|
147
|
-
{args.body}
|
148
|
-
</AccordionItem>
|
149
|
-
</Accordion>
|
150
|
-
);
|
151
|
-
};
|
152
|
-
|
153
|
-
export const Controlled: StoryObj<AccordionProps> = {
|
154
|
-
render: (props: AccordionProps) => ControlledAccordion(props),
|
155
|
-
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React
|
1
|
+
import React from 'react';
|
2
2
|
import type { ComponentProps, ReactNode } from 'react';
|
3
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
4
4
|
import { disableProps } from '@salutejs/plasma-sb-utils';
|
@@ -7,8 +7,6 @@ import { mergeConfig } from '../../../../engines';
|
|
7
7
|
import { WithTheme, argTypesFromConfig } from '../../../_helpers';
|
8
8
|
import { accordionConfig } from '../../../../components/Accordion';
|
9
9
|
import { Pin } from '../../../../utils/roundness';
|
10
|
-
import { IconButton } from '../IconButton/IconButton';
|
11
|
-
import { IconPlus } from '../../../../components/_Icon';
|
12
10
|
|
13
11
|
import { config } from './Accordion.config';
|
14
12
|
import { Accordion, AccordionItem } from './Accordion';
|
@@ -93,63 +91,3 @@ export const Default: StoryObj<AccordionProps> = {
|
|
93
91
|
);
|
94
92
|
},
|
95
93
|
};
|
96
|
-
|
97
|
-
const getSizeForIcon = (size) => (size === 'xs' ? 'xs' : 's');
|
98
|
-
|
99
|
-
const ControlledAccordion = (props: AccordionProps) => {
|
100
|
-
const args = { ...props, text: undefined };
|
101
|
-
const [activeFirst, setActiveFirst] = useState(false);
|
102
|
-
const [activeSecond, setActiveSecond] = useState(false);
|
103
|
-
const [activeThree, setActiveThree] = useState(false);
|
104
|
-
|
105
|
-
return (
|
106
|
-
<Accordion {...args}>
|
107
|
-
<AccordionItem
|
108
|
-
contentRight={
|
109
|
-
<IconButton view="secondary" size={args.size} onClick={() => setActiveFirst(!activeFirst)}>
|
110
|
-
<IconPlus size={getSizeForIcon(args.size)} />
|
111
|
-
</IconButton>
|
112
|
-
}
|
113
|
-
alignWithTitle={args.alignWithTitle}
|
114
|
-
type={args.type}
|
115
|
-
pin={args.pin}
|
116
|
-
title={args.title}
|
117
|
-
opened={activeFirst}
|
118
|
-
>
|
119
|
-
{args.body}
|
120
|
-
</AccordionItem>
|
121
|
-
<AccordionItem
|
122
|
-
contentRight={
|
123
|
-
<IconButton view="secondary" size={args.size} onClick={() => setActiveSecond(!activeSecond)}>
|
124
|
-
<IconPlus size={getSizeForIcon(args.size)} />
|
125
|
-
</IconButton>
|
126
|
-
}
|
127
|
-
alignWithTitle={args.alignWithTitle}
|
128
|
-
type={args.type}
|
129
|
-
pin={args.pin}
|
130
|
-
title={args.title}
|
131
|
-
opened={activeSecond}
|
132
|
-
>
|
133
|
-
{args.body}
|
134
|
-
</AccordionItem>
|
135
|
-
<AccordionItem
|
136
|
-
contentRight={
|
137
|
-
<IconButton view="secondary" size={args.size} onClick={() => setActiveThree(!activeThree)}>
|
138
|
-
<IconPlus size={getSizeForIcon(args.size)} />
|
139
|
-
</IconButton>
|
140
|
-
}
|
141
|
-
alignWithTitle={args.alignWithTitle}
|
142
|
-
type={args.type}
|
143
|
-
pin={args.pin}
|
144
|
-
title={args.title}
|
145
|
-
opened={activeThree}
|
146
|
-
>
|
147
|
-
{args.body}
|
148
|
-
</AccordionItem>
|
149
|
-
</Accordion>
|
150
|
-
);
|
151
|
-
};
|
152
|
-
|
153
|
-
export const Controlled: StoryObj<AccordionProps> = {
|
154
|
-
render: (props: AccordionProps) => ControlledAccordion(props),
|
155
|
-
};
|
@@ -1,19 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
|
3
|
-
|
4
|
-
type?: "arrow" | "clear" | "sign" | undefined;
|
5
|
-
contentLeft?: React.ReactNode;
|
6
|
-
alignWithTitle?: boolean | undefined;
|
7
|
-
contentRight?: React.ReactNode;
|
8
|
-
pin?: "square-square" | "square-clear" | "clear-square" | "clear-clear" | "clear-circle" | "circle-clear" | "circle-circle" | undefined;
|
9
|
-
title?: React.ReactNode;
|
10
|
-
children: React.ReactNode;
|
11
|
-
onChange?: ((index: number, value: boolean) => void) | undefined;
|
12
|
-
onClick?: ((index: number, value: boolean) => void) | undefined;
|
13
|
-
disabled?: boolean | undefined;
|
14
|
-
opened?: boolean | undefined;
|
15
|
-
eventKey?: number | undefined;
|
16
|
-
index?: number | undefined;
|
17
|
-
view?: string | undefined;
|
18
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
2
|
+
import type { AccordionItemProps } from './AccordionItem.types';
|
3
|
+
export declare const AccordionItem: React.FC<AccordionItemProps>;
|
19
4
|
//# sourceMappingURL=AccordionItem.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/Accordion/ui/AccordionItem/AccordionItem.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/Accordion/ui/AccordionItem/AccordionItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAmB3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAqGtD,CAAC"}
|
@@ -2,7 +2,7 @@ import type { ReactNode, HTMLAttributes } from 'react';
|
|
2
2
|
import type { Pin } from '../../../../utils/roundness';
|
3
3
|
declare type Props = {
|
4
4
|
/**
|
5
|
-
* Значение раскрытия
|
5
|
+
* Значение раскрытия accordion
|
6
6
|
*/
|
7
7
|
value?: boolean;
|
8
8
|
/**
|
@@ -22,39 +22,31 @@ declare type Props = {
|
|
22
22
|
*/
|
23
23
|
contentRight?: ReactNode;
|
24
24
|
/**
|
25
|
-
* Скругление
|
25
|
+
* Скругление accordion
|
26
26
|
*/
|
27
27
|
pin?: Pin;
|
28
28
|
/**
|
29
|
-
* Заголовок
|
29
|
+
* Заголовок accordion
|
30
30
|
*/
|
31
|
-
title
|
31
|
+
title: ReactNode;
|
32
32
|
/**
|
33
|
-
* Контент
|
33
|
+
* Контент аккордеона
|
34
34
|
*/
|
35
35
|
children: ReactNode;
|
36
36
|
/**
|
37
|
-
* @deprecated Внутренняя функция при открытии accordion (будет удалена в ближайшее время)
|
37
|
+
* @deprecated Внутренняя функция при открытии accordion (будет удалена в ближайшее время)
|
38
38
|
*/
|
39
39
|
onChange?: (index: number, value: boolean) => void;
|
40
40
|
/**
|
41
|
-
*
|
42
|
-
*/
|
43
|
-
onClick?: (index: number, value: boolean) => void;
|
44
|
-
/**
|
45
|
-
* Блокировка элемента accordion
|
41
|
+
* Блокировка элемента
|
46
42
|
*/
|
47
43
|
disabled?: boolean;
|
48
44
|
/**
|
49
|
-
*
|
50
|
-
*/
|
51
|
-
opened?: boolean;
|
52
|
-
/**
|
53
|
-
* Индекс элемента accordion, который необходимо автоматически открыть
|
45
|
+
* Индекс элемента, который необходимо автоматически открыть
|
54
46
|
*/
|
55
47
|
eventKey?: number;
|
56
48
|
/**
|
57
|
-
* @deprecated Внутреннее свойство индекс элемента
|
49
|
+
* @deprecated Внутреннее свойство индекс элемента (будет удалено в ближайшее время)
|
58
50
|
*/
|
59
51
|
index?: number;
|
60
52
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AccordionItem.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Accordion/ui/AccordionItem/AccordionItem.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAEvD,aAAK,KAAK,GAAG;IACT;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;IAElC;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IAEzB;;OAEG;IACH,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV;;OAEG;IACH,KAAK,
|
1
|
+
{"version":3,"file":"AccordionItem.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Accordion/ui/AccordionItem/AccordionItem.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAEvD,aAAK,KAAK,GAAG;IACT;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;IAElC;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IAEzB;;OAEG;IACH,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAEnD;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAMnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,kBAAkB,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,KAAK,CAAC"}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { MutableRefObject } from 'react';
|
2
2
|
export declare const ROOT_FONT_SIZE = 16;
|
3
|
-
export declare const useAutoResize: <T extends HTMLTextAreaElement>(active: boolean, ref: MutableRefObject<T | null>, value?: string | number | readonly string[] | undefined, minAuto?: number | undefined, maxAuto?: number | undefined) => void;
|
3
|
+
export declare const useAutoResize: <T extends HTMLTextAreaElement>(active: boolean, ref: MutableRefObject<T | null>, value?: string | number | readonly string[] | undefined, minAuto?: number | undefined, maxAuto?: number | undefined, defaultValue?: string | number | readonly string[] | undefined) => void;
|
4
4
|
//# sourceMappingURL=useAutoResize.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAutoResize.d.ts","sourceRoot":"","sources":["../../../../src/components/TextArea/hooks/useAutoResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE5D,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,eAAO,MAAM,aAAa,0CACd,OAAO,+
|
1
|
+
{"version":3,"file":"useAutoResize.d.ts","sourceRoot":"","sources":["../../../../src/components/TextArea/hooks/useAutoResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE5D,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,eAAO,MAAM,aAAa,0CACd,OAAO,+NAqClB,CAAC"}
|