@purpurds/accordion 5.8.2 → 5.9.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/dist/LICENSE.txt +3 -3
- package/dist/accordion-item.d.ts +2 -2
- package/dist/accordion-item.d.ts.map +1 -1
- package/dist/accordion.cjs.js +2 -2
- package/dist/accordion.cjs.js.map +1 -1
- package/dist/accordion.d.ts +1 -1
- package/dist/accordion.es.js +115 -112
- package/dist/accordion.es.js.map +1 -1
- package/package.json +5 -5
- package/src/accordion-item.tsx +48 -41
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@purpurds/accordion",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.9.0",
|
4
4
|
"license": "AGPL-3.0-only",
|
5
5
|
"main": "./dist/accordion.cjs.js",
|
6
6
|
"types": "./dist/accordion.d.ts",
|
@@ -16,10 +16,10 @@
|
|
16
16
|
"dependencies": {
|
17
17
|
"classnames": "~2.5.0",
|
18
18
|
"@radix-ui/react-accordion": "~1.1.2",
|
19
|
-
"@purpurds/
|
20
|
-
"@purpurds/
|
21
|
-
"@purpurds/
|
22
|
-
"@purpurds/paragraph": "5.
|
19
|
+
"@purpurds/heading": "5.9.0",
|
20
|
+
"@purpurds/icon": "5.9.0",
|
21
|
+
"@purpurds/tokens": "5.9.0",
|
22
|
+
"@purpurds/paragraph": "5.9.0"
|
23
23
|
},
|
24
24
|
"devDependencies": {
|
25
25
|
"@rushstack/eslint-patch": "~1.10.0",
|
package/src/accordion-item.tsx
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import
|
1
|
+
import type { ForwardedRef, ReactNode } from "react";
|
2
|
+
import React, { forwardRef } from "react";
|
2
3
|
import type { HeadingTagType } from "@purpurds/heading";
|
3
4
|
import { Heading } from "@purpurds/heading";
|
4
5
|
import { IconChevronDown } from "@purpurds/icon";
|
@@ -43,45 +44,51 @@ export type AccordionItemProps = {
|
|
43
44
|
onClick?: (event: AccordionItemOnClickEvent) => void;
|
44
45
|
};
|
45
46
|
|
46
|
-
export const AccordionItem = (
|
47
|
-
|
48
|
-
className,
|
49
|
-
title,
|
50
|
-
titleTag = "h3",
|
51
|
-
negative,
|
52
|
-
onClick,
|
53
|
-
...props
|
54
|
-
}: AccordionItemProps) => {
|
55
|
-
const classes = cx([
|
56
|
-
className,
|
57
|
-
rootClassName,
|
47
|
+
export const AccordionItem = forwardRef(
|
48
|
+
(
|
58
49
|
{
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
children,
|
51
|
+
className,
|
52
|
+
title,
|
53
|
+
titleTag = "h3",
|
54
|
+
negative,
|
55
|
+
onClick,
|
56
|
+
...props
|
57
|
+
}: AccordionItemProps,
|
58
|
+
ref: ForwardedRef<HTMLButtonElement>
|
59
|
+
) => {
|
60
|
+
const classes = cx([
|
61
|
+
className,
|
62
|
+
rootClassName,
|
63
|
+
{
|
64
|
+
[`${rootClassName}--negative`]: negative,
|
65
|
+
},
|
66
|
+
]);
|
62
67
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
<
|
78
|
-
{
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
68
|
+
return (
|
69
|
+
<RadixAccordion.Item className={classes} value={title} {...props}>
|
70
|
+
<RadixAccordion.Header className={cx(`${rootClassName}__header`)} asChild>
|
71
|
+
<Heading tag={titleTag} variant="title-100" className={cx(`${rootClassName}__title`)}>
|
72
|
+
<RadixAccordion.Trigger
|
73
|
+
ref={ref}
|
74
|
+
onClick={onClick}
|
75
|
+
className={cx(`${rootClassName}__trigger`, className)}
|
76
|
+
>
|
77
|
+
{title}
|
78
|
+
<IconChevronDown size="md" className={cx(`${rootClassName}__icon`)} aria-hidden />
|
79
|
+
</RadixAccordion.Trigger>
|
80
|
+
</Heading>
|
81
|
+
</RadixAccordion.Header>
|
82
|
+
<RadixAccordion.Content className={cx(`${rootClassName}__content`, className)}>
|
83
|
+
<div className={cx(`${rootClassName}__contentText`)}>
|
84
|
+
{typeof children === "string" ? (
|
85
|
+
<Paragraph variant="paragraph-200">{children}</Paragraph>
|
86
|
+
) : (
|
87
|
+
children
|
88
|
+
)}
|
89
|
+
</div>
|
90
|
+
</RadixAccordion.Content>
|
91
|
+
</RadixAccordion.Item>
|
92
|
+
);
|
93
|
+
}
|
94
|
+
);
|