piral-modals 1.0.0-pre.2296 → 1.0.0
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/LICENSE +1 -1
- package/README.md +8 -2
- package/esm/Modals.js +18 -18
- package/esm/Modals.js.map +1 -1
- package/esm/actions.js +5 -6
- package/esm/actions.js.map +1 -1
- package/esm/components.d.ts +3 -4
- package/esm/components.js +2 -2
- package/esm/components.js.map +1 -1
- package/esm/create.d.ts +13 -2
- package/esm/create.js +36 -31
- package/esm/create.js.map +1 -1
- package/esm/default.js +2 -2
- package/esm/default.js.map +1 -1
- package/esm/types.d.ts +36 -5
- package/lib/Modals.js +22 -21
- package/lib/Modals.js.map +1 -1
- package/lib/actions.js +5 -6
- package/lib/actions.js.map +1 -1
- package/lib/components.d.ts +3 -4
- package/lib/components.js +3 -3
- package/lib/components.js.map +1 -1
- package/lib/create.d.ts +13 -2
- package/lib/create.js +39 -34
- package/lib/create.js.map +1 -1
- package/lib/default.js +6 -4
- package/lib/default.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/types.d.ts +36 -5
- package/package.json +29 -6
- package/piral-modals.min.js +1 -0
- package/src/Modals.test.tsx +151 -85
- package/src/Modals.tsx +7 -9
- package/src/actions.test.ts +19 -18
- package/src/actions.ts +2 -2
- package/src/components.tsx +2 -4
- package/src/create.test.ts +7 -3
- package/src/create.ts +43 -23
- package/src/default.tsx +1 -1
- package/src/types.ts +36 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[](https://piral.io)
|
|
2
2
|
|
|
3
|
-
# [Piral Modals](https://piral.io) · [](https://github.com/smapiot/piral/blob/
|
|
3
|
+
# [Piral Modals](https://piral.io) · [](https://github.com/smapiot/piral/blob/main/LICENSE) [](https://www.npmjs.com/package/piral-modals) [](https://jestjs.io) [](https://gitter.im/piral-io/community)
|
|
4
4
|
|
|
5
5
|
This is a plugin that only has a peer dependency to `piral-core`. What `piral-modals` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core` to easily trigger the display of modal dialogs from pilets.
|
|
6
6
|
|
|
@@ -10,6 +10,12 @@ If you have modal dialogs on your page that `piral-modals` gives you a nice abst
|
|
|
10
10
|
|
|
11
11
|
Alternative: You could simply use an event to trigger opening a dialog. The event could transport a React component which would then be globally used. Alternatively, each pilet would come up with its own dialog design and management system.
|
|
12
12
|
|
|
13
|
+
## Video
|
|
14
|
+
|
|
15
|
+
We also have a video for this plugin:
|
|
16
|
+
|
|
17
|
+
@[youtube](https://youtu.be/gZt7Ic1BHNA)
|
|
18
|
+
|
|
13
19
|
## Documentation
|
|
14
20
|
|
|
15
21
|
The following functions are brought to the Pilet API.
|
package/esm/Modals.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { useGlobalState } from 'piral-core';
|
|
4
3
|
import { PiralModalsDialog, PiralModalsHost } from './components';
|
|
5
4
|
function closeAll(modals) {
|
|
6
|
-
modals.forEach(
|
|
5
|
+
modals.forEach((m) => m.close());
|
|
7
6
|
}
|
|
8
7
|
function findModal(modals, name) {
|
|
9
8
|
if (name) {
|
|
10
|
-
|
|
11
|
-
.filter(
|
|
12
|
-
.map(
|
|
9
|
+
const [modal] = Object.keys(modals)
|
|
10
|
+
.filter((m) => modals[m].name === name)
|
|
11
|
+
.map((m) => modals[m]);
|
|
13
12
|
return modal;
|
|
14
13
|
}
|
|
15
14
|
return undefined;
|
|
16
15
|
}
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.map(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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 = Object.assign(Object.assign({}, defaults), n.options);
|
|
26
|
+
return (Component && (React.createElement(PiralModalsDialog, Object.assign({}, n, { options: options, defaults: reg.defaults, layout: reg.layout, key: n.name }),
|
|
27
|
+
React.createElement(Component, { onClose: n.close, options: options }))));
|
|
28
28
|
})
|
|
29
|
-
.filter(
|
|
30
|
-
|
|
29
|
+
.filter(Boolean);
|
|
30
|
+
const open = children.length > 0;
|
|
31
31
|
return (React.createElement(PiralModalsHost, { open: open, close: close }, children));
|
|
32
32
|
};
|
|
33
33
|
Modals.displayName = 'Modals';
|
package/esm/Modals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modals.js","sourceRoot":"","sources":["../src/Modals.tsx"],"names":[],"mappings":"
|
|
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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C;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.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { withKey, withoutKey, prependItem, excludeItem } from 'piral-core';
|
|
1
|
+
import { withKey, withoutKey, prependItem, excludeOn } from 'piral-core';
|
|
3
2
|
export function openModal(ctx, dialog) {
|
|
4
|
-
ctx.dispatch(
|
|
3
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modals: prependItem(state.modals, dialog) })));
|
|
5
4
|
}
|
|
6
5
|
export function closeModal(ctx, dialog) {
|
|
7
|
-
ctx.dispatch(
|
|
6
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modals: excludeOn(state.modals, (modal) => modal.id === dialog.id) })));
|
|
8
7
|
}
|
|
9
8
|
export function registerModal(ctx, name, value) {
|
|
10
|
-
ctx.dispatch(
|
|
9
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { modals: withKey(state.registry.modals, name, value) }) })));
|
|
11
10
|
}
|
|
12
11
|
export function unregisterModal(ctx, name) {
|
|
13
|
-
ctx.dispatch(
|
|
12
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { modals: withoutKey(state.registry.modals, name) }) })));
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=actions.js.map
|
package/esm/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.js","sour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1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const PiralModalsDialog: React.ComponentType<ModalsDialogProps>;
|
|
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { getPiralComponent } from 'piral-core';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export const PiralModalsHost = getPiralComponent('ModalsHost');
|
|
3
|
+
export const PiralModalsDialog = getPiralComponent('ModalsDialog');
|
|
4
4
|
//# sourceMappingURL=components.js.map
|
package/esm/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"
|
|
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { PiralPlugin } from 'piral-core';
|
|
3
|
-
import { PiletModalsApi, BareModalComponentProps } from './types';
|
|
3
|
+
import { PiletModalsApi, BareModalComponentProps, ModalLayoutOptions } from './types';
|
|
4
4
|
export interface InitialModalDialog {
|
|
5
5
|
/**
|
|
6
6
|
* The name of the modal dialog.
|
|
@@ -13,7 +13,11 @@ export interface InitialModalDialog {
|
|
|
13
13
|
/**
|
|
14
14
|
* The default options for the modal dialog.
|
|
15
15
|
*/
|
|
16
|
-
defaults
|
|
16
|
+
defaults?: any;
|
|
17
|
+
/**
|
|
18
|
+
* The layout options for the modal dialog.
|
|
19
|
+
*/
|
|
20
|
+
layout?: ModalLayoutOptions;
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* Available configuration options for the modals plugin.
|
|
@@ -23,6 +27,13 @@ export interface ModalsConfig {
|
|
|
23
27
|
* The initial modal dialogs.
|
|
24
28
|
*/
|
|
25
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;
|
|
26
37
|
}
|
|
27
38
|
/**
|
|
28
39
|
* Creates new Pilet API extensions for support modal dialogs.
|
package/esm/create.js
CHANGED
|
@@ -1,56 +1,61 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import * as actions from './actions';
|
|
3
|
-
import { withApi, buildName } from 'piral-core';
|
|
2
|
+
import { withApi, buildName, withRootExtension, withAll } from 'piral-core';
|
|
4
3
|
import { DefaultHost, DefaultDialog } from './default';
|
|
4
|
+
import { Modals } from './Modals';
|
|
5
5
|
function getModalDialogs(dialogs) {
|
|
6
|
-
|
|
7
|
-
for (
|
|
8
|
-
|
|
9
|
-
modals["global-" + name_1] = {
|
|
6
|
+
const modals = {};
|
|
7
|
+
for (const { name, component, defaults, layout = {} } of dialogs) {
|
|
8
|
+
modals[`global-${name}`] = {
|
|
10
9
|
pilet: undefined,
|
|
11
|
-
name
|
|
12
|
-
component
|
|
13
|
-
defaults
|
|
10
|
+
name,
|
|
11
|
+
component,
|
|
12
|
+
defaults,
|
|
13
|
+
layout,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
return modals;
|
|
17
17
|
}
|
|
18
|
+
function withModals(modals) {
|
|
19
|
+
return (state) => (Object.assign(Object.assign({}, state), { components: Object.assign({ ModalsHost: DefaultHost, ModalsDialog: DefaultDialog }, state.components), registry: Object.assign(Object.assign({}, state.registry), { modals }), modals: [] }));
|
|
20
|
+
}
|
|
18
21
|
/**
|
|
19
22
|
* Creates new Pilet API extensions for support modal dialogs.
|
|
20
23
|
*/
|
|
21
|
-
export function createModalsApi(config) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return function (context) {
|
|
24
|
+
export function createModalsApi(config = {}) {
|
|
25
|
+
const { dialogs = [], selectId = (name) => `${name}-${~~(Math.random() * 10000)}` } = config;
|
|
26
|
+
return (context) => {
|
|
25
27
|
context.defineActions(actions);
|
|
26
|
-
context.dispatch(
|
|
27
|
-
return
|
|
28
|
-
|
|
28
|
+
context.dispatch(withAll(withModals(getModalDialogs(dialogs)), withRootExtension('piral-modals', Modals)));
|
|
29
|
+
return (api, target) => {
|
|
30
|
+
const pilet = target.name;
|
|
29
31
|
return {
|
|
30
|
-
showModal
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
showModal(simpleName, options) {
|
|
33
|
+
const name = buildName(pilet, simpleName);
|
|
34
|
+
const dialog = {
|
|
35
|
+
id: selectId(name),
|
|
36
|
+
name,
|
|
37
|
+
alternative: simpleName,
|
|
38
|
+
options,
|
|
39
|
+
close() {
|
|
40
|
+
context.closeModal(dialog);
|
|
37
41
|
},
|
|
38
42
|
};
|
|
39
43
|
context.openModal(dialog);
|
|
40
44
|
return dialog.close;
|
|
41
45
|
},
|
|
42
|
-
registerModal
|
|
43
|
-
|
|
46
|
+
registerModal(name, arg, defaults, layout = {}) {
|
|
47
|
+
const id = buildName(pilet, name);
|
|
44
48
|
context.registerModal(id, {
|
|
45
|
-
pilet
|
|
46
|
-
name
|
|
49
|
+
pilet,
|
|
50
|
+
name,
|
|
47
51
|
component: withApi(context, arg, api, 'modal'),
|
|
48
|
-
defaults
|
|
52
|
+
defaults,
|
|
53
|
+
layout,
|
|
49
54
|
});
|
|
50
|
-
return
|
|
55
|
+
return () => api.unregisterModal(name);
|
|
51
56
|
},
|
|
52
|
-
unregisterModal
|
|
53
|
-
|
|
57
|
+
unregisterModal(name) {
|
|
58
|
+
const id = buildName(pilet, name);
|
|
54
59
|
context.unregisterModal(id);
|
|
55
60
|
},
|
|
56
61
|
};
|
package/esm/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"
|
|
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,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,iCACvC,KAAK,KACR,UAAU,kBACR,UAAU,EAAE,WAAW,EACvB,YAAY,EAAE,aAAa,IACxB,KAAK,CAAC,UAAU,GAErB,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,MAAM,KAER,MAAM,EAAE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;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.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { defaultRender } from 'piral-core';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
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
5
|
//# sourceMappingURL=default.js.map
|
package/esm/default.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import { Dict, WrappedComponent, BaseComponentProps, BaseRegistration, Disposable, AnyComponent, RegistrationDisposer } from 'piral-core';
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type { Dict, WrappedComponent, BaseComponentProps, BaseRegistration, Disposable, AnyComponent, RegistrationDisposer } from 'piral-core';
|
|
3
3
|
declare module 'piral-core/lib/types/custom' {
|
|
4
4
|
interface PiletCustomApi extends PiletModalsApi {
|
|
5
5
|
}
|
|
@@ -61,8 +61,29 @@ export interface ModalsHostProps {
|
|
|
61
61
|
* Callback to invoke closing the modal dialog.
|
|
62
62
|
*/
|
|
63
63
|
close(): void;
|
|
64
|
+
/**
|
|
65
|
+
* The dialogs to display.
|
|
66
|
+
*/
|
|
67
|
+
children?: ReactNode;
|
|
64
68
|
}
|
|
65
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 {
|
|
66
87
|
}
|
|
67
88
|
/**
|
|
68
89
|
* The error used when a registered modal dialog crashed.
|
|
@@ -80,8 +101,16 @@ export interface ModalErrorInfoProps {
|
|
|
80
101
|
* Callback for closing the modal programmatically.
|
|
81
102
|
*/
|
|
82
103
|
onClose(): void;
|
|
104
|
+
/**
|
|
105
|
+
* The name of the pilet emitting the error.
|
|
106
|
+
*/
|
|
107
|
+
pilet?: string;
|
|
83
108
|
}
|
|
84
109
|
export interface OpenModalDialog {
|
|
110
|
+
/**
|
|
111
|
+
* Gets the ID of the modal to open. For tracking its state.
|
|
112
|
+
*/
|
|
113
|
+
id: string;
|
|
85
114
|
/**
|
|
86
115
|
* Specifies the fully qualified name of the dialog to show.
|
|
87
116
|
*/
|
|
@@ -113,6 +142,7 @@ export interface ModalRegistration extends BaseRegistration {
|
|
|
113
142
|
name: string;
|
|
114
143
|
component: WrappedComponent<ModalComponentProps<any>>;
|
|
115
144
|
defaults: any;
|
|
145
|
+
layout: ModalLayoutOptions;
|
|
116
146
|
}
|
|
117
147
|
export interface BaseModalOptions {
|
|
118
148
|
}
|
|
@@ -120,8 +150,8 @@ export interface PiralCustomModalsMap {
|
|
|
120
150
|
}
|
|
121
151
|
export interface PiralModalsMap extends PiralCustomModalsMap {
|
|
122
152
|
}
|
|
123
|
-
export
|
|
124
|
-
export
|
|
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>>;
|
|
125
155
|
export interface PiletModalsApi {
|
|
126
156
|
/**
|
|
127
157
|
* Shows a modal dialog with the given name.
|
|
@@ -137,8 +167,9 @@ export interface PiletModalsApi {
|
|
|
137
167
|
* @param name The name of the modal to register.
|
|
138
168
|
* @param Component The component to render the page.
|
|
139
169
|
* @param defaults Optionally, sets the default values for the inserted options.
|
|
170
|
+
* @param layout Optionally, sets the layout options for the dialog wrapper.
|
|
140
171
|
*/
|
|
141
|
-
registerModal<T>(name: T extends string ? T : string, Component: AnyComponent<ModalComponentProps<T>>, defaults?: ModalOptions<T
|
|
172
|
+
registerModal<T>(name: T extends string ? T : string, Component: AnyComponent<ModalComponentProps<T>>, defaults?: ModalOptions<T>, layout?: ModalLayoutOptions): RegistrationDisposer;
|
|
142
173
|
/**
|
|
143
174
|
* Unregisters a modal by its name.
|
|
144
175
|
* @param name The name that was previously registered.
|
package/lib/Modals.js
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Modals = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var components_1 = require("./components");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const piral_core_1 = require("piral-core");
|
|
6
|
+
const components_1 = require("./components");
|
|
8
7
|
function closeAll(modals) {
|
|
9
|
-
modals.forEach(
|
|
8
|
+
modals.forEach((m) => m.close());
|
|
10
9
|
}
|
|
11
10
|
function findModal(modals, name) {
|
|
12
11
|
if (name) {
|
|
13
|
-
|
|
14
|
-
.filter(
|
|
15
|
-
.map(
|
|
12
|
+
const [modal] = Object.keys(modals)
|
|
13
|
+
.filter((m) => modals[m].name === name)
|
|
14
|
+
.map((m) => modals[m]);
|
|
16
15
|
return modal;
|
|
17
16
|
}
|
|
18
17
|
return undefined;
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.map(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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);
|
|
22
|
+
const close = () => closeAll(dialogs);
|
|
23
|
+
const children = dialogs
|
|
24
|
+
.map((n) => {
|
|
25
|
+
const reg = modals[n.name] || findModal(modals, n.alternative);
|
|
26
|
+
const Component = reg && reg.component;
|
|
27
|
+
const defaults = reg && reg.defaults;
|
|
28
|
+
const options = Object.assign(Object.assign({}, defaults), n.options);
|
|
29
|
+
return (Component && (React.createElement(components_1.PiralModalsDialog, Object.assign({}, n, { options: options, defaults: reg.defaults, layout: reg.layout, key: n.name }),
|
|
30
|
+
React.createElement(Component, { onClose: n.close, options: options }))));
|
|
31
31
|
})
|
|
32
|
-
.filter(
|
|
33
|
-
|
|
32
|
+
.filter(Boolean);
|
|
33
|
+
const open = children.length > 0;
|
|
34
34
|
return (React.createElement(components_1.PiralModalsHost, { open: open, close: close }, children));
|
|
35
35
|
};
|
|
36
|
+
exports.Modals = Modals;
|
|
36
37
|
exports.Modals.displayName = 'Modals';
|
|
37
38
|
//# sourceMappingURL=Modals.js.map
|
package/lib/Modals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modals.js","sourceRoot":"","sources":["../src/Modals.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Modals.js","sourceRoot":"","sources":["../src/Modals.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAA4C;AAC5C,6CAAkE;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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I,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,IACtC,QAAQ,CACO,CACnB,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,MAAM,UA6BjB;AACF,cAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
package/lib/actions.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unregisterModal = exports.registerModal = exports.closeModal = exports.openModal = void 0;
|
|
4
|
-
|
|
5
|
-
var piral_core_1 = require("piral-core");
|
|
4
|
+
const piral_core_1 = require("piral-core");
|
|
6
5
|
function openModal(ctx, dialog) {
|
|
7
|
-
ctx.dispatch(
|
|
6
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modals: (0, piral_core_1.prependItem)(state.modals, dialog) })));
|
|
8
7
|
}
|
|
9
8
|
exports.openModal = openModal;
|
|
10
9
|
function closeModal(ctx, dialog) {
|
|
11
|
-
ctx.dispatch(
|
|
10
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modals: (0, piral_core_1.excludeOn)(state.modals, (modal) => modal.id === dialog.id) })));
|
|
12
11
|
}
|
|
13
12
|
exports.closeModal = closeModal;
|
|
14
13
|
function registerModal(ctx, name, value) {
|
|
15
|
-
ctx.dispatch(
|
|
14
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { modals: (0, piral_core_1.withKey)(state.registry.modals, name, value) }) })));
|
|
16
15
|
}
|
|
17
16
|
exports.registerModal = registerModal;
|
|
18
17
|
function unregisterModal(ctx, name) {
|
|
19
|
-
ctx.dispatch(
|
|
18
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { modals: (0, piral_core_1.withoutKey)(state.registry.modals, name) }) })));
|
|
20
19
|
}
|
|
21
20
|
exports.unregisterModal = unregisterModal;
|
|
22
21
|
//# sourceMappingURL=actions.js.map
|
package/lib/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"
|
|
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,iCACnB,KAAK,KACR,MAAM,EAAE,IAAA,wBAAW,EAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,IACzC,CAAC,CAAC;AACN,CAAC;AALD,8BAKC;AAED,SAAgB,UAAU,CAAC,GAAuB,EAAE,MAAuB;IACzE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,MAAM,EAAE,IAAA,sBAAS,EAAC,KAAK,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,IAClE,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,iCACnB,KAAK,KACR,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,MAAM,EAAE,IAAA,oBAAO,EAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,OAErD,CAAC,CAAC;AACN,CAAC;AARD,sCAQC;AAED,SAAgB,eAAe,CAAC,GAAuB,EAAE,IAAY;IACnE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,MAAM,EAAE,IAAA,uBAAU,EAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,OAEjD,CAAC,CAAC;AACN,CAAC;AARD,0CAQC"}
|
package/lib/components.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const PiralModalsDialog: React.ComponentType<ModalsDialogProps>;
|
|
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/lib/components.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PiralModalsDialog = exports.PiralModalsHost = void 0;
|
|
4
|
-
|
|
5
|
-
exports.PiralModalsHost = piral_core_1.getPiralComponent('ModalsHost');
|
|
6
|
-
exports.PiralModalsDialog = piral_core_1.getPiralComponent('ModalsDialog');
|
|
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');
|
|
7
7
|
//# sourceMappingURL=components.js.map
|
package/lib/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":";;;
|
|
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"}
|
package/lib/create.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { PiralPlugin } from 'piral-core';
|
|
3
|
-
import { PiletModalsApi, BareModalComponentProps } from './types';
|
|
3
|
+
import { PiletModalsApi, BareModalComponentProps, ModalLayoutOptions } from './types';
|
|
4
4
|
export interface InitialModalDialog {
|
|
5
5
|
/**
|
|
6
6
|
* The name of the modal dialog.
|
|
@@ -13,7 +13,11 @@ export interface InitialModalDialog {
|
|
|
13
13
|
/**
|
|
14
14
|
* The default options for the modal dialog.
|
|
15
15
|
*/
|
|
16
|
-
defaults
|
|
16
|
+
defaults?: any;
|
|
17
|
+
/**
|
|
18
|
+
* The layout options for the modal dialog.
|
|
19
|
+
*/
|
|
20
|
+
layout?: ModalLayoutOptions;
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* Available configuration options for the modals plugin.
|
|
@@ -23,6 +27,13 @@ export interface ModalsConfig {
|
|
|
23
27
|
* The initial modal dialogs.
|
|
24
28
|
*/
|
|
25
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;
|
|
26
37
|
}
|
|
27
38
|
/**
|
|
28
39
|
* Creates new Pilet API extensions for support modal dialogs.
|