piral-modals 0.14.3-beta.3303 → 0.14.4
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/create.js +6 -2
- package/esm/create.js.map +1 -1
- package/lib/create.js +5 -1
- package/lib/create.js.map +1 -1
- package/package.json +3 -3
- package/src/create.test.ts +5 -1
- package/src/create.ts +19 -14
package/esm/create.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as actions from './actions';
|
|
2
|
-
import { withApi, buildName } from 'piral-core';
|
|
2
|
+
import { withApi, buildName, withRootExtension, withAll } from 'piral-core';
|
|
3
3
|
import { DefaultHost, DefaultDialog } from './default';
|
|
4
|
+
import { Modals } from './Modals';
|
|
4
5
|
function getModalDialogs(dialogs) {
|
|
5
6
|
const modals = {};
|
|
6
7
|
for (const { name, component, defaults } of dialogs) {
|
|
@@ -13,6 +14,9 @@ function getModalDialogs(dialogs) {
|
|
|
13
14
|
}
|
|
14
15
|
return modals;
|
|
15
16
|
}
|
|
17
|
+
function withModals(modals) {
|
|
18
|
+
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: [] }));
|
|
19
|
+
}
|
|
16
20
|
/**
|
|
17
21
|
* Creates new Pilet API extensions for support modal dialogs.
|
|
18
22
|
*/
|
|
@@ -20,7 +24,7 @@ export function createModalsApi(config = {}) {
|
|
|
20
24
|
const { dialogs = [], selectId = (name) => `${name}-${~~(Math.random() * 10000)}` } = config;
|
|
21
25
|
return (context) => {
|
|
22
26
|
context.defineActions(actions);
|
|
23
|
-
context.dispatch((
|
|
27
|
+
context.dispatch(withAll(withModals(getModalDialogs(dialogs)), withRootExtension('piral-modals', Modals)));
|
|
24
28
|
return (api, target) => {
|
|
25
29
|
const pilet = target.name;
|
|
26
30
|
return {
|
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,MAAM,YAAY,CAAC;
|
|
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;AAmClC,SAAS,eAAe,CAAC,OAAkC;IACzD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,OAAO,EAAE;QACnD,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,GAAG;YACzB,KAAK,EAAE,SAAS;YAChB,IAAI;YACJ,SAAS;YACT,QAAQ;SACT,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,EAAE,IACV,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB,EAAE;IACvD,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CA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C,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/create.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.createModalsApi = void 0;
|
|
|
4
4
|
const actions = require("./actions");
|
|
5
5
|
const piral_core_1 = require("piral-core");
|
|
6
6
|
const default_1 = require("./default");
|
|
7
|
+
const Modals_1 = require("./Modals");
|
|
7
8
|
function getModalDialogs(dialogs) {
|
|
8
9
|
const modals = {};
|
|
9
10
|
for (const { name, component, defaults } of dialogs) {
|
|
@@ -16,6 +17,9 @@ function getModalDialogs(dialogs) {
|
|
|
16
17
|
}
|
|
17
18
|
return modals;
|
|
18
19
|
}
|
|
20
|
+
function withModals(modals) {
|
|
21
|
+
return (state) => (Object.assign(Object.assign({}, state), { components: Object.assign({ ModalsHost: default_1.DefaultHost, ModalsDialog: default_1.DefaultDialog }, state.components), registry: Object.assign(Object.assign({}, state.registry), { modals }), modals: [] }));
|
|
22
|
+
}
|
|
19
23
|
/**
|
|
20
24
|
* Creates new Pilet API extensions for support modal dialogs.
|
|
21
25
|
*/
|
|
@@ -23,7 +27,7 @@ function createModalsApi(config = {}) {
|
|
|
23
27
|
const { dialogs = [], selectId = (name) => `${name}-${~~(Math.random() * 10000)}` } = config;
|
|
24
28
|
return (context) => {
|
|
25
29
|
context.defineActions(actions);
|
|
26
|
-
context.dispatch((
|
|
30
|
+
context.dispatch((0, piral_core_1.withAll)(withModals(getModalDialogs(dialogs)), (0, piral_core_1.withRootExtension)('piral-modals', Modals_1.Modals)));
|
|
27
31
|
return (api, target) => {
|
|
28
32
|
const pilet = target.name;
|
|
29
33
|
return {
|
package/lib/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AAErC,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AAErC,2CAA4G;AAC5G,uCAAuD;AACvD,qCAAkC;AAmClC,SAAS,eAAe,CAAC,OAAkC;IACzD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,OAAO,EAAE;QACnD,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,GAAG;YACzB,KAAK,EAAE,SAAS;YAChB,IAAI;YACJ,SAAS;YACT,QAAQ;SACT,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,qBAAW,EACvB,YAAY,EAAE,uBAAa,IACxB,KAAK,CAAC,UAAU,GAErB,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,MAAM,KAER,MAAM,EAAE,EAAE,IACV,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,SAAuB,EAAE;IACvD,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC;IAE7F,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAE/B,OAAO,CAAC,QAAQ,CAAC,IAAA,oBAAO,EAAC,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAA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,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA3CD,0CA2CC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-modals",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
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.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"piral-core": "0.14.x"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "18c4b414ae4643486c44c057662fd5e4f04bf265"
|
|
50
50
|
}
|
package/src/create.test.ts
CHANGED
|
@@ -6,7 +6,11 @@ const StubComponent: FC = (props) => createElement('div', props);
|
|
|
6
6
|
StubComponent.displayName = 'StubComponent';
|
|
7
7
|
|
|
8
8
|
function createMockContainer() {
|
|
9
|
-
const state = Atom.of({
|
|
9
|
+
const state = Atom.of({
|
|
10
|
+
registry: {
|
|
11
|
+
extensions: {},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
10
14
|
return {
|
|
11
15
|
context: {
|
|
12
16
|
on: jest.fn(),
|
package/src/create.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as actions from './actions';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
|
-
import { withApi, buildName, PiralPlugin, Dict } from 'piral-core';
|
|
3
|
+
import { withApi, buildName, PiralPlugin, Dict, withRootExtension, withAll, GlobalState } from 'piral-core';
|
|
4
4
|
import { DefaultHost, DefaultDialog } from './default';
|
|
5
|
+
import { Modals } from './Modals';
|
|
5
6
|
import { PiletModalsApi, ModalRegistration, BareModalComponentProps } from './types';
|
|
6
7
|
|
|
7
8
|
export interface InitialModalDialog {
|
|
@@ -51,6 +52,22 @@ function getModalDialogs(dialogs: Array<InitialModalDialog>) {
|
|
|
51
52
|
return modals;
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
function withModals(modals: Dict<ModalRegistration>) {
|
|
56
|
+
return (state: GlobalState): GlobalState => ({
|
|
57
|
+
...state,
|
|
58
|
+
components: {
|
|
59
|
+
ModalsHost: DefaultHost,
|
|
60
|
+
ModalsDialog: DefaultDialog,
|
|
61
|
+
...state.components,
|
|
62
|
+
},
|
|
63
|
+
registry: {
|
|
64
|
+
...state.registry,
|
|
65
|
+
modals,
|
|
66
|
+
},
|
|
67
|
+
modals: [],
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
54
71
|
/**
|
|
55
72
|
* Creates new Pilet API extensions for support modal dialogs.
|
|
56
73
|
*/
|
|
@@ -60,19 +77,7 @@ export function createModalsApi(config: ModalsConfig = {}): PiralPlugin<PiletMod
|
|
|
60
77
|
return (context) => {
|
|
61
78
|
context.defineActions(actions);
|
|
62
79
|
|
|
63
|
-
context.dispatch((
|
|
64
|
-
...state,
|
|
65
|
-
components: {
|
|
66
|
-
ModalsHost: DefaultHost,
|
|
67
|
-
ModalsDialog: DefaultDialog,
|
|
68
|
-
...state.components,
|
|
69
|
-
},
|
|
70
|
-
registry: {
|
|
71
|
-
...state.registry,
|
|
72
|
-
modals: getModalDialogs(dialogs),
|
|
73
|
-
},
|
|
74
|
-
modals: [],
|
|
75
|
-
}));
|
|
80
|
+
context.dispatch(withAll(withModals(getModalDialogs(dialogs)), withRootExtension('piral-modals', Modals)));
|
|
76
81
|
|
|
77
82
|
return (api, target) => {
|
|
78
83
|
const pilet = target.name;
|