@salutejs/plasma-new-hope 0.170.0-canary.1484.11388945571.0 → 0.170.0-canary.1488.11387414081.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/ViewContainer/ViewContainer.js +38 -0
- package/cjs/components/ViewContainer/ViewContainer.js.map +1 -0
- package/cjs/components/ViewContainer/ViewContainer_yiqfcb.css +1 -0
- package/cjs/components/ViewContainer/_view/base.js +9 -0
- package/cjs/components/ViewContainer/_view/base.js.map +1 -0
- package/cjs/components/ViewContainer/_view/base_x642ct.css +1 -0
- package/cjs/index.css +2 -0
- package/cjs/index.js +3 -0
- package/cjs/index.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/ViewContainer/ViewContainer.js +49 -0
- package/emotion/cjs/components/ViewContainer/ViewContainer.template-doc.mdx +82 -0
- package/emotion/cjs/components/ViewContainer/_view/base.js +8 -0
- package/emotion/cjs/components/ViewContainer/_view/tokens.json +1 -0
- package/emotion/cjs/components/ViewContainer/index.js +18 -0
- package/emotion/cjs/examples/_helpers.js +3 -14
- package/emotion/cjs/examples/plasma_b2c/components/Accordion/Accordion.stories.tsx +1 -63
- package/emotion/cjs/examples/plasma_b2c/components/ViewContainer/ViewContainer.config.js +16 -0
- package/emotion/cjs/examples/plasma_b2c/components/ViewContainer/ViewContainer.js +11 -0
- package/emotion/cjs/examples/plasma_b2c/components/ViewContainer/ViewContainer.stories.tsx +65 -0
- package/emotion/cjs/examples/plasma_web/components/Accordion/Accordion.stories.tsx +1 -63
- package/emotion/cjs/examples/plasma_web/components/ViewContainer/ViewContainer.config.js +16 -0
- package/emotion/cjs/examples/plasma_web/components/ViewContainer/ViewContainer.js +11 -0
- package/emotion/cjs/examples/plasma_web/components/ViewContainer/ViewContainer.stories.tsx +65 -0
- package/emotion/cjs/index.js +11 -0
- 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/ViewContainer/ViewContainer.js +40 -0
- package/emotion/es/components/ViewContainer/ViewContainer.template-doc.mdx +82 -0
- package/emotion/es/components/ViewContainer/_view/base.js +2 -0
- package/emotion/es/components/ViewContainer/_view/tokens.json +1 -0
- package/emotion/es/components/ViewContainer/index.js +1 -0
- package/emotion/es/examples/_helpers.js +3 -14
- package/emotion/es/examples/plasma_b2c/components/Accordion/Accordion.stories.tsx +1 -63
- package/emotion/es/examples/plasma_b2c/components/ViewContainer/ViewContainer.config.js +10 -0
- package/emotion/es/examples/plasma_b2c/components/ViewContainer/ViewContainer.js +5 -0
- package/emotion/es/examples/plasma_b2c/components/ViewContainer/ViewContainer.stories.tsx +65 -0
- package/emotion/es/examples/plasma_web/components/Accordion/Accordion.stories.tsx +1 -63
- package/emotion/es/examples/plasma_web/components/ViewContainer/ViewContainer.config.js +10 -0
- package/emotion/es/examples/plasma_web/components/ViewContainer/ViewContainer.js +5 -0
- package/emotion/es/examples/plasma_web/components/ViewContainer/ViewContainer.stories.tsx +65 -0
- package/emotion/es/index.js +2 -1
- package/es/components/Accordion/ui/AccordionItem/AccordionItem.js +14 -20
- package/es/components/Accordion/ui/AccordionItem/AccordionItem.js.map +1 -1
- package/es/components/ViewContainer/ViewContainer.js +33 -0
- package/es/components/ViewContainer/ViewContainer.js.map +1 -0
- package/es/components/ViewContainer/ViewContainer_yiqfcb.css +1 -0
- package/es/components/ViewContainer/_view/base.js +5 -0
- package/es/components/ViewContainer/_view/base.js.map +1 -0
- package/es/components/ViewContainer/_view/base_x642ct.css +1 -0
- package/es/index.css +2 -0
- package/es/index.js +1 -0
- package/es/index.js.map +1 -1
- package/package.json +3 -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/ViewContainer/ViewContainer.js +40 -0
- package/styled-components/cjs/components/ViewContainer/ViewContainer.template-doc.mdx +82 -0
- package/styled-components/cjs/components/ViewContainer/_view/base.js +8 -0
- package/styled-components/cjs/components/ViewContainer/_view/tokens.json +1 -0
- package/styled-components/cjs/components/ViewContainer/index.js +18 -0
- package/styled-components/cjs/examples/_helpers.js +3 -14
- package/styled-components/cjs/examples/plasma_b2c/components/Accordion/Accordion.stories.tsx +1 -63
- package/styled-components/cjs/examples/plasma_b2c/components/ViewContainer/ViewContainer.config.js +16 -0
- package/styled-components/cjs/examples/plasma_b2c/components/ViewContainer/ViewContainer.js +11 -0
- package/styled-components/cjs/examples/plasma_b2c/components/ViewContainer/ViewContainer.stories.tsx +65 -0
- package/styled-components/cjs/examples/plasma_web/components/Accordion/Accordion.stories.tsx +1 -63
- package/styled-components/cjs/examples/plasma_web/components/ViewContainer/ViewContainer.config.js +16 -0
- package/styled-components/cjs/examples/plasma_web/components/ViewContainer/ViewContainer.js +11 -0
- package/styled-components/cjs/examples/plasma_web/components/ViewContainer/ViewContainer.stories.tsx +65 -0
- package/styled-components/cjs/index.js +11 -0
- 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/ViewContainer/ViewContainer.js +31 -0
- package/styled-components/es/components/ViewContainer/ViewContainer.template-doc.mdx +82 -0
- package/styled-components/es/components/ViewContainer/_view/base.js +2 -0
- package/styled-components/es/components/ViewContainer/_view/tokens.json +1 -0
- package/styled-components/es/components/ViewContainer/index.js +1 -0
- package/styled-components/es/examples/_helpers.js +3 -14
- package/styled-components/es/examples/plasma_b2c/components/Accordion/Accordion.stories.tsx +1 -63
- package/styled-components/es/examples/plasma_b2c/components/ViewContainer/ViewContainer.config.js +10 -0
- package/styled-components/es/examples/plasma_b2c/components/ViewContainer/ViewContainer.js +5 -0
- package/styled-components/es/examples/plasma_b2c/components/ViewContainer/ViewContainer.stories.tsx +65 -0
- package/styled-components/es/examples/plasma_web/components/Accordion/Accordion.stories.tsx +1 -63
- package/styled-components/es/examples/plasma_web/components/ViewContainer/ViewContainer.config.js +10 -0
- package/styled-components/es/examples/plasma_web/components/ViewContainer/ViewContainer.js +5 -0
- package/styled-components/es/examples/plasma_web/components/ViewContainer/ViewContainer.stories.tsx +65 -0
- package/styled-components/es/index.js +2 -1
- 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 +8 -16
- package/types/components/Accordion/ui/AccordionItem/AccordionItem.types.d.ts.map +1 -1
- package/types/components/ViewContainer/ViewContainer.d.ts +26 -0
- package/types/components/ViewContainer/ViewContainer.d.ts.map +1 -0
- package/types/components/ViewContainer/_view/base.d.ts +2 -0
- package/types/components/ViewContainer/_view/base.d.ts.map +1 -0
- package/types/components/ViewContainer/index.d.ts +2 -0
- package/types/components/ViewContainer/index.d.ts.map +1 -0
- package/types/examples/_helpers.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/ViewContainer/ViewContainer.config.d.ts +9 -0
- package/types/examples/plasma_b2c/components/ViewContainer/ViewContainer.config.d.ts.map +1 -0
- package/types/examples/plasma_b2c/components/ViewContainer/ViewContainer.d.ts +8 -0
- package/types/examples/plasma_b2c/components/ViewContainer/ViewContainer.d.ts.map +1 -0
- package/types/examples/plasma_web/components/ViewContainer/ViewContainer.config.d.ts +9 -0
- package/types/examples/plasma_web/components/ViewContainer/ViewContainer.config.d.ts.map +1 -0
- package/types/examples/plasma_web/components/ViewContainer/ViewContainer.d.ts +8 -0
- package/types/examples/plasma_web/components/ViewContainer/ViewContainer.d.ts.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/emotion/cjs/examples/themes/declaration.d.ts +0 -4
- package/emotion/cjs/examples/themes/index.js +0 -15
- package/emotion/cjs/examples/themes/plasma_b2c.module.css +0 -984
- package/emotion/cjs/examples/themes/plasma_web.module.css +0 -984
- package/emotion/es/examples/themes/declaration.d.ts +0 -4
- package/emotion/es/examples/themes/index.js +0 -7
- package/emotion/es/examples/themes/plasma_b2c.module.css +0 -984
- package/emotion/es/examples/themes/plasma_web.module.css +0 -984
- package/styled-components/cjs/examples/themes/declaration.d.ts +0 -4
- package/styled-components/cjs/examples/themes/index.js +0 -15
- package/styled-components/cjs/examples/themes/plasma_b2c.module.css +0 -984
- package/styled-components/cjs/examples/themes/plasma_web.module.css +0 -984
- package/styled-components/es/examples/themes/declaration.d.ts +0 -4
- package/styled-components/es/examples/themes/index.js +0 -7
- package/styled-components/es/examples/themes/plasma_b2c.module.css +0 -984
- package/styled-components/es/examples/themes/plasma_web.module.css +0 -984
- package/types/examples/themes/index.d.ts +0 -6
- package/types/examples/themes/index.d.ts.map +0 -1
package/styled-components/cjs/examples/plasma_web/components/ViewContainer/ViewContainer.stories.tsx
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
import React, { ComponentProps } from 'react';
|
2
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
3
|
+
|
4
|
+
import { Button } from '../Button/Button';
|
5
|
+
import { TextField } from '../Textfield/Textfield';
|
6
|
+
import { Checkbox } from '../Checkbox/Checkbox';
|
7
|
+
|
8
|
+
import { ViewContainer } from './ViewContainer';
|
9
|
+
|
10
|
+
type StoryViewProps = ComponentProps<typeof ViewContainer>;
|
11
|
+
|
12
|
+
const meta: Meta<StoryViewProps> = {
|
13
|
+
title: 'plasma_web/ViewContainer',
|
14
|
+
};
|
15
|
+
|
16
|
+
export default meta;
|
17
|
+
|
18
|
+
type Story = StoryObj<StoryViewProps>;
|
19
|
+
|
20
|
+
const ViewExample = ({ view }: StoryViewProps) => {
|
21
|
+
const style = view
|
22
|
+
? {
|
23
|
+
background: view === 'onDark' ? '#1a1a1a' : '#ededed',
|
24
|
+
color: view === 'onDark' ? 'white' : 'black',
|
25
|
+
}
|
26
|
+
: undefined;
|
27
|
+
|
28
|
+
return (
|
29
|
+
<>
|
30
|
+
<h4>view: {view ?? 'default'}</h4>
|
31
|
+
<div>
|
32
|
+
<ViewContainer
|
33
|
+
view={view}
|
34
|
+
style={{
|
35
|
+
...style,
|
36
|
+
padding: '1rem',
|
37
|
+
borderRadius: '1rem',
|
38
|
+
display: 'flex',
|
39
|
+
flexDirection: 'column',
|
40
|
+
gap: '1rem',
|
41
|
+
}}
|
42
|
+
>
|
43
|
+
<h3 style={{ margin: 0 }}>Inside ViewContainer</h3>
|
44
|
+
<Button text="default Button" />
|
45
|
+
<Checkbox checked label="Label" />
|
46
|
+
<TextField value="Example Value" label="Label" labelPlacement="inner" />
|
47
|
+
</ViewContainer>
|
48
|
+
</div>
|
49
|
+
</>
|
50
|
+
);
|
51
|
+
};
|
52
|
+
|
53
|
+
export const Default: Story = {
|
54
|
+
render: () => {
|
55
|
+
return (
|
56
|
+
<>
|
57
|
+
<ViewExample />
|
58
|
+
<br />
|
59
|
+
<ViewExample view="onDark" />
|
60
|
+
<br />
|
61
|
+
<ViewExample view="onLight" />
|
62
|
+
</>
|
63
|
+
);
|
64
|
+
},
|
65
|
+
};
|
@@ -673,4 +673,15 @@ Object.keys(_Attach).forEach(function (key) {
|
|
673
673
|
return _Attach[key];
|
674
674
|
}
|
675
675
|
});
|
676
|
+
});
|
677
|
+
var _ViewContainer = /*#__PURE__*/require("./components/ViewContainer");
|
678
|
+
Object.keys(_ViewContainer).forEach(function (key) {
|
679
|
+
if (key === "default" || key === "__esModule") return;
|
680
|
+
if (key in exports && exports[key] === _ViewContainer[key]) return;
|
681
|
+
Object.defineProperty(exports, key, {
|
682
|
+
enumerable: true,
|
683
|
+
get: function get() {
|
684
|
+
return _ViewContainer[key];
|
685
|
+
}
|
686
|
+
});
|
676
687
|
});
|
@@ -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
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
var _excluded = ["children"];
|
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
|
+
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
|
+
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
|
+
import React, { forwardRef } from 'react';
|
6
|
+
import { css } from 'styled-components';
|
7
|
+
import { base as viewCSS } from './_view/base';
|
8
|
+
var base = /*#__PURE__*/css(["position:relative;"]);
|
9
|
+
export var viewContainerRoot = function viewContainerRoot(Root) {
|
10
|
+
return /*#__PURE__*/forwardRef(function (props, ref) {
|
11
|
+
var children = props.children,
|
12
|
+
rest = _objectWithoutProperties(props, _excluded);
|
13
|
+
return /*#__PURE__*/React.createElement(Root, _extends({
|
14
|
+
ref: ref
|
15
|
+
}, rest), children);
|
16
|
+
});
|
17
|
+
};
|
18
|
+
export var viewContainerConfig = {
|
19
|
+
name: 'ViewContainer',
|
20
|
+
tag: 'div',
|
21
|
+
layout: viewContainerRoot,
|
22
|
+
base: base,
|
23
|
+
variations: {
|
24
|
+
view: {
|
25
|
+
css: viewCSS
|
26
|
+
}
|
27
|
+
},
|
28
|
+
defaults: {
|
29
|
+
view: undefined
|
30
|
+
}
|
31
|
+
};
|
@@ -0,0 +1,82 @@
|
|
1
|
+
---
|
2
|
+
id: link
|
3
|
+
title: Link
|
4
|
+
---
|
5
|
+
|
6
|
+
import { PropsTable, Description } from '@site/src/components';
|
7
|
+
|
8
|
+
# ViewContainer
|
9
|
+
<Description name="ViewContainer" />
|
10
|
+
<PropsTable name="ViewContainer" exclude={['css']} />
|
11
|
+
|
12
|
+
# Описание
|
13
|
+
|
14
|
+
Данный компонент представляет собой обёртку, которая инвертирует токены компонент, которые в неё помещены, в зависимости от выбранного значения свойства view - `onDark` или `onLight`.
|
15
|
+
|
16
|
+
При этом, независимо от режима темы (тёмный или светлый) для всего приложения, токены внутри не будут меняться.
|
17
|
+
|
18
|
+
Этот механизм необходим для случаев, когда требуется отобразить компонент на специфичном бэкграунде, чтобы избежать наложение цветов.
|
19
|
+
|
20
|
+
# Пример использования
|
21
|
+
|
22
|
+
```tsx live
|
23
|
+
import React from 'react';
|
24
|
+
import { ViewContainer, Button, Checkbox, TextField } from '@salutejs/{{ package }}';
|
25
|
+
|
26
|
+
export function App() {
|
27
|
+
return (
|
28
|
+
<div>
|
29
|
+
<ViewContainer
|
30
|
+
style=\{{
|
31
|
+
padding: '1rem',
|
32
|
+
borderRadius: '1rem',
|
33
|
+
display: 'flex',
|
34
|
+
flexDirection: 'column',
|
35
|
+
gap: '1rem',
|
36
|
+
}}
|
37
|
+
>
|
38
|
+
<h3 style=\{{ margin: 0 }}>Inside default ViewContainer</h3>
|
39
|
+
<Button text="default Button" />
|
40
|
+
<Checkbox checked label="Label" />
|
41
|
+
<TextField value="Example Value" label="Label" labelPlacement="inner" />
|
42
|
+
</ViewContainer>
|
43
|
+
<br />
|
44
|
+
<ViewContainer
|
45
|
+
view="onDark"
|
46
|
+
style=\{{
|
47
|
+
background: '#1a1a1a',
|
48
|
+
color: 'white',
|
49
|
+
padding: '1rem',
|
50
|
+
borderRadius: '1rem',
|
51
|
+
display: 'flex',
|
52
|
+
flexDirection: 'column',
|
53
|
+
gap: '1rem',
|
54
|
+
}}
|
55
|
+
>
|
56
|
+
<h3 style=\{{ margin: 0 }}>Inside onDark ViewContainer</h3>
|
57
|
+
<Button text="default Button" />
|
58
|
+
<Checkbox checked label="Label" />
|
59
|
+
<TextField value="Example Value" label="Label" labelPlacement="inner" />
|
60
|
+
</ViewContainer>
|
61
|
+
<br />
|
62
|
+
<ViewContainer
|
63
|
+
view="onLight"
|
64
|
+
style=\{{
|
65
|
+
background: '#ededed',
|
66
|
+
color: 'black',
|
67
|
+
padding: '1rem',
|
68
|
+
borderRadius: '1rem',
|
69
|
+
display: 'flex',
|
70
|
+
flexDirection: 'column',
|
71
|
+
gap: '1rem',
|
72
|
+
}}
|
73
|
+
>
|
74
|
+
<h3 style=\{{ margin: 0 }}>Inside onLight ViewContainer</h3>
|
75
|
+
<Button text="default Button" />
|
76
|
+
<Checkbox checked label="Label" />
|
77
|
+
<TextField value="Example Value" label="Label" labelPlacement="inner" />
|
78
|
+
</ViewContainer>
|
79
|
+
</div>
|
80
|
+
);
|
81
|
+
}
|
82
|
+
```
|
@@ -0,0 +1 @@
|
|
1
|
+
[]
|
@@ -0,0 +1 @@
|
|
1
|
+
export { viewContainerRoot, viewContainerConfig } from './ViewContainer';
|
@@ -6,20 +6,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
6
6
|
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; } }
|
7
7
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
8
8
|
import React from 'react';
|
9
|
-
|
10
|
-
export var WithTheme = function WithTheme(Story
|
11
|
-
|
12
|
-
var themeType = context.globals.theme;
|
13
|
-
var themeName = context.title.split('/')[0];
|
14
|
-
return /*#__PURE__*/React.createElement("div", {
|
15
|
-
id: "theme-root",
|
16
|
-
className: themes === null || themes === void 0 || (_themes$themeName = themes[themeName]) === null || _themes$themeName === void 0 ? void 0 : _themes$themeName[themeType],
|
17
|
-
style: {
|
18
|
-
padding: '1rem',
|
19
|
-
minHeight: '100vh',
|
20
|
-
boxSizing: 'border-box'
|
21
|
-
}
|
22
|
-
}, /*#__PURE__*/React.createElement(Story, null));
|
9
|
+
// TODO: Удалить в отдельном пр из всех компонент
|
10
|
+
export var WithTheme = function WithTheme(Story) {
|
11
|
+
return /*#__PURE__*/React.createElement(Story, null);
|
23
12
|
};
|
24
13
|
export function argTypesFromConfig(config) {
|
25
14
|
var exclude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
@@ -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
|
-
};
|
package/styled-components/es/examples/plasma_b2c/components/ViewContainer/ViewContainer.config.js
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import { css } from 'styled-components';
|
2
|
+
import { viewContainer } from '@salutejs/plasma-themes/tokens/plasma_b2c';
|
3
|
+
export var config = {
|
4
|
+
variations: {
|
5
|
+
view: {
|
6
|
+
onDark: /*#__PURE__*/css(["", ""], viewContainer.dark),
|
7
|
+
onLight: /*#__PURE__*/css(["", ""], viewContainer.light)
|
8
|
+
}
|
9
|
+
}
|
10
|
+
};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { viewContainerConfig } from '../../../../components/ViewContainer';
|
2
|
+
import { component, mergeConfig } from '../../../../engines';
|
3
|
+
import { config } from './ViewContainer.config';
|
4
|
+
var mergedConfig = /*#__PURE__*/mergeConfig(viewContainerConfig, config);
|
5
|
+
export var ViewContainer = /*#__PURE__*/component(mergedConfig);
|
package/styled-components/es/examples/plasma_b2c/components/ViewContainer/ViewContainer.stories.tsx
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
import React, { ComponentProps } from 'react';
|
2
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
3
|
+
|
4
|
+
import { Button } from '../Button/Button';
|
5
|
+
import { TextField } from '../Textfield/Textfield';
|
6
|
+
import { Checkbox } from '../Checkbox/Checkbox';
|
7
|
+
|
8
|
+
import { ViewContainer } from './ViewContainer';
|
9
|
+
|
10
|
+
type StoryViewProps = ComponentProps<typeof ViewContainer>;
|
11
|
+
|
12
|
+
const meta: Meta<StoryViewProps> = {
|
13
|
+
title: 'plasma_b2c/ViewContainer',
|
14
|
+
};
|
15
|
+
|
16
|
+
export default meta;
|
17
|
+
|
18
|
+
type Story = StoryObj<StoryViewProps>;
|
19
|
+
|
20
|
+
const ViewExample = ({ view }: StoryViewProps) => {
|
21
|
+
const style = view
|
22
|
+
? {
|
23
|
+
background: view === 'onDark' ? '#1a1a1a' : '#ededed',
|
24
|
+
color: view === 'onDark' ? 'white' : 'black',
|
25
|
+
}
|
26
|
+
: undefined;
|
27
|
+
|
28
|
+
return (
|
29
|
+
<>
|
30
|
+
<h4>view: {view ?? 'default'}</h4>
|
31
|
+
<div>
|
32
|
+
<ViewContainer
|
33
|
+
view={view}
|
34
|
+
style={{
|
35
|
+
...style,
|
36
|
+
padding: '1rem',
|
37
|
+
borderRadius: '1rem',
|
38
|
+
display: 'flex',
|
39
|
+
flexDirection: 'column',
|
40
|
+
gap: '1rem',
|
41
|
+
}}
|
42
|
+
>
|
43
|
+
<h3 style={{ margin: 0 }}>Inside ViewContainer</h3>
|
44
|
+
<Button text="default Button" />
|
45
|
+
<Checkbox checked label="Label" />
|
46
|
+
<TextField value="Example Value" label="Label" labelPlacement="inner" />
|
47
|
+
</ViewContainer>
|
48
|
+
</div>
|
49
|
+
</>
|
50
|
+
);
|
51
|
+
};
|
52
|
+
|
53
|
+
export const Default: Story = {
|
54
|
+
render: () => {
|
55
|
+
return (
|
56
|
+
<>
|
57
|
+
<ViewExample />
|
58
|
+
<br />
|
59
|
+
<ViewExample view="onDark" />
|
60
|
+
<br />
|
61
|
+
<ViewExample view="onLight" />
|
62
|
+
</>
|
63
|
+
);
|
64
|
+
},
|
65
|
+
};
|
@@ -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
|
-
};
|
package/styled-components/es/examples/plasma_web/components/ViewContainer/ViewContainer.config.js
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import { css } from 'styled-components';
|
2
|
+
import { viewContainer } from '@salutejs/plasma-themes/tokens/plasma_b2c';
|
3
|
+
export var config = {
|
4
|
+
variations: {
|
5
|
+
view: {
|
6
|
+
onDark: /*#__PURE__*/css(["", ""], viewContainer.dark),
|
7
|
+
onLight: /*#__PURE__*/css(["", ""], viewContainer.light)
|
8
|
+
}
|
9
|
+
}
|
10
|
+
};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { viewContainerConfig } from '../../../../components/ViewContainer';
|
2
|
+
import { component, mergeConfig } from '../../../../engines';
|
3
|
+
import { config } from './ViewContainer.config';
|
4
|
+
var mergedConfig = /*#__PURE__*/mergeConfig(viewContainerConfig, config);
|
5
|
+
export var ViewContainer = /*#__PURE__*/component(mergedConfig);
|