piral-modals 1.6.0-beta.7216 → 1.6.0-beta.7243

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/lib/Modals.js CHANGED
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Modals = void 0;
4
- const React = require("react");
5
- const piral_core_1 = require("piral-core");
6
- const components_1 = require("./components");
1
+ import * as React from 'react';
2
+ import { useGlobalState } from 'piral-core';
3
+ import { PiralModalsDialog, PiralModalsHost } from './components';
7
4
  function closeAll(modals) {
8
5
  modals.forEach((m) => m.close());
9
6
  }
@@ -16,9 +13,9 @@ function findModal(modals, name) {
16
13
  }
17
14
  return undefined;
18
15
  }
19
- const Modals = () => {
20
- const modals = (0, piral_core_1.useGlobalState)((s) => s.registry.modals);
21
- const dialogs = (0, piral_core_1.useGlobalState)((s) => s.modals);
16
+ export const Modals = () => {
17
+ const modals = useGlobalState((s) => s.registry.modals);
18
+ const dialogs = useGlobalState((s) => s.modals);
22
19
  const close = () => closeAll(dialogs);
23
20
  const children = dialogs
24
21
  .map((n) => {
@@ -29,13 +26,12 @@ const Modals = () => {
29
26
  ...defaults,
30
27
  ...n.options,
31
28
  };
32
- return (Component && (React.createElement(components_1.PiralModalsDialog, { ...n, options: options, defaults: reg.defaults, layout: reg.layout, key: n.name },
29
+ return (Component && (React.createElement(PiralModalsDialog, { ...n, options: options, defaults: reg.defaults, layout: reg.layout, key: n.name },
33
30
  React.createElement(Component, { onClose: n.close, options: options }))));
34
31
  })
35
32
  .filter(Boolean);
36
33
  const open = children.length > 0;
37
- return (React.createElement(components_1.PiralModalsHost, { open: open, close: close }, children));
34
+ return (React.createElement(PiralModalsHost, { open: open, close: close }, children));
38
35
  };
39
- exports.Modals = Modals;
40
- exports.Modals.displayName = 'Modals';
36
+ Modals.displayName = 'Modals';
41
37
  //# sourceMappingURL=Modals.js.map
package/lib/Modals.js.map CHANGED
@@ -1 +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C,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,CAC/B,CACrB,CACF,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAEjC,OAAO,CACL,oBAAC,eAAe,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,IACtC,QAAQ,CACO,CACnB,CAAC;AACJ,CAAC,CAAC;AACF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
package/lib/actions.js CHANGED
@@ -1,39 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unregisterModal = exports.registerModal = exports.closeModal = exports.openModal = void 0;
4
- const piral_core_1 = require("piral-core");
5
- function openModal(ctx, dialog) {
1
+ import { withKey, withoutKey, prependItem, excludeOn } from 'piral-core';
2
+ export function openModal(ctx, dialog) {
6
3
  ctx.dispatch((state) => ({
7
4
  ...state,
8
- modals: (0, piral_core_1.prependItem)(state.modals, dialog),
5
+ modals: prependItem(state.modals, dialog),
9
6
  }));
10
7
  }
11
- exports.openModal = openModal;
12
- function closeModal(ctx, dialog) {
8
+ export function closeModal(ctx, dialog) {
13
9
  ctx.dispatch((state) => ({
14
10
  ...state,
15
- modals: (0, piral_core_1.excludeOn)(state.modals, (modal) => modal.id === dialog.id),
11
+ modals: excludeOn(state.modals, (modal) => modal.id === dialog.id),
16
12
  }));
17
13
  }
18
- exports.closeModal = closeModal;
19
- function registerModal(ctx, name, value) {
14
+ export function registerModal(ctx, name, value) {
20
15
  ctx.dispatch((state) => ({
21
16
  ...state,
22
17
  registry: {
23
18
  ...state.registry,
24
- modals: (0, piral_core_1.withKey)(state.registry.modals, name, value),
19
+ modals: withKey(state.registry.modals, name, value),
25
20
  },
26
21
  }));
27
22
  }
28
- exports.registerModal = registerModal;
29
- function unregisterModal(ctx, name) {
23
+ export function unregisterModal(ctx, name) {
30
24
  ctx.dispatch((state) => ({
31
25
  ...state,
32
26
  registry: {
33
27
  ...state.registry,
34
- modals: (0, piral_core_1.withoutKey)(state.registry.modals, name),
28
+ modals: withoutKey(state.registry.modals, name),
35
29
  },
36
30
  }));
37
31
  }
38
- exports.unregisterModal = unregisterModal;
39
32
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;AAAA,2CAA6F;AAG7F,SAAgB,SAAS,CAAC,GAAuB,EAAE,MAAuB;IACxE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,GAAG,KAAK;QACR,MAAM,EAAE,IAAA,wBAAW,EAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC;KAC1C,CAAC,CAAC,CAAC;AACN,CAAC;AALD,8BAKC;AAED,SAAgB,UAAU,CAAC,GAAuB,EAAE,MAAuB;IACzE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,GAAG,KAAK;QACR,MAAM,EAAE,IAAA,sBAAS,EAAC,KAAK,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC;KACnE,CAAC,CAAC,CAAC;AACN,CAAC;AALD,gCAKC;AAED,SAAgB,aAAa,CAAC,GAAuB,EAAE,IAAY,EAAE,KAAwB;IAC3F,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,GAAG,KAAK;QACR,QAAQ,EAAE;YACR,GAAG,KAAK,CAAC,QAAQ;YACjB,MAAM,EAAE,IAAA,oBAAO,EAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC;SACpD;KACF,CAAC,CAAC,CAAC;AACN,CAAC;AARD,sCAQC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,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC;SACpD;KACF,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAuB,EAAE,IAAY;IACnE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,GAAG,KAAK;QACR,QAAQ,EAAE;YACR,GAAG,KAAK,CAAC,QAAQ;YACjB,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;SAChD;KACF,CAAC,CAAC,CAAC;AACN,CAAC"}
package/lib/components.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PiralModalsDialog = exports.PiralModalsHost = void 0;
4
- const piral_core_1 = require("piral-core");
5
- exports.PiralModalsHost = (0, piral_core_1.getPiralComponent)('ModalsHost');
6
- exports.PiralModalsDialog = (0, piral_core_1.getPiralComponent)('ModalsDialog');
1
+ import { getPiralComponent } from 'piral-core';
2
+ export const PiralModalsHost = getPiralComponent('ModalsHost');
3
+ export const PiralModalsDialog = getPiralComponent('ModalsDialog');
7
4
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":";;;AAAA,2CAA+C;AAElC,QAAA,eAAe,GAAG,IAAA,8BAAiB,EAAC,YAAY,CAAC,CAAC;AAClD,QAAA,iBAAiB,GAAG,IAAA,8BAAiB,EAAC,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC"}
package/lib/create.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createModalsApi = void 0;
4
- const actions = require("./actions");
5
- const piral_core_1 = require("piral-core");
6
- const default_1 = require("./default");
7
- const Modals_1 = require("./Modals");
1
+ import * as actions from './actions';
2
+ import { withApi, buildName, withRootExtension, withAll } from 'piral-core';
3
+ import { DefaultHost, DefaultDialog } from './default';
4
+ import { Modals } from './Modals';
8
5
  function getModalDialogs(dialogs) {
9
6
  const modals = {};
10
7
  for (const { name, component, defaults, layout = {} } of dialogs) {
@@ -22,8 +19,8 @@ function withModals(modals) {
22
19
  return (state) => ({
23
20
  ...state,
24
21
  components: {
25
- ModalsHost: default_1.DefaultHost,
26
- ModalsDialog: default_1.DefaultDialog,
22
+ ModalsHost: DefaultHost,
23
+ ModalsDialog: DefaultDialog,
27
24
  ...state.components,
28
25
  },
29
26
  registry: {
@@ -36,16 +33,16 @@ function withModals(modals) {
36
33
  /**
37
34
  * Creates new Pilet API extensions for support modal dialogs.
38
35
  */
39
- function createModalsApi(config = {}) {
36
+ export function createModalsApi(config = {}) {
40
37
  const { dialogs = [], selectId = (name) => `${name}-${~~(Math.random() * 10000)}` } = config;
41
38
  return (context) => {
42
39
  context.defineActions(actions);
43
- context.dispatch((0, piral_core_1.withAll)(withModals(getModalDialogs(dialogs)), (0, piral_core_1.withRootExtension)('piral-modals', Modals_1.Modals)));
40
+ context.dispatch(withAll(withModals(getModalDialogs(dialogs)), withRootExtension('piral-modals', Modals)));
44
41
  return (api, target) => {
45
42
  const pilet = target.name;
46
43
  return {
47
44
  showModal(simpleName, options) {
48
- const name = (0, piral_core_1.buildName)(pilet, simpleName);
45
+ const name = buildName(pilet, simpleName);
49
46
  const dialog = {
50
47
  id: selectId(name),
51
48
  name,
@@ -59,23 +56,22 @@ function createModalsApi(config = {}) {
59
56
  return dialog.close;
60
57
  },
61
58
  registerModal(name, arg, defaults, layout = {}) {
62
- const id = (0, piral_core_1.buildName)(pilet, name);
59
+ const id = buildName(pilet, name);
63
60
  context.registerModal(id, {
64
61
  pilet,
65
62
  name,
66
- component: (0, piral_core_1.withApi)(context, arg, api, 'modal'),
63
+ component: withApi(context, arg, api, 'modal'),
67
64
  defaults,
68
65
  layout,
69
66
  });
70
67
  return () => api.unregisterModal(name);
71
68
  },
72
69
  unregisterModal(name) {
73
- const id = (0, piral_core_1.buildName)(pilet, name);
70
+ const id = buildName(pilet, name);
74
71
  context.unregisterModal(id);
75
72
  },
76
73
  };
77
74
  };
78
75
  };
79
76
  }
80
- exports.createModalsApi = createModalsApi;
81
77
  //# sourceMappingURL=create.js.map
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AAErC,2CAA4G;AAC5G,uCAAuD;AACvD,qCAAkC;AAuClC,SAAS,eAAe,CAAC,OAAkC;IACzD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,EAAE,EAAE,IAAI,OAAO,EAAE;QAChE,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,GAAG;YACzB,KAAK,EAAE,SAAS;YAChB,IAAI;YACJ,SAAS;YACT,QAAQ;YACR,MAAM;SACP,CAAC;KACH;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,UAAU,CAAC,MAA+B;IACjD,OAAO,CAAC,KAAkB,EAAe,EAAE,CAAC,CAAC;QAC3C,GAAG,KAAK;QACR,UAAU,EAAE;YACV,UAAU,EAAE,qBAAW;YACvB,YAAY,EAAE,uBAAa;YAC3B,GAAG,KAAK,CAAC,UAAU;SACpB;QACD,QAAQ,EAAE;YACR,GAAG,KAAK,CAAC,QAAQ;YACjB,MAAM;SACP;QACD,MAAM,EAAE,EAAE;KACX,C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CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,EAAE;oBAC5C,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE;wBACxB,KAAK;wBACL,IAAI;wBACJ,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;wBAC9C,QAAQ;wBACR,MAAM;qBACP,CAAC,CAAC;oBACH,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBACzC,CAAC;gBACD,eAAe,CAAC,IAAI;oBAClB,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;gBAC9B,CAAC;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
package/lib/default.js CHANGED
@@ -1,10 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultDialog = exports.DefaultHost = void 0;
4
- const React = require("react");
5
- const piral_core_1 = require("piral-core");
6
- const DefaultHost = (props) => (React.createElement("div", { className: "piral-modals-host" }, props.open && React.createElement("div", { className: "piral-modals-overlay" }, props.children)));
7
- exports.DefaultHost = DefaultHost;
8
- const DefaultDialog = (props) => (0, piral_core_1.defaultRender)(props.children);
9
- exports.DefaultDialog = DefaultDialog;
1
+ import * as React from 'react';
2
+ import { defaultRender } from 'piral-core';
3
+ export const DefaultHost = (props) => (React.createElement("div", { className: "piral-modals-host" }, props.open && React.createElement("div", { className: "piral-modals-overlay" }, props.children)));
4
+ export const DefaultDialog = (props) => defaultRender(props.children);
10
5
  //# sourceMappingURL=default.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAA2C;AAGpC,MAAM,WAAW,GAA8B,CAAC,KAAK,EAAE,EAAE,CAAC,CAC/D,6BAAK,SAAS,EAAC,mBAAmB,IAC/B,KAAK,CAAC,IAAI,IAAI,6BAAK,SAAS,EAAC,sBAAsB,IAAE,KAAK,CAAC,QAAQ,CAAO,CACvE,CACP,CAAC;AAJW,QAAA,WAAW,eAItB;AAEK,MAAM,aAAa,GAAgC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,0BAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAtF,QAAA,aAAa,iBAAyE"}
1
+ {"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,CAAC,MAAM,WAAW,GAA8B,CAAC,KAAK,EAAE,EAAE,CAAC,CAC/D,6BAAK,SAAS,EAAC,mBAAmB,IAC/B,KAAK,CAAC,IAAI,IAAI,6BAAK,SAAS,EAAC,sBAAsB,IAAE,KAAK,CAAC,QAAQ,CAAO,CACvE,CACP,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAgC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC"}
package/lib/index.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./create"), exports);
5
- tslib_1.__exportStar(require("./components"), exports);
6
- tslib_1.__exportStar(require("./Modals"), exports);
7
- tslib_1.__exportStar(require("./types"), exports);
1
+ export * from './create';
2
+ export * from './components';
3
+ export * from './Modals';
4
+ export * from './types';
8
5
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,uDAA6B;AAC7B,mDAAyB;AACzB,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
package/lib/types.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-modals",
3
- "version": "1.6.0-beta.7216",
3
+ "version": "1.6.0-beta.7243",
4
4
  "description": "Plugin for the display of modal dialogs in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -17,29 +17,16 @@
17
17
  "author": "smapiot",
18
18
  "homepage": "https://piral.io",
19
19
  "license": "MIT",
20
- "module": "esm/index.js",
20
+ "module": "lib/index.js",
21
21
  "main": "lib/index.js",
22
22
  "typings": "lib/index.d.ts",
23
23
  "exports": {
24
- ".": {
25
- "import": "./esm/index.js",
26
- "require": "./lib/index.js"
27
- },
28
- "./esm/*": {
29
- "import": "./esm/*"
30
- },
31
- "./lib/*": {
32
- "require": "./lib/*"
33
- },
34
- "./_/*": {
35
- "import": "./esm/*.js",
36
- "require": "./lib/*.js"
37
- },
24
+ ".": "./lib/index.js",
25
+ "./lib/*": "./lib/*",
38
26
  "./package.json": "./package.json"
39
27
  },
40
28
  "sideEffects": false,
41
29
  "files": [
42
- "esm",
43
30
  "lib",
44
31
  "src",
45
32
  "piral-modals.min.js"
@@ -53,17 +40,16 @@
53
40
  },
54
41
  "scripts": {
55
42
  "cleanup": "rimraf esm lib piral-modals.min.js",
56
- "build": "yarn build:bundle && yarn build:commonjs && yarn build:esnext",
43
+ "build": "yarn build:bundle && yarn build:esnext",
57
44
  "build:bundle": "esbuild src/index.ts --outfile=piral-modals.min.js --bundle --external:piral-core --external:react --minify --global-name=piralModals",
58
- "build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
59
- "build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
45
+ "build:esnext": "tsc --project tsconfig.json --outDir lib --module esnext",
60
46
  "typedoc": "typedoc --json ../../../docs/types/piral-modals.json src --exclude \"src/**/*.test.*\"",
61
47
  "test": "echo \"Error: run tests from root\" && exit 1"
62
48
  },
63
49
  "devDependencies": {
64
50
  "@types/react": "^18.0.0",
65
- "piral-core": "1.6.0-beta.7216",
51
+ "piral-core": "1.6.0-beta.7243",
66
52
  "react": "^18.0.0"
67
53
  },
68
- "gitHead": "bd3742af68fc25af93ed9b37021d2d69a6f40f18"
54
+ "gitHead": "bbb6e4f78c61b6ef753099a5b378ad2708565ce3"
69
55
  }
package/esm/Modals.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import * as React from 'react';
2
- export declare const Modals: React.FC;
package/esm/Modals.js DELETED
@@ -1,37 +0,0 @@
1
- import * as React from 'react';
2
- import { useGlobalState } from 'piral-core';
3
- import { PiralModalsDialog, PiralModalsHost } from './components';
4
- function closeAll(modals) {
5
- modals.forEach((m) => m.close());
6
- }
7
- function findModal(modals, name) {
8
- if (name) {
9
- const [modal] = Object.keys(modals)
10
- .filter((m) => modals[m].name === name)
11
- .map((m) => modals[m]);
12
- return modal;
13
- }
14
- return undefined;
15
- }
16
- export const Modals = () => {
17
- const modals = useGlobalState((s) => s.registry.modals);
18
- const dialogs = useGlobalState((s) => s.modals);
19
- const close = () => closeAll(dialogs);
20
- const children = dialogs
21
- .map((n) => {
22
- const reg = modals[n.name] || findModal(modals, n.alternative);
23
- const Component = reg && reg.component;
24
- const defaults = reg && reg.defaults;
25
- const options = {
26
- ...defaults,
27
- ...n.options,
28
- };
29
- return (Component && (React.createElement(PiralModalsDialog, { ...n, options: options, defaults: reg.defaults, layout: reg.layout, key: n.name },
30
- React.createElement(Component, { onClose: n.close, options: options }))));
31
- })
32
- .filter(Boolean);
33
- const open = children.length > 0;
34
- return (React.createElement(PiralModalsHost, { open: open, close: close }, children));
35
- };
36
- Modals.displayName = 'Modals';
37
- //# sourceMappingURL=Modals.js.map
package/esm/Modals.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"Modals.js","sourceRoot":"","sources":["../src/Modals.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGlE,SAAS,QAAQ,CAAC,MAA8B;IAC9C,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,SAAS,CAAC,MAAyC,EAAE,IAAY;IACxE,IAAI,IAAI,EAAE;QACR,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;aAChC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;aACtC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzB,OAAO,KAAK,CAAC;KACd;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAa,GAAG,EAAE;IACnC,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO;SACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;QAC/D,MAAM,SAAS,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC;QACvC,MAAM,QAAQ,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC;QACrC,MAAM,OAAO,GAAG;YACd,GAAG,QAAQ;YACX,GAAG,CAAC,CAAC,OAAO;SACb,CAAC;QACF,OAAO,CACL,SAAS,IAAI,CACX,oBAAC,iBAAiB,OAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI;YACjG,oBAAC,SAAS,IAAC,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAI,CAC/B,CACrB,CACF,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAEjC,OAAO,CACL,oBAAC,eAAe,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,IACtC,QAAQ,CACO,CACnB,CAAC;AACJ,CAAC,CAAC;AACF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
package/esm/actions.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { GlobalStateContext } from 'piral-core';
2
- import { ModalRegistration, OpenModalDialog } from './types';
3
- export declare function openModal(ctx: GlobalStateContext, dialog: OpenModalDialog): void;
4
- export declare function closeModal(ctx: GlobalStateContext, dialog: OpenModalDialog): void;
5
- export declare function registerModal(ctx: GlobalStateContext, name: string, value: ModalRegistration): void;
6
- export declare function unregisterModal(ctx: GlobalStateContext, name: string): void;
package/esm/actions.js DELETED
@@ -1,32 +0,0 @@
1
- import { withKey, withoutKey, prependItem, excludeOn } from 'piral-core';
2
- export function openModal(ctx, dialog) {
3
- ctx.dispatch((state) => ({
4
- ...state,
5
- modals: prependItem(state.modals, dialog),
6
- }));
7
- }
8
- export function closeModal(ctx, dialog) {
9
- ctx.dispatch((state) => ({
10
- ...state,
11
- modals: excludeOn(state.modals, (modal) => modal.id === dialog.id),
12
- }));
13
- }
14
- export function registerModal(ctx, name, value) {
15
- ctx.dispatch((state) => ({
16
- ...state,
17
- registry: {
18
- ...state.registry,
19
- modals: withKey(state.registry.modals, name, value),
20
- },
21
- }));
22
- }
23
- export function unregisterModal(ctx, name) {
24
- ctx.dispatch((state) => ({
25
- ...state,
26
- registry: {
27
- ...state.registry,
28
- modals: withoutKey(state.registry.modals, name),
29
- },
30
- }));
31
- }
32
- //# sourceMappingURL=actions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAC;AAG7F,MAAM,UAAU,SAAS,CAAC,GAAuB,EAAE,MAAuB;IACxE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,GAAG,KAAK;QACR,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC;KAC1C,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAuB,EAAE,MAAuB;IACzE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,GAAG,KAAK;QACR,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC;KACnE,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAuB,EAAE,IAAY,EAAE,KAAwB;IAC3F,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,GAAG,KAAK;QACR,QAAQ,EAAE;YACR,GAAG,KAAK,CAAC,QAAQ;YACjB,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC;SACpD;KACF,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAuB,EAAE,IAAY;IACnE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,GAAG,KAAK;QACR,QAAQ,EAAE;YACR,GAAG,KAAK,CAAC,QAAQ;YACjB,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;SAChD;KACF,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const PiralModalsHost: import("react").ComponentType<import("./types").ModalsHostProps>;
3
- export declare const PiralModalsDialog: import("react").ComponentType<import("./types").ModalsDialogProps>;
package/esm/components.js DELETED
@@ -1,4 +0,0 @@
1
- import { getPiralComponent } from 'piral-core';
2
- export const PiralModalsHost = getPiralComponent('ModalsHost');
3
- export const PiralModalsDialog = getPiralComponent('ModalsDialog');
4
- //# sourceMappingURL=components.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC"}
package/esm/create.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import { ComponentType } from 'react';
2
- import { PiralPlugin } from 'piral-core';
3
- import { PiletModalsApi, BareModalComponentProps, ModalLayoutOptions } from './types';
4
- export interface InitialModalDialog {
5
- /**
6
- * The name of the modal dialog.
7
- */
8
- name: string;
9
- /**
10
- * The component to show representing the modal dialog.
11
- */
12
- component: ComponentType<BareModalComponentProps<any>>;
13
- /**
14
- * The default options for the modal dialog.
15
- */
16
- defaults?: any;
17
- /**
18
- * The layout options for the modal dialog.
19
- */
20
- layout?: ModalLayoutOptions;
21
- }
22
- /**
23
- * Available configuration options for the modals plugin.
24
- */
25
- export interface ModalsConfig {
26
- /**
27
- * The initial modal dialogs.
28
- */
29
- dialogs?: Array<InitialModalDialog>;
30
- /**
31
- * Defines how the next ID for the key is selected.
32
- * By default a random number is used.
33
- *
34
- * @param name The name of the modal dialog.
35
- */
36
- selectId?(name: string): string;
37
- }
38
- /**
39
- * Creates new Pilet API extensions for support modal dialogs.
40
- */
41
- export declare function createModalsApi(config?: ModalsConfig): PiralPlugin<PiletModalsApi>;
package/esm/create.js DELETED
@@ -1,77 +0,0 @@
1
- import * as actions from './actions';
2
- import { withApi, buildName, withRootExtension, withAll } from 'piral-core';
3
- import { DefaultHost, DefaultDialog } from './default';
4
- import { Modals } from './Modals';
5
- function getModalDialogs(dialogs) {
6
- const modals = {};
7
- for (const { name, component, defaults, layout = {} } of dialogs) {
8
- modals[`global-${name}`] = {
9
- pilet: undefined,
10
- name,
11
- component,
12
- defaults,
13
- layout,
14
- };
15
- }
16
- return modals;
17
- }
18
- function withModals(modals) {
19
- return (state) => ({
20
- ...state,
21
- components: {
22
- ModalsHost: DefaultHost,
23
- ModalsDialog: DefaultDialog,
24
- ...state.components,
25
- },
26
- registry: {
27
- ...state.registry,
28
- modals,
29
- },
30
- modals: [],
31
- });
32
- }
33
- /**
34
- * Creates new Pilet API extensions for support modal dialogs.
35
- */
36
- export function createModalsApi(config = {}) {
37
- const { dialogs = [], selectId = (name) => `${name}-${~~(Math.random() * 10000)}` } = config;
38
- return (context) => {
39
- context.defineActions(actions);
40
- context.dispatch(withAll(withModals(getModalDialogs(dialogs)), withRootExtension('piral-modals', Modals)));
41
- return (api, target) => {
42
- const pilet = target.name;
43
- return {
44
- showModal(simpleName, options) {
45
- const name = buildName(pilet, simpleName);
46
- const dialog = {
47
- id: selectId(name),
48
- name,
49
- alternative: simpleName,
50
- options,
51
- close() {
52
- context.closeModal(dialog);
53
- },
54
- };
55
- context.openModal(dialog);
56
- return dialog.close;
57
- },
58
- registerModal(name, arg, defaults, layout = {}) {
59
- const id = buildName(pilet, name);
60
- context.registerModal(id, {
61
- pilet,
62
- name,
63
- component: withApi(context, arg, api, 'modal'),
64
- defaults,
65
- layout,
66
- });
67
- return () => api.unregisterModal(name);
68
- },
69
- unregisterModal(name) {
70
- const id = buildName(pilet, name);
71
- context.unregisterModal(id);
72
- },
73
- };
74
- };
75
- };
76
- }
77
- //# sourceMappingURL=create.js.map
package/esm/create.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAqB,iBAAiB,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AAC5G,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAuClC,SAAS,eAAe,CAAC,OAAkC;IACzD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,EAAE,EAAE,IAAI,OAAO,EAAE;QAChE,MAAM,CAA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AAC;wBAClB,IAAI;wBACJ,WAAW,EAAE,UAAU;wBACvB,OAAO;wBACP,KAAK;4BACH,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;wBAC7B,CAAC;qBACF,CAAC;oBACF,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;oBAC1B,OAAO,MAAM,CAAC,KAAK,CAAC;gBACtB,CAAC;gBACD,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,EAAE;oBAC5C,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE;wBACxB,KAAK;wBACL,IAAI;wBACJ,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;wBAC9C,QAAQ;wBACR,MAAM;qBACP,CAAC,CAAC;oBACH,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBACzC,CAAC;gBACD,eAAe,CAAC,IAAI;oBAClB,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;gBAC9B,CAAC;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
package/esm/default.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { ModalsHostProps, ModalsDialogProps } from './types';
3
- export declare const DefaultHost: React.FC<ModalsHostProps>;
4
- export declare const DefaultDialog: React.FC<ModalsDialogProps>;
package/esm/default.js DELETED
@@ -1,5 +0,0 @@
1
- import * as React from 'react';
2
- import { defaultRender } from 'piral-core';
3
- export const DefaultHost = (props) => (React.createElement("div", { className: "piral-modals-host" }, props.open && React.createElement("div", { className: "piral-modals-overlay" }, props.children)));
4
- export const DefaultDialog = (props) => defaultRender(props.children);
5
- //# sourceMappingURL=default.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,CAAC,MAAM,WAAW,GAA8B,CAAC,KAAK,EAAE,EAAE,CAAC,CAC/D,6BAAK,SAAS,EAAC,mBAAmB,IAC/B,KAAK,CAAC,IAAI,IAAI,6BAAK,SAAS,EAAC,sBAAsB,IAAE,KAAK,CAAC,QAAQ,CAAO,CACvE,CACP,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAgC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC"}
package/esm/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './create';
2
- export * from './components';
3
- export * from './Modals';
4
- export * from './types';
package/esm/index.js DELETED
@@ -1,5 +0,0 @@
1
- export * from './create';
2
- export * from './components';
3
- export * from './Modals';
4
- export * from './types';
5
- //# sourceMappingURL=index.js.map
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
package/esm/types.d.ts DELETED
@@ -1,178 +0,0 @@
1
- import type { ComponentType, ReactNode } from 'react';
2
- import type { Dict, WrappedComponent, BaseComponentProps, BaseRegistration, Disposable, AnyComponent, RegistrationDisposer } from 'piral-core';
3
- declare module 'piral-core/lib/types/custom' {
4
- interface PiletCustomApi extends PiletModalsApi {
5
- }
6
- interface PiralCustomState {
7
- /**
8
- * The currently open modal dialogs.
9
- */
10
- modals: Array<OpenModalDialog>;
11
- }
12
- interface PiralCustomActions {
13
- /**
14
- * Opens the provided dialog.
15
- * @param dialog The dialog to show.
16
- */
17
- openModal(dialog: OpenModalDialog): void;
18
- /**
19
- * Closes the provided dialog.
20
- * @param dialog The dialog to hide.
21
- */
22
- closeModal(dialog: OpenModalDialog): void;
23
- /**
24
- * Registers a new modal dialog.
25
- * @param name The name of the modal.
26
- * @param value The modal registration.
27
- */
28
- registerModal(name: string, value: ModalRegistration): void;
29
- /**
30
- * Unregisters an existing modal dialog.
31
- * @param name The name of the modal to be removed.
32
- */
33
- unregisterModal(name: string): void;
34
- }
35
- interface PiralCustomRegistryState {
36
- /**
37
- * The registered modal dialog components.
38
- */
39
- modals: Dict<ModalRegistration>;
40
- }
41
- interface PiralCustomErrors {
42
- modal: ModalErrorInfoProps;
43
- }
44
- interface PiralCustomComponentsState {
45
- /**
46
- * The host component for modal dialogs.
47
- */
48
- ModalsHost: ComponentType<ModalsHostProps>;
49
- /**
50
- * The modal dialog component.
51
- */
52
- ModalsDialog: ComponentType<ModalsDialogProps>;
53
- }
54
- }
55
- export interface ModalsHostProps {
56
- /**
57
- * Gets if the modal is currently open or closed.
58
- */
59
- open: boolean;
60
- /**
61
- * Callback to invoke closing the modal dialog.
62
- */
63
- close(): void;
64
- /**
65
- * The dialogs to display.
66
- */
67
- children?: ReactNode;
68
- }
69
- export interface ModalsDialogProps extends OpenModalDialog {
70
- /**
71
- * The layout options given for the current dialog.
72
- */
73
- layout: ModalLayoutOptions;
74
- /**
75
- * The provided default options.
76
- */
77
- defaults: any;
78
- /**
79
- * The content of the dialog to display.
80
- */
81
- children?: ReactNode;
82
- }
83
- /**
84
- * The options provided for the dialog layout.
85
- */
86
- export interface ModalLayoutOptions {
87
- }
88
- /**
89
- * The error used when a registered modal dialog crashed.
90
- */
91
- export interface ModalErrorInfoProps {
92
- /**
93
- * The type of the error.
94
- */
95
- type: 'modal';
96
- /**
97
- * The provided error details.
98
- */
99
- error: any;
100
- /**
101
- * Callback for closing the modal programmatically.
102
- */
103
- onClose(): void;
104
- /**
105
- * The name of the pilet emitting the error.
106
- */
107
- pilet?: string;
108
- }
109
- export interface OpenModalDialog {
110
- /**
111
- * Gets the ID of the modal to open. For tracking its state.
112
- */
113
- id: string;
114
- /**
115
- * Specifies the fully qualified name of the dialog to show.
116
- */
117
- name: string;
118
- /**
119
- * Specifies the alternative (original) name of the dialog to show.
120
- */
121
- alternative?: string;
122
- /**
123
- * Defines the transported options.
124
- */
125
- options: BaseModalOptions;
126
- /**
127
- * Closes the modal dialog.
128
- */
129
- close(): void;
130
- }
131
- export interface BareModalComponentProps<TOpts> {
132
- /**
133
- * Callback for closing the modal programmatically.
134
- */
135
- onClose(): void;
136
- /**
137
- * Provides the passed in options for this particular modal.
138
- */
139
- options?: TOpts;
140
- }
141
- export interface ModalRegistration extends BaseRegistration {
142
- name: string;
143
- component: WrappedComponent<ModalComponentProps<any>>;
144
- defaults: any;
145
- layout: ModalLayoutOptions;
146
- }
147
- export interface BaseModalOptions {
148
- }
149
- export interface PiralCustomModalsMap {
150
- }
151
- export interface PiralModalsMap extends PiralCustomModalsMap {
152
- }
153
- export type ModalOptions<T> = T extends keyof PiralModalsMap ? PiralModalsMap[T] & BaseModalOptions : T extends string ? BaseModalOptions : T;
154
- export type ModalComponentProps<T> = BaseComponentProps & BareModalComponentProps<ModalOptions<T>>;
155
- export interface PiletModalsApi {
156
- /**
157
- * Shows a modal dialog with the given name.
158
- * The modal can be optionally programmatically closed using the returned callback.
159
- * @param name The name of the registered modal.
160
- * @param options Optional arguments for creating the modal.
161
- * @returns A callback to trigger closing the modal.
162
- */
163
- showModal<T>(name: T extends string ? T : string, options?: ModalOptions<T>): Disposable;
164
- /**
165
- * Registers a modal dialog using a React component.
166
- * The name needs to be unique to be used without the pilet's name.
167
- * @param name The name of the modal to register.
168
- * @param Component The component to render the page.
169
- * @param defaults Optionally, sets the default values for the inserted options.
170
- * @param layout Optionally, sets the layout options for the dialog wrapper.
171
- */
172
- registerModal<T>(name: T extends string ? T : string, Component: AnyComponent<ModalComponentProps<T>>, defaults?: ModalOptions<T>, layout?: ModalLayoutOptions): RegistrationDisposer;
173
- /**
174
- * Unregisters a modal by its name.
175
- * @param name The name that was previously registered.
176
- */
177
- unregisterModal<T>(name: T extends string ? T : string): void;
178
- }
package/esm/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/esm/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}