@gustavo-valsechi/client 1.4.159 → 1.4.160
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.
|
@@ -42,14 +42,28 @@ const memory = [];
|
|
|
42
42
|
const ModalProviderContainer = ({ children }) => {
|
|
43
43
|
const [modals, setModals] = (0, import_react.useState)([]);
|
|
44
44
|
const add = (modal) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const addModal = (config) => {
|
|
46
|
+
if (import_lodash.default.some(memory, (data) => data.name === config.name)) return;
|
|
47
|
+
memory.push(config);
|
|
48
|
+
setModals(memory);
|
|
49
|
+
};
|
|
50
|
+
if (import_lodash.default.isArray(modal)) {
|
|
51
|
+
import_lodash.default.forEach(modal, (config) => addModal(config));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
addModal(modal);
|
|
48
55
|
};
|
|
49
56
|
const remove = (modalName) => {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
const removeModal = (name) => {
|
|
58
|
+
const index = import_lodash.default.findIndex(memory, (data) => data.name === name);
|
|
59
|
+
memory.slice(index, 1);
|
|
60
|
+
setModals(memory);
|
|
61
|
+
};
|
|
62
|
+
if (import_lodash.default.isArray(modalName)) {
|
|
63
|
+
import_lodash.default.forEach(modalName, (name) => removeModal(name));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
removeModal(modalName);
|
|
53
67
|
};
|
|
54
68
|
const setProps = (modalName, props) => {
|
|
55
69
|
const index = import_lodash.default.findIndex(modals, (modal) => modal.name === modalName);
|
|
@@ -8,14 +8,28 @@ const memory = [];
|
|
|
8
8
|
const ModalProviderContainer = ({ children }) => {
|
|
9
9
|
const [modals, setModals] = useState([]);
|
|
10
10
|
const add = (modal) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const addModal = (config) => {
|
|
12
|
+
if (_.some(memory, (data) => data.name === config.name)) return;
|
|
13
|
+
memory.push(config);
|
|
14
|
+
setModals(memory);
|
|
15
|
+
};
|
|
16
|
+
if (_.isArray(modal)) {
|
|
17
|
+
_.forEach(modal, (config) => addModal(config));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
addModal(modal);
|
|
14
21
|
};
|
|
15
22
|
const remove = (modalName) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
const removeModal = (name) => {
|
|
24
|
+
const index = _.findIndex(memory, (data) => data.name === name);
|
|
25
|
+
memory.slice(index, 1);
|
|
26
|
+
setModals(memory);
|
|
27
|
+
};
|
|
28
|
+
if (_.isArray(modalName)) {
|
|
29
|
+
_.forEach(modalName, (name) => removeModal(name));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
removeModal(modalName);
|
|
19
33
|
};
|
|
20
34
|
const setProps = (modalName, props) => {
|
|
21
35
|
const index = _.findIndex(modals, (modal) => modal.name === modalName);
|
|
@@ -8,8 +8,8 @@ export interface IModalConfig {
|
|
|
8
8
|
props?: IModal;
|
|
9
9
|
}
|
|
10
10
|
export interface IModalContext {
|
|
11
|
-
add: (config: IModalConfig) => void;
|
|
12
|
-
remove: (modalName: string) => void;
|
|
11
|
+
add: (config: IModalConfig | IModalConfig[]) => void;
|
|
12
|
+
remove: (modalName: string | string[]) => void;
|
|
13
13
|
setProps: (modalName: string, props: IModal) => void;
|
|
14
14
|
toggle: (modalName: string) => void;
|
|
15
15
|
}
|