Socket
Socket
Sign inDemoInstall

@ajoelp/dialog-manager-react

Package Overview
Dependencies
6
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 1.0.0

dist/__tests__/DialogManager/dialogService.spec.d.ts

65

dist/dialog-manager-react.js
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = _interopDefault(require('react'));
var React = require('react');
var React__default = _interopDefault(React);
var DialogManager = function DialogManager() {
return React.createElement("div", null, "Dialog Manager");
var DialogService = /*#__PURE__*/function () {
function DialogService() {
this.dialogs = {};
}
var _proto = DialogService.prototype;
_proto.register = function register(name, dialog) {
this.dialogs[name] = dialog;
};
_proto.registerMultiple = function registerMultiple(dialogs) {
this.dialogs = dialogs;
};
_proto.get = function get(name) {
if (!this.dialogs[name]) {
throw new Error("Dialog " + name + " not found");
}
return this.dialogs[name];
};
return DialogService;
}();
var DialogService$1 = new DialogService();
var DialogManagerContext = React__default.createContext({
openDialog: function openDialog() {},
closeDialog: function closeDialog() {}
});
var DialogManager = function DialogManager(_ref) {
var children = _ref.children;
var _useState = React.useState(),
dialogName = _useState[0],
setDialogName = _useState[1];
var DialogNode = dialogName ? DialogService$1.get(dialogName) : null;
var closeDialog = function closeDialog() {
setDialogName(undefined);
};
var openDialog = function openDialog(name) {
setDialogName(name);
};
return React__default.createElement(DialogManagerContext.Provider, {
value: {
currentDialog: dialogName,
openDialog: openDialog,
closeDialog: closeDialog
}
}, children, DialogNode ? React__default.createElement(DialogNode, null) : null);
};
module.exports = DialogManager;
exports.DialogService = DialogService$1;
exports.default = DialogManager;

@@ -1,7 +0,57 @@

import React from 'react';
import React, { useState } from 'react';
const DialogManager = () => {
return React.createElement("div", null, "Dialog Manager");
class DialogService {
constructor() {
this.dialogs = {};
}
register(name, dialog) {
this.dialogs[name] = dialog;
}
registerMultiple(dialogs) {
this.dialogs = dialogs;
}
get(name) {
if (!this.dialogs[name]) {
throw new Error(`Dialog ${name} not found`);
}
return this.dialogs[name];
}
}
var DialogService$1 = new DialogService();
var DialogManagerContext = React.createContext({
openDialog: () => {},
closeDialog: () => {}
});
const DialogManager = ({
children
}) => {
const [dialogName, setDialogName] = useState();
const DialogNode = dialogName ? DialogService$1.get(dialogName) : null;
const closeDialog = () => {
setDialogName(undefined);
};
const openDialog = name => {
setDialogName(name);
};
return React.createElement(DialogManagerContext.Provider, {
value: {
currentDialog: dialogName,
openDialog,
closeDialog
}
}, children, DialogNode ? React.createElement(DialogNode, null) : null);
};
export default DialogManager;
export { DialogService$1 as DialogService };

@@ -1,7 +0,63 @@

import React from 'react';
import React, { useState } from 'react';
var DialogManager = function DialogManager() {
return React.createElement("div", null, "Dialog Manager");
var DialogService = /*#__PURE__*/function () {
function DialogService() {
this.dialogs = {};
}
var _proto = DialogService.prototype;
_proto.register = function register(name, dialog) {
this.dialogs[name] = dialog;
};
_proto.registerMultiple = function registerMultiple(dialogs) {
this.dialogs = dialogs;
};
_proto.get = function get(name) {
if (!this.dialogs[name]) {
throw new Error("Dialog " + name + " not found");
}
return this.dialogs[name];
};
return DialogService;
}();
var DialogService$1 = new DialogService();
var DialogManagerContext = React.createContext({
openDialog: function openDialog() {},
closeDialog: function closeDialog() {}
});
var DialogManager = function DialogManager(_ref) {
var children = _ref.children;
var _useState = useState(),
dialogName = _useState[0],
setDialogName = _useState[1];
var DialogNode = dialogName ? DialogService$1.get(dialogName) : null;
var closeDialog = function closeDialog() {
setDialogName(undefined);
};
var openDialog = function openDialog(name) {
setDialogName(name);
};
return React.createElement(DialogManagerContext.Provider, {
value: {
currentDialog: dialogName,
openDialog: openDialog,
closeDialog: closeDialog
}
}, children, DialogNode ? React.createElement(DialogNode, null) : null);
};
export default DialogManager;
export { DialogService$1 as DialogService };
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
typeof define === 'function' && define.amd ? define(['react'], factory) :
(global = global || self, global.DialogManager = factory(global.react));
}(this, (function (React) {
React = React && Object.prototype.hasOwnProperty.call(React, 'default') ? React['default'] : React;
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
(global = global || self, factory(global.DialogManager = {}, global.react));
}(this, (function (exports, React) {
var React__default = 'default' in React ? React['default'] : React;
var DialogManager = function DialogManager() {
return React.createElement("div", null, "Dialog Manager");
var DialogService = /*#__PURE__*/function () {
function DialogService() {
this.dialogs = {};
}
var _proto = DialogService.prototype;
_proto.register = function register(name, dialog) {
this.dialogs[name] = dialog;
};
_proto.registerMultiple = function registerMultiple(dialogs) {
this.dialogs = dialogs;
};
_proto.get = function get(name) {
if (!this.dialogs[name]) {
throw new Error("Dialog " + name + " not found");
}
return this.dialogs[name];
};
return DialogService;
}();
var DialogService$1 = new DialogService();
var DialogManagerContext = React__default.createContext({
openDialog: function openDialog() {},
closeDialog: function closeDialog() {}
});
var DialogManager = function DialogManager(_ref) {
var children = _ref.children;
var _useState = React.useState(),
dialogName = _useState[0],
setDialogName = _useState[1];
var DialogNode = dialogName ? DialogService$1.get(dialogName) : null;
var closeDialog = function closeDialog() {
setDialogName(undefined);
};
var openDialog = function openDialog(name) {
setDialogName(name);
};
return React__default.createElement(DialogManagerContext.Provider, {
value: {
currentDialog: dialogName,
openDialog: openDialog,
closeDialog: closeDialog
}
}, children, DialogNode ? React__default.createElement(DialogNode, null) : null);
};
return DialogManager;
exports.DialogService = DialogService$1;
exports.default = DialogManager;
})));

4

dist/DialogManager/index.d.ts

@@ -1,3 +0,3 @@

import { VFC } from 'react';
import { FC } from 'react';
export declare type DialogManagerProps = {};
export declare const DialogManager: VFC<DialogManagerProps>;
export declare const DialogManager: FC<DialogManagerProps>;
export { DialogManager as default, DialogManagerProps } from './DialogManager';
export { default as DialogService } from './DialogService';
{
"name": "@ajoelp/dialog-manager-react",
"version": "0.0.4",
"version": "1.0.0",
"description": "A headless dialog/modal manager for react.",

@@ -22,3 +22,3 @@ "source": "src/index.ts",

"build": "microbundle -o dist/ --name DialogManager --jsx React.createElement --compress false --sourcemap false",
"storybook": "start-storybook -p 6006",
"storybook": "start-storybook -p 6066",
"build-storybook": "build-storybook"

@@ -25,0 +25,0 @@ },

export { DialogManager as default, DialogManagerProps } from './DialogManager';
export { default as DialogService } from './DialogService';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc