@sproutsocial/seeds-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/.eslintignore +6 -0
- package/.eslintrc.js +4 -0
- package/.turbo/turbo-build.log +21 -0
- package/CHANGELOG.md +7 -0
- package/dist/esm/index.js +267 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +300 -0
- package/dist/index.js.map +1 -0
- package/jest.config.js +9 -0
- package/package.json +47 -0
- package/src/Accordion.stories.tsx +563 -0
- package/src/Accordion.tsx +63 -0
- package/src/AccordionContent.tsx +23 -0
- package/src/AccordionItem.tsx +11 -0
- package/src/AccordionTrigger.tsx +188 -0
- package/src/AccordionTypes.ts +54 -0
- package/src/__tests__/accordion.test.tsx +419 -0
- package/src/index.ts +6 -0
- package/src/styled.d.ts +7 -0
- package/src/styles.ts +194 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +12 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
Accordion: () => Accordion,
|
|
34
|
+
AccordionContent: () => AccordionContent,
|
|
35
|
+
AccordionItem: () => AccordionItem
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
|
|
39
|
+
// src/Accordion.tsx
|
|
40
|
+
var import_react = __toESM(require("react"));
|
|
41
|
+
var RadixAccordion = __toESM(require("@radix-ui/react-accordion"));
|
|
42
|
+
var import_seeds_react_icon2 = require("@sproutsocial/seeds-react-icon");
|
|
43
|
+
|
|
44
|
+
// src/AccordionTypes.ts
|
|
45
|
+
var React = require("react");
|
|
46
|
+
var import_seeds_react_system_props = require("@sproutsocial/seeds-react-system-props");
|
|
47
|
+
var import_seeds_react_icon = require("@sproutsocial/seeds-react-icon");
|
|
48
|
+
var import_seeds_react_menu = require("@sproutsocial/seeds-react-menu");
|
|
49
|
+
|
|
50
|
+
// src/Accordion.tsx
|
|
51
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
+
var AccordionContext = (0, import_react.createContext)({
|
|
53
|
+
triggerIcon: null,
|
|
54
|
+
triggerPosition: "",
|
|
55
|
+
styled: false
|
|
56
|
+
});
|
|
57
|
+
var Accordion = ({
|
|
58
|
+
children,
|
|
59
|
+
collapsible,
|
|
60
|
+
defaultValue = ["item-0"],
|
|
61
|
+
triggerPosition = "right",
|
|
62
|
+
triggerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_seeds_react_icon2.Icon, { className: "triggerIcon", name: "chevron-down-outline" }),
|
|
63
|
+
type = "multiple",
|
|
64
|
+
styled: styled2 = true
|
|
65
|
+
}) => {
|
|
66
|
+
if (type === "single") {
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
+
RadixAccordion.Root,
|
|
69
|
+
{
|
|
70
|
+
type: "single",
|
|
71
|
+
defaultValue: Array.isArray(defaultValue) ? defaultValue[0] : defaultValue,
|
|
72
|
+
collapsible,
|
|
73
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
|
+
AccordionContext.Provider,
|
|
75
|
+
{
|
|
76
|
+
value: {
|
|
77
|
+
triggerIcon: import_react.default.isValidElement(triggerIcon) ? triggerIcon : null,
|
|
78
|
+
triggerPosition,
|
|
79
|
+
styled: styled2
|
|
80
|
+
},
|
|
81
|
+
children
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
88
|
+
RadixAccordion.Root,
|
|
89
|
+
{
|
|
90
|
+
type: "multiple",
|
|
91
|
+
defaultValue: Array.isArray(defaultValue) ? defaultValue : [defaultValue],
|
|
92
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
93
|
+
AccordionContext.Provider,
|
|
94
|
+
{
|
|
95
|
+
value: {
|
|
96
|
+
triggerIcon: import_react.default.isValidElement(triggerIcon) ? triggerIcon : null,
|
|
97
|
+
triggerPosition,
|
|
98
|
+
styled: styled2
|
|
99
|
+
},
|
|
100
|
+
children
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// src/AccordionItem.tsx
|
|
108
|
+
var RadixAccordion3 = require("@radix-ui/react-accordion");
|
|
109
|
+
|
|
110
|
+
// src/styles.ts
|
|
111
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
112
|
+
var RadixAccordion2 = __toESM(require("@radix-ui/react-accordion"));
|
|
113
|
+
var import_seeds_react_system_props2 = require("@sproutsocial/seeds-react-system-props");
|
|
114
|
+
var StyledAccordionItem = (0, import_styled_components.default)(RadixAccordion2.Item)``;
|
|
115
|
+
var animations = import_styled_components.css`
|
|
116
|
+
@keyframes slideDown {
|
|
117
|
+
from {
|
|
118
|
+
height: 0;
|
|
119
|
+
}
|
|
120
|
+
to {
|
|
121
|
+
height: var(--radix-accordion-content-height);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@keyframes slideUp {
|
|
126
|
+
from {
|
|
127
|
+
height: var(--radix-accordion-content-height);
|
|
128
|
+
}
|
|
129
|
+
to {
|
|
130
|
+
height: 0;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
var StyledRadixAccordionTrigger = (0, import_styled_components.default)(
|
|
135
|
+
RadixAccordion2.Trigger
|
|
136
|
+
)`
|
|
137
|
+
padding: 0;
|
|
138
|
+
width: 100%;
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
justify-content: space-between;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
outline: none;
|
|
144
|
+
border: none;
|
|
145
|
+
background: transparent;
|
|
146
|
+
${({ theme }) => theme.typography[200]};
|
|
147
|
+
|
|
148
|
+
.triggerIcon {
|
|
149
|
+
color: ${({ theme }) => theme.colors.icon.base};
|
|
150
|
+
transition: transform 300ms ease-in-out;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
&[data-state="open"] {
|
|
154
|
+
.triggerIcon {
|
|
155
|
+
transform: rotate(-180deg);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&[data-styled] {
|
|
160
|
+
padding: ${({ theme }) => theme.space[400]};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
${import_seeds_react_system_props2.COMMON}
|
|
164
|
+
`;
|
|
165
|
+
var StyledRadixAccordionContent = (0, import_styled_components.default)(
|
|
166
|
+
RadixAccordion2.Content
|
|
167
|
+
)`
|
|
168
|
+
${animations}
|
|
169
|
+
|
|
170
|
+
overflow: hidden;
|
|
171
|
+
|
|
172
|
+
&[data-state="open"] {
|
|
173
|
+
animation: slideDown 300ms ease-in-out;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&[data-state="closed"] {
|
|
177
|
+
animation: slideUp 300ms ease-in-out;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&[data-styled="true"] {
|
|
181
|
+
border-left: ${({ theme }) => `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
|
|
182
|
+
border-right: ${({ theme }) => `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
|
|
183
|
+
background: ${({ theme }) => theme.colors.container.background.base};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.accordion-item:last-child[data-state="open"] &[data-styled="true"],
|
|
187
|
+
.accordion-item:last-child[data-state="closed"] &[data-styled="true"] {
|
|
188
|
+
border-bottom: ${({ theme }) => `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
|
|
189
|
+
border-bottom-left-radius: ${({ theme }) => theme.radii.outer};
|
|
190
|
+
border-bottom-right-radius: ${({ theme }) => theme.radii.outer};
|
|
191
|
+
}
|
|
192
|
+
`;
|
|
193
|
+
var StyledAccordionArea = import_styled_components.default.div`
|
|
194
|
+
display: flex;
|
|
195
|
+
align-items: center;
|
|
196
|
+
justify-content: space-between;
|
|
197
|
+
width: 100%;
|
|
198
|
+
`;
|
|
199
|
+
var FlexCenter = import_styled_components.default.div`
|
|
200
|
+
display: flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
`;
|
|
203
|
+
var ContentContainer = import_styled_components.default.div`
|
|
204
|
+
color: ${({ theme }) => theme.colors.text.body};
|
|
205
|
+
background: transparent;
|
|
206
|
+
font-family: ${({ theme }) => theme.fontFamily};
|
|
207
|
+
${({ theme }) => theme.typography[200]};
|
|
208
|
+
|
|
209
|
+
&[data-styled="true"] {
|
|
210
|
+
padding: ${({ theme }) => theme.space[400]};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.accordion-item:last-child[data-state="open"] &[data-styled="true"],
|
|
214
|
+
.accordion-item:last-child[data-state="closed"] &[data-styled="true"] {
|
|
215
|
+
border-bottom-left-radius: ${({ theme }) => theme.radii.outer};
|
|
216
|
+
border-bottom-right-radius: ${({ theme }) => theme.radii.outer};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
${import_seeds_react_system_props2.COMMON}
|
|
220
|
+
${import_seeds_react_system_props2.BORDER}
|
|
221
|
+
${import_seeds_react_system_props2.LAYOUT}
|
|
222
|
+
${import_seeds_react_system_props2.FLEXBOX}
|
|
223
|
+
`;
|
|
224
|
+
var TriggerContainer = import_styled_components.default.div`
|
|
225
|
+
display: flex;
|
|
226
|
+
align-items: center;
|
|
227
|
+
|
|
228
|
+
&[data-styled="true"] {
|
|
229
|
+
border-top: ${({ theme }) => `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
|
|
230
|
+
border-left: ${({ theme }) => `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
|
|
231
|
+
border-right: ${({ theme }) => `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
|
|
232
|
+
background: ${({ theme }) => theme.colors.container.background.base};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.accordion-item[data-state="open"] &[data-styled="true"] {
|
|
236
|
+
border-bottom: ${({ theme }) => `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.accordion-item[data-state="closed"] &[data-styled="true"] {
|
|
240
|
+
transition: border-bottom-color 0s ease-in-out 0.3s;
|
|
241
|
+
border-bottom: ${({ theme }) => `${theme.borderWidths[500]} solid transparent`};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.accordion-item:first-child &[data-styled="true"] {
|
|
245
|
+
border-top-left-radius: ${({ theme }) => theme.radii.outer};
|
|
246
|
+
border-top-right-radius: ${({ theme }) => theme.radii.outer};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.accordion-item:last-child &[data-styled="true"] {
|
|
250
|
+
border-bottom: ${({ theme }) => `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.accordion-item:last-child[data-state="closed"] &[data-styled="true"] {
|
|
254
|
+
transition: border-radius 0s linear 0.3s;
|
|
255
|
+
border-bottom-left-radius: ${({ theme }) => theme.radii.outer};
|
|
256
|
+
border-bottom-right-radius: ${({ theme }) => theme.radii.outer};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
${import_seeds_react_system_props2.COMMON}
|
|
260
|
+
${import_seeds_react_system_props2.BORDER}
|
|
261
|
+
${import_seeds_react_system_props2.LAYOUT}
|
|
262
|
+
${import_seeds_react_system_props2.FLEXBOX}
|
|
263
|
+
`;
|
|
264
|
+
var TitleStyles = import_styled_components.default.h4`
|
|
265
|
+
margin: 0;
|
|
266
|
+
font-size: ${({ theme }) => theme.fontSizes[200]};
|
|
267
|
+
font-weight: normal;
|
|
268
|
+
|
|
269
|
+
&[data-styled="true"] {
|
|
270
|
+
font-weight: ${({ theme }) => theme.fontWeights.semibold};
|
|
271
|
+
color: ${({ theme }) => theme.colors.text.headline};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
${import_seeds_react_system_props2.COMMON}
|
|
275
|
+
${import_seeds_react_system_props2.TYPOGRAPHY}
|
|
276
|
+
`;
|
|
277
|
+
|
|
278
|
+
// src/AccordionItem.tsx
|
|
279
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
280
|
+
var AccordionItem = ({ children, value }) => {
|
|
281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StyledAccordionItem, { className: "accordion-item", value, children });
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// src/AccordionContent.tsx
|
|
285
|
+
var import_react2 = require("react");
|
|
286
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
287
|
+
var AccordionContent = ({
|
|
288
|
+
children,
|
|
289
|
+
...rest
|
|
290
|
+
}) => {
|
|
291
|
+
const { styled: styled2 } = (0, import_react2.useContext)(AccordionContext);
|
|
292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyledRadixAccordionContent, { "data-styled": styled2, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ContentContainer, { "data-styled": styled2, ...rest, children }) });
|
|
293
|
+
};
|
|
294
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
295
|
+
0 && (module.exports = {
|
|
296
|
+
Accordion,
|
|
297
|
+
AccordionContent,
|
|
298
|
+
AccordionItem
|
|
299
|
+
});
|
|
300
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/Accordion.tsx","../src/AccordionTypes.ts","../src/AccordionItem.tsx","../src/styles.ts","../src/AccordionContent.tsx"],"sourcesContent":["import { Accordion } from \"./Accordion\";\nimport { AccordionItem } from \"./AccordionItem\";\nimport { AccordionContent } from \"./AccordionContent\";\n\nexport { Accordion, AccordionItem, AccordionContent };\nexport * from \"./AccordionTypes\";\n","import React, { createContext, type ReactElement } from \"react\";\nimport * as RadixAccordion from \"@radix-ui/react-accordion\";\nimport { Icon } from \"@sproutsocial/seeds-react-icon\";\nimport { type TypeAccordionProps } from \"./AccordionTypes\";\n\nexport const AccordionContext = createContext<{\n triggerIcon: ReactElement | null;\n triggerPosition: string;\n styled: boolean;\n}>({\n triggerIcon: null,\n triggerPosition: \"\",\n styled: false,\n});\n\nexport const Accordion = ({\n children,\n collapsible,\n defaultValue = [\"item-0\"],\n triggerPosition = \"right\",\n triggerIcon = <Icon className=\"triggerIcon\" name=\"chevron-down-outline\" />,\n type = \"multiple\",\n styled = true,\n}: TypeAccordionProps) => {\n if (type === \"single\") {\n return (\n <RadixAccordion.Root\n type=\"single\"\n defaultValue={\n Array.isArray(defaultValue) ? defaultValue[0] : defaultValue\n }\n collapsible={collapsible}\n >\n <AccordionContext.Provider\n value={{\n triggerIcon: React.isValidElement(triggerIcon) ? triggerIcon : null,\n triggerPosition,\n styled,\n }}\n >\n {children}\n </AccordionContext.Provider>\n </RadixAccordion.Root>\n );\n }\n\n return (\n <RadixAccordion.Root\n type=\"multiple\"\n defaultValue={Array.isArray(defaultValue) ? defaultValue : [defaultValue]}\n >\n <AccordionContext.Provider\n value={{\n triggerIcon: React.isValidElement(triggerIcon) ? triggerIcon : null,\n triggerPosition,\n styled,\n }}\n >\n {children}\n </AccordionContext.Provider>\n </RadixAccordion.Root>\n );\n};\n","import * as React from \"react\";\nimport {\n type TypeSystemCommonProps,\n type TypeBorderSystemProps,\n type TypeFlexboxSystemProps,\n type TypeLayoutSystemProps,\n type TypeStyledComponentsCommonProps,\n type TypeTypographySystemProps,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport { type TypeIconName } from \"@sproutsocial/seeds-react-icon\";\nimport { type TypeMenuItemProps } from \"@sproutsocial/seeds-react-menu\";\n\nexport interface TypeAccordionSystemProps\n extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"color\">,\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n TypeBorderSystemProps,\n TypeFlexboxSystemProps,\n TypeLayoutSystemProps,\n TypeTypographySystemProps {}\n\nexport interface TypeAccordionProps {\n children?: React.ReactNode;\n collapsible?: boolean;\n defaultValue: string | [string];\n triggerIcon?: React.ReactNode;\n triggerPosition?: \"left\" | \"right\";\n type?: \"single\" | \"multiple\";\n styled?: boolean;\n}\n\nexport interface TypeRelatedAction {\n iconName: TypeIconName;\n onClick: () => void;\n \"aria-label\": string;\n}\n\nexport interface TypeOverflowMenuItem extends TypeMenuItemProps {\n iconName?: TypeIconName;\n}\n\nexport interface TypeOverflowMenuConfig {\n /** Menu items to be rendered in the overflow menu */\n items: TypeOverflowMenuItem[];\n /** Aria label for the overflow menu trigger button. Defaults to \"More actions\" */\n \"aria-label\"?: string;\n}\n\nexport interface TypeAccordionItemProps {\n children: React.ReactNode;\n relatedActions?: TypeRelatedAction[];\n overflowMenu?: TypeOverflowMenuConfig;\n value: string;\n}\n","import * as RadixAccordion from \"@radix-ui/react-accordion\";\nimport { type TypeAccordionItemProps } from \"./AccordionTypes\";\nimport { StyledAccordionItem } from \"./styles\";\n\nexport const AccordionItem = ({ children, value }: TypeAccordionItemProps) => {\n return (\n <StyledAccordionItem className=\"accordion-item\" value={value}>\n {children}\n </StyledAccordionItem>\n );\n};\n","import styled, { css } from \"styled-components\";\nimport * as RadixAccordion from \"@radix-ui/react-accordion\";\nimport {\n BORDER,\n COMMON,\n FLEXBOX,\n LAYOUT,\n TYPOGRAPHY,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport { type TypeAccordionSystemProps } from \"./AccordionTypes\";\n\ninterface StyledAccordionProps extends TypeAccordionSystemProps {\n $styled?: boolean;\n}\n\nexport const StyledAccordionItem = styled(RadixAccordion.Item)``;\n\nconst animations = css`\n @keyframes slideDown {\n from {\n height: 0;\n }\n to {\n height: var(--radix-accordion-content-height);\n }\n }\n\n @keyframes slideUp {\n from {\n height: var(--radix-accordion-content-height);\n }\n to {\n height: 0;\n }\n }\n`;\n\nexport const StyledRadixAccordionTrigger = styled(\n RadixAccordion.Trigger\n)<StyledAccordionProps>`\n padding: 0;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: space-between;\n cursor: pointer;\n outline: none;\n border: none;\n background: transparent;\n ${({ theme }) => theme.typography[200]};\n\n .triggerIcon {\n color: ${({ theme }) => theme.colors.icon.base};\n transition: transform 300ms ease-in-out;\n }\n\n &[data-state=\"open\"] {\n .triggerIcon {\n transform: rotate(-180deg);\n }\n }\n\n &[data-styled] {\n padding: ${({ theme }) => theme.space[400]};\n }\n\n ${COMMON}\n`;\n\nexport const StyledRadixAccordionContent = styled(\n RadixAccordion.Content\n)<StyledAccordionProps>`\n ${animations}\n\n overflow: hidden;\n\n &[data-state=\"open\"] {\n animation: slideDown 300ms ease-in-out;\n }\n\n &[data-state=\"closed\"] {\n animation: slideUp 300ms ease-in-out;\n }\n\n &[data-styled=\"true\"] {\n border-left: ${({ theme }) =>\n `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};\n border-right: ${({ theme }) =>\n `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};\n background: ${({ theme }) => theme.colors.container.background.base};\n }\n\n .accordion-item:last-child[data-state=\"open\"] &[data-styled=\"true\"],\n .accordion-item:last-child[data-state=\"closed\"] &[data-styled=\"true\"] {\n border-bottom: ${({ theme }) =>\n `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};\n border-bottom-left-radius: ${({ theme }) => theme.radii.outer};\n border-bottom-right-radius: ${({ theme }) => theme.radii.outer};\n }\n`;\n\nexport const StyledAccordionArea = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n`;\nexport const FlexCenter = styled.div`\n display: flex;\n align-items: center;\n`;\n\nexport const ContentContainer = styled.div<StyledAccordionProps>`\n color: ${({ theme }) => theme.colors.text.body};\n background: transparent;\n font-family: ${({ theme }) => theme.fontFamily};\n ${({ theme }) => theme.typography[200]};\n\n &[data-styled=\"true\"] {\n padding: ${({ theme }) => theme.space[400]};\n }\n\n .accordion-item:last-child[data-state=\"open\"] &[data-styled=\"true\"],\n .accordion-item:last-child[data-state=\"closed\"] &[data-styled=\"true\"] {\n border-bottom-left-radius: ${({ theme }) => theme.radii.outer};\n border-bottom-right-radius: ${({ theme }) => theme.radii.outer};\n }\n\n ${COMMON}\n ${BORDER}\n\t${LAYOUT}\n\t${FLEXBOX}\n`;\n\nexport const TriggerContainer = styled.div<StyledAccordionProps>`\n display: flex;\n align-items: center;\n\n &[data-styled=\"true\"] {\n border-top: ${({ theme }) =>\n `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};\n border-left: ${({ theme }) =>\n `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};\n border-right: ${({ theme }) =>\n `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};\n background: ${({ theme }) => theme.colors.container.background.base};\n }\n\n .accordion-item[data-state=\"open\"] &[data-styled=\"true\"] {\n border-bottom: ${({ theme }) =>\n `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};\n }\n\n .accordion-item[data-state=\"closed\"] &[data-styled=\"true\"] {\n transition: border-bottom-color 0s ease-in-out 0.3s;\n border-bottom: ${({ theme }) =>\n `${theme.borderWidths[500]} solid transparent`};\n }\n\n .accordion-item:first-child &[data-styled=\"true\"] {\n border-top-left-radius: ${({ theme }) => theme.radii.outer};\n border-top-right-radius: ${({ theme }) => theme.radii.outer};\n }\n\n .accordion-item:last-child &[data-styled=\"true\"] {\n border-bottom: ${({ theme }) =>\n `${theme.borderWidths[500]} solid ${theme.colors.container.border.base}`};\n }\n\n .accordion-item:last-child[data-state=\"closed\"] &[data-styled=\"true\"] {\n transition: border-radius 0s linear 0.3s;\n border-bottom-left-radius: ${({ theme }) => theme.radii.outer};\n border-bottom-right-radius: ${({ theme }) => theme.radii.outer};\n }\n\n ${COMMON}\n ${BORDER}\n\t${LAYOUT}\n\t${FLEXBOX}\n`;\n\nexport const TitleStyles = styled.h4<StyledAccordionProps>`\n margin: 0;\n font-size: ${({ theme }) => theme.fontSizes[200]};\n font-weight: normal;\n\n &[data-styled=\"true\"] {\n font-weight: ${({ theme }) => theme.fontWeights.semibold};\n color: ${({ theme }) => theme.colors.text.headline};\n }\n\n ${COMMON}\n ${TYPOGRAPHY}\n`;\n","import { StyledRadixAccordionContent, ContentContainer } from \"./styles\";\nimport { type TypeAccordionSystemProps } from \"./AccordionTypes\";\nimport { AccordionContext } from \"./Accordion\";\nimport { useContext } from \"react\";\n\ninterface TypeAccordionContentProps extends TypeAccordionSystemProps {\n children?: React.ReactNode;\n}\n\nexport const AccordionContent = ({\n children,\n ...rest\n}: TypeAccordionContentProps) => {\n const { styled } = useContext(AccordionContext);\n\n return (\n <StyledRadixAccordionContent data-styled={styled}>\n <ContentContainer data-styled={styled} {...rest}>\n {children}\n </ContentContainer>\n </StyledRadixAccordionContent>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAwD;AACxD,qBAAgC;AAChC,IAAAA,2BAAqB;;;ACFrB,YAAuB;AACvB,sCAOO;AACP,8BAAkC;AAClC,8BAAuC;;;ADUvB;AAfT,IAAM,uBAAmB,4BAI7B;AAAA,EACD,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,QAAQ;AACV,CAAC;AAEM,IAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA,eAAe,CAAC,QAAQ;AAAA,EACxB,kBAAkB;AAAA,EAClB,cAAc,4CAAC,iCAAK,WAAU,eAAc,MAAK,wBAAuB;AAAA,EACxE,OAAO;AAAA,EACP,QAAAC,UAAS;AACX,MAA0B;AACxB,MAAI,SAAS,UAAU;AACrB,WACE;AAAA,MAAgB;AAAA,MAAf;AAAA,QACC,MAAK;AAAA,QACL,cACE,MAAM,QAAQ,YAAY,IAAI,aAAa,CAAC,IAAI;AAAA,QAElD;AAAA,QAEA;AAAA,UAAC,iBAAiB;AAAA,UAAjB;AAAA,YACC,OAAO;AAAA,cACL,aAAa,aAAAC,QAAM,eAAe,WAAW,IAAI,cAAc;AAAA,cAC/D;AAAA,cACA,QAAAD;AAAA,YACF;AAAA,YAE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,QAAQ;AAAA,aAC/C,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,KAAK,QAAQ;AAAA;AAAA;AAAA,IAGlD,uCAAM;AAAA,IACN,2CAAU;AAAA;;;AD1LV,IAAAC,sBAAA;AAFG,IAAM,gBAAgB,CAAC,EAAE,UAAU,MAAM,MAA8B;AAC5E,SACE,6CAAC,uBAAoB,WAAU,kBAAiB,OAC7C,UACH;AAEJ;;;AEPA,IAAAC,gBAA2B;AAcrB,IAAAC,sBAAA;AARC,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,GAAG;AACL,MAAiC;AAC/B,QAAM,EAAE,QAAAC,QAAO,QAAI,0BAAW,gBAAgB;AAE9C,SACE,6CAAC,+BAA4B,eAAaA,SACxC,uDAAC,oBAAiB,eAAaA,SAAS,GAAG,MACxC,UACH,GACF;AAEJ;","names":["import_seeds_react_icon","styled","React","RadixAccordion","RadixAccordion","import_seeds_react_system_props","styled","import_jsx_runtime","import_react","import_jsx_runtime","styled"]}
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sproutsocial/seeds-react-accordion",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Seeds React Accordion",
|
|
5
|
+
"author": "Sprout Social, Inc.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/esm/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsup --dts",
|
|
12
|
+
"build:debug": "tsup --dts --metafile",
|
|
13
|
+
"dev": "tsup --watch --dts",
|
|
14
|
+
"clean": "rm -rf .turbo dist",
|
|
15
|
+
"clean:modules": "rm -rf node_modules",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"test": "jest",
|
|
18
|
+
"test:watch": "jest --watch --coverage=false"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@radix-ui/react-accordion": "1.2.12",
|
|
22
|
+
"@sproutsocial/seeds-react-theme": "^3.1.0",
|
|
23
|
+
"@sproutsocial/seeds-react-system-props": "^3.0.1",
|
|
24
|
+
"@sproutsocial/seeds-react-box": "1.1.5",
|
|
25
|
+
"@sproutsocial/seeds-react-button": "1.3.2",
|
|
26
|
+
"@sproutsocial/seeds-react-icon": "1.1.6",
|
|
27
|
+
"@sproutsocial/seeds-react-menu": "1.6.13"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/react": "^18.0.0",
|
|
31
|
+
"@types/styled-components": "^5.1.26",
|
|
32
|
+
"@sproutsocial/eslint-config-seeds": "*",
|
|
33
|
+
"react": "^18.0.0",
|
|
34
|
+
"styled-components": "^5.2.3",
|
|
35
|
+
"tsup": "^8.3.4",
|
|
36
|
+
"typescript": "^5.6.2",
|
|
37
|
+
"@sproutsocial/seeds-tsconfig": "*",
|
|
38
|
+
"@sproutsocial/seeds-testing": "*",
|
|
39
|
+
"@sproutsocial/seeds-react-testing-library": "*"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"styled-components": "^5.2.3"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
}
|
|
47
|
+
}
|