@cypress-design/react-accordion 0.1.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/Accordion.rootstory.tsx +37 -0
- package/Accordion.stories.mdx +117 -0
- package/Accordion.tsx +80 -0
- package/AccordionReact.cy.tsx +13 -0
- package/CHANGELOG.md +12 -0
- package/ReadMe.md +37 -0
- package/css-modules.d.ts +4 -0
- package/dist/constants.d.ts +53 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/index.es.mjs +156 -0
- package/dist/index.es.mjs.map +1 -0
- package/dist/index.umd.js +181 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/react/Accordion.d.ts +8 -0
- package/dist/react/Accordion.d.ts.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -0
- package/index.ts +1 -0
- package/package.json +27 -0
- package/rollup.config.js +3 -0
- package/tsconfig.build.json +13 -0
- package/tsconfig.json +4 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { IconActionQuestionMarkCircle } from '@cypress-design/react-icon'
|
|
3
|
+
import { AccordionStoryOptions } from '../assertions'
|
|
4
|
+
import Accordion from './Accordion'
|
|
5
|
+
|
|
6
|
+
export default (options: AccordionStoryOptions = {}) => {
|
|
7
|
+
const {
|
|
8
|
+
title = 'Accordion Title',
|
|
9
|
+
description = 'Vestibulum id ligula porta felis euismod semper. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla.',
|
|
10
|
+
icon = IconActionQuestionMarkCircle,
|
|
11
|
+
separator = true,
|
|
12
|
+
open = false,
|
|
13
|
+
fullWidthContent = false,
|
|
14
|
+
headingClassName,
|
|
15
|
+
...rest
|
|
16
|
+
} = options
|
|
17
|
+
return (
|
|
18
|
+
<div className="m-16px">
|
|
19
|
+
<Accordion
|
|
20
|
+
title={title}
|
|
21
|
+
description={description}
|
|
22
|
+
icon={icon}
|
|
23
|
+
separator={separator}
|
|
24
|
+
open={open}
|
|
25
|
+
fullWidthContent={fullWidthContent}
|
|
26
|
+
headingClassName={headingClassName}
|
|
27
|
+
{...rest}
|
|
28
|
+
>
|
|
29
|
+
<p data-cy="content">
|
|
30
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odio dolore
|
|
31
|
+
omnis nemo minus, sapiente magni laudantium eligendi modi deserunt ea
|
|
32
|
+
non iure consequatur sed id quidem! Ad.
|
|
33
|
+
</p>
|
|
34
|
+
</Accordion>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story, Description } from '@storybook/addon-docs'
|
|
2
|
+
import { version } from "./package.json"
|
|
3
|
+
import changelog from "./CHANGELOG.md"
|
|
4
|
+
import readMe from "./ReadMe.md"
|
|
5
|
+
import AccordionStory from './Accordion.rootstory'
|
|
6
|
+
import { FIGMA_URL } from '../constants'
|
|
7
|
+
|
|
8
|
+
import { Accordion } from './Accordion'
|
|
9
|
+
|
|
10
|
+
<h1>Accordion<span className="text-lg font-normal"> - v{version}</span></h1>
|
|
11
|
+
|
|
12
|
+
<Meta title="Accordion" component={Accordion} parameters={{
|
|
13
|
+
design: {
|
|
14
|
+
type: "figma",
|
|
15
|
+
url: FIGMA_URL,
|
|
16
|
+
}
|
|
17
|
+
}} />
|
|
18
|
+
|
|
19
|
+
### Usage
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import Accordion from '@cypress-design/react-accordion'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<Canvas withSource="none">
|
|
26
|
+
<Story name="Accordion">
|
|
27
|
+
<AccordionStory />
|
|
28
|
+
</Story>
|
|
29
|
+
</Canvas>
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<Accordion
|
|
33
|
+
icon={IconActionQuestionMarkCircle}
|
|
34
|
+
title="Accordion Title"
|
|
35
|
+
description="Vestibulum id ligula porta felis euismod semper. Nulla... "
|
|
36
|
+
separator
|
|
37
|
+
>
|
|
38
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odio dolore omnis nemo minus, sapiente magni ...
|
|
39
|
+
</Accordion>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Minimal
|
|
43
|
+
|
|
44
|
+
<Canvas withSource="none">
|
|
45
|
+
<Story name="Minimal">
|
|
46
|
+
<AccordionStory description={null} icon={null} />
|
|
47
|
+
</Story>
|
|
48
|
+
</Canvas>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
<Accordion title="Accordion Title">
|
|
53
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odio dolore omnis nemo minus, sapiente magni ...
|
|
54
|
+
</Accordion>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Without separator
|
|
58
|
+
|
|
59
|
+
<Canvas withSource="none">
|
|
60
|
+
<Story name="No Separator">
|
|
61
|
+
<AccordionStory separator={false} />
|
|
62
|
+
</Story>
|
|
63
|
+
</Canvas>
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
<Accordion
|
|
67
|
+
icon={IconActionQuestionMarkCircle}
|
|
68
|
+
title="Accordion Title"
|
|
69
|
+
description="Vestibulum id ligula porta felis euismod semper. Nulla... "
|
|
70
|
+
>
|
|
71
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odio dolore omnis nemo minus, sapiente magni ...
|
|
72
|
+
</Accordion>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Without description
|
|
76
|
+
|
|
77
|
+
<Canvas withSource="none">
|
|
78
|
+
<Story name="No Description">
|
|
79
|
+
<AccordionStory description={null} />
|
|
80
|
+
</Story>
|
|
81
|
+
</Canvas>
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
<Accordion
|
|
85
|
+
icon={IconActionQuestionMarkCircle}
|
|
86
|
+
title="Accordion Title"
|
|
87
|
+
separator
|
|
88
|
+
>
|
|
89
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odio dolore omnis nemo minus, sapiente magni ...
|
|
90
|
+
</Accordion>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Open by default
|
|
94
|
+
|
|
95
|
+
<Canvas withSource="none">
|
|
96
|
+
<Story name="Open">
|
|
97
|
+
<AccordionStory open />
|
|
98
|
+
</Story>
|
|
99
|
+
</Canvas>
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
<Accordion
|
|
103
|
+
icon={IconActionQuestionMarkCircle}
|
|
104
|
+
title="Accordion Title"
|
|
105
|
+
description="Vestibulum id ligula porta felis euismod semper. Nulla... "
|
|
106
|
+
separator
|
|
107
|
+
open
|
|
108
|
+
>
|
|
109
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odio dolore omnis nemo minus, sapiente magni ...
|
|
110
|
+
</Accordion>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
<ArgsTable />
|
|
114
|
+
|
|
115
|
+
<Description>
|
|
116
|
+
{changelog.replace(/^# .+/, '## Changelog')}
|
|
117
|
+
</Description>
|
package/Accordion.tsx
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import { CssClasses } from '../constants'
|
|
4
|
+
import type { AccordionProps } from '../constants'
|
|
5
|
+
import { DetailsAnimation } from '@cypress-design/details-animation'
|
|
6
|
+
import { IconChevronDownSmall } from '@cypress-design/react-icon'
|
|
7
|
+
|
|
8
|
+
export interface AccordionPropsReact extends AccordionProps {
|
|
9
|
+
icon?: React.FC<React.SVGProps<SVGSVGElement>>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Accordion: React.FC<
|
|
13
|
+
AccordionPropsReact & React.HTMLProps<HTMLDetailsElement>
|
|
14
|
+
> = ({
|
|
15
|
+
title,
|
|
16
|
+
description,
|
|
17
|
+
icon: Icon,
|
|
18
|
+
separator = false,
|
|
19
|
+
children,
|
|
20
|
+
headingClassName,
|
|
21
|
+
titleClassName,
|
|
22
|
+
descriptionClassName,
|
|
23
|
+
fullWidthContent,
|
|
24
|
+
...rest
|
|
25
|
+
}) => {
|
|
26
|
+
const details = React.useRef(null)
|
|
27
|
+
const content = React.useRef(null)
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
if (details.current && content.current) {
|
|
30
|
+
new DetailsAnimation(details.current, content.current)
|
|
31
|
+
}
|
|
32
|
+
}, [])
|
|
33
|
+
return (
|
|
34
|
+
<details {...rest} className={clsx(rest.className)} ref={details}>
|
|
35
|
+
<summary
|
|
36
|
+
className={clsx(
|
|
37
|
+
'flex items-center',
|
|
38
|
+
CssClasses.summary,
|
|
39
|
+
headingClassName ?? CssClasses.summaryColor
|
|
40
|
+
)}
|
|
41
|
+
>
|
|
42
|
+
{Icon && <Icon className={CssClasses.icon} />}
|
|
43
|
+
{Icon && separator && <hr className={CssClasses.separator} />}
|
|
44
|
+
<div className="flex-grow pr-16px">
|
|
45
|
+
<div
|
|
46
|
+
className={clsx(
|
|
47
|
+
titleClassName ?? CssClasses.summaryTitleColor,
|
|
48
|
+
CssClasses.summaryTitle
|
|
49
|
+
)}
|
|
50
|
+
>
|
|
51
|
+
{title}
|
|
52
|
+
</div>
|
|
53
|
+
{description && (
|
|
54
|
+
<div
|
|
55
|
+
className={clsx(
|
|
56
|
+
CssClasses.summaryDescription,
|
|
57
|
+
descriptionClassName ?? CssClasses.summaryDescriptionColor
|
|
58
|
+
)}
|
|
59
|
+
>
|
|
60
|
+
{description}
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
<IconChevronDownSmall
|
|
65
|
+
strokeColor="gray-300"
|
|
66
|
+
className={clsx('open:icon-dark-gray-500', CssClasses.chevron)}
|
|
67
|
+
/>
|
|
68
|
+
</summary>
|
|
69
|
+
<div ref={content} className={CssClasses.contentWrapper}>
|
|
70
|
+
{fullWidthContent ? (
|
|
71
|
+
<>{children}</>
|
|
72
|
+
) : (
|
|
73
|
+
<div className={CssClasses.content}>{children}</div>
|
|
74
|
+
)}
|
|
75
|
+
</div>
|
|
76
|
+
</details>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default Accordion
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { mount } from 'cypress/react'
|
|
5
|
+
import AccordionStory from './Accordion.rootstory'
|
|
6
|
+
import assertions from '../assertions'
|
|
7
|
+
|
|
8
|
+
describe('Accordion', () => {
|
|
9
|
+
function mountStory(options: Parameters<typeof AccordionStory>[0] = {}) {
|
|
10
|
+
mount(<AccordionStory {...options} />)
|
|
11
|
+
}
|
|
12
|
+
assertions(mountStory)
|
|
13
|
+
})
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @cypress-design/react-accordion
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#74](https://github.com/cypress-io/cypress-design/pull/74) [`6d8b6fd`](https://github.com/cypress-io/cypress-design/commit/6d8b6fd763b0389d748884c35f4ff6dd73724977) Thanks [@elevatebart](https://github.com/elevatebart)! - create the first version of accordion
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`6d8b6fd`](https://github.com/cypress-io/cypress-design/commit/6d8b6fd763b0389d748884c35f4ff6dd73724977)]:
|
|
12
|
+
- @cypress-design/details-animation@0.0.1
|
package/ReadMe.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Accordion
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Collapsible component with a header and a body.
|
|
6
|
+
|
|
7
|
+
## install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @cypress-design/react-accordion
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or with yarn
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @cypress-design/react-accordion
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import Accordion from '@cypress-design/react-accordion'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
<Accordion
|
|
27
|
+
icon={IconActionQuestionMarkCircle}
|
|
28
|
+
title="Accordion Title"
|
|
29
|
+
description="Vestibulum id ligula porta felis euismod semper. Nulla... "
|
|
30
|
+
separator
|
|
31
|
+
open
|
|
32
|
+
fullWidthContent
|
|
33
|
+
>
|
|
34
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odio dolore omnis
|
|
35
|
+
nemo minus, sapiente magni ...
|
|
36
|
+
</Accordion>
|
|
37
|
+
```
|
package/css-modules.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const CssClasses: {
|
|
2
|
+
details: string;
|
|
3
|
+
summary: string;
|
|
4
|
+
summaryColor: string;
|
|
5
|
+
summaryTitle: string;
|
|
6
|
+
summaryTitleColor: string;
|
|
7
|
+
summaryDescription: string;
|
|
8
|
+
summaryDescriptionColor: string;
|
|
9
|
+
icon: string;
|
|
10
|
+
separator: string;
|
|
11
|
+
chevron: string;
|
|
12
|
+
contentWrapper: string;
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
export interface AccordionProps {
|
|
16
|
+
/**
|
|
17
|
+
* Main indigo title.
|
|
18
|
+
* > [NOTE] It's color and font can be customized using `titleClassName`.
|
|
19
|
+
*/
|
|
20
|
+
title: string;
|
|
21
|
+
/**
|
|
22
|
+
* Second line in the heading.
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Icon to be displayed on the left of the the heading.
|
|
27
|
+
*/
|
|
28
|
+
icon?: any;
|
|
29
|
+
/**
|
|
30
|
+
* Should we add a vertical separator between the icon and the text.
|
|
31
|
+
*/
|
|
32
|
+
separator?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Change the font and color of the heading title
|
|
35
|
+
*/
|
|
36
|
+
titleClassName?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Change the font and color of the heading description
|
|
39
|
+
*/
|
|
40
|
+
descriptionClassName?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Additional classes to add to the header of the accordion
|
|
43
|
+
* > [NOTE] useful to change the background color of the header
|
|
44
|
+
*/
|
|
45
|
+
headingClassName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* When using content that needs ti be edge to edge,
|
|
48
|
+
* removes the content wrapper from the content.
|
|
49
|
+
*/
|
|
50
|
+
fullWidthContent?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare const FIGMA_URL = "https://www.figma.com/file/1WJ3GVQyMV5e7xVxPg3yID/Design-System?node-id=2232%3A3477";
|
|
53
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;;;;;;;;CActB,CAAA;AAED,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,GAAG,CAAA;IACV;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,eAAO,MAAM,SAAS,wFACiE,CAAA"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { DetailsAnimation } from '@cypress-design/details-animation';
|
|
4
|
+
import * as iconsRegistry from '@cypress-design/icon-registry';
|
|
5
|
+
import { ICON_COLOR_PROP_NAMES } from '@cypress-design/icon-registry';
|
|
6
|
+
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
|
|
22
|
+
var __assign$1 = function() {
|
|
23
|
+
__assign$1 = Object.assign || function __assign(t) {
|
|
24
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25
|
+
s = arguments[i];
|
|
26
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
27
|
+
}
|
|
28
|
+
return t;
|
|
29
|
+
};
|
|
30
|
+
return __assign$1.apply(this, arguments);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function __rest$1(s, e) {
|
|
34
|
+
var t = {};
|
|
35
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
36
|
+
t[p] = s[p];
|
|
37
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
38
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
39
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
40
|
+
t[p[i]] = s[p[i]];
|
|
41
|
+
}
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var CssClasses = {
|
|
46
|
+
details: '',
|
|
47
|
+
summary: 'details-none min-h-65px py-12px card open:rounded-b-none px-24px flex items-center',
|
|
48
|
+
summaryColor: 'bg-white',
|
|
49
|
+
summaryTitle: 'text-18px leading-28px font-medium',
|
|
50
|
+
summaryTitleColor: 'text-indigo-500',
|
|
51
|
+
summaryDescription: 'text-14px leading-20px font-normal',
|
|
52
|
+
summaryDescriptionColor: 'text-gray-700',
|
|
53
|
+
icon: 'mr-24px flex-shrink-0',
|
|
54
|
+
separator: 'w-1px h-40px bg-gray-100 mr-16px',
|
|
55
|
+
chevron: 'flex-shrink-0 transition transform rotate-0 open:rotate-180',
|
|
56
|
+
contentWrapper: 'border border-gray-100 rounded-b-md border-t-0',
|
|
57
|
+
content: 'px-24px py-16px'
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/******************************************************************************
|
|
61
|
+
Copyright (c) Microsoft Corporation.
|
|
62
|
+
|
|
63
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
64
|
+
purpose with or without fee is hereby granted.
|
|
65
|
+
|
|
66
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
67
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
68
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
69
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
70
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
71
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
72
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
73
|
+
***************************************************************************** */
|
|
74
|
+
|
|
75
|
+
var __assign = function() {
|
|
76
|
+
__assign = Object.assign || function __assign(t) {
|
|
77
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
78
|
+
s = arguments[i];
|
|
79
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
80
|
+
}
|
|
81
|
+
return t;
|
|
82
|
+
};
|
|
83
|
+
return __assign.apply(this, arguments);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
function __rest(s, e) {
|
|
87
|
+
var t = {};
|
|
88
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
89
|
+
t[p] = s[p];
|
|
90
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
91
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
92
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
93
|
+
t[p[i]] = s[p[i]];
|
|
94
|
+
}
|
|
95
|
+
return t;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var compileReactIconProperties = function (_a) {
|
|
99
|
+
var body = _a.body, compiledClasses = _a.compiledClasses, size = _a.size, attributes = __rest(_a, ["body", "compiledClasses", "size"]);
|
|
100
|
+
var filteredAttributes = Object.keys(attributes).reduce(function (newAttributes, attrName) {
|
|
101
|
+
if (!ICON_COLOR_PROP_NAMES.includes(attrName)) {
|
|
102
|
+
newAttributes[attrName] =
|
|
103
|
+
attributes[attrName];
|
|
104
|
+
}
|
|
105
|
+
return newAttributes;
|
|
106
|
+
}, {});
|
|
107
|
+
var componentProps = __assign({ width: size, height: size, fill: 'none', dangerouslySetInnerHTML: {
|
|
108
|
+
__html: body
|
|
109
|
+
} }, filteredAttributes);
|
|
110
|
+
if (attributes.className) {
|
|
111
|
+
compiledClasses.push(attributes.className);
|
|
112
|
+
}
|
|
113
|
+
if (compiledClasses.length) {
|
|
114
|
+
componentProps.className = compiledClasses.join(' ');
|
|
115
|
+
}
|
|
116
|
+
return componentProps;
|
|
117
|
+
};
|
|
118
|
+
var IconChevronDownSmall = function (props) {
|
|
119
|
+
var _a = iconsRegistry.getComponentAttributes(__assign(__assign({}, props), { availableSizes: ["8", "16"] })), size = _a.sizeWithDefault, compiledClasses = _a.compiledClasses;
|
|
120
|
+
var iconBodies = {
|
|
121
|
+
"8": "<path d=\"m1 2.5 3 3 3-3\" stroke=\"currentColor\" class=\"icon-dark\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>",
|
|
122
|
+
"16": "<path d=\"m4 6 4 4 4-4\" stroke=\"currentColor\" class=\"icon-dark\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>"
|
|
123
|
+
};
|
|
124
|
+
var body = iconBodies[size];
|
|
125
|
+
if (!body) {
|
|
126
|
+
throw Error("Icon \"chevron-down-small\" is not available in size " + size);
|
|
127
|
+
}
|
|
128
|
+
return React.createElement('svg', compileReactIconProperties(__assign(__assign({}, props), { size: size, body: body, compiledClasses: compiledClasses })));
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/* <windicss-keep class=""> */
|
|
132
|
+
|
|
133
|
+
var Accordion = function (_a) {
|
|
134
|
+
var title = _a.title, description = _a.description, Icon = _a.icon, _b = _a.separator, separator = _b === void 0 ? false : _b, children = _a.children, headingClassName = _a.headingClassName, titleClassName = _a.titleClassName, descriptionClassName = _a.descriptionClassName, fullWidthContent = _a.fullWidthContent, rest = __rest$1(_a, ["title", "description", "icon", "separator", "children", "headingClassName", "titleClassName", "descriptionClassName", "fullWidthContent"]);
|
|
135
|
+
var details = React.useRef(null);
|
|
136
|
+
var content = React.useRef(null);
|
|
137
|
+
React.useEffect(function () {
|
|
138
|
+
if (details.current && content.current) {
|
|
139
|
+
new DetailsAnimation(details.current, content.current);
|
|
140
|
+
}
|
|
141
|
+
}, []);
|
|
142
|
+
return (React.createElement("details", __assign$1({}, rest, { className: clsx(rest.className), ref: details }),
|
|
143
|
+
React.createElement("summary", { className: clsx('flex items-center', CssClasses.summary, headingClassName !== null && headingClassName !== void 0 ? headingClassName : CssClasses.summaryColor) },
|
|
144
|
+
Icon && React.createElement(Icon, { className: CssClasses.icon }),
|
|
145
|
+
Icon && separator && React.createElement("hr", { className: CssClasses.separator }),
|
|
146
|
+
React.createElement("div", { className: "flex-grow pr-16px" },
|
|
147
|
+
React.createElement("div", { className: clsx(titleClassName !== null && titleClassName !== void 0 ? titleClassName : CssClasses.summaryTitleColor, CssClasses.summaryTitle) }, title),
|
|
148
|
+
description && (React.createElement("div", { className: clsx(CssClasses.summaryDescription, descriptionClassName !== null && descriptionClassName !== void 0 ? descriptionClassName : CssClasses.summaryDescriptionColor) }, description))),
|
|
149
|
+
React.createElement(IconChevronDownSmall, { strokeColor: "gray-300", className: clsx('open:icon-dark-gray-500', CssClasses.chevron) })),
|
|
150
|
+
React.createElement("div", { ref: content, className: CssClasses.contentWrapper }, fullWidthContent ? (React.createElement(React.Fragment, null, children)) : (React.createElement("div", { className: CssClasses.content }, children)))));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export { Accordion as default };
|
|
154
|
+
|
|
155
|
+
/* <windicss-keep class="flex items-center flex-grow pr-16px open:icon-dark-gray-500 details-none min-h-65px py-12px card open:rounded-b-none px-24px bg-white text-18px leading-28px font-medium text-indigo-500 text-14px leading-20px font-normal text-gray-700 mr-24px flex-shrink-0 w-1px h-40px bg-gray-100 mr-16px transition transform rotate-0 open:rotate-180 border border-gray-100 rounded-b-md border-t-0 py-16px"> */
|
|
156
|
+
//# sourceMappingURL=index.es.mjs.map
|