@gustavo-valsechi/client 1.4.368 → 1.4.370

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.
@@ -68,13 +68,32 @@ const ModalProviderContainer = ({ children }) => {
68
68
  };
69
69
  const setProps = (modalName, props) => {
70
70
  const index = import_lodash.default.findIndex(memory, (modal) => modal.name === modalName);
71
- const content = import_lodash.default.find(memory, (modal) => modal.name === modalName);
72
- if (!content) return;
71
+ const data = import_lodash.default.find(memory, (modal) => modal.name === modalName);
72
+ if (!data) return;
73
+ const newProps = import_lodash.default.isFunction(props) ? props(data) : props;
74
+ memory.splice(index, 1, {
75
+ ...data,
76
+ props: {
77
+ ...data.props,
78
+ ...newProps
79
+ }
80
+ });
81
+ setModals([...memory]);
82
+ };
83
+ const setContent = (modalName, content) => {
84
+ var _a;
85
+ const index = import_lodash.default.findIndex(memory, (modal) => modal.name === modalName);
86
+ const data = import_lodash.default.find(memory, (modal) => modal.name === modalName);
87
+ if (!data) return;
88
+ const newContent = import_lodash.default.isFunction(content) ? content(data) : content;
73
89
  memory.splice(index, 1, {
74
- ...content,
90
+ ...data,
75
91
  props: {
76
- ...content.props,
77
- ...props
92
+ ...data.props,
93
+ content: ((_a = data.props) == null ? void 0 : _a.content) ? {
94
+ ...data.props.content,
95
+ ...newContent
96
+ } : newContent
78
97
  }
79
98
  });
80
99
  setModals([...memory]);
@@ -92,6 +111,7 @@ const ModalProviderContainer = ({ children }) => {
92
111
  add,
93
112
  remove,
94
113
  setProps,
114
+ setContent,
95
115
  toggle
96
116
  },
97
117
  children: [
@@ -34,13 +34,32 @@ const ModalProviderContainer = ({ children }) => {
34
34
  };
35
35
  const setProps = (modalName, props) => {
36
36
  const index = _.findIndex(memory, (modal) => modal.name === modalName);
37
- const content = _.find(memory, (modal) => modal.name === modalName);
38
- if (!content) return;
37
+ const data = _.find(memory, (modal) => modal.name === modalName);
38
+ if (!data) return;
39
+ const newProps = _.isFunction(props) ? props(data) : props;
40
+ memory.splice(index, 1, {
41
+ ...data,
42
+ props: {
43
+ ...data.props,
44
+ ...newProps
45
+ }
46
+ });
47
+ setModals([...memory]);
48
+ };
49
+ const setContent = (modalName, content) => {
50
+ var _a;
51
+ const index = _.findIndex(memory, (modal) => modal.name === modalName);
52
+ const data = _.find(memory, (modal) => modal.name === modalName);
53
+ if (!data) return;
54
+ const newContent = _.isFunction(content) ? content(data) : content;
39
55
  memory.splice(index, 1, {
40
- ...content,
56
+ ...data,
41
57
  props: {
42
- ...content.props,
43
- ...props
58
+ ...data.props,
59
+ content: ((_a = data.props) == null ? void 0 : _a.content) ? {
60
+ ...data.props.content,
61
+ ...newContent
62
+ } : newContent
44
63
  }
45
64
  });
46
65
  setModals([...memory]);
@@ -58,6 +77,7 @@ const ModalProviderContainer = ({ children }) => {
58
77
  add,
59
78
  remove,
60
79
  setProps,
80
+ setContent,
61
81
  toggle
62
82
  },
63
83
  children: [
@@ -10,6 +10,11 @@ export interface IModalConfig {
10
10
  export interface IModalContext {
11
11
  add: (config: IModalConfig | IModalConfig[]) => void;
12
12
  remove: (modalName: string | string[]) => void;
13
- setProps: (modalName: string, props: IModal) => void;
13
+ setProps: (modalName: string, props: IModal | ((props: IModal) => object)) => void;
14
+ setContent: (modalName: string, content: {
15
+ [key: string]: any;
16
+ } | ((props: IModal) => {
17
+ [key: string]: any;
18
+ })) => void;
14
19
  toggle: (modalName: string) => void;
15
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.368",
3
+ "version": "1.4.370",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",