@cloud-ru/ds-accordion 1.1.6 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-ru/ds-accordion",
3
- "version": "1.1.6",
3
+ "version": "1.2.0",
4
4
  "description": "Аккордеон дизайн-системы — контейнер Accordion и три уровня раскрываемых блоков CollapseBlock с общими токенами view, backgroundPredefined и chevronPosition.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,11 +37,11 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "classnames": "^2.5.1",
40
+ "@cloud-ru/ds-toggles": "^1.1.8",
40
41
  "@cloud-ru/ds-materials": "^2.0.1",
41
- "@cloud-ru/ds-icons": "^1.4.0",
42
42
  "@cloud-ru/ds-truncate-string": "^1.0.11",
43
- "@cloud-ru/ds-toggles": "^1.1.8",
44
43
  "@cloud-ru/ds-typography": "^1.0.1",
44
+ "@cloud-ru/ds-icons": "^1.4.0",
45
45
  "@cloud-ru/ds-utils": "^1.2.0"
46
46
  }
47
47
  }
@@ -17,7 +17,11 @@ import styles from './styles.module.scss';
17
17
 
18
18
  type Component = 'accordionPrimary' | 'accordionSecondary' | 'accordionTertiary';
19
19
 
20
- const stopPropagation = (e: MouseEvent) => e.stopPropagation();
20
+ const getStopPropagationHandler = (stopPropagation: boolean) => (e: MouseEvent) => {
21
+ if (stopPropagation) {
22
+ e.stopPropagation();
23
+ }
24
+ };
21
25
 
22
26
  export type CollapseBlockProps = PropsWithChildren<
23
27
  WithSupportProps<{
@@ -49,6 +53,11 @@ export type CollapseBlockProps = PropsWithChildren<
49
53
  component: Component;
50
54
  /** Оставлять ли контент в DOM при сворачивании */
51
55
  keepMounted?: boolean;
56
+ /**
57
+ * Клики в слотах afterTitle и subTitle не тригерять расскрытие/закрытие блока
58
+ * @default false
59
+ */
60
+ stopSlotsClickPropagation?: boolean;
52
61
  }>
53
62
  >;
54
63
 
@@ -74,6 +83,7 @@ export function CollapseBlock({
74
83
  keepMounted = false,
75
84
  component,
76
85
  showChevron = true,
86
+ stopSlotsClickPropagation = false,
77
87
  'data-test-id': dataTestId,
78
88
  ...rest
79
89
  }: CollapseBlockProps) {
@@ -138,7 +148,7 @@ export function CollapseBlock({
138
148
  id={afterTitleId}
139
149
  data-test-id={TEST_IDS.afterTitle}
140
150
  className={styles.afterTitle}
141
- onClick={stopPropagation}
151
+ onClick={getStopPropagationHandler(stopSlotsClickPropagation)}
142
152
  >
143
153
  {afterTitle}
144
154
  </div>
@@ -146,7 +156,11 @@ export function CollapseBlock({
146
156
  </div>
147
157
  {subTitle && (
148
158
  /* eslint-disable-next-line jsx-a11y/no-static-element-interactions */
149
- <div className={styles.subTitle} data-test-id={TEST_IDS.subTitle} onClick={stopPropagation}>
159
+ <div
160
+ className={styles.subTitle}
161
+ data-test-id={TEST_IDS.subTitle}
162
+ onClick={getStopPropagationHandler(stopSlotsClickPropagation)}
163
+ >
150
164
  {subTitle}
151
165
  </div>
152
166
  )}