piral-modals 0.14.20 → 0.14.21
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/esm/Modals.js +4 -3
- package/esm/Modals.js.map +1 -1
- package/esm/create.d.ts +6 -2
- package/esm/create.js +4 -2
- package/esm/create.js.map +1 -1
- package/esm/types.d.ts +12 -3
- package/lib/Modals.js +4 -3
- package/lib/Modals.js.map +1 -1
- package/lib/create.d.ts +6 -2
- package/lib/create.js +4 -2
- package/lib/create.js.map +1 -1
- package/lib/types.d.ts +12 -3
- package/package.json +3 -3
- package/src/Modals.tsx +7 -9
- package/src/create.ts +10 -4
- package/src/types.ts +14 -3
package/esm/Modals.js
CHANGED
|
@@ -22,10 +22,11 @@ export const Modals = () => {
|
|
|
22
22
|
const reg = modals[n.name] || findModal(modals, n.alternative);
|
|
23
23
|
const Component = reg && reg.component;
|
|
24
24
|
const defaults = reg && reg.defaults;
|
|
25
|
-
|
|
26
|
-
|
|
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 }))));
|
|
27
28
|
})
|
|
28
|
-
.filter(
|
|
29
|
+
.filter(Boolean);
|
|
29
30
|
const open = children.length > 0;
|
|
30
31
|
return (React.createElement(PiralModalsHost, { open: open, close: close }, children));
|
|
31
32
|
};
|
package/esm/Modals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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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AAC,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,mCACR,QAAQ,GACR,CAAC,CAAC,OAAO,CACb,CAAC;QACF,OAAO,CACL,SAAS,IAAI,CACX,oBAAC,iBAAiB,oBAAK,CAAC,IAAE,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/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.
|
package/esm/create.js
CHANGED
|
@@ -4,12 +4,13 @@ import { DefaultHost, DefaultDialog } from './default';
|
|
|
4
4
|
import { Modals } from './Modals';
|
|
5
5
|
function getModalDialogs(dialogs) {
|
|
6
6
|
const modals = {};
|
|
7
|
-
for (const { name, component, defaults } of dialogs) {
|
|
7
|
+
for (const { name, component, defaults, layout = {} } of dialogs) {
|
|
8
8
|
modals[`global-${name}`] = {
|
|
9
9
|
pilet: undefined,
|
|
10
10
|
name,
|
|
11
11
|
component,
|
|
12
12
|
defaults,
|
|
13
|
+
layout,
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
return modals;
|
|
@@ -42,13 +43,14 @@ export function createModalsApi(config = {}) {
|
|
|
42
43
|
context.openModal(dialog);
|
|
43
44
|
return dialog.close;
|
|
44
45
|
},
|
|
45
|
-
registerModal(name, arg, defaults) {
|
|
46
|
+
registerModal(name, arg, defaults, layout = {}) {
|
|
46
47
|
const id = buildName(pilet, name);
|
|
47
48
|
context.registerModal(id, {
|
|
48
49
|
pilet,
|
|
49
50
|
name,
|
|
50
51
|
component: withApi(context, arg, api, 'modal'),
|
|
51
52
|
defaults,
|
|
53
|
+
layout,
|
|
52
54
|
});
|
|
53
55
|
return () => api.unregisterModal(name);
|
|
54
56
|
},
|
package/esm/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,E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AC,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/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 } 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
|
}
|
|
@@ -63,6 +63,13 @@ export interface ModalsHostProps {
|
|
|
63
63
|
close(): void;
|
|
64
64
|
}
|
|
65
65
|
export interface ModalsDialogProps extends OpenModalDialog {
|
|
66
|
+
layout: ModalLayoutOptions;
|
|
67
|
+
defaults: any;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The options provided for the dialog layout.
|
|
71
|
+
*/
|
|
72
|
+
export interface ModalLayoutOptions {
|
|
66
73
|
}
|
|
67
74
|
/**
|
|
68
75
|
* The error used when a registered modal dialog crashed.
|
|
@@ -121,6 +128,7 @@ export interface ModalRegistration extends BaseRegistration {
|
|
|
121
128
|
name: string;
|
|
122
129
|
component: WrappedComponent<ModalComponentProps<any>>;
|
|
123
130
|
defaults: any;
|
|
131
|
+
layout: ModalLayoutOptions;
|
|
124
132
|
}
|
|
125
133
|
export interface BaseModalOptions {
|
|
126
134
|
}
|
|
@@ -145,8 +153,9 @@ export interface PiletModalsApi {
|
|
|
145
153
|
* @param name The name of the modal to register.
|
|
146
154
|
* @param Component The component to render the page.
|
|
147
155
|
* @param defaults Optionally, sets the default values for the inserted options.
|
|
156
|
+
* @param layout Optionally, sets the layout options for the dialog wrapper.
|
|
148
157
|
*/
|
|
149
|
-
registerModal<T>(name: T extends string ? T : string, Component: AnyComponent<ModalComponentProps<T>>, defaults?: ModalOptions<T
|
|
158
|
+
registerModal<T>(name: T extends string ? T : string, Component: AnyComponent<ModalComponentProps<T>>, defaults?: ModalOptions<T>, layout?: ModalLayoutOptions): RegistrationDisposer;
|
|
150
159
|
/**
|
|
151
160
|
* Unregisters a modal by its name.
|
|
152
161
|
* @param name The name that was previously registered.
|
package/lib/Modals.js
CHANGED
|
@@ -25,10 +25,11 @@ const Modals = () => {
|
|
|
25
25
|
const reg = modals[n.name] || findModal(modals, n.alternative);
|
|
26
26
|
const Component = reg && reg.component;
|
|
27
27
|
const defaults = reg && reg.defaults;
|
|
28
|
-
|
|
29
|
-
|
|
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 }))));
|
|
30
31
|
})
|
|
31
|
-
.filter(
|
|
32
|
+
.filter(Boolean);
|
|
32
33
|
const open = children.length > 0;
|
|
33
34
|
return (React.createElement(components_1.PiralModalsHost, { open: open, close: close }, children));
|
|
34
35
|
};
|
package/lib/Modals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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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AC,CAAC,OAAO,CACb,CAAC;QACF,OAAO,CACL,SAAS,IAAI,CACX,oBAAC,8BAAiB,oBAAK,CAAC,IAAE,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,4BAAe,IAAC,IAAI,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/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.
|
package/lib/create.js
CHANGED
|
@@ -7,12 +7,13 @@ const default_1 = require("./default");
|
|
|
7
7
|
const Modals_1 = require("./Modals");
|
|
8
8
|
function getModalDialogs(dialogs) {
|
|
9
9
|
const modals = {};
|
|
10
|
-
for (const { name, component, defaults } of dialogs) {
|
|
10
|
+
for (const { name, component, defaults, layout = {} } of dialogs) {
|
|
11
11
|
modals[`global-${name}`] = {
|
|
12
12
|
pilet: undefined,
|
|
13
13
|
name,
|
|
14
14
|
component,
|
|
15
15
|
defaults,
|
|
16
|
+
layout,
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
return modals;
|
|
@@ -45,13 +46,14 @@ function createModalsApi(config = {}) {
|
|
|
45
46
|
context.openModal(dialog);
|
|
46
47
|
return dialog.close;
|
|
47
48
|
},
|
|
48
|
-
registerModal(name, arg, defaults) {
|
|
49
|
+
registerModal(name, arg, defaults, layout = {}) {
|
|
49
50
|
const id = (0, piral_core_1.buildName)(pilet, name);
|
|
50
51
|
context.registerModal(id, {
|
|
51
52
|
pilet,
|
|
52
53
|
name,
|
|
53
54
|
component: (0, piral_core_1.withApi)(context, arg, api, 'modal'),
|
|
54
55
|
defaults,
|
|
56
|
+
layout,
|
|
55
57
|
});
|
|
56
58
|
return () => api.unregisterModal(name);
|
|
57
59
|
},
|
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;
|
|
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,M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AE,QAAQ,CAAC,IAAI,CAAC;wBAClB,IAAI;wBACJ,WAAW,EAAE,UAAU;wBACvB,OAAO;wBACP,KAAK;4BACH,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;wBAClD,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,IAAA,sBAAS,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE;wBACxB,KAAK;wBACL,IAAI;wBACJ,SAAS,EAAE,IAAA,oBAAO,EAAC,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,IAAA,sBAAS,EAAC,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;AA5CD,0CA4CC"}
|
package/lib/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 } 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
|
}
|
|
@@ -63,6 +63,13 @@ export interface ModalsHostProps {
|
|
|
63
63
|
close(): void;
|
|
64
64
|
}
|
|
65
65
|
export interface ModalsDialogProps extends OpenModalDialog {
|
|
66
|
+
layout: ModalLayoutOptions;
|
|
67
|
+
defaults: any;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The options provided for the dialog layout.
|
|
71
|
+
*/
|
|
72
|
+
export interface ModalLayoutOptions {
|
|
66
73
|
}
|
|
67
74
|
/**
|
|
68
75
|
* The error used when a registered modal dialog crashed.
|
|
@@ -121,6 +128,7 @@ export interface ModalRegistration extends BaseRegistration {
|
|
|
121
128
|
name: string;
|
|
122
129
|
component: WrappedComponent<ModalComponentProps<any>>;
|
|
123
130
|
defaults: any;
|
|
131
|
+
layout: ModalLayoutOptions;
|
|
124
132
|
}
|
|
125
133
|
export interface BaseModalOptions {
|
|
126
134
|
}
|
|
@@ -145,8 +153,9 @@ export interface PiletModalsApi {
|
|
|
145
153
|
* @param name The name of the modal to register.
|
|
146
154
|
* @param Component The component to render the page.
|
|
147
155
|
* @param defaults Optionally, sets the default values for the inserted options.
|
|
156
|
+
* @param layout Optionally, sets the layout options for the dialog wrapper.
|
|
148
157
|
*/
|
|
149
|
-
registerModal<T>(name: T extends string ? T : string, Component: AnyComponent<ModalComponentProps<T>>, defaults?: ModalOptions<T
|
|
158
|
+
registerModal<T>(name: T extends string ? T : string, Component: AnyComponent<ModalComponentProps<T>>, defaults?: ModalOptions<T>, layout?: ModalLayoutOptions): RegistrationDisposer;
|
|
150
159
|
/**
|
|
151
160
|
* Unregisters a modal by its name.
|
|
152
161
|
* @param name The name that was previously registered.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-modals",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.21",
|
|
4
4
|
"description": "Plugin for the display of modal dialogs in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"piral-core": "^0.14.
|
|
44
|
+
"piral-core": "^0.14.21"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"piral-core": "0.14.x"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "28d12711859b01c425da9242f08b6a7270cc3686"
|
|
50
50
|
}
|
package/src/Modals.tsx
CHANGED
|
@@ -28,21 +28,19 @@ export const Modals: React.FC = () => {
|
|
|
28
28
|
const reg = modals[n.name] || findModal(modals, n.alternative);
|
|
29
29
|
const Component = reg && reg.component;
|
|
30
30
|
const defaults = reg && reg.defaults;
|
|
31
|
+
const options = {
|
|
32
|
+
...defaults,
|
|
33
|
+
...n.options,
|
|
34
|
+
};
|
|
31
35
|
return (
|
|
32
36
|
Component && (
|
|
33
|
-
<PiralModalsDialog {...n} key={n.name}>
|
|
34
|
-
<Component
|
|
35
|
-
onClose={n.close}
|
|
36
|
-
options={{
|
|
37
|
-
...defaults,
|
|
38
|
-
...n.options,
|
|
39
|
-
}}
|
|
40
|
-
/>
|
|
37
|
+
<PiralModalsDialog {...n} options={options} defaults={reg.defaults} layout={reg.layout} key={n.name}>
|
|
38
|
+
<Component onClose={n.close} options={options} />
|
|
41
39
|
</PiralModalsDialog>
|
|
42
40
|
)
|
|
43
41
|
);
|
|
44
42
|
})
|
|
45
|
-
.filter(
|
|
43
|
+
.filter(Boolean);
|
|
46
44
|
const open = children.length > 0;
|
|
47
45
|
|
|
48
46
|
return (
|
package/src/create.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ComponentType } from 'react';
|
|
|
3
3
|
import { withApi, buildName, PiralPlugin, Dict, withRootExtension, withAll, GlobalState } from 'piral-core';
|
|
4
4
|
import { DefaultHost, DefaultDialog } from './default';
|
|
5
5
|
import { Modals } from './Modals';
|
|
6
|
-
import { PiletModalsApi, ModalRegistration, BareModalComponentProps } from './types';
|
|
6
|
+
import { PiletModalsApi, ModalRegistration, BareModalComponentProps, ModalLayoutOptions } from './types';
|
|
7
7
|
|
|
8
8
|
export interface InitialModalDialog {
|
|
9
9
|
/**
|
|
@@ -17,7 +17,11 @@ export interface InitialModalDialog {
|
|
|
17
17
|
/**
|
|
18
18
|
* The default options for the modal dialog.
|
|
19
19
|
*/
|
|
20
|
-
defaults
|
|
20
|
+
defaults?: any;
|
|
21
|
+
/**
|
|
22
|
+
* The layout options for the modal dialog.
|
|
23
|
+
*/
|
|
24
|
+
layout?: ModalLayoutOptions;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
|
@@ -40,12 +44,13 @@ export interface ModalsConfig {
|
|
|
40
44
|
function getModalDialogs(dialogs: Array<InitialModalDialog>) {
|
|
41
45
|
const modals: Dict<ModalRegistration> = {};
|
|
42
46
|
|
|
43
|
-
for (const { name, component, defaults } of dialogs) {
|
|
47
|
+
for (const { name, component, defaults, layout = {} } of dialogs) {
|
|
44
48
|
modals[`global-${name}`] = {
|
|
45
49
|
pilet: undefined,
|
|
46
50
|
name,
|
|
47
51
|
component,
|
|
48
52
|
defaults,
|
|
53
|
+
layout,
|
|
49
54
|
};
|
|
50
55
|
}
|
|
51
56
|
|
|
@@ -97,13 +102,14 @@ export function createModalsApi(config: ModalsConfig = {}): PiralPlugin<PiletMod
|
|
|
97
102
|
context.openModal(dialog);
|
|
98
103
|
return dialog.close;
|
|
99
104
|
},
|
|
100
|
-
registerModal(name, arg, defaults) {
|
|
105
|
+
registerModal(name, arg, defaults, layout = {}) {
|
|
101
106
|
const id = buildName(pilet, name);
|
|
102
107
|
context.registerModal(id, {
|
|
103
108
|
pilet,
|
|
104
109
|
name,
|
|
105
110
|
component: withApi(context, arg, api, 'modal'),
|
|
106
111
|
defaults,
|
|
112
|
+
layout,
|
|
107
113
|
});
|
|
108
114
|
return () => api.unregisterModal(name);
|
|
109
115
|
},
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type {
|
|
3
3
|
Dict,
|
|
4
4
|
WrappedComponent,
|
|
5
5
|
BaseComponentProps,
|
|
@@ -77,7 +77,15 @@ export interface ModalsHostProps {
|
|
|
77
77
|
close(): void;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export interface ModalsDialogProps extends OpenModalDialog {
|
|
80
|
+
export interface ModalsDialogProps extends OpenModalDialog {
|
|
81
|
+
layout: ModalLayoutOptions;
|
|
82
|
+
defaults: any;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The options provided for the dialog layout.
|
|
87
|
+
*/
|
|
88
|
+
export interface ModalLayoutOptions {}
|
|
81
89
|
|
|
82
90
|
/**
|
|
83
91
|
* The error used when a registered modal dialog crashed.
|
|
@@ -139,6 +147,7 @@ export interface ModalRegistration extends BaseRegistration {
|
|
|
139
147
|
name: string;
|
|
140
148
|
component: WrappedComponent<ModalComponentProps<any>>;
|
|
141
149
|
defaults: any;
|
|
150
|
+
layout: ModalLayoutOptions;
|
|
142
151
|
}
|
|
143
152
|
|
|
144
153
|
export interface BaseModalOptions {}
|
|
@@ -170,11 +179,13 @@ export interface PiletModalsApi {
|
|
|
170
179
|
* @param name The name of the modal to register.
|
|
171
180
|
* @param Component The component to render the page.
|
|
172
181
|
* @param defaults Optionally, sets the default values for the inserted options.
|
|
182
|
+
* @param layout Optionally, sets the layout options for the dialog wrapper.
|
|
173
183
|
*/
|
|
174
184
|
registerModal<T>(
|
|
175
185
|
name: T extends string ? T : string,
|
|
176
186
|
Component: AnyComponent<ModalComponentProps<T>>,
|
|
177
187
|
defaults?: ModalOptions<T>,
|
|
188
|
+
layout?: ModalLayoutOptions,
|
|
178
189
|
): RegistrationDisposer;
|
|
179
190
|
/**
|
|
180
191
|
* Unregisters a modal by its name.
|