@gustavo-valsechi/client 1.4.159 → 1.4.161

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
- if (import_lodash.default.some(memory, (data) => data.name === modal.name)) return;
46
- memory.push(modal);
47
- setModals(memory);
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 index = import_lodash.default.findIndex(memory, (data) => data.name === modalName);
51
- memory.slice(index, 1);
52
- setModals(memory);
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);
@@ -65,6 +79,7 @@ const ModalProviderContainer = ({ children }) => {
65
79
  if (!content) return;
66
80
  setProps(modalName, { toggle: !((_a = content == null ? void 0 : content.props) == null ? void 0 : _a.toggle) });
67
81
  };
82
+ console.log(modals);
68
83
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
69
84
  ModalContext.Provider,
70
85
  {
@@ -8,14 +8,28 @@ const memory = [];
8
8
  const ModalProviderContainer = ({ children }) => {
9
9
  const [modals, setModals] = useState([]);
10
10
  const add = (modal) => {
11
- if (_.some(memory, (data) => data.name === modal.name)) return;
12
- memory.push(modal);
13
- setModals(memory);
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 index = _.findIndex(memory, (data) => data.name === modalName);
17
- memory.slice(index, 1);
18
- setModals(memory);
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);
@@ -31,6 +45,7 @@ const ModalProviderContainer = ({ children }) => {
31
45
  if (!content) return;
32
46
  setProps(modalName, { toggle: !((_a = content == null ? void 0 : content.props) == null ? void 0 : _a.toggle) });
33
47
  };
48
+ console.log(modals);
34
49
  return /* @__PURE__ */ jsxs(
35
50
  ModalContext.Provider,
36
51
  {
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.159",
3
+ "version": "1.4.161",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",