@xyo-network/react-drawer 2.81.10 → 2.82.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. package/dist/browser/components/Drawer.d.cts +1 -1
  2. package/dist/browser/components/Drawer.d.cts.map +1 -1
  3. package/dist/browser/components/Drawer.d.mts +1 -1
  4. package/dist/browser/components/Drawer.d.mts.map +1 -1
  5. package/dist/browser/components/Drawer.d.ts +1 -1
  6. package/dist/browser/components/Drawer.d.ts.map +1 -1
  7. package/dist/browser/components/index.d.cts +1 -1
  8. package/dist/browser/components/index.d.cts.map +1 -1
  9. package/dist/browser/components/index.d.mts +1 -1
  10. package/dist/browser/components/index.d.mts.map +1 -1
  11. package/dist/browser/components/index.d.ts +1 -1
  12. package/dist/browser/components/index.d.ts.map +1 -1
  13. package/dist/browser/index.cjs +46 -31
  14. package/dist/browser/index.cjs.map +1 -1
  15. package/dist/browser/index.d.cts +1 -1
  16. package/dist/browser/index.d.mts +1 -1
  17. package/dist/browser/index.d.ts +1 -1
  18. package/dist/browser/index.mjs +82 -0
  19. package/dist/browser/index.mjs.map +1 -0
  20. package/dist/neutral/components/Drawer.d.cts +1 -1
  21. package/dist/neutral/components/Drawer.d.cts.map +1 -1
  22. package/dist/neutral/components/Drawer.d.mts +1 -1
  23. package/dist/neutral/components/Drawer.d.mts.map +1 -1
  24. package/dist/neutral/components/Drawer.d.ts +1 -1
  25. package/dist/neutral/components/Drawer.d.ts.map +1 -1
  26. package/dist/neutral/components/index.d.cts +1 -1
  27. package/dist/neutral/components/index.d.cts.map +1 -1
  28. package/dist/neutral/components/index.d.mts +1 -1
  29. package/dist/neutral/components/index.d.mts.map +1 -1
  30. package/dist/neutral/components/index.d.ts +1 -1
  31. package/dist/neutral/components/index.d.ts.map +1 -1
  32. package/dist/neutral/index.cjs +46 -31
  33. package/dist/neutral/index.cjs.map +1 -1
  34. package/dist/neutral/index.d.cts +1 -1
  35. package/dist/neutral/index.d.mts +1 -1
  36. package/dist/neutral/index.d.ts +1 -1
  37. package/dist/neutral/index.mjs +82 -0
  38. package/dist/neutral/index.mjs.map +1 -0
  39. package/dist/node/components/Drawer.d.cts +1 -1
  40. package/dist/node/components/Drawer.d.cts.map +1 -1
  41. package/dist/node/components/Drawer.d.mts +1 -1
  42. package/dist/node/components/Drawer.d.mts.map +1 -1
  43. package/dist/node/components/Drawer.d.ts +1 -1
  44. package/dist/node/components/Drawer.d.ts.map +1 -1
  45. package/dist/node/components/index.d.cts +1 -1
  46. package/dist/node/components/index.d.cts.map +1 -1
  47. package/dist/node/components/index.d.mts +1 -1
  48. package/dist/node/components/index.d.mts.map +1 -1
  49. package/dist/node/components/index.d.ts +1 -1
  50. package/dist/node/components/index.d.ts.map +1 -1
  51. package/dist/node/index.cjs +46 -31
  52. package/dist/node/index.cjs.map +1 -1
  53. package/dist/node/index.d.cts +1 -1
  54. package/dist/node/index.d.mts +1 -1
  55. package/dist/node/index.d.ts +1 -1
  56. package/dist/node/index.mjs +82 -0
  57. package/dist/node/index.mjs.map +1 -0
  58. package/package.json +9 -9
  59. package/src/components/Drawer.stories.tsx +2 -2
  60. package/src/components/Drawer.tsx +20 -16
  61. package/src/components/index.ts +1 -1
  62. package/src/index.ts +1 -1
  63. package/dist/browser/index.js +0 -75
  64. package/dist/browser/index.js.map +0 -1
  65. package/dist/neutral/index.js +0 -75
  66. package/dist/neutral/index.js.map +0 -1
  67. package/dist/node/index.js +0 -75
  68. package/dist/node/index.js.map +0 -1
@@ -1,75 +0,0 @@
1
- // src/components/Drawer.tsx
2
- import { Drawer, Paper, styled, Typography } from "@mui/material";
3
- import { FlexCol } from "@xylabs/react-flexbox";
4
- import { useMemo } from "react";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- var DrawerEx = ({
7
- children,
8
- heightVariant = "full",
9
- subTitle,
10
- title,
11
- onClose,
12
- widthVariant = "partial",
13
- ...props
14
- }) => {
15
- const variantBasedProps = useMemo(() => {
16
- return {
17
- PaperProps: {
18
- sx: {
19
- alignItems: "center",
20
- background: "transparent",
21
- boxShadow: "none",
22
- height: heightVariant === "full" ? "100%" : "auto",
23
- width: widthVariant === "partial" ? "auto" : "100%"
24
- }
25
- },
26
- onClick: (event) => onClose?.(event, "backdropClick")
27
- };
28
- }, [heightVariant, onClose, widthVariant]);
29
- return /* @__PURE__ */ jsx(Drawer, { anchor: "top", onClose, ...variantBasedProps, ...props, children: /* @__PURE__ */ jsxs(
30
- StyledDrawerContentPaper,
31
- {
32
- widthVariant,
33
- elevation: 16,
34
- onClick: (event) => event.stopPropagation(),
35
- sx: { width: widthVariant === "full" ? "100%" : void 0 },
36
- children: [
37
- title || subTitle ? /* @__PURE__ */ jsxs(FlexCol, { alignItems: "start", gap: 1, children: [
38
- title ? /* @__PURE__ */ jsx(StyledEllipsisTypography, { variant: "h3", children: title }) : null,
39
- subTitle ? /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", textTransform: "none", children: subTitle }) : null
40
- ] }) : null,
41
- children
42
- ]
43
- }
44
- ) });
45
- };
46
- var StyledEllipsisTypography = styled(Typography, { name: "StyledEllipsisTypography" })(() => ({
47
- maxWidth: "100%",
48
- overflowX: "hidden",
49
- textOverflow: "ellipsis",
50
- whiteSpace: "nowrap"
51
- }));
52
- var StyledDrawerContentPaper = styled(Paper, {
53
- name: "StyledDrawerContentPaper",
54
- shouldForwardProp: (prop) => !["widthVariant"].includes(prop)
55
- })(({ theme, widthVariant }) => ({
56
- alignItems: "stretch",
57
- borderRadius: `0 0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px`,
58
- display: "flex",
59
- flexDirection: "column",
60
- gap: theme.spacing(2),
61
- height: "100%",
62
- maxWidth: "100%",
63
- overflowX: "hidden",
64
- padding: theme.spacing(3),
65
- [theme.breakpoints.up("lg")]: {
66
- width: widthVariant === "full" ? "100%" : "50%"
67
- },
68
- [theme.breakpoints.up("md")]: {
69
- width: widthVariant === "full" ? "100%" : "75%"
70
- }
71
- }));
72
- export {
73
- DrawerEx
74
- };
75
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Drawer.tsx"],"sourcesContent":["import { Drawer, DrawerProps, Paper, styled, Typography } from '@mui/material'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { MouseEvent, PropsWithChildren, useMemo } from 'react'\n\nexport interface DrawerExProps extends PropsWithChildren<DrawerProps> {\n heightVariant?: 'full' | 'auto'\n subTitle?: string\n title?: string\n widthVariant?: 'full' | 'partial'\n}\n\nexport const DrawerEx: React.FC<DrawerExProps> = ({\n children,\n heightVariant = 'full',\n subTitle,\n title,\n onClose,\n widthVariant = 'partial',\n ...props\n}) => {\n const variantBasedProps = useMemo(() => {\n return {\n PaperProps: {\n sx: {\n alignItems: 'center',\n background: 'transparent',\n boxShadow: 'none',\n height: heightVariant === 'full' ? '100%' : 'auto',\n width: widthVariant === 'partial' ? 'auto' : '100%',\n },\n },\n onClick: (event: MouseEvent) => onClose?.(event, 'backdropClick'),\n }\n }, [heightVariant, onClose, widthVariant])\n\n return (\n <Drawer anchor={'top'} onClose={onClose} {...variantBasedProps} {...props}>\n {/* Trap the event to prevent triggering the backdrop onClick */}\n <StyledDrawerContentPaper\n widthVariant={widthVariant}\n elevation={16}\n onClick={(event) => event.stopPropagation()}\n sx={{ width: widthVariant === 'full' ? '100%' : undefined }}\n >\n {title || subTitle ?\n <FlexCol alignItems=\"start\" gap={1}>\n {title ?\n <StyledEllipsisTypography variant={'h3'}>{title}</StyledEllipsisTypography>\n : null}\n {subTitle ?\n <Typography variant={'subtitle1'} textTransform=\"none\">\n {subTitle}\n </Typography>\n : null}\n </FlexCol>\n : null}\n {children}\n </StyledDrawerContentPaper>\n </Drawer>\n )\n}\n\nconst StyledEllipsisTypography = styled(Typography, { name: 'StyledEllipsisTypography' })(() => ({\n maxWidth: '100%',\n overflowX: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}))\n\nconst StyledDrawerContentPaper = styled(Paper, {\n name: 'StyledDrawerContentPaper',\n shouldForwardProp: (prop) => !['widthVariant'].includes(prop as string),\n})<DrawerExProps>(({ theme, widthVariant }) => ({\n alignItems: 'stretch',\n borderRadius: `0 0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px`,\n display: 'flex',\n flexDirection: 'column',\n gap: theme.spacing(2),\n height: '100%',\n maxWidth: '100%',\n overflowX: 'hidden',\n padding: theme.spacing(3),\n [theme.breakpoints.up('lg')]: {\n width: widthVariant === 'full' ? '100%' : '50%',\n },\n [theme.breakpoints.up('md')]: {\n width: widthVariant === 'full' ? '100%' : '75%',\n },\n}))\n"],"mappings":";AAAA,SAAS,QAAqB,OAAO,QAAQ,kBAAkB;AAC/D,SAAS,eAAe;AACxB,SAAwC,eAAe;AA2C7C,SAEI,KAFJ;AAlCH,IAAM,WAAoC,CAAC;AAAA,EAChD;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,GAAG;AACL,MAAM;AACJ,QAAM,oBAAoB,QAAQ,MAAM;AACtC,WAAO;AAAA,MACL,YAAY;AAAA,QACV,IAAI;AAAA,UACF,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,WAAW;AAAA,UACX,QAAQ,kBAAkB,SAAS,SAAS;AAAA,UAC5C,OAAO,iBAAiB,YAAY,SAAS;AAAA,QAC/C;AAAA,MACF;AAAA,MACA,SAAS,CAAC,UAAsB,UAAU,OAAO,eAAe;AAAA,IAClE;AAAA,EACF,GAAG,CAAC,eAAe,SAAS,YAAY,CAAC;AAEzC,SACE,oBAAC,UAAO,QAAQ,OAAO,SAAmB,GAAG,mBAAoB,GAAG,OAElE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,MACX,SAAS,CAAC,UAAU,MAAM,gBAAgB;AAAA,MAC1C,IAAI,EAAE,OAAO,iBAAiB,SAAS,SAAS,OAAU;AAAA,MAEzD;AAAA,iBAAS,WACR,qBAAC,WAAQ,YAAW,SAAQ,KAAK,GAC9B;AAAA,kBACC,oBAAC,4BAAyB,SAAS,MAAO,iBAAM,IAChD;AAAA,UACD,WACC,oBAAC,cAAW,SAAS,aAAa,eAAc,QAC7C,oBACH,IACA;AAAA,WACJ,IACA;AAAA,QACD;AAAA;AAAA;AAAA,EACH,GACF;AAEJ;AAEA,IAAM,2BAA2B,OAAO,YAAY,EAAE,MAAM,2BAA2B,CAAC,EAAE,OAAO;AAAA,EAC/F,UAAU;AAAA,EACV,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AACd,EAAE;AAEF,IAAM,2BAA2B,OAAO,OAAO;AAAA,EAC7C,MAAM;AAAA,EACN,mBAAmB,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,SAAS,IAAc;AACxE,CAAC,EAAiB,CAAC,EAAE,OAAO,aAAa,OAAO;AAAA,EAC9C,YAAY;AAAA,EACZ,cAAc,OAAO,MAAM,MAAM,YAAY,MAAM,MAAM,MAAM,YAAY;AAAA,EAC3E,SAAS;AAAA,EACT,eAAe;AAAA,EACf,KAAK,MAAM,QAAQ,CAAC;AAAA,EACpB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS,MAAM,QAAQ,CAAC;AAAA,EACxB,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG;AAAA,IAC5B,OAAO,iBAAiB,SAAS,SAAS;AAAA,EAC5C;AAAA,EACA,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG;AAAA,IAC5B,OAAO,iBAAiB,SAAS,SAAS;AAAA,EAC5C;AACF,EAAE;","names":[]}
@@ -1,75 +0,0 @@
1
- // src/components/Drawer.tsx
2
- import { Drawer, Paper, styled, Typography } from "@mui/material";
3
- import { FlexCol } from "@xylabs/react-flexbox";
4
- import { useMemo } from "react";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- var DrawerEx = ({
7
- children,
8
- heightVariant = "full",
9
- subTitle,
10
- title,
11
- onClose,
12
- widthVariant = "partial",
13
- ...props
14
- }) => {
15
- const variantBasedProps = useMemo(() => {
16
- return {
17
- PaperProps: {
18
- sx: {
19
- alignItems: "center",
20
- background: "transparent",
21
- boxShadow: "none",
22
- height: heightVariant === "full" ? "100%" : "auto",
23
- width: widthVariant === "partial" ? "auto" : "100%"
24
- }
25
- },
26
- onClick: (event) => onClose?.(event, "backdropClick")
27
- };
28
- }, [heightVariant, onClose, widthVariant]);
29
- return /* @__PURE__ */ jsx(Drawer, { anchor: "top", onClose, ...variantBasedProps, ...props, children: /* @__PURE__ */ jsxs(
30
- StyledDrawerContentPaper,
31
- {
32
- widthVariant,
33
- elevation: 16,
34
- onClick: (event) => event.stopPropagation(),
35
- sx: { width: widthVariant === "full" ? "100%" : void 0 },
36
- children: [
37
- title || subTitle ? /* @__PURE__ */ jsxs(FlexCol, { alignItems: "start", gap: 1, children: [
38
- title ? /* @__PURE__ */ jsx(StyledEllipsisTypography, { variant: "h3", children: title }) : null,
39
- subTitle ? /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", textTransform: "none", children: subTitle }) : null
40
- ] }) : null,
41
- children
42
- ]
43
- }
44
- ) });
45
- };
46
- var StyledEllipsisTypography = styled(Typography, { name: "StyledEllipsisTypography" })(() => ({
47
- maxWidth: "100%",
48
- overflowX: "hidden",
49
- textOverflow: "ellipsis",
50
- whiteSpace: "nowrap"
51
- }));
52
- var StyledDrawerContentPaper = styled(Paper, {
53
- name: "StyledDrawerContentPaper",
54
- shouldForwardProp: (prop) => !["widthVariant"].includes(prop)
55
- })(({ theme, widthVariant }) => ({
56
- alignItems: "stretch",
57
- borderRadius: `0 0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px`,
58
- display: "flex",
59
- flexDirection: "column",
60
- gap: theme.spacing(2),
61
- height: "100%",
62
- maxWidth: "100%",
63
- overflowX: "hidden",
64
- padding: theme.spacing(3),
65
- [theme.breakpoints.up("lg")]: {
66
- width: widthVariant === "full" ? "100%" : "50%"
67
- },
68
- [theme.breakpoints.up("md")]: {
69
- width: widthVariant === "full" ? "100%" : "75%"
70
- }
71
- }));
72
- export {
73
- DrawerEx
74
- };
75
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Drawer.tsx"],"sourcesContent":["import { Drawer, DrawerProps, Paper, styled, Typography } from '@mui/material'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { MouseEvent, PropsWithChildren, useMemo } from 'react'\n\nexport interface DrawerExProps extends PropsWithChildren<DrawerProps> {\n heightVariant?: 'full' | 'auto'\n subTitle?: string\n title?: string\n widthVariant?: 'full' | 'partial'\n}\n\nexport const DrawerEx: React.FC<DrawerExProps> = ({\n children,\n heightVariant = 'full',\n subTitle,\n title,\n onClose,\n widthVariant = 'partial',\n ...props\n}) => {\n const variantBasedProps = useMemo(() => {\n return {\n PaperProps: {\n sx: {\n alignItems: 'center',\n background: 'transparent',\n boxShadow: 'none',\n height: heightVariant === 'full' ? '100%' : 'auto',\n width: widthVariant === 'partial' ? 'auto' : '100%',\n },\n },\n onClick: (event: MouseEvent) => onClose?.(event, 'backdropClick'),\n }\n }, [heightVariant, onClose, widthVariant])\n\n return (\n <Drawer anchor={'top'} onClose={onClose} {...variantBasedProps} {...props}>\n {/* Trap the event to prevent triggering the backdrop onClick */}\n <StyledDrawerContentPaper\n widthVariant={widthVariant}\n elevation={16}\n onClick={(event) => event.stopPropagation()}\n sx={{ width: widthVariant === 'full' ? '100%' : undefined }}\n >\n {title || subTitle ?\n <FlexCol alignItems=\"start\" gap={1}>\n {title ?\n <StyledEllipsisTypography variant={'h3'}>{title}</StyledEllipsisTypography>\n : null}\n {subTitle ?\n <Typography variant={'subtitle1'} textTransform=\"none\">\n {subTitle}\n </Typography>\n : null}\n </FlexCol>\n : null}\n {children}\n </StyledDrawerContentPaper>\n </Drawer>\n )\n}\n\nconst StyledEllipsisTypography = styled(Typography, { name: 'StyledEllipsisTypography' })(() => ({\n maxWidth: '100%',\n overflowX: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}))\n\nconst StyledDrawerContentPaper = styled(Paper, {\n name: 'StyledDrawerContentPaper',\n shouldForwardProp: (prop) => !['widthVariant'].includes(prop as string),\n})<DrawerExProps>(({ theme, widthVariant }) => ({\n alignItems: 'stretch',\n borderRadius: `0 0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px`,\n display: 'flex',\n flexDirection: 'column',\n gap: theme.spacing(2),\n height: '100%',\n maxWidth: '100%',\n overflowX: 'hidden',\n padding: theme.spacing(3),\n [theme.breakpoints.up('lg')]: {\n width: widthVariant === 'full' ? '100%' : '50%',\n },\n [theme.breakpoints.up('md')]: {\n width: widthVariant === 'full' ? '100%' : '75%',\n },\n}))\n"],"mappings":";AAAA,SAAS,QAAqB,OAAO,QAAQ,kBAAkB;AAC/D,SAAS,eAAe;AACxB,SAAwC,eAAe;AA2C7C,SAEI,KAFJ;AAlCH,IAAM,WAAoC,CAAC;AAAA,EAChD;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,GAAG;AACL,MAAM;AACJ,QAAM,oBAAoB,QAAQ,MAAM;AACtC,WAAO;AAAA,MACL,YAAY;AAAA,QACV,IAAI;AAAA,UACF,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,WAAW;AAAA,UACX,QAAQ,kBAAkB,SAAS,SAAS;AAAA,UAC5C,OAAO,iBAAiB,YAAY,SAAS;AAAA,QAC/C;AAAA,MACF;AAAA,MACA,SAAS,CAAC,UAAsB,UAAU,OAAO,eAAe;AAAA,IAClE;AAAA,EACF,GAAG,CAAC,eAAe,SAAS,YAAY,CAAC;AAEzC,SACE,oBAAC,UAAO,QAAQ,OAAO,SAAmB,GAAG,mBAAoB,GAAG,OAElE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,MACX,SAAS,CAAC,UAAU,MAAM,gBAAgB;AAAA,MAC1C,IAAI,EAAE,OAAO,iBAAiB,SAAS,SAAS,OAAU;AAAA,MAEzD;AAAA,iBAAS,WACR,qBAAC,WAAQ,YAAW,SAAQ,KAAK,GAC9B;AAAA,kBACC,oBAAC,4BAAyB,SAAS,MAAO,iBAAM,IAChD;AAAA,UACD,WACC,oBAAC,cAAW,SAAS,aAAa,eAAc,QAC7C,oBACH,IACA;AAAA,WACJ,IACA;AAAA,QACD;AAAA;AAAA;AAAA,EACH,GACF;AAEJ;AAEA,IAAM,2BAA2B,OAAO,YAAY,EAAE,MAAM,2BAA2B,CAAC,EAAE,OAAO;AAAA,EAC/F,UAAU;AAAA,EACV,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AACd,EAAE;AAEF,IAAM,2BAA2B,OAAO,OAAO;AAAA,EAC7C,MAAM;AAAA,EACN,mBAAmB,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,SAAS,IAAc;AACxE,CAAC,EAAiB,CAAC,EAAE,OAAO,aAAa,OAAO;AAAA,EAC9C,YAAY;AAAA,EACZ,cAAc,OAAO,MAAM,MAAM,YAAY,MAAM,MAAM,MAAM,YAAY;AAAA,EAC3E,SAAS;AAAA,EACT,eAAe;AAAA,EACf,KAAK,MAAM,QAAQ,CAAC;AAAA,EACpB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS,MAAM,QAAQ,CAAC;AAAA,EACxB,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG;AAAA,IAC5B,OAAO,iBAAiB,SAAS,SAAS;AAAA,EAC5C;AAAA,EACA,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG;AAAA,IAC5B,OAAO,iBAAiB,SAAS,SAAS;AAAA,EAC5C;AACF,EAAE;","names":[]}
@@ -1,75 +0,0 @@
1
- // src/components/Drawer.tsx
2
- import { Drawer, Paper, styled, Typography } from "@mui/material";
3
- import { FlexCol } from "@xylabs/react-flexbox";
4
- import { useMemo } from "react";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- var DrawerEx = ({
7
- children,
8
- heightVariant = "full",
9
- subTitle,
10
- title,
11
- onClose,
12
- widthVariant = "partial",
13
- ...props
14
- }) => {
15
- const variantBasedProps = useMemo(() => {
16
- return {
17
- PaperProps: {
18
- sx: {
19
- alignItems: "center",
20
- background: "transparent",
21
- boxShadow: "none",
22
- height: heightVariant === "full" ? "100%" : "auto",
23
- width: widthVariant === "partial" ? "auto" : "100%"
24
- }
25
- },
26
- onClick: (event) => onClose == null ? void 0 : onClose(event, "backdropClick")
27
- };
28
- }, [heightVariant, onClose, widthVariant]);
29
- return /* @__PURE__ */ jsx(Drawer, { anchor: "top", onClose, ...variantBasedProps, ...props, children: /* @__PURE__ */ jsxs(
30
- StyledDrawerContentPaper,
31
- {
32
- widthVariant,
33
- elevation: 16,
34
- onClick: (event) => event.stopPropagation(),
35
- sx: { width: widthVariant === "full" ? "100%" : void 0 },
36
- children: [
37
- title || subTitle ? /* @__PURE__ */ jsxs(FlexCol, { alignItems: "start", gap: 1, children: [
38
- title ? /* @__PURE__ */ jsx(StyledEllipsisTypography, { variant: "h3", children: title }) : null,
39
- subTitle ? /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", textTransform: "none", children: subTitle }) : null
40
- ] }) : null,
41
- children
42
- ]
43
- }
44
- ) });
45
- };
46
- var StyledEllipsisTypography = styled(Typography, { name: "StyledEllipsisTypography" })(() => ({
47
- maxWidth: "100%",
48
- overflowX: "hidden",
49
- textOverflow: "ellipsis",
50
- whiteSpace: "nowrap"
51
- }));
52
- var StyledDrawerContentPaper = styled(Paper, {
53
- name: "StyledDrawerContentPaper",
54
- shouldForwardProp: (prop) => !["widthVariant"].includes(prop)
55
- })(({ theme, widthVariant }) => ({
56
- alignItems: "stretch",
57
- borderRadius: `0 0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px`,
58
- display: "flex",
59
- flexDirection: "column",
60
- gap: theme.spacing(2),
61
- height: "100%",
62
- maxWidth: "100%",
63
- overflowX: "hidden",
64
- padding: theme.spacing(3),
65
- [theme.breakpoints.up("lg")]: {
66
- width: widthVariant === "full" ? "100%" : "50%"
67
- },
68
- [theme.breakpoints.up("md")]: {
69
- width: widthVariant === "full" ? "100%" : "75%"
70
- }
71
- }));
72
- export {
73
- DrawerEx
74
- };
75
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/Drawer.tsx"],"sourcesContent":["import { Drawer, DrawerProps, Paper, styled, Typography } from '@mui/material'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { MouseEvent, PropsWithChildren, useMemo } from 'react'\n\nexport interface DrawerExProps extends PropsWithChildren<DrawerProps> {\n heightVariant?: 'full' | 'auto'\n subTitle?: string\n title?: string\n widthVariant?: 'full' | 'partial'\n}\n\nexport const DrawerEx: React.FC<DrawerExProps> = ({\n children,\n heightVariant = 'full',\n subTitle,\n title,\n onClose,\n widthVariant = 'partial',\n ...props\n}) => {\n const variantBasedProps = useMemo(() => {\n return {\n PaperProps: {\n sx: {\n alignItems: 'center',\n background: 'transparent',\n boxShadow: 'none',\n height: heightVariant === 'full' ? '100%' : 'auto',\n width: widthVariant === 'partial' ? 'auto' : '100%',\n },\n },\n onClick: (event: MouseEvent) => onClose?.(event, 'backdropClick'),\n }\n }, [heightVariant, onClose, widthVariant])\n\n return (\n <Drawer anchor={'top'} onClose={onClose} {...variantBasedProps} {...props}>\n {/* Trap the event to prevent triggering the backdrop onClick */}\n <StyledDrawerContentPaper\n widthVariant={widthVariant}\n elevation={16}\n onClick={(event) => event.stopPropagation()}\n sx={{ width: widthVariant === 'full' ? '100%' : undefined }}\n >\n {title || subTitle ?\n <FlexCol alignItems=\"start\" gap={1}>\n {title ?\n <StyledEllipsisTypography variant={'h3'}>{title}</StyledEllipsisTypography>\n : null}\n {subTitle ?\n <Typography variant={'subtitle1'} textTransform=\"none\">\n {subTitle}\n </Typography>\n : null}\n </FlexCol>\n : null}\n {children}\n </StyledDrawerContentPaper>\n </Drawer>\n )\n}\n\nconst StyledEllipsisTypography = styled(Typography, { name: 'StyledEllipsisTypography' })(() => ({\n maxWidth: '100%',\n overflowX: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n}))\n\nconst StyledDrawerContentPaper = styled(Paper, {\n name: 'StyledDrawerContentPaper',\n shouldForwardProp: (prop) => !['widthVariant'].includes(prop as string),\n})<DrawerExProps>(({ theme, widthVariant }) => ({\n alignItems: 'stretch',\n borderRadius: `0 0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px`,\n display: 'flex',\n flexDirection: 'column',\n gap: theme.spacing(2),\n height: '100%',\n maxWidth: '100%',\n overflowX: 'hidden',\n padding: theme.spacing(3),\n [theme.breakpoints.up('lg')]: {\n width: widthVariant === 'full' ? '100%' : '50%',\n },\n [theme.breakpoints.up('md')]: {\n width: widthVariant === 'full' ? '100%' : '75%',\n },\n}))\n"],"mappings":";AAAA,SAAS,QAAqB,OAAO,QAAQ,kBAAkB;AAC/D,SAAS,eAAe;AACxB,SAAwC,eAAe;AA2C7C,SAEI,KAFJ;AAlCH,IAAM,WAAoC,CAAC;AAAA,EAChD;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,GAAG;AACL,MAAM;AACJ,QAAM,oBAAoB,QAAQ,MAAM;AACtC,WAAO;AAAA,MACL,YAAY;AAAA,QACV,IAAI;AAAA,UACF,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,WAAW;AAAA,UACX,QAAQ,kBAAkB,SAAS,SAAS;AAAA,UAC5C,OAAO,iBAAiB,YAAY,SAAS;AAAA,QAC/C;AAAA,MACF;AAAA,MACA,SAAS,CAAC,UAAsB,mCAAU,OAAO;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,eAAe,SAAS,YAAY,CAAC;AAEzC,SACE,oBAAC,UAAO,QAAQ,OAAO,SAAmB,GAAG,mBAAoB,GAAG,OAElE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,MACX,SAAS,CAAC,UAAU,MAAM,gBAAgB;AAAA,MAC1C,IAAI,EAAE,OAAO,iBAAiB,SAAS,SAAS,OAAU;AAAA,MAEzD;AAAA,iBAAS,WACR,qBAAC,WAAQ,YAAW,SAAQ,KAAK,GAC9B;AAAA,kBACC,oBAAC,4BAAyB,SAAS,MAAO,iBAAM,IAChD;AAAA,UACD,WACC,oBAAC,cAAW,SAAS,aAAa,eAAc,QAC7C,oBACH,IACA;AAAA,WACJ,IACA;AAAA,QACD;AAAA;AAAA;AAAA,EACH,GACF;AAEJ;AAEA,IAAM,2BAA2B,OAAO,YAAY,EAAE,MAAM,2BAA2B,CAAC,EAAE,OAAO;AAAA,EAC/F,UAAU;AAAA,EACV,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AACd,EAAE;AAEF,IAAM,2BAA2B,OAAO,OAAO;AAAA,EAC7C,MAAM;AAAA,EACN,mBAAmB,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,SAAS,IAAc;AACxE,CAAC,EAAiB,CAAC,EAAE,OAAO,aAAa,OAAO;AAAA,EAC9C,YAAY;AAAA,EACZ,cAAc,OAAO,MAAM,MAAM,YAAY,MAAM,MAAM,MAAM,YAAY;AAAA,EAC3E,SAAS;AAAA,EACT,eAAe;AAAA,EACf,KAAK,MAAM,QAAQ,CAAC;AAAA,EACpB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS,MAAM,QAAQ,CAAC;AAAA,EACxB,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG;AAAA,IAC5B,OAAO,iBAAiB,SAAS,SAAS;AAAA,EAC5C;AAAA,EACA,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG;AAAA,IAC5B,OAAO,iBAAiB,SAAS,SAAS;AAAA,EAC5C;AACF,EAAE;","names":[]}