@xyo-network/react-drawer 7.5.8 → 7.5.12

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.
@@ -1,11 +1,22 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // src/components/Drawer.tsx
5
- import { Drawer, Paper, styled, Typography } from "@mui/material";
2
+ import {
3
+ Drawer,
4
+ Paper,
5
+ styled,
6
+ Typography
7
+ } from "@mui/material";
6
8
  import { FlexCol } from "@xylabs/react-flexbox";
7
- import React, { useMemo } from "react";
8
- var DrawerEx = /* @__PURE__ */ __name(({ children, heightVariant = "full", subTitle, title, onClose, widthVariant = "partial", ...props }) => {
9
+ import { useMemo } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ var DrawerEx = ({
12
+ children,
13
+ heightVariant = "full",
14
+ subTitle,
15
+ title,
16
+ onClose,
17
+ widthVariant = "partial",
18
+ ...props
19
+ }) => {
9
20
  const variantBasedProps = useMemo(() => {
10
21
  return {
11
22
  PaperProps: {
@@ -17,38 +28,27 @@ var DrawerEx = /* @__PURE__ */ __name(({ children, heightVariant = "full", subTi
17
28
  width: widthVariant === "partial" ? "auto" : "100%"
18
29
  }
19
30
  },
20
- onClick: /* @__PURE__ */ __name((event) => onClose?.(event, "backdropClick"), "onClick")
31
+ onClick: (event) => onClose?.(event, "backdropClick")
21
32
  };
22
- }, [
23
- heightVariant,
24
- onClose,
25
- widthVariant
26
- ]);
27
- return /* @__PURE__ */ React.createElement(Drawer, {
28
- anchor: "top",
29
- onClose,
30
- ...variantBasedProps,
31
- ...props
32
- }, /* @__PURE__ */ React.createElement(StyledDrawerContentPaper, {
33
- widthVariant,
34
- elevation: 16,
35
- onClick: /* @__PURE__ */ __name((event) => event.stopPropagation(), "onClick"),
36
- sx: {
37
- width: widthVariant === "full" ? "100%" : void 0
33
+ }, [heightVariant, onClose, widthVariant]);
34
+ return /* @__PURE__ */ jsx(Drawer, { anchor: "top", onClose, ...variantBasedProps, ...props, children: /* @__PURE__ */ jsxs(
35
+ StyledDrawerContentPaper,
36
+ {
37
+ widthVariant,
38
+ elevation: 16,
39
+ onClick: (event) => event.stopPropagation(),
40
+ sx: { width: widthVariant === "full" ? "100%" : void 0 },
41
+ children: [
42
+ title || subTitle ? /* @__PURE__ */ jsxs(FlexCol, { alignItems: "start", gap: 1, children: [
43
+ title ? /* @__PURE__ */ jsx(StyledEllipsisTypography, { variant: "h3", children: title }) : null,
44
+ subTitle ? /* @__PURE__ */ jsx(Typography, { variant: "subtitle1", textTransform: "none", children: subTitle }) : null
45
+ ] }) : null,
46
+ children
47
+ ]
38
48
  }
39
- }, title || subTitle ? /* @__PURE__ */ React.createElement(FlexCol, {
40
- alignItems: "start",
41
- gap: 1
42
- }, title ? /* @__PURE__ */ React.createElement(StyledEllipsisTypography, {
43
- variant: "h3"
44
- }, title) : null, subTitle ? /* @__PURE__ */ React.createElement(Typography, {
45
- variant: "subtitle1",
46
- textTransform: "none"
47
- }, subTitle) : null) : null, children));
48
- }, "DrawerEx");
49
- var StyledEllipsisTypography = styled(Typography, {
50
- name: "StyledEllipsisTypography"
51
- })(() => ({
49
+ ) });
50
+ };
51
+ var StyledEllipsisTypography = styled(Typography, { name: "StyledEllipsisTypography" })(() => ({
52
52
  maxWidth: "100%",
53
53
  overflowX: "hidden",
54
54
  textOverflow: "ellipsis",
@@ -56,9 +56,7 @@ var StyledEllipsisTypography = styled(Typography, {
56
56
  }));
57
57
  var StyledDrawerContentPaper = styled(Paper, {
58
58
  name: "StyledDrawerContentPaper",
59
- shouldForwardProp: /* @__PURE__ */ __name((prop) => ![
60
- "widthVariant"
61
- ].includes(prop), "shouldForwardProp")
59
+ shouldForwardProp: (prop) => !["widthVariant"].includes(prop)
62
60
  })(({ theme, widthVariant }) => ({
63
61
  alignItems: "stretch",
64
62
  borderRadius: `0 0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px`,
@@ -69,12 +67,8 @@ var StyledDrawerContentPaper = styled(Paper, {
69
67
  maxWidth: "100%",
70
68
  overflowX: "hidden",
71
69
  padding: theme.spacing(3),
72
- [theme.breakpoints.up("lg")]: {
73
- width: widthVariant === "full" ? "100%" : "50%"
74
- },
75
- [theme.breakpoints.up("md")]: {
76
- width: widthVariant === "full" ? "100%" : "75%"
77
- }
70
+ [theme.breakpoints.up("lg")]: { width: widthVariant === "full" ? "100%" : "50%" },
71
+ [theme.breakpoints.up("md")]: { width: widthVariant === "full" ? "100%" : "75%" }
78
72
  }));
79
73
  export {
80
74
  DrawerEx
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/Drawer.tsx"],"sourcesContent":["import type { DrawerProps } from '@mui/material'\nimport {\n Drawer, Paper, styled, Typography,\n} from '@mui/material'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport type { MouseEvent, PropsWithChildren } from 'react'\nimport React, { 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: MouseEvent) => event.stopPropagation()}\n sx={{ width: widthVariant === 'full' ? '100%' : undefined }}\n >\n {title || subTitle\n ? (\n <FlexCol alignItems=\"start\" gap={1}>\n {title\n ? <StyledEllipsisTypography variant=\"h3\">{title}</StyledEllipsisTypography>\n : null}\n {subTitle\n ? (\n <Typography variant=\"subtitle1\" textTransform=\"none\">\n {subTitle}\n </Typography>\n )\n : null}\n </FlexCol>\n )\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')]: { width: widthVariant === 'full' ? '100%' : '50%' },\n [theme.breakpoints.up('md')]: { width: widthVariant === 'full' ? '100%' : '75%' },\n}))\n"],"mappings":";;;;AACA,SACEA,QAAQC,OAAOC,QAAQC,kBAClB;AACP,SAASC,eAAe;AAExB,OAAOC,SAASC,eAAe;AASxB,IAAMC,WAAoC,wBAAC,EAChDC,UACAC,gBAAgB,QAChBC,UACAC,OACAC,SACAC,eAAe,WACf,GAAGC,MAAAA,MACJ;AACC,QAAMC,oBAAoBC,QAAQ,MAAA;AAChC,WAAO;MACLC,YAAY;QACVC,IAAI;UACFC,YAAY;UACZC,YAAY;UACZC,WAAW;UACXC,QAAQb,kBAAkB,SAAS,SAAS;UAC5Cc,OAAOV,iBAAiB,YAAY,SAAS;QAC/C;MACF;MACAW,SAAS,wBAACC,UAAsBb,UAAUa,OAAO,eAAA,GAAxC;IACX;EACF,GA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AAOV,iBAAiB,SAAS,SAAS;EAAM;AAClF,EAAA;","names":["Drawer","Paper","styled","Typography","FlexCol","React","useMemo","DrawerEx","children","heightVariant","subTitle","title","onClose","widthVariant","props","variantBasedProps","useMemo","PaperProps","sx","alignItems","background","boxShadow","height","width","onClick","event","Drawer","anchor","StyledDrawerContentPaper","elevation","stopPropagation","undefined","FlexCol","gap","StyledEllipsisTypography","variant","Typography","textTransform","styled","name","maxWidth","overflowX","textOverflow","whiteSpace","Paper","shouldForwardProp","prop","includes","theme","borderRadius","shape","display","flexDirection","spacing","padding","breakpoints","up"]}
1
+ {"version":3,"sources":["../../src/components/Drawer.tsx"],"sourcesContent":["import type { DrawerProps } from '@mui/material'\nimport {\n Drawer, Paper, styled, Typography,\n} from '@mui/material'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport type { MouseEvent, PropsWithChildren } from 'react'\nimport React, { 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: MouseEvent) => event.stopPropagation()}\n sx={{ width: widthVariant === 'full' ? '100%' : undefined }}\n >\n {title || subTitle\n ? (\n <FlexCol alignItems=\"start\" gap={1}>\n {title\n ? <StyledEllipsisTypography variant=\"h3\">{title}</StyledEllipsisTypography>\n : null}\n {subTitle\n ? (\n <Typography variant=\"subtitle1\" textTransform=\"none\">\n {subTitle}\n </Typography>\n )\n : null}\n </FlexCol>\n )\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')]: { width: widthVariant === 'full' ? '100%' : '50%' },\n [theme.breakpoints.up('md')]: { width: widthVariant === 'full' ? '100%' : '75%' },\n}))\n"],"mappings":";AACA;AAAA,EACE;AAAA,EAAQ;AAAA,EAAO;AAAA,EAAQ;AAAA,OAClB;AACP,SAAS,eAAe;AAExB,SAAgB,eAAe;AA4CjB,SAEM,KAFN;AAnCP,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,SAA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AE,OAAO,iBAAiB,SAAS,SAAS,MAAM;AAAA,EAChF,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,OAAO,iBAAiB,SAAS,SAAS,MAAM;AAClF,EAAE;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/react-drawer",
3
- "version": "7.5.8",
3
+ "version": "7.5.12",
4
4
  "description": "Common React library for all XYO projects that use React",
5
5
  "keywords": [
6
6
  "xyo",
@@ -36,37 +36,57 @@
36
36
  },
37
37
  "./package.json": "./package.json"
38
38
  },
39
- "module": "dist/browser/index.mjs",
40
- "types": "dist/browser/index.d.ts",
41
39
  "files": [
42
40
  "dist",
43
- "src"
41
+ "README.md"
44
42
  ],
45
- "dependencies": {
46
- "@xylabs/react-flexbox": "~7.1.17"
47
- },
48
43
  "devDependencies": {
49
- "@mui/material": "~7.3.9",
50
- "@storybook/react-vite": "~10.3.3",
44
+ "@mui/material": "^7.3.10",
45
+ "@opentelemetry/api": "^1.9.1",
46
+ "@opentelemetry/sdk-trace-base": "^2.7.0",
47
+ "@storybook/react-vite": "~10.3.5",
48
+ "@types/node": "~25.6.0",
51
49
  "@types/react": "^19.2.14",
52
- "@xylabs/ts-scripts-common": "~7.5.6",
53
- "@xylabs/ts-scripts-yarn3": "~7.5.6",
54
- "@xylabs/tsconfig": "~7.5.6",
55
- "@xylabs/tsconfig-dom": "~7.5.6",
56
- "@xylabs/tsconfig-react": "~7.5.6",
57
- "react": "^19.2.4",
58
- "react-dom": "^19.2.4",
59
- "storybook": "~10.3.3",
50
+ "@xylabs/react-async-effect": "~7.1.20",
51
+ "@xylabs/react-flexbox": "~7.1.20",
52
+ "@xylabs/react-promise": "~7.1.20",
53
+ "@xylabs/toolchain": "~7.11.9",
54
+ "@xylabs/tsconfig": "^7.11.9",
55
+ "@xylabs/tsconfig-dom": "^7.11.9",
56
+ "@xylabs/tsconfig-react": "~7.11.9",
57
+ "async-mutex": "^0.5.0",
58
+ "axios": "^1.15.2",
59
+ "bn.js": "^5.2.3",
60
+ "buffer": "^6.0.3",
61
+ "chalk": "^5.6.2",
62
+ "esbuild": "~0.28.0",
63
+ "eslint": "^10.2.1",
64
+ "ethers": "^6.16.0",
65
+ "pako": "^2.1.0",
66
+ "react": "^19.2.5",
67
+ "react-dom": "^19.2.5",
68
+ "storybook": "^10.3.5",
60
69
  "typescript": "^5.9.3",
61
- "vite": "~8.0.3"
70
+ "vite": "^8.0.10",
71
+ "zod": "^4.3.6"
62
72
  },
63
73
  "peerDependencies": {
64
- "@mui/material": ">=6 <8",
65
- "react": "^19",
66
- "react-dom": "^19"
74
+ "@mui/material": "^7.3.10",
75
+ "@opentelemetry/sdk-trace-base": "^2.7.0",
76
+ "@xylabs/react-async-effect": "~7.1.20",
77
+ "@xylabs/react-flexbox": "~7.1.20",
78
+ "async-mutex": "^0.5.0",
79
+ "bn.js": "^5.2.3",
80
+ "buffer": "^6.0.3",
81
+ "chalk": "^5.6.2",
82
+ "ethers": "^6.16.0",
83
+ "pako": "^2.1.0",
84
+ "react": "^19.2.5",
85
+ "react-dom": "^19.2.5",
86
+ "zod": "^4.3.6"
67
87
  },
68
88
  "publishConfig": {
69
89
  "access": "public"
70
90
  },
71
91
  "docs": "dist/docs.json"
72
- }
92
+ }
@@ -1,39 +0,0 @@
1
- import type { Meta, StoryFn } from '@storybook/react-vite'
2
- import React from 'react'
3
-
4
- import type { DrawerExProps } from './Drawer.tsx'
5
- import { DrawerEx } from './Drawer.tsx'
6
-
7
- export default { title: 'modules/drawer/Ex' } as Meta
8
-
9
- const Template: StoryFn<React.FC<DrawerExProps>> = (props) => {
10
- return (
11
- <div style={{ height: 'calc(100vh - 2rem)', width: '100vw' }}>
12
- <DrawerEx {...props} />
13
- </div>
14
- )
15
- }
16
-
17
- const Default = Template.bind({})
18
- Default.args = {}
19
-
20
- const WithOpen = Template.bind({})
21
- WithOpen.args = { open: true }
22
-
23
- const WithFullScreen = Template.bind({})
24
- WithFullScreen.args = {
25
- heightVariant: 'full',
26
- open: true,
27
- widthVariant: 'full',
28
- }
29
-
30
- const WithTitles = Template.bind({})
31
- WithTitles.args = {
32
- open: true,
33
- subTitle: 'SubTitle',
34
- title: 'Title',
35
- }
36
-
37
- export {
38
- Default, WithFullScreen, WithOpen, WithTitles,
39
- }
@@ -1,93 +0,0 @@
1
- import type { DrawerProps } from '@mui/material'
2
- import {
3
- Drawer, Paper, styled, Typography,
4
- } from '@mui/material'
5
- import { FlexCol } from '@xylabs/react-flexbox'
6
- import type { MouseEvent, PropsWithChildren } from 'react'
7
- import React, { useMemo } from 'react'
8
-
9
- export interface DrawerExProps extends PropsWithChildren<DrawerProps> {
10
- heightVariant?: 'full' | 'auto'
11
- subTitle?: string
12
- title?: string
13
- widthVariant?: 'full' | 'partial'
14
- }
15
-
16
- export const DrawerEx: React.FC<DrawerExProps> = ({
17
- children,
18
- heightVariant = 'full',
19
- subTitle,
20
- title,
21
- onClose,
22
- widthVariant = 'partial',
23
- ...props
24
- }) => {
25
- const variantBasedProps = useMemo(() => {
26
- return {
27
- PaperProps: {
28
- sx: {
29
- alignItems: 'center',
30
- background: 'transparent',
31
- boxShadow: 'none',
32
- height: heightVariant === 'full' ? '100%' : 'auto',
33
- width: widthVariant === 'partial' ? 'auto' : '100%',
34
- },
35
- },
36
- onClick: (event: MouseEvent) => onClose?.(event, 'backdropClick'),
37
- }
38
- }, [heightVariant, onClose, widthVariant])
39
-
40
- return (
41
- <Drawer anchor="top" onClose={onClose} {...variantBasedProps} {...props}>
42
- {/* Trap the event to prevent triggering the backdrop onClick */}
43
- <StyledDrawerContentPaper
44
- widthVariant={widthVariant}
45
- elevation={16}
46
- onClick={(event: MouseEvent) => event.stopPropagation()}
47
- sx={{ width: widthVariant === 'full' ? '100%' : undefined }}
48
- >
49
- {title || subTitle
50
- ? (
51
- <FlexCol alignItems="start" gap={1}>
52
- {title
53
- ? <StyledEllipsisTypography variant="h3">{title}</StyledEllipsisTypography>
54
- : null}
55
- {subTitle
56
- ? (
57
- <Typography variant="subtitle1" textTransform="none">
58
- {subTitle}
59
- </Typography>
60
- )
61
- : null}
62
- </FlexCol>
63
- )
64
- : null}
65
- {children}
66
- </StyledDrawerContentPaper>
67
- </Drawer>
68
- )
69
- }
70
-
71
- const StyledEllipsisTypography = styled(Typography, { name: 'StyledEllipsisTypography' })(() => ({
72
- maxWidth: '100%',
73
- overflowX: 'hidden',
74
- textOverflow: 'ellipsis',
75
- whiteSpace: 'nowrap',
76
- }))
77
-
78
- const StyledDrawerContentPaper = styled(Paper, {
79
- name: 'StyledDrawerContentPaper',
80
- shouldForwardProp: prop => !['widthVariant'].includes(prop as string),
81
- })<DrawerExProps>(({ theme, widthVariant }) => ({
82
- alignItems: 'stretch',
83
- borderRadius: `0 0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px`,
84
- display: 'flex',
85
- flexDirection: 'column',
86
- gap: theme.spacing(2),
87
- height: '100%',
88
- maxWidth: '100%',
89
- overflowX: 'hidden',
90
- padding: theme.spacing(3),
91
- [theme.breakpoints.up('lg')]: { width: widthVariant === 'full' ? '100%' : '50%' },
92
- [theme.breakpoints.up('md')]: { width: widthVariant === 'full' ? '100%' : '75%' },
93
- }))
@@ -1 +0,0 @@
1
- export * from './Drawer.tsx'
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './components/index.ts'
@@ -1,5 +0,0 @@
1
- declare module '*.png'
2
- declare module '*.jpg'
3
- declare module '*.svg'
4
- declare module '*.gif'
5
- declare module '*.webp'