bitmax-dialog
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -9,3 +9,2 @@ 'use strict'; | ||
var React__default = _interopDefault(React); | ||
var uuid = _interopDefault(require('uuid')); | ||
@@ -36,3 +35,3 @@ function _extends() { | ||
setModals([].concat(modals, [{ | ||
id: uuid.v4(), | ||
id: new Date().getTime().toString(), | ||
data: data, | ||
@@ -71,3 +70,3 @@ element: element, | ||
}, modal)); | ||
}), React__default.createElement("code", null, JSON.stringify(modals, null, 2))); | ||
})); | ||
} | ||
@@ -140,2 +139,3 @@ function ModalItemProvider(modal) { | ||
var handleAnimationEnd = function handleAnimationEnd(ev) { | ||
console.log('close', ev); | ||
if (ev.animationName == 'exit') { | ||
@@ -142,0 +142,0 @@ remove(); |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),o=e(require("uuid"));function a(){return(a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}var r=n.createContext({}),l=n.createContext({});function i(e){var o=t.useState({size:"sm",title:"",closable:!1}),r=o[0],i=o[1];return n.createElement(l.Provider,{value:{id:e.id,data:e.data,updateOptions:function(e){i((function(t){return a({},t,e)}))}}},n.createElement(s,{element:e.element,id:e.id,data:e.data,title:r.title,size:r.size,closed:e.closed}))}function c(){var e=t.useContext(l),n=t.useContext(r);return function(t){n.closeModal(e.id,t)}}function d(){var e=t.useContext(l),n=t.useContext(r);return function(){n.removeModal(e.id)}}var u={xs:480,sm:640,md:768,lg:1024,xl:1280,"2xl":1536};function s(e){var t=c(),o=d();return n.createElement("div",{className:"dialog"},n.createElement("div",{onClick:function(){return t()},className:"dialog-backdrop"}),n.createElement("div",{onAnimationEnd:function(e){"exit"==e.animationName&&o()},style:{maxWidth:u[e.size||"md"]},className:"dialog-content "+(e.closed?"closed":"")},n.createElement("div",{className:"dialog-header"},n.createElement("h1",{className:"dialog-title"},e.title),n.createElement("button",{className:"dialog-close",onClick:function(){return t()}},n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},n.createElement("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"})))),n.createElement("div",{className:"dialog-body"},n.createElement(e.element,null))))}exports.Dialog=s,exports.ModalItemContext=l,exports.ModalItemProvider=i,exports.ModalProvider=function(e){var l=t.useState([]),c=l[0],d=l[1];return n.createElement(r.Provider,{value:{removeModal:function(e){d(c.filter((function(t){return t.id!==e})))},addModal:function(e,t){return new Promise((function(n){d([].concat(c,[{id:o.v4(),data:t,element:e,onClose:n,closed:!1}]))}))},closeModal:function(e,t){var n=c.find((function(t){return t.id==e}));null==n||n.onClose(t),d(c.map((function(t){return a({},t,{closed:t.id==e})})))}}},e.children,c.map((function(e){return n.createElement(i,Object.assign({key:e.id},e))})),n.createElement("code",null,JSON.stringify(c,null,2)))},exports.ModalRootContext=r,exports.useModalClose=c,exports.useModalData=function(){return t.useContext(l).data},exports.useModalRemove=d,exports.useOpenModal=function(e){var n=t.useContext(r);return function(t){return n.addModal(e,t)}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}var a=n.createContext({}),r=n.createContext({});function l(e){var a=t.useState({size:"sm",title:"",closable:!1}),l=a[0],i=a[1];return n.createElement(r.Provider,{value:{id:e.id,data:e.data,updateOptions:function(e){i((function(t){return o({},t,e)}))}}},n.createElement(d,{element:e.element,id:e.id,data:e.data,title:l.title,size:l.size,closed:e.closed}))}function i(){var e=t.useContext(r),n=t.useContext(a);return function(t){n.closeModal(e.id,t)}}function c(){var e=t.useContext(r),n=t.useContext(a);return function(){n.removeModal(e.id)}}var s={xs:480,sm:640,md:768,lg:1024,xl:1280,"2xl":1536};function d(e){var t=i(),o=c();return n.createElement("div",{className:"dialog"},n.createElement("div",{onClick:function(){return t()},className:"dialog-backdrop"}),n.createElement("div",{onAnimationEnd:function(e){console.log("close",e),"exit"==e.animationName&&o()},style:{maxWidth:s[e.size||"md"]},className:"dialog-content "+(e.closed?"closed":"")},n.createElement("div",{className:"dialog-header"},n.createElement("h1",{className:"dialog-title"},e.title),n.createElement("button",{className:"dialog-close",onClick:function(){return t()}},n.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},n.createElement("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"})))),n.createElement("div",{className:"dialog-body"},n.createElement(e.element,null))))}exports.Dialog=d,exports.ModalItemContext=r,exports.ModalItemProvider=l,exports.ModalProvider=function(e){var r=t.useState([]),i=r[0],c=r[1];return n.createElement(a.Provider,{value:{removeModal:function(e){c(i.filter((function(t){return t.id!==e})))},addModal:function(e,t){return new Promise((function(n){c([].concat(i,[{id:(new Date).getTime().toString(),data:t,element:e,onClose:n,closed:!1}]))}))},closeModal:function(e,t){var n=i.find((function(t){return t.id==e}));null==n||n.onClose(t),c(i.map((function(t){return o({},t,{closed:t.id==e})})))}}},e.children,i.map((function(e){return n.createElement(l,Object.assign({key:e.id},e))})))},exports.ModalRootContext=a,exports.useModalClose=i,exports.useModalData=function(){return t.useContext(r).data},exports.useModalRemove=c,exports.useOpenModal=function(e){var n=t.useContext(a);return function(t){return n.addModal(e,t)}}; | ||
//# sourceMappingURL=bitmax-dialog.cjs.production.min.js.map |
import React, { useState, useContext } from 'react'; | ||
import uuid from 'uuid'; | ||
@@ -28,3 +27,3 @@ function _extends() { | ||
setModals([].concat(modals, [{ | ||
id: uuid.v4(), | ||
id: new Date().getTime().toString(), | ||
data: data, | ||
@@ -63,3 +62,3 @@ element: element, | ||
}, modal)); | ||
}), React.createElement("code", null, JSON.stringify(modals, null, 2))); | ||
})); | ||
} | ||
@@ -132,2 +131,3 @@ function ModalItemProvider(modal) { | ||
var handleAnimationEnd = function handleAnimationEnd(ev) { | ||
console.log('close', ev); | ||
if (ev.animationName == 'exit') { | ||
@@ -134,0 +134,0 @@ remove(); |
{ | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
@@ -53,2 +53,3 @@ "main": "dist/index.js", | ||
"@types/react-dom": "^18.0.11", | ||
"@types/uuid": "^9.0.1", | ||
"autoprefixer": "^10.4.14", | ||
@@ -55,0 +56,0 @@ "husky": "^8.0.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70884
15
700