@snack-uikit/accordion 0.6.7-preview-7a18c2ee.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/components/CollapseBlockPrimary/CollapseBlockPrimary.d.ts +1 -1
- package/dist/components/CollapseBlockPrimary/CollapseBlockPrimary.js +2 -2
- package/dist/components/CollapseBlockPrimary/styles.module.css +10 -3
- package/dist/helperComponents/CollapseBlockHeader/CollapseBlockHeader.js +1 -1
- package/dist/helperComponents/CollapseBlockPrivate/CollapseBlockPrivate.d.ts +2 -1
- package/dist/helperComponents/CollapseBlockPrivate/CollapseBlockPrivate.js +2 -2
- package/dist/types.d.ts +2 -0
- package/package.json +8 -8
- package/src/components/CollapseBlockPrimary/CollapseBlockPrimary.tsx +2 -0
- package/src/components/CollapseBlockPrimary/styles.module.scss +10 -1
- package/src/helperComponents/CollapseBlockHeader/CollapseBlockHeader.tsx +1 -1
- package/src/helperComponents/CollapseBlockPrivate/CollapseBlockPrivate.tsx +11 -1
- package/src/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 0.7.0 (2024-04-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PDS-45:** add shape prop ([a7e1ec2](https://github.com/cloud-ru-tech/snack-uikit/commit/a7e1ec27ad3e679d493ba14bc6f2159c6a5e6b55))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.6.6 (2024-03-26)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CollapseBlockPrimaryProps } from '../../types';
|
|
2
|
-
export declare function CollapseBlockPrimary({ id, header, children, actions, className, outline, ...rest }: CollapseBlockPrimaryProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function CollapseBlockPrimary({ id, header, children, actions, className, outline, shape, ...rest }: CollapseBlockPrimaryProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -16,7 +16,7 @@ import { extractSupportProps } from '@snack-uikit/utils';
|
|
|
16
16
|
import { CollapseBlockHeaderContainer, CollapseBlockPrivate } from '../../helperComponents';
|
|
17
17
|
import styles from './styles.module.css';
|
|
18
18
|
export function CollapseBlockPrimary(_a) {
|
|
19
|
-
var { id, header, children, actions, className, outline } = _a, rest = __rest(_a, ["id", "header", "children", "actions", "className", "outline"]);
|
|
19
|
+
var { id, header, children, actions, className, outline, shape = 'round' } = _a, rest = __rest(_a, ["id", "header", "children", "actions", "className", "outline", "shape"]);
|
|
20
20
|
const { isChecked: isExpanded, handleClick: handleExpandedChange } = useToggleGroup({ value: id });
|
|
21
|
-
return (_jsx(CollapseBlockPrivate, Object.assign({ className: cn(styles.containerBase, { [styles.container]: !outline, [styles.containerOutline]: outline }, className), header: _jsx(CollapseBlockHeaderContainer, { expanded: isExpanded, toggleExpanded: handleExpandedChange, actions: actions, children: header }), expanded: isExpanded }, extractSupportProps(rest), { children: children })));
|
|
21
|
+
return (_jsx(CollapseBlockPrivate, Object.assign({ className: cn(styles.containerBase, { [styles.container]: !outline, [styles.containerOutline]: outline }, className), shape: shape, header: _jsx(CollapseBlockHeaderContainer, { expanded: isExpanded, toggleExpanded: handleExpandedChange, actions: actions, children: header }), expanded: isExpanded }, extractSupportProps(rest), { children: children })));
|
|
22
22
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
.containerBase{
|
|
2
2
|
max-width:100%;
|
|
3
|
-
background-color:var(--sys-neutral-background1-level, #
|
|
3
|
+
background-color:var(--sys-neutral-background1-level, #fdfdff);
|
|
4
4
|
}
|
|
5
5
|
.containerBase:focus-within, .containerBase:hover{
|
|
6
6
|
background-color:var(--sys-neutral-background2-level, #ffffff);
|
|
7
7
|
}
|
|
8
|
+
.containerBase[data-shape=round]{
|
|
9
|
+
border-radius:var(--radius-accordion-collapse-block-primary-round, 24px);
|
|
10
|
+
border-width:var(--border-width-accordion-collapse-block-primary, 1px);
|
|
11
|
+
}
|
|
12
|
+
.containerBase[data-shape=square]{
|
|
13
|
+
border-radius:var(--radius-accordion-collapse-block-primary-square, 4px);
|
|
14
|
+
border-width:var(--border-width-accordion-collapse-block-primary, 1px);
|
|
15
|
+
}
|
|
8
16
|
|
|
9
17
|
.container{
|
|
10
18
|
padding-top:var(--space-accordion-collapse-block-primary-vertical-padding, 32px);
|
|
@@ -12,7 +20,7 @@
|
|
|
12
20
|
padding-left:var(--space-accordion-collapse-block-primary-horizontal-padding, 32px);
|
|
13
21
|
padding-right:var(--space-accordion-collapse-block-primary-horizontal-padding, 32px);
|
|
14
22
|
gap:var(--space-accordion-collapse-block-primary-gap, 32px);
|
|
15
|
-
border-
|
|
23
|
+
border-width:var(--border-width-accordion-collapse-block-primary, 1px);
|
|
16
24
|
}
|
|
17
25
|
.container:focus-within, .container:hover{
|
|
18
26
|
box-shadow:var(--box-shadow-elevation-level2, 0px 0px 4px 0px rgba(0, 0, 0, 0.0392156863), 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863));
|
|
@@ -24,7 +32,6 @@
|
|
|
24
32
|
padding-left:var(--space-accordion-collapse-block-primary-horizontal-padding, 32px);
|
|
25
33
|
padding-right:var(--space-accordion-collapse-block-primary-horizontal-padding, 32px);
|
|
26
34
|
gap:var(--space-accordion-collapse-block-primary-gap, 32px);
|
|
27
|
-
border-radius:var(--radius-accordion-collapse-block-primary, 24px);
|
|
28
35
|
border-width:var(--border-width-accordion-collapse-block-primary, 1px);
|
|
29
36
|
border-width:0;
|
|
30
37
|
outline-color:var(--sys-neutral-decor-default, #dfe2ec);
|
|
@@ -5,5 +5,5 @@ import { Typography } from '@snack-uikit/typography';
|
|
|
5
5
|
import { TEST_IDS } from '../../testIds';
|
|
6
6
|
import styles from './styles.module.css';
|
|
7
7
|
export function CollapseBlockHeader({ title, description, tip }) {
|
|
8
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.headline, children: [_jsx(Typography.SansTitleM, { className: styles.title, "data-test-id": TEST_IDS.title, children: _jsx(TruncateString, { text: title, maxLines: 1 }) }), tip && _jsx(QuestionTooltip, { size: 's', tip: tip, triggerDataTestId: TEST_IDS.tooltip })] }), description && (_jsx(Typography.SansBodyM, { className: styles.subtitle, "data-test-id": TEST_IDS.description, children: _jsx(TruncateString, { text: description, maxLines: 2 }) }))] }));
|
|
8
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: styles.headline, children: [_jsx(Typography.SansTitleM, { className: styles.title, "data-test-id": TEST_IDS.title, children: _jsx(TruncateString, { text: title, maxLines: 1 }) }), tip && _jsx(QuestionTooltip, { size: 's', tip: tip, triggerDataTestId: TEST_IDS.tooltip, tabIndex: -1 })] }), description && (_jsx(Typography.SansBodyM, { className: styles.subtitle, "data-test-id": TEST_IDS.description, children: _jsx(TruncateString, { text: description, maxLines: 2 }) }))] }));
|
|
9
9
|
}
|
|
@@ -5,5 +5,6 @@ export type CollapseBlockPrivateProps = WithSupportProps<{
|
|
|
5
5
|
header: ReactNode;
|
|
6
6
|
expanded: boolean;
|
|
7
7
|
className?: string;
|
|
8
|
+
shape?: 'round' | 'square';
|
|
8
9
|
}>;
|
|
9
|
-
export declare function CollapseBlockPrivate({ children, expanded, className, header, ...rest }: CollapseBlockPrivateProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function CollapseBlockPrivate({ children, expanded, className, header, shape, ...rest }: CollapseBlockPrivateProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,8 +15,8 @@ import { extractSupportProps } from '@snack-uikit/utils';
|
|
|
15
15
|
import { TEST_IDS } from '../../testIds';
|
|
16
16
|
import styles from './styles.module.css';
|
|
17
17
|
export function CollapseBlockPrivate(_a) {
|
|
18
|
-
var { children, expanded, className, header } = _a, rest = __rest(_a, ["children", "expanded", "className", "header"]);
|
|
18
|
+
var { children, expanded, className, header, shape } = _a, rest = __rest(_a, ["children", "expanded", "className", "header", "shape"]);
|
|
19
19
|
return (_jsxs("div", Object.assign({ className: cn(styles.accordion, className),
|
|
20
20
|
// eslint-disable-next-line jsx-a11y/aria-role
|
|
21
|
-
role: 'accordion', "aria-expanded": expanded }, extractSupportProps(rest), { children: [header, _jsx("div", { className: styles.contentWrapper, "aria-hidden": !expanded, "data-test-id": TEST_IDS.content, children: _jsx("div", { className: styles.content, "data-content": true, children: children }) })] })));
|
|
21
|
+
role: 'accordion', "data-shape": shape, "aria-expanded": expanded }, extractSupportProps(rest), { children: [header, _jsx("div", { className: styles.contentWrapper, "aria-hidden": !expanded, "data-test-id": TEST_IDS.content, children: _jsx("div", { className: styles.content, "data-content": true, children: children }) })] })));
|
|
22
22
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type CollapseBlockSecondaryProps = WithSupportProps<{
|
|
|
16
16
|
export type CollapseBlockPrimaryProps = CollapseBlockSecondaryProps & {
|
|
17
17
|
/** Внешний бордер */
|
|
18
18
|
outline?: boolean;
|
|
19
|
+
/** Форма: круглая или квадратная */
|
|
20
|
+
shape?: 'round' | 'square';
|
|
19
21
|
};
|
|
20
22
|
export type CollapseBlockProps = CollapseBlockPrimaryProps | CollapseBlockSecondaryProps;
|
|
21
23
|
export type AccordionProps = WithSupportProps<{
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Accordion",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.7.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"scripts": {},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@snack-uikit/button": "0.17.1
|
|
35
|
+
"@snack-uikit/button": "0.17.1",
|
|
36
36
|
"@snack-uikit/icons": "0.20.1",
|
|
37
|
-
"@snack-uikit/toggles": "0.9.8
|
|
38
|
-
"@snack-uikit/tooltip": "0.13.2
|
|
39
|
-
"@snack-uikit/truncate-string": "0.4.13
|
|
40
|
-
"@snack-uikit/typography": "0.6.2
|
|
41
|
-
"@snack-uikit/utils": "3.
|
|
37
|
+
"@snack-uikit/toggles": "0.9.8",
|
|
38
|
+
"@snack-uikit/tooltip": "0.13.2",
|
|
39
|
+
"@snack-uikit/truncate-string": "0.4.13",
|
|
40
|
+
"@snack-uikit/typography": "0.6.2",
|
|
41
|
+
"@snack-uikit/utils": "3.3.0",
|
|
42
42
|
"classnames": "2.3.2"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "bf1e1f3cfabccc1ee288c18722e33009bd001798"
|
|
45
45
|
}
|
|
@@ -14,6 +14,7 @@ export function CollapseBlockPrimary({
|
|
|
14
14
|
actions,
|
|
15
15
|
className,
|
|
16
16
|
outline,
|
|
17
|
+
shape = 'round',
|
|
17
18
|
...rest
|
|
18
19
|
}: CollapseBlockPrimaryProps) {
|
|
19
20
|
const { isChecked: isExpanded, handleClick: handleExpandedChange } = useToggleGroup({ value: id });
|
|
@@ -25,6 +26,7 @@ export function CollapseBlockPrimary({
|
|
|
25
26
|
{ [styles.container]: !outline, [styles.containerOutline]: outline },
|
|
26
27
|
className,
|
|
27
28
|
)}
|
|
29
|
+
shape={shape}
|
|
28
30
|
header={
|
|
29
31
|
<CollapseBlockHeaderContainer expanded={isExpanded} toggleExpanded={handleExpandedChange} actions={actions}>
|
|
30
32
|
{header}
|
|
@@ -8,6 +8,14 @@
|
|
|
8
8
|
&:hover {
|
|
9
9
|
background-color: $sys-neutral-background2-level;
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
&[data-shape='round'] {
|
|
13
|
+
@include composite-var($collapse-block, 'container', 'shape-round');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&[data-shape='square'] {
|
|
17
|
+
@include composite-var($collapse-block, 'container', 'shape-square');
|
|
18
|
+
}
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
.container {
|
|
@@ -20,12 +28,13 @@
|
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
.containerOutline {
|
|
23
|
-
@include composite-var($collapse-block-container-primary
|
|
31
|
+
@include composite-var($collapse-block-container-primary);
|
|
24
32
|
|
|
25
33
|
border-width: 0;
|
|
26
34
|
outline-color: $sys-neutral-decor-default;
|
|
27
35
|
outline-style: solid;
|
|
28
36
|
outline-width: $border-width-accordion-collapse-block-primary;
|
|
37
|
+
|
|
29
38
|
&:focus-within,
|
|
30
39
|
&:hover {
|
|
31
40
|
outline-color: $sys-neutral-decor-hovered;
|
|
@@ -22,7 +22,7 @@ export function CollapseBlockHeader({ title, description, tip }: CollapseBlockHe
|
|
|
22
22
|
<TruncateString text={title} maxLines={1} />
|
|
23
23
|
</Typography.SansTitleM>
|
|
24
24
|
|
|
25
|
-
{tip && <QuestionTooltip size='s' tip={tip} triggerDataTestId={TEST_IDS.tooltip} />}
|
|
25
|
+
{tip && <QuestionTooltip size='s' tip={tip} triggerDataTestId={TEST_IDS.tooltip} tabIndex={-1} />}
|
|
26
26
|
</div>
|
|
27
27
|
|
|
28
28
|
{description && (
|
|
@@ -11,14 +11,24 @@ export type CollapseBlockPrivateProps = WithSupportProps<{
|
|
|
11
11
|
header: ReactNode;
|
|
12
12
|
expanded: boolean;
|
|
13
13
|
className?: string;
|
|
14
|
+
shape?: 'round' | 'square';
|
|
14
15
|
}>;
|
|
15
16
|
|
|
16
|
-
export function CollapseBlockPrivate({
|
|
17
|
+
export function CollapseBlockPrivate({
|
|
18
|
+
children,
|
|
19
|
+
expanded,
|
|
20
|
+
className,
|
|
21
|
+
header,
|
|
22
|
+
shape,
|
|
23
|
+
...rest
|
|
24
|
+
}: CollapseBlockPrivateProps) {
|
|
17
25
|
return (
|
|
18
26
|
<div
|
|
19
27
|
className={cn(styles.accordion, className)}
|
|
20
28
|
// eslint-disable-next-line jsx-a11y/aria-role
|
|
21
29
|
role='accordion'
|
|
30
|
+
data-shape={shape}
|
|
31
|
+
// data-outline={outline || undefined}
|
|
22
32
|
aria-expanded={expanded}
|
|
23
33
|
{...extractSupportProps(rest)}
|
|
24
34
|
>
|
package/src/types.ts
CHANGED
|
@@ -20,6 +20,8 @@ export type CollapseBlockSecondaryProps = WithSupportProps<{
|
|
|
20
20
|
export type CollapseBlockPrimaryProps = CollapseBlockSecondaryProps & {
|
|
21
21
|
/** Внешний бордер */
|
|
22
22
|
outline?: boolean;
|
|
23
|
+
/** Форма: круглая или квадратная */
|
|
24
|
+
shape?: 'round' | 'square';
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
export type CollapseBlockProps = CollapseBlockPrimaryProps | CollapseBlockSecondaryProps;
|