@soyfri/shared-library 1.2.2 → 1.3.1
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/cjs/components/Modal/Modal.cjs +2 -0
- package/cjs/components/Modal/Modal.cjs.map +1 -0
- package/cjs/components/Modal/ModalBody.cjs +2 -0
- package/cjs/components/Modal/ModalBody.cjs.map +1 -0
- package/cjs/components/Modal/ModalFooter.cjs +2 -0
- package/cjs/components/Modal/ModalFooter.cjs.map +1 -0
- package/cjs/components/Modal/ModalHeader.cjs +2 -0
- package/cjs/components/Modal/ModalHeader.cjs.map +1 -0
- package/cjs/components/Modal.cjs +2 -0
- package/cjs/components/Modal.cjs.map +1 -0
- package/components/Modal/index.ts +1 -0
- package/esm/components/Modal/Modal.d.ts +28 -0
- package/esm/components/Modal/Modal.js +2 -0
- package/esm/components/Modal/Modal.js.map +1 -0
- package/esm/components/Modal/Modal.stories.d.ts +12 -0
- package/esm/components/Modal/ModalBody.d.ts +6 -0
- package/esm/components/Modal/ModalBody.js +2 -0
- package/esm/components/Modal/ModalBody.js.map +1 -0
- package/esm/components/Modal/ModalFooter.d.ts +19 -0
- package/esm/components/Modal/ModalFooter.js +2 -0
- package/esm/components/Modal/ModalFooter.js.map +1 -0
- package/esm/components/Modal/ModalHeader.d.ts +6 -0
- package/esm/components/Modal/ModalHeader.js +2 -0
- package/esm/components/Modal/ModalHeader.js.map +1 -0
- package/esm/components/Modal/index.d.ts +1 -0
- package/esm/components/Modal.js +2 -0
- package/esm/components/Modal.js.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.cjs"),t=require("../../_virtual/jsx-runtime.cjs"),o=require("react"),s=require("@mui/material"),r=require("./ModalFooter.cjs"),l=require("./ModalHeader.cjs"),n=require("./ModalBody.cjs");const a={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"90%",maxHeight:"90vh",display:"flex",flexDirection:"column",outline:"none"},i=o.forwardRef((({open:i,onClose:u,title:d,children:c,showCloseButton:x=!0,closeButtonText:p="Cerrar",closeButtonDisabled:m=!1,actions:j=[],maxWidth:h="sm"},B)=>{const[b,f]=o.useState(!1),M=void 0!==i?i:b;o.useImperativeHandle(B,(()=>({open:()=>f(!0),close:()=>{f(!1),null==u||u()}})));const C=()=>{f(!1),null==u||u()},y=s.useTheme(),w=s.useMediaQuery(y.breakpoints.down("sm"));return t.jsxRuntimeExports.jsx(s.Modal,{open:M,onClose:C,"aria-labelledby":"modal-title","aria-describedby":"modal-description",closeAfterTransition:!0,children:t.jsxRuntimeExports.jsx(s.Paper,{sx:Object.assign(Object.assign({},a),{width:(()=>{if(w)return"95%";switch(h){case"xs":return 300;case"sm":return 500;case"md":return 700;case"lg":return 900;case"xl":return 1100;case!1:return"auto";default:return 500}})()}),children:(()=>{let s=null,a=null,i=null;return o.Children.forEach(c,(t=>{if(o.isValidElement(t))if(t.type===l.ModalHeader)s=t;else if(t.type===n.ModalBody)a=t;else if(t.type===r.ModalFooter){const s=t,r=s.props,{showCloseButton:l,closeButtonText:n,closeButtonDisabled:a,onClose:u,actions:d}=r,c=e.__rest(r,["showCloseButton","closeButtonText","closeButtonDisabled","onClose","actions"]);i=o.cloneElement(s,Object.assign({showCloseButton:x,closeButtonText:p,closeButtonDisabled:m,onClose:C,actions:j},c))}})),i||(i=t.jsxRuntimeExports.jsx(r.ModalFooter,{showCloseButton:x,closeButtonText:p,closeButtonDisabled:m,onClose:C,actions:j})),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[s||d&&t.jsxRuntimeExports.jsx(l.ModalHeader,{children:d}),a,i]})})()})})})),u=i;u.Header=l.ModalHeader,u.Body=n.ModalBody,u.Footer=r.ModalFooter,exports.Modal=i,exports.default=u;
|
|
2
|
+
//# sourceMappingURL=Modal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/jsx-runtime.cjs"),r=require("@mui/material");const t=({children:t})=>e.jsxRuntimeExports.jsx(r.Box,{sx:{padding:2,overflowY:"auto",flexGrow:1},children:t});exports.ModalBody=t,exports.default=t;
|
|
2
|
+
//# sourceMappingURL=ModalBody.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalBody.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/jsx-runtime.cjs"),t=require("@mui/material");const o=({children:o,showCloseButton:r=!0,closeButtonText:s="Cerrar",closeButtonDisabled:i=!1,onClose:n,actions:l=[]})=>e.jsxRuntimeExports.jsxs(t.Box,{sx:{padding:2,borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"flex-end",gap:1},children:[o,e.jsxRuntimeExports.jsxs(t.Stack,{direction:"row",spacing:1,children:[r&&e.jsxRuntimeExports.jsx(t.Button,{onClick:n,disabled:i,variant:"outlined",color:"secondary",children:s}),l.map(((o,r)=>e.jsxRuntimeExports.jsx(t.Button,{onClick:o.onClick,disabled:o.disabled,variant:o.variant||"contained",color:o.color||"primary",children:o.text},r)))]})]});exports.ModalFooter=o,exports.default=o;
|
|
2
|
+
//# sourceMappingURL=ModalFooter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalFooter.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/jsx-runtime.cjs"),t=require("@mui/material");const r=({children:r})=>e.jsxRuntimeExports.jsx(t.Box,{sx:{padding:2,borderBottom:"1px solid #e0e0e0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:e.jsxRuntimeExports.jsx(t.Typography,{variant:"h6",component:"h2",children:r})});exports.ModalHeader=r,exports.default=r;
|
|
2
|
+
//# sourceMappingURL=ModalHeader.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalHeader.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../esm/components/Modal';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DialogProps } from '@mui/material/Dialog';
|
|
3
|
+
import { ModalAction, ModalFooter } from './ModalFooter';
|
|
4
|
+
import { ModalHeader } from './ModalHeader';
|
|
5
|
+
import { ModalBody } from './ModalBody';
|
|
6
|
+
export interface ModalRef {
|
|
7
|
+
open: () => void;
|
|
8
|
+
close: () => void;
|
|
9
|
+
}
|
|
10
|
+
interface ModalProps {
|
|
11
|
+
open?: boolean;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
title?: string;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
showCloseButton?: boolean;
|
|
16
|
+
closeButtonText?: string;
|
|
17
|
+
closeButtonDisabled?: boolean;
|
|
18
|
+
actions?: ModalAction[];
|
|
19
|
+
maxWidth?: DialogProps['maxWidth'];
|
|
20
|
+
}
|
|
21
|
+
export declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<ModalRef>>;
|
|
22
|
+
type ModalComponent = React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<ModalRef>> & {
|
|
23
|
+
Header: typeof ModalHeader;
|
|
24
|
+
Body: typeof ModalBody;
|
|
25
|
+
Footer: typeof ModalFooter;
|
|
26
|
+
};
|
|
27
|
+
declare const ModalWithStatics: ModalComponent;
|
|
28
|
+
export default ModalWithStatics;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__rest as e}from"../../_virtual/_tslib.js";import{j as o}from"../../_virtual/jsx-runtime.js";import t,{forwardRef as s,useState as l,useImperativeHandle as n}from"react";import{useTheme as r,useMediaQuery as i,Modal as a,Paper as c}from"@mui/material";import{ModalFooter as u}from"./ModalFooter.js";import{ModalHeader as d}from"./ModalHeader.js";import{ModalBody as m}from"./ModalBody.js";const p={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"90%",maxHeight:"90vh",display:"flex",flexDirection:"column",outline:"none"},f=s((({open:s,onClose:f,title:x,children:h,showCloseButton:B=!0,closeButtonText:b="Cerrar",closeButtonDisabled:j=!1,actions:C=[],maxWidth:w="sm"},y)=>{const[g,D]=l(!1),T=void 0!==s?s:g;n(y,(()=>({open:()=>D(!0),close:()=>{D(!1),null==f||f()}})));const v=()=>{D(!1),null==f||f()},M=r(),E=i(M.breakpoints.down("sm"));return o.jsx(a,{open:T,onClose:v,"aria-labelledby":"modal-title","aria-describedby":"modal-description",closeAfterTransition:!0,children:o.jsx(c,{sx:Object.assign(Object.assign({},p),{width:(()=>{if(E)return"95%";switch(w){case"xs":return 300;case"sm":return 500;case"md":return 700;case"lg":return 900;case"xl":return 1100;case!1:return"auto";default:return 500}})()}),children:(()=>{let s=null,l=null,n=null;return t.Children.forEach(h,(o=>{if(t.isValidElement(o))if(o.type===d)s=o;else if(o.type===m)l=o;else if(o.type===u){const s=o,l=s.props,{showCloseButton:r,closeButtonText:i,closeButtonDisabled:a,onClose:c,actions:u}=l,d=e(l,["showCloseButton","closeButtonText","closeButtonDisabled","onClose","actions"]);n=t.cloneElement(s,Object.assign({showCloseButton:B,closeButtonText:b,closeButtonDisabled:j,onClose:v,actions:C},d))}})),n||(n=o.jsx(u,{showCloseButton:B,closeButtonText:b,closeButtonDisabled:j,onClose:v,actions:C})),o.jsxs(o.Fragment,{children:[s||x&&o.jsx(d,{children:x}),l,n]})})()})})})),x=f;x.Header=d,x.Body=m,x.Footer=u;export{f as Modal,x as default};
|
|
2
|
+
//# sourceMappingURL=Modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Modal from './Modal';
|
|
3
|
+
declare const meta: Meta<typeof Modal>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Modal>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const ImperativeControl: Story;
|
|
8
|
+
export declare const CompleteStructure: Story;
|
|
9
|
+
export declare const NoDefaultCloseButton: Story;
|
|
10
|
+
export declare const DisabledCloseButton: Story;
|
|
11
|
+
export declare const Sizing: Story;
|
|
12
|
+
export declare const LongContent: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalBody.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonProps } from '@mui/material/Button';
|
|
3
|
+
export interface ModalAction {
|
|
4
|
+
text: string;
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
variant?: ButtonProps['variant'];
|
|
8
|
+
color?: ButtonProps['color'];
|
|
9
|
+
}
|
|
10
|
+
export interface ModalFooterProps {
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
showCloseButton?: boolean;
|
|
13
|
+
closeButtonText?: string;
|
|
14
|
+
closeButtonDisabled?: boolean;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
actions?: ModalAction[];
|
|
17
|
+
}
|
|
18
|
+
export declare const ModalFooter: React.FC<ModalFooterProps>;
|
|
19
|
+
export default ModalFooter;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as o}from"../../_virtual/jsx-runtime.js";import{Box as e,Stack as i,Button as r}from"@mui/material";const n=({children:n,showCloseButton:l=!0,closeButtonText:s="Cerrar",closeButtonDisabled:t=!1,onClose:a,actions:d=[]})=>o.jsxs(e,{sx:{padding:2,borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"flex-end",gap:1},children:[n,o.jsxs(i,{direction:"row",spacing:1,children:[l&&o.jsx(r,{onClick:a,disabled:t,variant:"outlined",color:"secondary",children:s}),d.map(((e,i)=>o.jsx(r,{onClick:e.onClick,disabled:e.disabled,variant:e.variant||"contained",color:e.color||"primary",children:e.text},i)))]})]});export{n as ModalFooter,n as default};
|
|
2
|
+
//# sourceMappingURL=ModalFooter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalFooter.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e}from"../../_virtual/jsx-runtime.js";import{Box as t,Typography as i}from"@mui/material";const r=({children:r})=>e.jsx(t,{sx:{padding:2,borderBottom:"1px solid #e0e0e0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:e.jsx(i,{variant:"h6",component:"h2",children:r})});export{r as ModalHeader,r as default};
|
|
2
|
+
//# sourceMappingURL=ModalHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalHeader.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Modal } from './Modal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soyfri/shared-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -60,6 +60,11 @@
|
|
|
60
60
|
"require": "./cjs/components/Select.cjs",
|
|
61
61
|
"types": "./esm/components/Select/Select.d.ts"
|
|
62
62
|
},
|
|
63
|
+
"./components/Modal": {
|
|
64
|
+
"import": "./esm/components/Modal.js",
|
|
65
|
+
"require": "./cjs/components/Modal.cjs",
|
|
66
|
+
"types": "./esm/components/Modal/Modal.d.ts"
|
|
67
|
+
},
|
|
63
68
|
"./components/MenuButton": {
|
|
64
69
|
"import": "./esm/components/MenuButton.js",
|
|
65
70
|
"require": "./cjs/components/MenuButton.cjs",
|