react-native-fxdialog 1.0.0-beta04 → 1.0.0-beta06

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/FXDialog.d.ts CHANGED
@@ -1,17 +1,22 @@
1
- import { FXDialogAnimationType, FXDialogAction, FXDialogTitle, FXDialogMessage, FXDialogCustomView, FXDialogCloseType, FXDialogController, FXDialogAnimationImpl } from "./types";
1
+ import { FXDialogViewProps } from "./FXDialogView";
2
+ import { FXDialogAnimationType, FXDialogAction, FXDialogTitle, FXDialogMessage, FXDialogCustomContent, FXDialogCloseType, FXDialogController, FXDialogAnimationImpl, FXDialogUpdateConfig, FXDialogQueueItem, FXDialogContent } from "./types";
3
+ import { FXDialogStyleInterceptor } from "./style/FXDialogStyleInterceptor";
4
+ import { FXDialogAnimation } from "./animation/FXDialogAnimation";
2
5
  import { ViewStyle } from "react-native";
6
+ import React from "react";
3
7
  /**
4
8
  * Dialog 构建器
5
9
  */
6
10
  declare class FXDialog {
7
- private _fxViewId?;
8
- private _priority;
9
- private _didShow?;
10
- private _didClose?;
11
- private _queueItem;
12
- private _enqueue;
13
- private viewDefaultAnimation;
14
- private viewConfiguration;
11
+ protected _fxViewId?: string;
12
+ protected _priority: number;
13
+ protected _didShow?: () => void;
14
+ protected _didClose?: (closeType?: FXDialogCloseType) => void;
15
+ protected _queueItem: FXDialogQueueItem | null;
16
+ protected _enqueue: boolean;
17
+ protected _viewDefaultAnimation: FXDialogAnimation;
18
+ protected _viewConfiguration: FXDialogViewProps;
19
+ protected _styleInterceptor: FXDialogStyleInterceptor;
15
20
  /**
16
21
  * 设置弹窗类型
17
22
  */
@@ -34,20 +39,48 @@ declare class FXDialog {
34
39
  /**
35
40
  * 添加自定义视图
36
41
  */
37
- addCustom(view: FXDialogCustomView): this;
42
+ addCustom(view: FXDialogCustomContent): this;
43
+ /**
44
+ * 添加背景,有默认样式,默认铺满overlay,position: "absolute",传进来的组件带style,会合并默认样式
45
+ * 注意:这里设置style属性最好不要设置布局相关的样式,比如宽高、margin、padding, top/left/right/bottom 等,这些设置不管用,会被默认样式覆盖
46
+ * @param view 自定义背景组件
47
+ */
48
+ appendBackground(view: React.ReactNode): this;
38
49
  /**
39
50
  * 设置点击背景是否关闭
40
51
  */
41
52
  clickBackgroundClose(enable: boolean): this;
53
+ /**
54
+ * 设置背景样式
55
+ */
56
+ backgroundStyle(style: ViewStyle): this;
57
+ /**
58
+ * 添加容器背景,有默认样式,默认铺满container,position: "absolute",传进来的组件带style,会合并默认样式
59
+ * 注意:这里设置style属性最好不要设置布局相关的样式,比如宽高、margin、padding, top/left/right/bottom 等,这些设置不管用,会被默认样式覆盖
60
+ * @param view 自定义容器背景组件
61
+ */
62
+ appendContainer(view: React.ReactNode): this;
42
63
  /**
43
64
  * 设置容器样式
44
65
  */
45
66
  containerStyle(style: ViewStyle): this;
46
67
  /**
47
- * 添加背景样式
68
+ * 设置内容区域容器样式 除按钮外的内容区域样式
69
+ */
70
+ contentsContainerStyle(style: ViewStyle): this;
71
+ /**
72
+ * 设置按钮区样式
73
+ */
74
+ actionsContainerStyle(style: ViewStyle): this;
75
+ /**
76
+ * 设置弹窗显示动画时长
77
+ * @param duration 动画时长 ms
48
78
  */
49
- backgroundStyle(style: ViewStyle): this;
50
79
  showAnimationDuration(duration: number): this;
80
+ /**
81
+ * 设置弹窗关闭动画时长
82
+ * @param duration 动画时长 ms
83
+ */
51
84
  closeAnimationDuration(duration: number): this;
52
85
  /**
53
86
  * 设置动画:支持传入内置类型
@@ -63,7 +96,7 @@ declare class FXDialog {
63
96
  */
64
97
  containerScrollMaxHeight(maxHeight: number): this;
65
98
  /**
66
- * 设置按钮区最小高度
99
+ * 设置弹窗需要滚动时按钮区最小高度
67
100
  * @param minHeight 最小高度
68
101
  */
69
102
  actionsScrollMinHeight(minHeight: number): this;
@@ -94,6 +127,25 @@ declare class FXDialog {
94
127
  * 设置关闭回调
95
128
  */
96
129
  didClose(callback: (closeType?: FXDialogCloseType) => void): this;
130
+ /**
131
+ * 更新弹窗内容
132
+ * @param updates 要更新的内容
133
+ */
134
+ protected update(updates: FXDialogUpdateConfig): void;
135
+ /**
136
+ * 更新弹窗内容
137
+ * @param update 要更新的内容,通过id匹配
138
+ */
139
+ protected updateContent(update: FXDialogContent): void;
140
+ /**
141
+ * 更新操作按钮
142
+ * @param actions 要更新的操作按钮,通过id匹配
143
+ */
144
+ protected updateAction(update: FXDialogAction): void;
145
+ protected updateBackgroundStyle(style: ViewStyle): void;
146
+ protected updateContainerStyle(style: ViewStyle): void;
147
+ protected updateContentsContainerStyle(style: ViewStyle): void;
148
+ protected updateActionsContainerStyle(style: ViewStyle): void;
97
149
  /**
98
150
  * 显示弹窗
99
151
  */
@@ -101,12 +153,7 @@ declare class FXDialog {
101
153
  /**
102
154
  * 触发关闭,关闭弹窗, 转发给 DialogManager
103
155
  */
104
- private close;
105
- /**
106
- * 更新弹窗内容
107
- * @param updates 要更新的内容
108
- */
109
- private update;
156
+ protected close(closeType?: FXDialogCloseType): void;
110
157
  /**
111
158
  * 静态函数关闭弹窗,关闭的是最近展示出来的那个。触发关闭弹窗,并不是关闭完成。转发给 DialogManager
112
159
  * @param fxViewId 可选,指定要关闭的弹窗的 fxViewId
package/FXDialog.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"FXDialog.d.ts","sourceRoot":"","sources":["FXDialog.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,qBAAqB,EACrB,cAAc,EAGd,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAElB,qBAAqB,EAGtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AACH,cAAM,QAAQ;IAEZ,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,SAAS,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C,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI;IA6ClD;;OAEG;IACH,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,iBAAiB;IAU7C;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,iBAAiB;IAW7D;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM;CAIjC;AAED,eAAe,QAAQ,CAAC"}
package/FXDialog.js CHANGED
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const types_1 = require("./types");
7
+ const FXDialogStyleInterceptor_1 = require("./style/FXDialogStyleInterceptor");
7
8
  const FXDialogManager_1 = __importDefault(require("./FXDialogManager"));
8
9
  const FXDialogAnimation_1 = require("./animation/FXDialogAnimation");
9
10
  const react_native_fxview_1 = require("react-native-fxview");
@@ -16,12 +17,14 @@ class FXDialog {
16
17
  // 队列项 调用 show() 时生成,show 之前是 null
17
18
  this._queueItem = null;
18
19
  this._enqueue = false;
19
- this.viewDefaultAnimation = new FXDialogAnimation_1.FXDialogAnimation(types_1.FXDialogAnimationType.Scale, 300, 200);
20
- this.viewConfiguration = {
20
+ this._viewDefaultAnimation = new FXDialogAnimation_1.FXDialogAnimation(types_1.FXDialogAnimationType.Scale, 300, 200);
21
+ this._viewConfiguration = {
21
22
  type: types_1.FXDialogType.Alert,
22
23
  closeOnClickBackground: true,
23
- elements: [],
24
+ contents: [],
25
+ actions: [],
24
26
  };
27
+ this._styleInterceptor = FXDialogStyleInterceptor_1.FXDialogStyleInterceptorChain;
25
28
  }
26
29
  /**
27
30
  * 设置弹窗类型
@@ -36,9 +39,9 @@ class FXDialog {
36
39
  return this.createDialog(types_1.FXDialogType.Popup, types_1.FXDialogAnimationType.SlideUp);
37
40
  }
38
41
  static createDialog(dialogType, animationType) {
39
- const dialog = new FXDialog();
40
- dialog.viewConfiguration.type = dialogType;
41
- dialog.viewDefaultAnimation.animationType =
42
+ const dialog = new this();
43
+ dialog._viewConfiguration.type = dialogType;
44
+ dialog._viewDefaultAnimation.animationType =
42
45
  animationType || types_1.FXDialogAnimationType.Scale;
43
46
  return dialog;
44
47
  }
@@ -48,10 +51,7 @@ class FXDialog {
48
51
  */
49
52
  addTitle(title) {
50
53
  var _a;
51
- (_a = this.viewConfiguration.elements) === null || _a === void 0 ? void 0 : _a.push({
52
- type: types_1.FXDialogElementType.Title,
53
- item: title,
54
- });
54
+ (_a = this._viewConfiguration.contents) === null || _a === void 0 ? void 0 : _a.push(title);
55
55
  return this;
56
56
  }
57
57
  /**
@@ -59,10 +59,7 @@ class FXDialog {
59
59
  */
60
60
  addMessage(message) {
61
61
  var _a;
62
- (_a = this.viewConfiguration.elements) === null || _a === void 0 ? void 0 : _a.push({
63
- type: types_1.FXDialogElementType.Message,
64
- item: message,
65
- });
62
+ (_a = this._viewConfiguration.contents) === null || _a === void 0 ? void 0 : _a.push(message);
66
63
  return this;
67
64
  }
68
65
  /**
@@ -70,10 +67,7 @@ class FXDialog {
70
67
  */
71
68
  addAction(action) {
72
69
  var _a;
73
- (_a = this.viewConfiguration.elements) === null || _a === void 0 ? void 0 : _a.push({
74
- type: types_1.FXDialogElementType.Action,
75
- item: Object.assign(Object.assign({}, action), { type: action.type || types_1.FXDialogActionType.Default }),
76
- });
70
+ (_a = this._viewConfiguration.actions) === null || _a === void 0 ? void 0 : _a.push(action);
77
71
  return this;
78
72
  }
79
73
  /**
@@ -81,46 +75,83 @@ class FXDialog {
81
75
  */
82
76
  addCustom(view) {
83
77
  var _a;
84
- (_a = this.viewConfiguration.elements) === null || _a === void 0 ? void 0 : _a.push({
85
- type: types_1.FXDialogElementType.CustomView,
86
- item: view,
87
- });
78
+ (_a = this._viewConfiguration.contents) === null || _a === void 0 ? void 0 : _a.push(view);
79
+ return this;
80
+ }
81
+ /**
82
+ * 添加背景,有默认样式,默认铺满overlay,position: "absolute",传进来的组件带style,会合并默认样式
83
+ * 注意:这里设置style属性最好不要设置布局相关的样式,比如宽高、margin、padding, top/left/right/bottom 等,这些设置不管用,会被默认样式覆盖
84
+ * @param view 自定义背景组件
85
+ */
86
+ appendBackground(view) {
87
+ this._viewConfiguration.appendBackground = view;
88
88
  return this;
89
89
  }
90
90
  /**
91
91
  * 设置点击背景是否关闭
92
92
  */
93
93
  clickBackgroundClose(enable) {
94
- this.viewConfiguration.closeOnClickBackground = enable;
94
+ this._viewConfiguration.closeOnClickBackground = enable;
95
+ return this;
96
+ }
97
+ /**
98
+ * 设置背景样式
99
+ */
100
+ backgroundStyle(style) {
101
+ this._viewConfiguration.backgroundStyle = Object.assign(Object.assign({}, this._viewConfiguration.backgroundStyle), style);
102
+ return this;
103
+ }
104
+ /**
105
+ * 添加容器背景,有默认样式,默认铺满container,position: "absolute",传进来的组件带style,会合并默认样式
106
+ * 注意:这里设置style属性最好不要设置布局相关的样式,比如宽高、margin、padding, top/left/right/bottom 等,这些设置不管用,会被默认样式覆盖
107
+ * @param view 自定义容器背景组件
108
+ */
109
+ appendContainer(view) {
110
+ this._viewConfiguration.appendContainer = view;
95
111
  return this;
96
112
  }
97
113
  /**
98
114
  * 设置容器样式
99
115
  */
100
116
  containerStyle(style) {
101
- this.viewConfiguration.containerStyle = Object.assign(Object.assign({}, this.viewConfiguration.containerStyle), style);
117
+ this._viewConfiguration.containerStyle = Object.assign(Object.assign({}, this._viewConfiguration.containerStyle), style);
102
118
  return this;
103
119
  }
104
120
  /**
105
- * 添加背景样式
121
+ * 设置内容区域容器样式 除按钮外的内容区域样式
106
122
  */
107
- backgroundStyle(style) {
108
- this.viewConfiguration.backgroundStyle = Object.assign(Object.assign({}, this.viewConfiguration.backgroundStyle), style);
123
+ contentsContainerStyle(style) {
124
+ this._viewConfiguration.contentsContainerStyle = Object.assign(Object.assign({}, this._viewConfiguration.contentsContainerStyle), style);
109
125
  return this;
110
126
  }
127
+ /**
128
+ * 设置按钮区样式
129
+ */
130
+ actionsContainerStyle(style) {
131
+ this._viewConfiguration.actionsContainerStyle = Object.assign(Object.assign({}, this._viewConfiguration.actionsContainerStyle), style);
132
+ return this;
133
+ }
134
+ /**
135
+ * 设置弹窗显示动画时长
136
+ * @param duration 动画时长 ms
137
+ */
111
138
  showAnimationDuration(duration) {
112
- this.viewDefaultAnimation.showDuration = duration;
139
+ this._viewDefaultAnimation.showDuration = duration;
113
140
  return this;
114
141
  }
142
+ /**
143
+ * 设置弹窗关闭动画时长
144
+ * @param duration 动画时长 ms
145
+ */
115
146
  closeAnimationDuration(duration) {
116
- this.viewDefaultAnimation.closeDuration = duration;
147
+ this._viewDefaultAnimation.closeDuration = duration;
117
148
  return this;
118
149
  }
119
150
  /**
120
151
  * 设置动画:支持传入内置类型
121
152
  */
122
153
  animationType(animation) {
123
- this.viewDefaultAnimation.animationType = animation;
154
+ this._viewDefaultAnimation.animationType = animation;
124
155
  return this;
125
156
  }
126
157
  /**
@@ -128,22 +159,22 @@ class FXDialog {
128
159
  * @param animator 自定义动画控制器
129
160
  */
130
161
  animator(animator) {
131
- this.viewConfiguration.animator = animator;
162
+ this._viewConfiguration.animator = animator;
132
163
  return this;
133
164
  }
134
165
  /**
135
166
  * 设置弹窗容器最大高度
136
167
  */
137
168
  containerScrollMaxHeight(maxHeight) {
138
- this.viewConfiguration.containerScrollMaxHeight = maxHeight;
169
+ this._viewConfiguration.containerScrollMaxHeight = maxHeight;
139
170
  return this;
140
171
  }
141
172
  /**
142
- * 设置按钮区最小高度
173
+ * 设置弹窗需要滚动时按钮区最小高度
143
174
  * @param minHeight 最小高度
144
175
  */
145
176
  actionsScrollMinHeight(minHeight) {
146
- this.viewConfiguration.actionsScrollMinHeight = minHeight;
177
+ this._viewConfiguration.actionsScrollMinHeight = minHeight;
147
178
  return this;
148
179
  }
149
180
  /**
@@ -151,7 +182,7 @@ class FXDialog {
151
182
  * @param maxHeight 最大高度
152
183
  */
153
184
  actionsScrollMaxHeight(maxHeight) {
154
- this.viewConfiguration.actionsScrollMaxHeight = maxHeight;
185
+ this._viewConfiguration.actionsScrollMaxHeight = maxHeight;
155
186
  return this;
156
187
  }
157
188
  /**
@@ -188,20 +219,88 @@ class FXDialog {
188
219
  this._didClose = callback;
189
220
  return this;
190
221
  }
222
+ /**
223
+ * 更新弹窗内容
224
+ * @param updates 要更新的内容
225
+ */
226
+ update(updates) {
227
+ try {
228
+ react_native_fxview_1.logger.log("Dialog update", this._fxViewId);
229
+ if (this._queueItem) {
230
+ // 通过引用调用DialogView的update方法(只作用于弹窗层)
231
+ const dialogViewRef = this._queueItem.dialogViewRef;
232
+ react_native_fxview_1.logger.log("[Dialog] update", this._queueItem.dialogViewRef);
233
+ if (dialogViewRef && dialogViewRef.current) {
234
+ dialogViewRef.current.update(updates);
235
+ }
236
+ else {
237
+ react_native_fxview_1.logger.warn("[Dialog] Cannot update: DialogView ref not available");
238
+ }
239
+ }
240
+ else {
241
+ react_native_fxview_1.logger.warn("[Dialog] Cannot update: dialog not shown yet");
242
+ }
243
+ }
244
+ catch (error) {
245
+ react_native_fxview_1.logger.error("[Dialog] Failed to update dialog", error);
246
+ }
247
+ }
248
+ /**
249
+ * 更新弹窗内容
250
+ * @param update 要更新的内容,通过id匹配
251
+ */
252
+ updateContent(update) {
253
+ this.update({
254
+ contents: [update],
255
+ });
256
+ }
257
+ /**
258
+ * 更新操作按钮
259
+ * @param actions 要更新的操作按钮,通过id匹配
260
+ */
261
+ updateAction(update) {
262
+ this.update({
263
+ actions: [update],
264
+ });
265
+ }
266
+ updateBackgroundStyle(style) {
267
+ this.update({
268
+ backgroundStyle: style,
269
+ });
270
+ }
271
+ updateContainerStyle(style) {
272
+ this.update({
273
+ containerStyle: style,
274
+ });
275
+ }
276
+ updateContentsContainerStyle(style) {
277
+ this.update({
278
+ contentsContainerStyle: style,
279
+ });
280
+ }
281
+ updateActionsContainerStyle(style) {
282
+ this.update({
283
+ actionsContainerStyle: style,
284
+ });
285
+ }
191
286
  // region========== 显示方法 ==========
192
287
  /**
193
288
  * 显示弹窗
194
289
  */
195
290
  show(fxViewId) {
196
291
  try {
197
- if (!this.viewConfiguration.animator) {
198
- this.viewConfiguration.animator = this.viewDefaultAnimation;
292
+ if (!this._viewConfiguration.animator) {
293
+ this._viewConfiguration.animator = this._viewDefaultAnimation;
199
294
  }
295
+ if (this._styleInterceptor) {
296
+ this._viewConfiguration = this._styleInterceptor.intercept(this._viewConfiguration);
297
+ }
298
+ react_native_fxview_1.logger.log("Dialog show", this._viewConfiguration);
200
299
  this._queueItem = FXDialogManager_1.default.getInstance().show({
201
300
  fxViewId: fxViewId,
202
301
  priority: this._priority,
203
302
  enqueue: this._enqueue,
204
- dialogProps: this.viewConfiguration,
303
+ dialogProps: this._viewConfiguration,
205
304
  didShow: this._didShow,
206
305
  didClose: this._didClose,
207
306
  });
@@ -214,6 +313,12 @@ class FXDialog {
214
313
  return {
215
314
  close: this.close.bind(this),
216
315
  update: this.update.bind(this),
316
+ updateContent: this.updateContent.bind(this),
317
+ updateAction: this.updateAction.bind(this),
318
+ updateBackgroundStyle: this.updateBackgroundStyle.bind(this),
319
+ updateContainerStyle: this.updateContainerStyle.bind(this),
320
+ updateContentContainerStyle: this.updateContentsContainerStyle.bind(this),
321
+ updateActionsContainerStyle: this.updateActionsContainerStyle.bind(this),
217
322
  fxViewId: () => this._fxViewId,
218
323
  };
219
324
  }
@@ -231,32 +336,6 @@ class FXDialog {
231
336
  FXDialogManager_1.default.getInstance().close(this._queueItem, closeType || types_1.FXDialogCloseSystemType.Custom);
232
337
  }
233
338
  }
234
- /**
235
- * 更新弹窗内容
236
- * @param updates 要更新的内容
237
- */
238
- update(updates) {
239
- try {
240
- react_native_fxview_1.logger.log("Dialog update", this._fxViewId);
241
- if (this._queueItem) {
242
- // 通过引用调用DialogView的update方法(只作用于弹窗层)
243
- const dialogViewRef = this._queueItem.dialogViewRef;
244
- react_native_fxview_1.logger.log("[Dialog] update", this._queueItem.dialogViewRef);
245
- if (dialogViewRef && dialogViewRef.current) {
246
- dialogViewRef.current.update(updates);
247
- }
248
- else {
249
- react_native_fxview_1.logger.warn("[Dialog] Cannot update: DialogView ref not available");
250
- }
251
- }
252
- else {
253
- react_native_fxview_1.logger.warn("[Dialog] Cannot update: dialog not shown yet");
254
- }
255
- }
256
- catch (error) {
257
- react_native_fxview_1.logger.error("[Dialog] Failed to update dialog", error);
258
- }
259
- }
260
339
  /**
261
340
  * 静态函数关闭弹窗,关闭的是最近展示出来的那个。触发关闭弹窗,并不是关闭完成。转发给 DialogManager
262
341
  * @param fxViewId 可选,指定要关闭的弹窗的 fxViewId
package/FXDialogView.d.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  import React, { Component } from "react";
2
2
  import { ViewStyle } from "react-native";
3
- import { FXDialogType, FXDialogAction, FXDialogElement, FXDialogAnimationImpl, FXDialogUpdateConfiguration } from "./types";
3
+ import { FXDialogType, FXDialogAction, FXDialogAnimationImpl, FXDialogUpdateConfig, FXDialogContent } from "./types";
4
4
  export interface FXDialogViewProps {
5
5
  type?: FXDialogType;
6
- elements?: FXDialogElement[];
7
- containerStyle?: ViewStyle;
6
+ contents?: FXDialogContent[];
7
+ actions?: FXDialogAction[];
8
8
  backgroundStyle?: ViewStyle;
9
+ containerStyle?: ViewStyle;
10
+ contentsContainerStyle?: ViewStyle;
11
+ actionsContainerStyle?: ViewStyle;
12
+ appendBackground?: React.ReactNode;
13
+ appendContainer?: React.ReactNode;
9
14
  animator?: FXDialogAnimationImpl;
10
15
  closeOnClickBackground?: boolean;
11
16
  actionsScrollMinHeight?: number;
@@ -22,10 +27,16 @@ interface FXDialogViewState {
22
27
  actionsScrollable: boolean;
23
28
  adjustedContentHeight: number;
24
29
  adjustedActionsHeight: number;
25
- displayElements?: FXDialogElement[];
26
- measureElements?: FXDialogElement[];
30
+ displayContents?: FXDialogContent[];
31
+ displayActions?: FXDialogAction[];
32
+ measureContents?: FXDialogContent[];
33
+ measureActions?: FXDialogAction[];
27
34
  containerStyle?: ViewStyle;
28
35
  backgroundStyle?: ViewStyle;
36
+ contentsContainerStyle?: ViewStyle;
37
+ actionsContainerStyle?: ViewStyle;
38
+ appendBackground?: React.ReactNode;
39
+ appendContainer?: React.ReactNode;
29
40
  }
30
41
  export declare const FXDialogViewDefaultScrollConfig: {
31
42
  layout: {
@@ -47,7 +58,7 @@ export default class FXDialogView extends Component<FXDialogViewProps, FXDialogV
47
58
  componentDidMount(): void;
48
59
  componentWillUnmount(): void;
49
60
  shouldComponentUpdate(nextProps: FXDialogViewProps, nextState: FXDialogViewState): boolean;
50
- update(updates: FXDialogUpdateConfiguration): void;
61
+ update(updates: FXDialogUpdateConfig): void;
51
62
  private handleContentLayout;
52
63
  private handleActionsLayout;
53
64
  private checkIfBothMeasured;
@@ -55,13 +66,18 @@ export default class FXDialogView extends Component<FXDialogViewProps, FXDialogV
55
66
  private calculateScrollState;
56
67
  handleBackdropPress: () => void;
57
68
  handleActionPress: (action: FXDialogAction) => void;
58
- private categorizeElements;
69
+ private categorizeContents;
70
+ private allActions;
59
71
  private renderTitle;
60
72
  private renderMessage;
61
- private renderCustomView;
62
- private renderContentElement;
73
+ private renderCustomContent;
74
+ private renderSingleContent;
75
+ private renderSingleAction;
76
+ renderAppendBackground(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
77
+ renderAppendContainer(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
63
78
  renderActions: (actions: FXDialogAction[]) => React.JSX.Element;
64
- renderContentArea: (elements: FXDialogElement[]) => React.JSX.Element;
79
+ renderContents: (contents: FXDialogContent[]) => React.JSX.Element;
80
+ renderAllArea: (contents: FXDialogContent[], actions: FXDialogAction[]) => React.JSX.Element;
65
81
  render(): React.JSX.Element;
66
82
  }
67
83
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"FXDialogView.d.ts","sourceRoot":"","sources":["FXDialogView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MA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