@snack-uikit/accordion 0.4.1 → 0.5.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 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.5.0 (2023-12-14)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
13
+
14
+
15
+
16
+
6
17
  ## 0.4.1 (2023-12-06)
7
18
 
8
19
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -7,25 +7,24 @@
7
7
 
8
8
  ## Example
9
9
 
10
- ```typescript
10
+ ```tsx
11
+ import { AccordionPrimary } from '@snack-uikit/accordion'
11
12
 
12
- import {AccordionPrimary} from '@snack-uikit/accordion'
13
+ function Example() {
13
14
 
14
- function Example() {
15
-
16
- // ...some actions
15
+ // ...some actions
17
16
 
18
- return (
19
- <AccordionPrimary >
20
- <AccordionPrimary.CollapseBlock title={title} description={description} actions={actions}>
21
- <Content />
22
- </AccordionPrimary.CollapseBlock>
17
+ return (
18
+ <AccordionPrimary >
19
+ <AccordionPrimary.CollapseBlock title={title} description={description} actions={actions}>
20
+ <Content />
21
+ </AccordionPrimary.CollapseBlock>
23
22
 
24
- <AccordionPrimary.CollapseBlock title={title} description={description} actions={actions}>
25
- <Content />
26
- </AccordionPrimary.CollapseBlock>
27
- </AccordionPrimary>
28
- )}
23
+ <AccordionPrimary.CollapseBlock title={title} description={description} actions={actions}>
24
+ <Content />
25
+ </AccordionPrimary.CollapseBlock>
26
+ </AccordionPrimary>
27
+ )}
29
28
  ```
30
29
 
31
30
 
@@ -41,7 +40,7 @@
41
40
  | expandedDefault | `string \| string[]` | - | Начальное состояние |
42
41
  | expanded | `string \| string[]` | - | Controlled состояние |
43
42
  | onExpandedChange | `((value: string) => void) \| ((value: string[]) => void)` | - | Controlled обработчик измения состояния |
44
- | selectionMode | enum SelectionMode: `"single"`, `"multiple"` | - | Режим работы аккордиона |
43
+ | selectionMode | "single" \| "multiple" | - | Режим работы аккордиона |
45
44
  ## AccordionSecondary
46
45
  ### Props
47
46
  | name | type | default value | description |
@@ -51,7 +50,7 @@
51
50
  | expandedDefault | `string \| string[]` | - | Начальное состояние |
52
51
  | expanded | `string \| string[]` | - | Controlled состояние |
53
52
  | onExpandedChange | `((value: string) => void) \| ((value: string[]) => void)` | - | Controlled обработчик измения состояния |
54
- | selectionMode | enum SelectionMode: `"single"`, `"multiple"` | - | Режим работы аккордиона |
53
+ | selectionMode | "single" \| "multiple" | - | Режим работы аккордиона |
55
54
 
56
55
 
57
56
  [//]: DOCUMENTATION_SECTION_END
@@ -1,5 +1,2 @@
1
1
  import { AccordionProps } from '../../types';
2
2
  export declare function AccordionPrimary({ className, ...rest }: AccordionProps): import("react/jsx-runtime").JSX.Element;
3
- export declare namespace AccordionPrimary {
4
- var selectionModes: typeof import("@snack-uikit/toggles/dist/constants").SelectionMode;
5
- }
@@ -11,11 +11,9 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
- import { ToggleGroup } from '@snack-uikit/toggles';
15
14
  import { Accordion } from '../../helperComponents';
16
15
  import styles from './styles.module.css';
17
16
  export function AccordionPrimary(_a) {
18
17
  var { className } = _a, rest = __rest(_a, ["className"]);
19
18
  return _jsx(Accordion, Object.assign({ className: cn(styles.accordionPrimary, className) }, rest));
20
19
  }
21
- AccordionPrimary.selectionModes = ToggleGroup.selectionModes;
@@ -1,5 +1,2 @@
1
1
  import { AccordionProps } from '../../types';
2
2
  export declare function AccordionSecondary({ className, ...rest }: AccordionProps): import("react/jsx-runtime").JSX.Element;
3
- export declare namespace AccordionSecondary {
4
- var selectionModes: typeof import("@snack-uikit/toggles/dist/constants").SelectionMode;
5
- }
@@ -11,11 +11,9 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
- import { ToggleGroup } from '@snack-uikit/toggles';
15
14
  import { Accordion } from '../../helperComponents';
16
15
  import styles from './styles.module.css';
17
16
  export function AccordionSecondary(_a) {
18
17
  var { className } = _a, rest = __rest(_a, ["className"]);
19
18
  return _jsx(Accordion, Object.assign({ className: cn(styles.accordionSecondary, className) }, rest));
20
19
  }
21
- AccordionSecondary.selectionModes = ToggleGroup.selectionModes;
@@ -0,0 +1,4 @@
1
+ export declare const SELECTION_MODE: {
2
+ readonly Single: "single";
3
+ readonly Multiple: "multiple";
4
+ };
@@ -0,0 +1,4 @@
1
+ export const SELECTION_MODE = {
2
+ Single: 'single',
3
+ Multiple: 'multiple',
4
+ };
@@ -13,7 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { ToggleGroup } from '@snack-uikit/toggles';
14
14
  import { extractSupportProps } from '@snack-uikit/utils';
15
15
  export function Accordion(_a) {
16
- var { children, expanded, onExpandedChange, expandedDefault, selectionMode = ToggleGroup.selectionModes.Single, className } = _a, rest = __rest(_a, ["children", "expanded", "onExpandedChange", "expandedDefault", "selectionMode", "className"]);
16
+ var { children, expanded, onExpandedChange, expandedDefault, selectionMode = 'single', className } = _a, rest = __rest(_a, ["children", "expanded", "onExpandedChange", "expandedDefault", "selectionMode", "className"]);
17
17
  return (
18
18
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19
19
  // @ts-ignore
@@ -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", Object.assign({ className: styles.headline }, { children: [_jsx(Typography.SansTitleM, Object.assign({ className: styles.title, "data-test-id": TEST_IDS.title }, { children: _jsx(TruncateString, { text: title, maxLines: 1 }) })), tip && _jsx(QuestionTooltip, { size: QuestionTooltip.sizes.S, tip: tip, triggerDataTestId: TEST_IDS.tooltip })] })), description && (_jsx(Typography.SansBodyM, Object.assign({ className: styles.subtitle, "data-test-id": TEST_IDS.description }, { children: _jsx(TruncateString, { text: description, maxLines: 2 }) })))] }));
8
+ return (_jsxs(_Fragment, { children: [_jsxs("div", Object.assign({ className: styles.headline }, { children: [_jsx(Typography.SansTitleM, Object.assign({ 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, Object.assign({ className: styles.subtitle, "data-test-id": TEST_IDS.description }, { children: _jsx(TruncateString, { text: description, maxLines: 2 }) })))] }));
9
9
  }
@@ -17,5 +17,5 @@ export function CollapseBlockHeaderContainer({ children, toggleExpanded, expande
17
17
  }, [functionLayoutRef]);
18
18
  return (
19
19
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
20
- _jsxs("div", Object.assign({ className: styles.header, "data-test-id": TEST_IDS.header, onClick: toggleExpanded }, { children: [_jsx("div", Object.assign({ className: styles.text, style: { '--width': width } }, { children: children })), _jsxs("div", Object.assign({ className: styles.functionLayout, ref: functionLayoutRef }, { children: [actions, _jsx(ButtonFunction, { className: styles.button, "data-expanded": expanded || undefined, icon: _jsx(ChevronDownSVG, {}), size: ButtonFunction.sizes.Xs, "data-test-id": TEST_IDS.chevron })] }))] })));
20
+ _jsxs("div", Object.assign({ className: styles.header, "data-test-id": TEST_IDS.header, onClick: toggleExpanded }, { children: [_jsx("div", Object.assign({ className: styles.text, style: { '--width': width } }, { children: children })), _jsxs("div", Object.assign({ className: styles.functionLayout, ref: functionLayoutRef }, { children: [actions, _jsx(ButtonFunction, { className: styles.button, "data-expanded": expanded || undefined, icon: _jsx(ChevronDownSVG, {}), size: 'xs', "data-test-id": TEST_IDS.chevron })] }))] })));
21
21
  }
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
- import { ToggleGroup } from '@snack-uikit/toggles';
3
2
  import { WithSupportProps } from '@snack-uikit/utils';
3
+ import { SELECTION_MODE } from './constants';
4
4
  export type CollapseBlockProps = WithSupportProps<{
5
5
  /** Уникальный id блока */
6
6
  id: string;
@@ -26,7 +26,7 @@ export type AccordionProps = WithSupportProps<{
26
26
  /** Controlled обработчик измения состояния */
27
27
  onExpandedChange?(value: (string | undefined) | string): void;
28
28
  /** Режим работы аккордиона */
29
- selectionMode?: typeof ToggleGroup.selectionModes.Single;
29
+ selectionMode?: typeof SELECTION_MODE.Single;
30
30
  } | {
31
31
  /** Начальное состояние */
32
32
  expandedDefault?: string[];
@@ -35,5 +35,5 @@ export type AccordionProps = WithSupportProps<{
35
35
  /** Controlled обработчик измения состояния */
36
36
  onExpandedChange?(value: (string[] | undefined) | string[]): void;
37
37
  /** Режим работы аккордиона */
38
- selectionMode: typeof ToggleGroup.selectionModes.Multiple;
38
+ selectionMode: typeof SELECTION_MODE.Multiple;
39
39
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Accordion",
7
- "version": "0.4.1",
7
+ "version": "0.5.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.14.1",
35
+ "@snack-uikit/button": "0.15.0",
36
36
  "@snack-uikit/icons": "0.19.0",
37
- "@snack-uikit/toggles": "0.8.1",
38
- "@snack-uikit/tooltip": "0.9.1",
39
- "@snack-uikit/truncate-string": "0.3.1",
40
- "@snack-uikit/typography": "0.5.1",
41
- "@snack-uikit/utils": "3.1.0",
37
+ "@snack-uikit/toggles": "0.9.0",
38
+ "@snack-uikit/tooltip": "0.10.0",
39
+ "@snack-uikit/truncate-string": "0.4.0",
40
+ "@snack-uikit/typography": "0.6.0",
41
+ "@snack-uikit/utils": "3.2.0",
42
42
  "classnames": "2.3.2"
43
43
  },
44
- "gitHead": "76a159dde7baccf49dc7b11e1fd7abc31424b42f"
44
+ "gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
45
45
  }
@@ -1,7 +1,5 @@
1
1
  import cn from 'classnames';
2
2
 
3
- import { ToggleGroup } from '@snack-uikit/toggles';
4
-
5
3
  import { Accordion } from '../../helperComponents';
6
4
  import { AccordionProps } from '../../types';
7
5
  import styles from './styles.module.scss';
@@ -9,5 +7,3 @@ import styles from './styles.module.scss';
9
7
  export function AccordionPrimary({ className, ...rest }: AccordionProps) {
10
8
  return <Accordion className={cn(styles.accordionPrimary, className)} {...rest} />;
11
9
  }
12
-
13
- AccordionPrimary.selectionModes = ToggleGroup.selectionModes;
@@ -1,7 +1,5 @@
1
1
  import cn from 'classnames';
2
2
 
3
- import { ToggleGroup } from '@snack-uikit/toggles';
4
-
5
3
  import { Accordion } from '../../helperComponents';
6
4
  import { AccordionProps } from '../../types';
7
5
  import styles from './styles.module.scss';
@@ -9,5 +7,3 @@ import styles from './styles.module.scss';
9
7
  export function AccordionSecondary({ className, ...rest }: AccordionProps) {
10
8
  return <Accordion className={cn(styles.accordionSecondary, className)} {...rest} />;
11
9
  }
12
-
13
- AccordionSecondary.selectionModes = ToggleGroup.selectionModes;
@@ -0,0 +1,4 @@
1
+ export const SELECTION_MODE = {
2
+ Single: 'single',
3
+ Multiple: 'multiple',
4
+ } as const;
@@ -8,7 +8,7 @@ export function Accordion({
8
8
  expanded,
9
9
  onExpandedChange,
10
10
  expandedDefault,
11
- selectionMode = ToggleGroup.selectionModes.Single,
11
+ selectionMode = 'single',
12
12
  className,
13
13
  ...rest
14
14
  }: AccordionProps) {
@@ -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={QuestionTooltip.sizes.S} tip={tip} triggerDataTestId={TEST_IDS.tooltip} />}
25
+ {tip && <QuestionTooltip size='s' tip={tip} triggerDataTestId={TEST_IDS.tooltip} />}
26
26
  </div>
27
27
 
28
28
  {description && (
@@ -47,7 +47,7 @@ export function CollapseBlockHeaderContainer({
47
47
  className={styles.button}
48
48
  data-expanded={expanded || undefined}
49
49
  icon={<ChevronDownSVG />}
50
- size={ButtonFunction.sizes.Xs}
50
+ size='xs'
51
51
  data-test-id={TEST_IDS.chevron}
52
52
  />
53
53
  </div>
package/src/types.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
 
3
- import { ToggleGroup } from '@snack-uikit/toggles';
4
3
  import { WithSupportProps } from '@snack-uikit/utils';
5
4
 
5
+ import { SELECTION_MODE } from './constants';
6
+
6
7
  export type CollapseBlockProps = WithSupportProps<{
7
8
  /** Уникальный id блока */
8
9
  id: string;
@@ -31,7 +32,7 @@ export type AccordionProps = WithSupportProps<{
31
32
  /** Controlled обработчик измения состояния */
32
33
  onExpandedChange?(value: (string | undefined) | string): void;
33
34
  /** Режим работы аккордиона */
34
- selectionMode?: typeof ToggleGroup.selectionModes.Single;
35
+ selectionMode?: typeof SELECTION_MODE.Single;
35
36
  }
36
37
  | {
37
38
  /** Начальное состояние */
@@ -41,6 +42,6 @@ export type AccordionProps = WithSupportProps<{
41
42
  /** Controlled обработчик измения состояния */
42
43
  onExpandedChange?(value: (string[] | undefined) | string[]): void;
43
44
  /** Режим работы аккордиона */
44
- selectionMode: typeof ToggleGroup.selectionModes.Multiple;
45
+ selectionMode: typeof SELECTION_MODE.Multiple;
45
46
  }
46
47
  );