@xylabs/react-accordion 6.3.12 → 6.3.14
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/browser/index.d.ts +2 -26
- package/dist/browser/index.mjs +39 -32
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type Override<T1, T2> = Omit<T1, keyof T2> & T2;
|
|
5
|
-
interface SimpleAccordionCardAdditionalProps extends AccordionProps {
|
|
6
|
-
description?: string;
|
|
7
|
-
expanded?: boolean;
|
|
8
|
-
href?: string;
|
|
9
|
-
linkText?: string;
|
|
10
|
-
name: string;
|
|
11
|
-
onChange?: () => void;
|
|
12
|
-
to?: string;
|
|
13
|
-
}
|
|
14
|
-
interface OptionalChildren {
|
|
15
|
-
children?: ReactNode;
|
|
16
|
-
}
|
|
17
|
-
type SimpleAccordionCardProps = Override<SimpleAccordionCardAdditionalProps, OptionalChildren>;
|
|
18
|
-
interface AccordionGroupProps {
|
|
19
|
-
data?: SimpleAccordionCardProps[];
|
|
20
|
-
defaultExpandedName?: string;
|
|
21
|
-
}
|
|
22
|
-
declare const AccordionGroup: React.FC<AccordionGroupProps>;
|
|
23
|
-
declare const SimpleAccordion: React.FC<SimpleAccordionCardProps>;
|
|
24
|
-
|
|
25
|
-
export { AccordionGroup, SimpleAccordion };
|
|
26
|
-
export type { SimpleAccordionCardProps };
|
|
1
|
+
export * from './AccordionGroup.tsx';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,41 +1,48 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/AccordionGroup.tsx
|
|
2
5
|
import { ExpandMoreRounded } from "@mui/icons-material";
|
|
3
|
-
import {
|
|
4
|
-
Accordion,
|
|
5
|
-
AccordionDetails,
|
|
6
|
-
AccordionSummary,
|
|
7
|
-
Typography,
|
|
8
|
-
useMediaQuery,
|
|
9
|
-
useTheme
|
|
10
|
-
} from "@mui/material";
|
|
6
|
+
import { Accordion, AccordionDetails, AccordionSummary, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
11
7
|
import { ButtonEx } from "@xylabs/react-button";
|
|
12
|
-
import { useState } from "react";
|
|
13
|
-
|
|
14
|
-
var AccordionGroup = ({ defaultExpandedName, data }) => {
|
|
8
|
+
import React, { useState } from "react";
|
|
9
|
+
var AccordionGroup = /* @__PURE__ */ __name(({ defaultExpandedName, data }) => {
|
|
15
10
|
const [expandedName, setExpandedName] = useState(() => defaultExpandedName);
|
|
16
|
-
return /* @__PURE__ */
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
expanded,
|
|
25
|
-
onChange,
|
|
26
|
-
children
|
|
27
|
-
}) => {
|
|
11
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, data?.map((item) => /* @__PURE__ */ React.createElement(SimpleAccordion, {
|
|
12
|
+
key: item.name,
|
|
13
|
+
...item,
|
|
14
|
+
expanded: item.name === expandedName,
|
|
15
|
+
onChange: /* @__PURE__ */ __name(() => setExpandedName(item.name), "onChange")
|
|
16
|
+
})));
|
|
17
|
+
}, "AccordionGroup");
|
|
18
|
+
var SimpleAccordion = /* @__PURE__ */ __name(({ name, linkText, to, href, description, expanded, onChange, children }) => {
|
|
28
19
|
const theme = useTheme();
|
|
29
20
|
const isMobile = useMediaQuery(theme.breakpoints.down("md"));
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
-
|
|
32
|
-
/* @__PURE__ */
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
return /* @__PURE__ */ React.createElement(Accordion, {
|
|
22
|
+
expanded,
|
|
23
|
+
onChange: /* @__PURE__ */ __name(() => onChange?.(), "onChange")
|
|
24
|
+
}, /* @__PURE__ */ React.createElement(AccordionSummary, {
|
|
25
|
+
expandIcon: /* @__PURE__ */ React.createElement(ExpandMoreRounded, null),
|
|
26
|
+
"aria-controls": "panel1bh-content",
|
|
27
|
+
id: "panel1bh-header"
|
|
28
|
+
}, /* @__PURE__ */ React.createElement(Typography, {
|
|
29
|
+
variant: "h6",
|
|
30
|
+
textAlign: "left",
|
|
31
|
+
gutterBottom: isMobile ? true : false
|
|
32
|
+
}, name)), /* @__PURE__ */ React.createElement(AccordionDetails, null, description && /* @__PURE__ */ React.createElement(Typography, {
|
|
33
|
+
variant: "body1",
|
|
34
|
+
fontWeight: 400,
|
|
35
|
+
textAlign: "left"
|
|
36
|
+
}, description), children, href ? /* @__PURE__ */ React.createElement(ButtonEx, {
|
|
37
|
+
href,
|
|
38
|
+
target: href ?? "_blank"
|
|
39
|
+
}, linkText ?? "Learn More") : to ? /* @__PURE__ */ React.createElement(ButtonEx, {
|
|
40
|
+
to,
|
|
41
|
+
target: href ?? "_blank"
|
|
42
|
+
}, linkText ?? "Learn More") : /* @__PURE__ */ React.createElement(ButtonEx, {
|
|
43
|
+
target: href ?? "_blank"
|
|
44
|
+
}, linkText ?? "Learn More")));
|
|
45
|
+
}, "SimpleAccordion");
|
|
39
46
|
export {
|
|
40
47
|
AccordionGroup,
|
|
41
48
|
SimpleAccordion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/AccordionGroup.tsx"],"sourcesContent":["import { ExpandMoreRounded } from '@mui/icons-material'\nimport type { AccordionProps } from '@mui/material'\nimport {\n Accordion, AccordionDetails, AccordionSummary, Typography, useMediaQuery, useTheme,\n} from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { ReactNode } from 'react'\nimport React, { useState } from 'react'\n\ntype Override<T1, T2> = Omit<T1, keyof T2> & T2\n\ninterface SimpleAccordionCardAdditionalProps extends AccordionProps {\n description?: string\n expanded?: boolean\n href?: string\n linkText?: string\n name: string\n onChange?: () => void\n to?: string\n}\n\ninterface OptionalChildren {\n children?: ReactNode\n}\n// this makes the requirement for children from AccordionProps go away\nexport type SimpleAccordionCardProps = Override<SimpleAccordionCardAdditionalProps, OptionalChildren>\n\ninterface AccordionGroupProps {\n data?: SimpleAccordionCardProps[]\n defaultExpandedName?: string\n}\n\nexport const AccordionGroup: React.FC<AccordionGroupProps> = ({ defaultExpandedName, data }) => {\n const [expandedName, setExpandedName] = useState(() => defaultExpandedName)\n\n return (\n <>\n {data?.map(item => (\n <SimpleAccordion key={item.name} {...item} expanded={item.name === expandedName} onChange={() => setExpandedName(item.name)} />\n ))}\n </>\n )\n}\nexport const SimpleAccordion: React.FC<SimpleAccordionCardProps> = ({\n name, linkText, to, href, description, expanded, onChange, children,\n}) => {\n const theme = useTheme()\n const isMobile = useMediaQuery(theme.breakpoints.down('md'))\n return (\n <Accordion expanded={expanded} onChange={() => onChange?.()}>\n <AccordionSummary expandIcon={<ExpandMoreRounded />} aria-controls=\"panel1bh-content\" id=\"panel1bh-header\">\n <Typography variant=\"h6\" textAlign=\"left\" gutterBottom={isMobile ? true : false}>\n {name}\n </Typography>\n </AccordionSummary>\n <AccordionDetails>\n {description && (\n <Typography variant=\"body1\" fontWeight={400} textAlign=\"left\">\n {description}\n </Typography>\n )}\n {children}\n {href\n ? (\n <ButtonEx href={href} target={href ?? '_blank'}>\n {linkText ?? 'Learn More'}\n </ButtonEx>\n )\n : to\n ? (\n <ButtonEx to={to} target={href ?? '_blank'}>\n {linkText ?? 'Learn More'}\n </ButtonEx>\n )\n : (\n <ButtonEx target={href ?? '_blank'}>\n {linkText ?? 'Learn More'}\n </ButtonEx>\n )}\n </AccordionDetails>\n </Accordion>\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/AccordionGroup.tsx"],"sourcesContent":["import { ExpandMoreRounded } from '@mui/icons-material'\nimport type { AccordionProps } from '@mui/material'\nimport {\n Accordion, AccordionDetails, AccordionSummary, Typography, useMediaQuery, useTheme,\n} from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { ReactNode } from 'react'\nimport React, { useState } from 'react'\n\ntype Override<T1, T2> = Omit<T1, keyof T2> & T2\n\ninterface SimpleAccordionCardAdditionalProps extends AccordionProps {\n description?: string\n expanded?: boolean\n href?: string\n linkText?: string\n name: string\n onChange?: () => void\n to?: string\n}\n\ninterface OptionalChildren {\n children?: ReactNode\n}\n// this makes the requirement for children from AccordionProps go away\nexport type SimpleAccordionCardProps = Override<SimpleAccordionCardAdditionalProps, OptionalChildren>\n\ninterface AccordionGroupProps {\n data?: SimpleAccordionCardProps[]\n defaultExpandedName?: string\n}\n\nexport const AccordionGroup: React.FC<AccordionGroupProps> = ({ defaultExpandedName, data }) => {\n const [expandedName, setExpandedName] = useState(() => defaultExpandedName)\n\n return (\n <>\n {data?.map(item => (\n <SimpleAccordion key={item.name} {...item} expanded={item.name === expandedName} onChange={() => setExpandedName(item.name)} />\n ))}\n </>\n )\n}\nexport const SimpleAccordion: React.FC<SimpleAccordionCardProps> = ({\n name, linkText, to, href, description, expanded, onChange, children,\n}) => {\n const theme = useTheme()\n const isMobile = useMediaQuery(theme.breakpoints.down('md'))\n return (\n <Accordion expanded={expanded} onChange={() => onChange?.()}>\n <AccordionSummary expandIcon={<ExpandMoreRounded />} aria-controls=\"panel1bh-content\" id=\"panel1bh-header\">\n <Typography variant=\"h6\" textAlign=\"left\" gutterBottom={isMobile ? true : false}>\n {name}\n </Typography>\n </AccordionSummary>\n <AccordionDetails>\n {description && (\n <Typography variant=\"body1\" fontWeight={400} textAlign=\"left\">\n {description}\n </Typography>\n )}\n {children}\n {href\n ? (\n <ButtonEx href={href} target={href ?? '_blank'}>\n {linkText ?? 'Learn More'}\n </ButtonEx>\n )\n : to\n ? (\n <ButtonEx to={to} target={href ?? '_blank'}>\n {linkText ?? 'Learn More'}\n </ButtonEx>\n )\n : (\n <ButtonEx target={href ?? '_blank'}>\n {linkText ?? 'Learn More'}\n </ButtonEx>\n )}\n </AccordionDetails>\n </Accordion>\n )\n}\n"],"mappings":";;;;AAAA,SAASA,yBAAyB;AAElC,SACEC,WAAWC,kBAAkBC,kBAAkBC,YAAYC,eAAeC,gBACrE;AACP,SAASC,gBAAgB;AAEzB,OAAOC,SAASC,gBAAgB;AAyBzB,IAAMC,iBAAgD,wBAAC,EAAEC,qBAAqBC,KAAI,MAAE;AACzF,QAAM,CAACC,cAAcC,eAAAA,IAAmBC,SAAS,MAAMJ,mBAAAA;AAEvD,SACE,sBAAA,cAAA,MAAA,UAAA,MACGC,MAAMI,IAAIC,CAAAA,SACT,sBAAA,cAACC,iBAAAA;IAAgBC,KAAKF,KAAKG;IAAO,GAAGH;IAAMI,UAAUJ,KAAKG,SAASP;IAAcS,UAAU,6BAAMR,gBAAgBG,KAAKG,IAAI,GAA/B;;AAInG,GAV6D;AAWtD,IAAMF,kBAAsD,wBAAC,EAClEE,MAAMG,UAAUC,IAAIC,MAAMC,aAAaL,UAAUC,UAAUK,SAAQ,MACpE;AACC,QAAMC,QAAQC,SAAAA;AACd,QAAMC,WAAWC,cAAcH,MAAMI,YAAYC,KAAK,IAAA,CAAA;AACtD,SACE,sBAAA,cAACC,WAAAA;IAAUb;IAAoBC,UAAU,6BAAMA,WAAAA,GAAN;KACvC,sBAAA,cAACa,kBAAAA;IAAiBC,YAAY,sBAAA,cAACC,mBAAAA,IAAAA;IAAsBC,iBAAc;IAAmBC,IAAG;KACvF,sBAAA,cAACC,YAAAA;IAAWC,SAAQ;IAAKC,WAAU;IAAOC,cAAcb,WAAW,OAAO;KACvEV,IAAAA,CAAAA,GAGL,sBAAA,cAACwB,kBAAAA,MACElB,eACC,sBAAA,cAACc,YAAAA;IAAWC,SAAQ;IAAQI,YAAY;IAAKH,WAAU;KACpDhB,WAAAA,GAGJC,UACAF,OAEK,sBAAA,cAACqB,UAAAA;IAASrB;IAAYsB,QAAQtB,QAAQ;KACnCF,YAAY,YAAA,IAGjBC,KAEI,sBAAA,cAACsB,UAAAA;IAAStB;IAAQuB,QAAQtB,QAAQ;KAC/BF,YAAY,YAAA,IAIf,sBAAA,cAACuB,UAAAA;IAASC,QAAQtB,QAAQ;KACvBF,YAAY,YAAA,CAAA,CAAA;AAM/B,GAvCmE;","names":["ExpandMoreRounded","Accordion","AccordionDetails","AccordionSummary","Typography","useMediaQuery","useTheme","ButtonEx","React","useState","AccordionGroup","defaultExpandedName","data","expandedName","setExpandedName","useState","map","item","SimpleAccordion","key","name","expanded","onChange","linkText","to","href","description","children","theme","useTheme","isMobile","useMediaQuery","breakpoints","down","Accordion","AccordionSummary","expandIcon","ExpandMoreRounded","aria-controls","id","Typography","variant","textAlign","gutterBottom","AccordionDetails","fontWeight","ButtonEx","target"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/react-accordion",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.14",
|
|
4
4
|
"description": "Common React library for all XY Labs projects that use React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utility",
|
|
@@ -37,20 +37,20 @@
|
|
|
37
37
|
"packages/*"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@xylabs/react-button": "^6.3.
|
|
40
|
+
"@xylabs/react-button": "^6.3.14"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@mui/icons-material": "^7.2.0",
|
|
44
44
|
"@mui/material": "^7.2.0",
|
|
45
|
-
"@storybook/react-vite": "^9.0.
|
|
45
|
+
"@storybook/react-vite": "^9.0.18",
|
|
46
46
|
"@types/react": "^19.1.8",
|
|
47
|
-
"@xylabs/react-flexbox": "^6.3.
|
|
48
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.0
|
|
49
|
-
"@xylabs/tsconfig-react": "^7.0.0
|
|
50
|
-
"knip": "^5.
|
|
47
|
+
"@xylabs/react-flexbox": "^6.3.14",
|
|
48
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.0",
|
|
49
|
+
"@xylabs/tsconfig-react": "^7.0.0",
|
|
50
|
+
"knip": "^5.62.0",
|
|
51
51
|
"react": "^19.1.0",
|
|
52
52
|
"react-dom": "^19.1.0",
|
|
53
|
-
"storybook": "^9.0.
|
|
53
|
+
"storybook": "^9.0.18",
|
|
54
54
|
"typescript": "^5.8.3"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|